@dxos/teleport 0.3.5-main.fa2fc5b → 0.3.5-next.63b0922

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(channelId).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(channelId) {
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;
@@ -398,9 +441,9 @@ var Muxer = class {
398
441
  tag,
399
442
  contentType: opts.contentType
400
443
  });
401
- invariant2(!channel.push, `Channel already open: ${tag}`, {
444
+ invariant3(!channel.push, `Channel already open: ${tag}`, {
402
445
  F: __dxlog_file3,
403
- L: 138,
446
+ L: 141,
404
447
  S: this,
405
448
  A: [
406
449
  "!channel.push",
@@ -446,9 +489,9 @@ var Muxer = class {
446
489
  tag,
447
490
  contentType: opts.contentType
448
491
  });
449
- invariant2(!channel.push, `Channel already open: ${tag}`, {
492
+ invariant3(!channel.push, `Channel already open: ${tag}`, {
450
493
  F: __dxlog_file3,
451
- L: 190,
494
+ L: 193,
452
495
  S: this,
453
496
  A: [
454
497
  "!channel.push",
@@ -466,13 +509,13 @@ var Muxer = class {
466
509
  }
467
510
  };
468
511
  const port = {
469
- send: async (data) => {
470
- await this._sendData(channel, data);
512
+ send: async (data, timeout) => {
513
+ await this._sendData(channel, data, timeout);
471
514
  },
472
515
  subscribe: (cb) => {
473
- invariant2(!callback, "Only one subscriber is allowed", {
516
+ invariant3(!callback, "Only one subscriber is allowed", {
474
517
  F: __dxlog_file3,
475
- L: 212,
518
+ L: 215,
476
519
  S: this,
477
520
  A: [
478
521
  "!callback",
@@ -505,7 +548,7 @@ var Muxer = class {
505
548
  if (this._destroying) {
506
549
  log3("already destroying, ignoring graceful close request", void 0, {
507
550
  F: __dxlog_file3,
508
- L: 245,
551
+ L: 248,
509
552
  S: this,
510
553
  C: (f, a) => f(...a)
511
554
  });
@@ -514,7 +557,7 @@ var Muxer = class {
514
557
  if (this._closing) {
515
558
  log3("already closing, ignoring graceful close request", void 0, {
516
559
  F: __dxlog_file3,
517
- L: 249,
560
+ L: 252,
518
561
  S: this,
519
562
  C: (f, a) => f(...a)
520
563
  });
@@ -525,12 +568,12 @@ var Muxer = class {
525
568
  close: {
526
569
  error: err?.message
527
570
  }
528
- }, SYSTEM_CHANNEL_ID).catch(async (err2) => {
571
+ }, SYSTEM_CHANNEL_ID, DESTROY_COMMAND_SEND_TIMEOUT).catch(async (err2) => {
529
572
  log3("error sending close command", {
530
573
  err: err2
531
574
  }, {
532
575
  F: __dxlog_file3,
533
- L: 263,
576
+ L: 267,
534
577
  S: this,
535
578
  C: (f, a) => f(...a)
536
579
  });
@@ -552,7 +595,7 @@ var Muxer = class {
552
595
  if (this._destroying) {
553
596
  log3("already destroying, ignoring destroy request", void 0, {
554
597
  F: __dxlog_file3,
555
- L: 284,
598
+ L: 288,
556
599
  S: this,
557
600
  C: (f, a) => f(...a)
558
601
  });
@@ -563,7 +606,7 @@ var Muxer = class {
563
606
  if (this._closing) {
564
607
  log3("destroy cancelling graceful close", void 0, {
565
608
  F: __dxlog_file3,
566
- L: 290,
609
+ L: 294,
567
610
  S: this,
568
611
  C: (f, a) => f(...a)
569
612
  });
@@ -578,7 +621,7 @@ var Muxer = class {
578
621
  err: err2
579
622
  }, {
580
623
  F: __dxlog_file3,
581
- L: 303,
624
+ L: 307,
582
625
  S: this,
583
626
  C: (f, a) => f(...a)
584
627
  });
@@ -589,7 +632,7 @@ var Muxer = class {
589
632
  err: err2
590
633
  }, {
591
634
  F: __dxlog_file3,
592
- L: 308,
635
+ L: 312,
593
636
  S: this,
594
637
  C: (f, a) => f(...a)
595
638
  });
@@ -600,7 +643,7 @@ var Muxer = class {
600
643
  if (this._destroyed) {
601
644
  log3("already destroyed, ignoring dispose request", void 0, {
602
645
  F: __dxlog_file3,
603
- L: 316,
646
+ L: 320,
604
647
  S: this,
605
648
  C: (f, a) => f(...a)
606
649
  });
@@ -622,7 +665,7 @@ var Muxer = class {
622
665
  cmd
623
666
  }, {
624
667
  F: __dxlog_file3,
625
- L: 338,
668
+ L: 342,
626
669
  S: this,
627
670
  C: (f, a) => f(...a)
628
671
  });
@@ -632,7 +675,7 @@ var Muxer = class {
632
675
  if (!this._closing) {
633
676
  log3("received peer close, initiating my own graceful close", void 0, {
634
677
  F: __dxlog_file3,
635
- L: 344,
678
+ L: 348,
636
679
  S: this,
637
680
  C: (f, a) => f(...a)
638
681
  });
@@ -640,7 +683,7 @@ var Muxer = class {
640
683
  } else {
641
684
  log3("received close from peer, already closing", void 0, {
642
685
  F: __dxlog_file3,
643
- L: 347,
686
+ L: 351,
644
687
  S: this,
645
688
  C: (f, a) => f(...a)
646
689
  });
@@ -669,7 +712,7 @@ var Muxer = class {
669
712
  tag: stream.tag
670
713
  }, {
671
714
  F: __dxlog_file3,
672
- L: 376,
715
+ L: 380,
673
716
  S: this,
674
717
  C: (f, a) => f(...a)
675
718
  });
@@ -678,11 +721,13 @@ var Muxer = class {
678
721
  stream.push(cmd.data.data);
679
722
  }
680
723
  }
681
- async _sendCommand(cmd, channelId = -1) {
724
+ async _sendCommand(cmd, channelId = -1, timeout = DEFAULT_SEND_COMMAND_TIMEOUT) {
682
725
  try {
683
726
  const trigger = new Trigger();
684
727
  this._balancer.pushData(Command.encode(cmd), trigger, channelId);
685
- await trigger.wait();
728
+ await trigger.wait({
729
+ timeout
730
+ });
686
731
  } catch (err) {
687
732
  await this.destroy(err);
688
733
  }
@@ -709,14 +754,14 @@ var Muxer = class {
709
754
  }
710
755
  return channel;
711
756
  }
712
- async _sendData(channel, data) {
757
+ async _sendData(channel, data, timeout) {
713
758
  if (data.length > MAX_SAFE_FRAME_SIZE) {
714
759
  log3.warn("frame size exceeds maximum safe value", {
715
760
  size: data.length,
716
761
  threshold: MAX_SAFE_FRAME_SIZE
717
762
  }, {
718
763
  F: __dxlog_file3,
719
- L: 419,
764
+ L: 423,
720
765
  S: this,
721
766
  C: (f, a) => f(...a)
722
767
  });
@@ -731,7 +776,7 @@ var Muxer = class {
731
776
  channelId: channel.remoteId,
732
777
  data
733
778
  }
734
- }, channel.id);
779
+ }, channel.id, timeout);
735
780
  }
736
781
  _destroyChannel(channel, err) {
737
782
  if (channel.destroy) {
@@ -794,6 +839,8 @@ function _ts_decorate(decorators, target, key, desc) {
794
839
  return c > 3 && r && Object.defineProperty(target, key, r), r;
795
840
  }
796
841
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/teleport.ts";
842
+ var CONTROL_HEARTBEAT_INTERVAL = 1e4;
843
+ var CONTROL_HEARTBEAT_TIMEOUT = 6e4;
797
844
  var Teleport = class {
798
845
  constructor({ initiator, localPeerId, remotePeerId }) {
799
846
  this._ctx = new Context2({
@@ -801,7 +848,7 @@ var Teleport = class {
801
848
  void this.destroy(err).catch(() => {
802
849
  log4.error("Error during destroy", err, {
803
850
  F: __dxlog_file4,
804
- L: 44,
851
+ L: 47,
805
852
  S: this,
806
853
  C: (f, a) => f(...a)
807
854
  });
@@ -810,21 +857,21 @@ var Teleport = class {
810
857
  });
811
858
  this._muxer = new Muxer();
812
859
  this._control = new ControlExtension({
813
- heartbeatInterval: 1e4,
814
- heartbeatTimeout: 1e4,
860
+ heartbeatInterval: CONTROL_HEARTBEAT_INTERVAL,
861
+ heartbeatTimeout: CONTROL_HEARTBEAT_TIMEOUT,
815
862
  onTimeout: () => {
816
863
  if (this._destroying || this._aborting) {
817
864
  return;
818
865
  }
819
- log4("destroy teleport due to onTimeout in ControlExtension", void 0, {
866
+ log4("abort teleport due to onTimeout in ControlExtension", void 0, {
820
867
  F: __dxlog_file4,
821
- L: 59,
868
+ L: 62,
822
869
  S: this,
823
870
  C: (f, a) => f(...a)
824
871
  });
825
- this.destroy(new TimeoutError2("control extension")).catch((err) => log4.catch(err, void 0, {
872
+ this.abort(new TimeoutError2("control extension")).catch((err) => log4.catch(err, void 0, {
826
873
  F: __dxlog_file4,
827
- L: 60,
874
+ L: 63,
828
875
  S: this,
829
876
  C: (f, a) => f(...a)
830
877
  }));
@@ -835,27 +882,27 @@ var Teleport = class {
835
882
  this._open = false;
836
883
  this._destroying = false;
837
884
  this._aborting = false;
838
- invariant3(typeof initiator === "boolean", void 0, {
885
+ invariant4(typeof initiator === "boolean", void 0, {
839
886
  F: __dxlog_file4,
840
- L: 72,
887
+ L: 75,
841
888
  S: this,
842
889
  A: [
843
890
  "typeof initiator === 'boolean'",
844
891
  ""
845
892
  ]
846
893
  });
847
- invariant3(PublicKey.isPublicKey(localPeerId), void 0, {
894
+ invariant4(PublicKey.isPublicKey(localPeerId), void 0, {
848
895
  F: __dxlog_file4,
849
- L: 73,
896
+ L: 76,
850
897
  S: this,
851
898
  A: [
852
899
  "PublicKey.isPublicKey(localPeerId)",
853
900
  ""
854
901
  ]
855
902
  });
856
- invariant3(PublicKey.isPublicKey(remotePeerId), void 0, {
903
+ invariant4(PublicKey.isPublicKey(remotePeerId), void 0, {
857
904
  F: __dxlog_file4,
858
- L: 74,
905
+ L: 77,
859
906
  S: this,
860
907
  A: [
861
908
  "PublicKey.isPublicKey(remotePeerId)",
@@ -870,13 +917,13 @@ var Teleport = class {
870
917
  name
871
918
  }, {
872
919
  F: __dxlog_file4,
873
- L: 80,
920
+ L: 83,
874
921
  S: this,
875
922
  C: (f, a) => f(...a)
876
923
  });
877
- invariant3(!this._remoteExtensions.has(name), "Remote extension already exists", {
924
+ invariant4(!this._remoteExtensions.has(name), "Remote extension already exists", {
878
925
  F: __dxlog_file4,
879
- L: 81,
926
+ L: 84,
880
927
  S: this,
881
928
  A: [
882
929
  "!this._remoteExtensions.has(name)",
@@ -897,7 +944,7 @@ var Teleport = class {
897
944
  if (this._destroying || this._aborting) {
898
945
  log4("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
899
946
  F: __dxlog_file4,
900
- L: 97,
947
+ L: 100,
901
948
  S: this,
902
949
  C: (f, a) => f(...a)
903
950
  });
@@ -920,7 +967,7 @@ var Teleport = class {
920
967
  channels: stats.channels
921
968
  }, {
922
969
  F: __dxlog_file4,
923
- L: 110,
970
+ L: 113,
924
971
  S: this,
925
972
  C: (f, a) => f(...a)
926
973
  });
@@ -958,7 +1005,7 @@ var Teleport = class {
958
1005
  } catch (err2) {
959
1006
  log4.catch(err2, void 0, {
960
1007
  F: __dxlog_file4,
961
- L: 163,
1008
+ L: 166,
962
1009
  S: this,
963
1010
  C: (f, a) => f(...a)
964
1011
  });
@@ -981,7 +1028,7 @@ var Teleport = class {
981
1028
  } catch (err2) {
982
1029
  log4.catch(err2, void 0, {
983
1030
  F: __dxlog_file4,
984
- L: 187,
1031
+ L: 190,
985
1032
  S: this,
986
1033
  C: (f, a) => f(...a)
987
1034
  });
@@ -997,7 +1044,7 @@ var Teleport = class {
997
1044
  name
998
1045
  }, {
999
1046
  F: __dxlog_file4,
1000
- L: 199,
1047
+ L: 202,
1001
1048
  S: this,
1002
1049
  C: (f, a) => f(...a)
1003
1050
  });
@@ -1019,18 +1066,18 @@ var Teleport = class {
1019
1066
  }
1020
1067
  }
1021
1068
  _setExtension(extensionName, extension) {
1022
- invariant3(!extensionName.includes("/"), "Invalid extension name", {
1069
+ invariant4(!extensionName.includes("/"), "Invalid extension name", {
1023
1070
  F: __dxlog_file4,
1024
- L: 223,
1071
+ L: 226,
1025
1072
  S: this,
1026
1073
  A: [
1027
1074
  "!extensionName.includes('/')",
1028
1075
  "'Invalid extension name'"
1029
1076
  ]
1030
1077
  });
1031
- invariant3(!this._extensions.has(extensionName), "Extension already exists", {
1078
+ invariant4(!this._extensions.has(extensionName), "Extension already exists", {
1032
1079
  F: __dxlog_file4,
1033
- L: 224,
1080
+ L: 227,
1034
1081
  S: this,
1035
1082
  A: [
1036
1083
  "!this._extensions.has(extensionName)",
@@ -1044,7 +1091,7 @@ var Teleport = class {
1044
1091
  extensionName
1045
1092
  }, {
1046
1093
  F: __dxlog_file4,
1047
- L: 229,
1094
+ L: 232,
1048
1095
  S: this,
1049
1096
  C: (f, a) => f(...a)
1050
1097
  });
@@ -1054,9 +1101,9 @@ var Teleport = class {
1054
1101
  localPeerId: this.localPeerId,
1055
1102
  remotePeerId: this.remotePeerId,
1056
1103
  createPort: async (channelName, opts) => {
1057
- invariant3(!channelName.includes("/"), "Invalid channel name", {
1104
+ invariant4(!channelName.includes("/"), "Invalid channel name", {
1058
1105
  F: __dxlog_file4,
1059
- L: 237,
1106
+ L: 240,
1060
1107
  S: this,
1061
1108
  A: [
1062
1109
  "!channelName.includes('/')",
@@ -1066,9 +1113,9 @@ var Teleport = class {
1066
1113
  return this._muxer.createPort(`${extensionName}/${channelName}`, opts);
1067
1114
  },
1068
1115
  createStream: async (channelName, opts) => {
1069
- invariant3(!channelName.includes("/"), "Invalid channel name", {
1116
+ invariant4(!channelName.includes("/"), "Invalid channel name", {
1070
1117
  F: __dxlog_file4,
1071
- L: 241,
1118
+ L: 244,
1072
1119
  S: this,
1073
1120
  A: [
1074
1121
  "!channelName.includes('/')",
@@ -1088,7 +1135,7 @@ var Teleport = class {
1088
1135
  extensionName
1089
1136
  }, {
1090
1137
  F: __dxlog_file4,
1091
- L: 252,
1138
+ L: 255,
1092
1139
  S: this,
1093
1140
  C: (f, a) => f(...a)
1094
1141
  });
@@ -1176,7 +1223,7 @@ var TestBuilder = class {
1176
1223
  await Promise.all(Array.from(this._peers).map((agent) => agent.destroy()));
1177
1224
  }
1178
1225
  async connect(peer1, peer2) {
1179
- invariant4(peer1 !== peer2, void 0, {
1226
+ invariant5(peer1 !== peer2, void 0, {
1180
1227
  F: __dxlog_file5,
1181
1228
  L: 37,
1182
1229
  S: this,
@@ -1185,7 +1232,7 @@ var TestBuilder = class {
1185
1232
  ""
1186
1233
  ]
1187
1234
  });
1188
- invariant4(this._peers.has(peer1), void 0, {
1235
+ invariant5(this._peers.has(peer1), void 0, {
1189
1236
  F: __dxlog_file5,
1190
1237
  L: 38,
1191
1238
  S: this,
@@ -1194,7 +1241,7 @@ var TestBuilder = class {
1194
1241
  ""
1195
1242
  ]
1196
1243
  });
1197
- invariant4(this._peers.has(peer1), void 0, {
1244
+ invariant5(this._peers.has(peer1), void 0, {
1198
1245
  F: __dxlog_file5,
1199
1246
  L: 39,
1200
1247
  S: this,
@@ -1222,7 +1269,7 @@ var TestBuilder = class {
1222
1269
  ];
1223
1270
  }
1224
1271
  async disconnect(peer1, peer2) {
1225
- invariant4(peer1 !== peer2, void 0, {
1272
+ invariant5(peer1 !== peer2, void 0, {
1226
1273
  F: __dxlog_file5,
1227
1274
  L: 51,
1228
1275
  S: this,
@@ -1231,7 +1278,7 @@ var TestBuilder = class {
1231
1278
  ""
1232
1279
  ]
1233
1280
  });
1234
- invariant4(this._peers.has(peer1), void 0, {
1281
+ invariant5(this._peers.has(peer1), void 0, {
1235
1282
  F: __dxlog_file5,
1236
1283
  L: 52,
1237
1284
  S: this,
@@ -1240,7 +1287,7 @@ var TestBuilder = class {
1240
1287
  ""
1241
1288
  ]
1242
1289
  });
1243
- invariant4(this._peers.has(peer1), void 0, {
1290
+ invariant5(this._peers.has(peer1), void 0, {
1244
1291
  F: __dxlog_file5,
1245
1292
  L: 53,
1246
1293
  S: this,
@@ -1251,7 +1298,7 @@ var TestBuilder = class {
1251
1298
  });
1252
1299
  const connection1 = Array.from(peer1.connections).find((connection) => connection.remotePeerId.equals(peer2.peerId));
1253
1300
  const connection2 = Array.from(peer2.connections).find((connection) => connection.remotePeerId.equals(peer1.peerId));
1254
- invariant4(connection1, void 0, {
1301
+ invariant5(connection1, void 0, {
1255
1302
  F: __dxlog_file5,
1256
1303
  L: 62,
1257
1304
  S: this,
@@ -1260,7 +1307,7 @@ var TestBuilder = class {
1260
1307
  ""
1261
1308
  ]
1262
1309
  });
1263
- invariant4(connection2, void 0, {
1310
+ invariant5(connection2, void 0, {
1264
1311
  F: __dxlog_file5,
1265
1312
  L: 63,
1266
1313
  S: this,
@@ -1290,7 +1337,7 @@ var TestPeer = class {
1290
1337
  return connection;
1291
1338
  }
1292
1339
  async openConnection(connection) {
1293
- invariant4(this.connections.has(connection), void 0, {
1340
+ invariant5(this.connections.has(connection), void 0, {
1294
1341
  F: __dxlog_file5,
1295
1342
  L: 84,
1296
1343
  S: this,
@@ -1303,7 +1350,7 @@ var TestPeer = class {
1303
1350
  await this.onOpen(connection);
1304
1351
  }
1305
1352
  async closeConnection(connection) {
1306
- invariant4(this.connections.has(connection), void 0, {
1353
+ invariant5(this.connections.has(connection), void 0, {
1307
1354
  F: __dxlog_file5,
1308
1355
  L: 90,
1309
1356
  S: this,
@@ -1359,7 +1406,7 @@ var TestConnection = class {
1359
1406
 
1360
1407
  // packages/core/mesh/teleport/src/testing/test-extension.ts
1361
1408
  import { asyncTimeout as asyncTimeout2, Trigger as Trigger2 } from "@dxos/async";
1362
- import { invariant as invariant5 } from "@dxos/invariant";
1409
+ import { invariant as invariant6 } from "@dxos/invariant";
1363
1410
  import { log as log6 } from "@dxos/log";
1364
1411
  import { schema as schema3 } from "@dxos/protocols";
1365
1412
  import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
@@ -1445,7 +1492,7 @@ var TestExtension = class {
1445
1492
  const res = await asyncTimeout2(this._rpc.rpc.TestService.testCall({
1446
1493
  data: message
1447
1494
  }), 1500);
1448
- invariant5(res.data === message, void 0, {
1495
+ invariant6(res.data === message, void 0, {
1449
1496
  F: __dxlog_file6,
1450
1497
  L: 84,
1451
1498
  S: this,
@@ -1466,7 +1513,7 @@ var TestExtension = class {
1466
1513
  // packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts
1467
1514
  import { randomBytes } from "@dxos/node-std/crypto";
1468
1515
  import { Trigger as Trigger3 } from "@dxos/async";
1469
- import { invariant as invariant6 } from "@dxos/invariant";
1516
+ import { invariant as invariant7 } from "@dxos/invariant";
1470
1517
  import { log as log7 } from "@dxos/log";
1471
1518
  import { schema as schema4 } from "@dxos/protocols";
1472
1519
  import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
@@ -1483,7 +1530,7 @@ var TestExtensionWithStreams = class {
1483
1530
  return this.extensionContext?.remotePeerId;
1484
1531
  }
1485
1532
  async _openStream(streamTag, interval = 5, chunkSize = 2048) {
1486
- invariant6(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
1533
+ invariant7(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
1487
1534
  F: __dxlog_file7,
1488
1535
  L: 39,
1489
1536
  S: this,
@@ -1549,7 +1596,7 @@ var TestExtensionWithStreams = class {
1549
1596
  }, 100);
1550
1597
  }
1551
1598
  _closeStream(streamTag) {
1552
- invariant6(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
1599
+ invariant7(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
1553
1600
  F: __dxlog_file7,
1554
1601
  L: 106,
1555
1602
  S: this,
@@ -1672,7 +1719,7 @@ var TestExtensionWithStreams = class {
1672
1719
  streamLoadInterval,
1673
1720
  streamLoadChunkSize
1674
1721
  });
1675
- invariant6(data === streamTag, void 0, {
1722
+ invariant7(data === streamTag, void 0, {
1676
1723
  F: __dxlog_file7,
1677
1724
  L: 207,
1678
1725
  S: this,
@@ -1691,7 +1738,7 @@ var TestExtensionWithStreams = class {
1691
1738
  const { data, bytesSent, bytesReceived, sendErrors, receiveErrors, runningTime } = await this._rpc.rpc.TestServiceWithStreams.closeTestStream({
1692
1739
  data: streamTag
1693
1740
  });
1694
- invariant6(data === streamTag, void 0, {
1741
+ invariant7(data === streamTag, void 0, {
1695
1742
  F: __dxlog_file7,
1696
1743
  L: 220,
1697
1744
  S: this,
@@ -1735,4 +1782,4 @@ export {
1735
1782
  TestExtension,
1736
1783
  TestExtensionWithStreams
1737
1784
  };
1738
- //# sourceMappingURL=chunk-PWWDYMDW.mjs.map
1785
+ //# sourceMappingURL=chunk-NRNKGCJ5.mjs.map