@dxos/network-manager 0.1.58-main.fa022ee → 0.1.58-main.fc3ea9b

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 (47) hide show
  1. package/dist/lib/browser/{chunk-66HPNABI.mjs → chunk-3KLH55NB.mjs} +132 -79
  2. package/dist/lib/browser/chunk-3KLH55NB.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +5 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +19 -148
  6. package/dist/lib/browser/testing/index.mjs.map +4 -4
  7. package/dist/lib/node/index.cjs +562 -397
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +923 -891
  11. package/dist/lib/node/testing/index.cjs.map +4 -4
  12. package/dist/types/src/swarm/connection.d.ts.map +1 -1
  13. package/dist/types/src/swarm/peer.d.ts +2 -2
  14. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  15. package/dist/types/src/swarm/swarm-mapper.d.ts.map +1 -1
  16. package/dist/types/src/swarm/swarm.d.ts +2 -2
  17. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  18. package/dist/types/src/testing/test-builder.d.ts +1 -1
  19. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  20. package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
  21. package/dist/types/src/topology/star-topology.d.ts.map +1 -1
  22. package/dist/types/src/transport/index.d.ts +1 -0
  23. package/dist/types/src/transport/index.d.ts.map +1 -1
  24. package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
  25. package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -1
  26. package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
  27. package/dist/types/src/transport/tcp-transport.browser.d.ts +12 -0
  28. package/dist/types/src/transport/tcp-transport.browser.d.ts.map +1 -0
  29. package/package.json +18 -17
  30. package/src/swarm/connection.test.ts +1 -1
  31. package/src/swarm/connection.ts +4 -3
  32. package/src/swarm/peer.ts +7 -2
  33. package/src/swarm/swarm-mapper.ts +4 -7
  34. package/src/swarm/swarm.test.ts +3 -3
  35. package/src/swarm/swarm.ts +3 -3
  36. package/src/testing/test-builder.ts +1 -1
  37. package/src/tests/basic-test-suite.ts +1 -1
  38. package/src/tests/memory-transport.test.ts +2 -2
  39. package/src/tests/tcp-transport.test.ts +2 -2
  40. package/src/tests/webrtc-transport.test.ts +1 -1
  41. package/src/topology/star-topology.ts +1 -4
  42. package/src/transport/index.ts +1 -0
  43. package/src/transport/simplepeer-transport-proxy.ts +25 -24
  44. package/src/transport/simplepeer-transport-service.ts +9 -5
  45. package/src/transport/simplepeer-transport.ts +5 -0
  46. package/src/transport/tcp-transport.browser.ts +28 -0
  47. package/dist/lib/browser/chunk-66HPNABI.mjs.map +0 -7
@@ -197,7 +197,7 @@ var Connection = class {
197
197
  this.closeReason = err?.message;
198
198
  }
199
199
  if (err instanceof ConnectionResetError) {
200
- log("aborting due to transport ConnectionResetError", void 0, {
200
+ log.warn("aborting due to transport ConnectionResetError", void 0, {
201
201
  F: __dxlog_file,
202
202
  L: 197,
203
203
  S: this,
@@ -205,7 +205,7 @@ var Connection = class {
205
205
  });
206
206
  this.abort().catch((err2) => this.errors.raise(err2));
207
207
  } else if (err instanceof ConnectivityError) {
208
- log("aborting due to transport ConnectivityError", void 0, {
208
+ log.warn("aborting due to transport ConnectivityError", void 0, {
209
209
  F: __dxlog_file,
210
210
  L: 200,
211
211
  S: this,
@@ -213,7 +213,7 @@ var Connection = class {
213
213
  });
214
214
  this.abort().catch((err2) => this.errors.raise(err2));
215
215
  } else if (err instanceof UnknownProtocolError) {
216
- log("unsure what to do for UnknownProtocolError", {
216
+ log.warn("unsure what to do with UnknownProtocolError, will keep on truckin", {
217
217
  err
218
218
  }, {
219
219
  F: __dxlog_file,
@@ -244,14 +244,14 @@ var Connection = class {
244
244
  err
245
245
  }, {
246
246
  F: __dxlog_file,
247
- L: 224,
247
+ L: 225,
248
248
  S: this,
249
249
  C: (f, a) => f(...a)
250
250
  });
251
251
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
252
252
  log(`abort ignored: already ${this._state}`, this.closeReason, {
253
253
  F: __dxlog_file,
254
- L: 226,
254
+ L: 227,
255
255
  S: this,
256
256
  C: (f, a) => f(...a)
257
257
  });
@@ -267,7 +267,7 @@ var Connection = class {
267
267
  proto: this._protocol
268
268
  }, {
269
269
  F: __dxlog_file,
270
- L: 239,
270
+ L: 240,
271
271
  S: this,
272
272
  C: (f, a) => f(...a)
273
273
  });
@@ -275,7 +275,7 @@ var Connection = class {
275
275
  } catch (err2) {
276
276
  log.catch(err2, void 0, {
277
277
  F: __dxlog_file,
278
- L: 242,
278
+ L: 243,
279
279
  S: this,
280
280
  C: (f, a) => f(...a)
281
281
  });
@@ -285,7 +285,7 @@ var Connection = class {
285
285
  } catch (err2) {
286
286
  log.catch(err2, void 0, {
287
287
  F: __dxlog_file,
288
- L: 249,
288
+ L: 250,
289
289
  S: this,
290
290
  C: (f, a) => f(...a)
291
291
  });
@@ -295,7 +295,7 @@ var Connection = class {
295
295
  } catch (err2) {
296
296
  log.catch(err2, void 0, {
297
297
  F: __dxlog_file,
298
- L: 255,
298
+ L: 256,
299
299
  S: this,
300
300
  C: (f, a) => f(...a)
301
301
  });
@@ -316,7 +316,7 @@ var Connection = class {
316
316
  peerId: this.ownId
317
317
  }, {
318
318
  F: __dxlog_file,
319
- L: 277,
319
+ L: 278,
320
320
  S: this,
321
321
  C: (f, a) => f(...a)
322
322
  });
@@ -326,7 +326,7 @@ var Connection = class {
326
326
  } catch (err2) {
327
327
  log.catch(err2, void 0, {
328
328
  F: __dxlog_file,
329
- L: 284,
329
+ L: 285,
330
330
  S: this,
331
331
  C: (f, a) => f(...a)
332
332
  });
@@ -336,7 +336,7 @@ var Connection = class {
336
336
  } catch (err2) {
337
337
  log.catch(err2, void 0, {
338
338
  F: __dxlog_file,
339
- L: 291,
339
+ L: 292,
340
340
  S: this,
341
341
  C: (f, a) => f(...a)
342
342
  });
@@ -346,7 +346,7 @@ var Connection = class {
346
346
  peerId: this.ownId
347
347
  }, {
348
348
  F: __dxlog_file,
349
- L: 295,
349
+ L: 296,
350
350
  S: this,
351
351
  C: (f, a) => f(...a)
352
352
  });
@@ -389,7 +389,7 @@ var Connection = class {
389
389
  err
390
390
  }, {
391
391
  F: __dxlog_file,
392
- L: 332,
392
+ L: 333,
393
393
  S: this,
394
394
  C: (f, a) => f(...a)
395
395
  });
@@ -402,7 +402,7 @@ var Connection = class {
402
402
  async signal(msg) {
403
403
  invariant(msg.sessionId, void 0, {
404
404
  F: __dxlog_file,
405
- L: 341,
405
+ L: 342,
406
406
  S: this,
407
407
  A: [
408
408
  "msg.sessionId",
@@ -412,7 +412,7 @@ var Connection = class {
412
412
  if (!msg.sessionId.equals(this.sessionId)) {
413
413
  log("dropping signal for incorrect session id", void 0, {
414
414
  F: __dxlog_file,
415
- L: 343,
415
+ L: 344,
416
416
  S: this,
417
417
  C: (f, a) => f(...a)
418
418
  });
@@ -420,7 +420,7 @@ var Connection = class {
420
420
  }
421
421
  invariant(msg.data.signal || msg.data.signalBatch, void 0, {
422
422
  F: __dxlog_file,
423
- L: 346,
423
+ L: 347,
424
424
  S: this,
425
425
  A: [
426
426
  "msg.data.signal || msg.data.signalBatch",
@@ -429,7 +429,7 @@ var Connection = class {
429
429
  });
430
430
  invariant(msg.author?.equals(this.remoteId), void 0, {
431
431
  F: __dxlog_file,
432
- L: 347,
432
+ L: 348,
433
433
  S: this,
434
434
  A: [
435
435
  "msg.author?.equals(this.remoteId)",
@@ -438,7 +438,7 @@ var Connection = class {
438
438
  });
439
439
  invariant(msg.recipient?.equals(this.ownId), void 0, {
440
440
  F: __dxlog_file,
441
- L: 348,
441
+ L: 349,
442
442
  S: this,
443
443
  A: [
444
444
  "msg.recipient?.equals(this.ownId)",
@@ -462,7 +462,7 @@ var Connection = class {
462
462
  msg: msg.data
463
463
  }, {
464
464
  F: __dxlog_file,
465
- L: 357,
465
+ L: 358,
466
466
  S: this,
467
467
  C: (f, a) => f(...a)
468
468
  });
@@ -470,7 +470,7 @@ var Connection = class {
470
470
  } else {
471
471
  invariant(this._transport, "Connection not ready to accept signals.", {
472
472
  F: __dxlog_file,
473
- L: 360,
473
+ L: 361,
474
474
  S: this,
475
475
  A: [
476
476
  "this._transport",
@@ -483,7 +483,7 @@ var Connection = class {
483
483
  msg: msg.data
484
484
  }, {
485
485
  F: __dxlog_file,
486
- L: 361,
486
+ L: 362,
487
487
  S: this,
488
488
  C: (f, a) => f(...a)
489
489
  });
@@ -501,13 +501,13 @@ var Connection = class {
501
501
  peerId: this.ownId
502
502
  }, {
503
503
  F: __dxlog_file,
504
- L: 372,
504
+ L: 373,
505
505
  S: this,
506
506
  C: (f, a) => f(...a)
507
507
  });
508
508
  invariant(state !== this._state, "Already in this state.", {
509
509
  F: __dxlog_file,
510
- L: 373,
510
+ L: 374,
511
511
  S: this,
512
512
  A: [
513
513
  "state !== this._state",
@@ -814,6 +814,20 @@ var Peer = class {
814
814
  */
815
815
  async onOffer(message) {
816
816
  const remoteId = message.author;
817
+ if (this.connection && ![
818
+ ConnectionState.CREATED,
819
+ ConnectionState.INITIAL
820
+ ].includes(this.connection.state)) {
821
+ log3.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
822
+ F: __dxlog_file3,
823
+ L: 112,
824
+ S: this,
825
+ C: (f, a) => f(...a)
826
+ });
827
+ return {
828
+ accept: false
829
+ };
830
+ }
817
831
  if (this.connection || this.initiating) {
818
832
  if (remoteId.toHex() < this.localPeerId.toHex()) {
819
833
  log3("close local connection", {
@@ -823,7 +837,7 @@ var Peer = class {
823
837
  sessionId: this.connection?.sessionId
824
838
  }, {
825
839
  F: __dxlog_file3,
826
- L: 117,
840
+ L: 121,
827
841
  S: this,
828
842
  C: (f, a) => f(...a)
829
843
  });
@@ -840,7 +854,7 @@ var Peer = class {
840
854
  if (!this.connection) {
841
855
  invariant3(message.sessionId, void 0, {
842
856
  F: __dxlog_file3,
843
- L: 137,
857
+ L: 141,
844
858
  S: this,
845
859
  A: [
846
860
  "message.sessionId",
@@ -861,7 +875,7 @@ var Peer = class {
861
875
  err
862
876
  }, {
863
877
  F: __dxlog_file3,
864
- L: 147,
878
+ L: 151,
865
879
  S: this,
866
880
  C: (f, a) => f(...a)
867
881
  });
@@ -883,7 +897,7 @@ var Peer = class {
883
897
  async initiateConnection() {
884
898
  invariant3(!this.initiating, "Initiation in progress.", {
885
899
  F: __dxlog_file3,
886
- L: 164,
900
+ L: 168,
887
901
  S: this,
888
902
  A: [
889
903
  "!this.initiating",
@@ -892,7 +906,7 @@ var Peer = class {
892
906
  });
893
907
  invariant3(!this.connection, "Already connected.", {
894
908
  F: __dxlog_file3,
895
- L: 165,
909
+ L: 169,
896
910
  S: this,
897
911
  A: [
898
912
  "!this.connection",
@@ -907,7 +921,7 @@ var Peer = class {
907
921
  sessionId
908
922
  }, {
909
923
  F: __dxlog_file3,
910
- L: 167,
924
+ L: 171,
911
925
  S: this,
912
926
  C: (f, a) => f(...a)
913
927
  });
@@ -932,14 +946,14 @@ var Peer = class {
932
946
  remoteId: this.id
933
947
  }, {
934
948
  F: __dxlog_file3,
935
- L: 183,
949
+ L: 187,
936
950
  S: this,
937
951
  C: (f, a) => f(...a)
938
952
  });
939
953
  if (connection.state !== ConnectionState.INITIAL) {
940
954
  log3("ignoring response", void 0, {
941
955
  F: __dxlog_file3,
942
- L: 185,
956
+ L: 189,
943
957
  S: this,
944
958
  C: (f, a) => f(...a)
945
959
  });
@@ -959,11 +973,17 @@ var Peer = class {
959
973
  remoteId: this.id
960
974
  }, {
961
975
  F: __dxlog_file3,
962
- L: 196,
976
+ L: 200,
963
977
  S: this,
964
978
  C: (f, a) => f(...a)
965
979
  });
966
980
  if (err instanceof TimeoutError) {
981
+ log3.warn("aborting connection due to signalling failure", void 0, {
982
+ F: __dxlog_file3,
983
+ L: 202,
984
+ S: this,
985
+ C: (f, a) => f(...a)
986
+ });
967
987
  await connection.abort(err);
968
988
  }
969
989
  await this.closeConnection(err);
@@ -985,13 +1005,13 @@ var Peer = class {
985
1005
  sessionId
986
1006
  }, {
987
1007
  F: __dxlog_file3,
988
- L: 213,
1008
+ L: 218,
989
1009
  S: this,
990
1010
  C: (f, a) => f(...a)
991
1011
  });
992
1012
  invariant3(!this.connection, "Already connected.", {
993
1013
  F: __dxlog_file3,
994
- L: 220,
1014
+ L: 225,
995
1015
  S: this,
996
1016
  A: [
997
1017
  "!this.connection",
@@ -1027,7 +1047,7 @@ var Peer = class {
1027
1047
  initiator
1028
1048
  }, {
1029
1049
  F: __dxlog_file3,
1030
- L: 239,
1050
+ L: 244,
1031
1051
  S: this,
1032
1052
  C: (f, a) => f(...a)
1033
1053
  });
@@ -1040,14 +1060,14 @@ var Peer = class {
1040
1060
  initiator
1041
1061
  }, {
1042
1062
  F: __dxlog_file3,
1043
- L: 248,
1063
+ L: 253,
1044
1064
  S: this,
1045
1065
  C: (f, a) => f(...a)
1046
1066
  });
1047
1067
  this._connectionLimiter.doneConnecting(sessionId);
1048
1068
  invariant3(this.connection === connection, "Connection mismatch (race condition).", {
1049
1069
  F: __dxlog_file3,
1050
- L: 253,
1070
+ L: 258,
1051
1071
  S: this,
1052
1072
  A: [
1053
1073
  "this.connection === connection",
@@ -1062,7 +1082,7 @@ var Peer = class {
1062
1082
  initiator
1063
1083
  }, {
1064
1084
  F: __dxlog_file3,
1065
- L: 255,
1085
+ L: 260,
1066
1086
  S: this,
1067
1087
  C: (f, a) => f(...a)
1068
1088
  });
@@ -1097,7 +1117,7 @@ var Peer = class {
1097
1117
  err
1098
1118
  }, {
1099
1119
  F: __dxlog_file3,
1100
- L: 295,
1120
+ L: 300,
1101
1121
  S: this,
1102
1122
  C: (f, a) => f(...a)
1103
1123
  });
@@ -1110,7 +1130,7 @@ var Peer = class {
1110
1130
  err
1111
1131
  }, {
1112
1132
  F: __dxlog_file3,
1113
- L: 296,
1133
+ L: 301,
1114
1134
  S: this,
1115
1135
  C: (f, a) => f(...a)
1116
1136
  });
@@ -1129,7 +1149,7 @@ var Peer = class {
1129
1149
  sessionId: connection.sessionId
1130
1150
  }, {
1131
1151
  F: __dxlog_file3,
1132
- L: 321,
1152
+ L: 326,
1133
1153
  S: this,
1134
1154
  C: (f, a) => f(...a)
1135
1155
  });
@@ -1139,7 +1159,7 @@ var Peer = class {
1139
1159
  sessionId: connection.sessionId
1140
1160
  }, {
1141
1161
  F: __dxlog_file3,
1142
- L: 327,
1162
+ L: 332,
1143
1163
  S: this,
1144
1164
  C: (f, a) => f(...a)
1145
1165
  });
@@ -1150,7 +1170,7 @@ var Peer = class {
1150
1170
  message
1151
1171
  }, {
1152
1172
  F: __dxlog_file3,
1153
- L: 332,
1173
+ L: 337,
1154
1174
  S: this,
1155
1175
  C: (f, a) => f(...a)
1156
1176
  });
@@ -1165,7 +1185,7 @@ var Peer = class {
1165
1185
  topic: this.topic
1166
1186
  }, {
1167
1187
  F: __dxlog_file3,
1168
- L: 342,
1188
+ L: 347,
1169
1189
  S: this,
1170
1190
  C: (f, a) => f(...a)
1171
1191
  });
@@ -1678,7 +1698,6 @@ var SwarmMapper = class {
1678
1698
  get peers() {
1679
1699
  return Array.from(this._peers.values());
1680
1700
  }
1681
- // prettier-ignore
1682
1701
  constructor(_swarm) {
1683
1702
  this._swarm = _swarm;
1684
1703
  this._subscriptions = new EventSubscriptions();
@@ -1701,7 +1720,7 @@ var SwarmMapper = class {
1701
1720
  _update() {
1702
1721
  log5("updating swarm", void 0, {
1703
1722
  F: __dxlog_file5,
1704
- L: 75,
1723
+ L: 72,
1705
1724
  S: this,
1706
1725
  C: (f, a) => f(...a)
1707
1726
  });
@@ -1725,7 +1744,7 @@ var SwarmMapper = class {
1725
1744
  totalPeersInSwarm: this._peers.size
1726
1745
  }, {
1727
1746
  F: __dxlog_file5,
1728
- L: 116,
1747
+ L: 113,
1729
1748
  S: this,
1730
1749
  C: (f, a) => f(...a)
1731
1750
  });
@@ -2289,7 +2308,6 @@ import { invariant as invariant9 } from "@dxos/invariant";
2289
2308
  import { log as log9 } from "@dxos/log";
2290
2309
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
2291
2310
  var StarTopology = class {
2292
- // prettier-ignore
2293
2311
  constructor(_centralPeer) {
2294
2312
  this._centralPeer = _centralPeer;
2295
2313
  }
@@ -2299,7 +2317,7 @@ var StarTopology = class {
2299
2317
  init(controller) {
2300
2318
  invariant9(!this._controller, "Already initialized.", {
2301
2319
  F: __dxlog_file10,
2302
- L: 24,
2320
+ L: 21,
2303
2321
  S: this,
2304
2322
  A: [
2305
2323
  "!this._controller",
@@ -2311,7 +2329,7 @@ var StarTopology = class {
2311
2329
  update() {
2312
2330
  invariant9(this._controller, "Not initialized.", {
2313
2331
  F: __dxlog_file10,
2314
- L: 29,
2332
+ L: 26,
2315
2333
  S: this,
2316
2334
  A: [
2317
2335
  "this._controller",
@@ -2322,7 +2340,7 @@ var StarTopology = class {
2322
2340
  if (!ownPeerId.equals(this._centralPeer)) {
2323
2341
  log9("leaf peer dropping all connections apart from central peer.", void 0, {
2324
2342
  F: __dxlog_file10,
2325
- L: 32,
2343
+ L: 29,
2326
2344
  S: this,
2327
2345
  C: (f, a) => f(...a)
2328
2346
  });
@@ -2332,7 +2350,7 @@ var StarTopology = class {
2332
2350
  peer
2333
2351
  }, {
2334
2352
  F: __dxlog_file10,
2335
- L: 37,
2353
+ L: 34,
2336
2354
  S: this,
2337
2355
  C: (f, a) => f(...a)
2338
2356
  });
@@ -2346,7 +2364,7 @@ var StarTopology = class {
2346
2364
  peer
2347
2365
  }, {
2348
2366
  F: __dxlog_file10,
2349
- L: 46,
2367
+ L: 43,
2350
2368
  S: this,
2351
2369
  C: (f, a) => f(...a)
2352
2370
  });
@@ -2357,7 +2375,7 @@ var StarTopology = class {
2357
2375
  async onOffer(peer) {
2358
2376
  invariant9(this._controller, "Not initialized.", {
2359
2377
  F: __dxlog_file10,
2360
- L: 53,
2378
+ L: 50,
2361
2379
  S: this,
2362
2380
  A: [
2363
2381
  "this._controller",
@@ -2371,7 +2389,7 @@ var StarTopology = class {
2371
2389
  isSelfCentral: ownPeerId.equals(this._centralPeer)
2372
2390
  }, {
2373
2391
  F: __dxlog_file10,
2374
- L: 55,
2392
+ L: 52,
2375
2393
  S: this,
2376
2394
  C: (f, a) => f(...a)
2377
2395
  });
@@ -2673,24 +2691,28 @@ var SimplePeerTransport = class {
2673
2691
  switch (err.code) {
2674
2692
  case "ERR_WEBRTC_SUPPORT":
2675
2693
  this.errors.raise(new ProtocolError2("WebRTC not supported", err));
2694
+ break;
2676
2695
  case "ERR_ICE_CONNECTION_FAILURE":
2677
2696
  case "ERR_DATA_CHANNEL":
2678
2697
  case "ERR_CONNECTION_FAILURE":
2679
2698
  case "ERR_SIGNALING":
2680
2699
  this.errors.raise(new ConnectivityError2("unknown communication failure", err));
2700
+ break;
2681
2701
  case "ERR_CREATE_OFFER":
2682
2702
  case "ERR_CREATE_ANSWER":
2683
2703
  case "ERR_SET_LOCAL_DESCRIPTION":
2684
2704
  case "ERR_SET_REMOTE_DESCRIPTION":
2685
2705
  case "ERR_ADD_ICE_CANDIDATE":
2686
2706
  this.errors.raise(new UnknownProtocolError2("unknown simple-peer library failure", err));
2707
+ break;
2687
2708
  default:
2688
2709
  this.errors.raise(new Error("unknown simple-peer error"));
2710
+ break;
2689
2711
  }
2690
2712
  } else {
2691
2713
  log11.info("unknown peer connection error", err, {
2692
2714
  F: __dxlog_file12,
2693
- L: 96,
2715
+ L: 101,
2694
2716
  S: this,
2695
2717
  C: (f, a) => f(...a)
2696
2718
  });
@@ -2704,7 +2726,7 @@ var SimplePeerTransport = class {
2704
2726
  stats
2705
2727
  }, {
2706
2728
  F: __dxlog_file12,
2707
- L: 104,
2729
+ L: 109,
2708
2730
  S: this,
2709
2731
  C: (f, a) => f(...a)
2710
2732
  });
@@ -2713,7 +2735,7 @@ var SimplePeerTransport = class {
2713
2735
  } catch (err2) {
2714
2736
  log11.catch(err2, void 0, {
2715
2737
  F: __dxlog_file12,
2716
- L: 111,
2738
+ L: 116,
2717
2739
  S: this,
2718
2740
  C: (f, a) => f(...a)
2719
2741
  });
@@ -2724,7 +2746,7 @@ var SimplePeerTransport = class {
2724
2746
  id: this._instanceId
2725
2747
  }), {
2726
2748
  F: __dxlog_file12,
2727
- L: 116,
2749
+ L: 121,
2728
2750
  S: this,
2729
2751
  C: (f, a) => f(...a)
2730
2752
  });
@@ -2732,7 +2754,7 @@ var SimplePeerTransport = class {
2732
2754
  async destroy() {
2733
2755
  log11("closing...", void 0, {
2734
2756
  F: __dxlog_file12,
2735
- L: 120,
2757
+ L: 125,
2736
2758
  S: this,
2737
2759
  C: (f, a) => f(...a)
2738
2760
  });
@@ -2742,7 +2764,7 @@ var SimplePeerTransport = class {
2742
2764
  this.closed.emit();
2743
2765
  log11("closed", void 0, {
2744
2766
  F: __dxlog_file12,
2745
- L: 125,
2767
+ L: 130,
2746
2768
  S: this,
2747
2769
  C: (f, a) => f(...a)
2748
2770
  });
@@ -2775,7 +2797,6 @@ import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/
2775
2797
  import { ComplexMap as ComplexMap8 } from "@dxos/util";
2776
2798
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
2777
2799
  var SimplePeerTransportService = class {
2778
- // prettier-ignore
2779
2800
  constructor(_webrtcConfig) {
2780
2801
  this._webrtcConfig = _webrtcConfig;
2781
2802
  this.transports = new ComplexMap8(PublicKey11.hash);
@@ -2845,7 +2866,8 @@ var SimplePeerTransportService = class {
2845
2866
  const transportState = {
2846
2867
  transport,
2847
2868
  stream: duplex,
2848
- writeCallbacks: []
2869
+ writeCallbacks: [],
2870
+ state: "OPEN"
2849
2871
  };
2850
2872
  ready();
2851
2873
  this.transports.set(request.proxyId, transportState);
@@ -2855,7 +2877,7 @@ var SimplePeerTransportService = class {
2855
2877
  async sendSignal({ proxyId, signal }) {
2856
2878
  invariant12(this.transports.has(proxyId), void 0, {
2857
2879
  F: __dxlog_file13,
2858
- L: 113,
2880
+ L: 112,
2859
2881
  S: this,
2860
2882
  A: [
2861
2883
  "this.transports.has(proxyId)",
@@ -2865,9 +2887,17 @@ var SimplePeerTransportService = class {
2865
2887
  await this.transports.get(proxyId).transport.signal(signal);
2866
2888
  }
2867
2889
  async sendData({ proxyId, payload }) {
2890
+ if (this.transports.get(proxyId)?.state !== "OPEN") {
2891
+ log12.debug("transport is closed", void 0, {
2892
+ F: __dxlog_file13,
2893
+ L: 118,
2894
+ S: this,
2895
+ C: (f, a) => f(...a)
2896
+ });
2897
+ }
2868
2898
  invariant12(this.transports.has(proxyId), void 0, {
2869
2899
  F: __dxlog_file13,
2870
- L: 118,
2900
+ L: 120,
2871
2901
  S: this,
2872
2902
  A: [
2873
2903
  "this.transports.has(proxyId)",
@@ -2885,10 +2915,12 @@ var SimplePeerTransportService = class {
2885
2915
  async close({ proxyId }) {
2886
2916
  await this.transports.get(proxyId)?.transport.destroy();
2887
2917
  await this.transports.get(proxyId)?.stream.end();
2888
- this.transports.delete(proxyId);
2918
+ if (this.transports.get(proxyId)) {
2919
+ this.transports.get(proxyId).state = "CLOSED";
2920
+ }
2889
2921
  log12("Closed.", void 0, {
2890
2922
  F: __dxlog_file13,
2891
- L: 132,
2923
+ L: 136,
2892
2924
  S: this,
2893
2925
  C: (f, a) => f(...a)
2894
2926
  });
@@ -2908,7 +2940,6 @@ import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/
2908
2940
  import { arrayToBuffer } from "@dxos/util";
2909
2941
  var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
2910
2942
  var SimplePeerTransportProxy = class {
2911
- // prettier-ignore
2912
2943
  constructor(_params) {
2913
2944
  this._params = _params;
2914
2945
  this._proxyId = PublicKey12.random();
@@ -2925,7 +2956,7 @@ var SimplePeerTransportProxy = class {
2925
2956
  this._serviceStream.subscribe(async (event) => {
2926
2957
  log13("SimplePeerTransportProxy: event", event, {
2927
2958
  F: __dxlog_file14,
2928
- L: 58,
2959
+ L: 55,
2929
2960
  S: this,
2930
2961
  C: (f, a) => f(...a)
2931
2962
  });
@@ -2954,7 +2985,7 @@ var SimplePeerTransportProxy = class {
2954
2985
  }));
2955
2986
  }, (error) => log13.catch(error, void 0, {
2956
2987
  F: __dxlog_file14,
2957
- L: 82,
2988
+ L: 83,
2958
2989
  S: this,
2959
2990
  C: (f, a) => f(...a)
2960
2991
  }));
@@ -3000,7 +3031,7 @@ var SimplePeerTransportProxy = class {
3000
3031
  } catch (err) {
3001
3032
  log13.catch(err, void 0, {
3002
3033
  F: __dxlog_file14,
3003
- L: 133,
3034
+ L: 134,
3004
3035
  S: this,
3005
3036
  C: (f, a) => f(...a)
3006
3037
  });
@@ -3036,7 +3067,7 @@ var SimplePeerTransportProxyFactory = class {
3036
3067
  createTransport(options) {
3037
3068
  invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
3038
3069
  F: __dxlog_file14,
3039
- L: 170,
3070
+ L: 171,
3040
3071
  S: this,
3041
3072
  A: [
3042
3073
  "this._bridgeService",
@@ -3054,15 +3085,15 @@ var SimplePeerTransportProxyFactory = class {
3054
3085
  };
3055
3086
  var decodeError = (err) => {
3056
3087
  const message = typeof err === "string" ? err : err.message;
3057
- if (message.includes("ConnectionResetError")) {
3088
+ if (message.includes("CONNECTION_RESET")) {
3058
3089
  return new ConnectionResetError3(message);
3059
- } else if (message.includes("TimeoutError")) {
3090
+ } else if (message.includes("TIMEOUT")) {
3060
3091
  return new TimeoutError2(message);
3061
- } else if (message.includes("ProtocolError")) {
3092
+ } else if (message.includes("PROTOCOL_ERROR")) {
3062
3093
  return new ProtocolError3(message);
3063
- } else if (message.includes("ConnectivityError")) {
3094
+ } else if (message.includes("CONNECTIVITY_ERROR")) {
3064
3095
  return new ConnectivityError3(message);
3065
- } else if (message.includes("UnknownProtocolError")) {
3096
+ } else if (message.includes("UNKNOWN_PROTOCOL_ERROR")) {
3066
3097
  return new UnknownProtocolError3(message);
3067
3098
  } else {
3068
3099
  return typeof err === "string" ? new Error(err) : err;
@@ -3408,6 +3439,26 @@ var createLibDataChannelTransportFactory = (webrtcConfig) => ({
3408
3439
  })
3409
3440
  });
3410
3441
 
3442
+ // packages/core/mesh/network-manager/src/transport/tcp-transport.browser.ts
3443
+ import { Event as Event11 } from "@dxos/async";
3444
+ import { ErrorStream as ErrorStream7 } from "@dxos/debug";
3445
+ var TcpTransportFactory = {
3446
+ createTransport: () => new TcpTransport()
3447
+ };
3448
+ var TcpTransport = class {
3449
+ constructor() {
3450
+ this.closed = new Event11();
3451
+ this.connected = new Event11();
3452
+ this.errors = new ErrorStream7();
3453
+ }
3454
+ async destroy() {
3455
+ throw new Error("Method not implemented.");
3456
+ }
3457
+ signal() {
3458
+ throw new Error("Method not implemented.");
3459
+ }
3460
+ };
3461
+
3411
3462
  // packages/core/mesh/network-manager/src/wire-protocol.ts
3412
3463
  import { Teleport } from "@dxos/teleport";
3413
3464
  var createTeleportProtocolFactory = (onConnection) => {
@@ -3453,6 +3504,8 @@ export {
3453
3504
  SimplePeerTransportProxyFactory,
3454
3505
  LibDataChannelTransport,
3455
3506
  createLibDataChannelTransportFactory,
3507
+ TcpTransportFactory,
3508
+ TcpTransport,
3456
3509
  createTeleportProtocolFactory
3457
3510
  };
3458
- //# sourceMappingURL=chunk-66HPNABI.mjs.map
3511
+ //# sourceMappingURL=chunk-3KLH55NB.mjs.map