Skip to content

Commit

Permalink
Regenerate and release version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonWoolf committed Mar 13, 2017
1 parent b1f55b1 commit b34b9d1
Show file tree
Hide file tree
Showing 14 changed files with 965 additions and 907 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Javascript client library for [Ably Realtime](https://www.ably.io), a realtime data delivery platform.

## Version: 1.0.0
## Version: 1.0.1

This repo contains the Ably Javascript client library, for the browser (including IE8+), Nodejs, React Native, NativeScript and Cordova.

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Ably",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://www.ably.io/",
"authors": [
"Paddy Byers <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion browser/fragments/license.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Copyright 2017, Ably
*
* Ably JavaScript Library v1.0.0
* Ably JavaScript Library v1.0.1
* https://github.com/ably/ably-js
*
* Ably Realtime Messaging
Expand Down
160 changes: 85 additions & 75 deletions browser/static/ably-commonjs.js

Large diffs are not rendered by default.

160 changes: 85 additions & 75 deletions browser/static/ably-commonjs.noencryption.js

Large diffs are not rendered by default.

117 changes: 63 additions & 54 deletions browser/static/ably-nativescript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Copyright 2017, Ably
*
* Ably JavaScript Library v1.0.0
* Ably JavaScript Library v1.0.1
* https://github.com/ably/ably-js
*
* Ably Realtime Messaging
Expand Down Expand Up @@ -3480,11 +3480,12 @@ var Defaults = {
internetUpUrl: 'https://internet-up.ably-realtime.com/is-the-internet-up.txt',
jsonpInternetUpUrl: 'https://internet-up.ably-realtime.com/is-the-internet-up-0-9.js',
/* Order matters here: the base transport is the leftmost one in the
* intersection of this list and the transports clientOption that's
* intersection of baseTransportOrder and the transports clientOption that's
* supported. This is not quite the same as the preference order -- e.g.
* xhr_polling is preferred to jsonp, but for browsers that support it we want
* the base transport to be xhr_polling, not jsonp */
transports: ['xhr_polling', 'xhr_streaming', 'jsonp', 'web_socket'],
defaultTransports: ['xhr_polling', 'xhr_streaming', 'jsonp', 'web_socket'],
baseTransportOrder: ['xhr_polling', 'xhr_streaming', 'jsonp', 'web_socket'],
transportPreferenceOrder: ['jsonp', 'xhr_polling', 'xhr_streaming', 'web_socket'],
upgradeTransports: ['xhr_streaming', 'web_socket'],
minified: !(function _(){}).name
Expand Down Expand Up @@ -4018,7 +4019,7 @@ Defaults.TIMEOUTS = {
};
Defaults.httpMaxRetryCount = 3;

Defaults.version = '1.0.0';
Defaults.version = '1.0.1';
Defaults.libstring = 'js-' + Defaults.version;
Defaults.apiVersion = '1.0';

Expand Down Expand Up @@ -5718,7 +5719,7 @@ var ConnectionManager = (function() {
initialized: {state: 'initialized', terminal: false, queueEvents: true, sendEvents: false, failState: 'disconnected'},
connecting: {state: 'connecting', terminal: false, queueEvents: true, sendEvents: false, retryDelay: connectingTimeout, failState: 'disconnected'},
connected: {state: 'connected', terminal: false, queueEvents: false, sendEvents: true, failState: 'disconnected'},
synchronizing: {state: 'connected', terminal: false, queueEvents: true, sendEvents: false, failState: 'disconnected'},
synchronizing: {state: 'connected', terminal: false, queueEvents: true, sendEvents: false, forceQueueEvents: true, failState: 'disconnected'},
disconnected: {state: 'disconnected', terminal: false, queueEvents: true, sendEvents: false, retryDelay: timeouts.disconnectedRetryTimeout, failState: 'disconnected'},
suspended: {state: 'suspended', terminal: false, queueEvents: false, sendEvents: false, retryDelay: timeouts.suspendedRetryTimeout, failState: 'suspended'},
closing: {state: 'closing', terminal: false, queueEvents: false, sendEvents: false, retryDelay: timeouts.realtimeRequestTimeout, failState: 'closed'},
Expand All @@ -5734,12 +5735,12 @@ var ConnectionManager = (function() {
this.connectionKey = undefined;
this.connectionSerial = undefined;

this.transports = Utils.intersect((options.transports || Defaults.transports), ConnectionManager.supportedTransports);
/* baseTransports selects the leftmost transport in the Defaults.transports list
this.transports = Utils.intersect((options.transports || Defaults.defaultTransports), ConnectionManager.supportedTransports);
/* baseTransports selects the leftmost transport in the Defaults.baseTransportOrder list
* that's both requested and supported. Normally this will be xhr_polling;
* if xhr isn't supported it will be jsonp. If the user has forced a
* transport, it'll just be that one. */
this.baseTransport = Utils.intersect(Defaults.transports, this.transports)[0];
this.baseTransport = Utils.intersect(Defaults.baseTransportOrder, this.transports)[0];
this.upgradeTransports = Utils.intersect(this.transports, Defaults.upgradeTransports);
/* Map of hosts to an array of transports to not be tried for that host */
this.transportHostBlacklist = {};
Expand All @@ -5753,7 +5754,7 @@ var ConnectionManager = (function() {
this.lastAutoReconnectAttempt = null;

Logger.logAction(Logger.LOG_MINOR, 'Realtime.ConnectionManager()', 'started');
Logger.logAction(Logger.LOG_MICRO, 'Realtime.ConnectionManager()', 'requested transports = [' + (options.transports || Defaults.transports) + ']');
Logger.logAction(Logger.LOG_MICRO, 'Realtime.ConnectionManager()', 'requested transports = [' + (options.transports || Defaults.defaultTransports) + ']');
Logger.logAction(Logger.LOG_MICRO, 'Realtime.ConnectionManager()', 'available transports = [' + this.transports + ']');
Logger.logAction(Logger.LOG_MICRO, 'Realtime.ConnectionManager()', 'http hosts = [' + this.httpHosts + ']');

Expand Down Expand Up @@ -6136,8 +6137,6 @@ var ConnectionManager = (function() {
});
})

this.emit('transport.active', transport, connectionKey, transport.params);

/* If previously not connected, notify the state change (including any
* error). */
if(existingState.state === this.states.connected.state) {
Expand All @@ -6153,6 +6152,10 @@ var ConnectionManager = (function() {
this.errorReason = this.realtime.connection.errorReason = error || null;
}

/* Send after the connection state update, as Channels hooks into this to
* resend attaches on a new transport if necessary */
this.emit('transport.active', transport, connectionKey, transport.params);

/* Gracefully terminate existing protocol */
if(existingActiveProtocol) {
if(existingActiveProtocol.messageQueue.count() > 0) {
Expand Down Expand Up @@ -6280,8 +6283,10 @@ var ConnectionManager = (function() {
if(this.connectionId && this.connectionId !== connectionId) {
Logger.logAction(Logger.LOG_MINOR, 'ConnectionManager.setConnection()', 'connectionId has changed; resetting msgSerial and reattaching channels');
this.msgSerial = 0;
/* Wait till next tick before reattaching channels so that connection
* state will be updated */
/* Wait till next tick before reattaching channels, so that connection
* state will be updated and so that it will be applied after
* Channels#onTransportUpdate, else channels will not have an ATTACHED
* sent twice (once from this and once from that). */
Utils.nextTick(function() {
self.realtime.channels.reattach();
});
Expand Down Expand Up @@ -6706,8 +6711,7 @@ var ConnectionManager = (function() {
/* before trying any fallback (or any remaining fallback) we decide if
* there is a problem with the ably host, or there is a general connectivity
* problem */
var connectivityCheckTransport = self.baseTransport === 'web_socket' ? 'xhr_polling' : self.baseTransport;
ConnectionManager.supportedTransports[connectivityCheckTransport].checkConnectivity(function(err, connectivity) {
Http.checkConnectivity(function(err, connectivity) {
/* we know err won't happen but handle it here anyway */
if(err) {
giveUp(err);
Expand Down Expand Up @@ -6749,8 +6753,9 @@ var ConnectionManager = (function() {
return;
}

var upgradeTransportParams = new TransportParams(this.options, transportParams.host, 'upgrade', this.connectionKey);
Utils.arrForEach(upgradePossibilities, function(upgradeTransport) {
/* Note: the transport may mutate the params, so give each transport a fresh one */
var upgradeTransportParams = new TransportParams(self.options, transportParams.host, 'upgrade', self.connectionKey);
self.tryATransport(upgradeTransportParams, upgradeTransport, noop);
});
};
Expand Down Expand Up @@ -6895,7 +6900,7 @@ var ConnectionManager = (function() {
* event queueing
******************/

ConnectionManager.prototype.send = function(msg, queueEvents, callback) {
ConnectionManager.prototype.send = function(msg, queueEvent, callback) {
callback = callback || noop;
var state = this.state;

Expand All @@ -6904,18 +6909,17 @@ var ConnectionManager = (function() {
this.sendImpl(new PendingMessage(msg, callback));
return;
}
if(state.queueEvents) {
if(state == this.states.synchronizing || queueEvents) {
if (Logger.shouldLog(Logger.LOG_MICRO)) {
Logger.logAction(Logger.LOG_MICRO, 'ConnectionManager.send()', 'queueing msg; ' + ProtocolMessage.stringify(msg));
}
this.queue(msg, callback);
} else {
var err = 'rejecting event as queueMessages was disabled; state = ' + state.state;
Logger.logAction(Logger.LOG_MICRO, 'ConnectionManager.send()', err);
callback(this.errorReason || new ErrorInfo(err, 90000, 400));
}
var shouldQueue = (queueEvent && state.queueEvents) || state.forceQueueEvents;
if(!shouldQueue) {
var err = 'rejecting event, queueEvent was ' + queueEvent + ', state was ' + state.state;
Logger.logAction(Logger.LOG_MICRO, 'ConnectionManager.send()', err);
callback(this.errorReason || new ErrorInfo(err, 90000, 400));
return;
}
if(Logger.shouldLog(Logger.LOG_MICRO)) {
Logger.logAction(Logger.LOG_MICRO, 'ConnectionManager.send()', 'queueing msg; ' + ProtocolMessage.stringify(msg));
}
this.queue(msg, callback);
};

ConnectionManager.prototype.sendImpl = function(pendingMessage) {
Expand Down Expand Up @@ -9111,13 +9115,7 @@ var Realtime = (function() {
this.realtime = realtime;
this.all = {};
this.inProgress = {};
var self = this;
realtime.connection.connectionManager.on('transport.active', function() {
/* nextTick to allow connectionManager to set the connection state to 'connected' if necessary */
Utils.nextTick(function() {
self.onTransportActive();
});
});
realtime.connection.connectionManager.on('transport.active', this.onTransportActive.bind(this));
}
Utils.inherits(Channels, EventEmitter);

Expand Down Expand Up @@ -9153,7 +9151,9 @@ var Realtime = (function() {
Channels.prototype.reattach = function(reason) {
for(var channelId in this.all) {
var channel = this.all[channelId];
if(channel.state === 'attaching' || channel.state === 'attached') {
/* NB this should not trigger for merely attaching channels, as they will
* be reattached anyway through the onTransportActive checkPendingState */
if(channel.state === 'attached') {
channel.requestState('attaching', reason);
}
}
Expand Down Expand Up @@ -9684,7 +9684,9 @@ var RealtimeChannel = (function() {

/* send sync request */
var syncMessage = ProtocolMessage.fromValues({action: actions.SYNC, channel: this.name});
syncMessage.channelSerial = this.syncChannelSerial;
if(this.syncChannelSerial) {
syncMessage.channelSerial = this.syncChannelSerial;
}
connectionManager.send(syncMessage);
};

Expand Down Expand Up @@ -9889,8 +9891,11 @@ var RealtimeChannel = (function() {

RealtimeChannel.prototype.checkPendingState = function() {
/* if can't send events, do nothing */
if(!this.connectionManager.state.sendEvents) {
Logger.logAction(Logger.LOG_MINOR, 'RealtimeChannel.checkPendingState', 'not connected');
var cmState = this.connectionManager.state;
/* Allow attach messages to queue up when synchronizing, since this will be
* the state we'll be in when upgrade transport.active triggers a checkpendingstate */
if(!(cmState.sendEvents || cmState.forceQueueEvents)) {
Logger.logAction(Logger.LOG_MINOR, 'RealtimeChannel.checkPendingState', 'sendEvents is false; state is ' + this.connectionManager.state.state);
return;
}

Expand Down Expand Up @@ -9996,12 +10001,16 @@ var RealtimeChannel = (function() {
}

if(params && params.untilAttach) {
if(this.state === 'attached') {
delete params.untilAttach;
params.from_serial = this.attachSerial;
} else {
if(this.state !== 'attached') {
callback(new ErrorInfo("option untilAttach requires the channel to be attached", 40000, 400));
return;
}
if(!this.attachSerial) {
callback(new ErrorInfo("untilAttach was specified and channel is attached, but attachSerial is not defined", 40000, 400));
return;
}
delete params.untilAttach;
params.from_serial = this.attachSerial;
}

Channel.prototype._history.call(this, params, callback);
Expand Down Expand Up @@ -10293,6 +10302,7 @@ var RealtimePresence = (function() {
/* RTP5c2: re-enter our own members if they haven't shown up in the sync */
this._ensureMyMembersPresent();
this.channel.setInProgress(RealtimeChannel.progressOps.sync, false);
this.channel.syncChannelSerial = null;
}

/* broadcast to listeners */
Expand Down Expand Up @@ -10894,6 +10904,16 @@ var XHRRequest = (function() {
req.exec();
return req;
};

Http.checkConnectivity = function(callback) {
var upUrl = Defaults.internetUpUrl;
Logger.logAction(Logger.LOG_MICRO, '(XHRRequest)Http.checkConnectivity()', 'Sending; ' + upUrl);
Http.Request(null, upUrl, null, null, null, function(err, responseText) {
var result = (!err && responseText.replace(/\n/, '') == 'yes');
Logger.logAction(Logger.LOG_MICRO, '(XHRRequest)Http.checkConnectivity()', 'Result: ' + result);
callback(null, result);
});
};
}
}

Expand All @@ -10912,16 +10932,6 @@ var XHRStreamingTransport = (function() {

XHRStreamingTransport.isAvailable = XHRRequest.isAvailable;

XHRStreamingTransport.checkConnectivity = function(callback) {
var upUrl = Defaults.internetUpUrl;
Logger.logAction(Logger.LOG_MICRO, 'XHRStreamingTransport.checkConnectivity()', 'Sending; ' + upUrl);
Http.Request(null, upUrl, null, null, null, function(err, responseText) {
var result = (!err && responseText.replace(/\n/, '') == 'yes');
Logger.logAction(Logger.LOG_MICRO, 'XHRStreamingTransport.checkConnectivity()', 'Result: ' + result);
callback(null, result);
});
};

XHRStreamingTransport.tryConnect = function(connectionManager, auth, params, callback) {
var transport = new XHRStreamingTransport(connectionManager, auth, params);
var errorCb = function(err) { callback({event: this.event, error: err}); };
Expand Down Expand Up @@ -10958,7 +10968,6 @@ var XHRPollingTransport = (function() {
Utils.inherits(XHRPollingTransport, CometTransport);

XHRPollingTransport.isAvailable = XHRRequest.isAvailable;
XHRPollingTransport.checkConnectivity = XHRStreamingTransport.checkConnectivity;

XHRPollingTransport.tryConnect = function(connectionManager, auth, params, callback) {
var transport = new XHRPollingTransport(connectionManager, auth, params);
Expand Down
Loading

0 comments on commit b34b9d1

Please sign in to comment.