-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtypes.ts
More file actions
147 lines (124 loc) · 3.76 KB
/
types.ts
File metadata and controls
147 lines (124 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import type {
Server as HTTPServer,
IncomingMessage,
ServerResponse,
} from 'node:http';
import type { ServerOptions } from 'node:https';
import type {
DevServer,
DevServerMiddlewareHandler,
DevServerOpenOptions,
DevServerStaticItem,
} from '@rspack/core';
import type { FSWatcher, ChokidarOptions as WatchOptions } from 'chokidar';
import type {
Server as ConnectApplication,
IncomingMessage as ConnectIncomingMessage,
ErrorHandleFunction,
HandleFunction,
NextHandleFunction,
} from 'connect-next';
import type { RequestHandler } from 'http-proxy-middleware';
export type {
FSWatcher,
WatchOptions,
RequestHandler,
BasicServer,
HTTPServer,
ServerOptions,
IncomingMessage,
ConnectApplication,
};
export type { IPv6 } from 'ipaddr.js';
export type { Socket } from 'node:net';
export type { AddressInfo } from 'node:net';
export type { NetworkInterfaceInfo } from 'node:os';
export type {
Compiler,
DevServer,
MultiCompiler,
MultiStats,
Stats,
StatsCompilation,
StatsOptions,
} from '@rspack/core';
export type EXPECTED_ANY = any;
type BasicServer = import('node:net').Server | import('node:tls').Server;
/** https://github.com/microsoft/TypeScript/issues/29729 */
export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
export type ConnectHistoryApiFallbackOptions = Exclude<
NonNullable<DevServer['historyApiFallback']>,
boolean
>;
// type-level helpers, inferred as util types
export type Request<T extends BasicApplication = ConnectApplication> =
T extends ConnectApplication ? ConnectIncomingMessage : IncomingMessage;
export type Response = ServerResponse;
export type DevMiddlewareOptions<
T extends Request,
U extends Response,
> = import('@rspack/dev-middleware').Options<T, U>;
export type DevMiddlewareContext<
T extends Request,
U extends Response,
> = import('@rspack/dev-middleware').Context<T, U>;
export type Port = number | LiteralUnion<'auto', string>;
export interface WatchFiles {
paths: string | string[];
options?: WatchOptions & {
aggregateTimeout?: number;
poll?: number | boolean;
};
}
export interface NormalizedStatic {
directory: string;
publicPath: string[];
staticOptions: DevServerStaticItem['staticOptions'];
watch: false | WatchOptions;
}
export type ServerType<A extends BasicApplication, S extends BasicServer> =
| LiteralUnion<'http' | 'https' | 'http2', string>
| ((serverOptions: ServerOptions, application: A) => S);
export interface ServerConfiguration<
A extends BasicApplication = ConnectApplication,
S extends BasicServer = HTTPServer,
> {
type?: ServerType<A, S>;
options?: ServerOptions;
}
export interface WebSocketServerConfiguration {
type?: LiteralUnion<'ws', string> | (() => WebSocketServerConfiguration);
options?: Record<string, EXPECTED_ANY>;
}
export type ClientConnection = import('ws').WebSocket & { isAlive?: boolean };
export type WebSocketServer = import('ws').WebSocketServer;
export interface WebSocketServerImplementation {
implementation: WebSocketServer;
clients: ClientConnection[];
}
export type Open = DevServerOpenOptions & {
target?: string | string[];
};
export interface NormalizedOpen {
target: string;
options: DevServerOpenOptions;
}
export interface MiddlewareObject {
name?: string;
path?: string;
middleware: DevServerMiddlewareHandler | ErrorHandleFunction;
}
export type Middleware =
| MiddlewareObject
| DevServerMiddlewareHandler
| ErrorHandleFunction;
export type OverlayMessageOptions = boolean | ((error: Error) => void);
type UseFn = {
(fn: NextHandleFunction): BasicApplication;
(fn: HandleFunction): BasicApplication;
(route: string, fn: NextHandleFunction): BasicApplication;
(route: string, fn: HandleFunction): BasicApplication;
};
export type BasicApplication = {
use: UseFn;
};