@dxos/network-manager 0.1.53-main.3ecc504 → 0.1.53-main.55faa2f

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.
@@ -43,10 +43,10 @@ var import_messaging2 = require("@dxos/messaging");
43
43
  var import_protocols6 = require("@dxos/protocols");
44
44
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
45
45
  var import_rpc = require("@dxos/rpc");
46
- var import_util9 = require("@dxos/util");
46
+ var import_util10 = require("@dxos/util");
47
47
 
48
48
  // packages/core/mesh/network-manager/src/network-manager.ts
49
- var import_node_assert5 = __toESM(require("node:assert"));
49
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
50
50
  var import_async6 = require("@dxos/async");
51
51
  var import_keys7 = require("@dxos/keys");
52
52
  var import_log6 = require("@dxos/log");
@@ -62,7 +62,7 @@ var import_keys6 = require("@dxos/keys");
62
62
  var import_util4 = require("@dxos/util");
63
63
 
64
64
  // packages/core/mesh/network-manager/src/swarm/connection.ts
65
- var import_node_assert = __toESM(require("node:assert"));
65
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
66
66
  var import_async = require("@dxos/async");
67
67
  var import_context = require("@dxos/context");
68
68
  var import_debug = require("@dxos/debug");
@@ -152,7 +152,7 @@ var Connection = class {
152
152
  */
153
153
  // TODO(burdon): Make async?
154
154
  openConnection() {
155
- (0, import_node_assert.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
155
+ (0, import_tiny_invariant.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
156
156
  import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.begin({
157
157
  id: this._instanceId
158
158
  }), {
@@ -174,7 +174,7 @@ var Connection = class {
174
174
  });
175
175
  this.close().catch((err) => this.errors.raise(err));
176
176
  });
177
- (0, import_node_assert.default)(!this._transport);
177
+ (0, import_tiny_invariant.default)(!this._transport);
178
178
  this._transport = this._transportFactory.createTransport({
179
179
  initiator: this.initiator,
180
180
  stream: this._protocol.stream,
@@ -296,7 +296,7 @@ var Connection = class {
296
296
  */
297
297
  async signal(msg) {
298
298
  var _a2, _b, _c;
299
- (0, import_node_assert.default)(msg.sessionId);
299
+ (0, import_tiny_invariant.default)(msg.sessionId);
300
300
  if (!msg.sessionId.equals(this.sessionId)) {
301
301
  (0, import_log.log)("dropping signal for incorrect session id", {}, {
302
302
  file: "connection.ts",
@@ -306,9 +306,9 @@ var Connection = class {
306
306
  });
307
307
  return;
308
308
  }
309
- (0, import_node_assert.default)(msg.data.signal || msg.data.signalBatch);
310
- (0, import_node_assert.default)((_a2 = msg.author) == null ? void 0 : _a2.equals(this.remoteId));
311
- (0, import_node_assert.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
309
+ (0, import_tiny_invariant.default)(msg.data.signal || msg.data.signalBatch);
310
+ (0, import_tiny_invariant.default)((_a2 = msg.author) == null ? void 0 : _a2.equals(this.remoteId));
311
+ (0, import_tiny_invariant.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
312
312
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
313
313
  msg.data.signal
314
314
  ];
@@ -329,7 +329,7 @@ var Connection = class {
329
329
  });
330
330
  this._incomingSignalBuffer.push(signal);
331
331
  } else {
332
- (0, import_node_assert.default)(this._transport, "Connection not ready to accept signals.");
332
+ (0, import_tiny_invariant.default)(this._transport, "Connection not ready to accept signals.");
333
333
  (0, import_log.log)("received signal", {
334
334
  peerId: this.ownId,
335
335
  remoteId: this.remoteId,
@@ -355,7 +355,7 @@ var Connection = class {
355
355
  scope: this,
356
356
  callSite: (f, a) => f(...a)
357
357
  });
358
- (0, import_node_assert.default)(state !== this._state, "Already in this state.");
358
+ (0, import_tiny_invariant.default)(state !== this._state, "Already in this state.");
359
359
  this._state = state;
360
360
  this.stateChanged.emit(state);
361
361
  }
@@ -365,7 +365,7 @@ __decorate([
365
365
  ], Connection.prototype, "close", null);
366
366
 
367
367
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
368
- var import_node_assert4 = __toESM(require("node:assert"));
368
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
369
369
  var import_async3 = require("@dxos/async");
370
370
  var import_context4 = require("@dxos/context");
371
371
  var import_debug2 = require("@dxos/debug");
@@ -375,7 +375,7 @@ var import_protocols3 = require("@dxos/protocols");
375
375
  var import_util2 = require("@dxos/util");
376
376
 
377
377
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
378
- var import_node_assert2 = __toESM(require("node:assert"));
378
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
379
379
  var import_context2 = require("@dxos/context");
380
380
  var import_keys2 = require("@dxos/keys");
381
381
  var import_log2 = require("@dxos/log");
@@ -442,7 +442,7 @@ var SwarmMessenger = class {
442
442
  }
443
443
  async signal(message) {
444
444
  var _a2, _b;
445
- (0, import_node_assert2.default)(((_a2 = message.data) == null ? void 0 : _a2.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
445
+ (0, import_tiny_invariant2.default)(((_a2 = message.data) == null ? void 0 : _a2.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
446
446
  await this._sendReliableMessage({
447
447
  author: message.author,
448
448
  recipient: message.recipient,
@@ -493,11 +493,11 @@ var SwarmMessenger = class {
493
493
  }
494
494
  async _resolveAnswers(message) {
495
495
  var _a2, _b, _c;
496
- (0, import_node_assert2.default)((_b = (_a2 = message.data) == null ? void 0 : _a2.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
496
+ (0, import_tiny_invariant2.default)((_b = (_a2 = message.data) == null ? void 0 : _a2.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
497
497
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
498
498
  if (offerRecord) {
499
499
  this._offerRecords.delete(message.data.answer.offerMessageId);
500
- (0, import_node_assert2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
500
+ (0, import_tiny_invariant2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
501
501
  (0, import_log2.log)("resolving", {
502
502
  answer: message.data.answer
503
503
  }, {
@@ -510,7 +510,7 @@ var SwarmMessenger = class {
510
510
  }
511
511
  }
512
512
  async _handleOffer({ author, recipient, message }) {
513
- (0, import_node_assert2.default)(message.data.offer, "No offer");
513
+ (0, import_tiny_invariant2.default)(message.data.offer, "No offer");
514
514
  const offerMessage = {
515
515
  author,
516
516
  recipient,
@@ -545,8 +545,8 @@ var SwarmMessenger = class {
545
545
  }
546
546
  }
547
547
  async _handleSignal({ author, recipient, message }) {
548
- (0, import_node_assert2.default)(message.messageId);
549
- (0, import_node_assert2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
548
+ (0, import_tiny_invariant2.default)(message.messageId);
549
+ (0, import_tiny_invariant2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
550
550
  const signalMessage = {
551
551
  author,
552
552
  recipient,
@@ -561,7 +561,7 @@ var SwarmMessenger = class {
561
561
  };
562
562
 
563
563
  // packages/core/mesh/network-manager/src/swarm/peer.ts
564
- var import_node_assert3 = __toESM(require("node:assert"));
564
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
565
565
  var import_async2 = require("@dxos/async");
566
566
  var import_context3 = require("@dxos/context");
567
567
  var import_keys3 = require("@dxos/keys");
@@ -620,7 +620,7 @@ var Peer = class {
620
620
  }
621
621
  if (await this._callbacks.onOffer(remoteId)) {
622
622
  if (!this.connection) {
623
- (0, import_node_assert3.default)(message.sessionId);
623
+ (0, import_tiny_invariant3.default)(message.sessionId);
624
624
  const connection = this._createConnection(false, message.sessionId);
625
625
  try {
626
626
  connection.openConnection();
@@ -651,8 +651,8 @@ var Peer = class {
651
651
  * Initiate a connection to the remote peer.
652
652
  */
653
653
  async initiateConnection() {
654
- (0, import_node_assert3.default)(!this.initiating, "Initiation in progress.");
655
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
654
+ (0, import_tiny_invariant3.default)(!this.initiating, "Initiation in progress.");
655
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
656
656
  const sessionId = import_keys3.PublicKey.random();
657
657
  (0, import_log3.log)("initiating...", {
658
658
  id: this.id,
@@ -739,7 +739,7 @@ var Peer = class {
739
739
  scope: this,
740
740
  callSite: (f, a) => f(...a)
741
741
  });
742
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
742
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
743
743
  const connection = new Connection(
744
744
  this.topic,
745
745
  this.localPeerId,
@@ -779,7 +779,7 @@ var Peer = class {
779
779
  scope: this,
780
780
  callSite: (f, a) => f(...a)
781
781
  });
782
- (0, import_node_assert3.default)(this.connection === connection, "Connection mismatch (race condition).");
782
+ (0, import_tiny_invariant3.default)(this.connection === connection, "Connection mismatch (race condition).");
783
783
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
784
784
  this._availableAfter = 0;
785
785
  } else {
@@ -968,7 +968,7 @@ var Swarm = class {
968
968
  return this._topic;
969
969
  }
970
970
  async open() {
971
- (0, import_node_assert4.default)(!this._listeningHandle);
971
+ (0, import_tiny_invariant4.default)(!this._listeningHandle);
972
972
  this._listeningHandle = await this._messenger.listen({
973
973
  peerId: this._ownPeerId,
974
974
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -1005,7 +1005,7 @@ var Swarm = class {
1005
1005
  });
1006
1006
  }
1007
1007
  async setTopology(topology) {
1008
- (0, import_node_assert4.default)(!this._ctx.disposed, "Swarm is offline");
1008
+ (0, import_tiny_invariant4.default)(!this._ctx.disposed, "Swarm is offline");
1009
1009
  if (topology === this._topology) {
1010
1010
  return;
1011
1011
  }
@@ -1093,7 +1093,7 @@ var Swarm = class {
1093
1093
  accept: false
1094
1094
  };
1095
1095
  }
1096
- (0, import_node_assert4.default)(message.author);
1096
+ (0, import_tiny_invariant4.default)(message.author);
1097
1097
  if (!((_a2 = message.recipient) == null ? void 0 : _a2.equals(this._ownPeerId))) {
1098
1098
  (0, import_log4.log)("rejecting offer with incorrect peerId", {
1099
1099
  message
@@ -1144,9 +1144,9 @@ var Swarm = class {
1144
1144
  });
1145
1145
  return;
1146
1146
  }
1147
- (0, import_node_assert4.default)((_a2 = message.recipient) == null ? void 0 : _a2.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1148
- (0, import_node_assert4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1149
- (0, import_node_assert4.default)(message.author);
1147
+ (0, import_tiny_invariant4.default)((_a2 = message.recipient) == null ? void 0 : _a2.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1148
+ (0, import_tiny_invariant4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1149
+ (0, import_tiny_invariant4.default)(message.author);
1150
1150
  const peer = this._getOrCreatePeer(message.author);
1151
1151
  await peer.onSignal(message);
1152
1152
  }
@@ -1198,7 +1198,7 @@ var Swarm = class {
1198
1198
  return peer;
1199
1199
  }
1200
1200
  async _destroyPeer(peerId) {
1201
- (0, import_node_assert4.default)(this._peers.has(peerId));
1201
+ (0, import_tiny_invariant4.default)(this._peers.has(peerId));
1202
1202
  await this._peers.get(peerId).destroy();
1203
1203
  this._peers.delete(peerId);
1204
1204
  }
@@ -1417,6 +1417,7 @@ var ConnectionLog = class {
1417
1417
  this._swarms.set(import_keys6.PublicKey.from(swarm._instanceId), info);
1418
1418
  this.update.emit();
1419
1419
  swarm.connectionAdded.on((connection) => {
1420
+ var _a2, _b;
1420
1421
  const connectionInfo = {
1421
1422
  state: ConnectionState.INITIAL,
1422
1423
  remotePeerId: connection.remoteId,
@@ -1435,6 +1436,10 @@ var ConnectionLog = class {
1435
1436
  });
1436
1437
  this.update.emit();
1437
1438
  });
1439
+ (_b = (_a2 = connection.protocol) == null ? void 0 : _a2.stats) == null ? void 0 : _b.on((stats) => {
1440
+ connectionInfo.streams = stats;
1441
+ this.update.emit();
1442
+ });
1438
1443
  });
1439
1444
  }
1440
1445
  leftSwarm(swarm) {
@@ -1525,10 +1530,10 @@ var NetworkManager = class {
1525
1530
  */
1526
1531
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1527
1532
  var _a2;
1528
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(topic));
1529
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1530
- (0, import_node_assert5.default)(topology);
1531
- (0, import_node_assert5.default)(typeof protocol === "function");
1533
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(topic));
1534
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1535
+ (0, import_tiny_invariant5.default)(topology);
1536
+ (0, import_tiny_invariant5.default)(typeof protocol === "function");
1532
1537
  if (this._swarms.has(topic)) {
1533
1538
  throw new Error(`Already connected to swarm: ${import_keys7.PublicKey.from(topic)}`);
1534
1539
  }
@@ -1647,17 +1652,17 @@ var NetworkManager = class {
1647
1652
  };
1648
1653
 
1649
1654
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1650
- var import_node_assert6 = __toESM(require("node:assert"));
1655
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1651
1656
  var FullyConnectedTopology = class {
1652
1657
  toString() {
1653
1658
  return "FullyConnectedTopology";
1654
1659
  }
1655
1660
  init(controller) {
1656
- (0, import_node_assert6.default)(!this._controller, "Already initialized");
1661
+ (0, import_tiny_invariant6.default)(!this._controller, "Already initialized");
1657
1662
  this._controller = controller;
1658
1663
  }
1659
1664
  update() {
1660
- (0, import_node_assert6.default)(this._controller, "Not initialized");
1665
+ (0, import_tiny_invariant6.default)(this._controller, "Not initialized");
1661
1666
  const { candidates: discovered } = this._controller.getState();
1662
1667
  for (const peer of discovered) {
1663
1668
  this._controller.connect(peer);
@@ -1671,15 +1676,17 @@ var FullyConnectedTopology = class {
1671
1676
  };
1672
1677
 
1673
1678
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1679
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1674
1680
  var import_xor_distance = __toESM(require("xor-distance"));
1675
1681
  var import_log7 = require("@dxos/log");
1676
1682
 
1677
1683
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1684
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1678
1685
  var import_log8 = require("@dxos/log");
1679
1686
 
1680
1687
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1681
- var import_node_assert7 = __toESM(require("node:assert"));
1682
1688
  var import_node_stream = require("node:stream");
1689
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
1683
1690
  var import_async7 = require("@dxos/async");
1684
1691
  var import_debug4 = require("@dxos/debug");
1685
1692
  var import_keys8 = require("@dxos/keys");
@@ -1725,7 +1732,7 @@ var _MemoryTransport = class {
1725
1732
  scope: this,
1726
1733
  callSite: (f, a) => f(...a)
1727
1734
  });
1728
- (0, import_node_assert7.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1735
+ (0, import_tiny_invariant9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1729
1736
  _MemoryTransport._connections.set(this._instanceId, this);
1730
1737
  if (this.options.initiator) {
1731
1738
  setTimeout(async () => {
@@ -1759,12 +1766,12 @@ var _MemoryTransport = class {
1759
1766
  this.closed.emit();
1760
1767
  return;
1761
1768
  }
1762
- (0, import_node_assert7.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1769
+ (0, import_tiny_invariant9.default)(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
1763
1770
  this._remoteConnection._remoteConnection = this;
1764
1771
  this._remoteConnection._remoteInstanceId = this._instanceId;
1765
1772
  (0, import_log9.log)("connected", {}, {
1766
1773
  file: "memory-transport.ts",
1767
- line: 106,
1774
+ line: 103,
1768
1775
  scope: this,
1769
1776
  callSite: (f, a) => f(...a)
1770
1777
  });
@@ -1782,7 +1789,7 @@ var _MemoryTransport = class {
1782
1789
  async destroy() {
1783
1790
  (0, import_log9.log)("closing", {}, {
1784
1791
  file: "memory-transport.ts",
1785
- line: 127,
1792
+ line: 124,
1786
1793
  scope: this,
1787
1794
  callSite: (f, a) => f(...a)
1788
1795
  });
@@ -1791,7 +1798,7 @@ var _MemoryTransport = class {
1791
1798
  if (this._remoteConnection) {
1792
1799
  (0, import_log9.log)("closing", {}, {
1793
1800
  file: "memory-transport.ts",
1794
- line: 132,
1801
+ line: 129,
1795
1802
  scope: this,
1796
1803
  callSite: (f, a) => f(...a)
1797
1804
  });
@@ -1804,7 +1811,7 @@ var _MemoryTransport = class {
1804
1811
  this._remoteConnection = void 0;
1805
1812
  (0, import_log9.log)("closed", {}, {
1806
1813
  file: "memory-transport.ts",
1807
- line: 150,
1814
+ line: 147,
1808
1815
  scope: this,
1809
1816
  callSite: (f, a) => f(...a)
1810
1817
  });
@@ -1812,7 +1819,7 @@ var _MemoryTransport = class {
1812
1819
  this.closed.emit();
1813
1820
  (0, import_log9.log)("closed", {}, {
1814
1821
  file: "memory-transport.ts",
1815
- line: 154,
1822
+ line: 151,
1816
1823
  scope: this,
1817
1824
  callSite: (f, a) => f(...a)
1818
1825
  });
@@ -1822,7 +1829,7 @@ var _MemoryTransport = class {
1822
1829
  payload
1823
1830
  }, {
1824
1831
  file: "memory-transport.ts",
1825
- line: 158,
1832
+ line: 155,
1826
1833
  scope: this,
1827
1834
  callSite: (f, a) => f(...a)
1828
1835
  });
@@ -1847,8 +1854,8 @@ __decorate4([
1847
1854
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
1848
1855
 
1849
1856
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1850
- var import_node_assert8 = __toESM(require("node:assert"));
1851
1857
  var import_simple_peer = __toESM(require("simple-peer"));
1858
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
1852
1859
  var import_async8 = require("@dxos/async");
1853
1860
  var import_debug5 = require("@dxos/debug");
1854
1861
  var import_keys9 = require("@dxos/keys");
@@ -1976,7 +1983,7 @@ var WebRTCTransport = class {
1976
1983
  if (this._closed) {
1977
1984
  return;
1978
1985
  }
1979
- (0, import_node_assert8.default)(signal.payload.data, "Signal message must contain signal data.");
1986
+ (0, import_tiny_invariant10.default)(signal.payload.data, "Signal message must contain signal data.");
1980
1987
  this._peer.signal(signal.payload.data);
1981
1988
  }
1982
1989
  async _disconnectStreams() {
@@ -1986,8 +1993,8 @@ var WebRTCTransport = class {
1986
1993
  };
1987
1994
 
1988
1995
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
1989
- var import_node_assert9 = __toESM(require("node:assert"));
1990
1996
  var import_node_stream2 = require("node:stream");
1997
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
1991
1998
  var import_codec_protobuf = require("@dxos/codec-protobuf");
1992
1999
  var import_keys10 = require("@dxos/keys");
1993
2000
  var import_log11 = require("@dxos/log");
@@ -2063,11 +2070,11 @@ var WebRTCTransportService = class {
2063
2070
  return rpcStream;
2064
2071
  }
2065
2072
  async sendSignal({ proxyId, signal }) {
2066
- (0, import_node_assert9.default)(this.transports.has(proxyId));
2073
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2067
2074
  await this.transports.get(proxyId).transport.signal(signal);
2068
2075
  }
2069
2076
  async sendData({ proxyId, payload }) {
2070
- (0, import_node_assert9.default)(this.transports.has(proxyId));
2077
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2071
2078
  await this.transports.get(proxyId).stream.push(payload);
2072
2079
  }
2073
2080
  async close({ proxyId }) {
@@ -2085,13 +2092,14 @@ var WebRTCTransportService = class {
2085
2092
  };
2086
2093
 
2087
2094
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2088
- var import_node_assert10 = __toESM(require("node:assert"));
2095
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
2089
2096
  var import_async9 = require("@dxos/async");
2090
2097
  var import_context5 = require("@dxos/context");
2091
2098
  var import_debug6 = require("@dxos/debug");
2092
2099
  var import_keys11 = require("@dxos/keys");
2093
2100
  var import_log12 = require("@dxos/log");
2094
2101
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
2102
+ var import_util8 = require("@dxos/util");
2095
2103
  var WebRTCTransportProxy = class {
2096
2104
  // prettier-ignore
2097
2105
  constructor(_params) {
@@ -2110,7 +2118,7 @@ var WebRTCTransportProxy = class {
2110
2118
  this._serviceStream.subscribe(async (event) => {
2111
2119
  (0, import_log12.log)("WebRTCTransportProxy: event", event, {
2112
2120
  file: "webrtc-transport-proxy.ts",
2113
- line: 49,
2121
+ line: 50,
2114
2122
  scope: this,
2115
2123
  callSite: (f, a) => f(...a)
2116
2124
  });
@@ -2131,7 +2139,7 @@ var WebRTCTransportProxy = class {
2131
2139
  } catch (err) {
2132
2140
  import_log12.log.catch(err, {}, {
2133
2141
  file: "webrtc-transport-proxy.ts",
2134
- line: 66,
2142
+ line: 67,
2135
2143
  scope: this,
2136
2144
  callSite: (f, a) => f(...a)
2137
2145
  });
@@ -2143,7 +2151,7 @@ var WebRTCTransportProxy = class {
2143
2151
  });
2144
2152
  }, (error) => import_log12.log.catch(error, {}, {
2145
2153
  file: "webrtc-transport-proxy.ts",
2146
- line: 72,
2154
+ line: 73,
2147
2155
  scope: this,
2148
2156
  callSite: (f, a) => f(...a)
2149
2157
  }));
@@ -2164,7 +2172,7 @@ var WebRTCTransportProxy = class {
2164
2172
  }
2165
2173
  }
2166
2174
  _handleData(dataEvent) {
2167
- this._params.stream.write(Buffer.from(dataEvent.payload));
2175
+ this._params.stream.write((0, import_util8.arrayToBuffer)(dataEvent.payload));
2168
2176
  }
2169
2177
  async _handleSignal(signalEvent) {
2170
2178
  await this._params.sendSignal(signalEvent.payload);
@@ -2189,7 +2197,7 @@ var WebRTCTransportProxy = class {
2189
2197
  } catch (err) {
2190
2198
  import_log12.log.catch(err, {}, {
2191
2199
  file: "webrtc-transport-proxy.ts",
2192
- line: 123,
2200
+ line: 124,
2193
2201
  scope: this,
2194
2202
  callSite: (f, a) => f(...a)
2195
2203
  });
@@ -2223,7 +2231,7 @@ var WebRTCTransportProxyFactory = class {
2223
2231
  return this;
2224
2232
  }
2225
2233
  createTransport(options) {
2226
- (0, import_node_assert10.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2234
+ (0, import_tiny_invariant12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2227
2235
  const transport = new WebRTCTransportProxy({
2228
2236
  ...options,
2229
2237
  bridgeService: this._bridgeService
@@ -2239,7 +2247,7 @@ var import_async10 = require("@dxos/async");
2239
2247
  var import_keys12 = require("@dxos/keys");
2240
2248
  var import_log13 = require("@dxos/log");
2241
2249
  var import_teleport2 = require("@dxos/teleport");
2242
- var import_util8 = require("@dxos/util");
2250
+ var import_util9 = require("@dxos/util");
2243
2251
 
2244
2252
  // packages/core/mesh/network-manager/src/wire-protocol.ts
2245
2253
  var import_teleport = require("@dxos/teleport");
@@ -2263,7 +2271,7 @@ var createTeleportProtocolFactory = (onConnection) => {
2263
2271
  var TestWireProtocol = class {
2264
2272
  constructor(peerId) {
2265
2273
  this.peerId = peerId;
2266
- this.connections = new import_util8.ComplexMap(import_keys12.PublicKey.hash);
2274
+ this.connections = new import_util9.ComplexMap(import_keys12.PublicKey.hash);
2267
2275
  this.connected = new import_async10.Event();
2268
2276
  this.disconnected = new import_async10.Event();
2269
2277
  this.factory = createTeleportProtocolFactory(async (teleport) => {
@@ -2338,7 +2346,7 @@ var TestPeer = class {
2338
2346
  constructor(testBuilder, peerId) {
2339
2347
  this.testBuilder = testBuilder;
2340
2348
  this.peerId = peerId;
2341
- this._swarms = new import_util9.ComplexMap(import_keys13.PublicKey.hash);
2349
+ this._swarms = new import_util10.ComplexMap(import_keys13.PublicKey.hash);
2342
2350
  this._signalManager = this.testBuilder.createSignalManager();
2343
2351
  this._networkManager = this.createNetworkManager();
2344
2352
  }