create-airjam 0.1.8 → 0.2.0

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