elit 3.0.1 → 3.0.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.
Files changed (87) hide show
  1. package/dist/build.d.ts +4 -12
  2. package/dist/build.d.ts.map +1 -0
  3. package/dist/chokidar.d.ts +7 -9
  4. package/dist/chokidar.d.ts.map +1 -0
  5. package/dist/cli.d.ts +6 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +17 -4
  8. package/dist/config.d.ts +29 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/dom.d.ts +7 -14
  11. package/dist/dom.d.ts.map +1 -0
  12. package/dist/el.d.ts +19 -191
  13. package/dist/el.d.ts.map +1 -0
  14. package/dist/fs.d.ts +35 -35
  15. package/dist/fs.d.ts.map +1 -0
  16. package/dist/hmr.d.ts +3 -3
  17. package/dist/hmr.d.ts.map +1 -0
  18. package/dist/http.d.ts +20 -22
  19. package/dist/http.d.ts.map +1 -0
  20. package/dist/https.d.ts +12 -15
  21. package/dist/https.d.ts.map +1 -0
  22. package/dist/index.d.ts +10 -629
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/mime-types.d.ts +9 -9
  25. package/dist/mime-types.d.ts.map +1 -0
  26. package/dist/path.d.ts +22 -19
  27. package/dist/path.d.ts.map +1 -0
  28. package/dist/router.d.ts +10 -17
  29. package/dist/router.d.ts.map +1 -0
  30. package/dist/runtime.d.ts +5 -6
  31. package/dist/runtime.d.ts.map +1 -0
  32. package/dist/server.d.ts +105 -7
  33. package/dist/server.d.ts.map +1 -0
  34. package/dist/server.js +14 -2
  35. package/dist/server.mjs +14 -2
  36. package/dist/state.d.ts +21 -27
  37. package/dist/state.d.ts.map +1 -0
  38. package/dist/style.d.ts +14 -55
  39. package/dist/style.d.ts.map +1 -0
  40. package/dist/types.d.ts +26 -240
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/ws.d.ts +14 -17
  43. package/dist/ws.d.ts.map +1 -0
  44. package/dist/wss.d.ts +16 -16
  45. package/dist/wss.d.ts.map +1 -0
  46. package/package.json +3 -2
  47. package/src/build.ts +337 -0
  48. package/src/chokidar.ts +401 -0
  49. package/src/cli.ts +638 -0
  50. package/src/config.ts +205 -0
  51. package/src/dom.ts +817 -0
  52. package/src/el.ts +164 -0
  53. package/src/fs.ts +727 -0
  54. package/src/hmr.ts +137 -0
  55. package/src/http.ts +775 -0
  56. package/src/https.ts +411 -0
  57. package/src/index.ts +14 -0
  58. package/src/mime-types.ts +222 -0
  59. package/src/path.ts +493 -0
  60. package/src/router.ts +237 -0
  61. package/src/runtime.ts +97 -0
  62. package/src/server.ts +1290 -0
  63. package/src/state.ts +468 -0
  64. package/src/style.ts +524 -0
  65. package/{dist/types-Du6kfwTm.d.ts → src/types.ts} +58 -141
  66. package/src/ws.ts +506 -0
  67. package/src/wss.ts +241 -0
  68. package/dist/build.d.mts +0 -20
  69. package/dist/chokidar.d.mts +0 -134
  70. package/dist/dom.d.mts +0 -87
  71. package/dist/el.d.mts +0 -207
  72. package/dist/fs.d.mts +0 -255
  73. package/dist/hmr.d.mts +0 -38
  74. package/dist/http.d.mts +0 -163
  75. package/dist/https.d.mts +0 -108
  76. package/dist/index.d.mts +0 -629
  77. package/dist/mime-types.d.mts +0 -48
  78. package/dist/path.d.mts +0 -163
  79. package/dist/router.d.mts +0 -47
  80. package/dist/runtime.d.mts +0 -97
  81. package/dist/server.d.mts +0 -7
  82. package/dist/state.d.mts +0 -111
  83. package/dist/style.d.mts +0 -159
  84. package/dist/types-C0nGi6MX.d.mts +0 -346
  85. package/dist/types.d.mts +0 -452
  86. package/dist/ws.d.mts +0 -195
  87. package/dist/wss.d.mts +0 -108
@@ -1,129 +1,22 @@
1
- import { IncomingMessage, ServerResponse } from './http.js';
2
- import { WebSocket } from './ws.js';
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
1
  /**
110
2
  * Elit - Types and Interfaces
111
3
  */
112
- interface VNode {
4
+
5
+ export interface VNode {
113
6
  tagName: string;
114
7
  props: Props;
115
8
  children: Children;
116
9
  }
117
- type Child = VNode | string | number | boolean | null | undefined;
118
- type Children = Child[];
119
- interface Props {
10
+
11
+ export type Child = VNode | string | number | boolean | null | undefined;
12
+ export type Children = Child[];
13
+
14
+ export interface Props {
120
15
  [key: string]: any;
121
16
  className?: string | string[];
122
17
  class?: string | string[];
123
18
  style?: Partial<CSSStyleDeclaration> | string;
124
- dangerouslySetInnerHTML?: {
125
- __html: string;
126
- };
19
+ dangerouslySetInnerHTML?: { __html: string };
127
20
  ref?: RefCallback | RefObject;
128
21
  onClick?: (event: MouseEvent) => void;
129
22
  onChange?: (event: Event) => void;
@@ -132,41 +25,59 @@ interface Props {
132
25
  value?: string | number;
133
26
  checked?: boolean;
134
27
  }
135
- type RefCallback = (element: HTMLElement | SVGElement) => void;
136
- interface RefObject {
28
+
29
+ export type RefCallback = (element: HTMLElement | SVGElement) => void;
30
+
31
+ export interface RefObject {
137
32
  current: HTMLElement | SVGElement | null;
138
33
  }
139
- interface State<T> {
34
+
35
+ export interface State<T> {
140
36
  value: T;
141
37
  subscribe(fn: (value: T) => void): () => void;
142
38
  destroy(): void;
143
39
  }
144
- interface StateOptions {
40
+
41
+ export interface StateOptions {
145
42
  throttle?: number;
146
43
  deep?: boolean;
147
44
  }
148
- interface VirtualListController {
45
+
46
+ export interface VirtualListController {
149
47
  render: () => void;
150
48
  destroy: () => void;
151
49
  }
152
- interface JsonNode {
50
+
51
+ // JSON Node structure for renderJson
52
+ export interface JsonNode {
153
53
  tag: string;
154
54
  attributes?: Record<string, any>;
155
55
  children?: JsonNode | JsonNode[] | string | number | boolean | null;
156
56
  }
157
- type VNodeJson = {
57
+
58
+ // VNode JSON structure for renderVNode (serializable VNode format)
59
+ export type VNodeJson = {
158
60
  tagName: string;
159
61
  props?: Record<string, any>;
160
62
  children?: (VNodeJson | string | number | boolean | null)[];
161
63
  } | string | number | boolean | null;
162
- type ElementFactory = {
64
+
65
+ // Element Factory type
66
+ export type ElementFactory = {
163
67
  (...children: Child[]): VNode;
164
68
  (props: Props | null, ...children: Child[]): VNode;
165
69
  };
166
70
 
167
- type Router = ServerRouter;
168
- type StateManager = StateManager$1;
169
- interface ClientConfig {
71
+ // ===== Development Server Types =====
72
+
73
+ import type { Server } from 'http';
74
+ import type { WebSocketServer } from 'ws';
75
+
76
+ // Forward declarations to avoid circular dependency
77
+ export type Router = import('./server').ServerRouter;
78
+ export type StateManager = import('./server').StateManager;
79
+
80
+ export interface ClientConfig {
170
81
  /** Root directory to serve files from */
171
82
  root: string;
172
83
  /** Base path for the client application (e.g., '/app1', '/app2') */
@@ -190,7 +101,8 @@ interface ClientConfig {
190
101
  /** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
191
102
  mode?: 'dev' | 'preview';
192
103
  }
193
- interface ProxyConfig {
104
+
105
+ export interface ProxyConfig {
194
106
  /** Path prefix to match for proxying (e.g., '/api', '/graphql') */
195
107
  context: string;
196
108
  /** Target URL to proxy to (e.g., 'http://localhost:8080') */
@@ -204,7 +116,8 @@ interface ProxyConfig {
204
116
  /** Enable WebSocket proxying */
205
117
  ws?: boolean;
206
118
  }
207
- interface WorkerConfig {
119
+
120
+ export interface WorkerConfig {
208
121
  /** Worker script path relative to root directory */
209
122
  path: string;
210
123
  /** Worker name/identifier (optional, defaults to filename) */
@@ -212,7 +125,8 @@ interface WorkerConfig {
212
125
  /** Worker type: 'module' (ESM) or 'classic' (default: 'module') */
213
126
  type?: 'module' | 'classic';
214
127
  }
215
- interface DevServerOptions {
128
+
129
+ export interface DevServerOptions {
216
130
  /** Port to run the server on (default: 3000) */
217
131
  port?: number;
218
132
  /** Host to bind to (default: 'localhost') */
@@ -248,7 +162,8 @@ interface DevServerOptions {
248
162
  /** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
249
163
  mode?: 'dev' | 'preview';
250
164
  }
251
- interface DevServer {
165
+
166
+ export interface DevServer {
252
167
  /** HTTP server instance */
253
168
  server: Server;
254
169
  /** WebSocket server for HMR */
@@ -260,13 +175,17 @@ interface DevServer {
260
175
  /** Close the server */
261
176
  close: () => Promise<void>;
262
177
  }
263
- interface HMRMessage {
178
+
179
+ export interface HMRMessage {
264
180
  type: 'update' | 'reload' | 'error' | 'connected';
265
181
  path?: string;
266
182
  timestamp?: number;
267
183
  error?: string;
268
184
  }
269
- interface BuildOptions {
185
+
186
+ // ===== Build Types =====
187
+
188
+ export interface BuildOptions {
270
189
  /** Entry file to build */
271
190
  entry: string;
272
191
  /** Output directory */
@@ -296,15 +215,12 @@ interface BuildOptions {
296
215
  /** Environment variables to inject (prefix with VITE_ for client access) */
297
216
  env?: Record<string, string>;
298
217
  /** Copy static files after build */
299
- copy?: Array<{
300
- from: string;
301
- to: string;
302
- transform?: (content: string, config: BuildOptions) => string;
303
- }>;
218
+ copy?: Array<{ from: string; to: string; transform?: (content: string, config: BuildOptions) => string }>;
304
219
  /** Post-build hook */
305
220
  onBuildEnd?: (result: BuildResult) => void | Promise<void>;
306
221
  }
307
- interface BuildResult {
222
+
223
+ export interface BuildResult {
308
224
  /** Output file path */
309
225
  outputPath: string;
310
226
  /** Build time in milliseconds */
@@ -312,7 +228,10 @@ interface BuildResult {
312
228
  /** Output file size in bytes */
313
229
  size: number;
314
230
  }
315
- interface PreviewOptions {
231
+
232
+ // ===== Preview Types =====
233
+
234
+ export interface PreviewOptions {
316
235
  /** Port to run the preview server on (default: 4173) */
317
236
  port?: number;
318
237
  /** Host to bind to (default: 'localhost') */
@@ -342,5 +261,3 @@ interface PreviewOptions {
342
261
  /** Global worker scripts (applies to all clients) */
343
262
  worker?: WorkerConfig[];
344
263
  }
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 };