@actuallab/rpc 12.3.83 → 12.4.1

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
@@ -748,7 +748,7 @@ declare const RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
748
748
  /** Maximum time to wait for the server's handshake response after opening the socket. */
749
749
  declare const HANDSHAKE_TIMEOUT_MS = 10000;
750
750
  /** Builds the WebSocket connection URL for an RpcClientPeer. */
751
- type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string;
751
+ type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string | Promise<string>;
752
752
  /** Default connection URL provider — sets `clientId` and `f` query parameters,
753
753
  * replacing any existing values to keep the wire format consistent with the
754
754
  * peer's actual `serializationFormat`. */
@@ -995,7 +995,7 @@ interface RpcStreamRef {
995
995
  readonly hostId: string;
996
996
  readonly localId: number;
997
997
  readonly ackPeriod: number;
998
- readonly ackAdvance: number;
998
+ readonly bufferSize: number;
999
999
  readonly allowReconnect: boolean;
1000
1000
  readonly isRealTime: boolean;
1001
1001
  }
@@ -1009,13 +1009,13 @@ type RpcStreamSource<T> = AsyncIterable<T> | ((abortSignal: AbortSignal) => Asyn
1009
1009
  /** Configuration options for creating a local (origin-side) RpcStream. */
1010
1010
  interface RpcStreamOptions<T> {
1011
1011
  ackPeriod?: number;
1012
- ackAdvance?: number;
1012
+ bufferSize?: number;
1013
1013
  allowReconnect?: boolean;
1014
1014
  isRealTime?: boolean;
1015
1015
  canSkipTo?: (item: T) => boolean;
1016
1016
  }
1017
1017
  /**
1018
- * Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{ackAdvance}".
1018
+ * Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{bufferSize}".
1019
1019
  * Returns null if the value is not a valid stream reference.
1020
1020
  */
1021
1021
  declare function parseStreamRef(value: unknown): RpcStreamRef | null;
@@ -1047,7 +1047,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1047
1047
  readonly isRealTime: boolean;
1048
1048
  readonly canSkipTo: (item: T) => boolean;
1049
1049
  readonly ackPeriod: number;
1050
- readonly ackAdvance: number;
1050
+ readonly bufferSize: number;
1051
1051
  readonly localSource?: RpcStreamSource<T>;
1052
1052
  readonly peer: RpcPeer;
1053
1053
  private _sender?;
@@ -1078,7 +1078,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1078
1078
  * stream reference.
1079
1079
  *
1080
1080
  * For binary peers the ref is a MessagePack-compatible object
1081
- * (`{ SerializedId, AckPeriod, AckAdvance, AllowReconnect }`);
1081
+ * (`{ SerializedId, AckPeriod, BufferSize, AllowReconnect }`);
1082
1082
  * for text peers it is a comma-separated string.
1083
1083
  *
1084
1084
  * Can only be called once per stream.
@@ -1104,7 +1104,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1104
1104
  * Recursively walks a deserialized value and replaces any stream ref strings
1105
1105
  * with live RpcStream<unknown> instances registered on the given peer.
1106
1106
  * This handles nested stream refs inside complex return types (e.g. Table<T>
1107
- * containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{ackAdvance}").
1107
+ * containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{bufferSize}").
1108
1108
  */
1109
1109
  declare function resolveStreamRefs(value: unknown, peer: RpcPeer): unknown;
1110
1110
 
@@ -1123,13 +1123,12 @@ declare function resolveStreamRefs(value: unknown, peer: RpcPeer): unknown;
1123
1123
  * The pump is ACK-driven: the main loop blocks on `_whenAckReady` until a
1124
1124
  * client ACK is queued, processes it (updating `_lastAckedIndex`, rewinding
1125
1125
  * `_index` on mustReset, trimming the replay buffer), then sends items up
1126
- * to `ack.nextIndex + ackAdvance`. While the peer is disconnected no ACKs
1126
+ * to `ack.nextIndex + bufferSize`. While the peer is disconnected no ACKs
1127
1127
  * arrive, so the source is never pulled — the sender naturally pauses
1128
1128
  * instead of spinning.
1129
1129
  *
1130
1130
  * Direct port of .NET `RpcSharedStream<T>` at
1131
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs — including the
1132
- * separate non-real-time / real-time pump variants.
1131
+ * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs.
1133
1132
  */
1134
1133
  declare class RpcStreamSender<T> implements IRpcObject {
1135
1134
  private static readonly _emptyGuid;
@@ -1140,7 +1139,7 @@ declare class RpcStreamSender<T> implements IRpcObject {
1140
1139
  readonly canSkipTo: (item: T) => boolean;
1141
1140
  readonly peer: RpcPeer;
1142
1141
  readonly ackPeriod: number;
1143
- readonly ackAdvance: number;
1142
+ readonly bufferSize: number;
1144
1143
  /**
1145
1144
  * If true, the source was produced by a factory `(abortSignal) => AsyncIterable<T>`
1146
1145
  * and may honor the AbortSignal to exit gracefully. `disconnect()` first aborts
@@ -1161,7 +1160,7 @@ declare class RpcStreamSender<T> implements IRpcObject {
1161
1160
  private _iterator;
1162
1161
  private _acks;
1163
1162
  private _whenAckReady;
1164
- constructor(peer: RpcPeer, ackPeriod?: number, ackAdvance?: number, allowReconnect?: boolean, isRealTime?: boolean, canSkipTo?: (item: T) => boolean, sourceUsesAbortSignal?: boolean);
1163
+ constructor(peer: RpcPeer, ackPeriod?: number, bufferSize?: number, allowReconnect?: boolean, isRealTime?: boolean, canSkipTo?: (item: T) => boolean, sourceUsesAbortSignal?: boolean);
1165
1164
  /** AbortSignal that is aborted when the sender is disconnected. */
1166
1165
  get abortSignal(): AbortSignal;
1167
1166
  /** Returns the stream reference string for the $sys.Ok response. */
@@ -1192,25 +1191,16 @@ declare class RpcStreamSender<T> implements IRpcObject {
1192
1191
  /**
1193
1192
  * Consume an AsyncIterable and send all items to the client.
1194
1193
  *
1195
- * Dispatches to the non-real-time or real-time pump, matching .NET
1196
- * `RpcSharedStream<T>.OnRun` at
1197
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs:105-108.
1194
+ * Matches .NET `RpcSharedStream<T>.OnRun` at
1195
+ * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs.
1198
1196
  */
1199
1197
  writeFrom(source: AsyncIterable<T>): Promise<void>;
1200
1198
  /**
1201
- * Non-real-time pump — back-pressure through buffered ACKs.
1202
- *
1203
- * Direct port of .NET `OnRunNonRealTime` at
1204
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs:110-217.
1205
- */
1206
- private _runNonRealTime;
1207
- /**
1208
- * Real-time pump — drops stale items to stay close to the source's head.
1209
- *
1210
- * Direct port of .NET `OnRunRealTime` at
1211
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs:219-420.
1199
+ * ACK-driven pump. Non-real-time streams apply normal backpressure at
1200
+ * `bufferSize`; real-time streams may compact the already-buffered unsent
1201
+ * suffix to the latest buffered `canSkipTo` item after the consumer ACKs.
1212
1202
  */
1213
- private _runRealTime;
1203
+ private _run;
1214
1204
  /** Drain all queued ACKs, returning the most recent one (or null if none). */
1215
1205
  private _tryProcessAcks;
1216
1206
  /** Wait for the ACK queue to have at least one entry (or `_ended`). */
package/dist/index.d.ts CHANGED
@@ -748,7 +748,7 @@ declare const RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
748
748
  /** Maximum time to wait for the server's handshake response after opening the socket. */
749
749
  declare const HANDSHAKE_TIMEOUT_MS = 10000;
750
750
  /** Builds the WebSocket connection URL for an RpcClientPeer. */
751
- type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string;
751
+ type RpcConnectionUrlResolver = (peer: RpcClientPeer) => string | Promise<string>;
752
752
  /** Default connection URL provider — sets `clientId` and `f` query parameters,
753
753
  * replacing any existing values to keep the wire format consistent with the
754
754
  * peer's actual `serializationFormat`. */
@@ -995,7 +995,7 @@ interface RpcStreamRef {
995
995
  readonly hostId: string;
996
996
  readonly localId: number;
997
997
  readonly ackPeriod: number;
998
- readonly ackAdvance: number;
998
+ readonly bufferSize: number;
999
999
  readonly allowReconnect: boolean;
1000
1000
  readonly isRealTime: boolean;
1001
1001
  }
@@ -1009,13 +1009,13 @@ type RpcStreamSource<T> = AsyncIterable<T> | ((abortSignal: AbortSignal) => Asyn
1009
1009
  /** Configuration options for creating a local (origin-side) RpcStream. */
1010
1010
  interface RpcStreamOptions<T> {
1011
1011
  ackPeriod?: number;
1012
- ackAdvance?: number;
1012
+ bufferSize?: number;
1013
1013
  allowReconnect?: boolean;
1014
1014
  isRealTime?: boolean;
1015
1015
  canSkipTo?: (item: T) => boolean;
1016
1016
  }
1017
1017
  /**
1018
- * Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{ackAdvance}".
1018
+ * Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{bufferSize}".
1019
1019
  * Returns null if the value is not a valid stream reference.
1020
1020
  */
1021
1021
  declare function parseStreamRef(value: unknown): RpcStreamRef | null;
@@ -1047,7 +1047,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1047
1047
  readonly isRealTime: boolean;
1048
1048
  readonly canSkipTo: (item: T) => boolean;
1049
1049
  readonly ackPeriod: number;
1050
- readonly ackAdvance: number;
1050
+ readonly bufferSize: number;
1051
1051
  readonly localSource?: RpcStreamSource<T>;
1052
1052
  readonly peer: RpcPeer;
1053
1053
  private _sender?;
@@ -1078,7 +1078,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1078
1078
  * stream reference.
1079
1079
  *
1080
1080
  * For binary peers the ref is a MessagePack-compatible object
1081
- * (`{ SerializedId, AckPeriod, AckAdvance, AllowReconnect }`);
1081
+ * (`{ SerializedId, AckPeriod, BufferSize, AllowReconnect }`);
1082
1082
  * for text peers it is a comma-separated string.
1083
1083
  *
1084
1084
  * Can only be called once per stream.
@@ -1104,7 +1104,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1104
1104
  * Recursively walks a deserialized value and replaces any stream ref strings
1105
1105
  * with live RpcStream<unknown> instances registered on the given peer.
1106
1106
  * This handles nested stream refs inside complex return types (e.g. Table<T>
1107
- * containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{ackAdvance}").
1107
+ * containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{bufferSize}").
1108
1108
  */
1109
1109
  declare function resolveStreamRefs(value: unknown, peer: RpcPeer): unknown;
1110
1110
 
@@ -1123,13 +1123,12 @@ declare function resolveStreamRefs(value: unknown, peer: RpcPeer): unknown;
1123
1123
  * The pump is ACK-driven: the main loop blocks on `_whenAckReady` until a
1124
1124
  * client ACK is queued, processes it (updating `_lastAckedIndex`, rewinding
1125
1125
  * `_index` on mustReset, trimming the replay buffer), then sends items up
1126
- * to `ack.nextIndex + ackAdvance`. While the peer is disconnected no ACKs
1126
+ * to `ack.nextIndex + bufferSize`. While the peer is disconnected no ACKs
1127
1127
  * arrive, so the source is never pulled — the sender naturally pauses
1128
1128
  * instead of spinning.
1129
1129
  *
1130
1130
  * Direct port of .NET `RpcSharedStream<T>` at
1131
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs — including the
1132
- * separate non-real-time / real-time pump variants.
1131
+ * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs.
1133
1132
  */
1134
1133
  declare class RpcStreamSender<T> implements IRpcObject {
1135
1134
  private static readonly _emptyGuid;
@@ -1140,7 +1139,7 @@ declare class RpcStreamSender<T> implements IRpcObject {
1140
1139
  readonly canSkipTo: (item: T) => boolean;
1141
1140
  readonly peer: RpcPeer;
1142
1141
  readonly ackPeriod: number;
1143
- readonly ackAdvance: number;
1142
+ readonly bufferSize: number;
1144
1143
  /**
1145
1144
  * If true, the source was produced by a factory `(abortSignal) => AsyncIterable<T>`
1146
1145
  * and may honor the AbortSignal to exit gracefully. `disconnect()` first aborts
@@ -1161,7 +1160,7 @@ declare class RpcStreamSender<T> implements IRpcObject {
1161
1160
  private _iterator;
1162
1161
  private _acks;
1163
1162
  private _whenAckReady;
1164
- constructor(peer: RpcPeer, ackPeriod?: number, ackAdvance?: number, allowReconnect?: boolean, isRealTime?: boolean, canSkipTo?: (item: T) => boolean, sourceUsesAbortSignal?: boolean);
1163
+ constructor(peer: RpcPeer, ackPeriod?: number, bufferSize?: number, allowReconnect?: boolean, isRealTime?: boolean, canSkipTo?: (item: T) => boolean, sourceUsesAbortSignal?: boolean);
1165
1164
  /** AbortSignal that is aborted when the sender is disconnected. */
1166
1165
  get abortSignal(): AbortSignal;
1167
1166
  /** Returns the stream reference string for the $sys.Ok response. */
@@ -1192,25 +1191,16 @@ declare class RpcStreamSender<T> implements IRpcObject {
1192
1191
  /**
1193
1192
  * Consume an AsyncIterable and send all items to the client.
1194
1193
  *
1195
- * Dispatches to the non-real-time or real-time pump, matching .NET
1196
- * `RpcSharedStream<T>.OnRun` at
1197
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs:105-108.
1194
+ * Matches .NET `RpcSharedStream<T>.OnRun` at
1195
+ * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs.
1198
1196
  */
1199
1197
  writeFrom(source: AsyncIterable<T>): Promise<void>;
1200
1198
  /**
1201
- * Non-real-time pump — back-pressure through buffered ACKs.
1202
- *
1203
- * Direct port of .NET `OnRunNonRealTime` at
1204
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs:110-217.
1205
- */
1206
- private _runNonRealTime;
1207
- /**
1208
- * Real-time pump — drops stale items to stay close to the source's head.
1209
- *
1210
- * Direct port of .NET `OnRunRealTime` at
1211
- * src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs:219-420.
1199
+ * ACK-driven pump. Non-real-time streams apply normal backpressure at
1200
+ * `bufferSize`; real-time streams may compact the already-buffered unsent
1201
+ * suffix to the latest buffered `canSkipTo` item after the consumer ACKs.
1212
1202
  */
1213
- private _runRealTime;
1203
+ private _run;
1214
1204
  /** Drain all queued ACKs, returning the most recent one (or null if none). */
1215
1205
  private _tryProcessAcks;
1216
1206
  /** Wait for the ACK queue to have at least one entry (or `_ended`). */