@vitejs/devtools-rpc 0.0.0-alpha.2 → 0.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-C3McYp9c.d.mts +13 -0
- package/dist/index.d.mts +15 -0
- package/dist/{index.js → index.mjs} +6 -2
- package/dist/{index-BOWJO778.d.ts → presets/index.d.mts} +1 -1
- package/dist/presets/ws/client.d.mts +3 -0
- package/dist/presets/ws/{client.js → client.mjs} +2 -3
- package/dist/presets/ws/server.d.mts +503 -0
- package/dist/presets/ws/{server.js → server.mjs} +284 -294
- package/package.json +11 -11
- package/dist/index.d.ts +0 -15
- package/dist/presets/index.d.ts +0 -2
- package/dist/presets/index.js +0 -3
- package/dist/presets/ws/client.d.ts +0 -17
- package/dist/presets/ws/server.d.ts +0 -13
- /package/dist/{presets-CXNlz3L-.js → presets/index.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineRpcServerPreset } from "
|
|
1
|
+
import { defineRpcServerPreset } from "../index.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { parse, stringify } from "structured-clone-es";
|
|
4
4
|
|
|
@@ -9,16 +9,18 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
9
9
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
10
|
var __getProtoOf = Object.getPrototypeOf;
|
|
11
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var
|
|
13
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
-
};
|
|
12
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
15
13
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
+
key = keys[i];
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
18
|
+
__defProp(to, key, {
|
|
19
|
+
get: ((k) => from[k]).bind(null, key),
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
25
|
return to;
|
|
24
26
|
};
|
|
@@ -30,32 +32,32 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
30
32
|
|
|
31
33
|
//#endregion
|
|
32
34
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/constants.js
|
|
33
|
-
var require_constants = /* @__PURE__ */
|
|
34
|
-
const BINARY_TYPES
|
|
35
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
36
|
+
const BINARY_TYPES = [
|
|
35
37
|
"nodebuffer",
|
|
36
38
|
"arraybuffer",
|
|
37
39
|
"fragments"
|
|
38
40
|
];
|
|
39
|
-
const hasBlob
|
|
40
|
-
if (hasBlob
|
|
41
|
+
const hasBlob = typeof Blob !== "undefined";
|
|
42
|
+
if (hasBlob) BINARY_TYPES.push("blob");
|
|
41
43
|
module.exports = {
|
|
42
|
-
BINARY_TYPES
|
|
44
|
+
BINARY_TYPES,
|
|
43
45
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
44
46
|
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
45
|
-
hasBlob
|
|
47
|
+
hasBlob,
|
|
46
48
|
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
|
47
49
|
kListener: Symbol("kListener"),
|
|
48
50
|
kStatusCode: Symbol("status-code"),
|
|
49
51
|
kWebSocket: Symbol("websocket"),
|
|
50
52
|
NOOP: () => {}
|
|
51
53
|
};
|
|
52
|
-
})
|
|
54
|
+
}));
|
|
53
55
|
|
|
54
56
|
//#endregion
|
|
55
57
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/buffer-util.js
|
|
56
|
-
var require_buffer_util = /* @__PURE__ */
|
|
57
|
-
const { EMPTY_BUFFER
|
|
58
|
-
const FastBuffer
|
|
58
|
+
var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
59
|
+
const { EMPTY_BUFFER } = require_constants();
|
|
60
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
59
61
|
/**
|
|
60
62
|
* Merges an array of buffers into a new buffer.
|
|
61
63
|
*
|
|
@@ -64,8 +66,8 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
|
|
|
64
66
|
* @return {Buffer} The resulting buffer
|
|
65
67
|
* @public
|
|
66
68
|
*/
|
|
67
|
-
function concat
|
|
68
|
-
if (list.length === 0) return EMPTY_BUFFER
|
|
69
|
+
function concat(list, totalLength) {
|
|
70
|
+
if (list.length === 0) return EMPTY_BUFFER;
|
|
69
71
|
if (list.length === 1) return list[0];
|
|
70
72
|
const target = Buffer.allocUnsafe(totalLength);
|
|
71
73
|
let offset = 0;
|
|
@@ -74,7 +76,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
|
|
|
74
76
|
target.set(buf, offset);
|
|
75
77
|
offset += buf.length;
|
|
76
78
|
}
|
|
77
|
-
if (offset < totalLength) return new FastBuffer
|
|
79
|
+
if (offset < totalLength) return new FastBuffer(target.buffer, target.byteOffset, offset);
|
|
78
80
|
return target;
|
|
79
81
|
}
|
|
80
82
|
/**
|
|
@@ -107,7 +109,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
|
|
|
107
109
|
* @return {ArrayBuffer} Converted buffer
|
|
108
110
|
* @public
|
|
109
111
|
*/
|
|
110
|
-
function toArrayBuffer
|
|
112
|
+
function toArrayBuffer(buf) {
|
|
111
113
|
if (buf.length === buf.buffer.byteLength) return buf.buffer;
|
|
112
114
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
113
115
|
}
|
|
@@ -119,49 +121,49 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
|
|
|
119
121
|
* @throws {TypeError}
|
|
120
122
|
* @public
|
|
121
123
|
*/
|
|
122
|
-
function toBuffer
|
|
123
|
-
toBuffer
|
|
124
|
+
function toBuffer(data) {
|
|
125
|
+
toBuffer.readOnly = true;
|
|
124
126
|
if (Buffer.isBuffer(data)) return data;
|
|
125
127
|
let buf;
|
|
126
|
-
if (data instanceof ArrayBuffer) buf = new FastBuffer
|
|
127
|
-
else if (ArrayBuffer.isView(data)) buf = new FastBuffer
|
|
128
|
+
if (data instanceof ArrayBuffer) buf = new FastBuffer(data);
|
|
129
|
+
else if (ArrayBuffer.isView(data)) buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
|
|
128
130
|
else {
|
|
129
131
|
buf = Buffer.from(data);
|
|
130
|
-
toBuffer
|
|
132
|
+
toBuffer.readOnly = false;
|
|
131
133
|
}
|
|
132
134
|
return buf;
|
|
133
135
|
}
|
|
134
136
|
module.exports = {
|
|
135
|
-
concat
|
|
137
|
+
concat,
|
|
136
138
|
mask: _mask,
|
|
137
|
-
toArrayBuffer
|
|
138
|
-
toBuffer
|
|
139
|
+
toArrayBuffer,
|
|
140
|
+
toBuffer,
|
|
139
141
|
unmask: _unmask
|
|
140
142
|
};
|
|
141
143
|
/* istanbul ignore else */
|
|
142
144
|
if (!process.env.WS_NO_BUFFER_UTIL) try {
|
|
143
|
-
const bufferUtil
|
|
145
|
+
const bufferUtil = __require("bufferutil");
|
|
144
146
|
module.exports.mask = function(source, mask, output, offset, length) {
|
|
145
147
|
if (length < 48) _mask(source, mask, output, offset, length);
|
|
146
|
-
else bufferUtil
|
|
148
|
+
else bufferUtil.mask(source, mask, output, offset, length);
|
|
147
149
|
};
|
|
148
150
|
module.exports.unmask = function(buffer, mask) {
|
|
149
151
|
if (buffer.length < 32) _unmask(buffer, mask);
|
|
150
|
-
else bufferUtil
|
|
152
|
+
else bufferUtil.unmask(buffer, mask);
|
|
151
153
|
};
|
|
152
154
|
} catch (e) {}
|
|
153
|
-
})
|
|
155
|
+
}));
|
|
154
156
|
|
|
155
157
|
//#endregion
|
|
156
158
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/limiter.js
|
|
157
|
-
var require_limiter = /* @__PURE__ */
|
|
159
|
+
var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
158
160
|
const kDone = Symbol("kDone");
|
|
159
161
|
const kRun = Symbol("kRun");
|
|
160
162
|
/**
|
|
161
163
|
* A very simple job queue with adjustable concurrency. Adapted from
|
|
162
164
|
* https://github.com/STRML/async-limiter
|
|
163
165
|
*/
|
|
164
|
-
var Limiter
|
|
166
|
+
var Limiter = class {
|
|
165
167
|
/**
|
|
166
168
|
* Creates a new `Limiter`.
|
|
167
169
|
*
|
|
@@ -201,17 +203,17 @@ var require_limiter = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@
|
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
205
|
};
|
|
204
|
-
module.exports = Limiter
|
|
205
|
-
})
|
|
206
|
+
module.exports = Limiter;
|
|
207
|
+
}));
|
|
206
208
|
|
|
207
209
|
//#endregion
|
|
208
210
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/permessage-deflate.js
|
|
209
|
-
var require_permessage_deflate = /* @__PURE__ */
|
|
211
|
+
var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
210
212
|
const zlib = __require("zlib");
|
|
211
213
|
const bufferUtil = require_buffer_util();
|
|
212
214
|
const Limiter = require_limiter();
|
|
213
|
-
const { kStatusCode
|
|
214
|
-
const FastBuffer
|
|
215
|
+
const { kStatusCode } = require_constants();
|
|
216
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
215
217
|
const TRAILER = Buffer.from([
|
|
216
218
|
0,
|
|
217
219
|
0,
|
|
@@ -222,12 +224,12 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
222
224
|
const kTotalLength = Symbol("total-length");
|
|
223
225
|
const kCallback = Symbol("callback");
|
|
224
226
|
const kBuffers = Symbol("buffers");
|
|
225
|
-
const kError
|
|
227
|
+
const kError = Symbol("error");
|
|
226
228
|
let zlibLimiter;
|
|
227
229
|
/**
|
|
228
230
|
* permessage-deflate implementation.
|
|
229
231
|
*/
|
|
230
|
-
var PerMessageDeflate
|
|
232
|
+
var PerMessageDeflate = class {
|
|
231
233
|
/**
|
|
232
234
|
* Creates a PerMessageDeflate instance.
|
|
233
235
|
*
|
|
@@ -260,10 +262,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
260
262
|
this._deflate = null;
|
|
261
263
|
this._inflate = null;
|
|
262
264
|
this.params = null;
|
|
263
|
-
if (!zlibLimiter)
|
|
264
|
-
const concurrency = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
|
|
265
|
-
zlibLimiter = new Limiter(concurrency);
|
|
266
|
-
}
|
|
265
|
+
if (!zlibLimiter) zlibLimiter = new Limiter(this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10);
|
|
267
266
|
}
|
|
268
267
|
/**
|
|
269
268
|
* @type {String}
|
|
@@ -441,7 +440,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
441
440
|
this._inflate.write(data);
|
|
442
441
|
if (fin) this._inflate.write(TRAILER);
|
|
443
442
|
this._inflate.flush(() => {
|
|
444
|
-
const err = this._inflate[kError
|
|
443
|
+
const err = this._inflate[kError];
|
|
445
444
|
if (err) {
|
|
446
445
|
this._inflate.close();
|
|
447
446
|
this._inflate = null;
|
|
@@ -486,7 +485,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
486
485
|
this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
|
|
487
486
|
if (!this._deflate) return;
|
|
488
487
|
let data$1 = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
489
|
-
if (fin) data$1 = new FastBuffer
|
|
488
|
+
if (fin) data$1 = new FastBuffer(data$1.buffer, data$1.byteOffset, data$1.length - 4);
|
|
490
489
|
this._deflate[kCallback] = null;
|
|
491
490
|
this._deflate[kTotalLength] = 0;
|
|
492
491
|
this._deflate[kBuffers] = [];
|
|
@@ -495,7 +494,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
495
494
|
});
|
|
496
495
|
}
|
|
497
496
|
};
|
|
498
|
-
module.exports = PerMessageDeflate
|
|
497
|
+
module.exports = PerMessageDeflate;
|
|
499
498
|
/**
|
|
500
499
|
* The listener of the `zlib.DeflateRaw` stream `'data'` event.
|
|
501
500
|
*
|
|
@@ -518,9 +517,9 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
518
517
|
this[kBuffers].push(chunk);
|
|
519
518
|
return;
|
|
520
519
|
}
|
|
521
|
-
this[kError
|
|
522
|
-
this[kError
|
|
523
|
-
this[kError
|
|
520
|
+
this[kError] = /* @__PURE__ */ new RangeError("Max payload size exceeded");
|
|
521
|
+
this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
|
|
522
|
+
this[kError][kStatusCode] = 1009;
|
|
524
523
|
this.removeListener("data", inflateOnData);
|
|
525
524
|
this.reset();
|
|
526
525
|
}
|
|
@@ -532,21 +531,21 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "../../node_module
|
|
|
532
531
|
*/
|
|
533
532
|
function inflateOnError(err) {
|
|
534
533
|
this[kPerMessageDeflate]._inflate = null;
|
|
535
|
-
if (this[kError
|
|
536
|
-
this[kCallback](this[kError
|
|
534
|
+
if (this[kError]) {
|
|
535
|
+
this[kCallback](this[kError]);
|
|
537
536
|
return;
|
|
538
537
|
}
|
|
539
|
-
err[kStatusCode
|
|
538
|
+
err[kStatusCode] = 1007;
|
|
540
539
|
this[kCallback](err);
|
|
541
540
|
}
|
|
542
|
-
})
|
|
541
|
+
}));
|
|
543
542
|
|
|
544
543
|
//#endregion
|
|
545
544
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/validation.js
|
|
546
|
-
var require_validation = /* @__PURE__ */
|
|
545
|
+
var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
547
546
|
const { isUtf8 } = __require("buffer");
|
|
548
547
|
const { hasBlob } = require_constants();
|
|
549
|
-
const tokenChars
|
|
548
|
+
const tokenChars = [
|
|
550
549
|
0,
|
|
551
550
|
0,
|
|
552
551
|
0,
|
|
@@ -683,7 +682,7 @@ var require_validation = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
|
|
|
683
682
|
* @return {Boolean} `true` if the status code is valid, else `false`
|
|
684
683
|
* @public
|
|
685
684
|
*/
|
|
686
|
-
function isValidStatusCode
|
|
685
|
+
function isValidStatusCode(code) {
|
|
687
686
|
return code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;
|
|
688
687
|
}
|
|
689
688
|
/**
|
|
@@ -718,34 +717,34 @@ var require_validation = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/
|
|
|
718
717
|
* @return {Boolean} `true` if `value` is a `Blob`, else `false`
|
|
719
718
|
* @private
|
|
720
719
|
*/
|
|
721
|
-
function isBlob
|
|
720
|
+
function isBlob(value) {
|
|
722
721
|
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");
|
|
723
722
|
}
|
|
724
723
|
module.exports = {
|
|
725
|
-
isBlob
|
|
726
|
-
isValidStatusCode
|
|
724
|
+
isBlob,
|
|
725
|
+
isValidStatusCode,
|
|
727
726
|
isValidUTF8: _isValidUTF8,
|
|
728
|
-
tokenChars
|
|
727
|
+
tokenChars
|
|
729
728
|
};
|
|
730
729
|
if (isUtf8) module.exports.isValidUTF8 = function(buf) {
|
|
731
730
|
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
732
731
|
};
|
|
733
732
|
else if (!process.env.WS_NO_UTF_8_VALIDATE) try {
|
|
734
|
-
const isValidUTF8
|
|
733
|
+
const isValidUTF8 = __require("utf-8-validate");
|
|
735
734
|
module.exports.isValidUTF8 = function(buf) {
|
|
736
|
-
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8
|
|
735
|
+
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
737
736
|
};
|
|
738
737
|
} catch (e) {}
|
|
739
|
-
})
|
|
738
|
+
}));
|
|
740
739
|
|
|
741
740
|
//#endregion
|
|
742
741
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/receiver.js
|
|
743
|
-
var require_receiver = /* @__PURE__ */
|
|
742
|
+
var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
744
743
|
const { Writable } = __require("stream");
|
|
745
|
-
const PerMessageDeflate
|
|
746
|
-
const { BINARY_TYPES
|
|
744
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
745
|
+
const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = require_constants();
|
|
747
746
|
const { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
748
|
-
const { isValidStatusCode
|
|
747
|
+
const { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
749
748
|
const FastBuffer = Buffer[Symbol.species];
|
|
750
749
|
const GET_INFO = 0;
|
|
751
750
|
const GET_PAYLOAD_LENGTH_16 = 1;
|
|
@@ -759,7 +758,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
759
758
|
*
|
|
760
759
|
* @extends Writable
|
|
761
760
|
*/
|
|
762
|
-
var Receiver
|
|
761
|
+
var Receiver = class extends Writable {
|
|
763
762
|
/**
|
|
764
763
|
* Creates a Receiver instance.
|
|
765
764
|
*
|
|
@@ -779,12 +778,12 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
779
778
|
constructor(options = {}) {
|
|
780
779
|
super();
|
|
781
780
|
this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
|
|
782
|
-
this._binaryType = options.binaryType || BINARY_TYPES
|
|
781
|
+
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
783
782
|
this._extensions = options.extensions || {};
|
|
784
783
|
this._isServer = !!options.isServer;
|
|
785
784
|
this._maxPayload = options.maxPayload | 0;
|
|
786
785
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
787
|
-
this[kWebSocket
|
|
786
|
+
this[kWebSocket] = void 0;
|
|
788
787
|
this._bufferedBytes = 0;
|
|
789
788
|
this._buffers = [];
|
|
790
789
|
this._compressed = false;
|
|
@@ -889,14 +888,12 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
889
888
|
}
|
|
890
889
|
const buf = this.consume(2);
|
|
891
890
|
if ((buf[0] & 48) !== 0) {
|
|
892
|
-
|
|
893
|
-
cb(error);
|
|
891
|
+
cb(this.createError(RangeError, "RSV2 and RSV3 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_2_3"));
|
|
894
892
|
return;
|
|
895
893
|
}
|
|
896
894
|
const compressed = (buf[0] & 64) === 64;
|
|
897
|
-
if (compressed && !this._extensions[PerMessageDeflate
|
|
898
|
-
|
|
899
|
-
cb(error);
|
|
895
|
+
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
|
|
896
|
+
cb(this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
900
897
|
return;
|
|
901
898
|
}
|
|
902
899
|
this._fin = (buf[0] & 128) === 128;
|
|
@@ -904,55 +901,46 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
904
901
|
this._payloadLength = buf[1] & 127;
|
|
905
902
|
if (this._opcode === 0) {
|
|
906
903
|
if (compressed) {
|
|
907
|
-
|
|
908
|
-
cb(error);
|
|
904
|
+
cb(this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
909
905
|
return;
|
|
910
906
|
}
|
|
911
907
|
if (!this._fragmented) {
|
|
912
|
-
|
|
913
|
-
cb(error);
|
|
908
|
+
cb(this.createError(RangeError, "invalid opcode 0", true, 1002, "WS_ERR_INVALID_OPCODE"));
|
|
914
909
|
return;
|
|
915
910
|
}
|
|
916
911
|
this._opcode = this._fragmented;
|
|
917
912
|
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
918
913
|
if (this._fragmented) {
|
|
919
|
-
|
|
920
|
-
cb(error);
|
|
914
|
+
cb(this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE"));
|
|
921
915
|
return;
|
|
922
916
|
}
|
|
923
917
|
this._compressed = compressed;
|
|
924
918
|
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
925
919
|
if (!this._fin) {
|
|
926
|
-
|
|
927
|
-
cb(error);
|
|
920
|
+
cb(this.createError(RangeError, "FIN must be set", true, 1002, "WS_ERR_EXPECTED_FIN"));
|
|
928
921
|
return;
|
|
929
922
|
}
|
|
930
923
|
if (compressed) {
|
|
931
|
-
|
|
932
|
-
cb(error);
|
|
924
|
+
cb(this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
933
925
|
return;
|
|
934
926
|
}
|
|
935
927
|
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
936
|
-
|
|
937
|
-
cb(error);
|
|
928
|
+
cb(this.createError(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"));
|
|
938
929
|
return;
|
|
939
930
|
}
|
|
940
931
|
} else {
|
|
941
|
-
|
|
942
|
-
cb(error);
|
|
932
|
+
cb(this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE"));
|
|
943
933
|
return;
|
|
944
934
|
}
|
|
945
935
|
if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
|
|
946
936
|
this._masked = (buf[1] & 128) === 128;
|
|
947
937
|
if (this._isServer) {
|
|
948
938
|
if (!this._masked) {
|
|
949
|
-
|
|
950
|
-
cb(error);
|
|
939
|
+
cb(this.createError(RangeError, "MASK must be set", true, 1002, "WS_ERR_EXPECTED_MASK"));
|
|
951
940
|
return;
|
|
952
941
|
}
|
|
953
942
|
} else if (this._masked) {
|
|
954
|
-
|
|
955
|
-
cb(error);
|
|
943
|
+
cb(this.createError(RangeError, "MASK must be clear", true, 1002, "WS_ERR_UNEXPECTED_MASK"));
|
|
956
944
|
return;
|
|
957
945
|
}
|
|
958
946
|
if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
|
|
@@ -987,8 +975,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
987
975
|
const buf = this.consume(8);
|
|
988
976
|
const num = buf.readUInt32BE(0);
|
|
989
977
|
if (num > Math.pow(2, 21) - 1) {
|
|
990
|
-
|
|
991
|
-
cb(error);
|
|
978
|
+
cb(this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", false, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"));
|
|
992
979
|
return;
|
|
993
980
|
}
|
|
994
981
|
this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
@@ -1004,8 +991,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
1004
991
|
if (this._payloadLength && this._opcode < 8) {
|
|
1005
992
|
this._totalPayloadLength += this._payloadLength;
|
|
1006
993
|
if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
|
|
1007
|
-
|
|
1008
|
-
cb(error);
|
|
994
|
+
cb(this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
|
|
1009
995
|
return;
|
|
1010
996
|
}
|
|
1011
997
|
}
|
|
@@ -1032,7 +1018,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
1032
1018
|
* @private
|
|
1033
1019
|
*/
|
|
1034
1020
|
getData(cb) {
|
|
1035
|
-
let data = EMPTY_BUFFER
|
|
1021
|
+
let data = EMPTY_BUFFER;
|
|
1036
1022
|
if (this._payloadLength) {
|
|
1037
1023
|
if (this._bufferedBytes < this._payloadLength) {
|
|
1038
1024
|
this._loop = false;
|
|
@@ -1064,13 +1050,12 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
1064
1050
|
* @private
|
|
1065
1051
|
*/
|
|
1066
1052
|
decompress(data, cb) {
|
|
1067
|
-
this._extensions[PerMessageDeflate
|
|
1053
|
+
this._extensions[PerMessageDeflate.extensionName].decompress(data, this._fin, (err, buf) => {
|
|
1068
1054
|
if (err) return cb(err);
|
|
1069
1055
|
if (buf.length) {
|
|
1070
1056
|
this._messageLength += buf.length;
|
|
1071
1057
|
if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
1072
|
-
|
|
1073
|
-
cb(error);
|
|
1058
|
+
cb(this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
|
|
1074
1059
|
return;
|
|
1075
1060
|
}
|
|
1076
1061
|
this._fragments.push(buf);
|
|
@@ -1116,8 +1101,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
1116
1101
|
} else {
|
|
1117
1102
|
const buf = concat(fragments, messageLength);
|
|
1118
1103
|
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
1119
|
-
|
|
1120
|
-
cb(error);
|
|
1104
|
+
cb(this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8"));
|
|
1121
1105
|
return;
|
|
1122
1106
|
}
|
|
1123
1107
|
if (this._state === INFLATING || this._allowSynchronousEvents) {
|
|
@@ -1144,19 +1128,17 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
1144
1128
|
if (this._opcode === 8) {
|
|
1145
1129
|
if (data.length === 0) {
|
|
1146
1130
|
this._loop = false;
|
|
1147
|
-
this.emit("conclude", 1005, EMPTY_BUFFER
|
|
1131
|
+
this.emit("conclude", 1005, EMPTY_BUFFER);
|
|
1148
1132
|
this.end();
|
|
1149
1133
|
} else {
|
|
1150
1134
|
const code = data.readUInt16BE(0);
|
|
1151
|
-
if (!isValidStatusCode
|
|
1152
|
-
|
|
1153
|
-
cb(error);
|
|
1135
|
+
if (!isValidStatusCode(code)) {
|
|
1136
|
+
cb(this.createError(RangeError, `invalid status code ${code}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE"));
|
|
1154
1137
|
return;
|
|
1155
1138
|
}
|
|
1156
1139
|
const buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
1157
1140
|
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
1158
|
-
|
|
1159
|
-
cb(error);
|
|
1141
|
+
cb(this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8"));
|
|
1160
1142
|
return;
|
|
1161
1143
|
}
|
|
1162
1144
|
this._loop = false;
|
|
@@ -1196,22 +1178,22 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws
|
|
|
1196
1178
|
const err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
|
|
1197
1179
|
Error.captureStackTrace(err, this.createError);
|
|
1198
1180
|
err.code = errorCode;
|
|
1199
|
-
err[kStatusCode
|
|
1181
|
+
err[kStatusCode] = statusCode;
|
|
1200
1182
|
return err;
|
|
1201
1183
|
}
|
|
1202
1184
|
};
|
|
1203
|
-
module.exports = Receiver
|
|
1204
|
-
})
|
|
1185
|
+
module.exports = Receiver;
|
|
1186
|
+
}));
|
|
1205
1187
|
|
|
1206
1188
|
//#endregion
|
|
1207
1189
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/sender.js
|
|
1208
|
-
var require_sender = /* @__PURE__ */
|
|
1190
|
+
var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1209
1191
|
const { Duplex: Duplex$3 } = __require("stream");
|
|
1210
1192
|
const { randomFillSync } = __require("crypto");
|
|
1211
|
-
const PerMessageDeflate
|
|
1212
|
-
const { EMPTY_BUFFER
|
|
1213
|
-
const { isBlob
|
|
1214
|
-
const { mask: applyMask, toBuffer
|
|
1193
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
1194
|
+
const { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
|
|
1195
|
+
const { isBlob, isValidStatusCode } = require_validation();
|
|
1196
|
+
const { mask: applyMask, toBuffer } = require_buffer_util();
|
|
1215
1197
|
const kByteLength = Symbol("kByteLength");
|
|
1216
1198
|
const maskBuffer = Buffer.alloc(4);
|
|
1217
1199
|
const RANDOM_POOL_SIZE = 8 * 1024;
|
|
@@ -1223,7 +1205,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1223
1205
|
/**
|
|
1224
1206
|
* HyBi Sender implementation.
|
|
1225
1207
|
*/
|
|
1226
|
-
var Sender
|
|
1208
|
+
var Sender = class Sender {
|
|
1227
1209
|
/**
|
|
1228
1210
|
* Creates a Sender instance.
|
|
1229
1211
|
*
|
|
@@ -1244,8 +1226,8 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1244
1226
|
this._bufferedBytes = 0;
|
|
1245
1227
|
this._queue = [];
|
|
1246
1228
|
this._state = DEFAULT;
|
|
1247
|
-
this.onerror = NOOP
|
|
1248
|
-
this[kWebSocket
|
|
1229
|
+
this.onerror = NOOP;
|
|
1230
|
+
this[kWebSocket] = void 0;
|
|
1249
1231
|
}
|
|
1250
1232
|
/**
|
|
1251
1233
|
* Frames a piece of data according to the HyBi WebSocket protocol.
|
|
@@ -1343,7 +1325,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1343
1325
|
*/
|
|
1344
1326
|
close(code, data, mask, cb) {
|
|
1345
1327
|
let buf;
|
|
1346
|
-
if (code === void 0) buf = EMPTY_BUFFER
|
|
1328
|
+
if (code === void 0) buf = EMPTY_BUFFER;
|
|
1347
1329
|
else if (typeof code !== "number" || !isValidStatusCode(code)) throw new TypeError("First argument must be a valid error code number");
|
|
1348
1330
|
else if (data === void 0 || !data.length) {
|
|
1349
1331
|
buf = Buffer.allocUnsafe(2);
|
|
@@ -1373,7 +1355,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1373
1355
|
options,
|
|
1374
1356
|
cb
|
|
1375
1357
|
]);
|
|
1376
|
-
else this.sendFrame(Sender
|
|
1358
|
+
else this.sendFrame(Sender.frame(buf, options), cb);
|
|
1377
1359
|
}
|
|
1378
1360
|
/**
|
|
1379
1361
|
* Sends a ping message to the other peer.
|
|
@@ -1389,13 +1371,13 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1389
1371
|
if (typeof data === "string") {
|
|
1390
1372
|
byteLength = Buffer.byteLength(data);
|
|
1391
1373
|
readOnly = false;
|
|
1392
|
-
} else if (isBlob
|
|
1374
|
+
} else if (isBlob(data)) {
|
|
1393
1375
|
byteLength = data.size;
|
|
1394
1376
|
readOnly = false;
|
|
1395
1377
|
} else {
|
|
1396
|
-
data = toBuffer
|
|
1378
|
+
data = toBuffer(data);
|
|
1397
1379
|
byteLength = data.length;
|
|
1398
|
-
readOnly = toBuffer
|
|
1380
|
+
readOnly = toBuffer.readOnly;
|
|
1399
1381
|
}
|
|
1400
1382
|
if (byteLength > 125) throw new RangeError("The data size must not be greater than 125 bytes");
|
|
1401
1383
|
const options = {
|
|
@@ -1408,7 +1390,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1408
1390
|
readOnly,
|
|
1409
1391
|
rsv1: false
|
|
1410
1392
|
};
|
|
1411
|
-
if (isBlob
|
|
1393
|
+
if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
|
|
1412
1394
|
this.getBlobData,
|
|
1413
1395
|
data,
|
|
1414
1396
|
false,
|
|
@@ -1423,7 +1405,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1423
1405
|
options,
|
|
1424
1406
|
cb
|
|
1425
1407
|
]);
|
|
1426
|
-
else this.sendFrame(Sender
|
|
1408
|
+
else this.sendFrame(Sender.frame(data, options), cb);
|
|
1427
1409
|
}
|
|
1428
1410
|
/**
|
|
1429
1411
|
* Sends a pong message to the other peer.
|
|
@@ -1439,13 +1421,13 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1439
1421
|
if (typeof data === "string") {
|
|
1440
1422
|
byteLength = Buffer.byteLength(data);
|
|
1441
1423
|
readOnly = false;
|
|
1442
|
-
} else if (isBlob
|
|
1424
|
+
} else if (isBlob(data)) {
|
|
1443
1425
|
byteLength = data.size;
|
|
1444
1426
|
readOnly = false;
|
|
1445
1427
|
} else {
|
|
1446
|
-
data = toBuffer
|
|
1428
|
+
data = toBuffer(data);
|
|
1447
1429
|
byteLength = data.length;
|
|
1448
|
-
readOnly = toBuffer
|
|
1430
|
+
readOnly = toBuffer.readOnly;
|
|
1449
1431
|
}
|
|
1450
1432
|
if (byteLength > 125) throw new RangeError("The data size must not be greater than 125 bytes");
|
|
1451
1433
|
const options = {
|
|
@@ -1458,7 +1440,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1458
1440
|
readOnly,
|
|
1459
1441
|
rsv1: false
|
|
1460
1442
|
};
|
|
1461
|
-
if (isBlob
|
|
1443
|
+
if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
|
|
1462
1444
|
this.getBlobData,
|
|
1463
1445
|
data,
|
|
1464
1446
|
false,
|
|
@@ -1473,7 +1455,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1473
1455
|
options,
|
|
1474
1456
|
cb
|
|
1475
1457
|
]);
|
|
1476
|
-
else this.sendFrame(Sender
|
|
1458
|
+
else this.sendFrame(Sender.frame(data, options), cb);
|
|
1477
1459
|
}
|
|
1478
1460
|
/**
|
|
1479
1461
|
* Sends a data message to the other peer.
|
|
@@ -1492,7 +1474,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1492
1474
|
* @public
|
|
1493
1475
|
*/
|
|
1494
1476
|
send(data, options, cb) {
|
|
1495
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate
|
|
1477
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
1496
1478
|
let opcode = options.binary ? 2 : 1;
|
|
1497
1479
|
let rsv1 = options.compress;
|
|
1498
1480
|
let byteLength;
|
|
@@ -1500,13 +1482,13 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1500
1482
|
if (typeof data === "string") {
|
|
1501
1483
|
byteLength = Buffer.byteLength(data);
|
|
1502
1484
|
readOnly = false;
|
|
1503
|
-
} else if (isBlob
|
|
1485
|
+
} else if (isBlob(data)) {
|
|
1504
1486
|
byteLength = data.size;
|
|
1505
1487
|
readOnly = false;
|
|
1506
1488
|
} else {
|
|
1507
|
-
data = toBuffer
|
|
1489
|
+
data = toBuffer(data);
|
|
1508
1490
|
byteLength = data.length;
|
|
1509
|
-
readOnly = toBuffer
|
|
1491
|
+
readOnly = toBuffer.readOnly;
|
|
1510
1492
|
}
|
|
1511
1493
|
if (this._firstFragment) {
|
|
1512
1494
|
this._firstFragment = false;
|
|
@@ -1527,7 +1509,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1527
1509
|
readOnly,
|
|
1528
1510
|
rsv1
|
|
1529
1511
|
};
|
|
1530
|
-
if (isBlob
|
|
1512
|
+
if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
|
|
1531
1513
|
this.getBlobData,
|
|
1532
1514
|
data,
|
|
1533
1515
|
this._compress,
|
|
@@ -1577,10 +1559,10 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1577
1559
|
return;
|
|
1578
1560
|
}
|
|
1579
1561
|
this._bufferedBytes -= options[kByteLength];
|
|
1580
|
-
const data = toBuffer
|
|
1562
|
+
const data = toBuffer(arrayBuffer);
|
|
1581
1563
|
if (!compress) {
|
|
1582
1564
|
this._state = DEFAULT;
|
|
1583
|
-
this.sendFrame(Sender
|
|
1565
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
1584
1566
|
this.dequeue();
|
|
1585
1567
|
} else this.dispatch(data, compress, options, cb);
|
|
1586
1568
|
}).catch((err) => {
|
|
@@ -1612,10 +1594,10 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1612
1594
|
*/
|
|
1613
1595
|
dispatch(data, compress, options, cb) {
|
|
1614
1596
|
if (!compress) {
|
|
1615
|
-
this.sendFrame(Sender
|
|
1597
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
1616
1598
|
return;
|
|
1617
1599
|
}
|
|
1618
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate
|
|
1600
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
1619
1601
|
this._bufferedBytes += options[kByteLength];
|
|
1620
1602
|
this._state = DEFLATING;
|
|
1621
1603
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
@@ -1626,7 +1608,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1626
1608
|
this._bufferedBytes -= options[kByteLength];
|
|
1627
1609
|
this._state = DEFAULT;
|
|
1628
1610
|
options.readOnly = false;
|
|
1629
|
-
this.sendFrame(Sender
|
|
1611
|
+
this.sendFrame(Sender.frame(buf, options), cb);
|
|
1630
1612
|
this.dequeue();
|
|
1631
1613
|
});
|
|
1632
1614
|
}
|
|
@@ -1668,7 +1650,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1668
1650
|
} else this._socket.write(list[0], cb);
|
|
1669
1651
|
}
|
|
1670
1652
|
};
|
|
1671
|
-
module.exports = Sender
|
|
1653
|
+
module.exports = Sender;
|
|
1672
1654
|
/**
|
|
1673
1655
|
* Calls queued callbacks with an error.
|
|
1674
1656
|
*
|
|
@@ -1697,12 +1679,12 @@ var require_sender = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
1697
1679
|
callCallbacks(sender, err, cb);
|
|
1698
1680
|
sender.onerror(err);
|
|
1699
1681
|
}
|
|
1700
|
-
})
|
|
1682
|
+
}));
|
|
1701
1683
|
|
|
1702
1684
|
//#endregion
|
|
1703
1685
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/event-target.js
|
|
1704
|
-
var require_event_target = /* @__PURE__ */
|
|
1705
|
-
const { kForOnEventAttribute
|
|
1686
|
+
var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1687
|
+
const { kForOnEventAttribute, kListener } = require_constants();
|
|
1706
1688
|
const kCode = Symbol("kCode");
|
|
1707
1689
|
const kData = Symbol("kData");
|
|
1708
1690
|
const kError = Symbol("kError");
|
|
@@ -1856,7 +1838,7 @@ var require_event_target = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
|
|
|
1856
1838
|
*/
|
|
1857
1839
|
const EventTarget = {
|
|
1858
1840
|
addEventListener(type, handler, options = {}) {
|
|
1859
|
-
for (const listener of this.listeners(type)) if (!options[kForOnEventAttribute
|
|
1841
|
+
for (const listener of this.listeners(type)) if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) return;
|
|
1860
1842
|
let wrapper;
|
|
1861
1843
|
if (type === "message") wrapper = function onMessage(data, isBinary) {
|
|
1862
1844
|
const event = new MessageEvent("message", { data: isBinary ? data : data.toString() });
|
|
@@ -1872,7 +1854,7 @@ var require_event_target = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
|
|
|
1872
1854
|
event[kTarget] = this;
|
|
1873
1855
|
callListener(handler, this, event);
|
|
1874
1856
|
};
|
|
1875
|
-
else if (type === "error") wrapper = function onError
|
|
1857
|
+
else if (type === "error") wrapper = function onError(error) {
|
|
1876
1858
|
const event = new ErrorEvent("error", {
|
|
1877
1859
|
error,
|
|
1878
1860
|
message: error.message
|
|
@@ -1886,13 +1868,13 @@ var require_event_target = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
|
|
|
1886
1868
|
callListener(handler, this, event);
|
|
1887
1869
|
};
|
|
1888
1870
|
else return;
|
|
1889
|
-
wrapper[kForOnEventAttribute
|
|
1890
|
-
wrapper[kListener
|
|
1871
|
+
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
1872
|
+
wrapper[kListener] = handler;
|
|
1891
1873
|
if (options.once) this.once(type, wrapper);
|
|
1892
1874
|
else this.on(type, wrapper);
|
|
1893
1875
|
},
|
|
1894
1876
|
removeEventListener(type, handler) {
|
|
1895
|
-
for (const listener of this.listeners(type)) if (listener[kListener
|
|
1877
|
+
for (const listener of this.listeners(type)) if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
1896
1878
|
this.removeListener(type, listener);
|
|
1897
1879
|
break;
|
|
1898
1880
|
}
|
|
@@ -1917,12 +1899,12 @@ var require_event_target = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
|
|
|
1917
1899
|
if (typeof listener === "object" && listener.handleEvent) listener.handleEvent.call(listener, event);
|
|
1918
1900
|
else listener.call(thisArg, event);
|
|
1919
1901
|
}
|
|
1920
|
-
})
|
|
1902
|
+
}));
|
|
1921
1903
|
|
|
1922
1904
|
//#endregion
|
|
1923
1905
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/extension.js
|
|
1924
|
-
var require_extension = /* @__PURE__ */
|
|
1925
|
-
const { tokenChars
|
|
1906
|
+
var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1907
|
+
const { tokenChars } = require_validation();
|
|
1926
1908
|
/**
|
|
1927
1909
|
* Adds an offer to the map of extension offers or a parameter to the map of
|
|
1928
1910
|
* parameters.
|
|
@@ -1944,7 +1926,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
1944
1926
|
* @return {Object} The parsed object
|
|
1945
1927
|
* @public
|
|
1946
1928
|
*/
|
|
1947
|
-
function parse
|
|
1929
|
+
function parse(header) {
|
|
1948
1930
|
const offers = Object.create(null);
|
|
1949
1931
|
let params = Object.create(null);
|
|
1950
1932
|
let mustUnescape = false;
|
|
@@ -1958,7 +1940,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
1958
1940
|
let i = 0;
|
|
1959
1941
|
for (; i < header.length; i++) {
|
|
1960
1942
|
code = header.charCodeAt(i);
|
|
1961
|
-
if (extensionName === void 0) if (end === -1 && tokenChars
|
|
1943
|
+
if (extensionName === void 0) if (end === -1 && tokenChars[code] === 1) {
|
|
1962
1944
|
if (start === -1) start = i;
|
|
1963
1945
|
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
1964
1946
|
if (end === -1 && start !== -1) end = i;
|
|
@@ -1972,7 +1954,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
1972
1954
|
} else extensionName = name;
|
|
1973
1955
|
start = end = -1;
|
|
1974
1956
|
} else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
1975
|
-
else if (paramName === void 0) if (end === -1 && tokenChars
|
|
1957
|
+
else if (paramName === void 0) if (end === -1 && tokenChars[code] === 1) {
|
|
1976
1958
|
if (start === -1) start = i;
|
|
1977
1959
|
} else if (code === 32 || code === 9) {
|
|
1978
1960
|
if (end === -1 && start !== -1) end = i;
|
|
@@ -1991,11 +1973,11 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
1991
1973
|
start = end = -1;
|
|
1992
1974
|
} else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
1993
1975
|
else if (isEscaping) {
|
|
1994
|
-
if (tokenChars
|
|
1976
|
+
if (tokenChars[code] !== 1) throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
1995
1977
|
if (start === -1) start = i;
|
|
1996
1978
|
else if (!mustUnescape) mustUnescape = true;
|
|
1997
1979
|
isEscaping = false;
|
|
1998
|
-
} else if (inQuotes) if (tokenChars
|
|
1980
|
+
} else if (inQuotes) if (tokenChars[code] === 1) {
|
|
1999
1981
|
if (start === -1) start = i;
|
|
2000
1982
|
} else if (code === 34 && start !== -1) {
|
|
2001
1983
|
inQuotes = false;
|
|
@@ -2003,7 +1985,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2003
1985
|
} else if (code === 92) isEscaping = true;
|
|
2004
1986
|
else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
2005
1987
|
else if (code === 34 && header.charCodeAt(i - 1) === 61) inQuotes = true;
|
|
2006
|
-
else if (end === -1 && tokenChars
|
|
1988
|
+
else if (end === -1 && tokenChars[code] === 1) {
|
|
2007
1989
|
if (start === -1) start = i;
|
|
2008
1990
|
} else if (start !== -1 && (code === 32 || code === 9)) {
|
|
2009
1991
|
if (end === -1) end = i;
|
|
@@ -2044,12 +2026,12 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2044
2026
|
* @return {String} A string representing the given object
|
|
2045
2027
|
* @public
|
|
2046
2028
|
*/
|
|
2047
|
-
function format
|
|
2048
|
-
return Object.keys(extensions).map((extension
|
|
2049
|
-
let configurations = extensions[extension
|
|
2029
|
+
function format(extensions) {
|
|
2030
|
+
return Object.keys(extensions).map((extension) => {
|
|
2031
|
+
let configurations = extensions[extension];
|
|
2050
2032
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
2051
2033
|
return configurations.map((params) => {
|
|
2052
|
-
return [extension
|
|
2034
|
+
return [extension].concat(Object.keys(params).map((k) => {
|
|
2053
2035
|
let values = params[k];
|
|
2054
2036
|
if (!Array.isArray(values)) values = [values];
|
|
2055
2037
|
return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
|
|
@@ -2058,14 +2040,14 @@ var require_extension = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2058
2040
|
}).join(", ");
|
|
2059
2041
|
}
|
|
2060
2042
|
module.exports = {
|
|
2061
|
-
format
|
|
2062
|
-
parse
|
|
2043
|
+
format,
|
|
2044
|
+
parse
|
|
2063
2045
|
};
|
|
2064
|
-
})
|
|
2046
|
+
}));
|
|
2065
2047
|
|
|
2066
2048
|
//#endregion
|
|
2067
2049
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/websocket.js
|
|
2068
|
-
var require_websocket = /* @__PURE__ */
|
|
2050
|
+
var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2069
2051
|
const EventEmitter$1 = __require("events");
|
|
2070
2052
|
const https = __require("https");
|
|
2071
2053
|
const http$1 = __require("http");
|
|
@@ -2074,13 +2056,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2074
2056
|
const { randomBytes, createHash: createHash$1 } = __require("crypto");
|
|
2075
2057
|
const { Duplex: Duplex$2, Readable } = __require("stream");
|
|
2076
2058
|
const { URL } = __require("url");
|
|
2077
|
-
const PerMessageDeflate
|
|
2078
|
-
const Receiver
|
|
2079
|
-
const Sender
|
|
2059
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
2060
|
+
const Receiver = require_receiver();
|
|
2061
|
+
const Sender = require_sender();
|
|
2080
2062
|
const { isBlob } = require_validation();
|
|
2081
|
-
const { BINARY_TYPES, EMPTY_BUFFER, GUID
|
|
2063
|
+
const { BINARY_TYPES, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = require_constants();
|
|
2082
2064
|
const { EventTarget: { addEventListener, removeEventListener } } = require_event_target();
|
|
2083
|
-
const { format, parse
|
|
2065
|
+
const { format, parse } = require_extension();
|
|
2084
2066
|
const { toBuffer } = require_buffer_util();
|
|
2085
2067
|
const closeTimeout = 30 * 1e3;
|
|
2086
2068
|
const kAborted = Symbol("kAborted");
|
|
@@ -2097,7 +2079,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2097
2079
|
*
|
|
2098
2080
|
* @extends EventEmitter
|
|
2099
2081
|
*/
|
|
2100
|
-
var WebSocket
|
|
2082
|
+
var WebSocket = class WebSocket extends EventEmitter$1 {
|
|
2101
2083
|
/**
|
|
2102
2084
|
* Create a new `WebSocket`.
|
|
2103
2085
|
*
|
|
@@ -2117,7 +2099,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2117
2099
|
this._extensions = {};
|
|
2118
2100
|
this._paused = false;
|
|
2119
2101
|
this._protocol = "";
|
|
2120
|
-
this._readyState = WebSocket
|
|
2102
|
+
this._readyState = WebSocket.CONNECTING;
|
|
2121
2103
|
this._receiver = null;
|
|
2122
2104
|
this._sender = null;
|
|
2123
2105
|
this._socket = null;
|
|
@@ -2232,7 +2214,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2232
2214
|
* @private
|
|
2233
2215
|
*/
|
|
2234
2216
|
setSocket(socket, head, options) {
|
|
2235
|
-
const receiver = new Receiver
|
|
2217
|
+
const receiver = new Receiver({
|
|
2236
2218
|
allowSynchronousEvents: options.allowSynchronousEvents,
|
|
2237
2219
|
binaryType: this.binaryType,
|
|
2238
2220
|
extensions: this._extensions,
|
|
@@ -2240,13 +2222,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2240
2222
|
maxPayload: options.maxPayload,
|
|
2241
2223
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2242
2224
|
});
|
|
2243
|
-
const sender = new Sender
|
|
2225
|
+
const sender = new Sender(socket, this._extensions, options.generateMask);
|
|
2244
2226
|
this._receiver = receiver;
|
|
2245
2227
|
this._sender = sender;
|
|
2246
2228
|
this._socket = socket;
|
|
2247
|
-
receiver[kWebSocket
|
|
2248
|
-
sender[kWebSocket
|
|
2249
|
-
socket[kWebSocket
|
|
2229
|
+
receiver[kWebSocket] = this;
|
|
2230
|
+
sender[kWebSocket] = this;
|
|
2231
|
+
socket[kWebSocket] = this;
|
|
2250
2232
|
receiver.on("conclude", receiverOnConclude);
|
|
2251
2233
|
receiver.on("drain", receiverOnDrain);
|
|
2252
2234
|
receiver.on("error", receiverOnError);
|
|
@@ -2260,8 +2242,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2260
2242
|
socket.on("close", socketOnClose);
|
|
2261
2243
|
socket.on("data", socketOnData);
|
|
2262
2244
|
socket.on("end", socketOnEnd);
|
|
2263
|
-
socket.on("error", socketOnError
|
|
2264
|
-
this._readyState = WebSocket
|
|
2245
|
+
socket.on("error", socketOnError);
|
|
2246
|
+
this._readyState = WebSocket.OPEN;
|
|
2265
2247
|
this.emit("open");
|
|
2266
2248
|
}
|
|
2267
2249
|
/**
|
|
@@ -2271,13 +2253,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2271
2253
|
*/
|
|
2272
2254
|
emitClose() {
|
|
2273
2255
|
if (!this._socket) {
|
|
2274
|
-
this._readyState = WebSocket
|
|
2256
|
+
this._readyState = WebSocket.CLOSED;
|
|
2275
2257
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2276
2258
|
return;
|
|
2277
2259
|
}
|
|
2278
|
-
if (this._extensions[PerMessageDeflate
|
|
2260
|
+
if (this._extensions[PerMessageDeflate.extensionName]) this._extensions[PerMessageDeflate.extensionName].cleanup();
|
|
2279
2261
|
this._receiver.removeAllListeners();
|
|
2280
|
-
this._readyState = WebSocket
|
|
2262
|
+
this._readyState = WebSocket.CLOSED;
|
|
2281
2263
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2282
2264
|
}
|
|
2283
2265
|
/**
|
|
@@ -2301,16 +2283,16 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2301
2283
|
* @public
|
|
2302
2284
|
*/
|
|
2303
2285
|
close(code, data) {
|
|
2304
|
-
if (this.readyState === WebSocket
|
|
2305
|
-
if (this.readyState === WebSocket
|
|
2306
|
-
abortHandshake
|
|
2286
|
+
if (this.readyState === WebSocket.CLOSED) return;
|
|
2287
|
+
if (this.readyState === WebSocket.CONNECTING) {
|
|
2288
|
+
abortHandshake(this, this._req, "WebSocket was closed before the connection was established");
|
|
2307
2289
|
return;
|
|
2308
2290
|
}
|
|
2309
|
-
if (this.readyState === WebSocket
|
|
2291
|
+
if (this.readyState === WebSocket.CLOSING) {
|
|
2310
2292
|
if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) this._socket.end();
|
|
2311
2293
|
return;
|
|
2312
2294
|
}
|
|
2313
|
-
this._readyState = WebSocket
|
|
2295
|
+
this._readyState = WebSocket.CLOSING;
|
|
2314
2296
|
this._sender.close(code, data, !this._isServer, (err) => {
|
|
2315
2297
|
if (err) return;
|
|
2316
2298
|
this._closeFrameSent = true;
|
|
@@ -2324,7 +2306,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2324
2306
|
* @public
|
|
2325
2307
|
*/
|
|
2326
2308
|
pause() {
|
|
2327
|
-
if (this.readyState === WebSocket
|
|
2309
|
+
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;
|
|
2328
2310
|
this._paused = true;
|
|
2329
2311
|
this._socket.pause();
|
|
2330
2312
|
}
|
|
@@ -2337,7 +2319,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2337
2319
|
* @public
|
|
2338
2320
|
*/
|
|
2339
2321
|
ping(data, mask, cb) {
|
|
2340
|
-
if (this.readyState === WebSocket
|
|
2322
|
+
if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
2341
2323
|
if (typeof data === "function") {
|
|
2342
2324
|
cb = data;
|
|
2343
2325
|
data = mask = void 0;
|
|
@@ -2346,7 +2328,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2346
2328
|
mask = void 0;
|
|
2347
2329
|
}
|
|
2348
2330
|
if (typeof data === "number") data = data.toString();
|
|
2349
|
-
if (this.readyState !== WebSocket
|
|
2331
|
+
if (this.readyState !== WebSocket.OPEN) {
|
|
2350
2332
|
sendAfterClose(this, data, cb);
|
|
2351
2333
|
return;
|
|
2352
2334
|
}
|
|
@@ -2362,7 +2344,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2362
2344
|
* @public
|
|
2363
2345
|
*/
|
|
2364
2346
|
pong(data, mask, cb) {
|
|
2365
|
-
if (this.readyState === WebSocket
|
|
2347
|
+
if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
2366
2348
|
if (typeof data === "function") {
|
|
2367
2349
|
cb = data;
|
|
2368
2350
|
data = mask = void 0;
|
|
@@ -2371,7 +2353,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2371
2353
|
mask = void 0;
|
|
2372
2354
|
}
|
|
2373
2355
|
if (typeof data === "number") data = data.toString();
|
|
2374
|
-
if (this.readyState !== WebSocket
|
|
2356
|
+
if (this.readyState !== WebSocket.OPEN) {
|
|
2375
2357
|
sendAfterClose(this, data, cb);
|
|
2376
2358
|
return;
|
|
2377
2359
|
}
|
|
@@ -2384,7 +2366,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2384
2366
|
* @public
|
|
2385
2367
|
*/
|
|
2386
2368
|
resume() {
|
|
2387
|
-
if (this.readyState === WebSocket
|
|
2369
|
+
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;
|
|
2388
2370
|
this._paused = false;
|
|
2389
2371
|
if (!this._receiver._writableState.needDrain) this._socket.resume();
|
|
2390
2372
|
}
|
|
@@ -2404,13 +2386,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2404
2386
|
* @public
|
|
2405
2387
|
*/
|
|
2406
2388
|
send(data, options, cb) {
|
|
2407
|
-
if (this.readyState === WebSocket
|
|
2389
|
+
if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
2408
2390
|
if (typeof options === "function") {
|
|
2409
2391
|
cb = options;
|
|
2410
2392
|
options = {};
|
|
2411
2393
|
}
|
|
2412
2394
|
if (typeof data === "number") data = data.toString();
|
|
2413
|
-
if (this.readyState !== WebSocket
|
|
2395
|
+
if (this.readyState !== WebSocket.OPEN) {
|
|
2414
2396
|
sendAfterClose(this, data, cb);
|
|
2415
2397
|
return;
|
|
2416
2398
|
}
|
|
@@ -2421,7 +2403,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2421
2403
|
fin: true,
|
|
2422
2404
|
...options
|
|
2423
2405
|
};
|
|
2424
|
-
if (!this._extensions[PerMessageDeflate
|
|
2406
|
+
if (!this._extensions[PerMessageDeflate.extensionName]) opts.compress = false;
|
|
2425
2407
|
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
2426
2408
|
}
|
|
2427
2409
|
/**
|
|
@@ -2430,13 +2412,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2430
2412
|
* @public
|
|
2431
2413
|
*/
|
|
2432
2414
|
terminate() {
|
|
2433
|
-
if (this.readyState === WebSocket
|
|
2434
|
-
if (this.readyState === WebSocket
|
|
2435
|
-
abortHandshake
|
|
2415
|
+
if (this.readyState === WebSocket.CLOSED) return;
|
|
2416
|
+
if (this.readyState === WebSocket.CONNECTING) {
|
|
2417
|
+
abortHandshake(this, this._req, "WebSocket was closed before the connection was established");
|
|
2436
2418
|
return;
|
|
2437
2419
|
}
|
|
2438
2420
|
if (this._socket) {
|
|
2439
|
-
this._readyState = WebSocket
|
|
2421
|
+
this._readyState = WebSocket.CLOSING;
|
|
2440
2422
|
this._socket.destroy();
|
|
2441
2423
|
}
|
|
2442
2424
|
}
|
|
@@ -2445,7 +2427,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2445
2427
|
* @constant {Number} CONNECTING
|
|
2446
2428
|
* @memberof WebSocket
|
|
2447
2429
|
*/
|
|
2448
|
-
Object.defineProperty(WebSocket
|
|
2430
|
+
Object.defineProperty(WebSocket, "CONNECTING", {
|
|
2449
2431
|
enumerable: true,
|
|
2450
2432
|
value: readyStates.indexOf("CONNECTING")
|
|
2451
2433
|
});
|
|
@@ -2453,7 +2435,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2453
2435
|
* @constant {Number} CONNECTING
|
|
2454
2436
|
* @memberof WebSocket.prototype
|
|
2455
2437
|
*/
|
|
2456
|
-
Object.defineProperty(WebSocket
|
|
2438
|
+
Object.defineProperty(WebSocket.prototype, "CONNECTING", {
|
|
2457
2439
|
enumerable: true,
|
|
2458
2440
|
value: readyStates.indexOf("CONNECTING")
|
|
2459
2441
|
});
|
|
@@ -2461,7 +2443,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2461
2443
|
* @constant {Number} OPEN
|
|
2462
2444
|
* @memberof WebSocket
|
|
2463
2445
|
*/
|
|
2464
|
-
Object.defineProperty(WebSocket
|
|
2446
|
+
Object.defineProperty(WebSocket, "OPEN", {
|
|
2465
2447
|
enumerable: true,
|
|
2466
2448
|
value: readyStates.indexOf("OPEN")
|
|
2467
2449
|
});
|
|
@@ -2469,7 +2451,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2469
2451
|
* @constant {Number} OPEN
|
|
2470
2452
|
* @memberof WebSocket.prototype
|
|
2471
2453
|
*/
|
|
2472
|
-
Object.defineProperty(WebSocket
|
|
2454
|
+
Object.defineProperty(WebSocket.prototype, "OPEN", {
|
|
2473
2455
|
enumerable: true,
|
|
2474
2456
|
value: readyStates.indexOf("OPEN")
|
|
2475
2457
|
});
|
|
@@ -2477,7 +2459,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2477
2459
|
* @constant {Number} CLOSING
|
|
2478
2460
|
* @memberof WebSocket
|
|
2479
2461
|
*/
|
|
2480
|
-
Object.defineProperty(WebSocket
|
|
2462
|
+
Object.defineProperty(WebSocket, "CLOSING", {
|
|
2481
2463
|
enumerable: true,
|
|
2482
2464
|
value: readyStates.indexOf("CLOSING")
|
|
2483
2465
|
});
|
|
@@ -2485,7 +2467,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2485
2467
|
* @constant {Number} CLOSING
|
|
2486
2468
|
* @memberof WebSocket.prototype
|
|
2487
2469
|
*/
|
|
2488
|
-
Object.defineProperty(WebSocket
|
|
2470
|
+
Object.defineProperty(WebSocket.prototype, "CLOSING", {
|
|
2489
2471
|
enumerable: true,
|
|
2490
2472
|
value: readyStates.indexOf("CLOSING")
|
|
2491
2473
|
});
|
|
@@ -2493,7 +2475,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2493
2475
|
* @constant {Number} CLOSED
|
|
2494
2476
|
* @memberof WebSocket
|
|
2495
2477
|
*/
|
|
2496
|
-
Object.defineProperty(WebSocket
|
|
2478
|
+
Object.defineProperty(WebSocket, "CLOSED", {
|
|
2497
2479
|
enumerable: true,
|
|
2498
2480
|
value: readyStates.indexOf("CLOSED")
|
|
2499
2481
|
});
|
|
@@ -2501,7 +2483,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2501
2483
|
* @constant {Number} CLOSED
|
|
2502
2484
|
* @memberof WebSocket.prototype
|
|
2503
2485
|
*/
|
|
2504
|
-
Object.defineProperty(WebSocket
|
|
2486
|
+
Object.defineProperty(WebSocket.prototype, "CLOSED", {
|
|
2505
2487
|
enumerable: true,
|
|
2506
2488
|
value: readyStates.indexOf("CLOSED")
|
|
2507
2489
|
});
|
|
@@ -2514,7 +2496,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2514
2496
|
"readyState",
|
|
2515
2497
|
"url"
|
|
2516
2498
|
].forEach((property) => {
|
|
2517
|
-
Object.defineProperty(WebSocket
|
|
2499
|
+
Object.defineProperty(WebSocket.prototype, property, { enumerable: true });
|
|
2518
2500
|
});
|
|
2519
2501
|
[
|
|
2520
2502
|
"open",
|
|
@@ -2522,7 +2504,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2522
2504
|
"close",
|
|
2523
2505
|
"message"
|
|
2524
2506
|
].forEach((method) => {
|
|
2525
|
-
Object.defineProperty(WebSocket
|
|
2507
|
+
Object.defineProperty(WebSocket.prototype, `on${method}`, {
|
|
2526
2508
|
enumerable: true,
|
|
2527
2509
|
get() {
|
|
2528
2510
|
for (const listener of this.listeners(method)) if (listener[kForOnEventAttribute]) return listener[kListener];
|
|
@@ -2538,9 +2520,9 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2538
2520
|
}
|
|
2539
2521
|
});
|
|
2540
2522
|
});
|
|
2541
|
-
WebSocket
|
|
2542
|
-
WebSocket
|
|
2543
|
-
module.exports = WebSocket
|
|
2523
|
+
WebSocket.prototype.addEventListener = addEventListener;
|
|
2524
|
+
WebSocket.prototype.removeEventListener = removeEventListener;
|
|
2525
|
+
module.exports = WebSocket;
|
|
2544
2526
|
/**
|
|
2545
2527
|
* Initialize a WebSocket client.
|
|
2546
2528
|
*
|
|
@@ -2640,8 +2622,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2640
2622
|
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
2641
2623
|
opts.timeout = opts.handshakeTimeout;
|
|
2642
2624
|
if (opts.perMessageDeflate) {
|
|
2643
|
-
perMessageDeflate = new PerMessageDeflate
|
|
2644
|
-
opts.headers["Sec-WebSocket-Extensions"] = format({ [PerMessageDeflate
|
|
2625
|
+
perMessageDeflate = new PerMessageDeflate(opts.perMessageDeflate !== true ? opts.perMessageDeflate : {}, false, opts.maxPayload);
|
|
2626
|
+
opts.headers["Sec-WebSocket-Extensions"] = format({ [PerMessageDeflate.extensionName]: perMessageDeflate.offer() });
|
|
2645
2627
|
}
|
|
2646
2628
|
if (protocols.length) {
|
|
2647
2629
|
for (const protocol of protocols) {
|
|
@@ -2684,7 +2666,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2684
2666
|
if (websocket._redirects) websocket.emit("redirect", websocket.url, req);
|
|
2685
2667
|
} else req = websocket._req = request(opts);
|
|
2686
2668
|
if (opts.timeout) req.on("timeout", () => {
|
|
2687
|
-
abortHandshake
|
|
2669
|
+
abortHandshake(websocket, req, "Opening handshake has timed out");
|
|
2688
2670
|
});
|
|
2689
2671
|
req.on("error", (err) => {
|
|
2690
2672
|
if (req === null || req[kAborted]) return;
|
|
@@ -2696,7 +2678,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2696
2678
|
const statusCode = res.statusCode;
|
|
2697
2679
|
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
2698
2680
|
if (++websocket._redirects > opts.maxRedirects) {
|
|
2699
|
-
abortHandshake
|
|
2681
|
+
abortHandshake(websocket, req, "Maximum redirects exceeded");
|
|
2700
2682
|
return;
|
|
2701
2683
|
}
|
|
2702
2684
|
req.abort();
|
|
@@ -2704,25 +2686,24 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2704
2686
|
try {
|
|
2705
2687
|
addr = new URL(location, address);
|
|
2706
2688
|
} catch (e) {
|
|
2707
|
-
|
|
2708
|
-
emitErrorAndClose(websocket, err);
|
|
2689
|
+
emitErrorAndClose(websocket, /* @__PURE__ */ new SyntaxError(`Invalid URL: ${location}`));
|
|
2709
2690
|
return;
|
|
2710
2691
|
}
|
|
2711
2692
|
initAsClient(websocket, addr, protocols, options);
|
|
2712
|
-
} else if (!websocket.emit("unexpected-response", req, res)) abortHandshake
|
|
2693
|
+
} else if (!websocket.emit("unexpected-response", req, res)) abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
|
|
2713
2694
|
});
|
|
2714
2695
|
req.on("upgrade", (res, socket, head) => {
|
|
2715
2696
|
websocket.emit("upgrade", res);
|
|
2716
|
-
if (websocket.readyState !== WebSocket
|
|
2697
|
+
if (websocket.readyState !== WebSocket.CONNECTING) return;
|
|
2717
2698
|
req = websocket._req = null;
|
|
2718
2699
|
const upgrade = res.headers.upgrade;
|
|
2719
2700
|
if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
|
|
2720
|
-
abortHandshake
|
|
2701
|
+
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
2721
2702
|
return;
|
|
2722
2703
|
}
|
|
2723
|
-
const digest = createHash$1("sha1").update(key + GUID
|
|
2704
|
+
const digest = createHash$1("sha1").update(key + GUID).digest("base64");
|
|
2724
2705
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
2725
|
-
abortHandshake
|
|
2706
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
2726
2707
|
return;
|
|
2727
2708
|
}
|
|
2728
2709
|
const serverProt = res.headers["sec-websocket-protocol"];
|
|
@@ -2732,35 +2713,35 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2732
2713
|
else if (!protocolSet.has(serverProt)) protError = "Server sent an invalid subprotocol";
|
|
2733
2714
|
} else if (protocolSet.size) protError = "Server sent no subprotocol";
|
|
2734
2715
|
if (protError) {
|
|
2735
|
-
abortHandshake
|
|
2716
|
+
abortHandshake(websocket, socket, protError);
|
|
2736
2717
|
return;
|
|
2737
2718
|
}
|
|
2738
2719
|
if (serverProt) websocket._protocol = serverProt;
|
|
2739
2720
|
const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
|
|
2740
2721
|
if (secWebSocketExtensions !== void 0) {
|
|
2741
2722
|
if (!perMessageDeflate) {
|
|
2742
|
-
abortHandshake
|
|
2723
|
+
abortHandshake(websocket, socket, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
|
2743
2724
|
return;
|
|
2744
2725
|
}
|
|
2745
2726
|
let extensions;
|
|
2746
2727
|
try {
|
|
2747
|
-
extensions = parse
|
|
2728
|
+
extensions = parse(secWebSocketExtensions);
|
|
2748
2729
|
} catch (err) {
|
|
2749
|
-
abortHandshake
|
|
2730
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Extensions header");
|
|
2750
2731
|
return;
|
|
2751
2732
|
}
|
|
2752
2733
|
const extensionNames = Object.keys(extensions);
|
|
2753
|
-
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate
|
|
2754
|
-
abortHandshake
|
|
2734
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
|
|
2735
|
+
abortHandshake(websocket, socket, "Server indicated an extension that was not requested");
|
|
2755
2736
|
return;
|
|
2756
2737
|
}
|
|
2757
2738
|
try {
|
|
2758
|
-
perMessageDeflate.accept(extensions[PerMessageDeflate
|
|
2739
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
|
|
2759
2740
|
} catch (err) {
|
|
2760
|
-
abortHandshake
|
|
2741
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Extensions header");
|
|
2761
2742
|
return;
|
|
2762
2743
|
}
|
|
2763
|
-
websocket._extensions[PerMessageDeflate
|
|
2744
|
+
websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
2764
2745
|
}
|
|
2765
2746
|
websocket.setSocket(socket, head, {
|
|
2766
2747
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
@@ -2780,7 +2761,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2780
2761
|
* @private
|
|
2781
2762
|
*/
|
|
2782
2763
|
function emitErrorAndClose(websocket, err) {
|
|
2783
|
-
websocket._readyState = WebSocket
|
|
2764
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2784
2765
|
websocket._errorEmitted = true;
|
|
2785
2766
|
websocket.emit("error", err);
|
|
2786
2767
|
websocket.emitClose();
|
|
@@ -2817,10 +2798,10 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2817
2798
|
* @param {String} message The error message
|
|
2818
2799
|
* @private
|
|
2819
2800
|
*/
|
|
2820
|
-
function abortHandshake
|
|
2821
|
-
websocket._readyState = WebSocket
|
|
2801
|
+
function abortHandshake(websocket, stream, message) {
|
|
2802
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2822
2803
|
const err = new Error(message);
|
|
2823
|
-
Error.captureStackTrace(err, abortHandshake
|
|
2804
|
+
Error.captureStackTrace(err, abortHandshake);
|
|
2824
2805
|
if (stream.setHeader) {
|
|
2825
2806
|
stream[kAborted] = true;
|
|
2826
2807
|
stream.abort();
|
|
@@ -2860,11 +2841,11 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2860
2841
|
* @private
|
|
2861
2842
|
*/
|
|
2862
2843
|
function receiverOnConclude(code, reason) {
|
|
2863
|
-
const websocket = this[kWebSocket
|
|
2844
|
+
const websocket = this[kWebSocket];
|
|
2864
2845
|
websocket._closeFrameReceived = true;
|
|
2865
2846
|
websocket._closeMessage = reason;
|
|
2866
2847
|
websocket._closeCode = code;
|
|
2867
|
-
if (websocket._socket[kWebSocket
|
|
2848
|
+
if (websocket._socket[kWebSocket] === void 0) return;
|
|
2868
2849
|
websocket._socket.removeListener("data", socketOnData);
|
|
2869
2850
|
process.nextTick(resume, websocket._socket);
|
|
2870
2851
|
if (code === 1005) websocket.close();
|
|
@@ -2876,7 +2857,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2876
2857
|
* @private
|
|
2877
2858
|
*/
|
|
2878
2859
|
function receiverOnDrain() {
|
|
2879
|
-
const websocket = this[kWebSocket
|
|
2860
|
+
const websocket = this[kWebSocket];
|
|
2880
2861
|
if (!websocket.isPaused) websocket._socket.resume();
|
|
2881
2862
|
}
|
|
2882
2863
|
/**
|
|
@@ -2886,8 +2867,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2886
2867
|
* @private
|
|
2887
2868
|
*/
|
|
2888
2869
|
function receiverOnError(err) {
|
|
2889
|
-
const websocket = this[kWebSocket
|
|
2890
|
-
if (websocket._socket[kWebSocket
|
|
2870
|
+
const websocket = this[kWebSocket];
|
|
2871
|
+
if (websocket._socket[kWebSocket] !== void 0) {
|
|
2891
2872
|
websocket._socket.removeListener("data", socketOnData);
|
|
2892
2873
|
process.nextTick(resume, websocket._socket);
|
|
2893
2874
|
websocket.close(err[kStatusCode]);
|
|
@@ -2903,7 +2884,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2903
2884
|
* @private
|
|
2904
2885
|
*/
|
|
2905
2886
|
function receiverOnFinish() {
|
|
2906
|
-
this[kWebSocket
|
|
2887
|
+
this[kWebSocket].emitClose();
|
|
2907
2888
|
}
|
|
2908
2889
|
/**
|
|
2909
2890
|
* The listener of the `Receiver` `'message'` event.
|
|
@@ -2913,7 +2894,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2913
2894
|
* @private
|
|
2914
2895
|
*/
|
|
2915
2896
|
function receiverOnMessage(data, isBinary) {
|
|
2916
|
-
this[kWebSocket
|
|
2897
|
+
this[kWebSocket].emit("message", data, isBinary);
|
|
2917
2898
|
}
|
|
2918
2899
|
/**
|
|
2919
2900
|
* The listener of the `Receiver` `'ping'` event.
|
|
@@ -2922,8 +2903,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2922
2903
|
* @private
|
|
2923
2904
|
*/
|
|
2924
2905
|
function receiverOnPing(data) {
|
|
2925
|
-
const websocket = this[kWebSocket
|
|
2926
|
-
if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP
|
|
2906
|
+
const websocket = this[kWebSocket];
|
|
2907
|
+
if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
|
|
2927
2908
|
websocket.emit("ping", data);
|
|
2928
2909
|
}
|
|
2929
2910
|
/**
|
|
@@ -2933,7 +2914,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2933
2914
|
* @private
|
|
2934
2915
|
*/
|
|
2935
2916
|
function receiverOnPong(data) {
|
|
2936
|
-
this[kWebSocket
|
|
2917
|
+
this[kWebSocket].emit("pong", data);
|
|
2937
2918
|
}
|
|
2938
2919
|
/**
|
|
2939
2920
|
* Resume a readable stream
|
|
@@ -2951,10 +2932,10 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2951
2932
|
* @private
|
|
2952
2933
|
*/
|
|
2953
2934
|
function senderOnError(err) {
|
|
2954
|
-
const websocket = this[kWebSocket
|
|
2955
|
-
if (websocket.readyState === WebSocket
|
|
2956
|
-
if (websocket.readyState === WebSocket
|
|
2957
|
-
websocket._readyState = WebSocket
|
|
2935
|
+
const websocket = this[kWebSocket];
|
|
2936
|
+
if (websocket.readyState === WebSocket.CLOSED) return;
|
|
2937
|
+
if (websocket.readyState === WebSocket.OPEN) {
|
|
2938
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2958
2939
|
setCloseTimer(websocket);
|
|
2959
2940
|
}
|
|
2960
2941
|
this._socket.end();
|
|
@@ -2978,15 +2959,15 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
2978
2959
|
* @private
|
|
2979
2960
|
*/
|
|
2980
2961
|
function socketOnClose() {
|
|
2981
|
-
const websocket = this[kWebSocket
|
|
2962
|
+
const websocket = this[kWebSocket];
|
|
2982
2963
|
this.removeListener("close", socketOnClose);
|
|
2983
2964
|
this.removeListener("data", socketOnData);
|
|
2984
2965
|
this.removeListener("end", socketOnEnd);
|
|
2985
|
-
websocket._readyState = WebSocket
|
|
2966
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2986
2967
|
let chunk;
|
|
2987
2968
|
if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk = websocket._socket.read()) !== null) websocket._receiver.write(chunk);
|
|
2988
2969
|
websocket._receiver.end();
|
|
2989
|
-
this[kWebSocket
|
|
2970
|
+
this[kWebSocket] = void 0;
|
|
2990
2971
|
clearTimeout(websocket._closeTimer);
|
|
2991
2972
|
if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) websocket.emitClose();
|
|
2992
2973
|
else {
|
|
@@ -3001,7 +2982,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
3001
2982
|
* @private
|
|
3002
2983
|
*/
|
|
3003
2984
|
function socketOnData(chunk) {
|
|
3004
|
-
if (!this[kWebSocket
|
|
2985
|
+
if (!this[kWebSocket]._receiver.write(chunk)) this.pause();
|
|
3005
2986
|
}
|
|
3006
2987
|
/**
|
|
3007
2988
|
* The listener of the socket `'end'` event.
|
|
@@ -3009,8 +2990,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
3009
2990
|
* @private
|
|
3010
2991
|
*/
|
|
3011
2992
|
function socketOnEnd() {
|
|
3012
|
-
const websocket = this[kWebSocket
|
|
3013
|
-
websocket._readyState = WebSocket
|
|
2993
|
+
const websocket = this[kWebSocket];
|
|
2994
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
3014
2995
|
websocket._receiver.end();
|
|
3015
2996
|
this.end();
|
|
3016
2997
|
}
|
|
@@ -3019,20 +3000,20 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/w
|
|
|
3019
3000
|
*
|
|
3020
3001
|
* @private
|
|
3021
3002
|
*/
|
|
3022
|
-
function socketOnError
|
|
3023
|
-
const websocket = this[kWebSocket
|
|
3024
|
-
this.removeListener("error", socketOnError
|
|
3025
|
-
this.on("error", NOOP
|
|
3003
|
+
function socketOnError() {
|
|
3004
|
+
const websocket = this[kWebSocket];
|
|
3005
|
+
this.removeListener("error", socketOnError);
|
|
3006
|
+
this.on("error", NOOP);
|
|
3026
3007
|
if (websocket) {
|
|
3027
|
-
websocket._readyState = WebSocket
|
|
3008
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
3028
3009
|
this.destroy();
|
|
3029
3010
|
}
|
|
3030
3011
|
}
|
|
3031
|
-
})
|
|
3012
|
+
}));
|
|
3032
3013
|
|
|
3033
3014
|
//#endregion
|
|
3034
3015
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/stream.js
|
|
3035
|
-
var require_stream = /* @__PURE__ */
|
|
3016
|
+
var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3036
3017
|
require_websocket();
|
|
3037
3018
|
const { Duplex: Duplex$1 } = __require("stream");
|
|
3038
3019
|
/**
|
|
@@ -3041,7 +3022,7 @@ var require_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
3041
3022
|
* @param {Duplex} stream The stream.
|
|
3042
3023
|
* @private
|
|
3043
3024
|
*/
|
|
3044
|
-
function emitClose
|
|
3025
|
+
function emitClose(stream) {
|
|
3045
3026
|
stream.emit("close");
|
|
3046
3027
|
}
|
|
3047
3028
|
/**
|
|
@@ -3071,7 +3052,7 @@ var require_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
3071
3052
|
* @return {Duplex} The duplex stream
|
|
3072
3053
|
* @public
|
|
3073
3054
|
*/
|
|
3074
|
-
function createWebSocketStream
|
|
3055
|
+
function createWebSocketStream(ws, options) {
|
|
3075
3056
|
let terminateOnDestroy = true;
|
|
3076
3057
|
const duplex = new Duplex$1({
|
|
3077
3058
|
...options,
|
|
@@ -3096,7 +3077,7 @@ var require_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
3096
3077
|
duplex._destroy = function(err, callback) {
|
|
3097
3078
|
if (ws.readyState === ws.CLOSED) {
|
|
3098
3079
|
callback(err);
|
|
3099
|
-
process.nextTick(emitClose
|
|
3080
|
+
process.nextTick(emitClose, duplex);
|
|
3100
3081
|
return;
|
|
3101
3082
|
}
|
|
3102
3083
|
let called = false;
|
|
@@ -3106,7 +3087,7 @@ var require_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
3106
3087
|
});
|
|
3107
3088
|
ws.once("close", function close() {
|
|
3108
3089
|
if (!called) callback(err);
|
|
3109
|
-
process.nextTick(emitClose
|
|
3090
|
+
process.nextTick(emitClose, duplex);
|
|
3110
3091
|
});
|
|
3111
3092
|
if (terminateOnDestroy) ws.terminate();
|
|
3112
3093
|
};
|
|
@@ -3144,12 +3125,12 @@ var require_stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ws@8
|
|
|
3144
3125
|
duplex.on("error", duplexOnError);
|
|
3145
3126
|
return duplex;
|
|
3146
3127
|
}
|
|
3147
|
-
module.exports = createWebSocketStream
|
|
3148
|
-
})
|
|
3128
|
+
module.exports = createWebSocketStream;
|
|
3129
|
+
}));
|
|
3149
3130
|
|
|
3150
3131
|
//#endregion
|
|
3151
3132
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/subprotocol.js
|
|
3152
|
-
var require_subprotocol = /* @__PURE__ */
|
|
3133
|
+
var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3153
3134
|
const { tokenChars } = require_validation();
|
|
3154
3135
|
/**
|
|
3155
3136
|
* Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.
|
|
@@ -3158,7 +3139,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
|
|
|
3158
3139
|
* @return {Set} The subprotocol names
|
|
3159
3140
|
* @public
|
|
3160
3141
|
*/
|
|
3161
|
-
function parse
|
|
3142
|
+
function parse(header) {
|
|
3162
3143
|
const protocols = /* @__PURE__ */ new Set();
|
|
3163
3144
|
let start = -1;
|
|
3164
3145
|
let end = -1;
|
|
@@ -3184,12 +3165,12 @@ var require_subprotocol = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
|
|
|
3184
3165
|
protocols.add(protocol);
|
|
3185
3166
|
return protocols;
|
|
3186
3167
|
}
|
|
3187
|
-
module.exports = { parse
|
|
3188
|
-
})
|
|
3168
|
+
module.exports = { parse };
|
|
3169
|
+
}));
|
|
3189
3170
|
|
|
3190
3171
|
//#endregion
|
|
3191
3172
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/websocket-server.js
|
|
3192
|
-
var require_websocket_server = /* @__PURE__ */
|
|
3173
|
+
var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3193
3174
|
const EventEmitter = __require("events");
|
|
3194
3175
|
const http = __require("http");
|
|
3195
3176
|
const { Duplex } = __require("stream");
|
|
@@ -3197,7 +3178,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "../../node_modules/
|
|
|
3197
3178
|
const extension = require_extension();
|
|
3198
3179
|
const PerMessageDeflate = require_permessage_deflate();
|
|
3199
3180
|
const subprotocol = require_subprotocol();
|
|
3200
|
-
const WebSocket
|
|
3181
|
+
const WebSocket = require_websocket();
|
|
3201
3182
|
const { GUID, kWebSocket } = require_constants();
|
|
3202
3183
|
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
3203
3184
|
const RUNNING = 0;
|
|
@@ -3208,7 +3189,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "../../node_modules/
|
|
|
3208
3189
|
*
|
|
3209
3190
|
* @extends EventEmitter
|
|
3210
3191
|
*/
|
|
3211
|
-
var WebSocketServer
|
|
3192
|
+
var WebSocketServer = class extends EventEmitter {
|
|
3212
3193
|
/**
|
|
3213
3194
|
* Create a `WebSocketServer` instance.
|
|
3214
3195
|
*
|
|
@@ -3257,7 +3238,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "../../node_modules/
|
|
|
3257
3238
|
host: null,
|
|
3258
3239
|
path: null,
|
|
3259
3240
|
port: null,
|
|
3260
|
-
WebSocket
|
|
3241
|
+
WebSocket,
|
|
3261
3242
|
...options
|
|
3262
3243
|
};
|
|
3263
3244
|
if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) throw new TypeError("One and only one of the \"port\", \"server\", or \"noServer\" options must be specified");
|
|
@@ -3482,7 +3463,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "../../node_modules/
|
|
|
3482
3463
|
cb(ws, req);
|
|
3483
3464
|
}
|
|
3484
3465
|
};
|
|
3485
|
-
module.exports = WebSocketServer
|
|
3466
|
+
module.exports = WebSocketServer;
|
|
3486
3467
|
/**
|
|
3487
3468
|
* Add event listeners on an `EventEmitter` using a map of <event, listener>
|
|
3488
3469
|
* pairs.
|
|
@@ -3556,7 +3537,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "../../node_modules/
|
|
|
3556
3537
|
server.emit("wsClientError", err, socket, req);
|
|
3557
3538
|
} else abortHandshake(socket, code, message, headers);
|
|
3558
3539
|
}
|
|
3559
|
-
})
|
|
3540
|
+
}));
|
|
3560
3541
|
|
|
3561
3542
|
//#endregion
|
|
3562
3543
|
//#region ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/wrapper.mjs
|
|
@@ -3568,13 +3549,21 @@ var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server()
|
|
|
3568
3549
|
|
|
3569
3550
|
//#endregion
|
|
3570
3551
|
//#region src/presets/ws/server.ts
|
|
3552
|
+
let id = 0;
|
|
3571
3553
|
function NOOP() {}
|
|
3572
3554
|
const createWsRpcPreset = defineRpcServerPreset((options) => {
|
|
3573
|
-
const { port, onConnected = NOOP, onDisconnected = NOOP } = options;
|
|
3574
|
-
const wss = new import_websocket_server.default({
|
|
3555
|
+
const { port, host = "localhost", onConnected = NOOP, onDisconnected = NOOP } = options;
|
|
3556
|
+
const wss = new import_websocket_server.default({
|
|
3557
|
+
port,
|
|
3558
|
+
host
|
|
3559
|
+
});
|
|
3575
3560
|
return (rpc, options$1) => {
|
|
3576
3561
|
const { serialize = stringify, deserialize = parse } = options$1 ?? {};
|
|
3577
3562
|
wss.on("connection", (ws) => {
|
|
3563
|
+
const meta = {
|
|
3564
|
+
id: id++,
|
|
3565
|
+
ws
|
|
3566
|
+
};
|
|
3578
3567
|
const channel = {
|
|
3579
3568
|
post: (data) => {
|
|
3580
3569
|
ws.send(data);
|
|
@@ -3585,7 +3574,8 @@ const createWsRpcPreset = defineRpcServerPreset((options) => {
|
|
|
3585
3574
|
});
|
|
3586
3575
|
},
|
|
3587
3576
|
serialize,
|
|
3588
|
-
deserialize
|
|
3577
|
+
deserialize,
|
|
3578
|
+
meta
|
|
3589
3579
|
};
|
|
3590
3580
|
rpc.updateChannels((channels) => {
|
|
3591
3581
|
channels.push(channel);
|
|
@@ -3595,9 +3585,9 @@ const createWsRpcPreset = defineRpcServerPreset((options) => {
|
|
|
3595
3585
|
const index = channels.indexOf(channel);
|
|
3596
3586
|
if (index >= 0) channels.splice(index, 1);
|
|
3597
3587
|
});
|
|
3598
|
-
onDisconnected(ws);
|
|
3588
|
+
onDisconnected(ws, meta);
|
|
3599
3589
|
});
|
|
3600
|
-
onConnected(ws);
|
|
3590
|
+
onConnected(ws, meta);
|
|
3601
3591
|
});
|
|
3602
3592
|
};
|
|
3603
3593
|
});
|