@actuallab/rpc 15.1.62 → 16.0.4

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/dist/index.d.cts CHANGED
@@ -192,11 +192,11 @@ interface RpcDeserializedMessage {
192
192
  /** Wire data produced by serialization — either text or binary. */
193
193
  type RpcWireData = string | Uint8Array;
194
194
  /**
195
- * Base class for RPC serialization formats.
195
+ * Base class for RPC wire formats.
196
196
  * Instances are immutable singletons — one per format key.
197
197
  * State (like method registries) is passed via parameters.
198
198
  */
199
- declare abstract class RpcSerializationFormat {
199
+ declare abstract class RpcWireFormat {
200
200
  abstract readonly key: string;
201
201
  abstract readonly isBinary: boolean;
202
202
  /** Whether this format uses compact method hashes (needs RpcMethodRegistry). */
@@ -213,22 +213,22 @@ declare abstract class RpcSerializationFormat {
213
213
  createEncoder(): Encoder | undefined;
214
214
  /** Create a reusable binary decoder for this format. Returns undefined for text formats. */
215
215
  createDecoder(): Decoder | undefined;
216
- static SystemJsonV5: RpcSerializationFormat;
217
- static SystemJsonV5NP: RpcSerializationFormat;
218
- static NewtonsoftJsonV5: RpcSerializationFormat;
219
- static NewtonsoftJsonV5NP: RpcSerializationFormat;
220
- static MessagePackV6: RpcSerializationFormat;
221
- static MessagePackV6C: RpcSerializationFormat;
222
- static All: readonly RpcSerializationFormat[];
223
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.get(key). */
224
- static get(key: string): RpcSerializationFormat;
225
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.tryGet(key). */
226
- static tryGet(key: string): RpcSerializationFormat | undefined;
216
+ static SystemJsonV5: RpcWireFormat;
217
+ static SystemJsonV5NP: RpcWireFormat;
218
+ static NewtonsoftJsonV5: RpcWireFormat;
219
+ static NewtonsoftJsonV5NP: RpcWireFormat;
220
+ static MessagePackV6: RpcWireFormat;
221
+ static MessagePackV6C: RpcWireFormat;
222
+ static All: readonly RpcWireFormat[];
223
+ /** Convenience shortcut for RpcWireFormatResolver.Default.get(key). */
224
+ static get(key: string): RpcWireFormat;
225
+ /** Convenience shortcut for RpcWireFormatResolver.Default.tryGet(key). */
226
+ static tryGet(key: string): RpcWireFormat | undefined;
227
227
  }
228
228
  /**
229
229
  * JSON text format — "json5np" (System.Text.Json, no polymorphism).
230
230
  */
231
- declare class RpcJsonSerializationFormat extends RpcSerializationFormat {
231
+ declare class RpcJsonWireFormat extends RpcWireFormat {
232
232
  readonly key: string;
233
233
  readonly isBinary = false;
234
234
  readonly isCompact = false;
@@ -241,7 +241,7 @@ declare class RpcJsonSerializationFormat extends RpcSerializationFormat {
241
241
  /**
242
242
  * MessagePack binary format — "msgpack6" (V5 wire format).
243
243
  */
244
- declare class RpcMessagePackSerializationFormat extends RpcSerializationFormat {
244
+ declare class RpcMessagePackWireFormat extends RpcWireFormat {
245
245
  readonly key: string;
246
246
  readonly isBinary = true;
247
247
  readonly isCompact = false;
@@ -258,7 +258,7 @@ declare class RpcMessagePackSerializationFormat extends RpcSerializationFormat {
258
258
  * Uses 4-byte method hash instead of full method name.
259
259
  * Registry is passed via parameters — format instance is immutable.
260
260
  */
261
- declare class RpcMessagePackCompactSerializationFormat extends RpcSerializationFormat {
261
+ declare class RpcMessagePackCompactWireFormat extends RpcWireFormat {
262
262
  readonly key: string;
263
263
  readonly isBinary = true;
264
264
  readonly isCompact = true;
@@ -271,18 +271,18 @@ declare class RpcMessagePackCompactSerializationFormat extends RpcSerializationF
271
271
  createDecoder(): Decoder;
272
272
  }
273
273
  /**
274
- * Resolves RpcSerializationFormat instances by key, with a configurable default.
275
- * Mirrors .NET RpcSerializationFormatResolver.
274
+ * Resolves RpcWireFormat instances by key, with a configurable default.
275
+ * Similar to .NET RpcWireFormatResolver, which takes its formats from RpcConfiguration.WireFormats.
276
276
  */
277
- declare class RpcSerializationFormatResolver {
278
- static DefaultFormats: readonly RpcSerializationFormat[];
279
- static Default: RpcSerializationFormatResolver;
277
+ declare class RpcWireFormatResolver {
278
+ static DefaultFormats: readonly RpcWireFormat[];
279
+ static Default: RpcWireFormatResolver;
280
280
  readonly defaultFormatKey: string;
281
- readonly formats: ReadonlyMap<string, RpcSerializationFormat>;
282
- get defaultFormat(): RpcSerializationFormat;
283
- constructor(defaultFormatKey: string, formats?: Iterable<RpcSerializationFormat>);
284
- get(key: string): RpcSerializationFormat;
285
- tryGet(key: string): RpcSerializationFormat | undefined;
281
+ readonly formats: ReadonlyMap<string, RpcWireFormat>;
282
+ get defaultFormat(): RpcWireFormat;
283
+ constructor(defaultFormatKey: string, formats?: Iterable<RpcWireFormat>);
284
+ get(key: string): RpcWireFormat;
285
+ tryGet(key: string): RpcWireFormat | undefined;
286
286
  }
287
287
 
288
288
  /** Abstract WebSocket interface — works with both browser WebSocket and Node.js ws. */
@@ -353,7 +353,7 @@ declare class RpcWebSocketConnection implements RpcConnection {
353
353
  * pass to synchronous encode calls on the same event-loop turn. */
354
354
  get encoder(): Encoder;
355
355
  get decoder(): Decoder;
356
- private _format;
356
+ private _wireFormat;
357
357
  private _methodRegistry;
358
358
  readonly binaryMode: boolean;
359
359
  readonly messageReceived: EventHandlerSet<RpcReceivedMessage>;
@@ -362,14 +362,14 @@ declare class RpcWebSocketConnection implements RpcConnection {
362
362
  reason: string;
363
363
  }>;
364
364
  readonly error: EventHandlerSet<unknown>;
365
- constructor(ws: WebSocketLike, binaryMode?: boolean, format?: RpcSerializationFormat, methodRegistry?: RpcMethodRegistry);
365
+ constructor(ws: WebSocketLike, binaryMode?: boolean, wireFormat?: RpcWireFormat, methodRegistry?: RpcMethodRegistry);
366
366
  get isOpen(): boolean;
367
367
  get whenConnected(): Promise<void>;
368
368
  send(serializedMessage: string): void;
369
369
  sendBinary(data: Uint8Array): void;
370
370
  sendTextBatch(messages: string[]): void;
371
371
  sendBinaryBatch(messages: Uint8Array[]): void;
372
- /** Split a binary frame using the format (compact-aware) or default splitter. */
372
+ /** Split a binary frame using the wire format (compact-aware) or default splitter. */
373
373
  private _splitBinary;
374
374
  private _dispatchBinary;
375
375
  close(code?: number, reason?: string): void;
@@ -764,7 +764,7 @@ declare function rpcMethod(options?: {
764
764
  * on every call showed up as ~2-4% self time + non-trivial GC pressure in
765
765
  * the 300-pull video-load-test profile.
766
766
  *
767
- * The sender itself is a per-Hub singleton and `_send`/format.serializeMessage
767
+ * The sender itself is a per-Hub singleton and `_send`/wireFormat.serializeMessage
768
768
  * are fully synchronous (no awaits, no re-entrancy on a single-threaded event
769
769
  * loop), so we reuse a small pool of preallocated envelope + arg-array slots
770
770
  * per hot method. Mutate fields just before the send call; the encoder reads
@@ -789,21 +789,21 @@ declare class RpcSystemCallSender {
789
789
  * {@link genericErrorFilter}) on a TS-hosted server, where handler errors
790
790
  * would otherwise disclose internal details to unauthenticated callers. */
791
791
  errorFilter?: RpcErrorFilter;
792
- protected _send(conn: RpcConnection, format: RpcSerializationFormat, envelope: RpcMessage, args?: unknown[]): void;
793
- handshake(conn: RpcConnection, format: RpcSerializationFormat, peerId: string, hubId: string, index: number): void;
794
- ok(conn: RpcConnection, format: RpcSerializationFormat, relatedId: number, result: unknown): void;
795
- error(conn: RpcConnection, format: RpcSerializationFormat, relatedId: number, error: unknown): void;
796
- cancel(conn: RpcConnection, format: RpcSerializationFormat, relatedId: number): void;
797
- keepAlive(conn: RpcConnection, format: RpcSerializationFormat, activeCallIds: number[]): void;
798
- disconnect(conn: RpcConnection, format: RpcSerializationFormat, localIds: number[]): void;
799
- item(conn: RpcConnection, format: RpcSerializationFormat, localId: number, index: number, item: unknown): void;
800
- batch(conn: RpcConnection, format: RpcSerializationFormat, localId: number, index: number, items: unknown[]): void;
801
- end(conn: RpcConnection, format: RpcSerializationFormat, localId: number, index: number, error?: {
792
+ protected _send(conn: RpcConnection, wireFormat: RpcWireFormat, envelope: RpcMessage, args?: unknown[]): void;
793
+ handshake(conn: RpcConnection, wireFormat: RpcWireFormat, peerId: string, hubId: string, index: number): void;
794
+ ok(conn: RpcConnection, wireFormat: RpcWireFormat, relatedId: number, result: unknown): void;
795
+ error(conn: RpcConnection, wireFormat: RpcWireFormat, relatedId: number, error: unknown): void;
796
+ cancel(conn: RpcConnection, wireFormat: RpcWireFormat, relatedId: number): void;
797
+ keepAlive(conn: RpcConnection, wireFormat: RpcWireFormat, activeCallIds: number[]): void;
798
+ disconnect(conn: RpcConnection, wireFormat: RpcWireFormat, localIds: number[]): void;
799
+ item(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, index: number, item: unknown): void;
800
+ batch(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, index: number, items: unknown[]): void;
801
+ end(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, index: number, error?: {
802
802
  TypeRef: string;
803
803
  Message: string;
804
804
  }): void;
805
- ack(conn: RpcConnection, format: RpcSerializationFormat, localId: number, nextIndex: number, hostId: string): void;
806
- ackEnd(conn: RpcConnection, format: RpcSerializationFormat, localId: number, hostId: string): void;
805
+ ack(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, nextIndex: number, hostId: string): void;
806
+ ackEnd(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, hostId: string): void;
807
807
  }
808
808
 
809
809
  /** Factory signature shared by all peer lookup/creation methods. Serialization
@@ -935,13 +935,13 @@ interface RpcReconnectProofParameters {
935
935
  declare function isReconnectProofSupported(): boolean;
936
936
  declare function computeReconnectProof(secret: string, clientId: string, counterText: string): Promise<string>;
937
937
 
938
- /** WebSocket close code sent by the server when the client's serialization format is unsupported. */
938
+ /** WebSocket close code sent by the server when the client's wire format is unsupported. */
939
939
  declare const RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
940
940
  /** Builds the WebSocket connection URL for an RpcClientPeer. */
941
941
  type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string | Promise<string>;
942
942
  /** Default connection URL provider — sets `clientId` and `f` query parameters,
943
943
  * replacing any existing values to keep the wire format consistent with the
944
- * peer's actual `serializationFormat`. Adds the reconnect proof (`c` + `p`)
944
+ * peer's actual `wireFormat`. Adds the reconnect proof (`c` + `p`)
945
945
  * once the peer holds a server-issued secret. */
946
946
  declare const defaultConnectionUrlResolver: RpcConnectionUrlResolver;
947
947
  /** Options for RpcPeer.call() — allows custom call types and cancellation. */
@@ -1033,13 +1033,13 @@ declare abstract class RpcPeer {
1033
1033
  whenConnected(): Promise<void>;
1034
1034
  protected setupConnection(conn: RpcConnection): void;
1035
1035
  /**
1036
- * The serialization format used by this peer for outgoing messages.
1036
+ * The wire format used by this peer for outgoing messages.
1037
1037
  * If not set explicitly, defaults to the resolver's default (JSON /
1038
1038
  * json5np). Subclasses can pre-assign in their constructor.
1039
1039
  */
1040
- private _serializationFormat;
1041
- get serializationFormat(): RpcSerializationFormat;
1042
- set serializationFormat(value: RpcSerializationFormat);
1040
+ private _wireFormat;
1041
+ get wireFormat(): RpcWireFormat;
1042
+ set wireFormat(value: RpcWireFormat);
1043
1043
  call(method: string, args?: unknown[], options?: RpcCallOptions): RpcOutboundCall;
1044
1044
  callNoWait(method: string, args?: unknown[]): void;
1045
1045
  /** Close the current WS connection without disposing the peer. The
@@ -1142,7 +1142,7 @@ declare class RpcClientPeer extends RpcPeer {
1142
1142
  * Initialized from `hub.limits` at construction; override per peer. */
1143
1143
  prematureDisconnectTimeoutMs: number;
1144
1144
  readonly peerChanged: EventHandlerSet<void>;
1145
- /** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
1145
+ /** Fired when the server rejects the connection due to an unsupported wire format (close code 4001). */
1146
1146
  readonly unsupportedFormat: EventHandlerSet<{
1147
1147
  reason: string;
1148
1148
  }>;
@@ -1155,7 +1155,7 @@ declare class RpcClientPeer extends RpcPeer {
1155
1155
  whenRunning: Promise<void> | undefined;
1156
1156
  /**
1157
1157
  * @param hub RpcHub instance this peer will be tracked by
1158
- * @param url Full WebSocket URL — the serialization format is taken from
1158
+ * @param url Full WebSocket URL — the wire format is taken from
1159
1159
  * the `f=` query parameter (e.g. `wss://host/rpc/ws?f=msgpack6`);
1160
1160
  * falls back to the resolver's default when absent. Use
1161
1161
  * {@link RpcRefBuilder.forClient} to compose URLs with a format.
@@ -1583,11 +1583,11 @@ declare function toRpcStream<T>(value: unknown, peer: RpcPeer): RpcStream<T> | n
1583
1583
 
1584
1584
  declare class RpcRefBuilder {
1585
1585
  /** Build a client peer ref from a WebSocket URL, optionally baking in the
1586
- * serialization format as a `f=` query parameter.
1586
+ * wire format as a `f=` query parameter.
1587
1587
  * @param url Base WebSocket URL, e.g. `wss://host/rpc/ws`.
1588
- * @param serializationFormat Optional format key, e.g. `msgpack6`. When
1588
+ * @param wireFormat Optional format key, e.g. `msgpack6`. When
1589
1589
  * provided, replaces any existing `f=` in the URL. */
1590
- static forClient(url: string, serializationFormat?: string): string;
1590
+ static forClient(url: string, wireFormat?: string): string;
1591
1591
  /** Build a server peer ref from a peer id — returns `server://{id}`. */
1592
1592
  static forServer(id: string): string;
1593
1593
  }
@@ -1656,4 +1656,4 @@ declare function xxh3_64str(input: string, seed?: bigint): bigint;
1656
1656
  */
1657
1657
  declare function computeMethodHash(methodName: string): number;
1658
1658
 
1659
- export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, REMOTE_EXCEPTION_TYPE_REF, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTimeouts, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcError, type RpcErrorFilter, type RpcExceptionInfo, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonSerializationFormat, RpcLimits, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactSerializationFormat, RpcMessagePackSerializationFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerChangeKind, type RpcPeerFactory, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, type RpcReconnectProofParameters, RpcRefBuilder, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcSerializationFormat, RpcSerializationFormatResolver, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, computeReconnectProof, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, genericErrorFilter, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, isReconnectProofSupported, likelyConnected, parseStreamRef, readPolymorphismMarker, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, toExceptionInfo, toRpcStream, wireMethodName, xxh3_64, xxh3_64str };
1659
+ export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, REMOTE_EXCEPTION_TYPE_REF, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTimeouts, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcError, type RpcErrorFilter, type RpcExceptionInfo, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonWireFormat, RpcLimits, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactWireFormat, RpcMessagePackWireFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerChangeKind, type RpcPeerFactory, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, type RpcReconnectProofParameters, RpcRefBuilder, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, RpcWireFormat, RpcWireFormatResolver, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, computeReconnectProof, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, genericErrorFilter, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, isReconnectProofSupported, likelyConnected, parseStreamRef, readPolymorphismMarker, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, toExceptionInfo, toRpcStream, wireMethodName, xxh3_64, xxh3_64str };
package/dist/index.d.ts CHANGED
@@ -192,11 +192,11 @@ interface RpcDeserializedMessage {
192
192
  /** Wire data produced by serialization — either text or binary. */
193
193
  type RpcWireData = string | Uint8Array;
194
194
  /**
195
- * Base class for RPC serialization formats.
195
+ * Base class for RPC wire formats.
196
196
  * Instances are immutable singletons — one per format key.
197
197
  * State (like method registries) is passed via parameters.
198
198
  */
199
- declare abstract class RpcSerializationFormat {
199
+ declare abstract class RpcWireFormat {
200
200
  abstract readonly key: string;
201
201
  abstract readonly isBinary: boolean;
202
202
  /** Whether this format uses compact method hashes (needs RpcMethodRegistry). */
@@ -213,22 +213,22 @@ declare abstract class RpcSerializationFormat {
213
213
  createEncoder(): Encoder | undefined;
214
214
  /** Create a reusable binary decoder for this format. Returns undefined for text formats. */
215
215
  createDecoder(): Decoder | undefined;
216
- static SystemJsonV5: RpcSerializationFormat;
217
- static SystemJsonV5NP: RpcSerializationFormat;
218
- static NewtonsoftJsonV5: RpcSerializationFormat;
219
- static NewtonsoftJsonV5NP: RpcSerializationFormat;
220
- static MessagePackV6: RpcSerializationFormat;
221
- static MessagePackV6C: RpcSerializationFormat;
222
- static All: readonly RpcSerializationFormat[];
223
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.get(key). */
224
- static get(key: string): RpcSerializationFormat;
225
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.tryGet(key). */
226
- static tryGet(key: string): RpcSerializationFormat | undefined;
216
+ static SystemJsonV5: RpcWireFormat;
217
+ static SystemJsonV5NP: RpcWireFormat;
218
+ static NewtonsoftJsonV5: RpcWireFormat;
219
+ static NewtonsoftJsonV5NP: RpcWireFormat;
220
+ static MessagePackV6: RpcWireFormat;
221
+ static MessagePackV6C: RpcWireFormat;
222
+ static All: readonly RpcWireFormat[];
223
+ /** Convenience shortcut for RpcWireFormatResolver.Default.get(key). */
224
+ static get(key: string): RpcWireFormat;
225
+ /** Convenience shortcut for RpcWireFormatResolver.Default.tryGet(key). */
226
+ static tryGet(key: string): RpcWireFormat | undefined;
227
227
  }
228
228
  /**
229
229
  * JSON text format — "json5np" (System.Text.Json, no polymorphism).
230
230
  */
231
- declare class RpcJsonSerializationFormat extends RpcSerializationFormat {
231
+ declare class RpcJsonWireFormat extends RpcWireFormat {
232
232
  readonly key: string;
233
233
  readonly isBinary = false;
234
234
  readonly isCompact = false;
@@ -241,7 +241,7 @@ declare class RpcJsonSerializationFormat extends RpcSerializationFormat {
241
241
  /**
242
242
  * MessagePack binary format — "msgpack6" (V5 wire format).
243
243
  */
244
- declare class RpcMessagePackSerializationFormat extends RpcSerializationFormat {
244
+ declare class RpcMessagePackWireFormat extends RpcWireFormat {
245
245
  readonly key: string;
246
246
  readonly isBinary = true;
247
247
  readonly isCompact = false;
@@ -258,7 +258,7 @@ declare class RpcMessagePackSerializationFormat extends RpcSerializationFormat {
258
258
  * Uses 4-byte method hash instead of full method name.
259
259
  * Registry is passed via parameters — format instance is immutable.
260
260
  */
261
- declare class RpcMessagePackCompactSerializationFormat extends RpcSerializationFormat {
261
+ declare class RpcMessagePackCompactWireFormat extends RpcWireFormat {
262
262
  readonly key: string;
263
263
  readonly isBinary = true;
264
264
  readonly isCompact = true;
@@ -271,18 +271,18 @@ declare class RpcMessagePackCompactSerializationFormat extends RpcSerializationF
271
271
  createDecoder(): Decoder;
272
272
  }
273
273
  /**
274
- * Resolves RpcSerializationFormat instances by key, with a configurable default.
275
- * Mirrors .NET RpcSerializationFormatResolver.
274
+ * Resolves RpcWireFormat instances by key, with a configurable default.
275
+ * Similar to .NET RpcWireFormatResolver, which takes its formats from RpcConfiguration.WireFormats.
276
276
  */
277
- declare class RpcSerializationFormatResolver {
278
- static DefaultFormats: readonly RpcSerializationFormat[];
279
- static Default: RpcSerializationFormatResolver;
277
+ declare class RpcWireFormatResolver {
278
+ static DefaultFormats: readonly RpcWireFormat[];
279
+ static Default: RpcWireFormatResolver;
280
280
  readonly defaultFormatKey: string;
281
- readonly formats: ReadonlyMap<string, RpcSerializationFormat>;
282
- get defaultFormat(): RpcSerializationFormat;
283
- constructor(defaultFormatKey: string, formats?: Iterable<RpcSerializationFormat>);
284
- get(key: string): RpcSerializationFormat;
285
- tryGet(key: string): RpcSerializationFormat | undefined;
281
+ readonly formats: ReadonlyMap<string, RpcWireFormat>;
282
+ get defaultFormat(): RpcWireFormat;
283
+ constructor(defaultFormatKey: string, formats?: Iterable<RpcWireFormat>);
284
+ get(key: string): RpcWireFormat;
285
+ tryGet(key: string): RpcWireFormat | undefined;
286
286
  }
287
287
 
288
288
  /** Abstract WebSocket interface — works with both browser WebSocket and Node.js ws. */
@@ -353,7 +353,7 @@ declare class RpcWebSocketConnection implements RpcConnection {
353
353
  * pass to synchronous encode calls on the same event-loop turn. */
354
354
  get encoder(): Encoder;
355
355
  get decoder(): Decoder;
356
- private _format;
356
+ private _wireFormat;
357
357
  private _methodRegistry;
358
358
  readonly binaryMode: boolean;
359
359
  readonly messageReceived: EventHandlerSet<RpcReceivedMessage>;
@@ -362,14 +362,14 @@ declare class RpcWebSocketConnection implements RpcConnection {
362
362
  reason: string;
363
363
  }>;
364
364
  readonly error: EventHandlerSet<unknown>;
365
- constructor(ws: WebSocketLike, binaryMode?: boolean, format?: RpcSerializationFormat, methodRegistry?: RpcMethodRegistry);
365
+ constructor(ws: WebSocketLike, binaryMode?: boolean, wireFormat?: RpcWireFormat, methodRegistry?: RpcMethodRegistry);
366
366
  get isOpen(): boolean;
367
367
  get whenConnected(): Promise<void>;
368
368
  send(serializedMessage: string): void;
369
369
  sendBinary(data: Uint8Array): void;
370
370
  sendTextBatch(messages: string[]): void;
371
371
  sendBinaryBatch(messages: Uint8Array[]): void;
372
- /** Split a binary frame using the format (compact-aware) or default splitter. */
372
+ /** Split a binary frame using the wire format (compact-aware) or default splitter. */
373
373
  private _splitBinary;
374
374
  private _dispatchBinary;
375
375
  close(code?: number, reason?: string): void;
@@ -764,7 +764,7 @@ declare function rpcMethod(options?: {
764
764
  * on every call showed up as ~2-4% self time + non-trivial GC pressure in
765
765
  * the 300-pull video-load-test profile.
766
766
  *
767
- * The sender itself is a per-Hub singleton and `_send`/format.serializeMessage
767
+ * The sender itself is a per-Hub singleton and `_send`/wireFormat.serializeMessage
768
768
  * are fully synchronous (no awaits, no re-entrancy on a single-threaded event
769
769
  * loop), so we reuse a small pool of preallocated envelope + arg-array slots
770
770
  * per hot method. Mutate fields just before the send call; the encoder reads
@@ -789,21 +789,21 @@ declare class RpcSystemCallSender {
789
789
  * {@link genericErrorFilter}) on a TS-hosted server, where handler errors
790
790
  * would otherwise disclose internal details to unauthenticated callers. */
791
791
  errorFilter?: RpcErrorFilter;
792
- protected _send(conn: RpcConnection, format: RpcSerializationFormat, envelope: RpcMessage, args?: unknown[]): void;
793
- handshake(conn: RpcConnection, format: RpcSerializationFormat, peerId: string, hubId: string, index: number): void;
794
- ok(conn: RpcConnection, format: RpcSerializationFormat, relatedId: number, result: unknown): void;
795
- error(conn: RpcConnection, format: RpcSerializationFormat, relatedId: number, error: unknown): void;
796
- cancel(conn: RpcConnection, format: RpcSerializationFormat, relatedId: number): void;
797
- keepAlive(conn: RpcConnection, format: RpcSerializationFormat, activeCallIds: number[]): void;
798
- disconnect(conn: RpcConnection, format: RpcSerializationFormat, localIds: number[]): void;
799
- item(conn: RpcConnection, format: RpcSerializationFormat, localId: number, index: number, item: unknown): void;
800
- batch(conn: RpcConnection, format: RpcSerializationFormat, localId: number, index: number, items: unknown[]): void;
801
- end(conn: RpcConnection, format: RpcSerializationFormat, localId: number, index: number, error?: {
792
+ protected _send(conn: RpcConnection, wireFormat: RpcWireFormat, envelope: RpcMessage, args?: unknown[]): void;
793
+ handshake(conn: RpcConnection, wireFormat: RpcWireFormat, peerId: string, hubId: string, index: number): void;
794
+ ok(conn: RpcConnection, wireFormat: RpcWireFormat, relatedId: number, result: unknown): void;
795
+ error(conn: RpcConnection, wireFormat: RpcWireFormat, relatedId: number, error: unknown): void;
796
+ cancel(conn: RpcConnection, wireFormat: RpcWireFormat, relatedId: number): void;
797
+ keepAlive(conn: RpcConnection, wireFormat: RpcWireFormat, activeCallIds: number[]): void;
798
+ disconnect(conn: RpcConnection, wireFormat: RpcWireFormat, localIds: number[]): void;
799
+ item(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, index: number, item: unknown): void;
800
+ batch(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, index: number, items: unknown[]): void;
801
+ end(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, index: number, error?: {
802
802
  TypeRef: string;
803
803
  Message: string;
804
804
  }): void;
805
- ack(conn: RpcConnection, format: RpcSerializationFormat, localId: number, nextIndex: number, hostId: string): void;
806
- ackEnd(conn: RpcConnection, format: RpcSerializationFormat, localId: number, hostId: string): void;
805
+ ack(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, nextIndex: number, hostId: string): void;
806
+ ackEnd(conn: RpcConnection, wireFormat: RpcWireFormat, localId: number, hostId: string): void;
807
807
  }
808
808
 
809
809
  /** Factory signature shared by all peer lookup/creation methods. Serialization
@@ -935,13 +935,13 @@ interface RpcReconnectProofParameters {
935
935
  declare function isReconnectProofSupported(): boolean;
936
936
  declare function computeReconnectProof(secret: string, clientId: string, counterText: string): Promise<string>;
937
937
 
938
- /** WebSocket close code sent by the server when the client's serialization format is unsupported. */
938
+ /** WebSocket close code sent by the server when the client's wire format is unsupported. */
939
939
  declare const RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
940
940
  /** Builds the WebSocket connection URL for an RpcClientPeer. */
941
941
  type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string | Promise<string>;
942
942
  /** Default connection URL provider — sets `clientId` and `f` query parameters,
943
943
  * replacing any existing values to keep the wire format consistent with the
944
- * peer's actual `serializationFormat`. Adds the reconnect proof (`c` + `p`)
944
+ * peer's actual `wireFormat`. Adds the reconnect proof (`c` + `p`)
945
945
  * once the peer holds a server-issued secret. */
946
946
  declare const defaultConnectionUrlResolver: RpcConnectionUrlResolver;
947
947
  /** Options for RpcPeer.call() — allows custom call types and cancellation. */
@@ -1033,13 +1033,13 @@ declare abstract class RpcPeer {
1033
1033
  whenConnected(): Promise<void>;
1034
1034
  protected setupConnection(conn: RpcConnection): void;
1035
1035
  /**
1036
- * The serialization format used by this peer for outgoing messages.
1036
+ * The wire format used by this peer for outgoing messages.
1037
1037
  * If not set explicitly, defaults to the resolver's default (JSON /
1038
1038
  * json5np). Subclasses can pre-assign in their constructor.
1039
1039
  */
1040
- private _serializationFormat;
1041
- get serializationFormat(): RpcSerializationFormat;
1042
- set serializationFormat(value: RpcSerializationFormat);
1040
+ private _wireFormat;
1041
+ get wireFormat(): RpcWireFormat;
1042
+ set wireFormat(value: RpcWireFormat);
1043
1043
  call(method: string, args?: unknown[], options?: RpcCallOptions): RpcOutboundCall;
1044
1044
  callNoWait(method: string, args?: unknown[]): void;
1045
1045
  /** Close the current WS connection without disposing the peer. The
@@ -1142,7 +1142,7 @@ declare class RpcClientPeer extends RpcPeer {
1142
1142
  * Initialized from `hub.limits` at construction; override per peer. */
1143
1143
  prematureDisconnectTimeoutMs: number;
1144
1144
  readonly peerChanged: EventHandlerSet<void>;
1145
- /** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
1145
+ /** Fired when the server rejects the connection due to an unsupported wire format (close code 4001). */
1146
1146
  readonly unsupportedFormat: EventHandlerSet<{
1147
1147
  reason: string;
1148
1148
  }>;
@@ -1155,7 +1155,7 @@ declare class RpcClientPeer extends RpcPeer {
1155
1155
  whenRunning: Promise<void> | undefined;
1156
1156
  /**
1157
1157
  * @param hub RpcHub instance this peer will be tracked by
1158
- * @param url Full WebSocket URL — the serialization format is taken from
1158
+ * @param url Full WebSocket URL — the wire format is taken from
1159
1159
  * the `f=` query parameter (e.g. `wss://host/rpc/ws?f=msgpack6`);
1160
1160
  * falls back to the resolver's default when absent. Use
1161
1161
  * {@link RpcRefBuilder.forClient} to compose URLs with a format.
@@ -1583,11 +1583,11 @@ declare function toRpcStream<T>(value: unknown, peer: RpcPeer): RpcStream<T> | n
1583
1583
 
1584
1584
  declare class RpcRefBuilder {
1585
1585
  /** Build a client peer ref from a WebSocket URL, optionally baking in the
1586
- * serialization format as a `f=` query parameter.
1586
+ * wire format as a `f=` query parameter.
1587
1587
  * @param url Base WebSocket URL, e.g. `wss://host/rpc/ws`.
1588
- * @param serializationFormat Optional format key, e.g. `msgpack6`. When
1588
+ * @param wireFormat Optional format key, e.g. `msgpack6`. When
1589
1589
  * provided, replaces any existing `f=` in the URL. */
1590
- static forClient(url: string, serializationFormat?: string): string;
1590
+ static forClient(url: string, wireFormat?: string): string;
1591
1591
  /** Build a server peer ref from a peer id — returns `server://{id}`. */
1592
1592
  static forServer(id: string): string;
1593
1593
  }
@@ -1656,4 +1656,4 @@ declare function xxh3_64str(input: string, seed?: bigint): bigint;
1656
1656
  */
1657
1657
  declare function computeMethodHash(methodName: string): number;
1658
1658
 
1659
- export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, REMOTE_EXCEPTION_TYPE_REF, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTimeouts, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcError, type RpcErrorFilter, type RpcExceptionInfo, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonSerializationFormat, RpcLimits, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactSerializationFormat, RpcMessagePackSerializationFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerChangeKind, type RpcPeerFactory, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, type RpcReconnectProofParameters, RpcRefBuilder, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcSerializationFormat, RpcSerializationFormatResolver, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, computeReconnectProof, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, genericErrorFilter, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, isReconnectProofSupported, likelyConnected, parseStreamRef, readPolymorphismMarker, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, toExceptionInfo, toRpcStream, wireMethodName, xxh3_64, xxh3_64str };
1659
+ export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, REMOTE_EXCEPTION_TYPE_REF, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTimeouts, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcError, type RpcErrorFilter, type RpcExceptionInfo, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonWireFormat, RpcLimits, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactWireFormat, RpcMessagePackWireFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, RpcPeerChangeKind, type RpcPeerFactory, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, type RpcReconnectProofParameters, RpcRefBuilder, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, RpcWireFormat, RpcWireFormatResolver, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, computeReconnectProof, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, genericErrorFilter, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, isReconnectProofSupported, likelyConnected, parseStreamRef, readPolymorphismMarker, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, toExceptionInfo, toRpcStream, wireMethodName, xxh3_64, xxh3_64str };