@dxos/network-manager 0.1.32-next.86f5578 → 0.1.34
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
package/dist/lib/node/index.cjs
CHANGED
|
@@ -55,14 +55,16 @@ module.exports = __toCommonJS(src_exports);
|
|
|
55
55
|
// packages/core/mesh/network-manager/src/connection-log.ts
|
|
56
56
|
var import_async5 = require("@dxos/async");
|
|
57
57
|
var import_debug3 = require("@dxos/debug");
|
|
58
|
-
var
|
|
58
|
+
var import_keys6 = require("@dxos/keys");
|
|
59
59
|
var import_util4 = require("@dxos/util");
|
|
60
60
|
|
|
61
61
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
62
62
|
var import_node_assert = __toESM(require("node:assert"));
|
|
63
63
|
var import_async = require("@dxos/async");
|
|
64
64
|
var import_debug = require("@dxos/debug");
|
|
65
|
+
var import_keys = require("@dxos/keys");
|
|
65
66
|
var import_log = require("@dxos/log");
|
|
67
|
+
var import_protocols = require("@dxos/protocols");
|
|
66
68
|
var __decorate = function(decorators, target, key, desc) {
|
|
67
69
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
68
70
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -121,6 +123,10 @@ var Connection = class {
|
|
|
121
123
|
this._bufferedSignals = [];
|
|
122
124
|
this.stateChanged = new import_async.Event();
|
|
123
125
|
this.errors = new import_debug.ErrorStream();
|
|
126
|
+
this._instanceId = import_keys.PublicKey.random().toHex();
|
|
127
|
+
this._performance = {
|
|
128
|
+
signalsSent: 0
|
|
129
|
+
};
|
|
124
130
|
}
|
|
125
131
|
get state() {
|
|
126
132
|
return this._state;
|
|
@@ -138,13 +144,22 @@ var Connection = class {
|
|
|
138
144
|
openConnection() {
|
|
139
145
|
(0, import_node_assert.default)(this._state === ConnectionState.INITIAL, "Invalid state.");
|
|
140
146
|
this._changeState(ConnectionState.CONNECTING);
|
|
147
|
+
import_log.log.trace("dxos.mesh.connection", import_protocols.trace.begin({
|
|
148
|
+
id: this._instanceId,
|
|
149
|
+
parentId: this._traceParent
|
|
150
|
+
}), {
|
|
151
|
+
file: "connection.ts",
|
|
152
|
+
line: 97,
|
|
153
|
+
scope: this,
|
|
154
|
+
callSite: (f, a) => f(...a)
|
|
155
|
+
});
|
|
141
156
|
this._protocol.initialize().catch((err) => {
|
|
142
157
|
this.errors.raise(err);
|
|
143
158
|
});
|
|
144
159
|
this._protocol.stream.on("close", () => {
|
|
145
160
|
(0, import_log.log)("protocol stream closed", {}, {
|
|
146
161
|
file: "connection.ts",
|
|
147
|
-
line:
|
|
162
|
+
line: 106,
|
|
148
163
|
scope: this,
|
|
149
164
|
callSite: (f, a) => f(...a)
|
|
150
165
|
});
|
|
@@ -155,6 +170,7 @@ var Connection = class {
|
|
|
155
170
|
initiator: this.initiator,
|
|
156
171
|
stream: this._protocol.stream,
|
|
157
172
|
sendSignal: async (signal) => {
|
|
173
|
+
this._performance.signalsSent++;
|
|
158
174
|
await this._signalMessaging.signal({
|
|
159
175
|
author: this.ownId,
|
|
160
176
|
recipient: this.remoteId,
|
|
@@ -193,7 +209,7 @@ var Connection = class {
|
|
|
193
209
|
peerId: this.ownId
|
|
194
210
|
}, {
|
|
195
211
|
file: "connection.ts",
|
|
196
|
-
line:
|
|
212
|
+
line: 156,
|
|
197
213
|
scope: this,
|
|
198
214
|
callSite: (f, a) => f(...a)
|
|
199
215
|
});
|
|
@@ -202,7 +218,7 @@ var Connection = class {
|
|
|
202
218
|
} catch (err) {
|
|
203
219
|
import_log.log.catch(err, {}, {
|
|
204
220
|
file: "connection.ts",
|
|
205
|
-
line:
|
|
221
|
+
line: 162,
|
|
206
222
|
scope: this,
|
|
207
223
|
callSite: (f, a) => f(...a)
|
|
208
224
|
});
|
|
@@ -212,7 +228,7 @@ var Connection = class {
|
|
|
212
228
|
} catch (err1) {
|
|
213
229
|
import_log.log.catch(err1, {}, {
|
|
214
230
|
file: "connection.ts",
|
|
215
|
-
line:
|
|
231
|
+
line: 169,
|
|
216
232
|
scope: this,
|
|
217
233
|
callSite: (f, a) => f(...a)
|
|
218
234
|
});
|
|
@@ -221,11 +237,23 @@ var Connection = class {
|
|
|
221
237
|
peerId: this.ownId
|
|
222
238
|
}, {
|
|
223
239
|
file: "connection.ts",
|
|
224
|
-
line:
|
|
240
|
+
line: 172,
|
|
225
241
|
scope: this,
|
|
226
242
|
callSite: (f, a) => f(...a)
|
|
227
243
|
});
|
|
228
244
|
this._changeState(ConnectionState.CLOSED);
|
|
245
|
+
import_log.log.trace("dxos.mesh.connection", import_protocols.trace.end({
|
|
246
|
+
id: this._instanceId,
|
|
247
|
+
status: "ok",
|
|
248
|
+
data: {
|
|
249
|
+
performance: this._performance
|
|
250
|
+
}
|
|
251
|
+
}), {
|
|
252
|
+
file: "connection.ts",
|
|
253
|
+
line: 174,
|
|
254
|
+
scope: this,
|
|
255
|
+
callSite: (f, a) => f(...a)
|
|
256
|
+
});
|
|
229
257
|
}
|
|
230
258
|
async signal(msg) {
|
|
231
259
|
var _a, _b;
|
|
@@ -233,7 +261,7 @@ var Connection = class {
|
|
|
233
261
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
234
262
|
(0, import_log.log)("dropping signal for incorrect session id", {}, {
|
|
235
263
|
file: "connection.ts",
|
|
236
|
-
line:
|
|
264
|
+
line: 183,
|
|
237
265
|
scope: this,
|
|
238
266
|
callSite: (f, a) => f(...a)
|
|
239
267
|
});
|
|
@@ -249,7 +277,7 @@ var Connection = class {
|
|
|
249
277
|
msg: msg.data
|
|
250
278
|
}, {
|
|
251
279
|
file: "connection.ts",
|
|
252
|
-
line:
|
|
280
|
+
line: 191,
|
|
253
281
|
scope: this,
|
|
254
282
|
callSite: (f, a) => f(...a)
|
|
255
283
|
});
|
|
@@ -263,7 +291,7 @@ var Connection = class {
|
|
|
263
291
|
msg: msg.data
|
|
264
292
|
}, {
|
|
265
293
|
file: "connection.ts",
|
|
266
|
-
line:
|
|
294
|
+
line: 197,
|
|
267
295
|
scope: this,
|
|
268
296
|
callSite: (f, a) => f(...a)
|
|
269
297
|
});
|
|
@@ -276,7 +304,7 @@ var Connection = class {
|
|
|
276
304
|
peerId: this.ownId
|
|
277
305
|
}, {
|
|
278
306
|
file: "connection.ts",
|
|
279
|
-
line:
|
|
307
|
+
line: 202,
|
|
280
308
|
scope: this,
|
|
281
309
|
callSite: (f, a) => f(...a)
|
|
282
310
|
});
|
|
@@ -294,15 +322,16 @@ var import_node_assert4 = __toESM(require("node:assert"));
|
|
|
294
322
|
var import_async3 = require("@dxos/async");
|
|
295
323
|
var import_context = require("@dxos/context");
|
|
296
324
|
var import_debug2 = require("@dxos/debug");
|
|
297
|
-
var
|
|
325
|
+
var import_keys4 = require("@dxos/keys");
|
|
298
326
|
var import_log4 = require("@dxos/log");
|
|
327
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
299
328
|
var import_util2 = require("@dxos/util");
|
|
300
329
|
|
|
301
330
|
// packages/core/mesh/network-manager/src/signal/message-router.ts
|
|
302
331
|
var import_node_assert2 = __toESM(require("node:assert"));
|
|
303
|
-
var
|
|
332
|
+
var import_keys2 = require("@dxos/keys");
|
|
304
333
|
var import_log2 = require("@dxos/log");
|
|
305
|
-
var
|
|
334
|
+
var import_protocols2 = require("@dxos/protocols");
|
|
306
335
|
var import_util = require("@dxos/util");
|
|
307
336
|
var MessageRouter = class {
|
|
308
337
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -317,7 +346,7 @@ var MessageRouter = class {
|
|
|
317
346
|
if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
|
|
318
347
|
return;
|
|
319
348
|
}
|
|
320
|
-
const message =
|
|
349
|
+
const message = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage").decode(payload.value);
|
|
321
350
|
if (!this._topic.equals(message.topic)) {
|
|
322
351
|
return;
|
|
323
352
|
}
|
|
@@ -359,7 +388,7 @@ var MessageRouter = class {
|
|
|
359
388
|
async offer(message) {
|
|
360
389
|
const networkMessage = {
|
|
361
390
|
...message,
|
|
362
|
-
messageId:
|
|
391
|
+
messageId: import_keys2.PublicKey.random()
|
|
363
392
|
};
|
|
364
393
|
return new Promise((resolve, reject) => {
|
|
365
394
|
this._offerRecords.set(networkMessage.messageId, {
|
|
@@ -378,7 +407,7 @@ var MessageRouter = class {
|
|
|
378
407
|
const networkMessage = {
|
|
379
408
|
...message,
|
|
380
409
|
// Setting unique message_id if it not specified yet.
|
|
381
|
-
messageId: (_a = message.messageId) != null ? _a :
|
|
410
|
+
messageId: (_a = message.messageId) != null ? _a : import_keys2.PublicKey.random()
|
|
382
411
|
};
|
|
383
412
|
(0, import_log2.log)("sending", {
|
|
384
413
|
from: author,
|
|
@@ -402,7 +431,7 @@ var MessageRouter = class {
|
|
|
402
431
|
recipient,
|
|
403
432
|
payload: {
|
|
404
433
|
type_url: "dxos.mesh.swarm.SwarmMessage",
|
|
405
|
-
value:
|
|
434
|
+
value: import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage").encode(message)
|
|
406
435
|
}
|
|
407
436
|
});
|
|
408
437
|
}
|
|
@@ -466,7 +495,7 @@ var MessageRouter = class {
|
|
|
466
495
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
467
496
|
var import_node_assert3 = __toESM(require("node:assert"));
|
|
468
497
|
var import_async2 = require("@dxos/async");
|
|
469
|
-
var
|
|
498
|
+
var import_keys3 = require("@dxos/keys");
|
|
470
499
|
var import_log3 = require("@dxos/log");
|
|
471
500
|
var __decorate2 = function(decorators, target, key, desc) {
|
|
472
501
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -503,7 +532,7 @@ var Peer = class {
|
|
|
503
532
|
peerId: this.localPeerId
|
|
504
533
|
}, {
|
|
505
534
|
file: "peer.ts",
|
|
506
|
-
line:
|
|
535
|
+
line: 86,
|
|
507
536
|
scope: this,
|
|
508
537
|
callSite: (f, a) => f(...a)
|
|
509
538
|
});
|
|
@@ -530,7 +559,7 @@ var Peer = class {
|
|
|
530
559
|
err
|
|
531
560
|
}, {
|
|
532
561
|
file: "peer.ts",
|
|
533
|
-
line:
|
|
562
|
+
line: 110,
|
|
534
563
|
scope: this,
|
|
535
564
|
callSite: (f, a) => f(...a)
|
|
536
565
|
});
|
|
@@ -551,7 +580,7 @@ var Peer = class {
|
|
|
551
580
|
async initiateConnection() {
|
|
552
581
|
(0, import_node_assert3.default)(!this.initiating, "Initiation in progress.");
|
|
553
582
|
(0, import_node_assert3.default)(!this.connection, "Already connected.");
|
|
554
|
-
const sessionId =
|
|
583
|
+
const sessionId = import_keys3.PublicKey.random();
|
|
555
584
|
(0, import_log3.log)("initiating...", {
|
|
556
585
|
id: this.id,
|
|
557
586
|
topic: this.topic,
|
|
@@ -559,7 +588,7 @@ var Peer = class {
|
|
|
559
588
|
sessionId
|
|
560
589
|
}, {
|
|
561
590
|
file: "peer.ts",
|
|
562
|
-
line:
|
|
591
|
+
line: 128,
|
|
563
592
|
scope: this,
|
|
564
593
|
callSite: (f, a) => f(...a)
|
|
565
594
|
});
|
|
@@ -582,14 +611,14 @@ var Peer = class {
|
|
|
582
611
|
remoteId: this.id
|
|
583
612
|
}, {
|
|
584
613
|
file: "peer.ts",
|
|
585
|
-
line:
|
|
614
|
+
line: 140,
|
|
586
615
|
scope: this,
|
|
587
616
|
callSite: (f, a) => f(...a)
|
|
588
617
|
});
|
|
589
618
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
590
619
|
(0, import_log3.log)("ignoring response", {}, {
|
|
591
620
|
file: "peer.ts",
|
|
592
|
-
line:
|
|
621
|
+
line: 142,
|
|
593
622
|
scope: this,
|
|
594
623
|
callSite: (f, a) => f(...a)
|
|
595
624
|
});
|
|
@@ -609,7 +638,7 @@ var Peer = class {
|
|
|
609
638
|
err
|
|
610
639
|
}, {
|
|
611
640
|
file: "peer.ts",
|
|
612
|
-
line:
|
|
641
|
+
line: 153,
|
|
613
642
|
scope: this,
|
|
614
643
|
callSite: (f, a) => f(...a)
|
|
615
644
|
});
|
|
@@ -632,7 +661,7 @@ var Peer = class {
|
|
|
632
661
|
sessionId
|
|
633
662
|
}, {
|
|
634
663
|
file: "peer.ts",
|
|
635
|
-
line:
|
|
664
|
+
line: 167,
|
|
636
665
|
scope: this,
|
|
637
666
|
callSite: (f, a) => f(...a)
|
|
638
667
|
});
|
|
@@ -653,6 +682,7 @@ var Peer = class {
|
|
|
653
682
|
}),
|
|
654
683
|
this._transportFactory
|
|
655
684
|
);
|
|
685
|
+
connection._traceParent = this._traceParent;
|
|
656
686
|
this._callbacks.onInitiated(connection);
|
|
657
687
|
connection.stateChanged.on((state) => {
|
|
658
688
|
switch (state) {
|
|
@@ -668,7 +698,7 @@ var Peer = class {
|
|
|
668
698
|
initiator
|
|
669
699
|
}, {
|
|
670
700
|
file: "peer.ts",
|
|
671
|
-
line:
|
|
701
|
+
line: 197,
|
|
672
702
|
scope: this,
|
|
673
703
|
callSite: (f, a) => f(...a)
|
|
674
704
|
});
|
|
@@ -688,7 +718,7 @@ var Peer = class {
|
|
|
688
718
|
err
|
|
689
719
|
}, {
|
|
690
720
|
file: "peer.ts",
|
|
691
|
-
line:
|
|
721
|
+
line: 207,
|
|
692
722
|
scope: this,
|
|
693
723
|
callSite: (f, a) => f(...a)
|
|
694
724
|
});
|
|
@@ -707,7 +737,7 @@ var Peer = class {
|
|
|
707
737
|
sessionId: connection.sessionId
|
|
708
738
|
}, {
|
|
709
739
|
file: "peer.ts",
|
|
710
|
-
line:
|
|
740
|
+
line: 223,
|
|
711
741
|
scope: this,
|
|
712
742
|
callSite: (f, a) => f(...a)
|
|
713
743
|
});
|
|
@@ -717,7 +747,7 @@ var Peer = class {
|
|
|
717
747
|
sessionId: connection.sessionId
|
|
718
748
|
}, {
|
|
719
749
|
file: "peer.ts",
|
|
720
|
-
line:
|
|
750
|
+
line: 229,
|
|
721
751
|
scope: this,
|
|
722
752
|
callSite: (f, a) => f(...a)
|
|
723
753
|
});
|
|
@@ -728,7 +758,7 @@ var Peer = class {
|
|
|
728
758
|
message
|
|
729
759
|
}, {
|
|
730
760
|
file: "peer.ts",
|
|
731
|
-
line:
|
|
761
|
+
line: 234,
|
|
732
762
|
scope: this,
|
|
733
763
|
callSite: (f, a) => f(...a)
|
|
734
764
|
});
|
|
@@ -743,7 +773,7 @@ var Peer = class {
|
|
|
743
773
|
topic: this.topic
|
|
744
774
|
}, {
|
|
745
775
|
file: "peer.ts",
|
|
746
|
-
line:
|
|
776
|
+
line: 242,
|
|
747
777
|
scope: this,
|
|
748
778
|
callSite: (f, a) => f(...a)
|
|
749
779
|
});
|
|
@@ -778,18 +808,18 @@ var Swarm = class {
|
|
|
778
808
|
this._messenger = _messenger;
|
|
779
809
|
this._transportFactory = _transportFactory;
|
|
780
810
|
this._label = _label;
|
|
781
|
-
this._peers = new import_util2.ComplexMap(
|
|
811
|
+
this._peers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
|
|
782
812
|
this._ctx = new import_context.Context();
|
|
783
813
|
this.connectionAdded = new import_async3.Event();
|
|
784
814
|
this.disconnected = new import_async3.Event();
|
|
785
815
|
this.connected = new import_async3.Event();
|
|
786
816
|
this.errors = new import_debug2.ErrorStream();
|
|
787
|
-
this.
|
|
817
|
+
this._instanceId = import_keys4.PublicKey.random().toHex();
|
|
788
818
|
(0, import_log4.log)("creating swarm", {
|
|
789
819
|
peerId: _ownPeerId
|
|
790
820
|
}, {
|
|
791
821
|
file: "swarm.ts",
|
|
792
|
-
line:
|
|
822
|
+
line: 84,
|
|
793
823
|
scope: this,
|
|
794
824
|
callSite: (f, a) => f(...a)
|
|
795
825
|
});
|
|
@@ -806,10 +836,22 @@ var Swarm = class {
|
|
|
806
836
|
onMessage: async (message) => await this._swarmMessenger.receiveMessage(message)
|
|
807
837
|
}).catch((error) => import_log4.log.catch(error, {}, {
|
|
808
838
|
file: "swarm.ts",
|
|
809
|
-
line:
|
|
839
|
+
line: 100,
|
|
810
840
|
scope: this,
|
|
811
841
|
callSite: (f, a) => f(...a)
|
|
812
842
|
}));
|
|
843
|
+
import_log4.log.trace("dxos.mesh.swarm", import_protocols3.trace.begin({
|
|
844
|
+
id: this._instanceId,
|
|
845
|
+
data: {
|
|
846
|
+
topic: this._topic.toHex(),
|
|
847
|
+
peerId: this._ownPeerId.toHex()
|
|
848
|
+
}
|
|
849
|
+
}), {
|
|
850
|
+
file: "swarm.ts",
|
|
851
|
+
line: 102,
|
|
852
|
+
scope: this,
|
|
853
|
+
callSite: (f, a) => f(...a)
|
|
854
|
+
});
|
|
813
855
|
}
|
|
814
856
|
get connections() {
|
|
815
857
|
return Array.from(this._peers.values()).map((peer) => peer.connection).filter(import_util2.isNotNullOrUndefined);
|
|
@@ -830,7 +872,7 @@ var Swarm = class {
|
|
|
830
872
|
async destroy() {
|
|
831
873
|
(0, import_log4.log)("destroying...", {}, {
|
|
832
874
|
file: "swarm.ts",
|
|
833
|
-
line:
|
|
875
|
+
line: 133,
|
|
834
876
|
scope: this,
|
|
835
877
|
callSite: (f, a) => f(...a)
|
|
836
878
|
});
|
|
@@ -839,7 +881,15 @@ var Swarm = class {
|
|
|
839
881
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
840
882
|
(0, import_log4.log)("destroyed", {}, {
|
|
841
883
|
file: "swarm.ts",
|
|
842
|
-
line:
|
|
884
|
+
line: 137,
|
|
885
|
+
scope: this,
|
|
886
|
+
callSite: (f, a) => f(...a)
|
|
887
|
+
});
|
|
888
|
+
import_log4.log.trace("dxos.mesh.swarm", import_protocols3.trace.end({
|
|
889
|
+
id: this._instanceId
|
|
890
|
+
}), {
|
|
891
|
+
file: "swarm.ts",
|
|
892
|
+
line: 138,
|
|
843
893
|
scope: this,
|
|
844
894
|
callSite: (f, a) => f(...a)
|
|
845
895
|
});
|
|
@@ -854,7 +904,7 @@ var Swarm = class {
|
|
|
854
904
|
topology: getClassName(topology)
|
|
855
905
|
}, {
|
|
856
906
|
file: "swarm.ts",
|
|
857
|
-
line:
|
|
907
|
+
line: 146,
|
|
858
908
|
scope: this,
|
|
859
909
|
callSite: (f, a) => f(...a)
|
|
860
910
|
});
|
|
@@ -869,26 +919,26 @@ var Swarm = class {
|
|
|
869
919
|
swarmEvent
|
|
870
920
|
}, {
|
|
871
921
|
file: "swarm.ts",
|
|
872
|
-
line:
|
|
922
|
+
line: 159,
|
|
873
923
|
scope: this,
|
|
874
924
|
callSite: (f, a) => f(...a)
|
|
875
925
|
});
|
|
876
926
|
if (this._ctx.disposed) {
|
|
877
927
|
(0, import_log4.log)("swarm event ignored for disposed swarm", {}, {
|
|
878
928
|
file: "swarm.ts",
|
|
879
|
-
line:
|
|
929
|
+
line: 162,
|
|
880
930
|
scope: this,
|
|
881
931
|
callSite: (f, a) => f(...a)
|
|
882
932
|
});
|
|
883
933
|
return;
|
|
884
934
|
}
|
|
885
935
|
if (swarmEvent.peerAvailable) {
|
|
886
|
-
const peerId =
|
|
936
|
+
const peerId = import_keys4.PublicKey.from(swarmEvent.peerAvailable.peer);
|
|
887
937
|
(0, import_log4.log)("new peer", {
|
|
888
938
|
peerId
|
|
889
939
|
}, {
|
|
890
940
|
file: "swarm.ts",
|
|
891
|
-
line:
|
|
941
|
+
line: 168,
|
|
892
942
|
scope: this,
|
|
893
943
|
callSite: (f, a) => f(...a)
|
|
894
944
|
});
|
|
@@ -897,13 +947,13 @@ var Swarm = class {
|
|
|
897
947
|
peer.advertizing = true;
|
|
898
948
|
}
|
|
899
949
|
} else if (swarmEvent.peerLeft) {
|
|
900
|
-
const peer1 = this._peers.get(
|
|
950
|
+
const peer1 = this._peers.get(import_keys4.PublicKey.from(swarmEvent.peerLeft.peer));
|
|
901
951
|
if (peer1) {
|
|
902
952
|
peer1.advertizing = false;
|
|
903
953
|
if (((_a = peer1.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
|
|
904
954
|
void this._destroyPeer(peer1.id).catch((err) => import_log4.log.catch(err, {}, {
|
|
905
955
|
file: "swarm.ts",
|
|
906
|
-
line:
|
|
956
|
+
line: 179,
|
|
907
957
|
scope: this,
|
|
908
958
|
callSite: (f, a) => f(...a)
|
|
909
959
|
}));
|
|
@@ -918,14 +968,14 @@ var Swarm = class {
|
|
|
918
968
|
message
|
|
919
969
|
}, {
|
|
920
970
|
file: "swarm.ts",
|
|
921
|
-
line:
|
|
971
|
+
line: 189,
|
|
922
972
|
scope: this,
|
|
923
973
|
callSite: (f, a) => f(...a)
|
|
924
974
|
});
|
|
925
975
|
if (this._ctx.disposed) {
|
|
926
976
|
(0, import_log4.log)("ignored for disposed swarm", {}, {
|
|
927
977
|
file: "swarm.ts",
|
|
928
|
-
line:
|
|
978
|
+
line: 191,
|
|
929
979
|
scope: this,
|
|
930
980
|
callSite: (f, a) => f(...a)
|
|
931
981
|
});
|
|
@@ -939,7 +989,7 @@ var Swarm = class {
|
|
|
939
989
|
message
|
|
940
990
|
}, {
|
|
941
991
|
file: "swarm.ts",
|
|
942
|
-
line:
|
|
992
|
+
line: 198,
|
|
943
993
|
scope: this,
|
|
944
994
|
callSite: (f, a) => f(...a)
|
|
945
995
|
});
|
|
@@ -952,7 +1002,7 @@ var Swarm = class {
|
|
|
952
1002
|
message
|
|
953
1003
|
}, {
|
|
954
1004
|
file: "swarm.ts",
|
|
955
|
-
line:
|
|
1005
|
+
line: 202,
|
|
956
1006
|
scope: this,
|
|
957
1007
|
callSite: (f, a) => f(...a)
|
|
958
1008
|
});
|
|
@@ -971,14 +1021,14 @@ var Swarm = class {
|
|
|
971
1021
|
message
|
|
972
1022
|
}, {
|
|
973
1023
|
file: "swarm.ts",
|
|
974
|
-
line:
|
|
1024
|
+
line: 214,
|
|
975
1025
|
scope: this,
|
|
976
1026
|
callSite: (f, a) => f(...a)
|
|
977
1027
|
});
|
|
978
1028
|
if (this._ctx.disposed) {
|
|
979
1029
|
import_log4.log.info("ignored for offline swarm", {}, {
|
|
980
1030
|
file: "swarm.ts",
|
|
981
|
-
line:
|
|
1031
|
+
line: 216,
|
|
982
1032
|
scope: this,
|
|
983
1033
|
callSite: (f, a) => f(...a)
|
|
984
1034
|
});
|
|
@@ -1030,6 +1080,7 @@ var Swarm = class {
|
|
|
1030
1080
|
return this._topology.onOffer(remoteId);
|
|
1031
1081
|
}
|
|
1032
1082
|
});
|
|
1083
|
+
peer._traceParent = this._instanceId;
|
|
1033
1084
|
this._peers.set(peerId, peer);
|
|
1034
1085
|
}
|
|
1035
1086
|
return peer;
|
|
@@ -1056,7 +1107,7 @@ var Swarm = class {
|
|
|
1056
1107
|
} catch (err) {
|
|
1057
1108
|
import_log4.log.warn("initiation error", err, {
|
|
1058
1109
|
file: "swarm.ts",
|
|
1059
|
-
line:
|
|
1110
|
+
line: 317,
|
|
1060
1111
|
scope: this,
|
|
1061
1112
|
callSite: (f, a) => f(...a)
|
|
1062
1113
|
});
|
|
@@ -1084,7 +1135,7 @@ var Swarm = class {
|
|
|
1084
1135
|
remoteId
|
|
1085
1136
|
}, {
|
|
1086
1137
|
file: "swarm.ts",
|
|
1087
|
-
line:
|
|
1138
|
+
line: 344,
|
|
1088
1139
|
scope: this,
|
|
1089
1140
|
callSite: (f, a) => f(...a)
|
|
1090
1141
|
});
|
|
@@ -1101,7 +1152,7 @@ var Swarm = class {
|
|
|
1101
1152
|
remoteId
|
|
1102
1153
|
}, {
|
|
1103
1154
|
file: "swarm.ts",
|
|
1104
|
-
line:
|
|
1155
|
+
line: 358,
|
|
1105
1156
|
scope: this,
|
|
1106
1157
|
callSite: (f, a) => f(...a)
|
|
1107
1158
|
});
|
|
@@ -1111,7 +1162,7 @@ var Swarm = class {
|
|
|
1111
1162
|
remoteId
|
|
1112
1163
|
}, {
|
|
1113
1164
|
file: "swarm.ts",
|
|
1114
|
-
line:
|
|
1165
|
+
line: 361,
|
|
1115
1166
|
scope: this,
|
|
1116
1167
|
callSite: (f, a) => f(...a)
|
|
1117
1168
|
});
|
|
@@ -1126,7 +1177,7 @@ var Swarm = class {
|
|
|
1126
1177
|
};
|
|
1127
1178
|
__decorate3([
|
|
1128
1179
|
import_log4.logInfo
|
|
1129
|
-
], Swarm.prototype, "
|
|
1180
|
+
], Swarm.prototype, "_instanceId", void 0);
|
|
1130
1181
|
__decorate3([
|
|
1131
1182
|
import_log4.logInfo
|
|
1132
1183
|
], Swarm.prototype, "ownPeerId", null);
|
|
@@ -1151,7 +1202,7 @@ __decorate3([
|
|
|
1151
1202
|
|
|
1152
1203
|
// packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts
|
|
1153
1204
|
var import_async4 = require("@dxos/async");
|
|
1154
|
-
var
|
|
1205
|
+
var import_keys5 = require("@dxos/keys");
|
|
1155
1206
|
var import_log5 = require("@dxos/log");
|
|
1156
1207
|
var import_util3 = require("@dxos/util");
|
|
1157
1208
|
var SwarmMapper = class {
|
|
@@ -1162,8 +1213,8 @@ var SwarmMapper = class {
|
|
|
1162
1213
|
constructor(_swarm) {
|
|
1163
1214
|
this._swarm = _swarm;
|
|
1164
1215
|
this._subscriptions = new import_async4.EventSubscriptions();
|
|
1165
|
-
this._connectionSubscriptions = new import_util3.ComplexMap(
|
|
1166
|
-
this._peers = new import_util3.ComplexMap(
|
|
1216
|
+
this._connectionSubscriptions = new import_util3.ComplexMap(import_keys5.PublicKey.hash);
|
|
1217
|
+
this._peers = new import_util3.ComplexMap(import_keys5.PublicKey.hash);
|
|
1167
1218
|
this.mapUpdated = new import_async4.Event();
|
|
1168
1219
|
this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
|
|
1169
1220
|
this._update();
|
|
@@ -1233,7 +1284,7 @@ var ConnectionLog = class {
|
|
|
1233
1284
|
/**
|
|
1234
1285
|
* SwarmId => info
|
|
1235
1286
|
*/
|
|
1236
|
-
this._swarms = new import_util4.ComplexMap(
|
|
1287
|
+
this._swarms = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
1237
1288
|
this.update = new import_async5.Event();
|
|
1238
1289
|
}
|
|
1239
1290
|
getSwarmInfo(swarmId) {
|
|
@@ -1245,13 +1296,13 @@ var ConnectionLog = class {
|
|
|
1245
1296
|
}
|
|
1246
1297
|
joinedSwarm(swarm) {
|
|
1247
1298
|
const info = {
|
|
1248
|
-
id: swarm.
|
|
1299
|
+
id: import_keys6.PublicKey.from(swarm._instanceId),
|
|
1249
1300
|
topic: swarm.topic,
|
|
1250
1301
|
isActive: true,
|
|
1251
1302
|
label: swarm.label,
|
|
1252
1303
|
connections: []
|
|
1253
1304
|
};
|
|
1254
|
-
this._swarms.set(swarm.
|
|
1305
|
+
this._swarms.set(import_keys6.PublicKey.from(swarm._instanceId), info);
|
|
1255
1306
|
this.update.emit();
|
|
1256
1307
|
swarm.connectionAdded.on((connection) => {
|
|
1257
1308
|
const connectionInfo = {
|
|
@@ -1275,7 +1326,7 @@ var ConnectionLog = class {
|
|
|
1275
1326
|
});
|
|
1276
1327
|
}
|
|
1277
1328
|
leftSwarm(swarm) {
|
|
1278
|
-
this.getSwarmInfo(swarm.
|
|
1329
|
+
this.getSwarmInfo(import_keys6.PublicKey.from(swarm._instanceId)).isActive = false;
|
|
1279
1330
|
this.update.emit();
|
|
1280
1331
|
}
|
|
1281
1332
|
};
|
|
@@ -1283,18 +1334,20 @@ var ConnectionLog = class {
|
|
|
1283
1334
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
1284
1335
|
var import_node_assert5 = __toESM(require("node:assert"));
|
|
1285
1336
|
var import_async6 = require("@dxos/async");
|
|
1286
|
-
var
|
|
1337
|
+
var import_keys7 = require("@dxos/keys");
|
|
1287
1338
|
var import_log6 = require("@dxos/log");
|
|
1288
1339
|
var import_messaging = require("@dxos/messaging");
|
|
1340
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
1289
1341
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
1290
1342
|
var import_util5 = require("@dxos/util");
|
|
1291
1343
|
var NetworkManager = class {
|
|
1292
1344
|
constructor({ transportFactory, signalManager, log: log13 }) {
|
|
1293
|
-
this._swarms = new import_util5.ComplexMap(
|
|
1294
|
-
this._mappers = new import_util5.ComplexMap(
|
|
1345
|
+
this._swarms = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
|
|
1346
|
+
this._mappers = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
|
|
1295
1347
|
this._connectionState = import_services.ConnectionState.ONLINE;
|
|
1296
1348
|
this.connectionStateChanged = new import_async6.Event();
|
|
1297
1349
|
this.topicsUpdated = new import_async6.Event();
|
|
1350
|
+
this._instanceId = import_keys7.PublicKey.random().toHex();
|
|
1298
1351
|
this._transportFactory = transportFactory;
|
|
1299
1352
|
this._signalManager = signalManager;
|
|
1300
1353
|
this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => {
|
|
@@ -1304,6 +1357,7 @@ var NetworkManager = class {
|
|
|
1304
1357
|
this._messenger = new import_messaging.Messenger({
|
|
1305
1358
|
signalManager: this._signalManager
|
|
1306
1359
|
});
|
|
1360
|
+
this._messenger._traceParent = this._instanceId;
|
|
1307
1361
|
this._signalConnection = {
|
|
1308
1362
|
join: (opts) => this._signalManager.join(opts),
|
|
1309
1363
|
leave: (opts) => this._signalManager.leave(opts)
|
|
@@ -1334,6 +1388,14 @@ var NetworkManager = class {
|
|
|
1334
1388
|
return this._swarms.get(topic);
|
|
1335
1389
|
}
|
|
1336
1390
|
async open() {
|
|
1391
|
+
import_log6.log.trace("dxos.mesh.network-manager", import_protocols4.trace.begin({
|
|
1392
|
+
id: this._instanceId
|
|
1393
|
+
}), {
|
|
1394
|
+
file: "network-manager.ts",
|
|
1395
|
+
line: 133,
|
|
1396
|
+
scope: this,
|
|
1397
|
+
callSite: (f, a) => f(...a)
|
|
1398
|
+
});
|
|
1337
1399
|
await this._messenger.open();
|
|
1338
1400
|
await this._signalManager.open();
|
|
1339
1401
|
}
|
|
@@ -1342,7 +1404,7 @@ var NetworkManager = class {
|
|
|
1342
1404
|
await this.leaveSwarm(topic).catch((err) => {
|
|
1343
1405
|
(0, import_log6.log)(err, {}, {
|
|
1344
1406
|
file: "network-manager.ts",
|
|
1345
|
-
line:
|
|
1407
|
+
line: 141,
|
|
1346
1408
|
scope: this,
|
|
1347
1409
|
callSite: (f, a) => f(...a)
|
|
1348
1410
|
});
|
|
@@ -1350,26 +1412,34 @@ var NetworkManager = class {
|
|
|
1350
1412
|
}
|
|
1351
1413
|
await this._messenger.close();
|
|
1352
1414
|
await this._signalManager.close();
|
|
1415
|
+
import_log6.log.trace("dxos.mesh.network-manager", import_protocols4.trace.end({
|
|
1416
|
+
id: this._instanceId
|
|
1417
|
+
}), {
|
|
1418
|
+
file: "network-manager.ts",
|
|
1419
|
+
line: 147,
|
|
1420
|
+
scope: this,
|
|
1421
|
+
callSite: (f, a) => f(...a)
|
|
1422
|
+
});
|
|
1353
1423
|
}
|
|
1354
1424
|
/**
|
|
1355
1425
|
* Join the swarm.
|
|
1356
1426
|
*/
|
|
1357
1427
|
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1358
1428
|
var _a;
|
|
1359
|
-
(0, import_node_assert5.default)(
|
|
1360
|
-
(0, import_node_assert5.default)(
|
|
1429
|
+
(0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(topic));
|
|
1430
|
+
(0, import_node_assert5.default)(import_keys7.PublicKey.isPublicKey(peerId));
|
|
1361
1431
|
(0, import_node_assert5.default)(topology);
|
|
1362
1432
|
(0, import_node_assert5.default)(typeof protocol === "function");
|
|
1363
1433
|
if (this._swarms.has(topic)) {
|
|
1364
|
-
throw new Error(`Already connected to swarm: ${
|
|
1434
|
+
throw new Error(`Already connected to swarm: ${import_keys7.PublicKey.from(topic)}`);
|
|
1365
1435
|
}
|
|
1366
1436
|
(0, import_log6.log)("joining", {
|
|
1367
|
-
topic:
|
|
1437
|
+
topic: import_keys7.PublicKey.from(topic),
|
|
1368
1438
|
peerId,
|
|
1369
1439
|
topology: topology.toString()
|
|
1370
1440
|
}, {
|
|
1371
1441
|
file: "network-manager.ts",
|
|
1372
|
-
line:
|
|
1442
|
+
line: 168,
|
|
1373
1443
|
scope: this,
|
|
1374
1444
|
callSite: (f, a) => f(...a)
|
|
1375
1445
|
});
|
|
@@ -1379,7 +1449,7 @@ var NetworkManager = class {
|
|
|
1379
1449
|
error
|
|
1380
1450
|
}, {
|
|
1381
1451
|
file: "network-manager.ts",
|
|
1382
|
-
line:
|
|
1452
|
+
line: 171,
|
|
1383
1453
|
scope: this,
|
|
1384
1454
|
callSite: (f, a) => f(...a)
|
|
1385
1455
|
});
|
|
@@ -1390,7 +1460,7 @@ var NetworkManager = class {
|
|
|
1390
1460
|
peerId
|
|
1391
1461
|
}).catch((error) => import_log6.log.catch(error, {}, {
|
|
1392
1462
|
file: "network-manager.ts",
|
|
1393
|
-
line:
|
|
1463
|
+
line: 175,
|
|
1394
1464
|
scope: this,
|
|
1395
1465
|
callSite: (f, a) => f(...a)
|
|
1396
1466
|
}));
|
|
@@ -1398,11 +1468,11 @@ var NetworkManager = class {
|
|
|
1398
1468
|
this.topicsUpdated.emit();
|
|
1399
1469
|
(_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
|
|
1400
1470
|
(0, import_log6.log)("joined", {
|
|
1401
|
-
topic:
|
|
1471
|
+
topic: import_keys7.PublicKey.from(topic),
|
|
1402
1472
|
count: this._swarms.size
|
|
1403
1473
|
}, {
|
|
1404
1474
|
file: "network-manager.ts",
|
|
1405
|
-
line:
|
|
1475
|
+
line: 180,
|
|
1406
1476
|
scope: this,
|
|
1407
1477
|
callSite: (f, a) => f(...a)
|
|
1408
1478
|
});
|
|
@@ -1417,20 +1487,20 @@ var NetworkManager = class {
|
|
|
1417
1487
|
var _a;
|
|
1418
1488
|
if (!this._swarms.has(topic)) {
|
|
1419
1489
|
import_log6.log.warn("swarm not open", {
|
|
1420
|
-
topic:
|
|
1490
|
+
topic: import_keys7.PublicKey.from(topic).truncate()
|
|
1421
1491
|
}, {
|
|
1422
1492
|
file: "network-manager.ts",
|
|
1423
|
-
line:
|
|
1493
|
+
line: 192,
|
|
1424
1494
|
scope: this,
|
|
1425
1495
|
callSite: (f, a) => f(...a)
|
|
1426
1496
|
});
|
|
1427
1497
|
return;
|
|
1428
1498
|
}
|
|
1429
1499
|
(0, import_log6.log)("leaving", {
|
|
1430
|
-
topic:
|
|
1500
|
+
topic: import_keys7.PublicKey.from(topic)
|
|
1431
1501
|
}, {
|
|
1432
1502
|
file: "network-manager.ts",
|
|
1433
|
-
line:
|
|
1503
|
+
line: 196,
|
|
1434
1504
|
scope: this,
|
|
1435
1505
|
callSite: (f, a) => f(...a)
|
|
1436
1506
|
});
|
|
@@ -1447,11 +1517,11 @@ var NetworkManager = class {
|
|
|
1447
1517
|
this._swarms.delete(topic);
|
|
1448
1518
|
await this.topicsUpdated.emit();
|
|
1449
1519
|
(0, import_log6.log)("left", {
|
|
1450
|
-
topic:
|
|
1520
|
+
topic: import_keys7.PublicKey.from(topic),
|
|
1451
1521
|
count: this._swarms.size
|
|
1452
1522
|
}, {
|
|
1453
1523
|
file: "network-manager.ts",
|
|
1454
|
-
line:
|
|
1524
|
+
line: 210,
|
|
1455
1525
|
scope: this,
|
|
1456
1526
|
callSite: (f, a) => f(...a)
|
|
1457
1527
|
});
|
|
@@ -1662,7 +1732,7 @@ var import_node_assert9 = __toESM(require("node:assert"));
|
|
|
1662
1732
|
var import_node_stream = require("node:stream");
|
|
1663
1733
|
var import_async7 = require("@dxos/async");
|
|
1664
1734
|
var import_debug4 = require("@dxos/debug");
|
|
1665
|
-
var
|
|
1735
|
+
var import_keys8 = require("@dxos/keys");
|
|
1666
1736
|
var import_log9 = require("@dxos/log");
|
|
1667
1737
|
var import_util6 = require("@dxos/util");
|
|
1668
1738
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
@@ -1698,7 +1768,7 @@ var _MemoryTransport = class {
|
|
|
1698
1768
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1699
1769
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1700
1770
|
this._destroyed = false;
|
|
1701
|
-
this._instanceId =
|
|
1771
|
+
this._instanceId = import_keys8.PublicKey.random();
|
|
1702
1772
|
(0, import_log9.log)("creating", {}, {
|
|
1703
1773
|
file: "memory-transport.ts",
|
|
1704
1774
|
line: 64,
|
|
@@ -1807,14 +1877,14 @@ var _MemoryTransport = class {
|
|
|
1807
1877
|
}
|
|
1808
1878
|
const transportId = payload.transportId;
|
|
1809
1879
|
if (transportId) {
|
|
1810
|
-
const remoteId =
|
|
1880
|
+
const remoteId = import_keys8.PublicKey.fromHex(transportId);
|
|
1811
1881
|
this._remote.wake(remoteId);
|
|
1812
1882
|
}
|
|
1813
1883
|
}
|
|
1814
1884
|
};
|
|
1815
1885
|
var MemoryTransport = _MemoryTransport;
|
|
1816
1886
|
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
1817
|
-
MemoryTransport._connections = new import_util6.ComplexMap(
|
|
1887
|
+
MemoryTransport._connections = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
|
|
1818
1888
|
__decorate4([
|
|
1819
1889
|
import_log9.logInfo
|
|
1820
1890
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
@@ -1827,7 +1897,9 @@ var import_node_assert10 = __toESM(require("node:assert"));
|
|
|
1827
1897
|
var import_simple_peer = __toESM(require("simple-peer"));
|
|
1828
1898
|
var import_async8 = require("@dxos/async");
|
|
1829
1899
|
var import_debug5 = require("@dxos/debug");
|
|
1900
|
+
var import_keys9 = require("@dxos/keys");
|
|
1830
1901
|
var import_log10 = require("@dxos/log");
|
|
1902
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
1831
1903
|
|
|
1832
1904
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
1833
1905
|
var wrtc = null;
|
|
@@ -1845,9 +1917,22 @@ var WebRTCTransport = class {
|
|
|
1845
1917
|
this.closed = new import_async8.Event();
|
|
1846
1918
|
this.connected = new import_async8.Event();
|
|
1847
1919
|
this.errors = new import_debug5.ErrorStream();
|
|
1920
|
+
this._instanceId = import_keys9.PublicKey.random().toHex();
|
|
1921
|
+
this._performance = {
|
|
1922
|
+
bytesSent: 0,
|
|
1923
|
+
bytesReceived: 0
|
|
1924
|
+
};
|
|
1925
|
+
import_log10.log.trace("dxos.mesh.webrtc-transport", import_protocols5.trace.begin({
|
|
1926
|
+
id: this._instanceId
|
|
1927
|
+
}), {
|
|
1928
|
+
file: "webrtc-transport.ts",
|
|
1929
|
+
line: 43,
|
|
1930
|
+
scope: this,
|
|
1931
|
+
callSite: (f, a) => f(...a)
|
|
1932
|
+
});
|
|
1848
1933
|
(0, import_log10.log)("created connection", params, {
|
|
1849
1934
|
file: "webrtc-transport.ts",
|
|
1850
|
-
line:
|
|
1935
|
+
line: 44,
|
|
1851
1936
|
scope: this,
|
|
1852
1937
|
callSite: (f, a) => f(...a)
|
|
1853
1938
|
});
|
|
@@ -1859,7 +1944,7 @@ var WebRTCTransport = class {
|
|
|
1859
1944
|
this._peer.on("signal", async (data) => {
|
|
1860
1945
|
(0, import_log10.log)("signal", data, {
|
|
1861
1946
|
file: "webrtc-transport.ts",
|
|
1862
|
-
line:
|
|
1947
|
+
line: 52,
|
|
1863
1948
|
scope: this,
|
|
1864
1949
|
callSite: (f, a) => f(...a)
|
|
1865
1950
|
});
|
|
@@ -1872,7 +1957,7 @@ var WebRTCTransport = class {
|
|
|
1872
1957
|
this._peer.on("connect", () => {
|
|
1873
1958
|
(0, import_log10.log)("connected", {}, {
|
|
1874
1959
|
file: "webrtc-transport.ts",
|
|
1875
|
-
line:
|
|
1960
|
+
line: 57,
|
|
1876
1961
|
scope: this,
|
|
1877
1962
|
callSite: (f, a) => f(...a)
|
|
1878
1963
|
});
|
|
@@ -1882,7 +1967,7 @@ var WebRTCTransport = class {
|
|
|
1882
1967
|
this._peer.on("close", async () => {
|
|
1883
1968
|
(0, import_log10.log)("closed", {}, {
|
|
1884
1969
|
file: "webrtc-transport.ts",
|
|
1885
|
-
line:
|
|
1970
|
+
line: 63,
|
|
1886
1971
|
scope: this,
|
|
1887
1972
|
callSite: (f, a) => f(...a)
|
|
1888
1973
|
});
|
|
@@ -1900,7 +1985,7 @@ var WebRTCTransport = class {
|
|
|
1900
1985
|
stats
|
|
1901
1986
|
}, {
|
|
1902
1987
|
file: "webrtc-transport.ts",
|
|
1903
|
-
line:
|
|
1988
|
+
line: 75,
|
|
1904
1989
|
scope: this,
|
|
1905
1990
|
callSite: (f, a) => f(...a)
|
|
1906
1991
|
});
|
|
@@ -1914,7 +1999,7 @@ var WebRTCTransport = class {
|
|
|
1914
1999
|
async destroy() {
|
|
1915
2000
|
(0, import_log10.log)("closing...", {}, {
|
|
1916
2001
|
file: "webrtc-transport.ts",
|
|
1917
|
-
line:
|
|
2002
|
+
line: 88,
|
|
1918
2003
|
scope: this,
|
|
1919
2004
|
callSite: (f, a) => f(...a)
|
|
1920
2005
|
});
|
|
@@ -1924,7 +2009,18 @@ var WebRTCTransport = class {
|
|
|
1924
2009
|
this.closed.emit();
|
|
1925
2010
|
(0, import_log10.log)("closed", {}, {
|
|
1926
2011
|
file: "webrtc-transport.ts",
|
|
1927
|
-
line:
|
|
2012
|
+
line: 93,
|
|
2013
|
+
scope: this,
|
|
2014
|
+
callSite: (f, a) => f(...a)
|
|
2015
|
+
});
|
|
2016
|
+
import_log10.log.trace("dxos.mesh.webrtc-transport", import_protocols5.trace.end({
|
|
2017
|
+
id: this._instanceId,
|
|
2018
|
+
data: {
|
|
2019
|
+
performance: this._performance
|
|
2020
|
+
}
|
|
2021
|
+
}), {
|
|
2022
|
+
file: "webrtc-transport.ts",
|
|
2023
|
+
line: 94,
|
|
1928
2024
|
scope: this,
|
|
1929
2025
|
callSite: (f, a) => f(...a)
|
|
1930
2026
|
});
|
|
@@ -1952,7 +2048,7 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
1952
2048
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
1953
2049
|
var import_node_stream2 = require("node:stream");
|
|
1954
2050
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
1955
|
-
var
|
|
2051
|
+
var import_keys10 = require("@dxos/keys");
|
|
1956
2052
|
var import_log11 = require("@dxos/log");
|
|
1957
2053
|
var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
1958
2054
|
var import_util7 = require("@dxos/util");
|
|
@@ -1960,7 +2056,7 @@ var WebRTCTransportService = class {
|
|
|
1960
2056
|
// prettier-ignore
|
|
1961
2057
|
constructor(_webrtcConfig) {
|
|
1962
2058
|
this._webrtcConfig = _webrtcConfig;
|
|
1963
|
-
this.transports = new import_util7.ComplexMap(
|
|
2059
|
+
this.transports = new import_util7.ComplexMap(import_keys10.PublicKey.hash);
|
|
1964
2060
|
}
|
|
1965
2061
|
open(request) {
|
|
1966
2062
|
const rpcStream = new import_codec_protobuf.Stream(({ ready, next, close }) => {
|
|
@@ -2051,14 +2147,14 @@ var import_node_assert12 = __toESM(require("node:assert"));
|
|
|
2051
2147
|
var import_async9 = require("@dxos/async");
|
|
2052
2148
|
var import_context2 = require("@dxos/context");
|
|
2053
2149
|
var import_debug6 = require("@dxos/debug");
|
|
2054
|
-
var
|
|
2150
|
+
var import_keys11 = require("@dxos/keys");
|
|
2055
2151
|
var import_log12 = require("@dxos/log");
|
|
2056
2152
|
var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
2057
2153
|
var WebRTCTransportProxy = class {
|
|
2058
2154
|
// prettier-ignore
|
|
2059
2155
|
constructor(_params) {
|
|
2060
2156
|
this._params = _params;
|
|
2061
|
-
this._proxyId =
|
|
2157
|
+
this._proxyId = import_keys11.PublicKey.random();
|
|
2062
2158
|
this._ctx = new import_context2.Context();
|
|
2063
2159
|
this.closed = new import_async9.Event();
|
|
2064
2160
|
this._closed = false;
|