@dxos/network-manager 0.1.21 → 0.1.23
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/index.mjs +39 -42
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +41 -44
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +39 -42
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +40 -43
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/swarm/swarm.d.ts +0 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
- package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/network-manager.ts +2 -2
- package/src/swarm/swarm.ts +16 -16
- package/src/testing/test-wire-protocol.ts +5 -2
- package/src/tests/basic-test-suite.ts +41 -17
- package/src/tests/webrtc-transport.test.ts +0 -3
package/dist/lib/node/index.cjs
CHANGED
|
@@ -770,7 +770,7 @@ var Swarm = class {
|
|
|
770
770
|
peerId: _ownPeerId
|
|
771
771
|
}, {
|
|
772
772
|
file: "swarm.ts",
|
|
773
|
-
line:
|
|
773
|
+
line: 83,
|
|
774
774
|
scope: this,
|
|
775
775
|
callSite: (f, a) => f(...a)
|
|
776
776
|
});
|
|
@@ -787,7 +787,7 @@ var Swarm = class {
|
|
|
787
787
|
onMessage: async (message) => await this._swarmMessenger.receiveMessage(message)
|
|
788
788
|
}).catch((error) => import_log4.log.catch(error, {}, {
|
|
789
789
|
file: "swarm.ts",
|
|
790
|
-
line:
|
|
790
|
+
line: 99,
|
|
791
791
|
scope: this,
|
|
792
792
|
callSite: (f, a) => f(...a)
|
|
793
793
|
}));
|
|
@@ -811,7 +811,7 @@ var Swarm = class {
|
|
|
811
811
|
async destroy() {
|
|
812
812
|
(0, import_log4.log)("destroying...", {}, {
|
|
813
813
|
file: "swarm.ts",
|
|
814
|
-
line:
|
|
814
|
+
line: 127,
|
|
815
815
|
scope: this,
|
|
816
816
|
callSite: (f, a) => f(...a)
|
|
817
817
|
});
|
|
@@ -820,7 +820,7 @@ var Swarm = class {
|
|
|
820
820
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
821
821
|
(0, import_log4.log)("destroyed", {}, {
|
|
822
822
|
file: "swarm.ts",
|
|
823
|
-
line:
|
|
823
|
+
line: 131,
|
|
824
824
|
scope: this,
|
|
825
825
|
callSite: (f, a) => f(...a)
|
|
826
826
|
});
|
|
@@ -835,7 +835,7 @@ var Swarm = class {
|
|
|
835
835
|
topology: getClassName(topology)
|
|
836
836
|
}, {
|
|
837
837
|
file: "swarm.ts",
|
|
838
|
-
line:
|
|
838
|
+
line: 139,
|
|
839
839
|
scope: this,
|
|
840
840
|
callSite: (f, a) => f(...a)
|
|
841
841
|
});
|
|
@@ -845,30 +845,31 @@ var Swarm = class {
|
|
|
845
845
|
this._topology.update();
|
|
846
846
|
}
|
|
847
847
|
onSwarmEvent(swarmEvent) {
|
|
848
|
+
var _a;
|
|
848
849
|
(0, import_log4.log)("swarm event", {
|
|
849
850
|
swarmEvent
|
|
850
851
|
}, {
|
|
851
852
|
file: "swarm.ts",
|
|
852
|
-
line:
|
|
853
|
+
line: 152,
|
|
853
854
|
scope: this,
|
|
854
855
|
callSite: (f, a) => f(...a)
|
|
855
856
|
});
|
|
857
|
+
if (this._ctx.disposed) {
|
|
858
|
+
import_log4.log.warn("ignored for offline swarm", {}, {
|
|
859
|
+
file: "swarm.ts",
|
|
860
|
+
line: 155,
|
|
861
|
+
scope: this,
|
|
862
|
+
callSite: (f, a) => f(...a)
|
|
863
|
+
});
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
856
866
|
if (swarmEvent.peerAvailable) {
|
|
857
|
-
if (this._ctx.disposed) {
|
|
858
|
-
import_log4.log.warn("ignored for offline swarm", {}, {
|
|
859
|
-
file: "swarm.ts",
|
|
860
|
-
line: 153,
|
|
861
|
-
scope: this,
|
|
862
|
-
callSite: (f, a) => f(...a)
|
|
863
|
-
});
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
867
|
const peerId = import_keys3.PublicKey.from(swarmEvent.peerAvailable.peer);
|
|
867
868
|
(0, import_log4.log)("new peer", {
|
|
868
869
|
peerId
|
|
869
870
|
}, {
|
|
870
871
|
file: "swarm.ts",
|
|
871
|
-
line:
|
|
872
|
+
line: 161,
|
|
872
873
|
scope: this,
|
|
873
874
|
callSite: (f, a) => f(...a)
|
|
874
875
|
});
|
|
@@ -880,10 +881,10 @@ var Swarm = class {
|
|
|
880
881
|
const peer1 = this._peers.get(import_keys3.PublicKey.from(swarmEvent.peerLeft.peer));
|
|
881
882
|
if (peer1) {
|
|
882
883
|
peer1.advertizing = false;
|
|
883
|
-
if (
|
|
884
|
+
if (((_a = peer1.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
|
|
884
885
|
void this._destroyPeer(peer1.id).catch((err) => import_log4.log.catch(err, {}, {
|
|
885
886
|
file: "swarm.ts",
|
|
886
|
-
line:
|
|
887
|
+
line: 172,
|
|
887
888
|
scope: this,
|
|
888
889
|
callSite: (f, a) => f(...a)
|
|
889
890
|
}));
|
|
@@ -898,14 +899,14 @@ var Swarm = class {
|
|
|
898
899
|
message
|
|
899
900
|
}, {
|
|
900
901
|
file: "swarm.ts",
|
|
901
|
-
line:
|
|
902
|
+
line: 182,
|
|
902
903
|
scope: this,
|
|
903
904
|
callSite: (f, a) => f(...a)
|
|
904
905
|
});
|
|
905
906
|
if (this._ctx.disposed) {
|
|
906
907
|
import_log4.log.info("ignored for offline swarm", {}, {
|
|
907
908
|
file: "swarm.ts",
|
|
908
|
-
line:
|
|
909
|
+
line: 184,
|
|
909
910
|
scope: this,
|
|
910
911
|
callSite: (f, a) => f(...a)
|
|
911
912
|
});
|
|
@@ -919,7 +920,7 @@ var Swarm = class {
|
|
|
919
920
|
message
|
|
920
921
|
}, {
|
|
921
922
|
file: "swarm.ts",
|
|
922
|
-
line:
|
|
923
|
+
line: 191,
|
|
923
924
|
scope: this,
|
|
924
925
|
callSite: (f, a) => f(...a)
|
|
925
926
|
});
|
|
@@ -932,7 +933,7 @@ var Swarm = class {
|
|
|
932
933
|
message
|
|
933
934
|
}, {
|
|
934
935
|
file: "swarm.ts",
|
|
935
|
-
line:
|
|
936
|
+
line: 195,
|
|
936
937
|
scope: this,
|
|
937
938
|
callSite: (f, a) => f(...a)
|
|
938
939
|
});
|
|
@@ -951,14 +952,14 @@ var Swarm = class {
|
|
|
951
952
|
message
|
|
952
953
|
}, {
|
|
953
954
|
file: "swarm.ts",
|
|
954
|
-
line:
|
|
955
|
+
line: 207,
|
|
955
956
|
scope: this,
|
|
956
957
|
callSite: (f, a) => f(...a)
|
|
957
958
|
});
|
|
958
959
|
if (this._ctx.disposed) {
|
|
959
960
|
import_log4.log.info("ignored for offline swarm", {}, {
|
|
960
961
|
file: "swarm.ts",
|
|
961
|
-
line:
|
|
962
|
+
line: 209,
|
|
962
963
|
scope: this,
|
|
963
964
|
callSite: (f, a) => f(...a)
|
|
964
965
|
});
|
|
@@ -973,24 +974,13 @@ var Swarm = class {
|
|
|
973
974
|
// For debug purposes
|
|
974
975
|
async goOffline() {
|
|
975
976
|
await this._ctx.dispose();
|
|
976
|
-
[
|
|
977
|
-
...this._peers.values()
|
|
978
|
-
].forEach((peer) => {
|
|
979
|
-
peer.advertizing = false;
|
|
980
|
-
});
|
|
981
977
|
await Promise.all([
|
|
982
978
|
...this._peers.keys()
|
|
983
|
-
].map((peerId) => this.
|
|
979
|
+
].map((peerId) => this._destroyPeer(peerId)));
|
|
984
980
|
}
|
|
985
981
|
// For debug purposes
|
|
986
982
|
async goOnline() {
|
|
987
983
|
this._ctx = new import_context.Context();
|
|
988
|
-
[
|
|
989
|
-
...this._peers.values()
|
|
990
|
-
].forEach((peer) => {
|
|
991
|
-
peer.advertizing = true;
|
|
992
|
-
});
|
|
993
|
-
this._topology.update();
|
|
994
984
|
}
|
|
995
985
|
_getOrCreatePeer(peerId) {
|
|
996
986
|
let peer = this._peers.get(peerId);
|
|
@@ -1047,7 +1037,7 @@ var Swarm = class {
|
|
|
1047
1037
|
} catch (err) {
|
|
1048
1038
|
import_log4.log.warn("initiation error", err, {
|
|
1049
1039
|
file: "swarm.ts",
|
|
1050
|
-
line:
|
|
1040
|
+
line: 309,
|
|
1051
1041
|
scope: this,
|
|
1052
1042
|
callSite: (f, a) => f(...a)
|
|
1053
1043
|
});
|
|
@@ -1069,6 +1059,7 @@ var Swarm = class {
|
|
|
1069
1059
|
* Creates a connection then sends message over signal network.
|
|
1070
1060
|
*/
|
|
1071
1061
|
async _initiateConnection(remoteId) {
|
|
1062
|
+
const ctx = this._ctx;
|
|
1072
1063
|
if (remoteId.toHex() < this._ownPeerId.toHex()) {
|
|
1073
1064
|
(0, import_log4.log)("initiation delay", {
|
|
1074
1065
|
remoteId
|
|
@@ -1080,7 +1071,7 @@ var Swarm = class {
|
|
|
1080
1071
|
});
|
|
1081
1072
|
await (0, import_async3.sleep)(INITIATION_DELAY);
|
|
1082
1073
|
}
|
|
1083
|
-
if (
|
|
1074
|
+
if (ctx.disposed) {
|
|
1084
1075
|
return;
|
|
1085
1076
|
}
|
|
1086
1077
|
const peer = this._getOrCreatePeer(remoteId);
|
|
@@ -1129,6 +1120,12 @@ __decorate3([
|
|
|
1129
1120
|
__decorate3([
|
|
1130
1121
|
import_async3.synchronized
|
|
1131
1122
|
], Swarm.prototype, "onOffer", null);
|
|
1123
|
+
__decorate3([
|
|
1124
|
+
import_async3.synchronized
|
|
1125
|
+
], Swarm.prototype, "onSignal", null);
|
|
1126
|
+
__decorate3([
|
|
1127
|
+
import_async3.synchronized
|
|
1128
|
+
], Swarm.prototype, "goOffline", null);
|
|
1132
1129
|
__decorate3([
|
|
1133
1130
|
import_async3.synchronized
|
|
1134
1131
|
], Swarm.prototype, "goOnline", null);
|
|
@@ -1447,20 +1444,20 @@ var NetworkManager = class {
|
|
|
1447
1444
|
switch (state) {
|
|
1448
1445
|
case import_services.ConnectionState.OFFLINE: {
|
|
1449
1446
|
this._connectionState = state;
|
|
1450
|
-
await this._messenger.close();
|
|
1451
|
-
await this._signalManager.close();
|
|
1452
1447
|
await Promise.all([
|
|
1453
1448
|
...this._swarms.values()
|
|
1454
1449
|
].map((swarm) => swarm.goOffline()));
|
|
1450
|
+
await this._messenger.close();
|
|
1451
|
+
await this._signalManager.close();
|
|
1455
1452
|
break;
|
|
1456
1453
|
}
|
|
1457
1454
|
case import_services.ConnectionState.ONLINE: {
|
|
1458
1455
|
this._connectionState = state;
|
|
1459
|
-
this._messenger.open();
|
|
1460
|
-
await this._signalManager.open();
|
|
1461
1456
|
await Promise.all([
|
|
1462
1457
|
...this._swarms.values()
|
|
1463
1458
|
].map((swarm) => swarm.goOnline()));
|
|
1459
|
+
this._messenger.open();
|
|
1460
|
+
await this._signalManager.open();
|
|
1464
1461
|
break;
|
|
1465
1462
|
}
|
|
1466
1463
|
}
|