@dxos/network-manager 0.1.52 → 0.1.53-main.01cbc6b

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