@rspack/dev-server 2.0.0-rc.1 → 2.0.0-rc.2

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 DELETED
@@ -1,74 +0,0 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack-dev-server
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
- */
10
- import type { DevServerClient, DevServerHeaders, DevServerHost, DevServerProxyConfigArray, DevServerStatic } from '@rspack/core';
11
- import type { NextHandleFunction } from 'connect-next';
12
- import type { BasicApplication, BasicServer, ClientConnection, Compiler, ConnectHistoryApiFallbackOptions, DevMiddlewareContext, DevMiddlewareOptions, DevServer, EXPECTED_ANY, FSWatcher, HTTPServer, LiteralUnion, Middleware, MultiCompiler, MultiStats, Open, Port, Request, Response, ServerConfiguration, ServerType, Socket, Stats, StatsOptions, WatchFiles, WatchOptions, WebSocketServerConfiguration, WebSocketServerImplementation } from './types.js';
13
- import type { ConnectApplication } from './types.js';
14
- export interface Configuration<A extends BasicApplication = ConnectApplication, S extends BasicServer = HTTPServer> {
15
- ipc?: boolean | string;
16
- host?: DevServerHost;
17
- port?: Port;
18
- hot?: boolean | 'only';
19
- liveReload?: boolean;
20
- devMiddleware?: DevMiddlewareOptions<Request, Response>;
21
- compress?: boolean;
22
- allowedHosts?: LiteralUnion<'auto' | 'all', string> | string[];
23
- historyApiFallback?: boolean | ConnectHistoryApiFallbackOptions;
24
- watchFiles?: string | string[] | WatchFiles | Array<string | WatchFiles>;
25
- static?: DevServerStatic;
26
- server?: ServerType<A, S> | ServerConfiguration<A, S>;
27
- app?: () => Promise<A>;
28
- webSocketServer?: boolean | LiteralUnion<'ws', string> | WebSocketServerConfiguration;
29
- proxy?: DevServerProxyConfigArray;
30
- open?: boolean | string | Open | Array<string | Open>;
31
- setupExitSignals?: boolean;
32
- client?: boolean | DevServerClient;
33
- headers?: DevServerHeaders | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => DevServerHeaders);
34
- onListening?: (devServer: Server<A, S>) => void;
35
- setupMiddlewares?: (middlewares: Middleware[], devServer: Server<A, S>) => Middleware[];
36
- }
37
- declare class Server<A extends BasicApplication = ConnectApplication, S extends BasicServer = HTTPServer> {
38
- #private;
39
- compiler: Compiler | MultiCompiler;
40
- logger: ReturnType<Compiler['getInfrastructureLogger']>;
41
- options: Configuration<A, S>;
42
- staticWatchers: FSWatcher[];
43
- listeners: {
44
- name: string | symbol;
45
- listener: (...args: EXPECTED_ANY[]) => void;
46
- }[];
47
- webSocketProxies: NextHandleFunction[];
48
- sockets: Socket[];
49
- currentHash: string | undefined;
50
- isTlsServer: boolean;
51
- webSocketServer: WebSocketServerImplementation | null | undefined;
52
- middleware: import('@rspack/dev-middleware').API<Request, Response> | undefined;
53
- server: S | undefined;
54
- app: A | undefined;
55
- stats: Stats | MultiStats | undefined;
56
- constructor(options: DevServer, compiler: Compiler | MultiCompiler);
57
- static get DEFAULT_STATS(): StatsOptions;
58
- static isAbsoluteURL(URL: string): boolean;
59
- static findIp(gatewayOrFamily: string, isInternal: boolean): string | undefined;
60
- static getHostname(hostname: DevServerHost): Promise<string>;
61
- static getFreePort(port: string, host: string): Promise<string | number>;
62
- static findCacheDir(): string;
63
- getClientEntry(): string;
64
- getClientHotEntry(): string | undefined;
65
- isValidHost(headers: Record<string, string | undefined>, headerToCheck: string, validateHost?: boolean): boolean;
66
- sendMessage(clients: ClientConnection[], type: string, data?: EXPECTED_ANY, params?: EXPECTED_ANY): void;
67
- watchFiles(watchPath: string | string[], watchOptions?: WatchOptions): Promise<void>;
68
- invalidate(callback?: import('@rspack/dev-middleware').Callback): void;
69
- start(): Promise<void>;
70
- startCallback(callback?: (err?: Error) => void): void;
71
- stop(): Promise<void>;
72
- stopCallback(callback?: (err?: Error) => void): void;
73
- }
74
- export { Server };
@@ -1,17 +0,0 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack-dev-server
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
- */
10
- import type { Server } from '../server.js';
11
- import type { ClientConnection } from '../types.js';
12
- declare class BaseServer {
13
- server: Server;
14
- clients: ClientConnection[];
15
- constructor(server: Server);
16
- }
17
- export default BaseServer;
@@ -1,17 +0,0 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack-dev-server
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack-dev-server/blob/main/LICENSE
9
- */
10
- import * as Ws from 'ws';
11
- import type { Server } from '../server.js';
12
- import BaseServer from './BaseServer.js';
13
- export declare class WebsocketServer extends BaseServer {
14
- static heartbeatInterval: number;
15
- implementation: Ws.WebSocketServer;
16
- constructor(server: Server);
17
- }
package/dist/types.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import type { Server as HTTPServer, IncomingMessage, ServerResponse } from 'node:http';
2
- import type { ServerOptions } from 'node:https';
3
- import type { DevServer, DevServerMiddlewareHandler, DevServerOpenOptions, DevServerStaticItem } from '@rspack/core';
4
- import type { FSWatcher, ChokidarOptions as WatchOptions } from 'chokidar';
5
- import type { Server as ConnectApplication, IncomingMessage as ConnectIncomingMessage, ErrorHandleFunction, HandleFunction, NextHandleFunction } from 'connect-next';
6
- export type { FSWatcher, WatchOptions, BasicServer, HTTPServer, ServerOptions, IncomingMessage, ConnectApplication, };
7
- export type { Socket } from 'node:net';
8
- export type { AddressInfo } from 'node:net';
9
- export type { NetworkInterfaceInfo } from 'node:os';
10
- export type { Compiler, DevServer, MultiCompiler, MultiStats, Stats, StatsCompilation, StatsOptions, } from '@rspack/core';
11
- export type EXPECTED_ANY = any;
12
- type BasicServer = import('node:net').Server | import('node:tls').Server;
13
- /** https://github.com/microsoft/TypeScript/issues/29729 */
14
- export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
15
- export type ConnectHistoryApiFallbackOptions = Exclude<NonNullable<DevServer['historyApiFallback']>, boolean>;
16
- export type Request<T extends BasicApplication = ConnectApplication> = T extends ConnectApplication ? ConnectIncomingMessage : IncomingMessage;
17
- export type Response = ServerResponse;
18
- export type DevMiddlewareOptions<T extends Request, U extends Response> = import('@rspack/dev-middleware').Options<T, U>;
19
- export type DevMiddlewareContext<T extends Request, U extends Response> = import('@rspack/dev-middleware').Context<T, U>;
20
- export type Port = number | LiteralUnion<'auto', string>;
21
- export interface WatchFiles {
22
- paths: string | string[];
23
- options?: WatchOptions & {
24
- aggregateTimeout?: number;
25
- poll?: number | boolean;
26
- };
27
- }
28
- export interface NormalizedStatic {
29
- directory: string;
30
- publicPath: string[];
31
- staticOptions: DevServerStaticItem['staticOptions'];
32
- watch: false | WatchOptions;
33
- }
34
- export type ServerType<A extends BasicApplication, S extends BasicServer> = LiteralUnion<'http' | 'https' | 'http2', string> | ((serverOptions: ServerOptions, application: A) => S);
35
- export interface ServerConfiguration<A extends BasicApplication = ConnectApplication, S extends BasicServer = HTTPServer> {
36
- type?: ServerType<A, S>;
37
- options?: ServerOptions;
38
- }
39
- export interface WebSocketServerConfiguration {
40
- type?: LiteralUnion<'ws', string> | (() => WebSocketServerConfiguration);
41
- options?: Record<string, EXPECTED_ANY>;
42
- }
43
- export type ClientConnection = import('ws').WebSocket & {
44
- isAlive?: boolean;
45
- };
46
- export type WebSocketServer = import('ws').WebSocketServer;
47
- export interface WebSocketServerImplementation {
48
- implementation: WebSocketServer;
49
- clients: ClientConnection[];
50
- }
51
- export type Open = DevServerOpenOptions & {
52
- target?: string | string[];
53
- };
54
- export interface NormalizedOpen {
55
- target: string;
56
- options: DevServerOpenOptions;
57
- }
58
- export interface MiddlewareObject {
59
- name?: string;
60
- path?: string;
61
- middleware: DevServerMiddlewareHandler | ErrorHandleFunction;
62
- }
63
- export type Middleware = MiddlewareObject | DevServerMiddlewareHandler | ErrorHandleFunction;
64
- export type OverlayMessageOptions = boolean | ((error: Error) => void);
65
- type UseFn = {
66
- (fn: NextHandleFunction): BasicApplication;
67
- (fn: HandleFunction): BasicApplication;
68
- (route: string, fn: NextHandleFunction): BasicApplication;
69
- (route: string, fn: HandleFunction): BasicApplication;
70
- };
71
- export type BasicApplication = {
72
- use: UseFn;
73
- };