@fest-lib/uniform 0.1.14 → 0.1.16

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 (2) hide show
  1. package/README.md +52 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,46 +1,77 @@
1
- # Uniform.TS
1
+ <p align="center">
2
+ <strong>@fest-lib/uniform</strong><br>
3
+ One channel API across workers, ports, BroadcastChannel, WebSocket, Chrome, Atomics, and WebRTC.
4
+ </p>
2
5
 
3
- `@fest-lib/uniform` — cross-context channels for fest-lib. One API over dedicated workers, SharedWorker, Service Worker, MessagePort, BroadcastChannel, WebSocket, Chrome extension ports, SharedArrayBuffer/Atomics, and WebRTC data channels.
6
+ <p align="center">
7
+ <a href="https://www.npmjs.com/package/@fest-lib/uniform"><img src="https://img.shields.io/npm/v/@fest-lib/uniform?style=flat-square" alt="npm"></a>
8
+ <a href="LICENSE"><img src="https://img.shields.io/npm/l/@fest-lib/uniform?style=flat-square" alt="MIT"></a>
9
+ <a href="https://github.com/fest-live/uniform.ts"><img src="https://img.shields.io/github/stars/fest-live/uniform.ts?style=flat-square" alt="stars"></a>
10
+ </p>
4
11
 
5
- Canonical runtime: `UnifiedChannel` / `createUnifiedChannel`. Invoker (`Requestor` / `Responder`) gives request/response across those transports. Legacy `createWorkerChannel` helpers remain under `src/original` and `src/newer/next/utils`.
12
+ Canonical runtime: `UnifiedChannel` / `createUnifiedChannel`. Invoker (`Requestor` / `Responder` / `createInvoker`) is request/response on a **channel name**. Older worker helpers stay under `src/original` and `src/newer/next/utils`.
13
+
14
+ ```text
15
+ core
16
+ └── fest/uniform ← you are here
17
+ └── object · lure · fl-ui
18
+ ```
6
19
 
7
20
  ## Install
8
21
 
9
22
  ```bash
10
- npm install @fest-lib/uniform
23
+ npm install @fest-lib/core @fest-lib/uniform
11
24
  ```
12
25
 
26
+ Peer: `@fest-lib/core` `>=0.1.0`.
27
+
28
+ ### Unified channel (host ↔ worker)
29
+
13
30
  ```ts
14
- import {
15
- createUnifiedChannel,
16
- createInvoker,
17
- detectContextType
18
- } from "@fest-lib/uniform";
19
-
20
- const channel = createUnifiedChannel({ name: "opfs" });
21
- const invoker = createInvoker(channel);
31
+ import { createUnifiedChannel } from "@fest-lib/uniform";
32
+
33
+ // worker
34
+ const w = createUnifiedChannel("worker");
35
+ w.expose("calc", { add: (a: number, b: number) => a + b });
36
+
37
+ // window
38
+ const host = createUnifiedChannel("host");
39
+ host.connect(worker);
40
+ const calc = host.proxy("worker", ["calc"]);
41
+ await calc.add(2, 3); // 5
22
42
  ```
23
43
 
24
- Worker-style (queued until ready):
44
+ `createUnifiedChannel` accepts a name string or a config object (`{ name, autoListen, … }`).
45
+
46
+ ### Invoker (named channel)
25
47
 
26
48
  ```ts
27
- import { createQueuedWorkerChannel } from "@fest-lib/uniform";
49
+ import { createInvoker, autoInvoker, detectContextType } from "@fest-lib/uniform";
28
50
 
29
- const worker = createQueuedWorkerChannel(
30
- { name: "my-worker", script: "./my-worker.uniform.worker.ts" },
31
- () => { /* connected */ }
32
- );
33
- const result = await worker.request("processData", { data: "hello" });
51
+ const invoker = createInvoker("opfs");
52
+ autoInvoker("opfs"); // connects `self` in worker / SW / Chrome
53
+ detectContextType(); // "window" | "worker" | "chrome-*" | …
34
54
  ```
35
55
 
56
+ `createInvoker(channelName)` — the first argument is the **string name**, not a `UnifiedChannel` instance. Use `.connect(target)` or `setupInvoker(name, worker)`.
57
+
36
58
  ## Layout
37
59
 
38
60
  | Path | Role |
39
61
  | --- | --- |
40
62
  | `src/newer/next/channel/UnifiedChannel.ts` | primary channel |
41
- | `src/newer/next/proxy/Invoker.ts` | request/response |
63
+ | `src/newer/next/proxy/Invoker.ts` | request / response |
42
64
  | `src/newer/core/TransportCore.ts` | transport factory |
43
65
  | `src/newer/messaging/*` | queues / protocol |
44
66
  | `src/original/*` | older worker helpers |
45
67
 
46
- Peer: `@fest-lib/core`. Build: `npm run build`. Publish: `npm run publish`.
68
+ ## Workspace
69
+
70
+ ```bash
71
+ cd modules/projects/uniform.ts
72
+ npm test # node + deno + browser
73
+ npm run build
74
+ npm run publish
75
+ ```
76
+
77
+ Typedoc: `npm run docs:md`. License: [MIT](LICENSE).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fest-lib/uniform",
3
3
  "description": "fest-lib UnifiedChannel: workers, ports, BroadcastChannel, Chrome, Atomics, WebRTC",
4
- "version": "0.1.14",
4
+ "version": "0.1.16",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": true,