@qwen-code/qwen-code 0.16.2 → 0.17.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 (73) hide show
  1. package/bundled/qc-helper/docs/configuration/settings.md +5 -1
  2. package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
  3. package/bundled/qc-helper/docs/features/channels/feishu.md +170 -0
  4. package/chunks/{agent-RY5EB3XR.js → agent-KVXFGIOU.js} +17 -12
  5. package/chunks/{anthropicContentGenerator-LYI3OHBB.js → anthropicContentGenerator-L4HWAOIV.js} +5 -5
  6. package/chunks/{askUserQuestion-R3MKD2JT.js → askUserQuestion-DC6OWQIL.js} +5 -3
  7. package/chunks/chunk-24YKA2DA.js +233 -0
  8. package/chunks/{chunk-UFC57OYT.js → chunk-33RDTIU6.js} +5 -3
  9. package/chunks/{chunk-C6WMLUNB.js → chunk-3BJBCG2K.js} +1 -1
  10. package/chunks/chunk-3HX5LZ6R.js +1798 -0
  11. package/chunks/{chunk-GQXXO5HJ.js → chunk-4O2TWJK4.js} +25 -5
  12. package/chunks/{chunk-RDYWTWEM.js → chunk-5IFG2VC4.js} +299 -232
  13. package/chunks/chunk-6RQTH7UQ.js +115 -0
  14. package/chunks/{chunk-7HM6OB7M.js → chunk-7EHPK6TK.js} +1336 -5164
  15. package/chunks/{chunk-PJLEMR7N.js → chunk-7NNBQRV7.js} +6 -6
  16. package/chunks/{chunk-K5PGHDBN.js → chunk-AKBFRR6J.js} +112 -132
  17. package/chunks/{chunk-C27V5A2J.js → chunk-EMVEDSVZ.js} +1 -1
  18. package/chunks/{chunk-TXQI3VZ7.js → chunk-GJHMAWS7.js} +1 -1
  19. package/chunks/{chunk-K72FHBFO.js → chunk-HAQCNXSG.js} +1 -0
  20. package/chunks/{chunk-T4VD6OJ4.js → chunk-HCSJIOLR.js} +1 -1
  21. package/chunks/chunk-J37FGIOA.js +1623 -0
  22. package/chunks/chunk-J5VCSWPA.js +1467 -0
  23. package/chunks/{chunk-UE5LPQF7.js → chunk-JI7FDD65.js} +7 -7
  24. package/chunks/{chunk-4YNZFYJY.js → chunk-MEN6IEKX.js} +2533 -3943
  25. package/chunks/{chunk-USE2VQ5P.js → chunk-NP3ICQCN.js} +1 -1
  26. package/chunks/{chunk-66CJCYYZ.js → chunk-QEXSIXLX.js} +1 -1
  27. package/chunks/{chunk-YMDXEEOW.js → chunk-R2B65CAN.js} +1 -82
  28. package/chunks/chunk-SZOEIL6S.js +35 -0
  29. package/chunks/chunk-TI4GXJKO.js +4277 -0
  30. package/chunks/{chunk-E7E2MFYM.js → chunk-U2K6HDUJ.js} +434 -13
  31. package/chunks/{chunk-FO7BIVSR.js → chunk-UQRYJQBE.js} +5 -3
  32. package/chunks/{chunk-VMOWXTRC.js → chunk-V7LMZR76.js} +1 -1
  33. package/chunks/chunk-W57YDFU5.js +41 -0
  34. package/chunks/computer-use-2J5ZXEER.js +768 -0
  35. package/chunks/{contextCommand-DDGVLQSF.js → contextCommand-52NTEMCT.js} +19 -14
  36. package/chunks/{cron-create-BTEOGHPH.js → cron-create-FXRORK2U.js} +5 -3
  37. package/chunks/{cron-delete-56CEWELN.js → cron-delete-D24IN6CA.js} +5 -3
  38. package/chunks/{cron-list-SV6QRZW2.js → cron-list-SMOX26SL.js} +5 -3
  39. package/chunks/{devtools-WN62SQPV.js → devtools-IXE4UP72.js} +31 -3748
  40. package/chunks/{dist-MN2PDDPR.js → dist-6RUZ2JD6.js} +13 -1612
  41. package/chunks/{dist-R2SXPG74.js → dist-AHZNZWRI.js} +5 -4
  42. package/chunks/dist-GRQVFL3G.js +94147 -0
  43. package/chunks/{dist-BXDUQ2QY.js → dist-XTTPOFAH.js} +4 -3
  44. package/chunks/{edit-4LLGNYVZ.js → edit-RLFUTT5F.js} +20 -14
  45. package/chunks/{enter-worktree-E2R5XAFT.js → enter-worktree-CYRAPQKJ.js} +20 -14
  46. package/chunks/{exit-worktree-YVBYYYDD.js → exit-worktree-WQZM72QD.js} +20 -14
  47. package/chunks/{exitPlanMode-WD5IH7NS.js → exitPlanMode-STFEBQZE.js} +20 -14
  48. package/chunks/{geminiContentGenerator-LM65ADWM.js → geminiContentGenerator-DIV32SKO.js} +4 -3
  49. package/chunks/{glob-6X6OCEWE.js → glob-N3XO4RVI.js} +20 -14
  50. package/chunks/{grep-2UUPSSIQ.js → grep-AK5MP7P3.js} +20 -14
  51. package/chunks/{ls-MYXAM7LJ.js → ls-7FYQHPWF.js} +5 -3
  52. package/chunks/{lsp-PFGI35JL.js → lsp-DKG34USR.js} +5 -3
  53. package/chunks/{monitor-VUHPEGUW.js → monitor-IVBWJZEZ.js} +20 -14
  54. package/chunks/{notebook-edit-P4QVLW6I.js → notebook-edit-PM46AXFS.js} +21 -15
  55. package/chunks/{openaiContentGenerator-JH4YNZ3H.js → openaiContentGenerator-4QXCH7L2.js} +13 -10
  56. package/chunks/{qwenContentGenerator-5FE4UYUT.js → qwenContentGenerator-BLXQIIMX.js} +21 -16
  57. package/chunks/{read-file-J7DH4OKV.js → read-file-IEQAS3EZ.js} +10 -6
  58. package/chunks/{ripGrep-33DECY4F.js → ripGrep-HQO7IE4C.js} +17 -12
  59. package/chunks/{send-message-JUFP62VD.js → send-message-ZL7CDM7K.js} +5 -3
  60. package/chunks/{serve-7FX7MREA.js → serve-CYRAK4UM.js} +63 -1837
  61. package/chunks/{shell-ZNTQIRK6.js → shell-UZBGNO2Q.js} +17 -12
  62. package/chunks/{skill-CFCUIY23.js → skill-JVC34QYN.js} +24 -13
  63. package/chunks/{src-AHV2CWEQ.js → src-FOODLH7B.js} +49 -41
  64. package/chunks/{syntheticOutput-AKTXC6FR.js → syntheticOutput-U3YJ3GOO.js} +3 -2
  65. package/chunks/{task-stop-2NYFR2ES.js → task-stop-NPUI3YBA.js} +5 -3
  66. package/chunks/{todoWrite-WHZ2O2XP.js → todoWrite-Y6F7YEIM.js} +6 -4
  67. package/chunks/{tool-search-C2EMLFBJ.js → tool-search-P7PRPOW3.js} +13 -8
  68. package/chunks/{web-fetch-S6MZXPZ5.js → web-fetch-XWEK4TFX.js} +6 -4
  69. package/chunks/{write-file-EEPVRS4Q.js → write-file-SIIEUON5.js} +21 -15
  70. package/cli.js +412 -329
  71. package/package.json +2 -2
  72. package/chunks/chunk-JVD46YJV.js +0 -434
  73. package/chunks/undici-4ARNOH74.js +0 -8
@@ -1,3721 +1,18 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
+ import {
4
+ wrapper_default
5
+ } from "./chunk-SZOEIL6S.js";
6
+ import "./chunk-5IFG2VC4.js";
3
7
  import {
4
8
  init_esbuild_shims
5
9
  } from "./chunk-A4BMJM77.js";
6
10
  import {
7
11
  __commonJS,
8
12
  __name,
9
- __require,
10
13
  __toESM
11
14
  } from "./chunk-J2S4EL5Y.js";
12
15
 
13
- // node_modules/ink/node_modules/ws/lib/constants.js
14
- var require_constants = __commonJS({
15
- "node_modules/ink/node_modules/ws/lib/constants.js"(exports, module) {
16
- "use strict";
17
- init_esbuild_shims();
18
- var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
19
- var hasBlob = typeof Blob !== "undefined";
20
- if (hasBlob) BINARY_TYPES.push("blob");
21
- module.exports = {
22
- BINARY_TYPES,
23
- CLOSE_TIMEOUT: 3e4,
24
- EMPTY_BUFFER: Buffer.alloc(0),
25
- GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
26
- hasBlob,
27
- kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
28
- kListener: Symbol("kListener"),
29
- kStatusCode: Symbol("status-code"),
30
- kWebSocket: Symbol("websocket"),
31
- NOOP: /* @__PURE__ */ __name(() => {
32
- }, "NOOP")
33
- };
34
- }
35
- });
36
-
37
- // node_modules/ink/node_modules/ws/lib/buffer-util.js
38
- var require_buffer_util = __commonJS({
39
- "node_modules/ink/node_modules/ws/lib/buffer-util.js"(exports, module) {
40
- "use strict";
41
- init_esbuild_shims();
42
- var { EMPTY_BUFFER } = require_constants();
43
- var FastBuffer = Buffer[Symbol.species];
44
- function concat(list, totalLength) {
45
- if (list.length === 0) return EMPTY_BUFFER;
46
- if (list.length === 1) return list[0];
47
- const target = Buffer.allocUnsafe(totalLength);
48
- let offset = 0;
49
- for (let i = 0; i < list.length; i++) {
50
- const buf = list[i];
51
- target.set(buf, offset);
52
- offset += buf.length;
53
- }
54
- if (offset < totalLength) {
55
- return new FastBuffer(target.buffer, target.byteOffset, offset);
56
- }
57
- return target;
58
- }
59
- __name(concat, "concat");
60
- function _mask(source, mask, output, offset, length) {
61
- for (let i = 0; i < length; i++) {
62
- output[offset + i] = source[i] ^ mask[i & 3];
63
- }
64
- }
65
- __name(_mask, "_mask");
66
- function _unmask(buffer, mask) {
67
- for (let i = 0; i < buffer.length; i++) {
68
- buffer[i] ^= mask[i & 3];
69
- }
70
- }
71
- __name(_unmask, "_unmask");
72
- function toArrayBuffer(buf) {
73
- if (buf.length === buf.buffer.byteLength) {
74
- return buf.buffer;
75
- }
76
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
77
- }
78
- __name(toArrayBuffer, "toArrayBuffer");
79
- function toBuffer(data) {
80
- toBuffer.readOnly = true;
81
- if (Buffer.isBuffer(data)) return data;
82
- let buf;
83
- if (data instanceof ArrayBuffer) {
84
- buf = new FastBuffer(data);
85
- } else if (ArrayBuffer.isView(data)) {
86
- buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
87
- } else {
88
- buf = Buffer.from(data);
89
- toBuffer.readOnly = false;
90
- }
91
- return buf;
92
- }
93
- __name(toBuffer, "toBuffer");
94
- module.exports = {
95
- concat,
96
- mask: _mask,
97
- toArrayBuffer,
98
- toBuffer,
99
- unmask: _unmask
100
- };
101
- if (!process.env.WS_NO_BUFFER_UTIL) {
102
- try {
103
- const bufferUtil = __require("bufferutil");
104
- module.exports.mask = function(source, mask, output, offset, length) {
105
- if (length < 48) _mask(source, mask, output, offset, length);
106
- else bufferUtil.mask(source, mask, output, offset, length);
107
- };
108
- module.exports.unmask = function(buffer, mask) {
109
- if (buffer.length < 32) _unmask(buffer, mask);
110
- else bufferUtil.unmask(buffer, mask);
111
- };
112
- } catch (e) {
113
- }
114
- }
115
- }
116
- });
117
-
118
- // node_modules/ink/node_modules/ws/lib/limiter.js
119
- var require_limiter = __commonJS({
120
- "node_modules/ink/node_modules/ws/lib/limiter.js"(exports, module) {
121
- "use strict";
122
- init_esbuild_shims();
123
- var kDone = Symbol("kDone");
124
- var kRun = Symbol("kRun");
125
- var Limiter = class {
126
- static {
127
- __name(this, "Limiter");
128
- }
129
- /**
130
- * Creates a new `Limiter`.
131
- *
132
- * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
133
- * to run concurrently
134
- */
135
- constructor(concurrency) {
136
- this[kDone] = () => {
137
- this.pending--;
138
- this[kRun]();
139
- };
140
- this.concurrency = concurrency || Infinity;
141
- this.jobs = [];
142
- this.pending = 0;
143
- }
144
- /**
145
- * Adds a job to the queue.
146
- *
147
- * @param {Function} job The job to run
148
- * @public
149
- */
150
- add(job) {
151
- this.jobs.push(job);
152
- this[kRun]();
153
- }
154
- /**
155
- * Removes a job from the queue and runs it if possible.
156
- *
157
- * @private
158
- */
159
- [kRun]() {
160
- if (this.pending === this.concurrency) return;
161
- if (this.jobs.length) {
162
- const job = this.jobs.shift();
163
- this.pending++;
164
- job(this[kDone]);
165
- }
166
- }
167
- };
168
- module.exports = Limiter;
169
- }
170
- });
171
-
172
- // node_modules/ink/node_modules/ws/lib/permessage-deflate.js
173
- var require_permessage_deflate = __commonJS({
174
- "node_modules/ink/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
175
- "use strict";
176
- init_esbuild_shims();
177
- var zlib = __require("zlib");
178
- var bufferUtil = require_buffer_util();
179
- var Limiter = require_limiter();
180
- var { kStatusCode } = require_constants();
181
- var FastBuffer = Buffer[Symbol.species];
182
- var TRAILER = Buffer.from([0, 0, 255, 255]);
183
- var kPerMessageDeflate = Symbol("permessage-deflate");
184
- var kTotalLength = Symbol("total-length");
185
- var kCallback = Symbol("callback");
186
- var kBuffers = Symbol("buffers");
187
- var kError = Symbol("error");
188
- var zlibLimiter;
189
- var PerMessageDeflate2 = class {
190
- static {
191
- __name(this, "PerMessageDeflate");
192
- }
193
- /**
194
- * Creates a PerMessageDeflate instance.
195
- *
196
- * @param {Object} [options] Configuration options
197
- * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
198
- * for, or request, a custom client window size
199
- * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
200
- * acknowledge disabling of client context takeover
201
- * @param {Number} [options.concurrencyLimit=10] The number of concurrent
202
- * calls to zlib
203
- * @param {Boolean} [options.isServer=false] Create the instance in either
204
- * server or client mode
205
- * @param {Number} [options.maxPayload=0] The maximum allowed message length
206
- * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
207
- * use of a custom server window size
208
- * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
209
- * disabling of server context takeover
210
- * @param {Number} [options.threshold=1024] Size (in bytes) below which
211
- * messages should not be compressed if context takeover is disabled
212
- * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
213
- * deflate
214
- * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
215
- * inflate
216
- */
217
- constructor(options) {
218
- this._options = options || {};
219
- this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
220
- this._maxPayload = this._options.maxPayload | 0;
221
- this._isServer = !!this._options.isServer;
222
- this._deflate = null;
223
- this._inflate = null;
224
- this.params = null;
225
- if (!zlibLimiter) {
226
- const concurrency = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
227
- zlibLimiter = new Limiter(concurrency);
228
- }
229
- }
230
- /**
231
- * @type {String}
232
- */
233
- static get extensionName() {
234
- return "permessage-deflate";
235
- }
236
- /**
237
- * Create an extension negotiation offer.
238
- *
239
- * @return {Object} Extension parameters
240
- * @public
241
- */
242
- offer() {
243
- const params = {};
244
- if (this._options.serverNoContextTakeover) {
245
- params.server_no_context_takeover = true;
246
- }
247
- if (this._options.clientNoContextTakeover) {
248
- params.client_no_context_takeover = true;
249
- }
250
- if (this._options.serverMaxWindowBits) {
251
- params.server_max_window_bits = this._options.serverMaxWindowBits;
252
- }
253
- if (this._options.clientMaxWindowBits) {
254
- params.client_max_window_bits = this._options.clientMaxWindowBits;
255
- } else if (this._options.clientMaxWindowBits == null) {
256
- params.client_max_window_bits = true;
257
- }
258
- return params;
259
- }
260
- /**
261
- * Accept an extension negotiation offer/response.
262
- *
263
- * @param {Array} configurations The extension negotiation offers/reponse
264
- * @return {Object} Accepted configuration
265
- * @public
266
- */
267
- accept(configurations) {
268
- configurations = this.normalizeParams(configurations);
269
- this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
270
- return this.params;
271
- }
272
- /**
273
- * Releases all resources used by the extension.
274
- *
275
- * @public
276
- */
277
- cleanup() {
278
- if (this._inflate) {
279
- this._inflate.close();
280
- this._inflate = null;
281
- }
282
- if (this._deflate) {
283
- const callback = this._deflate[kCallback];
284
- this._deflate.close();
285
- this._deflate = null;
286
- if (callback) {
287
- callback(
288
- new Error(
289
- "The deflate stream was closed while data was being processed"
290
- )
291
- );
292
- }
293
- }
294
- }
295
- /**
296
- * Accept an extension negotiation offer.
297
- *
298
- * @param {Array} offers The extension negotiation offers
299
- * @return {Object} Accepted configuration
300
- * @private
301
- */
302
- acceptAsServer(offers) {
303
- const opts = this._options;
304
- const accepted = offers.find((params) => {
305
- if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
306
- return false;
307
- }
308
- return true;
309
- });
310
- if (!accepted) {
311
- throw new Error("None of the extension offers can be accepted");
312
- }
313
- if (opts.serverNoContextTakeover) {
314
- accepted.server_no_context_takeover = true;
315
- }
316
- if (opts.clientNoContextTakeover) {
317
- accepted.client_no_context_takeover = true;
318
- }
319
- if (typeof opts.serverMaxWindowBits === "number") {
320
- accepted.server_max_window_bits = opts.serverMaxWindowBits;
321
- }
322
- if (typeof opts.clientMaxWindowBits === "number") {
323
- accepted.client_max_window_bits = opts.clientMaxWindowBits;
324
- } else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
325
- delete accepted.client_max_window_bits;
326
- }
327
- return accepted;
328
- }
329
- /**
330
- * Accept the extension negotiation response.
331
- *
332
- * @param {Array} response The extension negotiation response
333
- * @return {Object} Accepted configuration
334
- * @private
335
- */
336
- acceptAsClient(response) {
337
- const params = response[0];
338
- if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
339
- throw new Error('Unexpected parameter "client_no_context_takeover"');
340
- }
341
- if (!params.client_max_window_bits) {
342
- if (typeof this._options.clientMaxWindowBits === "number") {
343
- params.client_max_window_bits = this._options.clientMaxWindowBits;
344
- }
345
- } else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
346
- throw new Error(
347
- 'Unexpected or invalid parameter "client_max_window_bits"'
348
- );
349
- }
350
- return params;
351
- }
352
- /**
353
- * Normalize parameters.
354
- *
355
- * @param {Array} configurations The extension negotiation offers/reponse
356
- * @return {Array} The offers/response with normalized parameters
357
- * @private
358
- */
359
- normalizeParams(configurations) {
360
- configurations.forEach((params) => {
361
- Object.keys(params).forEach((key) => {
362
- let value = params[key];
363
- if (value.length > 1) {
364
- throw new Error(`Parameter "${key}" must have only a single value`);
365
- }
366
- value = value[0];
367
- if (key === "client_max_window_bits") {
368
- if (value !== true) {
369
- const num = +value;
370
- if (!Number.isInteger(num) || num < 8 || num > 15) {
371
- throw new TypeError(
372
- `Invalid value for parameter "${key}": ${value}`
373
- );
374
- }
375
- value = num;
376
- } else if (!this._isServer) {
377
- throw new TypeError(
378
- `Invalid value for parameter "${key}": ${value}`
379
- );
380
- }
381
- } else if (key === "server_max_window_bits") {
382
- const num = +value;
383
- if (!Number.isInteger(num) || num < 8 || num > 15) {
384
- throw new TypeError(
385
- `Invalid value for parameter "${key}": ${value}`
386
- );
387
- }
388
- value = num;
389
- } else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
390
- if (value !== true) {
391
- throw new TypeError(
392
- `Invalid value for parameter "${key}": ${value}`
393
- );
394
- }
395
- } else {
396
- throw new Error(`Unknown parameter "${key}"`);
397
- }
398
- params[key] = value;
399
- });
400
- });
401
- return configurations;
402
- }
403
- /**
404
- * Decompress data. Concurrency limited.
405
- *
406
- * @param {Buffer} data Compressed data
407
- * @param {Boolean} fin Specifies whether or not this is the last fragment
408
- * @param {Function} callback Callback
409
- * @public
410
- */
411
- decompress(data, fin, callback) {
412
- zlibLimiter.add((done) => {
413
- this._decompress(data, fin, (err, result) => {
414
- done();
415
- callback(err, result);
416
- });
417
- });
418
- }
419
- /**
420
- * Compress data. Concurrency limited.
421
- *
422
- * @param {(Buffer|String)} data Data to compress
423
- * @param {Boolean} fin Specifies whether or not this is the last fragment
424
- * @param {Function} callback Callback
425
- * @public
426
- */
427
- compress(data, fin, callback) {
428
- zlibLimiter.add((done) => {
429
- this._compress(data, fin, (err, result) => {
430
- done();
431
- callback(err, result);
432
- });
433
- });
434
- }
435
- /**
436
- * Decompress data.
437
- *
438
- * @param {Buffer} data Compressed data
439
- * @param {Boolean} fin Specifies whether or not this is the last fragment
440
- * @param {Function} callback Callback
441
- * @private
442
- */
443
- _decompress(data, fin, callback) {
444
- const endpoint = this._isServer ? "client" : "server";
445
- if (!this._inflate) {
446
- const key = `${endpoint}_max_window_bits`;
447
- const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
448
- this._inflate = zlib.createInflateRaw({
449
- ...this._options.zlibInflateOptions,
450
- windowBits
451
- });
452
- this._inflate[kPerMessageDeflate] = this;
453
- this._inflate[kTotalLength] = 0;
454
- this._inflate[kBuffers] = [];
455
- this._inflate.on("error", inflateOnError);
456
- this._inflate.on("data", inflateOnData);
457
- }
458
- this._inflate[kCallback] = callback;
459
- this._inflate.write(data);
460
- if (fin) this._inflate.write(TRAILER);
461
- this._inflate.flush(() => {
462
- const err = this._inflate[kError];
463
- if (err) {
464
- this._inflate.close();
465
- this._inflate = null;
466
- callback(err);
467
- return;
468
- }
469
- const data2 = bufferUtil.concat(
470
- this._inflate[kBuffers],
471
- this._inflate[kTotalLength]
472
- );
473
- if (this._inflate._readableState.endEmitted) {
474
- this._inflate.close();
475
- this._inflate = null;
476
- } else {
477
- this._inflate[kTotalLength] = 0;
478
- this._inflate[kBuffers] = [];
479
- if (fin && this.params[`${endpoint}_no_context_takeover`]) {
480
- this._inflate.reset();
481
- }
482
- }
483
- callback(null, data2);
484
- });
485
- }
486
- /**
487
- * Compress data.
488
- *
489
- * @param {(Buffer|String)} data Data to compress
490
- * @param {Boolean} fin Specifies whether or not this is the last fragment
491
- * @param {Function} callback Callback
492
- * @private
493
- */
494
- _compress(data, fin, callback) {
495
- const endpoint = this._isServer ? "server" : "client";
496
- if (!this._deflate) {
497
- const key = `${endpoint}_max_window_bits`;
498
- const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
499
- this._deflate = zlib.createDeflateRaw({
500
- ...this._options.zlibDeflateOptions,
501
- windowBits
502
- });
503
- this._deflate[kTotalLength] = 0;
504
- this._deflate[kBuffers] = [];
505
- this._deflate.on("data", deflateOnData);
506
- }
507
- this._deflate[kCallback] = callback;
508
- this._deflate.write(data);
509
- this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
510
- if (!this._deflate) {
511
- return;
512
- }
513
- let data2 = bufferUtil.concat(
514
- this._deflate[kBuffers],
515
- this._deflate[kTotalLength]
516
- );
517
- if (fin) {
518
- data2 = new FastBuffer(data2.buffer, data2.byteOffset, data2.length - 4);
519
- }
520
- this._deflate[kCallback] = null;
521
- this._deflate[kTotalLength] = 0;
522
- this._deflate[kBuffers] = [];
523
- if (fin && this.params[`${endpoint}_no_context_takeover`]) {
524
- this._deflate.reset();
525
- }
526
- callback(null, data2);
527
- });
528
- }
529
- };
530
- module.exports = PerMessageDeflate2;
531
- function deflateOnData(chunk) {
532
- this[kBuffers].push(chunk);
533
- this[kTotalLength] += chunk.length;
534
- }
535
- __name(deflateOnData, "deflateOnData");
536
- function inflateOnData(chunk) {
537
- this[kTotalLength] += chunk.length;
538
- if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
539
- this[kBuffers].push(chunk);
540
- return;
541
- }
542
- this[kError] = new RangeError("Max payload size exceeded");
543
- this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
544
- this[kError][kStatusCode] = 1009;
545
- this.removeListener("data", inflateOnData);
546
- this.reset();
547
- }
548
- __name(inflateOnData, "inflateOnData");
549
- function inflateOnError(err) {
550
- this[kPerMessageDeflate]._inflate = null;
551
- if (this[kError]) {
552
- this[kCallback](this[kError]);
553
- return;
554
- }
555
- err[kStatusCode] = 1007;
556
- this[kCallback](err);
557
- }
558
- __name(inflateOnError, "inflateOnError");
559
- }
560
- });
561
-
562
- // node_modules/ink/node_modules/ws/lib/validation.js
563
- var require_validation = __commonJS({
564
- "node_modules/ink/node_modules/ws/lib/validation.js"(exports, module) {
565
- "use strict";
566
- init_esbuild_shims();
567
- var { isUtf8 } = __require("buffer");
568
- var { hasBlob } = require_constants();
569
- var tokenChars = [
570
- 0,
571
- 0,
572
- 0,
573
- 0,
574
- 0,
575
- 0,
576
- 0,
577
- 0,
578
- 0,
579
- 0,
580
- 0,
581
- 0,
582
- 0,
583
- 0,
584
- 0,
585
- 0,
586
- // 0 - 15
587
- 0,
588
- 0,
589
- 0,
590
- 0,
591
- 0,
592
- 0,
593
- 0,
594
- 0,
595
- 0,
596
- 0,
597
- 0,
598
- 0,
599
- 0,
600
- 0,
601
- 0,
602
- 0,
603
- // 16 - 31
604
- 0,
605
- 1,
606
- 0,
607
- 1,
608
- 1,
609
- 1,
610
- 1,
611
- 1,
612
- 0,
613
- 0,
614
- 1,
615
- 1,
616
- 0,
617
- 1,
618
- 1,
619
- 0,
620
- // 32 - 47
621
- 1,
622
- 1,
623
- 1,
624
- 1,
625
- 1,
626
- 1,
627
- 1,
628
- 1,
629
- 1,
630
- 1,
631
- 0,
632
- 0,
633
- 0,
634
- 0,
635
- 0,
636
- 0,
637
- // 48 - 63
638
- 0,
639
- 1,
640
- 1,
641
- 1,
642
- 1,
643
- 1,
644
- 1,
645
- 1,
646
- 1,
647
- 1,
648
- 1,
649
- 1,
650
- 1,
651
- 1,
652
- 1,
653
- 1,
654
- // 64 - 79
655
- 1,
656
- 1,
657
- 1,
658
- 1,
659
- 1,
660
- 1,
661
- 1,
662
- 1,
663
- 1,
664
- 1,
665
- 1,
666
- 0,
667
- 0,
668
- 0,
669
- 1,
670
- 1,
671
- // 80 - 95
672
- 1,
673
- 1,
674
- 1,
675
- 1,
676
- 1,
677
- 1,
678
- 1,
679
- 1,
680
- 1,
681
- 1,
682
- 1,
683
- 1,
684
- 1,
685
- 1,
686
- 1,
687
- 1,
688
- // 96 - 111
689
- 1,
690
- 1,
691
- 1,
692
- 1,
693
- 1,
694
- 1,
695
- 1,
696
- 1,
697
- 1,
698
- 1,
699
- 1,
700
- 0,
701
- 1,
702
- 0,
703
- 1,
704
- 0
705
- // 112 - 127
706
- ];
707
- function isValidStatusCode(code) {
708
- return code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;
709
- }
710
- __name(isValidStatusCode, "isValidStatusCode");
711
- function _isValidUTF8(buf) {
712
- const len = buf.length;
713
- let i = 0;
714
- while (i < len) {
715
- if ((buf[i] & 128) === 0) {
716
- i++;
717
- } else if ((buf[i] & 224) === 192) {
718
- if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
719
- return false;
720
- }
721
- i += 2;
722
- } else if ((buf[i] & 240) === 224) {
723
- if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // Overlong
724
- buf[i] === 237 && (buf[i + 1] & 224) === 160) {
725
- return false;
726
- }
727
- i += 3;
728
- } else if ((buf[i] & 248) === 240) {
729
- if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // Overlong
730
- buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
731
- return false;
732
- }
733
- i += 4;
734
- } else {
735
- return false;
736
- }
737
- }
738
- return true;
739
- }
740
- __name(_isValidUTF8, "_isValidUTF8");
741
- function isBlob(value) {
742
- return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
743
- }
744
- __name(isBlob, "isBlob");
745
- module.exports = {
746
- isBlob,
747
- isValidStatusCode,
748
- isValidUTF8: _isValidUTF8,
749
- tokenChars
750
- };
751
- if (isUtf8) {
752
- module.exports.isValidUTF8 = function(buf) {
753
- return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
754
- };
755
- } else if (!process.env.WS_NO_UTF_8_VALIDATE) {
756
- try {
757
- const isValidUTF8 = __require("utf-8-validate");
758
- module.exports.isValidUTF8 = function(buf) {
759
- return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
760
- };
761
- } catch (e) {
762
- }
763
- }
764
- }
765
- });
766
-
767
- // node_modules/ink/node_modules/ws/lib/receiver.js
768
- var require_receiver = __commonJS({
769
- "node_modules/ink/node_modules/ws/lib/receiver.js"(exports, module) {
770
- "use strict";
771
- init_esbuild_shims();
772
- var { Writable } = __require("stream");
773
- var PerMessageDeflate2 = require_permessage_deflate();
774
- var {
775
- BINARY_TYPES,
776
- EMPTY_BUFFER,
777
- kStatusCode,
778
- kWebSocket
779
- } = require_constants();
780
- var { concat, toArrayBuffer, unmask } = require_buffer_util();
781
- var { isValidStatusCode, isValidUTF8 } = require_validation();
782
- var FastBuffer = Buffer[Symbol.species];
783
- var GET_INFO = 0;
784
- var GET_PAYLOAD_LENGTH_16 = 1;
785
- var GET_PAYLOAD_LENGTH_64 = 2;
786
- var GET_MASK = 3;
787
- var GET_DATA = 4;
788
- var INFLATING = 5;
789
- var DEFER_EVENT = 6;
790
- var Receiver2 = class extends Writable {
791
- static {
792
- __name(this, "Receiver");
793
- }
794
- /**
795
- * Creates a Receiver instance.
796
- *
797
- * @param {Object} [options] Options object
798
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
799
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
800
- * multiple times in the same tick
801
- * @param {String} [options.binaryType=nodebuffer] The type for binary data
802
- * @param {Object} [options.extensions] An object containing the negotiated
803
- * extensions
804
- * @param {Boolean} [options.isServer=false] Specifies whether to operate in
805
- * client or server mode
806
- * @param {Number} [options.maxPayload=0] The maximum allowed message length
807
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
808
- * not to skip UTF-8 validation for text and close messages
809
- */
810
- constructor(options = {}) {
811
- super();
812
- this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
813
- this._binaryType = options.binaryType || BINARY_TYPES[0];
814
- this._extensions = options.extensions || {};
815
- this._isServer = !!options.isServer;
816
- this._maxPayload = options.maxPayload | 0;
817
- this._skipUTF8Validation = !!options.skipUTF8Validation;
818
- this[kWebSocket] = void 0;
819
- this._bufferedBytes = 0;
820
- this._buffers = [];
821
- this._compressed = false;
822
- this._payloadLength = 0;
823
- this._mask = void 0;
824
- this._fragmented = 0;
825
- this._masked = false;
826
- this._fin = false;
827
- this._opcode = 0;
828
- this._totalPayloadLength = 0;
829
- this._messageLength = 0;
830
- this._fragments = [];
831
- this._errored = false;
832
- this._loop = false;
833
- this._state = GET_INFO;
834
- }
835
- /**
836
- * Implements `Writable.prototype._write()`.
837
- *
838
- * @param {Buffer} chunk The chunk of data to write
839
- * @param {String} encoding The character encoding of `chunk`
840
- * @param {Function} cb Callback
841
- * @private
842
- */
843
- _write(chunk, encoding, cb) {
844
- if (this._opcode === 8 && this._state == GET_INFO) return cb();
845
- this._bufferedBytes += chunk.length;
846
- this._buffers.push(chunk);
847
- this.startLoop(cb);
848
- }
849
- /**
850
- * Consumes `n` bytes from the buffered data.
851
- *
852
- * @param {Number} n The number of bytes to consume
853
- * @return {Buffer} The consumed bytes
854
- * @private
855
- */
856
- consume(n) {
857
- this._bufferedBytes -= n;
858
- if (n === this._buffers[0].length) return this._buffers.shift();
859
- if (n < this._buffers[0].length) {
860
- const buf = this._buffers[0];
861
- this._buffers[0] = new FastBuffer(
862
- buf.buffer,
863
- buf.byteOffset + n,
864
- buf.length - n
865
- );
866
- return new FastBuffer(buf.buffer, buf.byteOffset, n);
867
- }
868
- const dst = Buffer.allocUnsafe(n);
869
- do {
870
- const buf = this._buffers[0];
871
- const offset = dst.length - n;
872
- if (n >= buf.length) {
873
- dst.set(this._buffers.shift(), offset);
874
- } else {
875
- dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
876
- this._buffers[0] = new FastBuffer(
877
- buf.buffer,
878
- buf.byteOffset + n,
879
- buf.length - n
880
- );
881
- }
882
- n -= buf.length;
883
- } while (n > 0);
884
- return dst;
885
- }
886
- /**
887
- * Starts the parsing loop.
888
- *
889
- * @param {Function} cb Callback
890
- * @private
891
- */
892
- startLoop(cb) {
893
- this._loop = true;
894
- do {
895
- switch (this._state) {
896
- case GET_INFO:
897
- this.getInfo(cb);
898
- break;
899
- case GET_PAYLOAD_LENGTH_16:
900
- this.getPayloadLength16(cb);
901
- break;
902
- case GET_PAYLOAD_LENGTH_64:
903
- this.getPayloadLength64(cb);
904
- break;
905
- case GET_MASK:
906
- this.getMask();
907
- break;
908
- case GET_DATA:
909
- this.getData(cb);
910
- break;
911
- case INFLATING:
912
- case DEFER_EVENT:
913
- this._loop = false;
914
- return;
915
- }
916
- } while (this._loop);
917
- if (!this._errored) cb();
918
- }
919
- /**
920
- * Reads the first two bytes of a frame.
921
- *
922
- * @param {Function} cb Callback
923
- * @private
924
- */
925
- getInfo(cb) {
926
- if (this._bufferedBytes < 2) {
927
- this._loop = false;
928
- return;
929
- }
930
- const buf = this.consume(2);
931
- if ((buf[0] & 48) !== 0) {
932
- const error = this.createError(
933
- RangeError,
934
- "RSV2 and RSV3 must be clear",
935
- true,
936
- 1002,
937
- "WS_ERR_UNEXPECTED_RSV_2_3"
938
- );
939
- cb(error);
940
- return;
941
- }
942
- const compressed = (buf[0] & 64) === 64;
943
- if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
944
- const error = this.createError(
945
- RangeError,
946
- "RSV1 must be clear",
947
- true,
948
- 1002,
949
- "WS_ERR_UNEXPECTED_RSV_1"
950
- );
951
- cb(error);
952
- return;
953
- }
954
- this._fin = (buf[0] & 128) === 128;
955
- this._opcode = buf[0] & 15;
956
- this._payloadLength = buf[1] & 127;
957
- if (this._opcode === 0) {
958
- if (compressed) {
959
- const error = this.createError(
960
- RangeError,
961
- "RSV1 must be clear",
962
- true,
963
- 1002,
964
- "WS_ERR_UNEXPECTED_RSV_1"
965
- );
966
- cb(error);
967
- return;
968
- }
969
- if (!this._fragmented) {
970
- const error = this.createError(
971
- RangeError,
972
- "invalid opcode 0",
973
- true,
974
- 1002,
975
- "WS_ERR_INVALID_OPCODE"
976
- );
977
- cb(error);
978
- return;
979
- }
980
- this._opcode = this._fragmented;
981
- } else if (this._opcode === 1 || this._opcode === 2) {
982
- if (this._fragmented) {
983
- const error = this.createError(
984
- RangeError,
985
- `invalid opcode ${this._opcode}`,
986
- true,
987
- 1002,
988
- "WS_ERR_INVALID_OPCODE"
989
- );
990
- cb(error);
991
- return;
992
- }
993
- this._compressed = compressed;
994
- } else if (this._opcode > 7 && this._opcode < 11) {
995
- if (!this._fin) {
996
- const error = this.createError(
997
- RangeError,
998
- "FIN must be set",
999
- true,
1000
- 1002,
1001
- "WS_ERR_EXPECTED_FIN"
1002
- );
1003
- cb(error);
1004
- return;
1005
- }
1006
- if (compressed) {
1007
- const error = this.createError(
1008
- RangeError,
1009
- "RSV1 must be clear",
1010
- true,
1011
- 1002,
1012
- "WS_ERR_UNEXPECTED_RSV_1"
1013
- );
1014
- cb(error);
1015
- return;
1016
- }
1017
- if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
1018
- const error = this.createError(
1019
- RangeError,
1020
- `invalid payload length ${this._payloadLength}`,
1021
- true,
1022
- 1002,
1023
- "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
1024
- );
1025
- cb(error);
1026
- return;
1027
- }
1028
- } else {
1029
- const error = this.createError(
1030
- RangeError,
1031
- `invalid opcode ${this._opcode}`,
1032
- true,
1033
- 1002,
1034
- "WS_ERR_INVALID_OPCODE"
1035
- );
1036
- cb(error);
1037
- return;
1038
- }
1039
- if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
1040
- this._masked = (buf[1] & 128) === 128;
1041
- if (this._isServer) {
1042
- if (!this._masked) {
1043
- const error = this.createError(
1044
- RangeError,
1045
- "MASK must be set",
1046
- true,
1047
- 1002,
1048
- "WS_ERR_EXPECTED_MASK"
1049
- );
1050
- cb(error);
1051
- return;
1052
- }
1053
- } else if (this._masked) {
1054
- const error = this.createError(
1055
- RangeError,
1056
- "MASK must be clear",
1057
- true,
1058
- 1002,
1059
- "WS_ERR_UNEXPECTED_MASK"
1060
- );
1061
- cb(error);
1062
- return;
1063
- }
1064
- if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
1065
- else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
1066
- else this.haveLength(cb);
1067
- }
1068
- /**
1069
- * Gets extended payload length (7+16).
1070
- *
1071
- * @param {Function} cb Callback
1072
- * @private
1073
- */
1074
- getPayloadLength16(cb) {
1075
- if (this._bufferedBytes < 2) {
1076
- this._loop = false;
1077
- return;
1078
- }
1079
- this._payloadLength = this.consume(2).readUInt16BE(0);
1080
- this.haveLength(cb);
1081
- }
1082
- /**
1083
- * Gets extended payload length (7+64).
1084
- *
1085
- * @param {Function} cb Callback
1086
- * @private
1087
- */
1088
- getPayloadLength64(cb) {
1089
- if (this._bufferedBytes < 8) {
1090
- this._loop = false;
1091
- return;
1092
- }
1093
- const buf = this.consume(8);
1094
- const num = buf.readUInt32BE(0);
1095
- if (num > Math.pow(2, 53 - 32) - 1) {
1096
- const error = this.createError(
1097
- RangeError,
1098
- "Unsupported WebSocket frame: payload length > 2^53 - 1",
1099
- false,
1100
- 1009,
1101
- "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
1102
- );
1103
- cb(error);
1104
- return;
1105
- }
1106
- this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
1107
- this.haveLength(cb);
1108
- }
1109
- /**
1110
- * Payload length has been read.
1111
- *
1112
- * @param {Function} cb Callback
1113
- * @private
1114
- */
1115
- haveLength(cb) {
1116
- if (this._payloadLength && this._opcode < 8) {
1117
- this._totalPayloadLength += this._payloadLength;
1118
- if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
1119
- const error = this.createError(
1120
- RangeError,
1121
- "Max payload size exceeded",
1122
- false,
1123
- 1009,
1124
- "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
1125
- );
1126
- cb(error);
1127
- return;
1128
- }
1129
- }
1130
- if (this._masked) this._state = GET_MASK;
1131
- else this._state = GET_DATA;
1132
- }
1133
- /**
1134
- * Reads mask bytes.
1135
- *
1136
- * @private
1137
- */
1138
- getMask() {
1139
- if (this._bufferedBytes < 4) {
1140
- this._loop = false;
1141
- return;
1142
- }
1143
- this._mask = this.consume(4);
1144
- this._state = GET_DATA;
1145
- }
1146
- /**
1147
- * Reads data bytes.
1148
- *
1149
- * @param {Function} cb Callback
1150
- * @private
1151
- */
1152
- getData(cb) {
1153
- let data = EMPTY_BUFFER;
1154
- if (this._payloadLength) {
1155
- if (this._bufferedBytes < this._payloadLength) {
1156
- this._loop = false;
1157
- return;
1158
- }
1159
- data = this.consume(this._payloadLength);
1160
- if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) {
1161
- unmask(data, this._mask);
1162
- }
1163
- }
1164
- if (this._opcode > 7) {
1165
- this.controlMessage(data, cb);
1166
- return;
1167
- }
1168
- if (this._compressed) {
1169
- this._state = INFLATING;
1170
- this.decompress(data, cb);
1171
- return;
1172
- }
1173
- if (data.length) {
1174
- this._messageLength = this._totalPayloadLength;
1175
- this._fragments.push(data);
1176
- }
1177
- this.dataMessage(cb);
1178
- }
1179
- /**
1180
- * Decompresses data.
1181
- *
1182
- * @param {Buffer} data Compressed data
1183
- * @param {Function} cb Callback
1184
- * @private
1185
- */
1186
- decompress(data, cb) {
1187
- const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
1188
- perMessageDeflate.decompress(data, this._fin, (err, buf) => {
1189
- if (err) return cb(err);
1190
- if (buf.length) {
1191
- this._messageLength += buf.length;
1192
- if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
1193
- const error = this.createError(
1194
- RangeError,
1195
- "Max payload size exceeded",
1196
- false,
1197
- 1009,
1198
- "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
1199
- );
1200
- cb(error);
1201
- return;
1202
- }
1203
- this._fragments.push(buf);
1204
- }
1205
- this.dataMessage(cb);
1206
- if (this._state === GET_INFO) this.startLoop(cb);
1207
- });
1208
- }
1209
- /**
1210
- * Handles a data message.
1211
- *
1212
- * @param {Function} cb Callback
1213
- * @private
1214
- */
1215
- dataMessage(cb) {
1216
- if (!this._fin) {
1217
- this._state = GET_INFO;
1218
- return;
1219
- }
1220
- const messageLength = this._messageLength;
1221
- const fragments = this._fragments;
1222
- this._totalPayloadLength = 0;
1223
- this._messageLength = 0;
1224
- this._fragmented = 0;
1225
- this._fragments = [];
1226
- if (this._opcode === 2) {
1227
- let data;
1228
- if (this._binaryType === "nodebuffer") {
1229
- data = concat(fragments, messageLength);
1230
- } else if (this._binaryType === "arraybuffer") {
1231
- data = toArrayBuffer(concat(fragments, messageLength));
1232
- } else if (this._binaryType === "blob") {
1233
- data = new Blob(fragments);
1234
- } else {
1235
- data = fragments;
1236
- }
1237
- if (this._allowSynchronousEvents) {
1238
- this.emit("message", data, true);
1239
- this._state = GET_INFO;
1240
- } else {
1241
- this._state = DEFER_EVENT;
1242
- setImmediate(() => {
1243
- this.emit("message", data, true);
1244
- this._state = GET_INFO;
1245
- this.startLoop(cb);
1246
- });
1247
- }
1248
- } else {
1249
- const buf = concat(fragments, messageLength);
1250
- if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
1251
- const error = this.createError(
1252
- Error,
1253
- "invalid UTF-8 sequence",
1254
- true,
1255
- 1007,
1256
- "WS_ERR_INVALID_UTF8"
1257
- );
1258
- cb(error);
1259
- return;
1260
- }
1261
- if (this._state === INFLATING || this._allowSynchronousEvents) {
1262
- this.emit("message", buf, false);
1263
- this._state = GET_INFO;
1264
- } else {
1265
- this._state = DEFER_EVENT;
1266
- setImmediate(() => {
1267
- this.emit("message", buf, false);
1268
- this._state = GET_INFO;
1269
- this.startLoop(cb);
1270
- });
1271
- }
1272
- }
1273
- }
1274
- /**
1275
- * Handles a control message.
1276
- *
1277
- * @param {Buffer} data Data to handle
1278
- * @return {(Error|RangeError|undefined)} A possible error
1279
- * @private
1280
- */
1281
- controlMessage(data, cb) {
1282
- if (this._opcode === 8) {
1283
- if (data.length === 0) {
1284
- this._loop = false;
1285
- this.emit("conclude", 1005, EMPTY_BUFFER);
1286
- this.end();
1287
- } else {
1288
- const code = data.readUInt16BE(0);
1289
- if (!isValidStatusCode(code)) {
1290
- const error = this.createError(
1291
- RangeError,
1292
- `invalid status code ${code}`,
1293
- true,
1294
- 1002,
1295
- "WS_ERR_INVALID_CLOSE_CODE"
1296
- );
1297
- cb(error);
1298
- return;
1299
- }
1300
- const buf = new FastBuffer(
1301
- data.buffer,
1302
- data.byteOffset + 2,
1303
- data.length - 2
1304
- );
1305
- if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
1306
- const error = this.createError(
1307
- Error,
1308
- "invalid UTF-8 sequence",
1309
- true,
1310
- 1007,
1311
- "WS_ERR_INVALID_UTF8"
1312
- );
1313
- cb(error);
1314
- return;
1315
- }
1316
- this._loop = false;
1317
- this.emit("conclude", code, buf);
1318
- this.end();
1319
- }
1320
- this._state = GET_INFO;
1321
- return;
1322
- }
1323
- if (this._allowSynchronousEvents) {
1324
- this.emit(this._opcode === 9 ? "ping" : "pong", data);
1325
- this._state = GET_INFO;
1326
- } else {
1327
- this._state = DEFER_EVENT;
1328
- setImmediate(() => {
1329
- this.emit(this._opcode === 9 ? "ping" : "pong", data);
1330
- this._state = GET_INFO;
1331
- this.startLoop(cb);
1332
- });
1333
- }
1334
- }
1335
- /**
1336
- * Builds an error object.
1337
- *
1338
- * @param {function(new:Error|RangeError)} ErrorCtor The error constructor
1339
- * @param {String} message The error message
1340
- * @param {Boolean} prefix Specifies whether or not to add a default prefix to
1341
- * `message`
1342
- * @param {Number} statusCode The status code
1343
- * @param {String} errorCode The exposed error code
1344
- * @return {(Error|RangeError)} The error
1345
- * @private
1346
- */
1347
- createError(ErrorCtor, message, prefix, statusCode, errorCode) {
1348
- this._loop = false;
1349
- this._errored = true;
1350
- const err = new ErrorCtor(
1351
- prefix ? `Invalid WebSocket frame: ${message}` : message
1352
- );
1353
- Error.captureStackTrace(err, this.createError);
1354
- err.code = errorCode;
1355
- err[kStatusCode] = statusCode;
1356
- return err;
1357
- }
1358
- };
1359
- module.exports = Receiver2;
1360
- }
1361
- });
1362
-
1363
- // node_modules/ink/node_modules/ws/lib/sender.js
1364
- var require_sender = __commonJS({
1365
- "node_modules/ink/node_modules/ws/lib/sender.js"(exports, module) {
1366
- "use strict";
1367
- init_esbuild_shims();
1368
- var { Duplex } = __require("stream");
1369
- var { randomFillSync } = __require("crypto");
1370
- var PerMessageDeflate2 = require_permessage_deflate();
1371
- var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
1372
- var { isBlob, isValidStatusCode } = require_validation();
1373
- var { mask: applyMask, toBuffer } = require_buffer_util();
1374
- var kByteLength = Symbol("kByteLength");
1375
- var maskBuffer = Buffer.alloc(4);
1376
- var RANDOM_POOL_SIZE = 8 * 1024;
1377
- var randomPool;
1378
- var randomPoolPointer = RANDOM_POOL_SIZE;
1379
- var DEFAULT = 0;
1380
- var DEFLATING = 1;
1381
- var GET_BLOB_DATA = 2;
1382
- var Sender2 = class _Sender {
1383
- static {
1384
- __name(this, "Sender");
1385
- }
1386
- /**
1387
- * Creates a Sender instance.
1388
- *
1389
- * @param {Duplex} socket The connection socket
1390
- * @param {Object} [extensions] An object containing the negotiated extensions
1391
- * @param {Function} [generateMask] The function used to generate the masking
1392
- * key
1393
- */
1394
- constructor(socket, extensions, generateMask) {
1395
- this._extensions = extensions || {};
1396
- if (generateMask) {
1397
- this._generateMask = generateMask;
1398
- this._maskBuffer = Buffer.alloc(4);
1399
- }
1400
- this._socket = socket;
1401
- this._firstFragment = true;
1402
- this._compress = false;
1403
- this._bufferedBytes = 0;
1404
- this._queue = [];
1405
- this._state = DEFAULT;
1406
- this.onerror = NOOP;
1407
- this[kWebSocket] = void 0;
1408
- }
1409
- /**
1410
- * Frames a piece of data according to the HyBi WebSocket protocol.
1411
- *
1412
- * @param {(Buffer|String)} data The data to frame
1413
- * @param {Object} options Options object
1414
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1415
- * FIN bit
1416
- * @param {Function} [options.generateMask] The function used to generate the
1417
- * masking key
1418
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1419
- * `data`
1420
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1421
- * key
1422
- * @param {Number} options.opcode The opcode
1423
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1424
- * modified
1425
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1426
- * RSV1 bit
1427
- * @return {(Buffer|String)[]} The framed data
1428
- * @public
1429
- */
1430
- static frame(data, options) {
1431
- let mask;
1432
- let merge = false;
1433
- let offset = 2;
1434
- let skipMasking = false;
1435
- if (options.mask) {
1436
- mask = options.maskBuffer || maskBuffer;
1437
- if (options.generateMask) {
1438
- options.generateMask(mask);
1439
- } else {
1440
- if (randomPoolPointer === RANDOM_POOL_SIZE) {
1441
- if (randomPool === void 0) {
1442
- randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
1443
- }
1444
- randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
1445
- randomPoolPointer = 0;
1446
- }
1447
- mask[0] = randomPool[randomPoolPointer++];
1448
- mask[1] = randomPool[randomPoolPointer++];
1449
- mask[2] = randomPool[randomPoolPointer++];
1450
- mask[3] = randomPool[randomPoolPointer++];
1451
- }
1452
- skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
1453
- offset = 6;
1454
- }
1455
- let dataLength;
1456
- if (typeof data === "string") {
1457
- if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) {
1458
- dataLength = options[kByteLength];
1459
- } else {
1460
- data = Buffer.from(data);
1461
- dataLength = data.length;
1462
- }
1463
- } else {
1464
- dataLength = data.length;
1465
- merge = options.mask && options.readOnly && !skipMasking;
1466
- }
1467
- let payloadLength = dataLength;
1468
- if (dataLength >= 65536) {
1469
- offset += 8;
1470
- payloadLength = 127;
1471
- } else if (dataLength > 125) {
1472
- offset += 2;
1473
- payloadLength = 126;
1474
- }
1475
- const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
1476
- target[0] = options.fin ? options.opcode | 128 : options.opcode;
1477
- if (options.rsv1) target[0] |= 64;
1478
- target[1] = payloadLength;
1479
- if (payloadLength === 126) {
1480
- target.writeUInt16BE(dataLength, 2);
1481
- } else if (payloadLength === 127) {
1482
- target[2] = target[3] = 0;
1483
- target.writeUIntBE(dataLength, 4, 6);
1484
- }
1485
- if (!options.mask) return [target, data];
1486
- target[1] |= 128;
1487
- target[offset - 4] = mask[0];
1488
- target[offset - 3] = mask[1];
1489
- target[offset - 2] = mask[2];
1490
- target[offset - 1] = mask[3];
1491
- if (skipMasking) return [target, data];
1492
- if (merge) {
1493
- applyMask(data, mask, target, offset, dataLength);
1494
- return [target];
1495
- }
1496
- applyMask(data, mask, data, 0, dataLength);
1497
- return [target, data];
1498
- }
1499
- /**
1500
- * Sends a close message to the other peer.
1501
- *
1502
- * @param {Number} [code] The status code component of the body
1503
- * @param {(String|Buffer)} [data] The message component of the body
1504
- * @param {Boolean} [mask=false] Specifies whether or not to mask the message
1505
- * @param {Function} [cb] Callback
1506
- * @public
1507
- */
1508
- close(code, data, mask, cb) {
1509
- let buf;
1510
- if (code === void 0) {
1511
- buf = EMPTY_BUFFER;
1512
- } else if (typeof code !== "number" || !isValidStatusCode(code)) {
1513
- throw new TypeError("First argument must be a valid error code number");
1514
- } else if (data === void 0 || !data.length) {
1515
- buf = Buffer.allocUnsafe(2);
1516
- buf.writeUInt16BE(code, 0);
1517
- } else {
1518
- const length = Buffer.byteLength(data);
1519
- if (length > 123) {
1520
- throw new RangeError("The message must not be greater than 123 bytes");
1521
- }
1522
- buf = Buffer.allocUnsafe(2 + length);
1523
- buf.writeUInt16BE(code, 0);
1524
- if (typeof data === "string") {
1525
- buf.write(data, 2);
1526
- } else {
1527
- buf.set(data, 2);
1528
- }
1529
- }
1530
- const options = {
1531
- [kByteLength]: buf.length,
1532
- fin: true,
1533
- generateMask: this._generateMask,
1534
- mask,
1535
- maskBuffer: this._maskBuffer,
1536
- opcode: 8,
1537
- readOnly: false,
1538
- rsv1: false
1539
- };
1540
- if (this._state !== DEFAULT) {
1541
- this.enqueue([this.dispatch, buf, false, options, cb]);
1542
- } else {
1543
- this.sendFrame(_Sender.frame(buf, options), cb);
1544
- }
1545
- }
1546
- /**
1547
- * Sends a ping message to the other peer.
1548
- *
1549
- * @param {*} data The message to send
1550
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1551
- * @param {Function} [cb] Callback
1552
- * @public
1553
- */
1554
- ping(data, mask, cb) {
1555
- let byteLength;
1556
- let readOnly;
1557
- if (typeof data === "string") {
1558
- byteLength = Buffer.byteLength(data);
1559
- readOnly = false;
1560
- } else if (isBlob(data)) {
1561
- byteLength = data.size;
1562
- readOnly = false;
1563
- } else {
1564
- data = toBuffer(data);
1565
- byteLength = data.length;
1566
- readOnly = toBuffer.readOnly;
1567
- }
1568
- if (byteLength > 125) {
1569
- throw new RangeError("The data size must not be greater than 125 bytes");
1570
- }
1571
- const options = {
1572
- [kByteLength]: byteLength,
1573
- fin: true,
1574
- generateMask: this._generateMask,
1575
- mask,
1576
- maskBuffer: this._maskBuffer,
1577
- opcode: 9,
1578
- readOnly,
1579
- rsv1: false
1580
- };
1581
- if (isBlob(data)) {
1582
- if (this._state !== DEFAULT) {
1583
- this.enqueue([this.getBlobData, data, false, options, cb]);
1584
- } else {
1585
- this.getBlobData(data, false, options, cb);
1586
- }
1587
- } else if (this._state !== DEFAULT) {
1588
- this.enqueue([this.dispatch, data, false, options, cb]);
1589
- } else {
1590
- this.sendFrame(_Sender.frame(data, options), cb);
1591
- }
1592
- }
1593
- /**
1594
- * Sends a pong message to the other peer.
1595
- *
1596
- * @param {*} data The message to send
1597
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1598
- * @param {Function} [cb] Callback
1599
- * @public
1600
- */
1601
- pong(data, mask, cb) {
1602
- let byteLength;
1603
- let readOnly;
1604
- if (typeof data === "string") {
1605
- byteLength = Buffer.byteLength(data);
1606
- readOnly = false;
1607
- } else if (isBlob(data)) {
1608
- byteLength = data.size;
1609
- readOnly = false;
1610
- } else {
1611
- data = toBuffer(data);
1612
- byteLength = data.length;
1613
- readOnly = toBuffer.readOnly;
1614
- }
1615
- if (byteLength > 125) {
1616
- throw new RangeError("The data size must not be greater than 125 bytes");
1617
- }
1618
- const options = {
1619
- [kByteLength]: byteLength,
1620
- fin: true,
1621
- generateMask: this._generateMask,
1622
- mask,
1623
- maskBuffer: this._maskBuffer,
1624
- opcode: 10,
1625
- readOnly,
1626
- rsv1: false
1627
- };
1628
- if (isBlob(data)) {
1629
- if (this._state !== DEFAULT) {
1630
- this.enqueue([this.getBlobData, data, false, options, cb]);
1631
- } else {
1632
- this.getBlobData(data, false, options, cb);
1633
- }
1634
- } else if (this._state !== DEFAULT) {
1635
- this.enqueue([this.dispatch, data, false, options, cb]);
1636
- } else {
1637
- this.sendFrame(_Sender.frame(data, options), cb);
1638
- }
1639
- }
1640
- /**
1641
- * Sends a data message to the other peer.
1642
- *
1643
- * @param {*} data The message to send
1644
- * @param {Object} options Options object
1645
- * @param {Boolean} [options.binary=false] Specifies whether `data` is binary
1646
- * or text
1647
- * @param {Boolean} [options.compress=false] Specifies whether or not to
1648
- * compress `data`
1649
- * @param {Boolean} [options.fin=false] Specifies whether the fragment is the
1650
- * last one
1651
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1652
- * `data`
1653
- * @param {Function} [cb] Callback
1654
- * @public
1655
- */
1656
- send(data, options, cb) {
1657
- const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
1658
- let opcode = options.binary ? 2 : 1;
1659
- let rsv1 = options.compress;
1660
- let byteLength;
1661
- let readOnly;
1662
- if (typeof data === "string") {
1663
- byteLength = Buffer.byteLength(data);
1664
- readOnly = false;
1665
- } else if (isBlob(data)) {
1666
- byteLength = data.size;
1667
- readOnly = false;
1668
- } else {
1669
- data = toBuffer(data);
1670
- byteLength = data.length;
1671
- readOnly = toBuffer.readOnly;
1672
- }
1673
- if (this._firstFragment) {
1674
- this._firstFragment = false;
1675
- if (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? "server_no_context_takeover" : "client_no_context_takeover"]) {
1676
- rsv1 = byteLength >= perMessageDeflate._threshold;
1677
- }
1678
- this._compress = rsv1;
1679
- } else {
1680
- rsv1 = false;
1681
- opcode = 0;
1682
- }
1683
- if (options.fin) this._firstFragment = true;
1684
- const opts = {
1685
- [kByteLength]: byteLength,
1686
- fin: options.fin,
1687
- generateMask: this._generateMask,
1688
- mask: options.mask,
1689
- maskBuffer: this._maskBuffer,
1690
- opcode,
1691
- readOnly,
1692
- rsv1
1693
- };
1694
- if (isBlob(data)) {
1695
- if (this._state !== DEFAULT) {
1696
- this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
1697
- } else {
1698
- this.getBlobData(data, this._compress, opts, cb);
1699
- }
1700
- } else if (this._state !== DEFAULT) {
1701
- this.enqueue([this.dispatch, data, this._compress, opts, cb]);
1702
- } else {
1703
- this.dispatch(data, this._compress, opts, cb);
1704
- }
1705
- }
1706
- /**
1707
- * Gets the contents of a blob as binary data.
1708
- *
1709
- * @param {Blob} blob The blob
1710
- * @param {Boolean} [compress=false] Specifies whether or not to compress
1711
- * the data
1712
- * @param {Object} options Options object
1713
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1714
- * FIN bit
1715
- * @param {Function} [options.generateMask] The function used to generate the
1716
- * masking key
1717
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1718
- * `data`
1719
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1720
- * key
1721
- * @param {Number} options.opcode The opcode
1722
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1723
- * modified
1724
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1725
- * RSV1 bit
1726
- * @param {Function} [cb] Callback
1727
- * @private
1728
- */
1729
- getBlobData(blob, compress, options, cb) {
1730
- this._bufferedBytes += options[kByteLength];
1731
- this._state = GET_BLOB_DATA;
1732
- blob.arrayBuffer().then((arrayBuffer) => {
1733
- if (this._socket.destroyed) {
1734
- const err = new Error(
1735
- "The socket was closed while the blob was being read"
1736
- );
1737
- process.nextTick(callCallbacks, this, err, cb);
1738
- return;
1739
- }
1740
- this._bufferedBytes -= options[kByteLength];
1741
- const data = toBuffer(arrayBuffer);
1742
- if (!compress) {
1743
- this._state = DEFAULT;
1744
- this.sendFrame(_Sender.frame(data, options), cb);
1745
- this.dequeue();
1746
- } else {
1747
- this.dispatch(data, compress, options, cb);
1748
- }
1749
- }).catch((err) => {
1750
- process.nextTick(onError, this, err, cb);
1751
- });
1752
- }
1753
- /**
1754
- * Dispatches a message.
1755
- *
1756
- * @param {(Buffer|String)} data The message to send
1757
- * @param {Boolean} [compress=false] Specifies whether or not to compress
1758
- * `data`
1759
- * @param {Object} options Options object
1760
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1761
- * FIN bit
1762
- * @param {Function} [options.generateMask] The function used to generate the
1763
- * masking key
1764
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1765
- * `data`
1766
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1767
- * key
1768
- * @param {Number} options.opcode The opcode
1769
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1770
- * modified
1771
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1772
- * RSV1 bit
1773
- * @param {Function} [cb] Callback
1774
- * @private
1775
- */
1776
- dispatch(data, compress, options, cb) {
1777
- if (!compress) {
1778
- this.sendFrame(_Sender.frame(data, options), cb);
1779
- return;
1780
- }
1781
- const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
1782
- this._bufferedBytes += options[kByteLength];
1783
- this._state = DEFLATING;
1784
- perMessageDeflate.compress(data, options.fin, (_, buf) => {
1785
- if (this._socket.destroyed) {
1786
- const err = new Error(
1787
- "The socket was closed while data was being compressed"
1788
- );
1789
- callCallbacks(this, err, cb);
1790
- return;
1791
- }
1792
- this._bufferedBytes -= options[kByteLength];
1793
- this._state = DEFAULT;
1794
- options.readOnly = false;
1795
- this.sendFrame(_Sender.frame(buf, options), cb);
1796
- this.dequeue();
1797
- });
1798
- }
1799
- /**
1800
- * Executes queued send operations.
1801
- *
1802
- * @private
1803
- */
1804
- dequeue() {
1805
- while (this._state === DEFAULT && this._queue.length) {
1806
- const params = this._queue.shift();
1807
- this._bufferedBytes -= params[3][kByteLength];
1808
- Reflect.apply(params[0], this, params.slice(1));
1809
- }
1810
- }
1811
- /**
1812
- * Enqueues a send operation.
1813
- *
1814
- * @param {Array} params Send operation parameters.
1815
- * @private
1816
- */
1817
- enqueue(params) {
1818
- this._bufferedBytes += params[3][kByteLength];
1819
- this._queue.push(params);
1820
- }
1821
- /**
1822
- * Sends a frame.
1823
- *
1824
- * @param {(Buffer | String)[]} list The frame to send
1825
- * @param {Function} [cb] Callback
1826
- * @private
1827
- */
1828
- sendFrame(list, cb) {
1829
- if (list.length === 2) {
1830
- this._socket.cork();
1831
- this._socket.write(list[0]);
1832
- this._socket.write(list[1], cb);
1833
- this._socket.uncork();
1834
- } else {
1835
- this._socket.write(list[0], cb);
1836
- }
1837
- }
1838
- };
1839
- module.exports = Sender2;
1840
- function callCallbacks(sender, err, cb) {
1841
- if (typeof cb === "function") cb(err);
1842
- for (let i = 0; i < sender._queue.length; i++) {
1843
- const params = sender._queue[i];
1844
- const callback = params[params.length - 1];
1845
- if (typeof callback === "function") callback(err);
1846
- }
1847
- }
1848
- __name(callCallbacks, "callCallbacks");
1849
- function onError(sender, err, cb) {
1850
- callCallbacks(sender, err, cb);
1851
- sender.onerror(err);
1852
- }
1853
- __name(onError, "onError");
1854
- }
1855
- });
1856
-
1857
- // node_modules/ink/node_modules/ws/lib/event-target.js
1858
- var require_event_target = __commonJS({
1859
- "node_modules/ink/node_modules/ws/lib/event-target.js"(exports, module) {
1860
- "use strict";
1861
- init_esbuild_shims();
1862
- var { kForOnEventAttribute, kListener } = require_constants();
1863
- var kCode = Symbol("kCode");
1864
- var kData = Symbol("kData");
1865
- var kError = Symbol("kError");
1866
- var kMessage = Symbol("kMessage");
1867
- var kReason = Symbol("kReason");
1868
- var kTarget = Symbol("kTarget");
1869
- var kType = Symbol("kType");
1870
- var kWasClean = Symbol("kWasClean");
1871
- var Event = class {
1872
- static {
1873
- __name(this, "Event");
1874
- }
1875
- /**
1876
- * Create a new `Event`.
1877
- *
1878
- * @param {String} type The name of the event
1879
- * @throws {TypeError} If the `type` argument is not specified
1880
- */
1881
- constructor(type) {
1882
- this[kTarget] = null;
1883
- this[kType] = type;
1884
- }
1885
- /**
1886
- * @type {*}
1887
- */
1888
- get target() {
1889
- return this[kTarget];
1890
- }
1891
- /**
1892
- * @type {String}
1893
- */
1894
- get type() {
1895
- return this[kType];
1896
- }
1897
- };
1898
- Object.defineProperty(Event.prototype, "target", { enumerable: true });
1899
- Object.defineProperty(Event.prototype, "type", { enumerable: true });
1900
- var CloseEvent = class extends Event {
1901
- static {
1902
- __name(this, "CloseEvent");
1903
- }
1904
- /**
1905
- * Create a new `CloseEvent`.
1906
- *
1907
- * @param {String} type The name of the event
1908
- * @param {Object} [options] A dictionary object that allows for setting
1909
- * attributes via object members of the same name
1910
- * @param {Number} [options.code=0] The status code explaining why the
1911
- * connection was closed
1912
- * @param {String} [options.reason=''] A human-readable string explaining why
1913
- * the connection was closed
1914
- * @param {Boolean} [options.wasClean=false] Indicates whether or not the
1915
- * connection was cleanly closed
1916
- */
1917
- constructor(type, options = {}) {
1918
- super(type);
1919
- this[kCode] = options.code === void 0 ? 0 : options.code;
1920
- this[kReason] = options.reason === void 0 ? "" : options.reason;
1921
- this[kWasClean] = options.wasClean === void 0 ? false : options.wasClean;
1922
- }
1923
- /**
1924
- * @type {Number}
1925
- */
1926
- get code() {
1927
- return this[kCode];
1928
- }
1929
- /**
1930
- * @type {String}
1931
- */
1932
- get reason() {
1933
- return this[kReason];
1934
- }
1935
- /**
1936
- * @type {Boolean}
1937
- */
1938
- get wasClean() {
1939
- return this[kWasClean];
1940
- }
1941
- };
1942
- Object.defineProperty(CloseEvent.prototype, "code", { enumerable: true });
1943
- Object.defineProperty(CloseEvent.prototype, "reason", { enumerable: true });
1944
- Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
1945
- var ErrorEvent = class extends Event {
1946
- static {
1947
- __name(this, "ErrorEvent");
1948
- }
1949
- /**
1950
- * Create a new `ErrorEvent`.
1951
- *
1952
- * @param {String} type The name of the event
1953
- * @param {Object} [options] A dictionary object that allows for setting
1954
- * attributes via object members of the same name
1955
- * @param {*} [options.error=null] The error that generated this event
1956
- * @param {String} [options.message=''] The error message
1957
- */
1958
- constructor(type, options = {}) {
1959
- super(type);
1960
- this[kError] = options.error === void 0 ? null : options.error;
1961
- this[kMessage] = options.message === void 0 ? "" : options.message;
1962
- }
1963
- /**
1964
- * @type {*}
1965
- */
1966
- get error() {
1967
- return this[kError];
1968
- }
1969
- /**
1970
- * @type {String}
1971
- */
1972
- get message() {
1973
- return this[kMessage];
1974
- }
1975
- };
1976
- Object.defineProperty(ErrorEvent.prototype, "error", { enumerable: true });
1977
- Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
1978
- var MessageEvent = class extends Event {
1979
- static {
1980
- __name(this, "MessageEvent");
1981
- }
1982
- /**
1983
- * Create a new `MessageEvent`.
1984
- *
1985
- * @param {String} type The name of the event
1986
- * @param {Object} [options] A dictionary object that allows for setting
1987
- * attributes via object members of the same name
1988
- * @param {*} [options.data=null] The message content
1989
- */
1990
- constructor(type, options = {}) {
1991
- super(type);
1992
- this[kData] = options.data === void 0 ? null : options.data;
1993
- }
1994
- /**
1995
- * @type {*}
1996
- */
1997
- get data() {
1998
- return this[kData];
1999
- }
2000
- };
2001
- Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
2002
- var EventTarget = {
2003
- /**
2004
- * Register an event listener.
2005
- *
2006
- * @param {String} type A string representing the event type to listen for
2007
- * @param {(Function|Object)} handler The listener to add
2008
- * @param {Object} [options] An options object specifies characteristics about
2009
- * the event listener
2010
- * @param {Boolean} [options.once=false] A `Boolean` indicating that the
2011
- * listener should be invoked at most once after being added. If `true`,
2012
- * the listener would be automatically removed when invoked.
2013
- * @public
2014
- */
2015
- addEventListener(type, handler, options = {}) {
2016
- for (const listener of this.listeners(type)) {
2017
- if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) {
2018
- return;
2019
- }
2020
- }
2021
- let wrapper;
2022
- if (type === "message") {
2023
- wrapper = /* @__PURE__ */ __name(function onMessage(data, isBinary) {
2024
- const event = new MessageEvent("message", {
2025
- data: isBinary ? data : data.toString()
2026
- });
2027
- event[kTarget] = this;
2028
- callListener(handler, this, event);
2029
- }, "onMessage");
2030
- } else if (type === "close") {
2031
- wrapper = /* @__PURE__ */ __name(function onClose(code, message) {
2032
- const event = new CloseEvent("close", {
2033
- code,
2034
- reason: message.toString(),
2035
- wasClean: this._closeFrameReceived && this._closeFrameSent
2036
- });
2037
- event[kTarget] = this;
2038
- callListener(handler, this, event);
2039
- }, "onClose");
2040
- } else if (type === "error") {
2041
- wrapper = /* @__PURE__ */ __name(function onError(error) {
2042
- const event = new ErrorEvent("error", {
2043
- error,
2044
- message: error.message
2045
- });
2046
- event[kTarget] = this;
2047
- callListener(handler, this, event);
2048
- }, "onError");
2049
- } else if (type === "open") {
2050
- wrapper = /* @__PURE__ */ __name(function onOpen() {
2051
- const event = new Event("open");
2052
- event[kTarget] = this;
2053
- callListener(handler, this, event);
2054
- }, "onOpen");
2055
- } else {
2056
- return;
2057
- }
2058
- wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
2059
- wrapper[kListener] = handler;
2060
- if (options.once) {
2061
- this.once(type, wrapper);
2062
- } else {
2063
- this.on(type, wrapper);
2064
- }
2065
- },
2066
- /**
2067
- * Remove an event listener.
2068
- *
2069
- * @param {String} type A string representing the event type to remove
2070
- * @param {(Function|Object)} handler The listener to remove
2071
- * @public
2072
- */
2073
- removeEventListener(type, handler) {
2074
- for (const listener of this.listeners(type)) {
2075
- if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
2076
- this.removeListener(type, listener);
2077
- break;
2078
- }
2079
- }
2080
- }
2081
- };
2082
- module.exports = {
2083
- CloseEvent,
2084
- ErrorEvent,
2085
- Event,
2086
- EventTarget,
2087
- MessageEvent
2088
- };
2089
- function callListener(listener, thisArg, event) {
2090
- if (typeof listener === "object" && listener.handleEvent) {
2091
- listener.handleEvent.call(listener, event);
2092
- } else {
2093
- listener.call(thisArg, event);
2094
- }
2095
- }
2096
- __name(callListener, "callListener");
2097
- }
2098
- });
2099
-
2100
- // node_modules/ink/node_modules/ws/lib/extension.js
2101
- var require_extension = __commonJS({
2102
- "node_modules/ink/node_modules/ws/lib/extension.js"(exports, module) {
2103
- "use strict";
2104
- init_esbuild_shims();
2105
- var { tokenChars } = require_validation();
2106
- function push(dest, name, elem) {
2107
- if (dest[name] === void 0) dest[name] = [elem];
2108
- else dest[name].push(elem);
2109
- }
2110
- __name(push, "push");
2111
- function parse(header) {
2112
- const offers = /* @__PURE__ */ Object.create(null);
2113
- let params = /* @__PURE__ */ Object.create(null);
2114
- let mustUnescape = false;
2115
- let isEscaping = false;
2116
- let inQuotes = false;
2117
- let extensionName;
2118
- let paramName;
2119
- let start = -1;
2120
- let code = -1;
2121
- let end = -1;
2122
- let i = 0;
2123
- for (; i < header.length; i++) {
2124
- code = header.charCodeAt(i);
2125
- if (extensionName === void 0) {
2126
- if (end === -1 && tokenChars[code] === 1) {
2127
- if (start === -1) start = i;
2128
- } else if (i !== 0 && (code === 32 || code === 9)) {
2129
- if (end === -1 && start !== -1) end = i;
2130
- } else if (code === 59 || code === 44) {
2131
- if (start === -1) {
2132
- throw new SyntaxError(`Unexpected character at index ${i}`);
2133
- }
2134
- if (end === -1) end = i;
2135
- const name = header.slice(start, end);
2136
- if (code === 44) {
2137
- push(offers, name, params);
2138
- params = /* @__PURE__ */ Object.create(null);
2139
- } else {
2140
- extensionName = name;
2141
- }
2142
- start = end = -1;
2143
- } else {
2144
- throw new SyntaxError(`Unexpected character at index ${i}`);
2145
- }
2146
- } else if (paramName === void 0) {
2147
- if (end === -1 && tokenChars[code] === 1) {
2148
- if (start === -1) start = i;
2149
- } else if (code === 32 || code === 9) {
2150
- if (end === -1 && start !== -1) end = i;
2151
- } else if (code === 59 || code === 44) {
2152
- if (start === -1) {
2153
- throw new SyntaxError(`Unexpected character at index ${i}`);
2154
- }
2155
- if (end === -1) end = i;
2156
- push(params, header.slice(start, end), true);
2157
- if (code === 44) {
2158
- push(offers, extensionName, params);
2159
- params = /* @__PURE__ */ Object.create(null);
2160
- extensionName = void 0;
2161
- }
2162
- start = end = -1;
2163
- } else if (code === 61 && start !== -1 && end === -1) {
2164
- paramName = header.slice(start, i);
2165
- start = end = -1;
2166
- } else {
2167
- throw new SyntaxError(`Unexpected character at index ${i}`);
2168
- }
2169
- } else {
2170
- if (isEscaping) {
2171
- if (tokenChars[code] !== 1) {
2172
- throw new SyntaxError(`Unexpected character at index ${i}`);
2173
- }
2174
- if (start === -1) start = i;
2175
- else if (!mustUnescape) mustUnescape = true;
2176
- isEscaping = false;
2177
- } else if (inQuotes) {
2178
- if (tokenChars[code] === 1) {
2179
- if (start === -1) start = i;
2180
- } else if (code === 34 && start !== -1) {
2181
- inQuotes = false;
2182
- end = i;
2183
- } else if (code === 92) {
2184
- isEscaping = true;
2185
- } else {
2186
- throw new SyntaxError(`Unexpected character at index ${i}`);
2187
- }
2188
- } else if (code === 34 && header.charCodeAt(i - 1) === 61) {
2189
- inQuotes = true;
2190
- } else if (end === -1 && tokenChars[code] === 1) {
2191
- if (start === -1) start = i;
2192
- } else if (start !== -1 && (code === 32 || code === 9)) {
2193
- if (end === -1) end = i;
2194
- } else if (code === 59 || code === 44) {
2195
- if (start === -1) {
2196
- throw new SyntaxError(`Unexpected character at index ${i}`);
2197
- }
2198
- if (end === -1) end = i;
2199
- let value = header.slice(start, end);
2200
- if (mustUnescape) {
2201
- value = value.replace(/\\/g, "");
2202
- mustUnescape = false;
2203
- }
2204
- push(params, paramName, value);
2205
- if (code === 44) {
2206
- push(offers, extensionName, params);
2207
- params = /* @__PURE__ */ Object.create(null);
2208
- extensionName = void 0;
2209
- }
2210
- paramName = void 0;
2211
- start = end = -1;
2212
- } else {
2213
- throw new SyntaxError(`Unexpected character at index ${i}`);
2214
- }
2215
- }
2216
- }
2217
- if (start === -1 || inQuotes || code === 32 || code === 9) {
2218
- throw new SyntaxError("Unexpected end of input");
2219
- }
2220
- if (end === -1) end = i;
2221
- const token = header.slice(start, end);
2222
- if (extensionName === void 0) {
2223
- push(offers, token, params);
2224
- } else {
2225
- if (paramName === void 0) {
2226
- push(params, token, true);
2227
- } else if (mustUnescape) {
2228
- push(params, paramName, token.replace(/\\/g, ""));
2229
- } else {
2230
- push(params, paramName, token);
2231
- }
2232
- push(offers, extensionName, params);
2233
- }
2234
- return offers;
2235
- }
2236
- __name(parse, "parse");
2237
- function format(extensions) {
2238
- return Object.keys(extensions).map((extension2) => {
2239
- let configurations = extensions[extension2];
2240
- if (!Array.isArray(configurations)) configurations = [configurations];
2241
- return configurations.map((params) => {
2242
- return [extension2].concat(
2243
- Object.keys(params).map((k) => {
2244
- let values = params[k];
2245
- if (!Array.isArray(values)) values = [values];
2246
- return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
2247
- })
2248
- ).join("; ");
2249
- }).join(", ");
2250
- }).join(", ");
2251
- }
2252
- __name(format, "format");
2253
- module.exports = { format, parse };
2254
- }
2255
- });
2256
-
2257
- // node_modules/ink/node_modules/ws/lib/websocket.js
2258
- var require_websocket = __commonJS({
2259
- "node_modules/ink/node_modules/ws/lib/websocket.js"(exports, module) {
2260
- "use strict";
2261
- init_esbuild_shims();
2262
- var EventEmitter = __require("events");
2263
- var https = __require("https");
2264
- var http = __require("http");
2265
- var net = __require("net");
2266
- var tls = __require("tls");
2267
- var { randomBytes, createHash } = __require("crypto");
2268
- var { Duplex, Readable } = __require("stream");
2269
- var { URL: URL2 } = __require("url");
2270
- var PerMessageDeflate2 = require_permessage_deflate();
2271
- var Receiver2 = require_receiver();
2272
- var Sender2 = require_sender();
2273
- var { isBlob } = require_validation();
2274
- var {
2275
- BINARY_TYPES,
2276
- CLOSE_TIMEOUT,
2277
- EMPTY_BUFFER,
2278
- GUID,
2279
- kForOnEventAttribute,
2280
- kListener,
2281
- kStatusCode,
2282
- kWebSocket,
2283
- NOOP
2284
- } = require_constants();
2285
- var {
2286
- EventTarget: { addEventListener, removeEventListener }
2287
- } = require_event_target();
2288
- var { format, parse } = require_extension();
2289
- var { toBuffer } = require_buffer_util();
2290
- var kAborted = Symbol("kAborted");
2291
- var protocolVersions = [8, 13];
2292
- var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
2293
- var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
2294
- var WebSocket2 = class _WebSocket extends EventEmitter {
2295
- static {
2296
- __name(this, "WebSocket");
2297
- }
2298
- /**
2299
- * Create a new `WebSocket`.
2300
- *
2301
- * @param {(String|URL)} address The URL to which to connect
2302
- * @param {(String|String[])} [protocols] The subprotocols
2303
- * @param {Object} [options] Connection options
2304
- */
2305
- constructor(address, protocols, options) {
2306
- super();
2307
- this._binaryType = BINARY_TYPES[0];
2308
- this._closeCode = 1006;
2309
- this._closeFrameReceived = false;
2310
- this._closeFrameSent = false;
2311
- this._closeMessage = EMPTY_BUFFER;
2312
- this._closeTimer = null;
2313
- this._errorEmitted = false;
2314
- this._extensions = {};
2315
- this._paused = false;
2316
- this._protocol = "";
2317
- this._readyState = _WebSocket.CONNECTING;
2318
- this._receiver = null;
2319
- this._sender = null;
2320
- this._socket = null;
2321
- if (address !== null) {
2322
- this._bufferedAmount = 0;
2323
- this._isServer = false;
2324
- this._redirects = 0;
2325
- if (protocols === void 0) {
2326
- protocols = [];
2327
- } else if (!Array.isArray(protocols)) {
2328
- if (typeof protocols === "object" && protocols !== null) {
2329
- options = protocols;
2330
- protocols = [];
2331
- } else {
2332
- protocols = [protocols];
2333
- }
2334
- }
2335
- initAsClient(this, address, protocols, options);
2336
- } else {
2337
- this._autoPong = options.autoPong;
2338
- this._closeTimeout = options.closeTimeout;
2339
- this._isServer = true;
2340
- }
2341
- }
2342
- /**
2343
- * For historical reasons, the custom "nodebuffer" type is used by the default
2344
- * instead of "blob".
2345
- *
2346
- * @type {String}
2347
- */
2348
- get binaryType() {
2349
- return this._binaryType;
2350
- }
2351
- set binaryType(type) {
2352
- if (!BINARY_TYPES.includes(type)) return;
2353
- this._binaryType = type;
2354
- if (this._receiver) this._receiver._binaryType = type;
2355
- }
2356
- /**
2357
- * @type {Number}
2358
- */
2359
- get bufferedAmount() {
2360
- if (!this._socket) return this._bufferedAmount;
2361
- return this._socket._writableState.length + this._sender._bufferedBytes;
2362
- }
2363
- /**
2364
- * @type {String}
2365
- */
2366
- get extensions() {
2367
- return Object.keys(this._extensions).join();
2368
- }
2369
- /**
2370
- * @type {Boolean}
2371
- */
2372
- get isPaused() {
2373
- return this._paused;
2374
- }
2375
- /**
2376
- * @type {Function}
2377
- */
2378
- /* istanbul ignore next */
2379
- get onclose() {
2380
- return null;
2381
- }
2382
- /**
2383
- * @type {Function}
2384
- */
2385
- /* istanbul ignore next */
2386
- get onerror() {
2387
- return null;
2388
- }
2389
- /**
2390
- * @type {Function}
2391
- */
2392
- /* istanbul ignore next */
2393
- get onopen() {
2394
- return null;
2395
- }
2396
- /**
2397
- * @type {Function}
2398
- */
2399
- /* istanbul ignore next */
2400
- get onmessage() {
2401
- return null;
2402
- }
2403
- /**
2404
- * @type {String}
2405
- */
2406
- get protocol() {
2407
- return this._protocol;
2408
- }
2409
- /**
2410
- * @type {Number}
2411
- */
2412
- get readyState() {
2413
- return this._readyState;
2414
- }
2415
- /**
2416
- * @type {String}
2417
- */
2418
- get url() {
2419
- return this._url;
2420
- }
2421
- /**
2422
- * Set up the socket and the internal resources.
2423
- *
2424
- * @param {Duplex} socket The network socket between the server and client
2425
- * @param {Buffer} head The first packet of the upgraded stream
2426
- * @param {Object} options Options object
2427
- * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
2428
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
2429
- * multiple times in the same tick
2430
- * @param {Function} [options.generateMask] The function used to generate the
2431
- * masking key
2432
- * @param {Number} [options.maxPayload=0] The maximum allowed message size
2433
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
2434
- * not to skip UTF-8 validation for text and close messages
2435
- * @private
2436
- */
2437
- setSocket(socket, head, options) {
2438
- const receiver = new Receiver2({
2439
- allowSynchronousEvents: options.allowSynchronousEvents,
2440
- binaryType: this.binaryType,
2441
- extensions: this._extensions,
2442
- isServer: this._isServer,
2443
- maxPayload: options.maxPayload,
2444
- skipUTF8Validation: options.skipUTF8Validation
2445
- });
2446
- const sender = new Sender2(socket, this._extensions, options.generateMask);
2447
- this._receiver = receiver;
2448
- this._sender = sender;
2449
- this._socket = socket;
2450
- receiver[kWebSocket] = this;
2451
- sender[kWebSocket] = this;
2452
- socket[kWebSocket] = this;
2453
- receiver.on("conclude", receiverOnConclude);
2454
- receiver.on("drain", receiverOnDrain);
2455
- receiver.on("error", receiverOnError);
2456
- receiver.on("message", receiverOnMessage);
2457
- receiver.on("ping", receiverOnPing);
2458
- receiver.on("pong", receiverOnPong);
2459
- sender.onerror = senderOnError;
2460
- if (socket.setTimeout) socket.setTimeout(0);
2461
- if (socket.setNoDelay) socket.setNoDelay();
2462
- if (head.length > 0) socket.unshift(head);
2463
- socket.on("close", socketOnClose);
2464
- socket.on("data", socketOnData);
2465
- socket.on("end", socketOnEnd);
2466
- socket.on("error", socketOnError);
2467
- this._readyState = _WebSocket.OPEN;
2468
- this.emit("open");
2469
- }
2470
- /**
2471
- * Emit the `'close'` event.
2472
- *
2473
- * @private
2474
- */
2475
- emitClose() {
2476
- if (!this._socket) {
2477
- this._readyState = _WebSocket.CLOSED;
2478
- this.emit("close", this._closeCode, this._closeMessage);
2479
- return;
2480
- }
2481
- if (this._extensions[PerMessageDeflate2.extensionName]) {
2482
- this._extensions[PerMessageDeflate2.extensionName].cleanup();
2483
- }
2484
- this._receiver.removeAllListeners();
2485
- this._readyState = _WebSocket.CLOSED;
2486
- this.emit("close", this._closeCode, this._closeMessage);
2487
- }
2488
- /**
2489
- * Start a closing handshake.
2490
- *
2491
- * +----------+ +-----------+ +----------+
2492
- * - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
2493
- * | +----------+ +-----------+ +----------+ |
2494
- * +----------+ +-----------+ |
2495
- * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
2496
- * +----------+ +-----------+ |
2497
- * | | | +---+ |
2498
- * +------------------------+-->|fin| - - - -
2499
- * | +---+ | +---+
2500
- * - - - - -|fin|<---------------------+
2501
- * +---+
2502
- *
2503
- * @param {Number} [code] Status code explaining why the connection is closing
2504
- * @param {(String|Buffer)} [data] The reason why the connection is
2505
- * closing
2506
- * @public
2507
- */
2508
- close(code, data) {
2509
- if (this.readyState === _WebSocket.CLOSED) return;
2510
- if (this.readyState === _WebSocket.CONNECTING) {
2511
- const msg = "WebSocket was closed before the connection was established";
2512
- abortHandshake(this, this._req, msg);
2513
- return;
2514
- }
2515
- if (this.readyState === _WebSocket.CLOSING) {
2516
- if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
2517
- this._socket.end();
2518
- }
2519
- return;
2520
- }
2521
- this._readyState = _WebSocket.CLOSING;
2522
- this._sender.close(code, data, !this._isServer, (err) => {
2523
- if (err) return;
2524
- this._closeFrameSent = true;
2525
- if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
2526
- this._socket.end();
2527
- }
2528
- });
2529
- setCloseTimer(this);
2530
- }
2531
- /**
2532
- * Pause the socket.
2533
- *
2534
- * @public
2535
- */
2536
- pause() {
2537
- if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
2538
- return;
2539
- }
2540
- this._paused = true;
2541
- this._socket.pause();
2542
- }
2543
- /**
2544
- * Send a ping.
2545
- *
2546
- * @param {*} [data] The data to send
2547
- * @param {Boolean} [mask] Indicates whether or not to mask `data`
2548
- * @param {Function} [cb] Callback which is executed when the ping is sent
2549
- * @public
2550
- */
2551
- ping(data, mask, cb) {
2552
- if (this.readyState === _WebSocket.CONNECTING) {
2553
- throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2554
- }
2555
- if (typeof data === "function") {
2556
- cb = data;
2557
- data = mask = void 0;
2558
- } else if (typeof mask === "function") {
2559
- cb = mask;
2560
- mask = void 0;
2561
- }
2562
- if (typeof data === "number") data = data.toString();
2563
- if (this.readyState !== _WebSocket.OPEN) {
2564
- sendAfterClose(this, data, cb);
2565
- return;
2566
- }
2567
- if (mask === void 0) mask = !this._isServer;
2568
- this._sender.ping(data || EMPTY_BUFFER, mask, cb);
2569
- }
2570
- /**
2571
- * Send a pong.
2572
- *
2573
- * @param {*} [data] The data to send
2574
- * @param {Boolean} [mask] Indicates whether or not to mask `data`
2575
- * @param {Function} [cb] Callback which is executed when the pong is sent
2576
- * @public
2577
- */
2578
- pong(data, mask, cb) {
2579
- if (this.readyState === _WebSocket.CONNECTING) {
2580
- throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2581
- }
2582
- if (typeof data === "function") {
2583
- cb = data;
2584
- data = mask = void 0;
2585
- } else if (typeof mask === "function") {
2586
- cb = mask;
2587
- mask = void 0;
2588
- }
2589
- if (typeof data === "number") data = data.toString();
2590
- if (this.readyState !== _WebSocket.OPEN) {
2591
- sendAfterClose(this, data, cb);
2592
- return;
2593
- }
2594
- if (mask === void 0) mask = !this._isServer;
2595
- this._sender.pong(data || EMPTY_BUFFER, mask, cb);
2596
- }
2597
- /**
2598
- * Resume the socket.
2599
- *
2600
- * @public
2601
- */
2602
- resume() {
2603
- if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
2604
- return;
2605
- }
2606
- this._paused = false;
2607
- if (!this._receiver._writableState.needDrain) this._socket.resume();
2608
- }
2609
- /**
2610
- * Send a data message.
2611
- *
2612
- * @param {*} data The message to send
2613
- * @param {Object} [options] Options object
2614
- * @param {Boolean} [options.binary] Specifies whether `data` is binary or
2615
- * text
2616
- * @param {Boolean} [options.compress] Specifies whether or not to compress
2617
- * `data`
2618
- * @param {Boolean} [options.fin=true] Specifies whether the fragment is the
2619
- * last one
2620
- * @param {Boolean} [options.mask] Specifies whether or not to mask `data`
2621
- * @param {Function} [cb] Callback which is executed when data is written out
2622
- * @public
2623
- */
2624
- send(data, options, cb) {
2625
- if (this.readyState === _WebSocket.CONNECTING) {
2626
- throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2627
- }
2628
- if (typeof options === "function") {
2629
- cb = options;
2630
- options = {};
2631
- }
2632
- if (typeof data === "number") data = data.toString();
2633
- if (this.readyState !== _WebSocket.OPEN) {
2634
- sendAfterClose(this, data, cb);
2635
- return;
2636
- }
2637
- const opts = {
2638
- binary: typeof data !== "string",
2639
- mask: !this._isServer,
2640
- compress: true,
2641
- fin: true,
2642
- ...options
2643
- };
2644
- if (!this._extensions[PerMessageDeflate2.extensionName]) {
2645
- opts.compress = false;
2646
- }
2647
- this._sender.send(data || EMPTY_BUFFER, opts, cb);
2648
- }
2649
- /**
2650
- * Forcibly close the connection.
2651
- *
2652
- * @public
2653
- */
2654
- terminate() {
2655
- if (this.readyState === _WebSocket.CLOSED) return;
2656
- if (this.readyState === _WebSocket.CONNECTING) {
2657
- const msg = "WebSocket was closed before the connection was established";
2658
- abortHandshake(this, this._req, msg);
2659
- return;
2660
- }
2661
- if (this._socket) {
2662
- this._readyState = _WebSocket.CLOSING;
2663
- this._socket.destroy();
2664
- }
2665
- }
2666
- };
2667
- Object.defineProperty(WebSocket2, "CONNECTING", {
2668
- enumerable: true,
2669
- value: readyStates.indexOf("CONNECTING")
2670
- });
2671
- Object.defineProperty(WebSocket2.prototype, "CONNECTING", {
2672
- enumerable: true,
2673
- value: readyStates.indexOf("CONNECTING")
2674
- });
2675
- Object.defineProperty(WebSocket2, "OPEN", {
2676
- enumerable: true,
2677
- value: readyStates.indexOf("OPEN")
2678
- });
2679
- Object.defineProperty(WebSocket2.prototype, "OPEN", {
2680
- enumerable: true,
2681
- value: readyStates.indexOf("OPEN")
2682
- });
2683
- Object.defineProperty(WebSocket2, "CLOSING", {
2684
- enumerable: true,
2685
- value: readyStates.indexOf("CLOSING")
2686
- });
2687
- Object.defineProperty(WebSocket2.prototype, "CLOSING", {
2688
- enumerable: true,
2689
- value: readyStates.indexOf("CLOSING")
2690
- });
2691
- Object.defineProperty(WebSocket2, "CLOSED", {
2692
- enumerable: true,
2693
- value: readyStates.indexOf("CLOSED")
2694
- });
2695
- Object.defineProperty(WebSocket2.prototype, "CLOSED", {
2696
- enumerable: true,
2697
- value: readyStates.indexOf("CLOSED")
2698
- });
2699
- [
2700
- "binaryType",
2701
- "bufferedAmount",
2702
- "extensions",
2703
- "isPaused",
2704
- "protocol",
2705
- "readyState",
2706
- "url"
2707
- ].forEach((property) => {
2708
- Object.defineProperty(WebSocket2.prototype, property, { enumerable: true });
2709
- });
2710
- ["open", "error", "close", "message"].forEach((method) => {
2711
- Object.defineProperty(WebSocket2.prototype, `on${method}`, {
2712
- enumerable: true,
2713
- get() {
2714
- for (const listener of this.listeners(method)) {
2715
- if (listener[kForOnEventAttribute]) return listener[kListener];
2716
- }
2717
- return null;
2718
- },
2719
- set(handler) {
2720
- for (const listener of this.listeners(method)) {
2721
- if (listener[kForOnEventAttribute]) {
2722
- this.removeListener(method, listener);
2723
- break;
2724
- }
2725
- }
2726
- if (typeof handler !== "function") return;
2727
- this.addEventListener(method, handler, {
2728
- [kForOnEventAttribute]: true
2729
- });
2730
- }
2731
- });
2732
- });
2733
- WebSocket2.prototype.addEventListener = addEventListener;
2734
- WebSocket2.prototype.removeEventListener = removeEventListener;
2735
- module.exports = WebSocket2;
2736
- function initAsClient(websocket, address, protocols, options) {
2737
- const opts = {
2738
- allowSynchronousEvents: true,
2739
- autoPong: true,
2740
- closeTimeout: CLOSE_TIMEOUT,
2741
- protocolVersion: protocolVersions[1],
2742
- maxPayload: 100 * 1024 * 1024,
2743
- skipUTF8Validation: false,
2744
- perMessageDeflate: true,
2745
- followRedirects: false,
2746
- maxRedirects: 10,
2747
- ...options,
2748
- socketPath: void 0,
2749
- hostname: void 0,
2750
- protocol: void 0,
2751
- timeout: void 0,
2752
- method: "GET",
2753
- host: void 0,
2754
- path: void 0,
2755
- port: void 0
2756
- };
2757
- websocket._autoPong = opts.autoPong;
2758
- websocket._closeTimeout = opts.closeTimeout;
2759
- if (!protocolVersions.includes(opts.protocolVersion)) {
2760
- throw new RangeError(
2761
- `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
2762
- );
2763
- }
2764
- let parsedUrl;
2765
- if (address instanceof URL2) {
2766
- parsedUrl = address;
2767
- } else {
2768
- try {
2769
- parsedUrl = new URL2(address);
2770
- } catch {
2771
- throw new SyntaxError(`Invalid URL: ${address}`);
2772
- }
2773
- }
2774
- if (parsedUrl.protocol === "http:") {
2775
- parsedUrl.protocol = "ws:";
2776
- } else if (parsedUrl.protocol === "https:") {
2777
- parsedUrl.protocol = "wss:";
2778
- }
2779
- websocket._url = parsedUrl.href;
2780
- const isSecure = parsedUrl.protocol === "wss:";
2781
- const isIpcUrl = parsedUrl.protocol === "ws+unix:";
2782
- let invalidUrlMessage;
2783
- if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
2784
- invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;
2785
- } else if (isIpcUrl && !parsedUrl.pathname) {
2786
- invalidUrlMessage = "The URL's pathname is empty";
2787
- } else if (parsedUrl.hash) {
2788
- invalidUrlMessage = "The URL contains a fragment identifier";
2789
- }
2790
- if (invalidUrlMessage) {
2791
- const err = new SyntaxError(invalidUrlMessage);
2792
- if (websocket._redirects === 0) {
2793
- throw err;
2794
- } else {
2795
- emitErrorAndClose(websocket, err);
2796
- return;
2797
- }
2798
- }
2799
- const defaultPort = isSecure ? 443 : 80;
2800
- const key = randomBytes(16).toString("base64");
2801
- const request = isSecure ? https.request : http.request;
2802
- const protocolSet = /* @__PURE__ */ new Set();
2803
- let perMessageDeflate;
2804
- opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
2805
- opts.defaultPort = opts.defaultPort || defaultPort;
2806
- opts.port = parsedUrl.port || defaultPort;
2807
- opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
2808
- opts.headers = {
2809
- ...opts.headers,
2810
- "Sec-WebSocket-Version": opts.protocolVersion,
2811
- "Sec-WebSocket-Key": key,
2812
- Connection: "Upgrade",
2813
- Upgrade: "websocket"
2814
- };
2815
- opts.path = parsedUrl.pathname + parsedUrl.search;
2816
- opts.timeout = opts.handshakeTimeout;
2817
- if (opts.perMessageDeflate) {
2818
- perMessageDeflate = new PerMessageDeflate2({
2819
- ...opts.perMessageDeflate,
2820
- isServer: false,
2821
- maxPayload: opts.maxPayload
2822
- });
2823
- opts.headers["Sec-WebSocket-Extensions"] = format({
2824
- [PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
2825
- });
2826
- }
2827
- if (protocols.length) {
2828
- for (const protocol of protocols) {
2829
- if (typeof protocol !== "string" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) {
2830
- throw new SyntaxError(
2831
- "An invalid or duplicated subprotocol was specified"
2832
- );
2833
- }
2834
- protocolSet.add(protocol);
2835
- }
2836
- opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
2837
- }
2838
- if (opts.origin) {
2839
- if (opts.protocolVersion < 13) {
2840
- opts.headers["Sec-WebSocket-Origin"] = opts.origin;
2841
- } else {
2842
- opts.headers.Origin = opts.origin;
2843
- }
2844
- }
2845
- if (parsedUrl.username || parsedUrl.password) {
2846
- opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
2847
- }
2848
- if (isIpcUrl) {
2849
- const parts = opts.path.split(":");
2850
- opts.socketPath = parts[0];
2851
- opts.path = parts[1];
2852
- }
2853
- let req;
2854
- if (opts.followRedirects) {
2855
- if (websocket._redirects === 0) {
2856
- websocket._originalIpc = isIpcUrl;
2857
- websocket._originalSecure = isSecure;
2858
- websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
2859
- const headers = options && options.headers;
2860
- options = { ...options, headers: {} };
2861
- if (headers) {
2862
- for (const [key2, value] of Object.entries(headers)) {
2863
- options.headers[key2.toLowerCase()] = value;
2864
- }
2865
- }
2866
- } else if (websocket.listenerCount("redirect") === 0) {
2867
- const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
2868
- if (!isSameHost || websocket._originalSecure && !isSecure) {
2869
- delete opts.headers.authorization;
2870
- delete opts.headers.cookie;
2871
- if (!isSameHost) delete opts.headers.host;
2872
- opts.auth = void 0;
2873
- }
2874
- }
2875
- if (opts.auth && !options.headers.authorization) {
2876
- options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
2877
- }
2878
- req = websocket._req = request(opts);
2879
- if (websocket._redirects) {
2880
- websocket.emit("redirect", websocket.url, req);
2881
- }
2882
- } else {
2883
- req = websocket._req = request(opts);
2884
- }
2885
- if (opts.timeout) {
2886
- req.on("timeout", () => {
2887
- abortHandshake(websocket, req, "Opening handshake has timed out");
2888
- });
2889
- }
2890
- req.on("error", (err) => {
2891
- if (req === null || req[kAborted]) return;
2892
- req = websocket._req = null;
2893
- emitErrorAndClose(websocket, err);
2894
- });
2895
- req.on("response", (res) => {
2896
- const location = res.headers.location;
2897
- const statusCode = res.statusCode;
2898
- if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
2899
- if (++websocket._redirects > opts.maxRedirects) {
2900
- abortHandshake(websocket, req, "Maximum redirects exceeded");
2901
- return;
2902
- }
2903
- req.abort();
2904
- let addr;
2905
- try {
2906
- addr = new URL2(location, address);
2907
- } catch (e) {
2908
- const err = new SyntaxError(`Invalid URL: ${location}`);
2909
- emitErrorAndClose(websocket, err);
2910
- return;
2911
- }
2912
- initAsClient(websocket, addr, protocols, options);
2913
- } else if (!websocket.emit("unexpected-response", req, res)) {
2914
- abortHandshake(
2915
- websocket,
2916
- req,
2917
- `Unexpected server response: ${res.statusCode}`
2918
- );
2919
- }
2920
- });
2921
- req.on("upgrade", (res, socket, head) => {
2922
- websocket.emit("upgrade", res);
2923
- if (websocket.readyState !== WebSocket2.CONNECTING) return;
2924
- req = websocket._req = null;
2925
- const upgrade = res.headers.upgrade;
2926
- if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
2927
- abortHandshake(websocket, socket, "Invalid Upgrade header");
2928
- return;
2929
- }
2930
- const digest = createHash("sha1").update(key + GUID).digest("base64");
2931
- if (res.headers["sec-websocket-accept"] !== digest) {
2932
- abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
2933
- return;
2934
- }
2935
- const serverProt = res.headers["sec-websocket-protocol"];
2936
- let protError;
2937
- if (serverProt !== void 0) {
2938
- if (!protocolSet.size) {
2939
- protError = "Server sent a subprotocol but none was requested";
2940
- } else if (!protocolSet.has(serverProt)) {
2941
- protError = "Server sent an invalid subprotocol";
2942
- }
2943
- } else if (protocolSet.size) {
2944
- protError = "Server sent no subprotocol";
2945
- }
2946
- if (protError) {
2947
- abortHandshake(websocket, socket, protError);
2948
- return;
2949
- }
2950
- if (serverProt) websocket._protocol = serverProt;
2951
- const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
2952
- if (secWebSocketExtensions !== void 0) {
2953
- if (!perMessageDeflate) {
2954
- const message = "Server sent a Sec-WebSocket-Extensions header but no extension was requested";
2955
- abortHandshake(websocket, socket, message);
2956
- return;
2957
- }
2958
- let extensions;
2959
- try {
2960
- extensions = parse(secWebSocketExtensions);
2961
- } catch (err) {
2962
- const message = "Invalid Sec-WebSocket-Extensions header";
2963
- abortHandshake(websocket, socket, message);
2964
- return;
2965
- }
2966
- const extensionNames = Object.keys(extensions);
2967
- if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
2968
- const message = "Server indicated an extension that was not requested";
2969
- abortHandshake(websocket, socket, message);
2970
- return;
2971
- }
2972
- try {
2973
- perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
2974
- } catch (err) {
2975
- const message = "Invalid Sec-WebSocket-Extensions header";
2976
- abortHandshake(websocket, socket, message);
2977
- return;
2978
- }
2979
- websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
2980
- }
2981
- websocket.setSocket(socket, head, {
2982
- allowSynchronousEvents: opts.allowSynchronousEvents,
2983
- generateMask: opts.generateMask,
2984
- maxPayload: opts.maxPayload,
2985
- skipUTF8Validation: opts.skipUTF8Validation
2986
- });
2987
- });
2988
- if (opts.finishRequest) {
2989
- opts.finishRequest(req, websocket);
2990
- } else {
2991
- req.end();
2992
- }
2993
- }
2994
- __name(initAsClient, "initAsClient");
2995
- function emitErrorAndClose(websocket, err) {
2996
- websocket._readyState = WebSocket2.CLOSING;
2997
- websocket._errorEmitted = true;
2998
- websocket.emit("error", err);
2999
- websocket.emitClose();
3000
- }
3001
- __name(emitErrorAndClose, "emitErrorAndClose");
3002
- function netConnect(options) {
3003
- options.path = options.socketPath;
3004
- return net.connect(options);
3005
- }
3006
- __name(netConnect, "netConnect");
3007
- function tlsConnect(options) {
3008
- options.path = void 0;
3009
- if (!options.servername && options.servername !== "") {
3010
- options.servername = net.isIP(options.host) ? "" : options.host;
3011
- }
3012
- return tls.connect(options);
3013
- }
3014
- __name(tlsConnect, "tlsConnect");
3015
- function abortHandshake(websocket, stream, message) {
3016
- websocket._readyState = WebSocket2.CLOSING;
3017
- const err = new Error(message);
3018
- Error.captureStackTrace(err, abortHandshake);
3019
- if (stream.setHeader) {
3020
- stream[kAborted] = true;
3021
- stream.abort();
3022
- if (stream.socket && !stream.socket.destroyed) {
3023
- stream.socket.destroy();
3024
- }
3025
- process.nextTick(emitErrorAndClose, websocket, err);
3026
- } else {
3027
- stream.destroy(err);
3028
- stream.once("error", websocket.emit.bind(websocket, "error"));
3029
- stream.once("close", websocket.emitClose.bind(websocket));
3030
- }
3031
- }
3032
- __name(abortHandshake, "abortHandshake");
3033
- function sendAfterClose(websocket, data, cb) {
3034
- if (data) {
3035
- const length = isBlob(data) ? data.size : toBuffer(data).length;
3036
- if (websocket._socket) websocket._sender._bufferedBytes += length;
3037
- else websocket._bufferedAmount += length;
3038
- }
3039
- if (cb) {
3040
- const err = new Error(
3041
- `WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`
3042
- );
3043
- process.nextTick(cb, err);
3044
- }
3045
- }
3046
- __name(sendAfterClose, "sendAfterClose");
3047
- function receiverOnConclude(code, reason) {
3048
- const websocket = this[kWebSocket];
3049
- websocket._closeFrameReceived = true;
3050
- websocket._closeMessage = reason;
3051
- websocket._closeCode = code;
3052
- if (websocket._socket[kWebSocket] === void 0) return;
3053
- websocket._socket.removeListener("data", socketOnData);
3054
- process.nextTick(resume, websocket._socket);
3055
- if (code === 1005) websocket.close();
3056
- else websocket.close(code, reason);
3057
- }
3058
- __name(receiverOnConclude, "receiverOnConclude");
3059
- function receiverOnDrain() {
3060
- const websocket = this[kWebSocket];
3061
- if (!websocket.isPaused) websocket._socket.resume();
3062
- }
3063
- __name(receiverOnDrain, "receiverOnDrain");
3064
- function receiverOnError(err) {
3065
- const websocket = this[kWebSocket];
3066
- if (websocket._socket[kWebSocket] !== void 0) {
3067
- websocket._socket.removeListener("data", socketOnData);
3068
- process.nextTick(resume, websocket._socket);
3069
- websocket.close(err[kStatusCode]);
3070
- }
3071
- if (!websocket._errorEmitted) {
3072
- websocket._errorEmitted = true;
3073
- websocket.emit("error", err);
3074
- }
3075
- }
3076
- __name(receiverOnError, "receiverOnError");
3077
- function receiverOnFinish() {
3078
- this[kWebSocket].emitClose();
3079
- }
3080
- __name(receiverOnFinish, "receiverOnFinish");
3081
- function receiverOnMessage(data, isBinary) {
3082
- this[kWebSocket].emit("message", data, isBinary);
3083
- }
3084
- __name(receiverOnMessage, "receiverOnMessage");
3085
- function receiverOnPing(data) {
3086
- const websocket = this[kWebSocket];
3087
- if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
3088
- websocket.emit("ping", data);
3089
- }
3090
- __name(receiverOnPing, "receiverOnPing");
3091
- function receiverOnPong(data) {
3092
- this[kWebSocket].emit("pong", data);
3093
- }
3094
- __name(receiverOnPong, "receiverOnPong");
3095
- function resume(stream) {
3096
- stream.resume();
3097
- }
3098
- __name(resume, "resume");
3099
- function senderOnError(err) {
3100
- const websocket = this[kWebSocket];
3101
- if (websocket.readyState === WebSocket2.CLOSED) return;
3102
- if (websocket.readyState === WebSocket2.OPEN) {
3103
- websocket._readyState = WebSocket2.CLOSING;
3104
- setCloseTimer(websocket);
3105
- }
3106
- this._socket.end();
3107
- if (!websocket._errorEmitted) {
3108
- websocket._errorEmitted = true;
3109
- websocket.emit("error", err);
3110
- }
3111
- }
3112
- __name(senderOnError, "senderOnError");
3113
- function setCloseTimer(websocket) {
3114
- websocket._closeTimer = setTimeout(
3115
- websocket._socket.destroy.bind(websocket._socket),
3116
- websocket._closeTimeout
3117
- );
3118
- }
3119
- __name(setCloseTimer, "setCloseTimer");
3120
- function socketOnClose() {
3121
- const websocket = this[kWebSocket];
3122
- this.removeListener("close", socketOnClose);
3123
- this.removeListener("data", socketOnData);
3124
- this.removeListener("end", socketOnEnd);
3125
- websocket._readyState = WebSocket2.CLOSING;
3126
- if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
3127
- const chunk = this.read(this._readableState.length);
3128
- websocket._receiver.write(chunk);
3129
- }
3130
- websocket._receiver.end();
3131
- this[kWebSocket] = void 0;
3132
- clearTimeout(websocket._closeTimer);
3133
- if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
3134
- websocket.emitClose();
3135
- } else {
3136
- websocket._receiver.on("error", receiverOnFinish);
3137
- websocket._receiver.on("finish", receiverOnFinish);
3138
- }
3139
- }
3140
- __name(socketOnClose, "socketOnClose");
3141
- function socketOnData(chunk) {
3142
- if (!this[kWebSocket]._receiver.write(chunk)) {
3143
- this.pause();
3144
- }
3145
- }
3146
- __name(socketOnData, "socketOnData");
3147
- function socketOnEnd() {
3148
- const websocket = this[kWebSocket];
3149
- websocket._readyState = WebSocket2.CLOSING;
3150
- websocket._receiver.end();
3151
- this.end();
3152
- }
3153
- __name(socketOnEnd, "socketOnEnd");
3154
- function socketOnError() {
3155
- const websocket = this[kWebSocket];
3156
- this.removeListener("error", socketOnError);
3157
- this.on("error", NOOP);
3158
- if (websocket) {
3159
- websocket._readyState = WebSocket2.CLOSING;
3160
- this.destroy();
3161
- }
3162
- }
3163
- __name(socketOnError, "socketOnError");
3164
- }
3165
- });
3166
-
3167
- // node_modules/ink/node_modules/ws/lib/stream.js
3168
- var require_stream = __commonJS({
3169
- "node_modules/ink/node_modules/ws/lib/stream.js"(exports, module) {
3170
- "use strict";
3171
- init_esbuild_shims();
3172
- var WebSocket2 = require_websocket();
3173
- var { Duplex } = __require("stream");
3174
- function emitClose(stream) {
3175
- stream.emit("close");
3176
- }
3177
- __name(emitClose, "emitClose");
3178
- function duplexOnEnd() {
3179
- if (!this.destroyed && this._writableState.finished) {
3180
- this.destroy();
3181
- }
3182
- }
3183
- __name(duplexOnEnd, "duplexOnEnd");
3184
- function duplexOnError(err) {
3185
- this.removeListener("error", duplexOnError);
3186
- this.destroy();
3187
- if (this.listenerCount("error") === 0) {
3188
- this.emit("error", err);
3189
- }
3190
- }
3191
- __name(duplexOnError, "duplexOnError");
3192
- function createWebSocketStream2(ws, options) {
3193
- let terminateOnDestroy = true;
3194
- const duplex = new Duplex({
3195
- ...options,
3196
- autoDestroy: false,
3197
- emitClose: false,
3198
- objectMode: false,
3199
- writableObjectMode: false
3200
- });
3201
- ws.on("message", /* @__PURE__ */ __name(function message(msg, isBinary) {
3202
- const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
3203
- if (!duplex.push(data)) ws.pause();
3204
- }, "message"));
3205
- ws.once("error", /* @__PURE__ */ __name(function error(err) {
3206
- if (duplex.destroyed) return;
3207
- terminateOnDestroy = false;
3208
- duplex.destroy(err);
3209
- }, "error"));
3210
- ws.once("close", /* @__PURE__ */ __name(function close() {
3211
- if (duplex.destroyed) return;
3212
- duplex.push(null);
3213
- }, "close"));
3214
- duplex._destroy = function(err, callback) {
3215
- if (ws.readyState === ws.CLOSED) {
3216
- callback(err);
3217
- process.nextTick(emitClose, duplex);
3218
- return;
3219
- }
3220
- let called = false;
3221
- ws.once("error", /* @__PURE__ */ __name(function error(err2) {
3222
- called = true;
3223
- callback(err2);
3224
- }, "error"));
3225
- ws.once("close", /* @__PURE__ */ __name(function close() {
3226
- if (!called) callback(err);
3227
- process.nextTick(emitClose, duplex);
3228
- }, "close"));
3229
- if (terminateOnDestroy) ws.terminate();
3230
- };
3231
- duplex._final = function(callback) {
3232
- if (ws.readyState === ws.CONNECTING) {
3233
- ws.once("open", /* @__PURE__ */ __name(function open() {
3234
- duplex._final(callback);
3235
- }, "open"));
3236
- return;
3237
- }
3238
- if (ws._socket === null) return;
3239
- if (ws._socket._writableState.finished) {
3240
- callback();
3241
- if (duplex._readableState.endEmitted) duplex.destroy();
3242
- } else {
3243
- ws._socket.once("finish", /* @__PURE__ */ __name(function finish() {
3244
- callback();
3245
- }, "finish"));
3246
- ws.close();
3247
- }
3248
- };
3249
- duplex._read = function() {
3250
- if (ws.isPaused) ws.resume();
3251
- };
3252
- duplex._write = function(chunk, encoding, callback) {
3253
- if (ws.readyState === ws.CONNECTING) {
3254
- ws.once("open", /* @__PURE__ */ __name(function open() {
3255
- duplex._write(chunk, encoding, callback);
3256
- }, "open"));
3257
- return;
3258
- }
3259
- ws.send(chunk, callback);
3260
- };
3261
- duplex.on("end", duplexOnEnd);
3262
- duplex.on("error", duplexOnError);
3263
- return duplex;
3264
- }
3265
- __name(createWebSocketStream2, "createWebSocketStream");
3266
- module.exports = createWebSocketStream2;
3267
- }
3268
- });
3269
-
3270
- // node_modules/ink/node_modules/ws/lib/subprotocol.js
3271
- var require_subprotocol = __commonJS({
3272
- "node_modules/ink/node_modules/ws/lib/subprotocol.js"(exports, module) {
3273
- "use strict";
3274
- init_esbuild_shims();
3275
- var { tokenChars } = require_validation();
3276
- function parse(header) {
3277
- const protocols = /* @__PURE__ */ new Set();
3278
- let start = -1;
3279
- let end = -1;
3280
- let i = 0;
3281
- for (i; i < header.length; i++) {
3282
- const code = header.charCodeAt(i);
3283
- if (end === -1 && tokenChars[code] === 1) {
3284
- if (start === -1) start = i;
3285
- } else if (i !== 0 && (code === 32 || code === 9)) {
3286
- if (end === -1 && start !== -1) end = i;
3287
- } else if (code === 44) {
3288
- if (start === -1) {
3289
- throw new SyntaxError(`Unexpected character at index ${i}`);
3290
- }
3291
- if (end === -1) end = i;
3292
- const protocol2 = header.slice(start, end);
3293
- if (protocols.has(protocol2)) {
3294
- throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
3295
- }
3296
- protocols.add(protocol2);
3297
- start = end = -1;
3298
- } else {
3299
- throw new SyntaxError(`Unexpected character at index ${i}`);
3300
- }
3301
- }
3302
- if (start === -1 || end !== -1) {
3303
- throw new SyntaxError("Unexpected end of input");
3304
- }
3305
- const protocol = header.slice(start, i);
3306
- if (protocols.has(protocol)) {
3307
- throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
3308
- }
3309
- protocols.add(protocol);
3310
- return protocols;
3311
- }
3312
- __name(parse, "parse");
3313
- module.exports = { parse };
3314
- }
3315
- });
3316
-
3317
- // node_modules/ink/node_modules/ws/lib/websocket-server.js
3318
- var require_websocket_server = __commonJS({
3319
- "node_modules/ink/node_modules/ws/lib/websocket-server.js"(exports, module) {
3320
- "use strict";
3321
- init_esbuild_shims();
3322
- var EventEmitter = __require("events");
3323
- var http = __require("http");
3324
- var { Duplex } = __require("stream");
3325
- var { createHash } = __require("crypto");
3326
- var extension2 = require_extension();
3327
- var PerMessageDeflate2 = require_permessage_deflate();
3328
- var subprotocol2 = require_subprotocol();
3329
- var WebSocket2 = require_websocket();
3330
- var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();
3331
- var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
3332
- var RUNNING = 0;
3333
- var CLOSING = 1;
3334
- var CLOSED = 2;
3335
- var WebSocketServer2 = class extends EventEmitter {
3336
- static {
3337
- __name(this, "WebSocketServer");
3338
- }
3339
- /**
3340
- * Create a `WebSocketServer` instance.
3341
- *
3342
- * @param {Object} options Configuration options
3343
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
3344
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
3345
- * multiple times in the same tick
3346
- * @param {Boolean} [options.autoPong=true] Specifies whether or not to
3347
- * automatically send a pong in response to a ping
3348
- * @param {Number} [options.backlog=511] The maximum length of the queue of
3349
- * pending connections
3350
- * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
3351
- * track clients
3352
- * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
3353
- * wait for the closing handshake to finish after `websocket.close()` is
3354
- * called
3355
- * @param {Function} [options.handleProtocols] A hook to handle protocols
3356
- * @param {String} [options.host] The hostname where to bind the server
3357
- * @param {Number} [options.maxPayload=104857600] The maximum allowed message
3358
- * size
3359
- * @param {Boolean} [options.noServer=false] Enable no server mode
3360
- * @param {String} [options.path] Accept only connections matching this path
3361
- * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
3362
- * permessage-deflate
3363
- * @param {Number} [options.port] The port where to bind the server
3364
- * @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
3365
- * server to use
3366
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
3367
- * not to skip UTF-8 validation for text and close messages
3368
- * @param {Function} [options.verifyClient] A hook to reject connections
3369
- * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
3370
- * class to use. It must be the `WebSocket` class or class that extends it
3371
- * @param {Function} [callback] A listener for the `listening` event
3372
- */
3373
- constructor(options, callback) {
3374
- super();
3375
- options = {
3376
- allowSynchronousEvents: true,
3377
- autoPong: true,
3378
- maxPayload: 100 * 1024 * 1024,
3379
- skipUTF8Validation: false,
3380
- perMessageDeflate: false,
3381
- handleProtocols: null,
3382
- clientTracking: true,
3383
- closeTimeout: CLOSE_TIMEOUT,
3384
- verifyClient: null,
3385
- noServer: false,
3386
- backlog: null,
3387
- // use default (511 as implemented in net.js)
3388
- server: null,
3389
- host: null,
3390
- path: null,
3391
- port: null,
3392
- WebSocket: WebSocket2,
3393
- ...options
3394
- };
3395
- if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
3396
- throw new TypeError(
3397
- 'One and only one of the "port", "server", or "noServer" options must be specified'
3398
- );
3399
- }
3400
- if (options.port != null) {
3401
- this._server = http.createServer((req, res) => {
3402
- const body = http.STATUS_CODES[426];
3403
- res.writeHead(426, {
3404
- "Content-Length": body.length,
3405
- "Content-Type": "text/plain"
3406
- });
3407
- res.end(body);
3408
- });
3409
- this._server.listen(
3410
- options.port,
3411
- options.host,
3412
- options.backlog,
3413
- callback
3414
- );
3415
- } else if (options.server) {
3416
- this._server = options.server;
3417
- }
3418
- if (this._server) {
3419
- const emitConnection = this.emit.bind(this, "connection");
3420
- this._removeListeners = addListeners(this._server, {
3421
- listening: this.emit.bind(this, "listening"),
3422
- error: this.emit.bind(this, "error"),
3423
- upgrade: /* @__PURE__ */ __name((req, socket, head) => {
3424
- this.handleUpgrade(req, socket, head, emitConnection);
3425
- }, "upgrade")
3426
- });
3427
- }
3428
- if (options.perMessageDeflate === true) options.perMessageDeflate = {};
3429
- if (options.clientTracking) {
3430
- this.clients = /* @__PURE__ */ new Set();
3431
- this._shouldEmitClose = false;
3432
- }
3433
- this.options = options;
3434
- this._state = RUNNING;
3435
- }
3436
- /**
3437
- * Returns the bound address, the address family name, and port of the server
3438
- * as reported by the operating system if listening on an IP socket.
3439
- * If the server is listening on a pipe or UNIX domain socket, the name is
3440
- * returned as a string.
3441
- *
3442
- * @return {(Object|String|null)} The address of the server
3443
- * @public
3444
- */
3445
- address() {
3446
- if (this.options.noServer) {
3447
- throw new Error('The server is operating in "noServer" mode');
3448
- }
3449
- if (!this._server) return null;
3450
- return this._server.address();
3451
- }
3452
- /**
3453
- * Stop the server from accepting new connections and emit the `'close'` event
3454
- * when all existing connections are closed.
3455
- *
3456
- * @param {Function} [cb] A one-time listener for the `'close'` event
3457
- * @public
3458
- */
3459
- close(cb) {
3460
- if (this._state === CLOSED) {
3461
- if (cb) {
3462
- this.once("close", () => {
3463
- cb(new Error("The server is not running"));
3464
- });
3465
- }
3466
- process.nextTick(emitClose, this);
3467
- return;
3468
- }
3469
- if (cb) this.once("close", cb);
3470
- if (this._state === CLOSING) return;
3471
- this._state = CLOSING;
3472
- if (this.options.noServer || this.options.server) {
3473
- if (this._server) {
3474
- this._removeListeners();
3475
- this._removeListeners = this._server = null;
3476
- }
3477
- if (this.clients) {
3478
- if (!this.clients.size) {
3479
- process.nextTick(emitClose, this);
3480
- } else {
3481
- this._shouldEmitClose = true;
3482
- }
3483
- } else {
3484
- process.nextTick(emitClose, this);
3485
- }
3486
- } else {
3487
- const server = this._server;
3488
- this._removeListeners();
3489
- this._removeListeners = this._server = null;
3490
- server.close(() => {
3491
- emitClose(this);
3492
- });
3493
- }
3494
- }
3495
- /**
3496
- * See if a given request should be handled by this server instance.
3497
- *
3498
- * @param {http.IncomingMessage} req Request object to inspect
3499
- * @return {Boolean} `true` if the request is valid, else `false`
3500
- * @public
3501
- */
3502
- shouldHandle(req) {
3503
- if (this.options.path) {
3504
- const index = req.url.indexOf("?");
3505
- const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
3506
- if (pathname !== this.options.path) return false;
3507
- }
3508
- return true;
3509
- }
3510
- /**
3511
- * Handle a HTTP Upgrade request.
3512
- *
3513
- * @param {http.IncomingMessage} req The request object
3514
- * @param {Duplex} socket The network socket between the server and client
3515
- * @param {Buffer} head The first packet of the upgraded stream
3516
- * @param {Function} cb Callback
3517
- * @public
3518
- */
3519
- handleUpgrade(req, socket, head, cb) {
3520
- socket.on("error", socketOnError);
3521
- const key = req.headers["sec-websocket-key"];
3522
- const upgrade = req.headers.upgrade;
3523
- const version = +req.headers["sec-websocket-version"];
3524
- if (req.method !== "GET") {
3525
- const message = "Invalid HTTP method";
3526
- abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
3527
- return;
3528
- }
3529
- if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
3530
- const message = "Invalid Upgrade header";
3531
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3532
- return;
3533
- }
3534
- if (key === void 0 || !keyRegex.test(key)) {
3535
- const message = "Missing or invalid Sec-WebSocket-Key header";
3536
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3537
- return;
3538
- }
3539
- if (version !== 13 && version !== 8) {
3540
- const message = "Missing or invalid Sec-WebSocket-Version header";
3541
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
3542
- "Sec-WebSocket-Version": "13, 8"
3543
- });
3544
- return;
3545
- }
3546
- if (!this.shouldHandle(req)) {
3547
- abortHandshake(socket, 400);
3548
- return;
3549
- }
3550
- const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
3551
- let protocols = /* @__PURE__ */ new Set();
3552
- if (secWebSocketProtocol !== void 0) {
3553
- try {
3554
- protocols = subprotocol2.parse(secWebSocketProtocol);
3555
- } catch (err) {
3556
- const message = "Invalid Sec-WebSocket-Protocol header";
3557
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3558
- return;
3559
- }
3560
- }
3561
- const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
3562
- const extensions = {};
3563
- if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
3564
- const perMessageDeflate = new PerMessageDeflate2({
3565
- ...this.options.perMessageDeflate,
3566
- isServer: true,
3567
- maxPayload: this.options.maxPayload
3568
- });
3569
- try {
3570
- const offers = extension2.parse(secWebSocketExtensions);
3571
- if (offers[PerMessageDeflate2.extensionName]) {
3572
- perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
3573
- extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
3574
- }
3575
- } catch (err) {
3576
- const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
3577
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3578
- return;
3579
- }
3580
- }
3581
- if (this.options.verifyClient) {
3582
- const info = {
3583
- origin: req.headers[`${version === 8 ? "sec-websocket-origin" : "origin"}`],
3584
- secure: !!(req.socket.authorized || req.socket.encrypted),
3585
- req
3586
- };
3587
- if (this.options.verifyClient.length === 2) {
3588
- this.options.verifyClient(info, (verified, code, message, headers) => {
3589
- if (!verified) {
3590
- return abortHandshake(socket, code || 401, message, headers);
3591
- }
3592
- this.completeUpgrade(
3593
- extensions,
3594
- key,
3595
- protocols,
3596
- req,
3597
- socket,
3598
- head,
3599
- cb
3600
- );
3601
- });
3602
- return;
3603
- }
3604
- if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
3605
- }
3606
- this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
3607
- }
3608
- /**
3609
- * Upgrade the connection to WebSocket.
3610
- *
3611
- * @param {Object} extensions The accepted extensions
3612
- * @param {String} key The value of the `Sec-WebSocket-Key` header
3613
- * @param {Set} protocols The subprotocols
3614
- * @param {http.IncomingMessage} req The request object
3615
- * @param {Duplex} socket The network socket between the server and client
3616
- * @param {Buffer} head The first packet of the upgraded stream
3617
- * @param {Function} cb Callback
3618
- * @throws {Error} If called more than once with the same socket
3619
- * @private
3620
- */
3621
- completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
3622
- if (!socket.readable || !socket.writable) return socket.destroy();
3623
- if (socket[kWebSocket]) {
3624
- throw new Error(
3625
- "server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
3626
- );
3627
- }
3628
- if (this._state > RUNNING) return abortHandshake(socket, 503);
3629
- const digest = createHash("sha1").update(key + GUID).digest("base64");
3630
- const headers = [
3631
- "HTTP/1.1 101 Switching Protocols",
3632
- "Upgrade: websocket",
3633
- "Connection: Upgrade",
3634
- `Sec-WebSocket-Accept: ${digest}`
3635
- ];
3636
- const ws = new this.options.WebSocket(null, void 0, this.options);
3637
- if (protocols.size) {
3638
- const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
3639
- if (protocol) {
3640
- headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
3641
- ws._protocol = protocol;
3642
- }
3643
- }
3644
- if (extensions[PerMessageDeflate2.extensionName]) {
3645
- const params = extensions[PerMessageDeflate2.extensionName].params;
3646
- const value = extension2.format({
3647
- [PerMessageDeflate2.extensionName]: [params]
3648
- });
3649
- headers.push(`Sec-WebSocket-Extensions: ${value}`);
3650
- ws._extensions = extensions;
3651
- }
3652
- this.emit("headers", headers, req);
3653
- socket.write(headers.concat("\r\n").join("\r\n"));
3654
- socket.removeListener("error", socketOnError);
3655
- ws.setSocket(socket, head, {
3656
- allowSynchronousEvents: this.options.allowSynchronousEvents,
3657
- maxPayload: this.options.maxPayload,
3658
- skipUTF8Validation: this.options.skipUTF8Validation
3659
- });
3660
- if (this.clients) {
3661
- this.clients.add(ws);
3662
- ws.on("close", () => {
3663
- this.clients.delete(ws);
3664
- if (this._shouldEmitClose && !this.clients.size) {
3665
- process.nextTick(emitClose, this);
3666
- }
3667
- });
3668
- }
3669
- cb(ws, req);
3670
- }
3671
- };
3672
- module.exports = WebSocketServer2;
3673
- function addListeners(server, map) {
3674
- for (const event of Object.keys(map)) server.on(event, map[event]);
3675
- return /* @__PURE__ */ __name(function removeListeners() {
3676
- for (const event of Object.keys(map)) {
3677
- server.removeListener(event, map[event]);
3678
- }
3679
- }, "removeListeners");
3680
- }
3681
- __name(addListeners, "addListeners");
3682
- function emitClose(server) {
3683
- server._state = CLOSED;
3684
- server.emit("close");
3685
- }
3686
- __name(emitClose, "emitClose");
3687
- function socketOnError() {
3688
- this.destroy();
3689
- }
3690
- __name(socketOnError, "socketOnError");
3691
- function abortHandshake(socket, code, message, headers) {
3692
- message = message || http.STATUS_CODES[code];
3693
- headers = {
3694
- Connection: "close",
3695
- "Content-Type": "text/html",
3696
- "Content-Length": Buffer.byteLength(message),
3697
- ...headers
3698
- };
3699
- socket.once("finish", socket.destroy);
3700
- socket.end(
3701
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
3702
- ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
3703
- );
3704
- }
3705
- __name(abortHandshake, "abortHandshake");
3706
- function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
3707
- if (server.listenerCount("wsClientError")) {
3708
- const err = new Error(message);
3709
- Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
3710
- server.emit("wsClientError", err, socket, req);
3711
- } else {
3712
- abortHandshake(socket, code, message, headers);
3713
- }
3714
- }
3715
- __name(abortHandshakeOrEmitwsClientError, "abortHandshakeOrEmitwsClientError");
3716
- }
3717
- });
3718
-
3719
16
  // node_modules/react-devtools-core/dist/backend.js
3720
17
  var require_backend = __commonJS({
3721
18
  "node_modules/react-devtools-core/dist/backend.js"(exports, module) {
@@ -4469,7 +766,7 @@ var require_backend = __commonJS({
4469
766
  /***/
4470
767
  (__unused_webpack_module, exports2, __webpack_require__2) => {
4471
768
  "use strict";
4472
- var process2 = __webpack_require__2(169);
769
+ var process = __webpack_require__2(169);
4473
770
  function _typeof(obj) {
4474
771
  "@babel/helpers - typeof";
4475
772
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
@@ -4675,8 +972,8 @@ var require_backend = __commonJS({
4675
972
  error
4676
973
  });
4677
974
  if (!window.dispatchEvent(event)) return;
4678
- } else if ("object" === (typeof process2 === "undefined" ? "undefined" : _typeof(process2)) && "function" === typeof process2.emit) {
4679
- process2.emit("uncaughtException", error);
975
+ } else if ("object" === (typeof process === "undefined" ? "undefined" : _typeof(process)) && "function" === typeof process.emit) {
976
+ process.emit("uncaughtException", error);
4680
977
  return;
4681
978
  }
4682
979
  console.error(error);
@@ -5454,7 +1751,7 @@ var require_backend = __commonJS({
5454
1751
  169: (
5455
1752
  /***/
5456
1753
  (module2) => {
5457
- var process2 = module2.exports = {};
1754
+ var process = module2.exports = {};
5458
1755
  var cachedSetTimeout;
5459
1756
  var cachedClearTimeout;
5460
1757
  function defaultSetTimout() {
@@ -5565,7 +1862,7 @@ var require_backend = __commonJS({
5565
1862
  runClearTimeout(timeout);
5566
1863
  }
5567
1864
  __name(drainQueue, "drainQueue");
5568
- process2.nextTick = function(fun) {
1865
+ process.nextTick = function(fun) {
5569
1866
  var args = new Array(arguments.length - 1);
5570
1867
  if (arguments.length > 1) {
5571
1868
  for (var i = 1; i < arguments.length; i++) {
@@ -5585,37 +1882,37 @@ var require_backend = __commonJS({
5585
1882
  Item.prototype.run = function() {
5586
1883
  this.fun.apply(null, this.array);
5587
1884
  };
5588
- process2.title = "browser";
5589
- process2.browser = true;
5590
- process2.env = {};
5591
- process2.argv = [];
5592
- process2.version = "";
5593
- process2.versions = {};
1885
+ process.title = "browser";
1886
+ process.browser = true;
1887
+ process.env = {};
1888
+ process.argv = [];
1889
+ process.version = "";
1890
+ process.versions = {};
5594
1891
  function noop() {
5595
1892
  }
5596
1893
  __name(noop, "noop");
5597
- process2.on = noop;
5598
- process2.addListener = noop;
5599
- process2.once = noop;
5600
- process2.off = noop;
5601
- process2.removeListener = noop;
5602
- process2.removeAllListeners = noop;
5603
- process2.emit = noop;
5604
- process2.prependListener = noop;
5605
- process2.prependOnceListener = noop;
5606
- process2.listeners = function(name) {
1894
+ process.on = noop;
1895
+ process.addListener = noop;
1896
+ process.once = noop;
1897
+ process.off = noop;
1898
+ process.removeListener = noop;
1899
+ process.removeAllListeners = noop;
1900
+ process.emit = noop;
1901
+ process.prependListener = noop;
1902
+ process.prependOnceListener = noop;
1903
+ process.listeners = function(name) {
5607
1904
  return [];
5608
1905
  };
5609
- process2.binding = function(name) {
1906
+ process.binding = function(name) {
5610
1907
  throw new Error("process.binding is not supported");
5611
1908
  };
5612
- process2.cwd = function() {
1909
+ process.cwd = function() {
5613
1910
  return "/";
5614
1911
  };
5615
- process2.chdir = function(dir) {
1912
+ process.chdir = function(dir) {
5616
1913
  throw new Error("process.chdir is not supported");
5617
1914
  };
5618
- process2.umask = function() {
1915
+ process.umask = function() {
5619
1916
  return 0;
5620
1917
  };
5621
1918
  }
@@ -6742,7 +3039,7 @@ var require_backend = __commonJS({
6742
3039
  var isArray = Array.isArray;
6743
3040
  const src_isArray = isArray;
6744
3041
  ;
6745
- var process2 = __webpack_require__(169);
3042
+ var process = __webpack_require__(169);
6746
3043
  function ownKeys(object, enumerableOnly) {
6747
3044
  var keys = Object.keys(object);
6748
3045
  if (Object.getOwnPropertySymbols) {
@@ -7047,7 +3344,7 @@ var require_backend = __commonJS({
7047
3344
  }
7048
3345
  __name(filterOutLocationComponentFilters, "filterOutLocationComponentFilters");
7049
3346
  function getDefaultOpenInEditorURL() {
7050
- return typeof process2.env.EDITOR_URL === "string" ? process2.env.EDITOR_URL : "";
3347
+ return typeof process.env.EDITOR_URL === "string" ? process.env.EDITOR_URL : "";
7051
3348
  }
7052
3349
  __name(getDefaultOpenInEditorURL, "getDefaultOpenInEditorURL");
7053
3350
  function getOpenInEditorURL() {
@@ -18636,20 +14933,6 @@ init_esbuild_shims();
18636
14933
 
18637
14934
  // node_modules/ink/build/devtools-window-polyfill.js
18638
14935
  init_esbuild_shims();
18639
-
18640
- // node_modules/ink/node_modules/ws/wrapper.mjs
18641
- init_esbuild_shims();
18642
- var import_stream = __toESM(require_stream(), 1);
18643
- var import_extension = __toESM(require_extension(), 1);
18644
- var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
18645
- var import_receiver = __toESM(require_receiver(), 1);
18646
- var import_sender = __toESM(require_sender(), 1);
18647
- var import_subprotocol = __toESM(require_subprotocol(), 1);
18648
- var import_websocket = __toESM(require_websocket(), 1);
18649
- var import_websocket_server = __toESM(require_websocket_server(), 1);
18650
- var wrapper_default = import_websocket.default;
18651
-
18652
- // node_modules/ink/build/devtools-window-polyfill.js
18653
14936
  var customGlobal = globalThis;
18654
14937
  customGlobal.WebSocket ||= wrapper_default;
18655
14938
  customGlobal.window ||= globalThis;