@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.
@@ -80,7 +80,7 @@ function _ts_decorate(decorators, target, key, desc) {
80
80
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
81
81
  return c > 3 && r && Object.defineProperty(target, key, r), r;
82
82
  }
83
- var __dxlog_file = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection.ts";
83
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
84
84
  var STARTING_SIGNALLING_DELAY = 10;
85
85
  var MAX_SIGNALLING_DELAY = 300;
86
86
  var ConnectionState;
@@ -118,7 +118,7 @@ var ConnectionState;
118
118
  ] = "CLOSED";
119
119
  })(ConnectionState || (ConnectionState = {}));
120
120
  var Connection = class {
121
- constructor(topic, ownId, remoteId, sessionId, initiator, _signalMessaging, _protocol, _transportFactory) {
121
+ constructor(topic, ownId, remoteId, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
122
122
  this.topic = topic;
123
123
  this.ownId = ownId;
124
124
  this.remoteId = remoteId;
@@ -127,6 +127,7 @@ var Connection = class {
127
127
  this._signalMessaging = _signalMessaging;
128
128
  this._protocol = _protocol;
129
129
  this._transportFactory = _transportFactory;
130
+ this._callbacks = _callbacks;
130
131
  this._ctx = new import_context.Context();
131
132
  this._state = ConnectionState.INITIAL;
132
133
  this._incomingSignalBuffer = [];
@@ -146,7 +147,7 @@ var Connection = class {
146
147
  initiator: this.initiator
147
148
  }, {
148
149
  F: __dxlog_file,
149
- L: 96,
150
+ L: 109,
150
151
  S: this,
151
152
  C: (f, a) => f(...a)
152
153
  });
@@ -166,7 +167,7 @@ var Connection = class {
166
167
  async openConnection() {
167
168
  (0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
168
169
  F: __dxlog_file,
169
- L: 121,
170
+ L: 134,
170
171
  S: this,
171
172
  A: [
172
173
  "this._state === ConnectionState.INITIAL",
@@ -177,7 +178,7 @@ var Connection = class {
177
178
  id: this._instanceId
178
179
  }), {
179
180
  F: __dxlog_file,
180
- L: 122,
181
+ L: 135,
181
182
  S: this,
182
183
  C: (f, a) => f(...a)
183
184
  });
@@ -189,7 +190,7 @@ var Connection = class {
189
190
  initiator: this.initiator
190
191
  }, {
191
192
  F: __dxlog_file,
192
- L: 123,
193
+ L: 136,
193
194
  S: this,
194
195
  C: (f, a) => f(...a)
195
196
  });
@@ -200,7 +201,7 @@ var Connection = class {
200
201
  this._protocol.stream.on("close", () => {
201
202
  (0, import_log.log)("protocol stream closed", void 0, {
202
203
  F: __dxlog_file,
203
- L: 140,
204
+ L: 153,
204
205
  S: this,
205
206
  C: (f, a) => f(...a)
206
207
  });
@@ -208,7 +209,7 @@ var Connection = class {
208
209
  });
209
210
  (0, import_invariant.invariant)(!this._transport, void 0, {
210
211
  F: __dxlog_file,
211
- L: 144,
212
+ L: 157,
212
213
  S: this,
213
214
  A: [
214
215
  "!this._transport",
@@ -222,6 +223,7 @@ var Connection = class {
222
223
  });
223
224
  this._transport.connected.once(() => {
224
225
  this._changeState(ConnectionState.CONNECTED);
226
+ this._callbacks?.onConnected?.();
225
227
  });
226
228
  this._transport.closed.once(() => {
227
229
  this._transport = void 0;
@@ -243,7 +245,7 @@ var Connection = class {
243
245
  id: this._instanceId
244
246
  }), {
245
247
  F: __dxlog_file,
246
- L: 176,
248
+ L: 190,
247
249
  S: this,
248
250
  C: (f, a) => f(...a)
249
251
  });
@@ -261,7 +263,7 @@ var Connection = class {
261
263
  peerId: this.ownId
262
264
  }, {
263
265
  F: __dxlog_file,
264
- L: 191,
266
+ L: 205,
265
267
  S: this,
266
268
  C: (f, a) => f(...a)
267
269
  });
@@ -270,7 +272,7 @@ var Connection = class {
270
272
  } catch (err2) {
271
273
  import_log.log.catch(err2, void 0, {
272
274
  F: __dxlog_file,
273
- L: 197,
275
+ L: 211,
274
276
  S: this,
275
277
  C: (f, a) => f(...a)
276
278
  });
@@ -280,7 +282,7 @@ var Connection = class {
280
282
  } catch (err2) {
281
283
  import_log.log.catch(err2, void 0, {
282
284
  F: __dxlog_file,
283
- L: 204,
285
+ L: 218,
284
286
  S: this,
285
287
  C: (f, a) => f(...a)
286
288
  });
@@ -289,11 +291,12 @@ var Connection = class {
289
291
  peerId: this.ownId
290
292
  }, {
291
293
  F: __dxlog_file,
292
- L: 207,
294
+ L: 221,
293
295
  S: this,
294
296
  C: (f, a) => f(...a)
295
297
  });
296
298
  this._changeState(ConnectionState.CLOSED);
299
+ this._callbacks?.onClosed?.(err);
297
300
  }
298
301
  _sendSignal(signal) {
299
302
  this._outgoingSignalBuffer.push(signal);
@@ -331,7 +334,7 @@ var Connection = class {
331
334
  err
332
335
  }, {
333
336
  F: __dxlog_file,
334
- L: 243,
337
+ L: 258,
335
338
  S: this,
336
339
  C: (f, a) => f(...a)
337
340
  });
@@ -344,7 +347,7 @@ var Connection = class {
344
347
  async signal(msg) {
345
348
  (0, import_invariant.invariant)(msg.sessionId, void 0, {
346
349
  F: __dxlog_file,
347
- L: 252,
350
+ L: 267,
348
351
  S: this,
349
352
  A: [
350
353
  "msg.sessionId",
@@ -354,7 +357,7 @@ var Connection = class {
354
357
  if (!msg.sessionId.equals(this.sessionId)) {
355
358
  (0, import_log.log)("dropping signal for incorrect session id", void 0, {
356
359
  F: __dxlog_file,
357
- L: 254,
360
+ L: 269,
358
361
  S: this,
359
362
  C: (f, a) => f(...a)
360
363
  });
@@ -362,7 +365,7 @@ var Connection = class {
362
365
  }
363
366
  (0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
364
367
  F: __dxlog_file,
365
- L: 257,
368
+ L: 272,
366
369
  S: this,
367
370
  A: [
368
371
  "msg.data.signal || msg.data.signalBatch",
@@ -371,7 +374,7 @@ var Connection = class {
371
374
  });
372
375
  (0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
373
376
  F: __dxlog_file,
374
- L: 258,
377
+ L: 273,
375
378
  S: this,
376
379
  A: [
377
380
  "msg.author?.equals(this.remoteId)",
@@ -380,7 +383,7 @@ var Connection = class {
380
383
  });
381
384
  (0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
382
385
  F: __dxlog_file,
383
- L: 259,
386
+ L: 274,
384
387
  S: this,
385
388
  A: [
386
389
  "msg.recipient?.equals(this.ownId)",
@@ -401,7 +404,7 @@ var Connection = class {
401
404
  msg: msg.data
402
405
  }, {
403
406
  F: __dxlog_file,
404
- L: 268,
407
+ L: 283,
405
408
  S: this,
406
409
  C: (f, a) => f(...a)
407
410
  });
@@ -409,7 +412,7 @@ var Connection = class {
409
412
  } else {
410
413
  (0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
411
414
  F: __dxlog_file,
412
- L: 271,
415
+ L: 286,
413
416
  S: this,
414
417
  A: [
415
418
  "this._transport",
@@ -422,7 +425,7 @@ var Connection = class {
422
425
  msg: msg.data
423
426
  }, {
424
427
  F: __dxlog_file,
425
- L: 272,
428
+ L: 287,
426
429
  S: this,
427
430
  C: (f, a) => f(...a)
428
431
  });
@@ -437,13 +440,13 @@ var Connection = class {
437
440
  peerId: this.ownId
438
441
  }, {
439
442
  F: __dxlog_file,
440
- L: 279,
443
+ L: 294,
441
444
  S: this,
442
445
  C: (f, a) => f(...a)
443
446
  });
444
447
  (0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
445
448
  F: __dxlog_file,
446
- L: 280,
449
+ L: 295,
447
450
  S: this,
448
451
  A: [
449
452
  "state !== this._state",
@@ -475,7 +478,7 @@ var import_keys2 = require("@dxos/keys");
475
478
  var import_log2 = require("@dxos/log");
476
479
  var import_protocols2 = require("@dxos/protocols");
477
480
  var import_util = require("@dxos/util");
478
- var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
481
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
479
482
  var SwarmMessage = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
480
483
  var SwarmMessenger = class {
481
484
  constructor({ sendMessage, onSignal, onOffer, topic }) {
@@ -717,7 +720,12 @@ function _ts_decorate2(decorators, target, key, desc) {
717
720
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
718
721
  return c > 3 && r && Object.defineProperty(target, key, r), r;
719
722
  }
720
- var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/peer.ts";
723
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
724
+ var ConnectionDisplacedError = class extends import_errors2.SystemError {
725
+ constructor() {
726
+ super("Connection displaced by remote initiator.");
727
+ }
728
+ };
721
729
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
722
730
  var Peer = class {
723
731
  // TODO(burdon): Convert to map?
@@ -735,6 +743,7 @@ var Peer = class {
735
743
  this._ctx = new import_context3.Context();
736
744
  this.advertizing = false;
737
745
  this.initiating = false;
746
+ this.connectionDisplaced = new import_async2.Event();
738
747
  }
739
748
  /**
740
749
  * Respond to remote offer.
@@ -750,12 +759,12 @@ var Peer = class {
750
759
  sessionId: this.connection?.sessionId
751
760
  }, {
752
761
  F: __dxlog_file3,
753
- L: 108,
762
+ L: 116,
754
763
  S: this,
755
764
  C: (f, a) => f(...a)
756
765
  });
757
766
  if (this.connection) {
758
- await this.closeConnection(new Error("Connection displaced by remote initiator."));
767
+ await this.closeConnection(new ConnectionDisplacedError());
759
768
  }
760
769
  } else {
761
770
  return {
@@ -767,7 +776,7 @@ var Peer = class {
767
776
  if (!this.connection) {
768
777
  (0, import_invariant3.invariant)(message.sessionId, void 0, {
769
778
  F: __dxlog_file3,
770
- L: 128,
779
+ L: 136,
771
780
  S: this,
772
781
  A: [
773
782
  "message.sessionId",
@@ -787,7 +796,7 @@ var Peer = class {
787
796
  err
788
797
  }, {
789
798
  F: __dxlog_file3,
790
- L: 136,
799
+ L: 144,
791
800
  S: this,
792
801
  C: (f, a) => f(...a)
793
802
  });
@@ -809,7 +818,7 @@ var Peer = class {
809
818
  async initiateConnection() {
810
819
  (0, import_invariant3.invariant)(!this.initiating, "Initiation in progress.", {
811
820
  F: __dxlog_file3,
812
- L: 153,
821
+ L: 161,
813
822
  S: this,
814
823
  A: [
815
824
  "!this.initiating",
@@ -818,7 +827,7 @@ var Peer = class {
818
827
  });
819
828
  (0, import_invariant3.invariant)(!this.connection, "Already connected.", {
820
829
  F: __dxlog_file3,
821
- L: 154,
830
+ L: 162,
822
831
  S: this,
823
832
  A: [
824
833
  "!this.connection",
@@ -833,7 +842,7 @@ var Peer = class {
833
842
  sessionId
834
843
  }, {
835
844
  F: __dxlog_file3,
836
- L: 156,
845
+ L: 164,
837
846
  S: this,
838
847
  C: (f, a) => f(...a)
839
848
  });
@@ -857,14 +866,14 @@ var Peer = class {
857
866
  remoteId: this.id
858
867
  }, {
859
868
  F: __dxlog_file3,
860
- L: 171,
869
+ L: 179,
861
870
  S: this,
862
871
  C: (f, a) => f(...a)
863
872
  });
864
873
  if (connection.state !== ConnectionState.INITIAL) {
865
874
  (0, import_log3.log)("ignoring response", void 0, {
866
875
  F: __dxlog_file3,
867
- L: 173,
876
+ L: 181,
868
877
  S: this,
869
878
  C: (f, a) => f(...a)
870
879
  });
@@ -884,7 +893,7 @@ var Peer = class {
884
893
  remoteId: this.id
885
894
  }, {
886
895
  F: __dxlog_file3,
887
- L: 184,
896
+ L: 192,
888
897
  S: this,
889
898
  C: (f, a) => f(...a)
890
899
  });
@@ -907,13 +916,13 @@ var Peer = class {
907
916
  sessionId
908
917
  }, {
909
918
  F: __dxlog_file3,
910
- L: 198,
919
+ L: 206,
911
920
  S: this,
912
921
  C: (f, a) => f(...a)
913
922
  });
914
923
  (0, import_invariant3.invariant)(!this.connection, "Already connected.", {
915
924
  F: __dxlog_file3,
916
- L: 205,
925
+ L: 213,
917
926
  S: this,
918
927
  A: [
919
928
  "!this.connection",
@@ -934,14 +943,9 @@ var Peer = class {
934
943
  remotePeerId: this.id,
935
944
  topic: this.topic
936
945
  }),
937
- this._transportFactory
938
- );
939
- this._callbacks.onInitiated(connection);
940
- void this._connectionCtx?.dispose();
941
- this._connectionCtx = this._ctx.derive();
942
- connection.stateChanged.on((state) => {
943
- switch (state) {
944
- case ConnectionState.CONNECTED: {
946
+ this._transportFactory,
947
+ {
948
+ onConnected: () => {
945
949
  this.availableToConnect = true;
946
950
  this._lastConnectionTime = Date.now();
947
951
  this._callbacks.onConnected();
@@ -954,13 +958,12 @@ var Peer = class {
954
958
  initiator
955
959
  }, {
956
960
  F: __dxlog_file3,
957
- L: 231,
961
+ L: 232,
958
962
  S: this,
959
963
  C: (f, a) => f(...a)
960
964
  });
961
- break;
962
- }
963
- case ConnectionState.CLOSED: {
965
+ },
966
+ onClosed: (err) => {
964
967
  (0, import_log3.log)("connection closed", {
965
968
  topic: this.topic,
966
969
  peerId: this.localPeerId,
@@ -968,13 +971,14 @@ var Peer = class {
968
971
  initiator
969
972
  }, {
970
973
  F: __dxlog_file3,
971
- L: 242,
974
+ L: 241,
972
975
  S: this,
973
976
  C: (f, a) => f(...a)
974
977
  });
978
+ this._connectionLimiter.doneConnecting(sessionId);
975
979
  (0, import_invariant3.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
976
980
  F: __dxlog_file3,
977
- L: 243,
981
+ L: 246,
978
982
  S: this,
979
983
  A: [
980
984
  "this.connection === connection",
@@ -989,27 +993,32 @@ var Peer = class {
989
993
  initiator
990
994
  }, {
991
995
  F: __dxlog_file3,
992
- L: 245,
996
+ L: 248,
993
997
  S: this,
994
998
  C: (f, a) => f(...a)
995
999
  });
996
- if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
997
- this._availableAfter = 0;
1000
+ if (err instanceof ConnectionDisplacedError) {
1001
+ this.connectionDisplaced.emit(this.connection);
998
1002
  } else {
999
- this.availableToConnect = false;
1000
- this._availableAfter = increaseInterval(this._availableAfter);
1003
+ if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
1004
+ this._availableAfter = 0;
1005
+ } else {
1006
+ this.availableToConnect = false;
1007
+ this._availableAfter = increaseInterval(this._availableAfter);
1008
+ }
1009
+ this._callbacks.onDisconnected();
1010
+ (0, import_async2.scheduleTask)(this._connectionCtx, () => {
1011
+ this.availableToConnect = true;
1012
+ this._callbacks.onPeerAvailable();
1013
+ }, this._availableAfter);
1001
1014
  }
1002
1015
  this.connection = void 0;
1003
- this._callbacks.onDisconnected();
1004
- this._connectionLimiter.doneConnecting(sessionId);
1005
- (0, import_async2.scheduleTask)(this._connectionCtx, () => {
1006
- this.availableToConnect = true;
1007
- this._callbacks.onPeerAvailable();
1008
- }, this._availableAfter);
1009
- break;
1010
1016
  }
1011
1017
  }
1012
- });
1018
+ );
1019
+ this._callbacks.onInitiated(connection);
1020
+ void this._connectionCtx?.dispose();
1021
+ this._connectionCtx = this._ctx.derive();
1013
1022
  connection.errors.handle((err) => {
1014
1023
  import_log3.log.warn("connection error", {
1015
1024
  topic: this.topic,
@@ -1019,7 +1028,7 @@ var Peer = class {
1019
1028
  err
1020
1029
  }, {
1021
1030
  F: __dxlog_file3,
1022
- L: 279,
1031
+ L: 288,
1023
1032
  S: this,
1024
1033
  C: (f, a) => f(...a)
1025
1034
  });
@@ -1032,7 +1041,7 @@ var Peer = class {
1032
1041
  err
1033
1042
  }, {
1034
1043
  F: __dxlog_file3,
1035
- L: 280,
1044
+ L: 289,
1036
1045
  S: this,
1037
1046
  C: (f, a) => f(...a)
1038
1047
  });
@@ -1051,7 +1060,7 @@ var Peer = class {
1051
1060
  sessionId: connection.sessionId
1052
1061
  }, {
1053
1062
  F: __dxlog_file3,
1054
- L: 303,
1063
+ L: 314,
1055
1064
  S: this,
1056
1065
  C: (f, a) => f(...a)
1057
1066
  });
@@ -1061,7 +1070,7 @@ var Peer = class {
1061
1070
  sessionId: connection.sessionId
1062
1071
  }, {
1063
1072
  F: __dxlog_file3,
1064
- L: 309,
1073
+ L: 320,
1065
1074
  S: this,
1066
1075
  C: (f, a) => f(...a)
1067
1076
  });
@@ -1072,7 +1081,7 @@ var Peer = class {
1072
1081
  message
1073
1082
  }, {
1074
1083
  F: __dxlog_file3,
1075
- L: 314,
1084
+ L: 325,
1076
1085
  S: this,
1077
1086
  C: (f, a) => f(...a)
1078
1087
  });
@@ -1087,7 +1096,7 @@ var Peer = class {
1087
1096
  topic: this.topic
1088
1097
  }, {
1089
1098
  F: __dxlog_file3,
1090
- L: 324,
1099
+ L: 335,
1091
1100
  S: this,
1092
1101
  C: (f, a) => f(...a)
1093
1102
  });
@@ -1121,13 +1130,13 @@ function _ts_decorate3(decorators, target, key, desc) {
1121
1130
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1122
1131
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1123
1132
  }
1124
- var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1133
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1125
1134
  var INITIATION_DELAY = 100;
1126
1135
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
1127
1136
  var Swarm = class {
1128
1137
  // TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
1129
1138
  // TODO(burdon): Split up properties.
1130
- constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter) {
1139
+ constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
1131
1140
  this._topic = _topic;
1132
1141
  this._ownPeerId = _ownPeerId;
1133
1142
  this._topology = _topology;
@@ -1136,6 +1145,7 @@ var Swarm = class {
1136
1145
  this._transportFactory = _transportFactory;
1137
1146
  this._label = _label;
1138
1147
  this._connectionLimiter = _connectionLimiter;
1148
+ this._initiationDelay = _initiationDelay;
1139
1149
  this._ctx = new import_context4.Context();
1140
1150
  this._listeningHandle = void 0;
1141
1151
  this._peers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
@@ -1152,7 +1162,7 @@ var Swarm = class {
1152
1162
  }
1153
1163
  }), {
1154
1164
  F: __dxlog_file4,
1155
- L: 87,
1165
+ L: 88,
1156
1166
  S: this,
1157
1167
  C: (f, a) => f(...a)
1158
1168
  });
@@ -1160,7 +1170,7 @@ var Swarm = class {
1160
1170
  peerId: _ownPeerId
1161
1171
  }, {
1162
1172
  F: __dxlog_file4,
1163
- L: 91,
1173
+ L: 92,
1164
1174
  S: this,
1165
1175
  C: (f, a) => f(...a)
1166
1176
  });
@@ -1175,7 +1185,7 @@ var Swarm = class {
1175
1185
  id: this._instanceId
1176
1186
  }), {
1177
1187
  F: __dxlog_file4,
1178
- L: 100,
1188
+ L: 101,
1179
1189
  S: this,
1180
1190
  C: (f, a) => f(...a)
1181
1191
  });
@@ -1198,7 +1208,7 @@ var Swarm = class {
1198
1208
  async open() {
1199
1209
  (0, import_invariant4.invariant)(!this._listeningHandle, void 0, {
1200
1210
  F: __dxlog_file4,
1201
- L: 127,
1211
+ L: 128,
1202
1212
  S: this,
1203
1213
  A: [
1204
1214
  "!this._listeningHandle",
@@ -1213,7 +1223,7 @@ var Swarm = class {
1213
1223
  err
1214
1224
  }, {
1215
1225
  F: __dxlog_file4,
1216
- L: 134,
1226
+ L: 135,
1217
1227
  S: this,
1218
1228
  C: (f, a) => f(...a)
1219
1229
  }));
@@ -1223,7 +1233,7 @@ var Swarm = class {
1223
1233
  async destroy() {
1224
1234
  (0, import_log4.log)("destroying...", void 0, {
1225
1235
  F: __dxlog_file4,
1226
- L: 140,
1236
+ L: 141,
1227
1237
  S: this,
1228
1238
  C: (f, a) => f(...a)
1229
1239
  });
@@ -1234,7 +1244,7 @@ var Swarm = class {
1234
1244
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
1235
1245
  (0, import_log4.log)("destroyed", void 0, {
1236
1246
  F: __dxlog_file4,
1237
- L: 147,
1247
+ L: 148,
1238
1248
  S: this,
1239
1249
  C: (f, a) => f(...a)
1240
1250
  });
@@ -1242,7 +1252,7 @@ var Swarm = class {
1242
1252
  async setTopology(topology) {
1243
1253
  (0, import_invariant4.invariant)(!this._ctx.disposed, "Swarm is offline", {
1244
1254
  F: __dxlog_file4,
1245
- L: 151,
1255
+ L: 152,
1246
1256
  S: this,
1247
1257
  A: [
1248
1258
  "!this._ctx.disposed",
@@ -1257,7 +1267,7 @@ var Swarm = class {
1257
1267
  topology: getClassName(topology)
1258
1268
  }, {
1259
1269
  F: __dxlog_file4,
1260
- L: 155,
1270
+ L: 156,
1261
1271
  S: this,
1262
1272
  C: (f, a) => f(...a)
1263
1273
  });
@@ -1271,14 +1281,14 @@ var Swarm = class {
1271
1281
  swarmEvent
1272
1282
  }, {
1273
1283
  F: __dxlog_file4,
1274
- L: 168,
1284
+ L: 169,
1275
1285
  S: this,
1276
1286
  C: (f, a) => f(...a)
1277
1287
  });
1278
1288
  if (this._ctx.disposed) {
1279
1289
  (0, import_log4.log)("swarm event ignored for disposed swarm", void 0, {
1280
1290
  F: __dxlog_file4,
1281
- L: 171,
1291
+ L: 172,
1282
1292
  S: this,
1283
1293
  C: (f, a) => f(...a)
1284
1294
  });
@@ -1290,7 +1300,7 @@ var Swarm = class {
1290
1300
  peerId
1291
1301
  }, {
1292
1302
  F: __dxlog_file4,
1293
- L: 177,
1303
+ L: 178,
1294
1304
  S: this,
1295
1305
  C: (f, a) => f(...a)
1296
1306
  });
@@ -1305,7 +1315,7 @@ var Swarm = class {
1305
1315
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
1306
1316
  void this._destroyPeer(peer.id).catch((err) => import_log4.log.catch(err, void 0, {
1307
1317
  F: __dxlog_file4,
1308
- L: 188,
1318
+ L: 189,
1309
1319
  S: this,
1310
1320
  C: (f, a) => f(...a)
1311
1321
  }));
@@ -1319,14 +1329,14 @@ var Swarm = class {
1319
1329
  message
1320
1330
  }, {
1321
1331
  F: __dxlog_file4,
1322
- L: 198,
1332
+ L: 199,
1323
1333
  S: this,
1324
1334
  C: (f, a) => f(...a)
1325
1335
  });
1326
1336
  if (this._ctx.disposed) {
1327
1337
  (0, import_log4.log)("ignored for disposed swarm", void 0, {
1328
1338
  F: __dxlog_file4,
1329
- L: 200,
1339
+ L: 201,
1330
1340
  S: this,
1331
1341
  C: (f, a) => f(...a)
1332
1342
  });
@@ -1336,7 +1346,7 @@ var Swarm = class {
1336
1346
  }
1337
1347
  (0, import_invariant4.invariant)(message.author, void 0, {
1338
1348
  F: __dxlog_file4,
1339
- L: 205,
1349
+ L: 206,
1340
1350
  S: this,
1341
1351
  A: [
1342
1352
  "message.author",
@@ -1348,7 +1358,7 @@ var Swarm = class {
1348
1358
  message
1349
1359
  }, {
1350
1360
  F: __dxlog_file4,
1351
- L: 207,
1361
+ L: 208,
1352
1362
  S: this,
1353
1363
  C: (f, a) => f(...a)
1354
1364
  });
@@ -1361,7 +1371,7 @@ var Swarm = class {
1361
1371
  message
1362
1372
  }, {
1363
1373
  F: __dxlog_file4,
1364
- L: 211,
1374
+ L: 212,
1365
1375
  S: this,
1366
1376
  C: (f, a) => f(...a)
1367
1377
  });
@@ -1379,14 +1389,14 @@ var Swarm = class {
1379
1389
  message
1380
1390
  }, {
1381
1391
  F: __dxlog_file4,
1382
- L: 222,
1392
+ L: 223,
1383
1393
  S: this,
1384
1394
  C: (f, a) => f(...a)
1385
1395
  });
1386
1396
  if (this._ctx.disposed) {
1387
1397
  import_log4.log.info("ignored for offline swarm", void 0, {
1388
1398
  F: __dxlog_file4,
1389
- L: 224,
1399
+ L: 225,
1390
1400
  S: this,
1391
1401
  C: (f, a) => f(...a)
1392
1402
  });
@@ -1394,7 +1404,7 @@ var Swarm = class {
1394
1404
  }
1395
1405
  (0, import_invariant4.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1396
1406
  F: __dxlog_file4,
1397
- L: 227,
1407
+ L: 228,
1398
1408
  S: this,
1399
1409
  A: [
1400
1410
  "message.recipient?.equals(this._ownPeerId)",
@@ -1403,7 +1413,7 @@ var Swarm = class {
1403
1413
  });
1404
1414
  (0, import_invariant4.invariant)(message.topic?.equals(this._topic), void 0, {
1405
1415
  F: __dxlog_file4,
1406
- L: 231,
1416
+ L: 232,
1407
1417
  S: this,
1408
1418
  A: [
1409
1419
  "message.topic?.equals(this._topic)",
@@ -1412,7 +1422,7 @@ var Swarm = class {
1412
1422
  });
1413
1423
  (0, import_invariant4.invariant)(message.author, void 0, {
1414
1424
  F: __dxlog_file4,
1415
- L: 232,
1425
+ L: 233,
1416
1426
  S: this,
1417
1427
  A: [
1418
1428
  "message.author",
@@ -1472,7 +1482,7 @@ var Swarm = class {
1472
1482
  async _destroyPeer(peerId) {
1473
1483
  (0, import_invariant4.invariant)(this._peers.has(peerId), void 0, {
1474
1484
  F: __dxlog_file4,
1475
- L: 302,
1485
+ L: 303,
1476
1486
  S: this,
1477
1487
  A: [
1478
1488
  "this._peers.has(peerId)",
@@ -1499,7 +1509,7 @@ var Swarm = class {
1499
1509
  } catch (err) {
1500
1510
  (0, import_log4.log)("initiation error", err, {
1501
1511
  F: __dxlog_file4,
1502
- L: 328,
1512
+ L: 329,
1503
1513
  S: this,
1504
1514
  C: (f, a) => f(...a)
1505
1515
  });
@@ -1527,11 +1537,11 @@ var Swarm = class {
1527
1537
  remoteId
1528
1538
  }, {
1529
1539
  F: __dxlog_file4,
1530
- L: 355,
1540
+ L: 356,
1531
1541
  S: this,
1532
1542
  C: (f, a) => f(...a)
1533
1543
  });
1534
- await (0, import_async3.sleep)(INITIATION_DELAY);
1544
+ await (0, import_async3.sleep)(this._initiationDelay);
1535
1545
  }
1536
1546
  if (ctx.disposed) {
1537
1547
  return;
@@ -1544,7 +1554,7 @@ var Swarm = class {
1544
1554
  remoteId
1545
1555
  }, {
1546
1556
  F: __dxlog_file4,
1547
- L: 369,
1557
+ L: 370,
1548
1558
  S: this,
1549
1559
  C: (f, a) => f(...a)
1550
1560
  });
@@ -1554,7 +1564,7 @@ var Swarm = class {
1554
1564
  remoteId
1555
1565
  }, {
1556
1566
  F: __dxlog_file4,
1557
- L: 372,
1567
+ L: 373,
1558
1568
  S: this,
1559
1569
  C: (f, a) => f(...a)
1560
1570
  });
@@ -1594,7 +1604,7 @@ var import_async4 = require("@dxos/async");
1594
1604
  var import_keys5 = require("@dxos/keys");
1595
1605
  var import_log5 = require("@dxos/log");
1596
1606
  var import_util3 = require("@dxos/util");
1597
- var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1607
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1598
1608
  var SwarmMapper = class {
1599
1609
  get peers() {
1600
1610
  return Array.from(this._peers.values());
@@ -1667,7 +1677,7 @@ var import_invariant5 = require("@dxos/invariant");
1667
1677
  var import_keys6 = require("@dxos/keys");
1668
1678
  var import_log6 = require("@dxos/log");
1669
1679
  var import_util4 = require("@dxos/util");
1670
- var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1680
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1671
1681
  var MAX_CONCURRENT_INITIATING_CONNECTIONS = 10;
1672
1682
  var ConnectionLimiter = class {
1673
1683
  constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
@@ -1808,7 +1818,7 @@ var ConnectionLog = class {
1808
1818
  };
1809
1819
 
1810
1820
  // packages/core/mesh/network-manager/src/network-manager.ts
1811
- var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/network-manager.ts";
1821
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
1812
1822
  var NetworkManager = class {
1813
1823
  constructor({ transportFactory, signalManager, log: log1 }) {
1814
1824
  /**
@@ -2044,7 +2054,7 @@ var NetworkManager = class {
2044
2054
 
2045
2055
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
2046
2056
  var import_invariant7 = require("@dxos/invariant");
2047
- var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2057
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2048
2058
  var FullyConnectedTopology = class {
2049
2059
  toString() {
2050
2060
  return "FullyConnectedTopology";
@@ -2110,7 +2120,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2110
2120
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2111
2121
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2112
2122
  }
2113
- var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2123
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2114
2124
  var MEMORY_TRANSPORT_DELAY = 1;
2115
2125
  var createStreamDelay = (delay) => {
2116
2126
  return new import_node_stream.Transform({
@@ -2295,7 +2305,7 @@ try {
2295
2305
  }
2296
2306
 
2297
2307
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
2298
- var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
2308
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
2299
2309
  var WebRTCTransport = class {
2300
2310
  constructor(params) {
2301
2311
  this.params = params;
@@ -2436,7 +2446,7 @@ var import_keys11 = require("@dxos/keys");
2436
2446
  var import_log12 = require("@dxos/log");
2437
2447
  var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
2438
2448
  var import_util8 = require("@dxos/util");
2439
- var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2449
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2440
2450
  var WebRTCTransportService = class {
2441
2451
  // prettier-ignore
2442
2452
  constructor(_webrtcConfig) {
@@ -2568,7 +2578,7 @@ var import_keys12 = require("@dxos/keys");
2568
2578
  var import_log13 = require("@dxos/log");
2569
2579
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
2570
2580
  var import_util9 = require("@dxos/util");
2571
- var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2581
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2572
2582
  var WebRTCTransportProxy = class {
2573
2583
  // prettier-ignore
2574
2584
  constructor(_params) {
@@ -2741,7 +2751,7 @@ var createTeleportProtocolFactory = (onConnection) => {
2741
2751
  };
2742
2752
 
2743
2753
  // packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts
2744
- var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts";
2754
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts";
2745
2755
  var TestWireProtocol = class {
2746
2756
  constructor(peerId, _extensionFactory = () => []) {
2747
2757
  this.peerId = peerId;