@ohos-ports/rsbuild-core 1.7.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/@jridgewell/remapping/index.d.ts +1 -0
- package/compiled/@jridgewell/remapping/index.js +1222 -0
- package/compiled/@jridgewell/remapping/license +19 -0
- package/compiled/@jridgewell/remapping/package.json +1 -0
- package/compiled/@jridgewell/trace-mapping/index.d.ts +194 -0
- package/compiled/@jridgewell/trace-mapping/index.js +1408 -0
- package/compiled/@jridgewell/trace-mapping/license +19 -0
- package/compiled/@jridgewell/trace-mapping/package.json +1 -0
- package/compiled/chokidar/index.d.ts +384 -0
- package/compiled/chokidar/index.js +1793 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +1240 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/index.js +371 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/index.d.ts +290 -0
- package/compiled/html-rspack-plugin/index.js +1602 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +166 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +319 -0
- package/compiled/http-proxy-middleware/index.js +5284 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +719 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/memfs/index.d.ts +1462 -0
- package/compiled/memfs/index.js +1 -0
- package/compiled/memfs/license +201 -0
- package/compiled/memfs/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +456 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/picocolors/index.d.ts +55 -0
- package/compiled/picocolors/index.js +108 -0
- package/compiled/picocolors/license +15 -0
- package/compiled/picocolors/package.json +1 -0
- package/compiled/postcss/index.js +1 -0
- package/compiled/postcss/lib/at-rule.d.ts +140 -0
- package/compiled/postcss/lib/comment.d.ts +68 -0
- package/compiled/postcss/lib/container.d.ts +483 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
- package/compiled/postcss/lib/declaration.d.ts +151 -0
- package/compiled/postcss/lib/document.d.ts +69 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +227 -0
- package/compiled/postcss/lib/lazy-result.d.ts +190 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +46 -0
- package/compiled/postcss/lib/node.d.ts +556 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +458 -0
- package/compiled/postcss/lib/previous-map.d.ts +81 -0
- package/compiled/postcss/lib/processor.d.ts +115 -0
- package/compiled/postcss/lib/result.d.ts +205 -0
- package/compiled/postcss/lib/root.d.ts +87 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/source-map-js.d.ts +4 -0
- package/compiled/postcss/lib/stringifier.d.ts +46 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +147 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +720 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rslog/index.d.ts +67 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/license +22 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-chain/types/index.d.ts +545 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/index.js +409 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +274 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +427 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/tinyglobby/index.d.ts +46 -0
- package/compiled/tinyglobby/index.js +2664 -0
- package/compiled/tinyglobby/license +21 -0
- package/compiled/tinyglobby/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
- package/compiled/webpack-bundle-analyzer/index.js +23 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/compiled/ws/index.d.ts +437 -0
- package/compiled/ws/index.js +3161 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/0~open.js +427 -0
- package/dist/0~range-parser.js +49 -0
- package/dist/0~range-parser.js.LICENSE.txt +6 -0
- package/dist/131.js +9305 -0
- package/dist/131.js.LICENSE.txt +26 -0
- package/dist/136.mjs +42 -0
- package/dist/2~open.cjs +436 -0
- package/dist/2~range-parser.cjs +52 -0
- package/dist/2~range-parser.cjs.LICENSE.txt +6 -0
- package/dist/client/59.js +22 -0
- package/dist/client/hmr.js +206 -0
- package/dist/client/overlay.js +203 -0
- package/dist/ignoreCssLoader.mjs +3 -0
- package/dist/index.cjs +9456 -0
- package/dist/index.cjs.LICENSE.txt +26 -0
- package/dist/index.js +1 -0
- package/dist/rslib-runtime.js +44 -0
- package/dist/transformLoader.mjs +1 -0
- package/dist/transformRawLoader.mjs +4 -0
- package/dist-types/cli/commands.d.ts +28 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/client/hmr.d.ts +3 -0
- package/dist-types/client/log.d.ts +13 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/configChain.d.ts +154 -0
- package/dist-types/constants.d.ts +52 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +5 -0
- package/dist-types/defaultConfig.d.ts +25 -0
- package/dist-types/helpers/compiler.d.ts +5 -0
- package/dist-types/helpers/exitHook.d.ts +3 -0
- package/dist-types/helpers/format.d.ts +2 -0
- package/dist-types/helpers/fs.d.ts +17 -0
- package/dist-types/helpers/index.d.ts +29 -0
- package/dist-types/helpers/path.d.ts +26 -0
- package/dist-types/helpers/stats.d.ts +18 -0
- package/dist-types/helpers/url.d.ts +11 -0
- package/dist-types/helpers/vendors.d.ts +29 -0
- package/dist-types/helpers/version.d.ts +7 -0
- package/dist-types/hooks.d.ts +44 -0
- package/dist-types/index.d.ts +22 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/inspectConfig.d.ts +35 -0
- package/dist-types/loadConfig.d.ts +60 -0
- package/dist-types/loadEnv.d.ts +63 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +3 -0
- package/dist-types/loader/transformLoader.d.ts +8 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +19 -0
- package/dist-types/mergeConfig.d.ts +2 -0
- package/dist-types/package.json +1 -0
- package/dist-types/pluginHelper.d.ts +12 -0
- package/dist-types/pluginManager.d.ts +21 -0
- package/dist-types/plugins/appIcon.d.ts +2 -0
- package/dist-types/plugins/asset.d.ts +3 -0
- package/dist-types/plugins/basic.d.ts +5 -0
- package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
- package/dist-types/plugins/cache.d.ts +2 -0
- package/dist-types/plugins/cleanOutput.d.ts +2 -0
- package/dist-types/plugins/css.d.ts +4 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/esm.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +6 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +6 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/dist-types/plugins/manifest.d.ts +2 -0
- package/dist-types/plugins/minimize.d.ts +10 -0
- package/dist-types/plugins/moduleFederation.d.ts +2 -0
- package/dist-types/plugins/moment.d.ts +2 -0
- package/dist-types/plugins/nodeAddons.d.ts +2 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/output.d.ts +2 -0
- package/dist-types/plugins/performance.d.ts +5 -0
- package/dist-types/plugins/progress.d.ts +2 -0
- package/dist-types/plugins/resolve.d.ts +2 -0
- package/dist-types/plugins/resourceHints.d.ts +2 -0
- package/dist-types/plugins/rsdoctor.d.ts +2 -0
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +2 -0
- package/dist-types/plugins/sourceMap.d.ts +2 -0
- package/dist-types/plugins/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +5 -0
- package/dist-types/plugins/target.d.ts +2 -0
- package/dist-types/plugins/wasm.d.ts +2 -0
- package/dist-types/provider/build.d.ts +4 -0
- package/dist-types/provider/createCompiler.d.ts +6 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +19 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/restart.d.ts +18 -0
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +38 -0
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +32 -0
- package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +28 -0
- package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +23 -0
- package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +22 -0
- package/dist-types/rspack.d.ts +2 -0
- package/dist-types/server/ansiHTML.d.ts +4 -0
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +12 -0
- package/dist-types/server/assets-middleware/index.d.ts +37 -0
- package/dist-types/server/assets-middleware/middleware.d.ts +2 -0
- package/dist-types/server/assets-middleware/parseTokenList.d.ts +1 -0
- package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
- package/dist-types/server/browserLogs.d.ts +9 -0
- package/dist-types/server/buildManager.d.ts +33 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/devMiddlewares.d.ts +21 -0
- package/dist-types/server/devServer.d.ts +79 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/gracefulShutdown.d.ts +10 -0
- package/dist-types/server/gzipMiddleware.d.ts +2 -0
- package/dist-types/server/helper.d.ts +91 -0
- package/dist-types/server/historyApiFallback.d.ts +2 -0
- package/dist-types/server/hmrFallback.d.ts +1 -0
- package/dist-types/server/httpServer.d.ts +7 -0
- package/dist-types/server/middlewares.d.ts +33 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/overlay.d.ts +3 -0
- package/dist-types/server/prodServer.d.ts +24 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +29 -0
- package/dist-types/server/runner/cjs.d.ts +10 -0
- package/dist-types/server/runner/esm.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +4 -0
- package/dist-types/server/runner/type.d.ts +42 -0
- package/dist-types/server/socketServer.d.ts +81 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1882 -0
- package/dist-types/types/context.d.ts +110 -0
- package/dist-types/types/hooks.d.ts +275 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +585 -0
- package/dist-types/types/rsbuild.d.ts +286 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +186 -0
- package/dist-types/types/utils.d.ts +19 -0
- package/package.json +114 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +349 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2015 Juho Vepsalainen
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"webpack-merge","author":"Juho Vepsalainen <bebraw@gmail.com>","version":"6.0.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -0,0 +1,437 @@
|
|
|
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 };
|