@dxos/teleport 0.3.5-main.d53523e → 0.3.5-main.d8a95f3

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.
@@ -2,7 +2,7 @@ import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/core/mesh/teleport/src/testing/test-builder.ts
4
4
  import { pipeline } from "@dxos/node-std/stream";
5
- import { invariant as invariant4 } from "@dxos/invariant";
5
+ import { invariant as invariant5 } from "@dxos/invariant";
6
6
  import { PublicKey as PublicKey2 } from "@dxos/keys";
7
7
  import { log as log5 } from "@dxos/log";
8
8
 
@@ -10,7 +10,7 @@ import { log as log5 } from "@dxos/log";
10
10
  import { asyncTimeout, scheduleTaskInterval as scheduleTaskInterval2, runInContextAsync, synchronized, scheduleTask } from "@dxos/async";
11
11
  import { Context as Context2 } from "@dxos/context";
12
12
  import { failUndefined as failUndefined2 } from "@dxos/debug";
13
- import { invariant as invariant3 } from "@dxos/invariant";
13
+ import { invariant as invariant4 } from "@dxos/invariant";
14
14
  import { PublicKey } from "@dxos/keys";
15
15
  import { log as log4 } from "@dxos/log";
16
16
  import { schema as schema2, RpcClosedError, TimeoutError as TimeoutError2 } from "@dxos/protocols";
@@ -188,13 +188,14 @@ import { Duplex as Duplex2 } from "@dxos/node-std/stream";
188
188
  import { scheduleTaskInterval, Event as Event3, Trigger } from "@dxos/async";
189
189
  import { Context } from "@dxos/context";
190
190
  import { failUndefined } from "@dxos/debug";
191
- import { invariant as invariant2 } from "@dxos/invariant";
191
+ import { invariant as invariant3 } from "@dxos/invariant";
192
192
  import { log as log3 } from "@dxos/log";
193
193
  import { schema, TimeoutError } from "@dxos/protocols";
194
194
 
195
195
  // packages/core/mesh/teleport/src/muxing/balancer.ts
196
196
  import * as varint from "varint";
197
197
  import { Event as Event2 } from "@dxos/async";
198
+ import { invariant as invariant2 } from "@dxos/invariant";
198
199
  import { log as log2 } from "@dxos/log";
199
200
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/balancer.ts";
200
201
  var MAX_CHUNK_SIZE = 8192;
@@ -206,6 +207,7 @@ var Balancer = class {
206
207
  this._framer = new Framer();
207
208
  this._sendBuffers = /* @__PURE__ */ new Map();
208
209
  this._receiveBuffers = /* @__PURE__ */ new Map();
210
+ this._sending = false;
209
211
  this.incomingData = new Event2();
210
212
  this.stream = this._framer.stream;
211
213
  this._channels.push(_sysChannelId);
@@ -224,43 +226,19 @@ var Balancer = class {
224
226
  this._channels.push(channel);
225
227
  }
226
228
  pushData(data, trigger, channelId) {
227
- const noCalls = this._sendBuffers.size === 0;
228
- if (!this._channels.includes(channelId)) {
229
- throw new Error(`Unknown channel ${channelId}`);
230
- }
231
- if (!this._sendBuffers.has(channelId)) {
232
- this._sendBuffers.set(channelId, []);
233
- }
234
- const sendBuffer = this._sendBuffers.get(channelId);
235
- const chunks = [];
236
- for (let idx = 0; idx < data.length; idx += MAX_CHUNK_SIZE) {
237
- chunks.push(data.subarray(idx, idx + MAX_CHUNK_SIZE));
238
- }
239
- chunks.forEach((chunk, index) => {
240
- const msg = encodeChunk({
241
- chunk,
242
- channelId,
243
- dataLength: index === 0 ? data.length : void 0
244
- });
245
- sendBuffer.push({
246
- msg,
247
- trigger: index === chunks.length - 1 ? trigger : void 0
248
- });
249
- });
250
- if (noCalls) {
251
- this._sendChunk().catch((err) => log2.catch(err, void 0, {
252
- F: __dxlog_file2,
253
- L: 100,
254
- S: this,
255
- C: (f, a) => f(...a)
256
- }));
257
- }
229
+ this._enqueueChunk(data, trigger, channelId);
230
+ this._sendChunks().catch((err) => log2.catch(err, void 0, {
231
+ F: __dxlog_file2,
232
+ L: 75,
233
+ S: this,
234
+ C: (f, a) => f(...a)
235
+ }));
258
236
  }
259
237
  destroy() {
260
238
  if (this._sendBuffers.size !== 0) {
261
239
  log2.warn("destroying balancer with pending calls", void 0, {
262
240
  F: __dxlog_file2,
263
- L: 106,
241
+ L: 80,
264
242
  S: this,
265
243
  C: (f, a) => f(...a)
266
244
  });
@@ -301,36 +279,99 @@ var Balancer = class {
301
279
  this._lastCallerIndex = (this._lastCallerIndex + 1) % this._channels.length;
302
280
  return this._channels[index];
303
281
  }
282
+ _enqueueChunk(data, trigger, channelId) {
283
+ if (!this._channels.includes(channelId)) {
284
+ throw new Error(`Unknown channel ${channelId}`);
285
+ }
286
+ if (!this._sendBuffers.has(channelId)) {
287
+ this._sendBuffers.set(channelId, []);
288
+ }
289
+ const sendBuffer = this._sendBuffers.get(channelId);
290
+ const chunks = [];
291
+ for (let idx = 0; idx < data.length; idx += MAX_CHUNK_SIZE) {
292
+ chunks.push(data.subarray(idx, idx + MAX_CHUNK_SIZE));
293
+ }
294
+ chunks.forEach((chunk, index) => {
295
+ const msg = encodeChunk({
296
+ chunk,
297
+ channelId,
298
+ dataLength: index === 0 ? data.length : void 0
299
+ });
300
+ sendBuffer.push({
301
+ msg,
302
+ trigger: index === chunks.length - 1 ? trigger : void 0
303
+ });
304
+ });
305
+ }
306
+ // get the next chunk or null if there are no chunks remaining
304
307
  _getNextChunk() {
305
308
  let chunk;
306
- while (!chunk) {
309
+ while (this._sendBuffers.size > 0) {
307
310
  const channelId = this._getNextCallerId();
308
311
  const sendBuffer = this._sendBuffers.get(channelId);
309
312
  if (!sendBuffer) {
310
313
  continue;
311
314
  }
312
315
  chunk = sendBuffer.shift();
316
+ if (!chunk) {
317
+ continue;
318
+ }
313
319
  if (sendBuffer.length === 0) {
314
320
  this._sendBuffers.delete(channelId);
315
321
  }
322
+ return chunk;
316
323
  }
317
- return chunk;
324
+ return null;
318
325
  }
319
- async _sendChunk() {
320
- if (this._sendBuffers.size === 0) {
326
+ async _sendChunks() {
327
+ if (this._sending) {
321
328
  return;
322
329
  }
323
- if (!this._framer.writable) {
324
- await this._framer.drain.waitForCount(1);
325
- }
326
- const chunk = this._getNextChunk();
327
- try {
328
- await this._framer.port.send(chunk.msg);
329
- chunk.trigger?.wake();
330
- } catch (err) {
331
- chunk.trigger?.throw(err);
330
+ this._sending = true;
331
+ let chunk;
332
+ chunk = this._getNextChunk();
333
+ while (chunk) {
334
+ if (!this._framer.writable) {
335
+ log2("PAUSE for drain", void 0, {
336
+ F: __dxlog_file2,
337
+ L: 179,
338
+ S: this,
339
+ C: (f, a) => f(...a)
340
+ });
341
+ await this._framer.drain.waitForCount(1);
342
+ log2("RESUME for drain", void 0, {
343
+ F: __dxlog_file2,
344
+ L: 181,
345
+ S: this,
346
+ C: (f, a) => f(...a)
347
+ });
348
+ }
349
+ try {
350
+ await this._framer.port.send(chunk.msg);
351
+ chunk.trigger?.wake();
352
+ } catch (err) {
353
+ log2("Error sending chunk", {
354
+ err
355
+ }, {
356
+ F: __dxlog_file2,
357
+ L: 187,
358
+ S: this,
359
+ C: (f, a) => f(...a)
360
+ });
361
+ chunk.trigger?.throw(err);
362
+ }
363
+ chunk = this._getNextChunk();
332
364
  }
333
- await this._sendChunk();
365
+ invariant2(this._sendBuffers.size === 0, "sendBuffers not empty", {
366
+ F: __dxlog_file2,
367
+ L: 192,
368
+ S: this,
369
+ A: [
370
+ "this._sendBuffers.size === 0",
371
+ "'sendBuffers not empty'"
372
+ ]
373
+ });
374
+ this._sending = false;
334
375
  }
335
376
  };
336
377
  var encodeChunk = ({ channelId, dataLength, chunk }) => {
@@ -363,6 +404,8 @@ var decodeChunk = (data, withLength) => {
363
404
  // packages/core/mesh/teleport/src/muxing/muxer.ts
364
405
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/muxer.ts";
365
406
  var Command = schema.getCodecForType("dxos.mesh.muxer.Command");
407
+ var DEFAULT_SEND_COMMAND_TIMEOUT = 6e4;
408
+ var DESTROY_COMMAND_SEND_TIMEOUT = 5e3;
366
409
  var STATS_INTERVAL = 1e3;
367
410
  var MAX_SAFE_FRAME_SIZE = 1e6;
368
411
  var SYSTEM_CHANNEL_ID = 0;
@@ -397,9 +440,9 @@ var Muxer = class {
397
440
  tag,
398
441
  contentType: opts.contentType
399
442
  });
400
- invariant2(!channel.push, `Channel already open: ${tag}`, {
443
+ invariant3(!channel.push, `Channel already open: ${tag}`, {
401
444
  F: __dxlog_file3,
402
- L: 137,
445
+ L: 140,
403
446
  S: this,
404
447
  A: [
405
448
  "!channel.push",
@@ -445,9 +488,9 @@ var Muxer = class {
445
488
  tag,
446
489
  contentType: opts.contentType
447
490
  });
448
- invariant2(!channel.push, `Channel already open: ${tag}`, {
491
+ invariant3(!channel.push, `Channel already open: ${tag}`, {
449
492
  F: __dxlog_file3,
450
- L: 189,
493
+ L: 192,
451
494
  S: this,
452
495
  A: [
453
496
  "!channel.push",
@@ -465,13 +508,13 @@ var Muxer = class {
465
508
  }
466
509
  };
467
510
  const port = {
468
- send: async (data) => {
469
- await this._sendData(channel, data);
511
+ send: async (data, timeout) => {
512
+ await this._sendData(channel, data, timeout);
470
513
  },
471
514
  subscribe: (cb) => {
472
- invariant2(!callback, "Only one subscriber is allowed", {
515
+ invariant3(!callback, "Only one subscriber is allowed", {
473
516
  F: __dxlog_file3,
474
- L: 211,
517
+ L: 214,
475
518
  S: this,
476
519
  A: [
477
520
  "!callback",
@@ -504,7 +547,7 @@ var Muxer = class {
504
547
  if (this._destroying) {
505
548
  log3("already destroying, ignoring graceful close request", void 0, {
506
549
  F: __dxlog_file3,
507
- L: 244,
550
+ L: 247,
508
551
  S: this,
509
552
  C: (f, a) => f(...a)
510
553
  });
@@ -513,7 +556,7 @@ var Muxer = class {
513
556
  if (this._closing) {
514
557
  log3("already closing, ignoring graceful close request", void 0, {
515
558
  F: __dxlog_file3,
516
- L: 248,
559
+ L: 251,
517
560
  S: this,
518
561
  C: (f, a) => f(...a)
519
562
  });
@@ -524,12 +567,12 @@ var Muxer = class {
524
567
  close: {
525
568
  error: err?.message
526
569
  }
527
- }, SYSTEM_CHANNEL_ID).catch(async (err2) => {
570
+ }, SYSTEM_CHANNEL_ID, DESTROY_COMMAND_SEND_TIMEOUT).catch(async (err2) => {
528
571
  log3("error sending close command", {
529
572
  err: err2
530
573
  }, {
531
574
  F: __dxlog_file3,
532
- L: 262,
575
+ L: 266,
533
576
  S: this,
534
577
  C: (f, a) => f(...a)
535
578
  });
@@ -551,7 +594,7 @@ var Muxer = class {
551
594
  if (this._destroying) {
552
595
  log3("already destroying, ignoring destroy request", void 0, {
553
596
  F: __dxlog_file3,
554
- L: 283,
597
+ L: 287,
555
598
  S: this,
556
599
  C: (f, a) => f(...a)
557
600
  });
@@ -562,7 +605,7 @@ var Muxer = class {
562
605
  if (this._closing) {
563
606
  log3("destroy cancelling graceful close", void 0, {
564
607
  F: __dxlog_file3,
565
- L: 289,
608
+ L: 293,
566
609
  S: this,
567
610
  C: (f, a) => f(...a)
568
611
  });
@@ -577,7 +620,7 @@ var Muxer = class {
577
620
  err: err2
578
621
  }, {
579
622
  F: __dxlog_file3,
580
- L: 302,
623
+ L: 306,
581
624
  S: this,
582
625
  C: (f, a) => f(...a)
583
626
  });
@@ -588,7 +631,7 @@ var Muxer = class {
588
631
  err: err2
589
632
  }, {
590
633
  F: __dxlog_file3,
591
- L: 307,
634
+ L: 311,
592
635
  S: this,
593
636
  C: (f, a) => f(...a)
594
637
  });
@@ -599,7 +642,7 @@ var Muxer = class {
599
642
  if (this._disposed) {
600
643
  log3("already destroyed, ignoring dispose request", void 0, {
601
644
  F: __dxlog_file3,
602
- L: 315,
645
+ L: 319,
603
646
  S: this,
604
647
  C: (f, a) => f(...a)
605
648
  });
@@ -621,7 +664,7 @@ var Muxer = class {
621
664
  cmd
622
665
  }, {
623
666
  F: __dxlog_file3,
624
- L: 337,
667
+ L: 341,
625
668
  S: this,
626
669
  C: (f, a) => f(...a)
627
670
  });
@@ -631,7 +674,7 @@ var Muxer = class {
631
674
  if (!this._closing) {
632
675
  log3("received peer close, initiating my own graceful close", void 0, {
633
676
  F: __dxlog_file3,
634
- L: 343,
677
+ L: 347,
635
678
  S: this,
636
679
  C: (f, a) => f(...a)
637
680
  });
@@ -639,7 +682,7 @@ var Muxer = class {
639
682
  } else {
640
683
  log3("received close from peer, already closing", void 0, {
641
684
  F: __dxlog_file3,
642
- L: 346,
685
+ L: 350,
643
686
  S: this,
644
687
  C: (f, a) => f(...a)
645
688
  });
@@ -668,7 +711,7 @@ var Muxer = class {
668
711
  tag: stream.tag
669
712
  }, {
670
713
  F: __dxlog_file3,
671
- L: 375,
714
+ L: 379,
672
715
  S: this,
673
716
  C: (f, a) => f(...a)
674
717
  });
@@ -677,11 +720,13 @@ var Muxer = class {
677
720
  stream.push(cmd.data.data);
678
721
  }
679
722
  }
680
- async _sendCommand(cmd, channelId = -1) {
723
+ async _sendCommand(cmd, channelId = -1, timeout = DEFAULT_SEND_COMMAND_TIMEOUT) {
681
724
  try {
682
725
  const trigger = new Trigger();
683
726
  this._balancer.pushData(Command.encode(cmd), trigger, channelId);
684
- await trigger.wait();
727
+ await trigger.wait({
728
+ timeout
729
+ });
685
730
  } catch (err) {
686
731
  await this.destroy(err);
687
732
  }
@@ -711,14 +756,14 @@ var Muxer = class {
711
756
  }
712
757
  return channel;
713
758
  }
714
- async _sendData(channel, data) {
759
+ async _sendData(channel, data, timeout) {
715
760
  if (data.length > MAX_SAFE_FRAME_SIZE) {
716
761
  log3.warn("frame size exceeds maximum safe value", {
717
762
  size: data.length,
718
763
  threshold: MAX_SAFE_FRAME_SIZE
719
764
  }, {
720
765
  F: __dxlog_file3,
721
- L: 421,
766
+ L: 425,
722
767
  S: this,
723
768
  C: (f, a) => f(...a)
724
769
  });
@@ -733,7 +778,7 @@ var Muxer = class {
733
778
  channelId: channel.remoteId,
734
779
  data
735
780
  }
736
- }, channel.id);
781
+ }, channel.id, timeout);
737
782
  }
738
783
  _destroyChannel(channel, err) {
739
784
  if (channel.destroy) {
@@ -796,6 +841,8 @@ function _ts_decorate(decorators, target, key, desc) {
796
841
  return c > 3 && r && Object.defineProperty(target, key, r), r;
797
842
  }
798
843
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/teleport.ts";
844
+ var CONTROL_HEARTBEAT_INTERVAL = 1e4;
845
+ var CONTROL_HEARTBEAT_TIMEOUT = 6e4;
799
846
  var Teleport = class {
800
847
  constructor({ initiator, localPeerId, remotePeerId }) {
801
848
  this._ctx = new Context2({
@@ -803,7 +850,7 @@ var Teleport = class {
803
850
  void this.destroy(err).catch(() => {
804
851
  log4.error("Error during destroy", err, {
805
852
  F: __dxlog_file4,
806
- L: 44,
853
+ L: 47,
807
854
  S: this,
808
855
  C: (f, a) => f(...a)
809
856
  });
@@ -812,21 +859,21 @@ var Teleport = class {
812
859
  });
813
860
  this._muxer = new Muxer();
814
861
  this._control = new ControlExtension({
815
- heartbeatInterval: 1e4,
816
- heartbeatTimeout: 1e4,
862
+ heartbeatInterval: CONTROL_HEARTBEAT_INTERVAL,
863
+ heartbeatTimeout: CONTROL_HEARTBEAT_TIMEOUT,
817
864
  onTimeout: () => {
818
865
  if (this._destroying || this._aborting) {
819
866
  return;
820
867
  }
821
- log4("destroy teleport due to onTimeout in ControlExtension", void 0, {
868
+ log4("abort teleport due to onTimeout in ControlExtension", void 0, {
822
869
  F: __dxlog_file4,
823
- L: 59,
870
+ L: 62,
824
871
  S: this,
825
872
  C: (f, a) => f(...a)
826
873
  });
827
- this.destroy(new TimeoutError2("control extension")).catch((err) => log4.catch(err, void 0, {
874
+ this.abort(new TimeoutError2("control extension")).catch((err) => log4.catch(err, void 0, {
828
875
  F: __dxlog_file4,
829
- L: 60,
876
+ L: 63,
830
877
  S: this,
831
878
  C: (f, a) => f(...a)
832
879
  }));
@@ -837,27 +884,27 @@ var Teleport = class {
837
884
  this._open = false;
838
885
  this._destroying = false;
839
886
  this._aborting = false;
840
- invariant3(typeof initiator === "boolean", void 0, {
887
+ invariant4(typeof initiator === "boolean", void 0, {
841
888
  F: __dxlog_file4,
842
- L: 72,
889
+ L: 75,
843
890
  S: this,
844
891
  A: [
845
892
  "typeof initiator === 'boolean'",
846
893
  ""
847
894
  ]
848
895
  });
849
- invariant3(PublicKey.isPublicKey(localPeerId), void 0, {
896
+ invariant4(PublicKey.isPublicKey(localPeerId), void 0, {
850
897
  F: __dxlog_file4,
851
- L: 73,
898
+ L: 76,
852
899
  S: this,
853
900
  A: [
854
901
  "PublicKey.isPublicKey(localPeerId)",
855
902
  ""
856
903
  ]
857
904
  });
858
- invariant3(PublicKey.isPublicKey(remotePeerId), void 0, {
905
+ invariant4(PublicKey.isPublicKey(remotePeerId), void 0, {
859
906
  F: __dxlog_file4,
860
- L: 74,
907
+ L: 77,
861
908
  S: this,
862
909
  A: [
863
910
  "PublicKey.isPublicKey(remotePeerId)",
@@ -872,13 +919,13 @@ var Teleport = class {
872
919
  name
873
920
  }, {
874
921
  F: __dxlog_file4,
875
- L: 80,
922
+ L: 83,
876
923
  S: this,
877
924
  C: (f, a) => f(...a)
878
925
  });
879
- invariant3(!this._remoteExtensions.has(name), "Remote extension already exists", {
926
+ invariant4(!this._remoteExtensions.has(name), "Remote extension already exists", {
880
927
  F: __dxlog_file4,
881
- L: 81,
928
+ L: 84,
882
929
  S: this,
883
930
  A: [
884
931
  "!this._remoteExtensions.has(name)",
@@ -899,7 +946,7 @@ var Teleport = class {
899
946
  if (this._destroying || this._aborting) {
900
947
  log4("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
901
948
  F: __dxlog_file4,
902
- L: 97,
949
+ L: 100,
903
950
  S: this,
904
951
  C: (f, a) => f(...a)
905
952
  });
@@ -922,7 +969,7 @@ var Teleport = class {
922
969
  channels: stats.channels
923
970
  }, {
924
971
  F: __dxlog_file4,
925
- L: 110,
972
+ L: 113,
926
973
  S: this,
927
974
  C: (f, a) => f(...a)
928
975
  });
@@ -960,7 +1007,7 @@ var Teleport = class {
960
1007
  } catch (err2) {
961
1008
  log4.catch(err2, void 0, {
962
1009
  F: __dxlog_file4,
963
- L: 163,
1010
+ L: 166,
964
1011
  S: this,
965
1012
  C: (f, a) => f(...a)
966
1013
  });
@@ -983,7 +1030,7 @@ var Teleport = class {
983
1030
  } catch (err2) {
984
1031
  log4.catch(err2, void 0, {
985
1032
  F: __dxlog_file4,
986
- L: 187,
1033
+ L: 190,
987
1034
  S: this,
988
1035
  C: (f, a) => f(...a)
989
1036
  });
@@ -999,7 +1046,7 @@ var Teleport = class {
999
1046
  name
1000
1047
  }, {
1001
1048
  F: __dxlog_file4,
1002
- L: 199,
1049
+ L: 202,
1003
1050
  S: this,
1004
1051
  C: (f, a) => f(...a)
1005
1052
  });
@@ -1021,18 +1068,18 @@ var Teleport = class {
1021
1068
  }
1022
1069
  }
1023
1070
  _setExtension(extensionName, extension) {
1024
- invariant3(!extensionName.includes("/"), "Invalid extension name", {
1071
+ invariant4(!extensionName.includes("/"), "Invalid extension name", {
1025
1072
  F: __dxlog_file4,
1026
- L: 223,
1073
+ L: 226,
1027
1074
  S: this,
1028
1075
  A: [
1029
1076
  "!extensionName.includes('/')",
1030
1077
  "'Invalid extension name'"
1031
1078
  ]
1032
1079
  });
1033
- invariant3(!this._extensions.has(extensionName), "Extension already exists", {
1080
+ invariant4(!this._extensions.has(extensionName), "Extension already exists", {
1034
1081
  F: __dxlog_file4,
1035
- L: 224,
1082
+ L: 227,
1036
1083
  S: this,
1037
1084
  A: [
1038
1085
  "!this._extensions.has(extensionName)",
@@ -1046,7 +1093,7 @@ var Teleport = class {
1046
1093
  extensionName
1047
1094
  }, {
1048
1095
  F: __dxlog_file4,
1049
- L: 229,
1096
+ L: 232,
1050
1097
  S: this,
1051
1098
  C: (f, a) => f(...a)
1052
1099
  });
@@ -1056,9 +1103,9 @@ var Teleport = class {
1056
1103
  localPeerId: this.localPeerId,
1057
1104
  remotePeerId: this.remotePeerId,
1058
1105
  createPort: async (channelName, opts) => {
1059
- invariant3(!channelName.includes("/"), "Invalid channel name", {
1106
+ invariant4(!channelName.includes("/"), "Invalid channel name", {
1060
1107
  F: __dxlog_file4,
1061
- L: 237,
1108
+ L: 240,
1062
1109
  S: this,
1063
1110
  A: [
1064
1111
  "!channelName.includes('/')",
@@ -1068,9 +1115,9 @@ var Teleport = class {
1068
1115
  return this._muxer.createPort(`${extensionName}/${channelName}`, opts);
1069
1116
  },
1070
1117
  createStream: async (channelName, opts) => {
1071
- invariant3(!channelName.includes("/"), "Invalid channel name", {
1118
+ invariant4(!channelName.includes("/"), "Invalid channel name", {
1072
1119
  F: __dxlog_file4,
1073
- L: 241,
1120
+ L: 244,
1074
1121
  S: this,
1075
1122
  A: [
1076
1123
  "!channelName.includes('/')",
@@ -1090,7 +1137,7 @@ var Teleport = class {
1090
1137
  extensionName
1091
1138
  }, {
1092
1139
  F: __dxlog_file4,
1093
- L: 252,
1140
+ L: 255,
1094
1141
  S: this,
1095
1142
  C: (f, a) => f(...a)
1096
1143
  });
@@ -1178,7 +1225,7 @@ var TestBuilder = class {
1178
1225
  await Promise.all(Array.from(this._peers).map((agent) => agent.destroy()));
1179
1226
  }
1180
1227
  async connect(peer1, peer2) {
1181
- invariant4(peer1 !== peer2, void 0, {
1228
+ invariant5(peer1 !== peer2, void 0, {
1182
1229
  F: __dxlog_file5,
1183
1230
  L: 37,
1184
1231
  S: this,
@@ -1187,7 +1234,7 @@ var TestBuilder = class {
1187
1234
  ""
1188
1235
  ]
1189
1236
  });
1190
- invariant4(this._peers.has(peer1), void 0, {
1237
+ invariant5(this._peers.has(peer1), void 0, {
1191
1238
  F: __dxlog_file5,
1192
1239
  L: 38,
1193
1240
  S: this,
@@ -1196,7 +1243,7 @@ var TestBuilder = class {
1196
1243
  ""
1197
1244
  ]
1198
1245
  });
1199
- invariant4(this._peers.has(peer1), void 0, {
1246
+ invariant5(this._peers.has(peer1), void 0, {
1200
1247
  F: __dxlog_file5,
1201
1248
  L: 39,
1202
1249
  S: this,
@@ -1224,7 +1271,7 @@ var TestBuilder = class {
1224
1271
  ];
1225
1272
  }
1226
1273
  async disconnect(peer1, peer2) {
1227
- invariant4(peer1 !== peer2, void 0, {
1274
+ invariant5(peer1 !== peer2, void 0, {
1228
1275
  F: __dxlog_file5,
1229
1276
  L: 51,
1230
1277
  S: this,
@@ -1233,7 +1280,7 @@ var TestBuilder = class {
1233
1280
  ""
1234
1281
  ]
1235
1282
  });
1236
- invariant4(this._peers.has(peer1), void 0, {
1283
+ invariant5(this._peers.has(peer1), void 0, {
1237
1284
  F: __dxlog_file5,
1238
1285
  L: 52,
1239
1286
  S: this,
@@ -1242,7 +1289,7 @@ var TestBuilder = class {
1242
1289
  ""
1243
1290
  ]
1244
1291
  });
1245
- invariant4(this._peers.has(peer1), void 0, {
1292
+ invariant5(this._peers.has(peer1), void 0, {
1246
1293
  F: __dxlog_file5,
1247
1294
  L: 53,
1248
1295
  S: this,
@@ -1253,7 +1300,7 @@ var TestBuilder = class {
1253
1300
  });
1254
1301
  const connection1 = Array.from(peer1.connections).find((connection) => connection.remotePeerId.equals(peer2.peerId));
1255
1302
  const connection2 = Array.from(peer2.connections).find((connection) => connection.remotePeerId.equals(peer1.peerId));
1256
- invariant4(connection1, void 0, {
1303
+ invariant5(connection1, void 0, {
1257
1304
  F: __dxlog_file5,
1258
1305
  L: 62,
1259
1306
  S: this,
@@ -1262,7 +1309,7 @@ var TestBuilder = class {
1262
1309
  ""
1263
1310
  ]
1264
1311
  });
1265
- invariant4(connection2, void 0, {
1312
+ invariant5(connection2, void 0, {
1266
1313
  F: __dxlog_file5,
1267
1314
  L: 63,
1268
1315
  S: this,
@@ -1292,7 +1339,7 @@ var TestPeer = class {
1292
1339
  return connection;
1293
1340
  }
1294
1341
  async openConnection(connection) {
1295
- invariant4(this.connections.has(connection), void 0, {
1342
+ invariant5(this.connections.has(connection), void 0, {
1296
1343
  F: __dxlog_file5,
1297
1344
  L: 84,
1298
1345
  S: this,
@@ -1305,7 +1352,7 @@ var TestPeer = class {
1305
1352
  await this.onOpen(connection);
1306
1353
  }
1307
1354
  async closeConnection(connection) {
1308
- invariant4(this.connections.has(connection), void 0, {
1355
+ invariant5(this.connections.has(connection), void 0, {
1309
1356
  F: __dxlog_file5,
1310
1357
  L: 90,
1311
1358
  S: this,
@@ -1361,7 +1408,7 @@ var TestConnection = class {
1361
1408
 
1362
1409
  // packages/core/mesh/teleport/src/testing/test-extension.ts
1363
1410
  import { asyncTimeout as asyncTimeout2, Trigger as Trigger2 } from "@dxos/async";
1364
- import { invariant as invariant5 } from "@dxos/invariant";
1411
+ import { invariant as invariant6 } from "@dxos/invariant";
1365
1412
  import { log as log6 } from "@dxos/log";
1366
1413
  import { schema as schema3 } from "@dxos/protocols";
1367
1414
  import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
@@ -1447,7 +1494,7 @@ var TestExtension = class {
1447
1494
  const res = await asyncTimeout2(this._rpc.rpc.TestService.testCall({
1448
1495
  data: message
1449
1496
  }), 1500);
1450
- invariant5(res.data === message, void 0, {
1497
+ invariant6(res.data === message, void 0, {
1451
1498
  F: __dxlog_file6,
1452
1499
  L: 84,
1453
1500
  S: this,
@@ -1468,7 +1515,7 @@ var TestExtension = class {
1468
1515
  // packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts
1469
1516
  import { randomBytes } from "@dxos/node-std/crypto";
1470
1517
  import { Trigger as Trigger3 } from "@dxos/async";
1471
- import { invariant as invariant6 } from "@dxos/invariant";
1518
+ import { invariant as invariant7 } from "@dxos/invariant";
1472
1519
  import { log as log7 } from "@dxos/log";
1473
1520
  import { schema as schema4 } from "@dxos/protocols";
1474
1521
  import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
@@ -1485,7 +1532,7 @@ var TestExtensionWithStreams = class {
1485
1532
  return this.extensionContext?.remotePeerId;
1486
1533
  }
1487
1534
  async _openStream(streamTag, interval = 5, chunkSize = 2048) {
1488
- invariant6(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
1535
+ invariant7(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
1489
1536
  F: __dxlog_file7,
1490
1537
  L: 39,
1491
1538
  S: this,
@@ -1551,7 +1598,7 @@ var TestExtensionWithStreams = class {
1551
1598
  }, 100);
1552
1599
  }
1553
1600
  _closeStream(streamTag) {
1554
- invariant6(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
1601
+ invariant7(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
1555
1602
  F: __dxlog_file7,
1556
1603
  L: 106,
1557
1604
  S: this,
@@ -1674,7 +1721,7 @@ var TestExtensionWithStreams = class {
1674
1721
  streamLoadInterval,
1675
1722
  streamLoadChunkSize
1676
1723
  });
1677
- invariant6(data === streamTag, void 0, {
1724
+ invariant7(data === streamTag, void 0, {
1678
1725
  F: __dxlog_file7,
1679
1726
  L: 207,
1680
1727
  S: this,
@@ -1693,7 +1740,7 @@ var TestExtensionWithStreams = class {
1693
1740
  const { data, bytesSent, bytesReceived, sendErrors, receiveErrors, runningTime } = await this._rpc.rpc.TestServiceWithStreams.closeTestStream({
1694
1741
  data: streamTag
1695
1742
  });
1696
- invariant6(data === streamTag, void 0, {
1743
+ invariant7(data === streamTag, void 0, {
1697
1744
  F: __dxlog_file7,
1698
1745
  L: 220,
1699
1746
  S: this,
@@ -1737,4 +1784,4 @@ export {
1737
1784
  TestExtension,
1738
1785
  TestExtensionWithStreams
1739
1786
  };
1740
- //# sourceMappingURL=chunk-ZKGQBIY6.mjs.map
1787
+ //# sourceMappingURL=chunk-VXXLKKBF.mjs.map