@dxos/network-manager 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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-NRRQ4H6U.mjs → chunk-E3P563GT.mjs} +366 -579
- package/dist/lib/{node-esm/chunk-AX4TJ2DL.mjs.map → browser/chunk-E3P563GT.mjs.map} +2 -2
- 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-AX4TJ2DL.mjs → chunk-PKBROUZV.mjs} +366 -579
- package/dist/lib/{browser/chunk-NRRQ4H6U.mjs.map → node-esm/chunk-PKBROUZV.mjs.map} +2 -2
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -29
|
@@ -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);
|
|
@@ -44,6 +31,61 @@ var ConnectionState = /* @__PURE__ */ (function(ConnectionState5) {
|
|
|
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
|
}
|
|
@@ -555,74 +597,6 @@ var Connection = class {
|
|
|
555
597
|
this.transportStats.emit(stats);
|
|
556
598
|
}
|
|
557
599
|
}
|
|
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
600
|
};
|
|
627
601
|
_ts_decorate([
|
|
628
602
|
logInfo
|
|
@@ -675,22 +649,24 @@ import { log as log3 } from "@dxos/log";
|
|
|
675
649
|
import { TimeoutError as TimeoutError2 } from "@dxos/protocols";
|
|
676
650
|
import { schema } from "@dxos/protocols/proto";
|
|
677
651
|
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
652
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
692
653
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
693
654
|
var SwarmMessenger = class {
|
|
655
|
+
_ctx = new Context2(void 0, {
|
|
656
|
+
F: __dxlog_file3,
|
|
657
|
+
L: 35
|
|
658
|
+
});
|
|
659
|
+
_sendMessage;
|
|
660
|
+
_onSignal;
|
|
661
|
+
_onOffer;
|
|
662
|
+
_topic;
|
|
663
|
+
_offerRecords = new ComplexMap((key) => key.toHex());
|
|
664
|
+
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
665
|
+
this._sendMessage = sendMessage;
|
|
666
|
+
this._onSignal = onSignal;
|
|
667
|
+
this._onOffer = onOffer;
|
|
668
|
+
this._topic = topic;
|
|
669
|
+
}
|
|
694
670
|
async receiveMessage({ author, recipient, payload }) {
|
|
695
671
|
if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
|
|
696
672
|
return;
|
|
@@ -914,21 +890,6 @@ var SwarmMessenger = class {
|
|
|
914
890
|
};
|
|
915
891
|
await this._onSignal(signalMessage);
|
|
916
892
|
}
|
|
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
893
|
};
|
|
933
894
|
|
|
934
895
|
// src/swarm/swarm.ts
|
|
@@ -949,19 +910,6 @@ import { invariant as invariant3 } from "@dxos/invariant";
|
|
|
949
910
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
950
911
|
import { log as log4 } from "@dxos/log";
|
|
951
912
|
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
913
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
966
914
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
967
915
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -976,6 +924,42 @@ var ConnectionDisplacedError = class extends SystemError {
|
|
|
976
924
|
};
|
|
977
925
|
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
978
926
|
var Peer = class {
|
|
927
|
+
remoteInfo;
|
|
928
|
+
topic;
|
|
929
|
+
localInfo;
|
|
930
|
+
_signalMessaging;
|
|
931
|
+
_protocolProvider;
|
|
932
|
+
_transportFactory;
|
|
933
|
+
_connectionLimiter;
|
|
934
|
+
_callbacks;
|
|
935
|
+
/**
|
|
936
|
+
* Will be available to connect after this time.
|
|
937
|
+
*/
|
|
938
|
+
_availableAfter = 0;
|
|
939
|
+
availableToConnect = true;
|
|
940
|
+
_lastConnectionTime;
|
|
941
|
+
_ctx = new Context3(void 0, {
|
|
942
|
+
F: __dxlog_file4,
|
|
943
|
+
L: 81
|
|
944
|
+
});
|
|
945
|
+
_connectionCtx;
|
|
946
|
+
connection;
|
|
947
|
+
/**
|
|
948
|
+
* Whether the peer is currently advertizing itself on the signal-network.
|
|
949
|
+
*/
|
|
950
|
+
advertizing = false;
|
|
951
|
+
initiating = false;
|
|
952
|
+
connectionDisplaced = new Event2();
|
|
953
|
+
constructor(remoteInfo, topic, localInfo, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
954
|
+
this.remoteInfo = remoteInfo;
|
|
955
|
+
this.topic = topic;
|
|
956
|
+
this.localInfo = localInfo;
|
|
957
|
+
this._signalMessaging = _signalMessaging;
|
|
958
|
+
this._protocolProvider = _protocolProvider;
|
|
959
|
+
this._transportFactory = _transportFactory;
|
|
960
|
+
this._connectionLimiter = _connectionLimiter;
|
|
961
|
+
this._callbacks = _callbacks;
|
|
962
|
+
}
|
|
979
963
|
/**
|
|
980
964
|
* Respond to remote offer.
|
|
981
965
|
*/
|
|
@@ -1412,42 +1396,6 @@ var Peer = class {
|
|
|
1412
1396
|
reason
|
|
1413
1397
|
});
|
|
1414
1398
|
}
|
|
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
1399
|
};
|
|
1452
1400
|
_ts_decorate2([
|
|
1453
1401
|
synchronized2
|
|
@@ -1466,19 +1414,6 @@ var increaseInterval = (interval) => {
|
|
|
1466
1414
|
};
|
|
1467
1415
|
|
|
1468
1416
|
// 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
1417
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
1483
1418
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1484
1419
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1489,6 +1424,94 @@ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm
|
|
|
1489
1424
|
var INITIATION_DELAY = 100;
|
|
1490
1425
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1491
1426
|
var Swarm = class {
|
|
1427
|
+
_topic;
|
|
1428
|
+
_ownPeer;
|
|
1429
|
+
_topology;
|
|
1430
|
+
_protocolProvider;
|
|
1431
|
+
_messenger;
|
|
1432
|
+
_transportFactory;
|
|
1433
|
+
_label;
|
|
1434
|
+
_connectionLimiter;
|
|
1435
|
+
_initiationDelay;
|
|
1436
|
+
_swarmMessenger;
|
|
1437
|
+
_ctx = new Context4(void 0, {
|
|
1438
|
+
F: __dxlog_file5,
|
|
1439
|
+
L: 39
|
|
1440
|
+
});
|
|
1441
|
+
_listeningHandle = void 0;
|
|
1442
|
+
/**
|
|
1443
|
+
* PeerInfo -> Peer.
|
|
1444
|
+
* @internal
|
|
1445
|
+
*/
|
|
1446
|
+
_peers = new ComplexMap2(PeerInfoHash);
|
|
1447
|
+
/**
|
|
1448
|
+
* Unique id of the swarm, local to the current peer, generated when swarm is joined.
|
|
1449
|
+
*/
|
|
1450
|
+
_instanceId = PublicKey4.random().toHex();
|
|
1451
|
+
/**
|
|
1452
|
+
* New connection to a peer is started.
|
|
1453
|
+
* @internal
|
|
1454
|
+
*/
|
|
1455
|
+
connectionAdded = new Event3();
|
|
1456
|
+
/**
|
|
1457
|
+
* Connection to a peer is dropped.
|
|
1458
|
+
* @internal
|
|
1459
|
+
*/
|
|
1460
|
+
disconnected = new Event3();
|
|
1461
|
+
/**
|
|
1462
|
+
* Connection is established to a new peer.
|
|
1463
|
+
* @internal
|
|
1464
|
+
*/
|
|
1465
|
+
connected = new Event3();
|
|
1466
|
+
errors = new ErrorStream2();
|
|
1467
|
+
// TODO(burdon): Swarm => Peer.create/destroy =< Connection.open/close
|
|
1468
|
+
// TODO(burdon): Pass in object.
|
|
1469
|
+
constructor(_topic, _ownPeer, _topology, _protocolProvider, _messenger, _transportFactory, _label, _connectionLimiter, _initiationDelay = INITIATION_DELAY) {
|
|
1470
|
+
this._topic = _topic;
|
|
1471
|
+
this._ownPeer = _ownPeer;
|
|
1472
|
+
this._topology = _topology;
|
|
1473
|
+
this._protocolProvider = _protocolProvider;
|
|
1474
|
+
this._messenger = _messenger;
|
|
1475
|
+
this._transportFactory = _transportFactory;
|
|
1476
|
+
this._label = _label;
|
|
1477
|
+
this._connectionLimiter = _connectionLimiter;
|
|
1478
|
+
this._initiationDelay = _initiationDelay;
|
|
1479
|
+
log5.trace("dxos.mesh.swarm.constructor", trace2.begin({
|
|
1480
|
+
id: this._instanceId,
|
|
1481
|
+
data: {
|
|
1482
|
+
topic: this._topic.toHex(),
|
|
1483
|
+
peer: this._ownPeer
|
|
1484
|
+
}
|
|
1485
|
+
}), {
|
|
1486
|
+
F: __dxlog_file5,
|
|
1487
|
+
L: 89,
|
|
1488
|
+
S: this,
|
|
1489
|
+
C: (f, a) => f(...a)
|
|
1490
|
+
});
|
|
1491
|
+
log5("creating swarm", {
|
|
1492
|
+
peerId: _ownPeer
|
|
1493
|
+
}, {
|
|
1494
|
+
F: __dxlog_file5,
|
|
1495
|
+
L: 93,
|
|
1496
|
+
S: this,
|
|
1497
|
+
C: (f, a) => f(...a)
|
|
1498
|
+
});
|
|
1499
|
+
_topology.init(this._getSwarmController());
|
|
1500
|
+
this._swarmMessenger = new SwarmMessenger({
|
|
1501
|
+
sendMessage: async (msg) => await this._messenger.sendMessage(msg),
|
|
1502
|
+
onSignal: async (msg) => await this.onSignal(msg),
|
|
1503
|
+
onOffer: async (msg) => await this.onOffer(msg),
|
|
1504
|
+
topic: this._topic
|
|
1505
|
+
});
|
|
1506
|
+
log5.trace("dxos.mesh.swarm.constructor", trace2.end({
|
|
1507
|
+
id: this._instanceId
|
|
1508
|
+
}), {
|
|
1509
|
+
F: __dxlog_file5,
|
|
1510
|
+
L: 102,
|
|
1511
|
+
S: this,
|
|
1512
|
+
C: (f, a) => f(...a)
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1492
1515
|
get connections() {
|
|
1493
1516
|
return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNonNullable2);
|
|
1494
1517
|
}
|
|
@@ -1963,83 +1986,6 @@ var Swarm = class {
|
|
|
1963
1986
|
_isUnregistered(peer) {
|
|
1964
1987
|
return !peer || this._peers.get(peer.remoteInfo) !== peer;
|
|
1965
1988
|
}
|
|
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
1989
|
};
|
|
2044
1990
|
_ts_decorate3([
|
|
2045
1991
|
logInfo2
|
|
@@ -2069,24 +2015,31 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
|
2069
2015
|
import { log as log6 } from "@dxos/log";
|
|
2070
2016
|
import { PeerInfoHash as PeerInfoHash2 } from "@dxos/messaging";
|
|
2071
2017
|
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
2018
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
2086
2019
|
var SwarmMapper = class {
|
|
2020
|
+
_swarm;
|
|
2021
|
+
_subscriptions = new SubscriptionList();
|
|
2022
|
+
_connectionSubscriptions = new ComplexMap3(PeerInfoHash2);
|
|
2023
|
+
_peers = new ComplexMap3(PeerInfoHash2);
|
|
2024
|
+
mapUpdated = new Event4();
|
|
2087
2025
|
get peers() {
|
|
2088
2026
|
return Array.from(this._peers.values());
|
|
2089
2027
|
}
|
|
2028
|
+
constructor(_swarm) {
|
|
2029
|
+
this._swarm = _swarm;
|
|
2030
|
+
this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
|
|
2031
|
+
this._update();
|
|
2032
|
+
this._connectionSubscriptions.set(connection.remoteInfo, connection.stateChanged.on(() => {
|
|
2033
|
+
this._update();
|
|
2034
|
+
}));
|
|
2035
|
+
}));
|
|
2036
|
+
this._subscriptions.add(_swarm.disconnected.on((peerId) => {
|
|
2037
|
+
this._connectionSubscriptions.get(peerId)?.();
|
|
2038
|
+
this._connectionSubscriptions.delete(peerId);
|
|
2039
|
+
this._update();
|
|
2040
|
+
}));
|
|
2041
|
+
this._update();
|
|
2042
|
+
}
|
|
2090
2043
|
_update() {
|
|
2091
2044
|
log6("updating swarm", void 0, {
|
|
2092
2045
|
F: __dxlog_file6,
|
|
@@ -2126,30 +2079,6 @@ var SwarmMapper = class {
|
|
|
2126
2079
|
this._connectionSubscriptions.clear();
|
|
2127
2080
|
this._subscriptions.clear();
|
|
2128
2081
|
}
|
|
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
2082
|
};
|
|
2154
2083
|
|
|
2155
2084
|
// src/swarm/connection-limiter.ts
|
|
@@ -2160,22 +2089,26 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
2160
2089
|
import { log as log7 } from "@dxos/log";
|
|
2161
2090
|
import { CancelledError as CancelledError3 } from "@dxos/protocols";
|
|
2162
2091
|
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
2092
|
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
2177
2093
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
2178
2094
|
var ConnectionLimiter = class {
|
|
2095
|
+
_ctx = new Context5(void 0, {
|
|
2096
|
+
F: __dxlog_file7,
|
|
2097
|
+
L: 23
|
|
2098
|
+
});
|
|
2099
|
+
_maxConcurrentInitConnections;
|
|
2100
|
+
/**
|
|
2101
|
+
* Queue of promises to resolve when initiating connections amount is below the limit.
|
|
2102
|
+
*/
|
|
2103
|
+
_waitingPromises = new ComplexMap4(PublicKey6.hash);
|
|
2104
|
+
resolveWaitingPromises = new DeferredTask2(this._ctx, async () => {
|
|
2105
|
+
Array.from(this._waitingPromises.values()).slice(0, this._maxConcurrentInitConnections).forEach(({ resolve }) => {
|
|
2106
|
+
resolve();
|
|
2107
|
+
});
|
|
2108
|
+
});
|
|
2109
|
+
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
2110
|
+
this._maxConcurrentInitConnections = maxConcurrentInitConnections;
|
|
2111
|
+
}
|
|
2179
2112
|
/**
|
|
2180
2113
|
* @returns Promise that resolves in queue when connections amount with 'CONNECTING' state is below the limit.
|
|
2181
2114
|
*/
|
|
@@ -2232,20 +2165,6 @@ var ConnectionLimiter = class {
|
|
|
2232
2165
|
this._waitingPromises.delete(sessionId);
|
|
2233
2166
|
this.resolveWaitingPromises.schedule();
|
|
2234
2167
|
}
|
|
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
2168
|
};
|
|
2250
2169
|
|
|
2251
2170
|
// src/connection-log.ts
|
|
@@ -2253,19 +2172,6 @@ import { Event as Event5 } from "@dxos/async";
|
|
|
2253
2172
|
import { raise } from "@dxos/debug";
|
|
2254
2173
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2255
2174
|
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
2175
|
var CONNECTION_GC_THRESHOLD = 1e3 * 60 * 15;
|
|
2270
2176
|
var EventType = /* @__PURE__ */ (function(EventType2) {
|
|
2271
2177
|
EventType2["CONNECTION_STATE_CHANGED"] = "CONNECTION_STATE_CHANGED";
|
|
@@ -2276,6 +2182,11 @@ var EventType = /* @__PURE__ */ (function(EventType2) {
|
|
|
2276
2182
|
return EventType2;
|
|
2277
2183
|
})({});
|
|
2278
2184
|
var ConnectionLog = class {
|
|
2185
|
+
/**
|
|
2186
|
+
* SwarmId => info
|
|
2187
|
+
*/
|
|
2188
|
+
_swarms = new ComplexMap5(PublicKey7.hash);
|
|
2189
|
+
update = new Event5();
|
|
2279
2190
|
getSwarmInfo(swarmId) {
|
|
2280
2191
|
return this._swarms.get(swarmId) ?? raise(new Error(`Swarm not found: ${swarmId}`));
|
|
2281
2192
|
}
|
|
@@ -2339,10 +2250,6 @@ var ConnectionLog = class {
|
|
|
2339
2250
|
this.getSwarmInfo(PublicKey7.from(swarm._instanceId)).isActive = false;
|
|
2340
2251
|
this.update.emit();
|
|
2341
2252
|
}
|
|
2342
|
-
constructor() {
|
|
2343
|
-
_define_property7(this, "_swarms", new ComplexMap5(PublicKey7.hash));
|
|
2344
|
-
_define_property7(this, "update", new Event5());
|
|
2345
|
-
}
|
|
2346
2253
|
};
|
|
2347
2254
|
var gcSwarm = (swarm) => {
|
|
2348
2255
|
swarm.connections = swarm.connections?.filter((connection) => {
|
|
@@ -2359,19 +2266,6 @@ import { Messenger } from "@dxos/messaging";
|
|
|
2359
2266
|
import { trace as trace3 } from "@dxos/protocols";
|
|
2360
2267
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2361
2268
|
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
2269
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2376
2270
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2377
2271
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2380,6 +2274,39 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2380
2274
|
}
|
|
2381
2275
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2382
2276
|
var SwarmNetworkManager = class {
|
|
2277
|
+
/**
|
|
2278
|
+
* @internal
|
|
2279
|
+
*/
|
|
2280
|
+
_swarms = new ComplexMap6(PublicKey8.hash);
|
|
2281
|
+
_mappers = new ComplexMap6(PublicKey8.hash);
|
|
2282
|
+
_transportFactory;
|
|
2283
|
+
_signalManager;
|
|
2284
|
+
_messenger;
|
|
2285
|
+
_signalConnection;
|
|
2286
|
+
_connectionLimiter;
|
|
2287
|
+
_connectionLog;
|
|
2288
|
+
_instanceId = PublicKey8.random().toHex();
|
|
2289
|
+
_peerInfo = void 0;
|
|
2290
|
+
_connectionState = ConnectionState2.ONLINE;
|
|
2291
|
+
connectionStateChanged = new Event6();
|
|
2292
|
+
topicsUpdated = new Event6();
|
|
2293
|
+
constructor({ transportFactory, signalManager, enableDevtoolsLogging, peerInfo }) {
|
|
2294
|
+
this._transportFactory = transportFactory;
|
|
2295
|
+
this._signalManager = signalManager;
|
|
2296
|
+
this._signalManager.swarmEvent.on((event) => this._swarms.get(event.topic)?.onSwarmEvent(event));
|
|
2297
|
+
this._messenger = new Messenger({
|
|
2298
|
+
signalManager: this._signalManager
|
|
2299
|
+
});
|
|
2300
|
+
this._signalConnection = {
|
|
2301
|
+
join: (opts) => this._signalManager.join(opts),
|
|
2302
|
+
leave: (opts) => this._signalManager.leave(opts)
|
|
2303
|
+
};
|
|
2304
|
+
this._peerInfo = peerInfo;
|
|
2305
|
+
this._connectionLimiter = new ConnectionLimiter();
|
|
2306
|
+
if (enableDevtoolsLogging) {
|
|
2307
|
+
this._connectionLog = new ConnectionLog();
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2383
2310
|
// TODO(burdon): Remove access (Devtools only).
|
|
2384
2311
|
get connectionLog() {
|
|
2385
2312
|
return this._connectionLog;
|
|
@@ -2588,36 +2515,6 @@ var SwarmNetworkManager = class {
|
|
|
2588
2515
|
}
|
|
2589
2516
|
this.connectionStateChanged.emit(this._connectionState);
|
|
2590
2517
|
}
|
|
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
2518
|
};
|
|
2622
2519
|
_ts_decorate4([
|
|
2623
2520
|
synchronized4
|
|
@@ -2628,21 +2525,9 @@ _ts_decorate4([
|
|
|
2628
2525
|
|
|
2629
2526
|
// src/topology/fully-connected-topology.ts
|
|
2630
2527
|
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
2528
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2645
2529
|
var FullyConnectedTopology = class {
|
|
2530
|
+
_controller;
|
|
2646
2531
|
toString() {
|
|
2647
2532
|
return "FullyConnectedTopology";
|
|
2648
2533
|
}
|
|
@@ -2678,31 +2563,26 @@ var FullyConnectedTopology = class {
|
|
|
2678
2563
|
}
|
|
2679
2564
|
async destroy() {
|
|
2680
2565
|
}
|
|
2681
|
-
constructor() {
|
|
2682
|
-
_define_property9(this, "_controller", void 0);
|
|
2683
|
-
}
|
|
2684
2566
|
};
|
|
2685
2567
|
|
|
2686
2568
|
// src/topology/mmst-topology.ts
|
|
2687
2569
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2688
2570
|
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
2571
|
var __dxlog_file10 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2703
2572
|
var MIN_UPDATE_INTERVAL = 1e3 * 10;
|
|
2704
2573
|
var MAX_CHANGES_PER_UPDATE = 1;
|
|
2705
2574
|
var MMSTTopology = class {
|
|
2575
|
+
_originateConnections;
|
|
2576
|
+
_maxPeers;
|
|
2577
|
+
_sampleSize;
|
|
2578
|
+
_controller;
|
|
2579
|
+
_sampleCollected = false;
|
|
2580
|
+
_lastAction = /* @__PURE__ */ new Date(0);
|
|
2581
|
+
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2582
|
+
this._originateConnections = originateConnections;
|
|
2583
|
+
this._maxPeers = maxPeers;
|
|
2584
|
+
this._sampleSize = sampleSize;
|
|
2585
|
+
}
|
|
2706
2586
|
init(controller) {
|
|
2707
2587
|
invariant8(!this._controller, "Already initialized", {
|
|
2708
2588
|
F: __dxlog_file10,
|
|
@@ -2859,17 +2739,6 @@ var MMSTTopology = class {
|
|
|
2859
2739
|
toString() {
|
|
2860
2740
|
return "MMSTTopology";
|
|
2861
2741
|
}
|
|
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
2742
|
};
|
|
2874
2743
|
var sortByXorDistance = (keys, reference) => {
|
|
2875
2744
|
const sorted = keys.sort((a, b) => {
|
|
@@ -2909,21 +2778,13 @@ var compareXor = (a, b) => {
|
|
|
2909
2778
|
// src/topology/star-topology.ts
|
|
2910
2779
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2911
2780
|
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
2781
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2926
2782
|
var StarTopology = class {
|
|
2783
|
+
_centralPeer;
|
|
2784
|
+
_controller;
|
|
2785
|
+
constructor(_centralPeer) {
|
|
2786
|
+
this._centralPeer = _centralPeer;
|
|
2787
|
+
}
|
|
2927
2788
|
toString() {
|
|
2928
2789
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
2929
2790
|
}
|
|
@@ -3010,11 +2871,6 @@ var StarTopology = class {
|
|
|
3010
2871
|
}
|
|
3011
2872
|
async destroy() {
|
|
3012
2873
|
}
|
|
3013
|
-
constructor(_centralPeer) {
|
|
3014
|
-
_define_property11(this, "_centralPeer", void 0);
|
|
3015
|
-
_define_property11(this, "_controller", void 0);
|
|
3016
|
-
this._centralPeer = _centralPeer;
|
|
3017
|
-
}
|
|
3018
2874
|
};
|
|
3019
2875
|
|
|
3020
2876
|
// src/transport/memory-transport.ts
|
|
@@ -3025,19 +2881,6 @@ import { invariant as invariant10 } from "@dxos/invariant";
|
|
|
3025
2881
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3026
2882
|
import { log as log11, logInfo as logInfo3 } from "@dxos/log";
|
|
3027
2883
|
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
2884
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
3042
2885
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3043
2886
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3058,6 +2901,32 @@ var MemoryTransportFactory = {
|
|
|
3058
2901
|
createTransport: (options) => new MemoryTransport(options)
|
|
3059
2902
|
};
|
|
3060
2903
|
var MemoryTransport = class _MemoryTransport {
|
|
2904
|
+
_options;
|
|
2905
|
+
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
2906
|
+
static _connections = new ComplexMap7(PublicKey9.hash);
|
|
2907
|
+
_instanceId = PublicKey9.random();
|
|
2908
|
+
_remote = new Trigger2();
|
|
2909
|
+
_outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
2910
|
+
_incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
2911
|
+
_closed = false;
|
|
2912
|
+
_remoteInstanceId;
|
|
2913
|
+
_remoteConnection;
|
|
2914
|
+
closed = new Event7();
|
|
2915
|
+
connected = new Event7();
|
|
2916
|
+
errors = new ErrorStream3();
|
|
2917
|
+
constructor(_options) {
|
|
2918
|
+
this._options = _options;
|
|
2919
|
+
invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
|
|
2920
|
+
F: __dxlog_file12,
|
|
2921
|
+
L: 64,
|
|
2922
|
+
S: this,
|
|
2923
|
+
A: [
|
|
2924
|
+
"!MemoryTransport._connections.has(this._instanceId)",
|
|
2925
|
+
"'Duplicate memory connection'"
|
|
2926
|
+
]
|
|
2927
|
+
});
|
|
2928
|
+
_MemoryTransport._connections.set(this._instanceId, this);
|
|
2929
|
+
}
|
|
3061
2930
|
get isOpen() {
|
|
3062
2931
|
return !this._closed;
|
|
3063
2932
|
}
|
|
@@ -3188,40 +3057,7 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
3188
3057
|
packetsReceived: 0
|
|
3189
3058
|
};
|
|
3190
3059
|
}
|
|
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
3060
|
};
|
|
3224
|
-
_define_property12(MemoryTransport, "_connections", new ComplexMap7(PublicKey9.hash));
|
|
3225
3061
|
_ts_decorate5([
|
|
3226
3062
|
logInfo3
|
|
3227
3063
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
@@ -3241,19 +3077,6 @@ var TransportKind = /* @__PURE__ */ (function(TransportKind2) {
|
|
|
3241
3077
|
|
|
3242
3078
|
// src/transport/webrtc/rtc-connection-factory.ts
|
|
3243
3079
|
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
3080
|
var BrowserRtcConnectionFactory = class {
|
|
3258
3081
|
async initialize() {
|
|
3259
3082
|
}
|
|
@@ -3266,6 +3089,8 @@ var BrowserRtcConnectionFactory = class {
|
|
|
3266
3089
|
}
|
|
3267
3090
|
};
|
|
3268
3091
|
var NodeRtcConnectionFactory = class _NodeRtcConnectionFactory {
|
|
3092
|
+
static _createdConnections = 0;
|
|
3093
|
+
static _cleanupMutex = new Mutex();
|
|
3269
3094
|
// This should be inside the function to avoid triggering `eval` in the global scope.
|
|
3270
3095
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
3271
3096
|
// TODO(burdon): Do imports here?
|
|
@@ -3291,8 +3116,6 @@ var NodeRtcConnectionFactory = class _NodeRtcConnectionFactory {
|
|
|
3291
3116
|
}
|
|
3292
3117
|
}
|
|
3293
3118
|
};
|
|
3294
|
-
_define_property13(NodeRtcConnectionFactory, "_createdConnections", 0);
|
|
3295
|
-
_define_property13(NodeRtcConnectionFactory, "_cleanupMutex", new Mutex());
|
|
3296
3119
|
var getRtcConnectionFactory = () => {
|
|
3297
3120
|
return typeof globalThis.RTCPeerConnection === "undefined" ? new NodeRtcConnectionFactory() : new BrowserRtcConnectionFactory();
|
|
3298
3121
|
};
|
|
@@ -3361,23 +3184,22 @@ var getRtcConnectionStats = async (connection, channelTopic) => {
|
|
|
3361
3184
|
};
|
|
3362
3185
|
|
|
3363
3186
|
// 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
3187
|
var __dxlog_file13 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
|
|
3378
3188
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
3379
3189
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3380
3190
|
var RtcTransportChannel = class extends Resource {
|
|
3191
|
+
_connection;
|
|
3192
|
+
_options;
|
|
3193
|
+
closed = new AsyncEvent();
|
|
3194
|
+
connected = new AsyncEvent();
|
|
3195
|
+
errors = new ErrorStream4();
|
|
3196
|
+
_channel;
|
|
3197
|
+
_stream;
|
|
3198
|
+
_streamDataFlushedCallback = null;
|
|
3199
|
+
_isChannelCreationInProgress = false;
|
|
3200
|
+
constructor(_connection, _options) {
|
|
3201
|
+
super(), this._connection = _connection, this._options = _options;
|
|
3202
|
+
}
|
|
3381
3203
|
get isRtcChannelCreationInProgress() {
|
|
3382
3204
|
return this._isChannelCreationInProgress;
|
|
3383
3205
|
}
|
|
@@ -3566,9 +3388,6 @@ var RtcTransportChannel = class extends Resource {
|
|
|
3566
3388
|
async getStats() {
|
|
3567
3389
|
return createRtcTransportStats(this._connection.currentConnection, this._options.topic);
|
|
3568
3390
|
}
|
|
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
3391
|
};
|
|
3573
3392
|
|
|
3574
3393
|
// src/transport/webrtc/utils.ts
|
|
@@ -3598,19 +3417,6 @@ var deduplicatedSdpLines = (sdp) => {
|
|
|
3598
3417
|
};
|
|
3599
3418
|
|
|
3600
3419
|
// 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
3420
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
3615
3421
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3616
3422
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3619,6 +3425,29 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
3619
3425
|
}
|
|
3620
3426
|
var __dxlog_file14 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
|
|
3621
3427
|
var RtcPeerConnection = class {
|
|
3428
|
+
_factory;
|
|
3429
|
+
_options;
|
|
3430
|
+
// A peer who is not the initiator waits for another party to open a channel.
|
|
3431
|
+
_channelCreatedCallbacks = /* @__PURE__ */ new Map();
|
|
3432
|
+
// Channels indexed by topic.
|
|
3433
|
+
_transportChannels = /* @__PURE__ */ new Map();
|
|
3434
|
+
_dataChannels = /* @__PURE__ */ new Map();
|
|
3435
|
+
// A peer is ready to receive ICE candidates when local and remote description were set.
|
|
3436
|
+
_readyForCandidates = new Trigger3();
|
|
3437
|
+
_offerProcessingMutex = new Mutex2();
|
|
3438
|
+
/**
|
|
3439
|
+
* Can't use peer.connection.initiator, because if two connections to the same peer are created in
|
|
3440
|
+
* different swarms, we might be the initiator of the first one, but not of the other one.
|
|
3441
|
+
* Use a stable peer keypair property (key ordering) to decide who's acting as the initiator of
|
|
3442
|
+
* transport connection establishment and data channel creation.
|
|
3443
|
+
*/
|
|
3444
|
+
_initiator;
|
|
3445
|
+
_connection;
|
|
3446
|
+
constructor(_factory, _options) {
|
|
3447
|
+
this._factory = _factory;
|
|
3448
|
+
this._options = _options;
|
|
3449
|
+
this._initiator = chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
|
|
3450
|
+
}
|
|
3622
3451
|
get transportChannelCount() {
|
|
3623
3452
|
return this._transportChannels.size;
|
|
3624
3453
|
}
|
|
@@ -4142,25 +3971,6 @@ var RtcPeerConnection = class {
|
|
|
4142
3971
|
channels: this._transportChannels.size
|
|
4143
3972
|
};
|
|
4144
3973
|
}
|
|
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
3974
|
};
|
|
4165
3975
|
_ts_decorate6([
|
|
4166
3976
|
synchronized5
|
|
@@ -4224,24 +4034,20 @@ import { log as log14 } from "@dxos/log";
|
|
|
4224
4034
|
import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError4, TimeoutError as TimeoutError3 } from "@dxos/protocols";
|
|
4225
4035
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
4226
4036
|
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
4037
|
var __dxlog_file15 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
|
|
4241
4038
|
var RPC_TIMEOUT = 1e4;
|
|
4242
4039
|
var CLOSE_RPC_TIMEOUT = 3e3;
|
|
4243
4040
|
var RESP_MIN_THRESHOLD = 500;
|
|
4244
4041
|
var RtcTransportProxy = class extends Resource2 {
|
|
4042
|
+
_options;
|
|
4043
|
+
_proxyId = PublicKey10.random();
|
|
4044
|
+
closed = new Event8();
|
|
4045
|
+
connected = new Event8();
|
|
4046
|
+
errors = new ErrorStream5();
|
|
4047
|
+
_serviceStream;
|
|
4048
|
+
constructor(_options) {
|
|
4049
|
+
super(), this._options = _options;
|
|
4050
|
+
}
|
|
4245
4051
|
async _open() {
|
|
4246
4052
|
let stream;
|
|
4247
4053
|
try {
|
|
@@ -4447,11 +4253,10 @@ var RtcTransportProxy = class extends Resource2 {
|
|
|
4447
4253
|
void this._serviceStream?.close();
|
|
4448
4254
|
this.closed.emit();
|
|
4449
4255
|
}
|
|
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
4256
|
};
|
|
4454
4257
|
var RtcTransportProxyFactory = class {
|
|
4258
|
+
_bridgeService;
|
|
4259
|
+
_connections = /* @__PURE__ */ new Set();
|
|
4455
4260
|
/**
|
|
4456
4261
|
* Sets the current BridgeService to be used to open connections.
|
|
4457
4262
|
* Calling this method will close any existing connections.
|
|
@@ -4483,10 +4288,6 @@ var RtcTransportProxyFactory = class {
|
|
|
4483
4288
|
});
|
|
4484
4289
|
return transport;
|
|
4485
4290
|
}
|
|
4486
|
-
constructor() {
|
|
4487
|
-
_define_property16(this, "_bridgeService", void 0);
|
|
4488
|
-
_define_property16(this, "_connections", /* @__PURE__ */ new Set());
|
|
4489
|
-
}
|
|
4490
4291
|
};
|
|
4491
4292
|
var decodeError = (err) => {
|
|
4492
4293
|
const message = typeof err === "string" ? err : err.message;
|
|
@@ -4509,21 +4310,13 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
4509
4310
|
import { log as log15 } from "@dxos/log";
|
|
4510
4311
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
4511
4312
|
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
4313
|
var __dxlog_file16 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
|
|
4526
4314
|
var RtcTransportService = class {
|
|
4315
|
+
_transportFactory;
|
|
4316
|
+
_openTransports = new ComplexMap8(PublicKey11.hash);
|
|
4317
|
+
constructor(webrtcConfig, iceProvider, _transportFactory = createRtcTransportFactory(webrtcConfig, iceProvider)) {
|
|
4318
|
+
this._transportFactory = _transportFactory;
|
|
4319
|
+
}
|
|
4527
4320
|
hasOpenTransports() {
|
|
4528
4321
|
return this._openTransports.size > 0;
|
|
4529
4322
|
}
|
|
@@ -4710,12 +4503,6 @@ var RtcTransportService = class {
|
|
|
4710
4503
|
C: (f, a) => f(...a)
|
|
4711
4504
|
});
|
|
4712
4505
|
}
|
|
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
4506
|
};
|
|
4720
4507
|
var createStateUpdater = (next) => {
|
|
4721
4508
|
return (state, err) => {
|
|
@@ -4778,4 +4565,4 @@ export {
|
|
|
4778
4565
|
RtcTransportService,
|
|
4779
4566
|
createTeleportProtocolFactory
|
|
4780
4567
|
};
|
|
4781
|
-
//# sourceMappingURL=chunk-
|
|
4568
|
+
//# sourceMappingURL=chunk-E3P563GT.mjs.map
|