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
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from './http.mjs';
|
|
2
|
-
import { WebSocket } from './ws.mjs';
|
|
3
|
-
import { Server } from 'http';
|
|
4
|
-
import { WebSocketServer } from 'ws';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Development server with HMR support
|
|
8
|
-
* Cross-runtime transpilation support
|
|
9
|
-
* - Node.js: uses esbuild
|
|
10
|
-
* - Bun: uses Bun.Transpiler
|
|
11
|
-
* - Deno: uses Deno.emit
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
|
|
15
|
-
interface ServerRouteContext {
|
|
16
|
-
req: IncomingMessage;
|
|
17
|
-
res: ServerResponse;
|
|
18
|
-
params: Record<string, string>;
|
|
19
|
-
query: Record<string, string>;
|
|
20
|
-
body: any;
|
|
21
|
-
headers: Record<string, string | string[] | undefined>;
|
|
22
|
-
}
|
|
23
|
-
type ServerRouteHandler = (ctx: ServerRouteContext) => void | Promise<void>;
|
|
24
|
-
type Middleware = (ctx: ServerRouteContext, next: () => Promise<void>) => void | Promise<void>;
|
|
25
|
-
declare class ServerRouter {
|
|
26
|
-
private routes;
|
|
27
|
-
private middlewares;
|
|
28
|
-
use(middleware: Middleware): this;
|
|
29
|
-
get: (path: string, handler: ServerRouteHandler) => this;
|
|
30
|
-
post: (path: string, handler: ServerRouteHandler) => this;
|
|
31
|
-
put: (path: string, handler: ServerRouteHandler) => this;
|
|
32
|
-
delete: (path: string, handler: ServerRouteHandler) => this;
|
|
33
|
-
patch: (path: string, handler: ServerRouteHandler) => this;
|
|
34
|
-
options: (path: string, handler: ServerRouteHandler) => this;
|
|
35
|
-
private addRoute;
|
|
36
|
-
private pathToRegex;
|
|
37
|
-
private parseQuery;
|
|
38
|
-
private parseBody;
|
|
39
|
-
handle(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
|
|
40
|
-
}
|
|
41
|
-
declare const json: (res: ServerResponse, data: any, status?: number) => ServerResponse;
|
|
42
|
-
declare const text: (res: ServerResponse, data: string, status?: number) => ServerResponse;
|
|
43
|
-
declare const html: (res: ServerResponse, data: string, status?: number) => ServerResponse;
|
|
44
|
-
declare const status: (res: ServerResponse, code: number, message?: string) => ServerResponse;
|
|
45
|
-
declare function cors(options?: {
|
|
46
|
-
origin?: string | string[];
|
|
47
|
-
methods?: string[];
|
|
48
|
-
credentials?: boolean;
|
|
49
|
-
maxAge?: number;
|
|
50
|
-
}): Middleware;
|
|
51
|
-
declare function logger(options?: {
|
|
52
|
-
format?: 'simple' | 'detailed';
|
|
53
|
-
}): Middleware;
|
|
54
|
-
declare function errorHandler(): Middleware;
|
|
55
|
-
declare function rateLimit(options?: {
|
|
56
|
-
windowMs?: number;
|
|
57
|
-
max?: number;
|
|
58
|
-
message?: string;
|
|
59
|
-
}): Middleware;
|
|
60
|
-
declare function bodyLimit(options?: {
|
|
61
|
-
limit?: number;
|
|
62
|
-
}): Middleware;
|
|
63
|
-
declare function cacheControl(options?: {
|
|
64
|
-
maxAge?: number;
|
|
65
|
-
public?: boolean;
|
|
66
|
-
}): Middleware;
|
|
67
|
-
declare function compress(): Middleware;
|
|
68
|
-
declare function security(): Middleware;
|
|
69
|
-
declare function createProxyHandler(proxyConfigs: ProxyConfig[]): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
|
|
70
|
-
type StateChangeHandler<T = any> = (value: T, oldValue: T) => void;
|
|
71
|
-
interface SharedStateOptions<T = any> {
|
|
72
|
-
initial: T;
|
|
73
|
-
persist?: boolean;
|
|
74
|
-
validate?: (value: T) => boolean;
|
|
75
|
-
}
|
|
76
|
-
declare class SharedState<T = any> {
|
|
77
|
-
readonly key: string;
|
|
78
|
-
private _value;
|
|
79
|
-
private listeners;
|
|
80
|
-
private changeHandlers;
|
|
81
|
-
private options;
|
|
82
|
-
constructor(key: string, options: SharedStateOptions<T>);
|
|
83
|
-
get value(): T;
|
|
84
|
-
set value(newValue: T);
|
|
85
|
-
update(updater: (current: T) => T): void;
|
|
86
|
-
subscribe(ws: WebSocket): void;
|
|
87
|
-
unsubscribe(ws: WebSocket): void;
|
|
88
|
-
onChange(handler: StateChangeHandler<T>): () => void;
|
|
89
|
-
private broadcast;
|
|
90
|
-
private sendTo;
|
|
91
|
-
get subscriberCount(): number;
|
|
92
|
-
clear(): void;
|
|
93
|
-
}
|
|
94
|
-
declare class StateManager$1 {
|
|
95
|
-
private states;
|
|
96
|
-
create<T>(key: string, options: SharedStateOptions<T>): SharedState<T>;
|
|
97
|
-
get<T>(key: string): SharedState<T> | undefined;
|
|
98
|
-
has(key: string): boolean;
|
|
99
|
-
delete(key: string): boolean;
|
|
100
|
-
subscribe(key: string, ws: WebSocket): void;
|
|
101
|
-
unsubscribe(key: string, ws: WebSocket): void;
|
|
102
|
-
unsubscribeAll(ws: WebSocket): void;
|
|
103
|
-
handleStateChange(key: string, value: any): void;
|
|
104
|
-
keys(): string[];
|
|
105
|
-
clear(): void;
|
|
106
|
-
}
|
|
107
|
-
declare function createDevServer(options: DevServerOptions): DevServer;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Elit - Types and Interfaces
|
|
111
|
-
*/
|
|
112
|
-
interface VNode {
|
|
113
|
-
tagName: string;
|
|
114
|
-
props: Props;
|
|
115
|
-
children: Children;
|
|
116
|
-
}
|
|
117
|
-
type Child = VNode | string | number | boolean | null | undefined;
|
|
118
|
-
type Children = Child[];
|
|
119
|
-
interface Props {
|
|
120
|
-
[key: string]: any;
|
|
121
|
-
className?: string | string[];
|
|
122
|
-
class?: string | string[];
|
|
123
|
-
style?: Partial<CSSStyleDeclaration> | string;
|
|
124
|
-
dangerouslySetInnerHTML?: {
|
|
125
|
-
__html: string;
|
|
126
|
-
};
|
|
127
|
-
ref?: RefCallback | RefObject;
|
|
128
|
-
onClick?: (event: MouseEvent) => void;
|
|
129
|
-
onChange?: (event: Event) => void;
|
|
130
|
-
onInput?: (event: Event) => void;
|
|
131
|
-
onSubmit?: (event: Event) => void;
|
|
132
|
-
value?: string | number;
|
|
133
|
-
checked?: boolean;
|
|
134
|
-
}
|
|
135
|
-
type RefCallback = (element: HTMLElement | SVGElement) => void;
|
|
136
|
-
interface RefObject {
|
|
137
|
-
current: HTMLElement | SVGElement | null;
|
|
138
|
-
}
|
|
139
|
-
interface State<T> {
|
|
140
|
-
value: T;
|
|
141
|
-
subscribe(fn: (value: T) => void): () => void;
|
|
142
|
-
destroy(): void;
|
|
143
|
-
}
|
|
144
|
-
interface StateOptions {
|
|
145
|
-
throttle?: number;
|
|
146
|
-
deep?: boolean;
|
|
147
|
-
}
|
|
148
|
-
interface VirtualListController {
|
|
149
|
-
render: () => void;
|
|
150
|
-
destroy: () => void;
|
|
151
|
-
}
|
|
152
|
-
interface JsonNode {
|
|
153
|
-
tag: string;
|
|
154
|
-
attributes?: Record<string, any>;
|
|
155
|
-
children?: JsonNode | JsonNode[] | string | number | boolean | null;
|
|
156
|
-
}
|
|
157
|
-
type VNodeJson = {
|
|
158
|
-
tagName: string;
|
|
159
|
-
props?: Record<string, any>;
|
|
160
|
-
children?: (VNodeJson | string | number | boolean | null)[];
|
|
161
|
-
} | string | number | boolean | null;
|
|
162
|
-
type ElementFactory = {
|
|
163
|
-
(...children: Child[]): VNode;
|
|
164
|
-
(props: Props | null, ...children: Child[]): VNode;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
type Router = ServerRouter;
|
|
168
|
-
type StateManager = StateManager$1;
|
|
169
|
-
interface ClientConfig {
|
|
170
|
-
/** Root directory to serve files from */
|
|
171
|
-
root: string;
|
|
172
|
-
/** Base path for the client application (e.g., '/app1', '/app2') */
|
|
173
|
-
basePath: string;
|
|
174
|
-
/** Custom index file path (relative to root, e.g., './public/index.html') */
|
|
175
|
-
index?: string;
|
|
176
|
-
/** SSR render function - returns HTML VNode or string */
|
|
177
|
-
ssr?: () => Child | string;
|
|
178
|
-
/** Watch patterns for file changes */
|
|
179
|
-
watch?: string[];
|
|
180
|
-
/** Ignore patterns for file watching */
|
|
181
|
-
ignore?: string[];
|
|
182
|
-
/** Proxy configuration specific to this client */
|
|
183
|
-
proxy?: ProxyConfig[];
|
|
184
|
-
/** Worker scripts specific to this client */
|
|
185
|
-
worker?: WorkerConfig[];
|
|
186
|
-
/** API router for REST endpoints specific to this client */
|
|
187
|
-
api?: Router;
|
|
188
|
-
/** Custom middleware specific to this client */
|
|
189
|
-
middleware?: ((req: any, res: any, next: () => void) => void)[];
|
|
190
|
-
/** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
|
|
191
|
-
mode?: 'dev' | 'preview';
|
|
192
|
-
}
|
|
193
|
-
interface ProxyConfig {
|
|
194
|
-
/** Path prefix to match for proxying (e.g., '/api', '/graphql') */
|
|
195
|
-
context: string;
|
|
196
|
-
/** Target URL to proxy to (e.g., 'http://localhost:8080') */
|
|
197
|
-
target: string;
|
|
198
|
-
/** Change the origin of the host header to the target URL */
|
|
199
|
-
changeOrigin?: boolean;
|
|
200
|
-
/** Rewrite path before sending to target */
|
|
201
|
-
pathRewrite?: Record<string, string>;
|
|
202
|
-
/** Additional headers to add to the proxied request */
|
|
203
|
-
headers?: Record<string, string>;
|
|
204
|
-
/** Enable WebSocket proxying */
|
|
205
|
-
ws?: boolean;
|
|
206
|
-
}
|
|
207
|
-
interface WorkerConfig {
|
|
208
|
-
/** Worker script path relative to root directory */
|
|
209
|
-
path: string;
|
|
210
|
-
/** Worker name/identifier (optional, defaults to filename) */
|
|
211
|
-
name?: string;
|
|
212
|
-
/** Worker type: 'module' (ESM) or 'classic' (default: 'module') */
|
|
213
|
-
type?: 'module' | 'classic';
|
|
214
|
-
}
|
|
215
|
-
interface DevServerOptions {
|
|
216
|
-
/** Port to run the server on (default: 3000) */
|
|
217
|
-
port?: number;
|
|
218
|
-
/** Host to bind to (default: 'localhost') */
|
|
219
|
-
host?: string;
|
|
220
|
-
/** Root directory to serve files from */
|
|
221
|
-
root?: string;
|
|
222
|
-
/** Base path for the client application (e.g., '/app1', '/app2') */
|
|
223
|
-
basePath?: string;
|
|
224
|
-
/** Custom index file path (relative to root, e.g., './public/index.html') */
|
|
225
|
-
index?: string;
|
|
226
|
-
/** Array of client configurations - allows multiple clients on same port */
|
|
227
|
-
clients?: ClientConfig[];
|
|
228
|
-
/** Enable HTTPS (default: false) */
|
|
229
|
-
https?: boolean;
|
|
230
|
-
/** Open browser automatically (default: true) */
|
|
231
|
-
open?: boolean;
|
|
232
|
-
/** Watch patterns for file changes */
|
|
233
|
-
watch?: string[];
|
|
234
|
-
/** Ignore patterns for file watcher */
|
|
235
|
-
ignore?: string[];
|
|
236
|
-
/** Global worker scripts (applies to all clients) */
|
|
237
|
-
worker?: WorkerConfig[];
|
|
238
|
-
/** Enable logging (default: true) */
|
|
239
|
-
logging?: boolean;
|
|
240
|
-
/** Custom middleware */
|
|
241
|
-
middleware?: ((req: any, res: any, next: () => void) => void)[];
|
|
242
|
-
/** API router for REST endpoints */
|
|
243
|
-
api?: Router;
|
|
244
|
-
/** SSR render function - returns HTML VNode or string */
|
|
245
|
-
ssr?: () => Child | string;
|
|
246
|
-
/** Proxy configuration for API requests */
|
|
247
|
-
proxy?: ProxyConfig[];
|
|
248
|
-
/** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
|
|
249
|
-
mode?: 'dev' | 'preview';
|
|
250
|
-
}
|
|
251
|
-
interface DevServer {
|
|
252
|
-
/** HTTP server instance */
|
|
253
|
-
server: Server;
|
|
254
|
-
/** WebSocket server for HMR */
|
|
255
|
-
wss: WebSocketServer;
|
|
256
|
-
/** Server URL */
|
|
257
|
-
url: string;
|
|
258
|
-
/** Shared state manager */
|
|
259
|
-
state: StateManager;
|
|
260
|
-
/** Close the server */
|
|
261
|
-
close: () => Promise<void>;
|
|
262
|
-
}
|
|
263
|
-
interface HMRMessage {
|
|
264
|
-
type: 'update' | 'reload' | 'error' | 'connected';
|
|
265
|
-
path?: string;
|
|
266
|
-
timestamp?: number;
|
|
267
|
-
error?: string;
|
|
268
|
-
}
|
|
269
|
-
interface BuildOptions {
|
|
270
|
-
/** Entry file to build */
|
|
271
|
-
entry: string;
|
|
272
|
-
/** Output directory */
|
|
273
|
-
outDir?: string;
|
|
274
|
-
/** Output filename */
|
|
275
|
-
outFile?: string;
|
|
276
|
-
/** Enable minification */
|
|
277
|
-
minify?: boolean;
|
|
278
|
-
/** Generate sourcemap */
|
|
279
|
-
sourcemap?: boolean;
|
|
280
|
-
/** Target environment */
|
|
281
|
-
target?: 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
|
|
282
|
-
/** Output format */
|
|
283
|
-
format?: 'esm' | 'cjs' | 'iife';
|
|
284
|
-
/** Global name for IIFE format */
|
|
285
|
-
globalName?: string;
|
|
286
|
-
/** Target platform */
|
|
287
|
-
platform?: 'browser' | 'node' | 'neutral';
|
|
288
|
-
/** Base path for the application (injected into HTML) */
|
|
289
|
-
basePath?: string;
|
|
290
|
-
/** External dependencies (not bundled) */
|
|
291
|
-
external?: string[];
|
|
292
|
-
/** Enable tree shaking */
|
|
293
|
-
treeshake?: boolean;
|
|
294
|
-
/** Enable logging */
|
|
295
|
-
logging?: boolean;
|
|
296
|
-
/** Environment variables to inject (prefix with VITE_ for client access) */
|
|
297
|
-
env?: Record<string, string>;
|
|
298
|
-
/** Copy static files after build */
|
|
299
|
-
copy?: Array<{
|
|
300
|
-
from: string;
|
|
301
|
-
to: string;
|
|
302
|
-
transform?: (content: string, config: BuildOptions) => string;
|
|
303
|
-
}>;
|
|
304
|
-
/** Post-build hook */
|
|
305
|
-
onBuildEnd?: (result: BuildResult) => void | Promise<void>;
|
|
306
|
-
}
|
|
307
|
-
interface BuildResult {
|
|
308
|
-
/** Output file path */
|
|
309
|
-
outputPath: string;
|
|
310
|
-
/** Build time in milliseconds */
|
|
311
|
-
buildTime: number;
|
|
312
|
-
/** Output file size in bytes */
|
|
313
|
-
size: number;
|
|
314
|
-
}
|
|
315
|
-
interface PreviewOptions {
|
|
316
|
-
/** Port to run the preview server on (default: 4173) */
|
|
317
|
-
port?: number;
|
|
318
|
-
/** Host to bind to (default: 'localhost') */
|
|
319
|
-
host?: string;
|
|
320
|
-
/** Root directory to serve files from (default: dist or build.outDir) */
|
|
321
|
-
root?: string;
|
|
322
|
-
/** Base path for the application (e.g., '/app') */
|
|
323
|
-
basePath?: string;
|
|
324
|
-
/** Custom index file path (relative to root, e.g., './public/index.html') */
|
|
325
|
-
index?: string;
|
|
326
|
-
/** Array of client configurations - allows multiple clients on same port */
|
|
327
|
-
clients?: ClientConfig[];
|
|
328
|
-
/** Enable HTTPS (default: false) */
|
|
329
|
-
https?: boolean;
|
|
330
|
-
/** Open browser automatically (default: true) */
|
|
331
|
-
open?: boolean;
|
|
332
|
-
/** Enable logging (default: true) */
|
|
333
|
-
logging?: boolean;
|
|
334
|
-
/** Custom middleware */
|
|
335
|
-
middleware?: ((req: any, res: any, next: () => void) => void)[];
|
|
336
|
-
/** API router for REST endpoints */
|
|
337
|
-
api?: Router;
|
|
338
|
-
/** SSR render function - returns HTML VNode or string */
|
|
339
|
-
ssr?: () => Child | string;
|
|
340
|
-
/** Proxy configuration for API requests */
|
|
341
|
-
proxy?: ProxyConfig[];
|
|
342
|
-
/** Global worker scripts (applies to all clients) */
|
|
343
|
-
worker?: WorkerConfig[];
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export { security as A, type BuildOptions as B, type Children as C, type DevServerOptions as D, type ElementFactory as E, createProxyHandler as F, type StateChangeHandler as G, type HMRMessage as H, type SharedStateOptions as I, type JsonNode as J, SharedState as K, StateManager$1 as L, type Middleware as M, createDevServer as N, type Props as P, type RefCallback as R, type StateOptions as S, type VNode as V, type WorkerConfig as W, type Child as a, type State as b, type VirtualListController as c, type VNodeJson as d, type RefObject as e, type StateManager as f, type ClientConfig as g, type ProxyConfig as h, type DevServer as i, type BuildResult as j, type PreviewOptions as k, type HttpMethod as l, type ServerRouteContext as m, type ServerRouteHandler as n, ServerRouter as o, json as p, html as q, cors as r, status as s, text as t, logger as u, errorHandler as v, rateLimit as w, bodyLimit as x, cacheControl as y, compress as z };
|