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

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