@dxos/network-manager 0.1.17 → 0.1.19
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/index.mjs +221 -352
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +222 -410
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +222 -357
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +222 -413
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/network-manager.d.ts +1 -5
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +4 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm-mapper.d.ts +1 -3
- package/dist/types/src/swarm/swarm-mapper.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +2 -2
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts +14 -0
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -0
- package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
- package/dist/types/src/tests/property-test-suite.d.ts.map +1 -1
- package/dist/types/src/tests/utils.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts +3 -3
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +0 -10
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +16 -18
- package/src/connection-log.ts +26 -26
- package/src/index.ts +0 -1
- package/src/network-manager.ts +1 -8
- package/src/swarm/connection.ts +12 -1
- package/src/swarm/peer.ts +1 -3
- package/src/swarm/swarm-mapper.ts +29 -31
- package/src/swarm/swarm.test.ts +12 -34
- package/src/testing/index.ts +0 -1
- package/src/testing/test-builder.ts +4 -7
- package/src/testing/test-wire-protocol.ts +44 -0
- package/src/tests/basic-test-suite.ts +13 -53
- package/src/tests/property-test-suite.ts +13 -15
- package/src/tests/utils.ts +10 -37
- package/src/transport/memory-transport.test.ts +13 -52
- package/src/transport/memory-transport.ts +37 -29
- package/src/transport/webrtc-transport-proxy.test.ts +13 -73
- package/src/transport/webrtc-transport.test.ts +7 -38
- package/src/wire-protocol.ts +0 -24
- package/dist/types/src/protocol-factory.d.ts +0 -36
- package/dist/types/src/protocol-factory.d.ts.map +0 -1
- package/dist/types/src/testing/test-protocol.d.ts +0 -52
- package/dist/types/src/testing/test-protocol.d.ts.map +0 -1
- package/dist/types/src/tests/presence.test.d.ts +0 -2
- package/dist/types/src/tests/presence.test.d.ts.map +0 -1
- package/src/protocol-factory.ts +0 -88
- package/src/testing/test-protocol.ts +0 -166
- package/src/tests/presence.test.ts +0 -80
package/dist/lib/node/index.cjs
CHANGED
|
@@ -43,12 +43,8 @@ __export(src_exports, {
|
|
|
43
43
|
WebRTCTransportProxy: () => WebRTCTransportProxy,
|
|
44
44
|
WebRTCTransportProxyFactory: () => WebRTCTransportProxyFactory,
|
|
45
45
|
WebRTCTransportService: () => WebRTCTransportService,
|
|
46
|
-
adaptProtocolProvider: () => adaptProtocolProvider,
|
|
47
|
-
createProtocolFactory: () => createProtocolFactory,
|
|
48
46
|
createTeleportProtocolFactory: () => createTeleportProtocolFactory,
|
|
49
|
-
createWebRTCTransportFactory: () => createWebRTCTransportFactory
|
|
50
|
-
protocolFactory: () => protocolFactory,
|
|
51
|
-
transportProtocolProvider: () => transportProtocolProvider
|
|
47
|
+
createWebRTCTransportFactory: () => createWebRTCTransportFactory
|
|
52
48
|
});
|
|
53
49
|
module.exports = __toCommonJS(src_exports);
|
|
54
50
|
|
|
@@ -78,6 +74,7 @@ var ConnectionState;
|
|
|
78
74
|
ConnectionState4["INITIAL"] = "INITIAL";
|
|
79
75
|
ConnectionState4["CONNECTING"] = "CONNECTING";
|
|
80
76
|
ConnectionState4["CONNECTED"] = "CONNECTED";
|
|
77
|
+
ConnectionState4["CLOSING"] = "CLOSING";
|
|
81
78
|
ConnectionState4["CLOSED"] = "CLOSED";
|
|
82
79
|
})(ConnectionState || (ConnectionState = {}));
|
|
83
80
|
var Connection = class {
|
|
@@ -133,7 +130,11 @@ var Connection = class {
|
|
|
133
130
|
this._transport = void 0;
|
|
134
131
|
this.close().catch((err) => this.errors.raise(err));
|
|
135
132
|
});
|
|
136
|
-
this._transport.errors.
|
|
133
|
+
this._transport.errors.handle((err) => {
|
|
134
|
+
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
135
|
+
this.errors.raise(err);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
137
138
|
for (const signal of this._bufferedSignals) {
|
|
138
139
|
void this._transport.signal(signal);
|
|
139
140
|
}
|
|
@@ -144,11 +145,12 @@ var Connection = class {
|
|
|
144
145
|
if (this._state === ConnectionState.CLOSED) {
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
148
|
+
this._changeState(ConnectionState.CLOSING);
|
|
147
149
|
(0, import_log.log)("closing...", {
|
|
148
150
|
peerId: this.ownId
|
|
149
151
|
}, {
|
|
150
|
-
file: "
|
|
151
|
-
line:
|
|
152
|
+
file: "connection.ts",
|
|
153
|
+
line: 142,
|
|
152
154
|
scope: this,
|
|
153
155
|
callSite: (f, a) => f(...a)
|
|
154
156
|
});
|
|
@@ -156,8 +158,8 @@ var Connection = class {
|
|
|
156
158
|
await this._protocol.destroy();
|
|
157
159
|
} catch (err) {
|
|
158
160
|
import_log.log.catch(err, {}, {
|
|
159
|
-
file: "
|
|
160
|
-
line:
|
|
161
|
+
file: "connection.ts",
|
|
162
|
+
line: 148,
|
|
161
163
|
scope: this,
|
|
162
164
|
callSite: (f, a) => f(...a)
|
|
163
165
|
});
|
|
@@ -166,8 +168,8 @@ var Connection = class {
|
|
|
166
168
|
await ((_a = this._transport) == null ? void 0 : _a.destroy());
|
|
167
169
|
} catch (err1) {
|
|
168
170
|
import_log.log.catch(err1, {}, {
|
|
169
|
-
file: "
|
|
170
|
-
line:
|
|
171
|
+
file: "connection.ts",
|
|
172
|
+
line: 155,
|
|
171
173
|
scope: this,
|
|
172
174
|
callSite: (f, a) => f(...a)
|
|
173
175
|
});
|
|
@@ -175,8 +177,8 @@ var Connection = class {
|
|
|
175
177
|
(0, import_log.log)("closed", {
|
|
176
178
|
peerId: this.ownId
|
|
177
179
|
}, {
|
|
178
|
-
file: "
|
|
179
|
-
line:
|
|
180
|
+
file: "connection.ts",
|
|
181
|
+
line: 158,
|
|
180
182
|
scope: this,
|
|
181
183
|
callSite: (f, a) => f(...a)
|
|
182
184
|
});
|
|
@@ -187,8 +189,8 @@ var Connection = class {
|
|
|
187
189
|
(0, import_node_assert.default)(msg.sessionId);
|
|
188
190
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
189
191
|
(0, import_log.log)("dropping signal for incorrect session id", {}, {
|
|
190
|
-
file: "
|
|
191
|
-
line:
|
|
192
|
+
file: "connection.ts",
|
|
193
|
+
line: 165,
|
|
192
194
|
scope: this,
|
|
193
195
|
callSite: (f, a) => f(...a)
|
|
194
196
|
});
|
|
@@ -203,8 +205,8 @@ var Connection = class {
|
|
|
203
205
|
remoteId: this.remoteId,
|
|
204
206
|
msg: msg.data
|
|
205
207
|
}, {
|
|
206
|
-
file: "
|
|
207
|
-
line:
|
|
208
|
+
file: "connection.ts",
|
|
209
|
+
line: 173,
|
|
208
210
|
scope: this,
|
|
209
211
|
callSite: (f, a) => f(...a)
|
|
210
212
|
});
|
|
@@ -217,8 +219,8 @@ var Connection = class {
|
|
|
217
219
|
remoteId: this.remoteId,
|
|
218
220
|
msg: msg.data
|
|
219
221
|
}, {
|
|
220
|
-
file: "
|
|
221
|
-
line:
|
|
222
|
+
file: "connection.ts",
|
|
223
|
+
line: 179,
|
|
222
224
|
scope: this,
|
|
223
225
|
callSite: (f, a) => f(...a)
|
|
224
226
|
});
|
|
@@ -271,7 +273,7 @@ var MessageRouter = class {
|
|
|
271
273
|
to: recipient,
|
|
272
274
|
msg: message
|
|
273
275
|
}, {
|
|
274
|
-
file: "
|
|
276
|
+
file: "message-router.ts",
|
|
275
277
|
line: 67,
|
|
276
278
|
scope: this,
|
|
277
279
|
callSite: (f, a) => f(...a)
|
|
@@ -329,7 +331,7 @@ var MessageRouter = class {
|
|
|
329
331
|
to: recipient,
|
|
330
332
|
msg: networkMessage
|
|
331
333
|
}, {
|
|
332
|
-
file: "
|
|
334
|
+
file: "message-router.ts",
|
|
333
335
|
line: 117,
|
|
334
336
|
scope: this,
|
|
335
337
|
callSite: (f, a) => f(...a)
|
|
@@ -360,7 +362,7 @@ var MessageRouter = class {
|
|
|
360
362
|
(0, import_log2.log)("resolving", {
|
|
361
363
|
answer: message.data.answer
|
|
362
364
|
}, {
|
|
363
|
-
file: "
|
|
365
|
+
file: "message-router.ts",
|
|
364
366
|
line: 146,
|
|
365
367
|
scope: this,
|
|
366
368
|
callSite: (f, a) => f(...a)
|
|
@@ -443,7 +445,7 @@ var Peer = class {
|
|
|
443
445
|
topic: this.topic,
|
|
444
446
|
peerId: this.localPeerId
|
|
445
447
|
}, {
|
|
446
|
-
file: "
|
|
448
|
+
file: "peer.ts",
|
|
447
449
|
line: 83,
|
|
448
450
|
scope: this,
|
|
449
451
|
callSite: (f, a) => f(...a)
|
|
@@ -470,7 +472,7 @@ var Peer = class {
|
|
|
470
472
|
remoteId: this.id,
|
|
471
473
|
err
|
|
472
474
|
}, {
|
|
473
|
-
file: "
|
|
475
|
+
file: "peer.ts",
|
|
474
476
|
line: 107,
|
|
475
477
|
scope: this,
|
|
476
478
|
callSite: (f, a) => f(...a)
|
|
@@ -496,7 +498,7 @@ var Peer = class {
|
|
|
496
498
|
peerId: this.id,
|
|
497
499
|
sessionId
|
|
498
500
|
}, {
|
|
499
|
-
file: "
|
|
501
|
+
file: "peer.ts",
|
|
500
502
|
line: 125,
|
|
501
503
|
scope: this,
|
|
502
504
|
callSite: (f, a) => f(...a)
|
|
@@ -519,14 +521,14 @@ var Peer = class {
|
|
|
519
521
|
ownId: this.localPeerId,
|
|
520
522
|
remoteId: this.id
|
|
521
523
|
}, {
|
|
522
|
-
file: "
|
|
524
|
+
file: "peer.ts",
|
|
523
525
|
line: 137,
|
|
524
526
|
scope: this,
|
|
525
527
|
callSite: (f, a) => f(...a)
|
|
526
528
|
});
|
|
527
529
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
528
530
|
(0, import_log3.log)("ignoring response", {}, {
|
|
529
|
-
file: "
|
|
531
|
+
file: "peer.ts",
|
|
530
532
|
line: 139,
|
|
531
533
|
scope: this,
|
|
532
534
|
callSite: (f, a) => f(...a)
|
|
@@ -546,7 +548,7 @@ var Peer = class {
|
|
|
546
548
|
remoteId: this.id,
|
|
547
549
|
err
|
|
548
550
|
}, {
|
|
549
|
-
file: "
|
|
551
|
+
file: "peer.ts",
|
|
550
552
|
line: 150,
|
|
551
553
|
scope: this,
|
|
552
554
|
callSite: (f, a) => f(...a)
|
|
@@ -565,7 +567,7 @@ var Peer = class {
|
|
|
565
567
|
initiator,
|
|
566
568
|
sessionId
|
|
567
569
|
}, {
|
|
568
|
-
file: "
|
|
570
|
+
file: "peer.ts",
|
|
569
571
|
line: 164,
|
|
570
572
|
scope: this,
|
|
571
573
|
callSite: (f, a) => f(...a)
|
|
@@ -600,7 +602,7 @@ var Peer = class {
|
|
|
600
602
|
remoteId: this.id,
|
|
601
603
|
initiator
|
|
602
604
|
}, {
|
|
603
|
-
file: "
|
|
605
|
+
file: "peer.ts",
|
|
604
606
|
line: 193,
|
|
605
607
|
scope: this,
|
|
606
608
|
callSite: (f, a) => f(...a)
|
|
@@ -620,19 +622,12 @@ var Peer = class {
|
|
|
620
622
|
initiator,
|
|
621
623
|
err
|
|
622
624
|
}, {
|
|
623
|
-
file: "
|
|
625
|
+
file: "peer.ts",
|
|
624
626
|
line: 203,
|
|
625
627
|
scope: this,
|
|
626
628
|
callSite: (f, a) => f(...a)
|
|
627
629
|
});
|
|
628
|
-
void this.closeConnection()
|
|
629
|
-
import_log3.log.catch(err, {}, {
|
|
630
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
|
|
631
|
-
line: 207,
|
|
632
|
-
scope: this,
|
|
633
|
-
callSite: (f, a) => f(...a)
|
|
634
|
-
});
|
|
635
|
-
});
|
|
630
|
+
void this.closeConnection();
|
|
636
631
|
});
|
|
637
632
|
this.connection = connection;
|
|
638
633
|
return connection;
|
|
@@ -646,8 +641,8 @@ var Peer = class {
|
|
|
646
641
|
peerId: this.id,
|
|
647
642
|
sessionId: connection.sessionId
|
|
648
643
|
}, {
|
|
649
|
-
file: "
|
|
650
|
-
line:
|
|
644
|
+
file: "peer.ts",
|
|
645
|
+
line: 219,
|
|
651
646
|
scope: this,
|
|
652
647
|
callSite: (f, a) => f(...a)
|
|
653
648
|
});
|
|
@@ -656,8 +651,8 @@ var Peer = class {
|
|
|
656
651
|
peerId: this.id,
|
|
657
652
|
sessionId: connection.sessionId
|
|
658
653
|
}, {
|
|
659
|
-
file: "
|
|
660
|
-
line:
|
|
654
|
+
file: "peer.ts",
|
|
655
|
+
line: 225,
|
|
661
656
|
scope: this,
|
|
662
657
|
callSite: (f, a) => f(...a)
|
|
663
658
|
});
|
|
@@ -667,8 +662,8 @@ var Peer = class {
|
|
|
667
662
|
(0, import_log3.log)("dropping signal message for non-existent connection", {
|
|
668
663
|
message
|
|
669
664
|
}, {
|
|
670
|
-
file: "
|
|
671
|
-
line:
|
|
665
|
+
file: "peer.ts",
|
|
666
|
+
line: 230,
|
|
672
667
|
scope: this,
|
|
673
668
|
callSite: (f, a) => f(...a)
|
|
674
669
|
});
|
|
@@ -682,8 +677,8 @@ var Peer = class {
|
|
|
682
677
|
peerId: this.id,
|
|
683
678
|
topic: this.topic
|
|
684
679
|
}, {
|
|
685
|
-
file: "
|
|
686
|
-
line:
|
|
680
|
+
file: "peer.ts",
|
|
681
|
+
line: 238,
|
|
687
682
|
scope: this,
|
|
688
683
|
callSite: (f, a) => f(...a)
|
|
689
684
|
});
|
|
@@ -726,7 +721,7 @@ var Swarm = class {
|
|
|
726
721
|
(0, import_log4.log)("creating swarm", {
|
|
727
722
|
peerId: _ownPeerId
|
|
728
723
|
}, {
|
|
729
|
-
file: "
|
|
724
|
+
file: "swarm.ts",
|
|
730
725
|
line: 80,
|
|
731
726
|
scope: this,
|
|
732
727
|
callSite: (f, a) => f(...a)
|
|
@@ -743,7 +738,7 @@ var Swarm = class {
|
|
|
743
738
|
payloadType: "dxos.mesh.swarm.SwarmMessage",
|
|
744
739
|
onMessage: async (message) => await this._swarmMessenger.receiveMessage(message)
|
|
745
740
|
}).catch((error) => import_log4.log.catch(error, {}, {
|
|
746
|
-
file: "
|
|
741
|
+
file: "swarm.ts",
|
|
747
742
|
line: 96,
|
|
748
743
|
scope: this,
|
|
749
744
|
callSite: (f, a) => f(...a)
|
|
@@ -763,7 +758,7 @@ var Swarm = class {
|
|
|
763
758
|
}
|
|
764
759
|
async destroy() {
|
|
765
760
|
(0, import_log4.log)("destroying...", {}, {
|
|
766
|
-
file: "
|
|
761
|
+
file: "swarm.ts",
|
|
767
762
|
line: 124,
|
|
768
763
|
scope: this,
|
|
769
764
|
callSite: (f, a) => f(...a)
|
|
@@ -772,7 +767,7 @@ var Swarm = class {
|
|
|
772
767
|
await this._topology.destroy();
|
|
773
768
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
774
769
|
(0, import_log4.log)("destroyed", {}, {
|
|
775
|
-
file: "
|
|
770
|
+
file: "swarm.ts",
|
|
776
771
|
line: 128,
|
|
777
772
|
scope: this,
|
|
778
773
|
callSite: (f, a) => f(...a)
|
|
@@ -786,7 +781,7 @@ var Swarm = class {
|
|
|
786
781
|
previous: getClassName(this._topology),
|
|
787
782
|
topology: getClassName(topology)
|
|
788
783
|
}, {
|
|
789
|
-
file: "
|
|
784
|
+
file: "swarm.ts",
|
|
790
785
|
line: 135,
|
|
791
786
|
scope: this,
|
|
792
787
|
callSite: (f, a) => f(...a)
|
|
@@ -838,14 +833,14 @@ var Swarm = class {
|
|
|
838
833
|
(0, import_log4.log)("swarm event", {
|
|
839
834
|
swarmEvent
|
|
840
835
|
}, {
|
|
841
|
-
file: "
|
|
836
|
+
file: "swarm.ts",
|
|
842
837
|
line: 199,
|
|
843
838
|
scope: this,
|
|
844
839
|
callSite: (f, a) => f(...a)
|
|
845
840
|
});
|
|
846
841
|
if (this._ctx.disposed) {
|
|
847
842
|
import_log4.log.warn("ignored for destroyed swarm", {}, {
|
|
848
|
-
file: "
|
|
843
|
+
file: "swarm.ts",
|
|
849
844
|
line: 201,
|
|
850
845
|
scope: this,
|
|
851
846
|
callSite: (f, a) => f(...a)
|
|
@@ -857,7 +852,7 @@ var Swarm = class {
|
|
|
857
852
|
(0, import_log4.log)("new peer", {
|
|
858
853
|
peerId
|
|
859
854
|
}, {
|
|
860
|
-
file: "
|
|
855
|
+
file: "swarm.ts",
|
|
861
856
|
line: 207,
|
|
862
857
|
scope: this,
|
|
863
858
|
callSite: (f, a) => f(...a)
|
|
@@ -882,14 +877,14 @@ var Swarm = class {
|
|
|
882
877
|
(0, import_log4.log)("offer", {
|
|
883
878
|
message
|
|
884
879
|
}, {
|
|
885
|
-
file: "
|
|
880
|
+
file: "swarm.ts",
|
|
886
881
|
line: 226,
|
|
887
882
|
scope: this,
|
|
888
883
|
callSite: (f, a) => f(...a)
|
|
889
884
|
});
|
|
890
885
|
if (this._ctx.disposed) {
|
|
891
886
|
import_log4.log.info("ignored for destroyed swarm", {}, {
|
|
892
|
-
file: "
|
|
887
|
+
file: "swarm.ts",
|
|
893
888
|
line: 228,
|
|
894
889
|
scope: this,
|
|
895
890
|
callSite: (f, a) => f(...a)
|
|
@@ -903,7 +898,7 @@ var Swarm = class {
|
|
|
903
898
|
(0, import_log4.log)("rejecting offer with incorrect peerId", {
|
|
904
899
|
message
|
|
905
900
|
}, {
|
|
906
|
-
file: "
|
|
901
|
+
file: "swarm.ts",
|
|
907
902
|
line: 235,
|
|
908
903
|
scope: this,
|
|
909
904
|
callSite: (f, a) => f(...a)
|
|
@@ -916,7 +911,7 @@ var Swarm = class {
|
|
|
916
911
|
(0, import_log4.log)("rejecting offer with incorrect topic", {
|
|
917
912
|
message
|
|
918
913
|
}, {
|
|
919
|
-
file: "
|
|
914
|
+
file: "swarm.ts",
|
|
920
915
|
line: 239,
|
|
921
916
|
scope: this,
|
|
922
917
|
callSite: (f, a) => f(...a)
|
|
@@ -935,14 +930,14 @@ var Swarm = class {
|
|
|
935
930
|
(0, import_log4.log)("signal", {
|
|
936
931
|
message
|
|
937
932
|
}, {
|
|
938
|
-
file: "
|
|
933
|
+
file: "swarm.ts",
|
|
939
934
|
line: 250,
|
|
940
935
|
scope: this,
|
|
941
936
|
callSite: (f, a) => f(...a)
|
|
942
937
|
});
|
|
943
938
|
if (this._ctx.disposed) {
|
|
944
939
|
import_log4.log.info("ignored for destroyed swarm", {}, {
|
|
945
|
-
file: "
|
|
940
|
+
file: "swarm.ts",
|
|
946
941
|
line: 252,
|
|
947
942
|
scope: this,
|
|
948
943
|
callSite: (f, a) => f(...a)
|
|
@@ -971,7 +966,7 @@ var Swarm = class {
|
|
|
971
966
|
await this._initiateConnection(peer);
|
|
972
967
|
} catch (err) {
|
|
973
968
|
import_log4.log.warn("initiation error", err, {
|
|
974
|
-
file: "
|
|
969
|
+
file: "swarm.ts",
|
|
975
970
|
line: 287,
|
|
976
971
|
scope: this,
|
|
977
972
|
callSite: (f, a) => f(...a)
|
|
@@ -995,7 +990,7 @@ var Swarm = class {
|
|
|
995
990
|
(0, import_log4.log)("initiation delay", {
|
|
996
991
|
remoteId
|
|
997
992
|
}, {
|
|
998
|
-
file: "
|
|
993
|
+
file: "swarm.ts",
|
|
999
994
|
line: 312,
|
|
1000
995
|
scope: this,
|
|
1001
996
|
callSite: (f, a) => f(...a)
|
|
@@ -1012,7 +1007,7 @@ var Swarm = class {
|
|
|
1012
1007
|
(0, import_log4.log)("initiating connection...", {
|
|
1013
1008
|
remoteId
|
|
1014
1009
|
}, {
|
|
1015
|
-
file: "
|
|
1010
|
+
file: "swarm.ts",
|
|
1016
1011
|
line: 326,
|
|
1017
1012
|
scope: this,
|
|
1018
1013
|
callSite: (f, a) => f(...a)
|
|
@@ -1022,7 +1017,7 @@ var Swarm = class {
|
|
|
1022
1017
|
(0, import_log4.log)("initiated", {
|
|
1023
1018
|
remoteId
|
|
1024
1019
|
}, {
|
|
1025
|
-
file: "
|
|
1020
|
+
file: "swarm.ts",
|
|
1026
1021
|
line: 329,
|
|
1027
1022
|
scope: this,
|
|
1028
1023
|
callSite: (f, a) => f(...a)
|
|
@@ -1055,9 +1050,8 @@ var SwarmMapper = class {
|
|
|
1055
1050
|
get peers() {
|
|
1056
1051
|
return Array.from(this._peers.values());
|
|
1057
1052
|
}
|
|
1058
|
-
constructor(_swarm
|
|
1053
|
+
constructor(_swarm) {
|
|
1059
1054
|
this._swarm = _swarm;
|
|
1060
|
-
this._presence = _presence;
|
|
1061
1055
|
this._subscriptions = new import_async4.EventSubscriptions();
|
|
1062
1056
|
this._connectionSubscriptions = new import_util3.ComplexMap(import_keys4.PublicKey.hash);
|
|
1063
1057
|
this._peers = new import_util3.ComplexMap(import_keys4.PublicKey.hash);
|
|
@@ -1074,17 +1068,12 @@ var SwarmMapper = class {
|
|
|
1074
1068
|
this._connectionSubscriptions.delete(peerId);
|
|
1075
1069
|
this._update();
|
|
1076
1070
|
}));
|
|
1077
|
-
if (_presence) {
|
|
1078
|
-
this._subscriptions.add(_presence.graphUpdated.on(() => {
|
|
1079
|
-
this._update();
|
|
1080
|
-
}));
|
|
1081
|
-
}
|
|
1082
1071
|
this._update();
|
|
1083
1072
|
}
|
|
1084
1073
|
_update() {
|
|
1085
1074
|
(0, import_log5.log)("updating swarm", {}, {
|
|
1086
|
-
file: "
|
|
1087
|
-
line:
|
|
1075
|
+
file: "swarm-mapper.ts",
|
|
1076
|
+
line: 75,
|
|
1088
1077
|
scope: this,
|
|
1089
1078
|
callSite: (f, a) => f(...a)
|
|
1090
1079
|
});
|
|
@@ -1103,32 +1092,12 @@ var SwarmMapper = class {
|
|
|
1103
1092
|
]
|
|
1104
1093
|
});
|
|
1105
1094
|
}
|
|
1106
|
-
if (this._presence) {
|
|
1107
|
-
this._presence.graph.forEachNode((node) => {
|
|
1108
|
-
const id = import_keys4.PublicKey.fromHex(node.id);
|
|
1109
|
-
if (this._peers.has(id)) {
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
this._peers.set(id, {
|
|
1113
|
-
id,
|
|
1114
|
-
state: "INDIRECTLY_CONNECTED",
|
|
1115
|
-
connections: []
|
|
1116
|
-
});
|
|
1117
|
-
});
|
|
1118
|
-
this._presence.graph.forEachLink((link) => {
|
|
1119
|
-
const from = import_keys4.PublicKey.from(link.fromId);
|
|
1120
|
-
const to = import_keys4.PublicKey.from(link.toId);
|
|
1121
|
-
if (!from.equals(this._swarm.ownPeerId) && !to.equals(this._swarm.ownPeerId)) {
|
|
1122
|
-
this._peers.get(from).connections.push(to);
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
1095
|
(0, import_log5.log)("graph changed", {
|
|
1127
1096
|
directConnections: this._swarm.connections.length,
|
|
1128
1097
|
totalPeersInSwarm: this._peers.size
|
|
1129
1098
|
}, {
|
|
1130
|
-
file: "
|
|
1131
|
-
line:
|
|
1099
|
+
file: "swarm-mapper.ts",
|
|
1100
|
+
line: 116,
|
|
1132
1101
|
scope: this,
|
|
1133
1102
|
callSite: (f, a) => f(...a)
|
|
1134
1103
|
});
|
|
@@ -1172,13 +1141,12 @@ var ConnectionLog = class {
|
|
|
1172
1141
|
this._swarms.set(swarm.instanceId, info);
|
|
1173
1142
|
this.update.emit();
|
|
1174
1143
|
swarm.connectionAdded.on((connection) => {
|
|
1175
|
-
var _a, _b, _c, _d, _e;
|
|
1176
1144
|
const connectionInfo = {
|
|
1177
1145
|
state: ConnectionState.INITIAL,
|
|
1178
1146
|
remotePeerId: connection.remoteId,
|
|
1179
1147
|
sessionId: connection.sessionId,
|
|
1180
1148
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
1181
|
-
protocolExtensions:
|
|
1149
|
+
protocolExtensions: [],
|
|
1182
1150
|
events: []
|
|
1183
1151
|
};
|
|
1184
1152
|
info.connections.push(connectionInfo);
|
|
@@ -1191,32 +1159,6 @@ var ConnectionLog = class {
|
|
|
1191
1159
|
});
|
|
1192
1160
|
this.update.emit();
|
|
1193
1161
|
});
|
|
1194
|
-
(_b = connection.protocol.protocol) == null ? void 0 : _b.error.on((error) => {
|
|
1195
|
-
var _a2;
|
|
1196
|
-
connectionInfo.events.push({
|
|
1197
|
-
type: EventType.PROTOCOL_ERROR,
|
|
1198
|
-
error: (_a2 = error.stack) != null ? _a2 : error.message
|
|
1199
|
-
});
|
|
1200
|
-
this.update.emit();
|
|
1201
|
-
});
|
|
1202
|
-
(_c = connection.protocol.protocol) == null ? void 0 : _c.extensionsInitialized.on(() => {
|
|
1203
|
-
connectionInfo.events.push({
|
|
1204
|
-
type: EventType.PROTOCOL_EXTENSIONS_INITIALIZED
|
|
1205
|
-
});
|
|
1206
|
-
this.update.emit();
|
|
1207
|
-
});
|
|
1208
|
-
(_d = connection.protocol.protocol) == null ? void 0 : _d.extensionsHandshake.on(() => {
|
|
1209
|
-
connectionInfo.events.push({
|
|
1210
|
-
type: EventType.PROTOCOL_EXTENSIONS_HANDSHAKE
|
|
1211
|
-
});
|
|
1212
|
-
this.update.emit();
|
|
1213
|
-
});
|
|
1214
|
-
(_e = connection.protocol.protocol) == null ? void 0 : _e.handshake.on(() => {
|
|
1215
|
-
connectionInfo.events.push({
|
|
1216
|
-
type: EventType.PROTOCOL_HANDSHAKE
|
|
1217
|
-
});
|
|
1218
|
-
this.update.emit();
|
|
1219
|
-
});
|
|
1220
1162
|
});
|
|
1221
1163
|
}
|
|
1222
1164
|
swarmLeft(swarm) {
|
|
@@ -1233,7 +1175,7 @@ var import_log6 = require("@dxos/log");
|
|
|
1233
1175
|
var import_messaging = require("@dxos/messaging");
|
|
1234
1176
|
var import_util5 = require("@dxos/util");
|
|
1235
1177
|
var NetworkManager = class {
|
|
1236
|
-
constructor({ transportFactory, signalManager, log:
|
|
1178
|
+
constructor({ transportFactory, signalManager, log: log13 }) {
|
|
1237
1179
|
this._swarms = new import_util5.ComplexMap(import_keys6.PublicKey.hash);
|
|
1238
1180
|
this._mappers = new import_util5.ComplexMap(import_keys6.PublicKey.hash);
|
|
1239
1181
|
this.topicsUpdated = new import_async6.Event();
|
|
@@ -1250,7 +1192,7 @@ var NetworkManager = class {
|
|
|
1250
1192
|
join: (opts) => this._signalManager.join(opts),
|
|
1251
1193
|
leave: (opts) => this._signalManager.leave(opts)
|
|
1252
1194
|
};
|
|
1253
|
-
if (
|
|
1195
|
+
if (log13) {
|
|
1254
1196
|
this._connectionLog = new ConnectionLog();
|
|
1255
1197
|
}
|
|
1256
1198
|
}
|
|
@@ -1273,8 +1215,8 @@ var NetworkManager = class {
|
|
|
1273
1215
|
for (const topic of this._swarms.keys()) {
|
|
1274
1216
|
await this.leaveSwarm(topic).catch((err) => {
|
|
1275
1217
|
(0, import_log6.log)(err, {}, {
|
|
1276
|
-
file: "
|
|
1277
|
-
line:
|
|
1218
|
+
file: "network-manager.ts",
|
|
1219
|
+
line: 122,
|
|
1278
1220
|
scope: this,
|
|
1279
1221
|
callSite: (f, a) => f(...a)
|
|
1280
1222
|
});
|
|
@@ -1282,7 +1224,7 @@ var NetworkManager = class {
|
|
|
1282
1224
|
}
|
|
1283
1225
|
await this._signalManager.destroy();
|
|
1284
1226
|
}
|
|
1285
|
-
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol,
|
|
1227
|
+
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1286
1228
|
var _a;
|
|
1287
1229
|
(0, import_node_assert5.default)(import_keys6.PublicKey.isPublicKey(topic));
|
|
1288
1230
|
(0, import_node_assert5.default)(import_keys6.PublicKey.isPublicKey(peerId));
|
|
@@ -1296,8 +1238,8 @@ var NetworkManager = class {
|
|
|
1296
1238
|
peerId,
|
|
1297
1239
|
topology: topology.toString()
|
|
1298
1240
|
}, {
|
|
1299
|
-
file: "
|
|
1300
|
-
line:
|
|
1241
|
+
file: "network-manager.ts",
|
|
1242
|
+
line: 148,
|
|
1301
1243
|
scope: this,
|
|
1302
1244
|
callSite: (f, a) => f(...a)
|
|
1303
1245
|
});
|
|
@@ -1306,8 +1248,8 @@ var NetworkManager = class {
|
|
|
1306
1248
|
(0, import_log6.log)("swarm error", {
|
|
1307
1249
|
error
|
|
1308
1250
|
}, {
|
|
1309
|
-
file: "
|
|
1310
|
-
line:
|
|
1251
|
+
file: "network-manager.ts",
|
|
1252
|
+
line: 151,
|
|
1311
1253
|
scope: this,
|
|
1312
1254
|
callSite: (f, a) => f(...a)
|
|
1313
1255
|
});
|
|
@@ -1317,20 +1259,20 @@ var NetworkManager = class {
|
|
|
1317
1259
|
topic,
|
|
1318
1260
|
peerId
|
|
1319
1261
|
}).catch((error) => import_log6.log.catch(error, {}, {
|
|
1320
|
-
file: "
|
|
1321
|
-
line:
|
|
1262
|
+
file: "network-manager.ts",
|
|
1263
|
+
line: 155,
|
|
1322
1264
|
scope: this,
|
|
1323
1265
|
callSite: (f, a) => f(...a)
|
|
1324
1266
|
}));
|
|
1325
|
-
this._mappers.set(topic, new SwarmMapper(swarm
|
|
1267
|
+
this._mappers.set(topic, new SwarmMapper(swarm));
|
|
1326
1268
|
this.topicsUpdated.emit();
|
|
1327
1269
|
(_a = this._connectionLog) == null ? void 0 : _a.swarmJoined(swarm);
|
|
1328
1270
|
(0, import_log6.log)("joined", {
|
|
1329
1271
|
topic: import_keys6.PublicKey.from(topic),
|
|
1330
1272
|
count: this._swarms.size
|
|
1331
1273
|
}, {
|
|
1332
|
-
file: "
|
|
1333
|
-
line:
|
|
1274
|
+
file: "network-manager.ts",
|
|
1275
|
+
line: 160,
|
|
1334
1276
|
scope: this,
|
|
1335
1277
|
callSite: (f, a) => f(...a)
|
|
1336
1278
|
});
|
|
@@ -1344,8 +1286,8 @@ var NetworkManager = class {
|
|
|
1344
1286
|
import_log6.log.warn("swarm not open", {
|
|
1345
1287
|
topic: import_keys6.PublicKey.from(topic)
|
|
1346
1288
|
}, {
|
|
1347
|
-
file: "
|
|
1348
|
-
line:
|
|
1289
|
+
file: "network-manager.ts",
|
|
1290
|
+
line: 172,
|
|
1349
1291
|
scope: this,
|
|
1350
1292
|
callSite: (f, a) => f(...a)
|
|
1351
1293
|
});
|
|
@@ -1354,8 +1296,8 @@ var NetworkManager = class {
|
|
|
1354
1296
|
(0, import_log6.log)("leaving", {
|
|
1355
1297
|
topic: import_keys6.PublicKey.from(topic)
|
|
1356
1298
|
}, {
|
|
1357
|
-
file: "
|
|
1358
|
-
line:
|
|
1299
|
+
file: "network-manager.ts",
|
|
1300
|
+
line: 176,
|
|
1359
1301
|
scope: this,
|
|
1360
1302
|
callSite: (f, a) => f(...a)
|
|
1361
1303
|
});
|
|
@@ -1375,86 +1317,26 @@ var NetworkManager = class {
|
|
|
1375
1317
|
topic: import_keys6.PublicKey.from(topic),
|
|
1376
1318
|
count: this._swarms.size
|
|
1377
1319
|
}, {
|
|
1378
|
-
file: "
|
|
1379
|
-
line:
|
|
1320
|
+
file: "network-manager.ts",
|
|
1321
|
+
line: 190,
|
|
1380
1322
|
scope: this,
|
|
1381
1323
|
callSite: (f, a) => f(...a)
|
|
1382
1324
|
});
|
|
1383
1325
|
}
|
|
1384
1326
|
};
|
|
1385
1327
|
|
|
1386
|
-
// packages/core/mesh/network-manager/src/protocol-factory.ts
|
|
1387
|
-
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1388
|
-
var import_crypto = require("@dxos/crypto");
|
|
1389
|
-
var import_keys7 = require("@dxos/keys");
|
|
1390
|
-
var import_log7 = require("@dxos/log");
|
|
1391
|
-
var import_mesh_protocol = require("@dxos/mesh-protocol");
|
|
1392
|
-
var protocolFactory = ({ session = {}, plugins = [], getTopics }) => {
|
|
1393
|
-
(0, import_node_assert6.default)(getTopics);
|
|
1394
|
-
return ({ channel, initiator }) => {
|
|
1395
|
-
(0, import_log7.log)("creating protocol", {}, {
|
|
1396
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/protocol-factory.ts",
|
|
1397
|
-
line: 41,
|
|
1398
|
-
scope: void 0,
|
|
1399
|
-
callSite: (f, a) => f(...a)
|
|
1400
|
-
});
|
|
1401
|
-
const protocol = new import_mesh_protocol.Protocol({
|
|
1402
|
-
streamOptions: {
|
|
1403
|
-
live: true
|
|
1404
|
-
},
|
|
1405
|
-
discoveryToPublicKey: (dk) => {
|
|
1406
|
-
const publicKey = getTopics().find((topic) => (0, import_crypto.discoveryKey)(topic).equals(dk));
|
|
1407
|
-
if (publicKey) {
|
|
1408
|
-
protocol.setContext({
|
|
1409
|
-
topic: import_keys7.PublicKey.stringify(publicKey)
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
(0, import_node_assert6.default)(publicKey, "PublicKey not found in discovery.");
|
|
1413
|
-
return publicKey;
|
|
1414
|
-
},
|
|
1415
|
-
initiator,
|
|
1416
|
-
userSession: session,
|
|
1417
|
-
discoveryKey: channel
|
|
1418
|
-
});
|
|
1419
|
-
protocol.setExtensions(plugins.map((plugin) => plugin.createExtension())).init();
|
|
1420
|
-
return protocol;
|
|
1421
|
-
};
|
|
1422
|
-
};
|
|
1423
|
-
var createProtocolFactory = (topic, peerId, plugins) => protocolFactory({
|
|
1424
|
-
getTopics: () => [
|
|
1425
|
-
topic.asBuffer()
|
|
1426
|
-
],
|
|
1427
|
-
session: {
|
|
1428
|
-
peerId: import_keys7.PublicKey.stringify(peerId.asBuffer())
|
|
1429
|
-
},
|
|
1430
|
-
plugins
|
|
1431
|
-
});
|
|
1432
|
-
var transportProtocolProvider = (rendezvousKey, peerId, protocolPlugin) => {
|
|
1433
|
-
return protocolFactory({
|
|
1434
|
-
getTopics: () => [
|
|
1435
|
-
rendezvousKey
|
|
1436
|
-
],
|
|
1437
|
-
session: {
|
|
1438
|
-
peerId: import_keys7.PublicKey.stringify(peerId)
|
|
1439
|
-
},
|
|
1440
|
-
plugins: [
|
|
1441
|
-
protocolPlugin
|
|
1442
|
-
]
|
|
1443
|
-
});
|
|
1444
|
-
};
|
|
1445
|
-
|
|
1446
1328
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
1447
|
-
var
|
|
1329
|
+
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1448
1330
|
var FullyConnectedTopology = class {
|
|
1449
1331
|
toString() {
|
|
1450
1332
|
return "FullyConnectedTopology";
|
|
1451
1333
|
}
|
|
1452
1334
|
init(controller) {
|
|
1453
|
-
(0,
|
|
1335
|
+
(0, import_node_assert6.default)(!this._controller, "Already initialized");
|
|
1454
1336
|
this._controller = controller;
|
|
1455
1337
|
}
|
|
1456
1338
|
update() {
|
|
1457
|
-
(0,
|
|
1339
|
+
(0, import_node_assert6.default)(this._controller, "Not initialized");
|
|
1458
1340
|
const { candidates: discovered } = this._controller.getState();
|
|
1459
1341
|
for (const peer of discovered) {
|
|
1460
1342
|
this._controller.connect(peer);
|
|
@@ -1468,9 +1350,9 @@ var FullyConnectedTopology = class {
|
|
|
1468
1350
|
};
|
|
1469
1351
|
|
|
1470
1352
|
// packages/core/mesh/network-manager/src/topology/mmst-topology.ts
|
|
1471
|
-
var
|
|
1353
|
+
var import_node_assert7 = __toESM(require("node:assert"));
|
|
1472
1354
|
var import_xor_distance = __toESM(require("xor-distance"));
|
|
1473
|
-
var
|
|
1355
|
+
var import_log7 = require("@dxos/log");
|
|
1474
1356
|
var MMSTTopology = class {
|
|
1475
1357
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
1476
1358
|
this._sampleCollected = false;
|
|
@@ -1479,15 +1361,15 @@ var MMSTTopology = class {
|
|
|
1479
1361
|
this._sampleSize = sampleSize;
|
|
1480
1362
|
}
|
|
1481
1363
|
init(controller) {
|
|
1482
|
-
(0,
|
|
1364
|
+
(0, import_node_assert7.default)(!this._controller, "Already initialized");
|
|
1483
1365
|
this._controller = controller;
|
|
1484
1366
|
}
|
|
1485
1367
|
update() {
|
|
1486
|
-
(0,
|
|
1368
|
+
(0, import_node_assert7.default)(this._controller, "Not initialized");
|
|
1487
1369
|
const { connected, candidates } = this._controller.getState();
|
|
1488
1370
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
1489
|
-
(0,
|
|
1490
|
-
file: "
|
|
1371
|
+
(0, import_log7.log)("Running the algorithm.", {}, {
|
|
1372
|
+
file: "mmst-topology.ts",
|
|
1491
1373
|
line: 55,
|
|
1492
1374
|
scope: this,
|
|
1493
1375
|
callSite: (f, a) => f(...a)
|
|
@@ -1497,11 +1379,11 @@ var MMSTTopology = class {
|
|
|
1497
1379
|
}
|
|
1498
1380
|
}
|
|
1499
1381
|
async onOffer(peer) {
|
|
1500
|
-
(0,
|
|
1382
|
+
(0, import_node_assert7.default)(this._controller, "Not initialized");
|
|
1501
1383
|
const { connected } = this._controller.getState();
|
|
1502
1384
|
const accept = connected.length < this._maxPeers;
|
|
1503
|
-
(0,
|
|
1504
|
-
file: "
|
|
1385
|
+
(0, import_log7.log)(`Offer ${peer} accept=${accept}`, {}, {
|
|
1386
|
+
file: "mmst-topology.ts",
|
|
1505
1387
|
line: 65,
|
|
1506
1388
|
scope: this,
|
|
1507
1389
|
callSite: (f, a) => f(...a)
|
|
@@ -1511,13 +1393,13 @@ var MMSTTopology = class {
|
|
|
1511
1393
|
async destroy() {
|
|
1512
1394
|
}
|
|
1513
1395
|
_runAlgorithm() {
|
|
1514
|
-
(0,
|
|
1396
|
+
(0, import_node_assert7.default)(this._controller, "Not initialized");
|
|
1515
1397
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
1516
1398
|
if (connected.length > this._maxPeers) {
|
|
1517
1399
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
1518
1400
|
for (const peer of sorted) {
|
|
1519
|
-
(0,
|
|
1520
|
-
file: "
|
|
1401
|
+
(0, import_log7.log)(`Disconnect ${peer}.`, {}, {
|
|
1402
|
+
file: "mmst-topology.ts",
|
|
1521
1403
|
line: 83,
|
|
1522
1404
|
scope: this,
|
|
1523
1405
|
callSite: (f, a) => f(...a)
|
|
@@ -1528,8 +1410,8 @@ var MMSTTopology = class {
|
|
|
1528
1410
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
1529
1411
|
const sorted1 = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
1530
1412
|
for (const peer1 of sorted1) {
|
|
1531
|
-
(0,
|
|
1532
|
-
file: "
|
|
1413
|
+
(0, import_log7.log)(`Connect ${peer1}.`, {}, {
|
|
1414
|
+
file: "mmst-topology.ts",
|
|
1533
1415
|
line: 91,
|
|
1534
1416
|
scope: this,
|
|
1535
1417
|
callSite: (f, a) => f(...a)
|
|
@@ -1545,8 +1427,8 @@ var MMSTTopology = class {
|
|
|
1545
1427
|
var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_distance.default.gt((0, import_xor_distance.default)(a.asBuffer(), reference.asBuffer()), (0, import_xor_distance.default)(b.asBuffer(), reference.asBuffer())));
|
|
1546
1428
|
|
|
1547
1429
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
1548
|
-
var
|
|
1549
|
-
var
|
|
1430
|
+
var import_node_assert8 = __toESM(require("node:assert"));
|
|
1431
|
+
var import_log8 = require("@dxos/log");
|
|
1550
1432
|
var StarTopology = class {
|
|
1551
1433
|
constructor(_centralPeer) {
|
|
1552
1434
|
this._centralPeer = _centralPeer;
|
|
@@ -1555,25 +1437,25 @@ var StarTopology = class {
|
|
|
1555
1437
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
1556
1438
|
}
|
|
1557
1439
|
init(controller) {
|
|
1558
|
-
(0,
|
|
1440
|
+
(0, import_node_assert8.default)(!this._controller, "Already initialized.");
|
|
1559
1441
|
this._controller = controller;
|
|
1560
1442
|
}
|
|
1561
1443
|
update() {
|
|
1562
|
-
(0,
|
|
1444
|
+
(0, import_node_assert8.default)(this._controller, "Not initialized.");
|
|
1563
1445
|
const { candidates, connected, ownPeerId } = this._controller.getState();
|
|
1564
1446
|
if (!ownPeerId.equals(this._centralPeer)) {
|
|
1565
|
-
(0,
|
|
1566
|
-
file: "
|
|
1447
|
+
(0, import_log8.log)("leaf peer dropping all connections apart from central peer.", {}, {
|
|
1448
|
+
file: "star-topology.ts",
|
|
1567
1449
|
line: 33,
|
|
1568
1450
|
scope: this,
|
|
1569
1451
|
callSite: (f, a) => f(...a)
|
|
1570
1452
|
});
|
|
1571
1453
|
for (const peer of connected) {
|
|
1572
1454
|
if (!peer.equals(this._centralPeer)) {
|
|
1573
|
-
(0,
|
|
1455
|
+
(0, import_log8.log)("dropping connection", {
|
|
1574
1456
|
peer
|
|
1575
1457
|
}, {
|
|
1576
|
-
file: "
|
|
1458
|
+
file: "star-topology.ts",
|
|
1577
1459
|
line: 38,
|
|
1578
1460
|
scope: this,
|
|
1579
1461
|
callSite: (f, a) => f(...a)
|
|
@@ -1584,10 +1466,10 @@ var StarTopology = class {
|
|
|
1584
1466
|
}
|
|
1585
1467
|
for (const peer1 of candidates) {
|
|
1586
1468
|
if (peer1.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
|
|
1587
|
-
(0,
|
|
1469
|
+
(0, import_log8.log)("connecting to peer", {
|
|
1588
1470
|
peer: peer1
|
|
1589
1471
|
}, {
|
|
1590
|
-
file: "
|
|
1472
|
+
file: "star-topology.ts",
|
|
1591
1473
|
line: 47,
|
|
1592
1474
|
scope: this,
|
|
1593
1475
|
callSite: (f, a) => f(...a)
|
|
@@ -1597,14 +1479,14 @@ var StarTopology = class {
|
|
|
1597
1479
|
}
|
|
1598
1480
|
}
|
|
1599
1481
|
async onOffer(peer) {
|
|
1600
|
-
(0,
|
|
1482
|
+
(0, import_node_assert8.default)(this._controller, "Not initialized.");
|
|
1601
1483
|
const { ownPeerId } = this._controller.getState();
|
|
1602
|
-
(0,
|
|
1484
|
+
(0, import_log8.log)("offer", {
|
|
1603
1485
|
peer,
|
|
1604
1486
|
isCentral: peer.equals(this._centralPeer),
|
|
1605
1487
|
isSelfCentral: ownPeerId.equals(this._centralPeer)
|
|
1606
1488
|
}, {
|
|
1607
|
-
file: "
|
|
1489
|
+
file: "star-topology.ts",
|
|
1608
1490
|
line: 56,
|
|
1609
1491
|
scope: this,
|
|
1610
1492
|
callSite: (f, a) => f(...a)
|
|
@@ -1616,13 +1498,23 @@ var StarTopology = class {
|
|
|
1616
1498
|
};
|
|
1617
1499
|
|
|
1618
1500
|
// packages/core/mesh/network-manager/src/transport/memory-transport.ts
|
|
1619
|
-
var
|
|
1501
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
1620
1502
|
var import_node_stream = require("node:stream");
|
|
1621
1503
|
var import_async7 = require("@dxos/async");
|
|
1622
1504
|
var import_debug4 = require("@dxos/debug");
|
|
1623
|
-
var
|
|
1624
|
-
var
|
|
1505
|
+
var import_keys7 = require("@dxos/keys");
|
|
1506
|
+
var import_log9 = require("@dxos/log");
|
|
1625
1507
|
var import_util6 = require("@dxos/util");
|
|
1508
|
+
var __decorate4 = function(decorators, target, key, desc) {
|
|
1509
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1510
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1511
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1512
|
+
else
|
|
1513
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1514
|
+
if (d = decorators[i])
|
|
1515
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1516
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1517
|
+
};
|
|
1626
1518
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
1627
1519
|
var createStreamDelay = (delay) => {
|
|
1628
1520
|
return new import_node_stream.Transform({
|
|
@@ -1642,34 +1534,30 @@ var _MemoryTransport = class {
|
|
|
1642
1534
|
this.closed = new import_async7.Event();
|
|
1643
1535
|
this.connected = new import_async7.Event();
|
|
1644
1536
|
this.errors = new import_debug4.ErrorStream();
|
|
1645
|
-
this._id = import_keys8.PublicKey.random();
|
|
1646
1537
|
this._remote = new import_async7.Trigger();
|
|
1647
1538
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1648
1539
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1649
1540
|
this._destroyed = false;
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
line: 59,
|
|
1541
|
+
this._instanceId = import_keys7.PublicKey.random();
|
|
1542
|
+
(0, import_log9.log)("creating", {}, {
|
|
1543
|
+
file: "memory-transport.ts",
|
|
1544
|
+
line: 64,
|
|
1655
1545
|
scope: this,
|
|
1656
1546
|
callSite: (f, a) => f(...a)
|
|
1657
1547
|
});
|
|
1658
|
-
(0,
|
|
1659
|
-
_MemoryTransport._connections.set(this.
|
|
1548
|
+
(0, import_node_assert9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
|
|
1549
|
+
_MemoryTransport._connections.set(this._instanceId, this);
|
|
1660
1550
|
if (this.options.initiator) {
|
|
1661
1551
|
setTimeout(async () => {
|
|
1662
|
-
(0,
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1666
|
-
line: 68,
|
|
1552
|
+
(0, import_log9.log)("sending signal", {}, {
|
|
1553
|
+
file: "memory-transport.ts",
|
|
1554
|
+
line: 73,
|
|
1667
1555
|
scope: this,
|
|
1668
1556
|
callSite: (f, a) => f(...a)
|
|
1669
1557
|
});
|
|
1670
1558
|
void this.options.sendSignal({
|
|
1671
1559
|
payload: {
|
|
1672
|
-
transportId: this.
|
|
1560
|
+
transportId: this._instanceId.toHex()
|
|
1673
1561
|
}
|
|
1674
1562
|
});
|
|
1675
1563
|
});
|
|
@@ -1680,22 +1568,19 @@ var _MemoryTransport = class {
|
|
|
1680
1568
|
if (this._destroyed) {
|
|
1681
1569
|
return;
|
|
1682
1570
|
}
|
|
1683
|
-
this.
|
|
1684
|
-
this._remoteConnection = _MemoryTransport._connections.get(this.
|
|
1571
|
+
this._remoteInstanceId = remoteId;
|
|
1572
|
+
this._remoteConnection = _MemoryTransport._connections.get(this._remoteInstanceId);
|
|
1685
1573
|
if (!this._remoteConnection) {
|
|
1686
1574
|
this._destroyed = true;
|
|
1687
1575
|
this.closed.emit();
|
|
1688
1576
|
return;
|
|
1689
1577
|
}
|
|
1690
|
-
(0,
|
|
1578
|
+
(0, import_node_assert9.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
|
|
1691
1579
|
this._remoteConnection._remoteConnection = this;
|
|
1692
|
-
this._remoteConnection.
|
|
1693
|
-
(0,
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
}, {
|
|
1697
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1698
|
-
line: 94,
|
|
1580
|
+
this._remoteConnection._remoteInstanceId = this._instanceId;
|
|
1581
|
+
(0, import_log9.log)("connected", {}, {
|
|
1582
|
+
file: "memory-transport.ts",
|
|
1583
|
+
line: 102,
|
|
1699
1584
|
scope: this,
|
|
1700
1585
|
callSite: (f, a) => f(...a)
|
|
1701
1586
|
});
|
|
@@ -1711,80 +1596,77 @@ var _MemoryTransport = class {
|
|
|
1711
1596
|
}
|
|
1712
1597
|
}
|
|
1713
1598
|
async destroy() {
|
|
1714
|
-
(0,
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1718
|
-
line: 115,
|
|
1599
|
+
(0, import_log9.log)("closing", {}, {
|
|
1600
|
+
file: "memory-transport.ts",
|
|
1601
|
+
line: 123,
|
|
1719
1602
|
scope: this,
|
|
1720
1603
|
callSite: (f, a) => f(...a)
|
|
1721
1604
|
});
|
|
1722
1605
|
this._destroyed = true;
|
|
1723
|
-
_MemoryTransport._connections.delete(this.
|
|
1606
|
+
_MemoryTransport._connections.delete(this._instanceId);
|
|
1724
1607
|
if (this._remoteConnection) {
|
|
1725
|
-
(0,
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1729
|
-
line: 120,
|
|
1608
|
+
(0, import_log9.log)("closing", {}, {
|
|
1609
|
+
file: "memory-transport.ts",
|
|
1610
|
+
line: 128,
|
|
1730
1611
|
scope: this,
|
|
1731
1612
|
callSite: (f, a) => f(...a)
|
|
1732
1613
|
});
|
|
1733
1614
|
this._remoteConnection._destroyed = true;
|
|
1734
|
-
_MemoryTransport._connections.delete(this.
|
|
1615
|
+
_MemoryTransport._connections.delete(this._remoteInstanceId);
|
|
1735
1616
|
this._outgoingDelay.unpipe();
|
|
1736
1617
|
this._incomingDelay.unpipe();
|
|
1737
1618
|
this._remoteConnection.closed.emit();
|
|
1738
1619
|
this._remoteConnection._remoteConnection = void 0;
|
|
1739
1620
|
this._remoteConnection = void 0;
|
|
1740
|
-
(0,
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1744
|
-
line: 138,
|
|
1621
|
+
(0, import_log9.log)("closed", {}, {
|
|
1622
|
+
file: "memory-transport.ts",
|
|
1623
|
+
line: 146,
|
|
1745
1624
|
scope: this,
|
|
1746
1625
|
callSite: (f, a) => f(...a)
|
|
1747
1626
|
});
|
|
1748
1627
|
}
|
|
1749
1628
|
this.closed.emit();
|
|
1750
|
-
(0,
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1754
|
-
line: 142,
|
|
1629
|
+
(0, import_log9.log)("closed", {}, {
|
|
1630
|
+
file: "memory-transport.ts",
|
|
1631
|
+
line: 150,
|
|
1755
1632
|
scope: this,
|
|
1756
1633
|
callSite: (f, a) => f(...a)
|
|
1757
1634
|
});
|
|
1758
1635
|
}
|
|
1759
|
-
signal(
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
}
|
|
1636
|
+
signal({ payload }) {
|
|
1637
|
+
(0, import_log9.log)("received signal", {
|
|
1638
|
+
payload
|
|
1639
|
+
}, {
|
|
1640
|
+
file: "memory-transport.ts",
|
|
1641
|
+
line: 154,
|
|
1642
|
+
scope: this,
|
|
1643
|
+
callSite: (f, a) => f(...a)
|
|
1644
|
+
});
|
|
1645
|
+
if (!(payload == null ? void 0 : payload.transportId)) {
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
const transportId = payload.transportId;
|
|
1649
|
+
if (transportId) {
|
|
1650
|
+
const remoteId = import_keys7.PublicKey.fromHex(transportId);
|
|
1651
|
+
this._remote.wake(remoteId);
|
|
1776
1652
|
}
|
|
1777
1653
|
}
|
|
1778
1654
|
};
|
|
1779
1655
|
var MemoryTransport = _MemoryTransport;
|
|
1780
|
-
MemoryTransport._connections = new import_util6.ComplexMap(
|
|
1656
|
+
MemoryTransport._connections = new import_util6.ComplexMap(import_keys7.PublicKey.hash);
|
|
1657
|
+
__decorate4([
|
|
1658
|
+
import_log9.logInfo
|
|
1659
|
+
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
1660
|
+
__decorate4([
|
|
1661
|
+
import_log9.logInfo
|
|
1662
|
+
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
1781
1663
|
|
|
1782
1664
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
1783
|
-
var
|
|
1665
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
1784
1666
|
var import_simple_peer = __toESM(require("simple-peer"));
|
|
1785
1667
|
var import_async8 = require("@dxos/async");
|
|
1786
1668
|
var import_debug5 = require("@dxos/debug");
|
|
1787
|
-
var
|
|
1669
|
+
var import_log10 = require("@dxos/log");
|
|
1788
1670
|
|
|
1789
1671
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
1790
1672
|
var wrtc = null;
|
|
@@ -1801,8 +1683,8 @@ var WebRTCTransport = class {
|
|
|
1801
1683
|
this.closed = new import_async8.Event();
|
|
1802
1684
|
this.connected = new import_async8.Event();
|
|
1803
1685
|
this.errors = new import_debug5.ErrorStream();
|
|
1804
|
-
(0,
|
|
1805
|
-
file: "
|
|
1686
|
+
(0, import_log10.log)("created connection", params, {
|
|
1687
|
+
file: "webrtc-transport.ts",
|
|
1806
1688
|
line: 34,
|
|
1807
1689
|
scope: this,
|
|
1808
1690
|
callSite: (f, a) => f(...a)
|
|
@@ -1813,8 +1695,8 @@ var WebRTCTransport = class {
|
|
|
1813
1695
|
config: this.params.webrtcConfig
|
|
1814
1696
|
});
|
|
1815
1697
|
this._peer.on("signal", async (data) => {
|
|
1816
|
-
(0,
|
|
1817
|
-
file: "
|
|
1698
|
+
(0, import_log10.log)("signal", data, {
|
|
1699
|
+
file: "webrtc-transport.ts",
|
|
1818
1700
|
line: 42,
|
|
1819
1701
|
scope: this,
|
|
1820
1702
|
callSite: (f, a) => f(...a)
|
|
@@ -1826,8 +1708,8 @@ var WebRTCTransport = class {
|
|
|
1826
1708
|
});
|
|
1827
1709
|
});
|
|
1828
1710
|
this._peer.on("connect", () => {
|
|
1829
|
-
(0,
|
|
1830
|
-
file: "
|
|
1711
|
+
(0, import_log10.log)("connected", {}, {
|
|
1712
|
+
file: "webrtc-transport.ts",
|
|
1831
1713
|
line: 47,
|
|
1832
1714
|
scope: this,
|
|
1833
1715
|
callSite: (f, a) => f(...a)
|
|
@@ -1836,8 +1718,8 @@ var WebRTCTransport = class {
|
|
|
1836
1718
|
this.connected.emit();
|
|
1837
1719
|
});
|
|
1838
1720
|
this._peer.on("close", async () => {
|
|
1839
|
-
(0,
|
|
1840
|
-
file: "
|
|
1721
|
+
(0, import_log10.log)("closed", {}, {
|
|
1722
|
+
file: "webrtc-transport.ts",
|
|
1841
1723
|
line: 53,
|
|
1842
1724
|
scope: this,
|
|
1843
1725
|
callSite: (f, a) => f(...a)
|
|
@@ -1851,8 +1733,8 @@ var WebRTCTransport = class {
|
|
|
1851
1733
|
});
|
|
1852
1734
|
}
|
|
1853
1735
|
async destroy() {
|
|
1854
|
-
(0,
|
|
1855
|
-
file: "
|
|
1736
|
+
(0, import_log10.log)("closing...", {}, {
|
|
1737
|
+
file: "webrtc-transport.ts",
|
|
1856
1738
|
line: 65,
|
|
1857
1739
|
scope: this,
|
|
1858
1740
|
callSite: (f, a) => f(...a)
|
|
@@ -1860,16 +1742,16 @@ var WebRTCTransport = class {
|
|
|
1860
1742
|
await this._disconnectStreams();
|
|
1861
1743
|
this._peer.destroy();
|
|
1862
1744
|
this.closed.emit();
|
|
1863
|
-
(0,
|
|
1864
|
-
file: "
|
|
1745
|
+
(0, import_log10.log)("closed", {}, {
|
|
1746
|
+
file: "webrtc-transport.ts",
|
|
1865
1747
|
line: 69,
|
|
1866
1748
|
scope: this,
|
|
1867
1749
|
callSite: (f, a) => f(...a)
|
|
1868
1750
|
});
|
|
1869
1751
|
}
|
|
1870
1752
|
signal(signal) {
|
|
1871
|
-
(0,
|
|
1872
|
-
(0,
|
|
1753
|
+
(0, import_node_assert10.default)(this._peer, "Connection not ready to accept signals.");
|
|
1754
|
+
(0, import_node_assert10.default)(signal.payload.data, "Signal message must contain signal data.");
|
|
1873
1755
|
this._peer.signal(signal.payload.data);
|
|
1874
1756
|
}
|
|
1875
1757
|
async _disconnectStreams() {
|
|
@@ -1885,17 +1767,17 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
1885
1767
|
});
|
|
1886
1768
|
|
|
1887
1769
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
|
|
1888
|
-
var
|
|
1770
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
1889
1771
|
var import_node_stream2 = require("node:stream");
|
|
1890
1772
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
1891
|
-
var
|
|
1892
|
-
var
|
|
1773
|
+
var import_keys8 = require("@dxos/keys");
|
|
1774
|
+
var import_log11 = require("@dxos/log");
|
|
1893
1775
|
var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
1894
1776
|
var import_util7 = require("@dxos/util");
|
|
1895
1777
|
var WebRTCTransportService = class {
|
|
1896
1778
|
constructor(_webrtcConfig) {
|
|
1897
1779
|
this._webrtcConfig = _webrtcConfig;
|
|
1898
|
-
this.transports = new import_util7.ComplexMap(
|
|
1780
|
+
this.transports = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
|
|
1899
1781
|
}
|
|
1900
1782
|
open(request) {
|
|
1901
1783
|
const rpcStream = new import_codec_protobuf.Stream(({ ready, next, close }) => {
|
|
@@ -1960,11 +1842,11 @@ var WebRTCTransportService = class {
|
|
|
1960
1842
|
return rpcStream;
|
|
1961
1843
|
}
|
|
1962
1844
|
async sendSignal({ proxyId, signal }) {
|
|
1963
|
-
(0,
|
|
1845
|
+
(0, import_node_assert11.default)(this.transports.has(proxyId));
|
|
1964
1846
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
1965
1847
|
}
|
|
1966
1848
|
async sendData({ proxyId, payload }) {
|
|
1967
|
-
(0,
|
|
1849
|
+
(0, import_node_assert11.default)(this.transports.has(proxyId));
|
|
1968
1850
|
await this.transports.get(proxyId).stream.push(payload);
|
|
1969
1851
|
}
|
|
1970
1852
|
async close({ proxyId }) {
|
|
@@ -1972,8 +1854,8 @@ var WebRTCTransportService = class {
|
|
|
1972
1854
|
await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
|
|
1973
1855
|
await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
|
|
1974
1856
|
this.transports.delete(proxyId);
|
|
1975
|
-
(0,
|
|
1976
|
-
file: "
|
|
1857
|
+
(0, import_log11.log)("Closed.", {}, {
|
|
1858
|
+
file: "webrtc-transport-service.ts",
|
|
1977
1859
|
line: 108,
|
|
1978
1860
|
scope: this,
|
|
1979
1861
|
callSite: (f, a) => f(...a)
|
|
@@ -1982,11 +1864,11 @@ var WebRTCTransportService = class {
|
|
|
1982
1864
|
};
|
|
1983
1865
|
|
|
1984
1866
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
|
|
1985
|
-
var
|
|
1867
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
1986
1868
|
var import_async9 = require("@dxos/async");
|
|
1987
1869
|
var import_debug6 = require("@dxos/debug");
|
|
1988
|
-
var
|
|
1989
|
-
var
|
|
1870
|
+
var import_keys9 = require("@dxos/keys");
|
|
1871
|
+
var import_log12 = require("@dxos/log");
|
|
1990
1872
|
var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
1991
1873
|
var WebRTCTransportProxy = class {
|
|
1992
1874
|
constructor(_params) {
|
|
@@ -1995,15 +1877,15 @@ var WebRTCTransportProxy = class {
|
|
|
1995
1877
|
this._closed = false;
|
|
1996
1878
|
this.connected = new import_async9.Event();
|
|
1997
1879
|
this.errors = new import_debug6.ErrorStream();
|
|
1998
|
-
this._proxyId =
|
|
1880
|
+
this._proxyId = import_keys9.PublicKey.random();
|
|
1999
1881
|
this._serviceStream = this._params.bridgeService.open({
|
|
2000
1882
|
proxyId: this._proxyId,
|
|
2001
1883
|
initiator: this._params.initiator
|
|
2002
1884
|
});
|
|
2003
1885
|
this._serviceStream.waitUntilReady().then(() => {
|
|
2004
1886
|
this._serviceStream.subscribe(async (event) => {
|
|
2005
|
-
(0,
|
|
2006
|
-
file: "
|
|
1887
|
+
(0, import_log12.log)("WebRTCTransportProxy: event", event, {
|
|
1888
|
+
file: "webrtc-transport-proxy.ts",
|
|
2007
1889
|
line: 46,
|
|
2008
1890
|
scope: this,
|
|
2009
1891
|
callSite: (f, a) => f(...a)
|
|
@@ -2023,16 +1905,16 @@ var WebRTCTransportProxy = class {
|
|
|
2023
1905
|
payload: data
|
|
2024
1906
|
});
|
|
2025
1907
|
} catch (err) {
|
|
2026
|
-
|
|
2027
|
-
file: "
|
|
1908
|
+
import_log12.log.catch(err, {}, {
|
|
1909
|
+
file: "webrtc-transport-proxy.ts",
|
|
2028
1910
|
line: 63,
|
|
2029
1911
|
scope: this,
|
|
2030
1912
|
callSite: (f, a) => f(...a)
|
|
2031
1913
|
});
|
|
2032
1914
|
}
|
|
2033
1915
|
});
|
|
2034
|
-
}, (error) =>
|
|
2035
|
-
file: "
|
|
1916
|
+
}, (error) => import_log12.log.catch(error, {}, {
|
|
1917
|
+
file: "webrtc-transport-proxy.ts",
|
|
2036
1918
|
line: 67,
|
|
2037
1919
|
scope: this,
|
|
2038
1920
|
callSite: (f, a) => f(...a)
|
|
@@ -2075,8 +1957,8 @@ var WebRTCTransportProxy = class {
|
|
|
2075
1957
|
proxyId: this._proxyId
|
|
2076
1958
|
});
|
|
2077
1959
|
} catch (err) {
|
|
2078
|
-
|
|
2079
|
-
file: "
|
|
1960
|
+
import_log12.log.catch(err, {}, {
|
|
1961
|
+
file: "webrtc-transport-proxy.ts",
|
|
2080
1962
|
line: 117,
|
|
2081
1963
|
scope: this,
|
|
2082
1964
|
callSite: (f, a) => f(...a)
|
|
@@ -2103,7 +1985,7 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2103
1985
|
return this;
|
|
2104
1986
|
}
|
|
2105
1987
|
createTransport(options) {
|
|
2106
|
-
(0,
|
|
1988
|
+
(0, import_node_assert12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
|
|
2107
1989
|
const transport = new WebRTCTransportProxy({
|
|
2108
1990
|
...options,
|
|
2109
1991
|
bridgeService: this._bridgeService
|
|
@@ -2115,20 +1997,7 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2115
1997
|
};
|
|
2116
1998
|
|
|
2117
1999
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
2118
|
-
var import_crypto2 = require("@dxos/crypto");
|
|
2119
2000
|
var import_teleport = require("@dxos/teleport");
|
|
2120
|
-
var adaptProtocolProvider = (factory) => ({ initiator, localPeerId, remotePeerId, topic }) => {
|
|
2121
|
-
const protocol = factory({
|
|
2122
|
-
channel: (0, import_crypto2.discoveryKey)(topic),
|
|
2123
|
-
initiator
|
|
2124
|
-
});
|
|
2125
|
-
return {
|
|
2126
|
-
initialize: () => protocol.open(),
|
|
2127
|
-
destroy: () => protocol.close(),
|
|
2128
|
-
stream: protocol.stream,
|
|
2129
|
-
protocol
|
|
2130
|
-
};
|
|
2131
|
-
};
|
|
2132
2001
|
var createTeleportProtocolFactory = (onConnection) => {
|
|
2133
2002
|
return (params) => {
|
|
2134
2003
|
const teleport = new import_teleport.Teleport(params);
|
|
@@ -2163,11 +2032,7 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
2163
2032
|
WebRTCTransportProxy,
|
|
2164
2033
|
WebRTCTransportProxyFactory,
|
|
2165
2034
|
WebRTCTransportService,
|
|
2166
|
-
adaptProtocolProvider,
|
|
2167
|
-
createProtocolFactory,
|
|
2168
2035
|
createTeleportProtocolFactory,
|
|
2169
|
-
createWebRTCTransportFactory
|
|
2170
|
-
protocolFactory,
|
|
2171
|
-
transportProtocolProvider
|
|
2036
|
+
createWebRTCTransportFactory
|
|
2172
2037
|
});
|
|
2173
2038
|
//# sourceMappingURL=index.cjs.map
|