@symbo.ls/socket 2.10.18 → 2.10.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.cjs +3806 -0
- package/client.cjs.map +7 -0
- package/client.js +15 -11
- package/package.json +2 -3
package/client.cjs
ADDED
|
@@ -0,0 +1,3806 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/socket.io-client/dist/socket.io.js
|
|
34
|
+
var require_socket_io = __commonJS({
|
|
35
|
+
"../../node_modules/socket.io-client/dist/socket.io.js"(exports, module2) {
|
|
36
|
+
(function(global, factory) {
|
|
37
|
+
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.io = factory());
|
|
38
|
+
})(exports, function() {
|
|
39
|
+
"use strict";
|
|
40
|
+
function _typeof(obj2) {
|
|
41
|
+
"@babel/helpers - typeof";
|
|
42
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj3) {
|
|
43
|
+
return typeof obj3;
|
|
44
|
+
} : function(obj3) {
|
|
45
|
+
return obj3 && "function" == typeof Symbol && obj3.constructor === Symbol && obj3 !== Symbol.prototype ? "symbol" : typeof obj3;
|
|
46
|
+
}, _typeof(obj2);
|
|
47
|
+
}
|
|
48
|
+
function _classCallCheck(instance, Constructor) {
|
|
49
|
+
if (!(instance instanceof Constructor)) {
|
|
50
|
+
throw new TypeError("Cannot call a class as a function");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function _defineProperties(target, props) {
|
|
54
|
+
for (var i2 = 0; i2 < props.length; i2++) {
|
|
55
|
+
var descriptor = props[i2];
|
|
56
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
57
|
+
descriptor.configurable = true;
|
|
58
|
+
if ("value" in descriptor)
|
|
59
|
+
descriptor.writable = true;
|
|
60
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
64
|
+
if (protoProps)
|
|
65
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
66
|
+
if (staticProps)
|
|
67
|
+
_defineProperties(Constructor, staticProps);
|
|
68
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
69
|
+
writable: false
|
|
70
|
+
});
|
|
71
|
+
return Constructor;
|
|
72
|
+
}
|
|
73
|
+
function _extends() {
|
|
74
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
75
|
+
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
76
|
+
var source = arguments[i2];
|
|
77
|
+
for (var key in source) {
|
|
78
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
79
|
+
target[key] = source[key];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return target;
|
|
84
|
+
};
|
|
85
|
+
return _extends.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function _inherits(subClass, superClass) {
|
|
88
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
89
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
90
|
+
}
|
|
91
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
92
|
+
constructor: {
|
|
93
|
+
value: subClass,
|
|
94
|
+
writable: true,
|
|
95
|
+
configurable: true
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(subClass, "prototype", {
|
|
99
|
+
writable: false
|
|
100
|
+
});
|
|
101
|
+
if (superClass)
|
|
102
|
+
_setPrototypeOf(subClass, superClass);
|
|
103
|
+
}
|
|
104
|
+
function _getPrototypeOf(o) {
|
|
105
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
106
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
107
|
+
};
|
|
108
|
+
return _getPrototypeOf(o);
|
|
109
|
+
}
|
|
110
|
+
function _setPrototypeOf(o, p) {
|
|
111
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
112
|
+
o2.__proto__ = p2;
|
|
113
|
+
return o2;
|
|
114
|
+
};
|
|
115
|
+
return _setPrototypeOf(o, p);
|
|
116
|
+
}
|
|
117
|
+
function _isNativeReflectConstruct() {
|
|
118
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
119
|
+
return false;
|
|
120
|
+
if (Reflect.construct.sham)
|
|
121
|
+
return false;
|
|
122
|
+
if (typeof Proxy === "function")
|
|
123
|
+
return true;
|
|
124
|
+
try {
|
|
125
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
126
|
+
}));
|
|
127
|
+
return true;
|
|
128
|
+
} catch (e) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function _construct(Parent, args, Class) {
|
|
133
|
+
if (_isNativeReflectConstruct()) {
|
|
134
|
+
_construct = Reflect.construct.bind();
|
|
135
|
+
} else {
|
|
136
|
+
_construct = function _construct2(Parent2, args2, Class2) {
|
|
137
|
+
var a = [null];
|
|
138
|
+
a.push.apply(a, args2);
|
|
139
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
140
|
+
var instance = new Constructor();
|
|
141
|
+
if (Class2)
|
|
142
|
+
_setPrototypeOf(instance, Class2.prototype);
|
|
143
|
+
return instance;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return _construct.apply(null, arguments);
|
|
147
|
+
}
|
|
148
|
+
function _isNativeFunction(fn) {
|
|
149
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
150
|
+
}
|
|
151
|
+
function _wrapNativeSuper(Class) {
|
|
152
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
153
|
+
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
154
|
+
if (Class2 === null || !_isNativeFunction(Class2))
|
|
155
|
+
return Class2;
|
|
156
|
+
if (typeof Class2 !== "function") {
|
|
157
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
158
|
+
}
|
|
159
|
+
if (typeof _cache !== "undefined") {
|
|
160
|
+
if (_cache.has(Class2))
|
|
161
|
+
return _cache.get(Class2);
|
|
162
|
+
_cache.set(Class2, Wrapper);
|
|
163
|
+
}
|
|
164
|
+
function Wrapper() {
|
|
165
|
+
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
|
166
|
+
}
|
|
167
|
+
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
168
|
+
constructor: {
|
|
169
|
+
value: Wrapper,
|
|
170
|
+
enumerable: false,
|
|
171
|
+
writable: true,
|
|
172
|
+
configurable: true
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return _setPrototypeOf(Wrapper, Class2);
|
|
176
|
+
};
|
|
177
|
+
return _wrapNativeSuper(Class);
|
|
178
|
+
}
|
|
179
|
+
function _assertThisInitialized(self2) {
|
|
180
|
+
if (self2 === void 0) {
|
|
181
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
182
|
+
}
|
|
183
|
+
return self2;
|
|
184
|
+
}
|
|
185
|
+
function _possibleConstructorReturn(self2, call) {
|
|
186
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
187
|
+
return call;
|
|
188
|
+
} else if (call !== void 0) {
|
|
189
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
190
|
+
}
|
|
191
|
+
return _assertThisInitialized(self2);
|
|
192
|
+
}
|
|
193
|
+
function _createSuper(Derived) {
|
|
194
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
195
|
+
return function _createSuperInternal() {
|
|
196
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
197
|
+
if (hasNativeReflectConstruct) {
|
|
198
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
199
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
200
|
+
} else {
|
|
201
|
+
result = Super.apply(this, arguments);
|
|
202
|
+
}
|
|
203
|
+
return _possibleConstructorReturn(this, result);
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function _superPropBase(object, property) {
|
|
207
|
+
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
208
|
+
object = _getPrototypeOf(object);
|
|
209
|
+
if (object === null)
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
return object;
|
|
213
|
+
}
|
|
214
|
+
function _get() {
|
|
215
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
216
|
+
_get = Reflect.get.bind();
|
|
217
|
+
} else {
|
|
218
|
+
_get = function _get2(target, property, receiver) {
|
|
219
|
+
var base = _superPropBase(target, property);
|
|
220
|
+
if (!base)
|
|
221
|
+
return;
|
|
222
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
223
|
+
if (desc.get) {
|
|
224
|
+
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
225
|
+
}
|
|
226
|
+
return desc.value;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return _get.apply(this, arguments);
|
|
230
|
+
}
|
|
231
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
232
|
+
if (!o)
|
|
233
|
+
return;
|
|
234
|
+
if (typeof o === "string")
|
|
235
|
+
return _arrayLikeToArray(o, minLen);
|
|
236
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
237
|
+
if (n === "Object" && o.constructor)
|
|
238
|
+
n = o.constructor.name;
|
|
239
|
+
if (n === "Map" || n === "Set")
|
|
240
|
+
return Array.from(o);
|
|
241
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
242
|
+
return _arrayLikeToArray(o, minLen);
|
|
243
|
+
}
|
|
244
|
+
function _arrayLikeToArray(arr, len) {
|
|
245
|
+
if (len == null || len > arr.length)
|
|
246
|
+
len = arr.length;
|
|
247
|
+
for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++)
|
|
248
|
+
arr2[i2] = arr[i2];
|
|
249
|
+
return arr2;
|
|
250
|
+
}
|
|
251
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
252
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
253
|
+
if (!it) {
|
|
254
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
255
|
+
if (it)
|
|
256
|
+
o = it;
|
|
257
|
+
var i2 = 0;
|
|
258
|
+
var F = function() {
|
|
259
|
+
};
|
|
260
|
+
return {
|
|
261
|
+
s: F,
|
|
262
|
+
n: function() {
|
|
263
|
+
if (i2 >= o.length)
|
|
264
|
+
return {
|
|
265
|
+
done: true
|
|
266
|
+
};
|
|
267
|
+
return {
|
|
268
|
+
done: false,
|
|
269
|
+
value: o[i2++]
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
e: function(e) {
|
|
273
|
+
throw e;
|
|
274
|
+
},
|
|
275
|
+
f: F
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
279
|
+
}
|
|
280
|
+
var normalCompletion = true, didErr = false, err;
|
|
281
|
+
return {
|
|
282
|
+
s: function() {
|
|
283
|
+
it = it.call(o);
|
|
284
|
+
},
|
|
285
|
+
n: function() {
|
|
286
|
+
var step = it.next();
|
|
287
|
+
normalCompletion = step.done;
|
|
288
|
+
return step;
|
|
289
|
+
},
|
|
290
|
+
e: function(e) {
|
|
291
|
+
didErr = true;
|
|
292
|
+
err = e;
|
|
293
|
+
},
|
|
294
|
+
f: function() {
|
|
295
|
+
try {
|
|
296
|
+
if (!normalCompletion && it.return != null)
|
|
297
|
+
it.return();
|
|
298
|
+
} finally {
|
|
299
|
+
if (didErr)
|
|
300
|
+
throw err;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
var PACKET_TYPES = /* @__PURE__ */ Object.create(null);
|
|
306
|
+
PACKET_TYPES["open"] = "0";
|
|
307
|
+
PACKET_TYPES["close"] = "1";
|
|
308
|
+
PACKET_TYPES["ping"] = "2";
|
|
309
|
+
PACKET_TYPES["pong"] = "3";
|
|
310
|
+
PACKET_TYPES["message"] = "4";
|
|
311
|
+
PACKET_TYPES["upgrade"] = "5";
|
|
312
|
+
PACKET_TYPES["noop"] = "6";
|
|
313
|
+
var PACKET_TYPES_REVERSE = /* @__PURE__ */ Object.create(null);
|
|
314
|
+
Object.keys(PACKET_TYPES).forEach(function(key) {
|
|
315
|
+
PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
|
|
316
|
+
});
|
|
317
|
+
var ERROR_PACKET = {
|
|
318
|
+
type: "error",
|
|
319
|
+
data: "parser error"
|
|
320
|
+
};
|
|
321
|
+
var withNativeBlob$1 = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]";
|
|
322
|
+
var withNativeArrayBuffer$2 = typeof ArrayBuffer === "function";
|
|
323
|
+
var isView$1 = function isView2(obj2) {
|
|
324
|
+
return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj2) : obj2 && obj2.buffer instanceof ArrayBuffer;
|
|
325
|
+
};
|
|
326
|
+
var encodePacket = function encodePacket2(_ref, supportsBinary, callback) {
|
|
327
|
+
var type = _ref.type, data = _ref.data;
|
|
328
|
+
if (withNativeBlob$1 && data instanceof Blob) {
|
|
329
|
+
if (supportsBinary) {
|
|
330
|
+
return callback(data);
|
|
331
|
+
} else {
|
|
332
|
+
return encodeBlobAsBase64(data, callback);
|
|
333
|
+
}
|
|
334
|
+
} else if (withNativeArrayBuffer$2 && (data instanceof ArrayBuffer || isView$1(data))) {
|
|
335
|
+
if (supportsBinary) {
|
|
336
|
+
return callback(data);
|
|
337
|
+
} else {
|
|
338
|
+
return encodeBlobAsBase64(new Blob([data]), callback);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return callback(PACKET_TYPES[type] + (data || ""));
|
|
342
|
+
};
|
|
343
|
+
var encodeBlobAsBase64 = function encodeBlobAsBase642(data, callback) {
|
|
344
|
+
var fileReader = new FileReader();
|
|
345
|
+
fileReader.onload = function() {
|
|
346
|
+
var content = fileReader.result.split(",")[1];
|
|
347
|
+
callback("b" + content);
|
|
348
|
+
};
|
|
349
|
+
return fileReader.readAsDataURL(data);
|
|
350
|
+
};
|
|
351
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
352
|
+
var lookup$1 = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
|
|
353
|
+
for (var i$1 = 0; i$1 < chars.length; i$1++) {
|
|
354
|
+
lookup$1[chars.charCodeAt(i$1)] = i$1;
|
|
355
|
+
}
|
|
356
|
+
var decode$1 = function decode2(base64) {
|
|
357
|
+
var bufferLength = base64.length * 0.75, len = base64.length, i2, p = 0, encoded1, encoded2, encoded3, encoded4;
|
|
358
|
+
if (base64[base64.length - 1] === "=") {
|
|
359
|
+
bufferLength--;
|
|
360
|
+
if (base64[base64.length - 2] === "=") {
|
|
361
|
+
bufferLength--;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
|
|
365
|
+
for (i2 = 0; i2 < len; i2 += 4) {
|
|
366
|
+
encoded1 = lookup$1[base64.charCodeAt(i2)];
|
|
367
|
+
encoded2 = lookup$1[base64.charCodeAt(i2 + 1)];
|
|
368
|
+
encoded3 = lookup$1[base64.charCodeAt(i2 + 2)];
|
|
369
|
+
encoded4 = lookup$1[base64.charCodeAt(i2 + 3)];
|
|
370
|
+
bytes[p++] = encoded1 << 2 | encoded2 >> 4;
|
|
371
|
+
bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
|
372
|
+
bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
|
373
|
+
}
|
|
374
|
+
return arraybuffer;
|
|
375
|
+
};
|
|
376
|
+
var withNativeArrayBuffer$1 = typeof ArrayBuffer === "function";
|
|
377
|
+
var decodePacket = function decodePacket2(encodedPacket, binaryType) {
|
|
378
|
+
if (typeof encodedPacket !== "string") {
|
|
379
|
+
return {
|
|
380
|
+
type: "message",
|
|
381
|
+
data: mapBinary(encodedPacket, binaryType)
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
var type = encodedPacket.charAt(0);
|
|
385
|
+
if (type === "b") {
|
|
386
|
+
return {
|
|
387
|
+
type: "message",
|
|
388
|
+
data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
var packetType = PACKET_TYPES_REVERSE[type];
|
|
392
|
+
if (!packetType) {
|
|
393
|
+
return ERROR_PACKET;
|
|
394
|
+
}
|
|
395
|
+
return encodedPacket.length > 1 ? {
|
|
396
|
+
type: PACKET_TYPES_REVERSE[type],
|
|
397
|
+
data: encodedPacket.substring(1)
|
|
398
|
+
} : {
|
|
399
|
+
type: PACKET_TYPES_REVERSE[type]
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
var decodeBase64Packet = function decodeBase64Packet2(data, binaryType) {
|
|
403
|
+
if (withNativeArrayBuffer$1) {
|
|
404
|
+
var decoded = decode$1(data);
|
|
405
|
+
return mapBinary(decoded, binaryType);
|
|
406
|
+
} else {
|
|
407
|
+
return {
|
|
408
|
+
base64: true,
|
|
409
|
+
data
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var mapBinary = function mapBinary2(data, binaryType) {
|
|
414
|
+
switch (binaryType) {
|
|
415
|
+
case "blob":
|
|
416
|
+
return data instanceof ArrayBuffer ? new Blob([data]) : data;
|
|
417
|
+
case "arraybuffer":
|
|
418
|
+
default:
|
|
419
|
+
return data;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
var SEPARATOR = String.fromCharCode(30);
|
|
423
|
+
var encodePayload = function encodePayload2(packets, callback) {
|
|
424
|
+
var length2 = packets.length;
|
|
425
|
+
var encodedPackets = new Array(length2);
|
|
426
|
+
var count = 0;
|
|
427
|
+
packets.forEach(function(packet, i2) {
|
|
428
|
+
encodePacket(packet, false, function(encodedPacket) {
|
|
429
|
+
encodedPackets[i2] = encodedPacket;
|
|
430
|
+
if (++count === length2) {
|
|
431
|
+
callback(encodedPackets.join(SEPARATOR));
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
var decodePayload = function decodePayload2(encodedPayload, binaryType) {
|
|
437
|
+
var encodedPackets = encodedPayload.split(SEPARATOR);
|
|
438
|
+
var packets = [];
|
|
439
|
+
for (var i2 = 0; i2 < encodedPackets.length; i2++) {
|
|
440
|
+
var decodedPacket = decodePacket(encodedPackets[i2], binaryType);
|
|
441
|
+
packets.push(decodedPacket);
|
|
442
|
+
if (decodedPacket.type === "error") {
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return packets;
|
|
447
|
+
};
|
|
448
|
+
var protocol$1 = 4;
|
|
449
|
+
function Emitter(obj2) {
|
|
450
|
+
if (obj2)
|
|
451
|
+
return mixin(obj2);
|
|
452
|
+
}
|
|
453
|
+
function mixin(obj2) {
|
|
454
|
+
for (var key in Emitter.prototype) {
|
|
455
|
+
obj2[key] = Emitter.prototype[key];
|
|
456
|
+
}
|
|
457
|
+
return obj2;
|
|
458
|
+
}
|
|
459
|
+
Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) {
|
|
460
|
+
this._callbacks = this._callbacks || {};
|
|
461
|
+
(this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn);
|
|
462
|
+
return this;
|
|
463
|
+
};
|
|
464
|
+
Emitter.prototype.once = function(event, fn) {
|
|
465
|
+
function on2() {
|
|
466
|
+
this.off(event, on2);
|
|
467
|
+
fn.apply(this, arguments);
|
|
468
|
+
}
|
|
469
|
+
on2.fn = fn;
|
|
470
|
+
this.on(event, on2);
|
|
471
|
+
return this;
|
|
472
|
+
};
|
|
473
|
+
Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) {
|
|
474
|
+
this._callbacks = this._callbacks || {};
|
|
475
|
+
if (0 == arguments.length) {
|
|
476
|
+
this._callbacks = {};
|
|
477
|
+
return this;
|
|
478
|
+
}
|
|
479
|
+
var callbacks = this._callbacks["$" + event];
|
|
480
|
+
if (!callbacks)
|
|
481
|
+
return this;
|
|
482
|
+
if (1 == arguments.length) {
|
|
483
|
+
delete this._callbacks["$" + event];
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
var cb;
|
|
487
|
+
for (var i2 = 0; i2 < callbacks.length; i2++) {
|
|
488
|
+
cb = callbacks[i2];
|
|
489
|
+
if (cb === fn || cb.fn === fn) {
|
|
490
|
+
callbacks.splice(i2, 1);
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (callbacks.length === 0) {
|
|
495
|
+
delete this._callbacks["$" + event];
|
|
496
|
+
}
|
|
497
|
+
return this;
|
|
498
|
+
};
|
|
499
|
+
Emitter.prototype.emit = function(event) {
|
|
500
|
+
this._callbacks = this._callbacks || {};
|
|
501
|
+
var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event];
|
|
502
|
+
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
503
|
+
args[i2 - 1] = arguments[i2];
|
|
504
|
+
}
|
|
505
|
+
if (callbacks) {
|
|
506
|
+
callbacks = callbacks.slice(0);
|
|
507
|
+
for (var i2 = 0, len = callbacks.length; i2 < len; ++i2) {
|
|
508
|
+
callbacks[i2].apply(this, args);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return this;
|
|
512
|
+
};
|
|
513
|
+
Emitter.prototype.emitReserved = Emitter.prototype.emit;
|
|
514
|
+
Emitter.prototype.listeners = function(event) {
|
|
515
|
+
this._callbacks = this._callbacks || {};
|
|
516
|
+
return this._callbacks["$" + event] || [];
|
|
517
|
+
};
|
|
518
|
+
Emitter.prototype.hasListeners = function(event) {
|
|
519
|
+
return !!this.listeners(event).length;
|
|
520
|
+
};
|
|
521
|
+
var globalThisShim = function() {
|
|
522
|
+
if (typeof self !== "undefined") {
|
|
523
|
+
return self;
|
|
524
|
+
} else if (typeof window !== "undefined") {
|
|
525
|
+
return window;
|
|
526
|
+
} else {
|
|
527
|
+
return Function("return this")();
|
|
528
|
+
}
|
|
529
|
+
}();
|
|
530
|
+
function pick(obj2) {
|
|
531
|
+
for (var _len = arguments.length, attr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
532
|
+
attr[_key - 1] = arguments[_key];
|
|
533
|
+
}
|
|
534
|
+
return attr.reduce(function(acc, k) {
|
|
535
|
+
if (obj2.hasOwnProperty(k)) {
|
|
536
|
+
acc[k] = obj2[k];
|
|
537
|
+
}
|
|
538
|
+
return acc;
|
|
539
|
+
}, {});
|
|
540
|
+
}
|
|
541
|
+
var NATIVE_SET_TIMEOUT = setTimeout;
|
|
542
|
+
var NATIVE_CLEAR_TIMEOUT = clearTimeout;
|
|
543
|
+
function installTimerFunctions(obj2, opts) {
|
|
544
|
+
if (opts.useNativeTimers) {
|
|
545
|
+
obj2.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
|
|
546
|
+
obj2.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
|
|
547
|
+
} else {
|
|
548
|
+
obj2.setTimeoutFn = setTimeout.bind(globalThisShim);
|
|
549
|
+
obj2.clearTimeoutFn = clearTimeout.bind(globalThisShim);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
var BASE64_OVERHEAD = 1.33;
|
|
553
|
+
function byteLength(obj2) {
|
|
554
|
+
if (typeof obj2 === "string") {
|
|
555
|
+
return utf8Length(obj2);
|
|
556
|
+
}
|
|
557
|
+
return Math.ceil((obj2.byteLength || obj2.size) * BASE64_OVERHEAD);
|
|
558
|
+
}
|
|
559
|
+
function utf8Length(str) {
|
|
560
|
+
var c = 0, length2 = 0;
|
|
561
|
+
for (var i2 = 0, l = str.length; i2 < l; i2++) {
|
|
562
|
+
c = str.charCodeAt(i2);
|
|
563
|
+
if (c < 128) {
|
|
564
|
+
length2 += 1;
|
|
565
|
+
} else if (c < 2048) {
|
|
566
|
+
length2 += 2;
|
|
567
|
+
} else if (c < 55296 || c >= 57344) {
|
|
568
|
+
length2 += 3;
|
|
569
|
+
} else {
|
|
570
|
+
i2++;
|
|
571
|
+
length2 += 4;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return length2;
|
|
575
|
+
}
|
|
576
|
+
var TransportError = /* @__PURE__ */ function(_Error) {
|
|
577
|
+
_inherits(TransportError2, _Error);
|
|
578
|
+
var _super = _createSuper(TransportError2);
|
|
579
|
+
function TransportError2(reason, description, context) {
|
|
580
|
+
var _this;
|
|
581
|
+
_classCallCheck(this, TransportError2);
|
|
582
|
+
_this = _super.call(this, reason);
|
|
583
|
+
_this.description = description;
|
|
584
|
+
_this.context = context;
|
|
585
|
+
_this.type = "TransportError";
|
|
586
|
+
return _this;
|
|
587
|
+
}
|
|
588
|
+
return _createClass(TransportError2);
|
|
589
|
+
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
590
|
+
var Transport = /* @__PURE__ */ function(_Emitter) {
|
|
591
|
+
_inherits(Transport2, _Emitter);
|
|
592
|
+
var _super2 = _createSuper(Transport2);
|
|
593
|
+
function Transport2(opts) {
|
|
594
|
+
var _this2;
|
|
595
|
+
_classCallCheck(this, Transport2);
|
|
596
|
+
_this2 = _super2.call(this);
|
|
597
|
+
_this2.writable = false;
|
|
598
|
+
installTimerFunctions(_assertThisInitialized(_this2), opts);
|
|
599
|
+
_this2.opts = opts;
|
|
600
|
+
_this2.query = opts.query;
|
|
601
|
+
_this2.readyState = "";
|
|
602
|
+
_this2.socket = opts.socket;
|
|
603
|
+
return _this2;
|
|
604
|
+
}
|
|
605
|
+
_createClass(Transport2, [{
|
|
606
|
+
key: "onError",
|
|
607
|
+
value: function onError(reason, description, context) {
|
|
608
|
+
_get(_getPrototypeOf(Transport2.prototype), "emitReserved", this).call(this, "error", new TransportError(reason, description, context));
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Opens the transport.
|
|
613
|
+
*
|
|
614
|
+
* @api public
|
|
615
|
+
*/
|
|
616
|
+
}, {
|
|
617
|
+
key: "open",
|
|
618
|
+
value: function open() {
|
|
619
|
+
if ("closed" === this.readyState || "" === this.readyState) {
|
|
620
|
+
this.readyState = "opening";
|
|
621
|
+
this.doOpen();
|
|
622
|
+
}
|
|
623
|
+
return this;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Closes the transport.
|
|
627
|
+
*
|
|
628
|
+
* @api public
|
|
629
|
+
*/
|
|
630
|
+
}, {
|
|
631
|
+
key: "close",
|
|
632
|
+
value: function close() {
|
|
633
|
+
if ("opening" === this.readyState || "open" === this.readyState) {
|
|
634
|
+
this.doClose();
|
|
635
|
+
this.onClose();
|
|
636
|
+
}
|
|
637
|
+
return this;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Sends multiple packets.
|
|
641
|
+
*
|
|
642
|
+
* @param {Array} packets
|
|
643
|
+
* @api public
|
|
644
|
+
*/
|
|
645
|
+
}, {
|
|
646
|
+
key: "send",
|
|
647
|
+
value: function send2(packets) {
|
|
648
|
+
if ("open" === this.readyState) {
|
|
649
|
+
this.write(packets);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Called upon open
|
|
654
|
+
*
|
|
655
|
+
* @api protected
|
|
656
|
+
*/
|
|
657
|
+
}, {
|
|
658
|
+
key: "onOpen",
|
|
659
|
+
value: function onOpen() {
|
|
660
|
+
this.readyState = "open";
|
|
661
|
+
this.writable = true;
|
|
662
|
+
_get(_getPrototypeOf(Transport2.prototype), "emitReserved", this).call(this, "open");
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Called with data.
|
|
666
|
+
*
|
|
667
|
+
* @param {String} data
|
|
668
|
+
* @api protected
|
|
669
|
+
*/
|
|
670
|
+
}, {
|
|
671
|
+
key: "onData",
|
|
672
|
+
value: function onData(data) {
|
|
673
|
+
var packet = decodePacket(data, this.socket.binaryType);
|
|
674
|
+
this.onPacket(packet);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Called with a decoded packet.
|
|
678
|
+
*
|
|
679
|
+
* @api protected
|
|
680
|
+
*/
|
|
681
|
+
}, {
|
|
682
|
+
key: "onPacket",
|
|
683
|
+
value: function onPacket(packet) {
|
|
684
|
+
_get(_getPrototypeOf(Transport2.prototype), "emitReserved", this).call(this, "packet", packet);
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Called upon close.
|
|
688
|
+
*
|
|
689
|
+
* @api protected
|
|
690
|
+
*/
|
|
691
|
+
}, {
|
|
692
|
+
key: "onClose",
|
|
693
|
+
value: function onClose(details) {
|
|
694
|
+
this.readyState = "closed";
|
|
695
|
+
_get(_getPrototypeOf(Transport2.prototype), "emitReserved", this).call(this, "close", details);
|
|
696
|
+
}
|
|
697
|
+
}]);
|
|
698
|
+
return Transport2;
|
|
699
|
+
}(Emitter);
|
|
700
|
+
var alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""), length = 64, map2 = {};
|
|
701
|
+
var seed = 0, i = 0, prev;
|
|
702
|
+
function encode$1(num) {
|
|
703
|
+
var encoded = "";
|
|
704
|
+
do {
|
|
705
|
+
encoded = alphabet[num % length] + encoded;
|
|
706
|
+
num = Math.floor(num / length);
|
|
707
|
+
} while (num > 0);
|
|
708
|
+
return encoded;
|
|
709
|
+
}
|
|
710
|
+
function yeast() {
|
|
711
|
+
var now = encode$1(+/* @__PURE__ */ new Date());
|
|
712
|
+
if (now !== prev)
|
|
713
|
+
return seed = 0, prev = now;
|
|
714
|
+
return now + "." + encode$1(seed++);
|
|
715
|
+
}
|
|
716
|
+
for (; i < length; i++) {
|
|
717
|
+
map2[alphabet[i]] = i;
|
|
718
|
+
}
|
|
719
|
+
function encode(obj2) {
|
|
720
|
+
var str = "";
|
|
721
|
+
for (var i2 in obj2) {
|
|
722
|
+
if (obj2.hasOwnProperty(i2)) {
|
|
723
|
+
if (str.length)
|
|
724
|
+
str += "&";
|
|
725
|
+
str += encodeURIComponent(i2) + "=" + encodeURIComponent(obj2[i2]);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return str;
|
|
729
|
+
}
|
|
730
|
+
function decode(qs) {
|
|
731
|
+
var qry = {};
|
|
732
|
+
var pairs = qs.split("&");
|
|
733
|
+
for (var i2 = 0, l = pairs.length; i2 < l; i2++) {
|
|
734
|
+
var pair = pairs[i2].split("=");
|
|
735
|
+
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
736
|
+
}
|
|
737
|
+
return qry;
|
|
738
|
+
}
|
|
739
|
+
var value = false;
|
|
740
|
+
try {
|
|
741
|
+
value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest();
|
|
742
|
+
} catch (err) {
|
|
743
|
+
}
|
|
744
|
+
var hasCORS = value;
|
|
745
|
+
function XHR(opts) {
|
|
746
|
+
var xdomain = opts.xdomain;
|
|
747
|
+
try {
|
|
748
|
+
if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
|
749
|
+
return new XMLHttpRequest();
|
|
750
|
+
}
|
|
751
|
+
} catch (e) {
|
|
752
|
+
}
|
|
753
|
+
if (!xdomain) {
|
|
754
|
+
try {
|
|
755
|
+
return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
756
|
+
} catch (e) {
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function empty() {
|
|
761
|
+
}
|
|
762
|
+
var hasXHR2 = function() {
|
|
763
|
+
var xhr = new XHR({
|
|
764
|
+
xdomain: false
|
|
765
|
+
});
|
|
766
|
+
return null != xhr.responseType;
|
|
767
|
+
}();
|
|
768
|
+
var Polling = /* @__PURE__ */ function(_Transport) {
|
|
769
|
+
_inherits(Polling2, _Transport);
|
|
770
|
+
var _super = _createSuper(Polling2);
|
|
771
|
+
function Polling2(opts) {
|
|
772
|
+
var _this;
|
|
773
|
+
_classCallCheck(this, Polling2);
|
|
774
|
+
_this = _super.call(this, opts);
|
|
775
|
+
_this.polling = false;
|
|
776
|
+
if (typeof location !== "undefined") {
|
|
777
|
+
var isSSL = "https:" === location.protocol;
|
|
778
|
+
var port = location.port;
|
|
779
|
+
if (!port) {
|
|
780
|
+
port = isSSL ? "443" : "80";
|
|
781
|
+
}
|
|
782
|
+
_this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
|
|
783
|
+
_this.xs = opts.secure !== isSSL;
|
|
784
|
+
}
|
|
785
|
+
var forceBase64 = opts && opts.forceBase64;
|
|
786
|
+
_this.supportsBinary = hasXHR2 && !forceBase64;
|
|
787
|
+
return _this;
|
|
788
|
+
}
|
|
789
|
+
_createClass(Polling2, [{
|
|
790
|
+
key: "name",
|
|
791
|
+
get: function get() {
|
|
792
|
+
return "polling";
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Opens the socket (triggers polling). We write a PING message to determine
|
|
796
|
+
* when the transport is open.
|
|
797
|
+
*
|
|
798
|
+
* @api private
|
|
799
|
+
*/
|
|
800
|
+
}, {
|
|
801
|
+
key: "doOpen",
|
|
802
|
+
value: function doOpen() {
|
|
803
|
+
this.poll();
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Pauses polling.
|
|
807
|
+
*
|
|
808
|
+
* @param {Function} callback upon buffers are flushed and transport is paused
|
|
809
|
+
* @api private
|
|
810
|
+
*/
|
|
811
|
+
}, {
|
|
812
|
+
key: "pause",
|
|
813
|
+
value: function pause(onPause) {
|
|
814
|
+
var _this2 = this;
|
|
815
|
+
this.readyState = "pausing";
|
|
816
|
+
var pause2 = function pause3() {
|
|
817
|
+
_this2.readyState = "paused";
|
|
818
|
+
onPause();
|
|
819
|
+
};
|
|
820
|
+
if (this.polling || !this.writable) {
|
|
821
|
+
var total = 0;
|
|
822
|
+
if (this.polling) {
|
|
823
|
+
total++;
|
|
824
|
+
this.once("pollComplete", function() {
|
|
825
|
+
--total || pause2();
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
if (!this.writable) {
|
|
829
|
+
total++;
|
|
830
|
+
this.once("drain", function() {
|
|
831
|
+
--total || pause2();
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
} else {
|
|
835
|
+
pause2();
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Starts polling cycle.
|
|
840
|
+
*
|
|
841
|
+
* @api public
|
|
842
|
+
*/
|
|
843
|
+
}, {
|
|
844
|
+
key: "poll",
|
|
845
|
+
value: function poll() {
|
|
846
|
+
this.polling = true;
|
|
847
|
+
this.doPoll();
|
|
848
|
+
this.emitReserved("poll");
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Overloads onData to detect payloads.
|
|
852
|
+
*
|
|
853
|
+
* @api private
|
|
854
|
+
*/
|
|
855
|
+
}, {
|
|
856
|
+
key: "onData",
|
|
857
|
+
value: function onData(data) {
|
|
858
|
+
var _this3 = this;
|
|
859
|
+
var callback = function callback2(packet) {
|
|
860
|
+
if ("opening" === _this3.readyState && packet.type === "open") {
|
|
861
|
+
_this3.onOpen();
|
|
862
|
+
}
|
|
863
|
+
if ("close" === packet.type) {
|
|
864
|
+
_this3.onClose({
|
|
865
|
+
description: "transport closed by the server"
|
|
866
|
+
});
|
|
867
|
+
return false;
|
|
868
|
+
}
|
|
869
|
+
_this3.onPacket(packet);
|
|
870
|
+
};
|
|
871
|
+
decodePayload(data, this.socket.binaryType).forEach(callback);
|
|
872
|
+
if ("closed" !== this.readyState) {
|
|
873
|
+
this.polling = false;
|
|
874
|
+
this.emitReserved("pollComplete");
|
|
875
|
+
if ("open" === this.readyState) {
|
|
876
|
+
this.poll();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* For polling, send a close packet.
|
|
882
|
+
*
|
|
883
|
+
* @api private
|
|
884
|
+
*/
|
|
885
|
+
}, {
|
|
886
|
+
key: "doClose",
|
|
887
|
+
value: function doClose() {
|
|
888
|
+
var _this4 = this;
|
|
889
|
+
var close = function close2() {
|
|
890
|
+
_this4.write([{
|
|
891
|
+
type: "close"
|
|
892
|
+
}]);
|
|
893
|
+
};
|
|
894
|
+
if ("open" === this.readyState) {
|
|
895
|
+
close();
|
|
896
|
+
} else {
|
|
897
|
+
this.once("open", close);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Writes a packets payload.
|
|
902
|
+
*
|
|
903
|
+
* @param {Array} data packets
|
|
904
|
+
* @param {Function} drain callback
|
|
905
|
+
* @api private
|
|
906
|
+
*/
|
|
907
|
+
}, {
|
|
908
|
+
key: "write",
|
|
909
|
+
value: function write(packets) {
|
|
910
|
+
var _this5 = this;
|
|
911
|
+
this.writable = false;
|
|
912
|
+
encodePayload(packets, function(data) {
|
|
913
|
+
_this5.doWrite(data, function() {
|
|
914
|
+
_this5.writable = true;
|
|
915
|
+
_this5.emitReserved("drain");
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Generates uri for connection.
|
|
921
|
+
*
|
|
922
|
+
* @api private
|
|
923
|
+
*/
|
|
924
|
+
}, {
|
|
925
|
+
key: "uri",
|
|
926
|
+
value: function uri() {
|
|
927
|
+
var query = this.query || {};
|
|
928
|
+
var schema = this.opts.secure ? "https" : "http";
|
|
929
|
+
var port = "";
|
|
930
|
+
if (false !== this.opts.timestampRequests) {
|
|
931
|
+
query[this.opts.timestampParam] = yeast();
|
|
932
|
+
}
|
|
933
|
+
if (!this.supportsBinary && !query.sid) {
|
|
934
|
+
query.b64 = 1;
|
|
935
|
+
}
|
|
936
|
+
if (this.opts.port && ("https" === schema && Number(this.opts.port) !== 443 || "http" === schema && Number(this.opts.port) !== 80)) {
|
|
937
|
+
port = ":" + this.opts.port;
|
|
938
|
+
}
|
|
939
|
+
var encodedQuery = encode(query);
|
|
940
|
+
var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
|
941
|
+
return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + (encodedQuery.length ? "?" + encodedQuery : "");
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Creates a request.
|
|
945
|
+
*
|
|
946
|
+
* @param {String} method
|
|
947
|
+
* @api private
|
|
948
|
+
*/
|
|
949
|
+
}, {
|
|
950
|
+
key: "request",
|
|
951
|
+
value: function request() {
|
|
952
|
+
var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
953
|
+
_extends(opts, {
|
|
954
|
+
xd: this.xd,
|
|
955
|
+
xs: this.xs
|
|
956
|
+
}, this.opts);
|
|
957
|
+
return new Request(this.uri(), opts);
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Sends data.
|
|
961
|
+
*
|
|
962
|
+
* @param {String} data to send.
|
|
963
|
+
* @param {Function} called upon flush.
|
|
964
|
+
* @api private
|
|
965
|
+
*/
|
|
966
|
+
}, {
|
|
967
|
+
key: "doWrite",
|
|
968
|
+
value: function doWrite(data, fn) {
|
|
969
|
+
var _this6 = this;
|
|
970
|
+
var req = this.request({
|
|
971
|
+
method: "POST",
|
|
972
|
+
data
|
|
973
|
+
});
|
|
974
|
+
req.on("success", fn);
|
|
975
|
+
req.on("error", function(xhrStatus, context) {
|
|
976
|
+
_this6.onError("xhr post error", xhrStatus, context);
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Starts a poll cycle.
|
|
981
|
+
*
|
|
982
|
+
* @api private
|
|
983
|
+
*/
|
|
984
|
+
}, {
|
|
985
|
+
key: "doPoll",
|
|
986
|
+
value: function doPoll() {
|
|
987
|
+
var _this7 = this;
|
|
988
|
+
var req = this.request();
|
|
989
|
+
req.on("data", this.onData.bind(this));
|
|
990
|
+
req.on("error", function(xhrStatus, context) {
|
|
991
|
+
_this7.onError("xhr poll error", xhrStatus, context);
|
|
992
|
+
});
|
|
993
|
+
this.pollXhr = req;
|
|
994
|
+
}
|
|
995
|
+
}]);
|
|
996
|
+
return Polling2;
|
|
997
|
+
}(Transport);
|
|
998
|
+
var Request = /* @__PURE__ */ function(_Emitter) {
|
|
999
|
+
_inherits(Request2, _Emitter);
|
|
1000
|
+
var _super2 = _createSuper(Request2);
|
|
1001
|
+
function Request2(uri, opts) {
|
|
1002
|
+
var _this8;
|
|
1003
|
+
_classCallCheck(this, Request2);
|
|
1004
|
+
_this8 = _super2.call(this);
|
|
1005
|
+
installTimerFunctions(_assertThisInitialized(_this8), opts);
|
|
1006
|
+
_this8.opts = opts;
|
|
1007
|
+
_this8.method = opts.method || "GET";
|
|
1008
|
+
_this8.uri = uri;
|
|
1009
|
+
_this8.async = false !== opts.async;
|
|
1010
|
+
_this8.data = void 0 !== opts.data ? opts.data : null;
|
|
1011
|
+
_this8.create();
|
|
1012
|
+
return _this8;
|
|
1013
|
+
}
|
|
1014
|
+
_createClass(Request2, [{
|
|
1015
|
+
key: "create",
|
|
1016
|
+
value: function create() {
|
|
1017
|
+
var _this9 = this;
|
|
1018
|
+
var opts = pick(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
1019
|
+
opts.xdomain = !!this.opts.xd;
|
|
1020
|
+
opts.xscheme = !!this.opts.xs;
|
|
1021
|
+
var xhr = this.xhr = new XHR(opts);
|
|
1022
|
+
try {
|
|
1023
|
+
xhr.open(this.method, this.uri, this.async);
|
|
1024
|
+
try {
|
|
1025
|
+
if (this.opts.extraHeaders) {
|
|
1026
|
+
xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
|
|
1027
|
+
for (var i2 in this.opts.extraHeaders) {
|
|
1028
|
+
if (this.opts.extraHeaders.hasOwnProperty(i2)) {
|
|
1029
|
+
xhr.setRequestHeader(i2, this.opts.extraHeaders[i2]);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
} catch (e) {
|
|
1034
|
+
}
|
|
1035
|
+
if ("POST" === this.method) {
|
|
1036
|
+
try {
|
|
1037
|
+
xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
|
|
1038
|
+
} catch (e) {
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
try {
|
|
1042
|
+
xhr.setRequestHeader("Accept", "*/*");
|
|
1043
|
+
} catch (e) {
|
|
1044
|
+
}
|
|
1045
|
+
if ("withCredentials" in xhr) {
|
|
1046
|
+
xhr.withCredentials = this.opts.withCredentials;
|
|
1047
|
+
}
|
|
1048
|
+
if (this.opts.requestTimeout) {
|
|
1049
|
+
xhr.timeout = this.opts.requestTimeout;
|
|
1050
|
+
}
|
|
1051
|
+
xhr.onreadystatechange = function() {
|
|
1052
|
+
if (4 !== xhr.readyState)
|
|
1053
|
+
return;
|
|
1054
|
+
if (200 === xhr.status || 1223 === xhr.status) {
|
|
1055
|
+
_this9.onLoad();
|
|
1056
|
+
} else {
|
|
1057
|
+
_this9.setTimeoutFn(function() {
|
|
1058
|
+
_this9.onError(typeof xhr.status === "number" ? xhr.status : 0);
|
|
1059
|
+
}, 0);
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
xhr.send(this.data);
|
|
1063
|
+
} catch (e) {
|
|
1064
|
+
this.setTimeoutFn(function() {
|
|
1065
|
+
_this9.onError(e);
|
|
1066
|
+
}, 0);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (typeof document !== "undefined") {
|
|
1070
|
+
this.index = Request2.requestsCount++;
|
|
1071
|
+
Request2.requests[this.index] = this;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Called upon error.
|
|
1076
|
+
*
|
|
1077
|
+
* @api private
|
|
1078
|
+
*/
|
|
1079
|
+
}, {
|
|
1080
|
+
key: "onError",
|
|
1081
|
+
value: function onError(err) {
|
|
1082
|
+
this.emitReserved("error", err, this.xhr);
|
|
1083
|
+
this.cleanup(true);
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Cleans up house.
|
|
1087
|
+
*
|
|
1088
|
+
* @api private
|
|
1089
|
+
*/
|
|
1090
|
+
}, {
|
|
1091
|
+
key: "cleanup",
|
|
1092
|
+
value: function cleanup(fromError) {
|
|
1093
|
+
if ("undefined" === typeof this.xhr || null === this.xhr) {
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
this.xhr.onreadystatechange = empty;
|
|
1097
|
+
if (fromError) {
|
|
1098
|
+
try {
|
|
1099
|
+
this.xhr.abort();
|
|
1100
|
+
} catch (e) {
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
if (typeof document !== "undefined") {
|
|
1104
|
+
delete Request2.requests[this.index];
|
|
1105
|
+
}
|
|
1106
|
+
this.xhr = null;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Called upon load.
|
|
1110
|
+
*
|
|
1111
|
+
* @api private
|
|
1112
|
+
*/
|
|
1113
|
+
}, {
|
|
1114
|
+
key: "onLoad",
|
|
1115
|
+
value: function onLoad() {
|
|
1116
|
+
var data = this.xhr.responseText;
|
|
1117
|
+
if (data !== null) {
|
|
1118
|
+
this.emitReserved("data", data);
|
|
1119
|
+
this.emitReserved("success");
|
|
1120
|
+
this.cleanup();
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Aborts the request.
|
|
1125
|
+
*
|
|
1126
|
+
* @api public
|
|
1127
|
+
*/
|
|
1128
|
+
}, {
|
|
1129
|
+
key: "abort",
|
|
1130
|
+
value: function abort() {
|
|
1131
|
+
this.cleanup();
|
|
1132
|
+
}
|
|
1133
|
+
}]);
|
|
1134
|
+
return Request2;
|
|
1135
|
+
}(Emitter);
|
|
1136
|
+
Request.requestsCount = 0;
|
|
1137
|
+
Request.requests = {};
|
|
1138
|
+
if (typeof document !== "undefined") {
|
|
1139
|
+
if (typeof attachEvent === "function") {
|
|
1140
|
+
attachEvent("onunload", unloadHandler);
|
|
1141
|
+
} else if (typeof addEventListener === "function") {
|
|
1142
|
+
var terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
|
|
1143
|
+
addEventListener(terminationEvent, unloadHandler, false);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
function unloadHandler() {
|
|
1147
|
+
for (var i2 in Request.requests) {
|
|
1148
|
+
if (Request.requests.hasOwnProperty(i2)) {
|
|
1149
|
+
Request.requests[i2].abort();
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
var nextTick = function() {
|
|
1154
|
+
var isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
|
|
1155
|
+
if (isPromiseAvailable) {
|
|
1156
|
+
return function(cb) {
|
|
1157
|
+
return Promise.resolve().then(cb);
|
|
1158
|
+
};
|
|
1159
|
+
} else {
|
|
1160
|
+
return function(cb, setTimeoutFn) {
|
|
1161
|
+
return setTimeoutFn(cb, 0);
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
}();
|
|
1165
|
+
var WebSocket = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
|
|
1166
|
+
var usingBrowserWebSocket = true;
|
|
1167
|
+
var defaultBinaryType = "arraybuffer";
|
|
1168
|
+
var isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
|
|
1169
|
+
var WS = /* @__PURE__ */ function(_Transport) {
|
|
1170
|
+
_inherits(WS2, _Transport);
|
|
1171
|
+
var _super = _createSuper(WS2);
|
|
1172
|
+
function WS2(opts) {
|
|
1173
|
+
var _this;
|
|
1174
|
+
_classCallCheck(this, WS2);
|
|
1175
|
+
_this = _super.call(this, opts);
|
|
1176
|
+
_this.supportsBinary = !opts.forceBase64;
|
|
1177
|
+
return _this;
|
|
1178
|
+
}
|
|
1179
|
+
_createClass(WS2, [{
|
|
1180
|
+
key: "name",
|
|
1181
|
+
get: function get() {
|
|
1182
|
+
return "websocket";
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Opens socket.
|
|
1186
|
+
*
|
|
1187
|
+
* @api private
|
|
1188
|
+
*/
|
|
1189
|
+
}, {
|
|
1190
|
+
key: "doOpen",
|
|
1191
|
+
value: function doOpen() {
|
|
1192
|
+
if (!this.check()) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
var uri = this.uri();
|
|
1196
|
+
var protocols = this.opts.protocols;
|
|
1197
|
+
var opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
1198
|
+
if (this.opts.extraHeaders) {
|
|
1199
|
+
opts.headers = this.opts.extraHeaders;
|
|
1200
|
+
}
|
|
1201
|
+
try {
|
|
1202
|
+
this.ws = usingBrowserWebSocket && !isReactNative ? protocols ? new WebSocket(uri, protocols) : new WebSocket(uri) : new WebSocket(uri, protocols, opts);
|
|
1203
|
+
} catch (err) {
|
|
1204
|
+
return this.emitReserved("error", err);
|
|
1205
|
+
}
|
|
1206
|
+
this.ws.binaryType = this.socket.binaryType || defaultBinaryType;
|
|
1207
|
+
this.addEventListeners();
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Adds event listeners to the socket
|
|
1211
|
+
*
|
|
1212
|
+
* @api private
|
|
1213
|
+
*/
|
|
1214
|
+
}, {
|
|
1215
|
+
key: "addEventListeners",
|
|
1216
|
+
value: function addEventListeners() {
|
|
1217
|
+
var _this2 = this;
|
|
1218
|
+
this.ws.onopen = function() {
|
|
1219
|
+
if (_this2.opts.autoUnref) {
|
|
1220
|
+
_this2.ws._socket.unref();
|
|
1221
|
+
}
|
|
1222
|
+
_this2.onOpen();
|
|
1223
|
+
};
|
|
1224
|
+
this.ws.onclose = function(closeEvent) {
|
|
1225
|
+
return _this2.onClose({
|
|
1226
|
+
description: "websocket connection closed",
|
|
1227
|
+
context: closeEvent
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1230
|
+
this.ws.onmessage = function(ev) {
|
|
1231
|
+
return _this2.onData(ev.data);
|
|
1232
|
+
};
|
|
1233
|
+
this.ws.onerror = function(e) {
|
|
1234
|
+
return _this2.onError("websocket error", e);
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Writes data to socket.
|
|
1239
|
+
*
|
|
1240
|
+
* @param {Array} array of packets.
|
|
1241
|
+
* @api private
|
|
1242
|
+
*/
|
|
1243
|
+
}, {
|
|
1244
|
+
key: "write",
|
|
1245
|
+
value: function write(packets) {
|
|
1246
|
+
var _this3 = this;
|
|
1247
|
+
this.writable = false;
|
|
1248
|
+
var _loop = function _loop2(i3) {
|
|
1249
|
+
var packet = packets[i3];
|
|
1250
|
+
var lastPacket = i3 === packets.length - 1;
|
|
1251
|
+
encodePacket(packet, _this3.supportsBinary, function(data) {
|
|
1252
|
+
var opts = {};
|
|
1253
|
+
try {
|
|
1254
|
+
if (usingBrowserWebSocket) {
|
|
1255
|
+
_this3.ws.send(data);
|
|
1256
|
+
}
|
|
1257
|
+
} catch (e) {
|
|
1258
|
+
}
|
|
1259
|
+
if (lastPacket) {
|
|
1260
|
+
nextTick(function() {
|
|
1261
|
+
_this3.writable = true;
|
|
1262
|
+
_this3.emitReserved("drain");
|
|
1263
|
+
}, _this3.setTimeoutFn);
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
};
|
|
1267
|
+
for (var i2 = 0; i2 < packets.length; i2++) {
|
|
1268
|
+
_loop(i2);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Closes socket.
|
|
1273
|
+
*
|
|
1274
|
+
* @api private
|
|
1275
|
+
*/
|
|
1276
|
+
}, {
|
|
1277
|
+
key: "doClose",
|
|
1278
|
+
value: function doClose() {
|
|
1279
|
+
if (typeof this.ws !== "undefined") {
|
|
1280
|
+
this.ws.close();
|
|
1281
|
+
this.ws = null;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Generates uri for connection.
|
|
1286
|
+
*
|
|
1287
|
+
* @api private
|
|
1288
|
+
*/
|
|
1289
|
+
}, {
|
|
1290
|
+
key: "uri",
|
|
1291
|
+
value: function uri() {
|
|
1292
|
+
var query = this.query || {};
|
|
1293
|
+
var schema = this.opts.secure ? "wss" : "ws";
|
|
1294
|
+
var port = "";
|
|
1295
|
+
if (this.opts.port && ("wss" === schema && Number(this.opts.port) !== 443 || "ws" === schema && Number(this.opts.port) !== 80)) {
|
|
1296
|
+
port = ":" + this.opts.port;
|
|
1297
|
+
}
|
|
1298
|
+
if (this.opts.timestampRequests) {
|
|
1299
|
+
query[this.opts.timestampParam] = yeast();
|
|
1300
|
+
}
|
|
1301
|
+
if (!this.supportsBinary) {
|
|
1302
|
+
query.b64 = 1;
|
|
1303
|
+
}
|
|
1304
|
+
var encodedQuery = encode(query);
|
|
1305
|
+
var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
|
1306
|
+
return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + (encodedQuery.length ? "?" + encodedQuery : "");
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Feature detection for WebSocket.
|
|
1310
|
+
*
|
|
1311
|
+
* @return {Boolean} whether this transport is available.
|
|
1312
|
+
* @api public
|
|
1313
|
+
*/
|
|
1314
|
+
}, {
|
|
1315
|
+
key: "check",
|
|
1316
|
+
value: function check() {
|
|
1317
|
+
return !!WebSocket;
|
|
1318
|
+
}
|
|
1319
|
+
}]);
|
|
1320
|
+
return WS2;
|
|
1321
|
+
}(Transport);
|
|
1322
|
+
var transports = {
|
|
1323
|
+
websocket: WS,
|
|
1324
|
+
polling: Polling
|
|
1325
|
+
};
|
|
1326
|
+
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
|
|
1327
|
+
var parts = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"];
|
|
1328
|
+
function parse(str) {
|
|
1329
|
+
var src = str, b = str.indexOf("["), e = str.indexOf("]");
|
|
1330
|
+
if (b != -1 && e != -1) {
|
|
1331
|
+
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length);
|
|
1332
|
+
}
|
|
1333
|
+
var m = re.exec(str || ""), uri = {}, i2 = 14;
|
|
1334
|
+
while (i2--) {
|
|
1335
|
+
uri[parts[i2]] = m[i2] || "";
|
|
1336
|
+
}
|
|
1337
|
+
if (b != -1 && e != -1) {
|
|
1338
|
+
uri.source = src;
|
|
1339
|
+
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":");
|
|
1340
|
+
uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":");
|
|
1341
|
+
uri.ipv6uri = true;
|
|
1342
|
+
}
|
|
1343
|
+
uri.pathNames = pathNames(uri, uri["path"]);
|
|
1344
|
+
uri.queryKey = queryKey(uri, uri["query"]);
|
|
1345
|
+
return uri;
|
|
1346
|
+
}
|
|
1347
|
+
function pathNames(obj2, path) {
|
|
1348
|
+
var regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/");
|
|
1349
|
+
if (path.slice(0, 1) == "/" || path.length === 0) {
|
|
1350
|
+
names.splice(0, 1);
|
|
1351
|
+
}
|
|
1352
|
+
if (path.slice(-1) == "/") {
|
|
1353
|
+
names.splice(names.length - 1, 1);
|
|
1354
|
+
}
|
|
1355
|
+
return names;
|
|
1356
|
+
}
|
|
1357
|
+
function queryKey(uri, query) {
|
|
1358
|
+
var data = {};
|
|
1359
|
+
query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) {
|
|
1360
|
+
if ($1) {
|
|
1361
|
+
data[$1] = $2;
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
return data;
|
|
1365
|
+
}
|
|
1366
|
+
var Socket$1 = /* @__PURE__ */ function(_Emitter) {
|
|
1367
|
+
_inherits(Socket2, _Emitter);
|
|
1368
|
+
var _super = _createSuper(Socket2);
|
|
1369
|
+
function Socket2(uri) {
|
|
1370
|
+
var _this;
|
|
1371
|
+
var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1372
|
+
_classCallCheck(this, Socket2);
|
|
1373
|
+
_this = _super.call(this);
|
|
1374
|
+
if (uri && "object" === _typeof(uri)) {
|
|
1375
|
+
opts = uri;
|
|
1376
|
+
uri = null;
|
|
1377
|
+
}
|
|
1378
|
+
if (uri) {
|
|
1379
|
+
uri = parse(uri);
|
|
1380
|
+
opts.hostname = uri.host;
|
|
1381
|
+
opts.secure = uri.protocol === "https" || uri.protocol === "wss";
|
|
1382
|
+
opts.port = uri.port;
|
|
1383
|
+
if (uri.query)
|
|
1384
|
+
opts.query = uri.query;
|
|
1385
|
+
} else if (opts.host) {
|
|
1386
|
+
opts.hostname = parse(opts.host).host;
|
|
1387
|
+
}
|
|
1388
|
+
installTimerFunctions(_assertThisInitialized(_this), opts);
|
|
1389
|
+
_this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;
|
|
1390
|
+
if (opts.hostname && !opts.port) {
|
|
1391
|
+
opts.port = _this.secure ? "443" : "80";
|
|
1392
|
+
}
|
|
1393
|
+
_this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
|
|
1394
|
+
_this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : _this.secure ? "443" : "80");
|
|
1395
|
+
_this.transports = opts.transports || ["polling", "websocket"];
|
|
1396
|
+
_this.readyState = "";
|
|
1397
|
+
_this.writeBuffer = [];
|
|
1398
|
+
_this.prevBufferLen = 0;
|
|
1399
|
+
_this.opts = _extends({
|
|
1400
|
+
path: "/engine.io",
|
|
1401
|
+
agent: false,
|
|
1402
|
+
withCredentials: false,
|
|
1403
|
+
upgrade: true,
|
|
1404
|
+
timestampParam: "t",
|
|
1405
|
+
rememberUpgrade: false,
|
|
1406
|
+
rejectUnauthorized: true,
|
|
1407
|
+
perMessageDeflate: {
|
|
1408
|
+
threshold: 1024
|
|
1409
|
+
},
|
|
1410
|
+
transportOptions: {},
|
|
1411
|
+
closeOnBeforeunload: true
|
|
1412
|
+
}, opts);
|
|
1413
|
+
_this.opts.path = _this.opts.path.replace(/\/$/, "") + "/";
|
|
1414
|
+
if (typeof _this.opts.query === "string") {
|
|
1415
|
+
_this.opts.query = decode(_this.opts.query);
|
|
1416
|
+
}
|
|
1417
|
+
_this.id = null;
|
|
1418
|
+
_this.upgrades = null;
|
|
1419
|
+
_this.pingInterval = null;
|
|
1420
|
+
_this.pingTimeout = null;
|
|
1421
|
+
_this.pingTimeoutTimer = null;
|
|
1422
|
+
if (typeof addEventListener === "function") {
|
|
1423
|
+
if (_this.opts.closeOnBeforeunload) {
|
|
1424
|
+
_this.beforeunloadEventListener = function() {
|
|
1425
|
+
if (_this.transport) {
|
|
1426
|
+
_this.transport.removeAllListeners();
|
|
1427
|
+
_this.transport.close();
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
addEventListener("beforeunload", _this.beforeunloadEventListener, false);
|
|
1431
|
+
}
|
|
1432
|
+
if (_this.hostname !== "localhost") {
|
|
1433
|
+
_this.offlineEventListener = function() {
|
|
1434
|
+
_this.onClose("transport close", {
|
|
1435
|
+
description: "network connection lost"
|
|
1436
|
+
});
|
|
1437
|
+
};
|
|
1438
|
+
addEventListener("offline", _this.offlineEventListener, false);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
_this.open();
|
|
1442
|
+
return _this;
|
|
1443
|
+
}
|
|
1444
|
+
_createClass(Socket2, [{
|
|
1445
|
+
key: "createTransport",
|
|
1446
|
+
value: function createTransport(name) {
|
|
1447
|
+
var query = _extends({}, this.opts.query);
|
|
1448
|
+
query.EIO = protocol$1;
|
|
1449
|
+
query.transport = name;
|
|
1450
|
+
if (this.id)
|
|
1451
|
+
query.sid = this.id;
|
|
1452
|
+
var opts = _extends({}, this.opts.transportOptions[name], this.opts, {
|
|
1453
|
+
query,
|
|
1454
|
+
socket: this,
|
|
1455
|
+
hostname: this.hostname,
|
|
1456
|
+
secure: this.secure,
|
|
1457
|
+
port: this.port
|
|
1458
|
+
});
|
|
1459
|
+
return new transports[name](opts);
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Initializes transport to use and starts probe.
|
|
1463
|
+
*
|
|
1464
|
+
* @api private
|
|
1465
|
+
*/
|
|
1466
|
+
}, {
|
|
1467
|
+
key: "open",
|
|
1468
|
+
value: function open() {
|
|
1469
|
+
var _this2 = this;
|
|
1470
|
+
var transport;
|
|
1471
|
+
if (this.opts.rememberUpgrade && Socket2.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1) {
|
|
1472
|
+
transport = "websocket";
|
|
1473
|
+
} else if (0 === this.transports.length) {
|
|
1474
|
+
this.setTimeoutFn(function() {
|
|
1475
|
+
_this2.emitReserved("error", "No transports available");
|
|
1476
|
+
}, 0);
|
|
1477
|
+
return;
|
|
1478
|
+
} else {
|
|
1479
|
+
transport = this.transports[0];
|
|
1480
|
+
}
|
|
1481
|
+
this.readyState = "opening";
|
|
1482
|
+
try {
|
|
1483
|
+
transport = this.createTransport(transport);
|
|
1484
|
+
} catch (e) {
|
|
1485
|
+
this.transports.shift();
|
|
1486
|
+
this.open();
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
transport.open();
|
|
1490
|
+
this.setTransport(transport);
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Sets the current transport. Disables the existing one (if any).
|
|
1494
|
+
*
|
|
1495
|
+
* @api private
|
|
1496
|
+
*/
|
|
1497
|
+
}, {
|
|
1498
|
+
key: "setTransport",
|
|
1499
|
+
value: function setTransport(transport) {
|
|
1500
|
+
var _this3 = this;
|
|
1501
|
+
if (this.transport) {
|
|
1502
|
+
this.transport.removeAllListeners();
|
|
1503
|
+
}
|
|
1504
|
+
this.transport = transport;
|
|
1505
|
+
transport.on("drain", this.onDrain.bind(this)).on("packet", this.onPacket.bind(this)).on("error", this.onError.bind(this)).on("close", function(reason) {
|
|
1506
|
+
return _this3.onClose("transport close", reason);
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Probes a transport.
|
|
1511
|
+
*
|
|
1512
|
+
* @param {String} transport name
|
|
1513
|
+
* @api private
|
|
1514
|
+
*/
|
|
1515
|
+
}, {
|
|
1516
|
+
key: "probe",
|
|
1517
|
+
value: function probe(name) {
|
|
1518
|
+
var _this4 = this;
|
|
1519
|
+
var transport = this.createTransport(name);
|
|
1520
|
+
var failed = false;
|
|
1521
|
+
Socket2.priorWebsocketSuccess = false;
|
|
1522
|
+
var onTransportOpen = function onTransportOpen2() {
|
|
1523
|
+
if (failed)
|
|
1524
|
+
return;
|
|
1525
|
+
transport.send([{
|
|
1526
|
+
type: "ping",
|
|
1527
|
+
data: "probe"
|
|
1528
|
+
}]);
|
|
1529
|
+
transport.once("packet", function(msg) {
|
|
1530
|
+
if (failed)
|
|
1531
|
+
return;
|
|
1532
|
+
if ("pong" === msg.type && "probe" === msg.data) {
|
|
1533
|
+
_this4.upgrading = true;
|
|
1534
|
+
_this4.emitReserved("upgrading", transport);
|
|
1535
|
+
if (!transport)
|
|
1536
|
+
return;
|
|
1537
|
+
Socket2.priorWebsocketSuccess = "websocket" === transport.name;
|
|
1538
|
+
_this4.transport.pause(function() {
|
|
1539
|
+
if (failed)
|
|
1540
|
+
return;
|
|
1541
|
+
if ("closed" === _this4.readyState)
|
|
1542
|
+
return;
|
|
1543
|
+
cleanup();
|
|
1544
|
+
_this4.setTransport(transport);
|
|
1545
|
+
transport.send([{
|
|
1546
|
+
type: "upgrade"
|
|
1547
|
+
}]);
|
|
1548
|
+
_this4.emitReserved("upgrade", transport);
|
|
1549
|
+
transport = null;
|
|
1550
|
+
_this4.upgrading = false;
|
|
1551
|
+
_this4.flush();
|
|
1552
|
+
});
|
|
1553
|
+
} else {
|
|
1554
|
+
var err = new Error("probe error");
|
|
1555
|
+
err.transport = transport.name;
|
|
1556
|
+
_this4.emitReserved("upgradeError", err);
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
};
|
|
1560
|
+
function freezeTransport() {
|
|
1561
|
+
if (failed)
|
|
1562
|
+
return;
|
|
1563
|
+
failed = true;
|
|
1564
|
+
cleanup();
|
|
1565
|
+
transport.close();
|
|
1566
|
+
transport = null;
|
|
1567
|
+
}
|
|
1568
|
+
var onerror = function onerror2(err) {
|
|
1569
|
+
var error = new Error("probe error: " + err);
|
|
1570
|
+
error.transport = transport.name;
|
|
1571
|
+
freezeTransport();
|
|
1572
|
+
_this4.emitReserved("upgradeError", error);
|
|
1573
|
+
};
|
|
1574
|
+
function onTransportClose() {
|
|
1575
|
+
onerror("transport closed");
|
|
1576
|
+
}
|
|
1577
|
+
function onclose() {
|
|
1578
|
+
onerror("socket closed");
|
|
1579
|
+
}
|
|
1580
|
+
function onupgrade(to) {
|
|
1581
|
+
if (transport && to.name !== transport.name) {
|
|
1582
|
+
freezeTransport();
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
var cleanup = function cleanup2() {
|
|
1586
|
+
transport.removeListener("open", onTransportOpen);
|
|
1587
|
+
transport.removeListener("error", onerror);
|
|
1588
|
+
transport.removeListener("close", onTransportClose);
|
|
1589
|
+
_this4.off("close", onclose);
|
|
1590
|
+
_this4.off("upgrading", onupgrade);
|
|
1591
|
+
};
|
|
1592
|
+
transport.once("open", onTransportOpen);
|
|
1593
|
+
transport.once("error", onerror);
|
|
1594
|
+
transport.once("close", onTransportClose);
|
|
1595
|
+
this.once("close", onclose);
|
|
1596
|
+
this.once("upgrading", onupgrade);
|
|
1597
|
+
transport.open();
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Called when connection is deemed open.
|
|
1601
|
+
*
|
|
1602
|
+
* @api private
|
|
1603
|
+
*/
|
|
1604
|
+
}, {
|
|
1605
|
+
key: "onOpen",
|
|
1606
|
+
value: function onOpen() {
|
|
1607
|
+
this.readyState = "open";
|
|
1608
|
+
Socket2.priorWebsocketSuccess = "websocket" === this.transport.name;
|
|
1609
|
+
this.emitReserved("open");
|
|
1610
|
+
this.flush();
|
|
1611
|
+
if ("open" === this.readyState && this.opts.upgrade && this.transport.pause) {
|
|
1612
|
+
var i2 = 0;
|
|
1613
|
+
var l = this.upgrades.length;
|
|
1614
|
+
for (; i2 < l; i2++) {
|
|
1615
|
+
this.probe(this.upgrades[i2]);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Handles a packet.
|
|
1621
|
+
*
|
|
1622
|
+
* @api private
|
|
1623
|
+
*/
|
|
1624
|
+
}, {
|
|
1625
|
+
key: "onPacket",
|
|
1626
|
+
value: function onPacket(packet) {
|
|
1627
|
+
if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
|
|
1628
|
+
this.emitReserved("packet", packet);
|
|
1629
|
+
this.emitReserved("heartbeat");
|
|
1630
|
+
switch (packet.type) {
|
|
1631
|
+
case "open":
|
|
1632
|
+
this.onHandshake(JSON.parse(packet.data));
|
|
1633
|
+
break;
|
|
1634
|
+
case "ping":
|
|
1635
|
+
this.resetPingTimeout();
|
|
1636
|
+
this.sendPacket("pong");
|
|
1637
|
+
this.emitReserved("ping");
|
|
1638
|
+
this.emitReserved("pong");
|
|
1639
|
+
break;
|
|
1640
|
+
case "error":
|
|
1641
|
+
var err = new Error("server error");
|
|
1642
|
+
err.code = packet.data;
|
|
1643
|
+
this.onError(err);
|
|
1644
|
+
break;
|
|
1645
|
+
case "message":
|
|
1646
|
+
this.emitReserved("data", packet.data);
|
|
1647
|
+
this.emitReserved("message", packet.data);
|
|
1648
|
+
break;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Called upon handshake completion.
|
|
1654
|
+
*
|
|
1655
|
+
* @param {Object} data - handshake obj
|
|
1656
|
+
* @api private
|
|
1657
|
+
*/
|
|
1658
|
+
}, {
|
|
1659
|
+
key: "onHandshake",
|
|
1660
|
+
value: function onHandshake(data) {
|
|
1661
|
+
this.emitReserved("handshake", data);
|
|
1662
|
+
this.id = data.sid;
|
|
1663
|
+
this.transport.query.sid = data.sid;
|
|
1664
|
+
this.upgrades = this.filterUpgrades(data.upgrades);
|
|
1665
|
+
this.pingInterval = data.pingInterval;
|
|
1666
|
+
this.pingTimeout = data.pingTimeout;
|
|
1667
|
+
this.maxPayload = data.maxPayload;
|
|
1668
|
+
this.onOpen();
|
|
1669
|
+
if ("closed" === this.readyState)
|
|
1670
|
+
return;
|
|
1671
|
+
this.resetPingTimeout();
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Sets and resets ping timeout timer based on server pings.
|
|
1675
|
+
*
|
|
1676
|
+
* @api private
|
|
1677
|
+
*/
|
|
1678
|
+
}, {
|
|
1679
|
+
key: "resetPingTimeout",
|
|
1680
|
+
value: function resetPingTimeout() {
|
|
1681
|
+
var _this5 = this;
|
|
1682
|
+
this.clearTimeoutFn(this.pingTimeoutTimer);
|
|
1683
|
+
this.pingTimeoutTimer = this.setTimeoutFn(function() {
|
|
1684
|
+
_this5.onClose("ping timeout");
|
|
1685
|
+
}, this.pingInterval + this.pingTimeout);
|
|
1686
|
+
if (this.opts.autoUnref) {
|
|
1687
|
+
this.pingTimeoutTimer.unref();
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Called on `drain` event
|
|
1692
|
+
*
|
|
1693
|
+
* @api private
|
|
1694
|
+
*/
|
|
1695
|
+
}, {
|
|
1696
|
+
key: "onDrain",
|
|
1697
|
+
value: function onDrain() {
|
|
1698
|
+
this.writeBuffer.splice(0, this.prevBufferLen);
|
|
1699
|
+
this.prevBufferLen = 0;
|
|
1700
|
+
if (0 === this.writeBuffer.length) {
|
|
1701
|
+
this.emitReserved("drain");
|
|
1702
|
+
} else {
|
|
1703
|
+
this.flush();
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Flush write buffers.
|
|
1708
|
+
*
|
|
1709
|
+
* @api private
|
|
1710
|
+
*/
|
|
1711
|
+
}, {
|
|
1712
|
+
key: "flush",
|
|
1713
|
+
value: function flush() {
|
|
1714
|
+
if ("closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
|
|
1715
|
+
var packets = this.getWritablePackets();
|
|
1716
|
+
this.transport.send(packets);
|
|
1717
|
+
this.prevBufferLen = packets.length;
|
|
1718
|
+
this.emitReserved("flush");
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP
|
|
1723
|
+
* long-polling)
|
|
1724
|
+
*
|
|
1725
|
+
* @private
|
|
1726
|
+
*/
|
|
1727
|
+
}, {
|
|
1728
|
+
key: "getWritablePackets",
|
|
1729
|
+
value: function getWritablePackets() {
|
|
1730
|
+
var shouldCheckPayloadSize = this.maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1;
|
|
1731
|
+
if (!shouldCheckPayloadSize) {
|
|
1732
|
+
return this.writeBuffer;
|
|
1733
|
+
}
|
|
1734
|
+
var payloadSize = 1;
|
|
1735
|
+
for (var i2 = 0; i2 < this.writeBuffer.length; i2++) {
|
|
1736
|
+
var data = this.writeBuffer[i2].data;
|
|
1737
|
+
if (data) {
|
|
1738
|
+
payloadSize += byteLength(data);
|
|
1739
|
+
}
|
|
1740
|
+
if (i2 > 0 && payloadSize > this.maxPayload) {
|
|
1741
|
+
return this.writeBuffer.slice(0, i2);
|
|
1742
|
+
}
|
|
1743
|
+
payloadSize += 2;
|
|
1744
|
+
}
|
|
1745
|
+
return this.writeBuffer;
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Sends a message.
|
|
1749
|
+
*
|
|
1750
|
+
* @param {String} message.
|
|
1751
|
+
* @param {Function} callback function.
|
|
1752
|
+
* @param {Object} options.
|
|
1753
|
+
* @return {Socket} for chaining.
|
|
1754
|
+
* @api public
|
|
1755
|
+
*/
|
|
1756
|
+
}, {
|
|
1757
|
+
key: "write",
|
|
1758
|
+
value: function write(msg, options, fn) {
|
|
1759
|
+
this.sendPacket("message", msg, options, fn);
|
|
1760
|
+
return this;
|
|
1761
|
+
}
|
|
1762
|
+
}, {
|
|
1763
|
+
key: "send",
|
|
1764
|
+
value: function send2(msg, options, fn) {
|
|
1765
|
+
this.sendPacket("message", msg, options, fn);
|
|
1766
|
+
return this;
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Sends a packet.
|
|
1770
|
+
*
|
|
1771
|
+
* @param {String} packet type.
|
|
1772
|
+
* @param {String} data.
|
|
1773
|
+
* @param {Object} options.
|
|
1774
|
+
* @param {Function} callback function.
|
|
1775
|
+
* @api private
|
|
1776
|
+
*/
|
|
1777
|
+
}, {
|
|
1778
|
+
key: "sendPacket",
|
|
1779
|
+
value: function sendPacket(type, data, options, fn) {
|
|
1780
|
+
if ("function" === typeof data) {
|
|
1781
|
+
fn = data;
|
|
1782
|
+
data = void 0;
|
|
1783
|
+
}
|
|
1784
|
+
if ("function" === typeof options) {
|
|
1785
|
+
fn = options;
|
|
1786
|
+
options = null;
|
|
1787
|
+
}
|
|
1788
|
+
if ("closing" === this.readyState || "closed" === this.readyState) {
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
options = options || {};
|
|
1792
|
+
options.compress = false !== options.compress;
|
|
1793
|
+
var packet = {
|
|
1794
|
+
type,
|
|
1795
|
+
data,
|
|
1796
|
+
options
|
|
1797
|
+
};
|
|
1798
|
+
this.emitReserved("packetCreate", packet);
|
|
1799
|
+
this.writeBuffer.push(packet);
|
|
1800
|
+
if (fn)
|
|
1801
|
+
this.once("flush", fn);
|
|
1802
|
+
this.flush();
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Closes the connection.
|
|
1806
|
+
*
|
|
1807
|
+
* @api public
|
|
1808
|
+
*/
|
|
1809
|
+
}, {
|
|
1810
|
+
key: "close",
|
|
1811
|
+
value: function close() {
|
|
1812
|
+
var _this6 = this;
|
|
1813
|
+
var close2 = function close3() {
|
|
1814
|
+
_this6.onClose("forced close");
|
|
1815
|
+
_this6.transport.close();
|
|
1816
|
+
};
|
|
1817
|
+
var cleanupAndClose = function cleanupAndClose2() {
|
|
1818
|
+
_this6.off("upgrade", cleanupAndClose2);
|
|
1819
|
+
_this6.off("upgradeError", cleanupAndClose2);
|
|
1820
|
+
close2();
|
|
1821
|
+
};
|
|
1822
|
+
var waitForUpgrade = function waitForUpgrade2() {
|
|
1823
|
+
_this6.once("upgrade", cleanupAndClose);
|
|
1824
|
+
_this6.once("upgradeError", cleanupAndClose);
|
|
1825
|
+
};
|
|
1826
|
+
if ("opening" === this.readyState || "open" === this.readyState) {
|
|
1827
|
+
this.readyState = "closing";
|
|
1828
|
+
if (this.writeBuffer.length) {
|
|
1829
|
+
this.once("drain", function() {
|
|
1830
|
+
if (_this6.upgrading) {
|
|
1831
|
+
waitForUpgrade();
|
|
1832
|
+
} else {
|
|
1833
|
+
close2();
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
} else if (this.upgrading) {
|
|
1837
|
+
waitForUpgrade();
|
|
1838
|
+
} else {
|
|
1839
|
+
close2();
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
return this;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Called upon transport error
|
|
1846
|
+
*
|
|
1847
|
+
* @api private
|
|
1848
|
+
*/
|
|
1849
|
+
}, {
|
|
1850
|
+
key: "onError",
|
|
1851
|
+
value: function onError(err) {
|
|
1852
|
+
Socket2.priorWebsocketSuccess = false;
|
|
1853
|
+
this.emitReserved("error", err);
|
|
1854
|
+
this.onClose("transport error", err);
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Called upon transport close.
|
|
1858
|
+
*
|
|
1859
|
+
* @api private
|
|
1860
|
+
*/
|
|
1861
|
+
}, {
|
|
1862
|
+
key: "onClose",
|
|
1863
|
+
value: function onClose(reason, description) {
|
|
1864
|
+
if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
|
|
1865
|
+
this.clearTimeoutFn(this.pingTimeoutTimer);
|
|
1866
|
+
this.transport.removeAllListeners("close");
|
|
1867
|
+
this.transport.close();
|
|
1868
|
+
this.transport.removeAllListeners();
|
|
1869
|
+
if (typeof removeEventListener === "function") {
|
|
1870
|
+
removeEventListener("beforeunload", this.beforeunloadEventListener, false);
|
|
1871
|
+
removeEventListener("offline", this.offlineEventListener, false);
|
|
1872
|
+
}
|
|
1873
|
+
this.readyState = "closed";
|
|
1874
|
+
this.id = null;
|
|
1875
|
+
this.emitReserved("close", reason, description);
|
|
1876
|
+
this.writeBuffer = [];
|
|
1877
|
+
this.prevBufferLen = 0;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Filters upgrades, returning only those matching client transports.
|
|
1882
|
+
*
|
|
1883
|
+
* @param {Array} server upgrades
|
|
1884
|
+
* @api private
|
|
1885
|
+
*
|
|
1886
|
+
*/
|
|
1887
|
+
}, {
|
|
1888
|
+
key: "filterUpgrades",
|
|
1889
|
+
value: function filterUpgrades(upgrades) {
|
|
1890
|
+
var filteredUpgrades = [];
|
|
1891
|
+
var i2 = 0;
|
|
1892
|
+
var j = upgrades.length;
|
|
1893
|
+
for (; i2 < j; i2++) {
|
|
1894
|
+
if (~this.transports.indexOf(upgrades[i2]))
|
|
1895
|
+
filteredUpgrades.push(upgrades[i2]);
|
|
1896
|
+
}
|
|
1897
|
+
return filteredUpgrades;
|
|
1898
|
+
}
|
|
1899
|
+
}]);
|
|
1900
|
+
return Socket2;
|
|
1901
|
+
}(Emitter);
|
|
1902
|
+
Socket$1.protocol = protocol$1;
|
|
1903
|
+
Socket$1.protocol;
|
|
1904
|
+
function url(uri) {
|
|
1905
|
+
var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
1906
|
+
var loc = arguments.length > 2 ? arguments[2] : void 0;
|
|
1907
|
+
var obj2 = uri;
|
|
1908
|
+
loc = loc || typeof location !== "undefined" && location;
|
|
1909
|
+
if (null == uri)
|
|
1910
|
+
uri = loc.protocol + "//" + loc.host;
|
|
1911
|
+
if (typeof uri === "string") {
|
|
1912
|
+
if ("/" === uri.charAt(0)) {
|
|
1913
|
+
if ("/" === uri.charAt(1)) {
|
|
1914
|
+
uri = loc.protocol + uri;
|
|
1915
|
+
} else {
|
|
1916
|
+
uri = loc.host + uri;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
if (!/^(https?|wss?):\/\//.test(uri)) {
|
|
1920
|
+
if ("undefined" !== typeof loc) {
|
|
1921
|
+
uri = loc.protocol + "//" + uri;
|
|
1922
|
+
} else {
|
|
1923
|
+
uri = "https://" + uri;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
obj2 = parse(uri);
|
|
1927
|
+
}
|
|
1928
|
+
if (!obj2.port) {
|
|
1929
|
+
if (/^(http|ws)$/.test(obj2.protocol)) {
|
|
1930
|
+
obj2.port = "80";
|
|
1931
|
+
} else if (/^(http|ws)s$/.test(obj2.protocol)) {
|
|
1932
|
+
obj2.port = "443";
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
obj2.path = obj2.path || "/";
|
|
1936
|
+
var ipv6 = obj2.host.indexOf(":") !== -1;
|
|
1937
|
+
var host = ipv6 ? "[" + obj2.host + "]" : obj2.host;
|
|
1938
|
+
obj2.id = obj2.protocol + "://" + host + ":" + obj2.port + path;
|
|
1939
|
+
obj2.href = obj2.protocol + "://" + host + (loc && loc.port === obj2.port ? "" : ":" + obj2.port);
|
|
1940
|
+
return obj2;
|
|
1941
|
+
}
|
|
1942
|
+
var withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
|
1943
|
+
var isView = function isView2(obj2) {
|
|
1944
|
+
return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj2) : obj2.buffer instanceof ArrayBuffer;
|
|
1945
|
+
};
|
|
1946
|
+
var toString = Object.prototype.toString;
|
|
1947
|
+
var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && toString.call(Blob) === "[object BlobConstructor]";
|
|
1948
|
+
var withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString.call(File) === "[object FileConstructor]";
|
|
1949
|
+
function isBinary(obj2) {
|
|
1950
|
+
return withNativeArrayBuffer && (obj2 instanceof ArrayBuffer || isView(obj2)) || withNativeBlob && obj2 instanceof Blob || withNativeFile && obj2 instanceof File;
|
|
1951
|
+
}
|
|
1952
|
+
function hasBinary(obj2, toJSON) {
|
|
1953
|
+
if (!obj2 || _typeof(obj2) !== "object") {
|
|
1954
|
+
return false;
|
|
1955
|
+
}
|
|
1956
|
+
if (Array.isArray(obj2)) {
|
|
1957
|
+
for (var i2 = 0, l = obj2.length; i2 < l; i2++) {
|
|
1958
|
+
if (hasBinary(obj2[i2])) {
|
|
1959
|
+
return true;
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
return false;
|
|
1963
|
+
}
|
|
1964
|
+
if (isBinary(obj2)) {
|
|
1965
|
+
return true;
|
|
1966
|
+
}
|
|
1967
|
+
if (obj2.toJSON && typeof obj2.toJSON === "function" && arguments.length === 1) {
|
|
1968
|
+
return hasBinary(obj2.toJSON(), true);
|
|
1969
|
+
}
|
|
1970
|
+
for (var key in obj2) {
|
|
1971
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key) && hasBinary(obj2[key])) {
|
|
1972
|
+
return true;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
function deconstructPacket(packet) {
|
|
1978
|
+
var buffers = [];
|
|
1979
|
+
var packetData = packet.data;
|
|
1980
|
+
var pack = packet;
|
|
1981
|
+
pack.data = _deconstructPacket(packetData, buffers);
|
|
1982
|
+
pack.attachments = buffers.length;
|
|
1983
|
+
return {
|
|
1984
|
+
packet: pack,
|
|
1985
|
+
buffers
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
function _deconstructPacket(data, buffers) {
|
|
1989
|
+
if (!data)
|
|
1990
|
+
return data;
|
|
1991
|
+
if (isBinary(data)) {
|
|
1992
|
+
var placeholder = {
|
|
1993
|
+
_placeholder: true,
|
|
1994
|
+
num: buffers.length
|
|
1995
|
+
};
|
|
1996
|
+
buffers.push(data);
|
|
1997
|
+
return placeholder;
|
|
1998
|
+
} else if (Array.isArray(data)) {
|
|
1999
|
+
var newData = new Array(data.length);
|
|
2000
|
+
for (var i2 = 0; i2 < data.length; i2++) {
|
|
2001
|
+
newData[i2] = _deconstructPacket(data[i2], buffers);
|
|
2002
|
+
}
|
|
2003
|
+
return newData;
|
|
2004
|
+
} else if (_typeof(data) === "object" && !(data instanceof Date)) {
|
|
2005
|
+
var _newData = {};
|
|
2006
|
+
for (var key in data) {
|
|
2007
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
2008
|
+
_newData[key] = _deconstructPacket(data[key], buffers);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
return _newData;
|
|
2012
|
+
}
|
|
2013
|
+
return data;
|
|
2014
|
+
}
|
|
2015
|
+
function reconstructPacket(packet, buffers) {
|
|
2016
|
+
packet.data = _reconstructPacket(packet.data, buffers);
|
|
2017
|
+
packet.attachments = void 0;
|
|
2018
|
+
return packet;
|
|
2019
|
+
}
|
|
2020
|
+
function _reconstructPacket(data, buffers) {
|
|
2021
|
+
if (!data)
|
|
2022
|
+
return data;
|
|
2023
|
+
if (data && data._placeholder === true) {
|
|
2024
|
+
var isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
|
|
2025
|
+
if (isIndexValid) {
|
|
2026
|
+
return buffers[data.num];
|
|
2027
|
+
} else {
|
|
2028
|
+
throw new Error("illegal attachments");
|
|
2029
|
+
}
|
|
2030
|
+
} else if (Array.isArray(data)) {
|
|
2031
|
+
for (var i2 = 0; i2 < data.length; i2++) {
|
|
2032
|
+
data[i2] = _reconstructPacket(data[i2], buffers);
|
|
2033
|
+
}
|
|
2034
|
+
} else if (_typeof(data) === "object") {
|
|
2035
|
+
for (var key in data) {
|
|
2036
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
2037
|
+
data[key] = _reconstructPacket(data[key], buffers);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
return data;
|
|
2042
|
+
}
|
|
2043
|
+
var protocol = 5;
|
|
2044
|
+
var PacketType;
|
|
2045
|
+
(function(PacketType2) {
|
|
2046
|
+
PacketType2[PacketType2["CONNECT"] = 0] = "CONNECT";
|
|
2047
|
+
PacketType2[PacketType2["DISCONNECT"] = 1] = "DISCONNECT";
|
|
2048
|
+
PacketType2[PacketType2["EVENT"] = 2] = "EVENT";
|
|
2049
|
+
PacketType2[PacketType2["ACK"] = 3] = "ACK";
|
|
2050
|
+
PacketType2[PacketType2["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
|
|
2051
|
+
PacketType2[PacketType2["BINARY_EVENT"] = 5] = "BINARY_EVENT";
|
|
2052
|
+
PacketType2[PacketType2["BINARY_ACK"] = 6] = "BINARY_ACK";
|
|
2053
|
+
})(PacketType || (PacketType = {}));
|
|
2054
|
+
var Encoder = /* @__PURE__ */ function() {
|
|
2055
|
+
function Encoder2(replacer) {
|
|
2056
|
+
_classCallCheck(this, Encoder2);
|
|
2057
|
+
this.replacer = replacer;
|
|
2058
|
+
}
|
|
2059
|
+
_createClass(Encoder2, [{
|
|
2060
|
+
key: "encode",
|
|
2061
|
+
value: function encode2(obj2) {
|
|
2062
|
+
if (obj2.type === PacketType.EVENT || obj2.type === PacketType.ACK) {
|
|
2063
|
+
if (hasBinary(obj2)) {
|
|
2064
|
+
obj2.type = obj2.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK;
|
|
2065
|
+
return this.encodeAsBinary(obj2);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
return [this.encodeAsString(obj2)];
|
|
2069
|
+
}
|
|
2070
|
+
/**
|
|
2071
|
+
* Encode packet as string.
|
|
2072
|
+
*/
|
|
2073
|
+
}, {
|
|
2074
|
+
key: "encodeAsString",
|
|
2075
|
+
value: function encodeAsString(obj2) {
|
|
2076
|
+
var str = "" + obj2.type;
|
|
2077
|
+
if (obj2.type === PacketType.BINARY_EVENT || obj2.type === PacketType.BINARY_ACK) {
|
|
2078
|
+
str += obj2.attachments + "-";
|
|
2079
|
+
}
|
|
2080
|
+
if (obj2.nsp && "/" !== obj2.nsp) {
|
|
2081
|
+
str += obj2.nsp + ",";
|
|
2082
|
+
}
|
|
2083
|
+
if (null != obj2.id) {
|
|
2084
|
+
str += obj2.id;
|
|
2085
|
+
}
|
|
2086
|
+
if (null != obj2.data) {
|
|
2087
|
+
str += JSON.stringify(obj2.data, this.replacer);
|
|
2088
|
+
}
|
|
2089
|
+
return str;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
2093
|
+
* deconstructing packet into object with placeholders and
|
|
2094
|
+
* a list of buffers.
|
|
2095
|
+
*/
|
|
2096
|
+
}, {
|
|
2097
|
+
key: "encodeAsBinary",
|
|
2098
|
+
value: function encodeAsBinary(obj2) {
|
|
2099
|
+
var deconstruction = deconstructPacket(obj2);
|
|
2100
|
+
var pack = this.encodeAsString(deconstruction.packet);
|
|
2101
|
+
var buffers = deconstruction.buffers;
|
|
2102
|
+
buffers.unshift(pack);
|
|
2103
|
+
return buffers;
|
|
2104
|
+
}
|
|
2105
|
+
}]);
|
|
2106
|
+
return Encoder2;
|
|
2107
|
+
}();
|
|
2108
|
+
var Decoder = /* @__PURE__ */ function(_Emitter) {
|
|
2109
|
+
_inherits(Decoder2, _Emitter);
|
|
2110
|
+
var _super = _createSuper(Decoder2);
|
|
2111
|
+
function Decoder2(reviver) {
|
|
2112
|
+
var _this;
|
|
2113
|
+
_classCallCheck(this, Decoder2);
|
|
2114
|
+
_this = _super.call(this);
|
|
2115
|
+
_this.reviver = reviver;
|
|
2116
|
+
return _this;
|
|
2117
|
+
}
|
|
2118
|
+
_createClass(Decoder2, [{
|
|
2119
|
+
key: "add",
|
|
2120
|
+
value: function add(obj2) {
|
|
2121
|
+
var packet;
|
|
2122
|
+
if (typeof obj2 === "string") {
|
|
2123
|
+
if (this.reconstructor) {
|
|
2124
|
+
throw new Error("got plaintext data when reconstructing a packet");
|
|
2125
|
+
}
|
|
2126
|
+
packet = this.decodeString(obj2);
|
|
2127
|
+
if (packet.type === PacketType.BINARY_EVENT || packet.type === PacketType.BINARY_ACK) {
|
|
2128
|
+
this.reconstructor = new BinaryReconstructor(packet);
|
|
2129
|
+
if (packet.attachments === 0) {
|
|
2130
|
+
_get(_getPrototypeOf(Decoder2.prototype), "emitReserved", this).call(this, "decoded", packet);
|
|
2131
|
+
}
|
|
2132
|
+
} else {
|
|
2133
|
+
_get(_getPrototypeOf(Decoder2.prototype), "emitReserved", this).call(this, "decoded", packet);
|
|
2134
|
+
}
|
|
2135
|
+
} else if (isBinary(obj2) || obj2.base64) {
|
|
2136
|
+
if (!this.reconstructor) {
|
|
2137
|
+
throw new Error("got binary data when not reconstructing a packet");
|
|
2138
|
+
} else {
|
|
2139
|
+
packet = this.reconstructor.takeBinaryData(obj2);
|
|
2140
|
+
if (packet) {
|
|
2141
|
+
this.reconstructor = null;
|
|
2142
|
+
_get(_getPrototypeOf(Decoder2.prototype), "emitReserved", this).call(this, "decoded", packet);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
} else {
|
|
2146
|
+
throw new Error("Unknown type: " + obj2);
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Decode a packet String (JSON data)
|
|
2151
|
+
*
|
|
2152
|
+
* @param {String} str
|
|
2153
|
+
* @return {Object} packet
|
|
2154
|
+
*/
|
|
2155
|
+
}, {
|
|
2156
|
+
key: "decodeString",
|
|
2157
|
+
value: function decodeString(str) {
|
|
2158
|
+
var i2 = 0;
|
|
2159
|
+
var p = {
|
|
2160
|
+
type: Number(str.charAt(0))
|
|
2161
|
+
};
|
|
2162
|
+
if (PacketType[p.type] === void 0) {
|
|
2163
|
+
throw new Error("unknown packet type " + p.type);
|
|
2164
|
+
}
|
|
2165
|
+
if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
|
|
2166
|
+
var start = i2 + 1;
|
|
2167
|
+
while (str.charAt(++i2) !== "-" && i2 != str.length) {
|
|
2168
|
+
}
|
|
2169
|
+
var buf = str.substring(start, i2);
|
|
2170
|
+
if (buf != Number(buf) || str.charAt(i2) !== "-") {
|
|
2171
|
+
throw new Error("Illegal attachments");
|
|
2172
|
+
}
|
|
2173
|
+
p.attachments = Number(buf);
|
|
2174
|
+
}
|
|
2175
|
+
if ("/" === str.charAt(i2 + 1)) {
|
|
2176
|
+
var _start = i2 + 1;
|
|
2177
|
+
while (++i2) {
|
|
2178
|
+
var c = str.charAt(i2);
|
|
2179
|
+
if ("," === c)
|
|
2180
|
+
break;
|
|
2181
|
+
if (i2 === str.length)
|
|
2182
|
+
break;
|
|
2183
|
+
}
|
|
2184
|
+
p.nsp = str.substring(_start, i2);
|
|
2185
|
+
} else {
|
|
2186
|
+
p.nsp = "/";
|
|
2187
|
+
}
|
|
2188
|
+
var next = str.charAt(i2 + 1);
|
|
2189
|
+
if ("" !== next && Number(next) == next) {
|
|
2190
|
+
var _start2 = i2 + 1;
|
|
2191
|
+
while (++i2) {
|
|
2192
|
+
var _c = str.charAt(i2);
|
|
2193
|
+
if (null == _c || Number(_c) != _c) {
|
|
2194
|
+
--i2;
|
|
2195
|
+
break;
|
|
2196
|
+
}
|
|
2197
|
+
if (i2 === str.length)
|
|
2198
|
+
break;
|
|
2199
|
+
}
|
|
2200
|
+
p.id = Number(str.substring(_start2, i2 + 1));
|
|
2201
|
+
}
|
|
2202
|
+
if (str.charAt(++i2)) {
|
|
2203
|
+
var payload = this.tryParse(str.substr(i2));
|
|
2204
|
+
if (Decoder2.isPayloadValid(p.type, payload)) {
|
|
2205
|
+
p.data = payload;
|
|
2206
|
+
} else {
|
|
2207
|
+
throw new Error("invalid payload");
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
return p;
|
|
2211
|
+
}
|
|
2212
|
+
}, {
|
|
2213
|
+
key: "tryParse",
|
|
2214
|
+
value: function tryParse(str) {
|
|
2215
|
+
try {
|
|
2216
|
+
return JSON.parse(str, this.reviver);
|
|
2217
|
+
} catch (e) {
|
|
2218
|
+
return false;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}, {
|
|
2222
|
+
key: "destroy",
|
|
2223
|
+
value: (
|
|
2224
|
+
/**
|
|
2225
|
+
* Deallocates a parser's resources
|
|
2226
|
+
*/
|
|
2227
|
+
function destroy() {
|
|
2228
|
+
if (this.reconstructor) {
|
|
2229
|
+
this.reconstructor.finishedReconstruction();
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
)
|
|
2233
|
+
}], [{
|
|
2234
|
+
key: "isPayloadValid",
|
|
2235
|
+
value: function isPayloadValid(type, payload) {
|
|
2236
|
+
switch (type) {
|
|
2237
|
+
case PacketType.CONNECT:
|
|
2238
|
+
return _typeof(payload) === "object";
|
|
2239
|
+
case PacketType.DISCONNECT:
|
|
2240
|
+
return payload === void 0;
|
|
2241
|
+
case PacketType.CONNECT_ERROR:
|
|
2242
|
+
return typeof payload === "string" || _typeof(payload) === "object";
|
|
2243
|
+
case PacketType.EVENT:
|
|
2244
|
+
case PacketType.BINARY_EVENT:
|
|
2245
|
+
return Array.isArray(payload) && payload.length > 0;
|
|
2246
|
+
case PacketType.ACK:
|
|
2247
|
+
case PacketType.BINARY_ACK:
|
|
2248
|
+
return Array.isArray(payload);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}]);
|
|
2252
|
+
return Decoder2;
|
|
2253
|
+
}(Emitter);
|
|
2254
|
+
var BinaryReconstructor = /* @__PURE__ */ function() {
|
|
2255
|
+
function BinaryReconstructor2(packet) {
|
|
2256
|
+
_classCallCheck(this, BinaryReconstructor2);
|
|
2257
|
+
this.packet = packet;
|
|
2258
|
+
this.buffers = [];
|
|
2259
|
+
this.reconPack = packet;
|
|
2260
|
+
}
|
|
2261
|
+
_createClass(BinaryReconstructor2, [{
|
|
2262
|
+
key: "takeBinaryData",
|
|
2263
|
+
value: function takeBinaryData(binData) {
|
|
2264
|
+
this.buffers.push(binData);
|
|
2265
|
+
if (this.buffers.length === this.reconPack.attachments) {
|
|
2266
|
+
var packet = reconstructPacket(this.reconPack, this.buffers);
|
|
2267
|
+
this.finishedReconstruction();
|
|
2268
|
+
return packet;
|
|
2269
|
+
}
|
|
2270
|
+
return null;
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* Cleans up binary packet reconstruction variables.
|
|
2274
|
+
*/
|
|
2275
|
+
}, {
|
|
2276
|
+
key: "finishedReconstruction",
|
|
2277
|
+
value: function finishedReconstruction() {
|
|
2278
|
+
this.reconPack = null;
|
|
2279
|
+
this.buffers = [];
|
|
2280
|
+
}
|
|
2281
|
+
}]);
|
|
2282
|
+
return BinaryReconstructor2;
|
|
2283
|
+
}();
|
|
2284
|
+
var parser = /* @__PURE__ */ Object.freeze({
|
|
2285
|
+
__proto__: null,
|
|
2286
|
+
protocol,
|
|
2287
|
+
get PacketType() {
|
|
2288
|
+
return PacketType;
|
|
2289
|
+
},
|
|
2290
|
+
Encoder,
|
|
2291
|
+
Decoder
|
|
2292
|
+
});
|
|
2293
|
+
function on(obj2, ev, fn) {
|
|
2294
|
+
obj2.on(ev, fn);
|
|
2295
|
+
return function subDestroy() {
|
|
2296
|
+
obj2.off(ev, fn);
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
var RESERVED_EVENTS = Object.freeze({
|
|
2300
|
+
connect: 1,
|
|
2301
|
+
connect_error: 1,
|
|
2302
|
+
disconnect: 1,
|
|
2303
|
+
disconnecting: 1,
|
|
2304
|
+
// EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
|
|
2305
|
+
newListener: 1,
|
|
2306
|
+
removeListener: 1
|
|
2307
|
+
});
|
|
2308
|
+
var Socket = /* @__PURE__ */ function(_Emitter) {
|
|
2309
|
+
_inherits(Socket2, _Emitter);
|
|
2310
|
+
var _super = _createSuper(Socket2);
|
|
2311
|
+
function Socket2(io2, nsp, opts) {
|
|
2312
|
+
var _this;
|
|
2313
|
+
_classCallCheck(this, Socket2);
|
|
2314
|
+
_this = _super.call(this);
|
|
2315
|
+
_this.connected = false;
|
|
2316
|
+
_this.receiveBuffer = [];
|
|
2317
|
+
_this.sendBuffer = [];
|
|
2318
|
+
_this.ids = 0;
|
|
2319
|
+
_this.acks = {};
|
|
2320
|
+
_this.flags = {};
|
|
2321
|
+
_this.io = io2;
|
|
2322
|
+
_this.nsp = nsp;
|
|
2323
|
+
if (opts && opts.auth) {
|
|
2324
|
+
_this.auth = opts.auth;
|
|
2325
|
+
}
|
|
2326
|
+
if (_this.io._autoConnect)
|
|
2327
|
+
_this.open();
|
|
2328
|
+
return _this;
|
|
2329
|
+
}
|
|
2330
|
+
_createClass(Socket2, [{
|
|
2331
|
+
key: "disconnected",
|
|
2332
|
+
get: function get() {
|
|
2333
|
+
return !this.connected;
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Subscribe to open, close and packet events
|
|
2337
|
+
*
|
|
2338
|
+
* @private
|
|
2339
|
+
*/
|
|
2340
|
+
}, {
|
|
2341
|
+
key: "subEvents",
|
|
2342
|
+
value: function subEvents() {
|
|
2343
|
+
if (this.subs)
|
|
2344
|
+
return;
|
|
2345
|
+
var io2 = this.io;
|
|
2346
|
+
this.subs = [on(io2, "open", this.onopen.bind(this)), on(io2, "packet", this.onpacket.bind(this)), on(io2, "error", this.onerror.bind(this)), on(io2, "close", this.onclose.bind(this))];
|
|
2347
|
+
}
|
|
2348
|
+
/**
|
|
2349
|
+
* Whether the Socket will try to reconnect when its Manager connects or reconnects.
|
|
2350
|
+
*
|
|
2351
|
+
* @example
|
|
2352
|
+
* const socket = io();
|
|
2353
|
+
*
|
|
2354
|
+
* console.log(socket.active); // true
|
|
2355
|
+
*
|
|
2356
|
+
* socket.on("disconnect", (reason) => {
|
|
2357
|
+
* if (reason === "io server disconnect") {
|
|
2358
|
+
* // the disconnection was initiated by the server, you need to manually reconnect
|
|
2359
|
+
* console.log(socket.active); // false
|
|
2360
|
+
* }
|
|
2361
|
+
* // else the socket will automatically try to reconnect
|
|
2362
|
+
* console.log(socket.active); // true
|
|
2363
|
+
* });
|
|
2364
|
+
*/
|
|
2365
|
+
}, {
|
|
2366
|
+
key: "active",
|
|
2367
|
+
get: function get() {
|
|
2368
|
+
return !!this.subs;
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* "Opens" the socket.
|
|
2372
|
+
*
|
|
2373
|
+
* @example
|
|
2374
|
+
* const socket = io({
|
|
2375
|
+
* autoConnect: false
|
|
2376
|
+
* });
|
|
2377
|
+
*
|
|
2378
|
+
* socket.connect();
|
|
2379
|
+
*/
|
|
2380
|
+
}, {
|
|
2381
|
+
key: "connect",
|
|
2382
|
+
value: function connect2() {
|
|
2383
|
+
if (this.connected)
|
|
2384
|
+
return this;
|
|
2385
|
+
this.subEvents();
|
|
2386
|
+
if (!this.io["_reconnecting"])
|
|
2387
|
+
this.io.open();
|
|
2388
|
+
if ("open" === this.io._readyState)
|
|
2389
|
+
this.onopen();
|
|
2390
|
+
return this;
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Alias for {@link connect()}.
|
|
2394
|
+
*/
|
|
2395
|
+
}, {
|
|
2396
|
+
key: "open",
|
|
2397
|
+
value: function open() {
|
|
2398
|
+
return this.connect();
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Sends a `message` event.
|
|
2402
|
+
*
|
|
2403
|
+
* This method mimics the WebSocket.send() method.
|
|
2404
|
+
*
|
|
2405
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
|
|
2406
|
+
*
|
|
2407
|
+
* @example
|
|
2408
|
+
* socket.send("hello");
|
|
2409
|
+
*
|
|
2410
|
+
* // this is equivalent to
|
|
2411
|
+
* socket.emit("message", "hello");
|
|
2412
|
+
*
|
|
2413
|
+
* @return self
|
|
2414
|
+
*/
|
|
2415
|
+
}, {
|
|
2416
|
+
key: "send",
|
|
2417
|
+
value: function send2() {
|
|
2418
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2419
|
+
args[_key] = arguments[_key];
|
|
2420
|
+
}
|
|
2421
|
+
args.unshift("message");
|
|
2422
|
+
this.emit.apply(this, args);
|
|
2423
|
+
return this;
|
|
2424
|
+
}
|
|
2425
|
+
/**
|
|
2426
|
+
* Override `emit`.
|
|
2427
|
+
* If the event is in `events`, it's emitted normally.
|
|
2428
|
+
*
|
|
2429
|
+
* @example
|
|
2430
|
+
* socket.emit("hello", "world");
|
|
2431
|
+
*
|
|
2432
|
+
* // all serializable datastructures are supported (no need to call JSON.stringify)
|
|
2433
|
+
* socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
|
|
2434
|
+
*
|
|
2435
|
+
* // with an acknowledgement from the server
|
|
2436
|
+
* socket.emit("hello", "world", (val) => {
|
|
2437
|
+
* // ...
|
|
2438
|
+
* });
|
|
2439
|
+
*
|
|
2440
|
+
* @return self
|
|
2441
|
+
*/
|
|
2442
|
+
}, {
|
|
2443
|
+
key: "emit",
|
|
2444
|
+
value: function emit(ev) {
|
|
2445
|
+
if (RESERVED_EVENTS.hasOwnProperty(ev)) {
|
|
2446
|
+
throw new Error('"' + ev.toString() + '" is a reserved event name');
|
|
2447
|
+
}
|
|
2448
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2449
|
+
args[_key2 - 1] = arguments[_key2];
|
|
2450
|
+
}
|
|
2451
|
+
args.unshift(ev);
|
|
2452
|
+
var packet = {
|
|
2453
|
+
type: PacketType.EVENT,
|
|
2454
|
+
data: args
|
|
2455
|
+
};
|
|
2456
|
+
packet.options = {};
|
|
2457
|
+
packet.options.compress = this.flags.compress !== false;
|
|
2458
|
+
if ("function" === typeof args[args.length - 1]) {
|
|
2459
|
+
var id = this.ids++;
|
|
2460
|
+
var ack = args.pop();
|
|
2461
|
+
this._registerAckCallback(id, ack);
|
|
2462
|
+
packet.id = id;
|
|
2463
|
+
}
|
|
2464
|
+
var isTransportWritable = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable;
|
|
2465
|
+
var discardPacket = this.flags["volatile"] && (!isTransportWritable || !this.connected);
|
|
2466
|
+
if (discardPacket)
|
|
2467
|
+
;
|
|
2468
|
+
else if (this.connected) {
|
|
2469
|
+
this.notifyOutgoingListeners(packet);
|
|
2470
|
+
this.packet(packet);
|
|
2471
|
+
} else {
|
|
2472
|
+
this.sendBuffer.push(packet);
|
|
2473
|
+
}
|
|
2474
|
+
this.flags = {};
|
|
2475
|
+
return this;
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* @private
|
|
2479
|
+
*/
|
|
2480
|
+
}, {
|
|
2481
|
+
key: "_registerAckCallback",
|
|
2482
|
+
value: function _registerAckCallback(id, ack) {
|
|
2483
|
+
var _this2 = this;
|
|
2484
|
+
var timeout = this.flags.timeout;
|
|
2485
|
+
if (timeout === void 0) {
|
|
2486
|
+
this.acks[id] = ack;
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
var timer = this.io.setTimeoutFn(function() {
|
|
2490
|
+
delete _this2.acks[id];
|
|
2491
|
+
for (var i2 = 0; i2 < _this2.sendBuffer.length; i2++) {
|
|
2492
|
+
if (_this2.sendBuffer[i2].id === id) {
|
|
2493
|
+
_this2.sendBuffer.splice(i2, 1);
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
ack.call(_this2, new Error("operation has timed out"));
|
|
2497
|
+
}, timeout);
|
|
2498
|
+
this.acks[id] = function() {
|
|
2499
|
+
_this2.io.clearTimeoutFn(timer);
|
|
2500
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
2501
|
+
args[_key3] = arguments[_key3];
|
|
2502
|
+
}
|
|
2503
|
+
ack.apply(_this2, [null].concat(args));
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Sends a packet.
|
|
2508
|
+
*
|
|
2509
|
+
* @param packet
|
|
2510
|
+
* @private
|
|
2511
|
+
*/
|
|
2512
|
+
}, {
|
|
2513
|
+
key: "packet",
|
|
2514
|
+
value: function packet(_packet) {
|
|
2515
|
+
_packet.nsp = this.nsp;
|
|
2516
|
+
this.io._packet(_packet);
|
|
2517
|
+
}
|
|
2518
|
+
/**
|
|
2519
|
+
* Called upon engine `open`.
|
|
2520
|
+
*
|
|
2521
|
+
* @private
|
|
2522
|
+
*/
|
|
2523
|
+
}, {
|
|
2524
|
+
key: "onopen",
|
|
2525
|
+
value: function onopen() {
|
|
2526
|
+
var _this3 = this;
|
|
2527
|
+
if (typeof this.auth == "function") {
|
|
2528
|
+
this.auth(function(data) {
|
|
2529
|
+
_this3.packet({
|
|
2530
|
+
type: PacketType.CONNECT,
|
|
2531
|
+
data
|
|
2532
|
+
});
|
|
2533
|
+
});
|
|
2534
|
+
} else {
|
|
2535
|
+
this.packet({
|
|
2536
|
+
type: PacketType.CONNECT,
|
|
2537
|
+
data: this.auth
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Called upon engine or manager `error`.
|
|
2543
|
+
*
|
|
2544
|
+
* @param err
|
|
2545
|
+
* @private
|
|
2546
|
+
*/
|
|
2547
|
+
}, {
|
|
2548
|
+
key: "onerror",
|
|
2549
|
+
value: function onerror(err) {
|
|
2550
|
+
if (!this.connected) {
|
|
2551
|
+
this.emitReserved("connect_error", err);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Called upon engine `close`.
|
|
2556
|
+
*
|
|
2557
|
+
* @param reason
|
|
2558
|
+
* @param description
|
|
2559
|
+
* @private
|
|
2560
|
+
*/
|
|
2561
|
+
}, {
|
|
2562
|
+
key: "onclose",
|
|
2563
|
+
value: function onclose(reason, description) {
|
|
2564
|
+
this.connected = false;
|
|
2565
|
+
delete this.id;
|
|
2566
|
+
this.emitReserved("disconnect", reason, description);
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* Called with socket packet.
|
|
2570
|
+
*
|
|
2571
|
+
* @param packet
|
|
2572
|
+
* @private
|
|
2573
|
+
*/
|
|
2574
|
+
}, {
|
|
2575
|
+
key: "onpacket",
|
|
2576
|
+
value: function onpacket(packet) {
|
|
2577
|
+
var sameNamespace = packet.nsp === this.nsp;
|
|
2578
|
+
if (!sameNamespace)
|
|
2579
|
+
return;
|
|
2580
|
+
switch (packet.type) {
|
|
2581
|
+
case PacketType.CONNECT:
|
|
2582
|
+
if (packet.data && packet.data.sid) {
|
|
2583
|
+
var id = packet.data.sid;
|
|
2584
|
+
this.onconnect(id);
|
|
2585
|
+
} else {
|
|
2586
|
+
this.emitReserved("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/)"));
|
|
2587
|
+
}
|
|
2588
|
+
break;
|
|
2589
|
+
case PacketType.EVENT:
|
|
2590
|
+
case PacketType.BINARY_EVENT:
|
|
2591
|
+
this.onevent(packet);
|
|
2592
|
+
break;
|
|
2593
|
+
case PacketType.ACK:
|
|
2594
|
+
case PacketType.BINARY_ACK:
|
|
2595
|
+
this.onack(packet);
|
|
2596
|
+
break;
|
|
2597
|
+
case PacketType.DISCONNECT:
|
|
2598
|
+
this.ondisconnect();
|
|
2599
|
+
break;
|
|
2600
|
+
case PacketType.CONNECT_ERROR:
|
|
2601
|
+
this.destroy();
|
|
2602
|
+
var err = new Error(packet.data.message);
|
|
2603
|
+
err.data = packet.data.data;
|
|
2604
|
+
this.emitReserved("connect_error", err);
|
|
2605
|
+
break;
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* Called upon a server event.
|
|
2610
|
+
*
|
|
2611
|
+
* @param packet
|
|
2612
|
+
* @private
|
|
2613
|
+
*/
|
|
2614
|
+
}, {
|
|
2615
|
+
key: "onevent",
|
|
2616
|
+
value: function onevent(packet) {
|
|
2617
|
+
var args = packet.data || [];
|
|
2618
|
+
if (null != packet.id) {
|
|
2619
|
+
args.push(this.ack(packet.id));
|
|
2620
|
+
}
|
|
2621
|
+
if (this.connected) {
|
|
2622
|
+
this.emitEvent(args);
|
|
2623
|
+
} else {
|
|
2624
|
+
this.receiveBuffer.push(Object.freeze(args));
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}, {
|
|
2628
|
+
key: "emitEvent",
|
|
2629
|
+
value: function emitEvent(args) {
|
|
2630
|
+
if (this._anyListeners && this._anyListeners.length) {
|
|
2631
|
+
var listeners = this._anyListeners.slice();
|
|
2632
|
+
var _iterator = _createForOfIteratorHelper(listeners), _step;
|
|
2633
|
+
try {
|
|
2634
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
2635
|
+
var listener = _step.value;
|
|
2636
|
+
listener.apply(this, args);
|
|
2637
|
+
}
|
|
2638
|
+
} catch (err) {
|
|
2639
|
+
_iterator.e(err);
|
|
2640
|
+
} finally {
|
|
2641
|
+
_iterator.f();
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
_get(_getPrototypeOf(Socket2.prototype), "emit", this).apply(this, args);
|
|
2645
|
+
}
|
|
2646
|
+
/**
|
|
2647
|
+
* Produces an ack callback to emit with an event.
|
|
2648
|
+
*
|
|
2649
|
+
* @private
|
|
2650
|
+
*/
|
|
2651
|
+
}, {
|
|
2652
|
+
key: "ack",
|
|
2653
|
+
value: function ack(id) {
|
|
2654
|
+
var self2 = this;
|
|
2655
|
+
var sent = false;
|
|
2656
|
+
return function() {
|
|
2657
|
+
if (sent)
|
|
2658
|
+
return;
|
|
2659
|
+
sent = true;
|
|
2660
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
2661
|
+
args[_key4] = arguments[_key4];
|
|
2662
|
+
}
|
|
2663
|
+
self2.packet({
|
|
2664
|
+
type: PacketType.ACK,
|
|
2665
|
+
id,
|
|
2666
|
+
data: args
|
|
2667
|
+
});
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Called upon a server acknowlegement.
|
|
2672
|
+
*
|
|
2673
|
+
* @param packet
|
|
2674
|
+
* @private
|
|
2675
|
+
*/
|
|
2676
|
+
}, {
|
|
2677
|
+
key: "onack",
|
|
2678
|
+
value: function onack(packet) {
|
|
2679
|
+
var ack = this.acks[packet.id];
|
|
2680
|
+
if ("function" === typeof ack) {
|
|
2681
|
+
ack.apply(this, packet.data);
|
|
2682
|
+
delete this.acks[packet.id];
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
/**
|
|
2686
|
+
* Called upon server connect.
|
|
2687
|
+
*
|
|
2688
|
+
* @private
|
|
2689
|
+
*/
|
|
2690
|
+
}, {
|
|
2691
|
+
key: "onconnect",
|
|
2692
|
+
value: function onconnect(id) {
|
|
2693
|
+
this.id = id;
|
|
2694
|
+
this.connected = true;
|
|
2695
|
+
this.emitBuffered();
|
|
2696
|
+
this.emitReserved("connect");
|
|
2697
|
+
}
|
|
2698
|
+
/**
|
|
2699
|
+
* Emit buffered events (received and emitted).
|
|
2700
|
+
*
|
|
2701
|
+
* @private
|
|
2702
|
+
*/
|
|
2703
|
+
}, {
|
|
2704
|
+
key: "emitBuffered",
|
|
2705
|
+
value: function emitBuffered() {
|
|
2706
|
+
var _this4 = this;
|
|
2707
|
+
this.receiveBuffer.forEach(function(args) {
|
|
2708
|
+
return _this4.emitEvent(args);
|
|
2709
|
+
});
|
|
2710
|
+
this.receiveBuffer = [];
|
|
2711
|
+
this.sendBuffer.forEach(function(packet) {
|
|
2712
|
+
_this4.notifyOutgoingListeners(packet);
|
|
2713
|
+
_this4.packet(packet);
|
|
2714
|
+
});
|
|
2715
|
+
this.sendBuffer = [];
|
|
2716
|
+
}
|
|
2717
|
+
/**
|
|
2718
|
+
* Called upon server disconnect.
|
|
2719
|
+
*
|
|
2720
|
+
* @private
|
|
2721
|
+
*/
|
|
2722
|
+
}, {
|
|
2723
|
+
key: "ondisconnect",
|
|
2724
|
+
value: function ondisconnect() {
|
|
2725
|
+
this.destroy();
|
|
2726
|
+
this.onclose("io server disconnect");
|
|
2727
|
+
}
|
|
2728
|
+
/**
|
|
2729
|
+
* Called upon forced client/server side disconnections,
|
|
2730
|
+
* this method ensures the manager stops tracking us and
|
|
2731
|
+
* that reconnections don't get triggered for this.
|
|
2732
|
+
*
|
|
2733
|
+
* @private
|
|
2734
|
+
*/
|
|
2735
|
+
}, {
|
|
2736
|
+
key: "destroy",
|
|
2737
|
+
value: function destroy() {
|
|
2738
|
+
if (this.subs) {
|
|
2739
|
+
this.subs.forEach(function(subDestroy) {
|
|
2740
|
+
return subDestroy();
|
|
2741
|
+
});
|
|
2742
|
+
this.subs = void 0;
|
|
2743
|
+
}
|
|
2744
|
+
this.io["_destroy"](this);
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Disconnects the socket manually. In that case, the socket will not try to reconnect.
|
|
2748
|
+
*
|
|
2749
|
+
* If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
|
|
2750
|
+
*
|
|
2751
|
+
* @example
|
|
2752
|
+
* const socket = io();
|
|
2753
|
+
*
|
|
2754
|
+
* socket.on("disconnect", (reason) => {
|
|
2755
|
+
* // console.log(reason); prints "io client disconnect"
|
|
2756
|
+
* });
|
|
2757
|
+
*
|
|
2758
|
+
* socket.disconnect();
|
|
2759
|
+
*
|
|
2760
|
+
* @return self
|
|
2761
|
+
*/
|
|
2762
|
+
}, {
|
|
2763
|
+
key: "disconnect",
|
|
2764
|
+
value: function disconnect2() {
|
|
2765
|
+
if (this.connected) {
|
|
2766
|
+
this.packet({
|
|
2767
|
+
type: PacketType.DISCONNECT
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
this.destroy();
|
|
2771
|
+
if (this.connected) {
|
|
2772
|
+
this.onclose("io client disconnect");
|
|
2773
|
+
}
|
|
2774
|
+
return this;
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* Alias for {@link disconnect()}.
|
|
2778
|
+
*
|
|
2779
|
+
* @return self
|
|
2780
|
+
*/
|
|
2781
|
+
}, {
|
|
2782
|
+
key: "close",
|
|
2783
|
+
value: function close() {
|
|
2784
|
+
return this.disconnect();
|
|
2785
|
+
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Sets the compress flag.
|
|
2788
|
+
*
|
|
2789
|
+
* @example
|
|
2790
|
+
* socket.compress(false).emit("hello");
|
|
2791
|
+
*
|
|
2792
|
+
* @param compress - if `true`, compresses the sending data
|
|
2793
|
+
* @return self
|
|
2794
|
+
*/
|
|
2795
|
+
}, {
|
|
2796
|
+
key: "compress",
|
|
2797
|
+
value: function compress(_compress) {
|
|
2798
|
+
this.flags.compress = _compress;
|
|
2799
|
+
return this;
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
|
|
2803
|
+
* ready to send messages.
|
|
2804
|
+
*
|
|
2805
|
+
* @example
|
|
2806
|
+
* socket.volatile.emit("hello"); // the server may or may not receive it
|
|
2807
|
+
*
|
|
2808
|
+
* @returns self
|
|
2809
|
+
*/
|
|
2810
|
+
}, {
|
|
2811
|
+
key: "volatile",
|
|
2812
|
+
get: function get() {
|
|
2813
|
+
this.flags["volatile"] = true;
|
|
2814
|
+
return this;
|
|
2815
|
+
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Sets a modifier for a subsequent event emission that the callback will be called with an error when the
|
|
2818
|
+
* given number of milliseconds have elapsed without an acknowledgement from the server:
|
|
2819
|
+
*
|
|
2820
|
+
* @example
|
|
2821
|
+
* socket.timeout(5000).emit("my-event", (err) => {
|
|
2822
|
+
* if (err) {
|
|
2823
|
+
* // the server did not acknowledge the event in the given delay
|
|
2824
|
+
* }
|
|
2825
|
+
* });
|
|
2826
|
+
*
|
|
2827
|
+
* @returns self
|
|
2828
|
+
*/
|
|
2829
|
+
}, {
|
|
2830
|
+
key: "timeout",
|
|
2831
|
+
value: function timeout(_timeout) {
|
|
2832
|
+
this.flags.timeout = _timeout;
|
|
2833
|
+
return this;
|
|
2834
|
+
}
|
|
2835
|
+
/**
|
|
2836
|
+
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2837
|
+
* callback.
|
|
2838
|
+
*
|
|
2839
|
+
* @example
|
|
2840
|
+
* socket.onAny((event, ...args) => {
|
|
2841
|
+
* console.log(`got ${event}`);
|
|
2842
|
+
* });
|
|
2843
|
+
*
|
|
2844
|
+
* @param listener
|
|
2845
|
+
*/
|
|
2846
|
+
}, {
|
|
2847
|
+
key: "onAny",
|
|
2848
|
+
value: function onAny(listener) {
|
|
2849
|
+
this._anyListeners = this._anyListeners || [];
|
|
2850
|
+
this._anyListeners.push(listener);
|
|
2851
|
+
return this;
|
|
2852
|
+
}
|
|
2853
|
+
/**
|
|
2854
|
+
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2855
|
+
* callback. The listener is added to the beginning of the listeners array.
|
|
2856
|
+
*
|
|
2857
|
+
* @example
|
|
2858
|
+
* socket.prependAny((event, ...args) => {
|
|
2859
|
+
* console.log(`got event ${event}`);
|
|
2860
|
+
* });
|
|
2861
|
+
*
|
|
2862
|
+
* @param listener
|
|
2863
|
+
*/
|
|
2864
|
+
}, {
|
|
2865
|
+
key: "prependAny",
|
|
2866
|
+
value: function prependAny(listener) {
|
|
2867
|
+
this._anyListeners = this._anyListeners || [];
|
|
2868
|
+
this._anyListeners.unshift(listener);
|
|
2869
|
+
return this;
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* Removes the listener that will be fired when any event is emitted.
|
|
2873
|
+
*
|
|
2874
|
+
* @example
|
|
2875
|
+
* const catchAllListener = (event, ...args) => {
|
|
2876
|
+
* console.log(`got event ${event}`);
|
|
2877
|
+
* }
|
|
2878
|
+
*
|
|
2879
|
+
* socket.onAny(catchAllListener);
|
|
2880
|
+
*
|
|
2881
|
+
* // remove a specific listener
|
|
2882
|
+
* socket.offAny(catchAllListener);
|
|
2883
|
+
*
|
|
2884
|
+
* // or remove all listeners
|
|
2885
|
+
* socket.offAny();
|
|
2886
|
+
*
|
|
2887
|
+
* @param listener
|
|
2888
|
+
*/
|
|
2889
|
+
}, {
|
|
2890
|
+
key: "offAny",
|
|
2891
|
+
value: function offAny(listener) {
|
|
2892
|
+
if (!this._anyListeners) {
|
|
2893
|
+
return this;
|
|
2894
|
+
}
|
|
2895
|
+
if (listener) {
|
|
2896
|
+
var listeners = this._anyListeners;
|
|
2897
|
+
for (var i2 = 0; i2 < listeners.length; i2++) {
|
|
2898
|
+
if (listener === listeners[i2]) {
|
|
2899
|
+
listeners.splice(i2, 1);
|
|
2900
|
+
return this;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
} else {
|
|
2904
|
+
this._anyListeners = [];
|
|
2905
|
+
}
|
|
2906
|
+
return this;
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
|
2910
|
+
* e.g. to remove listeners.
|
|
2911
|
+
*/
|
|
2912
|
+
}, {
|
|
2913
|
+
key: "listenersAny",
|
|
2914
|
+
value: function listenersAny() {
|
|
2915
|
+
return this._anyListeners || [];
|
|
2916
|
+
}
|
|
2917
|
+
/**
|
|
2918
|
+
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2919
|
+
* callback.
|
|
2920
|
+
*
|
|
2921
|
+
* Note: acknowledgements sent to the server are not included.
|
|
2922
|
+
*
|
|
2923
|
+
* @example
|
|
2924
|
+
* socket.onAnyOutgoing((event, ...args) => {
|
|
2925
|
+
* console.log(`sent event ${event}`);
|
|
2926
|
+
* });
|
|
2927
|
+
*
|
|
2928
|
+
* @param listener
|
|
2929
|
+
*/
|
|
2930
|
+
}, {
|
|
2931
|
+
key: "onAnyOutgoing",
|
|
2932
|
+
value: function onAnyOutgoing(listener) {
|
|
2933
|
+
this._anyOutgoingListeners = this._anyOutgoingListeners || [];
|
|
2934
|
+
this._anyOutgoingListeners.push(listener);
|
|
2935
|
+
return this;
|
|
2936
|
+
}
|
|
2937
|
+
/**
|
|
2938
|
+
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2939
|
+
* callback. The listener is added to the beginning of the listeners array.
|
|
2940
|
+
*
|
|
2941
|
+
* Note: acknowledgements sent to the server are not included.
|
|
2942
|
+
*
|
|
2943
|
+
* @example
|
|
2944
|
+
* socket.prependAnyOutgoing((event, ...args) => {
|
|
2945
|
+
* console.log(`sent event ${event}`);
|
|
2946
|
+
* });
|
|
2947
|
+
*
|
|
2948
|
+
* @param listener
|
|
2949
|
+
*/
|
|
2950
|
+
}, {
|
|
2951
|
+
key: "prependAnyOutgoing",
|
|
2952
|
+
value: function prependAnyOutgoing(listener) {
|
|
2953
|
+
this._anyOutgoingListeners = this._anyOutgoingListeners || [];
|
|
2954
|
+
this._anyOutgoingListeners.unshift(listener);
|
|
2955
|
+
return this;
|
|
2956
|
+
}
|
|
2957
|
+
/**
|
|
2958
|
+
* Removes the listener that will be fired when any event is emitted.
|
|
2959
|
+
*
|
|
2960
|
+
* @example
|
|
2961
|
+
* const catchAllListener = (event, ...args) => {
|
|
2962
|
+
* console.log(`sent event ${event}`);
|
|
2963
|
+
* }
|
|
2964
|
+
*
|
|
2965
|
+
* socket.onAnyOutgoing(catchAllListener);
|
|
2966
|
+
*
|
|
2967
|
+
* // remove a specific listener
|
|
2968
|
+
* socket.offAnyOutgoing(catchAllListener);
|
|
2969
|
+
*
|
|
2970
|
+
* // or remove all listeners
|
|
2971
|
+
* socket.offAnyOutgoing();
|
|
2972
|
+
*
|
|
2973
|
+
* @param [listener] - the catch-all listener (optional)
|
|
2974
|
+
*/
|
|
2975
|
+
}, {
|
|
2976
|
+
key: "offAnyOutgoing",
|
|
2977
|
+
value: function offAnyOutgoing(listener) {
|
|
2978
|
+
if (!this._anyOutgoingListeners) {
|
|
2979
|
+
return this;
|
|
2980
|
+
}
|
|
2981
|
+
if (listener) {
|
|
2982
|
+
var listeners = this._anyOutgoingListeners;
|
|
2983
|
+
for (var i2 = 0; i2 < listeners.length; i2++) {
|
|
2984
|
+
if (listener === listeners[i2]) {
|
|
2985
|
+
listeners.splice(i2, 1);
|
|
2986
|
+
return this;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
} else {
|
|
2990
|
+
this._anyOutgoingListeners = [];
|
|
2991
|
+
}
|
|
2992
|
+
return this;
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
|
2996
|
+
* e.g. to remove listeners.
|
|
2997
|
+
*/
|
|
2998
|
+
}, {
|
|
2999
|
+
key: "listenersAnyOutgoing",
|
|
3000
|
+
value: function listenersAnyOutgoing() {
|
|
3001
|
+
return this._anyOutgoingListeners || [];
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Notify the listeners for each packet sent
|
|
3005
|
+
*
|
|
3006
|
+
* @param packet
|
|
3007
|
+
*
|
|
3008
|
+
* @private
|
|
3009
|
+
*/
|
|
3010
|
+
}, {
|
|
3011
|
+
key: "notifyOutgoingListeners",
|
|
3012
|
+
value: function notifyOutgoingListeners(packet) {
|
|
3013
|
+
if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
|
|
3014
|
+
var listeners = this._anyOutgoingListeners.slice();
|
|
3015
|
+
var _iterator2 = _createForOfIteratorHelper(listeners), _step2;
|
|
3016
|
+
try {
|
|
3017
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
|
|
3018
|
+
var listener = _step2.value;
|
|
3019
|
+
listener.apply(this, packet.data);
|
|
3020
|
+
}
|
|
3021
|
+
} catch (err) {
|
|
3022
|
+
_iterator2.e(err);
|
|
3023
|
+
} finally {
|
|
3024
|
+
_iterator2.f();
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
}]);
|
|
3029
|
+
return Socket2;
|
|
3030
|
+
}(Emitter);
|
|
3031
|
+
function Backoff(opts) {
|
|
3032
|
+
opts = opts || {};
|
|
3033
|
+
this.ms = opts.min || 100;
|
|
3034
|
+
this.max = opts.max || 1e4;
|
|
3035
|
+
this.factor = opts.factor || 2;
|
|
3036
|
+
this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
|
|
3037
|
+
this.attempts = 0;
|
|
3038
|
+
}
|
|
3039
|
+
Backoff.prototype.duration = function() {
|
|
3040
|
+
var ms = this.ms * Math.pow(this.factor, this.attempts++);
|
|
3041
|
+
if (this.jitter) {
|
|
3042
|
+
var rand = Math.random();
|
|
3043
|
+
var deviation = Math.floor(rand * this.jitter * ms);
|
|
3044
|
+
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
|
|
3045
|
+
}
|
|
3046
|
+
return Math.min(ms, this.max) | 0;
|
|
3047
|
+
};
|
|
3048
|
+
Backoff.prototype.reset = function() {
|
|
3049
|
+
this.attempts = 0;
|
|
3050
|
+
};
|
|
3051
|
+
Backoff.prototype.setMin = function(min) {
|
|
3052
|
+
this.ms = min;
|
|
3053
|
+
};
|
|
3054
|
+
Backoff.prototype.setMax = function(max) {
|
|
3055
|
+
this.max = max;
|
|
3056
|
+
};
|
|
3057
|
+
Backoff.prototype.setJitter = function(jitter) {
|
|
3058
|
+
this.jitter = jitter;
|
|
3059
|
+
};
|
|
3060
|
+
var Manager = /* @__PURE__ */ function(_Emitter) {
|
|
3061
|
+
_inherits(Manager2, _Emitter);
|
|
3062
|
+
var _super = _createSuper(Manager2);
|
|
3063
|
+
function Manager2(uri, opts) {
|
|
3064
|
+
var _this;
|
|
3065
|
+
_classCallCheck(this, Manager2);
|
|
3066
|
+
var _a;
|
|
3067
|
+
_this = _super.call(this);
|
|
3068
|
+
_this.nsps = {};
|
|
3069
|
+
_this.subs = [];
|
|
3070
|
+
if (uri && "object" === _typeof(uri)) {
|
|
3071
|
+
opts = uri;
|
|
3072
|
+
uri = void 0;
|
|
3073
|
+
}
|
|
3074
|
+
opts = opts || {};
|
|
3075
|
+
opts.path = opts.path || "/socket.io";
|
|
3076
|
+
_this.opts = opts;
|
|
3077
|
+
installTimerFunctions(_assertThisInitialized(_this), opts);
|
|
3078
|
+
_this.reconnection(opts.reconnection !== false);
|
|
3079
|
+
_this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
|
|
3080
|
+
_this.reconnectionDelay(opts.reconnectionDelay || 1e3);
|
|
3081
|
+
_this.reconnectionDelayMax(opts.reconnectionDelayMax || 5e3);
|
|
3082
|
+
_this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
|
|
3083
|
+
_this.backoff = new Backoff({
|
|
3084
|
+
min: _this.reconnectionDelay(),
|
|
3085
|
+
max: _this.reconnectionDelayMax(),
|
|
3086
|
+
jitter: _this.randomizationFactor()
|
|
3087
|
+
});
|
|
3088
|
+
_this.timeout(null == opts.timeout ? 2e4 : opts.timeout);
|
|
3089
|
+
_this._readyState = "closed";
|
|
3090
|
+
_this.uri = uri;
|
|
3091
|
+
var _parser = opts.parser || parser;
|
|
3092
|
+
_this.encoder = new _parser.Encoder();
|
|
3093
|
+
_this.decoder = new _parser.Decoder();
|
|
3094
|
+
_this._autoConnect = opts.autoConnect !== false;
|
|
3095
|
+
if (_this._autoConnect)
|
|
3096
|
+
_this.open();
|
|
3097
|
+
return _this;
|
|
3098
|
+
}
|
|
3099
|
+
_createClass(Manager2, [{
|
|
3100
|
+
key: "reconnection",
|
|
3101
|
+
value: function reconnection(v) {
|
|
3102
|
+
if (!arguments.length)
|
|
3103
|
+
return this._reconnection;
|
|
3104
|
+
this._reconnection = !!v;
|
|
3105
|
+
return this;
|
|
3106
|
+
}
|
|
3107
|
+
}, {
|
|
3108
|
+
key: "reconnectionAttempts",
|
|
3109
|
+
value: function reconnectionAttempts(v) {
|
|
3110
|
+
if (v === void 0)
|
|
3111
|
+
return this._reconnectionAttempts;
|
|
3112
|
+
this._reconnectionAttempts = v;
|
|
3113
|
+
return this;
|
|
3114
|
+
}
|
|
3115
|
+
}, {
|
|
3116
|
+
key: "reconnectionDelay",
|
|
3117
|
+
value: function reconnectionDelay(v) {
|
|
3118
|
+
var _a;
|
|
3119
|
+
if (v === void 0)
|
|
3120
|
+
return this._reconnectionDelay;
|
|
3121
|
+
this._reconnectionDelay = v;
|
|
3122
|
+
(_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
|
|
3123
|
+
return this;
|
|
3124
|
+
}
|
|
3125
|
+
}, {
|
|
3126
|
+
key: "randomizationFactor",
|
|
3127
|
+
value: function randomizationFactor(v) {
|
|
3128
|
+
var _a;
|
|
3129
|
+
if (v === void 0)
|
|
3130
|
+
return this._randomizationFactor;
|
|
3131
|
+
this._randomizationFactor = v;
|
|
3132
|
+
(_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
|
|
3133
|
+
return this;
|
|
3134
|
+
}
|
|
3135
|
+
}, {
|
|
3136
|
+
key: "reconnectionDelayMax",
|
|
3137
|
+
value: function reconnectionDelayMax(v) {
|
|
3138
|
+
var _a;
|
|
3139
|
+
if (v === void 0)
|
|
3140
|
+
return this._reconnectionDelayMax;
|
|
3141
|
+
this._reconnectionDelayMax = v;
|
|
3142
|
+
(_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
|
|
3143
|
+
return this;
|
|
3144
|
+
}
|
|
3145
|
+
}, {
|
|
3146
|
+
key: "timeout",
|
|
3147
|
+
value: function timeout(v) {
|
|
3148
|
+
if (!arguments.length)
|
|
3149
|
+
return this._timeout;
|
|
3150
|
+
this._timeout = v;
|
|
3151
|
+
return this;
|
|
3152
|
+
}
|
|
3153
|
+
/**
|
|
3154
|
+
* Starts trying to reconnect if reconnection is enabled and we have not
|
|
3155
|
+
* started reconnecting yet
|
|
3156
|
+
*
|
|
3157
|
+
* @private
|
|
3158
|
+
*/
|
|
3159
|
+
}, {
|
|
3160
|
+
key: "maybeReconnectOnOpen",
|
|
3161
|
+
value: function maybeReconnectOnOpen() {
|
|
3162
|
+
if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) {
|
|
3163
|
+
this.reconnect();
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
/**
|
|
3167
|
+
* Sets the current transport `socket`.
|
|
3168
|
+
*
|
|
3169
|
+
* @param {Function} fn - optional, callback
|
|
3170
|
+
* @return self
|
|
3171
|
+
* @public
|
|
3172
|
+
*/
|
|
3173
|
+
}, {
|
|
3174
|
+
key: "open",
|
|
3175
|
+
value: function open(fn) {
|
|
3176
|
+
var _this2 = this;
|
|
3177
|
+
if (~this._readyState.indexOf("open"))
|
|
3178
|
+
return this;
|
|
3179
|
+
this.engine = new Socket$1(this.uri, this.opts);
|
|
3180
|
+
var socket2 = this.engine;
|
|
3181
|
+
var self2 = this;
|
|
3182
|
+
this._readyState = "opening";
|
|
3183
|
+
this.skipReconnect = false;
|
|
3184
|
+
var openSubDestroy = on(socket2, "open", function() {
|
|
3185
|
+
self2.onopen();
|
|
3186
|
+
fn && fn();
|
|
3187
|
+
});
|
|
3188
|
+
var errorSub = on(socket2, "error", function(err) {
|
|
3189
|
+
self2.cleanup();
|
|
3190
|
+
self2._readyState = "closed";
|
|
3191
|
+
_this2.emitReserved("error", err);
|
|
3192
|
+
if (fn) {
|
|
3193
|
+
fn(err);
|
|
3194
|
+
} else {
|
|
3195
|
+
self2.maybeReconnectOnOpen();
|
|
3196
|
+
}
|
|
3197
|
+
});
|
|
3198
|
+
if (false !== this._timeout) {
|
|
3199
|
+
var timeout = this._timeout;
|
|
3200
|
+
if (timeout === 0) {
|
|
3201
|
+
openSubDestroy();
|
|
3202
|
+
}
|
|
3203
|
+
var timer = this.setTimeoutFn(function() {
|
|
3204
|
+
openSubDestroy();
|
|
3205
|
+
socket2.close();
|
|
3206
|
+
socket2.emit("error", new Error("timeout"));
|
|
3207
|
+
}, timeout);
|
|
3208
|
+
if (this.opts.autoUnref) {
|
|
3209
|
+
timer.unref();
|
|
3210
|
+
}
|
|
3211
|
+
this.subs.push(function subDestroy() {
|
|
3212
|
+
clearTimeout(timer);
|
|
3213
|
+
});
|
|
3214
|
+
}
|
|
3215
|
+
this.subs.push(openSubDestroy);
|
|
3216
|
+
this.subs.push(errorSub);
|
|
3217
|
+
return this;
|
|
3218
|
+
}
|
|
3219
|
+
/**
|
|
3220
|
+
* Alias for open()
|
|
3221
|
+
*
|
|
3222
|
+
* @return self
|
|
3223
|
+
* @public
|
|
3224
|
+
*/
|
|
3225
|
+
}, {
|
|
3226
|
+
key: "connect",
|
|
3227
|
+
value: function connect2(fn) {
|
|
3228
|
+
return this.open(fn);
|
|
3229
|
+
}
|
|
3230
|
+
/**
|
|
3231
|
+
* Called upon transport open.
|
|
3232
|
+
*
|
|
3233
|
+
* @private
|
|
3234
|
+
*/
|
|
3235
|
+
}, {
|
|
3236
|
+
key: "onopen",
|
|
3237
|
+
value: function onopen() {
|
|
3238
|
+
this.cleanup();
|
|
3239
|
+
this._readyState = "open";
|
|
3240
|
+
this.emitReserved("open");
|
|
3241
|
+
var socket2 = this.engine;
|
|
3242
|
+
this.subs.push(on(socket2, "ping", this.onping.bind(this)), on(socket2, "data", this.ondata.bind(this)), on(socket2, "error", this.onerror.bind(this)), on(socket2, "close", this.onclose.bind(this)), on(this.decoder, "decoded", this.ondecoded.bind(this)));
|
|
3243
|
+
}
|
|
3244
|
+
/**
|
|
3245
|
+
* Called upon a ping.
|
|
3246
|
+
*
|
|
3247
|
+
* @private
|
|
3248
|
+
*/
|
|
3249
|
+
}, {
|
|
3250
|
+
key: "onping",
|
|
3251
|
+
value: function onping() {
|
|
3252
|
+
this.emitReserved("ping");
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* Called with data.
|
|
3256
|
+
*
|
|
3257
|
+
* @private
|
|
3258
|
+
*/
|
|
3259
|
+
}, {
|
|
3260
|
+
key: "ondata",
|
|
3261
|
+
value: function ondata(data) {
|
|
3262
|
+
try {
|
|
3263
|
+
this.decoder.add(data);
|
|
3264
|
+
} catch (e) {
|
|
3265
|
+
this.onclose("parse error", e);
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Called when parser fully decodes a packet.
|
|
3270
|
+
*
|
|
3271
|
+
* @private
|
|
3272
|
+
*/
|
|
3273
|
+
}, {
|
|
3274
|
+
key: "ondecoded",
|
|
3275
|
+
value: function ondecoded(packet) {
|
|
3276
|
+
var _this3 = this;
|
|
3277
|
+
nextTick(function() {
|
|
3278
|
+
_this3.emitReserved("packet", packet);
|
|
3279
|
+
}, this.setTimeoutFn);
|
|
3280
|
+
}
|
|
3281
|
+
/**
|
|
3282
|
+
* Called upon socket error.
|
|
3283
|
+
*
|
|
3284
|
+
* @private
|
|
3285
|
+
*/
|
|
3286
|
+
}, {
|
|
3287
|
+
key: "onerror",
|
|
3288
|
+
value: function onerror(err) {
|
|
3289
|
+
this.emitReserved("error", err);
|
|
3290
|
+
}
|
|
3291
|
+
/**
|
|
3292
|
+
* Creates a new socket for the given `nsp`.
|
|
3293
|
+
*
|
|
3294
|
+
* @return {Socket}
|
|
3295
|
+
* @public
|
|
3296
|
+
*/
|
|
3297
|
+
}, {
|
|
3298
|
+
key: "socket",
|
|
3299
|
+
value: function socket2(nsp, opts) {
|
|
3300
|
+
var socket3 = this.nsps[nsp];
|
|
3301
|
+
if (!socket3) {
|
|
3302
|
+
socket3 = new Socket(this, nsp, opts);
|
|
3303
|
+
this.nsps[nsp] = socket3;
|
|
3304
|
+
}
|
|
3305
|
+
return socket3;
|
|
3306
|
+
}
|
|
3307
|
+
/**
|
|
3308
|
+
* Called upon a socket close.
|
|
3309
|
+
*
|
|
3310
|
+
* @param socket
|
|
3311
|
+
* @private
|
|
3312
|
+
*/
|
|
3313
|
+
}, {
|
|
3314
|
+
key: "_destroy",
|
|
3315
|
+
value: function _destroy(socket2) {
|
|
3316
|
+
var nsps = Object.keys(this.nsps);
|
|
3317
|
+
for (var _i = 0, _nsps = nsps; _i < _nsps.length; _i++) {
|
|
3318
|
+
var nsp = _nsps[_i];
|
|
3319
|
+
var _socket = this.nsps[nsp];
|
|
3320
|
+
if (_socket.active) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
this._close();
|
|
3325
|
+
}
|
|
3326
|
+
/**
|
|
3327
|
+
* Writes a packet.
|
|
3328
|
+
*
|
|
3329
|
+
* @param packet
|
|
3330
|
+
* @private
|
|
3331
|
+
*/
|
|
3332
|
+
}, {
|
|
3333
|
+
key: "_packet",
|
|
3334
|
+
value: function _packet(packet) {
|
|
3335
|
+
var encodedPackets = this.encoder.encode(packet);
|
|
3336
|
+
for (var i2 = 0; i2 < encodedPackets.length; i2++) {
|
|
3337
|
+
this.engine.write(encodedPackets[i2], packet.options);
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Clean up transport subscriptions and packet buffer.
|
|
3342
|
+
*
|
|
3343
|
+
* @private
|
|
3344
|
+
*/
|
|
3345
|
+
}, {
|
|
3346
|
+
key: "cleanup",
|
|
3347
|
+
value: function cleanup() {
|
|
3348
|
+
this.subs.forEach(function(subDestroy) {
|
|
3349
|
+
return subDestroy();
|
|
3350
|
+
});
|
|
3351
|
+
this.subs.length = 0;
|
|
3352
|
+
this.decoder.destroy();
|
|
3353
|
+
}
|
|
3354
|
+
/**
|
|
3355
|
+
* Close the current socket.
|
|
3356
|
+
*
|
|
3357
|
+
* @private
|
|
3358
|
+
*/
|
|
3359
|
+
}, {
|
|
3360
|
+
key: "_close",
|
|
3361
|
+
value: function _close() {
|
|
3362
|
+
this.skipReconnect = true;
|
|
3363
|
+
this._reconnecting = false;
|
|
3364
|
+
this.onclose("forced close");
|
|
3365
|
+
if (this.engine)
|
|
3366
|
+
this.engine.close();
|
|
3367
|
+
}
|
|
3368
|
+
/**
|
|
3369
|
+
* Alias for close()
|
|
3370
|
+
*
|
|
3371
|
+
* @private
|
|
3372
|
+
*/
|
|
3373
|
+
}, {
|
|
3374
|
+
key: "disconnect",
|
|
3375
|
+
value: function disconnect2() {
|
|
3376
|
+
return this._close();
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* Called upon engine close.
|
|
3380
|
+
*
|
|
3381
|
+
* @private
|
|
3382
|
+
*/
|
|
3383
|
+
}, {
|
|
3384
|
+
key: "onclose",
|
|
3385
|
+
value: function onclose(reason, description) {
|
|
3386
|
+
this.cleanup();
|
|
3387
|
+
this.backoff.reset();
|
|
3388
|
+
this._readyState = "closed";
|
|
3389
|
+
this.emitReserved("close", reason, description);
|
|
3390
|
+
if (this._reconnection && !this.skipReconnect) {
|
|
3391
|
+
this.reconnect();
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Attempt a reconnection.
|
|
3396
|
+
*
|
|
3397
|
+
* @private
|
|
3398
|
+
*/
|
|
3399
|
+
}, {
|
|
3400
|
+
key: "reconnect",
|
|
3401
|
+
value: function reconnect() {
|
|
3402
|
+
var _this4 = this;
|
|
3403
|
+
if (this._reconnecting || this.skipReconnect)
|
|
3404
|
+
return this;
|
|
3405
|
+
var self2 = this;
|
|
3406
|
+
if (this.backoff.attempts >= this._reconnectionAttempts) {
|
|
3407
|
+
this.backoff.reset();
|
|
3408
|
+
this.emitReserved("reconnect_failed");
|
|
3409
|
+
this._reconnecting = false;
|
|
3410
|
+
} else {
|
|
3411
|
+
var delay = this.backoff.duration();
|
|
3412
|
+
this._reconnecting = true;
|
|
3413
|
+
var timer = this.setTimeoutFn(function() {
|
|
3414
|
+
if (self2.skipReconnect)
|
|
3415
|
+
return;
|
|
3416
|
+
_this4.emitReserved("reconnect_attempt", self2.backoff.attempts);
|
|
3417
|
+
if (self2.skipReconnect)
|
|
3418
|
+
return;
|
|
3419
|
+
self2.open(function(err) {
|
|
3420
|
+
if (err) {
|
|
3421
|
+
self2._reconnecting = false;
|
|
3422
|
+
self2.reconnect();
|
|
3423
|
+
_this4.emitReserved("reconnect_error", err);
|
|
3424
|
+
} else {
|
|
3425
|
+
self2.onreconnect();
|
|
3426
|
+
}
|
|
3427
|
+
});
|
|
3428
|
+
}, delay);
|
|
3429
|
+
if (this.opts.autoUnref) {
|
|
3430
|
+
timer.unref();
|
|
3431
|
+
}
|
|
3432
|
+
this.subs.push(function subDestroy() {
|
|
3433
|
+
clearTimeout(timer);
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3437
|
+
/**
|
|
3438
|
+
* Called upon successful reconnect.
|
|
3439
|
+
*
|
|
3440
|
+
* @private
|
|
3441
|
+
*/
|
|
3442
|
+
}, {
|
|
3443
|
+
key: "onreconnect",
|
|
3444
|
+
value: function onreconnect() {
|
|
3445
|
+
var attempt = this.backoff.attempts;
|
|
3446
|
+
this._reconnecting = false;
|
|
3447
|
+
this.backoff.reset();
|
|
3448
|
+
this.emitReserved("reconnect", attempt);
|
|
3449
|
+
}
|
|
3450
|
+
}]);
|
|
3451
|
+
return Manager2;
|
|
3452
|
+
}(Emitter);
|
|
3453
|
+
var cache = {};
|
|
3454
|
+
function lookup(uri, opts) {
|
|
3455
|
+
if (_typeof(uri) === "object") {
|
|
3456
|
+
opts = uri;
|
|
3457
|
+
uri = void 0;
|
|
3458
|
+
}
|
|
3459
|
+
opts = opts || {};
|
|
3460
|
+
var parsed = url(uri, opts.path || "/socket.io");
|
|
3461
|
+
var source = parsed.source;
|
|
3462
|
+
var id = parsed.id;
|
|
3463
|
+
var path = parsed.path;
|
|
3464
|
+
var sameNamespace = cache[id] && path in cache[id]["nsps"];
|
|
3465
|
+
var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
|
|
3466
|
+
var io2;
|
|
3467
|
+
if (newConnection) {
|
|
3468
|
+
io2 = new Manager(source, opts);
|
|
3469
|
+
} else {
|
|
3470
|
+
if (!cache[id]) {
|
|
3471
|
+
cache[id] = new Manager(source, opts);
|
|
3472
|
+
}
|
|
3473
|
+
io2 = cache[id];
|
|
3474
|
+
}
|
|
3475
|
+
if (parsed.query && !opts.query) {
|
|
3476
|
+
opts.query = parsed.queryKey;
|
|
3477
|
+
}
|
|
3478
|
+
return io2.socket(parsed.path, opts);
|
|
3479
|
+
}
|
|
3480
|
+
_extends(lookup, {
|
|
3481
|
+
Manager,
|
|
3482
|
+
Socket,
|
|
3483
|
+
io: lookup,
|
|
3484
|
+
connect: lookup
|
|
3485
|
+
});
|
|
3486
|
+
return lookup;
|
|
3487
|
+
});
|
|
3488
|
+
}
|
|
3489
|
+
});
|
|
3490
|
+
|
|
3491
|
+
// client.js
|
|
3492
|
+
var client_exports = {};
|
|
3493
|
+
__export(client_exports, {
|
|
3494
|
+
connect: () => connect,
|
|
3495
|
+
disconnect: () => disconnect,
|
|
3496
|
+
send: () => send
|
|
3497
|
+
});
|
|
3498
|
+
module.exports = __toCommonJS(client_exports);
|
|
3499
|
+
|
|
3500
|
+
// ../../node_modules/@domql/globals/index.js
|
|
3501
|
+
var window2 = globalThis;
|
|
3502
|
+
var document2 = window2.document;
|
|
3503
|
+
|
|
3504
|
+
// ../../node_modules/@domql/utils/types.js
|
|
3505
|
+
var isObject = (arg) => {
|
|
3506
|
+
if (arg === null)
|
|
3507
|
+
return false;
|
|
3508
|
+
return typeof arg === "object" && arg.constructor === Object;
|
|
3509
|
+
};
|
|
3510
|
+
var isString = (arg) => typeof arg === "string";
|
|
3511
|
+
var isFunction = (arg) => typeof arg === "function";
|
|
3512
|
+
var isArray = (arg) => Array.isArray(arg);
|
|
3513
|
+
var isObjectLike = (arg) => {
|
|
3514
|
+
if (arg === null)
|
|
3515
|
+
return false;
|
|
3516
|
+
return typeof arg === "object";
|
|
3517
|
+
};
|
|
3518
|
+
|
|
3519
|
+
// ../../node_modules/@domql/utils/object.js
|
|
3520
|
+
var exec = (param, element, state) => {
|
|
3521
|
+
if (isFunction(param))
|
|
3522
|
+
return param(element, state || element.state);
|
|
3523
|
+
return param;
|
|
3524
|
+
};
|
|
3525
|
+
var map = (obj2, extention, element) => {
|
|
3526
|
+
for (const e in extention) {
|
|
3527
|
+
obj2[e] = exec(extention[e], element);
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3530
|
+
var merge = (element, obj2) => {
|
|
3531
|
+
for (const e in obj2) {
|
|
3532
|
+
const elementProp = element[e];
|
|
3533
|
+
const objProp2 = obj2[e];
|
|
3534
|
+
if (elementProp === void 0) {
|
|
3535
|
+
element[e] = objProp2;
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
return element;
|
|
3539
|
+
};
|
|
3540
|
+
var deepMerge = (element, extend) => {
|
|
3541
|
+
for (const e in extend) {
|
|
3542
|
+
const elementProp = element[e];
|
|
3543
|
+
const extendProp = extend[e];
|
|
3544
|
+
if (e === "parent" || e === "props")
|
|
3545
|
+
continue;
|
|
3546
|
+
if (elementProp === void 0) {
|
|
3547
|
+
element[e] = extendProp;
|
|
3548
|
+
} else if (isObjectLike(elementProp) && isObject(extendProp)) {
|
|
3549
|
+
deepMerge(elementProp, extendProp);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
return element;
|
|
3553
|
+
};
|
|
3554
|
+
var clone = (obj2) => {
|
|
3555
|
+
const o = {};
|
|
3556
|
+
for (const prop2 in obj2) {
|
|
3557
|
+
if (prop2 === "node")
|
|
3558
|
+
continue;
|
|
3559
|
+
o[prop2] = obj2[prop2];
|
|
3560
|
+
}
|
|
3561
|
+
return o;
|
|
3562
|
+
};
|
|
3563
|
+
var deepClone = (obj2) => {
|
|
3564
|
+
if (isArray(obj2)) {
|
|
3565
|
+
return obj2.map(deepClone);
|
|
3566
|
+
}
|
|
3567
|
+
const o = {};
|
|
3568
|
+
for (const prop2 in obj2) {
|
|
3569
|
+
let objProp2 = obj2[prop2];
|
|
3570
|
+
if (prop2 === "extend" && isArray(objProp2)) {
|
|
3571
|
+
objProp2 = mergeArray(objProp2);
|
|
3572
|
+
}
|
|
3573
|
+
if (isArray(objProp2)) {
|
|
3574
|
+
o[prop2] = objProp2.map((v) => isObject(v) ? deepClone(v) : v);
|
|
3575
|
+
} else if (isObject(objProp2)) {
|
|
3576
|
+
o[prop2] = deepClone(objProp2);
|
|
3577
|
+
} else
|
|
3578
|
+
o[prop2] = objProp2;
|
|
3579
|
+
}
|
|
3580
|
+
return o;
|
|
3581
|
+
};
|
|
3582
|
+
var deepStringify = (obj2, stringified2 = {}) => {
|
|
3583
|
+
console.log(obj2);
|
|
3584
|
+
for (const prop2 in obj2) {
|
|
3585
|
+
const objProp2 = obj2[prop2];
|
|
3586
|
+
if (isFunction(objProp2)) {
|
|
3587
|
+
stringified2[prop2] = objProp2.toString();
|
|
3588
|
+
} else
|
|
3589
|
+
stringified2[prop2] = objProp2;
|
|
3590
|
+
if (isObject(objProp2))
|
|
3591
|
+
deepStringify(stringified2[prop2], stringified2[prop2]);
|
|
3592
|
+
}
|
|
3593
|
+
return stringified2;
|
|
3594
|
+
};
|
|
3595
|
+
var deepDestringify = (obj, stringified = {}) => {
|
|
3596
|
+
for (const prop in obj) {
|
|
3597
|
+
const objProp = obj[prop];
|
|
3598
|
+
if (isString(objProp)) {
|
|
3599
|
+
if (objProp.slice(0, 1) === "(") {
|
|
3600
|
+
try {
|
|
3601
|
+
stringified[prop] = eval(objProp);
|
|
3602
|
+
} catch (e) {
|
|
3603
|
+
if (e)
|
|
3604
|
+
stringified[prop] = objProp;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
} else
|
|
3608
|
+
stringified[prop] = objProp;
|
|
3609
|
+
if (isObject(objProp))
|
|
3610
|
+
deepDestringify(stringified[prop], stringified[prop]);
|
|
3611
|
+
}
|
|
3612
|
+
return stringified;
|
|
3613
|
+
};
|
|
3614
|
+
var overwrite = (element, params, options) => {
|
|
3615
|
+
const { ref } = element;
|
|
3616
|
+
const changes = {};
|
|
3617
|
+
for (const e in params) {
|
|
3618
|
+
if (e === "props")
|
|
3619
|
+
continue;
|
|
3620
|
+
const elementProp = element[e];
|
|
3621
|
+
const paramsProp = params[e];
|
|
3622
|
+
if (paramsProp) {
|
|
3623
|
+
ref.__cache[e] = changes[e] = elementProp;
|
|
3624
|
+
ref[e] = paramsProp;
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
return changes;
|
|
3628
|
+
};
|
|
3629
|
+
var diff = (obj2, original, cache) => {
|
|
3630
|
+
const changes = cache || {};
|
|
3631
|
+
for (const e in obj2) {
|
|
3632
|
+
if (e === "ref")
|
|
3633
|
+
continue;
|
|
3634
|
+
const originalProp = original[e];
|
|
3635
|
+
const objProp2 = obj2[e];
|
|
3636
|
+
if (isObjectLike(originalProp) && isObjectLike(objProp2)) {
|
|
3637
|
+
changes[e] = {};
|
|
3638
|
+
diff(originalProp, objProp2, changes[e]);
|
|
3639
|
+
} else if (objProp2 !== void 0) {
|
|
3640
|
+
changes[e] = objProp2;
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
return changes;
|
|
3644
|
+
};
|
|
3645
|
+
var overwriteObj = (params, obj2) => {
|
|
3646
|
+
const changes = {};
|
|
3647
|
+
for (const e in params) {
|
|
3648
|
+
const objProp2 = obj2[e];
|
|
3649
|
+
const paramsProp = params[e];
|
|
3650
|
+
if (paramsProp) {
|
|
3651
|
+
obj2[e] = changes[e] = objProp2;
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
return changes;
|
|
3655
|
+
};
|
|
3656
|
+
var overwriteDeep = (params, obj2) => {
|
|
3657
|
+
for (const e in params) {
|
|
3658
|
+
const objProp2 = obj2[e];
|
|
3659
|
+
const paramsProp = params[e];
|
|
3660
|
+
if (isObjectLike(objProp2) && isObjectLike(paramsProp)) {
|
|
3661
|
+
overwriteDeep(objProp2, paramsProp);
|
|
3662
|
+
} else if (paramsProp !== void 0) {
|
|
3663
|
+
obj2[e] = paramsProp;
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
return obj2;
|
|
3667
|
+
};
|
|
3668
|
+
var mergeIfExisted = (a, b) => {
|
|
3669
|
+
if (isObjectLike(a) && isObjectLike(b))
|
|
3670
|
+
return deepMerge(a, b);
|
|
3671
|
+
return a || b;
|
|
3672
|
+
};
|
|
3673
|
+
var mergeArray = (arr) => {
|
|
3674
|
+
return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {});
|
|
3675
|
+
};
|
|
3676
|
+
var mergeAndCloneIfArray = (obj2) => {
|
|
3677
|
+
return isArray(obj2) ? mergeArray(obj2) : deepClone(obj2);
|
|
3678
|
+
};
|
|
3679
|
+
var flattenRecursive = (param, prop2, stack = []) => {
|
|
3680
|
+
const objectized = mergeAndCloneIfArray(param);
|
|
3681
|
+
stack.push(objectized);
|
|
3682
|
+
const extendOfExtend = objectized[prop2];
|
|
3683
|
+
if (extendOfExtend)
|
|
3684
|
+
flattenRecursive(extendOfExtend, prop2, stack);
|
|
3685
|
+
delete objectized[prop2];
|
|
3686
|
+
return stack;
|
|
3687
|
+
};
|
|
3688
|
+
var isEqualDeep = (param, element) => {
|
|
3689
|
+
if (param === element)
|
|
3690
|
+
return true;
|
|
3691
|
+
if (!param || !element)
|
|
3692
|
+
return false;
|
|
3693
|
+
for (const prop2 in param) {
|
|
3694
|
+
const paramProp = param[prop2];
|
|
3695
|
+
const elementProp = element[prop2];
|
|
3696
|
+
if (isObjectLike(paramProp)) {
|
|
3697
|
+
const isEqual = isEqualDeep(paramProp, elementProp);
|
|
3698
|
+
if (!isEqual)
|
|
3699
|
+
return false;
|
|
3700
|
+
} else {
|
|
3701
|
+
const isEqual = paramProp === elementProp;
|
|
3702
|
+
if (!isEqual)
|
|
3703
|
+
return false;
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3706
|
+
return true;
|
|
3707
|
+
};
|
|
3708
|
+
|
|
3709
|
+
// ../../node_modules/@domql/utils/node.js
|
|
3710
|
+
var createID = function* () {
|
|
3711
|
+
let index = 1;
|
|
3712
|
+
while (index < index + 1) {
|
|
3713
|
+
yield index++;
|
|
3714
|
+
}
|
|
3715
|
+
}();
|
|
3716
|
+
|
|
3717
|
+
// client.js
|
|
3718
|
+
var import_socket_io = __toESM(require_socket_io(), 1);
|
|
3719
|
+
var ENV = "development";
|
|
3720
|
+
var SOCKET_BACKEND_URL = window2.location?.host.includes("local") ? "localhost:13335" : "socket.symbols.app";
|
|
3721
|
+
var socket;
|
|
3722
|
+
var defautlOpts = {};
|
|
3723
|
+
var connect = (key, options = {}) => {
|
|
3724
|
+
const socketUrls = isArray(options.socketUrl) ? options.socketUrl : [options.socketUrl || SOCKET_BACKEND_URL];
|
|
3725
|
+
const primaryUrl = socketUrls[0];
|
|
3726
|
+
const secondaryUrl = socketUrls[1] || "socket.symbols.app";
|
|
3727
|
+
socket = (0, import_socket_io.default)(primaryUrl || SOCKET_BACKEND_URL);
|
|
3728
|
+
socket.on("connect", () => {
|
|
3729
|
+
if (ENV === "test" || ENV === "development") {
|
|
3730
|
+
console.log(
|
|
3731
|
+
`Connected to %c${primaryUrl || SOCKET_BACKEND_URL} %c${key} %c${socket.id}`,
|
|
3732
|
+
"font-weight: bold; color: green;",
|
|
3733
|
+
"font-weight: bold;",
|
|
3734
|
+
""
|
|
3735
|
+
);
|
|
3736
|
+
}
|
|
3737
|
+
socket.emit("initConnect", options);
|
|
3738
|
+
try {
|
|
3739
|
+
if (isFunction(options.onConnect))
|
|
3740
|
+
options.onConnect(socket.id, socket);
|
|
3741
|
+
} catch (e) {
|
|
3742
|
+
console.error(e);
|
|
3743
|
+
}
|
|
3744
|
+
});
|
|
3745
|
+
let tryConnect = 0;
|
|
3746
|
+
const tryConnectMax = 1;
|
|
3747
|
+
socket.on("connect_error", (err) => {
|
|
3748
|
+
console.log(err);
|
|
3749
|
+
console.log(`event: connect_error | reason: ${err.message}`);
|
|
3750
|
+
try {
|
|
3751
|
+
if (isFunction(options.onError))
|
|
3752
|
+
options.onError(err, socket);
|
|
3753
|
+
if (tryConnect === tryConnectMax) {
|
|
3754
|
+
socket.disconnect();
|
|
3755
|
+
if (primaryUrl !== secondaryUrl) {
|
|
3756
|
+
if (ENV === "test" || ENV === "development") {
|
|
3757
|
+
console.log(
|
|
3758
|
+
"Could not connect to %c" + primaryUrl + "%c, reconnecting to %c" + secondaryUrl,
|
|
3759
|
+
"font-weight: bold; color: red;",
|
|
3760
|
+
"",
|
|
3761
|
+
"font-weight: bold; color: green;"
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
connect(key, { ...options, socketUrl: secondaryUrl });
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
} catch (e) {
|
|
3768
|
+
console.error(e);
|
|
3769
|
+
}
|
|
3770
|
+
tryConnect++;
|
|
3771
|
+
});
|
|
3772
|
+
socket.on("disconnect", (reason) => {
|
|
3773
|
+
console.log(`event: disconnect | reason: ${reason}`);
|
|
3774
|
+
try {
|
|
3775
|
+
if (isFunction(options.onDisconnect))
|
|
3776
|
+
options.onDisconnect(reason, socket);
|
|
3777
|
+
} catch (e) {
|
|
3778
|
+
console.error(e);
|
|
3779
|
+
}
|
|
3780
|
+
});
|
|
3781
|
+
socket.onAny((event, ...args) => {
|
|
3782
|
+
if (event === "connect")
|
|
3783
|
+
return;
|
|
3784
|
+
try {
|
|
3785
|
+
if (isFunction(options.onChange))
|
|
3786
|
+
options.onChange(event, args[0], socket);
|
|
3787
|
+
} catch (e) {
|
|
3788
|
+
console.error(e);
|
|
3789
|
+
}
|
|
3790
|
+
});
|
|
3791
|
+
};
|
|
3792
|
+
var send = (event = "change", changes, options) => {
|
|
3793
|
+
socket.emit(event, changes, { ...options, ...defautlOpts });
|
|
3794
|
+
};
|
|
3795
|
+
var disconnect = () => {
|
|
3796
|
+
socket.disconnect();
|
|
3797
|
+
};
|
|
3798
|
+
/*! Bundled license information:
|
|
3799
|
+
|
|
3800
|
+
socket.io-client/dist/socket.io.js:
|
|
3801
|
+
(*!
|
|
3802
|
+
* Socket.IO v4.5.4
|
|
3803
|
+
* (c) 2014-2022 Guillermo Rauch
|
|
3804
|
+
* Released under the MIT License.
|
|
3805
|
+
*)
|
|
3806
|
+
*/
|