@rspack/dev-server 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.d.ts CHANGED
@@ -1,36 +1,119 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  /**
4
2
  * The following code is modified based on
5
- * https://github.com/webpack/webpack-dev-server/blob/b0f15ace0123c125d5870609ef4691c141a6d187/lib/Server.js
3
+ * https://github.com/webpack/webpack-dev-server
6
4
  *
7
5
  * MIT Licensed
8
6
  * Author Tobias Koppers @sokra
9
7
  * Copyright (c) JS Foundation and other contributors
10
- * https://github.com/webpack/webpack-dev-server/blob/b0f15ace0123c125d5870609ef4691c141a6d187/LICENSE
8
+ * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
11
9
  */
12
- import type { Server } from 'node:http';
13
- import type { Socket } from 'node:net';
14
- import type { Compiler, MultiCompiler } from '@rspack/core';
15
- import type { FSWatcher } from 'chokidar';
16
- import WebpackDevServer from 'webpack-dev-server';
17
- import type { DevServer, ResolvedDevServer } from './config';
18
- export declare class RspackDevServer extends WebpackDevServer {
19
- static getFreePort: (port: string, host: string) => Promise<any>;
20
- /**
21
- * resolved after `normalizedOptions`
22
- */
23
- /** @ts-ignore: types of path data of rspack is not compatible with webpack */
24
- options: ResolvedDevServer;
10
+ /// <reference types="express" />
11
+ /// <reference types="node" />
12
+ /// <reference types="connect-history-api-fallback" />
13
+ /// <reference types="node" />
14
+ import type { BasicApplication, ExpressApplication, HTTPServer, Response, Request, Host, Port, DevMiddlewareOptions, ConnectHistoryApiFallbackOptions, BonjourOptions, WatchFiles, Static, ServerType, ServerConfiguration, WebSocketServerConfiguration, ProxyConfigArray, Open, ClientConfiguration, Middleware, DevMiddlewareContext, Compiler, MultiCompiler, FSWatcher, EXPECTED_ANY, RequestHandler, Socket, Bonjour, WebSocketServerImplementation, Stats, MultiStats, DevServer, Schema, StatsOptions, WatchOptions, StatsCompilation, NextFunction, ClientConnection, Headers } from './types';
15
+ export interface Configuration<A extends BasicApplication = ExpressApplication, S extends HTTPServer = HTTPServer> {
16
+ ipc?: boolean | string;
17
+ host?: Host;
18
+ port?: Port;
19
+ hot?: boolean | 'only';
20
+ liveReload?: boolean;
21
+ devMiddleware?: DevMiddlewareOptions<Request, Response>;
22
+ compress?: boolean;
23
+ allowedHosts?: 'auto' | 'all' | string | string[];
24
+ historyApiFallback?: boolean | ConnectHistoryApiFallbackOptions;
25
+ bonjour?: boolean | Record<string, never> | BonjourOptions;
26
+ watchFiles?: string | string[] | WatchFiles | Array<string | WatchFiles>;
27
+ static?: boolean | string | Static | Array<string | Static>;
28
+ server?: ServerType<A, S> | ServerConfiguration<A, S>;
29
+ app?: () => Promise<A>;
30
+ webSocketServer?: boolean | 'sockjs' | 'ws' | string | WebSocketServerConfiguration;
31
+ proxy?: ProxyConfigArray;
32
+ open?: boolean | string | Open | Array<string | Open>;
33
+ setupExitSignals?: boolean;
34
+ client?: boolean | ClientConfiguration;
35
+ headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => Headers);
36
+ onListening?: (devServer: Server<A, S>) => void;
37
+ setupMiddlewares?: (middlewares: Middleware[], devServer: Server<A, S>) => Middleware[];
38
+ }
39
+ declare class Server<A extends BasicApplication = ExpressApplication, S extends import('http').Server = HTTPServer> {
40
+ compiler: Compiler | MultiCompiler;
41
+ logger: ReturnType<Compiler['getInfrastructureLogger']>;
42
+ options: Configuration<A, S>;
25
43
  staticWatchers: FSWatcher[];
44
+ listeners: {
45
+ name: string | symbol;
46
+ listener: (...args: EXPECTED_ANY[]) => void;
47
+ }[];
48
+ webSocketProxies: RequestHandler[];
26
49
  sockets: Socket[];
27
- server: Server;
28
- /** @ts-ignore */
29
- compiler: Compiler | MultiCompiler;
30
- webSocketServer: WebpackDevServer.WebSocketServerImplementation | undefined;
31
- static version: string;
50
+ currentHash: string | undefined;
51
+ isTlsServer: boolean;
52
+ bonjour: Bonjour | undefined;
53
+ webSocketServer: WebSocketServerImplementation | null | undefined;
54
+ middleware: import('webpack-dev-middleware').API<Request, Response> | undefined;
55
+ server: S | undefined;
56
+ app: A | undefined;
57
+ stats: Stats | MultiStats | undefined;
32
58
  constructor(options: DevServer, compiler: Compiler | MultiCompiler);
33
- initialize(): Promise<void>;
59
+ static get schema(): Schema;
60
+ static get DEFAULT_STATS(): StatsOptions;
61
+ static isAbsoluteURL(URL: string): boolean;
62
+ static findIp(gatewayOrFamily: string, isInternal: boolean): string | undefined;
63
+ static internalIP(family: 'v4' | 'v6'): Promise<string | undefined>;
64
+ static internalIPSync(family: 'v4' | 'v6'): string | undefined;
65
+ static getHostname(hostname: Host): Promise<string>;
66
+ static getFreePort(port: string, host: string): Promise<any>;
67
+ static findCacheDir(): string;
68
+ static isWebTarget(compiler: Compiler): boolean;
69
+ addAdditionalEntries(compiler: Compiler): void;
70
+ /**
71
+ * @private
72
+ * @returns {Compiler["options"]} compiler options
73
+ */
74
+ getCompilerOptions(): import("@rspack/core").RspackOptionsNormalized;
75
+ normalizeOptions(): Promise<void>;
76
+ /**
77
+ * @private
78
+ * @returns {string} client transport
79
+ */
80
+ getClientTransport(): string;
81
+ getServerTransport(): typeof import("./servers/SockJSServer") | typeof import("./servers/WebsocketServer") | undefined;
34
82
  getClientEntry(): string;
35
83
  getClientHotEntry(): string | undefined;
84
+ setupProgressPlugin(): void;
85
+ /**
86
+ * @private
87
+ * @returns {Promise<void>}
88
+ */
89
+ initialize(): Promise<void>;
90
+ setupApp(): Promise<void>;
91
+ getStats(statsObj: Stats | MultiStats): StatsCompilation;
92
+ setupHooks(): void;
93
+ setupWatchStaticFiles(): void;
94
+ setupWatchFiles(): void;
95
+ setupMiddlewares(): void;
96
+ /**
97
+ * @private
98
+ * @returns {Promise<void>}
99
+ */
100
+ createServer(): Promise<void>;
101
+ createWebSocketServer(): void;
102
+ openBrowser(defaultOpenTarget: string): Promise<void>;
103
+ runBonjour(): void;
104
+ stopBonjour(callback?: () => void): void;
105
+ logStatus(): Promise<void>;
106
+ setHeaders(req: Request, res: Response, next: NextFunction): void;
107
+ isHostAllowed(value: string): boolean;
108
+ isValidHost(headers: Record<string, string | undefined>, headerToCheck: string, validateHost?: boolean): boolean;
109
+ isSameOrigin(headers: Record<string, string | undefined>): boolean;
110
+ sendMessage(clients: ClientConnection[], type: string, data?: EXPECTED_ANY, params?: EXPECTED_ANY): void;
111
+ sendStats(clients: ClientConnection[], stats: StatsCompilation, force?: boolean): void;
112
+ watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): void;
113
+ invalidate(callback?: import('webpack-dev-middleware').Callback): void;
114
+ start(): Promise<void>;
115
+ startCallback(callback?: (err?: Error) => void): void;
116
+ stop(): Promise<void>;
117
+ stopCallback(callback?: (err?: Error) => void): void;
36
118
  }
119
+ export default Server;