@dxos/network-manager 0.1.56 → 0.1.57-main.281294d

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.
@@ -79,7 +79,7 @@ function _ts_decorate(decorators, target, key, desc) {
79
79
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
80
80
  return c > 3 && r && Object.defineProperty(target, key, r), r;
81
81
  }
82
- var __dxlog_file = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection.ts";
82
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
83
83
  var STARTING_SIGNALLING_DELAY = 10;
84
84
  var MAX_SIGNALLING_DELAY = 300;
85
85
  var ConnectionState;
@@ -117,7 +117,7 @@ var ConnectionState;
117
117
  ] = "CLOSED";
118
118
  })(ConnectionState || (ConnectionState = {}));
119
119
  var Connection = class {
120
- constructor(topic, ownId, remoteId, sessionId, initiator, _signalMessaging, _protocol, _transportFactory) {
120
+ constructor(topic, ownId, remoteId, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
121
121
  this.topic = topic;
122
122
  this.ownId = ownId;
123
123
  this.remoteId = remoteId;
@@ -126,6 +126,7 @@ var Connection = class {
126
126
  this._signalMessaging = _signalMessaging;
127
127
  this._protocol = _protocol;
128
128
  this._transportFactory = _transportFactory;
129
+ this._callbacks = _callbacks;
129
130
  this._ctx = new import_context.Context();
130
131
  this._state = ConnectionState.INITIAL;
131
132
  this._incomingSignalBuffer = [];
@@ -145,7 +146,7 @@ var Connection = class {
145
146
  initiator: this.initiator
146
147
  }, {
147
148
  F: __dxlog_file,
148
- L: 96,
149
+ L: 109,
149
150
  S: this,
150
151
  C: (f, a) => f(...a)
151
152
  });
@@ -165,7 +166,7 @@ var Connection = class {
165
166
  async openConnection() {
166
167
  (0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
167
168
  F: __dxlog_file,
168
- L: 121,
169
+ L: 134,
169
170
  S: this,
170
171
  A: [
171
172
  "this._state === ConnectionState.INITIAL",
@@ -176,7 +177,7 @@ var Connection = class {
176
177
  id: this._instanceId
177
178
  }), {
178
179
  F: __dxlog_file,
179
- L: 122,
180
+ L: 135,
180
181
  S: this,
181
182
  C: (f, a) => f(...a)
182
183
  });
@@ -188,7 +189,7 @@ var Connection = class {
188
189
  initiator: this.initiator
189
190
  }, {
190
191
  F: __dxlog_file,
191
- L: 123,
192
+ L: 136,
192
193
  S: this,
193
194
  C: (f, a) => f(...a)
194
195
  });
@@ -199,7 +200,7 @@ var Connection = class {
199
200
  this._protocol.stream.on("close", () => {
200
201
  (0, import_log.log)("protocol stream closed", void 0, {
201
202
  F: __dxlog_file,
202
- L: 140,
203
+ L: 153,
203
204
  S: this,
204
205
  C: (f, a) => f(...a)
205
206
  });
@@ -207,7 +208,7 @@ var Connection = class {
207
208
  });
208
209
  (0, import_invariant.invariant)(!this._transport, void 0, {
209
210
  F: __dxlog_file,
210
- L: 144,
211
+ L: 157,
211
212
  S: this,
212
213
  A: [
213
214
  "!this._transport",
@@ -221,6 +222,7 @@ var Connection = class {
221
222
  });
222
223
  this._transport.connected.once(() => {
223
224
  this._changeState(ConnectionState.CONNECTED);
225
+ this._callbacks?.onConnected?.();
224
226
  });
225
227
  this._transport.closed.once(() => {
226
228
  this._transport = void 0;
@@ -242,7 +244,7 @@ var Connection = class {
242
244
  id: this._instanceId
243
245
  }), {
244
246
  F: __dxlog_file,
245
- L: 176,
247
+ L: 190,
246
248
  S: this,
247
249
  C: (f, a) => f(...a)
248
250
  });
@@ -260,7 +262,7 @@ var Connection = class {
260
262
  peerId: this.ownId
261
263
  }, {
262
264
  F: __dxlog_file,
263
- L: 191,
265
+ L: 205,
264
266
  S: this,
265
267
  C: (f, a) => f(...a)
266
268
  });
@@ -269,7 +271,7 @@ var Connection = class {
269
271
  } catch (err2) {
270
272
  import_log.log.catch(err2, void 0, {
271
273
  F: __dxlog_file,
272
- L: 197,
274
+ L: 211,
273
275
  S: this,
274
276
  C: (f, a) => f(...a)
275
277
  });
@@ -279,7 +281,7 @@ var Connection = class {
279
281
  } catch (err2) {
280
282
  import_log.log.catch(err2, void 0, {
281
283
  F: __dxlog_file,
282
- L: 204,
284
+ L: 218,
283
285
  S: this,
284
286
  C: (f, a) => f(...a)
285
287
  });
@@ -288,11 +290,12 @@ var Connection = class {
288
290
  peerId: this.ownId
289
291
  }, {
290
292
  F: __dxlog_file,
291
- L: 207,
293
+ L: 221,
292
294
  S: this,
293
295
  C: (f, a) => f(...a)
294
296
  });
295
297
  this._changeState(ConnectionState.CLOSED);
298
+ this._callbacks?.onClosed?.(err);
296
299
  }
297
300
  _sendSignal(signal) {
298
301
  this._outgoingSignalBuffer.push(signal);
@@ -330,7 +333,7 @@ var Connection = class {
330
333
  err
331
334
  }, {
332
335
  F: __dxlog_file,
333
- L: 243,
336
+ L: 258,
334
337
  S: this,
335
338
  C: (f, a) => f(...a)
336
339
  });
@@ -343,7 +346,7 @@ var Connection = class {
343
346
  async signal(msg) {
344
347
  (0, import_invariant.invariant)(msg.sessionId, void 0, {
345
348
  F: __dxlog_file,
346
- L: 252,
349
+ L: 267,
347
350
  S: this,
348
351
  A: [
349
352
  "msg.sessionId",
@@ -353,7 +356,7 @@ var Connection = class {
353
356
  if (!msg.sessionId.equals(this.sessionId)) {
354
357
  (0, import_log.log)("dropping signal for incorrect session id", void 0, {
355
358
  F: __dxlog_file,
356
- L: 254,
359
+ L: 269,
357
360
  S: this,
358
361
  C: (f, a) => f(...a)
359
362
  });
@@ -361,7 +364,7 @@ var Connection = class {
361
364
  }
362
365
  (0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
363
366
  F: __dxlog_file,
364
- L: 257,
367
+ L: 272,
365
368
  S: this,
366
369
  A: [
367
370
  "msg.data.signal || msg.data.signalBatch",
@@ -370,7 +373,7 @@ var Connection = class {
370
373
  });
371
374
  (0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
372
375
  F: __dxlog_file,
373
- L: 258,
376
+ L: 273,
374
377
  S: this,
375
378
  A: [
376
379
  "msg.author?.equals(this.remoteId)",
@@ -379,7 +382,7 @@ var Connection = class {
379
382
  });
380
383
  (0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
381
384
  F: __dxlog_file,
382
- L: 259,
385
+ L: 274,
383
386
  S: this,
384
387
  A: [
385
388
  "msg.recipient?.equals(this.ownId)",
@@ -400,7 +403,7 @@ var Connection = class {
400
403
  msg: msg.data
401
404
  }, {
402
405
  F: __dxlog_file,
403
- L: 268,
406
+ L: 283,
404
407
  S: this,
405
408
  C: (f, a) => f(...a)
406
409
  });
@@ -408,7 +411,7 @@ var Connection = class {
408
411
  } else {
409
412
  (0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
410
413
  F: __dxlog_file,
411
- L: 271,
414
+ L: 286,
412
415
  S: this,
413
416
  A: [
414
417
  "this._transport",
@@ -421,7 +424,7 @@ var Connection = class {
421
424
  msg: msg.data
422
425
  }, {
423
426
  F: __dxlog_file,
424
- L: 272,
427
+ L: 287,
425
428
  S: this,
426
429
  C: (f, a) => f(...a)
427
430
  });
@@ -436,13 +439,13 @@ var Connection = class {
436
439
  peerId: this.ownId
437
440
  }, {
438
441
  F: __dxlog_file,
439
- L: 279,
442
+ L: 294,
440
443
  S: this,
441
444
  C: (f, a) => f(...a)
442
445
  });
443
446
  (0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
444
447
  F: __dxlog_file,
445
- L: 280,
448
+ L: 295,
446
449
  S: this,
447
450
  A: [
448
451
  "state !== this._state",
@@ -474,7 +477,7 @@ var import_keys2 = require("@dxos/keys");
474
477
  var import_log2 = require("@dxos/log");
475
478
  var import_protocols2 = require("@dxos/protocols");
476
479
  var import_util = require("@dxos/util");
477
- var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
480
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
478
481
  var SwarmMessage = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
479
482
  var SwarmMessenger = class {
480
483
  constructor({ sendMessage, onSignal, onOffer, topic }) {
@@ -716,7 +719,12 @@ function _ts_decorate2(decorators, target, key, desc) {
716
719
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
717
720
  return c > 3 && r && Object.defineProperty(target, key, r), r;
718
721
  }
719
- var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/peer.ts";
722
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
723
+ var ConnectionDisplacedError = class extends import_errors2.SystemError {
724
+ constructor() {
725
+ super("Connection displaced by remote initiator.");
726
+ }
727
+ };
720
728
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
721
729
  var Peer = class {
722
730
  // TODO(burdon): Convert to map?
@@ -734,6 +742,7 @@ var Peer = class {
734
742
  this._ctx = new import_context3.Context();
735
743
  this.advertizing = false;
736
744
  this.initiating = false;
745
+ this.connectionDisplaced = new import_async2.Event();
737
746
  }
738
747
  /**
739
748
  * Respond to remote offer.
@@ -749,12 +758,12 @@ var Peer = class {
749
758
  sessionId: this.connection?.sessionId
750
759
  }, {
751
760
  F: __dxlog_file3,
752
- L: 108,
761
+ L: 116,
753
762
  S: this,
754
763
  C: (f, a) => f(...a)
755
764
  });
756
765
  if (this.connection) {
757
- await this.closeConnection(new Error("Connection displaced by remote initiator."));
766
+ await this.closeConnection(new ConnectionDisplacedError());
758
767
  }
759
768
  } else {
760
769
  return {
@@ -766,7 +775,7 @@ var Peer = class {
766
775
  if (!this.connection) {
767
776
  (0, import_invariant3.invariant)(message.sessionId, void 0, {
768
777
  F: __dxlog_file3,
769
- L: 128,
778
+ L: 136,
770
779
  S: this,
771
780
  A: [
772
781
  "message.sessionId",
@@ -786,7 +795,7 @@ var Peer = class {
786
795
  err
787
796
  }, {
788
797
  F: __dxlog_file3,
789
- L: 136,
798
+ L: 144,
790
799
  S: this,
791
800
  C: (f, a) => f(...a)
792
801
  });
@@ -808,7 +817,7 @@ var Peer = class {
808
817
  async initiateConnection() {
809
818
  (0, import_invariant3.invariant)(!this.initiating, "Initiation in progress.", {
810
819
  F: __dxlog_file3,
811
- L: 153,
820
+ L: 161,
812
821
  S: this,
813
822
  A: [
814
823
  "!this.initiating",
@@ -817,7 +826,7 @@ var Peer = class {
817
826
  });
818
827
  (0, import_invariant3.invariant)(!this.connection, "Already connected.", {
819
828
  F: __dxlog_file3,
820
- L: 154,
829
+ L: 162,
821
830
  S: this,
822
831
  A: [
823
832
  "!this.connection",
@@ -832,7 +841,7 @@ var Peer = class {
832
841
  sessionId
833
842
  }, {
834
843
  F: __dxlog_file3,
835
- L: 156,
844
+ L: 164,
836
845
  S: this,
837
846
  C: (f, a) => f(...a)
838
847
  });
@@ -856,14 +865,14 @@ var Peer = class {
856
865
  remoteId: this.id
857
866
  }, {
858
867
  F: __dxlog_file3,
859
- L: 171,
868
+ L: 179,
860
869
  S: this,
861
870
  C: (f, a) => f(...a)
862
871
  });
863
872
  if (connection.state !== ConnectionState.INITIAL) {
864
873
  (0, import_log3.log)("ignoring response", void 0, {
865
874
  F: __dxlog_file3,
866
- L: 173,
875
+ L: 181,
867
876
  S: this,
868
877
  C: (f, a) => f(...a)
869
878
  });
@@ -883,7 +892,7 @@ var Peer = class {
883
892
  remoteId: this.id
884
893
  }, {
885
894
  F: __dxlog_file3,
886
- L: 184,
895
+ L: 192,
887
896
  S: this,
888
897
  C: (f, a) => f(...a)
889
898
  });
@@ -906,13 +915,13 @@ var Peer = class {
906
915
  sessionId
907
916
  }, {
908
917
  F: __dxlog_file3,
909
- L: 198,
918
+ L: 206,
910
919
  S: this,
911
920
  C: (f, a) => f(...a)
912
921
  });
913
922
  (0, import_invariant3.invariant)(!this.connection, "Already connected.", {
914
923
  F: __dxlog_file3,
915
- L: 205,
924
+ L: 213,
916
925
  S: this,
917
926
  A: [
918
927
  "!this.connection",
@@ -933,14 +942,9 @@ var Peer = class {
933
942
  remotePeerId: this.id,
934
943
  topic: this.topic
935
944
  }),
936
- this._transportFactory
937
- );
938
- this._callbacks.onInitiated(connection);
939
- void this._connectionCtx?.dispose();
940
- this._connectionCtx = this._ctx.derive();
941
- connection.stateChanged.on((state) => {
942
- switch (state) {
943
- case ConnectionState.CONNECTED: {
945
+ this._transportFactory,
946
+ {
947
+ onConnected: () => {
944
948
  this.availableToConnect = true;
945
949
  this._lastConnectionTime = Date.now();
946
950
  this._callbacks.onConnected();
@@ -953,13 +957,12 @@ var Peer = class {
953
957
  initiator
954
958
  }, {
955
959
  F: __dxlog_file3,
956
- L: 231,
960
+ L: 232,
957
961
  S: this,
958
962
  C: (f, a) => f(...a)
959
963
  });
960
- break;
961
- }
962
- case ConnectionState.CLOSED: {
964
+ },
965
+ onClosed: (err) => {
963
966
  (0, import_log3.log)("connection closed", {
964
967
  topic: this.topic,
965
968
  peerId: this.localPeerId,
@@ -967,13 +970,14 @@ var Peer = class {
967
970
  initiator
968
971
  }, {
969
972
  F: __dxlog_file3,
970
- L: 242,
973
+ L: 241,
971
974
  S: this,
972
975
  C: (f, a) => f(...a)
973
976
  });
977
+ this._connectionLimiter.doneConnecting(sessionId);
974
978
  (0, import_invariant3.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
975
979
  F: __dxlog_file3,
976
- L: 243,
980
+ L: 246,
977
981
  S: this,
978
982
  A: [
979
983
  "this.connection === connection",
@@ -988,27 +992,32 @@ var Peer = class {
988
992
  initiator
989
993
  }, {
990
994
  F: __dxlog_file3,
991
- L: 245,
995
+ L: 248,
992
996
  S: this,
993
997
  C: (f, a) => f(...a)
994
998
  });
995
- if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
996
- this._availableAfter = 0;
999
+ if (err instanceof ConnectionDisplacedError) {
1000
+ this.connectionDisplaced.emit(this.connection);
997
1001
  } else {
998
- this.availableToConnect = false;
999
- this._availableAfter = increaseInterval(this._availableAfter);
1002
+ if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
1003
+ this._availableAfter = 0;
1004
+ } else {
1005
+ this.availableToConnect = false;
1006
+ this._availableAfter = increaseInterval(this._availableAfter);
1007
+ }
1008
+ this._callbacks.onDisconnected();
1009
+ (0, import_async2.scheduleTask)(this._connectionCtx, () => {
1010
+ this.availableToConnect = true;
1011
+ this._callbacks.onPeerAvailable();
1012
+ }, this._availableAfter);
1000
1013
  }
1001
1014
  this.connection = void 0;
1002
- this._callbacks.onDisconnected();
1003
- this._connectionLimiter.doneConnecting(sessionId);
1004
- (0, import_async2.scheduleTask)(this._connectionCtx, () => {
1005
- this.availableToConnect = true;
1006
- this._callbacks.onPeerAvailable();
1007
- }, this._availableAfter);
1008
- break;
1009
1015
  }
1010
1016
  }
1011
- });
1017
+ );
1018
+ this._callbacks.onInitiated(connection);
1019
+ void this._connectionCtx?.dispose();
1020
+ this._connectionCtx = this._ctx.derive();
1012
1021
  connection.errors.handle((err) => {
1013
1022
  import_log3.log.warn("connection error", {
1014
1023
  topic: this.topic,
@@ -1018,7 +1027,7 @@ var Peer = class {
1018
1027
  err
1019
1028
  }, {
1020
1029
  F: __dxlog_file3,
1021
- L: 279,
1030
+ L: 288,
1022
1031
  S: this,
1023
1032
  C: (f, a) => f(...a)
1024
1033
  });
@@ -1031,7 +1040,7 @@ var Peer = class {
1031
1040
  err
1032
1041
  }, {
1033
1042
  F: __dxlog_file3,
1034
- L: 280,
1043
+ L: 289,
1035
1044
  S: this,
1036
1045
  C: (f, a) => f(...a)
1037
1046
  });
@@ -1050,7 +1059,7 @@ var Peer = class {
1050
1059
  sessionId: connection.sessionId
1051
1060
  }, {
1052
1061
  F: __dxlog_file3,
1053
- L: 303,
1062
+ L: 314,
1054
1063
  S: this,
1055
1064
  C: (f, a) => f(...a)
1056
1065
  });
@@ -1060,7 +1069,7 @@ var Peer = class {
1060
1069
  sessionId: connection.sessionId
1061
1070
  }, {
1062
1071
  F: __dxlog_file3,
1063
- L: 309,
1072
+ L: 320,
1064
1073
  S: this,
1065
1074
  C: (f, a) => f(...a)
1066
1075
  });
@@ -1071,7 +1080,7 @@ var Peer = class {
1071
1080
  message
1072
1081
  }, {
1073
1082
  F: __dxlog_file3,
1074
- L: 314,
1083
+ L: 325,
1075
1084
  S: this,
1076
1085
  C: (f, a) => f(...a)
1077
1086
  });
@@ -1086,7 +1095,7 @@ var Peer = class {
1086
1095
  topic: this.topic
1087
1096
  }, {
1088
1097
  F: __dxlog_file3,
1089
- L: 324,
1098
+ L: 335,
1090
1099
  S: this,
1091
1100
  C: (f, a) => f(...a)
1092
1101
  });
@@ -1120,13 +1129,13 @@ function _ts_decorate3(decorators, target, key, desc) {
1120
1129
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1121
1130
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1122
1131
  }
1123
- var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1132
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1124
1133
  var INITIATION_DELAY = 100;
1125
1134
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
1126
1135
  var Swarm = class {
1127
1136
  // TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
1128
1137
  // TODO(burdon): Split up properties.
1129
- constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter) {
1138
+ constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
1130
1139
  this._topic = _topic;
1131
1140
  this._ownPeerId = _ownPeerId;
1132
1141
  this._topology = _topology;
@@ -1135,6 +1144,7 @@ var Swarm = class {
1135
1144
  this._transportFactory = _transportFactory;
1136
1145
  this._label = _label;
1137
1146
  this._connectionLimiter = _connectionLimiter;
1147
+ this._initiationDelay = _initiationDelay;
1138
1148
  this._ctx = new import_context4.Context();
1139
1149
  this._listeningHandle = void 0;
1140
1150
  this._peers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
@@ -1151,7 +1161,7 @@ var Swarm = class {
1151
1161
  }
1152
1162
  }), {
1153
1163
  F: __dxlog_file4,
1154
- L: 87,
1164
+ L: 88,
1155
1165
  S: this,
1156
1166
  C: (f, a) => f(...a)
1157
1167
  });
@@ -1159,7 +1169,7 @@ var Swarm = class {
1159
1169
  peerId: _ownPeerId
1160
1170
  }, {
1161
1171
  F: __dxlog_file4,
1162
- L: 91,
1172
+ L: 92,
1163
1173
  S: this,
1164
1174
  C: (f, a) => f(...a)
1165
1175
  });
@@ -1174,7 +1184,7 @@ var Swarm = class {
1174
1184
  id: this._instanceId
1175
1185
  }), {
1176
1186
  F: __dxlog_file4,
1177
- L: 100,
1187
+ L: 101,
1178
1188
  S: this,
1179
1189
  C: (f, a) => f(...a)
1180
1190
  });
@@ -1197,7 +1207,7 @@ var Swarm = class {
1197
1207
  async open() {
1198
1208
  (0, import_invariant4.invariant)(!this._listeningHandle, void 0, {
1199
1209
  F: __dxlog_file4,
1200
- L: 127,
1210
+ L: 128,
1201
1211
  S: this,
1202
1212
  A: [
1203
1213
  "!this._listeningHandle",
@@ -1212,7 +1222,7 @@ var Swarm = class {
1212
1222
  err
1213
1223
  }, {
1214
1224
  F: __dxlog_file4,
1215
- L: 134,
1225
+ L: 135,
1216
1226
  S: this,
1217
1227
  C: (f, a) => f(...a)
1218
1228
  }));
@@ -1222,7 +1232,7 @@ var Swarm = class {
1222
1232
  async destroy() {
1223
1233
  (0, import_log4.log)("destroying...", void 0, {
1224
1234
  F: __dxlog_file4,
1225
- L: 140,
1235
+ L: 141,
1226
1236
  S: this,
1227
1237
  C: (f, a) => f(...a)
1228
1238
  });
@@ -1233,7 +1243,7 @@ var Swarm = class {
1233
1243
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
1234
1244
  (0, import_log4.log)("destroyed", void 0, {
1235
1245
  F: __dxlog_file4,
1236
- L: 147,
1246
+ L: 148,
1237
1247
  S: this,
1238
1248
  C: (f, a) => f(...a)
1239
1249
  });
@@ -1241,7 +1251,7 @@ var Swarm = class {
1241
1251
  async setTopology(topology) {
1242
1252
  (0, import_invariant4.invariant)(!this._ctx.disposed, "Swarm is offline", {
1243
1253
  F: __dxlog_file4,
1244
- L: 151,
1254
+ L: 152,
1245
1255
  S: this,
1246
1256
  A: [
1247
1257
  "!this._ctx.disposed",
@@ -1256,7 +1266,7 @@ var Swarm = class {
1256
1266
  topology: getClassName(topology)
1257
1267
  }, {
1258
1268
  F: __dxlog_file4,
1259
- L: 155,
1269
+ L: 156,
1260
1270
  S: this,
1261
1271
  C: (f, a) => f(...a)
1262
1272
  });
@@ -1270,14 +1280,14 @@ var Swarm = class {
1270
1280
  swarmEvent
1271
1281
  }, {
1272
1282
  F: __dxlog_file4,
1273
- L: 168,
1283
+ L: 169,
1274
1284
  S: this,
1275
1285
  C: (f, a) => f(...a)
1276
1286
  });
1277
1287
  if (this._ctx.disposed) {
1278
1288
  (0, import_log4.log)("swarm event ignored for disposed swarm", void 0, {
1279
1289
  F: __dxlog_file4,
1280
- L: 171,
1290
+ L: 172,
1281
1291
  S: this,
1282
1292
  C: (f, a) => f(...a)
1283
1293
  });
@@ -1289,7 +1299,7 @@ var Swarm = class {
1289
1299
  peerId
1290
1300
  }, {
1291
1301
  F: __dxlog_file4,
1292
- L: 177,
1302
+ L: 178,
1293
1303
  S: this,
1294
1304
  C: (f, a) => f(...a)
1295
1305
  });
@@ -1304,7 +1314,7 @@ var Swarm = class {
1304
1314
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
1305
1315
  void this._destroyPeer(peer.id).catch((err) => import_log4.log.catch(err, void 0, {
1306
1316
  F: __dxlog_file4,
1307
- L: 188,
1317
+ L: 189,
1308
1318
  S: this,
1309
1319
  C: (f, a) => f(...a)
1310
1320
  }));
@@ -1318,14 +1328,14 @@ var Swarm = class {
1318
1328
  message
1319
1329
  }, {
1320
1330
  F: __dxlog_file4,
1321
- L: 198,
1331
+ L: 199,
1322
1332
  S: this,
1323
1333
  C: (f, a) => f(...a)
1324
1334
  });
1325
1335
  if (this._ctx.disposed) {
1326
1336
  (0, import_log4.log)("ignored for disposed swarm", void 0, {
1327
1337
  F: __dxlog_file4,
1328
- L: 200,
1338
+ L: 201,
1329
1339
  S: this,
1330
1340
  C: (f, a) => f(...a)
1331
1341
  });
@@ -1335,7 +1345,7 @@ var Swarm = class {
1335
1345
  }
1336
1346
  (0, import_invariant4.invariant)(message.author, void 0, {
1337
1347
  F: __dxlog_file4,
1338
- L: 205,
1348
+ L: 206,
1339
1349
  S: this,
1340
1350
  A: [
1341
1351
  "message.author",
@@ -1347,7 +1357,7 @@ var Swarm = class {
1347
1357
  message
1348
1358
  }, {
1349
1359
  F: __dxlog_file4,
1350
- L: 207,
1360
+ L: 208,
1351
1361
  S: this,
1352
1362
  C: (f, a) => f(...a)
1353
1363
  });
@@ -1360,7 +1370,7 @@ var Swarm = class {
1360
1370
  message
1361
1371
  }, {
1362
1372
  F: __dxlog_file4,
1363
- L: 211,
1373
+ L: 212,
1364
1374
  S: this,
1365
1375
  C: (f, a) => f(...a)
1366
1376
  });
@@ -1378,14 +1388,14 @@ var Swarm = class {
1378
1388
  message
1379
1389
  }, {
1380
1390
  F: __dxlog_file4,
1381
- L: 222,
1391
+ L: 223,
1382
1392
  S: this,
1383
1393
  C: (f, a) => f(...a)
1384
1394
  });
1385
1395
  if (this._ctx.disposed) {
1386
1396
  import_log4.log.info("ignored for offline swarm", void 0, {
1387
1397
  F: __dxlog_file4,
1388
- L: 224,
1398
+ L: 225,
1389
1399
  S: this,
1390
1400
  C: (f, a) => f(...a)
1391
1401
  });
@@ -1393,7 +1403,7 @@ var Swarm = class {
1393
1403
  }
1394
1404
  (0, import_invariant4.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1395
1405
  F: __dxlog_file4,
1396
- L: 227,
1406
+ L: 228,
1397
1407
  S: this,
1398
1408
  A: [
1399
1409
  "message.recipient?.equals(this._ownPeerId)",
@@ -1402,7 +1412,7 @@ var Swarm = class {
1402
1412
  });
1403
1413
  (0, import_invariant4.invariant)(message.topic?.equals(this._topic), void 0, {
1404
1414
  F: __dxlog_file4,
1405
- L: 231,
1415
+ L: 232,
1406
1416
  S: this,
1407
1417
  A: [
1408
1418
  "message.topic?.equals(this._topic)",
@@ -1411,7 +1421,7 @@ var Swarm = class {
1411
1421
  });
1412
1422
  (0, import_invariant4.invariant)(message.author, void 0, {
1413
1423
  F: __dxlog_file4,
1414
- L: 232,
1424
+ L: 233,
1415
1425
  S: this,
1416
1426
  A: [
1417
1427
  "message.author",
@@ -1471,7 +1481,7 @@ var Swarm = class {
1471
1481
  async _destroyPeer(peerId) {
1472
1482
  (0, import_invariant4.invariant)(this._peers.has(peerId), void 0, {
1473
1483
  F: __dxlog_file4,
1474
- L: 302,
1484
+ L: 303,
1475
1485
  S: this,
1476
1486
  A: [
1477
1487
  "this._peers.has(peerId)",
@@ -1498,7 +1508,7 @@ var Swarm = class {
1498
1508
  } catch (err) {
1499
1509
  (0, import_log4.log)("initiation error", err, {
1500
1510
  F: __dxlog_file4,
1501
- L: 328,
1511
+ L: 329,
1502
1512
  S: this,
1503
1513
  C: (f, a) => f(...a)
1504
1514
  });
@@ -1526,11 +1536,11 @@ var Swarm = class {
1526
1536
  remoteId
1527
1537
  }, {
1528
1538
  F: __dxlog_file4,
1529
- L: 355,
1539
+ L: 356,
1530
1540
  S: this,
1531
1541
  C: (f, a) => f(...a)
1532
1542
  });
1533
- await (0, import_async3.sleep)(INITIATION_DELAY);
1543
+ await (0, import_async3.sleep)(this._initiationDelay);
1534
1544
  }
1535
1545
  if (ctx.disposed) {
1536
1546
  return;
@@ -1543,7 +1553,7 @@ var Swarm = class {
1543
1553
  remoteId
1544
1554
  }, {
1545
1555
  F: __dxlog_file4,
1546
- L: 369,
1556
+ L: 370,
1547
1557
  S: this,
1548
1558
  C: (f, a) => f(...a)
1549
1559
  });
@@ -1553,7 +1563,7 @@ var Swarm = class {
1553
1563
  remoteId
1554
1564
  }, {
1555
1565
  F: __dxlog_file4,
1556
- L: 372,
1566
+ L: 373,
1557
1567
  S: this,
1558
1568
  C: (f, a) => f(...a)
1559
1569
  });
@@ -1593,7 +1603,7 @@ var import_async4 = require("@dxos/async");
1593
1603
  var import_keys5 = require("@dxos/keys");
1594
1604
  var import_log5 = require("@dxos/log");
1595
1605
  var import_util3 = require("@dxos/util");
1596
- var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1606
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1597
1607
  var SwarmMapper = class {
1598
1608
  get peers() {
1599
1609
  return Array.from(this._peers.values());
@@ -1666,7 +1676,7 @@ var import_invariant5 = require("@dxos/invariant");
1666
1676
  var import_keys6 = require("@dxos/keys");
1667
1677
  var import_log6 = require("@dxos/log");
1668
1678
  var import_util4 = require("@dxos/util");
1669
- var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1679
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1670
1680
  var MAX_CONCURRENT_INITIATING_CONNECTIONS = 10;
1671
1681
  var ConnectionLimiter = class {
1672
1682
  constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
@@ -1815,7 +1825,7 @@ var import_messaging = require("@dxos/messaging");
1815
1825
  var import_protocols4 = require("@dxos/protocols");
1816
1826
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
1817
1827
  var import_util6 = require("@dxos/util");
1818
- var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/network-manager.ts";
1828
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
1819
1829
  var NetworkManager = class {
1820
1830
  constructor({ transportFactory, signalManager, log: log1 }) {
1821
1831
  /**
@@ -2051,7 +2061,7 @@ var NetworkManager = class {
2051
2061
 
2052
2062
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
2053
2063
  var import_invariant7 = require("@dxos/invariant");
2054
- var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2064
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2055
2065
  var FullyConnectedTopology = class {
2056
2066
  toString() {
2057
2067
  return "FullyConnectedTopology";
@@ -2094,7 +2104,7 @@ var FullyConnectedTopology = class {
2094
2104
  var import_xor_distance = __toESM(require("xor-distance"));
2095
2105
  var import_invariant8 = require("@dxos/invariant");
2096
2106
  var import_log8 = require("@dxos/log");
2097
- var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
2107
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
2098
2108
  var MMSTTopology = class {
2099
2109
  constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
2100
2110
  this._sampleCollected = false;
@@ -2203,7 +2213,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_dist
2203
2213
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
2204
2214
  var import_invariant9 = require("@dxos/invariant");
2205
2215
  var import_log9 = require("@dxos/log");
2206
- var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/star-topology.ts";
2216
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
2207
2217
  var StarTopology = class {
2208
2218
  // prettier-ignore
2209
2219
  constructor(_centralPeer) {
@@ -2315,7 +2325,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2315
2325
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2316
2326
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2317
2327
  }
2318
- var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2328
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2319
2329
  var MEMORY_TRANSPORT_DELAY = 1;
2320
2330
  var createStreamDelay = (delay) => {
2321
2331
  return new import_node_stream.Transform({
@@ -2500,7 +2510,7 @@ try {
2500
2510
  }
2501
2511
 
2502
2512
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
2503
- var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
2513
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
2504
2514
  var WebRTCTransport = class {
2505
2515
  constructor(params) {
2506
2516
  this.params = params;
@@ -2647,7 +2657,7 @@ var import_keys11 = require("@dxos/keys");
2647
2657
  var import_log12 = require("@dxos/log");
2648
2658
  var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
2649
2659
  var import_util8 = require("@dxos/util");
2650
- var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2660
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2651
2661
  var WebRTCTransportService = class {
2652
2662
  // prettier-ignore
2653
2663
  constructor(_webrtcConfig) {
@@ -2779,7 +2789,7 @@ var import_keys12 = require("@dxos/keys");
2779
2789
  var import_log13 = require("@dxos/log");
2780
2790
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
2781
2791
  var import_util9 = require("@dxos/util");
2782
- var __dxlog_file14 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2792
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2783
2793
  var WebRTCTransportProxy = class {
2784
2794
  // prettier-ignore
2785
2795
  constructor(_params) {