@rsbuild/core 2.0.0-beta.6 → 2.0.0-beta.8
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/bin/rsbuild.js +13 -0
- package/compiled/chokidar/index.d.ts +197 -29
- package/compiled/chokidar/package.json +1 -1
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/jiti/dist/babel.cjs +60 -60
- package/compiled/jiti/dist/jiti.cjs +2 -2
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/postcss/lib/comment.d.ts +1 -1
- package/compiled/postcss/lib/container.d.ts +1 -1
- package/compiled/postcss/lib/css-syntax-error.d.ts +1 -1
- package/compiled/postcss/lib/declaration.d.ts +1 -1
- package/compiled/postcss/lib/document.d.ts +1 -1
- package/compiled/postcss/lib/input.d.ts +1 -1
- package/compiled/postcss/lib/lazy-result.d.ts +1 -1
- package/compiled/postcss/lib/no-work-result.d.ts +1 -1
- package/compiled/postcss/lib/node.d.ts +1 -1
- package/compiled/postcss/lib/previous-map.d.ts +1 -1
- package/compiled/postcss/lib/processor.d.ts +1 -1
- package/compiled/postcss/lib/result.d.ts +1 -1
- package/compiled/postcss/lib/root.d.ts +1 -1
- package/compiled/postcss/lib/rule.d.ts +1 -1
- package/compiled/postcss/lib/stringifier.d.ts +1 -1
- package/compiled/postcss/lib/warning.d.ts +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +17 -1
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +0 -2
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/style-loader/index.js +37 -94
- package/compiled/style-loader/package.json +1 -1
- package/dist/{131.js → 958.js} +1125 -1083
- package/dist/chokidar.js +59 -57
- package/dist/client/hmr.js +2 -2
- package/dist/client/overlay.js +1 -1
- package/dist/connect-next.js +268 -0
- package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
- package/dist/cors.js +2 -2
- package/dist/http-proxy-middleware.js +57 -552
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +31 -15
- package/dist/manifest-plugin.js +18 -18
- package/dist/memfs.js +217 -756
- package/dist/{710.js → mrmime.js} +2 -1
- package/dist/open.js +36 -34
- package/dist/range-parser.js +2 -2
- package/dist/remapping.js +2 -2
- package/dist/rslib-runtime.js +3 -3
- package/dist/sirv.js +14 -14
- package/dist/src.js +510 -0
- package/dist/tinyglobby.js +114 -69
- package/dist/transformLoader.mjs +38 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist/ws.js +1541 -0
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/vendors.d.ts +0 -1
- package/dist-types/server/runner/asModule.d.ts +1 -1
- package/dist-types/server/socketServer.d.ts +1 -1
- package/dist-types/types/config.d.ts +4 -4
- package/dist-types/types/thirdParty.d.ts +14 -5
- package/package.json +13 -14
- package/compiled/chokidar/handler.d.ts +0 -90
- package/compiled/ws/index.d.ts +0 -437
- package/compiled/ws/index.js +0 -3166
- package/compiled/ws/license +0 -20
- package/compiled/ws/package.json +0 -1
- package/dist/397.js +0 -11
- package/dist/7.js +0 -1
- package/dist/712.js +0 -15
- package/dist/743.js +0 -7
- package/dist/88.js +0 -40
- package/dist/connect.js +0 -570
- package/dist-types/helpers/color.d.ts +0 -4
- /package/dist/{131.js.LICENSE.txt → 958.js.LICENSE.txt} +0 -0
- /package/dist/client/{59.js → 797.js} +0 -0
- /package/dist/{31.js → trace-mapping.js} +0 -0
package/compiled/ws/index.d.ts
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { ClientRequestArgs, IncomingMessage, ClientRequest, OutgoingHttpHeaders, Agent, Server } from 'http';
|
|
4
|
-
import { Server as Server$1 } from 'https';
|
|
5
|
-
import { createConnection } from 'net';
|
|
6
|
-
import { Duplex, DuplexOptions } from 'stream';
|
|
7
|
-
import { SecureContextOptions } from 'tls';
|
|
8
|
-
import { URL } from 'url';
|
|
9
|
-
import { ZlibOptions } from 'zlib';
|
|
10
|
-
|
|
11
|
-
// can not get all overload of BufferConstructor['from'], need to copy all it's first arguments here
|
|
12
|
-
// https://github.com/microsoft/TypeScript/issues/32164
|
|
13
|
-
type BufferLike =
|
|
14
|
-
| string
|
|
15
|
-
| Buffer
|
|
16
|
-
| DataView
|
|
17
|
-
| number
|
|
18
|
-
| ArrayBufferView
|
|
19
|
-
| Uint8Array
|
|
20
|
-
| ArrayBuffer
|
|
21
|
-
| SharedArrayBuffer
|
|
22
|
-
| Blob
|
|
23
|
-
| readonly any[]
|
|
24
|
-
| readonly number[]
|
|
25
|
-
| { valueOf(): ArrayBuffer }
|
|
26
|
-
| { valueOf(): SharedArrayBuffer }
|
|
27
|
-
| { valueOf(): Uint8Array }
|
|
28
|
-
| { valueOf(): readonly number[] }
|
|
29
|
-
| { valueOf(): string }
|
|
30
|
-
| { [Symbol.toPrimitive](hint: string): string };
|
|
31
|
-
|
|
32
|
-
declare const WebSocketAlias: typeof WebSocket;
|
|
33
|
-
interface WebSocketAlias extends WebSocket {}
|
|
34
|
-
// WebSocket socket.
|
|
35
|
-
declare class WebSocket extends EventEmitter {
|
|
36
|
-
/** The connection is not yet open. */
|
|
37
|
-
static readonly CONNECTING: 0;
|
|
38
|
-
/** The connection is open and ready to communicate. */
|
|
39
|
-
static readonly OPEN: 1;
|
|
40
|
-
/** The connection is in the process of closing. */
|
|
41
|
-
static readonly CLOSING: 2;
|
|
42
|
-
/** The connection is closed. */
|
|
43
|
-
static readonly CLOSED: 3;
|
|
44
|
-
|
|
45
|
-
binaryType: "nodebuffer" | "arraybuffer" | "fragments";
|
|
46
|
-
readonly bufferedAmount: number;
|
|
47
|
-
readonly extensions: string;
|
|
48
|
-
/** Indicates whether the websocket is paused */
|
|
49
|
-
readonly isPaused: boolean;
|
|
50
|
-
readonly protocol: string;
|
|
51
|
-
/** The current state of the connection */
|
|
52
|
-
readonly readyState:
|
|
53
|
-
| typeof WebSocket.CONNECTING
|
|
54
|
-
| typeof WebSocket.OPEN
|
|
55
|
-
| typeof WebSocket.CLOSING
|
|
56
|
-
| typeof WebSocket.CLOSED;
|
|
57
|
-
readonly url: string;
|
|
58
|
-
|
|
59
|
-
/** The connection is not yet open. */
|
|
60
|
-
readonly CONNECTING: 0;
|
|
61
|
-
/** The connection is open and ready to communicate. */
|
|
62
|
-
readonly OPEN: 1;
|
|
63
|
-
/** The connection is in the process of closing. */
|
|
64
|
-
readonly CLOSING: 2;
|
|
65
|
-
/** The connection is closed. */
|
|
66
|
-
readonly CLOSED: 3;
|
|
67
|
-
|
|
68
|
-
onopen: ((event: WebSocket.Event) => void) | null;
|
|
69
|
-
onerror: ((event: WebSocket.ErrorEvent) => void) | null;
|
|
70
|
-
onclose: ((event: WebSocket.CloseEvent) => void) | null;
|
|
71
|
-
onmessage: ((event: WebSocket.MessageEvent) => void) | null;
|
|
72
|
-
|
|
73
|
-
constructor(address: null);
|
|
74
|
-
constructor(address: string | URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
|
|
75
|
-
constructor(
|
|
76
|
-
address: string | URL,
|
|
77
|
-
protocols?: string | string[],
|
|
78
|
-
options?: WebSocket.ClientOptions | ClientRequestArgs,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
close(code?: number, data?: string | Buffer): void;
|
|
82
|
-
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
|
|
83
|
-
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
|
|
84
|
-
// https://github.com/websockets/ws/issues/2076#issuecomment-1250354722
|
|
85
|
-
send(data: BufferLike, cb?: (err?: Error) => void): void;
|
|
86
|
-
send(
|
|
87
|
-
data: BufferLike,
|
|
88
|
-
options: {
|
|
89
|
-
mask?: boolean | undefined;
|
|
90
|
-
binary?: boolean | undefined;
|
|
91
|
-
compress?: boolean | undefined;
|
|
92
|
-
fin?: boolean | undefined;
|
|
93
|
-
},
|
|
94
|
-
cb?: (err?: Error) => void,
|
|
95
|
-
): void;
|
|
96
|
-
terminate(): void;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Pause the websocket causing it to stop emitting events. Some events can still be
|
|
100
|
-
* emitted after this is called, until all buffered data is consumed. This method
|
|
101
|
-
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
|
102
|
-
*/
|
|
103
|
-
pause(): void;
|
|
104
|
-
/**
|
|
105
|
-
* Make a paused socket resume emitting events. This method is a noop if the ready
|
|
106
|
-
* state is `CONNECTING` or `CLOSED`.
|
|
107
|
-
*/
|
|
108
|
-
resume(): void;
|
|
109
|
-
|
|
110
|
-
// HTML5 WebSocket events
|
|
111
|
-
addEventListener<K extends keyof WebSocket.WebSocketEventMap>(
|
|
112
|
-
type: K,
|
|
113
|
-
listener:
|
|
114
|
-
| ((event: WebSocket.WebSocketEventMap[K]) => void)
|
|
115
|
-
| { handleEvent(event: WebSocket.WebSocketEventMap[K]): void },
|
|
116
|
-
options?: WebSocket.EventListenerOptions,
|
|
117
|
-
): void;
|
|
118
|
-
removeEventListener<K extends keyof WebSocket.WebSocketEventMap>(
|
|
119
|
-
type: K,
|
|
120
|
-
listener:
|
|
121
|
-
| ((event: WebSocket.WebSocketEventMap[K]) => void)
|
|
122
|
-
| { handleEvent(event: WebSocket.WebSocketEventMap[K]): void },
|
|
123
|
-
): void;
|
|
124
|
-
|
|
125
|
-
// Events
|
|
126
|
-
on(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
|
|
127
|
-
on(event: "error", listener: (this: WebSocket, error: Error) => void): this;
|
|
128
|
-
on(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
|
|
129
|
-
on(event: "message", listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
|
|
130
|
-
on(event: "open", listener: (this: WebSocket) => void): this;
|
|
131
|
-
on(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
|
|
132
|
-
on(event: "redirect", listener: (this: WebSocket, url: string, request: ClientRequest) => void): this;
|
|
133
|
-
on(
|
|
134
|
-
event: "unexpected-response",
|
|
135
|
-
listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void,
|
|
136
|
-
): this;
|
|
137
|
-
on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
|
|
138
|
-
|
|
139
|
-
once(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
|
|
140
|
-
once(event: "error", listener: (this: WebSocket, error: Error) => void): this;
|
|
141
|
-
once(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
|
|
142
|
-
once(event: "message", listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
|
|
143
|
-
once(event: "open", listener: (this: WebSocket) => void): this;
|
|
144
|
-
once(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
|
|
145
|
-
once(event: "redirect", listener: (this: WebSocket, url: string, request: ClientRequest) => void): this;
|
|
146
|
-
once(
|
|
147
|
-
event: "unexpected-response",
|
|
148
|
-
listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void,
|
|
149
|
-
): this;
|
|
150
|
-
once(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
|
|
151
|
-
|
|
152
|
-
off(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
|
|
153
|
-
off(event: "error", listener: (this: WebSocket, error: Error) => void): this;
|
|
154
|
-
off(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
|
|
155
|
-
off(event: "message", listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
|
|
156
|
-
off(event: "open", listener: (this: WebSocket) => void): this;
|
|
157
|
-
off(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
|
|
158
|
-
off(event: "redirect", listener: (this: WebSocket, url: string, request: ClientRequest) => void): this;
|
|
159
|
-
off(
|
|
160
|
-
event: "unexpected-response",
|
|
161
|
-
listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void,
|
|
162
|
-
): this;
|
|
163
|
-
off(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
|
|
164
|
-
|
|
165
|
-
addListener(event: "close", listener: (code: number, reason: Buffer) => void): this;
|
|
166
|
-
addListener(event: "error", listener: (error: Error) => void): this;
|
|
167
|
-
addListener(event: "upgrade", listener: (request: IncomingMessage) => void): this;
|
|
168
|
-
addListener(event: "message", listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
|
|
169
|
-
addListener(event: "open", listener: () => void): this;
|
|
170
|
-
addListener(event: "ping" | "pong", listener: (data: Buffer) => void): this;
|
|
171
|
-
addListener(event: "redirect", listener: (url: string, request: ClientRequest) => void): this;
|
|
172
|
-
addListener(
|
|
173
|
-
event: "unexpected-response",
|
|
174
|
-
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
|
175
|
-
): this;
|
|
176
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
177
|
-
|
|
178
|
-
removeListener(event: "close", listener: (code: number, reason: Buffer) => void): this;
|
|
179
|
-
removeListener(event: "error", listener: (error: Error) => void): this;
|
|
180
|
-
removeListener(event: "upgrade", listener: (request: IncomingMessage) => void): this;
|
|
181
|
-
removeListener(event: "message", listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
|
|
182
|
-
removeListener(event: "open", listener: () => void): this;
|
|
183
|
-
removeListener(event: "ping" | "pong", listener: (data: Buffer) => void): this;
|
|
184
|
-
removeListener(event: "redirect", listener: (url: string, request: ClientRequest) => void): this;
|
|
185
|
-
removeListener(
|
|
186
|
-
event: "unexpected-response",
|
|
187
|
-
listener: (request: ClientRequest, response: IncomingMessage) => void,
|
|
188
|
-
): this;
|
|
189
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
190
|
-
}
|
|
191
|
-
// eslint-disable-line @typescript-eslint/no-empty-interface
|
|
192
|
-
|
|
193
|
-
declare namespace WebSocket {
|
|
194
|
-
/**
|
|
195
|
-
* Data represents the raw message payload received over the WebSocket.
|
|
196
|
-
*/
|
|
197
|
-
type RawData = Buffer | ArrayBuffer | Buffer[];
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Data represents the message payload received over the WebSocket.
|
|
201
|
-
*/
|
|
202
|
-
type Data = string | Buffer | ArrayBuffer | Buffer[];
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* CertMeta represents the accepted types for certificate & key data.
|
|
206
|
-
*/
|
|
207
|
-
type CertMeta = string | string[] | Buffer | Buffer[];
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
|
211
|
-
* incoming message. The return value (boolean) of the function determines
|
|
212
|
-
* whether or not to accept the handshake.
|
|
213
|
-
*/
|
|
214
|
-
type VerifyClientCallbackSync<Request extends IncomingMessage = IncomingMessage> = (info: {
|
|
215
|
-
origin: string;
|
|
216
|
-
secure: boolean;
|
|
217
|
-
req: Request;
|
|
218
|
-
}) => boolean;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
|
|
222
|
-
* incoming message. The return value (boolean) of the function determines
|
|
223
|
-
* whether or not to accept the handshake.
|
|
224
|
-
*/
|
|
225
|
-
type VerifyClientCallbackAsync<Request extends IncomingMessage = IncomingMessage> = (
|
|
226
|
-
info: { origin: string; secure: boolean; req: Request },
|
|
227
|
-
callback: (res: boolean, code?: number, message?: string, headers?: OutgoingHttpHeaders) => void,
|
|
228
|
-
) => void;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* FinishRequestCallback is a callback for last minute customization of the
|
|
232
|
-
* headers. If finishRequest is set, then it has the responsibility to call
|
|
233
|
-
* request.end() once it is done setting request headers.
|
|
234
|
-
*/
|
|
235
|
-
type FinishRequestCallback = (request: ClientRequest, websocket: WebSocket) => void;
|
|
236
|
-
|
|
237
|
-
interface ClientOptions extends SecureContextOptions {
|
|
238
|
-
protocol?: string | undefined;
|
|
239
|
-
followRedirects?: boolean | undefined;
|
|
240
|
-
generateMask?(mask: Buffer): void;
|
|
241
|
-
handshakeTimeout?: number | undefined;
|
|
242
|
-
maxRedirects?: number | undefined;
|
|
243
|
-
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
244
|
-
localAddress?: string | undefined;
|
|
245
|
-
protocolVersion?: number | undefined;
|
|
246
|
-
headers?: { [key: string]: string } | undefined;
|
|
247
|
-
origin?: string | undefined;
|
|
248
|
-
agent?: Agent | undefined;
|
|
249
|
-
host?: string | undefined;
|
|
250
|
-
family?: number | undefined;
|
|
251
|
-
checkServerIdentity?(servername: string, cert: CertMeta): boolean;
|
|
252
|
-
rejectUnauthorized?: boolean | undefined;
|
|
253
|
-
allowSynchronousEvents?: boolean | undefined;
|
|
254
|
-
autoPong?: boolean | undefined;
|
|
255
|
-
maxPayload?: number | undefined;
|
|
256
|
-
skipUTF8Validation?: boolean | undefined;
|
|
257
|
-
createConnection?: typeof createConnection | undefined;
|
|
258
|
-
finishRequest?: FinishRequestCallback | undefined;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
interface PerMessageDeflateOptions {
|
|
262
|
-
serverNoContextTakeover?: boolean | undefined;
|
|
263
|
-
clientNoContextTakeover?: boolean | undefined;
|
|
264
|
-
serverMaxWindowBits?: number | undefined;
|
|
265
|
-
clientMaxWindowBits?: number | undefined;
|
|
266
|
-
zlibDeflateOptions?: {
|
|
267
|
-
flush?: number | undefined;
|
|
268
|
-
finishFlush?: number | undefined;
|
|
269
|
-
chunkSize?: number | undefined;
|
|
270
|
-
windowBits?: number | undefined;
|
|
271
|
-
level?: number | undefined;
|
|
272
|
-
memLevel?: number | undefined;
|
|
273
|
-
strategy?: number | undefined;
|
|
274
|
-
dictionary?: Buffer | Buffer[] | DataView | undefined;
|
|
275
|
-
info?: boolean | undefined;
|
|
276
|
-
} | undefined;
|
|
277
|
-
zlibInflateOptions?: ZlibOptions | undefined;
|
|
278
|
-
threshold?: number | undefined;
|
|
279
|
-
concurrencyLimit?: number | undefined;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
interface Event {
|
|
283
|
-
type: string;
|
|
284
|
-
target: WebSocket;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
interface ErrorEvent {
|
|
288
|
-
error: any;
|
|
289
|
-
message: string;
|
|
290
|
-
type: string;
|
|
291
|
-
target: WebSocket;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
interface CloseEvent {
|
|
295
|
-
wasClean: boolean;
|
|
296
|
-
code: number;
|
|
297
|
-
reason: string;
|
|
298
|
-
type: string;
|
|
299
|
-
target: WebSocket;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
interface MessageEvent {
|
|
303
|
-
data: Data;
|
|
304
|
-
type: string;
|
|
305
|
-
target: WebSocket;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
interface WebSocketEventMap {
|
|
309
|
-
open: Event;
|
|
310
|
-
error: ErrorEvent;
|
|
311
|
-
close: CloseEvent;
|
|
312
|
-
message: MessageEvent;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
interface EventListenerOptions {
|
|
316
|
-
once?: boolean | undefined;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
interface ServerOptions<
|
|
320
|
-
U extends typeof WebSocket.WebSocket = typeof WebSocket.WebSocket,
|
|
321
|
-
V extends typeof IncomingMessage = typeof IncomingMessage,
|
|
322
|
-
> {
|
|
323
|
-
host?: string | undefined;
|
|
324
|
-
port?: number | undefined;
|
|
325
|
-
backlog?: number | undefined;
|
|
326
|
-
server?: Server<V> | Server$1<V> | undefined;
|
|
327
|
-
verifyClient?:
|
|
328
|
-
| VerifyClientCallbackAsync<InstanceType<V>>
|
|
329
|
-
| VerifyClientCallbackSync<InstanceType<V>>
|
|
330
|
-
| undefined;
|
|
331
|
-
handleProtocols?: (protocols: Set<string>, request: InstanceType<V>) => string | false;
|
|
332
|
-
path?: string | undefined;
|
|
333
|
-
noServer?: boolean | undefined;
|
|
334
|
-
allowSynchronousEvents?: boolean | undefined;
|
|
335
|
-
autoPong?: boolean | undefined;
|
|
336
|
-
clientTracking?: boolean | undefined;
|
|
337
|
-
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
338
|
-
maxPayload?: number | undefined;
|
|
339
|
-
skipUTF8Validation?: boolean | undefined;
|
|
340
|
-
WebSocket?: U | undefined;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
interface AddressInfo {
|
|
344
|
-
address: string;
|
|
345
|
-
family: string;
|
|
346
|
-
port: number;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// WebSocket Server
|
|
350
|
-
class Server<
|
|
351
|
-
T extends typeof WebSocket.WebSocket = typeof WebSocket.WebSocket,
|
|
352
|
-
U extends typeof IncomingMessage = typeof IncomingMessage,
|
|
353
|
-
> extends EventEmitter {
|
|
354
|
-
options: ServerOptions<T, U>;
|
|
355
|
-
path: string;
|
|
356
|
-
clients: Set<InstanceType<T>>;
|
|
357
|
-
|
|
358
|
-
constructor(options?: ServerOptions<T, U>, callback?: () => void);
|
|
359
|
-
|
|
360
|
-
address(): AddressInfo | string | null;
|
|
361
|
-
close(cb?: (err?: Error) => void): void;
|
|
362
|
-
handleUpgrade(
|
|
363
|
-
request: InstanceType<U>,
|
|
364
|
-
socket: Duplex,
|
|
365
|
-
upgradeHead: Buffer,
|
|
366
|
-
callback: (client: InstanceType<T>, request: InstanceType<U>) => void,
|
|
367
|
-
): void;
|
|
368
|
-
shouldHandle(request: InstanceType<U>): boolean | Promise<boolean>;
|
|
369
|
-
|
|
370
|
-
// Events
|
|
371
|
-
on(
|
|
372
|
-
event: "connection",
|
|
373
|
-
cb: (this: Server<T>, websocket: InstanceType<T>, request: InstanceType<U>) => void,
|
|
374
|
-
): this;
|
|
375
|
-
on(event: "error", cb: (this: Server<T>, error: Error) => void): this;
|
|
376
|
-
on(event: "headers", cb: (this: Server<T>, headers: string[], request: InstanceType<U>) => void): this;
|
|
377
|
-
on(event: "close" | "listening", cb: (this: Server<T>) => void): this;
|
|
378
|
-
on(
|
|
379
|
-
event: "wsClientError",
|
|
380
|
-
cb: (this: Server<T>, error: Error, socket: Duplex, request: InstanceType<U>) => void,
|
|
381
|
-
): this;
|
|
382
|
-
on(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
|
|
383
|
-
|
|
384
|
-
once(
|
|
385
|
-
event: "connection",
|
|
386
|
-
cb: (this: Server<T>, websocket: InstanceType<T>, request: InstanceType<U>) => void,
|
|
387
|
-
): this;
|
|
388
|
-
once(event: "error", cb: (this: Server<T>, error: Error) => void): this;
|
|
389
|
-
once(event: "headers", cb: (this: Server<T>, headers: string[], request: InstanceType<U>) => void): this;
|
|
390
|
-
once(event: "close" | "listening", cb: (this: Server<T>) => void): this;
|
|
391
|
-
once(
|
|
392
|
-
event: "wsClientError",
|
|
393
|
-
cb: (this: Server<T>, error: Error, socket: Duplex, request: InstanceType<U>) => void,
|
|
394
|
-
): this;
|
|
395
|
-
once(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
|
|
396
|
-
|
|
397
|
-
off(
|
|
398
|
-
event: "connection",
|
|
399
|
-
cb: (this: Server<T>, socket: InstanceType<T>, request: InstanceType<U>) => void,
|
|
400
|
-
): this;
|
|
401
|
-
off(event: "error", cb: (this: Server<T>, error: Error) => void): this;
|
|
402
|
-
off(event: "headers", cb: (this: Server<T>, headers: string[], request: InstanceType<U>) => void): this;
|
|
403
|
-
off(event: "close" | "listening", cb: (this: Server<T>) => void): this;
|
|
404
|
-
off(
|
|
405
|
-
event: "wsClientError",
|
|
406
|
-
cb: (this: Server<T>, error: Error, socket: Duplex, request: InstanceType<U>) => void,
|
|
407
|
-
): this;
|
|
408
|
-
off(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
|
|
409
|
-
|
|
410
|
-
addListener(event: "connection", cb: (websocket: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
411
|
-
addListener(event: "error", cb: (error: Error) => void): this;
|
|
412
|
-
addListener(event: "headers", cb: (headers: string[], request: InstanceType<U>) => void): this;
|
|
413
|
-
addListener(event: "close" | "listening", cb: () => void): this;
|
|
414
|
-
addListener(event: "wsClientError", cb: (error: Error, socket: Duplex, request: InstanceType<U>) => void): this;
|
|
415
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
416
|
-
|
|
417
|
-
removeListener(event: "connection", cb: (websocket: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
418
|
-
removeListener(event: "error", cb: (error: Error) => void): this;
|
|
419
|
-
removeListener(event: "headers", cb: (headers: string[], request: InstanceType<U>) => void): this;
|
|
420
|
-
removeListener(event: "close" | "listening", cb: () => void): this;
|
|
421
|
-
removeListener(
|
|
422
|
-
event: "wsClientError",
|
|
423
|
-
cb: (error: Error, socket: Duplex, request: InstanceType<U>) => void,
|
|
424
|
-
): this;
|
|
425
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const WebSocketServer: typeof Server;
|
|
429
|
-
interface WebSocketServer extends Server {} // eslint-disable-line @typescript-eslint/no-empty-interface
|
|
430
|
-
const WebSocket: typeof WebSocketAlias;
|
|
431
|
-
interface WebSocket extends WebSocketAlias {} // eslint-disable-line @typescript-eslint/no-empty-interface
|
|
432
|
-
|
|
433
|
-
// WebSocket stream
|
|
434
|
-
function createWebSocketStream(websocket: WebSocket, options?: DuplexOptions): Duplex;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export { WebSocket as default };
|