@dxos/network-manager 0.8.4-main.5ea62a8 → 0.8.4-main.66e292d
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-VAQETEB2.mjs → chunk-5ISEIDVN.mjs} +441 -633
- package/dist/lib/browser/chunk-5ISEIDVN.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 +85 -113
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/browser/transport/tcp/index.mjs +3 -18
- package/dist/lib/browser/transport/tcp/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-RAHYLU4N.mjs → chunk-S7AVXKL7.mjs} +441 -633
- package/dist/lib/node-esm/chunk-S7AVXKL7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +85 -113
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/transport/tcp/index.mjs +11 -31
- package/dist/lib/node-esm/transport/tcp/index.mjs.map +2 -2
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-proxy.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -29
- package/src/swarm/connection.test.ts +2 -1
- package/src/swarm/connection.ts +7 -5
- package/src/swarm/peer.ts +1 -1
- package/src/swarm/swarm.test.ts +2 -1
- package/src/tests/webrtc-transport.test.ts +4 -2
- package/src/transport/webrtc/rtc-peer-connection.ts +1 -1
- package/src/transport/webrtc/rtc-transport-channel.ts +1 -1
- package/src/transport/webrtc/rtc-transport-proxy.test.ts +2 -1
- package/src/transport/webrtc/rtc-transport-proxy.ts +6 -4
- package/src/transport/webrtc/rtc-transport.test.ts +2 -1
- package/dist/lib/browser/chunk-VAQETEB2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RAHYLU4N.mjs.map +0 -7
|
@@ -8,19 +8,6 @@ import { invariant } from "@dxos/invariant";
|
|
|
8
8
|
import { PublicKey } from "@dxos/keys";
|
|
9
9
|
import { log, logInfo } from "@dxos/log";
|
|
10
10
|
import { CancelledError, ConnectionResetError, ConnectivityError, ProtocolError, TimeoutError, trace } from "@dxos/protocols";
|
|
11
|
-
function _define_property(obj, key, value) {
|
|
12
|
-
if (key in obj) {
|
|
13
|
-
Object.defineProperty(obj, key, {
|
|
14
|
-
value,
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true
|
|
18
|
-
});
|
|
19
|
-
} else {
|
|
20
|
-
obj[key] = value;
|
|
21
|
-
}
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
11
|
function _ts_decorate(decorators, target, key, desc) {
|
|
25
12
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26
13
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -32,7 +19,7 @@ var STARTING_SIGNALLING_DELAY = 10;
|
|
|
32
19
|
var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
|
|
33
20
|
var TRANSPORT_STATS_INTERVAL = 5e3;
|
|
34
21
|
var MAX_SIGNALLING_DELAY = 300;
|
|
35
|
-
var ConnectionState = /* @__PURE__ */ function(ConnectionState5) {
|
|
22
|
+
var ConnectionState = /* @__PURE__ */ (function(ConnectionState5) {
|
|
36
23
|
ConnectionState5["CREATED"] = "CREATED";
|
|
37
24
|
ConnectionState5["INITIAL"] = "INITIAL";
|
|
38
25
|
ConnectionState5["CONNECTING"] = "CONNECTING";
|
|
@@ -42,8 +29,63 @@ var ConnectionState = /* @__PURE__ */ function(ConnectionState5) {
|
|
|
42
29
|
ConnectionState5["ABORTING"] = "ABORTING";
|
|
43
30
|
ConnectionState5["ABORTED"] = "ABORTED";
|
|
44
31
|
return ConnectionState5;
|
|
45
|
-
}({});
|
|
32
|
+
})({});
|
|
46
33
|
var Connection = class {
|
|
34
|
+
topic;
|
|
35
|
+
localInfo;
|
|
36
|
+
remoteInfo;
|
|
37
|
+
sessionId;
|
|
38
|
+
initiator;
|
|
39
|
+
_signalMessaging;
|
|
40
|
+
_protocol;
|
|
41
|
+
_transportFactory;
|
|
42
|
+
_callbacks;
|
|
43
|
+
_ctx = new Context(void 0, {
|
|
44
|
+
F: __dxlog_file,
|
|
45
|
+
L: 100
|
|
46
|
+
});
|
|
47
|
+
connectedTimeoutContext = new Context(void 0, {
|
|
48
|
+
F: __dxlog_file,
|
|
49
|
+
L: 101
|
|
50
|
+
});
|
|
51
|
+
_protocolClosed = new Trigger();
|
|
52
|
+
_transportClosed = new Trigger();
|
|
53
|
+
_state = "CREATED";
|
|
54
|
+
_transport;
|
|
55
|
+
closeReason;
|
|
56
|
+
_incomingSignalBuffer = [];
|
|
57
|
+
_outgoingSignalBuffer = [];
|
|
58
|
+
stateChanged = new Event();
|
|
59
|
+
errors = new ErrorStream();
|
|
60
|
+
_instanceId = PublicKey.random().toHex();
|
|
61
|
+
transportStats = new Event();
|
|
62
|
+
_signalSendTask = new DeferredTask(this._ctx, async () => {
|
|
63
|
+
await this._flushSignalBuffer();
|
|
64
|
+
});
|
|
65
|
+
_signallingDelay = STARTING_SIGNALLING_DELAY;
|
|
66
|
+
constructor(topic, localInfo, remoteInfo, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
|
|
67
|
+
this.topic = topic;
|
|
68
|
+
this.localInfo = localInfo;
|
|
69
|
+
this.remoteInfo = remoteInfo;
|
|
70
|
+
this.sessionId = sessionId;
|
|
71
|
+
this.initiator = initiator;
|
|
72
|
+
this._signalMessaging = _signalMessaging;
|
|
73
|
+
this._protocol = _protocol;
|
|
74
|
+
this._transportFactory = _transportFactory;
|
|
75
|
+
this._callbacks = _callbacks;
|
|
76
|
+
log.trace("dxos.mesh.connection.construct", {
|
|
77
|
+
sessionId: this.sessionId,
|
|
78
|
+
topic: this.topic,
|
|
79
|
+
localPeer: this.localInfo,
|
|
80
|
+
remotePeer: this.remoteInfo,
|
|
81
|
+
initiator: this.initiator
|
|
82
|
+
}, {
|
|
83
|
+
F: __dxlog_file,
|
|
84
|
+
L: 137,
|
|
85
|
+
S: this,
|
|
86
|
+
C: (f, a) => f(...a)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
47
89
|
get sessionIdString() {
|
|
48
90
|
return this.sessionId.truncate();
|
|
49
91
|
}
|
|
@@ -102,21 +144,25 @@ var Connection = class {
|
|
|
102
144
|
});
|
|
103
145
|
this._protocolClosed.wake();
|
|
104
146
|
this.close({
|
|
105
|
-
error: new ProtocolError(
|
|
147
|
+
error: new ProtocolError({
|
|
148
|
+
message: "protocol stream closed"
|
|
149
|
+
})
|
|
106
150
|
}).catch((err) => this.errors.raise(err));
|
|
107
151
|
});
|
|
108
152
|
scheduleTask(this.connectedTimeoutContext, async () => {
|
|
109
153
|
log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
110
154
|
F: __dxlog_file,
|
|
111
|
-
L:
|
|
155
|
+
L: 196,
|
|
112
156
|
S: this,
|
|
113
157
|
C: (f, a) => f(...a)
|
|
114
158
|
});
|
|
115
|
-
await this.abort(new TimeoutError(
|
|
159
|
+
await this.abort(new TimeoutError({
|
|
160
|
+
message: `${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect`
|
|
161
|
+
})).catch((err) => this.errors.raise(err));
|
|
116
162
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
117
163
|
invariant(!this._transport, void 0, {
|
|
118
164
|
F: __dxlog_file,
|
|
119
|
-
L:
|
|
165
|
+
L: 204,
|
|
120
166
|
S: this,
|
|
121
167
|
A: [
|
|
122
168
|
"!this._transport",
|
|
@@ -143,7 +189,7 @@ var Connection = class {
|
|
|
143
189
|
this._transportClosed.wake();
|
|
144
190
|
log("abort triggered by transport close", void 0, {
|
|
145
191
|
F: __dxlog_file,
|
|
146
|
-
L:
|
|
192
|
+
L: 226,
|
|
147
193
|
S: this,
|
|
148
194
|
C: (f, a) => f(...a)
|
|
149
195
|
});
|
|
@@ -154,7 +200,7 @@ var Connection = class {
|
|
|
154
200
|
err
|
|
155
201
|
}, {
|
|
156
202
|
F: __dxlog_file,
|
|
157
|
-
L:
|
|
203
|
+
L: 231,
|
|
158
204
|
S: this,
|
|
159
205
|
C: (f, a) => f(...a)
|
|
160
206
|
});
|
|
@@ -164,7 +210,7 @@ var Connection = class {
|
|
|
164
210
|
if (err instanceof ConnectionResetError) {
|
|
165
211
|
log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
166
212
|
F: __dxlog_file,
|
|
167
|
-
L:
|
|
213
|
+
L: 238,
|
|
168
214
|
S: this,
|
|
169
215
|
C: (f, a) => f(...a)
|
|
170
216
|
});
|
|
@@ -172,7 +218,7 @@ var Connection = class {
|
|
|
172
218
|
} else if (err instanceof ConnectivityError) {
|
|
173
219
|
log.info("aborting due to transport ConnectivityError", void 0, {
|
|
174
220
|
F: __dxlog_file,
|
|
175
|
-
L:
|
|
221
|
+
L: 241,
|
|
176
222
|
S: this,
|
|
177
223
|
C: (f, a) => f(...a)
|
|
178
224
|
});
|
|
@@ -192,7 +238,7 @@ var Connection = class {
|
|
|
192
238
|
id: this._instanceId
|
|
193
239
|
}), {
|
|
194
240
|
F: __dxlog_file,
|
|
195
|
-
L:
|
|
241
|
+
L: 260,
|
|
196
242
|
S: this,
|
|
197
243
|
C: (f, a) => f(...a)
|
|
198
244
|
});
|
|
@@ -202,14 +248,14 @@ var Connection = class {
|
|
|
202
248
|
err
|
|
203
249
|
}, {
|
|
204
250
|
F: __dxlog_file,
|
|
205
|
-
L:
|
|
251
|
+
L: 267,
|
|
206
252
|
S: this,
|
|
207
253
|
C: (f, a) => f(...a)
|
|
208
254
|
});
|
|
209
255
|
if (this._state === "CLOSED" || this._state === "ABORTED") {
|
|
210
256
|
log(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
211
257
|
F: __dxlog_file,
|
|
212
|
-
L:
|
|
258
|
+
L: 269,
|
|
213
259
|
S: this,
|
|
214
260
|
C: (f, a) => f(...a)
|
|
215
261
|
});
|
|
@@ -226,7 +272,7 @@ var Connection = class {
|
|
|
226
272
|
err
|
|
227
273
|
}, {
|
|
228
274
|
F: __dxlog_file,
|
|
229
|
-
L:
|
|
275
|
+
L: 281,
|
|
230
276
|
S: this,
|
|
231
277
|
C: (f, a) => f(...a)
|
|
232
278
|
});
|
|
@@ -237,7 +283,7 @@ var Connection = class {
|
|
|
237
283
|
} catch (err2) {
|
|
238
284
|
log.catch(err2, void 0, {
|
|
239
285
|
F: __dxlog_file,
|
|
240
|
-
L:
|
|
286
|
+
L: 287,
|
|
241
287
|
S: this,
|
|
242
288
|
C: (f, a) => f(...a)
|
|
243
289
|
});
|
|
@@ -247,7 +293,7 @@ var Connection = class {
|
|
|
247
293
|
} catch (err2) {
|
|
248
294
|
log.catch(err2, void 0, {
|
|
249
295
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
296
|
+
L: 294,
|
|
251
297
|
S: this,
|
|
252
298
|
C: (f, a) => f(...a)
|
|
253
299
|
});
|
|
@@ -257,7 +303,7 @@ var Connection = class {
|
|
|
257
303
|
} catch (err2) {
|
|
258
304
|
log.catch(err2, void 0, {
|
|
259
305
|
F: __dxlog_file,
|
|
260
|
-
L:
|
|
306
|
+
L: 300,
|
|
261
307
|
S: this,
|
|
262
308
|
C: (f, a) => f(...a)
|
|
263
309
|
});
|
|
@@ -269,7 +315,7 @@ var Connection = class {
|
|
|
269
315
|
error
|
|
270
316
|
}, {
|
|
271
317
|
F: __dxlog_file,
|
|
272
|
-
L:
|
|
318
|
+
L: 307,
|
|
273
319
|
S: this,
|
|
274
320
|
C: (f, a) => f(...a)
|
|
275
321
|
});
|
|
@@ -284,7 +330,7 @@ var Connection = class {
|
|
|
284
330
|
error
|
|
285
331
|
}, {
|
|
286
332
|
F: __dxlog_file,
|
|
287
|
-
L:
|
|
333
|
+
L: 318,
|
|
288
334
|
S: this,
|
|
289
335
|
C: (f, a) => f(...a)
|
|
290
336
|
});
|
|
@@ -298,7 +344,7 @@ var Connection = class {
|
|
|
298
344
|
if (lastState !== "CONNECTED" || error != null) {
|
|
299
345
|
log(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
300
346
|
F: __dxlog_file,
|
|
301
|
-
L:
|
|
347
|
+
L: 329,
|
|
302
348
|
S: this,
|
|
303
349
|
C: (f, a) => f(...a)
|
|
304
350
|
});
|
|
@@ -310,7 +356,7 @@ var Connection = class {
|
|
|
310
356
|
error
|
|
311
357
|
}, {
|
|
312
358
|
F: __dxlog_file,
|
|
313
|
-
L:
|
|
359
|
+
L: 333,
|
|
314
360
|
S: this,
|
|
315
361
|
C: (f, a) => f(...a)
|
|
316
362
|
});
|
|
@@ -321,7 +367,7 @@ var Connection = class {
|
|
|
321
367
|
} catch (err) {
|
|
322
368
|
log.catch(err, void 0, {
|
|
323
369
|
F: __dxlog_file,
|
|
324
|
-
L:
|
|
370
|
+
L: 338,
|
|
325
371
|
S: this,
|
|
326
372
|
C: (f, a) => f(...a)
|
|
327
373
|
});
|
|
@@ -331,7 +377,7 @@ var Connection = class {
|
|
|
331
377
|
} catch (err) {
|
|
332
378
|
log.catch(err, void 0, {
|
|
333
379
|
F: __dxlog_file,
|
|
334
|
-
L:
|
|
380
|
+
L: 344,
|
|
335
381
|
S: this,
|
|
336
382
|
C: (f, a) => f(...a)
|
|
337
383
|
});
|
|
@@ -340,7 +386,7 @@ var Connection = class {
|
|
|
340
386
|
peerId: this.localInfo
|
|
341
387
|
}, {
|
|
342
388
|
F: __dxlog_file,
|
|
343
|
-
L:
|
|
389
|
+
L: 347,
|
|
344
390
|
S: this,
|
|
345
391
|
C: (f, a) => f(...a)
|
|
346
392
|
});
|
|
@@ -350,7 +396,7 @@ var Connection = class {
|
|
|
350
396
|
async _closeProtocol(options) {
|
|
351
397
|
log("closing protocol", options, {
|
|
352
398
|
F: __dxlog_file,
|
|
353
|
-
L:
|
|
399
|
+
L: 353,
|
|
354
400
|
S: this,
|
|
355
401
|
C: (f, a) => f(...a)
|
|
356
402
|
});
|
|
@@ -360,7 +406,7 @@ var Connection = class {
|
|
|
360
406
|
]);
|
|
361
407
|
log("protocol closed", options, {
|
|
362
408
|
F: __dxlog_file,
|
|
363
|
-
L:
|
|
409
|
+
L: 355,
|
|
364
410
|
S: this,
|
|
365
411
|
C: (f, a) => f(...a)
|
|
366
412
|
});
|
|
@@ -368,7 +414,7 @@ var Connection = class {
|
|
|
368
414
|
async _closeTransport() {
|
|
369
415
|
log("closing transport", void 0, {
|
|
370
416
|
F: __dxlog_file,
|
|
371
|
-
L:
|
|
417
|
+
L: 359,
|
|
372
418
|
S: this,
|
|
373
419
|
C: (f, a) => f(...a)
|
|
374
420
|
});
|
|
@@ -378,7 +424,7 @@ var Connection = class {
|
|
|
378
424
|
]);
|
|
379
425
|
log("transport closed", void 0, {
|
|
380
426
|
F: __dxlog_file,
|
|
381
|
-
L:
|
|
427
|
+
L: 361,
|
|
382
428
|
S: this,
|
|
383
429
|
C: (f, a) => f(...a)
|
|
384
430
|
});
|
|
@@ -419,12 +465,15 @@ var Connection = class {
|
|
|
419
465
|
err
|
|
420
466
|
}, {
|
|
421
467
|
F: __dxlog_file,
|
|
422
|
-
L:
|
|
468
|
+
L: 401,
|
|
423
469
|
S: this,
|
|
424
470
|
C: (f, a) => f(...a)
|
|
425
471
|
});
|
|
426
472
|
await this.close({
|
|
427
|
-
error: new ConnectivityError(
|
|
473
|
+
error: new ConnectivityError({
|
|
474
|
+
message: "signal message failed to deliver",
|
|
475
|
+
cause: err
|
|
476
|
+
})
|
|
428
477
|
});
|
|
429
478
|
}
|
|
430
479
|
}
|
|
@@ -434,7 +483,7 @@ var Connection = class {
|
|
|
434
483
|
async signal(msg) {
|
|
435
484
|
invariant(msg.sessionId, void 0, {
|
|
436
485
|
F: __dxlog_file,
|
|
437
|
-
L:
|
|
486
|
+
L: 410,
|
|
438
487
|
S: this,
|
|
439
488
|
A: [
|
|
440
489
|
"msg.sessionId",
|
|
@@ -444,7 +493,7 @@ var Connection = class {
|
|
|
444
493
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
445
494
|
log("dropping signal for incorrect session id", void 0, {
|
|
446
495
|
F: __dxlog_file,
|
|
447
|
-
L:
|
|
496
|
+
L: 412,
|
|
448
497
|
S: this,
|
|
449
498
|
C: (f, a) => f(...a)
|
|
450
499
|
});
|
|
@@ -452,7 +501,7 @@ var Connection = class {
|
|
|
452
501
|
}
|
|
453
502
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
454
503
|
F: __dxlog_file,
|
|
455
|
-
L:
|
|
504
|
+
L: 415,
|
|
456
505
|
S: this,
|
|
457
506
|
A: [
|
|
458
507
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -461,7 +510,7 @@ var Connection = class {
|
|
|
461
510
|
});
|
|
462
511
|
invariant(msg.author.peerKey === this.remoteInfo.peerKey, void 0, {
|
|
463
512
|
F: __dxlog_file,
|
|
464
|
-
L:
|
|
513
|
+
L: 416,
|
|
465
514
|
S: this,
|
|
466
515
|
A: [
|
|
467
516
|
"msg.author.peerKey === this.remoteInfo.peerKey",
|
|
@@ -470,7 +519,7 @@ var Connection = class {
|
|
|
470
519
|
});
|
|
471
520
|
invariant(msg.recipient.peerKey === this.localInfo.peerKey, void 0, {
|
|
472
521
|
F: __dxlog_file,
|
|
473
|
-
L:
|
|
522
|
+
L: 417,
|
|
474
523
|
S: this,
|
|
475
524
|
A: [
|
|
476
525
|
"msg.recipient.peerKey === this.localInfo.peerKey",
|
|
@@ -494,7 +543,7 @@ var Connection = class {
|
|
|
494
543
|
msg: msg.data
|
|
495
544
|
}, {
|
|
496
545
|
F: __dxlog_file,
|
|
497
|
-
L:
|
|
546
|
+
L: 426,
|
|
498
547
|
S: this,
|
|
499
548
|
C: (f, a) => f(...a)
|
|
500
549
|
});
|
|
@@ -502,7 +551,7 @@ var Connection = class {
|
|
|
502
551
|
} else {
|
|
503
552
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
504
553
|
F: __dxlog_file,
|
|
505
|
-
L:
|
|
554
|
+
L: 429,
|
|
506
555
|
S: this,
|
|
507
556
|
A: [
|
|
508
557
|
"this._transport",
|
|
@@ -515,7 +564,7 @@ var Connection = class {
|
|
|
515
564
|
msg: msg.data
|
|
516
565
|
}, {
|
|
517
566
|
F: __dxlog_file,
|
|
518
|
-
L:
|
|
567
|
+
L: 430,
|
|
519
568
|
S: this,
|
|
520
569
|
C: (f, a) => f(...a)
|
|
521
570
|
});
|
|
@@ -533,13 +582,13 @@ var Connection = class {
|
|
|
533
582
|
peerId: this.localInfo
|
|
534
583
|
}, {
|
|
535
584
|
F: __dxlog_file,
|
|
536
|
-
L:
|
|
585
|
+
L: 441,
|
|
537
586
|
S: this,
|
|
538
587
|
C: (f, a) => f(...a)
|
|
539
588
|
});
|
|
540
589
|
invariant(state !== this._state, "Already in this state.", {
|
|
541
590
|
F: __dxlog_file,
|
|
542
|
-
L:
|
|
591
|
+
L: 442,
|
|
543
592
|
S: this,
|
|
544
593
|
A: [
|
|
545
594
|
"state !== this._state",
|
|
@@ -555,74 +604,6 @@ var Connection = class {
|
|
|
555
604
|
this.transportStats.emit(stats);
|
|
556
605
|
}
|
|
557
606
|
}
|
|
558
|
-
constructor(topic, localInfo, remoteInfo, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
|
|
559
|
-
_define_property(this, "topic", void 0);
|
|
560
|
-
_define_property(this, "localInfo", void 0);
|
|
561
|
-
_define_property(this, "remoteInfo", void 0);
|
|
562
|
-
_define_property(this, "sessionId", void 0);
|
|
563
|
-
_define_property(this, "initiator", void 0);
|
|
564
|
-
_define_property(this, "_signalMessaging", void 0);
|
|
565
|
-
_define_property(this, "_protocol", void 0);
|
|
566
|
-
_define_property(this, "_transportFactory", void 0);
|
|
567
|
-
_define_property(this, "_callbacks", void 0);
|
|
568
|
-
_define_property(this, "_ctx", void 0);
|
|
569
|
-
_define_property(this, "connectedTimeoutContext", void 0);
|
|
570
|
-
_define_property(this, "_protocolClosed", void 0);
|
|
571
|
-
_define_property(this, "_transportClosed", void 0);
|
|
572
|
-
_define_property(this, "_state", void 0);
|
|
573
|
-
_define_property(this, "_transport", void 0);
|
|
574
|
-
_define_property(this, "closeReason", void 0);
|
|
575
|
-
_define_property(this, "_incomingSignalBuffer", void 0);
|
|
576
|
-
_define_property(this, "_outgoingSignalBuffer", void 0);
|
|
577
|
-
_define_property(this, "stateChanged", void 0);
|
|
578
|
-
_define_property(this, "errors", void 0);
|
|
579
|
-
_define_property(this, "_instanceId", void 0);
|
|
580
|
-
_define_property(this, "transportStats", void 0);
|
|
581
|
-
_define_property(this, "_signalSendTask", void 0);
|
|
582
|
-
_define_property(this, "_signallingDelay", void 0);
|
|
583
|
-
this.topic = topic;
|
|
584
|
-
this.localInfo = localInfo;
|
|
585
|
-
this.remoteInfo = remoteInfo;
|
|
586
|
-
this.sessionId = sessionId;
|
|
587
|
-
this.initiator = initiator;
|
|
588
|
-
this._signalMessaging = _signalMessaging;
|
|
589
|
-
this._protocol = _protocol;
|
|
590
|
-
this._transportFactory = _transportFactory;
|
|
591
|
-
this._callbacks = _callbacks;
|
|
592
|
-
this._ctx = new Context(void 0, {
|
|
593
|
-
F: __dxlog_file,
|
|
594
|
-
L: 100
|
|
595
|
-
});
|
|
596
|
-
this.connectedTimeoutContext = new Context(void 0, {
|
|
597
|
-
F: __dxlog_file,
|
|
598
|
-
L: 101
|
|
599
|
-
});
|
|
600
|
-
this._protocolClosed = new Trigger();
|
|
601
|
-
this._transportClosed = new Trigger();
|
|
602
|
-
this._state = "CREATED";
|
|
603
|
-
this._incomingSignalBuffer = [];
|
|
604
|
-
this._outgoingSignalBuffer = [];
|
|
605
|
-
this.stateChanged = new Event();
|
|
606
|
-
this.errors = new ErrorStream();
|
|
607
|
-
this._instanceId = PublicKey.random().toHex();
|
|
608
|
-
this.transportStats = new Event();
|
|
609
|
-
this._signalSendTask = new DeferredTask(this._ctx, async () => {
|
|
610
|
-
await this._flushSignalBuffer();
|
|
611
|
-
});
|
|
612
|
-
this._signallingDelay = STARTING_SIGNALLING_DELAY;
|
|
613
|
-
log.trace("dxos.mesh.connection.construct", {
|
|
614
|
-
sessionId: this.sessionId,
|
|
615
|
-
topic: this.topic,
|
|
616
|
-
localPeer: this.localInfo,
|
|
617
|
-
remotePeer: this.remoteInfo,
|
|
618
|
-
initiator: this.initiator
|
|
619
|
-
}, {
|
|
620
|
-
F: __dxlog_file,
|
|
621
|
-
L: 137,
|
|
622
|
-
S: this,
|
|
623
|
-
C: (f, a) => f(...a)
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
607
|
};
|
|
627
608
|
_ts_decorate([
|
|
628
609
|
logInfo
|
|
@@ -675,22 +656,24 @@ import { log as log3 } from "@dxos/log";
|
|
|
675
656
|
import { TimeoutError as TimeoutError2 } from "@dxos/protocols";
|
|
676
657
|
import { schema } from "@dxos/protocols/proto";
|
|
677
658
|
import { ComplexMap } from "@dxos/util";
|
|
678
|
-
function _define_property2(obj, key, value) {
|
|
679
|
-
if (key in obj) {
|
|
680
|
-
Object.defineProperty(obj, key, {
|
|
681
|
-
value,
|
|
682
|
-
enumerable: true,
|
|
683
|
-
configurable: true,
|
|
684
|
-
writable: true
|
|
685
|
-
});
|
|
686
|
-
} else {
|
|
687
|
-
obj[key] = value;
|
|
688
|
-
}
|
|
689
|
-
return obj;
|
|
690
|
-
}
|
|
691
659
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
692
660
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
693
661
|
var SwarmMessenger = class {
|
|
662
|
+
_ctx = new Context2(void 0, {
|
|
663
|
+
F: __dxlog_file3,
|
|
664
|
+
L: 35
|
|
665
|
+
});
|
|
666
|
+
_sendMessage;
|
|
667
|
+
_onSignal;
|
|
668
|
+
_onOffer;
|
|
669
|
+
_topic;
|
|
670
|
+
_offerRecords = new ComplexMap((key) => key.toHex());
|
|
671
|
+
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
672
|
+
this._sendMessage = sendMessage;
|
|
673
|
+
this._onSignal = onSignal;
|
|
674
|
+
this._onOffer = onOffer;
|
|
675
|
+
this._topic = topic;
|
|
676
|
+
}
|
|
694
677
|
async receiveMessage({ author, recipient, payload }) {
|
|
695
678
|
if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
|
|
696
679
|
return;
|
|
@@ -914,21 +897,6 @@ var SwarmMessenger = class {
|
|
|
914
897
|
};
|
|
915
898
|
await this._onSignal(signalMessage);
|
|
916
899
|
}
|
|
917
|
-
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
918
|
-
_define_property2(this, "_ctx", new Context2(void 0, {
|
|
919
|
-
F: __dxlog_file3,
|
|
920
|
-
L: 35
|
|
921
|
-
}));
|
|
922
|
-
_define_property2(this, "_sendMessage", void 0);
|
|
923
|
-
_define_property2(this, "_onSignal", void 0);
|
|
924
|
-
_define_property2(this, "_onOffer", void 0);
|
|
925
|
-
_define_property2(this, "_topic", void 0);
|
|
926
|
-
_define_property2(this, "_offerRecords", new ComplexMap((key) => key.toHex()));
|
|
927
|
-
this._sendMessage = sendMessage;
|
|
928
|
-
this._onSignal = onSignal;
|
|
929
|
-
this._onOffer = onOffer;
|
|
930
|
-
this._topic = topic;
|
|
931
|
-
}
|
|
932
900
|
};
|
|
933
901
|
|
|
934
902
|
// src/swarm/swarm.ts
|
|
@@ -949,19 +917,6 @@ import { invariant as invariant3 } from "@dxos/invariant";
|
|
|
949
917
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
950
918
|
import { log as log4 } from "@dxos/log";
|
|
951
919
|
import { CancelledError as CancelledError2, SystemError } from "@dxos/protocols";
|
|
952
|
-
function _define_property3(obj, key, value) {
|
|
953
|
-
if (key in obj) {
|
|
954
|
-
Object.defineProperty(obj, key, {
|
|
955
|
-
value,
|
|
956
|
-
enumerable: true,
|
|
957
|
-
configurable: true,
|
|
958
|
-
writable: true
|
|
959
|
-
});
|
|
960
|
-
} else {
|
|
961
|
-
obj[key] = value;
|
|
962
|
-
}
|
|
963
|
-
return obj;
|
|
964
|
-
}
|
|
965
920
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
966
921
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
967
922
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -971,11 +926,49 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
971
926
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
972
927
|
var ConnectionDisplacedError = class extends SystemError {
|
|
973
928
|
constructor() {
|
|
974
|
-
super(
|
|
929
|
+
super({
|
|
930
|
+
message: "Connection displaced by remote initiator."
|
|
931
|
+
});
|
|
975
932
|
}
|
|
976
933
|
};
|
|
977
934
|
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
978
935
|
var Peer = class {
|
|
936
|
+
remoteInfo;
|
|
937
|
+
topic;
|
|
938
|
+
localInfo;
|
|
939
|
+
_signalMessaging;
|
|
940
|
+
_protocolProvider;
|
|
941
|
+
_transportFactory;
|
|
942
|
+
_connectionLimiter;
|
|
943
|
+
_callbacks;
|
|
944
|
+
/**
|
|
945
|
+
* Will be available to connect after this time.
|
|
946
|
+
*/
|
|
947
|
+
_availableAfter = 0;
|
|
948
|
+
availableToConnect = true;
|
|
949
|
+
_lastConnectionTime;
|
|
950
|
+
_ctx = new Context3(void 0, {
|
|
951
|
+
F: __dxlog_file4,
|
|
952
|
+
L: 81
|
|
953
|
+
});
|
|
954
|
+
_connectionCtx;
|
|
955
|
+
connection;
|
|
956
|
+
/**
|
|
957
|
+
* Whether the peer is currently advertizing itself on the signal-network.
|
|
958
|
+
*/
|
|
959
|
+
advertizing = false;
|
|
960
|
+
initiating = false;
|
|
961
|
+
connectionDisplaced = new Event2();
|
|
962
|
+
constructor(remoteInfo, topic, localInfo, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
963
|
+
this.remoteInfo = remoteInfo;
|
|
964
|
+
this.topic = topic;
|
|
965
|
+
this.localInfo = localInfo;
|
|
966
|
+
this._signalMessaging = _signalMessaging;
|
|
967
|
+
this._protocolProvider = _protocolProvider;
|
|
968
|
+
this._transportFactory = _transportFactory;
|
|
969
|
+
this._connectionLimiter = _connectionLimiter;
|
|
970
|
+
this._callbacks = _callbacks;
|
|
971
|
+
}
|
|
979
972
|
/**
|
|
980
973
|
* Respond to remote offer.
|
|
981
974
|
*/
|
|
@@ -1412,42 +1405,6 @@ var Peer = class {
|
|
|
1412
1405
|
reason
|
|
1413
1406
|
});
|
|
1414
1407
|
}
|
|
1415
|
-
constructor(remoteInfo, topic, localInfo, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
1416
|
-
_define_property3(this, "remoteInfo", void 0);
|
|
1417
|
-
_define_property3(this, "topic", void 0);
|
|
1418
|
-
_define_property3(this, "localInfo", void 0);
|
|
1419
|
-
_define_property3(this, "_signalMessaging", void 0);
|
|
1420
|
-
_define_property3(this, "_protocolProvider", void 0);
|
|
1421
|
-
_define_property3(this, "_transportFactory", void 0);
|
|
1422
|
-
_define_property3(this, "_connectionLimiter", void 0);
|
|
1423
|
-
_define_property3(this, "_callbacks", void 0);
|
|
1424
|
-
_define_property3(this, "_availableAfter", void 0);
|
|
1425
|
-
_define_property3(this, "availableToConnect", void 0);
|
|
1426
|
-
_define_property3(this, "_lastConnectionTime", void 0);
|
|
1427
|
-
_define_property3(this, "_ctx", void 0);
|
|
1428
|
-
_define_property3(this, "_connectionCtx", void 0);
|
|
1429
|
-
_define_property3(this, "connection", void 0);
|
|
1430
|
-
_define_property3(this, "advertizing", void 0);
|
|
1431
|
-
_define_property3(this, "initiating", void 0);
|
|
1432
|
-
_define_property3(this, "connectionDisplaced", void 0);
|
|
1433
|
-
this.remoteInfo = remoteInfo;
|
|
1434
|
-
this.topic = topic;
|
|
1435
|
-
this.localInfo = localInfo;
|
|
1436
|
-
this._signalMessaging = _signalMessaging;
|
|
1437
|
-
this._protocolProvider = _protocolProvider;
|
|
1438
|
-
this._transportFactory = _transportFactory;
|
|
1439
|
-
this._connectionLimiter = _connectionLimiter;
|
|
1440
|
-
this._callbacks = _callbacks;
|
|
1441
|
-
this._availableAfter = 0;
|
|
1442
|
-
this.availableToConnect = true;
|
|
1443
|
-
this._ctx = new Context3(void 0, {
|
|
1444
|
-
F: __dxlog_file4,
|
|
1445
|
-
L: 81
|
|
1446
|
-
});
|
|
1447
|
-
this.advertizing = false;
|
|
1448
|
-
this.initiating = false;
|
|
1449
|
-
this.connectionDisplaced = new Event2();
|
|
1450
|
-
}
|
|
1451
1408
|
};
|
|
1452
1409
|
_ts_decorate2([
|
|
1453
1410
|
synchronized2
|
|
@@ -1466,19 +1423,6 @@ var increaseInterval = (interval) => {
|
|
|
1466
1423
|
};
|
|
1467
1424
|
|
|
1468
1425
|
// src/swarm/swarm.ts
|
|
1469
|
-
function _define_property4(obj, key, value) {
|
|
1470
|
-
if (key in obj) {
|
|
1471
|
-
Object.defineProperty(obj, key, {
|
|
1472
|
-
value,
|
|
1473
|
-
enumerable: true,
|
|
1474
|
-
configurable: true,
|
|
1475
|
-
writable: true
|
|
1476
|
-
});
|
|
1477
|
-
} else {
|
|
1478
|
-
obj[key] = value;
|
|
1479
|
-
}
|
|
1480
|
-
return obj;
|
|
1481
|
-
}
|
|
1482
1426
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
1483
1427
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1484
1428
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1489,6 +1433,94 @@ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm
|
|
|
1489
1433
|
var INITIATION_DELAY = 100;
|
|
1490
1434
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1491
1435
|
var Swarm = class {
|
|
1436
|
+
_topic;
|
|
1437
|
+
_ownPeer;
|
|
1438
|
+
_topology;
|
|
1439
|
+
_protocolProvider;
|
|
1440
|
+
_messenger;
|
|
1441
|
+
_transportFactory;
|
|
1442
|
+
_label;
|
|
1443
|
+
_connectionLimiter;
|
|
1444
|
+
_initiationDelay;
|
|
1445
|
+
_swarmMessenger;
|
|
1446
|
+
_ctx = new Context4(void 0, {
|
|
1447
|
+
F: __dxlog_file5,
|
|
1448
|
+
L: 39
|
|
1449
|
+
});
|
|
1450
|
+
_listeningHandle = void 0;
|
|
1451
|
+
/**
|
|
1452
|
+
* PeerInfo -> Peer.
|
|
1453
|
+
* @internal
|
|
1454
|
+
*/
|
|
1455
|
+
_peers = new ComplexMap2(PeerInfoHash);
|
|
1456
|
+
/**
|
|
1457
|
+
* Unique id of the swarm, local to the current peer, generated when swarm is joined.
|
|
1458
|
+
*/
|
|
1459
|
+
_instanceId = PublicKey4.random().toHex();
|
|
1460
|
+
/**
|
|
1461
|
+
* New connection to a peer is started.
|
|
1462
|
+
* @internal
|
|
1463
|
+
*/
|
|
1464
|
+
connectionAdded = new Event3();
|
|
1465
|
+
/**
|
|
1466
|
+
* Connection to a peer is dropped.
|
|
1467
|
+
* @internal
|
|
1468
|
+
*/
|
|
1469
|
+
disconnected = new Event3();
|
|
1470
|
+
/**
|
|
1471
|
+
* Connection is established to a new peer.
|
|
1472
|
+
* @internal
|
|
1473
|
+
*/
|
|
1474
|
+
connected = new Event3();
|
|
1475
|
+
errors = new ErrorStream2();
|
|
1476
|
+
// TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
|
|
1477
|
+
// TODO(burdon): Pass in object.
|
|
1478
|
+
constructor(_topic, _ownPeer, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
|
|
1479
|
+
this._topic = _topic;
|
|
1480
|
+
this._ownPeer = _ownPeer;
|
|
1481
|
+
this._topology = _topology;
|
|
1482
|
+
this._protocolProvider = _protocolProvider;
|
|
1483
|
+
this._messenger = _messenger;
|
|
1484
|
+
this._transportFactory = _transportFactory;
|
|
1485
|
+
this._label = _label;
|
|
1486
|
+
this._connectionLimiter = _connectionLimiter;
|
|
1487
|
+
this._initiationDelay = _initiationDelay;
|
|
1488
|
+
log5.trace("dxos.mesh.swarm.constructor", trace2.begin({
|
|
1489
|
+
id: this._instanceId,
|
|
1490
|
+
data: {
|
|
1491
|
+
topic: this._topic.toHex(),
|
|
1492
|
+
peer: this._ownPeer
|
|
1493
|
+
}
|
|
1494
|
+
}), {
|
|
1495
|
+
F: __dxlog_file5,
|
|
1496
|
+
L: 89,
|
|
1497
|
+
S: this,
|
|
1498
|
+
C: (f, a) => f(...a)
|
|
1499
|
+
});
|
|
1500
|
+
log5("creating swarm", {
|
|
1501
|
+
peerId: _ownPeer
|
|
1502
|
+
}, {
|
|
1503
|
+
F: __dxlog_file5,
|
|
1504
|
+
L: 93,
|
|
1505
|
+
S: this,
|
|
1506
|
+
C: (f, a) => f(...a)
|
|
1507
|
+
});
|
|
1508
|
+
_topology.init(this._getSwarmController());
|
|
1509
|
+
this._swarmMessenger = new SwarmMessenger({
|
|
1510
|
+
sendMessage: async (msg) => await this._messenger.sendMessage(msg),
|
|
1511
|
+
onSignal: async (msg) => await this.onSignal(msg),
|
|
1512
|
+
onOffer: async (msg) => await this.onOffer(msg),
|
|
1513
|
+
topic: this._topic
|
|
1514
|
+
});
|
|
1515
|
+
log5.trace("dxos.mesh.swarm.constructor", trace2.end({
|
|
1516
|
+
id: this._instanceId
|
|
1517
|
+
}), {
|
|
1518
|
+
F: __dxlog_file5,
|
|
1519
|
+
L: 102,
|
|
1520
|
+
S: this,
|
|
1521
|
+
C: (f, a) => f(...a)
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1492
1524
|
get connections() {
|
|
1493
1525
|
return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNonNullable2);
|
|
1494
1526
|
}
|
|
@@ -1963,83 +1995,6 @@ var Swarm = class {
|
|
|
1963
1995
|
_isUnregistered(peer) {
|
|
1964
1996
|
return !peer || this._peers.get(peer.remoteInfo) !== peer;
|
|
1965
1997
|
}
|
|
1966
|
-
// TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
|
|
1967
|
-
// TODO(burdon): Pass in object.
|
|
1968
|
-
constructor(_topic, _ownPeer, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
|
|
1969
|
-
_define_property4(this, "_topic", void 0);
|
|
1970
|
-
_define_property4(this, "_ownPeer", void 0);
|
|
1971
|
-
_define_property4(this, "_topology", void 0);
|
|
1972
|
-
_define_property4(this, "_protocolProvider", void 0);
|
|
1973
|
-
_define_property4(this, "_messenger", void 0);
|
|
1974
|
-
_define_property4(this, "_transportFactory", void 0);
|
|
1975
|
-
_define_property4(this, "_label", void 0);
|
|
1976
|
-
_define_property4(this, "_connectionLimiter", void 0);
|
|
1977
|
-
_define_property4(this, "_initiationDelay", void 0);
|
|
1978
|
-
_define_property4(this, "_swarmMessenger", void 0);
|
|
1979
|
-
_define_property4(this, "_ctx", void 0);
|
|
1980
|
-
_define_property4(this, "_listeningHandle", void 0);
|
|
1981
|
-
_define_property4(this, "_peers", void 0);
|
|
1982
|
-
_define_property4(this, "_instanceId", void 0);
|
|
1983
|
-
_define_property4(this, "connectionAdded", void 0);
|
|
1984
|
-
_define_property4(this, "disconnected", void 0);
|
|
1985
|
-
_define_property4(this, "connected", void 0);
|
|
1986
|
-
_define_property4(this, "errors", void 0);
|
|
1987
|
-
this._topic = _topic;
|
|
1988
|
-
this._ownPeer = _ownPeer;
|
|
1989
|
-
this._topology = _topology;
|
|
1990
|
-
this._protocolProvider = _protocolProvider;
|
|
1991
|
-
this._messenger = _messenger;
|
|
1992
|
-
this._transportFactory = _transportFactory;
|
|
1993
|
-
this._label = _label;
|
|
1994
|
-
this._connectionLimiter = _connectionLimiter;
|
|
1995
|
-
this._initiationDelay = _initiationDelay;
|
|
1996
|
-
this._ctx = new Context4(void 0, {
|
|
1997
|
-
F: __dxlog_file5,
|
|
1998
|
-
L: 39
|
|
1999
|
-
});
|
|
2000
|
-
this._listeningHandle = void 0;
|
|
2001
|
-
this._peers = new ComplexMap2(PeerInfoHash);
|
|
2002
|
-
this._instanceId = PublicKey4.random().toHex();
|
|
2003
|
-
this.connectionAdded = new Event3();
|
|
2004
|
-
this.disconnected = new Event3();
|
|
2005
|
-
this.connected = new Event3();
|
|
2006
|
-
this.errors = new ErrorStream2();
|
|
2007
|
-
log5.trace("dxos.mesh.swarm.constructor", trace2.begin({
|
|
2008
|
-
id: this._instanceId,
|
|
2009
|
-
data: {
|
|
2010
|
-
topic: this._topic.toHex(),
|
|
2011
|
-
peer: this._ownPeer
|
|
2012
|
-
}
|
|
2013
|
-
}), {
|
|
2014
|
-
F: __dxlog_file5,
|
|
2015
|
-
L: 89,
|
|
2016
|
-
S: this,
|
|
2017
|
-
C: (f, a) => f(...a)
|
|
2018
|
-
});
|
|
2019
|
-
log5("creating swarm", {
|
|
2020
|
-
peerId: _ownPeer
|
|
2021
|
-
}, {
|
|
2022
|
-
F: __dxlog_file5,
|
|
2023
|
-
L: 93,
|
|
2024
|
-
S: this,
|
|
2025
|
-
C: (f, a) => f(...a)
|
|
2026
|
-
});
|
|
2027
|
-
_topology.init(this._getSwarmController());
|
|
2028
|
-
this._swarmMessenger = new SwarmMessenger({
|
|
2029
|
-
sendMessage: async (msg) => await this._messenger.sendMessage(msg),
|
|
2030
|
-
onSignal: async (msg) => await this.onSignal(msg),
|
|
2031
|
-
onOffer: async (msg) => await this.onOffer(msg),
|
|
2032
|
-
topic: this._topic
|
|
2033
|
-
});
|
|
2034
|
-
log5.trace("dxos.mesh.swarm.constructor", trace2.end({
|
|
2035
|
-
id: this._instanceId
|
|
2036
|
-
}), {
|
|
2037
|
-
F: __dxlog_file5,
|
|
2038
|
-
L: 102,
|
|
2039
|
-
S: this,
|
|
2040
|
-
C: (f, a) => f(...a)
|
|
2041
|
-
});
|
|
2042
|
-
}
|
|
2043
1998
|
};
|
|
2044
1999
|
_ts_decorate3([
|
|
2045
2000
|
logInfo2
|
|
@@ -2069,24 +2024,31 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
|
2069
2024
|
import { log as log6 } from "@dxos/log";
|
|
2070
2025
|
import { PeerInfoHash as PeerInfoHash2 } from "@dxos/messaging";
|
|
2071
2026
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
2072
|
-
function _define_property5(obj, key, value) {
|
|
2073
|
-
if (key in obj) {
|
|
2074
|
-
Object.defineProperty(obj, key, {
|
|
2075
|
-
value,
|
|
2076
|
-
enumerable: true,
|
|
2077
|
-
configurable: true,
|
|
2078
|
-
writable: true
|
|
2079
|
-
});
|
|
2080
|
-
} else {
|
|
2081
|
-
obj[key] = value;
|
|
2082
|
-
}
|
|
2083
|
-
return obj;
|
|
2084
|
-
}
|
|
2085
2027
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
2086
2028
|
var SwarmMapper = class {
|
|
2029
|
+
_swarm;
|
|
2030
|
+
_subscriptions = new SubscriptionList();
|
|
2031
|
+
_connectionSubscriptions = new ComplexMap3(PeerInfoHash2);
|
|
2032
|
+
_peers = new ComplexMap3(PeerInfoHash2);
|
|
2033
|
+
mapUpdated = new Event4();
|
|
2087
2034
|
get peers() {
|
|
2088
2035
|
return Array.from(this._peers.values());
|
|
2089
2036
|
}
|
|
2037
|
+
constructor(_swarm) {
|
|
2038
|
+
this._swarm = _swarm;
|
|
2039
|
+
this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
|
|
2040
|
+
this._update();
|
|
2041
|
+
this._connectionSubscriptions.set(connection.remoteInfo, connection.stateChanged.on(() => {
|
|
2042
|
+
this._update();
|
|
2043
|
+
}));
|
|
2044
|
+
}));
|
|
2045
|
+
this._subscriptions.add(_swarm.disconnected.on((peerId) => {
|
|
2046
|
+
this._connectionSubscriptions.get(peerId)?.();
|
|
2047
|
+
this._connectionSubscriptions.delete(peerId);
|
|
2048
|
+
this._update();
|
|
2049
|
+
}));
|
|
2050
|
+
this._update();
|
|
2051
|
+
}
|
|
2090
2052
|
_update() {
|
|
2091
2053
|
log6("updating swarm", void 0, {
|
|
2092
2054
|
F: __dxlog_file6,
|
|
@@ -2126,30 +2088,6 @@ var SwarmMapper = class {
|
|
|
2126
2088
|
this._connectionSubscriptions.clear();
|
|
2127
2089
|
this._subscriptions.clear();
|
|
2128
2090
|
}
|
|
2129
|
-
constructor(_swarm) {
|
|
2130
|
-
_define_property5(this, "_swarm", void 0);
|
|
2131
|
-
_define_property5(this, "_subscriptions", void 0);
|
|
2132
|
-
_define_property5(this, "_connectionSubscriptions", void 0);
|
|
2133
|
-
_define_property5(this, "_peers", void 0);
|
|
2134
|
-
_define_property5(this, "mapUpdated", void 0);
|
|
2135
|
-
this._swarm = _swarm;
|
|
2136
|
-
this._subscriptions = new SubscriptionList();
|
|
2137
|
-
this._connectionSubscriptions = new ComplexMap3(PeerInfoHash2);
|
|
2138
|
-
this._peers = new ComplexMap3(PeerInfoHash2);
|
|
2139
|
-
this.mapUpdated = new Event4();
|
|
2140
|
-
this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
|
|
2141
|
-
this._update();
|
|
2142
|
-
this._connectionSubscriptions.set(connection.remoteInfo, connection.stateChanged.on(() => {
|
|
2143
|
-
this._update();
|
|
2144
|
-
}));
|
|
2145
|
-
}));
|
|
2146
|
-
this._subscriptions.add(_swarm.disconnected.on((peerId) => {
|
|
2147
|
-
this._connectionSubscriptions.get(peerId)?.();
|
|
2148
|
-
this._connectionSubscriptions.delete(peerId);
|
|
2149
|
-
this._update();
|
|
2150
|
-
}));
|
|
2151
|
-
this._update();
|
|
2152
|
-
}
|
|
2153
2091
|
};
|
|
2154
2092
|
|
|
2155
2093
|
// src/swarm/connection-limiter.ts
|
|
@@ -2160,22 +2098,26 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
2160
2098
|
import { log as log7 } from "@dxos/log";
|
|
2161
2099
|
import { CancelledError as CancelledError3 } from "@dxos/protocols";
|
|
2162
2100
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
2163
|
-
function _define_property6(obj, key, value) {
|
|
2164
|
-
if (key in obj) {
|
|
2165
|
-
Object.defineProperty(obj, key, {
|
|
2166
|
-
value,
|
|
2167
|
-
enumerable: true,
|
|
2168
|
-
configurable: true,
|
|
2169
|
-
writable: true
|
|
2170
|
-
});
|
|
2171
|
-
} else {
|
|
2172
|
-
obj[key] = value;
|
|
2173
|
-
}
|
|
2174
|
-
return obj;
|
|
2175
|
-
}
|
|
2176
2101
|
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
2177
2102
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
2178
2103
|
var ConnectionLimiter = class {
|
|
2104
|
+
_ctx = new Context5(void 0, {
|
|
2105
|
+
F: __dxlog_file7,
|
|
2106
|
+
L: 23
|
|
2107
|
+
});
|
|
2108
|
+
_maxConcurrentInitConnections;
|
|
2109
|
+
/**
|
|
2110
|
+
* Queue of promises to resolve when initiating connections amount is below the limit.
|
|
2111
|
+
*/
|
|
2112
|
+
_waitingPromises = new ComplexMap4(PublicKey6.hash);
|
|
2113
|
+
resolveWaitingPromises = new DeferredTask2(this._ctx, async () => {
|
|
2114
|
+
Array.from(this._waitingPromises.values()).slice(0, this._maxConcurrentInitConnections).forEach(({ resolve }) => {
|
|
2115
|
+
resolve();
|
|
2116
|
+
});
|
|
2117
|
+
});
|
|
2118
|
+
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
2119
|
+
this._maxConcurrentInitConnections = maxConcurrentInitConnections;
|
|
2120
|
+
}
|
|
2179
2121
|
/**
|
|
2180
2122
|
* @returns Promise that resolves in queue when connections amount with 'CONNECTING' state is below the limit.
|
|
2181
2123
|
*/
|
|
@@ -2232,20 +2174,6 @@ var ConnectionLimiter = class {
|
|
|
2232
2174
|
this._waitingPromises.delete(sessionId);
|
|
2233
2175
|
this.resolveWaitingPromises.schedule();
|
|
2234
2176
|
}
|
|
2235
|
-
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
2236
|
-
_define_property6(this, "_ctx", new Context5(void 0, {
|
|
2237
|
-
F: __dxlog_file7,
|
|
2238
|
-
L: 23
|
|
2239
|
-
}));
|
|
2240
|
-
_define_property6(this, "_maxConcurrentInitConnections", void 0);
|
|
2241
|
-
_define_property6(this, "_waitingPromises", new ComplexMap4(PublicKey6.hash));
|
|
2242
|
-
_define_property6(this, "resolveWaitingPromises", new DeferredTask2(this._ctx, async () => {
|
|
2243
|
-
Array.from(this._waitingPromises.values()).slice(0, this._maxConcurrentInitConnections).forEach(({ resolve }) => {
|
|
2244
|
-
resolve();
|
|
2245
|
-
});
|
|
2246
|
-
}));
|
|
2247
|
-
this._maxConcurrentInitConnections = maxConcurrentInitConnections;
|
|
2248
|
-
}
|
|
2249
2177
|
};
|
|
2250
2178
|
|
|
2251
2179
|
// src/connection-log.ts
|
|
@@ -2253,29 +2181,21 @@ import { Event as Event5 } from "@dxos/async";
|
|
|
2253
2181
|
import { raise } from "@dxos/debug";
|
|
2254
2182
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2255
2183
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2256
|
-
function _define_property7(obj, key, value) {
|
|
2257
|
-
if (key in obj) {
|
|
2258
|
-
Object.defineProperty(obj, key, {
|
|
2259
|
-
value,
|
|
2260
|
-
enumerable: true,
|
|
2261
|
-
configurable: true,
|
|
2262
|
-
writable: true
|
|
2263
|
-
});
|
|
2264
|
-
} else {
|
|
2265
|
-
obj[key] = value;
|
|
2266
|
-
}
|
|
2267
|
-
return obj;
|
|
2268
|
-
}
|
|
2269
2184
|
var CONNECTION_GC_THRESHOLD = 1e3 * 60 * 15;
|
|
2270
|
-
var EventType = /* @__PURE__ */ function(EventType2) {
|
|
2185
|
+
var EventType = /* @__PURE__ */ (function(EventType2) {
|
|
2271
2186
|
EventType2["CONNECTION_STATE_CHANGED"] = "CONNECTION_STATE_CHANGED";
|
|
2272
2187
|
EventType2["PROTOCOL_ERROR"] = "PROTOCOL_ERROR";
|
|
2273
2188
|
EventType2["PROTOCOL_EXTENSIONS_INITIALIZED"] = "PROTOCOL_EXTENSIONS_INITIALIZED";
|
|
2274
2189
|
EventType2["PROTOCOL_EXTENSIONS_HANDSHAKE"] = "PROTOCOL_EXTENSIONS_HANDSHAKE";
|
|
2275
2190
|
EventType2["PROTOCOL_HANDSHAKE"] = "PROTOCOL_HANDSHAKE";
|
|
2276
2191
|
return EventType2;
|
|
2277
|
-
}({});
|
|
2192
|
+
})({});
|
|
2278
2193
|
var ConnectionLog = class {
|
|
2194
|
+
/**
|
|
2195
|
+
* SwarmId => info
|
|
2196
|
+
*/
|
|
2197
|
+
_swarms = new ComplexMap5(PublicKey7.hash);
|
|
2198
|
+
update = new Event5();
|
|
2279
2199
|
getSwarmInfo(swarmId) {
|
|
2280
2200
|
return this._swarms.get(swarmId) ?? raise(new Error(`Swarm not found: ${swarmId}`));
|
|
2281
2201
|
}
|
|
@@ -2339,10 +2259,6 @@ var ConnectionLog = class {
|
|
|
2339
2259
|
this.getSwarmInfo(PublicKey7.from(swarm._instanceId)).isActive = false;
|
|
2340
2260
|
this.update.emit();
|
|
2341
2261
|
}
|
|
2342
|
-
constructor() {
|
|
2343
|
-
_define_property7(this, "_swarms", new ComplexMap5(PublicKey7.hash));
|
|
2344
|
-
_define_property7(this, "update", new Event5());
|
|
2345
|
-
}
|
|
2346
2262
|
};
|
|
2347
2263
|
var gcSwarm = (swarm) => {
|
|
2348
2264
|
swarm.connections = swarm.connections?.filter((connection) => {
|
|
@@ -2359,19 +2275,6 @@ import { Messenger } from "@dxos/messaging";
|
|
|
2359
2275
|
import { trace as trace3 } from "@dxos/protocols";
|
|
2360
2276
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2361
2277
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
2362
|
-
function _define_property8(obj, key, value) {
|
|
2363
|
-
if (key in obj) {
|
|
2364
|
-
Object.defineProperty(obj, key, {
|
|
2365
|
-
value,
|
|
2366
|
-
enumerable: true,
|
|
2367
|
-
configurable: true,
|
|
2368
|
-
writable: true
|
|
2369
|
-
});
|
|
2370
|
-
} else {
|
|
2371
|
-
obj[key] = value;
|
|
2372
|
-
}
|
|
2373
|
-
return obj;
|
|
2374
|
-
}
|
|
2375
2278
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2376
2279
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2377
2280
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2380,6 +2283,39 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2380
2283
|
}
|
|
2381
2284
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2382
2285
|
var SwarmNetworkManager = class {
|
|
2286
|
+
/**
|
|
2287
|
+
* @internal
|
|
2288
|
+
*/
|
|
2289
|
+
_swarms = new ComplexMap6(PublicKey8.hash);
|
|
2290
|
+
_mappers = new ComplexMap6(PublicKey8.hash);
|
|
2291
|
+
_transportFactory;
|
|
2292
|
+
_signalManager;
|
|
2293
|
+
_messenger;
|
|
2294
|
+
_signalConnection;
|
|
2295
|
+
_connectionLimiter;
|
|
2296
|
+
_connectionLog;
|
|
2297
|
+
_instanceId = PublicKey8.random().toHex();
|
|
2298
|
+
_peerInfo = void 0;
|
|
2299
|
+
_connectionState = ConnectionState2.ONLINE;
|
|
2300
|
+
connectionStateChanged = new Event6();
|
|
2301
|
+
topicsUpdated = new Event6();
|
|
2302
|
+
constructor({ transportFactory, signalManager, enableDevtoolsLogging, peerInfo }) {
|
|
2303
|
+
this._transportFactory = transportFactory;
|
|
2304
|
+
this._signalManager = signalManager;
|
|
2305
|
+
this._signalManager.swarmEvent.on((event) => this._swarms.get(event.topic)?.onSwarmEvent(event));
|
|
2306
|
+
this._messenger = new Messenger({
|
|
2307
|
+
signalManager: this._signalManager
|
|
2308
|
+
});
|
|
2309
|
+
this._signalConnection = {
|
|
2310
|
+
join: (opts) => this._signalManager.join(opts),
|
|
2311
|
+
leave: (opts) => this._signalManager.leave(opts)
|
|
2312
|
+
};
|
|
2313
|
+
this._peerInfo = peerInfo;
|
|
2314
|
+
this._connectionLimiter = new ConnectionLimiter();
|
|
2315
|
+
if (enableDevtoolsLogging) {
|
|
2316
|
+
this._connectionLog = new ConnectionLog();
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2383
2319
|
// TODO(burdon): Remove access (Devtools only).
|
|
2384
2320
|
get connectionLog() {
|
|
2385
2321
|
return this._connectionLog;
|
|
@@ -2588,36 +2524,6 @@ var SwarmNetworkManager = class {
|
|
|
2588
2524
|
}
|
|
2589
2525
|
this.connectionStateChanged.emit(this._connectionState);
|
|
2590
2526
|
}
|
|
2591
|
-
constructor({ transportFactory, signalManager, enableDevtoolsLogging, peerInfo }) {
|
|
2592
|
-
_define_property8(this, "_swarms", new ComplexMap6(PublicKey8.hash));
|
|
2593
|
-
_define_property8(this, "_mappers", new ComplexMap6(PublicKey8.hash));
|
|
2594
|
-
_define_property8(this, "_transportFactory", void 0);
|
|
2595
|
-
_define_property8(this, "_signalManager", void 0);
|
|
2596
|
-
_define_property8(this, "_messenger", void 0);
|
|
2597
|
-
_define_property8(this, "_signalConnection", void 0);
|
|
2598
|
-
_define_property8(this, "_connectionLimiter", void 0);
|
|
2599
|
-
_define_property8(this, "_connectionLog", void 0);
|
|
2600
|
-
_define_property8(this, "_instanceId", PublicKey8.random().toHex());
|
|
2601
|
-
_define_property8(this, "_peerInfo", void 0);
|
|
2602
|
-
_define_property8(this, "_connectionState", ConnectionState2.ONLINE);
|
|
2603
|
-
_define_property8(this, "connectionStateChanged", new Event6());
|
|
2604
|
-
_define_property8(this, "topicsUpdated", new Event6());
|
|
2605
|
-
this._transportFactory = transportFactory;
|
|
2606
|
-
this._signalManager = signalManager;
|
|
2607
|
-
this._signalManager.swarmEvent.on((event) => this._swarms.get(event.topic)?.onSwarmEvent(event));
|
|
2608
|
-
this._messenger = new Messenger({
|
|
2609
|
-
signalManager: this._signalManager
|
|
2610
|
-
});
|
|
2611
|
-
this._signalConnection = {
|
|
2612
|
-
join: (opts) => this._signalManager.join(opts),
|
|
2613
|
-
leave: (opts) => this._signalManager.leave(opts)
|
|
2614
|
-
};
|
|
2615
|
-
this._peerInfo = peerInfo;
|
|
2616
|
-
this._connectionLimiter = new ConnectionLimiter();
|
|
2617
|
-
if (enableDevtoolsLogging) {
|
|
2618
|
-
this._connectionLog = new ConnectionLog();
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
2527
|
};
|
|
2622
2528
|
_ts_decorate4([
|
|
2623
2529
|
synchronized4
|
|
@@ -2628,21 +2534,9 @@ _ts_decorate4([
|
|
|
2628
2534
|
|
|
2629
2535
|
// src/topology/fully-connected-topology.ts
|
|
2630
2536
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2631
|
-
function _define_property9(obj, key, value) {
|
|
2632
|
-
if (key in obj) {
|
|
2633
|
-
Object.defineProperty(obj, key, {
|
|
2634
|
-
value,
|
|
2635
|
-
enumerable: true,
|
|
2636
|
-
configurable: true,
|
|
2637
|
-
writable: true
|
|
2638
|
-
});
|
|
2639
|
-
} else {
|
|
2640
|
-
obj[key] = value;
|
|
2641
|
-
}
|
|
2642
|
-
return obj;
|
|
2643
|
-
}
|
|
2644
2537
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2645
2538
|
var FullyConnectedTopology = class {
|
|
2539
|
+
_controller;
|
|
2646
2540
|
toString() {
|
|
2647
2541
|
return "FullyConnectedTopology";
|
|
2648
2542
|
}
|
|
@@ -2678,31 +2572,26 @@ var FullyConnectedTopology = class {
|
|
|
2678
2572
|
}
|
|
2679
2573
|
async destroy() {
|
|
2680
2574
|
}
|
|
2681
|
-
constructor() {
|
|
2682
|
-
_define_property9(this, "_controller", void 0);
|
|
2683
|
-
}
|
|
2684
2575
|
};
|
|
2685
2576
|
|
|
2686
2577
|
// src/topology/mmst-topology.ts
|
|
2687
2578
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2688
2579
|
import { log as log9 } from "@dxos/log";
|
|
2689
|
-
function _define_property10(obj, key, value) {
|
|
2690
|
-
if (key in obj) {
|
|
2691
|
-
Object.defineProperty(obj, key, {
|
|
2692
|
-
value,
|
|
2693
|
-
enumerable: true,
|
|
2694
|
-
configurable: true,
|
|
2695
|
-
writable: true
|
|
2696
|
-
});
|
|
2697
|
-
} else {
|
|
2698
|
-
obj[key] = value;
|
|
2699
|
-
}
|
|
2700
|
-
return obj;
|
|
2701
|
-
}
|
|
2702
2580
|
var __dxlog_file10 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2703
2581
|
var MIN_UPDATE_INTERVAL = 1e3 * 10;
|
|
2704
2582
|
var MAX_CHANGES_PER_UPDATE = 1;
|
|
2705
2583
|
var MMSTTopology = class {
|
|
2584
|
+
_originateConnections;
|
|
2585
|
+
_maxPeers;
|
|
2586
|
+
_sampleSize;
|
|
2587
|
+
_controller;
|
|
2588
|
+
_sampleCollected = false;
|
|
2589
|
+
_lastAction = /* @__PURE__ */ new Date(0);
|
|
2590
|
+
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2591
|
+
this._originateConnections = originateConnections;
|
|
2592
|
+
this._maxPeers = maxPeers;
|
|
2593
|
+
this._sampleSize = sampleSize;
|
|
2594
|
+
}
|
|
2706
2595
|
init(controller) {
|
|
2707
2596
|
invariant8(!this._controller, "Already initialized", {
|
|
2708
2597
|
F: __dxlog_file10,
|
|
@@ -2859,17 +2748,6 @@ var MMSTTopology = class {
|
|
|
2859
2748
|
toString() {
|
|
2860
2749
|
return "MMSTTopology";
|
|
2861
2750
|
}
|
|
2862
|
-
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2863
|
-
_define_property10(this, "_originateConnections", void 0);
|
|
2864
|
-
_define_property10(this, "_maxPeers", void 0);
|
|
2865
|
-
_define_property10(this, "_sampleSize", void 0);
|
|
2866
|
-
_define_property10(this, "_controller", void 0);
|
|
2867
|
-
_define_property10(this, "_sampleCollected", false);
|
|
2868
|
-
_define_property10(this, "_lastAction", /* @__PURE__ */ new Date(0));
|
|
2869
|
-
this._originateConnections = originateConnections;
|
|
2870
|
-
this._maxPeers = maxPeers;
|
|
2871
|
-
this._sampleSize = sampleSize;
|
|
2872
|
-
}
|
|
2873
2751
|
};
|
|
2874
2752
|
var sortByXorDistance = (keys, reference) => {
|
|
2875
2753
|
const sorted = keys.sort((a, b) => {
|
|
@@ -2909,21 +2787,13 @@ var compareXor = (a, b) => {
|
|
|
2909
2787
|
// src/topology/star-topology.ts
|
|
2910
2788
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2911
2789
|
import { log as log10 } from "@dxos/log";
|
|
2912
|
-
function _define_property11(obj, key, value) {
|
|
2913
|
-
if (key in obj) {
|
|
2914
|
-
Object.defineProperty(obj, key, {
|
|
2915
|
-
value,
|
|
2916
|
-
enumerable: true,
|
|
2917
|
-
configurable: true,
|
|
2918
|
-
writable: true
|
|
2919
|
-
});
|
|
2920
|
-
} else {
|
|
2921
|
-
obj[key] = value;
|
|
2922
|
-
}
|
|
2923
|
-
return obj;
|
|
2924
|
-
}
|
|
2925
2790
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2926
2791
|
var StarTopology = class {
|
|
2792
|
+
_centralPeer;
|
|
2793
|
+
_controller;
|
|
2794
|
+
constructor(_centralPeer) {
|
|
2795
|
+
this._centralPeer = _centralPeer;
|
|
2796
|
+
}
|
|
2927
2797
|
toString() {
|
|
2928
2798
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
2929
2799
|
}
|
|
@@ -3010,11 +2880,6 @@ var StarTopology = class {
|
|
|
3010
2880
|
}
|
|
3011
2881
|
async destroy() {
|
|
3012
2882
|
}
|
|
3013
|
-
constructor(_centralPeer) {
|
|
3014
|
-
_define_property11(this, "_centralPeer", void 0);
|
|
3015
|
-
_define_property11(this, "_controller", void 0);
|
|
3016
|
-
this._centralPeer = _centralPeer;
|
|
3017
|
-
}
|
|
3018
2883
|
};
|
|
3019
2884
|
|
|
3020
2885
|
// src/transport/memory-transport.ts
|
|
@@ -3025,19 +2890,6 @@ import { invariant as invariant10 } from "@dxos/invariant";
|
|
|
3025
2890
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3026
2891
|
import { log as log11, logInfo as logInfo3 } from "@dxos/log";
|
|
3027
2892
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
3028
|
-
function _define_property12(obj, key, value) {
|
|
3029
|
-
if (key in obj) {
|
|
3030
|
-
Object.defineProperty(obj, key, {
|
|
3031
|
-
value,
|
|
3032
|
-
enumerable: true,
|
|
3033
|
-
configurable: true,
|
|
3034
|
-
writable: true
|
|
3035
|
-
});
|
|
3036
|
-
} else {
|
|
3037
|
-
obj[key] = value;
|
|
3038
|
-
}
|
|
3039
|
-
return obj;
|
|
3040
|
-
}
|
|
3041
2893
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
3042
2894
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3043
2895
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3058,6 +2910,32 @@ var MemoryTransportFactory = {
|
|
|
3058
2910
|
createTransport: (options) => new MemoryTransport(options)
|
|
3059
2911
|
};
|
|
3060
2912
|
var MemoryTransport = class _MemoryTransport {
|
|
2913
|
+
_options;
|
|
2914
|
+
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
2915
|
+
static _connections = new ComplexMap7(PublicKey9.hash);
|
|
2916
|
+
_instanceId = PublicKey9.random();
|
|
2917
|
+
_remote = new Trigger2();
|
|
2918
|
+
_outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
2919
|
+
_incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
2920
|
+
_closed = false;
|
|
2921
|
+
_remoteInstanceId;
|
|
2922
|
+
_remoteConnection;
|
|
2923
|
+
closed = new Event7();
|
|
2924
|
+
connected = new Event7();
|
|
2925
|
+
errors = new ErrorStream3();
|
|
2926
|
+
constructor(_options) {
|
|
2927
|
+
this._options = _options;
|
|
2928
|
+
invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
|
|
2929
|
+
F: __dxlog_file12,
|
|
2930
|
+
L: 64,
|
|
2931
|
+
S: this,
|
|
2932
|
+
A: [
|
|
2933
|
+
"!MemoryTransport._connections.has(this._instanceId)",
|
|
2934
|
+
"'Duplicate memory connection'"
|
|
2935
|
+
]
|
|
2936
|
+
});
|
|
2937
|
+
_MemoryTransport._connections.set(this._instanceId, this);
|
|
2938
|
+
}
|
|
3061
2939
|
get isOpen() {
|
|
3062
2940
|
return !this._closed;
|
|
3063
2941
|
}
|
|
@@ -3188,40 +3066,7 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
3188
3066
|
packetsReceived: 0
|
|
3189
3067
|
};
|
|
3190
3068
|
}
|
|
3191
|
-
constructor(_options) {
|
|
3192
|
-
_define_property12(this, "_options", void 0);
|
|
3193
|
-
_define_property12(this, "_instanceId", void 0);
|
|
3194
|
-
_define_property12(this, "_remote", void 0);
|
|
3195
|
-
_define_property12(this, "_outgoingDelay", void 0);
|
|
3196
|
-
_define_property12(this, "_incomingDelay", void 0);
|
|
3197
|
-
_define_property12(this, "_closed", void 0);
|
|
3198
|
-
_define_property12(this, "_remoteInstanceId", void 0);
|
|
3199
|
-
_define_property12(this, "_remoteConnection", void 0);
|
|
3200
|
-
_define_property12(this, "closed", void 0);
|
|
3201
|
-
_define_property12(this, "connected", void 0);
|
|
3202
|
-
_define_property12(this, "errors", void 0);
|
|
3203
|
-
this._options = _options;
|
|
3204
|
-
this._instanceId = PublicKey9.random();
|
|
3205
|
-
this._remote = new Trigger2();
|
|
3206
|
-
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
3207
|
-
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
3208
|
-
this._closed = false;
|
|
3209
|
-
this.closed = new Event7();
|
|
3210
|
-
this.connected = new Event7();
|
|
3211
|
-
this.errors = new ErrorStream3();
|
|
3212
|
-
invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
|
|
3213
|
-
F: __dxlog_file12,
|
|
3214
|
-
L: 64,
|
|
3215
|
-
S: this,
|
|
3216
|
-
A: [
|
|
3217
|
-
"!MemoryTransport._connections.has(this._instanceId)",
|
|
3218
|
-
"'Duplicate memory connection'"
|
|
3219
|
-
]
|
|
3220
|
-
});
|
|
3221
|
-
_MemoryTransport._connections.set(this._instanceId, this);
|
|
3222
|
-
}
|
|
3223
3069
|
};
|
|
3224
|
-
_define_property12(MemoryTransport, "_connections", new ComplexMap7(PublicKey9.hash));
|
|
3225
3070
|
_ts_decorate5([
|
|
3226
3071
|
logInfo3
|
|
3227
3072
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
@@ -3231,29 +3076,16 @@ _ts_decorate5([
|
|
|
3231
3076
|
var toError = (err) => err instanceof Error ? err : new Error(String(err));
|
|
3232
3077
|
|
|
3233
3078
|
// src/transport/transport.ts
|
|
3234
|
-
var TransportKind = /* @__PURE__ */ function(TransportKind2) {
|
|
3079
|
+
var TransportKind = /* @__PURE__ */ (function(TransportKind2) {
|
|
3235
3080
|
TransportKind2["WEB_RTC"] = "WEB-RTC";
|
|
3236
3081
|
TransportKind2["WEB_RTC_PROXY"] = "WEB-RTC_PROXY";
|
|
3237
3082
|
TransportKind2["MEMORY"] = "MEMORY";
|
|
3238
3083
|
TransportKind2["TCP"] = "TCP";
|
|
3239
3084
|
return TransportKind2;
|
|
3240
|
-
}({});
|
|
3085
|
+
})({});
|
|
3241
3086
|
|
|
3242
3087
|
// src/transport/webrtc/rtc-connection-factory.ts
|
|
3243
3088
|
import { Mutex } from "@dxos/async";
|
|
3244
|
-
function _define_property13(obj, key, value) {
|
|
3245
|
-
if (key in obj) {
|
|
3246
|
-
Object.defineProperty(obj, key, {
|
|
3247
|
-
value,
|
|
3248
|
-
enumerable: true,
|
|
3249
|
-
configurable: true,
|
|
3250
|
-
writable: true
|
|
3251
|
-
});
|
|
3252
|
-
} else {
|
|
3253
|
-
obj[key] = value;
|
|
3254
|
-
}
|
|
3255
|
-
return obj;
|
|
3256
|
-
}
|
|
3257
3089
|
var BrowserRtcConnectionFactory = class {
|
|
3258
3090
|
async initialize() {
|
|
3259
3091
|
}
|
|
@@ -3266,6 +3098,8 @@ var BrowserRtcConnectionFactory = class {
|
|
|
3266
3098
|
}
|
|
3267
3099
|
};
|
|
3268
3100
|
var NodeRtcConnectionFactory = class _NodeRtcConnectionFactory {
|
|
3101
|
+
static _createdConnections = 0;
|
|
3102
|
+
static _cleanupMutex = new Mutex();
|
|
3269
3103
|
// This should be inside the function to avoid triggering `eval` in the global scope.
|
|
3270
3104
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
3271
3105
|
// TODO(burdon): Do imports here?
|
|
@@ -3291,8 +3125,6 @@ var NodeRtcConnectionFactory = class _NodeRtcConnectionFactory {
|
|
|
3291
3125
|
}
|
|
3292
3126
|
}
|
|
3293
3127
|
};
|
|
3294
|
-
_define_property13(NodeRtcConnectionFactory, "_createdConnections", 0);
|
|
3295
|
-
_define_property13(NodeRtcConnectionFactory, "_cleanupMutex", new Mutex());
|
|
3296
3128
|
var getRtcConnectionFactory = () => {
|
|
3297
3129
|
return typeof globalThis.RTCPeerConnection === "undefined" ? new NodeRtcConnectionFactory() : new BrowserRtcConnectionFactory();
|
|
3298
3130
|
};
|
|
@@ -3361,23 +3193,22 @@ var getRtcConnectionStats = async (connection, channelTopic) => {
|
|
|
3361
3193
|
};
|
|
3362
3194
|
|
|
3363
3195
|
// src/transport/webrtc/rtc-transport-channel.ts
|
|
3364
|
-
function _define_property14(obj, key, value) {
|
|
3365
|
-
if (key in obj) {
|
|
3366
|
-
Object.defineProperty(obj, key, {
|
|
3367
|
-
value,
|
|
3368
|
-
enumerable: true,
|
|
3369
|
-
configurable: true,
|
|
3370
|
-
writable: true
|
|
3371
|
-
});
|
|
3372
|
-
} else {
|
|
3373
|
-
obj[key] = value;
|
|
3374
|
-
}
|
|
3375
|
-
return obj;
|
|
3376
|
-
}
|
|
3377
3196
|
var __dxlog_file13 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
|
|
3378
3197
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
3379
3198
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3380
3199
|
var RtcTransportChannel = class extends Resource {
|
|
3200
|
+
_connection;
|
|
3201
|
+
_options;
|
|
3202
|
+
closed = new AsyncEvent();
|
|
3203
|
+
connected = new AsyncEvent();
|
|
3204
|
+
errors = new ErrorStream4();
|
|
3205
|
+
_channel;
|
|
3206
|
+
_stream;
|
|
3207
|
+
_streamDataFlushedCallback = null;
|
|
3208
|
+
_isChannelCreationInProgress = false;
|
|
3209
|
+
constructor(_connection, _options) {
|
|
3210
|
+
super(), this._connection = _connection, this._options = _options;
|
|
3211
|
+
}
|
|
3381
3212
|
get isRtcChannelCreationInProgress() {
|
|
3382
3213
|
return this._isChannelCreationInProgress;
|
|
3383
3214
|
}
|
|
@@ -3406,7 +3237,9 @@ var RtcTransportChannel = class extends Resource {
|
|
|
3406
3237
|
}
|
|
3407
3238
|
}).catch((err) => {
|
|
3408
3239
|
if (this.isOpen) {
|
|
3409
|
-
const error = err instanceof Error ? err : new ConnectivityError2(
|
|
3240
|
+
const error = err instanceof Error ? err : new ConnectivityError2({
|
|
3241
|
+
message: `Failed to create a channel: ${JSON.stringify(err?.message)}`
|
|
3242
|
+
});
|
|
3410
3243
|
this.errors.raise(error);
|
|
3411
3244
|
} else {
|
|
3412
3245
|
log12.verbose("connection establishment failed after transport was closed", {
|
|
@@ -3566,9 +3399,6 @@ var RtcTransportChannel = class extends Resource {
|
|
|
3566
3399
|
async getStats() {
|
|
3567
3400
|
return createRtcTransportStats(this._connection.currentConnection, this._options.topic);
|
|
3568
3401
|
}
|
|
3569
|
-
constructor(_connection, _options) {
|
|
3570
|
-
super(), _define_property14(this, "_connection", void 0), _define_property14(this, "_options", void 0), _define_property14(this, "closed", void 0), _define_property14(this, "connected", void 0), _define_property14(this, "errors", void 0), _define_property14(this, "_channel", void 0), _define_property14(this, "_stream", void 0), _define_property14(this, "_streamDataFlushedCallback", void 0), _define_property14(this, "_isChannelCreationInProgress", void 0), this._connection = _connection, this._options = _options, this.closed = new AsyncEvent(), this.connected = new AsyncEvent(), this.errors = new ErrorStream4(), this._streamDataFlushedCallback = null, this._isChannelCreationInProgress = false;
|
|
3571
|
-
}
|
|
3572
3402
|
};
|
|
3573
3403
|
|
|
3574
3404
|
// src/transport/webrtc/utils.ts
|
|
@@ -3598,19 +3428,6 @@ var deduplicatedSdpLines = (sdp) => {
|
|
|
3598
3428
|
};
|
|
3599
3429
|
|
|
3600
3430
|
// src/transport/webrtc/rtc-peer-connection.ts
|
|
3601
|
-
function _define_property15(obj, key, value) {
|
|
3602
|
-
if (key in obj) {
|
|
3603
|
-
Object.defineProperty(obj, key, {
|
|
3604
|
-
value,
|
|
3605
|
-
enumerable: true,
|
|
3606
|
-
configurable: true,
|
|
3607
|
-
writable: true
|
|
3608
|
-
});
|
|
3609
|
-
} else {
|
|
3610
|
-
obj[key] = value;
|
|
3611
|
-
}
|
|
3612
|
-
return obj;
|
|
3613
|
-
}
|
|
3614
3431
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
3615
3432
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3616
3433
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3619,6 +3436,29 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
3619
3436
|
}
|
|
3620
3437
|
var __dxlog_file14 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
|
|
3621
3438
|
var RtcPeerConnection = class {
|
|
3439
|
+
_factory;
|
|
3440
|
+
_options;
|
|
3441
|
+
// A peer who is not the initiator waits for another party to open a channel.
|
|
3442
|
+
_channelCreatedCallbacks = /* @__PURE__ */ new Map();
|
|
3443
|
+
// Channels indexed by topic.
|
|
3444
|
+
_transportChannels = /* @__PURE__ */ new Map();
|
|
3445
|
+
_dataChannels = /* @__PURE__ */ new Map();
|
|
3446
|
+
// A peer is ready to receive ICE candidates when local and remote description were set.
|
|
3447
|
+
_readyForCandidates = new Trigger3();
|
|
3448
|
+
_offerProcessingMutex = new Mutex2();
|
|
3449
|
+
/**
|
|
3450
|
+
* Can't use peer.connection.initiator, because if two connections to the same peer are created in
|
|
3451
|
+
* different swarms, we might be the initiator of the first one, but not of the other one.
|
|
3452
|
+
* Use a stable peer keypair property (key ordering) to decide who's acting as the initiator of
|
|
3453
|
+
* transport connection establishment and data channel creation.
|
|
3454
|
+
*/
|
|
3455
|
+
_initiator;
|
|
3456
|
+
_connection;
|
|
3457
|
+
constructor(_factory, _options) {
|
|
3458
|
+
this._factory = _factory;
|
|
3459
|
+
this._options = _options;
|
|
3460
|
+
this._initiator = chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
|
|
3461
|
+
}
|
|
3622
3462
|
get transportChannelCount() {
|
|
3623
3463
|
return this._transportChannels.size;
|
|
3624
3464
|
}
|
|
@@ -4142,25 +3982,6 @@ var RtcPeerConnection = class {
|
|
|
4142
3982
|
channels: this._transportChannels.size
|
|
4143
3983
|
};
|
|
4144
3984
|
}
|
|
4145
|
-
constructor(_factory, _options) {
|
|
4146
|
-
_define_property15(this, "_factory", void 0);
|
|
4147
|
-
_define_property15(this, "_options", void 0);
|
|
4148
|
-
_define_property15(this, "_channelCreatedCallbacks", void 0);
|
|
4149
|
-
_define_property15(this, "_transportChannels", void 0);
|
|
4150
|
-
_define_property15(this, "_dataChannels", void 0);
|
|
4151
|
-
_define_property15(this, "_readyForCandidates", void 0);
|
|
4152
|
-
_define_property15(this, "_offerProcessingMutex", void 0);
|
|
4153
|
-
_define_property15(this, "_initiator", void 0);
|
|
4154
|
-
_define_property15(this, "_connection", void 0);
|
|
4155
|
-
this._factory = _factory;
|
|
4156
|
-
this._options = _options;
|
|
4157
|
-
this._channelCreatedCallbacks = /* @__PURE__ */ new Map();
|
|
4158
|
-
this._transportChannels = /* @__PURE__ */ new Map();
|
|
4159
|
-
this._dataChannels = /* @__PURE__ */ new Map();
|
|
4160
|
-
this._readyForCandidates = new Trigger3();
|
|
4161
|
-
this._offerProcessingMutex = new Mutex2();
|
|
4162
|
-
this._initiator = chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
|
|
4163
|
-
}
|
|
4164
3985
|
};
|
|
4165
3986
|
_ts_decorate6([
|
|
4166
3987
|
synchronized5
|
|
@@ -4191,8 +4012,10 @@ var isRemoteDescriptionSet = (connection, data) => {
|
|
|
4191
4012
|
};
|
|
4192
4013
|
var createIceFailureError = (details) => {
|
|
4193
4014
|
const candidateErrors = details.map(({ url, errorCode, errorText }) => `${errorCode} ${url}: ${errorText}`);
|
|
4194
|
-
return new ConnectivityError3(
|
|
4195
|
-
|
|
4015
|
+
return new ConnectivityError3({
|
|
4016
|
+
message: `ICE failed:
|
|
4017
|
+
${candidateErrors.join("\n")}`
|
|
4018
|
+
});
|
|
4196
4019
|
};
|
|
4197
4020
|
|
|
4198
4021
|
// src/transport/webrtc/rtc-transport-factory.ts
|
|
@@ -4224,24 +4047,20 @@ import { log as log14 } from "@dxos/log";
|
|
|
4224
4047
|
import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError4, TimeoutError as TimeoutError3 } from "@dxos/protocols";
|
|
4225
4048
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
4226
4049
|
import { arrayToBuffer } from "@dxos/util";
|
|
4227
|
-
function _define_property16(obj, key, value) {
|
|
4228
|
-
if (key in obj) {
|
|
4229
|
-
Object.defineProperty(obj, key, {
|
|
4230
|
-
value,
|
|
4231
|
-
enumerable: true,
|
|
4232
|
-
configurable: true,
|
|
4233
|
-
writable: true
|
|
4234
|
-
});
|
|
4235
|
-
} else {
|
|
4236
|
-
obj[key] = value;
|
|
4237
|
-
}
|
|
4238
|
-
return obj;
|
|
4239
|
-
}
|
|
4240
4050
|
var __dxlog_file15 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
|
|
4241
4051
|
var RPC_TIMEOUT = 1e4;
|
|
4242
4052
|
var CLOSE_RPC_TIMEOUT = 3e3;
|
|
4243
4053
|
var RESP_MIN_THRESHOLD = 500;
|
|
4244
4054
|
var RtcTransportProxy = class extends Resource2 {
|
|
4055
|
+
_options;
|
|
4056
|
+
_proxyId = PublicKey10.random();
|
|
4057
|
+
closed = new Event8();
|
|
4058
|
+
connected = new Event8();
|
|
4059
|
+
errors = new ErrorStream5();
|
|
4060
|
+
_serviceStream;
|
|
4061
|
+
constructor(_options) {
|
|
4062
|
+
super(), this._options = _options;
|
|
4063
|
+
}
|
|
4245
4064
|
async _open() {
|
|
4246
4065
|
let stream;
|
|
4247
4066
|
try {
|
|
@@ -4392,7 +4211,9 @@ var RtcTransportProxy = class extends Resource2 {
|
|
|
4392
4211
|
} catch (error) {
|
|
4393
4212
|
const type = signalEvent.payload.payload.data?.type;
|
|
4394
4213
|
if (type === "offer" || type === "answer") {
|
|
4395
|
-
this._raiseIfOpen(new ConnectivityError4(
|
|
4214
|
+
this._raiseIfOpen(new ConnectivityError4({
|
|
4215
|
+
message: `Session establishment failed: ${type} couldn't be sent.`
|
|
4216
|
+
}));
|
|
4396
4217
|
}
|
|
4397
4218
|
}
|
|
4398
4219
|
}
|
|
@@ -4434,7 +4255,7 @@ var RtcTransportProxy = class extends Resource2 {
|
|
|
4434
4255
|
message: error.message
|
|
4435
4256
|
}, {
|
|
4436
4257
|
F: __dxlog_file15,
|
|
4437
|
-
L:
|
|
4258
|
+
L: 217,
|
|
4438
4259
|
S: this,
|
|
4439
4260
|
C: (f, a) => f(...a)
|
|
4440
4261
|
});
|
|
@@ -4447,11 +4268,10 @@ var RtcTransportProxy = class extends Resource2 {
|
|
|
4447
4268
|
void this._serviceStream?.close();
|
|
4448
4269
|
this.closed.emit();
|
|
4449
4270
|
}
|
|
4450
|
-
constructor(_options) {
|
|
4451
|
-
super(), _define_property16(this, "_options", void 0), _define_property16(this, "_proxyId", void 0), _define_property16(this, "closed", void 0), _define_property16(this, "connected", void 0), _define_property16(this, "errors", void 0), _define_property16(this, "_serviceStream", void 0), this._options = _options, this._proxyId = PublicKey10.random(), this.closed = new Event8(), this.connected = new Event8(), this.errors = new ErrorStream5();
|
|
4452
|
-
}
|
|
4453
4271
|
};
|
|
4454
4272
|
var RtcTransportProxyFactory = class {
|
|
4273
|
+
_bridgeService;
|
|
4274
|
+
_connections = /* @__PURE__ */ new Set();
|
|
4455
4275
|
/**
|
|
4456
4276
|
* Sets the current BridgeService to be used to open connections.
|
|
4457
4277
|
* Calling this method will close any existing connections.
|
|
@@ -4466,7 +4286,7 @@ var RtcTransportProxyFactory = class {
|
|
|
4466
4286
|
createTransport(options) {
|
|
4467
4287
|
invariant13(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
|
|
4468
4288
|
F: __dxlog_file15,
|
|
4469
|
-
L:
|
|
4289
|
+
L: 247,
|
|
4470
4290
|
S: this,
|
|
4471
4291
|
A: [
|
|
4472
4292
|
"this._bridgeService",
|
|
@@ -4483,19 +4303,21 @@ var RtcTransportProxyFactory = class {
|
|
|
4483
4303
|
});
|
|
4484
4304
|
return transport;
|
|
4485
4305
|
}
|
|
4486
|
-
constructor() {
|
|
4487
|
-
_define_property16(this, "_bridgeService", void 0);
|
|
4488
|
-
_define_property16(this, "_connections", /* @__PURE__ */ new Set());
|
|
4489
|
-
}
|
|
4490
4306
|
};
|
|
4491
4307
|
var decodeError = (err) => {
|
|
4492
4308
|
const message = typeof err === "string" ? err : err.message;
|
|
4493
4309
|
if (message.includes("CONNECTION_RESET")) {
|
|
4494
|
-
return new ConnectionResetError2(
|
|
4310
|
+
return new ConnectionResetError2({
|
|
4311
|
+
message
|
|
4312
|
+
});
|
|
4495
4313
|
} else if (message.includes("TIMEOUT")) {
|
|
4496
|
-
return new TimeoutError3(
|
|
4314
|
+
return new TimeoutError3({
|
|
4315
|
+
message
|
|
4316
|
+
});
|
|
4497
4317
|
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
4498
|
-
return new ConnectivityError4(
|
|
4318
|
+
return new ConnectivityError4({
|
|
4319
|
+
message
|
|
4320
|
+
});
|
|
4499
4321
|
} else {
|
|
4500
4322
|
return typeof err === "string" ? new Error(err) : err;
|
|
4501
4323
|
}
|
|
@@ -4509,21 +4331,13 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
4509
4331
|
import { log as log15 } from "@dxos/log";
|
|
4510
4332
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
4511
4333
|
import { ComplexMap as ComplexMap8 } from "@dxos/util";
|
|
4512
|
-
function _define_property17(obj, key, value) {
|
|
4513
|
-
if (key in obj) {
|
|
4514
|
-
Object.defineProperty(obj, key, {
|
|
4515
|
-
value,
|
|
4516
|
-
enumerable: true,
|
|
4517
|
-
configurable: true,
|
|
4518
|
-
writable: true
|
|
4519
|
-
});
|
|
4520
|
-
} else {
|
|
4521
|
-
obj[key] = value;
|
|
4522
|
-
}
|
|
4523
|
-
return obj;
|
|
4524
|
-
}
|
|
4525
4334
|
var __dxlog_file16 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
|
|
4526
4335
|
var RtcTransportService = class {
|
|
4336
|
+
_transportFactory;
|
|
4337
|
+
_openTransports = new ComplexMap8(PublicKey11.hash);
|
|
4338
|
+
constructor(webrtcConfig, iceProvider, _transportFactory = createRtcTransportFactory(webrtcConfig, iceProvider)) {
|
|
4339
|
+
this._transportFactory = _transportFactory;
|
|
4340
|
+
}
|
|
4527
4341
|
hasOpenTransports() {
|
|
4528
4342
|
return this._openTransports.size > 0;
|
|
4529
4343
|
}
|
|
@@ -4710,12 +4524,6 @@ var RtcTransportService = class {
|
|
|
4710
4524
|
C: (f, a) => f(...a)
|
|
4711
4525
|
});
|
|
4712
4526
|
}
|
|
4713
|
-
constructor(webrtcConfig, iceProvider, _transportFactory = createRtcTransportFactory(webrtcConfig, iceProvider)) {
|
|
4714
|
-
_define_property17(this, "_transportFactory", void 0);
|
|
4715
|
-
_define_property17(this, "_openTransports", void 0);
|
|
4716
|
-
this._transportFactory = _transportFactory;
|
|
4717
|
-
this._openTransports = new ComplexMap8(PublicKey11.hash);
|
|
4718
|
-
}
|
|
4719
4527
|
};
|
|
4720
4528
|
var createStateUpdater = (next) => {
|
|
4721
4529
|
return (state, err) => {
|
|
@@ -4778,4 +4586,4 @@ export {
|
|
|
4778
4586
|
RtcTransportService,
|
|
4779
4587
|
createTeleportProtocolFactory
|
|
4780
4588
|
};
|
|
4781
|
-
//# sourceMappingURL=chunk-
|
|
4589
|
+
//# sourceMappingURL=chunk-5ISEIDVN.mjs.map
|