@dxos/network-manager 0.6.14-staging.e15392e → 0.7.1-staging.599df14

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-6O74LX7U.mjs} +136 -79
  2. package/dist/lib/browser/chunk-6O74LX7U.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-UBEMIUZP.cjs} +139 -82
  8. package/dist/lib/node/chunk-UBEMIUZP.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-S267VFUM.mjs} +136 -79
  15. package/dist/lib/node-esm/chunk-S267VFUM.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 +22 -22
  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 +6 -1
  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
  });
@@ -3290,7 +3338,7 @@ var RtcPeerConnection = class {
3290
3338
  }
3291
3339
  log13("waiting for initiator-peer to open a data channel", void 0, {
3292
3340
  F: __dxlog_file14,
3293
- L: 90,
3341
+ L: 95,
3294
3342
  S: this,
3295
3343
  C: (f, a) => f(...a)
3296
3344
  });
@@ -3321,7 +3369,7 @@ var RtcPeerConnection = class {
3321
3369
  remotePeer: this._options.remotePeerKey
3322
3370
  }), {
3323
3371
  F: __dxlog_file14,
3324
- L: 115,
3372
+ L: 120,
3325
3373
  S: this,
3326
3374
  C: (f, a) => f(...a)
3327
3375
  });
@@ -3332,7 +3380,7 @@ var RtcPeerConnection = class {
3332
3380
  onnegotiationneeded: async () => {
3333
3381
  invariant12(this._initiator, void 0, {
3334
3382
  F: __dxlog_file14,
3335
- L: 130,
3383
+ L: 135,
3336
3384
  S: this,
3337
3385
  A: [
3338
3386
  "this._initiator",
@@ -3345,7 +3393,7 @@ var RtcPeerConnection = class {
3345
3393
  }
3346
3394
  log13("onnegotiationneeded", void 0, {
3347
3395
  F: __dxlog_file14,
3348
- L: 137,
3396
+ L: 142,
3349
3397
  S: this,
3350
3398
  C: (f, a) => f(...a)
3351
3399
  });
@@ -3369,7 +3417,7 @@ var RtcPeerConnection = class {
3369
3417
  candidate: event.candidate.candidate
3370
3418
  }, {
3371
3419
  F: __dxlog_file14,
3372
- L: 156,
3420
+ L: 161,
3373
3421
  S: this,
3374
3422
  C: (f, a) => f(...a)
3375
3423
  });
@@ -3377,7 +3425,7 @@ var RtcPeerConnection = class {
3377
3425
  } else {
3378
3426
  log13("onicecandidate gathering complete", void 0, {
3379
3427
  F: __dxlog_file14,
3380
- L: 159,
3428
+ L: 164,
3381
3429
  S: this,
3382
3430
  C: (f, a) => f(...a)
3383
3431
  });
@@ -3405,7 +3453,7 @@ var RtcPeerConnection = class {
3405
3453
  state: connection.iceConnectionState
3406
3454
  }, {
3407
3455
  F: __dxlog_file14,
3408
- L: 179,
3456
+ L: 184,
3409
3457
  S: this,
3410
3458
  C: (f, a) => f(...a)
3411
3459
  });
@@ -3427,7 +3475,7 @@ var RtcPeerConnection = class {
3427
3475
  state: connection.connectionState
3428
3476
  }, {
3429
3477
  F: __dxlog_file14,
3430
- L: 196,
3478
+ L: 201,
3431
3479
  S: this,
3432
3480
  C: (f, a) => f(...a)
3433
3481
  });
@@ -3440,7 +3488,7 @@ var RtcPeerConnection = class {
3440
3488
  state: connection.signalingState
3441
3489
  }, {
3442
3490
  F: __dxlog_file14,
3443
- L: 203,
3491
+ L: 208,
3444
3492
  S: this,
3445
3493
  C: (f, a) => f(...a)
3446
3494
  });
@@ -3450,7 +3498,7 @@ var RtcPeerConnection = class {
3450
3498
  ondatachannel: (event) => {
3451
3499
  invariant12(!this._initiator, "Initiator is expected to create data channels.", {
3452
3500
  F: __dxlog_file14,
3453
- L: 209,
3501
+ L: 214,
3454
3502
  S: this,
3455
3503
  A: [
3456
3504
  "!this._initiator",
@@ -3465,7 +3513,7 @@ var RtcPeerConnection = class {
3465
3513
  label: event.channel.label
3466
3514
  }, {
3467
3515
  F: __dxlog_file14,
3468
- L: 216,
3516
+ L: 221,
3469
3517
  S: this,
3470
3518
  C: (f, a) => f(...a)
3471
3519
  });
@@ -3493,7 +3541,7 @@ var RtcPeerConnection = class {
3493
3541
  error
3494
3542
  }, {
3495
3543
  F: __dxlog_file14,
3496
- L: 241,
3544
+ L: 246,
3497
3545
  S: this,
3498
3546
  C: (f, a) => f(...a)
3499
3547
  });
@@ -3514,7 +3562,7 @@ var RtcPeerConnection = class {
3514
3562
  reason: error.message
3515
3563
  }, {
3516
3564
  F: __dxlog_file14,
3517
- L: 255,
3565
+ L: 260,
3518
3566
  S: this,
3519
3567
  C: (f, a) => f(...a)
3520
3568
  });
@@ -3522,7 +3570,7 @@ var RtcPeerConnection = class {
3522
3570
  _lockAndCloseConnection() {
3523
3571
  invariant12(this._transportChannels.size === 0, void 0, {
3524
3572
  F: __dxlog_file14,
3525
- L: 260,
3573
+ L: 265,
3526
3574
  S: this,
3527
3575
  A: [
3528
3576
  "this._transportChannels.size === 0",
@@ -3533,7 +3581,7 @@ var RtcPeerConnection = class {
3533
3581
  this._safeCloseConnection();
3534
3582
  log13("connection closed", void 0, {
3535
3583
  F: __dxlog_file14,
3536
- L: 263,
3584
+ L: 268,
3537
3585
  S: this,
3538
3586
  C: (f, a) => f(...a)
3539
3587
  });
@@ -3546,7 +3594,7 @@ var RtcPeerConnection = class {
3546
3594
  type: signal.payload.data.type
3547
3595
  }, {
3548
3596
  F: __dxlog_file14,
3549
- L: 271,
3597
+ L: 276,
3550
3598
  S: this,
3551
3599
  C: (f, a) => f(...a)
3552
3600
  });
@@ -3609,9 +3657,11 @@ var RtcPeerConnection = class {
3609
3657
  this._abortConnection(connection, new Error(`Unknown signal type ${data.type}.`));
3610
3658
  break;
3611
3659
  }
3612
- log13("signal processed", void 0, {
3660
+ log13("signal processed", {
3661
+ type: data.type
3662
+ }, {
3613
3663
  F: __dxlog_file14,
3614
- L: 330,
3664
+ L: 335,
3615
3665
  S: this,
3616
3666
  C: (f, a) => f(...a)
3617
3667
  });
@@ -3624,7 +3674,7 @@ var RtcPeerConnection = class {
3624
3674
  candidate
3625
3675
  }, {
3626
3676
  F: __dxlog_file14,
3627
- L: 338,
3677
+ L: 343,
3628
3678
  S: this,
3629
3679
  C: (f, a) => f(...a)
3630
3680
  });
@@ -3633,7 +3683,7 @@ var RtcPeerConnection = class {
3633
3683
  } catch (err) {
3634
3684
  log13.catch(err, void 0, {
3635
3685
  F: __dxlog_file14,
3636
- L: 342,
3686
+ L: 347,
3637
3687
  S: this,
3638
3688
  C: (f, a) => f(...a)
3639
3689
  });
@@ -3643,7 +3693,7 @@ var RtcPeerConnection = class {
3643
3693
  if (connection === this._connection) {
3644
3694
  log13("ready to process ice candidates", void 0, {
3645
3695
  F: __dxlog_file14,
3646
- L: 348,
3696
+ L: 353,
3647
3697
  S: this,
3648
3698
  C: (f, a) => f(...a)
3649
3699
  });
@@ -3651,7 +3701,7 @@ var RtcPeerConnection = class {
3651
3701
  } else {
3652
3702
  log13.warn("session was negotiated after connection became inactive", void 0, {
3653
3703
  F: __dxlog_file14,
3654
- L: 351,
3704
+ L: 356,
3655
3705
  S: this,
3656
3706
  C: (f, a) => f(...a)
3657
3707
  });
@@ -3663,7 +3713,7 @@ var RtcPeerConnection = class {
3663
3713
  state: connection.connectionState
3664
3714
  }, {
3665
3715
  F: __dxlog_file14,
3666
- L: 356,
3716
+ L: 361,
3667
3717
  S: this,
3668
3718
  C: (f, a) => f(...a)
3669
3719
  });
@@ -3676,7 +3726,7 @@ var RtcPeerConnection = class {
3676
3726
  } catch (err) {
3677
3727
  log13.catch(err, void 0, {
3678
3728
  F: __dxlog_file14,
3679
- L: 368,
3729
+ L: 373,
3680
3730
  S: this,
3681
3731
  C: (f, a) => f(...a)
3682
3732
  });
@@ -3687,7 +3737,7 @@ var RtcPeerConnection = class {
3687
3737
  this._readyForCandidates.wake();
3688
3738
  void this._factory.onConnectionDestroyed().catch((err) => log13.catch(err, void 0, {
3689
3739
  F: __dxlog_file14,
3690
- L: 374,
3740
+ L: 379,
3691
3741
  S: this,
3692
3742
  C: (f, a) => f(...a)
3693
3743
  }));
@@ -3712,7 +3762,7 @@ var RtcPeerConnection = class {
3712
3762
  } catch (error) {
3713
3763
  log13.catch(error, void 0, {
3714
3764
  F: __dxlog_file14,
3715
- L: 390,
3765
+ L: 395,
3716
3766
  S: this,
3717
3767
  C: (f, a) => f(...a)
3718
3768
  });
@@ -3739,7 +3789,7 @@ var RtcPeerConnection = class {
3739
3789
  err
3740
3790
  }, {
3741
3791
  F: __dxlog_file14,
3742
- L: 411,
3792
+ L: 416,
3743
3793
  S: this,
3744
3794
  C: (f, a) => f(...a)
3745
3795
  });
@@ -3829,6 +3879,7 @@ var createRtcTransportFactory = (webrtcConfig, iceProvider) => {
3829
3879
  ownPeerKey: options.ownPeerKey,
3830
3880
  remotePeerKey: options.remotePeerKey,
3831
3881
  sendSignal: options.sendSignal,
3882
+ legacyInitiator: options.initiator,
3832
3883
  webrtcConfig,
3833
3884
  iceProvider
3834
3885
  });
@@ -4182,7 +4233,6 @@ var RtcTransportService = class {
4182
4233
  connectorStream: transportStream,
4183
4234
  writeProcessedCallbacks: []
4184
4235
  };
4185
- pushNewState(ConnectionState4.CONNECTING);
4186
4236
  transport.connected.on(() => pushNewState(ConnectionState4.CONNECTED));
4187
4237
  transport.errors.handle(async (err) => {
4188
4238
  pushNewState(ConnectionState4.CLOSED, err);
@@ -4201,13 +4251,20 @@ var RtcTransportService = class {
4201
4251
  close(err);
4202
4252
  });
4203
4253
  ready();
4254
+ log15("stream ready", void 0, {
4255
+ F: __dxlog_file16,
4256
+ L: 115,
4257
+ S: this,
4258
+ C: (f, a) => f(...a)
4259
+ });
4260
+ pushNewState(ConnectionState4.CONNECTING);
4204
4261
  });
4205
4262
  }
4206
4263
  async sendSignal({ proxyId, signal }) {
4207
4264
  const transport = this._openTransports.get(proxyId);
4208
4265
  invariant14(transport, void 0, {
4209
4266
  F: __dxlog_file16,
4210
- L: 121,
4267
+ L: 123,
4211
4268
  S: this,
4212
4269
  A: [
4213
4270
  "transport",
@@ -4220,7 +4277,7 @@ var RtcTransportService = class {
4220
4277
  const transport = this._openTransports.get(proxyId);
4221
4278
  invariant14(transport, void 0, {
4222
4279
  F: __dxlog_file16,
4223
- L: 128,
4280
+ L: 130,
4224
4281
  S: this,
4225
4282
  A: [
4226
4283
  "transport",
@@ -4235,7 +4292,7 @@ var RtcTransportService = class {
4235
4292
  const transport = this._openTransports.get(proxyId);
4236
4293
  invariant14(transport, void 0, {
4237
4294
  F: __dxlog_file16,
4238
- L: 135,
4295
+ L: 137,
4239
4296
  S: this,
4240
4297
  A: [
4241
4298
  "transport",
@@ -4250,7 +4307,7 @@ var RtcTransportService = class {
4250
4307
  const transport = this._openTransports.get(proxyId);
4251
4308
  invariant14(transport, void 0, {
4252
4309
  F: __dxlog_file16,
4253
- L: 142,
4310
+ L: 144,
4254
4311
  S: this,
4255
4312
  A: [
4256
4313
  "transport",
@@ -4284,7 +4341,7 @@ var RtcTransportService = class {
4284
4341
  message: error?.message
4285
4342
  }, {
4286
4343
  F: __dxlog_file16,
4287
- L: 172,
4344
+ L: 174,
4288
4345
  S: this,
4289
4346
  C: (f, a) => f(...a)
4290
4347
  });
@@ -4296,14 +4353,14 @@ var RtcTransportService = class {
4296
4353
  message: error?.message
4297
4354
  }, {
4298
4355
  F: __dxlog_file16,
4299
- L: 177,
4356
+ L: 179,
4300
4357
  S: this,
4301
4358
  C: (f, a) => f(...a)
4302
4359
  });
4303
4360
  }
4304
4361
  log15("closed", void 0, {
4305
4362
  F: __dxlog_file16,
4306
- L: 179,
4363
+ L: 181,
4307
4364
  S: this,
4308
4365
  C: (f, a) => f(...a)
4309
4366
  });
@@ -4370,4 +4427,4 @@ export {
4370
4427
  RtcTransportService,
4371
4428
  createTeleportProtocolFactory
4372
4429
  };
4373
- //# sourceMappingURL=chunk-RUNQZNCV.mjs.map
4430
+ //# sourceMappingURL=chunk-6O74LX7U.mjs.map