elit 3.0.1 → 3.0.3
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/build.d.ts +4 -12
- package/dist/build.d.ts.map +1 -0
- package/dist/chokidar.d.ts +7 -9
- package/dist/chokidar.d.ts.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +250 -21
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/dom.d.ts +7 -14
- package/dist/dom.d.ts.map +1 -0
- package/dist/el.d.ts +19 -191
- package/dist/el.d.ts.map +1 -0
- package/dist/fs.d.ts +35 -35
- package/dist/fs.d.ts.map +1 -0
- package/dist/hmr.d.ts +3 -3
- package/dist/hmr.d.ts.map +1 -0
- package/dist/http.d.ts +20 -22
- package/dist/http.d.ts.map +1 -0
- package/dist/https.d.ts +12 -15
- package/dist/https.d.ts.map +1 -0
- package/dist/index.d.ts +10 -629
- package/dist/index.d.ts.map +1 -0
- package/dist/mime-types.d.ts +9 -9
- package/dist/mime-types.d.ts.map +1 -0
- package/dist/path.d.ts +22 -19
- package/dist/path.d.ts.map +1 -0
- package/dist/router.d.ts +10 -17
- package/dist/router.d.ts.map +1 -0
- package/dist/runtime.d.ts +5 -6
- package/dist/runtime.d.ts.map +1 -0
- package/dist/server.d.ts +109 -7
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +712 -137
- package/dist/server.mjs +711 -137
- package/dist/state.d.ts +21 -27
- package/dist/state.d.ts.map +1 -0
- package/dist/style.d.ts +14 -55
- package/dist/style.d.ts.map +1 -0
- package/dist/types.d.ts +26 -240
- package/dist/types.d.ts.map +1 -0
- package/dist/ws.d.ts +14 -17
- package/dist/ws.d.ts.map +1 -0
- package/dist/wss.d.ts +16 -16
- package/dist/wss.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/build.ts +337 -0
- package/src/chokidar.ts +401 -0
- package/src/cli.ts +638 -0
- package/src/config.ts +205 -0
- package/src/dom.ts +817 -0
- package/src/el.ts +164 -0
- package/src/fs.ts +727 -0
- package/src/hmr.ts +137 -0
- package/src/http.ts +775 -0
- package/src/https.ts +411 -0
- package/src/index.ts +14 -0
- package/src/mime-types.ts +222 -0
- package/src/path.ts +493 -0
- package/src/router.ts +237 -0
- package/src/runtime.ts +97 -0
- package/src/server.ts +1593 -0
- package/src/state.ts +468 -0
- package/src/style.ts +524 -0
- package/{dist/types-Du6kfwTm.d.ts → src/types.ts} +58 -141
- package/src/ws.ts +506 -0
- package/src/wss.ts +241 -0
- package/dist/build.d.mts +0 -20
- package/dist/chokidar.d.mts +0 -134
- package/dist/dom.d.mts +0 -87
- package/dist/el.d.mts +0 -207
- package/dist/fs.d.mts +0 -255
- package/dist/hmr.d.mts +0 -38
- package/dist/http.d.mts +0 -163
- package/dist/https.d.mts +0 -108
- package/dist/index.d.mts +0 -629
- package/dist/mime-types.d.mts +0 -48
- package/dist/path.d.mts +0 -163
- package/dist/router.d.mts +0 -47
- package/dist/runtime.d.mts +0 -97
- package/dist/server.d.mts +0 -7
- package/dist/state.d.mts +0 -111
- package/dist/style.d.mts +0 -159
- package/dist/types-C0nGi6MX.d.mts +0 -346
- package/dist/types.d.mts +0 -452
- package/dist/ws.d.mts +0 -195
- package/dist/wss.d.mts +0 -108
package/dist/types.d.mts
DELETED
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { EventEmitter as EventEmitter$1 } from 'events';
|
|
3
|
-
import { Server } from 'http';
|
|
4
|
-
import { WebSocketServer } from 'ws';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* HTTP module with unified API across runtimes
|
|
8
|
-
* Ultra-optimized for maximum performance across Node.js, Bun, and Deno
|
|
9
|
-
*
|
|
10
|
-
* Performance optimizations:
|
|
11
|
-
* - Bun fast path: Zero class instantiation (object literals only)
|
|
12
|
-
* - Eliminated EventEmitter overhead for Bun/Deno
|
|
13
|
-
* - Zero-copy headers conversion
|
|
14
|
-
* - Inline response creation
|
|
15
|
-
* - Reduced object allocations
|
|
16
|
-
* - Direct closure capture (no resolver indirection)
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* HTTP Headers type
|
|
21
|
-
*/
|
|
22
|
-
type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
|
|
23
|
-
type OutgoingHttpHeaders = Record<string, string | string[] | number>;
|
|
24
|
-
/**
|
|
25
|
-
* IncomingMessage - Ultra-optimized for zero-copy operations
|
|
26
|
-
*/
|
|
27
|
-
declare class IncomingMessage extends EventEmitter {
|
|
28
|
-
method: string;
|
|
29
|
-
url: string;
|
|
30
|
-
headers: IncomingHttpHeaders;
|
|
31
|
-
statusCode?: number;
|
|
32
|
-
statusMessage?: string;
|
|
33
|
-
httpVersion: string;
|
|
34
|
-
rawHeaders: string[];
|
|
35
|
-
socket: any;
|
|
36
|
-
private _req;
|
|
37
|
-
constructor(req: any);
|
|
38
|
-
text(): Promise<string>;
|
|
39
|
-
json(): Promise<any>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* ServerResponse - Ultra-optimized write operations
|
|
43
|
-
*/
|
|
44
|
-
declare class ServerResponse extends EventEmitter {
|
|
45
|
-
statusCode: number;
|
|
46
|
-
statusMessage: string;
|
|
47
|
-
headersSent: boolean;
|
|
48
|
-
private _headers;
|
|
49
|
-
private _body;
|
|
50
|
-
private _resolve?;
|
|
51
|
-
private _finished;
|
|
52
|
-
private _nodeRes?;
|
|
53
|
-
constructor(_req?: IncomingMessage, nodeRes?: any);
|
|
54
|
-
setHeader(name: string, value: string | string[] | number): this;
|
|
55
|
-
getHeader(name: string): string | string[] | number | undefined;
|
|
56
|
-
getHeaders(): OutgoingHttpHeaders;
|
|
57
|
-
getHeaderNames(): string[];
|
|
58
|
-
hasHeader(name: string): boolean;
|
|
59
|
-
removeHeader(name: string): void;
|
|
60
|
-
writeHead(statusCode: number, statusMessage?: string | OutgoingHttpHeaders, headers?: OutgoingHttpHeaders): this;
|
|
61
|
-
write(chunk: any, encoding?: BufferEncoding | (() => void), callback?: () => void): boolean;
|
|
62
|
-
end(chunk?: any, encoding?: BufferEncoding | (() => void), callback?: () => void): this;
|
|
63
|
-
_setResolver(resolve: (response: Response) => void): void;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* WebSocket module with unified API across runtimes
|
|
68
|
-
* Pure implementation without external dependencies
|
|
69
|
-
* - Node.js: uses native 'ws' module (built-in WebSocket implementation)
|
|
70
|
-
* - Bun: uses native WebSocket
|
|
71
|
-
* - Deno: uses native WebSocket
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* WebSocket ready state
|
|
76
|
-
*/
|
|
77
|
-
declare enum ReadyState {
|
|
78
|
-
CONNECTING = 0,
|
|
79
|
-
OPEN = 1,
|
|
80
|
-
CLOSING = 2,
|
|
81
|
-
CLOSED = 3
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* WebSocket data types
|
|
85
|
-
*/
|
|
86
|
-
type Data = string | Buffer | ArrayBuffer | Buffer[];
|
|
87
|
-
/**
|
|
88
|
-
* WebSocket send options
|
|
89
|
-
*/
|
|
90
|
-
interface SendOptions {
|
|
91
|
-
binary?: boolean;
|
|
92
|
-
compress?: boolean;
|
|
93
|
-
fin?: boolean;
|
|
94
|
-
mask?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* WebSocket class - Pure implementation
|
|
98
|
-
*/
|
|
99
|
-
declare class WebSocket extends EventEmitter$1 {
|
|
100
|
-
readyState: ReadyState;
|
|
101
|
-
url: string;
|
|
102
|
-
protocol: string;
|
|
103
|
-
extensions: string;
|
|
104
|
-
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments';
|
|
105
|
-
/** @internal */
|
|
106
|
-
_socket: any;
|
|
107
|
-
constructor(address: string | URL, protocols?: string | string[], _options?: any);
|
|
108
|
-
private _setupNativeSocket;
|
|
109
|
-
/**
|
|
110
|
-
* Send data through WebSocket
|
|
111
|
-
*/
|
|
112
|
-
send(data: Data, options?: SendOptions | ((err?: Error) => void), callback?: (err?: Error) => void): void;
|
|
113
|
-
/**
|
|
114
|
-
* Close the WebSocket connection
|
|
115
|
-
*/
|
|
116
|
-
close(code?: number, reason?: string | Buffer): void;
|
|
117
|
-
/**
|
|
118
|
-
* Pause the socket (no-op for native WebSocket)
|
|
119
|
-
*/
|
|
120
|
-
pause(): void;
|
|
121
|
-
/**
|
|
122
|
-
* Resume the socket (no-op for native WebSocket)
|
|
123
|
-
*/
|
|
124
|
-
resume(): void;
|
|
125
|
-
/**
|
|
126
|
-
* Send a ping frame (no-op for native WebSocket)
|
|
127
|
-
*/
|
|
128
|
-
ping(_data?: Data, _mask?: boolean, callback?: (err?: Error) => void): void;
|
|
129
|
-
/**
|
|
130
|
-
* Send a pong frame (no-op for native WebSocket)
|
|
131
|
-
*/
|
|
132
|
-
pong(_data?: Data, _mask?: boolean, callback?: (err?: Error) => void): void;
|
|
133
|
-
/**
|
|
134
|
-
* Terminate the connection
|
|
135
|
-
*/
|
|
136
|
-
terminate(): void;
|
|
137
|
-
/**
|
|
138
|
-
* Get buffered amount
|
|
139
|
-
*/
|
|
140
|
-
get bufferedAmount(): number;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Development server with HMR support
|
|
145
|
-
* Cross-runtime transpilation support
|
|
146
|
-
* - Node.js: uses esbuild
|
|
147
|
-
* - Bun: uses Bun.Transpiler
|
|
148
|
-
* - Deno: uses Deno.emit
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
interface ServerRouteContext {
|
|
152
|
-
req: IncomingMessage;
|
|
153
|
-
res: ServerResponse;
|
|
154
|
-
params: Record<string, string>;
|
|
155
|
-
query: Record<string, string>;
|
|
156
|
-
body: any;
|
|
157
|
-
headers: Record<string, string | string[] | undefined>;
|
|
158
|
-
}
|
|
159
|
-
type ServerRouteHandler = (ctx: ServerRouteContext) => void | Promise<void>;
|
|
160
|
-
type Middleware = (ctx: ServerRouteContext, next: () => Promise<void>) => void | Promise<void>;
|
|
161
|
-
declare class ServerRouter {
|
|
162
|
-
private routes;
|
|
163
|
-
private middlewares;
|
|
164
|
-
use(middleware: Middleware): this;
|
|
165
|
-
get: (path: string, handler: ServerRouteHandler) => this;
|
|
166
|
-
post: (path: string, handler: ServerRouteHandler) => this;
|
|
167
|
-
put: (path: string, handler: ServerRouteHandler) => this;
|
|
168
|
-
delete: (path: string, handler: ServerRouteHandler) => this;
|
|
169
|
-
patch: (path: string, handler: ServerRouteHandler) => this;
|
|
170
|
-
options: (path: string, handler: ServerRouteHandler) => this;
|
|
171
|
-
private addRoute;
|
|
172
|
-
private pathToRegex;
|
|
173
|
-
private parseQuery;
|
|
174
|
-
private parseBody;
|
|
175
|
-
handle(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
|
|
176
|
-
}
|
|
177
|
-
type StateChangeHandler<T = any> = (value: T, oldValue: T) => void;
|
|
178
|
-
interface SharedStateOptions<T = any> {
|
|
179
|
-
initial: T;
|
|
180
|
-
persist?: boolean;
|
|
181
|
-
validate?: (value: T) => boolean;
|
|
182
|
-
}
|
|
183
|
-
declare class SharedState<T = any> {
|
|
184
|
-
readonly key: string;
|
|
185
|
-
private _value;
|
|
186
|
-
private listeners;
|
|
187
|
-
private changeHandlers;
|
|
188
|
-
private options;
|
|
189
|
-
constructor(key: string, options: SharedStateOptions<T>);
|
|
190
|
-
get value(): T;
|
|
191
|
-
set value(newValue: T);
|
|
192
|
-
update(updater: (current: T) => T): void;
|
|
193
|
-
subscribe(ws: WebSocket): void;
|
|
194
|
-
unsubscribe(ws: WebSocket): void;
|
|
195
|
-
onChange(handler: StateChangeHandler<T>): () => void;
|
|
196
|
-
private broadcast;
|
|
197
|
-
private sendTo;
|
|
198
|
-
get subscriberCount(): number;
|
|
199
|
-
clear(): void;
|
|
200
|
-
}
|
|
201
|
-
declare class StateManager$1 {
|
|
202
|
-
private states;
|
|
203
|
-
create<T>(key: string, options: SharedStateOptions<T>): SharedState<T>;
|
|
204
|
-
get<T>(key: string): SharedState<T> | undefined;
|
|
205
|
-
has(key: string): boolean;
|
|
206
|
-
delete(key: string): boolean;
|
|
207
|
-
subscribe(key: string, ws: WebSocket): void;
|
|
208
|
-
unsubscribe(key: string, ws: WebSocket): void;
|
|
209
|
-
unsubscribeAll(ws: WebSocket): void;
|
|
210
|
-
handleStateChange(key: string, value: any): void;
|
|
211
|
-
keys(): string[];
|
|
212
|
-
clear(): void;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Elit - Types and Interfaces
|
|
217
|
-
*/
|
|
218
|
-
interface VNode {
|
|
219
|
-
tagName: string;
|
|
220
|
-
props: Props;
|
|
221
|
-
children: Children;
|
|
222
|
-
}
|
|
223
|
-
type Child = VNode | string | number | boolean | null | undefined;
|
|
224
|
-
type Children = Child[];
|
|
225
|
-
interface Props {
|
|
226
|
-
[key: string]: any;
|
|
227
|
-
className?: string | string[];
|
|
228
|
-
class?: string | string[];
|
|
229
|
-
style?: Partial<CSSStyleDeclaration> | string;
|
|
230
|
-
dangerouslySetInnerHTML?: {
|
|
231
|
-
__html: string;
|
|
232
|
-
};
|
|
233
|
-
ref?: RefCallback | RefObject;
|
|
234
|
-
onClick?: (event: MouseEvent) => void;
|
|
235
|
-
onChange?: (event: Event) => void;
|
|
236
|
-
onInput?: (event: Event) => void;
|
|
237
|
-
onSubmit?: (event: Event) => void;
|
|
238
|
-
value?: string | number;
|
|
239
|
-
checked?: boolean;
|
|
240
|
-
}
|
|
241
|
-
type RefCallback = (element: HTMLElement | SVGElement) => void;
|
|
242
|
-
interface RefObject {
|
|
243
|
-
current: HTMLElement | SVGElement | null;
|
|
244
|
-
}
|
|
245
|
-
interface State<T> {
|
|
246
|
-
value: T;
|
|
247
|
-
subscribe(fn: (value: T) => void): () => void;
|
|
248
|
-
destroy(): void;
|
|
249
|
-
}
|
|
250
|
-
interface StateOptions {
|
|
251
|
-
throttle?: number;
|
|
252
|
-
deep?: boolean;
|
|
253
|
-
}
|
|
254
|
-
interface VirtualListController {
|
|
255
|
-
render: () => void;
|
|
256
|
-
destroy: () => void;
|
|
257
|
-
}
|
|
258
|
-
interface JsonNode {
|
|
259
|
-
tag: string;
|
|
260
|
-
attributes?: Record<string, any>;
|
|
261
|
-
children?: JsonNode | JsonNode[] | string | number | boolean | null;
|
|
262
|
-
}
|
|
263
|
-
type VNodeJson = {
|
|
264
|
-
tagName: string;
|
|
265
|
-
props?: Record<string, any>;
|
|
266
|
-
children?: (VNodeJson | string | number | boolean | null)[];
|
|
267
|
-
} | string | number | boolean | null;
|
|
268
|
-
type ElementFactory = {
|
|
269
|
-
(...children: Child[]): VNode;
|
|
270
|
-
(props: Props | null, ...children: Child[]): VNode;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
type Router = ServerRouter;
|
|
274
|
-
type StateManager = StateManager$1;
|
|
275
|
-
interface ClientConfig {
|
|
276
|
-
/** Root directory to serve files from */
|
|
277
|
-
root: string;
|
|
278
|
-
/** Base path for the client application (e.g., '/app1', '/app2') */
|
|
279
|
-
basePath: string;
|
|
280
|
-
/** Custom index file path (relative to root, e.g., './public/index.html') */
|
|
281
|
-
index?: string;
|
|
282
|
-
/** SSR render function - returns HTML VNode or string */
|
|
283
|
-
ssr?: () => Child | string;
|
|
284
|
-
/** Watch patterns for file changes */
|
|
285
|
-
watch?: string[];
|
|
286
|
-
/** Ignore patterns for file watching */
|
|
287
|
-
ignore?: string[];
|
|
288
|
-
/** Proxy configuration specific to this client */
|
|
289
|
-
proxy?: ProxyConfig[];
|
|
290
|
-
/** Worker scripts specific to this client */
|
|
291
|
-
worker?: WorkerConfig[];
|
|
292
|
-
/** API router for REST endpoints specific to this client */
|
|
293
|
-
api?: Router;
|
|
294
|
-
/** Custom middleware specific to this client */
|
|
295
|
-
middleware?: ((req: any, res: any, next: () => void) => void)[];
|
|
296
|
-
/** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
|
|
297
|
-
mode?: 'dev' | 'preview';
|
|
298
|
-
}
|
|
299
|
-
interface ProxyConfig {
|
|
300
|
-
/** Path prefix to match for proxying (e.g., '/api', '/graphql') */
|
|
301
|
-
context: string;
|
|
302
|
-
/** Target URL to proxy to (e.g., 'http://localhost:8080') */
|
|
303
|
-
target: string;
|
|
304
|
-
/** Change the origin of the host header to the target URL */
|
|
305
|
-
changeOrigin?: boolean;
|
|
306
|
-
/** Rewrite path before sending to target */
|
|
307
|
-
pathRewrite?: Record<string, string>;
|
|
308
|
-
/** Additional headers to add to the proxied request */
|
|
309
|
-
headers?: Record<string, string>;
|
|
310
|
-
/** Enable WebSocket proxying */
|
|
311
|
-
ws?: boolean;
|
|
312
|
-
}
|
|
313
|
-
interface WorkerConfig {
|
|
314
|
-
/** Worker script path relative to root directory */
|
|
315
|
-
path: string;
|
|
316
|
-
/** Worker name/identifier (optional, defaults to filename) */
|
|
317
|
-
name?: string;
|
|
318
|
-
/** Worker type: 'module' (ESM) or 'classic' (default: 'module') */
|
|
319
|
-
type?: 'module' | 'classic';
|
|
320
|
-
}
|
|
321
|
-
interface DevServerOptions {
|
|
322
|
-
/** Port to run the server on (default: 3000) */
|
|
323
|
-
port?: number;
|
|
324
|
-
/** Host to bind to (default: 'localhost') */
|
|
325
|
-
host?: string;
|
|
326
|
-
/** Root directory to serve files from */
|
|
327
|
-
root?: string;
|
|
328
|
-
/** Base path for the client application (e.g., '/app1', '/app2') */
|
|
329
|
-
basePath?: string;
|
|
330
|
-
/** Custom index file path (relative to root, e.g., './public/index.html') */
|
|
331
|
-
index?: string;
|
|
332
|
-
/** Array of client configurations - allows multiple clients on same port */
|
|
333
|
-
clients?: ClientConfig[];
|
|
334
|
-
/** Enable HTTPS (default: false) */
|
|
335
|
-
https?: boolean;
|
|
336
|
-
/** Open browser automatically (default: true) */
|
|
337
|
-
open?: boolean;
|
|
338
|
-
/** Watch patterns for file changes */
|
|
339
|
-
watch?: string[];
|
|
340
|
-
/** Ignore patterns for file watcher */
|
|
341
|
-
ignore?: string[];
|
|
342
|
-
/** Global worker scripts (applies to all clients) */
|
|
343
|
-
worker?: WorkerConfig[];
|
|
344
|
-
/** Enable logging (default: true) */
|
|
345
|
-
logging?: boolean;
|
|
346
|
-
/** Custom middleware */
|
|
347
|
-
middleware?: ((req: any, res: any, next: () => void) => void)[];
|
|
348
|
-
/** API router for REST endpoints */
|
|
349
|
-
api?: Router;
|
|
350
|
-
/** SSR render function - returns HTML VNode or string */
|
|
351
|
-
ssr?: () => Child | string;
|
|
352
|
-
/** Proxy configuration for API requests */
|
|
353
|
-
proxy?: ProxyConfig[];
|
|
354
|
-
/** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
|
|
355
|
-
mode?: 'dev' | 'preview';
|
|
356
|
-
}
|
|
357
|
-
interface DevServer {
|
|
358
|
-
/** HTTP server instance */
|
|
359
|
-
server: Server;
|
|
360
|
-
/** WebSocket server for HMR */
|
|
361
|
-
wss: WebSocketServer;
|
|
362
|
-
/** Server URL */
|
|
363
|
-
url: string;
|
|
364
|
-
/** Shared state manager */
|
|
365
|
-
state: StateManager;
|
|
366
|
-
/** Close the server */
|
|
367
|
-
close: () => Promise<void>;
|
|
368
|
-
}
|
|
369
|
-
interface HMRMessage {
|
|
370
|
-
type: 'update' | 'reload' | 'error' | 'connected';
|
|
371
|
-
path?: string;
|
|
372
|
-
timestamp?: number;
|
|
373
|
-
error?: string;
|
|
374
|
-
}
|
|
375
|
-
interface BuildOptions {
|
|
376
|
-
/** Entry file to build */
|
|
377
|
-
entry: string;
|
|
378
|
-
/** Output directory */
|
|
379
|
-
outDir?: string;
|
|
380
|
-
/** Output filename */
|
|
381
|
-
outFile?: string;
|
|
382
|
-
/** Enable minification */
|
|
383
|
-
minify?: boolean;
|
|
384
|
-
/** Generate sourcemap */
|
|
385
|
-
sourcemap?: boolean;
|
|
386
|
-
/** Target environment */
|
|
387
|
-
target?: 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
|
|
388
|
-
/** Output format */
|
|
389
|
-
format?: 'esm' | 'cjs' | 'iife';
|
|
390
|
-
/** Global name for IIFE format */
|
|
391
|
-
globalName?: string;
|
|
392
|
-
/** Target platform */
|
|
393
|
-
platform?: 'browser' | 'node' | 'neutral';
|
|
394
|
-
/** Base path for the application (injected into HTML) */
|
|
395
|
-
basePath?: string;
|
|
396
|
-
/** External dependencies (not bundled) */
|
|
397
|
-
external?: string[];
|
|
398
|
-
/** Enable tree shaking */
|
|
399
|
-
treeshake?: boolean;
|
|
400
|
-
/** Enable logging */
|
|
401
|
-
logging?: boolean;
|
|
402
|
-
/** Environment variables to inject (prefix with VITE_ for client access) */
|
|
403
|
-
env?: Record<string, string>;
|
|
404
|
-
/** Copy static files after build */
|
|
405
|
-
copy?: Array<{
|
|
406
|
-
from: string;
|
|
407
|
-
to: string;
|
|
408
|
-
transform?: (content: string, config: BuildOptions) => string;
|
|
409
|
-
}>;
|
|
410
|
-
/** Post-build hook */
|
|
411
|
-
onBuildEnd?: (result: BuildResult) => void | Promise<void>;
|
|
412
|
-
}
|
|
413
|
-
interface BuildResult {
|
|
414
|
-
/** Output file path */
|
|
415
|
-
outputPath: string;
|
|
416
|
-
/** Build time in milliseconds */
|
|
417
|
-
buildTime: number;
|
|
418
|
-
/** Output file size in bytes */
|
|
419
|
-
size: number;
|
|
420
|
-
}
|
|
421
|
-
interface PreviewOptions {
|
|
422
|
-
/** Port to run the preview server on (default: 4173) */
|
|
423
|
-
port?: number;
|
|
424
|
-
/** Host to bind to (default: 'localhost') */
|
|
425
|
-
host?: string;
|
|
426
|
-
/** Root directory to serve files from (default: dist or build.outDir) */
|
|
427
|
-
root?: string;
|
|
428
|
-
/** Base path for the application (e.g., '/app') */
|
|
429
|
-
basePath?: string;
|
|
430
|
-
/** Custom index file path (relative to root, e.g., './public/index.html') */
|
|
431
|
-
index?: string;
|
|
432
|
-
/** Array of client configurations - allows multiple clients on same port */
|
|
433
|
-
clients?: ClientConfig[];
|
|
434
|
-
/** Enable HTTPS (default: false) */
|
|
435
|
-
https?: boolean;
|
|
436
|
-
/** Open browser automatically (default: true) */
|
|
437
|
-
open?: boolean;
|
|
438
|
-
/** Enable logging (default: true) */
|
|
439
|
-
logging?: boolean;
|
|
440
|
-
/** Custom middleware */
|
|
441
|
-
middleware?: ((req: any, res: any, next: () => void) => void)[];
|
|
442
|
-
/** API router for REST endpoints */
|
|
443
|
-
api?: Router;
|
|
444
|
-
/** SSR render function - returns HTML VNode or string */
|
|
445
|
-
ssr?: () => Child | string;
|
|
446
|
-
/** Proxy configuration for API requests */
|
|
447
|
-
proxy?: ProxyConfig[];
|
|
448
|
-
/** Global worker scripts (applies to all clients) */
|
|
449
|
-
worker?: WorkerConfig[];
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export type { BuildOptions, BuildResult, Child, Children, ClientConfig, DevServer, DevServerOptions, ElementFactory, HMRMessage, JsonNode, PreviewOptions, Props, ProxyConfig, RefCallback, RefObject, Router, State, StateManager, StateOptions, VNode, VNodeJson, VirtualListController, WorkerConfig };
|
package/dist/ws.d.mts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { IncomingMessage } from './http.mjs';
|
|
3
|
-
import 'node:events';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* WebSocket module with unified API across runtimes
|
|
7
|
-
* Pure implementation without external dependencies
|
|
8
|
-
* - Node.js: uses native 'ws' module (built-in WebSocket implementation)
|
|
9
|
-
* - Bun: uses native WebSocket
|
|
10
|
-
* - Deno: uses native WebSocket
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* WebSocket ready state
|
|
15
|
-
*/
|
|
16
|
-
declare enum ReadyState {
|
|
17
|
-
CONNECTING = 0,
|
|
18
|
-
OPEN = 1,
|
|
19
|
-
CLOSING = 2,
|
|
20
|
-
CLOSED = 3
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* WebSocket close codes
|
|
24
|
-
*/
|
|
25
|
-
declare const CLOSE_CODES: {
|
|
26
|
-
readonly NORMAL: 1000;
|
|
27
|
-
readonly GOING_AWAY: 1001;
|
|
28
|
-
readonly PROTOCOL_ERROR: 1002;
|
|
29
|
-
readonly UNSUPPORTED_DATA: 1003;
|
|
30
|
-
readonly NO_STATUS: 1005;
|
|
31
|
-
readonly ABNORMAL: 1006;
|
|
32
|
-
readonly INVALID_DATA: 1007;
|
|
33
|
-
readonly POLICY_VIOLATION: 1008;
|
|
34
|
-
readonly MESSAGE_TOO_BIG: 1009;
|
|
35
|
-
readonly EXTENSION_REQUIRED: 1010;
|
|
36
|
-
readonly INTERNAL_ERROR: 1011;
|
|
37
|
-
readonly SERVICE_RESTART: 1012;
|
|
38
|
-
readonly TRY_AGAIN_LATER: 1013;
|
|
39
|
-
readonly BAD_GATEWAY: 1014;
|
|
40
|
-
readonly TLS_HANDSHAKE_FAIL: 1015;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* WebSocket data types
|
|
44
|
-
*/
|
|
45
|
-
type Data = string | Buffer | ArrayBuffer | Buffer[];
|
|
46
|
-
/**
|
|
47
|
-
* WebSocket send options
|
|
48
|
-
*/
|
|
49
|
-
interface SendOptions {
|
|
50
|
-
binary?: boolean;
|
|
51
|
-
compress?: boolean;
|
|
52
|
-
fin?: boolean;
|
|
53
|
-
mask?: boolean;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* WebSocket server options
|
|
57
|
-
*/
|
|
58
|
-
interface ServerOptions {
|
|
59
|
-
host?: string;
|
|
60
|
-
port?: number;
|
|
61
|
-
backlog?: number;
|
|
62
|
-
server?: any;
|
|
63
|
-
verifyClient?: VerifyClientCallback;
|
|
64
|
-
handleProtocols?: (protocols: Set<string>, request: IncomingMessage) => string | false;
|
|
65
|
-
path?: string;
|
|
66
|
-
noServer?: boolean;
|
|
67
|
-
clientTracking?: boolean;
|
|
68
|
-
perMessageDeflate?: boolean | object;
|
|
69
|
-
maxPayload?: number;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Verify client callback
|
|
73
|
-
*/
|
|
74
|
-
type VerifyClientCallback = (info: {
|
|
75
|
-
origin: string;
|
|
76
|
-
secure: boolean;
|
|
77
|
-
req: IncomingMessage;
|
|
78
|
-
}, callback?: (result: boolean, code?: number, message?: string) => void) => boolean | void;
|
|
79
|
-
/**
|
|
80
|
-
* WebSocket class - Pure implementation
|
|
81
|
-
*/
|
|
82
|
-
declare class WebSocket extends EventEmitter {
|
|
83
|
-
readyState: ReadyState;
|
|
84
|
-
url: string;
|
|
85
|
-
protocol: string;
|
|
86
|
-
extensions: string;
|
|
87
|
-
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments';
|
|
88
|
-
/** @internal */
|
|
89
|
-
_socket: any;
|
|
90
|
-
constructor(address: string | URL, protocols?: string | string[], _options?: any);
|
|
91
|
-
private _setupNativeSocket;
|
|
92
|
-
/**
|
|
93
|
-
* Send data through WebSocket
|
|
94
|
-
*/
|
|
95
|
-
send(data: Data, options?: SendOptions | ((err?: Error) => void), callback?: (err?: Error) => void): void;
|
|
96
|
-
/**
|
|
97
|
-
* Close the WebSocket connection
|
|
98
|
-
*/
|
|
99
|
-
close(code?: number, reason?: string | Buffer): void;
|
|
100
|
-
/**
|
|
101
|
-
* Pause the socket (no-op for native WebSocket)
|
|
102
|
-
*/
|
|
103
|
-
pause(): void;
|
|
104
|
-
/**
|
|
105
|
-
* Resume the socket (no-op for native WebSocket)
|
|
106
|
-
*/
|
|
107
|
-
resume(): void;
|
|
108
|
-
/**
|
|
109
|
-
* Send a ping frame (no-op for native WebSocket)
|
|
110
|
-
*/
|
|
111
|
-
ping(_data?: Data, _mask?: boolean, callback?: (err?: Error) => void): void;
|
|
112
|
-
/**
|
|
113
|
-
* Send a pong frame (no-op for native WebSocket)
|
|
114
|
-
*/
|
|
115
|
-
pong(_data?: Data, _mask?: boolean, callback?: (err?: Error) => void): void;
|
|
116
|
-
/**
|
|
117
|
-
* Terminate the connection
|
|
118
|
-
*/
|
|
119
|
-
terminate(): void;
|
|
120
|
-
/**
|
|
121
|
-
* Get buffered amount
|
|
122
|
-
*/
|
|
123
|
-
get bufferedAmount(): number;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* WebSocket Server - Server-side WebSocket implementation
|
|
127
|
-
*/
|
|
128
|
-
declare class WebSocketServer extends EventEmitter {
|
|
129
|
-
clients: Set<WebSocket>;
|
|
130
|
-
options: ServerOptions;
|
|
131
|
-
path: string;
|
|
132
|
-
private _httpServer;
|
|
133
|
-
constructor(options?: ServerOptions, callback?: () => void);
|
|
134
|
-
private _setupUpgradeHandler;
|
|
135
|
-
/**
|
|
136
|
-
* Handle HTTP upgrade for WebSocket
|
|
137
|
-
*/
|
|
138
|
-
handleUpgrade(request: IncomingMessage, socket: any, _head: Buffer, callback: (client: WebSocket) => void): void;
|
|
139
|
-
private _createClientFromSocket;
|
|
140
|
-
private _parseFrame;
|
|
141
|
-
private _createFrame;
|
|
142
|
-
/**
|
|
143
|
-
* Close the server
|
|
144
|
-
*/
|
|
145
|
-
close(callback?: (err?: Error) => void): void;
|
|
146
|
-
/**
|
|
147
|
-
* Check if server should handle request
|
|
148
|
-
*/
|
|
149
|
-
shouldHandle(request: IncomingMessage): boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Get server address
|
|
152
|
-
*/
|
|
153
|
-
address(): {
|
|
154
|
-
port: number;
|
|
155
|
-
family: string;
|
|
156
|
-
address: string;
|
|
157
|
-
} | null;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Create WebSocket server
|
|
161
|
-
*/
|
|
162
|
-
declare function createWebSocketServer(options?: ServerOptions, callback?: () => void): WebSocketServer;
|
|
163
|
-
/**
|
|
164
|
-
* Get current runtime
|
|
165
|
-
*/
|
|
166
|
-
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
167
|
-
/**
|
|
168
|
-
* Default export
|
|
169
|
-
*/
|
|
170
|
-
declare const _default: {
|
|
171
|
-
WebSocket: typeof WebSocket;
|
|
172
|
-
WebSocketServer: typeof WebSocketServer;
|
|
173
|
-
createWebSocketServer: typeof createWebSocketServer;
|
|
174
|
-
ReadyState: typeof ReadyState;
|
|
175
|
-
CLOSE_CODES: {
|
|
176
|
-
readonly NORMAL: 1000;
|
|
177
|
-
readonly GOING_AWAY: 1001;
|
|
178
|
-
readonly PROTOCOL_ERROR: 1002;
|
|
179
|
-
readonly UNSUPPORTED_DATA: 1003;
|
|
180
|
-
readonly NO_STATUS: 1005;
|
|
181
|
-
readonly ABNORMAL: 1006;
|
|
182
|
-
readonly INVALID_DATA: 1007;
|
|
183
|
-
readonly POLICY_VIOLATION: 1008;
|
|
184
|
-
readonly MESSAGE_TOO_BIG: 1009;
|
|
185
|
-
readonly EXTENSION_REQUIRED: 1010;
|
|
186
|
-
readonly INTERNAL_ERROR: 1011;
|
|
187
|
-
readonly SERVICE_RESTART: 1012;
|
|
188
|
-
readonly TRY_AGAIN_LATER: 1013;
|
|
189
|
-
readonly BAD_GATEWAY: 1014;
|
|
190
|
-
readonly TLS_HANDSHAKE_FAIL: 1015;
|
|
191
|
-
};
|
|
192
|
-
getRuntime: typeof getRuntime;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export { CLOSE_CODES, type Data, ReadyState, type SendOptions, type ServerOptions, type VerifyClientCallback, WebSocket, WebSocketServer, createWebSocketServer, _default as default, getRuntime };
|