Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fallback-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"capnweb": minor
---

Add an opt-in `fallbackCall` for `RpcTarget`s. If a path followed over RPC reaches an `RpcTarget` that doesn't declare the requested property as a method or getter, and that name is not an instance property or local stub helper, a target method under the exported `fallbackCall` symbol receives the unmatched remainder of the path and the call's arguments. The handler may be async, and promise pipelining is preserved: the whole dotted path is sent in one call with the same round-trip cost as a declared method. Canonical numeric property indexes such as `stub.items[0]` arrive as numeric path segments; RPC/Promise helper names such as `then`, `map`, and `dup` remain local stub APIs.
613 changes: 611 additions & 2 deletions __tests__/index.test.ts

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Examples

- batch-pipelining: Node server + client. Shows batching and pipelining to execute a dependent sequence of RPC calls in a single HTTP round trip, with timing vs sequential.
- dynamic-capabilities: Cloudflare Worker + Durable Object. Shows PR #2's runtime capability registry: one client publishes a capability, another calls it through `fallbackCall`.
- worker-react: Cloudflare Worker backend + React frontend. Shows the same pattern from a browser app, served by the Worker.

Notes

- Examples import from `../../dist/index.js`. Run `npm run build` at the repo root before running an example.
- Most examples import from `../../dist/index.js`; run `npm run build` at the repo root first.
`dynamic-capabilities` is a standalone Workers package that depends on the repo via `file:../..`.
- Requires Node 18+ (built-in `fetch`, `Request`, `Response`).
Loading