@dxos/network-manager 0.1.53 → 0.1.54-main.270ec56

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.
@@ -59,7 +59,7 @@ var import_keys6 = require("@dxos/keys");
59
59
  var import_util4 = require("@dxos/util");
60
60
 
61
61
  // packages/core/mesh/network-manager/src/swarm/connection.ts
62
- var import_node_assert = __toESM(require("node:assert"));
62
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
63
63
  var import_async = require("@dxos/async");
64
64
  var import_context = require("@dxos/context");
65
65
  var import_debug = require("@dxos/debug");
@@ -67,7 +67,7 @@ var import_errors = require("@dxos/errors");
67
67
  var import_keys = require("@dxos/keys");
68
68
  var import_log = require("@dxos/log");
69
69
  var import_protocols = require("@dxos/protocols");
70
- var __decorate = function(decorators, target, key, desc) {
70
+ function _ts_decorate(decorators, target, key, desc) {
71
71
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
72
72
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
73
73
  r = Reflect.decorate(decorators, target, key, desc);
@@ -76,7 +76,8 @@ var __decorate = function(decorators, target, key, desc) {
76
76
  if (d = decorators[i])
77
77
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
78
78
  return c > 3 && r && Object.defineProperty(target, key, r), r;
79
- };
79
+ }
80
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
80
81
  var STARTING_SIGNALLING_DELAY = 10;
81
82
  var MAX_SIGNALLING_DELAY = 300;
82
83
  var ConnectionState;
@@ -149,29 +150,29 @@ var Connection = class {
149
150
  */
150
151
  // TODO(burdon): Make async?
151
152
  openConnection() {
152
- (0, import_node_assert.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
153
+ (0, import_tiny_invariant.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
153
154
  import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.begin({
154
155
  id: this._instanceId
155
156
  }), {
156
- file: "connection.ts",
157
- line: 115,
158
- scope: this,
159
- callSite: (f, a) => f(...a)
157
+ F: __dxlog_file,
158
+ L: 115,
159
+ S: this,
160
+ C: (f, a) => f(...a)
160
161
  });
161
162
  this._changeState(ConnectionState.CONNECTING);
162
163
  this._protocol.initialize().catch((err) => {
163
164
  this.errors.raise(err);
164
165
  });
165
166
  this._protocol.stream.on("close", () => {
166
- (0, import_log.log)("protocol stream closed", {}, {
167
- file: "connection.ts",
168
- line: 126,
169
- scope: this,
170
- callSite: (f, a) => f(...a)
167
+ (0, import_log.log)("protocol stream closed", void 0, {
168
+ F: __dxlog_file,
169
+ L: 126,
170
+ S: this,
171
+ C: (f, a) => f(...a)
171
172
  });
172
173
  this.close().catch((err) => this.errors.raise(err));
173
174
  });
174
- (0, import_node_assert.default)(!this._transport);
175
+ (0, import_tiny_invariant.default)(!this._transport);
175
176
  this._transport = this._transportFactory.createTransport({
176
177
  initiator: this.initiator,
177
178
  stream: this._protocol.stream,
@@ -196,10 +197,10 @@ var Connection = class {
196
197
  import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.end({
197
198
  id: this._instanceId
198
199
  }), {
199
- file: "connection.ts",
200
- line: 159,
201
- scope: this,
202
- callSite: (f, a) => f(...a)
200
+ F: __dxlog_file,
201
+ L: 159,
202
+ S: this,
203
+ C: (f, a) => f(...a)
203
204
  });
204
205
  }
205
206
  async close() {
@@ -212,38 +213,38 @@ var Connection = class {
212
213
  (0, import_log.log)("closing...", {
213
214
  peerId: this.ownId
214
215
  }, {
215
- file: "connection.ts",
216
- line: 171,
217
- scope: this,
218
- callSite: (f, a) => f(...a)
216
+ F: __dxlog_file,
217
+ L: 171,
218
+ S: this,
219
+ C: (f, a) => f(...a)
219
220
  });
220
221
  try {
221
222
  await this._protocol.destroy();
222
223
  } catch (err) {
223
- import_log.log.catch(err, {}, {
224
- file: "connection.ts",
225
- line: 177,
226
- scope: this,
227
- callSite: (f, a) => f(...a)
224
+ import_log.log.catch(err, void 0, {
225
+ F: __dxlog_file,
226
+ L: 177,
227
+ S: this,
228
+ C: (f, a) => f(...a)
228
229
  });
229
230
  }
230
231
  try {
231
232
  await ((_a = this._transport) == null ? void 0 : _a.destroy());
232
- } catch (err1) {
233
- import_log.log.catch(err1, {}, {
234
- file: "connection.ts",
235
- line: 184,
236
- scope: this,
237
- callSite: (f, a) => f(...a)
233
+ } catch (err) {
234
+ import_log.log.catch(err, void 0, {
235
+ F: __dxlog_file,
236
+ L: 184,
237
+ S: this,
238
+ C: (f, a) => f(...a)
238
239
  });
239
240
  }
240
241
  (0, import_log.log)("closed", {
241
242
  peerId: this.ownId
242
243
  }, {
243
- file: "connection.ts",
244
- line: 187,
245
- scope: this,
246
- callSite: (f, a) => f(...a)
244
+ F: __dxlog_file,
245
+ L: 187,
246
+ S: this,
247
+ C: (f, a) => f(...a)
247
248
  });
248
249
  this._changeState(ConnectionState.CLOSED);
249
250
  }
@@ -280,10 +281,10 @@ var Connection = class {
280
281
  import_log.log.warn("Signal failed", {
281
282
  err
282
283
  }, {
283
- file: "connection.ts",
284
- line: 221,
285
- scope: this,
286
- callSite: (f, a) => f(...a)
284
+ F: __dxlog_file,
285
+ L: 221,
286
+ S: this,
287
+ C: (f, a) => f(...a)
287
288
  });
288
289
  await this.close();
289
290
  }
@@ -293,19 +294,19 @@ var Connection = class {
293
294
  */
294
295
  async signal(msg) {
295
296
  var _a, _b, _c;
296
- (0, import_node_assert.default)(msg.sessionId);
297
+ (0, import_tiny_invariant.default)(msg.sessionId);
297
298
  if (!msg.sessionId.equals(this.sessionId)) {
298
- (0, import_log.log)("dropping signal for incorrect session id", {}, {
299
- file: "connection.ts",
300
- line: 232,
301
- scope: this,
302
- callSite: (f, a) => f(...a)
299
+ (0, import_log.log)("dropping signal for incorrect session id", void 0, {
300
+ F: __dxlog_file,
301
+ L: 232,
302
+ S: this,
303
+ C: (f, a) => f(...a)
303
304
  });
304
305
  return;
305
306
  }
306
- (0, import_node_assert.default)(msg.data.signal || msg.data.signalBatch);
307
- (0, import_node_assert.default)((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
308
- (0, import_node_assert.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
307
+ (0, import_tiny_invariant.default)(msg.data.signal || msg.data.signalBatch);
308
+ (0, import_tiny_invariant.default)((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
309
+ (0, import_tiny_invariant.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
309
310
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
310
311
  msg.data.signal
311
312
  ];
@@ -319,23 +320,23 @@ var Connection = class {
319
320
  remoteId: this.remoteId,
320
321
  msg: msg.data
321
322
  }, {
322
- file: "connection.ts",
323
- line: 246,
324
- scope: this,
325
- callSite: (f, a) => f(...a)
323
+ F: __dxlog_file,
324
+ L: 246,
325
+ S: this,
326
+ C: (f, a) => f(...a)
326
327
  });
327
328
  this._incomingSignalBuffer.push(signal);
328
329
  } else {
329
- (0, import_node_assert.default)(this._transport, "Connection not ready to accept signals.");
330
+ (0, import_tiny_invariant.default)(this._transport, "Connection not ready to accept signals.");
330
331
  (0, import_log.log)("received signal", {
331
332
  peerId: this.ownId,
332
333
  remoteId: this.remoteId,
333
334
  msg: msg.data
334
335
  }, {
335
- file: "connection.ts",
336
- line: 250,
337
- scope: this,
338
- callSite: (f, a) => f(...a)
336
+ F: __dxlog_file,
337
+ L: 250,
338
+ S: this,
339
+ C: (f, a) => f(...a)
339
340
  });
340
341
  await this._transport.signal(signal);
341
342
  }
@@ -347,22 +348,22 @@ var Connection = class {
347
348
  too: state,
348
349
  peerId: this.ownId
349
350
  }, {
350
- file: "connection.ts",
351
- line: 257,
352
- scope: this,
353
- callSite: (f, a) => f(...a)
351
+ F: __dxlog_file,
352
+ L: 257,
353
+ S: this,
354
+ C: (f, a) => f(...a)
354
355
  });
355
- (0, import_node_assert.default)(state !== this._state, "Already in this state.");
356
+ (0, import_tiny_invariant.default)(state !== this._state, "Already in this state.");
356
357
  this._state = state;
357
358
  this.stateChanged.emit(state);
358
359
  }
359
360
  };
360
- __decorate([
361
+ _ts_decorate([
361
362
  import_async.synchronized
362
363
  ], Connection.prototype, "close", null);
363
364
 
364
365
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
365
- var import_node_assert4 = __toESM(require("node:assert"));
366
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
366
367
  var import_async3 = require("@dxos/async");
367
368
  var import_context4 = require("@dxos/context");
368
369
  var import_debug2 = require("@dxos/debug");
@@ -372,12 +373,14 @@ var import_protocols3 = require("@dxos/protocols");
372
373
  var import_util2 = require("@dxos/util");
373
374
 
374
375
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
375
- var import_node_assert2 = __toESM(require("node:assert"));
376
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
376
377
  var import_context2 = require("@dxos/context");
377
378
  var import_keys2 = require("@dxos/keys");
378
379
  var import_log2 = require("@dxos/log");
379
380
  var import_protocols2 = require("@dxos/protocols");
380
381
  var import_util = require("@dxos/util");
382
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
383
+ var SwarmMessage = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
381
384
  var SwarmMessenger = class {
382
385
  constructor({ sendMessage, onSignal, onOffer, topic }) {
383
386
  this._ctx = new import_context2.Context();
@@ -392,7 +395,7 @@ var SwarmMessenger = class {
392
395
  if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
393
396
  return;
394
397
  }
395
- const message = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage").decode(payload.value);
398
+ const message = SwarmMessage.decode(payload.value);
396
399
  if (!this._topic.equals(message.topic)) {
397
400
  return;
398
401
  }
@@ -401,10 +404,10 @@ var SwarmMessenger = class {
401
404
  to: recipient,
402
405
  msg: message
403
406
  }, {
404
- file: "swarm-messenger.ts",
405
- line: 68,
406
- scope: this,
407
- callSite: (f, a) => f(...a)
407
+ F: __dxlog_file2,
408
+ L: 70,
409
+ S: this,
410
+ C: (f, a) => f(...a)
408
411
  });
409
412
  if ((_a = message.data) == null ? void 0 : _a.offer) {
410
413
  await this._handleOffer({
@@ -430,16 +433,16 @@ var SwarmMessenger = class {
430
433
  import_log2.log.warn("unknown message", {
431
434
  message
432
435
  }, {
433
- file: "swarm-messenger.ts",
434
- line: 79,
435
- scope: this,
436
- callSite: (f, a) => f(...a)
436
+ F: __dxlog_file2,
437
+ L: 81,
438
+ S: this,
439
+ C: (f, a) => f(...a)
437
440
  });
438
441
  }
439
442
  }
440
443
  async signal(message) {
441
444
  var _a, _b;
442
- (0, import_node_assert2.default)(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
445
+ (0, import_tiny_invariant2.default)(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
443
446
  await this._sendReliableMessage({
444
447
  author: message.author,
445
448
  recipient: message.recipient,
@@ -474,40 +477,40 @@ var SwarmMessenger = class {
474
477
  to: recipient,
475
478
  msg: networkMessage
476
479
  }, {
477
- file: "swarm-messenger.ts",
478
- line: 122,
479
- scope: this,
480
- callSite: (f, a) => f(...a)
480
+ F: __dxlog_file2,
481
+ L: 124,
482
+ S: this,
483
+ C: (f, a) => f(...a)
481
484
  });
482
485
  await this._sendMessage({
483
486
  author,
484
487
  recipient,
485
488
  payload: {
486
489
  type_url: "dxos.mesh.swarm.SwarmMessage",
487
- value: import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage").encode(networkMessage)
490
+ value: SwarmMessage.encode(networkMessage)
488
491
  }
489
492
  });
490
493
  }
491
494
  async _resolveAnswers(message) {
492
495
  var _a, _b, _c;
493
- (0, import_node_assert2.default)((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
496
+ (0, import_tiny_invariant2.default)((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
494
497
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
495
498
  if (offerRecord) {
496
499
  this._offerRecords.delete(message.data.answer.offerMessageId);
497
- (0, import_node_assert2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
500
+ (0, import_tiny_invariant2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
498
501
  (0, import_log2.log)("resolving", {
499
502
  answer: message.data.answer
500
503
  }, {
501
- file: "swarm-messenger.ts",
502
- line: 139,
503
- scope: this,
504
- callSite: (f, a) => f(...a)
504
+ F: __dxlog_file2,
505
+ L: 141,
506
+ S: this,
507
+ C: (f, a) => f(...a)
505
508
  });
506
509
  offerRecord.resolve(message.data.answer);
507
510
  }
508
511
  }
509
512
  async _handleOffer({ author, recipient, message }) {
510
- (0, import_node_assert2.default)(message.data.offer, "No offer");
513
+ (0, import_tiny_invariant2.default)(message.data.offer, "No offer");
511
514
  const offerMessage = {
512
515
  author,
513
516
  recipient,
@@ -534,16 +537,16 @@ var SwarmMessenger = class {
534
537
  import_log2.log.warn("error sending answer", {
535
538
  err
536
539
  }, {
537
- file: "swarm-messenger.ts",
538
- line: 173,
539
- scope: this,
540
- callSite: (f, a) => f(...a)
540
+ F: __dxlog_file2,
541
+ L: 175,
542
+ S: this,
543
+ C: (f, a) => f(...a)
541
544
  });
542
545
  }
543
546
  }
544
547
  async _handleSignal({ author, recipient, message }) {
545
- (0, import_node_assert2.default)(message.messageId);
546
- (0, import_node_assert2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
548
+ (0, import_tiny_invariant2.default)(message.messageId);
549
+ (0, import_tiny_invariant2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
547
550
  const signalMessage = {
548
551
  author,
549
552
  recipient,
@@ -558,12 +561,12 @@ var SwarmMessenger = class {
558
561
  };
559
562
 
560
563
  // packages/core/mesh/network-manager/src/swarm/peer.ts
561
- var import_node_assert3 = __toESM(require("node:assert"));
564
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
562
565
  var import_async2 = require("@dxos/async");
563
566
  var import_context3 = require("@dxos/context");
564
567
  var import_keys3 = require("@dxos/keys");
565
568
  var import_log3 = require("@dxos/log");
566
- var __decorate2 = function(decorators, target, key, desc) {
569
+ function _ts_decorate2(decorators, target, key, desc) {
567
570
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
568
571
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
569
572
  r = Reflect.decorate(decorators, target, key, desc);
@@ -572,7 +575,8 @@ var __decorate2 = function(decorators, target, key, desc) {
572
575
  if (d = decorators[i])
573
576
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
574
577
  return c > 3 && r && Object.defineProperty(target, key, r), r;
575
- };
578
+ }
579
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
576
580
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
577
581
  var Peer = class {
578
582
  constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _callbacks) {
@@ -601,10 +605,10 @@ var Peer = class {
601
605
  topic: this.topic,
602
606
  peerId: this.localPeerId
603
607
  }, {
604
- file: "peer.ts",
605
- line: 105,
606
- scope: this,
607
- callSite: (f, a) => f(...a)
608
+ F: __dxlog_file3,
609
+ L: 105,
610
+ S: this,
611
+ C: (f, a) => f(...a)
608
612
  });
609
613
  if (this.connection) {
610
614
  await this.closeConnection();
@@ -617,7 +621,7 @@ var Peer = class {
617
621
  }
618
622
  if (await this._callbacks.onOffer(remoteId)) {
619
623
  if (!this.connection) {
620
- (0, import_node_assert3.default)(message.sessionId);
624
+ (0, import_tiny_invariant3.default)(message.sessionId);
621
625
  const connection = this._createConnection(false, message.sessionId);
622
626
  try {
623
627
  connection.openConnection();
@@ -628,10 +632,10 @@ var Peer = class {
628
632
  remoteId: this.id,
629
633
  err
630
634
  }, {
631
- file: "peer.ts",
632
- line: 129,
633
- scope: this,
634
- callSite: (f, a) => f(...a)
635
+ F: __dxlog_file3,
636
+ L: 129,
637
+ S: this,
638
+ C: (f, a) => f(...a)
635
639
  });
636
640
  await this.closeConnection();
637
641
  }
@@ -648,8 +652,8 @@ var Peer = class {
648
652
  * Initiate a connection to the remote peer.
649
653
  */
650
654
  async initiateConnection() {
651
- (0, import_node_assert3.default)(!this.initiating, "Initiation in progress.");
652
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
655
+ (0, import_tiny_invariant3.default)(!this.initiating, "Initiation in progress.");
656
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
653
657
  const sessionId = import_keys3.PublicKey.random();
654
658
  (0, import_log3.log)("initiating...", {
655
659
  id: this.id,
@@ -657,10 +661,10 @@ var Peer = class {
657
661
  peerId: this.id,
658
662
  sessionId
659
663
  }, {
660
- file: "peer.ts",
661
- line: 147,
662
- scope: this,
663
- callSite: (f, a) => f(...a)
664
+ F: __dxlog_file3,
665
+ L: 147,
666
+ S: this,
667
+ C: (f, a) => f(...a)
664
668
  });
665
669
  const connection = this._createConnection(true, sessionId);
666
670
  this.initiating = true;
@@ -680,17 +684,17 @@ var Peer = class {
680
684
  ownId: this.localPeerId,
681
685
  remoteId: this.id
682
686
  }, {
683
- file: "peer.ts",
684
- line: 159,
685
- scope: this,
686
- callSite: (f, a) => f(...a)
687
+ F: __dxlog_file3,
688
+ L: 159,
689
+ S: this,
690
+ C: (f, a) => f(...a)
687
691
  });
688
692
  if (connection.state !== ConnectionState.INITIAL) {
689
- (0, import_log3.log)("ignoring response", {}, {
690
- file: "peer.ts",
691
- line: 161,
692
- scope: this,
693
- callSite: (f, a) => f(...a)
693
+ (0, import_log3.log)("ignoring response", void 0, {
694
+ F: __dxlog_file3,
695
+ L: 161,
696
+ S: this,
697
+ C: (f, a) => f(...a)
694
698
  });
695
699
  return;
696
700
  }
@@ -707,10 +711,10 @@ var Peer = class {
707
711
  peerId: this.localPeerId,
708
712
  remoteId: this.id
709
713
  }, {
710
- file: "peer.ts",
711
- line: 172,
712
- scope: this,
713
- callSite: (f, a) => f(...a)
714
+ F: __dxlog_file3,
715
+ L: 172,
716
+ S: this,
717
+ C: (f, a) => f(...a)
714
718
  });
715
719
  await this.closeConnection();
716
720
  throw err;
@@ -731,12 +735,12 @@ var Peer = class {
731
735
  initiator,
732
736
  sessionId
733
737
  }, {
734
- file: "peer.ts",
735
- line: 186,
736
- scope: this,
737
- callSite: (f, a) => f(...a)
738
+ F: __dxlog_file3,
739
+ L: 186,
740
+ S: this,
741
+ C: (f, a) => f(...a)
738
742
  });
739
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
743
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
740
744
  const connection = new Connection(
741
745
  this.topic,
742
746
  this.localPeerId,
@@ -771,12 +775,12 @@ var Peer = class {
771
775
  remoteId: this.id,
772
776
  initiator
773
777
  }, {
774
- file: "peer.ts",
775
- line: 221,
776
- scope: this,
777
- callSite: (f, a) => f(...a)
778
+ F: __dxlog_file3,
779
+ L: 221,
780
+ S: this,
781
+ C: (f, a) => f(...a)
778
782
  });
779
- (0, import_node_assert3.default)(this.connection === connection, "Connection mismatch (race condition).");
783
+ (0, import_tiny_invariant3.default)(this.connection === connection, "Connection mismatch (race condition).");
780
784
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
781
785
  this._availableAfter = 0;
782
786
  } else {
@@ -801,10 +805,10 @@ var Peer = class {
801
805
  initiator,
802
806
  err
803
807
  }, {
804
- file: "peer.ts",
805
- line: 249,
806
- scope: this,
807
- callSite: (f, a) => f(...a)
808
+ F: __dxlog_file3,
809
+ L: 249,
810
+ S: this,
811
+ C: (f, a) => f(...a)
808
812
  });
809
813
  void this.closeConnection();
810
814
  });
@@ -820,20 +824,20 @@ var Peer = class {
820
824
  peerId: this.id,
821
825
  sessionId: connection.sessionId
822
826
  }, {
823
- file: "peer.ts",
824
- line: 265,
825
- scope: this,
826
- callSite: (f, a) => f(...a)
827
+ F: __dxlog_file3,
828
+ L: 265,
829
+ S: this,
830
+ C: (f, a) => f(...a)
827
831
  });
828
832
  await connection.close();
829
833
  (0, import_log3.log)("closed", {
830
834
  peerId: this.id,
831
835
  sessionId: connection.sessionId
832
836
  }, {
833
- file: "peer.ts",
834
- line: 271,
835
- scope: this,
836
- callSite: (f, a) => f(...a)
837
+ F: __dxlog_file3,
838
+ L: 271,
839
+ S: this,
840
+ C: (f, a) => f(...a)
837
841
  });
838
842
  }
839
843
  async onSignal(message) {
@@ -841,10 +845,10 @@ var Peer = class {
841
845
  (0, import_log3.log)("dropping signal message for non-existent connection", {
842
846
  message
843
847
  }, {
844
- file: "peer.ts",
845
- line: 276,
846
- scope: this,
847
- callSite: (f, a) => f(...a)
848
+ F: __dxlog_file3,
849
+ L: 276,
850
+ S: this,
851
+ C: (f, a) => f(...a)
848
852
  });
849
853
  return;
850
854
  }
@@ -857,15 +861,15 @@ var Peer = class {
857
861
  peerId: this.id,
858
862
  topic: this.topic
859
863
  }, {
860
- file: "peer.ts",
861
- line: 285,
862
- scope: this,
863
- callSite: (f, a) => f(...a)
864
+ F: __dxlog_file3,
865
+ L: 285,
866
+ S: this,
867
+ C: (f, a) => f(...a)
864
868
  });
865
869
  await ((_a = this == null ? void 0 : this.connection) == null ? void 0 : _a.close());
866
870
  }
867
871
  };
868
- __decorate2([
872
+ _ts_decorate2([
869
873
  import_async2.synchronized
870
874
  ], Peer.prototype, "destroy", null);
871
875
  var increaseInterval = (interval) => {
@@ -882,7 +886,7 @@ var increaseInterval = (interval) => {
882
886
  };
883
887
 
884
888
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
885
- var __decorate3 = function(decorators, target, key, desc) {
889
+ function _ts_decorate3(decorators, target, key, desc) {
886
890
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
887
891
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
888
892
  r = Reflect.decorate(decorators, target, key, desc);
@@ -891,7 +895,8 @@ var __decorate3 = function(decorators, target, key, desc) {
891
895
  if (d = decorators[i])
892
896
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
893
897
  return c > 3 && r && Object.defineProperty(target, key, r), r;
894
- };
898
+ }
899
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
895
900
  var INITIATION_DELAY = 100;
896
901
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
897
902
  var Swarm = class {
@@ -908,11 +913,11 @@ var Swarm = class {
908
913
  this._peers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
909
914
  this._ctx = new import_context4.Context();
910
915
  this._listeningHandle = void 0;
916
+ this._instanceId = import_keys4.PublicKey.random().toHex();
911
917
  this.connectionAdded = new import_async3.Event();
912
918
  this.disconnected = new import_async3.Event();
913
919
  this.connected = new import_async3.Event();
914
920
  this.errors = new import_debug2.ErrorStream();
915
- this._instanceId = import_keys4.PublicKey.random().toHex();
916
921
  import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols3.trace.begin({
917
922
  id: this._instanceId,
918
923
  data: {
@@ -920,18 +925,18 @@ var Swarm = class {
920
925
  peerId: this._ownPeerId.toHex()
921
926
  }
922
927
  }), {
923
- file: "swarm.ts",
924
- line: 86,
925
- scope: this,
926
- callSite: (f, a) => f(...a)
928
+ F: __dxlog_file4,
929
+ L: 86,
930
+ S: this,
931
+ C: (f, a) => f(...a)
927
932
  });
928
933
  (0, import_log4.log)("creating swarm", {
929
934
  peerId: _ownPeerId
930
935
  }, {
931
- file: "swarm.ts",
932
- line: 90,
933
- scope: this,
934
- callSite: (f, a) => f(...a)
936
+ F: __dxlog_file4,
937
+ L: 90,
938
+ S: this,
939
+ C: (f, a) => f(...a)
935
940
  });
936
941
  _topology.init(this._getSwarmController());
937
942
  this._swarmMessenger = new SwarmMessenger({
@@ -943,10 +948,10 @@ var Swarm = class {
943
948
  import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols3.trace.end({
944
949
  id: this._instanceId
945
950
  }), {
946
- file: "swarm.ts",
947
- line: 99,
948
- scope: this,
949
- callSite: (f, a) => f(...a)
951
+ F: __dxlog_file4,
952
+ L: 99,
953
+ S: this,
954
+ C: (f, a) => f(...a)
950
955
  });
951
956
  }
952
957
  get connections() {
@@ -965,7 +970,7 @@ var Swarm = class {
965
970
  return this._topic;
966
971
  }
967
972
  async open() {
968
- (0, import_node_assert4.default)(!this._listeningHandle);
973
+ (0, import_tiny_invariant4.default)(!this._listeningHandle);
969
974
  this._listeningHandle = await this._messenger.listen({
970
975
  peerId: this._ownPeerId,
971
976
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -973,36 +978,36 @@ var Swarm = class {
973
978
  await this._swarmMessenger.receiveMessage(message).catch((err) => import_log4.log.warn("Error while receiving message", {
974
979
  err
975
980
  }, {
976
- file: "swarm.ts",
977
- line: 133,
978
- scope: this,
979
- callSite: (f, a) => f(...a)
981
+ F: __dxlog_file4,
982
+ L: 133,
983
+ S: this,
984
+ C: (f, a) => f(...a)
980
985
  }));
981
986
  }
982
987
  });
983
988
  }
984
989
  async destroy() {
985
990
  var _a;
986
- (0, import_log4.log)("destroying...", {}, {
987
- file: "swarm.ts",
988
- line: 139,
989
- scope: this,
990
- callSite: (f, a) => f(...a)
991
+ (0, import_log4.log)("destroying...", void 0, {
992
+ F: __dxlog_file4,
993
+ L: 139,
994
+ S: this,
995
+ C: (f, a) => f(...a)
991
996
  });
992
997
  await ((_a = this._listeningHandle) == null ? void 0 : _a.unsubscribe());
993
998
  this._listeningHandle = void 0;
994
999
  await this._ctx.dispose();
995
1000
  await this._topology.destroy();
996
1001
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
997
- (0, import_log4.log)("destroyed", {}, {
998
- file: "swarm.ts",
999
- line: 146,
1000
- scope: this,
1001
- callSite: (f, a) => f(...a)
1002
+ (0, import_log4.log)("destroyed", void 0, {
1003
+ F: __dxlog_file4,
1004
+ L: 146,
1005
+ S: this,
1006
+ C: (f, a) => f(...a)
1002
1007
  });
1003
1008
  }
1004
1009
  async setTopology(topology) {
1005
- (0, import_node_assert4.default)(!this._ctx.disposed, "Swarm is offline");
1010
+ (0, import_tiny_invariant4.default)(!this._ctx.disposed, "Swarm is offline");
1006
1011
  if (topology === this._topology) {
1007
1012
  return;
1008
1013
  }
@@ -1010,10 +1015,10 @@ var Swarm = class {
1010
1015
  previous: getClassName(this._topology),
1011
1016
  topology: getClassName(topology)
1012
1017
  }, {
1013
- file: "swarm.ts",
1014
- line: 154,
1015
- scope: this,
1016
- callSite: (f, a) => f(...a)
1018
+ F: __dxlog_file4,
1019
+ L: 154,
1020
+ S: this,
1021
+ C: (f, a) => f(...a)
1017
1022
  });
1018
1023
  await this._topology.destroy();
1019
1024
  this._topology = topology;
@@ -1025,17 +1030,17 @@ var Swarm = class {
1025
1030
  (0, import_log4.log)("swarm event", {
1026
1031
  swarmEvent
1027
1032
  }, {
1028
- file: "swarm.ts",
1029
- line: 167,
1030
- scope: this,
1031
- callSite: (f, a) => f(...a)
1033
+ F: __dxlog_file4,
1034
+ L: 167,
1035
+ S: this,
1036
+ C: (f, a) => f(...a)
1032
1037
  });
1033
1038
  if (this._ctx.disposed) {
1034
- (0, import_log4.log)("swarm event ignored for disposed swarm", {}, {
1035
- file: "swarm.ts",
1036
- line: 170,
1037
- scope: this,
1038
- callSite: (f, a) => f(...a)
1039
+ (0, import_log4.log)("swarm event ignored for disposed swarm", void 0, {
1040
+ F: __dxlog_file4,
1041
+ L: 170,
1042
+ S: this,
1043
+ C: (f, a) => f(...a)
1039
1044
  });
1040
1045
  return;
1041
1046
  }
@@ -1044,25 +1049,25 @@ var Swarm = class {
1044
1049
  (0, import_log4.log)("new peer", {
1045
1050
  peerId
1046
1051
  }, {
1047
- file: "swarm.ts",
1048
- line: 176,
1049
- scope: this,
1050
- callSite: (f, a) => f(...a)
1052
+ F: __dxlog_file4,
1053
+ L: 176,
1054
+ S: this,
1055
+ C: (f, a) => f(...a)
1051
1056
  });
1052
1057
  if (!peerId.equals(this._ownPeerId)) {
1053
1058
  const peer = this._getOrCreatePeer(peerId);
1054
1059
  peer.advertizing = true;
1055
1060
  }
1056
1061
  } else if (swarmEvent.peerLeft) {
1057
- const peer1 = this._peers.get(import_keys4.PublicKey.from(swarmEvent.peerLeft.peer));
1058
- if (peer1) {
1059
- peer1.advertizing = false;
1060
- if (((_a = peer1.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
1061
- void this._destroyPeer(peer1.id).catch((err) => import_log4.log.catch(err, {}, {
1062
- file: "swarm.ts",
1063
- line: 187,
1064
- scope: this,
1065
- callSite: (f, a) => f(...a)
1062
+ const peer = this._peers.get(import_keys4.PublicKey.from(swarmEvent.peerLeft.peer));
1063
+ if (peer) {
1064
+ peer.advertizing = false;
1065
+ if (((_a = peer.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
1066
+ void this._destroyPeer(peer.id).catch((err) => import_log4.log.catch(err, void 0, {
1067
+ F: __dxlog_file4,
1068
+ L: 187,
1069
+ S: this,
1070
+ C: (f, a) => f(...a)
1066
1071
  }));
1067
1072
  }
1068
1073
  }
@@ -1074,31 +1079,31 @@ var Swarm = class {
1074
1079
  (0, import_log4.log)("offer", {
1075
1080
  message
1076
1081
  }, {
1077
- file: "swarm.ts",
1078
- line: 197,
1079
- scope: this,
1080
- callSite: (f, a) => f(...a)
1082
+ F: __dxlog_file4,
1083
+ L: 197,
1084
+ S: this,
1085
+ C: (f, a) => f(...a)
1081
1086
  });
1082
1087
  if (this._ctx.disposed) {
1083
- (0, import_log4.log)("ignored for disposed swarm", {}, {
1084
- file: "swarm.ts",
1085
- line: 199,
1086
- scope: this,
1087
- callSite: (f, a) => f(...a)
1088
+ (0, import_log4.log)("ignored for disposed swarm", void 0, {
1089
+ F: __dxlog_file4,
1090
+ L: 199,
1091
+ S: this,
1092
+ C: (f, a) => f(...a)
1088
1093
  });
1089
1094
  return {
1090
1095
  accept: false
1091
1096
  };
1092
1097
  }
1093
- (0, import_node_assert4.default)(message.author);
1098
+ (0, import_tiny_invariant4.default)(message.author);
1094
1099
  if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
1095
1100
  (0, import_log4.log)("rejecting offer with incorrect peerId", {
1096
1101
  message
1097
1102
  }, {
1098
- file: "swarm.ts",
1099
- line: 206,
1100
- scope: this,
1101
- callSite: (f, a) => f(...a)
1103
+ F: __dxlog_file4,
1104
+ L: 206,
1105
+ S: this,
1106
+ C: (f, a) => f(...a)
1102
1107
  });
1103
1108
  return {
1104
1109
  accept: false
@@ -1108,10 +1113,10 @@ var Swarm = class {
1108
1113
  (0, import_log4.log)("rejecting offer with incorrect topic", {
1109
1114
  message
1110
1115
  }, {
1111
- file: "swarm.ts",
1112
- line: 210,
1113
- scope: this,
1114
- callSite: (f, a) => f(...a)
1116
+ F: __dxlog_file4,
1117
+ L: 210,
1118
+ S: this,
1119
+ C: (f, a) => f(...a)
1115
1120
  });
1116
1121
  return {
1117
1122
  accept: false
@@ -1127,23 +1132,23 @@ var Swarm = class {
1127
1132
  (0, import_log4.log)("signal", {
1128
1133
  message
1129
1134
  }, {
1130
- file: "swarm.ts",
1131
- line: 222,
1132
- scope: this,
1133
- callSite: (f, a) => f(...a)
1135
+ F: __dxlog_file4,
1136
+ L: 222,
1137
+ S: this,
1138
+ C: (f, a) => f(...a)
1134
1139
  });
1135
1140
  if (this._ctx.disposed) {
1136
- import_log4.log.info("ignored for offline swarm", {}, {
1137
- file: "swarm.ts",
1138
- line: 224,
1139
- scope: this,
1140
- callSite: (f, a) => f(...a)
1141
+ import_log4.log.info("ignored for offline swarm", void 0, {
1142
+ F: __dxlog_file4,
1143
+ L: 224,
1144
+ S: this,
1145
+ C: (f, a) => f(...a)
1141
1146
  });
1142
1147
  return;
1143
1148
  }
1144
- (0, import_node_assert4.default)((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1145
- (0, import_node_assert4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1146
- (0, import_node_assert4.default)(message.author);
1149
+ (0, import_tiny_invariant4.default)((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1150
+ (0, import_tiny_invariant4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1151
+ (0, import_tiny_invariant4.default)(message.author);
1147
1152
  const peer = this._getOrCreatePeer(message.author);
1148
1153
  await peer.onSignal(message);
1149
1154
  }
@@ -1195,7 +1200,7 @@ var Swarm = class {
1195
1200
  return peer;
1196
1201
  }
1197
1202
  async _destroyPeer(peerId) {
1198
- (0, import_node_assert4.default)(this._peers.has(peerId));
1203
+ (0, import_tiny_invariant4.default)(this._peers.has(peerId));
1199
1204
  await this._peers.get(peerId).destroy();
1200
1205
  this._peers.delete(peerId);
1201
1206
  }
@@ -1215,10 +1220,10 @@ var Swarm = class {
1215
1220
  await this._initiateConnection(peer);
1216
1221
  } catch (err) {
1217
1222
  (0, import_log4.log)("initiation error", err, {
1218
- file: "swarm.ts",
1219
- line: 327,
1220
- scope: this,
1221
- callSite: (f, a) => f(...a)
1223
+ F: __dxlog_file4,
1224
+ L: 327,
1225
+ S: this,
1226
+ C: (f, a) => f(...a)
1222
1227
  });
1223
1228
  }
1224
1229
  });
@@ -1243,10 +1248,10 @@ var Swarm = class {
1243
1248
  (0, import_log4.log)("initiation delay", {
1244
1249
  remoteId
1245
1250
  }, {
1246
- file: "swarm.ts",
1247
- line: 354,
1248
- scope: this,
1249
- callSite: (f, a) => f(...a)
1251
+ F: __dxlog_file4,
1252
+ L: 354,
1253
+ S: this,
1254
+ C: (f, a) => f(...a)
1250
1255
  });
1251
1256
  await (0, import_async3.sleep)(INITIATION_DELAY);
1252
1257
  }
@@ -1260,20 +1265,20 @@ var Swarm = class {
1260
1265
  (0, import_log4.log)("initiating connection...", {
1261
1266
  remoteId
1262
1267
  }, {
1263
- file: "swarm.ts",
1264
- line: 368,
1265
- scope: this,
1266
- callSite: (f, a) => f(...a)
1268
+ F: __dxlog_file4,
1269
+ L: 368,
1270
+ S: this,
1271
+ C: (f, a) => f(...a)
1267
1272
  });
1268
1273
  await peer.initiateConnection();
1269
1274
  this._topology.update();
1270
1275
  (0, import_log4.log)("initiated", {
1271
1276
  remoteId
1272
1277
  }, {
1273
- file: "swarm.ts",
1274
- line: 371,
1275
- scope: this,
1276
- callSite: (f, a) => f(...a)
1278
+ F: __dxlog_file4,
1279
+ L: 371,
1280
+ S: this,
1281
+ C: (f, a) => f(...a)
1277
1282
  });
1278
1283
  }
1279
1284
  async _closeConnection(peerId) {
@@ -1284,28 +1289,28 @@ var Swarm = class {
1284
1289
  await peer.closeConnection();
1285
1290
  }
1286
1291
  };
1287
- __decorate3([
1292
+ _ts_decorate3([
1288
1293
  import_log4.logInfo
1289
1294
  ], Swarm.prototype, "_instanceId", void 0);
1290
- __decorate3([
1295
+ _ts_decorate3([
1291
1296
  import_log4.logInfo
1292
1297
  ], Swarm.prototype, "ownPeerId", null);
1293
- __decorate3([
1298
+ _ts_decorate3([
1294
1299
  import_log4.logInfo
1295
1300
  ], Swarm.prototype, "topic", null);
1296
- __decorate3([
1301
+ _ts_decorate3([
1297
1302
  import_async3.synchronized
1298
1303
  ], Swarm.prototype, "onSwarmEvent", null);
1299
- __decorate3([
1304
+ _ts_decorate3([
1300
1305
  import_async3.synchronized
1301
1306
  ], Swarm.prototype, "onOffer", null);
1302
- __decorate3([
1307
+ _ts_decorate3([
1303
1308
  import_async3.synchronized
1304
1309
  ], Swarm.prototype, "onSignal", null);
1305
- __decorate3([
1310
+ _ts_decorate3([
1306
1311
  import_async3.synchronized
1307
1312
  ], Swarm.prototype, "goOffline", null);
1308
- __decorate3([
1313
+ _ts_decorate3([
1309
1314
  import_async3.synchronized
1310
1315
  ], Swarm.prototype, "goOnline", null);
1311
1316
 
@@ -1314,6 +1319,7 @@ var import_async4 = require("@dxos/async");
1314
1319
  var import_keys5 = require("@dxos/keys");
1315
1320
  var import_log5 = require("@dxos/log");
1316
1321
  var import_util3 = require("@dxos/util");
1322
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1317
1323
  var SwarmMapper = class {
1318
1324
  get peers() {
1319
1325
  return Array.from(this._peers.values());
@@ -1340,11 +1346,11 @@ var SwarmMapper = class {
1340
1346
  this._update();
1341
1347
  }
1342
1348
  _update() {
1343
- (0, import_log5.log)("updating swarm", {}, {
1344
- file: "swarm-mapper.ts",
1345
- line: 75,
1346
- scope: this,
1347
- callSite: (f, a) => f(...a)
1349
+ (0, import_log5.log)("updating swarm", void 0, {
1350
+ F: __dxlog_file5,
1351
+ L: 75,
1352
+ S: this,
1353
+ C: (f, a) => f(...a)
1348
1354
  });
1349
1355
  this._peers.clear();
1350
1356
  this._peers.set(this._swarm.ownPeerId, {
@@ -1365,10 +1371,10 @@ var SwarmMapper = class {
1365
1371
  directConnections: this._swarm.connections.length,
1366
1372
  totalPeersInSwarm: this._peers.size
1367
1373
  }, {
1368
- file: "swarm-mapper.ts",
1369
- line: 116,
1370
- scope: this,
1371
- callSite: (f, a) => f(...a)
1374
+ F: __dxlog_file5,
1375
+ L: 116,
1376
+ S: this,
1377
+ C: (f, a) => f(...a)
1372
1378
  });
1373
1379
  this.mapUpdated.emit(Array.from(this._peers.values()));
1374
1380
  }
@@ -1446,7 +1452,7 @@ var ConnectionLog = class {
1446
1452
  };
1447
1453
 
1448
1454
  // packages/core/mesh/network-manager/src/network-manager.ts
1449
- var import_node_assert5 = __toESM(require("node:assert"));
1455
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
1450
1456
  var import_async6 = require("@dxos/async");
1451
1457
  var import_keys7 = require("@dxos/keys");
1452
1458
  var import_log6 = require("@dxos/log");
@@ -1454,8 +1460,9 @@ var import_messaging = require("@dxos/messaging");
1454
1460
  var import_protocols4 = require("@dxos/protocols");
1455
1461
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
1456
1462
  var import_util5 = require("@dxos/util");
1463
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
1457
1464
  var NetworkManager = class {
1458
- constructor({ transportFactory, signalManager, log: log13 }) {
1465
+ constructor({ transportFactory, signalManager, log: log1 }) {
1459
1466
  this._swarms = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
1460
1467
  this._mappers = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
1461
1468
  this._connectionState = import_services.ConnectionState.ONLINE;
@@ -1475,7 +1482,7 @@ var NetworkManager = class {
1475
1482
  join: (opts) => this._signalManager.join(opts),
1476
1483
  leave: (opts) => this._signalManager.leave(opts)
1477
1484
  };
1478
- if (log13) {
1485
+ if (log1) {
1479
1486
  this._connectionLog = new ConnectionLog();
1480
1487
  }
1481
1488
  }
@@ -1500,30 +1507,30 @@ var NetworkManager = class {
1500
1507
  import_log6.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.begin({
1501
1508
  id: this._instanceId
1502
1509
  }), {
1503
- file: "network-manager.ts",
1504
- line: 127,
1505
- scope: this,
1506
- callSite: (f, a) => f(...a)
1510
+ F: __dxlog_file6,
1511
+ L: 127,
1512
+ S: this,
1513
+ C: (f, a) => f(...a)
1507
1514
  });
1508
1515
  await this._messenger.open();
1509
1516
  await this._signalManager.open();
1510
1517
  import_log6.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.end({
1511
1518
  id: this._instanceId
1512
1519
  }), {
1513
- file: "network-manager.ts",
1514
- line: 130,
1515
- scope: this,
1516
- callSite: (f, a) => f(...a)
1520
+ F: __dxlog_file6,
1521
+ L: 130,
1522
+ S: this,
1523
+ C: (f, a) => f(...a)
1517
1524
  });
1518
1525
  }
1519
1526
  async close() {
1520
1527
  for (const topic of this._swarms.keys()) {
1521
1528
  await this.leaveSwarm(topic).catch((err) => {
1522
- (0, import_log6.log)(err, {}, {
1523
- file: "network-manager.ts",
1524
- line: 136,
1525
- scope: this,
1526
- callSite: (f, a) => f(...a)
1529
+ (0, import_log6.log)(err, void 0, {
1530
+ F: __dxlog_file6,
1531
+ L: 136,
1532
+ S: this,
1533
+ C: (f, a) => f(...a)
1527
1534
  });
1528
1535
  });
1529
1536
  }
@@ -1535,10 +1542,10 @@ var NetworkManager = class {
1535
1542
  */
1536
1543
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1537
1544
  var _a;
1538
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(topic));
1539
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1540
- (0, import_node_assert5.default)(topology);
1541
- (0, import_node_assert5.default)(typeof protocol === "function");
1545
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(topic));
1546
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1547
+ (0, import_tiny_invariant5.default)(topology);
1548
+ (0, import_tiny_invariant5.default)(typeof protocol === "function");
1542
1549
  if (this._swarms.has(topic)) {
1543
1550
  throw new Error(`Already connected to swarm: ${import_keys7.PublicKey.from(topic)}`);
1544
1551
  }
@@ -1547,20 +1554,20 @@ var NetworkManager = class {
1547
1554
  peerId,
1548
1555
  topology: topology.toString()
1549
1556
  }, {
1550
- file: "network-manager.ts",
1551
- line: 162,
1552
- scope: this,
1553
- callSite: (f, a) => f(...a)
1557
+ F: __dxlog_file6,
1558
+ L: 162,
1559
+ S: this,
1560
+ C: (f, a) => f(...a)
1554
1561
  });
1555
1562
  const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label);
1556
1563
  swarm.errors.handle((error) => {
1557
1564
  (0, import_log6.log)("swarm error", {
1558
1565
  error
1559
1566
  }, {
1560
- file: "network-manager.ts",
1561
- line: 165,
1562
- scope: this,
1563
- callSite: (f, a) => f(...a)
1567
+ F: __dxlog_file6,
1568
+ L: 165,
1569
+ S: this,
1570
+ C: (f, a) => f(...a)
1564
1571
  });
1565
1572
  });
1566
1573
  this._swarms.set(topic, swarm);
@@ -1569,11 +1576,11 @@ var NetworkManager = class {
1569
1576
  this._signalConnection.join({
1570
1577
  topic,
1571
1578
  peerId
1572
- }).catch((error) => import_log6.log.catch(error, {}, {
1573
- file: "network-manager.ts",
1574
- line: 174,
1575
- scope: this,
1576
- callSite: (f, a) => f(...a)
1579
+ }).catch((error) => import_log6.log.catch(error, void 0, {
1580
+ F: __dxlog_file6,
1581
+ L: 174,
1582
+ S: this,
1583
+ C: (f, a) => f(...a)
1577
1584
  }));
1578
1585
  this.topicsUpdated.emit();
1579
1586
  (_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
@@ -1581,10 +1588,10 @@ var NetworkManager = class {
1581
1588
  topic: import_keys7.PublicKey.from(topic),
1582
1589
  count: this._swarms.size
1583
1590
  }, {
1584
- file: "network-manager.ts",
1585
- line: 178,
1586
- scope: this,
1587
- callSite: (f, a) => f(...a)
1591
+ F: __dxlog_file6,
1592
+ L: 178,
1593
+ S: this,
1594
+ C: (f, a) => f(...a)
1588
1595
  });
1589
1596
  return {
1590
1597
  close: () => this.leaveSwarm(topic)
@@ -1601,10 +1608,10 @@ var NetworkManager = class {
1601
1608
  (0, import_log6.log)("leaving", {
1602
1609
  topic: import_keys7.PublicKey.from(topic)
1603
1610
  }, {
1604
- file: "network-manager.ts",
1605
- line: 194,
1606
- scope: this,
1607
- callSite: (f, a) => f(...a)
1611
+ F: __dxlog_file6,
1612
+ L: 194,
1613
+ S: this,
1614
+ C: (f, a) => f(...a)
1608
1615
  });
1609
1616
  const swarm = this._swarms.get(topic);
1610
1617
  await this._signalConnection.leave({
@@ -1622,10 +1629,10 @@ var NetworkManager = class {
1622
1629
  topic: import_keys7.PublicKey.from(topic),
1623
1630
  count: this._swarms.size
1624
1631
  }, {
1625
- file: "network-manager.ts",
1626
- line: 208,
1627
- scope: this,
1628
- callSite: (f, a) => f(...a)
1632
+ F: __dxlog_file6,
1633
+ L: 208,
1634
+ S: this,
1635
+ C: (f, a) => f(...a)
1629
1636
  });
1630
1637
  }
1631
1638
  async setConnectionState(state) {
@@ -1657,17 +1664,17 @@ var NetworkManager = class {
1657
1664
  };
1658
1665
 
1659
1666
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1660
- var import_node_assert6 = __toESM(require("node:assert"));
1667
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1661
1668
  var FullyConnectedTopology = class {
1662
1669
  toString() {
1663
1670
  return "FullyConnectedTopology";
1664
1671
  }
1665
1672
  init(controller) {
1666
- (0, import_node_assert6.default)(!this._controller, "Already initialized");
1673
+ (0, import_tiny_invariant6.default)(!this._controller, "Already initialized");
1667
1674
  this._controller = controller;
1668
1675
  }
1669
1676
  update() {
1670
- (0, import_node_assert6.default)(this._controller, "Not initialized");
1677
+ (0, import_tiny_invariant6.default)(this._controller, "Not initialized");
1671
1678
  const { candidates: discovered } = this._controller.getState();
1672
1679
  for (const peer of discovered) {
1673
1680
  this._controller.connect(peer);
@@ -1681,9 +1688,10 @@ var FullyConnectedTopology = class {
1681
1688
  };
1682
1689
 
1683
1690
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1684
- var import_node_assert7 = __toESM(require("node:assert"));
1691
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1685
1692
  var import_xor_distance = __toESM(require("xor-distance"));
1686
1693
  var import_log7 = require("@dxos/log");
1694
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
1687
1695
  var MMSTTopology = class {
1688
1696
  constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
1689
1697
  this._sampleCollected = false;
@@ -1692,62 +1700,62 @@ var MMSTTopology = class {
1692
1700
  this._sampleSize = sampleSize;
1693
1701
  }
1694
1702
  init(controller) {
1695
- (0, import_node_assert7.default)(!this._controller, "Already initialized");
1703
+ (0, import_tiny_invariant7.default)(!this._controller, "Already initialized");
1696
1704
  this._controller = controller;
1697
1705
  }
1698
1706
  update() {
1699
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1707
+ (0, import_tiny_invariant7.default)(this._controller, "Not initialized");
1700
1708
  const { connected, candidates } = this._controller.getState();
1701
1709
  if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
1702
- (0, import_log7.log)("Running the algorithm.", {}, {
1703
- file: "mmst-topology.ts",
1704
- line: 55,
1705
- scope: this,
1706
- callSite: (f, a) => f(...a)
1710
+ (0, import_log7.log)("Running the algorithm.", void 0, {
1711
+ F: __dxlog_file7,
1712
+ L: 55,
1713
+ S: this,
1714
+ C: (f, a) => f(...a)
1707
1715
  });
1708
1716
  this._sampleCollected = true;
1709
1717
  this._runAlgorithm();
1710
1718
  }
1711
1719
  }
1712
1720
  async onOffer(peer) {
1713
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1721
+ (0, import_tiny_invariant7.default)(this._controller, "Not initialized");
1714
1722
  const { connected } = this._controller.getState();
1715
1723
  const accept = connected.length < this._maxPeers;
1716
- (0, import_log7.log)(`Offer ${peer} accept=${accept}`, {}, {
1717
- file: "mmst-topology.ts",
1718
- line: 65,
1719
- scope: this,
1720
- callSite: (f, a) => f(...a)
1724
+ (0, import_log7.log)(`Offer ${peer} accept=${accept}`, void 0, {
1725
+ F: __dxlog_file7,
1726
+ L: 65,
1727
+ S: this,
1728
+ C: (f, a) => f(...a)
1721
1729
  });
1722
1730
  return accept;
1723
1731
  }
1724
1732
  async destroy() {
1725
1733
  }
1726
1734
  _runAlgorithm() {
1727
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1735
+ (0, import_tiny_invariant7.default)(this._controller, "Not initialized");
1728
1736
  const { connected, candidates, ownPeerId } = this._controller.getState();
1729
1737
  if (connected.length > this._maxPeers) {
1730
1738
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
1731
1739
  for (const peer of sorted) {
1732
- (0, import_log7.log)(`Disconnect ${peer}.`, {}, {
1733
- file: "mmst-topology.ts",
1734
- line: 83,
1735
- scope: this,
1736
- callSite: (f, a) => f(...a)
1740
+ (0, import_log7.log)(`Disconnect ${peer}.`, void 0, {
1741
+ F: __dxlog_file7,
1742
+ L: 83,
1743
+ S: this,
1744
+ C: (f, a) => f(...a)
1737
1745
  });
1738
1746
  this._controller.disconnect(peer);
1739
1747
  }
1740
1748
  } else if (connected.length < this._originateConnections) {
1741
1749
  const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
1742
- const sorted1 = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
1743
- for (const peer1 of sorted1) {
1744
- (0, import_log7.log)(`Connect ${peer1}.`, {}, {
1745
- file: "mmst-topology.ts",
1746
- line: 91,
1747
- scope: this,
1748
- callSite: (f, a) => f(...a)
1750
+ const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
1751
+ for (const peer of sorted) {
1752
+ (0, import_log7.log)(`Connect ${peer}.`, void 0, {
1753
+ F: __dxlog_file7,
1754
+ L: 91,
1755
+ S: this,
1756
+ C: (f, a) => f(...a)
1749
1757
  });
1750
- this._controller.connect(peer1);
1758
+ this._controller.connect(peer);
1751
1759
  }
1752
1760
  }
1753
1761
  }
@@ -1758,8 +1766,9 @@ var MMSTTopology = class {
1758
1766
  var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_distance.default.gt((0, import_xor_distance.default)(a.asBuffer(), reference.asBuffer()), (0, import_xor_distance.default)(b.asBuffer(), reference.asBuffer())));
1759
1767
 
1760
1768
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1761
- var import_node_assert8 = __toESM(require("node:assert"));
1769
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1762
1770
  var import_log8 = require("@dxos/log");
1771
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
1763
1772
  var StarTopology = class {
1764
1773
  // prettier-ignore
1765
1774
  constructor(_centralPeer) {
@@ -1769,59 +1778,59 @@ var StarTopology = class {
1769
1778
  return `StarTopology(${this._centralPeer.truncate()})`;
1770
1779
  }
1771
1780
  init(controller) {
1772
- (0, import_node_assert8.default)(!this._controller, "Already initialized.");
1781
+ (0, import_tiny_invariant8.default)(!this._controller, "Already initialized.");
1773
1782
  this._controller = controller;
1774
1783
  }
1775
1784
  update() {
1776
- (0, import_node_assert8.default)(this._controller, "Not initialized.");
1785
+ (0, import_tiny_invariant8.default)(this._controller, "Not initialized.");
1777
1786
  const { candidates, connected, ownPeerId } = this._controller.getState();
1778
1787
  if (!ownPeerId.equals(this._centralPeer)) {
1779
- (0, import_log8.log)("leaf peer dropping all connections apart from central peer.", {}, {
1780
- file: "star-topology.ts",
1781
- line: 33,
1782
- scope: this,
1783
- callSite: (f, a) => f(...a)
1788
+ (0, import_log8.log)("leaf peer dropping all connections apart from central peer.", void 0, {
1789
+ F: __dxlog_file8,
1790
+ L: 33,
1791
+ S: this,
1792
+ C: (f, a) => f(...a)
1784
1793
  });
1785
1794
  for (const peer of connected) {
1786
1795
  if (!peer.equals(this._centralPeer)) {
1787
1796
  (0, import_log8.log)("dropping connection", {
1788
1797
  peer
1789
1798
  }, {
1790
- file: "star-topology.ts",
1791
- line: 38,
1792
- scope: this,
1793
- callSite: (f, a) => f(...a)
1799
+ F: __dxlog_file8,
1800
+ L: 38,
1801
+ S: this,
1802
+ C: (f, a) => f(...a)
1794
1803
  });
1795
1804
  this._controller.disconnect(peer);
1796
1805
  }
1797
1806
  }
1798
1807
  }
1799
- for (const peer1 of candidates) {
1800
- if (peer1.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
1808
+ for (const peer of candidates) {
1809
+ if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
1801
1810
  (0, import_log8.log)("connecting to peer", {
1802
- peer: peer1
1811
+ peer
1803
1812
  }, {
1804
- file: "star-topology.ts",
1805
- line: 47,
1806
- scope: this,
1807
- callSite: (f, a) => f(...a)
1813
+ F: __dxlog_file8,
1814
+ L: 47,
1815
+ S: this,
1816
+ C: (f, a) => f(...a)
1808
1817
  });
1809
- this._controller.connect(peer1);
1818
+ this._controller.connect(peer);
1810
1819
  }
1811
1820
  }
1812
1821
  }
1813
1822
  async onOffer(peer) {
1814
- (0, import_node_assert8.default)(this._controller, "Not initialized.");
1823
+ (0, import_tiny_invariant8.default)(this._controller, "Not initialized.");
1815
1824
  const { ownPeerId } = this._controller.getState();
1816
1825
  (0, import_log8.log)("offer", {
1817
1826
  peer,
1818
1827
  isCentral: peer.equals(this._centralPeer),
1819
1828
  isSelfCentral: ownPeerId.equals(this._centralPeer)
1820
1829
  }, {
1821
- file: "star-topology.ts",
1822
- line: 56,
1823
- scope: this,
1824
- callSite: (f, a) => f(...a)
1830
+ F: __dxlog_file8,
1831
+ L: 56,
1832
+ S: this,
1833
+ C: (f, a) => f(...a)
1825
1834
  });
1826
1835
  return ownPeerId.equals(this._centralPeer) || peer.equals(this._centralPeer);
1827
1836
  }
@@ -1830,14 +1839,14 @@ var StarTopology = class {
1830
1839
  };
1831
1840
 
1832
1841
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1833
- var import_node_assert9 = __toESM(require("node:assert"));
1834
1842
  var import_node_stream = require("node:stream");
1843
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
1835
1844
  var import_async7 = require("@dxos/async");
1836
1845
  var import_debug4 = require("@dxos/debug");
1837
1846
  var import_keys8 = require("@dxos/keys");
1838
1847
  var import_log9 = require("@dxos/log");
1839
1848
  var import_util6 = require("@dxos/util");
1840
- var __decorate4 = function(decorators, target, key, desc) {
1849
+ function _ts_decorate4(decorators, target, key, desc) {
1841
1850
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1842
1851
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1843
1852
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1846,7 +1855,8 @@ var __decorate4 = function(decorators, target, key, desc) {
1846
1855
  if (d = decorators[i])
1847
1856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1848
1857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1849
- };
1858
+ }
1859
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
1850
1860
  var MEMORY_TRANSPORT_DELAY = 1;
1851
1861
  var createStreamDelay = (delay) => {
1852
1862
  return new import_node_stream.Transform({
@@ -1866,26 +1876,26 @@ var _MemoryTransport = class {
1866
1876
  this.closed = new import_async7.Event();
1867
1877
  this.connected = new import_async7.Event();
1868
1878
  this.errors = new import_debug4.ErrorStream();
1879
+ this._instanceId = import_keys8.PublicKey.random();
1869
1880
  this._remote = new import_async7.Trigger();
1870
1881
  this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1871
1882
  this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1872
1883
  this._destroyed = false;
1873
- this._instanceId = import_keys8.PublicKey.random();
1874
- (0, import_log9.log)("creating", {}, {
1875
- file: "memory-transport.ts",
1876
- line: 64,
1877
- scope: this,
1878
- callSite: (f, a) => f(...a)
1884
+ (0, import_log9.log)("creating", void 0, {
1885
+ F: __dxlog_file9,
1886
+ L: 64,
1887
+ S: this,
1888
+ C: (f, a) => f(...a)
1879
1889
  });
1880
- (0, import_node_assert9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1890
+ (0, import_tiny_invariant9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1881
1891
  _MemoryTransport._connections.set(this._instanceId, this);
1882
1892
  if (this.options.initiator) {
1883
1893
  setTimeout(async () => {
1884
- (0, import_log9.log)("sending signal", {}, {
1885
- file: "memory-transport.ts",
1886
- line: 73,
1887
- scope: this,
1888
- callSite: (f, a) => f(...a)
1894
+ (0, import_log9.log)("sending signal", void 0, {
1895
+ F: __dxlog_file9,
1896
+ L: 73,
1897
+ S: this,
1898
+ C: (f, a) => f(...a)
1889
1899
  });
1890
1900
  void this.options.sendSignal({
1891
1901
  payload: {
@@ -1911,14 +1921,14 @@ var _MemoryTransport = class {
1911
1921
  this.closed.emit();
1912
1922
  return;
1913
1923
  }
1914
- (0, import_node_assert9.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1924
+ (0, import_tiny_invariant9.default)(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
1915
1925
  this._remoteConnection._remoteConnection = this;
1916
1926
  this._remoteConnection._remoteInstanceId = this._instanceId;
1917
- (0, import_log9.log)("connected", {}, {
1918
- file: "memory-transport.ts",
1919
- line: 106,
1920
- scope: this,
1921
- callSite: (f, a) => f(...a)
1927
+ (0, import_log9.log)("connected", void 0, {
1928
+ F: __dxlog_file9,
1929
+ L: 103,
1930
+ S: this,
1931
+ C: (f, a) => f(...a)
1922
1932
  });
1923
1933
  this.options.stream.pipe(this._outgoingDelay).pipe(this._remoteConnection.options.stream).pipe(this._incomingDelay).pipe(this.options.stream);
1924
1934
  this.connected.emit();
@@ -1932,20 +1942,20 @@ var _MemoryTransport = class {
1932
1942
  }
1933
1943
  }
1934
1944
  async destroy() {
1935
- (0, import_log9.log)("closing", {}, {
1936
- file: "memory-transport.ts",
1937
- line: 127,
1938
- scope: this,
1939
- callSite: (f, a) => f(...a)
1945
+ (0, import_log9.log)("closing", void 0, {
1946
+ F: __dxlog_file9,
1947
+ L: 124,
1948
+ S: this,
1949
+ C: (f, a) => f(...a)
1940
1950
  });
1941
1951
  this._destroyed = true;
1942
1952
  _MemoryTransport._connections.delete(this._instanceId);
1943
1953
  if (this._remoteConnection) {
1944
- (0, import_log9.log)("closing", {}, {
1945
- file: "memory-transport.ts",
1946
- line: 132,
1947
- scope: this,
1948
- callSite: (f, a) => f(...a)
1954
+ (0, import_log9.log)("closing", void 0, {
1955
+ F: __dxlog_file9,
1956
+ L: 129,
1957
+ S: this,
1958
+ C: (f, a) => f(...a)
1949
1959
  });
1950
1960
  this._remoteConnection._destroyed = true;
1951
1961
  _MemoryTransport._connections.delete(this._remoteInstanceId);
@@ -1954,29 +1964,29 @@ var _MemoryTransport = class {
1954
1964
  this._remoteConnection.closed.emit();
1955
1965
  this._remoteConnection._remoteConnection = void 0;
1956
1966
  this._remoteConnection = void 0;
1957
- (0, import_log9.log)("closed", {}, {
1958
- file: "memory-transport.ts",
1959
- line: 150,
1960
- scope: this,
1961
- callSite: (f, a) => f(...a)
1967
+ (0, import_log9.log)("closed", void 0, {
1968
+ F: __dxlog_file9,
1969
+ L: 147,
1970
+ S: this,
1971
+ C: (f, a) => f(...a)
1962
1972
  });
1963
1973
  }
1964
1974
  this.closed.emit();
1965
- (0, import_log9.log)("closed", {}, {
1966
- file: "memory-transport.ts",
1967
- line: 154,
1968
- scope: this,
1969
- callSite: (f, a) => f(...a)
1975
+ (0, import_log9.log)("closed", void 0, {
1976
+ F: __dxlog_file9,
1977
+ L: 151,
1978
+ S: this,
1979
+ C: (f, a) => f(...a)
1970
1980
  });
1971
1981
  }
1972
1982
  signal({ payload }) {
1973
1983
  (0, import_log9.log)("received signal", {
1974
1984
  payload
1975
1985
  }, {
1976
- file: "memory-transport.ts",
1977
- line: 158,
1978
- scope: this,
1979
- callSite: (f, a) => f(...a)
1986
+ F: __dxlog_file9,
1987
+ L: 155,
1988
+ S: this,
1989
+ C: (f, a) => f(...a)
1980
1990
  });
1981
1991
  if (!(payload == null ? void 0 : payload.transportId)) {
1982
1992
  return;
@@ -1991,16 +2001,16 @@ var _MemoryTransport = class {
1991
2001
  var MemoryTransport = _MemoryTransport;
1992
2002
  // TODO(burdon): Remove static properties (inject context into constructor).
1993
2003
  MemoryTransport._connections = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
1994
- __decorate4([
2004
+ _ts_decorate4([
1995
2005
  import_log9.logInfo
1996
2006
  ], MemoryTransport.prototype, "_instanceId", void 0);
1997
- __decorate4([
2007
+ _ts_decorate4([
1998
2008
  import_log9.logInfo
1999
2009
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
2000
2010
 
2001
2011
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
2002
- var import_node_assert10 = __toESM(require("node:assert"));
2003
2012
  var import_simple_peer = __toESM(require("simple-peer"));
2013
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
2004
2014
  var import_async8 = require("@dxos/async");
2005
2015
  var import_debug5 = require("@dxos/debug");
2006
2016
  var import_keys9 = require("@dxos/keys");
@@ -2015,6 +2025,7 @@ try {
2015
2025
  }
2016
2026
 
2017
2027
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
2028
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
2018
2029
  var WebRTCTransport = class {
2019
2030
  constructor(params) {
2020
2031
  var _a;
@@ -2027,16 +2038,16 @@ var WebRTCTransport = class {
2027
2038
  import_log10.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.begin({
2028
2039
  id: this._instanceId
2029
2040
  }), {
2030
- file: "webrtc-transport.ts",
2031
- line: 39,
2032
- scope: this,
2033
- callSite: (f, a) => f(...a)
2041
+ F: __dxlog_file10,
2042
+ L: 39,
2043
+ S: this,
2044
+ C: (f, a) => f(...a)
2034
2045
  });
2035
2046
  (0, import_log10.log)("created connection", params, {
2036
- file: "webrtc-transport.ts",
2037
- line: 40,
2038
- scope: this,
2039
- callSite: (f, a) => f(...a)
2047
+ F: __dxlog_file10,
2048
+ L: 40,
2049
+ S: this,
2050
+ C: (f, a) => f(...a)
2040
2051
  });
2041
2052
  this._peer = new import_simple_peer.default({
2042
2053
  initiator: this.params.initiator,
@@ -2045,10 +2056,10 @@ var WebRTCTransport = class {
2045
2056
  });
2046
2057
  this._peer.on("signal", async (data) => {
2047
2058
  (0, import_log10.log)("signal", data, {
2048
- file: "webrtc-transport.ts",
2049
- line: 48,
2050
- scope: this,
2051
- callSite: (f, a) => f(...a)
2059
+ F: __dxlog_file10,
2060
+ L: 48,
2061
+ S: this,
2062
+ C: (f, a) => f(...a)
2052
2063
  });
2053
2064
  await this.params.sendSignal({
2054
2065
  payload: {
@@ -2057,21 +2068,21 @@ var WebRTCTransport = class {
2057
2068
  });
2058
2069
  });
2059
2070
  this._peer.on("connect", () => {
2060
- (0, import_log10.log)("connected", {}, {
2061
- file: "webrtc-transport.ts",
2062
- line: 53,
2063
- scope: this,
2064
- callSite: (f, a) => f(...a)
2071
+ (0, import_log10.log)("connected", void 0, {
2072
+ F: __dxlog_file10,
2073
+ L: 53,
2074
+ S: this,
2075
+ C: (f, a) => f(...a)
2065
2076
  });
2066
2077
  this.params.stream.pipe(this._peer).pipe(this.params.stream);
2067
2078
  this.connected.emit();
2068
2079
  });
2069
2080
  this._peer.on("close", async () => {
2070
- (0, import_log10.log)("closed", {}, {
2071
- file: "webrtc-transport.ts",
2072
- line: 59,
2073
- scope: this,
2074
- callSite: (f, a) => f(...a)
2081
+ (0, import_log10.log)("closed", void 0, {
2082
+ F: __dxlog_file10,
2083
+ L: 59,
2084
+ S: this,
2085
+ C: (f, a) => f(...a)
2075
2086
  });
2076
2087
  await this._disconnectStreams();
2077
2088
  this.closed.emit();
@@ -2086,10 +2097,10 @@ var WebRTCTransport = class {
2086
2097
  config: this.params.webrtcConfig,
2087
2098
  stats
2088
2099
  }, {
2089
- file: "webrtc-transport.ts",
2090
- line: 71,
2091
- scope: this,
2092
- callSite: (f, a) => f(...a)
2100
+ F: __dxlog_file10,
2101
+ L: 71,
2102
+ S: this,
2103
+ C: (f, a) => f(...a)
2093
2104
  });
2094
2105
  });
2095
2106
  }
@@ -2100,35 +2111,35 @@ var WebRTCTransport = class {
2100
2111
  import_log10.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.end({
2101
2112
  id: this._instanceId
2102
2113
  }), {
2103
- file: "webrtc-transport.ts",
2104
- line: 81,
2105
- scope: this,
2106
- callSite: (f, a) => f(...a)
2114
+ F: __dxlog_file10,
2115
+ L: 81,
2116
+ S: this,
2117
+ C: (f, a) => f(...a)
2107
2118
  });
2108
2119
  }
2109
2120
  async destroy() {
2110
- (0, import_log10.log)("closing...", {}, {
2111
- file: "webrtc-transport.ts",
2112
- line: 85,
2113
- scope: this,
2114
- callSite: (f, a) => f(...a)
2121
+ (0, import_log10.log)("closing...", void 0, {
2122
+ F: __dxlog_file10,
2123
+ L: 85,
2124
+ S: this,
2125
+ C: (f, a) => f(...a)
2115
2126
  });
2116
2127
  this._closed = true;
2117
2128
  await this._disconnectStreams();
2118
2129
  this._peer.destroy();
2119
2130
  this.closed.emit();
2120
- (0, import_log10.log)("closed", {}, {
2121
- file: "webrtc-transport.ts",
2122
- line: 90,
2123
- scope: this,
2124
- callSite: (f, a) => f(...a)
2131
+ (0, import_log10.log)("closed", void 0, {
2132
+ F: __dxlog_file10,
2133
+ L: 90,
2134
+ S: this,
2135
+ C: (f, a) => f(...a)
2125
2136
  });
2126
2137
  }
2127
2138
  signal(signal) {
2128
2139
  if (this._closed) {
2129
2140
  return;
2130
2141
  }
2131
- (0, import_node_assert10.default)(signal.payload.data, "Signal message must contain signal data.");
2142
+ (0, import_tiny_invariant10.default)(signal.payload.data, "Signal message must contain signal data.");
2132
2143
  this._peer.signal(signal.payload.data);
2133
2144
  }
2134
2145
  async _disconnectStreams() {
@@ -2144,13 +2155,14 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
2144
2155
  });
2145
2156
 
2146
2157
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
2147
- var import_node_assert11 = __toESM(require("node:assert"));
2148
2158
  var import_node_stream2 = require("node:stream");
2159
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
2149
2160
  var import_codec_protobuf = require("@dxos/codec-protobuf");
2150
2161
  var import_keys10 = require("@dxos/keys");
2151
2162
  var import_log11 = require("@dxos/log");
2152
2163
  var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
2153
2164
  var import_util7 = require("@dxos/util");
2165
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
2154
2166
  var WebRTCTransportService = class {
2155
2167
  // prettier-ignore
2156
2168
  constructor(_webrtcConfig) {
@@ -2221,11 +2233,11 @@ var WebRTCTransportService = class {
2221
2233
  return rpcStream;
2222
2234
  }
2223
2235
  async sendSignal({ proxyId, signal }) {
2224
- (0, import_node_assert11.default)(this.transports.has(proxyId));
2236
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2225
2237
  await this.transports.get(proxyId).transport.signal(signal);
2226
2238
  }
2227
2239
  async sendData({ proxyId, payload }) {
2228
- (0, import_node_assert11.default)(this.transports.has(proxyId));
2240
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2229
2241
  await this.transports.get(proxyId).stream.push(payload);
2230
2242
  }
2231
2243
  async close({ proxyId }) {
@@ -2233,17 +2245,17 @@ var WebRTCTransportService = class {
2233
2245
  await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
2234
2246
  await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
2235
2247
  this.transports.delete(proxyId);
2236
- (0, import_log11.log)("Closed.", {}, {
2237
- file: "webrtc-transport-service.ts",
2238
- line: 109,
2239
- scope: this,
2240
- callSite: (f, a) => f(...a)
2248
+ (0, import_log11.log)("Closed.", void 0, {
2249
+ F: __dxlog_file11,
2250
+ L: 109,
2251
+ S: this,
2252
+ C: (f, a) => f(...a)
2241
2253
  });
2242
2254
  }
2243
2255
  };
2244
2256
 
2245
2257
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2246
- var import_node_assert12 = __toESM(require("node:assert"));
2258
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
2247
2259
  var import_async9 = require("@dxos/async");
2248
2260
  var import_context5 = require("@dxos/context");
2249
2261
  var import_debug6 = require("@dxos/debug");
@@ -2251,6 +2263,7 @@ var import_keys11 = require("@dxos/keys");
2251
2263
  var import_log12 = require("@dxos/log");
2252
2264
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
2253
2265
  var import_util8 = require("@dxos/util");
2266
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2254
2267
  var WebRTCTransportProxy = class {
2255
2268
  // prettier-ignore
2256
2269
  constructor(_params) {
@@ -2268,10 +2281,10 @@ var WebRTCTransportProxy = class {
2268
2281
  this._serviceStream.waitUntilReady().then(() => {
2269
2282
  this._serviceStream.subscribe(async (event) => {
2270
2283
  (0, import_log12.log)("WebRTCTransportProxy: event", event, {
2271
- file: "webrtc-transport-proxy.ts",
2272
- line: 50,
2273
- scope: this,
2274
- callSite: (f, a) => f(...a)
2284
+ F: __dxlog_file12,
2285
+ L: 50,
2286
+ S: this,
2287
+ C: (f, a) => f(...a)
2275
2288
  });
2276
2289
  if (event.connection) {
2277
2290
  await this._handleConnection(event.connection);
@@ -2288,11 +2301,11 @@ var WebRTCTransportProxy = class {
2288
2301
  payload: data
2289
2302
  });
2290
2303
  } catch (err) {
2291
- import_log12.log.catch(err, {}, {
2292
- file: "webrtc-transport-proxy.ts",
2293
- line: 67,
2294
- scope: this,
2295
- callSite: (f, a) => f(...a)
2304
+ import_log12.log.catch(err, void 0, {
2305
+ F: __dxlog_file12,
2306
+ L: 67,
2307
+ S: this,
2308
+ C: (f, a) => f(...a)
2296
2309
  });
2297
2310
  }
2298
2311
  };
@@ -2300,11 +2313,11 @@ var WebRTCTransportProxy = class {
2300
2313
  this._ctx.onDispose(() => {
2301
2314
  this._params.stream.off("data", dataListener);
2302
2315
  });
2303
- }, (error) => import_log12.log.catch(error, {}, {
2304
- file: "webrtc-transport-proxy.ts",
2305
- line: 73,
2306
- scope: this,
2307
- callSite: (f, a) => f(...a)
2316
+ }, (error) => import_log12.log.catch(error, void 0, {
2317
+ F: __dxlog_file12,
2318
+ L: 73,
2319
+ S: this,
2320
+ C: (f, a) => f(...a)
2308
2321
  }));
2309
2322
  }
2310
2323
  async _handleConnection(connectionEvent) {
@@ -2346,11 +2359,11 @@ var WebRTCTransportProxy = class {
2346
2359
  proxyId: this._proxyId
2347
2360
  });
2348
2361
  } catch (err) {
2349
- import_log12.log.catch(err, {}, {
2350
- file: "webrtc-transport-proxy.ts",
2351
- line: 124,
2352
- scope: this,
2353
- callSite: (f, a) => f(...a)
2362
+ import_log12.log.catch(err, void 0, {
2363
+ F: __dxlog_file12,
2364
+ L: 124,
2365
+ S: this,
2366
+ C: (f, a) => f(...a)
2354
2367
  });
2355
2368
  }
2356
2369
  this.closed.emit();
@@ -2382,7 +2395,7 @@ var WebRTCTransportProxyFactory = class {
2382
2395
  return this;
2383
2396
  }
2384
2397
  createTransport(options) {
2385
- (0, import_node_assert12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2398
+ (0, import_tiny_invariant12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2386
2399
  const transport = new WebRTCTransportProxy({
2387
2400
  ...options,
2388
2401
  bridgeService: this._bridgeService