@dxos/network-manager 0.1.53-main.e7b89d1 → 0.1.53-main.ef33b07

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.
@@ -1,4 +1,4 @@
1
- import "@dxos/node-std/globals"
1
+ import "@dxos/node-std/globals";
2
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
4
  }) : x)(function(x) {
@@ -8,7 +8,7 @@ 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 assert from "@dxos/node-std/assert";
11
+ import invariant from "tiny-invariant";
12
12
  import { DeferredTask, Event, sleep, synchronized } from "@dxos/async";
13
13
  import { Context, cancelWithContext } from "@dxos/context";
14
14
  import { ErrorStream } from "@dxos/debug";
@@ -16,7 +16,7 @@ import { CancelledError } from "@dxos/errors";
16
16
  import { PublicKey } from "@dxos/keys";
17
17
  import { log } from "@dxos/log";
18
18
  import { trace } from "@dxos/protocols";
19
- var __decorate = function(decorators, target, key, desc) {
19
+ function _ts_decorate(decorators, target, key, desc) {
20
20
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21
21
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
22
22
  r = Reflect.decorate(decorators, target, key, desc);
@@ -25,7 +25,8 @@ var __decorate = function(decorators, target, key, desc) {
25
25
  if (d = decorators[i])
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 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
29
30
  var STARTING_SIGNALLING_DELAY = 10;
30
31
  var MAX_SIGNALLING_DELAY = 300;
31
32
  var ConnectionState;
@@ -98,29 +99,29 @@ var Connection = class {
98
99
  */
99
100
  // TODO(burdon): Make async?
100
101
  openConnection() {
101
- assert(this._state === ConnectionState.INITIAL, "Invalid state.");
102
+ invariant(this._state === ConnectionState.INITIAL, "Invalid state.");
102
103
  log.trace("dxos.mesh.connection.open-connection", trace.begin({
103
104
  id: this._instanceId
104
105
  }), {
105
- file: "connection.ts",
106
- line: 115,
107
- scope: this,
108
- callSite: (f, a) => f(...a)
106
+ F: __dxlog_file,
107
+ L: 115,
108
+ S: this,
109
+ C: (f, a) => f(...a)
109
110
  });
110
111
  this._changeState(ConnectionState.CONNECTING);
111
112
  this._protocol.initialize().catch((err) => {
112
113
  this.errors.raise(err);
113
114
  });
114
115
  this._protocol.stream.on("close", () => {
115
- log("protocol stream closed", {}, {
116
- file: "connection.ts",
117
- line: 126,
118
- scope: this,
119
- callSite: (f, a) => f(...a)
116
+ log("protocol stream closed", void 0, {
117
+ F: __dxlog_file,
118
+ L: 126,
119
+ S: this,
120
+ C: (f, a) => f(...a)
120
121
  });
121
122
  this.close().catch((err) => this.errors.raise(err));
122
123
  });
123
- assert(!this._transport);
124
+ invariant(!this._transport);
124
125
  this._transport = this._transportFactory.createTransport({
125
126
  initiator: this.initiator,
126
127
  stream: this._protocol.stream,
@@ -145,10 +146,10 @@ var Connection = class {
145
146
  log.trace("dxos.mesh.connection.open-connection", trace.end({
146
147
  id: this._instanceId
147
148
  }), {
148
- file: "connection.ts",
149
- line: 159,
150
- scope: this,
151
- callSite: (f, a) => f(...a)
149
+ F: __dxlog_file,
150
+ L: 159,
151
+ S: this,
152
+ C: (f, a) => f(...a)
152
153
  });
153
154
  }
154
155
  async close() {
@@ -161,38 +162,38 @@ var Connection = class {
161
162
  log("closing...", {
162
163
  peerId: this.ownId
163
164
  }, {
164
- file: "connection.ts",
165
- line: 171,
166
- scope: this,
167
- callSite: (f, a) => f(...a)
165
+ F: __dxlog_file,
166
+ L: 171,
167
+ S: this,
168
+ C: (f, a) => f(...a)
168
169
  });
169
170
  try {
170
171
  await this._protocol.destroy();
171
172
  } catch (err) {
172
- log.catch(err, {}, {
173
- file: "connection.ts",
174
- line: 177,
175
- scope: this,
176
- callSite: (f, a) => f(...a)
173
+ log.catch(err, void 0, {
174
+ F: __dxlog_file,
175
+ L: 177,
176
+ S: this,
177
+ C: (f, a) => f(...a)
177
178
  });
178
179
  }
179
180
  try {
180
181
  await ((_a = this._transport) == null ? void 0 : _a.destroy());
181
- } catch (err1) {
182
- log.catch(err1, {}, {
183
- file: "connection.ts",
184
- line: 184,
185
- scope: this,
186
- callSite: (f, a) => f(...a)
182
+ } catch (err) {
183
+ log.catch(err, void 0, {
184
+ F: __dxlog_file,
185
+ L: 184,
186
+ S: this,
187
+ C: (f, a) => f(...a)
187
188
  });
188
189
  }
189
190
  log("closed", {
190
191
  peerId: this.ownId
191
192
  }, {
192
- file: "connection.ts",
193
- line: 187,
194
- scope: this,
195
- callSite: (f, a) => f(...a)
193
+ F: __dxlog_file,
194
+ L: 187,
195
+ S: this,
196
+ C: (f, a) => f(...a)
196
197
  });
197
198
  this._changeState(ConnectionState.CLOSED);
198
199
  }
@@ -229,10 +230,10 @@ var Connection = class {
229
230
  log.warn("Signal failed", {
230
231
  err
231
232
  }, {
232
- file: "connection.ts",
233
- line: 221,
234
- scope: this,
235
- callSite: (f, a) => f(...a)
233
+ F: __dxlog_file,
234
+ L: 221,
235
+ S: this,
236
+ C: (f, a) => f(...a)
236
237
  });
237
238
  await this.close();
238
239
  }
@@ -242,19 +243,19 @@ var Connection = class {
242
243
  */
243
244
  async signal(msg) {
244
245
  var _a, _b, _c;
245
- assert(msg.sessionId);
246
+ invariant(msg.sessionId);
246
247
  if (!msg.sessionId.equals(this.sessionId)) {
247
- log("dropping signal for incorrect session id", {}, {
248
- file: "connection.ts",
249
- line: 232,
250
- scope: this,
251
- callSite: (f, a) => f(...a)
248
+ log("dropping signal for incorrect session id", void 0, {
249
+ F: __dxlog_file,
250
+ L: 232,
251
+ S: this,
252
+ C: (f, a) => f(...a)
252
253
  });
253
254
  return;
254
255
  }
255
- assert(msg.data.signal || msg.data.signalBatch);
256
- assert((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
257
- assert((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
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));
258
259
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
259
260
  msg.data.signal
260
261
  ];
@@ -268,23 +269,23 @@ var Connection = class {
268
269
  remoteId: this.remoteId,
269
270
  msg: msg.data
270
271
  }, {
271
- file: "connection.ts",
272
- line: 246,
273
- scope: this,
274
- callSite: (f, a) => f(...a)
272
+ F: __dxlog_file,
273
+ L: 246,
274
+ S: this,
275
+ C: (f, a) => f(...a)
275
276
  });
276
277
  this._incomingSignalBuffer.push(signal);
277
278
  } else {
278
- assert(this._transport, "Connection not ready to accept signals.");
279
+ invariant(this._transport, "Connection not ready to accept signals.");
279
280
  log("received signal", {
280
281
  peerId: this.ownId,
281
282
  remoteId: this.remoteId,
282
283
  msg: msg.data
283
284
  }, {
284
- file: "connection.ts",
285
- line: 250,
286
- scope: this,
287
- callSite: (f, a) => f(...a)
285
+ F: __dxlog_file,
286
+ L: 250,
287
+ S: this,
288
+ C: (f, a) => f(...a)
288
289
  });
289
290
  await this._transport.signal(signal);
290
291
  }
@@ -296,27 +297,28 @@ var Connection = class {
296
297
  too: state,
297
298
  peerId: this.ownId
298
299
  }, {
299
- file: "connection.ts",
300
- line: 257,
301
- scope: this,
302
- callSite: (f, a) => f(...a)
300
+ F: __dxlog_file,
301
+ L: 257,
302
+ S: this,
303
+ C: (f, a) => f(...a)
303
304
  });
304
- assert(state !== this._state, "Already in this state.");
305
+ invariant(state !== this._state, "Already in this state.");
305
306
  this._state = state;
306
307
  this.stateChanged.emit(state);
307
308
  }
308
309
  };
309
- __decorate([
310
+ _ts_decorate([
310
311
  synchronized
311
312
  ], Connection.prototype, "close", null);
312
313
 
313
314
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
314
- import assert2 from "@dxos/node-std/assert";
315
+ import invariant2 from "tiny-invariant";
315
316
  import { Context as Context2 } from "@dxos/context";
316
317
  import { PublicKey as PublicKey2 } from "@dxos/keys";
317
318
  import { log as log2 } from "@dxos/log";
318
319
  import { schema } from "@dxos/protocols";
319
320
  import { ComplexMap } from "@dxos/util";
321
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
320
322
  var SwarmMessenger = class {
321
323
  constructor({ sendMessage, onSignal, onOffer, topic }) {
322
324
  this._ctx = new Context2();
@@ -340,10 +342,10 @@ var SwarmMessenger = class {
340
342
  to: recipient,
341
343
  msg: message
342
344
  }, {
343
- file: "swarm-messenger.ts",
344
- line: 68,
345
- scope: this,
346
- callSite: (f, a) => f(...a)
345
+ F: __dxlog_file2,
346
+ L: 68,
347
+ S: this,
348
+ C: (f, a) => f(...a)
347
349
  });
348
350
  if ((_a = message.data) == null ? void 0 : _a.offer) {
349
351
  await this._handleOffer({
@@ -369,16 +371,16 @@ var SwarmMessenger = class {
369
371
  log2.warn("unknown message", {
370
372
  message
371
373
  }, {
372
- file: "swarm-messenger.ts",
373
- line: 79,
374
- scope: this,
375
- callSite: (f, a) => f(...a)
374
+ F: __dxlog_file2,
375
+ L: 79,
376
+ S: this,
377
+ C: (f, a) => f(...a)
376
378
  });
377
379
  }
378
380
  }
379
381
  async signal(message) {
380
382
  var _a, _b;
381
- assert2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
383
+ invariant2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
382
384
  await this._sendReliableMessage({
383
385
  author: message.author,
384
386
  recipient: message.recipient,
@@ -413,10 +415,10 @@ var SwarmMessenger = class {
413
415
  to: recipient,
414
416
  msg: networkMessage
415
417
  }, {
416
- file: "swarm-messenger.ts",
417
- line: 122,
418
- scope: this,
419
- callSite: (f, a) => f(...a)
418
+ F: __dxlog_file2,
419
+ L: 122,
420
+ S: this,
421
+ C: (f, a) => f(...a)
420
422
  });
421
423
  await this._sendMessage({
422
424
  author,
@@ -429,24 +431,24 @@ var SwarmMessenger = class {
429
431
  }
430
432
  async _resolveAnswers(message) {
431
433
  var _a, _b, _c;
432
- assert2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
434
+ invariant2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
433
435
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
434
436
  if (offerRecord) {
435
437
  this._offerRecords.delete(message.data.answer.offerMessageId);
436
- assert2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
438
+ invariant2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
437
439
  log2("resolving", {
438
440
  answer: message.data.answer
439
441
  }, {
440
- file: "swarm-messenger.ts",
441
- line: 139,
442
- scope: this,
443
- callSite: (f, a) => f(...a)
442
+ F: __dxlog_file2,
443
+ L: 139,
444
+ S: this,
445
+ C: (f, a) => f(...a)
444
446
  });
445
447
  offerRecord.resolve(message.data.answer);
446
448
  }
447
449
  }
448
450
  async _handleOffer({ author, recipient, message }) {
449
- assert2(message.data.offer, "No offer");
451
+ invariant2(message.data.offer, "No offer");
450
452
  const offerMessage = {
451
453
  author,
452
454
  recipient,
@@ -473,16 +475,16 @@ var SwarmMessenger = class {
473
475
  log2.warn("error sending answer", {
474
476
  err
475
477
  }, {
476
- file: "swarm-messenger.ts",
477
- line: 173,
478
- scope: this,
479
- callSite: (f, a) => f(...a)
478
+ F: __dxlog_file2,
479
+ L: 173,
480
+ S: this,
481
+ C: (f, a) => f(...a)
480
482
  });
481
483
  }
482
484
  }
483
485
  async _handleSignal({ author, recipient, message }) {
484
- assert2(message.messageId);
485
- assert2(message.data.signal || message.data.signalBatch, "Invalid message");
486
+ invariant2(message.messageId);
487
+ invariant2(message.data.signal || message.data.signalBatch, "Invalid message");
486
488
  const signalMessage = {
487
489
  author,
488
490
  recipient,
@@ -497,7 +499,7 @@ var SwarmMessenger = class {
497
499
  };
498
500
 
499
501
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
500
- import assert4 from "@dxos/node-std/assert";
502
+ import invariant4 from "tiny-invariant";
501
503
  import { Event as Event2, scheduleTask as scheduleTask2, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
502
504
  import { Context as Context4 } from "@dxos/context";
503
505
  import { ErrorStream as ErrorStream2 } from "@dxos/debug";
@@ -507,12 +509,12 @@ import { trace as trace2 } from "@dxos/protocols";
507
509
  import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
508
510
 
509
511
  // packages/core/mesh/network-manager/src/swarm/peer.ts
510
- import assert3 from "@dxos/node-std/assert";
512
+ import invariant3 from "tiny-invariant";
511
513
  import { scheduleTask, synchronized as synchronized2 } from "@dxos/async";
512
514
  import { Context as Context3 } from "@dxos/context";
513
515
  import { PublicKey as PublicKey3 } from "@dxos/keys";
514
516
  import { log as log3 } from "@dxos/log";
515
- var __decorate2 = function(decorators, target, key, desc) {
517
+ function _ts_decorate2(decorators, target, key, desc) {
516
518
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
517
519
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
518
520
  r = Reflect.decorate(decorators, target, key, desc);
@@ -521,7 +523,8 @@ var __decorate2 = function(decorators, target, key, desc) {
521
523
  if (d = decorators[i])
522
524
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
523
525
  return c > 3 && r && Object.defineProperty(target, key, r), r;
524
- };
526
+ }
527
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
525
528
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
526
529
  var Peer = class {
527
530
  constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _callbacks) {
@@ -550,10 +553,10 @@ var Peer = class {
550
553
  topic: this.topic,
551
554
  peerId: this.localPeerId
552
555
  }, {
553
- file: "peer.ts",
554
- line: 105,
555
- scope: this,
556
- callSite: (f, a) => f(...a)
556
+ F: __dxlog_file3,
557
+ L: 105,
558
+ S: this,
559
+ C: (f, a) => f(...a)
557
560
  });
558
561
  if (this.connection) {
559
562
  await this.closeConnection();
@@ -566,7 +569,7 @@ var Peer = class {
566
569
  }
567
570
  if (await this._callbacks.onOffer(remoteId)) {
568
571
  if (!this.connection) {
569
- assert3(message.sessionId);
572
+ invariant3(message.sessionId);
570
573
  const connection = this._createConnection(false, message.sessionId);
571
574
  try {
572
575
  connection.openConnection();
@@ -577,10 +580,10 @@ var Peer = class {
577
580
  remoteId: this.id,
578
581
  err
579
582
  }, {
580
- file: "peer.ts",
581
- line: 129,
582
- scope: this,
583
- callSite: (f, a) => f(...a)
583
+ F: __dxlog_file3,
584
+ L: 129,
585
+ S: this,
586
+ C: (f, a) => f(...a)
584
587
  });
585
588
  await this.closeConnection();
586
589
  }
@@ -597,8 +600,8 @@ var Peer = class {
597
600
  * Initiate a connection to the remote peer.
598
601
  */
599
602
  async initiateConnection() {
600
- assert3(!this.initiating, "Initiation in progress.");
601
- assert3(!this.connection, "Already connected.");
603
+ invariant3(!this.initiating, "Initiation in progress.");
604
+ invariant3(!this.connection, "Already connected.");
602
605
  const sessionId = PublicKey3.random();
603
606
  log3("initiating...", {
604
607
  id: this.id,
@@ -606,10 +609,10 @@ var Peer = class {
606
609
  peerId: this.id,
607
610
  sessionId
608
611
  }, {
609
- file: "peer.ts",
610
- line: 147,
611
- scope: this,
612
- callSite: (f, a) => f(...a)
612
+ F: __dxlog_file3,
613
+ L: 147,
614
+ S: this,
615
+ C: (f, a) => f(...a)
613
616
  });
614
617
  const connection = this._createConnection(true, sessionId);
615
618
  this.initiating = true;
@@ -629,17 +632,17 @@ var Peer = class {
629
632
  ownId: this.localPeerId,
630
633
  remoteId: this.id
631
634
  }, {
632
- file: "peer.ts",
633
- line: 159,
634
- scope: this,
635
- callSite: (f, a) => f(...a)
635
+ F: __dxlog_file3,
636
+ L: 159,
637
+ S: this,
638
+ C: (f, a) => f(...a)
636
639
  });
637
640
  if (connection.state !== ConnectionState.INITIAL) {
638
- log3("ignoring response", {}, {
639
- file: "peer.ts",
640
- line: 161,
641
- scope: this,
642
- callSite: (f, a) => f(...a)
641
+ log3("ignoring response", void 0, {
642
+ F: __dxlog_file3,
643
+ L: 161,
644
+ S: this,
645
+ C: (f, a) => f(...a)
643
646
  });
644
647
  return;
645
648
  }
@@ -656,10 +659,10 @@ var Peer = class {
656
659
  peerId: this.localPeerId,
657
660
  remoteId: this.id
658
661
  }, {
659
- file: "peer.ts",
660
- line: 172,
661
- scope: this,
662
- callSite: (f, a) => f(...a)
662
+ F: __dxlog_file3,
663
+ L: 172,
664
+ S: this,
665
+ C: (f, a) => f(...a)
663
666
  });
664
667
  await this.closeConnection();
665
668
  throw err;
@@ -680,12 +683,12 @@ var Peer = class {
680
683
  initiator,
681
684
  sessionId
682
685
  }, {
683
- file: "peer.ts",
684
- line: 186,
685
- scope: this,
686
- callSite: (f, a) => f(...a)
686
+ F: __dxlog_file3,
687
+ L: 186,
688
+ S: this,
689
+ C: (f, a) => f(...a)
687
690
  });
688
- assert3(!this.connection, "Already connected.");
691
+ invariant3(!this.connection, "Already connected.");
689
692
  const connection = new Connection(
690
693
  this.topic,
691
694
  this.localPeerId,
@@ -720,12 +723,12 @@ var Peer = class {
720
723
  remoteId: this.id,
721
724
  initiator
722
725
  }, {
723
- file: "peer.ts",
724
- line: 221,
725
- scope: this,
726
- callSite: (f, a) => f(...a)
726
+ F: __dxlog_file3,
727
+ L: 221,
728
+ S: this,
729
+ C: (f, a) => f(...a)
727
730
  });
728
- assert3(this.connection === connection, "Connection mismatch (race condition).");
731
+ invariant3(this.connection === connection, "Connection mismatch (race condition).");
729
732
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
730
733
  this._availableAfter = 0;
731
734
  } else {
@@ -750,10 +753,10 @@ var Peer = class {
750
753
  initiator,
751
754
  err
752
755
  }, {
753
- file: "peer.ts",
754
- line: 249,
755
- scope: this,
756
- callSite: (f, a) => f(...a)
756
+ F: __dxlog_file3,
757
+ L: 249,
758
+ S: this,
759
+ C: (f, a) => f(...a)
757
760
  });
758
761
  void this.closeConnection();
759
762
  });
@@ -769,20 +772,20 @@ var Peer = class {
769
772
  peerId: this.id,
770
773
  sessionId: connection.sessionId
771
774
  }, {
772
- file: "peer.ts",
773
- line: 265,
774
- scope: this,
775
- callSite: (f, a) => f(...a)
775
+ F: __dxlog_file3,
776
+ L: 265,
777
+ S: this,
778
+ C: (f, a) => f(...a)
776
779
  });
777
780
  await connection.close();
778
781
  log3("closed", {
779
782
  peerId: this.id,
780
783
  sessionId: connection.sessionId
781
784
  }, {
782
- file: "peer.ts",
783
- line: 271,
784
- scope: this,
785
- callSite: (f, a) => f(...a)
785
+ F: __dxlog_file3,
786
+ L: 271,
787
+ S: this,
788
+ C: (f, a) => f(...a)
786
789
  });
787
790
  }
788
791
  async onSignal(message) {
@@ -790,10 +793,10 @@ var Peer = class {
790
793
  log3("dropping signal message for non-existent connection", {
791
794
  message
792
795
  }, {
793
- file: "peer.ts",
794
- line: 276,
795
- scope: this,
796
- callSite: (f, a) => f(...a)
796
+ F: __dxlog_file3,
797
+ L: 276,
798
+ S: this,
799
+ C: (f, a) => f(...a)
797
800
  });
798
801
  return;
799
802
  }
@@ -806,15 +809,15 @@ var Peer = class {
806
809
  peerId: this.id,
807
810
  topic: this.topic
808
811
  }, {
809
- file: "peer.ts",
810
- line: 285,
811
- scope: this,
812
- callSite: (f, a) => f(...a)
812
+ F: __dxlog_file3,
813
+ L: 285,
814
+ S: this,
815
+ C: (f, a) => f(...a)
813
816
  });
814
817
  await ((_a = this == null ? void 0 : this.connection) == null ? void 0 : _a.close());
815
818
  }
816
819
  };
817
- __decorate2([
820
+ _ts_decorate2([
818
821
  synchronized2
819
822
  ], Peer.prototype, "destroy", null);
820
823
  var increaseInterval = (interval) => {
@@ -831,7 +834,7 @@ var increaseInterval = (interval) => {
831
834
  };
832
835
 
833
836
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
834
- var __decorate3 = function(decorators, target, key, desc) {
837
+ function _ts_decorate3(decorators, target, key, desc) {
835
838
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
836
839
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
837
840
  r = Reflect.decorate(decorators, target, key, desc);
@@ -840,7 +843,8 @@ var __decorate3 = function(decorators, target, key, desc) {
840
843
  if (d = decorators[i])
841
844
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
842
845
  return c > 3 && r && Object.defineProperty(target, key, r), r;
843
- };
846
+ }
847
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
844
848
  var INITIATION_DELAY = 100;
845
849
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
846
850
  var Swarm = class {
@@ -857,11 +861,11 @@ var Swarm = class {
857
861
  this._peers = new ComplexMap2(PublicKey4.hash);
858
862
  this._ctx = new Context4();
859
863
  this._listeningHandle = void 0;
864
+ this._instanceId = PublicKey4.random().toHex();
860
865
  this.connectionAdded = new Event2();
861
866
  this.disconnected = new Event2();
862
867
  this.connected = new Event2();
863
868
  this.errors = new ErrorStream2();
864
- this._instanceId = PublicKey4.random().toHex();
865
869
  log4.trace("dxos.mesh.swarm.constructor", trace2.begin({
866
870
  id: this._instanceId,
867
871
  data: {
@@ -869,18 +873,18 @@ var Swarm = class {
869
873
  peerId: this._ownPeerId.toHex()
870
874
  }
871
875
  }), {
872
- file: "swarm.ts",
873
- line: 86,
874
- scope: this,
875
- callSite: (f, a) => f(...a)
876
+ F: __dxlog_file4,
877
+ L: 86,
878
+ S: this,
879
+ C: (f, a) => f(...a)
876
880
  });
877
881
  log4("creating swarm", {
878
882
  peerId: _ownPeerId
879
883
  }, {
880
- file: "swarm.ts",
881
- line: 90,
882
- scope: this,
883
- callSite: (f, a) => f(...a)
884
+ F: __dxlog_file4,
885
+ L: 90,
886
+ S: this,
887
+ C: (f, a) => f(...a)
884
888
  });
885
889
  _topology.init(this._getSwarmController());
886
890
  this._swarmMessenger = new SwarmMessenger({
@@ -892,10 +896,10 @@ var Swarm = class {
892
896
  log4.trace("dxos.mesh.swarm.constructor", trace2.end({
893
897
  id: this._instanceId
894
898
  }), {
895
- file: "swarm.ts",
896
- line: 99,
897
- scope: this,
898
- callSite: (f, a) => f(...a)
899
+ F: __dxlog_file4,
900
+ L: 99,
901
+ S: this,
902
+ C: (f, a) => f(...a)
899
903
  });
900
904
  }
901
905
  get connections() {
@@ -914,7 +918,7 @@ var Swarm = class {
914
918
  return this._topic;
915
919
  }
916
920
  async open() {
917
- assert4(!this._listeningHandle);
921
+ invariant4(!this._listeningHandle);
918
922
  this._listeningHandle = await this._messenger.listen({
919
923
  peerId: this._ownPeerId,
920
924
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -922,36 +926,36 @@ var Swarm = class {
922
926
  await this._swarmMessenger.receiveMessage(message).catch((err) => log4.warn("Error while receiving message", {
923
927
  err
924
928
  }, {
925
- file: "swarm.ts",
926
- line: 133,
927
- scope: this,
928
- callSite: (f, a) => f(...a)
929
+ F: __dxlog_file4,
930
+ L: 133,
931
+ S: this,
932
+ C: (f, a) => f(...a)
929
933
  }));
930
934
  }
931
935
  });
932
936
  }
933
937
  async destroy() {
934
938
  var _a;
935
- log4("destroying...", {}, {
936
- file: "swarm.ts",
937
- line: 139,
938
- scope: this,
939
- callSite: (f, a) => f(...a)
939
+ log4("destroying...", void 0, {
940
+ F: __dxlog_file4,
941
+ L: 139,
942
+ S: this,
943
+ C: (f, a) => f(...a)
940
944
  });
941
945
  await ((_a = this._listeningHandle) == null ? void 0 : _a.unsubscribe());
942
946
  this._listeningHandle = void 0;
943
947
  await this._ctx.dispose();
944
948
  await this._topology.destroy();
945
949
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
946
- log4("destroyed", {}, {
947
- file: "swarm.ts",
948
- line: 146,
949
- scope: this,
950
- callSite: (f, a) => f(...a)
950
+ log4("destroyed", void 0, {
951
+ F: __dxlog_file4,
952
+ L: 146,
953
+ S: this,
954
+ C: (f, a) => f(...a)
951
955
  });
952
956
  }
953
957
  async setTopology(topology) {
954
- assert4(!this._ctx.disposed, "Swarm is offline");
958
+ invariant4(!this._ctx.disposed, "Swarm is offline");
955
959
  if (topology === this._topology) {
956
960
  return;
957
961
  }
@@ -959,10 +963,10 @@ var Swarm = class {
959
963
  previous: getClassName(this._topology),
960
964
  topology: getClassName(topology)
961
965
  }, {
962
- file: "swarm.ts",
963
- line: 154,
964
- scope: this,
965
- callSite: (f, a) => f(...a)
966
+ F: __dxlog_file4,
967
+ L: 154,
968
+ S: this,
969
+ C: (f, a) => f(...a)
966
970
  });
967
971
  await this._topology.destroy();
968
972
  this._topology = topology;
@@ -974,17 +978,17 @@ var Swarm = class {
974
978
  log4("swarm event", {
975
979
  swarmEvent
976
980
  }, {
977
- file: "swarm.ts",
978
- line: 167,
979
- scope: this,
980
- callSite: (f, a) => f(...a)
981
+ F: __dxlog_file4,
982
+ L: 167,
983
+ S: this,
984
+ C: (f, a) => f(...a)
981
985
  });
982
986
  if (this._ctx.disposed) {
983
- log4("swarm event ignored for disposed swarm", {}, {
984
- file: "swarm.ts",
985
- line: 170,
986
- scope: this,
987
- callSite: (f, a) => f(...a)
987
+ log4("swarm event ignored for disposed swarm", void 0, {
988
+ F: __dxlog_file4,
989
+ L: 170,
990
+ S: this,
991
+ C: (f, a) => f(...a)
988
992
  });
989
993
  return;
990
994
  }
@@ -993,25 +997,25 @@ var Swarm = class {
993
997
  log4("new peer", {
994
998
  peerId
995
999
  }, {
996
- file: "swarm.ts",
997
- line: 176,
998
- scope: this,
999
- callSite: (f, a) => f(...a)
1000
+ F: __dxlog_file4,
1001
+ L: 176,
1002
+ S: this,
1003
+ C: (f, a) => f(...a)
1000
1004
  });
1001
1005
  if (!peerId.equals(this._ownPeerId)) {
1002
1006
  const peer = this._getOrCreatePeer(peerId);
1003
1007
  peer.advertizing = true;
1004
1008
  }
1005
1009
  } else if (swarmEvent.peerLeft) {
1006
- const peer1 = this._peers.get(PublicKey4.from(swarmEvent.peerLeft.peer));
1007
- if (peer1) {
1008
- peer1.advertizing = false;
1009
- if (((_a = peer1.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
1010
- void this._destroyPeer(peer1.id).catch((err) => log4.catch(err, {}, {
1011
- file: "swarm.ts",
1012
- line: 187,
1013
- scope: this,
1014
- callSite: (f, a) => f(...a)
1010
+ const peer = this._peers.get(PublicKey4.from(swarmEvent.peerLeft.peer));
1011
+ if (peer) {
1012
+ peer.advertizing = false;
1013
+ if (((_a = peer.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
1014
+ void this._destroyPeer(peer.id).catch((err) => log4.catch(err, void 0, {
1015
+ F: __dxlog_file4,
1016
+ L: 187,
1017
+ S: this,
1018
+ C: (f, a) => f(...a)
1015
1019
  }));
1016
1020
  }
1017
1021
  }
@@ -1023,31 +1027,31 @@ var Swarm = class {
1023
1027
  log4("offer", {
1024
1028
  message
1025
1029
  }, {
1026
- file: "swarm.ts",
1027
- line: 197,
1028
- scope: this,
1029
- callSite: (f, a) => f(...a)
1030
+ F: __dxlog_file4,
1031
+ L: 197,
1032
+ S: this,
1033
+ C: (f, a) => f(...a)
1030
1034
  });
1031
1035
  if (this._ctx.disposed) {
1032
- log4("ignored for disposed swarm", {}, {
1033
- file: "swarm.ts",
1034
- line: 199,
1035
- scope: this,
1036
- callSite: (f, a) => f(...a)
1036
+ log4("ignored for disposed swarm", void 0, {
1037
+ F: __dxlog_file4,
1038
+ L: 199,
1039
+ S: this,
1040
+ C: (f, a) => f(...a)
1037
1041
  });
1038
1042
  return {
1039
1043
  accept: false
1040
1044
  };
1041
1045
  }
1042
- assert4(message.author);
1046
+ invariant4(message.author);
1043
1047
  if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
1044
1048
  log4("rejecting offer with incorrect peerId", {
1045
1049
  message
1046
1050
  }, {
1047
- file: "swarm.ts",
1048
- line: 206,
1049
- scope: this,
1050
- callSite: (f, a) => f(...a)
1051
+ F: __dxlog_file4,
1052
+ L: 206,
1053
+ S: this,
1054
+ C: (f, a) => f(...a)
1051
1055
  });
1052
1056
  return {
1053
1057
  accept: false
@@ -1057,10 +1061,10 @@ var Swarm = class {
1057
1061
  log4("rejecting offer with incorrect topic", {
1058
1062
  message
1059
1063
  }, {
1060
- file: "swarm.ts",
1061
- line: 210,
1062
- scope: this,
1063
- callSite: (f, a) => f(...a)
1064
+ F: __dxlog_file4,
1065
+ L: 210,
1066
+ S: this,
1067
+ C: (f, a) => f(...a)
1064
1068
  });
1065
1069
  return {
1066
1070
  accept: false
@@ -1076,23 +1080,23 @@ var Swarm = class {
1076
1080
  log4("signal", {
1077
1081
  message
1078
1082
  }, {
1079
- file: "swarm.ts",
1080
- line: 222,
1081
- scope: this,
1082
- callSite: (f, a) => f(...a)
1083
+ F: __dxlog_file4,
1084
+ L: 222,
1085
+ S: this,
1086
+ C: (f, a) => f(...a)
1083
1087
  });
1084
1088
  if (this._ctx.disposed) {
1085
- log4.info("ignored for offline swarm", {}, {
1086
- file: "swarm.ts",
1087
- line: 224,
1088
- scope: this,
1089
- callSite: (f, a) => f(...a)
1089
+ log4.info("ignored for offline swarm", void 0, {
1090
+ F: __dxlog_file4,
1091
+ L: 224,
1092
+ S: this,
1093
+ C: (f, a) => f(...a)
1090
1094
  });
1091
1095
  return;
1092
1096
  }
1093
- assert4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1094
- assert4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1095
- assert4(message.author);
1097
+ invariant4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1098
+ invariant4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1099
+ invariant4(message.author);
1096
1100
  const peer = this._getOrCreatePeer(message.author);
1097
1101
  await peer.onSignal(message);
1098
1102
  }
@@ -1144,7 +1148,7 @@ var Swarm = class {
1144
1148
  return peer;
1145
1149
  }
1146
1150
  async _destroyPeer(peerId) {
1147
- assert4(this._peers.has(peerId));
1151
+ invariant4(this._peers.has(peerId));
1148
1152
  await this._peers.get(peerId).destroy();
1149
1153
  this._peers.delete(peerId);
1150
1154
  }
@@ -1164,10 +1168,10 @@ var Swarm = class {
1164
1168
  await this._initiateConnection(peer);
1165
1169
  } catch (err) {
1166
1170
  log4("initiation error", err, {
1167
- file: "swarm.ts",
1168
- line: 327,
1169
- scope: this,
1170
- callSite: (f, a) => f(...a)
1171
+ F: __dxlog_file4,
1172
+ L: 327,
1173
+ S: this,
1174
+ C: (f, a) => f(...a)
1171
1175
  });
1172
1176
  }
1173
1177
  });
@@ -1192,10 +1196,10 @@ var Swarm = class {
1192
1196
  log4("initiation delay", {
1193
1197
  remoteId
1194
1198
  }, {
1195
- file: "swarm.ts",
1196
- line: 354,
1197
- scope: this,
1198
- callSite: (f, a) => f(...a)
1199
+ F: __dxlog_file4,
1200
+ L: 354,
1201
+ S: this,
1202
+ C: (f, a) => f(...a)
1199
1203
  });
1200
1204
  await sleep2(INITIATION_DELAY);
1201
1205
  }
@@ -1209,20 +1213,20 @@ var Swarm = class {
1209
1213
  log4("initiating connection...", {
1210
1214
  remoteId
1211
1215
  }, {
1212
- file: "swarm.ts",
1213
- line: 368,
1214
- scope: this,
1215
- callSite: (f, a) => f(...a)
1216
+ F: __dxlog_file4,
1217
+ L: 368,
1218
+ S: this,
1219
+ C: (f, a) => f(...a)
1216
1220
  });
1217
1221
  await peer.initiateConnection();
1218
1222
  this._topology.update();
1219
1223
  log4("initiated", {
1220
1224
  remoteId
1221
1225
  }, {
1222
- file: "swarm.ts",
1223
- line: 371,
1224
- scope: this,
1225
- callSite: (f, a) => f(...a)
1226
+ F: __dxlog_file4,
1227
+ L: 371,
1228
+ S: this,
1229
+ C: (f, a) => f(...a)
1226
1230
  });
1227
1231
  }
1228
1232
  async _closeConnection(peerId) {
@@ -1233,28 +1237,28 @@ var Swarm = class {
1233
1237
  await peer.closeConnection();
1234
1238
  }
1235
1239
  };
1236
- __decorate3([
1240
+ _ts_decorate3([
1237
1241
  logInfo
1238
1242
  ], Swarm.prototype, "_instanceId", void 0);
1239
- __decorate3([
1243
+ _ts_decorate3([
1240
1244
  logInfo
1241
1245
  ], Swarm.prototype, "ownPeerId", null);
1242
- __decorate3([
1246
+ _ts_decorate3([
1243
1247
  logInfo
1244
1248
  ], Swarm.prototype, "topic", null);
1245
- __decorate3([
1249
+ _ts_decorate3([
1246
1250
  synchronized3
1247
1251
  ], Swarm.prototype, "onSwarmEvent", null);
1248
- __decorate3([
1252
+ _ts_decorate3([
1249
1253
  synchronized3
1250
1254
  ], Swarm.prototype, "onOffer", null);
1251
- __decorate3([
1255
+ _ts_decorate3([
1252
1256
  synchronized3
1253
1257
  ], Swarm.prototype, "onSignal", null);
1254
- __decorate3([
1258
+ _ts_decorate3([
1255
1259
  synchronized3
1256
1260
  ], Swarm.prototype, "goOffline", null);
1257
- __decorate3([
1261
+ _ts_decorate3([
1258
1262
  synchronized3
1259
1263
  ], Swarm.prototype, "goOnline", null);
1260
1264
 
@@ -1263,6 +1267,7 @@ import { Event as Event3, EventSubscriptions } from "@dxos/async";
1263
1267
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1264
1268
  import { log as log5 } from "@dxos/log";
1265
1269
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
1270
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1266
1271
  var SwarmMapper = class {
1267
1272
  get peers() {
1268
1273
  return Array.from(this._peers.values());
@@ -1289,11 +1294,11 @@ var SwarmMapper = class {
1289
1294
  this._update();
1290
1295
  }
1291
1296
  _update() {
1292
- log5("updating swarm", {}, {
1293
- file: "swarm-mapper.ts",
1294
- line: 75,
1295
- scope: this,
1296
- callSite: (f, a) => f(...a)
1297
+ log5("updating swarm", void 0, {
1298
+ F: __dxlog_file5,
1299
+ L: 75,
1300
+ S: this,
1301
+ C: (f, a) => f(...a)
1297
1302
  });
1298
1303
  this._peers.clear();
1299
1304
  this._peers.set(this._swarm.ownPeerId, {
@@ -1314,10 +1319,10 @@ var SwarmMapper = class {
1314
1319
  directConnections: this._swarm.connections.length,
1315
1320
  totalPeersInSwarm: this._peers.size
1316
1321
  }, {
1317
- file: "swarm-mapper.ts",
1318
- line: 116,
1319
- scope: this,
1320
- callSite: (f, a) => f(...a)
1322
+ F: __dxlog_file5,
1323
+ L: 116,
1324
+ S: this,
1325
+ C: (f, a) => f(...a)
1321
1326
  });
1322
1327
  this.mapUpdated.emit(Array.from(this._peers.values()));
1323
1328
  }
@@ -1399,7 +1404,7 @@ var ConnectionLog = class {
1399
1404
  };
1400
1405
 
1401
1406
  // packages/core/mesh/network-manager/src/network-manager.ts
1402
- import assert5 from "@dxos/node-std/assert";
1407
+ import invariant5 from "tiny-invariant";
1403
1408
  import { Event as Event5 } from "@dxos/async";
1404
1409
  import { PublicKey as PublicKey7 } from "@dxos/keys";
1405
1410
  import { log as log6 } from "@dxos/log";
@@ -1407,8 +1412,9 @@ import { Messenger } from "@dxos/messaging";
1407
1412
  import { trace as trace3 } from "@dxos/protocols";
1408
1413
  import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
1409
1414
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1415
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
1410
1416
  var NetworkManager = class {
1411
- constructor({ transportFactory, signalManager, log: log13 }) {
1417
+ constructor({ transportFactory, signalManager, log: log1 }) {
1412
1418
  this._swarms = new ComplexMap5(PublicKey7.hash);
1413
1419
  this._mappers = new ComplexMap5(PublicKey7.hash);
1414
1420
  this._connectionState = ConnectionState2.ONLINE;
@@ -1428,7 +1434,7 @@ var NetworkManager = class {
1428
1434
  join: (opts) => this._signalManager.join(opts),
1429
1435
  leave: (opts) => this._signalManager.leave(opts)
1430
1436
  };
1431
- if (log13) {
1437
+ if (log1) {
1432
1438
  this._connectionLog = new ConnectionLog();
1433
1439
  }
1434
1440
  }
@@ -1453,30 +1459,30 @@ var NetworkManager = class {
1453
1459
  log6.trace("dxos.mesh.network-manager.open", trace3.begin({
1454
1460
  id: this._instanceId
1455
1461
  }), {
1456
- file: "network-manager.ts",
1457
- line: 127,
1458
- scope: this,
1459
- callSite: (f, a) => f(...a)
1462
+ F: __dxlog_file6,
1463
+ L: 127,
1464
+ S: this,
1465
+ C: (f, a) => f(...a)
1460
1466
  });
1461
1467
  await this._messenger.open();
1462
1468
  await this._signalManager.open();
1463
1469
  log6.trace("dxos.mesh.network-manager.open", trace3.end({
1464
1470
  id: this._instanceId
1465
1471
  }), {
1466
- file: "network-manager.ts",
1467
- line: 130,
1468
- scope: this,
1469
- callSite: (f, a) => f(...a)
1472
+ F: __dxlog_file6,
1473
+ L: 130,
1474
+ S: this,
1475
+ C: (f, a) => f(...a)
1470
1476
  });
1471
1477
  }
1472
1478
  async close() {
1473
1479
  for (const topic of this._swarms.keys()) {
1474
1480
  await this.leaveSwarm(topic).catch((err) => {
1475
- log6(err, {}, {
1476
- file: "network-manager.ts",
1477
- line: 136,
1478
- scope: this,
1479
- callSite: (f, a) => f(...a)
1481
+ log6(err, void 0, {
1482
+ F: __dxlog_file6,
1483
+ L: 136,
1484
+ S: this,
1485
+ C: (f, a) => f(...a)
1480
1486
  });
1481
1487
  });
1482
1488
  }
@@ -1488,10 +1494,10 @@ var NetworkManager = class {
1488
1494
  */
1489
1495
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1490
1496
  var _a;
1491
- assert5(PublicKey7.isPublicKey(topic));
1492
- assert5(PublicKey7.isPublicKey(peerId));
1493
- assert5(topology);
1494
- assert5(typeof protocol === "function");
1497
+ invariant5(PublicKey7.isPublicKey(topic));
1498
+ invariant5(PublicKey7.isPublicKey(peerId));
1499
+ invariant5(topology);
1500
+ invariant5(typeof protocol === "function");
1495
1501
  if (this._swarms.has(topic)) {
1496
1502
  throw new Error(`Already connected to swarm: ${PublicKey7.from(topic)}`);
1497
1503
  }
@@ -1500,20 +1506,20 @@ var NetworkManager = class {
1500
1506
  peerId,
1501
1507
  topology: topology.toString()
1502
1508
  }, {
1503
- file: "network-manager.ts",
1504
- line: 162,
1505
- scope: this,
1506
- callSite: (f, a) => f(...a)
1509
+ F: __dxlog_file6,
1510
+ L: 162,
1511
+ S: this,
1512
+ C: (f, a) => f(...a)
1507
1513
  });
1508
1514
  const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label);
1509
1515
  swarm.errors.handle((error) => {
1510
1516
  log6("swarm error", {
1511
1517
  error
1512
1518
  }, {
1513
- file: "network-manager.ts",
1514
- line: 165,
1515
- scope: this,
1516
- callSite: (f, a) => f(...a)
1519
+ F: __dxlog_file6,
1520
+ L: 165,
1521
+ S: this,
1522
+ C: (f, a) => f(...a)
1517
1523
  });
1518
1524
  });
1519
1525
  this._swarms.set(topic, swarm);
@@ -1522,11 +1528,11 @@ var NetworkManager = class {
1522
1528
  this._signalConnection.join({
1523
1529
  topic,
1524
1530
  peerId
1525
- }).catch((error) => log6.catch(error, {}, {
1526
- file: "network-manager.ts",
1527
- line: 174,
1528
- scope: this,
1529
- callSite: (f, a) => f(...a)
1531
+ }).catch((error) => log6.catch(error, void 0, {
1532
+ F: __dxlog_file6,
1533
+ L: 174,
1534
+ S: this,
1535
+ C: (f, a) => f(...a)
1530
1536
  }));
1531
1537
  this.topicsUpdated.emit();
1532
1538
  (_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
@@ -1534,10 +1540,10 @@ var NetworkManager = class {
1534
1540
  topic: PublicKey7.from(topic),
1535
1541
  count: this._swarms.size
1536
1542
  }, {
1537
- file: "network-manager.ts",
1538
- line: 178,
1539
- scope: this,
1540
- callSite: (f, a) => f(...a)
1543
+ F: __dxlog_file6,
1544
+ L: 178,
1545
+ S: this,
1546
+ C: (f, a) => f(...a)
1541
1547
  });
1542
1548
  return {
1543
1549
  close: () => this.leaveSwarm(topic)
@@ -1554,10 +1560,10 @@ var NetworkManager = class {
1554
1560
  log6("leaving", {
1555
1561
  topic: PublicKey7.from(topic)
1556
1562
  }, {
1557
- file: "network-manager.ts",
1558
- line: 194,
1559
- scope: this,
1560
- callSite: (f, a) => f(...a)
1563
+ F: __dxlog_file6,
1564
+ L: 194,
1565
+ S: this,
1566
+ C: (f, a) => f(...a)
1561
1567
  });
1562
1568
  const swarm = this._swarms.get(topic);
1563
1569
  await this._signalConnection.leave({
@@ -1575,10 +1581,10 @@ var NetworkManager = class {
1575
1581
  topic: PublicKey7.from(topic),
1576
1582
  count: this._swarms.size
1577
1583
  }, {
1578
- file: "network-manager.ts",
1579
- line: 208,
1580
- scope: this,
1581
- callSite: (f, a) => f(...a)
1584
+ F: __dxlog_file6,
1585
+ L: 208,
1586
+ S: this,
1587
+ C: (f, a) => f(...a)
1582
1588
  });
1583
1589
  }
1584
1590
  async setConnectionState(state) {
@@ -1610,17 +1616,17 @@ var NetworkManager = class {
1610
1616
  };
1611
1617
 
1612
1618
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1613
- import assert6 from "@dxos/node-std/assert";
1619
+ import invariant6 from "tiny-invariant";
1614
1620
  var FullyConnectedTopology = class {
1615
1621
  toString() {
1616
1622
  return "FullyConnectedTopology";
1617
1623
  }
1618
1624
  init(controller) {
1619
- assert6(!this._controller, "Already initialized");
1625
+ invariant6(!this._controller, "Already initialized");
1620
1626
  this._controller = controller;
1621
1627
  }
1622
1628
  update() {
1623
- assert6(this._controller, "Not initialized");
1629
+ invariant6(this._controller, "Not initialized");
1624
1630
  const { candidates: discovered } = this._controller.getState();
1625
1631
  for (const peer of discovered) {
1626
1632
  this._controller.connect(peer);
@@ -1634,9 +1640,10 @@ var FullyConnectedTopology = class {
1634
1640
  };
1635
1641
 
1636
1642
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1637
- import assert7 from "@dxos/node-std/assert";
1643
+ import invariant7 from "tiny-invariant";
1638
1644
  import distance from "xor-distance";
1639
1645
  import { log as log7 } from "@dxos/log";
1646
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
1640
1647
  var MMSTTopology = class {
1641
1648
  constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
1642
1649
  this._sampleCollected = false;
@@ -1645,62 +1652,62 @@ var MMSTTopology = class {
1645
1652
  this._sampleSize = sampleSize;
1646
1653
  }
1647
1654
  init(controller) {
1648
- assert7(!this._controller, "Already initialized");
1655
+ invariant7(!this._controller, "Already initialized");
1649
1656
  this._controller = controller;
1650
1657
  }
1651
1658
  update() {
1652
- assert7(this._controller, "Not initialized");
1659
+ invariant7(this._controller, "Not initialized");
1653
1660
  const { connected, candidates } = this._controller.getState();
1654
1661
  if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
1655
- log7("Running the algorithm.", {}, {
1656
- file: "mmst-topology.ts",
1657
- line: 55,
1658
- scope: this,
1659
- callSite: (f, a) => f(...a)
1662
+ log7("Running the algorithm.", void 0, {
1663
+ F: __dxlog_file7,
1664
+ L: 55,
1665
+ S: this,
1666
+ C: (f, a) => f(...a)
1660
1667
  });
1661
1668
  this._sampleCollected = true;
1662
1669
  this._runAlgorithm();
1663
1670
  }
1664
1671
  }
1665
1672
  async onOffer(peer) {
1666
- assert7(this._controller, "Not initialized");
1673
+ invariant7(this._controller, "Not initialized");
1667
1674
  const { connected } = this._controller.getState();
1668
1675
  const accept = connected.length < this._maxPeers;
1669
- log7(`Offer ${peer} accept=${accept}`, {}, {
1670
- file: "mmst-topology.ts",
1671
- line: 65,
1672
- scope: this,
1673
- callSite: (f, a) => f(...a)
1676
+ log7(`Offer ${peer} accept=${accept}`, void 0, {
1677
+ F: __dxlog_file7,
1678
+ L: 65,
1679
+ S: this,
1680
+ C: (f, a) => f(...a)
1674
1681
  });
1675
1682
  return accept;
1676
1683
  }
1677
1684
  async destroy() {
1678
1685
  }
1679
1686
  _runAlgorithm() {
1680
- assert7(this._controller, "Not initialized");
1687
+ invariant7(this._controller, "Not initialized");
1681
1688
  const { connected, candidates, ownPeerId } = this._controller.getState();
1682
1689
  if (connected.length > this._maxPeers) {
1683
1690
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
1684
1691
  for (const peer of sorted) {
1685
- log7(`Disconnect ${peer}.`, {}, {
1686
- file: "mmst-topology.ts",
1687
- line: 83,
1688
- scope: this,
1689
- callSite: (f, a) => f(...a)
1692
+ log7(`Disconnect ${peer}.`, void 0, {
1693
+ F: __dxlog_file7,
1694
+ L: 83,
1695
+ S: this,
1696
+ C: (f, a) => f(...a)
1690
1697
  });
1691
1698
  this._controller.disconnect(peer);
1692
1699
  }
1693
1700
  } else if (connected.length < this._originateConnections) {
1694
1701
  const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
1695
- const sorted1 = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
1696
- for (const peer1 of sorted1) {
1697
- log7(`Connect ${peer1}.`, {}, {
1698
- file: "mmst-topology.ts",
1699
- line: 91,
1700
- scope: this,
1701
- callSite: (f, a) => f(...a)
1702
+ const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
1703
+ for (const peer of sorted) {
1704
+ log7(`Connect ${peer}.`, void 0, {
1705
+ F: __dxlog_file7,
1706
+ L: 91,
1707
+ S: this,
1708
+ C: (f, a) => f(...a)
1702
1709
  });
1703
- this._controller.connect(peer1);
1710
+ this._controller.connect(peer);
1704
1711
  }
1705
1712
  }
1706
1713
  }
@@ -1711,8 +1718,9 @@ var MMSTTopology = class {
1711
1718
  var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
1712
1719
 
1713
1720
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1714
- import assert8 from "@dxos/node-std/assert";
1721
+ import invariant8 from "tiny-invariant";
1715
1722
  import { log as log8 } from "@dxos/log";
1723
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
1716
1724
  var StarTopology = class {
1717
1725
  // prettier-ignore
1718
1726
  constructor(_centralPeer) {
@@ -1722,59 +1730,59 @@ var StarTopology = class {
1722
1730
  return `StarTopology(${this._centralPeer.truncate()})`;
1723
1731
  }
1724
1732
  init(controller) {
1725
- assert8(!this._controller, "Already initialized.");
1733
+ invariant8(!this._controller, "Already initialized.");
1726
1734
  this._controller = controller;
1727
1735
  }
1728
1736
  update() {
1729
- assert8(this._controller, "Not initialized.");
1737
+ invariant8(this._controller, "Not initialized.");
1730
1738
  const { candidates, connected, ownPeerId } = this._controller.getState();
1731
1739
  if (!ownPeerId.equals(this._centralPeer)) {
1732
- log8("leaf peer dropping all connections apart from central peer.", {}, {
1733
- file: "star-topology.ts",
1734
- line: 33,
1735
- scope: this,
1736
- callSite: (f, a) => f(...a)
1740
+ log8("leaf peer dropping all connections apart from central peer.", void 0, {
1741
+ F: __dxlog_file8,
1742
+ L: 33,
1743
+ S: this,
1744
+ C: (f, a) => f(...a)
1737
1745
  });
1738
1746
  for (const peer of connected) {
1739
1747
  if (!peer.equals(this._centralPeer)) {
1740
1748
  log8("dropping connection", {
1741
1749
  peer
1742
1750
  }, {
1743
- file: "star-topology.ts",
1744
- line: 38,
1745
- scope: this,
1746
- callSite: (f, a) => f(...a)
1751
+ F: __dxlog_file8,
1752
+ L: 38,
1753
+ S: this,
1754
+ C: (f, a) => f(...a)
1747
1755
  });
1748
1756
  this._controller.disconnect(peer);
1749
1757
  }
1750
1758
  }
1751
1759
  }
1752
- for (const peer1 of candidates) {
1753
- if (peer1.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
1760
+ for (const peer of candidates) {
1761
+ if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
1754
1762
  log8("connecting to peer", {
1755
- peer: peer1
1763
+ peer
1756
1764
  }, {
1757
- file: "star-topology.ts",
1758
- line: 47,
1759
- scope: this,
1760
- callSite: (f, a) => f(...a)
1765
+ F: __dxlog_file8,
1766
+ L: 47,
1767
+ S: this,
1768
+ C: (f, a) => f(...a)
1761
1769
  });
1762
- this._controller.connect(peer1);
1770
+ this._controller.connect(peer);
1763
1771
  }
1764
1772
  }
1765
1773
  }
1766
1774
  async onOffer(peer) {
1767
- assert8(this._controller, "Not initialized.");
1775
+ invariant8(this._controller, "Not initialized.");
1768
1776
  const { ownPeerId } = this._controller.getState();
1769
1777
  log8("offer", {
1770
1778
  peer,
1771
1779
  isCentral: peer.equals(this._centralPeer),
1772
1780
  isSelfCentral: ownPeerId.equals(this._centralPeer)
1773
1781
  }, {
1774
- file: "star-topology.ts",
1775
- line: 56,
1776
- scope: this,
1777
- callSite: (f, a) => f(...a)
1782
+ F: __dxlog_file8,
1783
+ L: 56,
1784
+ S: this,
1785
+ C: (f, a) => f(...a)
1778
1786
  });
1779
1787
  return ownPeerId.equals(this._centralPeer) || peer.equals(this._centralPeer);
1780
1788
  }
@@ -1783,14 +1791,14 @@ var StarTopology = class {
1783
1791
  };
1784
1792
 
1785
1793
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1786
- import assert9 from "@dxos/node-std/assert";
1787
1794
  import { Transform } from "@dxos/node-std/stream";
1795
+ import invariant9 from "tiny-invariant";
1788
1796
  import { Event as Event6, Trigger } from "@dxos/async";
1789
1797
  import { ErrorStream as ErrorStream3 } from "@dxos/debug";
1790
1798
  import { PublicKey as PublicKey8 } from "@dxos/keys";
1791
1799
  import { log as log9, logInfo as logInfo2 } from "@dxos/log";
1792
1800
  import { ComplexMap as ComplexMap6 } from "@dxos/util";
1793
- var __decorate4 = function(decorators, target, key, desc) {
1801
+ function _ts_decorate4(decorators, target, key, desc) {
1794
1802
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1795
1803
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1796
1804
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1799,7 +1807,8 @@ var __decorate4 = function(decorators, target, key, desc) {
1799
1807
  if (d = decorators[i])
1800
1808
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1801
1809
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1802
- };
1810
+ }
1811
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
1803
1812
  var MEMORY_TRANSPORT_DELAY = 1;
1804
1813
  var createStreamDelay = (delay) => {
1805
1814
  return new Transform({
@@ -1819,26 +1828,26 @@ var _MemoryTransport = class {
1819
1828
  this.closed = new Event6();
1820
1829
  this.connected = new Event6();
1821
1830
  this.errors = new ErrorStream3();
1831
+ this._instanceId = PublicKey8.random();
1822
1832
  this._remote = new Trigger();
1823
1833
  this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1824
1834
  this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1825
1835
  this._destroyed = false;
1826
- this._instanceId = PublicKey8.random();
1827
- log9("creating", {}, {
1828
- file: "memory-transport.ts",
1829
- line: 64,
1830
- scope: this,
1831
- callSite: (f, a) => f(...a)
1836
+ log9("creating", void 0, {
1837
+ F: __dxlog_file9,
1838
+ L: 64,
1839
+ S: this,
1840
+ C: (f, a) => f(...a)
1832
1841
  });
1833
- assert9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1842
+ invariant9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1834
1843
  _MemoryTransport._connections.set(this._instanceId, this);
1835
1844
  if (this.options.initiator) {
1836
1845
  setTimeout(async () => {
1837
- log9("sending signal", {}, {
1838
- file: "memory-transport.ts",
1839
- line: 73,
1840
- scope: this,
1841
- callSite: (f, a) => f(...a)
1846
+ log9("sending signal", void 0, {
1847
+ F: __dxlog_file9,
1848
+ L: 73,
1849
+ S: this,
1850
+ C: (f, a) => f(...a)
1842
1851
  });
1843
1852
  void this.options.sendSignal({
1844
1853
  payload: {
@@ -1864,14 +1873,14 @@ var _MemoryTransport = class {
1864
1873
  this.closed.emit();
1865
1874
  return;
1866
1875
  }
1867
- assert9(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1876
+ invariant9(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
1868
1877
  this._remoteConnection._remoteConnection = this;
1869
1878
  this._remoteConnection._remoteInstanceId = this._instanceId;
1870
- log9("connected", {}, {
1871
- file: "memory-transport.ts",
1872
- line: 106,
1873
- scope: this,
1874
- callSite: (f, a) => f(...a)
1879
+ log9("connected", void 0, {
1880
+ F: __dxlog_file9,
1881
+ L: 103,
1882
+ S: this,
1883
+ C: (f, a) => f(...a)
1875
1884
  });
1876
1885
  this.options.stream.pipe(this._outgoingDelay).pipe(this._remoteConnection.options.stream).pipe(this._incomingDelay).pipe(this.options.stream);
1877
1886
  this.connected.emit();
@@ -1885,20 +1894,20 @@ var _MemoryTransport = class {
1885
1894
  }
1886
1895
  }
1887
1896
  async destroy() {
1888
- log9("closing", {}, {
1889
- file: "memory-transport.ts",
1890
- line: 127,
1891
- scope: this,
1892
- callSite: (f, a) => f(...a)
1897
+ log9("closing", void 0, {
1898
+ F: __dxlog_file9,
1899
+ L: 124,
1900
+ S: this,
1901
+ C: (f, a) => f(...a)
1893
1902
  });
1894
1903
  this._destroyed = true;
1895
1904
  _MemoryTransport._connections.delete(this._instanceId);
1896
1905
  if (this._remoteConnection) {
1897
- log9("closing", {}, {
1898
- file: "memory-transport.ts",
1899
- line: 132,
1900
- scope: this,
1901
- callSite: (f, a) => f(...a)
1906
+ log9("closing", void 0, {
1907
+ F: __dxlog_file9,
1908
+ L: 129,
1909
+ S: this,
1910
+ C: (f, a) => f(...a)
1902
1911
  });
1903
1912
  this._remoteConnection._destroyed = true;
1904
1913
  _MemoryTransport._connections.delete(this._remoteInstanceId);
@@ -1907,29 +1916,29 @@ var _MemoryTransport = class {
1907
1916
  this._remoteConnection.closed.emit();
1908
1917
  this._remoteConnection._remoteConnection = void 0;
1909
1918
  this._remoteConnection = void 0;
1910
- log9("closed", {}, {
1911
- file: "memory-transport.ts",
1912
- line: 150,
1913
- scope: this,
1914
- callSite: (f, a) => f(...a)
1919
+ log9("closed", void 0, {
1920
+ F: __dxlog_file9,
1921
+ L: 147,
1922
+ S: this,
1923
+ C: (f, a) => f(...a)
1915
1924
  });
1916
1925
  }
1917
1926
  this.closed.emit();
1918
- log9("closed", {}, {
1919
- file: "memory-transport.ts",
1920
- line: 154,
1921
- scope: this,
1922
- callSite: (f, a) => f(...a)
1927
+ log9("closed", void 0, {
1928
+ F: __dxlog_file9,
1929
+ L: 151,
1930
+ S: this,
1931
+ C: (f, a) => f(...a)
1923
1932
  });
1924
1933
  }
1925
1934
  signal({ payload }) {
1926
1935
  log9("received signal", {
1927
1936
  payload
1928
1937
  }, {
1929
- file: "memory-transport.ts",
1930
- line: 158,
1931
- scope: this,
1932
- callSite: (f, a) => f(...a)
1938
+ F: __dxlog_file9,
1939
+ L: 155,
1940
+ S: this,
1941
+ C: (f, a) => f(...a)
1933
1942
  });
1934
1943
  if (!(payload == null ? void 0 : payload.transportId)) {
1935
1944
  return;
@@ -1944,16 +1953,16 @@ var _MemoryTransport = class {
1944
1953
  var MemoryTransport = _MemoryTransport;
1945
1954
  // TODO(burdon): Remove static properties (inject context into constructor).
1946
1955
  MemoryTransport._connections = new ComplexMap6(PublicKey8.hash);
1947
- __decorate4([
1956
+ _ts_decorate4([
1948
1957
  logInfo2
1949
1958
  ], MemoryTransport.prototype, "_instanceId", void 0);
1950
- __decorate4([
1959
+ _ts_decorate4([
1951
1960
  logInfo2
1952
1961
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
1953
1962
 
1954
1963
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1955
- import assert10 from "@dxos/node-std/assert";
1956
1964
  import SimplePeerConstructor from "simple-peer";
1965
+ import invariant10 from "tiny-invariant";
1957
1966
  import { Event as Event7 } from "@dxos/async";
1958
1967
  import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
1959
1968
  import { PublicKey as PublicKey9 } from "@dxos/keys";
@@ -1968,6 +1977,7 @@ try {
1968
1977
  }
1969
1978
 
1970
1979
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1980
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
1971
1981
  var WebRTCTransport = class {
1972
1982
  constructor(params) {
1973
1983
  var _a;
@@ -1980,16 +1990,16 @@ var WebRTCTransport = class {
1980
1990
  log10.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
1981
1991
  id: this._instanceId
1982
1992
  }), {
1983
- file: "webrtc-transport.ts",
1984
- line: 39,
1985
- scope: this,
1986
- callSite: (f, a) => f(...a)
1993
+ F: __dxlog_file10,
1994
+ L: 39,
1995
+ S: this,
1996
+ C: (f, a) => f(...a)
1987
1997
  });
1988
1998
  log10("created connection", params, {
1989
- file: "webrtc-transport.ts",
1990
- line: 40,
1991
- scope: this,
1992
- callSite: (f, a) => f(...a)
1999
+ F: __dxlog_file10,
2000
+ L: 40,
2001
+ S: this,
2002
+ C: (f, a) => f(...a)
1993
2003
  });
1994
2004
  this._peer = new SimplePeerConstructor({
1995
2005
  initiator: this.params.initiator,
@@ -1998,10 +2008,10 @@ var WebRTCTransport = class {
1998
2008
  });
1999
2009
  this._peer.on("signal", async (data) => {
2000
2010
  log10("signal", data, {
2001
- file: "webrtc-transport.ts",
2002
- line: 48,
2003
- scope: this,
2004
- callSite: (f, a) => f(...a)
2011
+ F: __dxlog_file10,
2012
+ L: 48,
2013
+ S: this,
2014
+ C: (f, a) => f(...a)
2005
2015
  });
2006
2016
  await this.params.sendSignal({
2007
2017
  payload: {
@@ -2010,21 +2020,21 @@ var WebRTCTransport = class {
2010
2020
  });
2011
2021
  });
2012
2022
  this._peer.on("connect", () => {
2013
- log10("connected", {}, {
2014
- file: "webrtc-transport.ts",
2015
- line: 53,
2016
- scope: this,
2017
- callSite: (f, a) => f(...a)
2023
+ log10("connected", void 0, {
2024
+ F: __dxlog_file10,
2025
+ L: 53,
2026
+ S: this,
2027
+ C: (f, a) => f(...a)
2018
2028
  });
2019
2029
  this.params.stream.pipe(this._peer).pipe(this.params.stream);
2020
2030
  this.connected.emit();
2021
2031
  });
2022
2032
  this._peer.on("close", async () => {
2023
- log10("closed", {}, {
2024
- file: "webrtc-transport.ts",
2025
- line: 59,
2026
- scope: this,
2027
- callSite: (f, a) => f(...a)
2033
+ log10("closed", void 0, {
2034
+ F: __dxlog_file10,
2035
+ L: 59,
2036
+ S: this,
2037
+ C: (f, a) => f(...a)
2028
2038
  });
2029
2039
  await this._disconnectStreams();
2030
2040
  this.closed.emit();
@@ -2039,10 +2049,10 @@ var WebRTCTransport = class {
2039
2049
  config: this.params.webrtcConfig,
2040
2050
  stats
2041
2051
  }, {
2042
- file: "webrtc-transport.ts",
2043
- line: 71,
2044
- scope: this,
2045
- callSite: (f, a) => f(...a)
2052
+ F: __dxlog_file10,
2053
+ L: 71,
2054
+ S: this,
2055
+ C: (f, a) => f(...a)
2046
2056
  });
2047
2057
  });
2048
2058
  }
@@ -2053,35 +2063,35 @@ var WebRTCTransport = class {
2053
2063
  log10.trace("dxos.mesh.webrtc-transport.constructor", trace4.end({
2054
2064
  id: this._instanceId
2055
2065
  }), {
2056
- file: "webrtc-transport.ts",
2057
- line: 81,
2058
- scope: this,
2059
- callSite: (f, a) => f(...a)
2066
+ F: __dxlog_file10,
2067
+ L: 81,
2068
+ S: this,
2069
+ C: (f, a) => f(...a)
2060
2070
  });
2061
2071
  }
2062
2072
  async destroy() {
2063
- log10("closing...", {}, {
2064
- file: "webrtc-transport.ts",
2065
- line: 85,
2066
- scope: this,
2067
- callSite: (f, a) => f(...a)
2073
+ log10("closing...", void 0, {
2074
+ F: __dxlog_file10,
2075
+ L: 85,
2076
+ S: this,
2077
+ C: (f, a) => f(...a)
2068
2078
  });
2069
2079
  this._closed = true;
2070
2080
  await this._disconnectStreams();
2071
2081
  this._peer.destroy();
2072
2082
  this.closed.emit();
2073
- log10("closed", {}, {
2074
- file: "webrtc-transport.ts",
2075
- line: 90,
2076
- scope: this,
2077
- callSite: (f, a) => f(...a)
2083
+ log10("closed", void 0, {
2084
+ F: __dxlog_file10,
2085
+ L: 90,
2086
+ S: this,
2087
+ C: (f, a) => f(...a)
2078
2088
  });
2079
2089
  }
2080
2090
  signal(signal) {
2081
2091
  if (this._closed) {
2082
2092
  return;
2083
2093
  }
2084
- assert10(signal.payload.data, "Signal message must contain signal data.");
2094
+ invariant10(signal.payload.data, "Signal message must contain signal data.");
2085
2095
  this._peer.signal(signal.payload.data);
2086
2096
  }
2087
2097
  async _disconnectStreams() {
@@ -2097,13 +2107,14 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
2097
2107
  });
2098
2108
 
2099
2109
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
2100
- import assert11 from "@dxos/node-std/assert";
2101
2110
  import { Duplex } from "@dxos/node-std/stream";
2111
+ import invariant11 from "tiny-invariant";
2102
2112
  import { Stream } from "@dxos/codec-protobuf";
2103
2113
  import { PublicKey as PublicKey10 } from "@dxos/keys";
2104
2114
  import { log as log11 } from "@dxos/log";
2105
2115
  import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
2106
2116
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
2117
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2107
2118
  var WebRTCTransportService = class {
2108
2119
  // prettier-ignore
2109
2120
  constructor(_webrtcConfig) {
@@ -2174,11 +2185,11 @@ var WebRTCTransportService = class {
2174
2185
  return rpcStream;
2175
2186
  }
2176
2187
  async sendSignal({ proxyId, signal }) {
2177
- assert11(this.transports.has(proxyId));
2188
+ invariant11(this.transports.has(proxyId));
2178
2189
  await this.transports.get(proxyId).transport.signal(signal);
2179
2190
  }
2180
2191
  async sendData({ proxyId, payload }) {
2181
- assert11(this.transports.has(proxyId));
2192
+ invariant11(this.transports.has(proxyId));
2182
2193
  await this.transports.get(proxyId).stream.push(payload);
2183
2194
  }
2184
2195
  async close({ proxyId }) {
@@ -2186,17 +2197,17 @@ var WebRTCTransportService = class {
2186
2197
  await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
2187
2198
  await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
2188
2199
  this.transports.delete(proxyId);
2189
- log11("Closed.", {}, {
2190
- file: "webrtc-transport-service.ts",
2191
- line: 109,
2192
- scope: this,
2193
- callSite: (f, a) => f(...a)
2200
+ log11("Closed.", void 0, {
2201
+ F: __dxlog_file11,
2202
+ L: 109,
2203
+ S: this,
2204
+ C: (f, a) => f(...a)
2194
2205
  });
2195
2206
  }
2196
2207
  };
2197
2208
 
2198
2209
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2199
- import assert12 from "@dxos/node-std/assert";
2210
+ import invariant12 from "tiny-invariant";
2200
2211
  import { Event as Event8 } from "@dxos/async";
2201
2212
  import { Context as Context5 } from "@dxos/context";
2202
2213
  import { ErrorStream as ErrorStream5 } from "@dxos/debug";
@@ -2204,6 +2215,7 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
2204
2215
  import { log as log12 } from "@dxos/log";
2205
2216
  import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
2206
2217
  import { arrayToBuffer } from "@dxos/util";
2218
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2207
2219
  var WebRTCTransportProxy = class {
2208
2220
  // prettier-ignore
2209
2221
  constructor(_params) {
@@ -2221,10 +2233,10 @@ var WebRTCTransportProxy = class {
2221
2233
  this._serviceStream.waitUntilReady().then(() => {
2222
2234
  this._serviceStream.subscribe(async (event) => {
2223
2235
  log12("WebRTCTransportProxy: event", event, {
2224
- file: "webrtc-transport-proxy.ts",
2225
- line: 50,
2226
- scope: this,
2227
- callSite: (f, a) => f(...a)
2236
+ F: __dxlog_file12,
2237
+ L: 50,
2238
+ S: this,
2239
+ C: (f, a) => f(...a)
2228
2240
  });
2229
2241
  if (event.connection) {
2230
2242
  await this._handleConnection(event.connection);
@@ -2241,11 +2253,11 @@ var WebRTCTransportProxy = class {
2241
2253
  payload: data
2242
2254
  });
2243
2255
  } catch (err) {
2244
- log12.catch(err, {}, {
2245
- file: "webrtc-transport-proxy.ts",
2246
- line: 67,
2247
- scope: this,
2248
- callSite: (f, a) => f(...a)
2256
+ log12.catch(err, void 0, {
2257
+ F: __dxlog_file12,
2258
+ L: 67,
2259
+ S: this,
2260
+ C: (f, a) => f(...a)
2249
2261
  });
2250
2262
  }
2251
2263
  };
@@ -2253,11 +2265,11 @@ var WebRTCTransportProxy = class {
2253
2265
  this._ctx.onDispose(() => {
2254
2266
  this._params.stream.off("data", dataListener);
2255
2267
  });
2256
- }, (error) => log12.catch(error, {}, {
2257
- file: "webrtc-transport-proxy.ts",
2258
- line: 73,
2259
- scope: this,
2260
- callSite: (f, a) => f(...a)
2268
+ }, (error) => log12.catch(error, void 0, {
2269
+ F: __dxlog_file12,
2270
+ L: 73,
2271
+ S: this,
2272
+ C: (f, a) => f(...a)
2261
2273
  }));
2262
2274
  }
2263
2275
  async _handleConnection(connectionEvent) {
@@ -2299,11 +2311,11 @@ var WebRTCTransportProxy = class {
2299
2311
  proxyId: this._proxyId
2300
2312
  });
2301
2313
  } catch (err) {
2302
- log12.catch(err, {}, {
2303
- file: "webrtc-transport-proxy.ts",
2304
- line: 124,
2305
- scope: this,
2306
- callSite: (f, a) => f(...a)
2314
+ log12.catch(err, void 0, {
2315
+ F: __dxlog_file12,
2316
+ L: 124,
2317
+ S: this,
2318
+ C: (f, a) => f(...a)
2307
2319
  });
2308
2320
  }
2309
2321
  this.closed.emit();
@@ -2335,7 +2347,7 @@ var WebRTCTransportProxyFactory = class {
2335
2347
  return this;
2336
2348
  }
2337
2349
  createTransport(options) {
2338
- assert12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2350
+ invariant12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2339
2351
  const transport = new WebRTCTransportProxy({
2340
2352
  ...options,
2341
2353
  bridgeService: this._bridgeService
@@ -2385,4 +2397,4 @@ export {
2385
2397
  WebRTCTransportProxyFactory,
2386
2398
  createTeleportProtocolFactory
2387
2399
  };
2388
- //# sourceMappingURL=chunk-6CP5XM3F.mjs.map
2400
+ //# sourceMappingURL=chunk-N5RZB7V4.mjs.map