@edgeflowjs/bridge
v0.2.2
Published
WebSocket protocol connecting the React UI to the Node.js core.
Readme
@edgeflowjs/bridge
WebSocket protocol connecting the React UI to the Node.js core.
Install
pnpm add @edgeflowjs/bridgeServer (Node.js)
import { createBridgeServer } from "@edgeflowjs/bridge";
const bridge = createBridgeServer({ port: 19707, logger });
await bridge.start();
bridge.publish({ id: "...", type: "flow.transition", ts: Date.now(), payload: { ... } });Client (Browser)
Use the /client subpath to avoid pulling in Node dependencies:
import { createBridgeClient } from "@edgeflowjs/bridge/client";
const bridge = createBridgeClient({ url: "ws://localhost:19707" });
const data = await bridge.request({ id: crypto.randomUUID(), type: "flow.getSnapshot", ts: Date.now(), payload: { instanceId: "main" } });
bridge.subscribe((evt) => console.log(evt));