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.
- package/README.md +88 -11
- package/dist/build.d.mts +1 -1
- package/dist/cli.d.ts +8 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +223 -109
- package/dist/config.d.mts +2 -4
- package/dist/config.d.ts +1 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/config.mjs.map +1 -1
- package/dist/coverage.d.mts +1 -1
- package/dist/desktop-cli.d.ts.map +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +5 -4
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +5 -4
- package/dist/http.mjs.map +1 -1
- package/dist/https.js +5 -4
- package/dist/https.js.map +1 -1
- package/dist/https.mjs +5 -4
- package/dist/https.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -1
- package/dist/index.mjs.map +1 -1
- package/dist/native.js +20 -1
- package/dist/native.js.map +1 -1
- package/dist/native.mjs +20 -1
- package/dist/native.mjs.map +1 -1
- package/dist/{server-DpnTyF7I.d.mts → server--YFoC6ln.d.mts} +27 -0
- package/dist/{server-BU71N4fk.d.ts → server-DacsdjFJ.d.ts} +27 -0
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +141 -52
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +141 -52
- package/dist/server.mjs.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +20 -1
- package/dist/state.js.map +1 -1
- package/dist/state.mjs +20 -1
- package/dist/state.mjs.map +1 -1
- package/dist/types.d.mts +28 -1
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wapk-cli.d.ts +0 -1
- package/dist/wapk-cli.d.ts.map +1 -1
- package/dist/ws.d.mts +1 -1
- package/dist/ws.d.ts +1 -1
- package/dist/ws.d.ts.map +1 -1
- package/dist/ws.js +9 -4
- package/dist/ws.js.map +1 -1
- package/dist/ws.mjs +9 -4
- package/dist/ws.mjs.map +1 -1
- package/dist/wss.js +14 -8
- package/dist/wss.js.map +1 -1
- package/dist/wss.mjs +14 -8
- package/dist/wss.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +26 -8
- package/src/config.ts +1 -3
- package/src/desktop-cli.ts +0 -9
- package/src/http.ts +5 -4
- package/src/server.ts +182 -56
- package/src/state.ts +25 -1
- package/src/types.ts +30 -0
- package/src/wapk-cli.ts +20 -55
- 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-
|
|
258
|
+
- `elit wapk pack . --password secret-123`
|
|
259
259
|
- `elit wapk ./app.wapk --runtime node|bun|deno`
|
|
260
|
-
- `elit wapk run ./app.wapk --password-
|
|
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-
|
|
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-
|
|
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`
|
|
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
|
|
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
|
-
|
|
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.
|
|
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
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"}
|