@dxos/teleport 0.1.55 → 0.1.56-main.09ca29d
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.
- package/dist/lib/browser/{chunk-WUEX3RV3.mjs → chunk-3FNN6ZOF.mjs} +295 -67
- package/dist/lib/browser/chunk-3FNN6ZOF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +12 -3
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +305 -68
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +294 -66
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/muxing/framer.d.ts.map +1 -1
- package/dist/types/src/muxing/muxer.d.ts.map +1 -1
- package/dist/types/src/rpc-extension.d.ts.map +1 -1
- package/dist/types/src/teleport.d.ts.map +1 -1
- package/dist/types/src/testing/test-extension-with-streams.d.ts.map +1 -1
- package/dist/types/src/testing/test-extension.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/muxing/framer.ts +2 -1
- package/src/muxing/muxer.ts +5 -1
- package/src/rpc-extension.ts +1 -2
- package/src/teleport.ts +1 -1
- package/src/testing/test-builder.ts +1 -1
- package/src/testing/test-extension-with-streams.ts +5 -5
- package/src/testing/test-extension.ts +1 -2
- package/dist/lib/browser/chunk-WUEX3RV3.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -46,7 +46,8 @@ module.exports = __toCommonJS(src_exports);
|
|
|
46
46
|
|
|
47
47
|
// packages/core/mesh/teleport/src/muxing/framer.ts
|
|
48
48
|
var import_node_stream = require("node:stream");
|
|
49
|
-
var
|
|
49
|
+
var import_invariant = require("@dxos/invariant");
|
|
50
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/framer.ts";
|
|
50
51
|
var FRAME_LENGTH_SIZE = 2;
|
|
51
52
|
var Framer = class {
|
|
52
53
|
constructor() {
|
|
@@ -59,7 +60,15 @@ var Framer = class {
|
|
|
59
60
|
this._processResponseQueue();
|
|
60
61
|
},
|
|
61
62
|
write: (chunk, encoding, callback) => {
|
|
62
|
-
(0,
|
|
63
|
+
(0, import_invariant.invariant)(!this._subscribeCb, "Internal Framer bug. Concurrent writes detected.", {
|
|
64
|
+
F: __dxlog_file,
|
|
65
|
+
L: 34,
|
|
66
|
+
S: this,
|
|
67
|
+
A: [
|
|
68
|
+
"!this._subscribeCb",
|
|
69
|
+
"'Internal Framer bug. Concurrent writes detected.'"
|
|
70
|
+
]
|
|
71
|
+
});
|
|
63
72
|
this._bytesReceived += chunk.length;
|
|
64
73
|
if (this._buffer && this._buffer.length > 0) {
|
|
65
74
|
this._buffer = Buffer.concat([
|
|
@@ -96,7 +105,15 @@ var Framer = class {
|
|
|
96
105
|
},
|
|
97
106
|
subscribe: (callback) => {
|
|
98
107
|
var _a;
|
|
99
|
-
(0,
|
|
108
|
+
(0, import_invariant.invariant)(!this._messageCb, "Rpc port already has a message listener.", {
|
|
109
|
+
F: __dxlog_file,
|
|
110
|
+
L: 73,
|
|
111
|
+
S: this,
|
|
112
|
+
A: [
|
|
113
|
+
"!this._messageCb",
|
|
114
|
+
"'Rpc port already has a message listener.'"
|
|
115
|
+
]
|
|
116
|
+
});
|
|
100
117
|
this._messageCb = callback;
|
|
101
118
|
(_a = this._subscribeCb) == null ? void 0 : _a.call(this);
|
|
102
119
|
return () => {
|
|
@@ -166,10 +183,10 @@ var encodeFrame = (payload) => {
|
|
|
166
183
|
|
|
167
184
|
// packages/core/mesh/teleport/src/muxing/muxer.ts
|
|
168
185
|
var import_node_stream2 = require("node:stream");
|
|
169
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
170
186
|
var import_async2 = require("@dxos/async");
|
|
171
187
|
var import_context = require("@dxos/context");
|
|
172
188
|
var import_debug = require("@dxos/debug");
|
|
189
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
173
190
|
var import_log2 = require("@dxos/log");
|
|
174
191
|
var import_protocols = require("@dxos/protocols");
|
|
175
192
|
|
|
@@ -177,7 +194,7 @@ var import_protocols = require("@dxos/protocols");
|
|
|
177
194
|
var varint = __toESM(require("varint"));
|
|
178
195
|
var import_async = require("@dxos/async");
|
|
179
196
|
var import_log = require("@dxos/log");
|
|
180
|
-
var
|
|
197
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/balancer.ts";
|
|
181
198
|
var MAX_CHUNK_SIZE = 8192;
|
|
182
199
|
var Balancer = class {
|
|
183
200
|
constructor(_sysChannelId) {
|
|
@@ -227,7 +244,7 @@ var Balancer = class {
|
|
|
227
244
|
});
|
|
228
245
|
if (noCalls) {
|
|
229
246
|
this._sendChunks().catch((err) => import_log.log.catch(err, void 0, {
|
|
230
|
-
F:
|
|
247
|
+
F: __dxlog_file2,
|
|
231
248
|
L: 96,
|
|
232
249
|
S: this,
|
|
233
250
|
C: (f, a) => f(...a)
|
|
@@ -329,7 +346,7 @@ var decodeChunk = (data, withLength) => {
|
|
|
329
346
|
};
|
|
330
347
|
|
|
331
348
|
// packages/core/mesh/teleport/src/muxing/muxer.ts
|
|
332
|
-
var
|
|
349
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/muxer.ts";
|
|
333
350
|
var Command = import_protocols.schema.getCodecForType("dxos.mesh.muxer.Command");
|
|
334
351
|
var STATS_INTERVAL = 1e3;
|
|
335
352
|
var MAX_SAFE_FRAME_SIZE = 1e6;
|
|
@@ -362,7 +379,15 @@ var Muxer = class {
|
|
|
362
379
|
tag,
|
|
363
380
|
contentType: opts.contentType
|
|
364
381
|
});
|
|
365
|
-
(0,
|
|
382
|
+
(0, import_invariant2.invariant)(!channel.push, `Channel already open: ${tag}`, {
|
|
383
|
+
F: __dxlog_file3,
|
|
384
|
+
L: 91,
|
|
385
|
+
S: this,
|
|
386
|
+
A: [
|
|
387
|
+
"!channel.push",
|
|
388
|
+
"`Channel already open: ${tag}`"
|
|
389
|
+
]
|
|
390
|
+
});
|
|
366
391
|
const stream = new import_node_stream2.Duplex({
|
|
367
392
|
write: (data, encoding, callback) => {
|
|
368
393
|
this._sendData(channel, data).then(() => callback()).catch(callback);
|
|
@@ -402,7 +427,15 @@ var Muxer = class {
|
|
|
402
427
|
tag,
|
|
403
428
|
contentType: opts.contentType
|
|
404
429
|
});
|
|
405
|
-
(0,
|
|
430
|
+
(0, import_invariant2.invariant)(!channel.push, `Channel already open: ${tag}`, {
|
|
431
|
+
F: __dxlog_file3,
|
|
432
|
+
L: 143,
|
|
433
|
+
S: this,
|
|
434
|
+
A: [
|
|
435
|
+
"!channel.push",
|
|
436
|
+
"`Channel already open: ${tag}`"
|
|
437
|
+
]
|
|
438
|
+
});
|
|
406
439
|
let inboundBuffer = [];
|
|
407
440
|
let callback;
|
|
408
441
|
channel.push = (data) => {
|
|
@@ -418,7 +451,15 @@ var Muxer = class {
|
|
|
418
451
|
await this._sendData(channel, data);
|
|
419
452
|
},
|
|
420
453
|
subscribe: (cb) => {
|
|
421
|
-
(0,
|
|
454
|
+
(0, import_invariant2.invariant)(!callback, "Only one subscriber is allowed", {
|
|
455
|
+
F: __dxlog_file3,
|
|
456
|
+
L: 165,
|
|
457
|
+
S: this,
|
|
458
|
+
A: [
|
|
459
|
+
"!callback",
|
|
460
|
+
"'Only one subscriber is allowed'"
|
|
461
|
+
]
|
|
462
|
+
});
|
|
422
463
|
callback = cb;
|
|
423
464
|
for (const data of inboundBuffer) {
|
|
424
465
|
cb(data);
|
|
@@ -478,17 +519,20 @@ var Muxer = class {
|
|
|
478
519
|
(0, import_log2.log)("Received command", {
|
|
479
520
|
cmd
|
|
480
521
|
}, {
|
|
481
|
-
F:
|
|
522
|
+
F: __dxlog_file3,
|
|
482
523
|
L: 240,
|
|
483
524
|
S: this,
|
|
484
525
|
C: (f, a) => f(...a)
|
|
485
526
|
});
|
|
486
527
|
if (this._destroyed || this._destroying) {
|
|
528
|
+
if (cmd.destroy) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
487
531
|
import_log2.log.warn("Received command after destroy", {
|
|
488
532
|
cmd
|
|
489
533
|
}, {
|
|
490
|
-
F:
|
|
491
|
-
L:
|
|
534
|
+
F: __dxlog_file3,
|
|
535
|
+
L: 247,
|
|
492
536
|
S: this,
|
|
493
537
|
C: (f, a) => f(...a)
|
|
494
538
|
});
|
|
@@ -515,8 +559,8 @@ var Muxer = class {
|
|
|
515
559
|
import_log2.log.warn("Received data for channel before it was opened", {
|
|
516
560
|
tag: stream.tag
|
|
517
561
|
}, {
|
|
518
|
-
F:
|
|
519
|
-
L:
|
|
562
|
+
F: __dxlog_file3,
|
|
563
|
+
L: 274,
|
|
520
564
|
S: this,
|
|
521
565
|
C: (f, a) => f(...a)
|
|
522
566
|
});
|
|
@@ -564,8 +608,8 @@ var Muxer = class {
|
|
|
564
608
|
size: data.length,
|
|
565
609
|
threshold: MAX_SAFE_FRAME_SIZE
|
|
566
610
|
}, {
|
|
567
|
-
F:
|
|
568
|
-
L:
|
|
611
|
+
F: __dxlog_file3,
|
|
612
|
+
L: 318,
|
|
569
613
|
S: this,
|
|
570
614
|
C: (f, a) => f(...a)
|
|
571
615
|
});
|
|
@@ -610,10 +654,10 @@ var Muxer = class {
|
|
|
610
654
|
};
|
|
611
655
|
|
|
612
656
|
// packages/core/mesh/teleport/src/teleport.ts
|
|
613
|
-
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
614
657
|
var import_async3 = require("@dxos/async");
|
|
615
658
|
var import_context2 = require("@dxos/context");
|
|
616
659
|
var import_debug2 = require("@dxos/debug");
|
|
660
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
617
661
|
var import_keys = require("@dxos/keys");
|
|
618
662
|
var import_log3 = require("@dxos/log");
|
|
619
663
|
var import_protocols2 = require("@dxos/protocols");
|
|
@@ -629,14 +673,14 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
629
673
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
630
674
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
631
675
|
}
|
|
632
|
-
var
|
|
676
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/teleport.ts";
|
|
633
677
|
var Teleport = class {
|
|
634
678
|
constructor({ initiator, localPeerId, remotePeerId }) {
|
|
635
679
|
this._ctx = new import_context2.Context({
|
|
636
680
|
onError: (err) => {
|
|
637
681
|
void this.destroy(err).catch(() => {
|
|
638
682
|
import_log3.log.error("Error during destroy", err, {
|
|
639
|
-
F:
|
|
683
|
+
F: __dxlog_file4,
|
|
640
684
|
L: 34,
|
|
641
685
|
S: this,
|
|
642
686
|
C: (f, a) => f(...a)
|
|
@@ -650,7 +694,7 @@ var Teleport = class {
|
|
|
650
694
|
heartbeatTimeout: 1e4,
|
|
651
695
|
onTimeout: () => {
|
|
652
696
|
this.destroy(new Error("Connection timed out")).catch((err) => import_log3.log.catch(err, void 0, {
|
|
653
|
-
F:
|
|
697
|
+
F: __dxlog_file4,
|
|
654
698
|
L: 45,
|
|
655
699
|
S: this,
|
|
656
700
|
C: (f, a) => f(...a)
|
|
@@ -660,9 +704,33 @@ var Teleport = class {
|
|
|
660
704
|
this._extensions = /* @__PURE__ */ new Map();
|
|
661
705
|
this._remoteExtensions = /* @__PURE__ */ new Set();
|
|
662
706
|
this._open = false;
|
|
663
|
-
(0,
|
|
664
|
-
|
|
665
|
-
|
|
707
|
+
(0, import_invariant3.invariant)(typeof initiator === "boolean", void 0, {
|
|
708
|
+
F: __dxlog_file4,
|
|
709
|
+
L: 55,
|
|
710
|
+
S: this,
|
|
711
|
+
A: [
|
|
712
|
+
"typeof initiator === 'boolean'",
|
|
713
|
+
""
|
|
714
|
+
]
|
|
715
|
+
});
|
|
716
|
+
(0, import_invariant3.invariant)(import_keys.PublicKey.isPublicKey(localPeerId), void 0, {
|
|
717
|
+
F: __dxlog_file4,
|
|
718
|
+
L: 56,
|
|
719
|
+
S: this,
|
|
720
|
+
A: [
|
|
721
|
+
"PublicKey.isPublicKey(localPeerId)",
|
|
722
|
+
""
|
|
723
|
+
]
|
|
724
|
+
});
|
|
725
|
+
(0, import_invariant3.invariant)(import_keys.PublicKey.isPublicKey(remotePeerId), void 0, {
|
|
726
|
+
F: __dxlog_file4,
|
|
727
|
+
L: 57,
|
|
728
|
+
S: this,
|
|
729
|
+
A: [
|
|
730
|
+
"PublicKey.isPublicKey(remotePeerId)",
|
|
731
|
+
""
|
|
732
|
+
]
|
|
733
|
+
});
|
|
666
734
|
this.initiator = initiator;
|
|
667
735
|
this.localPeerId = localPeerId;
|
|
668
736
|
this.remotePeerId = remotePeerId;
|
|
@@ -670,12 +738,20 @@ var Teleport = class {
|
|
|
670
738
|
(0, import_log3.log)("remote extension", {
|
|
671
739
|
name
|
|
672
740
|
}, {
|
|
673
|
-
F:
|
|
741
|
+
F: __dxlog_file4,
|
|
674
742
|
L: 63,
|
|
675
743
|
S: this,
|
|
676
744
|
C: (f, a) => f(...a)
|
|
677
745
|
});
|
|
678
|
-
(0,
|
|
746
|
+
(0, import_invariant3.invariant)(!this._remoteExtensions.has(name), "Remote extension already exists", {
|
|
747
|
+
F: __dxlog_file4,
|
|
748
|
+
L: 64,
|
|
749
|
+
S: this,
|
|
750
|
+
A: [
|
|
751
|
+
"!this._remoteExtensions.has(name)",
|
|
752
|
+
"'Remote extension already exists'"
|
|
753
|
+
]
|
|
754
|
+
});
|
|
679
755
|
this._remoteExtensions.add(name);
|
|
680
756
|
if (this._extensions.has(name)) {
|
|
681
757
|
try {
|
|
@@ -701,7 +777,7 @@ var Teleport = class {
|
|
|
701
777
|
bytesReceived: stats.bytesReceived,
|
|
702
778
|
channels: stats.channels
|
|
703
779
|
}, {
|
|
704
|
-
F:
|
|
780
|
+
F: __dxlog_file4,
|
|
705
781
|
L: 88,
|
|
706
782
|
S: this,
|
|
707
783
|
C: (f, a) => f(...a)
|
|
@@ -735,7 +811,7 @@ var Teleport = class {
|
|
|
735
811
|
await extension.onClose(err);
|
|
736
812
|
} catch (err2) {
|
|
737
813
|
import_log3.log.catch(err2, void 0, {
|
|
738
|
-
F:
|
|
814
|
+
F: __dxlog_file4,
|
|
739
815
|
L: 132,
|
|
740
816
|
S: this,
|
|
741
817
|
C: (f, a) => f(...a)
|
|
@@ -751,7 +827,7 @@ var Teleport = class {
|
|
|
751
827
|
(0, import_log3.log)("addExtension", {
|
|
752
828
|
name
|
|
753
829
|
}, {
|
|
754
|
-
F:
|
|
830
|
+
F: __dxlog_file4,
|
|
755
831
|
L: 144,
|
|
756
832
|
S: this,
|
|
757
833
|
C: (f, a) => f(...a)
|
|
@@ -774,8 +850,24 @@ var Teleport = class {
|
|
|
774
850
|
}
|
|
775
851
|
}
|
|
776
852
|
_setExtension(extensionName, extension) {
|
|
777
|
-
(0,
|
|
778
|
-
|
|
853
|
+
(0, import_invariant3.invariant)(!extensionName.includes("/"), "Invalid extension name", {
|
|
854
|
+
F: __dxlog_file4,
|
|
855
|
+
L: 168,
|
|
856
|
+
S: this,
|
|
857
|
+
A: [
|
|
858
|
+
"!extensionName.includes('/')",
|
|
859
|
+
"'Invalid extension name'"
|
|
860
|
+
]
|
|
861
|
+
});
|
|
862
|
+
(0, import_invariant3.invariant)(!this._extensions.has(extensionName), "Extension already exists", {
|
|
863
|
+
F: __dxlog_file4,
|
|
864
|
+
L: 169,
|
|
865
|
+
S: this,
|
|
866
|
+
A: [
|
|
867
|
+
"!this._extensions.has(extensionName)",
|
|
868
|
+
"'Extension already exists'"
|
|
869
|
+
]
|
|
870
|
+
});
|
|
779
871
|
this._extensions.set(extensionName, extension);
|
|
780
872
|
}
|
|
781
873
|
async _openExtension(extensionName) {
|
|
@@ -783,7 +875,7 @@ var Teleport = class {
|
|
|
783
875
|
(0, import_log3.log)("open extension", {
|
|
784
876
|
extensionName
|
|
785
877
|
}, {
|
|
786
|
-
F:
|
|
878
|
+
F: __dxlog_file4,
|
|
787
879
|
L: 174,
|
|
788
880
|
S: this,
|
|
789
881
|
C: (f, a) => f(...a)
|
|
@@ -794,11 +886,27 @@ var Teleport = class {
|
|
|
794
886
|
localPeerId: this.localPeerId,
|
|
795
887
|
remotePeerId: this.remotePeerId,
|
|
796
888
|
createPort: async (channelName, opts) => {
|
|
797
|
-
(0,
|
|
889
|
+
(0, import_invariant3.invariant)(!channelName.includes("/"), "Invalid channel name", {
|
|
890
|
+
F: __dxlog_file4,
|
|
891
|
+
L: 182,
|
|
892
|
+
S: this,
|
|
893
|
+
A: [
|
|
894
|
+
"!channelName.includes('/')",
|
|
895
|
+
"'Invalid channel name'"
|
|
896
|
+
]
|
|
897
|
+
});
|
|
798
898
|
return this._muxer.createPort(`${extensionName}/${channelName}`, opts);
|
|
799
899
|
},
|
|
800
900
|
createStream: async (channelName, opts) => {
|
|
801
|
-
(0,
|
|
901
|
+
(0, import_invariant3.invariant)(!channelName.includes("/"), "Invalid channel name", {
|
|
902
|
+
F: __dxlog_file4,
|
|
903
|
+
L: 186,
|
|
904
|
+
S: this,
|
|
905
|
+
A: [
|
|
906
|
+
"!channelName.includes('/')",
|
|
907
|
+
"'Invalid channel name'"
|
|
908
|
+
]
|
|
909
|
+
});
|
|
802
910
|
return this._muxer.createStream(`${extensionName}/${channelName}`, opts);
|
|
803
911
|
},
|
|
804
912
|
close: (err) => {
|
|
@@ -811,7 +919,7 @@ var Teleport = class {
|
|
|
811
919
|
(0, import_log3.log)("extension opened", {
|
|
812
920
|
extensionName
|
|
813
921
|
}, {
|
|
814
|
-
F:
|
|
922
|
+
F: __dxlog_file4,
|
|
815
923
|
L: 197,
|
|
816
924
|
S: this,
|
|
817
925
|
C: (f, a) => f(...a)
|
|
@@ -875,10 +983,10 @@ var ControlExtension = class {
|
|
|
875
983
|
|
|
876
984
|
// packages/core/mesh/teleport/src/testing/test-builder.ts
|
|
877
985
|
var import_node_stream3 = require("node:stream");
|
|
878
|
-
var
|
|
986
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
879
987
|
var import_keys2 = require("@dxos/keys");
|
|
880
988
|
var import_log4 = require("@dxos/log");
|
|
881
|
-
var
|
|
989
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/testing/test-builder.ts";
|
|
882
990
|
var TestBuilder = class {
|
|
883
991
|
constructor() {
|
|
884
992
|
this._peers = /* @__PURE__ */ new Set();
|
|
@@ -897,9 +1005,33 @@ var TestBuilder = class {
|
|
|
897
1005
|
await Promise.all(Array.from(this._peers).map((agent) => agent.destroy()));
|
|
898
1006
|
}
|
|
899
1007
|
async connect(peer1, peer2) {
|
|
900
|
-
(0,
|
|
901
|
-
|
|
902
|
-
|
|
1008
|
+
(0, import_invariant4.invariant)(peer1 !== peer2, void 0, {
|
|
1009
|
+
F: __dxlog_file5,
|
|
1010
|
+
L: 37,
|
|
1011
|
+
S: this,
|
|
1012
|
+
A: [
|
|
1013
|
+
"peer1 !== peer2",
|
|
1014
|
+
""
|
|
1015
|
+
]
|
|
1016
|
+
});
|
|
1017
|
+
(0, import_invariant4.invariant)(this._peers.has(peer1), void 0, {
|
|
1018
|
+
F: __dxlog_file5,
|
|
1019
|
+
L: 38,
|
|
1020
|
+
S: this,
|
|
1021
|
+
A: [
|
|
1022
|
+
"this._peers.has(peer1)",
|
|
1023
|
+
""
|
|
1024
|
+
]
|
|
1025
|
+
});
|
|
1026
|
+
(0, import_invariant4.invariant)(this._peers.has(peer1), void 0, {
|
|
1027
|
+
F: __dxlog_file5,
|
|
1028
|
+
L: 39,
|
|
1029
|
+
S: this,
|
|
1030
|
+
A: [
|
|
1031
|
+
"this._peers.has(peer1)",
|
|
1032
|
+
""
|
|
1033
|
+
]
|
|
1034
|
+
});
|
|
903
1035
|
const connection1 = peer1.createConnection({
|
|
904
1036
|
initiator: true,
|
|
905
1037
|
remotePeerId: peer2.peerId
|
|
@@ -919,13 +1051,53 @@ var TestBuilder = class {
|
|
|
919
1051
|
];
|
|
920
1052
|
}
|
|
921
1053
|
async disconnect(peer1, peer2) {
|
|
922
|
-
(0,
|
|
923
|
-
|
|
924
|
-
|
|
1054
|
+
(0, import_invariant4.invariant)(peer1 !== peer2, void 0, {
|
|
1055
|
+
F: __dxlog_file5,
|
|
1056
|
+
L: 51,
|
|
1057
|
+
S: this,
|
|
1058
|
+
A: [
|
|
1059
|
+
"peer1 !== peer2",
|
|
1060
|
+
""
|
|
1061
|
+
]
|
|
1062
|
+
});
|
|
1063
|
+
(0, import_invariant4.invariant)(this._peers.has(peer1), void 0, {
|
|
1064
|
+
F: __dxlog_file5,
|
|
1065
|
+
L: 52,
|
|
1066
|
+
S: this,
|
|
1067
|
+
A: [
|
|
1068
|
+
"this._peers.has(peer1)",
|
|
1069
|
+
""
|
|
1070
|
+
]
|
|
1071
|
+
});
|
|
1072
|
+
(0, import_invariant4.invariant)(this._peers.has(peer1), void 0, {
|
|
1073
|
+
F: __dxlog_file5,
|
|
1074
|
+
L: 53,
|
|
1075
|
+
S: this,
|
|
1076
|
+
A: [
|
|
1077
|
+
"this._peers.has(peer1)",
|
|
1078
|
+
""
|
|
1079
|
+
]
|
|
1080
|
+
});
|
|
925
1081
|
const connection1 = Array.from(peer1.connections).find((connection) => connection.remotePeerId.equals(peer2.peerId));
|
|
926
1082
|
const connection2 = Array.from(peer2.connections).find((connection) => connection.remotePeerId.equals(peer1.peerId));
|
|
927
|
-
(0,
|
|
928
|
-
|
|
1083
|
+
(0, import_invariant4.invariant)(connection1, void 0, {
|
|
1084
|
+
F: __dxlog_file5,
|
|
1085
|
+
L: 62,
|
|
1086
|
+
S: this,
|
|
1087
|
+
A: [
|
|
1088
|
+
"connection1",
|
|
1089
|
+
""
|
|
1090
|
+
]
|
|
1091
|
+
});
|
|
1092
|
+
(0, import_invariant4.invariant)(connection2, void 0, {
|
|
1093
|
+
F: __dxlog_file5,
|
|
1094
|
+
L: 63,
|
|
1095
|
+
S: this,
|
|
1096
|
+
A: [
|
|
1097
|
+
"connection2",
|
|
1098
|
+
""
|
|
1099
|
+
]
|
|
1100
|
+
});
|
|
929
1101
|
await Promise.all([
|
|
930
1102
|
peer1.closeConnection(connection1),
|
|
931
1103
|
peer2.closeConnection(connection2)
|
|
@@ -947,12 +1119,28 @@ var TestPeer = class {
|
|
|
947
1119
|
return connection;
|
|
948
1120
|
}
|
|
949
1121
|
async openConnection(connection) {
|
|
950
|
-
(0,
|
|
1122
|
+
(0, import_invariant4.invariant)(this.connections.has(connection), void 0, {
|
|
1123
|
+
F: __dxlog_file5,
|
|
1124
|
+
L: 84,
|
|
1125
|
+
S: this,
|
|
1126
|
+
A: [
|
|
1127
|
+
"this.connections.has(connection)",
|
|
1128
|
+
""
|
|
1129
|
+
]
|
|
1130
|
+
});
|
|
951
1131
|
await connection.teleport.open();
|
|
952
1132
|
await this.onOpen(connection);
|
|
953
1133
|
}
|
|
954
1134
|
async closeConnection(connection) {
|
|
955
|
-
(0,
|
|
1135
|
+
(0, import_invariant4.invariant)(this.connections.has(connection), void 0, {
|
|
1136
|
+
F: __dxlog_file5,
|
|
1137
|
+
L: 90,
|
|
1138
|
+
S: this,
|
|
1139
|
+
A: [
|
|
1140
|
+
"this.connections.has(connection)",
|
|
1141
|
+
""
|
|
1142
|
+
]
|
|
1143
|
+
});
|
|
956
1144
|
await this.onClose(connection);
|
|
957
1145
|
await connection.teleport.close();
|
|
958
1146
|
this.connections.delete(connection);
|
|
@@ -967,7 +1155,7 @@ var pipeStreams = (stream1, stream2) => {
|
|
|
967
1155
|
(0, import_node_stream3.pipeline)(stream1, stream2, (err) => {
|
|
968
1156
|
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
969
1157
|
import_log4.log.catch(err, void 0, {
|
|
970
|
-
F:
|
|
1158
|
+
F: __dxlog_file5,
|
|
971
1159
|
L: 106,
|
|
972
1160
|
S: void 0,
|
|
973
1161
|
C: (f, a) => f(...a)
|
|
@@ -977,7 +1165,7 @@ var pipeStreams = (stream1, stream2) => {
|
|
|
977
1165
|
(0, import_node_stream3.pipeline)(stream2, stream1, (err) => {
|
|
978
1166
|
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
979
1167
|
import_log4.log.catch(err, void 0, {
|
|
980
|
-
F:
|
|
1168
|
+
F: __dxlog_file5,
|
|
981
1169
|
L: 111,
|
|
982
1170
|
S: void 0,
|
|
983
1171
|
C: (f, a) => f(...a)
|
|
@@ -999,12 +1187,12 @@ var TestConnection = class {
|
|
|
999
1187
|
};
|
|
1000
1188
|
|
|
1001
1189
|
// packages/core/mesh/teleport/src/testing/test-extension.ts
|
|
1002
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
1003
1190
|
var import_async4 = require("@dxos/async");
|
|
1191
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
1004
1192
|
var import_log5 = require("@dxos/log");
|
|
1005
1193
|
var import_protocols3 = require("@dxos/protocols");
|
|
1006
1194
|
var import_rpc2 = require("@dxos/rpc");
|
|
1007
|
-
var
|
|
1195
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/testing/test-extension.ts";
|
|
1008
1196
|
var TestExtension = class {
|
|
1009
1197
|
constructor(callbacks = {}) {
|
|
1010
1198
|
this.callbacks = callbacks;
|
|
@@ -1021,8 +1209,8 @@ var TestExtension = class {
|
|
|
1021
1209
|
localPeerId: context.localPeerId,
|
|
1022
1210
|
remotePeerId: context.remotePeerId
|
|
1023
1211
|
}, {
|
|
1024
|
-
F:
|
|
1025
|
-
L:
|
|
1212
|
+
F: __dxlog_file6,
|
|
1213
|
+
L: 32,
|
|
1026
1214
|
S: this,
|
|
1027
1215
|
C: (f, a) => f(...a)
|
|
1028
1216
|
});
|
|
@@ -1059,8 +1247,8 @@ var TestExtension = class {
|
|
|
1059
1247
|
(0, import_log5.log)("onClose", {
|
|
1060
1248
|
err
|
|
1061
1249
|
}, {
|
|
1062
|
-
F:
|
|
1063
|
-
L:
|
|
1250
|
+
F: __dxlog_file6,
|
|
1251
|
+
L: 66,
|
|
1064
1252
|
S: this,
|
|
1065
1253
|
C: (f, a) => f(...a)
|
|
1066
1254
|
});
|
|
@@ -1075,7 +1263,15 @@ var TestExtension = class {
|
|
|
1075
1263
|
const res = await (0, import_async4.asyncTimeout)(this._rpc.rpc.TestService.testCall({
|
|
1076
1264
|
data: message
|
|
1077
1265
|
}), 1500);
|
|
1078
|
-
(0,
|
|
1266
|
+
(0, import_invariant5.invariant)(res.data === message, void 0, {
|
|
1267
|
+
F: __dxlog_file6,
|
|
1268
|
+
L: 75,
|
|
1269
|
+
S: this,
|
|
1270
|
+
A: [
|
|
1271
|
+
"res.data === message",
|
|
1272
|
+
""
|
|
1273
|
+
]
|
|
1274
|
+
});
|
|
1079
1275
|
}
|
|
1080
1276
|
/**
|
|
1081
1277
|
* Force-close the connection.
|
|
@@ -1087,13 +1283,13 @@ var TestExtension = class {
|
|
|
1087
1283
|
};
|
|
1088
1284
|
|
|
1089
1285
|
// packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts
|
|
1090
|
-
var import_node_assert = __toESM(require("node:assert"));
|
|
1091
1286
|
var import_node_crypto = require("node:crypto");
|
|
1092
1287
|
var import_async5 = require("@dxos/async");
|
|
1288
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
1093
1289
|
var import_log6 = require("@dxos/log");
|
|
1094
1290
|
var import_protocols4 = require("@dxos/protocols");
|
|
1095
1291
|
var import_rpc3 = require("@dxos/rpc");
|
|
1096
|
-
var
|
|
1292
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts";
|
|
1097
1293
|
var TestExtensionWithStreams = class {
|
|
1098
1294
|
constructor(callbacks = {}) {
|
|
1099
1295
|
this.callbacks = callbacks;
|
|
@@ -1106,7 +1302,15 @@ var TestExtensionWithStreams = class {
|
|
|
1106
1302
|
return (_a = this.extensionContext) == null ? void 0 : _a.remotePeerId;
|
|
1107
1303
|
}
|
|
1108
1304
|
async _openStream(streamTag, interval = 5, chunkSize = 2048) {
|
|
1109
|
-
(0,
|
|
1305
|
+
(0, import_invariant6.invariant)(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
|
|
1306
|
+
F: __dxlog_file7,
|
|
1307
|
+
L: 37,
|
|
1308
|
+
S: this,
|
|
1309
|
+
A: [
|
|
1310
|
+
"!this._streams.has(streamTag)",
|
|
1311
|
+
"`Stream already exists: ${streamTag}`"
|
|
1312
|
+
]
|
|
1313
|
+
});
|
|
1110
1314
|
const networkStream = await this.extensionContext.createStream(streamTag, {
|
|
1111
1315
|
contentType: "application/x-test-stream"
|
|
1112
1316
|
});
|
|
@@ -1157,7 +1361,7 @@ var TestExtensionWithStreams = class {
|
|
|
1157
1361
|
from: (_a = this.extensionContext) == null ? void 0 : _a.localPeerId,
|
|
1158
1362
|
to: (_b = this.extensionContext) == null ? void 0 : _b.remotePeerId
|
|
1159
1363
|
}, {
|
|
1160
|
-
F:
|
|
1364
|
+
F: __dxlog_file7,
|
|
1161
1365
|
L: 91,
|
|
1162
1366
|
S: this,
|
|
1163
1367
|
C: (f, a) => f(...a)
|
|
@@ -1165,7 +1369,15 @@ var TestExtensionWithStreams = class {
|
|
|
1165
1369
|
}, 100);
|
|
1166
1370
|
}
|
|
1167
1371
|
_closeStream(streamTag) {
|
|
1168
|
-
(0,
|
|
1372
|
+
(0, import_invariant6.invariant)(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
|
|
1373
|
+
F: __dxlog_file7,
|
|
1374
|
+
L: 104,
|
|
1375
|
+
S: this,
|
|
1376
|
+
A: [
|
|
1377
|
+
"this._streams.has(streamTag)",
|
|
1378
|
+
"`Stream does not exist: ${streamTag}`"
|
|
1379
|
+
]
|
|
1380
|
+
});
|
|
1169
1381
|
const stream = this._streams.get(streamTag);
|
|
1170
1382
|
clearTimeout(stream.timer);
|
|
1171
1383
|
clearTimeout(stream.reportingTimer);
|
|
@@ -1186,7 +1398,7 @@ var TestExtensionWithStreams = class {
|
|
|
1186
1398
|
localPeerId: context.localPeerId,
|
|
1187
1399
|
remotePeerId: context.remotePeerId
|
|
1188
1400
|
}, {
|
|
1189
|
-
F:
|
|
1401
|
+
F: __dxlog_file7,
|
|
1190
1402
|
L: 126,
|
|
1191
1403
|
S: this,
|
|
1192
1404
|
C: (f, a) => f(...a)
|
|
@@ -1236,7 +1448,7 @@ var TestExtensionWithStreams = class {
|
|
|
1236
1448
|
(0, import_log6.log)("onClose", {
|
|
1237
1449
|
err
|
|
1238
1450
|
}, {
|
|
1239
|
-
F:
|
|
1451
|
+
F: __dxlog_file7,
|
|
1240
1452
|
L: 177,
|
|
1241
1453
|
S: this,
|
|
1242
1454
|
C: (f, a) => f(...a)
|
|
@@ -1247,7 +1459,7 @@ var TestExtensionWithStreams = class {
|
|
|
1247
1459
|
(0, import_log6.log)("closing stream", {
|
|
1248
1460
|
streamTag
|
|
1249
1461
|
}, {
|
|
1250
|
-
F:
|
|
1462
|
+
F: __dxlog_file7,
|
|
1251
1463
|
L: 181,
|
|
1252
1464
|
S: this,
|
|
1253
1465
|
C: (f, a) => f(...a)
|
|
@@ -1269,7 +1481,15 @@ var TestExtensionWithStreams = class {
|
|
|
1269
1481
|
streamLoadInterval,
|
|
1270
1482
|
streamLoadChunkSize
|
|
1271
1483
|
});
|
|
1272
|
-
(0,
|
|
1484
|
+
(0, import_invariant6.invariant)(data === streamTag, void 0, {
|
|
1485
|
+
F: __dxlog_file7,
|
|
1486
|
+
L: 198,
|
|
1487
|
+
S: this,
|
|
1488
|
+
A: [
|
|
1489
|
+
"data === streamTag",
|
|
1490
|
+
""
|
|
1491
|
+
]
|
|
1492
|
+
});
|
|
1273
1493
|
await this._openStream(streamTag, streamLoadInterval, streamLoadChunkSize);
|
|
1274
1494
|
return streamTag;
|
|
1275
1495
|
}
|
|
@@ -1280,7 +1500,15 @@ var TestExtensionWithStreams = class {
|
|
|
1280
1500
|
const { data, bytesSent, bytesReceived, sendErrors, receiveErrors, runningTime } = await this._rpc.rpc.TestServiceWithStreams.closeTestStream({
|
|
1281
1501
|
data: streamTag
|
|
1282
1502
|
});
|
|
1283
|
-
(0,
|
|
1503
|
+
(0, import_invariant6.invariant)(data === streamTag, void 0, {
|
|
1504
|
+
F: __dxlog_file7,
|
|
1505
|
+
L: 211,
|
|
1506
|
+
S: this,
|
|
1507
|
+
A: [
|
|
1508
|
+
"data === streamTag",
|
|
1509
|
+
""
|
|
1510
|
+
]
|
|
1511
|
+
});
|
|
1284
1512
|
const local = this._closeStream(streamTag);
|
|
1285
1513
|
return {
|
|
1286
1514
|
streamTag,
|
|
@@ -1306,8 +1534,9 @@ var TestExtensionWithStreams = class {
|
|
|
1306
1534
|
};
|
|
1307
1535
|
|
|
1308
1536
|
// packages/core/mesh/teleport/src/rpc-extension.ts
|
|
1309
|
-
var
|
|
1537
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
1310
1538
|
var import_rpc4 = require("@dxos/rpc");
|
|
1539
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/rpc-extension.ts";
|
|
1311
1540
|
var RpcExtension = class {
|
|
1312
1541
|
constructor(_rpcParams) {
|
|
1313
1542
|
this._rpcParams = _rpcParams;
|
|
@@ -1323,7 +1552,15 @@ var RpcExtension = class {
|
|
|
1323
1552
|
return this._extensionContext.remotePeerId;
|
|
1324
1553
|
}
|
|
1325
1554
|
get rpc() {
|
|
1326
|
-
(0,
|
|
1555
|
+
(0, import_invariant7.invariant)(this._rpc, void 0, {
|
|
1556
|
+
F: __dxlog_file8,
|
|
1557
|
+
L: 32,
|
|
1558
|
+
S: this,
|
|
1559
|
+
A: [
|
|
1560
|
+
"this._rpc",
|
|
1561
|
+
""
|
|
1562
|
+
]
|
|
1563
|
+
});
|
|
1327
1564
|
return this._rpc.rpc;
|
|
1328
1565
|
}
|
|
1329
1566
|
async onOpen(context) {
|