@dxos/network-manager 0.1.55 → 0.1.56-main.09ca29d

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 (52) hide show
  1. package/dist/lib/browser/{chunk-IBLQYMBY.mjs → chunk-FC6CWDES.mjs} +823 -294
  2. package/dist/lib/browser/chunk-FC6CWDES.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 +2 -2
  6. package/dist/lib/node/index.cjs +843 -312
  7. package/dist/lib/node/index.cjs.map +4 -4
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/testing/index.cjs +772 -301
  10. package/dist/lib/node/testing/index.cjs.map +4 -4
  11. package/dist/types/src/network-manager.d.ts +1 -1
  12. package/dist/types/src/network-manager.d.ts.map +1 -1
  13. package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
  14. package/dist/types/src/swarm/connection-limiter.d.ts +28 -0
  15. package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -0
  16. package/dist/types/src/swarm/connection-limiter.test.d.ts +2 -0
  17. package/dist/types/src/swarm/connection-limiter.test.d.ts.map +1 -0
  18. package/dist/types/src/swarm/connection.d.ts +1 -1
  19. package/dist/types/src/swarm/connection.d.ts.map +1 -1
  20. package/dist/types/src/swarm/connection.test.d.ts +2 -0
  21. package/dist/types/src/swarm/connection.test.d.ts.map +1 -0
  22. package/dist/types/src/swarm/index.d.ts +1 -0
  23. package/dist/types/src/swarm/index.d.ts.map +1 -1
  24. package/dist/types/src/swarm/peer.d.ts +3 -1
  25. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  26. package/dist/types/src/swarm/swarm.d.ts +3 -1
  27. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  28. package/dist/types/src/topology/fully-connected-topology.d.ts.map +1 -1
  29. package/dist/types/src/topology/star-topology.d.ts.map +1 -1
  30. package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
  31. package/dist/types/src/transport/webrtc-transport-proxy.d.ts.map +1 -1
  32. package/dist/types/src/transport/webrtc-transport-service.d.ts.map +1 -1
  33. package/dist/types/src/transport/webrtc-transport.d.ts.map +1 -1
  34. package/package.json +18 -18
  35. package/src/network-manager.ts +19 -6
  36. package/src/signal/swarm-messenger.ts +1 -2
  37. package/src/swarm/connection-limiter.test.ts +44 -0
  38. package/src/swarm/connection-limiter.ts +72 -0
  39. package/src/swarm/connection.test.ts +72 -0
  40. package/src/swarm/connection.ts +18 -5
  41. package/src/swarm/index.ts +1 -0
  42. package/src/swarm/peer.ts +46 -9
  43. package/src/swarm/swarm.test.ts +140 -90
  44. package/src/swarm/swarm.ts +4 -3
  45. package/src/topology/fully-connected-topology.ts +1 -2
  46. package/src/topology/mmst-topology.ts +1 -1
  47. package/src/topology/star-topology.ts +1 -2
  48. package/src/transport/memory-transport.ts +1 -1
  49. package/src/transport/webrtc-transport-proxy.ts +14 -12
  50. package/src/transport/webrtc-transport-service.ts +31 -8
  51. package/src/transport/webrtc-transport.ts +1 -1
  52. package/dist/lib/browser/chunk-IBLQYMBY.mjs.map +0 -7
@@ -8,11 +8,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
  });
9
9
 
10
10
  // packages/core/mesh/network-manager/src/swarm/connection.ts
11
- import invariant from "tiny-invariant";
12
11
  import { DeferredTask, Event, sleep, synchronized } from "@dxos/async";
13
12
  import { Context, cancelWithContext } from "@dxos/context";
14
13
  import { ErrorStream } from "@dxos/debug";
15
14
  import { CancelledError } from "@dxos/errors";
15
+ import { invariant } from "@dxos/invariant";
16
16
  import { PublicKey } from "@dxos/keys";
17
17
  import { log } from "@dxos/log";
18
18
  import { trace } from "@dxos/protocols";
@@ -26,7 +26,7 @@ function _ts_decorate(decorators, target, key, desc) {
26
26
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
27
27
  return c > 3 && r && Object.defineProperty(target, key, r), r;
28
28
  }
29
- var __dxlog_file = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection.ts";
29
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
30
30
  var STARTING_SIGNALLING_DELAY = 10;
31
31
  var MAX_SIGNALLING_DELAY = 300;
32
32
  var ConnectionState;
@@ -84,6 +84,18 @@ var Connection = class {
84
84
  await this._flushSignalBuffer();
85
85
  });
86
86
  this._signallingDelay = STARTING_SIGNALLING_DELAY;
87
+ log.trace("dxos.mesh.connection.construct", {
88
+ sessionId: this.sessionId,
89
+ topic: this.topic,
90
+ localPeerId: this.ownId,
91
+ remotePeerId: this.remoteId,
92
+ initiator: this.initiator
93
+ }, {
94
+ F: __dxlog_file,
95
+ L: 95,
96
+ S: this,
97
+ C: (f, a) => f(...a)
98
+ });
87
99
  }
88
100
  get state() {
89
101
  return this._state;
@@ -97,14 +109,33 @@ var Connection = class {
97
109
  /**
98
110
  * Create an underlying transport and prepares it for the connection.
99
111
  */
100
- // TODO(burdon): Make async?
101
- openConnection() {
102
- invariant(this._state === ConnectionState.INITIAL, "Invalid state.");
112
+ async openConnection() {
113
+ invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
114
+ F: __dxlog_file,
115
+ L: 120,
116
+ S: this,
117
+ A: [
118
+ "this._state === ConnectionState.INITIAL",
119
+ "'Invalid state.'"
120
+ ]
121
+ });
103
122
  log.trace("dxos.mesh.connection.open-connection", trace.begin({
104
123
  id: this._instanceId
105
124
  }), {
106
125
  F: __dxlog_file,
107
- L: 115,
126
+ L: 121,
127
+ S: this,
128
+ C: (f, a) => f(...a)
129
+ });
130
+ log.trace("dxos.mesh.connection.open", {
131
+ sessionId: this.sessionId,
132
+ topic: this.topic,
133
+ localPeerId: this.ownId,
134
+ remotePeerId: this.remoteId,
135
+ initiator: this.initiator
136
+ }, {
137
+ F: __dxlog_file,
138
+ L: 122,
108
139
  S: this,
109
140
  C: (f, a) => f(...a)
110
141
  });
@@ -115,13 +146,21 @@ var Connection = class {
115
146
  this._protocol.stream.on("close", () => {
116
147
  log("protocol stream closed", void 0, {
117
148
  F: __dxlog_file,
118
- L: 126,
149
+ L: 139,
119
150
  S: this,
120
151
  C: (f, a) => f(...a)
121
152
  });
122
153
  this.close().catch((err) => this.errors.raise(err));
123
154
  });
124
- invariant(!this._transport);
155
+ invariant(!this._transport, void 0, {
156
+ F: __dxlog_file,
157
+ L: 143,
158
+ S: this,
159
+ A: [
160
+ "!this._transport",
161
+ ""
162
+ ]
163
+ });
125
164
  this._transport = this._transportFactory.createTransport({
126
165
  initiator: this.initiator,
127
166
  stream: this._protocol.stream,
@@ -147,7 +186,7 @@ var Connection = class {
147
186
  id: this._instanceId
148
187
  }), {
149
188
  F: __dxlog_file,
150
- L: 159,
189
+ L: 172,
151
190
  S: this,
152
191
  C: (f, a) => f(...a)
153
192
  });
@@ -163,7 +202,7 @@ var Connection = class {
163
202
  peerId: this.ownId
164
203
  }, {
165
204
  F: __dxlog_file,
166
- L: 171,
205
+ L: 184,
167
206
  S: this,
168
207
  C: (f, a) => f(...a)
169
208
  });
@@ -172,7 +211,7 @@ var Connection = class {
172
211
  } catch (err) {
173
212
  log.catch(err, void 0, {
174
213
  F: __dxlog_file,
175
- L: 177,
214
+ L: 190,
176
215
  S: this,
177
216
  C: (f, a) => f(...a)
178
217
  });
@@ -182,7 +221,7 @@ var Connection = class {
182
221
  } catch (err) {
183
222
  log.catch(err, void 0, {
184
223
  F: __dxlog_file,
185
- L: 184,
224
+ L: 197,
186
225
  S: this,
187
226
  C: (f, a) => f(...a)
188
227
  });
@@ -191,7 +230,7 @@ var Connection = class {
191
230
  peerId: this.ownId
192
231
  }, {
193
232
  F: __dxlog_file,
194
- L: 187,
233
+ L: 200,
195
234
  S: this,
196
235
  C: (f, a) => f(...a)
197
236
  });
@@ -231,7 +270,7 @@ var Connection = class {
231
270
  err
232
271
  }, {
233
272
  F: __dxlog_file,
234
- L: 221,
273
+ L: 234,
235
274
  S: this,
236
275
  C: (f, a) => f(...a)
237
276
  });
@@ -243,19 +282,51 @@ var Connection = class {
243
282
  */
244
283
  async signal(msg) {
245
284
  var _a, _b, _c;
246
- invariant(msg.sessionId);
285
+ invariant(msg.sessionId, void 0, {
286
+ F: __dxlog_file,
287
+ L: 243,
288
+ S: this,
289
+ A: [
290
+ "msg.sessionId",
291
+ ""
292
+ ]
293
+ });
247
294
  if (!msg.sessionId.equals(this.sessionId)) {
248
295
  log("dropping signal for incorrect session id", void 0, {
249
296
  F: __dxlog_file,
250
- L: 232,
297
+ L: 245,
251
298
  S: this,
252
299
  C: (f, a) => f(...a)
253
300
  });
254
301
  return;
255
302
  }
256
- invariant(msg.data.signal || msg.data.signalBatch);
257
- invariant((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
258
- invariant((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
303
+ invariant(msg.data.signal || msg.data.signalBatch, void 0, {
304
+ F: __dxlog_file,
305
+ L: 248,
306
+ S: this,
307
+ A: [
308
+ "msg.data.signal || msg.data.signalBatch",
309
+ ""
310
+ ]
311
+ });
312
+ invariant((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId), void 0, {
313
+ F: __dxlog_file,
314
+ L: 249,
315
+ S: this,
316
+ A: [
317
+ "msg.author?.equals(this.remoteId)",
318
+ ""
319
+ ]
320
+ });
321
+ invariant((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId), void 0, {
322
+ F: __dxlog_file,
323
+ L: 250,
324
+ S: this,
325
+ A: [
326
+ "msg.recipient?.equals(this.ownId)",
327
+ ""
328
+ ]
329
+ });
259
330
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
260
331
  msg.data.signal
261
332
  ];
@@ -270,20 +341,28 @@ var Connection = class {
270
341
  msg: msg.data
271
342
  }, {
272
343
  F: __dxlog_file,
273
- L: 246,
344
+ L: 259,
274
345
  S: this,
275
346
  C: (f, a) => f(...a)
276
347
  });
277
348
  this._incomingSignalBuffer.push(signal);
278
349
  } else {
279
- invariant(this._transport, "Connection not ready to accept signals.");
350
+ invariant(this._transport, "Connection not ready to accept signals.", {
351
+ F: __dxlog_file,
352
+ L: 262,
353
+ S: this,
354
+ A: [
355
+ "this._transport",
356
+ "'Connection not ready to accept signals.'"
357
+ ]
358
+ });
280
359
  log("received signal", {
281
360
  peerId: this.ownId,
282
361
  remoteId: this.remoteId,
283
362
  msg: msg.data
284
363
  }, {
285
364
  F: __dxlog_file,
286
- L: 250,
365
+ L: 263,
287
366
  S: this,
288
367
  C: (f, a) => f(...a)
289
368
  });
@@ -298,11 +377,19 @@ var Connection = class {
298
377
  peerId: this.ownId
299
378
  }, {
300
379
  F: __dxlog_file,
301
- L: 257,
380
+ L: 270,
302
381
  S: this,
303
382
  C: (f, a) => f(...a)
304
383
  });
305
- invariant(state !== this._state, "Already in this state.");
384
+ invariant(state !== this._state, "Already in this state.", {
385
+ F: __dxlog_file,
386
+ L: 271,
387
+ S: this,
388
+ A: [
389
+ "state !== this._state",
390
+ "'Already in this state.'"
391
+ ]
392
+ });
306
393
  this._state = state;
307
394
  this.stateChanged.emit(state);
308
395
  }
@@ -312,13 +399,13 @@ _ts_decorate([
312
399
  ], Connection.prototype, "close", null);
313
400
 
314
401
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
315
- import invariant2 from "tiny-invariant";
316
402
  import { Context as Context2 } from "@dxos/context";
403
+ import { invariant as invariant2 } from "@dxos/invariant";
317
404
  import { PublicKey as PublicKey2 } from "@dxos/keys";
318
405
  import { log as log2 } from "@dxos/log";
319
406
  import { schema } from "@dxos/protocols";
320
407
  import { ComplexMap } from "@dxos/util";
321
- var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
408
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
322
409
  var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
323
410
  var SwarmMessenger = class {
324
411
  constructor({ sendMessage, onSignal, onOffer, topic }) {
@@ -344,7 +431,7 @@ var SwarmMessenger = class {
344
431
  msg: message
345
432
  }, {
346
433
  F: __dxlog_file2,
347
- L: 70,
434
+ L: 69,
348
435
  S: this,
349
436
  C: (f, a) => f(...a)
350
437
  });
@@ -373,7 +460,7 @@ var SwarmMessenger = class {
373
460
  message
374
461
  }, {
375
462
  F: __dxlog_file2,
376
- L: 81,
463
+ L: 80,
377
464
  S: this,
378
465
  C: (f, a) => f(...a)
379
466
  });
@@ -381,7 +468,15 @@ var SwarmMessenger = class {
381
468
  }
382
469
  async signal(message) {
383
470
  var _a, _b;
384
- invariant2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
471
+ invariant2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message", {
472
+ F: __dxlog_file2,
473
+ L: 85,
474
+ S: this,
475
+ A: [
476
+ "message.data?.signal || message.data?.signalBatch",
477
+ "'Invalid message'"
478
+ ]
479
+ });
385
480
  await this._sendReliableMessage({
386
481
  author: message.author,
387
482
  recipient: message.recipient,
@@ -417,7 +512,7 @@ var SwarmMessenger = class {
417
512
  msg: networkMessage
418
513
  }, {
419
514
  F: __dxlog_file2,
420
- L: 124,
515
+ L: 123,
421
516
  S: this,
422
517
  C: (f, a) => f(...a)
423
518
  });
@@ -432,16 +527,32 @@ var SwarmMessenger = class {
432
527
  }
433
528
  async _resolveAnswers(message) {
434
529
  var _a, _b, _c;
435
- invariant2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
530
+ invariant2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId", {
531
+ F: __dxlog_file2,
532
+ L: 135,
533
+ S: this,
534
+ A: [
535
+ "message.data?.answer?.offerMessageId",
536
+ "'No offerMessageId'"
537
+ ]
538
+ });
436
539
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
437
540
  if (offerRecord) {
438
541
  this._offerRecords.delete(message.data.answer.offerMessageId);
439
- invariant2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
542
+ invariant2((_c = message.data) == null ? void 0 : _c.answer, "No answer", {
543
+ F: __dxlog_file2,
544
+ L: 139,
545
+ S: this,
546
+ A: [
547
+ "message.data?.answer",
548
+ "'No answer'"
549
+ ]
550
+ });
440
551
  log2("resolving", {
441
552
  answer: message.data.answer
442
553
  }, {
443
554
  F: __dxlog_file2,
444
- L: 141,
555
+ L: 140,
445
556
  S: this,
446
557
  C: (f, a) => f(...a)
447
558
  });
@@ -449,7 +560,15 @@ var SwarmMessenger = class {
449
560
  }
450
561
  }
451
562
  async _handleOffer({ author, recipient, message }) {
452
- invariant2(message.data.offer, "No offer");
563
+ invariant2(message.data.offer, "No offer", {
564
+ F: __dxlog_file2,
565
+ L: 154,
566
+ S: this,
567
+ A: [
568
+ "message.data.offer",
569
+ "'No offer'"
570
+ ]
571
+ });
453
572
  const offerMessage = {
454
573
  author,
455
574
  recipient,
@@ -477,15 +596,31 @@ var SwarmMessenger = class {
477
596
  err
478
597
  }, {
479
598
  F: __dxlog_file2,
480
- L: 175,
599
+ L: 174,
481
600
  S: this,
482
601
  C: (f, a) => f(...a)
483
602
  });
484
603
  }
485
604
  }
486
605
  async _handleSignal({ author, recipient, message }) {
487
- invariant2(message.messageId);
488
- invariant2(message.data.signal || message.data.signalBatch, "Invalid message");
606
+ invariant2(message.messageId, void 0, {
607
+ F: __dxlog_file2,
608
+ L: 187,
609
+ S: this,
610
+ A: [
611
+ "message.messageId",
612
+ ""
613
+ ]
614
+ });
615
+ invariant2(message.data.signal || message.data.signalBatch, "Invalid message", {
616
+ F: __dxlog_file2,
617
+ L: 188,
618
+ S: this,
619
+ A: [
620
+ "message.data.signal || message.data.signalBatch",
621
+ "'Invalid message'"
622
+ ]
623
+ });
489
624
  const signalMessage = {
490
625
  author,
491
626
  recipient,
@@ -500,19 +635,20 @@ var SwarmMessenger = class {
500
635
  };
501
636
 
502
637
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
503
- import invariant4 from "tiny-invariant";
504
638
  import { Event as Event2, scheduleTask as scheduleTask2, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
505
639
  import { Context as Context4 } from "@dxos/context";
506
640
  import { ErrorStream as ErrorStream2 } from "@dxos/debug";
641
+ import { invariant as invariant4 } from "@dxos/invariant";
507
642
  import { PublicKey as PublicKey4 } from "@dxos/keys";
508
643
  import { log as log4, logInfo } from "@dxos/log";
509
644
  import { trace as trace2 } from "@dxos/protocols";
510
645
  import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
511
646
 
512
647
  // packages/core/mesh/network-manager/src/swarm/peer.ts
513
- import invariant3 from "tiny-invariant";
514
648
  import { scheduleTask, synchronized as synchronized2 } from "@dxos/async";
515
649
  import { Context as Context3 } from "@dxos/context";
650
+ import { CancelledError as CancelledError2 } from "@dxos/errors";
651
+ import { invariant as invariant3 } from "@dxos/invariant";
516
652
  import { PublicKey as PublicKey3 } from "@dxos/keys";
517
653
  import { log as log3 } from "@dxos/log";
518
654
  function _ts_decorate2(decorators, target, key, desc) {
@@ -525,16 +661,17 @@ function _ts_decorate2(decorators, target, key, desc) {
525
661
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
526
662
  return c > 3 && r && Object.defineProperty(target, key, r), r;
527
663
  }
528
- var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/peer.ts";
664
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
529
665
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
530
666
  var Peer = class {
531
- constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _callbacks) {
667
+ constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
532
668
  this.id = id;
533
669
  this.topic = topic;
534
670
  this.localPeerId = localPeerId;
535
671
  this._signalMessaging = _signalMessaging;
536
672
  this._protocolProvider = _protocolProvider;
537
673
  this._transportFactory = _transportFactory;
674
+ this._connectionLimiter = _connectionLimiter;
538
675
  this._callbacks = _callbacks;
539
676
  this._availableAfter = 0;
540
677
  this.availableToConnect = true;
@@ -546,16 +683,18 @@ var Peer = class {
546
683
  * Respond to remote offer.
547
684
  */
548
685
  async onOffer(message) {
686
+ var _a;
549
687
  const remoteId = message.author;
550
688
  if (this.connection || this.initiating) {
551
689
  if (remoteId.toHex() < this.localPeerId.toHex()) {
552
- log3("closing local connection and accepting remote peer's offer", {
553
- id: this.id,
690
+ log3("close local connection", {
691
+ localPeerId: this.id,
554
692
  topic: this.topic,
555
- peerId: this.localPeerId
693
+ remotePeerId: this.localPeerId,
694
+ sessionId: (_a = this.connection) == null ? void 0 : _a.sessionId
556
695
  }, {
557
696
  F: __dxlog_file3,
558
- L: 105,
697
+ L: 106,
559
698
  S: this,
560
699
  C: (f, a) => f(...a)
561
700
  });
@@ -570,22 +709,33 @@ var Peer = class {
570
709
  }
571
710
  if (await this._callbacks.onOffer(remoteId)) {
572
711
  if (!this.connection) {
573
- invariant3(message.sessionId);
712
+ invariant3(message.sessionId, void 0, {
713
+ F: __dxlog_file3,
714
+ L: 126,
715
+ S: this,
716
+ A: [
717
+ "message.sessionId",
718
+ ""
719
+ ]
720
+ });
574
721
  const connection = this._createConnection(false, message.sessionId);
575
722
  try {
576
- connection.openConnection();
723
+ await this._connectionLimiter.connecting(message.sessionId);
724
+ await connection.openConnection();
577
725
  } catch (err) {
578
- log3.warn("connection error", {
579
- topic: this.topic,
580
- peerId: this.localPeerId,
581
- remoteId: this.id,
582
- err
583
- }, {
584
- F: __dxlog_file3,
585
- L: 129,
586
- S: this,
587
- C: (f, a) => f(...a)
588
- });
726
+ if (!(err instanceof CancelledError2)) {
727
+ log3.warn("connection error", {
728
+ topic: this.topic,
729
+ peerId: this.localPeerId,
730
+ remoteId: this.id,
731
+ err
732
+ }, {
733
+ F: __dxlog_file3,
734
+ L: 134,
735
+ S: this,
736
+ C: (f, a) => f(...a)
737
+ });
738
+ }
589
739
  await this.closeConnection();
590
740
  }
591
741
  return {
@@ -601,8 +751,24 @@ var Peer = class {
601
751
  * Initiate a connection to the remote peer.
602
752
  */
603
753
  async initiateConnection() {
604
- invariant3(!this.initiating, "Initiation in progress.");
605
- invariant3(!this.connection, "Already connected.");
754
+ invariant3(!this.initiating, "Initiation in progress.", {
755
+ F: __dxlog_file3,
756
+ L: 151,
757
+ S: this,
758
+ A: [
759
+ "!this.initiating",
760
+ "'Initiation in progress.'"
761
+ ]
762
+ });
763
+ invariant3(!this.connection, "Already connected.", {
764
+ F: __dxlog_file3,
765
+ L: 152,
766
+ S: this,
767
+ A: [
768
+ "!this.connection",
769
+ "'Already connected.'"
770
+ ]
771
+ });
606
772
  const sessionId = PublicKey3.random();
607
773
  log3("initiating...", {
608
774
  id: this.id,
@@ -611,13 +777,14 @@ var Peer = class {
611
777
  sessionId
612
778
  }, {
613
779
  F: __dxlog_file3,
614
- L: 147,
780
+ L: 154,
615
781
  S: this,
616
782
  C: (f, a) => f(...a)
617
783
  });
618
784
  const connection = this._createConnection(true, sessionId);
619
785
  this.initiating = true;
620
786
  try {
787
+ await this._connectionLimiter.connecting(sessionId);
621
788
  const answer = await this._signalMessaging.offer({
622
789
  author: this.localPeerId,
623
790
  recipient: this.id,
@@ -634,14 +801,14 @@ var Peer = class {
634
801
  remoteId: this.id
635
802
  }, {
636
803
  F: __dxlog_file3,
637
- L: 159,
804
+ L: 169,
638
805
  S: this,
639
806
  C: (f, a) => f(...a)
640
807
  });
641
808
  if (connection.state !== ConnectionState.INITIAL) {
642
809
  log3("ignoring response", void 0, {
643
810
  F: __dxlog_file3,
644
- L: 161,
811
+ L: 171,
645
812
  S: this,
646
813
  C: (f, a) => f(...a)
647
814
  });
@@ -651,7 +818,7 @@ var Peer = class {
651
818
  this._callbacks.onRejected();
652
819
  return;
653
820
  }
654
- connection.openConnection();
821
+ await connection.openConnection();
655
822
  this._callbacks.onAccepted();
656
823
  } catch (err) {
657
824
  log3("initiation error", {
@@ -661,7 +828,7 @@ var Peer = class {
661
828
  remoteId: this.id
662
829
  }, {
663
830
  F: __dxlog_file3,
664
- L: 172,
831
+ L: 182,
665
832
  S: this,
666
833
  C: (f, a) => f(...a)
667
834
  });
@@ -685,11 +852,19 @@ var Peer = class {
685
852
  sessionId
686
853
  }, {
687
854
  F: __dxlog_file3,
688
- L: 186,
855
+ L: 196,
689
856
  S: this,
690
857
  C: (f, a) => f(...a)
691
858
  });
692
- invariant3(!this.connection, "Already connected.");
859
+ invariant3(!this.connection, "Already connected.", {
860
+ F: __dxlog_file3,
861
+ L: 203,
862
+ S: this,
863
+ A: [
864
+ "!this.connection",
865
+ "'Already connected.'"
866
+ ]
867
+ });
693
868
  const connection = new Connection(
694
869
  this.topic,
695
870
  this.localPeerId,
@@ -715,6 +890,19 @@ var Peer = class {
715
890
  this.availableToConnect = true;
716
891
  this._lastConnectionTime = Date.now();
717
892
  this._callbacks.onConnected();
893
+ this._connectionLimiter.doneConnecting(sessionId);
894
+ log3.trace("dxos.mesh.connection.connected", {
895
+ topic: this.topic,
896
+ localPeerId: this.localPeerId,
897
+ remotePeerId: this.id,
898
+ sessionId,
899
+ initiator
900
+ }, {
901
+ F: __dxlog_file3,
902
+ L: 229,
903
+ S: this,
904
+ C: (f, a) => f(...a)
905
+ });
718
906
  break;
719
907
  }
720
908
  case ConnectionState.CLOSED: {
@@ -725,11 +913,31 @@ var Peer = class {
725
913
  initiator
726
914
  }, {
727
915
  F: __dxlog_file3,
728
- L: 221,
916
+ L: 240,
917
+ S: this,
918
+ C: (f, a) => f(...a)
919
+ });
920
+ invariant3(this.connection === connection, "Connection mismatch (race condition).", {
921
+ F: __dxlog_file3,
922
+ L: 241,
923
+ S: this,
924
+ A: [
925
+ "this.connection === connection",
926
+ "'Connection mismatch (race condition).'"
927
+ ]
928
+ });
929
+ log3.trace("dxos.mesh.connection.closed", {
930
+ topic: this.topic,
931
+ localPeerId: this.localPeerId,
932
+ remotePeerId: this.id,
933
+ sessionId,
934
+ initiator
935
+ }, {
936
+ F: __dxlog_file3,
937
+ L: 243,
729
938
  S: this,
730
939
  C: (f, a) => f(...a)
731
940
  });
732
- invariant3(this.connection === connection, "Connection mismatch (race condition).");
733
941
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
734
942
  this._availableAfter = 0;
735
943
  } else {
@@ -738,6 +946,7 @@ var Peer = class {
738
946
  }
739
947
  this.connection = void 0;
740
948
  this._callbacks.onDisconnected();
949
+ this._connectionLimiter.doneConnecting(sessionId);
741
950
  scheduleTask(this._connectionCtx, () => {
742
951
  this.availableToConnect = true;
743
952
  this._callbacks.onPeerAvailable();
@@ -755,7 +964,20 @@ var Peer = class {
755
964
  err
756
965
  }, {
757
966
  F: __dxlog_file3,
758
- L: 249,
967
+ L: 277,
968
+ S: this,
969
+ C: (f, a) => f(...a)
970
+ });
971
+ log3.trace("dxos.mesh.connection.error", {
972
+ topic: this.topic,
973
+ localPeerId: this.localPeerId,
974
+ remotePeerId: this.id,
975
+ sessionId,
976
+ initiator,
977
+ err
978
+ }, {
979
+ F: __dxlog_file3,
980
+ L: 278,
759
981
  S: this,
760
982
  C: (f, a) => f(...a)
761
983
  });
@@ -774,7 +996,7 @@ var Peer = class {
774
996
  sessionId: connection.sessionId
775
997
  }, {
776
998
  F: __dxlog_file3,
777
- L: 265,
999
+ L: 301,
778
1000
  S: this,
779
1001
  C: (f, a) => f(...a)
780
1002
  });
@@ -784,7 +1006,7 @@ var Peer = class {
784
1006
  sessionId: connection.sessionId
785
1007
  }, {
786
1008
  F: __dxlog_file3,
787
- L: 271,
1009
+ L: 307,
788
1010
  S: this,
789
1011
  C: (f, a) => f(...a)
790
1012
  });
@@ -795,7 +1017,7 @@ var Peer = class {
795
1017
  message
796
1018
  }, {
797
1019
  F: __dxlog_file3,
798
- L: 276,
1020
+ L: 312,
799
1021
  S: this,
800
1022
  C: (f, a) => f(...a)
801
1023
  });
@@ -811,7 +1033,7 @@ var Peer = class {
811
1033
  topic: this.topic
812
1034
  }, {
813
1035
  F: __dxlog_file3,
814
- L: 285,
1036
+ L: 322,
815
1037
  S: this,
816
1038
  C: (f, a) => f(...a)
817
1039
  });
@@ -845,13 +1067,13 @@ function _ts_decorate3(decorators, target, key, desc) {
845
1067
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
846
1068
  return c > 3 && r && Object.defineProperty(target, key, r), r;
847
1069
  }
848
- var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1070
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
849
1071
  var INITIATION_DELAY = 100;
850
1072
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
851
1073
  var Swarm = class {
852
1074
  // TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
853
1075
  // TODO(burdon): Split up properties.
854
- constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label) {
1076
+ constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter) {
855
1077
  this._topic = _topic;
856
1078
  this._ownPeerId = _ownPeerId;
857
1079
  this._topology = _topology;
@@ -859,6 +1081,7 @@ var Swarm = class {
859
1081
  this._messenger = _messenger;
860
1082
  this._transportFactory = _transportFactory;
861
1083
  this._label = _label;
1084
+ this._connectionLimiter = _connectionLimiter;
862
1085
  this._peers = new ComplexMap2(PublicKey4.hash);
863
1086
  this._ctx = new Context4();
864
1087
  this._listeningHandle = void 0;
@@ -875,7 +1098,7 @@ var Swarm = class {
875
1098
  }
876
1099
  }), {
877
1100
  F: __dxlog_file4,
878
- L: 86,
1101
+ L: 87,
879
1102
  S: this,
880
1103
  C: (f, a) => f(...a)
881
1104
  });
@@ -883,7 +1106,7 @@ var Swarm = class {
883
1106
  peerId: _ownPeerId
884
1107
  }, {
885
1108
  F: __dxlog_file4,
886
- L: 90,
1109
+ L: 91,
887
1110
  S: this,
888
1111
  C: (f, a) => f(...a)
889
1112
  });
@@ -898,7 +1121,7 @@ var Swarm = class {
898
1121
  id: this._instanceId
899
1122
  }), {
900
1123
  F: __dxlog_file4,
901
- L: 99,
1124
+ L: 100,
902
1125
  S: this,
903
1126
  C: (f, a) => f(...a)
904
1127
  });
@@ -919,7 +1142,15 @@ var Swarm = class {
919
1142
  return this._topic;
920
1143
  }
921
1144
  async open() {
922
- invariant4(!this._listeningHandle);
1145
+ invariant4(!this._listeningHandle, void 0, {
1146
+ F: __dxlog_file4,
1147
+ L: 127,
1148
+ S: this,
1149
+ A: [
1150
+ "!this._listeningHandle",
1151
+ ""
1152
+ ]
1153
+ });
923
1154
  this._listeningHandle = await this._messenger.listen({
924
1155
  peerId: this._ownPeerId,
925
1156
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -928,7 +1159,7 @@ var Swarm = class {
928
1159
  err
929
1160
  }, {
930
1161
  F: __dxlog_file4,
931
- L: 133,
1162
+ L: 134,
932
1163
  S: this,
933
1164
  C: (f, a) => f(...a)
934
1165
  }));
@@ -939,7 +1170,7 @@ var Swarm = class {
939
1170
  var _a;
940
1171
  log4("destroying...", void 0, {
941
1172
  F: __dxlog_file4,
942
- L: 139,
1173
+ L: 140,
943
1174
  S: this,
944
1175
  C: (f, a) => f(...a)
945
1176
  });
@@ -950,13 +1181,21 @@ var Swarm = class {
950
1181
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
951
1182
  log4("destroyed", void 0, {
952
1183
  F: __dxlog_file4,
953
- L: 146,
1184
+ L: 147,
954
1185
  S: this,
955
1186
  C: (f, a) => f(...a)
956
1187
  });
957
1188
  }
958
1189
  async setTopology(topology) {
959
- invariant4(!this._ctx.disposed, "Swarm is offline");
1190
+ invariant4(!this._ctx.disposed, "Swarm is offline", {
1191
+ F: __dxlog_file4,
1192
+ L: 151,
1193
+ S: this,
1194
+ A: [
1195
+ "!this._ctx.disposed",
1196
+ "'Swarm is offline'"
1197
+ ]
1198
+ });
960
1199
  if (topology === this._topology) {
961
1200
  return;
962
1201
  }
@@ -965,7 +1204,7 @@ var Swarm = class {
965
1204
  topology: getClassName(topology)
966
1205
  }, {
967
1206
  F: __dxlog_file4,
968
- L: 154,
1207
+ L: 155,
969
1208
  S: this,
970
1209
  C: (f, a) => f(...a)
971
1210
  });
@@ -980,14 +1219,14 @@ var Swarm = class {
980
1219
  swarmEvent
981
1220
  }, {
982
1221
  F: __dxlog_file4,
983
- L: 167,
1222
+ L: 168,
984
1223
  S: this,
985
1224
  C: (f, a) => f(...a)
986
1225
  });
987
1226
  if (this._ctx.disposed) {
988
1227
  log4("swarm event ignored for disposed swarm", void 0, {
989
1228
  F: __dxlog_file4,
990
- L: 170,
1229
+ L: 171,
991
1230
  S: this,
992
1231
  C: (f, a) => f(...a)
993
1232
  });
@@ -999,7 +1238,7 @@ var Swarm = class {
999
1238
  peerId
1000
1239
  }, {
1001
1240
  F: __dxlog_file4,
1002
- L: 176,
1241
+ L: 177,
1003
1242
  S: this,
1004
1243
  C: (f, a) => f(...a)
1005
1244
  });
@@ -1014,7 +1253,7 @@ var Swarm = class {
1014
1253
  if (((_a = peer.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
1015
1254
  void this._destroyPeer(peer.id).catch((err) => log4.catch(err, void 0, {
1016
1255
  F: __dxlog_file4,
1017
- L: 187,
1256
+ L: 188,
1018
1257
  S: this,
1019
1258
  C: (f, a) => f(...a)
1020
1259
  }));
@@ -1029,14 +1268,14 @@ var Swarm = class {
1029
1268
  message
1030
1269
  }, {
1031
1270
  F: __dxlog_file4,
1032
- L: 197,
1271
+ L: 198,
1033
1272
  S: this,
1034
1273
  C: (f, a) => f(...a)
1035
1274
  });
1036
1275
  if (this._ctx.disposed) {
1037
1276
  log4("ignored for disposed swarm", void 0, {
1038
1277
  F: __dxlog_file4,
1039
- L: 199,
1278
+ L: 200,
1040
1279
  S: this,
1041
1280
  C: (f, a) => f(...a)
1042
1281
  });
@@ -1044,13 +1283,21 @@ var Swarm = class {
1044
1283
  accept: false
1045
1284
  };
1046
1285
  }
1047
- invariant4(message.author);
1286
+ invariant4(message.author, void 0, {
1287
+ F: __dxlog_file4,
1288
+ L: 205,
1289
+ S: this,
1290
+ A: [
1291
+ "message.author",
1292
+ ""
1293
+ ]
1294
+ });
1048
1295
  if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
1049
1296
  log4("rejecting offer with incorrect peerId", {
1050
1297
  message
1051
1298
  }, {
1052
1299
  F: __dxlog_file4,
1053
- L: 206,
1300
+ L: 207,
1054
1301
  S: this,
1055
1302
  C: (f, a) => f(...a)
1056
1303
  });
@@ -1063,7 +1310,7 @@ var Swarm = class {
1063
1310
  message
1064
1311
  }, {
1065
1312
  F: __dxlog_file4,
1066
- L: 210,
1313
+ L: 211,
1067
1314
  S: this,
1068
1315
  C: (f, a) => f(...a)
1069
1316
  });
@@ -1095,9 +1342,33 @@ var Swarm = class {
1095
1342
  });
1096
1343
  return;
1097
1344
  }
1098
- invariant4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1099
- invariant4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1100
- invariant4(message.author);
1345
+ invariant4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1346
+ F: __dxlog_file4,
1347
+ L: 227,
1348
+ S: this,
1349
+ A: [
1350
+ "message.recipient?.equals(this._ownPeerId)",
1351
+ "`Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`"
1352
+ ]
1353
+ });
1354
+ invariant4((_b = message.topic) == null ? void 0 : _b.equals(this._topic), void 0, {
1355
+ F: __dxlog_file4,
1356
+ L: 231,
1357
+ S: this,
1358
+ A: [
1359
+ "message.topic?.equals(this._topic)",
1360
+ ""
1361
+ ]
1362
+ });
1363
+ invariant4(message.author, void 0, {
1364
+ F: __dxlog_file4,
1365
+ L: 232,
1366
+ S: this,
1367
+ A: [
1368
+ "message.author",
1369
+ ""
1370
+ ]
1371
+ });
1101
1372
  const peer = this._getOrCreatePeer(message.author);
1102
1373
  await peer.onSignal(message);
1103
1374
  }
@@ -1115,7 +1386,7 @@ var Swarm = class {
1115
1386
  _getOrCreatePeer(peerId) {
1116
1387
  let peer = this._peers.get(peerId);
1117
1388
  if (!peer) {
1118
- peer = new Peer(peerId, this._topic, this._ownPeerId, this._swarmMessenger, this._protocolProvider, this._transportFactory, {
1389
+ peer = new Peer(peerId, this._topic, this._ownPeerId, this._swarmMessenger, this._protocolProvider, this._transportFactory, this._connectionLimiter, {
1119
1390
  onInitiated: (connection) => {
1120
1391
  this.connectionAdded.emit(connection);
1121
1392
  },
@@ -1149,7 +1420,15 @@ var Swarm = class {
1149
1420
  return peer;
1150
1421
  }
1151
1422
  async _destroyPeer(peerId) {
1152
- invariant4(this._peers.has(peerId));
1423
+ invariant4(this._peers.has(peerId), void 0, {
1424
+ F: __dxlog_file4,
1425
+ L: 302,
1426
+ S: this,
1427
+ A: [
1428
+ "this._peers.has(peerId)",
1429
+ ""
1430
+ ]
1431
+ });
1153
1432
  await this._peers.get(peerId).destroy();
1154
1433
  this._peers.delete(peerId);
1155
1434
  }
@@ -1170,7 +1449,7 @@ var Swarm = class {
1170
1449
  } catch (err) {
1171
1450
  log4("initiation error", err, {
1172
1451
  F: __dxlog_file4,
1173
- L: 327,
1452
+ L: 328,
1174
1453
  S: this,
1175
1454
  C: (f, a) => f(...a)
1176
1455
  });
@@ -1198,7 +1477,7 @@ var Swarm = class {
1198
1477
  remoteId
1199
1478
  }, {
1200
1479
  F: __dxlog_file4,
1201
- L: 354,
1480
+ L: 355,
1202
1481
  S: this,
1203
1482
  C: (f, a) => f(...a)
1204
1483
  });
@@ -1215,7 +1494,7 @@ var Swarm = class {
1215
1494
  remoteId
1216
1495
  }, {
1217
1496
  F: __dxlog_file4,
1218
- L: 368,
1497
+ L: 369,
1219
1498
  S: this,
1220
1499
  C: (f, a) => f(...a)
1221
1500
  });
@@ -1225,7 +1504,7 @@ var Swarm = class {
1225
1504
  remoteId
1226
1505
  }, {
1227
1506
  F: __dxlog_file4,
1228
- L: 371,
1507
+ L: 372,
1229
1508
  S: this,
1230
1509
  C: (f, a) => f(...a)
1231
1510
  });
@@ -1253,9 +1532,6 @@ _ts_decorate3([
1253
1532
  _ts_decorate3([
1254
1533
  synchronized3
1255
1534
  ], Swarm.prototype, "onOffer", null);
1256
- _ts_decorate3([
1257
- synchronized3
1258
- ], Swarm.prototype, "onSignal", null);
1259
1535
  _ts_decorate3([
1260
1536
  synchronized3
1261
1537
  ], Swarm.prototype, "goOffline", null);
@@ -1268,7 +1544,7 @@ import { Event as Event3, EventSubscriptions } from "@dxos/async";
1268
1544
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1269
1545
  import { log as log5 } from "@dxos/log";
1270
1546
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
1271
- var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1547
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1272
1548
  var SwarmMapper = class {
1273
1549
  get peers() {
1274
1550
  return Array.from(this._peers.values());
@@ -1334,11 +1610,93 @@ var SwarmMapper = class {
1334
1610
  }
1335
1611
  };
1336
1612
 
1613
+ // packages/core/mesh/network-manager/src/swarm/connection-limiter.ts
1614
+ import { DeferredTask as DeferredTask2 } from "@dxos/async";
1615
+ import { Context as Context5 } from "@dxos/context";
1616
+ import { CancelledError as CancelledError3 } from "@dxos/errors";
1617
+ import { invariant as invariant5 } from "@dxos/invariant";
1618
+ import { PublicKey as PublicKey6 } from "@dxos/keys";
1619
+ import { log as log6 } from "@dxos/log";
1620
+ import { ComplexMap as ComplexMap4 } from "@dxos/util";
1621
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1622
+ var MAX_CONCURRENT_INITIATING_CONNECTIONS = 3;
1623
+ var ConnectionLimiter = class {
1624
+ constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
1625
+ this._ctx = new Context5();
1626
+ /**
1627
+ * Queue of promises to resolve when initiating connections amount is below the limit.
1628
+ */
1629
+ this._waitingPromises = new ComplexMap4(PublicKey6.hash);
1630
+ this.resolveWaitingPromises = new DeferredTask2(this._ctx, async () => {
1631
+ Array.from(this._waitingPromises.values()).slice(0, this._maxConcurrentInitConnections).forEach(({ resolve }) => {
1632
+ resolve();
1633
+ });
1634
+ });
1635
+ this._maxConcurrentInitConnections = maxConcurrentInitConnections;
1636
+ }
1637
+ /**
1638
+ * @returns Promise that resolves in queue when connections amount with 'CONNECTING' state is below the limit.
1639
+ */
1640
+ async connecting(sessionId) {
1641
+ invariant5(!this._waitingPromises.has(sessionId), "Peer is already waiting for connection", {
1642
+ F: __dxlog_file6,
1643
+ L: 48,
1644
+ S: this,
1645
+ A: [
1646
+ "!this._waitingPromises.has(sessionId)",
1647
+ "'Peer is already waiting for connection'"
1648
+ ]
1649
+ });
1650
+ log6("waiting", {
1651
+ sessionId
1652
+ }, {
1653
+ F: __dxlog_file6,
1654
+ L: 49,
1655
+ S: this,
1656
+ C: (f, a) => f(...a)
1657
+ });
1658
+ await new Promise((resolve, reject) => {
1659
+ this._waitingPromises.set(sessionId, {
1660
+ resolve,
1661
+ reject
1662
+ });
1663
+ this.resolveWaitingPromises.schedule();
1664
+ });
1665
+ log6("allow", {
1666
+ sessionId
1667
+ }, {
1668
+ F: __dxlog_file6,
1669
+ L: 57,
1670
+ S: this,
1671
+ C: (f, a) => f(...a)
1672
+ });
1673
+ }
1674
+ /**
1675
+ * Rejects promise returned by `connecting` method.
1676
+ */
1677
+ doneConnecting(sessionId) {
1678
+ log6("done", {
1679
+ sessionId
1680
+ }, {
1681
+ F: __dxlog_file6,
1682
+ L: 64,
1683
+ S: this,
1684
+ C: (f, a) => f(...a)
1685
+ });
1686
+ if (!this._waitingPromises.has(sessionId)) {
1687
+ return;
1688
+ }
1689
+ this._waitingPromises.get(sessionId).reject(new CancelledError3());
1690
+ this._waitingPromises.delete(sessionId);
1691
+ this.resolveWaitingPromises.schedule();
1692
+ }
1693
+ };
1694
+
1337
1695
  // packages/core/mesh/network-manager/src/connection-log.ts
1338
1696
  import { Event as Event4 } from "@dxos/async";
1339
1697
  import { raise } from "@dxos/debug";
1340
- import { PublicKey as PublicKey6 } from "@dxos/keys";
1341
- import { ComplexMap as ComplexMap4 } from "@dxos/util";
1698
+ import { PublicKey as PublicKey7 } from "@dxos/keys";
1699
+ import { ComplexMap as ComplexMap5 } from "@dxos/util";
1342
1700
  var EventType;
1343
1701
  (function(EventType2) {
1344
1702
  EventType2["CONNECTION_STATE_CHANGED"] = "CONNECTION_STATE_CHANGED";
@@ -1352,7 +1710,7 @@ var ConnectionLog = class {
1352
1710
  /**
1353
1711
  * SwarmId => info
1354
1712
  */
1355
- this._swarms = new ComplexMap4(PublicKey6.hash);
1713
+ this._swarms = new ComplexMap5(PublicKey7.hash);
1356
1714
  this.update = new Event4();
1357
1715
  }
1358
1716
  getSwarmInfo(swarmId) {
@@ -1364,13 +1722,13 @@ var ConnectionLog = class {
1364
1722
  }
1365
1723
  joinedSwarm(swarm) {
1366
1724
  const info = {
1367
- id: PublicKey6.from(swarm._instanceId),
1725
+ id: PublicKey7.from(swarm._instanceId),
1368
1726
  topic: swarm.topic,
1369
1727
  isActive: true,
1370
1728
  label: swarm.label,
1371
1729
  connections: []
1372
1730
  };
1373
- this._swarms.set(PublicKey6.from(swarm._instanceId), info);
1731
+ this._swarms.set(PublicKey7.from(swarm._instanceId), info);
1374
1732
  this.update.emit();
1375
1733
  swarm.connectionAdded.on((connection) => {
1376
1734
  var _a, _b;
@@ -1399,29 +1757,32 @@ var ConnectionLog = class {
1399
1757
  });
1400
1758
  }
1401
1759
  leftSwarm(swarm) {
1402
- this.getSwarmInfo(PublicKey6.from(swarm._instanceId)).isActive = false;
1760
+ this.getSwarmInfo(PublicKey7.from(swarm._instanceId)).isActive = false;
1403
1761
  this.update.emit();
1404
1762
  }
1405
1763
  };
1406
1764
 
1407
1765
  // packages/core/mesh/network-manager/src/network-manager.ts
1408
- import invariant5 from "tiny-invariant";
1409
1766
  import { Event as Event5 } from "@dxos/async";
1410
- import { PublicKey as PublicKey7 } from "@dxos/keys";
1411
- import { log as log6 } from "@dxos/log";
1767
+ import { invariant as invariant6 } from "@dxos/invariant";
1768
+ import { PublicKey as PublicKey8 } from "@dxos/keys";
1769
+ import { log as log7 } from "@dxos/log";
1412
1770
  import { Messenger } from "@dxos/messaging";
1413
1771
  import { trace as trace3 } from "@dxos/protocols";
1414
1772
  import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
1415
- import { ComplexMap as ComplexMap5 } from "@dxos/util";
1416
- var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/network-manager.ts";
1773
+ import { ComplexMap as ComplexMap6 } from "@dxos/util";
1774
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
1417
1775
  var NetworkManager = class {
1418
1776
  constructor({ transportFactory, signalManager, log: log1 }) {
1419
- this._swarms = new ComplexMap5(PublicKey7.hash);
1420
- this._mappers = new ComplexMap5(PublicKey7.hash);
1777
+ /**
1778
+ * @internal
1779
+ */
1780
+ this._swarms = new ComplexMap6(PublicKey8.hash);
1781
+ this._mappers = new ComplexMap6(PublicKey8.hash);
1421
1782
  this._connectionState = ConnectionState2.ONLINE;
1422
1783
  this.connectionStateChanged = new Event5();
1423
1784
  this.topicsUpdated = new Event5();
1424
- this._instanceId = PublicKey7.random().toHex();
1785
+ this._instanceId = PublicKey8.random().toHex();
1425
1786
  this._transportFactory = transportFactory;
1426
1787
  this._signalManager = signalManager;
1427
1788
  this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => {
@@ -1435,6 +1796,7 @@ var NetworkManager = class {
1435
1796
  join: (opts) => this._signalManager.join(opts),
1436
1797
  leave: (opts) => this._signalManager.leave(opts)
1437
1798
  };
1799
+ this._connectionLimiter = new ConnectionLimiter();
1438
1800
  if (log1) {
1439
1801
  this._connectionLog = new ConnectionLog();
1440
1802
  }
@@ -1457,21 +1819,21 @@ var NetworkManager = class {
1457
1819
  return this._swarms.get(topic);
1458
1820
  }
1459
1821
  async open() {
1460
- log6.trace("dxos.mesh.network-manager.open", trace3.begin({
1822
+ log7.trace("dxos.mesh.network-manager.open", trace3.begin({
1461
1823
  id: this._instanceId
1462
1824
  }), {
1463
- F: __dxlog_file6,
1464
- L: 127,
1825
+ F: __dxlog_file7,
1826
+ L: 130,
1465
1827
  S: this,
1466
1828
  C: (f, a) => f(...a)
1467
1829
  });
1468
1830
  await this._messenger.open();
1469
1831
  await this._signalManager.open();
1470
- log6.trace("dxos.mesh.network-manager.open", trace3.end({
1832
+ log7.trace("dxos.mesh.network-manager.open", trace3.end({
1471
1833
  id: this._instanceId
1472
1834
  }), {
1473
- F: __dxlog_file6,
1474
- L: 130,
1835
+ F: __dxlog_file7,
1836
+ L: 133,
1475
1837
  S: this,
1476
1838
  C: (f, a) => f(...a)
1477
1839
  });
@@ -1479,9 +1841,9 @@ var NetworkManager = class {
1479
1841
  async close() {
1480
1842
  for (const topic of this._swarms.keys()) {
1481
1843
  await this.leaveSwarm(topic).catch((err) => {
1482
- log6(err, void 0, {
1483
- F: __dxlog_file6,
1484
- L: 136,
1844
+ log7(err, void 0, {
1845
+ F: __dxlog_file7,
1846
+ L: 139,
1485
1847
  S: this,
1486
1848
  C: (f, a) => f(...a)
1487
1849
  });
@@ -1495,30 +1857,62 @@ var NetworkManager = class {
1495
1857
  */
1496
1858
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1497
1859
  var _a;
1498
- invariant5(PublicKey7.isPublicKey(topic));
1499
- invariant5(PublicKey7.isPublicKey(peerId));
1500
- invariant5(topology);
1501
- invariant5(typeof protocol === "function");
1860
+ invariant6(PublicKey8.isPublicKey(topic), void 0, {
1861
+ F: __dxlog_file7,
1862
+ L: 157,
1863
+ S: this,
1864
+ A: [
1865
+ "PublicKey.isPublicKey(topic)",
1866
+ ""
1867
+ ]
1868
+ });
1869
+ invariant6(PublicKey8.isPublicKey(peerId), void 0, {
1870
+ F: __dxlog_file7,
1871
+ L: 158,
1872
+ S: this,
1873
+ A: [
1874
+ "PublicKey.isPublicKey(peerId)",
1875
+ ""
1876
+ ]
1877
+ });
1878
+ invariant6(topology, void 0, {
1879
+ F: __dxlog_file7,
1880
+ L: 159,
1881
+ S: this,
1882
+ A: [
1883
+ "topology",
1884
+ ""
1885
+ ]
1886
+ });
1887
+ invariant6(typeof protocol === "function", void 0, {
1888
+ F: __dxlog_file7,
1889
+ L: 160,
1890
+ S: this,
1891
+ A: [
1892
+ "typeof protocol === 'function'",
1893
+ ""
1894
+ ]
1895
+ });
1502
1896
  if (this._swarms.has(topic)) {
1503
- throw new Error(`Already connected to swarm: ${PublicKey7.from(topic)}`);
1897
+ throw new Error(`Already connected to swarm: ${PublicKey8.from(topic)}`);
1504
1898
  }
1505
- log6("joining", {
1506
- topic: PublicKey7.from(topic),
1899
+ log7("joining", {
1900
+ topic: PublicKey8.from(topic),
1507
1901
  peerId,
1508
1902
  topology: topology.toString()
1509
1903
  }, {
1510
- F: __dxlog_file6,
1511
- L: 162,
1904
+ F: __dxlog_file7,
1905
+ L: 165,
1512
1906
  S: this,
1513
1907
  C: (f, a) => f(...a)
1514
1908
  });
1515
- const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label);
1909
+ const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
1516
1910
  swarm.errors.handle((error) => {
1517
- log6("swarm error", {
1911
+ log7("swarm error", {
1518
1912
  error
1519
1913
  }, {
1520
- F: __dxlog_file6,
1521
- L: 165,
1914
+ F: __dxlog_file7,
1915
+ L: 178,
1522
1916
  S: this,
1523
1917
  C: (f, a) => f(...a)
1524
1918
  });
@@ -1529,20 +1923,20 @@ var NetworkManager = class {
1529
1923
  this._signalConnection.join({
1530
1924
  topic,
1531
1925
  peerId
1532
- }).catch((error) => log6.catch(error, void 0, {
1533
- F: __dxlog_file6,
1534
- L: 174,
1926
+ }).catch((error) => log7.catch(error, void 0, {
1927
+ F: __dxlog_file7,
1928
+ L: 187,
1535
1929
  S: this,
1536
1930
  C: (f, a) => f(...a)
1537
1931
  }));
1538
1932
  this.topicsUpdated.emit();
1539
1933
  (_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
1540
- log6("joined", {
1541
- topic: PublicKey7.from(topic),
1934
+ log7("joined", {
1935
+ topic: PublicKey8.from(topic),
1542
1936
  count: this._swarms.size
1543
1937
  }, {
1544
- F: __dxlog_file6,
1545
- L: 178,
1938
+ F: __dxlog_file7,
1939
+ L: 191,
1546
1940
  S: this,
1547
1941
  C: (f, a) => f(...a)
1548
1942
  });
@@ -1558,11 +1952,11 @@ var NetworkManager = class {
1558
1952
  if (!this._swarms.has(topic)) {
1559
1953
  return;
1560
1954
  }
1561
- log6("leaving", {
1562
- topic: PublicKey7.from(topic)
1955
+ log7("leaving", {
1956
+ topic: PublicKey8.from(topic)
1563
1957
  }, {
1564
- F: __dxlog_file6,
1565
- L: 194,
1958
+ F: __dxlog_file7,
1959
+ L: 207,
1566
1960
  S: this,
1567
1961
  C: (f, a) => f(...a)
1568
1962
  });
@@ -1578,12 +1972,12 @@ var NetworkManager = class {
1578
1972
  await swarm.destroy();
1579
1973
  this._swarms.delete(topic);
1580
1974
  await this.topicsUpdated.emit();
1581
- log6("left", {
1582
- topic: PublicKey7.from(topic),
1975
+ log7("left", {
1976
+ topic: PublicKey8.from(topic),
1583
1977
  count: this._swarms.size
1584
1978
  }, {
1585
- F: __dxlog_file6,
1586
- L: 208,
1979
+ F: __dxlog_file7,
1980
+ L: 221,
1587
1981
  S: this,
1588
1982
  C: (f, a) => f(...a)
1589
1983
  });
@@ -1617,17 +2011,34 @@ var NetworkManager = class {
1617
2011
  };
1618
2012
 
1619
2013
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1620
- import invariant6 from "tiny-invariant";
2014
+ import { invariant as invariant7 } from "@dxos/invariant";
2015
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
1621
2016
  var FullyConnectedTopology = class {
1622
2017
  toString() {
1623
2018
  return "FullyConnectedTopology";
1624
2019
  }
1625
2020
  init(controller) {
1626
- invariant6(!this._controller, "Already initialized");
2021
+ invariant7(!this._controller, "Already initialized", {
2022
+ F: __dxlog_file8,
2023
+ L: 18,
2024
+ S: this,
2025
+ A: [
2026
+ "!this._controller",
2027
+ "'Already initialized'"
2028
+ ]
2029
+ });
1627
2030
  this._controller = controller;
1628
2031
  }
1629
2032
  update() {
1630
- invariant6(this._controller, "Not initialized");
2033
+ invariant7(this._controller, "Not initialized", {
2034
+ F: __dxlog_file8,
2035
+ L: 23,
2036
+ S: this,
2037
+ A: [
2038
+ "this._controller",
2039
+ "'Not initialized'"
2040
+ ]
2041
+ });
1631
2042
  const { candidates: discovered } = this._controller.getState();
1632
2043
  for (const peer of discovered) {
1633
2044
  this._controller.connect(peer);
@@ -1641,10 +2052,10 @@ var FullyConnectedTopology = class {
1641
2052
  };
1642
2053
 
1643
2054
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1644
- import invariant7 from "tiny-invariant";
1645
2055
  import distance from "xor-distance";
1646
- import { log as log7 } from "@dxos/log";
1647
- var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
2056
+ import { invariant as invariant8 } from "@dxos/invariant";
2057
+ import { log as log8 } from "@dxos/log";
2058
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
1648
2059
  var MMSTTopology = class {
1649
2060
  constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
1650
2061
  this._sampleCollected = false;
@@ -1653,15 +2064,31 @@ var MMSTTopology = class {
1653
2064
  this._sampleSize = sampleSize;
1654
2065
  }
1655
2066
  init(controller) {
1656
- invariant7(!this._controller, "Already initialized");
2067
+ invariant8(!this._controller, "Already initialized", {
2068
+ F: __dxlog_file9,
2069
+ L: 46,
2070
+ S: this,
2071
+ A: [
2072
+ "!this._controller",
2073
+ "'Already initialized'"
2074
+ ]
2075
+ });
1657
2076
  this._controller = controller;
1658
2077
  }
1659
2078
  update() {
1660
- invariant7(this._controller, "Not initialized");
2079
+ invariant8(this._controller, "Not initialized", {
2080
+ F: __dxlog_file9,
2081
+ L: 51,
2082
+ S: this,
2083
+ A: [
2084
+ "this._controller",
2085
+ "'Not initialized'"
2086
+ ]
2087
+ });
1661
2088
  const { connected, candidates } = this._controller.getState();
1662
2089
  if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
1663
- log7("Running the algorithm.", void 0, {
1664
- F: __dxlog_file7,
2090
+ log8("Running the algorithm.", void 0, {
2091
+ F: __dxlog_file9,
1665
2092
  L: 55,
1666
2093
  S: this,
1667
2094
  C: (f, a) => f(...a)
@@ -1671,11 +2098,19 @@ var MMSTTopology = class {
1671
2098
  }
1672
2099
  }
1673
2100
  async onOffer(peer) {
1674
- invariant7(this._controller, "Not initialized");
2101
+ invariant8(this._controller, "Not initialized", {
2102
+ F: __dxlog_file9,
2103
+ L: 62,
2104
+ S: this,
2105
+ A: [
2106
+ "this._controller",
2107
+ "'Not initialized'"
2108
+ ]
2109
+ });
1675
2110
  const { connected } = this._controller.getState();
1676
2111
  const accept = connected.length < this._maxPeers;
1677
- log7(`Offer ${peer} accept=${accept}`, void 0, {
1678
- F: __dxlog_file7,
2112
+ log8(`Offer ${peer} accept=${accept}`, void 0, {
2113
+ F: __dxlog_file9,
1679
2114
  L: 65,
1680
2115
  S: this,
1681
2116
  C: (f, a) => f(...a)
@@ -1685,13 +2120,21 @@ var MMSTTopology = class {
1685
2120
  async destroy() {
1686
2121
  }
1687
2122
  _runAlgorithm() {
1688
- invariant7(this._controller, "Not initialized");
2123
+ invariant8(this._controller, "Not initialized", {
2124
+ F: __dxlog_file9,
2125
+ L: 74,
2126
+ S: this,
2127
+ A: [
2128
+ "this._controller",
2129
+ "'Not initialized'"
2130
+ ]
2131
+ });
1689
2132
  const { connected, candidates, ownPeerId } = this._controller.getState();
1690
2133
  if (connected.length > this._maxPeers) {
1691
2134
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
1692
2135
  for (const peer of sorted) {
1693
- log7(`Disconnect ${peer}.`, void 0, {
1694
- F: __dxlog_file7,
2136
+ log8(`Disconnect ${peer}.`, void 0, {
2137
+ F: __dxlog_file9,
1695
2138
  L: 83,
1696
2139
  S: this,
1697
2140
  C: (f, a) => f(...a)
@@ -1702,8 +2145,8 @@ var MMSTTopology = class {
1702
2145
  const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
1703
2146
  const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
1704
2147
  for (const peer of sorted) {
1705
- log7(`Connect ${peer}.`, void 0, {
1706
- F: __dxlog_file7,
2148
+ log8(`Connect ${peer}.`, void 0, {
2149
+ F: __dxlog_file9,
1707
2150
  L: 91,
1708
2151
  S: this,
1709
2152
  C: (f, a) => f(...a)
@@ -1719,9 +2162,9 @@ var MMSTTopology = class {
1719
2162
  var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
1720
2163
 
1721
2164
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1722
- import invariant8 from "tiny-invariant";
1723
- import { log as log8 } from "@dxos/log";
1724
- var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/star-topology.ts";
2165
+ import { invariant as invariant9 } from "@dxos/invariant";
2166
+ import { log as log9 } from "@dxos/log";
2167
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
1725
2168
  var StarTopology = class {
1726
2169
  // prettier-ignore
1727
2170
  constructor(_centralPeer) {
@@ -1731,26 +2174,42 @@ var StarTopology = class {
1731
2174
  return `StarTopology(${this._centralPeer.truncate()})`;
1732
2175
  }
1733
2176
  init(controller) {
1734
- invariant8(!this._controller, "Already initialized.");
2177
+ invariant9(!this._controller, "Already initialized.", {
2178
+ F: __dxlog_file10,
2179
+ L: 24,
2180
+ S: this,
2181
+ A: [
2182
+ "!this._controller",
2183
+ "'Already initialized.'"
2184
+ ]
2185
+ });
1735
2186
  this._controller = controller;
1736
2187
  }
1737
2188
  update() {
1738
- invariant8(this._controller, "Not initialized.");
2189
+ invariant9(this._controller, "Not initialized.", {
2190
+ F: __dxlog_file10,
2191
+ L: 29,
2192
+ S: this,
2193
+ A: [
2194
+ "this._controller",
2195
+ "'Not initialized.'"
2196
+ ]
2197
+ });
1739
2198
  const { candidates, connected, ownPeerId } = this._controller.getState();
1740
2199
  if (!ownPeerId.equals(this._centralPeer)) {
1741
- log8("leaf peer dropping all connections apart from central peer.", void 0, {
1742
- F: __dxlog_file8,
1743
- L: 33,
2200
+ log9("leaf peer dropping all connections apart from central peer.", void 0, {
2201
+ F: __dxlog_file10,
2202
+ L: 32,
1744
2203
  S: this,
1745
2204
  C: (f, a) => f(...a)
1746
2205
  });
1747
2206
  for (const peer of connected) {
1748
2207
  if (!peer.equals(this._centralPeer)) {
1749
- log8("dropping connection", {
2208
+ log9("dropping connection", {
1750
2209
  peer
1751
2210
  }, {
1752
- F: __dxlog_file8,
1753
- L: 38,
2211
+ F: __dxlog_file10,
2212
+ L: 37,
1754
2213
  S: this,
1755
2214
  C: (f, a) => f(...a)
1756
2215
  });
@@ -1760,11 +2219,11 @@ var StarTopology = class {
1760
2219
  }
1761
2220
  for (const peer of candidates) {
1762
2221
  if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
1763
- log8("connecting to peer", {
2222
+ log9("connecting to peer", {
1764
2223
  peer
1765
2224
  }, {
1766
- F: __dxlog_file8,
1767
- L: 47,
2225
+ F: __dxlog_file10,
2226
+ L: 46,
1768
2227
  S: this,
1769
2228
  C: (f, a) => f(...a)
1770
2229
  });
@@ -1773,15 +2232,23 @@ var StarTopology = class {
1773
2232
  }
1774
2233
  }
1775
2234
  async onOffer(peer) {
1776
- invariant8(this._controller, "Not initialized.");
2235
+ invariant9(this._controller, "Not initialized.", {
2236
+ F: __dxlog_file10,
2237
+ L: 53,
2238
+ S: this,
2239
+ A: [
2240
+ "this._controller",
2241
+ "'Not initialized.'"
2242
+ ]
2243
+ });
1777
2244
  const { ownPeerId } = this._controller.getState();
1778
- log8("offer", {
2245
+ log9("offer", {
1779
2246
  peer,
1780
2247
  isCentral: peer.equals(this._centralPeer),
1781
2248
  isSelfCentral: ownPeerId.equals(this._centralPeer)
1782
2249
  }, {
1783
- F: __dxlog_file8,
1784
- L: 56,
2250
+ F: __dxlog_file10,
2251
+ L: 55,
1785
2252
  S: this,
1786
2253
  C: (f, a) => f(...a)
1787
2254
  });
@@ -1793,12 +2260,12 @@ var StarTopology = class {
1793
2260
 
1794
2261
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1795
2262
  import { Transform } from "@dxos/node-std/stream";
1796
- import invariant9 from "tiny-invariant";
1797
2263
  import { Event as Event6, Trigger } from "@dxos/async";
1798
2264
  import { ErrorStream as ErrorStream3 } from "@dxos/debug";
1799
- import { PublicKey as PublicKey8 } from "@dxos/keys";
1800
- import { log as log9, logInfo as logInfo2 } from "@dxos/log";
1801
- import { ComplexMap as ComplexMap6 } from "@dxos/util";
2265
+ import { invariant as invariant10 } from "@dxos/invariant";
2266
+ import { PublicKey as PublicKey9 } from "@dxos/keys";
2267
+ import { log as log10, logInfo as logInfo2 } from "@dxos/log";
2268
+ import { ComplexMap as ComplexMap7 } from "@dxos/util";
1802
2269
  function _ts_decorate4(decorators, target, key, desc) {
1803
2270
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1804
2271
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -1809,7 +2276,7 @@ function _ts_decorate4(decorators, target, key, desc) {
1809
2276
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1810
2277
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1811
2278
  }
1812
- var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2279
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
1813
2280
  var MEMORY_TRANSPORT_DELAY = 1;
1814
2281
  var createStreamDelay = (delay) => {
1815
2282
  return new Transform({
@@ -1829,23 +2296,31 @@ var _MemoryTransport = class {
1829
2296
  this.closed = new Event6();
1830
2297
  this.connected = new Event6();
1831
2298
  this.errors = new ErrorStream3();
1832
- this._instanceId = PublicKey8.random();
2299
+ this._instanceId = PublicKey9.random();
1833
2300
  this._remote = new Trigger();
1834
2301
  this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1835
2302
  this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1836
2303
  this._destroyed = false;
1837
- log9("creating", void 0, {
1838
- F: __dxlog_file9,
2304
+ log10("creating", void 0, {
2305
+ F: __dxlog_file11,
1839
2306
  L: 64,
1840
2307
  S: this,
1841
2308
  C: (f, a) => f(...a)
1842
2309
  });
1843
- invariant9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
2310
+ invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2311
+ F: __dxlog_file11,
2312
+ L: 66,
2313
+ S: this,
2314
+ A: [
2315
+ "!MemoryTransport._connections.has(this._instanceId)",
2316
+ "'Duplicate memory connection'"
2317
+ ]
2318
+ });
1844
2319
  _MemoryTransport._connections.set(this._instanceId, this);
1845
2320
  if (this.options.initiator) {
1846
2321
  setTimeout(async () => {
1847
- log9("sending signal", void 0, {
1848
- F: __dxlog_file9,
2322
+ log10("sending signal", void 0, {
2323
+ F: __dxlog_file11,
1849
2324
  L: 73,
1850
2325
  S: this,
1851
2326
  C: (f, a) => f(...a)
@@ -1874,11 +2349,19 @@ var _MemoryTransport = class {
1874
2349
  this.closed.emit();
1875
2350
  return;
1876
2351
  }
1877
- invariant9(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
2352
+ invariant10(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2353
+ F: __dxlog_file11,
2354
+ L: 99,
2355
+ S: this,
2356
+ A: [
2357
+ "!this._remoteConnection._remoteConnection",
2358
+ "`Remote already connected: ${this._remoteInstanceId}`"
2359
+ ]
2360
+ });
1878
2361
  this._remoteConnection._remoteConnection = this;
1879
2362
  this._remoteConnection._remoteInstanceId = this._instanceId;
1880
- log9("connected", void 0, {
1881
- F: __dxlog_file9,
2363
+ log10("connected", void 0, {
2364
+ F: __dxlog_file11,
1882
2365
  L: 103,
1883
2366
  S: this,
1884
2367
  C: (f, a) => f(...a)
@@ -1895,8 +2378,8 @@ var _MemoryTransport = class {
1895
2378
  }
1896
2379
  }
1897
2380
  async destroy() {
1898
- log9("closing", void 0, {
1899
- F: __dxlog_file9,
2381
+ log10("closing", void 0, {
2382
+ F: __dxlog_file11,
1900
2383
  L: 124,
1901
2384
  S: this,
1902
2385
  C: (f, a) => f(...a)
@@ -1904,8 +2387,8 @@ var _MemoryTransport = class {
1904
2387
  this._destroyed = true;
1905
2388
  _MemoryTransport._connections.delete(this._instanceId);
1906
2389
  if (this._remoteConnection) {
1907
- log9("closing", void 0, {
1908
- F: __dxlog_file9,
2390
+ log10("closing", void 0, {
2391
+ F: __dxlog_file11,
1909
2392
  L: 129,
1910
2393
  S: this,
1911
2394
  C: (f, a) => f(...a)
@@ -1917,26 +2400,26 @@ var _MemoryTransport = class {
1917
2400
  this._remoteConnection.closed.emit();
1918
2401
  this._remoteConnection._remoteConnection = void 0;
1919
2402
  this._remoteConnection = void 0;
1920
- log9("closed", void 0, {
1921
- F: __dxlog_file9,
2403
+ log10("closed", void 0, {
2404
+ F: __dxlog_file11,
1922
2405
  L: 147,
1923
2406
  S: this,
1924
2407
  C: (f, a) => f(...a)
1925
2408
  });
1926
2409
  }
1927
2410
  this.closed.emit();
1928
- log9("closed", void 0, {
1929
- F: __dxlog_file9,
2411
+ log10("closed", void 0, {
2412
+ F: __dxlog_file11,
1930
2413
  L: 151,
1931
2414
  S: this,
1932
2415
  C: (f, a) => f(...a)
1933
2416
  });
1934
2417
  }
1935
2418
  signal({ payload }) {
1936
- log9("received signal", {
2419
+ log10("received signal", {
1937
2420
  payload
1938
2421
  }, {
1939
- F: __dxlog_file9,
2422
+ F: __dxlog_file11,
1940
2423
  L: 155,
1941
2424
  S: this,
1942
2425
  C: (f, a) => f(...a)
@@ -1946,14 +2429,14 @@ var _MemoryTransport = class {
1946
2429
  }
1947
2430
  const transportId = payload.transportId;
1948
2431
  if (transportId) {
1949
- const remoteId = PublicKey8.fromHex(transportId);
2432
+ const remoteId = PublicKey9.fromHex(transportId);
1950
2433
  this._remote.wake(remoteId);
1951
2434
  }
1952
2435
  }
1953
2436
  };
1954
2437
  var MemoryTransport = _MemoryTransport;
1955
2438
  // TODO(burdon): Remove static properties (inject context into constructor).
1956
- MemoryTransport._connections = new ComplexMap6(PublicKey8.hash);
2439
+ MemoryTransport._connections = new ComplexMap7(PublicKey9.hash);
1957
2440
  _ts_decorate4([
1958
2441
  logInfo2
1959
2442
  ], MemoryTransport.prototype, "_instanceId", void 0);
@@ -1963,11 +2446,11 @@ _ts_decorate4([
1963
2446
 
1964
2447
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1965
2448
  import SimplePeerConstructor from "simple-peer";
1966
- import invariant10 from "tiny-invariant";
1967
2449
  import { Event as Event7 } from "@dxos/async";
1968
2450
  import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
1969
- import { PublicKey as PublicKey9 } from "@dxos/keys";
1970
- import { log as log10 } from "@dxos/log";
2451
+ import { invariant as invariant11 } from "@dxos/invariant";
2452
+ import { PublicKey as PublicKey10 } from "@dxos/keys";
2453
+ import { log as log11 } from "@dxos/log";
1971
2454
  import { trace as trace4 } from "@dxos/protocols";
1972
2455
 
1973
2456
  // packages/core/mesh/network-manager/src/transport/webrtc.ts
@@ -1978,7 +2461,7 @@ try {
1978
2461
  }
1979
2462
 
1980
2463
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1981
- var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
2464
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
1982
2465
  var WebRTCTransport = class {
1983
2466
  constructor(params) {
1984
2467
  var _a;
@@ -1987,17 +2470,17 @@ var WebRTCTransport = class {
1987
2470
  this.closed = new Event7();
1988
2471
  this.connected = new Event7();
1989
2472
  this.errors = new ErrorStream4();
1990
- this._instanceId = PublicKey9.random().toHex();
1991
- log10.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
2473
+ this._instanceId = PublicKey10.random().toHex();
2474
+ log11.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
1992
2475
  id: this._instanceId
1993
2476
  }), {
1994
- F: __dxlog_file10,
2477
+ F: __dxlog_file12,
1995
2478
  L: 39,
1996
2479
  S: this,
1997
2480
  C: (f, a) => f(...a)
1998
2481
  });
1999
- log10("created connection", params, {
2000
- F: __dxlog_file10,
2482
+ log11("created connection", params, {
2483
+ F: __dxlog_file12,
2001
2484
  L: 40,
2002
2485
  S: this,
2003
2486
  C: (f, a) => f(...a)
@@ -2008,8 +2491,8 @@ var WebRTCTransport = class {
2008
2491
  config: this.params.webrtcConfig
2009
2492
  });
2010
2493
  this._peer.on("signal", async (data) => {
2011
- log10("signal", data, {
2012
- F: __dxlog_file10,
2494
+ log11("signal", data, {
2495
+ F: __dxlog_file12,
2013
2496
  L: 48,
2014
2497
  S: this,
2015
2498
  C: (f, a) => f(...a)
@@ -2021,8 +2504,8 @@ var WebRTCTransport = class {
2021
2504
  });
2022
2505
  });
2023
2506
  this._peer.on("connect", () => {
2024
- log10("connected", void 0, {
2025
- F: __dxlog_file10,
2507
+ log11("connected", void 0, {
2508
+ F: __dxlog_file12,
2026
2509
  L: 53,
2027
2510
  S: this,
2028
2511
  C: (f, a) => f(...a)
@@ -2031,8 +2514,8 @@ var WebRTCTransport = class {
2031
2514
  this.connected.emit();
2032
2515
  });
2033
2516
  this._peer.on("close", async () => {
2034
- log10("closed", void 0, {
2035
- F: __dxlog_file10,
2517
+ log11("closed", void 0, {
2518
+ F: __dxlog_file12,
2036
2519
  L: 59,
2037
2520
  S: this,
2038
2521
  C: (f, a) => f(...a)
@@ -2046,11 +2529,11 @@ var WebRTCTransport = class {
2046
2529
  try {
2047
2530
  if (typeof ((_a2 = this._peer) == null ? void 0 : _a2._pc.getStats) === "function") {
2048
2531
  this._peer._pc.getStats().then((stats) => {
2049
- log10.warn("report after webrtc error", {
2532
+ log11.warn("report after webrtc error", {
2050
2533
  config: this.params.webrtcConfig,
2051
2534
  stats
2052
2535
  }, {
2053
- F: __dxlog_file10,
2536
+ F: __dxlog_file12,
2054
2537
  L: 71,
2055
2538
  S: this,
2056
2539
  C: (f, a) => f(...a)
@@ -2061,18 +2544,18 @@ var WebRTCTransport = class {
2061
2544
  }
2062
2545
  await this.destroy();
2063
2546
  });
2064
- log10.trace("dxos.mesh.webrtc-transport.constructor", trace4.end({
2547
+ log11.trace("dxos.mesh.webrtc-transport.constructor", trace4.end({
2065
2548
  id: this._instanceId
2066
2549
  }), {
2067
- F: __dxlog_file10,
2550
+ F: __dxlog_file12,
2068
2551
  L: 81,
2069
2552
  S: this,
2070
2553
  C: (f, a) => f(...a)
2071
2554
  });
2072
2555
  }
2073
2556
  async destroy() {
2074
- log10("closing...", void 0, {
2075
- F: __dxlog_file10,
2557
+ log11("closing...", void 0, {
2558
+ F: __dxlog_file12,
2076
2559
  L: 85,
2077
2560
  S: this,
2078
2561
  C: (f, a) => f(...a)
@@ -2081,8 +2564,8 @@ var WebRTCTransport = class {
2081
2564
  await this._disconnectStreams();
2082
2565
  this._peer.destroy();
2083
2566
  this.closed.emit();
2084
- log10("closed", void 0, {
2085
- F: __dxlog_file10,
2567
+ log11("closed", void 0, {
2568
+ F: __dxlog_file12,
2086
2569
  L: 90,
2087
2570
  S: this,
2088
2571
  C: (f, a) => f(...a)
@@ -2092,7 +2575,15 @@ var WebRTCTransport = class {
2092
2575
  if (this._closed) {
2093
2576
  return;
2094
2577
  }
2095
- invariant10(signal.payload.data, "Signal message must contain signal data.");
2578
+ invariant11(signal.payload.data, "Signal message must contain signal data.", {
2579
+ F: __dxlog_file12,
2580
+ L: 98,
2581
+ S: this,
2582
+ A: [
2583
+ "signal.payload.data",
2584
+ "'Signal message must contain signal data.'"
2585
+ ]
2586
+ });
2096
2587
  this._peer.signal(signal.payload.data);
2097
2588
  }
2098
2589
  async _disconnectStreams() {
@@ -2109,23 +2600,30 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
2109
2600
 
2110
2601
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
2111
2602
  import { Duplex } from "@dxos/node-std/stream";
2112
- import invariant11 from "tiny-invariant";
2113
2603
  import { Stream } from "@dxos/codec-protobuf";
2114
- import { PublicKey as PublicKey10 } from "@dxos/keys";
2115
- import { log as log11 } from "@dxos/log";
2604
+ import { invariant as invariant12 } from "@dxos/invariant";
2605
+ import { PublicKey as PublicKey11 } from "@dxos/keys";
2606
+ import { log as log12 } from "@dxos/log";
2116
2607
  import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
2117
- import { ComplexMap as ComplexMap7 } from "@dxos/util";
2118
- var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2608
+ import { ComplexMap as ComplexMap8 } from "@dxos/util";
2609
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2119
2610
  var WebRTCTransportService = class {
2120
2611
  // prettier-ignore
2121
2612
  constructor(_webrtcConfig) {
2122
2613
  this._webrtcConfig = _webrtcConfig;
2123
- this.transports = new ComplexMap7(PublicKey10.hash);
2614
+ this.transports = new ComplexMap8(PublicKey11.hash);
2124
2615
  }
2125
2616
  open(request) {
2126
2617
  const rpcStream = new Stream(({ ready, next, close }) => {
2127
2618
  const duplex = new Duplex({
2128
2619
  read: () => {
2620
+ const callbacks = [
2621
+ ...transportState.writeCallbacks
2622
+ ];
2623
+ transportState.writeCallbacks.length = 0;
2624
+ for (const cb of callbacks) {
2625
+ cb();
2626
+ }
2129
2627
  },
2130
2628
  write: function(chunk, _, callback) {
2131
2629
  next({
@@ -2177,30 +2675,54 @@ var WebRTCTransportService = class {
2177
2675
  });
2178
2676
  close();
2179
2677
  });
2180
- ready();
2181
- this.transports.set(request.proxyId, {
2678
+ const transportState = {
2182
2679
  transport,
2183
- stream: duplex
2184
- });
2680
+ stream: duplex,
2681
+ writeCallbacks: []
2682
+ };
2683
+ ready();
2684
+ this.transports.set(request.proxyId, transportState);
2185
2685
  });
2186
2686
  return rpcStream;
2187
2687
  }
2188
2688
  async sendSignal({ proxyId, signal }) {
2189
- invariant11(this.transports.has(proxyId));
2689
+ invariant12(this.transports.has(proxyId), void 0, {
2690
+ F: __dxlog_file13,
2691
+ L: 113,
2692
+ S: this,
2693
+ A: [
2694
+ "this.transports.has(proxyId)",
2695
+ ""
2696
+ ]
2697
+ });
2190
2698
  await this.transports.get(proxyId).transport.signal(signal);
2191
2699
  }
2192
2700
  async sendData({ proxyId, payload }) {
2193
- invariant11(this.transports.has(proxyId));
2194
- await this.transports.get(proxyId).stream.push(payload);
2701
+ invariant12(this.transports.has(proxyId), void 0, {
2702
+ F: __dxlog_file13,
2703
+ L: 118,
2704
+ S: this,
2705
+ A: [
2706
+ "this.transports.has(proxyId)",
2707
+ ""
2708
+ ]
2709
+ });
2710
+ const state = this.transports.get(proxyId);
2711
+ const bufferHasSpace = state.stream.push(payload);
2712
+ if (!bufferHasSpace) {
2713
+ await new Promise((resolve) => {
2714
+ state.writeCallbacks.push(resolve);
2715
+ });
2716
+ }
2195
2717
  }
2196
2718
  async close({ proxyId }) {
2197
2719
  var _a, _b;
2198
2720
  await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
2199
2721
  await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
2200
2722
  this.transports.delete(proxyId);
2201
- log11("Closed.", void 0, {
2202
- F: __dxlog_file11,
2203
- L: 109,
2723
+ log12("Closed.", void 0, {
2724
+ F: __dxlog_file13,
2725
+ L: 132,
2204
2726
  S: this,
2205
2727
  C: (f, a) => f(...a)
2206
2728
  });
@@ -2208,21 +2730,22 @@ var WebRTCTransportService = class {
2208
2730
  };
2209
2731
 
2210
2732
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2211
- import invariant12 from "tiny-invariant";
2733
+ import { Writable } from "@dxos/node-std/stream";
2212
2734
  import { Event as Event8 } from "@dxos/async";
2213
- import { Context as Context5 } from "@dxos/context";
2735
+ import { Context as Context6 } from "@dxos/context";
2214
2736
  import { ErrorStream as ErrorStream5 } from "@dxos/debug";
2215
- import { PublicKey as PublicKey11 } from "@dxos/keys";
2216
- import { log as log12 } from "@dxos/log";
2737
+ import { invariant as invariant13 } from "@dxos/invariant";
2738
+ import { PublicKey as PublicKey12 } from "@dxos/keys";
2739
+ import { log as log13 } from "@dxos/log";
2217
2740
  import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
2218
2741
  import { arrayToBuffer } from "@dxos/util";
2219
- var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2742
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2220
2743
  var WebRTCTransportProxy = class {
2221
2744
  // prettier-ignore
2222
2745
  constructor(_params) {
2223
2746
  this._params = _params;
2224
- this._proxyId = PublicKey11.random();
2225
- this._ctx = new Context5();
2747
+ this._proxyId = PublicKey12.random();
2748
+ this._ctx = new Context6();
2226
2749
  this.closed = new Event8();
2227
2750
  this._closed = false;
2228
2751
  this.connected = new Event8();
@@ -2233,9 +2756,9 @@ var WebRTCTransportProxy = class {
2233
2756
  });
2234
2757
  this._serviceStream.waitUntilReady().then(() => {
2235
2758
  this._serviceStream.subscribe(async (event) => {
2236
- log12("WebRTCTransportProxy: event", event, {
2237
- F: __dxlog_file12,
2238
- L: 50,
2759
+ log13("WebRTCTransportProxy: event", event, {
2760
+ F: __dxlog_file14,
2761
+ L: 51,
2239
2762
  S: this,
2240
2763
  C: (f, a) => f(...a)
2241
2764
  });
@@ -2247,28 +2770,24 @@ var WebRTCTransportProxy = class {
2247
2770
  await this._handleSignal(event.signal);
2248
2771
  }
2249
2772
  });
2250
- const dataListener = async (data) => {
2251
- try {
2252
- await this._params.bridgeService.sendData({
2773
+ this._params.stream.pipe(new Writable({
2774
+ write: (chunk, _, callback) => {
2775
+ this._params.bridgeService.sendData({
2253
2776
  proxyId: this._proxyId,
2254
- payload: data
2255
- });
2256
- } catch (err) {
2257
- log12.catch(err, void 0, {
2258
- F: __dxlog_file12,
2259
- L: 67,
2260
- S: this,
2261
- C: (f, a) => f(...a)
2777
+ payload: chunk
2778
+ }).then(() => callback(), (err) => {
2779
+ log13.catch(err, void 0, {
2780
+ F: __dxlog_file14,
2781
+ L: 69,
2782
+ S: this,
2783
+ C: (f, a) => f(...a)
2784
+ });
2262
2785
  });
2263
2786
  }
2264
- };
2265
- this._params.stream.on("data", dataListener);
2266
- this._ctx.onDispose(() => {
2267
- this._params.stream.off("data", dataListener);
2268
- });
2269
- }, (error) => log12.catch(error, void 0, {
2270
- F: __dxlog_file12,
2271
- L: 73,
2787
+ }));
2788
+ }, (error) => log13.catch(error, void 0, {
2789
+ F: __dxlog_file14,
2790
+ L: 75,
2272
2791
  S: this,
2273
2792
  C: (f, a) => f(...a)
2274
2793
  }));
@@ -2312,9 +2831,9 @@ var WebRTCTransportProxy = class {
2312
2831
  proxyId: this._proxyId
2313
2832
  });
2314
2833
  } catch (err) {
2315
- log12.catch(err, void 0, {
2316
- F: __dxlog_file12,
2317
- L: 124,
2834
+ log13.catch(err, void 0, {
2835
+ F: __dxlog_file14,
2836
+ L: 126,
2318
2837
  S: this,
2319
2838
  C: (f, a) => f(...a)
2320
2839
  });
@@ -2348,7 +2867,15 @@ var WebRTCTransportProxyFactory = class {
2348
2867
  return this;
2349
2868
  }
2350
2869
  createTransport(options) {
2351
- invariant12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2870
+ invariant13(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections", {
2871
+ F: __dxlog_file14,
2872
+ L: 163,
2873
+ S: this,
2874
+ A: [
2875
+ "this._bridgeService",
2876
+ "'WebRTCTransportProxyFactory is not ready to open connections'"
2877
+ ]
2878
+ });
2352
2879
  const transport = new WebRTCTransportProxy({
2353
2880
  ...options,
2354
2881
  bridgeService: this._bridgeService
@@ -2383,6 +2910,8 @@ export {
2383
2910
  SwarmMessenger,
2384
2911
  Swarm,
2385
2912
  SwarmMapper,
2913
+ MAX_CONCURRENT_INITIATING_CONNECTIONS,
2914
+ ConnectionLimiter,
2386
2915
  EventType,
2387
2916
  ConnectionLog,
2388
2917
  NetworkManager,
@@ -2398,4 +2927,4 @@ export {
2398
2927
  WebRTCTransportProxyFactory,
2399
2928
  createTeleportProtocolFactory
2400
2929
  };
2401
- //# sourceMappingURL=chunk-IBLQYMBY.mjs.map
2930
+ //# sourceMappingURL=chunk-FC6CWDES.mjs.map