Reverting recent JS changes as they are not stable.

This commit is contained in:
Andrew Godwin 2017-09-15 10:17:28 -07:00
parent e559d9a2b9
commit 46484cdf39
4 changed files with 13 additions and 33 deletions

View File

@ -3,9 +3,6 @@
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.channels = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
;
;
;
var isWebSocket = function (constructor) {
return constructor && constructor.CLOSING === 2;
};
@ -47,9 +44,7 @@ var reassignEventListeners = function (ws, oldWs, listeners) {
});
});
if (oldWs) {
LEVEL_0_EVENTS.forEach(function (name) {
ws[name] = oldWs[name];
});
LEVEL_0_EVENTS.forEach(function (name) { ws[name] = oldWs[name]; });
}
};
var ReconnectingWebsocket = function (url, protocols, options) {
@ -77,7 +72,7 @@ var ReconnectingWebsocket = function (url, protocols, options) {
var log = config.debug ? function () {
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
params[_i - 0] = arguments[_i];
}
return console.log.apply(console, ['RWS:'].concat(params));
} : function () { };
@ -99,7 +94,7 @@ var ReconnectingWebsocket = function (url, protocols, options) {
}
}, 0); };
var handleClose = function () {
log('handleClose', { shouldRetry: shouldRetry });
log('close');
retriesCount++;
log('retries count:', retriesCount);
if (retriesCount > config.maxRetries) {
@ -112,19 +107,15 @@ var ReconnectingWebsocket = function (url, protocols, options) {
else {
reconnectDelay = updateReconnectionDelay(config, reconnectDelay);
}
log('handleClose - reconnectDelay:', reconnectDelay);
log('reconnectDelay:', reconnectDelay);
if (shouldRetry) {
setTimeout(connect, reconnectDelay);
}
};
var connect = function () {
if (!shouldRetry) {
return;
}
log('connect');
var oldWs = ws;
var wsUrl = (typeof url === 'function') ? url() : url;
ws = new config.constructor(wsUrl, protocols);
ws = new config.constructor(url, protocols);
connectingTimeout = setTimeout(function () {
log('timeout');
ws.close();
@ -156,11 +147,10 @@ var ReconnectingWebsocket = function (url, protocols, options) {
if (code === void 0) { code = 1000; }
if (reason === void 0) { reason = ''; }
var _b = _a === void 0 ? {} : _a, _c = _b.keepClosed, keepClosed = _c === void 0 ? false : _c, _d = _b.fastClose, fastClose = _d === void 0 ? true : _d, _e = _b.delay, delay = _e === void 0 ? 0 : _e;
log('close - params:', { reason: reason, keepClosed: keepClosed, fastClose: fastClose, delay: delay, retriesCount: retriesCount, maxRetries: config.maxRetries });
shouldRetry = !keepClosed && retriesCount <= config.maxRetries;
if (delay) {
reconnectDelay = delay;
}
shouldRetry = !keepClosed;
ws.close(code, reason);
if (fastClose) {
var fakeCloseEvent_1 = {
@ -215,7 +205,6 @@ var ReconnectingWebsocket = function (url, protocols, options) {
}
ws.removeEventListener(type, listener, options);
};
return this;
};
module.exports = ReconnectingWebsocket;
@ -270,7 +259,7 @@ var WebSocketBridge = function () {
* @param {String} [url] The url of the websocket. Defaults to
* `window.location.host`
* @param {String[]|String} [protocols] Optional string or array of protocols.
* @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/pladaria/reconnecting-websocket#configure).
* @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1).
* @example
* const webSocketBridge = new WebSocketBridge();
* webSocketBridge.connect();
@ -294,10 +283,7 @@ var WebSocketBridge = function () {
_url = url;
}
}
// Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code
// [1006] during handshake if `protocols` is `undefined`.
var _protocols = protocols === undefined ? '' : protocols;
this.socket = new _reconnectingWebsocket2.default(_url, _protocols, options);
this.socket = new _reconnectingWebsocket2.default(_url, protocols, options);
}
/**

View File

@ -48,7 +48,7 @@ var WebSocketBridge = function () {
* @param {String} [url] The url of the websocket. Defaults to
* `window.location.host`
* @param {String[]|String} [protocols] Optional string or array of protocols.
* @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/pladaria/reconnecting-websocket#configure).
* @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1).
* @example
* const webSocketBridge = new WebSocketBridge();
* webSocketBridge.connect();
@ -72,10 +72,7 @@ var WebSocketBridge = function () {
_url = url;
}
}
// Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code
// [1006] during handshake if `protocols` is `undefined`.
var _protocols = protocols === undefined ? '' : protocols;
this.socket = new _reconnectingWebsocket2.default(_url, _protocols, options);
this.socket = new _reconnectingWebsocket2.default(_url, protocols, options);
}
/**

View File

@ -23,7 +23,7 @@
],
"license": "BSD-3-Clause",
"dependencies": {
"reconnecting-websocket": "^3.2.1"
"reconnecting-websocket": "^3.0.3"
},
"jest": {
"roots": [

View File

@ -30,7 +30,7 @@ export class WebSocketBridge {
* @param {String} [url] The url of the websocket. Defaults to
* `window.location.host`
* @param {String[]|String} [protocols] Optional string or array of protocols.
* @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/pladaria/reconnecting-websocket#configure).
* @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1).
* @example
* const webSocketBridge = new WebSocketBridge();
* webSocketBridge.connect();
@ -50,10 +50,7 @@ export class WebSocketBridge {
_url = url;
}
}
// Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code
// [1006] during handshake if `protocols` is `undefined`.
const _protocols = protocols === undefined ? '' : protocols;
this.socket = new ReconnectingWebSocket(_url, _protocols, options);
this.socket = new ReconnectingWebSocket(_url, protocols, options);
}
/**