capnweb 0.0.0-b2fcb34 → 0.0.0-c2bb17b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -201,12 +201,12 @@ The following types can be passed over RPC (in arguments or return values), and
201
201
  * `Date`
202
202
  * `Uint8Array`
203
203
  * `Error` and its well-known subclasses
204
+ * `ReadableStream` and `WritableStream`, with automatic flow control.
204
205
 
205
206
  The following types are not supported as of this writing, but may be added in the future:
206
207
  * `Map` and `Set`
207
208
  * `ArrayBuffer` and typed arrays other than `Uint8Array`
208
209
  * `RegExp`
209
- * `ReadableStream` and `WritableStream`, with automatic flow control.
210
210
  * `Headers`, `Request`, and `Response`
211
211
 
212
212
  The following are intentionally NOT supported:
@@ -305,6 +305,10 @@ The trick here is record-replay: On the calling side, Cap'n Web will invoke your
305
305
 
306
306
  Since all of the not-yet-determined values seen by the callback are represented as `RpcPromise`s, the callback's behavior is deterministic. Any actual computation (arithmetic, branching, etc.) can't possibly use these promises as (meaningful) inputs, so would logically produce the same results for every invocation of the callback. Any such computation will actually end up being performed on the sending side, just once, with the results being imbued into the recording.
307
307
 
308
+ ### Streaming with flow control
309
+
310
+ You may pass a `ReadableStream` or `WritableStream` over RPC. When doing so, the RPC system automatically creates an equivalent stream at the other end and pumps bytes (or arbitrarily-typed chunks) across. This is done in such a way as to ensure the available bandwidth is fully utilized while minimizing buffer bloat, by observing the bandwidth-delay product and applying backpressure when too much is written. Multiple streams can be sent across the same connection -- they will be multiplexed appropriately, similar to HTTP/2 stream multiplexing.
311
+
308
312
  ### Cloudflare Workers RPC interoperability
309
313
 
310
314
  Cap'n Web works on any JavaScript platform. But, on Cloudflare Workers specifically, it's designed to play nicely with the [the built-in RPC system](https://blog.cloudflare.com/javascript-native-rpc/). The two have basically the same semantics, the only difference being that Workers RPC is a built-in API provided by the Workers Runtime, whereas Cap'n Web is implemented in pure JavaScript.
@@ -528,6 +532,14 @@ export default {
528
532
  }
529
533
  ```
530
534
 
535
+ #### Compatibility with Workers' built-in RPC
536
+
537
+ Cloudflare Workers has long featured [a built-in RPC system with semantics similar to Cap'n Web](https://developers.cloudflare.com/workers/runtime-apis/rpc/).
538
+
539
+ Cap'n Web is designed to be compatible with Workers RPC, meaning you can pass Cap'n Web RPC stubs over Workers RPC and vice versa. The system will automatically wrap one stub type in the other and arrange to proxy calls.
540
+
541
+ For best compatibility, make sure to set your [Workers compatibilty date](https://developers.cloudflare.com/workers/configuration/compatibility-dates/) to at least `2026-01-20`, or enable the [compatibility flag](https://developers.cloudflare.com/workers/configuration/compatibility-flags/) `rpc_params_dup_stubs`. (As of this writing, `2026-01-20` is in the future, so you will need to use the flag for now.)
542
+
531
543
  ### HTTP server on Node.js
532
544
 
533
545
  A server on Node.js is a bit more involved, due to the awkward handling of WebSockets in Node's HTTP library.
@@ -642,6 +654,10 @@ function newWebSocketRpcSession(
642
654
  : Disposable;
643
655
  ```
644
656
 
657
+ ### HTTP server using Hono
658
+
659
+ If your app is built on [Hono](https://hono.dev/) (on any runtime it supports), check out [`@hono/capnweb`](https://github.com/honojs/middleware/tree/main/packages/capnweb).
660
+
645
661
  ### MessagePort
646
662
 
647
663
  Cap'n Web can also talk over MessagePorts. This can be used in a browser to talk to Web Workers, iframes, etc.