@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
|
@@ -33,6 +33,7 @@ var ConnectionState;
|
|
|
33
33
|
ConnectionState4["INITIAL"] = "INITIAL";
|
|
34
34
|
ConnectionState4["CONNECTING"] = "CONNECTING";
|
|
35
35
|
ConnectionState4["CONNECTED"] = "CONNECTED";
|
|
36
|
+
ConnectionState4["CLOSING"] = "CLOSING";
|
|
36
37
|
ConnectionState4["CLOSED"] = "CLOSED";
|
|
37
38
|
})(ConnectionState || (ConnectionState = {}));
|
|
38
39
|
var Connection = class {
|
|
@@ -88,7 +89,11 @@ var Connection = class {
|
|
|
88
89
|
this._transport = void 0;
|
|
89
90
|
this.close().catch((err) => this.errors.raise(err));
|
|
90
91
|
});
|
|
91
|
-
this._transport.errors.
|
|
92
|
+
this._transport.errors.handle((err) => {
|
|
93
|
+
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
94
|
+
this.errors.raise(err);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
92
97
|
for (const signal of this._bufferedSignals) {
|
|
93
98
|
void this._transport.signal(signal);
|
|
94
99
|
}
|
|
@@ -99,11 +104,12 @@ var Connection = class {
|
|
|
99
104
|
if (this._state === ConnectionState.CLOSED) {
|
|
100
105
|
return;
|
|
101
106
|
}
|
|
107
|
+
this._changeState(ConnectionState.CLOSING);
|
|
102
108
|
log("closing...", {
|
|
103
109
|
peerId: this.ownId
|
|
104
110
|
}, {
|
|
105
|
-
file: "
|
|
106
|
-
line:
|
|
111
|
+
file: "connection.ts",
|
|
112
|
+
line: 142,
|
|
107
113
|
scope: this,
|
|
108
114
|
callSite: (f, a) => f(...a)
|
|
109
115
|
});
|
|
@@ -111,8 +117,8 @@ var Connection = class {
|
|
|
111
117
|
await this._protocol.destroy();
|
|
112
118
|
} catch (err) {
|
|
113
119
|
log.catch(err, {}, {
|
|
114
|
-
file: "
|
|
115
|
-
line:
|
|
120
|
+
file: "connection.ts",
|
|
121
|
+
line: 148,
|
|
116
122
|
scope: this,
|
|
117
123
|
callSite: (f, a) => f(...a)
|
|
118
124
|
});
|
|
@@ -121,8 +127,8 @@ var Connection = class {
|
|
|
121
127
|
await ((_a = this._transport) == null ? void 0 : _a.destroy());
|
|
122
128
|
} catch (err1) {
|
|
123
129
|
log.catch(err1, {}, {
|
|
124
|
-
file: "
|
|
125
|
-
line:
|
|
130
|
+
file: "connection.ts",
|
|
131
|
+
line: 155,
|
|
126
132
|
scope: this,
|
|
127
133
|
callSite: (f, a) => f(...a)
|
|
128
134
|
});
|
|
@@ -130,8 +136,8 @@ var Connection = class {
|
|
|
130
136
|
log("closed", {
|
|
131
137
|
peerId: this.ownId
|
|
132
138
|
}, {
|
|
133
|
-
file: "
|
|
134
|
-
line:
|
|
139
|
+
file: "connection.ts",
|
|
140
|
+
line: 158,
|
|
135
141
|
scope: this,
|
|
136
142
|
callSite: (f, a) => f(...a)
|
|
137
143
|
});
|
|
@@ -142,8 +148,8 @@ var Connection = class {
|
|
|
142
148
|
assert(msg.sessionId);
|
|
143
149
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
144
150
|
log("dropping signal for incorrect session id", {}, {
|
|
145
|
-
file: "
|
|
146
|
-
line:
|
|
151
|
+
file: "connection.ts",
|
|
152
|
+
line: 165,
|
|
147
153
|
scope: this,
|
|
148
154
|
callSite: (f, a) => f(...a)
|
|
149
155
|
});
|
|
@@ -158,8 +164,8 @@ var Connection = class {
|
|
|
158
164
|
remoteId: this.remoteId,
|
|
159
165
|
msg: msg.data
|
|
160
166
|
}, {
|
|
161
|
-
file: "
|
|
162
|
-
line:
|
|
167
|
+
file: "connection.ts",
|
|
168
|
+
line: 173,
|
|
163
169
|
scope: this,
|
|
164
170
|
callSite: (f, a) => f(...a)
|
|
165
171
|
});
|
|
@@ -172,8 +178,8 @@ var Connection = class {
|
|
|
172
178
|
remoteId: this.remoteId,
|
|
173
179
|
msg: msg.data
|
|
174
180
|
}, {
|
|
175
|
-
file: "
|
|
176
|
-
line:
|
|
181
|
+
file: "connection.ts",
|
|
182
|
+
line: 179,
|
|
177
183
|
scope: this,
|
|
178
184
|
callSite: (f, a) => f(...a)
|
|
179
185
|
});
|
|
@@ -226,7 +232,7 @@ var MessageRouter = class {
|
|
|
226
232
|
to: recipient,
|
|
227
233
|
msg: message
|
|
228
234
|
}, {
|
|
229
|
-
file: "
|
|
235
|
+
file: "message-router.ts",
|
|
230
236
|
line: 67,
|
|
231
237
|
scope: this,
|
|
232
238
|
callSite: (f, a) => f(...a)
|
|
@@ -284,7 +290,7 @@ var MessageRouter = class {
|
|
|
284
290
|
to: recipient,
|
|
285
291
|
msg: networkMessage
|
|
286
292
|
}, {
|
|
287
|
-
file: "
|
|
293
|
+
file: "message-router.ts",
|
|
288
294
|
line: 117,
|
|
289
295
|
scope: this,
|
|
290
296
|
callSite: (f, a) => f(...a)
|
|
@@ -315,7 +321,7 @@ var MessageRouter = class {
|
|
|
315
321
|
log2("resolving", {
|
|
316
322
|
answer: message.data.answer
|
|
317
323
|
}, {
|
|
318
|
-
file: "
|
|
324
|
+
file: "message-router.ts",
|
|
319
325
|
line: 146,
|
|
320
326
|
scope: this,
|
|
321
327
|
callSite: (f, a) => f(...a)
|
|
@@ -398,7 +404,7 @@ var Peer = class {
|
|
|
398
404
|
topic: this.topic,
|
|
399
405
|
peerId: this.localPeerId
|
|
400
406
|
}, {
|
|
401
|
-
file: "
|
|
407
|
+
file: "peer.ts",
|
|
402
408
|
line: 83,
|
|
403
409
|
scope: this,
|
|
404
410
|
callSite: (f, a) => f(...a)
|
|
@@ -425,7 +431,7 @@ var Peer = class {
|
|
|
425
431
|
remoteId: this.id,
|
|
426
432
|
err
|
|
427
433
|
}, {
|
|
428
|
-
file: "
|
|
434
|
+
file: "peer.ts",
|
|
429
435
|
line: 107,
|
|
430
436
|
scope: this,
|
|
431
437
|
callSite: (f, a) => f(...a)
|
|
@@ -451,7 +457,7 @@ var Peer = class {
|
|
|
451
457
|
peerId: this.id,
|
|
452
458
|
sessionId
|
|
453
459
|
}, {
|
|
454
|
-
file: "
|
|
460
|
+
file: "peer.ts",
|
|
455
461
|
line: 125,
|
|
456
462
|
scope: this,
|
|
457
463
|
callSite: (f, a) => f(...a)
|
|
@@ -474,14 +480,14 @@ var Peer = class {
|
|
|
474
480
|
ownId: this.localPeerId,
|
|
475
481
|
remoteId: this.id
|
|
476
482
|
}, {
|
|
477
|
-
file: "
|
|
483
|
+
file: "peer.ts",
|
|
478
484
|
line: 137,
|
|
479
485
|
scope: this,
|
|
480
486
|
callSite: (f, a) => f(...a)
|
|
481
487
|
});
|
|
482
488
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
483
489
|
log3("ignoring response", {}, {
|
|
484
|
-
file: "
|
|
490
|
+
file: "peer.ts",
|
|
485
491
|
line: 139,
|
|
486
492
|
scope: this,
|
|
487
493
|
callSite: (f, a) => f(...a)
|
|
@@ -501,7 +507,7 @@ var Peer = class {
|
|
|
501
507
|
remoteId: this.id,
|
|
502
508
|
err
|
|
503
509
|
}, {
|
|
504
|
-
file: "
|
|
510
|
+
file: "peer.ts",
|
|
505
511
|
line: 150,
|
|
506
512
|
scope: this,
|
|
507
513
|
callSite: (f, a) => f(...a)
|
|
@@ -520,7 +526,7 @@ var Peer = class {
|
|
|
520
526
|
initiator,
|
|
521
527
|
sessionId
|
|
522
528
|
}, {
|
|
523
|
-
file: "
|
|
529
|
+
file: "peer.ts",
|
|
524
530
|
line: 164,
|
|
525
531
|
scope: this,
|
|
526
532
|
callSite: (f, a) => f(...a)
|
|
@@ -555,7 +561,7 @@ var Peer = class {
|
|
|
555
561
|
remoteId: this.id,
|
|
556
562
|
initiator
|
|
557
563
|
}, {
|
|
558
|
-
file: "
|
|
564
|
+
file: "peer.ts",
|
|
559
565
|
line: 193,
|
|
560
566
|
scope: this,
|
|
561
567
|
callSite: (f, a) => f(...a)
|
|
@@ -575,19 +581,12 @@ var Peer = class {
|
|
|
575
581
|
initiator,
|
|
576
582
|
err
|
|
577
583
|
}, {
|
|
578
|
-
file: "
|
|
584
|
+
file: "peer.ts",
|
|
579
585
|
line: 203,
|
|
580
586
|
scope: this,
|
|
581
587
|
callSite: (f, a) => f(...a)
|
|
582
588
|
});
|
|
583
|
-
void this.closeConnection()
|
|
584
|
-
log3.catch(err, {}, {
|
|
585
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
|
|
586
|
-
line: 207,
|
|
587
|
-
scope: this,
|
|
588
|
-
callSite: (f, a) => f(...a)
|
|
589
|
-
});
|
|
590
|
-
});
|
|
589
|
+
void this.closeConnection();
|
|
591
590
|
});
|
|
592
591
|
this.connection = connection;
|
|
593
592
|
return connection;
|
|
@@ -601,8 +600,8 @@ var Peer = class {
|
|
|
601
600
|
peerId: this.id,
|
|
602
601
|
sessionId: connection.sessionId
|
|
603
602
|
}, {
|
|
604
|
-
file: "
|
|
605
|
-
line:
|
|
603
|
+
file: "peer.ts",
|
|
604
|
+
line: 219,
|
|
606
605
|
scope: this,
|
|
607
606
|
callSite: (f, a) => f(...a)
|
|
608
607
|
});
|
|
@@ -611,8 +610,8 @@ var Peer = class {
|
|
|
611
610
|
peerId: this.id,
|
|
612
611
|
sessionId: connection.sessionId
|
|
613
612
|
}, {
|
|
614
|
-
file: "
|
|
615
|
-
line:
|
|
613
|
+
file: "peer.ts",
|
|
614
|
+
line: 225,
|
|
616
615
|
scope: this,
|
|
617
616
|
callSite: (f, a) => f(...a)
|
|
618
617
|
});
|
|
@@ -622,8 +621,8 @@ var Peer = class {
|
|
|
622
621
|
log3("dropping signal message for non-existent connection", {
|
|
623
622
|
message
|
|
624
623
|
}, {
|
|
625
|
-
file: "
|
|
626
|
-
line:
|
|
624
|
+
file: "peer.ts",
|
|
625
|
+
line: 230,
|
|
627
626
|
scope: this,
|
|
628
627
|
callSite: (f, a) => f(...a)
|
|
629
628
|
});
|
|
@@ -637,8 +636,8 @@ var Peer = class {
|
|
|
637
636
|
peerId: this.id,
|
|
638
637
|
topic: this.topic
|
|
639
638
|
}, {
|
|
640
|
-
file: "
|
|
641
|
-
line:
|
|
639
|
+
file: "peer.ts",
|
|
640
|
+
line: 238,
|
|
642
641
|
scope: this,
|
|
643
642
|
callSite: (f, a) => f(...a)
|
|
644
643
|
});
|
|
@@ -681,7 +680,7 @@ var Swarm = class {
|
|
|
681
680
|
log4("creating swarm", {
|
|
682
681
|
peerId: _ownPeerId
|
|
683
682
|
}, {
|
|
684
|
-
file: "
|
|
683
|
+
file: "swarm.ts",
|
|
685
684
|
line: 80,
|
|
686
685
|
scope: this,
|
|
687
686
|
callSite: (f, a) => f(...a)
|
|
@@ -698,7 +697,7 @@ var Swarm = class {
|
|
|
698
697
|
payloadType: "dxos.mesh.swarm.SwarmMessage",
|
|
699
698
|
onMessage: async (message) => await this._swarmMessenger.receiveMessage(message)
|
|
700
699
|
}).catch((error) => log4.catch(error, {}, {
|
|
701
|
-
file: "
|
|
700
|
+
file: "swarm.ts",
|
|
702
701
|
line: 96,
|
|
703
702
|
scope: this,
|
|
704
703
|
callSite: (f, a) => f(...a)
|
|
@@ -718,7 +717,7 @@ var Swarm = class {
|
|
|
718
717
|
}
|
|
719
718
|
async destroy() {
|
|
720
719
|
log4("destroying...", {}, {
|
|
721
|
-
file: "
|
|
720
|
+
file: "swarm.ts",
|
|
722
721
|
line: 124,
|
|
723
722
|
scope: this,
|
|
724
723
|
callSite: (f, a) => f(...a)
|
|
@@ -727,7 +726,7 @@ var Swarm = class {
|
|
|
727
726
|
await this._topology.destroy();
|
|
728
727
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
729
728
|
log4("destroyed", {}, {
|
|
730
|
-
file: "
|
|
729
|
+
file: "swarm.ts",
|
|
731
730
|
line: 128,
|
|
732
731
|
scope: this,
|
|
733
732
|
callSite: (f, a) => f(...a)
|
|
@@ -741,7 +740,7 @@ var Swarm = class {
|
|
|
741
740
|
previous: getClassName(this._topology),
|
|
742
741
|
topology: getClassName(topology)
|
|
743
742
|
}, {
|
|
744
|
-
file: "
|
|
743
|
+
file: "swarm.ts",
|
|
745
744
|
line: 135,
|
|
746
745
|
scope: this,
|
|
747
746
|
callSite: (f, a) => f(...a)
|
|
@@ -793,14 +792,14 @@ var Swarm = class {
|
|
|
793
792
|
log4("swarm event", {
|
|
794
793
|
swarmEvent
|
|
795
794
|
}, {
|
|
796
|
-
file: "
|
|
795
|
+
file: "swarm.ts",
|
|
797
796
|
line: 199,
|
|
798
797
|
scope: this,
|
|
799
798
|
callSite: (f, a) => f(...a)
|
|
800
799
|
});
|
|
801
800
|
if (this._ctx.disposed) {
|
|
802
801
|
log4.warn("ignored for destroyed swarm", {}, {
|
|
803
|
-
file: "
|
|
802
|
+
file: "swarm.ts",
|
|
804
803
|
line: 201,
|
|
805
804
|
scope: this,
|
|
806
805
|
callSite: (f, a) => f(...a)
|
|
@@ -812,7 +811,7 @@ var Swarm = class {
|
|
|
812
811
|
log4("new peer", {
|
|
813
812
|
peerId
|
|
814
813
|
}, {
|
|
815
|
-
file: "
|
|
814
|
+
file: "swarm.ts",
|
|
816
815
|
line: 207,
|
|
817
816
|
scope: this,
|
|
818
817
|
callSite: (f, a) => f(...a)
|
|
@@ -837,14 +836,14 @@ var Swarm = class {
|
|
|
837
836
|
log4("offer", {
|
|
838
837
|
message
|
|
839
838
|
}, {
|
|
840
|
-
file: "
|
|
839
|
+
file: "swarm.ts",
|
|
841
840
|
line: 226,
|
|
842
841
|
scope: this,
|
|
843
842
|
callSite: (f, a) => f(...a)
|
|
844
843
|
});
|
|
845
844
|
if (this._ctx.disposed) {
|
|
846
845
|
log4.info("ignored for destroyed swarm", {}, {
|
|
847
|
-
file: "
|
|
846
|
+
file: "swarm.ts",
|
|
848
847
|
line: 228,
|
|
849
848
|
scope: this,
|
|
850
849
|
callSite: (f, a) => f(...a)
|
|
@@ -858,7 +857,7 @@ var Swarm = class {
|
|
|
858
857
|
log4("rejecting offer with incorrect peerId", {
|
|
859
858
|
message
|
|
860
859
|
}, {
|
|
861
|
-
file: "
|
|
860
|
+
file: "swarm.ts",
|
|
862
861
|
line: 235,
|
|
863
862
|
scope: this,
|
|
864
863
|
callSite: (f, a) => f(...a)
|
|
@@ -871,7 +870,7 @@ var Swarm = class {
|
|
|
871
870
|
log4("rejecting offer with incorrect topic", {
|
|
872
871
|
message
|
|
873
872
|
}, {
|
|
874
|
-
file: "
|
|
873
|
+
file: "swarm.ts",
|
|
875
874
|
line: 239,
|
|
876
875
|
scope: this,
|
|
877
876
|
callSite: (f, a) => f(...a)
|
|
@@ -890,14 +889,14 @@ var Swarm = class {
|
|
|
890
889
|
log4("signal", {
|
|
891
890
|
message
|
|
892
891
|
}, {
|
|
893
|
-
file: "
|
|
892
|
+
file: "swarm.ts",
|
|
894
893
|
line: 250,
|
|
895
894
|
scope: this,
|
|
896
895
|
callSite: (f, a) => f(...a)
|
|
897
896
|
});
|
|
898
897
|
if (this._ctx.disposed) {
|
|
899
898
|
log4.info("ignored for destroyed swarm", {}, {
|
|
900
|
-
file: "
|
|
899
|
+
file: "swarm.ts",
|
|
901
900
|
line: 252,
|
|
902
901
|
scope: this,
|
|
903
902
|
callSite: (f, a) => f(...a)
|
|
@@ -926,7 +925,7 @@ var Swarm = class {
|
|
|
926
925
|
await this._initiateConnection(peer);
|
|
927
926
|
} catch (err) {
|
|
928
927
|
log4.warn("initiation error", err, {
|
|
929
|
-
file: "
|
|
928
|
+
file: "swarm.ts",
|
|
930
929
|
line: 287,
|
|
931
930
|
scope: this,
|
|
932
931
|
callSite: (f, a) => f(...a)
|
|
@@ -950,7 +949,7 @@ var Swarm = class {
|
|
|
950
949
|
log4("initiation delay", {
|
|
951
950
|
remoteId
|
|
952
951
|
}, {
|
|
953
|
-
file: "
|
|
952
|
+
file: "swarm.ts",
|
|
954
953
|
line: 312,
|
|
955
954
|
scope: this,
|
|
956
955
|
callSite: (f, a) => f(...a)
|
|
@@ -967,7 +966,7 @@ var Swarm = class {
|
|
|
967
966
|
log4("initiating connection...", {
|
|
968
967
|
remoteId
|
|
969
968
|
}, {
|
|
970
|
-
file: "
|
|
969
|
+
file: "swarm.ts",
|
|
971
970
|
line: 326,
|
|
972
971
|
scope: this,
|
|
973
972
|
callSite: (f, a) => f(...a)
|
|
@@ -977,7 +976,7 @@ var Swarm = class {
|
|
|
977
976
|
log4("initiated", {
|
|
978
977
|
remoteId
|
|
979
978
|
}, {
|
|
980
|
-
file: "
|
|
979
|
+
file: "swarm.ts",
|
|
981
980
|
line: 329,
|
|
982
981
|
scope: this,
|
|
983
982
|
callSite: (f, a) => f(...a)
|
|
@@ -1010,9 +1009,8 @@ var SwarmMapper = class {
|
|
|
1010
1009
|
get peers() {
|
|
1011
1010
|
return Array.from(this._peers.values());
|
|
1012
1011
|
}
|
|
1013
|
-
constructor(_swarm
|
|
1012
|
+
constructor(_swarm) {
|
|
1014
1013
|
this._swarm = _swarm;
|
|
1015
|
-
this._presence = _presence;
|
|
1016
1014
|
this._subscriptions = new EventSubscriptions();
|
|
1017
1015
|
this._connectionSubscriptions = new ComplexMap3(PublicKey4.hash);
|
|
1018
1016
|
this._peers = new ComplexMap3(PublicKey4.hash);
|
|
@@ -1029,17 +1027,12 @@ var SwarmMapper = class {
|
|
|
1029
1027
|
this._connectionSubscriptions.delete(peerId);
|
|
1030
1028
|
this._update();
|
|
1031
1029
|
}));
|
|
1032
|
-
if (_presence) {
|
|
1033
|
-
this._subscriptions.add(_presence.graphUpdated.on(() => {
|
|
1034
|
-
this._update();
|
|
1035
|
-
}));
|
|
1036
|
-
}
|
|
1037
1030
|
this._update();
|
|
1038
1031
|
}
|
|
1039
1032
|
_update() {
|
|
1040
1033
|
log5("updating swarm", {}, {
|
|
1041
|
-
file: "
|
|
1042
|
-
line:
|
|
1034
|
+
file: "swarm-mapper.ts",
|
|
1035
|
+
line: 75,
|
|
1043
1036
|
scope: this,
|
|
1044
1037
|
callSite: (f, a) => f(...a)
|
|
1045
1038
|
});
|
|
@@ -1058,32 +1051,12 @@ var SwarmMapper = class {
|
|
|
1058
1051
|
]
|
|
1059
1052
|
});
|
|
1060
1053
|
}
|
|
1061
|
-
if (this._presence) {
|
|
1062
|
-
this._presence.graph.forEachNode((node) => {
|
|
1063
|
-
const id = PublicKey4.fromHex(node.id);
|
|
1064
|
-
if (this._peers.has(id)) {
|
|
1065
|
-
return;
|
|
1066
|
-
}
|
|
1067
|
-
this._peers.set(id, {
|
|
1068
|
-
id,
|
|
1069
|
-
state: "INDIRECTLY_CONNECTED",
|
|
1070
|
-
connections: []
|
|
1071
|
-
});
|
|
1072
|
-
});
|
|
1073
|
-
this._presence.graph.forEachLink((link) => {
|
|
1074
|
-
const from = PublicKey4.from(link.fromId);
|
|
1075
|
-
const to = PublicKey4.from(link.toId);
|
|
1076
|
-
if (!from.equals(this._swarm.ownPeerId) && !to.equals(this._swarm.ownPeerId)) {
|
|
1077
|
-
this._peers.get(from).connections.push(to);
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
1054
|
log5("graph changed", {
|
|
1082
1055
|
directConnections: this._swarm.connections.length,
|
|
1083
1056
|
totalPeersInSwarm: this._peers.size
|
|
1084
1057
|
}, {
|
|
1085
|
-
file: "
|
|
1086
|
-
line:
|
|
1058
|
+
file: "swarm-mapper.ts",
|
|
1059
|
+
line: 116,
|
|
1087
1060
|
scope: this,
|
|
1088
1061
|
callSite: (f, a) => f(...a)
|
|
1089
1062
|
});
|
|
@@ -1127,13 +1100,12 @@ var ConnectionLog = class {
|
|
|
1127
1100
|
this._swarms.set(swarm.instanceId, info);
|
|
1128
1101
|
this.update.emit();
|
|
1129
1102
|
swarm.connectionAdded.on((connection) => {
|
|
1130
|
-
var _a, _b, _c, _d, _e;
|
|
1131
1103
|
const connectionInfo = {
|
|
1132
1104
|
state: ConnectionState.INITIAL,
|
|
1133
1105
|
remotePeerId: connection.remoteId,
|
|
1134
1106
|
sessionId: connection.sessionId,
|
|
1135
1107
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
1136
|
-
protocolExtensions:
|
|
1108
|
+
protocolExtensions: [],
|
|
1137
1109
|
events: []
|
|
1138
1110
|
};
|
|
1139
1111
|
info.connections.push(connectionInfo);
|
|
@@ -1146,32 +1118,6 @@ var ConnectionLog = class {
|
|
|
1146
1118
|
});
|
|
1147
1119
|
this.update.emit();
|
|
1148
1120
|
});
|
|
1149
|
-
(_b = connection.protocol.protocol) == null ? void 0 : _b.error.on((error) => {
|
|
1150
|
-
var _a2;
|
|
1151
|
-
connectionInfo.events.push({
|
|
1152
|
-
type: EventType.PROTOCOL_ERROR,
|
|
1153
|
-
error: (_a2 = error.stack) != null ? _a2 : error.message
|
|
1154
|
-
});
|
|
1155
|
-
this.update.emit();
|
|
1156
|
-
});
|
|
1157
|
-
(_c = connection.protocol.protocol) == null ? void 0 : _c.extensionsInitialized.on(() => {
|
|
1158
|
-
connectionInfo.events.push({
|
|
1159
|
-
type: EventType.PROTOCOL_EXTENSIONS_INITIALIZED
|
|
1160
|
-
});
|
|
1161
|
-
this.update.emit();
|
|
1162
|
-
});
|
|
1163
|
-
(_d = connection.protocol.protocol) == null ? void 0 : _d.extensionsHandshake.on(() => {
|
|
1164
|
-
connectionInfo.events.push({
|
|
1165
|
-
type: EventType.PROTOCOL_EXTENSIONS_HANDSHAKE
|
|
1166
|
-
});
|
|
1167
|
-
this.update.emit();
|
|
1168
|
-
});
|
|
1169
|
-
(_e = connection.protocol.protocol) == null ? void 0 : _e.handshake.on(() => {
|
|
1170
|
-
connectionInfo.events.push({
|
|
1171
|
-
type: EventType.PROTOCOL_HANDSHAKE
|
|
1172
|
-
});
|
|
1173
|
-
this.update.emit();
|
|
1174
|
-
});
|
|
1175
1121
|
});
|
|
1176
1122
|
}
|
|
1177
1123
|
swarmLeft(swarm) {
|
|
@@ -1188,7 +1134,7 @@ import { log as log6 } from "@dxos/log";
|
|
|
1188
1134
|
import { Messenger } from "@dxos/messaging";
|
|
1189
1135
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1190
1136
|
var NetworkManager = class {
|
|
1191
|
-
constructor({ transportFactory, signalManager, log:
|
|
1137
|
+
constructor({ transportFactory, signalManager, log: log13 }) {
|
|
1192
1138
|
this._swarms = new ComplexMap5(PublicKey6.hash);
|
|
1193
1139
|
this._mappers = new ComplexMap5(PublicKey6.hash);
|
|
1194
1140
|
this.topicsUpdated = new Event5();
|
|
@@ -1205,7 +1151,7 @@ var NetworkManager = class {
|
|
|
1205
1151
|
join: (opts) => this._signalManager.join(opts),
|
|
1206
1152
|
leave: (opts) => this._signalManager.leave(opts)
|
|
1207
1153
|
};
|
|
1208
|
-
if (
|
|
1154
|
+
if (log13) {
|
|
1209
1155
|
this._connectionLog = new ConnectionLog();
|
|
1210
1156
|
}
|
|
1211
1157
|
}
|
|
@@ -1228,8 +1174,8 @@ var NetworkManager = class {
|
|
|
1228
1174
|
for (const topic of this._swarms.keys()) {
|
|
1229
1175
|
await this.leaveSwarm(topic).catch((err) => {
|
|
1230
1176
|
log6(err, {}, {
|
|
1231
|
-
file: "
|
|
1232
|
-
line:
|
|
1177
|
+
file: "network-manager.ts",
|
|
1178
|
+
line: 122,
|
|
1233
1179
|
scope: this,
|
|
1234
1180
|
callSite: (f, a) => f(...a)
|
|
1235
1181
|
});
|
|
@@ -1237,7 +1183,7 @@ var NetworkManager = class {
|
|
|
1237
1183
|
}
|
|
1238
1184
|
await this._signalManager.destroy();
|
|
1239
1185
|
}
|
|
1240
|
-
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol,
|
|
1186
|
+
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1241
1187
|
var _a;
|
|
1242
1188
|
assert5(PublicKey6.isPublicKey(topic));
|
|
1243
1189
|
assert5(PublicKey6.isPublicKey(peerId));
|
|
@@ -1251,8 +1197,8 @@ var NetworkManager = class {
|
|
|
1251
1197
|
peerId,
|
|
1252
1198
|
topology: topology.toString()
|
|
1253
1199
|
}, {
|
|
1254
|
-
file: "
|
|
1255
|
-
line:
|
|
1200
|
+
file: "network-manager.ts",
|
|
1201
|
+
line: 148,
|
|
1256
1202
|
scope: this,
|
|
1257
1203
|
callSite: (f, a) => f(...a)
|
|
1258
1204
|
});
|
|
@@ -1261,8 +1207,8 @@ var NetworkManager = class {
|
|
|
1261
1207
|
log6("swarm error", {
|
|
1262
1208
|
error
|
|
1263
1209
|
}, {
|
|
1264
|
-
file: "
|
|
1265
|
-
line:
|
|
1210
|
+
file: "network-manager.ts",
|
|
1211
|
+
line: 151,
|
|
1266
1212
|
scope: this,
|
|
1267
1213
|
callSite: (f, a) => f(...a)
|
|
1268
1214
|
});
|
|
@@ -1272,20 +1218,20 @@ var NetworkManager = class {
|
|
|
1272
1218
|
topic,
|
|
1273
1219
|
peerId
|
|
1274
1220
|
}).catch((error) => log6.catch(error, {}, {
|
|
1275
|
-
file: "
|
|
1276
|
-
line:
|
|
1221
|
+
file: "network-manager.ts",
|
|
1222
|
+
line: 155,
|
|
1277
1223
|
scope: this,
|
|
1278
1224
|
callSite: (f, a) => f(...a)
|
|
1279
1225
|
}));
|
|
1280
|
-
this._mappers.set(topic, new SwarmMapper(swarm
|
|
1226
|
+
this._mappers.set(topic, new SwarmMapper(swarm));
|
|
1281
1227
|
this.topicsUpdated.emit();
|
|
1282
1228
|
(_a = this._connectionLog) == null ? void 0 : _a.swarmJoined(swarm);
|
|
1283
1229
|
log6("joined", {
|
|
1284
1230
|
topic: PublicKey6.from(topic),
|
|
1285
1231
|
count: this._swarms.size
|
|
1286
1232
|
}, {
|
|
1287
|
-
file: "
|
|
1288
|
-
line:
|
|
1233
|
+
file: "network-manager.ts",
|
|
1234
|
+
line: 160,
|
|
1289
1235
|
scope: this,
|
|
1290
1236
|
callSite: (f, a) => f(...a)
|
|
1291
1237
|
});
|
|
@@ -1299,8 +1245,8 @@ var NetworkManager = class {
|
|
|
1299
1245
|
log6.warn("swarm not open", {
|
|
1300
1246
|
topic: PublicKey6.from(topic)
|
|
1301
1247
|
}, {
|
|
1302
|
-
file: "
|
|
1303
|
-
line:
|
|
1248
|
+
file: "network-manager.ts",
|
|
1249
|
+
line: 172,
|
|
1304
1250
|
scope: this,
|
|
1305
1251
|
callSite: (f, a) => f(...a)
|
|
1306
1252
|
});
|
|
@@ -1309,8 +1255,8 @@ var NetworkManager = class {
|
|
|
1309
1255
|
log6("leaving", {
|
|
1310
1256
|
topic: PublicKey6.from(topic)
|
|
1311
1257
|
}, {
|
|
1312
|
-
file: "
|
|
1313
|
-
line:
|
|
1258
|
+
file: "network-manager.ts",
|
|
1259
|
+
line: 176,
|
|
1314
1260
|
scope: this,
|
|
1315
1261
|
callSite: (f, a) => f(...a)
|
|
1316
1262
|
});
|
|
@@ -1330,86 +1276,26 @@ var NetworkManager = class {
|
|
|
1330
1276
|
topic: PublicKey6.from(topic),
|
|
1331
1277
|
count: this._swarms.size
|
|
1332
1278
|
}, {
|
|
1333
|
-
file: "
|
|
1334
|
-
line:
|
|
1279
|
+
file: "network-manager.ts",
|
|
1280
|
+
line: 190,
|
|
1335
1281
|
scope: this,
|
|
1336
1282
|
callSite: (f, a) => f(...a)
|
|
1337
1283
|
});
|
|
1338
1284
|
}
|
|
1339
1285
|
};
|
|
1340
1286
|
|
|
1341
|
-
// packages/core/mesh/network-manager/src/protocol-factory.ts
|
|
1342
|
-
import assert6 from "@dxos/node-std/assert";
|
|
1343
|
-
import { discoveryKey } from "@dxos/crypto";
|
|
1344
|
-
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1345
|
-
import { log as log7 } from "@dxos/log";
|
|
1346
|
-
import { Protocol } from "@dxos/mesh-protocol";
|
|
1347
|
-
var protocolFactory = ({ session = {}, plugins = [], getTopics }) => {
|
|
1348
|
-
assert6(getTopics);
|
|
1349
|
-
return ({ channel, initiator }) => {
|
|
1350
|
-
log7("creating protocol", {}, {
|
|
1351
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/protocol-factory.ts",
|
|
1352
|
-
line: 41,
|
|
1353
|
-
scope: void 0,
|
|
1354
|
-
callSite: (f, a) => f(...a)
|
|
1355
|
-
});
|
|
1356
|
-
const protocol = new Protocol({
|
|
1357
|
-
streamOptions: {
|
|
1358
|
-
live: true
|
|
1359
|
-
},
|
|
1360
|
-
discoveryToPublicKey: (dk) => {
|
|
1361
|
-
const publicKey = getTopics().find((topic) => discoveryKey(topic).equals(dk));
|
|
1362
|
-
if (publicKey) {
|
|
1363
|
-
protocol.setContext({
|
|
1364
|
-
topic: PublicKey7.stringify(publicKey)
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
assert6(publicKey, "PublicKey not found in discovery.");
|
|
1368
|
-
return publicKey;
|
|
1369
|
-
},
|
|
1370
|
-
initiator,
|
|
1371
|
-
userSession: session,
|
|
1372
|
-
discoveryKey: channel
|
|
1373
|
-
});
|
|
1374
|
-
protocol.setExtensions(plugins.map((plugin) => plugin.createExtension())).init();
|
|
1375
|
-
return protocol;
|
|
1376
|
-
};
|
|
1377
|
-
};
|
|
1378
|
-
var createProtocolFactory = (topic, peerId, plugins) => protocolFactory({
|
|
1379
|
-
getTopics: () => [
|
|
1380
|
-
topic.asBuffer()
|
|
1381
|
-
],
|
|
1382
|
-
session: {
|
|
1383
|
-
peerId: PublicKey7.stringify(peerId.asBuffer())
|
|
1384
|
-
},
|
|
1385
|
-
plugins
|
|
1386
|
-
});
|
|
1387
|
-
var transportProtocolProvider = (rendezvousKey, peerId, protocolPlugin) => {
|
|
1388
|
-
return protocolFactory({
|
|
1389
|
-
getTopics: () => [
|
|
1390
|
-
rendezvousKey
|
|
1391
|
-
],
|
|
1392
|
-
session: {
|
|
1393
|
-
peerId: PublicKey7.stringify(peerId)
|
|
1394
|
-
},
|
|
1395
|
-
plugins: [
|
|
1396
|
-
protocolPlugin
|
|
1397
|
-
]
|
|
1398
|
-
});
|
|
1399
|
-
};
|
|
1400
|
-
|
|
1401
1287
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
1402
|
-
import
|
|
1288
|
+
import assert6 from "@dxos/node-std/assert";
|
|
1403
1289
|
var FullyConnectedTopology = class {
|
|
1404
1290
|
toString() {
|
|
1405
1291
|
return "FullyConnectedTopology";
|
|
1406
1292
|
}
|
|
1407
1293
|
init(controller) {
|
|
1408
|
-
|
|
1294
|
+
assert6(!this._controller, "Already initialized");
|
|
1409
1295
|
this._controller = controller;
|
|
1410
1296
|
}
|
|
1411
1297
|
update() {
|
|
1412
|
-
|
|
1298
|
+
assert6(this._controller, "Not initialized");
|
|
1413
1299
|
const { candidates: discovered } = this._controller.getState();
|
|
1414
1300
|
for (const peer of discovered) {
|
|
1415
1301
|
this._controller.connect(peer);
|
|
@@ -1423,9 +1309,9 @@ var FullyConnectedTopology = class {
|
|
|
1423
1309
|
};
|
|
1424
1310
|
|
|
1425
1311
|
// packages/core/mesh/network-manager/src/topology/mmst-topology.ts
|
|
1426
|
-
import
|
|
1312
|
+
import assert7 from "@dxos/node-std/assert";
|
|
1427
1313
|
import distance from "xor-distance";
|
|
1428
|
-
import { log as
|
|
1314
|
+
import { log as log7 } from "@dxos/log";
|
|
1429
1315
|
var MMSTTopology = class {
|
|
1430
1316
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
1431
1317
|
this._sampleCollected = false;
|
|
@@ -1434,15 +1320,15 @@ var MMSTTopology = class {
|
|
|
1434
1320
|
this._sampleSize = sampleSize;
|
|
1435
1321
|
}
|
|
1436
1322
|
init(controller) {
|
|
1437
|
-
|
|
1323
|
+
assert7(!this._controller, "Already initialized");
|
|
1438
1324
|
this._controller = controller;
|
|
1439
1325
|
}
|
|
1440
1326
|
update() {
|
|
1441
|
-
|
|
1327
|
+
assert7(this._controller, "Not initialized");
|
|
1442
1328
|
const { connected, candidates } = this._controller.getState();
|
|
1443
1329
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
1444
|
-
|
|
1445
|
-
file: "
|
|
1330
|
+
log7("Running the algorithm.", {}, {
|
|
1331
|
+
file: "mmst-topology.ts",
|
|
1446
1332
|
line: 55,
|
|
1447
1333
|
scope: this,
|
|
1448
1334
|
callSite: (f, a) => f(...a)
|
|
@@ -1452,11 +1338,11 @@ var MMSTTopology = class {
|
|
|
1452
1338
|
}
|
|
1453
1339
|
}
|
|
1454
1340
|
async onOffer(peer) {
|
|
1455
|
-
|
|
1341
|
+
assert7(this._controller, "Not initialized");
|
|
1456
1342
|
const { connected } = this._controller.getState();
|
|
1457
1343
|
const accept = connected.length < this._maxPeers;
|
|
1458
|
-
|
|
1459
|
-
file: "
|
|
1344
|
+
log7(`Offer ${peer} accept=${accept}`, {}, {
|
|
1345
|
+
file: "mmst-topology.ts",
|
|
1460
1346
|
line: 65,
|
|
1461
1347
|
scope: this,
|
|
1462
1348
|
callSite: (f, a) => f(...a)
|
|
@@ -1466,13 +1352,13 @@ var MMSTTopology = class {
|
|
|
1466
1352
|
async destroy() {
|
|
1467
1353
|
}
|
|
1468
1354
|
_runAlgorithm() {
|
|
1469
|
-
|
|
1355
|
+
assert7(this._controller, "Not initialized");
|
|
1470
1356
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
1471
1357
|
if (connected.length > this._maxPeers) {
|
|
1472
1358
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
1473
1359
|
for (const peer of sorted) {
|
|
1474
|
-
|
|
1475
|
-
file: "
|
|
1360
|
+
log7(`Disconnect ${peer}.`, {}, {
|
|
1361
|
+
file: "mmst-topology.ts",
|
|
1476
1362
|
line: 83,
|
|
1477
1363
|
scope: this,
|
|
1478
1364
|
callSite: (f, a) => f(...a)
|
|
@@ -1483,8 +1369,8 @@ var MMSTTopology = class {
|
|
|
1483
1369
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
1484
1370
|
const sorted1 = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
1485
1371
|
for (const peer1 of sorted1) {
|
|
1486
|
-
|
|
1487
|
-
file: "
|
|
1372
|
+
log7(`Connect ${peer1}.`, {}, {
|
|
1373
|
+
file: "mmst-topology.ts",
|
|
1488
1374
|
line: 91,
|
|
1489
1375
|
scope: this,
|
|
1490
1376
|
callSite: (f, a) => f(...a)
|
|
@@ -1500,8 +1386,8 @@ var MMSTTopology = class {
|
|
|
1500
1386
|
var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
|
|
1501
1387
|
|
|
1502
1388
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
1503
|
-
import
|
|
1504
|
-
import { log as
|
|
1389
|
+
import assert8 from "@dxos/node-std/assert";
|
|
1390
|
+
import { log as log8 } from "@dxos/log";
|
|
1505
1391
|
var StarTopology = class {
|
|
1506
1392
|
constructor(_centralPeer) {
|
|
1507
1393
|
this._centralPeer = _centralPeer;
|
|
@@ -1510,25 +1396,25 @@ var StarTopology = class {
|
|
|
1510
1396
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
1511
1397
|
}
|
|
1512
1398
|
init(controller) {
|
|
1513
|
-
|
|
1399
|
+
assert8(!this._controller, "Already initialized.");
|
|
1514
1400
|
this._controller = controller;
|
|
1515
1401
|
}
|
|
1516
1402
|
update() {
|
|
1517
|
-
|
|
1403
|
+
assert8(this._controller, "Not initialized.");
|
|
1518
1404
|
const { candidates, connected, ownPeerId } = this._controller.getState();
|
|
1519
1405
|
if (!ownPeerId.equals(this._centralPeer)) {
|
|
1520
|
-
|
|
1521
|
-
file: "
|
|
1406
|
+
log8("leaf peer dropping all connections apart from central peer.", {}, {
|
|
1407
|
+
file: "star-topology.ts",
|
|
1522
1408
|
line: 33,
|
|
1523
1409
|
scope: this,
|
|
1524
1410
|
callSite: (f, a) => f(...a)
|
|
1525
1411
|
});
|
|
1526
1412
|
for (const peer of connected) {
|
|
1527
1413
|
if (!peer.equals(this._centralPeer)) {
|
|
1528
|
-
|
|
1414
|
+
log8("dropping connection", {
|
|
1529
1415
|
peer
|
|
1530
1416
|
}, {
|
|
1531
|
-
file: "
|
|
1417
|
+
file: "star-topology.ts",
|
|
1532
1418
|
line: 38,
|
|
1533
1419
|
scope: this,
|
|
1534
1420
|
callSite: (f, a) => f(...a)
|
|
@@ -1539,10 +1425,10 @@ var StarTopology = class {
|
|
|
1539
1425
|
}
|
|
1540
1426
|
for (const peer1 of candidates) {
|
|
1541
1427
|
if (peer1.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
|
|
1542
|
-
|
|
1428
|
+
log8("connecting to peer", {
|
|
1543
1429
|
peer: peer1
|
|
1544
1430
|
}, {
|
|
1545
|
-
file: "
|
|
1431
|
+
file: "star-topology.ts",
|
|
1546
1432
|
line: 47,
|
|
1547
1433
|
scope: this,
|
|
1548
1434
|
callSite: (f, a) => f(...a)
|
|
@@ -1552,14 +1438,14 @@ var StarTopology = class {
|
|
|
1552
1438
|
}
|
|
1553
1439
|
}
|
|
1554
1440
|
async onOffer(peer) {
|
|
1555
|
-
|
|
1441
|
+
assert8(this._controller, "Not initialized.");
|
|
1556
1442
|
const { ownPeerId } = this._controller.getState();
|
|
1557
|
-
|
|
1443
|
+
log8("offer", {
|
|
1558
1444
|
peer,
|
|
1559
1445
|
isCentral: peer.equals(this._centralPeer),
|
|
1560
1446
|
isSelfCentral: ownPeerId.equals(this._centralPeer)
|
|
1561
1447
|
}, {
|
|
1562
|
-
file: "
|
|
1448
|
+
file: "star-topology.ts",
|
|
1563
1449
|
line: 56,
|
|
1564
1450
|
scope: this,
|
|
1565
1451
|
callSite: (f, a) => f(...a)
|
|
@@ -1571,13 +1457,23 @@ var StarTopology = class {
|
|
|
1571
1457
|
};
|
|
1572
1458
|
|
|
1573
1459
|
// packages/core/mesh/network-manager/src/transport/memory-transport.ts
|
|
1574
|
-
import
|
|
1460
|
+
import assert9 from "@dxos/node-std/assert";
|
|
1575
1461
|
import { Transform } from "@dxos/node-std/stream";
|
|
1576
1462
|
import { Event as Event6, Trigger } from "@dxos/async";
|
|
1577
1463
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
1578
|
-
import { PublicKey as
|
|
1579
|
-
import { log as
|
|
1464
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1465
|
+
import { log as log9, logInfo as logInfo2 } from "@dxos/log";
|
|
1580
1466
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1467
|
+
var __decorate4 = function(decorators, target, key, desc) {
|
|
1468
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1469
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1470
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1471
|
+
else
|
|
1472
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1473
|
+
if (d = decorators[i])
|
|
1474
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1475
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1476
|
+
};
|
|
1581
1477
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
1582
1478
|
var createStreamDelay = (delay) => {
|
|
1583
1479
|
return new Transform({
|
|
@@ -1597,34 +1493,30 @@ var _MemoryTransport = class {
|
|
|
1597
1493
|
this.closed = new Event6();
|
|
1598
1494
|
this.connected = new Event6();
|
|
1599
1495
|
this.errors = new ErrorStream3();
|
|
1600
|
-
this._id = PublicKey8.random();
|
|
1601
1496
|
this._remote = new Trigger();
|
|
1602
1497
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1603
1498
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1604
1499
|
this._destroyed = false;
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
line: 59,
|
|
1500
|
+
this._instanceId = PublicKey7.random();
|
|
1501
|
+
log9("creating", {}, {
|
|
1502
|
+
file: "memory-transport.ts",
|
|
1503
|
+
line: 64,
|
|
1610
1504
|
scope: this,
|
|
1611
1505
|
callSite: (f, a) => f(...a)
|
|
1612
1506
|
});
|
|
1613
|
-
|
|
1614
|
-
_MemoryTransport._connections.set(this.
|
|
1507
|
+
assert9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
|
|
1508
|
+
_MemoryTransport._connections.set(this._instanceId, this);
|
|
1615
1509
|
if (this.options.initiator) {
|
|
1616
1510
|
setTimeout(async () => {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1621
|
-
line: 68,
|
|
1511
|
+
log9("sending signal", {}, {
|
|
1512
|
+
file: "memory-transport.ts",
|
|
1513
|
+
line: 73,
|
|
1622
1514
|
scope: this,
|
|
1623
1515
|
callSite: (f, a) => f(...a)
|
|
1624
1516
|
});
|
|
1625
1517
|
void this.options.sendSignal({
|
|
1626
1518
|
payload: {
|
|
1627
|
-
transportId: this.
|
|
1519
|
+
transportId: this._instanceId.toHex()
|
|
1628
1520
|
}
|
|
1629
1521
|
});
|
|
1630
1522
|
});
|
|
@@ -1635,22 +1527,19 @@ var _MemoryTransport = class {
|
|
|
1635
1527
|
if (this._destroyed) {
|
|
1636
1528
|
return;
|
|
1637
1529
|
}
|
|
1638
|
-
this.
|
|
1639
|
-
this._remoteConnection = _MemoryTransport._connections.get(this.
|
|
1530
|
+
this._remoteInstanceId = remoteId;
|
|
1531
|
+
this._remoteConnection = _MemoryTransport._connections.get(this._remoteInstanceId);
|
|
1640
1532
|
if (!this._remoteConnection) {
|
|
1641
1533
|
this._destroyed = true;
|
|
1642
1534
|
this.closed.emit();
|
|
1643
1535
|
return;
|
|
1644
1536
|
}
|
|
1645
|
-
|
|
1537
|
+
assert9(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
|
|
1646
1538
|
this._remoteConnection._remoteConnection = this;
|
|
1647
|
-
this._remoteConnection.
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
}, {
|
|
1652
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1653
|
-
line: 94,
|
|
1539
|
+
this._remoteConnection._remoteInstanceId = this._instanceId;
|
|
1540
|
+
log9("connected", {}, {
|
|
1541
|
+
file: "memory-transport.ts",
|
|
1542
|
+
line: 102,
|
|
1654
1543
|
scope: this,
|
|
1655
1544
|
callSite: (f, a) => f(...a)
|
|
1656
1545
|
});
|
|
@@ -1666,80 +1555,77 @@ var _MemoryTransport = class {
|
|
|
1666
1555
|
}
|
|
1667
1556
|
}
|
|
1668
1557
|
async destroy() {
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1673
|
-
line: 115,
|
|
1558
|
+
log9("closing", {}, {
|
|
1559
|
+
file: "memory-transport.ts",
|
|
1560
|
+
line: 123,
|
|
1674
1561
|
scope: this,
|
|
1675
1562
|
callSite: (f, a) => f(...a)
|
|
1676
1563
|
});
|
|
1677
1564
|
this._destroyed = true;
|
|
1678
|
-
_MemoryTransport._connections.delete(this.
|
|
1565
|
+
_MemoryTransport._connections.delete(this._instanceId);
|
|
1679
1566
|
if (this._remoteConnection) {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1684
|
-
line: 120,
|
|
1567
|
+
log9("closing", {}, {
|
|
1568
|
+
file: "memory-transport.ts",
|
|
1569
|
+
line: 128,
|
|
1685
1570
|
scope: this,
|
|
1686
1571
|
callSite: (f, a) => f(...a)
|
|
1687
1572
|
});
|
|
1688
1573
|
this._remoteConnection._destroyed = true;
|
|
1689
|
-
_MemoryTransport._connections.delete(this.
|
|
1574
|
+
_MemoryTransport._connections.delete(this._remoteInstanceId);
|
|
1690
1575
|
this._outgoingDelay.unpipe();
|
|
1691
1576
|
this._incomingDelay.unpipe();
|
|
1692
1577
|
this._remoteConnection.closed.emit();
|
|
1693
1578
|
this._remoteConnection._remoteConnection = void 0;
|
|
1694
1579
|
this._remoteConnection = void 0;
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1699
|
-
line: 138,
|
|
1580
|
+
log9("closed", {}, {
|
|
1581
|
+
file: "memory-transport.ts",
|
|
1582
|
+
line: 146,
|
|
1700
1583
|
scope: this,
|
|
1701
1584
|
callSite: (f, a) => f(...a)
|
|
1702
1585
|
});
|
|
1703
1586
|
}
|
|
1704
1587
|
this.closed.emit();
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
|
|
1709
|
-
line: 142,
|
|
1588
|
+
log9("closed", {}, {
|
|
1589
|
+
file: "memory-transport.ts",
|
|
1590
|
+
line: 150,
|
|
1710
1591
|
scope: this,
|
|
1711
1592
|
callSite: (f, a) => f(...a)
|
|
1712
1593
|
});
|
|
1713
1594
|
}
|
|
1714
|
-
signal(
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
}
|
|
1595
|
+
signal({ payload }) {
|
|
1596
|
+
log9("received signal", {
|
|
1597
|
+
payload
|
|
1598
|
+
}, {
|
|
1599
|
+
file: "memory-transport.ts",
|
|
1600
|
+
line: 154,
|
|
1601
|
+
scope: this,
|
|
1602
|
+
callSite: (f, a) => f(...a)
|
|
1603
|
+
});
|
|
1604
|
+
if (!(payload == null ? void 0 : payload.transportId)) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
const transportId = payload.transportId;
|
|
1608
|
+
if (transportId) {
|
|
1609
|
+
const remoteId = PublicKey7.fromHex(transportId);
|
|
1610
|
+
this._remote.wake(remoteId);
|
|
1731
1611
|
}
|
|
1732
1612
|
}
|
|
1733
1613
|
};
|
|
1734
1614
|
var MemoryTransport = _MemoryTransport;
|
|
1735
|
-
MemoryTransport._connections = new ComplexMap6(
|
|
1615
|
+
MemoryTransport._connections = new ComplexMap6(PublicKey7.hash);
|
|
1616
|
+
__decorate4([
|
|
1617
|
+
logInfo2
|
|
1618
|
+
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
1619
|
+
__decorate4([
|
|
1620
|
+
logInfo2
|
|
1621
|
+
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
1736
1622
|
|
|
1737
1623
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
1738
|
-
import
|
|
1624
|
+
import assert10 from "@dxos/node-std/assert";
|
|
1739
1625
|
import SimplePeerConstructor from "simple-peer";
|
|
1740
1626
|
import { Event as Event7 } from "@dxos/async";
|
|
1741
1627
|
import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
|
|
1742
|
-
import { log as
|
|
1628
|
+
import { log as log10 } from "@dxos/log";
|
|
1743
1629
|
|
|
1744
1630
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
1745
1631
|
var wrtc = null;
|
|
@@ -1756,8 +1642,8 @@ var WebRTCTransport = class {
|
|
|
1756
1642
|
this.closed = new Event7();
|
|
1757
1643
|
this.connected = new Event7();
|
|
1758
1644
|
this.errors = new ErrorStream4();
|
|
1759
|
-
|
|
1760
|
-
file: "
|
|
1645
|
+
log10("created connection", params, {
|
|
1646
|
+
file: "webrtc-transport.ts",
|
|
1761
1647
|
line: 34,
|
|
1762
1648
|
scope: this,
|
|
1763
1649
|
callSite: (f, a) => f(...a)
|
|
@@ -1768,8 +1654,8 @@ var WebRTCTransport = class {
|
|
|
1768
1654
|
config: this.params.webrtcConfig
|
|
1769
1655
|
});
|
|
1770
1656
|
this._peer.on("signal", async (data) => {
|
|
1771
|
-
|
|
1772
|
-
file: "
|
|
1657
|
+
log10("signal", data, {
|
|
1658
|
+
file: "webrtc-transport.ts",
|
|
1773
1659
|
line: 42,
|
|
1774
1660
|
scope: this,
|
|
1775
1661
|
callSite: (f, a) => f(...a)
|
|
@@ -1781,8 +1667,8 @@ var WebRTCTransport = class {
|
|
|
1781
1667
|
});
|
|
1782
1668
|
});
|
|
1783
1669
|
this._peer.on("connect", () => {
|
|
1784
|
-
|
|
1785
|
-
file: "
|
|
1670
|
+
log10("connected", {}, {
|
|
1671
|
+
file: "webrtc-transport.ts",
|
|
1786
1672
|
line: 47,
|
|
1787
1673
|
scope: this,
|
|
1788
1674
|
callSite: (f, a) => f(...a)
|
|
@@ -1791,8 +1677,8 @@ var WebRTCTransport = class {
|
|
|
1791
1677
|
this.connected.emit();
|
|
1792
1678
|
});
|
|
1793
1679
|
this._peer.on("close", async () => {
|
|
1794
|
-
|
|
1795
|
-
file: "
|
|
1680
|
+
log10("closed", {}, {
|
|
1681
|
+
file: "webrtc-transport.ts",
|
|
1796
1682
|
line: 53,
|
|
1797
1683
|
scope: this,
|
|
1798
1684
|
callSite: (f, a) => f(...a)
|
|
@@ -1806,8 +1692,8 @@ var WebRTCTransport = class {
|
|
|
1806
1692
|
});
|
|
1807
1693
|
}
|
|
1808
1694
|
async destroy() {
|
|
1809
|
-
|
|
1810
|
-
file: "
|
|
1695
|
+
log10("closing...", {}, {
|
|
1696
|
+
file: "webrtc-transport.ts",
|
|
1811
1697
|
line: 65,
|
|
1812
1698
|
scope: this,
|
|
1813
1699
|
callSite: (f, a) => f(...a)
|
|
@@ -1815,16 +1701,16 @@ var WebRTCTransport = class {
|
|
|
1815
1701
|
await this._disconnectStreams();
|
|
1816
1702
|
this._peer.destroy();
|
|
1817
1703
|
this.closed.emit();
|
|
1818
|
-
|
|
1819
|
-
file: "
|
|
1704
|
+
log10("closed", {}, {
|
|
1705
|
+
file: "webrtc-transport.ts",
|
|
1820
1706
|
line: 69,
|
|
1821
1707
|
scope: this,
|
|
1822
1708
|
callSite: (f, a) => f(...a)
|
|
1823
1709
|
});
|
|
1824
1710
|
}
|
|
1825
1711
|
signal(signal) {
|
|
1826
|
-
|
|
1827
|
-
|
|
1712
|
+
assert10(this._peer, "Connection not ready to accept signals.");
|
|
1713
|
+
assert10(signal.payload.data, "Signal message must contain signal data.");
|
|
1828
1714
|
this._peer.signal(signal.payload.data);
|
|
1829
1715
|
}
|
|
1830
1716
|
async _disconnectStreams() {
|
|
@@ -1840,17 +1726,17 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
1840
1726
|
});
|
|
1841
1727
|
|
|
1842
1728
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
|
|
1843
|
-
import
|
|
1729
|
+
import assert11 from "@dxos/node-std/assert";
|
|
1844
1730
|
import { Duplex } from "@dxos/node-std/stream";
|
|
1845
1731
|
import { Stream } from "@dxos/codec-protobuf";
|
|
1846
|
-
import { PublicKey as
|
|
1847
|
-
import { log as
|
|
1732
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1733
|
+
import { log as log11 } from "@dxos/log";
|
|
1848
1734
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
1849
1735
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
1850
1736
|
var WebRTCTransportService = class {
|
|
1851
1737
|
constructor(_webrtcConfig) {
|
|
1852
1738
|
this._webrtcConfig = _webrtcConfig;
|
|
1853
|
-
this.transports = new ComplexMap7(
|
|
1739
|
+
this.transports = new ComplexMap7(PublicKey8.hash);
|
|
1854
1740
|
}
|
|
1855
1741
|
open(request) {
|
|
1856
1742
|
const rpcStream = new Stream(({ ready, next, close }) => {
|
|
@@ -1915,11 +1801,11 @@ var WebRTCTransportService = class {
|
|
|
1915
1801
|
return rpcStream;
|
|
1916
1802
|
}
|
|
1917
1803
|
async sendSignal({ proxyId, signal }) {
|
|
1918
|
-
|
|
1804
|
+
assert11(this.transports.has(proxyId));
|
|
1919
1805
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
1920
1806
|
}
|
|
1921
1807
|
async sendData({ proxyId, payload }) {
|
|
1922
|
-
|
|
1808
|
+
assert11(this.transports.has(proxyId));
|
|
1923
1809
|
await this.transports.get(proxyId).stream.push(payload);
|
|
1924
1810
|
}
|
|
1925
1811
|
async close({ proxyId }) {
|
|
@@ -1927,8 +1813,8 @@ var WebRTCTransportService = class {
|
|
|
1927
1813
|
await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
|
|
1928
1814
|
await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
|
|
1929
1815
|
this.transports.delete(proxyId);
|
|
1930
|
-
|
|
1931
|
-
file: "
|
|
1816
|
+
log11("Closed.", {}, {
|
|
1817
|
+
file: "webrtc-transport-service.ts",
|
|
1932
1818
|
line: 108,
|
|
1933
1819
|
scope: this,
|
|
1934
1820
|
callSite: (f, a) => f(...a)
|
|
@@ -1937,11 +1823,11 @@ var WebRTCTransportService = class {
|
|
|
1937
1823
|
};
|
|
1938
1824
|
|
|
1939
1825
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
|
|
1940
|
-
import
|
|
1826
|
+
import assert12 from "@dxos/node-std/assert";
|
|
1941
1827
|
import { Event as Event8 } from "@dxos/async";
|
|
1942
1828
|
import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
1943
|
-
import { PublicKey as
|
|
1944
|
-
import { log as
|
|
1829
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
1830
|
+
import { log as log12 } from "@dxos/log";
|
|
1945
1831
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
1946
1832
|
var WebRTCTransportProxy = class {
|
|
1947
1833
|
constructor(_params) {
|
|
@@ -1950,15 +1836,15 @@ var WebRTCTransportProxy = class {
|
|
|
1950
1836
|
this._closed = false;
|
|
1951
1837
|
this.connected = new Event8();
|
|
1952
1838
|
this.errors = new ErrorStream5();
|
|
1953
|
-
this._proxyId =
|
|
1839
|
+
this._proxyId = PublicKey9.random();
|
|
1954
1840
|
this._serviceStream = this._params.bridgeService.open({
|
|
1955
1841
|
proxyId: this._proxyId,
|
|
1956
1842
|
initiator: this._params.initiator
|
|
1957
1843
|
});
|
|
1958
1844
|
this._serviceStream.waitUntilReady().then(() => {
|
|
1959
1845
|
this._serviceStream.subscribe(async (event) => {
|
|
1960
|
-
|
|
1961
|
-
file: "
|
|
1846
|
+
log12("WebRTCTransportProxy: event", event, {
|
|
1847
|
+
file: "webrtc-transport-proxy.ts",
|
|
1962
1848
|
line: 46,
|
|
1963
1849
|
scope: this,
|
|
1964
1850
|
callSite: (f, a) => f(...a)
|
|
@@ -1978,16 +1864,16 @@ var WebRTCTransportProxy = class {
|
|
|
1978
1864
|
payload: data
|
|
1979
1865
|
});
|
|
1980
1866
|
} catch (err) {
|
|
1981
|
-
|
|
1982
|
-
file: "
|
|
1867
|
+
log12.catch(err, {}, {
|
|
1868
|
+
file: "webrtc-transport-proxy.ts",
|
|
1983
1869
|
line: 63,
|
|
1984
1870
|
scope: this,
|
|
1985
1871
|
callSite: (f, a) => f(...a)
|
|
1986
1872
|
});
|
|
1987
1873
|
}
|
|
1988
1874
|
});
|
|
1989
|
-
}, (error) =>
|
|
1990
|
-
file: "
|
|
1875
|
+
}, (error) => log12.catch(error, {}, {
|
|
1876
|
+
file: "webrtc-transport-proxy.ts",
|
|
1991
1877
|
line: 67,
|
|
1992
1878
|
scope: this,
|
|
1993
1879
|
callSite: (f, a) => f(...a)
|
|
@@ -2030,8 +1916,8 @@ var WebRTCTransportProxy = class {
|
|
|
2030
1916
|
proxyId: this._proxyId
|
|
2031
1917
|
});
|
|
2032
1918
|
} catch (err) {
|
|
2033
|
-
|
|
2034
|
-
file: "
|
|
1919
|
+
log12.catch(err, {}, {
|
|
1920
|
+
file: "webrtc-transport-proxy.ts",
|
|
2035
1921
|
line: 117,
|
|
2036
1922
|
scope: this,
|
|
2037
1923
|
callSite: (f, a) => f(...a)
|
|
@@ -2058,7 +1944,7 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2058
1944
|
return this;
|
|
2059
1945
|
}
|
|
2060
1946
|
createTransport(options) {
|
|
2061
|
-
|
|
1947
|
+
assert12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
|
|
2062
1948
|
const transport = new WebRTCTransportProxy({
|
|
2063
1949
|
...options,
|
|
2064
1950
|
bridgeService: this._bridgeService
|
|
@@ -2070,20 +1956,7 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2070
1956
|
};
|
|
2071
1957
|
|
|
2072
1958
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
2073
|
-
import { discoveryKey as discoveryKey2 } from "@dxos/crypto";
|
|
2074
1959
|
import { Teleport } from "@dxos/teleport";
|
|
2075
|
-
var adaptProtocolProvider = (factory) => ({ initiator, localPeerId, remotePeerId, topic }) => {
|
|
2076
|
-
const protocol = factory({
|
|
2077
|
-
channel: discoveryKey2(topic),
|
|
2078
|
-
initiator
|
|
2079
|
-
});
|
|
2080
|
-
return {
|
|
2081
|
-
initialize: () => protocol.open(),
|
|
2082
|
-
destroy: () => protocol.close(),
|
|
2083
|
-
stream: protocol.stream,
|
|
2084
|
-
protocol
|
|
2085
|
-
};
|
|
2086
|
-
};
|
|
2087
1960
|
var createTeleportProtocolFactory = (onConnection) => {
|
|
2088
1961
|
return (params) => {
|
|
2089
1962
|
const teleport = new Teleport(params);
|
|
@@ -2117,11 +1990,7 @@ export {
|
|
|
2117
1990
|
WebRTCTransportProxy,
|
|
2118
1991
|
WebRTCTransportProxyFactory,
|
|
2119
1992
|
WebRTCTransportService,
|
|
2120
|
-
adaptProtocolProvider,
|
|
2121
|
-
createProtocolFactory,
|
|
2122
1993
|
createTeleportProtocolFactory,
|
|
2123
|
-
createWebRTCTransportFactory
|
|
2124
|
-
protocolFactory,
|
|
2125
|
-
transportProtocolProvider
|
|
1994
|
+
createWebRTCTransportFactory
|
|
2126
1995
|
};
|
|
2127
1996
|
//# sourceMappingURL=index.mjs.map
|