@canmi/seam-client
v0.5.31
Published
Framework-agnostic client for calling seam procedures, subscribing to server events, and managing real-time connections.
Downloads
1,229
Readme
@canmi/seam-client
Framework-agnostic client for calling seam procedures, subscribing to server events, and managing real-time connections.
Key Exports
| Export | Purpose |
| ------------------------ | ------------------------------------------------------------------------------ |
| createClient | Create a SeamClient instance with call(), subscribe(), fetchManifest() |
| SeamClientError | Typed error class with error codes |
| ReconnectController | Automatic reconnection with exponential backoff |
| defaultReconnectConfig | Default reconnect configuration |
| parseSseStream | Fetch-based SSE stream parser |
| seamRpc | Low-level RPC call helper |
| configureRpcMap | Configure RPC hash map for obfuscated endpoints |
| createChannelHandle | Create an SSE-based channel handle |
| createWsChannelHandle | Create a WebSocket-based channel handle |
| prefetchRoute | Prefetch route data for faster navigation |
| clearPrefetchCache | Clear prefetched route cache |
Types
| Type | Purpose |
| ----------------- | ---------------------------------------------------------------- |
| ConnectionState | Reconnection state (connected, reconnecting, disconnected) |
| ReconnectConfig | Reconnect configuration (maxRetries, baseDelay, etc.) |
| SseCallbacks | Callback interface for SSE stream events |
| ChannelHandle | Handle for managing channel connections |
| ErrorCode | String union of standard error codes |
| ProcedureKind | 'query' \| 'command' \| 'subscription' \| 'stream' \| 'upload' |
Structure
src/index.ts— Public API exportssrc/client.ts—SeamClientimplementation (RPC calls, SSE subscriptions)src/errors.ts—SeamClientErrortyped error classsrc/reconnect.ts—ReconnectControllerwith exponential backoffsrc/sse-parser.ts— Fetch-based SSE stream parser withLast-Event-IDsupportsrc/rpc.ts—seamRpc/configureRpcMaplow-level RPC helperssrc/channel-handle.ts— SSE-based channel handlesrc/ws-channel-handle.ts— WebSocket-based channel handlesrc/prefetch.ts— Route prefetchingsrc/prefetch-cache.ts— Prefetch cache managementsrc/batch.ts— Batch RPC call support
Development
- Build:
just build-ts - Test:
just test-ts
Notes
- Used directly for vanilla JS or as a dependency of
@canmi/seam-react subscribe()uses fetch-based SSE withLast-Event-IDreconnection supportReconnectControllerhandles automatic reconnection with configurable exponential backoff
