@actuallab/rpc 15.1.59 → 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.js CHANGED
@@ -427,16 +427,16 @@ var RpcWebSocketConnection = class {
427
427
  get decoder() {
428
428
  return this._decoder;
429
429
  }
430
- _format;
430
+ _wireFormat;
431
431
  _methodRegistry;
432
432
  binaryMode;
433
433
  messageReceived = new EventHandlerSet();
434
434
  closed = new EventHandlerSet();
435
435
  error = new EventHandlerSet();
436
- constructor(ws, binaryMode = false, format, methodRegistry) {
436
+ constructor(ws, binaryMode = false, wireFormat, methodRegistry) {
437
437
  this._ws = ws;
438
438
  this.binaryMode = binaryMode;
439
- this._format = format;
439
+ this._wireFormat = wireFormat;
440
440
  this._methodRegistry = methodRegistry;
441
441
  if (binaryMode && ws.binaryType !== void 0)
442
442
  ws.binaryType = "arraybuffer";
@@ -510,10 +510,10 @@ var RpcWebSocketConnection = class {
510
510
  sendBinaryBatch(messages) {
511
511
  this._sendRaw(serializeBinaryFrame(messages));
512
512
  }
513
- /** Split a binary frame using the format (compact-aware) or default splitter. */
513
+ /** Split a binary frame using the wire format (compact-aware) or default splitter. */
514
514
  _splitBinary(frame) {
515
- if (this._format) {
516
- return this._format.splitBinaryFrame(
515
+ if (this._wireFormat) {
516
+ return this._wireFormat.splitBinaryFrame(
517
517
  frame,
518
518
  this._decoder,
519
519
  this._methodRegistry
@@ -1101,7 +1101,7 @@ var RpcSystemCallHandler = class {
1101
1101
  if (unknownIds.length > 0)
1102
1102
  peer.hub.systemCallSender.disconnect(
1103
1103
  peer.wireConnection,
1104
- peer.serializationFormat,
1104
+ peer.wireFormat,
1105
1105
  unknownIds
1106
1106
  );
1107
1107
  }
@@ -1152,7 +1152,7 @@ var RpcSystemCallHandler = class {
1152
1152
  else if (peer.wireConnection !== void 0)
1153
1153
  peer.hub.systemCallSender.disconnect(
1154
1154
  peer.wireConnection,
1155
- peer.serializationFormat,
1155
+ peer.wireFormat,
1156
1156
  [relatedId]
1157
1157
  );
1158
1158
  break;
@@ -1164,7 +1164,7 @@ var RpcSystemCallHandler = class {
1164
1164
  else if (peer.wireConnection !== void 0)
1165
1165
  peer.hub.systemCallSender.disconnect(
1166
1166
  peer.wireConnection,
1167
- peer.serializationFormat,
1167
+ peer.wireFormat,
1168
1168
  [relatedId]
1169
1169
  );
1170
1170
  break;
@@ -1202,7 +1202,7 @@ var RpcSystemCallHandler = class {
1202
1202
  const got = typeof handshakeIndex === "number" ? handshakeIndex : `<${typeof handshakeIndex}>`;
1203
1203
  peer.hub.systemCallSender.error(
1204
1204
  conn,
1205
- peer.serializationFormat,
1205
+ peer.wireFormat,
1206
1206
  relatedId,
1207
1207
  new Error(
1208
1208
  `TooLateToReconnect: own handshake index ${peer.ownHandshakeIndex} != ${got}`
@@ -1213,7 +1213,7 @@ var RpcSystemCallHandler = class {
1213
1213
  if (!peer.tryClaimReconnect()) {
1214
1214
  peer.hub.systemCallSender.error(
1215
1215
  conn,
1216
- peer.serializationFormat,
1216
+ peer.wireFormat,
1217
1217
  relatedId,
1218
1218
  new Error("TooLateToReconnect: this connection was already reconnected")
1219
1219
  );
@@ -1242,8 +1242,8 @@ var RpcSystemCallHandler = class {
1242
1242
  } catch {
1243
1243
  }
1244
1244
  const responseBytes = IncreasingSeqCompressor.serialize(unknownIds);
1245
- const responseValue = peer.serializationFormat.isBinary ? responseBytes : base64Encode(responseBytes);
1246
- peer.hub.systemCallSender.ok(conn, peer.serializationFormat, relatedId, responseValue);
1245
+ const responseValue = peer.wireFormat.isBinary ? responseBytes : base64Encode(responseBytes);
1246
+ peer.hub.systemCallSender.ok(conn, peer.wireFormat, relatedId, responseValue);
1247
1247
  }
1248
1248
  };
1249
1249
  function polymorphicPayloadError(method, got, expected) {
@@ -1318,8 +1318,8 @@ var RpcSystemCallSender = class _RpcSystemCallSender {
1318
1318
  * {@link genericErrorFilter}) on a TS-hosted server, where handler errors
1319
1319
  * would otherwise disclose internal details to unauthenticated callers. */
1320
1320
  errorFilter;
1321
- _send(conn, format, envelope, args) {
1322
- const wireData = format.serializeMessage(
1321
+ _send(conn, wireFormat, envelope, args) {
1322
+ const wireData = wireFormat.serializeMessage(
1323
1323
  envelope,
1324
1324
  args,
1325
1325
  conn.encoder,
@@ -1331,88 +1331,88 @@ var RpcSystemCallSender = class _RpcSystemCallSender {
1331
1331
  conn.sendBinary(wireData);
1332
1332
  }
1333
1333
  }
1334
- handshake(conn, format, peerId, hubId, index) {
1335
- const handshakeArg = format.isBinary ? [peerId, null, hubId, 2, index] : {
1334
+ handshake(conn, wireFormat, peerId, hubId, index) {
1335
+ const handshakeArg = wireFormat.isBinary ? [peerId, null, hubId, 2, index] : {
1336
1336
  RemotePeerId: peerId,
1337
1337
  RemoteApiVersionSet: null,
1338
1338
  RemoteHubId: hubId,
1339
1339
  ProtocolVersion: 2,
1340
1340
  Index: index
1341
1341
  };
1342
- this._send(conn, format, { Method: RpcSystemCalls.handshake }, [
1342
+ this._send(conn, wireFormat, { Method: RpcSystemCalls.handshake }, [
1343
1343
  handshakeArg
1344
1344
  ]);
1345
1345
  }
1346
- ok(conn, format, relatedId, result) {
1346
+ ok(conn, wireFormat, relatedId, result) {
1347
1347
  try {
1348
1348
  this._send(
1349
1349
  conn,
1350
- format,
1350
+ wireFormat,
1351
1351
  { Method: RpcSystemCalls.ok, RelatedId: relatedId },
1352
1352
  [result]
1353
1353
  );
1354
1354
  } catch (e) {
1355
1355
  errorLog?.log(`Failed to send Ok response for call #${relatedId}`, e);
1356
- this.error(conn, format, relatedId, e);
1356
+ this.error(conn, wireFormat, relatedId, e);
1357
1357
  }
1358
1358
  }
1359
- error(conn, format, relatedId, error) {
1359
+ error(conn, wireFormat, relatedId, error) {
1360
1360
  this._send(
1361
1361
  conn,
1362
- format,
1362
+ wireFormat,
1363
1363
  { Method: RpcSystemCalls.error, RelatedId: relatedId },
1364
1364
  [toExceptionInfo(error, this.errorFilter)]
1365
1365
  );
1366
1366
  }
1367
- cancel(conn, format, relatedId) {
1368
- this._send(conn, format, {
1367
+ cancel(conn, wireFormat, relatedId) {
1368
+ this._send(conn, wireFormat, {
1369
1369
  Method: RpcSystemCalls.cancel,
1370
1370
  RelatedId: relatedId
1371
1371
  });
1372
1372
  }
1373
- keepAlive(conn, format, activeCallIds) {
1374
- this._send(conn, format, { Method: RpcSystemCalls.keepAlive }, [
1373
+ keepAlive(conn, wireFormat, activeCallIds) {
1374
+ this._send(conn, wireFormat, { Method: RpcSystemCalls.keepAlive }, [
1375
1375
  activeCallIds
1376
1376
  ]);
1377
1377
  }
1378
1378
  // Tells the remote peer the listed shared-object ids are gone on our side,
1379
1379
  // so its matching remote objects (e.g. RpcStream consumers) fail fast
1380
1380
  // instead of hanging. Mirrors .NET RpcSystemCallSender.Disconnect.
1381
- disconnect(conn, format, localIds) {
1382
- this._send(conn, format, { Method: RpcSystemCalls.disconnect }, [
1381
+ disconnect(conn, wireFormat, localIds) {
1382
+ this._send(conn, wireFormat, { Method: RpcSystemCalls.disconnect }, [
1383
1383
  localIds
1384
1384
  ]);
1385
1385
  }
1386
- item(conn, format, localId, index, item) {
1386
+ item(conn, wireFormat, localId, index, item) {
1387
1387
  this._itemEnv.RelatedId = localId;
1388
1388
  this._itemArgs[0] = index;
1389
1389
  this._itemArgs[1] = item;
1390
- this._send(conn, format, this._itemEnv, this._itemArgs);
1390
+ this._send(conn, wireFormat, this._itemEnv, this._itemArgs);
1391
1391
  this._itemArgs[1] = null;
1392
1392
  }
1393
- batch(conn, format, localId, index, items) {
1393
+ batch(conn, wireFormat, localId, index, items) {
1394
1394
  this._batchEnv.RelatedId = localId;
1395
1395
  this._batchArgs[0] = index;
1396
1396
  this._batchArgs[1] = items;
1397
- this._send(conn, format, this._batchEnv, this._batchArgs);
1397
+ this._send(conn, wireFormat, this._batchEnv, this._batchArgs);
1398
1398
  this._batchArgs[1] = null;
1399
1399
  }
1400
- end(conn, format, localId, index, error = _RpcSystemCallSender.NO_ERROR) {
1400
+ end(conn, wireFormat, localId, index, error = _RpcSystemCallSender.NO_ERROR) {
1401
1401
  this._endEnv.RelatedId = localId;
1402
1402
  this._endArgs[0] = index;
1403
1403
  this._endArgs[1] = error;
1404
- this._send(conn, format, this._endEnv, this._endArgs);
1404
+ this._send(conn, wireFormat, this._endEnv, this._endArgs);
1405
1405
  }
1406
- ack(conn, format, localId, nextIndex, hostId) {
1406
+ ack(conn, wireFormat, localId, nextIndex, hostId) {
1407
1407
  this._ackEnv.RelatedId = localId;
1408
1408
  this._ackArgs[0] = nextIndex;
1409
1409
  this._ackArgs[1] = hostId;
1410
- this._send(conn, format, this._ackEnv, this._ackArgs);
1410
+ this._send(conn, wireFormat, this._ackEnv, this._ackArgs);
1411
1411
  }
1412
- ackEnd(conn, format, localId, hostId) {
1412
+ ackEnd(conn, wireFormat, localId, hostId) {
1413
1413
  this._ackEndEnv.RelatedId = localId;
1414
1414
  this._ackEndArgs[0] = hostId;
1415
- this._send(conn, format, this._ackEndEnv, this._ackEndArgs);
1415
+ this._send(conn, wireFormat, this._ackEndEnv, this._ackEndArgs);
1416
1416
  }
1417
1417
  };
1418
1418
 
@@ -1425,7 +1425,7 @@ import { PromiseSource as PromiseSource4 } from "@actuallab/core";
1425
1425
 
1426
1426
  // src/rpc-stream-sender.ts
1427
1427
  import { PromiseSource as PromiseSource3, RingBuffer } from "@actuallab/core";
1428
- var { warnLog: warnLog5 } = getLogs("RpcSharedStream");
1428
+ var { warnLog: warnLog5, errorLog: errorLog2 } = getLogs("RpcSharedStream");
1429
1429
  function _ignore() {
1430
1430
  }
1431
1431
  var DEFAULT_ACK_PERIOD = 256;
@@ -1601,7 +1601,7 @@ var RpcStreamSender = class _RpcStreamSender {
1601
1601
  _sendDisconnect() {
1602
1602
  const conn = this.peer.wireConnection;
1603
1603
  if (conn)
1604
- this.peer.hub.systemCallSender.disconnect(conn, this.peer.serializationFormat, [this.id.localId]);
1604
+ this.peer.hub.systemCallSender.disconnect(conn, this.peer.wireFormat, [this.id.localId]);
1605
1605
  this.disconnect();
1606
1606
  }
1607
1607
  /** Called by system call handler when $sys.AckEnd is received from the client. */
@@ -1623,7 +1623,7 @@ var RpcStreamSender = class _RpcStreamSender {
1623
1623
  if (conn) {
1624
1624
  this.peer.hub.systemCallSender.item(
1625
1625
  conn,
1626
- this.peer.serializationFormat,
1626
+ this.peer.wireFormat,
1627
1627
  this.id.localId,
1628
1628
  this._nextIndex,
1629
1629
  item
@@ -1641,7 +1641,7 @@ var RpcStreamSender = class _RpcStreamSender {
1641
1641
  if (conn) {
1642
1642
  this.peer.hub.systemCallSender.batch(
1643
1643
  conn,
1644
- this.peer.serializationFormat,
1644
+ this.peer.wireFormat,
1645
1645
  this.id.localId,
1646
1646
  this._nextIndex,
1647
1647
  items
@@ -1661,7 +1661,7 @@ var RpcStreamSender = class _RpcStreamSender {
1661
1661
  const errorInfo = error ? toExceptionInfo(error) : { TypeRef: "", Message: "" };
1662
1662
  this.peer.hub.systemCallSender.end(
1663
1663
  conn,
1664
- this.peer.serializationFormat,
1664
+ this.peer.wireFormat,
1665
1665
  this.id.localId,
1666
1666
  index,
1667
1667
  errorInfo
@@ -1839,7 +1839,14 @@ var RpcStreamSender = class _RpcStreamSender {
1839
1839
  while (this._nextIndex < maxIndex && bufferIndex < buffer.count) {
1840
1840
  const item = buffer.get(bufferIndex++);
1841
1841
  if (item.kind === "value") {
1842
- this.sendItem(item.value);
1842
+ try {
1843
+ this.sendItem(item.value);
1844
+ } catch (e) {
1845
+ const error = e instanceof Error ? e : new Error(String(e));
1846
+ errorLog2?.log(`Failed to send an item of stream #${this.id.localId}:`, error);
1847
+ this.sendEnd(error);
1848
+ continue nextAck;
1849
+ }
1843
1850
  } else {
1844
1851
  this.sendEnd(item.kind === "error" ? item.error : void 0);
1845
1852
  continue nextAck;
@@ -2120,7 +2127,7 @@ var RpcStream = class _RpcStream {
2120
2127
  this._sender = sender;
2121
2128
  const source = isFactory ? this.localSource(sender.abortSignal) : this.localSource;
2122
2129
  this._whenSent = sender.writeFrom(source);
2123
- this._toRefValue = peer.serializationFormat.isBinary ? {
2130
+ this._toRefValue = peer.wireFormat.isBinary ? {
2124
2131
  SerializedId: [sender.id.hostId, sender.id.localId],
2125
2132
  AckPeriod: sender.ackPeriod,
2126
2133
  AckAdvance: sender.ackAdvance,
@@ -2345,7 +2352,7 @@ var RpcStream = class _RpcStream {
2345
2352
  const hostId = mustReset ? this.id.hostId : _RpcStream._emptyGuid;
2346
2353
  this.peer.hub.systemCallSender.ack(
2347
2354
  conn,
2348
- this.peer.serializationFormat,
2355
+ this.peer.wireFormat,
2349
2356
  this.id.localId,
2350
2357
  nextIndex,
2351
2358
  hostId
@@ -2357,7 +2364,7 @@ var RpcStream = class _RpcStream {
2357
2364
  if (conn) {
2358
2365
  this.peer.hub.systemCallSender.ackEnd(
2359
2366
  conn,
2360
- this.peer.serializationFormat,
2367
+ this.peer.wireFormat,
2361
2368
  this.id.localId,
2362
2369
  this.id.hostId
2363
2370
  );
@@ -2460,9 +2467,9 @@ var RpcSharedObjectTracker = class {
2460
2467
  // src/rpc-peer.ts
2461
2468
  import { EventHandlerSet as EventHandlerSet3, PromiseSource as PromiseSource5, TimeoutError, cancellationError, withTimeout } from "@actuallab/core";
2462
2469
 
2463
- // src/rpc-serialization-format.ts
2470
+ // src/rpc-wire-format.ts
2464
2471
  import { Decoder as Decoder3 } from "@msgpack/msgpack";
2465
- var RpcSerializationFormat = class {
2472
+ var RpcWireFormat = class {
2466
2473
  /** Create a reusable binary encoder for this format. Returns undefined for text formats. */
2467
2474
  createEncoder() {
2468
2475
  return void 0;
@@ -2479,16 +2486,16 @@ var RpcSerializationFormat = class {
2479
2486
  static MessagePackV6;
2480
2487
  static MessagePackV6C;
2481
2488
  static All;
2482
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.get(key). */
2489
+ /** Convenience shortcut for RpcWireFormatResolver.Default.get(key). */
2483
2490
  static get(key) {
2484
- return RpcSerializationFormatResolver.Default.get(key);
2491
+ return RpcWireFormatResolver.Default.get(key);
2485
2492
  }
2486
- /** Convenience shortcut for RpcSerializationFormatResolver.Default.tryGet(key). */
2493
+ /** Convenience shortcut for RpcWireFormatResolver.Default.tryGet(key). */
2487
2494
  static tryGet(key) {
2488
- return RpcSerializationFormatResolver.Default.tryGet(key);
2495
+ return RpcWireFormatResolver.Default.tryGet(key);
2489
2496
  }
2490
2497
  };
2491
- var RpcJsonSerializationFormat = class extends RpcSerializationFormat {
2498
+ var RpcJsonWireFormat = class extends RpcWireFormat {
2492
2499
  key;
2493
2500
  isBinary = false;
2494
2501
  isCompact = false;
@@ -2509,7 +2516,7 @@ var RpcJsonSerializationFormat = class extends RpcSerializationFormat {
2509
2516
  throw new Error("Text format does not support binary frames");
2510
2517
  }
2511
2518
  };
2512
- var RpcMessagePackSerializationFormat = class extends RpcSerializationFormat {
2519
+ var RpcMessagePackWireFormat = class extends RpcWireFormat {
2513
2520
  key;
2514
2521
  isBinary = true;
2515
2522
  isCompact = false;
@@ -2536,7 +2543,7 @@ var RpcMessagePackSerializationFormat = class extends RpcSerializationFormat {
2536
2543
  return new Decoder3();
2537
2544
  }
2538
2545
  };
2539
- var RpcMessagePackCompactSerializationFormat = class extends RpcSerializationFormat {
2546
+ var RpcMessagePackCompactWireFormat = class extends RpcWireFormat {
2540
2547
  key;
2541
2548
  isBinary = true;
2542
2549
  isCompact = true;
@@ -2568,23 +2575,23 @@ var RpcMessagePackCompactSerializationFormat = class extends RpcSerializationFor
2568
2575
  return new Decoder3();
2569
2576
  }
2570
2577
  };
2571
- RpcSerializationFormat.SystemJsonV5 = new RpcJsonSerializationFormat("json5");
2572
- RpcSerializationFormat.SystemJsonV5NP = new RpcJsonSerializationFormat("json5np");
2573
- RpcSerializationFormat.NewtonsoftJsonV5 = new RpcJsonSerializationFormat("njson5");
2574
- RpcSerializationFormat.NewtonsoftJsonV5NP = new RpcJsonSerializationFormat("njson5np");
2575
- RpcSerializationFormat.MessagePackV6 = new RpcMessagePackSerializationFormat("msgpack6");
2576
- RpcSerializationFormat.MessagePackV6C = new RpcMessagePackCompactSerializationFormat("msgpack6c");
2577
- RpcSerializationFormat.All = [
2578
- RpcSerializationFormat.SystemJsonV5,
2579
- RpcSerializationFormat.SystemJsonV5NP,
2580
- RpcSerializationFormat.NewtonsoftJsonV5,
2581
- RpcSerializationFormat.NewtonsoftJsonV5NP,
2582
- RpcSerializationFormat.MessagePackV6,
2583
- RpcSerializationFormat.MessagePackV6C
2578
+ RpcWireFormat.SystemJsonV5 = new RpcJsonWireFormat("json5");
2579
+ RpcWireFormat.SystemJsonV5NP = new RpcJsonWireFormat("json5np");
2580
+ RpcWireFormat.NewtonsoftJsonV5 = new RpcJsonWireFormat("njson5");
2581
+ RpcWireFormat.NewtonsoftJsonV5NP = new RpcJsonWireFormat("njson5np");
2582
+ RpcWireFormat.MessagePackV6 = new RpcMessagePackWireFormat("msgpack6");
2583
+ RpcWireFormat.MessagePackV6C = new RpcMessagePackCompactWireFormat("msgpack6c");
2584
+ RpcWireFormat.All = [
2585
+ RpcWireFormat.SystemJsonV5,
2586
+ RpcWireFormat.SystemJsonV5NP,
2587
+ RpcWireFormat.NewtonsoftJsonV5,
2588
+ RpcWireFormat.NewtonsoftJsonV5NP,
2589
+ RpcWireFormat.MessagePackV6,
2590
+ RpcWireFormat.MessagePackV6C
2584
2591
  ];
2585
- var RpcSerializationFormatResolver = class _RpcSerializationFormatResolver {
2586
- static DefaultFormats = RpcSerializationFormat.All;
2587
- static Default = new _RpcSerializationFormatResolver("json5np");
2592
+ var RpcWireFormatResolver = class _RpcWireFormatResolver {
2593
+ static DefaultFormats = RpcWireFormat.All;
2594
+ static Default = new _RpcWireFormatResolver("json5np");
2588
2595
  defaultFormatKey;
2589
2596
  formats;
2590
2597
  get defaultFormat() {
@@ -2592,7 +2599,7 @@ var RpcSerializationFormatResolver = class _RpcSerializationFormatResolver {
2592
2599
  }
2593
2600
  constructor(defaultFormatKey, formats) {
2594
2601
  const map = /* @__PURE__ */ new Map();
2595
- for (const f of formats ?? _RpcSerializationFormatResolver.DefaultFormats)
2602
+ for (const f of formats ?? _RpcWireFormatResolver.DefaultFormats)
2596
2603
  map.set(f.key, f);
2597
2604
  if (!map.has(defaultFormatKey))
2598
2605
  throw new Error(`No format with key '${defaultFormatKey}'.`);
@@ -2601,16 +2608,16 @@ var RpcSerializationFormatResolver = class _RpcSerializationFormatResolver {
2601
2608
  }
2602
2609
  get(key) {
2603
2610
  if (isMemoryPackKey(key))
2604
- throw new Error(`Serialization format '${key}': MemoryPack formats are not supported by the TS client.`);
2605
- const format = this.tryGet(key);
2606
- if (!format)
2611
+ throw new Error(`Wire format '${key}': MemoryPack formats are not supported by the TS client.`);
2612
+ const wireFormat = this.tryGet(key);
2613
+ if (!wireFormat)
2607
2614
  throw new Error(`No format with key '${key}'.`);
2608
- return format;
2615
+ return wireFormat;
2609
2616
  }
2610
2617
  tryGet(key) {
2611
2618
  if (!key) key = this.defaultFormatKey;
2612
2619
  if (isMemoryPackKey(key))
2613
- throw new Error(`Serialization format '${key}': MemoryPack formats are not supported by the TS client.`);
2620
+ throw new Error(`Wire format '${key}': MemoryPack formats are not supported by the TS client.`);
2614
2621
  return this.formats.get(key);
2615
2622
  }
2616
2623
  };
@@ -2645,14 +2652,14 @@ function yieldToEventLoop() {
2645
2652
  return new Promise((resolve) => setTimeout(resolve, 0));
2646
2653
  }
2647
2654
  var RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
2648
- var { debugLog: debugLog2, infoLog, warnLog: warnLog8, errorLog: errorLog2 } = getLogs("RpcPeer");
2655
+ var { debugLog: debugLog2, infoLog, warnLog: warnLog8, errorLog: errorLog3 } = getLogs("RpcPeer");
2649
2656
  var defaultConnectionUrlResolver = async (peer) => {
2650
- const formatKey = peer.serializationFormat.key;
2657
+ const wireFormatKey = peer.wireFormat.key;
2651
2658
  const proof = await peer.computeReconnectProof();
2652
2659
  try {
2653
2660
  const url = new URL(peer.ref);
2654
2661
  url.searchParams.set("clientId", peer.clientId);
2655
- url.searchParams.set("f", formatKey);
2662
+ url.searchParams.set("f", wireFormatKey);
2656
2663
  if (proof !== void 0) {
2657
2664
  url.searchParams.set("c", proof.counter);
2658
2665
  url.searchParams.set("p", proof.proof);
@@ -2660,7 +2667,7 @@ var defaultConnectionUrlResolver = async (peer) => {
2660
2667
  return url.toString();
2661
2668
  } catch {
2662
2669
  const sep = peer.ref.includes("?") ? "&" : "?";
2663
- let url = peer.ref + sep + `clientId=${peer.clientId}&f=${formatKey}`;
2670
+ let url = peer.ref + sep + `clientId=${peer.clientId}&f=${wireFormatKey}`;
2664
2671
  if (proof !== void 0)
2665
2672
  url += `&c=${proof.counter}&p=${proof.proof}`;
2666
2673
  return url;
@@ -2682,7 +2689,7 @@ var sanitizeUrl = (url) => {
2682
2689
  return url.replace(/([?&](?:session|clientId|p)=)[^&]*/gi, "$1<redacted>");
2683
2690
  }
2684
2691
  };
2685
- function parseFormatFromUrl(url) {
2692
+ function parseWireFormatKeyFromUrl(url) {
2686
2693
  try {
2687
2694
  const f = new URL(url).searchParams.get("f");
2688
2695
  return f ?? void 0;
@@ -2865,16 +2872,16 @@ var RpcPeer = class {
2865
2872
  });
2866
2873
  }
2867
2874
  /**
2868
- * The serialization format used by this peer for outgoing messages.
2875
+ * The wire format used by this peer for outgoing messages.
2869
2876
  * If not set explicitly, defaults to the resolver's default (JSON /
2870
2877
  * json5np). Subclasses can pre-assign in their constructor.
2871
2878
  */
2872
- _serializationFormat;
2873
- get serializationFormat() {
2874
- return this._serializationFormat ?? RpcSerializationFormatResolver.Default.defaultFormat;
2879
+ _wireFormat;
2880
+ get wireFormat() {
2881
+ return this._wireFormat ?? RpcWireFormatResolver.Default.defaultFormat;
2875
2882
  }
2876
- set serializationFormat(value) {
2877
- this._serializationFormat = value;
2883
+ set wireFormat(value) {
2884
+ this._wireFormat = value;
2878
2885
  }
2879
2886
  call(method, args, options) {
2880
2887
  const callId = this.outboundCalls.nextId();
@@ -2884,7 +2891,7 @@ var RpcPeer = class {
2884
2891
  RelatedId: callId,
2885
2892
  CallType: options?.callTypeId ?? 0
2886
2893
  };
2887
- outboundCall.serializedWireData = this.serializationFormat.serializeMessage(
2894
+ outboundCall.serializedWireData = this.wireFormat.serializeMessage(
2888
2895
  envelope,
2889
2896
  args,
2890
2897
  this._connection?.encoder,
@@ -2914,7 +2921,7 @@ var RpcPeer = class {
2914
2921
  outboundCall.onDisconnect();
2915
2922
  const conn = this.wireConnection;
2916
2923
  if (conn !== void 0)
2917
- this.hub.systemCallSender.cancel(conn, this.serializationFormat, callId);
2924
+ this.hub.systemCallSender.cancel(conn, this.wireFormat, callId);
2918
2925
  }
2919
2926
  };
2920
2927
  signal.addEventListener("abort", onAbort, { once: true });
@@ -2926,7 +2933,7 @@ var RpcPeer = class {
2926
2933
  if (!this._isConnected) return;
2927
2934
  const conn = this._connection;
2928
2935
  const envelope = { Method: method, RelatedId: 0 };
2929
- const wireData = this.serializationFormat.serializeMessage(
2936
+ const wireData = this.wireFormat.serializeMessage(
2930
2937
  envelope,
2931
2938
  args,
2932
2939
  conn.encoder,
@@ -2978,7 +2985,7 @@ var RpcPeer = class {
2978
2985
  try {
2979
2986
  this._processMessage(received);
2980
2987
  } catch (e) {
2981
- errorLog2?.log(`'${this.ref}': Failed to process inbound message:`, received, e);
2988
+ errorLog3?.log(`'${this.ref}': Failed to process inbound message:`, received, e);
2982
2989
  }
2983
2990
  }
2984
2991
  _processMessage(received) {
@@ -3048,7 +3055,7 @@ var RpcPeer = class {
3048
3055
  if (conn !== void 0)
3049
3056
  this.hub.systemCallSender.ok(
3050
3057
  conn,
3051
- this.serializationFormat,
3058
+ this.wireFormat,
3052
3059
  relatedId,
3053
3060
  ref
3054
3061
  );
@@ -3066,7 +3073,7 @@ var RpcPeer = class {
3066
3073
  if (conn !== void 0)
3067
3074
  this.hub.systemCallSender.ok(
3068
3075
  conn,
3069
- this.serializationFormat,
3076
+ this.wireFormat,
3070
3077
  relatedId,
3071
3078
  result
3072
3079
  );
@@ -3083,7 +3090,7 @@ var RpcPeer = class {
3083
3090
  if (conn !== void 0)
3084
3091
  this.hub.systemCallSender.error(
3085
3092
  conn,
3086
- this.serializationFormat,
3093
+ this.wireFormat,
3087
3094
  relatedId,
3088
3095
  e
3089
3096
  );
@@ -3118,7 +3125,7 @@ var RpcPeer = class {
3118
3125
  const conn = this.wireConnection;
3119
3126
  if (conn !== void 0) {
3120
3127
  try {
3121
- this.hub.systemCallSender.keepAlive(conn, this.serializationFormat, [
3128
+ this.hub.systemCallSender.keepAlive(conn, this.wireFormat, [
3122
3129
  ...this.remoteObjects.keys()
3123
3130
  ]);
3124
3131
  } catch (e) {
@@ -3222,7 +3229,7 @@ var RpcClientPeer = class extends RpcPeer {
3222
3229
  * Initialized from `hub.limits` at construction; override per peer. */
3223
3230
  prematureDisconnectTimeoutMs;
3224
3231
  peerChanged = new EventHandlerSet3();
3225
- /** Fired when the server rejects the connection due to an unsupported serialization format (close code 4010). */
3232
+ /** Fired when the server rejects the connection due to an unsupported wire format (close code 4001). */
3226
3233
  unsupportedFormat = new EventHandlerSet3();
3227
3234
  reconnectsAtChanged = new EventHandlerSet3();
3228
3235
  get reconnectsAt() {
@@ -3239,7 +3246,7 @@ var RpcClientPeer = class extends RpcPeer {
3239
3246
  whenRunning;
3240
3247
  /**
3241
3248
  * @param hub RpcHub instance this peer will be tracked by
3242
- * @param url Full WebSocket URL — the serialization format is taken from
3249
+ * @param url Full WebSocket URL — the wire format is taken from
3243
3250
  * the `f=` query parameter (e.g. `wss://host/rpc/ws?f=msgpack6`);
3244
3251
  * falls back to the resolver's default when absent. Use
3245
3252
  * {@link RpcRefBuilder.forClient} to compose URLs with a format.
@@ -3255,8 +3262,8 @@ var RpcClientPeer = class extends RpcPeer {
3255
3262
  this.handshakeTimeoutMs = hub.limits.handshakeTimeoutMs;
3256
3263
  this.prematureDisconnectTimeoutMs = hub.limits.prematureDisconnectTimeoutMs;
3257
3264
  this.clientId = guidToBase64Url(this.id);
3258
- const resolver = RpcSerializationFormatResolver.Default;
3259
- this.serializationFormat = resolver.get(parseFormatFromUrl(url) ?? resolver.defaultFormatKey);
3265
+ const resolver = RpcWireFormatResolver.Default;
3266
+ this.wireFormat = resolver.get(parseWireFormatKeyFromUrl(url) ?? resolver.defaultFormatKey);
3260
3267
  if (mustStart)
3261
3268
  this.start();
3262
3269
  }
@@ -3272,7 +3279,7 @@ var RpcClientPeer = class extends RpcPeer {
3272
3279
  const whenHandshake = isPeerChanged ? void 0 : this._pendingHandshake = new PromiseSource5();
3273
3280
  this.hub.systemCallSender.handshake(
3274
3281
  conn,
3275
- this.serializationFormat,
3282
+ this.wireFormat,
3276
3283
  this.id,
3277
3284
  this.hub.hubId,
3278
3285
  this.nextOwnHandshakeIndex()
@@ -3353,8 +3360,8 @@ var RpcClientPeer = class extends RpcPeer {
3353
3360
  const ws = this.webSocketFactory?.(connUrl) ?? new WebSocket(connUrl);
3354
3361
  const conn = new RpcWebSocketConnection(
3355
3362
  ws,
3356
- this.serializationFormat.isBinary,
3357
- this.serializationFormat,
3363
+ this.wireFormat.isBinary,
3364
+ this.wireFormat,
3358
3365
  this.hub.registry
3359
3366
  );
3360
3367
  const whenClosed = new PromiseSource5();
@@ -3390,7 +3397,7 @@ var RpcClientPeer = class extends RpcPeer {
3390
3397
  try {
3391
3398
  this.hub.systemCallSender.handshake(
3392
3399
  conn,
3393
- this.serializationFormat,
3400
+ this.wireFormat,
3394
3401
  this.id,
3395
3402
  this.hub.hubId,
3396
3403
  this.nextOwnHandshakeIndex()
@@ -3439,7 +3446,7 @@ var RpcClientPeer = class extends RpcPeer {
3439
3446
  this._setConnectionState(0 /* Disconnected */);
3440
3447
  if (this._disposed) break;
3441
3448
  if (lastCloseCode === RPC_CLOSE_CODE_UNSUPPORTED_FORMAT) {
3442
- warnLog8?.log(`'${this.ref}': Unsupported serialization format - shutting down`);
3449
+ warnLog8?.log(`'${this.ref}': Unsupported wire format - shutting down`);
3443
3450
  this.unsupportedFormat.trigger({ reason: lastCloseReason });
3444
3451
  this._disposed = true;
3445
3452
  break;
@@ -3573,7 +3580,7 @@ var RpcClientPeer = class extends RpcPeer {
3573
3580
  if (byStage.size === 0) {
3574
3581
  return null;
3575
3582
  }
3576
- const isBinary = this.serializationFormat.isBinary;
3583
+ const isBinary = this.wireFormat.isBinary;
3577
3584
  const stagesArg = isBinary ? /* @__PURE__ */ new Map() : {};
3578
3585
  for (const [stage, ids] of byStage) {
3579
3586
  ids.sort((a, b) => a - b);
@@ -3679,7 +3686,7 @@ var RpcServerPeer = class extends RpcPeer {
3679
3686
  if (this._connection !== void 0) {
3680
3687
  this.hub.systemCallSender.handshake(
3681
3688
  this._connection,
3682
- this.serializationFormat,
3689
+ this.wireFormat,
3683
3690
  this.id,
3684
3691
  this.hub.hubId,
3685
3692
  this.nextOwnHandshakeIndex()
@@ -4638,14 +4645,14 @@ function isSameWireMethod(a, b) {
4638
4645
  // src/rpc-ref-builder.ts
4639
4646
  var RpcRefBuilder = class {
4640
4647
  /** Build a client peer ref from a WebSocket URL, optionally baking in the
4641
- * serialization format as a `f=` query parameter.
4648
+ * wire format as a `f=` query parameter.
4642
4649
  * @param url Base WebSocket URL, e.g. `wss://host/rpc/ws`.
4643
- * @param serializationFormat Optional format key, e.g. `msgpack6`. When
4650
+ * @param wireFormat Optional format key, e.g. `msgpack6`. When
4644
4651
  * provided, replaces any existing `f=` in the URL. */
4645
- static forClient(url, serializationFormat) {
4646
- if (serializationFormat === void 0) return url;
4652
+ static forClient(url, wireFormat) {
4653
+ if (wireFormat === void 0) return url;
4647
4654
  const u = new URL(url);
4648
- u.searchParams.set("f", serializationFormat);
4655
+ u.searchParams.set("f", wireFormat);
4649
4656
  return u.toString();
4650
4657
  }
4651
4658
  /** Build a server peer ref from a peer id — returns `server://{id}`. */
@@ -4907,11 +4914,11 @@ export {
4907
4914
  RpcHub,
4908
4915
  RpcInboundCall,
4909
4916
  RpcInboundCallTracker,
4910
- RpcJsonSerializationFormat,
4917
+ RpcJsonWireFormat,
4911
4918
  RpcLimits,
4912
4919
  RpcMessageChannelConnection,
4913
- RpcMessagePackCompactSerializationFormat,
4914
- RpcMessagePackSerializationFormat,
4920
+ RpcMessagePackCompactWireFormat,
4921
+ RpcMessagePackWireFormat,
4915
4922
  RpcMethodRegistry,
4916
4923
  RpcObjectKind,
4917
4924
  RpcOutboundCall,
@@ -4923,8 +4930,6 @@ export {
4923
4930
  RpcRefBuilder,
4924
4931
  RpcRemoteExecutionMode,
4925
4932
  RpcRemoteObjectTracker,
4926
- RpcSerializationFormat,
4927
- RpcSerializationFormatResolver,
4928
4933
  RpcServerPeer,
4929
4934
  RpcServiceHost,
4930
4935
  RpcSharedObjectTracker,
@@ -4935,6 +4940,8 @@ export {
4935
4940
  RpcSystemCalls,
4936
4941
  RpcType,
4937
4942
  RpcWebSocketConnection,
4943
+ RpcWireFormat,
4944
+ RpcWireFormatResolver,
4938
4945
  WebSocketState,
4939
4946
  computeMethodHash,
4940
4947
  computeReconnectProof,