Transferable
Marks encoded worker message fields that should move through postMessage as
transfer-list entries.
Worker messages still pass through schema encoding and structured clone, but
schemas wrapped with schema can also report backing resources such as
ArrayBuffer, ImageData.data.buffer, or MessagePort to a Collector.
Worker platforms then pass the collected values as the transfer list for the
same postMessage call, avoiding copies for large payloads and ports.
Accessors
Constructors
makeCollector
Effect that creates a fresh Collector service for accumulating
transferables.
Signature
declare const makeCollector: Effect.Effect<Collector["Service"]>makeCollectorUnsafe
Creates a mutable Collector service directly, exposing unsafe synchronous
methods for reading, adding, and clearing collected transferables.
Signature
declare function makeCollectorUnsafe(): { readonly addAll: (_: Iterable<Transferable>) => Effect<void>; readonly addAllUnsafe: (_: Iterable<Transferable>) => void; readonly clear: Effect<Array<Transferable>>; readonly clearUnsafe: () => Array<Transferable>; readonly read: Effect<Array<Transferable>>; readonly readUnsafe: () => Array<Transferable>;}Getters
getterAddAll
Creates a schema getter that records transferables derived from a value in
the current Collector while passing the value through unchanged.
Signature
declare function getterAddAll<A>(f: (_: A) => Iterable<Transferable>): Getter<A, A>Schemas
Schema for transferring ImageData values with their pixel data buffer.
Signature
declare const ImageData: Transferable<Schema.declare<ImageData>>MessagePort
Schema for transferring MessagePort values as transferable objects.
Signature
declare const MessagePort: Transferable<Schema.declare<MessagePort>>Wraps a schema so encoding records transferables selected from the encoded
value, enabling worker messages to populate a postMessage transfer list.
Signature
declare const schema: { <S extends Top>(f: (_: S["Encoded"]) => Iterable<Transferable>): (self: S) => Transferable<S>; <S extends Top>(self: S, f: (_: S["Encoded"]) => Iterable<Transferable>): Transferable<S>;}Transferable interface
Schema wrapper whose encode path can record transferables with a Collector
while preserving the wrapped schema's decoded type.
Signature
interface Transferable<S extends Schema.Top> extends decodeTo<Schema.toType<S["Rebuild"]>, S["Rebuild"]> { constructor(_: never);}Uint8Array
Schema for transferring Uint8Array values with their backing buffer.
Signature
declare const Uint8Array: Transferable<Schema.instanceOf<globalThis.Uint8Array<ArrayBuffer>>>Services
Service for collecting Transferable objects while encoding worker messages
so they can be passed to postMessage transfer lists.
Signature
declare class Collector extends Shape<"effect/workers/Transferable/Collector", { readonly addAll: (_: Iterable<Transferable>) => Effect<void>; readonly addAllUnsafe: (_: Iterable<Transferable>) => void; readonly clear: Effect<Array<Transferable>>; readonly clearUnsafe: () => Array<Transferable>; readonly read: Effect<Array<Transferable>>; readonly readUnsafe: () => Array<Transferable>;}, this> { constructor(_: never);}