@dxos/network-manager 0.1.16 → 0.1.18
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 +144 -276
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +153 -342
- package/dist/lib/node/index.cjs +145 -281
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +153 -345
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/network-manager.d.ts +1 -5
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +4 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm-mapper.d.ts +1 -3
- package/dist/types/src/swarm/swarm-mapper.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +2 -2
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts +14 -0
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -0
- package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
- package/dist/types/src/tests/property-test-suite.d.ts.map +1 -1
- package/dist/types/src/tests/utils.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts +3 -3
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +0 -10
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +16 -18
- package/src/connection-log.ts +26 -26
- package/src/index.ts +0 -1
- package/src/network-manager.ts +1 -8
- package/src/swarm/connection.ts +12 -1
- package/src/swarm/peer.ts +1 -3
- package/src/swarm/swarm-mapper.ts +29 -31
- package/src/swarm/swarm.test.ts +12 -34
- package/src/testing/index.ts +0 -1
- package/src/testing/test-builder.ts +4 -7
- package/src/testing/test-wire-protocol.ts +44 -0
- package/src/tests/basic-test-suite.ts +13 -53
- package/src/tests/property-test-suite.ts +13 -15
- package/src/tests/utils.ts +10 -37
- package/src/transport/memory-transport.test.ts +13 -52
- package/src/transport/memory-transport.ts +37 -29
- package/src/transport/webrtc-transport-proxy.test.ts +13 -73
- package/src/transport/webrtc-transport.test.ts +7 -38
- package/src/wire-protocol.ts +0 -24
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/types/src/protocol-factory.d.ts +0 -36
- package/dist/types/src/protocol-factory.d.ts.map +0 -1
- package/dist/types/src/testing/test-protocol.d.ts +0 -52
- package/dist/types/src/testing/test-protocol.d.ts.map +0 -1
- package/dist/types/src/tests/presence.test.d.ts +0 -2
- package/dist/types/src/tests/presence.test.d.ts.map +0 -1
- package/src/protocol-factory.ts +0 -88
- package/src/testing/test-protocol.ts +0 -166
- package/src/tests/presence.test.ts +0 -80
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
|
@@ -29,10 +29,6 @@ export declare type SwarmOptions = {
|
|
|
29
29
|
* Requested topology. Must be a new instance for every swarm.
|
|
30
30
|
*/
|
|
31
31
|
topology?: Topology;
|
|
32
|
-
/**
|
|
33
|
-
* Presence plugin for network mapping, if exists.
|
|
34
|
-
*/
|
|
35
|
-
presence?: any;
|
|
36
32
|
/**
|
|
37
33
|
* Custom label assigned to this swarm.
|
|
38
34
|
* Used in devtools to display human-readable names for swarms.
|
|
@@ -66,7 +62,7 @@ export declare class NetworkManager {
|
|
|
66
62
|
/**
|
|
67
63
|
* Join the swarm.
|
|
68
64
|
*/
|
|
69
|
-
joinSwarm({ topic, peerId, topology, protocolProvider: protocol,
|
|
65
|
+
joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }: SwarmOptions): Promise<SwarmConnection>;
|
|
70
66
|
/**
|
|
71
67
|
* Close the connection.
|
|
72
68
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-manager.d.ts","sourceRoot":"","sources":["../../../src/network-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAa,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;GAEG;AACH,oBAAY,eAAe,GAAG;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAGF,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC;IAElB;;OAEG;IACH,gBAAgB,EAA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AS;gBAGR,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,SAAS,EACrB,gBAAgB,EAAE,eAAe,EACjC,iBAAiB,EAAE,oBAAoB,EACvC,iBAAiB,EAAE,gBAAgB,EACnC,UAAU,EAAE,aAAa;IAG5C;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IA0CrD;;OAEG;IACG,kBAAkB;IAsCxB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmDnB,eAAe;IAcf,QAAQ,CAAC,OAAO,EAAE,aAAa;IAS/B,OAAO;CAMd"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
2
|
import { PublicKey } from '@dxos/keys';
|
|
3
|
-
import { PresencePlugin } from '@dxos/protocol-plugin-presence';
|
|
4
3
|
import { ConnectionState } from './connection';
|
|
5
4
|
import { Swarm } from './swarm';
|
|
6
5
|
/**
|
|
@@ -17,13 +16,12 @@ export interface PeerInfo {
|
|
|
17
16
|
}
|
|
18
17
|
export declare class SwarmMapper {
|
|
19
18
|
private readonly _swarm;
|
|
20
|
-
private readonly _presence;
|
|
21
19
|
private readonly _subscriptions;
|
|
22
20
|
private readonly _connectionSubscriptions;
|
|
23
21
|
private readonly _peers;
|
|
24
22
|
readonly mapUpdated: Event<PeerInfo[]>;
|
|
25
23
|
get peers(): PeerInfo[];
|
|
26
|
-
constructor(_swarm: Swarm
|
|
24
|
+
constructor(_swarm: Swarm);
|
|
27
25
|
private _update;
|
|
28
26
|
destroy(): void;
|
|
29
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-mapper.d.ts","sourceRoot":"","sources":["../../../../src/swarm/swarm-mapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAsB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"swarm-mapper.d.ts","sourceRoot":"","sources":["../../../../src/swarm/swarm-mapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAsB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;GAEG;AACH,oBAAY,SAAS,GAAG,eAAe,GAAG,sBAAsB,GAAG,IAAI,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,SAAS,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,EAAE,SAAS,EAAE,CAAC;CAC1B;AAID,qBAAa,WAAW;IAapB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAZzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA0D;IACnG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;IAE9E,QAAQ,CAAC,UAAU,oBAA2B;IAE9C,IAAI,KAAK,IAAI,QAAQ,EAAE,CAEtB;gBAIkB,MAAM,EAAE,KAAK;IAgChC,OAAO,CAAC,OAAO;IAmDf,OAAO;CAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { PublicKey } from '@dxos/keys';
|
|
|
2
2
|
import { MemorySignalManager, WebsocketSignalManager } from '@dxos/messaging';
|
|
3
3
|
import { NetworkManager } from '../network-manager';
|
|
4
4
|
import { FullyConnectedTopology } from '../topology';
|
|
5
|
-
import {
|
|
5
|
+
import { TestWireProtocol } from './test-wire-protocol';
|
|
6
6
|
export declare const TEST_SIGNAL_URL = "ws://localhost:4000/.well-known/dx/signal";
|
|
7
7
|
export declare type TestBuilderOptions = {
|
|
8
8
|
signalHosts?: string[];
|
|
@@ -37,7 +37,7 @@ export declare class TestPeer {
|
|
|
37
37
|
export declare class TestSwarmConnection {
|
|
38
38
|
readonly peer: TestPeer;
|
|
39
39
|
readonly topic: PublicKey;
|
|
40
|
-
|
|
40
|
+
protocol: TestWireProtocol;
|
|
41
41
|
constructor(peer: TestPeer, topic: PublicKey);
|
|
42
42
|
join(topology?: FullyConnectedTopology): Promise<this>;
|
|
43
43
|
leave(): Promise<this>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAA8B,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAK1G,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAA8B,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAK1G,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAQrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,eAAO,MAAM,eAAe,8CAA8C,CAAC;AAE3E,oBAAY,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,qBAAa,WAAW;aAGM,OAAO,EAAE,kBAAkB;IAFvD,OAAO,CAAC,cAAc,CAAoC;gBAE9B,OAAO,GAAE,kBAAuB;IAE5D,mBAAmB;IAQnB,UAAU;CAGX;AAED;;GAEG;AACH,qBAAa,QAAQ;IAaP,OAAO,CAAC,QAAQ,CAAC,WAAW;IAZxC,QAAQ,CAAC,MAAM,YAAsB;IAErC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkE;IAO1F,OAAO,CAAC,MAAM,CAAC,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAoB;gBAER,WAAW,EAAE,WAAW;IAKrD,oBAAoB;IA6Cd,IAAI;IAKJ,KAAK;IASX,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,mBAAmB;IAS/C,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,mBAAmB;CAUnD;AAGD,qBAAa,mBAAmB;IAGlB,QAAQ,CAAC,IAAI,EAAE,QAAQ;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS;IAF9D,QAAQ,EAAE,gBAAgB,CAAC;gBAEN,IAAI,EAAE,QAAQ,EAAW,KAAK,EAAE,SAAS;IAQxD,IAAI,CAAC,QAAQ,yBAA+B;IAW5C,KAAK;CAIZ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Event } from '@dxos/async';
|
|
2
|
+
import { PublicKey } from '@dxos/keys';
|
|
3
|
+
import { TestExtension } from '@dxos/teleport';
|
|
4
|
+
import { ComplexMap } from '@dxos/util';
|
|
5
|
+
export declare class TestWireProtocol {
|
|
6
|
+
readonly peerId: PublicKey;
|
|
7
|
+
readonly connections: ComplexMap<PublicKey, TestExtension>;
|
|
8
|
+
readonly connected: Event<PublicKey>;
|
|
9
|
+
constructor(peerId: PublicKey);
|
|
10
|
+
readonly factory: import("../wire-protocol").WireProtocolProvider;
|
|
11
|
+
waitForConnection(peerId: PublicKey): Promise<TestExtension>;
|
|
12
|
+
testConnection(peerId: PublicKey): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=test-wire-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-wire-protocol.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-wire-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC,qBAAa,gBAAgB;aAIC,MAAM,EAAE,SAAS;IAH7C,SAAgB,WAAW,uCAA4D;IACvF,SAAgB,SAAS,mBAA0B;gBAEvB,MAAM,EAAE,SAAS;IAE7C,QAAQ,CAAC,OAAO,kDAUb;IAEG,iBAAiB,CAAC,MAAM,EAAE,SAAS;IASnC,cAAc,CAAC,MAAM,EAAE,SAAS;CAIvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-test-suite.d.ts","sourceRoot":"","sources":["../../../../src/tests/basic-test-suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"basic-test-suite.d.ts","sourceRoot":"","sources":["../../../../src/tests/basic-test-suite.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMzC;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAiB,WAAW,6BA4GtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-test-suite.d.ts","sourceRoot":"","sources":["../../../../src/tests/property-test-suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"property-test-suite.d.ts","sourceRoot":"","sources":["../../../../src/tests/property-test-suite.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH,eAAO,MAAM,iBAAiB,YAuM7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/tests/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/tests/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC;;GAEG;AACH,eAAO,MAAM,qBAAqB,UAAiB,QAAQ,EAAE,kBAK5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,UAAiB,QAAQ,EAAE,SAAS,SAAS,aAAa,SAAS,QAAQ,CAAC,mCAOjG,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,UAAiB,QAAQ,EAAE,SAAS,SAAS,mCAOnE,CAAC;AAEF;;GAEG;AAGH,eAAO,MAAM,gBAAgB,WAAkB,mBAAmB,UAAU,mBAAmB,kBAG9F,CAAC"}
|
|
@@ -12,15 +12,15 @@ export declare class MemoryTransport implements Transport {
|
|
|
12
12
|
readonly closed: Event<void>;
|
|
13
13
|
readonly connected: Event<void>;
|
|
14
14
|
readonly errors: ErrorStream;
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly _instanceId;
|
|
16
16
|
private readonly _remote;
|
|
17
17
|
private readonly _outgoingDelay;
|
|
18
18
|
private readonly _incomingDelay;
|
|
19
19
|
private _destroyed;
|
|
20
|
-
private
|
|
20
|
+
private _remoteInstanceId;
|
|
21
21
|
private _remoteConnection?;
|
|
22
22
|
constructor(options: TransportOptions);
|
|
23
23
|
destroy(): Promise<void>;
|
|
24
|
-
signal(
|
|
24
|
+
signal({ payload }: Signal): void;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=memory-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/memory-transport.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB5E,eAAO,MAAM,sBAAsB,EAAE,gBAEpC,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;
|
|
1
|
+
{"version":3,"file":"memory-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/memory-transport.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB5E,eAAO,MAAM,sBAAsB,EAAE,gBAEpC,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAuBnC,OAAO,CAAC,QAAQ,CAAC,OAAO;IArBpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA8D;IAElG,SAAgB,MAAM,cAAqB;IAC3C,SAAgB,SAAS,cAAqB;IAC9C,SAAgB,MAAM,cAAqB;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAElD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAE5E,OAAO,CAAC,UAAU,CAAS;IAG3B,OAAO,CAAC,iBAAiB,CAAa;IAEtC,OAAO,CAAC,iBAAiB,CAAC,CAAkB;gBAEf,OAAO,EAAE,gBAAgB;IA2DhD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM;CAY3B"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Duplex } from 'node:stream';
|
|
3
3
|
import { PublicKey } from '@dxos/keys';
|
|
4
|
-
import { Protocol } from '@dxos/mesh-protocol';
|
|
5
4
|
import { Teleport } from '@dxos/teleport';
|
|
6
|
-
import { MeshProtocolProvider } from './protocol-factory';
|
|
7
5
|
export declare type WireProtocolParams = {
|
|
8
6
|
initiator: boolean;
|
|
9
7
|
localPeerId: PublicKey;
|
|
@@ -17,17 +15,9 @@ export declare type WireProtocolProvider = (params: WireProtocolParams) => WireP
|
|
|
17
15
|
*/
|
|
18
16
|
export interface WireProtocol {
|
|
19
17
|
stream: Duplex;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Only for devtools comapatibility.
|
|
22
|
-
*/
|
|
23
|
-
protocol?: Protocol;
|
|
24
18
|
initialize(): Promise<void>;
|
|
25
19
|
destroy(): Promise<void>;
|
|
26
20
|
}
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated
|
|
29
|
-
*/
|
|
30
|
-
export declare const adaptProtocolProvider: (factory: MeshProtocolProvider) => WireProtocolProvider;
|
|
31
21
|
/**
|
|
32
22
|
* Create a wire-protocol provider backed by a teleport instance.
|
|
33
23
|
* @param onConnection Called after teleport is initialized for the session. Protocol extensions could be attached here.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-protocol.d.ts","sourceRoot":"","sources":["../../../src/wire-protocol.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"wire-protocol.d.ts","sourceRoot":"","sources":["../../../src/wire-protocol.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,oBAAY,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,SAAS,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,oBAAY,oBAAoB,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,YAAY,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,4BACf,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAClD,oBAcF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/network-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Network Manager",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,21 +25,20 @@
|
|
|
25
25
|
"simple-peer": "9.11.0",
|
|
26
26
|
"ws": "^7.4.4",
|
|
27
27
|
"xor-distance": "^2.0.0",
|
|
28
|
-
"@dxos/async": "0.1.
|
|
29
|
-
"@dxos/codec-protobuf": "0.1.
|
|
30
|
-
"@dxos/context": "0.1.
|
|
31
|
-
"@dxos/credentials": "0.1.
|
|
32
|
-
"@dxos/crypto": "0.1.
|
|
33
|
-
"@dxos/debug": "0.1.
|
|
34
|
-
"@dxos/keys": "0.1.
|
|
35
|
-
"@dxos/log": "0.1.
|
|
36
|
-
"@dxos/messaging": "0.1.
|
|
37
|
-
"@dxos/node-std": "0.1.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/util": "0.1.16"
|
|
28
|
+
"@dxos/async": "0.1.18",
|
|
29
|
+
"@dxos/codec-protobuf": "0.1.18",
|
|
30
|
+
"@dxos/context": "0.1.18",
|
|
31
|
+
"@dxos/credentials": "0.1.18",
|
|
32
|
+
"@dxos/crypto": "0.1.18",
|
|
33
|
+
"@dxos/debug": "0.1.18",
|
|
34
|
+
"@dxos/keys": "0.1.18",
|
|
35
|
+
"@dxos/log": "0.1.18",
|
|
36
|
+
"@dxos/messaging": "0.1.18",
|
|
37
|
+
"@dxos/node-std": "0.1.18",
|
|
38
|
+
"@dxos/protocols": "0.1.18",
|
|
39
|
+
"@dxos/rpc": "0.1.18",
|
|
40
|
+
"@dxos/teleport": "0.1.18",
|
|
41
|
+
"@dxos/util": "0.1.18"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@swc-node/register": "^1.5.4",
|
|
@@ -49,8 +48,7 @@
|
|
|
49
48
|
"earljs": "~0.1.10",
|
|
50
49
|
"fast-check": "~3.3.0",
|
|
51
50
|
"typescript": "^4.8.4",
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/signal": "0.1.16"
|
|
51
|
+
"@dxos/signal": "0.1.18"
|
|
54
52
|
},
|
|
55
53
|
"publishConfig": {
|
|
56
54
|
"access": "public"
|
package/src/connection-log.ts
CHANGED
|
@@ -52,7 +52,7 @@ export class ConnectionLog {
|
|
|
52
52
|
remotePeerId: connection.remoteId,
|
|
53
53
|
sessionId: connection.sessionId,
|
|
54
54
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
55
|
-
protocolExtensions:
|
|
55
|
+
protocolExtensions: [], // TODO(dmaretskyi): Fix.
|
|
56
56
|
events: []
|
|
57
57
|
};
|
|
58
58
|
info.connections!.push(connectionInfo);
|
|
@@ -67,31 +67,31 @@ export class ConnectionLog {
|
|
|
67
67
|
this.update.emit();
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
connection.protocol.protocol?.error.on((error) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
connection.protocol.protocol?.extensionsInitialized.on(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
connection.protocol.protocol?.extensionsHandshake.on(() => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
connection.protocol.protocol?.handshake.on(() => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
70
|
+
// connection.protocol.protocol?.error.on((error) => {
|
|
71
|
+
// connectionInfo.events!.push({
|
|
72
|
+
// type: EventType.PROTOCOL_ERROR,
|
|
73
|
+
// error: error.stack ?? error.message
|
|
74
|
+
// });
|
|
75
|
+
// this.update.emit();
|
|
76
|
+
// });
|
|
77
|
+
// connection.protocol.protocol?.extensionsInitialized.on(() => {
|
|
78
|
+
// connectionInfo.events!.push({
|
|
79
|
+
// type: EventType.PROTOCOL_EXTENSIONS_INITIALIZED
|
|
80
|
+
// });
|
|
81
|
+
// this.update.emit();
|
|
82
|
+
// });
|
|
83
|
+
// connection.protocol.protocol?.extensionsHandshake.on(() => {
|
|
84
|
+
// connectionInfo.events!.push({
|
|
85
|
+
// type: EventType.PROTOCOL_EXTENSIONS_HANDSHAKE
|
|
86
|
+
// });
|
|
87
|
+
// this.update.emit();
|
|
88
|
+
// });
|
|
89
|
+
// connection.protocol.protocol?.handshake.on(() => {
|
|
90
|
+
// connectionInfo.events!.push({
|
|
91
|
+
// type: EventType.PROTOCOL_HANDSHAKE
|
|
92
|
+
// });
|
|
93
|
+
// this.update.emit();
|
|
94
|
+
// });
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
package/src/index.ts
CHANGED
package/src/network-manager.ts
CHANGED
|
@@ -46,12 +46,6 @@ export type SwarmOptions = {
|
|
|
46
46
|
*/
|
|
47
47
|
topology?: Topology;
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* Presence plugin for network mapping, if exists.
|
|
51
|
-
*/
|
|
52
|
-
// TODO(dmaretskyi): Remove this dependency.
|
|
53
|
-
presence?: any;
|
|
54
|
-
|
|
55
49
|
/**
|
|
56
50
|
* Custom label assigned to this swarm.
|
|
57
51
|
* Used in devtools to display human-readable names for swarms.
|
|
@@ -141,7 +135,6 @@ export class NetworkManager {
|
|
|
141
135
|
peerId,
|
|
142
136
|
topology,
|
|
143
137
|
protocolProvider: protocol,
|
|
144
|
-
presence,
|
|
145
138
|
label
|
|
146
139
|
}: SwarmOptions): Promise<SwarmConnection> {
|
|
147
140
|
assert(PublicKey.isPublicKey(topic));
|
|
@@ -160,7 +153,7 @@ export class NetworkManager {
|
|
|
160
153
|
|
|
161
154
|
this._swarms.set(topic, swarm);
|
|
162
155
|
this._signalConnection.join({ topic, peerId }).catch((error) => log.catch(error));
|
|
163
|
-
this._mappers.set(topic, new SwarmMapper(swarm
|
|
156
|
+
this._mappers.set(topic, new SwarmMapper(swarm));
|
|
164
157
|
|
|
165
158
|
this.topicsUpdated.emit();
|
|
166
159
|
this._connectionLog?.swarmJoined(swarm);
|
package/src/swarm/connection.ts
CHANGED
|
@@ -34,6 +34,11 @@ export enum ConnectionState {
|
|
|
34
34
|
*/
|
|
35
35
|
CONNECTED = 'CONNECTED',
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Connection is being closed.
|
|
39
|
+
*/
|
|
40
|
+
CLOSING = 'CLOSING',
|
|
41
|
+
|
|
37
42
|
/**
|
|
38
43
|
* Connection closed.
|
|
39
44
|
*/
|
|
@@ -112,7 +117,11 @@ export class Connection {
|
|
|
112
117
|
this.close().catch((err) => this.errors.raise(err));
|
|
113
118
|
});
|
|
114
119
|
|
|
115
|
-
this._transport.errors.
|
|
120
|
+
this._transport.errors.handle((err) => {
|
|
121
|
+
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
122
|
+
this.errors.raise(err);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
116
125
|
|
|
117
126
|
// Replay signals that were received before transport was created.
|
|
118
127
|
for (const signal of this._bufferedSignals) {
|
|
@@ -128,6 +137,8 @@ export class Connection {
|
|
|
128
137
|
return;
|
|
129
138
|
}
|
|
130
139
|
|
|
140
|
+
this._changeState(ConnectionState.CLOSING);
|
|
141
|
+
|
|
131
142
|
log('closing...', { peerId: this.ownId });
|
|
132
143
|
|
|
133
144
|
try {
|
package/src/swarm/peer.ts
CHANGED
|
@@ -203,9 +203,7 @@ export class Peer {
|
|
|
203
203
|
log.warn('connection error', { topic: this.topic, peerId: this.localPeerId, remoteId: this.id, initiator, err });
|
|
204
204
|
|
|
205
205
|
// Calls `onStateChange` with CLOSED state.
|
|
206
|
-
void this.closeConnection()
|
|
207
|
-
log.catch(err);
|
|
208
|
-
});
|
|
206
|
+
void this.closeConnection();
|
|
209
207
|
});
|
|
210
208
|
|
|
211
209
|
this.connection = connection;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { Event, EventSubscriptions } from '@dxos/async';
|
|
6
6
|
import { PublicKey } from '@dxos/keys';
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
|
-
import { PresencePlugin } from '@dxos/protocol-plugin-presence';
|
|
9
8
|
import { ComplexMap } from '@dxos/util';
|
|
10
9
|
|
|
11
10
|
import { ConnectionState } from './connection';
|
|
@@ -40,8 +39,7 @@ export class SwarmMapper {
|
|
|
40
39
|
|
|
41
40
|
// prettier-ignore
|
|
42
41
|
constructor(
|
|
43
|
-
private readonly _swarm: Swarm
|
|
44
|
-
private readonly _presence: PresencePlugin | undefined
|
|
42
|
+
private readonly _swarm: Swarm
|
|
45
43
|
) {
|
|
46
44
|
this._subscriptions.add(
|
|
47
45
|
_swarm.connectionAdded.on((connection) => {
|
|
@@ -63,11 +61,11 @@ export class SwarmMapper {
|
|
|
63
61
|
})
|
|
64
62
|
);
|
|
65
63
|
|
|
66
|
-
if (_presence) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
64
|
+
// if (_presence) {
|
|
65
|
+
// this._subscriptions.add(_presence.graphUpdated.on(() => {
|
|
66
|
+
// this._update();
|
|
67
|
+
// }));
|
|
68
|
+
// }
|
|
71
69
|
|
|
72
70
|
// TODO(burdon): Do not call from constructor.
|
|
73
71
|
this._update();
|
|
@@ -91,29 +89,29 @@ export class SwarmMapper {
|
|
|
91
89
|
});
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
if (this._presence) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
92
|
+
// if (this._presence) {
|
|
93
|
+
// this._presence.graph.forEachNode((node: any) => {
|
|
94
|
+
// const id = PublicKey.fromHex(node.id);
|
|
95
|
+
// if (this._peers.has(id)) {
|
|
96
|
+
// return;
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
// this._peers.set(id, {
|
|
100
|
+
// id,
|
|
101
|
+
// state: 'INDIRECTLY_CONNECTED',
|
|
102
|
+
// connections: []
|
|
103
|
+
// });
|
|
104
|
+
// });
|
|
105
|
+
|
|
106
|
+
// this._presence.graph.forEachLink((link: any) => {
|
|
107
|
+
// const from = PublicKey.from(link.fromId);
|
|
108
|
+
// const to = PublicKey.from(link.toId);
|
|
109
|
+
// // Ignore connections to self, they are already handled.
|
|
110
|
+
// if (!from.equals(this._swarm.ownPeerId) && !to.equals(this._swarm.ownPeerId)) {
|
|
111
|
+
// this._peers.get(from)!.connections.push(to);
|
|
112
|
+
// }
|
|
113
|
+
// });
|
|
114
|
+
// }
|
|
117
115
|
|
|
118
116
|
log('graph changed', {
|
|
119
117
|
directConnections: this._swarm.connections.length,
|