1 | /*!
|
---|
2 | * Socket.IO v3.1.2
|
---|
3 | * (c) 2014-2021 Guillermo Rauch
|
---|
4 | * Released under the MIT License.
|
---|
5 | */
|
---|
6 | (function webpackUniversalModuleDefinition(root, factory) {
|
---|
7 | if(typeof exports === 'object' && typeof module === 'object')
|
---|
8 | module.exports = factory();
|
---|
9 | else if(typeof define === 'function' && define.amd)
|
---|
10 | define([], factory);
|
---|
11 | else if(typeof exports === 'object')
|
---|
12 | exports["io"] = factory();
|
---|
13 | else
|
---|
14 | root["io"] = factory();
|
---|
15 | })(this, function() {
|
---|
16 | return /******/ (function(modules) { // webpackBootstrap
|
---|
17 | /******/ // The module cache
|
---|
18 | /******/ var installedModules = {};
|
---|
19 | /******/
|
---|
20 | /******/ // The require function
|
---|
21 | /******/ function __webpack_require__(moduleId) {
|
---|
22 | /******/
|
---|
23 | /******/ // Check if module is in cache
|
---|
24 | /******/ if(installedModules[moduleId]) {
|
---|
25 | /******/ return installedModules[moduleId].exports;
|
---|
26 | /******/ }
|
---|
27 | /******/ // Create a new module (and put it into the cache)
|
---|
28 | /******/ var module = installedModules[moduleId] = {
|
---|
29 | /******/ i: moduleId,
|
---|
30 | /******/ l: false,
|
---|
31 | /******/ exports: {}
|
---|
32 | /******/ };
|
---|
33 | /******/
|
---|
34 | /******/ // Execute the module function
|
---|
35 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
---|
36 | /******/
|
---|
37 | /******/ // Flag the module as loaded
|
---|
38 | /******/ module.l = true;
|
---|
39 | /******/
|
---|
40 | /******/ // Return the exports of the module
|
---|
41 | /******/ return module.exports;
|
---|
42 | /******/ }
|
---|
43 | /******/
|
---|
44 | /******/
|
---|
45 | /******/ // expose the modules object (__webpack_modules__)
|
---|
46 | /******/ __webpack_require__.m = modules;
|
---|
47 | /******/
|
---|
48 | /******/ // expose the module cache
|
---|
49 | /******/ __webpack_require__.c = installedModules;
|
---|
50 | /******/
|
---|
51 | /******/ // define getter function for harmony exports
|
---|
52 | /******/ __webpack_require__.d = function(exports, name, getter) {
|
---|
53 | /******/ if(!__webpack_require__.o(exports, name)) {
|
---|
54 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
---|
55 | /******/ }
|
---|
56 | /******/ };
|
---|
57 | /******/
|
---|
58 | /******/ // define __esModule on exports
|
---|
59 | /******/ __webpack_require__.r = function(exports) {
|
---|
60 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
---|
61 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
---|
62 | /******/ }
|
---|
63 | /******/ Object.defineProperty(exports, '__esModule', { value: true });
|
---|
64 | /******/ };
|
---|
65 | /******/
|
---|
66 | /******/ // create a fake namespace object
|
---|
67 | /******/ // mode & 1: value is a module id, require it
|
---|
68 | /******/ // mode & 2: merge all properties of value into the ns
|
---|
69 | /******/ // mode & 4: return value when already ns object
|
---|
70 | /******/ // mode & 8|1: behave like require
|
---|
71 | /******/ __webpack_require__.t = function(value, mode) {
|
---|
72 | /******/ if(mode & 1) value = __webpack_require__(value);
|
---|
73 | /******/ if(mode & 8) return value;
|
---|
74 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
---|
75 | /******/ var ns = Object.create(null);
|
---|
76 | /******/ __webpack_require__.r(ns);
|
---|
77 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
---|
78 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
---|
79 | /******/ return ns;
|
---|
80 | /******/ };
|
---|
81 | /******/
|
---|
82 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
---|
83 | /******/ __webpack_require__.n = function(module) {
|
---|
84 | /******/ var getter = module && module.__esModule ?
|
---|
85 | /******/ function getDefault() { return module['default']; } :
|
---|
86 | /******/ function getModuleExports() { return module; };
|
---|
87 | /******/ __webpack_require__.d(getter, 'a', getter);
|
---|
88 | /******/ return getter;
|
---|
89 | /******/ };
|
---|
90 | /******/
|
---|
91 | /******/ // Object.prototype.hasOwnProperty.call
|
---|
92 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
---|
93 | /******/
|
---|
94 | /******/ // __webpack_public_path__
|
---|
95 | /******/ __webpack_require__.p = "";
|
---|
96 | /******/
|
---|
97 | /******/
|
---|
98 | /******/ // Load entry module and return exports
|
---|
99 | /******/ return __webpack_require__(__webpack_require__.s = "./build/index.js");
|
---|
100 | /******/ })
|
---|
101 | /************************************************************************/
|
---|
102 | /******/ ({
|
---|
103 |
|
---|
104 | /***/ "./build/index.js":
|
---|
105 | /*!************************!*\
|
---|
106 | !*** ./build/index.js ***!
|
---|
107 | \************************/
|
---|
108 | /*! no static exports found */
|
---|
109 | /***/ (function(module, exports, __webpack_require__) {
|
---|
110 |
|
---|
111 | "use strict";
|
---|
112 |
|
---|
113 |
|
---|
114 | 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); }
|
---|
115 |
|
---|
116 | Object.defineProperty(exports, "__esModule", {
|
---|
117 | value: true
|
---|
118 | });
|
---|
119 | exports.Socket = exports.io = exports.Manager = exports.protocol = void 0;
|
---|
120 |
|
---|
121 | var url_1 = __webpack_require__(/*! ./url */ "./build/url.js");
|
---|
122 |
|
---|
123 | var manager_1 = __webpack_require__(/*! ./manager */ "./build/manager.js");
|
---|
124 |
|
---|
125 | var socket_1 = __webpack_require__(/*! ./socket */ "./build/socket.js");
|
---|
126 |
|
---|
127 | Object.defineProperty(exports, "Socket", {
|
---|
128 | enumerable: true,
|
---|
129 | get: function get() {
|
---|
130 | return socket_1.Socket;
|
---|
131 | }
|
---|
132 | });
|
---|
133 |
|
---|
134 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("socket.io-client");
|
---|
135 | /**
|
---|
136 | * Module exports.
|
---|
137 | */
|
---|
138 |
|
---|
139 |
|
---|
140 | module.exports = exports = lookup;
|
---|
141 | /**
|
---|
142 | * Managers cache.
|
---|
143 | */
|
---|
144 |
|
---|
145 | var cache = exports.managers = {};
|
---|
146 |
|
---|
147 | function lookup(uri, opts) {
|
---|
148 | if (_typeof(uri) === "object") {
|
---|
149 | opts = uri;
|
---|
150 | uri = undefined;
|
---|
151 | }
|
---|
152 |
|
---|
153 | opts = opts || {};
|
---|
154 | var parsed = url_1.url(uri, opts.path);
|
---|
155 | var source = parsed.source;
|
---|
156 | var id = parsed.id;
|
---|
157 | var path = parsed.path;
|
---|
158 | var sameNamespace = cache[id] && path in cache[id]["nsps"];
|
---|
159 | var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
|
---|
160 | var io;
|
---|
161 |
|
---|
162 | if (newConnection) {
|
---|
163 | debug("ignoring socket cache for %s", source);
|
---|
164 | io = new manager_1.Manager(source, opts);
|
---|
165 | } else {
|
---|
166 | if (!cache[id]) {
|
---|
167 | debug("new io instance for %s", source);
|
---|
168 | cache[id] = new manager_1.Manager(source, opts);
|
---|
169 | }
|
---|
170 |
|
---|
171 | io = cache[id];
|
---|
172 | }
|
---|
173 |
|
---|
174 | if (parsed.query && !opts.query) {
|
---|
175 | opts.query = parsed.queryKey;
|
---|
176 | }
|
---|
177 |
|
---|
178 | return io.socket(parsed.path, opts);
|
---|
179 | }
|
---|
180 |
|
---|
181 | exports.io = lookup;
|
---|
182 | /**
|
---|
183 | * Protocol version.
|
---|
184 | *
|
---|
185 | * @public
|
---|
186 | */
|
---|
187 |
|
---|
188 | var socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/dist/index.js");
|
---|
189 |
|
---|
190 | Object.defineProperty(exports, "protocol", {
|
---|
191 | enumerable: true,
|
---|
192 | get: function get() {
|
---|
193 | return socket_io_parser_1.protocol;
|
---|
194 | }
|
---|
195 | });
|
---|
196 | /**
|
---|
197 | * `connect`.
|
---|
198 | *
|
---|
199 | * @param {String} uri
|
---|
200 | * @public
|
---|
201 | */
|
---|
202 |
|
---|
203 | exports.connect = lookup;
|
---|
204 | /**
|
---|
205 | * Expose constructors for standalone build.
|
---|
206 | *
|
---|
207 | * @public
|
---|
208 | */
|
---|
209 |
|
---|
210 | var manager_2 = __webpack_require__(/*! ./manager */ "./build/manager.js");
|
---|
211 |
|
---|
212 | Object.defineProperty(exports, "Manager", {
|
---|
213 | enumerable: true,
|
---|
214 | get: function get() {
|
---|
215 | return manager_2.Manager;
|
---|
216 | }
|
---|
217 | });
|
---|
218 |
|
---|
219 | /***/ }),
|
---|
220 |
|
---|
221 | /***/ "./build/manager.js":
|
---|
222 | /*!**************************!*\
|
---|
223 | !*** ./build/manager.js ***!
|
---|
224 | \**************************/
|
---|
225 | /*! no static exports found */
|
---|
226 | /***/ (function(module, exports, __webpack_require__) {
|
---|
227 |
|
---|
228 | "use strict";
|
---|
229 |
|
---|
230 |
|
---|
231 | 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); }
|
---|
232 |
|
---|
233 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
234 |
|
---|
235 | function _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); } }
|
---|
236 |
|
---|
237 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
238 |
|
---|
239 | function _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); }
|
---|
240 |
|
---|
241 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
---|
242 |
|
---|
243 | function _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); }
|
---|
244 |
|
---|
245 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
246 |
|
---|
247 | function _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); }; }
|
---|
248 |
|
---|
249 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
250 |
|
---|
251 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
252 |
|
---|
253 | function _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; } }
|
---|
254 |
|
---|
255 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
256 |
|
---|
257 | Object.defineProperty(exports, "__esModule", {
|
---|
258 | value: true
|
---|
259 | });
|
---|
260 | exports.Manager = void 0;
|
---|
261 |
|
---|
262 | var eio = __webpack_require__(/*! engine.io-client */ "./node_modules/engine.io-client/lib/index.js");
|
---|
263 |
|
---|
264 | var socket_1 = __webpack_require__(/*! ./socket */ "./build/socket.js");
|
---|
265 |
|
---|
266 | var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
---|
267 |
|
---|
268 | var parser = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/dist/index.js");
|
---|
269 |
|
---|
270 | var on_1 = __webpack_require__(/*! ./on */ "./build/on.js");
|
---|
271 |
|
---|
272 | var Backoff = __webpack_require__(/*! backo2 */ "./node_modules/backo2/index.js");
|
---|
273 |
|
---|
274 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("socket.io-client:manager");
|
---|
275 |
|
---|
276 | var Manager = /*#__PURE__*/function (_Emitter) {
|
---|
277 | _inherits(Manager, _Emitter);
|
---|
278 |
|
---|
279 | var _super = _createSuper(Manager);
|
---|
280 |
|
---|
281 | function Manager(uri, opts) {
|
---|
282 | var _this;
|
---|
283 |
|
---|
284 | _classCallCheck(this, Manager);
|
---|
285 |
|
---|
286 | _this = _super.call(this);
|
---|
287 | _this.nsps = {};
|
---|
288 | _this.subs = [];
|
---|
289 |
|
---|
290 | if (uri && "object" === _typeof(uri)) {
|
---|
291 | opts = uri;
|
---|
292 | uri = undefined;
|
---|
293 | }
|
---|
294 |
|
---|
295 | opts = opts || {};
|
---|
296 | opts.path = opts.path || "/socket.io";
|
---|
297 | _this.opts = opts;
|
---|
298 |
|
---|
299 | _this.reconnection(opts.reconnection !== false);
|
---|
300 |
|
---|
301 | _this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
|
---|
302 |
|
---|
303 | _this.reconnectionDelay(opts.reconnectionDelay || 1000);
|
---|
304 |
|
---|
305 | _this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
|
---|
306 |
|
---|
307 | _this.randomizationFactor(opts.randomizationFactor || 0.5);
|
---|
308 |
|
---|
309 | _this.backoff = new Backoff({
|
---|
310 | min: _this.reconnectionDelay(),
|
---|
311 | max: _this.reconnectionDelayMax(),
|
---|
312 | jitter: _this.randomizationFactor()
|
---|
313 | });
|
---|
314 |
|
---|
315 | _this.timeout(null == opts.timeout ? 20000 : opts.timeout);
|
---|
316 |
|
---|
317 | _this._readyState = "closed";
|
---|
318 | _this.uri = uri;
|
---|
319 |
|
---|
320 | var _parser = opts.parser || parser;
|
---|
321 |
|
---|
322 | _this.encoder = new _parser.Encoder();
|
---|
323 | _this.decoder = new _parser.Decoder();
|
---|
324 | _this._autoConnect = opts.autoConnect !== false;
|
---|
325 | if (_this._autoConnect) _this.open();
|
---|
326 | return _this;
|
---|
327 | }
|
---|
328 |
|
---|
329 | _createClass(Manager, [{
|
---|
330 | key: "reconnection",
|
---|
331 | value: function reconnection(v) {
|
---|
332 | if (!arguments.length) return this._reconnection;
|
---|
333 | this._reconnection = !!v;
|
---|
334 | return this;
|
---|
335 | }
|
---|
336 | }, {
|
---|
337 | key: "reconnectionAttempts",
|
---|
338 | value: function reconnectionAttempts(v) {
|
---|
339 | if (v === undefined) return this._reconnectionAttempts;
|
---|
340 | this._reconnectionAttempts = v;
|
---|
341 | return this;
|
---|
342 | }
|
---|
343 | }, {
|
---|
344 | key: "reconnectionDelay",
|
---|
345 | value: function reconnectionDelay(v) {
|
---|
346 | var _a;
|
---|
347 |
|
---|
348 | if (v === undefined) return this._reconnectionDelay;
|
---|
349 | this._reconnectionDelay = v;
|
---|
350 | (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
|
---|
351 | return this;
|
---|
352 | }
|
---|
353 | }, {
|
---|
354 | key: "randomizationFactor",
|
---|
355 | value: function randomizationFactor(v) {
|
---|
356 | var _a;
|
---|
357 |
|
---|
358 | if (v === undefined) return this._randomizationFactor;
|
---|
359 | this._randomizationFactor = v;
|
---|
360 | (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
|
---|
361 | return this;
|
---|
362 | }
|
---|
363 | }, {
|
---|
364 | key: "reconnectionDelayMax",
|
---|
365 | value: function reconnectionDelayMax(v) {
|
---|
366 | var _a;
|
---|
367 |
|
---|
368 | if (v === undefined) return this._reconnectionDelayMax;
|
---|
369 | this._reconnectionDelayMax = v;
|
---|
370 | (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
|
---|
371 | return this;
|
---|
372 | }
|
---|
373 | }, {
|
---|
374 | key: "timeout",
|
---|
375 | value: function timeout(v) {
|
---|
376 | if (!arguments.length) return this._timeout;
|
---|
377 | this._timeout = v;
|
---|
378 | return this;
|
---|
379 | }
|
---|
380 | /**
|
---|
381 | * Starts trying to reconnect if reconnection is enabled and we have not
|
---|
382 | * started reconnecting yet
|
---|
383 | *
|
---|
384 | * @private
|
---|
385 | */
|
---|
386 |
|
---|
387 | }, {
|
---|
388 | key: "maybeReconnectOnOpen",
|
---|
389 | value: function maybeReconnectOnOpen() {
|
---|
390 | // Only try to reconnect if it's the first time we're connecting
|
---|
391 | if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) {
|
---|
392 | // keeps reconnection from firing twice for the same reconnection loop
|
---|
393 | this.reconnect();
|
---|
394 | }
|
---|
395 | }
|
---|
396 | /**
|
---|
397 | * Sets the current transport `socket`.
|
---|
398 | *
|
---|
399 | * @param {Function} fn - optional, callback
|
---|
400 | * @return self
|
---|
401 | * @public
|
---|
402 | */
|
---|
403 |
|
---|
404 | }, {
|
---|
405 | key: "open",
|
---|
406 | value: function open(fn) {
|
---|
407 | var _this2 = this;
|
---|
408 |
|
---|
409 | debug("readyState %s", this._readyState);
|
---|
410 | if (~this._readyState.indexOf("open")) return this;
|
---|
411 | debug("opening %s", this.uri);
|
---|
412 | this.engine = eio(this.uri, this.opts);
|
---|
413 | var socket = this.engine;
|
---|
414 | var self = this;
|
---|
415 | this._readyState = "opening";
|
---|
416 | this.skipReconnect = false; // emit `open`
|
---|
417 |
|
---|
418 | var openSubDestroy = on_1.on(socket, "open", function () {
|
---|
419 | self.onopen();
|
---|
420 | fn && fn();
|
---|
421 | }); // emit `error`
|
---|
422 |
|
---|
423 | var errorSub = on_1.on(socket, "error", function (err) {
|
---|
424 | debug("error");
|
---|
425 | self.cleanup();
|
---|
426 | self._readyState = "closed";
|
---|
427 |
|
---|
428 | _get(_getPrototypeOf(Manager.prototype), "emit", _this2).call(_this2, "error", err);
|
---|
429 |
|
---|
430 | if (fn) {
|
---|
431 | fn(err);
|
---|
432 | } else {
|
---|
433 | // Only do this if there is no fn to handle the error
|
---|
434 | self.maybeReconnectOnOpen();
|
---|
435 | }
|
---|
436 | });
|
---|
437 |
|
---|
438 | if (false !== this._timeout) {
|
---|
439 | var timeout = this._timeout;
|
---|
440 | debug("connect attempt will timeout after %d", timeout);
|
---|
441 |
|
---|
442 | if (timeout === 0) {
|
---|
443 | openSubDestroy(); // prevents a race condition with the 'open' event
|
---|
444 | } // set timer
|
---|
445 |
|
---|
446 |
|
---|
447 | var timer = setTimeout(function () {
|
---|
448 | debug("connect attempt timed out after %d", timeout);
|
---|
449 | openSubDestroy();
|
---|
450 | socket.close();
|
---|
451 | socket.emit("error", new Error("timeout"));
|
---|
452 | }, timeout);
|
---|
453 | this.subs.push(function subDestroy() {
|
---|
454 | clearTimeout(timer);
|
---|
455 | });
|
---|
456 | }
|
---|
457 |
|
---|
458 | this.subs.push(openSubDestroy);
|
---|
459 | this.subs.push(errorSub);
|
---|
460 | return this;
|
---|
461 | }
|
---|
462 | /**
|
---|
463 | * Alias for open()
|
---|
464 | *
|
---|
465 | * @return self
|
---|
466 | * @public
|
---|
467 | */
|
---|
468 |
|
---|
469 | }, {
|
---|
470 | key: "connect",
|
---|
471 | value: function connect(fn) {
|
---|
472 | return this.open(fn);
|
---|
473 | }
|
---|
474 | /**
|
---|
475 | * Called upon transport open.
|
---|
476 | *
|
---|
477 | * @private
|
---|
478 | */
|
---|
479 |
|
---|
480 | }, {
|
---|
481 | key: "onopen",
|
---|
482 | value: function onopen() {
|
---|
483 | debug("open"); // clear old subs
|
---|
484 |
|
---|
485 | this.cleanup(); // mark as open
|
---|
486 |
|
---|
487 | this._readyState = "open";
|
---|
488 |
|
---|
489 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "open"); // add new subs
|
---|
490 |
|
---|
491 |
|
---|
492 | var socket = this.engine;
|
---|
493 | this.subs.push(on_1.on(socket, "ping", this.onping.bind(this)), on_1.on(socket, "data", this.ondata.bind(this)), on_1.on(socket, "error", this.onerror.bind(this)), on_1.on(socket, "close", this.onclose.bind(this)), on_1.on(this.decoder, "decoded", this.ondecoded.bind(this)));
|
---|
494 | }
|
---|
495 | /**
|
---|
496 | * Called upon a ping.
|
---|
497 | *
|
---|
498 | * @private
|
---|
499 | */
|
---|
500 |
|
---|
501 | }, {
|
---|
502 | key: "onping",
|
---|
503 | value: function onping() {
|
---|
504 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "ping");
|
---|
505 | }
|
---|
506 | /**
|
---|
507 | * Called with data.
|
---|
508 | *
|
---|
509 | * @private
|
---|
510 | */
|
---|
511 |
|
---|
512 | }, {
|
---|
513 | key: "ondata",
|
---|
514 | value: function ondata(data) {
|
---|
515 | this.decoder.add(data);
|
---|
516 | }
|
---|
517 | /**
|
---|
518 | * Called when parser fully decodes a packet.
|
---|
519 | *
|
---|
520 | * @private
|
---|
521 | */
|
---|
522 |
|
---|
523 | }, {
|
---|
524 | key: "ondecoded",
|
---|
525 | value: function ondecoded(packet) {
|
---|
526 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "packet", packet);
|
---|
527 | }
|
---|
528 | /**
|
---|
529 | * Called upon socket error.
|
---|
530 | *
|
---|
531 | * @private
|
---|
532 | */
|
---|
533 |
|
---|
534 | }, {
|
---|
535 | key: "onerror",
|
---|
536 | value: function onerror(err) {
|
---|
537 | debug("error", err);
|
---|
538 |
|
---|
539 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "error", err);
|
---|
540 | }
|
---|
541 | /**
|
---|
542 | * Creates a new socket for the given `nsp`.
|
---|
543 | *
|
---|
544 | * @return {Socket}
|
---|
545 | * @public
|
---|
546 | */
|
---|
547 |
|
---|
548 | }, {
|
---|
549 | key: "socket",
|
---|
550 | value: function socket(nsp, opts) {
|
---|
551 | var socket = this.nsps[nsp];
|
---|
552 |
|
---|
553 | if (!socket) {
|
---|
554 | socket = new socket_1.Socket(this, nsp, opts);
|
---|
555 | this.nsps[nsp] = socket;
|
---|
556 | }
|
---|
557 |
|
---|
558 | return socket;
|
---|
559 | }
|
---|
560 | /**
|
---|
561 | * Called upon a socket close.
|
---|
562 | *
|
---|
563 | * @param socket
|
---|
564 | * @private
|
---|
565 | */
|
---|
566 |
|
---|
567 | }, {
|
---|
568 | key: "_destroy",
|
---|
569 | value: function _destroy(socket) {
|
---|
570 | var nsps = Object.keys(this.nsps);
|
---|
571 |
|
---|
572 | for (var _i = 0, _nsps = nsps; _i < _nsps.length; _i++) {
|
---|
573 | var nsp = _nsps[_i];
|
---|
574 | var _socket = this.nsps[nsp];
|
---|
575 |
|
---|
576 | if (_socket.active) {
|
---|
577 | debug("socket %s is still active, skipping close", nsp);
|
---|
578 | return;
|
---|
579 | }
|
---|
580 | }
|
---|
581 |
|
---|
582 | this._close();
|
---|
583 | }
|
---|
584 | /**
|
---|
585 | * Writes a packet.
|
---|
586 | *
|
---|
587 | * @param packet
|
---|
588 | * @private
|
---|
589 | */
|
---|
590 |
|
---|
591 | }, {
|
---|
592 | key: "_packet",
|
---|
593 | value: function _packet(packet) {
|
---|
594 | debug("writing packet %j", packet);
|
---|
595 | var encodedPackets = this.encoder.encode(packet);
|
---|
596 |
|
---|
597 | for (var i = 0; i < encodedPackets.length; i++) {
|
---|
598 | this.engine.write(encodedPackets[i], packet.options);
|
---|
599 | }
|
---|
600 | }
|
---|
601 | /**
|
---|
602 | * Clean up transport subscriptions and packet buffer.
|
---|
603 | *
|
---|
604 | * @private
|
---|
605 | */
|
---|
606 |
|
---|
607 | }, {
|
---|
608 | key: "cleanup",
|
---|
609 | value: function cleanup() {
|
---|
610 | debug("cleanup");
|
---|
611 | this.subs.forEach(function (subDestroy) {
|
---|
612 | return subDestroy();
|
---|
613 | });
|
---|
614 | this.subs.length = 0;
|
---|
615 | this.decoder.destroy();
|
---|
616 | }
|
---|
617 | /**
|
---|
618 | * Close the current socket.
|
---|
619 | *
|
---|
620 | * @private
|
---|
621 | */
|
---|
622 |
|
---|
623 | }, {
|
---|
624 | key: "_close",
|
---|
625 | value: function _close() {
|
---|
626 | debug("disconnect");
|
---|
627 | this.skipReconnect = true;
|
---|
628 | this._reconnecting = false;
|
---|
629 |
|
---|
630 | if ("opening" === this._readyState) {
|
---|
631 | // `onclose` will not fire because
|
---|
632 | // an open event never happened
|
---|
633 | this.cleanup();
|
---|
634 | }
|
---|
635 |
|
---|
636 | this.backoff.reset();
|
---|
637 | this._readyState = "closed";
|
---|
638 | if (this.engine) this.engine.close();
|
---|
639 | }
|
---|
640 | /**
|
---|
641 | * Alias for close()
|
---|
642 | *
|
---|
643 | * @private
|
---|
644 | */
|
---|
645 |
|
---|
646 | }, {
|
---|
647 | key: "disconnect",
|
---|
648 | value: function disconnect() {
|
---|
649 | return this._close();
|
---|
650 | }
|
---|
651 | /**
|
---|
652 | * Called upon engine close.
|
---|
653 | *
|
---|
654 | * @private
|
---|
655 | */
|
---|
656 |
|
---|
657 | }, {
|
---|
658 | key: "onclose",
|
---|
659 | value: function onclose(reason) {
|
---|
660 | debug("onclose");
|
---|
661 | this.cleanup();
|
---|
662 | this.backoff.reset();
|
---|
663 | this._readyState = "closed";
|
---|
664 |
|
---|
665 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "close", reason);
|
---|
666 |
|
---|
667 | if (this._reconnection && !this.skipReconnect) {
|
---|
668 | this.reconnect();
|
---|
669 | }
|
---|
670 | }
|
---|
671 | /**
|
---|
672 | * Attempt a reconnection.
|
---|
673 | *
|
---|
674 | * @private
|
---|
675 | */
|
---|
676 |
|
---|
677 | }, {
|
---|
678 | key: "reconnect",
|
---|
679 | value: function reconnect() {
|
---|
680 | var _this3 = this;
|
---|
681 |
|
---|
682 | if (this._reconnecting || this.skipReconnect) return this;
|
---|
683 | var self = this;
|
---|
684 |
|
---|
685 | if (this.backoff.attempts >= this._reconnectionAttempts) {
|
---|
686 | debug("reconnect failed");
|
---|
687 | this.backoff.reset();
|
---|
688 |
|
---|
689 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "reconnect_failed");
|
---|
690 |
|
---|
691 | this._reconnecting = false;
|
---|
692 | } else {
|
---|
693 | var delay = this.backoff.duration();
|
---|
694 | debug("will wait %dms before reconnect attempt", delay);
|
---|
695 | this._reconnecting = true;
|
---|
696 | var timer = setTimeout(function () {
|
---|
697 | if (self.skipReconnect) return;
|
---|
698 | debug("attempting reconnect");
|
---|
699 |
|
---|
700 | _get(_getPrototypeOf(Manager.prototype), "emit", _this3).call(_this3, "reconnect_attempt", self.backoff.attempts); // check again for the case socket closed in above events
|
---|
701 |
|
---|
702 |
|
---|
703 | if (self.skipReconnect) return;
|
---|
704 | self.open(function (err) {
|
---|
705 | if (err) {
|
---|
706 | debug("reconnect attempt error");
|
---|
707 | self._reconnecting = false;
|
---|
708 | self.reconnect();
|
---|
709 |
|
---|
710 | _get(_getPrototypeOf(Manager.prototype), "emit", _this3).call(_this3, "reconnect_error", err);
|
---|
711 | } else {
|
---|
712 | debug("reconnect success");
|
---|
713 | self.onreconnect();
|
---|
714 | }
|
---|
715 | });
|
---|
716 | }, delay);
|
---|
717 | this.subs.push(function subDestroy() {
|
---|
718 | clearTimeout(timer);
|
---|
719 | });
|
---|
720 | }
|
---|
721 | }
|
---|
722 | /**
|
---|
723 | * Called upon successful reconnect.
|
---|
724 | *
|
---|
725 | * @private
|
---|
726 | */
|
---|
727 |
|
---|
728 | }, {
|
---|
729 | key: "onreconnect",
|
---|
730 | value: function onreconnect() {
|
---|
731 | var attempt = this.backoff.attempts;
|
---|
732 | this._reconnecting = false;
|
---|
733 | this.backoff.reset();
|
---|
734 |
|
---|
735 | _get(_getPrototypeOf(Manager.prototype), "emit", this).call(this, "reconnect", attempt);
|
---|
736 | }
|
---|
737 | }]);
|
---|
738 |
|
---|
739 | return Manager;
|
---|
740 | }(Emitter);
|
---|
741 |
|
---|
742 | exports.Manager = Manager;
|
---|
743 |
|
---|
744 | /***/ }),
|
---|
745 |
|
---|
746 | /***/ "./build/on.js":
|
---|
747 | /*!*********************!*\
|
---|
748 | !*** ./build/on.js ***!
|
---|
749 | \*********************/
|
---|
750 | /*! no static exports found */
|
---|
751 | /***/ (function(module, exports, __webpack_require__) {
|
---|
752 |
|
---|
753 | "use strict";
|
---|
754 |
|
---|
755 |
|
---|
756 | Object.defineProperty(exports, "__esModule", {
|
---|
757 | value: true
|
---|
758 | });
|
---|
759 | exports.on = void 0;
|
---|
760 |
|
---|
761 | function on(obj, ev, fn) {
|
---|
762 | obj.on(ev, fn);
|
---|
763 | return function subDestroy() {
|
---|
764 | obj.off(ev, fn);
|
---|
765 | };
|
---|
766 | }
|
---|
767 |
|
---|
768 | exports.on = on;
|
---|
769 |
|
---|
770 | /***/ }),
|
---|
771 |
|
---|
772 | /***/ "./build/socket.js":
|
---|
773 | /*!*************************!*\
|
---|
774 | !*** ./build/socket.js ***!
|
---|
775 | \*************************/
|
---|
776 | /*! no static exports found */
|
---|
777 | /***/ (function(module, exports, __webpack_require__) {
|
---|
778 |
|
---|
779 | "use strict";
|
---|
780 |
|
---|
781 |
|
---|
782 | 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); }
|
---|
783 |
|
---|
784 | function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
---|
785 |
|
---|
786 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
---|
787 |
|
---|
788 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
---|
789 |
|
---|
790 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
791 |
|
---|
792 | function _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); } }
|
---|
793 |
|
---|
794 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
795 |
|
---|
796 | function _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); }
|
---|
797 |
|
---|
798 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
---|
799 |
|
---|
800 | function _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); }
|
---|
801 |
|
---|
802 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
803 |
|
---|
804 | function _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); }; }
|
---|
805 |
|
---|
806 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
807 |
|
---|
808 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
809 |
|
---|
810 | function _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; } }
|
---|
811 |
|
---|
812 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
813 |
|
---|
814 | Object.defineProperty(exports, "__esModule", {
|
---|
815 | value: true
|
---|
816 | });
|
---|
817 | exports.Socket = void 0;
|
---|
818 |
|
---|
819 | var socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/dist/index.js");
|
---|
820 |
|
---|
821 | var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
---|
822 |
|
---|
823 | var on_1 = __webpack_require__(/*! ./on */ "./build/on.js");
|
---|
824 |
|
---|
825 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("socket.io-client:socket");
|
---|
826 | /**
|
---|
827 | * Internal events.
|
---|
828 | * These events can't be emitted by the user.
|
---|
829 | */
|
---|
830 |
|
---|
831 |
|
---|
832 | var RESERVED_EVENTS = Object.freeze({
|
---|
833 | connect: 1,
|
---|
834 | connect_error: 1,
|
---|
835 | disconnect: 1,
|
---|
836 | disconnecting: 1,
|
---|
837 | // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
|
---|
838 | newListener: 1,
|
---|
839 | removeListener: 1
|
---|
840 | });
|
---|
841 |
|
---|
842 | var Socket = /*#__PURE__*/function (_Emitter) {
|
---|
843 | _inherits(Socket, _Emitter);
|
---|
844 |
|
---|
845 | var _super = _createSuper(Socket);
|
---|
846 |
|
---|
847 | /**
|
---|
848 | * `Socket` constructor.
|
---|
849 | *
|
---|
850 | * @public
|
---|
851 | */
|
---|
852 | function Socket(io, nsp, opts) {
|
---|
853 | var _this;
|
---|
854 |
|
---|
855 | _classCallCheck(this, Socket);
|
---|
856 |
|
---|
857 | _this = _super.call(this);
|
---|
858 | _this.receiveBuffer = [];
|
---|
859 | _this.sendBuffer = [];
|
---|
860 | _this.ids = 0;
|
---|
861 | _this.acks = {};
|
---|
862 | _this.flags = {};
|
---|
863 | _this.io = io;
|
---|
864 | _this.nsp = nsp;
|
---|
865 | _this.ids = 0;
|
---|
866 | _this.acks = {};
|
---|
867 | _this.receiveBuffer = [];
|
---|
868 | _this.sendBuffer = [];
|
---|
869 | _this.connected = false;
|
---|
870 | _this.disconnected = true;
|
---|
871 | _this.flags = {};
|
---|
872 |
|
---|
873 | if (opts && opts.auth) {
|
---|
874 | _this.auth = opts.auth;
|
---|
875 | }
|
---|
876 |
|
---|
877 | if (_this.io._autoConnect) _this.open();
|
---|
878 | return _this;
|
---|
879 | }
|
---|
880 | /**
|
---|
881 | * Subscribe to open, close and packet events
|
---|
882 | *
|
---|
883 | * @private
|
---|
884 | */
|
---|
885 |
|
---|
886 |
|
---|
887 | _createClass(Socket, [{
|
---|
888 | key: "subEvents",
|
---|
889 | value: function subEvents() {
|
---|
890 | if (this.subs) return;
|
---|
891 | var io = this.io;
|
---|
892 | this.subs = [on_1.on(io, "open", this.onopen.bind(this)), on_1.on(io, "packet", this.onpacket.bind(this)), on_1.on(io, "error", this.onerror.bind(this)), on_1.on(io, "close", this.onclose.bind(this))];
|
---|
893 | }
|
---|
894 | /**
|
---|
895 | * Whether the Socket will try to reconnect when its Manager connects or reconnects
|
---|
896 | */
|
---|
897 |
|
---|
898 | }, {
|
---|
899 | key: "connect",
|
---|
900 |
|
---|
901 | /**
|
---|
902 | * "Opens" the socket.
|
---|
903 | *
|
---|
904 | * @public
|
---|
905 | */
|
---|
906 | value: function connect() {
|
---|
907 | if (this.connected) return this;
|
---|
908 | this.subEvents();
|
---|
909 | if (!this.io["_reconnecting"]) this.io.open(); // ensure open
|
---|
910 |
|
---|
911 | if ("open" === this.io._readyState) this.onopen();
|
---|
912 | return this;
|
---|
913 | }
|
---|
914 | /**
|
---|
915 | * Alias for connect()
|
---|
916 | */
|
---|
917 |
|
---|
918 | }, {
|
---|
919 | key: "open",
|
---|
920 | value: function open() {
|
---|
921 | return this.connect();
|
---|
922 | }
|
---|
923 | /**
|
---|
924 | * Sends a `message` event.
|
---|
925 | *
|
---|
926 | * @return self
|
---|
927 | * @public
|
---|
928 | */
|
---|
929 |
|
---|
930 | }, {
|
---|
931 | key: "send",
|
---|
932 | value: function send() {
|
---|
933 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
---|
934 | args[_key] = arguments[_key];
|
---|
935 | }
|
---|
936 |
|
---|
937 | args.unshift("message");
|
---|
938 | this.emit.apply(this, args);
|
---|
939 | return this;
|
---|
940 | }
|
---|
941 | /**
|
---|
942 | * Override `emit`.
|
---|
943 | * If the event is in `events`, it's emitted normally.
|
---|
944 | *
|
---|
945 | * @param ev - event name
|
---|
946 | * @return self
|
---|
947 | * @public
|
---|
948 | */
|
---|
949 |
|
---|
950 | }, {
|
---|
951 | key: "emit",
|
---|
952 | value: function emit(ev) {
|
---|
953 | if (RESERVED_EVENTS.hasOwnProperty(ev)) {
|
---|
954 | throw new Error('"' + ev + '" is a reserved event name');
|
---|
955 | }
|
---|
956 |
|
---|
957 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
---|
958 | args[_key2 - 1] = arguments[_key2];
|
---|
959 | }
|
---|
960 |
|
---|
961 | args.unshift(ev);
|
---|
962 | var packet = {
|
---|
963 | type: socket_io_parser_1.PacketType.EVENT,
|
---|
964 | data: args
|
---|
965 | };
|
---|
966 | packet.options = {};
|
---|
967 | packet.options.compress = this.flags.compress !== false; // event ack callback
|
---|
968 |
|
---|
969 | if ("function" === typeof args[args.length - 1]) {
|
---|
970 | debug("emitting packet with ack id %d", this.ids);
|
---|
971 | this.acks[this.ids] = args.pop();
|
---|
972 | packet.id = this.ids++;
|
---|
973 | }
|
---|
974 |
|
---|
975 | var isTransportWritable = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable;
|
---|
976 | var discardPacket = this.flags["volatile"] && (!isTransportWritable || !this.connected);
|
---|
977 |
|
---|
978 | if (discardPacket) {
|
---|
979 | debug("discard packet as the transport is not currently writable");
|
---|
980 | } else if (this.connected) {
|
---|
981 | this.packet(packet);
|
---|
982 | } else {
|
---|
983 | this.sendBuffer.push(packet);
|
---|
984 | }
|
---|
985 |
|
---|
986 | this.flags = {};
|
---|
987 | return this;
|
---|
988 | }
|
---|
989 | /**
|
---|
990 | * Sends a packet.
|
---|
991 | *
|
---|
992 | * @param packet
|
---|
993 | * @private
|
---|
994 | */
|
---|
995 |
|
---|
996 | }, {
|
---|
997 | key: "packet",
|
---|
998 | value: function packet(_packet) {
|
---|
999 | _packet.nsp = this.nsp;
|
---|
1000 |
|
---|
1001 | this.io._packet(_packet);
|
---|
1002 | }
|
---|
1003 | /**
|
---|
1004 | * Called upon engine `open`.
|
---|
1005 | *
|
---|
1006 | * @private
|
---|
1007 | */
|
---|
1008 |
|
---|
1009 | }, {
|
---|
1010 | key: "onopen",
|
---|
1011 | value: function onopen() {
|
---|
1012 | var _this2 = this;
|
---|
1013 |
|
---|
1014 | debug("transport is open - connecting");
|
---|
1015 |
|
---|
1016 | if (typeof this.auth == "function") {
|
---|
1017 | this.auth(function (data) {
|
---|
1018 | _this2.packet({
|
---|
1019 | type: socket_io_parser_1.PacketType.CONNECT,
|
---|
1020 | data: data
|
---|
1021 | });
|
---|
1022 | });
|
---|
1023 | } else {
|
---|
1024 | this.packet({
|
---|
1025 | type: socket_io_parser_1.PacketType.CONNECT,
|
---|
1026 | data: this.auth
|
---|
1027 | });
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | /**
|
---|
1031 | * Called upon engine or manager `error`.
|
---|
1032 | *
|
---|
1033 | * @param err
|
---|
1034 | * @private
|
---|
1035 | */
|
---|
1036 |
|
---|
1037 | }, {
|
---|
1038 | key: "onerror",
|
---|
1039 | value: function onerror(err) {
|
---|
1040 | if (!this.connected) {
|
---|
1041 | _get(_getPrototypeOf(Socket.prototype), "emit", this).call(this, "connect_error", err);
|
---|
1042 | }
|
---|
1043 | }
|
---|
1044 | /**
|
---|
1045 | * Called upon engine `close`.
|
---|
1046 | *
|
---|
1047 | * @param reason
|
---|
1048 | * @private
|
---|
1049 | */
|
---|
1050 |
|
---|
1051 | }, {
|
---|
1052 | key: "onclose",
|
---|
1053 | value: function onclose(reason) {
|
---|
1054 | debug("close (%s)", reason);
|
---|
1055 | this.connected = false;
|
---|
1056 | this.disconnected = true;
|
---|
1057 | delete this.id;
|
---|
1058 |
|
---|
1059 | _get(_getPrototypeOf(Socket.prototype), "emit", this).call(this, "disconnect", reason);
|
---|
1060 | }
|
---|
1061 | /**
|
---|
1062 | * Called with socket packet.
|
---|
1063 | *
|
---|
1064 | * @param packet
|
---|
1065 | * @private
|
---|
1066 | */
|
---|
1067 |
|
---|
1068 | }, {
|
---|
1069 | key: "onpacket",
|
---|
1070 | value: function onpacket(packet) {
|
---|
1071 | var sameNamespace = packet.nsp === this.nsp;
|
---|
1072 | if (!sameNamespace) return;
|
---|
1073 |
|
---|
1074 | switch (packet.type) {
|
---|
1075 | case socket_io_parser_1.PacketType.CONNECT:
|
---|
1076 | if (packet.data && packet.data.sid) {
|
---|
1077 | var id = packet.data.sid;
|
---|
1078 | this.onconnect(id);
|
---|
1079 | } else {
|
---|
1080 | _get(_getPrototypeOf(Socket.prototype), "emit", this).call(this, "connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | break;
|
---|
1084 |
|
---|
1085 | case socket_io_parser_1.PacketType.EVENT:
|
---|
1086 | this.onevent(packet);
|
---|
1087 | break;
|
---|
1088 |
|
---|
1089 | case socket_io_parser_1.PacketType.BINARY_EVENT:
|
---|
1090 | this.onevent(packet);
|
---|
1091 | break;
|
---|
1092 |
|
---|
1093 | case socket_io_parser_1.PacketType.ACK:
|
---|
1094 | this.onack(packet);
|
---|
1095 | break;
|
---|
1096 |
|
---|
1097 | case socket_io_parser_1.PacketType.BINARY_ACK:
|
---|
1098 | this.onack(packet);
|
---|
1099 | break;
|
---|
1100 |
|
---|
1101 | case socket_io_parser_1.PacketType.DISCONNECT:
|
---|
1102 | this.ondisconnect();
|
---|
1103 | break;
|
---|
1104 |
|
---|
1105 | case socket_io_parser_1.PacketType.CONNECT_ERROR:
|
---|
1106 | var err = new Error(packet.data.message); // @ts-ignore
|
---|
1107 |
|
---|
1108 | err.data = packet.data.data;
|
---|
1109 |
|
---|
1110 | _get(_getPrototypeOf(Socket.prototype), "emit", this).call(this, "connect_error", err);
|
---|
1111 |
|
---|
1112 | break;
|
---|
1113 | }
|
---|
1114 | }
|
---|
1115 | /**
|
---|
1116 | * Called upon a server event.
|
---|
1117 | *
|
---|
1118 | * @param packet
|
---|
1119 | * @private
|
---|
1120 | */
|
---|
1121 |
|
---|
1122 | }, {
|
---|
1123 | key: "onevent",
|
---|
1124 | value: function onevent(packet) {
|
---|
1125 | var args = packet.data || [];
|
---|
1126 | debug("emitting event %j", args);
|
---|
1127 |
|
---|
1128 | if (null != packet.id) {
|
---|
1129 | debug("attaching ack callback to event");
|
---|
1130 | args.push(this.ack(packet.id));
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | if (this.connected) {
|
---|
1134 | this.emitEvent(args);
|
---|
1135 | } else {
|
---|
1136 | this.receiveBuffer.push(Object.freeze(args));
|
---|
1137 | }
|
---|
1138 | }
|
---|
1139 | }, {
|
---|
1140 | key: "emitEvent",
|
---|
1141 | value: function emitEvent(args) {
|
---|
1142 | if (this._anyListeners && this._anyListeners.length) {
|
---|
1143 | var listeners = this._anyListeners.slice();
|
---|
1144 |
|
---|
1145 | var _iterator = _createForOfIteratorHelper(listeners),
|
---|
1146 | _step;
|
---|
1147 |
|
---|
1148 | try {
|
---|
1149 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
---|
1150 | var listener = _step.value;
|
---|
1151 | listener.apply(this, args);
|
---|
1152 | }
|
---|
1153 | } catch (err) {
|
---|
1154 | _iterator.e(err);
|
---|
1155 | } finally {
|
---|
1156 | _iterator.f();
|
---|
1157 | }
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 | _get(_getPrototypeOf(Socket.prototype), "emit", this).apply(this, args);
|
---|
1161 | }
|
---|
1162 | /**
|
---|
1163 | * Produces an ack callback to emit with an event.
|
---|
1164 | *
|
---|
1165 | * @private
|
---|
1166 | */
|
---|
1167 |
|
---|
1168 | }, {
|
---|
1169 | key: "ack",
|
---|
1170 | value: function ack(id) {
|
---|
1171 | var self = this;
|
---|
1172 | var sent = false;
|
---|
1173 | return function () {
|
---|
1174 | // prevent double callbacks
|
---|
1175 | if (sent) return;
|
---|
1176 | sent = true;
|
---|
1177 |
|
---|
1178 | for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
---|
1179 | args[_key3] = arguments[_key3];
|
---|
1180 | }
|
---|
1181 |
|
---|
1182 | debug("sending ack %j", args);
|
---|
1183 | self.packet({
|
---|
1184 | type: socket_io_parser_1.PacketType.ACK,
|
---|
1185 | id: id,
|
---|
1186 | data: args
|
---|
1187 | });
|
---|
1188 | };
|
---|
1189 | }
|
---|
1190 | /**
|
---|
1191 | * Called upon a server acknowlegement.
|
---|
1192 | *
|
---|
1193 | * @param packet
|
---|
1194 | * @private
|
---|
1195 | */
|
---|
1196 |
|
---|
1197 | }, {
|
---|
1198 | key: "onack",
|
---|
1199 | value: function onack(packet) {
|
---|
1200 | var ack = this.acks[packet.id];
|
---|
1201 |
|
---|
1202 | if ("function" === typeof ack) {
|
---|
1203 | debug("calling ack %s with %j", packet.id, packet.data);
|
---|
1204 | ack.apply(this, packet.data);
|
---|
1205 | delete this.acks[packet.id];
|
---|
1206 | } else {
|
---|
1207 | debug("bad ack %s", packet.id);
|
---|
1208 | }
|
---|
1209 | }
|
---|
1210 | /**
|
---|
1211 | * Called upon server connect.
|
---|
1212 | *
|
---|
1213 | * @private
|
---|
1214 | */
|
---|
1215 |
|
---|
1216 | }, {
|
---|
1217 | key: "onconnect",
|
---|
1218 | value: function onconnect(id) {
|
---|
1219 | debug("socket connected with id %s", id);
|
---|
1220 | this.id = id;
|
---|
1221 | this.connected = true;
|
---|
1222 | this.disconnected = false;
|
---|
1223 |
|
---|
1224 | _get(_getPrototypeOf(Socket.prototype), "emit", this).call(this, "connect");
|
---|
1225 |
|
---|
1226 | this.emitBuffered();
|
---|
1227 | }
|
---|
1228 | /**
|
---|
1229 | * Emit buffered events (received and emitted).
|
---|
1230 | *
|
---|
1231 | * @private
|
---|
1232 | */
|
---|
1233 |
|
---|
1234 | }, {
|
---|
1235 | key: "emitBuffered",
|
---|
1236 | value: function emitBuffered() {
|
---|
1237 | var _this3 = this;
|
---|
1238 |
|
---|
1239 | this.receiveBuffer.forEach(function (args) {
|
---|
1240 | return _this3.emitEvent(args);
|
---|
1241 | });
|
---|
1242 | this.receiveBuffer = [];
|
---|
1243 | this.sendBuffer.forEach(function (packet) {
|
---|
1244 | return _this3.packet(packet);
|
---|
1245 | });
|
---|
1246 | this.sendBuffer = [];
|
---|
1247 | }
|
---|
1248 | /**
|
---|
1249 | * Called upon server disconnect.
|
---|
1250 | *
|
---|
1251 | * @private
|
---|
1252 | */
|
---|
1253 |
|
---|
1254 | }, {
|
---|
1255 | key: "ondisconnect",
|
---|
1256 | value: function ondisconnect() {
|
---|
1257 | debug("server disconnect (%s)", this.nsp);
|
---|
1258 | this.destroy();
|
---|
1259 | this.onclose("io server disconnect");
|
---|
1260 | }
|
---|
1261 | /**
|
---|
1262 | * Called upon forced client/server side disconnections,
|
---|
1263 | * this method ensures the manager stops tracking us and
|
---|
1264 | * that reconnections don't get triggered for this.
|
---|
1265 | *
|
---|
1266 | * @private
|
---|
1267 | */
|
---|
1268 |
|
---|
1269 | }, {
|
---|
1270 | key: "destroy",
|
---|
1271 | value: function destroy() {
|
---|
1272 | if (this.subs) {
|
---|
1273 | // clean subscriptions to avoid reconnections
|
---|
1274 | this.subs.forEach(function (subDestroy) {
|
---|
1275 | return subDestroy();
|
---|
1276 | });
|
---|
1277 | this.subs = undefined;
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | this.io["_destroy"](this);
|
---|
1281 | }
|
---|
1282 | /**
|
---|
1283 | * Disconnects the socket manually.
|
---|
1284 | *
|
---|
1285 | * @return self
|
---|
1286 | * @public
|
---|
1287 | */
|
---|
1288 |
|
---|
1289 | }, {
|
---|
1290 | key: "disconnect",
|
---|
1291 | value: function disconnect() {
|
---|
1292 | if (this.connected) {
|
---|
1293 | debug("performing disconnect (%s)", this.nsp);
|
---|
1294 | this.packet({
|
---|
1295 | type: socket_io_parser_1.PacketType.DISCONNECT
|
---|
1296 | });
|
---|
1297 | } // remove socket from pool
|
---|
1298 |
|
---|
1299 |
|
---|
1300 | this.destroy();
|
---|
1301 |
|
---|
1302 | if (this.connected) {
|
---|
1303 | // fire events
|
---|
1304 | this.onclose("io client disconnect");
|
---|
1305 | }
|
---|
1306 |
|
---|
1307 | return this;
|
---|
1308 | }
|
---|
1309 | /**
|
---|
1310 | * Alias for disconnect()
|
---|
1311 | *
|
---|
1312 | * @return self
|
---|
1313 | * @public
|
---|
1314 | */
|
---|
1315 |
|
---|
1316 | }, {
|
---|
1317 | key: "close",
|
---|
1318 | value: function close() {
|
---|
1319 | return this.disconnect();
|
---|
1320 | }
|
---|
1321 | /**
|
---|
1322 | * Sets the compress flag.
|
---|
1323 | *
|
---|
1324 | * @param compress - if `true`, compresses the sending data
|
---|
1325 | * @return self
|
---|
1326 | * @public
|
---|
1327 | */
|
---|
1328 |
|
---|
1329 | }, {
|
---|
1330 | key: "compress",
|
---|
1331 | value: function compress(_compress) {
|
---|
1332 | this.flags.compress = _compress;
|
---|
1333 | return this;
|
---|
1334 | }
|
---|
1335 | /**
|
---|
1336 | * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
|
---|
1337 | * ready to send messages.
|
---|
1338 | *
|
---|
1339 | * @returns self
|
---|
1340 | * @public
|
---|
1341 | */
|
---|
1342 |
|
---|
1343 | }, {
|
---|
1344 | key: "onAny",
|
---|
1345 |
|
---|
1346 | /**
|
---|
1347 | * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
---|
1348 | * callback.
|
---|
1349 | *
|
---|
1350 | * @param listener
|
---|
1351 | * @public
|
---|
1352 | */
|
---|
1353 | value: function onAny(listener) {
|
---|
1354 | this._anyListeners = this._anyListeners || [];
|
---|
1355 |
|
---|
1356 | this._anyListeners.push(listener);
|
---|
1357 |
|
---|
1358 | return this;
|
---|
1359 | }
|
---|
1360 | /**
|
---|
1361 | * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
---|
1362 | * callback. The listener is added to the beginning of the listeners array.
|
---|
1363 | *
|
---|
1364 | * @param listener
|
---|
1365 | * @public
|
---|
1366 | */
|
---|
1367 |
|
---|
1368 | }, {
|
---|
1369 | key: "prependAny",
|
---|
1370 | value: function prependAny(listener) {
|
---|
1371 | this._anyListeners = this._anyListeners || [];
|
---|
1372 |
|
---|
1373 | this._anyListeners.unshift(listener);
|
---|
1374 |
|
---|
1375 | return this;
|
---|
1376 | }
|
---|
1377 | /**
|
---|
1378 | * Removes the listener that will be fired when any event is emitted.
|
---|
1379 | *
|
---|
1380 | * @param listener
|
---|
1381 | * @public
|
---|
1382 | */
|
---|
1383 |
|
---|
1384 | }, {
|
---|
1385 | key: "offAny",
|
---|
1386 | value: function offAny(listener) {
|
---|
1387 | if (!this._anyListeners) {
|
---|
1388 | return this;
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 | if (listener) {
|
---|
1392 | var listeners = this._anyListeners;
|
---|
1393 |
|
---|
1394 | for (var i = 0; i < listeners.length; i++) {
|
---|
1395 | if (listener === listeners[i]) {
|
---|
1396 | listeners.splice(i, 1);
|
---|
1397 | return this;
|
---|
1398 | }
|
---|
1399 | }
|
---|
1400 | } else {
|
---|
1401 | this._anyListeners = [];
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 | return this;
|
---|
1405 | }
|
---|
1406 | /**
|
---|
1407 | * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
---|
1408 | * e.g. to remove listeners.
|
---|
1409 | *
|
---|
1410 | * @public
|
---|
1411 | */
|
---|
1412 |
|
---|
1413 | }, {
|
---|
1414 | key: "listenersAny",
|
---|
1415 | value: function listenersAny() {
|
---|
1416 | return this._anyListeners || [];
|
---|
1417 | }
|
---|
1418 | }, {
|
---|
1419 | key: "active",
|
---|
1420 | get: function get() {
|
---|
1421 | return !!this.subs;
|
---|
1422 | }
|
---|
1423 | }, {
|
---|
1424 | key: "volatile",
|
---|
1425 | get: function get() {
|
---|
1426 | this.flags["volatile"] = true;
|
---|
1427 | return this;
|
---|
1428 | }
|
---|
1429 | }]);
|
---|
1430 |
|
---|
1431 | return Socket;
|
---|
1432 | }(Emitter);
|
---|
1433 |
|
---|
1434 | exports.Socket = Socket;
|
---|
1435 |
|
---|
1436 | /***/ }),
|
---|
1437 |
|
---|
1438 | /***/ "./build/url.js":
|
---|
1439 | /*!**********************!*\
|
---|
1440 | !*** ./build/url.js ***!
|
---|
1441 | \**********************/
|
---|
1442 | /*! no static exports found */
|
---|
1443 | /***/ (function(module, exports, __webpack_require__) {
|
---|
1444 |
|
---|
1445 | "use strict";
|
---|
1446 |
|
---|
1447 |
|
---|
1448 | Object.defineProperty(exports, "__esModule", {
|
---|
1449 | value: true
|
---|
1450 | });
|
---|
1451 | exports.url = void 0;
|
---|
1452 |
|
---|
1453 | var parseuri = __webpack_require__(/*! parseuri */ "./node_modules/parseuri/index.js");
|
---|
1454 |
|
---|
1455 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("socket.io-client:url");
|
---|
1456 | /**
|
---|
1457 | * URL parser.
|
---|
1458 | *
|
---|
1459 | * @param uri - url
|
---|
1460 | * @param path - the request path of the connection
|
---|
1461 | * @param loc - An object meant to mimic window.location.
|
---|
1462 | * Defaults to window.location.
|
---|
1463 | * @public
|
---|
1464 | */
|
---|
1465 |
|
---|
1466 |
|
---|
1467 | function url(uri) {
|
---|
1468 | var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
---|
1469 | var loc = arguments.length > 2 ? arguments[2] : undefined;
|
---|
1470 | var obj = uri; // default to window.location
|
---|
1471 |
|
---|
1472 | loc = loc || typeof location !== "undefined" && location;
|
---|
1473 | if (null == uri) uri = loc.protocol + "//" + loc.host; // relative path support
|
---|
1474 |
|
---|
1475 | if (typeof uri === "string") {
|
---|
1476 | if ("/" === uri.charAt(0)) {
|
---|
1477 | if ("/" === uri.charAt(1)) {
|
---|
1478 | uri = loc.protocol + uri;
|
---|
1479 | } else {
|
---|
1480 | uri = loc.host + uri;
|
---|
1481 | }
|
---|
1482 | }
|
---|
1483 |
|
---|
1484 | if (!/^(https?|wss?):\/\//.test(uri)) {
|
---|
1485 | debug("protocol-less url %s", uri);
|
---|
1486 |
|
---|
1487 | if ("undefined" !== typeof loc) {
|
---|
1488 | uri = loc.protocol + "//" + uri;
|
---|
1489 | } else {
|
---|
1490 | uri = "https://" + uri;
|
---|
1491 | }
|
---|
1492 | } // parse
|
---|
1493 |
|
---|
1494 |
|
---|
1495 | debug("parse %s", uri);
|
---|
1496 | obj = parseuri(uri);
|
---|
1497 | } // make sure we treat `localhost:80` and `localhost` equally
|
---|
1498 |
|
---|
1499 |
|
---|
1500 | if (!obj.port) {
|
---|
1501 | if (/^(http|ws)$/.test(obj.protocol)) {
|
---|
1502 | obj.port = "80";
|
---|
1503 | } else if (/^(http|ws)s$/.test(obj.protocol)) {
|
---|
1504 | obj.port = "443";
|
---|
1505 | }
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | obj.path = obj.path || "/";
|
---|
1509 | var ipv6 = obj.host.indexOf(":") !== -1;
|
---|
1510 | var host = ipv6 ? "[" + obj.host + "]" : obj.host; // define unique id
|
---|
1511 |
|
---|
1512 | obj.id = obj.protocol + "://" + host + ":" + obj.port + path; // define href
|
---|
1513 |
|
---|
1514 | obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
|
---|
1515 | return obj;
|
---|
1516 | }
|
---|
1517 |
|
---|
1518 | exports.url = url;
|
---|
1519 |
|
---|
1520 | /***/ }),
|
---|
1521 |
|
---|
1522 | /***/ "./node_modules/backo2/index.js":
|
---|
1523 | /*!**************************************!*\
|
---|
1524 | !*** ./node_modules/backo2/index.js ***!
|
---|
1525 | \**************************************/
|
---|
1526 | /*! no static exports found */
|
---|
1527 | /***/ (function(module, exports) {
|
---|
1528 |
|
---|
1529 | /**
|
---|
1530 | * Expose `Backoff`.
|
---|
1531 | */
|
---|
1532 | module.exports = Backoff;
|
---|
1533 | /**
|
---|
1534 | * Initialize backoff timer with `opts`.
|
---|
1535 | *
|
---|
1536 | * - `min` initial timeout in milliseconds [100]
|
---|
1537 | * - `max` max timeout [10000]
|
---|
1538 | * - `jitter` [0]
|
---|
1539 | * - `factor` [2]
|
---|
1540 | *
|
---|
1541 | * @param {Object} opts
|
---|
1542 | * @api public
|
---|
1543 | */
|
---|
1544 |
|
---|
1545 | function Backoff(opts) {
|
---|
1546 | opts = opts || {};
|
---|
1547 | this.ms = opts.min || 100;
|
---|
1548 | this.max = opts.max || 10000;
|
---|
1549 | this.factor = opts.factor || 2;
|
---|
1550 | this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
|
---|
1551 | this.attempts = 0;
|
---|
1552 | }
|
---|
1553 | /**
|
---|
1554 | * Return the backoff duration.
|
---|
1555 | *
|
---|
1556 | * @return {Number}
|
---|
1557 | * @api public
|
---|
1558 | */
|
---|
1559 |
|
---|
1560 |
|
---|
1561 | Backoff.prototype.duration = function () {
|
---|
1562 | var ms = this.ms * Math.pow(this.factor, this.attempts++);
|
---|
1563 |
|
---|
1564 | if (this.jitter) {
|
---|
1565 | var rand = Math.random();
|
---|
1566 | var deviation = Math.floor(rand * this.jitter * ms);
|
---|
1567 | ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 | return Math.min(ms, this.max) | 0;
|
---|
1571 | };
|
---|
1572 | /**
|
---|
1573 | * Reset the number of attempts.
|
---|
1574 | *
|
---|
1575 | * @api public
|
---|
1576 | */
|
---|
1577 |
|
---|
1578 |
|
---|
1579 | Backoff.prototype.reset = function () {
|
---|
1580 | this.attempts = 0;
|
---|
1581 | };
|
---|
1582 | /**
|
---|
1583 | * Set the minimum duration
|
---|
1584 | *
|
---|
1585 | * @api public
|
---|
1586 | */
|
---|
1587 |
|
---|
1588 |
|
---|
1589 | Backoff.prototype.setMin = function (min) {
|
---|
1590 | this.ms = min;
|
---|
1591 | };
|
---|
1592 | /**
|
---|
1593 | * Set the maximum duration
|
---|
1594 | *
|
---|
1595 | * @api public
|
---|
1596 | */
|
---|
1597 |
|
---|
1598 |
|
---|
1599 | Backoff.prototype.setMax = function (max) {
|
---|
1600 | this.max = max;
|
---|
1601 | };
|
---|
1602 | /**
|
---|
1603 | * Set the jitter
|
---|
1604 | *
|
---|
1605 | * @api public
|
---|
1606 | */
|
---|
1607 |
|
---|
1608 |
|
---|
1609 | Backoff.prototype.setJitter = function (jitter) {
|
---|
1610 | this.jitter = jitter;
|
---|
1611 | };
|
---|
1612 |
|
---|
1613 | /***/ }),
|
---|
1614 |
|
---|
1615 | /***/ "./node_modules/component-emitter/index.js":
|
---|
1616 | /*!*************************************************!*\
|
---|
1617 | !*** ./node_modules/component-emitter/index.js ***!
|
---|
1618 | \*************************************************/
|
---|
1619 | /*! no static exports found */
|
---|
1620 | /***/ (function(module, exports, __webpack_require__) {
|
---|
1621 |
|
---|
1622 | /**
|
---|
1623 | * Expose `Emitter`.
|
---|
1624 | */
|
---|
1625 | if (true) {
|
---|
1626 | module.exports = Emitter;
|
---|
1627 | }
|
---|
1628 | /**
|
---|
1629 | * Initialize a new `Emitter`.
|
---|
1630 | *
|
---|
1631 | * @api public
|
---|
1632 | */
|
---|
1633 |
|
---|
1634 |
|
---|
1635 | function Emitter(obj) {
|
---|
1636 | if (obj) return mixin(obj);
|
---|
1637 | }
|
---|
1638 |
|
---|
1639 | ;
|
---|
1640 | /**
|
---|
1641 | * Mixin the emitter properties.
|
---|
1642 | *
|
---|
1643 | * @param {Object} obj
|
---|
1644 | * @return {Object}
|
---|
1645 | * @api private
|
---|
1646 | */
|
---|
1647 |
|
---|
1648 | function mixin(obj) {
|
---|
1649 | for (var key in Emitter.prototype) {
|
---|
1650 | obj[key] = Emitter.prototype[key];
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | return obj;
|
---|
1654 | }
|
---|
1655 | /**
|
---|
1656 | * Listen on the given `event` with `fn`.
|
---|
1657 | *
|
---|
1658 | * @param {String} event
|
---|
1659 | * @param {Function} fn
|
---|
1660 | * @return {Emitter}
|
---|
1661 | * @api public
|
---|
1662 | */
|
---|
1663 |
|
---|
1664 |
|
---|
1665 | Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
|
---|
1666 | this._callbacks = this._callbacks || {};
|
---|
1667 | (this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
|
---|
1668 | return this;
|
---|
1669 | };
|
---|
1670 | /**
|
---|
1671 | * Adds an `event` listener that will be invoked a single
|
---|
1672 | * time then automatically removed.
|
---|
1673 | *
|
---|
1674 | * @param {String} event
|
---|
1675 | * @param {Function} fn
|
---|
1676 | * @return {Emitter}
|
---|
1677 | * @api public
|
---|
1678 | */
|
---|
1679 |
|
---|
1680 |
|
---|
1681 | Emitter.prototype.once = function (event, fn) {
|
---|
1682 | function on() {
|
---|
1683 | this.off(event, on);
|
---|
1684 | fn.apply(this, arguments);
|
---|
1685 | }
|
---|
1686 |
|
---|
1687 | on.fn = fn;
|
---|
1688 | this.on(event, on);
|
---|
1689 | return this;
|
---|
1690 | };
|
---|
1691 | /**
|
---|
1692 | * Remove the given callback for `event` or all
|
---|
1693 | * registered callbacks.
|
---|
1694 | *
|
---|
1695 | * @param {String} event
|
---|
1696 | * @param {Function} fn
|
---|
1697 | * @return {Emitter}
|
---|
1698 | * @api public
|
---|
1699 | */
|
---|
1700 |
|
---|
1701 |
|
---|
1702 | Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
|
---|
1703 | this._callbacks = this._callbacks || {}; // all
|
---|
1704 |
|
---|
1705 | if (0 == arguments.length) {
|
---|
1706 | this._callbacks = {};
|
---|
1707 | return this;
|
---|
1708 | } // specific event
|
---|
1709 |
|
---|
1710 |
|
---|
1711 | var callbacks = this._callbacks['$' + event];
|
---|
1712 | if (!callbacks) return this; // remove all handlers
|
---|
1713 |
|
---|
1714 | if (1 == arguments.length) {
|
---|
1715 | delete this._callbacks['$' + event];
|
---|
1716 | return this;
|
---|
1717 | } // remove specific handler
|
---|
1718 |
|
---|
1719 |
|
---|
1720 | var cb;
|
---|
1721 |
|
---|
1722 | for (var i = 0; i < callbacks.length; i++) {
|
---|
1723 | cb = callbacks[i];
|
---|
1724 |
|
---|
1725 | if (cb === fn || cb.fn === fn) {
|
---|
1726 | callbacks.splice(i, 1);
|
---|
1727 | break;
|
---|
1728 | }
|
---|
1729 | } // Remove event specific arrays for event types that no
|
---|
1730 | // one is subscribed for to avoid memory leak.
|
---|
1731 |
|
---|
1732 |
|
---|
1733 | if (callbacks.length === 0) {
|
---|
1734 | delete this._callbacks['$' + event];
|
---|
1735 | }
|
---|
1736 |
|
---|
1737 | return this;
|
---|
1738 | };
|
---|
1739 | /**
|
---|
1740 | * Emit `event` with the given args.
|
---|
1741 | *
|
---|
1742 | * @param {String} event
|
---|
1743 | * @param {Mixed} ...
|
---|
1744 | * @return {Emitter}
|
---|
1745 | */
|
---|
1746 |
|
---|
1747 |
|
---|
1748 | Emitter.prototype.emit = function (event) {
|
---|
1749 | this._callbacks = this._callbacks || {};
|
---|
1750 | var args = new Array(arguments.length - 1),
|
---|
1751 | callbacks = this._callbacks['$' + event];
|
---|
1752 |
|
---|
1753 | for (var i = 1; i < arguments.length; i++) {
|
---|
1754 | args[i - 1] = arguments[i];
|
---|
1755 | }
|
---|
1756 |
|
---|
1757 | if (callbacks) {
|
---|
1758 | callbacks = callbacks.slice(0);
|
---|
1759 |
|
---|
1760 | for (var i = 0, len = callbacks.length; i < len; ++i) {
|
---|
1761 | callbacks[i].apply(this, args);
|
---|
1762 | }
|
---|
1763 | }
|
---|
1764 |
|
---|
1765 | return this;
|
---|
1766 | };
|
---|
1767 | /**
|
---|
1768 | * Return array of callbacks for `event`.
|
---|
1769 | *
|
---|
1770 | * @param {String} event
|
---|
1771 | * @return {Array}
|
---|
1772 | * @api public
|
---|
1773 | */
|
---|
1774 |
|
---|
1775 |
|
---|
1776 | Emitter.prototype.listeners = function (event) {
|
---|
1777 | this._callbacks = this._callbacks || {};
|
---|
1778 | return this._callbacks['$' + event] || [];
|
---|
1779 | };
|
---|
1780 | /**
|
---|
1781 | * Check if this emitter has `event` handlers.
|
---|
1782 | *
|
---|
1783 | * @param {String} event
|
---|
1784 | * @return {Boolean}
|
---|
1785 | * @api public
|
---|
1786 | */
|
---|
1787 |
|
---|
1788 |
|
---|
1789 | Emitter.prototype.hasListeners = function (event) {
|
---|
1790 | return !!this.listeners(event).length;
|
---|
1791 | };
|
---|
1792 |
|
---|
1793 | /***/ }),
|
---|
1794 |
|
---|
1795 | /***/ "./node_modules/debug/src/browser.js":
|
---|
1796 | /*!*******************************************!*\
|
---|
1797 | !*** ./node_modules/debug/src/browser.js ***!
|
---|
1798 | \*******************************************/
|
---|
1799 | /*! no static exports found */
|
---|
1800 | /***/ (function(module, exports, __webpack_require__) {
|
---|
1801 |
|
---|
1802 | /* eslint-env browser */
|
---|
1803 |
|
---|
1804 | /**
|
---|
1805 | * This is the web browser implementation of `debug()`.
|
---|
1806 | */
|
---|
1807 | exports.formatArgs = formatArgs;
|
---|
1808 | exports.save = save;
|
---|
1809 | exports.load = load;
|
---|
1810 | exports.useColors = useColors;
|
---|
1811 | exports.storage = localstorage();
|
---|
1812 |
|
---|
1813 | exports.destroy = function () {
|
---|
1814 | var warned = false;
|
---|
1815 | return function () {
|
---|
1816 | if (!warned) {
|
---|
1817 | warned = true;
|
---|
1818 | console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
---|
1819 | }
|
---|
1820 | };
|
---|
1821 | }();
|
---|
1822 | /**
|
---|
1823 | * Colors.
|
---|
1824 | */
|
---|
1825 |
|
---|
1826 |
|
---|
1827 | exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
---|
1828 | /**
|
---|
1829 | * Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
---|
1830 | * and the Firebug extension (any Firefox version) are known
|
---|
1831 | * to support "%c" CSS customizations.
|
---|
1832 | *
|
---|
1833 | * TODO: add a `localStorage` variable to explicitly enable/disable colors
|
---|
1834 | */
|
---|
1835 | // eslint-disable-next-line complexity
|
---|
1836 |
|
---|
1837 | function useColors() {
|
---|
1838 | // NB: In an Electron preload script, document will be defined but not fully
|
---|
1839 | // initialized. Since we know we're in Chrome, we'll just detect this case
|
---|
1840 | // explicitly
|
---|
1841 | if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
---|
1842 | return true;
|
---|
1843 | } // Internet Explorer and Edge do not support colors.
|
---|
1844 |
|
---|
1845 |
|
---|
1846 | if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
---|
1847 | return false;
|
---|
1848 | } // Is webkit? http://stackoverflow.com/a/16459606/376773
|
---|
1849 | // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
---|
1850 |
|
---|
1851 |
|
---|
1852 | return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
---|
1853 | typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
---|
1854 | // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
---|
1855 | typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
---|
1856 | typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
---|
1857 | }
|
---|
1858 | /**
|
---|
1859 | * Colorize log arguments if enabled.
|
---|
1860 | *
|
---|
1861 | * @api public
|
---|
1862 | */
|
---|
1863 |
|
---|
1864 |
|
---|
1865 | function formatArgs(args) {
|
---|
1866 | args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
---|
1867 |
|
---|
1868 | if (!this.useColors) {
|
---|
1869 | return;
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 | var c = 'color: ' + this.color;
|
---|
1873 | args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
---|
1874 | // arguments passed either before or after the %c, so we need to
|
---|
1875 | // figure out the correct index to insert the CSS into
|
---|
1876 |
|
---|
1877 | var index = 0;
|
---|
1878 | var lastC = 0;
|
---|
1879 | args[0].replace(/%[a-zA-Z%]/g, function (match) {
|
---|
1880 | if (match === '%%') {
|
---|
1881 | return;
|
---|
1882 | }
|
---|
1883 |
|
---|
1884 | index++;
|
---|
1885 |
|
---|
1886 | if (match === '%c') {
|
---|
1887 | // We only are interested in the *last* %c
|
---|
1888 | // (the user may have provided their own)
|
---|
1889 | lastC = index;
|
---|
1890 | }
|
---|
1891 | });
|
---|
1892 | args.splice(lastC, 0, c);
|
---|
1893 | }
|
---|
1894 | /**
|
---|
1895 | * Invokes `console.debug()` when available.
|
---|
1896 | * No-op when `console.debug` is not a "function".
|
---|
1897 | * If `console.debug` is not available, falls back
|
---|
1898 | * to `console.log`.
|
---|
1899 | *
|
---|
1900 | * @api public
|
---|
1901 | */
|
---|
1902 |
|
---|
1903 |
|
---|
1904 | exports.log = console.debug || console.log || function () {};
|
---|
1905 | /**
|
---|
1906 | * Save `namespaces`.
|
---|
1907 | *
|
---|
1908 | * @param {String} namespaces
|
---|
1909 | * @api private
|
---|
1910 | */
|
---|
1911 |
|
---|
1912 |
|
---|
1913 | function save(namespaces) {
|
---|
1914 | try {
|
---|
1915 | if (namespaces) {
|
---|
1916 | exports.storage.setItem('debug', namespaces);
|
---|
1917 | } else {
|
---|
1918 | exports.storage.removeItem('debug');
|
---|
1919 | }
|
---|
1920 | } catch (error) {// Swallow
|
---|
1921 | // XXX (@Qix-) should we be logging these?
|
---|
1922 | }
|
---|
1923 | }
|
---|
1924 | /**
|
---|
1925 | * Load `namespaces`.
|
---|
1926 | *
|
---|
1927 | * @return {String} returns the previously persisted debug modes
|
---|
1928 | * @api private
|
---|
1929 | */
|
---|
1930 |
|
---|
1931 |
|
---|
1932 | function load() {
|
---|
1933 | var r;
|
---|
1934 |
|
---|
1935 | try {
|
---|
1936 | r = exports.storage.getItem('debug');
|
---|
1937 | } catch (error) {// Swallow
|
---|
1938 | // XXX (@Qix-) should we be logging these?
|
---|
1939 | } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
---|
1940 |
|
---|
1941 |
|
---|
1942 | if (!r && typeof process !== 'undefined' && 'env' in process) {
|
---|
1943 | r = process.env.DEBUG;
|
---|
1944 | }
|
---|
1945 |
|
---|
1946 | return r;
|
---|
1947 | }
|
---|
1948 | /**
|
---|
1949 | * Localstorage attempts to return the localstorage.
|
---|
1950 | *
|
---|
1951 | * This is necessary because safari throws
|
---|
1952 | * when a user disables cookies/localstorage
|
---|
1953 | * and you attempt to access it.
|
---|
1954 | *
|
---|
1955 | * @return {LocalStorage}
|
---|
1956 | * @api private
|
---|
1957 | */
|
---|
1958 |
|
---|
1959 |
|
---|
1960 | function localstorage() {
|
---|
1961 | try {
|
---|
1962 | // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
---|
1963 | // The Browser also has localStorage in the global context.
|
---|
1964 | return localStorage;
|
---|
1965 | } catch (error) {// Swallow
|
---|
1966 | // XXX (@Qix-) should we be logging these?
|
---|
1967 | }
|
---|
1968 | }
|
---|
1969 |
|
---|
1970 | module.exports = __webpack_require__(/*! ./common */ "./node_modules/debug/src/common.js")(exports);
|
---|
1971 | var formatters = module.exports.formatters;
|
---|
1972 | /**
|
---|
1973 | * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
---|
1974 | */
|
---|
1975 |
|
---|
1976 | formatters.j = function (v) {
|
---|
1977 | try {
|
---|
1978 | return JSON.stringify(v);
|
---|
1979 | } catch (error) {
|
---|
1980 | return '[UnexpectedJSONParseError]: ' + error.message;
|
---|
1981 | }
|
---|
1982 | };
|
---|
1983 |
|
---|
1984 | /***/ }),
|
---|
1985 |
|
---|
1986 | /***/ "./node_modules/debug/src/common.js":
|
---|
1987 | /*!******************************************!*\
|
---|
1988 | !*** ./node_modules/debug/src/common.js ***!
|
---|
1989 | \******************************************/
|
---|
1990 | /*! no static exports found */
|
---|
1991 | /***/ (function(module, exports, __webpack_require__) {
|
---|
1992 |
|
---|
1993 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
---|
1994 |
|
---|
1995 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
---|
1996 |
|
---|
1997 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
---|
1998 |
|
---|
1999 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
---|
2000 |
|
---|
2001 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
---|
2002 |
|
---|
2003 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
---|
2004 |
|
---|
2005 | /**
|
---|
2006 | * This is the common logic for both the Node.js and web browser
|
---|
2007 | * implementations of `debug()`.
|
---|
2008 | */
|
---|
2009 | function setup(env) {
|
---|
2010 | createDebug.debug = createDebug;
|
---|
2011 | createDebug["default"] = createDebug;
|
---|
2012 | createDebug.coerce = coerce;
|
---|
2013 | createDebug.disable = disable;
|
---|
2014 | createDebug.enable = enable;
|
---|
2015 | createDebug.enabled = enabled;
|
---|
2016 | createDebug.humanize = __webpack_require__(/*! ms */ "./node_modules/ms/index.js");
|
---|
2017 | createDebug.destroy = destroy;
|
---|
2018 | Object.keys(env).forEach(function (key) {
|
---|
2019 | createDebug[key] = env[key];
|
---|
2020 | });
|
---|
2021 | /**
|
---|
2022 | * The currently active debug mode names, and names to skip.
|
---|
2023 | */
|
---|
2024 |
|
---|
2025 | createDebug.names = [];
|
---|
2026 | createDebug.skips = [];
|
---|
2027 | /**
|
---|
2028 | * Map of special "%n" handling functions, for the debug "format" argument.
|
---|
2029 | *
|
---|
2030 | * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
---|
2031 | */
|
---|
2032 |
|
---|
2033 | createDebug.formatters = {};
|
---|
2034 | /**
|
---|
2035 | * Selects a color for a debug namespace
|
---|
2036 | * @param {String} namespace The namespace string for the for the debug instance to be colored
|
---|
2037 | * @return {Number|String} An ANSI color code for the given namespace
|
---|
2038 | * @api private
|
---|
2039 | */
|
---|
2040 |
|
---|
2041 | function selectColor(namespace) {
|
---|
2042 | var hash = 0;
|
---|
2043 |
|
---|
2044 | for (var i = 0; i < namespace.length; i++) {
|
---|
2045 | hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
---|
2046 | hash |= 0; // Convert to 32bit integer
|
---|
2047 | }
|
---|
2048 |
|
---|
2049 | return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
---|
2050 | }
|
---|
2051 |
|
---|
2052 | createDebug.selectColor = selectColor;
|
---|
2053 | /**
|
---|
2054 | * Create a debugger with the given `namespace`.
|
---|
2055 | *
|
---|
2056 | * @param {String} namespace
|
---|
2057 | * @return {Function}
|
---|
2058 | * @api public
|
---|
2059 | */
|
---|
2060 |
|
---|
2061 | function createDebug(namespace) {
|
---|
2062 | var prevTime;
|
---|
2063 | var enableOverride = null;
|
---|
2064 |
|
---|
2065 | function debug() {
|
---|
2066 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
---|
2067 | args[_key] = arguments[_key];
|
---|
2068 | }
|
---|
2069 |
|
---|
2070 | // Disabled?
|
---|
2071 | if (!debug.enabled) {
|
---|
2072 | return;
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 | var self = debug; // Set `diff` timestamp
|
---|
2076 |
|
---|
2077 | var curr = Number(new Date());
|
---|
2078 | var ms = curr - (prevTime || curr);
|
---|
2079 | self.diff = ms;
|
---|
2080 | self.prev = prevTime;
|
---|
2081 | self.curr = curr;
|
---|
2082 | prevTime = curr;
|
---|
2083 | args[0] = createDebug.coerce(args[0]);
|
---|
2084 |
|
---|
2085 | if (typeof args[0] !== 'string') {
|
---|
2086 | // Anything else let's inspect with %O
|
---|
2087 | args.unshift('%O');
|
---|
2088 | } // Apply any `formatters` transformations
|
---|
2089 |
|
---|
2090 |
|
---|
2091 | var index = 0;
|
---|
2092 | args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
|
---|
2093 | // If we encounter an escaped % then don't increase the array index
|
---|
2094 | if (match === '%%') {
|
---|
2095 | return '%';
|
---|
2096 | }
|
---|
2097 |
|
---|
2098 | index++;
|
---|
2099 | var formatter = createDebug.formatters[format];
|
---|
2100 |
|
---|
2101 | if (typeof formatter === 'function') {
|
---|
2102 | var val = args[index];
|
---|
2103 | match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
---|
2104 |
|
---|
2105 | args.splice(index, 1);
|
---|
2106 | index--;
|
---|
2107 | }
|
---|
2108 |
|
---|
2109 | return match;
|
---|
2110 | }); // Apply env-specific formatting (colors, etc.)
|
---|
2111 |
|
---|
2112 | createDebug.formatArgs.call(self, args);
|
---|
2113 | var logFn = self.log || createDebug.log;
|
---|
2114 | logFn.apply(self, args);
|
---|
2115 | }
|
---|
2116 |
|
---|
2117 | debug.namespace = namespace;
|
---|
2118 | debug.useColors = createDebug.useColors();
|
---|
2119 | debug.color = createDebug.selectColor(namespace);
|
---|
2120 | debug.extend = extend;
|
---|
2121 | debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
---|
2122 |
|
---|
2123 | Object.defineProperty(debug, 'enabled', {
|
---|
2124 | enumerable: true,
|
---|
2125 | configurable: false,
|
---|
2126 | get: function get() {
|
---|
2127 | return enableOverride === null ? createDebug.enabled(namespace) : enableOverride;
|
---|
2128 | },
|
---|
2129 | set: function set(v) {
|
---|
2130 | enableOverride = v;
|
---|
2131 | }
|
---|
2132 | }); // Env-specific initialization logic for debug instances
|
---|
2133 |
|
---|
2134 | if (typeof createDebug.init === 'function') {
|
---|
2135 | createDebug.init(debug);
|
---|
2136 | }
|
---|
2137 |
|
---|
2138 | return debug;
|
---|
2139 | }
|
---|
2140 |
|
---|
2141 | function extend(namespace, delimiter) {
|
---|
2142 | var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
---|
2143 | newDebug.log = this.log;
|
---|
2144 | return newDebug;
|
---|
2145 | }
|
---|
2146 | /**
|
---|
2147 | * Enables a debug mode by namespaces. This can include modes
|
---|
2148 | * separated by a colon and wildcards.
|
---|
2149 | *
|
---|
2150 | * @param {String} namespaces
|
---|
2151 | * @api public
|
---|
2152 | */
|
---|
2153 |
|
---|
2154 |
|
---|
2155 | function enable(namespaces) {
|
---|
2156 | createDebug.save(namespaces);
|
---|
2157 | createDebug.names = [];
|
---|
2158 | createDebug.skips = [];
|
---|
2159 | var i;
|
---|
2160 | var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
---|
2161 | var len = split.length;
|
---|
2162 |
|
---|
2163 | for (i = 0; i < len; i++) {
|
---|
2164 | if (!split[i]) {
|
---|
2165 | // ignore empty strings
|
---|
2166 | continue;
|
---|
2167 | }
|
---|
2168 |
|
---|
2169 | namespaces = split[i].replace(/\*/g, '.*?');
|
---|
2170 |
|
---|
2171 | if (namespaces[0] === '-') {
|
---|
2172 | createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
---|
2173 | } else {
|
---|
2174 | createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
---|
2175 | }
|
---|
2176 | }
|
---|
2177 | }
|
---|
2178 | /**
|
---|
2179 | * Disable debug output.
|
---|
2180 | *
|
---|
2181 | * @return {String} namespaces
|
---|
2182 | * @api public
|
---|
2183 | */
|
---|
2184 |
|
---|
2185 |
|
---|
2186 | function disable() {
|
---|
2187 | var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) {
|
---|
2188 | return '-' + namespace;
|
---|
2189 | }))).join(',');
|
---|
2190 | createDebug.enable('');
|
---|
2191 | return namespaces;
|
---|
2192 | }
|
---|
2193 | /**
|
---|
2194 | * Returns true if the given mode name is enabled, false otherwise.
|
---|
2195 | *
|
---|
2196 | * @param {String} name
|
---|
2197 | * @return {Boolean}
|
---|
2198 | * @api public
|
---|
2199 | */
|
---|
2200 |
|
---|
2201 |
|
---|
2202 | function enabled(name) {
|
---|
2203 | if (name[name.length - 1] === '*') {
|
---|
2204 | return true;
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 | var i;
|
---|
2208 | var len;
|
---|
2209 |
|
---|
2210 | for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
---|
2211 | if (createDebug.skips[i].test(name)) {
|
---|
2212 | return false;
|
---|
2213 | }
|
---|
2214 | }
|
---|
2215 |
|
---|
2216 | for (i = 0, len = createDebug.names.length; i < len; i++) {
|
---|
2217 | if (createDebug.names[i].test(name)) {
|
---|
2218 | return true;
|
---|
2219 | }
|
---|
2220 | }
|
---|
2221 |
|
---|
2222 | return false;
|
---|
2223 | }
|
---|
2224 | /**
|
---|
2225 | * Convert regexp to namespace
|
---|
2226 | *
|
---|
2227 | * @param {RegExp} regxep
|
---|
2228 | * @return {String} namespace
|
---|
2229 | * @api private
|
---|
2230 | */
|
---|
2231 |
|
---|
2232 |
|
---|
2233 | function toNamespace(regexp) {
|
---|
2234 | return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
|
---|
2235 | }
|
---|
2236 | /**
|
---|
2237 | * Coerce `val`.
|
---|
2238 | *
|
---|
2239 | * @param {Mixed} val
|
---|
2240 | * @return {Mixed}
|
---|
2241 | * @api private
|
---|
2242 | */
|
---|
2243 |
|
---|
2244 |
|
---|
2245 | function coerce(val) {
|
---|
2246 | if (val instanceof Error) {
|
---|
2247 | return val.stack || val.message;
|
---|
2248 | }
|
---|
2249 |
|
---|
2250 | return val;
|
---|
2251 | }
|
---|
2252 | /**
|
---|
2253 | * XXX DO NOT USE. This is a temporary stub function.
|
---|
2254 | * XXX It WILL be removed in the next major release.
|
---|
2255 | */
|
---|
2256 |
|
---|
2257 |
|
---|
2258 | function destroy() {
|
---|
2259 | console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
---|
2260 | }
|
---|
2261 |
|
---|
2262 | createDebug.enable(createDebug.load());
|
---|
2263 | return createDebug;
|
---|
2264 | }
|
---|
2265 |
|
---|
2266 | module.exports = setup;
|
---|
2267 |
|
---|
2268 | /***/ }),
|
---|
2269 |
|
---|
2270 | /***/ "./node_modules/engine.io-client/lib/globalThis.browser.js":
|
---|
2271 | /*!*****************************************************************!*\
|
---|
2272 | !*** ./node_modules/engine.io-client/lib/globalThis.browser.js ***!
|
---|
2273 | \*****************************************************************/
|
---|
2274 | /*! no static exports found */
|
---|
2275 | /***/ (function(module, exports) {
|
---|
2276 |
|
---|
2277 | module.exports = function () {
|
---|
2278 | if (typeof self !== "undefined") {
|
---|
2279 | return self;
|
---|
2280 | } else if (typeof window !== "undefined") {
|
---|
2281 | return window;
|
---|
2282 | } else {
|
---|
2283 | return Function("return this")();
|
---|
2284 | }
|
---|
2285 | }();
|
---|
2286 |
|
---|
2287 | /***/ }),
|
---|
2288 |
|
---|
2289 | /***/ "./node_modules/engine.io-client/lib/index.js":
|
---|
2290 | /*!****************************************************!*\
|
---|
2291 | !*** ./node_modules/engine.io-client/lib/index.js ***!
|
---|
2292 | \****************************************************/
|
---|
2293 | /*! no static exports found */
|
---|
2294 | /***/ (function(module, exports, __webpack_require__) {
|
---|
2295 |
|
---|
2296 | var Socket = __webpack_require__(/*! ./socket */ "./node_modules/engine.io-client/lib/socket.js");
|
---|
2297 |
|
---|
2298 | module.exports = function (uri, opts) {
|
---|
2299 | return new Socket(uri, opts);
|
---|
2300 | };
|
---|
2301 | /**
|
---|
2302 | * Expose deps for legacy compatibility
|
---|
2303 | * and standalone browser access.
|
---|
2304 | */
|
---|
2305 |
|
---|
2306 |
|
---|
2307 | module.exports.Socket = Socket;
|
---|
2308 | module.exports.protocol = Socket.protocol; // this is an int
|
---|
2309 |
|
---|
2310 | module.exports.Transport = __webpack_require__(/*! ./transport */ "./node_modules/engine.io-client/lib/transport.js");
|
---|
2311 | module.exports.transports = __webpack_require__(/*! ./transports/index */ "./node_modules/engine.io-client/lib/transports/index.js");
|
---|
2312 | module.exports.parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/index.js");
|
---|
2313 |
|
---|
2314 | /***/ }),
|
---|
2315 |
|
---|
2316 | /***/ "./node_modules/engine.io-client/lib/socket.js":
|
---|
2317 | /*!*****************************************************!*\
|
---|
2318 | !*** ./node_modules/engine.io-client/lib/socket.js ***!
|
---|
2319 | \*****************************************************/
|
---|
2320 | /*! no static exports found */
|
---|
2321 | /***/ (function(module, exports, __webpack_require__) {
|
---|
2322 |
|
---|
2323 | 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); }
|
---|
2324 |
|
---|
2325 | 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); }
|
---|
2326 |
|
---|
2327 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
2328 |
|
---|
2329 | function _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); } }
|
---|
2330 |
|
---|
2331 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
2332 |
|
---|
2333 | function _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); }
|
---|
2334 |
|
---|
2335 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
2336 |
|
---|
2337 | function _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); }; }
|
---|
2338 |
|
---|
2339 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
2340 |
|
---|
2341 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
2342 |
|
---|
2343 | function _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; } }
|
---|
2344 |
|
---|
2345 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
2346 |
|
---|
2347 | var transports = __webpack_require__(/*! ./transports/index */ "./node_modules/engine.io-client/lib/transports/index.js");
|
---|
2348 |
|
---|
2349 | var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
---|
2350 |
|
---|
2351 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("engine.io-client:socket");
|
---|
2352 |
|
---|
2353 | var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/index.js");
|
---|
2354 |
|
---|
2355 | var parseuri = __webpack_require__(/*! parseuri */ "./node_modules/parseuri/index.js");
|
---|
2356 |
|
---|
2357 | var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
|
---|
2358 |
|
---|
2359 | var Socket = /*#__PURE__*/function (_Emitter) {
|
---|
2360 | _inherits(Socket, _Emitter);
|
---|
2361 |
|
---|
2362 | var _super = _createSuper(Socket);
|
---|
2363 |
|
---|
2364 | /**
|
---|
2365 | * Socket constructor.
|
---|
2366 | *
|
---|
2367 | * @param {String|Object} uri or options
|
---|
2368 | * @param {Object} options
|
---|
2369 | * @api public
|
---|
2370 | */
|
---|
2371 | function Socket(uri) {
|
---|
2372 | var _this;
|
---|
2373 |
|
---|
2374 | var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
---|
2375 |
|
---|
2376 | _classCallCheck(this, Socket);
|
---|
2377 |
|
---|
2378 | _this = _super.call(this);
|
---|
2379 |
|
---|
2380 | if (uri && "object" === _typeof(uri)) {
|
---|
2381 | opts = uri;
|
---|
2382 | uri = null;
|
---|
2383 | }
|
---|
2384 |
|
---|
2385 | if (uri) {
|
---|
2386 | uri = parseuri(uri);
|
---|
2387 | opts.hostname = uri.host;
|
---|
2388 | opts.secure = uri.protocol === "https" || uri.protocol === "wss";
|
---|
2389 | opts.port = uri.port;
|
---|
2390 | if (uri.query) opts.query = uri.query;
|
---|
2391 | } else if (opts.host) {
|
---|
2392 | opts.hostname = parseuri(opts.host).host;
|
---|
2393 | }
|
---|
2394 |
|
---|
2395 | _this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;
|
---|
2396 |
|
---|
2397 | if (opts.hostname && !opts.port) {
|
---|
2398 | // if no port is specified manually, use the protocol default
|
---|
2399 | opts.port = _this.secure ? "443" : "80";
|
---|
2400 | }
|
---|
2401 |
|
---|
2402 | _this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
|
---|
2403 | _this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : _this.secure ? 443 : 80);
|
---|
2404 | _this.transports = opts.transports || ["polling", "websocket"];
|
---|
2405 | _this.readyState = "";
|
---|
2406 | _this.writeBuffer = [];
|
---|
2407 | _this.prevBufferLen = 0;
|
---|
2408 | _this.opts = _extends({
|
---|
2409 | path: "/engine.io",
|
---|
2410 | agent: false,
|
---|
2411 | withCredentials: false,
|
---|
2412 | upgrade: true,
|
---|
2413 | jsonp: true,
|
---|
2414 | timestampParam: "t",
|
---|
2415 | rememberUpgrade: false,
|
---|
2416 | rejectUnauthorized: true,
|
---|
2417 | perMessageDeflate: {
|
---|
2418 | threshold: 1024
|
---|
2419 | },
|
---|
2420 | transportOptions: {}
|
---|
2421 | }, opts);
|
---|
2422 | _this.opts.path = _this.opts.path.replace(/\/$/, "") + "/";
|
---|
2423 |
|
---|
2424 | if (typeof _this.opts.query === "string") {
|
---|
2425 | _this.opts.query = parseqs.decode(_this.opts.query);
|
---|
2426 | } // set on handshake
|
---|
2427 |
|
---|
2428 |
|
---|
2429 | _this.id = null;
|
---|
2430 | _this.upgrades = null;
|
---|
2431 | _this.pingInterval = null;
|
---|
2432 | _this.pingTimeout = null; // set on heartbeat
|
---|
2433 |
|
---|
2434 | _this.pingTimeoutTimer = null;
|
---|
2435 |
|
---|
2436 | if (typeof addEventListener === "function") {
|
---|
2437 | addEventListener("beforeunload", function () {
|
---|
2438 | if (_this.transport) {
|
---|
2439 | // silently close the transport
|
---|
2440 | _this.transport.removeAllListeners();
|
---|
2441 |
|
---|
2442 | _this.transport.close();
|
---|
2443 | }
|
---|
2444 | }, false);
|
---|
2445 | }
|
---|
2446 |
|
---|
2447 | _this.open();
|
---|
2448 |
|
---|
2449 | return _this;
|
---|
2450 | }
|
---|
2451 | /**
|
---|
2452 | * Creates transport of the given type.
|
---|
2453 | *
|
---|
2454 | * @param {String} transport name
|
---|
2455 | * @return {Transport}
|
---|
2456 | * @api private
|
---|
2457 | */
|
---|
2458 |
|
---|
2459 |
|
---|
2460 | _createClass(Socket, [{
|
---|
2461 | key: "createTransport",
|
---|
2462 | value: function createTransport(name) {
|
---|
2463 | debug('creating transport "%s"', name);
|
---|
2464 | var query = clone(this.opts.query); // append engine.io protocol identifier
|
---|
2465 |
|
---|
2466 | query.EIO = parser.protocol; // transport name
|
---|
2467 |
|
---|
2468 | query.transport = name; // session id if we already have one
|
---|
2469 |
|
---|
2470 | if (this.id) query.sid = this.id;
|
---|
2471 |
|
---|
2472 | var opts = _extends({}, this.opts.transportOptions[name], this.opts, {
|
---|
2473 | query: query,
|
---|
2474 | socket: this,
|
---|
2475 | hostname: this.hostname,
|
---|
2476 | secure: this.secure,
|
---|
2477 | port: this.port
|
---|
2478 | });
|
---|
2479 |
|
---|
2480 | debug("options: %j", opts);
|
---|
2481 | return new transports[name](opts);
|
---|
2482 | }
|
---|
2483 | /**
|
---|
2484 | * Initializes transport to use and starts probe.
|
---|
2485 | *
|
---|
2486 | * @api private
|
---|
2487 | */
|
---|
2488 |
|
---|
2489 | }, {
|
---|
2490 | key: "open",
|
---|
2491 | value: function open() {
|
---|
2492 | var transport;
|
---|
2493 |
|
---|
2494 | if (this.opts.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1) {
|
---|
2495 | transport = "websocket";
|
---|
2496 | } else if (0 === this.transports.length) {
|
---|
2497 | // Emit error on next tick so it can be listened to
|
---|
2498 | var self = this;
|
---|
2499 | setTimeout(function () {
|
---|
2500 | self.emit("error", "No transports available");
|
---|
2501 | }, 0);
|
---|
2502 | return;
|
---|
2503 | } else {
|
---|
2504 | transport = this.transports[0];
|
---|
2505 | }
|
---|
2506 |
|
---|
2507 | this.readyState = "opening"; // Retry with the next transport if the transport is disabled (jsonp: false)
|
---|
2508 |
|
---|
2509 | try {
|
---|
2510 | transport = this.createTransport(transport);
|
---|
2511 | } catch (e) {
|
---|
2512 | debug("error while creating transport: %s", e);
|
---|
2513 | this.transports.shift();
|
---|
2514 | this.open();
|
---|
2515 | return;
|
---|
2516 | }
|
---|
2517 |
|
---|
2518 | transport.open();
|
---|
2519 | this.setTransport(transport);
|
---|
2520 | }
|
---|
2521 | /**
|
---|
2522 | * Sets the current transport. Disables the existing one (if any).
|
---|
2523 | *
|
---|
2524 | * @api private
|
---|
2525 | */
|
---|
2526 |
|
---|
2527 | }, {
|
---|
2528 | key: "setTransport",
|
---|
2529 | value: function setTransport(transport) {
|
---|
2530 | debug("setting transport %s", transport.name);
|
---|
2531 | var self = this;
|
---|
2532 |
|
---|
2533 | if (this.transport) {
|
---|
2534 | debug("clearing existing transport %s", this.transport.name);
|
---|
2535 | this.transport.removeAllListeners();
|
---|
2536 | } // set up transport
|
---|
2537 |
|
---|
2538 |
|
---|
2539 | this.transport = transport; // set up transport listeners
|
---|
2540 |
|
---|
2541 | transport.on("drain", function () {
|
---|
2542 | self.onDrain();
|
---|
2543 | }).on("packet", function (packet) {
|
---|
2544 | self.onPacket(packet);
|
---|
2545 | }).on("error", function (e) {
|
---|
2546 | self.onError(e);
|
---|
2547 | }).on("close", function () {
|
---|
2548 | self.onClose("transport close");
|
---|
2549 | });
|
---|
2550 | }
|
---|
2551 | /**
|
---|
2552 | * Probes a transport.
|
---|
2553 | *
|
---|
2554 | * @param {String} transport name
|
---|
2555 | * @api private
|
---|
2556 | */
|
---|
2557 |
|
---|
2558 | }, {
|
---|
2559 | key: "probe",
|
---|
2560 | value: function probe(name) {
|
---|
2561 | debug('probing transport "%s"', name);
|
---|
2562 | var transport = this.createTransport(name, {
|
---|
2563 | probe: 1
|
---|
2564 | });
|
---|
2565 | var failed = false;
|
---|
2566 | var self = this;
|
---|
2567 | Socket.priorWebsocketSuccess = false;
|
---|
2568 |
|
---|
2569 | function onTransportOpen() {
|
---|
2570 | if (self.onlyBinaryUpgrades) {
|
---|
2571 | var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
|
---|
2572 | failed = failed || upgradeLosesBinary;
|
---|
2573 | }
|
---|
2574 |
|
---|
2575 | if (failed) return;
|
---|
2576 | debug('probe transport "%s" opened', name);
|
---|
2577 | transport.send([{
|
---|
2578 | type: "ping",
|
---|
2579 | data: "probe"
|
---|
2580 | }]);
|
---|
2581 | transport.once("packet", function (msg) {
|
---|
2582 | if (failed) return;
|
---|
2583 |
|
---|
2584 | if ("pong" === msg.type && "probe" === msg.data) {
|
---|
2585 | debug('probe transport "%s" pong', name);
|
---|
2586 | self.upgrading = true;
|
---|
2587 | self.emit("upgrading", transport);
|
---|
2588 | if (!transport) return;
|
---|
2589 | Socket.priorWebsocketSuccess = "websocket" === transport.name;
|
---|
2590 | debug('pausing current transport "%s"', self.transport.name);
|
---|
2591 | self.transport.pause(function () {
|
---|
2592 | if (failed) return;
|
---|
2593 | if ("closed" === self.readyState) return;
|
---|
2594 | debug("changing transport and sending upgrade packet");
|
---|
2595 | cleanup();
|
---|
2596 | self.setTransport(transport);
|
---|
2597 | transport.send([{
|
---|
2598 | type: "upgrade"
|
---|
2599 | }]);
|
---|
2600 | self.emit("upgrade", transport);
|
---|
2601 | transport = null;
|
---|
2602 | self.upgrading = false;
|
---|
2603 | self.flush();
|
---|
2604 | });
|
---|
2605 | } else {
|
---|
2606 | debug('probe transport "%s" failed', name);
|
---|
2607 | var err = new Error("probe error");
|
---|
2608 | err.transport = transport.name;
|
---|
2609 | self.emit("upgradeError", err);
|
---|
2610 | }
|
---|
2611 | });
|
---|
2612 | }
|
---|
2613 |
|
---|
2614 | function freezeTransport() {
|
---|
2615 | if (failed) return; // Any callback called by transport should be ignored since now
|
---|
2616 |
|
---|
2617 | failed = true;
|
---|
2618 | cleanup();
|
---|
2619 | transport.close();
|
---|
2620 | transport = null;
|
---|
2621 | } // Handle any error that happens while probing
|
---|
2622 |
|
---|
2623 |
|
---|
2624 | function onerror(err) {
|
---|
2625 | var error = new Error("probe error: " + err);
|
---|
2626 | error.transport = transport.name;
|
---|
2627 | freezeTransport();
|
---|
2628 | debug('probe transport "%s" failed because of error: %s', name, err);
|
---|
2629 | self.emit("upgradeError", error);
|
---|
2630 | }
|
---|
2631 |
|
---|
2632 | function onTransportClose() {
|
---|
2633 | onerror("transport closed");
|
---|
2634 | } // When the socket is closed while we're probing
|
---|
2635 |
|
---|
2636 |
|
---|
2637 | function onclose() {
|
---|
2638 | onerror("socket closed");
|
---|
2639 | } // When the socket is upgraded while we're probing
|
---|
2640 |
|
---|
2641 |
|
---|
2642 | function onupgrade(to) {
|
---|
2643 | if (transport && to.name !== transport.name) {
|
---|
2644 | debug('"%s" works - aborting "%s"', to.name, transport.name);
|
---|
2645 | freezeTransport();
|
---|
2646 | }
|
---|
2647 | } // Remove all listeners on the transport and on self
|
---|
2648 |
|
---|
2649 |
|
---|
2650 | function cleanup() {
|
---|
2651 | transport.removeListener("open", onTransportOpen);
|
---|
2652 | transport.removeListener("error", onerror);
|
---|
2653 | transport.removeListener("close", onTransportClose);
|
---|
2654 | self.removeListener("close", onclose);
|
---|
2655 | self.removeListener("upgrading", onupgrade);
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 | transport.once("open", onTransportOpen);
|
---|
2659 | transport.once("error", onerror);
|
---|
2660 | transport.once("close", onTransportClose);
|
---|
2661 | this.once("close", onclose);
|
---|
2662 | this.once("upgrading", onupgrade);
|
---|
2663 | transport.open();
|
---|
2664 | }
|
---|
2665 | /**
|
---|
2666 | * Called when connection is deemed open.
|
---|
2667 | *
|
---|
2668 | * @api public
|
---|
2669 | */
|
---|
2670 |
|
---|
2671 | }, {
|
---|
2672 | key: "onOpen",
|
---|
2673 | value: function onOpen() {
|
---|
2674 | debug("socket open");
|
---|
2675 | this.readyState = "open";
|
---|
2676 | Socket.priorWebsocketSuccess = "websocket" === this.transport.name;
|
---|
2677 | this.emit("open");
|
---|
2678 | this.flush(); // we check for `readyState` in case an `open`
|
---|
2679 | // listener already closed the socket
|
---|
2680 |
|
---|
2681 | if ("open" === this.readyState && this.opts.upgrade && this.transport.pause) {
|
---|
2682 | debug("starting upgrade probes");
|
---|
2683 | var i = 0;
|
---|
2684 | var l = this.upgrades.length;
|
---|
2685 |
|
---|
2686 | for (; i < l; i++) {
|
---|
2687 | this.probe(this.upgrades[i]);
|
---|
2688 | }
|
---|
2689 | }
|
---|
2690 | }
|
---|
2691 | /**
|
---|
2692 | * Handles a packet.
|
---|
2693 | *
|
---|
2694 | * @api private
|
---|
2695 | */
|
---|
2696 |
|
---|
2697 | }, {
|
---|
2698 | key: "onPacket",
|
---|
2699 | value: function onPacket(packet) {
|
---|
2700 | if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
|
---|
2701 | debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
|
---|
2702 | this.emit("packet", packet); // Socket is live - any packet counts
|
---|
2703 |
|
---|
2704 | this.emit("heartbeat");
|
---|
2705 |
|
---|
2706 | switch (packet.type) {
|
---|
2707 | case "open":
|
---|
2708 | this.onHandshake(JSON.parse(packet.data));
|
---|
2709 | break;
|
---|
2710 |
|
---|
2711 | case "ping":
|
---|
2712 | this.resetPingTimeout();
|
---|
2713 | this.sendPacket("pong");
|
---|
2714 | this.emit("pong");
|
---|
2715 | break;
|
---|
2716 |
|
---|
2717 | case "error":
|
---|
2718 | var err = new Error("server error");
|
---|
2719 | err.code = packet.data;
|
---|
2720 | this.onError(err);
|
---|
2721 | break;
|
---|
2722 |
|
---|
2723 | case "message":
|
---|
2724 | this.emit("data", packet.data);
|
---|
2725 | this.emit("message", packet.data);
|
---|
2726 | break;
|
---|
2727 | }
|
---|
2728 | } else {
|
---|
2729 | debug('packet received with socket readyState "%s"', this.readyState);
|
---|
2730 | }
|
---|
2731 | }
|
---|
2732 | /**
|
---|
2733 | * Called upon handshake completion.
|
---|
2734 | *
|
---|
2735 | * @param {Object} handshake obj
|
---|
2736 | * @api private
|
---|
2737 | */
|
---|
2738 |
|
---|
2739 | }, {
|
---|
2740 | key: "onHandshake",
|
---|
2741 | value: function onHandshake(data) {
|
---|
2742 | this.emit("handshake", data);
|
---|
2743 | this.id = data.sid;
|
---|
2744 | this.transport.query.sid = data.sid;
|
---|
2745 | this.upgrades = this.filterUpgrades(data.upgrades);
|
---|
2746 | this.pingInterval = data.pingInterval;
|
---|
2747 | this.pingTimeout = data.pingTimeout;
|
---|
2748 | this.onOpen(); // In case open handler closes socket
|
---|
2749 |
|
---|
2750 | if ("closed" === this.readyState) return;
|
---|
2751 | this.resetPingTimeout();
|
---|
2752 | }
|
---|
2753 | /**
|
---|
2754 | * Sets and resets ping timeout timer based on server pings.
|
---|
2755 | *
|
---|
2756 | * @api private
|
---|
2757 | */
|
---|
2758 |
|
---|
2759 | }, {
|
---|
2760 | key: "resetPingTimeout",
|
---|
2761 | value: function resetPingTimeout() {
|
---|
2762 | var _this2 = this;
|
---|
2763 |
|
---|
2764 | clearTimeout(this.pingTimeoutTimer);
|
---|
2765 | this.pingTimeoutTimer = setTimeout(function () {
|
---|
2766 | _this2.onClose("ping timeout");
|
---|
2767 | }, this.pingInterval + this.pingTimeout);
|
---|
2768 | }
|
---|
2769 | /**
|
---|
2770 | * Called on `drain` event
|
---|
2771 | *
|
---|
2772 | * @api private
|
---|
2773 | */
|
---|
2774 |
|
---|
2775 | }, {
|
---|
2776 | key: "onDrain",
|
---|
2777 | value: function onDrain() {
|
---|
2778 | this.writeBuffer.splice(0, this.prevBufferLen); // setting prevBufferLen = 0 is very important
|
---|
2779 | // for example, when upgrading, upgrade packet is sent over,
|
---|
2780 | // and a nonzero prevBufferLen could cause problems on `drain`
|
---|
2781 |
|
---|
2782 | this.prevBufferLen = 0;
|
---|
2783 |
|
---|
2784 | if (0 === this.writeBuffer.length) {
|
---|
2785 | this.emit("drain");
|
---|
2786 | } else {
|
---|
2787 | this.flush();
|
---|
2788 | }
|
---|
2789 | }
|
---|
2790 | /**
|
---|
2791 | * Flush write buffers.
|
---|
2792 | *
|
---|
2793 | * @api private
|
---|
2794 | */
|
---|
2795 |
|
---|
2796 | }, {
|
---|
2797 | key: "flush",
|
---|
2798 | value: function flush() {
|
---|
2799 | if ("closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
|
---|
2800 | debug("flushing %d packets in socket", this.writeBuffer.length);
|
---|
2801 | this.transport.send(this.writeBuffer); // keep track of current length of writeBuffer
|
---|
2802 | // splice writeBuffer and callbackBuffer on `drain`
|
---|
2803 |
|
---|
2804 | this.prevBufferLen = this.writeBuffer.length;
|
---|
2805 | this.emit("flush");
|
---|
2806 | }
|
---|
2807 | }
|
---|
2808 | /**
|
---|
2809 | * Sends a message.
|
---|
2810 | *
|
---|
2811 | * @param {String} message.
|
---|
2812 | * @param {Function} callback function.
|
---|
2813 | * @param {Object} options.
|
---|
2814 | * @return {Socket} for chaining.
|
---|
2815 | * @api public
|
---|
2816 | */
|
---|
2817 |
|
---|
2818 | }, {
|
---|
2819 | key: "write",
|
---|
2820 | value: function write(msg, options, fn) {
|
---|
2821 | this.sendPacket("message", msg, options, fn);
|
---|
2822 | return this;
|
---|
2823 | }
|
---|
2824 | }, {
|
---|
2825 | key: "send",
|
---|
2826 | value: function send(msg, options, fn) {
|
---|
2827 | this.sendPacket("message", msg, options, fn);
|
---|
2828 | return this;
|
---|
2829 | }
|
---|
2830 | /**
|
---|
2831 | * Sends a packet.
|
---|
2832 | *
|
---|
2833 | * @param {String} packet type.
|
---|
2834 | * @param {String} data.
|
---|
2835 | * @param {Object} options.
|
---|
2836 | * @param {Function} callback function.
|
---|
2837 | * @api private
|
---|
2838 | */
|
---|
2839 |
|
---|
2840 | }, {
|
---|
2841 | key: "sendPacket",
|
---|
2842 | value: function sendPacket(type, data, options, fn) {
|
---|
2843 | if ("function" === typeof data) {
|
---|
2844 | fn = data;
|
---|
2845 | data = undefined;
|
---|
2846 | }
|
---|
2847 |
|
---|
2848 | if ("function" === typeof options) {
|
---|
2849 | fn = options;
|
---|
2850 | options = null;
|
---|
2851 | }
|
---|
2852 |
|
---|
2853 | if ("closing" === this.readyState || "closed" === this.readyState) {
|
---|
2854 | return;
|
---|
2855 | }
|
---|
2856 |
|
---|
2857 | options = options || {};
|
---|
2858 | options.compress = false !== options.compress;
|
---|
2859 | var packet = {
|
---|
2860 | type: type,
|
---|
2861 | data: data,
|
---|
2862 | options: options
|
---|
2863 | };
|
---|
2864 | this.emit("packetCreate", packet);
|
---|
2865 | this.writeBuffer.push(packet);
|
---|
2866 | if (fn) this.once("flush", fn);
|
---|
2867 | this.flush();
|
---|
2868 | }
|
---|
2869 | /**
|
---|
2870 | * Closes the connection.
|
---|
2871 | *
|
---|
2872 | * @api private
|
---|
2873 | */
|
---|
2874 |
|
---|
2875 | }, {
|
---|
2876 | key: "close",
|
---|
2877 | value: function close() {
|
---|
2878 | var self = this;
|
---|
2879 |
|
---|
2880 | if ("opening" === this.readyState || "open" === this.readyState) {
|
---|
2881 | this.readyState = "closing";
|
---|
2882 |
|
---|
2883 | if (this.writeBuffer.length) {
|
---|
2884 | this.once("drain", function () {
|
---|
2885 | if (this.upgrading) {
|
---|
2886 | waitForUpgrade();
|
---|
2887 | } else {
|
---|
2888 | close();
|
---|
2889 | }
|
---|
2890 | });
|
---|
2891 | } else if (this.upgrading) {
|
---|
2892 | waitForUpgrade();
|
---|
2893 | } else {
|
---|
2894 | close();
|
---|
2895 | }
|
---|
2896 | }
|
---|
2897 |
|
---|
2898 | function close() {
|
---|
2899 | self.onClose("forced close");
|
---|
2900 | debug("socket closing - telling transport to close");
|
---|
2901 | self.transport.close();
|
---|
2902 | }
|
---|
2903 |
|
---|
2904 | function cleanupAndClose() {
|
---|
2905 | self.removeListener("upgrade", cleanupAndClose);
|
---|
2906 | self.removeListener("upgradeError", cleanupAndClose);
|
---|
2907 | close();
|
---|
2908 | }
|
---|
2909 |
|
---|
2910 | function waitForUpgrade() {
|
---|
2911 | // wait for upgrade to finish since we can't send packets while pausing a transport
|
---|
2912 | self.once("upgrade", cleanupAndClose);
|
---|
2913 | self.once("upgradeError", cleanupAndClose);
|
---|
2914 | }
|
---|
2915 |
|
---|
2916 | return this;
|
---|
2917 | }
|
---|
2918 | /**
|
---|
2919 | * Called upon transport error
|
---|
2920 | *
|
---|
2921 | * @api private
|
---|
2922 | */
|
---|
2923 |
|
---|
2924 | }, {
|
---|
2925 | key: "onError",
|
---|
2926 | value: function onError(err) {
|
---|
2927 | debug("socket error %j", err);
|
---|
2928 | Socket.priorWebsocketSuccess = false;
|
---|
2929 | this.emit("error", err);
|
---|
2930 | this.onClose("transport error", err);
|
---|
2931 | }
|
---|
2932 | /**
|
---|
2933 | * Called upon transport close.
|
---|
2934 | *
|
---|
2935 | * @api private
|
---|
2936 | */
|
---|
2937 |
|
---|
2938 | }, {
|
---|
2939 | key: "onClose",
|
---|
2940 | value: function onClose(reason, desc) {
|
---|
2941 | if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
|
---|
2942 | debug('socket close with reason: "%s"', reason);
|
---|
2943 | var self = this; // clear timers
|
---|
2944 |
|
---|
2945 | clearTimeout(this.pingIntervalTimer);
|
---|
2946 | clearTimeout(this.pingTimeoutTimer); // stop event from firing again for transport
|
---|
2947 |
|
---|
2948 | this.transport.removeAllListeners("close"); // ensure transport won't stay open
|
---|
2949 |
|
---|
2950 | this.transport.close(); // ignore further transport communication
|
---|
2951 |
|
---|
2952 | this.transport.removeAllListeners(); // set ready state
|
---|
2953 |
|
---|
2954 | this.readyState = "closed"; // clear session id
|
---|
2955 |
|
---|
2956 | this.id = null; // emit close event
|
---|
2957 |
|
---|
2958 | this.emit("close", reason, desc); // clean buffers after, so users can still
|
---|
2959 | // grab the buffers on `close` event
|
---|
2960 |
|
---|
2961 | self.writeBuffer = [];
|
---|
2962 | self.prevBufferLen = 0;
|
---|
2963 | }
|
---|
2964 | }
|
---|
2965 | /**
|
---|
2966 | * Filters upgrades, returning only those matching client transports.
|
---|
2967 | *
|
---|
2968 | * @param {Array} server upgrades
|
---|
2969 | * @api private
|
---|
2970 | *
|
---|
2971 | */
|
---|
2972 |
|
---|
2973 | }, {
|
---|
2974 | key: "filterUpgrades",
|
---|
2975 | value: function filterUpgrades(upgrades) {
|
---|
2976 | var filteredUpgrades = [];
|
---|
2977 | var i = 0;
|
---|
2978 | var j = upgrades.length;
|
---|
2979 |
|
---|
2980 | for (; i < j; i++) {
|
---|
2981 | if (~this.transports.indexOf(upgrades[i])) filteredUpgrades.push(upgrades[i]);
|
---|
2982 | }
|
---|
2983 |
|
---|
2984 | return filteredUpgrades;
|
---|
2985 | }
|
---|
2986 | }]);
|
---|
2987 |
|
---|
2988 | return Socket;
|
---|
2989 | }(Emitter);
|
---|
2990 |
|
---|
2991 | Socket.priorWebsocketSuccess = false;
|
---|
2992 | /**
|
---|
2993 | * Protocol version.
|
---|
2994 | *
|
---|
2995 | * @api public
|
---|
2996 | */
|
---|
2997 |
|
---|
2998 | Socket.protocol = parser.protocol; // this is an int
|
---|
2999 |
|
---|
3000 | function clone(obj) {
|
---|
3001 | var o = {};
|
---|
3002 |
|
---|
3003 | for (var i in obj) {
|
---|
3004 | if (obj.hasOwnProperty(i)) {
|
---|
3005 | o[i] = obj[i];
|
---|
3006 | }
|
---|
3007 | }
|
---|
3008 |
|
---|
3009 | return o;
|
---|
3010 | }
|
---|
3011 |
|
---|
3012 | module.exports = Socket;
|
---|
3013 |
|
---|
3014 | /***/ }),
|
---|
3015 |
|
---|
3016 | /***/ "./node_modules/engine.io-client/lib/transport.js":
|
---|
3017 | /*!********************************************************!*\
|
---|
3018 | !*** ./node_modules/engine.io-client/lib/transport.js ***!
|
---|
3019 | \********************************************************/
|
---|
3020 | /*! no static exports found */
|
---|
3021 | /***/ (function(module, exports, __webpack_require__) {
|
---|
3022 |
|
---|
3023 | 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); }
|
---|
3024 |
|
---|
3025 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
3026 |
|
---|
3027 | function _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); } }
|
---|
3028 |
|
---|
3029 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
3030 |
|
---|
3031 | function _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); }
|
---|
3032 |
|
---|
3033 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
3034 |
|
---|
3035 | function _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); }; }
|
---|
3036 |
|
---|
3037 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
3038 |
|
---|
3039 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
3040 |
|
---|
3041 | function _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; } }
|
---|
3042 |
|
---|
3043 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
3044 |
|
---|
3045 | var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/index.js");
|
---|
3046 |
|
---|
3047 | var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
---|
3048 |
|
---|
3049 | var Transport = /*#__PURE__*/function (_Emitter) {
|
---|
3050 | _inherits(Transport, _Emitter);
|
---|
3051 |
|
---|
3052 | var _super = _createSuper(Transport);
|
---|
3053 |
|
---|
3054 | /**
|
---|
3055 | * Transport abstract constructor.
|
---|
3056 | *
|
---|
3057 | * @param {Object} options.
|
---|
3058 | * @api private
|
---|
3059 | */
|
---|
3060 | function Transport(opts) {
|
---|
3061 | var _this;
|
---|
3062 |
|
---|
3063 | _classCallCheck(this, Transport);
|
---|
3064 |
|
---|
3065 | _this = _super.call(this);
|
---|
3066 | _this.opts = opts;
|
---|
3067 | _this.query = opts.query;
|
---|
3068 | _this.readyState = "";
|
---|
3069 | _this.socket = opts.socket;
|
---|
3070 | return _this;
|
---|
3071 | }
|
---|
3072 | /**
|
---|
3073 | * Emits an error.
|
---|
3074 | *
|
---|
3075 | * @param {String} str
|
---|
3076 | * @return {Transport} for chaining
|
---|
3077 | * @api public
|
---|
3078 | */
|
---|
3079 |
|
---|
3080 |
|
---|
3081 | _createClass(Transport, [{
|
---|
3082 | key: "onError",
|
---|
3083 | value: function onError(msg, desc) {
|
---|
3084 | var err = new Error(msg);
|
---|
3085 | err.type = "TransportError";
|
---|
3086 | err.description = desc;
|
---|
3087 | this.emit("error", err);
|
---|
3088 | return this;
|
---|
3089 | }
|
---|
3090 | /**
|
---|
3091 | * Opens the transport.
|
---|
3092 | *
|
---|
3093 | * @api public
|
---|
3094 | */
|
---|
3095 |
|
---|
3096 | }, {
|
---|
3097 | key: "open",
|
---|
3098 | value: function open() {
|
---|
3099 | if ("closed" === this.readyState || "" === this.readyState) {
|
---|
3100 | this.readyState = "opening";
|
---|
3101 | this.doOpen();
|
---|
3102 | }
|
---|
3103 |
|
---|
3104 | return this;
|
---|
3105 | }
|
---|
3106 | /**
|
---|
3107 | * Closes the transport.
|
---|
3108 | *
|
---|
3109 | * @api private
|
---|
3110 | */
|
---|
3111 |
|
---|
3112 | }, {
|
---|
3113 | key: "close",
|
---|
3114 | value: function close() {
|
---|
3115 | if ("opening" === this.readyState || "open" === this.readyState) {
|
---|
3116 | this.doClose();
|
---|
3117 | this.onClose();
|
---|
3118 | }
|
---|
3119 |
|
---|
3120 | return this;
|
---|
3121 | }
|
---|
3122 | /**
|
---|
3123 | * Sends multiple packets.
|
---|
3124 | *
|
---|
3125 | * @param {Array} packets
|
---|
3126 | * @api private
|
---|
3127 | */
|
---|
3128 |
|
---|
3129 | }, {
|
---|
3130 | key: "send",
|
---|
3131 | value: function send(packets) {
|
---|
3132 | if ("open" === this.readyState) {
|
---|
3133 | this.write(packets);
|
---|
3134 | } else {
|
---|
3135 | throw new Error("Transport not open");
|
---|
3136 | }
|
---|
3137 | }
|
---|
3138 | /**
|
---|
3139 | * Called upon open
|
---|
3140 | *
|
---|
3141 | * @api private
|
---|
3142 | */
|
---|
3143 |
|
---|
3144 | }, {
|
---|
3145 | key: "onOpen",
|
---|
3146 | value: function onOpen() {
|
---|
3147 | this.readyState = "open";
|
---|
3148 | this.writable = true;
|
---|
3149 | this.emit("open");
|
---|
3150 | }
|
---|
3151 | /**
|
---|
3152 | * Called with data.
|
---|
3153 | *
|
---|
3154 | * @param {String} data
|
---|
3155 | * @api private
|
---|
3156 | */
|
---|
3157 |
|
---|
3158 | }, {
|
---|
3159 | key: "onData",
|
---|
3160 | value: function onData(data) {
|
---|
3161 | var packet = parser.decodePacket(data, this.socket.binaryType);
|
---|
3162 | this.onPacket(packet);
|
---|
3163 | }
|
---|
3164 | /**
|
---|
3165 | * Called with a decoded packet.
|
---|
3166 | */
|
---|
3167 |
|
---|
3168 | }, {
|
---|
3169 | key: "onPacket",
|
---|
3170 | value: function onPacket(packet) {
|
---|
3171 | this.emit("packet", packet);
|
---|
3172 | }
|
---|
3173 | /**
|
---|
3174 | * Called upon close.
|
---|
3175 | *
|
---|
3176 | * @api private
|
---|
3177 | */
|
---|
3178 |
|
---|
3179 | }, {
|
---|
3180 | key: "onClose",
|
---|
3181 | value: function onClose() {
|
---|
3182 | this.readyState = "closed";
|
---|
3183 | this.emit("close");
|
---|
3184 | }
|
---|
3185 | }]);
|
---|
3186 |
|
---|
3187 | return Transport;
|
---|
3188 | }(Emitter);
|
---|
3189 |
|
---|
3190 | module.exports = Transport;
|
---|
3191 |
|
---|
3192 | /***/ }),
|
---|
3193 |
|
---|
3194 | /***/ "./node_modules/engine.io-client/lib/transports/index.js":
|
---|
3195 | /*!***************************************************************!*\
|
---|
3196 | !*** ./node_modules/engine.io-client/lib/transports/index.js ***!
|
---|
3197 | \***************************************************************/
|
---|
3198 | /*! no static exports found */
|
---|
3199 | /***/ (function(module, exports, __webpack_require__) {
|
---|
3200 |
|
---|
3201 | var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
|
---|
3202 |
|
---|
3203 | var XHR = __webpack_require__(/*! ./polling-xhr */ "./node_modules/engine.io-client/lib/transports/polling-xhr.js");
|
---|
3204 |
|
---|
3205 | var JSONP = __webpack_require__(/*! ./polling-jsonp */ "./node_modules/engine.io-client/lib/transports/polling-jsonp.js");
|
---|
3206 |
|
---|
3207 | var websocket = __webpack_require__(/*! ./websocket */ "./node_modules/engine.io-client/lib/transports/websocket.js");
|
---|
3208 |
|
---|
3209 | exports.polling = polling;
|
---|
3210 | exports.websocket = websocket;
|
---|
3211 | /**
|
---|
3212 | * Polling transport polymorphic constructor.
|
---|
3213 | * Decides on xhr vs jsonp based on feature detection.
|
---|
3214 | *
|
---|
3215 | * @api private
|
---|
3216 | */
|
---|
3217 |
|
---|
3218 | function polling(opts) {
|
---|
3219 | var xhr;
|
---|
3220 | var xd = false;
|
---|
3221 | var xs = false;
|
---|
3222 | var jsonp = false !== opts.jsonp;
|
---|
3223 |
|
---|
3224 | if (typeof location !== "undefined") {
|
---|
3225 | var isSSL = "https:" === location.protocol;
|
---|
3226 | var port = location.port; // some user agents have empty `location.port`
|
---|
3227 |
|
---|
3228 | if (!port) {
|
---|
3229 | port = isSSL ? 443 : 80;
|
---|
3230 | }
|
---|
3231 |
|
---|
3232 | xd = opts.hostname !== location.hostname || port !== opts.port;
|
---|
3233 | xs = opts.secure !== isSSL;
|
---|
3234 | }
|
---|
3235 |
|
---|
3236 | opts.xdomain = xd;
|
---|
3237 | opts.xscheme = xs;
|
---|
3238 | xhr = new XMLHttpRequest(opts);
|
---|
3239 |
|
---|
3240 | if ("open" in xhr && !opts.forceJSONP) {
|
---|
3241 | return new XHR(opts);
|
---|
3242 | } else {
|
---|
3243 | if (!jsonp) throw new Error("JSONP disabled");
|
---|
3244 | return new JSONP(opts);
|
---|
3245 | }
|
---|
3246 | }
|
---|
3247 |
|
---|
3248 | /***/ }),
|
---|
3249 |
|
---|
3250 | /***/ "./node_modules/engine.io-client/lib/transports/polling-jsonp.js":
|
---|
3251 | /*!***********************************************************************!*\
|
---|
3252 | !*** ./node_modules/engine.io-client/lib/transports/polling-jsonp.js ***!
|
---|
3253 | \***********************************************************************/
|
---|
3254 | /*! no static exports found */
|
---|
3255 | /***/ (function(module, exports, __webpack_require__) {
|
---|
3256 |
|
---|
3257 | 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); }
|
---|
3258 |
|
---|
3259 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
3260 |
|
---|
3261 | function _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); } }
|
---|
3262 |
|
---|
3263 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
3264 |
|
---|
3265 | function _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); }
|
---|
3266 |
|
---|
3267 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
---|
3268 |
|
---|
3269 | function _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); }
|
---|
3270 |
|
---|
3271 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
3272 |
|
---|
3273 | function _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); }; }
|
---|
3274 |
|
---|
3275 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
3276 |
|
---|
3277 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
3278 |
|
---|
3279 | function _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; } }
|
---|
3280 |
|
---|
3281 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
3282 |
|
---|
3283 | var Polling = __webpack_require__(/*! ./polling */ "./node_modules/engine.io-client/lib/transports/polling.js");
|
---|
3284 |
|
---|
3285 | var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
---|
3286 |
|
---|
3287 | var rNewline = /\n/g;
|
---|
3288 | var rEscapedNewline = /\\n/g;
|
---|
3289 | /**
|
---|
3290 | * Global JSONP callbacks.
|
---|
3291 | */
|
---|
3292 |
|
---|
3293 | var callbacks;
|
---|
3294 |
|
---|
3295 | var JSONPPolling = /*#__PURE__*/function (_Polling) {
|
---|
3296 | _inherits(JSONPPolling, _Polling);
|
---|
3297 |
|
---|
3298 | var _super = _createSuper(JSONPPolling);
|
---|
3299 |
|
---|
3300 | /**
|
---|
3301 | * JSONP Polling constructor.
|
---|
3302 | *
|
---|
3303 | * @param {Object} opts.
|
---|
3304 | * @api public
|
---|
3305 | */
|
---|
3306 | function JSONPPolling(opts) {
|
---|
3307 | var _this;
|
---|
3308 |
|
---|
3309 | _classCallCheck(this, JSONPPolling);
|
---|
3310 |
|
---|
3311 | _this = _super.call(this, opts);
|
---|
3312 | _this.query = _this.query || {}; // define global callbacks array if not present
|
---|
3313 | // we do this here (lazily) to avoid unneeded global pollution
|
---|
3314 |
|
---|
3315 | if (!callbacks) {
|
---|
3316 | // we need to consider multiple engines in the same page
|
---|
3317 | callbacks = globalThis.___eio = globalThis.___eio || [];
|
---|
3318 | } // callback identifier
|
---|
3319 |
|
---|
3320 |
|
---|
3321 | _this.index = callbacks.length; // add callback to jsonp global
|
---|
3322 |
|
---|
3323 | var self = _assertThisInitialized(_this);
|
---|
3324 |
|
---|
3325 | callbacks.push(function (msg) {
|
---|
3326 | self.onData(msg);
|
---|
3327 | }); // append to query string
|
---|
3328 |
|
---|
3329 | _this.query.j = _this.index;
|
---|
3330 | return _this;
|
---|
3331 | }
|
---|
3332 | /**
|
---|
3333 | * JSONP only supports binary as base64 encoded strings
|
---|
3334 | */
|
---|
3335 |
|
---|
3336 |
|
---|
3337 | _createClass(JSONPPolling, [{
|
---|
3338 | key: "doClose",
|
---|
3339 |
|
---|
3340 | /**
|
---|
3341 | * Closes the socket.
|
---|
3342 | *
|
---|
3343 | * @api private
|
---|
3344 | */
|
---|
3345 | value: function doClose() {
|
---|
3346 | if (this.script) {
|
---|
3347 | // prevent spurious errors from being emitted when the window is unloaded
|
---|
3348 | this.script.onerror = function () {};
|
---|
3349 |
|
---|
3350 | this.script.parentNode.removeChild(this.script);
|
---|
3351 | this.script = null;
|
---|
3352 | }
|
---|
3353 |
|
---|
3354 | if (this.form) {
|
---|
3355 | this.form.parentNode.removeChild(this.form);
|
---|
3356 | this.form = null;
|
---|
3357 | this.iframe = null;
|
---|
3358 | }
|
---|
3359 |
|
---|
3360 | _get(_getPrototypeOf(JSONPPolling.prototype), "doClose", this).call(this);
|
---|
3361 | }
|
---|
3362 | /**
|
---|
3363 | * Starts a poll cycle.
|
---|
3364 | *
|
---|
3365 | * @api private
|
---|
3366 | */
|
---|
3367 |
|
---|
3368 | }, {
|
---|
3369 | key: "doPoll",
|
---|
3370 | value: function doPoll() {
|
---|
3371 | var self = this;
|
---|
3372 | var script = document.createElement("script");
|
---|
3373 |
|
---|
3374 | if (this.script) {
|
---|
3375 | this.script.parentNode.removeChild(this.script);
|
---|
3376 | this.script = null;
|
---|
3377 | }
|
---|
3378 |
|
---|
3379 | script.async = true;
|
---|
3380 | script.src = this.uri();
|
---|
3381 |
|
---|
3382 | script.onerror = function (e) {
|
---|
3383 | self.onError("jsonp poll error", e);
|
---|
3384 | };
|
---|
3385 |
|
---|
3386 | var insertAt = document.getElementsByTagName("script")[0];
|
---|
3387 |
|
---|
3388 | if (insertAt) {
|
---|
3389 | insertAt.parentNode.insertBefore(script, insertAt);
|
---|
3390 | } else {
|
---|
3391 | (document.head || document.body).appendChild(script);
|
---|
3392 | }
|
---|
3393 |
|
---|
3394 | this.script = script;
|
---|
3395 | var isUAgecko = "undefined" !== typeof navigator && /gecko/i.test(navigator.userAgent);
|
---|
3396 |
|
---|
3397 | if (isUAgecko) {
|
---|
3398 | setTimeout(function () {
|
---|
3399 | var iframe = document.createElement("iframe");
|
---|
3400 | document.body.appendChild(iframe);
|
---|
3401 | document.body.removeChild(iframe);
|
---|
3402 | }, 100);
|
---|
3403 | }
|
---|
3404 | }
|
---|
3405 | /**
|
---|
3406 | * Writes with a hidden iframe.
|
---|
3407 | *
|
---|
3408 | * @param {String} data to send
|
---|
3409 | * @param {Function} called upon flush.
|
---|
3410 | * @api private
|
---|
3411 | */
|
---|
3412 |
|
---|
3413 | }, {
|
---|
3414 | key: "doWrite",
|
---|
3415 | value: function doWrite(data, fn) {
|
---|
3416 | var self = this;
|
---|
3417 | var iframe;
|
---|
3418 |
|
---|
3419 | if (!this.form) {
|
---|
3420 | var form = document.createElement("form");
|
---|
3421 | var area = document.createElement("textarea");
|
---|
3422 | var id = this.iframeId = "eio_iframe_" + this.index;
|
---|
3423 | form.className = "socketio";
|
---|
3424 | form.style.position = "absolute";
|
---|
3425 | form.style.top = "-1000px";
|
---|
3426 | form.style.left = "-1000px";
|
---|
3427 | form.target = id;
|
---|
3428 | form.method = "POST";
|
---|
3429 | form.setAttribute("accept-charset", "utf-8");
|
---|
3430 | area.name = "d";
|
---|
3431 | form.appendChild(area);
|
---|
3432 | document.body.appendChild(form);
|
---|
3433 | this.form = form;
|
---|
3434 | this.area = area;
|
---|
3435 | }
|
---|
3436 |
|
---|
3437 | this.form.action = this.uri();
|
---|
3438 |
|
---|
3439 | function complete() {
|
---|
3440 | initIframe();
|
---|
3441 | fn();
|
---|
3442 | }
|
---|
3443 |
|
---|
3444 | function initIframe() {
|
---|
3445 | if (self.iframe) {
|
---|
3446 | try {
|
---|
3447 | self.form.removeChild(self.iframe);
|
---|
3448 | } catch (e) {
|
---|
3449 | self.onError("jsonp polling iframe removal error", e);
|
---|
3450 | }
|
---|
3451 | }
|
---|
3452 |
|
---|
3453 | try {
|
---|
3454 | // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
|
---|
3455 | var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
|
---|
3456 | iframe = document.createElement(html);
|
---|
3457 | } catch (e) {
|
---|
3458 | iframe = document.createElement("iframe");
|
---|
3459 | iframe.name = self.iframeId;
|
---|
3460 | iframe.src = "javascript:0";
|
---|
3461 | }
|
---|
3462 |
|
---|
3463 | iframe.id = self.iframeId;
|
---|
3464 | self.form.appendChild(iframe);
|
---|
3465 | self.iframe = iframe;
|
---|
3466 | }
|
---|
3467 |
|
---|
3468 | initIframe(); // escape \n to prevent it from being converted into \r\n by some UAs
|
---|
3469 | // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
|
---|
3470 |
|
---|
3471 | data = data.replace(rEscapedNewline, "\\\n");
|
---|
3472 | this.area.value = data.replace(rNewline, "\\n");
|
---|
3473 |
|
---|
3474 | try {
|
---|
3475 | this.form.submit();
|
---|
3476 | } catch (e) {}
|
---|
3477 |
|
---|
3478 | if (this.iframe.attachEvent) {
|
---|
3479 | this.iframe.onreadystatechange = function () {
|
---|
3480 | if (self.iframe.readyState === "complete") {
|
---|
3481 | complete();
|
---|
3482 | }
|
---|
3483 | };
|
---|
3484 | } else {
|
---|
3485 | this.iframe.onload = complete;
|
---|
3486 | }
|
---|
3487 | }
|
---|
3488 | }, {
|
---|
3489 | key: "supportsBinary",
|
---|
3490 | get: function get() {
|
---|
3491 | return false;
|
---|
3492 | }
|
---|
3493 | }]);
|
---|
3494 |
|
---|
3495 | return JSONPPolling;
|
---|
3496 | }(Polling);
|
---|
3497 |
|
---|
3498 | module.exports = JSONPPolling;
|
---|
3499 |
|
---|
3500 | /***/ }),
|
---|
3501 |
|
---|
3502 | /***/ "./node_modules/engine.io-client/lib/transports/polling-xhr.js":
|
---|
3503 | /*!*********************************************************************!*\
|
---|
3504 | !*** ./node_modules/engine.io-client/lib/transports/polling-xhr.js ***!
|
---|
3505 | \*********************************************************************/
|
---|
3506 | /*! no static exports found */
|
---|
3507 | /***/ (function(module, exports, __webpack_require__) {
|
---|
3508 |
|
---|
3509 | 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); }
|
---|
3510 |
|
---|
3511 | 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); }
|
---|
3512 |
|
---|
3513 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
3514 |
|
---|
3515 | function _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); } }
|
---|
3516 |
|
---|
3517 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
3518 |
|
---|
3519 | function _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); }
|
---|
3520 |
|
---|
3521 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
3522 |
|
---|
3523 | function _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); }; }
|
---|
3524 |
|
---|
3525 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
3526 |
|
---|
3527 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
3528 |
|
---|
3529 | function _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; } }
|
---|
3530 |
|
---|
3531 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
3532 |
|
---|
3533 | /* global attachEvent */
|
---|
3534 | var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
|
---|
3535 |
|
---|
3536 | var Polling = __webpack_require__(/*! ./polling */ "./node_modules/engine.io-client/lib/transports/polling.js");
|
---|
3537 |
|
---|
3538 | var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
---|
3539 |
|
---|
3540 | var _require = __webpack_require__(/*! ../util */ "./node_modules/engine.io-client/lib/util.js"),
|
---|
3541 | pick = _require.pick;
|
---|
3542 |
|
---|
3543 | var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
---|
3544 |
|
---|
3545 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("engine.io-client:polling-xhr");
|
---|
3546 | /**
|
---|
3547 | * Empty function
|
---|
3548 | */
|
---|
3549 |
|
---|
3550 |
|
---|
3551 | function empty() {}
|
---|
3552 |
|
---|
3553 | var hasXHR2 = function () {
|
---|
3554 | var xhr = new XMLHttpRequest({
|
---|
3555 | xdomain: false
|
---|
3556 | });
|
---|
3557 | return null != xhr.responseType;
|
---|
3558 | }();
|
---|
3559 |
|
---|
3560 | var XHR = /*#__PURE__*/function (_Polling) {
|
---|
3561 | _inherits(XHR, _Polling);
|
---|
3562 |
|
---|
3563 | var _super = _createSuper(XHR);
|
---|
3564 |
|
---|
3565 | /**
|
---|
3566 | * XHR Polling constructor.
|
---|
3567 | *
|
---|
3568 | * @param {Object} opts
|
---|
3569 | * @api public
|
---|
3570 | */
|
---|
3571 | function XHR(opts) {
|
---|
3572 | var _this;
|
---|
3573 |
|
---|
3574 | _classCallCheck(this, XHR);
|
---|
3575 |
|
---|
3576 | _this = _super.call(this, opts);
|
---|
3577 |
|
---|
3578 | if (typeof location !== "undefined") {
|
---|
3579 | var isSSL = "https:" === location.protocol;
|
---|
3580 | var port = location.port; // some user agents have empty `location.port`
|
---|
3581 |
|
---|
3582 | if (!port) {
|
---|
3583 | port = isSSL ? 443 : 80;
|
---|
3584 | }
|
---|
3585 |
|
---|
3586 | _this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
|
---|
3587 | _this.xs = opts.secure !== isSSL;
|
---|
3588 | }
|
---|
3589 | /**
|
---|
3590 | * XHR supports binary
|
---|
3591 | */
|
---|
3592 |
|
---|
3593 |
|
---|
3594 | var forceBase64 = opts && opts.forceBase64;
|
---|
3595 | _this.supportsBinary = hasXHR2 && !forceBase64;
|
---|
3596 | return _this;
|
---|
3597 | }
|
---|
3598 | /**
|
---|
3599 | * Creates a request.
|
---|
3600 | *
|
---|
3601 | * @param {String} method
|
---|
3602 | * @api private
|
---|
3603 | */
|
---|
3604 |
|
---|
3605 |
|
---|
3606 | _createClass(XHR, [{
|
---|
3607 | key: "request",
|
---|
3608 | value: function request() {
|
---|
3609 | var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
---|
3610 |
|
---|
3611 | _extends(opts, {
|
---|
3612 | xd: this.xd,
|
---|
3613 | xs: this.xs
|
---|
3614 | }, this.opts);
|
---|
3615 |
|
---|
3616 | return new Request(this.uri(), opts);
|
---|
3617 | }
|
---|
3618 | /**
|
---|
3619 | * Sends data.
|
---|
3620 | *
|
---|
3621 | * @param {String} data to send.
|
---|
3622 | * @param {Function} called upon flush.
|
---|
3623 | * @api private
|
---|
3624 | */
|
---|
3625 |
|
---|
3626 | }, {
|
---|
3627 | key: "doWrite",
|
---|
3628 | value: function doWrite(data, fn) {
|
---|
3629 | var req = this.request({
|
---|
3630 | method: "POST",
|
---|
3631 | data: data
|
---|
3632 | });
|
---|
3633 | var self = this;
|
---|
3634 | req.on("success", fn);
|
---|
3635 | req.on("error", function (err) {
|
---|
3636 | self.onError("xhr post error", err);
|
---|
3637 | });
|
---|
3638 | }
|
---|
3639 | /**
|
---|
3640 | * Starts a poll cycle.
|
---|
3641 | *
|
---|
3642 | * @api private
|
---|
3643 | */
|
---|
3644 |
|
---|
3645 | }, {
|
---|
3646 | key: "doPoll",
|
---|
3647 | value: function doPoll() {
|
---|
3648 | debug("xhr poll");
|
---|
3649 | var req = this.request();
|
---|
3650 | var self = this;
|
---|
3651 | req.on("data", function (data) {
|
---|
3652 | self.onData(data);
|
---|
3653 | });
|
---|
3654 | req.on("error", function (err) {
|
---|
3655 | self.onError("xhr poll error", err);
|
---|
3656 | });
|
---|
3657 | this.pollXhr = req;
|
---|
3658 | }
|
---|
3659 | }]);
|
---|
3660 |
|
---|
3661 | return XHR;
|
---|
3662 | }(Polling);
|
---|
3663 |
|
---|
3664 | var Request = /*#__PURE__*/function (_Emitter) {
|
---|
3665 | _inherits(Request, _Emitter);
|
---|
3666 |
|
---|
3667 | var _super2 = _createSuper(Request);
|
---|
3668 |
|
---|
3669 | /**
|
---|
3670 | * Request constructor
|
---|
3671 | *
|
---|
3672 | * @param {Object} options
|
---|
3673 | * @api public
|
---|
3674 | */
|
---|
3675 | function Request(uri, opts) {
|
---|
3676 | var _this2;
|
---|
3677 |
|
---|
3678 | _classCallCheck(this, Request);
|
---|
3679 |
|
---|
3680 | _this2 = _super2.call(this);
|
---|
3681 | _this2.opts = opts;
|
---|
3682 | _this2.method = opts.method || "GET";
|
---|
3683 | _this2.uri = uri;
|
---|
3684 | _this2.async = false !== opts.async;
|
---|
3685 | _this2.data = undefined !== opts.data ? opts.data : null;
|
---|
3686 |
|
---|
3687 | _this2.create();
|
---|
3688 |
|
---|
3689 | return _this2;
|
---|
3690 | }
|
---|
3691 | /**
|
---|
3692 | * Creates the XHR object and sends the request.
|
---|
3693 | *
|
---|
3694 | * @api private
|
---|
3695 | */
|
---|
3696 |
|
---|
3697 |
|
---|
3698 | _createClass(Request, [{
|
---|
3699 | key: "create",
|
---|
3700 | value: function create() {
|
---|
3701 | var opts = pick(this.opts, "agent", "enablesXDR", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized");
|
---|
3702 | opts.xdomain = !!this.opts.xd;
|
---|
3703 | opts.xscheme = !!this.opts.xs;
|
---|
3704 | var xhr = this.xhr = new XMLHttpRequest(opts);
|
---|
3705 | var self = this;
|
---|
3706 |
|
---|
3707 | try {
|
---|
3708 | debug("xhr open %s: %s", this.method, this.uri);
|
---|
3709 | xhr.open(this.method, this.uri, this.async);
|
---|
3710 |
|
---|
3711 | try {
|
---|
3712 | if (this.opts.extraHeaders) {
|
---|
3713 | xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
|
---|
3714 |
|
---|
3715 | for (var i in this.opts.extraHeaders) {
|
---|
3716 | if (this.opts.extraHeaders.hasOwnProperty(i)) {
|
---|
3717 | xhr.setRequestHeader(i, this.opts.extraHeaders[i]);
|
---|
3718 | }
|
---|
3719 | }
|
---|
3720 | }
|
---|
3721 | } catch (e) {}
|
---|
3722 |
|
---|
3723 | if ("POST" === this.method) {
|
---|
3724 | try {
|
---|
3725 | xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
|
---|
3726 | } catch (e) {}
|
---|
3727 | }
|
---|
3728 |
|
---|
3729 | try {
|
---|
3730 | xhr.setRequestHeader("Accept", "*/*");
|
---|
3731 | } catch (e) {} // ie6 check
|
---|
3732 |
|
---|
3733 |
|
---|
3734 | if ("withCredentials" in xhr) {
|
---|
3735 | xhr.withCredentials = this.opts.withCredentials;
|
---|
3736 | }
|
---|
3737 |
|
---|
3738 | if (this.opts.requestTimeout) {
|
---|
3739 | xhr.timeout = this.opts.requestTimeout;
|
---|
3740 | }
|
---|
3741 |
|
---|
3742 | if (this.hasXDR()) {
|
---|
3743 | xhr.onload = function () {
|
---|
3744 | self.onLoad();
|
---|
3745 | };
|
---|
3746 |
|
---|
3747 | xhr.onerror = function () {
|
---|
3748 | self.onError(xhr.responseText);
|
---|
3749 | };
|
---|
3750 | } else {
|
---|
3751 | xhr.onreadystatechange = function () {
|
---|
3752 | if (4 !== xhr.readyState) return;
|
---|
3753 |
|
---|
3754 | if (200 === xhr.status || 1223 === xhr.status) {
|
---|
3755 | self.onLoad();
|
---|
3756 | } else {
|
---|
3757 | // make sure the `error` event handler that's user-set
|
---|
3758 | // does not throw in the same tick and gets caught here
|
---|
3759 | setTimeout(function () {
|
---|
3760 | self.onError(typeof xhr.status === "number" ? xhr.status : 0);
|
---|
3761 | }, 0);
|
---|
3762 | }
|
---|
3763 | };
|
---|
3764 | }
|
---|
3765 |
|
---|
3766 | debug("xhr data %s", this.data);
|
---|
3767 | xhr.send(this.data);
|
---|
3768 | } catch (e) {
|
---|
3769 | // Need to defer since .create() is called directly from the constructor
|
---|
3770 | // and thus the 'error' event can only be only bound *after* this exception
|
---|
3771 | // occurs. Therefore, also, we cannot throw here at all.
|
---|
3772 | setTimeout(function () {
|
---|
3773 | self.onError(e);
|
---|
3774 | }, 0);
|
---|
3775 | return;
|
---|
3776 | }
|
---|
3777 |
|
---|
3778 | if (typeof document !== "undefined") {
|
---|
3779 | this.index = Request.requestsCount++;
|
---|
3780 | Request.requests[this.index] = this;
|
---|
3781 | }
|
---|
3782 | }
|
---|
3783 | /**
|
---|
3784 | * Called upon successful response.
|
---|
3785 | *
|
---|
3786 | * @api private
|
---|
3787 | */
|
---|
3788 |
|
---|
3789 | }, {
|
---|
3790 | key: "onSuccess",
|
---|
3791 | value: function onSuccess() {
|
---|
3792 | this.emit("success");
|
---|
3793 | this.cleanup();
|
---|
3794 | }
|
---|
3795 | /**
|
---|
3796 | * Called if we have data.
|
---|
3797 | *
|
---|
3798 | * @api private
|
---|
3799 | */
|
---|
3800 |
|
---|
3801 | }, {
|
---|
3802 | key: "onData",
|
---|
3803 | value: function onData(data) {
|
---|
3804 | this.emit("data", data);
|
---|
3805 | this.onSuccess();
|
---|
3806 | }
|
---|
3807 | /**
|
---|
3808 | * Called upon error.
|
---|
3809 | *
|
---|
3810 | * @api private
|
---|
3811 | */
|
---|
3812 |
|
---|
3813 | }, {
|
---|
3814 | key: "onError",
|
---|
3815 | value: function onError(err) {
|
---|
3816 | this.emit("error", err);
|
---|
3817 | this.cleanup(true);
|
---|
3818 | }
|
---|
3819 | /**
|
---|
3820 | * Cleans up house.
|
---|
3821 | *
|
---|
3822 | * @api private
|
---|
3823 | */
|
---|
3824 |
|
---|
3825 | }, {
|
---|
3826 | key: "cleanup",
|
---|
3827 | value: function cleanup(fromError) {
|
---|
3828 | if ("undefined" === typeof this.xhr || null === this.xhr) {
|
---|
3829 | return;
|
---|
3830 | } // xmlhttprequest
|
---|
3831 |
|
---|
3832 |
|
---|
3833 | if (this.hasXDR()) {
|
---|
3834 | this.xhr.onload = this.xhr.onerror = empty;
|
---|
3835 | } else {
|
---|
3836 | this.xhr.onreadystatechange = empty;
|
---|
3837 | }
|
---|
3838 |
|
---|
3839 | if (fromError) {
|
---|
3840 | try {
|
---|
3841 | this.xhr.abort();
|
---|
3842 | } catch (e) {}
|
---|
3843 | }
|
---|
3844 |
|
---|
3845 | if (typeof document !== "undefined") {
|
---|
3846 | delete Request.requests[this.index];
|
---|
3847 | }
|
---|
3848 |
|
---|
3849 | this.xhr = null;
|
---|
3850 | }
|
---|
3851 | /**
|
---|
3852 | * Called upon load.
|
---|
3853 | *
|
---|
3854 | * @api private
|
---|
3855 | */
|
---|
3856 |
|
---|
3857 | }, {
|
---|
3858 | key: "onLoad",
|
---|
3859 | value: function onLoad() {
|
---|
3860 | var data = this.xhr.responseText;
|
---|
3861 |
|
---|
3862 | if (data !== null) {
|
---|
3863 | this.onData(data);
|
---|
3864 | }
|
---|
3865 | }
|
---|
3866 | /**
|
---|
3867 | * Check if it has XDomainRequest.
|
---|
3868 | *
|
---|
3869 | * @api private
|
---|
3870 | */
|
---|
3871 |
|
---|
3872 | }, {
|
---|
3873 | key: "hasXDR",
|
---|
3874 | value: function hasXDR() {
|
---|
3875 | return typeof XDomainRequest !== "undefined" && !this.xs && this.enablesXDR;
|
---|
3876 | }
|
---|
3877 | /**
|
---|
3878 | * Aborts the request.
|
---|
3879 | *
|
---|
3880 | * @api public
|
---|
3881 | */
|
---|
3882 |
|
---|
3883 | }, {
|
---|
3884 | key: "abort",
|
---|
3885 | value: function abort() {
|
---|
3886 | this.cleanup();
|
---|
3887 | }
|
---|
3888 | }]);
|
---|
3889 |
|
---|
3890 | return Request;
|
---|
3891 | }(Emitter);
|
---|
3892 | /**
|
---|
3893 | * Aborts pending requests when unloading the window. This is needed to prevent
|
---|
3894 | * memory leaks (e.g. when using IE) and to ensure that no spurious error is
|
---|
3895 | * emitted.
|
---|
3896 | */
|
---|
3897 |
|
---|
3898 |
|
---|
3899 | Request.requestsCount = 0;
|
---|
3900 | Request.requests = {};
|
---|
3901 |
|
---|
3902 | if (typeof document !== "undefined") {
|
---|
3903 | if (typeof attachEvent === "function") {
|
---|
3904 | attachEvent("onunload", unloadHandler);
|
---|
3905 | } else if (typeof addEventListener === "function") {
|
---|
3906 | var terminationEvent = "onpagehide" in globalThis ? "pagehide" : "unload";
|
---|
3907 | addEventListener(terminationEvent, unloadHandler, false);
|
---|
3908 | }
|
---|
3909 | }
|
---|
3910 |
|
---|
3911 | function unloadHandler() {
|
---|
3912 | for (var i in Request.requests) {
|
---|
3913 | if (Request.requests.hasOwnProperty(i)) {
|
---|
3914 | Request.requests[i].abort();
|
---|
3915 | }
|
---|
3916 | }
|
---|
3917 | }
|
---|
3918 |
|
---|
3919 | module.exports = XHR;
|
---|
3920 | module.exports.Request = Request;
|
---|
3921 |
|
---|
3922 | /***/ }),
|
---|
3923 |
|
---|
3924 | /***/ "./node_modules/engine.io-client/lib/transports/polling.js":
|
---|
3925 | /*!*****************************************************************!*\
|
---|
3926 | !*** ./node_modules/engine.io-client/lib/transports/polling.js ***!
|
---|
3927 | \*****************************************************************/
|
---|
3928 | /*! no static exports found */
|
---|
3929 | /***/ (function(module, exports, __webpack_require__) {
|
---|
3930 |
|
---|
3931 | 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); }
|
---|
3932 |
|
---|
3933 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
3934 |
|
---|
3935 | function _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); } }
|
---|
3936 |
|
---|
3937 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
3938 |
|
---|
3939 | function _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); }
|
---|
3940 |
|
---|
3941 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
3942 |
|
---|
3943 | function _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); }; }
|
---|
3944 |
|
---|
3945 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
3946 |
|
---|
3947 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
3948 |
|
---|
3949 | function _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; } }
|
---|
3950 |
|
---|
3951 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
3952 |
|
---|
3953 | var Transport = __webpack_require__(/*! ../transport */ "./node_modules/engine.io-client/lib/transport.js");
|
---|
3954 |
|
---|
3955 | var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
|
---|
3956 |
|
---|
3957 | var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/index.js");
|
---|
3958 |
|
---|
3959 | var yeast = __webpack_require__(/*! yeast */ "./node_modules/yeast/index.js");
|
---|
3960 |
|
---|
3961 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("engine.io-client:polling");
|
---|
3962 |
|
---|
3963 | var Polling = /*#__PURE__*/function (_Transport) {
|
---|
3964 | _inherits(Polling, _Transport);
|
---|
3965 |
|
---|
3966 | var _super = _createSuper(Polling);
|
---|
3967 |
|
---|
3968 | function Polling() {
|
---|
3969 | _classCallCheck(this, Polling);
|
---|
3970 |
|
---|
3971 | return _super.apply(this, arguments);
|
---|
3972 | }
|
---|
3973 |
|
---|
3974 | _createClass(Polling, [{
|
---|
3975 | key: "doOpen",
|
---|
3976 |
|
---|
3977 | /**
|
---|
3978 | * Opens the socket (triggers polling). We write a PING message to determine
|
---|
3979 | * when the transport is open.
|
---|
3980 | *
|
---|
3981 | * @api private
|
---|
3982 | */
|
---|
3983 | value: function doOpen() {
|
---|
3984 | this.poll();
|
---|
3985 | }
|
---|
3986 | /**
|
---|
3987 | * Pauses polling.
|
---|
3988 | *
|
---|
3989 | * @param {Function} callback upon buffers are flushed and transport is paused
|
---|
3990 | * @api private
|
---|
3991 | */
|
---|
3992 |
|
---|
3993 | }, {
|
---|
3994 | key: "pause",
|
---|
3995 | value: function pause(onPause) {
|
---|
3996 | var self = this;
|
---|
3997 | this.readyState = "pausing";
|
---|
3998 |
|
---|
3999 | function pause() {
|
---|
4000 | debug("paused");
|
---|
4001 | self.readyState = "paused";
|
---|
4002 | onPause();
|
---|
4003 | }
|
---|
4004 |
|
---|
4005 | if (this.polling || !this.writable) {
|
---|
4006 | var total = 0;
|
---|
4007 |
|
---|
4008 | if (this.polling) {
|
---|
4009 | debug("we are currently polling - waiting to pause");
|
---|
4010 | total++;
|
---|
4011 | this.once("pollComplete", function () {
|
---|
4012 | debug("pre-pause polling complete");
|
---|
4013 | --total || pause();
|
---|
4014 | });
|
---|
4015 | }
|
---|
4016 |
|
---|
4017 | if (!this.writable) {
|
---|
4018 | debug("we are currently writing - waiting to pause");
|
---|
4019 | total++;
|
---|
4020 | this.once("drain", function () {
|
---|
4021 | debug("pre-pause writing complete");
|
---|
4022 | --total || pause();
|
---|
4023 | });
|
---|
4024 | }
|
---|
4025 | } else {
|
---|
4026 | pause();
|
---|
4027 | }
|
---|
4028 | }
|
---|
4029 | /**
|
---|
4030 | * Starts polling cycle.
|
---|
4031 | *
|
---|
4032 | * @api public
|
---|
4033 | */
|
---|
4034 |
|
---|
4035 | }, {
|
---|
4036 | key: "poll",
|
---|
4037 | value: function poll() {
|
---|
4038 | debug("polling");
|
---|
4039 | this.polling = true;
|
---|
4040 | this.doPoll();
|
---|
4041 | this.emit("poll");
|
---|
4042 | }
|
---|
4043 | /**
|
---|
4044 | * Overloads onData to detect payloads.
|
---|
4045 | *
|
---|
4046 | * @api private
|
---|
4047 | */
|
---|
4048 |
|
---|
4049 | }, {
|
---|
4050 | key: "onData",
|
---|
4051 | value: function onData(data) {
|
---|
4052 | var self = this;
|
---|
4053 | debug("polling got data %s", data);
|
---|
4054 |
|
---|
4055 | var callback = function callback(packet, index, total) {
|
---|
4056 | // if its the first message we consider the transport open
|
---|
4057 | if ("opening" === self.readyState && packet.type === "open") {
|
---|
4058 | self.onOpen();
|
---|
4059 | } // if its a close packet, we close the ongoing requests
|
---|
4060 |
|
---|
4061 |
|
---|
4062 | if ("close" === packet.type) {
|
---|
4063 | self.onClose();
|
---|
4064 | return false;
|
---|
4065 | } // otherwise bypass onData and handle the message
|
---|
4066 |
|
---|
4067 |
|
---|
4068 | self.onPacket(packet);
|
---|
4069 | }; // decode payload
|
---|
4070 |
|
---|
4071 |
|
---|
4072 | parser.decodePayload(data, this.socket.binaryType).forEach(callback); // if an event did not trigger closing
|
---|
4073 |
|
---|
4074 | if ("closed" !== this.readyState) {
|
---|
4075 | // if we got data we're not polling
|
---|
4076 | this.polling = false;
|
---|
4077 | this.emit("pollComplete");
|
---|
4078 |
|
---|
4079 | if ("open" === this.readyState) {
|
---|
4080 | this.poll();
|
---|
4081 | } else {
|
---|
4082 | debug('ignoring poll - transport state "%s"', this.readyState);
|
---|
4083 | }
|
---|
4084 | }
|
---|
4085 | }
|
---|
4086 | /**
|
---|
4087 | * For polling, send a close packet.
|
---|
4088 | *
|
---|
4089 | * @api private
|
---|
4090 | */
|
---|
4091 |
|
---|
4092 | }, {
|
---|
4093 | key: "doClose",
|
---|
4094 | value: function doClose() {
|
---|
4095 | var self = this;
|
---|
4096 |
|
---|
4097 | function close() {
|
---|
4098 | debug("writing close packet");
|
---|
4099 | self.write([{
|
---|
4100 | type: "close"
|
---|
4101 | }]);
|
---|
4102 | }
|
---|
4103 |
|
---|
4104 | if ("open" === this.readyState) {
|
---|
4105 | debug("transport open - closing");
|
---|
4106 | close();
|
---|
4107 | } else {
|
---|
4108 | // in case we're trying to close while
|
---|
4109 | // handshaking is in progress (GH-164)
|
---|
4110 | debug("transport not open - deferring close");
|
---|
4111 | this.once("open", close);
|
---|
4112 | }
|
---|
4113 | }
|
---|
4114 | /**
|
---|
4115 | * Writes a packets payload.
|
---|
4116 | *
|
---|
4117 | * @param {Array} data packets
|
---|
4118 | * @param {Function} drain callback
|
---|
4119 | * @api private
|
---|
4120 | */
|
---|
4121 |
|
---|
4122 | }, {
|
---|
4123 | key: "write",
|
---|
4124 | value: function write(packets) {
|
---|
4125 | var _this = this;
|
---|
4126 |
|
---|
4127 | this.writable = false;
|
---|
4128 | parser.encodePayload(packets, function (data) {
|
---|
4129 | _this.doWrite(data, function () {
|
---|
4130 | _this.writable = true;
|
---|
4131 |
|
---|
4132 | _this.emit("drain");
|
---|
4133 | });
|
---|
4134 | });
|
---|
4135 | }
|
---|
4136 | /**
|
---|
4137 | * Generates uri for connection.
|
---|
4138 | *
|
---|
4139 | * @api private
|
---|
4140 | */
|
---|
4141 |
|
---|
4142 | }, {
|
---|
4143 | key: "uri",
|
---|
4144 | value: function uri() {
|
---|
4145 | var query = this.query || {};
|
---|
4146 | var schema = this.opts.secure ? "https" : "http";
|
---|
4147 | var port = ""; // cache busting is forced
|
---|
4148 |
|
---|
4149 | if (false !== this.opts.timestampRequests) {
|
---|
4150 | query[this.opts.timestampParam] = yeast();
|
---|
4151 | }
|
---|
4152 |
|
---|
4153 | if (!this.supportsBinary && !query.sid) {
|
---|
4154 | query.b64 = 1;
|
---|
4155 | }
|
---|
4156 |
|
---|
4157 | query = parseqs.encode(query); // avoid port if default for schema
|
---|
4158 |
|
---|
4159 | if (this.opts.port && ("https" === schema && Number(this.opts.port) !== 443 || "http" === schema && Number(this.opts.port) !== 80)) {
|
---|
4160 | port = ":" + this.opts.port;
|
---|
4161 | } // prepend ? to query
|
---|
4162 |
|
---|
4163 |
|
---|
4164 | if (query.length) {
|
---|
4165 | query = "?" + query;
|
---|
4166 | }
|
---|
4167 |
|
---|
4168 | var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
---|
4169 | return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + query;
|
---|
4170 | }
|
---|
4171 | }, {
|
---|
4172 | key: "name",
|
---|
4173 |
|
---|
4174 | /**
|
---|
4175 | * Transport name.
|
---|
4176 | */
|
---|
4177 | get: function get() {
|
---|
4178 | return "polling";
|
---|
4179 | }
|
---|
4180 | }]);
|
---|
4181 |
|
---|
4182 | return Polling;
|
---|
4183 | }(Transport);
|
---|
4184 |
|
---|
4185 | module.exports = Polling;
|
---|
4186 |
|
---|
4187 | /***/ }),
|
---|
4188 |
|
---|
4189 | /***/ "./node_modules/engine.io-client/lib/transports/websocket-constructor.browser.js":
|
---|
4190 | /*!***************************************************************************************!*\
|
---|
4191 | !*** ./node_modules/engine.io-client/lib/transports/websocket-constructor.browser.js ***!
|
---|
4192 | \***************************************************************************************/
|
---|
4193 | /*! no static exports found */
|
---|
4194 | /***/ (function(module, exports, __webpack_require__) {
|
---|
4195 |
|
---|
4196 | var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
---|
4197 |
|
---|
4198 | module.exports = {
|
---|
4199 | WebSocket: globalThis.WebSocket || globalThis.MozWebSocket,
|
---|
4200 | usingBrowserWebSocket: true,
|
---|
4201 | defaultBinaryType: "arraybuffer"
|
---|
4202 | };
|
---|
4203 |
|
---|
4204 | /***/ }),
|
---|
4205 |
|
---|
4206 | /***/ "./node_modules/engine.io-client/lib/transports/websocket.js":
|
---|
4207 | /*!*******************************************************************!*\
|
---|
4208 | !*** ./node_modules/engine.io-client/lib/transports/websocket.js ***!
|
---|
4209 | \*******************************************************************/
|
---|
4210 | /*! no static exports found */
|
---|
4211 | /***/ (function(module, exports, __webpack_require__) {
|
---|
4212 |
|
---|
4213 | 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); }
|
---|
4214 |
|
---|
4215 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
4216 |
|
---|
4217 | function _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); } }
|
---|
4218 |
|
---|
4219 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
4220 |
|
---|
4221 | function _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); }
|
---|
4222 |
|
---|
4223 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
4224 |
|
---|
4225 | function _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); }; }
|
---|
4226 |
|
---|
4227 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
4228 |
|
---|
4229 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
4230 |
|
---|
4231 | function _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; } }
|
---|
4232 |
|
---|
4233 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
4234 |
|
---|
4235 | var Transport = __webpack_require__(/*! ../transport */ "./node_modules/engine.io-client/lib/transport.js");
|
---|
4236 |
|
---|
4237 | var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/index.js");
|
---|
4238 |
|
---|
4239 | var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
|
---|
4240 |
|
---|
4241 | var yeast = __webpack_require__(/*! yeast */ "./node_modules/yeast/index.js");
|
---|
4242 |
|
---|
4243 | var _require = __webpack_require__(/*! ../util */ "./node_modules/engine.io-client/lib/util.js"),
|
---|
4244 | pick = _require.pick;
|
---|
4245 |
|
---|
4246 | var _require2 = __webpack_require__(/*! ./websocket-constructor */ "./node_modules/engine.io-client/lib/transports/websocket-constructor.browser.js"),
|
---|
4247 | WebSocket = _require2.WebSocket,
|
---|
4248 | usingBrowserWebSocket = _require2.usingBrowserWebSocket,
|
---|
4249 | defaultBinaryType = _require2.defaultBinaryType;
|
---|
4250 |
|
---|
4251 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("engine.io-client:websocket"); // detect ReactNative environment
|
---|
4252 |
|
---|
4253 |
|
---|
4254 | var isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
|
---|
4255 |
|
---|
4256 | var WS = /*#__PURE__*/function (_Transport) {
|
---|
4257 | _inherits(WS, _Transport);
|
---|
4258 |
|
---|
4259 | var _super = _createSuper(WS);
|
---|
4260 |
|
---|
4261 | /**
|
---|
4262 | * WebSocket transport constructor.
|
---|
4263 | *
|
---|
4264 | * @api {Object} connection options
|
---|
4265 | * @api public
|
---|
4266 | */
|
---|
4267 | function WS(opts) {
|
---|
4268 | var _this;
|
---|
4269 |
|
---|
4270 | _classCallCheck(this, WS);
|
---|
4271 |
|
---|
4272 | _this = _super.call(this, opts);
|
---|
4273 | _this.supportsBinary = !opts.forceBase64;
|
---|
4274 | return _this;
|
---|
4275 | }
|
---|
4276 | /**
|
---|
4277 | * Transport name.
|
---|
4278 | *
|
---|
4279 | * @api public
|
---|
4280 | */
|
---|
4281 |
|
---|
4282 |
|
---|
4283 | _createClass(WS, [{
|
---|
4284 | key: "doOpen",
|
---|
4285 |
|
---|
4286 | /**
|
---|
4287 | * Opens socket.
|
---|
4288 | *
|
---|
4289 | * @api private
|
---|
4290 | */
|
---|
4291 | value: function doOpen() {
|
---|
4292 | if (!this.check()) {
|
---|
4293 | // let probe timeout
|
---|
4294 | return;
|
---|
4295 | }
|
---|
4296 |
|
---|
4297 | var uri = this.uri();
|
---|
4298 | var protocols = this.opts.protocols; // React Native only supports the 'headers' option, and will print a warning if anything else is passed
|
---|
4299 |
|
---|
4300 | var opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
---|
4301 |
|
---|
4302 | if (this.opts.extraHeaders) {
|
---|
4303 | opts.headers = this.opts.extraHeaders;
|
---|
4304 | }
|
---|
4305 |
|
---|
4306 | try {
|
---|
4307 | this.ws = usingBrowserWebSocket && !isReactNative ? protocols ? new WebSocket(uri, protocols) : new WebSocket(uri) : new WebSocket(uri, protocols, opts);
|
---|
4308 | } catch (err) {
|
---|
4309 | return this.emit("error", err);
|
---|
4310 | }
|
---|
4311 |
|
---|
4312 | this.ws.binaryType = this.socket.binaryType || defaultBinaryType;
|
---|
4313 | this.addEventListeners();
|
---|
4314 | }
|
---|
4315 | /**
|
---|
4316 | * Adds event listeners to the socket
|
---|
4317 | *
|
---|
4318 | * @api private
|
---|
4319 | */
|
---|
4320 |
|
---|
4321 | }, {
|
---|
4322 | key: "addEventListeners",
|
---|
4323 | value: function addEventListeners() {
|
---|
4324 | var self = this;
|
---|
4325 |
|
---|
4326 | this.ws.onopen = function () {
|
---|
4327 | self.onOpen();
|
---|
4328 | };
|
---|
4329 |
|
---|
4330 | this.ws.onclose = function () {
|
---|
4331 | self.onClose();
|
---|
4332 | };
|
---|
4333 |
|
---|
4334 | this.ws.onmessage = function (ev) {
|
---|
4335 | self.onData(ev.data);
|
---|
4336 | };
|
---|
4337 |
|
---|
4338 | this.ws.onerror = function (e) {
|
---|
4339 | self.onError("websocket error", e);
|
---|
4340 | };
|
---|
4341 | }
|
---|
4342 | /**
|
---|
4343 | * Writes data to socket.
|
---|
4344 | *
|
---|
4345 | * @param {Array} array of packets.
|
---|
4346 | * @api private
|
---|
4347 | */
|
---|
4348 |
|
---|
4349 | }, {
|
---|
4350 | key: "write",
|
---|
4351 | value: function write(packets) {
|
---|
4352 | var self = this;
|
---|
4353 | this.writable = false; // encodePacket efficient as it uses WS framing
|
---|
4354 | // no need for encodePayload
|
---|
4355 |
|
---|
4356 | var total = packets.length;
|
---|
4357 | var i = 0;
|
---|
4358 | var l = total;
|
---|
4359 |
|
---|
4360 | for (; i < l; i++) {
|
---|
4361 | (function (packet) {
|
---|
4362 | parser.encodePacket(packet, self.supportsBinary, function (data) {
|
---|
4363 | // always create a new object (GH-437)
|
---|
4364 | var opts = {};
|
---|
4365 |
|
---|
4366 | if (!usingBrowserWebSocket) {
|
---|
4367 | if (packet.options) {
|
---|
4368 | opts.compress = packet.options.compress;
|
---|
4369 | }
|
---|
4370 |
|
---|
4371 | if (self.opts.perMessageDeflate) {
|
---|
4372 | var len = "string" === typeof data ? Buffer.byteLength(data) : data.length;
|
---|
4373 |
|
---|
4374 | if (len < self.opts.perMessageDeflate.threshold) {
|
---|
4375 | opts.compress = false;
|
---|
4376 | }
|
---|
4377 | }
|
---|
4378 | } // Sometimes the websocket has already been closed but the browser didn't
|
---|
4379 | // have a chance of informing us about it yet, in that case send will
|
---|
4380 | // throw an error
|
---|
4381 |
|
---|
4382 |
|
---|
4383 | try {
|
---|
4384 | if (usingBrowserWebSocket) {
|
---|
4385 | // TypeError is thrown when passing the second argument on Safari
|
---|
4386 | self.ws.send(data);
|
---|
4387 | } else {
|
---|
4388 | self.ws.send(data, opts);
|
---|
4389 | }
|
---|
4390 | } catch (e) {
|
---|
4391 | debug("websocket closed before onclose event");
|
---|
4392 | }
|
---|
4393 |
|
---|
4394 | --total || done();
|
---|
4395 | });
|
---|
4396 | })(packets[i]);
|
---|
4397 | }
|
---|
4398 |
|
---|
4399 | function done() {
|
---|
4400 | self.emit("flush"); // fake drain
|
---|
4401 | // defer to next tick to allow Socket to clear writeBuffer
|
---|
4402 |
|
---|
4403 | setTimeout(function () {
|
---|
4404 | self.writable = true;
|
---|
4405 | self.emit("drain");
|
---|
4406 | }, 0);
|
---|
4407 | }
|
---|
4408 | }
|
---|
4409 | /**
|
---|
4410 | * Called upon close
|
---|
4411 | *
|
---|
4412 | * @api private
|
---|
4413 | */
|
---|
4414 |
|
---|
4415 | }, {
|
---|
4416 | key: "onClose",
|
---|
4417 | value: function onClose() {
|
---|
4418 | Transport.prototype.onClose.call(this);
|
---|
4419 | }
|
---|
4420 | /**
|
---|
4421 | * Closes socket.
|
---|
4422 | *
|
---|
4423 | * @api private
|
---|
4424 | */
|
---|
4425 |
|
---|
4426 | }, {
|
---|
4427 | key: "doClose",
|
---|
4428 | value: function doClose() {
|
---|
4429 | if (typeof this.ws !== "undefined") {
|
---|
4430 | this.ws.close();
|
---|
4431 | this.ws = null;
|
---|
4432 | }
|
---|
4433 | }
|
---|
4434 | /**
|
---|
4435 | * Generates uri for connection.
|
---|
4436 | *
|
---|
4437 | * @api private
|
---|
4438 | */
|
---|
4439 |
|
---|
4440 | }, {
|
---|
4441 | key: "uri",
|
---|
4442 | value: function uri() {
|
---|
4443 | var query = this.query || {};
|
---|
4444 | var schema = this.opts.secure ? "wss" : "ws";
|
---|
4445 | var port = ""; // avoid port if default for schema
|
---|
4446 |
|
---|
4447 | if (this.opts.port && ("wss" === schema && Number(this.opts.port) !== 443 || "ws" === schema && Number(this.opts.port) !== 80)) {
|
---|
4448 | port = ":" + this.opts.port;
|
---|
4449 | } // append timestamp to URI
|
---|
4450 |
|
---|
4451 |
|
---|
4452 | if (this.opts.timestampRequests) {
|
---|
4453 | query[this.opts.timestampParam] = yeast();
|
---|
4454 | } // communicate binary support capabilities
|
---|
4455 |
|
---|
4456 |
|
---|
4457 | if (!this.supportsBinary) {
|
---|
4458 | query.b64 = 1;
|
---|
4459 | }
|
---|
4460 |
|
---|
4461 | query = parseqs.encode(query); // prepend ? to query
|
---|
4462 |
|
---|
4463 | if (query.length) {
|
---|
4464 | query = "?" + query;
|
---|
4465 | }
|
---|
4466 |
|
---|
4467 | var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
---|
4468 | return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + query;
|
---|
4469 | }
|
---|
4470 | /**
|
---|
4471 | * Feature detection for WebSocket.
|
---|
4472 | *
|
---|
4473 | * @return {Boolean} whether this transport is available.
|
---|
4474 | * @api public
|
---|
4475 | */
|
---|
4476 |
|
---|
4477 | }, {
|
---|
4478 | key: "check",
|
---|
4479 | value: function check() {
|
---|
4480 | return !!WebSocket && !("__initialize" in WebSocket && this.name === WS.prototype.name);
|
---|
4481 | }
|
---|
4482 | }, {
|
---|
4483 | key: "name",
|
---|
4484 | get: function get() {
|
---|
4485 | return "websocket";
|
---|
4486 | }
|
---|
4487 | }]);
|
---|
4488 |
|
---|
4489 | return WS;
|
---|
4490 | }(Transport);
|
---|
4491 |
|
---|
4492 | module.exports = WS;
|
---|
4493 |
|
---|
4494 | /***/ }),
|
---|
4495 |
|
---|
4496 | /***/ "./node_modules/engine.io-client/lib/util.js":
|
---|
4497 | /*!***************************************************!*\
|
---|
4498 | !*** ./node_modules/engine.io-client/lib/util.js ***!
|
---|
4499 | \***************************************************/
|
---|
4500 | /*! no static exports found */
|
---|
4501 | /***/ (function(module, exports) {
|
---|
4502 |
|
---|
4503 | module.exports.pick = function (obj) {
|
---|
4504 | for (var _len = arguments.length, attr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
---|
4505 | attr[_key - 1] = arguments[_key];
|
---|
4506 | }
|
---|
4507 |
|
---|
4508 | return attr.reduce(function (acc, k) {
|
---|
4509 | if (obj.hasOwnProperty(k)) {
|
---|
4510 | acc[k] = obj[k];
|
---|
4511 | }
|
---|
4512 |
|
---|
4513 | return acc;
|
---|
4514 | }, {});
|
---|
4515 | };
|
---|
4516 |
|
---|
4517 | /***/ }),
|
---|
4518 |
|
---|
4519 | /***/ "./node_modules/engine.io-client/lib/xmlhttprequest.js":
|
---|
4520 | /*!*************************************************************!*\
|
---|
4521 | !*** ./node_modules/engine.io-client/lib/xmlhttprequest.js ***!
|
---|
4522 | \*************************************************************/
|
---|
4523 | /*! no static exports found */
|
---|
4524 | /***/ (function(module, exports, __webpack_require__) {
|
---|
4525 |
|
---|
4526 | // browser shim for xmlhttprequest module
|
---|
4527 | var hasCORS = __webpack_require__(/*! has-cors */ "./node_modules/has-cors/index.js");
|
---|
4528 |
|
---|
4529 | var globalThis = __webpack_require__(/*! ./globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
---|
4530 |
|
---|
4531 | module.exports = function (opts) {
|
---|
4532 | var xdomain = opts.xdomain; // scheme must be same when usign XDomainRequest
|
---|
4533 | // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
|
---|
4534 |
|
---|
4535 | var xscheme = opts.xscheme; // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
|
---|
4536 | // https://github.com/Automattic/engine.io-client/pull/217
|
---|
4537 |
|
---|
4538 | var enablesXDR = opts.enablesXDR; // XMLHttpRequest can be disabled on IE
|
---|
4539 |
|
---|
4540 | try {
|
---|
4541 | if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
---|
4542 | return new XMLHttpRequest();
|
---|
4543 | }
|
---|
4544 | } catch (e) {} // Use XDomainRequest for IE8 if enablesXDR is true
|
---|
4545 | // because loading bar keeps flashing when using jsonp-polling
|
---|
4546 | // https://github.com/yujiosaka/socke.io-ie8-loading-example
|
---|
4547 |
|
---|
4548 |
|
---|
4549 | try {
|
---|
4550 | if ("undefined" !== typeof XDomainRequest && !xscheme && enablesXDR) {
|
---|
4551 | return new XDomainRequest();
|
---|
4552 | }
|
---|
4553 | } catch (e) {}
|
---|
4554 |
|
---|
4555 | if (!xdomain) {
|
---|
4556 | try {
|
---|
4557 | return new globalThis[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
---|
4558 | } catch (e) {}
|
---|
4559 | }
|
---|
4560 | };
|
---|
4561 |
|
---|
4562 | /***/ }),
|
---|
4563 |
|
---|
4564 | /***/ "./node_modules/engine.io-parser/lib/commons.js":
|
---|
4565 | /*!******************************************************!*\
|
---|
4566 | !*** ./node_modules/engine.io-parser/lib/commons.js ***!
|
---|
4567 | \******************************************************/
|
---|
4568 | /*! no static exports found */
|
---|
4569 | /***/ (function(module, exports) {
|
---|
4570 |
|
---|
4571 | var PACKET_TYPES = Object.create(null); // no Map = no polyfill
|
---|
4572 |
|
---|
4573 | PACKET_TYPES["open"] = "0";
|
---|
4574 | PACKET_TYPES["close"] = "1";
|
---|
4575 | PACKET_TYPES["ping"] = "2";
|
---|
4576 | PACKET_TYPES["pong"] = "3";
|
---|
4577 | PACKET_TYPES["message"] = "4";
|
---|
4578 | PACKET_TYPES["upgrade"] = "5";
|
---|
4579 | PACKET_TYPES["noop"] = "6";
|
---|
4580 | var PACKET_TYPES_REVERSE = Object.create(null);
|
---|
4581 | Object.keys(PACKET_TYPES).forEach(function (key) {
|
---|
4582 | PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
|
---|
4583 | });
|
---|
4584 | var ERROR_PACKET = {
|
---|
4585 | type: "error",
|
---|
4586 | data: "parser error"
|
---|
4587 | };
|
---|
4588 | module.exports = {
|
---|
4589 | PACKET_TYPES: PACKET_TYPES,
|
---|
4590 | PACKET_TYPES_REVERSE: PACKET_TYPES_REVERSE,
|
---|
4591 | ERROR_PACKET: ERROR_PACKET
|
---|
4592 | };
|
---|
4593 |
|
---|
4594 | /***/ }),
|
---|
4595 |
|
---|
4596 | /***/ "./node_modules/engine.io-parser/lib/decodePacket.browser.js":
|
---|
4597 | /*!*******************************************************************!*\
|
---|
4598 | !*** ./node_modules/engine.io-parser/lib/decodePacket.browser.js ***!
|
---|
4599 | \*******************************************************************/
|
---|
4600 | /*! no static exports found */
|
---|
4601 | /***/ (function(module, exports, __webpack_require__) {
|
---|
4602 |
|
---|
4603 | var _require = __webpack_require__(/*! ./commons */ "./node_modules/engine.io-parser/lib/commons.js"),
|
---|
4604 | PACKET_TYPES_REVERSE = _require.PACKET_TYPES_REVERSE,
|
---|
4605 | ERROR_PACKET = _require.ERROR_PACKET;
|
---|
4606 |
|
---|
4607 | var withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
---|
4608 | var base64decoder;
|
---|
4609 |
|
---|
4610 | if (withNativeArrayBuffer) {
|
---|
4611 | base64decoder = __webpack_require__(/*! base64-arraybuffer */ "./node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js");
|
---|
4612 | }
|
---|
4613 |
|
---|
4614 | var decodePacket = function decodePacket(encodedPacket, binaryType) {
|
---|
4615 | if (typeof encodedPacket !== "string") {
|
---|
4616 | return {
|
---|
4617 | type: "message",
|
---|
4618 | data: mapBinary(encodedPacket, binaryType)
|
---|
4619 | };
|
---|
4620 | }
|
---|
4621 |
|
---|
4622 | var type = encodedPacket.charAt(0);
|
---|
4623 |
|
---|
4624 | if (type === "b") {
|
---|
4625 | return {
|
---|
4626 | type: "message",
|
---|
4627 | data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
|
---|
4628 | };
|
---|
4629 | }
|
---|
4630 |
|
---|
4631 | var packetType = PACKET_TYPES_REVERSE[type];
|
---|
4632 |
|
---|
4633 | if (!packetType) {
|
---|
4634 | return ERROR_PACKET;
|
---|
4635 | }
|
---|
4636 |
|
---|
4637 | return encodedPacket.length > 1 ? {
|
---|
4638 | type: PACKET_TYPES_REVERSE[type],
|
---|
4639 | data: encodedPacket.substring(1)
|
---|
4640 | } : {
|
---|
4641 | type: PACKET_TYPES_REVERSE[type]
|
---|
4642 | };
|
---|
4643 | };
|
---|
4644 |
|
---|
4645 | var decodeBase64Packet = function decodeBase64Packet(data, binaryType) {
|
---|
4646 | if (base64decoder) {
|
---|
4647 | var decoded = base64decoder.decode(data);
|
---|
4648 | return mapBinary(decoded, binaryType);
|
---|
4649 | } else {
|
---|
4650 | return {
|
---|
4651 | base64: true,
|
---|
4652 | data: data
|
---|
4653 | }; // fallback for old browsers
|
---|
4654 | }
|
---|
4655 | };
|
---|
4656 |
|
---|
4657 | var mapBinary = function mapBinary(data, binaryType) {
|
---|
4658 | switch (binaryType) {
|
---|
4659 | case "blob":
|
---|
4660 | return data instanceof ArrayBuffer ? new Blob([data]) : data;
|
---|
4661 |
|
---|
4662 | case "arraybuffer":
|
---|
4663 | default:
|
---|
4664 | return data;
|
---|
4665 | // assuming the data is already an ArrayBuffer
|
---|
4666 | }
|
---|
4667 | };
|
---|
4668 |
|
---|
4669 | module.exports = decodePacket;
|
---|
4670 |
|
---|
4671 | /***/ }),
|
---|
4672 |
|
---|
4673 | /***/ "./node_modules/engine.io-parser/lib/encodePacket.browser.js":
|
---|
4674 | /*!*******************************************************************!*\
|
---|
4675 | !*** ./node_modules/engine.io-parser/lib/encodePacket.browser.js ***!
|
---|
4676 | \*******************************************************************/
|
---|
4677 | /*! no static exports found */
|
---|
4678 | /***/ (function(module, exports, __webpack_require__) {
|
---|
4679 |
|
---|
4680 | var _require = __webpack_require__(/*! ./commons */ "./node_modules/engine.io-parser/lib/commons.js"),
|
---|
4681 | PACKET_TYPES = _require.PACKET_TYPES;
|
---|
4682 |
|
---|
4683 | var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]";
|
---|
4684 | var withNativeArrayBuffer = typeof ArrayBuffer === "function"; // ArrayBuffer.isView method is not defined in IE10
|
---|
4685 |
|
---|
4686 | var isView = function isView(obj) {
|
---|
4687 | return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer;
|
---|
4688 | };
|
---|
4689 |
|
---|
4690 | var encodePacket = function encodePacket(_ref, supportsBinary, callback) {
|
---|
4691 | var type = _ref.type,
|
---|
4692 | data = _ref.data;
|
---|
4693 |
|
---|
4694 | if (withNativeBlob && data instanceof Blob) {
|
---|
4695 | if (supportsBinary) {
|
---|
4696 | return callback(data);
|
---|
4697 | } else {
|
---|
4698 | return encodeBlobAsBase64(data, callback);
|
---|
4699 | }
|
---|
4700 | } else if (withNativeArrayBuffer && (data instanceof ArrayBuffer || isView(data))) {
|
---|
4701 | if (supportsBinary) {
|
---|
4702 | return callback(data instanceof ArrayBuffer ? data : data.buffer);
|
---|
4703 | } else {
|
---|
4704 | return encodeBlobAsBase64(new Blob([data]), callback);
|
---|
4705 | }
|
---|
4706 | } // plain string
|
---|
4707 |
|
---|
4708 |
|
---|
4709 | return callback(PACKET_TYPES[type] + (data || ""));
|
---|
4710 | };
|
---|
4711 |
|
---|
4712 | var encodeBlobAsBase64 = function encodeBlobAsBase64(data, callback) {
|
---|
4713 | var fileReader = new FileReader();
|
---|
4714 |
|
---|
4715 | fileReader.onload = function () {
|
---|
4716 | var content = fileReader.result.split(",")[1];
|
---|
4717 | callback("b" + content);
|
---|
4718 | };
|
---|
4719 |
|
---|
4720 | return fileReader.readAsDataURL(data);
|
---|
4721 | };
|
---|
4722 |
|
---|
4723 | module.exports = encodePacket;
|
---|
4724 |
|
---|
4725 | /***/ }),
|
---|
4726 |
|
---|
4727 | /***/ "./node_modules/engine.io-parser/lib/index.js":
|
---|
4728 | /*!****************************************************!*\
|
---|
4729 | !*** ./node_modules/engine.io-parser/lib/index.js ***!
|
---|
4730 | \****************************************************/
|
---|
4731 | /*! no static exports found */
|
---|
4732 | /***/ (function(module, exports, __webpack_require__) {
|
---|
4733 |
|
---|
4734 | var encodePacket = __webpack_require__(/*! ./encodePacket */ "./node_modules/engine.io-parser/lib/encodePacket.browser.js");
|
---|
4735 |
|
---|
4736 | var decodePacket = __webpack_require__(/*! ./decodePacket */ "./node_modules/engine.io-parser/lib/decodePacket.browser.js");
|
---|
4737 |
|
---|
4738 | var SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
|
---|
4739 |
|
---|
4740 | var encodePayload = function encodePayload(packets, callback) {
|
---|
4741 | // some packets may be added to the array while encoding, so the initial length must be saved
|
---|
4742 | var length = packets.length;
|
---|
4743 | var encodedPackets = new Array(length);
|
---|
4744 | var count = 0;
|
---|
4745 | packets.forEach(function (packet, i) {
|
---|
4746 | // force base64 encoding for binary packets
|
---|
4747 | encodePacket(packet, false, function (encodedPacket) {
|
---|
4748 | encodedPackets[i] = encodedPacket;
|
---|
4749 |
|
---|
4750 | if (++count === length) {
|
---|
4751 | callback(encodedPackets.join(SEPARATOR));
|
---|
4752 | }
|
---|
4753 | });
|
---|
4754 | });
|
---|
4755 | };
|
---|
4756 |
|
---|
4757 | var decodePayload = function decodePayload(encodedPayload, binaryType) {
|
---|
4758 | var encodedPackets = encodedPayload.split(SEPARATOR);
|
---|
4759 | var packets = [];
|
---|
4760 |
|
---|
4761 | for (var i = 0; i < encodedPackets.length; i++) {
|
---|
4762 | var decodedPacket = decodePacket(encodedPackets[i], binaryType);
|
---|
4763 | packets.push(decodedPacket);
|
---|
4764 |
|
---|
4765 | if (decodedPacket.type === "error") {
|
---|
4766 | break;
|
---|
4767 | }
|
---|
4768 | }
|
---|
4769 |
|
---|
4770 | return packets;
|
---|
4771 | };
|
---|
4772 |
|
---|
4773 | module.exports = {
|
---|
4774 | protocol: 4,
|
---|
4775 | encodePacket: encodePacket,
|
---|
4776 | encodePayload: encodePayload,
|
---|
4777 | decodePacket: decodePacket,
|
---|
4778 | decodePayload: decodePayload
|
---|
4779 | };
|
---|
4780 |
|
---|
4781 | /***/ }),
|
---|
4782 |
|
---|
4783 | /***/ "./node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js":
|
---|
4784 | /*!*************************************************************************************************!*\
|
---|
4785 | !*** ./node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js ***!
|
---|
4786 | \*************************************************************************************************/
|
---|
4787 | /*! no static exports found */
|
---|
4788 | /***/ (function(module, exports) {
|
---|
4789 |
|
---|
4790 | /*
|
---|
4791 | * base64-arraybuffer
|
---|
4792 | * https://github.com/niklasvh/base64-arraybuffer
|
---|
4793 | *
|
---|
4794 | * Copyright (c) 2012 Niklas von Hertzen
|
---|
4795 | * Licensed under the MIT license.
|
---|
4796 | */
|
---|
4797 | (function (chars) {
|
---|
4798 | "use strict";
|
---|
4799 |
|
---|
4800 | exports.encode = function (arraybuffer) {
|
---|
4801 | var bytes = new Uint8Array(arraybuffer),
|
---|
4802 | i,
|
---|
4803 | len = bytes.length,
|
---|
4804 | base64 = "";
|
---|
4805 |
|
---|
4806 | for (i = 0; i < len; i += 3) {
|
---|
4807 | base64 += chars[bytes[i] >> 2];
|
---|
4808 | base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
|
---|
4809 | base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
|
---|
4810 | base64 += chars[bytes[i + 2] & 63];
|
---|
4811 | }
|
---|
4812 |
|
---|
4813 | if (len % 3 === 2) {
|
---|
4814 | base64 = base64.substring(0, base64.length - 1) + "=";
|
---|
4815 | } else if (len % 3 === 1) {
|
---|
4816 | base64 = base64.substring(0, base64.length - 2) + "==";
|
---|
4817 | }
|
---|
4818 |
|
---|
4819 | return base64;
|
---|
4820 | };
|
---|
4821 |
|
---|
4822 | exports.decode = function (base64) {
|
---|
4823 | var bufferLength = base64.length * 0.75,
|
---|
4824 | len = base64.length,
|
---|
4825 | i,
|
---|
4826 | p = 0,
|
---|
4827 | encoded1,
|
---|
4828 | encoded2,
|
---|
4829 | encoded3,
|
---|
4830 | encoded4;
|
---|
4831 |
|
---|
4832 | if (base64[base64.length - 1] === "=") {
|
---|
4833 | bufferLength--;
|
---|
4834 |
|
---|
4835 | if (base64[base64.length - 2] === "=") {
|
---|
4836 | bufferLength--;
|
---|
4837 | }
|
---|
4838 | }
|
---|
4839 |
|
---|
4840 | var arraybuffer = new ArrayBuffer(bufferLength),
|
---|
4841 | bytes = new Uint8Array(arraybuffer);
|
---|
4842 |
|
---|
4843 | for (i = 0; i < len; i += 4) {
|
---|
4844 | encoded1 = chars.indexOf(base64[i]);
|
---|
4845 | encoded2 = chars.indexOf(base64[i + 1]);
|
---|
4846 | encoded3 = chars.indexOf(base64[i + 2]);
|
---|
4847 | encoded4 = chars.indexOf(base64[i + 3]);
|
---|
4848 | bytes[p++] = encoded1 << 2 | encoded2 >> 4;
|
---|
4849 | bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
---|
4850 | bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
---|
4851 | }
|
---|
4852 |
|
---|
4853 | return arraybuffer;
|
---|
4854 | };
|
---|
4855 | })("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
---|
4856 |
|
---|
4857 | /***/ }),
|
---|
4858 |
|
---|
4859 | /***/ "./node_modules/has-cors/index.js":
|
---|
4860 | /*!****************************************!*\
|
---|
4861 | !*** ./node_modules/has-cors/index.js ***!
|
---|
4862 | \****************************************/
|
---|
4863 | /*! no static exports found */
|
---|
4864 | /***/ (function(module, exports) {
|
---|
4865 |
|
---|
4866 | /**
|
---|
4867 | * Module exports.
|
---|
4868 | *
|
---|
4869 | * Logic borrowed from Modernizr:
|
---|
4870 | *
|
---|
4871 | * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
|
---|
4872 | */
|
---|
4873 | try {
|
---|
4874 | module.exports = typeof XMLHttpRequest !== 'undefined' && 'withCredentials' in new XMLHttpRequest();
|
---|
4875 | } catch (err) {
|
---|
4876 | // if XMLHttp support is disabled in IE then it will throw
|
---|
4877 | // when trying to create
|
---|
4878 | module.exports = false;
|
---|
4879 | }
|
---|
4880 |
|
---|
4881 | /***/ }),
|
---|
4882 |
|
---|
4883 | /***/ "./node_modules/ms/index.js":
|
---|
4884 | /*!**********************************!*\
|
---|
4885 | !*** ./node_modules/ms/index.js ***!
|
---|
4886 | \**********************************/
|
---|
4887 | /*! no static exports found */
|
---|
4888 | /***/ (function(module, exports) {
|
---|
4889 |
|
---|
4890 | 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); }
|
---|
4891 |
|
---|
4892 | /**
|
---|
4893 | * Helpers.
|
---|
4894 | */
|
---|
4895 | var s = 1000;
|
---|
4896 | var m = s * 60;
|
---|
4897 | var h = m * 60;
|
---|
4898 | var d = h * 24;
|
---|
4899 | var w = d * 7;
|
---|
4900 | var y = d * 365.25;
|
---|
4901 | /**
|
---|
4902 | * Parse or format the given `val`.
|
---|
4903 | *
|
---|
4904 | * Options:
|
---|
4905 | *
|
---|
4906 | * - `long` verbose formatting [false]
|
---|
4907 | *
|
---|
4908 | * @param {String|Number} val
|
---|
4909 | * @param {Object} [options]
|
---|
4910 | * @throws {Error} throw an error if val is not a non-empty string or a number
|
---|
4911 | * @return {String|Number}
|
---|
4912 | * @api public
|
---|
4913 | */
|
---|
4914 |
|
---|
4915 | module.exports = function (val, options) {
|
---|
4916 | options = options || {};
|
---|
4917 |
|
---|
4918 | var type = _typeof(val);
|
---|
4919 |
|
---|
4920 | if (type === 'string' && val.length > 0) {
|
---|
4921 | return parse(val);
|
---|
4922 | } else if (type === 'number' && isFinite(val)) {
|
---|
4923 | return options["long"] ? fmtLong(val) : fmtShort(val);
|
---|
4924 | }
|
---|
4925 |
|
---|
4926 | throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
---|
4927 | };
|
---|
4928 | /**
|
---|
4929 | * Parse the given `str` and return milliseconds.
|
---|
4930 | *
|
---|
4931 | * @param {String} str
|
---|
4932 | * @return {Number}
|
---|
4933 | * @api private
|
---|
4934 | */
|
---|
4935 |
|
---|
4936 |
|
---|
4937 | function parse(str) {
|
---|
4938 | str = String(str);
|
---|
4939 |
|
---|
4940 | if (str.length > 100) {
|
---|
4941 | return;
|
---|
4942 | }
|
---|
4943 |
|
---|
4944 | var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
---|
4945 |
|
---|
4946 | if (!match) {
|
---|
4947 | return;
|
---|
4948 | }
|
---|
4949 |
|
---|
4950 | var n = parseFloat(match[1]);
|
---|
4951 | var type = (match[2] || 'ms').toLowerCase();
|
---|
4952 |
|
---|
4953 | switch (type) {
|
---|
4954 | case 'years':
|
---|
4955 | case 'year':
|
---|
4956 | case 'yrs':
|
---|
4957 | case 'yr':
|
---|
4958 | case 'y':
|
---|
4959 | return n * y;
|
---|
4960 |
|
---|
4961 | case 'weeks':
|
---|
4962 | case 'week':
|
---|
4963 | case 'w':
|
---|
4964 | return n * w;
|
---|
4965 |
|
---|
4966 | case 'days':
|
---|
4967 | case 'day':
|
---|
4968 | case 'd':
|
---|
4969 | return n * d;
|
---|
4970 |
|
---|
4971 | case 'hours':
|
---|
4972 | case 'hour':
|
---|
4973 | case 'hrs':
|
---|
4974 | case 'hr':
|
---|
4975 | case 'h':
|
---|
4976 | return n * h;
|
---|
4977 |
|
---|
4978 | case 'minutes':
|
---|
4979 | case 'minute':
|
---|
4980 | case 'mins':
|
---|
4981 | case 'min':
|
---|
4982 | case 'm':
|
---|
4983 | return n * m;
|
---|
4984 |
|
---|
4985 | case 'seconds':
|
---|
4986 | case 'second':
|
---|
4987 | case 'secs':
|
---|
4988 | case 'sec':
|
---|
4989 | case 's':
|
---|
4990 | return n * s;
|
---|
4991 |
|
---|
4992 | case 'milliseconds':
|
---|
4993 | case 'millisecond':
|
---|
4994 | case 'msecs':
|
---|
4995 | case 'msec':
|
---|
4996 | case 'ms':
|
---|
4997 | return n;
|
---|
4998 |
|
---|
4999 | default:
|
---|
5000 | return undefined;
|
---|
5001 | }
|
---|
5002 | }
|
---|
5003 | /**
|
---|
5004 | * Short format for `ms`.
|
---|
5005 | *
|
---|
5006 | * @param {Number} ms
|
---|
5007 | * @return {String}
|
---|
5008 | * @api private
|
---|
5009 | */
|
---|
5010 |
|
---|
5011 |
|
---|
5012 | function fmtShort(ms) {
|
---|
5013 | var msAbs = Math.abs(ms);
|
---|
5014 |
|
---|
5015 | if (msAbs >= d) {
|
---|
5016 | return Math.round(ms / d) + 'd';
|
---|
5017 | }
|
---|
5018 |
|
---|
5019 | if (msAbs >= h) {
|
---|
5020 | return Math.round(ms / h) + 'h';
|
---|
5021 | }
|
---|
5022 |
|
---|
5023 | if (msAbs >= m) {
|
---|
5024 | return Math.round(ms / m) + 'm';
|
---|
5025 | }
|
---|
5026 |
|
---|
5027 | if (msAbs >= s) {
|
---|
5028 | return Math.round(ms / s) + 's';
|
---|
5029 | }
|
---|
5030 |
|
---|
5031 | return ms + 'ms';
|
---|
5032 | }
|
---|
5033 | /**
|
---|
5034 | * Long format for `ms`.
|
---|
5035 | *
|
---|
5036 | * @param {Number} ms
|
---|
5037 | * @return {String}
|
---|
5038 | * @api private
|
---|
5039 | */
|
---|
5040 |
|
---|
5041 |
|
---|
5042 | function fmtLong(ms) {
|
---|
5043 | var msAbs = Math.abs(ms);
|
---|
5044 |
|
---|
5045 | if (msAbs >= d) {
|
---|
5046 | return plural(ms, msAbs, d, 'day');
|
---|
5047 | }
|
---|
5048 |
|
---|
5049 | if (msAbs >= h) {
|
---|
5050 | return plural(ms, msAbs, h, 'hour');
|
---|
5051 | }
|
---|
5052 |
|
---|
5053 | if (msAbs >= m) {
|
---|
5054 | return plural(ms, msAbs, m, 'minute');
|
---|
5055 | }
|
---|
5056 |
|
---|
5057 | if (msAbs >= s) {
|
---|
5058 | return plural(ms, msAbs, s, 'second');
|
---|
5059 | }
|
---|
5060 |
|
---|
5061 | return ms + ' ms';
|
---|
5062 | }
|
---|
5063 | /**
|
---|
5064 | * Pluralization helper.
|
---|
5065 | */
|
---|
5066 |
|
---|
5067 |
|
---|
5068 | function plural(ms, msAbs, n, name) {
|
---|
5069 | var isPlural = msAbs >= n * 1.5;
|
---|
5070 | return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
---|
5071 | }
|
---|
5072 |
|
---|
5073 | /***/ }),
|
---|
5074 |
|
---|
5075 | /***/ "./node_modules/parseqs/index.js":
|
---|
5076 | /*!***************************************!*\
|
---|
5077 | !*** ./node_modules/parseqs/index.js ***!
|
---|
5078 | \***************************************/
|
---|
5079 | /*! no static exports found */
|
---|
5080 | /***/ (function(module, exports) {
|
---|
5081 |
|
---|
5082 | /**
|
---|
5083 | * Compiles a querystring
|
---|
5084 | * Returns string representation of the object
|
---|
5085 | *
|
---|
5086 | * @param {Object}
|
---|
5087 | * @api private
|
---|
5088 | */
|
---|
5089 | exports.encode = function (obj) {
|
---|
5090 | var str = '';
|
---|
5091 |
|
---|
5092 | for (var i in obj) {
|
---|
5093 | if (obj.hasOwnProperty(i)) {
|
---|
5094 | if (str.length) str += '&';
|
---|
5095 | str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
|
---|
5096 | }
|
---|
5097 | }
|
---|
5098 |
|
---|
5099 | return str;
|
---|
5100 | };
|
---|
5101 | /**
|
---|
5102 | * Parses a simple querystring into an object
|
---|
5103 | *
|
---|
5104 | * @param {String} qs
|
---|
5105 | * @api private
|
---|
5106 | */
|
---|
5107 |
|
---|
5108 |
|
---|
5109 | exports.decode = function (qs) {
|
---|
5110 | var qry = {};
|
---|
5111 | var pairs = qs.split('&');
|
---|
5112 |
|
---|
5113 | for (var i = 0, l = pairs.length; i < l; i++) {
|
---|
5114 | var pair = pairs[i].split('=');
|
---|
5115 | qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
---|
5116 | }
|
---|
5117 |
|
---|
5118 | return qry;
|
---|
5119 | };
|
---|
5120 |
|
---|
5121 | /***/ }),
|
---|
5122 |
|
---|
5123 | /***/ "./node_modules/parseuri/index.js":
|
---|
5124 | /*!****************************************!*\
|
---|
5125 | !*** ./node_modules/parseuri/index.js ***!
|
---|
5126 | \****************************************/
|
---|
5127 | /*! no static exports found */
|
---|
5128 | /***/ (function(module, exports) {
|
---|
5129 |
|
---|
5130 | /**
|
---|
5131 | * Parses an URI
|
---|
5132 | *
|
---|
5133 | * @author Steven Levithan <stevenlevithan.com> (MIT license)
|
---|
5134 | * @api private
|
---|
5135 | */
|
---|
5136 | var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
|
---|
5137 | var parts = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'];
|
---|
5138 |
|
---|
5139 | module.exports = function parseuri(str) {
|
---|
5140 | var src = str,
|
---|
5141 | b = str.indexOf('['),
|
---|
5142 | e = str.indexOf(']');
|
---|
5143 |
|
---|
5144 | if (b != -1 && e != -1) {
|
---|
5145 | str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
|
---|
5146 | }
|
---|
5147 |
|
---|
5148 | var m = re.exec(str || ''),
|
---|
5149 | uri = {},
|
---|
5150 | i = 14;
|
---|
5151 |
|
---|
5152 | while (i--) {
|
---|
5153 | uri[parts[i]] = m[i] || '';
|
---|
5154 | }
|
---|
5155 |
|
---|
5156 | if (b != -1 && e != -1) {
|
---|
5157 | uri.source = src;
|
---|
5158 | uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
|
---|
5159 | uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
|
---|
5160 | uri.ipv6uri = true;
|
---|
5161 | }
|
---|
5162 |
|
---|
5163 | uri.pathNames = pathNames(uri, uri['path']);
|
---|
5164 | uri.queryKey = queryKey(uri, uri['query']);
|
---|
5165 | return uri;
|
---|
5166 | };
|
---|
5167 |
|
---|
5168 | function pathNames(obj, path) {
|
---|
5169 | var regx = /\/{2,9}/g,
|
---|
5170 | names = path.replace(regx, "/").split("/");
|
---|
5171 |
|
---|
5172 | if (path.substr(0, 1) == '/' || path.length === 0) {
|
---|
5173 | names.splice(0, 1);
|
---|
5174 | }
|
---|
5175 |
|
---|
5176 | if (path.substr(path.length - 1, 1) == '/') {
|
---|
5177 | names.splice(names.length - 1, 1);
|
---|
5178 | }
|
---|
5179 |
|
---|
5180 | return names;
|
---|
5181 | }
|
---|
5182 |
|
---|
5183 | function queryKey(uri, query) {
|
---|
5184 | var data = {};
|
---|
5185 | query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
|
---|
5186 | if ($1) {
|
---|
5187 | data[$1] = $2;
|
---|
5188 | }
|
---|
5189 | });
|
---|
5190 | return data;
|
---|
5191 | }
|
---|
5192 |
|
---|
5193 | /***/ }),
|
---|
5194 |
|
---|
5195 | /***/ "./node_modules/socket.io-parser/dist/binary.js":
|
---|
5196 | /*!******************************************************!*\
|
---|
5197 | !*** ./node_modules/socket.io-parser/dist/binary.js ***!
|
---|
5198 | \******************************************************/
|
---|
5199 | /*! no static exports found */
|
---|
5200 | /***/ (function(module, exports, __webpack_require__) {
|
---|
5201 |
|
---|
5202 | "use strict";
|
---|
5203 |
|
---|
5204 |
|
---|
5205 | 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); }
|
---|
5206 |
|
---|
5207 | Object.defineProperty(exports, "__esModule", {
|
---|
5208 | value: true
|
---|
5209 | });
|
---|
5210 | exports.reconstructPacket = exports.deconstructPacket = void 0;
|
---|
5211 |
|
---|
5212 | var is_binary_1 = __webpack_require__(/*! ./is-binary */ "./node_modules/socket.io-parser/dist/is-binary.js");
|
---|
5213 | /**
|
---|
5214 | * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
|
---|
5215 | *
|
---|
5216 | * @param {Object} packet - socket.io event packet
|
---|
5217 | * @return {Object} with deconstructed packet and list of buffers
|
---|
5218 | * @public
|
---|
5219 | */
|
---|
5220 |
|
---|
5221 |
|
---|
5222 | function deconstructPacket(packet) {
|
---|
5223 | var buffers = [];
|
---|
5224 | var packetData = packet.data;
|
---|
5225 | var pack = packet;
|
---|
5226 | pack.data = _deconstructPacket(packetData, buffers);
|
---|
5227 | pack.attachments = buffers.length; // number of binary 'attachments'
|
---|
5228 |
|
---|
5229 | return {
|
---|
5230 | packet: pack,
|
---|
5231 | buffers: buffers
|
---|
5232 | };
|
---|
5233 | }
|
---|
5234 |
|
---|
5235 | exports.deconstructPacket = deconstructPacket;
|
---|
5236 |
|
---|
5237 | function _deconstructPacket(data, buffers) {
|
---|
5238 | if (!data) return data;
|
---|
5239 |
|
---|
5240 | if (is_binary_1.isBinary(data)) {
|
---|
5241 | var placeholder = {
|
---|
5242 | _placeholder: true,
|
---|
5243 | num: buffers.length
|
---|
5244 | };
|
---|
5245 | buffers.push(data);
|
---|
5246 | return placeholder;
|
---|
5247 | } else if (Array.isArray(data)) {
|
---|
5248 | var newData = new Array(data.length);
|
---|
5249 |
|
---|
5250 | for (var i = 0; i < data.length; i++) {
|
---|
5251 | newData[i] = _deconstructPacket(data[i], buffers);
|
---|
5252 | }
|
---|
5253 |
|
---|
5254 | return newData;
|
---|
5255 | } else if (_typeof(data) === "object" && !(data instanceof Date)) {
|
---|
5256 | var _newData = {};
|
---|
5257 |
|
---|
5258 | for (var key in data) {
|
---|
5259 | if (data.hasOwnProperty(key)) {
|
---|
5260 | _newData[key] = _deconstructPacket(data[key], buffers);
|
---|
5261 | }
|
---|
5262 | }
|
---|
5263 |
|
---|
5264 | return _newData;
|
---|
5265 | }
|
---|
5266 |
|
---|
5267 | return data;
|
---|
5268 | }
|
---|
5269 | /**
|
---|
5270 | * Reconstructs a binary packet from its placeholder packet and buffers
|
---|
5271 | *
|
---|
5272 | * @param {Object} packet - event packet with placeholders
|
---|
5273 | * @param {Array} buffers - binary buffers to put in placeholder positions
|
---|
5274 | * @return {Object} reconstructed packet
|
---|
5275 | * @public
|
---|
5276 | */
|
---|
5277 |
|
---|
5278 |
|
---|
5279 | function reconstructPacket(packet, buffers) {
|
---|
5280 | packet.data = _reconstructPacket(packet.data, buffers);
|
---|
5281 | packet.attachments = undefined; // no longer useful
|
---|
5282 |
|
---|
5283 | return packet;
|
---|
5284 | }
|
---|
5285 |
|
---|
5286 | exports.reconstructPacket = reconstructPacket;
|
---|
5287 |
|
---|
5288 | function _reconstructPacket(data, buffers) {
|
---|
5289 | if (!data) return data;
|
---|
5290 |
|
---|
5291 | if (data && data._placeholder) {
|
---|
5292 | return buffers[data.num]; // appropriate buffer (should be natural order anyway)
|
---|
5293 | } else if (Array.isArray(data)) {
|
---|
5294 | for (var i = 0; i < data.length; i++) {
|
---|
5295 | data[i] = _reconstructPacket(data[i], buffers);
|
---|
5296 | }
|
---|
5297 | } else if (_typeof(data) === "object") {
|
---|
5298 | for (var key in data) {
|
---|
5299 | if (data.hasOwnProperty(key)) {
|
---|
5300 | data[key] = _reconstructPacket(data[key], buffers);
|
---|
5301 | }
|
---|
5302 | }
|
---|
5303 | }
|
---|
5304 |
|
---|
5305 | return data;
|
---|
5306 | }
|
---|
5307 |
|
---|
5308 | /***/ }),
|
---|
5309 |
|
---|
5310 | /***/ "./node_modules/socket.io-parser/dist/index.js":
|
---|
5311 | /*!*****************************************************!*\
|
---|
5312 | !*** ./node_modules/socket.io-parser/dist/index.js ***!
|
---|
5313 | \*****************************************************/
|
---|
5314 | /*! no static exports found */
|
---|
5315 | /***/ (function(module, exports, __webpack_require__) {
|
---|
5316 |
|
---|
5317 | "use strict";
|
---|
5318 |
|
---|
5319 |
|
---|
5320 | 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); }
|
---|
5321 |
|
---|
5322 | function _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); }
|
---|
5323 |
|
---|
5324 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
---|
5325 |
|
---|
5326 | function _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); }
|
---|
5327 |
|
---|
5328 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
5329 |
|
---|
5330 | function _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); }; }
|
---|
5331 |
|
---|
5332 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
5333 |
|
---|
5334 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
5335 |
|
---|
5336 | function _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; } }
|
---|
5337 |
|
---|
5338 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
5339 |
|
---|
5340 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
5341 |
|
---|
5342 | function _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); } }
|
---|
5343 |
|
---|
5344 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
5345 |
|
---|
5346 | Object.defineProperty(exports, "__esModule", {
|
---|
5347 | value: true
|
---|
5348 | });
|
---|
5349 | exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
|
---|
5350 |
|
---|
5351 | var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
---|
5352 |
|
---|
5353 | var binary_1 = __webpack_require__(/*! ./binary */ "./node_modules/socket.io-parser/dist/binary.js");
|
---|
5354 |
|
---|
5355 | var is_binary_1 = __webpack_require__(/*! ./is-binary */ "./node_modules/socket.io-parser/dist/is-binary.js");
|
---|
5356 |
|
---|
5357 | var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("socket.io-parser");
|
---|
5358 | /**
|
---|
5359 | * Protocol version.
|
---|
5360 | *
|
---|
5361 | * @public
|
---|
5362 | */
|
---|
5363 |
|
---|
5364 |
|
---|
5365 | exports.protocol = 5;
|
---|
5366 | var PacketType;
|
---|
5367 |
|
---|
5368 | (function (PacketType) {
|
---|
5369 | PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
|
---|
5370 | PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
|
---|
5371 | PacketType[PacketType["EVENT"] = 2] = "EVENT";
|
---|
5372 | PacketType[PacketType["ACK"] = 3] = "ACK";
|
---|
5373 | PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
|
---|
5374 | PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
|
---|
5375 | PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
|
---|
5376 | })(PacketType = exports.PacketType || (exports.PacketType = {}));
|
---|
5377 | /**
|
---|
5378 | * A socket.io Encoder instance
|
---|
5379 | */
|
---|
5380 |
|
---|
5381 |
|
---|
5382 | var Encoder = /*#__PURE__*/function () {
|
---|
5383 | function Encoder() {
|
---|
5384 | _classCallCheck(this, Encoder);
|
---|
5385 | }
|
---|
5386 |
|
---|
5387 | _createClass(Encoder, [{
|
---|
5388 | key: "encode",
|
---|
5389 |
|
---|
5390 | /**
|
---|
5391 | * Encode a packet as a single string if non-binary, or as a
|
---|
5392 | * buffer sequence, depending on packet type.
|
---|
5393 | *
|
---|
5394 | * @param {Object} obj - packet object
|
---|
5395 | */
|
---|
5396 | value: function encode(obj) {
|
---|
5397 | debug("encoding packet %j", obj);
|
---|
5398 |
|
---|
5399 | if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
|
---|
5400 | if (is_binary_1.hasBinary(obj)) {
|
---|
5401 | obj.type = obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK;
|
---|
5402 | return this.encodeAsBinary(obj);
|
---|
5403 | }
|
---|
5404 | }
|
---|
5405 |
|
---|
5406 | return [this.encodeAsString(obj)];
|
---|
5407 | }
|
---|
5408 | /**
|
---|
5409 | * Encode packet as string.
|
---|
5410 | */
|
---|
5411 |
|
---|
5412 | }, {
|
---|
5413 | key: "encodeAsString",
|
---|
5414 | value: function encodeAsString(obj) {
|
---|
5415 | // first is type
|
---|
5416 | var str = "" + obj.type; // attachments if we have them
|
---|
5417 |
|
---|
5418 | if (obj.type === PacketType.BINARY_EVENT || obj.type === PacketType.BINARY_ACK) {
|
---|
5419 | str += obj.attachments + "-";
|
---|
5420 | } // if we have a namespace other than `/`
|
---|
5421 | // we append it followed by a comma `,`
|
---|
5422 |
|
---|
5423 |
|
---|
5424 | if (obj.nsp && "/" !== obj.nsp) {
|
---|
5425 | str += obj.nsp + ",";
|
---|
5426 | } // immediately followed by the id
|
---|
5427 |
|
---|
5428 |
|
---|
5429 | if (null != obj.id) {
|
---|
5430 | str += obj.id;
|
---|
5431 | } // json data
|
---|
5432 |
|
---|
5433 |
|
---|
5434 | if (null != obj.data) {
|
---|
5435 | str += JSON.stringify(obj.data);
|
---|
5436 | }
|
---|
5437 |
|
---|
5438 | debug("encoded %j as %s", obj, str);
|
---|
5439 | return str;
|
---|
5440 | }
|
---|
5441 | /**
|
---|
5442 | * Encode packet as 'buffer sequence' by removing blobs, and
|
---|
5443 | * deconstructing packet into object with placeholders and
|
---|
5444 | * a list of buffers.
|
---|
5445 | */
|
---|
5446 |
|
---|
5447 | }, {
|
---|
5448 | key: "encodeAsBinary",
|
---|
5449 | value: function encodeAsBinary(obj) {
|
---|
5450 | var deconstruction = binary_1.deconstructPacket(obj);
|
---|
5451 | var pack = this.encodeAsString(deconstruction.packet);
|
---|
5452 | var buffers = deconstruction.buffers;
|
---|
5453 | buffers.unshift(pack); // add packet info to beginning of data list
|
---|
5454 |
|
---|
5455 | return buffers; // write all the buffers
|
---|
5456 | }
|
---|
5457 | }]);
|
---|
5458 |
|
---|
5459 | return Encoder;
|
---|
5460 | }();
|
---|
5461 |
|
---|
5462 | exports.Encoder = Encoder;
|
---|
5463 | /**
|
---|
5464 | * A socket.io Decoder instance
|
---|
5465 | *
|
---|
5466 | * @return {Object} decoder
|
---|
5467 | */
|
---|
5468 |
|
---|
5469 | var Decoder = /*#__PURE__*/function (_Emitter) {
|
---|
5470 | _inherits(Decoder, _Emitter);
|
---|
5471 |
|
---|
5472 | var _super = _createSuper(Decoder);
|
---|
5473 |
|
---|
5474 | function Decoder() {
|
---|
5475 | _classCallCheck(this, Decoder);
|
---|
5476 |
|
---|
5477 | return _super.call(this);
|
---|
5478 | }
|
---|
5479 | /**
|
---|
5480 | * Decodes an encoded packet string into packet JSON.
|
---|
5481 | *
|
---|
5482 | * @param {String} obj - encoded packet
|
---|
5483 | */
|
---|
5484 |
|
---|
5485 |
|
---|
5486 | _createClass(Decoder, [{
|
---|
5487 | key: "add",
|
---|
5488 | value: function add(obj) {
|
---|
5489 | var packet;
|
---|
5490 |
|
---|
5491 | if (typeof obj === "string") {
|
---|
5492 | packet = this.decodeString(obj);
|
---|
5493 |
|
---|
5494 | if (packet.type === PacketType.BINARY_EVENT || packet.type === PacketType.BINARY_ACK) {
|
---|
5495 | // binary packet's json
|
---|
5496 | this.reconstructor = new BinaryReconstructor(packet); // no attachments, labeled binary but no binary data to follow
|
---|
5497 |
|
---|
5498 | if (packet.attachments === 0) {
|
---|
5499 | _get(_getPrototypeOf(Decoder.prototype), "emit", this).call(this, "decoded", packet);
|
---|
5500 | }
|
---|
5501 | } else {
|
---|
5502 | // non-binary full packet
|
---|
5503 | _get(_getPrototypeOf(Decoder.prototype), "emit", this).call(this, "decoded", packet);
|
---|
5504 | }
|
---|
5505 | } else if (is_binary_1.isBinary(obj) || obj.base64) {
|
---|
5506 | // raw binary data
|
---|
5507 | if (!this.reconstructor) {
|
---|
5508 | throw new Error("got binary data when not reconstructing a packet");
|
---|
5509 | } else {
|
---|
5510 | packet = this.reconstructor.takeBinaryData(obj);
|
---|
5511 |
|
---|
5512 | if (packet) {
|
---|
5513 | // received final buffer
|
---|
5514 | this.reconstructor = null;
|
---|
5515 |
|
---|
5516 | _get(_getPrototypeOf(Decoder.prototype), "emit", this).call(this, "decoded", packet);
|
---|
5517 | }
|
---|
5518 | }
|
---|
5519 | } else {
|
---|
5520 | throw new Error("Unknown type: " + obj);
|
---|
5521 | }
|
---|
5522 | }
|
---|
5523 | /**
|
---|
5524 | * Decode a packet String (JSON data)
|
---|
5525 | *
|
---|
5526 | * @param {String} str
|
---|
5527 | * @return {Object} packet
|
---|
5528 | */
|
---|
5529 |
|
---|
5530 | }, {
|
---|
5531 | key: "decodeString",
|
---|
5532 | value: function decodeString(str) {
|
---|
5533 | var i = 0; // look up type
|
---|
5534 |
|
---|
5535 | var p = {
|
---|
5536 | type: Number(str.charAt(0))
|
---|
5537 | };
|
---|
5538 |
|
---|
5539 | if (PacketType[p.type] === undefined) {
|
---|
5540 | throw new Error("unknown packet type " + p.type);
|
---|
5541 | } // look up attachments if type binary
|
---|
5542 |
|
---|
5543 |
|
---|
5544 | if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
|
---|
5545 | var start = i + 1;
|
---|
5546 |
|
---|
5547 | while (str.charAt(++i) !== "-" && i != str.length) {}
|
---|
5548 |
|
---|
5549 | var buf = str.substring(start, i);
|
---|
5550 |
|
---|
5551 | if (buf != Number(buf) || str.charAt(i) !== "-") {
|
---|
5552 | throw new Error("Illegal attachments");
|
---|
5553 | }
|
---|
5554 |
|
---|
5555 | p.attachments = Number(buf);
|
---|
5556 | } // look up namespace (if any)
|
---|
5557 |
|
---|
5558 |
|
---|
5559 | if ("/" === str.charAt(i + 1)) {
|
---|
5560 | var _start = i + 1;
|
---|
5561 |
|
---|
5562 | while (++i) {
|
---|
5563 | var c = str.charAt(i);
|
---|
5564 | if ("," === c) break;
|
---|
5565 | if (i === str.length) break;
|
---|
5566 | }
|
---|
5567 |
|
---|
5568 | p.nsp = str.substring(_start, i);
|
---|
5569 | } else {
|
---|
5570 | p.nsp = "/";
|
---|
5571 | } // look up id
|
---|
5572 |
|
---|
5573 |
|
---|
5574 | var next = str.charAt(i + 1);
|
---|
5575 |
|
---|
5576 | if ("" !== next && Number(next) == next) {
|
---|
5577 | var _start2 = i + 1;
|
---|
5578 |
|
---|
5579 | while (++i) {
|
---|
5580 | var _c = str.charAt(i);
|
---|
5581 |
|
---|
5582 | if (null == _c || Number(_c) != _c) {
|
---|
5583 | --i;
|
---|
5584 | break;
|
---|
5585 | }
|
---|
5586 |
|
---|
5587 | if (i === str.length) break;
|
---|
5588 | }
|
---|
5589 |
|
---|
5590 | p.id = Number(str.substring(_start2, i + 1));
|
---|
5591 | } // look up json data
|
---|
5592 |
|
---|
5593 |
|
---|
5594 | if (str.charAt(++i)) {
|
---|
5595 | var payload = tryParse(str.substr(i));
|
---|
5596 |
|
---|
5597 | if (Decoder.isPayloadValid(p.type, payload)) {
|
---|
5598 | p.data = payload;
|
---|
5599 | } else {
|
---|
5600 | throw new Error("invalid payload");
|
---|
5601 | }
|
---|
5602 | }
|
---|
5603 |
|
---|
5604 | debug("decoded %s as %j", str, p);
|
---|
5605 | return p;
|
---|
5606 | }
|
---|
5607 | }, {
|
---|
5608 | key: "destroy",
|
---|
5609 |
|
---|
5610 | /**
|
---|
5611 | * Deallocates a parser's resources
|
---|
5612 | */
|
---|
5613 | value: function destroy() {
|
---|
5614 | if (this.reconstructor) {
|
---|
5615 | this.reconstructor.finishedReconstruction();
|
---|
5616 | }
|
---|
5617 | }
|
---|
5618 | }], [{
|
---|
5619 | key: "isPayloadValid",
|
---|
5620 | value: function isPayloadValid(type, payload) {
|
---|
5621 | switch (type) {
|
---|
5622 | case PacketType.CONNECT:
|
---|
5623 | return _typeof(payload) === "object";
|
---|
5624 |
|
---|
5625 | case PacketType.DISCONNECT:
|
---|
5626 | return payload === undefined;
|
---|
5627 |
|
---|
5628 | case PacketType.CONNECT_ERROR:
|
---|
5629 | return typeof payload === "string" || _typeof(payload) === "object";
|
---|
5630 |
|
---|
5631 | case PacketType.EVENT:
|
---|
5632 | case PacketType.BINARY_EVENT:
|
---|
5633 | return Array.isArray(payload) && payload.length > 0;
|
---|
5634 |
|
---|
5635 | case PacketType.ACK:
|
---|
5636 | case PacketType.BINARY_ACK:
|
---|
5637 | return Array.isArray(payload);
|
---|
5638 | }
|
---|
5639 | }
|
---|
5640 | }]);
|
---|
5641 |
|
---|
5642 | return Decoder;
|
---|
5643 | }(Emitter);
|
---|
5644 |
|
---|
5645 | exports.Decoder = Decoder;
|
---|
5646 |
|
---|
5647 | function tryParse(str) {
|
---|
5648 | try {
|
---|
5649 | return JSON.parse(str);
|
---|
5650 | } catch (e) {
|
---|
5651 | return false;
|
---|
5652 | }
|
---|
5653 | }
|
---|
5654 | /**
|
---|
5655 | * A manager of a binary event's 'buffer sequence'. Should
|
---|
5656 | * be constructed whenever a packet of type BINARY_EVENT is
|
---|
5657 | * decoded.
|
---|
5658 | *
|
---|
5659 | * @param {Object} packet
|
---|
5660 | * @return {BinaryReconstructor} initialized reconstructor
|
---|
5661 | */
|
---|
5662 |
|
---|
5663 |
|
---|
5664 | var BinaryReconstructor = /*#__PURE__*/function () {
|
---|
5665 | function BinaryReconstructor(packet) {
|
---|
5666 | _classCallCheck(this, BinaryReconstructor);
|
---|
5667 |
|
---|
5668 | this.packet = packet;
|
---|
5669 | this.buffers = [];
|
---|
5670 | this.reconPack = packet;
|
---|
5671 | }
|
---|
5672 | /**
|
---|
5673 | * Method to be called when binary data received from connection
|
---|
5674 | * after a BINARY_EVENT packet.
|
---|
5675 | *
|
---|
5676 | * @param {Buffer | ArrayBuffer} binData - the raw binary data received
|
---|
5677 | * @return {null | Object} returns null if more binary data is expected or
|
---|
5678 | * a reconstructed packet object if all buffers have been received.
|
---|
5679 | */
|
---|
5680 |
|
---|
5681 |
|
---|
5682 | _createClass(BinaryReconstructor, [{
|
---|
5683 | key: "takeBinaryData",
|
---|
5684 | value: function takeBinaryData(binData) {
|
---|
5685 | this.buffers.push(binData);
|
---|
5686 |
|
---|
5687 | if (this.buffers.length === this.reconPack.attachments) {
|
---|
5688 | // done with buffer list
|
---|
5689 | var packet = binary_1.reconstructPacket(this.reconPack, this.buffers);
|
---|
5690 | this.finishedReconstruction();
|
---|
5691 | return packet;
|
---|
5692 | }
|
---|
5693 |
|
---|
5694 | return null;
|
---|
5695 | }
|
---|
5696 | /**
|
---|
5697 | * Cleans up binary packet reconstruction variables.
|
---|
5698 | */
|
---|
5699 |
|
---|
5700 | }, {
|
---|
5701 | key: "finishedReconstruction",
|
---|
5702 | value: function finishedReconstruction() {
|
---|
5703 | this.reconPack = null;
|
---|
5704 | this.buffers = [];
|
---|
5705 | }
|
---|
5706 | }]);
|
---|
5707 |
|
---|
5708 | return BinaryReconstructor;
|
---|
5709 | }();
|
---|
5710 |
|
---|
5711 | /***/ }),
|
---|
5712 |
|
---|
5713 | /***/ "./node_modules/socket.io-parser/dist/is-binary.js":
|
---|
5714 | /*!*********************************************************!*\
|
---|
5715 | !*** ./node_modules/socket.io-parser/dist/is-binary.js ***!
|
---|
5716 | \*********************************************************/
|
---|
5717 | /*! no static exports found */
|
---|
5718 | /***/ (function(module, exports, __webpack_require__) {
|
---|
5719 |
|
---|
5720 | "use strict";
|
---|
5721 |
|
---|
5722 |
|
---|
5723 | 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); }
|
---|
5724 |
|
---|
5725 | Object.defineProperty(exports, "__esModule", {
|
---|
5726 | value: true
|
---|
5727 | });
|
---|
5728 | exports.hasBinary = exports.isBinary = void 0;
|
---|
5729 | var withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
---|
5730 |
|
---|
5731 | var isView = function isView(obj) {
|
---|
5732 | return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj.buffer instanceof ArrayBuffer;
|
---|
5733 | };
|
---|
5734 |
|
---|
5735 | var toString = Object.prototype.toString;
|
---|
5736 | var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && toString.call(Blob) === "[object BlobConstructor]";
|
---|
5737 | var withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString.call(File) === "[object FileConstructor]";
|
---|
5738 | /**
|
---|
5739 | * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
|
---|
5740 | *
|
---|
5741 | * @private
|
---|
5742 | */
|
---|
5743 |
|
---|
5744 | function isBinary(obj) {
|
---|
5745 | return withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)) || withNativeBlob && obj instanceof Blob || withNativeFile && obj instanceof File;
|
---|
5746 | }
|
---|
5747 |
|
---|
5748 | exports.isBinary = isBinary;
|
---|
5749 |
|
---|
5750 | function hasBinary(obj, toJSON) {
|
---|
5751 | if (!obj || _typeof(obj) !== "object") {
|
---|
5752 | return false;
|
---|
5753 | }
|
---|
5754 |
|
---|
5755 | if (Array.isArray(obj)) {
|
---|
5756 | for (var i = 0, l = obj.length; i < l; i++) {
|
---|
5757 | if (hasBinary(obj[i])) {
|
---|
5758 | return true;
|
---|
5759 | }
|
---|
5760 | }
|
---|
5761 |
|
---|
5762 | return false;
|
---|
5763 | }
|
---|
5764 |
|
---|
5765 | if (isBinary(obj)) {
|
---|
5766 | return true;
|
---|
5767 | }
|
---|
5768 |
|
---|
5769 | if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) {
|
---|
5770 | return hasBinary(obj.toJSON(), true);
|
---|
5771 | }
|
---|
5772 |
|
---|
5773 | for (var key in obj) {
|
---|
5774 | if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
|
---|
5775 | return true;
|
---|
5776 | }
|
---|
5777 | }
|
---|
5778 |
|
---|
5779 | return false;
|
---|
5780 | }
|
---|
5781 |
|
---|
5782 | exports.hasBinary = hasBinary;
|
---|
5783 |
|
---|
5784 | /***/ }),
|
---|
5785 |
|
---|
5786 | /***/ "./node_modules/yeast/index.js":
|
---|
5787 | /*!*************************************!*\
|
---|
5788 | !*** ./node_modules/yeast/index.js ***!
|
---|
5789 | \*************************************/
|
---|
5790 | /*! no static exports found */
|
---|
5791 | /***/ (function(module, exports, __webpack_require__) {
|
---|
5792 |
|
---|
5793 | "use strict";
|
---|
5794 |
|
---|
5795 |
|
---|
5796 | var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''),
|
---|
5797 | length = 64,
|
---|
5798 | map = {},
|
---|
5799 | seed = 0,
|
---|
5800 | i = 0,
|
---|
5801 | prev;
|
---|
5802 | /**
|
---|
5803 | * Return a string representing the specified number.
|
---|
5804 | *
|
---|
5805 | * @param {Number} num The number to convert.
|
---|
5806 | * @returns {String} The string representation of the number.
|
---|
5807 | * @api public
|
---|
5808 | */
|
---|
5809 |
|
---|
5810 | function encode(num) {
|
---|
5811 | var encoded = '';
|
---|
5812 |
|
---|
5813 | do {
|
---|
5814 | encoded = alphabet[num % length] + encoded;
|
---|
5815 | num = Math.floor(num / length);
|
---|
5816 | } while (num > 0);
|
---|
5817 |
|
---|
5818 | return encoded;
|
---|
5819 | }
|
---|
5820 | /**
|
---|
5821 | * Return the integer value specified by the given string.
|
---|
5822 | *
|
---|
5823 | * @param {String} str The string to convert.
|
---|
5824 | * @returns {Number} The integer value represented by the string.
|
---|
5825 | * @api public
|
---|
5826 | */
|
---|
5827 |
|
---|
5828 |
|
---|
5829 | function decode(str) {
|
---|
5830 | var decoded = 0;
|
---|
5831 |
|
---|
5832 | for (i = 0; i < str.length; i++) {
|
---|
5833 | decoded = decoded * length + map[str.charAt(i)];
|
---|
5834 | }
|
---|
5835 |
|
---|
5836 | return decoded;
|
---|
5837 | }
|
---|
5838 | /**
|
---|
5839 | * Yeast: A tiny growing id generator.
|
---|
5840 | *
|
---|
5841 | * @returns {String} A unique id.
|
---|
5842 | * @api public
|
---|
5843 | */
|
---|
5844 |
|
---|
5845 |
|
---|
5846 | function yeast() {
|
---|
5847 | var now = encode(+new Date());
|
---|
5848 | if (now !== prev) return seed = 0, prev = now;
|
---|
5849 | return now + '.' + encode(seed++);
|
---|
5850 | } //
|
---|
5851 | // Map each character to its index.
|
---|
5852 | //
|
---|
5853 |
|
---|
5854 |
|
---|
5855 | for (; i < length; i++) {
|
---|
5856 | map[alphabet[i]] = i;
|
---|
5857 | } //
|
---|
5858 | // Expose the `yeast`, `encode` and `decode` functions.
|
---|
5859 | //
|
---|
5860 |
|
---|
5861 |
|
---|
5862 | yeast.encode = encode;
|
---|
5863 | yeast.decode = decode;
|
---|
5864 | module.exports = yeast;
|
---|
5865 |
|
---|
5866 | /***/ })
|
---|
5867 |
|
---|
5868 | /******/ });
|
---|
5869 | });
|
---|
5870 | //# sourceMappingURL=socket.io.js.map |
---|