@actuallab/rpc 14.4.3 → 14.4.11

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
@@ -1021,6 +1021,7 @@ declare abstract class RpcPeer {
1021
1021
  * (queries) never time out here. */
1022
1022
  private _maintainOutboundCalls;
1023
1023
  get connection(): RpcConnection | undefined;
1024
+ get wireConnection(): RpcConnection | undefined;
1024
1025
  get connectionState(): RpcConnectionState;
1025
1026
  get isConnected(): boolean;
1026
1027
  get ownHandshakeIndex(): number;
@@ -1047,7 +1048,9 @@ declare abstract class RpcPeer {
1047
1048
  * stays in the hub and all client proxies bound to it remain valid. */
1048
1049
  disconnect(): void;
1049
1050
  close(): void;
1050
- /** Send pre-serialized wire data through the current connection. */
1051
+ /** Send pre-serialized wire data through the current connection. Callers are
1052
+ * already gated on `_isConnected`; the check is repeated here so the next one
1053
+ * cannot reintroduce a pre-handshake write. $sys.Handshake does not use this. */
1051
1054
  protected _sendWireData(data: string | Uint8Array): void;
1052
1055
  /** Override in subclasses to handle the remote peer's handshake response. */
1053
1056
  protected _onHandshakeReceived(_handshake: RemoteHandshake): void;
@@ -1326,7 +1329,11 @@ declare class RpcStreamSender<T> implements IRpcObject {
1326
1329
  readonly sourceUsesAbortSignal: boolean;
1327
1330
  /** Next stream index that will be sent (matches .NET's `index`). */
1328
1331
  private _nextIndex;
1329
- private _ended;
1332
+ /** Torn down — `disconnect()` ran. .NET's counterpart is disposal; note it
1333
+ * does NOT mean "an End was sent", which .NET does not track at all. */
1334
+ private _isDisposed;
1335
+ /** The pump has returned. .NET's `WhenRunning.IsCompleted`. */
1336
+ private _isCompleted;
1330
1337
  private _started;
1331
1338
  /** Highest `nextIndex` observed in an ACK so far (matches .NET's `lastAckNextIndex` idiom). */
1332
1339
  private _lastAckedIndex;
@@ -1379,14 +1386,17 @@ declare class RpcStreamSender<T> implements IRpcObject {
1379
1386
  *
1380
1387
  * Advances `_nextIndex` unconditionally — even if the peer is disconnected
1381
1388
  * the item is considered "sent" from the pump's perspective so the replay
1382
- * buffer indexing stays consistent. If a connection is absent, the wire
1389
+ * buffer indexing stays consistent. If the peer isn't connected, the wire
1383
1390
  * message is dropped; the item will be resent from the replay buffer
1384
1391
  * after a reconnect (client sends `Ack(N, mustReset=true)`).
1385
1392
  */
1386
1393
  sendItem(item: T): void;
1387
1394
  /** Send a batch of items to the client. See {@link sendItem} for disconnect semantics. */
1388
1395
  sendBatch(items: T[]): void;
1389
- /** Signal stream completion to the client. */
1396
+ /** Signal stream completion to the client. Re-sendable on purpose: if the
1397
+ * peer was not connected the frame is dropped, and the End stays in the
1398
+ * replay buffer for the next reset ack — .NET has no "already ended" latch
1399
+ * (the End is an ordinary buffer entry, RpcSharedStream.cs:185/239). */
1390
1400
  sendEnd(error?: Error | null): void;
1391
1401
  /**
1392
1402
  * Consume an AsyncIterable and send all items to the client.
@@ -1409,7 +1419,7 @@ declare class RpcStreamSender<T> implements IRpcObject {
1409
1419
  * ACKs the client sends right after it, so `mustReset` accumulates across
1410
1420
  * the whole batch — the newest ACK alone can't represent it. */
1411
1421
  private _tryProcessAcks;
1412
- /** Wait until an ACK is pending (or `_ended`). */
1422
+ /** Wait until an ACK is pending (or the sender is torn down). */
1413
1423
  private _waitAckReady;
1414
1424
  private _sampleRtt;
1415
1425
  reconnect(): void;
@@ -1511,8 +1521,11 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1511
1521
  /** Create a remote (target-side) stream from a parsed stream reference and peer. */
1512
1522
  constructor(ref: RpcStreamRef, peer: RpcPeer);
1513
1523
  /**
1514
- * For local streams: resolves when the sender finishes pumping (after `toRef()` was called).
1515
- * Rejects if the source throws. Throws if `toRef()` hasn't been called yet.
1524
+ * For local streams: resolves once the consumer acknowledges the end
1525
+ * ($sys.AckEnd) or the sender is disconnected — NOT when the source drains,
1526
+ * since the sender keeps serving acks after End so a reconnect can replay it.
1527
+ * A source error reaches the consumer as $sys.End(error) instead of rejecting
1528
+ * this. Throws if `toRef()` hasn't been called yet.
1516
1529
  */
1517
1530
  get whenSent(): Promise<void>;
1518
1531
  /** Local sender backing this stream after `toRef()` has been called.
package/dist/index.d.ts CHANGED
@@ -1021,6 +1021,7 @@ declare abstract class RpcPeer {
1021
1021
  * (queries) never time out here. */
1022
1022
  private _maintainOutboundCalls;
1023
1023
  get connection(): RpcConnection | undefined;
1024
+ get wireConnection(): RpcConnection | undefined;
1024
1025
  get connectionState(): RpcConnectionState;
1025
1026
  get isConnected(): boolean;
1026
1027
  get ownHandshakeIndex(): number;
@@ -1047,7 +1048,9 @@ declare abstract class RpcPeer {
1047
1048
  * stays in the hub and all client proxies bound to it remain valid. */
1048
1049
  disconnect(): void;
1049
1050
  close(): void;
1050
- /** Send pre-serialized wire data through the current connection. */
1051
+ /** Send pre-serialized wire data through the current connection. Callers are
1052
+ * already gated on `_isConnected`; the check is repeated here so the next one
1053
+ * cannot reintroduce a pre-handshake write. $sys.Handshake does not use this. */
1051
1054
  protected _sendWireData(data: string | Uint8Array): void;
1052
1055
  /** Override in subclasses to handle the remote peer's handshake response. */
1053
1056
  protected _onHandshakeReceived(_handshake: RemoteHandshake): void;
@@ -1326,7 +1329,11 @@ declare class RpcStreamSender<T> implements IRpcObject {
1326
1329
  readonly sourceUsesAbortSignal: boolean;
1327
1330
  /** Next stream index that will be sent (matches .NET's `index`). */
1328
1331
  private _nextIndex;
1329
- private _ended;
1332
+ /** Torn down — `disconnect()` ran. .NET's counterpart is disposal; note it
1333
+ * does NOT mean "an End was sent", which .NET does not track at all. */
1334
+ private _isDisposed;
1335
+ /** The pump has returned. .NET's `WhenRunning.IsCompleted`. */
1336
+ private _isCompleted;
1330
1337
  private _started;
1331
1338
  /** Highest `nextIndex` observed in an ACK so far (matches .NET's `lastAckNextIndex` idiom). */
1332
1339
  private _lastAckedIndex;
@@ -1379,14 +1386,17 @@ declare class RpcStreamSender<T> implements IRpcObject {
1379
1386
  *
1380
1387
  * Advances `_nextIndex` unconditionally — even if the peer is disconnected
1381
1388
  * the item is considered "sent" from the pump's perspective so the replay
1382
- * buffer indexing stays consistent. If a connection is absent, the wire
1389
+ * buffer indexing stays consistent. If the peer isn't connected, the wire
1383
1390
  * message is dropped; the item will be resent from the replay buffer
1384
1391
  * after a reconnect (client sends `Ack(N, mustReset=true)`).
1385
1392
  */
1386
1393
  sendItem(item: T): void;
1387
1394
  /** Send a batch of items to the client. See {@link sendItem} for disconnect semantics. */
1388
1395
  sendBatch(items: T[]): void;
1389
- /** Signal stream completion to the client. */
1396
+ /** Signal stream completion to the client. Re-sendable on purpose: if the
1397
+ * peer was not connected the frame is dropped, and the End stays in the
1398
+ * replay buffer for the next reset ack — .NET has no "already ended" latch
1399
+ * (the End is an ordinary buffer entry, RpcSharedStream.cs:185/239). */
1390
1400
  sendEnd(error?: Error | null): void;
1391
1401
  /**
1392
1402
  * Consume an AsyncIterable and send all items to the client.
@@ -1409,7 +1419,7 @@ declare class RpcStreamSender<T> implements IRpcObject {
1409
1419
  * ACKs the client sends right after it, so `mustReset` accumulates across
1410
1420
  * the whole batch — the newest ACK alone can't represent it. */
1411
1421
  private _tryProcessAcks;
1412
- /** Wait until an ACK is pending (or `_ended`). */
1422
+ /** Wait until an ACK is pending (or the sender is torn down). */
1413
1423
  private _waitAckReady;
1414
1424
  private _sampleRtt;
1415
1425
  reconnect(): void;
@@ -1511,8 +1521,11 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
1511
1521
  /** Create a remote (target-side) stream from a parsed stream reference and peer. */
1512
1522
  constructor(ref: RpcStreamRef, peer: RpcPeer);
1513
1523
  /**
1514
- * For local streams: resolves when the sender finishes pumping (after `toRef()` was called).
1515
- * Rejects if the source throws. Throws if `toRef()` hasn't been called yet.
1524
+ * For local streams: resolves once the consumer acknowledges the end
1525
+ * ($sys.AckEnd) or the sender is disconnected — NOT when the source drains,
1526
+ * since the sender keeps serving acks after End so a reconnect can replay it.
1527
+ * A source error reaches the consumer as $sys.End(error) instead of rejecting
1528
+ * this. Throws if `toRef()` hasn't been called yet.
1516
1529
  */
1517
1530
  get whenSent(): Promise<void>;
1518
1531
  /** Local sender backing this stream after `toRef()` has been called.