@umijs/bundler-webpack 4.0.42 → 4.0.43
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/client/utils/formatWebpackMessages.js +27 -8
- package/compiled/babel-loader/index.js +8 -2
- package/compiled/babel-loader/package.json +1 -1
- package/compiled/less-loader/index.js +1 -1
- package/compiled/less-loader/package.json +1 -1
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +22 -60
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +2 -10
- package/compiled/mini-css-extract-plugin/index.js +492 -696
- package/compiled/mini-css-extract-plugin/loader.js +54 -120
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +27 -44
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/sass-loader/sass.default.dart.js +4 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser/index.js +1 -1
- package/compiled/terser/package.json +1 -1
- package/compiled/terser/tools/terser.d.ts +6 -3
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser-webpack-plugin/index.js +1211 -3390
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +10 -10
- package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -9
- package/compiled/terser-webpack-plugin/utils.js +36 -10
- package/compiled/webpack/package.json +1 -1
- package/compiled/webpack/types.d.ts +137 -126
- package/compiled/webpack-5-chain/index.js +1 -1
- package/compiled/webpack-5-chain/package.json +1 -1
- package/compiled/webpack-5-chain/types/index.d.ts +76 -20
- package/compiled/webpack-bundle-analyzer/index.js +7 -6
- package/compiled/webpack-bundle-analyzer/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
- package/compiled/webpack-dev-middleware/index.js +5 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/ws/LICENSE +13 -12
- package/compiled/ws/index.d.ts +73 -33
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.js +8 -2
- package/dist/cli.js +4 -1
- package/dist/config/compressPlugin.js +4 -1
- package/dist/config/config.js +41 -11
- package/dist/config/cssRules.js +17 -5
- package/dist/config/detectDeadCode.js +38 -8
- package/dist/config/detectDeadCodePlugin.js +8 -2
- package/dist/config/fastRefreshPlugin.js +4 -1
- package/dist/config/forkTSCheckerPlugin.js +4 -1
- package/dist/config/harmonyLinkingErrorPlugin.js +14 -11
- package/dist/config/javaScriptRules.js +10 -5
- package/dist/config/miniCSSExtractPlugin.js +4 -1
- package/dist/config/progressPlugin.js +9 -2
- package/dist/config/speedMeasureWebpackPlugin.js +7 -2
- package/dist/config/ssrPlugin.js +20 -6
- package/dist/config/svgRules.js +4 -1
- package/dist/dev.js +29 -10
- package/dist/loader/svgr.js +16 -11
- package/dist/loader/swc.js +26 -8
- package/dist/parcelCSS.js +4 -1
- package/dist/plugins/ProgressPlugin.js +6 -2
- package/dist/plugins/RuntimePublicPathPlugin.js +9 -6
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +1 -1
- package/dist/requireHook.js +4 -1
- package/dist/schema.js +58 -23
- package/dist/server/server.d.ts +1 -4
- package/dist/server/server.js +37 -23
- package/dist/server/ws.js +8 -3
- package/dist/swcPlugins/autoCSSModules.js +4 -1
- package/dist/swcPlugins/lockCoreJS.js +8 -2
- package/dist/types.d.ts +2 -1
- package/dist/utils/formatWebpackMessages.js +31 -9
- package/dist/utils/getEsBuildTarget.js +7 -1
- package/package.json +25 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"webpack-dev-middleware","author":"Tobias Koppers @sokra","license":"MIT","types":"types/index.d.ts"}
|
|
1
|
+
{"name":"webpack-dev-middleware","version":"6.0.1","author":"Tobias Koppers @sokra","license":"MIT","types":"types/index.d.ts"}
|
package/compiled/ws/LICENSE
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
2
|
+
Copyright (c) 2013 Arnout Kazemier and contributors
|
|
3
|
+
Copyright (c) 2016 Luigi Pinca and contributors
|
|
2
4
|
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
9
11
|
|
|
10
12
|
The above copyright notice and this permission notice shall be included in all
|
|
11
13
|
copies or substantial portions of the Software.
|
|
12
14
|
|
|
13
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
SOFTWARE.
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/compiled/ws/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for ws 8.
|
|
1
|
+
// Type definitions for ws 8.5
|
|
2
2
|
// Project: https://github.com/websockets/ws
|
|
3
3
|
// Definitions by: Paul Loyd <https://github.com/loyd>
|
|
4
4
|
// Margus Lamp <https://github.com/mlamp>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// teidesu <https://github.com/teidesu>
|
|
8
8
|
// Bartosz Wojtkowiak <https://github.com/wojtkowiak>
|
|
9
9
|
// Kyle Hensel <https://github.com/k-yle>
|
|
10
|
+
// Samuel Skeen <https://github.com/cwadrupldijjit>
|
|
10
11
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
11
12
|
|
|
12
13
|
/// <reference types="node" />
|
|
@@ -26,6 +27,26 @@ import { SecureContextOptions } from 'tls';
|
|
|
26
27
|
import { URL } from 'url';
|
|
27
28
|
import { ZlibOptions } from 'zlib';
|
|
28
29
|
|
|
30
|
+
// can not get all overload of BufferConstructor['from'], need to copy all it's first arguments here
|
|
31
|
+
// https://github.com/microsoft/TypeScript/issues/32164
|
|
32
|
+
type BufferLike =
|
|
33
|
+
| string
|
|
34
|
+
| Buffer
|
|
35
|
+
| DataView
|
|
36
|
+
| number
|
|
37
|
+
| ArrayBufferView
|
|
38
|
+
| Uint8Array
|
|
39
|
+
| ArrayBuffer
|
|
40
|
+
| SharedArrayBuffer
|
|
41
|
+
| ReadonlyArray<any>
|
|
42
|
+
| ReadonlyArray<number>
|
|
43
|
+
| { valueOf(): ArrayBuffer }
|
|
44
|
+
| { valueOf(): SharedArrayBuffer }
|
|
45
|
+
| { valueOf(): Uint8Array }
|
|
46
|
+
| { valueOf(): ReadonlyArray<number> }
|
|
47
|
+
| { valueOf(): string }
|
|
48
|
+
| { [Symbol.toPrimitive](hint: string): string };
|
|
49
|
+
|
|
29
50
|
// WebSocket socket.
|
|
30
51
|
declare class WebSocket extends EventEmitter {
|
|
31
52
|
/** The connection is not yet open. */
|
|
@@ -40,6 +61,8 @@ declare class WebSocket extends EventEmitter {
|
|
|
40
61
|
binaryType: "nodebuffer" | "arraybuffer" | "fragments";
|
|
41
62
|
readonly bufferedAmount: number;
|
|
42
63
|
readonly extensions: string;
|
|
64
|
+
/** Indicates whether the websocket is paused */
|
|
65
|
+
readonly isPaused: boolean;
|
|
43
66
|
readonly protocol: string;
|
|
44
67
|
/** The current state of the connection */
|
|
45
68
|
readonly readyState:
|
|
@@ -58,11 +81,12 @@ declare class WebSocket extends EventEmitter {
|
|
|
58
81
|
/** The connection is closed. */
|
|
59
82
|
readonly CLOSED: 3;
|
|
60
83
|
|
|
61
|
-
onopen: (event: WebSocket.Event) => void;
|
|
62
|
-
onerror: (event: WebSocket.ErrorEvent) => void;
|
|
63
|
-
onclose: (event: WebSocket.CloseEvent) => void;
|
|
64
|
-
onmessage: (event: WebSocket.MessageEvent) => void;
|
|
84
|
+
onopen: ((event: WebSocket.Event) => void) | null;
|
|
85
|
+
onerror: ((event: WebSocket.ErrorEvent) => void) | null;
|
|
86
|
+
onclose: ((event: WebSocket.CloseEvent) => void) | null;
|
|
87
|
+
onmessage: ((event: WebSocket.MessageEvent) => void) | null;
|
|
65
88
|
|
|
89
|
+
constructor(address: null);
|
|
66
90
|
constructor(address: string | URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
|
|
67
91
|
constructor(
|
|
68
92
|
address: string | URL,
|
|
@@ -73,14 +97,27 @@ declare class WebSocket extends EventEmitter {
|
|
|
73
97
|
close(code?: number, data?: string | Buffer): void;
|
|
74
98
|
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
|
|
75
99
|
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
|
|
76
|
-
|
|
100
|
+
// https://github.com/websockets/ws/issues/2076#issuecomment-1250354722
|
|
101
|
+
send(data: BufferLike, cb?: (err?: Error) => void): void;
|
|
77
102
|
send(
|
|
78
|
-
data:
|
|
103
|
+
data: BufferLike,
|
|
79
104
|
options: { mask?: boolean | undefined; binary?: boolean | undefined; compress?: boolean | undefined; fin?: boolean | undefined },
|
|
80
105
|
cb?: (err?: Error) => void,
|
|
81
106
|
): void;
|
|
82
107
|
terminate(): void;
|
|
83
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
|
111
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
|
112
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
|
113
|
+
*/
|
|
114
|
+
pause(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
|
117
|
+
* state is `CONNECTING` or `CLOSED`.
|
|
118
|
+
*/
|
|
119
|
+
resume(): void;
|
|
120
|
+
|
|
84
121
|
// HTML5 WebSocket events
|
|
85
122
|
addEventListener(
|
|
86
123
|
method: "message",
|
|
@@ -171,7 +208,7 @@ declare class WebSocket extends EventEmitter {
|
|
|
171
208
|
}
|
|
172
209
|
|
|
173
210
|
declare const WebSocketAlias: typeof WebSocket;
|
|
174
|
-
|
|
211
|
+
interface WebSocketAlias extends WebSocket {} // tslint:disable-line no-empty-interface
|
|
175
212
|
|
|
176
213
|
declare namespace WebSocket {
|
|
177
214
|
/**
|
|
@@ -209,6 +246,7 @@ declare namespace WebSocket {
|
|
|
209
246
|
interface ClientOptions extends SecureContextOptions {
|
|
210
247
|
protocol?: string | undefined;
|
|
211
248
|
followRedirects?: boolean | undefined;
|
|
249
|
+
generateMask?(mask: Buffer): void;
|
|
212
250
|
handshakeTimeout?: number | undefined;
|
|
213
251
|
maxRedirects?: number | undefined;
|
|
214
252
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
@@ -222,6 +260,7 @@ declare namespace WebSocket {
|
|
|
222
260
|
checkServerIdentity?(servername: string, cert: CertMeta): boolean;
|
|
223
261
|
rejectUnauthorized?: boolean | undefined;
|
|
224
262
|
maxPayload?: number | undefined;
|
|
263
|
+
skipUTF8Validation?: boolean | undefined;
|
|
225
264
|
}
|
|
226
265
|
|
|
227
266
|
interface PerMessageDeflateOptions {
|
|
@@ -288,6 +327,7 @@ declare namespace WebSocket {
|
|
|
288
327
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
289
328
|
maxPayload?: number | undefined;
|
|
290
329
|
skipUTF8Validation?: boolean | undefined;
|
|
330
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined;
|
|
291
331
|
}
|
|
292
332
|
|
|
293
333
|
interface AddressInfo {
|
|
@@ -297,10 +337,10 @@ declare namespace WebSocket {
|
|
|
297
337
|
}
|
|
298
338
|
|
|
299
339
|
// WebSocket Server
|
|
300
|
-
class Server extends EventEmitter {
|
|
340
|
+
class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
|
301
341
|
options: ServerOptions;
|
|
302
342
|
path: string;
|
|
303
|
-
clients: Set<
|
|
343
|
+
clients: Set<T>;
|
|
304
344
|
|
|
305
345
|
constructor(options?: ServerOptions, callback?: () => void);
|
|
306
346
|
|
|
@@ -310,36 +350,36 @@ declare namespace WebSocket {
|
|
|
310
350
|
request: IncomingMessage,
|
|
311
351
|
socket: Duplex,
|
|
312
352
|
upgradeHead: Buffer,
|
|
313
|
-
callback: (client:
|
|
353
|
+
callback: (client: T, request: IncomingMessage) => void,
|
|
314
354
|
): void;
|
|
315
355
|
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>;
|
|
316
356
|
|
|
317
357
|
// Events
|
|
318
|
-
on(event: "connection", cb: (this: Server
|
|
319
|
-
on(event: "error", cb: (this: Server
|
|
320
|
-
on(event: "headers", cb: (this: Server
|
|
321
|
-
on(event: "close" | "listening", cb: (this: Server) => void): this;
|
|
322
|
-
on(event: string | symbol, listener: (this: Server
|
|
323
|
-
|
|
324
|
-
once(event: "connection", cb: (this: Server
|
|
325
|
-
once(event: "error", cb: (this: Server
|
|
326
|
-
once(event: "headers", cb: (this: Server
|
|
327
|
-
once(event: "close" | "listening", cb: (this: Server) => void): this;
|
|
328
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
329
|
-
|
|
330
|
-
off(event: "connection", cb: (this: Server
|
|
331
|
-
off(event: "error", cb: (this: Server
|
|
332
|
-
off(event: "headers", cb: (this: Server
|
|
333
|
-
off(event: "close" | "listening", cb: (this: Server) => void): this;
|
|
334
|
-
off(event: string | symbol, listener: (this: Server
|
|
335
|
-
|
|
336
|
-
addListener(event: "connection", cb: (client:
|
|
358
|
+
on(event: "connection", cb: (this: Server<T>, socket: T, request: IncomingMessage) => void): this;
|
|
359
|
+
on(event: "error", cb: (this: Server<T>, error: Error) => void): this;
|
|
360
|
+
on(event: "headers", cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void): this;
|
|
361
|
+
on(event: "close" | "listening", cb: (this: Server<T>) => void): this;
|
|
362
|
+
on(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
|
|
363
|
+
|
|
364
|
+
once(event: "connection", cb: (this: Server<T>, socket: T, request: IncomingMessage) => void): this;
|
|
365
|
+
once(event: "error", cb: (this: Server<T>, error: Error) => void): this;
|
|
366
|
+
once(event: "headers", cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void): this;
|
|
367
|
+
once(event: "close" | "listening", cb: (this: Server<T>) => void): this;
|
|
368
|
+
once(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
|
|
369
|
+
|
|
370
|
+
off(event: "connection", cb: (this: Server<T>, socket: T, request: IncomingMessage) => void): this;
|
|
371
|
+
off(event: "error", cb: (this: Server<T>, error: Error) => void): this;
|
|
372
|
+
off(event: "headers", cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void): this;
|
|
373
|
+
off(event: "close" | "listening", cb: (this: Server<T>) => void): this;
|
|
374
|
+
off(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
|
|
375
|
+
|
|
376
|
+
addListener(event: "connection", cb: (client: T, request: IncomingMessage) => void): this;
|
|
337
377
|
addListener(event: "error", cb: (err: Error) => void): this;
|
|
338
378
|
addListener(event: "headers", cb: (headers: string[], request: IncomingMessage) => void): this;
|
|
339
379
|
addListener(event: "close" | "listening", cb: () => void): this;
|
|
340
380
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
341
381
|
|
|
342
|
-
removeListener(event: "connection", cb: (client:
|
|
382
|
+
removeListener(event: "connection", cb: (client: T) => void): this;
|
|
343
383
|
removeListener(event: "error", cb: (err: Error) => void): this;
|
|
344
384
|
removeListener(event: "headers", cb: (headers: string[], request: IncomingMessage) => void): this;
|
|
345
385
|
removeListener(event: "close" | "listening", cb: () => void): this;
|
|
@@ -347,9 +387,9 @@ declare namespace WebSocket {
|
|
|
347
387
|
}
|
|
348
388
|
|
|
349
389
|
const WebSocketServer: typeof Server;
|
|
350
|
-
|
|
390
|
+
interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
|
351
391
|
const WebSocket: typeof WebSocketAlias;
|
|
352
|
-
|
|
392
|
+
interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
|
353
393
|
|
|
354
394
|
// WebSocket stream
|
|
355
395
|
function createWebSocketStream(websocket: WebSocket, options?: DuplexOptions): Duplex;
|
package/compiled/ws/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){var __webpack_modules__={993:function(e,t,s){"use strict";const r=s(830);r.createWebSocketStream=s(377);r.Server=s(631);r.Receiver=s(464);r.Sender=s(48);r.WebSocket=r;r.WebSocketServer=r.Server;e.exports=r},950:function(e,t,s){"use strict";const{EMPTY_BUFFER:r}=s(24);function concat(e,t){if(e.length===0)return r;if(e.length===1)return e[0];const s=Buffer.allocUnsafe(t);let n=0;for(let t=0;t<e.length;t++){const r=e[t];s.set(r,n);n+=r.length}if(n<t)return s.slice(0,n);return s}function _mask(e,t,s,r,n){for(let i=0;i<n;i++){s[r+i]=e[i]^t[i&3]}}function _unmask(e,t){for(let s=0;s<e.length;s++){e[s]^=t[s&3]}}function toArrayBuffer(e){if(e.byteLength===e.buffer.byteLength){return e.buffer}return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function toBuffer(e){toBuffer.readOnly=true;if(Buffer.isBuffer(e))return e;let t;if(e instanceof ArrayBuffer){t=Buffer.from(e)}else if(ArrayBuffer.isView(e)){t=Buffer.from(e.buffer,e.byteOffset,e.byteLength)}else{t=Buffer.from(e);toBuffer.readOnly=false}return t}try{const t=s(745);e.exports={concat:concat,mask(e,s,r,n,i){if(i<48)_mask(e,s,r,n,i);else t.mask(e,s,r,n,i)},toArrayBuffer:toArrayBuffer,toBuffer:toBuffer,unmask(e,s){if(e.length<32)_unmask(e,s);else t.unmask(e,s)}}}catch(t){e.exports={concat:concat,mask:_mask,toArrayBuffer:toArrayBuffer,toBuffer:toBuffer,unmask:_unmask}}},24:function(e){"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},648:function(e,t,s){"use strict";const{kForOnEventAttribute:r,kListener:n}=s(24);const i=Symbol("kCode");const o=Symbol("kData");const a=Symbol("kError");const c=Symbol("kMessage");const l=Symbol("kReason");const f=Symbol("kTarget");const h=Symbol("kType");const d=Symbol("kWasClean");class Event{constructor(e){this[f]=null;this[h]=e}get target(){return this[f]}get type(){return this[h]}}Object.defineProperty(Event.prototype,"target",{enumerable:true});Object.defineProperty(Event.prototype,"type",{enumerable:true});class CloseEvent extends Event{constructor(e,t={}){super(e);this[i]=t.code===undefined?0:t.code;this[l]=t.reason===undefined?"":t.reason;this[d]=t.wasClean===undefined?false:t.wasClean}get code(){return this[i]}get reason(){return this[l]}get wasClean(){return this[d]}}Object.defineProperty(CloseEvent.prototype,"code",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"reason",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"wasClean",{enumerable:true});class ErrorEvent extends Event{constructor(e,t={}){super(e);this[a]=t.error===undefined?null:t.error;this[c]=t.message===undefined?"":t.message}get error(){return this[a]}get message(){return this[c]}}Object.defineProperty(ErrorEvent.prototype,"error",{enumerable:true});Object.defineProperty(ErrorEvent.prototype,"message",{enumerable:true});class MessageEvent extends Event{constructor(e,t={}){super(e);this[o]=t.data===undefined?null:t.data}get data(){return this[o]}}Object.defineProperty(MessageEvent.prototype,"data",{enumerable:true});const u={addEventListener(e,t,s={}){let i;if(e==="message"){i=function onMessage(e,s){const r=new MessageEvent("message",{data:s?e:e.toString()});r[f]=this;t.call(this,r)}}else if(e==="close"){i=function onClose(e,s){const r=new CloseEvent("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[f]=this;t.call(this,r)}}else if(e==="error"){i=function onError(e){const s=new ErrorEvent("error",{error:e,message:e.message});s[f]=this;t.call(this,s)}}else if(e==="open"){i=function onOpen(){const e=new Event("open");e[f]=this;t.call(this,e)}}else{return}i[r]=!!s[r];i[n]=t;if(s.once){this.once(e,i)}else{this.on(e,i)}},removeEventListener(e,t){for(const s of this.listeners(e)){if(s[n]===t&&!s[r]){this.removeListener(e,s);break}}}};e.exports={CloseEvent:CloseEvent,ErrorEvent:ErrorEvent,Event:Event,EventTarget:u,MessageEvent:MessageEvent}},686:function(e,t,s){"use strict";const{tokenChars:r}=s(210);function push(e,t,s){if(e[t]===undefined)e[t]=[s];else e[t].push(s)}function parse(e){const t=Object.create(null);let s=Object.create(null);let n=false;let i=false;let o=false;let a;let c;let l=-1;let f=-1;let h=-1;let d=0;for(;d<e.length;d++){f=e.charCodeAt(d);if(a===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(d!==0&&(f===32||f===9)){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;const r=e.slice(l,h);if(f===44){push(t,r,s);s=Object.create(null)}else{a=r}l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(c===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(f===32||f===9){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;push(s,e.slice(l,h),true);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}l=h=-1}else if(f===61&&l!==-1&&h===-1){c=e.slice(l,d);l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else{if(i){if(r[f]!==1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(l===-1)l=d;else if(!n)n=true;i=false}else if(o){if(r[f]===1){if(l===-1)l=d}else if(f===34&&l!==-1){o=false;h=d}else if(f===92){i=true}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(f===34&&e.charCodeAt(d-1)===61){o=true}else if(h===-1&&r[f]===1){if(l===-1)l=d}else if(l!==-1&&(f===32||f===9)){if(h===-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;let r=e.slice(l,h);if(n){r=r.replace(/\\/g,"");n=false}push(s,c,r);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}c=undefined;l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}}if(l===-1||o||f===32||f===9){throw new SyntaxError("Unexpected end of input")}if(h===-1)h=d;const u=e.slice(l,h);if(a===undefined){push(t,u,s)}else{if(c===undefined){push(s,u,true)}else if(n){push(s,c,u.replace(/\\/g,""))}else{push(s,c,u)}push(t,a,s)}return t}function format(e){return Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>e===true?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")}e.exports={format:format,parse:parse}},309:function(e){"use strict";const t=Symbol("kDone");const s=Symbol("kRun");class Limiter{constructor(e){this[t]=()=>{this.pending--;this[s]()};this.concurrency=e||Infinity;this.jobs=[];this.pending=0}add(e){this.jobs.push(e);this[s]()}[s](){if(this.pending===this.concurrency)return;if(this.jobs.length){const e=this.jobs.shift();this.pending++;e(this[t])}}}e.exports=Limiter},349:function(e,t,s){"use strict";const r=s(796);const n=s(950);const i=s(309);const{kStatusCode:o}=s(24);const a=Buffer.from([0,0,255,255]);const c=Symbol("permessage-deflate");const l=Symbol("total-length");const f=Symbol("callback");const h=Symbol("buffers");const d=Symbol("error");let u;class PerMessageDeflate{constructor(e,t,s){this._maxPayload=s|0;this._options=e||{};this._threshold=this._options.threshold!==undefined?this._options.threshold:1024;this._isServer=!!t;this._deflate=null;this._inflate=null;this.params=null;if(!u){const e=this._options.concurrencyLimit!==undefined?this._options.concurrencyLimit:10;u=new i(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};if(this._options.serverNoContextTakeover){e.server_no_context_takeover=true}if(this._options.clientNoContextTakeover){e.client_no_context_takeover=true}if(this._options.serverMaxWindowBits){e.server_max_window_bits=this._options.serverMaxWindowBits}if(this._options.clientMaxWindowBits){e.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits==null){e.client_max_window_bits=true}return e}accept(e){e=this.normalizeParams(e);this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e);return this.params}cleanup(){if(this._inflate){this._inflate.close();this._inflate=null}if(this._deflate){const e=this._deflate[f];this._deflate.close();this._deflate=null;if(e){e(new Error("The deflate stream was closed while data was being processed"))}}}acceptAsServer(e){const t=this._options;const s=e.find((e=>{if(t.serverNoContextTakeover===false&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===false||typeof t.serverMaxWindowBits==="number"&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==="number"&&!e.client_max_window_bits){return false}return true}));if(!s){throw new Error("None of the extension offers can be accepted")}if(t.serverNoContextTakeover){s.server_no_context_takeover=true}if(t.clientNoContextTakeover){s.client_no_context_takeover=true}if(typeof t.serverMaxWindowBits==="number"){s.server_max_window_bits=t.serverMaxWindowBits}if(typeof t.clientMaxWindowBits==="number"){s.client_max_window_bits=t.clientMaxWindowBits}else if(s.client_max_window_bits===true||t.clientMaxWindowBits===false){delete s.client_max_window_bits}return s}acceptAsClient(e){const t=e[0];if(this._options.clientNoContextTakeover===false&&t.client_no_context_takeover){throw new Error('Unexpected parameter "client_no_context_takeover"')}if(!t.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number"){t.client_max_window_bits=this._options.clientMaxWindowBits}}else if(this._options.clientMaxWindowBits===false||typeof this._options.clientMaxWindowBits==="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits){throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}return t}normalizeParams(e){e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1){throw new Error(`Parameter "${t}" must have only a single value`)}s=s[0];if(t==="client_max_window_bits"){if(s!==true){const e=+s;if(!Number.isInteger(e)||e<8||e>15){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}s=e}else if(!this._isServer){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}}else if(t==="server_max_window_bits"){const e=+s;if(!Number.isInteger(e)||e<8||e>15){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}s=e}else if(t==="client_no_context_takeover"||t==="server_no_context_takeover"){if(s!==true){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}}else{throw new Error(`Unknown parameter "${t}"`)}e[t]=s}))}));return e}decompress(e,t,s){u.add((r=>{this._decompress(e,t,((e,t)=>{r();s(e,t)}))}))}compress(e,t,s){u.add((r=>{this._compress(e,t,((e,t)=>{r();s(e,t)}))}))}_decompress(e,t,s){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t});this._inflate[c]=this;this._inflate[l]=0;this._inflate[h]=[];this._inflate.on("error",inflateOnError);this._inflate.on("data",inflateOnData)}this._inflate[f]=s;this._inflate.write(e);if(t)this._inflate.write(a);this._inflate.flush((()=>{const e=this._inflate[d];if(e){this._inflate.close();this._inflate=null;s(e);return}const r=n.concat(this._inflate[h],this._inflate[l]);if(this._inflate._readableState.endEmitted){this._inflate.close();this._inflate=null}else{this._inflate[l]=0;this._inflate[h]=[];if(t&&this.params[`${i}_no_context_takeover`]){this._inflate.reset()}}s(null,r)}))}_compress(e,t,s){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t});this._deflate[l]=0;this._deflate[h]=[];this._deflate.on("data",deflateOnData)}this._deflate[f]=s;this._deflate.write(e);this._deflate.flush(r.Z_SYNC_FLUSH,(()=>{if(!this._deflate){return}let e=n.concat(this._deflate[h],this._deflate[l]);if(t)e=e.slice(0,e.length-4);this._deflate[f]=null;this._deflate[l]=0;this._deflate[h]=[];if(t&&this.params[`${i}_no_context_takeover`]){this._deflate.reset()}s(null,e)}))}}e.exports=PerMessageDeflate;function deflateOnData(e){this[h].push(e);this[l]+=e.length}function inflateOnData(e){this[l]+=e.length;if(this[c]._maxPayload<1||this[l]<=this[c]._maxPayload){this[h].push(e);return}this[d]=new RangeError("Max payload size exceeded");this[d].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";this[d][o]=1009;this.removeListener("data",inflateOnData);this.reset()}function inflateOnError(e){this[c]._inflate=null;e[o]=1007;this[f](e)}},464:function(e,t,s){"use strict";const{Writable:r}=s(781);const n=s(349);const{BINARY_TYPES:i,EMPTY_BUFFER:o,kStatusCode:a,kWebSocket:c}=s(24);const{concat:l,toArrayBuffer:f,unmask:h}=s(950);const{isValidStatusCode:d,isValidUTF8:u}=s(210);const _=0;const p=1;const m=2;const b=3;const k=4;const y=5;class Receiver extends r{constructor(e={}){super();this._binaryType=e.binaryType||i[0];this._extensions=e.extensions||{};this._isServer=!!e.isServer;this._maxPayload=e.maxPayload|0;this._skipUTF8Validation=!!e.skipUTF8Validation;this[c]=undefined;this._bufferedBytes=0;this._buffers=[];this._compressed=false;this._payloadLength=0;this._mask=undefined;this._fragmented=0;this._masked=false;this._fin=false;this._opcode=0;this._totalPayloadLength=0;this._messageLength=0;this._fragments=[];this._state=_;this._loop=false}_write(e,t,s){if(this._opcode===8&&this._state==_)return s();this._bufferedBytes+=e.length;this._buffers.push(e);this.startLoop(s)}consume(e){this._bufferedBytes-=e;if(e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];this._buffers[0]=t.slice(e);return t.slice(0,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0];const r=t.length-e;if(e>=s.length){t.set(this._buffers.shift(),r)}else{t.set(new Uint8Array(s.buffer,s.byteOffset,e),r);this._buffers[0]=s.slice(e)}e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=true;do{switch(this._state){case _:t=this.getInfo();break;case p:t=this.getPayloadLength16();break;case m:t=this.getPayloadLength64();break;case b:this.getMask();break;case k:t=this.getData(e);break;default:this._loop=false;return}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=false;return}const e=this.consume(2);if((e[0]&48)!==0){this._loop=false;return error(RangeError,"RSV2 and RSV3 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_2_3")}const t=(e[0]&64)===64;if(t&&!this._extensions[n.extensionName]){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}this._fin=(e[0]&128)===128;this._opcode=e[0]&15;this._payloadLength=e[1]&127;if(this._opcode===0){if(t){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}if(!this._fragmented){this._loop=false;return error(RangeError,"invalid opcode 0",true,1002,"WS_ERR_INVALID_OPCODE")}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){this._loop=false;return error(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE")}this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin){this._loop=false;return error(RangeError,"FIN must be set",true,1002,"WS_ERR_EXPECTED_FIN")}if(t){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}if(this._payloadLength>125){this._loop=false;return error(RangeError,`invalid payload length ${this._payloadLength}`,true,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}}else{this._loop=false;return error(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE")}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;this._masked=(e[1]&128)===128;if(this._isServer){if(!this._masked){this._loop=false;return error(RangeError,"MASK must be set",true,1002,"WS_ERR_EXPECTED_MASK")}}else if(this._masked){this._loop=false;return error(RangeError,"MASK must be clear",true,1002,"WS_ERR_UNEXPECTED_MASK")}if(this._payloadLength===126)this._state=p;else if(this._payloadLength===127)this._state=m;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=false;return}this._payloadLength=this.consume(2).readUInt16BE(0);return this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=false;return}const e=this.consume(8);const t=e.readUInt32BE(0);if(t>Math.pow(2,53-32)-1){this._loop=false;return error(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",false,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")}this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4);return this.haveLength()}haveLength(){if(this._payloadLength&&this._opcode<8){this._totalPayloadLength+=this._payloadLength;if(this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){this._loop=false;return error(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")}}if(this._masked)this._state=b;else this._state=k}getMask(){if(this._bufferedBytes<4){this._loop=false;return}this._mask=this.consume(4);this._state=k}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=false;return}t=this.consume(this._payloadLength);if(this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0){h(t,this._mask)}}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=y;this.decompress(t,e);return}if(t.length){this._messageLength=this._totalPayloadLength;this._fragments.push(t)}return this.dataMessage()}decompress(e,t){const s=this._extensions[n.extensionName];s.decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){this._messageLength+=s.length;if(this._messageLength>this._maxPayload&&this._maxPayload>0){return t(error(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}this._fragments.push(s)}const r=this.dataMessage();if(r)return t(r);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength;const t=this._fragments;this._totalPayloadLength=0;this._messageLength=0;this._fragmented=0;this._fragments=[];if(this._opcode===2){let s;if(this._binaryType==="nodebuffer"){s=l(t,e)}else if(this._binaryType==="arraybuffer"){s=f(l(t,e))}else{s=t}this.emit("message",s,true)}else{const s=l(t,e);if(!this._skipUTF8Validation&&!u(s)){this._loop=false;return error(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8")}this.emit("message",s,false)}}this._state=_}controlMessage(e){if(this._opcode===8){this._loop=false;if(e.length===0){this.emit("conclude",1005,o);this.end()}else if(e.length===1){return error(RangeError,"invalid payload length 1",true,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else{const t=e.readUInt16BE(0);if(!d(t)){return error(RangeError,`invalid status code ${t}`,true,1002,"WS_ERR_INVALID_CLOSE_CODE")}const s=e.slice(2);if(!this._skipUTF8Validation&&!u(s)){return error(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8")}this.emit("conclude",t,s);this.end()}}else if(this._opcode===9){this.emit("ping",e)}else{this.emit("pong",e)}this._state=_}}e.exports=Receiver;function error(e,t,s,r,n){const i=new e(s?`Invalid WebSocket frame: ${t}`:t);Error.captureStackTrace(i,error);i.code=n;i[a]=r;return i}},48:function(e,t,s){"use strict";const r=s(808);const n=s(404);const{randomFillSync:i}=s(113);const o=s(349);const{EMPTY_BUFFER:a}=s(24);const{isValidStatusCode:c}=s(210);const{mask:l,toBuffer:f}=s(950);const h=Symbol("kByteLength");const d=Buffer.alloc(4);class Sender{constructor(e,t,s){this._extensions=t||{};if(s){this._generateMask=s;this._maskBuffer=Buffer.alloc(4)}this._socket=e;this._firstFragment=true;this._compress=false;this._bufferedBytes=0;this._deflating=false;this._queue=[]}static frame(e,t){let s;let r=false;let n=2;let o=false;if(t.mask){s=t.maskBuffer||d;if(t.generateMask){t.generateMask(s)}else{i(s,0,4)}o=(s[0]|s[1]|s[2]|s[3])===0;n=6}let a;if(typeof e==="string"){if((!t.mask||o)&&t[h]!==undefined){a=t[h]}else{e=Buffer.from(e);a=e.length}}else{a=e.length;r=t.mask&&t.readOnly&&!o}let c=a;if(a>=65536){n+=8;c=127}else if(a>125){n+=2;c=126}const f=Buffer.allocUnsafe(r?a+n:n);f[0]=t.fin?t.opcode|128:t.opcode;if(t.rsv1)f[0]|=64;f[1]=c;if(c===126){f.writeUInt16BE(a,2)}else if(c===127){f[2]=f[3]=0;f.writeUIntBE(a,4,6)}if(!t.mask)return[f,e];f[1]|=128;f[n-4]=s[0];f[n-3]=s[1];f[n-2]=s[2];f[n-1]=s[3];if(o)return[f,e];if(r){l(e,s,f,n,a);return[f]}l(e,s,e,0,a);return[f,e]}close(e,t,s,r){let n;if(e===undefined){n=a}else if(typeof e!=="number"||!c(e)){throw new TypeError("First argument must be a valid error code number")}else if(t===undefined||!t.length){n=Buffer.allocUnsafe(2);n.writeUInt16BE(e,0)}else{const s=Buffer.byteLength(t);if(s>123){throw new RangeError("The message must not be greater than 123 bytes")}n=Buffer.allocUnsafe(2+s);n.writeUInt16BE(e,0);if(typeof t==="string"){n.write(t,2)}else{n.set(t,2)}}const i={[h]:n.length,fin:true,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:false,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,n,false,i,r])}else{this.sendFrame(Sender.frame(n,i),r)}}ping(e,t,s){let r;let n;if(typeof e==="string"){r=Buffer.byteLength(e);n=false}else{e=f(e);r=e.length;n=f.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const i={[h]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,i,s])}else{this.sendFrame(Sender.frame(e,i),s)}}pong(e,t,s){let r;let n;if(typeof e==="string"){r=Buffer.byteLength(e);n=false}else{e=f(e);r=e.length;n=f.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const i={[h]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,i,s])}else{this.sendFrame(Sender.frame(e,i),s)}}send(e,t,s){const r=this._extensions[o.extensionName];let n=t.binary?2:1;let i=t.compress;let a;let c;if(typeof e==="string"){a=Buffer.byteLength(e);c=false}else{e=f(e);a=e.length;c=f.readOnly}if(this._firstFragment){this._firstFragment=false;if(i&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]){i=a>=r._threshold}this._compress=i}else{i=false;n=0}if(t.fin)this._firstFragment=true;if(r){const r={[h]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:i};if(this._deflating){this.enqueue([this.dispatch,e,this._compress,r,s])}else{this.dispatch(e,this._compress,r,s)}}else{this.sendFrame(Sender.frame(e,{[h]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:false}),s)}}dispatch(e,t,s,r){if(!t){this.sendFrame(Sender.frame(e,s),r);return}const n=this._extensions[o.extensionName];this._bufferedBytes+=s[h];this._deflating=true;n.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");if(typeof r==="function")r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t];const r=s[s.length-1];if(typeof r==="function")r(e)}return}this._bufferedBytes-=s[h];this._deflating=false;s.readOnly=false;this.sendFrame(Sender.frame(t,s),r);this.dequeue()}))}dequeue(){while(!this._deflating&&this._queue.length){const e=this._queue.shift();this._bufferedBytes-=e[3][h];Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][h];this._queue.push(e)}sendFrame(e,t){if(e.length===2){this._socket.cork();this._socket.write(e[0]);this._socket.write(e[1],t);this._socket.uncork()}else{this._socket.write(e[0],t)}}}e.exports=Sender},377:function(e,t,s){"use strict";const{Duplex:r}=s(781);function emitClose(e){e.emit("close")}function duplexOnEnd(){if(!this.destroyed&&this._writableState.finished){this.destroy()}}function duplexOnError(e){this.removeListener("error",duplexOnError);this.destroy();if(this.listenerCount("error")===0){this.emit("error",e)}}function createWebSocketStream(e,t){let s=true;const n=new r({...t,autoDestroy:false,emitClose:false,objectMode:false,writableObjectMode:false});e.on("message",(function message(t,s){const r=!s&&n._readableState.objectMode?t.toString():t;if(!n.push(r))e.pause()}));e.once("error",(function error(e){if(n.destroyed)return;s=false;n.destroy(e)}));e.once("close",(function close(){if(n.destroyed)return;n.push(null)}));n._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t);process.nextTick(emitClose,n);return}let i=false;e.once("error",(function error(e){i=true;r(e)}));e.once("close",(function close(){if(!i)r(t);process.nextTick(emitClose,n)}));if(s)e.terminate()};n._final=function(t){if(e.readyState===e.CONNECTING){e.once("open",(function open(){n._final(t)}));return}if(e._socket===null)return;if(e._socket._writableState.finished){t();if(n._readableState.endEmitted)n.destroy()}else{e._socket.once("finish",(function finish(){t()}));e.close()}};n._read=function(){if(e.isPaused)e.resume()};n._write=function(t,s,r){if(e.readyState===e.CONNECTING){e.once("open",(function open(){n._write(t,s,r)}));return}e.send(t,r)};n.on("end",duplexOnEnd);n.on("error",duplexOnError);return n}e.exports=createWebSocketStream},897:function(e,t,s){"use strict";const{tokenChars:r}=s(210);function parse(e){const t=new Set;let s=-1;let n=-1;let i=0;for(i;i<e.length;i++){const o=e.charCodeAt(i);if(n===-1&&r[o]===1){if(s===-1)s=i}else if(i!==0&&(o===32||o===9)){if(n===-1&&s!==-1)n=i}else if(o===44){if(s===-1){throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1)n=i;const r=e.slice(s,n);if(t.has(r)){throw new SyntaxError(`The "${r}" subprotocol is duplicated`)}t.add(r);s=n=-1}else{throw new SyntaxError(`Unexpected character at index ${i}`)}}if(s===-1||n!==-1){throw new SyntaxError("Unexpected end of input")}const o=e.slice(s,i);if(t.has(o)){throw new SyntaxError(`The "${o}" subprotocol is duplicated`)}t.add(o);return t}e.exports={parse:parse}},210:function(e,t,s){"use strict";const r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function isValidStatusCode(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function _isValidUTF8(e){const t=e.length;let s=0;while(s<t){if((e[s]&128)===0){s++}else if((e[s]&224)===192){if(s+1===t||(e[s+1]&192)!==128||(e[s]&254)===192){return false}s+=2}else if((e[s]&240)===224){if(s+2>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||e[s]===224&&(e[s+1]&224)===128||e[s]===237&&(e[s+1]&224)===160){return false}s+=3}else if((e[s]&248)===240){if(s+3>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||(e[s+3]&192)!==128||e[s]===240&&(e[s+1]&240)===128||e[s]===244&&e[s+1]>143||e[s]>244){return false}s+=4}else{return false}}return true}try{const t=s(533);e.exports={isValidStatusCode:isValidStatusCode,isValidUTF8(e){return e.length<150?_isValidUTF8(e):t(e)},tokenChars:r}}catch(t){e.exports={isValidStatusCode:isValidStatusCode,isValidUTF8:_isValidUTF8,tokenChars:r}}},631:function(e,t,s){"use strict";const r=s(361);const n=s(685);const i=s(687);const o=s(808);const a=s(404);const{createHash:c}=s(113);const l=s(686);const f=s(349);const h=s(897);const d=s(830);const{GUID:u,kWebSocket:_}=s(24);const p=/^[+/0-9A-Za-z]{22}==$/;const m=0;const b=1;const k=2;class WebSocketServer extends r{constructor(e,t){super();e={maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:false,handleProtocols:null,clientTracking:true,verifyClient:null,noServer:false,backlog:null,server:null,host:null,path:null,port:null,WebSocket:d,...e};if(e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer){throw new TypeError('One and only one of the "port", "server", or "noServer" options '+"must be specified")}if(e.port!=null){this._server=n.createServer(((e,t)=>{const s=n.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"});t.end(s)}));this._server.listen(e.port,e.host,e.backlog,t)}else if(e.server){this._server=e.server}if(this._server){const e=this.emit.bind(this,"connection");this._removeListeners=addListeners(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}if(e.perMessageDeflate===true)e.perMessageDeflate={};if(e.clientTracking){this.clients=new Set;this._shouldEmitClose=false}this.options=e;this._state=m}address(){if(this.options.noServer){throw new Error('The server is operating in "noServer" mode')}if(!this._server)return null;return this._server.address()}close(e){if(this._state===k){if(e){this.once("close",(()=>{e(new Error("The server is not running"))}))}process.nextTick(emitClose,this);return}if(e)this.once("close",e);if(this._state===b)return;this._state=b;if(this.options.noServer||this.options.server){if(this._server){this._removeListeners();this._removeListeners=this._server=null}if(this.clients){if(!this.clients.size){process.nextTick(emitClose,this)}else{this._shouldEmitClose=true}}else{process.nextTick(emitClose,this)}}else{const e=this._server;this._removeListeners();this._removeListeners=this._server=null;e.close((()=>{emitClose(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");const s=t!==-1?e.url.slice(0,t):e.url;if(s!==this.options.path)return false}return true}handleUpgrade(e,t,s,r){t.on("error",socketOnError);const n=e.headers["sec-websocket-key"]!==undefined?e.headers["sec-websocket-key"]:false;const i=+e.headers["sec-websocket-version"];if(e.method!=="GET"||e.headers.upgrade.toLowerCase()!=="websocket"||!n||!p.test(n)||i!==8&&i!==13||!this.shouldHandle(e)){return abortHandshake(t,400)}const o=e.headers["sec-websocket-protocol"];let a=new Set;if(o!==undefined){try{a=h.parse(o)}catch(e){return abortHandshake(t,400)}}const c=e.headers["sec-websocket-extensions"];const d={};if(this.options.perMessageDeflate&&c!==undefined){const e=new f(this.options.perMessageDeflate,true,this.options.maxPayload);try{const t=l.parse(c);if(t[f.extensionName]){e.accept(t[f.extensionName]);d[f.extensionName]=e}}catch(e){return abortHandshake(t,400)}}if(this.options.verifyClient){const o={origin:e.headers[`${i===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(o,((i,o,c,l)=>{if(!i){return abortHandshake(t,o||401,c,l)}this.completeUpgrade(d,n,a,e,t,s,r)}));return}if(!this.options.verifyClient(o))return abortHandshake(t,401)}this.completeUpgrade(d,n,a,e,t,s,r)}completeUpgrade(e,t,s,r,n,i,o){if(!n.readable||!n.writable)return n.destroy();if(n[_]){throw new Error("server.handleUpgrade() was called more than once with the same "+"socket, possibly due to a misconfiguration")}if(this._state>m)return abortHandshake(n,503);const a=c("sha1").update(t+u).digest("base64");const h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${a}`];const d=new this.options.WebSocket(null);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;if(e){h.push(`Sec-WebSocket-Protocol: ${e}`);d._protocol=e}}if(e[f.extensionName]){const t=e[f.extensionName].params;const s=l.format({[f.extensionName]:[t]});h.push(`Sec-WebSocket-Extensions: ${s}`);d._extensions=e}this.emit("headers",h,r);n.write(h.concat("\r\n").join("\r\n"));n.removeListener("error",socketOnError);d.setSocket(n,i,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation});if(this.clients){this.clients.add(d);d.on("close",(()=>{this.clients.delete(d);if(this._shouldEmitClose&&!this.clients.size){process.nextTick(emitClose,this)}}))}o(d,r)}}e.exports=WebSocketServer;function addListeners(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function removeListeners(){for(const s of Object.keys(t)){e.removeListener(s,t[s])}}}function emitClose(e){e._state=k;e.emit("close")}function socketOnError(){this.destroy()}function abortHandshake(e,t,s,r){if(e.writable){s=s||n.STATUS_CODES[t];r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r};e.write(`HTTP/1.1 ${t} ${n.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}e.removeListener("error",socketOnError);e.destroy()}},830:function(e,t,s){"use strict";const r=s(361);const n=s(687);const i=s(685);const o=s(808);const a=s(404);const{randomBytes:c,createHash:l}=s(113);const{Readable:f}=s(781);const{URL:h}=s(310);const d=s(349);const u=s(464);const _=s(48);const{BINARY_TYPES:p,EMPTY_BUFFER:m,GUID:b,kForOnEventAttribute:k,kListener:y,kStatusCode:S,kWebSocket:g,NOOP:E}=s(24);const{EventTarget:{addEventListener:v,removeEventListener:w}}=s(648);const{format:x,parse:O}=s(686);const{toBuffer:C}=s(950);const T=["CONNECTING","OPEN","CLOSING","CLOSED"];const N=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;const L=[8,13];const W=30*1e3;class WebSocket extends r{constructor(e,t,s){super();this._binaryType=p[0];this._closeCode=1006;this._closeFrameReceived=false;this._closeFrameSent=false;this._closeMessage=m;this._closeTimer=null;this._extensions={};this._paused=false;this._protocol="";this._readyState=WebSocket.CONNECTING;this._receiver=null;this._sender=null;this._socket=null;if(e!==null){this._bufferedAmount=0;this._isServer=false;this._redirects=0;if(t===undefined){t=[]}else if(!Array.isArray(t)){if(typeof t==="object"&&t!==null){s=t;t=[]}else{t=[t]}}initAsClient(this,e,t,s)}else{this._isServer=true}}get binaryType(){return this._binaryType}set binaryType(e){if(!p.includes(e))return;this._binaryType=e;if(this._receiver)this._receiver._binaryType=e}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){const r=new u({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new _(e,this._extensions,s.generateMask);this._receiver=r;this._socket=e;r[g]=this;e[g]=this;r.on("conclude",receiverOnConclude);r.on("drain",receiverOnDrain);r.on("error",receiverOnError);r.on("message",receiverOnMessage);r.on("ping",receiverOnPing);r.on("pong",receiverOnPong);e.setTimeout(0);e.setNoDelay();if(t.length>0)e.unshift(t);e.on("close",socketOnClose);e.on("data",socketOnData);e.on("end",socketOnEnd);e.on("error",socketOnError);this._readyState=WebSocket.OPEN;this.emit("open")}emitClose(){if(!this._socket){this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[d.extensionName]){this._extensions[d.extensionName].cleanup()}this._receiver.removeAllListeners();this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";return abortHandshake(this,this._req,e)}if(this.readyState===WebSocket.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)){this._socket.end()}return}this._readyState=WebSocket.CLOSING;this._sender.close(e,t,!this._isServer,(e=>{if(e)return;this._closeFrameSent=true;if(this._closeFrameReceived||this._receiver._writableState.errorEmitted){this._socket.end()}}));this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),W)}pause(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=true;this._socket.pause()}ping(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.ping(e||m,t,s)}pong(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.pong(e||m,t,s)}resume(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=false;if(!this._receiver._writableState.needDrain)this._socket.resume()}send(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof t==="function"){s=t;t={}}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}const r={binary:typeof e!=="string",mask:!this._isServer,compress:true,fin:true,...t};if(!this._extensions[d.extensionName]){r.compress=false}this._sender.send(e||m,r,s)}terminate(){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";return abortHandshake(this,this._req,e)}if(this._socket){this._readyState=WebSocket.CLOSING;this._socket.destroy()}}}Object.defineProperty(WebSocket,"CONNECTING",{enumerable:true,value:T.indexOf("CONNECTING")});Object.defineProperty(WebSocket.prototype,"CONNECTING",{enumerable:true,value:T.indexOf("CONNECTING")});Object.defineProperty(WebSocket,"OPEN",{enumerable:true,value:T.indexOf("OPEN")});Object.defineProperty(WebSocket.prototype,"OPEN",{enumerable:true,value:T.indexOf("OPEN")});Object.defineProperty(WebSocket,"CLOSING",{enumerable:true,value:T.indexOf("CLOSING")});Object.defineProperty(WebSocket.prototype,"CLOSING",{enumerable:true,value:T.indexOf("CLOSING")});Object.defineProperty(WebSocket,"CLOSED",{enumerable:true,value:T.indexOf("CLOSED")});Object.defineProperty(WebSocket.prototype,"CLOSED",{enumerable:true,value:T.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(WebSocket.prototype,e,{enumerable:true})}));["open","error","close","message"].forEach((e=>{Object.defineProperty(WebSocket.prototype,`on${e}`,{enumerable:true,get(){for(const t of this.listeners(e)){if(t[k])return t[y]}return null},set(t){for(const t of this.listeners(e)){if(t[k]){this.removeListener(e,t);break}}if(typeof t!=="function")return;this.addEventListener(e,t,{[k]:true})}})}));WebSocket.prototype.addEventListener=v;WebSocket.prototype.removeEventListener=w;e.exports=WebSocket;function initAsClient(e,t,s,r){const o={protocolVersion:L[1],maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:true,followRedirects:false,maxRedirects:10,...r,createConnection:undefined,socketPath:undefined,hostname:undefined,protocol:undefined,timeout:undefined,method:undefined,host:undefined,path:undefined,port:undefined};if(!L.includes(o.protocolVersion)){throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} `+`(supported versions: ${L.join(", ")})`)}let a;if(t instanceof h){a=t;e._url=t.href}else{try{a=new h(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}e._url=t}const f=a.protocol==="wss:";const u=a.protocol==="ws+unix:";let _;if(a.protocol!=="ws:"&&!f&&!u){_='The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"'}else if(u&&!a.pathname){_="The URL's pathname is empty"}else if(a.hash){_="The URL contains a fragment identifier"}if(_){const t=new SyntaxError(_);if(e._redirects===0){throw t}else{emitErrorAndClose(e,t);return}}const p=f?443:80;const m=c(16).toString("base64");const k=f?n.get:i.get;const y=new Set;let S;o.createConnection=f?tlsConnect:netConnect;o.defaultPort=o.defaultPort||p;o.port=a.port||p;o.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname;o.headers={"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket",...o.headers};o.path=a.pathname+a.search;o.timeout=o.handshakeTimeout;if(o.perMessageDeflate){S=new d(o.perMessageDeflate!==true?o.perMessageDeflate:{},false,o.maxPayload);o.headers["Sec-WebSocket-Extensions"]=x({[d.extensionName]:S.offer()})}if(s.length){for(const e of s){if(typeof e!=="string"||!N.test(e)||y.has(e)){throw new SyntaxError("An invalid or duplicated subprotocol was specified")}y.add(e)}o.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(o.origin){if(o.protocolVersion<13){o.headers["Sec-WebSocket-Origin"]=o.origin}else{o.headers.Origin=o.origin}}if(a.username||a.password){o.auth=`${a.username}:${a.password}`}if(u){const e=o.path.split(":");o.socketPath=e[0];o.path=e[1]}if(o.followRedirects){if(e._redirects===0){e._originalHost=a.host;const t=r&&r.headers;r={...r,headers:{}};if(t){for(const[e,s]of Object.entries(t)){r.headers[e.toLowerCase()]=s}}}else if(a.host!==e._originalHost){delete o.headers.authorization;delete o.headers.cookie;delete o.headers.host;o.auth=undefined}if(o.auth&&!r.headers.authorization){r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")}}let g=e._req=k(o);if(o.timeout){g.on("timeout",(()=>{abortHandshake(e,g,"Opening handshake has timed out")}))}g.on("error",(t=>{if(g===null||g.aborted)return;g=e._req=null;emitErrorAndClose(e,t)}));g.on("response",(n=>{const i=n.headers.location;const a=n.statusCode;if(i&&o.followRedirects&&a>=300&&a<400){if(++e._redirects>o.maxRedirects){abortHandshake(e,g,"Maximum redirects exceeded");return}g.abort();let n;try{n=new h(i,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${i}`);emitErrorAndClose(e,s);return}initAsClient(e,n,s,r)}else if(!e.emit("unexpected-response",g,n)){abortHandshake(e,g,`Unexpected server response: ${n.statusCode}`)}}));g.on("upgrade",((t,s,r)=>{e.emit("upgrade",t);if(e.readyState!==WebSocket.CONNECTING)return;g=e._req=null;const n=l("sha1").update(m+b).digest("base64");if(t.headers["sec-websocket-accept"]!==n){abortHandshake(e,s,"Invalid Sec-WebSocket-Accept header");return}const i=t.headers["sec-websocket-protocol"];let a;if(i!==undefined){if(!y.size){a="Server sent a subprotocol but none was requested"}else if(!y.has(i)){a="Server sent an invalid subprotocol"}}else if(y.size){a="Server sent no subprotocol"}if(a){abortHandshake(e,s,a);return}if(i)e._protocol=i;const c=t.headers["sec-websocket-extensions"];if(c!==undefined){if(!S){const t="Server sent a Sec-WebSocket-Extensions header but no extension "+"was requested";abortHandshake(e,s,t);return}let t;try{t=O(c)}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}const r=Object.keys(t);if(r.length!==1||r[0]!==d.extensionName){const t="Server indicated an extension that was not requested";abortHandshake(e,s,t);return}try{S.accept(t[d.extensionName])}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}e._extensions[d.extensionName]=S}e.setSocket(s,r,{generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}))}function emitErrorAndClose(e,t){e._readyState=WebSocket.CLOSING;e.emit("error",t);e.emitClose()}function netConnect(e){e.path=e.socketPath;return o.connect(e)}function tlsConnect(e){e.path=undefined;if(!e.servername&&e.servername!==""){e.servername=o.isIP(e.host)?"":e.host}return a.connect(e)}function abortHandshake(e,t,s){e._readyState=WebSocket.CLOSING;const r=new Error(s);Error.captureStackTrace(r,abortHandshake);if(t.setHeader){t.abort();if(t.socket&&!t.socket.destroyed){t.socket.destroy()}t.once("abort",e.emitClose.bind(e));e.emit("error",r)}else{t.destroy(r);t.once("error",e.emit.bind(e,"error"));t.once("close",e.emitClose.bind(e))}}function sendAfterClose(e,t,s){if(t){const s=C(t).length;if(e._socket)e._sender._bufferedBytes+=s;else e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} `+`(${T[e.readyState]})`);s(t)}}function receiverOnConclude(e,t){const s=this[g];s._closeFrameReceived=true;s._closeMessage=t;s._closeCode=e;if(s._socket[g]===undefined)return;s._socket.removeListener("data",socketOnData);process.nextTick(resume,s._socket);if(e===1005)s.close();else s.close(e,t)}function receiverOnDrain(){const e=this[g];if(!e.isPaused)e._socket.resume()}function receiverOnError(e){const t=this[g];if(t._socket[g]!==undefined){t._socket.removeListener("data",socketOnData);process.nextTick(resume,t._socket);t.close(e[S])}t.emit("error",e)}function receiverOnFinish(){this[g].emitClose()}function receiverOnMessage(e,t){this[g].emit("message",e,t)}function receiverOnPing(e){const t=this[g];t.pong(e,!t._isServer,E);t.emit("ping",e)}function receiverOnPong(e){this[g].emit("pong",e)}function resume(e){e.resume()}function socketOnClose(){const e=this[g];this.removeListener("close",socketOnClose);this.removeListener("data",socketOnData);this.removeListener("end",socketOnEnd);e._readyState=WebSocket.CLOSING;let t;if(!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null){e._receiver.write(t)}e._receiver.end();this[g]=undefined;clearTimeout(e._closeTimer);if(e._receiver._writableState.finished||e._receiver._writableState.errorEmitted){e.emitClose()}else{e._receiver.on("error",receiverOnFinish);e._receiver.on("finish",receiverOnFinish)}}function socketOnData(e){if(!this[g]._receiver.write(e)){this.pause()}}function socketOnEnd(){const e=this[g];e._readyState=WebSocket.CLOSING;e._receiver.end();this.end()}function socketOnError(){const e=this[g];this.removeListener("error",socketOnError);this.on("error",E);if(e){e._readyState=WebSocket.CLOSING;this.destroy()}}},745:function(module){module.exports=eval("require")("bufferutil")},533:function(module){module.exports=eval("require")("utf-8-validate")},113:function(e){"use strict";e.exports=require("crypto")},361:function(e){"use strict";e.exports=require("events")},685:function(e){"use strict";e.exports=require("http")},687:function(e){"use strict";e.exports=require("https")},808:function(e){"use strict";e.exports=require("net")},781:function(e){"use strict";e.exports=require("stream")},404:function(e){"use strict";e.exports=require("tls")},310:function(e){"use strict";e.exports=require("url")},796:function(e){"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var r=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(993);module.exports=__webpack_exports__})();
|
|
1
|
+
(function(){var __webpack_modules__={821:function(e,t,s){"use strict";const r=s(191);r.createWebSocketStream=s(382);r.Server=s(847);r.Receiver=s(288);r.Sender=s(262);r.WebSocket=r;r.WebSocketServer=r.Server;e.exports=r},465:function(e,t,s){"use strict";const{EMPTY_BUFFER:r}=s(273);const n=Buffer[Symbol.species];function concat(e,t){if(e.length===0)return r;if(e.length===1)return e[0];const s=Buffer.allocUnsafe(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];s.set(r,i);i+=r.length}if(i<t){return new n(s.buffer,s.byteOffset,i)}return s}function _mask(e,t,s,r,n){for(let i=0;i<n;i++){s[r+i]=e[i]^t[i&3]}}function _unmask(e,t){for(let s=0;s<e.length;s++){e[s]^=t[s&3]}}function toArrayBuffer(e){if(e.length===e.buffer.byteLength){return e.buffer}return e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function toBuffer(e){toBuffer.readOnly=true;if(Buffer.isBuffer(e))return e;let t;if(e instanceof ArrayBuffer){t=new n(e)}else if(ArrayBuffer.isView(e)){t=new n(e.buffer,e.byteOffset,e.byteLength)}else{t=Buffer.from(e);toBuffer.readOnly=false}return t}e.exports={concat:concat,mask:_mask,toArrayBuffer:toArrayBuffer,toBuffer:toBuffer,unmask:_unmask};if(!process.env.WS_NO_BUFFER_UTIL){try{const t=s(815);e.exports.mask=function(e,s,r,n,i){if(i<48)_mask(e,s,r,n,i);else t.mask(e,s,r,n,i)};e.exports.unmask=function(e,s){if(e.length<32)_unmask(e,s);else t.unmask(e,s)}}catch(e){}}},273:function(e){"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},460:function(e,t,s){"use strict";const{kForOnEventAttribute:r,kListener:n}=s(273);const i=Symbol("kCode");const o=Symbol("kData");const a=Symbol("kError");const c=Symbol("kMessage");const l=Symbol("kReason");const f=Symbol("kTarget");const h=Symbol("kType");const d=Symbol("kWasClean");class Event{constructor(e){this[f]=null;this[h]=e}get target(){return this[f]}get type(){return this[h]}}Object.defineProperty(Event.prototype,"target",{enumerable:true});Object.defineProperty(Event.prototype,"type",{enumerable:true});class CloseEvent extends Event{constructor(e,t={}){super(e);this[i]=t.code===undefined?0:t.code;this[l]=t.reason===undefined?"":t.reason;this[d]=t.wasClean===undefined?false:t.wasClean}get code(){return this[i]}get reason(){return this[l]}get wasClean(){return this[d]}}Object.defineProperty(CloseEvent.prototype,"code",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"reason",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"wasClean",{enumerable:true});class ErrorEvent extends Event{constructor(e,t={}){super(e);this[a]=t.error===undefined?null:t.error;this[c]=t.message===undefined?"":t.message}get error(){return this[a]}get message(){return this[c]}}Object.defineProperty(ErrorEvent.prototype,"error",{enumerable:true});Object.defineProperty(ErrorEvent.prototype,"message",{enumerable:true});class MessageEvent extends Event{constructor(e,t={}){super(e);this[o]=t.data===undefined?null:t.data}get data(){return this[o]}}Object.defineProperty(MessageEvent.prototype,"data",{enumerable:true});const u={addEventListener(e,t,s={}){for(const i of this.listeners(e)){if(!s[r]&&i[n]===t&&!i[r]){return}}let i;if(e==="message"){i=function onMessage(e,s){const r=new MessageEvent("message",{data:s?e:e.toString()});r[f]=this;callListener(t,this,r)}}else if(e==="close"){i=function onClose(e,s){const r=new CloseEvent("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[f]=this;callListener(t,this,r)}}else if(e==="error"){i=function onError(e){const s=new ErrorEvent("error",{error:e,message:e.message});s[f]=this;callListener(t,this,s)}}else if(e==="open"){i=function onOpen(){const e=new Event("open");e[f]=this;callListener(t,this,e)}}else{return}i[r]=!!s[r];i[n]=t;if(s.once){this.once(e,i)}else{this.on(e,i)}},removeEventListener(e,t){for(const s of this.listeners(e)){if(s[n]===t&&!s[r]){this.removeListener(e,s);break}}}};e.exports={CloseEvent:CloseEvent,ErrorEvent:ErrorEvent,Event:Event,EventTarget:u,MessageEvent:MessageEvent};function callListener(e,t,s){if(typeof e==="object"&&e.handleEvent){e.handleEvent.call(e,s)}else{e.call(t,s)}}},459:function(e,t,s){"use strict";const{tokenChars:r}=s(916);function push(e,t,s){if(e[t]===undefined)e[t]=[s];else e[t].push(s)}function parse(e){const t=Object.create(null);let s=Object.create(null);let n=false;let i=false;let o=false;let a;let c;let l=-1;let f=-1;let h=-1;let d=0;for(;d<e.length;d++){f=e.charCodeAt(d);if(a===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(d!==0&&(f===32||f===9)){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;const r=e.slice(l,h);if(f===44){push(t,r,s);s=Object.create(null)}else{a=r}l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(c===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(f===32||f===9){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;push(s,e.slice(l,h),true);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}l=h=-1}else if(f===61&&l!==-1&&h===-1){c=e.slice(l,d);l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else{if(i){if(r[f]!==1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(l===-1)l=d;else if(!n)n=true;i=false}else if(o){if(r[f]===1){if(l===-1)l=d}else if(f===34&&l!==-1){o=false;h=d}else if(f===92){i=true}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(f===34&&e.charCodeAt(d-1)===61){o=true}else if(h===-1&&r[f]===1){if(l===-1)l=d}else if(l!==-1&&(f===32||f===9)){if(h===-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;let r=e.slice(l,h);if(n){r=r.replace(/\\/g,"");n=false}push(s,c,r);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}c=undefined;l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}}if(l===-1||o||f===32||f===9){throw new SyntaxError("Unexpected end of input")}if(h===-1)h=d;const u=e.slice(l,h);if(a===undefined){push(t,u,s)}else{if(c===undefined){push(s,u,true)}else if(n){push(s,c,u.replace(/\\/g,""))}else{push(s,c,u)}push(t,a,s)}return t}function format(e){return Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>e===true?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")}e.exports={format:format,parse:parse}},241:function(e){"use strict";const t=Symbol("kDone");const s=Symbol("kRun");class Limiter{constructor(e){this[t]=()=>{this.pending--;this[s]()};this.concurrency=e||Infinity;this.jobs=[];this.pending=0}add(e){this.jobs.push(e);this[s]()}[s](){if(this.pending===this.concurrency)return;if(this.jobs.length){const e=this.jobs.shift();this.pending++;e(this[t])}}}e.exports=Limiter},668:function(e,t,s){"use strict";const r=s(796);const n=s(465);const i=s(241);const{kStatusCode:o}=s(273);const a=Buffer[Symbol.species];const c=Buffer.from([0,0,255,255]);const l=Symbol("permessage-deflate");const f=Symbol("total-length");const h=Symbol("callback");const d=Symbol("buffers");const u=Symbol("error");let _;class PerMessageDeflate{constructor(e,t,s){this._maxPayload=s|0;this._options=e||{};this._threshold=this._options.threshold!==undefined?this._options.threshold:1024;this._isServer=!!t;this._deflate=null;this._inflate=null;this.params=null;if(!_){const e=this._options.concurrencyLimit!==undefined?this._options.concurrencyLimit:10;_=new i(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};if(this._options.serverNoContextTakeover){e.server_no_context_takeover=true}if(this._options.clientNoContextTakeover){e.client_no_context_takeover=true}if(this._options.serverMaxWindowBits){e.server_max_window_bits=this._options.serverMaxWindowBits}if(this._options.clientMaxWindowBits){e.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits==null){e.client_max_window_bits=true}return e}accept(e){e=this.normalizeParams(e);this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e);return this.params}cleanup(){if(this._inflate){this._inflate.close();this._inflate=null}if(this._deflate){const e=this._deflate[h];this._deflate.close();this._deflate=null;if(e){e(new Error("The deflate stream was closed while data was being processed"))}}}acceptAsServer(e){const t=this._options;const s=e.find((e=>{if(t.serverNoContextTakeover===false&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===false||typeof t.serverMaxWindowBits==="number"&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==="number"&&!e.client_max_window_bits){return false}return true}));if(!s){throw new Error("None of the extension offers can be accepted")}if(t.serverNoContextTakeover){s.server_no_context_takeover=true}if(t.clientNoContextTakeover){s.client_no_context_takeover=true}if(typeof t.serverMaxWindowBits==="number"){s.server_max_window_bits=t.serverMaxWindowBits}if(typeof t.clientMaxWindowBits==="number"){s.client_max_window_bits=t.clientMaxWindowBits}else if(s.client_max_window_bits===true||t.clientMaxWindowBits===false){delete s.client_max_window_bits}return s}acceptAsClient(e){const t=e[0];if(this._options.clientNoContextTakeover===false&&t.client_no_context_takeover){throw new Error('Unexpected parameter "client_no_context_takeover"')}if(!t.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number"){t.client_max_window_bits=this._options.clientMaxWindowBits}}else if(this._options.clientMaxWindowBits===false||typeof this._options.clientMaxWindowBits==="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits){throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}return t}normalizeParams(e){e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1){throw new Error(`Parameter "${t}" must have only a single value`)}s=s[0];if(t==="client_max_window_bits"){if(s!==true){const e=+s;if(!Number.isInteger(e)||e<8||e>15){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}s=e}else if(!this._isServer){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}}else if(t==="server_max_window_bits"){const e=+s;if(!Number.isInteger(e)||e<8||e>15){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}s=e}else if(t==="client_no_context_takeover"||t==="server_no_context_takeover"){if(s!==true){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}}else{throw new Error(`Unknown parameter "${t}"`)}e[t]=s}))}));return e}decompress(e,t,s){_.add((r=>{this._decompress(e,t,((e,t)=>{r();s(e,t)}))}))}compress(e,t,s){_.add((r=>{this._compress(e,t,((e,t)=>{r();s(e,t)}))}))}_decompress(e,t,s){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t});this._inflate[l]=this;this._inflate[f]=0;this._inflate[d]=[];this._inflate.on("error",inflateOnError);this._inflate.on("data",inflateOnData)}this._inflate[h]=s;this._inflate.write(e);if(t)this._inflate.write(c);this._inflate.flush((()=>{const e=this._inflate[u];if(e){this._inflate.close();this._inflate=null;s(e);return}const r=n.concat(this._inflate[d],this._inflate[f]);if(this._inflate._readableState.endEmitted){this._inflate.close();this._inflate=null}else{this._inflate[f]=0;this._inflate[d]=[];if(t&&this.params[`${i}_no_context_takeover`]){this._inflate.reset()}}s(null,r)}))}_compress(e,t,s){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t});this._deflate[f]=0;this._deflate[d]=[];this._deflate.on("data",deflateOnData)}this._deflate[h]=s;this._deflate.write(e);this._deflate.flush(r.Z_SYNC_FLUSH,(()=>{if(!this._deflate){return}let e=n.concat(this._deflate[d],this._deflate[f]);if(t){e=new a(e.buffer,e.byteOffset,e.length-4)}this._deflate[h]=null;this._deflate[f]=0;this._deflate[d]=[];if(t&&this.params[`${i}_no_context_takeover`]){this._deflate.reset()}s(null,e)}))}}e.exports=PerMessageDeflate;function deflateOnData(e){this[d].push(e);this[f]+=e.length}function inflateOnData(e){this[f]+=e.length;if(this[l]._maxPayload<1||this[f]<=this[l]._maxPayload){this[d].push(e);return}this[u]=new RangeError("Max payload size exceeded");this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";this[u][o]=1009;this.removeListener("data",inflateOnData);this.reset()}function inflateOnError(e){this[l]._inflate=null;e[o]=1007;this[h](e)}},288:function(e,t,s){"use strict";const{Writable:r}=s(781);const n=s(668);const{BINARY_TYPES:i,EMPTY_BUFFER:o,kStatusCode:a,kWebSocket:c}=s(273);const{concat:l,toArrayBuffer:f,unmask:h}=s(465);const{isValidStatusCode:d,isValidUTF8:u}=s(916);const _=Buffer[Symbol.species];const p=0;const m=1;const b=2;const k=3;const S=4;const y=5;class Receiver extends r{constructor(e={}){super();this._binaryType=e.binaryType||i[0];this._extensions=e.extensions||{};this._isServer=!!e.isServer;this._maxPayload=e.maxPayload|0;this._skipUTF8Validation=!!e.skipUTF8Validation;this[c]=undefined;this._bufferedBytes=0;this._buffers=[];this._compressed=false;this._payloadLength=0;this._mask=undefined;this._fragmented=0;this._masked=false;this._fin=false;this._opcode=0;this._totalPayloadLength=0;this._messageLength=0;this._fragments=[];this._state=p;this._loop=false}_write(e,t,s){if(this._opcode===8&&this._state==p)return s();this._bufferedBytes+=e.length;this._buffers.push(e);this.startLoop(s)}consume(e){this._bufferedBytes-=e;if(e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];this._buffers[0]=new _(t.buffer,t.byteOffset+e,t.length-e);return new _(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0];const r=t.length-e;if(e>=s.length){t.set(this._buffers.shift(),r)}else{t.set(new Uint8Array(s.buffer,s.byteOffset,e),r);this._buffers[0]=new _(s.buffer,s.byteOffset+e,s.length-e)}e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=true;do{switch(this._state){case p:t=this.getInfo();break;case m:t=this.getPayloadLength16();break;case b:t=this.getPayloadLength64();break;case k:this.getMask();break;case S:t=this.getData(e);break;default:this._loop=false;return}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=false;return}const e=this.consume(2);if((e[0]&48)!==0){this._loop=false;return error(RangeError,"RSV2 and RSV3 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_2_3")}const t=(e[0]&64)===64;if(t&&!this._extensions[n.extensionName]){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}this._fin=(e[0]&128)===128;this._opcode=e[0]&15;this._payloadLength=e[1]&127;if(this._opcode===0){if(t){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}if(!this._fragmented){this._loop=false;return error(RangeError,"invalid opcode 0",true,1002,"WS_ERR_INVALID_OPCODE")}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){this._loop=false;return error(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE")}this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin){this._loop=false;return error(RangeError,"FIN must be set",true,1002,"WS_ERR_EXPECTED_FIN")}if(t){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){this._loop=false;return error(RangeError,`invalid payload length ${this._payloadLength}`,true,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}}else{this._loop=false;return error(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE")}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;this._masked=(e[1]&128)===128;if(this._isServer){if(!this._masked){this._loop=false;return error(RangeError,"MASK must be set",true,1002,"WS_ERR_EXPECTED_MASK")}}else if(this._masked){this._loop=false;return error(RangeError,"MASK must be clear",true,1002,"WS_ERR_UNEXPECTED_MASK")}if(this._payloadLength===126)this._state=m;else if(this._payloadLength===127)this._state=b;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=false;return}this._payloadLength=this.consume(2).readUInt16BE(0);return this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=false;return}const e=this.consume(8);const t=e.readUInt32BE(0);if(t>Math.pow(2,53-32)-1){this._loop=false;return error(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",false,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")}this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4);return this.haveLength()}haveLength(){if(this._payloadLength&&this._opcode<8){this._totalPayloadLength+=this._payloadLength;if(this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){this._loop=false;return error(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")}}if(this._masked)this._state=k;else this._state=S}getMask(){if(this._bufferedBytes<4){this._loop=false;return}this._mask=this.consume(4);this._state=S}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=false;return}t=this.consume(this._payloadLength);if(this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0){h(t,this._mask)}}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=y;this.decompress(t,e);return}if(t.length){this._messageLength=this._totalPayloadLength;this._fragments.push(t)}return this.dataMessage()}decompress(e,t){const s=this._extensions[n.extensionName];s.decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){this._messageLength+=s.length;if(this._messageLength>this._maxPayload&&this._maxPayload>0){return t(error(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"))}this._fragments.push(s)}const r=this.dataMessage();if(r)return t(r);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength;const t=this._fragments;this._totalPayloadLength=0;this._messageLength=0;this._fragmented=0;this._fragments=[];if(this._opcode===2){let s;if(this._binaryType==="nodebuffer"){s=l(t,e)}else if(this._binaryType==="arraybuffer"){s=f(l(t,e))}else{s=t}this.emit("message",s,true)}else{const s=l(t,e);if(!this._skipUTF8Validation&&!u(s)){this._loop=false;return error(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8")}this.emit("message",s,false)}}this._state=p}controlMessage(e){if(this._opcode===8){this._loop=false;if(e.length===0){this.emit("conclude",1005,o);this.end()}else{const t=e.readUInt16BE(0);if(!d(t)){return error(RangeError,`invalid status code ${t}`,true,1002,"WS_ERR_INVALID_CLOSE_CODE")}const s=new _(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!u(s)){return error(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8")}this.emit("conclude",t,s);this.end()}}else if(this._opcode===9){this.emit("ping",e)}else{this.emit("pong",e)}this._state=p}}e.exports=Receiver;function error(e,t,s,r,n){const i=new e(s?`Invalid WebSocket frame: ${t}`:t);Error.captureStackTrace(i,error);i.code=n;i[a]=r;return i}},262:function(e,t,s){"use strict";const r=s(808);const n=s(404);const{randomFillSync:i}=s(113);const o=s(668);const{EMPTY_BUFFER:a}=s(273);const{isValidStatusCode:c}=s(916);const{mask:l,toBuffer:f}=s(465);const h=Symbol("kByteLength");const d=Buffer.alloc(4);class Sender{constructor(e,t,s){this._extensions=t||{};if(s){this._generateMask=s;this._maskBuffer=Buffer.alloc(4)}this._socket=e;this._firstFragment=true;this._compress=false;this._bufferedBytes=0;this._deflating=false;this._queue=[]}static frame(e,t){let s;let r=false;let n=2;let o=false;if(t.mask){s=t.maskBuffer||d;if(t.generateMask){t.generateMask(s)}else{i(s,0,4)}o=(s[0]|s[1]|s[2]|s[3])===0;n=6}let a;if(typeof e==="string"){if((!t.mask||o)&&t[h]!==undefined){a=t[h]}else{e=Buffer.from(e);a=e.length}}else{a=e.length;r=t.mask&&t.readOnly&&!o}let c=a;if(a>=65536){n+=8;c=127}else if(a>125){n+=2;c=126}const f=Buffer.allocUnsafe(r?a+n:n);f[0]=t.fin?t.opcode|128:t.opcode;if(t.rsv1)f[0]|=64;f[1]=c;if(c===126){f.writeUInt16BE(a,2)}else if(c===127){f[2]=f[3]=0;f.writeUIntBE(a,4,6)}if(!t.mask)return[f,e];f[1]|=128;f[n-4]=s[0];f[n-3]=s[1];f[n-2]=s[2];f[n-1]=s[3];if(o)return[f,e];if(r){l(e,s,f,n,a);return[f]}l(e,s,e,0,a);return[f,e]}close(e,t,s,r){let n;if(e===undefined){n=a}else if(typeof e!=="number"||!c(e)){throw new TypeError("First argument must be a valid error code number")}else if(t===undefined||!t.length){n=Buffer.allocUnsafe(2);n.writeUInt16BE(e,0)}else{const s=Buffer.byteLength(t);if(s>123){throw new RangeError("The message must not be greater than 123 bytes")}n=Buffer.allocUnsafe(2+s);n.writeUInt16BE(e,0);if(typeof t==="string"){n.write(t,2)}else{n.set(t,2)}}const i={[h]:n.length,fin:true,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:false,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,n,false,i,r])}else{this.sendFrame(Sender.frame(n,i),r)}}ping(e,t,s){let r;let n;if(typeof e==="string"){r=Buffer.byteLength(e);n=false}else{e=f(e);r=e.length;n=f.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const i={[h]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,i,s])}else{this.sendFrame(Sender.frame(e,i),s)}}pong(e,t,s){let r;let n;if(typeof e==="string"){r=Buffer.byteLength(e);n=false}else{e=f(e);r=e.length;n=f.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const i={[h]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,i,s])}else{this.sendFrame(Sender.frame(e,i),s)}}send(e,t,s){const r=this._extensions[o.extensionName];let n=t.binary?2:1;let i=t.compress;let a;let c;if(typeof e==="string"){a=Buffer.byteLength(e);c=false}else{e=f(e);a=e.length;c=f.readOnly}if(this._firstFragment){this._firstFragment=false;if(i&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]){i=a>=r._threshold}this._compress=i}else{i=false;n=0}if(t.fin)this._firstFragment=true;if(r){const r={[h]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:i};if(this._deflating){this.enqueue([this.dispatch,e,this._compress,r,s])}else{this.dispatch(e,this._compress,r,s)}}else{this.sendFrame(Sender.frame(e,{[h]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:false}),s)}}dispatch(e,t,s,r){if(!t){this.sendFrame(Sender.frame(e,s),r);return}const n=this._extensions[o.extensionName];this._bufferedBytes+=s[h];this._deflating=true;n.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");if(typeof r==="function")r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t];const r=s[s.length-1];if(typeof r==="function")r(e)}return}this._bufferedBytes-=s[h];this._deflating=false;s.readOnly=false;this.sendFrame(Sender.frame(t,s),r);this.dequeue()}))}dequeue(){while(!this._deflating&&this._queue.length){const e=this._queue.shift();this._bufferedBytes-=e[3][h];Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][h];this._queue.push(e)}sendFrame(e,t){if(e.length===2){this._socket.cork();this._socket.write(e[0]);this._socket.write(e[1],t);this._socket.uncork()}else{this._socket.write(e[0],t)}}}e.exports=Sender},382:function(e,t,s){"use strict";const{Duplex:r}=s(781);function emitClose(e){e.emit("close")}function duplexOnEnd(){if(!this.destroyed&&this._writableState.finished){this.destroy()}}function duplexOnError(e){this.removeListener("error",duplexOnError);this.destroy();if(this.listenerCount("error")===0){this.emit("error",e)}}function createWebSocketStream(e,t){let s=true;const n=new r({...t,autoDestroy:false,emitClose:false,objectMode:false,writableObjectMode:false});e.on("message",(function message(t,s){const r=!s&&n._readableState.objectMode?t.toString():t;if(!n.push(r))e.pause()}));e.once("error",(function error(e){if(n.destroyed)return;s=false;n.destroy(e)}));e.once("close",(function close(){if(n.destroyed)return;n.push(null)}));n._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t);process.nextTick(emitClose,n);return}let i=false;e.once("error",(function error(e){i=true;r(e)}));e.once("close",(function close(){if(!i)r(t);process.nextTick(emitClose,n)}));if(s)e.terminate()};n._final=function(t){if(e.readyState===e.CONNECTING){e.once("open",(function open(){n._final(t)}));return}if(e._socket===null)return;if(e._socket._writableState.finished){t();if(n._readableState.endEmitted)n.destroy()}else{e._socket.once("finish",(function finish(){t()}));e.close()}};n._read=function(){if(e.isPaused)e.resume()};n._write=function(t,s,r){if(e.readyState===e.CONNECTING){e.once("open",(function open(){n._write(t,s,r)}));return}e.send(t,r)};n.on("end",duplexOnEnd);n.on("error",duplexOnError);return n}e.exports=createWebSocketStream},491:function(e,t,s){"use strict";const{tokenChars:r}=s(916);function parse(e){const t=new Set;let s=-1;let n=-1;let i=0;for(i;i<e.length;i++){const o=e.charCodeAt(i);if(n===-1&&r[o]===1){if(s===-1)s=i}else if(i!==0&&(o===32||o===9)){if(n===-1&&s!==-1)n=i}else if(o===44){if(s===-1){throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1)n=i;const r=e.slice(s,n);if(t.has(r)){throw new SyntaxError(`The "${r}" subprotocol is duplicated`)}t.add(r);s=n=-1}else{throw new SyntaxError(`Unexpected character at index ${i}`)}}if(s===-1||n!==-1){throw new SyntaxError("Unexpected end of input")}const o=e.slice(s,i);if(t.has(o)){throw new SyntaxError(`The "${o}" subprotocol is duplicated`)}t.add(o);return t}e.exports={parse:parse}},916:function(e,t,s){"use strict";const{isUtf8:r}=s(300);const n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function isValidStatusCode(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function _isValidUTF8(e){const t=e.length;let s=0;while(s<t){if((e[s]&128)===0){s++}else if((e[s]&224)===192){if(s+1===t||(e[s+1]&192)!==128||(e[s]&254)===192){return false}s+=2}else if((e[s]&240)===224){if(s+2>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||e[s]===224&&(e[s+1]&224)===128||e[s]===237&&(e[s+1]&224)===160){return false}s+=3}else if((e[s]&248)===240){if(s+3>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||(e[s+3]&192)!==128||e[s]===240&&(e[s+1]&240)===128||e[s]===244&&e[s+1]>143||e[s]>244){return false}s+=4}else{return false}}return true}e.exports={isValidStatusCode:isValidStatusCode,isValidUTF8:_isValidUTF8,tokenChars:n};if(r){e.exports.isValidUTF8=function(e){return e.length<24?_isValidUTF8(e):r(e)}}else if(!process.env.WS_NO_UTF_8_VALIDATE){try{const t=s(646);e.exports.isValidUTF8=function(e){return e.length<32?_isValidUTF8(e):t(e)}}catch(e){}}},847:function(e,t,s){"use strict";const r=s(361);const n=s(685);const i=s(687);const o=s(808);const a=s(404);const{createHash:c}=s(113);const l=s(459);const f=s(668);const h=s(491);const d=s(191);const{GUID:u,kWebSocket:_}=s(273);const p=/^[+/0-9A-Za-z]{22}==$/;const m=0;const b=1;const k=2;class WebSocketServer extends r{constructor(e,t){super();e={maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:false,handleProtocols:null,clientTracking:true,verifyClient:null,noServer:false,backlog:null,server:null,host:null,path:null,port:null,WebSocket:d,...e};if(e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer){throw new TypeError('One and only one of the "port", "server", or "noServer" options '+"must be specified")}if(e.port!=null){this._server=n.createServer(((e,t)=>{const s=n.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"});t.end(s)}));this._server.listen(e.port,e.host,e.backlog,t)}else if(e.server){this._server=e.server}if(this._server){const e=this.emit.bind(this,"connection");this._removeListeners=addListeners(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}if(e.perMessageDeflate===true)e.perMessageDeflate={};if(e.clientTracking){this.clients=new Set;this._shouldEmitClose=false}this.options=e;this._state=m}address(){if(this.options.noServer){throw new Error('The server is operating in "noServer" mode')}if(!this._server)return null;return this._server.address()}close(e){if(this._state===k){if(e){this.once("close",(()=>{e(new Error("The server is not running"))}))}process.nextTick(emitClose,this);return}if(e)this.once("close",e);if(this._state===b)return;this._state=b;if(this.options.noServer||this.options.server){if(this._server){this._removeListeners();this._removeListeners=this._server=null}if(this.clients){if(!this.clients.size){process.nextTick(emitClose,this)}else{this._shouldEmitClose=true}}else{process.nextTick(emitClose,this)}}else{const e=this._server;this._removeListeners();this._removeListeners=this._server=null;e.close((()=>{emitClose(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");const s=t!==-1?e.url.slice(0,t):e.url;if(s!==this.options.path)return false}return true}handleUpgrade(e,t,s,r){t.on("error",socketOnError);const n=e.headers["sec-websocket-key"];const i=+e.headers["sec-websocket-version"];if(e.method!=="GET"){const s="Invalid HTTP method";abortHandshakeOrEmitwsClientError(this,e,t,405,s);return}if(e.headers.upgrade.toLowerCase()!=="websocket"){const s="Invalid Upgrade header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(!n||!p.test(n)){const s="Missing or invalid Sec-WebSocket-Key header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(i!==8&&i!==13){const s="Missing or invalid Sec-WebSocket-Version header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(!this.shouldHandle(e)){abortHandshake(t,400);return}const o=e.headers["sec-websocket-protocol"];let a=new Set;if(o!==undefined){try{a=h.parse(o)}catch(s){const r="Invalid Sec-WebSocket-Protocol header";abortHandshakeOrEmitwsClientError(this,e,t,400,r);return}}const c=e.headers["sec-websocket-extensions"];const d={};if(this.options.perMessageDeflate&&c!==undefined){const s=new f(this.options.perMessageDeflate,true,this.options.maxPayload);try{const e=l.parse(c);if(e[f.extensionName]){s.accept(e[f.extensionName]);d[f.extensionName]=s}}catch(s){const r="Invalid or unacceptable Sec-WebSocket-Extensions header";abortHandshakeOrEmitwsClientError(this,e,t,400,r);return}}if(this.options.verifyClient){const o={origin:e.headers[`${i===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(o,((i,o,c,l)=>{if(!i){return abortHandshake(t,o||401,c,l)}this.completeUpgrade(d,n,a,e,t,s,r)}));return}if(!this.options.verifyClient(o))return abortHandshake(t,401)}this.completeUpgrade(d,n,a,e,t,s,r)}completeUpgrade(e,t,s,r,n,i,o){if(!n.readable||!n.writable)return n.destroy();if(n[_]){throw new Error("server.handleUpgrade() was called more than once with the same "+"socket, possibly due to a misconfiguration")}if(this._state>m)return abortHandshake(n,503);const a=c("sha1").update(t+u).digest("base64");const h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${a}`];const d=new this.options.WebSocket(null);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;if(e){h.push(`Sec-WebSocket-Protocol: ${e}`);d._protocol=e}}if(e[f.extensionName]){const t=e[f.extensionName].params;const s=l.format({[f.extensionName]:[t]});h.push(`Sec-WebSocket-Extensions: ${s}`);d._extensions=e}this.emit("headers",h,r);n.write(h.concat("\r\n").join("\r\n"));n.removeListener("error",socketOnError);d.setSocket(n,i,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation});if(this.clients){this.clients.add(d);d.on("close",(()=>{this.clients.delete(d);if(this._shouldEmitClose&&!this.clients.size){process.nextTick(emitClose,this)}}))}o(d,r)}}e.exports=WebSocketServer;function addListeners(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function removeListeners(){for(const s of Object.keys(t)){e.removeListener(s,t[s])}}}function emitClose(e){e._state=k;e.emit("close")}function socketOnError(){this.destroy()}function abortHandshake(e,t,s,r){s=s||n.STATUS_CODES[t];r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r};e.once("finish",e.destroy);e.end(`HTTP/1.1 ${t} ${n.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function abortHandshakeOrEmitwsClientError(e,t,s,r,n){if(e.listenerCount("wsClientError")){const r=new Error(n);Error.captureStackTrace(r,abortHandshakeOrEmitwsClientError);e.emit("wsClientError",r,s,t)}else{abortHandshake(s,r,n)}}},191:function(e,t,s){"use strict";const r=s(361);const n=s(687);const i=s(685);const o=s(808);const a=s(404);const{randomBytes:c,createHash:l}=s(113);const{Readable:f}=s(781);const{URL:h}=s(310);const d=s(668);const u=s(288);const _=s(262);const{BINARY_TYPES:p,EMPTY_BUFFER:m,GUID:b,kForOnEventAttribute:k,kListener:S,kStatusCode:y,kWebSocket:g,NOOP:E}=s(273);const{EventTarget:{addEventListener:v,removeEventListener:w}}=s(460);const{format:x,parse:O}=s(459);const{toBuffer:C}=s(465);const T=30*1e3;const L=Symbol("kAborted");const N=[8,13];const W=["CONNECTING","OPEN","CLOSING","CLOSED"];const P=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class WebSocket extends r{constructor(e,t,s){super();this._binaryType=p[0];this._closeCode=1006;this._closeFrameReceived=false;this._closeFrameSent=false;this._closeMessage=m;this._closeTimer=null;this._extensions={};this._paused=false;this._protocol="";this._readyState=WebSocket.CONNECTING;this._receiver=null;this._sender=null;this._socket=null;if(e!==null){this._bufferedAmount=0;this._isServer=false;this._redirects=0;if(t===undefined){t=[]}else if(!Array.isArray(t)){if(typeof t==="object"&&t!==null){s=t;t=[]}else{t=[t]}}initAsClient(this,e,t,s)}else{this._isServer=true}}get binaryType(){return this._binaryType}set binaryType(e){if(!p.includes(e))return;this._binaryType=e;if(this._receiver)this._receiver._binaryType=e}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){const r=new u({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new _(e,this._extensions,s.generateMask);this._receiver=r;this._socket=e;r[g]=this;e[g]=this;r.on("conclude",receiverOnConclude);r.on("drain",receiverOnDrain);r.on("error",receiverOnError);r.on("message",receiverOnMessage);r.on("ping",receiverOnPing);r.on("pong",receiverOnPong);e.setTimeout(0);e.setNoDelay();if(t.length>0)e.unshift(t);e.on("close",socketOnClose);e.on("data",socketOnData);e.on("end",socketOnEnd);e.on("error",socketOnError);this._readyState=WebSocket.OPEN;this.emit("open")}emitClose(){if(!this._socket){this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[d.extensionName]){this._extensions[d.extensionName].cleanup()}this._receiver.removeAllListeners();this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";abortHandshake(this,this._req,e);return}if(this.readyState===WebSocket.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)){this._socket.end()}return}this._readyState=WebSocket.CLOSING;this._sender.close(e,t,!this._isServer,(e=>{if(e)return;this._closeFrameSent=true;if(this._closeFrameReceived||this._receiver._writableState.errorEmitted){this._socket.end()}}));this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),T)}pause(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=true;this._socket.pause()}ping(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.ping(e||m,t,s)}pong(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.pong(e||m,t,s)}resume(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=false;if(!this._receiver._writableState.needDrain)this._socket.resume()}send(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof t==="function"){s=t;t={}}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}const r={binary:typeof e!=="string",mask:!this._isServer,compress:true,fin:true,...t};if(!this._extensions[d.extensionName]){r.compress=false}this._sender.send(e||m,r,s)}terminate(){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";abortHandshake(this,this._req,e);return}if(this._socket){this._readyState=WebSocket.CLOSING;this._socket.destroy()}}}Object.defineProperty(WebSocket,"CONNECTING",{enumerable:true,value:W.indexOf("CONNECTING")});Object.defineProperty(WebSocket.prototype,"CONNECTING",{enumerable:true,value:W.indexOf("CONNECTING")});Object.defineProperty(WebSocket,"OPEN",{enumerable:true,value:W.indexOf("OPEN")});Object.defineProperty(WebSocket.prototype,"OPEN",{enumerable:true,value:W.indexOf("OPEN")});Object.defineProperty(WebSocket,"CLOSING",{enumerable:true,value:W.indexOf("CLOSING")});Object.defineProperty(WebSocket.prototype,"CLOSING",{enumerable:true,value:W.indexOf("CLOSING")});Object.defineProperty(WebSocket,"CLOSED",{enumerable:true,value:W.indexOf("CLOSED")});Object.defineProperty(WebSocket.prototype,"CLOSED",{enumerable:true,value:W.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(WebSocket.prototype,e,{enumerable:true})}));["open","error","close","message"].forEach((e=>{Object.defineProperty(WebSocket.prototype,`on${e}`,{enumerable:true,get(){for(const t of this.listeners(e)){if(t[k])return t[S]}return null},set(t){for(const t of this.listeners(e)){if(t[k]){this.removeListener(e,t);break}}if(typeof t!=="function")return;this.addEventListener(e,t,{[k]:true})}})}));WebSocket.prototype.addEventListener=v;WebSocket.prototype.removeEventListener=w;e.exports=WebSocket;function initAsClient(e,t,s,r){const o={protocolVersion:N[1],maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:true,followRedirects:false,maxRedirects:10,...r,createConnection:undefined,socketPath:undefined,hostname:undefined,protocol:undefined,timeout:undefined,method:"GET",host:undefined,path:undefined,port:undefined};if(!N.includes(o.protocolVersion)){throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} `+`(supported versions: ${N.join(", ")})`)}let a;if(t instanceof h){a=t;e._url=t.href}else{try{a=new h(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}e._url=t}const f=a.protocol==="wss:";const u=a.protocol==="ws+unix:";let _;if(a.protocol!=="ws:"&&!f&&!u){_='The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"'}else if(u&&!a.pathname){_="The URL's pathname is empty"}else if(a.hash){_="The URL contains a fragment identifier"}if(_){const t=new SyntaxError(_);if(e._redirects===0){throw t}else{emitErrorAndClose(e,t);return}}const p=f?443:80;const m=c(16).toString("base64");const k=f?n.request:i.request;const S=new Set;let y;o.createConnection=f?tlsConnect:netConnect;o.defaultPort=o.defaultPort||p;o.port=a.port||p;o.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname;o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"};o.path=a.pathname+a.search;o.timeout=o.handshakeTimeout;if(o.perMessageDeflate){y=new d(o.perMessageDeflate!==true?o.perMessageDeflate:{},false,o.maxPayload);o.headers["Sec-WebSocket-Extensions"]=x({[d.extensionName]:y.offer()})}if(s.length){for(const e of s){if(typeof e!=="string"||!P.test(e)||S.has(e)){throw new SyntaxError("An invalid or duplicated subprotocol was specified")}S.add(e)}o.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(o.origin){if(o.protocolVersion<13){o.headers["Sec-WebSocket-Origin"]=o.origin}else{o.headers.Origin=o.origin}}if(a.username||a.password){o.auth=`${a.username}:${a.password}`}if(u){const e=o.path.split(":");o.socketPath=e[0];o.path=e[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=u;e._originalSecure=f;e._originalHostOrSocketPath=u?o.socketPath:a.host;const t=r&&r.headers;r={...r,headers:{}};if(t){for(const[e,s]of Object.entries(t)){r.headers[e.toLowerCase()]=s}}}else if(e.listenerCount("redirect")===0){const t=u?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:false:e._originalIpc?false:a.host===e._originalHostOrSocketPath;if(!t||e._originalSecure&&!f){delete o.headers.authorization;delete o.headers.cookie;if(!t)delete o.headers.host;o.auth=undefined}}if(o.auth&&!r.headers.authorization){r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")}g=e._req=k(o);if(e._redirects){e.emit("redirect",e.url,g)}}else{g=e._req=k(o)}if(o.timeout){g.on("timeout",(()=>{abortHandshake(e,g,"Opening handshake has timed out")}))}g.on("error",(t=>{if(g===null||g[L])return;g=e._req=null;emitErrorAndClose(e,t)}));g.on("response",(n=>{const i=n.headers.location;const a=n.statusCode;if(i&&o.followRedirects&&a>=300&&a<400){if(++e._redirects>o.maxRedirects){abortHandshake(e,g,"Maximum redirects exceeded");return}g.abort();let n;try{n=new h(i,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${i}`);emitErrorAndClose(e,s);return}initAsClient(e,n,s,r)}else if(!e.emit("unexpected-response",g,n)){abortHandshake(e,g,`Unexpected server response: ${n.statusCode}`)}}));g.on("upgrade",((t,s,r)=>{e.emit("upgrade",t);if(e.readyState!==WebSocket.CONNECTING)return;g=e._req=null;if(t.headers.upgrade.toLowerCase()!=="websocket"){abortHandshake(e,s,"Invalid Upgrade header");return}const n=l("sha1").update(m+b).digest("base64");if(t.headers["sec-websocket-accept"]!==n){abortHandshake(e,s,"Invalid Sec-WebSocket-Accept header");return}const i=t.headers["sec-websocket-protocol"];let a;if(i!==undefined){if(!S.size){a="Server sent a subprotocol but none was requested"}else if(!S.has(i)){a="Server sent an invalid subprotocol"}}else if(S.size){a="Server sent no subprotocol"}if(a){abortHandshake(e,s,a);return}if(i)e._protocol=i;const c=t.headers["sec-websocket-extensions"];if(c!==undefined){if(!y){const t="Server sent a Sec-WebSocket-Extensions header but no extension "+"was requested";abortHandshake(e,s,t);return}let t;try{t=O(c)}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}const r=Object.keys(t);if(r.length!==1||r[0]!==d.extensionName){const t="Server indicated an extension that was not requested";abortHandshake(e,s,t);return}try{y.accept(t[d.extensionName])}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}e._extensions[d.extensionName]=y}e.setSocket(s,r,{generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}));g.end()}function emitErrorAndClose(e,t){e._readyState=WebSocket.CLOSING;e.emit("error",t);e.emitClose()}function netConnect(e){e.path=e.socketPath;return o.connect(e)}function tlsConnect(e){e.path=undefined;if(!e.servername&&e.servername!==""){e.servername=o.isIP(e.host)?"":e.host}return a.connect(e)}function abortHandshake(e,t,s){e._readyState=WebSocket.CLOSING;const r=new Error(s);Error.captureStackTrace(r,abortHandshake);if(t.setHeader){t[L]=true;t.abort();if(t.socket&&!t.socket.destroyed){t.socket.destroy()}process.nextTick(emitErrorAndClose,e,r)}else{t.destroy(r);t.once("error",e.emit.bind(e,"error"));t.once("close",e.emitClose.bind(e))}}function sendAfterClose(e,t,s){if(t){const s=C(t).length;if(e._socket)e._sender._bufferedBytes+=s;else e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} `+`(${W[e.readyState]})`);process.nextTick(s,t)}}function receiverOnConclude(e,t){const s=this[g];s._closeFrameReceived=true;s._closeMessage=t;s._closeCode=e;if(s._socket[g]===undefined)return;s._socket.removeListener("data",socketOnData);process.nextTick(resume,s._socket);if(e===1005)s.close();else s.close(e,t)}function receiverOnDrain(){const e=this[g];if(!e.isPaused)e._socket.resume()}function receiverOnError(e){const t=this[g];if(t._socket[g]!==undefined){t._socket.removeListener("data",socketOnData);process.nextTick(resume,t._socket);t.close(e[y])}t.emit("error",e)}function receiverOnFinish(){this[g].emitClose()}function receiverOnMessage(e,t){this[g].emit("message",e,t)}function receiverOnPing(e){const t=this[g];t.pong(e,!t._isServer,E);t.emit("ping",e)}function receiverOnPong(e){this[g].emit("pong",e)}function resume(e){e.resume()}function socketOnClose(){const e=this[g];this.removeListener("close",socketOnClose);this.removeListener("data",socketOnData);this.removeListener("end",socketOnEnd);e._readyState=WebSocket.CLOSING;let t;if(!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null){e._receiver.write(t)}e._receiver.end();this[g]=undefined;clearTimeout(e._closeTimer);if(e._receiver._writableState.finished||e._receiver._writableState.errorEmitted){e.emitClose()}else{e._receiver.on("error",receiverOnFinish);e._receiver.on("finish",receiverOnFinish)}}function socketOnData(e){if(!this[g]._receiver.write(e)){this.pause()}}function socketOnEnd(){const e=this[g];e._readyState=WebSocket.CLOSING;e._receiver.end();this.end()}function socketOnError(){const e=this[g];this.removeListener("error",socketOnError);this.on("error",E);if(e){e._readyState=WebSocket.CLOSING;this.destroy()}}},815:function(module){module.exports=eval("require")("bufferutil")},646:function(module){module.exports=eval("require")("utf-8-validate")},300:function(e){"use strict";e.exports=require("buffer")},113:function(e){"use strict";e.exports=require("crypto")},361:function(e){"use strict";e.exports=require("events")},685:function(e){"use strict";e.exports=require("http")},687:function(e){"use strict";e.exports=require("https")},808:function(e){"use strict";e.exports=require("net")},781:function(e){"use strict";e.exports=require("stream")},404:function(e){"use strict";e.exports=require("tls")},310:function(e){"use strict";e.exports=require("url")},796:function(e){"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var r=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(821);module.exports=__webpack_exports__})();
|
package/compiled/ws/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","license":"MIT"}
|
|
1
|
+
{"name":"ws","version":"8.12.0","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","license":"MIT"}
|
package/dist/build.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/build.ts
|
|
@@ -31,7 +34,10 @@ var import_webpack = __toESM(require("../compiled/webpack"));
|
|
|
31
34
|
var import_config = require("./config/config");
|
|
32
35
|
var import_types = require("./types");
|
|
33
36
|
async function build(opts) {
|
|
34
|
-
const cacheDirectoryPath = (0, import_path.resolve)(
|
|
37
|
+
const cacheDirectoryPath = (0, import_path.resolve)(
|
|
38
|
+
opts.rootDir || opts.cwd,
|
|
39
|
+
opts.config.cacheDirectoryPath || "node_modules/.cache"
|
|
40
|
+
);
|
|
35
41
|
const webpackConfig = await (0, import_config.getConfig)({
|
|
36
42
|
cwd: opts.cwd,
|
|
37
43
|
rootDir: opts.rootDir,
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
}
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
17
|
+
mod
|
|
18
|
+
));
|
|
16
19
|
|
|
17
20
|
// src/cli.ts
|
|
18
21
|
var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/compressPlugin.ts
|