@builder.io/fusion 0.0.1
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/acorn-CvZ7-_4Z.js +4565 -0
- package/angular-CgPQvf1n.js +3718 -0
- package/babel-KOYmARf2.js +9664 -0
- package/builtin_esm-external-require-https-CiDIUPOC.js +35 -0
- package/chunk-hvVJRdgc.js +21 -0
- package/cli.mjs +282974 -0
- package/devtools-D3ITQRwM.js +1824 -0
- package/estree-P1woeAuW.js +6948 -0
- package/flow-Cj8Bfqbw.js +52803 -0
- package/glimmer-DZgC0aBD.js +7417 -0
- package/graphql-9ZKKjw7o.js +1869 -0
- package/html-iG00QOEO.js +6310 -0
- package/markdown-DHYtuV_q.js +6419 -0
- package/meriyah-DdBcx-fh.js +7533 -0
- package/package.json +13 -0
- package/postcss-Co6D0qWj.js +6351 -0
- package/prettier-CMDYv6GV.js +11244 -0
- package/typescript-Ds2m0NUA.js +22131 -0
- package/yaml-B1jXch5c.js +4974 -0
|
@@ -0,0 +1,1824 @@
|
|
|
1
|
+
import { fileURLToPath as __cjsFileURLToPath } from 'url';
|
|
2
|
+
import { dirname as __cjsDirname } from 'path';
|
|
3
|
+
const __dirname = __cjsDirname(__cjsFileURLToPath(import.meta.url));
|
|
4
|
+
import { i as e, o as t, t as n } from "./chunk-hvVJRdgc.js";
|
|
5
|
+
import { a as r, c as i, i as a, l as o, n as s, o as c, r as l, s as u, t as d, u as f } from "./builtin_esm-external-require-https-CiDIUPOC.js";
|
|
6
|
+
import * as p from "tls";
|
|
7
|
+
import * as m from "zlib";
|
|
8
|
+
import * as h from "buffer";
|
|
9
|
+
import g from "react-devtools-core";
|
|
10
|
+
//#region builtin:esm-external-require-tls
|
|
11
|
+
var _ = /* @__PURE__ */ n(((e, t) => {
|
|
12
|
+
t.exports = p.default;
|
|
13
|
+
})), v = /* @__PURE__ */ n(((e, t) => {
|
|
14
|
+
t.exports = m.default;
|
|
15
|
+
})), y = /* @__PURE__ */ n(((e, t) => {
|
|
16
|
+
var n = [
|
|
17
|
+
"nodebuffer",
|
|
18
|
+
"arraybuffer",
|
|
19
|
+
"fragments"
|
|
20
|
+
], r = typeof Blob < "u";
|
|
21
|
+
r && n.push("blob"), t.exports = {
|
|
22
|
+
BINARY_TYPES: n,
|
|
23
|
+
CLOSE_TIMEOUT: 3e4,
|
|
24
|
+
EMPTY_BUFFER: Buffer.alloc(0),
|
|
25
|
+
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
26
|
+
hasBlob: r,
|
|
27
|
+
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
|
28
|
+
kListener: Symbol("kListener"),
|
|
29
|
+
kStatusCode: Symbol("status-code"),
|
|
30
|
+
kWebSocket: Symbol("websocket"),
|
|
31
|
+
NOOP: () => {}
|
|
32
|
+
};
|
|
33
|
+
})), b = /* @__PURE__ */ n(((t, n) => {
|
|
34
|
+
var r = o(), a = i(), s = u(), c = typeof __webpack_require__ == "function" ? __non_webpack_require__ : e, l = process.config && process.config.variables || {}, d = !!process.env.PREBUILDS_ONLY, f = process.versions.modules, p = j() ? "electron" : A() ? "node-webkit" : "node", m = process.env.npm_config_arch || s.arch(), h = process.env.npm_config_platform || s.platform(), g = process.env.LIBC || (M(h) ? "musl" : "glibc"), _ = process.env.ARM_VERSION || (m === "arm64" ? "8" : l.arm_version) || "", v = (process.versions.uv || "").split(".")[0];
|
|
35
|
+
n.exports = y;
|
|
36
|
+
function y(e) {
|
|
37
|
+
return c(y.resolve(e));
|
|
38
|
+
}
|
|
39
|
+
y.resolve = y.path = function(e) {
|
|
40
|
+
e = a.resolve(e || ".");
|
|
41
|
+
try {
|
|
42
|
+
var t = c(a.join(e, "package.json")).name.toUpperCase().replace(/-/g, "_");
|
|
43
|
+
process.env[t + "_PREBUILD"] && (e = process.env[t + "_PREBUILD"]);
|
|
44
|
+
} catch {}
|
|
45
|
+
if (!d) {
|
|
46
|
+
var n = x(a.join(e, "build/Release"), S);
|
|
47
|
+
if (n) return n;
|
|
48
|
+
var r = x(a.join(e, "build/Debug"), S);
|
|
49
|
+
if (r) return r;
|
|
50
|
+
}
|
|
51
|
+
var i = l(e);
|
|
52
|
+
if (i) return i;
|
|
53
|
+
var o = l(a.dirname(process.execPath));
|
|
54
|
+
if (o) return o;
|
|
55
|
+
var s = [
|
|
56
|
+
"platform=" + h,
|
|
57
|
+
"arch=" + m,
|
|
58
|
+
"runtime=" + p,
|
|
59
|
+
"abi=" + f,
|
|
60
|
+
"uv=" + v,
|
|
61
|
+
_ ? "armv=" + _ : "",
|
|
62
|
+
"libc=" + g,
|
|
63
|
+
"node=" + process.versions.node,
|
|
64
|
+
process.versions.electron ? "electron=" + process.versions.electron : "",
|
|
65
|
+
typeof __webpack_require__ == "function" ? "webpack=true" : ""
|
|
66
|
+
].filter(Boolean).join(" ");
|
|
67
|
+
throw Error("No native build was found for " + s + "\n loaded from: " + e + "\n");
|
|
68
|
+
function l(e) {
|
|
69
|
+
var t = b(a.join(e, "prebuilds")).map(C).filter(w(h, m)).sort(T)[0];
|
|
70
|
+
if (t) {
|
|
71
|
+
var n = a.join(e, "prebuilds", t.name), r = b(n).map(E).filter(D(p, f)).sort(k(p))[0];
|
|
72
|
+
if (r) return a.join(n, r.file);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
function b(e) {
|
|
77
|
+
try {
|
|
78
|
+
return r.readdirSync(e);
|
|
79
|
+
} catch {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function x(e, t) {
|
|
84
|
+
var n = b(e).filter(t);
|
|
85
|
+
return n[0] && a.join(e, n[0]);
|
|
86
|
+
}
|
|
87
|
+
function S(e) {
|
|
88
|
+
return /\.node$/.test(e);
|
|
89
|
+
}
|
|
90
|
+
function C(e) {
|
|
91
|
+
var t = e.split("-");
|
|
92
|
+
if (t.length === 2) {
|
|
93
|
+
var n = t[0], r = t[1].split("+");
|
|
94
|
+
if (n && r.length && r.every(Boolean)) return {
|
|
95
|
+
name: e,
|
|
96
|
+
platform: n,
|
|
97
|
+
architectures: r
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function w(e, t) {
|
|
102
|
+
return function(n) {
|
|
103
|
+
return n == null || n.platform !== e ? !1 : n.architectures.includes(t);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function T(e, t) {
|
|
107
|
+
return e.architectures.length - t.architectures.length;
|
|
108
|
+
}
|
|
109
|
+
function E(e) {
|
|
110
|
+
var t = e.split("."), n = t.pop(), r = {
|
|
111
|
+
file: e,
|
|
112
|
+
specificity: 0
|
|
113
|
+
};
|
|
114
|
+
if (n === "node") {
|
|
115
|
+
for (var i = 0; i < t.length; i++) {
|
|
116
|
+
var a = t[i];
|
|
117
|
+
if (a === "node" || a === "electron" || a === "node-webkit") r.runtime = a;
|
|
118
|
+
else if (a === "napi") r.napi = !0;
|
|
119
|
+
else if (a.slice(0, 3) === "abi") r.abi = a.slice(3);
|
|
120
|
+
else if (a.slice(0, 2) === "uv") r.uv = a.slice(2);
|
|
121
|
+
else if (a.slice(0, 4) === "armv") r.armv = a.slice(4);
|
|
122
|
+
else if (a === "glibc" || a === "musl") r.libc = a;
|
|
123
|
+
else continue;
|
|
124
|
+
r.specificity++;
|
|
125
|
+
}
|
|
126
|
+
return r;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function D(e, t) {
|
|
130
|
+
return function(n) {
|
|
131
|
+
return !(n == null || n.runtime && n.runtime !== e && !O(n) || n.abi && n.abi !== t && !n.napi || n.uv && n.uv !== v || n.armv && n.armv !== _ || n.libc && n.libc !== g);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function O(e) {
|
|
135
|
+
return e.runtime === "node" && e.napi;
|
|
136
|
+
}
|
|
137
|
+
function k(e) {
|
|
138
|
+
return function(t, n) {
|
|
139
|
+
return t.runtime === n.runtime ? t.abi === n.abi ? t.specificity === n.specificity ? 0 : t.specificity > n.specificity ? -1 : 1 : t.abi ? -1 : 1 : t.runtime === e ? -1 : 1;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function A() {
|
|
143
|
+
return !!(process.versions && process.versions.nw);
|
|
144
|
+
}
|
|
145
|
+
function j() {
|
|
146
|
+
return process.versions && process.versions.electron || process.env.ELECTRON_RUN_AS_NODE ? !0 : typeof window < "u" && window.process && window.process.type === "renderer";
|
|
147
|
+
}
|
|
148
|
+
function M(e) {
|
|
149
|
+
return e === "linux" && r.existsSync("/etc/alpine-release");
|
|
150
|
+
}
|
|
151
|
+
y.parseTags = E, y.matchTags = D, y.compareTags = k, y.parseTuple = C, y.matchTuple = w, y.compareTuples = T;
|
|
152
|
+
})), x = /* @__PURE__ */ n(((t, n) => {
|
|
153
|
+
var r = typeof __webpack_require__ == "function" ? __non_webpack_require__ : e;
|
|
154
|
+
typeof r.addon == "function" ? n.exports = r.addon.bind(r) : n.exports = b();
|
|
155
|
+
})), S = /* @__PURE__ */ n(((e, t) => {
|
|
156
|
+
t.exports = {
|
|
157
|
+
mask: (e, t, n, r, i) => {
|
|
158
|
+
for (var a = 0; a < i; a++) n[r + a] = e[a] ^ t[a & 3];
|
|
159
|
+
},
|
|
160
|
+
unmask: (e, t) => {
|
|
161
|
+
let n = e.length;
|
|
162
|
+
for (var r = 0; r < n; r++) e[r] ^= t[r & 3];
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
})), C = /* @__PURE__ */ n(((e, t) => {
|
|
166
|
+
try {
|
|
167
|
+
t.exports = x()(__dirname);
|
|
168
|
+
} catch {
|
|
169
|
+
t.exports = S();
|
|
170
|
+
}
|
|
171
|
+
})), w = /* @__PURE__ */ n(((e, t) => {
|
|
172
|
+
var { EMPTY_BUFFER: n } = y(), r = Buffer[Symbol.species];
|
|
173
|
+
function i(e, t) {
|
|
174
|
+
if (e.length === 0) return n;
|
|
175
|
+
if (e.length === 1) return e[0];
|
|
176
|
+
let i = Buffer.allocUnsafe(t), a = 0;
|
|
177
|
+
for (let t = 0; t < e.length; t++) {
|
|
178
|
+
let n = e[t];
|
|
179
|
+
i.set(n, a), a += n.length;
|
|
180
|
+
}
|
|
181
|
+
return a < t ? new r(i.buffer, i.byteOffset, a) : i;
|
|
182
|
+
}
|
|
183
|
+
function a(e, t, n, r, i) {
|
|
184
|
+
for (let a = 0; a < i; a++) n[r + a] = e[a] ^ t[a & 3];
|
|
185
|
+
}
|
|
186
|
+
function o(e, t) {
|
|
187
|
+
for (let n = 0; n < e.length; n++) e[n] ^= t[n & 3];
|
|
188
|
+
}
|
|
189
|
+
function s(e) {
|
|
190
|
+
return e.length === e.buffer.byteLength ? e.buffer : e.buffer.slice(e.byteOffset, e.byteOffset + e.length);
|
|
191
|
+
}
|
|
192
|
+
function c(e) {
|
|
193
|
+
if (c.readOnly = !0, Buffer.isBuffer(e)) return e;
|
|
194
|
+
let t;
|
|
195
|
+
return e instanceof ArrayBuffer ? t = new r(e) : ArrayBuffer.isView(e) ? t = new r(e.buffer, e.byteOffset, e.byteLength) : (t = Buffer.from(e), c.readOnly = !1), t;
|
|
196
|
+
}
|
|
197
|
+
/* istanbul ignore else */
|
|
198
|
+
if (t.exports = {
|
|
199
|
+
concat: i,
|
|
200
|
+
mask: a,
|
|
201
|
+
toArrayBuffer: s,
|
|
202
|
+
toBuffer: c,
|
|
203
|
+
unmask: o
|
|
204
|
+
}, !process.env.WS_NO_BUFFER_UTIL) try {
|
|
205
|
+
let e = C();
|
|
206
|
+
t.exports.mask = function(t, n, r, i, o) {
|
|
207
|
+
o < 48 ? a(t, n, r, i, o) : e.mask(t, n, r, i, o);
|
|
208
|
+
}, t.exports.unmask = function(t, n) {
|
|
209
|
+
t.length < 32 ? o(t, n) : e.unmask(t, n);
|
|
210
|
+
};
|
|
211
|
+
} catch {}
|
|
212
|
+
})), T = /* @__PURE__ */ n(((e, t) => {
|
|
213
|
+
var n = Symbol("kDone"), r = Symbol("kRun");
|
|
214
|
+
t.exports = class {
|
|
215
|
+
constructor(e) {
|
|
216
|
+
this[n] = () => {
|
|
217
|
+
this.pending--, this[r]();
|
|
218
|
+
}, this.concurrency = e || Infinity, this.jobs = [], this.pending = 0;
|
|
219
|
+
}
|
|
220
|
+
add(e) {
|
|
221
|
+
this.jobs.push(e), this[r]();
|
|
222
|
+
}
|
|
223
|
+
[r]() {
|
|
224
|
+
if (this.pending !== this.concurrency && this.jobs.length) {
|
|
225
|
+
let e = this.jobs.shift();
|
|
226
|
+
this.pending++, e(this[n]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
})), E = /* @__PURE__ */ n(((e, t) => {
|
|
231
|
+
var n = v(), r = w(), i = T(), { kStatusCode: a } = y(), o = Buffer[Symbol.species], s = Buffer.from([
|
|
232
|
+
0,
|
|
233
|
+
0,
|
|
234
|
+
255,
|
|
235
|
+
255
|
|
236
|
+
]), c = Symbol("permessage-deflate"), l = Symbol("total-length"), u = Symbol("callback"), d = Symbol("buffers"), f = Symbol("error"), p;
|
|
237
|
+
t.exports = class {
|
|
238
|
+
constructor(e) {
|
|
239
|
+
this._options = e || {}, this._threshold = this._options.threshold === void 0 ? 1024 : this._options.threshold, this._maxPayload = this._options.maxPayload | 0, this._isServer = !!this._options.isServer, this._deflate = null, this._inflate = null, this.params = null, p ||= new i(this._options.concurrencyLimit === void 0 ? 10 : this._options.concurrencyLimit);
|
|
240
|
+
}
|
|
241
|
+
static get extensionName() {
|
|
242
|
+
return "permessage-deflate";
|
|
243
|
+
}
|
|
244
|
+
offer() {
|
|
245
|
+
let e = {};
|
|
246
|
+
return this._options.serverNoContextTakeover && (e.server_no_context_takeover = !0), this._options.clientNoContextTakeover && (e.client_no_context_takeover = !0), this._options.serverMaxWindowBits && (e.server_max_window_bits = this._options.serverMaxWindowBits), this._options.clientMaxWindowBits ? e.client_max_window_bits = this._options.clientMaxWindowBits : this._options.clientMaxWindowBits ?? (e.client_max_window_bits = !0), e;
|
|
247
|
+
}
|
|
248
|
+
accept(e) {
|
|
249
|
+
return e = this.normalizeParams(e), this.params = this._isServer ? this.acceptAsServer(e) : this.acceptAsClient(e), this.params;
|
|
250
|
+
}
|
|
251
|
+
cleanup() {
|
|
252
|
+
if (this._inflate &&= (this._inflate.close(), null), this._deflate) {
|
|
253
|
+
let e = this._deflate[u];
|
|
254
|
+
this._deflate.close(), this._deflate = null, e && e(/* @__PURE__ */ Error("The deflate stream was closed while data was being processed"));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
acceptAsServer(e) {
|
|
258
|
+
let t = this._options, n = e.find((e) => !(t.serverNoContextTakeover === !1 && e.server_no_context_takeover || e.server_max_window_bits && (t.serverMaxWindowBits === !1 || typeof t.serverMaxWindowBits == "number" && t.serverMaxWindowBits > e.server_max_window_bits) || typeof t.clientMaxWindowBits == "number" && !e.client_max_window_bits));
|
|
259
|
+
if (!n) throw Error("None of the extension offers can be accepted");
|
|
260
|
+
return t.serverNoContextTakeover && (n.server_no_context_takeover = !0), t.clientNoContextTakeover && (n.client_no_context_takeover = !0), typeof t.serverMaxWindowBits == "number" && (n.server_max_window_bits = t.serverMaxWindowBits), typeof t.clientMaxWindowBits == "number" ? n.client_max_window_bits = t.clientMaxWindowBits : (n.client_max_window_bits === !0 || t.clientMaxWindowBits === !1) && delete n.client_max_window_bits, n;
|
|
261
|
+
}
|
|
262
|
+
acceptAsClient(e) {
|
|
263
|
+
let t = e[0];
|
|
264
|
+
if (this._options.clientNoContextTakeover === !1 && t.client_no_context_takeover) throw Error("Unexpected parameter \"client_no_context_takeover\"");
|
|
265
|
+
if (!t.client_max_window_bits) typeof this._options.clientMaxWindowBits == "number" && (t.client_max_window_bits = this._options.clientMaxWindowBits);
|
|
266
|
+
else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && t.client_max_window_bits > this._options.clientMaxWindowBits) throw Error("Unexpected or invalid parameter \"client_max_window_bits\"");
|
|
267
|
+
return t;
|
|
268
|
+
}
|
|
269
|
+
normalizeParams(e) {
|
|
270
|
+
return e.forEach((e) => {
|
|
271
|
+
Object.keys(e).forEach((t) => {
|
|
272
|
+
let n = e[t];
|
|
273
|
+
if (n.length > 1) throw Error(`Parameter "${t}" must have only a single value`);
|
|
274
|
+
if (n = n[0], t === "client_max_window_bits") {
|
|
275
|
+
if (n !== !0) {
|
|
276
|
+
let e = +n;
|
|
277
|
+
if (!Number.isInteger(e) || e < 8 || e > 15) throw TypeError(`Invalid value for parameter "${t}": ${n}`);
|
|
278
|
+
n = e;
|
|
279
|
+
} else if (!this._isServer) throw TypeError(`Invalid value for parameter "${t}": ${n}`);
|
|
280
|
+
} else if (t === "server_max_window_bits") {
|
|
281
|
+
let e = +n;
|
|
282
|
+
if (!Number.isInteger(e) || e < 8 || e > 15) throw TypeError(`Invalid value for parameter "${t}": ${n}`);
|
|
283
|
+
n = e;
|
|
284
|
+
} else if (t === "client_no_context_takeover" || t === "server_no_context_takeover") {
|
|
285
|
+
if (n !== !0) throw TypeError(`Invalid value for parameter "${t}": ${n}`);
|
|
286
|
+
} else throw Error(`Unknown parameter "${t}"`);
|
|
287
|
+
e[t] = n;
|
|
288
|
+
});
|
|
289
|
+
}), e;
|
|
290
|
+
}
|
|
291
|
+
decompress(e, t, n) {
|
|
292
|
+
p.add((r) => {
|
|
293
|
+
this._decompress(e, t, (e, t) => {
|
|
294
|
+
r(), n(e, t);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
compress(e, t, n) {
|
|
299
|
+
p.add((r) => {
|
|
300
|
+
this._compress(e, t, (e, t) => {
|
|
301
|
+
r(), n(e, t);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
_decompress(e, t, i) {
|
|
306
|
+
let a = this._isServer ? "client" : "server";
|
|
307
|
+
if (!this._inflate) {
|
|
308
|
+
let e = `${a}_max_window_bits`, t = typeof this.params[e] == "number" ? this.params[e] : n.Z_DEFAULT_WINDOWBITS;
|
|
309
|
+
this._inflate = n.createInflateRaw({
|
|
310
|
+
...this._options.zlibInflateOptions,
|
|
311
|
+
windowBits: t
|
|
312
|
+
}), this._inflate[c] = this, this._inflate[l] = 0, this._inflate[d] = [], this._inflate.on("error", g), this._inflate.on("data", h);
|
|
313
|
+
}
|
|
314
|
+
this._inflate[u] = i, this._inflate.write(e), t && this._inflate.write(s), this._inflate.flush(() => {
|
|
315
|
+
let e = this._inflate[f];
|
|
316
|
+
if (e) {
|
|
317
|
+
this._inflate.close(), this._inflate = null, i(e);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
let n = r.concat(this._inflate[d], this._inflate[l]);
|
|
321
|
+
this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[l] = 0, this._inflate[d] = [], t && this.params[`${a}_no_context_takeover`] && this._inflate.reset()), i(null, n);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
_compress(e, t, i) {
|
|
325
|
+
let a = this._isServer ? "server" : "client";
|
|
326
|
+
if (!this._deflate) {
|
|
327
|
+
let e = `${a}_max_window_bits`, t = typeof this.params[e] == "number" ? this.params[e] : n.Z_DEFAULT_WINDOWBITS;
|
|
328
|
+
this._deflate = n.createDeflateRaw({
|
|
329
|
+
...this._options.zlibDeflateOptions,
|
|
330
|
+
windowBits: t
|
|
331
|
+
}), this._deflate[l] = 0, this._deflate[d] = [], this._deflate.on("data", m);
|
|
332
|
+
}
|
|
333
|
+
this._deflate[u] = i, this._deflate.write(e), this._deflate.flush(n.Z_SYNC_FLUSH, () => {
|
|
334
|
+
if (!this._deflate) return;
|
|
335
|
+
let e = r.concat(this._deflate[d], this._deflate[l]);
|
|
336
|
+
t && (e = new o(e.buffer, e.byteOffset, e.length - 4)), this._deflate[u] = null, this._deflate[l] = 0, this._deflate[d] = [], t && this.params[`${a}_no_context_takeover`] && this._deflate.reset(), i(null, e);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
function m(e) {
|
|
341
|
+
this[d].push(e), this[l] += e.length;
|
|
342
|
+
}
|
|
343
|
+
function h(e) {
|
|
344
|
+
if (this[l] += e.length, this[c]._maxPayload < 1 || this[l] <= this[c]._maxPayload) {
|
|
345
|
+
this[d].push(e);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
this[f] = /* @__PURE__ */ RangeError("Max payload size exceeded"), this[f].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH", this[f][a] = 1009, this.removeListener("data", h), this.reset();
|
|
349
|
+
}
|
|
350
|
+
function g(e) {
|
|
351
|
+
if (this[c]._inflate = null, this[f]) {
|
|
352
|
+
this[u](this[f]);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
e[a] = 1007, this[u](e);
|
|
356
|
+
}
|
|
357
|
+
})), D = /* @__PURE__ */ n(((e, t) => {
|
|
358
|
+
t.exports = h.default;
|
|
359
|
+
})), O = /* @__PURE__ */ n(((e, t) => {
|
|
360
|
+
function n(e) {
|
|
361
|
+
let t = e.length, n = 0;
|
|
362
|
+
for (; n < t;) if (!(e[n] & 128)) n++;
|
|
363
|
+
else if ((e[n] & 224) == 192) {
|
|
364
|
+
if (n + 1 === t || (e[n + 1] & 192) != 128 || (e[n] & 254) == 192) return !1;
|
|
365
|
+
n += 2;
|
|
366
|
+
} else if ((e[n] & 240) == 224) {
|
|
367
|
+
if (n + 2 >= t || (e[n + 1] & 192) != 128 || (e[n + 2] & 192) != 128 || e[n] === 224 && (e[n + 1] & 224) == 128 || e[n] === 237 && (e[n + 1] & 224) == 160) return !1;
|
|
368
|
+
n += 3;
|
|
369
|
+
} else if ((e[n] & 248) == 240) {
|
|
370
|
+
if (n + 3 >= t || (e[n + 1] & 192) != 128 || (e[n + 2] & 192) != 128 || (e[n + 3] & 192) != 128 || e[n] === 240 && (e[n + 1] & 240) == 128 || e[n] === 244 && e[n + 1] > 143 || e[n] > 244) return !1;
|
|
371
|
+
n += 4;
|
|
372
|
+
} else return !1;
|
|
373
|
+
return !0;
|
|
374
|
+
}
|
|
375
|
+
t.exports = n;
|
|
376
|
+
})), k = /* @__PURE__ */ n(((e, t) => {
|
|
377
|
+
try {
|
|
378
|
+
t.exports = x()(__dirname);
|
|
379
|
+
} catch {
|
|
380
|
+
t.exports = O();
|
|
381
|
+
}
|
|
382
|
+
})), A = /* @__PURE__ */ n(((e, t) => {
|
|
383
|
+
var { isUtf8: n } = D(), { hasBlob: r } = y(), i = [
|
|
384
|
+
0,
|
|
385
|
+
0,
|
|
386
|
+
0,
|
|
387
|
+
0,
|
|
388
|
+
0,
|
|
389
|
+
0,
|
|
390
|
+
0,
|
|
391
|
+
0,
|
|
392
|
+
0,
|
|
393
|
+
0,
|
|
394
|
+
0,
|
|
395
|
+
0,
|
|
396
|
+
0,
|
|
397
|
+
0,
|
|
398
|
+
0,
|
|
399
|
+
0,
|
|
400
|
+
0,
|
|
401
|
+
0,
|
|
402
|
+
0,
|
|
403
|
+
0,
|
|
404
|
+
0,
|
|
405
|
+
0,
|
|
406
|
+
0,
|
|
407
|
+
0,
|
|
408
|
+
0,
|
|
409
|
+
0,
|
|
410
|
+
0,
|
|
411
|
+
0,
|
|
412
|
+
0,
|
|
413
|
+
0,
|
|
414
|
+
0,
|
|
415
|
+
0,
|
|
416
|
+
0,
|
|
417
|
+
1,
|
|
418
|
+
0,
|
|
419
|
+
1,
|
|
420
|
+
1,
|
|
421
|
+
1,
|
|
422
|
+
1,
|
|
423
|
+
1,
|
|
424
|
+
0,
|
|
425
|
+
0,
|
|
426
|
+
1,
|
|
427
|
+
1,
|
|
428
|
+
0,
|
|
429
|
+
1,
|
|
430
|
+
1,
|
|
431
|
+
0,
|
|
432
|
+
1,
|
|
433
|
+
1,
|
|
434
|
+
1,
|
|
435
|
+
1,
|
|
436
|
+
1,
|
|
437
|
+
1,
|
|
438
|
+
1,
|
|
439
|
+
1,
|
|
440
|
+
1,
|
|
441
|
+
1,
|
|
442
|
+
0,
|
|
443
|
+
0,
|
|
444
|
+
0,
|
|
445
|
+
0,
|
|
446
|
+
0,
|
|
447
|
+
0,
|
|
448
|
+
0,
|
|
449
|
+
1,
|
|
450
|
+
1,
|
|
451
|
+
1,
|
|
452
|
+
1,
|
|
453
|
+
1,
|
|
454
|
+
1,
|
|
455
|
+
1,
|
|
456
|
+
1,
|
|
457
|
+
1,
|
|
458
|
+
1,
|
|
459
|
+
1,
|
|
460
|
+
1,
|
|
461
|
+
1,
|
|
462
|
+
1,
|
|
463
|
+
1,
|
|
464
|
+
1,
|
|
465
|
+
1,
|
|
466
|
+
1,
|
|
467
|
+
1,
|
|
468
|
+
1,
|
|
469
|
+
1,
|
|
470
|
+
1,
|
|
471
|
+
1,
|
|
472
|
+
1,
|
|
473
|
+
1,
|
|
474
|
+
1,
|
|
475
|
+
0,
|
|
476
|
+
0,
|
|
477
|
+
0,
|
|
478
|
+
1,
|
|
479
|
+
1,
|
|
480
|
+
1,
|
|
481
|
+
1,
|
|
482
|
+
1,
|
|
483
|
+
1,
|
|
484
|
+
1,
|
|
485
|
+
1,
|
|
486
|
+
1,
|
|
487
|
+
1,
|
|
488
|
+
1,
|
|
489
|
+
1,
|
|
490
|
+
1,
|
|
491
|
+
1,
|
|
492
|
+
1,
|
|
493
|
+
1,
|
|
494
|
+
1,
|
|
495
|
+
1,
|
|
496
|
+
1,
|
|
497
|
+
1,
|
|
498
|
+
1,
|
|
499
|
+
1,
|
|
500
|
+
1,
|
|
501
|
+
1,
|
|
502
|
+
1,
|
|
503
|
+
1,
|
|
504
|
+
1,
|
|
505
|
+
1,
|
|
506
|
+
1,
|
|
507
|
+
0,
|
|
508
|
+
1,
|
|
509
|
+
0,
|
|
510
|
+
1,
|
|
511
|
+
0
|
|
512
|
+
];
|
|
513
|
+
function a(e) {
|
|
514
|
+
return e >= 1e3 && e <= 1014 && e !== 1004 && e !== 1005 && e !== 1006 || e >= 3e3 && e <= 4999;
|
|
515
|
+
}
|
|
516
|
+
function o(e) {
|
|
517
|
+
let t = e.length, n = 0;
|
|
518
|
+
for (; n < t;) if (!(e[n] & 128)) n++;
|
|
519
|
+
else if ((e[n] & 224) == 192) {
|
|
520
|
+
if (n + 1 === t || (e[n + 1] & 192) != 128 || (e[n] & 254) == 192) return !1;
|
|
521
|
+
n += 2;
|
|
522
|
+
} else if ((e[n] & 240) == 224) {
|
|
523
|
+
if (n + 2 >= t || (e[n + 1] & 192) != 128 || (e[n + 2] & 192) != 128 || e[n] === 224 && (e[n + 1] & 224) == 128 || e[n] === 237 && (e[n + 1] & 224) == 160) return !1;
|
|
524
|
+
n += 3;
|
|
525
|
+
} else if ((e[n] & 248) == 240) {
|
|
526
|
+
if (n + 3 >= t || (e[n + 1] & 192) != 128 || (e[n + 2] & 192) != 128 || (e[n + 3] & 192) != 128 || e[n] === 240 && (e[n + 1] & 240) == 128 || e[n] === 244 && e[n + 1] > 143 || e[n] > 244) return !1;
|
|
527
|
+
n += 4;
|
|
528
|
+
} else return !1;
|
|
529
|
+
return !0;
|
|
530
|
+
}
|
|
531
|
+
function s(e) {
|
|
532
|
+
return r && typeof e == "object" && typeof e.arrayBuffer == "function" && typeof e.type == "string" && typeof e.stream == "function" && (e[Symbol.toStringTag] === "Blob" || e[Symbol.toStringTag] === "File");
|
|
533
|
+
}
|
|
534
|
+
if (t.exports = {
|
|
535
|
+
isBlob: s,
|
|
536
|
+
isValidStatusCode: a,
|
|
537
|
+
isValidUTF8: o,
|
|
538
|
+
tokenChars: i
|
|
539
|
+
}, n) t.exports.isValidUTF8 = function(e) {
|
|
540
|
+
return e.length < 24 ? o(e) : n(e);
|
|
541
|
+
};
|
|
542
|
+
else if (!process.env.WS_NO_UTF_8_VALIDATE) try {
|
|
543
|
+
let e = k();
|
|
544
|
+
t.exports.isValidUTF8 = function(t) {
|
|
545
|
+
return t.length < 32 ? o(t) : e(t);
|
|
546
|
+
};
|
|
547
|
+
} catch {}
|
|
548
|
+
})), j = /* @__PURE__ */ n(((e, t) => {
|
|
549
|
+
var { Writable: n } = l(), r = E(), { BINARY_TYPES: i, EMPTY_BUFFER: a, kStatusCode: o, kWebSocket: s } = y(), { concat: c, toArrayBuffer: u, unmask: d } = w(), { isValidStatusCode: f, isValidUTF8: p } = A(), m = Buffer[Symbol.species], h = 0, g = 1, _ = 2, v = 3, b = 4, x = 5, S = 6;
|
|
550
|
+
t.exports = class extends n {
|
|
551
|
+
constructor(e = {}) {
|
|
552
|
+
super(), this._allowSynchronousEvents = e.allowSynchronousEvents === void 0 ? !0 : e.allowSynchronousEvents, this._binaryType = e.binaryType || i[0], this._extensions = e.extensions || {}, this._isServer = !!e.isServer, this._maxPayload = e.maxPayload | 0, this._skipUTF8Validation = !!e.skipUTF8Validation, this[s] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._fragments = [], this._errored = !1, this._loop = !1, this._state = h;
|
|
553
|
+
}
|
|
554
|
+
_write(e, t, n) {
|
|
555
|
+
if (this._opcode === 8 && this._state == h) return n();
|
|
556
|
+
this._bufferedBytes += e.length, this._buffers.push(e), this.startLoop(n);
|
|
557
|
+
}
|
|
558
|
+
consume(e) {
|
|
559
|
+
if (this._bufferedBytes -= e, e === this._buffers[0].length) return this._buffers.shift();
|
|
560
|
+
if (e < this._buffers[0].length) {
|
|
561
|
+
let t = this._buffers[0];
|
|
562
|
+
return this._buffers[0] = new m(t.buffer, t.byteOffset + e, t.length - e), new m(t.buffer, t.byteOffset, e);
|
|
563
|
+
}
|
|
564
|
+
let t = Buffer.allocUnsafe(e);
|
|
565
|
+
do {
|
|
566
|
+
let n = this._buffers[0], r = t.length - e;
|
|
567
|
+
e >= n.length ? t.set(this._buffers.shift(), r) : (t.set(new Uint8Array(n.buffer, n.byteOffset, e), r), this._buffers[0] = new m(n.buffer, n.byteOffset + e, n.length - e)), e -= n.length;
|
|
568
|
+
} while (e > 0);
|
|
569
|
+
return t;
|
|
570
|
+
}
|
|
571
|
+
startLoop(e) {
|
|
572
|
+
this._loop = !0;
|
|
573
|
+
do
|
|
574
|
+
switch (this._state) {
|
|
575
|
+
case h:
|
|
576
|
+
this.getInfo(e);
|
|
577
|
+
break;
|
|
578
|
+
case g:
|
|
579
|
+
this.getPayloadLength16(e);
|
|
580
|
+
break;
|
|
581
|
+
case _:
|
|
582
|
+
this.getPayloadLength64(e);
|
|
583
|
+
break;
|
|
584
|
+
case v:
|
|
585
|
+
this.getMask();
|
|
586
|
+
break;
|
|
587
|
+
case b:
|
|
588
|
+
this.getData(e);
|
|
589
|
+
break;
|
|
590
|
+
case x:
|
|
591
|
+
case S:
|
|
592
|
+
this._loop = !1;
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
while (this._loop);
|
|
596
|
+
this._errored || e();
|
|
597
|
+
}
|
|
598
|
+
getInfo(e) {
|
|
599
|
+
if (this._bufferedBytes < 2) {
|
|
600
|
+
this._loop = !1;
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
let t = this.consume(2);
|
|
604
|
+
if (t[0] & 48) {
|
|
605
|
+
e(this.createError(RangeError, "RSV2 and RSV3 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_2_3"));
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
let n = (t[0] & 64) == 64;
|
|
609
|
+
if (n && !this._extensions[r.extensionName]) {
|
|
610
|
+
e(this.createError(RangeError, "RSV1 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (this._fin = (t[0] & 128) == 128, this._opcode = t[0] & 15, this._payloadLength = t[1] & 127, this._opcode === 0) {
|
|
614
|
+
if (n) {
|
|
615
|
+
e(this.createError(RangeError, "RSV1 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (!this._fragmented) {
|
|
619
|
+
e(this.createError(RangeError, "invalid opcode 0", !0, 1002, "WS_ERR_INVALID_OPCODE"));
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
this._opcode = this._fragmented;
|
|
623
|
+
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
624
|
+
if (this._fragmented) {
|
|
625
|
+
e(this.createError(RangeError, `invalid opcode ${this._opcode}`, !0, 1002, "WS_ERR_INVALID_OPCODE"));
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
this._compressed = n;
|
|
629
|
+
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
630
|
+
if (!this._fin) {
|
|
631
|
+
e(this.createError(RangeError, "FIN must be set", !0, 1002, "WS_ERR_EXPECTED_FIN"));
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (n) {
|
|
635
|
+
e(this.createError(RangeError, "RSV1 must be clear", !0, 1002, "WS_ERR_UNEXPECTED_RSV_1"));
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
639
|
+
e(this.createError(RangeError, `invalid payload length ${this._payloadLength}`, !0, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"));
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
} else {
|
|
643
|
+
e(this.createError(RangeError, `invalid opcode ${this._opcode}`, !0, 1002, "WS_ERR_INVALID_OPCODE"));
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (t[1] & 128) == 128, this._isServer) {
|
|
647
|
+
if (!this._masked) {
|
|
648
|
+
e(this.createError(RangeError, "MASK must be set", !0, 1002, "WS_ERR_EXPECTED_MASK"));
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
} else if (this._masked) {
|
|
652
|
+
e(this.createError(RangeError, "MASK must be clear", !0, 1002, "WS_ERR_UNEXPECTED_MASK"));
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
this._payloadLength === 126 ? this._state = g : this._payloadLength === 127 ? this._state = _ : this.haveLength(e);
|
|
656
|
+
}
|
|
657
|
+
getPayloadLength16(e) {
|
|
658
|
+
if (this._bufferedBytes < 2) {
|
|
659
|
+
this._loop = !1;
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength(e);
|
|
663
|
+
}
|
|
664
|
+
getPayloadLength64(e) {
|
|
665
|
+
if (this._bufferedBytes < 8) {
|
|
666
|
+
this._loop = !1;
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
let t = this.consume(8), n = t.readUInt32BE(0);
|
|
670
|
+
if (n > 2 ** 21 - 1) {
|
|
671
|
+
e(this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", !1, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"));
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
this._payloadLength = n * 2 ** 32 + t.readUInt32BE(4), this.haveLength(e);
|
|
675
|
+
}
|
|
676
|
+
haveLength(e) {
|
|
677
|
+
if (this._payloadLength && this._opcode < 8 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0)) {
|
|
678
|
+
e(this.createError(RangeError, "Max payload size exceeded", !1, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
this._masked ? this._state = v : this._state = b;
|
|
682
|
+
}
|
|
683
|
+
getMask() {
|
|
684
|
+
if (this._bufferedBytes < 4) {
|
|
685
|
+
this._loop = !1;
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
this._mask = this.consume(4), this._state = b;
|
|
689
|
+
}
|
|
690
|
+
getData(e) {
|
|
691
|
+
let t = a;
|
|
692
|
+
if (this._payloadLength) {
|
|
693
|
+
if (this._bufferedBytes < this._payloadLength) {
|
|
694
|
+
this._loop = !1;
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
t = this.consume(this._payloadLength), this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0 && d(t, this._mask);
|
|
698
|
+
}
|
|
699
|
+
if (this._opcode > 7) {
|
|
700
|
+
this.controlMessage(t, e);
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
if (this._compressed) {
|
|
704
|
+
this._state = x, this.decompress(t, e);
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
t.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(t)), this.dataMessage(e);
|
|
708
|
+
}
|
|
709
|
+
decompress(e, t) {
|
|
710
|
+
this._extensions[r.extensionName].decompress(e, this._fin, (e, n) => {
|
|
711
|
+
if (e) return t(e);
|
|
712
|
+
if (n.length) {
|
|
713
|
+
if (this._messageLength += n.length, this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
714
|
+
t(this.createError(RangeError, "Max payload size exceeded", !1, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
this._fragments.push(n);
|
|
718
|
+
}
|
|
719
|
+
this.dataMessage(t), this._state === h && this.startLoop(t);
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
dataMessage(e) {
|
|
723
|
+
if (!this._fin) {
|
|
724
|
+
this._state = h;
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
let t = this._messageLength, n = this._fragments;
|
|
728
|
+
if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._fragments = [], this._opcode === 2) {
|
|
729
|
+
let r;
|
|
730
|
+
r = this._binaryType === "nodebuffer" ? c(n, t) : this._binaryType === "arraybuffer" ? u(c(n, t)) : this._binaryType === "blob" ? new Blob(n) : n, this._allowSynchronousEvents ? (this.emit("message", r, !0), this._state = h) : (this._state = S, setImmediate(() => {
|
|
731
|
+
this.emit("message", r, !0), this._state = h, this.startLoop(e);
|
|
732
|
+
}));
|
|
733
|
+
} else {
|
|
734
|
+
let r = c(n, t);
|
|
735
|
+
if (!this._skipUTF8Validation && !p(r)) {
|
|
736
|
+
e(this.createError(Error, "invalid UTF-8 sequence", !0, 1007, "WS_ERR_INVALID_UTF8"));
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
this._state === x || this._allowSynchronousEvents ? (this.emit("message", r, !1), this._state = h) : (this._state = S, setImmediate(() => {
|
|
740
|
+
this.emit("message", r, !1), this._state = h, this.startLoop(e);
|
|
741
|
+
}));
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
controlMessage(e, t) {
|
|
745
|
+
if (this._opcode === 8) {
|
|
746
|
+
if (e.length === 0) this._loop = !1, this.emit("conclude", 1005, a), this.end();
|
|
747
|
+
else {
|
|
748
|
+
let n = e.readUInt16BE(0);
|
|
749
|
+
if (!f(n)) {
|
|
750
|
+
t(this.createError(RangeError, `invalid status code ${n}`, !0, 1002, "WS_ERR_INVALID_CLOSE_CODE"));
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
let r = new m(e.buffer, e.byteOffset + 2, e.length - 2);
|
|
754
|
+
if (!this._skipUTF8Validation && !p(r)) {
|
|
755
|
+
t(this.createError(Error, "invalid UTF-8 sequence", !0, 1007, "WS_ERR_INVALID_UTF8"));
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
this._loop = !1, this.emit("conclude", n, r), this.end();
|
|
759
|
+
}
|
|
760
|
+
this._state = h;
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
this._allowSynchronousEvents ? (this.emit(this._opcode === 9 ? "ping" : "pong", e), this._state = h) : (this._state = S, setImmediate(() => {
|
|
764
|
+
this.emit(this._opcode === 9 ? "ping" : "pong", e), this._state = h, this.startLoop(t);
|
|
765
|
+
}));
|
|
766
|
+
}
|
|
767
|
+
createError(e, t, n, r, i) {
|
|
768
|
+
this._loop = !1, this._errored = !0;
|
|
769
|
+
let a = new e(n ? `Invalid WebSocket frame: ${t}` : t);
|
|
770
|
+
return Error.captureStackTrace(a, this.createError), a.code = i, a[o] = r, a;
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
})), M = /* @__PURE__ */ n(((e, t) => {
|
|
774
|
+
var { Duplex: n } = l(), { randomFillSync: r } = c(), i = E(), { EMPTY_BUFFER: a, kWebSocket: o, NOOP: s } = y(), { isBlob: u, isValidStatusCode: d } = A(), { mask: f, toBuffer: p } = w(), m = Symbol("kByteLength"), h = Buffer.alloc(4), g = 8 * 1024, _, v = g, b = 0, x = 1, S = 2;
|
|
775
|
+
t.exports = class e {
|
|
776
|
+
constructor(e, t, n) {
|
|
777
|
+
this._extensions = t || {}, n && (this._generateMask = n, this._maskBuffer = Buffer.alloc(4)), this._socket = e, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._queue = [], this._state = b, this.onerror = s, this[o] = void 0;
|
|
778
|
+
}
|
|
779
|
+
static frame(e, t) {
|
|
780
|
+
let n, i = !1, a = 2, o = !1;
|
|
781
|
+
t.mask && (n = t.maskBuffer || h, t.generateMask ? t.generateMask(n) : (v === g && (_ === void 0 && (_ = Buffer.alloc(g)), r(_, 0, g), v = 0), n[0] = _[v++], n[1] = _[v++], n[2] = _[v++], n[3] = _[v++]), o = (n[0] | n[1] | n[2] | n[3]) === 0, a = 6);
|
|
782
|
+
let s;
|
|
783
|
+
typeof e == "string" ? (!t.mask || o) && t[m] !== void 0 ? s = t[m] : (e = Buffer.from(e), s = e.length) : (s = e.length, i = t.mask && t.readOnly && !o);
|
|
784
|
+
let c = s;
|
|
785
|
+
s >= 65536 ? (a += 8, c = 127) : s > 125 && (a += 2, c = 126);
|
|
786
|
+
let l = Buffer.allocUnsafe(i ? s + a : a);
|
|
787
|
+
return l[0] = t.fin ? t.opcode | 128 : t.opcode, t.rsv1 && (l[0] |= 64), l[1] = c, c === 126 ? l.writeUInt16BE(s, 2) : c === 127 && (l[2] = l[3] = 0, l.writeUIntBE(s, 4, 6)), !t.mask || (l[1] |= 128, l[a - 4] = n[0], l[a - 3] = n[1], l[a - 2] = n[2], l[a - 1] = n[3], o) ? [l, e] : i ? (f(e, n, l, a, s), [l]) : (f(e, n, e, 0, s), [l, e]);
|
|
788
|
+
}
|
|
789
|
+
close(t, n, r, i) {
|
|
790
|
+
let o;
|
|
791
|
+
if (t === void 0) o = a;
|
|
792
|
+
else if (typeof t != "number" || !d(t)) throw TypeError("First argument must be a valid error code number");
|
|
793
|
+
else if (n === void 0 || !n.length) o = Buffer.allocUnsafe(2), o.writeUInt16BE(t, 0);
|
|
794
|
+
else {
|
|
795
|
+
let e = Buffer.byteLength(n);
|
|
796
|
+
if (e > 123) throw RangeError("The message must not be greater than 123 bytes");
|
|
797
|
+
o = Buffer.allocUnsafe(2 + e), o.writeUInt16BE(t, 0), typeof n == "string" ? o.write(n, 2) : o.set(n, 2);
|
|
798
|
+
}
|
|
799
|
+
let s = {
|
|
800
|
+
[m]: o.length,
|
|
801
|
+
fin: !0,
|
|
802
|
+
generateMask: this._generateMask,
|
|
803
|
+
mask: r,
|
|
804
|
+
maskBuffer: this._maskBuffer,
|
|
805
|
+
opcode: 8,
|
|
806
|
+
readOnly: !1,
|
|
807
|
+
rsv1: !1
|
|
808
|
+
};
|
|
809
|
+
this._state === b ? this.sendFrame(e.frame(o, s), i) : this.enqueue([
|
|
810
|
+
this.dispatch,
|
|
811
|
+
o,
|
|
812
|
+
!1,
|
|
813
|
+
s,
|
|
814
|
+
i
|
|
815
|
+
]);
|
|
816
|
+
}
|
|
817
|
+
ping(t, n, r) {
|
|
818
|
+
let i, a;
|
|
819
|
+
if (typeof t == "string" ? (i = Buffer.byteLength(t), a = !1) : u(t) ? (i = t.size, a = !1) : (t = p(t), i = t.length, a = p.readOnly), i > 125) throw RangeError("The data size must not be greater than 125 bytes");
|
|
820
|
+
let o = {
|
|
821
|
+
[m]: i,
|
|
822
|
+
fin: !0,
|
|
823
|
+
generateMask: this._generateMask,
|
|
824
|
+
mask: n,
|
|
825
|
+
maskBuffer: this._maskBuffer,
|
|
826
|
+
opcode: 9,
|
|
827
|
+
readOnly: a,
|
|
828
|
+
rsv1: !1
|
|
829
|
+
};
|
|
830
|
+
u(t) ? this._state === b ? this.getBlobData(t, !1, o, r) : this.enqueue([
|
|
831
|
+
this.getBlobData,
|
|
832
|
+
t,
|
|
833
|
+
!1,
|
|
834
|
+
o,
|
|
835
|
+
r
|
|
836
|
+
]) : this._state === b ? this.sendFrame(e.frame(t, o), r) : this.enqueue([
|
|
837
|
+
this.dispatch,
|
|
838
|
+
t,
|
|
839
|
+
!1,
|
|
840
|
+
o,
|
|
841
|
+
r
|
|
842
|
+
]);
|
|
843
|
+
}
|
|
844
|
+
pong(t, n, r) {
|
|
845
|
+
let i, a;
|
|
846
|
+
if (typeof t == "string" ? (i = Buffer.byteLength(t), a = !1) : u(t) ? (i = t.size, a = !1) : (t = p(t), i = t.length, a = p.readOnly), i > 125) throw RangeError("The data size must not be greater than 125 bytes");
|
|
847
|
+
let o = {
|
|
848
|
+
[m]: i,
|
|
849
|
+
fin: !0,
|
|
850
|
+
generateMask: this._generateMask,
|
|
851
|
+
mask: n,
|
|
852
|
+
maskBuffer: this._maskBuffer,
|
|
853
|
+
opcode: 10,
|
|
854
|
+
readOnly: a,
|
|
855
|
+
rsv1: !1
|
|
856
|
+
};
|
|
857
|
+
u(t) ? this._state === b ? this.getBlobData(t, !1, o, r) : this.enqueue([
|
|
858
|
+
this.getBlobData,
|
|
859
|
+
t,
|
|
860
|
+
!1,
|
|
861
|
+
o,
|
|
862
|
+
r
|
|
863
|
+
]) : this._state === b ? this.sendFrame(e.frame(t, o), r) : this.enqueue([
|
|
864
|
+
this.dispatch,
|
|
865
|
+
t,
|
|
866
|
+
!1,
|
|
867
|
+
o,
|
|
868
|
+
r
|
|
869
|
+
]);
|
|
870
|
+
}
|
|
871
|
+
send(e, t, n) {
|
|
872
|
+
let r = this._extensions[i.extensionName], a = t.binary ? 2 : 1, o = t.compress, s, c;
|
|
873
|
+
typeof e == "string" ? (s = Buffer.byteLength(e), c = !1) : u(e) ? (s = e.size, c = !1) : (e = p(e), s = e.length, c = p.readOnly), this._firstFragment ? (this._firstFragment = !1, o && r && r.params[r._isServer ? "server_no_context_takeover" : "client_no_context_takeover"] && (o = s >= r._threshold), this._compress = o) : (o = !1, a = 0), t.fin && (this._firstFragment = !0);
|
|
874
|
+
let l = {
|
|
875
|
+
[m]: s,
|
|
876
|
+
fin: t.fin,
|
|
877
|
+
generateMask: this._generateMask,
|
|
878
|
+
mask: t.mask,
|
|
879
|
+
maskBuffer: this._maskBuffer,
|
|
880
|
+
opcode: a,
|
|
881
|
+
readOnly: c,
|
|
882
|
+
rsv1: o
|
|
883
|
+
};
|
|
884
|
+
u(e) ? this._state === b ? this.getBlobData(e, this._compress, l, n) : this.enqueue([
|
|
885
|
+
this.getBlobData,
|
|
886
|
+
e,
|
|
887
|
+
this._compress,
|
|
888
|
+
l,
|
|
889
|
+
n
|
|
890
|
+
]) : this._state === b ? this.dispatch(e, this._compress, l, n) : this.enqueue([
|
|
891
|
+
this.dispatch,
|
|
892
|
+
e,
|
|
893
|
+
this._compress,
|
|
894
|
+
l,
|
|
895
|
+
n
|
|
896
|
+
]);
|
|
897
|
+
}
|
|
898
|
+
getBlobData(t, n, r, i) {
|
|
899
|
+
this._bufferedBytes += r[m], this._state = S, t.arrayBuffer().then((t) => {
|
|
900
|
+
if (this._socket.destroyed) {
|
|
901
|
+
let e = /* @__PURE__ */ Error("The socket was closed while the blob was being read");
|
|
902
|
+
process.nextTick(C, this, e, i);
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
this._bufferedBytes -= r[m];
|
|
906
|
+
let a = p(t);
|
|
907
|
+
n ? this.dispatch(a, n, r, i) : (this._state = b, this.sendFrame(e.frame(a, r), i), this.dequeue());
|
|
908
|
+
}).catch((e) => {
|
|
909
|
+
process.nextTick(T, this, e, i);
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
dispatch(t, n, r, a) {
|
|
913
|
+
if (!n) {
|
|
914
|
+
this.sendFrame(e.frame(t, r), a);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
let o = this._extensions[i.extensionName];
|
|
918
|
+
this._bufferedBytes += r[m], this._state = x, o.compress(t, r.fin, (t, n) => {
|
|
919
|
+
if (this._socket.destroyed) {
|
|
920
|
+
C(this, /* @__PURE__ */ Error("The socket was closed while data was being compressed"), a);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
this._bufferedBytes -= r[m], this._state = b, r.readOnly = !1, this.sendFrame(e.frame(n, r), a), this.dequeue();
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
dequeue() {
|
|
927
|
+
for (; this._state === b && this._queue.length;) {
|
|
928
|
+
let e = this._queue.shift();
|
|
929
|
+
this._bufferedBytes -= e[3][m], Reflect.apply(e[0], this, e.slice(1));
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
enqueue(e) {
|
|
933
|
+
this._bufferedBytes += e[3][m], this._queue.push(e);
|
|
934
|
+
}
|
|
935
|
+
sendFrame(e, t) {
|
|
936
|
+
e.length === 2 ? (this._socket.cork(), this._socket.write(e[0]), this._socket.write(e[1], t), this._socket.uncork()) : this._socket.write(e[0], t);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
function C(e, t, n) {
|
|
940
|
+
typeof n == "function" && n(t);
|
|
941
|
+
for (let n = 0; n < e._queue.length; n++) {
|
|
942
|
+
let r = e._queue[n], i = r[r.length - 1];
|
|
943
|
+
typeof i == "function" && i(t);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
function T(e, t, n) {
|
|
947
|
+
C(e, t, n), e.onerror(t);
|
|
948
|
+
}
|
|
949
|
+
})), ee = /* @__PURE__ */ n(((e, t) => {
|
|
950
|
+
var { kForOnEventAttribute: n, kListener: r } = y(), i = Symbol("kCode"), a = Symbol("kData"), o = Symbol("kError"), s = Symbol("kMessage"), c = Symbol("kReason"), l = Symbol("kTarget"), u = Symbol("kType"), d = Symbol("kWasClean"), f = class {
|
|
951
|
+
constructor(e) {
|
|
952
|
+
this[l] = null, this[u] = e;
|
|
953
|
+
}
|
|
954
|
+
get target() {
|
|
955
|
+
return this[l];
|
|
956
|
+
}
|
|
957
|
+
get type() {
|
|
958
|
+
return this[u];
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
Object.defineProperty(f.prototype, "target", { enumerable: !0 }), Object.defineProperty(f.prototype, "type", { enumerable: !0 });
|
|
962
|
+
var p = class extends f {
|
|
963
|
+
constructor(e, t = {}) {
|
|
964
|
+
super(e), this[i] = t.code === void 0 ? 0 : t.code, this[c] = t.reason === void 0 ? "" : t.reason, this[d] = t.wasClean === void 0 ? !1 : t.wasClean;
|
|
965
|
+
}
|
|
966
|
+
get code() {
|
|
967
|
+
return this[i];
|
|
968
|
+
}
|
|
969
|
+
get reason() {
|
|
970
|
+
return this[c];
|
|
971
|
+
}
|
|
972
|
+
get wasClean() {
|
|
973
|
+
return this[d];
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
Object.defineProperty(p.prototype, "code", { enumerable: !0 }), Object.defineProperty(p.prototype, "reason", { enumerable: !0 }), Object.defineProperty(p.prototype, "wasClean", { enumerable: !0 });
|
|
977
|
+
var m = class extends f {
|
|
978
|
+
constructor(e, t = {}) {
|
|
979
|
+
super(e), this[o] = t.error === void 0 ? null : t.error, this[s] = t.message === void 0 ? "" : t.message;
|
|
980
|
+
}
|
|
981
|
+
get error() {
|
|
982
|
+
return this[o];
|
|
983
|
+
}
|
|
984
|
+
get message() {
|
|
985
|
+
return this[s];
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
Object.defineProperty(m.prototype, "error", { enumerable: !0 }), Object.defineProperty(m.prototype, "message", { enumerable: !0 });
|
|
989
|
+
var h = class extends f {
|
|
990
|
+
constructor(e, t = {}) {
|
|
991
|
+
super(e), this[a] = t.data === void 0 ? null : t.data;
|
|
992
|
+
}
|
|
993
|
+
get data() {
|
|
994
|
+
return this[a];
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
Object.defineProperty(h.prototype, "data", { enumerable: !0 }), t.exports = {
|
|
998
|
+
CloseEvent: p,
|
|
999
|
+
ErrorEvent: m,
|
|
1000
|
+
Event: f,
|
|
1001
|
+
EventTarget: {
|
|
1002
|
+
addEventListener(e, t, i = {}) {
|
|
1003
|
+
for (let a of this.listeners(e)) if (!i[n] && a[r] === t && !a[n]) return;
|
|
1004
|
+
let a;
|
|
1005
|
+
if (e === "message") a = function(e, n) {
|
|
1006
|
+
let r = new h("message", { data: n ? e : e.toString() });
|
|
1007
|
+
r[l] = this, g(t, this, r);
|
|
1008
|
+
};
|
|
1009
|
+
else if (e === "close") a = function(e, n) {
|
|
1010
|
+
let r = new p("close", {
|
|
1011
|
+
code: e,
|
|
1012
|
+
reason: n.toString(),
|
|
1013
|
+
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
1014
|
+
});
|
|
1015
|
+
r[l] = this, g(t, this, r);
|
|
1016
|
+
};
|
|
1017
|
+
else if (e === "error") a = function(e) {
|
|
1018
|
+
let n = new m("error", {
|
|
1019
|
+
error: e,
|
|
1020
|
+
message: e.message
|
|
1021
|
+
});
|
|
1022
|
+
n[l] = this, g(t, this, n);
|
|
1023
|
+
};
|
|
1024
|
+
else if (e === "open") a = function() {
|
|
1025
|
+
let e = new f("open");
|
|
1026
|
+
e[l] = this, g(t, this, e);
|
|
1027
|
+
};
|
|
1028
|
+
else return;
|
|
1029
|
+
a[n] = !!i[n], a[r] = t, i.once ? this.once(e, a) : this.on(e, a);
|
|
1030
|
+
},
|
|
1031
|
+
removeEventListener(e, t) {
|
|
1032
|
+
for (let i of this.listeners(e)) if (i[r] === t && !i[n]) {
|
|
1033
|
+
this.removeListener(e, i);
|
|
1034
|
+
break;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
MessageEvent: h
|
|
1039
|
+
};
|
|
1040
|
+
function g(e, t, n) {
|
|
1041
|
+
typeof e == "object" && e.handleEvent ? e.handleEvent.call(e, n) : e.call(t, n);
|
|
1042
|
+
}
|
|
1043
|
+
})), N = /* @__PURE__ */ n(((e, t) => {
|
|
1044
|
+
var { tokenChars: n } = A();
|
|
1045
|
+
function r(e, t, n) {
|
|
1046
|
+
e[t] === void 0 ? e[t] = [n] : e[t].push(n);
|
|
1047
|
+
}
|
|
1048
|
+
function i(e) {
|
|
1049
|
+
let t = Object.create(null), i = Object.create(null), a = !1, o = !1, s = !1, c, l, u = -1, d = -1, f = -1, p = 0;
|
|
1050
|
+
for (; p < e.length; p++) if (d = e.charCodeAt(p), c === void 0) if (f === -1 && n[d] === 1) u === -1 && (u = p);
|
|
1051
|
+
else if (p !== 0 && (d === 32 || d === 9)) f === -1 && u !== -1 && (f = p);
|
|
1052
|
+
else if (d === 59 || d === 44) {
|
|
1053
|
+
if (u === -1) throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1054
|
+
f === -1 && (f = p);
|
|
1055
|
+
let n = e.slice(u, f);
|
|
1056
|
+
d === 44 ? (r(t, n, i), i = Object.create(null)) : c = n, u = f = -1;
|
|
1057
|
+
} else throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1058
|
+
else if (l === void 0) if (f === -1 && n[d] === 1) u === -1 && (u = p);
|
|
1059
|
+
else if (d === 32 || d === 9) f === -1 && u !== -1 && (f = p);
|
|
1060
|
+
else if (d === 59 || d === 44) {
|
|
1061
|
+
if (u === -1) throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1062
|
+
f === -1 && (f = p), r(i, e.slice(u, f), !0), d === 44 && (r(t, c, i), i = Object.create(null), c = void 0), u = f = -1;
|
|
1063
|
+
} else if (d === 61 && u !== -1 && f === -1) l = e.slice(u, p), u = f = -1;
|
|
1064
|
+
else throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1065
|
+
else if (o) {
|
|
1066
|
+
if (n[d] !== 1) throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1067
|
+
u === -1 ? u = p : a ||= !0, o = !1;
|
|
1068
|
+
} else if (s) if (n[d] === 1) u === -1 && (u = p);
|
|
1069
|
+
else if (d === 34 && u !== -1) s = !1, f = p;
|
|
1070
|
+
else if (d === 92) o = !0;
|
|
1071
|
+
else throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1072
|
+
else if (d === 34 && e.charCodeAt(p - 1) === 61) s = !0;
|
|
1073
|
+
else if (f === -1 && n[d] === 1) u === -1 && (u = p);
|
|
1074
|
+
else if (u !== -1 && (d === 32 || d === 9)) f === -1 && (f = p);
|
|
1075
|
+
else if (d === 59 || d === 44) {
|
|
1076
|
+
if (u === -1) throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1077
|
+
f === -1 && (f = p);
|
|
1078
|
+
let n = e.slice(u, f);
|
|
1079
|
+
a &&= (n = n.replace(/\\/g, ""), !1), r(i, l, n), d === 44 && (r(t, c, i), i = Object.create(null), c = void 0), l = void 0, u = f = -1;
|
|
1080
|
+
} else throw SyntaxError(`Unexpected character at index ${p}`);
|
|
1081
|
+
if (u === -1 || s || d === 32 || d === 9) throw SyntaxError("Unexpected end of input");
|
|
1082
|
+
f === -1 && (f = p);
|
|
1083
|
+
let m = e.slice(u, f);
|
|
1084
|
+
return c === void 0 ? r(t, m, i) : (l === void 0 ? r(i, m, !0) : a ? r(i, l, m.replace(/\\/g, "")) : r(i, l, m), r(t, c, i)), t;
|
|
1085
|
+
}
|
|
1086
|
+
function a(e) {
|
|
1087
|
+
return Object.keys(e).map((t) => {
|
|
1088
|
+
let n = e[t];
|
|
1089
|
+
return Array.isArray(n) || (n = [n]), n.map((e) => [t].concat(Object.keys(e).map((t) => {
|
|
1090
|
+
let n = e[t];
|
|
1091
|
+
return Array.isArray(n) || (n = [n]), n.map((e) => e === !0 ? t : `${t}=${e}`).join("; ");
|
|
1092
|
+
})).join("; ")).join(", ");
|
|
1093
|
+
}).join(", ");
|
|
1094
|
+
}
|
|
1095
|
+
t.exports = {
|
|
1096
|
+
format: a,
|
|
1097
|
+
parse: i
|
|
1098
|
+
};
|
|
1099
|
+
})), P = /* @__PURE__ */ n(((e, t) => {
|
|
1100
|
+
var n = f(), i = d(), o = s(), u = a(), p = _(), { randomBytes: m, createHash: h } = c(), { Duplex: g, Readable: v } = l(), { URL: b } = r(), x = E(), S = j(), C = M(), { isBlob: T } = A(), { BINARY_TYPES: D, CLOSE_TIMEOUT: O, EMPTY_BUFFER: k, GUID: P, kForOnEventAttribute: F, kListener: I, kStatusCode: L, kWebSocket: R, NOOP: z } = y(), { EventTarget: { addEventListener: B, removeEventListener: te } } = ee(), { format: ne, parse: re } = N(), { toBuffer: ie } = w(), V = Symbol("kAborted"), H = [8, 13], U = [
|
|
1101
|
+
"CONNECTING",
|
|
1102
|
+
"OPEN",
|
|
1103
|
+
"CLOSING",
|
|
1104
|
+
"CLOSED"
|
|
1105
|
+
], ae = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/, W = class e extends n {
|
|
1106
|
+
constructor(t, n, r) {
|
|
1107
|
+
super(), this._binaryType = D[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = k, this._closeTimer = null, this._errorEmitted = !1, this._extensions = {}, this._paused = !1, this._protocol = "", this._readyState = e.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, t === null ? (this._autoPong = r.autoPong, this._closeTimeout = r.closeTimeout, this._isServer = !0) : (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, n === void 0 ? n = [] : Array.isArray(n) || (typeof n == "object" && n ? (r = n, n = []) : n = [n]), G(this, t, n, r));
|
|
1108
|
+
}
|
|
1109
|
+
get binaryType() {
|
|
1110
|
+
return this._binaryType;
|
|
1111
|
+
}
|
|
1112
|
+
set binaryType(e) {
|
|
1113
|
+
D.includes(e) && (this._binaryType = e, this._receiver && (this._receiver._binaryType = e));
|
|
1114
|
+
}
|
|
1115
|
+
get bufferedAmount() {
|
|
1116
|
+
return this._socket ? this._socket._writableState.length + this._sender._bufferedBytes : this._bufferedAmount;
|
|
1117
|
+
}
|
|
1118
|
+
get extensions() {
|
|
1119
|
+
return Object.keys(this._extensions).join();
|
|
1120
|
+
}
|
|
1121
|
+
get isPaused() {
|
|
1122
|
+
return this._paused;
|
|
1123
|
+
}
|
|
1124
|
+
/* istanbul ignore next */
|
|
1125
|
+
get onclose() {
|
|
1126
|
+
return null;
|
|
1127
|
+
}
|
|
1128
|
+
/* istanbul ignore next */
|
|
1129
|
+
get onerror() {
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
/* istanbul ignore next */
|
|
1133
|
+
get onopen() {
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
/* istanbul ignore next */
|
|
1137
|
+
get onmessage() {
|
|
1138
|
+
return null;
|
|
1139
|
+
}
|
|
1140
|
+
get protocol() {
|
|
1141
|
+
return this._protocol;
|
|
1142
|
+
}
|
|
1143
|
+
get readyState() {
|
|
1144
|
+
return this._readyState;
|
|
1145
|
+
}
|
|
1146
|
+
get url() {
|
|
1147
|
+
return this._url;
|
|
1148
|
+
}
|
|
1149
|
+
setSocket(t, n, r) {
|
|
1150
|
+
let i = new S({
|
|
1151
|
+
allowSynchronousEvents: r.allowSynchronousEvents,
|
|
1152
|
+
binaryType: this.binaryType,
|
|
1153
|
+
extensions: this._extensions,
|
|
1154
|
+
isServer: this._isServer,
|
|
1155
|
+
maxPayload: r.maxPayload,
|
|
1156
|
+
skipUTF8Validation: r.skipUTF8Validation
|
|
1157
|
+
}), a = new C(t, this._extensions, r.generateMask);
|
|
1158
|
+
this._receiver = i, this._sender = a, this._socket = t, i[R] = this, a[R] = this, t[R] = this, i.on("conclude", ce), i.on("drain", le), i.on("error", ue), i.on("message", de), i.on("ping", fe), i.on("pong", pe), a.onerror = me, t.setTimeout && t.setTimeout(0), t.setNoDelay && t.setNoDelay(), n.length > 0 && t.unshift(n), t.on("close", Q), t.on("data", $), t.on("end", he), t.on("error", ge), this._readyState = e.OPEN, this.emit("open");
|
|
1159
|
+
}
|
|
1160
|
+
emitClose() {
|
|
1161
|
+
if (!this._socket) {
|
|
1162
|
+
this._readyState = e.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
this._extensions[x.extensionName] && this._extensions[x.extensionName].cleanup(), this._receiver.removeAllListeners(), this._readyState = e.CLOSED, this.emit("close", this._closeCode, this._closeMessage);
|
|
1166
|
+
}
|
|
1167
|
+
close(t, n) {
|
|
1168
|
+
if (this.readyState !== e.CLOSED) {
|
|
1169
|
+
if (this.readyState === e.CONNECTING) {
|
|
1170
|
+
q(this, this._req, "WebSocket was closed before the connection was established");
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (this.readyState === e.CLOSING) {
|
|
1174
|
+
this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
this._readyState = e.CLOSING, this._sender.close(t, n, !this._isServer, (e) => {
|
|
1178
|
+
e || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
|
|
1179
|
+
}), Z(this);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
pause() {
|
|
1183
|
+
this.readyState === e.CONNECTING || this.readyState === e.CLOSED || (this._paused = !0, this._socket.pause());
|
|
1184
|
+
}
|
|
1185
|
+
ping(t, n, r) {
|
|
1186
|
+
if (this.readyState === e.CONNECTING) throw Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
1187
|
+
if (typeof t == "function" ? (r = t, t = n = void 0) : typeof n == "function" && (r = n, n = void 0), typeof t == "number" && (t = t.toString()), this.readyState !== e.OPEN) {
|
|
1188
|
+
J(this, t, r);
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
n === void 0 && (n = !this._isServer), this._sender.ping(t || k, n, r);
|
|
1192
|
+
}
|
|
1193
|
+
pong(t, n, r) {
|
|
1194
|
+
if (this.readyState === e.CONNECTING) throw Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
1195
|
+
if (typeof t == "function" ? (r = t, t = n = void 0) : typeof n == "function" && (r = n, n = void 0), typeof t == "number" && (t = t.toString()), this.readyState !== e.OPEN) {
|
|
1196
|
+
J(this, t, r);
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
n === void 0 && (n = !this._isServer), this._sender.pong(t || k, n, r);
|
|
1200
|
+
}
|
|
1201
|
+
resume() {
|
|
1202
|
+
this.readyState === e.CONNECTING || this.readyState === e.CLOSED || (this._paused = !1, this._receiver._writableState.needDrain || this._socket.resume());
|
|
1203
|
+
}
|
|
1204
|
+
send(t, n, r) {
|
|
1205
|
+
if (this.readyState === e.CONNECTING) throw Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
1206
|
+
if (typeof n == "function" && (r = n, n = {}), typeof t == "number" && (t = t.toString()), this.readyState !== e.OPEN) {
|
|
1207
|
+
J(this, t, r);
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
let i = {
|
|
1211
|
+
binary: typeof t != "string",
|
|
1212
|
+
mask: !this._isServer,
|
|
1213
|
+
compress: !0,
|
|
1214
|
+
fin: !0,
|
|
1215
|
+
...n
|
|
1216
|
+
};
|
|
1217
|
+
this._extensions[x.extensionName] || (i.compress = !1), this._sender.send(t || k, i, r);
|
|
1218
|
+
}
|
|
1219
|
+
terminate() {
|
|
1220
|
+
if (this.readyState !== e.CLOSED) {
|
|
1221
|
+
if (this.readyState === e.CONNECTING) {
|
|
1222
|
+
q(this, this._req, "WebSocket was closed before the connection was established");
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
this._socket && (this._readyState = e.CLOSING, this._socket.destroy());
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
Object.defineProperty(W, "CONNECTING", {
|
|
1230
|
+
enumerable: !0,
|
|
1231
|
+
value: U.indexOf("CONNECTING")
|
|
1232
|
+
}), Object.defineProperty(W.prototype, "CONNECTING", {
|
|
1233
|
+
enumerable: !0,
|
|
1234
|
+
value: U.indexOf("CONNECTING")
|
|
1235
|
+
}), Object.defineProperty(W, "OPEN", {
|
|
1236
|
+
enumerable: !0,
|
|
1237
|
+
value: U.indexOf("OPEN")
|
|
1238
|
+
}), Object.defineProperty(W.prototype, "OPEN", {
|
|
1239
|
+
enumerable: !0,
|
|
1240
|
+
value: U.indexOf("OPEN")
|
|
1241
|
+
}), Object.defineProperty(W, "CLOSING", {
|
|
1242
|
+
enumerable: !0,
|
|
1243
|
+
value: U.indexOf("CLOSING")
|
|
1244
|
+
}), Object.defineProperty(W.prototype, "CLOSING", {
|
|
1245
|
+
enumerable: !0,
|
|
1246
|
+
value: U.indexOf("CLOSING")
|
|
1247
|
+
}), Object.defineProperty(W, "CLOSED", {
|
|
1248
|
+
enumerable: !0,
|
|
1249
|
+
value: U.indexOf("CLOSED")
|
|
1250
|
+
}), Object.defineProperty(W.prototype, "CLOSED", {
|
|
1251
|
+
enumerable: !0,
|
|
1252
|
+
value: U.indexOf("CLOSED")
|
|
1253
|
+
}), [
|
|
1254
|
+
"binaryType",
|
|
1255
|
+
"bufferedAmount",
|
|
1256
|
+
"extensions",
|
|
1257
|
+
"isPaused",
|
|
1258
|
+
"protocol",
|
|
1259
|
+
"readyState",
|
|
1260
|
+
"url"
|
|
1261
|
+
].forEach((e) => {
|
|
1262
|
+
Object.defineProperty(W.prototype, e, { enumerable: !0 });
|
|
1263
|
+
}), [
|
|
1264
|
+
"open",
|
|
1265
|
+
"error",
|
|
1266
|
+
"close",
|
|
1267
|
+
"message"
|
|
1268
|
+
].forEach((e) => {
|
|
1269
|
+
Object.defineProperty(W.prototype, `on${e}`, {
|
|
1270
|
+
enumerable: !0,
|
|
1271
|
+
get() {
|
|
1272
|
+
for (let t of this.listeners(e)) if (t[F]) return t[I];
|
|
1273
|
+
return null;
|
|
1274
|
+
},
|
|
1275
|
+
set(t) {
|
|
1276
|
+
for (let t of this.listeners(e)) if (t[F]) {
|
|
1277
|
+
this.removeListener(e, t);
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
typeof t == "function" && this.addEventListener(e, t, { [F]: !0 });
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
}), W.prototype.addEventListener = B, W.prototype.removeEventListener = te, t.exports = W;
|
|
1284
|
+
function G(e, t, n, r) {
|
|
1285
|
+
let a = {
|
|
1286
|
+
allowSynchronousEvents: !0,
|
|
1287
|
+
autoPong: !0,
|
|
1288
|
+
closeTimeout: O,
|
|
1289
|
+
protocolVersion: H[1],
|
|
1290
|
+
maxPayload: 100 * 1024 * 1024,
|
|
1291
|
+
skipUTF8Validation: !1,
|
|
1292
|
+
perMessageDeflate: !0,
|
|
1293
|
+
followRedirects: !1,
|
|
1294
|
+
maxRedirects: 10,
|
|
1295
|
+
...r,
|
|
1296
|
+
socketPath: void 0,
|
|
1297
|
+
hostname: void 0,
|
|
1298
|
+
protocol: void 0,
|
|
1299
|
+
timeout: void 0,
|
|
1300
|
+
method: "GET",
|
|
1301
|
+
host: void 0,
|
|
1302
|
+
path: void 0,
|
|
1303
|
+
port: void 0
|
|
1304
|
+
};
|
|
1305
|
+
if (e._autoPong = a.autoPong, e._closeTimeout = a.closeTimeout, !H.includes(a.protocolVersion)) throw RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${H.join(", ")})`);
|
|
1306
|
+
let s;
|
|
1307
|
+
if (t instanceof b) s = t;
|
|
1308
|
+
else try {
|
|
1309
|
+
s = new b(t);
|
|
1310
|
+
} catch {
|
|
1311
|
+
throw SyntaxError(`Invalid URL: ${t}`);
|
|
1312
|
+
}
|
|
1313
|
+
s.protocol === "http:" ? s.protocol = "ws:" : s.protocol === "https:" && (s.protocol = "wss:"), e._url = s.href;
|
|
1314
|
+
let c = s.protocol === "wss:", l = s.protocol === "ws+unix:", u;
|
|
1315
|
+
if (s.protocol !== "ws:" && !c && !l ? u = "The URL's protocol must be one of \"ws:\", \"wss:\", \"http:\", \"https:\", or \"ws+unix:\"" : l && !s.pathname ? u = "The URL's pathname is empty" : s.hash && (u = "The URL contains a fragment identifier"), u) {
|
|
1316
|
+
let t = SyntaxError(u);
|
|
1317
|
+
if (e._redirects === 0) throw t;
|
|
1318
|
+
K(e, t);
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
let d = c ? 443 : 80, f = m(16).toString("base64"), p = c ? i.request : o.request, g = /* @__PURE__ */ new Set(), _;
|
|
1322
|
+
if (a.createConnection = a.createConnection || (c ? se : oe), a.defaultPort = a.defaultPort || d, a.port = s.port || d, a.host = s.hostname.startsWith("[") ? s.hostname.slice(1, -1) : s.hostname, a.headers = {
|
|
1323
|
+
...a.headers,
|
|
1324
|
+
"Sec-WebSocket-Version": a.protocolVersion,
|
|
1325
|
+
"Sec-WebSocket-Key": f,
|
|
1326
|
+
Connection: "Upgrade",
|
|
1327
|
+
Upgrade: "websocket"
|
|
1328
|
+
}, a.path = s.pathname + s.search, a.timeout = a.handshakeTimeout, a.perMessageDeflate && (_ = new x({
|
|
1329
|
+
...a.perMessageDeflate,
|
|
1330
|
+
isServer: !1,
|
|
1331
|
+
maxPayload: a.maxPayload
|
|
1332
|
+
}), a.headers["Sec-WebSocket-Extensions"] = ne({ [x.extensionName]: _.offer() })), n.length) {
|
|
1333
|
+
for (let e of n) {
|
|
1334
|
+
if (typeof e != "string" || !ae.test(e) || g.has(e)) throw SyntaxError("An invalid or duplicated subprotocol was specified");
|
|
1335
|
+
g.add(e);
|
|
1336
|
+
}
|
|
1337
|
+
a.headers["Sec-WebSocket-Protocol"] = n.join(",");
|
|
1338
|
+
}
|
|
1339
|
+
if (a.origin && (a.protocolVersion < 13 ? a.headers["Sec-WebSocket-Origin"] = a.origin : a.headers.Origin = a.origin), (s.username || s.password) && (a.auth = `${s.username}:${s.password}`), l) {
|
|
1340
|
+
let e = a.path.split(":");
|
|
1341
|
+
a.socketPath = e[0], a.path = e[1];
|
|
1342
|
+
}
|
|
1343
|
+
let v;
|
|
1344
|
+
if (a.followRedirects) {
|
|
1345
|
+
if (e._redirects === 0) {
|
|
1346
|
+
e._originalIpc = l, e._originalSecure = c, e._originalHostOrSocketPath = l ? a.socketPath : s.host;
|
|
1347
|
+
let t = r && r.headers;
|
|
1348
|
+
if (r = {
|
|
1349
|
+
...r,
|
|
1350
|
+
headers: {}
|
|
1351
|
+
}, t) for (let [e, n] of Object.entries(t)) r.headers[e.toLowerCase()] = n;
|
|
1352
|
+
} else if (e.listenerCount("redirect") === 0) {
|
|
1353
|
+
let t = l ? e._originalIpc ? a.socketPath === e._originalHostOrSocketPath : !1 : e._originalIpc ? !1 : s.host === e._originalHostOrSocketPath;
|
|
1354
|
+
(!t || e._originalSecure && !c) && (delete a.headers.authorization, delete a.headers.cookie, t || delete a.headers.host, a.auth = void 0);
|
|
1355
|
+
}
|
|
1356
|
+
a.auth && !r.headers.authorization && (r.headers.authorization = "Basic " + Buffer.from(a.auth).toString("base64")), v = e._req = p(a), e._redirects && e.emit("redirect", e.url, v);
|
|
1357
|
+
} else v = e._req = p(a);
|
|
1358
|
+
a.timeout && v.on("timeout", () => {
|
|
1359
|
+
q(e, v, "Opening handshake has timed out");
|
|
1360
|
+
}), v.on("error", (t) => {
|
|
1361
|
+
v === null || v[V] || (v = e._req = null, K(e, t));
|
|
1362
|
+
}), v.on("response", (i) => {
|
|
1363
|
+
let o = i.headers.location, s = i.statusCode;
|
|
1364
|
+
if (o && a.followRedirects && s >= 300 && s < 400) {
|
|
1365
|
+
if (++e._redirects > a.maxRedirects) {
|
|
1366
|
+
q(e, v, "Maximum redirects exceeded");
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
v.abort();
|
|
1370
|
+
let i;
|
|
1371
|
+
try {
|
|
1372
|
+
i = new b(o, t);
|
|
1373
|
+
} catch {
|
|
1374
|
+
K(e, /* @__PURE__ */ SyntaxError(`Invalid URL: ${o}`));
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
G(e, i, n, r);
|
|
1378
|
+
} else e.emit("unexpected-response", v, i) || q(e, v, `Unexpected server response: ${i.statusCode}`);
|
|
1379
|
+
}), v.on("upgrade", (t, n, r) => {
|
|
1380
|
+
if (e.emit("upgrade", t), e.readyState !== W.CONNECTING) return;
|
|
1381
|
+
v = e._req = null;
|
|
1382
|
+
let i = t.headers.upgrade;
|
|
1383
|
+
if (i === void 0 || i.toLowerCase() !== "websocket") {
|
|
1384
|
+
q(e, n, "Invalid Upgrade header");
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
let o = h("sha1").update(f + P).digest("base64");
|
|
1388
|
+
if (t.headers["sec-websocket-accept"] !== o) {
|
|
1389
|
+
q(e, n, "Invalid Sec-WebSocket-Accept header");
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
let s = t.headers["sec-websocket-protocol"], c;
|
|
1393
|
+
if (s === void 0 ? g.size && (c = "Server sent no subprotocol") : g.size ? g.has(s) || (c = "Server sent an invalid subprotocol") : c = "Server sent a subprotocol but none was requested", c) {
|
|
1394
|
+
q(e, n, c);
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
s && (e._protocol = s);
|
|
1398
|
+
let l = t.headers["sec-websocket-extensions"];
|
|
1399
|
+
if (l !== void 0) {
|
|
1400
|
+
if (!_) {
|
|
1401
|
+
q(e, n, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
let t;
|
|
1405
|
+
try {
|
|
1406
|
+
t = re(l);
|
|
1407
|
+
} catch {
|
|
1408
|
+
q(e, n, "Invalid Sec-WebSocket-Extensions header");
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
let r = Object.keys(t);
|
|
1412
|
+
if (r.length !== 1 || r[0] !== x.extensionName) {
|
|
1413
|
+
q(e, n, "Server indicated an extension that was not requested");
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
try {
|
|
1417
|
+
_.accept(t[x.extensionName]);
|
|
1418
|
+
} catch {
|
|
1419
|
+
q(e, n, "Invalid Sec-WebSocket-Extensions header");
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
e._extensions[x.extensionName] = _;
|
|
1423
|
+
}
|
|
1424
|
+
e.setSocket(n, r, {
|
|
1425
|
+
allowSynchronousEvents: a.allowSynchronousEvents,
|
|
1426
|
+
generateMask: a.generateMask,
|
|
1427
|
+
maxPayload: a.maxPayload,
|
|
1428
|
+
skipUTF8Validation: a.skipUTF8Validation
|
|
1429
|
+
});
|
|
1430
|
+
}), a.finishRequest ? a.finishRequest(v, e) : v.end();
|
|
1431
|
+
}
|
|
1432
|
+
function K(e, t) {
|
|
1433
|
+
e._readyState = W.CLOSING, e._errorEmitted = !0, e.emit("error", t), e.emitClose();
|
|
1434
|
+
}
|
|
1435
|
+
function oe(e) {
|
|
1436
|
+
return e.path = e.socketPath, u.connect(e);
|
|
1437
|
+
}
|
|
1438
|
+
function se(e) {
|
|
1439
|
+
return e.path = void 0, !e.servername && e.servername !== "" && (e.servername = u.isIP(e.host) ? "" : e.host), p.connect(e);
|
|
1440
|
+
}
|
|
1441
|
+
function q(e, t, n) {
|
|
1442
|
+
e._readyState = W.CLOSING;
|
|
1443
|
+
let r = Error(n);
|
|
1444
|
+
Error.captureStackTrace(r, q), t.setHeader ? (t[V] = !0, t.abort(), t.socket && !t.socket.destroyed && t.socket.destroy(), process.nextTick(K, e, r)) : (t.destroy(r), t.once("error", e.emit.bind(e, "error")), t.once("close", e.emitClose.bind(e)));
|
|
1445
|
+
}
|
|
1446
|
+
function J(e, t, n) {
|
|
1447
|
+
if (t) {
|
|
1448
|
+
let n = T(t) ? t.size : ie(t).length;
|
|
1449
|
+
e._socket ? e._sender._bufferedBytes += n : e._bufferedAmount += n;
|
|
1450
|
+
}
|
|
1451
|
+
if (n) {
|
|
1452
|
+
let t = /* @__PURE__ */ Error(`WebSocket is not open: readyState ${e.readyState} (${U[e.readyState]})`);
|
|
1453
|
+
process.nextTick(n, t);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
function ce(e, t) {
|
|
1457
|
+
let n = this[R];
|
|
1458
|
+
n._closeFrameReceived = !0, n._closeMessage = t, n._closeCode = e, n._socket[R] !== void 0 && (n._socket.removeListener("data", $), process.nextTick(X, n._socket), e === 1005 ? n.close() : n.close(e, t));
|
|
1459
|
+
}
|
|
1460
|
+
function le() {
|
|
1461
|
+
let e = this[R];
|
|
1462
|
+
e.isPaused || e._socket.resume();
|
|
1463
|
+
}
|
|
1464
|
+
function ue(e) {
|
|
1465
|
+
let t = this[R];
|
|
1466
|
+
t._socket[R] !== void 0 && (t._socket.removeListener("data", $), process.nextTick(X, t._socket), t.close(e[L])), t._errorEmitted || (t._errorEmitted = !0, t.emit("error", e));
|
|
1467
|
+
}
|
|
1468
|
+
function Y() {
|
|
1469
|
+
this[R].emitClose();
|
|
1470
|
+
}
|
|
1471
|
+
function de(e, t) {
|
|
1472
|
+
this[R].emit("message", e, t);
|
|
1473
|
+
}
|
|
1474
|
+
function fe(e) {
|
|
1475
|
+
let t = this[R];
|
|
1476
|
+
t._autoPong && t.pong(e, !this._isServer, z), t.emit("ping", e);
|
|
1477
|
+
}
|
|
1478
|
+
function pe(e) {
|
|
1479
|
+
this[R].emit("pong", e);
|
|
1480
|
+
}
|
|
1481
|
+
function X(e) {
|
|
1482
|
+
e.resume();
|
|
1483
|
+
}
|
|
1484
|
+
function me(e) {
|
|
1485
|
+
let t = this[R];
|
|
1486
|
+
t.readyState !== W.CLOSED && (t.readyState === W.OPEN && (t._readyState = W.CLOSING, Z(t)), this._socket.end(), t._errorEmitted || (t._errorEmitted = !0, t.emit("error", e)));
|
|
1487
|
+
}
|
|
1488
|
+
function Z(e) {
|
|
1489
|
+
e._closeTimer = setTimeout(e._socket.destroy.bind(e._socket), e._closeTimeout);
|
|
1490
|
+
}
|
|
1491
|
+
function Q() {
|
|
1492
|
+
let e = this[R];
|
|
1493
|
+
if (this.removeListener("close", Q), this.removeListener("data", $), this.removeListener("end", he), e._readyState = W.CLOSING, !this._readableState.endEmitted && !e._closeFrameReceived && !e._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
1494
|
+
let t = this.read(this._readableState.length);
|
|
1495
|
+
e._receiver.write(t);
|
|
1496
|
+
}
|
|
1497
|
+
e._receiver.end(), this[R] = void 0, clearTimeout(e._closeTimer), e._receiver._writableState.finished || e._receiver._writableState.errorEmitted ? e.emitClose() : (e._receiver.on("error", Y), e._receiver.on("finish", Y));
|
|
1498
|
+
}
|
|
1499
|
+
function $(e) {
|
|
1500
|
+
this[R]._receiver.write(e) || this.pause();
|
|
1501
|
+
}
|
|
1502
|
+
function he() {
|
|
1503
|
+
let e = this[R];
|
|
1504
|
+
e._readyState = W.CLOSING, e._receiver.end(), this.end();
|
|
1505
|
+
}
|
|
1506
|
+
function ge() {
|
|
1507
|
+
let e = this[R];
|
|
1508
|
+
this.removeListener("error", ge), this.on("error", z), e && (e._readyState = W.CLOSING, this.destroy());
|
|
1509
|
+
}
|
|
1510
|
+
})), F = /* @__PURE__ */ n(((e, t) => {
|
|
1511
|
+
P();
|
|
1512
|
+
var { Duplex: n } = l();
|
|
1513
|
+
function r(e) {
|
|
1514
|
+
e.emit("close");
|
|
1515
|
+
}
|
|
1516
|
+
function i() {
|
|
1517
|
+
!this.destroyed && this._writableState.finished && this.destroy();
|
|
1518
|
+
}
|
|
1519
|
+
function a(e) {
|
|
1520
|
+
this.removeListener("error", a), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", e);
|
|
1521
|
+
}
|
|
1522
|
+
function o(e, t) {
|
|
1523
|
+
let o = !0, s = new n({
|
|
1524
|
+
...t,
|
|
1525
|
+
autoDestroy: !1,
|
|
1526
|
+
emitClose: !1,
|
|
1527
|
+
objectMode: !1,
|
|
1528
|
+
writableObjectMode: !1
|
|
1529
|
+
});
|
|
1530
|
+
return e.on("message", function(t, n) {
|
|
1531
|
+
let r = !n && s._readableState.objectMode ? t.toString() : t;
|
|
1532
|
+
s.push(r) || e.pause();
|
|
1533
|
+
}), e.once("error", function(e) {
|
|
1534
|
+
s.destroyed || (o = !1, s.destroy(e));
|
|
1535
|
+
}), e.once("close", function() {
|
|
1536
|
+
s.destroyed || s.push(null);
|
|
1537
|
+
}), s._destroy = function(t, n) {
|
|
1538
|
+
if (e.readyState === e.CLOSED) {
|
|
1539
|
+
n(t), process.nextTick(r, s);
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
let i = !1;
|
|
1543
|
+
e.once("error", function(e) {
|
|
1544
|
+
i = !0, n(e);
|
|
1545
|
+
}), e.once("close", function() {
|
|
1546
|
+
i || n(t), process.nextTick(r, s);
|
|
1547
|
+
}), o && e.terminate();
|
|
1548
|
+
}, s._final = function(t) {
|
|
1549
|
+
if (e.readyState === e.CONNECTING) {
|
|
1550
|
+
e.once("open", function() {
|
|
1551
|
+
s._final(t);
|
|
1552
|
+
});
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
e._socket !== null && (e._socket._writableState.finished ? (t(), s._readableState.endEmitted && s.destroy()) : (e._socket.once("finish", function() {
|
|
1556
|
+
t();
|
|
1557
|
+
}), e.close()));
|
|
1558
|
+
}, s._read = function() {
|
|
1559
|
+
e.isPaused && e.resume();
|
|
1560
|
+
}, s._write = function(t, n, r) {
|
|
1561
|
+
if (e.readyState === e.CONNECTING) {
|
|
1562
|
+
e.once("open", function() {
|
|
1563
|
+
s._write(t, n, r);
|
|
1564
|
+
});
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
e.send(t, r);
|
|
1568
|
+
}, s.on("end", i), s.on("error", a), s;
|
|
1569
|
+
}
|
|
1570
|
+
t.exports = o;
|
|
1571
|
+
})), I = /* @__PURE__ */ n(((e, t) => {
|
|
1572
|
+
var { tokenChars: n } = A();
|
|
1573
|
+
function r(e) {
|
|
1574
|
+
let t = /* @__PURE__ */ new Set(), r = -1, i = -1, a = 0;
|
|
1575
|
+
for (; a < e.length; a++) {
|
|
1576
|
+
let o = e.charCodeAt(a);
|
|
1577
|
+
if (i === -1 && n[o] === 1) r === -1 && (r = a);
|
|
1578
|
+
else if (a !== 0 && (o === 32 || o === 9)) i === -1 && r !== -1 && (i = a);
|
|
1579
|
+
else if (o === 44) {
|
|
1580
|
+
if (r === -1) throw SyntaxError(`Unexpected character at index ${a}`);
|
|
1581
|
+
i === -1 && (i = a);
|
|
1582
|
+
let n = e.slice(r, i);
|
|
1583
|
+
if (t.has(n)) throw SyntaxError(`The "${n}" subprotocol is duplicated`);
|
|
1584
|
+
t.add(n), r = i = -1;
|
|
1585
|
+
} else throw SyntaxError(`Unexpected character at index ${a}`);
|
|
1586
|
+
}
|
|
1587
|
+
if (r === -1 || i !== -1) throw SyntaxError("Unexpected end of input");
|
|
1588
|
+
let o = e.slice(r, a);
|
|
1589
|
+
if (t.has(o)) throw SyntaxError(`The "${o}" subprotocol is duplicated`);
|
|
1590
|
+
return t.add(o), t;
|
|
1591
|
+
}
|
|
1592
|
+
t.exports = { parse: r };
|
|
1593
|
+
})), L = /* @__PURE__ */ n(((e, t) => {
|
|
1594
|
+
var n = f(), r = s(), { Duplex: i } = l(), { createHash: a } = c(), o = N(), u = E(), d = I(), p = P(), { CLOSE_TIMEOUT: m, GUID: h, kWebSocket: g } = y(), _ = /^[+/0-9A-Za-z]{22}==$/, v = 0, b = 1, x = 2;
|
|
1595
|
+
t.exports = class extends n {
|
|
1596
|
+
constructor(e, t) {
|
|
1597
|
+
if (super(), e = {
|
|
1598
|
+
allowSynchronousEvents: !0,
|
|
1599
|
+
autoPong: !0,
|
|
1600
|
+
maxPayload: 100 * 1024 * 1024,
|
|
1601
|
+
skipUTF8Validation: !1,
|
|
1602
|
+
perMessageDeflate: !1,
|
|
1603
|
+
handleProtocols: null,
|
|
1604
|
+
clientTracking: !0,
|
|
1605
|
+
closeTimeout: m,
|
|
1606
|
+
verifyClient: null,
|
|
1607
|
+
noServer: !1,
|
|
1608
|
+
backlog: null,
|
|
1609
|
+
server: null,
|
|
1610
|
+
host: null,
|
|
1611
|
+
path: null,
|
|
1612
|
+
port: null,
|
|
1613
|
+
WebSocket: p,
|
|
1614
|
+
...e
|
|
1615
|
+
}, e.port == null && !e.server && !e.noServer || e.port != null && (e.server || e.noServer) || e.server && e.noServer) throw TypeError("One and only one of the \"port\", \"server\", or \"noServer\" options must be specified");
|
|
1616
|
+
if (e.port == null ? e.server && (this._server = e.server) : (this._server = r.createServer((e, t) => {
|
|
1617
|
+
let n = r.STATUS_CODES[426];
|
|
1618
|
+
t.writeHead(426, {
|
|
1619
|
+
"Content-Length": n.length,
|
|
1620
|
+
"Content-Type": "text/plain"
|
|
1621
|
+
}), t.end(n);
|
|
1622
|
+
}), this._server.listen(e.port, e.host, e.backlog, t)), this._server) {
|
|
1623
|
+
let e = this.emit.bind(this, "connection");
|
|
1624
|
+
this._removeListeners = S(this._server, {
|
|
1625
|
+
listening: this.emit.bind(this, "listening"),
|
|
1626
|
+
error: this.emit.bind(this, "error"),
|
|
1627
|
+
upgrade: (t, n, r) => {
|
|
1628
|
+
this.handleUpgrade(t, n, r, e);
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = /* @__PURE__ */ new Set(), this._shouldEmitClose = !1), this.options = e, this._state = v;
|
|
1633
|
+
}
|
|
1634
|
+
address() {
|
|
1635
|
+
if (this.options.noServer) throw Error("The server is operating in \"noServer\" mode");
|
|
1636
|
+
return this._server ? this._server.address() : null;
|
|
1637
|
+
}
|
|
1638
|
+
close(e) {
|
|
1639
|
+
if (this._state === x) {
|
|
1640
|
+
e && this.once("close", () => {
|
|
1641
|
+
e(/* @__PURE__ */ Error("The server is not running"));
|
|
1642
|
+
}), process.nextTick(C, this);
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
if (e && this.once("close", e), this._state !== b) if (this._state = b, this.options.noServer || this.options.server) this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients && this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(C, this);
|
|
1646
|
+
else {
|
|
1647
|
+
let e = this._server;
|
|
1648
|
+
this._removeListeners(), this._removeListeners = this._server = null, e.close(() => {
|
|
1649
|
+
C(this);
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
shouldHandle(e) {
|
|
1654
|
+
if (this.options.path) {
|
|
1655
|
+
let t = e.url.indexOf("?");
|
|
1656
|
+
if ((t === -1 ? e.url : e.url.slice(0, t)) !== this.options.path) return !1;
|
|
1657
|
+
}
|
|
1658
|
+
return !0;
|
|
1659
|
+
}
|
|
1660
|
+
handleUpgrade(e, t, n, r) {
|
|
1661
|
+
t.on("error", w);
|
|
1662
|
+
let i = e.headers["sec-websocket-key"], a = e.headers.upgrade, s = +e.headers["sec-websocket-version"];
|
|
1663
|
+
if (e.method !== "GET") {
|
|
1664
|
+
D(this, e, t, 405, "Invalid HTTP method");
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
if (a === void 0 || a.toLowerCase() !== "websocket") {
|
|
1668
|
+
D(this, e, t, 400, "Invalid Upgrade header");
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
if (i === void 0 || !_.test(i)) {
|
|
1672
|
+
D(this, e, t, 400, "Missing or invalid Sec-WebSocket-Key header");
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
if (s !== 13 && s !== 8) {
|
|
1676
|
+
D(this, e, t, 400, "Missing or invalid Sec-WebSocket-Version header", { "Sec-WebSocket-Version": "13, 8" });
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
if (!this.shouldHandle(e)) {
|
|
1680
|
+
T(t, 400);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
let c = e.headers["sec-websocket-protocol"], l = /* @__PURE__ */ new Set();
|
|
1684
|
+
if (c !== void 0) try {
|
|
1685
|
+
l = d.parse(c);
|
|
1686
|
+
} catch {
|
|
1687
|
+
D(this, e, t, 400, "Invalid Sec-WebSocket-Protocol header");
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
let f = e.headers["sec-websocket-extensions"], p = {};
|
|
1691
|
+
if (this.options.perMessageDeflate && f !== void 0) {
|
|
1692
|
+
let n = new u({
|
|
1693
|
+
...this.options.perMessageDeflate,
|
|
1694
|
+
isServer: !0,
|
|
1695
|
+
maxPayload: this.options.maxPayload
|
|
1696
|
+
});
|
|
1697
|
+
try {
|
|
1698
|
+
let e = o.parse(f);
|
|
1699
|
+
e[u.extensionName] && (n.accept(e[u.extensionName]), p[u.extensionName] = n);
|
|
1700
|
+
} catch {
|
|
1701
|
+
D(this, e, t, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
if (this.options.verifyClient) {
|
|
1706
|
+
let a = {
|
|
1707
|
+
origin: e.headers[`${s === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
1708
|
+
secure: !!(e.socket.authorized || e.socket.encrypted),
|
|
1709
|
+
req: e
|
|
1710
|
+
};
|
|
1711
|
+
if (this.options.verifyClient.length === 2) {
|
|
1712
|
+
this.options.verifyClient(a, (a, o, s, c) => {
|
|
1713
|
+
if (!a) return T(t, o || 401, s, c);
|
|
1714
|
+
this.completeUpgrade(p, i, l, e, t, n, r);
|
|
1715
|
+
});
|
|
1716
|
+
return;
|
|
1717
|
+
}
|
|
1718
|
+
if (!this.options.verifyClient(a)) return T(t, 401);
|
|
1719
|
+
}
|
|
1720
|
+
this.completeUpgrade(p, i, l, e, t, n, r);
|
|
1721
|
+
}
|
|
1722
|
+
completeUpgrade(e, t, n, r, i, s, c) {
|
|
1723
|
+
if (!i.readable || !i.writable) return i.destroy();
|
|
1724
|
+
if (i[g]) throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");
|
|
1725
|
+
if (this._state > v) return T(i, 503);
|
|
1726
|
+
let l = [
|
|
1727
|
+
"HTTP/1.1 101 Switching Protocols",
|
|
1728
|
+
"Upgrade: websocket",
|
|
1729
|
+
"Connection: Upgrade",
|
|
1730
|
+
`Sec-WebSocket-Accept: ${a("sha1").update(t + h).digest("base64")}`
|
|
1731
|
+
], d = new this.options.WebSocket(null, void 0, this.options);
|
|
1732
|
+
if (n.size) {
|
|
1733
|
+
let e = this.options.handleProtocols ? this.options.handleProtocols(n, r) : n.values().next().value;
|
|
1734
|
+
e && (l.push(`Sec-WebSocket-Protocol: ${e}`), d._protocol = e);
|
|
1735
|
+
}
|
|
1736
|
+
if (e[u.extensionName]) {
|
|
1737
|
+
let t = e[u.extensionName].params, n = o.format({ [u.extensionName]: [t] });
|
|
1738
|
+
l.push(`Sec-WebSocket-Extensions: ${n}`), d._extensions = e;
|
|
1739
|
+
}
|
|
1740
|
+
this.emit("headers", l, r), i.write(l.concat("\r\n").join("\r\n")), i.removeListener("error", w), d.setSocket(i, s, {
|
|
1741
|
+
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
1742
|
+
maxPayload: this.options.maxPayload,
|
|
1743
|
+
skipUTF8Validation: this.options.skipUTF8Validation
|
|
1744
|
+
}), this.clients && (this.clients.add(d), d.on("close", () => {
|
|
1745
|
+
this.clients.delete(d), this._shouldEmitClose && !this.clients.size && process.nextTick(C, this);
|
|
1746
|
+
})), c(d, r);
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
function S(e, t) {
|
|
1750
|
+
for (let n of Object.keys(t)) e.on(n, t[n]);
|
|
1751
|
+
return function() {
|
|
1752
|
+
for (let n of Object.keys(t)) e.removeListener(n, t[n]);
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
function C(e) {
|
|
1756
|
+
e._state = x, e.emit("close");
|
|
1757
|
+
}
|
|
1758
|
+
function w() {
|
|
1759
|
+
this.destroy();
|
|
1760
|
+
}
|
|
1761
|
+
function T(e, t, n, i) {
|
|
1762
|
+
n ||= r.STATUS_CODES[t], i = {
|
|
1763
|
+
Connection: "close",
|
|
1764
|
+
"Content-Type": "text/html",
|
|
1765
|
+
"Content-Length": Buffer.byteLength(n),
|
|
1766
|
+
...i
|
|
1767
|
+
}, e.once("finish", e.destroy), e.end(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n` + Object.keys(i).map((e) => `${e}: ${i[e]}`).join("\r\n") + "\r\n\r\n" + n);
|
|
1768
|
+
}
|
|
1769
|
+
function D(e, t, n, r, i, a) {
|
|
1770
|
+
if (e.listenerCount("wsClientError")) {
|
|
1771
|
+
let r = Error(i);
|
|
1772
|
+
Error.captureStackTrace(r, D), e.emit("wsClientError", r, n, t);
|
|
1773
|
+
} else T(n, r, i, a);
|
|
1774
|
+
}
|
|
1775
|
+
}));
|
|
1776
|
+
F(), N(), E(), j(), M(), I();
|
|
1777
|
+
var R = /* @__PURE__ */ t(P(), 1);
|
|
1778
|
+
L();
|
|
1779
|
+
var z = R.default, B = global;
|
|
1780
|
+
B.WebSocket ||= z, B.window ||= global, B.self ||= global, B.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
|
|
1781
|
+
{
|
|
1782
|
+
type: 1,
|
|
1783
|
+
value: 7,
|
|
1784
|
+
isEnabled: !0
|
|
1785
|
+
},
|
|
1786
|
+
{
|
|
1787
|
+
type: 2,
|
|
1788
|
+
value: "InternalApp",
|
|
1789
|
+
isEnabled: !0,
|
|
1790
|
+
isValid: !0
|
|
1791
|
+
},
|
|
1792
|
+
{
|
|
1793
|
+
type: 2,
|
|
1794
|
+
value: "InternalAppContext",
|
|
1795
|
+
isEnabled: !0,
|
|
1796
|
+
isValid: !0
|
|
1797
|
+
},
|
|
1798
|
+
{
|
|
1799
|
+
type: 2,
|
|
1800
|
+
value: "InternalStdoutContext",
|
|
1801
|
+
isEnabled: !0,
|
|
1802
|
+
isValid: !0
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
type: 2,
|
|
1806
|
+
value: "InternalStderrContext",
|
|
1807
|
+
isEnabled: !0,
|
|
1808
|
+
isValid: !0
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
type: 2,
|
|
1812
|
+
value: "InternalStdinContext",
|
|
1813
|
+
isEnabled: !0,
|
|
1814
|
+
isValid: !0
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
type: 2,
|
|
1818
|
+
value: "InternalFocusContext",
|
|
1819
|
+
isEnabled: !0,
|
|
1820
|
+
isValid: !0
|
|
1821
|
+
}
|
|
1822
|
+
], g.initialize(), g.connectToDevTools();
|
|
1823
|
+
//#endregion
|
|
1824
|
+
export {};
|