Skip to content

BridgeCodec

Defined in: packages/client/src/worker/protocol.ts:509

The codec every bridge payload crosses through (owner-mandated seam, ADR-0032 S2 §1). v1 ships exactly ONE codec — identityCodec, which relies on the transport’s own structured clone. The seam exists so a columnar/transferable codec (e.g. one that packs live-diff rows into a shared ArrayBuffer and returns it as a transferable) can be swapped in later WITHOUT any protocol change: the router already treats BridgeEnvelope.payload as opaque, and encode may return { payload, transfer } so the sender hands transferables to postMessage. Keep encode/decode inverse and side-effect free.

decode: (payload) => unknown

Defined in: packages/client/src/worker/protocol.ts:513

Decode an envelope body back into the raw payload. Inverse of encode.

unknown

unknown


encode: (payload) => object

Defined in: packages/client/src/worker/protocol.ts:511

Encode a raw payload into the envelope body. May declare transferables for a future zero-copy codec.

unknown

object

payload: unknown

optional transfer?: unknown[]