@jskit-ai/assistant-voice 0.1.1 → 0.1.2

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