@dxos/network-manager 0.1.53-main.d095ee3 → 0.1.53-main.d2dd40b

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.
@@ -59,7 +59,7 @@ var import_keys6 = require("@dxos/keys");
59
59
  var import_util4 = require("@dxos/util");
60
60
 
61
61
  // packages/core/mesh/network-manager/src/swarm/connection.ts
62
- var import_node_assert = __toESM(require("node:assert"));
62
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
63
63
  var import_async = require("@dxos/async");
64
64
  var import_context = require("@dxos/context");
65
65
  var import_debug = require("@dxos/debug");
@@ -149,7 +149,7 @@ var Connection = class {
149
149
  */
150
150
  // TODO(burdon): Make async?
151
151
  openConnection() {
152
- (0, import_node_assert.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
152
+ (0, import_tiny_invariant.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
153
153
  import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.begin({
154
154
  id: this._instanceId
155
155
  }), {
@@ -171,7 +171,7 @@ var Connection = class {
171
171
  });
172
172
  this.close().catch((err) => this.errors.raise(err));
173
173
  });
174
- (0, import_node_assert.default)(!this._transport);
174
+ (0, import_tiny_invariant.default)(!this._transport);
175
175
  this._transport = this._transportFactory.createTransport({
176
176
  initiator: this.initiator,
177
177
  stream: this._protocol.stream,
@@ -293,7 +293,7 @@ var Connection = class {
293
293
  */
294
294
  async signal(msg) {
295
295
  var _a, _b, _c;
296
- (0, import_node_assert.default)(msg.sessionId);
296
+ (0, import_tiny_invariant.default)(msg.sessionId);
297
297
  if (!msg.sessionId.equals(this.sessionId)) {
298
298
  (0, import_log.log)("dropping signal for incorrect session id", {}, {
299
299
  file: "connection.ts",
@@ -303,9 +303,9 @@ var Connection = class {
303
303
  });
304
304
  return;
305
305
  }
306
- (0, import_node_assert.default)(msg.data.signal || msg.data.signalBatch);
307
- (0, import_node_assert.default)((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
308
- (0, import_node_assert.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
306
+ (0, import_tiny_invariant.default)(msg.data.signal || msg.data.signalBatch);
307
+ (0, import_tiny_invariant.default)((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
308
+ (0, import_tiny_invariant.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
309
309
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
310
310
  msg.data.signal
311
311
  ];
@@ -326,7 +326,7 @@ var Connection = class {
326
326
  });
327
327
  this._incomingSignalBuffer.push(signal);
328
328
  } else {
329
- (0, import_node_assert.default)(this._transport, "Connection not ready to accept signals.");
329
+ (0, import_tiny_invariant.default)(this._transport, "Connection not ready to accept signals.");
330
330
  (0, import_log.log)("received signal", {
331
331
  peerId: this.ownId,
332
332
  remoteId: this.remoteId,
@@ -352,7 +352,7 @@ var Connection = class {
352
352
  scope: this,
353
353
  callSite: (f, a) => f(...a)
354
354
  });
355
- (0, import_node_assert.default)(state !== this._state, "Already in this state.");
355
+ (0, import_tiny_invariant.default)(state !== this._state, "Already in this state.");
356
356
  this._state = state;
357
357
  this.stateChanged.emit(state);
358
358
  }
@@ -362,7 +362,7 @@ __decorate([
362
362
  ], Connection.prototype, "close", null);
363
363
 
364
364
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
365
- var import_node_assert4 = __toESM(require("node:assert"));
365
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
366
366
  var import_async3 = require("@dxos/async");
367
367
  var import_context4 = require("@dxos/context");
368
368
  var import_debug2 = require("@dxos/debug");
@@ -372,7 +372,7 @@ var import_protocols3 = require("@dxos/protocols");
372
372
  var import_util2 = require("@dxos/util");
373
373
 
374
374
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
375
- var import_node_assert2 = __toESM(require("node:assert"));
375
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
376
376
  var import_context2 = require("@dxos/context");
377
377
  var import_keys2 = require("@dxos/keys");
378
378
  var import_log2 = require("@dxos/log");
@@ -439,7 +439,7 @@ var SwarmMessenger = class {
439
439
  }
440
440
  async signal(message) {
441
441
  var _a, _b;
442
- (0, import_node_assert2.default)(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
442
+ (0, import_tiny_invariant2.default)(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
443
443
  await this._sendReliableMessage({
444
444
  author: message.author,
445
445
  recipient: message.recipient,
@@ -490,11 +490,11 @@ var SwarmMessenger = class {
490
490
  }
491
491
  async _resolveAnswers(message) {
492
492
  var _a, _b, _c;
493
- (0, import_node_assert2.default)((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
493
+ (0, import_tiny_invariant2.default)((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
494
494
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
495
495
  if (offerRecord) {
496
496
  this._offerRecords.delete(message.data.answer.offerMessageId);
497
- (0, import_node_assert2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
497
+ (0, import_tiny_invariant2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
498
498
  (0, import_log2.log)("resolving", {
499
499
  answer: message.data.answer
500
500
  }, {
@@ -507,7 +507,7 @@ var SwarmMessenger = class {
507
507
  }
508
508
  }
509
509
  async _handleOffer({ author, recipient, message }) {
510
- (0, import_node_assert2.default)(message.data.offer, "No offer");
510
+ (0, import_tiny_invariant2.default)(message.data.offer, "No offer");
511
511
  const offerMessage = {
512
512
  author,
513
513
  recipient,
@@ -542,8 +542,8 @@ var SwarmMessenger = class {
542
542
  }
543
543
  }
544
544
  async _handleSignal({ author, recipient, message }) {
545
- (0, import_node_assert2.default)(message.messageId);
546
- (0, import_node_assert2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
545
+ (0, import_tiny_invariant2.default)(message.messageId);
546
+ (0, import_tiny_invariant2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
547
547
  const signalMessage = {
548
548
  author,
549
549
  recipient,
@@ -558,7 +558,7 @@ var SwarmMessenger = class {
558
558
  };
559
559
 
560
560
  // packages/core/mesh/network-manager/src/swarm/peer.ts
561
- var import_node_assert3 = __toESM(require("node:assert"));
561
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
562
562
  var import_async2 = require("@dxos/async");
563
563
  var import_context3 = require("@dxos/context");
564
564
  var import_keys3 = require("@dxos/keys");
@@ -617,7 +617,7 @@ var Peer = class {
617
617
  }
618
618
  if (await this._callbacks.onOffer(remoteId)) {
619
619
  if (!this.connection) {
620
- (0, import_node_assert3.default)(message.sessionId);
620
+ (0, import_tiny_invariant3.default)(message.sessionId);
621
621
  const connection = this._createConnection(false, message.sessionId);
622
622
  try {
623
623
  connection.openConnection();
@@ -648,8 +648,8 @@ var Peer = class {
648
648
  * Initiate a connection to the remote peer.
649
649
  */
650
650
  async initiateConnection() {
651
- (0, import_node_assert3.default)(!this.initiating, "Initiation in progress.");
652
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
651
+ (0, import_tiny_invariant3.default)(!this.initiating, "Initiation in progress.");
652
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
653
653
  const sessionId = import_keys3.PublicKey.random();
654
654
  (0, import_log3.log)("initiating...", {
655
655
  id: this.id,
@@ -736,7 +736,7 @@ var Peer = class {
736
736
  scope: this,
737
737
  callSite: (f, a) => f(...a)
738
738
  });
739
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
739
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
740
740
  const connection = new Connection(
741
741
  this.topic,
742
742
  this.localPeerId,
@@ -776,7 +776,7 @@ var Peer = class {
776
776
  scope: this,
777
777
  callSite: (f, a) => f(...a)
778
778
  });
779
- (0, import_node_assert3.default)(this.connection === connection, "Connection mismatch (race condition).");
779
+ (0, import_tiny_invariant3.default)(this.connection === connection, "Connection mismatch (race condition).");
780
780
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
781
781
  this._availableAfter = 0;
782
782
  } else {
@@ -965,7 +965,7 @@ var Swarm = class {
965
965
  return this._topic;
966
966
  }
967
967
  async open() {
968
- (0, import_node_assert4.default)(!this._listeningHandle);
968
+ (0, import_tiny_invariant4.default)(!this._listeningHandle);
969
969
  this._listeningHandle = await this._messenger.listen({
970
970
  peerId: this._ownPeerId,
971
971
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -1002,7 +1002,7 @@ var Swarm = class {
1002
1002
  });
1003
1003
  }
1004
1004
  async setTopology(topology) {
1005
- (0, import_node_assert4.default)(!this._ctx.disposed, "Swarm is offline");
1005
+ (0, import_tiny_invariant4.default)(!this._ctx.disposed, "Swarm is offline");
1006
1006
  if (topology === this._topology) {
1007
1007
  return;
1008
1008
  }
@@ -1090,7 +1090,7 @@ var Swarm = class {
1090
1090
  accept: false
1091
1091
  };
1092
1092
  }
1093
- (0, import_node_assert4.default)(message.author);
1093
+ (0, import_tiny_invariant4.default)(message.author);
1094
1094
  if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
1095
1095
  (0, import_log4.log)("rejecting offer with incorrect peerId", {
1096
1096
  message
@@ -1141,9 +1141,9 @@ var Swarm = class {
1141
1141
  });
1142
1142
  return;
1143
1143
  }
1144
- (0, import_node_assert4.default)((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1145
- (0, import_node_assert4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1146
- (0, import_node_assert4.default)(message.author);
1144
+ (0, import_tiny_invariant4.default)((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1145
+ (0, import_tiny_invariant4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1146
+ (0, import_tiny_invariant4.default)(message.author);
1147
1147
  const peer = this._getOrCreatePeer(message.author);
1148
1148
  await peer.onSignal(message);
1149
1149
  }
@@ -1195,7 +1195,7 @@ var Swarm = class {
1195
1195
  return peer;
1196
1196
  }
1197
1197
  async _destroyPeer(peerId) {
1198
- (0, import_node_assert4.default)(this._peers.has(peerId));
1198
+ (0, import_tiny_invariant4.default)(this._peers.has(peerId));
1199
1199
  await this._peers.get(peerId).destroy();
1200
1200
  this._peers.delete(peerId);
1201
1201
  }
@@ -1446,7 +1446,7 @@ var ConnectionLog = class {
1446
1446
  };
1447
1447
 
1448
1448
  // packages/core/mesh/network-manager/src/network-manager.ts
1449
- var import_node_assert5 = __toESM(require("node:assert"));
1449
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
1450
1450
  var import_async6 = require("@dxos/async");
1451
1451
  var import_keys7 = require("@dxos/keys");
1452
1452
  var import_log6 = require("@dxos/log");
@@ -1535,10 +1535,10 @@ var NetworkManager = class {
1535
1535
  */
1536
1536
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1537
1537
  var _a;
1538
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(topic));
1539
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1540
- (0, import_node_assert5.default)(topology);
1541
- (0, import_node_assert5.default)(typeof protocol === "function");
1538
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(topic));
1539
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1540
+ (0, import_tiny_invariant5.default)(topology);
1541
+ (0, import_tiny_invariant5.default)(typeof protocol === "function");
1542
1542
  if (this._swarms.has(topic)) {
1543
1543
  throw new Error(`Already connected to swarm: ${import_keys7.PublicKey.from(topic)}`);
1544
1544
  }
@@ -1657,17 +1657,17 @@ var NetworkManager = class {
1657
1657
  };
1658
1658
 
1659
1659
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1660
- var import_node_assert6 = __toESM(require("node:assert"));
1660
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1661
1661
  var FullyConnectedTopology = class {
1662
1662
  toString() {
1663
1663
  return "FullyConnectedTopology";
1664
1664
  }
1665
1665
  init(controller) {
1666
- (0, import_node_assert6.default)(!this._controller, "Already initialized");
1666
+ (0, import_tiny_invariant6.default)(!this._controller, "Already initialized");
1667
1667
  this._controller = controller;
1668
1668
  }
1669
1669
  update() {
1670
- (0, import_node_assert6.default)(this._controller, "Not initialized");
1670
+ (0, import_tiny_invariant6.default)(this._controller, "Not initialized");
1671
1671
  const { candidates: discovered } = this._controller.getState();
1672
1672
  for (const peer of discovered) {
1673
1673
  this._controller.connect(peer);
@@ -1681,7 +1681,7 @@ var FullyConnectedTopology = class {
1681
1681
  };
1682
1682
 
1683
1683
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1684
- var import_node_assert7 = __toESM(require("node:assert"));
1684
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1685
1685
  var import_xor_distance = __toESM(require("xor-distance"));
1686
1686
  var import_log7 = require("@dxos/log");
1687
1687
  var MMSTTopology = class {
@@ -1692,11 +1692,11 @@ var MMSTTopology = class {
1692
1692
  this._sampleSize = sampleSize;
1693
1693
  }
1694
1694
  init(controller) {
1695
- (0, import_node_assert7.default)(!this._controller, "Already initialized");
1695
+ (0, import_tiny_invariant7.default)(!this._controller, "Already initialized");
1696
1696
  this._controller = controller;
1697
1697
  }
1698
1698
  update() {
1699
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1699
+ (0, import_tiny_invariant7.default)(this._controller, "Not initialized");
1700
1700
  const { connected, candidates } = this._controller.getState();
1701
1701
  if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
1702
1702
  (0, import_log7.log)("Running the algorithm.", {}, {
@@ -1710,7 +1710,7 @@ var MMSTTopology = class {
1710
1710
  }
1711
1711
  }
1712
1712
  async onOffer(peer) {
1713
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1713
+ (0, import_tiny_invariant7.default)(this._controller, "Not initialized");
1714
1714
  const { connected } = this._controller.getState();
1715
1715
  const accept = connected.length < this._maxPeers;
1716
1716
  (0, import_log7.log)(`Offer ${peer} accept=${accept}`, {}, {
@@ -1724,7 +1724,7 @@ var MMSTTopology = class {
1724
1724
  async destroy() {
1725
1725
  }
1726
1726
  _runAlgorithm() {
1727
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1727
+ (0, import_tiny_invariant7.default)(this._controller, "Not initialized");
1728
1728
  const { connected, candidates, ownPeerId } = this._controller.getState();
1729
1729
  if (connected.length > this._maxPeers) {
1730
1730
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
@@ -1758,7 +1758,7 @@ var MMSTTopology = class {
1758
1758
  var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_distance.default.gt((0, import_xor_distance.default)(a.asBuffer(), reference.asBuffer()), (0, import_xor_distance.default)(b.asBuffer(), reference.asBuffer())));
1759
1759
 
1760
1760
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1761
- var import_node_assert8 = __toESM(require("node:assert"));
1761
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1762
1762
  var import_log8 = require("@dxos/log");
1763
1763
  var StarTopology = class {
1764
1764
  // prettier-ignore
@@ -1769,11 +1769,11 @@ var StarTopology = class {
1769
1769
  return `StarTopology(${this._centralPeer.truncate()})`;
1770
1770
  }
1771
1771
  init(controller) {
1772
- (0, import_node_assert8.default)(!this._controller, "Already initialized.");
1772
+ (0, import_tiny_invariant8.default)(!this._controller, "Already initialized.");
1773
1773
  this._controller = controller;
1774
1774
  }
1775
1775
  update() {
1776
- (0, import_node_assert8.default)(this._controller, "Not initialized.");
1776
+ (0, import_tiny_invariant8.default)(this._controller, "Not initialized.");
1777
1777
  const { candidates, connected, ownPeerId } = this._controller.getState();
1778
1778
  if (!ownPeerId.equals(this._centralPeer)) {
1779
1779
  (0, import_log8.log)("leaf peer dropping all connections apart from central peer.", {}, {
@@ -1811,7 +1811,7 @@ var StarTopology = class {
1811
1811
  }
1812
1812
  }
1813
1813
  async onOffer(peer) {
1814
- (0, import_node_assert8.default)(this._controller, "Not initialized.");
1814
+ (0, import_tiny_invariant8.default)(this._controller, "Not initialized.");
1815
1815
  const { ownPeerId } = this._controller.getState();
1816
1816
  (0, import_log8.log)("offer", {
1817
1817
  peer,
@@ -1830,8 +1830,8 @@ var StarTopology = class {
1830
1830
  };
1831
1831
 
1832
1832
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1833
- var import_node_assert9 = __toESM(require("node:assert"));
1834
1833
  var import_node_stream = require("node:stream");
1834
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
1835
1835
  var import_async7 = require("@dxos/async");
1836
1836
  var import_debug4 = require("@dxos/debug");
1837
1837
  var import_keys8 = require("@dxos/keys");
@@ -1877,7 +1877,7 @@ var _MemoryTransport = class {
1877
1877
  scope: this,
1878
1878
  callSite: (f, a) => f(...a)
1879
1879
  });
1880
- (0, import_node_assert9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1880
+ (0, import_tiny_invariant9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1881
1881
  _MemoryTransport._connections.set(this._instanceId, this);
1882
1882
  if (this.options.initiator) {
1883
1883
  setTimeout(async () => {
@@ -1911,12 +1911,12 @@ var _MemoryTransport = class {
1911
1911
  this.closed.emit();
1912
1912
  return;
1913
1913
  }
1914
- (0, import_node_assert9.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1914
+ (0, import_tiny_invariant9.default)(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
1915
1915
  this._remoteConnection._remoteConnection = this;
1916
1916
  this._remoteConnection._remoteInstanceId = this._instanceId;
1917
1917
  (0, import_log9.log)("connected", {}, {
1918
1918
  file: "memory-transport.ts",
1919
- line: 106,
1919
+ line: 103,
1920
1920
  scope: this,
1921
1921
  callSite: (f, a) => f(...a)
1922
1922
  });
@@ -1934,7 +1934,7 @@ var _MemoryTransport = class {
1934
1934
  async destroy() {
1935
1935
  (0, import_log9.log)("closing", {}, {
1936
1936
  file: "memory-transport.ts",
1937
- line: 127,
1937
+ line: 124,
1938
1938
  scope: this,
1939
1939
  callSite: (f, a) => f(...a)
1940
1940
  });
@@ -1943,7 +1943,7 @@ var _MemoryTransport = class {
1943
1943
  if (this._remoteConnection) {
1944
1944
  (0, import_log9.log)("closing", {}, {
1945
1945
  file: "memory-transport.ts",
1946
- line: 132,
1946
+ line: 129,
1947
1947
  scope: this,
1948
1948
  callSite: (f, a) => f(...a)
1949
1949
  });
@@ -1956,7 +1956,7 @@ var _MemoryTransport = class {
1956
1956
  this._remoteConnection = void 0;
1957
1957
  (0, import_log9.log)("closed", {}, {
1958
1958
  file: "memory-transport.ts",
1959
- line: 150,
1959
+ line: 147,
1960
1960
  scope: this,
1961
1961
  callSite: (f, a) => f(...a)
1962
1962
  });
@@ -1964,7 +1964,7 @@ var _MemoryTransport = class {
1964
1964
  this.closed.emit();
1965
1965
  (0, import_log9.log)("closed", {}, {
1966
1966
  file: "memory-transport.ts",
1967
- line: 154,
1967
+ line: 151,
1968
1968
  scope: this,
1969
1969
  callSite: (f, a) => f(...a)
1970
1970
  });
@@ -1974,7 +1974,7 @@ var _MemoryTransport = class {
1974
1974
  payload
1975
1975
  }, {
1976
1976
  file: "memory-transport.ts",
1977
- line: 158,
1977
+ line: 155,
1978
1978
  scope: this,
1979
1979
  callSite: (f, a) => f(...a)
1980
1980
  });
@@ -1999,8 +1999,8 @@ __decorate4([
1999
1999
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
2000
2000
 
2001
2001
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
2002
- var import_node_assert10 = __toESM(require("node:assert"));
2003
2002
  var import_simple_peer = __toESM(require("simple-peer"));
2003
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
2004
2004
  var import_async8 = require("@dxos/async");
2005
2005
  var import_debug5 = require("@dxos/debug");
2006
2006
  var import_keys9 = require("@dxos/keys");
@@ -2128,7 +2128,7 @@ var WebRTCTransport = class {
2128
2128
  if (this._closed) {
2129
2129
  return;
2130
2130
  }
2131
- (0, import_node_assert10.default)(signal.payload.data, "Signal message must contain signal data.");
2131
+ (0, import_tiny_invariant10.default)(signal.payload.data, "Signal message must contain signal data.");
2132
2132
  this._peer.signal(signal.payload.data);
2133
2133
  }
2134
2134
  async _disconnectStreams() {
@@ -2144,8 +2144,8 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
2144
2144
  });
2145
2145
 
2146
2146
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
2147
- var import_node_assert11 = __toESM(require("node:assert"));
2148
2147
  var import_node_stream2 = require("node:stream");
2148
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
2149
2149
  var import_codec_protobuf = require("@dxos/codec-protobuf");
2150
2150
  var import_keys10 = require("@dxos/keys");
2151
2151
  var import_log11 = require("@dxos/log");
@@ -2221,11 +2221,11 @@ var WebRTCTransportService = class {
2221
2221
  return rpcStream;
2222
2222
  }
2223
2223
  async sendSignal({ proxyId, signal }) {
2224
- (0, import_node_assert11.default)(this.transports.has(proxyId));
2224
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2225
2225
  await this.transports.get(proxyId).transport.signal(signal);
2226
2226
  }
2227
2227
  async sendData({ proxyId, payload }) {
2228
- (0, import_node_assert11.default)(this.transports.has(proxyId));
2228
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2229
2229
  await this.transports.get(proxyId).stream.push(payload);
2230
2230
  }
2231
2231
  async close({ proxyId }) {
@@ -2243,7 +2243,7 @@ var WebRTCTransportService = class {
2243
2243
  };
2244
2244
 
2245
2245
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2246
- var import_node_assert12 = __toESM(require("node:assert"));
2246
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
2247
2247
  var import_async9 = require("@dxos/async");
2248
2248
  var import_context5 = require("@dxos/context");
2249
2249
  var import_debug6 = require("@dxos/debug");
@@ -2382,7 +2382,7 @@ var WebRTCTransportProxyFactory = class {
2382
2382
  return this;
2383
2383
  }
2384
2384
  createTransport(options) {
2385
- (0, import_node_assert12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2385
+ (0, import_tiny_invariant12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2386
2386
  const transport = new WebRTCTransportProxy({
2387
2387
  ...options,
2388
2388
  bridgeService: this._bridgeService