crossws 0.4.3 → 0.4.5

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 (50) hide show
  1. package/adapters/bunny.d.ts +2 -0
  2. package/dist/THIRD-PARTY-LICENSES.md +33 -0
  3. package/dist/_chunks/_request.mjs +4 -6
  4. package/dist/_chunks/_types.d.mts +2 -3
  5. package/dist/_chunks/adapter.d.mts +45 -53
  6. package/dist/_chunks/adapter.mjs +6 -7
  7. package/dist/_chunks/bun.d.mts +0 -3
  8. package/dist/_chunks/bunny.d.mts +22 -0
  9. package/dist/_chunks/cloudflare.d.mts +16 -19
  10. package/dist/_chunks/deno.d.mts +0 -3
  11. package/dist/_chunks/error.mjs +1 -4
  12. package/dist/_chunks/libs/ws.mjs +77 -1179
  13. package/dist/_chunks/node.d.mts +43 -14
  14. package/dist/_chunks/node.mjs +129 -0
  15. package/dist/_chunks/peer.mjs +1 -59
  16. package/dist/_chunks/rolldown-runtime.mjs +7 -15
  17. package/dist/_chunks/sse.d.mts +0 -3
  18. package/dist/_chunks/web.d.mts +164 -166
  19. package/dist/adapters/bun.mjs +1 -6
  20. package/dist/adapters/bunny.d.mts +2 -0
  21. package/dist/adapters/bunny.mjs +68 -0
  22. package/dist/adapters/cloudflare.mjs +7 -12
  23. package/dist/adapters/deno.mjs +1 -6
  24. package/dist/adapters/node.d.mts +2 -2
  25. package/dist/adapters/node.mjs +2 -125
  26. package/dist/adapters/sse.mjs +1 -6
  27. package/dist/adapters/uws.d.mts +0 -5
  28. package/dist/adapters/uws.mjs +2 -7
  29. package/dist/index.d.mts +81 -1
  30. package/dist/index.mjs +161 -2
  31. package/dist/server/bun.d.mts +0 -6
  32. package/dist/server/bun.mjs +3 -7
  33. package/dist/server/bunny.d.mts +5 -0
  34. package/dist/server/bunny.mjs +23 -0
  35. package/dist/server/cloudflare.d.mts +0 -6
  36. package/dist/server/cloudflare.mjs +3 -7
  37. package/dist/server/default.d.mts +0 -6
  38. package/dist/server/default.mjs +3 -7
  39. package/dist/server/deno.d.mts +0 -6
  40. package/dist/server/deno.mjs +3 -7
  41. package/dist/server/node.d.mts +0 -6
  42. package/dist/server/node.mjs +3 -9
  43. package/dist/websocket/native.d.mts +0 -2
  44. package/dist/websocket/native.mjs +1 -5
  45. package/dist/websocket/node.d.mts +0 -2
  46. package/dist/websocket/node.mjs +1 -7
  47. package/dist/websocket/sse.d.mts +0 -3
  48. package/dist/websocket/sse.mjs +1 -4
  49. package/package.json +42 -40
  50. package/server/bunny.d.ts +2 -0
@@ -1,6 +1,4 @@
1
1
  import { n as __require, r as __toESM, t as __commonJSMin } from "../rolldown-runtime.mjs";
2
-
3
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/constants.js
4
2
  var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
3
  const BINARY_TYPES = [
6
4
  "nodebuffer",
@@ -22,20 +20,9 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22
20
  NOOP: () => {}
23
21
  };
24
22
  }));
25
-
26
- //#endregion
27
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/buffer-util.js
28
23
  var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29
24
  const { EMPTY_BUFFER } = require_constants();
30
25
  const FastBuffer = Buffer[Symbol.species];
31
- /**
32
- * Merges an array of buffers into a new buffer.
33
- *
34
- * @param {Buffer[]} list The array of buffers to concat
35
- * @param {Number} totalLength The total length of buffers in the list
36
- * @return {Buffer} The resulting buffer
37
- * @public
38
- */
39
26
  function concat(list, totalLength) {
40
27
  if (list.length === 0) return EMPTY_BUFFER;
41
28
  if (list.length === 1) return list[0];
@@ -49,48 +36,16 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
49
36
  if (offset < totalLength) return new FastBuffer(target.buffer, target.byteOffset, offset);
50
37
  return target;
51
38
  }
52
- /**
53
- * Masks a buffer using the given mask.
54
- *
55
- * @param {Buffer} source The buffer to mask
56
- * @param {Buffer} mask The mask to use
57
- * @param {Buffer} output The buffer where to store the result
58
- * @param {Number} offset The offset at which to start writing
59
- * @param {Number} length The number of bytes to mask.
60
- * @public
61
- */
62
39
  function _mask(source, mask, output, offset, length) {
63
40
  for (let i = 0; i < length; i++) output[offset + i] = source[i] ^ mask[i & 3];
64
41
  }
65
- /**
66
- * Unmasks a buffer using the given mask.
67
- *
68
- * @param {Buffer} buffer The buffer to unmask
69
- * @param {Buffer} mask The mask to use
70
- * @public
71
- */
72
42
  function _unmask(buffer, mask) {
73
43
  for (let i = 0; i < buffer.length; i++) buffer[i] ^= mask[i & 3];
74
44
  }
75
- /**
76
- * Converts a buffer to an `ArrayBuffer`.
77
- *
78
- * @param {Buffer} buf The buffer to convert
79
- * @return {ArrayBuffer} Converted buffer
80
- * @public
81
- */
82
45
  function toArrayBuffer(buf) {
83
46
  if (buf.length === buf.buffer.byteLength) return buf.buffer;
84
47
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
85
48
  }
86
- /**
87
- * Converts `data` to a `Buffer`.
88
- *
89
- * @param {*} data The data to convert
90
- * @return {Buffer} The buffer
91
- * @throws {TypeError}
92
- * @public
93
- */
94
49
  function toBuffer(data) {
95
50
  toBuffer.readOnly = true;
96
51
  if (Buffer.isBuffer(data)) return data;
@@ -110,7 +65,6 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110
65
  toBuffer,
111
66
  unmask: _unmask
112
67
  };
113
- /* istanbul ignore else */
114
68
  if (!process.env.WS_NO_BUFFER_UTIL) try {
115
69
  const bufferUtil = __require("bufferutil");
116
70
  module.exports.mask = function(source, mask, output, offset, length) {
@@ -123,23 +77,10 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
123
77
  };
124
78
  } catch (e) {}
125
79
  }));
126
-
127
- //#endregion
128
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/limiter.js
129
80
  var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
130
81
  const kDone = Symbol("kDone");
131
82
  const kRun = Symbol("kRun");
132
- /**
133
- * A very simple job queue with adjustable concurrency. Adapted from
134
- * https://github.com/STRML/async-limiter
135
- */
136
83
  var Limiter = class {
137
- /**
138
- * Creates a new `Limiter`.
139
- *
140
- * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
141
- * to run concurrently
142
- */
143
84
  constructor(concurrency) {
144
85
  this[kDone] = () => {
145
86
  this.pending--;
@@ -149,21 +90,10 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
149
90
  this.jobs = [];
150
91
  this.pending = 0;
151
92
  }
152
- /**
153
- * Adds a job to the queue.
154
- *
155
- * @param {Function} job The job to run
156
- * @public
157
- */
158
93
  add(job) {
159
94
  this.jobs.push(job);
160
95
  this[kRun]();
161
96
  }
162
- /**
163
- * Removes a job from the queue and runs it if possible.
164
- *
165
- * @private
166
- */
167
97
  [kRun]() {
168
98
  if (this.pending === this.concurrency) return;
169
99
  if (this.jobs.length) {
@@ -175,9 +105,6 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
175
105
  };
176
106
  module.exports = Limiter;
177
107
  }));
178
-
179
- //#endregion
180
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/permessage-deflate.js
181
108
  var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
182
109
  const zlib = __require("zlib");
183
110
  const bufferUtil = require_buffer_util();
@@ -196,56 +123,20 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
196
123
  const kBuffers = Symbol("buffers");
197
124
  const kError = Symbol("error");
198
125
  let zlibLimiter;
199
- /**
200
- * permessage-deflate implementation.
201
- */
202
126
  var PerMessageDeflate = class {
203
- /**
204
- * Creates a PerMessageDeflate instance.
205
- *
206
- * @param {Object} [options] Configuration options
207
- * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
208
- * for, or request, a custom client window size
209
- * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
210
- * acknowledge disabling of client context takeover
211
- * @param {Number} [options.concurrencyLimit=10] The number of concurrent
212
- * calls to zlib
213
- * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
214
- * use of a custom server window size
215
- * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
216
- * disabling of server context takeover
217
- * @param {Number} [options.threshold=1024] Size (in bytes) below which
218
- * messages should not be compressed if context takeover is disabled
219
- * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
220
- * deflate
221
- * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
222
- * inflate
223
- * @param {Boolean} [isServer=false] Create the instance in either server or
224
- * client mode
225
- * @param {Number} [maxPayload=0] The maximum allowed message length
226
- */
227
- constructor(options, isServer, maxPayload) {
228
- this._maxPayload = maxPayload | 0;
127
+ constructor(options) {
229
128
  this._options = options || {};
230
129
  this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
231
- this._isServer = !!isServer;
130
+ this._maxPayload = this._options.maxPayload | 0;
131
+ this._isServer = !!this._options.isServer;
232
132
  this._deflate = null;
233
133
  this._inflate = null;
234
134
  this.params = null;
235
135
  if (!zlibLimiter) zlibLimiter = new Limiter(this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10);
236
136
  }
237
- /**
238
- * @type {String}
239
- */
240
137
  static get extensionName() {
241
138
  return "permessage-deflate";
242
139
  }
243
- /**
244
- * Create an extension negotiation offer.
245
- *
246
- * @return {Object} Extension parameters
247
- * @public
248
- */
249
140
  offer() {
250
141
  const params = {};
251
142
  if (this._options.serverNoContextTakeover) params.server_no_context_takeover = true;
@@ -255,23 +146,11 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
255
146
  else if (this._options.clientMaxWindowBits == null) params.client_max_window_bits = true;
256
147
  return params;
257
148
  }
258
- /**
259
- * Accept an extension negotiation offer/response.
260
- *
261
- * @param {Array} configurations The extension negotiation offers/reponse
262
- * @return {Object} Accepted configuration
263
- * @public
264
- */
265
149
  accept(configurations) {
266
150
  configurations = this.normalizeParams(configurations);
267
151
  this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
268
152
  return this.params;
269
153
  }
270
- /**
271
- * Releases all resources used by the extension.
272
- *
273
- * @public
274
- */
275
154
  cleanup() {
276
155
  if (this._inflate) {
277
156
  this._inflate.close();
@@ -284,13 +163,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
284
163
  if (callback) callback(/* @__PURE__ */ new Error("The deflate stream was closed while data was being processed"));
285
164
  }
286
165
  }
287
- /**
288
- * Accept an extension negotiation offer.
289
- *
290
- * @param {Array} offers The extension negotiation offers
291
- * @return {Object} Accepted configuration
292
- * @private
293
- */
294
166
  acceptAsServer(offers) {
295
167
  const opts = this._options;
296
168
  const accepted = offers.find((params) => {
@@ -305,13 +177,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
305
177
  else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) delete accepted.client_max_window_bits;
306
178
  return accepted;
307
179
  }
308
- /**
309
- * Accept the extension negotiation response.
310
- *
311
- * @param {Array} response The extension negotiation response
312
- * @return {Object} Accepted configuration
313
- * @private
314
- */
315
180
  acceptAsClient(response) {
316
181
  const params = response[0];
317
182
  if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) throw new Error("Unexpected parameter \"client_no_context_takeover\"");
@@ -320,13 +185,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
320
185
  } else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) throw new Error("Unexpected or invalid parameter \"client_max_window_bits\"");
321
186
  return params;
322
187
  }
323
- /**
324
- * Normalize parameters.
325
- *
326
- * @param {Array} configurations The extension negotiation offers/reponse
327
- * @return {Array} The offers/response with normalized parameters
328
- * @private
329
- */
330
188
  normalizeParams(configurations) {
331
189
  configurations.forEach((params) => {
332
190
  Object.keys(params).forEach((key) => {
@@ -351,14 +209,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
351
209
  });
352
210
  return configurations;
353
211
  }
354
- /**
355
- * Decompress data. Concurrency limited.
356
- *
357
- * @param {Buffer} data Compressed data
358
- * @param {Boolean} fin Specifies whether or not this is the last fragment
359
- * @param {Function} callback Callback
360
- * @public
361
- */
362
212
  decompress(data, fin, callback) {
363
213
  zlibLimiter.add((done) => {
364
214
  this._decompress(data, fin, (err, result) => {
@@ -367,14 +217,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
367
217
  });
368
218
  });
369
219
  }
370
- /**
371
- * Compress data. Concurrency limited.
372
- *
373
- * @param {(Buffer|String)} data Data to compress
374
- * @param {Boolean} fin Specifies whether or not this is the last fragment
375
- * @param {Function} callback Callback
376
- * @public
377
- */
378
220
  compress(data, fin, callback) {
379
221
  zlibLimiter.add((done) => {
380
222
  this._compress(data, fin, (err, result) => {
@@ -383,14 +225,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
383
225
  });
384
226
  });
385
227
  }
386
- /**
387
- * Decompress data.
388
- *
389
- * @param {Buffer} data Compressed data
390
- * @param {Boolean} fin Specifies whether or not this is the last fragment
391
- * @param {Function} callback Callback
392
- * @private
393
- */
394
228
  _decompress(data, fin, callback) {
395
229
  const endpoint = this._isServer ? "client" : "server";
396
230
  if (!this._inflate) {
@@ -417,7 +251,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
417
251
  callback(err);
418
252
  return;
419
253
  }
420
- const data$1 = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
254
+ const data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
421
255
  if (this._inflate._readableState.endEmitted) {
422
256
  this._inflate.close();
423
257
  this._inflate = null;
@@ -426,17 +260,9 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
426
260
  this._inflate[kBuffers] = [];
427
261
  if (fin && this.params[`${endpoint}_no_context_takeover`]) this._inflate.reset();
428
262
  }
429
- callback(null, data$1);
263
+ callback(null, data);
430
264
  });
431
265
  }
432
- /**
433
- * Compress data.
434
- *
435
- * @param {(Buffer|String)} data Data to compress
436
- * @param {Boolean} fin Specifies whether or not this is the last fragment
437
- * @param {Function} callback Callback
438
- * @private
439
- */
440
266
  _compress(data, fin, callback) {
441
267
  const endpoint = this._isServer ? "server" : "client";
442
268
  if (!this._deflate) {
@@ -454,33 +280,21 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
454
280
  this._deflate.write(data);
455
281
  this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
456
282
  if (!this._deflate) return;
457
- let data$1 = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
458
- if (fin) data$1 = new FastBuffer(data$1.buffer, data$1.byteOffset, data$1.length - 4);
283
+ let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
284
+ if (fin) data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);
459
285
  this._deflate[kCallback] = null;
460
286
  this._deflate[kTotalLength] = 0;
461
287
  this._deflate[kBuffers] = [];
462
288
  if (fin && this.params[`${endpoint}_no_context_takeover`]) this._deflate.reset();
463
- callback(null, data$1);
289
+ callback(null, data);
464
290
  });
465
291
  }
466
292
  };
467
293
  module.exports = PerMessageDeflate;
468
- /**
469
- * The listener of the `zlib.DeflateRaw` stream `'data'` event.
470
- *
471
- * @param {Buffer} chunk A chunk of data
472
- * @private
473
- */
474
294
  function deflateOnData(chunk) {
475
295
  this[kBuffers].push(chunk);
476
296
  this[kTotalLength] += chunk.length;
477
297
  }
478
- /**
479
- * The listener of the `zlib.InflateRaw` stream `'data'` event.
480
- *
481
- * @param {Buffer} chunk A chunk of data
482
- * @private
483
- */
484
298
  function inflateOnData(chunk) {
485
299
  this[kTotalLength] += chunk.length;
486
300
  if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
@@ -493,12 +307,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
493
307
  this.removeListener("data", inflateOnData);
494
308
  this.reset();
495
309
  }
496
- /**
497
- * The listener of the `zlib.InflateRaw` stream `'error'` event.
498
- *
499
- * @param {Error} err The emitted error
500
- * @private
501
- */
502
310
  function inflateOnError(err) {
503
311
  this[kPerMessageDeflate]._inflate = null;
504
312
  if (this[kError]) {
@@ -509,9 +317,6 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
509
317
  this[kCallback](err);
510
318
  }
511
319
  }));
512
-
513
- //#endregion
514
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/validation.js
515
320
  var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
516
321
  const { isUtf8 } = __require("buffer");
517
322
  const { hasBlob } = require_constants();
@@ -645,25 +450,9 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
645
450
  1,
646
451
  0
647
452
  ];
648
- /**
649
- * Checks if a status code is allowed in a close frame.
650
- *
651
- * @param {Number} code The status code
652
- * @return {Boolean} `true` if the status code is valid, else `false`
653
- * @public
654
- */
655
453
  function isValidStatusCode(code) {
656
454
  return code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;
657
455
  }
658
- /**
659
- * Checks if a given buffer contains only correct UTF-8.
660
- * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
661
- * Markus Kuhn.
662
- *
663
- * @param {Buffer} buf The buffer to check
664
- * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
665
- * @public
666
- */
667
456
  function _isValidUTF8(buf) {
668
457
  const len = buf.length;
669
458
  let i = 0;
@@ -680,13 +469,6 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
680
469
  } else return false;
681
470
  return true;
682
471
  }
683
- /**
684
- * Determines whether a value is a `Blob`.
685
- *
686
- * @param {*} value The value to be tested
687
- * @return {Boolean} `true` if `value` is a `Blob`, else `false`
688
- * @private
689
- */
690
472
  function isBlob(value) {
691
473
  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");
692
474
  }
@@ -706,9 +488,6 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
706
488
  };
707
489
  } catch (e) {}
708
490
  }));
709
-
710
- //#endregion
711
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/receiver.js
712
491
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
713
492
  const { Writable } = __require("stream");
714
493
  const PerMessageDeflate = require_permessage_deflate();
@@ -723,28 +502,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
723
502
  const GET_DATA = 4;
724
503
  const INFLATING = 5;
725
504
  const DEFER_EVENT = 6;
726
- /**
727
- * HyBi Receiver implementation.
728
- *
729
- * @extends Writable
730
- */
731
505
  var Receiver = class extends Writable {
732
- /**
733
- * Creates a Receiver instance.
734
- *
735
- * @param {Object} [options] Options object
736
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
737
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
738
- * multiple times in the same tick
739
- * @param {String} [options.binaryType=nodebuffer] The type for binary data
740
- * @param {Object} [options.extensions] An object containing the negotiated
741
- * extensions
742
- * @param {Boolean} [options.isServer=false] Specifies whether to operate in
743
- * client or server mode
744
- * @param {Number} [options.maxPayload=0] The maximum allowed message length
745
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
746
- * not to skip UTF-8 validation for text and close messages
747
- */
748
506
  constructor(options = {}) {
749
507
  super();
750
508
  this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
@@ -770,27 +528,12 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
770
528
  this._loop = false;
771
529
  this._state = GET_INFO;
772
530
  }
773
- /**
774
- * Implements `Writable.prototype._write()`.
775
- *
776
- * @param {Buffer} chunk The chunk of data to write
777
- * @param {String} encoding The character encoding of `chunk`
778
- * @param {Function} cb Callback
779
- * @private
780
- */
781
531
  _write(chunk, encoding, cb) {
782
532
  if (this._opcode === 8 && this._state == GET_INFO) return cb();
783
533
  this._bufferedBytes += chunk.length;
784
534
  this._buffers.push(chunk);
785
535
  this.startLoop(cb);
786
536
  }
787
- /**
788
- * Consumes `n` bytes from the buffered data.
789
- *
790
- * @param {Number} n The number of bytes to consume
791
- * @return {Buffer} The consumed bytes
792
- * @private
793
- */
794
537
  consume(n) {
795
538
  this._bufferedBytes -= n;
796
539
  if (n === this._buffers[0].length) return this._buffers.shift();
@@ -812,12 +555,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
812
555
  } while (n > 0);
813
556
  return dst;
814
557
  }
815
- /**
816
- * Starts the parsing loop.
817
- *
818
- * @param {Function} cb Callback
819
- * @private
820
- */
821
558
  startLoop(cb) {
822
559
  this._loop = true;
823
560
  do
@@ -845,12 +582,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
845
582
  while (this._loop);
846
583
  if (!this._errored) cb();
847
584
  }
848
- /**
849
- * Reads the first two bytes of a frame.
850
- *
851
- * @param {Function} cb Callback
852
- * @private
853
- */
854
585
  getInfo(cb) {
855
586
  if (this._bufferedBytes < 2) {
856
587
  this._loop = false;
@@ -917,12 +648,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
917
648
  else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
918
649
  else this.haveLength(cb);
919
650
  }
920
- /**
921
- * Gets extended payload length (7+16).
922
- *
923
- * @param {Function} cb Callback
924
- * @private
925
- */
926
651
  getPayloadLength16(cb) {
927
652
  if (this._bufferedBytes < 2) {
928
653
  this._loop = false;
@@ -931,12 +656,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
931
656
  this._payloadLength = this.consume(2).readUInt16BE(0);
932
657
  this.haveLength(cb);
933
658
  }
934
- /**
935
- * Gets extended payload length (7+64).
936
- *
937
- * @param {Function} cb Callback
938
- * @private
939
- */
940
659
  getPayloadLength64(cb) {
941
660
  if (this._bufferedBytes < 8) {
942
661
  this._loop = false;
@@ -951,12 +670,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
951
670
  this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
952
671
  this.haveLength(cb);
953
672
  }
954
- /**
955
- * Payload length has been read.
956
- *
957
- * @param {Function} cb Callback
958
- * @private
959
- */
960
673
  haveLength(cb) {
961
674
  if (this._payloadLength && this._opcode < 8) {
962
675
  this._totalPayloadLength += this._payloadLength;
@@ -968,11 +681,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
968
681
  if (this._masked) this._state = GET_MASK;
969
682
  else this._state = GET_DATA;
970
683
  }
971
- /**
972
- * Reads mask bytes.
973
- *
974
- * @private
975
- */
976
684
  getMask() {
977
685
  if (this._bufferedBytes < 4) {
978
686
  this._loop = false;
@@ -981,12 +689,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
981
689
  this._mask = this.consume(4);
982
690
  this._state = GET_DATA;
983
691
  }
984
- /**
985
- * Reads data bytes.
986
- *
987
- * @param {Function} cb Callback
988
- * @private
989
- */
990
692
  getData(cb) {
991
693
  let data = EMPTY_BUFFER;
992
694
  if (this._payloadLength) {
@@ -1012,13 +714,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1012
714
  }
1013
715
  this.dataMessage(cb);
1014
716
  }
1015
- /**
1016
- * Decompresses data.
1017
- *
1018
- * @param {Buffer} data Compressed data
1019
- * @param {Function} cb Callback
1020
- * @private
1021
- */
1022
717
  decompress(data, cb) {
1023
718
  this._extensions[PerMessageDeflate.extensionName].decompress(data, this._fin, (err, buf) => {
1024
719
  if (err) return cb(err);
@@ -1034,12 +729,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1034
729
  if (this._state === GET_INFO) this.startLoop(cb);
1035
730
  });
1036
731
  }
1037
- /**
1038
- * Handles a data message.
1039
- *
1040
- * @param {Function} cb Callback
1041
- * @private
1042
- */
1043
732
  dataMessage(cb) {
1044
733
  if (!this._fin) {
1045
734
  this._state = GET_INFO;
@@ -1087,13 +776,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1087
776
  }
1088
777
  }
1089
778
  }
1090
- /**
1091
- * Handles a control message.
1092
- *
1093
- * @param {Buffer} data Data to handle
1094
- * @return {(Error|RangeError|undefined)} A possible error
1095
- * @private
1096
- */
1097
779
  controlMessage(data, cb) {
1098
780
  if (this._opcode === 8) {
1099
781
  if (data.length === 0) {
@@ -1130,18 +812,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1130
812
  });
1131
813
  }
1132
814
  }
1133
- /**
1134
- * Builds an error object.
1135
- *
1136
- * @param {function(new:Error|RangeError)} ErrorCtor The error constructor
1137
- * @param {String} message The error message
1138
- * @param {Boolean} prefix Specifies whether or not to add a default prefix to
1139
- * `message`
1140
- * @param {Number} statusCode The status code
1141
- * @param {String} errorCode The exposed error code
1142
- * @return {(Error|RangeError)} The error
1143
- * @private
1144
- */
1145
815
  createError(ErrorCtor, message, prefix, statusCode, errorCode) {
1146
816
  this._loop = false;
1147
817
  this._errored = true;
@@ -1154,9 +824,6 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1154
824
  };
1155
825
  module.exports = Receiver;
1156
826
  }));
1157
-
1158
- //#endregion
1159
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/sender.js
1160
827
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1161
828
  const { Duplex: Duplex$3 } = __require("stream");
1162
829
  const { randomFillSync } = __require("crypto");
@@ -1172,18 +839,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1172
839
  const DEFAULT = 0;
1173
840
  const DEFLATING = 1;
1174
841
  const GET_BLOB_DATA = 2;
1175
- /**
1176
- * HyBi Sender implementation.
1177
- */
1178
- var Sender = class Sender {
1179
- /**
1180
- * Creates a Sender instance.
1181
- *
1182
- * @param {Duplex} socket The connection socket
1183
- * @param {Object} [extensions] An object containing the negotiated extensions
1184
- * @param {Function} [generateMask] The function used to generate the masking
1185
- * key
1186
- */
842
+ module.exports = class Sender {
1187
843
  constructor(socket, extensions, generateMask) {
1188
844
  this._extensions = extensions || {};
1189
845
  if (generateMask) {
@@ -1199,27 +855,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1199
855
  this.onerror = NOOP;
1200
856
  this[kWebSocket] = void 0;
1201
857
  }
1202
- /**
1203
- * Frames a piece of data according to the HyBi WebSocket protocol.
1204
- *
1205
- * @param {(Buffer|String)} data The data to frame
1206
- * @param {Object} options Options object
1207
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1208
- * FIN bit
1209
- * @param {Function} [options.generateMask] The function used to generate the
1210
- * masking key
1211
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1212
- * `data`
1213
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1214
- * key
1215
- * @param {Number} options.opcode The opcode
1216
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1217
- * modified
1218
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1219
- * RSV1 bit
1220
- * @return {(Buffer|String)[]} The framed data
1221
- * @public
1222
- */
1223
858
  static frame(data, options) {
1224
859
  let mask;
1225
860
  let merge = false;
@@ -1230,7 +865,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1230
865
  if (options.generateMask) options.generateMask(mask);
1231
866
  else {
1232
867
  if (randomPoolPointer === RANDOM_POOL_SIZE) {
1233
- /* istanbul ignore else */
1234
868
  if (randomPool === void 0) randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
1235
869
  randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
1236
870
  randomPoolPointer = 0;
@@ -1284,15 +918,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1284
918
  applyMask(data, mask, data, 0, dataLength);
1285
919
  return [target, data];
1286
920
  }
1287
- /**
1288
- * Sends a close message to the other peer.
1289
- *
1290
- * @param {Number} [code] The status code component of the body
1291
- * @param {(String|Buffer)} [data] The message component of the body
1292
- * @param {Boolean} [mask=false] Specifies whether or not to mask the message
1293
- * @param {Function} [cb] Callback
1294
- * @public
1295
- */
1296
921
  close(code, data, mask, cb) {
1297
922
  let buf;
1298
923
  if (code === void 0) buf = EMPTY_BUFFER;
@@ -1327,14 +952,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1327
952
  ]);
1328
953
  else this.sendFrame(Sender.frame(buf, options), cb);
1329
954
  }
1330
- /**
1331
- * Sends a ping message to the other peer.
1332
- *
1333
- * @param {*} data The message to send
1334
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1335
- * @param {Function} [cb] Callback
1336
- * @public
1337
- */
1338
955
  ping(data, mask, cb) {
1339
956
  let byteLength;
1340
957
  let readOnly;
@@ -1377,14 +994,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1377
994
  ]);
1378
995
  else this.sendFrame(Sender.frame(data, options), cb);
1379
996
  }
1380
- /**
1381
- * Sends a pong message to the other peer.
1382
- *
1383
- * @param {*} data The message to send
1384
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
1385
- * @param {Function} [cb] Callback
1386
- * @public
1387
- */
1388
997
  pong(data, mask, cb) {
1389
998
  let byteLength;
1390
999
  let readOnly;
@@ -1427,22 +1036,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1427
1036
  ]);
1428
1037
  else this.sendFrame(Sender.frame(data, options), cb);
1429
1038
  }
1430
- /**
1431
- * Sends a data message to the other peer.
1432
- *
1433
- * @param {*} data The message to send
1434
- * @param {Object} options Options object
1435
- * @param {Boolean} [options.binary=false] Specifies whether `data` is binary
1436
- * or text
1437
- * @param {Boolean} [options.compress=false] Specifies whether or not to
1438
- * compress `data`
1439
- * @param {Boolean} [options.fin=false] Specifies whether the fragment is the
1440
- * last one
1441
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1442
- * `data`
1443
- * @param {Function} [cb] Callback
1444
- * @public
1445
- */
1446
1039
  send(data, options, cb) {
1447
1040
  const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
1448
1041
  let opcode = options.binary ? 2 : 1;
@@ -1496,29 +1089,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1496
1089
  ]);
1497
1090
  else this.dispatch(data, this._compress, opts, cb);
1498
1091
  }
1499
- /**
1500
- * Gets the contents of a blob as binary data.
1501
- *
1502
- * @param {Blob} blob The blob
1503
- * @param {Boolean} [compress=false] Specifies whether or not to compress
1504
- * the data
1505
- * @param {Object} options Options object
1506
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1507
- * FIN bit
1508
- * @param {Function} [options.generateMask] The function used to generate the
1509
- * masking key
1510
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1511
- * `data`
1512
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1513
- * key
1514
- * @param {Number} options.opcode The opcode
1515
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1516
- * modified
1517
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1518
- * RSV1 bit
1519
- * @param {Function} [cb] Callback
1520
- * @private
1521
- */
1522
1092
  getBlobData(blob, compress, options, cb) {
1523
1093
  this._bufferedBytes += options[kByteLength];
1524
1094
  this._state = GET_BLOB_DATA;
@@ -1539,29 +1109,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1539
1109
  process.nextTick(onError, this, err, cb);
1540
1110
  });
1541
1111
  }
1542
- /**
1543
- * Dispatches a message.
1544
- *
1545
- * @param {(Buffer|String)} data The message to send
1546
- * @param {Boolean} [compress=false] Specifies whether or not to compress
1547
- * `data`
1548
- * @param {Object} options Options object
1549
- * @param {Boolean} [options.fin=false] Specifies whether or not to set the
1550
- * FIN bit
1551
- * @param {Function} [options.generateMask] The function used to generate the
1552
- * masking key
1553
- * @param {Boolean} [options.mask=false] Specifies whether or not to mask
1554
- * `data`
1555
- * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
1556
- * key
1557
- * @param {Number} options.opcode The opcode
1558
- * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
1559
- * modified
1560
- * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
1561
- * RSV1 bit
1562
- * @param {Function} [cb] Callback
1563
- * @private
1564
- */
1565
1112
  dispatch(data, compress, options, cb) {
1566
1113
  if (!compress) {
1567
1114
  this.sendFrame(Sender.frame(data, options), cb);
@@ -1582,11 +1129,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1582
1129
  this.dequeue();
1583
1130
  });
1584
1131
  }
1585
- /**
1586
- * Executes queued send operations.
1587
- *
1588
- * @private
1589
- */
1590
1132
  dequeue() {
1591
1133
  while (this._state === DEFAULT && this._queue.length) {
1592
1134
  const params = this._queue.shift();
@@ -1594,23 +1136,10 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1594
1136
  Reflect.apply(params[0], this, params.slice(1));
1595
1137
  }
1596
1138
  }
1597
- /**
1598
- * Enqueues a send operation.
1599
- *
1600
- * @param {Array} params Send operation parameters.
1601
- * @private
1602
- */
1603
1139
  enqueue(params) {
1604
1140
  this._bufferedBytes += params[3][kByteLength];
1605
1141
  this._queue.push(params);
1606
1142
  }
1607
- /**
1608
- * Sends a frame.
1609
- *
1610
- * @param {(Buffer | String)[]} list The frame to send
1611
- * @param {Function} [cb] Callback
1612
- * @private
1613
- */
1614
1143
  sendFrame(list, cb) {
1615
1144
  if (list.length === 2) {
1616
1145
  this._socket.cork();
@@ -1620,15 +1149,6 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1620
1149
  } else this._socket.write(list[0], cb);
1621
1150
  }
1622
1151
  };
1623
- module.exports = Sender;
1624
- /**
1625
- * Calls queued callbacks with an error.
1626
- *
1627
- * @param {Sender} sender The `Sender` instance
1628
- * @param {Error} err The error to call the callbacks with
1629
- * @param {Function} [cb] The first callback
1630
- * @private
1631
- */
1632
1152
  function callCallbacks(sender, err, cb) {
1633
1153
  if (typeof cb === "function") cb(err);
1634
1154
  for (let i = 0; i < sender._queue.length; i++) {
@@ -1637,22 +1157,11 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1637
1157
  if (typeof callback === "function") callback(err);
1638
1158
  }
1639
1159
  }
1640
- /**
1641
- * Handles a `Sender` error.
1642
- *
1643
- * @param {Sender} sender The `Sender` instance
1644
- * @param {Error} err The error
1645
- * @param {Function} [cb] The first pending callback
1646
- * @private
1647
- */
1648
1160
  function onError(sender, err, cb) {
1649
1161
  callCallbacks(sender, err, cb);
1650
1162
  sender.onerror(err);
1651
1163
  }
1652
1164
  }));
1653
-
1654
- //#endregion
1655
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/event-target.js
1656
1165
  var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1657
1166
  const { kForOnEventAttribute, kListener } = require_constants();
1658
1167
  const kCode = Symbol("kCode");
@@ -1663,75 +1172,33 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1663
1172
  const kTarget = Symbol("kTarget");
1664
1173
  const kType = Symbol("kType");
1665
1174
  const kWasClean = Symbol("kWasClean");
1666
- /**
1667
- * Class representing an event.
1668
- */
1669
1175
  var Event = class {
1670
- /**
1671
- * Create a new `Event`.
1672
- *
1673
- * @param {String} type The name of the event
1674
- * @throws {TypeError} If the `type` argument is not specified
1675
- */
1676
1176
  constructor(type) {
1677
1177
  this[kTarget] = null;
1678
1178
  this[kType] = type;
1679
1179
  }
1680
- /**
1681
- * @type {*}
1682
- */
1683
1180
  get target() {
1684
1181
  return this[kTarget];
1685
1182
  }
1686
- /**
1687
- * @type {String}
1688
- */
1689
1183
  get type() {
1690
1184
  return this[kType];
1691
1185
  }
1692
1186
  };
1693
1187
  Object.defineProperty(Event.prototype, "target", { enumerable: true });
1694
1188
  Object.defineProperty(Event.prototype, "type", { enumerable: true });
1695
- /**
1696
- * Class representing a close event.
1697
- *
1698
- * @extends Event
1699
- */
1700
1189
  var CloseEvent = class extends Event {
1701
- /**
1702
- * Create a new `CloseEvent`.
1703
- *
1704
- * @param {String} type The name of the event
1705
- * @param {Object} [options] A dictionary object that allows for setting
1706
- * attributes via object members of the same name
1707
- * @param {Number} [options.code=0] The status code explaining why the
1708
- * connection was closed
1709
- * @param {String} [options.reason=''] A human-readable string explaining why
1710
- * the connection was closed
1711
- * @param {Boolean} [options.wasClean=false] Indicates whether or not the
1712
- * connection was cleanly closed
1713
- */
1714
1190
  constructor(type, options = {}) {
1715
1191
  super(type);
1716
1192
  this[kCode] = options.code === void 0 ? 0 : options.code;
1717
1193
  this[kReason] = options.reason === void 0 ? "" : options.reason;
1718
1194
  this[kWasClean] = options.wasClean === void 0 ? false : options.wasClean;
1719
1195
  }
1720
- /**
1721
- * @type {Number}
1722
- */
1723
1196
  get code() {
1724
1197
  return this[kCode];
1725
1198
  }
1726
- /**
1727
- * @type {String}
1728
- */
1729
1199
  get reason() {
1730
1200
  return this[kReason];
1731
1201
  }
1732
- /**
1733
- * @type {Boolean}
1734
- */
1735
1202
  get wasClean() {
1736
1203
  return this[kWasClean];
1737
1204
  }
@@ -1739,163 +1206,92 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1739
1206
  Object.defineProperty(CloseEvent.prototype, "code", { enumerable: true });
1740
1207
  Object.defineProperty(CloseEvent.prototype, "reason", { enumerable: true });
1741
1208
  Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
1742
- /**
1743
- * Class representing an error event.
1744
- *
1745
- * @extends Event
1746
- */
1747
1209
  var ErrorEvent = class extends Event {
1748
- /**
1749
- * Create a new `ErrorEvent`.
1750
- *
1751
- * @param {String} type The name of the event
1752
- * @param {Object} [options] A dictionary object that allows for setting
1753
- * attributes via object members of the same name
1754
- * @param {*} [options.error=null] The error that generated this event
1755
- * @param {String} [options.message=''] The error message
1756
- */
1757
1210
  constructor(type, options = {}) {
1758
1211
  super(type);
1759
1212
  this[kError] = options.error === void 0 ? null : options.error;
1760
1213
  this[kMessage] = options.message === void 0 ? "" : options.message;
1761
1214
  }
1762
- /**
1763
- * @type {*}
1764
- */
1765
1215
  get error() {
1766
1216
  return this[kError];
1767
1217
  }
1768
- /**
1769
- * @type {String}
1770
- */
1771
1218
  get message() {
1772
1219
  return this[kMessage];
1773
1220
  }
1774
1221
  };
1775
1222
  Object.defineProperty(ErrorEvent.prototype, "error", { enumerable: true });
1776
1223
  Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
1777
- /**
1778
- * Class representing a message event.
1779
- *
1780
- * @extends Event
1781
- */
1782
1224
  var MessageEvent = class extends Event {
1783
- /**
1784
- * Create a new `MessageEvent`.
1785
- *
1786
- * @param {String} type The name of the event
1787
- * @param {Object} [options] A dictionary object that allows for setting
1788
- * attributes via object members of the same name
1789
- * @param {*} [options.data=null] The message content
1790
- */
1791
1225
  constructor(type, options = {}) {
1792
1226
  super(type);
1793
1227
  this[kData] = options.data === void 0 ? null : options.data;
1794
1228
  }
1795
- /**
1796
- * @type {*}
1797
- */
1798
1229
  get data() {
1799
1230
  return this[kData];
1800
1231
  }
1801
1232
  };
1802
1233
  Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
1803
- /**
1804
- * This provides methods for emulating the `EventTarget` interface. It's not
1805
- * meant to be used directly.
1806
- *
1807
- * @mixin
1808
- */
1809
- const EventTarget = {
1810
- addEventListener(type, handler, options = {}) {
1811
- for (const listener of this.listeners(type)) if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) return;
1812
- let wrapper;
1813
- if (type === "message") wrapper = function onMessage(data, isBinary) {
1814
- const event = new MessageEvent("message", { data: isBinary ? data : data.toString() });
1815
- event[kTarget] = this;
1816
- callListener(handler, this, event);
1817
- };
1818
- else if (type === "close") wrapper = function onClose(code, message) {
1819
- const event = new CloseEvent("close", {
1820
- code,
1821
- reason: message.toString(),
1822
- wasClean: this._closeFrameReceived && this._closeFrameSent
1823
- });
1824
- event[kTarget] = this;
1825
- callListener(handler, this, event);
1826
- };
1827
- else if (type === "error") wrapper = function onError(error) {
1828
- const event = new ErrorEvent("error", {
1829
- error,
1830
- message: error.message
1831
- });
1832
- event[kTarget] = this;
1833
- callListener(handler, this, event);
1834
- };
1835
- else if (type === "open") wrapper = function onOpen() {
1836
- const event = new Event("open");
1837
- event[kTarget] = this;
1838
- callListener(handler, this, event);
1839
- };
1840
- else return;
1841
- wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
1842
- wrapper[kListener] = handler;
1843
- if (options.once) this.once(type, wrapper);
1844
- else this.on(type, wrapper);
1845
- },
1846
- removeEventListener(type, handler) {
1847
- for (const listener of this.listeners(type)) if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
1848
- this.removeListener(type, listener);
1849
- break;
1850
- }
1851
- }
1852
- };
1853
1234
  module.exports = {
1854
1235
  CloseEvent,
1855
1236
  ErrorEvent,
1856
1237
  Event,
1857
- EventTarget,
1238
+ EventTarget: {
1239
+ addEventListener(type, handler, options = {}) {
1240
+ for (const listener of this.listeners(type)) if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) return;
1241
+ let wrapper;
1242
+ if (type === "message") wrapper = function onMessage(data, isBinary) {
1243
+ const event = new MessageEvent("message", { data: isBinary ? data : data.toString() });
1244
+ event[kTarget] = this;
1245
+ callListener(handler, this, event);
1246
+ };
1247
+ else if (type === "close") wrapper = function onClose(code, message) {
1248
+ const event = new CloseEvent("close", {
1249
+ code,
1250
+ reason: message.toString(),
1251
+ wasClean: this._closeFrameReceived && this._closeFrameSent
1252
+ });
1253
+ event[kTarget] = this;
1254
+ callListener(handler, this, event);
1255
+ };
1256
+ else if (type === "error") wrapper = function onError(error) {
1257
+ const event = new ErrorEvent("error", {
1258
+ error,
1259
+ message: error.message
1260
+ });
1261
+ event[kTarget] = this;
1262
+ callListener(handler, this, event);
1263
+ };
1264
+ else if (type === "open") wrapper = function onOpen() {
1265
+ const event = new Event("open");
1266
+ event[kTarget] = this;
1267
+ callListener(handler, this, event);
1268
+ };
1269
+ else return;
1270
+ wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
1271
+ wrapper[kListener] = handler;
1272
+ if (options.once) this.once(type, wrapper);
1273
+ else this.on(type, wrapper);
1274
+ },
1275
+ removeEventListener(type, handler) {
1276
+ for (const listener of this.listeners(type)) if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
1277
+ this.removeListener(type, listener);
1278
+ break;
1279
+ }
1280
+ }
1281
+ },
1858
1282
  MessageEvent
1859
1283
  };
1860
- /**
1861
- * Call an event listener
1862
- *
1863
- * @param {(Function|Object)} listener The listener to call
1864
- * @param {*} thisArg The value to use as `this`` when calling the listener
1865
- * @param {Event} event The event to pass to the listener
1866
- * @private
1867
- */
1868
1284
  function callListener(listener, thisArg, event) {
1869
1285
  if (typeof listener === "object" && listener.handleEvent) listener.handleEvent.call(listener, event);
1870
1286
  else listener.call(thisArg, event);
1871
1287
  }
1872
1288
  }));
1873
-
1874
- //#endregion
1875
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/extension.js
1876
1289
  var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1877
1290
  const { tokenChars } = require_validation();
1878
- /**
1879
- * Adds an offer to the map of extension offers or a parameter to the map of
1880
- * parameters.
1881
- *
1882
- * @param {Object} dest The map of extension offers or parameters
1883
- * @param {String} name The extension or parameter name
1884
- * @param {(Object|Boolean|String)} elem The extension parameters or the
1885
- * parameter value
1886
- * @private
1887
- */
1888
1291
  function push(dest, name, elem) {
1889
1292
  if (dest[name] === void 0) dest[name] = [elem];
1890
1293
  else dest[name].push(elem);
1891
1294
  }
1892
- /**
1893
- * Parses the `Sec-WebSocket-Extensions` header into an object.
1894
- *
1895
- * @param {String} header The field value of the header
1896
- * @return {Object} The parsed object
1897
- * @public
1898
- */
1899
1295
  function parse(header) {
1900
1296
  const offers = Object.create(null);
1901
1297
  let params = Object.create(null);
@@ -1989,13 +1385,6 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1989
1385
  }
1990
1386
  return offers;
1991
1387
  }
1992
- /**
1993
- * Builds the `Sec-WebSocket-Extensions` header field value.
1994
- *
1995
- * @param {Object} extensions The map of extensions and parameters to format
1996
- * @return {String} A string representing the given object
1997
- * @public
1998
- */
1999
1388
  function format(extensions) {
2000
1389
  return Object.keys(extensions).map((extension) => {
2001
1390
  let configurations = extensions[extension];
@@ -2014,9 +1403,6 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2014
1403
  parse
2015
1404
  };
2016
1405
  }));
2017
-
2018
- //#endregion
2019
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/websocket.js
2020
1406
  var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2021
1407
  const EventEmitter$1 = __require("events");
2022
1408
  const https = __require("https");
@@ -2043,19 +1429,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2043
1429
  "CLOSED"
2044
1430
  ];
2045
1431
  const subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
2046
- /**
2047
- * Class representing a WebSocket.
2048
- *
2049
- * @extends EventEmitter
2050
- */
2051
1432
  var WebSocket = class WebSocket extends EventEmitter$1 {
2052
- /**
2053
- * Create a new `WebSocket`.
2054
- *
2055
- * @param {(String|URL)} address The URL to which to connect
2056
- * @param {(String|String[])} [protocols] The subprotocols
2057
- * @param {Object} [options] Connection options
2058
- */
2059
1433
  constructor(address, protocols, options) {
2060
1434
  super();
2061
1435
  this._binaryType = BINARY_TYPES[0];
@@ -2088,12 +1462,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2088
1462
  this._isServer = true;
2089
1463
  }
2090
1464
  }
2091
- /**
2092
- * For historical reasons, the custom "nodebuffer" type is used by the default
2093
- * instead of "blob".
2094
- *
2095
- * @type {String}
2096
- */
2097
1465
  get binaryType() {
2098
1466
  return this._binaryType;
2099
1467
  }
@@ -2102,87 +1470,37 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2102
1470
  this._binaryType = type;
2103
1471
  if (this._receiver) this._receiver._binaryType = type;
2104
1472
  }
2105
- /**
2106
- * @type {Number}
2107
- */
2108
1473
  get bufferedAmount() {
2109
1474
  if (!this._socket) return this._bufferedAmount;
2110
1475
  return this._socket._writableState.length + this._sender._bufferedBytes;
2111
1476
  }
2112
- /**
2113
- * @type {String}
2114
- */
2115
1477
  get extensions() {
2116
1478
  return Object.keys(this._extensions).join();
2117
1479
  }
2118
- /**
2119
- * @type {Boolean}
2120
- */
2121
1480
  get isPaused() {
2122
1481
  return this._paused;
2123
1482
  }
2124
- /**
2125
- * @type {Function}
2126
- */
2127
- /* istanbul ignore next */
2128
1483
  get onclose() {
2129
1484
  return null;
2130
1485
  }
2131
- /**
2132
- * @type {Function}
2133
- */
2134
- /* istanbul ignore next */
2135
1486
  get onerror() {
2136
1487
  return null;
2137
1488
  }
2138
- /**
2139
- * @type {Function}
2140
- */
2141
- /* istanbul ignore next */
2142
1489
  get onopen() {
2143
1490
  return null;
2144
1491
  }
2145
- /**
2146
- * @type {Function}
2147
- */
2148
- /* istanbul ignore next */
2149
1492
  get onmessage() {
2150
1493
  return null;
2151
1494
  }
2152
- /**
2153
- * @type {String}
2154
- */
2155
1495
  get protocol() {
2156
1496
  return this._protocol;
2157
1497
  }
2158
- /**
2159
- * @type {Number}
2160
- */
2161
1498
  get readyState() {
2162
1499
  return this._readyState;
2163
1500
  }
2164
- /**
2165
- * @type {String}
2166
- */
2167
1501
  get url() {
2168
1502
  return this._url;
2169
1503
  }
2170
- /**
2171
- * Set up the socket and the internal resources.
2172
- *
2173
- * @param {Duplex} socket The network socket between the server and client
2174
- * @param {Buffer} head The first packet of the upgraded stream
2175
- * @param {Object} options Options object
2176
- * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
2177
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
2178
- * multiple times in the same tick
2179
- * @param {Function} [options.generateMask] The function used to generate the
2180
- * masking key
2181
- * @param {Number} [options.maxPayload=0] The maximum allowed message size
2182
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
2183
- * not to skip UTF-8 validation for text and close messages
2184
- * @private
2185
- */
2186
1504
  setSocket(socket, head, options) {
2187
1505
  const receiver = new Receiver({
2188
1506
  allowSynchronousEvents: options.allowSynchronousEvents,
@@ -2216,11 +1534,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2216
1534
  this._readyState = WebSocket.OPEN;
2217
1535
  this.emit("open");
2218
1536
  }
2219
- /**
2220
- * Emit the `'close'` event.
2221
- *
2222
- * @private
2223
- */
2224
1537
  emitClose() {
2225
1538
  if (!this._socket) {
2226
1539
  this._readyState = WebSocket.CLOSED;
@@ -2232,26 +1545,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2232
1545
  this._readyState = WebSocket.CLOSED;
2233
1546
  this.emit("close", this._closeCode, this._closeMessage);
2234
1547
  }
2235
- /**
2236
- * Start a closing handshake.
2237
- *
2238
- * +----------+ +-----------+ +----------+
2239
- * - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
2240
- * | +----------+ +-----------+ +----------+ |
2241
- * +----------+ +-----------+ |
2242
- * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
2243
- * +----------+ +-----------+ |
2244
- * | | | +---+ |
2245
- * +------------------------+-->|fin| - - - -
2246
- * | +---+ | +---+
2247
- * - - - - -|fin|<---------------------+
2248
- * +---+
2249
- *
2250
- * @param {Number} [code] Status code explaining why the connection is closing
2251
- * @param {(String|Buffer)} [data] The reason why the connection is
2252
- * closing
2253
- * @public
2254
- */
2255
1548
  close(code, data) {
2256
1549
  if (this.readyState === WebSocket.CLOSED) return;
2257
1550
  if (this.readyState === WebSocket.CONNECTING) {
@@ -2270,24 +1563,11 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2270
1563
  });
2271
1564
  setCloseTimer(this);
2272
1565
  }
2273
- /**
2274
- * Pause the socket.
2275
- *
2276
- * @public
2277
- */
2278
1566
  pause() {
2279
1567
  if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;
2280
1568
  this._paused = true;
2281
1569
  this._socket.pause();
2282
1570
  }
2283
- /**
2284
- * Send a ping.
2285
- *
2286
- * @param {*} [data] The data to send
2287
- * @param {Boolean} [mask] Indicates whether or not to mask `data`
2288
- * @param {Function} [cb] Callback which is executed when the ping is sent
2289
- * @public
2290
- */
2291
1571
  ping(data, mask, cb) {
2292
1572
  if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2293
1573
  if (typeof data === "function") {
@@ -2305,14 +1585,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2305
1585
  if (mask === void 0) mask = !this._isServer;
2306
1586
  this._sender.ping(data || EMPTY_BUFFER, mask, cb);
2307
1587
  }
2308
- /**
2309
- * Send a pong.
2310
- *
2311
- * @param {*} [data] The data to send
2312
- * @param {Boolean} [mask] Indicates whether or not to mask `data`
2313
- * @param {Function} [cb] Callback which is executed when the pong is sent
2314
- * @public
2315
- */
2316
1588
  pong(data, mask, cb) {
2317
1589
  if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2318
1590
  if (typeof data === "function") {
@@ -2330,31 +1602,11 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2330
1602
  if (mask === void 0) mask = !this._isServer;
2331
1603
  this._sender.pong(data || EMPTY_BUFFER, mask, cb);
2332
1604
  }
2333
- /**
2334
- * Resume the socket.
2335
- *
2336
- * @public
2337
- */
2338
1605
  resume() {
2339
1606
  if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;
2340
1607
  this._paused = false;
2341
1608
  if (!this._receiver._writableState.needDrain) this._socket.resume();
2342
1609
  }
2343
- /**
2344
- * Send a data message.
2345
- *
2346
- * @param {*} data The message to send
2347
- * @param {Object} [options] Options object
2348
- * @param {Boolean} [options.binary] Specifies whether `data` is binary or
2349
- * text
2350
- * @param {Boolean} [options.compress] Specifies whether or not to compress
2351
- * `data`
2352
- * @param {Boolean} [options.fin=true] Specifies whether the fragment is the
2353
- * last one
2354
- * @param {Boolean} [options.mask] Specifies whether or not to mask `data`
2355
- * @param {Function} [cb] Callback which is executed when data is written out
2356
- * @public
2357
- */
2358
1610
  send(data, options, cb) {
2359
1611
  if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
2360
1612
  if (typeof options === "function") {
@@ -2376,11 +1628,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2376
1628
  if (!this._extensions[PerMessageDeflate.extensionName]) opts.compress = false;
2377
1629
  this._sender.send(data || EMPTY_BUFFER, opts, cb);
2378
1630
  }
2379
- /**
2380
- * Forcibly close the connection.
2381
- *
2382
- * @public
2383
- */
2384
1631
  terminate() {
2385
1632
  if (this.readyState === WebSocket.CLOSED) return;
2386
1633
  if (this.readyState === WebSocket.CONNECTING) {
@@ -2393,66 +1640,34 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2393
1640
  }
2394
1641
  }
2395
1642
  };
2396
- /**
2397
- * @constant {Number} CONNECTING
2398
- * @memberof WebSocket
2399
- */
2400
1643
  Object.defineProperty(WebSocket, "CONNECTING", {
2401
1644
  enumerable: true,
2402
1645
  value: readyStates.indexOf("CONNECTING")
2403
1646
  });
2404
- /**
2405
- * @constant {Number} CONNECTING
2406
- * @memberof WebSocket.prototype
2407
- */
2408
1647
  Object.defineProperty(WebSocket.prototype, "CONNECTING", {
2409
1648
  enumerable: true,
2410
1649
  value: readyStates.indexOf("CONNECTING")
2411
1650
  });
2412
- /**
2413
- * @constant {Number} OPEN
2414
- * @memberof WebSocket
2415
- */
2416
1651
  Object.defineProperty(WebSocket, "OPEN", {
2417
1652
  enumerable: true,
2418
1653
  value: readyStates.indexOf("OPEN")
2419
1654
  });
2420
- /**
2421
- * @constant {Number} OPEN
2422
- * @memberof WebSocket.prototype
2423
- */
2424
1655
  Object.defineProperty(WebSocket.prototype, "OPEN", {
2425
1656
  enumerable: true,
2426
1657
  value: readyStates.indexOf("OPEN")
2427
1658
  });
2428
- /**
2429
- * @constant {Number} CLOSING
2430
- * @memberof WebSocket
2431
- */
2432
1659
  Object.defineProperty(WebSocket, "CLOSING", {
2433
1660
  enumerable: true,
2434
1661
  value: readyStates.indexOf("CLOSING")
2435
1662
  });
2436
- /**
2437
- * @constant {Number} CLOSING
2438
- * @memberof WebSocket.prototype
2439
- */
2440
1663
  Object.defineProperty(WebSocket.prototype, "CLOSING", {
2441
1664
  enumerable: true,
2442
1665
  value: readyStates.indexOf("CLOSING")
2443
1666
  });
2444
- /**
2445
- * @constant {Number} CLOSED
2446
- * @memberof WebSocket
2447
- */
2448
1667
  Object.defineProperty(WebSocket, "CLOSED", {
2449
1668
  enumerable: true,
2450
1669
  value: readyStates.indexOf("CLOSED")
2451
1670
  });
2452
- /**
2453
- * @constant {Number} CLOSED
2454
- * @memberof WebSocket.prototype
2455
- */
2456
1671
  Object.defineProperty(WebSocket.prototype, "CLOSED", {
2457
1672
  enumerable: true,
2458
1673
  value: readyStates.indexOf("CLOSED")
@@ -2493,42 +1708,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2493
1708
  WebSocket.prototype.addEventListener = addEventListener;
2494
1709
  WebSocket.prototype.removeEventListener = removeEventListener;
2495
1710
  module.exports = WebSocket;
2496
- /**
2497
- * Initialize a WebSocket client.
2498
- *
2499
- * @param {WebSocket} websocket The client to initialize
2500
- * @param {(String|URL)} address The URL to which to connect
2501
- * @param {Array} protocols The subprotocols
2502
- * @param {Object} [options] Connection options
2503
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether any
2504
- * of the `'message'`, `'ping'`, and `'pong'` events can be emitted multiple
2505
- * times in the same tick
2506
- * @param {Boolean} [options.autoPong=true] Specifies whether or not to
2507
- * automatically send a pong in response to a ping
2508
- * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to wait
2509
- * for the closing handshake to finish after `websocket.close()` is called
2510
- * @param {Function} [options.finishRequest] A function which can be used to
2511
- * customize the headers of each http request before it is sent
2512
- * @param {Boolean} [options.followRedirects=false] Whether or not to follow
2513
- * redirects
2514
- * @param {Function} [options.generateMask] The function used to generate the
2515
- * masking key
2516
- * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
2517
- * handshake request
2518
- * @param {Number} [options.maxPayload=104857600] The maximum allowed message
2519
- * size
2520
- * @param {Number} [options.maxRedirects=10] The maximum number of redirects
2521
- * allowed
2522
- * @param {String} [options.origin] Value of the `Origin` or
2523
- * `Sec-WebSocket-Origin` header
2524
- * @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable
2525
- * permessage-deflate
2526
- * @param {Number} [options.protocolVersion=13] Value of the
2527
- * `Sec-WebSocket-Version` header
2528
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
2529
- * not to skip UTF-8 validation for text and close messages
2530
- * @private
2531
- */
2532
1711
  function initAsClient(websocket, address, protocols, options) {
2533
1712
  const opts = {
2534
1713
  allowSynchronousEvents: true,
@@ -2557,7 +1736,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2557
1736
  if (address instanceof URL) parsedUrl = address;
2558
1737
  else try {
2559
1738
  parsedUrl = new URL(address);
2560
- } catch (e) {
1739
+ } catch {
2561
1740
  throw new SyntaxError(`Invalid URL: ${address}`);
2562
1741
  }
2563
1742
  if (parsedUrl.protocol === "http:") parsedUrl.protocol = "ws:";
@@ -2596,7 +1775,11 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2596
1775
  opts.path = parsedUrl.pathname + parsedUrl.search;
2597
1776
  opts.timeout = opts.handshakeTimeout;
2598
1777
  if (opts.perMessageDeflate) {
2599
- perMessageDeflate = new PerMessageDeflate(opts.perMessageDeflate !== true ? opts.perMessageDeflate : {}, false, opts.maxPayload);
1778
+ perMessageDeflate = new PerMessageDeflate({
1779
+ ...opts.perMessageDeflate,
1780
+ isServer: false,
1781
+ maxPayload: opts.maxPayload
1782
+ });
2600
1783
  opts.headers["Sec-WebSocket-Extensions"] = format({ [PerMessageDeflate.extensionName]: perMessageDeflate.offer() });
2601
1784
  }
2602
1785
  if (protocols.length) {
@@ -2625,7 +1808,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2625
1808
  ...options,
2626
1809
  headers: {}
2627
1810
  };
2628
- if (headers) for (const [key$1, value] of Object.entries(headers)) options.headers[key$1.toLowerCase()] = value;
1811
+ if (headers) for (const [key, value] of Object.entries(headers)) options.headers[key.toLowerCase()] = value;
2629
1812
  } else if (websocket.listenerCount("redirect") === 0) {
2630
1813
  const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
2631
1814
  if (!isSameHost || websocket._originalSecure && !isSecure) {
@@ -2727,51 +1910,21 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2727
1910
  if (opts.finishRequest) opts.finishRequest(req, websocket);
2728
1911
  else req.end();
2729
1912
  }
2730
- /**
2731
- * Emit the `'error'` and `'close'` events.
2732
- *
2733
- * @param {WebSocket} websocket The WebSocket instance
2734
- * @param {Error} The error to emit
2735
- * @private
2736
- */
2737
1913
  function emitErrorAndClose(websocket, err) {
2738
1914
  websocket._readyState = WebSocket.CLOSING;
2739
1915
  websocket._errorEmitted = true;
2740
1916
  websocket.emit("error", err);
2741
1917
  websocket.emitClose();
2742
1918
  }
2743
- /**
2744
- * Create a `net.Socket` and initiate a connection.
2745
- *
2746
- * @param {Object} options Connection options
2747
- * @return {net.Socket} The newly created socket used to start the connection
2748
- * @private
2749
- */
2750
1919
  function netConnect(options) {
2751
1920
  options.path = options.socketPath;
2752
1921
  return net.connect(options);
2753
1922
  }
2754
- /**
2755
- * Create a `tls.TLSSocket` and initiate a connection.
2756
- *
2757
- * @param {Object} options Connection options
2758
- * @return {tls.TLSSocket} The newly created socket used to start the connection
2759
- * @private
2760
- */
2761
1923
  function tlsConnect(options) {
2762
1924
  options.path = void 0;
2763
1925
  if (!options.servername && options.servername !== "") options.servername = net.isIP(options.host) ? "" : options.host;
2764
1926
  return tls.connect(options);
2765
1927
  }
2766
- /**
2767
- * Abort the handshake and emit an error.
2768
- *
2769
- * @param {WebSocket} websocket The WebSocket instance
2770
- * @param {(http.ClientRequest|net.Socket|tls.Socket)} stream The request to
2771
- * abort or the socket to destroy
2772
- * @param {String} message The error message
2773
- * @private
2774
- */
2775
1928
  function abortHandshake(websocket, stream, message) {
2776
1929
  websocket._readyState = WebSocket.CLOSING;
2777
1930
  const err = new Error(message);
@@ -2787,15 +1940,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2787
1940
  stream.once("close", websocket.emitClose.bind(websocket));
2788
1941
  }
2789
1942
  }
2790
- /**
2791
- * Handle cases where the `ping()`, `pong()`, or `send()` methods are called
2792
- * when the `readyState` attribute is `CLOSING` or `CLOSED`.
2793
- *
2794
- * @param {WebSocket} websocket The WebSocket instance
2795
- * @param {*} [data] The data to send
2796
- * @param {Function} [cb] Callback
2797
- * @private
2798
- */
2799
1943
  function sendAfterClose(websocket, data, cb) {
2800
1944
  if (data) {
2801
1945
  const length = isBlob(data) ? data.size : toBuffer(data).length;
@@ -2807,13 +1951,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2807
1951
  process.nextTick(cb, err);
2808
1952
  }
2809
1953
  }
2810
- /**
2811
- * The listener of the `Receiver` `'conclude'` event.
2812
- *
2813
- * @param {Number} code The status code
2814
- * @param {Buffer} reason The reason for closing
2815
- * @private
2816
- */
2817
1954
  function receiverOnConclude(code, reason) {
2818
1955
  const websocket = this[kWebSocket];
2819
1956
  websocket._closeFrameReceived = true;
@@ -2825,21 +1962,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2825
1962
  if (code === 1005) websocket.close();
2826
1963
  else websocket.close(code, reason);
2827
1964
  }
2828
- /**
2829
- * The listener of the `Receiver` `'drain'` event.
2830
- *
2831
- * @private
2832
- */
2833
1965
  function receiverOnDrain() {
2834
1966
  const websocket = this[kWebSocket];
2835
1967
  if (!websocket.isPaused) websocket._socket.resume();
2836
1968
  }
2837
- /**
2838
- * The listener of the `Receiver` `'error'` event.
2839
- *
2840
- * @param {(RangeError|Error)} err The emitted error
2841
- * @private
2842
- */
2843
1969
  function receiverOnError(err) {
2844
1970
  const websocket = this[kWebSocket];
2845
1971
  if (websocket._socket[kWebSocket] !== void 0) {
@@ -2852,59 +1978,23 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2852
1978
  websocket.emit("error", err);
2853
1979
  }
2854
1980
  }
2855
- /**
2856
- * The listener of the `Receiver` `'finish'` event.
2857
- *
2858
- * @private
2859
- */
2860
1981
  function receiverOnFinish() {
2861
1982
  this[kWebSocket].emitClose();
2862
1983
  }
2863
- /**
2864
- * The listener of the `Receiver` `'message'` event.
2865
- *
2866
- * @param {Buffer|ArrayBuffer|Buffer[])} data The message
2867
- * @param {Boolean} isBinary Specifies whether the message is binary or not
2868
- * @private
2869
- */
2870
1984
  function receiverOnMessage(data, isBinary) {
2871
1985
  this[kWebSocket].emit("message", data, isBinary);
2872
1986
  }
2873
- /**
2874
- * The listener of the `Receiver` `'ping'` event.
2875
- *
2876
- * @param {Buffer} data The data included in the ping frame
2877
- * @private
2878
- */
2879
1987
  function receiverOnPing(data) {
2880
1988
  const websocket = this[kWebSocket];
2881
1989
  if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
2882
1990
  websocket.emit("ping", data);
2883
1991
  }
2884
- /**
2885
- * The listener of the `Receiver` `'pong'` event.
2886
- *
2887
- * @param {Buffer} data The data included in the pong frame
2888
- * @private
2889
- */
2890
1992
  function receiverOnPong(data) {
2891
1993
  this[kWebSocket].emit("pong", data);
2892
1994
  }
2893
- /**
2894
- * Resume a readable stream
2895
- *
2896
- * @param {Readable} stream The readable stream
2897
- * @private
2898
- */
2899
1995
  function resume(stream) {
2900
1996
  stream.resume();
2901
1997
  }
2902
- /**
2903
- * The `Sender` error event handler.
2904
- *
2905
- * @param {Error} The error
2906
- * @private
2907
- */
2908
1998
  function senderOnError(err) {
2909
1999
  const websocket = this[kWebSocket];
2910
2000
  if (websocket.readyState === WebSocket.CLOSED) return;
@@ -2918,20 +2008,9 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2918
2008
  websocket.emit("error", err);
2919
2009
  }
2920
2010
  }
2921
- /**
2922
- * Set a timer to destroy the underlying raw socket of a WebSocket.
2923
- *
2924
- * @param {WebSocket} websocket The WebSocket instance
2925
- * @private
2926
- */
2927
2011
  function setCloseTimer(websocket) {
2928
2012
  websocket._closeTimer = setTimeout(websocket._socket.destroy.bind(websocket._socket), websocket._closeTimeout);
2929
2013
  }
2930
- /**
2931
- * The listener of the socket `'close'` event.
2932
- *
2933
- * @private
2934
- */
2935
2014
  function socketOnClose() {
2936
2015
  const websocket = this[kWebSocket];
2937
2016
  this.removeListener("close", socketOnClose);
@@ -2951,31 +2030,15 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2951
2030
  websocket._receiver.on("finish", receiverOnFinish);
2952
2031
  }
2953
2032
  }
2954
- /**
2955
- * The listener of the socket `'data'` event.
2956
- *
2957
- * @param {Buffer} chunk A chunk of data
2958
- * @private
2959
- */
2960
2033
  function socketOnData(chunk) {
2961
2034
  if (!this[kWebSocket]._receiver.write(chunk)) this.pause();
2962
2035
  }
2963
- /**
2964
- * The listener of the socket `'end'` event.
2965
- *
2966
- * @private
2967
- */
2968
2036
  function socketOnEnd() {
2969
2037
  const websocket = this[kWebSocket];
2970
2038
  websocket._readyState = WebSocket.CLOSING;
2971
2039
  websocket._receiver.end();
2972
2040
  this.end();
2973
2041
  }
2974
- /**
2975
- * The listener of the socket `'error'` event.
2976
- *
2977
- * @private
2978
- */
2979
2042
  function socketOnError() {
2980
2043
  const websocket = this[kWebSocket];
2981
2044
  this.removeListener("error", socketOnError);
@@ -2986,48 +2049,20 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2986
2049
  }
2987
2050
  }
2988
2051
  }));
2989
-
2990
- //#endregion
2991
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/stream.js
2992
2052
  var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2993
2053
  require_websocket();
2994
2054
  const { Duplex: Duplex$1 } = __require("stream");
2995
- /**
2996
- * Emits the `'close'` event on a stream.
2997
- *
2998
- * @param {Duplex} stream The stream.
2999
- * @private
3000
- */
3001
2055
  function emitClose(stream) {
3002
2056
  stream.emit("close");
3003
2057
  }
3004
- /**
3005
- * The listener of the `'end'` event.
3006
- *
3007
- * @private
3008
- */
3009
2058
  function duplexOnEnd() {
3010
2059
  if (!this.destroyed && this._writableState.finished) this.destroy();
3011
2060
  }
3012
- /**
3013
- * The listener of the `'error'` event.
3014
- *
3015
- * @param {Error} err The error
3016
- * @private
3017
- */
3018
2061
  function duplexOnError(err) {
3019
2062
  this.removeListener("error", duplexOnError);
3020
2063
  this.destroy();
3021
2064
  if (this.listenerCount("error") === 0) this.emit("error", err);
3022
2065
  }
3023
- /**
3024
- * Wraps a `WebSocket` in a duplex stream.
3025
- *
3026
- * @param {WebSocket} ws The `WebSocket` to wrap
3027
- * @param {Object} [options] The options for the `Duplex` constructor
3028
- * @return {Duplex} The duplex stream
3029
- * @public
3030
- */
3031
2066
  function createWebSocketStream(ws, options) {
3032
2067
  let terminateOnDestroy = true;
3033
2068
  const duplex = new Duplex$1({
@@ -3057,9 +2092,9 @@ var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3057
2092
  return;
3058
2093
  }
3059
2094
  let called = false;
3060
- ws.once("error", function error(err$1) {
2095
+ ws.once("error", function error(err) {
3061
2096
  called = true;
3062
- callback(err$1);
2097
+ callback(err);
3063
2098
  });
3064
2099
  ws.once("close", function close() {
3065
2100
  if (!called) callback(err);
@@ -3103,18 +2138,8 @@ var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3103
2138
  }
3104
2139
  module.exports = createWebSocketStream;
3105
2140
  }));
3106
-
3107
- //#endregion
3108
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/subprotocol.js
3109
2141
  var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3110
2142
  const { tokenChars } = require_validation();
3111
- /**
3112
- * Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.
3113
- *
3114
- * @param {String} header The field value of the header
3115
- * @return {Set} The subprotocol names
3116
- * @public
3117
- */
3118
2143
  function parse(header) {
3119
2144
  const protocols = /* @__PURE__ */ new Set();
3120
2145
  let start = -1;
@@ -3129,9 +2154,9 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3129
2154
  } else if (code === 44) {
3130
2155
  if (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);
3131
2156
  if (end === -1) end = i;
3132
- const protocol$1 = header.slice(start, end);
3133
- if (protocols.has(protocol$1)) throw new SyntaxError(`The "${protocol$1}" subprotocol is duplicated`);
3134
- protocols.add(protocol$1);
2157
+ const protocol = header.slice(start, end);
2158
+ if (protocols.has(protocol)) throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
2159
+ protocols.add(protocol);
3135
2160
  start = end = -1;
3136
2161
  } else throw new SyntaxError(`Unexpected character at index ${i}`);
3137
2162
  }
@@ -3143,9 +2168,6 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3143
2168
  }
3144
2169
  module.exports = { parse };
3145
2170
  }));
3146
-
3147
- //#endregion
3148
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/websocket-server.js
3149
2171
  var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3150
2172
  const EventEmitter = __require("events");
3151
2173
  const http = __require("http");
@@ -3160,46 +2182,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3160
2182
  const RUNNING = 0;
3161
2183
  const CLOSING = 1;
3162
2184
  const CLOSED = 2;
3163
- /**
3164
- * Class representing a WebSocket server.
3165
- *
3166
- * @extends EventEmitter
3167
- */
3168
2185
  var WebSocketServer = class extends EventEmitter {
3169
- /**
3170
- * Create a `WebSocketServer` instance.
3171
- *
3172
- * @param {Object} options Configuration options
3173
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
3174
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
3175
- * multiple times in the same tick
3176
- * @param {Boolean} [options.autoPong=true] Specifies whether or not to
3177
- * automatically send a pong in response to a ping
3178
- * @param {Number} [options.backlog=511] The maximum length of the queue of
3179
- * pending connections
3180
- * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
3181
- * track clients
3182
- * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
3183
- * wait for the closing handshake to finish after `websocket.close()` is
3184
- * called
3185
- * @param {Function} [options.handleProtocols] A hook to handle protocols
3186
- * @param {String} [options.host] The hostname where to bind the server
3187
- * @param {Number} [options.maxPayload=104857600] The maximum allowed message
3188
- * size
3189
- * @param {Boolean} [options.noServer=false] Enable no server mode
3190
- * @param {String} [options.path] Accept only connections matching this path
3191
- * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
3192
- * permessage-deflate
3193
- * @param {Number} [options.port] The port where to bind the server
3194
- * @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
3195
- * server to use
3196
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
3197
- * not to skip UTF-8 validation for text and close messages
3198
- * @param {Function} [options.verifyClient] A hook to reject connections
3199
- * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
3200
- * class to use. It must be the `WebSocket` class or class that extends it
3201
- * @param {Function} [callback] A listener for the `listening` event
3202
- */
3203
2186
  constructor(options, callback) {
3204
2187
  super();
3205
2188
  options = {
@@ -3251,27 +2234,11 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3251
2234
  this.options = options;
3252
2235
  this._state = RUNNING;
3253
2236
  }
3254
- /**
3255
- * Returns the bound address, the address family name, and port of the server
3256
- * as reported by the operating system if listening on an IP socket.
3257
- * If the server is listening on a pipe or UNIX domain socket, the name is
3258
- * returned as a string.
3259
- *
3260
- * @return {(Object|String|null)} The address of the server
3261
- * @public
3262
- */
3263
2237
  address() {
3264
2238
  if (this.options.noServer) throw new Error("The server is operating in \"noServer\" mode");
3265
2239
  if (!this._server) return null;
3266
2240
  return this._server.address();
3267
2241
  }
3268
- /**
3269
- * Stop the server from accepting new connections and emit the `'close'` event
3270
- * when all existing connections are closed.
3271
- *
3272
- * @param {Function} [cb] A one-time listener for the `'close'` event
3273
- * @public
3274
- */
3275
2242
  close(cb) {
3276
2243
  if (this._state === CLOSED) {
3277
2244
  if (cb) this.once("close", () => {
@@ -3300,13 +2267,6 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3300
2267
  });
3301
2268
  }
3302
2269
  }
3303
- /**
3304
- * See if a given request should be handled by this server instance.
3305
- *
3306
- * @param {http.IncomingMessage} req Request object to inspect
3307
- * @return {Boolean} `true` if the request is valid, else `false`
3308
- * @public
3309
- */
3310
2270
  shouldHandle(req) {
3311
2271
  if (this.options.path) {
3312
2272
  const index = req.url.indexOf("?");
@@ -3314,15 +2274,6 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3314
2274
  }
3315
2275
  return true;
3316
2276
  }
3317
- /**
3318
- * Handle a HTTP Upgrade request.
3319
- *
3320
- * @param {http.IncomingMessage} req The request object
3321
- * @param {Duplex} socket The network socket between the server and client
3322
- * @param {Buffer} head The first packet of the upgraded stream
3323
- * @param {Function} cb Callback
3324
- * @public
3325
- */
3326
2277
  handleUpgrade(req, socket, head, cb) {
3327
2278
  socket.on("error", socketOnError);
3328
2279
  const key = req.headers["sec-websocket-key"];
@@ -3359,7 +2310,11 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3359
2310
  const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
3360
2311
  const extensions = {};
3361
2312
  if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
3362
- const perMessageDeflate = new PerMessageDeflate(this.options.perMessageDeflate, true, this.options.maxPayload);
2313
+ const perMessageDeflate = new PerMessageDeflate({
2314
+ ...this.options.perMessageDeflate,
2315
+ isServer: true,
2316
+ maxPayload: this.options.maxPayload
2317
+ });
3363
2318
  try {
3364
2319
  const offers = extension.parse(secWebSocketExtensions);
3365
2320
  if (offers[PerMessageDeflate.extensionName]) {
@@ -3388,19 +2343,6 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3388
2343
  }
3389
2344
  this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
3390
2345
  }
3391
- /**
3392
- * Upgrade the connection to WebSocket.
3393
- *
3394
- * @param {Object} extensions The accepted extensions
3395
- * @param {String} key The value of the `Sec-WebSocket-Key` header
3396
- * @param {Set} protocols The subprotocols
3397
- * @param {http.IncomingMessage} req The request object
3398
- * @param {Duplex} socket The network socket between the server and client
3399
- * @param {Buffer} head The first packet of the upgraded stream
3400
- * @param {Function} cb Callback
3401
- * @throws {Error} If called more than once with the same socket
3402
- * @private
3403
- */
3404
2346
  completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
3405
2347
  if (!socket.readable || !socket.writable) return socket.destroy();
3406
2348
  if (socket[kWebSocket]) throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");
@@ -3444,49 +2386,19 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3444
2386
  }
3445
2387
  };
3446
2388
  module.exports = WebSocketServer;
3447
- /**
3448
- * Add event listeners on an `EventEmitter` using a map of <event, listener>
3449
- * pairs.
3450
- *
3451
- * @param {EventEmitter} server The event emitter
3452
- * @param {Object.<String, Function>} map The listeners to add
3453
- * @return {Function} A function that will remove the added listeners when
3454
- * called
3455
- * @private
3456
- */
3457
2389
  function addListeners(server, map) {
3458
2390
  for (const event of Object.keys(map)) server.on(event, map[event]);
3459
2391
  return function removeListeners() {
3460
2392
  for (const event of Object.keys(map)) server.removeListener(event, map[event]);
3461
2393
  };
3462
2394
  }
3463
- /**
3464
- * Emit a `'close'` event on an `EventEmitter`.
3465
- *
3466
- * @param {EventEmitter} server The event emitter
3467
- * @private
3468
- */
3469
2395
  function emitClose(server) {
3470
2396
  server._state = CLOSED;
3471
2397
  server.emit("close");
3472
2398
  }
3473
- /**
3474
- * Handle socket errors.
3475
- *
3476
- * @private
3477
- */
3478
2399
  function socketOnError() {
3479
2400
  this.destroy();
3480
2401
  }
3481
- /**
3482
- * Close the connection when preconditions are not fulfilled.
3483
- *
3484
- * @param {Duplex} socket The socket of the upgrade request
3485
- * @param {Number} code The HTTP response status code
3486
- * @param {String} [message] The HTTP response body
3487
- * @param {Object} [headers] Additional HTTP response headers
3488
- * @private
3489
- */
3490
2402
  function abortHandshake(socket, code, message, headers) {
3491
2403
  message = message || http.STATUS_CODES[code];
3492
2404
  headers = {
@@ -3498,18 +2410,6 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3498
2410
  socket.once("finish", socket.destroy);
3499
2411
  socket.end(`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message);
3500
2412
  }
3501
- /**
3502
- * Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least
3503
- * one listener for it, otherwise call `abortHandshake()`.
3504
- *
3505
- * @param {WebSocketServer} server The WebSocket server
3506
- * @param {http.IncomingMessage} req The request object
3507
- * @param {Duplex} socket The socket of the upgrade request
3508
- * @param {Number} code The HTTP response status code
3509
- * @param {String} message The HTTP response body
3510
- * @param {Object} [headers] The HTTP response headers
3511
- * @private
3512
- */
3513
2413
  function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
3514
2414
  if (server.listenerCount("wsClientError")) {
3515
2415
  const err = new Error(message);
@@ -3518,14 +2418,12 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
3518
2418
  } else abortHandshake(socket, code, message, headers);
3519
2419
  }
3520
2420
  }));
3521
-
3522
- //#endregion
3523
- //#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/wrapper.mjs
3524
- var import_stream = /* @__PURE__ */ __toESM(require_stream(), 1);
3525
- var import_receiver = /* @__PURE__ */ __toESM(require_receiver(), 1);
3526
- var import_sender = /* @__PURE__ */ __toESM(require_sender(), 1);
2421
+ require_stream();
2422
+ require_extension();
2423
+ require_permessage_deflate();
2424
+ require_receiver();
2425
+ require_sender();
2426
+ require_subprotocol();
3527
2427
  var import_websocket = /* @__PURE__ */ __toESM(require_websocket(), 1);
3528
2428
  var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);
3529
-
3530
- //#endregion
3531
- export { import_websocket_server as n, import_websocket as t };
2429
+ export { import_websocket_server as n, import_websocket as t };