@dxos/network-manager 0.6.14-staging.934c9de → 0.6.14-staging.9b873ce

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.
Files changed (45) hide show
  1. package/dist/lib/browser/{chunk-RUNQZNCV.mjs → chunk-MAR4A5JK.mjs} +144 -85
  2. package/dist/lib/browser/chunk-MAR4A5JK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +15 -9
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-D6P7ACEM.cjs → chunk-J5PWZKEH.cjs} +147 -88
  8. package/dist/lib/node/chunk-J5PWZKEH.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +23 -23
  10. package/dist/lib/node/index.cjs.map +1 -1
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/testing/index.cjs +28 -22
  13. package/dist/lib/node/testing/index.cjs.map +3 -3
  14. package/dist/lib/node-esm/{chunk-22DA2US6.mjs → chunk-XHE7MQ7U.mjs} +144 -85
  15. package/dist/lib/node-esm/chunk-XHE7MQ7U.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +1 -1
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +15 -9
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  20. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  21. package/dist/types/src/swarm/swarm.d.ts +1 -0
  22. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  23. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  24. package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
  25. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts +4 -0
  26. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
  27. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
  28. package/dist/types/src/transport/webrtc/rtc-transport-factory.d.ts.map +1 -1
  29. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
  30. package/package.json +18 -18
  31. package/src/swarm/connection.ts +2 -2
  32. package/src/swarm/peer.ts +4 -1
  33. package/src/swarm/swarm.ts +15 -2
  34. package/src/testing/test-builder.ts +1 -0
  35. package/src/testing/test-wire-protocol.ts +6 -4
  36. package/src/tests/basic-test-suite.ts +13 -13
  37. package/src/tests/webrtc-transport.test.ts +1 -1
  38. package/src/transport/webrtc/rtc-peer-connection.ts +21 -7
  39. package/src/transport/webrtc/rtc-transport-channel.ts +7 -1
  40. package/src/transport/webrtc/rtc-transport-factory.ts +1 -0
  41. package/src/transport/webrtc/rtc-transport-service.ts +4 -2
  42. package/src/transport/webrtc/rtc-transport.test.ts +18 -6
  43. package/dist/lib/browser/chunk-RUNQZNCV.mjs.map +0 -7
  44. package/dist/lib/node/chunk-D6P7ACEM.cjs.map +0 -7
  45. package/dist/lib/node-esm/chunk-22DA2US6.mjs.map +0 -7
@@ -197,7 +197,7 @@ var Connection = class {
197
197
  S: this,
198
198
  C: (f, a) => f(...a)
199
199
  });
200
- this.abort().catch((err2) => this.errors.raise(err2));
200
+ this.abort(err).catch((err2) => this.errors.raise(err2));
201
201
  } else if (err instanceof ConnectivityError) {
202
202
  log.info("aborting due to transport ConnectivityError", void 0, {
203
203
  F: __dxlog_file,
@@ -205,7 +205,7 @@ var Connection = class {
205
205
  S: this,
206
206
  C: (f, a) => f(...a)
207
207
  });
208
- this.abort().catch((err2) => this.errors.raise(err2));
208
+ this.abort(err).catch((err2) => this.errors.raise(err2));
209
209
  }
210
210
  if (this._state !== "CLOSED" && this._state !== "CLOSING") {
211
211
  await this.connectedTimeoutContext.dispose();
@@ -1183,21 +1183,22 @@ var Peer = class {
1183
1183
  });
1184
1184
  },
1185
1185
  onClosed: (err) => {
1186
- log4("connection closed", {
1186
+ const logMeta = {
1187
1187
  topic: this.topic,
1188
1188
  peerId: this.localInfo,
1189
1189
  remoteId: this.remoteInfo,
1190
1190
  initiator
1191
- }, {
1191
+ };
1192
+ log4("connection closed", logMeta, {
1192
1193
  F: __dxlog_file4,
1193
- L: 288,
1194
+ L: 289,
1194
1195
  S: this,
1195
1196
  C: (f, a) => f(...a)
1196
1197
  });
1197
1198
  this._connectionLimiter.doneConnecting(sessionId);
1198
1199
  invariant3(this.connection === connection, "Connection mismatch (race condition).", {
1199
1200
  F: __dxlog_file4,
1200
- L: 293,
1201
+ L: 294,
1201
1202
  S: this,
1202
1203
  A: [
1203
1204
  "this.connection === connection",
@@ -1212,7 +1213,7 @@ var Peer = class {
1212
1213
  initiator
1213
1214
  }, {
1214
1215
  F: __dxlog_file4,
1215
- L: 295,
1216
+ L: 296,
1216
1217
  S: this,
1217
1218
  C: (f, a) => f(...a)
1218
1219
  });
@@ -1227,6 +1228,12 @@ var Peer = class {
1227
1228
  }
1228
1229
  this._callbacks.onDisconnected();
1229
1230
  scheduleTask2(this._connectionCtx, () => {
1231
+ log4("peer became available", logMeta, {
1232
+ F: __dxlog_file4,
1233
+ L: 320,
1234
+ S: this,
1235
+ C: (f, a) => f(...a)
1236
+ });
1230
1237
  this.availableToConnect = true;
1231
1238
  this._callbacks.onPeerAvailable();
1232
1239
  }, this._availableAfter);
@@ -1247,7 +1254,7 @@ var Peer = class {
1247
1254
  err
1248
1255
  }, {
1249
1256
  F: __dxlog_file4,
1250
- L: 335,
1257
+ L: 338,
1251
1258
  S: this,
1252
1259
  C: (f, a) => f(...a)
1253
1260
  });
@@ -1260,7 +1267,7 @@ var Peer = class {
1260
1267
  err
1261
1268
  }, {
1262
1269
  F: __dxlog_file4,
1263
- L: 342,
1270
+ L: 345,
1264
1271
  S: this,
1265
1272
  C: (f, a) => f(...a)
1266
1273
  });
@@ -1279,7 +1286,7 @@ var Peer = class {
1279
1286
  sessionId: connection.sessionId
1280
1287
  }, {
1281
1288
  F: __dxlog_file4,
1282
- L: 367,
1289
+ L: 370,
1283
1290
  S: this,
1284
1291
  C: (f, a) => f(...a)
1285
1292
  });
@@ -1289,7 +1296,7 @@ var Peer = class {
1289
1296
  sessionId: connection.sessionId
1290
1297
  }, {
1291
1298
  F: __dxlog_file4,
1292
- L: 373,
1299
+ L: 376,
1293
1300
  S: this,
1294
1301
  C: (f, a) => f(...a)
1295
1302
  });
@@ -1300,7 +1307,7 @@ var Peer = class {
1300
1307
  message
1301
1308
  }, {
1302
1309
  F: __dxlog_file4,
1303
- L: 378,
1310
+ L: 381,
1304
1311
  S: this,
1305
1312
  C: (f, a) => f(...a)
1306
1313
  });
@@ -1315,7 +1322,7 @@ var Peer = class {
1315
1322
  topic: this.topic
1316
1323
  }, {
1317
1324
  F: __dxlog_file4,
1318
- L: 388,
1325
+ L: 391,
1319
1326
  S: this,
1320
1327
  C: (f, a) => f(...a)
1321
1328
  });
@@ -1533,10 +1540,16 @@ var Swarm = class {
1533
1540
  const peer = this._peers.get(swarmEvent.peerLeft.peer);
1534
1541
  if (peer) {
1535
1542
  peer.advertizing = false;
1536
- if (peer.connection?.state !== ConnectionState.CONNECTED) {
1543
+ if (this._isConnectionEstablishmentInProgress(peer)) {
1544
+ log5(`destroying peer, state: ${peer.connection?.state}`, void 0, {
1545
+ F: __dxlog_file5,
1546
+ L: 195,
1547
+ S: this,
1548
+ C: (f, a) => f(...a)
1549
+ });
1537
1550
  void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log5.catch(err, void 0, {
1538
1551
  F: __dxlog_file5,
1539
- L: 194,
1552
+ L: 196,
1540
1553
  S: this,
1541
1554
  C: (f, a) => f(...a)
1542
1555
  }));
@@ -1546,7 +1559,7 @@ var Swarm = class {
1546
1559
  peer: swarmEvent.peerLeft.peer.peerKey
1547
1560
  }, {
1548
1561
  F: __dxlog_file5,
1549
- L: 197,
1562
+ L: 199,
1550
1563
  S: this,
1551
1564
  C: (f, a) => f(...a)
1552
1565
  });
@@ -1559,14 +1572,14 @@ var Swarm = class {
1559
1572
  message
1560
1573
  }, {
1561
1574
  F: __dxlog_file5,
1562
- L: 206,
1575
+ L: 208,
1563
1576
  S: this,
1564
1577
  C: (f, a) => f(...a)
1565
1578
  });
1566
1579
  if (this._ctx.disposed) {
1567
1580
  log5("ignored for disposed swarm", void 0, {
1568
1581
  F: __dxlog_file5,
1569
- L: 208,
1582
+ L: 210,
1570
1583
  S: this,
1571
1584
  C: (f, a) => f(...a)
1572
1585
  });
@@ -1576,7 +1589,7 @@ var Swarm = class {
1576
1589
  }
1577
1590
  invariant4(message.author, void 0, {
1578
1591
  F: __dxlog_file5,
1579
- L: 213,
1592
+ L: 215,
1580
1593
  S: this,
1581
1594
  A: [
1582
1595
  "message.author",
@@ -1588,7 +1601,7 @@ var Swarm = class {
1588
1601
  message
1589
1602
  }, {
1590
1603
  F: __dxlog_file5,
1591
- L: 215,
1604
+ L: 217,
1592
1605
  S: this,
1593
1606
  C: (f, a) => f(...a)
1594
1607
  });
@@ -1601,7 +1614,7 @@ var Swarm = class {
1601
1614
  message
1602
1615
  }, {
1603
1616
  F: __dxlog_file5,
1604
- L: 219,
1617
+ L: 221,
1605
1618
  S: this,
1606
1619
  C: (f, a) => f(...a)
1607
1620
  });
@@ -1619,14 +1632,14 @@ var Swarm = class {
1619
1632
  message
1620
1633
  }, {
1621
1634
  F: __dxlog_file5,
1622
- L: 230,
1635
+ L: 232,
1623
1636
  S: this,
1624
1637
  C: (f, a) => f(...a)
1625
1638
  });
1626
1639
  if (this._ctx.disposed) {
1627
1640
  log5.info("ignored for offline swarm", void 0, {
1628
1641
  F: __dxlog_file5,
1629
- L: 232,
1642
+ L: 234,
1630
1643
  S: this,
1631
1644
  C: (f, a) => f(...a)
1632
1645
  });
@@ -1634,7 +1647,7 @@ var Swarm = class {
1634
1647
  }
1635
1648
  invariant4(message.recipient.peerKey === this._ownPeer.peerKey, `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1636
1649
  F: __dxlog_file5,
1637
- L: 235,
1650
+ L: 237,
1638
1651
  S: this,
1639
1652
  A: [
1640
1653
  "message.recipient.peerKey === this._ownPeer.peerKey",
@@ -1643,7 +1656,7 @@ var Swarm = class {
1643
1656
  });
1644
1657
  invariant4(message.topic?.equals(this._topic), void 0, {
1645
1658
  F: __dxlog_file5,
1646
- L: 239,
1659
+ L: 241,
1647
1660
  S: this,
1648
1661
  A: [
1649
1662
  "message.topic?.equals(this._topic)",
@@ -1652,7 +1665,7 @@ var Swarm = class {
1652
1665
  });
1653
1666
  invariant4(message.author, void 0, {
1654
1667
  F: __dxlog_file5,
1655
- L: 240,
1668
+ L: 242,
1656
1669
  S: this,
1657
1670
  A: [
1658
1671
  "message.author",
@@ -1673,13 +1686,13 @@ var Swarm = class {
1673
1686
  async goOnline() {
1674
1687
  this._ctx = new Context4(void 0, {
1675
1688
  F: __dxlog_file5,
1676
- L: 256
1689
+ L: 258
1677
1690
  });
1678
1691
  }
1679
1692
  _getOrCreatePeer(peerInfo) {
1680
1693
  invariant4(peerInfo.peerKey, "PeerInfo.peerKey is required", {
1681
1694
  F: __dxlog_file5,
1682
- L: 260,
1695
+ L: 262,
1683
1696
  S: this,
1684
1697
  A: [
1685
1698
  "peerInfo.peerKey",
@@ -1697,6 +1710,12 @@ var Swarm = class {
1697
1710
  },
1698
1711
  onDisconnected: async () => {
1699
1712
  if (this._isUnregistered(peer)) {
1713
+ log5.verbose("ignored onDisconnected for unregistered peer", void 0, {
1714
+ F: __dxlog_file5,
1715
+ L: 282,
1716
+ S: this,
1717
+ C: (f, a) => f(...a)
1718
+ });
1700
1719
  return;
1701
1720
  }
1702
1721
  if (!peer.advertizing) {
@@ -1711,7 +1730,7 @@ var Swarm = class {
1711
1730
  peerInfo
1712
1731
  }, {
1713
1732
  F: __dxlog_file5,
1714
- L: 293,
1733
+ L: 296,
1715
1734
  S: this,
1716
1735
  C: (f, a) => f(...a)
1717
1736
  });
@@ -1733,10 +1752,19 @@ var Swarm = class {
1733
1752
  return peer;
1734
1753
  }
1735
1754
  async _destroyPeer(peerInfo, reason) {
1755
+ log5("destroy peer", {
1756
+ peerKey: peerInfo.peerKey,
1757
+ reason
1758
+ }, {
1759
+ F: __dxlog_file5,
1760
+ L: 318,
1761
+ S: this,
1762
+ C: (f, a) => f(...a)
1763
+ });
1736
1764
  const peer = this._peers.get(peerInfo);
1737
1765
  invariant4(peer, void 0, {
1738
1766
  F: __dxlog_file5,
1739
- L: 316,
1767
+ L: 320,
1740
1768
  S: this,
1741
1769
  A: [
1742
1770
  "peer",
@@ -1766,7 +1794,7 @@ var Swarm = class {
1766
1794
  } catch (err) {
1767
1795
  log5("initiation error", err, {
1768
1796
  F: __dxlog_file5,
1769
- L: 343,
1797
+ L: 347,
1770
1798
  S: this,
1771
1799
  C: (f, a) => f(...a)
1772
1800
  });
@@ -1797,7 +1825,7 @@ var Swarm = class {
1797
1825
  remotePeer
1798
1826
  }, {
1799
1827
  F: __dxlog_file5,
1800
- L: 371,
1828
+ L: 375,
1801
1829
  S: this,
1802
1830
  C: (f, a) => f(...a)
1803
1831
  });
@@ -1816,7 +1844,7 @@ var Swarm = class {
1816
1844
  remotePeer
1817
1845
  }, {
1818
1846
  F: __dxlog_file5,
1819
- L: 387,
1847
+ L: 391,
1820
1848
  S: this,
1821
1849
  C: (f, a) => f(...a)
1822
1850
  });
@@ -1826,7 +1854,7 @@ var Swarm = class {
1826
1854
  remotePeer
1827
1855
  }, {
1828
1856
  F: __dxlog_file5,
1829
- L: 390,
1857
+ L: 394,
1830
1858
  S: this,
1831
1859
  C: (f, a) => f(...a)
1832
1860
  });
@@ -1838,6 +1866,16 @@ var Swarm = class {
1838
1866
  }
1839
1867
  await peer.closeConnection();
1840
1868
  }
1869
+ _isConnectionEstablishmentInProgress(peer) {
1870
+ if (!peer.connection) {
1871
+ return true;
1872
+ }
1873
+ return [
1874
+ ConnectionState.INITIAL,
1875
+ ConnectionState.CREATED,
1876
+ ConnectionState.CONNECTING
1877
+ ].includes(peer.connection.state);
1878
+ }
1841
1879
  _isUnregistered(peer) {
1842
1880
  return !peer || this._peers.get(peer.remoteInfo) !== peer;
1843
1881
  }
@@ -3070,7 +3108,17 @@ var RtcTransportChannel = class extends Resource {
3070
3108
  }
3071
3109
  }).catch((err) => {
3072
3110
  if (this.isOpen) {
3073
- this.errors.raise(new ConnectivityError2(`Failed to create a channel: ${err?.message ?? "unknown reason."}`));
3111
+ const error = err instanceof Error ? err : new ConnectivityError2(`Failed to create a channel: ${JSON.stringify(err?.message)}`);
3112
+ this.errors.raise(error);
3113
+ } else {
3114
+ log12.verbose("connection establishment failed after transport was closed", {
3115
+ err
3116
+ }, {
3117
+ F: __dxlog_file13,
3118
+ L: 76,
3119
+ S: this,
3120
+ C: (f, a) => f(...a)
3121
+ });
3074
3122
  }
3075
3123
  }).finally(() => {
3076
3124
  this._isChannelCreationInProgress = false;
@@ -3085,7 +3133,7 @@ var RtcTransportChannel = class extends Resource {
3085
3133
  this.closed.emit();
3086
3134
  log12("closed", void 0, {
3087
3135
  F: __dxlog_file13,
3088
- L: 86,
3136
+ L: 92,
3089
3137
  S: this,
3090
3138
  C: (f, a) => f(...a)
3091
3139
  });
@@ -3098,7 +3146,7 @@ var RtcTransportChannel = class extends Resource {
3098
3146
  topic: this._options.topic
3099
3147
  }, {
3100
3148
  F: __dxlog_file13,
3101
- L: 93,
3149
+ L: 99,
3102
3150
  S: this,
3103
3151
  C: (f, a) => f(...a)
3104
3152
  });
@@ -3107,7 +3155,7 @@ var RtcTransportChannel = class extends Resource {
3107
3155
  }
3108
3156
  log12("onopen", void 0, {
3109
3157
  F: __dxlog_file13,
3110
- L: 98,
3158
+ L: 104,
3111
3159
  S: this,
3112
3160
  C: (f, a) => f(...a)
3113
3161
  });
@@ -3125,7 +3173,7 @@ var RtcTransportChannel = class extends Resource {
3125
3173
  onclose: async () => {
3126
3174
  log12("onclose", void 0, {
3127
3175
  F: __dxlog_file13,
3128
- L: 111,
3176
+ L: 117,
3129
3177
  S: this,
3130
3178
  C: (f, a) => f(...a)
3131
3179
  });
@@ -3135,7 +3183,7 @@ var RtcTransportChannel = class extends Resource {
3135
3183
  if (!this._stream) {
3136
3184
  log12.warn("ignoring message on a closed channel", void 0, {
3137
3185
  F: __dxlog_file13,
3138
- L: 117,
3186
+ L: 123,
3139
3187
  S: this,
3140
3188
  C: (f, a) => f(...a)
3141
3189
  });
@@ -3164,7 +3212,7 @@ var RtcTransportChannel = class extends Resource {
3164
3212
  if (!this._channel) {
3165
3213
  log12.warn("writing to a channel after a connection was closed", void 0, {
3166
3214
  F: __dxlog_file13,
3167
- L: 145,
3215
+ L: 151,
3168
3216
  S: this,
3169
3217
  C: (f, a) => f(...a)
3170
3218
  });
@@ -3187,7 +3235,7 @@ var RtcTransportChannel = class extends Resource {
3187
3235
  if (this._streamDataFlushedCallback !== null) {
3188
3236
  log12.error("consumer trying to write before we are ready for more data", void 0, {
3189
3237
  F: __dxlog_file13,
3190
- L: 166,
3238
+ L: 172,
3191
3239
  S: this,
3192
3240
  C: (f, a) => f(...a)
3193
3241
  });
@@ -3203,7 +3251,7 @@ var RtcTransportChannel = class extends Resource {
3203
3251
  } catch (error) {
3204
3252
  log12.catch(error, void 0, {
3205
3253
  F: __dxlog_file13,
3206
- L: 178,
3254
+ L: 184,
3207
3255
  S: this,
3208
3256
  C: (f, a) => f(...a)
3209
3257
  });
@@ -3254,6 +3302,7 @@ function _ts_decorate6(decorators, target, key, desc) {
3254
3302
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3255
3303
  }
3256
3304
  var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3305
+ var isLegacyInteropEnabled = () => Boolean(globalThis?.DEVICE_INVITE_INTEROP);
3257
3306
  var RtcPeerConnection = class {
3258
3307
  constructor(_factory, _options) {
3259
3308
  this._factory = _factory;
@@ -3263,7 +3312,7 @@ var RtcPeerConnection = class {
3263
3312
  this._dataChannels = /* @__PURE__ */ new Map();
3264
3313
  this._readyForCandidates = new Trigger3();
3265
3314
  this._offerProcessingMutex = new Mutex2();
3266
- this._initiator = chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
3315
+ this._initiator = isLegacyInteropEnabled() ? Boolean(this._options.legacyInitiator) : chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
3267
3316
  }
3268
3317
  get transportChannelCount() {
3269
3318
  return this._transportChannels.size;
@@ -3272,30 +3321,31 @@ var RtcPeerConnection = class {
3272
3321
  return this._connection;
3273
3322
  }
3274
3323
  async createDataChannel(topic) {
3324
+ const channelKey = isLegacyInteropEnabled() ? "dxos.mesh.transport" : topic;
3275
3325
  const connection = await this._openConnection();
3276
- if (!this._transportChannels.has(topic)) {
3326
+ if (isLegacyInteropEnabled() ? this._transportChannels.size === 0 : !this._transportChannels.has(channelKey)) {
3277
3327
  if (!this._transportChannels.size) {
3278
3328
  this._lockAndCloseConnection();
3279
3329
  }
3280
3330
  throw new Error("Transport closed while connection was being open");
3281
3331
  }
3282
3332
  if (this._initiator) {
3283
- const channel = connection.createDataChannel(topic);
3284
- this._dataChannels.set(topic, channel);
3333
+ const channel = connection.createDataChannel(channelKey);
3334
+ this._dataChannels.set(channelKey, channel);
3285
3335
  return channel;
3286
3336
  } else {
3287
- const existingChannel = this._dataChannels.get(topic);
3337
+ const existingChannel = this._dataChannels.get(channelKey);
3288
3338
  if (existingChannel) {
3289
3339
  return existingChannel;
3290
3340
  }
3291
3341
  log13("waiting for initiator-peer to open a data channel", void 0, {
3292
3342
  F: __dxlog_file14,
3293
- L: 90,
3343
+ L: 104,
3294
3344
  S: this,
3295
3345
  C: (f, a) => f(...a)
3296
3346
  });
3297
3347
  return new Promise((resolve, reject) => {
3298
- this._channelCreatedCallbacks.set(topic, {
3348
+ this._channelCreatedCallbacks.set(channelKey, {
3299
3349
  resolve,
3300
3350
  reject
3301
3351
  });
@@ -3321,7 +3371,7 @@ var RtcPeerConnection = class {
3321
3371
  remotePeer: this._options.remotePeerKey
3322
3372
  }), {
3323
3373
  F: __dxlog_file14,
3324
- L: 115,
3374
+ L: 129,
3325
3375
  S: this,
3326
3376
  C: (f, a) => f(...a)
3327
3377
  });
@@ -3332,7 +3382,7 @@ var RtcPeerConnection = class {
3332
3382
  onnegotiationneeded: async () => {
3333
3383
  invariant12(this._initiator, void 0, {
3334
3384
  F: __dxlog_file14,
3335
- L: 130,
3385
+ L: 144,
3336
3386
  S: this,
3337
3387
  A: [
3338
3388
  "this._initiator",
@@ -3345,7 +3395,7 @@ var RtcPeerConnection = class {
3345
3395
  }
3346
3396
  log13("onnegotiationneeded", void 0, {
3347
3397
  F: __dxlog_file14,
3348
- L: 137,
3398
+ L: 151,
3349
3399
  S: this,
3350
3400
  C: (f, a) => f(...a)
3351
3401
  });
@@ -3369,7 +3419,7 @@ var RtcPeerConnection = class {
3369
3419
  candidate: event.candidate.candidate
3370
3420
  }, {
3371
3421
  F: __dxlog_file14,
3372
- L: 156,
3422
+ L: 170,
3373
3423
  S: this,
3374
3424
  C: (f, a) => f(...a)
3375
3425
  });
@@ -3377,7 +3427,7 @@ var RtcPeerConnection = class {
3377
3427
  } else {
3378
3428
  log13("onicecandidate gathering complete", void 0, {
3379
3429
  F: __dxlog_file14,
3380
- L: 159,
3430
+ L: 173,
3381
3431
  S: this,
3382
3432
  C: (f, a) => f(...a)
3383
3433
  });
@@ -3405,7 +3455,7 @@ var RtcPeerConnection = class {
3405
3455
  state: connection.iceConnectionState
3406
3456
  }, {
3407
3457
  F: __dxlog_file14,
3408
- L: 179,
3458
+ L: 193,
3409
3459
  S: this,
3410
3460
  C: (f, a) => f(...a)
3411
3461
  });
@@ -3427,7 +3477,7 @@ var RtcPeerConnection = class {
3427
3477
  state: connection.connectionState
3428
3478
  }, {
3429
3479
  F: __dxlog_file14,
3430
- L: 196,
3480
+ L: 210,
3431
3481
  S: this,
3432
3482
  C: (f, a) => f(...a)
3433
3483
  });
@@ -3440,7 +3490,7 @@ var RtcPeerConnection = class {
3440
3490
  state: connection.signalingState
3441
3491
  }, {
3442
3492
  F: __dxlog_file14,
3443
- L: 203,
3493
+ L: 217,
3444
3494
  S: this,
3445
3495
  C: (f, a) => f(...a)
3446
3496
  });
@@ -3450,7 +3500,7 @@ var RtcPeerConnection = class {
3450
3500
  ondatachannel: (event) => {
3451
3501
  invariant12(!this._initiator, "Initiator is expected to create data channels.", {
3452
3502
  F: __dxlog_file14,
3453
- L: 209,
3503
+ L: 223,
3454
3504
  S: this,
3455
3505
  A: [
3456
3506
  "!this._initiator",
@@ -3465,7 +3515,7 @@ var RtcPeerConnection = class {
3465
3515
  label: event.channel.label
3466
3516
  }, {
3467
3517
  F: __dxlog_file14,
3468
- L: 216,
3518
+ L: 230,
3469
3519
  S: this,
3470
3520
  C: (f, a) => f(...a)
3471
3521
  });
@@ -3493,7 +3543,7 @@ var RtcPeerConnection = class {
3493
3543
  error
3494
3544
  }, {
3495
3545
  F: __dxlog_file14,
3496
- L: 241,
3546
+ L: 255,
3497
3547
  S: this,
3498
3548
  C: (f, a) => f(...a)
3499
3549
  });
@@ -3514,7 +3564,7 @@ var RtcPeerConnection = class {
3514
3564
  reason: error.message
3515
3565
  }, {
3516
3566
  F: __dxlog_file14,
3517
- L: 255,
3567
+ L: 269,
3518
3568
  S: this,
3519
3569
  C: (f, a) => f(...a)
3520
3570
  });
@@ -3522,7 +3572,7 @@ var RtcPeerConnection = class {
3522
3572
  _lockAndCloseConnection() {
3523
3573
  invariant12(this._transportChannels.size === 0, void 0, {
3524
3574
  F: __dxlog_file14,
3525
- L: 260,
3575
+ L: 274,
3526
3576
  S: this,
3527
3577
  A: [
3528
3578
  "this._transportChannels.size === 0",
@@ -3533,7 +3583,7 @@ var RtcPeerConnection = class {
3533
3583
  this._safeCloseConnection();
3534
3584
  log13("connection closed", void 0, {
3535
3585
  F: __dxlog_file14,
3536
- L: 263,
3586
+ L: 277,
3537
3587
  S: this,
3538
3588
  C: (f, a) => f(...a)
3539
3589
  });
@@ -3546,7 +3596,7 @@ var RtcPeerConnection = class {
3546
3596
  type: signal.payload.data.type
3547
3597
  }, {
3548
3598
  F: __dxlog_file14,
3549
- L: 271,
3599
+ L: 285,
3550
3600
  S: this,
3551
3601
  C: (f, a) => f(...a)
3552
3602
  });
@@ -3609,9 +3659,11 @@ var RtcPeerConnection = class {
3609
3659
  this._abortConnection(connection, new Error(`Unknown signal type ${data.type}.`));
3610
3660
  break;
3611
3661
  }
3612
- log13("signal processed", void 0, {
3662
+ log13("signal processed", {
3663
+ type: data.type
3664
+ }, {
3613
3665
  F: __dxlog_file14,
3614
- L: 330,
3666
+ L: 344,
3615
3667
  S: this,
3616
3668
  C: (f, a) => f(...a)
3617
3669
  });
@@ -3624,7 +3676,7 @@ var RtcPeerConnection = class {
3624
3676
  candidate
3625
3677
  }, {
3626
3678
  F: __dxlog_file14,
3627
- L: 338,
3679
+ L: 352,
3628
3680
  S: this,
3629
3681
  C: (f, a) => f(...a)
3630
3682
  });
@@ -3633,7 +3685,7 @@ var RtcPeerConnection = class {
3633
3685
  } catch (err) {
3634
3686
  log13.catch(err, void 0, {
3635
3687
  F: __dxlog_file14,
3636
- L: 342,
3688
+ L: 356,
3637
3689
  S: this,
3638
3690
  C: (f, a) => f(...a)
3639
3691
  });
@@ -3643,7 +3695,7 @@ var RtcPeerConnection = class {
3643
3695
  if (connection === this._connection) {
3644
3696
  log13("ready to process ice candidates", void 0, {
3645
3697
  F: __dxlog_file14,
3646
- L: 348,
3698
+ L: 362,
3647
3699
  S: this,
3648
3700
  C: (f, a) => f(...a)
3649
3701
  });
@@ -3651,7 +3703,7 @@ var RtcPeerConnection = class {
3651
3703
  } else {
3652
3704
  log13.warn("session was negotiated after connection became inactive", void 0, {
3653
3705
  F: __dxlog_file14,
3654
- L: 351,
3706
+ L: 365,
3655
3707
  S: this,
3656
3708
  C: (f, a) => f(...a)
3657
3709
  });
@@ -3663,7 +3715,7 @@ var RtcPeerConnection = class {
3663
3715
  state: connection.connectionState
3664
3716
  }, {
3665
3717
  F: __dxlog_file14,
3666
- L: 356,
3718
+ L: 370,
3667
3719
  S: this,
3668
3720
  C: (f, a) => f(...a)
3669
3721
  });
@@ -3676,7 +3728,7 @@ var RtcPeerConnection = class {
3676
3728
  } catch (err) {
3677
3729
  log13.catch(err, void 0, {
3678
3730
  F: __dxlog_file14,
3679
- L: 368,
3731
+ L: 382,
3680
3732
  S: this,
3681
3733
  C: (f, a) => f(...a)
3682
3734
  });
@@ -3687,7 +3739,7 @@ var RtcPeerConnection = class {
3687
3739
  this._readyForCandidates.wake();
3688
3740
  void this._factory.onConnectionDestroyed().catch((err) => log13.catch(err, void 0, {
3689
3741
  F: __dxlog_file14,
3690
- L: 374,
3742
+ L: 388,
3691
3743
  S: this,
3692
3744
  C: (f, a) => f(...a)
3693
3745
  }));
@@ -3712,7 +3764,7 @@ var RtcPeerConnection = class {
3712
3764
  } catch (error) {
3713
3765
  log13.catch(error, void 0, {
3714
3766
  F: __dxlog_file14,
3715
- L: 390,
3767
+ L: 404,
3716
3768
  S: this,
3717
3769
  C: (f, a) => f(...a)
3718
3770
  });
@@ -3739,7 +3791,7 @@ var RtcPeerConnection = class {
3739
3791
  err
3740
3792
  }, {
3741
3793
  F: __dxlog_file14,
3742
- L: 411,
3794
+ L: 425,
3743
3795
  S: this,
3744
3796
  C: (f, a) => f(...a)
3745
3797
  });
@@ -3829,6 +3881,7 @@ var createRtcTransportFactory = (webrtcConfig, iceProvider) => {
3829
3881
  ownPeerKey: options.ownPeerKey,
3830
3882
  remotePeerKey: options.remotePeerKey,
3831
3883
  sendSignal: options.sendSignal,
3884
+ legacyInitiator: options.initiator,
3832
3885
  webrtcConfig,
3833
3886
  iceProvider
3834
3887
  });
@@ -4182,7 +4235,6 @@ var RtcTransportService = class {
4182
4235
  connectorStream: transportStream,
4183
4236
  writeProcessedCallbacks: []
4184
4237
  };
4185
- pushNewState(ConnectionState4.CONNECTING);
4186
4238
  transport.connected.on(() => pushNewState(ConnectionState4.CONNECTED));
4187
4239
  transport.errors.handle(async (err) => {
4188
4240
  pushNewState(ConnectionState4.CLOSED, err);
@@ -4201,13 +4253,20 @@ var RtcTransportService = class {
4201
4253
  close(err);
4202
4254
  });
4203
4255
  ready();
4256
+ log15("stream ready", void 0, {
4257
+ F: __dxlog_file16,
4258
+ L: 115,
4259
+ S: this,
4260
+ C: (f, a) => f(...a)
4261
+ });
4262
+ pushNewState(ConnectionState4.CONNECTING);
4204
4263
  });
4205
4264
  }
4206
4265
  async sendSignal({ proxyId, signal }) {
4207
4266
  const transport = this._openTransports.get(proxyId);
4208
4267
  invariant14(transport, void 0, {
4209
4268
  F: __dxlog_file16,
4210
- L: 121,
4269
+ L: 123,
4211
4270
  S: this,
4212
4271
  A: [
4213
4272
  "transport",
@@ -4220,7 +4279,7 @@ var RtcTransportService = class {
4220
4279
  const transport = this._openTransports.get(proxyId);
4221
4280
  invariant14(transport, void 0, {
4222
4281
  F: __dxlog_file16,
4223
- L: 128,
4282
+ L: 130,
4224
4283
  S: this,
4225
4284
  A: [
4226
4285
  "transport",
@@ -4235,7 +4294,7 @@ var RtcTransportService = class {
4235
4294
  const transport = this._openTransports.get(proxyId);
4236
4295
  invariant14(transport, void 0, {
4237
4296
  F: __dxlog_file16,
4238
- L: 135,
4297
+ L: 137,
4239
4298
  S: this,
4240
4299
  A: [
4241
4300
  "transport",
@@ -4250,7 +4309,7 @@ var RtcTransportService = class {
4250
4309
  const transport = this._openTransports.get(proxyId);
4251
4310
  invariant14(transport, void 0, {
4252
4311
  F: __dxlog_file16,
4253
- L: 142,
4312
+ L: 144,
4254
4313
  S: this,
4255
4314
  A: [
4256
4315
  "transport",
@@ -4284,7 +4343,7 @@ var RtcTransportService = class {
4284
4343
  message: error?.message
4285
4344
  }, {
4286
4345
  F: __dxlog_file16,
4287
- L: 172,
4346
+ L: 174,
4288
4347
  S: this,
4289
4348
  C: (f, a) => f(...a)
4290
4349
  });
@@ -4296,14 +4355,14 @@ var RtcTransportService = class {
4296
4355
  message: error?.message
4297
4356
  }, {
4298
4357
  F: __dxlog_file16,
4299
- L: 177,
4358
+ L: 179,
4300
4359
  S: this,
4301
4360
  C: (f, a) => f(...a)
4302
4361
  });
4303
4362
  }
4304
4363
  log15("closed", void 0, {
4305
4364
  F: __dxlog_file16,
4306
- L: 179,
4365
+ L: 181,
4307
4366
  S: this,
4308
4367
  C: (f, a) => f(...a)
4309
4368
  });
@@ -4370,4 +4429,4 @@ export {
4370
4429
  RtcTransportService,
4371
4430
  createTeleportProtocolFactory
4372
4431
  };
4373
- //# sourceMappingURL=chunk-RUNQZNCV.mjs.map
4432
+ //# sourceMappingURL=chunk-MAR4A5JK.mjs.map