elit 3.5.0 → 3.5.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 (70) hide show
  1. package/README.md +88 -11
  2. package/dist/build.d.mts +1 -1
  3. package/dist/cli.d.ts +8 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +223 -109
  6. package/dist/config.d.mts +2 -4
  7. package/dist/config.d.ts +1 -3
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js.map +1 -1
  10. package/dist/config.mjs.map +1 -1
  11. package/dist/coverage.d.mts +1 -1
  12. package/dist/desktop-cli.d.ts.map +1 -1
  13. package/dist/http.d.ts.map +1 -1
  14. package/dist/http.js +5 -4
  15. package/dist/http.js.map +1 -1
  16. package/dist/http.mjs +5 -4
  17. package/dist/http.mjs.map +1 -1
  18. package/dist/https.js +5 -4
  19. package/dist/https.js.map +1 -1
  20. package/dist/https.mjs +5 -4
  21. package/dist/https.mjs.map +1 -1
  22. package/dist/index.d.mts +1 -1
  23. package/dist/index.js +20 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +20 -1
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/native.js +20 -1
  28. package/dist/native.js.map +1 -1
  29. package/dist/native.mjs +20 -1
  30. package/dist/native.mjs.map +1 -1
  31. package/dist/{server-DpnTyF7I.d.mts → server--YFoC6ln.d.mts} +27 -0
  32. package/dist/{server-BU71N4fk.d.ts → server-DacsdjFJ.d.ts} +27 -0
  33. package/dist/server.d.mts +1 -1
  34. package/dist/server.d.ts.map +1 -1
  35. package/dist/server.js +141 -52
  36. package/dist/server.js.map +1 -1
  37. package/dist/server.mjs +141 -52
  38. package/dist/server.mjs.map +1 -1
  39. package/dist/state.d.ts.map +1 -1
  40. package/dist/state.js +20 -1
  41. package/dist/state.js.map +1 -1
  42. package/dist/state.mjs +20 -1
  43. package/dist/state.mjs.map +1 -1
  44. package/dist/types.d.mts +28 -1
  45. package/dist/types.d.ts +27 -0
  46. package/dist/types.d.ts.map +1 -1
  47. package/dist/types.js.map +1 -1
  48. package/dist/wapk-cli.d.ts +0 -1
  49. package/dist/wapk-cli.d.ts.map +1 -1
  50. package/dist/ws.d.mts +1 -1
  51. package/dist/ws.d.ts +1 -1
  52. package/dist/ws.d.ts.map +1 -1
  53. package/dist/ws.js +9 -4
  54. package/dist/ws.js.map +1 -1
  55. package/dist/ws.mjs +9 -4
  56. package/dist/ws.mjs.map +1 -1
  57. package/dist/wss.js +14 -8
  58. package/dist/wss.js.map +1 -1
  59. package/dist/wss.mjs +14 -8
  60. package/dist/wss.mjs.map +1 -1
  61. package/package.json +1 -1
  62. package/src/cli.ts +26 -8
  63. package/src/config.ts +1 -3
  64. package/src/desktop-cli.ts +0 -9
  65. package/src/http.ts +5 -4
  66. package/src/server.ts +182 -56
  67. package/src/state.ts +25 -1
  68. package/src/types.ts +30 -0
  69. package/src/wapk-cli.ts +20 -55
  70. package/src/ws.ts +12 -5
package/README.md CHANGED
@@ -9,7 +9,7 @@ The package is split by runtime. Browser-facing APIs live in `elit` and the clie
9
9
  If you are generating or editing code for Elit, follow these rules first:
10
10
 
11
11
  - Use `elit` or the client subpaths for browser UI code.
12
- - Use `elit/server` for HTTP routes, middleware, dev server, preview server, and server-side shared state.
12
+ - Use `elit/server` for HTTP routes, WebSocket endpoints, middleware, dev server, preview server, and server-side shared state.
13
13
  - Use `elit/desktop` only inside `elit desktop ...` runtime. Those APIs are injected by the native desktop runtime and are not normal browser globals.
14
14
  - Use `elit/build` for programmatic bundling.
15
15
  - Use `elit/database` for the VM-backed file database helpers.
@@ -62,7 +62,7 @@ Use this table as the import map for generated code.
62
62
  | `elit/state` | Reactive state and render helpers | `createState`, `computed`, `reactive`, `text`, `bindValue`, `bindChecked`, `createSharedState` |
63
63
  | `elit/style` | CSS generation and injection | `CreateStyle`, `styles`, `renderStyle`, `injectStyle`, `addClass`, `addTag` |
64
64
  | `elit/router` | Client-side routing | `createRouter`, `createRouterView`, `routerLink` |
65
- | `elit/server` | HTTP router, dev server, middleware, shared server state | `ServerRouter`, `createDevServer`, `cors`, `logger`, `rateLimit`, `compress`, `security`, `StateManager` |
65
+ | `elit/server` | HTTP router, dev server, middleware, WebSocket endpoints, shared server state | `ServerRouter`, `createDevServer`, `cors`, `logger`, `rateLimit`, `compress`, `security`, `StateManager` |
66
66
  | `elit/build` | Programmatic build API | `build` |
67
67
  | `elit/desktop` | Native desktop window APIs | `createWindow`, `createWindowServer`, `onMessage`, `windowQuit`, `windowSetTitle`, `windowEval` |
68
68
  | `elit/database` | VM-backed file database | `Database`, `create`, `read`, `save`, `update`, `rename`, `remove` |
@@ -255,14 +255,14 @@ Useful flags:
255
255
  - `elit native generate android ./src/native-screen.ts --name HomeScreen --package com.example.app`
256
256
  - `elit native generate ios ./src/native-screen.ts --out ./ios/HomeScreen.swift --no-preview`
257
257
  - `elit native generate ir ./src/native-screen.ts --platform android --export screen`
258
- - `elit wapk pack . --password-env WAPK_PASSWORD`
258
+ - `elit wapk pack . --password secret-123`
259
259
  - `elit wapk ./app.wapk --runtime node|bun|deno`
260
- - `elit wapk run ./app.wapk --password-env WAPK_PASSWORD --sync-interval 100 --watcher`
260
+ - `elit wapk run ./app.wapk --password secret-123 --sync-interval 100 --watcher`
261
261
  - `elit wapk pack . --include-deps`
262
- - `elit wapk inspect ./app.wapk --password-env WAPK_PASSWORD`
262
+ - `elit wapk inspect ./app.wapk --password secret-123`
263
263
  - `elit wapk extract ./app.wapk`
264
264
  - `elit desktop wapk ./app.wapk --runtime node|bun|deno --watcher`
265
- - `elit desktop wapk run ./app.wapk --runtime bun --password-env WAPK_PASSWORD`
265
+ - `elit desktop wapk run ./app.wapk --runtime bun --password secret-123`
266
266
 
267
267
  Desktop mode notes:
268
268
 
@@ -308,11 +308,11 @@ WAPK mode notes:
308
308
  - `elit desktop wapk <file.wapk>` and `elit desktop wapk run <file.wapk>` run packaged apps in desktop mode.
309
309
  - During run, the archive is expanded into a temporary work directory and changes are synced back to the same `.wapk` file.
310
310
  - Use `--sync-interval <ms>` for polling mode, or `--watcher` / `--use-watcher` for event-driven sync.
311
- - Use `--password` or, preferably, `--password-env` when packing, inspecting, extracting, or running a locked archive.
311
+ - Use `--password` when packing, inspecting, extracting, or running a locked archive.
312
312
  - `inspect` without credentials still reports whether the archive is locked, but it does not print the archive contents.
313
313
  - Locked archives stay encrypted when live sync writes changes back into the same `.wapk` file.
314
314
  - Configure package metadata in `elit.config.*` under `wapk`, and use `wapk.lock` when you want password-protected archives by default.
315
- - WAPK stays unlocked by default unless `wapk.lock.password`, `wapk.lock.passwordEnv`, `--password`, or `--password-env` is provided.
315
+ - WAPK stays unlocked by default unless `wapk.lock.password` or `--password` is provided.
316
316
  - See [docs/wapk.md](docs/wapk.md) for the full archive guide and `examples/wapk-example` for an end-to-end sample.
317
317
 
318
318
  ## Config File
@@ -388,7 +388,6 @@ The config shape is:
388
388
  desktop?: Record<string, unknown>;
389
389
  lock?: {
390
390
  password?: string;
391
- passwordEnv?: string;
392
391
  };
393
392
  };
394
393
  }
@@ -412,6 +411,17 @@ export default {
412
411
  basePath: '',
413
412
  ssr: () => documentShell,
414
413
  api,
414
+ ws: [
415
+ {
416
+ path: '/ws',
417
+ handler: ({ ws, query }) => {
418
+ ws.send(JSON.stringify({ type: 'connected', room: query.room || 'general' }));
419
+ ws.on('message', (message) => {
420
+ ws.send(message.toString());
421
+ });
422
+ },
423
+ },
424
+ ],
415
425
  },
416
426
  ],
417
427
  },
@@ -431,6 +441,14 @@ export default {
431
441
  root: './dist',
432
442
  index: './index.html',
433
443
  port: 4173,
444
+ ws: [
445
+ {
446
+ path: '/ws',
447
+ handler: ({ ws }) => {
448
+ ws.on('message', (message) => ws.send(message.toString()));
449
+ },
450
+ },
451
+ ],
434
452
  },
435
453
  test: {
436
454
  include: ['testing/unit/**/*.test.ts'],
@@ -471,12 +489,18 @@ export default {
471
489
  NODE_ENV: 'production',
472
490
  },
473
491
  lock: {
474
- passwordEnv: 'WAPK_PASSWORD',
492
+ password: 'secret-123',
475
493
  },
476
494
  },
477
495
  };
478
496
  ```
479
497
 
498
+ Notes:
499
+
500
+ - `dev.ws` and `preview.ws` register global WebSocket endpoints.
501
+ - `clients[].ws` registers client-specific endpoints and prefixes each path with that client's `basePath`.
502
+ - The internal Elit HMR and shared-state socket uses `/__elit_ws`, so do not reuse that path for custom endpoints.
503
+
480
504
  Important details:
481
505
 
482
506
  - `build` may be a single object or an array. If it is an array, all builds run sequentially.
@@ -486,7 +510,7 @@ Important details:
486
510
  - `desktop` config provides defaults for `elit desktop`, `elit desktop run`, `elit desktop build`, and `elit desktop wapk`. Use `desktop.entry` for hybrid defaults, `desktop.native.entry` for native defaults, and `desktop.mode` to choose which one runs by default.
487
511
  - `mobile` config provides defaults for `elit mobile init|sync|open|run|build`.
488
512
  - `wapk` config is loaded from `elit.config.*`, then package metadata is used as fallback.
489
- - `wapk.lock.passwordEnv` is the safest reusable way to protect archives without putting the password directly into shell history or committed config.
513
+ - `wapk.lock.password` is the config-level default for locked archives. Use `--password` when you want to supply unlock credentials at command time instead of writing them into config.
490
514
  - `wapk run` and `desktop wapk run` sync runtime file changes back into the same `.wapk` archive.
491
515
 
492
516
  ## Browser Patterns
@@ -620,6 +644,49 @@ const server = createDevServer({
620
644
  console.log(server.url);
621
645
  ```
622
646
 
647
+ ### Custom WebSocket Endpoints
648
+
649
+ Server:
650
+
651
+ ```ts
652
+ import { createDevServer } from 'elit/server';
653
+
654
+ const server = createDevServer({
655
+ root: '.',
656
+ open: false,
657
+ ws: [
658
+ {
659
+ path: '/ws',
660
+ handler: ({ ws, query }) => {
661
+ ws.send(JSON.stringify({ type: 'connected', room: query.room || 'general' }));
662
+
663
+ ws.on('message', (message) => {
664
+ ws.send(message.toString());
665
+ });
666
+ },
667
+ },
668
+ ],
669
+ });
670
+ ```
671
+
672
+ Client:
673
+
674
+ ```ts
675
+ const socket = new WebSocket(`ws://${location.host}/ws?room=general`);
676
+
677
+ socket.addEventListener('message', (event) => {
678
+ console.log(event.data);
679
+ });
680
+
681
+ socket.send('hello');
682
+ ```
683
+
684
+ Notes:
685
+
686
+ - Use `dev.ws` or `preview.ws` for global endpoints.
687
+ - Use `clients[].ws` when each client should expose its own endpoint under its `basePath`.
688
+ - Do not use `/__elit_ws`; Elit reserves that path for internal HMR and shared-state traffic.
689
+
623
690
  ### Shared State Between Server and Client
624
691
 
625
692
  Client:
@@ -801,6 +868,16 @@ npx elit test --coverage --coverage-reporter text,html
801
868
 
802
869
  The package also exports `elit/test`, `elit/test-runtime`, and `elit/test-reporter` for advanced use, but most users should stay on the CLI.
803
870
 
871
+ ## Changelog
872
+
873
+ Latest release notes live in [CHANGELOG.md](CHANGELOG.md).
874
+
875
+ Highlights in `v3.5.2`:
876
+
877
+ - Simplified WAPK locking to password-only credentials across config, CLI, and helper APIs.
878
+ - `wapk.lock` now accepts only `password` in `elit.config.*`.
879
+ - `elit wapk` and `elit desktop wapk` now accept only `--password` when opening locked archives.
880
+
804
881
  ## Good Defaults For Generated Code
805
882
 
806
883
  When writing new Elit code, these defaults are usually correct:
package/dist/build.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as BuildOptions, a as BuildResult } from './server-DpnTyF7I.mjs';
1
+ import { B as BuildOptions, a as BuildResult } from './server--YFoC6ln.mjs';
2
2
  import './http.mjs';
3
3
  import 'node:events';
4
4
  import './ws.mjs';
package/dist/cli.d.ts CHANGED
@@ -2,5 +2,12 @@
2
2
  /**
3
3
  * Main CLI for Elit
4
4
  */
5
- export {};
5
+ export declare function runDev(args: string[]): Promise<void>;
6
+ export declare function runBuild(args: string[]): Promise<void>;
7
+ export declare function runPreview(args: string[]): Promise<void>;
8
+ export declare function runTest(args: string[]): Promise<void>;
9
+ export declare function runDesktop(args: string[]): Promise<void>;
10
+ export declare function runMobile(args: string[]): Promise<void>;
11
+ export declare function runNative(args: string[]): Promise<void>;
12
+ export declare function runWapk(args: string[]): Promise<void>;
6
13
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG;AA6HH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBAqD1C;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,iBA2D5C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,iBAoF9C;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,iBA8C3C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,iBAO9C;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,iBAO7C;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,iBAO7C;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,iBAOzC"}