@dxos/network-manager 0.1.53-main.b6f5d87 → 0.1.53-main.ceb8ff5

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.
@@ -1,4 +1,4 @@
1
- import "@dxos/node-std/globals"
1
+ import "@dxos/node-std/globals";
2
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
4
  }) : x)(function(x) {
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
  });
9
9
 
10
10
  // packages/core/mesh/network-manager/src/swarm/connection.ts
11
- import assert from "@dxos/node-std/assert";
11
+ import invariant from "tiny-invariant";
12
12
  import { DeferredTask, Event, sleep, synchronized } from "@dxos/async";
13
13
  import { Context, cancelWithContext } from "@dxos/context";
14
14
  import { ErrorStream } from "@dxos/debug";
@@ -98,7 +98,7 @@ var Connection = class {
98
98
  */
99
99
  // TODO(burdon): Make async?
100
100
  openConnection() {
101
- assert(this._state === ConnectionState.INITIAL, "Invalid state.");
101
+ invariant(this._state === ConnectionState.INITIAL, "Invalid state.");
102
102
  log.trace("dxos.mesh.connection.open-connection", trace.begin({
103
103
  id: this._instanceId
104
104
  }), {
@@ -120,7 +120,7 @@ var Connection = class {
120
120
  });
121
121
  this.close().catch((err) => this.errors.raise(err));
122
122
  });
123
- assert(!this._transport);
123
+ invariant(!this._transport);
124
124
  this._transport = this._transportFactory.createTransport({
125
125
  initiator: this.initiator,
126
126
  stream: this._protocol.stream,
@@ -242,7 +242,7 @@ var Connection = class {
242
242
  */
243
243
  async signal(msg) {
244
244
  var _a, _b, _c;
245
- assert(msg.sessionId);
245
+ invariant(msg.sessionId);
246
246
  if (!msg.sessionId.equals(this.sessionId)) {
247
247
  log("dropping signal for incorrect session id", {}, {
248
248
  file: "connection.ts",
@@ -252,9 +252,9 @@ var Connection = class {
252
252
  });
253
253
  return;
254
254
  }
255
- assert(msg.data.signal || msg.data.signalBatch);
256
- assert((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
257
- assert((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
255
+ invariant(msg.data.signal || msg.data.signalBatch);
256
+ invariant((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
257
+ invariant((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
258
258
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
259
259
  msg.data.signal
260
260
  ];
@@ -275,7 +275,7 @@ var Connection = class {
275
275
  });
276
276
  this._incomingSignalBuffer.push(signal);
277
277
  } else {
278
- assert(this._transport, "Connection not ready to accept signals.");
278
+ invariant(this._transport, "Connection not ready to accept signals.");
279
279
  log("received signal", {
280
280
  peerId: this.ownId,
281
281
  remoteId: this.remoteId,
@@ -301,7 +301,7 @@ var Connection = class {
301
301
  scope: this,
302
302
  callSite: (f, a) => f(...a)
303
303
  });
304
- assert(state !== this._state, "Already in this state.");
304
+ invariant(state !== this._state, "Already in this state.");
305
305
  this._state = state;
306
306
  this.stateChanged.emit(state);
307
307
  }
@@ -311,7 +311,7 @@ __decorate([
311
311
  ], Connection.prototype, "close", null);
312
312
 
313
313
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
314
- import assert2 from "@dxos/node-std/assert";
314
+ import invariant2 from "tiny-invariant";
315
315
  import { Context as Context2 } from "@dxos/context";
316
316
  import { PublicKey as PublicKey2 } from "@dxos/keys";
317
317
  import { log as log2 } from "@dxos/log";
@@ -378,7 +378,7 @@ var SwarmMessenger = class {
378
378
  }
379
379
  async signal(message) {
380
380
  var _a, _b;
381
- assert2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
381
+ invariant2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
382
382
  await this._sendReliableMessage({
383
383
  author: message.author,
384
384
  recipient: message.recipient,
@@ -429,11 +429,11 @@ var SwarmMessenger = class {
429
429
  }
430
430
  async _resolveAnswers(message) {
431
431
  var _a, _b, _c;
432
- assert2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
432
+ invariant2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
433
433
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
434
434
  if (offerRecord) {
435
435
  this._offerRecords.delete(message.data.answer.offerMessageId);
436
- assert2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
436
+ invariant2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
437
437
  log2("resolving", {
438
438
  answer: message.data.answer
439
439
  }, {
@@ -446,7 +446,7 @@ var SwarmMessenger = class {
446
446
  }
447
447
  }
448
448
  async _handleOffer({ author, recipient, message }) {
449
- assert2(message.data.offer, "No offer");
449
+ invariant2(message.data.offer, "No offer");
450
450
  const offerMessage = {
451
451
  author,
452
452
  recipient,
@@ -481,8 +481,8 @@ var SwarmMessenger = class {
481
481
  }
482
482
  }
483
483
  async _handleSignal({ author, recipient, message }) {
484
- assert2(message.messageId);
485
- assert2(message.data.signal || message.data.signalBatch, "Invalid message");
484
+ invariant2(message.messageId);
485
+ invariant2(message.data.signal || message.data.signalBatch, "Invalid message");
486
486
  const signalMessage = {
487
487
  author,
488
488
  recipient,
@@ -497,7 +497,7 @@ var SwarmMessenger = class {
497
497
  };
498
498
 
499
499
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
500
- import assert4 from "@dxos/node-std/assert";
500
+ import invariant4 from "tiny-invariant";
501
501
  import { Event as Event2, scheduleTask as scheduleTask2, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
502
502
  import { Context as Context4 } from "@dxos/context";
503
503
  import { ErrorStream as ErrorStream2 } from "@dxos/debug";
@@ -507,7 +507,7 @@ import { trace as trace2 } from "@dxos/protocols";
507
507
  import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
508
508
 
509
509
  // packages/core/mesh/network-manager/src/swarm/peer.ts
510
- import assert3 from "@dxos/node-std/assert";
510
+ import invariant3 from "tiny-invariant";
511
511
  import { scheduleTask, synchronized as synchronized2 } from "@dxos/async";
512
512
  import { Context as Context3 } from "@dxos/context";
513
513
  import { PublicKey as PublicKey3 } from "@dxos/keys";
@@ -566,7 +566,7 @@ var Peer = class {
566
566
  }
567
567
  if (await this._callbacks.onOffer(remoteId)) {
568
568
  if (!this.connection) {
569
- assert3(message.sessionId);
569
+ invariant3(message.sessionId);
570
570
  const connection = this._createConnection(false, message.sessionId);
571
571
  try {
572
572
  connection.openConnection();
@@ -597,8 +597,8 @@ var Peer = class {
597
597
  * Initiate a connection to the remote peer.
598
598
  */
599
599
  async initiateConnection() {
600
- assert3(!this.initiating, "Initiation in progress.");
601
- assert3(!this.connection, "Already connected.");
600
+ invariant3(!this.initiating, "Initiation in progress.");
601
+ invariant3(!this.connection, "Already connected.");
602
602
  const sessionId = PublicKey3.random();
603
603
  log3("initiating...", {
604
604
  id: this.id,
@@ -685,7 +685,7 @@ var Peer = class {
685
685
  scope: this,
686
686
  callSite: (f, a) => f(...a)
687
687
  });
688
- assert3(!this.connection, "Already connected.");
688
+ invariant3(!this.connection, "Already connected.");
689
689
  const connection = new Connection(
690
690
  this.topic,
691
691
  this.localPeerId,
@@ -725,7 +725,7 @@ var Peer = class {
725
725
  scope: this,
726
726
  callSite: (f, a) => f(...a)
727
727
  });
728
- assert3(this.connection === connection, "Connection mismatch (race condition).");
728
+ invariant3(this.connection === connection, "Connection mismatch (race condition).");
729
729
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
730
730
  this._availableAfter = 0;
731
731
  } else {
@@ -914,7 +914,7 @@ var Swarm = class {
914
914
  return this._topic;
915
915
  }
916
916
  async open() {
917
- assert4(!this._listeningHandle);
917
+ invariant4(!this._listeningHandle);
918
918
  this._listeningHandle = await this._messenger.listen({
919
919
  peerId: this._ownPeerId,
920
920
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -951,7 +951,7 @@ var Swarm = class {
951
951
  });
952
952
  }
953
953
  async setTopology(topology) {
954
- assert4(!this._ctx.disposed, "Swarm is offline");
954
+ invariant4(!this._ctx.disposed, "Swarm is offline");
955
955
  if (topology === this._topology) {
956
956
  return;
957
957
  }
@@ -1039,7 +1039,7 @@ var Swarm = class {
1039
1039
  accept: false
1040
1040
  };
1041
1041
  }
1042
- assert4(message.author);
1042
+ invariant4(message.author);
1043
1043
  if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
1044
1044
  log4("rejecting offer with incorrect peerId", {
1045
1045
  message
@@ -1090,9 +1090,9 @@ var Swarm = class {
1090
1090
  });
1091
1091
  return;
1092
1092
  }
1093
- assert4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1094
- assert4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1095
- assert4(message.author);
1093
+ invariant4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1094
+ invariant4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1095
+ invariant4(message.author);
1096
1096
  const peer = this._getOrCreatePeer(message.author);
1097
1097
  await peer.onSignal(message);
1098
1098
  }
@@ -1144,7 +1144,7 @@ var Swarm = class {
1144
1144
  return peer;
1145
1145
  }
1146
1146
  async _destroyPeer(peerId) {
1147
- assert4(this._peers.has(peerId));
1147
+ invariant4(this._peers.has(peerId));
1148
1148
  await this._peers.get(peerId).destroy();
1149
1149
  this._peers.delete(peerId);
1150
1150
  }
@@ -1367,6 +1367,7 @@ var ConnectionLog = class {
1367
1367
  this._swarms.set(PublicKey6.from(swarm._instanceId), info);
1368
1368
  this.update.emit();
1369
1369
  swarm.connectionAdded.on((connection) => {
1370
+ var _a, _b;
1370
1371
  const connectionInfo = {
1371
1372
  state: ConnectionState.INITIAL,
1372
1373
  remotePeerId: connection.remoteId,
@@ -1385,6 +1386,10 @@ var ConnectionLog = class {
1385
1386
  });
1386
1387
  this.update.emit();
1387
1388
  });
1389
+ (_b = (_a = connection.protocol) == null ? void 0 : _a.stats) == null ? void 0 : _b.on((stats) => {
1390
+ connectionInfo.streams = stats;
1391
+ this.update.emit();
1392
+ });
1388
1393
  });
1389
1394
  }
1390
1395
  leftSwarm(swarm) {
@@ -1394,7 +1399,7 @@ var ConnectionLog = class {
1394
1399
  };
1395
1400
 
1396
1401
  // packages/core/mesh/network-manager/src/network-manager.ts
1397
- import assert5 from "@dxos/node-std/assert";
1402
+ import invariant5 from "tiny-invariant";
1398
1403
  import { Event as Event5 } from "@dxos/async";
1399
1404
  import { PublicKey as PublicKey7 } from "@dxos/keys";
1400
1405
  import { log as log6 } from "@dxos/log";
@@ -1483,10 +1488,10 @@ var NetworkManager = class {
1483
1488
  */
1484
1489
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1485
1490
  var _a;
1486
- assert5(PublicKey7.isPublicKey(topic));
1487
- assert5(PublicKey7.isPublicKey(peerId));
1488
- assert5(topology);
1489
- assert5(typeof protocol === "function");
1491
+ invariant5(PublicKey7.isPublicKey(topic));
1492
+ invariant5(PublicKey7.isPublicKey(peerId));
1493
+ invariant5(topology);
1494
+ invariant5(typeof protocol === "function");
1490
1495
  if (this._swarms.has(topic)) {
1491
1496
  throw new Error(`Already connected to swarm: ${PublicKey7.from(topic)}`);
1492
1497
  }
@@ -1605,17 +1610,17 @@ var NetworkManager = class {
1605
1610
  };
1606
1611
 
1607
1612
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1608
- import assert6 from "@dxos/node-std/assert";
1613
+ import invariant6 from "tiny-invariant";
1609
1614
  var FullyConnectedTopology = class {
1610
1615
  toString() {
1611
1616
  return "FullyConnectedTopology";
1612
1617
  }
1613
1618
  init(controller) {
1614
- assert6(!this._controller, "Already initialized");
1619
+ invariant6(!this._controller, "Already initialized");
1615
1620
  this._controller = controller;
1616
1621
  }
1617
1622
  update() {
1618
- assert6(this._controller, "Not initialized");
1623
+ invariant6(this._controller, "Not initialized");
1619
1624
  const { candidates: discovered } = this._controller.getState();
1620
1625
  for (const peer of discovered) {
1621
1626
  this._controller.connect(peer);
@@ -1629,7 +1634,7 @@ var FullyConnectedTopology = class {
1629
1634
  };
1630
1635
 
1631
1636
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1632
- import assert7 from "@dxos/node-std/assert";
1637
+ import invariant7 from "tiny-invariant";
1633
1638
  import distance from "xor-distance";
1634
1639
  import { log as log7 } from "@dxos/log";
1635
1640
  var MMSTTopology = class {
@@ -1640,11 +1645,11 @@ var MMSTTopology = class {
1640
1645
  this._sampleSize = sampleSize;
1641
1646
  }
1642
1647
  init(controller) {
1643
- assert7(!this._controller, "Already initialized");
1648
+ invariant7(!this._controller, "Already initialized");
1644
1649
  this._controller = controller;
1645
1650
  }
1646
1651
  update() {
1647
- assert7(this._controller, "Not initialized");
1652
+ invariant7(this._controller, "Not initialized");
1648
1653
  const { connected, candidates } = this._controller.getState();
1649
1654
  if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
1650
1655
  log7("Running the algorithm.", {}, {
@@ -1658,7 +1663,7 @@ var MMSTTopology = class {
1658
1663
  }
1659
1664
  }
1660
1665
  async onOffer(peer) {
1661
- assert7(this._controller, "Not initialized");
1666
+ invariant7(this._controller, "Not initialized");
1662
1667
  const { connected } = this._controller.getState();
1663
1668
  const accept = connected.length < this._maxPeers;
1664
1669
  log7(`Offer ${peer} accept=${accept}`, {}, {
@@ -1672,7 +1677,7 @@ var MMSTTopology = class {
1672
1677
  async destroy() {
1673
1678
  }
1674
1679
  _runAlgorithm() {
1675
- assert7(this._controller, "Not initialized");
1680
+ invariant7(this._controller, "Not initialized");
1676
1681
  const { connected, candidates, ownPeerId } = this._controller.getState();
1677
1682
  if (connected.length > this._maxPeers) {
1678
1683
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
@@ -1706,7 +1711,7 @@ var MMSTTopology = class {
1706
1711
  var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
1707
1712
 
1708
1713
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1709
- import assert8 from "@dxos/node-std/assert";
1714
+ import invariant8 from "tiny-invariant";
1710
1715
  import { log as log8 } from "@dxos/log";
1711
1716
  var StarTopology = class {
1712
1717
  // prettier-ignore
@@ -1717,11 +1722,11 @@ var StarTopology = class {
1717
1722
  return `StarTopology(${this._centralPeer.truncate()})`;
1718
1723
  }
1719
1724
  init(controller) {
1720
- assert8(!this._controller, "Already initialized.");
1725
+ invariant8(!this._controller, "Already initialized.");
1721
1726
  this._controller = controller;
1722
1727
  }
1723
1728
  update() {
1724
- assert8(this._controller, "Not initialized.");
1729
+ invariant8(this._controller, "Not initialized.");
1725
1730
  const { candidates, connected, ownPeerId } = this._controller.getState();
1726
1731
  if (!ownPeerId.equals(this._centralPeer)) {
1727
1732
  log8("leaf peer dropping all connections apart from central peer.", {}, {
@@ -1759,7 +1764,7 @@ var StarTopology = class {
1759
1764
  }
1760
1765
  }
1761
1766
  async onOffer(peer) {
1762
- assert8(this._controller, "Not initialized.");
1767
+ invariant8(this._controller, "Not initialized.");
1763
1768
  const { ownPeerId } = this._controller.getState();
1764
1769
  log8("offer", {
1765
1770
  peer,
@@ -1778,8 +1783,8 @@ var StarTopology = class {
1778
1783
  };
1779
1784
 
1780
1785
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1781
- import assert9 from "@dxos/node-std/assert";
1782
1786
  import { Transform } from "@dxos/node-std/stream";
1787
+ import invariant9 from "tiny-invariant";
1783
1788
  import { Event as Event6, Trigger } from "@dxos/async";
1784
1789
  import { ErrorStream as ErrorStream3 } from "@dxos/debug";
1785
1790
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -1825,7 +1830,7 @@ var _MemoryTransport = class {
1825
1830
  scope: this,
1826
1831
  callSite: (f, a) => f(...a)
1827
1832
  });
1828
- assert9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1833
+ invariant9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1829
1834
  _MemoryTransport._connections.set(this._instanceId, this);
1830
1835
  if (this.options.initiator) {
1831
1836
  setTimeout(async () => {
@@ -1859,12 +1864,12 @@ var _MemoryTransport = class {
1859
1864
  this.closed.emit();
1860
1865
  return;
1861
1866
  }
1862
- assert9(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1867
+ invariant9(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
1863
1868
  this._remoteConnection._remoteConnection = this;
1864
1869
  this._remoteConnection._remoteInstanceId = this._instanceId;
1865
1870
  log9("connected", {}, {
1866
1871
  file: "memory-transport.ts",
1867
- line: 106,
1872
+ line: 103,
1868
1873
  scope: this,
1869
1874
  callSite: (f, a) => f(...a)
1870
1875
  });
@@ -1882,7 +1887,7 @@ var _MemoryTransport = class {
1882
1887
  async destroy() {
1883
1888
  log9("closing", {}, {
1884
1889
  file: "memory-transport.ts",
1885
- line: 127,
1890
+ line: 124,
1886
1891
  scope: this,
1887
1892
  callSite: (f, a) => f(...a)
1888
1893
  });
@@ -1891,7 +1896,7 @@ var _MemoryTransport = class {
1891
1896
  if (this._remoteConnection) {
1892
1897
  log9("closing", {}, {
1893
1898
  file: "memory-transport.ts",
1894
- line: 132,
1899
+ line: 129,
1895
1900
  scope: this,
1896
1901
  callSite: (f, a) => f(...a)
1897
1902
  });
@@ -1904,7 +1909,7 @@ var _MemoryTransport = class {
1904
1909
  this._remoteConnection = void 0;
1905
1910
  log9("closed", {}, {
1906
1911
  file: "memory-transport.ts",
1907
- line: 150,
1912
+ line: 147,
1908
1913
  scope: this,
1909
1914
  callSite: (f, a) => f(...a)
1910
1915
  });
@@ -1912,7 +1917,7 @@ var _MemoryTransport = class {
1912
1917
  this.closed.emit();
1913
1918
  log9("closed", {}, {
1914
1919
  file: "memory-transport.ts",
1915
- line: 154,
1920
+ line: 151,
1916
1921
  scope: this,
1917
1922
  callSite: (f, a) => f(...a)
1918
1923
  });
@@ -1922,7 +1927,7 @@ var _MemoryTransport = class {
1922
1927
  payload
1923
1928
  }, {
1924
1929
  file: "memory-transport.ts",
1925
- line: 158,
1930
+ line: 155,
1926
1931
  scope: this,
1927
1932
  callSite: (f, a) => f(...a)
1928
1933
  });
@@ -1947,8 +1952,8 @@ __decorate4([
1947
1952
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
1948
1953
 
1949
1954
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1950
- import assert10 from "@dxos/node-std/assert";
1951
1955
  import SimplePeerConstructor from "simple-peer";
1956
+ import invariant10 from "tiny-invariant";
1952
1957
  import { Event as Event7 } from "@dxos/async";
1953
1958
  import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
1954
1959
  import { PublicKey as PublicKey9 } from "@dxos/keys";
@@ -2076,7 +2081,7 @@ var WebRTCTransport = class {
2076
2081
  if (this._closed) {
2077
2082
  return;
2078
2083
  }
2079
- assert10(signal.payload.data, "Signal message must contain signal data.");
2084
+ invariant10(signal.payload.data, "Signal message must contain signal data.");
2080
2085
  this._peer.signal(signal.payload.data);
2081
2086
  }
2082
2087
  async _disconnectStreams() {
@@ -2092,8 +2097,8 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
2092
2097
  });
2093
2098
 
2094
2099
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
2095
- import assert11 from "@dxos/node-std/assert";
2096
2100
  import { Duplex } from "@dxos/node-std/stream";
2101
+ import invariant11 from "tiny-invariant";
2097
2102
  import { Stream } from "@dxos/codec-protobuf";
2098
2103
  import { PublicKey as PublicKey10 } from "@dxos/keys";
2099
2104
  import { log as log11 } from "@dxos/log";
@@ -2169,11 +2174,11 @@ var WebRTCTransportService = class {
2169
2174
  return rpcStream;
2170
2175
  }
2171
2176
  async sendSignal({ proxyId, signal }) {
2172
- assert11(this.transports.has(proxyId));
2177
+ invariant11(this.transports.has(proxyId));
2173
2178
  await this.transports.get(proxyId).transport.signal(signal);
2174
2179
  }
2175
2180
  async sendData({ proxyId, payload }) {
2176
- assert11(this.transports.has(proxyId));
2181
+ invariant11(this.transports.has(proxyId));
2177
2182
  await this.transports.get(proxyId).stream.push(payload);
2178
2183
  }
2179
2184
  async close({ proxyId }) {
@@ -2191,7 +2196,7 @@ var WebRTCTransportService = class {
2191
2196
  };
2192
2197
 
2193
2198
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2194
- import assert12 from "@dxos/node-std/assert";
2199
+ import invariant12 from "tiny-invariant";
2195
2200
  import { Event as Event8 } from "@dxos/async";
2196
2201
  import { Context as Context5 } from "@dxos/context";
2197
2202
  import { ErrorStream as ErrorStream5 } from "@dxos/debug";
@@ -2330,7 +2335,7 @@ var WebRTCTransportProxyFactory = class {
2330
2335
  return this;
2331
2336
  }
2332
2337
  createTransport(options) {
2333
- assert12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2338
+ invariant12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2334
2339
  const transport = new WebRTCTransportProxy({
2335
2340
  ...options,
2336
2341
  bridgeService: this._bridgeService
@@ -2380,4 +2385,4 @@ export {
2380
2385
  WebRTCTransportProxyFactory,
2381
2386
  createTeleportProtocolFactory
2382
2387
  };
2383
- //# sourceMappingURL=chunk-A3FS4AKZ.mjs.map
2388
+ //# sourceMappingURL=chunk-SA5ALANV.mjs.map