@dxos/network-manager 0.1.32-next.77d513e → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-ELRPGOK3.mjs → chunk-4W77MFHZ.mjs} +191 -95
- package/dist/lib/browser/chunk-4W77MFHZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +193 -97
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +201 -105
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/network-manager.d.ts +1 -0
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +5 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -0
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts +1 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport.d.ts +2 -0
- package/dist/types/src/transport/webrtc-transport.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/connection-log.ts +3 -3
- package/src/network-manager.ts +6 -0
- package/src/swarm/connection.ts +13 -1
- package/src/swarm/peer.ts +3 -0
- package/src/swarm/swarm.ts +9 -1
- package/src/transport/webrtc-transport.ts +13 -0
- package/dist/lib/browser/chunk-ELRPGOK3.mjs.map +0 -7
|
@@ -11,7 +11,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
11
|
import assert from "@dxos/node-std/assert";
|
|
12
12
|
import { Event, synchronized } from "@dxos/async";
|
|
13
13
|
import { ErrorStream } from "@dxos/debug";
|
|
14
|
+
import { PublicKey } from "@dxos/keys";
|
|
14
15
|
import { log } from "@dxos/log";
|
|
16
|
+
import { trace } from "@dxos/protocols";
|
|
15
17
|
var __decorate = function(decorators, target, key, desc) {
|
|
16
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
19
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -70,6 +72,10 @@ var Connection = class {
|
|
|
70
72
|
this._bufferedSignals = [];
|
|
71
73
|
this.stateChanged = new Event();
|
|
72
74
|
this.errors = new ErrorStream();
|
|
75
|
+
this._instanceId = PublicKey.random().toHex();
|
|
76
|
+
this._performance = {
|
|
77
|
+
signalsSent: 0
|
|
78
|
+
};
|
|
73
79
|
}
|
|
74
80
|
get state() {
|
|
75
81
|
return this._state;
|
|
@@ -87,13 +93,22 @@ var Connection = class {
|
|
|
87
93
|
openConnection() {
|
|
88
94
|
assert(this._state === ConnectionState.INITIAL, "Invalid state.");
|
|
89
95
|
this._changeState(ConnectionState.CONNECTING);
|
|
96
|
+
log.trace("dxos.mesh.connection", trace.begin({
|
|
97
|
+
id: this._instanceId,
|
|
98
|
+
parentId: this._traceParent
|
|
99
|
+
}), {
|
|
100
|
+
file: "connection.ts",
|
|
101
|
+
line: 97,
|
|
102
|
+
scope: this,
|
|
103
|
+
callSite: (f, a) => f(...a)
|
|
104
|
+
});
|
|
90
105
|
this._protocol.initialize().catch((err) => {
|
|
91
106
|
this.errors.raise(err);
|
|
92
107
|
});
|
|
93
108
|
this._protocol.stream.on("close", () => {
|
|
94
109
|
log("protocol stream closed", {}, {
|
|
95
110
|
file: "connection.ts",
|
|
96
|
-
line:
|
|
111
|
+
line: 106,
|
|
97
112
|
scope: this,
|
|
98
113
|
callSite: (f, a) => f(...a)
|
|
99
114
|
});
|
|
@@ -104,6 +119,7 @@ var Connection = class {
|
|
|
104
119
|
initiator: this.initiator,
|
|
105
120
|
stream: this._protocol.stream,
|
|
106
121
|
sendSignal: async (signal) => {
|
|
122
|
+
this._performance.signalsSent++;
|
|
107
123
|
await this._signalMessaging.signal({
|
|
108
124
|
author: this.ownId,
|
|
109
125
|
recipient: this.remoteId,
|
|
@@ -142,7 +158,7 @@ var Connection = class {
|
|
|
142
158
|
peerId: this.ownId
|
|
143
159
|
}, {
|
|
144
160
|
file: "connection.ts",
|
|
145
|
-
line:
|
|
161
|
+
line: 156,
|
|
146
162
|
scope: this,
|
|
147
163
|
callSite: (f, a) => f(...a)
|
|
148
164
|
});
|
|
@@ -151,7 +167,7 @@ var Connection = class {
|
|
|
151
167
|
} catch (err) {
|
|
152
168
|
log.catch(err, {}, {
|
|
153
169
|
file: "connection.ts",
|
|
154
|
-
line:
|
|
170
|
+
line: 162,
|
|
155
171
|
scope: this,
|
|
156
172
|
callSite: (f, a) => f(...a)
|
|
157
173
|
});
|
|
@@ -161,7 +177,7 @@ var Connection = class {
|
|
|
161
177
|
} catch (err1) {
|
|
162
178
|
log.catch(err1, {}, {
|
|
163
179
|
file: "connection.ts",
|
|
164
|
-
line:
|
|
180
|
+
line: 169,
|
|
165
181
|
scope: this,
|
|
166
182
|
callSite: (f, a) => f(...a)
|
|
167
183
|
});
|
|
@@ -170,11 +186,23 @@ var Connection = class {
|
|
|
170
186
|
peerId: this.ownId
|
|
171
187
|
}, {
|
|
172
188
|
file: "connection.ts",
|
|
173
|
-
line:
|
|
189
|
+
line: 172,
|
|
174
190
|
scope: this,
|
|
175
191
|
callSite: (f, a) => f(...a)
|
|
176
192
|
});
|
|
177
193
|
this._changeState(ConnectionState.CLOSED);
|
|
194
|
+
log.trace("dxos.mesh.connection", trace.end({
|
|
195
|
+
id: this._instanceId,
|
|
196
|
+
status: "ok",
|
|
197
|
+
data: {
|
|
198
|
+
performance: this._performance
|
|
199
|
+
}
|
|
200
|
+
}), {
|
|
201
|
+
file: "connection.ts",
|
|
202
|
+
line: 174,
|
|
203
|
+
scope: this,
|
|
204
|
+
callSite: (f, a) => f(...a)
|
|
205
|
+
});
|
|
178
206
|
}
|
|
179
207
|
async signal(msg) {
|
|
180
208
|
var _a, _b;
|
|
@@ -182,7 +210,7 @@ var Connection = class {
|
|
|
182
210
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
183
211
|
log("dropping signal for incorrect session id", {}, {
|
|
184
212
|
file: "connection.ts",
|
|
185
|
-
line:
|
|
213
|
+
line: 183,
|
|
186
214
|
scope: this,
|
|
187
215
|
callSite: (f, a) => f(...a)
|
|
188
216
|
});
|
|
@@ -198,7 +226,7 @@ var Connection = class {
|
|
|
198
226
|
msg: msg.data
|
|
199
227
|
}, {
|
|
200
228
|
file: "connection.ts",
|
|
201
|
-
line:
|
|
229
|
+
line: 191,
|
|
202
230
|
scope: this,
|
|
203
231
|
callSite: (f, a) => f(...a)
|
|
204
232
|
});
|
|
@@ -212,7 +240,7 @@ var Connection = class {
|
|
|
212
240
|
msg: msg.data
|
|
213
241
|
}, {
|
|
214
242
|
file: "connection.ts",
|
|
215
|
-
line:
|
|
243
|
+
line: 197,
|
|
216
244
|
scope: this,
|
|
217
245
|
callSite: (f, a) => f(...a)
|
|
218
246
|
});
|
|
@@ -225,7 +253,7 @@ var Connection = class {
|
|
|
225
253
|
peerId: this.ownId
|
|
226
254
|
}, {
|
|
227
255
|
file: "connection.ts",
|
|
228
|
-
line:
|
|
256
|
+
line: 202,
|
|
229
257
|
scope: this,
|
|
230
258
|
callSite: (f, a) => f(...a)
|
|
231
259
|
});
|
|
@@ -240,7 +268,7 @@ __decorate([
|
|
|
240
268
|
|
|
241
269
|
// packages/core/mesh/network-manager/src/signal/message-router.ts
|
|
242
270
|
import assert2 from "@dxos/node-std/assert";
|
|
243
|
-
import { PublicKey } from "@dxos/keys";
|
|
271
|
+
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
244
272
|
import { log as log2 } from "@dxos/log";
|
|
245
273
|
import { schema } from "@dxos/protocols";
|
|
246
274
|
import { ComplexMap } from "@dxos/util";
|
|
@@ -299,7 +327,7 @@ var MessageRouter = class {
|
|
|
299
327
|
async offer(message) {
|
|
300
328
|
const networkMessage = {
|
|
301
329
|
...message,
|
|
302
|
-
messageId:
|
|
330
|
+
messageId: PublicKey2.random()
|
|
303
331
|
};
|
|
304
332
|
return new Promise((resolve, reject) => {
|
|
305
333
|
this._offerRecords.set(networkMessage.messageId, {
|
|
@@ -318,7 +346,7 @@ var MessageRouter = class {
|
|
|
318
346
|
const networkMessage = {
|
|
319
347
|
...message,
|
|
320
348
|
// Setting unique message_id if it not specified yet.
|
|
321
|
-
messageId: (_a = message.messageId) != null ? _a :
|
|
349
|
+
messageId: (_a = message.messageId) != null ? _a : PublicKey2.random()
|
|
322
350
|
};
|
|
323
351
|
log2("sending", {
|
|
324
352
|
from: author,
|
|
@@ -408,14 +436,15 @@ import assert4 from "@dxos/node-std/assert";
|
|
|
408
436
|
import { Event as Event2, scheduleTask, sleep, synchronized as synchronized3 } from "@dxos/async";
|
|
409
437
|
import { Context } from "@dxos/context";
|
|
410
438
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
411
|
-
import { PublicKey as
|
|
439
|
+
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
412
440
|
import { log as log4, logInfo } from "@dxos/log";
|
|
441
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
413
442
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
414
443
|
|
|
415
444
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
416
445
|
import assert3 from "@dxos/node-std/assert";
|
|
417
446
|
import { synchronized as synchronized2 } from "@dxos/async";
|
|
418
|
-
import { PublicKey as
|
|
447
|
+
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
419
448
|
import { log as log3 } from "@dxos/log";
|
|
420
449
|
var __decorate2 = function(decorators, target, key, desc) {
|
|
421
450
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -452,7 +481,7 @@ var Peer = class {
|
|
|
452
481
|
peerId: this.localPeerId
|
|
453
482
|
}, {
|
|
454
483
|
file: "peer.ts",
|
|
455
|
-
line:
|
|
484
|
+
line: 86,
|
|
456
485
|
scope: this,
|
|
457
486
|
callSite: (f, a) => f(...a)
|
|
458
487
|
});
|
|
@@ -479,7 +508,7 @@ var Peer = class {
|
|
|
479
508
|
err
|
|
480
509
|
}, {
|
|
481
510
|
file: "peer.ts",
|
|
482
|
-
line:
|
|
511
|
+
line: 110,
|
|
483
512
|
scope: this,
|
|
484
513
|
callSite: (f, a) => f(...a)
|
|
485
514
|
});
|
|
@@ -500,7 +529,7 @@ var Peer = class {
|
|
|
500
529
|
async initiateConnection() {
|
|
501
530
|
assert3(!this.initiating, "Initiation in progress.");
|
|
502
531
|
assert3(!this.connection, "Already connected.");
|
|
503
|
-
const sessionId =
|
|
532
|
+
const sessionId = PublicKey3.random();
|
|
504
533
|
log3("initiating...", {
|
|
505
534
|
id: this.id,
|
|
506
535
|
topic: this.topic,
|
|
@@ -508,7 +537,7 @@ var Peer = class {
|
|
|
508
537
|
sessionId
|
|
509
538
|
}, {
|
|
510
539
|
file: "peer.ts",
|
|
511
|
-
line:
|
|
540
|
+
line: 128,
|
|
512
541
|
scope: this,
|
|
513
542
|
callSite: (f, a) => f(...a)
|
|
514
543
|
});
|
|
@@ -531,14 +560,14 @@ var Peer = class {
|
|
|
531
560
|
remoteId: this.id
|
|
532
561
|
}, {
|
|
533
562
|
file: "peer.ts",
|
|
534
|
-
line:
|
|
563
|
+
line: 140,
|
|
535
564
|
scope: this,
|
|
536
565
|
callSite: (f, a) => f(...a)
|
|
537
566
|
});
|
|
538
567
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
539
568
|
log3("ignoring response", {}, {
|
|
540
569
|
file: "peer.ts",
|
|
541
|
-
line:
|
|
570
|
+
line: 142,
|
|
542
571
|
scope: this,
|
|
543
572
|
callSite: (f, a) => f(...a)
|
|
544
573
|
});
|
|
@@ -558,7 +587,7 @@ var Peer = class {
|
|
|
558
587
|
err
|
|
559
588
|
}, {
|
|
560
589
|
file: "peer.ts",
|
|
561
|
-
line:
|
|
590
|
+
line: 153,
|
|
562
591
|
scope: this,
|
|
563
592
|
callSite: (f, a) => f(...a)
|
|
564
593
|
});
|
|
@@ -581,7 +610,7 @@ var Peer = class {
|
|
|
581
610
|
sessionId
|
|
582
611
|
}, {
|
|
583
612
|
file: "peer.ts",
|
|
584
|
-
line:
|
|
613
|
+
line: 167,
|
|
585
614
|
scope: this,
|
|
586
615
|
callSite: (f, a) => f(...a)
|
|
587
616
|
});
|
|
@@ -602,6 +631,7 @@ var Peer = class {
|
|
|
602
631
|
}),
|
|
603
632
|
this._transportFactory
|
|
604
633
|
);
|
|
634
|
+
connection._traceParent = this._traceParent;
|
|
605
635
|
this._callbacks.onInitiated(connection);
|
|
606
636
|
connection.stateChanged.on((state) => {
|
|
607
637
|
switch (state) {
|
|
@@ -617,7 +647,7 @@ var Peer = class {
|
|
|
617
647
|
initiator
|
|
618
648
|
}, {
|
|
619
649
|
file: "peer.ts",
|
|
620
|
-
line:
|
|
650
|
+
line: 197,
|
|
621
651
|
scope: this,
|
|
622
652
|
callSite: (f, a) => f(...a)
|
|
623
653
|
});
|
|
@@ -637,7 +667,7 @@ var Peer = class {
|
|
|
637
667
|
err
|
|
638
668
|
}, {
|
|
639
669
|
file: "peer.ts",
|
|
640
|
-
line:
|
|
670
|
+
line: 207,
|
|
641
671
|
scope: this,
|
|
642
672
|
callSite: (f, a) => f(...a)
|
|
643
673
|
});
|
|
@@ -656,7 +686,7 @@ var Peer = class {
|
|
|
656
686
|
sessionId: connection.sessionId
|
|
657
687
|
}, {
|
|
658
688
|
file: "peer.ts",
|
|
659
|
-
line:
|
|
689
|
+
line: 223,
|
|
660
690
|
scope: this,
|
|
661
691
|
callSite: (f, a) => f(...a)
|
|
662
692
|
});
|
|
@@ -666,7 +696,7 @@ var Peer = class {
|
|
|
666
696
|
sessionId: connection.sessionId
|
|
667
697
|
}, {
|
|
668
698
|
file: "peer.ts",
|
|
669
|
-
line:
|
|
699
|
+
line: 229,
|
|
670
700
|
scope: this,
|
|
671
701
|
callSite: (f, a) => f(...a)
|
|
672
702
|
});
|
|
@@ -677,7 +707,7 @@ var Peer = class {
|
|
|
677
707
|
message
|
|
678
708
|
}, {
|
|
679
709
|
file: "peer.ts",
|
|
680
|
-
line:
|
|
710
|
+
line: 234,
|
|
681
711
|
scope: this,
|
|
682
712
|
callSite: (f, a) => f(...a)
|
|
683
713
|
});
|
|
@@ -692,7 +722,7 @@ var Peer = class {
|
|
|
692
722
|
topic: this.topic
|
|
693
723
|
}, {
|
|
694
724
|
file: "peer.ts",
|
|
695
|
-
line:
|
|
725
|
+
line: 242,
|
|
696
726
|
scope: this,
|
|
697
727
|
callSite: (f, a) => f(...a)
|
|
698
728
|
});
|
|
@@ -727,18 +757,18 @@ var Swarm = class {
|
|
|
727
757
|
this._messenger = _messenger;
|
|
728
758
|
this._transportFactory = _transportFactory;
|
|
729
759
|
this._label = _label;
|
|
730
|
-
this._peers = new ComplexMap2(
|
|
760
|
+
this._peers = new ComplexMap2(PublicKey4.hash);
|
|
731
761
|
this._ctx = new Context();
|
|
732
762
|
this.connectionAdded = new Event2();
|
|
733
763
|
this.disconnected = new Event2();
|
|
734
764
|
this.connected = new Event2();
|
|
735
765
|
this.errors = new ErrorStream2();
|
|
736
|
-
this.
|
|
766
|
+
this._instanceId = PublicKey4.random().toHex();
|
|
737
767
|
log4("creating swarm", {
|
|
738
768
|
peerId: _ownPeerId
|
|
739
769
|
}, {
|
|
740
770
|
file: "swarm.ts",
|
|
741
|
-
line:
|
|
771
|
+
line: 84,
|
|
742
772
|
scope: this,
|
|
743
773
|
callSite: (f, a) => f(...a)
|
|
744
774
|
});
|
|
@@ -755,10 +785,22 @@ var Swarm = class {
|
|
|
755
785
|
onMessage: async (message) => await this._swarmMessenger.receiveMessage(message)
|
|
756
786
|
}).catch((error) => log4.catch(error, {}, {
|
|
757
787
|
file: "swarm.ts",
|
|
758
|
-
line:
|
|
788
|
+
line: 100,
|
|
759
789
|
scope: this,
|
|
760
790
|
callSite: (f, a) => f(...a)
|
|
761
791
|
}));
|
|
792
|
+
log4.trace("dxos.mesh.swarm", trace2.begin({
|
|
793
|
+
id: this._instanceId,
|
|
794
|
+
data: {
|
|
795
|
+
topic: this._topic.toHex(),
|
|
796
|
+
peerId: this._ownPeerId.toHex()
|
|
797
|
+
}
|
|
798
|
+
}), {
|
|
799
|
+
file: "swarm.ts",
|
|
800
|
+
line: 102,
|
|
801
|
+
scope: this,
|
|
802
|
+
callSite: (f, a) => f(...a)
|
|
803
|
+
});
|
|
762
804
|
}
|
|
763
805
|
get connections() {
|
|
764
806
|
return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNotNullOrUndefined);
|
|
@@ -779,7 +821,7 @@ var Swarm = class {
|
|
|
779
821
|
async destroy() {
|
|
780
822
|
log4("destroying...", {}, {
|
|
781
823
|
file: "swarm.ts",
|
|
782
|
-
line:
|
|
824
|
+
line: 133,
|
|
783
825
|
scope: this,
|
|
784
826
|
callSite: (f, a) => f(...a)
|
|
785
827
|
});
|
|
@@ -788,7 +830,15 @@ var Swarm = class {
|
|
|
788
830
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
789
831
|
log4("destroyed", {}, {
|
|
790
832
|
file: "swarm.ts",
|
|
791
|
-
line:
|
|
833
|
+
line: 137,
|
|
834
|
+
scope: this,
|
|
835
|
+
callSite: (f, a) => f(...a)
|
|
836
|
+
});
|
|
837
|
+
log4.trace("dxos.mesh.swarm", trace2.end({
|
|
838
|
+
id: this._instanceId
|
|
839
|
+
}), {
|
|
840
|
+
file: "swarm.ts",
|
|
841
|
+
line: 138,
|
|
792
842
|
scope: this,
|
|
793
843
|
callSite: (f, a) => f(...a)
|
|
794
844
|
});
|
|
@@ -803,7 +853,7 @@ var Swarm = class {
|
|
|
803
853
|
topology: getClassName(topology)
|
|
804
854
|
}, {
|
|
805
855
|
file: "swarm.ts",
|
|
806
|
-
line:
|
|
856
|
+
line: 146,
|
|
807
857
|
scope: this,
|
|
808
858
|
callSite: (f, a) => f(...a)
|
|
809
859
|
});
|
|
@@ -818,26 +868,26 @@ var Swarm = class {
|
|
|
818
868
|
swarmEvent
|
|
819
869
|
}, {
|
|
820
870
|
file: "swarm.ts",
|
|
821
|
-
line:
|
|
871
|
+
line: 159,
|
|
822
872
|
scope: this,
|
|
823
873
|
callSite: (f, a) => f(...a)
|
|
824
874
|
});
|
|
825
875
|
if (this._ctx.disposed) {
|
|
826
876
|
log4("swarm event ignored for disposed swarm", {}, {
|
|
827
877
|
file: "swarm.ts",
|
|
828
|
-
line:
|
|
878
|
+
line: 162,
|
|
829
879
|
scope: this,
|
|
830
880
|
callSite: (f, a) => f(...a)
|
|
831
881
|
});
|
|
832
882
|
return;
|
|
833
883
|
}
|
|
834
884
|
if (swarmEvent.peerAvailable) {
|
|
835
|
-
const peerId =
|
|
885
|
+
const peerId = PublicKey4.from(swarmEvent.peerAvailable.peer);
|
|
836
886
|
log4("new peer", {
|
|
837
887
|
peerId
|
|
838
888
|
}, {
|
|
839
889
|
file: "swarm.ts",
|
|
840
|
-
line:
|
|
890
|
+
line: 168,
|
|
841
891
|
scope: this,
|
|
842
892
|
callSite: (f, a) => f(...a)
|
|
843
893
|
});
|
|
@@ -846,13 +896,13 @@ var Swarm = class {
|
|
|
846
896
|
peer.advertizing = true;
|
|
847
897
|
}
|
|
848
898
|
} else if (swarmEvent.peerLeft) {
|
|
849
|
-
const peer1 = this._peers.get(
|
|
899
|
+
const peer1 = this._peers.get(PublicKey4.from(swarmEvent.peerLeft.peer));
|
|
850
900
|
if (peer1) {
|
|
851
901
|
peer1.advertizing = false;
|
|
852
902
|
if (((_a = peer1.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
|
|
853
903
|
void this._destroyPeer(peer1.id).catch((err) => log4.catch(err, {}, {
|
|
854
904
|
file: "swarm.ts",
|
|
855
|
-
line:
|
|
905
|
+
line: 179,
|
|
856
906
|
scope: this,
|
|
857
907
|
callSite: (f, a) => f(...a)
|
|
858
908
|
}));
|
|
@@ -867,14 +917,14 @@ var Swarm = class {
|
|
|
867
917
|
message
|
|
868
918
|
}, {
|
|
869
919
|
file: "swarm.ts",
|
|
870
|
-
line:
|
|
920
|
+
line: 189,
|
|
871
921
|
scope: this,
|
|
872
922
|
callSite: (f, a) => f(...a)
|
|
873
923
|
});
|
|
874
924
|
if (this._ctx.disposed) {
|
|
875
925
|
log4("ignored for disposed swarm", {}, {
|
|
876
926
|
file: "swarm.ts",
|
|
877
|
-
line:
|
|
927
|
+
line: 191,
|
|
878
928
|
scope: this,
|
|
879
929
|
callSite: (f, a) => f(...a)
|
|
880
930
|
});
|
|
@@ -888,7 +938,7 @@ var Swarm = class {
|
|
|
888
938
|
message
|
|
889
939
|
}, {
|
|
890
940
|
file: "swarm.ts",
|
|
891
|
-
line:
|
|
941
|
+
line: 198,
|
|
892
942
|
scope: this,
|
|
893
943
|
callSite: (f, a) => f(...a)
|
|
894
944
|
});
|
|
@@ -901,7 +951,7 @@ var Swarm = class {
|
|
|
901
951
|
message
|
|
902
952
|
}, {
|
|
903
953
|
file: "swarm.ts",
|
|
904
|
-
line:
|
|
954
|
+
line: 202,
|
|
905
955
|
scope: this,
|
|
906
956
|
callSite: (f, a) => f(...a)
|
|
907
957
|
});
|
|
@@ -920,14 +970,14 @@ var Swarm = class {
|
|
|
920
970
|
message
|
|
921
971
|
}, {
|
|
922
972
|
file: "swarm.ts",
|
|
923
|
-
line:
|
|
973
|
+
line: 214,
|
|
924
974
|
scope: this,
|
|
925
975
|
callSite: (f, a) => f(...a)
|
|
926
976
|
});
|
|
927
977
|
if (this._ctx.disposed) {
|
|
928
978
|
log4.info("ignored for offline swarm", {}, {
|
|
929
979
|
file: "swarm.ts",
|
|
930
|
-
line:
|
|
980
|
+
line: 216,
|
|
931
981
|
scope: this,
|
|
932
982
|
callSite: (f, a) => f(...a)
|
|
933
983
|
});
|
|
@@ -979,6 +1029,7 @@ var Swarm = class {
|
|
|
979
1029
|
return this._topology.onOffer(remoteId);
|
|
980
1030
|
}
|
|
981
1031
|
});
|
|
1032
|
+
peer._traceParent = this._instanceId;
|
|
982
1033
|
this._peers.set(peerId, peer);
|
|
983
1034
|
}
|
|
984
1035
|
return peer;
|
|
@@ -1005,7 +1056,7 @@ var Swarm = class {
|
|
|
1005
1056
|
} catch (err) {
|
|
1006
1057
|
log4.warn("initiation error", err, {
|
|
1007
1058
|
file: "swarm.ts",
|
|
1008
|
-
line:
|
|
1059
|
+
line: 317,
|
|
1009
1060
|
scope: this,
|
|
1010
1061
|
callSite: (f, a) => f(...a)
|
|
1011
1062
|
});
|
|
@@ -1033,7 +1084,7 @@ var Swarm = class {
|
|
|
1033
1084
|
remoteId
|
|
1034
1085
|
}, {
|
|
1035
1086
|
file: "swarm.ts",
|
|
1036
|
-
line:
|
|
1087
|
+
line: 344,
|
|
1037
1088
|
scope: this,
|
|
1038
1089
|
callSite: (f, a) => f(...a)
|
|
1039
1090
|
});
|
|
@@ -1050,7 +1101,7 @@ var Swarm = class {
|
|
|
1050
1101
|
remoteId
|
|
1051
1102
|
}, {
|
|
1052
1103
|
file: "swarm.ts",
|
|
1053
|
-
line:
|
|
1104
|
+
line: 358,
|
|
1054
1105
|
scope: this,
|
|
1055
1106
|
callSite: (f, a) => f(...a)
|
|
1056
1107
|
});
|
|
@@ -1060,7 +1111,7 @@ var Swarm = class {
|
|
|
1060
1111
|
remoteId
|
|
1061
1112
|
}, {
|
|
1062
1113
|
file: "swarm.ts",
|
|
1063
|
-
line:
|
|
1114
|
+
line: 361,
|
|
1064
1115
|
scope: this,
|
|
1065
1116
|
callSite: (f, a) => f(...a)
|
|
1066
1117
|
});
|
|
@@ -1075,7 +1126,7 @@ var Swarm = class {
|
|
|
1075
1126
|
};
|
|
1076
1127
|
__decorate3([
|
|
1077
1128
|
logInfo
|
|
1078
|
-
], Swarm.prototype, "
|
|
1129
|
+
], Swarm.prototype, "_instanceId", void 0);
|
|
1079
1130
|
__decorate3([
|
|
1080
1131
|
logInfo
|
|
1081
1132
|
], Swarm.prototype, "ownPeerId", null);
|
|
@@ -1100,7 +1151,7 @@ __decorate3([
|
|
|
1100
1151
|
|
|
1101
1152
|
// packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts
|
|
1102
1153
|
import { Event as Event3, EventSubscriptions } from "@dxos/async";
|
|
1103
|
-
import { PublicKey as
|
|
1154
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1104
1155
|
import { log as log5 } from "@dxos/log";
|
|
1105
1156
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1106
1157
|
var SwarmMapper = class {
|
|
@@ -1111,8 +1162,8 @@ var SwarmMapper = class {
|
|
|
1111
1162
|
constructor(_swarm) {
|
|
1112
1163
|
this._swarm = _swarm;
|
|
1113
1164
|
this._subscriptions = new EventSubscriptions();
|
|
1114
|
-
this._connectionSubscriptions = new ComplexMap3(
|
|
1115
|
-
this._peers = new ComplexMap3(
|
|
1165
|
+
this._connectionSubscriptions = new ComplexMap3(PublicKey5.hash);
|
|
1166
|
+
this._peers = new ComplexMap3(PublicKey5.hash);
|
|
1116
1167
|
this.mapUpdated = new Event3();
|
|
1117
1168
|
this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
|
|
1118
1169
|
this._update();
|
|
@@ -1171,7 +1222,7 @@ var SwarmMapper = class {
|
|
|
1171
1222
|
// packages/core/mesh/network-manager/src/connection-log.ts
|
|
1172
1223
|
import { Event as Event4 } from "@dxos/async";
|
|
1173
1224
|
import { raise } from "@dxos/debug";
|
|
1174
|
-
import { PublicKey as
|
|
1225
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1175
1226
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1176
1227
|
var EventType;
|
|
1177
1228
|
(function(EventType2) {
|
|
@@ -1186,7 +1237,7 @@ var ConnectionLog = class {
|
|
|
1186
1237
|
/**
|
|
1187
1238
|
* SwarmId => info
|
|
1188
1239
|
*/
|
|
1189
|
-
this._swarms = new ComplexMap4(
|
|
1240
|
+
this._swarms = new ComplexMap4(PublicKey6.hash);
|
|
1190
1241
|
this.update = new Event4();
|
|
1191
1242
|
}
|
|
1192
1243
|
getSwarmInfo(swarmId) {
|
|
@@ -1198,13 +1249,13 @@ var ConnectionLog = class {
|
|
|
1198
1249
|
}
|
|
1199
1250
|
joinedSwarm(swarm) {
|
|
1200
1251
|
const info = {
|
|
1201
|
-
id: swarm.
|
|
1252
|
+
id: PublicKey6.from(swarm._instanceId),
|
|
1202
1253
|
topic: swarm.topic,
|
|
1203
1254
|
isActive: true,
|
|
1204
1255
|
label: swarm.label,
|
|
1205
1256
|
connections: []
|
|
1206
1257
|
};
|
|
1207
|
-
this._swarms.set(swarm.
|
|
1258
|
+
this._swarms.set(PublicKey6.from(swarm._instanceId), info);
|
|
1208
1259
|
this.update.emit();
|
|
1209
1260
|
swarm.connectionAdded.on((connection) => {
|
|
1210
1261
|
const connectionInfo = {
|
|
@@ -1228,7 +1279,7 @@ var ConnectionLog = class {
|
|
|
1228
1279
|
});
|
|
1229
1280
|
}
|
|
1230
1281
|
leftSwarm(swarm) {
|
|
1231
|
-
this.getSwarmInfo(swarm.
|
|
1282
|
+
this.getSwarmInfo(PublicKey6.from(swarm._instanceId)).isActive = false;
|
|
1232
1283
|
this.update.emit();
|
|
1233
1284
|
}
|
|
1234
1285
|
};
|
|
@@ -1236,18 +1287,20 @@ var ConnectionLog = class {
|
|
|
1236
1287
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
1237
1288
|
import assert5 from "@dxos/node-std/assert";
|
|
1238
1289
|
import { Event as Event5 } from "@dxos/async";
|
|
1239
|
-
import { PublicKey as
|
|
1290
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1240
1291
|
import { log as log6 } from "@dxos/log";
|
|
1241
1292
|
import { Messenger } from "@dxos/messaging";
|
|
1293
|
+
import { trace as trace3 } from "@dxos/protocols";
|
|
1242
1294
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1243
1295
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1244
1296
|
var NetworkManager = class {
|
|
1245
1297
|
constructor({ transportFactory, signalManager, log: log13 }) {
|
|
1246
|
-
this._swarms = new ComplexMap5(
|
|
1247
|
-
this._mappers = new ComplexMap5(
|
|
1298
|
+
this._swarms = new ComplexMap5(PublicKey7.hash);
|
|
1299
|
+
this._mappers = new ComplexMap5(PublicKey7.hash);
|
|
1248
1300
|
this._connectionState = ConnectionState2.ONLINE;
|
|
1249
1301
|
this.connectionStateChanged = new Event5();
|
|
1250
1302
|
this.topicsUpdated = new Event5();
|
|
1303
|
+
this._instanceId = PublicKey7.random().toHex();
|
|
1251
1304
|
this._transportFactory = transportFactory;
|
|
1252
1305
|
this._signalManager = signalManager;
|
|
1253
1306
|
this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => {
|
|
@@ -1257,6 +1310,7 @@ var NetworkManager = class {
|
|
|
1257
1310
|
this._messenger = new Messenger({
|
|
1258
1311
|
signalManager: this._signalManager
|
|
1259
1312
|
});
|
|
1313
|
+
this._messenger._traceParent = this._instanceId;
|
|
1260
1314
|
this._signalConnection = {
|
|
1261
1315
|
join: (opts) => this._signalManager.join(opts),
|
|
1262
1316
|
leave: (opts) => this._signalManager.leave(opts)
|
|
@@ -1287,6 +1341,14 @@ var NetworkManager = class {
|
|
|
1287
1341
|
return this._swarms.get(topic);
|
|
1288
1342
|
}
|
|
1289
1343
|
async open() {
|
|
1344
|
+
log6.trace("dxos.mesh.network-manager", trace3.begin({
|
|
1345
|
+
id: this._instanceId
|
|
1346
|
+
}), {
|
|
1347
|
+
file: "network-manager.ts",
|
|
1348
|
+
line: 133,
|
|
1349
|
+
scope: this,
|
|
1350
|
+
callSite: (f, a) => f(...a)
|
|
1351
|
+
});
|
|
1290
1352
|
await this._messenger.open();
|
|
1291
1353
|
await this._signalManager.open();
|
|
1292
1354
|
}
|
|
@@ -1295,7 +1357,7 @@ var NetworkManager = class {
|
|
|
1295
1357
|
await this.leaveSwarm(topic).catch((err) => {
|
|
1296
1358
|
log6(err, {}, {
|
|
1297
1359
|
file: "network-manager.ts",
|
|
1298
|
-
line:
|
|
1360
|
+
line: 141,
|
|
1299
1361
|
scope: this,
|
|
1300
1362
|
callSite: (f, a) => f(...a)
|
|
1301
1363
|
});
|
|
@@ -1303,26 +1365,34 @@ var NetworkManager = class {
|
|
|
1303
1365
|
}
|
|
1304
1366
|
await this._messenger.close();
|
|
1305
1367
|
await this._signalManager.close();
|
|
1368
|
+
log6.trace("dxos.mesh.network-manager", trace3.end({
|
|
1369
|
+
id: this._instanceId
|
|
1370
|
+
}), {
|
|
1371
|
+
file: "network-manager.ts",
|
|
1372
|
+
line: 147,
|
|
1373
|
+
scope: this,
|
|
1374
|
+
callSite: (f, a) => f(...a)
|
|
1375
|
+
});
|
|
1306
1376
|
}
|
|
1307
1377
|
/**
|
|
1308
1378
|
* Join the swarm.
|
|
1309
1379
|
*/
|
|
1310
1380
|
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1311
1381
|
var _a;
|
|
1312
|
-
assert5(
|
|
1313
|
-
assert5(
|
|
1382
|
+
assert5(PublicKey7.isPublicKey(topic));
|
|
1383
|
+
assert5(PublicKey7.isPublicKey(peerId));
|
|
1314
1384
|
assert5(topology);
|
|
1315
1385
|
assert5(typeof protocol === "function");
|
|
1316
1386
|
if (this._swarms.has(topic)) {
|
|
1317
|
-
throw new Error(`Already connected to swarm: ${
|
|
1387
|
+
throw new Error(`Already connected to swarm: ${PublicKey7.from(topic)}`);
|
|
1318
1388
|
}
|
|
1319
1389
|
log6("joining", {
|
|
1320
|
-
topic:
|
|
1390
|
+
topic: PublicKey7.from(topic),
|
|
1321
1391
|
peerId,
|
|
1322
1392
|
topology: topology.toString()
|
|
1323
1393
|
}, {
|
|
1324
1394
|
file: "network-manager.ts",
|
|
1325
|
-
line:
|
|
1395
|
+
line: 168,
|
|
1326
1396
|
scope: this,
|
|
1327
1397
|
callSite: (f, a) => f(...a)
|
|
1328
1398
|
});
|
|
@@ -1332,7 +1402,7 @@ var NetworkManager = class {
|
|
|
1332
1402
|
error
|
|
1333
1403
|
}, {
|
|
1334
1404
|
file: "network-manager.ts",
|
|
1335
|
-
line:
|
|
1405
|
+
line: 171,
|
|
1336
1406
|
scope: this,
|
|
1337
1407
|
callSite: (f, a) => f(...a)
|
|
1338
1408
|
});
|
|
@@ -1343,7 +1413,7 @@ var NetworkManager = class {
|
|
|
1343
1413
|
peerId
|
|
1344
1414
|
}).catch((error) => log6.catch(error, {}, {
|
|
1345
1415
|
file: "network-manager.ts",
|
|
1346
|
-
line:
|
|
1416
|
+
line: 175,
|
|
1347
1417
|
scope: this,
|
|
1348
1418
|
callSite: (f, a) => f(...a)
|
|
1349
1419
|
}));
|
|
@@ -1351,11 +1421,11 @@ var NetworkManager = class {
|
|
|
1351
1421
|
this.topicsUpdated.emit();
|
|
1352
1422
|
(_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
|
|
1353
1423
|
log6("joined", {
|
|
1354
|
-
topic:
|
|
1424
|
+
topic: PublicKey7.from(topic),
|
|
1355
1425
|
count: this._swarms.size
|
|
1356
1426
|
}, {
|
|
1357
1427
|
file: "network-manager.ts",
|
|
1358
|
-
line:
|
|
1428
|
+
line: 180,
|
|
1359
1429
|
scope: this,
|
|
1360
1430
|
callSite: (f, a) => f(...a)
|
|
1361
1431
|
});
|
|
@@ -1370,20 +1440,20 @@ var NetworkManager = class {
|
|
|
1370
1440
|
var _a;
|
|
1371
1441
|
if (!this._swarms.has(topic)) {
|
|
1372
1442
|
log6.warn("swarm not open", {
|
|
1373
|
-
topic:
|
|
1443
|
+
topic: PublicKey7.from(topic).truncate()
|
|
1374
1444
|
}, {
|
|
1375
1445
|
file: "network-manager.ts",
|
|
1376
|
-
line:
|
|
1446
|
+
line: 192,
|
|
1377
1447
|
scope: this,
|
|
1378
1448
|
callSite: (f, a) => f(...a)
|
|
1379
1449
|
});
|
|
1380
1450
|
return;
|
|
1381
1451
|
}
|
|
1382
1452
|
log6("leaving", {
|
|
1383
|
-
topic:
|
|
1453
|
+
topic: PublicKey7.from(topic)
|
|
1384
1454
|
}, {
|
|
1385
1455
|
file: "network-manager.ts",
|
|
1386
|
-
line:
|
|
1456
|
+
line: 196,
|
|
1387
1457
|
scope: this,
|
|
1388
1458
|
callSite: (f, a) => f(...a)
|
|
1389
1459
|
});
|
|
@@ -1400,11 +1470,11 @@ var NetworkManager = class {
|
|
|
1400
1470
|
this._swarms.delete(topic);
|
|
1401
1471
|
await this.topicsUpdated.emit();
|
|
1402
1472
|
log6("left", {
|
|
1403
|
-
topic:
|
|
1473
|
+
topic: PublicKey7.from(topic),
|
|
1404
1474
|
count: this._swarms.size
|
|
1405
1475
|
}, {
|
|
1406
1476
|
file: "network-manager.ts",
|
|
1407
|
-
line:
|
|
1477
|
+
line: 210,
|
|
1408
1478
|
scope: this,
|
|
1409
1479
|
callSite: (f, a) => f(...a)
|
|
1410
1480
|
});
|
|
@@ -1615,7 +1685,7 @@ import assert9 from "@dxos/node-std/assert";
|
|
|
1615
1685
|
import { Transform } from "@dxos/node-std/stream";
|
|
1616
1686
|
import { Event as Event6, Trigger } from "@dxos/async";
|
|
1617
1687
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
1618
|
-
import { PublicKey as
|
|
1688
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1619
1689
|
import { log as log9, logInfo as logInfo2 } from "@dxos/log";
|
|
1620
1690
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1621
1691
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
@@ -1651,7 +1721,7 @@ var _MemoryTransport = class {
|
|
|
1651
1721
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1652
1722
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1653
1723
|
this._destroyed = false;
|
|
1654
|
-
this._instanceId =
|
|
1724
|
+
this._instanceId = PublicKey8.random();
|
|
1655
1725
|
log9("creating", {}, {
|
|
1656
1726
|
file: "memory-transport.ts",
|
|
1657
1727
|
line: 64,
|
|
@@ -1760,14 +1830,14 @@ var _MemoryTransport = class {
|
|
|
1760
1830
|
}
|
|
1761
1831
|
const transportId = payload.transportId;
|
|
1762
1832
|
if (transportId) {
|
|
1763
|
-
const remoteId =
|
|
1833
|
+
const remoteId = PublicKey8.fromHex(transportId);
|
|
1764
1834
|
this._remote.wake(remoteId);
|
|
1765
1835
|
}
|
|
1766
1836
|
}
|
|
1767
1837
|
};
|
|
1768
1838
|
var MemoryTransport = _MemoryTransport;
|
|
1769
1839
|
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
1770
|
-
MemoryTransport._connections = new ComplexMap6(
|
|
1840
|
+
MemoryTransport._connections = new ComplexMap6(PublicKey8.hash);
|
|
1771
1841
|
__decorate4([
|
|
1772
1842
|
logInfo2
|
|
1773
1843
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
@@ -1780,7 +1850,9 @@ import assert10 from "@dxos/node-std/assert";
|
|
|
1780
1850
|
import SimplePeerConstructor from "simple-peer";
|
|
1781
1851
|
import { Event as Event7 } from "@dxos/async";
|
|
1782
1852
|
import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
|
|
1853
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
1783
1854
|
import { log as log10 } from "@dxos/log";
|
|
1855
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
1784
1856
|
|
|
1785
1857
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
1786
1858
|
var wrtc = null;
|
|
@@ -1798,9 +1870,22 @@ var WebRTCTransport = class {
|
|
|
1798
1870
|
this.closed = new Event7();
|
|
1799
1871
|
this.connected = new Event7();
|
|
1800
1872
|
this.errors = new ErrorStream4();
|
|
1873
|
+
this._instanceId = PublicKey9.random().toHex();
|
|
1874
|
+
this._performance = {
|
|
1875
|
+
bytesSent: 0,
|
|
1876
|
+
bytesReceived: 0
|
|
1877
|
+
};
|
|
1878
|
+
log10.trace("dxos.mesh.webrtc-transport", trace4.begin({
|
|
1879
|
+
id: this._instanceId
|
|
1880
|
+
}), {
|
|
1881
|
+
file: "webrtc-transport.ts",
|
|
1882
|
+
line: 43,
|
|
1883
|
+
scope: this,
|
|
1884
|
+
callSite: (f, a) => f(...a)
|
|
1885
|
+
});
|
|
1801
1886
|
log10("created connection", params, {
|
|
1802
1887
|
file: "webrtc-transport.ts",
|
|
1803
|
-
line:
|
|
1888
|
+
line: 44,
|
|
1804
1889
|
scope: this,
|
|
1805
1890
|
callSite: (f, a) => f(...a)
|
|
1806
1891
|
});
|
|
@@ -1812,7 +1897,7 @@ var WebRTCTransport = class {
|
|
|
1812
1897
|
this._peer.on("signal", async (data) => {
|
|
1813
1898
|
log10("signal", data, {
|
|
1814
1899
|
file: "webrtc-transport.ts",
|
|
1815
|
-
line:
|
|
1900
|
+
line: 52,
|
|
1816
1901
|
scope: this,
|
|
1817
1902
|
callSite: (f, a) => f(...a)
|
|
1818
1903
|
});
|
|
@@ -1825,7 +1910,7 @@ var WebRTCTransport = class {
|
|
|
1825
1910
|
this._peer.on("connect", () => {
|
|
1826
1911
|
log10("connected", {}, {
|
|
1827
1912
|
file: "webrtc-transport.ts",
|
|
1828
|
-
line:
|
|
1913
|
+
line: 57,
|
|
1829
1914
|
scope: this,
|
|
1830
1915
|
callSite: (f, a) => f(...a)
|
|
1831
1916
|
});
|
|
@@ -1835,7 +1920,7 @@ var WebRTCTransport = class {
|
|
|
1835
1920
|
this._peer.on("close", async () => {
|
|
1836
1921
|
log10("closed", {}, {
|
|
1837
1922
|
file: "webrtc-transport.ts",
|
|
1838
|
-
line:
|
|
1923
|
+
line: 63,
|
|
1839
1924
|
scope: this,
|
|
1840
1925
|
callSite: (f, a) => f(...a)
|
|
1841
1926
|
});
|
|
@@ -1853,7 +1938,7 @@ var WebRTCTransport = class {
|
|
|
1853
1938
|
stats
|
|
1854
1939
|
}, {
|
|
1855
1940
|
file: "webrtc-transport.ts",
|
|
1856
|
-
line:
|
|
1941
|
+
line: 75,
|
|
1857
1942
|
scope: this,
|
|
1858
1943
|
callSite: (f, a) => f(...a)
|
|
1859
1944
|
});
|
|
@@ -1867,7 +1952,7 @@ var WebRTCTransport = class {
|
|
|
1867
1952
|
async destroy() {
|
|
1868
1953
|
log10("closing...", {}, {
|
|
1869
1954
|
file: "webrtc-transport.ts",
|
|
1870
|
-
line:
|
|
1955
|
+
line: 88,
|
|
1871
1956
|
scope: this,
|
|
1872
1957
|
callSite: (f, a) => f(...a)
|
|
1873
1958
|
});
|
|
@@ -1877,7 +1962,18 @@ var WebRTCTransport = class {
|
|
|
1877
1962
|
this.closed.emit();
|
|
1878
1963
|
log10("closed", {}, {
|
|
1879
1964
|
file: "webrtc-transport.ts",
|
|
1880
|
-
line:
|
|
1965
|
+
line: 93,
|
|
1966
|
+
scope: this,
|
|
1967
|
+
callSite: (f, a) => f(...a)
|
|
1968
|
+
});
|
|
1969
|
+
log10.trace("dxos.mesh.webrtc-transport", trace4.end({
|
|
1970
|
+
id: this._instanceId,
|
|
1971
|
+
data: {
|
|
1972
|
+
performance: this._performance
|
|
1973
|
+
}
|
|
1974
|
+
}), {
|
|
1975
|
+
file: "webrtc-transport.ts",
|
|
1976
|
+
line: 94,
|
|
1881
1977
|
scope: this,
|
|
1882
1978
|
callSite: (f, a) => f(...a)
|
|
1883
1979
|
});
|
|
@@ -1905,7 +2001,7 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
1905
2001
|
import assert11 from "@dxos/node-std/assert";
|
|
1906
2002
|
import { Duplex } from "@dxos/node-std/stream";
|
|
1907
2003
|
import { Stream } from "@dxos/codec-protobuf";
|
|
1908
|
-
import { PublicKey as
|
|
2004
|
+
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
1909
2005
|
import { log as log11 } from "@dxos/log";
|
|
1910
2006
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
1911
2007
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
@@ -1913,7 +2009,7 @@ var WebRTCTransportService = class {
|
|
|
1913
2009
|
// prettier-ignore
|
|
1914
2010
|
constructor(_webrtcConfig) {
|
|
1915
2011
|
this._webrtcConfig = _webrtcConfig;
|
|
1916
|
-
this.transports = new ComplexMap7(
|
|
2012
|
+
this.transports = new ComplexMap7(PublicKey10.hash);
|
|
1917
2013
|
}
|
|
1918
2014
|
open(request) {
|
|
1919
2015
|
const rpcStream = new Stream(({ ready, next, close }) => {
|
|
@@ -2004,14 +2100,14 @@ import assert12 from "@dxos/node-std/assert";
|
|
|
2004
2100
|
import { Event as Event8 } from "@dxos/async";
|
|
2005
2101
|
import { Context as Context2 } from "@dxos/context";
|
|
2006
2102
|
import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
2007
|
-
import { PublicKey as
|
|
2103
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
2008
2104
|
import { log as log12 } from "@dxos/log";
|
|
2009
2105
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2010
2106
|
var WebRTCTransportProxy = class {
|
|
2011
2107
|
// prettier-ignore
|
|
2012
2108
|
constructor(_params) {
|
|
2013
2109
|
this._params = _params;
|
|
2014
|
-
this._proxyId =
|
|
2110
|
+
this._proxyId = PublicKey11.random();
|
|
2015
2111
|
this._ctx = new Context2();
|
|
2016
2112
|
this.closed = new Event8();
|
|
2017
2113
|
this._closed = false;
|
|
@@ -2188,4 +2284,4 @@ export {
|
|
|
2188
2284
|
WebRTCTransportProxyFactory,
|
|
2189
2285
|
createTeleportProtocolFactory
|
|
2190
2286
|
};
|
|
2191
|
-
//# sourceMappingURL=chunk-
|
|
2287
|
+
//# sourceMappingURL=chunk-4W77MFHZ.mjs.map
|