@actuallab/rpc 15.1.62 → 16.0.47

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.cjs CHANGED
@@ -46,11 +46,11 @@ __export(index_exports, {
46
46
  RpcHub: () => RpcHub,
47
47
  RpcInboundCall: () => RpcInboundCall,
48
48
  RpcInboundCallTracker: () => RpcInboundCallTracker,
49
- RpcJsonSerializationFormat: () => RpcJsonSerializationFormat,
49
+ RpcJsonWireFormat: () => RpcJsonWireFormat,
50
50
  RpcLimits: () => RpcLimits,
51
51
  RpcMessageChannelConnection: () => RpcMessageChannelConnection,
52
- RpcMessagePackCompactSerializationFormat: () => RpcMessagePackCompactSerializationFormat,
53
- RpcMessagePackSerializationFormat: () => RpcMessagePackSerializationFormat,
52
+ RpcMessagePackCompactWireFormat: () => RpcMessagePackCompactWireFormat,
53
+ RpcMessagePackWireFormat: () => RpcMessagePackWireFormat,
54
54
  RpcMethodRegistry: () => RpcMethodRegistry,
55
55
  RpcObjectKind: () => RpcObjectKind,
56
56
  RpcOutboundCall: () => RpcOutboundCall,
@@ -62,8 +62,6 @@ __export(index_exports, {
62
62
  RpcRefBuilder: () => RpcRefBuilder,
63
63
  RpcRemoteExecutionMode: () => RpcRemoteExecutionMode,
64
64
  RpcRemoteObjectTracker: () => RpcRemoteObjectTracker,
65
- RpcSerializationFormat: () => RpcSerializationFormat,
66
- RpcSerializationFormatResolver: () => RpcSerializationFormatResolver,
67
65
  RpcServerPeer: () => RpcServerPeer,
68
66
  RpcServiceHost: () => RpcServiceHost,
69
67
  RpcSharedObjectTracker: () => RpcSharedObjectTracker,
@@ -74,6 +72,8 @@ __export(index_exports, {
74
72
  RpcSystemCalls: () => RpcSystemCalls,
75
73
  RpcType: () => RpcType,
76
74
  RpcWebSocketConnection: () => RpcWebSocketConnection,
75
+ RpcWireFormat: () => RpcWireFormat,
76
+ RpcWireFormatResolver: () => RpcWireFormatResolver,
77
77
  WebSocketState: () => WebSocketState,
78
78
  computeMethodHash: () => computeMethodHash,
79
79
  computeReconnectProof: () => computeReconnectProof,
@@ -541,16 +541,16 @@ var RpcWebSocketConnection = class {
541
541
  get decoder() {
542
542
  return this._decoder;
543
543
  }
544
- _format;
544
+ _wireFormat;
545
545
  _methodRegistry;
546
546
  binaryMode;
547
547
  messageReceived = new import_core2.EventHandlerSet();
548
548
  closed = new import_core2.EventHandlerSet();
549
549
  error = new import_core2.EventHandlerSet();
550
- constructor(ws, binaryMode = false, format, methodRegistry) {
550
+ constructor(ws, binaryMode = false, wireFormat, methodRegistry) {
551
551
  this._ws = ws;
552
552
  this.binaryMode = binaryMode;
553
- this._format = format;
553
+ this._wireFormat = wireFormat;
554
554
  this._methodRegistry = methodRegistry;
555
555
  if (binaryMode && ws.binaryType !== void 0)
556
556
  ws.binaryType = "arraybuffer";
@@ -624,10 +624,10 @@ var RpcWebSocketConnection = class {
624
624
  sendBinaryBatch(messages) {
625
625
  this._sendRaw(serializeBinaryFrame(messages));
626
626
  }
627
- /** Split a binary frame using the format (compact-aware) or default splitter. */
627
+ /** Split a binary frame using the wire format (compact-aware) or default splitter. */
628
628
  _splitBinary(frame) {
629
- if (this._format) {
630
- return this._format.splitBinaryFrame(
629
+ if (this._wireFormat) {
630
+ return this._wireFormat.splitBinaryFrame(
631
631
  frame,
632
632
  this._decoder,
633
633
  this._methodRegistry
@@ -1215,7 +1215,7 @@ var RpcSystemCallHandler = class {
1215
1215
  if (unknownIds.length > 0)
1216
1216
  peer.hub.systemCallSender.disconnect(
1217
1217
  peer.wireConnection,
1218
- peer.serializationFormat,
1218
+ peer.wireFormat,
1219
1219
  unknownIds
1220
1220
  );
1221
1221
  }
@@ -1266,7 +1266,7 @@ var RpcSystemCallHandler = class {
1266
1266
  else if (peer.wireConnection !== void 0)
1267
1267
  peer.hub.systemCallSender.disconnect(
1268
1268
  peer.wireConnection,
1269
- peer.serializationFormat,
1269
+ peer.wireFormat,
1270
1270
  [relatedId]
1271
1271
  );
1272
1272
  break;
@@ -1278,7 +1278,7 @@ var RpcSystemCallHandler = class {
1278
1278
  else if (peer.wireConnection !== void 0)
1279
1279
  peer.hub.systemCallSender.disconnect(
1280
1280
  peer.wireConnection,
1281
- peer.serializationFormat,
1281
+ peer.wireFormat,
1282
1282
  [relatedId]
1283
1283
  );
1284
1284
  break;
@@ -1316,7 +1316,7 @@ var RpcSystemCallHandler = class {
1316
1316
  const got = typeof handshakeIndex === "number" ? handshakeIndex : `<${typeof handshakeIndex}>`;
1317
1317
  peer.hub.systemCallSender.error(
1318
1318
  conn,
1319
- peer.serializationFormat,
1319
+ peer.wireFormat,
1320
1320
  relatedId,
1321
1321
  new Error(
1322
1322
  `TooLateToReconnect: own handshake index ${peer.ownHandshakeIndex} != ${got}`
@@ -1327,7 +1327,7 @@ var RpcSystemCallHandler = class {
1327
1327
  if (!peer.tryClaimReconnect()) {
1328
1328
  peer.hub.systemCallSender.error(
1329
1329
  conn,
1330
- peer.serializationFormat,
1330
+ peer.wireFormat,
1331
1331
  relatedId,
1332
1332
  new Error("TooLateToReconnect: this connection was already reconnected")
1333
1333
  );
@@ -1356,8 +1356,8 @@ var RpcSystemCallHandler = class {
1356
1356
  } catch {
1357
1357
  }
1358
1358
  const responseBytes = IncreasingSeqCompressor.serialize(unknownIds);
1359
- const responseValue = peer.serializationFormat.isBinary ? responseBytes : base64Encode(responseBytes);
1360
- peer.hub.systemCallSender.ok(conn, peer.serializationFormat, relatedId, responseValue);
1359
+ const responseValue = peer.wireFormat.isBinary ? responseBytes : base64Encode(responseBytes);
1360
+ peer.hub.systemCallSender.ok(conn, peer.wireFormat, relatedId, responseValue);
1361
1361
  }
1362
1362
  };
1363
1363
  function polymorphicPayloadError(method, got, expected) {
@@ -1432,8 +1432,8 @@ var RpcSystemCallSender = class _RpcSystemCallSender {
1432
1432
  * {@link genericErrorFilter}) on a TS-hosted server, where handler errors
1433
1433
  * would otherwise disclose internal details to unauthenticated callers. */
1434
1434
  errorFilter;
1435
- _send(conn, format, envelope, args) {
1436
- const wireData = format.serializeMessage(
1435
+ _send(conn, wireFormat, envelope, args) {
1436
+ const wireData = wireFormat.serializeMessage(
1437
1437
  envelope,
1438
1438
  args,
1439
1439
  conn.encoder,
@@ -1445,88 +1445,88 @@ var RpcSystemCallSender = class _RpcSystemCallSender {
1445
1445
  conn.sendBinary(wireData);
1446
1446
  }
1447
1447
  }
1448
- handshake(conn, format, peerId, hubId, index) {
1449
- const handshakeArg = format.isBinary ? [peerId, null, hubId, 2, index] : {
1448
+ handshake(conn, wireFormat, peerId, hubId, index) {
1449
+ const handshakeArg = wireFormat.isBinary ? [peerId, null, hubId, 2, index] : {
1450
1450
  RemotePeerId: peerId,
1451
1451
  RemoteApiVersionSet: null,
1452
1452
  RemoteHubId: hubId,
1453
1453
  ProtocolVersion: 2,
1454
1454
  Index: index
1455
1455
  };
1456
- this._send(conn, format, { Method: RpcSystemCalls.handshake }, [
1456
+ this._send(conn, wireFormat, { Method: RpcSystemCalls.handshake }, [
1457
1457
  handshakeArg
1458
1458
  ]);
1459
1459
  }
1460
- ok(conn, format, relatedId, result) {
1460
+ ok(conn, wireFormat, relatedId, result) {
1461
1461
  try {
1462
1462
  this._send(
1463
1463
  conn,
1464
- format,
1464
+ wireFormat,
1465
1465
  { Method: RpcSystemCalls.ok, RelatedId: relatedId },
1466
1466
  [result]
1467
1467
  );
1468
1468
  } catch (e) {
1469
1469
  errorLog?.log(`Failed to send Ok response for call #${relatedId}`, e);
1470
- this.error(conn, format, relatedId, e);
1470
+ this.error(conn, wireFormat, relatedId, e);
1471
1471
  }
1472
1472
  }
1473
- error(conn, format, relatedId, error) {
1473
+ error(conn, wireFormat, relatedId, error) {
1474
1474
  this._send(
1475
1475
  conn,
1476
- format,
1476
+ wireFormat,
1477
1477
  { Method: RpcSystemCalls.error, RelatedId: relatedId },
1478
1478
  [toExceptionInfo(error, this.errorFilter)]
1479
1479
  );
1480
1480
  }
1481
- cancel(conn, format, relatedId) {
1482
- this._send(conn, format, {
1481
+ cancel(conn, wireFormat, relatedId) {
1482
+ this._send(conn, wireFormat, {
1483
1483
  Method: RpcSystemCalls.cancel,
1484
1484
  RelatedId: relatedId
1485
1485
  });
1486
1486
  }
1487
- keepAlive(conn, format, activeCallIds) {
1488
- this._send(conn, format, { Method: RpcSystemCalls.keepAlive }, [
1487
+ keepAlive(conn, wireFormat, activeCallIds) {
1488
+ this._send(conn, wireFormat, { Method: RpcSystemCalls.keepAlive }, [
1489
1489
  activeCallIds
1490
1490
  ]);
1491
1491
  }
1492
1492
  // Tells the remote peer the listed shared-object ids are gone on our side,
1493
1493
  // so its matching remote objects (e.g. RpcStream consumers) fail fast
1494
1494
  // instead of hanging. Mirrors .NET RpcSystemCallSender.Disconnect.
1495
- disconnect(conn, format, localIds) {
1496
- this._send(conn, format, { Method: RpcSystemCalls.disconnect }, [
1495
+ disconnect(conn, wireFormat, localIds) {
1496
+ this._send(conn, wireFormat, { Method: RpcSystemCalls.disconnect }, [
1497
1497
  localIds
1498
1498
  ]);
1499
1499
  }
1500
- item(conn, format, localId, index, item) {
1500
+ item(conn, wireFormat, localId, index, item) {
1501
1501
  this._itemEnv.RelatedId = localId;
1502
1502
  this._itemArgs[0] = index;
1503
1503
  this._itemArgs[1] = item;
1504
- this._send(conn, format, this._itemEnv, this._itemArgs);
1504
+ this._send(conn, wireFormat, this._itemEnv, this._itemArgs);
1505
1505
  this._itemArgs[1] = null;
1506
1506
  }
1507
- batch(conn, format, localId, index, items) {
1507
+ batch(conn, wireFormat, localId, index, items) {
1508
1508
  this._batchEnv.RelatedId = localId;
1509
1509
  this._batchArgs[0] = index;
1510
1510
  this._batchArgs[1] = items;
1511
- this._send(conn, format, this._batchEnv, this._batchArgs);
1511
+ this._send(conn, wireFormat, this._batchEnv, this._batchArgs);
1512
1512
  this._batchArgs[1] = null;
1513
1513
  }
1514
- end(conn, format, localId, index, error = _RpcSystemCallSender.NO_ERROR) {
1514
+ end(conn, wireFormat, localId, index, error = _RpcSystemCallSender.NO_ERROR) {
1515
1515
  this._endEnv.RelatedId = localId;
1516
1516
  this._endArgs[0] = index;
1517
1517
  this._endArgs[1] = error;
1518
- this._send(conn, format, this._endEnv, this._endArgs);
1518
+ this._send(conn, wireFormat, this._endEnv, this._endArgs);
1519
1519
  }
1520
- ack(conn, format, localId, nextIndex, hostId) {
1520
+ ack(conn, wireFormat, localId, nextIndex, hostId) {
1521
1521
  this._ackEnv.RelatedId = localId;
1522
1522
  this._ackArgs[0] = nextIndex;
1523
1523
  this._ackArgs[1] = hostId;
1524
- this._send(conn, format, this._ackEnv, this._ackArgs);
1524
+ this._send(conn, wireFormat, this._ackEnv, this._ackArgs);
1525
1525
  }
1526
- ackEnd(conn, format, localId, hostId) {
1526
+ ackEnd(conn, wireFormat, localId, hostId) {
1527
1527
  this._ackEndEnv.RelatedId = localId;
1528
1528
  this._ackEndArgs[0] = hostId;
1529
- this._send(conn, format, this._ackEndEnv, this._ackEndArgs);
1529
+ this._send(conn, wireFormat, this._ackEndEnv, this._ackEndArgs);
1530
1530
  }
1531
1531
  };
1532
1532
 
@@ -1539,7 +1539,7 @@ var import_core6 = require("@actuallab/core");
1539
1539
 
1540
1540
  // src/rpc-stream-sender.ts
1541
1541
  var import_core5 = require("@actuallab/core");
1542
- var { warnLog: warnLog5 } = getLogs("RpcSharedStream");
1542
+ var { warnLog: warnLog5, errorLog: errorLog2 } = getLogs("RpcSharedStream");
1543
1543
  function _ignore() {
1544
1544
  }
1545
1545
  var DEFAULT_ACK_PERIOD = 256;
@@ -1715,7 +1715,7 @@ var RpcStreamSender = class _RpcStreamSender {
1715
1715
  _sendDisconnect() {
1716
1716
  const conn = this.peer.wireConnection;
1717
1717
  if (conn)
1718
- this.peer.hub.systemCallSender.disconnect(conn, this.peer.serializationFormat, [this.id.localId]);
1718
+ this.peer.hub.systemCallSender.disconnect(conn, this.peer.wireFormat, [this.id.localId]);
1719
1719
  this.disconnect();
1720
1720
  }
1721
1721
  /** Called by system call handler when $sys.AckEnd is received from the client. */
@@ -1737,7 +1737,7 @@ var RpcStreamSender = class _RpcStreamSender {
1737
1737
  if (conn) {
1738
1738
  this.peer.hub.systemCallSender.item(
1739
1739
  conn,
1740
- this.peer.serializationFormat,
1740
+ this.peer.wireFormat,
1741
1741
  this.id.localId,
1742
1742
  this._nextIndex,
1743
1743
  item
@@ -1755,7 +1755,7 @@ var RpcStreamSender = class _RpcStreamSender {
1755
1755
  if (conn) {
1756
1756
  this.peer.hub.systemCallSender.batch(
1757
1757
  conn,
1758
- this.peer.serializationFormat,
1758
+ this.peer.wireFormat,
1759
1759
  this.id.localId,
1760
1760
  this._nextIndex,
1761
1761
  items
@@ -1775,7 +1775,7 @@ var RpcStreamSender = class _RpcStreamSender {
1775
1775
  const errorInfo = error ? toExceptionInfo(error) : { TypeRef: "", Message: "" };
1776
1776
  this.peer.hub.systemCallSender.end(
1777
1777
  conn,
1778
- this.peer.serializationFormat,
1778
+ this.peer.wireFormat,
1779
1779
  this.id.localId,
1780
1780
  index,
1781
1781
  errorInfo
@@ -1953,7 +1953,14 @@ var RpcStreamSender = class _RpcStreamSender {
1953
1953
  while (this._nextIndex < maxIndex && bufferIndex < buffer.count) {
1954
1954
  const item = buffer.get(bufferIndex++);
1955
1955
  if (item.kind === "value") {
1956
- this.sendItem(item.value);
1956
+ try {
1957
+ this.sendItem(item.value);
1958
+ } catch (e) {
1959
+ const error = e instanceof Error ? e : new Error(String(e));
1960
+ errorLog2?.log(`Failed to send an item of stream #${this.id.localId}:`, error);
1961
+ this.sendEnd(error);
1962
+ continue nextAck;
1963
+ }
1957
1964
  } else {
1958
1965
  this.sendEnd(item.kind === "error" ? item.error : void 0);
1959
1966
  continue nextAck;
@@ -2234,7 +2241,7 @@ var RpcStream = class _RpcStream {
2234
2241
  this._sender = sender;
2235
2242
  const source = isFactory ? this.localSource(sender.abortSignal) : this.localSource;
2236
2243
  this._whenSent = sender.writeFrom(source);
2237
- this._toRefValue = peer.serializationFormat.isBinary ? {
2244
+ this._toRefValue = peer.wireFormat.isBinary ? {
2238
2245
  SerializedId: [sender.id.hostId, sender.id.localId],
2239
2246
  AckPeriod: sender.ackPeriod,
2240
2247
  AckAdvance: sender.ackAdvance,
@@ -2459,7 +2466,7 @@ var RpcStream = class _RpcStream {
2459
2466
  const hostId = mustReset ? this.id.hostId : _RpcStream._emptyGuid;
2460
2467
  this.peer.hub.systemCallSender.ack(
2461
2468
  conn,
2462
- this.peer.serializationFormat,
2469
+ this.peer.wireFormat,
2463
2470
  this.id.localId,
2464
2471
  nextIndex,
2465
2472
  hostId
@@ -2471,7 +2478,7 @@ var RpcStream = class _RpcStream {
2471
2478
  if (conn) {
2472
2479
  this.peer.hub.systemCallSender.ackEnd(
2473
2480
  conn,
2474
- this.peer.serializationFormat,
2481
+ this.peer.wireFormat,
2475
2482
  this.id.localId,
2476
2483
  this.id.hostId
2477
2484
  );
@@ -2574,9 +2581,9 @@ var RpcSharedObjectTracker = class {
2574
2581
  // src/rpc-peer.ts
2575
2582
  var import_core7 = require("@actuallab/core");
2576
2583
 
2577
- // src/rpc-serialization-format.ts
2584
+ // src/rpc-wire-format.ts
2578
2585
  var import_msgpack4 = require("@msgpack/msgpack");
2579
- var RpcSerializationFormat = class {
2586
+ var RpcWireFormat = class {
2580
2587
  /** Create a reusable binary encoder for this format. Returns undefined for text formats. */
2581
2588
  createEncoder() {
2582
2589
  return void 0;
@@ -2593,16 +2600,16 @@ var RpcSerializationFormat = class {
2593
2600
  static MessagePackV6;
2594
2601
  static MessagePackV6C;
2595
2602
  static All;
2596
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.get(key). */
2603
+ /** Convenience shortcut for RpcWireFormatResolver.Default.get(key). */
2597
2604
  static get(key) {
2598
- return RpcSerializationFormatResolver.Default.get(key);
2605
+ return RpcWireFormatResolver.Default.get(key);
2599
2606
  }
2600
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.tryGet(key). */
2607
+ /** Convenience shortcut for RpcWireFormatResolver.Default.tryGet(key). */
2601
2608
  static tryGet(key) {
2602
- return RpcSerializationFormatResolver.Default.tryGet(key);
2609
+ return RpcWireFormatResolver.Default.tryGet(key);
2603
2610
  }
2604
2611
  };
2605
- var RpcJsonSerializationFormat = class extends RpcSerializationFormat {
2612
+ var RpcJsonWireFormat = class extends RpcWireFormat {
2606
2613
  key;
2607
2614
  isBinary = false;
2608
2615
  isCompact = false;
@@ -2623,7 +2630,7 @@ var RpcJsonSerializationFormat = class extends RpcSerializationFormat {
2623
2630
  throw new Error("Text format does not support binary frames");
2624
2631
  }
2625
2632
  };
2626
- var RpcMessagePackSerializationFormat = class extends RpcSerializationFormat {
2633
+ var RpcMessagePackWireFormat = class extends RpcWireFormat {
2627
2634
  key;
2628
2635
  isBinary = true;
2629
2636
  isCompact = false;
@@ -2650,7 +2657,7 @@ var RpcMessagePackSerializationFormat = class extends RpcSerializationFormat {
2650
2657
  return new import_msgpack4.Decoder();
2651
2658
  }
2652
2659
  };
2653
- var RpcMessagePackCompactSerializationFormat = class extends RpcSerializationFormat {
2660
+ var RpcMessagePackCompactWireFormat = class extends RpcWireFormat {
2654
2661
  key;
2655
2662
  isBinary = true;
2656
2663
  isCompact = true;
@@ -2682,23 +2689,23 @@ var RpcMessagePackCompactSerializationFormat = class extends RpcSerializationFor
2682
2689
  return new import_msgpack4.Decoder();
2683
2690
  }
2684
2691
  };
2685
- RpcSerializationFormat.SystemJsonV5 = new RpcJsonSerializationFormat("json5");
2686
- RpcSerializationFormat.SystemJsonV5NP = new RpcJsonSerializationFormat("json5np");
2687
- RpcSerializationFormat.NewtonsoftJsonV5 = new RpcJsonSerializationFormat("njson5");
2688
- RpcSerializationFormat.NewtonsoftJsonV5NP = new RpcJsonSerializationFormat("njson5np");
2689
- RpcSerializationFormat.MessagePackV6 = new RpcMessagePackSerializationFormat("msgpack6");
2690
- RpcSerializationFormat.MessagePackV6C = new RpcMessagePackCompactSerializationFormat("msgpack6c");
2691
- RpcSerializationFormat.All = [
2692
- RpcSerializationFormat.SystemJsonV5,
2693
- RpcSerializationFormat.SystemJsonV5NP,
2694
- RpcSerializationFormat.NewtonsoftJsonV5,
2695
- RpcSerializationFormat.NewtonsoftJsonV5NP,
2696
- RpcSerializationFormat.MessagePackV6,
2697
- RpcSerializationFormat.MessagePackV6C
2692
+ RpcWireFormat.SystemJsonV5 = new RpcJsonWireFormat("json5");
2693
+ RpcWireFormat.SystemJsonV5NP = new RpcJsonWireFormat("json5np");
2694
+ RpcWireFormat.NewtonsoftJsonV5 = new RpcJsonWireFormat("njson5");
2695
+ RpcWireFormat.NewtonsoftJsonV5NP = new RpcJsonWireFormat("njson5np");
2696
+ RpcWireFormat.MessagePackV6 = new RpcMessagePackWireFormat("msgpack6");
2697
+ RpcWireFormat.MessagePackV6C = new RpcMessagePackCompactWireFormat("msgpack6c");
2698
+ RpcWireFormat.All = [
2699
+ RpcWireFormat.SystemJsonV5,
2700
+ RpcWireFormat.SystemJsonV5NP,
2701
+ RpcWireFormat.NewtonsoftJsonV5,
2702
+ RpcWireFormat.NewtonsoftJsonV5NP,
2703
+ RpcWireFormat.MessagePackV6,
2704
+ RpcWireFormat.MessagePackV6C
2698
2705
  ];
2699
- var RpcSerializationFormatResolver = class _RpcSerializationFormatResolver {
2700
- static DefaultFormats = RpcSerializationFormat.All;
2701
- static Default = new _RpcSerializationFormatResolver("json5np");
2706
+ var RpcWireFormatResolver = class _RpcWireFormatResolver {
2707
+ static DefaultFormats = RpcWireFormat.All;
2708
+ static Default = new _RpcWireFormatResolver("json5np");
2702
2709
  defaultFormatKey;
2703
2710
  formats;
2704
2711
  get defaultFormat() {
@@ -2706,7 +2713,7 @@ var RpcSerializationFormatResolver = class _RpcSerializationFormatResolver {
2706
2713
  }
2707
2714
  constructor(defaultFormatKey, formats) {
2708
2715
  const map = /* @__PURE__ */ new Map();
2709
- for (const f of formats ?? _RpcSerializationFormatResolver.DefaultFormats)
2716
+ for (const f of formats ?? _RpcWireFormatResolver.DefaultFormats)
2710
2717
  map.set(f.key, f);
2711
2718
  if (!map.has(defaultFormatKey))
2712
2719
  throw new Error(`No format with key '${defaultFormatKey}'.`);
@@ -2715,16 +2722,16 @@ var RpcSerializationFormatResolver = class _RpcSerializationFormatResolver {
2715
2722
  }
2716
2723
  get(key) {
2717
2724
  if (isMemoryPackKey(key))
2718
- throw new Error(`Serialization format '${key}': MemoryPack formats are not supported by the TS client.`);
2719
- const format = this.tryGet(key);
2720
- if (!format)
2725
+ throw new Error(`Wire format '${key}': MemoryPack formats are not supported by the TS client.`);
2726
+ const wireFormat = this.tryGet(key);
2727
+ if (!wireFormat)
2721
2728
  throw new Error(`No format with key '${key}'.`);
2722
- return format;
2729
+ return wireFormat;
2723
2730
  }
2724
2731
  tryGet(key) {
2725
2732
  if (!key) key = this.defaultFormatKey;
2726
2733
  if (isMemoryPackKey(key))
2727
- throw new Error(`Serialization format '${key}': MemoryPack formats are not supported by the TS client.`);
2734
+ throw new Error(`Wire format '${key}': MemoryPack formats are not supported by the TS client.`);
2728
2735
  return this.formats.get(key);
2729
2736
  }
2730
2737
  };
@@ -2759,14 +2766,14 @@ function yieldToEventLoop() {
2759
2766
  return new Promise((resolve) => setTimeout(resolve, 0));
2760
2767
  }
2761
2768
  var RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
2762
- var { debugLog: debugLog2, infoLog, warnLog: warnLog8, errorLog: errorLog2 } = getLogs("RpcPeer");
2769
+ var { debugLog: debugLog2, infoLog, warnLog: warnLog8, errorLog: errorLog3 } = getLogs("RpcPeer");
2763
2770
  var defaultConnectionUrlResolver = async (peer) => {
2764
- const formatKey = peer.serializationFormat.key;
2771
+ const wireFormatKey = peer.wireFormat.key;
2765
2772
  const proof = await peer.computeReconnectProof();
2766
2773
  try {
2767
2774
  const url = new URL(peer.ref);
2768
2775
  url.searchParams.set("clientId", peer.clientId);
2769
- url.searchParams.set("f", formatKey);
2776
+ url.searchParams.set("f", wireFormatKey);
2770
2777
  if (proof !== void 0) {
2771
2778
  url.searchParams.set("c", proof.counter);
2772
2779
  url.searchParams.set("p", proof.proof);
@@ -2774,7 +2781,7 @@ var defaultConnectionUrlResolver = async (peer) => {
2774
2781
  return url.toString();
2775
2782
  } catch {
2776
2783
  const sep = peer.ref.includes("?") ? "&" : "?";
2777
- let url = peer.ref + sep + `clientId=${peer.clientId}&f=${formatKey}`;
2784
+ let url = peer.ref + sep + `clientId=${peer.clientId}&f=${wireFormatKey}`;
2778
2785
  if (proof !== void 0)
2779
2786
  url += `&c=${proof.counter}&p=${proof.proof}`;
2780
2787
  return url;
@@ -2796,7 +2803,7 @@ var sanitizeUrl = (url) => {
2796
2803
  return url.replace(/([?&](?:session|clientId|p)=)[^&]*/gi, "$1<redacted>");
2797
2804
  }
2798
2805
  };
2799
- function parseFormatFromUrl(url) {
2806
+ function parseWireFormatKeyFromUrl(url) {
2800
2807
  try {
2801
2808
  const f = new URL(url).searchParams.get("f");
2802
2809
  return f ?? void 0;
@@ -2979,16 +2986,16 @@ var RpcPeer = class {
2979
2986
  });
2980
2987
  }
2981
2988
  /**
2982
- * The serialization format used by this peer for outgoing messages.
2989
+ * The wire format used by this peer for outgoing messages.
2983
2990
  * If not set explicitly, defaults to the resolver's default (JSON /
2984
2991
  * json5np). Subclasses can pre-assign in their constructor.
2985
2992
  */
2986
- _serializationFormat;
2987
- get serializationFormat() {
2988
- return this._serializationFormat ?? RpcSerializationFormatResolver.Default.defaultFormat;
2993
+ _wireFormat;
2994
+ get wireFormat() {
2995
+ return this._wireFormat ?? RpcWireFormatResolver.Default.defaultFormat;
2989
2996
  }
2990
- set serializationFormat(value) {
2991
- this._serializationFormat = value;
2997
+ set wireFormat(value) {
2998
+ this._wireFormat = value;
2992
2999
  }
2993
3000
  call(method, args, options) {
2994
3001
  const callId = this.outboundCalls.nextId();
@@ -2998,7 +3005,7 @@ var RpcPeer = class {
2998
3005
  RelatedId: callId,
2999
3006
  CallType: options?.callTypeId ?? 0
3000
3007
  };
3001
- outboundCall.serializedWireData = this.serializationFormat.serializeMessage(
3008
+ outboundCall.serializedWireData = this.wireFormat.serializeMessage(
3002
3009
  envelope,
3003
3010
  args,
3004
3011
  this._connection?.encoder,
@@ -3028,7 +3035,7 @@ var RpcPeer = class {
3028
3035
  outboundCall.onDisconnect();
3029
3036
  const conn = this.wireConnection;
3030
3037
  if (conn !== void 0)
3031
- this.hub.systemCallSender.cancel(conn, this.serializationFormat, callId);
3038
+ this.hub.systemCallSender.cancel(conn, this.wireFormat, callId);
3032
3039
  }
3033
3040
  };
3034
3041
  signal.addEventListener("abort", onAbort, { once: true });
@@ -3040,7 +3047,7 @@ var RpcPeer = class {
3040
3047
  if (!this._isConnected) return;
3041
3048
  const conn = this._connection;
3042
3049
  const envelope = { Method: method, RelatedId: 0 };
3043
- const wireData = this.serializationFormat.serializeMessage(
3050
+ const wireData = this.wireFormat.serializeMessage(
3044
3051
  envelope,
3045
3052
  args,
3046
3053
  conn.encoder,
@@ -3092,7 +3099,7 @@ var RpcPeer = class {
3092
3099
  try {
3093
3100
  this._processMessage(received);
3094
3101
  } catch (e) {
3095
- errorLog2?.log(`'${this.ref}': Failed to process inbound message:`, received, e);
3102
+ errorLog3?.log(`'${this.ref}': Failed to process inbound message:`, received, e);
3096
3103
  }
3097
3104
  }
3098
3105
  _processMessage(received) {
@@ -3162,7 +3169,7 @@ var RpcPeer = class {
3162
3169
  if (conn !== void 0)
3163
3170
  this.hub.systemCallSender.ok(
3164
3171
  conn,
3165
- this.serializationFormat,
3172
+ this.wireFormat,
3166
3173
  relatedId,
3167
3174
  ref
3168
3175
  );
@@ -3180,7 +3187,7 @@ var RpcPeer = class {
3180
3187
  if (conn !== void 0)
3181
3188
  this.hub.systemCallSender.ok(
3182
3189
  conn,
3183
- this.serializationFormat,
3190
+ this.wireFormat,
3184
3191
  relatedId,
3185
3192
  result
3186
3193
  );
@@ -3197,7 +3204,7 @@ var RpcPeer = class {
3197
3204
  if (conn !== void 0)
3198
3205
  this.hub.systemCallSender.error(
3199
3206
  conn,
3200
- this.serializationFormat,
3207
+ this.wireFormat,
3201
3208
  relatedId,
3202
3209
  e
3203
3210
  );
@@ -3232,7 +3239,7 @@ var RpcPeer = class {
3232
3239
  const conn = this.wireConnection;
3233
3240
  if (conn !== void 0) {
3234
3241
  try {
3235
- this.hub.systemCallSender.keepAlive(conn, this.serializationFormat, [
3242
+ this.hub.systemCallSender.keepAlive(conn, this.wireFormat, [
3236
3243
  ...this.remoteObjects.keys()
3237
3244
  ]);
3238
3245
  } catch (e) {
@@ -3336,7 +3343,7 @@ var RpcClientPeer = class extends RpcPeer {
3336
3343
  * Initialized from `hub.limits` at construction; override per peer. */
3337
3344
  prematureDisconnectTimeoutMs;
3338
3345
  peerChanged = new import_core7.EventHandlerSet();
3339
- /** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
3346
+ /** Fired when the server rejects the connection due to an unsupported wire format (close code 4001). */
3340
3347
  unsupportedFormat = new import_core7.EventHandlerSet();
3341
3348
  reconnectsAtChanged = new import_core7.EventHandlerSet();
3342
3349
  get reconnectsAt() {
@@ -3353,7 +3360,7 @@ var RpcClientPeer = class extends RpcPeer {
3353
3360
  whenRunning;
3354
3361
  /**
3355
3362
  * @param hub RpcHub instance this peer will be tracked by
3356
- * @param url Full WebSocket URL — the serialization format is taken from
3363
+ * @param url Full WebSocket URL — the wire format is taken from
3357
3364
  * the `f=` query parameter (e.g. `wss://host/rpc/ws?f=msgpack6`);
3358
3365
  * falls back to the resolver's default when absent. Use
3359
3366
  * {@link RpcRefBuilder.forClient} to compose URLs with a format.
@@ -3369,8 +3376,8 @@ var RpcClientPeer = class extends RpcPeer {
3369
3376
  this.handshakeTimeoutMs = hub.limits.handshakeTimeoutMs;
3370
3377
  this.prematureDisconnectTimeoutMs = hub.limits.prematureDisconnectTimeoutMs;
3371
3378
  this.clientId = guidToBase64Url(this.id);
3372
- const resolver = RpcSerializationFormatResolver.Default;
3373
- this.serializationFormat = resolver.get(parseFormatFromUrl(url) ?? resolver.defaultFormatKey);
3379
+ const resolver = RpcWireFormatResolver.Default;
3380
+ this.wireFormat = resolver.get(parseWireFormatKeyFromUrl(url) ?? resolver.defaultFormatKey);
3374
3381
  if (mustStart)
3375
3382
  this.start();
3376
3383
  }
@@ -3386,7 +3393,7 @@ var RpcClientPeer = class extends RpcPeer {
3386
3393
  const whenHandshake = isPeerChanged ? void 0 : this._pendingHandshake = new import_core7.PromiseSource();
3387
3394
  this.hub.systemCallSender.handshake(
3388
3395
  conn,
3389
- this.serializationFormat,
3396
+ this.wireFormat,
3390
3397
  this.id,
3391
3398
  this.hub.hubId,
3392
3399
  this.nextOwnHandshakeIndex()
@@ -3467,8 +3474,8 @@ var RpcClientPeer = class extends RpcPeer {
3467
3474
  const ws = this.webSocketFactory?.(connUrl) ?? new WebSocket(connUrl);
3468
3475
  const conn = new RpcWebSocketConnection(
3469
3476
  ws,
3470
- this.serializationFormat.isBinary,
3471
- this.serializationFormat,
3477
+ this.wireFormat.isBinary,
3478
+ this.wireFormat,
3472
3479
  this.hub.registry
3473
3480
  );
3474
3481
  const whenClosed = new import_core7.PromiseSource();
@@ -3504,7 +3511,7 @@ var RpcClientPeer = class extends RpcPeer {
3504
3511
  try {
3505
3512
  this.hub.systemCallSender.handshake(
3506
3513
  conn,
3507
- this.serializationFormat,
3514
+ this.wireFormat,
3508
3515
  this.id,
3509
3516
  this.hub.hubId,
3510
3517
  this.nextOwnHandshakeIndex()
@@ -3553,7 +3560,7 @@ var RpcClientPeer = class extends RpcPeer {
3553
3560
  this._setConnectionState(0 /* Disconnected */);
3554
3561
  if (this._disposed) break;
3555
3562
  if (lastCloseCode === RPC_CLOSE_CODE_UNSUPPORTED_FORMAT) {
3556
- warnLog8?.log(`'${this.ref}': Unsupported serialization format - shutting down`);
3563
+ warnLog8?.log(`'${this.ref}': Unsupported wire format - shutting down`);
3557
3564
  this.unsupportedFormat.trigger({ reason: lastCloseReason });
3558
3565
  this._disposed = true;
3559
3566
  break;
@@ -3687,7 +3694,7 @@ var RpcClientPeer = class extends RpcPeer {
3687
3694
  if (byStage.size === 0) {
3688
3695
  return null;
3689
3696
  }
3690
- const isBinary = this.serializationFormat.isBinary;
3697
+ const isBinary = this.wireFormat.isBinary;
3691
3698
  const stagesArg = isBinary ? /* @__PURE__ */ new Map() : {};
3692
3699
  for (const [stage, ids] of byStage) {
3693
3700
  ids.sort((a, b) => a - b);
@@ -3793,7 +3800,7 @@ var RpcServerPeer = class extends RpcPeer {
3793
3800
  if (this._connection !== void 0) {
3794
3801
  this.hub.systemCallSender.handshake(
3795
3802
  this._connection,
3796
- this.serializationFormat,
3803
+ this.wireFormat,
3797
3804
  this.id,
3798
3805
  this.hub.hubId,
3799
3806
  this.nextOwnHandshakeIndex()
@@ -4752,14 +4759,14 @@ function isSameWireMethod(a, b) {
4752
4759
  // src/rpc-ref-builder.ts
4753
4760
  var RpcRefBuilder = class {
4754
4761
  /** Build a client peer ref from a WebSocket URL, optionally baking in the
4755
- * serialization format as a `f=` query parameter.
4762
+ * wire format as a `f=` query parameter.
4756
4763
  * @param url Base WebSocket URL, e.g. `wss://host/rpc/ws`.
4757
- * @param serializationFormat Optional format key, e.g. `msgpack6`. When
4764
+ * @param wireFormat Optional format key, e.g. `msgpack6`. When
4758
4765
  * provided, replaces any existing `f=` in the URL. */
4759
- static forClient(url, serializationFormat) {
4760
- if (serializationFormat === void 0) return url;
4766
+ static forClient(url, wireFormat) {
4767
+ if (wireFormat === void 0) return url;
4761
4768
  const u = new URL(url);
4762
- u.searchParams.set("f", serializationFormat);
4769
+ u.searchParams.set("f", wireFormat);
4763
4770
  return u.toString();
4764
4771
  }
4765
4772
  /** Build a server peer ref from a peer id — returns `server://{id}`. */
@@ -5022,11 +5029,11 @@ var RpcPeerStateMonitor = class {
5022
5029
  RpcHub,
5023
5030
  RpcInboundCall,
5024
5031
  RpcInboundCallTracker,
5025
- RpcJsonSerializationFormat,
5032
+ RpcJsonWireFormat,
5026
5033
  RpcLimits,
5027
5034
  RpcMessageChannelConnection,
5028
- RpcMessagePackCompactSerializationFormat,
5029
- RpcMessagePackSerializationFormat,
5035
+ RpcMessagePackCompactWireFormat,
5036
+ RpcMessagePackWireFormat,
5030
5037
  RpcMethodRegistry,
5031
5038
  RpcObjectKind,
5032
5039
  RpcOutboundCall,
@@ -5038,8 +5045,6 @@ var RpcPeerStateMonitor = class {
5038
5045
  RpcRefBuilder,
5039
5046
  RpcRemoteExecutionMode,
5040
5047
  RpcRemoteObjectTracker,
5041
- RpcSerializationFormat,
5042
- RpcSerializationFormatResolver,
5043
5048
  RpcServerPeer,
5044
5049
  RpcServiceHost,
5045
5050
  RpcSharedObjectTracker,
@@ -5050,6 +5055,8 @@ var RpcPeerStateMonitor = class {
5050
5055
  RpcSystemCalls,
5051
5056
  RpcType,
5052
5057
  RpcWebSocketConnection,
5058
+ RpcWireFormat,
5059
+ RpcWireFormatResolver,
5053
5060
  WebSocketState,
5054
5061
  computeMethodHash,
5055
5062
  computeReconnectProof,