github-router 0.3.240 → 0.3.241
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/browser-bridge/index.js +357 -369
- package/dist/browser-ext/background.js +2 -2
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/browser-ext/snapshot-cdp.js +1 -1
- package/dist/engine-DL15-epb.js +2 -0
- package/dist/lib/tree-sitter-pool/worker.js +36 -31
- package/dist/lifecycle-0rXrwjWk.js +2 -0
- package/dist/{lifecycle-Cuuj40CW.js → lifecycle-CUf1UDrH.js} +37 -17
- package/dist/lifecycle-CUf1UDrH.js.map +1 -0
- package/dist/{lifecycle-C-9_vhyM.js → lifecycle-DHZsVN8j.js} +39 -16
- package/dist/lifecycle-DHZsVN8j.js.map +1 -0
- package/dist/lifecycle-hzPwXc3I.js +2 -0
- package/dist/main.js +840 -408
- package/dist/main.js.map +1 -1
- package/dist/{paths-Srxs-aR-.js → paths-BjTMI_xK.js} +155 -54
- package/dist/{paths-Srxs-aR-.js.map → paths-BjTMI_xK.js.map} +1 -1
- package/dist/paths-D3XgmTcQ.js +2 -0
- package/dist/{peer-mcp-personas-CDja7arT.js → peer-mcp-personas-r_UmLBkJ.js} +1850 -1206
- package/dist/peer-mcp-personas-r_UmLBkJ.js.map +1 -0
- package/package.json +21 -21
- package/dist/engine-5VxiBAdY.js +0 -6
- package/dist/lifecycle-C-9_vhyM.js.map +0 -1
- package/dist/lifecycle-Cuuj40CW.js.map +0 -1
- package/dist/lifecycle-DF2ygqz8.js +0 -4
- package/dist/lifecycle-wIIt0wGo.js +0 -4
- package/dist/paths-C75DZ_Y3.js +0 -3
- package/dist/peer-mcp-personas-CDja7arT.js.map +0 -1
|
@@ -5,17 +5,14 @@ import { createServer } from "node:http";
|
|
|
5
5
|
import { homedir, platform, tmpdir } from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import process$1 from "node:process";
|
|
8
|
-
|
|
9
|
-
//#region rolldown:runtime
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
10
9
|
var __create = Object.create;
|
|
11
10
|
var __defProp = Object.defineProperty;
|
|
12
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
13
|
var __getProtoOf = Object.getPrototypeOf;
|
|
15
14
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var
|
|
17
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
-
};
|
|
15
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
19
16
|
var __copyProps = (to, from, except, desc) => {
|
|
20
17
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
18
|
key = keys[i];
|
|
@@ -26,41 +23,39 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
23
|
}
|
|
27
24
|
return to;
|
|
28
25
|
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
30
27
|
value: mod,
|
|
31
28
|
enumerable: true
|
|
32
29
|
}) : target, mod));
|
|
33
|
-
var __require = /*
|
|
34
|
-
|
|
30
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
35
31
|
//#endregion
|
|
36
32
|
//#region node_modules/ws/lib/constants.js
|
|
37
|
-
var require_constants = /* @__PURE__ */
|
|
38
|
-
const BINARY_TYPES
|
|
33
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
34
|
+
const BINARY_TYPES = [
|
|
39
35
|
"nodebuffer",
|
|
40
36
|
"arraybuffer",
|
|
41
37
|
"fragments"
|
|
42
38
|
];
|
|
43
|
-
const hasBlob
|
|
44
|
-
if (hasBlob
|
|
39
|
+
const hasBlob = typeof Blob !== "undefined";
|
|
40
|
+
if (hasBlob) BINARY_TYPES.push("blob");
|
|
45
41
|
module.exports = {
|
|
46
|
-
BINARY_TYPES
|
|
42
|
+
BINARY_TYPES,
|
|
47
43
|
CLOSE_TIMEOUT: 3e4,
|
|
48
44
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
49
45
|
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
50
|
-
hasBlob
|
|
46
|
+
hasBlob,
|
|
51
47
|
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
|
52
48
|
kListener: Symbol("kListener"),
|
|
53
49
|
kStatusCode: Symbol("status-code"),
|
|
54
50
|
kWebSocket: Symbol("websocket"),
|
|
55
51
|
NOOP: () => {}
|
|
56
52
|
};
|
|
57
|
-
})
|
|
58
|
-
|
|
53
|
+
}));
|
|
59
54
|
//#endregion
|
|
60
55
|
//#region node_modules/ws/lib/buffer-util.js
|
|
61
|
-
var require_buffer_util = /* @__PURE__ */
|
|
62
|
-
const { EMPTY_BUFFER
|
|
63
|
-
const FastBuffer
|
|
56
|
+
var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
57
|
+
const { EMPTY_BUFFER } = require_constants();
|
|
58
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
64
59
|
/**
|
|
65
60
|
* Merges an array of buffers into a new buffer.
|
|
66
61
|
*
|
|
@@ -69,8 +64,8 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/buff
|
|
|
69
64
|
* @return {Buffer} The resulting buffer
|
|
70
65
|
* @public
|
|
71
66
|
*/
|
|
72
|
-
function concat
|
|
73
|
-
if (list.length === 0) return EMPTY_BUFFER
|
|
67
|
+
function concat(list, totalLength) {
|
|
68
|
+
if (list.length === 0) return EMPTY_BUFFER;
|
|
74
69
|
if (list.length === 1) return list[0];
|
|
75
70
|
const target = Buffer.allocUnsafe(totalLength);
|
|
76
71
|
let offset = 0;
|
|
@@ -79,7 +74,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/buff
|
|
|
79
74
|
target.set(buf, offset);
|
|
80
75
|
offset += buf.length;
|
|
81
76
|
}
|
|
82
|
-
if (offset < totalLength) return new FastBuffer
|
|
77
|
+
if (offset < totalLength) return new FastBuffer(target.buffer, target.byteOffset, offset);
|
|
83
78
|
return target;
|
|
84
79
|
}
|
|
85
80
|
/**
|
|
@@ -112,7 +107,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/buff
|
|
|
112
107
|
* @return {ArrayBuffer} Converted buffer
|
|
113
108
|
* @public
|
|
114
109
|
*/
|
|
115
|
-
function toArrayBuffer
|
|
110
|
+
function toArrayBuffer(buf) {
|
|
116
111
|
if (buf.length === buf.buffer.byteLength) return buf.buffer;
|
|
117
112
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
118
113
|
}
|
|
@@ -124,49 +119,48 @@ var require_buffer_util = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/buff
|
|
|
124
119
|
* @throws {TypeError}
|
|
125
120
|
* @public
|
|
126
121
|
*/
|
|
127
|
-
function toBuffer
|
|
128
|
-
toBuffer
|
|
122
|
+
function toBuffer(data) {
|
|
123
|
+
toBuffer.readOnly = true;
|
|
129
124
|
if (Buffer.isBuffer(data)) return data;
|
|
130
125
|
let buf;
|
|
131
|
-
if (data instanceof ArrayBuffer) buf = new FastBuffer
|
|
132
|
-
else if (ArrayBuffer.isView(data)) buf = new FastBuffer
|
|
126
|
+
if (data instanceof ArrayBuffer) buf = new FastBuffer(data);
|
|
127
|
+
else if (ArrayBuffer.isView(data)) buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
|
|
133
128
|
else {
|
|
134
129
|
buf = Buffer.from(data);
|
|
135
|
-
toBuffer
|
|
130
|
+
toBuffer.readOnly = false;
|
|
136
131
|
}
|
|
137
132
|
return buf;
|
|
138
133
|
}
|
|
139
134
|
module.exports = {
|
|
140
|
-
concat
|
|
135
|
+
concat,
|
|
141
136
|
mask: _mask,
|
|
142
|
-
toArrayBuffer
|
|
143
|
-
toBuffer
|
|
137
|
+
toArrayBuffer,
|
|
138
|
+
toBuffer,
|
|
144
139
|
unmask: _unmask
|
|
145
140
|
};
|
|
146
141
|
/* istanbul ignore else */
|
|
147
142
|
if (!process.env.WS_NO_BUFFER_UTIL) try {
|
|
148
|
-
const bufferUtil
|
|
143
|
+
const bufferUtil = __require("bufferutil");
|
|
149
144
|
module.exports.mask = function(source, mask, output, offset, length) {
|
|
150
145
|
if (length < 48) _mask(source, mask, output, offset, length);
|
|
151
|
-
else bufferUtil
|
|
146
|
+
else bufferUtil.mask(source, mask, output, offset, length);
|
|
152
147
|
};
|
|
153
148
|
module.exports.unmask = function(buffer, mask) {
|
|
154
149
|
if (buffer.length < 32) _unmask(buffer, mask);
|
|
155
|
-
else bufferUtil
|
|
150
|
+
else bufferUtil.unmask(buffer, mask);
|
|
156
151
|
};
|
|
157
152
|
} catch (e) {}
|
|
158
|
-
})
|
|
159
|
-
|
|
153
|
+
}));
|
|
160
154
|
//#endregion
|
|
161
155
|
//#region node_modules/ws/lib/limiter.js
|
|
162
|
-
var require_limiter = /* @__PURE__ */
|
|
156
|
+
var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
163
157
|
const kDone = Symbol("kDone");
|
|
164
158
|
const kRun = Symbol("kRun");
|
|
165
159
|
/**
|
|
166
160
|
* A very simple job queue with adjustable concurrency. Adapted from
|
|
167
161
|
* https://github.com/STRML/async-limiter
|
|
168
162
|
*/
|
|
169
|
-
var Limiter
|
|
163
|
+
var Limiter = class {
|
|
170
164
|
/**
|
|
171
165
|
* Creates a new `Limiter`.
|
|
172
166
|
*
|
|
@@ -206,17 +200,16 @@ var require_limiter = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/limiter.
|
|
|
206
200
|
}
|
|
207
201
|
}
|
|
208
202
|
};
|
|
209
|
-
module.exports = Limiter
|
|
210
|
-
})
|
|
211
|
-
|
|
203
|
+
module.exports = Limiter;
|
|
204
|
+
}));
|
|
212
205
|
//#endregion
|
|
213
206
|
//#region node_modules/ws/lib/permessage-deflate.js
|
|
214
|
-
var require_permessage_deflate = /* @__PURE__ */
|
|
207
|
+
var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
215
208
|
const zlib = __require("zlib");
|
|
216
209
|
const bufferUtil = require_buffer_util();
|
|
217
210
|
const Limiter = require_limiter();
|
|
218
|
-
const { kStatusCode
|
|
219
|
-
const FastBuffer
|
|
211
|
+
const { kStatusCode } = require_constants();
|
|
212
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
220
213
|
const TRAILER = Buffer.from([
|
|
221
214
|
0,
|
|
222
215
|
0,
|
|
@@ -227,12 +220,12 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
227
220
|
const kTotalLength = Symbol("total-length");
|
|
228
221
|
const kCallback = Symbol("callback");
|
|
229
222
|
const kBuffers = Symbol("buffers");
|
|
230
|
-
const kError
|
|
223
|
+
const kError = Symbol("error");
|
|
231
224
|
let zlibLimiter;
|
|
232
225
|
/**
|
|
233
226
|
* permessage-deflate implementation.
|
|
234
227
|
*/
|
|
235
|
-
var PerMessageDeflate
|
|
228
|
+
var PerMessageDeflate = class {
|
|
236
229
|
/**
|
|
237
230
|
* Creates a PerMessageDeflate instance.
|
|
238
231
|
*
|
|
@@ -265,7 +258,10 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
265
258
|
this._deflate = null;
|
|
266
259
|
this._inflate = null;
|
|
267
260
|
this.params = null;
|
|
268
|
-
if (!zlibLimiter)
|
|
261
|
+
if (!zlibLimiter) {
|
|
262
|
+
const concurrency = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
|
|
263
|
+
zlibLimiter = new Limiter(concurrency);
|
|
264
|
+
}
|
|
269
265
|
}
|
|
270
266
|
/**
|
|
271
267
|
* @type {String}
|
|
@@ -443,14 +439,14 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
443
439
|
this._inflate.write(data);
|
|
444
440
|
if (fin) this._inflate.write(TRAILER);
|
|
445
441
|
this._inflate.flush(() => {
|
|
446
|
-
const err = this._inflate[kError
|
|
442
|
+
const err = this._inflate[kError];
|
|
447
443
|
if (err) {
|
|
448
444
|
this._inflate.close();
|
|
449
445
|
this._inflate = null;
|
|
450
446
|
callback(err);
|
|
451
447
|
return;
|
|
452
448
|
}
|
|
453
|
-
const data
|
|
449
|
+
const data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
|
|
454
450
|
if (this._inflate._readableState.endEmitted) {
|
|
455
451
|
this._inflate.close();
|
|
456
452
|
this._inflate = null;
|
|
@@ -459,7 +455,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
459
455
|
this._inflate[kBuffers] = [];
|
|
460
456
|
if (fin && this.params[`${endpoint}_no_context_takeover`]) this._inflate.reset();
|
|
461
457
|
}
|
|
462
|
-
callback(null, data
|
|
458
|
+
callback(null, data);
|
|
463
459
|
});
|
|
464
460
|
}
|
|
465
461
|
/**
|
|
@@ -487,17 +483,17 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
487
483
|
this._deflate.write(data);
|
|
488
484
|
this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
|
|
489
485
|
if (!this._deflate) return;
|
|
490
|
-
let data
|
|
491
|
-
if (fin) data
|
|
486
|
+
let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
487
|
+
if (fin) data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);
|
|
492
488
|
this._deflate[kCallback] = null;
|
|
493
489
|
this._deflate[kTotalLength] = 0;
|
|
494
490
|
this._deflate[kBuffers] = [];
|
|
495
491
|
if (fin && this.params[`${endpoint}_no_context_takeover`]) this._deflate.reset();
|
|
496
|
-
callback(null, data
|
|
492
|
+
callback(null, data);
|
|
497
493
|
});
|
|
498
494
|
}
|
|
499
495
|
};
|
|
500
|
-
module.exports = PerMessageDeflate
|
|
496
|
+
module.exports = PerMessageDeflate;
|
|
501
497
|
/**
|
|
502
498
|
* The listener of the `zlib.DeflateRaw` stream `'data'` event.
|
|
503
499
|
*
|
|
@@ -520,9 +516,9 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
520
516
|
this[kBuffers].push(chunk);
|
|
521
517
|
return;
|
|
522
518
|
}
|
|
523
|
-
this[kError
|
|
524
|
-
this[kError
|
|
525
|
-
this[kError
|
|
519
|
+
this[kError] = /* @__PURE__ */ new RangeError("Max payload size exceeded");
|
|
520
|
+
this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
|
|
521
|
+
this[kError][kStatusCode] = 1009;
|
|
526
522
|
this.removeListener("data", inflateOnData);
|
|
527
523
|
this.reset();
|
|
528
524
|
}
|
|
@@ -534,21 +530,20 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJS({ "node_modules/ws/l
|
|
|
534
530
|
*/
|
|
535
531
|
function inflateOnError(err) {
|
|
536
532
|
this[kPerMessageDeflate]._inflate = null;
|
|
537
|
-
if (this[kError
|
|
538
|
-
this[kCallback](this[kError
|
|
533
|
+
if (this[kError]) {
|
|
534
|
+
this[kCallback](this[kError]);
|
|
539
535
|
return;
|
|
540
536
|
}
|
|
541
|
-
err[kStatusCode
|
|
537
|
+
err[kStatusCode] = 1007;
|
|
542
538
|
this[kCallback](err);
|
|
543
539
|
}
|
|
544
|
-
})
|
|
545
|
-
|
|
540
|
+
}));
|
|
546
541
|
//#endregion
|
|
547
542
|
//#region node_modules/ws/lib/validation.js
|
|
548
|
-
var require_validation = /* @__PURE__ */
|
|
543
|
+
var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
549
544
|
const { isUtf8 } = __require("buffer");
|
|
550
545
|
const { hasBlob } = require_constants();
|
|
551
|
-
const tokenChars
|
|
546
|
+
const tokenChars = [
|
|
552
547
|
0,
|
|
553
548
|
0,
|
|
554
549
|
0,
|
|
@@ -685,7 +680,7 @@ var require_validation = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/valid
|
|
|
685
680
|
* @return {Boolean} `true` if the status code is valid, else `false`
|
|
686
681
|
* @public
|
|
687
682
|
*/
|
|
688
|
-
function isValidStatusCode
|
|
683
|
+
function isValidStatusCode(code) {
|
|
689
684
|
return code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;
|
|
690
685
|
}
|
|
691
686
|
/**
|
|
@@ -720,34 +715,33 @@ var require_validation = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/valid
|
|
|
720
715
|
* @return {Boolean} `true` if `value` is a `Blob`, else `false`
|
|
721
716
|
* @private
|
|
722
717
|
*/
|
|
723
|
-
function isBlob
|
|
718
|
+
function isBlob(value) {
|
|
724
719
|
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");
|
|
725
720
|
}
|
|
726
721
|
module.exports = {
|
|
727
|
-
isBlob
|
|
728
|
-
isValidStatusCode
|
|
722
|
+
isBlob,
|
|
723
|
+
isValidStatusCode,
|
|
729
724
|
isValidUTF8: _isValidUTF8,
|
|
730
|
-
tokenChars
|
|
725
|
+
tokenChars
|
|
731
726
|
};
|
|
732
727
|
if (isUtf8) module.exports.isValidUTF8 = function(buf) {
|
|
733
728
|
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
734
729
|
};
|
|
735
730
|
else if (!process.env.WS_NO_UTF_8_VALIDATE) try {
|
|
736
|
-
const isValidUTF8
|
|
731
|
+
const isValidUTF8 = __require("utf-8-validate");
|
|
737
732
|
module.exports.isValidUTF8 = function(buf) {
|
|
738
|
-
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8
|
|
733
|
+
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
739
734
|
};
|
|
740
735
|
} catch (e) {}
|
|
741
|
-
})
|
|
742
|
-
|
|
736
|
+
}));
|
|
743
737
|
//#endregion
|
|
744
738
|
//#region node_modules/ws/lib/receiver.js
|
|
745
|
-
var require_receiver = /* @__PURE__ */
|
|
739
|
+
var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
746
740
|
const { Writable } = __require("stream");
|
|
747
|
-
const PerMessageDeflate
|
|
748
|
-
const { BINARY_TYPES
|
|
741
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
742
|
+
const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = require_constants();
|
|
749
743
|
const { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
750
|
-
const { isValidStatusCode
|
|
744
|
+
const { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
751
745
|
const FastBuffer = Buffer[Symbol.species];
|
|
752
746
|
const GET_INFO = 0;
|
|
753
747
|
const GET_PAYLOAD_LENGTH_16 = 1;
|
|
@@ -761,7 +755,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
761
755
|
*
|
|
762
756
|
* @extends Writable
|
|
763
757
|
*/
|
|
764
|
-
var Receiver
|
|
758
|
+
var Receiver = class extends Writable {
|
|
765
759
|
/**
|
|
766
760
|
* Creates a Receiver instance.
|
|
767
761
|
*
|
|
@@ -785,14 +779,14 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
785
779
|
constructor(options = {}) {
|
|
786
780
|
super();
|
|
787
781
|
this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
|
|
788
|
-
this._binaryType = options.binaryType || BINARY_TYPES
|
|
782
|
+
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
789
783
|
this._extensions = options.extensions || {};
|
|
790
784
|
this._isServer = !!options.isServer;
|
|
791
785
|
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
792
786
|
this._maxFragments = options.maxFragments | 0;
|
|
793
787
|
this._maxPayload = options.maxPayload | 0;
|
|
794
788
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
795
|
-
this[kWebSocket
|
|
789
|
+
this[kWebSocket] = void 0;
|
|
796
790
|
this._bufferedBytes = 0;
|
|
797
791
|
this._buffers = [];
|
|
798
792
|
this._compressed = false;
|
|
@@ -804,6 +798,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
804
798
|
this._opcode = 0;
|
|
805
799
|
this._totalPayloadLength = 0;
|
|
806
800
|
this._messageLength = 0;
|
|
801
|
+
this._numFragments = 0;
|
|
807
802
|
this._fragments = [];
|
|
808
803
|
this._errored = false;
|
|
809
804
|
this._loop = false;
|
|
@@ -905,7 +900,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
905
900
|
return;
|
|
906
901
|
}
|
|
907
902
|
const compressed = (buf[0] & 64) === 64;
|
|
908
|
-
if (compressed && !this._extensions[PerMessageDeflate
|
|
903
|
+
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
|
|
909
904
|
cb(this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
910
905
|
return;
|
|
911
906
|
}
|
|
@@ -1031,7 +1026,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1031
1026
|
* @private
|
|
1032
1027
|
*/
|
|
1033
1028
|
getData(cb) {
|
|
1034
|
-
let data = EMPTY_BUFFER
|
|
1029
|
+
let data = EMPTY_BUFFER;
|
|
1035
1030
|
if (this._payloadLength) {
|
|
1036
1031
|
if (this._bufferedBytes < this._payloadLength) {
|
|
1037
1032
|
this._loop = false;
|
|
@@ -1044,16 +1039,16 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1044
1039
|
this.controlMessage(data, cb);
|
|
1045
1040
|
return;
|
|
1046
1041
|
}
|
|
1042
|
+
if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
1043
|
+
cb(this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1047
1046
|
if (this._compressed) {
|
|
1048
1047
|
this._state = INFLATING;
|
|
1049
1048
|
this.decompress(data, cb);
|
|
1050
1049
|
return;
|
|
1051
1050
|
}
|
|
1052
1051
|
if (data.length) {
|
|
1053
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1054
|
-
cb(this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
|
|
1055
|
-
return;
|
|
1056
|
-
}
|
|
1057
1052
|
this._messageLength = this._totalPayloadLength;
|
|
1058
1053
|
this._fragments.push(data);
|
|
1059
1054
|
}
|
|
@@ -1067,7 +1062,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1067
1062
|
* @private
|
|
1068
1063
|
*/
|
|
1069
1064
|
decompress(data, cb) {
|
|
1070
|
-
this._extensions[PerMessageDeflate
|
|
1065
|
+
this._extensions[PerMessageDeflate.extensionName].decompress(data, this._fin, (err, buf) => {
|
|
1071
1066
|
if (err) return cb(err);
|
|
1072
1067
|
if (buf.length) {
|
|
1073
1068
|
this._messageLength += buf.length;
|
|
@@ -1075,10 +1070,6 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1075
1070
|
cb(this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
|
|
1076
1071
|
return;
|
|
1077
1072
|
}
|
|
1078
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1079
|
-
cb(this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
1073
|
this._fragments.push(buf);
|
|
1083
1074
|
}
|
|
1084
1075
|
this.dataMessage(cb);
|
|
@@ -1101,6 +1092,7 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1101
1092
|
this._totalPayloadLength = 0;
|
|
1102
1093
|
this._messageLength = 0;
|
|
1103
1094
|
this._fragmented = 0;
|
|
1095
|
+
this._numFragments = 0;
|
|
1104
1096
|
this._fragments = [];
|
|
1105
1097
|
if (this._opcode === 2) {
|
|
1106
1098
|
let data;
|
|
@@ -1149,11 +1141,11 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1149
1141
|
if (this._opcode === 8) {
|
|
1150
1142
|
if (data.length === 0) {
|
|
1151
1143
|
this._loop = false;
|
|
1152
|
-
this.emit("conclude", 1005, EMPTY_BUFFER
|
|
1144
|
+
this.emit("conclude", 1005, EMPTY_BUFFER);
|
|
1153
1145
|
this.end();
|
|
1154
1146
|
} else {
|
|
1155
1147
|
const code = data.readUInt16BE(0);
|
|
1156
|
-
if (!isValidStatusCode
|
|
1148
|
+
if (!isValidStatusCode(code)) {
|
|
1157
1149
|
cb(this.createError(RangeError, `invalid status code ${code}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE"));
|
|
1158
1150
|
return;
|
|
1159
1151
|
}
|
|
@@ -1199,35 +1191,31 @@ var require_receiver = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/receive
|
|
|
1199
1191
|
const err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
|
|
1200
1192
|
Error.captureStackTrace(err, this.createError);
|
|
1201
1193
|
err.code = errorCode;
|
|
1202
|
-
err[kStatusCode
|
|
1194
|
+
err[kStatusCode] = statusCode;
|
|
1203
1195
|
return err;
|
|
1204
1196
|
}
|
|
1205
1197
|
};
|
|
1206
|
-
module.exports = Receiver
|
|
1207
|
-
})
|
|
1208
|
-
|
|
1198
|
+
module.exports = Receiver;
|
|
1199
|
+
}));
|
|
1209
1200
|
//#endregion
|
|
1210
1201
|
//#region node_modules/ws/lib/sender.js
|
|
1211
|
-
var require_sender = /* @__PURE__ */
|
|
1202
|
+
var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1212
1203
|
const { Duplex: Duplex$3 } = __require("stream");
|
|
1213
1204
|
const { randomFillSync } = __require("crypto");
|
|
1214
1205
|
const { types: { isUint8Array } } = __require("util");
|
|
1215
|
-
const PerMessageDeflate
|
|
1216
|
-
const { EMPTY_BUFFER
|
|
1217
|
-
const { isBlob
|
|
1218
|
-
const { mask: applyMask, toBuffer
|
|
1206
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
1207
|
+
const { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
|
|
1208
|
+
const { isBlob, isValidStatusCode } = require_validation();
|
|
1209
|
+
const { mask: applyMask, toBuffer } = require_buffer_util();
|
|
1219
1210
|
const kByteLength = Symbol("kByteLength");
|
|
1220
1211
|
const maskBuffer = Buffer.alloc(4);
|
|
1221
|
-
const RANDOM_POOL_SIZE =
|
|
1212
|
+
const RANDOM_POOL_SIZE = 8192;
|
|
1222
1213
|
let randomPool;
|
|
1223
1214
|
let randomPoolPointer = RANDOM_POOL_SIZE;
|
|
1224
1215
|
const DEFAULT = 0;
|
|
1225
1216
|
const DEFLATING = 1;
|
|
1226
1217
|
const GET_BLOB_DATA = 2;
|
|
1227
|
-
|
|
1228
|
-
* HyBi Sender implementation.
|
|
1229
|
-
*/
|
|
1230
|
-
var Sender$2 = class Sender$2 {
|
|
1218
|
+
module.exports = class Sender {
|
|
1231
1219
|
/**
|
|
1232
1220
|
* Creates a Sender instance.
|
|
1233
1221
|
*
|
|
@@ -1248,8 +1236,8 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1248
1236
|
this._bufferedBytes = 0;
|
|
1249
1237
|
this._queue = [];
|
|
1250
1238
|
this._state = DEFAULT;
|
|
1251
|
-
this.onerror = NOOP
|
|
1252
|
-
this[kWebSocket
|
|
1239
|
+
this.onerror = NOOP;
|
|
1240
|
+
this[kWebSocket] = void 0;
|
|
1253
1241
|
}
|
|
1254
1242
|
/**
|
|
1255
1243
|
* Frames a piece of data according to the HyBi WebSocket protocol.
|
|
@@ -1347,7 +1335,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1347
1335
|
*/
|
|
1348
1336
|
close(code, data, mask, cb) {
|
|
1349
1337
|
let buf;
|
|
1350
|
-
if (code === void 0) buf = EMPTY_BUFFER
|
|
1338
|
+
if (code === void 0) buf = EMPTY_BUFFER;
|
|
1351
1339
|
else if (typeof code !== "number" || !isValidStatusCode(code)) throw new TypeError("First argument must be a valid error code number");
|
|
1352
1340
|
else if (data === void 0 || !data.length) {
|
|
1353
1341
|
buf = Buffer.allocUnsafe(2);
|
|
@@ -1378,7 +1366,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1378
1366
|
options,
|
|
1379
1367
|
cb
|
|
1380
1368
|
]);
|
|
1381
|
-
else this.sendFrame(Sender
|
|
1369
|
+
else this.sendFrame(Sender.frame(buf, options), cb);
|
|
1382
1370
|
}
|
|
1383
1371
|
/**
|
|
1384
1372
|
* Sends a ping message to the other peer.
|
|
@@ -1394,13 +1382,13 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1394
1382
|
if (typeof data === "string") {
|
|
1395
1383
|
byteLength = Buffer.byteLength(data);
|
|
1396
1384
|
readOnly = false;
|
|
1397
|
-
} else if (isBlob
|
|
1385
|
+
} else if (isBlob(data)) {
|
|
1398
1386
|
byteLength = data.size;
|
|
1399
1387
|
readOnly = false;
|
|
1400
1388
|
} else {
|
|
1401
|
-
data = toBuffer
|
|
1389
|
+
data = toBuffer(data);
|
|
1402
1390
|
byteLength = data.length;
|
|
1403
|
-
readOnly = toBuffer
|
|
1391
|
+
readOnly = toBuffer.readOnly;
|
|
1404
1392
|
}
|
|
1405
1393
|
if (byteLength > 125) throw new RangeError("The data size must not be greater than 125 bytes");
|
|
1406
1394
|
const options = {
|
|
@@ -1413,7 +1401,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1413
1401
|
readOnly,
|
|
1414
1402
|
rsv1: false
|
|
1415
1403
|
};
|
|
1416
|
-
if (isBlob
|
|
1404
|
+
if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
|
|
1417
1405
|
this.getBlobData,
|
|
1418
1406
|
data,
|
|
1419
1407
|
false,
|
|
@@ -1428,7 +1416,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1428
1416
|
options,
|
|
1429
1417
|
cb
|
|
1430
1418
|
]);
|
|
1431
|
-
else this.sendFrame(Sender
|
|
1419
|
+
else this.sendFrame(Sender.frame(data, options), cb);
|
|
1432
1420
|
}
|
|
1433
1421
|
/**
|
|
1434
1422
|
* Sends a pong message to the other peer.
|
|
@@ -1444,13 +1432,13 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1444
1432
|
if (typeof data === "string") {
|
|
1445
1433
|
byteLength = Buffer.byteLength(data);
|
|
1446
1434
|
readOnly = false;
|
|
1447
|
-
} else if (isBlob
|
|
1435
|
+
} else if (isBlob(data)) {
|
|
1448
1436
|
byteLength = data.size;
|
|
1449
1437
|
readOnly = false;
|
|
1450
1438
|
} else {
|
|
1451
|
-
data = toBuffer
|
|
1439
|
+
data = toBuffer(data);
|
|
1452
1440
|
byteLength = data.length;
|
|
1453
|
-
readOnly = toBuffer
|
|
1441
|
+
readOnly = toBuffer.readOnly;
|
|
1454
1442
|
}
|
|
1455
1443
|
if (byteLength > 125) throw new RangeError("The data size must not be greater than 125 bytes");
|
|
1456
1444
|
const options = {
|
|
@@ -1463,7 +1451,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1463
1451
|
readOnly,
|
|
1464
1452
|
rsv1: false
|
|
1465
1453
|
};
|
|
1466
|
-
if (isBlob
|
|
1454
|
+
if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
|
|
1467
1455
|
this.getBlobData,
|
|
1468
1456
|
data,
|
|
1469
1457
|
false,
|
|
@@ -1478,7 +1466,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1478
1466
|
options,
|
|
1479
1467
|
cb
|
|
1480
1468
|
]);
|
|
1481
|
-
else this.sendFrame(Sender
|
|
1469
|
+
else this.sendFrame(Sender.frame(data, options), cb);
|
|
1482
1470
|
}
|
|
1483
1471
|
/**
|
|
1484
1472
|
* Sends a data message to the other peer.
|
|
@@ -1497,7 +1485,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1497
1485
|
* @public
|
|
1498
1486
|
*/
|
|
1499
1487
|
send(data, options, cb) {
|
|
1500
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate
|
|
1488
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
1501
1489
|
let opcode = options.binary ? 2 : 1;
|
|
1502
1490
|
let rsv1 = options.compress;
|
|
1503
1491
|
let byteLength;
|
|
@@ -1505,13 +1493,13 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1505
1493
|
if (typeof data === "string") {
|
|
1506
1494
|
byteLength = Buffer.byteLength(data);
|
|
1507
1495
|
readOnly = false;
|
|
1508
|
-
} else if (isBlob
|
|
1496
|
+
} else if (isBlob(data)) {
|
|
1509
1497
|
byteLength = data.size;
|
|
1510
1498
|
readOnly = false;
|
|
1511
1499
|
} else {
|
|
1512
|
-
data = toBuffer
|
|
1500
|
+
data = toBuffer(data);
|
|
1513
1501
|
byteLength = data.length;
|
|
1514
|
-
readOnly = toBuffer
|
|
1502
|
+
readOnly = toBuffer.readOnly;
|
|
1515
1503
|
}
|
|
1516
1504
|
if (this._firstFragment) {
|
|
1517
1505
|
this._firstFragment = false;
|
|
@@ -1532,7 +1520,7 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1532
1520
|
readOnly,
|
|
1533
1521
|
rsv1
|
|
1534
1522
|
};
|
|
1535
|
-
if (isBlob
|
|
1523
|
+
if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
|
|
1536
1524
|
this.getBlobData,
|
|
1537
1525
|
data,
|
|
1538
1526
|
this._compress,
|
|
@@ -1582,10 +1570,10 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1582
1570
|
return;
|
|
1583
1571
|
}
|
|
1584
1572
|
this._bufferedBytes -= options[kByteLength];
|
|
1585
|
-
const data = toBuffer
|
|
1573
|
+
const data = toBuffer(arrayBuffer);
|
|
1586
1574
|
if (!compress) {
|
|
1587
1575
|
this._state = DEFAULT;
|
|
1588
|
-
this.sendFrame(Sender
|
|
1576
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
1589
1577
|
this.dequeue();
|
|
1590
1578
|
} else this.dispatch(data, compress, options, cb);
|
|
1591
1579
|
}).catch((err) => {
|
|
@@ -1617,21 +1605,22 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1617
1605
|
*/
|
|
1618
1606
|
dispatch(data, compress, options, cb) {
|
|
1619
1607
|
if (!compress) {
|
|
1620
|
-
this.sendFrame(Sender
|
|
1608
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
1621
1609
|
return;
|
|
1622
1610
|
}
|
|
1623
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate
|
|
1611
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
1624
1612
|
this._bufferedBytes += options[kByteLength];
|
|
1625
1613
|
this._state = DEFLATING;
|
|
1626
1614
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
1627
1615
|
if (this._socket.destroyed) {
|
|
1628
|
-
|
|
1616
|
+
const err = /* @__PURE__ */ new Error("The socket was closed while data was being compressed");
|
|
1617
|
+
callCallbacks(this, err, cb);
|
|
1629
1618
|
return;
|
|
1630
1619
|
}
|
|
1631
1620
|
this._bufferedBytes -= options[kByteLength];
|
|
1632
1621
|
this._state = DEFAULT;
|
|
1633
1622
|
options.readOnly = false;
|
|
1634
|
-
this.sendFrame(Sender
|
|
1623
|
+
this.sendFrame(Sender.frame(buf, options), cb);
|
|
1635
1624
|
this.dequeue();
|
|
1636
1625
|
});
|
|
1637
1626
|
}
|
|
@@ -1673,7 +1662,6 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1673
1662
|
} else this._socket.write(list[0], cb);
|
|
1674
1663
|
}
|
|
1675
1664
|
};
|
|
1676
|
-
module.exports = Sender$2;
|
|
1677
1665
|
/**
|
|
1678
1666
|
* Calls queued callbacks with an error.
|
|
1679
1667
|
*
|
|
@@ -1702,12 +1690,11 @@ var require_sender = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/sender.js
|
|
|
1702
1690
|
callCallbacks(sender, err, cb);
|
|
1703
1691
|
sender.onerror(err);
|
|
1704
1692
|
}
|
|
1705
|
-
})
|
|
1706
|
-
|
|
1693
|
+
}));
|
|
1707
1694
|
//#endregion
|
|
1708
1695
|
//#region node_modules/ws/lib/event-target.js
|
|
1709
|
-
var require_event_target = /* @__PURE__ */
|
|
1710
|
-
const { kForOnEventAttribute
|
|
1696
|
+
var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1697
|
+
const { kForOnEventAttribute, kListener } = require_constants();
|
|
1711
1698
|
const kCode = Symbol("kCode");
|
|
1712
1699
|
const kData = Symbol("kData");
|
|
1713
1700
|
const kError = Symbol("kError");
|
|
@@ -1853,61 +1840,73 @@ var require_event_target = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/eve
|
|
|
1853
1840
|
}
|
|
1854
1841
|
};
|
|
1855
1842
|
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
1856
|
-
/**
|
|
1857
|
-
* This provides methods for emulating the `EventTarget` interface. It's not
|
|
1858
|
-
* meant to be used directly.
|
|
1859
|
-
*
|
|
1860
|
-
* @mixin
|
|
1861
|
-
*/
|
|
1862
|
-
const EventTarget = {
|
|
1863
|
-
addEventListener(type, handler, options = {}) {
|
|
1864
|
-
for (const listener of this.listeners(type)) if (!options[kForOnEventAttribute$1] && listener[kListener$1] === handler && !listener[kForOnEventAttribute$1]) return;
|
|
1865
|
-
let wrapper;
|
|
1866
|
-
if (type === "message") wrapper = function onMessage(data, isBinary) {
|
|
1867
|
-
const event = new MessageEvent("message", { data: isBinary ? data : data.toString() });
|
|
1868
|
-
event[kTarget] = this;
|
|
1869
|
-
callListener(handler, this, event);
|
|
1870
|
-
};
|
|
1871
|
-
else if (type === "close") wrapper = function onClose(code, message) {
|
|
1872
|
-
const event = new CloseEvent("close", {
|
|
1873
|
-
code,
|
|
1874
|
-
reason: message.toString(),
|
|
1875
|
-
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
1876
|
-
});
|
|
1877
|
-
event[kTarget] = this;
|
|
1878
|
-
callListener(handler, this, event);
|
|
1879
|
-
};
|
|
1880
|
-
else if (type === "error") wrapper = function onError$1(error) {
|
|
1881
|
-
const event = new ErrorEvent("error", {
|
|
1882
|
-
error,
|
|
1883
|
-
message: error.message
|
|
1884
|
-
});
|
|
1885
|
-
event[kTarget] = this;
|
|
1886
|
-
callListener(handler, this, event);
|
|
1887
|
-
};
|
|
1888
|
-
else if (type === "open") wrapper = function onOpen() {
|
|
1889
|
-
const event = new Event("open");
|
|
1890
|
-
event[kTarget] = this;
|
|
1891
|
-
callListener(handler, this, event);
|
|
1892
|
-
};
|
|
1893
|
-
else return;
|
|
1894
|
-
wrapper[kForOnEventAttribute$1] = !!options[kForOnEventAttribute$1];
|
|
1895
|
-
wrapper[kListener$1] = handler;
|
|
1896
|
-
if (options.once) this.once(type, wrapper);
|
|
1897
|
-
else this.on(type, wrapper);
|
|
1898
|
-
},
|
|
1899
|
-
removeEventListener(type, handler) {
|
|
1900
|
-
for (const listener of this.listeners(type)) if (listener[kListener$1] === handler && !listener[kForOnEventAttribute$1]) {
|
|
1901
|
-
this.removeListener(type, listener);
|
|
1902
|
-
break;
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
};
|
|
1906
1843
|
module.exports = {
|
|
1907
1844
|
CloseEvent,
|
|
1908
1845
|
ErrorEvent,
|
|
1909
1846
|
Event,
|
|
1910
|
-
EventTarget
|
|
1847
|
+
EventTarget: {
|
|
1848
|
+
/**
|
|
1849
|
+
* Register an event listener.
|
|
1850
|
+
*
|
|
1851
|
+
* @param {String} type A string representing the event type to listen for
|
|
1852
|
+
* @param {(Function|Object)} handler The listener to add
|
|
1853
|
+
* @param {Object} [options] An options object specifies characteristics about
|
|
1854
|
+
* the event listener
|
|
1855
|
+
* @param {Boolean} [options.once=false] A `Boolean` indicating that the
|
|
1856
|
+
* listener should be invoked at most once after being added. If `true`,
|
|
1857
|
+
* the listener would be automatically removed when invoked.
|
|
1858
|
+
* @public
|
|
1859
|
+
*/
|
|
1860
|
+
addEventListener(type, handler, options = {}) {
|
|
1861
|
+
for (const listener of this.listeners(type)) if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) return;
|
|
1862
|
+
let wrapper;
|
|
1863
|
+
if (type === "message") wrapper = function onMessage(data, isBinary) {
|
|
1864
|
+
const event = new MessageEvent("message", { data: isBinary ? data : data.toString() });
|
|
1865
|
+
event[kTarget] = this;
|
|
1866
|
+
callListener(handler, this, event);
|
|
1867
|
+
};
|
|
1868
|
+
else if (type === "close") wrapper = function onClose(code, message) {
|
|
1869
|
+
const event = new CloseEvent("close", {
|
|
1870
|
+
code,
|
|
1871
|
+
reason: message.toString(),
|
|
1872
|
+
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
1873
|
+
});
|
|
1874
|
+
event[kTarget] = this;
|
|
1875
|
+
callListener(handler, this, event);
|
|
1876
|
+
};
|
|
1877
|
+
else if (type === "error") wrapper = function onError(error) {
|
|
1878
|
+
const event = new ErrorEvent("error", {
|
|
1879
|
+
error,
|
|
1880
|
+
message: error.message
|
|
1881
|
+
});
|
|
1882
|
+
event[kTarget] = this;
|
|
1883
|
+
callListener(handler, this, event);
|
|
1884
|
+
};
|
|
1885
|
+
else if (type === "open") wrapper = function onOpen() {
|
|
1886
|
+
const event = new Event("open");
|
|
1887
|
+
event[kTarget] = this;
|
|
1888
|
+
callListener(handler, this, event);
|
|
1889
|
+
};
|
|
1890
|
+
else return;
|
|
1891
|
+
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
1892
|
+
wrapper[kListener] = handler;
|
|
1893
|
+
if (options.once) this.once(type, wrapper);
|
|
1894
|
+
else this.on(type, wrapper);
|
|
1895
|
+
},
|
|
1896
|
+
/**
|
|
1897
|
+
* Remove an event listener.
|
|
1898
|
+
*
|
|
1899
|
+
* @param {String} type A string representing the event type to remove
|
|
1900
|
+
* @param {(Function|Object)} handler The listener to remove
|
|
1901
|
+
* @public
|
|
1902
|
+
*/
|
|
1903
|
+
removeEventListener(type, handler) {
|
|
1904
|
+
for (const listener of this.listeners(type)) if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
1905
|
+
this.removeListener(type, listener);
|
|
1906
|
+
break;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
},
|
|
1911
1910
|
MessageEvent
|
|
1912
1911
|
};
|
|
1913
1912
|
/**
|
|
@@ -1922,12 +1921,11 @@ var require_event_target = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/eve
|
|
|
1922
1921
|
if (typeof listener === "object" && listener.handleEvent) listener.handleEvent.call(listener, event);
|
|
1923
1922
|
else listener.call(thisArg, event);
|
|
1924
1923
|
}
|
|
1925
|
-
})
|
|
1926
|
-
|
|
1924
|
+
}));
|
|
1927
1925
|
//#endregion
|
|
1928
1926
|
//#region node_modules/ws/lib/extension.js
|
|
1929
|
-
var require_extension = /* @__PURE__ */
|
|
1930
|
-
const { tokenChars
|
|
1927
|
+
var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1928
|
+
const { tokenChars } = require_validation();
|
|
1931
1929
|
/**
|
|
1932
1930
|
* Adds an offer to the map of extension offers or a parameter to the map of
|
|
1933
1931
|
* parameters.
|
|
@@ -1949,7 +1947,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
1949
1947
|
* @return {Object} The parsed object
|
|
1950
1948
|
* @public
|
|
1951
1949
|
*/
|
|
1952
|
-
function parse
|
|
1950
|
+
function parse(header) {
|
|
1953
1951
|
const offers = Object.create(null);
|
|
1954
1952
|
let params = Object.create(null);
|
|
1955
1953
|
let mustUnescape = false;
|
|
@@ -1963,7 +1961,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
1963
1961
|
let i = 0;
|
|
1964
1962
|
for (; i < header.length; i++) {
|
|
1965
1963
|
code = header.charCodeAt(i);
|
|
1966
|
-
if (extensionName === void 0) if (end === -1 && tokenChars
|
|
1964
|
+
if (extensionName === void 0) if (end === -1 && tokenChars[code] === 1) {
|
|
1967
1965
|
if (start === -1) start = i;
|
|
1968
1966
|
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
1969
1967
|
if (end === -1 && start !== -1) end = i;
|
|
@@ -1977,7 +1975,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
1977
1975
|
} else extensionName = name;
|
|
1978
1976
|
start = end = -1;
|
|
1979
1977
|
} else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
1980
|
-
else if (paramName === void 0) if (end === -1 && tokenChars
|
|
1978
|
+
else if (paramName === void 0) if (end === -1 && tokenChars[code] === 1) {
|
|
1981
1979
|
if (start === -1) start = i;
|
|
1982
1980
|
} else if (code === 32 || code === 9) {
|
|
1983
1981
|
if (end === -1 && start !== -1) end = i;
|
|
@@ -1996,11 +1994,11 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
1996
1994
|
start = end = -1;
|
|
1997
1995
|
} else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
1998
1996
|
else if (isEscaping) {
|
|
1999
|
-
if (tokenChars
|
|
1997
|
+
if (tokenChars[code] !== 1) throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
2000
1998
|
if (start === -1) start = i;
|
|
2001
1999
|
else if (!mustUnescape) mustUnescape = true;
|
|
2002
2000
|
isEscaping = false;
|
|
2003
|
-
} else if (inQuotes) if (tokenChars
|
|
2001
|
+
} else if (inQuotes) if (tokenChars[code] === 1) {
|
|
2004
2002
|
if (start === -1) start = i;
|
|
2005
2003
|
} else if (code === 34 && start !== -1) {
|
|
2006
2004
|
inQuotes = false;
|
|
@@ -2008,7 +2006,7 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
2008
2006
|
} else if (code === 92) isEscaping = true;
|
|
2009
2007
|
else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
2010
2008
|
else if (code === 34 && header.charCodeAt(i - 1) === 61) inQuotes = true;
|
|
2011
|
-
else if (end === -1 && tokenChars
|
|
2009
|
+
else if (end === -1 && tokenChars[code] === 1) {
|
|
2012
2010
|
if (start === -1) start = i;
|
|
2013
2011
|
} else if (start !== -1 && (code === 32 || code === 9)) {
|
|
2014
2012
|
if (end === -1) end = i;
|
|
@@ -2032,12 +2030,12 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
2032
2030
|
}
|
|
2033
2031
|
if (start === -1 || inQuotes || code === 32 || code === 9) throw new SyntaxError("Unexpected end of input");
|
|
2034
2032
|
if (end === -1) end = i;
|
|
2035
|
-
const token
|
|
2036
|
-
if (extensionName === void 0) push(offers, token
|
|
2033
|
+
const token = header.slice(start, end);
|
|
2034
|
+
if (extensionName === void 0) push(offers, token, params);
|
|
2037
2035
|
else {
|
|
2038
|
-
if (paramName === void 0) push(params, token
|
|
2039
|
-
else if (mustUnescape) push(params, paramName, token
|
|
2040
|
-
else push(params, paramName, token
|
|
2036
|
+
if (paramName === void 0) push(params, token, true);
|
|
2037
|
+
else if (mustUnescape) push(params, paramName, token.replace(/\\/g, ""));
|
|
2038
|
+
else push(params, paramName, token);
|
|
2041
2039
|
push(offers, extensionName, params);
|
|
2042
2040
|
}
|
|
2043
2041
|
return offers;
|
|
@@ -2049,12 +2047,12 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
2049
2047
|
* @return {String} A string representing the given object
|
|
2050
2048
|
* @public
|
|
2051
2049
|
*/
|
|
2052
|
-
function format
|
|
2053
|
-
return Object.keys(extensions).map((extension
|
|
2054
|
-
let configurations = extensions[extension
|
|
2050
|
+
function format(extensions) {
|
|
2051
|
+
return Object.keys(extensions).map((extension) => {
|
|
2052
|
+
let configurations = extensions[extension];
|
|
2055
2053
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
2056
2054
|
return configurations.map((params) => {
|
|
2057
|
-
return [extension
|
|
2055
|
+
return [extension].concat(Object.keys(params).map((k) => {
|
|
2058
2056
|
let values = params[k];
|
|
2059
2057
|
if (!Array.isArray(values)) values = [values];
|
|
2060
2058
|
return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
|
|
@@ -2063,14 +2061,13 @@ var require_extension = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/extens
|
|
|
2063
2061
|
}).join(", ");
|
|
2064
2062
|
}
|
|
2065
2063
|
module.exports = {
|
|
2066
|
-
format
|
|
2067
|
-
parse
|
|
2064
|
+
format,
|
|
2065
|
+
parse
|
|
2068
2066
|
};
|
|
2069
|
-
})
|
|
2070
|
-
|
|
2067
|
+
}));
|
|
2071
2068
|
//#endregion
|
|
2072
2069
|
//#region node_modules/ws/lib/websocket.js
|
|
2073
|
-
var require_websocket = /* @__PURE__ */
|
|
2070
|
+
var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2074
2071
|
const EventEmitter$1 = __require("events");
|
|
2075
2072
|
const https = __require("https");
|
|
2076
2073
|
const http$1 = __require("http");
|
|
@@ -2079,13 +2076,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2079
2076
|
const { randomBytes: randomBytes$1, createHash: createHash$1 } = __require("crypto");
|
|
2080
2077
|
const { Duplex: Duplex$2, Readable } = __require("stream");
|
|
2081
2078
|
const { URL } = __require("url");
|
|
2082
|
-
const PerMessageDeflate
|
|
2083
|
-
const Receiver
|
|
2084
|
-
const Sender
|
|
2079
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
2080
|
+
const Receiver = require_receiver();
|
|
2081
|
+
const Sender = require_sender();
|
|
2085
2082
|
const { isBlob } = require_validation();
|
|
2086
|
-
const { BINARY_TYPES, CLOSE_TIMEOUT
|
|
2083
|
+
const { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = require_constants();
|
|
2087
2084
|
const { EventTarget: { addEventListener, removeEventListener } } = require_event_target();
|
|
2088
|
-
const { format, parse
|
|
2085
|
+
const { format, parse } = require_extension();
|
|
2089
2086
|
const { toBuffer } = require_buffer_util();
|
|
2090
2087
|
const kAborted = Symbol("kAborted");
|
|
2091
2088
|
const protocolVersions = [8, 13];
|
|
@@ -2101,7 +2098,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2101
2098
|
*
|
|
2102
2099
|
* @extends EventEmitter
|
|
2103
2100
|
*/
|
|
2104
|
-
var WebSocket
|
|
2101
|
+
var WebSocket = class WebSocket extends EventEmitter$1 {
|
|
2105
2102
|
/**
|
|
2106
2103
|
* Create a new `WebSocket`.
|
|
2107
2104
|
*
|
|
@@ -2121,7 +2118,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2121
2118
|
this._extensions = {};
|
|
2122
2119
|
this._paused = false;
|
|
2123
2120
|
this._protocol = "";
|
|
2124
|
-
this._readyState = WebSocket
|
|
2121
|
+
this._readyState = WebSocket.CONNECTING;
|
|
2125
2122
|
this._receiver = null;
|
|
2126
2123
|
this._sender = null;
|
|
2127
2124
|
this._socket = null;
|
|
@@ -2241,7 +2238,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2241
2238
|
* @private
|
|
2242
2239
|
*/
|
|
2243
2240
|
setSocket(socket, head, options) {
|
|
2244
|
-
const receiver = new Receiver
|
|
2241
|
+
const receiver = new Receiver({
|
|
2245
2242
|
allowSynchronousEvents: options.allowSynchronousEvents,
|
|
2246
2243
|
binaryType: this.binaryType,
|
|
2247
2244
|
extensions: this._extensions,
|
|
@@ -2251,13 +2248,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2251
2248
|
maxPayload: options.maxPayload,
|
|
2252
2249
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2253
2250
|
});
|
|
2254
|
-
const sender = new Sender
|
|
2251
|
+
const sender = new Sender(socket, this._extensions, options.generateMask);
|
|
2255
2252
|
this._receiver = receiver;
|
|
2256
2253
|
this._sender = sender;
|
|
2257
2254
|
this._socket = socket;
|
|
2258
|
-
receiver[kWebSocket
|
|
2259
|
-
sender[kWebSocket
|
|
2260
|
-
socket[kWebSocket
|
|
2255
|
+
receiver[kWebSocket] = this;
|
|
2256
|
+
sender[kWebSocket] = this;
|
|
2257
|
+
socket[kWebSocket] = this;
|
|
2261
2258
|
receiver.on("conclude", receiverOnConclude);
|
|
2262
2259
|
receiver.on("drain", receiverOnDrain);
|
|
2263
2260
|
receiver.on("error", receiverOnError);
|
|
@@ -2271,8 +2268,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2271
2268
|
socket.on("close", socketOnClose);
|
|
2272
2269
|
socket.on("data", socketOnData);
|
|
2273
2270
|
socket.on("end", socketOnEnd);
|
|
2274
|
-
socket.on("error", socketOnError
|
|
2275
|
-
this._readyState = WebSocket
|
|
2271
|
+
socket.on("error", socketOnError);
|
|
2272
|
+
this._readyState = WebSocket.OPEN;
|
|
2276
2273
|
this.emit("open");
|
|
2277
2274
|
}
|
|
2278
2275
|
/**
|
|
@@ -2282,13 +2279,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2282
2279
|
*/
|
|
2283
2280
|
emitClose() {
|
|
2284
2281
|
if (!this._socket) {
|
|
2285
|
-
this._readyState = WebSocket
|
|
2282
|
+
this._readyState = WebSocket.CLOSED;
|
|
2286
2283
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2287
2284
|
return;
|
|
2288
2285
|
}
|
|
2289
|
-
if (this._extensions[PerMessageDeflate
|
|
2286
|
+
if (this._extensions[PerMessageDeflate.extensionName]) this._extensions[PerMessageDeflate.extensionName].cleanup();
|
|
2290
2287
|
this._receiver.removeAllListeners();
|
|
2291
|
-
this._readyState = WebSocket
|
|
2288
|
+
this._readyState = WebSocket.CLOSED;
|
|
2292
2289
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2293
2290
|
}
|
|
2294
2291
|
/**
|
|
@@ -2312,16 +2309,16 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2312
2309
|
* @public
|
|
2313
2310
|
*/
|
|
2314
2311
|
close(code, data) {
|
|
2315
|
-
if (this.readyState === WebSocket
|
|
2316
|
-
if (this.readyState === WebSocket
|
|
2317
|
-
abortHandshake
|
|
2312
|
+
if (this.readyState === WebSocket.CLOSED) return;
|
|
2313
|
+
if (this.readyState === WebSocket.CONNECTING) {
|
|
2314
|
+
abortHandshake(this, this._req, "WebSocket was closed before the connection was established");
|
|
2318
2315
|
return;
|
|
2319
2316
|
}
|
|
2320
|
-
if (this.readyState === WebSocket
|
|
2317
|
+
if (this.readyState === WebSocket.CLOSING) {
|
|
2321
2318
|
if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) this._socket.end();
|
|
2322
2319
|
return;
|
|
2323
2320
|
}
|
|
2324
|
-
this._readyState = WebSocket
|
|
2321
|
+
this._readyState = WebSocket.CLOSING;
|
|
2325
2322
|
this._sender.close(code, data, !this._isServer, (err) => {
|
|
2326
2323
|
if (err) return;
|
|
2327
2324
|
this._closeFrameSent = true;
|
|
@@ -2335,7 +2332,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2335
2332
|
* @public
|
|
2336
2333
|
*/
|
|
2337
2334
|
pause() {
|
|
2338
|
-
if (this.readyState === WebSocket
|
|
2335
|
+
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;
|
|
2339
2336
|
this._paused = true;
|
|
2340
2337
|
this._socket.pause();
|
|
2341
2338
|
}
|
|
@@ -2348,7 +2345,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2348
2345
|
* @public
|
|
2349
2346
|
*/
|
|
2350
2347
|
ping(data, mask, cb) {
|
|
2351
|
-
if (this.readyState === WebSocket
|
|
2348
|
+
if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
2352
2349
|
if (typeof data === "function") {
|
|
2353
2350
|
cb = data;
|
|
2354
2351
|
data = mask = void 0;
|
|
@@ -2357,7 +2354,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2357
2354
|
mask = void 0;
|
|
2358
2355
|
}
|
|
2359
2356
|
if (typeof data === "number") data = data.toString();
|
|
2360
|
-
if (this.readyState !== WebSocket
|
|
2357
|
+
if (this.readyState !== WebSocket.OPEN) {
|
|
2361
2358
|
sendAfterClose(this, data, cb);
|
|
2362
2359
|
return;
|
|
2363
2360
|
}
|
|
@@ -2373,7 +2370,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2373
2370
|
* @public
|
|
2374
2371
|
*/
|
|
2375
2372
|
pong(data, mask, cb) {
|
|
2376
|
-
if (this.readyState === WebSocket
|
|
2373
|
+
if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
2377
2374
|
if (typeof data === "function") {
|
|
2378
2375
|
cb = data;
|
|
2379
2376
|
data = mask = void 0;
|
|
@@ -2382,7 +2379,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2382
2379
|
mask = void 0;
|
|
2383
2380
|
}
|
|
2384
2381
|
if (typeof data === "number") data = data.toString();
|
|
2385
|
-
if (this.readyState !== WebSocket
|
|
2382
|
+
if (this.readyState !== WebSocket.OPEN) {
|
|
2386
2383
|
sendAfterClose(this, data, cb);
|
|
2387
2384
|
return;
|
|
2388
2385
|
}
|
|
@@ -2395,7 +2392,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2395
2392
|
* @public
|
|
2396
2393
|
*/
|
|
2397
2394
|
resume() {
|
|
2398
|
-
if (this.readyState === WebSocket
|
|
2395
|
+
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;
|
|
2399
2396
|
this._paused = false;
|
|
2400
2397
|
if (!this._receiver._writableState.needDrain) this._socket.resume();
|
|
2401
2398
|
}
|
|
@@ -2415,13 +2412,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2415
2412
|
* @public
|
|
2416
2413
|
*/
|
|
2417
2414
|
send(data, options, cb) {
|
|
2418
|
-
if (this.readyState === WebSocket
|
|
2415
|
+
if (this.readyState === WebSocket.CONNECTING) throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
2419
2416
|
if (typeof options === "function") {
|
|
2420
2417
|
cb = options;
|
|
2421
2418
|
options = {};
|
|
2422
2419
|
}
|
|
2423
2420
|
if (typeof data === "number") data = data.toString();
|
|
2424
|
-
if (this.readyState !== WebSocket
|
|
2421
|
+
if (this.readyState !== WebSocket.OPEN) {
|
|
2425
2422
|
sendAfterClose(this, data, cb);
|
|
2426
2423
|
return;
|
|
2427
2424
|
}
|
|
@@ -2432,7 +2429,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2432
2429
|
fin: true,
|
|
2433
2430
|
...options
|
|
2434
2431
|
};
|
|
2435
|
-
if (!this._extensions[PerMessageDeflate
|
|
2432
|
+
if (!this._extensions[PerMessageDeflate.extensionName]) opts.compress = false;
|
|
2436
2433
|
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
2437
2434
|
}
|
|
2438
2435
|
/**
|
|
@@ -2441,13 +2438,13 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2441
2438
|
* @public
|
|
2442
2439
|
*/
|
|
2443
2440
|
terminate() {
|
|
2444
|
-
if (this.readyState === WebSocket
|
|
2445
|
-
if (this.readyState === WebSocket
|
|
2446
|
-
abortHandshake
|
|
2441
|
+
if (this.readyState === WebSocket.CLOSED) return;
|
|
2442
|
+
if (this.readyState === WebSocket.CONNECTING) {
|
|
2443
|
+
abortHandshake(this, this._req, "WebSocket was closed before the connection was established");
|
|
2447
2444
|
return;
|
|
2448
2445
|
}
|
|
2449
2446
|
if (this._socket) {
|
|
2450
|
-
this._readyState = WebSocket
|
|
2447
|
+
this._readyState = WebSocket.CLOSING;
|
|
2451
2448
|
this._socket.destroy();
|
|
2452
2449
|
}
|
|
2453
2450
|
}
|
|
@@ -2456,7 +2453,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2456
2453
|
* @constant {Number} CONNECTING
|
|
2457
2454
|
* @memberof WebSocket
|
|
2458
2455
|
*/
|
|
2459
|
-
Object.defineProperty(WebSocket
|
|
2456
|
+
Object.defineProperty(WebSocket, "CONNECTING", {
|
|
2460
2457
|
enumerable: true,
|
|
2461
2458
|
value: readyStates.indexOf("CONNECTING")
|
|
2462
2459
|
});
|
|
@@ -2464,7 +2461,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2464
2461
|
* @constant {Number} CONNECTING
|
|
2465
2462
|
* @memberof WebSocket.prototype
|
|
2466
2463
|
*/
|
|
2467
|
-
Object.defineProperty(WebSocket
|
|
2464
|
+
Object.defineProperty(WebSocket.prototype, "CONNECTING", {
|
|
2468
2465
|
enumerable: true,
|
|
2469
2466
|
value: readyStates.indexOf("CONNECTING")
|
|
2470
2467
|
});
|
|
@@ -2472,7 +2469,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2472
2469
|
* @constant {Number} OPEN
|
|
2473
2470
|
* @memberof WebSocket
|
|
2474
2471
|
*/
|
|
2475
|
-
Object.defineProperty(WebSocket
|
|
2472
|
+
Object.defineProperty(WebSocket, "OPEN", {
|
|
2476
2473
|
enumerable: true,
|
|
2477
2474
|
value: readyStates.indexOf("OPEN")
|
|
2478
2475
|
});
|
|
@@ -2480,7 +2477,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2480
2477
|
* @constant {Number} OPEN
|
|
2481
2478
|
* @memberof WebSocket.prototype
|
|
2482
2479
|
*/
|
|
2483
|
-
Object.defineProperty(WebSocket
|
|
2480
|
+
Object.defineProperty(WebSocket.prototype, "OPEN", {
|
|
2484
2481
|
enumerable: true,
|
|
2485
2482
|
value: readyStates.indexOf("OPEN")
|
|
2486
2483
|
});
|
|
@@ -2488,7 +2485,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2488
2485
|
* @constant {Number} CLOSING
|
|
2489
2486
|
* @memberof WebSocket
|
|
2490
2487
|
*/
|
|
2491
|
-
Object.defineProperty(WebSocket
|
|
2488
|
+
Object.defineProperty(WebSocket, "CLOSING", {
|
|
2492
2489
|
enumerable: true,
|
|
2493
2490
|
value: readyStates.indexOf("CLOSING")
|
|
2494
2491
|
});
|
|
@@ -2496,7 +2493,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2496
2493
|
* @constant {Number} CLOSING
|
|
2497
2494
|
* @memberof WebSocket.prototype
|
|
2498
2495
|
*/
|
|
2499
|
-
Object.defineProperty(WebSocket
|
|
2496
|
+
Object.defineProperty(WebSocket.prototype, "CLOSING", {
|
|
2500
2497
|
enumerable: true,
|
|
2501
2498
|
value: readyStates.indexOf("CLOSING")
|
|
2502
2499
|
});
|
|
@@ -2504,7 +2501,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2504
2501
|
* @constant {Number} CLOSED
|
|
2505
2502
|
* @memberof WebSocket
|
|
2506
2503
|
*/
|
|
2507
|
-
Object.defineProperty(WebSocket
|
|
2504
|
+
Object.defineProperty(WebSocket, "CLOSED", {
|
|
2508
2505
|
enumerable: true,
|
|
2509
2506
|
value: readyStates.indexOf("CLOSED")
|
|
2510
2507
|
});
|
|
@@ -2512,7 +2509,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2512
2509
|
* @constant {Number} CLOSED
|
|
2513
2510
|
* @memberof WebSocket.prototype
|
|
2514
2511
|
*/
|
|
2515
|
-
Object.defineProperty(WebSocket
|
|
2512
|
+
Object.defineProperty(WebSocket.prototype, "CLOSED", {
|
|
2516
2513
|
enumerable: true,
|
|
2517
2514
|
value: readyStates.indexOf("CLOSED")
|
|
2518
2515
|
});
|
|
@@ -2525,7 +2522,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2525
2522
|
"readyState",
|
|
2526
2523
|
"url"
|
|
2527
2524
|
].forEach((property) => {
|
|
2528
|
-
Object.defineProperty(WebSocket
|
|
2525
|
+
Object.defineProperty(WebSocket.prototype, property, { enumerable: true });
|
|
2529
2526
|
});
|
|
2530
2527
|
[
|
|
2531
2528
|
"open",
|
|
@@ -2533,7 +2530,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2533
2530
|
"close",
|
|
2534
2531
|
"message"
|
|
2535
2532
|
].forEach((method) => {
|
|
2536
|
-
Object.defineProperty(WebSocket
|
|
2533
|
+
Object.defineProperty(WebSocket.prototype, `on${method}`, {
|
|
2537
2534
|
enumerable: true,
|
|
2538
2535
|
get() {
|
|
2539
2536
|
for (const listener of this.listeners(method)) if (listener[kForOnEventAttribute]) return listener[kListener];
|
|
@@ -2549,9 +2546,9 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2549
2546
|
}
|
|
2550
2547
|
});
|
|
2551
2548
|
});
|
|
2552
|
-
WebSocket
|
|
2553
|
-
WebSocket
|
|
2554
|
-
module.exports = WebSocket
|
|
2549
|
+
WebSocket.prototype.addEventListener = addEventListener;
|
|
2550
|
+
WebSocket.prototype.removeEventListener = removeEventListener;
|
|
2551
|
+
module.exports = WebSocket;
|
|
2555
2552
|
/**
|
|
2556
2553
|
* Initialize a WebSocket client.
|
|
2557
2554
|
*
|
|
@@ -2574,9 +2571,9 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2574
2571
|
* masking key
|
|
2575
2572
|
* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
|
|
2576
2573
|
* handshake request
|
|
2577
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
2574
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
2578
2575
|
* buffered data chunks
|
|
2579
|
-
* @param {Number} [options.maxFragments=
|
|
2576
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
2580
2577
|
* fragments
|
|
2581
2578
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
2582
2579
|
* size
|
|
@@ -2596,11 +2593,11 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2596
2593
|
const opts = {
|
|
2597
2594
|
allowSynchronousEvents: true,
|
|
2598
2595
|
autoPong: true,
|
|
2599
|
-
closeTimeout: CLOSE_TIMEOUT
|
|
2596
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
2600
2597
|
protocolVersion: protocolVersions[1],
|
|
2601
|
-
maxBufferedChunks:
|
|
2602
|
-
maxFragments:
|
|
2603
|
-
maxPayload:
|
|
2598
|
+
maxBufferedChunks: 262144,
|
|
2599
|
+
maxFragments: 16384,
|
|
2600
|
+
maxPayload: 104857600,
|
|
2604
2601
|
skipUTF8Validation: false,
|
|
2605
2602
|
perMessageDeflate: true,
|
|
2606
2603
|
followRedirects: false,
|
|
@@ -2661,12 +2658,12 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2661
2658
|
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
2662
2659
|
opts.timeout = opts.handshakeTimeout;
|
|
2663
2660
|
if (opts.perMessageDeflate) {
|
|
2664
|
-
perMessageDeflate = new PerMessageDeflate
|
|
2661
|
+
perMessageDeflate = new PerMessageDeflate({
|
|
2665
2662
|
...opts.perMessageDeflate,
|
|
2666
2663
|
isServer: false,
|
|
2667
2664
|
maxPayload: opts.maxPayload
|
|
2668
2665
|
});
|
|
2669
|
-
opts.headers["Sec-WebSocket-Extensions"] = format({ [PerMessageDeflate
|
|
2666
|
+
opts.headers["Sec-WebSocket-Extensions"] = format({ [PerMessageDeflate.extensionName]: perMessageDeflate.offer() });
|
|
2670
2667
|
}
|
|
2671
2668
|
if (protocols.length) {
|
|
2672
2669
|
for (const protocol of protocols) {
|
|
@@ -2694,7 +2691,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2694
2691
|
...options,
|
|
2695
2692
|
headers: {}
|
|
2696
2693
|
};
|
|
2697
|
-
if (headers) for (const [key
|
|
2694
|
+
if (headers) for (const [key, value] of Object.entries(headers)) options.headers[key.toLowerCase()] = value;
|
|
2698
2695
|
} else if (websocket.listenerCount("redirect") === 0) {
|
|
2699
2696
|
const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
|
|
2700
2697
|
if (!isSameHost || websocket._originalSecure && !isSecure) {
|
|
@@ -2709,7 +2706,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2709
2706
|
if (websocket._redirects) websocket.emit("redirect", websocket.url, req);
|
|
2710
2707
|
} else req = websocket._req = request(opts);
|
|
2711
2708
|
if (opts.timeout) req.on("timeout", () => {
|
|
2712
|
-
abortHandshake
|
|
2709
|
+
abortHandshake(websocket, req, "Opening handshake has timed out");
|
|
2713
2710
|
});
|
|
2714
2711
|
req.on("error", (err) => {
|
|
2715
2712
|
if (req === null || req[kAborted]) return;
|
|
@@ -2721,7 +2718,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2721
2718
|
const statusCode = res.statusCode;
|
|
2722
2719
|
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
2723
2720
|
if (++websocket._redirects > opts.maxRedirects) {
|
|
2724
|
-
abortHandshake
|
|
2721
|
+
abortHandshake(websocket, req, "Maximum redirects exceeded");
|
|
2725
2722
|
return;
|
|
2726
2723
|
}
|
|
2727
2724
|
req.abort();
|
|
@@ -2733,20 +2730,20 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2733
2730
|
return;
|
|
2734
2731
|
}
|
|
2735
2732
|
initAsClient(websocket, addr, protocols, options);
|
|
2736
|
-
} else if (!websocket.emit("unexpected-response", req, res)) abortHandshake
|
|
2733
|
+
} else if (!websocket.emit("unexpected-response", req, res)) abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
|
|
2737
2734
|
});
|
|
2738
2735
|
req.on("upgrade", (res, socket, head) => {
|
|
2739
2736
|
websocket.emit("upgrade", res);
|
|
2740
|
-
if (websocket.readyState !== WebSocket
|
|
2737
|
+
if (websocket.readyState !== WebSocket.CONNECTING) return;
|
|
2741
2738
|
req = websocket._req = null;
|
|
2742
2739
|
const upgrade = res.headers.upgrade;
|
|
2743
2740
|
if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
|
|
2744
|
-
abortHandshake
|
|
2741
|
+
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
2745
2742
|
return;
|
|
2746
2743
|
}
|
|
2747
|
-
const digest = createHash$1("sha1").update(key + GUID
|
|
2744
|
+
const digest = createHash$1("sha1").update(key + GUID).digest("base64");
|
|
2748
2745
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
2749
|
-
abortHandshake
|
|
2746
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
2750
2747
|
return;
|
|
2751
2748
|
}
|
|
2752
2749
|
const serverProt = res.headers["sec-websocket-protocol"];
|
|
@@ -2756,35 +2753,35 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2756
2753
|
else if (!protocolSet.has(serverProt)) protError = "Server sent an invalid subprotocol";
|
|
2757
2754
|
} else if (protocolSet.size) protError = "Server sent no subprotocol";
|
|
2758
2755
|
if (protError) {
|
|
2759
|
-
abortHandshake
|
|
2756
|
+
abortHandshake(websocket, socket, protError);
|
|
2760
2757
|
return;
|
|
2761
2758
|
}
|
|
2762
2759
|
if (serverProt) websocket._protocol = serverProt;
|
|
2763
2760
|
const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
|
|
2764
2761
|
if (secWebSocketExtensions !== void 0) {
|
|
2765
2762
|
if (!perMessageDeflate) {
|
|
2766
|
-
abortHandshake
|
|
2763
|
+
abortHandshake(websocket, socket, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
|
2767
2764
|
return;
|
|
2768
2765
|
}
|
|
2769
2766
|
let extensions;
|
|
2770
2767
|
try {
|
|
2771
|
-
extensions = parse
|
|
2768
|
+
extensions = parse(secWebSocketExtensions);
|
|
2772
2769
|
} catch (err) {
|
|
2773
|
-
abortHandshake
|
|
2770
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Extensions header");
|
|
2774
2771
|
return;
|
|
2775
2772
|
}
|
|
2776
2773
|
const extensionNames = Object.keys(extensions);
|
|
2777
|
-
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate
|
|
2778
|
-
abortHandshake
|
|
2774
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
|
|
2775
|
+
abortHandshake(websocket, socket, "Server indicated an extension that was not requested");
|
|
2779
2776
|
return;
|
|
2780
2777
|
}
|
|
2781
2778
|
try {
|
|
2782
|
-
perMessageDeflate.accept(extensions[PerMessageDeflate
|
|
2779
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
|
|
2783
2780
|
} catch (err) {
|
|
2784
|
-
abortHandshake
|
|
2781
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Extensions header");
|
|
2785
2782
|
return;
|
|
2786
2783
|
}
|
|
2787
|
-
websocket._extensions[PerMessageDeflate
|
|
2784
|
+
websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
2788
2785
|
}
|
|
2789
2786
|
websocket.setSocket(socket, head, {
|
|
2790
2787
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
@@ -2806,7 +2803,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2806
2803
|
* @private
|
|
2807
2804
|
*/
|
|
2808
2805
|
function emitErrorAndClose(websocket, err) {
|
|
2809
|
-
websocket._readyState = WebSocket
|
|
2806
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2810
2807
|
websocket._errorEmitted = true;
|
|
2811
2808
|
websocket.emit("error", err);
|
|
2812
2809
|
websocket.emitClose();
|
|
@@ -2843,10 +2840,10 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2843
2840
|
* @param {String} message The error message
|
|
2844
2841
|
* @private
|
|
2845
2842
|
*/
|
|
2846
|
-
function abortHandshake
|
|
2847
|
-
websocket._readyState = WebSocket
|
|
2843
|
+
function abortHandshake(websocket, stream, message) {
|
|
2844
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2848
2845
|
const err = new Error(message);
|
|
2849
|
-
Error.captureStackTrace(err, abortHandshake
|
|
2846
|
+
Error.captureStackTrace(err, abortHandshake);
|
|
2850
2847
|
if (stream.setHeader) {
|
|
2851
2848
|
stream[kAborted] = true;
|
|
2852
2849
|
stream.abort();
|
|
@@ -2886,11 +2883,11 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2886
2883
|
* @private
|
|
2887
2884
|
*/
|
|
2888
2885
|
function receiverOnConclude(code, reason) {
|
|
2889
|
-
const websocket = this[kWebSocket
|
|
2886
|
+
const websocket = this[kWebSocket];
|
|
2890
2887
|
websocket._closeFrameReceived = true;
|
|
2891
2888
|
websocket._closeMessage = reason;
|
|
2892
2889
|
websocket._closeCode = code;
|
|
2893
|
-
if (websocket._socket[kWebSocket
|
|
2890
|
+
if (websocket._socket[kWebSocket] === void 0) return;
|
|
2894
2891
|
websocket._socket.removeListener("data", socketOnData);
|
|
2895
2892
|
process.nextTick(resume, websocket._socket);
|
|
2896
2893
|
if (code === 1005) websocket.close();
|
|
@@ -2902,7 +2899,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2902
2899
|
* @private
|
|
2903
2900
|
*/
|
|
2904
2901
|
function receiverOnDrain() {
|
|
2905
|
-
const websocket = this[kWebSocket
|
|
2902
|
+
const websocket = this[kWebSocket];
|
|
2906
2903
|
if (!websocket.isPaused) websocket._socket.resume();
|
|
2907
2904
|
}
|
|
2908
2905
|
/**
|
|
@@ -2912,8 +2909,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2912
2909
|
* @private
|
|
2913
2910
|
*/
|
|
2914
2911
|
function receiverOnError(err) {
|
|
2915
|
-
const websocket = this[kWebSocket
|
|
2916
|
-
if (websocket._socket[kWebSocket
|
|
2912
|
+
const websocket = this[kWebSocket];
|
|
2913
|
+
if (websocket._socket[kWebSocket] !== void 0) {
|
|
2917
2914
|
websocket._socket.removeListener("data", socketOnData);
|
|
2918
2915
|
process.nextTick(resume, websocket._socket);
|
|
2919
2916
|
websocket.close(err[kStatusCode]);
|
|
@@ -2929,7 +2926,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2929
2926
|
* @private
|
|
2930
2927
|
*/
|
|
2931
2928
|
function receiverOnFinish() {
|
|
2932
|
-
this[kWebSocket
|
|
2929
|
+
this[kWebSocket].emitClose();
|
|
2933
2930
|
}
|
|
2934
2931
|
/**
|
|
2935
2932
|
* The listener of the `Receiver` `'message'` event.
|
|
@@ -2939,7 +2936,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2939
2936
|
* @private
|
|
2940
2937
|
*/
|
|
2941
2938
|
function receiverOnMessage(data, isBinary) {
|
|
2942
|
-
this[kWebSocket
|
|
2939
|
+
this[kWebSocket].emit("message", data, isBinary);
|
|
2943
2940
|
}
|
|
2944
2941
|
/**
|
|
2945
2942
|
* The listener of the `Receiver` `'ping'` event.
|
|
@@ -2948,7 +2945,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2948
2945
|
* @private
|
|
2949
2946
|
*/
|
|
2950
2947
|
function receiverOnPing(data) {
|
|
2951
|
-
const websocket = this[kWebSocket
|
|
2948
|
+
const websocket = this[kWebSocket];
|
|
2952
2949
|
if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
|
|
2953
2950
|
websocket.emit("ping", data);
|
|
2954
2951
|
}
|
|
@@ -2959,7 +2956,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2959
2956
|
* @private
|
|
2960
2957
|
*/
|
|
2961
2958
|
function receiverOnPong(data) {
|
|
2962
|
-
this[kWebSocket
|
|
2959
|
+
this[kWebSocket].emit("pong", data);
|
|
2963
2960
|
}
|
|
2964
2961
|
/**
|
|
2965
2962
|
* Resume a readable stream
|
|
@@ -2977,10 +2974,10 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
2977
2974
|
* @private
|
|
2978
2975
|
*/
|
|
2979
2976
|
function senderOnError(err) {
|
|
2980
|
-
const websocket = this[kWebSocket
|
|
2981
|
-
if (websocket.readyState === WebSocket
|
|
2982
|
-
if (websocket.readyState === WebSocket
|
|
2983
|
-
websocket._readyState = WebSocket
|
|
2977
|
+
const websocket = this[kWebSocket];
|
|
2978
|
+
if (websocket.readyState === WebSocket.CLOSED) return;
|
|
2979
|
+
if (websocket.readyState === WebSocket.OPEN) {
|
|
2980
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
2984
2981
|
setCloseTimer(websocket);
|
|
2985
2982
|
}
|
|
2986
2983
|
this._socket.end();
|
|
@@ -3004,17 +3001,17 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
3004
3001
|
* @private
|
|
3005
3002
|
*/
|
|
3006
3003
|
function socketOnClose() {
|
|
3007
|
-
const websocket = this[kWebSocket
|
|
3004
|
+
const websocket = this[kWebSocket];
|
|
3008
3005
|
this.removeListener("close", socketOnClose);
|
|
3009
3006
|
this.removeListener("data", socketOnData);
|
|
3010
3007
|
this.removeListener("end", socketOnEnd);
|
|
3011
|
-
websocket._readyState = WebSocket
|
|
3008
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
3012
3009
|
if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
3013
3010
|
const chunk = this.read(this._readableState.length);
|
|
3014
3011
|
websocket._receiver.write(chunk);
|
|
3015
3012
|
}
|
|
3016
3013
|
websocket._receiver.end();
|
|
3017
|
-
this[kWebSocket
|
|
3014
|
+
this[kWebSocket] = void 0;
|
|
3018
3015
|
clearTimeout(websocket._closeTimer);
|
|
3019
3016
|
if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) websocket.emitClose();
|
|
3020
3017
|
else {
|
|
@@ -3029,7 +3026,7 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
3029
3026
|
* @private
|
|
3030
3027
|
*/
|
|
3031
3028
|
function socketOnData(chunk) {
|
|
3032
|
-
if (!this[kWebSocket
|
|
3029
|
+
if (!this[kWebSocket]._receiver.write(chunk)) this.pause();
|
|
3033
3030
|
}
|
|
3034
3031
|
/**
|
|
3035
3032
|
* The listener of the socket `'end'` event.
|
|
@@ -3037,8 +3034,8 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
3037
3034
|
* @private
|
|
3038
3035
|
*/
|
|
3039
3036
|
function socketOnEnd() {
|
|
3040
|
-
const websocket = this[kWebSocket
|
|
3041
|
-
websocket._readyState = WebSocket
|
|
3037
|
+
const websocket = this[kWebSocket];
|
|
3038
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
3042
3039
|
websocket._receiver.end();
|
|
3043
3040
|
this.end();
|
|
3044
3041
|
}
|
|
@@ -3047,20 +3044,19 @@ var require_websocket = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/websoc
|
|
|
3047
3044
|
*
|
|
3048
3045
|
* @private
|
|
3049
3046
|
*/
|
|
3050
|
-
function socketOnError
|
|
3051
|
-
const websocket = this[kWebSocket
|
|
3052
|
-
this.removeListener("error", socketOnError
|
|
3047
|
+
function socketOnError() {
|
|
3048
|
+
const websocket = this[kWebSocket];
|
|
3049
|
+
this.removeListener("error", socketOnError);
|
|
3053
3050
|
this.on("error", NOOP);
|
|
3054
3051
|
if (websocket) {
|
|
3055
|
-
websocket._readyState = WebSocket
|
|
3052
|
+
websocket._readyState = WebSocket.CLOSING;
|
|
3056
3053
|
this.destroy();
|
|
3057
3054
|
}
|
|
3058
3055
|
}
|
|
3059
|
-
})
|
|
3060
|
-
|
|
3056
|
+
}));
|
|
3061
3057
|
//#endregion
|
|
3062
3058
|
//#region node_modules/ws/lib/stream.js
|
|
3063
|
-
var require_stream = /* @__PURE__ */
|
|
3059
|
+
var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3064
3060
|
require_websocket();
|
|
3065
3061
|
const { Duplex: Duplex$1 } = __require("stream");
|
|
3066
3062
|
/**
|
|
@@ -3069,7 +3065,7 @@ var require_stream = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/stream.js
|
|
|
3069
3065
|
* @param {Duplex} stream The stream.
|
|
3070
3066
|
* @private
|
|
3071
3067
|
*/
|
|
3072
|
-
function emitClose
|
|
3068
|
+
function emitClose(stream) {
|
|
3073
3069
|
stream.emit("close");
|
|
3074
3070
|
}
|
|
3075
3071
|
/**
|
|
@@ -3099,7 +3095,7 @@ var require_stream = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/stream.js
|
|
|
3099
3095
|
* @return {Duplex} The duplex stream
|
|
3100
3096
|
* @public
|
|
3101
3097
|
*/
|
|
3102
|
-
function createWebSocketStream
|
|
3098
|
+
function createWebSocketStream(ws, options) {
|
|
3103
3099
|
let terminateOnDestroy = true;
|
|
3104
3100
|
const duplex = new Duplex$1({
|
|
3105
3101
|
...options,
|
|
@@ -3124,17 +3120,17 @@ var require_stream = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/stream.js
|
|
|
3124
3120
|
duplex._destroy = function(err, callback) {
|
|
3125
3121
|
if (ws.readyState === ws.CLOSED) {
|
|
3126
3122
|
callback(err);
|
|
3127
|
-
process.nextTick(emitClose
|
|
3123
|
+
process.nextTick(emitClose, duplex);
|
|
3128
3124
|
return;
|
|
3129
3125
|
}
|
|
3130
3126
|
let called = false;
|
|
3131
|
-
ws.once("error", function error(err
|
|
3127
|
+
ws.once("error", function error(err) {
|
|
3132
3128
|
called = true;
|
|
3133
|
-
callback(err
|
|
3129
|
+
callback(err);
|
|
3134
3130
|
});
|
|
3135
3131
|
ws.once("close", function close() {
|
|
3136
3132
|
if (!called) callback(err);
|
|
3137
|
-
process.nextTick(emitClose
|
|
3133
|
+
process.nextTick(emitClose, duplex);
|
|
3138
3134
|
});
|
|
3139
3135
|
if (terminateOnDestroy) ws.terminate();
|
|
3140
3136
|
};
|
|
@@ -3172,12 +3168,11 @@ var require_stream = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/stream.js
|
|
|
3172
3168
|
duplex.on("error", duplexOnError);
|
|
3173
3169
|
return duplex;
|
|
3174
3170
|
}
|
|
3175
|
-
module.exports = createWebSocketStream
|
|
3176
|
-
})
|
|
3177
|
-
|
|
3171
|
+
module.exports = createWebSocketStream;
|
|
3172
|
+
}));
|
|
3178
3173
|
//#endregion
|
|
3179
3174
|
//#region node_modules/ws/lib/subprotocol.js
|
|
3180
|
-
var require_subprotocol = /* @__PURE__ */
|
|
3175
|
+
var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3181
3176
|
const { tokenChars } = require_validation();
|
|
3182
3177
|
/**
|
|
3183
3178
|
* Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.
|
|
@@ -3200,9 +3195,9 @@ var require_subprotocol = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/subp
|
|
|
3200
3195
|
} else if (code === 44) {
|
|
3201
3196
|
if (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
3202
3197
|
if (end === -1) end = i;
|
|
3203
|
-
const protocol
|
|
3204
|
-
if (protocols.has(protocol
|
|
3205
|
-
protocols.add(protocol
|
|
3198
|
+
const protocol = header.slice(start, end);
|
|
3199
|
+
if (protocols.has(protocol)) throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
3200
|
+
protocols.add(protocol);
|
|
3206
3201
|
start = end = -1;
|
|
3207
3202
|
} else throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
3208
3203
|
}
|
|
@@ -3213,19 +3208,18 @@ var require_subprotocol = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib/subp
|
|
|
3213
3208
|
return protocols;
|
|
3214
3209
|
}
|
|
3215
3210
|
module.exports = { parse };
|
|
3216
|
-
})
|
|
3217
|
-
|
|
3211
|
+
}));
|
|
3218
3212
|
//#endregion
|
|
3219
3213
|
//#region node_modules/ws/lib/websocket-server.js
|
|
3220
|
-
var require_websocket_server = /* @__PURE__ */
|
|
3214
|
+
var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3221
3215
|
const EventEmitter = __require("events");
|
|
3222
3216
|
const http = __require("http");
|
|
3223
3217
|
const { Duplex } = __require("stream");
|
|
3224
3218
|
const { createHash } = __require("crypto");
|
|
3225
|
-
const extension
|
|
3226
|
-
const PerMessageDeflate
|
|
3227
|
-
const subprotocol
|
|
3228
|
-
const WebSocket
|
|
3219
|
+
const extension = require_extension();
|
|
3220
|
+
const PerMessageDeflate = require_permessage_deflate();
|
|
3221
|
+
const subprotocol = require_subprotocol();
|
|
3222
|
+
const WebSocket = require_websocket();
|
|
3229
3223
|
const { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();
|
|
3230
3224
|
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
3231
3225
|
const RUNNING = 0;
|
|
@@ -3236,7 +3230,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3236
3230
|
*
|
|
3237
3231
|
* @extends EventEmitter
|
|
3238
3232
|
*/
|
|
3239
|
-
var WebSocketServer
|
|
3233
|
+
var WebSocketServer = class extends EventEmitter {
|
|
3240
3234
|
/**
|
|
3241
3235
|
* Create a `WebSocketServer` instance.
|
|
3242
3236
|
*
|
|
@@ -3255,9 +3249,9 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3255
3249
|
* called
|
|
3256
3250
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
3257
3251
|
* @param {String} [options.host] The hostname where to bind the server
|
|
3258
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
3252
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
3259
3253
|
* buffered data chunks
|
|
3260
|
-
* @param {Number} [options.maxFragments=
|
|
3254
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
3261
3255
|
* fragments
|
|
3262
3256
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3263
3257
|
* size
|
|
@@ -3280,9 +3274,9 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3280
3274
|
options = {
|
|
3281
3275
|
allowSynchronousEvents: true,
|
|
3282
3276
|
autoPong: true,
|
|
3283
|
-
maxBufferedChunks:
|
|
3284
|
-
maxFragments:
|
|
3285
|
-
maxPayload:
|
|
3277
|
+
maxBufferedChunks: 262144,
|
|
3278
|
+
maxFragments: 16384,
|
|
3279
|
+
maxPayload: 104857600,
|
|
3286
3280
|
skipUTF8Validation: false,
|
|
3287
3281
|
perMessageDeflate: false,
|
|
3288
3282
|
handleProtocols: null,
|
|
@@ -3295,7 +3289,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3295
3289
|
host: null,
|
|
3296
3290
|
path: null,
|
|
3297
3291
|
port: null,
|
|
3298
|
-
WebSocket
|
|
3292
|
+
WebSocket,
|
|
3299
3293
|
...options
|
|
3300
3294
|
};
|
|
3301
3295
|
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");
|
|
@@ -3428,7 +3422,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3428
3422
|
const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
|
|
3429
3423
|
let protocols = /* @__PURE__ */ new Set();
|
|
3430
3424
|
if (secWebSocketProtocol !== void 0) try {
|
|
3431
|
-
protocols = subprotocol
|
|
3425
|
+
protocols = subprotocol.parse(secWebSocketProtocol);
|
|
3432
3426
|
} catch (err) {
|
|
3433
3427
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, "Invalid Sec-WebSocket-Protocol header");
|
|
3434
3428
|
return;
|
|
@@ -3436,16 +3430,16 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3436
3430
|
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
3437
3431
|
const extensions = {};
|
|
3438
3432
|
if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
|
|
3439
|
-
const perMessageDeflate = new PerMessageDeflate
|
|
3433
|
+
const perMessageDeflate = new PerMessageDeflate({
|
|
3440
3434
|
...this.options.perMessageDeflate,
|
|
3441
3435
|
isServer: true,
|
|
3442
3436
|
maxPayload: this.options.maxPayload
|
|
3443
3437
|
});
|
|
3444
3438
|
try {
|
|
3445
|
-
const offers = extension
|
|
3446
|
-
if (offers[PerMessageDeflate
|
|
3447
|
-
perMessageDeflate.accept(offers[PerMessageDeflate
|
|
3448
|
-
extensions[PerMessageDeflate
|
|
3439
|
+
const offers = extension.parse(secWebSocketExtensions);
|
|
3440
|
+
if (offers[PerMessageDeflate.extensionName]) {
|
|
3441
|
+
perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
|
|
3442
|
+
extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
3449
3443
|
}
|
|
3450
3444
|
} catch (err) {
|
|
3451
3445
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
|
|
@@ -3500,9 +3494,9 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3500
3494
|
ws._protocol = protocol;
|
|
3501
3495
|
}
|
|
3502
3496
|
}
|
|
3503
|
-
if (extensions[PerMessageDeflate
|
|
3504
|
-
const params = extensions[PerMessageDeflate
|
|
3505
|
-
const value = extension
|
|
3497
|
+
if (extensions[PerMessageDeflate.extensionName]) {
|
|
3498
|
+
const params = extensions[PerMessageDeflate.extensionName].params;
|
|
3499
|
+
const value = extension.format({ [PerMessageDeflate.extensionName]: [params] });
|
|
3506
3500
|
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
3507
3501
|
ws._extensions = extensions;
|
|
3508
3502
|
}
|
|
@@ -3526,7 +3520,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3526
3520
|
cb(ws, req);
|
|
3527
3521
|
}
|
|
3528
3522
|
};
|
|
3529
|
-
module.exports = WebSocketServer
|
|
3523
|
+
module.exports = WebSocketServer;
|
|
3530
3524
|
/**
|
|
3531
3525
|
* Add event listeners on an `EventEmitter` using a map of <event, listener>
|
|
3532
3526
|
* pairs.
|
|
@@ -3600,19 +3594,15 @@ var require_websocket_server = /* @__PURE__ */ __commonJS({ "node_modules/ws/lib
|
|
|
3600
3594
|
server.emit("wsClientError", err, socket, req);
|
|
3601
3595
|
} else abortHandshake(socket, code, message, headers);
|
|
3602
3596
|
}
|
|
3603
|
-
})
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
var import_sender = /* @__PURE__ */ __toESM(require_sender(), 1);
|
|
3612
|
-
var import_subprotocol = /* @__PURE__ */ __toESM(require_subprotocol(), 1);
|
|
3613
|
-
var import_websocket = /* @__PURE__ */ __toESM(require_websocket(), 1);
|
|
3597
|
+
}));
|
|
3598
|
+
require_stream();
|
|
3599
|
+
require_extension();
|
|
3600
|
+
require_permessage_deflate();
|
|
3601
|
+
require_receiver();
|
|
3602
|
+
require_sender();
|
|
3603
|
+
require_subprotocol();
|
|
3604
|
+
require_websocket();
|
|
3614
3605
|
var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);
|
|
3615
|
-
|
|
3616
3606
|
//#endregion
|
|
3617
3607
|
//#region src/lib/browser-mcp/bridge-paths.ts
|
|
3618
3608
|
/**
|
|
@@ -3638,7 +3628,6 @@ var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server()
|
|
|
3638
3628
|
function discoveryPath() {
|
|
3639
3629
|
return path.join(homedir(), ".local", "share", "github-router", "browser-mcp", "bridge.json");
|
|
3640
3630
|
}
|
|
3641
|
-
|
|
3642
3631
|
//#endregion
|
|
3643
3632
|
//#region src/browser-bridge/pending.ts
|
|
3644
3633
|
const pendingMap = /* @__PURE__ */ new Map();
|
|
@@ -3696,11 +3685,11 @@ function pendingDropClient(client) {
|
|
|
3696
3685
|
pendingMap.delete(id);
|
|
3697
3686
|
}
|
|
3698
3687
|
}
|
|
3699
|
-
|
|
3700
3688
|
//#endregion
|
|
3701
3689
|
//#region src/browser-bridge/index.ts
|
|
3702
3690
|
try {
|
|
3703
|
-
|
|
3691
|
+
const debugLog = path.join(tmpdir(), "github-router-bridge-boot.log");
|
|
3692
|
+
appendFileSync(debugLog, `${(/* @__PURE__ */ new Date()).toISOString()} pid=${process$1.pid} argv=${JSON.stringify(process$1.argv)}\n`);
|
|
3704
3693
|
} catch {}
|
|
3705
3694
|
const HEARTBEAT_MS = 5e3;
|
|
3706
3695
|
const HEARTBEAT_MISS_LIMIT = 3;
|
|
@@ -3903,6 +3892,5 @@ process$1.on("uncaughtException", (err) => {
|
|
|
3903
3892
|
process$1.on("unhandledRejection", (err) => {
|
|
3904
3893
|
console.error("[bridge] unhandled rejection:", err);
|
|
3905
3894
|
});
|
|
3906
|
-
|
|
3907
3895
|
//#endregion
|
|
3908
|
-
export {
|
|
3896
|
+
export {};
|