Skip to content

Commit

Permalink
Update the Pusher JS client to version 3.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristandunn committed Sep 1, 2015
1 parent 66cbf8b commit f9029c3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 78 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Warn when Pusher configuration is not set. (Tristan Dunn)
* Update the Pusher JS client to version 3.0.0. (Tristan Dunn)

## 1.4.0 — May 20th, 2015

Expand Down
3 changes: 1 addition & 2 deletions lib/pusher-fake/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def initialize
def to_options(options = {})
options.merge(
wsHost: socket_options[:host],
wsPort: socket_options[:port],
enabledTransports: ["ws"]
wsPort: socket_options[:port]
)
end

Expand Down
6 changes: 0 additions & 6 deletions spec/lib/pusher-fake/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
expect(options).to include(wsPort: subject.socket_options[:port])
end

it "only enables the WebSocket transport" do
options = subject.to_options

expect(options).to include(enabledTransports: ["ws"])
end

it "supports passing custom options" do
options = subject.to_options(custom: "option")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
/*!
* Pusher JavaScript Library v2.2.4
* Pusher JavaScript Library v3.0.0
* http://pusher.com/
*
* Copyright 2014, Pusher
* Released under the MIT licence.
*/

// Uses Node, AMD or browser globals to create a module. This example creates
// a global even when AMD is used. This is useful if you have some scripts
// that are loaded by an AMD loader, but they still want access to globals.
// If you do not need to export a global for the AMD case,
// see returnExports.js.

// If you want something that will work in other stricter CommonJS environments,
// or if you need to create a circular dependency, see commonJsStrictGlobal.js

// Defines a module "Pusher".

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], function () {
return (root.Pusher = factory());
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals
root.Pusher = factory();
}
}(this, function () {

;(function() {
function Pusher(app_key, options) {
checkAppKey(app_key);
Expand Down Expand Up @@ -74,7 +102,7 @@
channel.handleEvent(params.event, params.data);
}
}
// Emit globaly [deprecated]
// Emit globally [deprecated]
if (!internal) {
self.global_emitter.emit(params.event, params.data);
}
Expand Down Expand Up @@ -188,7 +216,7 @@

prototype.unsubscribe = function(channel_name) {
var channel = this.channels.remove(channel_name);
if (this.connection.state === 'connected') {
if (channel && this.connection.state === 'connected') {
channel.unsubscribe();
}
};
Expand Down Expand Up @@ -573,10 +601,6 @@
return document;
},

getNavigator: function() {
return navigator;
},

getLocalStorage: function() {
try {
return window.localStorage;
Expand All @@ -588,7 +612,7 @@
getClientFeatures: function() {
return Pusher.Util.keys(
Pusher.Util.filterObject(
{ "ws": Pusher.WSTransport, "flash": Pusher.FlashTransport },
{ "ws": Pusher.WSTransport },
function (t) { return t.isSupported({}); }
)
);
Expand Down Expand Up @@ -626,7 +650,7 @@
}).call(this);

;(function() {
Pusher.VERSION = '2.2.4';
Pusher.VERSION = '3.0.0';
Pusher.PROTOCOL = 7;

// DEPRECATED: WS connection parameters
Expand Down Expand Up @@ -700,7 +724,6 @@

[":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"],
[":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"],
[":def_transport", "flash", "flash", 2, ":ws_options", ":ws_manager"],
[":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"],
[":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"],
[":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"],
Expand All @@ -709,7 +732,6 @@

[":def", "ws_loop", [":sequential", ":timeouts", ":ws"]],
[":def", "wss_loop", [":sequential", ":timeouts", ":wss"]],
[":def", "flash_loop", [":sequential", ":timeouts", ":flash"]],
[":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]],

[":def", "streaming_loop", [":sequential", ":timeouts",
Expand Down Expand Up @@ -746,13 +768,8 @@
[":first_connected",
[":if", [":is_supported", ":ws"],
wsStrategy,
[":if", [":is_supported", ":flash"], [
":best_connected_ever",
":flash_loop",
[":delayed", 2000, [":http_fallback_loop"]]
], [
":http_fallback_loop"
]]]
]
]
]
]
Expand Down Expand Up @@ -1980,12 +1997,6 @@
return getGenericURL("ws", params, getGenericPath(key, "flash=false"));
}
},
/** URL scheme for Flash. Same as WebSocket, but with a flash parameter. */
flash: {
getInitial: function(key, params) {
return getGenericURL("ws", params, getGenericPath(key, "flash=true"));
}
},
/** SockJS URL scheme. Supplies the path separately from the initial URL. */
sockjs: {
getInitial: function(key, params) {
Expand Down Expand Up @@ -2078,10 +2089,6 @@
transport: self.name + (self.options.encrypted ? "s" : "")
}));

if (self.hooks.beforeInitialize) {
self.hooks.beforeInitialize.call(self);
}

if (self.hooks.isInitialized()) {
self.changeState("initialized");
} else if (self.hooks.file) {
Expand Down Expand Up @@ -2344,45 +2351,6 @@
}
});

/** Flash transport using the WebSocket protocol. */
Pusher.FlashTransport = new Pusher.Transport({
file: "flashfallback",
urls: Pusher.URLSchemes.flash,
handlesActivityChecks: false,
supportsPing: false,

isSupported: function() {
try {
return Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
} catch (e1) {
try {
var nav = Pusher.Util.getNavigator();
return Boolean(
nav &&
nav.mimeTypes &&
nav.mimeTypes["application/x-shockwave-flash"] !== undefined
);
} catch (e2) {
return false;
}
}
},
beforeInitialize: function() {
if (window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR === undefined) {
window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;
}
window.WEB_SOCKET_SWF_LOCATION =
Pusher.Dependencies.getRoot({ encrypted: this.options.encrypted }) +
"/WebSocketMain.swf";
},
isInitialized: function() {
return window.FlashWebSocket !== undefined;
},
getSocket: function(url) {
return new FlashWebSocket(url);
}
});

/** SockJS transport. */
Pusher.SockJSTransport = new Pusher.Transport({
file: "sockjs",
Expand Down Expand Up @@ -2609,7 +2577,6 @@

var transports = {
ws: Pusher.WSTransport,
flash: Pusher.FlashTransport,
sockjs: Pusher.SockJSTransport,
xhr_streaming: Pusher.XHRStreamingTransport,
xdr_streaming: Pusher.XDRStreamingTransport,
Expand Down Expand Up @@ -2665,8 +2632,7 @@
(!context.enabledTransports ||
Pusher.Util.arrayIndexOf(context.enabledTransports, name) !== -1) &&
(!context.disabledTransports ||
Pusher.Util.arrayIndexOf(context.disabledTransports, name) === -1) &&
(name !== "flash" || context.disableFlash !== true);
Pusher.Util.arrayIndexOf(context.disabledTransports, name) === -1);

var transport;
if (enabled) {
Expand Down Expand Up @@ -4013,3 +3979,6 @@
}
};
}).call(this);

return Pusher;
}));
2 changes: 1 addition & 1 deletion spec/support/application/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ul></ul>
</section>

<script src="/javascripts/vendor/pusher-2.2.4.js"></script>
<script src="/javascripts/vendor/pusher-3.0.0.js"></script>
<script>
Pusher.instance = <%= PusherFake.javascript %>;
Pusher.instance.connection.bind("state_change", function(states) {
Expand Down

0 comments on commit f9029c3

Please sign in to comment.