From 484e3eced9ac1357540e7259c6687365ef562831 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Thu, 8 Nov 2018 00:20:58 +0100 Subject: [PATCH] [chore] Release 3.3.0 --- engine.io.js | 804 ++++++++++++++++++++++++--------------------------- package.json | 4 +- 2 files changed, 375 insertions(+), 433 deletions(-) diff --git a/engine.io.js b/engine.io.js index a37bbd6f9..6c0b575e2 100644 --- a/engine.io.js +++ b/engine.io.js @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 1 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + '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; }; @@ -79,12 +79,12 @@ return /******/ (function(modules) { // webpackBootstrap */ var transports = __webpack_require__(2); - var Emitter = __webpack_require__(18); - var debug = __webpack_require__(22)('engine.io-client:socket'); - var index = __webpack_require__(29); + var Emitter = __webpack_require__(17); + var debug = __webpack_require__(21)('engine.io-client:socket'); + var index = __webpack_require__(28); var parser = __webpack_require__(8); - var parseuri = __webpack_require__(30); - var parseqs = __webpack_require__(19); + var parseuri = __webpack_require__(29); + var parseqs = __webpack_require__(18); /** * Module exports. @@ -120,7 +120,7 @@ return /******/ (function(modules) { // webpackBootstrap opts.hostname = parseuri(opts.host).host; } - this.secure = null != opts.secure ? opts.secure : global.location && '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 +128,8 @@ return /******/ (function(modules) { // webpackBootstrap } this.agent = opts.agent || false; - this.hostname = opts.hostname || (global.location ? location.hostname : 'localhost'); - this.port = opts.port || (global.location && 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; @@ -166,9 +166,11 @@ return /******/ (function(modules) { // webpackBootstrap this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized; this.forceNode = !!opts.forceNode; - // other options for Node.js client - var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) === 'object' && global; - if (freeGlobal.global === freeGlobal) { + // detect ReactNative environment + 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) { if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) { this.extraHeaders = opts.extraHeaders; } @@ -268,7 +270,8 @@ 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; @@ -806,13 +809,12 @@ return /******/ (function(modules) { // webpackBootstrap } return filteredUpgrades; }; - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 2 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + 'use strict'; /** * Module dependencies @@ -820,8 +822,8 @@ return /******/ (function(modules) { // webpackBootstrap var XMLHttpRequest = __webpack_require__(3); var XHR = __webpack_require__(5); - var JSONP = __webpack_require__(26); - var websocket = __webpack_require__(27); + var JSONP = __webpack_require__(25); + var websocket = __webpack_require__(26); /** * Export transports. @@ -843,7 +845,7 @@ return /******/ (function(modules) { // webpackBootstrap var xs = false; var jsonp = false !== opts.jsonp; - if (global.location) { + if (typeof location !== 'undefined') { var isSSL = 'https:' === location.protocol; var port = location.port; @@ -867,13 +869,12 @@ return /******/ (function(modules) { // webpackBootstrap return new JSONP(opts); } } - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 3 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + 'use strict'; // browser shim for xmlhttprequest module @@ -908,11 +909,10 @@ return /******/ (function(modules) { // webpackBootstrap if (!xdomain) { try { - return new global[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); + return new self[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP'); } catch (e) {} } }; - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 4 */ @@ -941,7 +941,9 @@ return /******/ (function(modules) { // webpackBootstrap /* 5 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + 'use strict'; + + /* global attachEvent */ /** * Module requirements. @@ -949,9 +951,9 @@ return /******/ (function(modules) { // webpackBootstrap var XMLHttpRequest = __webpack_require__(3); var Polling = __webpack_require__(6); - var Emitter = __webpack_require__(18); - var inherit = __webpack_require__(20); - var debug = __webpack_require__(22)('engine.io-client:polling-xhr'); + var Emitter = __webpack_require__(17); + var inherit = __webpack_require__(19); + var debug = __webpack_require__(21)('engine.io-client:polling-xhr'); /** * Module exports. @@ -978,7 +980,7 @@ return /******/ (function(modules) { // webpackBootstrap this.requestTimeout = opts.requestTimeout; this.extraHeaders = opts.extraHeaders; - if (global.location) { + if (typeof location !== 'undefined') { var isSSL = 'https:' === location.protocol; var port = location.port; @@ -987,7 +989,7 @@ return /******/ (function(modules) { // webpackBootstrap port = isSSL ? 443 : 80; } - this.xd = opts.hostname !== global.location.hostname || port !== opts.port; + this.xd = typeof location !== 'undefined' && opts.hostname !== location.hostname || port !== opts.port; this.xs = opts.secure !== isSSL; } } @@ -1215,7 +1217,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } - if (global.document) { + if (typeof document !== 'undefined') { this.index = Request.requestsCount++; Request.requests[this.index] = this; } @@ -1277,7 +1279,7 @@ return /******/ (function(modules) { // webpackBootstrap } catch (e) {} } - if (global.document) { + if (typeof document !== 'undefined') { delete Request.requests[this.index]; } @@ -1317,7 +1319,7 @@ return /******/ (function(modules) { // webpackBootstrap */ Request.prototype.hasXDR = function () { - return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR; + return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR; }; /** @@ -1339,11 +1341,11 @@ return /******/ (function(modules) { // webpackBootstrap Request.requestsCount = 0; Request.requests = {}; - if (global.document) { - if (global.attachEvent) { - global.attachEvent('onunload', unloadHandler); - } else if (global.addEventListener) { - global.addEventListener('beforeunload', unloadHandler, false); + if (typeof document !== 'undefined') { + if (typeof attachEvent === 'function') { + attachEvent('onunload', unloadHandler); + } else if (typeof addEventListener === 'function') { + addEventListener('beforeunload', unloadHandler, false); } } @@ -1354,7 +1356,6 @@ return /******/ (function(modules) { // webpackBootstrap } } } - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 6 */ @@ -1367,11 +1368,11 @@ return /******/ (function(modules) { // webpackBootstrap */ var Transport = __webpack_require__(7); - var parseqs = __webpack_require__(19); + var parseqs = __webpack_require__(18); var parser = __webpack_require__(8); - var inherit = __webpack_require__(20); - var yeast = __webpack_require__(21); - var debug = __webpack_require__(22)('engine.io-client:polling'); + var inherit = __webpack_require__(19); + var yeast = __webpack_require__(20); + var debug = __webpack_require__(21)('engine.io-client:polling'); /** * Module exports. @@ -1618,7 +1619,7 @@ return /******/ (function(modules) { // webpackBootstrap */ var parser = __webpack_require__(8); - var Emitter = __webpack_require__(18); + var Emitter = __webpack_require__(17); /** * Module exports. @@ -1656,6 +1657,9 @@ return /******/ (function(modules) { // webpackBootstrap this.rejectUnauthorized = opts.rejectUnauthorized; this.forceNode = opts.forceNode; + // results of ReactNative environment detection + this.isReactNative = opts.isReactNative; + // other options for Node.js client this.extraHeaders = opts.extraHeaders; this.localAddress = opts.localAddress; @@ -1775,7 +1779,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 8 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {/** + /** * Module dependencies. */ @@ -1786,8 +1790,8 @@ return /******/ (function(modules) { // webpackBootstrap var utf8 = __webpack_require__(14); var base64encoder; - if (global && global.ArrayBuffer) { - base64encoder = __webpack_require__(16); + if (typeof ArrayBuffer !== 'undefined') { + base64encoder = __webpack_require__(15); } /** @@ -1845,7 +1849,7 @@ return /******/ (function(modules) { // webpackBootstrap * Create a blob api even for blob builder when vendor prefixes exist */ - var Blob = __webpack_require__(17); + var Blob = __webpack_require__(16); /** * Encodes a packet. @@ -1878,9 +1882,9 @@ return /******/ (function(modules) { // webpackBootstrap ? undefined : packet.data.buffer || packet.data; - if (global.ArrayBuffer && data instanceof ArrayBuffer) { + if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) { return encodeArrayBuffer(packet, supportsBinary, callback); - } else if (Blob && data instanceof global.Blob) { + } else if (typeof Blob !== 'undefined' && data instanceof Blob) { return encodeBlob(packet, supportsBinary, callback); } @@ -1935,8 +1939,7 @@ return /******/ (function(modules) { // webpackBootstrap var fr = new FileReader(); fr.onload = function() { - packet.data = fr.result; - exports.encodePacket(packet, supportsBinary, true, callback); + exports.encodePacket({ type: packet.type, data: fr.result }, supportsBinary, true, callback); }; return fr.readAsArrayBuffer(packet.data); } @@ -1966,7 +1969,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.encodeBase64Packet = function(packet, callback) { var message = 'b' + exports.packets[packet.type]; - if (Blob && packet.data instanceof global.Blob) { + if (typeof Blob !== 'undefined' && packet.data instanceof Blob) { var fr = new FileReader(); fr.onload = function() { var b64 = fr.result.split(',')[1]; @@ -1987,7 +1990,7 @@ return /******/ (function(modules) { // webpackBootstrap } b64data = String.fromCharCode.apply(null, basic); } - message += global.btoa(b64data); + message += btoa(b64data); return callback(message); }; @@ -2382,7 +2385,6 @@ return /******/ (function(modules) { // webpackBootstrap }); }; - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 9 */ @@ -2413,7 +2415,7 @@ return /******/ (function(modules) { // webpackBootstrap /* 10 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {/* global Blob File */ + /* global Blob File */ /* * Module requirements. @@ -2422,8 +2424,10 @@ return /******/ (function(modules) { // webpackBootstrap var isArray = __webpack_require__(11); var toString = Object.prototype.toString; - var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]'; - var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]'; + var withNativeBlob = typeof Blob === 'function' || + typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]'; + var withNativeFile = typeof File === 'function' || + typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]'; /** * Module exports. @@ -2454,11 +2458,11 @@ return /******/ (function(modules) { // webpackBootstrap return false; } - if ((typeof global.Buffer === 'function' && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || - (typeof global.ArrayBuffer === 'function' && obj instanceof ArrayBuffer) || - (withNativeBlob && obj instanceof Blob) || - (withNativeFile && obj instanceof File) - ) { + if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) || + (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) || + (withNativeBlob && obj instanceof Blob) || + (withNativeFile && obj instanceof File) + ) { return true; } @@ -2476,7 +2480,6 @@ return /******/ (function(modules) { // webpackBootstrap return false; } - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, /* 11 */ @@ -2560,282 +2563,222 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, /* 14 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/*! https://mths.be/utf8js v2.1.2 by @mathias */ - ;(function(root) { - - // Detect free variables `exports` - var freeExports = typeof exports == 'object' && exports; - - // Detect free variable `module` - var freeModule = typeof module == 'object' && module && - module.exports == freeExports && module; - - // Detect free variable `global`, from Node.js or Browserified code, - // and use it as `root` - var freeGlobal = typeof global == 'object' && global; - if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { - root = freeGlobal; - } +/***/ function(module, exports) { - /*--------------------------------------------------------------------------*/ - - var stringFromCharCode = String.fromCharCode; - - // Taken from https://mths.be/punycode - function ucs2decode(string) { - var output = []; - var counter = 0; - var length = string.length; - var value; - var extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } + /*! https://mths.be/utf8js v2.1.2 by @mathias */ + + var stringFromCharCode = String.fromCharCode; + + // Taken from https://mths.be/punycode + function ucs2decode(string) { + var output = []; + var counter = 0; + var length = string.length; + var value; + var extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair output.push(value); + counter--; } + } else { + output.push(value); } - return output; } + return output; + } - // Taken from https://mths.be/punycode - function ucs2encode(array) { - var length = array.length; - var index = -1; - var value; - var output = ''; - while (++index < length) { - value = array[index]; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); + // Taken from https://mths.be/punycode + function ucs2encode(array) { + var length = array.length; + var index = -1; + var value; + var output = ''; + while (++index < length) { + value = array[index]; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; } - return output; + output += stringFromCharCode(value); } + return output; + } - function checkScalarValue(codePoint, strict) { - if (codePoint >= 0xD800 && codePoint <= 0xDFFF) { - if (strict) { - throw Error( - 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() + - ' is not a scalar value' - ); - } - return false; + function checkScalarValue(codePoint, strict) { + if (codePoint >= 0xD800 && codePoint <= 0xDFFF) { + if (strict) { + throw Error( + 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() + + ' is not a scalar value' + ); } - return true; + return false; } - /*--------------------------------------------------------------------------*/ + return true; + } + /*--------------------------------------------------------------------------*/ - function createByte(codePoint, shift) { - return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); - } + function createByte(codePoint, shift) { + return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80); + } - function encodeCodePoint(codePoint, strict) { - if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence - return stringFromCharCode(codePoint); - } - var symbol = ''; - if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence - symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0); - } - else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence - if (!checkScalarValue(codePoint, strict)) { - codePoint = 0xFFFD; - } - symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0); - symbol += createByte(codePoint, 6); - } - else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence - symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0); - symbol += createByte(codePoint, 12); - symbol += createByte(codePoint, 6); - } - symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); - return symbol; + function encodeCodePoint(codePoint, strict) { + if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence + return stringFromCharCode(codePoint); } - - function utf8encode(string, opts) { - opts = opts || {}; - var strict = false !== opts.strict; - - var codePoints = ucs2decode(string); - var length = codePoints.length; - var index = -1; - var codePoint; - var byteString = ''; - while (++index < length) { - codePoint = codePoints[index]; - byteString += encodeCodePoint(codePoint, strict); + var symbol = ''; + if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence + symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0); + } + else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence + if (!checkScalarValue(codePoint, strict)) { + codePoint = 0xFFFD; } - return byteString; + symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0); + symbol += createByte(codePoint, 6); + } + else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence + symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0); + symbol += createByte(codePoint, 12); + symbol += createByte(codePoint, 6); } + symbol += stringFromCharCode((codePoint & 0x3F) | 0x80); + return symbol; + } - /*--------------------------------------------------------------------------*/ + function utf8encode(string, opts) { + opts = opts || {}; + var strict = false !== opts.strict; + + var codePoints = ucs2decode(string); + var length = codePoints.length; + var index = -1; + var codePoint; + var byteString = ''; + while (++index < length) { + codePoint = codePoints[index]; + byteString += encodeCodePoint(codePoint, strict); + } + return byteString; + } - function readContinuationByte() { - if (byteIndex >= byteCount) { - throw Error('Invalid byte index'); - } + /*--------------------------------------------------------------------------*/ - var continuationByte = byteArray[byteIndex] & 0xFF; - byteIndex++; + function readContinuationByte() { + if (byteIndex >= byteCount) { + throw Error('Invalid byte index'); + } - if ((continuationByte & 0xC0) == 0x80) { - return continuationByte & 0x3F; - } + var continuationByte = byteArray[byteIndex] & 0xFF; + byteIndex++; - // If we end up here, it’s not a continuation byte - throw Error('Invalid continuation byte'); + if ((continuationByte & 0xC0) == 0x80) { + return continuationByte & 0x3F; } - function decodeSymbol(strict) { - var byte1; - var byte2; - var byte3; - var byte4; - var codePoint; + // If we end up here, it’s not a continuation byte + throw Error('Invalid continuation byte'); + } - if (byteIndex > byteCount) { - throw Error('Invalid byte index'); - } + function decodeSymbol(strict) { + var byte1; + var byte2; + var byte3; + var byte4; + var codePoint; - if (byteIndex == byteCount) { - return false; - } + if (byteIndex > byteCount) { + throw Error('Invalid byte index'); + } - // Read first byte - byte1 = byteArray[byteIndex] & 0xFF; - byteIndex++; + if (byteIndex == byteCount) { + return false; + } - // 1-byte sequence (no continuation bytes) - if ((byte1 & 0x80) == 0) { - return byte1; - } + // Read first byte + byte1 = byteArray[byteIndex] & 0xFF; + byteIndex++; - // 2-byte sequence - if ((byte1 & 0xE0) == 0xC0) { - byte2 = readContinuationByte(); - codePoint = ((byte1 & 0x1F) << 6) | byte2; - if (codePoint >= 0x80) { - return codePoint; - } else { - throw Error('Invalid continuation byte'); - } - } + // 1-byte sequence (no continuation bytes) + if ((byte1 & 0x80) == 0) { + return byte1; + } - // 3-byte sequence (may include unpaired surrogates) - if ((byte1 & 0xF0) == 0xE0) { - byte2 = readContinuationByte(); - byte3 = readContinuationByte(); - codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3; - if (codePoint >= 0x0800) { - return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD; - } else { - throw Error('Invalid continuation byte'); - } + // 2-byte sequence + if ((byte1 & 0xE0) == 0xC0) { + byte2 = readContinuationByte(); + codePoint = ((byte1 & 0x1F) << 6) | byte2; + if (codePoint >= 0x80) { + return codePoint; + } else { + throw Error('Invalid continuation byte'); } - - // 4-byte sequence - if ((byte1 & 0xF8) == 0xF0) { - byte2 = readContinuationByte(); - byte3 = readContinuationByte(); - byte4 = readContinuationByte(); - codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) | - (byte3 << 0x06) | byte4; - if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) { - return codePoint; - } - } - - throw Error('Invalid UTF-8 detected'); } - var byteArray; - var byteCount; - var byteIndex; - function utf8decode(byteString, opts) { - opts = opts || {}; - var strict = false !== opts.strict; - - byteArray = ucs2decode(byteString); - byteCount = byteArray.length; - byteIndex = 0; - var codePoints = []; - var tmp; - while ((tmp = decodeSymbol(strict)) !== false) { - codePoints.push(tmp); + // 3-byte sequence (may include unpaired surrogates) + if ((byte1 & 0xF0) == 0xE0) { + byte2 = readContinuationByte(); + byte3 = readContinuationByte(); + codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3; + if (codePoint >= 0x0800) { + return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD; + } else { + throw Error('Invalid continuation byte'); } - return ucs2encode(codePoints); } - /*--------------------------------------------------------------------------*/ - - var utf8 = { - 'version': '2.1.2', - 'encode': utf8encode, - 'decode': utf8decode - }; - - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - true - ) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { - return utf8; - }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (freeExports && !freeExports.nodeType) { - if (freeModule) { // in Node.js or RingoJS v0.8.0+ - freeModule.exports = utf8; - } else { // in Narwhal or RingoJS v0.7.0- - var object = {}; - var hasOwnProperty = object.hasOwnProperty; - for (var key in utf8) { - hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]); - } + // 4-byte sequence + if ((byte1 & 0xF8) == 0xF0) { + byte2 = readContinuationByte(); + byte3 = readContinuationByte(); + byte4 = readContinuationByte(); + codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) | + (byte3 << 0x06) | byte4; + if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) { + return codePoint; } - } else { // in Rhino or a web browser - root.utf8 = utf8; } - }(this)); - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15)(module), (function() { return this; }()))) + throw Error('Invalid UTF-8 detected'); + } -/***/ }, -/* 15 */ -/***/ function(module, exports) { + var byteArray; + var byteCount; + var byteIndex; + function utf8decode(byteString, opts) { + opts = opts || {}; + var strict = false !== opts.strict; + + byteArray = ucs2decode(byteString); + byteCount = byteArray.length; + byteIndex = 0; + var codePoints = []; + var tmp; + while ((tmp = decodeSymbol(strict)) !== false) { + codePoints.push(tmp); + } + return ucs2encode(codePoints); + } - module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - module.children = []; - module.webpackPolyfill = 1; - } - return module; - } + module.exports = { + version: '2.1.2', + encode: utf8encode, + decode: utf8decode + }; /***/ }, -/* 16 */ +/* 15 */ /***/ function(module, exports) { /* @@ -2908,110 +2851,113 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 17 */ +/* 16 */ /***/ function(module, exports) { - /* WEBPACK VAR INJECTION */(function(global) {/** - * Create a blob builder even when vendor prefixes exist - */ - - var BlobBuilder = global.BlobBuilder - || global.WebKitBlobBuilder - || global.MSBlobBuilder - || global.MozBlobBuilder; - - /** - * Check if Blob constructor is supported - */ - - var blobSupported = (function() { - try { - var a = new Blob(['hi']); - return a.size === 2; - } catch(e) { - return false; - } - })(); - - /** - * Check if Blob constructor supports ArrayBufferViews - * Fails in Safari 6, so we need to map to ArrayBuffers there. - */ - - var blobSupportsArrayBufferView = blobSupported && (function() { - try { - var b = new Blob([new Uint8Array([1,2])]); - return b.size === 2; - } catch(e) { - return false; - } - })(); - - /** - * Check if BlobBuilder is supported - */ - - var blobBuilderSupported = BlobBuilder - && BlobBuilder.prototype.append - && BlobBuilder.prototype.getBlob; - - /** - * Helper function that maps ArrayBufferViews to ArrayBuffers - * Used by BlobBuilder constructor and old browsers that didn't - * support it in the Blob constructor. - */ - - function mapArrayBufferViews(ary) { - for (var i = 0; i < ary.length; i++) { - var chunk = ary[i]; - if (chunk.buffer instanceof ArrayBuffer) { - var buf = chunk.buffer; - - // if this is a subarray, make a copy so we only - // include the subarray region from the underlying buffer - if (chunk.byteLength !== buf.byteLength) { - var copy = new Uint8Array(chunk.byteLength); - copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength)); - buf = copy.buffer; - } - - ary[i] = buf; - } - } - } - - function BlobBuilderConstructor(ary, options) { - options = options || {}; - - var bb = new BlobBuilder(); - mapArrayBufferViews(ary); - - for (var i = 0; i < ary.length; i++) { - bb.append(ary[i]); - } - - return (options.type) ? bb.getBlob(options.type) : bb.getBlob(); - }; - - function BlobConstructor(ary, options) { - mapArrayBufferViews(ary); - return new Blob(ary, options || {}); - }; - - module.exports = (function() { - if (blobSupported) { - return blobSupportsArrayBufferView ? global.Blob : BlobConstructor; - } else if (blobBuilderSupported) { - return BlobBuilderConstructor; - } else { - return undefined; - } - })(); + /** + * Create a blob builder even when vendor prefixes exist + */ + + var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : + typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder : + typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : + typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : + false; + + /** + * Check if Blob constructor is supported + */ + + var blobSupported = (function() { + try { + var a = new Blob(['hi']); + return a.size === 2; + } catch(e) { + return false; + } + })(); + + /** + * Check if Blob constructor supports ArrayBufferViews + * Fails in Safari 6, so we need to map to ArrayBuffers there. + */ + + var blobSupportsArrayBufferView = blobSupported && (function() { + try { + var b = new Blob([new Uint8Array([1,2])]); + return b.size === 2; + } catch(e) { + return false; + } + })(); + + /** + * Check if BlobBuilder is supported + */ + + var blobBuilderSupported = BlobBuilder + && BlobBuilder.prototype.append + && BlobBuilder.prototype.getBlob; + + /** + * Helper function that maps ArrayBufferViews to ArrayBuffers + * Used by BlobBuilder constructor and old browsers that didn't + * support it in the Blob constructor. + */ + + function mapArrayBufferViews(ary) { + return ary.map(function(chunk) { + if (chunk.buffer instanceof ArrayBuffer) { + var buf = chunk.buffer; + + // if this is a subarray, make a copy so we only + // include the subarray region from the underlying buffer + if (chunk.byteLength !== buf.byteLength) { + var copy = new Uint8Array(chunk.byteLength); + copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength)); + buf = copy.buffer; + } + + return buf; + } + + return chunk; + }); + } + + function BlobBuilderConstructor(ary, options) { + options = options || {}; + + var bb = new BlobBuilder(); + mapArrayBufferViews(ary).forEach(function(part) { + bb.append(part); + }); + + return (options.type) ? bb.getBlob(options.type) : bb.getBlob(); + }; + + function BlobConstructor(ary, options) { + return new Blob(mapArrayBufferViews(ary), options || {}); + }; + + if (typeof Blob !== 'undefined') { + BlobBuilderConstructor.prototype = Blob.prototype; + BlobConstructor.prototype = Blob.prototype; + } + + module.exports = (function() { + if (blobSupported) { + return blobSupportsArrayBufferView ? Blob : BlobConstructor; + } else if (blobBuilderSupported) { + return BlobBuilderConstructor; + } else { + return undefined; + } + })(); - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 18 */ +/* 17 */ /***/ function(module, exports, __webpack_require__) { @@ -3180,7 +3126,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 19 */ +/* 18 */ /***/ function(module, exports) { /** @@ -3223,7 +3169,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 20 */ +/* 19 */ /***/ function(module, exports) { @@ -3235,7 +3181,7 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 21 */ +/* 20 */ /***/ function(module, exports) { 'use strict'; @@ -3309,7 +3255,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 22 */ +/* 21 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** @@ -3318,7 +3264,7 @@ return /******/ (function(modules) { // webpackBootstrap * Expose `debug()` as the module. */ - exports = module.exports = __webpack_require__(24); + exports = module.exports = __webpack_require__(23); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -3508,10 +3454,10 @@ return /******/ (function(modules) { // webpackBootstrap } catch (e) {} } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(23))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22))) /***/ }, -/* 23 */ +/* 22 */ /***/ function(module, exports) { // shim for using process in browser @@ -3701,7 +3647,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 24 */ +/* 23 */ /***/ function(module, exports, __webpack_require__) { @@ -3717,7 +3663,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.disable = disable; exports.enable = enable; exports.enabled = enabled; - exports.humanize = __webpack_require__(25); + exports.humanize = __webpack_require__(24); /** * Active `debug` instances. @@ -3932,7 +3878,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 25 */ +/* 24 */ /***/ function(module, exports) { /** @@ -4090,17 +4036,17 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 26 */ +/* 25 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + 'use strict'; /** * Module requirements. */ var Polling = __webpack_require__(6); - var inherit = __webpack_require__(20); + var inherit = __webpack_require__(19); /** * Module exports. @@ -4143,8 +4089,8 @@ return /******/ (function(modules) { // webpackBootstrap // we do this here (lazily) to avoid unneeded global pollution if (!callbacks) { // we need to consider multiple engines in the same page - if (!global.___eio) global.___eio = []; - callbacks = global.___eio; + if (!window.___eio) window.___eio = []; + callbacks = window.___eio; } // callback identifier @@ -4160,8 +4106,8 @@ return /******/ (function(modules) { // webpackBootstrap this.query.j = this.index; // prevent spurious errors from being emitted when the window is unloaded - if (global.document && global.addEventListener) { - global.addEventListener('beforeunload', function () { + if (typeof addEventListener === 'function') { + addEventListener('beforeunload', function () { if (self.script) self.script.onerror = empty; }, false); } @@ -4325,13 +4271,12 @@ return /******/ (function(modules) { // webpackBootstrap this.iframe.onload = complete; } }; - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 27 */ +/* 26 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + 'use strict'; /** * Module dependencies. @@ -4339,16 +4284,17 @@ return /******/ (function(modules) { // webpackBootstrap var Transport = __webpack_require__(7); var parser = __webpack_require__(8); - var parseqs = __webpack_require__(19); - var inherit = __webpack_require__(20); - var yeast = __webpack_require__(21); - var debug = __webpack_require__(22)('engine.io-client:websocket'); - var BrowserWebSocket = global.WebSocket || global.MozWebSocket; - var NodeWebSocket; - if (typeof window === 'undefined') { + var parseqs = __webpack_require__(18); + var inherit = __webpack_require__(19); + var yeast = __webpack_require__(20); + var debug = __webpack_require__(21)('engine.io-client:websocket'); + var BrowserWebSocket, NodeWebSocket; + if (typeof self === 'undefined') { try { - NodeWebSocket = __webpack_require__(28); + NodeWebSocket = __webpack_require__(27); } catch (e) {} + } else { + BrowserWebSocket = self.WebSocket || self.MozWebSocket; } /** @@ -4357,10 +4303,7 @@ return /******/ (function(modules) { // webpackBootstrap * interface exposed by `ws` for Node-like environment. */ - var WebSocket = BrowserWebSocket; - if (!WebSocket && typeof window === 'undefined') { - WebSocket = NodeWebSocket; - } + var WebSocket = BrowserWebSocket || NodeWebSocket; /** * Module exports. @@ -4444,7 +4387,7 @@ return /******/ (function(modules) { // webpackBootstrap } try { - this.ws = this.usingBrowserWebSocket ? protocols ? new WebSocket(uri, protocols) : new WebSocket(uri) : new WebSocket(uri, protocols, opts); + this.ws = this.usingBrowserWebSocket && !this.isReactNative ? protocols ? new WebSocket(uri, protocols) : new WebSocket(uri) : new WebSocket(uri, protocols, opts); } catch (err) { return this.emit('error', err); } @@ -4511,7 +4454,7 @@ return /******/ (function(modules) { // webpackBootstrap } if (self.perMessageDeflate) { - var len = 'string' === typeof data ? global.Buffer.byteLength(data) : data.length; + var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length; if (len < self.perMessageDeflate.threshold) { opts.compress = false; } @@ -4618,16 +4561,15 @@ return /******/ (function(modules) { // webpackBootstrap WS.prototype.check = function () { return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name); }; - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 28 */ +/* 27 */ /***/ function(module, exports) { /* (ignored) */ /***/ }, -/* 29 */ +/* 28 */ /***/ function(module, exports) { @@ -4642,7 +4584,7 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 30 */ +/* 29 */ /***/ function(module, exports) { /** diff --git a/package.json b/package.json index 257bce722..cf6b0b3de 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.2.1", + "version": "3.3.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.2.0", + "engine.io": "3.3.0", "eslint-config-standard": "4.4.0", "eslint-plugin-standard": "1.3.1", "expect.js": "^0.3.1",