Licence
Apache-2.0
Version
1.0.1
Deps
1
Size
84 kB
Vulns
0
Weekly
0
@appport/client
The transport-independent application client.
import { createClient } from "@appport/client";
const client = createClient({ transport });
await client.connect();
await client.load(); // discovers capabilities and versions from the manifest
await client.call("documents.save", { documentId, content });
await client.capabilities.documents.save({ documentId, content });
for await (const chunk of client.stream("build.logs", { buildId })) console.log(chunk.line);
const unsubscribe = await client.events.subscribe("documents.changed", (payload) => refresh(payload));
The client builds envelopes, correlates responses, resolves capability versions
from the manifest, unwraps errors into AppPortError, and exposes capabilities
as a namespaced proxy. Application code never touches a protocol envelope.
createDuplexTransport implements request correlation, subscriptions and stream
reassembly once, for every carrier that can push: WebSocket, Electron IPC, Tauri
IPC and the in-process bridge.
With a generated contract the client is fully typed:
import { createDocumentsClient } from "./appport/generated/client.ts";
const client = createDocumentsClient({ transport });
const { version } = await client.capabilities.documents.save({ documentId, content });