@dxos/network-manager 0.1.55 → 0.1.56-main.09ca29d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-IBLQYMBY.mjs → chunk-FC6CWDES.mjs} +823 -294
- package/dist/lib/browser/chunk-FC6CWDES.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -2
- package/dist/lib/node/index.cjs +843 -312
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +772 -301
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/network-manager.d.ts +1 -1
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts +28 -0
- package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -0
- package/dist/types/src/swarm/connection-limiter.test.d.ts +2 -0
- package/dist/types/src/swarm/connection-limiter.test.d.ts.map +1 -0
- package/dist/types/src/swarm/connection.d.ts +1 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.test.d.ts +2 -0
- package/dist/types/src/swarm/connection.test.d.ts.map +1 -0
- package/dist/types/src/swarm/index.d.ts +1 -0
- package/dist/types/src/swarm/index.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +3 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts +3 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/topology/fully-connected-topology.d.ts.map +1 -1
- package/dist/types/src/topology/star-topology.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport-service.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/network-manager.ts +19 -6
- package/src/signal/swarm-messenger.ts +1 -2
- package/src/swarm/connection-limiter.test.ts +44 -0
- package/src/swarm/connection-limiter.ts +72 -0
- package/src/swarm/connection.test.ts +72 -0
- package/src/swarm/connection.ts +18 -5
- package/src/swarm/index.ts +1 -0
- package/src/swarm/peer.ts +46 -9
- package/src/swarm/swarm.test.ts +140 -90
- package/src/swarm/swarm.ts +4 -3
- package/src/topology/fully-connected-topology.ts +1 -2
- package/src/topology/mmst-topology.ts +1 -1
- package/src/topology/star-topology.ts +1 -2
- package/src/transport/memory-transport.ts +1 -1
- package/src/transport/webrtc-transport-proxy.ts +14 -12
- package/src/transport/webrtc-transport-service.ts +31 -8
- package/src/transport/webrtc-transport.ts +1 -1
- package/dist/lib/browser/chunk-IBLQYMBY.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -31,10 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Connection: () => Connection,
|
|
34
|
+
ConnectionLimiter: () => ConnectionLimiter,
|
|
34
35
|
ConnectionLog: () => ConnectionLog,
|
|
35
36
|
ConnectionState: () => ConnectionState,
|
|
36
37
|
EventType: () => EventType,
|
|
37
38
|
FullyConnectedTopology: () => FullyConnectedTopology,
|
|
39
|
+
MAX_CONCURRENT_INITIATING_CONNECTIONS: () => MAX_CONCURRENT_INITIATING_CONNECTIONS,
|
|
38
40
|
MMSTTopology: () => MMSTTopology,
|
|
39
41
|
MemoryTransport: () => MemoryTransport,
|
|
40
42
|
MemoryTransportFactory: () => MemoryTransportFactory,
|
|
@@ -53,17 +55,17 @@ __export(src_exports, {
|
|
|
53
55
|
module.exports = __toCommonJS(src_exports);
|
|
54
56
|
|
|
55
57
|
// packages/core/mesh/network-manager/src/connection-log.ts
|
|
56
|
-
var
|
|
58
|
+
var import_async6 = require("@dxos/async");
|
|
57
59
|
var import_debug3 = require("@dxos/debug");
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
+
var import_keys7 = require("@dxos/keys");
|
|
61
|
+
var import_util5 = require("@dxos/util");
|
|
60
62
|
|
|
61
63
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
62
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
63
64
|
var import_async = require("@dxos/async");
|
|
64
65
|
var import_context = require("@dxos/context");
|
|
65
66
|
var import_debug = require("@dxos/debug");
|
|
66
67
|
var import_errors = require("@dxos/errors");
|
|
68
|
+
var import_invariant = require("@dxos/invariant");
|
|
67
69
|
var import_keys = require("@dxos/keys");
|
|
68
70
|
var import_log = require("@dxos/log");
|
|
69
71
|
var import_protocols = require("@dxos/protocols");
|
|
@@ -77,7 +79,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
77
79
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
78
80
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
79
81
|
}
|
|
80
|
-
var __dxlog_file = "/
|
|
82
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
81
83
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
82
84
|
var MAX_SIGNALLING_DELAY = 300;
|
|
83
85
|
var ConnectionState;
|
|
@@ -135,6 +137,18 @@ var Connection = class {
|
|
|
135
137
|
await this._flushSignalBuffer();
|
|
136
138
|
});
|
|
137
139
|
this._signallingDelay = STARTING_SIGNALLING_DELAY;
|
|
140
|
+
import_log.log.trace("dxos.mesh.connection.construct", {
|
|
141
|
+
sessionId: this.sessionId,
|
|
142
|
+
topic: this.topic,
|
|
143
|
+
localPeerId: this.ownId,
|
|
144
|
+
remotePeerId: this.remoteId,
|
|
145
|
+
initiator: this.initiator
|
|
146
|
+
}, {
|
|
147
|
+
F: __dxlog_file,
|
|
148
|
+
L: 95,
|
|
149
|
+
S: this,
|
|
150
|
+
C: (f, a) => f(...a)
|
|
151
|
+
});
|
|
138
152
|
}
|
|
139
153
|
get state() {
|
|
140
154
|
return this._state;
|
|
@@ -148,14 +162,33 @@ var Connection = class {
|
|
|
148
162
|
/**
|
|
149
163
|
* Create an underlying transport and prepares it for the connection.
|
|
150
164
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
165
|
+
async openConnection() {
|
|
166
|
+
(0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
167
|
+
F: __dxlog_file,
|
|
168
|
+
L: 120,
|
|
169
|
+
S: this,
|
|
170
|
+
A: [
|
|
171
|
+
"this._state === ConnectionState.INITIAL",
|
|
172
|
+
"'Invalid state.'"
|
|
173
|
+
]
|
|
174
|
+
});
|
|
154
175
|
import_log.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.begin({
|
|
155
176
|
id: this._instanceId
|
|
156
177
|
}), {
|
|
157
178
|
F: __dxlog_file,
|
|
158
|
-
L:
|
|
179
|
+
L: 121,
|
|
180
|
+
S: this,
|
|
181
|
+
C: (f, a) => f(...a)
|
|
182
|
+
});
|
|
183
|
+
import_log.log.trace("dxos.mesh.connection.open", {
|
|
184
|
+
sessionId: this.sessionId,
|
|
185
|
+
topic: this.topic,
|
|
186
|
+
localPeerId: this.ownId,
|
|
187
|
+
remotePeerId: this.remoteId,
|
|
188
|
+
initiator: this.initiator
|
|
189
|
+
}, {
|
|
190
|
+
F: __dxlog_file,
|
|
191
|
+
L: 122,
|
|
159
192
|
S: this,
|
|
160
193
|
C: (f, a) => f(...a)
|
|
161
194
|
});
|
|
@@ -166,13 +199,21 @@ var Connection = class {
|
|
|
166
199
|
this._protocol.stream.on("close", () => {
|
|
167
200
|
(0, import_log.log)("protocol stream closed", void 0, {
|
|
168
201
|
F: __dxlog_file,
|
|
169
|
-
L:
|
|
202
|
+
L: 139,
|
|
170
203
|
S: this,
|
|
171
204
|
C: (f, a) => f(...a)
|
|
172
205
|
});
|
|
173
206
|
this.close().catch((err) => this.errors.raise(err));
|
|
174
207
|
});
|
|
175
|
-
(0,
|
|
208
|
+
(0, import_invariant.invariant)(!this._transport, void 0, {
|
|
209
|
+
F: __dxlog_file,
|
|
210
|
+
L: 143,
|
|
211
|
+
S: this,
|
|
212
|
+
A: [
|
|
213
|
+
"!this._transport",
|
|
214
|
+
""
|
|
215
|
+
]
|
|
216
|
+
});
|
|
176
217
|
this._transport = this._transportFactory.createTransport({
|
|
177
218
|
initiator: this.initiator,
|
|
178
219
|
stream: this._protocol.stream,
|
|
@@ -198,7 +239,7 @@ var Connection = class {
|
|
|
198
239
|
id: this._instanceId
|
|
199
240
|
}), {
|
|
200
241
|
F: __dxlog_file,
|
|
201
|
-
L:
|
|
242
|
+
L: 172,
|
|
202
243
|
S: this,
|
|
203
244
|
C: (f, a) => f(...a)
|
|
204
245
|
});
|
|
@@ -214,7 +255,7 @@ var Connection = class {
|
|
|
214
255
|
peerId: this.ownId
|
|
215
256
|
}, {
|
|
216
257
|
F: __dxlog_file,
|
|
217
|
-
L:
|
|
258
|
+
L: 184,
|
|
218
259
|
S: this,
|
|
219
260
|
C: (f, a) => f(...a)
|
|
220
261
|
});
|
|
@@ -223,7 +264,7 @@ var Connection = class {
|
|
|
223
264
|
} catch (err) {
|
|
224
265
|
import_log.log.catch(err, void 0, {
|
|
225
266
|
F: __dxlog_file,
|
|
226
|
-
L:
|
|
267
|
+
L: 190,
|
|
227
268
|
S: this,
|
|
228
269
|
C: (f, a) => f(...a)
|
|
229
270
|
});
|
|
@@ -233,7 +274,7 @@ var Connection = class {
|
|
|
233
274
|
} catch (err) {
|
|
234
275
|
import_log.log.catch(err, void 0, {
|
|
235
276
|
F: __dxlog_file,
|
|
236
|
-
L:
|
|
277
|
+
L: 197,
|
|
237
278
|
S: this,
|
|
238
279
|
C: (f, a) => f(...a)
|
|
239
280
|
});
|
|
@@ -242,7 +283,7 @@ var Connection = class {
|
|
|
242
283
|
peerId: this.ownId
|
|
243
284
|
}, {
|
|
244
285
|
F: __dxlog_file,
|
|
245
|
-
L:
|
|
286
|
+
L: 200,
|
|
246
287
|
S: this,
|
|
247
288
|
C: (f, a) => f(...a)
|
|
248
289
|
});
|
|
@@ -282,7 +323,7 @@ var Connection = class {
|
|
|
282
323
|
err
|
|
283
324
|
}, {
|
|
284
325
|
F: __dxlog_file,
|
|
285
|
-
L:
|
|
326
|
+
L: 234,
|
|
286
327
|
S: this,
|
|
287
328
|
C: (f, a) => f(...a)
|
|
288
329
|
});
|
|
@@ -294,19 +335,51 @@ var Connection = class {
|
|
|
294
335
|
*/
|
|
295
336
|
async signal(msg) {
|
|
296
337
|
var _a, _b, _c;
|
|
297
|
-
(0,
|
|
338
|
+
(0, import_invariant.invariant)(msg.sessionId, void 0, {
|
|
339
|
+
F: __dxlog_file,
|
|
340
|
+
L: 243,
|
|
341
|
+
S: this,
|
|
342
|
+
A: [
|
|
343
|
+
"msg.sessionId",
|
|
344
|
+
""
|
|
345
|
+
]
|
|
346
|
+
});
|
|
298
347
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
299
348
|
(0, import_log.log)("dropping signal for incorrect session id", void 0, {
|
|
300
349
|
F: __dxlog_file,
|
|
301
|
-
L:
|
|
350
|
+
L: 245,
|
|
302
351
|
S: this,
|
|
303
352
|
C: (f, a) => f(...a)
|
|
304
353
|
});
|
|
305
354
|
return;
|
|
306
355
|
}
|
|
307
|
-
(0,
|
|
308
|
-
|
|
309
|
-
|
|
356
|
+
(0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
357
|
+
F: __dxlog_file,
|
|
358
|
+
L: 248,
|
|
359
|
+
S: this,
|
|
360
|
+
A: [
|
|
361
|
+
"msg.data.signal || msg.data.signalBatch",
|
|
362
|
+
""
|
|
363
|
+
]
|
|
364
|
+
});
|
|
365
|
+
(0, import_invariant.invariant)((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId), void 0, {
|
|
366
|
+
F: __dxlog_file,
|
|
367
|
+
L: 249,
|
|
368
|
+
S: this,
|
|
369
|
+
A: [
|
|
370
|
+
"msg.author?.equals(this.remoteId)",
|
|
371
|
+
""
|
|
372
|
+
]
|
|
373
|
+
});
|
|
374
|
+
(0, import_invariant.invariant)((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId), void 0, {
|
|
375
|
+
F: __dxlog_file,
|
|
376
|
+
L: 250,
|
|
377
|
+
S: this,
|
|
378
|
+
A: [
|
|
379
|
+
"msg.recipient?.equals(this.ownId)",
|
|
380
|
+
""
|
|
381
|
+
]
|
|
382
|
+
});
|
|
310
383
|
const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
|
|
311
384
|
msg.data.signal
|
|
312
385
|
];
|
|
@@ -321,20 +394,28 @@ var Connection = class {
|
|
|
321
394
|
msg: msg.data
|
|
322
395
|
}, {
|
|
323
396
|
F: __dxlog_file,
|
|
324
|
-
L:
|
|
397
|
+
L: 259,
|
|
325
398
|
S: this,
|
|
326
399
|
C: (f, a) => f(...a)
|
|
327
400
|
});
|
|
328
401
|
this._incomingSignalBuffer.push(signal);
|
|
329
402
|
} else {
|
|
330
|
-
(0,
|
|
403
|
+
(0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
|
|
404
|
+
F: __dxlog_file,
|
|
405
|
+
L: 262,
|
|
406
|
+
S: this,
|
|
407
|
+
A: [
|
|
408
|
+
"this._transport",
|
|
409
|
+
"'Connection not ready to accept signals.'"
|
|
410
|
+
]
|
|
411
|
+
});
|
|
331
412
|
(0, import_log.log)("received signal", {
|
|
332
413
|
peerId: this.ownId,
|
|
333
414
|
remoteId: this.remoteId,
|
|
334
415
|
msg: msg.data
|
|
335
416
|
}, {
|
|
336
417
|
F: __dxlog_file,
|
|
337
|
-
L:
|
|
418
|
+
L: 263,
|
|
338
419
|
S: this,
|
|
339
420
|
C: (f, a) => f(...a)
|
|
340
421
|
});
|
|
@@ -349,11 +430,19 @@ var Connection = class {
|
|
|
349
430
|
peerId: this.ownId
|
|
350
431
|
}, {
|
|
351
432
|
F: __dxlog_file,
|
|
352
|
-
L:
|
|
433
|
+
L: 270,
|
|
353
434
|
S: this,
|
|
354
435
|
C: (f, a) => f(...a)
|
|
355
436
|
});
|
|
356
|
-
(0,
|
|
437
|
+
(0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
|
|
438
|
+
F: __dxlog_file,
|
|
439
|
+
L: 271,
|
|
440
|
+
S: this,
|
|
441
|
+
A: [
|
|
442
|
+
"state !== this._state",
|
|
443
|
+
"'Already in this state.'"
|
|
444
|
+
]
|
|
445
|
+
});
|
|
357
446
|
this._state = state;
|
|
358
447
|
this.stateChanged.emit(state);
|
|
359
448
|
}
|
|
@@ -363,23 +452,23 @@ _ts_decorate([
|
|
|
363
452
|
], Connection.prototype, "close", null);
|
|
364
453
|
|
|
365
454
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
366
|
-
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
367
455
|
var import_async3 = require("@dxos/async");
|
|
368
456
|
var import_context4 = require("@dxos/context");
|
|
369
457
|
var import_debug2 = require("@dxos/debug");
|
|
458
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
370
459
|
var import_keys4 = require("@dxos/keys");
|
|
371
460
|
var import_log4 = require("@dxos/log");
|
|
372
461
|
var import_protocols3 = require("@dxos/protocols");
|
|
373
462
|
var import_util2 = require("@dxos/util");
|
|
374
463
|
|
|
375
464
|
// packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
|
|
376
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
377
465
|
var import_context2 = require("@dxos/context");
|
|
466
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
378
467
|
var import_keys2 = require("@dxos/keys");
|
|
379
468
|
var import_log2 = require("@dxos/log");
|
|
380
469
|
var import_protocols2 = require("@dxos/protocols");
|
|
381
470
|
var import_util = require("@dxos/util");
|
|
382
|
-
var __dxlog_file2 = "/
|
|
471
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
383
472
|
var SwarmMessage = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
384
473
|
var SwarmMessenger = class {
|
|
385
474
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -405,7 +494,7 @@ var SwarmMessenger = class {
|
|
|
405
494
|
msg: message
|
|
406
495
|
}, {
|
|
407
496
|
F: __dxlog_file2,
|
|
408
|
-
L:
|
|
497
|
+
L: 69,
|
|
409
498
|
S: this,
|
|
410
499
|
C: (f, a) => f(...a)
|
|
411
500
|
});
|
|
@@ -434,7 +523,7 @@ var SwarmMessenger = class {
|
|
|
434
523
|
message
|
|
435
524
|
}, {
|
|
436
525
|
F: __dxlog_file2,
|
|
437
|
-
L:
|
|
526
|
+
L: 80,
|
|
438
527
|
S: this,
|
|
439
528
|
C: (f, a) => f(...a)
|
|
440
529
|
});
|
|
@@ -442,7 +531,15 @@ var SwarmMessenger = class {
|
|
|
442
531
|
}
|
|
443
532
|
async signal(message) {
|
|
444
533
|
var _a, _b;
|
|
445
|
-
(0,
|
|
534
|
+
(0, import_invariant2.invariant)(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message", {
|
|
535
|
+
F: __dxlog_file2,
|
|
536
|
+
L: 85,
|
|
537
|
+
S: this,
|
|
538
|
+
A: [
|
|
539
|
+
"message.data?.signal || message.data?.signalBatch",
|
|
540
|
+
"'Invalid message'"
|
|
541
|
+
]
|
|
542
|
+
});
|
|
446
543
|
await this._sendReliableMessage({
|
|
447
544
|
author: message.author,
|
|
448
545
|
recipient: message.recipient,
|
|
@@ -478,7 +575,7 @@ var SwarmMessenger = class {
|
|
|
478
575
|
msg: networkMessage
|
|
479
576
|
}, {
|
|
480
577
|
F: __dxlog_file2,
|
|
481
|
-
L:
|
|
578
|
+
L: 123,
|
|
482
579
|
S: this,
|
|
483
580
|
C: (f, a) => f(...a)
|
|
484
581
|
});
|
|
@@ -493,16 +590,32 @@ var SwarmMessenger = class {
|
|
|
493
590
|
}
|
|
494
591
|
async _resolveAnswers(message) {
|
|
495
592
|
var _a, _b, _c;
|
|
496
|
-
(0,
|
|
593
|
+
(0, import_invariant2.invariant)((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId", {
|
|
594
|
+
F: __dxlog_file2,
|
|
595
|
+
L: 135,
|
|
596
|
+
S: this,
|
|
597
|
+
A: [
|
|
598
|
+
"message.data?.answer?.offerMessageId",
|
|
599
|
+
"'No offerMessageId'"
|
|
600
|
+
]
|
|
601
|
+
});
|
|
497
602
|
const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
|
|
498
603
|
if (offerRecord) {
|
|
499
604
|
this._offerRecords.delete(message.data.answer.offerMessageId);
|
|
500
|
-
(0,
|
|
605
|
+
(0, import_invariant2.invariant)((_c = message.data) == null ? void 0 : _c.answer, "No answer", {
|
|
606
|
+
F: __dxlog_file2,
|
|
607
|
+
L: 139,
|
|
608
|
+
S: this,
|
|
609
|
+
A: [
|
|
610
|
+
"message.data?.answer",
|
|
611
|
+
"'No answer'"
|
|
612
|
+
]
|
|
613
|
+
});
|
|
501
614
|
(0, import_log2.log)("resolving", {
|
|
502
615
|
answer: message.data.answer
|
|
503
616
|
}, {
|
|
504
617
|
F: __dxlog_file2,
|
|
505
|
-
L:
|
|
618
|
+
L: 140,
|
|
506
619
|
S: this,
|
|
507
620
|
C: (f, a) => f(...a)
|
|
508
621
|
});
|
|
@@ -510,7 +623,15 @@ var SwarmMessenger = class {
|
|
|
510
623
|
}
|
|
511
624
|
}
|
|
512
625
|
async _handleOffer({ author, recipient, message }) {
|
|
513
|
-
(0,
|
|
626
|
+
(0, import_invariant2.invariant)(message.data.offer, "No offer", {
|
|
627
|
+
F: __dxlog_file2,
|
|
628
|
+
L: 154,
|
|
629
|
+
S: this,
|
|
630
|
+
A: [
|
|
631
|
+
"message.data.offer",
|
|
632
|
+
"'No offer'"
|
|
633
|
+
]
|
|
634
|
+
});
|
|
514
635
|
const offerMessage = {
|
|
515
636
|
author,
|
|
516
637
|
recipient,
|
|
@@ -538,15 +659,31 @@ var SwarmMessenger = class {
|
|
|
538
659
|
err
|
|
539
660
|
}, {
|
|
540
661
|
F: __dxlog_file2,
|
|
541
|
-
L:
|
|
662
|
+
L: 174,
|
|
542
663
|
S: this,
|
|
543
664
|
C: (f, a) => f(...a)
|
|
544
665
|
});
|
|
545
666
|
}
|
|
546
667
|
}
|
|
547
668
|
async _handleSignal({ author, recipient, message }) {
|
|
548
|
-
(0,
|
|
549
|
-
|
|
669
|
+
(0, import_invariant2.invariant)(message.messageId, void 0, {
|
|
670
|
+
F: __dxlog_file2,
|
|
671
|
+
L: 187,
|
|
672
|
+
S: this,
|
|
673
|
+
A: [
|
|
674
|
+
"message.messageId",
|
|
675
|
+
""
|
|
676
|
+
]
|
|
677
|
+
});
|
|
678
|
+
(0, import_invariant2.invariant)(message.data.signal || message.data.signalBatch, "Invalid message", {
|
|
679
|
+
F: __dxlog_file2,
|
|
680
|
+
L: 188,
|
|
681
|
+
S: this,
|
|
682
|
+
A: [
|
|
683
|
+
"message.data.signal || message.data.signalBatch",
|
|
684
|
+
"'Invalid message'"
|
|
685
|
+
]
|
|
686
|
+
});
|
|
550
687
|
const signalMessage = {
|
|
551
688
|
author,
|
|
552
689
|
recipient,
|
|
@@ -561,9 +698,10 @@ var SwarmMessenger = class {
|
|
|
561
698
|
};
|
|
562
699
|
|
|
563
700
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
564
|
-
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
565
701
|
var import_async2 = require("@dxos/async");
|
|
566
702
|
var import_context3 = require("@dxos/context");
|
|
703
|
+
var import_errors2 = require("@dxos/errors");
|
|
704
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
567
705
|
var import_keys3 = require("@dxos/keys");
|
|
568
706
|
var import_log3 = require("@dxos/log");
|
|
569
707
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
@@ -576,16 +714,17 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
576
714
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
577
715
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
578
716
|
}
|
|
579
|
-
var __dxlog_file3 = "/
|
|
717
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
580
718
|
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
581
719
|
var Peer = class {
|
|
582
|
-
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _callbacks) {
|
|
720
|
+
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
583
721
|
this.id = id;
|
|
584
722
|
this.topic = topic;
|
|
585
723
|
this.localPeerId = localPeerId;
|
|
586
724
|
this._signalMessaging = _signalMessaging;
|
|
587
725
|
this._protocolProvider = _protocolProvider;
|
|
588
726
|
this._transportFactory = _transportFactory;
|
|
727
|
+
this._connectionLimiter = _connectionLimiter;
|
|
589
728
|
this._callbacks = _callbacks;
|
|
590
729
|
this._availableAfter = 0;
|
|
591
730
|
this.availableToConnect = true;
|
|
@@ -597,16 +736,18 @@ var Peer = class {
|
|
|
597
736
|
* Respond to remote offer.
|
|
598
737
|
*/
|
|
599
738
|
async onOffer(message) {
|
|
739
|
+
var _a;
|
|
600
740
|
const remoteId = message.author;
|
|
601
741
|
if (this.connection || this.initiating) {
|
|
602
742
|
if (remoteId.toHex() < this.localPeerId.toHex()) {
|
|
603
|
-
(0, import_log3.log)("
|
|
604
|
-
|
|
743
|
+
(0, import_log3.log)("close local connection", {
|
|
744
|
+
localPeerId: this.id,
|
|
605
745
|
topic: this.topic,
|
|
606
|
-
|
|
746
|
+
remotePeerId: this.localPeerId,
|
|
747
|
+
sessionId: (_a = this.connection) == null ? void 0 : _a.sessionId
|
|
607
748
|
}, {
|
|
608
749
|
F: __dxlog_file3,
|
|
609
|
-
L:
|
|
750
|
+
L: 106,
|
|
610
751
|
S: this,
|
|
611
752
|
C: (f, a) => f(...a)
|
|
612
753
|
});
|
|
@@ -621,22 +762,33 @@ var Peer = class {
|
|
|
621
762
|
}
|
|
622
763
|
if (await this._callbacks.onOffer(remoteId)) {
|
|
623
764
|
if (!this.connection) {
|
|
624
|
-
(0,
|
|
765
|
+
(0, import_invariant3.invariant)(message.sessionId, void 0, {
|
|
766
|
+
F: __dxlog_file3,
|
|
767
|
+
L: 126,
|
|
768
|
+
S: this,
|
|
769
|
+
A: [
|
|
770
|
+
"message.sessionId",
|
|
771
|
+
""
|
|
772
|
+
]
|
|
773
|
+
});
|
|
625
774
|
const connection = this._createConnection(false, message.sessionId);
|
|
626
775
|
try {
|
|
627
|
-
|
|
776
|
+
await this._connectionLimiter.connecting(message.sessionId);
|
|
777
|
+
await connection.openConnection();
|
|
628
778
|
} catch (err) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
779
|
+
if (!(err instanceof import_errors2.CancelledError)) {
|
|
780
|
+
import_log3.log.warn("connection error", {
|
|
781
|
+
topic: this.topic,
|
|
782
|
+
peerId: this.localPeerId,
|
|
783
|
+
remoteId: this.id,
|
|
784
|
+
err
|
|
785
|
+
}, {
|
|
786
|
+
F: __dxlog_file3,
|
|
787
|
+
L: 134,
|
|
788
|
+
S: this,
|
|
789
|
+
C: (f, a) => f(...a)
|
|
790
|
+
});
|
|
791
|
+
}
|
|
640
792
|
await this.closeConnection();
|
|
641
793
|
}
|
|
642
794
|
return {
|
|
@@ -652,8 +804,24 @@ var Peer = class {
|
|
|
652
804
|
* Initiate a connection to the remote peer.
|
|
653
805
|
*/
|
|
654
806
|
async initiateConnection() {
|
|
655
|
-
(0,
|
|
656
|
-
|
|
807
|
+
(0, import_invariant3.invariant)(!this.initiating, "Initiation in progress.", {
|
|
808
|
+
F: __dxlog_file3,
|
|
809
|
+
L: 151,
|
|
810
|
+
S: this,
|
|
811
|
+
A: [
|
|
812
|
+
"!this.initiating",
|
|
813
|
+
"'Initiation in progress.'"
|
|
814
|
+
]
|
|
815
|
+
});
|
|
816
|
+
(0, import_invariant3.invariant)(!this.connection, "Already connected.", {
|
|
817
|
+
F: __dxlog_file3,
|
|
818
|
+
L: 152,
|
|
819
|
+
S: this,
|
|
820
|
+
A: [
|
|
821
|
+
"!this.connection",
|
|
822
|
+
"'Already connected.'"
|
|
823
|
+
]
|
|
824
|
+
});
|
|
657
825
|
const sessionId = import_keys3.PublicKey.random();
|
|
658
826
|
(0, import_log3.log)("initiating...", {
|
|
659
827
|
id: this.id,
|
|
@@ -662,13 +830,14 @@ var Peer = class {
|
|
|
662
830
|
sessionId
|
|
663
831
|
}, {
|
|
664
832
|
F: __dxlog_file3,
|
|
665
|
-
L:
|
|
833
|
+
L: 154,
|
|
666
834
|
S: this,
|
|
667
835
|
C: (f, a) => f(...a)
|
|
668
836
|
});
|
|
669
837
|
const connection = this._createConnection(true, sessionId);
|
|
670
838
|
this.initiating = true;
|
|
671
839
|
try {
|
|
840
|
+
await this._connectionLimiter.connecting(sessionId);
|
|
672
841
|
const answer = await this._signalMessaging.offer({
|
|
673
842
|
author: this.localPeerId,
|
|
674
843
|
recipient: this.id,
|
|
@@ -685,14 +854,14 @@ var Peer = class {
|
|
|
685
854
|
remoteId: this.id
|
|
686
855
|
}, {
|
|
687
856
|
F: __dxlog_file3,
|
|
688
|
-
L:
|
|
857
|
+
L: 169,
|
|
689
858
|
S: this,
|
|
690
859
|
C: (f, a) => f(...a)
|
|
691
860
|
});
|
|
692
861
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
693
862
|
(0, import_log3.log)("ignoring response", void 0, {
|
|
694
863
|
F: __dxlog_file3,
|
|
695
|
-
L:
|
|
864
|
+
L: 171,
|
|
696
865
|
S: this,
|
|
697
866
|
C: (f, a) => f(...a)
|
|
698
867
|
});
|
|
@@ -702,7 +871,7 @@ var Peer = class {
|
|
|
702
871
|
this._callbacks.onRejected();
|
|
703
872
|
return;
|
|
704
873
|
}
|
|
705
|
-
connection.openConnection();
|
|
874
|
+
await connection.openConnection();
|
|
706
875
|
this._callbacks.onAccepted();
|
|
707
876
|
} catch (err) {
|
|
708
877
|
(0, import_log3.log)("initiation error", {
|
|
@@ -712,7 +881,7 @@ var Peer = class {
|
|
|
712
881
|
remoteId: this.id
|
|
713
882
|
}, {
|
|
714
883
|
F: __dxlog_file3,
|
|
715
|
-
L:
|
|
884
|
+
L: 182,
|
|
716
885
|
S: this,
|
|
717
886
|
C: (f, a) => f(...a)
|
|
718
887
|
});
|
|
@@ -736,11 +905,19 @@ var Peer = class {
|
|
|
736
905
|
sessionId
|
|
737
906
|
}, {
|
|
738
907
|
F: __dxlog_file3,
|
|
739
|
-
L:
|
|
908
|
+
L: 196,
|
|
740
909
|
S: this,
|
|
741
910
|
C: (f, a) => f(...a)
|
|
742
911
|
});
|
|
743
|
-
(0,
|
|
912
|
+
(0, import_invariant3.invariant)(!this.connection, "Already connected.", {
|
|
913
|
+
F: __dxlog_file3,
|
|
914
|
+
L: 203,
|
|
915
|
+
S: this,
|
|
916
|
+
A: [
|
|
917
|
+
"!this.connection",
|
|
918
|
+
"'Already connected.'"
|
|
919
|
+
]
|
|
920
|
+
});
|
|
744
921
|
const connection = new Connection(
|
|
745
922
|
this.topic,
|
|
746
923
|
this.localPeerId,
|
|
@@ -766,6 +943,19 @@ var Peer = class {
|
|
|
766
943
|
this.availableToConnect = true;
|
|
767
944
|
this._lastConnectionTime = Date.now();
|
|
768
945
|
this._callbacks.onConnected();
|
|
946
|
+
this._connectionLimiter.doneConnecting(sessionId);
|
|
947
|
+
import_log3.log.trace("dxos.mesh.connection.connected", {
|
|
948
|
+
topic: this.topic,
|
|
949
|
+
localPeerId: this.localPeerId,
|
|
950
|
+
remotePeerId: this.id,
|
|
951
|
+
sessionId,
|
|
952
|
+
initiator
|
|
953
|
+
}, {
|
|
954
|
+
F: __dxlog_file3,
|
|
955
|
+
L: 229,
|
|
956
|
+
S: this,
|
|
957
|
+
C: (f, a) => f(...a)
|
|
958
|
+
});
|
|
769
959
|
break;
|
|
770
960
|
}
|
|
771
961
|
case ConnectionState.CLOSED: {
|
|
@@ -776,11 +966,31 @@ var Peer = class {
|
|
|
776
966
|
initiator
|
|
777
967
|
}, {
|
|
778
968
|
F: __dxlog_file3,
|
|
779
|
-
L:
|
|
969
|
+
L: 240,
|
|
970
|
+
S: this,
|
|
971
|
+
C: (f, a) => f(...a)
|
|
972
|
+
});
|
|
973
|
+
(0, import_invariant3.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
|
|
974
|
+
F: __dxlog_file3,
|
|
975
|
+
L: 241,
|
|
976
|
+
S: this,
|
|
977
|
+
A: [
|
|
978
|
+
"this.connection === connection",
|
|
979
|
+
"'Connection mismatch (race condition).'"
|
|
980
|
+
]
|
|
981
|
+
});
|
|
982
|
+
import_log3.log.trace("dxos.mesh.connection.closed", {
|
|
983
|
+
topic: this.topic,
|
|
984
|
+
localPeerId: this.localPeerId,
|
|
985
|
+
remotePeerId: this.id,
|
|
986
|
+
sessionId,
|
|
987
|
+
initiator
|
|
988
|
+
}, {
|
|
989
|
+
F: __dxlog_file3,
|
|
990
|
+
L: 243,
|
|
780
991
|
S: this,
|
|
781
992
|
C: (f, a) => f(...a)
|
|
782
993
|
});
|
|
783
|
-
(0, import_tiny_invariant3.default)(this.connection === connection, "Connection mismatch (race condition).");
|
|
784
994
|
if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
|
|
785
995
|
this._availableAfter = 0;
|
|
786
996
|
} else {
|
|
@@ -789,6 +999,7 @@ var Peer = class {
|
|
|
789
999
|
}
|
|
790
1000
|
this.connection = void 0;
|
|
791
1001
|
this._callbacks.onDisconnected();
|
|
1002
|
+
this._connectionLimiter.doneConnecting(sessionId);
|
|
792
1003
|
(0, import_async2.scheduleTask)(this._connectionCtx, () => {
|
|
793
1004
|
this.availableToConnect = true;
|
|
794
1005
|
this._callbacks.onPeerAvailable();
|
|
@@ -806,7 +1017,20 @@ var Peer = class {
|
|
|
806
1017
|
err
|
|
807
1018
|
}, {
|
|
808
1019
|
F: __dxlog_file3,
|
|
809
|
-
L:
|
|
1020
|
+
L: 277,
|
|
1021
|
+
S: this,
|
|
1022
|
+
C: (f, a) => f(...a)
|
|
1023
|
+
});
|
|
1024
|
+
import_log3.log.trace("dxos.mesh.connection.error", {
|
|
1025
|
+
topic: this.topic,
|
|
1026
|
+
localPeerId: this.localPeerId,
|
|
1027
|
+
remotePeerId: this.id,
|
|
1028
|
+
sessionId,
|
|
1029
|
+
initiator,
|
|
1030
|
+
err
|
|
1031
|
+
}, {
|
|
1032
|
+
F: __dxlog_file3,
|
|
1033
|
+
L: 278,
|
|
810
1034
|
S: this,
|
|
811
1035
|
C: (f, a) => f(...a)
|
|
812
1036
|
});
|
|
@@ -825,7 +1049,7 @@ var Peer = class {
|
|
|
825
1049
|
sessionId: connection.sessionId
|
|
826
1050
|
}, {
|
|
827
1051
|
F: __dxlog_file3,
|
|
828
|
-
L:
|
|
1052
|
+
L: 301,
|
|
829
1053
|
S: this,
|
|
830
1054
|
C: (f, a) => f(...a)
|
|
831
1055
|
});
|
|
@@ -835,7 +1059,7 @@ var Peer = class {
|
|
|
835
1059
|
sessionId: connection.sessionId
|
|
836
1060
|
}, {
|
|
837
1061
|
F: __dxlog_file3,
|
|
838
|
-
L:
|
|
1062
|
+
L: 307,
|
|
839
1063
|
S: this,
|
|
840
1064
|
C: (f, a) => f(...a)
|
|
841
1065
|
});
|
|
@@ -846,7 +1070,7 @@ var Peer = class {
|
|
|
846
1070
|
message
|
|
847
1071
|
}, {
|
|
848
1072
|
F: __dxlog_file3,
|
|
849
|
-
L:
|
|
1073
|
+
L: 312,
|
|
850
1074
|
S: this,
|
|
851
1075
|
C: (f, a) => f(...a)
|
|
852
1076
|
});
|
|
@@ -862,7 +1086,7 @@ var Peer = class {
|
|
|
862
1086
|
topic: this.topic
|
|
863
1087
|
}, {
|
|
864
1088
|
F: __dxlog_file3,
|
|
865
|
-
L:
|
|
1089
|
+
L: 322,
|
|
866
1090
|
S: this,
|
|
867
1091
|
C: (f, a) => f(...a)
|
|
868
1092
|
});
|
|
@@ -896,13 +1120,13 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
896
1120
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
897
1121
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
898
1122
|
}
|
|
899
|
-
var __dxlog_file4 = "/
|
|
1123
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
900
1124
|
var INITIATION_DELAY = 100;
|
|
901
1125
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
902
1126
|
var Swarm = class {
|
|
903
1127
|
// TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
|
|
904
1128
|
// TODO(burdon): Split up properties.
|
|
905
|
-
constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label) {
|
|
1129
|
+
constructor(_topic, _ownPeerId, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter) {
|
|
906
1130
|
this._topic = _topic;
|
|
907
1131
|
this._ownPeerId = _ownPeerId;
|
|
908
1132
|
this._topology = _topology;
|
|
@@ -910,6 +1134,7 @@ var Swarm = class {
|
|
|
910
1134
|
this._messenger = _messenger;
|
|
911
1135
|
this._transportFactory = _transportFactory;
|
|
912
1136
|
this._label = _label;
|
|
1137
|
+
this._connectionLimiter = _connectionLimiter;
|
|
913
1138
|
this._peers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
|
|
914
1139
|
this._ctx = new import_context4.Context();
|
|
915
1140
|
this._listeningHandle = void 0;
|
|
@@ -926,7 +1151,7 @@ var Swarm = class {
|
|
|
926
1151
|
}
|
|
927
1152
|
}), {
|
|
928
1153
|
F: __dxlog_file4,
|
|
929
|
-
L:
|
|
1154
|
+
L: 87,
|
|
930
1155
|
S: this,
|
|
931
1156
|
C: (f, a) => f(...a)
|
|
932
1157
|
});
|
|
@@ -934,7 +1159,7 @@ var Swarm = class {
|
|
|
934
1159
|
peerId: _ownPeerId
|
|
935
1160
|
}, {
|
|
936
1161
|
F: __dxlog_file4,
|
|
937
|
-
L:
|
|
1162
|
+
L: 91,
|
|
938
1163
|
S: this,
|
|
939
1164
|
C: (f, a) => f(...a)
|
|
940
1165
|
});
|
|
@@ -949,7 +1174,7 @@ var Swarm = class {
|
|
|
949
1174
|
id: this._instanceId
|
|
950
1175
|
}), {
|
|
951
1176
|
F: __dxlog_file4,
|
|
952
|
-
L:
|
|
1177
|
+
L: 100,
|
|
953
1178
|
S: this,
|
|
954
1179
|
C: (f, a) => f(...a)
|
|
955
1180
|
});
|
|
@@ -970,7 +1195,15 @@ var Swarm = class {
|
|
|
970
1195
|
return this._topic;
|
|
971
1196
|
}
|
|
972
1197
|
async open() {
|
|
973
|
-
(0,
|
|
1198
|
+
(0, import_invariant4.invariant)(!this._listeningHandle, void 0, {
|
|
1199
|
+
F: __dxlog_file4,
|
|
1200
|
+
L: 127,
|
|
1201
|
+
S: this,
|
|
1202
|
+
A: [
|
|
1203
|
+
"!this._listeningHandle",
|
|
1204
|
+
""
|
|
1205
|
+
]
|
|
1206
|
+
});
|
|
974
1207
|
this._listeningHandle = await this._messenger.listen({
|
|
975
1208
|
peerId: this._ownPeerId,
|
|
976
1209
|
payloadType: "dxos.mesh.swarm.SwarmMessage",
|
|
@@ -979,7 +1212,7 @@ var Swarm = class {
|
|
|
979
1212
|
err
|
|
980
1213
|
}, {
|
|
981
1214
|
F: __dxlog_file4,
|
|
982
|
-
L:
|
|
1215
|
+
L: 134,
|
|
983
1216
|
S: this,
|
|
984
1217
|
C: (f, a) => f(...a)
|
|
985
1218
|
}));
|
|
@@ -990,7 +1223,7 @@ var Swarm = class {
|
|
|
990
1223
|
var _a;
|
|
991
1224
|
(0, import_log4.log)("destroying...", void 0, {
|
|
992
1225
|
F: __dxlog_file4,
|
|
993
|
-
L:
|
|
1226
|
+
L: 140,
|
|
994
1227
|
S: this,
|
|
995
1228
|
C: (f, a) => f(...a)
|
|
996
1229
|
});
|
|
@@ -1001,13 +1234,21 @@ var Swarm = class {
|
|
|
1001
1234
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
1002
1235
|
(0, import_log4.log)("destroyed", void 0, {
|
|
1003
1236
|
F: __dxlog_file4,
|
|
1004
|
-
L:
|
|
1237
|
+
L: 147,
|
|
1005
1238
|
S: this,
|
|
1006
1239
|
C: (f, a) => f(...a)
|
|
1007
1240
|
});
|
|
1008
1241
|
}
|
|
1009
1242
|
async setTopology(topology) {
|
|
1010
|
-
(0,
|
|
1243
|
+
(0, import_invariant4.invariant)(!this._ctx.disposed, "Swarm is offline", {
|
|
1244
|
+
F: __dxlog_file4,
|
|
1245
|
+
L: 151,
|
|
1246
|
+
S: this,
|
|
1247
|
+
A: [
|
|
1248
|
+
"!this._ctx.disposed",
|
|
1249
|
+
"'Swarm is offline'"
|
|
1250
|
+
]
|
|
1251
|
+
});
|
|
1011
1252
|
if (topology === this._topology) {
|
|
1012
1253
|
return;
|
|
1013
1254
|
}
|
|
@@ -1016,7 +1257,7 @@ var Swarm = class {
|
|
|
1016
1257
|
topology: getClassName(topology)
|
|
1017
1258
|
}, {
|
|
1018
1259
|
F: __dxlog_file4,
|
|
1019
|
-
L:
|
|
1260
|
+
L: 155,
|
|
1020
1261
|
S: this,
|
|
1021
1262
|
C: (f, a) => f(...a)
|
|
1022
1263
|
});
|
|
@@ -1031,14 +1272,14 @@ var Swarm = class {
|
|
|
1031
1272
|
swarmEvent
|
|
1032
1273
|
}, {
|
|
1033
1274
|
F: __dxlog_file4,
|
|
1034
|
-
L:
|
|
1275
|
+
L: 168,
|
|
1035
1276
|
S: this,
|
|
1036
1277
|
C: (f, a) => f(...a)
|
|
1037
1278
|
});
|
|
1038
1279
|
if (this._ctx.disposed) {
|
|
1039
1280
|
(0, import_log4.log)("swarm event ignored for disposed swarm", void 0, {
|
|
1040
1281
|
F: __dxlog_file4,
|
|
1041
|
-
L:
|
|
1282
|
+
L: 171,
|
|
1042
1283
|
S: this,
|
|
1043
1284
|
C: (f, a) => f(...a)
|
|
1044
1285
|
});
|
|
@@ -1050,7 +1291,7 @@ var Swarm = class {
|
|
|
1050
1291
|
peerId
|
|
1051
1292
|
}, {
|
|
1052
1293
|
F: __dxlog_file4,
|
|
1053
|
-
L:
|
|
1294
|
+
L: 177,
|
|
1054
1295
|
S: this,
|
|
1055
1296
|
C: (f, a) => f(...a)
|
|
1056
1297
|
});
|
|
@@ -1065,7 +1306,7 @@ var Swarm = class {
|
|
|
1065
1306
|
if (((_a = peer.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
|
|
1066
1307
|
void this._destroyPeer(peer.id).catch((err) => import_log4.log.catch(err, void 0, {
|
|
1067
1308
|
F: __dxlog_file4,
|
|
1068
|
-
L:
|
|
1309
|
+
L: 188,
|
|
1069
1310
|
S: this,
|
|
1070
1311
|
C: (f, a) => f(...a)
|
|
1071
1312
|
}));
|
|
@@ -1080,14 +1321,14 @@ var Swarm = class {
|
|
|
1080
1321
|
message
|
|
1081
1322
|
}, {
|
|
1082
1323
|
F: __dxlog_file4,
|
|
1083
|
-
L:
|
|
1324
|
+
L: 198,
|
|
1084
1325
|
S: this,
|
|
1085
1326
|
C: (f, a) => f(...a)
|
|
1086
1327
|
});
|
|
1087
1328
|
if (this._ctx.disposed) {
|
|
1088
1329
|
(0, import_log4.log)("ignored for disposed swarm", void 0, {
|
|
1089
1330
|
F: __dxlog_file4,
|
|
1090
|
-
L:
|
|
1331
|
+
L: 200,
|
|
1091
1332
|
S: this,
|
|
1092
1333
|
C: (f, a) => f(...a)
|
|
1093
1334
|
});
|
|
@@ -1095,13 +1336,21 @@ var Swarm = class {
|
|
|
1095
1336
|
accept: false
|
|
1096
1337
|
};
|
|
1097
1338
|
}
|
|
1098
|
-
(0,
|
|
1339
|
+
(0, import_invariant4.invariant)(message.author, void 0, {
|
|
1340
|
+
F: __dxlog_file4,
|
|
1341
|
+
L: 205,
|
|
1342
|
+
S: this,
|
|
1343
|
+
A: [
|
|
1344
|
+
"message.author",
|
|
1345
|
+
""
|
|
1346
|
+
]
|
|
1347
|
+
});
|
|
1099
1348
|
if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
|
|
1100
1349
|
(0, import_log4.log)("rejecting offer with incorrect peerId", {
|
|
1101
1350
|
message
|
|
1102
1351
|
}, {
|
|
1103
1352
|
F: __dxlog_file4,
|
|
1104
|
-
L:
|
|
1353
|
+
L: 207,
|
|
1105
1354
|
S: this,
|
|
1106
1355
|
C: (f, a) => f(...a)
|
|
1107
1356
|
});
|
|
@@ -1114,7 +1363,7 @@ var Swarm = class {
|
|
|
1114
1363
|
message
|
|
1115
1364
|
}, {
|
|
1116
1365
|
F: __dxlog_file4,
|
|
1117
|
-
L:
|
|
1366
|
+
L: 211,
|
|
1118
1367
|
S: this,
|
|
1119
1368
|
C: (f, a) => f(...a)
|
|
1120
1369
|
});
|
|
@@ -1146,9 +1395,33 @@ var Swarm = class {
|
|
|
1146
1395
|
});
|
|
1147
1396
|
return;
|
|
1148
1397
|
}
|
|
1149
|
-
(0,
|
|
1150
|
-
|
|
1151
|
-
|
|
1398
|
+
(0, import_invariant4.invariant)((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
|
|
1399
|
+
F: __dxlog_file4,
|
|
1400
|
+
L: 227,
|
|
1401
|
+
S: this,
|
|
1402
|
+
A: [
|
|
1403
|
+
"message.recipient?.equals(this._ownPeerId)",
|
|
1404
|
+
"`Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`"
|
|
1405
|
+
]
|
|
1406
|
+
});
|
|
1407
|
+
(0, import_invariant4.invariant)((_b = message.topic) == null ? void 0 : _b.equals(this._topic), void 0, {
|
|
1408
|
+
F: __dxlog_file4,
|
|
1409
|
+
L: 231,
|
|
1410
|
+
S: this,
|
|
1411
|
+
A: [
|
|
1412
|
+
"message.topic?.equals(this._topic)",
|
|
1413
|
+
""
|
|
1414
|
+
]
|
|
1415
|
+
});
|
|
1416
|
+
(0, import_invariant4.invariant)(message.author, void 0, {
|
|
1417
|
+
F: __dxlog_file4,
|
|
1418
|
+
L: 232,
|
|
1419
|
+
S: this,
|
|
1420
|
+
A: [
|
|
1421
|
+
"message.author",
|
|
1422
|
+
""
|
|
1423
|
+
]
|
|
1424
|
+
});
|
|
1152
1425
|
const peer = this._getOrCreatePeer(message.author);
|
|
1153
1426
|
await peer.onSignal(message);
|
|
1154
1427
|
}
|
|
@@ -1166,7 +1439,7 @@ var Swarm = class {
|
|
|
1166
1439
|
_getOrCreatePeer(peerId) {
|
|
1167
1440
|
let peer = this._peers.get(peerId);
|
|
1168
1441
|
if (!peer) {
|
|
1169
|
-
peer = new Peer(peerId, this._topic, this._ownPeerId, this._swarmMessenger, this._protocolProvider, this._transportFactory, {
|
|
1442
|
+
peer = new Peer(peerId, this._topic, this._ownPeerId, this._swarmMessenger, this._protocolProvider, this._transportFactory, this._connectionLimiter, {
|
|
1170
1443
|
onInitiated: (connection) => {
|
|
1171
1444
|
this.connectionAdded.emit(connection);
|
|
1172
1445
|
},
|
|
@@ -1200,7 +1473,15 @@ var Swarm = class {
|
|
|
1200
1473
|
return peer;
|
|
1201
1474
|
}
|
|
1202
1475
|
async _destroyPeer(peerId) {
|
|
1203
|
-
(0,
|
|
1476
|
+
(0, import_invariant4.invariant)(this._peers.has(peerId), void 0, {
|
|
1477
|
+
F: __dxlog_file4,
|
|
1478
|
+
L: 302,
|
|
1479
|
+
S: this,
|
|
1480
|
+
A: [
|
|
1481
|
+
"this._peers.has(peerId)",
|
|
1482
|
+
""
|
|
1483
|
+
]
|
|
1484
|
+
});
|
|
1204
1485
|
await this._peers.get(peerId).destroy();
|
|
1205
1486
|
this._peers.delete(peerId);
|
|
1206
1487
|
}
|
|
@@ -1221,7 +1502,7 @@ var Swarm = class {
|
|
|
1221
1502
|
} catch (err) {
|
|
1222
1503
|
(0, import_log4.log)("initiation error", err, {
|
|
1223
1504
|
F: __dxlog_file4,
|
|
1224
|
-
L:
|
|
1505
|
+
L: 328,
|
|
1225
1506
|
S: this,
|
|
1226
1507
|
C: (f, a) => f(...a)
|
|
1227
1508
|
});
|
|
@@ -1249,7 +1530,7 @@ var Swarm = class {
|
|
|
1249
1530
|
remoteId
|
|
1250
1531
|
}, {
|
|
1251
1532
|
F: __dxlog_file4,
|
|
1252
|
-
L:
|
|
1533
|
+
L: 355,
|
|
1253
1534
|
S: this,
|
|
1254
1535
|
C: (f, a) => f(...a)
|
|
1255
1536
|
});
|
|
@@ -1266,7 +1547,7 @@ var Swarm = class {
|
|
|
1266
1547
|
remoteId
|
|
1267
1548
|
}, {
|
|
1268
1549
|
F: __dxlog_file4,
|
|
1269
|
-
L:
|
|
1550
|
+
L: 369,
|
|
1270
1551
|
S: this,
|
|
1271
1552
|
C: (f, a) => f(...a)
|
|
1272
1553
|
});
|
|
@@ -1276,7 +1557,7 @@ var Swarm = class {
|
|
|
1276
1557
|
remoteId
|
|
1277
1558
|
}, {
|
|
1278
1559
|
F: __dxlog_file4,
|
|
1279
|
-
L:
|
|
1560
|
+
L: 372,
|
|
1280
1561
|
S: this,
|
|
1281
1562
|
C: (f, a) => f(...a)
|
|
1282
1563
|
});
|
|
@@ -1304,9 +1585,6 @@ _ts_decorate3([
|
|
|
1304
1585
|
_ts_decorate3([
|
|
1305
1586
|
import_async3.synchronized
|
|
1306
1587
|
], Swarm.prototype, "onOffer", null);
|
|
1307
|
-
_ts_decorate3([
|
|
1308
|
-
import_async3.synchronized
|
|
1309
|
-
], Swarm.prototype, "onSignal", null);
|
|
1310
1588
|
_ts_decorate3([
|
|
1311
1589
|
import_async3.synchronized
|
|
1312
1590
|
], Swarm.prototype, "goOffline", null);
|
|
@@ -1319,7 +1597,7 @@ var import_async4 = require("@dxos/async");
|
|
|
1319
1597
|
var import_keys5 = require("@dxos/keys");
|
|
1320
1598
|
var import_log5 = require("@dxos/log");
|
|
1321
1599
|
var import_util3 = require("@dxos/util");
|
|
1322
|
-
var __dxlog_file5 = "/
|
|
1600
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1323
1601
|
var SwarmMapper = class {
|
|
1324
1602
|
get peers() {
|
|
1325
1603
|
return Array.from(this._peers.values());
|
|
@@ -1385,6 +1663,88 @@ var SwarmMapper = class {
|
|
|
1385
1663
|
}
|
|
1386
1664
|
};
|
|
1387
1665
|
|
|
1666
|
+
// packages/core/mesh/network-manager/src/swarm/connection-limiter.ts
|
|
1667
|
+
var import_async5 = require("@dxos/async");
|
|
1668
|
+
var import_context5 = require("@dxos/context");
|
|
1669
|
+
var import_errors3 = require("@dxos/errors");
|
|
1670
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
1671
|
+
var import_keys6 = require("@dxos/keys");
|
|
1672
|
+
var import_log6 = require("@dxos/log");
|
|
1673
|
+
var import_util4 = require("@dxos/util");
|
|
1674
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1675
|
+
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 3;
|
|
1676
|
+
var ConnectionLimiter = class {
|
|
1677
|
+
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
1678
|
+
this._ctx = new import_context5.Context();
|
|
1679
|
+
/**
|
|
1680
|
+
* Queue of promises to resolve when initiating connections amount is below the limit.
|
|
1681
|
+
*/
|
|
1682
|
+
this._waitingPromises = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
1683
|
+
this.resolveWaitingPromises = new import_async5.DeferredTask(this._ctx, async () => {
|
|
1684
|
+
Array.from(this._waitingPromises.values()).slice(0, this._maxConcurrentInitConnections).forEach(({ resolve }) => {
|
|
1685
|
+
resolve();
|
|
1686
|
+
});
|
|
1687
|
+
});
|
|
1688
|
+
this._maxConcurrentInitConnections = maxConcurrentInitConnections;
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* @returns Promise that resolves in queue when connections amount with 'CONNECTING' state is below the limit.
|
|
1692
|
+
*/
|
|
1693
|
+
async connecting(sessionId) {
|
|
1694
|
+
(0, import_invariant5.invariant)(!this._waitingPromises.has(sessionId), "Peer is already waiting for connection", {
|
|
1695
|
+
F: __dxlog_file6,
|
|
1696
|
+
L: 48,
|
|
1697
|
+
S: this,
|
|
1698
|
+
A: [
|
|
1699
|
+
"!this._waitingPromises.has(sessionId)",
|
|
1700
|
+
"'Peer is already waiting for connection'"
|
|
1701
|
+
]
|
|
1702
|
+
});
|
|
1703
|
+
(0, import_log6.log)("waiting", {
|
|
1704
|
+
sessionId
|
|
1705
|
+
}, {
|
|
1706
|
+
F: __dxlog_file6,
|
|
1707
|
+
L: 49,
|
|
1708
|
+
S: this,
|
|
1709
|
+
C: (f, a) => f(...a)
|
|
1710
|
+
});
|
|
1711
|
+
await new Promise((resolve, reject) => {
|
|
1712
|
+
this._waitingPromises.set(sessionId, {
|
|
1713
|
+
resolve,
|
|
1714
|
+
reject
|
|
1715
|
+
});
|
|
1716
|
+
this.resolveWaitingPromises.schedule();
|
|
1717
|
+
});
|
|
1718
|
+
(0, import_log6.log)("allow", {
|
|
1719
|
+
sessionId
|
|
1720
|
+
}, {
|
|
1721
|
+
F: __dxlog_file6,
|
|
1722
|
+
L: 57,
|
|
1723
|
+
S: this,
|
|
1724
|
+
C: (f, a) => f(...a)
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Rejects promise returned by `connecting` method.
|
|
1729
|
+
*/
|
|
1730
|
+
doneConnecting(sessionId) {
|
|
1731
|
+
(0, import_log6.log)("done", {
|
|
1732
|
+
sessionId
|
|
1733
|
+
}, {
|
|
1734
|
+
F: __dxlog_file6,
|
|
1735
|
+
L: 64,
|
|
1736
|
+
S: this,
|
|
1737
|
+
C: (f, a) => f(...a)
|
|
1738
|
+
});
|
|
1739
|
+
if (!this._waitingPromises.has(sessionId)) {
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
this._waitingPromises.get(sessionId).reject(new import_errors3.CancelledError());
|
|
1743
|
+
this._waitingPromises.delete(sessionId);
|
|
1744
|
+
this.resolveWaitingPromises.schedule();
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
|
|
1388
1748
|
// packages/core/mesh/network-manager/src/connection-log.ts
|
|
1389
1749
|
var EventType;
|
|
1390
1750
|
(function(EventType2) {
|
|
@@ -1399,8 +1759,8 @@ var ConnectionLog = class {
|
|
|
1399
1759
|
/**
|
|
1400
1760
|
* SwarmId => info
|
|
1401
1761
|
*/
|
|
1402
|
-
this._swarms = new
|
|
1403
|
-
this.update = new
|
|
1762
|
+
this._swarms = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
|
|
1763
|
+
this.update = new import_async6.Event();
|
|
1404
1764
|
}
|
|
1405
1765
|
getSwarmInfo(swarmId) {
|
|
1406
1766
|
var _a;
|
|
@@ -1411,13 +1771,13 @@ var ConnectionLog = class {
|
|
|
1411
1771
|
}
|
|
1412
1772
|
joinedSwarm(swarm) {
|
|
1413
1773
|
const info = {
|
|
1414
|
-
id:
|
|
1774
|
+
id: import_keys7.PublicKey.from(swarm._instanceId),
|
|
1415
1775
|
topic: swarm.topic,
|
|
1416
1776
|
isActive: true,
|
|
1417
1777
|
label: swarm.label,
|
|
1418
1778
|
connections: []
|
|
1419
1779
|
};
|
|
1420
|
-
this._swarms.set(
|
|
1780
|
+
this._swarms.set(import_keys7.PublicKey.from(swarm._instanceId), info);
|
|
1421
1781
|
this.update.emit();
|
|
1422
1782
|
swarm.connectionAdded.on((connection) => {
|
|
1423
1783
|
var _a, _b;
|
|
@@ -1446,29 +1806,32 @@ var ConnectionLog = class {
|
|
|
1446
1806
|
});
|
|
1447
1807
|
}
|
|
1448
1808
|
leftSwarm(swarm) {
|
|
1449
|
-
this.getSwarmInfo(
|
|
1809
|
+
this.getSwarmInfo(import_keys7.PublicKey.from(swarm._instanceId)).isActive = false;
|
|
1450
1810
|
this.update.emit();
|
|
1451
1811
|
}
|
|
1452
1812
|
};
|
|
1453
1813
|
|
|
1454
1814
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
1455
|
-
var
|
|
1456
|
-
var
|
|
1457
|
-
var
|
|
1458
|
-
var
|
|
1815
|
+
var import_async7 = require("@dxos/async");
|
|
1816
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
1817
|
+
var import_keys8 = require("@dxos/keys");
|
|
1818
|
+
var import_log7 = require("@dxos/log");
|
|
1459
1819
|
var import_messaging = require("@dxos/messaging");
|
|
1460
1820
|
var import_protocols4 = require("@dxos/protocols");
|
|
1461
1821
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
1462
|
-
var
|
|
1463
|
-
var
|
|
1822
|
+
var import_util6 = require("@dxos/util");
|
|
1823
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
1464
1824
|
var NetworkManager = class {
|
|
1465
1825
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
1466
|
-
|
|
1467
|
-
|
|
1826
|
+
/**
|
|
1827
|
+
* @internal
|
|
1828
|
+
*/
|
|
1829
|
+
this._swarms = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
|
|
1830
|
+
this._mappers = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
|
|
1468
1831
|
this._connectionState = import_services.ConnectionState.ONLINE;
|
|
1469
|
-
this.connectionStateChanged = new
|
|
1470
|
-
this.topicsUpdated = new
|
|
1471
|
-
this._instanceId =
|
|
1832
|
+
this.connectionStateChanged = new import_async7.Event();
|
|
1833
|
+
this.topicsUpdated = new import_async7.Event();
|
|
1834
|
+
this._instanceId = import_keys8.PublicKey.random().toHex();
|
|
1472
1835
|
this._transportFactory = transportFactory;
|
|
1473
1836
|
this._signalManager = signalManager;
|
|
1474
1837
|
this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => {
|
|
@@ -1482,6 +1845,7 @@ var NetworkManager = class {
|
|
|
1482
1845
|
join: (opts) => this._signalManager.join(opts),
|
|
1483
1846
|
leave: (opts) => this._signalManager.leave(opts)
|
|
1484
1847
|
};
|
|
1848
|
+
this._connectionLimiter = new ConnectionLimiter();
|
|
1485
1849
|
if (log1) {
|
|
1486
1850
|
this._connectionLog = new ConnectionLog();
|
|
1487
1851
|
}
|
|
@@ -1504,21 +1868,21 @@ var NetworkManager = class {
|
|
|
1504
1868
|
return this._swarms.get(topic);
|
|
1505
1869
|
}
|
|
1506
1870
|
async open() {
|
|
1507
|
-
|
|
1871
|
+
import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.begin({
|
|
1508
1872
|
id: this._instanceId
|
|
1509
1873
|
}), {
|
|
1510
|
-
F:
|
|
1511
|
-
L:
|
|
1874
|
+
F: __dxlog_file7,
|
|
1875
|
+
L: 130,
|
|
1512
1876
|
S: this,
|
|
1513
1877
|
C: (f, a) => f(...a)
|
|
1514
1878
|
});
|
|
1515
1879
|
await this._messenger.open();
|
|
1516
1880
|
await this._signalManager.open();
|
|
1517
|
-
|
|
1881
|
+
import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.end({
|
|
1518
1882
|
id: this._instanceId
|
|
1519
1883
|
}), {
|
|
1520
|
-
F:
|
|
1521
|
-
L:
|
|
1884
|
+
F: __dxlog_file7,
|
|
1885
|
+
L: 133,
|
|
1522
1886
|
S: this,
|
|
1523
1887
|
C: (f, a) => f(...a)
|
|
1524
1888
|
});
|
|
@@ -1526,9 +1890,9 @@ var NetworkManager = class {
|
|
|
1526
1890
|
async close() {
|
|
1527
1891
|
for (const topic of this._swarms.keys()) {
|
|
1528
1892
|
await this.leaveSwarm(topic).catch((err) => {
|
|
1529
|
-
(0,
|
|
1530
|
-
F:
|
|
1531
|
-
L:
|
|
1893
|
+
(0, import_log7.log)(err, void 0, {
|
|
1894
|
+
F: __dxlog_file7,
|
|
1895
|
+
L: 139,
|
|
1532
1896
|
S: this,
|
|
1533
1897
|
C: (f, a) => f(...a)
|
|
1534
1898
|
});
|
|
@@ -1542,30 +1906,62 @@ var NetworkManager = class {
|
|
|
1542
1906
|
*/
|
|
1543
1907
|
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1544
1908
|
var _a;
|
|
1545
|
-
(0,
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1909
|
+
(0, import_invariant6.invariant)(import_keys8.PublicKey.isPublicKey(topic), void 0, {
|
|
1910
|
+
F: __dxlog_file7,
|
|
1911
|
+
L: 157,
|
|
1912
|
+
S: this,
|
|
1913
|
+
A: [
|
|
1914
|
+
"PublicKey.isPublicKey(topic)",
|
|
1915
|
+
""
|
|
1916
|
+
]
|
|
1917
|
+
});
|
|
1918
|
+
(0, import_invariant6.invariant)(import_keys8.PublicKey.isPublicKey(peerId), void 0, {
|
|
1919
|
+
F: __dxlog_file7,
|
|
1920
|
+
L: 158,
|
|
1921
|
+
S: this,
|
|
1922
|
+
A: [
|
|
1923
|
+
"PublicKey.isPublicKey(peerId)",
|
|
1924
|
+
""
|
|
1925
|
+
]
|
|
1926
|
+
});
|
|
1927
|
+
(0, import_invariant6.invariant)(topology, void 0, {
|
|
1928
|
+
F: __dxlog_file7,
|
|
1929
|
+
L: 159,
|
|
1930
|
+
S: this,
|
|
1931
|
+
A: [
|
|
1932
|
+
"topology",
|
|
1933
|
+
""
|
|
1934
|
+
]
|
|
1935
|
+
});
|
|
1936
|
+
(0, import_invariant6.invariant)(typeof protocol === "function", void 0, {
|
|
1937
|
+
F: __dxlog_file7,
|
|
1938
|
+
L: 160,
|
|
1939
|
+
S: this,
|
|
1940
|
+
A: [
|
|
1941
|
+
"typeof protocol === 'function'",
|
|
1942
|
+
""
|
|
1943
|
+
]
|
|
1944
|
+
});
|
|
1549
1945
|
if (this._swarms.has(topic)) {
|
|
1550
|
-
throw new Error(`Already connected to swarm: ${
|
|
1946
|
+
throw new Error(`Already connected to swarm: ${import_keys8.PublicKey.from(topic)}`);
|
|
1551
1947
|
}
|
|
1552
|
-
(0,
|
|
1553
|
-
topic:
|
|
1948
|
+
(0, import_log7.log)("joining", {
|
|
1949
|
+
topic: import_keys8.PublicKey.from(topic),
|
|
1554
1950
|
peerId,
|
|
1555
1951
|
topology: topology.toString()
|
|
1556
1952
|
}, {
|
|
1557
|
-
F:
|
|
1558
|
-
L:
|
|
1953
|
+
F: __dxlog_file7,
|
|
1954
|
+
L: 165,
|
|
1559
1955
|
S: this,
|
|
1560
1956
|
C: (f, a) => f(...a)
|
|
1561
1957
|
});
|
|
1562
|
-
const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label);
|
|
1958
|
+
const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
|
|
1563
1959
|
swarm.errors.handle((error) => {
|
|
1564
|
-
(0,
|
|
1960
|
+
(0, import_log7.log)("swarm error", {
|
|
1565
1961
|
error
|
|
1566
1962
|
}, {
|
|
1567
|
-
F:
|
|
1568
|
-
L:
|
|
1963
|
+
F: __dxlog_file7,
|
|
1964
|
+
L: 178,
|
|
1569
1965
|
S: this,
|
|
1570
1966
|
C: (f, a) => f(...a)
|
|
1571
1967
|
});
|
|
@@ -1576,20 +1972,20 @@ var NetworkManager = class {
|
|
|
1576
1972
|
this._signalConnection.join({
|
|
1577
1973
|
topic,
|
|
1578
1974
|
peerId
|
|
1579
|
-
}).catch((error) =>
|
|
1580
|
-
F:
|
|
1581
|
-
L:
|
|
1975
|
+
}).catch((error) => import_log7.log.catch(error, void 0, {
|
|
1976
|
+
F: __dxlog_file7,
|
|
1977
|
+
L: 187,
|
|
1582
1978
|
S: this,
|
|
1583
1979
|
C: (f, a) => f(...a)
|
|
1584
1980
|
}));
|
|
1585
1981
|
this.topicsUpdated.emit();
|
|
1586
1982
|
(_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
|
|
1587
|
-
(0,
|
|
1588
|
-
topic:
|
|
1983
|
+
(0, import_log7.log)("joined", {
|
|
1984
|
+
topic: import_keys8.PublicKey.from(topic),
|
|
1589
1985
|
count: this._swarms.size
|
|
1590
1986
|
}, {
|
|
1591
|
-
F:
|
|
1592
|
-
L:
|
|
1987
|
+
F: __dxlog_file7,
|
|
1988
|
+
L: 191,
|
|
1593
1989
|
S: this,
|
|
1594
1990
|
C: (f, a) => f(...a)
|
|
1595
1991
|
});
|
|
@@ -1605,11 +2001,11 @@ var NetworkManager = class {
|
|
|
1605
2001
|
if (!this._swarms.has(topic)) {
|
|
1606
2002
|
return;
|
|
1607
2003
|
}
|
|
1608
|
-
(0,
|
|
1609
|
-
topic:
|
|
2004
|
+
(0, import_log7.log)("leaving", {
|
|
2005
|
+
topic: import_keys8.PublicKey.from(topic)
|
|
1610
2006
|
}, {
|
|
1611
|
-
F:
|
|
1612
|
-
L:
|
|
2007
|
+
F: __dxlog_file7,
|
|
2008
|
+
L: 207,
|
|
1613
2009
|
S: this,
|
|
1614
2010
|
C: (f, a) => f(...a)
|
|
1615
2011
|
});
|
|
@@ -1625,12 +2021,12 @@ var NetworkManager = class {
|
|
|
1625
2021
|
await swarm.destroy();
|
|
1626
2022
|
this._swarms.delete(topic);
|
|
1627
2023
|
await this.topicsUpdated.emit();
|
|
1628
|
-
(0,
|
|
1629
|
-
topic:
|
|
2024
|
+
(0, import_log7.log)("left", {
|
|
2025
|
+
topic: import_keys8.PublicKey.from(topic),
|
|
1630
2026
|
count: this._swarms.size
|
|
1631
2027
|
}, {
|
|
1632
|
-
F:
|
|
1633
|
-
L:
|
|
2028
|
+
F: __dxlog_file7,
|
|
2029
|
+
L: 221,
|
|
1634
2030
|
S: this,
|
|
1635
2031
|
C: (f, a) => f(...a)
|
|
1636
2032
|
});
|
|
@@ -1664,17 +2060,34 @@ var NetworkManager = class {
|
|
|
1664
2060
|
};
|
|
1665
2061
|
|
|
1666
2062
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
1667
|
-
var
|
|
2063
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
2064
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
1668
2065
|
var FullyConnectedTopology = class {
|
|
1669
2066
|
toString() {
|
|
1670
2067
|
return "FullyConnectedTopology";
|
|
1671
2068
|
}
|
|
1672
2069
|
init(controller) {
|
|
1673
|
-
(0,
|
|
2070
|
+
(0, import_invariant7.invariant)(!this._controller, "Already initialized", {
|
|
2071
|
+
F: __dxlog_file8,
|
|
2072
|
+
L: 18,
|
|
2073
|
+
S: this,
|
|
2074
|
+
A: [
|
|
2075
|
+
"!this._controller",
|
|
2076
|
+
"'Already initialized'"
|
|
2077
|
+
]
|
|
2078
|
+
});
|
|
1674
2079
|
this._controller = controller;
|
|
1675
2080
|
}
|
|
1676
2081
|
update() {
|
|
1677
|
-
(0,
|
|
2082
|
+
(0, import_invariant7.invariant)(this._controller, "Not initialized", {
|
|
2083
|
+
F: __dxlog_file8,
|
|
2084
|
+
L: 23,
|
|
2085
|
+
S: this,
|
|
2086
|
+
A: [
|
|
2087
|
+
"this._controller",
|
|
2088
|
+
"'Not initialized'"
|
|
2089
|
+
]
|
|
2090
|
+
});
|
|
1678
2091
|
const { candidates: discovered } = this._controller.getState();
|
|
1679
2092
|
for (const peer of discovered) {
|
|
1680
2093
|
this._controller.connect(peer);
|
|
@@ -1688,10 +2101,10 @@ var FullyConnectedTopology = class {
|
|
|
1688
2101
|
};
|
|
1689
2102
|
|
|
1690
2103
|
// packages/core/mesh/network-manager/src/topology/mmst-topology.ts
|
|
1691
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1692
2104
|
var import_xor_distance = __toESM(require("xor-distance"));
|
|
1693
|
-
var
|
|
1694
|
-
var
|
|
2105
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
2106
|
+
var import_log8 = require("@dxos/log");
|
|
2107
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
1695
2108
|
var MMSTTopology = class {
|
|
1696
2109
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
1697
2110
|
this._sampleCollected = false;
|
|
@@ -1700,15 +2113,31 @@ var MMSTTopology = class {
|
|
|
1700
2113
|
this._sampleSize = sampleSize;
|
|
1701
2114
|
}
|
|
1702
2115
|
init(controller) {
|
|
1703
|
-
(0,
|
|
2116
|
+
(0, import_invariant8.invariant)(!this._controller, "Already initialized", {
|
|
2117
|
+
F: __dxlog_file9,
|
|
2118
|
+
L: 46,
|
|
2119
|
+
S: this,
|
|
2120
|
+
A: [
|
|
2121
|
+
"!this._controller",
|
|
2122
|
+
"'Already initialized'"
|
|
2123
|
+
]
|
|
2124
|
+
});
|
|
1704
2125
|
this._controller = controller;
|
|
1705
2126
|
}
|
|
1706
2127
|
update() {
|
|
1707
|
-
(0,
|
|
2128
|
+
(0, import_invariant8.invariant)(this._controller, "Not initialized", {
|
|
2129
|
+
F: __dxlog_file9,
|
|
2130
|
+
L: 51,
|
|
2131
|
+
S: this,
|
|
2132
|
+
A: [
|
|
2133
|
+
"this._controller",
|
|
2134
|
+
"'Not initialized'"
|
|
2135
|
+
]
|
|
2136
|
+
});
|
|
1708
2137
|
const { connected, candidates } = this._controller.getState();
|
|
1709
2138
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
1710
|
-
(0,
|
|
1711
|
-
F:
|
|
2139
|
+
(0, import_log8.log)("Running the algorithm.", void 0, {
|
|
2140
|
+
F: __dxlog_file9,
|
|
1712
2141
|
L: 55,
|
|
1713
2142
|
S: this,
|
|
1714
2143
|
C: (f, a) => f(...a)
|
|
@@ -1718,11 +2147,19 @@ var MMSTTopology = class {
|
|
|
1718
2147
|
}
|
|
1719
2148
|
}
|
|
1720
2149
|
async onOffer(peer) {
|
|
1721
|
-
(0,
|
|
2150
|
+
(0, import_invariant8.invariant)(this._controller, "Not initialized", {
|
|
2151
|
+
F: __dxlog_file9,
|
|
2152
|
+
L: 62,
|
|
2153
|
+
S: this,
|
|
2154
|
+
A: [
|
|
2155
|
+
"this._controller",
|
|
2156
|
+
"'Not initialized'"
|
|
2157
|
+
]
|
|
2158
|
+
});
|
|
1722
2159
|
const { connected } = this._controller.getState();
|
|
1723
2160
|
const accept = connected.length < this._maxPeers;
|
|
1724
|
-
(0,
|
|
1725
|
-
F:
|
|
2161
|
+
(0, import_log8.log)(`Offer ${peer} accept=${accept}`, void 0, {
|
|
2162
|
+
F: __dxlog_file9,
|
|
1726
2163
|
L: 65,
|
|
1727
2164
|
S: this,
|
|
1728
2165
|
C: (f, a) => f(...a)
|
|
@@ -1732,13 +2169,21 @@ var MMSTTopology = class {
|
|
|
1732
2169
|
async destroy() {
|
|
1733
2170
|
}
|
|
1734
2171
|
_runAlgorithm() {
|
|
1735
|
-
(0,
|
|
2172
|
+
(0, import_invariant8.invariant)(this._controller, "Not initialized", {
|
|
2173
|
+
F: __dxlog_file9,
|
|
2174
|
+
L: 74,
|
|
2175
|
+
S: this,
|
|
2176
|
+
A: [
|
|
2177
|
+
"this._controller",
|
|
2178
|
+
"'Not initialized'"
|
|
2179
|
+
]
|
|
2180
|
+
});
|
|
1736
2181
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
1737
2182
|
if (connected.length > this._maxPeers) {
|
|
1738
2183
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
1739
2184
|
for (const peer of sorted) {
|
|
1740
|
-
(0,
|
|
1741
|
-
F:
|
|
2185
|
+
(0, import_log8.log)(`Disconnect ${peer}.`, void 0, {
|
|
2186
|
+
F: __dxlog_file9,
|
|
1742
2187
|
L: 83,
|
|
1743
2188
|
S: this,
|
|
1744
2189
|
C: (f, a) => f(...a)
|
|
@@ -1749,8 +2194,8 @@ var MMSTTopology = class {
|
|
|
1749
2194
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
1750
2195
|
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
1751
2196
|
for (const peer of sorted) {
|
|
1752
|
-
(0,
|
|
1753
|
-
F:
|
|
2197
|
+
(0, import_log8.log)(`Connect ${peer}.`, void 0, {
|
|
2198
|
+
F: __dxlog_file9,
|
|
1754
2199
|
L: 91,
|
|
1755
2200
|
S: this,
|
|
1756
2201
|
C: (f, a) => f(...a)
|
|
@@ -1766,9 +2211,9 @@ var MMSTTopology = class {
|
|
|
1766
2211
|
var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_distance.default.gt((0, import_xor_distance.default)(a.asBuffer(), reference.asBuffer()), (0, import_xor_distance.default)(b.asBuffer(), reference.asBuffer())));
|
|
1767
2212
|
|
|
1768
2213
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
1769
|
-
var
|
|
1770
|
-
var
|
|
1771
|
-
var
|
|
2214
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2215
|
+
var import_log9 = require("@dxos/log");
|
|
2216
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
1772
2217
|
var StarTopology = class {
|
|
1773
2218
|
// prettier-ignore
|
|
1774
2219
|
constructor(_centralPeer) {
|
|
@@ -1778,26 +2223,42 @@ var StarTopology = class {
|
|
|
1778
2223
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
1779
2224
|
}
|
|
1780
2225
|
init(controller) {
|
|
1781
|
-
(0,
|
|
2226
|
+
(0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
|
|
2227
|
+
F: __dxlog_file10,
|
|
2228
|
+
L: 24,
|
|
2229
|
+
S: this,
|
|
2230
|
+
A: [
|
|
2231
|
+
"!this._controller",
|
|
2232
|
+
"'Already initialized.'"
|
|
2233
|
+
]
|
|
2234
|
+
});
|
|
1782
2235
|
this._controller = controller;
|
|
1783
2236
|
}
|
|
1784
2237
|
update() {
|
|
1785
|
-
(0,
|
|
2238
|
+
(0, import_invariant9.invariant)(this._controller, "Not initialized.", {
|
|
2239
|
+
F: __dxlog_file10,
|
|
2240
|
+
L: 29,
|
|
2241
|
+
S: this,
|
|
2242
|
+
A: [
|
|
2243
|
+
"this._controller",
|
|
2244
|
+
"'Not initialized.'"
|
|
2245
|
+
]
|
|
2246
|
+
});
|
|
1786
2247
|
const { candidates, connected, ownPeerId } = this._controller.getState();
|
|
1787
2248
|
if (!ownPeerId.equals(this._centralPeer)) {
|
|
1788
|
-
(0,
|
|
1789
|
-
F:
|
|
1790
|
-
L:
|
|
2249
|
+
(0, import_log9.log)("leaf peer dropping all connections apart from central peer.", void 0, {
|
|
2250
|
+
F: __dxlog_file10,
|
|
2251
|
+
L: 32,
|
|
1791
2252
|
S: this,
|
|
1792
2253
|
C: (f, a) => f(...a)
|
|
1793
2254
|
});
|
|
1794
2255
|
for (const peer of connected) {
|
|
1795
2256
|
if (!peer.equals(this._centralPeer)) {
|
|
1796
|
-
(0,
|
|
2257
|
+
(0, import_log9.log)("dropping connection", {
|
|
1797
2258
|
peer
|
|
1798
2259
|
}, {
|
|
1799
|
-
F:
|
|
1800
|
-
L:
|
|
2260
|
+
F: __dxlog_file10,
|
|
2261
|
+
L: 37,
|
|
1801
2262
|
S: this,
|
|
1802
2263
|
C: (f, a) => f(...a)
|
|
1803
2264
|
});
|
|
@@ -1807,11 +2268,11 @@ var StarTopology = class {
|
|
|
1807
2268
|
}
|
|
1808
2269
|
for (const peer of candidates) {
|
|
1809
2270
|
if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
|
|
1810
|
-
(0,
|
|
2271
|
+
(0, import_log9.log)("connecting to peer", {
|
|
1811
2272
|
peer
|
|
1812
2273
|
}, {
|
|
1813
|
-
F:
|
|
1814
|
-
L:
|
|
2274
|
+
F: __dxlog_file10,
|
|
2275
|
+
L: 46,
|
|
1815
2276
|
S: this,
|
|
1816
2277
|
C: (f, a) => f(...a)
|
|
1817
2278
|
});
|
|
@@ -1820,15 +2281,23 @@ var StarTopology = class {
|
|
|
1820
2281
|
}
|
|
1821
2282
|
}
|
|
1822
2283
|
async onOffer(peer) {
|
|
1823
|
-
(0,
|
|
2284
|
+
(0, import_invariant9.invariant)(this._controller, "Not initialized.", {
|
|
2285
|
+
F: __dxlog_file10,
|
|
2286
|
+
L: 53,
|
|
2287
|
+
S: this,
|
|
2288
|
+
A: [
|
|
2289
|
+
"this._controller",
|
|
2290
|
+
"'Not initialized.'"
|
|
2291
|
+
]
|
|
2292
|
+
});
|
|
1824
2293
|
const { ownPeerId } = this._controller.getState();
|
|
1825
|
-
(0,
|
|
2294
|
+
(0, import_log9.log)("offer", {
|
|
1826
2295
|
peer,
|
|
1827
2296
|
isCentral: peer.equals(this._centralPeer),
|
|
1828
2297
|
isSelfCentral: ownPeerId.equals(this._centralPeer)
|
|
1829
2298
|
}, {
|
|
1830
|
-
F:
|
|
1831
|
-
L:
|
|
2299
|
+
F: __dxlog_file10,
|
|
2300
|
+
L: 55,
|
|
1832
2301
|
S: this,
|
|
1833
2302
|
C: (f, a) => f(...a)
|
|
1834
2303
|
});
|
|
@@ -1840,12 +2309,12 @@ var StarTopology = class {
|
|
|
1840
2309
|
|
|
1841
2310
|
// packages/core/mesh/network-manager/src/transport/memory-transport.ts
|
|
1842
2311
|
var import_node_stream = require("node:stream");
|
|
1843
|
-
var
|
|
1844
|
-
var import_async7 = require("@dxos/async");
|
|
2312
|
+
var import_async8 = require("@dxos/async");
|
|
1845
2313
|
var import_debug4 = require("@dxos/debug");
|
|
1846
|
-
var
|
|
1847
|
-
var
|
|
1848
|
-
var
|
|
2314
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
2315
|
+
var import_keys9 = require("@dxos/keys");
|
|
2316
|
+
var import_log10 = require("@dxos/log");
|
|
2317
|
+
var import_util7 = require("@dxos/util");
|
|
1849
2318
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1850
2319
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1851
2320
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -1856,7 +2325,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
1856
2325
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1857
2326
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1858
2327
|
}
|
|
1859
|
-
var
|
|
2328
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
1860
2329
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
1861
2330
|
var createStreamDelay = (delay) => {
|
|
1862
2331
|
return new import_node_stream.Transform({
|
|
@@ -1873,26 +2342,34 @@ var _MemoryTransport = class {
|
|
|
1873
2342
|
constructor(options) {
|
|
1874
2343
|
var _a;
|
|
1875
2344
|
this.options = options;
|
|
1876
|
-
this.closed = new
|
|
1877
|
-
this.connected = new
|
|
2345
|
+
this.closed = new import_async8.Event();
|
|
2346
|
+
this.connected = new import_async8.Event();
|
|
1878
2347
|
this.errors = new import_debug4.ErrorStream();
|
|
1879
|
-
this._instanceId =
|
|
1880
|
-
this._remote = new
|
|
2348
|
+
this._instanceId = import_keys9.PublicKey.random();
|
|
2349
|
+
this._remote = new import_async8.Trigger();
|
|
1881
2350
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1882
2351
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1883
2352
|
this._destroyed = false;
|
|
1884
|
-
(0,
|
|
1885
|
-
F:
|
|
2353
|
+
(0, import_log10.log)("creating", void 0, {
|
|
2354
|
+
F: __dxlog_file11,
|
|
1886
2355
|
L: 64,
|
|
1887
2356
|
S: this,
|
|
1888
2357
|
C: (f, a) => f(...a)
|
|
1889
2358
|
});
|
|
1890
|
-
(0,
|
|
2359
|
+
(0, import_invariant10.invariant)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
|
|
2360
|
+
F: __dxlog_file11,
|
|
2361
|
+
L: 66,
|
|
2362
|
+
S: this,
|
|
2363
|
+
A: [
|
|
2364
|
+
"!MemoryTransport._connections.has(this._instanceId)",
|
|
2365
|
+
"'Duplicate memory connection'"
|
|
2366
|
+
]
|
|
2367
|
+
});
|
|
1891
2368
|
_MemoryTransport._connections.set(this._instanceId, this);
|
|
1892
2369
|
if (this.options.initiator) {
|
|
1893
2370
|
setTimeout(async () => {
|
|
1894
|
-
(0,
|
|
1895
|
-
F:
|
|
2371
|
+
(0, import_log10.log)("sending signal", void 0, {
|
|
2372
|
+
F: __dxlog_file11,
|
|
1896
2373
|
L: 73,
|
|
1897
2374
|
S: this,
|
|
1898
2375
|
C: (f, a) => f(...a)
|
|
@@ -1921,11 +2398,19 @@ var _MemoryTransport = class {
|
|
|
1921
2398
|
this.closed.emit();
|
|
1922
2399
|
return;
|
|
1923
2400
|
}
|
|
1924
|
-
(0,
|
|
2401
|
+
(0, import_invariant10.invariant)(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
|
|
2402
|
+
F: __dxlog_file11,
|
|
2403
|
+
L: 99,
|
|
2404
|
+
S: this,
|
|
2405
|
+
A: [
|
|
2406
|
+
"!this._remoteConnection._remoteConnection",
|
|
2407
|
+
"`Remote already connected: ${this._remoteInstanceId}`"
|
|
2408
|
+
]
|
|
2409
|
+
});
|
|
1925
2410
|
this._remoteConnection._remoteConnection = this;
|
|
1926
2411
|
this._remoteConnection._remoteInstanceId = this._instanceId;
|
|
1927
|
-
(0,
|
|
1928
|
-
F:
|
|
2412
|
+
(0, import_log10.log)("connected", void 0, {
|
|
2413
|
+
F: __dxlog_file11,
|
|
1929
2414
|
L: 103,
|
|
1930
2415
|
S: this,
|
|
1931
2416
|
C: (f, a) => f(...a)
|
|
@@ -1942,8 +2427,8 @@ var _MemoryTransport = class {
|
|
|
1942
2427
|
}
|
|
1943
2428
|
}
|
|
1944
2429
|
async destroy() {
|
|
1945
|
-
(0,
|
|
1946
|
-
F:
|
|
2430
|
+
(0, import_log10.log)("closing", void 0, {
|
|
2431
|
+
F: __dxlog_file11,
|
|
1947
2432
|
L: 124,
|
|
1948
2433
|
S: this,
|
|
1949
2434
|
C: (f, a) => f(...a)
|
|
@@ -1951,8 +2436,8 @@ var _MemoryTransport = class {
|
|
|
1951
2436
|
this._destroyed = true;
|
|
1952
2437
|
_MemoryTransport._connections.delete(this._instanceId);
|
|
1953
2438
|
if (this._remoteConnection) {
|
|
1954
|
-
(0,
|
|
1955
|
-
F:
|
|
2439
|
+
(0, import_log10.log)("closing", void 0, {
|
|
2440
|
+
F: __dxlog_file11,
|
|
1956
2441
|
L: 129,
|
|
1957
2442
|
S: this,
|
|
1958
2443
|
C: (f, a) => f(...a)
|
|
@@ -1964,26 +2449,26 @@ var _MemoryTransport = class {
|
|
|
1964
2449
|
this._remoteConnection.closed.emit();
|
|
1965
2450
|
this._remoteConnection._remoteConnection = void 0;
|
|
1966
2451
|
this._remoteConnection = void 0;
|
|
1967
|
-
(0,
|
|
1968
|
-
F:
|
|
2452
|
+
(0, import_log10.log)("closed", void 0, {
|
|
2453
|
+
F: __dxlog_file11,
|
|
1969
2454
|
L: 147,
|
|
1970
2455
|
S: this,
|
|
1971
2456
|
C: (f, a) => f(...a)
|
|
1972
2457
|
});
|
|
1973
2458
|
}
|
|
1974
2459
|
this.closed.emit();
|
|
1975
|
-
(0,
|
|
1976
|
-
F:
|
|
2460
|
+
(0, import_log10.log)("closed", void 0, {
|
|
2461
|
+
F: __dxlog_file11,
|
|
1977
2462
|
L: 151,
|
|
1978
2463
|
S: this,
|
|
1979
2464
|
C: (f, a) => f(...a)
|
|
1980
2465
|
});
|
|
1981
2466
|
}
|
|
1982
2467
|
signal({ payload }) {
|
|
1983
|
-
(0,
|
|
2468
|
+
(0, import_log10.log)("received signal", {
|
|
1984
2469
|
payload
|
|
1985
2470
|
}, {
|
|
1986
|
-
F:
|
|
2471
|
+
F: __dxlog_file11,
|
|
1987
2472
|
L: 155,
|
|
1988
2473
|
S: this,
|
|
1989
2474
|
C: (f, a) => f(...a)
|
|
@@ -1993,28 +2478,28 @@ var _MemoryTransport = class {
|
|
|
1993
2478
|
}
|
|
1994
2479
|
const transportId = payload.transportId;
|
|
1995
2480
|
if (transportId) {
|
|
1996
|
-
const remoteId =
|
|
2481
|
+
const remoteId = import_keys9.PublicKey.fromHex(transportId);
|
|
1997
2482
|
this._remote.wake(remoteId);
|
|
1998
2483
|
}
|
|
1999
2484
|
}
|
|
2000
2485
|
};
|
|
2001
2486
|
var MemoryTransport = _MemoryTransport;
|
|
2002
2487
|
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
2003
|
-
MemoryTransport._connections = new
|
|
2488
|
+
MemoryTransport._connections = new import_util7.ComplexMap(import_keys9.PublicKey.hash);
|
|
2004
2489
|
_ts_decorate4([
|
|
2005
|
-
|
|
2490
|
+
import_log10.logInfo
|
|
2006
2491
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
2007
2492
|
_ts_decorate4([
|
|
2008
|
-
|
|
2493
|
+
import_log10.logInfo
|
|
2009
2494
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
2010
2495
|
|
|
2011
2496
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
2012
2497
|
var import_simple_peer = __toESM(require("simple-peer"));
|
|
2013
|
-
var
|
|
2014
|
-
var import_async8 = require("@dxos/async");
|
|
2498
|
+
var import_async9 = require("@dxos/async");
|
|
2015
2499
|
var import_debug5 = require("@dxos/debug");
|
|
2016
|
-
var
|
|
2017
|
-
var
|
|
2500
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
2501
|
+
var import_keys10 = require("@dxos/keys");
|
|
2502
|
+
var import_log11 = require("@dxos/log");
|
|
2018
2503
|
var import_protocols5 = require("@dxos/protocols");
|
|
2019
2504
|
|
|
2020
2505
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
@@ -2025,26 +2510,26 @@ try {
|
|
|
2025
2510
|
}
|
|
2026
2511
|
|
|
2027
2512
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
2028
|
-
var
|
|
2513
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
|
|
2029
2514
|
var WebRTCTransport = class {
|
|
2030
2515
|
constructor(params) {
|
|
2031
2516
|
var _a;
|
|
2032
2517
|
this.params = params;
|
|
2033
2518
|
this._closed = false;
|
|
2034
|
-
this.closed = new
|
|
2035
|
-
this.connected = new
|
|
2519
|
+
this.closed = new import_async9.Event();
|
|
2520
|
+
this.connected = new import_async9.Event();
|
|
2036
2521
|
this.errors = new import_debug5.ErrorStream();
|
|
2037
|
-
this._instanceId =
|
|
2038
|
-
|
|
2522
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
2523
|
+
import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.begin({
|
|
2039
2524
|
id: this._instanceId
|
|
2040
2525
|
}), {
|
|
2041
|
-
F:
|
|
2526
|
+
F: __dxlog_file12,
|
|
2042
2527
|
L: 39,
|
|
2043
2528
|
S: this,
|
|
2044
2529
|
C: (f, a) => f(...a)
|
|
2045
2530
|
});
|
|
2046
|
-
(0,
|
|
2047
|
-
F:
|
|
2531
|
+
(0, import_log11.log)("created connection", params, {
|
|
2532
|
+
F: __dxlog_file12,
|
|
2048
2533
|
L: 40,
|
|
2049
2534
|
S: this,
|
|
2050
2535
|
C: (f, a) => f(...a)
|
|
@@ -2055,8 +2540,8 @@ var WebRTCTransport = class {
|
|
|
2055
2540
|
config: this.params.webrtcConfig
|
|
2056
2541
|
});
|
|
2057
2542
|
this._peer.on("signal", async (data) => {
|
|
2058
|
-
(0,
|
|
2059
|
-
F:
|
|
2543
|
+
(0, import_log11.log)("signal", data, {
|
|
2544
|
+
F: __dxlog_file12,
|
|
2060
2545
|
L: 48,
|
|
2061
2546
|
S: this,
|
|
2062
2547
|
C: (f, a) => f(...a)
|
|
@@ -2068,8 +2553,8 @@ var WebRTCTransport = class {
|
|
|
2068
2553
|
});
|
|
2069
2554
|
});
|
|
2070
2555
|
this._peer.on("connect", () => {
|
|
2071
|
-
(0,
|
|
2072
|
-
F:
|
|
2556
|
+
(0, import_log11.log)("connected", void 0, {
|
|
2557
|
+
F: __dxlog_file12,
|
|
2073
2558
|
L: 53,
|
|
2074
2559
|
S: this,
|
|
2075
2560
|
C: (f, a) => f(...a)
|
|
@@ -2078,8 +2563,8 @@ var WebRTCTransport = class {
|
|
|
2078
2563
|
this.connected.emit();
|
|
2079
2564
|
});
|
|
2080
2565
|
this._peer.on("close", async () => {
|
|
2081
|
-
(0,
|
|
2082
|
-
F:
|
|
2566
|
+
(0, import_log11.log)("closed", void 0, {
|
|
2567
|
+
F: __dxlog_file12,
|
|
2083
2568
|
L: 59,
|
|
2084
2569
|
S: this,
|
|
2085
2570
|
C: (f, a) => f(...a)
|
|
@@ -2093,11 +2578,11 @@ var WebRTCTransport = class {
|
|
|
2093
2578
|
try {
|
|
2094
2579
|
if (typeof ((_a2 = this._peer) == null ? void 0 : _a2._pc.getStats) === "function") {
|
|
2095
2580
|
this._peer._pc.getStats().then((stats) => {
|
|
2096
|
-
|
|
2581
|
+
import_log11.log.warn("report after webrtc error", {
|
|
2097
2582
|
config: this.params.webrtcConfig,
|
|
2098
2583
|
stats
|
|
2099
2584
|
}, {
|
|
2100
|
-
F:
|
|
2585
|
+
F: __dxlog_file12,
|
|
2101
2586
|
L: 71,
|
|
2102
2587
|
S: this,
|
|
2103
2588
|
C: (f, a) => f(...a)
|
|
@@ -2108,18 +2593,18 @@ var WebRTCTransport = class {
|
|
|
2108
2593
|
}
|
|
2109
2594
|
await this.destroy();
|
|
2110
2595
|
});
|
|
2111
|
-
|
|
2596
|
+
import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.end({
|
|
2112
2597
|
id: this._instanceId
|
|
2113
2598
|
}), {
|
|
2114
|
-
F:
|
|
2599
|
+
F: __dxlog_file12,
|
|
2115
2600
|
L: 81,
|
|
2116
2601
|
S: this,
|
|
2117
2602
|
C: (f, a) => f(...a)
|
|
2118
2603
|
});
|
|
2119
2604
|
}
|
|
2120
2605
|
async destroy() {
|
|
2121
|
-
(0,
|
|
2122
|
-
F:
|
|
2606
|
+
(0, import_log11.log)("closing...", void 0, {
|
|
2607
|
+
F: __dxlog_file12,
|
|
2123
2608
|
L: 85,
|
|
2124
2609
|
S: this,
|
|
2125
2610
|
C: (f, a) => f(...a)
|
|
@@ -2128,8 +2613,8 @@ var WebRTCTransport = class {
|
|
|
2128
2613
|
await this._disconnectStreams();
|
|
2129
2614
|
this._peer.destroy();
|
|
2130
2615
|
this.closed.emit();
|
|
2131
|
-
(0,
|
|
2132
|
-
F:
|
|
2616
|
+
(0, import_log11.log)("closed", void 0, {
|
|
2617
|
+
F: __dxlog_file12,
|
|
2133
2618
|
L: 90,
|
|
2134
2619
|
S: this,
|
|
2135
2620
|
C: (f, a) => f(...a)
|
|
@@ -2139,7 +2624,15 @@ var WebRTCTransport = class {
|
|
|
2139
2624
|
if (this._closed) {
|
|
2140
2625
|
return;
|
|
2141
2626
|
}
|
|
2142
|
-
(0,
|
|
2627
|
+
(0, import_invariant11.invariant)(signal.payload.data, "Signal message must contain signal data.", {
|
|
2628
|
+
F: __dxlog_file12,
|
|
2629
|
+
L: 98,
|
|
2630
|
+
S: this,
|
|
2631
|
+
A: [
|
|
2632
|
+
"signal.payload.data",
|
|
2633
|
+
"'Signal message must contain signal data.'"
|
|
2634
|
+
]
|
|
2635
|
+
});
|
|
2143
2636
|
this._peer.signal(signal.payload.data);
|
|
2144
2637
|
}
|
|
2145
2638
|
async _disconnectStreams() {
|
|
@@ -2156,23 +2649,30 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
2156
2649
|
|
|
2157
2650
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
|
|
2158
2651
|
var import_node_stream2 = require("node:stream");
|
|
2159
|
-
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
2160
2652
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
2161
|
-
var
|
|
2162
|
-
var
|
|
2653
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
2654
|
+
var import_keys11 = require("@dxos/keys");
|
|
2655
|
+
var import_log12 = require("@dxos/log");
|
|
2163
2656
|
var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
2164
|
-
var
|
|
2165
|
-
var
|
|
2657
|
+
var import_util8 = require("@dxos/util");
|
|
2658
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
|
|
2166
2659
|
var WebRTCTransportService = class {
|
|
2167
2660
|
// prettier-ignore
|
|
2168
2661
|
constructor(_webrtcConfig) {
|
|
2169
2662
|
this._webrtcConfig = _webrtcConfig;
|
|
2170
|
-
this.transports = new
|
|
2663
|
+
this.transports = new import_util8.ComplexMap(import_keys11.PublicKey.hash);
|
|
2171
2664
|
}
|
|
2172
2665
|
open(request) {
|
|
2173
2666
|
const rpcStream = new import_codec_protobuf.Stream(({ ready, next, close }) => {
|
|
2174
2667
|
const duplex = new import_node_stream2.Duplex({
|
|
2175
2668
|
read: () => {
|
|
2669
|
+
const callbacks = [
|
|
2670
|
+
...transportState.writeCallbacks
|
|
2671
|
+
];
|
|
2672
|
+
transportState.writeCallbacks.length = 0;
|
|
2673
|
+
for (const cb of callbacks) {
|
|
2674
|
+
cb();
|
|
2675
|
+
}
|
|
2176
2676
|
},
|
|
2177
2677
|
write: function(chunk, _, callback) {
|
|
2178
2678
|
next({
|
|
@@ -2224,30 +2724,54 @@ var WebRTCTransportService = class {
|
|
|
2224
2724
|
});
|
|
2225
2725
|
close();
|
|
2226
2726
|
});
|
|
2227
|
-
|
|
2228
|
-
this.transports.set(request.proxyId, {
|
|
2727
|
+
const transportState = {
|
|
2229
2728
|
transport,
|
|
2230
|
-
stream: duplex
|
|
2231
|
-
|
|
2729
|
+
stream: duplex,
|
|
2730
|
+
writeCallbacks: []
|
|
2731
|
+
};
|
|
2732
|
+
ready();
|
|
2733
|
+
this.transports.set(request.proxyId, transportState);
|
|
2232
2734
|
});
|
|
2233
2735
|
return rpcStream;
|
|
2234
2736
|
}
|
|
2235
2737
|
async sendSignal({ proxyId, signal }) {
|
|
2236
|
-
(0,
|
|
2738
|
+
(0, import_invariant12.invariant)(this.transports.has(proxyId), void 0, {
|
|
2739
|
+
F: __dxlog_file13,
|
|
2740
|
+
L: 113,
|
|
2741
|
+
S: this,
|
|
2742
|
+
A: [
|
|
2743
|
+
"this.transports.has(proxyId)",
|
|
2744
|
+
""
|
|
2745
|
+
]
|
|
2746
|
+
});
|
|
2237
2747
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
2238
2748
|
}
|
|
2239
2749
|
async sendData({ proxyId, payload }) {
|
|
2240
|
-
(0,
|
|
2241
|
-
|
|
2750
|
+
(0, import_invariant12.invariant)(this.transports.has(proxyId), void 0, {
|
|
2751
|
+
F: __dxlog_file13,
|
|
2752
|
+
L: 118,
|
|
2753
|
+
S: this,
|
|
2754
|
+
A: [
|
|
2755
|
+
"this.transports.has(proxyId)",
|
|
2756
|
+
""
|
|
2757
|
+
]
|
|
2758
|
+
});
|
|
2759
|
+
const state = this.transports.get(proxyId);
|
|
2760
|
+
const bufferHasSpace = state.stream.push(payload);
|
|
2761
|
+
if (!bufferHasSpace) {
|
|
2762
|
+
await new Promise((resolve) => {
|
|
2763
|
+
state.writeCallbacks.push(resolve);
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2242
2766
|
}
|
|
2243
2767
|
async close({ proxyId }) {
|
|
2244
2768
|
var _a, _b;
|
|
2245
2769
|
await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
|
|
2246
2770
|
await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
|
|
2247
2771
|
this.transports.delete(proxyId);
|
|
2248
|
-
(0,
|
|
2249
|
-
F:
|
|
2250
|
-
L:
|
|
2772
|
+
(0, import_log12.log)("Closed.", void 0, {
|
|
2773
|
+
F: __dxlog_file13,
|
|
2774
|
+
L: 132,
|
|
2251
2775
|
S: this,
|
|
2252
2776
|
C: (f, a) => f(...a)
|
|
2253
2777
|
});
|
|
@@ -2255,24 +2779,25 @@ var WebRTCTransportService = class {
|
|
|
2255
2779
|
};
|
|
2256
2780
|
|
|
2257
2781
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
|
|
2258
|
-
var
|
|
2259
|
-
var
|
|
2260
|
-
var
|
|
2782
|
+
var import_node_stream3 = require("node:stream");
|
|
2783
|
+
var import_async10 = require("@dxos/async");
|
|
2784
|
+
var import_context6 = require("@dxos/context");
|
|
2261
2785
|
var import_debug6 = require("@dxos/debug");
|
|
2262
|
-
var
|
|
2263
|
-
var
|
|
2786
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
2787
|
+
var import_keys12 = require("@dxos/keys");
|
|
2788
|
+
var import_log13 = require("@dxos/log");
|
|
2264
2789
|
var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
2265
|
-
var
|
|
2266
|
-
var
|
|
2790
|
+
var import_util9 = require("@dxos/util");
|
|
2791
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
|
|
2267
2792
|
var WebRTCTransportProxy = class {
|
|
2268
2793
|
// prettier-ignore
|
|
2269
2794
|
constructor(_params) {
|
|
2270
2795
|
this._params = _params;
|
|
2271
|
-
this._proxyId =
|
|
2272
|
-
this._ctx = new
|
|
2273
|
-
this.closed = new
|
|
2796
|
+
this._proxyId = import_keys12.PublicKey.random();
|
|
2797
|
+
this._ctx = new import_context6.Context();
|
|
2798
|
+
this.closed = new import_async10.Event();
|
|
2274
2799
|
this._closed = false;
|
|
2275
|
-
this.connected = new
|
|
2800
|
+
this.connected = new import_async10.Event();
|
|
2276
2801
|
this.errors = new import_debug6.ErrorStream();
|
|
2277
2802
|
this._serviceStream = this._params.bridgeService.open({
|
|
2278
2803
|
proxyId: this._proxyId,
|
|
@@ -2280,9 +2805,9 @@ var WebRTCTransportProxy = class {
|
|
|
2280
2805
|
});
|
|
2281
2806
|
this._serviceStream.waitUntilReady().then(() => {
|
|
2282
2807
|
this._serviceStream.subscribe(async (event) => {
|
|
2283
|
-
(0,
|
|
2284
|
-
F:
|
|
2285
|
-
L:
|
|
2808
|
+
(0, import_log13.log)("WebRTCTransportProxy: event", event, {
|
|
2809
|
+
F: __dxlog_file14,
|
|
2810
|
+
L: 51,
|
|
2286
2811
|
S: this,
|
|
2287
2812
|
C: (f, a) => f(...a)
|
|
2288
2813
|
});
|
|
@@ -2294,28 +2819,24 @@ var WebRTCTransportProxy = class {
|
|
|
2294
2819
|
await this._handleSignal(event.signal);
|
|
2295
2820
|
}
|
|
2296
2821
|
});
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2822
|
+
this._params.stream.pipe(new import_node_stream3.Writable({
|
|
2823
|
+
write: (chunk, _, callback) => {
|
|
2824
|
+
this._params.bridgeService.sendData({
|
|
2300
2825
|
proxyId: this._proxyId,
|
|
2301
|
-
payload:
|
|
2302
|
-
})
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2826
|
+
payload: chunk
|
|
2827
|
+
}).then(() => callback(), (err) => {
|
|
2828
|
+
import_log13.log.catch(err, void 0, {
|
|
2829
|
+
F: __dxlog_file14,
|
|
2830
|
+
L: 69,
|
|
2831
|
+
S: this,
|
|
2832
|
+
C: (f, a) => f(...a)
|
|
2833
|
+
});
|
|
2309
2834
|
});
|
|
2310
2835
|
}
|
|
2311
|
-
};
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
});
|
|
2316
|
-
}, (error) => import_log12.log.catch(error, void 0, {
|
|
2317
|
-
F: __dxlog_file12,
|
|
2318
|
-
L: 73,
|
|
2836
|
+
}));
|
|
2837
|
+
}, (error) => import_log13.log.catch(error, void 0, {
|
|
2838
|
+
F: __dxlog_file14,
|
|
2839
|
+
L: 75,
|
|
2319
2840
|
S: this,
|
|
2320
2841
|
C: (f, a) => f(...a)
|
|
2321
2842
|
}));
|
|
@@ -2336,7 +2857,7 @@ var WebRTCTransportProxy = class {
|
|
|
2336
2857
|
}
|
|
2337
2858
|
}
|
|
2338
2859
|
_handleData(dataEvent) {
|
|
2339
|
-
this._params.stream.write((0,
|
|
2860
|
+
this._params.stream.write((0, import_util9.arrayToBuffer)(dataEvent.payload));
|
|
2340
2861
|
}
|
|
2341
2862
|
async _handleSignal(signalEvent) {
|
|
2342
2863
|
await this._params.sendSignal(signalEvent.payload);
|
|
@@ -2359,9 +2880,9 @@ var WebRTCTransportProxy = class {
|
|
|
2359
2880
|
proxyId: this._proxyId
|
|
2360
2881
|
});
|
|
2361
2882
|
} catch (err) {
|
|
2362
|
-
|
|
2363
|
-
F:
|
|
2364
|
-
L:
|
|
2883
|
+
import_log13.log.catch(err, void 0, {
|
|
2884
|
+
F: __dxlog_file14,
|
|
2885
|
+
L: 126,
|
|
2365
2886
|
S: this,
|
|
2366
2887
|
C: (f, a) => f(...a)
|
|
2367
2888
|
});
|
|
@@ -2395,7 +2916,15 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2395
2916
|
return this;
|
|
2396
2917
|
}
|
|
2397
2918
|
createTransport(options) {
|
|
2398
|
-
(0,
|
|
2919
|
+
(0, import_invariant13.invariant)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections", {
|
|
2920
|
+
F: __dxlog_file14,
|
|
2921
|
+
L: 163,
|
|
2922
|
+
S: this,
|
|
2923
|
+
A: [
|
|
2924
|
+
"this._bridgeService",
|
|
2925
|
+
"'WebRTCTransportProxyFactory is not ready to open connections'"
|
|
2926
|
+
]
|
|
2927
|
+
});
|
|
2399
2928
|
const transport = new WebRTCTransportProxy({
|
|
2400
2929
|
...options,
|
|
2401
2930
|
bridgeService: this._bridgeService
|
|
@@ -2426,10 +2955,12 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
2426
2955
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2427
2956
|
0 && (module.exports = {
|
|
2428
2957
|
Connection,
|
|
2958
|
+
ConnectionLimiter,
|
|
2429
2959
|
ConnectionLog,
|
|
2430
2960
|
ConnectionState,
|
|
2431
2961
|
EventType,
|
|
2432
2962
|
FullyConnectedTopology,
|
|
2963
|
+
MAX_CONCURRENT_INITIATING_CONNECTIONS,
|
|
2433
2964
|
MMSTTopology,
|
|
2434
2965
|
MemoryTransport,
|
|
2435
2966
|
MemoryTransportFactory,
|