@dxos/network-manager 0.1.53-main.b6f5d87 → 0.1.53-main.cb0c729

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