elit 1.1.0 → 2.0.1

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 (50) hide show
  1. package/README.md +421 -203
  2. package/dist/build.d.mts +11 -0
  3. package/dist/build.d.ts +11 -0
  4. package/dist/build.js +1 -0
  5. package/dist/build.mjs +1 -0
  6. package/dist/cli.js +2307 -0
  7. package/dist/client.d.mts +9 -0
  8. package/dist/client.d.ts +9 -0
  9. package/dist/client.js +1 -0
  10. package/dist/client.mjs +1 -0
  11. package/dist/dom.d.mts +80 -0
  12. package/dist/dom.d.ts +80 -0
  13. package/dist/dom.js +1 -0
  14. package/dist/dom.mjs +1 -0
  15. package/dist/el.d.mts +227 -0
  16. package/dist/el.d.ts +227 -0
  17. package/dist/el.js +1 -0
  18. package/dist/el.mjs +1 -0
  19. package/dist/hmr.d.mts +38 -0
  20. package/dist/hmr.d.ts +38 -0
  21. package/dist/hmr.js +1 -0
  22. package/dist/hmr.mjs +1 -0
  23. package/dist/index.d.mts +38 -619
  24. package/dist/index.d.ts +38 -619
  25. package/dist/index.js +1 -35
  26. package/dist/index.mjs +1 -35
  27. package/dist/router.d.mts +45 -0
  28. package/dist/router.d.ts +45 -0
  29. package/dist/router.js +1 -0
  30. package/dist/router.mjs +1 -0
  31. package/dist/server.d.mts +3 -0
  32. package/dist/server.d.ts +3 -0
  33. package/dist/server.js +1 -0
  34. package/dist/server.mjs +1 -0
  35. package/dist/state.d.mts +109 -0
  36. package/dist/state.d.ts +109 -0
  37. package/dist/state.js +1 -0
  38. package/dist/state.mjs +1 -0
  39. package/dist/style.d.mts +113 -0
  40. package/dist/style.d.ts +113 -0
  41. package/dist/style.js +1 -0
  42. package/dist/style.mjs +1 -0
  43. package/dist/types-DOAdFFJB.d.mts +330 -0
  44. package/dist/types-DOAdFFJB.d.ts +330 -0
  45. package/dist/types.d.mts +3 -0
  46. package/dist/types.d.ts +3 -0
  47. package/dist/types.js +1 -0
  48. package/dist/types.mjs +0 -0
  49. package/package.json +65 -2
  50. package/dist/index.global.js +0 -35
package/README.md CHANGED
@@ -1,79 +1,182 @@
1
1
  # Elit
2
2
 
3
- ⚡ A lightweight, zero-dependency library for building reactive web applications with direct DOM manipulation.
3
+ ⚡ A lightweight TypeScript framework with built-in dev server, HMR, routing, and reactive state management. Minimal dependencies, maximum developer experience.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/elit.svg)](https://www.npmjs.com/package/elit)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
- [![Bundle Size](https://img.shields.io/badge/bundle%20size-~10KB%20gzipped-success)](https://bundlephobia.com/package/elit)
7
+ [![Bundle Size](https://img.shields.io/badge/bundle%20size-lightweight-success)](https://bundlephobia.com/package/elit)
8
8
 
9
- > **Quick Links:** [Installation](#installation) | [Features](#features) | [Quick Start](#quick-start) | [API](#api) | [Examples](#examples) | [@elit/server](./server/README.md)
9
+ > **Quick Links:** [Installation](#installation) | [Features](#features) | [Quick Start](#quick-start) | [CLI Tools](#cli-tools) | [API](#api) | [Deployment](#deployment)
10
10
 
11
11
  ## Why Elit?
12
12
 
13
- - **🎯 Tiny Bundle Size**: Only ~10KB gzipped (30KB minified) - no framework bloat
14
- - **📦 Zero Dependencies**: Pure TypeScript, no external dependencies
13
+ - **🎯 Lightweight**: Minimal bundle size with tree-shaking support
15
14
  - **⚡ Lightning Fast**: Direct DOM manipulation - no virtual DOM overhead
16
15
  - **🔷 TypeScript First**: Full type safety and IntelliSense out of the box
17
- - **🔄 Reactive State**: Simple but powerful reactive state management
16
+ - **🔄 Reactive State**: Simple but powerful reactive state management with `createState` and `computed`
18
17
  - **🌲 Tree-Shakeable**: Import only what you need for optimal bundle size
19
- - **🚀 Modern Features**: Router, SSR, virtual scrolling, CSS-in-JS, and more
20
- - **🎨 Developer Experience**: Clean, intuitive API with excellent tooling support
18
+ - **🚀 Full-Stack Ready**: Built-in dev server, HMR, build tool, and REST API
19
+ - **🔥 Hot Module Replacement**: Instant development feedback with automatic HMR
20
+ - **🏗️ Build System**: Integrated esbuild for fast production builds
21
+ - **🌐 ServerRouter**: Built-in server-side routing for REST APIs
22
+ - **🔌 WebSocket Support**: Real-time communication via WebSocket
23
+ - **🎨 CSS-in-JS**: Type-safe styling with `CreateStyle`
24
+ - **🛣️ Client Router**: Hash and history mode routing with guards
25
+ - **📦 Modular Exports**: Import from specific paths (`elit/dom`, `elit/router`, `elit/state`)
21
26
 
22
27
  ## Installation
23
28
 
24
29
  ```bash
25
30
  npm install elit
31
+ ```
32
+
33
+ ## CLI Tools
34
+
35
+ Elit includes a powerful CLI for development and production:
36
+
37
+ ```bash
38
+ # Development server with HMR
39
+ npx elit dev
26
40
 
27
- # Optional: Install dev server with HMR
28
- npm install --save-dev @elit/server
41
+ # Production build
42
+ npx elit build
43
+
44
+ # Preview production build
45
+ npx elit preview
46
+ ```
47
+
48
+ ### Configuration
49
+
50
+ Create `elit.config.mjs` (or .ts, .js, .json) in your project root:
51
+
52
+ ```javascript
53
+ import { defineConfig } from 'elit';
54
+ import { resolve } from 'path';
55
+
56
+ export default defineConfig({
57
+ dev: {
58
+ port: 3000,
59
+ host: 'localhost',
60
+ root: './src',
61
+ basePath: '/',
62
+ open: true
63
+ },
64
+ build: {
65
+ entry: './src/main.ts',
66
+ outDir: './dist',
67
+ format: 'esm',
68
+ minify: true,
69
+ platform: 'browser',
70
+ basePath: '/app',
71
+ copy: [
72
+ {
73
+ from: 'index.html',
74
+ to: 'index.html',
75
+ transform: (content, config) => {
76
+ // Inject base tag from basePath
77
+ return content;
78
+ }
79
+ }
80
+ ]
81
+ },
82
+ preview: {
83
+ port: 4173,
84
+ root: './dist',
85
+ basePath: '/app'
86
+ }
87
+ });
29
88
  ```
30
89
 
31
90
  ## Features
32
91
 
33
- ### Core Library (elit)
92
+ ### Frontend Framework
34
93
 
35
- - 🎯 **Ultra Lightweight**: Just 30KB minified, ~10KB gzipped - optimized for performance
94
+ - 🎯 **Ultra Lightweight**: Just 30KB minified, ~10KB gzipped
36
95
  - ⚡ **Reactive State**: Built-in reactive state management with `createState`
37
96
  - 🔄 **Computed Values**: Automatic dependency tracking with `computed`
38
- - 🌐 **Shared State**: Real-time state sync with `@elit/server` (optional)
39
- - 🎨 **CSS-in-JS**: Type-safe styling with `CreateStyle` - full CSS features support
97
+ - 🎨 **CSS-in-JS**: Type-safe styling with `CreateStyle`
40
98
  - 🛣️ **Client-Side Router**: Hash and history mode routing with dynamic parameters
41
- - 📱 **Virtual Scrolling**: Handle 100k+ items efficiently with built-in virtual list
99
+ - 📱 **Virtual Scrolling**: Handle 100k+ items efficiently
42
100
  - 🖥️ **SSR Support**: Full server-side rendering capabilities
43
- - 🎭 **SVG & MathML**: Complete support for SVG and MathML elements (100+ elements)
44
- - 🔧 **Performance Utilities**: Throttle, debounce, batch rendering, and chunked rendering
45
- - 📦 **Tree-Shakeable**: Import only what you need - excellent for bundle optimization
46
- - 🎮 **DOM Utilities**: Convenient helper functions for common DOM operations
47
- - 🔌 **No Build Required**: Works directly in browsers via CDN
48
-
49
- ### Development Server (@elit/server)
50
-
51
- - **Hot Module Replacement (HMR)**: Instant updates without page refresh
52
- - 🌐 **REST API Router**: Built-in routing system with regex parameters
53
- - 🔧 **Middleware Stack**: CORS, logging, error handling, rate limiting, compression, security headers
54
- - 🔄 **Shared State Sync**: Real-time WebSocket state synchronization
55
- - 📊 **WebSocket Support**: Built-in WebSocket server for real-time features
56
- - 📁 **Static File Server**: Serves your application files with MIME type detection
57
- - 🎯 **Zero Config**: Works out of the box with sensible defaults
58
- - 🛠️ **CLI Tool**: Simple command-line interface (`elit-dev`)
59
- - 📦 **Lightweight**: Minimal dependencies (chokidar, ws, mime-types)
101
+ - 🎭 **SVG & MathML**: Complete support for all elements
102
+ - 🔧 **Performance Utilities**: Throttle, debounce, batch rendering
103
+ - 📦 **Tree-Shakeable**: Import only what you need
104
+ - 🎮 **DOM Utilities**: Convenient helper functions
105
+
106
+ ### Development Tools
107
+
108
+ - 🔥 **Hot Module Replacement**: Instant development feedback with automatic reload
109
+ - 🏗️ **Build System**: Integrated esbuild for fast production builds
110
+ - 🌐 **ServerRouter**: Built-in REST API routing for server-side logic
111
+ - 🔧 **Middleware Support**: Add custom middleware to the ServerRouter
112
+ - 🔌 **WebSocket Server**: Built-in WebSocket support for real-time features
113
+ - 📁 **Static File Server**: Efficient static file serving with proper MIME types
114
+ - 🎯 **Smart Defaults**: Works with minimal configuration
115
+ - 📦 **TypeScript Compilation**: Automatic TypeScript compilation with esbuild
60
116
 
61
117
  ## Quick Start
62
118
 
63
- ### Development Server with HMR
64
-
65
- Get started instantly with hot module replacement:
119
+ ### 1. Create Your Project
66
120
 
67
121
  ```bash
68
- # Install Elit and dev server
122
+ # Create a new directory
123
+ mkdir my-elit-app
124
+ cd my-elit-app
125
+
126
+ # Initialize package.json
127
+ npm init -y
128
+
129
+ # Install Elit
69
130
  npm install elit
70
- npm install --save-dev @elit/server
131
+ ```
71
132
 
72
- # Start dev server
73
- npx elit-dev
133
+ ### 2. Create Your App
134
+
135
+ Create `src/main.ts`:
136
+
137
+ ```typescript
138
+ import { div, h1, button, createState, reactive, dom } from 'elit';
139
+
140
+ const count = createState(0);
141
+
142
+ const app = div({ className: 'app' },
143
+ h1('Hello Elit! 🚀'),
144
+ reactive(count, (value) =>
145
+ button({
146
+ onclick: () => count.value++,
147
+ className: 'btn'
148
+ }, `Count: ${value}`)
149
+ )
150
+ );
151
+
152
+ // Render to DOM
153
+ dom.render('#app', app);
74
154
  ```
75
155
 
76
- Your app will automatically reload when you make changes!
156
+ Create `index.html`:
157
+
158
+ ```html
159
+ <!DOCTYPE html>
160
+ <html lang="en">
161
+ <head>
162
+ <meta charset="UTF-8">
163
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
164
+ <title>Elit App</title>
165
+ </head>
166
+ <body>
167
+ <div id="app"></div>
168
+ <script type="module" src="src/main.ts"></script>
169
+ </body>
170
+ </html>
171
+ ```
172
+
173
+ ### 3. Start Development Server
174
+
175
+ ```bash
176
+ npx elit dev
177
+ ```
178
+
179
+ Your app will automatically reload when you make changes with HMR!
77
180
 
78
181
  ### NPM Installation
79
182
 
@@ -82,7 +185,7 @@ npm install elit
82
185
  ```
83
186
 
84
187
  ```typescript
85
- import { div, h1, p, button, createState, reactive, domNode } from 'elit';
188
+ import { div, h1, p, button, createState, reactive, dom } from 'elit';
86
189
 
87
190
  // Create reactive state
88
191
  const count = createState(0);
@@ -100,7 +203,7 @@ const app = div({ className: 'app' },
100
203
  );
101
204
 
102
205
  // Render to DOM
103
- domNode.render('#app', app);
206
+ dom.render('#app', app);
104
207
  ```
105
208
 
106
209
  ### CDN Usage
@@ -114,7 +217,7 @@ domNode.render('#app', app);
114
217
  <body>
115
218
  <div id="app"></div>
116
219
  <script>
117
- const { div, h1, button, createState, reactive, domNode } = window;
220
+ const { div, h1, button, createState, reactive, dom } = window;
118
221
 
119
222
  const count = createState(0);
120
223
  const app = div(
@@ -124,7 +227,7 @@ domNode.render('#app', app);
124
227
  )
125
228
  );
126
229
 
127
- domNode.render('#app', app);
230
+ dom.render('#app', app);
128
231
  </script>
129
232
  </body>
130
233
  </html>
@@ -165,106 +268,142 @@ const deepState = createState({ nested: { value: 1 } }, { deep: true });
165
268
  ### Reactive Rendering
166
269
 
167
270
  ```typescript
168
- import { reactive, text, bindValue } from 'elit';
271
+ import { reactive, text, bindValue, bindChecked } from 'elit';
169
272
 
170
273
  const message = createState('Hello');
274
+ const isEnabled = createState(false);
171
275
 
172
276
  // Reactive element - re-renders when state changes
173
277
  const display = reactive(message, (value) =>
174
278
  div({ className: 'message' }, value)
175
279
  );
176
280
 
177
- // Reactive text
281
+ // Reactive text node
178
282
  const label = text(message);
179
283
 
180
284
  // Two-way binding for inputs
181
285
  const inputEl = input({ type: 'text', ...bindValue(message) });
286
+ const checkbox = input({ type: 'checkbox', ...bindChecked(isEnabled) });
182
287
  ```
183
288
 
184
289
  ### Shared State (Real-time Sync)
185
290
 
186
- **Requires `@elit/server`** - Shared state syncs automatically between backend and frontend via WebSocket:
291
+ Shared state automatically syncs between server and client via WebSocket:
292
+
293
+ **Client-side:**
187
294
 
188
295
  ```typescript
189
296
  import { createSharedState, reactive } from 'elit';
190
297
 
191
- // Create shared state (auto-connects to @elit/server)
298
+ // Create shared state (auto-connects to WebSocket server)
192
299
  const counter = createSharedState('counter', 0);
193
- const todos = createSharedState('todos', []);
300
+ const users = createSharedState('users', []);
194
301
 
195
302
  // Use with reactive rendering
196
303
  const app = div(
197
304
  reactive(counter.state, value =>
198
305
  div(`Counter: ${value}`)
199
306
  ),
200
- button({ onclick: () => counter.value++ }, 'Increment')
307
+ button({ onclick: () => counter.set(counter.state.value + 1) }, 'Increment')
201
308
  );
202
309
 
203
310
  // Listen to changes
204
- counter.onChange((newValue, oldValue) => {
205
- console.log(`${oldValue} ${newValue}`);
311
+ counter.onChange((newValue) => {
312
+ console.log('Counter changed to:', newValue);
206
313
  });
207
314
 
208
- // Update from any client - syncs to all
209
- counter.value++;
315
+ // Update from any client - automatically syncs to all connected clients
316
+ counter.set(10);
210
317
  ```
211
318
 
212
- **Backend (Node.js with @elit/server):**
319
+ **Server-side:**
213
320
 
214
- ```javascript
215
- const { createDevServer } = require('@elit/server');
321
+ ```typescript
322
+ import { createDevServer, StateManager } from 'elit';
216
323
 
217
324
  const server = createDevServer({ port: 3000 });
218
325
 
219
- // Create matching shared states
220
- const counter = server.state.create('counter', { initial: 0 });
221
- const todos = server.state.create('todos', { initial: [] });
222
-
223
- // Listen to changes
224
- counter.onChange((newValue, oldValue) => {
225
- console.log(`Counter: ${oldValue} → ${newValue}`);
226
- });
227
-
228
- // Update from backend - syncs to all clients
229
- counter.value++;
326
+ // StateManager is built-in and handles WebSocket connections
327
+ // All clients with matching shared state keys will sync automatically
230
328
  ```
231
329
 
232
- ### @elit/server - Development Server
330
+ ### Development Server with REST API
233
331
 
234
- Full-featured development server with HMR, REST API, and real-time features:
332
+ Elit includes a built-in development server with HMR, WebSocket support, and REST API routing:
235
333
 
236
- ```javascript
237
- const { createDevServer, Router, cors, logger } = require('@elit/server');
334
+ **Server Configuration (server.ts):**
335
+
336
+ ```typescript
337
+ import { createDevServer, ServerRouter, cors, logger, json } from 'elit';
238
338
 
239
339
  // Create REST API router
240
- const api = new Router();
340
+ const api = new ServerRouter();
241
341
 
242
342
  // Add middleware
243
- api.use(cors());
343
+ api.use(cors({ origin: '*', methods: ['GET', 'POST', 'PUT', 'DELETE'] }));
244
344
  api.use(logger());
245
345
 
246
- // Define routes
346
+ // Define API routes with helper functions
247
347
  api.get('/api/users', (ctx) => {
248
- return { success: true, users: [...] };
348
+ json(ctx, { success: true, users: [] });
249
349
  });
250
350
 
251
- api.post('/api/users', (ctx) => {
351
+ api.post('/api/users', async (ctx) => {
252
352
  const user = ctx.body;
253
- return { success: true, user };
353
+ json(ctx, { success: true, user });
254
354
  });
255
355
 
256
- // Create server with API
356
+ // Create development server
257
357
  const server = createDevServer({
258
358
  port: 3000,
259
- root: __dirname,
260
- api,
261
- logging: true
359
+ root: './src',
360
+ open: true,
361
+ router: api
362
+ });
363
+ ```
364
+
365
+ **Available Middleware:**
366
+
367
+ ```typescript
368
+ import {
369
+ cors, // CORS headers
370
+ logger, // Request logging
371
+ errorHandler, // Error handling
372
+ rateLimit, // Rate limiting
373
+ bodyLimit, // Request body size limit
374
+ cacheControl, // Cache headers
375
+ compress, // Gzip compression
376
+ security // Security headers
377
+ } from 'elit';
378
+
379
+ // Example usage
380
+ api.use(cors({ origin: '*' }));
381
+ api.use(logger({ format: 'detailed' }));
382
+ api.use(rateLimit({ max: 100, windowMs: 60000 }));
383
+ api.use(bodyLimit({ limit: 1024 * 1024 })); // 1MB
384
+ api.use(compress());
385
+ api.use(security());
386
+ ```
387
+
388
+ **Helper Functions:**
389
+
390
+ ```typescript
391
+ import { json, sendText, html, status } from 'elit';
392
+
393
+ api.get('/api/data', (ctx) => {
394
+ json(ctx, { message: 'Hello' }); // JSON response
395
+ });
396
+
397
+ api.get('/text', (ctx) => {
398
+ sendText(ctx, 'Hello World'); // Text response
262
399
  });
263
400
 
264
- // Access shared state
265
- const counter = server.state.create('counter', {
266
- initial: 0,
267
- validate: (value) => typeof value === 'number'
401
+ api.get('/page', (ctx) => {
402
+ html(ctx, '<h1>Hello</h1>'); // HTML response
403
+ });
404
+
405
+ api.get('/error', (ctx) => {
406
+ status(ctx, 404, 'Not Found'); // Custom status
268
407
  });
269
408
  ```
270
409
 
@@ -272,41 +411,16 @@ const counter = server.state.create('counter', {
272
411
 
273
412
  ```bash
274
413
  # Start dev server
275
- npx elit-dev
414
+ npx elit dev
276
415
 
277
416
  # Custom port
278
- npx elit-dev --port 8080
417
+ npx elit dev --port 8080
279
418
 
280
419
  # Custom root directory
281
- npx elit-dev --root ./public
420
+ npx elit dev --root ./public
282
421
 
283
422
  # Disable auto-open browser
284
- npx elit-dev --no-open
285
-
286
- # Silent mode
287
- npx elit-dev --silent
288
- ```
289
-
290
- **Middleware:**
291
-
292
- ```javascript
293
- const {
294
- cors, // CORS headers
295
- logger, // Request logging
296
- errorHandler, // Error handling
297
- rateLimit, // Rate limiting
298
- bodyLimit, // Request body size limit
299
- cacheControl, // Cache headers
300
- compress, // Gzip compression
301
- security // Security headers
302
- } = require('@elit/server');
303
-
304
- api.use(cors({ origin: '*' }));
305
- api.use(logger());
306
- api.use(rateLimit({ max: 100, window: 60000 }));
307
- api.use(bodyLimit(1024 * 1024)); // 1MB
308
- api.use(compress());
309
- api.use(security());
423
+ npx elit dev --no-open
310
424
  ```
311
425
 
312
426
  ### Server-Side Rendering
@@ -376,7 +490,15 @@ const btn = button({ className: buttonClass }, 'Click me');
376
490
  ### Performance Utilities
377
491
 
378
492
  ```typescript
379
- import { batchRender, renderChunked, createVirtualList, throttle, debounce } from 'elit';
493
+ import {
494
+ batchRender,
495
+ renderChunked,
496
+ createVirtualList,
497
+ throttle,
498
+ debounce,
499
+ lazy,
500
+ cleanupUnused
501
+ } from 'elit';
380
502
 
381
503
  // Batch render multiple elements
382
504
  batchRender('#container', elements);
@@ -386,7 +508,7 @@ renderChunked('#container', largeArray, 5000, (current, total) => {
386
508
  console.log(`Rendered ${current}/${total}`);
387
509
  });
388
510
 
389
- // Virtual scrolling
511
+ // Virtual scrolling for 100k+ items
390
512
  const virtualList = createVirtualList(
391
513
  container,
392
514
  items,
@@ -395,9 +517,61 @@ const virtualList = createVirtualList(
395
517
  5 // buffer size
396
518
  );
397
519
 
520
+ // Lazy loading components
521
+ const LazyComponent = lazy(() => import('./HeavyComponent'));
522
+
398
523
  // Throttle and debounce
399
524
  const throttledFn = throttle(handleScroll, 100);
400
525
  const debouncedFn = debounce(handleInput, 300);
526
+
527
+ // Cleanup unused DOM elements
528
+ const cleaned = cleanupUnused(rootElement);
529
+ console.log(`Cleaned ${cleaned} elements`);
530
+ ```
531
+
532
+ ### Additional Features
533
+
534
+ **DOM Utilities:**
535
+
536
+ ```typescript
537
+ import { doc, el, els, createEl, elId, elClass, fragment } from 'elit';
538
+
539
+ // Query selectors
540
+ const element = el('.my-class'); // querySelector
541
+ const elements = els('.my-class'); // querySelectorAll
542
+ const byId = elId('my-id'); // getElementById
543
+ const byClass = elClass('my-class'); // getElementsByClassName
544
+
545
+ // Create elements
546
+ const div = createEl('div'); // createElement
547
+ const frag = fragment(); // createDocumentFragment
548
+
549
+ // Access document
550
+ doc.title = 'New Title';
551
+ ```
552
+
553
+ **Effect System:**
554
+
555
+ ```typescript
556
+ import { createState, effect } from 'elit';
557
+
558
+ const count = createState(0);
559
+
560
+ // Run side effects when state changes
561
+ effect(() => {
562
+ console.log('Count is now:', count.value);
563
+ });
564
+ ```
565
+
566
+ **Reactive As (Advanced):**
567
+
568
+ ```typescript
569
+ import { reactiveAs } from 'elit';
570
+
571
+ // Use different reactive context
572
+ const display = reactiveAs(customState, customContext, (value) =>
573
+ div(value)
574
+ );
401
575
  ```
402
576
 
403
577
  ### JSON Rendering
@@ -428,7 +602,7 @@ renderVNode('#app', {
428
602
  ### Head Management
429
603
 
430
604
  ```typescript
431
- import { setTitle, addMeta, addLink, addStyle, renderToHead } from 'elit';
605
+ import { setTitle, addMeta, addLink, addStyle } from 'elit';
432
606
 
433
607
  setTitle('My App');
434
608
  addMeta({ name: 'description', content: 'My awesome app' });
@@ -436,27 +610,6 @@ addLink({ rel: 'stylesheet', href: '/styles.css' });
436
610
  addStyle('body { margin: 0; }');
437
611
  ```
438
612
 
439
- ### DOM Utilities
440
-
441
- Elit provides convenient DOM utility functions for common operations:
442
-
443
- ```typescript
444
- import { doc, el, els, createEl, elId, elClass, fragment } from 'elit';
445
-
446
- // Query selectors (bound to document)
447
- const element = el('.my-class'); // querySelector
448
- const elements = els('.my-class'); // querySelectorAll
449
- const byId = elId('my-id'); // getElementById
450
- const byClass = elClass('my-class'); // getElementsByClassName
451
-
452
- // Create elements
453
- const div = createEl('div'); // createElement
454
- const frag = fragment(); // createDocumentFragment
455
-
456
- // Access document object
457
- doc.title = 'New Title';
458
- ```
459
-
460
613
  ## Available Elements
461
614
 
462
615
  ### HTML Elements (100+)
@@ -516,7 +669,7 @@ When loaded via script tag, all exports are available on the `window` object:
516
669
  ```html
517
670
  <script src="https://unpkg.com/elit@latest/dist/index.global.js"></script>
518
671
  <script>
519
- const { div, span, createState, domNode } = window;
672
+ const { div, span, createState, dom } = window;
520
673
  // or use DomLib global namespace
521
674
  const app = DomLib.div('Hello');
522
675
  </script>
@@ -599,100 +752,165 @@ const users: State<User[]> = createState([]);
599
752
  // Full IntelliSense support for all 100+ HTML elements
600
753
  ```
601
754
 
602
- ## Comparison with Other Libraries
755
+ ## Deployment
603
756
 
604
- | Feature | Elit | React | Vue | Svelte |
605
- |---------|------|-------|-----|--------|
606
- | Bundle Size (min) | 30KB | ~140KB | ~90KB | ~15KB* |
607
- | Zero Dependencies | ✅ | ❌ | ❌ | ✅ |
608
- | Virtual DOM | ❌ | ✅ | ✅ | ❌ |
609
- | TypeScript First | ✅ | ✅ | ✅ | ✅ |
610
- | Built-in Router | ✅ | ❌ | ❌ | ❌ |
611
- | Built-in State | ✅ | ❌ | ✅ | ✅ |
612
- | SSR Support | ✅ | ✅ | ✅ | ✅ |
613
- | Learning Curve | Easy | Medium | Medium | Easy |
757
+ Deploy your Elit application to production:
614
758
 
615
- *Svelte requires compilation
759
+ ### Build for Production
616
760
 
617
- ## Packages
761
+ ```bash
762
+ # Build your app
763
+ npx elit build
618
764
 
619
- This monorepo contains two packages:
765
+ # Preview production build
766
+ npx elit preview
767
+ ```
620
768
 
621
- ### elit
622
- [![npm version](https://img.shields.io/npm/v/elit.svg)](https://www.npmjs.com/package/elit)
769
+ ### Deploy to Vercel
623
770
 
624
- The core library for building reactive web applications.
771
+ ```bash
772
+ npm i -g vercel
773
+ npm run build
774
+ vercel --prod
775
+ ```
776
+
777
+ ### Deploy to Netlify
625
778
 
626
779
  ```bash
627
- npm install elit
780
+ npm i -g netlify-cli
781
+ npm run build
782
+ netlify deploy --prod --dir=dist
628
783
  ```
629
784
 
630
- ### @elit/server
631
- [![npm version](https://img.shields.io/npm/v/@elit/server.svg)](https://www.npmjs.com/package/@elit/server)
785
+ ### Deploy to GitHub Pages
786
+
787
+ Create `.github/workflows/deploy.yml`:
788
+
789
+ ```yaml
790
+ name: Deploy to GitHub Pages
791
+
792
+ on:
793
+ push:
794
+ branches: [main]
795
+
796
+ jobs:
797
+ deploy:
798
+ runs-on: ubuntu-latest
799
+ steps:
800
+ - uses: actions/checkout@v3
801
+ - uses: actions/setup-node@v3
802
+ with:
803
+ node-version: 18
804
+ - run: npm install
805
+ - run: npm run build
806
+ - uses: peaceiris/actions-gh-pages@v3
807
+ with:
808
+ github_token: ${{ secrets.GITHUB_TOKEN }}
809
+ publish_dir: ./dist
810
+ ```
632
811
 
633
- Development server with HMR, REST API, and real-time state synchronization.
812
+ ### Docker Deployment
634
813
 
635
- ```bash
636
- npm install --save-dev @elit/server
814
+ ```dockerfile
815
+ FROM node:18-alpine AS builder
816
+ WORKDIR /app
817
+ COPY package*.json ./
818
+ RUN npm install
819
+ COPY . .
820
+ RUN npm run build
821
+
822
+ FROM nginx:alpine
823
+ COPY --from=builder /app/dist /usr/share/nginx/html
824
+ EXPOSE 80
825
+ CMD ["nginx", "-g", "daemon off;"]
826
+ ```
827
+
828
+ ### Environment Variables
829
+
830
+ Create `.env.production`:
831
+
832
+ ```env
833
+ VITE_API_URL=https://api.example.com
834
+ VITE_ENV=production
637
835
  ```
638
836
 
639
- [View @elit/server documentation →](./server/README.md)
837
+ Access in your code:
838
+
839
+ ```typescript
840
+ const apiUrl = import.meta.env.VITE_API_URL;
841
+ const isProd = import.meta.env.PROD;
842
+ ```
843
+
844
+ ## Comparison with Other Frameworks
845
+
846
+ | Feature | Elit | Vite + React | Next.js | SvelteKit |
847
+ |---------|----------|--------------|---------|-----------|
848
+ | Runtime Size | Lightweight | ~140KB+ | ~200KB+ | ~15KB* |
849
+ | Dependencies | Minimal (5) | Many | Many | Many |
850
+ | Dev Server | ✅ Built-in | ✅ Vite | ✅ Built-in | ✅ Built-in |
851
+ | HMR | ✅ | ✅ | ✅ | ✅ |
852
+ | Build Tool | ✅ esbuild | ✅ Vite | ✅ Turbopack | ✅ Vite |
853
+ | REST API | ✅ Built-in | ❌ | ✅ | ✅ |
854
+ | Middleware | ✅ Built-in | ❌ | ✅ | ✅ |
855
+ | WebSocket | ✅ Built-in | ❌ | ❌ | ❌ |
856
+ | Shared State | ✅ Built-in | ❌ | ❌ | ❌ |
857
+ | TypeScript | ✅ | ✅ | ✅ | ✅ |
858
+ | SSR | ✅ | ❌ | ✅ | ✅ |
859
+ | Learning Curve | Easy | Medium | Medium | Easy |
860
+
861
+ *Svelte requires compilation step
640
862
 
641
863
  ## Documentation
642
864
 
643
- - 📚 [Documentation Hub](./docs/README.md)
644
- - ⚡ [Quick Start Guide](./docs/QUICK_START.md) - Get started in 5 minutes
645
- - 📖 [API Reference](./docs/API.md) - Complete API documentation
646
- - ⚖️ [Comparison Guide](./docs/COMPARISON.md) - Compare with React, Vue, Svelte
647
- - 🔄 [Migration Guide](./docs/MIGRATION.md) - Migrate from other frameworks
648
- - 🤝 [Contributing Guide](./CONTRIBUTING.md) - Contribute to Elit
865
+ - 📚 [Full Documentation](https://d-osc.github.io/elit)
866
+ - ⚡ [Quick Start](https://d-osc.github.io/elit#/docs)
867
+ - 📖 [API Reference](https://d-osc.github.io/elit#/api)
868
+ - 🎮 [Interactive Examples](https://d-osc.github.io/elit#/examples)
649
869
 
650
870
  ## Changelog
651
871
 
652
- ### elit v0.1.0
872
+ ### Elit - Full-Stack Framework
873
+
874
+ **Major Changes:**
875
+ - 🚀 **Integrated Build System**: Built-in esbuild with automatic client/server code separation
876
+ - 🔥 **CLI Tools**: New commands - `npx elit dev`, `npx elit build`, `npx elit preview`
877
+ - 🏗️ **Zero Config**: Works out of the box with optional `elit.config.mjs`
878
+ - 🌐 **REST API Router**: Server-side routing with full middleware stack
879
+ - 🔄 **Shared State**: Real-time WebSocket state synchronization
880
+ - 🎯 **basePath Support**: Configure base paths for subdirectory deployments
881
+ - 🔐 **Environment Variables**: .env file support with VITE_ prefix
882
+ - 📦 **Gzip Compression**: Automatic compression for production builds
883
+ - 💾 **Cache Headers**: Smart caching for static assets
884
+ - ⚡ **Hot Module Replacement**: Instant development feedback
653
885
 
654
886
  **Core Library:**
655
- - 🎉 Initial release
656
- - ⚡ Optimized bundle size (50% reduction from initial builds - 30KB minified)
657
- - 🚀 Full TypeScript support with complete type definitions
658
- - 🎨 Complete CSS-in-JS with CreateStyle
659
- - 🛣️ Client-side router with navigation guards
660
- - 📦 Tree-shakeable ES modules
887
+ - 🎯 Ultra lightweight (~10KB gzipped)
888
+ - ⚡ Reactive state management
889
+ - 🎨 CSS-in-JS with CreateStyle
890
+ - 🛣️ Client-side router
891
+ - 📱 Virtual scrolling
892
+ - 🖥️ SSR support
661
893
  - 🎭 100+ HTML, SVG, and MathML elements
662
- - 🔧 Performance utilities (throttle, debounce, virtual scrolling)
663
- - 🖥️ SSR capabilities with renderToString
664
- - 🎮 DOM utility functions
665
- - 🌐 Shared state integration with @elit/server
666
-
667
- **New Package - @elit/server v0.1.0:**
668
- - ⚡ Hot Module Replacement (HMR) with WebSocket
669
- - 🌐 REST API router with regex-based parameters
670
- - 🔧 Middleware stack (CORS, logging, error handling, rate limiting, compression, security)
671
- - 🔄 Real-time shared state synchronization
672
- - 📊 Built-in WebSocket server
673
- - 📁 Static file server with MIME type detection
674
- - 🛠️ CLI tool (`elit-dev`)
675
- - 🎯 Zero-config with sensible defaults
894
+ - 🔧 Performance utilities
895
+ - 📦 Tree-shakeable ES modules
676
896
 
677
897
  ## Examples
678
898
 
679
- Check out the example applications in the repository:
899
+ Example applications demonstrating Elit features:
680
900
 
681
- - **[HMR Example](./server/example/hmr-example.html)** - Hot Module Replacement demo
682
- - **[REST API Example](./server/example/api-example.js)** - Full REST API with todos
683
- - **[Shared State (Vanilla)](./server/example/state-demo.html)** - Real-time state sync without Elit
684
- - **[Shared State (Elit)](./server/example/elit-state-demo.html)** - Real-time state with Elit reactive system
685
- - **[Todo App](./examples)** - Complete todo application (coming soon)
901
+ - 📖 **[Documentation Site](./docs)** - Full-featured docs site with i18n and blog
902
+ - 🎯 **[Counter App](./examples/counter)** - Simple reactive counter
903
+ - **[Todo App](./examples/todo)** - Todo list with state management
904
+ - 🎨 **[Styled Components](./examples/styled)** - CSS-in-JS examples
686
905
 
687
- [View all examples →](./server/example/README.md)
906
+ [View all examples →](./examples)
688
907
 
689
908
  ## Links
690
909
 
691
- - 📦 [npm - elit](https://www.npmjs.com/package/elit)
692
- - 📦 [npm - @elit/server](https://www.npmjs.com/package/@elit/server)
693
- - 🐙 [GitHub Repository](https://github.com/oangsa/elit)
694
- - 📚 Documentation (coming soon)
695
- - 💬 Discord Community (coming soon)
910
+ - 📦 [npm Package](https://www.npmjs.com/package/elit)
911
+ - 🐙 [GitHub Repository](https://github.com/d-osc/elit)
912
+ - 📚 [Documentation](https://d-osc.github.io/elit)
913
+ - 💬 Community & Issues: [GitHub Discussions](https://github.com/d-osc/elit/discussions)
696
914
 
697
915
  ## Contributing
698
916