@fest-lib/uniform
v0.1.32
Published
fest-lib UnifiedChannel: workers, ports, BroadcastChannel, Chrome, Atomics, WebRTC
Downloads
386
Maintainers
Readme
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.
core
└── fest/uniform ← you are here
└── object · lure · fl-uiInstall
npm install @fest-lib/core @fest-lib/uniformPeer: @fest-lib/core >=0.1.0.
Unified channel (host ↔ worker)
import { createUnifiedChannel } from "@fest-lib/uniform";
// worker
const w = createUnifiedChannel("worker");
w.expose("calc", { add: (a: number, b: number) => a + b });
// window
const host = createUnifiedChannel("host");
host.connect(worker);
const calc = host.proxy("worker", ["calc"]);
await calc.add(2, 3); // 5createUnifiedChannel accepts a name string or a config object ({ name, autoListen, … }).
Invoker (named channel)
import { createInvoker, autoInvoker, detectContextType } from "@fest-lib/uniform";
const invoker = createInvoker("opfs");
autoInvoker("opfs"); // connects `self` in worker / SW / Chrome
detectContextType(); // "window" | "worker" | "chrome-*" | …createInvoker(channelName) — the first argument is the string name, not a UnifiedChannel instance. Use .connect(target) or setupInvoker(name, worker).
Layout
| Path | Role |
| --- | --- |
| src/newer/next/channel/UnifiedChannel.ts | primary channel |
| src/newer/next/proxy/Invoker.ts | request / response |
| src/newer/core/TransportCore.ts | transport factory |
| src/newer/messaging/* | queues / protocol |
| src/original/* | older worker helpers |
Workspace
cd modules/projects/uniform.ts
npm test # node + deno + browser
npm run build
npm run publishTypedoc: npm run docs:md. License: MIT.
