From ccc933749703485702f375858dae75744a39e648 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Fri, 13 Sep 2019 13:57:12 +0200 Subject: [PATCH] [chore] Release 3.4.0 Diff: https://github.com/socketio/engine.io-client/compare/3.3.2...3.4.0 --- engine.io.js | 802 +++++++++++++++++++++++++++------------------------ package.json | 4 +- 2 files changed, 434 insertions(+), 372 deletions(-) diff --git a/engine.io.js b/engine.io.js index 1c70c233f..bc537d04f 100644 --- a/engine.io.js +++ b/engine.io.js @@ -54,8 +54,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 0 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - + module.exports = __webpack_require__(1); /** @@ -66,14 +65,11 @@ return /******/ (function(modules) { // webpackBootstrap */ module.exports.parser = __webpack_require__(8); + /***/ }, /* 1 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - /** * Module dependencies. */ @@ -100,12 +96,12 @@ return /******/ (function(modules) { // webpackBootstrap * @api public */ - function Socket(uri, opts) { + function Socket (uri, opts) { if (!(this instanceof Socket)) return new Socket(uri, opts); opts = opts || {}; - if (uri && 'object' === (typeof uri === 'undefined' ? 'undefined' : _typeof(uri))) { + if (uri && 'object' === typeof uri) { opts = uri; uri = null; } @@ -120,7 +116,8 @@ return /******/ (function(modules) { // webpackBootstrap opts.hostname = parseuri(opts.host).host; } - this.secure = null != opts.secure ? opts.secure : typeof location !== 'undefined' && 'https:' === location.protocol; + this.secure = null != opts.secure ? opts.secure + : (typeof location !== 'undefined' && 'https:' === location.protocol); if (opts.hostname && !opts.port) { // if no port is specified manually, use the protocol default @@ -128,8 +125,11 @@ return /******/ (function(modules) { // webpackBootstrap } this.agent = opts.agent || false; - this.hostname = opts.hostname || (typeof location !== 'undefined' ? location.hostname : 'localhost'); - this.port = opts.port || (typeof location !== 'undefined' && location.port ? location.port : this.secure ? 443 : 80); + this.hostname = opts.hostname || + (typeof location !== 'undefined' ? location.hostname : 'localhost'); + this.port = opts.port || (typeof location !== 'undefined' && location.port + ? location.port + : (this.secure ? 443 : 80)); this.query = opts.query || {}; if ('string' === typeof this.query) this.query = parseqs.decode(this.query); this.upgrade = false !== opts.upgrade; @@ -138,6 +138,7 @@ return /******/ (function(modules) { // webpackBootstrap this.jsonp = false !== opts.jsonp; this.forceBase64 = !!opts.forceBase64; this.enablesXDR = !!opts.enablesXDR; + this.withCredentials = false !== opts.withCredentials; this.timestampParam = opts.timestampParam || 't'; this.timestampRequests = opts.timestampRequests; this.transports = opts.transports || ['polling', 'websocket']; @@ -149,7 +150,7 @@ return /******/ (function(modules) { // webpackBootstrap this.rememberUpgrade = opts.rememberUpgrade || false; this.binaryType = null; this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades; - this.perMessageDeflate = false !== opts.perMessageDeflate ? opts.perMessageDeflate || {} : false; + this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false; if (true === this.perMessageDeflate) this.perMessageDeflate = {}; if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) { @@ -167,7 +168,7 @@ return /******/ (function(modules) { // webpackBootstrap this.forceNode = !!opts.forceNode; // detect ReactNative environment - this.isReactNative = typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative'; + this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative'); // other options for Node.js or ReactNative client if (typeof self === 'undefined' || this.isReactNative) { @@ -255,6 +256,7 @@ return /******/ (function(modules) { // webpackBootstrap jsonp: options.jsonp || this.jsonp, forceBase64: options.forceBase64 || this.forceBase64, enablesXDR: options.enablesXDR || this.enablesXDR, + withCredentials: options.withCredentials || this.withCredentials, timestampRequests: options.timestampRequests || this.timestampRequests, timestampParam: options.timestampParam || this.timestampParam, policyPort: options.policyPort || this.policyPort, @@ -270,14 +272,14 @@ return /******/ (function(modules) { // webpackBootstrap forceNode: options.forceNode || this.forceNode, localAddress: options.localAddress || this.localAddress, requestTimeout: options.requestTimeout || this.requestTimeout, - protocols: options.protocols || void 0, + protocols: options.protocols || void (0), isReactNative: this.isReactNative }); return transport; }; - function clone(obj) { + function clone (obj) { var o = {}; for (var i in obj) { if (obj.hasOwnProperty(i)) { @@ -340,13 +342,17 @@ return /******/ (function(modules) { // webpackBootstrap this.transport = transport; // set up transport listeners - transport.on('drain', function () { + transport + .on('drain', function () { self.onDrain(); - }).on('packet', function (packet) { + }) + .on('packet', function (packet) { self.onPacket(packet); - }).on('error', function (e) { + }) + .on('error', function (e) { self.onError(e); - }).on('close', function () { + }) + .on('close', function () { self.onClose('transport close'); }); }; @@ -366,7 +372,7 @@ return /******/ (function(modules) { // webpackBootstrap Socket.priorWebsocketSuccess = false; - function onTransportOpen() { + function onTransportOpen () { if (self.onlyBinaryUpgrades) { var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary; failed = failed || upgradeLosesBinary; @@ -408,7 +414,7 @@ return /******/ (function(modules) { // webpackBootstrap }); } - function freezeTransport() { + function freezeTransport () { if (failed) return; // Any callback called by transport should be ignored since now @@ -421,7 +427,7 @@ return /******/ (function(modules) { // webpackBootstrap } // Handle any error that happens while probing - function onerror(err) { + function onerror (err) { var error = new Error('probe error: ' + err); error.transport = transport.name; @@ -432,17 +438,17 @@ return /******/ (function(modules) { // webpackBootstrap self.emit('upgradeError', error); } - function onTransportClose() { + function onTransportClose () { onerror('transport closed'); } // When the socket is closed while we're probing - function onclose() { + function onclose () { onerror('socket closed'); } // When the socket is upgraded while we're probing - function onupgrade(to) { + function onupgrade (to) { if (transport && to.name !== transport.name) { debug('"%s" works - aborting "%s"', to.name, transport.name); freezeTransport(); @@ -450,7 +456,7 @@ return /******/ (function(modules) { // webpackBootstrap } // Remove all listeners on the transport and on self - function cleanup() { + function cleanup () { transport.removeListener('open', onTransportOpen); transport.removeListener('error', onerror); transport.removeListener('close', onTransportClose); @@ -498,7 +504,8 @@ return /******/ (function(modules) { // webpackBootstrap */ Socket.prototype.onPacket = function (packet) { - if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) { + if ('opening' === this.readyState || 'open' === this.readyState || + 'closing' === this.readyState) { debug('socket receive: type "%s", data "%s"', packet.type, packet.data); this.emit('packet', packet); @@ -568,7 +575,7 @@ return /******/ (function(modules) { // webpackBootstrap self.pingTimeoutTimer = setTimeout(function () { if ('closed' === self.readyState) return; self.onClose('ping timeout'); - }, timeout || self.pingInterval + self.pingTimeout); + }, timeout || (self.pingInterval + self.pingTimeout)); }; /** @@ -629,7 +636,8 @@ return /******/ (function(modules) { // webpackBootstrap */ Socket.prototype.flush = function () { - if ('closed' !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) { + if ('closed' !== this.readyState && this.transport.writable && + !this.upgrading && this.writeBuffer.length) { debug('flushing %d packets in socket', this.writeBuffer.length); this.transport.send(this.writeBuffer); // keep track of current length of writeBuffer @@ -649,7 +657,8 @@ return /******/ (function(modules) { // webpackBootstrap * @api public */ - Socket.prototype.write = Socket.prototype.send = function (msg, options, fn) { + Socket.prototype.write = + Socket.prototype.send = function (msg, options, fn) { this.sendPacket('message', msg, options, fn); return this; }; @@ -720,19 +729,19 @@ return /******/ (function(modules) { // webpackBootstrap } } - function close() { + function close () { self.onClose('forced close'); debug('socket closing - telling transport to close'); self.transport.close(); } - function cleanupAndClose() { + function cleanupAndClose () { self.removeListener('upgrade', cleanupAndClose); self.removeListener('upgradeError', cleanupAndClose); close(); } - function waitForUpgrade() { + function waitForUpgrade () { // wait for upgrade to finish since we can't send packets while pausing a transport self.once('upgrade', cleanupAndClose); self.once('upgradeError', cleanupAndClose); @@ -810,12 +819,11 @@ return /******/ (function(modules) { // webpackBootstrap return filteredUpgrades; }; + /***/ }, /* 2 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - /** * Module dependencies */ @@ -839,7 +847,7 @@ return /******/ (function(modules) { // webpackBootstrap * @api private */ - function polling(opts) { + function polling (opts) { var xhr; var xd = false; var xs = false; @@ -870,12 +878,11 @@ return /******/ (function(modules) { // webpackBootstrap } } + /***/ }, /* 3 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - // browser shim for xmlhttprequest module var hasCORS = __webpack_require__(4); @@ -896,7 +903,7 @@ return /******/ (function(modules) { // webpackBootstrap if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) { return new XMLHttpRequest(); } - } catch (e) {} + } catch (e) { } // Use XDomainRequest for IE8 if enablesXDR is true // because loading bar keeps flashing when using jsonp-polling @@ -905,15 +912,16 @@ return /******/ (function(modules) { // webpackBootstrap if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) { return new XDomainRequest(); } - } catch (e) {} + } catch (e) { } if (!xdomain) { try { return new self[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); - } catch (e) {} + } catch (e) { } } }; + /***/ }, /* 4 */ /***/ function(module, exports) { @@ -941,8 +949,6 @@ return /******/ (function(modules) { // webpackBootstrap /* 5 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - /* global attachEvent */ /** @@ -966,7 +972,7 @@ return /******/ (function(modules) { // webpackBootstrap * Empty function */ - function empty() {} + function empty () {} /** * XHR Polling constructor. @@ -975,7 +981,7 @@ return /******/ (function(modules) { // webpackBootstrap * @api public */ - function XHR(opts) { + function XHR (opts) { Polling.call(this, opts); this.requestTimeout = opts.requestTimeout; this.extraHeaders = opts.extraHeaders; @@ -989,7 +995,8 @@ return /******/ (function(modules) { // webpackBootstrap port = isSSL ? 443 : 80; } - this.xd = typeof location !== 'undefined' && opts.hostname !== location.hostname || port !== opts.port; + this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) || + port !== opts.port; this.xs = opts.secure !== isSSL; } } @@ -1021,6 +1028,7 @@ return /******/ (function(modules) { // webpackBootstrap opts.agent = this.agent || false; opts.supportsBinary = this.supportsBinary; opts.enablesXDR = this.enablesXDR; + opts.withCredentials = this.withCredentials; // SSL options for Node.js client opts.pfx = this.pfx; @@ -1083,7 +1091,7 @@ return /******/ (function(modules) { // webpackBootstrap * @api public */ - function Request(opts) { + function Request (opts) { this.method = opts.method || 'GET'; this.uri = opts.uri; this.xd = !!opts.xd; @@ -1094,6 +1102,7 @@ return /******/ (function(modules) { // webpackBootstrap this.isBinary = opts.isBinary; this.supportsBinary = opts.supportsBinary; this.enablesXDR = opts.enablesXDR; + this.withCredentials = opts.withCredentials; this.requestTimeout = opts.requestTimeout; // SSL options for Node.js client @@ -1168,7 +1177,7 @@ return /******/ (function(modules) { // webpackBootstrap // ie6 check if ('withCredentials' in xhr) { - xhr.withCredentials = true; + xhr.withCredentials = this.withCredentials; } if (this.requestTimeout) { @@ -1187,7 +1196,7 @@ return /******/ (function(modules) { // webpackBootstrap if (xhr.readyState === 2) { try { var contentType = xhr.getResponseHeader('Content-Type'); - if (self.supportsBinary && contentType === 'application/octet-stream') { + if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') { xhr.responseType = 'arraybuffer'; } } catch (e) {} @@ -1199,7 +1208,7 @@ return /******/ (function(modules) { // webpackBootstrap // make sure the `error` event handler that's user-set // does not throw in the same tick and gets caught here setTimeout(function () { - self.onError(xhr.status); + self.onError(typeof xhr.status === 'number' ? xhr.status : 0); }, 0); } }; @@ -1299,7 +1308,7 @@ return /******/ (function(modules) { // webpackBootstrap try { contentType = this.xhr.getResponseHeader('Content-Type'); } catch (e) {} - if (contentType === 'application/octet-stream') { + if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') { data = this.xhr.response || this.xhr.responseText; } else { data = this.xhr.responseText; @@ -1350,7 +1359,7 @@ return /******/ (function(modules) { // webpackBootstrap } } - function unloadHandler() { + function unloadHandler () { for (var i in Request.requests) { if (Request.requests.hasOwnProperty(i)) { Request.requests[i].abort(); @@ -1358,12 +1367,11 @@ return /******/ (function(modules) { // webpackBootstrap } } + /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - /** * Module dependencies. */ @@ -1385,11 +1393,11 @@ return /******/ (function(modules) { // webpackBootstrap * Is XHR2 supported? */ - var hasXHR2 = function () { + var hasXHR2 = (function () { var XMLHttpRequest = __webpack_require__(3); var xhr = new XMLHttpRequest({ xdomain: false }); return null != xhr.responseType; - }(); + })(); /** * Polling interface. @@ -1398,8 +1406,8 @@ return /******/ (function(modules) { // webpackBootstrap * @api private */ - function Polling(opts) { - var forceBase64 = opts && opts.forceBase64; + function Polling (opts) { + var forceBase64 = (opts && opts.forceBase64); if (!hasXHR2 || forceBase64) { this.supportsBinary = false; } @@ -1441,7 +1449,7 @@ return /******/ (function(modules) { // webpackBootstrap this.readyState = 'pausing'; - function pause() { + function pause () { debug('paused'); self.readyState = 'paused'; onPause(); @@ -1494,7 +1502,7 @@ return /******/ (function(modules) { // webpackBootstrap Polling.prototype.onData = function (data) { var self = this; debug('polling got data %s', data); - var callback = function callback(packet, index, total) { + var callback = function (packet, index, total) { // if its the first message we consider the transport open if ('opening' === self.readyState) { self.onOpen(); @@ -1536,7 +1544,7 @@ return /******/ (function(modules) { // webpackBootstrap Polling.prototype.doClose = function () { var self = this; - function close() { + function close () { debug('writing close packet'); self.write([{ type: 'close' }]); } @@ -1563,7 +1571,7 @@ return /******/ (function(modules) { // webpackBootstrap Polling.prototype.write = function (packets) { var self = this; this.writable = false; - var callbackfn = function callbackfn() { + var callbackfn = function () { self.writable = true; self.emit('drain'); }; @@ -1596,7 +1604,8 @@ return /******/ (function(modules) { // webpackBootstrap query = parseqs.encode(query); // avoid port if default for schema - if (this.port && ('https' === schema && Number(this.port) !== 443 || 'http' === schema && Number(this.port) !== 80)) { + if (this.port && (('https' === schema && Number(this.port) !== 443) || + ('http' === schema && Number(this.port) !== 80))) { port = ':' + this.port; } @@ -1609,12 +1618,11 @@ return /******/ (function(modules) { // webpackBootstrap return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query; }; + /***/ }, /* 7 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - /** * Module dependencies. */ @@ -1635,7 +1643,7 @@ return /******/ (function(modules) { // webpackBootstrap * @api private */ - function Transport(opts) { + function Transport (opts) { this.path = opts.path; this.hostname = opts.hostname; this.port = opts.port; @@ -1647,6 +1655,7 @@ return /******/ (function(modules) { // webpackBootstrap this.agent = opts.agent || false; this.socket = opts.socket; this.enablesXDR = opts.enablesXDR; + this.withCredentials = opts.withCredentials; // SSL options for Node.js client this.pfx = opts.pfx; @@ -1776,6 +1785,7 @@ return /******/ (function(modules) { // webpackBootstrap this.emit('close'); }; + /***/ }, /* 8 */ /***/ function(module, exports, __webpack_require__) { @@ -3259,40 +3269,28 @@ return /******/ (function(modules) { // webpackBootstrap /* 21 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {/** + /* WEBPACK VAR INJECTION */(function(process) {'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + /* eslint-env browser */ + + /** * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. */ - exports = module.exports = __webpack_require__(23); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; - exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); + exports.storage = localstorage(); /** * Colors. */ - exports.colors = [ - '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', - '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', - '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', - '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', - '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', - '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', - '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', - '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', - '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', - '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', - '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' - ]; + exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33']; /** * Currently only WebKit-based Web Inspectors, Firefox >= v31, @@ -3302,44 +3300,32 @@ return /******/ (function(modules) { // webpackBootstrap * TODO: add a `localStorage` variable to explicitly enable/disable colors */ + // eslint-disable-next-line complexity function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; - } + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || + // Is firebug? http://stackoverflow.com/a/398120/376773 + typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || + // Double check webkit in userAgent just in case we are in a worker + typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); } - /** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - - exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } - }; - - /** * Colorize log arguments if enabled. * @@ -3347,36 +3333,33 @@ return /******/ (function(modules) { // webpackBootstrap */ function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); + + if (!this.useColors) { + return; + } - args.splice(lastC, 0, c); + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function (match) { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); } /** @@ -3385,13 +3368,12 @@ return /******/ (function(modules) { // webpackBootstrap * * @api public */ - function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); + var _console; + + // This hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return (typeof console === 'undefined' ? 'undefined' : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments); } /** @@ -3400,15 +3382,17 @@ return /******/ (function(modules) { // webpackBootstrap * @param {String} namespaces * @api private */ - function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } /** @@ -3417,26 +3401,22 @@ return /******/ (function(modules) { // webpackBootstrap * @return {String} returns the previously persisted debug modes * @api private */ - function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + var r = void 0; + try { + r = exports.storage.getItem('debug'); + } catch (error) {} + // Swallow + // XXX (@Qix-) should we be logging these? - return r; - } - /** - * Enable namespaces listed in `localStorage.debug` initially. - */ + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } - exports.enable(load()); + return r; + } /** * Localstorage attempts to return the localstorage. @@ -3450,11 +3430,31 @@ return /******/ (function(modules) { // webpackBootstrap */ function localstorage() { - try { - return window.localStorage; - } catch (e) {} + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } + module.exports = __webpack_require__(23)(exports); + + var formatters = module.exports.formatters; + + /** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + + formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } + }; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22))) /***/ }, @@ -3651,232 +3651,276 @@ return /******/ (function(modules) { // webpackBootstrap /* 23 */ /***/ function(module, exports, __webpack_require__) { - + 'use strict'; + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + /** * This is the common logic for both the Node.js and web browser * implementations of `debug()`. - * - * Expose `debug()` as the module. */ - exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; - exports.coerce = coerce; - exports.disable = disable; - exports.enable = enable; - exports.enabled = enabled; - exports.humanize = __webpack_require__(24); + function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = __webpack_require__(24); - /** + Object.keys(env).forEach(function (key) { + createDebug[key] = env[key]; + }); + + /** * Active `debug` instances. */ - exports.instances = []; + createDebug.instances = []; - /** + /** * The currently active debug mode names, and names to skip. */ - exports.names = []; - exports.skips = []; + createDebug.names = []; + createDebug.skips = []; - /** + /** * Map of special "%n" handling functions, for the debug "format" argument. * * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ + createDebug.formatters = {}; - exports.formatters = {}; - - /** - * Select a color. - * @param {String} namespace - * @return {Number} + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace * @api private */ + function selectColor(namespace) { + var hash = 0; - function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + for (var i = 0; i < namespace.length; i++) { + hash = (hash << 5) - hash + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } - return exports.colors[Math.abs(hash) % exports.colors.length]; - } + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; - /** + /** * Create a debugger with the given `namespace`. * * @param {String} namespace * @return {Function} * @api public */ + function createDebug(namespace) { + var prevTime = void 0; - function createDebug(namespace) { - - var prevTime; - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + function debug() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } + // Disabled? + if (!debug.enabled) { + return; + } - args[0] = exports.coerce(args[0]); + var self = debug; - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } + // Set `diff` timestamp + var curr = Number(new Date()); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + args[0] = createDebug.coerce(args[0]); - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } + // Apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return match; + } + index++; + var formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + var val = args[index]; + match = formatter.call(self, val); + + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); + + var logFn = self.log || createDebug.log; + logFn.apply(self, args); + } - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - debug.destroy = destroy; + debug.namespace = namespace; + debug.enabled = createDebug.enabled(namespace); + debug.useColors = createDebug.useColors(); + debug.color = selectColor(namespace); + debug.destroy = destroy; + debug.extend = extend; + // Debug.formatArgs = formatArgs; + // debug.rawLog = rawLog; + + // env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } + createDebug.instances.push(debug); - exports.instances.push(debug); + return debug; + } - return debug; - } + function destroy() { + var index = createDebug.instances.indexOf(this); + if (index !== -1) { + createDebug.instances.splice(index, 1); + return true; + } + return false; + } - function destroy () { - var index = exports.instances.indexOf(this); - if (index !== -1) { - exports.instances.splice(index, 1); - return true; - } else { - return false; - } - } + function extend(namespace, delimiter) { + var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } - /** + /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. * * @param {String} namespaces * @api public */ + function enable(namespaces) { + createDebug.save(namespaces); + + createDebug.names = []; + createDebug.skips = []; - function enable(namespaces) { - exports.save(namespaces); + var i = void 0; + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; - exports.names = []; - exports.skips = []; + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } - var i; - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; + namespaces = split[i].replace(/\*/g, '.*?'); - for (i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } - for (i = 0; i < exports.instances.length; i++) { - var instance = exports.instances[i]; - instance.enabled = exports.enabled(instance.namespace); - } - } + for (i = 0; i < createDebug.instances.length; i++) { + var instance = createDebug.instances[i]; + instance.enabled = createDebug.enabled(instance.namespace); + } + } - /** + /** * Disable debug output. * + * @return {String} namespaces * @api public */ + function disable() { + var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) { + return '-' + namespace; + }))).join(','); + createDebug.enable(''); + return namespaces; + } - function disable() { - exports.enable(''); - } - - /** + /** * Returns true if the given mode name is enabled, false otherwise. * * @param {String} name * @return {Boolean} * @api public */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; - } + var i = void 0; + var len = void 0; - /** + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } + + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } + + return false; + } + + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*'); + } + + /** * Coerce `val`. * * @param {Mixed} val * @return {Mixed} * @api private */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + + createDebug.enable(createDebug.load()); - function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; + return createDebug; } + module.exports = setup; /***/ }, /* 24 */ @@ -3890,6 +3934,7 @@ return /******/ (function(modules) { // webpackBootstrap var m = s * 60; var h = m * 60; var d = h * 24; + var w = d * 7; var y = d * 365.25; /** @@ -3911,7 +3956,7 @@ return /******/ (function(modules) { // webpackBootstrap var type = typeof val; if (type === 'string' && val.length > 0) { return parse(val); - } else if (type === 'number' && isNaN(val) === false) { + } else if (type === 'number' && isFinite(val)) { return options.long ? fmtLong(val) : fmtShort(val); } throw new Error( @@ -3933,7 +3978,7 @@ return /******/ (function(modules) { // webpackBootstrap if (str.length > 100) { return; } - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( str ); if (!match) { @@ -3948,6 +3993,10 @@ return /******/ (function(modules) { // webpackBootstrap case 'yr': case 'y': return n * y; + case 'weeks': + case 'week': + case 'w': + return n * w; case 'days': case 'day': case 'd': @@ -3990,16 +4039,17 @@ return /******/ (function(modules) { // webpackBootstrap */ function fmtShort(ms) { - if (ms >= d) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { return Math.round(ms / d) + 'd'; } - if (ms >= h) { + if (msAbs >= h) { return Math.round(ms / h) + 'h'; } - if (ms >= m) { + if (msAbs >= m) { return Math.round(ms / m) + 'm'; } - if (ms >= s) { + if (msAbs >= s) { return Math.round(ms / s) + 's'; } return ms + 'ms'; @@ -4014,25 +4064,29 @@ return /******/ (function(modules) { // webpackBootstrap */ function fmtLong(ms) { - return plural(ms, d, 'day') || - plural(ms, h, 'hour') || - plural(ms, m, 'minute') || - plural(ms, s, 'second') || - ms + ' ms'; + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural(ms, msAbs, d, 'day'); + } + if (msAbs >= h) { + return plural(ms, msAbs, h, 'hour'); + } + if (msAbs >= m) { + return plural(ms, msAbs, m, 'minute'); + } + if (msAbs >= s) { + return plural(ms, msAbs, s, 'second'); + } + return ms + ' ms'; } /** * Pluralization helper. */ - function plural(ms, n, name) { - if (ms < n) { - return; - } - if (ms < n * 1.5) { - return Math.floor(ms / n) + ' ' + name; - } - return Math.ceil(ms / n) + ' ' + name + 's'; + function plural(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } @@ -4040,9 +4094,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 25 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; - - /** + /* WEBPACK VAR INJECTION */(function(global) {/** * Module requirements. */ @@ -4072,13 +4124,15 @@ return /******/ (function(modules) { // webpackBootstrap * Noop. */ - function empty() {} + function empty () { } /** * Until https://github.com/tc39/proposal-global is shipped. */ - function glob() { - return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; + function glob () { + return typeof self !== 'undefined' ? self + : typeof window !== 'undefined' ? window + : typeof global !== 'undefined' ? global : {}; } /** @@ -4088,7 +4142,7 @@ return /******/ (function(modules) { // webpackBootstrap * @api public */ - function JSONPPolling(opts) { + function JSONPPolling (opts) { Polling.call(this, opts); this.query = this.query || {}; @@ -4098,7 +4152,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!callbacks) { // we need to consider multiple engines in the same page var global = glob(); - callbacks = global.___eio = global.___eio || []; + callbacks = global.___eio = (global.___eio || []); } // callback identifier @@ -4228,12 +4282,12 @@ return /******/ (function(modules) { // webpackBootstrap this.form.action = this.uri(); - function complete() { + function complete () { initIframe(); fn(); } - function initIframe() { + function initIframe () { if (self.iframe) { try { self.form.removeChild(self.iframe); @@ -4279,14 +4333,13 @@ return /******/ (function(modules) { // webpackBootstrap this.iframe.onload = complete; } }; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 26 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - /** * Module dependencies. */ @@ -4304,10 +4357,12 @@ return /******/ (function(modules) { // webpackBootstrap BrowserWebSocket = WebSocket; } else if (typeof self !== 'undefined') { BrowserWebSocket = self.WebSocket || self.MozWebSocket; - } else { + } + + if (typeof window === 'undefined') { try { NodeWebSocket = __webpack_require__(27); - } catch (e) {} + } catch (e) { } } /** @@ -4331,8 +4386,8 @@ return /******/ (function(modules) { // webpackBootstrap * @api public */ - function WS(opts) { - var forceBase64 = opts && opts.forceBase64; + function WS (opts) { + var forceBase64 = (opts && opts.forceBase64); if (forceBase64) { this.supportsBinary = false; } @@ -4400,7 +4455,12 @@ return /******/ (function(modules) { // webpackBootstrap } try { - this.ws = this.usingBrowserWebSocket && !this.isReactNative ? protocols ? new WebSocketImpl(uri, protocols) : new WebSocketImpl(uri) : new WebSocketImpl(uri, protocols, opts); + this.ws = + this.usingBrowserWebSocket && !this.isReactNative + ? protocols + ? new WebSocketImpl(uri, protocols) + : new WebSocketImpl(uri) + : new WebSocketImpl(uri, protocols, opts); } catch (err) { return this.emit('error', err); } @@ -4493,7 +4553,7 @@ return /******/ (function(modules) { // webpackBootstrap })(packets[i]); } - function done() { + function done () { self.emit('flush'); // fake drain @@ -4539,7 +4599,8 @@ return /******/ (function(modules) { // webpackBootstrap var port = ''; // avoid port if default for schema - if (this.port && ('wss' === schema && Number(this.port) !== 443 || 'ws' === schema && Number(this.port) !== 80)) { + if (this.port && (('wss' === schema && Number(this.port) !== 443) || + ('ws' === schema && Number(this.port) !== 80))) { port = ':' + this.port; } @@ -4575,6 +4636,7 @@ return /******/ (function(modules) { // webpackBootstrap return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name); }; + /***/ }, /* 27 */ /***/ function(module, exports) { diff --git a/package.json b/package.json index 25a3994a6..7e769f058 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "engine.io-client", "description": "Client for the realtime Engine", "license": "MIT", - "version": "3.3.2", + "version": "3.4.0", "main": "lib/index.js", "homepage": "https://github.com/socketio/engine.io-client", "contributors": [ @@ -45,7 +45,7 @@ "concat-stream": "^1.6.0", "del": "^2.2.2", "derequire": "^2.0.6", - "engine.io": "3.3.1", + "engine.io": "3.4.0", "eslint-config-standard": "4.4.0", "eslint-plugin-standard": "1.3.1", "expect.js": "^0.3.1",