diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 196c48004..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,25 +0,0 @@ - -*Note*: for support questions, please use one of these channels: [stackoverflow](http://stackoverflow.com/questions/tagged/engine.io) or [slack](https://socketio.slack.com) - -### You want to: - -* [x] report a *bug* -* [ ] request a *feature* - -### Current behaviour - - -### Steps to reproduce (if the current behaviour is a bug) - - -### Expected behaviour - - -### Setup -- OS: -- browser: -- engine.io version: - -### Other information (e.g. stacktraces, related issues, suggestions how to fix) - - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..7deb7968f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,66 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** + +Please fill the following code example: + +Engine.IO server version: `x.y.z` + +*Server* + +```js +const engine = require("engine.io"); +const server = engine.listen(3000, {}); + +server.on("connection", (socket) => { + console.log("connection"); + + socket.on("message", (data) => { + console.log("data", data); + }); + + socket.on("close", () => { + console.log("close"); + }); +}); +``` + +Engine.IO client version: `x.y.z` + +*Client* + +```js +const socket = require("engine.io-client")("ws://localhost:3000"); + +socket.on("open", () => { + console.log("open"); + + socket.on("message", (data) => { + console.log("data", data); + }); + + socket.on("close", () => { + console.log("close"); + }); +}); +``` + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Platform:** + - Device: [e.g. Samsung S8] + - OS: [e.g. Android 9.2] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..fe32cb299 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a Question + url: https://github.com/socketio/socket.io/discussions/new?category=q-a + about: Ask the community for help diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..36014cde5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: 'enhancement' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..e501ea4d2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * 0' + +jobs: + test-node: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm test + env: + CI: true + + test-browser: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - run: npm ci + - run: npm test + env: + CI: true + BROWSERS: 1 + NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }} + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + timeout-minutes: 10 diff --git a/.gitignore b/.gitignore index ceb0d24ae..362295943 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ components /coverage npm-debug.log .idea -test/support/public/engine.io.js +test/support/public/engine.io.min.js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..8f567aa41 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +test/support/public/engine.io.min.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ae563dce1..000000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: node_js -sudo: false -node_js: - - "10" - - "12" - - "14" -git: - depth: 1 -matrix: - include: - - node_js: '10' - env: BROWSERS=1 -cache: - directories: - - node_modules -env: - global: - - secure: EeWHa83dNLzbmwn7tai2D7nnqRMhpbZrWh8054je+6M2Iui6heV412ginyx+MfTBkDe9PF9yPhoknpJ1ZiitbFHVhdofzJJErEHWS33gLVXTL2PU1IzAU9h9T/wVSrVsiNfTARW4Bh9JexVl8x8erTzSh/P6fH2KWx4CaPtmYG4= - - secure: 0yzzTFfFW032oyHzLJPkjgtehnJiqbpmI5kPosjC3Nk0AT6wLSdXuo1Cv5mccggPoqtHQ4oo7e4roLgRaZD34ihc2n98oT5LUPoU6ifA2Z+1zmdmFS9oYTvmkMxaxHlyYuWn47INukGLVJkH5mukb4QDji+v2LjbZVGdVHL5iNM= - - secure: l2aD07VwTMZh+8dcE7u7X0lpdYuwl/wk5no1hxaOKvnHiaVSW39kEJFReO0EZXF/ld7teBNwdWVtRK0P28hKjXEr4Z1OjvGyz6WYZ6cSwxAPmDoTaKC4z1NsAlatqjOKyjSqadncYzWwKS+Trxgj8eO1mZt5h+EvgU2gz6l2N+I= diff --git a/CHANGELOG.md b/CHANGELOG.md index 64c042a5f..965f75746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,86 @@ +## [4.1.4](https://github.com/socketio/engine.io-client/compare/4.1.3...4.1.4) (2021-05-05) + +This release only contains a bump of `xmlhttprequest-ssl`, in order to fix the following vulnerability: https://www.npmjs.com/advisories/1665. + +Please note that `engine.io-client` was not directly impacted by this vulnerability, since we are always using `async: true`. + + +## [4.1.3](https://github.com/socketio/engine.io-client/compare/4.1.2...4.1.3) (2021-03-31) + + +### Bug Fixes + +* ignore packets when the transport is silently closed ([46e6de0](https://github.com/socketio/engine.io-client/commit/46e6de08e3786660307cf4a363ecb47646a43ca5)) + + +## [4.1.2](https://github.com/socketio/engine.io-client/compare/4.1.1...4.1.2) (2021-02-25) + + +### Bug Fixes + +* silently close the transport in the beforeunload hook ([ed48b5d](https://github.com/socketio/engine.io-client/commit/ed48b5dc3407e5ded45072606b3bb0eafa49c01f)) + + +## [4.1.1](https://github.com/socketio/engine.io-client/compare/4.1.0...4.1.1) (2021-02-02) + + +### Bug Fixes + +* remove polyfill for process in the bundle ([c95fdea](https://github.com/socketio/engine.io-client/commit/c95fdea83329b264964641bb48e3be2a8772f7a1)) + + +# [4.1.0](https://github.com/socketio/engine.io-client/compare/4.0.6...4.1.0) (2021-01-14) + + +### Features + +* add missing ws options ([d134fee](https://github.com/socketio/engine.io-client/commit/d134feeaa615afc4cbe0aa45aa4344c899b65df0)) + + +## [4.0.6](https://github.com/socketio/engine.io-client/compare/4.0.5...4.0.6) (2021-01-04) + + +# [3.5.0](https://github.com/socketio/engine.io-client/compare/3.4.4...3.5.0) (2020-12-30) + + +### Bug Fixes + +* check the type of the initial packet ([8750356](https://github.com/socketio/engine.io-client/commit/8750356dba5409ba0e1d3a27da6d214118702b3e)) + + + +## [4.0.5](https://github.com/socketio/engine.io-client/compare/4.0.4...4.0.5) (2020-12-07) + + +## [4.0.4](https://github.com/socketio/engine.io-client/compare/4.0.3...4.0.4) (2020-11-17) + + +### Bug Fixes + +* check the type of the initial packet ([1c8cba8](https://github.com/socketio/engine.io-client/commit/1c8cba8818e930205918a70f05c1164865842a48)) +* restore the cherry-picking of the WebSocket options ([4873a23](https://github.com/socketio/engine.io-client/commit/4873a237f1ce5fcb18e255dd604d50dcfc624ea8)) + + +## [4.0.3](https://github.com/socketio/engine.io-client/compare/4.0.2...4.0.3) (2020-11-17) + + +### Bug Fixes + +* **react-native:** add a default value for the withCredentials option ([ccb99e3](https://github.com/socketio/engine.io-client/commit/ccb99e3718e8ee2c50960430d2bd6c12a3dcb0dc)) +* **react-native:** exclude the localAddress option ([177b95f](https://github.com/socketio/engine.io-client/commit/177b95fe463ad049b35170f042a771380fdaedee)) + + +## [4.0.2](https://github.com/socketio/engine.io-client/compare/4.0.1...4.0.2) (2020-11-09) + + +## [4.0.1](https://github.com/socketio/engine.io-client/compare/4.0.0...4.0.1) (2020-10-21) + + + +## [3.4.4](https://github.com/socketio/engine.io-client/compare/3.4.3...3.4.4) (2020-09-30) + + + # [4.0.0](https://github.com/socketio/engine.io-client/compare/v4.0.0-alpha.1...4.0.0) (2020-09-10) More details about this release in the blog post: https://socket.io/blog/engine-io-4-release/ diff --git a/README.md b/README.md index 1971499d7..9dc765086 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Engine.IO client -[![Build Status](https://travis-ci.org/socketio/engine.io-client.svg?branch=master)](http://travis-ci.org/socketio/engine.io-client) +[![Build Status](https://github.com/socketio/engine.io-client/workflows/CI/badge.svg?branch=master)](https://github.com/socketio/engine.io-client/actions) [![NPM version](https://badge.fury.io/js/engine.io-client.svg)](http://badge.fury.io/js/engine.io-client) This is the client for [Engine.IO](http://github.com/socketio/engine.io), @@ -231,12 +231,11 @@ Exposed as `eio` in the browser standalone build. will be used instead. - `forceBase64` (`Boolean`): forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary. - `enablesXDR` (`Boolean`): enables XDomainRequest for IE8 to avoid loading bar flashing with click sound. default to `false` because XDomainRequest has a flaw of not sending cookie. - - `withCredentials` (`Boolean`): defaults to `true`, whether to include credentials (cookies, authorization headers, TLS client certificates, etc.) with cross-origin XHR polling requests. + - `withCredentials` (`Boolean`): defaults to `false`, whether to include credentials (cookies, authorization headers, TLS client certificates, etc.) with cross-origin XHR polling requests. - `timestampRequests` (`Boolean`): whether to add the timestamp with each transport request. Note: polling requests are always stamped unless this option is explicitly set to `false` (`false`) - `timestampParam` (`String`): timestamp parameter (`t`) - - `policyPort` (`Number`): port the policy server listens on (`843`) - `path` (`String`): path to connect to, default is `/engine.io` - `transports` (`Array`): a list of transports to try (in order). Defaults to `['polling', 'websocket']`. `Engine` diff --git a/dist/engine.io.js b/dist/engine.io.js index 0f82f47ad..959cea23e 100644 --- a/dist/engine.io.js +++ b/dist/engine.io.js @@ -1,6 +1,6 @@ /*! - * Engine.IO v4.0.0 - * (c) 2014-2020 Guillermo Rauch + * Engine.IO v4.1.4 + * (c) 2014-2021 Guillermo Rauch * Released under the MIT License. */ (function webpackUniversalModuleDefinition(root, factory) { @@ -12,17 +12,7 @@ exports["eio"] = factory(); else root["eio"] = factory(); -})((() => { - if (typeof self !== 'undefined') { - return self; - } else if (typeof window !== 'undefined') { - return window; - } else if (typeof global !== 'undefined') { - return global; - } else { - return Function('return this')(); - } - })(), function() { +})(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -140,7 +130,7 @@ eval("var Socket = __webpack_require__(/*! ./socket */ \"./lib/socket.js\");\n\n /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar transports = __webpack_require__(/*! ./transports/index */ \"./lib/transports/index.js\");\n\nvar Emitter = __webpack_require__(/*! component-emitter */ \"./node_modules/component-emitter/index.js\");\n\nvar debug = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")(\"engine.io-client:socket\");\n\nvar parser = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/lib/index.js\");\n\nvar parseuri = __webpack_require__(/*! parseuri */ \"./node_modules/parseuri/index.js\");\n\nvar parseqs = __webpack_require__(/*! parseqs */ \"./node_modules/parseqs/index.js\");\n\nvar Socket =\n/*#__PURE__*/\nfunction (_Emitter) {\n _inherits(Socket, _Emitter);\n\n /**\n * Socket constructor.\n *\n * @param {String|Object} uri or options\n * @param {Object} options\n * @api public\n */\n function Socket(uri) {\n var _this;\n\n var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Socket);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Socket).call(this));\n\n if (uri && \"object\" === _typeof(uri)) {\n opts = uri;\n uri = null;\n }\n\n if (uri) {\n uri = parseuri(uri);\n opts.hostname = uri.host;\n opts.secure = uri.protocol === \"https\" || uri.protocol === \"wss\";\n opts.port = uri.port;\n if (uri.query) opts.query = uri.query;\n } else if (opts.host) {\n opts.hostname = parseuri(opts.host).host;\n }\n\n _this.secure = null != opts.secure ? opts.secure : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n\n if (opts.hostname && !opts.port) {\n // if no port is specified manually, use the protocol default\n opts.port = _this.secure ? \"443\" : \"80\";\n }\n\n _this.hostname = opts.hostname || (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n _this.port = opts.port || (typeof location !== \"undefined\" && location.port ? location.port : _this.secure ? 443 : 80);\n _this.transports = opts.transports || [\"polling\", \"websocket\"];\n _this.readyState = \"\";\n _this.writeBuffer = [];\n _this.prevBufferLen = 0;\n _this.opts = _extends({\n path: \"/engine.io\",\n agent: false,\n upgrade: true,\n jsonp: true,\n timestampParam: \"t\",\n policyPort: 843,\n rememberUpgrade: false,\n rejectUnauthorized: true,\n perMessageDeflate: {\n threshold: 1024\n },\n transportOptions: {}\n }, opts);\n _this.opts.path = _this.opts.path.replace(/\\/$/, \"\") + \"/\";\n\n if (typeof _this.opts.query === \"string\") {\n _this.opts.query = parseqs.decode(_this.opts.query);\n } // set on handshake\n\n\n _this.id = null;\n _this.upgrades = null;\n _this.pingInterval = null;\n _this.pingTimeout = null; // set on heartbeat\n\n _this.pingTimeoutTimer = null;\n\n _this.open();\n\n return _this;\n }\n /**\n * Creates transport of the given type.\n *\n * @param {String} transport name\n * @return {Transport}\n * @api private\n */\n\n\n _createClass(Socket, [{\n key: \"createTransport\",\n value: function createTransport(name) {\n debug('creating transport \"%s\"', name);\n var query = clone(this.opts.query); // append engine.io protocol identifier\n\n query.EIO = parser.protocol; // transport name\n\n query.transport = name; // session id if we already have one\n\n if (this.id) query.sid = this.id;\n\n var opts = _extends({}, this.opts.transportOptions[name], this.opts, {\n query: query,\n socket: this,\n hostname: this.hostname,\n secure: this.secure,\n port: this.port\n });\n\n debug(\"options: %j\", opts);\n return new transports[name](opts);\n }\n /**\n * Initializes transport to use and starts probe.\n *\n * @api private\n */\n\n }, {\n key: \"open\",\n value: function open() {\n var transport;\n\n if (this.opts.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf(\"websocket\") !== -1) {\n transport = \"websocket\";\n } else if (0 === this.transports.length) {\n // Emit error on next tick so it can be listened to\n var self = this;\n setTimeout(function () {\n self.emit(\"error\", \"No transports available\");\n }, 0);\n return;\n } else {\n transport = this.transports[0];\n }\n\n this.readyState = \"opening\"; // Retry with the next transport if the transport is disabled (jsonp: false)\n\n try {\n transport = this.createTransport(transport);\n } catch (e) {\n debug(\"error while creating transport: %s\", e);\n this.transports.shift();\n this.open();\n return;\n }\n\n transport.open();\n this.setTransport(transport);\n }\n /**\n * Sets the current transport. Disables the existing one (if any).\n *\n * @api private\n */\n\n }, {\n key: \"setTransport\",\n value: function setTransport(transport) {\n debug(\"setting transport %s\", transport.name);\n var self = this;\n\n if (this.transport) {\n debug(\"clearing existing transport %s\", this.transport.name);\n this.transport.removeAllListeners();\n } // set up transport\n\n\n this.transport = transport; // set up transport listeners\n\n transport.on(\"drain\", function () {\n self.onDrain();\n }).on(\"packet\", function (packet) {\n self.onPacket(packet);\n }).on(\"error\", function (e) {\n self.onError(e);\n }).on(\"close\", function () {\n self.onClose(\"transport close\");\n });\n }\n /**\n * Probes a transport.\n *\n * @param {String} transport name\n * @api private\n */\n\n }, {\n key: \"probe\",\n value: function probe(name) {\n debug('probing transport \"%s\"', name);\n var transport = this.createTransport(name, {\n probe: 1\n });\n var failed = false;\n var self = this;\n Socket.priorWebsocketSuccess = false;\n\n function onTransportOpen() {\n if (self.onlyBinaryUpgrades) {\n var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;\n failed = failed || upgradeLosesBinary;\n }\n\n if (failed) return;\n debug('probe transport \"%s\" opened', name);\n transport.send([{\n type: \"ping\",\n data: \"probe\"\n }]);\n transport.once(\"packet\", function (msg) {\n if (failed) return;\n\n if (\"pong\" === msg.type && \"probe\" === msg.data) {\n debug('probe transport \"%s\" pong', name);\n self.upgrading = true;\n self.emit(\"upgrading\", transport);\n if (!transport) return;\n Socket.priorWebsocketSuccess = \"websocket\" === transport.name;\n debug('pausing current transport \"%s\"', self.transport.name);\n self.transport.pause(function () {\n if (failed) return;\n if (\"closed\" === self.readyState) return;\n debug(\"changing transport and sending upgrade packet\");\n cleanup();\n self.setTransport(transport);\n transport.send([{\n type: \"upgrade\"\n }]);\n self.emit(\"upgrade\", transport);\n transport = null;\n self.upgrading = false;\n self.flush();\n });\n } else {\n debug('probe transport \"%s\" failed', name);\n var err = new Error(\"probe error\");\n err.transport = transport.name;\n self.emit(\"upgradeError\", err);\n }\n });\n }\n\n function freezeTransport() {\n if (failed) return; // Any callback called by transport should be ignored since now\n\n failed = true;\n cleanup();\n transport.close();\n transport = null;\n } // Handle any error that happens while probing\n\n\n function onerror(err) {\n var error = new Error(\"probe error: \" + err);\n error.transport = transport.name;\n freezeTransport();\n debug('probe transport \"%s\" failed because of error: %s', name, err);\n self.emit(\"upgradeError\", error);\n }\n\n function onTransportClose() {\n onerror(\"transport closed\");\n } // When the socket is closed while we're probing\n\n\n function onclose() {\n onerror(\"socket closed\");\n } // When the socket is upgraded while we're probing\n\n\n function onupgrade(to) {\n if (transport && to.name !== transport.name) {\n debug('\"%s\" works - aborting \"%s\"', to.name, transport.name);\n freezeTransport();\n }\n } // Remove all listeners on the transport and on self\n\n\n function cleanup() {\n transport.removeListener(\"open\", onTransportOpen);\n transport.removeListener(\"error\", onerror);\n transport.removeListener(\"close\", onTransportClose);\n self.removeListener(\"close\", onclose);\n self.removeListener(\"upgrading\", onupgrade);\n }\n\n transport.once(\"open\", onTransportOpen);\n transport.once(\"error\", onerror);\n transport.once(\"close\", onTransportClose);\n this.once(\"close\", onclose);\n this.once(\"upgrading\", onupgrade);\n transport.open();\n }\n /**\n * Called when connection is deemed open.\n *\n * @api public\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n debug(\"socket open\");\n this.readyState = \"open\";\n Socket.priorWebsocketSuccess = \"websocket\" === this.transport.name;\n this.emit(\"open\");\n this.flush(); // we check for `readyState` in case an `open`\n // listener already closed the socket\n\n if (\"open\" === this.readyState && this.opts.upgrade && this.transport.pause) {\n debug(\"starting upgrade probes\");\n var i = 0;\n var l = this.upgrades.length;\n\n for (; i < l; i++) {\n this.probe(this.upgrades[i]);\n }\n }\n }\n /**\n * Handles a packet.\n *\n * @api private\n */\n\n }, {\n key: \"onPacket\",\n value: function onPacket(packet) {\n if (\"opening\" === this.readyState || \"open\" === this.readyState || \"closing\" === this.readyState) {\n debug('socket receive: type \"%s\", data \"%s\"', packet.type, packet.data);\n this.emit(\"packet\", packet); // Socket is live - any packet counts\n\n this.emit(\"heartbeat\");\n\n switch (packet.type) {\n case \"open\":\n this.onHandshake(JSON.parse(packet.data));\n break;\n\n case \"ping\":\n this.resetPingTimeout();\n this.sendPacket(\"pong\");\n this.emit(\"pong\");\n break;\n\n case \"error\":\n var err = new Error(\"server error\");\n err.code = packet.data;\n this.onError(err);\n break;\n\n case \"message\":\n this.emit(\"data\", packet.data);\n this.emit(\"message\", packet.data);\n break;\n }\n } else {\n debug('packet received with socket readyState \"%s\"', this.readyState);\n }\n }\n /**\n * Called upon handshake completion.\n *\n * @param {Object} handshake obj\n * @api private\n */\n\n }, {\n key: \"onHandshake\",\n value: function onHandshake(data) {\n this.emit(\"handshake\", data);\n this.id = data.sid;\n this.transport.query.sid = data.sid;\n this.upgrades = this.filterUpgrades(data.upgrades);\n this.pingInterval = data.pingInterval;\n this.pingTimeout = data.pingTimeout;\n this.onOpen(); // In case open handler closes socket\n\n if (\"closed\" === this.readyState) return;\n this.resetPingTimeout();\n }\n /**\n * Sets and resets ping timeout timer based on server pings.\n *\n * @api private\n */\n\n }, {\n key: \"resetPingTimeout\",\n value: function resetPingTimeout() {\n var _this2 = this;\n\n clearTimeout(this.pingTimeoutTimer);\n this.pingTimeoutTimer = setTimeout(function () {\n _this2.onClose(\"ping timeout\");\n }, this.pingInterval + this.pingTimeout);\n }\n /**\n * Called on `drain` event\n *\n * @api private\n */\n\n }, {\n key: \"onDrain\",\n value: function onDrain() {\n this.writeBuffer.splice(0, this.prevBufferLen); // setting prevBufferLen = 0 is very important\n // for example, when upgrading, upgrade packet is sent over,\n // and a nonzero prevBufferLen could cause problems on `drain`\n\n this.prevBufferLen = 0;\n\n if (0 === this.writeBuffer.length) {\n this.emit(\"drain\");\n } else {\n this.flush();\n }\n }\n /**\n * Flush write buffers.\n *\n * @api private\n */\n\n }, {\n key: \"flush\",\n value: function flush() {\n if (\"closed\" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {\n debug(\"flushing %d packets in socket\", this.writeBuffer.length);\n this.transport.send(this.writeBuffer); // keep track of current length of writeBuffer\n // splice writeBuffer and callbackBuffer on `drain`\n\n this.prevBufferLen = this.writeBuffer.length;\n this.emit(\"flush\");\n }\n }\n /**\n * Sends a message.\n *\n * @param {String} message.\n * @param {Function} callback function.\n * @param {Object} options.\n * @return {Socket} for chaining.\n * @api public\n */\n\n }, {\n key: \"write\",\n value: function write(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n }, {\n key: \"send\",\n value: function send(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n /**\n * Sends a packet.\n *\n * @param {String} packet type.\n * @param {String} data.\n * @param {Object} options.\n * @param {Function} callback function.\n * @api private\n */\n\n }, {\n key: \"sendPacket\",\n value: function sendPacket(type, data, options, fn) {\n if (\"function\" === typeof data) {\n fn = data;\n data = undefined;\n }\n\n if (\"function\" === typeof options) {\n fn = options;\n options = null;\n }\n\n if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n return;\n }\n\n options = options || {};\n options.compress = false !== options.compress;\n var packet = {\n type: type,\n data: data,\n options: options\n };\n this.emit(\"packetCreate\", packet);\n this.writeBuffer.push(packet);\n if (fn) this.once(\"flush\", fn);\n this.flush();\n }\n /**\n * Closes the connection.\n *\n * @api private\n */\n\n }, {\n key: \"close\",\n value: function close() {\n var self = this;\n\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.readyState = \"closing\";\n\n if (this.writeBuffer.length) {\n this.once(\"drain\", function () {\n if (this.upgrading) {\n waitForUpgrade();\n } else {\n close();\n }\n });\n } else if (this.upgrading) {\n waitForUpgrade();\n } else {\n close();\n }\n }\n\n function close() {\n self.onClose(\"forced close\");\n debug(\"socket closing - telling transport to close\");\n self.transport.close();\n }\n\n function cleanupAndClose() {\n self.removeListener(\"upgrade\", cleanupAndClose);\n self.removeListener(\"upgradeError\", cleanupAndClose);\n close();\n }\n\n function waitForUpgrade() {\n // wait for upgrade to finish since we can't send packets while pausing a transport\n self.once(\"upgrade\", cleanupAndClose);\n self.once(\"upgradeError\", cleanupAndClose);\n }\n\n return this;\n }\n /**\n * Called upon transport error\n *\n * @api private\n */\n\n }, {\n key: \"onError\",\n value: function onError(err) {\n debug(\"socket error %j\", err);\n Socket.priorWebsocketSuccess = false;\n this.emit(\"error\", err);\n this.onClose(\"transport error\", err);\n }\n /**\n * Called upon transport close.\n *\n * @api private\n */\n\n }, {\n key: \"onClose\",\n value: function onClose(reason, desc) {\n if (\"opening\" === this.readyState || \"open\" === this.readyState || \"closing\" === this.readyState) {\n debug('socket close with reason: \"%s\"', reason);\n var self = this; // clear timers\n\n clearTimeout(this.pingIntervalTimer);\n clearTimeout(this.pingTimeoutTimer); // stop event from firing again for transport\n\n this.transport.removeAllListeners(\"close\"); // ensure transport won't stay open\n\n this.transport.close(); // ignore further transport communication\n\n this.transport.removeAllListeners(); // set ready state\n\n this.readyState = \"closed\"; // clear session id\n\n this.id = null; // emit close event\n\n this.emit(\"close\", reason, desc); // clean buffers after, so users can still\n // grab the buffers on `close` event\n\n self.writeBuffer = [];\n self.prevBufferLen = 0;\n }\n }\n /**\n * Filters upgrades, returning only those matching client transports.\n *\n * @param {Array} server upgrades\n * @api private\n *\n */\n\n }, {\n key: \"filterUpgrades\",\n value: function filterUpgrades(upgrades) {\n var filteredUpgrades = [];\n var i = 0;\n var j = upgrades.length;\n\n for (; i < j; i++) {\n if (~this.transports.indexOf(upgrades[i])) filteredUpgrades.push(upgrades[i]);\n }\n\n return filteredUpgrades;\n }\n }]);\n\n return Socket;\n}(Emitter);\n\nSocket.priorWebsocketSuccess = false;\n/**\n * Protocol version.\n *\n * @api public\n */\n\nSocket.protocol = parser.protocol; // this is an int\n\nfunction clone(obj) {\n var o = {};\n\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) {\n o[i] = obj[i];\n }\n }\n\n return o;\n}\n\nmodule.exports = Socket;\n\n//# sourceURL=webpack://eio/./lib/socket.js?"); +eval("function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar transports = __webpack_require__(/*! ./transports/index */ \"./lib/transports/index.js\");\n\nvar Emitter = __webpack_require__(/*! component-emitter */ \"./node_modules/component-emitter/index.js\");\n\nvar debug = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")(\"engine.io-client:socket\");\n\nvar parser = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/lib/index.js\");\n\nvar parseuri = __webpack_require__(/*! parseuri */ \"./node_modules/parseuri/index.js\");\n\nvar parseqs = __webpack_require__(/*! parseqs */ \"./node_modules/parseqs/index.js\");\n\nvar Socket = /*#__PURE__*/function (_Emitter) {\n _inherits(Socket, _Emitter);\n\n var _super = _createSuper(Socket);\n\n /**\n * Socket constructor.\n *\n * @param {String|Object} uri or options\n * @param {Object} options\n * @api public\n */\n function Socket(uri) {\n var _this;\n\n var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Socket);\n\n _this = _super.call(this);\n\n if (uri && \"object\" === _typeof(uri)) {\n opts = uri;\n uri = null;\n }\n\n if (uri) {\n uri = parseuri(uri);\n opts.hostname = uri.host;\n opts.secure = uri.protocol === \"https\" || uri.protocol === \"wss\";\n opts.port = uri.port;\n if (uri.query) opts.query = uri.query;\n } else if (opts.host) {\n opts.hostname = parseuri(opts.host).host;\n }\n\n _this.secure = null != opts.secure ? opts.secure : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n\n if (opts.hostname && !opts.port) {\n // if no port is specified manually, use the protocol default\n opts.port = _this.secure ? \"443\" : \"80\";\n }\n\n _this.hostname = opts.hostname || (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n _this.port = opts.port || (typeof location !== \"undefined\" && location.port ? location.port : _this.secure ? 443 : 80);\n _this.transports = opts.transports || [\"polling\", \"websocket\"];\n _this.readyState = \"\";\n _this.writeBuffer = [];\n _this.prevBufferLen = 0;\n _this.opts = _extends({\n path: \"/engine.io\",\n agent: false,\n withCredentials: false,\n upgrade: true,\n jsonp: true,\n timestampParam: \"t\",\n rememberUpgrade: false,\n rejectUnauthorized: true,\n perMessageDeflate: {\n threshold: 1024\n },\n transportOptions: {}\n }, opts);\n _this.opts.path = _this.opts.path.replace(/\\/$/, \"\") + \"/\";\n\n if (typeof _this.opts.query === \"string\") {\n _this.opts.query = parseqs.decode(_this.opts.query);\n } // set on handshake\n\n\n _this.id = null;\n _this.upgrades = null;\n _this.pingInterval = null;\n _this.pingTimeout = null; // set on heartbeat\n\n _this.pingTimeoutTimer = null;\n\n if (typeof addEventListener === \"function\") {\n addEventListener(\"beforeunload\", function () {\n if (_this.transport) {\n // silently close the transport\n _this.transport.removeAllListeners();\n\n _this.transport.close();\n }\n }, false);\n }\n\n _this.open();\n\n return _this;\n }\n /**\n * Creates transport of the given type.\n *\n * @param {String} transport name\n * @return {Transport}\n * @api private\n */\n\n\n _createClass(Socket, [{\n key: \"createTransport\",\n value: function createTransport(name) {\n debug('creating transport \"%s\"', name);\n var query = clone(this.opts.query); // append engine.io protocol identifier\n\n query.EIO = parser.protocol; // transport name\n\n query.transport = name; // session id if we already have one\n\n if (this.id) query.sid = this.id;\n\n var opts = _extends({}, this.opts.transportOptions[name], this.opts, {\n query: query,\n socket: this,\n hostname: this.hostname,\n secure: this.secure,\n port: this.port\n });\n\n debug(\"options: %j\", opts);\n return new transports[name](opts);\n }\n /**\n * Initializes transport to use and starts probe.\n *\n * @api private\n */\n\n }, {\n key: \"open\",\n value: function open() {\n var transport;\n\n if (this.opts.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf(\"websocket\") !== -1) {\n transport = \"websocket\";\n } else if (0 === this.transports.length) {\n // Emit error on next tick so it can be listened to\n var self = this;\n setTimeout(function () {\n self.emit(\"error\", \"No transports available\");\n }, 0);\n return;\n } else {\n transport = this.transports[0];\n }\n\n this.readyState = \"opening\"; // Retry with the next transport if the transport is disabled (jsonp: false)\n\n try {\n transport = this.createTransport(transport);\n } catch (e) {\n debug(\"error while creating transport: %s\", e);\n this.transports.shift();\n this.open();\n return;\n }\n\n transport.open();\n this.setTransport(transport);\n }\n /**\n * Sets the current transport. Disables the existing one (if any).\n *\n * @api private\n */\n\n }, {\n key: \"setTransport\",\n value: function setTransport(transport) {\n debug(\"setting transport %s\", transport.name);\n var self = this;\n\n if (this.transport) {\n debug(\"clearing existing transport %s\", this.transport.name);\n this.transport.removeAllListeners();\n } // set up transport\n\n\n this.transport = transport; // set up transport listeners\n\n transport.on(\"drain\", function () {\n self.onDrain();\n }).on(\"packet\", function (packet) {\n self.onPacket(packet);\n }).on(\"error\", function (e) {\n self.onError(e);\n }).on(\"close\", function () {\n self.onClose(\"transport close\");\n });\n }\n /**\n * Probes a transport.\n *\n * @param {String} transport name\n * @api private\n */\n\n }, {\n key: \"probe\",\n value: function probe(name) {\n debug('probing transport \"%s\"', name);\n var transport = this.createTransport(name, {\n probe: 1\n });\n var failed = false;\n var self = this;\n Socket.priorWebsocketSuccess = false;\n\n function onTransportOpen() {\n if (self.onlyBinaryUpgrades) {\n var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;\n failed = failed || upgradeLosesBinary;\n }\n\n if (failed) return;\n debug('probe transport \"%s\" opened', name);\n transport.send([{\n type: \"ping\",\n data: \"probe\"\n }]);\n transport.once(\"packet\", function (msg) {\n if (failed) return;\n\n if (\"pong\" === msg.type && \"probe\" === msg.data) {\n debug('probe transport \"%s\" pong', name);\n self.upgrading = true;\n self.emit(\"upgrading\", transport);\n if (!transport) return;\n Socket.priorWebsocketSuccess = \"websocket\" === transport.name;\n debug('pausing current transport \"%s\"', self.transport.name);\n self.transport.pause(function () {\n if (failed) return;\n if (\"closed\" === self.readyState) return;\n debug(\"changing transport and sending upgrade packet\");\n cleanup();\n self.setTransport(transport);\n transport.send([{\n type: \"upgrade\"\n }]);\n self.emit(\"upgrade\", transport);\n transport = null;\n self.upgrading = false;\n self.flush();\n });\n } else {\n debug('probe transport \"%s\" failed', name);\n var err = new Error(\"probe error\");\n err.transport = transport.name;\n self.emit(\"upgradeError\", err);\n }\n });\n }\n\n function freezeTransport() {\n if (failed) return; // Any callback called by transport should be ignored since now\n\n failed = true;\n cleanup();\n transport.close();\n transport = null;\n } // Handle any error that happens while probing\n\n\n function onerror(err) {\n var error = new Error(\"probe error: \" + err);\n error.transport = transport.name;\n freezeTransport();\n debug('probe transport \"%s\" failed because of error: %s', name, err);\n self.emit(\"upgradeError\", error);\n }\n\n function onTransportClose() {\n onerror(\"transport closed\");\n } // When the socket is closed while we're probing\n\n\n function onclose() {\n onerror(\"socket closed\");\n } // When the socket is upgraded while we're probing\n\n\n function onupgrade(to) {\n if (transport && to.name !== transport.name) {\n debug('\"%s\" works - aborting \"%s\"', to.name, transport.name);\n freezeTransport();\n }\n } // Remove all listeners on the transport and on self\n\n\n function cleanup() {\n transport.removeListener(\"open\", onTransportOpen);\n transport.removeListener(\"error\", onerror);\n transport.removeListener(\"close\", onTransportClose);\n self.removeListener(\"close\", onclose);\n self.removeListener(\"upgrading\", onupgrade);\n }\n\n transport.once(\"open\", onTransportOpen);\n transport.once(\"error\", onerror);\n transport.once(\"close\", onTransportClose);\n this.once(\"close\", onclose);\n this.once(\"upgrading\", onupgrade);\n transport.open();\n }\n /**\n * Called when connection is deemed open.\n *\n * @api public\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n debug(\"socket open\");\n this.readyState = \"open\";\n Socket.priorWebsocketSuccess = \"websocket\" === this.transport.name;\n this.emit(\"open\");\n this.flush(); // we check for `readyState` in case an `open`\n // listener already closed the socket\n\n if (\"open\" === this.readyState && this.opts.upgrade && this.transport.pause) {\n debug(\"starting upgrade probes\");\n var i = 0;\n var l = this.upgrades.length;\n\n for (; i < l; i++) {\n this.probe(this.upgrades[i]);\n }\n }\n }\n /**\n * Handles a packet.\n *\n * @api private\n */\n\n }, {\n key: \"onPacket\",\n value: function onPacket(packet) {\n if (\"opening\" === this.readyState || \"open\" === this.readyState || \"closing\" === this.readyState) {\n debug('socket receive: type \"%s\", data \"%s\"', packet.type, packet.data);\n this.emit(\"packet\", packet); // Socket is live - any packet counts\n\n this.emit(\"heartbeat\");\n\n switch (packet.type) {\n case \"open\":\n this.onHandshake(JSON.parse(packet.data));\n break;\n\n case \"ping\":\n this.resetPingTimeout();\n this.sendPacket(\"pong\");\n this.emit(\"pong\");\n break;\n\n case \"error\":\n var err = new Error(\"server error\");\n err.code = packet.data;\n this.onError(err);\n break;\n\n case \"message\":\n this.emit(\"data\", packet.data);\n this.emit(\"message\", packet.data);\n break;\n }\n } else {\n debug('packet received with socket readyState \"%s\"', this.readyState);\n }\n }\n /**\n * Called upon handshake completion.\n *\n * @param {Object} handshake obj\n * @api private\n */\n\n }, {\n key: \"onHandshake\",\n value: function onHandshake(data) {\n this.emit(\"handshake\", data);\n this.id = data.sid;\n this.transport.query.sid = data.sid;\n this.upgrades = this.filterUpgrades(data.upgrades);\n this.pingInterval = data.pingInterval;\n this.pingTimeout = data.pingTimeout;\n this.onOpen(); // In case open handler closes socket\n\n if (\"closed\" === this.readyState) return;\n this.resetPingTimeout();\n }\n /**\n * Sets and resets ping timeout timer based on server pings.\n *\n * @api private\n */\n\n }, {\n key: \"resetPingTimeout\",\n value: function resetPingTimeout() {\n var _this2 = this;\n\n clearTimeout(this.pingTimeoutTimer);\n this.pingTimeoutTimer = setTimeout(function () {\n _this2.onClose(\"ping timeout\");\n }, this.pingInterval + this.pingTimeout);\n }\n /**\n * Called on `drain` event\n *\n * @api private\n */\n\n }, {\n key: \"onDrain\",\n value: function onDrain() {\n this.writeBuffer.splice(0, this.prevBufferLen); // setting prevBufferLen = 0 is very important\n // for example, when upgrading, upgrade packet is sent over,\n // and a nonzero prevBufferLen could cause problems on `drain`\n\n this.prevBufferLen = 0;\n\n if (0 === this.writeBuffer.length) {\n this.emit(\"drain\");\n } else {\n this.flush();\n }\n }\n /**\n * Flush write buffers.\n *\n * @api private\n */\n\n }, {\n key: \"flush\",\n value: function flush() {\n if (\"closed\" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {\n debug(\"flushing %d packets in socket\", this.writeBuffer.length);\n this.transport.send(this.writeBuffer); // keep track of current length of writeBuffer\n // splice writeBuffer and callbackBuffer on `drain`\n\n this.prevBufferLen = this.writeBuffer.length;\n this.emit(\"flush\");\n }\n }\n /**\n * Sends a message.\n *\n * @param {String} message.\n * @param {Function} callback function.\n * @param {Object} options.\n * @return {Socket} for chaining.\n * @api public\n */\n\n }, {\n key: \"write\",\n value: function write(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n }, {\n key: \"send\",\n value: function send(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n /**\n * Sends a packet.\n *\n * @param {String} packet type.\n * @param {String} data.\n * @param {Object} options.\n * @param {Function} callback function.\n * @api private\n */\n\n }, {\n key: \"sendPacket\",\n value: function sendPacket(type, data, options, fn) {\n if (\"function\" === typeof data) {\n fn = data;\n data = undefined;\n }\n\n if (\"function\" === typeof options) {\n fn = options;\n options = null;\n }\n\n if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n return;\n }\n\n options = options || {};\n options.compress = false !== options.compress;\n var packet = {\n type: type,\n data: data,\n options: options\n };\n this.emit(\"packetCreate\", packet);\n this.writeBuffer.push(packet);\n if (fn) this.once(\"flush\", fn);\n this.flush();\n }\n /**\n * Closes the connection.\n *\n * @api private\n */\n\n }, {\n key: \"close\",\n value: function close() {\n var self = this;\n\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.readyState = \"closing\";\n\n if (this.writeBuffer.length) {\n this.once(\"drain\", function () {\n if (this.upgrading) {\n waitForUpgrade();\n } else {\n close();\n }\n });\n } else if (this.upgrading) {\n waitForUpgrade();\n } else {\n close();\n }\n }\n\n function close() {\n self.onClose(\"forced close\");\n debug(\"socket closing - telling transport to close\");\n self.transport.close();\n }\n\n function cleanupAndClose() {\n self.removeListener(\"upgrade\", cleanupAndClose);\n self.removeListener(\"upgradeError\", cleanupAndClose);\n close();\n }\n\n function waitForUpgrade() {\n // wait for upgrade to finish since we can't send packets while pausing a transport\n self.once(\"upgrade\", cleanupAndClose);\n self.once(\"upgradeError\", cleanupAndClose);\n }\n\n return this;\n }\n /**\n * Called upon transport error\n *\n * @api private\n */\n\n }, {\n key: \"onError\",\n value: function onError(err) {\n debug(\"socket error %j\", err);\n Socket.priorWebsocketSuccess = false;\n this.emit(\"error\", err);\n this.onClose(\"transport error\", err);\n }\n /**\n * Called upon transport close.\n *\n * @api private\n */\n\n }, {\n key: \"onClose\",\n value: function onClose(reason, desc) {\n if (\"opening\" === this.readyState || \"open\" === this.readyState || \"closing\" === this.readyState) {\n debug('socket close with reason: \"%s\"', reason);\n var self = this; // clear timers\n\n clearTimeout(this.pingIntervalTimer);\n clearTimeout(this.pingTimeoutTimer); // stop event from firing again for transport\n\n this.transport.removeAllListeners(\"close\"); // ensure transport won't stay open\n\n this.transport.close(); // ignore further transport communication\n\n this.transport.removeAllListeners(); // set ready state\n\n this.readyState = \"closed\"; // clear session id\n\n this.id = null; // emit close event\n\n this.emit(\"close\", reason, desc); // clean buffers after, so users can still\n // grab the buffers on `close` event\n\n self.writeBuffer = [];\n self.prevBufferLen = 0;\n }\n }\n /**\n * Filters upgrades, returning only those matching client transports.\n *\n * @param {Array} server upgrades\n * @api private\n *\n */\n\n }, {\n key: \"filterUpgrades\",\n value: function filterUpgrades(upgrades) {\n var filteredUpgrades = [];\n var i = 0;\n var j = upgrades.length;\n\n for (; i < j; i++) {\n if (~this.transports.indexOf(upgrades[i])) filteredUpgrades.push(upgrades[i]);\n }\n\n return filteredUpgrades;\n }\n }]);\n\n return Socket;\n}(Emitter);\n\nSocket.priorWebsocketSuccess = false;\n/**\n * Protocol version.\n *\n * @api public\n */\n\nSocket.protocol = parser.protocol; // this is an int\n\nfunction clone(obj) {\n var o = {};\n\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) {\n o[i] = obj[i];\n }\n }\n\n return o;\n}\n\nmodule.exports = Socket;\n\n//# sourceURL=webpack://eio/./lib/socket.js?"); /***/ }), @@ -151,7 +141,7 @@ eval("function _extends() { _extends = Object.assign || function (target) { for /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar parser = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/lib/index.js\");\n\nvar Emitter = __webpack_require__(/*! component-emitter */ \"./node_modules/component-emitter/index.js\");\n\nvar Transport =\n/*#__PURE__*/\nfunction (_Emitter) {\n _inherits(Transport, _Emitter);\n\n /**\n * Transport abstract constructor.\n *\n * @param {Object} options.\n * @api private\n */\n function Transport(opts) {\n var _this;\n\n _classCallCheck(this, Transport);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Transport).call(this));\n _this.opts = opts;\n _this.query = opts.query;\n _this.readyState = \"\";\n _this.socket = opts.socket;\n return _this;\n }\n /**\n * Emits an error.\n *\n * @param {String} str\n * @return {Transport} for chaining\n * @api public\n */\n\n\n _createClass(Transport, [{\n key: \"onError\",\n value: function onError(msg, desc) {\n var err = new Error(msg);\n err.type = \"TransportError\";\n err.description = desc;\n this.emit(\"error\", err);\n return this;\n }\n /**\n * Opens the transport.\n *\n * @api public\n */\n\n }, {\n key: \"open\",\n value: function open() {\n if (\"closed\" === this.readyState || \"\" === this.readyState) {\n this.readyState = \"opening\";\n this.doOpen();\n }\n\n return this;\n }\n /**\n * Closes the transport.\n *\n * @api private\n */\n\n }, {\n key: \"close\",\n value: function close() {\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.doClose();\n this.onClose();\n }\n\n return this;\n }\n /**\n * Sends multiple packets.\n *\n * @param {Array} packets\n * @api private\n */\n\n }, {\n key: \"send\",\n value: function send(packets) {\n if (\"open\" === this.readyState) {\n this.write(packets);\n } else {\n throw new Error(\"Transport not open\");\n }\n }\n /**\n * Called upon open\n *\n * @api private\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n this.readyState = \"open\";\n this.writable = true;\n this.emit(\"open\");\n }\n /**\n * Called with data.\n *\n * @param {String} data\n * @api private\n */\n\n }, {\n key: \"onData\",\n value: function onData(data) {\n var packet = parser.decodePacket(data, this.socket.binaryType);\n this.onPacket(packet);\n }\n /**\n * Called with a decoded packet.\n */\n\n }, {\n key: \"onPacket\",\n value: function onPacket(packet) {\n this.emit(\"packet\", packet);\n }\n /**\n * Called upon close.\n *\n * @api private\n */\n\n }, {\n key: \"onClose\",\n value: function onClose() {\n this.readyState = \"closed\";\n this.emit(\"close\");\n }\n }]);\n\n return Transport;\n}(Emitter);\n\nmodule.exports = Transport;\n\n//# sourceURL=webpack://eio/./lib/transport.js?"); +eval("function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar parser = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/lib/index.js\");\n\nvar Emitter = __webpack_require__(/*! component-emitter */ \"./node_modules/component-emitter/index.js\");\n\nvar debug = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")(\"engine.io-client:transport\");\n\nvar Transport = /*#__PURE__*/function (_Emitter) {\n _inherits(Transport, _Emitter);\n\n var _super = _createSuper(Transport);\n\n /**\n * Transport abstract constructor.\n *\n * @param {Object} options.\n * @api private\n */\n function Transport(opts) {\n var _this;\n\n _classCallCheck(this, Transport);\n\n _this = _super.call(this);\n _this.opts = opts;\n _this.query = opts.query;\n _this.readyState = \"\";\n _this.socket = opts.socket;\n return _this;\n }\n /**\n * Emits an error.\n *\n * @param {String} str\n * @return {Transport} for chaining\n * @api public\n */\n\n\n _createClass(Transport, [{\n key: \"onError\",\n value: function onError(msg, desc) {\n var err = new Error(msg);\n err.type = \"TransportError\";\n err.description = desc;\n this.emit(\"error\", err);\n return this;\n }\n /**\n * Opens the transport.\n *\n * @api public\n */\n\n }, {\n key: \"open\",\n value: function open() {\n if (\"closed\" === this.readyState || \"\" === this.readyState) {\n this.readyState = \"opening\";\n this.doOpen();\n }\n\n return this;\n }\n /**\n * Closes the transport.\n *\n * @api private\n */\n\n }, {\n key: \"close\",\n value: function close() {\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.doClose();\n this.onClose();\n }\n\n return this;\n }\n /**\n * Sends multiple packets.\n *\n * @param {Array} packets\n * @api private\n */\n\n }, {\n key: \"send\",\n value: function send(packets) {\n if (\"open\" === this.readyState) {\n this.write(packets);\n } else {\n // this might happen if the transport was silently closed in the beforeunload event handler\n debug(\"transport is not open, discarding packets\");\n }\n }\n /**\n * Called upon open\n *\n * @api private\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n this.readyState = \"open\";\n this.writable = true;\n this.emit(\"open\");\n }\n /**\n * Called with data.\n *\n * @param {String} data\n * @api private\n */\n\n }, {\n key: \"onData\",\n value: function onData(data) {\n var packet = parser.decodePacket(data, this.socket.binaryType);\n this.onPacket(packet);\n }\n /**\n * Called with a decoded packet.\n */\n\n }, {\n key: \"onPacket\",\n value: function onPacket(packet) {\n this.emit(\"packet\", packet);\n }\n /**\n * Called upon close.\n *\n * @api private\n */\n\n }, {\n key: \"onClose\",\n value: function onClose() {\n this.readyState = \"closed\";\n this.emit(\"close\");\n }\n }]);\n\n return Transport;\n}(Emitter);\n\nmodule.exports = Transport;\n\n//# sourceURL=webpack://eio/./lib/transport.js?"); /***/ }), @@ -173,7 +163,7 @@ eval("var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ \"./lib /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar Polling = __webpack_require__(/*! ./polling */ \"./lib/transports/polling.js\");\n\nvar globalThis = __webpack_require__(/*! ../globalThis */ \"./lib/globalThis.browser.js\");\n\nvar rNewline = /\\n/g;\nvar rEscapedNewline = /\\\\n/g;\n/**\n * Global JSONP callbacks.\n */\n\nvar callbacks;\n/**\n * Noop.\n */\n\nfunction empty() {}\n\nvar JSONPPolling =\n/*#__PURE__*/\nfunction (_Polling) {\n _inherits(JSONPPolling, _Polling);\n\n /**\n * JSONP Polling constructor.\n *\n * @param {Object} opts.\n * @api public\n */\n function JSONPPolling(opts) {\n var _this;\n\n _classCallCheck(this, JSONPPolling);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(JSONPPolling).call(this, opts));\n _this.query = _this.query || {}; // define global callbacks array if not present\n // we do this here (lazily) to avoid unneeded global pollution\n\n if (!callbacks) {\n // we need to consider multiple engines in the same page\n callbacks = globalThis.___eio = globalThis.___eio || [];\n } // callback identifier\n\n\n _this.index = callbacks.length; // add callback to jsonp global\n\n var self = _assertThisInitialized(_this);\n\n callbacks.push(function (msg) {\n self.onData(msg);\n }); // append to query string\n\n _this.query.j = _this.index; // prevent spurious errors from being emitted when the window is unloaded\n\n if (typeof addEventListener === \"function\") {\n addEventListener(\"beforeunload\", function () {\n if (self.script) self.script.onerror = empty;\n }, false);\n }\n\n return _this;\n }\n /**\n * JSONP only supports binary as base64 encoded strings\n */\n\n\n _createClass(JSONPPolling, [{\n key: \"doClose\",\n\n /**\n * Closes the socket.\n *\n * @api private\n */\n value: function doClose() {\n if (this.script) {\n this.script.parentNode.removeChild(this.script);\n this.script = null;\n }\n\n if (this.form) {\n this.form.parentNode.removeChild(this.form);\n this.form = null;\n this.iframe = null;\n }\n\n _get(_getPrototypeOf(JSONPPolling.prototype), \"doClose\", this).call(this);\n }\n /**\n * Starts a poll cycle.\n *\n * @api private\n */\n\n }, {\n key: \"doPoll\",\n value: function doPoll() {\n var self = this;\n var script = document.createElement(\"script\");\n\n if (this.script) {\n this.script.parentNode.removeChild(this.script);\n this.script = null;\n }\n\n script.async = true;\n script.src = this.uri();\n\n script.onerror = function (e) {\n self.onError(\"jsonp poll error\", e);\n };\n\n var insertAt = document.getElementsByTagName(\"script\")[0];\n\n if (insertAt) {\n insertAt.parentNode.insertBefore(script, insertAt);\n } else {\n (document.head || document.body).appendChild(script);\n }\n\n this.script = script;\n var isUAgecko = \"undefined\" !== typeof navigator && /gecko/i.test(navigator.userAgent);\n\n if (isUAgecko) {\n setTimeout(function () {\n var iframe = document.createElement(\"iframe\");\n document.body.appendChild(iframe);\n document.body.removeChild(iframe);\n }, 100);\n }\n }\n /**\n * Writes with a hidden iframe.\n *\n * @param {String} data to send\n * @param {Function} called upon flush.\n * @api private\n */\n\n }, {\n key: \"doWrite\",\n value: function doWrite(data, fn) {\n var self = this;\n var iframe;\n\n if (!this.form) {\n var form = document.createElement(\"form\");\n var area = document.createElement(\"textarea\");\n var id = this.iframeId = \"eio_iframe_\" + this.index;\n form.className = \"socketio\";\n form.style.position = \"absolute\";\n form.style.top = \"-1000px\";\n form.style.left = \"-1000px\";\n form.target = id;\n form.method = \"POST\";\n form.setAttribute(\"accept-charset\", \"utf-8\");\n area.name = \"d\";\n form.appendChild(area);\n document.body.appendChild(form);\n this.form = form;\n this.area = area;\n }\n\n this.form.action = this.uri();\n\n function complete() {\n initIframe();\n fn();\n }\n\n function initIframe() {\n if (self.iframe) {\n try {\n self.form.removeChild(self.iframe);\n } catch (e) {\n self.onError(\"jsonp polling iframe removal error\", e);\n }\n }\n\n try {\n // ie6 dynamic iframes with target=\"\" support (thanks Chris Lambacher)\n var html = '