capnweb 0.0.0-1c87560 → 0.0.0-32e362f

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
@@ -528,6 +528,14 @@ export default {
528
528
  }
529
529
  ```
530
530
 
531
+ #### Compatibility with Workers' built-in RPC
532
+
533
+ 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/).
534
+
535
+ 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.
536
+
537
+ 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.)
538
+
531
539
  ### HTTP server on Node.js
532
540
 
533
541
  A server on Node.js is a bit more involved, due to the awkward handling of WebSockets in Node's HTTP library.
@@ -425,6 +425,12 @@ var RpcPayload = class _RpcPayload {
425
425
  // Get the StubHook representing the given RpcTarget found inside this payload.
426
426
  getHookForRpcTarget(target, parent, dupStubs = true) {
427
427
  if (this.source === "params") {
428
+ if (dupStubs) {
429
+ let dupable = target;
430
+ if (typeof dupable.dup === "function") {
431
+ target = dupable.dup();
432
+ }
433
+ }
428
434
  return TargetStubHook.create(target, parent);
429
435
  } else if (this.source === "return") {
430
436
  let hook = this.rpcTargets?.get(target);