@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.
@@ -43,10 +43,10 @@ var import_messaging2 = require("@dxos/messaging");
43
43
  var import_protocols6 = require("@dxos/protocols");
44
44
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
45
45
  var import_rpc = require("@dxos/rpc");
46
- var import_util9 = require("@dxos/util");
46
+ var import_util10 = require("@dxos/util");
47
47
 
48
48
  // packages/core/mesh/network-manager/src/network-manager.ts
49
- var import_node_assert5 = __toESM(require("node:assert"));
49
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
50
50
  var import_async6 = require("@dxos/async");
51
51
  var import_keys7 = require("@dxos/keys");
52
52
  var import_log6 = require("@dxos/log");
@@ -62,7 +62,7 @@ var import_keys6 = require("@dxos/keys");
62
62
  var import_util4 = require("@dxos/util");
63
63
 
64
64
  // packages/core/mesh/network-manager/src/swarm/connection.ts
65
- var import_node_assert = __toESM(require("node:assert"));
65
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
66
66
  var import_async = require("@dxos/async");
67
67
  var import_context = require("@dxos/context");
68
68
  var import_debug = require("@dxos/debug");
@@ -70,7 +70,7 @@ var import_errors = require("@dxos/errors");
70
70
  var import_keys = require("@dxos/keys");
71
71
  var import_log = require("@dxos/log");
72
72
  var import_protocols = require("@dxos/protocols");
73
- var __decorate = function(decorators, target, key, desc) {
73
+ function _ts_decorate(decorators, target, key, desc) {
74
74
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
75
75
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
76
76
  r = Reflect.decorate(decorators, target, key, desc);
@@ -79,7 +79,8 @@ var __decorate = function(decorators, target, key, desc) {
79
79
  if (d = decorators[i])
80
80
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
81
81
  return c > 3 && r && Object.defineProperty(target, key, r), r;
82
- };
82
+ }
83
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
83
84
  var STARTING_SIGNALLING_DELAY = 10;
84
85
  var MAX_SIGNALLING_DELAY = 300;
85
86
  var ConnectionState;
@@ -152,29 +153,29 @@ var Connection = class {
152
153
  */
153
154
  // TODO(burdon): Make async?
154
155
  openConnection() {
155
- (0, import_node_assert.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
156
+ (0, import_tiny_invariant.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
156
157
  import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.begin({
157
158
  id: this._instanceId
158
159
  }), {
159
- file: "connection.ts",
160
- line: 115,
161
- scope: this,
162
- callSite: (f, a) => f(...a)
160
+ F: __dxlog_file,
161
+ L: 115,
162
+ S: this,
163
+ C: (f, a) => f(...a)
163
164
  });
164
165
  this._changeState(ConnectionState.CONNECTING);
165
166
  this._protocol.initialize().catch((err) => {
166
167
  this.errors.raise(err);
167
168
  });
168
169
  this._protocol.stream.on("close", () => {
169
- (0, import_log.log)("protocol stream closed", {}, {
170
- file: "connection.ts",
171
- line: 126,
172
- scope: this,
173
- callSite: (f, a) => f(...a)
170
+ (0, import_log.log)("protocol stream closed", void 0, {
171
+ F: __dxlog_file,
172
+ L: 126,
173
+ S: this,
174
+ C: (f, a) => f(...a)
174
175
  });
175
176
  this.close().catch((err) => this.errors.raise(err));
176
177
  });
177
- (0, import_node_assert.default)(!this._transport);
178
+ (0, import_tiny_invariant.default)(!this._transport);
178
179
  this._transport = this._transportFactory.createTransport({
179
180
  initiator: this.initiator,
180
181
  stream: this._protocol.stream,
@@ -199,10 +200,10 @@ var Connection = class {
199
200
  import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.end({
200
201
  id: this._instanceId
201
202
  }), {
202
- file: "connection.ts",
203
- line: 159,
204
- scope: this,
205
- callSite: (f, a) => f(...a)
203
+ F: __dxlog_file,
204
+ L: 159,
205
+ S: this,
206
+ C: (f, a) => f(...a)
206
207
  });
207
208
  }
208
209
  async close() {
@@ -215,38 +216,38 @@ var Connection = class {
215
216
  (0, import_log.log)("closing...", {
216
217
  peerId: this.ownId
217
218
  }, {
218
- file: "connection.ts",
219
- line: 171,
220
- scope: this,
221
- callSite: (f, a) => f(...a)
219
+ F: __dxlog_file,
220
+ L: 171,
221
+ S: this,
222
+ C: (f, a) => f(...a)
222
223
  });
223
224
  try {
224
225
  await this._protocol.destroy();
225
226
  } catch (err) {
226
- import_log.log.catch(err, {}, {
227
- file: "connection.ts",
228
- line: 177,
229
- scope: this,
230
- callSite: (f, a) => f(...a)
227
+ import_log.log.catch(err, void 0, {
228
+ F: __dxlog_file,
229
+ L: 177,
230
+ S: this,
231
+ C: (f, a) => f(...a)
231
232
  });
232
233
  }
233
234
  try {
234
235
  await ((_a2 = this._transport) == null ? void 0 : _a2.destroy());
235
- } catch (err1) {
236
- import_log.log.catch(err1, {}, {
237
- file: "connection.ts",
238
- line: 184,
239
- scope: this,
240
- callSite: (f, a) => f(...a)
236
+ } catch (err) {
237
+ import_log.log.catch(err, void 0, {
238
+ F: __dxlog_file,
239
+ L: 184,
240
+ S: this,
241
+ C: (f, a) => f(...a)
241
242
  });
242
243
  }
243
244
  (0, import_log.log)("closed", {
244
245
  peerId: this.ownId
245
246
  }, {
246
- file: "connection.ts",
247
- line: 187,
248
- scope: this,
249
- callSite: (f, a) => f(...a)
247
+ F: __dxlog_file,
248
+ L: 187,
249
+ S: this,
250
+ C: (f, a) => f(...a)
250
251
  });
251
252
  this._changeState(ConnectionState.CLOSED);
252
253
  }
@@ -283,10 +284,10 @@ var Connection = class {
283
284
  import_log.log.warn("Signal failed", {
284
285
  err
285
286
  }, {
286
- file: "connection.ts",
287
- line: 221,
288
- scope: this,
289
- callSite: (f, a) => f(...a)
287
+ F: __dxlog_file,
288
+ L: 221,
289
+ S: this,
290
+ C: (f, a) => f(...a)
290
291
  });
291
292
  await this.close();
292
293
  }
@@ -296,19 +297,19 @@ var Connection = class {
296
297
  */
297
298
  async signal(msg) {
298
299
  var _a2, _b, _c;
299
- (0, import_node_assert.default)(msg.sessionId);
300
+ (0, import_tiny_invariant.default)(msg.sessionId);
300
301
  if (!msg.sessionId.equals(this.sessionId)) {
301
- (0, import_log.log)("dropping signal for incorrect session id", {}, {
302
- file: "connection.ts",
303
- line: 232,
304
- scope: this,
305
- callSite: (f, a) => f(...a)
302
+ (0, import_log.log)("dropping signal for incorrect session id", void 0, {
303
+ F: __dxlog_file,
304
+ L: 232,
305
+ S: this,
306
+ C: (f, a) => f(...a)
306
307
  });
307
308
  return;
308
309
  }
309
- (0, import_node_assert.default)(msg.data.signal || msg.data.signalBatch);
310
- (0, import_node_assert.default)((_a2 = msg.author) == null ? void 0 : _a2.equals(this.remoteId));
311
- (0, import_node_assert.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
310
+ (0, import_tiny_invariant.default)(msg.data.signal || msg.data.signalBatch);
311
+ (0, import_tiny_invariant.default)((_a2 = msg.author) == null ? void 0 : _a2.equals(this.remoteId));
312
+ (0, import_tiny_invariant.default)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
312
313
  const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
313
314
  msg.data.signal
314
315
  ];
@@ -322,23 +323,23 @@ var Connection = class {
322
323
  remoteId: this.remoteId,
323
324
  msg: msg.data
324
325
  }, {
325
- file: "connection.ts",
326
- line: 246,
327
- scope: this,
328
- callSite: (f, a) => f(...a)
326
+ F: __dxlog_file,
327
+ L: 246,
328
+ S: this,
329
+ C: (f, a) => f(...a)
329
330
  });
330
331
  this._incomingSignalBuffer.push(signal);
331
332
  } else {
332
- (0, import_node_assert.default)(this._transport, "Connection not ready to accept signals.");
333
+ (0, import_tiny_invariant.default)(this._transport, "Connection not ready to accept signals.");
333
334
  (0, import_log.log)("received signal", {
334
335
  peerId: this.ownId,
335
336
  remoteId: this.remoteId,
336
337
  msg: msg.data
337
338
  }, {
338
- file: "connection.ts",
339
- line: 250,
340
- scope: this,
341
- callSite: (f, a) => f(...a)
339
+ F: __dxlog_file,
340
+ L: 250,
341
+ S: this,
342
+ C: (f, a) => f(...a)
342
343
  });
343
344
  await this._transport.signal(signal);
344
345
  }
@@ -350,22 +351,22 @@ var Connection = class {
350
351
  too: state,
351
352
  peerId: this.ownId
352
353
  }, {
353
- file: "connection.ts",
354
- line: 257,
355
- scope: this,
356
- callSite: (f, a) => f(...a)
354
+ F: __dxlog_file,
355
+ L: 257,
356
+ S: this,
357
+ C: (f, a) => f(...a)
357
358
  });
358
- (0, import_node_assert.default)(state !== this._state, "Already in this state.");
359
+ (0, import_tiny_invariant.default)(state !== this._state, "Already in this state.");
359
360
  this._state = state;
360
361
  this.stateChanged.emit(state);
361
362
  }
362
363
  };
363
- __decorate([
364
+ _ts_decorate([
364
365
  import_async.synchronized
365
366
  ], Connection.prototype, "close", null);
366
367
 
367
368
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
368
- var import_node_assert4 = __toESM(require("node:assert"));
369
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
369
370
  var import_async3 = require("@dxos/async");
370
371
  var import_context4 = require("@dxos/context");
371
372
  var import_debug2 = require("@dxos/debug");
@@ -375,12 +376,13 @@ var import_protocols3 = require("@dxos/protocols");
375
376
  var import_util2 = require("@dxos/util");
376
377
 
377
378
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
378
- var import_node_assert2 = __toESM(require("node:assert"));
379
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
379
380
  var import_context2 = require("@dxos/context");
380
381
  var import_keys2 = require("@dxos/keys");
381
382
  var import_log2 = require("@dxos/log");
382
383
  var import_protocols2 = require("@dxos/protocols");
383
384
  var import_util = require("@dxos/util");
385
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
384
386
  var SwarmMessenger = class {
385
387
  constructor({ sendMessage, onSignal, onOffer, topic }) {
386
388
  this._ctx = new import_context2.Context();
@@ -404,10 +406,10 @@ var SwarmMessenger = class {
404
406
  to: recipient,
405
407
  msg: message
406
408
  }, {
407
- file: "swarm-messenger.ts",
408
- line: 68,
409
- scope: this,
410
- callSite: (f, a) => f(...a)
409
+ F: __dxlog_file2,
410
+ L: 68,
411
+ S: this,
412
+ C: (f, a) => f(...a)
411
413
  });
412
414
  if ((_a2 = message.data) == null ? void 0 : _a2.offer) {
413
415
  await this._handleOffer({
@@ -433,16 +435,16 @@ var SwarmMessenger = class {
433
435
  import_log2.log.warn("unknown message", {
434
436
  message
435
437
  }, {
436
- file: "swarm-messenger.ts",
437
- line: 79,
438
- scope: this,
439
- callSite: (f, a) => f(...a)
438
+ F: __dxlog_file2,
439
+ L: 79,
440
+ S: this,
441
+ C: (f, a) => f(...a)
440
442
  });
441
443
  }
442
444
  }
443
445
  async signal(message) {
444
446
  var _a2, _b;
445
- (0, import_node_assert2.default)(((_a2 = message.data) == null ? void 0 : _a2.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
447
+ (0, import_tiny_invariant2.default)(((_a2 = message.data) == null ? void 0 : _a2.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
446
448
  await this._sendReliableMessage({
447
449
  author: message.author,
448
450
  recipient: message.recipient,
@@ -477,10 +479,10 @@ var SwarmMessenger = class {
477
479
  to: recipient,
478
480
  msg: networkMessage
479
481
  }, {
480
- file: "swarm-messenger.ts",
481
- line: 122,
482
- scope: this,
483
- callSite: (f, a) => f(...a)
482
+ F: __dxlog_file2,
483
+ L: 122,
484
+ S: this,
485
+ C: (f, a) => f(...a)
484
486
  });
485
487
  await this._sendMessage({
486
488
  author,
@@ -493,24 +495,24 @@ var SwarmMessenger = class {
493
495
  }
494
496
  async _resolveAnswers(message) {
495
497
  var _a2, _b, _c;
496
- (0, import_node_assert2.default)((_b = (_a2 = message.data) == null ? void 0 : _a2.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
498
+ (0, import_tiny_invariant2.default)((_b = (_a2 = message.data) == null ? void 0 : _a2.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
497
499
  const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
498
500
  if (offerRecord) {
499
501
  this._offerRecords.delete(message.data.answer.offerMessageId);
500
- (0, import_node_assert2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
502
+ (0, import_tiny_invariant2.default)((_c = message.data) == null ? void 0 : _c.answer, "No answer");
501
503
  (0, import_log2.log)("resolving", {
502
504
  answer: message.data.answer
503
505
  }, {
504
- file: "swarm-messenger.ts",
505
- line: 139,
506
- scope: this,
507
- callSite: (f, a) => f(...a)
506
+ F: __dxlog_file2,
507
+ L: 139,
508
+ S: this,
509
+ C: (f, a) => f(...a)
508
510
  });
509
511
  offerRecord.resolve(message.data.answer);
510
512
  }
511
513
  }
512
514
  async _handleOffer({ author, recipient, message }) {
513
- (0, import_node_assert2.default)(message.data.offer, "No offer");
515
+ (0, import_tiny_invariant2.default)(message.data.offer, "No offer");
514
516
  const offerMessage = {
515
517
  author,
516
518
  recipient,
@@ -537,16 +539,16 @@ var SwarmMessenger = class {
537
539
  import_log2.log.warn("error sending answer", {
538
540
  err
539
541
  }, {
540
- file: "swarm-messenger.ts",
541
- line: 173,
542
- scope: this,
543
- callSite: (f, a) => f(...a)
542
+ F: __dxlog_file2,
543
+ L: 173,
544
+ S: this,
545
+ C: (f, a) => f(...a)
544
546
  });
545
547
  }
546
548
  }
547
549
  async _handleSignal({ author, recipient, message }) {
548
- (0, import_node_assert2.default)(message.messageId);
549
- (0, import_node_assert2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
550
+ (0, import_tiny_invariant2.default)(message.messageId);
551
+ (0, import_tiny_invariant2.default)(message.data.signal || message.data.signalBatch, "Invalid message");
550
552
  const signalMessage = {
551
553
  author,
552
554
  recipient,
@@ -561,12 +563,12 @@ var SwarmMessenger = class {
561
563
  };
562
564
 
563
565
  // packages/core/mesh/network-manager/src/swarm/peer.ts
564
- var import_node_assert3 = __toESM(require("node:assert"));
566
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
565
567
  var import_async2 = require("@dxos/async");
566
568
  var import_context3 = require("@dxos/context");
567
569
  var import_keys3 = require("@dxos/keys");
568
570
  var import_log3 = require("@dxos/log");
569
- var __decorate2 = function(decorators, target, key, desc) {
571
+ function _ts_decorate2(decorators, target, key, desc) {
570
572
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
571
573
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
572
574
  r = Reflect.decorate(decorators, target, key, desc);
@@ -575,7 +577,8 @@ var __decorate2 = function(decorators, target, key, desc) {
575
577
  if (d = decorators[i])
576
578
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
577
579
  return c > 3 && r && Object.defineProperty(target, key, r), r;
578
- };
580
+ }
581
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
579
582
  var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
580
583
  var Peer = class {
581
584
  constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _callbacks) {
@@ -604,10 +607,10 @@ var Peer = class {
604
607
  topic: this.topic,
605
608
  peerId: this.localPeerId
606
609
  }, {
607
- file: "peer.ts",
608
- line: 105,
609
- scope: this,
610
- callSite: (f, a) => f(...a)
610
+ F: __dxlog_file3,
611
+ L: 105,
612
+ S: this,
613
+ C: (f, a) => f(...a)
611
614
  });
612
615
  if (this.connection) {
613
616
  await this.closeConnection();
@@ -620,7 +623,7 @@ var Peer = class {
620
623
  }
621
624
  if (await this._callbacks.onOffer(remoteId)) {
622
625
  if (!this.connection) {
623
- (0, import_node_assert3.default)(message.sessionId);
626
+ (0, import_tiny_invariant3.default)(message.sessionId);
624
627
  const connection = this._createConnection(false, message.sessionId);
625
628
  try {
626
629
  connection.openConnection();
@@ -631,10 +634,10 @@ var Peer = class {
631
634
  remoteId: this.id,
632
635
  err
633
636
  }, {
634
- file: "peer.ts",
635
- line: 129,
636
- scope: this,
637
- callSite: (f, a) => f(...a)
637
+ F: __dxlog_file3,
638
+ L: 129,
639
+ S: this,
640
+ C: (f, a) => f(...a)
638
641
  });
639
642
  await this.closeConnection();
640
643
  }
@@ -651,8 +654,8 @@ var Peer = class {
651
654
  * Initiate a connection to the remote peer.
652
655
  */
653
656
  async initiateConnection() {
654
- (0, import_node_assert3.default)(!this.initiating, "Initiation in progress.");
655
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
657
+ (0, import_tiny_invariant3.default)(!this.initiating, "Initiation in progress.");
658
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
656
659
  const sessionId = import_keys3.PublicKey.random();
657
660
  (0, import_log3.log)("initiating...", {
658
661
  id: this.id,
@@ -660,10 +663,10 @@ var Peer = class {
660
663
  peerId: this.id,
661
664
  sessionId
662
665
  }, {
663
- file: "peer.ts",
664
- line: 147,
665
- scope: this,
666
- callSite: (f, a) => f(...a)
666
+ F: __dxlog_file3,
667
+ L: 147,
668
+ S: this,
669
+ C: (f, a) => f(...a)
667
670
  });
668
671
  const connection = this._createConnection(true, sessionId);
669
672
  this.initiating = true;
@@ -683,17 +686,17 @@ var Peer = class {
683
686
  ownId: this.localPeerId,
684
687
  remoteId: this.id
685
688
  }, {
686
- file: "peer.ts",
687
- line: 159,
688
- scope: this,
689
- callSite: (f, a) => f(...a)
689
+ F: __dxlog_file3,
690
+ L: 159,
691
+ S: this,
692
+ C: (f, a) => f(...a)
690
693
  });
691
694
  if (connection.state !== ConnectionState.INITIAL) {
692
- (0, import_log3.log)("ignoring response", {}, {
693
- file: "peer.ts",
694
- line: 161,
695
- scope: this,
696
- callSite: (f, a) => f(...a)
695
+ (0, import_log3.log)("ignoring response", void 0, {
696
+ F: __dxlog_file3,
697
+ L: 161,
698
+ S: this,
699
+ C: (f, a) => f(...a)
697
700
  });
698
701
  return;
699
702
  }
@@ -710,10 +713,10 @@ var Peer = class {
710
713
  peerId: this.localPeerId,
711
714
  remoteId: this.id
712
715
  }, {
713
- file: "peer.ts",
714
- line: 172,
715
- scope: this,
716
- callSite: (f, a) => f(...a)
716
+ F: __dxlog_file3,
717
+ L: 172,
718
+ S: this,
719
+ C: (f, a) => f(...a)
717
720
  });
718
721
  await this.closeConnection();
719
722
  throw err;
@@ -734,12 +737,12 @@ var Peer = class {
734
737
  initiator,
735
738
  sessionId
736
739
  }, {
737
- file: "peer.ts",
738
- line: 186,
739
- scope: this,
740
- callSite: (f, a) => f(...a)
740
+ F: __dxlog_file3,
741
+ L: 186,
742
+ S: this,
743
+ C: (f, a) => f(...a)
741
744
  });
742
- (0, import_node_assert3.default)(!this.connection, "Already connected.");
745
+ (0, import_tiny_invariant3.default)(!this.connection, "Already connected.");
743
746
  const connection = new Connection(
744
747
  this.topic,
745
748
  this.localPeerId,
@@ -774,12 +777,12 @@ var Peer = class {
774
777
  remoteId: this.id,
775
778
  initiator
776
779
  }, {
777
- file: "peer.ts",
778
- line: 221,
779
- scope: this,
780
- callSite: (f, a) => f(...a)
780
+ F: __dxlog_file3,
781
+ L: 221,
782
+ S: this,
783
+ C: (f, a) => f(...a)
781
784
  });
782
- (0, import_node_assert3.default)(this.connection === connection, "Connection mismatch (race condition).");
785
+ (0, import_tiny_invariant3.default)(this.connection === connection, "Connection mismatch (race condition).");
783
786
  if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
784
787
  this._availableAfter = 0;
785
788
  } else {
@@ -804,10 +807,10 @@ var Peer = class {
804
807
  initiator,
805
808
  err
806
809
  }, {
807
- file: "peer.ts",
808
- line: 249,
809
- scope: this,
810
- callSite: (f, a) => f(...a)
810
+ F: __dxlog_file3,
811
+ L: 249,
812
+ S: this,
813
+ C: (f, a) => f(...a)
811
814
  });
812
815
  void this.closeConnection();
813
816
  });
@@ -823,20 +826,20 @@ var Peer = class {
823
826
  peerId: this.id,
824
827
  sessionId: connection.sessionId
825
828
  }, {
826
- file: "peer.ts",
827
- line: 265,
828
- scope: this,
829
- callSite: (f, a) => f(...a)
829
+ F: __dxlog_file3,
830
+ L: 265,
831
+ S: this,
832
+ C: (f, a) => f(...a)
830
833
  });
831
834
  await connection.close();
832
835
  (0, import_log3.log)("closed", {
833
836
  peerId: this.id,
834
837
  sessionId: connection.sessionId
835
838
  }, {
836
- file: "peer.ts",
837
- line: 271,
838
- scope: this,
839
- callSite: (f, a) => f(...a)
839
+ F: __dxlog_file3,
840
+ L: 271,
841
+ S: this,
842
+ C: (f, a) => f(...a)
840
843
  });
841
844
  }
842
845
  async onSignal(message) {
@@ -844,10 +847,10 @@ var Peer = class {
844
847
  (0, import_log3.log)("dropping signal message for non-existent connection", {
845
848
  message
846
849
  }, {
847
- file: "peer.ts",
848
- line: 276,
849
- scope: this,
850
- callSite: (f, a) => f(...a)
850
+ F: __dxlog_file3,
851
+ L: 276,
852
+ S: this,
853
+ C: (f, a) => f(...a)
851
854
  });
852
855
  return;
853
856
  }
@@ -860,15 +863,15 @@ var Peer = class {
860
863
  peerId: this.id,
861
864
  topic: this.topic
862
865
  }, {
863
- file: "peer.ts",
864
- line: 285,
865
- scope: this,
866
- callSite: (f, a) => f(...a)
866
+ F: __dxlog_file3,
867
+ L: 285,
868
+ S: this,
869
+ C: (f, a) => f(...a)
867
870
  });
868
871
  await ((_a2 = this == null ? void 0 : this.connection) == null ? void 0 : _a2.close());
869
872
  }
870
873
  };
871
- __decorate2([
874
+ _ts_decorate2([
872
875
  import_async2.synchronized
873
876
  ], Peer.prototype, "destroy", null);
874
877
  var increaseInterval = (interval) => {
@@ -885,7 +888,7 @@ var increaseInterval = (interval) => {
885
888
  };
886
889
 
887
890
  // packages/core/mesh/network-manager/src/swarm/swarm.ts
888
- var __decorate3 = function(decorators, target, key, desc) {
891
+ function _ts_decorate3(decorators, target, key, desc) {
889
892
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
890
893
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
891
894
  r = Reflect.decorate(decorators, target, key, desc);
@@ -894,7 +897,8 @@ var __decorate3 = function(decorators, target, key, desc) {
894
897
  if (d = decorators[i])
895
898
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
896
899
  return c > 3 && r && Object.defineProperty(target, key, r), r;
897
- };
900
+ }
901
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
898
902
  var INITIATION_DELAY = 100;
899
903
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
900
904
  var Swarm = class {
@@ -911,11 +915,11 @@ var Swarm = class {
911
915
  this._peers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
912
916
  this._ctx = new import_context4.Context();
913
917
  this._listeningHandle = void 0;
918
+ this._instanceId = import_keys4.PublicKey.random().toHex();
914
919
  this.connectionAdded = new import_async3.Event();
915
920
  this.disconnected = new import_async3.Event();
916
921
  this.connected = new import_async3.Event();
917
922
  this.errors = new import_debug2.ErrorStream();
918
- this._instanceId = import_keys4.PublicKey.random().toHex();
919
923
  import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols3.trace.begin({
920
924
  id: this._instanceId,
921
925
  data: {
@@ -923,18 +927,18 @@ var Swarm = class {
923
927
  peerId: this._ownPeerId.toHex()
924
928
  }
925
929
  }), {
926
- file: "swarm.ts",
927
- line: 86,
928
- scope: this,
929
- callSite: (f, a) => f(...a)
930
+ F: __dxlog_file4,
931
+ L: 86,
932
+ S: this,
933
+ C: (f, a) => f(...a)
930
934
  });
931
935
  (0, import_log4.log)("creating swarm", {
932
936
  peerId: _ownPeerId
933
937
  }, {
934
- file: "swarm.ts",
935
- line: 90,
936
- scope: this,
937
- callSite: (f, a) => f(...a)
938
+ F: __dxlog_file4,
939
+ L: 90,
940
+ S: this,
941
+ C: (f, a) => f(...a)
938
942
  });
939
943
  _topology.init(this._getSwarmController());
940
944
  this._swarmMessenger = new SwarmMessenger({
@@ -946,10 +950,10 @@ var Swarm = class {
946
950
  import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols3.trace.end({
947
951
  id: this._instanceId
948
952
  }), {
949
- file: "swarm.ts",
950
- line: 99,
951
- scope: this,
952
- callSite: (f, a) => f(...a)
953
+ F: __dxlog_file4,
954
+ L: 99,
955
+ S: this,
956
+ C: (f, a) => f(...a)
953
957
  });
954
958
  }
955
959
  get connections() {
@@ -968,7 +972,7 @@ var Swarm = class {
968
972
  return this._topic;
969
973
  }
970
974
  async open() {
971
- (0, import_node_assert4.default)(!this._listeningHandle);
975
+ (0, import_tiny_invariant4.default)(!this._listeningHandle);
972
976
  this._listeningHandle = await this._messenger.listen({
973
977
  peerId: this._ownPeerId,
974
978
  payloadType: "dxos.mesh.swarm.SwarmMessage",
@@ -976,36 +980,36 @@ var Swarm = class {
976
980
  await this._swarmMessenger.receiveMessage(message).catch((err) => import_log4.log.warn("Error while receiving message", {
977
981
  err
978
982
  }, {
979
- file: "swarm.ts",
980
- line: 133,
981
- scope: this,
982
- callSite: (f, a) => f(...a)
983
+ F: __dxlog_file4,
984
+ L: 133,
985
+ S: this,
986
+ C: (f, a) => f(...a)
983
987
  }));
984
988
  }
985
989
  });
986
990
  }
987
991
  async destroy() {
988
992
  var _a2;
989
- (0, import_log4.log)("destroying...", {}, {
990
- file: "swarm.ts",
991
- line: 139,
992
- scope: this,
993
- callSite: (f, a) => f(...a)
993
+ (0, import_log4.log)("destroying...", void 0, {
994
+ F: __dxlog_file4,
995
+ L: 139,
996
+ S: this,
997
+ C: (f, a) => f(...a)
994
998
  });
995
999
  await ((_a2 = this._listeningHandle) == null ? void 0 : _a2.unsubscribe());
996
1000
  this._listeningHandle = void 0;
997
1001
  await this._ctx.dispose();
998
1002
  await this._topology.destroy();
999
1003
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
1000
- (0, import_log4.log)("destroyed", {}, {
1001
- file: "swarm.ts",
1002
- line: 146,
1003
- scope: this,
1004
- callSite: (f, a) => f(...a)
1004
+ (0, import_log4.log)("destroyed", void 0, {
1005
+ F: __dxlog_file4,
1006
+ L: 146,
1007
+ S: this,
1008
+ C: (f, a) => f(...a)
1005
1009
  });
1006
1010
  }
1007
1011
  async setTopology(topology) {
1008
- (0, import_node_assert4.default)(!this._ctx.disposed, "Swarm is offline");
1012
+ (0, import_tiny_invariant4.default)(!this._ctx.disposed, "Swarm is offline");
1009
1013
  if (topology === this._topology) {
1010
1014
  return;
1011
1015
  }
@@ -1013,10 +1017,10 @@ var Swarm = class {
1013
1017
  previous: getClassName(this._topology),
1014
1018
  topology: getClassName(topology)
1015
1019
  }, {
1016
- file: "swarm.ts",
1017
- line: 154,
1018
- scope: this,
1019
- callSite: (f, a) => f(...a)
1020
+ F: __dxlog_file4,
1021
+ L: 154,
1022
+ S: this,
1023
+ C: (f, a) => f(...a)
1020
1024
  });
1021
1025
  await this._topology.destroy();
1022
1026
  this._topology = topology;
@@ -1028,17 +1032,17 @@ var Swarm = class {
1028
1032
  (0, import_log4.log)("swarm event", {
1029
1033
  swarmEvent
1030
1034
  }, {
1031
- file: "swarm.ts",
1032
- line: 167,
1033
- scope: this,
1034
- callSite: (f, a) => f(...a)
1035
+ F: __dxlog_file4,
1036
+ L: 167,
1037
+ S: this,
1038
+ C: (f, a) => f(...a)
1035
1039
  });
1036
1040
  if (this._ctx.disposed) {
1037
- (0, import_log4.log)("swarm event ignored for disposed swarm", {}, {
1038
- file: "swarm.ts",
1039
- line: 170,
1040
- scope: this,
1041
- callSite: (f, a) => f(...a)
1041
+ (0, import_log4.log)("swarm event ignored for disposed swarm", void 0, {
1042
+ F: __dxlog_file4,
1043
+ L: 170,
1044
+ S: this,
1045
+ C: (f, a) => f(...a)
1042
1046
  });
1043
1047
  return;
1044
1048
  }
@@ -1047,25 +1051,25 @@ var Swarm = class {
1047
1051
  (0, import_log4.log)("new peer", {
1048
1052
  peerId
1049
1053
  }, {
1050
- file: "swarm.ts",
1051
- line: 176,
1052
- scope: this,
1053
- callSite: (f, a) => f(...a)
1054
+ F: __dxlog_file4,
1055
+ L: 176,
1056
+ S: this,
1057
+ C: (f, a) => f(...a)
1054
1058
  });
1055
1059
  if (!peerId.equals(this._ownPeerId)) {
1056
1060
  const peer = this._getOrCreatePeer(peerId);
1057
1061
  peer.advertizing = true;
1058
1062
  }
1059
1063
  } else if (swarmEvent.peerLeft) {
1060
- const peer1 = this._peers.get(import_keys4.PublicKey.from(swarmEvent.peerLeft.peer));
1061
- if (peer1) {
1062
- peer1.advertizing = false;
1063
- if (((_a2 = peer1.connection) == null ? void 0 : _a2.state) !== ConnectionState.CONNECTED) {
1064
- void this._destroyPeer(peer1.id).catch((err) => import_log4.log.catch(err, {}, {
1065
- file: "swarm.ts",
1066
- line: 187,
1067
- scope: this,
1068
- callSite: (f, a) => f(...a)
1064
+ const peer = this._peers.get(import_keys4.PublicKey.from(swarmEvent.peerLeft.peer));
1065
+ if (peer) {
1066
+ peer.advertizing = false;
1067
+ if (((_a2 = peer.connection) == null ? void 0 : _a2.state) !== ConnectionState.CONNECTED) {
1068
+ void this._destroyPeer(peer.id).catch((err) => import_log4.log.catch(err, void 0, {
1069
+ F: __dxlog_file4,
1070
+ L: 187,
1071
+ S: this,
1072
+ C: (f, a) => f(...a)
1069
1073
  }));
1070
1074
  }
1071
1075
  }
@@ -1077,31 +1081,31 @@ var Swarm = class {
1077
1081
  (0, import_log4.log)("offer", {
1078
1082
  message
1079
1083
  }, {
1080
- file: "swarm.ts",
1081
- line: 197,
1082
- scope: this,
1083
- callSite: (f, a) => f(...a)
1084
+ F: __dxlog_file4,
1085
+ L: 197,
1086
+ S: this,
1087
+ C: (f, a) => f(...a)
1084
1088
  });
1085
1089
  if (this._ctx.disposed) {
1086
- (0, import_log4.log)("ignored for disposed swarm", {}, {
1087
- file: "swarm.ts",
1088
- line: 199,
1089
- scope: this,
1090
- callSite: (f, a) => f(...a)
1090
+ (0, import_log4.log)("ignored for disposed swarm", void 0, {
1091
+ F: __dxlog_file4,
1092
+ L: 199,
1093
+ S: this,
1094
+ C: (f, a) => f(...a)
1091
1095
  });
1092
1096
  return {
1093
1097
  accept: false
1094
1098
  };
1095
1099
  }
1096
- (0, import_node_assert4.default)(message.author);
1100
+ (0, import_tiny_invariant4.default)(message.author);
1097
1101
  if (!((_a2 = message.recipient) == null ? void 0 : _a2.equals(this._ownPeerId))) {
1098
1102
  (0, import_log4.log)("rejecting offer with incorrect peerId", {
1099
1103
  message
1100
1104
  }, {
1101
- file: "swarm.ts",
1102
- line: 206,
1103
- scope: this,
1104
- callSite: (f, a) => f(...a)
1105
+ F: __dxlog_file4,
1106
+ L: 206,
1107
+ S: this,
1108
+ C: (f, a) => f(...a)
1105
1109
  });
1106
1110
  return {
1107
1111
  accept: false
@@ -1111,10 +1115,10 @@ var Swarm = class {
1111
1115
  (0, import_log4.log)("rejecting offer with incorrect topic", {
1112
1116
  message
1113
1117
  }, {
1114
- file: "swarm.ts",
1115
- line: 210,
1116
- scope: this,
1117
- callSite: (f, a) => f(...a)
1118
+ F: __dxlog_file4,
1119
+ L: 210,
1120
+ S: this,
1121
+ C: (f, a) => f(...a)
1118
1122
  });
1119
1123
  return {
1120
1124
  accept: false
@@ -1130,23 +1134,23 @@ var Swarm = class {
1130
1134
  (0, import_log4.log)("signal", {
1131
1135
  message
1132
1136
  }, {
1133
- file: "swarm.ts",
1134
- line: 222,
1135
- scope: this,
1136
- callSite: (f, a) => f(...a)
1137
+ F: __dxlog_file4,
1138
+ L: 222,
1139
+ S: this,
1140
+ C: (f, a) => f(...a)
1137
1141
  });
1138
1142
  if (this._ctx.disposed) {
1139
- import_log4.log.info("ignored for offline swarm", {}, {
1140
- file: "swarm.ts",
1141
- line: 224,
1142
- scope: this,
1143
- callSite: (f, a) => f(...a)
1143
+ import_log4.log.info("ignored for offline swarm", void 0, {
1144
+ F: __dxlog_file4,
1145
+ L: 224,
1146
+ S: this,
1147
+ C: (f, a) => f(...a)
1144
1148
  });
1145
1149
  return;
1146
1150
  }
1147
- (0, import_node_assert4.default)((_a2 = message.recipient) == null ? void 0 : _a2.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1148
- (0, import_node_assert4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1149
- (0, import_node_assert4.default)(message.author);
1151
+ (0, import_tiny_invariant4.default)((_a2 = message.recipient) == null ? void 0 : _a2.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
1152
+ (0, import_tiny_invariant4.default)((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
1153
+ (0, import_tiny_invariant4.default)(message.author);
1150
1154
  const peer = this._getOrCreatePeer(message.author);
1151
1155
  await peer.onSignal(message);
1152
1156
  }
@@ -1198,7 +1202,7 @@ var Swarm = class {
1198
1202
  return peer;
1199
1203
  }
1200
1204
  async _destroyPeer(peerId) {
1201
- (0, import_node_assert4.default)(this._peers.has(peerId));
1205
+ (0, import_tiny_invariant4.default)(this._peers.has(peerId));
1202
1206
  await this._peers.get(peerId).destroy();
1203
1207
  this._peers.delete(peerId);
1204
1208
  }
@@ -1218,10 +1222,10 @@ var Swarm = class {
1218
1222
  await this._initiateConnection(peer);
1219
1223
  } catch (err) {
1220
1224
  (0, import_log4.log)("initiation error", err, {
1221
- file: "swarm.ts",
1222
- line: 327,
1223
- scope: this,
1224
- callSite: (f, a) => f(...a)
1225
+ F: __dxlog_file4,
1226
+ L: 327,
1227
+ S: this,
1228
+ C: (f, a) => f(...a)
1225
1229
  });
1226
1230
  }
1227
1231
  });
@@ -1246,10 +1250,10 @@ var Swarm = class {
1246
1250
  (0, import_log4.log)("initiation delay", {
1247
1251
  remoteId
1248
1252
  }, {
1249
- file: "swarm.ts",
1250
- line: 354,
1251
- scope: this,
1252
- callSite: (f, a) => f(...a)
1253
+ F: __dxlog_file4,
1254
+ L: 354,
1255
+ S: this,
1256
+ C: (f, a) => f(...a)
1253
1257
  });
1254
1258
  await (0, import_async3.sleep)(INITIATION_DELAY);
1255
1259
  }
@@ -1263,20 +1267,20 @@ var Swarm = class {
1263
1267
  (0, import_log4.log)("initiating connection...", {
1264
1268
  remoteId
1265
1269
  }, {
1266
- file: "swarm.ts",
1267
- line: 368,
1268
- scope: this,
1269
- callSite: (f, a) => f(...a)
1270
+ F: __dxlog_file4,
1271
+ L: 368,
1272
+ S: this,
1273
+ C: (f, a) => f(...a)
1270
1274
  });
1271
1275
  await peer.initiateConnection();
1272
1276
  this._topology.update();
1273
1277
  (0, import_log4.log)("initiated", {
1274
1278
  remoteId
1275
1279
  }, {
1276
- file: "swarm.ts",
1277
- line: 371,
1278
- scope: this,
1279
- callSite: (f, a) => f(...a)
1280
+ F: __dxlog_file4,
1281
+ L: 371,
1282
+ S: this,
1283
+ C: (f, a) => f(...a)
1280
1284
  });
1281
1285
  }
1282
1286
  async _closeConnection(peerId) {
@@ -1287,28 +1291,28 @@ var Swarm = class {
1287
1291
  await peer.closeConnection();
1288
1292
  }
1289
1293
  };
1290
- __decorate3([
1294
+ _ts_decorate3([
1291
1295
  import_log4.logInfo
1292
1296
  ], Swarm.prototype, "_instanceId", void 0);
1293
- __decorate3([
1297
+ _ts_decorate3([
1294
1298
  import_log4.logInfo
1295
1299
  ], Swarm.prototype, "ownPeerId", null);
1296
- __decorate3([
1300
+ _ts_decorate3([
1297
1301
  import_log4.logInfo
1298
1302
  ], Swarm.prototype, "topic", null);
1299
- __decorate3([
1303
+ _ts_decorate3([
1300
1304
  import_async3.synchronized
1301
1305
  ], Swarm.prototype, "onSwarmEvent", null);
1302
- __decorate3([
1306
+ _ts_decorate3([
1303
1307
  import_async3.synchronized
1304
1308
  ], Swarm.prototype, "onOffer", null);
1305
- __decorate3([
1309
+ _ts_decorate3([
1306
1310
  import_async3.synchronized
1307
1311
  ], Swarm.prototype, "onSignal", null);
1308
- __decorate3([
1312
+ _ts_decorate3([
1309
1313
  import_async3.synchronized
1310
1314
  ], Swarm.prototype, "goOffline", null);
1311
- __decorate3([
1315
+ _ts_decorate3([
1312
1316
  import_async3.synchronized
1313
1317
  ], Swarm.prototype, "goOnline", null);
1314
1318
 
@@ -1317,6 +1321,7 @@ var import_async4 = require("@dxos/async");
1317
1321
  var import_keys5 = require("@dxos/keys");
1318
1322
  var import_log5 = require("@dxos/log");
1319
1323
  var import_util3 = require("@dxos/util");
1324
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1320
1325
  var SwarmMapper = class {
1321
1326
  get peers() {
1322
1327
  return Array.from(this._peers.values());
@@ -1343,11 +1348,11 @@ var SwarmMapper = class {
1343
1348
  this._update();
1344
1349
  }
1345
1350
  _update() {
1346
- (0, import_log5.log)("updating swarm", {}, {
1347
- file: "swarm-mapper.ts",
1348
- line: 75,
1349
- scope: this,
1350
- callSite: (f, a) => f(...a)
1351
+ (0, import_log5.log)("updating swarm", void 0, {
1352
+ F: __dxlog_file5,
1353
+ L: 75,
1354
+ S: this,
1355
+ C: (f, a) => f(...a)
1351
1356
  });
1352
1357
  this._peers.clear();
1353
1358
  this._peers.set(this._swarm.ownPeerId, {
@@ -1368,10 +1373,10 @@ var SwarmMapper = class {
1368
1373
  directConnections: this._swarm.connections.length,
1369
1374
  totalPeersInSwarm: this._peers.size
1370
1375
  }, {
1371
- file: "swarm-mapper.ts",
1372
- line: 116,
1373
- scope: this,
1374
- callSite: (f, a) => f(...a)
1376
+ F: __dxlog_file5,
1377
+ L: 116,
1378
+ S: this,
1379
+ C: (f, a) => f(...a)
1375
1380
  });
1376
1381
  this.mapUpdated.emit(Array.from(this._peers.values()));
1377
1382
  }
@@ -1417,6 +1422,7 @@ var ConnectionLog = class {
1417
1422
  this._swarms.set(import_keys6.PublicKey.from(swarm._instanceId), info);
1418
1423
  this.update.emit();
1419
1424
  swarm.connectionAdded.on((connection) => {
1425
+ var _a2, _b;
1420
1426
  const connectionInfo = {
1421
1427
  state: ConnectionState.INITIAL,
1422
1428
  remotePeerId: connection.remoteId,
@@ -1435,6 +1441,10 @@ var ConnectionLog = class {
1435
1441
  });
1436
1442
  this.update.emit();
1437
1443
  });
1444
+ (_b = (_a2 = connection.protocol) == null ? void 0 : _a2.stats) == null ? void 0 : _b.on((stats) => {
1445
+ connectionInfo.streams = stats;
1446
+ this.update.emit();
1447
+ });
1438
1448
  });
1439
1449
  }
1440
1450
  leftSwarm(swarm) {
@@ -1444,8 +1454,9 @@ var ConnectionLog = class {
1444
1454
  };
1445
1455
 
1446
1456
  // packages/core/mesh/network-manager/src/network-manager.ts
1457
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
1447
1458
  var NetworkManager = class {
1448
- constructor({ transportFactory, signalManager, log: log14 }) {
1459
+ constructor({ transportFactory, signalManager, log: log1 }) {
1449
1460
  this._swarms = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
1450
1461
  this._mappers = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
1451
1462
  this._connectionState = import_services.ConnectionState.ONLINE;
@@ -1465,7 +1476,7 @@ var NetworkManager = class {
1465
1476
  join: (opts) => this._signalManager.join(opts),
1466
1477
  leave: (opts) => this._signalManager.leave(opts)
1467
1478
  };
1468
- if (log14) {
1479
+ if (log1) {
1469
1480
  this._connectionLog = new ConnectionLog();
1470
1481
  }
1471
1482
  }
@@ -1490,30 +1501,30 @@ var NetworkManager = class {
1490
1501
  import_log6.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.begin({
1491
1502
  id: this._instanceId
1492
1503
  }), {
1493
- file: "network-manager.ts",
1494
- line: 127,
1495
- scope: this,
1496
- callSite: (f, a) => f(...a)
1504
+ F: __dxlog_file6,
1505
+ L: 127,
1506
+ S: this,
1507
+ C: (f, a) => f(...a)
1497
1508
  });
1498
1509
  await this._messenger.open();
1499
1510
  await this._signalManager.open();
1500
1511
  import_log6.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.end({
1501
1512
  id: this._instanceId
1502
1513
  }), {
1503
- file: "network-manager.ts",
1504
- line: 130,
1505
- scope: this,
1506
- callSite: (f, a) => f(...a)
1514
+ F: __dxlog_file6,
1515
+ L: 130,
1516
+ S: this,
1517
+ C: (f, a) => f(...a)
1507
1518
  });
1508
1519
  }
1509
1520
  async close() {
1510
1521
  for (const topic of this._swarms.keys()) {
1511
1522
  await this.leaveSwarm(topic).catch((err) => {
1512
- (0, import_log6.log)(err, {}, {
1513
- file: "network-manager.ts",
1514
- line: 136,
1515
- scope: this,
1516
- callSite: (f, a) => f(...a)
1523
+ (0, import_log6.log)(err, void 0, {
1524
+ F: __dxlog_file6,
1525
+ L: 136,
1526
+ S: this,
1527
+ C: (f, a) => f(...a)
1517
1528
  });
1518
1529
  });
1519
1530
  }
@@ -1525,10 +1536,10 @@ var NetworkManager = class {
1525
1536
  */
1526
1537
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1527
1538
  var _a2;
1528
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(topic));
1529
- (0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1530
- (0, import_node_assert5.default)(topology);
1531
- (0, import_node_assert5.default)(typeof protocol === "function");
1539
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(topic));
1540
+ (0, import_tiny_invariant5.default)(import_keys7.PublicKey.isPublicKey(peerId));
1541
+ (0, import_tiny_invariant5.default)(topology);
1542
+ (0, import_tiny_invariant5.default)(typeof protocol === "function");
1532
1543
  if (this._swarms.has(topic)) {
1533
1544
  throw new Error(`Already connected to swarm: ${import_keys7.PublicKey.from(topic)}`);
1534
1545
  }
@@ -1537,20 +1548,20 @@ var NetworkManager = class {
1537
1548
  peerId,
1538
1549
  topology: topology.toString()
1539
1550
  }, {
1540
- file: "network-manager.ts",
1541
- line: 162,
1542
- scope: this,
1543
- callSite: (f, a) => f(...a)
1551
+ F: __dxlog_file6,
1552
+ L: 162,
1553
+ S: this,
1554
+ C: (f, a) => f(...a)
1544
1555
  });
1545
1556
  const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label);
1546
1557
  swarm.errors.handle((error) => {
1547
1558
  (0, import_log6.log)("swarm error", {
1548
1559
  error
1549
1560
  }, {
1550
- file: "network-manager.ts",
1551
- line: 165,
1552
- scope: this,
1553
- callSite: (f, a) => f(...a)
1561
+ F: __dxlog_file6,
1562
+ L: 165,
1563
+ S: this,
1564
+ C: (f, a) => f(...a)
1554
1565
  });
1555
1566
  });
1556
1567
  this._swarms.set(topic, swarm);
@@ -1559,11 +1570,11 @@ var NetworkManager = class {
1559
1570
  this._signalConnection.join({
1560
1571
  topic,
1561
1572
  peerId
1562
- }).catch((error) => import_log6.log.catch(error, {}, {
1563
- file: "network-manager.ts",
1564
- line: 174,
1565
- scope: this,
1566
- callSite: (f, a) => f(...a)
1573
+ }).catch((error) => import_log6.log.catch(error, void 0, {
1574
+ F: __dxlog_file6,
1575
+ L: 174,
1576
+ S: this,
1577
+ C: (f, a) => f(...a)
1567
1578
  }));
1568
1579
  this.topicsUpdated.emit();
1569
1580
  (_a2 = this._connectionLog) == null ? void 0 : _a2.joinedSwarm(swarm);
@@ -1571,10 +1582,10 @@ var NetworkManager = class {
1571
1582
  topic: import_keys7.PublicKey.from(topic),
1572
1583
  count: this._swarms.size
1573
1584
  }, {
1574
- file: "network-manager.ts",
1575
- line: 178,
1576
- scope: this,
1577
- callSite: (f, a) => f(...a)
1585
+ F: __dxlog_file6,
1586
+ L: 178,
1587
+ S: this,
1588
+ C: (f, a) => f(...a)
1578
1589
  });
1579
1590
  return {
1580
1591
  close: () => this.leaveSwarm(topic)
@@ -1591,10 +1602,10 @@ var NetworkManager = class {
1591
1602
  (0, import_log6.log)("leaving", {
1592
1603
  topic: import_keys7.PublicKey.from(topic)
1593
1604
  }, {
1594
- file: "network-manager.ts",
1595
- line: 194,
1596
- scope: this,
1597
- callSite: (f, a) => f(...a)
1605
+ F: __dxlog_file6,
1606
+ L: 194,
1607
+ S: this,
1608
+ C: (f, a) => f(...a)
1598
1609
  });
1599
1610
  const swarm = this._swarms.get(topic);
1600
1611
  await this._signalConnection.leave({
@@ -1612,10 +1623,10 @@ var NetworkManager = class {
1612
1623
  topic: import_keys7.PublicKey.from(topic),
1613
1624
  count: this._swarms.size
1614
1625
  }, {
1615
- file: "network-manager.ts",
1616
- line: 208,
1617
- scope: this,
1618
- callSite: (f, a) => f(...a)
1626
+ F: __dxlog_file6,
1627
+ L: 208,
1628
+ S: this,
1629
+ C: (f, a) => f(...a)
1619
1630
  });
1620
1631
  }
1621
1632
  async setConnectionState(state) {
@@ -1647,17 +1658,17 @@ var NetworkManager = class {
1647
1658
  };
1648
1659
 
1649
1660
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1650
- var import_node_assert6 = __toESM(require("node:assert"));
1661
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1651
1662
  var FullyConnectedTopology = class {
1652
1663
  toString() {
1653
1664
  return "FullyConnectedTopology";
1654
1665
  }
1655
1666
  init(controller) {
1656
- (0, import_node_assert6.default)(!this._controller, "Already initialized");
1667
+ (0, import_tiny_invariant6.default)(!this._controller, "Already initialized");
1657
1668
  this._controller = controller;
1658
1669
  }
1659
1670
  update() {
1660
- (0, import_node_assert6.default)(this._controller, "Not initialized");
1671
+ (0, import_tiny_invariant6.default)(this._controller, "Not initialized");
1661
1672
  const { candidates: discovered } = this._controller.getState();
1662
1673
  for (const peer of discovered) {
1663
1674
  this._controller.connect(peer);
@@ -1671,21 +1682,23 @@ var FullyConnectedTopology = class {
1671
1682
  };
1672
1683
 
1673
1684
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1685
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1674
1686
  var import_xor_distance = __toESM(require("xor-distance"));
1675
1687
  var import_log7 = require("@dxos/log");
1676
1688
 
1677
1689
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1690
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1678
1691
  var import_log8 = require("@dxos/log");
1679
1692
 
1680
1693
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1681
- var import_node_assert7 = __toESM(require("node:assert"));
1682
1694
  var import_node_stream = require("node:stream");
1695
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
1683
1696
  var import_async7 = require("@dxos/async");
1684
1697
  var import_debug4 = require("@dxos/debug");
1685
1698
  var import_keys8 = require("@dxos/keys");
1686
1699
  var import_log9 = require("@dxos/log");
1687
1700
  var import_util6 = require("@dxos/util");
1688
- var __decorate4 = function(decorators, target, key, desc) {
1701
+ function _ts_decorate4(decorators, target, key, desc) {
1689
1702
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1690
1703
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1691
1704
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1694,7 +1707,8 @@ var __decorate4 = function(decorators, target, key, desc) {
1694
1707
  if (d = decorators[i])
1695
1708
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1696
1709
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1697
- };
1710
+ }
1711
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
1698
1712
  var MEMORY_TRANSPORT_DELAY = 1;
1699
1713
  var createStreamDelay = (delay) => {
1700
1714
  return new import_node_stream.Transform({
@@ -1714,26 +1728,26 @@ var _MemoryTransport = class {
1714
1728
  this.closed = new import_async7.Event();
1715
1729
  this.connected = new import_async7.Event();
1716
1730
  this.errors = new import_debug4.ErrorStream();
1731
+ this._instanceId = import_keys8.PublicKey.random();
1717
1732
  this._remote = new import_async7.Trigger();
1718
1733
  this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1719
1734
  this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1720
1735
  this._destroyed = false;
1721
- this._instanceId = import_keys8.PublicKey.random();
1722
- (0, import_log9.log)("creating", {}, {
1723
- file: "memory-transport.ts",
1724
- line: 64,
1725
- scope: this,
1726
- callSite: (f, a) => f(...a)
1736
+ (0, import_log9.log)("creating", void 0, {
1737
+ F: __dxlog_file7,
1738
+ L: 64,
1739
+ S: this,
1740
+ C: (f, a) => f(...a)
1727
1741
  });
1728
- (0, import_node_assert7.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1742
+ (0, import_tiny_invariant9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1729
1743
  _MemoryTransport._connections.set(this._instanceId, this);
1730
1744
  if (this.options.initiator) {
1731
1745
  setTimeout(async () => {
1732
- (0, import_log9.log)("sending signal", {}, {
1733
- file: "memory-transport.ts",
1734
- line: 73,
1735
- scope: this,
1736
- callSite: (f, a) => f(...a)
1746
+ (0, import_log9.log)("sending signal", void 0, {
1747
+ F: __dxlog_file7,
1748
+ L: 73,
1749
+ S: this,
1750
+ C: (f, a) => f(...a)
1737
1751
  });
1738
1752
  void this.options.sendSignal({
1739
1753
  payload: {
@@ -1759,14 +1773,14 @@ var _MemoryTransport = class {
1759
1773
  this.closed.emit();
1760
1774
  return;
1761
1775
  }
1762
- (0, import_node_assert7.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1776
+ (0, import_tiny_invariant9.default)(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
1763
1777
  this._remoteConnection._remoteConnection = this;
1764
1778
  this._remoteConnection._remoteInstanceId = this._instanceId;
1765
- (0, import_log9.log)("connected", {}, {
1766
- file: "memory-transport.ts",
1767
- line: 106,
1768
- scope: this,
1769
- callSite: (f, a) => f(...a)
1779
+ (0, import_log9.log)("connected", void 0, {
1780
+ F: __dxlog_file7,
1781
+ L: 103,
1782
+ S: this,
1783
+ C: (f, a) => f(...a)
1770
1784
  });
1771
1785
  this.options.stream.pipe(this._outgoingDelay).pipe(this._remoteConnection.options.stream).pipe(this._incomingDelay).pipe(this.options.stream);
1772
1786
  this.connected.emit();
@@ -1780,20 +1794,20 @@ var _MemoryTransport = class {
1780
1794
  }
1781
1795
  }
1782
1796
  async destroy() {
1783
- (0, import_log9.log)("closing", {}, {
1784
- file: "memory-transport.ts",
1785
- line: 127,
1786
- scope: this,
1787
- callSite: (f, a) => f(...a)
1797
+ (0, import_log9.log)("closing", void 0, {
1798
+ F: __dxlog_file7,
1799
+ L: 124,
1800
+ S: this,
1801
+ C: (f, a) => f(...a)
1788
1802
  });
1789
1803
  this._destroyed = true;
1790
1804
  _MemoryTransport._connections.delete(this._instanceId);
1791
1805
  if (this._remoteConnection) {
1792
- (0, import_log9.log)("closing", {}, {
1793
- file: "memory-transport.ts",
1794
- line: 132,
1795
- scope: this,
1796
- callSite: (f, a) => f(...a)
1806
+ (0, import_log9.log)("closing", void 0, {
1807
+ F: __dxlog_file7,
1808
+ L: 129,
1809
+ S: this,
1810
+ C: (f, a) => f(...a)
1797
1811
  });
1798
1812
  this._remoteConnection._destroyed = true;
1799
1813
  _MemoryTransport._connections.delete(this._remoteInstanceId);
@@ -1802,29 +1816,29 @@ var _MemoryTransport = class {
1802
1816
  this._remoteConnection.closed.emit();
1803
1817
  this._remoteConnection._remoteConnection = void 0;
1804
1818
  this._remoteConnection = void 0;
1805
- (0, import_log9.log)("closed", {}, {
1806
- file: "memory-transport.ts",
1807
- line: 150,
1808
- scope: this,
1809
- callSite: (f, a) => f(...a)
1819
+ (0, import_log9.log)("closed", void 0, {
1820
+ F: __dxlog_file7,
1821
+ L: 147,
1822
+ S: this,
1823
+ C: (f, a) => f(...a)
1810
1824
  });
1811
1825
  }
1812
1826
  this.closed.emit();
1813
- (0, import_log9.log)("closed", {}, {
1814
- file: "memory-transport.ts",
1815
- line: 154,
1816
- scope: this,
1817
- callSite: (f, a) => f(...a)
1827
+ (0, import_log9.log)("closed", void 0, {
1828
+ F: __dxlog_file7,
1829
+ L: 151,
1830
+ S: this,
1831
+ C: (f, a) => f(...a)
1818
1832
  });
1819
1833
  }
1820
1834
  signal({ payload }) {
1821
1835
  (0, import_log9.log)("received signal", {
1822
1836
  payload
1823
1837
  }, {
1824
- file: "memory-transport.ts",
1825
- line: 158,
1826
- scope: this,
1827
- callSite: (f, a) => f(...a)
1838
+ F: __dxlog_file7,
1839
+ L: 155,
1840
+ S: this,
1841
+ C: (f, a) => f(...a)
1828
1842
  });
1829
1843
  if (!(payload == null ? void 0 : payload.transportId)) {
1830
1844
  return;
@@ -1839,16 +1853,16 @@ var _MemoryTransport = class {
1839
1853
  var MemoryTransport = _MemoryTransport;
1840
1854
  // TODO(burdon): Remove static properties (inject context into constructor).
1841
1855
  MemoryTransport._connections = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
1842
- __decorate4([
1856
+ _ts_decorate4([
1843
1857
  import_log9.logInfo
1844
1858
  ], MemoryTransport.prototype, "_instanceId", void 0);
1845
- __decorate4([
1859
+ _ts_decorate4([
1846
1860
  import_log9.logInfo
1847
1861
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
1848
1862
 
1849
1863
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1850
- var import_node_assert8 = __toESM(require("node:assert"));
1851
1864
  var import_simple_peer = __toESM(require("simple-peer"));
1865
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
1852
1866
  var import_async8 = require("@dxos/async");
1853
1867
  var import_debug5 = require("@dxos/debug");
1854
1868
  var import_keys9 = require("@dxos/keys");
@@ -1863,6 +1877,7 @@ try {
1863
1877
  }
1864
1878
 
1865
1879
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1880
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
1866
1881
  var WebRTCTransport = class {
1867
1882
  constructor(params) {
1868
1883
  var _a2;
@@ -1875,16 +1890,16 @@ var WebRTCTransport = class {
1875
1890
  import_log10.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.begin({
1876
1891
  id: this._instanceId
1877
1892
  }), {
1878
- file: "webrtc-transport.ts",
1879
- line: 39,
1880
- scope: this,
1881
- callSite: (f, a) => f(...a)
1893
+ F: __dxlog_file8,
1894
+ L: 39,
1895
+ S: this,
1896
+ C: (f, a) => f(...a)
1882
1897
  });
1883
1898
  (0, import_log10.log)("created connection", params, {
1884
- file: "webrtc-transport.ts",
1885
- line: 40,
1886
- scope: this,
1887
- callSite: (f, a) => f(...a)
1899
+ F: __dxlog_file8,
1900
+ L: 40,
1901
+ S: this,
1902
+ C: (f, a) => f(...a)
1888
1903
  });
1889
1904
  this._peer = new import_simple_peer.default({
1890
1905
  initiator: this.params.initiator,
@@ -1893,10 +1908,10 @@ var WebRTCTransport = class {
1893
1908
  });
1894
1909
  this._peer.on("signal", async (data) => {
1895
1910
  (0, import_log10.log)("signal", data, {
1896
- file: "webrtc-transport.ts",
1897
- line: 48,
1898
- scope: this,
1899
- callSite: (f, a) => f(...a)
1911
+ F: __dxlog_file8,
1912
+ L: 48,
1913
+ S: this,
1914
+ C: (f, a) => f(...a)
1900
1915
  });
1901
1916
  await this.params.sendSignal({
1902
1917
  payload: {
@@ -1905,21 +1920,21 @@ var WebRTCTransport = class {
1905
1920
  });
1906
1921
  });
1907
1922
  this._peer.on("connect", () => {
1908
- (0, import_log10.log)("connected", {}, {
1909
- file: "webrtc-transport.ts",
1910
- line: 53,
1911
- scope: this,
1912
- callSite: (f, a) => f(...a)
1923
+ (0, import_log10.log)("connected", void 0, {
1924
+ F: __dxlog_file8,
1925
+ L: 53,
1926
+ S: this,
1927
+ C: (f, a) => f(...a)
1913
1928
  });
1914
1929
  this.params.stream.pipe(this._peer).pipe(this.params.stream);
1915
1930
  this.connected.emit();
1916
1931
  });
1917
1932
  this._peer.on("close", async () => {
1918
- (0, import_log10.log)("closed", {}, {
1919
- file: "webrtc-transport.ts",
1920
- line: 59,
1921
- scope: this,
1922
- callSite: (f, a) => f(...a)
1933
+ (0, import_log10.log)("closed", void 0, {
1934
+ F: __dxlog_file8,
1935
+ L: 59,
1936
+ S: this,
1937
+ C: (f, a) => f(...a)
1923
1938
  });
1924
1939
  await this._disconnectStreams();
1925
1940
  this.closed.emit();
@@ -1934,10 +1949,10 @@ var WebRTCTransport = class {
1934
1949
  config: this.params.webrtcConfig,
1935
1950
  stats
1936
1951
  }, {
1937
- file: "webrtc-transport.ts",
1938
- line: 71,
1939
- scope: this,
1940
- callSite: (f, a) => f(...a)
1952
+ F: __dxlog_file8,
1953
+ L: 71,
1954
+ S: this,
1955
+ C: (f, a) => f(...a)
1941
1956
  });
1942
1957
  });
1943
1958
  }
@@ -1948,35 +1963,35 @@ var WebRTCTransport = class {
1948
1963
  import_log10.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.end({
1949
1964
  id: this._instanceId
1950
1965
  }), {
1951
- file: "webrtc-transport.ts",
1952
- line: 81,
1953
- scope: this,
1954
- callSite: (f, a) => f(...a)
1966
+ F: __dxlog_file8,
1967
+ L: 81,
1968
+ S: this,
1969
+ C: (f, a) => f(...a)
1955
1970
  });
1956
1971
  }
1957
1972
  async destroy() {
1958
- (0, import_log10.log)("closing...", {}, {
1959
- file: "webrtc-transport.ts",
1960
- line: 85,
1961
- scope: this,
1962
- callSite: (f, a) => f(...a)
1973
+ (0, import_log10.log)("closing...", void 0, {
1974
+ F: __dxlog_file8,
1975
+ L: 85,
1976
+ S: this,
1977
+ C: (f, a) => f(...a)
1963
1978
  });
1964
1979
  this._closed = true;
1965
1980
  await this._disconnectStreams();
1966
1981
  this._peer.destroy();
1967
1982
  this.closed.emit();
1968
- (0, import_log10.log)("closed", {}, {
1969
- file: "webrtc-transport.ts",
1970
- line: 90,
1971
- scope: this,
1972
- callSite: (f, a) => f(...a)
1983
+ (0, import_log10.log)("closed", void 0, {
1984
+ F: __dxlog_file8,
1985
+ L: 90,
1986
+ S: this,
1987
+ C: (f, a) => f(...a)
1973
1988
  });
1974
1989
  }
1975
1990
  signal(signal) {
1976
1991
  if (this._closed) {
1977
1992
  return;
1978
1993
  }
1979
- (0, import_node_assert8.default)(signal.payload.data, "Signal message must contain signal data.");
1994
+ (0, import_tiny_invariant10.default)(signal.payload.data, "Signal message must contain signal data.");
1980
1995
  this._peer.signal(signal.payload.data);
1981
1996
  }
1982
1997
  async _disconnectStreams() {
@@ -1986,13 +2001,14 @@ var WebRTCTransport = class {
1986
2001
  };
1987
2002
 
1988
2003
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
1989
- var import_node_assert9 = __toESM(require("node:assert"));
1990
2004
  var import_node_stream2 = require("node:stream");
2005
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
1991
2006
  var import_codec_protobuf = require("@dxos/codec-protobuf");
1992
2007
  var import_keys10 = require("@dxos/keys");
1993
2008
  var import_log11 = require("@dxos/log");
1994
2009
  var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
1995
2010
  var import_util7 = require("@dxos/util");
2011
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
1996
2012
  var WebRTCTransportService = class {
1997
2013
  // prettier-ignore
1998
2014
  constructor(_webrtcConfig) {
@@ -2063,11 +2079,11 @@ var WebRTCTransportService = class {
2063
2079
  return rpcStream;
2064
2080
  }
2065
2081
  async sendSignal({ proxyId, signal }) {
2066
- (0, import_node_assert9.default)(this.transports.has(proxyId));
2082
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2067
2083
  await this.transports.get(proxyId).transport.signal(signal);
2068
2084
  }
2069
2085
  async sendData({ proxyId, payload }) {
2070
- (0, import_node_assert9.default)(this.transports.has(proxyId));
2086
+ (0, import_tiny_invariant11.default)(this.transports.has(proxyId));
2071
2087
  await this.transports.get(proxyId).stream.push(payload);
2072
2088
  }
2073
2089
  async close({ proxyId }) {
@@ -2075,23 +2091,25 @@ var WebRTCTransportService = class {
2075
2091
  await ((_a2 = this.transports.get(proxyId)) == null ? void 0 : _a2.transport.destroy());
2076
2092
  await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
2077
2093
  this.transports.delete(proxyId);
2078
- (0, import_log11.log)("Closed.", {}, {
2079
- file: "webrtc-transport-service.ts",
2080
- line: 109,
2081
- scope: this,
2082
- callSite: (f, a) => f(...a)
2094
+ (0, import_log11.log)("Closed.", void 0, {
2095
+ F: __dxlog_file9,
2096
+ L: 109,
2097
+ S: this,
2098
+ C: (f, a) => f(...a)
2083
2099
  });
2084
2100
  }
2085
2101
  };
2086
2102
 
2087
2103
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
2088
- var import_node_assert10 = __toESM(require("node:assert"));
2104
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
2089
2105
  var import_async9 = require("@dxos/async");
2090
2106
  var import_context5 = require("@dxos/context");
2091
2107
  var import_debug6 = require("@dxos/debug");
2092
2108
  var import_keys11 = require("@dxos/keys");
2093
2109
  var import_log12 = require("@dxos/log");
2094
2110
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
2111
+ var import_util8 = require("@dxos/util");
2112
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
2095
2113
  var WebRTCTransportProxy = class {
2096
2114
  // prettier-ignore
2097
2115
  constructor(_params) {
@@ -2109,10 +2127,10 @@ var WebRTCTransportProxy = class {
2109
2127
  this._serviceStream.waitUntilReady().then(() => {
2110
2128
  this._serviceStream.subscribe(async (event) => {
2111
2129
  (0, import_log12.log)("WebRTCTransportProxy: event", event, {
2112
- file: "webrtc-transport-proxy.ts",
2113
- line: 49,
2114
- scope: this,
2115
- callSite: (f, a) => f(...a)
2130
+ F: __dxlog_file10,
2131
+ L: 50,
2132
+ S: this,
2133
+ C: (f, a) => f(...a)
2116
2134
  });
2117
2135
  if (event.connection) {
2118
2136
  await this._handleConnection(event.connection);
@@ -2129,11 +2147,11 @@ var WebRTCTransportProxy = class {
2129
2147
  payload: data
2130
2148
  });
2131
2149
  } catch (err) {
2132
- import_log12.log.catch(err, {}, {
2133
- file: "webrtc-transport-proxy.ts",
2134
- line: 66,
2135
- scope: this,
2136
- callSite: (f, a) => f(...a)
2150
+ import_log12.log.catch(err, void 0, {
2151
+ F: __dxlog_file10,
2152
+ L: 67,
2153
+ S: this,
2154
+ C: (f, a) => f(...a)
2137
2155
  });
2138
2156
  }
2139
2157
  };
@@ -2141,11 +2159,11 @@ var WebRTCTransportProxy = class {
2141
2159
  this._ctx.onDispose(() => {
2142
2160
  this._params.stream.off("data", dataListener);
2143
2161
  });
2144
- }, (error) => import_log12.log.catch(error, {}, {
2145
- file: "webrtc-transport-proxy.ts",
2146
- line: 72,
2147
- scope: this,
2148
- callSite: (f, a) => f(...a)
2162
+ }, (error) => import_log12.log.catch(error, void 0, {
2163
+ F: __dxlog_file10,
2164
+ L: 73,
2165
+ S: this,
2166
+ C: (f, a) => f(...a)
2149
2167
  }));
2150
2168
  }
2151
2169
  async _handleConnection(connectionEvent) {
@@ -2164,7 +2182,7 @@ var WebRTCTransportProxy = class {
2164
2182
  }
2165
2183
  }
2166
2184
  _handleData(dataEvent) {
2167
- this._params.stream.write(Buffer.from(dataEvent.payload));
2185
+ this._params.stream.write((0, import_util8.arrayToBuffer)(dataEvent.payload));
2168
2186
  }
2169
2187
  async _handleSignal(signalEvent) {
2170
2188
  await this._params.sendSignal(signalEvent.payload);
@@ -2187,11 +2205,11 @@ var WebRTCTransportProxy = class {
2187
2205
  proxyId: this._proxyId
2188
2206
  });
2189
2207
  } catch (err) {
2190
- import_log12.log.catch(err, {}, {
2191
- file: "webrtc-transport-proxy.ts",
2192
- line: 123,
2193
- scope: this,
2194
- callSite: (f, a) => f(...a)
2208
+ import_log12.log.catch(err, void 0, {
2209
+ F: __dxlog_file10,
2210
+ L: 124,
2211
+ S: this,
2212
+ C: (f, a) => f(...a)
2195
2213
  });
2196
2214
  }
2197
2215
  this.closed.emit();
@@ -2223,7 +2241,7 @@ var WebRTCTransportProxyFactory = class {
2223
2241
  return this;
2224
2242
  }
2225
2243
  createTransport(options) {
2226
- (0, import_node_assert10.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2244
+ (0, import_tiny_invariant12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2227
2245
  const transport = new WebRTCTransportProxy({
2228
2246
  ...options,
2229
2247
  bridgeService: this._bridgeService
@@ -2239,7 +2257,7 @@ var import_async10 = require("@dxos/async");
2239
2257
  var import_keys12 = require("@dxos/keys");
2240
2258
  var import_log13 = require("@dxos/log");
2241
2259
  var import_teleport2 = require("@dxos/teleport");
2242
- var import_util8 = require("@dxos/util");
2260
+ var import_util9 = require("@dxos/util");
2243
2261
 
2244
2262
  // packages/core/mesh/network-manager/src/wire-protocol.ts
2245
2263
  var import_teleport = require("@dxos/teleport");
@@ -2260,20 +2278,21 @@ var createTeleportProtocolFactory = (onConnection) => {
2260
2278
  };
2261
2279
 
2262
2280
  // packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts
2281
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts";
2263
2282
  var TestWireProtocol = class {
2264
2283
  constructor(peerId) {
2265
2284
  this.peerId = peerId;
2266
- this.connections = new import_util8.ComplexMap(import_keys12.PublicKey.hash);
2285
+ this.connections = new import_util9.ComplexMap(import_keys12.PublicKey.hash);
2267
2286
  this.connected = new import_async10.Event();
2268
2287
  this.disconnected = new import_async10.Event();
2269
2288
  this.factory = createTeleportProtocolFactory(async (teleport) => {
2270
2289
  (0, import_log13.log)("create", {
2271
2290
  remotePeerId: teleport.remotePeerId
2272
2291
  }, {
2273
- file: "test-wire-protocol.ts",
2274
- line: 21,
2275
- scope: this,
2276
- callSite: (f, a) => f(...a)
2292
+ F: __dxlog_file11,
2293
+ L: 21,
2294
+ S: this,
2295
+ C: (f, a) => f(...a)
2277
2296
  });
2278
2297
  const extension = new import_teleport2.TestExtension({
2279
2298
  onClose: async () => {
@@ -2293,10 +2312,10 @@ var TestWireProtocol = class {
2293
2312
  (0, import_log13.log)("waitForConnection", {
2294
2313
  peerId
2295
2314
  }, {
2296
- file: "test-wire-protocol.ts",
2297
- line: 37,
2298
- scope: this,
2299
- callSite: (f, a) => f(...a)
2315
+ F: __dxlog_file11,
2316
+ L: 37,
2317
+ S: this,
2318
+ C: (f, a) => f(...a)
2300
2319
  });
2301
2320
  await (0, import_async10.asyncTimeout)(
2302
2321
  this.connected.waitFor((connectedId) => connectedId.equals(peerId)),
@@ -2338,7 +2357,7 @@ var TestPeer = class {
2338
2357
  constructor(testBuilder, peerId) {
2339
2358
  this.testBuilder = testBuilder;
2340
2359
  this.peerId = peerId;
2341
- this._swarms = new import_util9.ComplexMap(import_keys13.PublicKey.hash);
2360
+ this._swarms = new import_util10.ComplexMap(import_keys13.PublicKey.hash);
2342
2361
  this._signalManager = this.testBuilder.createSignalManager();
2343
2362
  this._networkManager = this.createNetworkManager();
2344
2363
  }