@dxos/client 2.33.5-dev.ea3876ba → 2.33.5-dev.fee8f5fe
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/src/api/client.test.js +3 -5
- package/dist/src/api/client.test.js.map +1 -1
- package/dist/src/api/index.js +5 -1
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/invitations/index.js +5 -1
- package/dist/src/api/invitations/index.js.map +1 -1
- package/dist/src/api/proxies/index.js +5 -1
- package/dist/src/api/proxies/index.js.map +1 -1
- package/dist/src/devtools/config.d.ts.map +1 -1
- package/dist/src/devtools/config.js +3 -5
- package/dist/src/devtools/config.js.map +1 -1
- package/dist/src/devtools/devtools-host.d.ts.map +1 -1
- package/dist/src/devtools/devtools-host.js +38 -68
- package/dist/src/devtools/devtools-host.js.map +1 -1
- package/dist/src/devtools/feeds.d.ts.map +1 -1
- package/dist/src/devtools/feeds.js +49 -50
- package/dist/src/devtools/feeds.js.map +1 -1
- package/dist/src/devtools/index.js +5 -1
- package/dist/src/devtools/index.js.map +1 -1
- package/dist/src/devtools/items.d.ts.map +1 -1
- package/dist/src/devtools/items.js +23 -25
- package/dist/src/devtools/items.js.map +1 -1
- package/dist/src/devtools/keys.d.ts.map +1 -1
- package/dist/src/devtools/keys.js +19 -23
- package/dist/src/devtools/keys.js.map +1 -1
- package/dist/src/devtools/network.d.ts.map +1 -1
- package/dist/src/devtools/network.js +51 -59
- package/dist/src/devtools/network.js.map +1 -1
- package/dist/src/devtools/parties.d.ts.map +1 -1
- package/dist/src/devtools/parties.js +23 -25
- package/dist/src/devtools/parties.js.map +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/proto/gen/dxos/client.d.ts +15 -15
- package/dist/src/proto/gen/dxos/client.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client.js.map +1 -1
- package/dist/src/proto/gen/dxos/config.d.ts +1 -1
- package/dist/src/proto/gen/dxos/config.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/config.js.map +1 -1
- package/dist/src/proto/gen/dxos/credentials.d.ts +3 -3
- package/dist/src/proto/gen/dxos/credentials.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/devtools.d.ts +15 -15
- package/dist/src/proto/gen/dxos/devtools.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/feed.d.ts +2 -14
- package/dist/src/proto/gen/dxos/echo/feed.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/feed.js.map +1 -1
- package/dist/src/proto/gen/dxos/echo/invitation.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/invitation.js.map +1 -1
- package/dist/src/proto/gen/dxos/echo/service.d.ts +7 -7
- package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/snapshot.d.ts +4 -4
- package/dist/src/proto/gen/dxos/echo/snapshot.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/timeframe.d.ts +13 -0
- package/dist/src/proto/gen/dxos/echo/timeframe.d.ts.map +1 -0
- package/dist/src/proto/gen/dxos/echo/timeframe.js +3 -0
- package/dist/src/proto/gen/dxos/echo/timeframe.js.map +1 -0
- package/dist/src/proto/gen/dxos/halo/keys.d.ts +3 -3
- package/dist/src/proto/gen/dxos/halo/keys.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/halo/keys.js.map +1 -1
- package/dist/src/proto/gen/dxos/rpc.d.ts +2 -2
- package/dist/src/proto/gen/dxos/rpc.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/rpc.js.map +1 -1
- package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
- package/dist/src/proto/gen/google/protobuf.js.map +1 -1
- package/dist/src/proto/gen/index.d.ts +3 -2
- package/dist/src/proto/gen/index.d.ts.map +1 -1
- package/dist/src/proto/gen/index.js +1 -1
- package/dist/src/proto/gen/index.js.map +1 -1
- package/dist/src/proto/substitutions.d.ts +1 -1
- package/dist/src/services/impl/halo.d.ts.map +1 -1
- package/dist/src/services/impl/halo.js +1 -3
- package/dist/src/services/impl/halo.js.map +1 -1
- package/dist/src/services/impl/index.js +5 -1
- package/dist/src/services/impl/index.js.map +1 -1
- package/dist/src/services/impl/party.d.ts.map +1 -1
- package/dist/src/services/impl/party.js +10 -16
- package/dist/src/services/impl/party.js.map +1 -1
- package/dist/src/services/impl/profile.d.ts.map +1 -1
- package/dist/src/services/impl/profile.js +1 -3
- package/dist/src/services/impl/profile.js.map +1 -1
- package/dist/src/services/impl/services.d.ts.map +1 -1
- package/dist/src/services/impl/services.js +14 -16
- package/dist/src/services/impl/services.js.map +1 -1
- package/dist/src/services/impl/system.d.ts.map +1 -1
- package/dist/src/services/impl/system.js +6 -10
- package/dist/src/services/impl/system.js.map +1 -1
- package/dist/src/services/index.js +5 -1
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/service-host.js +5 -1
- package/dist/src/services/service-host.js.map +1 -1
- package/dist/src/util/index.js +5 -1
- package/dist/src/util/index.js.map +1 -1
- package/dist/src/util/messages.js +2 -2
- package/dist/src/util/messages.js.map +1 -1
- package/dist/src/util/subscription.d.ts +2 -2
- package/dist/src/util/subscription.d.ts.map +1 -1
- package/dist/src/util/subscription.js +6 -8
- package/dist/src/util/subscription.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/api/client.test.ts +3 -5
- package/src/devtools/config.ts +3 -5
- package/src/devtools/devtools-host.ts +38 -68
- package/src/devtools/feeds.ts +53 -57
- package/src/devtools/items.ts +25 -27
- package/src/devtools/keys.ts +19 -26
- package/src/devtools/network.ts +47 -54
- package/src/devtools/parties.ts +25 -27
- package/src/proto/gen/dxos/client.ts +16 -15
- package/src/proto/gen/dxos/config.ts +2 -1
- package/src/proto/gen/dxos/credentials.ts +4 -3
- package/src/proto/gen/dxos/devtools.ts +16 -15
- package/src/proto/gen/dxos/echo/feed.ts +3 -14
- package/src/proto/gen/dxos/echo/invitation.ts +1 -0
- package/src/proto/gen/dxos/echo/service.ts +8 -7
- package/src/proto/gen/dxos/echo/snapshot.ts +5 -4
- package/src/proto/gen/dxos/echo/timeframe.ts +25 -0
- package/src/proto/gen/dxos/halo/keys.ts +4 -3
- package/src/proto/gen/dxos/rpc.ts +3 -2
- package/src/proto/gen/google/protobuf.ts +1 -0
- package/src/proto/gen/index.ts +4 -3
- package/src/services/impl/halo.ts +1 -3
- package/src/services/impl/party.ts +10 -16
- package/src/services/impl/profile.ts +1 -3
- package/src/services/impl/services.ts +14 -16
- package/src/services/impl/system.ts +6 -10
- package/src/util/subscription.ts +6 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client",
|
|
3
|
-
"version": "2.33.5-dev.
|
|
3
|
+
"version": "2.33.5-dev.fee8f5fe",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "DXOS.org",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"src"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dxos/async": "2.33.5-dev.
|
|
14
|
-
"@dxos/codec-protobuf": "2.33.5-dev.
|
|
15
|
-
"@dxos/config": "2.33.5-dev.
|
|
16
|
-
"@dxos/credentials": "2.33.5-dev.
|
|
17
|
-
"@dxos/crypto": "2.33.5-dev.
|
|
18
|
-
"@dxos/debug": "2.33.5-dev.
|
|
19
|
-
"@dxos/echo-db": "2.33.5-dev.
|
|
20
|
-
"@dxos/echo-protocol": "2.33.5-dev.
|
|
21
|
-
"@dxos/feed-store": "2.33.5-dev.
|
|
22
|
-
"@dxos/model-factory": "2.33.5-dev.
|
|
23
|
-
"@dxos/network-manager": "2.33.5-dev.
|
|
24
|
-
"@dxos/object-model": "2.33.5-dev.
|
|
25
|
-
"@dxos/protocols": "2.33.5-dev.
|
|
26
|
-
"@dxos/rpc": "2.33.5-dev.
|
|
27
|
-
"@dxos/util": "2.33.5-dev.
|
|
13
|
+
"@dxos/async": "2.33.5-dev.fee8f5fe",
|
|
14
|
+
"@dxos/codec-protobuf": "2.33.5-dev.fee8f5fe",
|
|
15
|
+
"@dxos/config": "2.33.5-dev.fee8f5fe",
|
|
16
|
+
"@dxos/credentials": "2.33.5-dev.fee8f5fe",
|
|
17
|
+
"@dxos/crypto": "2.33.5-dev.fee8f5fe",
|
|
18
|
+
"@dxos/debug": "2.33.5-dev.fee8f5fe",
|
|
19
|
+
"@dxos/echo-db": "2.33.5-dev.fee8f5fe",
|
|
20
|
+
"@dxos/echo-protocol": "2.33.5-dev.fee8f5fe",
|
|
21
|
+
"@dxos/feed-store": "2.33.5-dev.fee8f5fe",
|
|
22
|
+
"@dxos/model-factory": "2.33.5-dev.fee8f5fe",
|
|
23
|
+
"@dxos/network-manager": "2.33.5-dev.fee8f5fe",
|
|
24
|
+
"@dxos/object-model": "2.33.5-dev.fee8f5fe",
|
|
25
|
+
"@dxos/protocols": "2.33.5-dev.fee8f5fe",
|
|
26
|
+
"@dxos/rpc": "2.33.5-dev.fee8f5fe",
|
|
27
|
+
"@dxos/util": "2.33.5-dev.fee8f5fe",
|
|
28
28
|
"abstract-leveldown": "~7.0.0",
|
|
29
29
|
"assert": "^2.0.0",
|
|
30
30
|
"debug": "^4.3.3",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"uuid": "^8.3.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@dxos/eslint-plugin": "~1.0.
|
|
40
|
+
"@dxos/eslint-plugin": "~1.0.33",
|
|
41
41
|
"@dxos/protocols-toolchain": "2.33.4",
|
|
42
|
-
"@dxos/random-access-multi-storage": "2.33.5-dev.
|
|
42
|
+
"@dxos/random-access-multi-storage": "2.33.5-dev.fee8f5fe",
|
|
43
43
|
"@dxos/testutils": "2.33.4",
|
|
44
44
|
"@types/debug": "^4.1.7",
|
|
45
45
|
"@types/jest": "^26.0.7",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"eslint": "^7.12.1",
|
|
54
54
|
"expect": "~27.0.2",
|
|
55
55
|
"mocha": "~8.4.0",
|
|
56
|
-
"typescript": "^4.
|
|
56
|
+
"typescript": "^4.7.2",
|
|
57
57
|
"wait-for-expect": "^3.0.2"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
package/src/api/client.test.ts
CHANGED
|
@@ -25,7 +25,7 @@ describe('Client', () => {
|
|
|
25
25
|
//
|
|
26
26
|
// Suite is called for local and remote client configurations.
|
|
27
27
|
//
|
|
28
|
-
|
|
28
|
+
const testSuite = (createClient: () => Promise<Client>) => {
|
|
29
29
|
describe('initialization', () => {
|
|
30
30
|
test('initialize and destroy', async () => {
|
|
31
31
|
const client = await createClient();
|
|
@@ -285,12 +285,10 @@ describe('Client', () => {
|
|
|
285
285
|
expect(details.processedTimeframe.frames().some(([key, seq]) => seq > 0)).toBe(true);
|
|
286
286
|
});
|
|
287
287
|
});
|
|
288
|
-
}
|
|
288
|
+
};
|
|
289
289
|
|
|
290
290
|
describe('local', () => {
|
|
291
|
-
testSuite(async () =>
|
|
292
|
-
return new Client();
|
|
293
|
-
});
|
|
291
|
+
testSuite(async () => new Client());
|
|
294
292
|
});
|
|
295
293
|
|
|
296
294
|
describe('remote', () => {
|
package/src/devtools/config.ts
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
import { GetConfigResponse } from '../proto/gen/dxos/devtools';
|
|
6
6
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
7
7
|
|
|
8
|
-
export const getConfig = (hook: DevtoolsServiceDependencies): GetConfigResponse => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
};
|
|
8
|
+
export const getConfig = (hook: DevtoolsServiceDependencies): GetConfigResponse => ({
|
|
9
|
+
config: JSON.stringify(hook.config.values) // TODO(marik-d): Serialize config with protobuf.
|
|
10
|
+
});
|
|
@@ -22,71 +22,41 @@ import {
|
|
|
22
22
|
import { getPartySnapshot, savePartySnapshot, subscribeToParties } from './parties';
|
|
23
23
|
import { resetStorage } from './storage';
|
|
24
24
|
|
|
25
|
-
export const createDevtoolsHost = (context: DevtoolsServiceDependencies, events: DevtoolsHostEvents)
|
|
26
|
-
|
|
27
|
-
events
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
subscribeToFeed: (request) => {
|
|
65
|
-
return subscribeToFeed(context, request);
|
|
66
|
-
},
|
|
67
|
-
getPartySnapshot: async (request) => {
|
|
68
|
-
return getPartySnapshot(context, request);
|
|
69
|
-
},
|
|
70
|
-
savePartySnapshot: async (request) => {
|
|
71
|
-
return savePartySnapshot(context, request);
|
|
72
|
-
},
|
|
73
|
-
clearSnapshots: async () => {
|
|
74
|
-
await context.echo.snapshotStore.clear();
|
|
75
|
-
},
|
|
76
|
-
getNetworkPeers: async (request) => {
|
|
77
|
-
return getNetworkPeers(context, request);
|
|
78
|
-
},
|
|
79
|
-
subscribeToNetworkTopics: () => {
|
|
80
|
-
return subscribeToNetworkTopics(context);
|
|
81
|
-
},
|
|
82
|
-
subscribeToSignalStatus: () => {
|
|
83
|
-
return subscribeToNetworkStatus(context);
|
|
84
|
-
},
|
|
85
|
-
subscribeToSignalTrace: () => {
|
|
86
|
-
return subscribeToSignalTrace(context);
|
|
87
|
-
},
|
|
88
|
-
subscribeToSwarmInfo: () => {
|
|
89
|
-
return subscribeToSwarmInfo(context);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
};
|
|
25
|
+
export const createDevtoolsHost = (context: DevtoolsServiceDependencies, events: DevtoolsHostEvents): DevtoolsHost => ({
|
|
26
|
+
events: () => new Stream<ClientAPIEvent>(({ next }) => {
|
|
27
|
+
events.ready.on(() => {
|
|
28
|
+
next({ ready: {} });
|
|
29
|
+
});
|
|
30
|
+
}),
|
|
31
|
+
getConfig: async () => {
|
|
32
|
+
const config = getConfig(context);
|
|
33
|
+
return config;
|
|
34
|
+
},
|
|
35
|
+
resetStorage: async () => {
|
|
36
|
+
await resetStorage(context);
|
|
37
|
+
},
|
|
38
|
+
enableDebugLogging: async (request) => {
|
|
39
|
+
enableDebugLogging(context, request);
|
|
40
|
+
return {};
|
|
41
|
+
},
|
|
42
|
+
disableDebugLogging: async () => {
|
|
43
|
+
disableDebugLogging(context);
|
|
44
|
+
return {};
|
|
45
|
+
},
|
|
46
|
+
subscribeToKeyringKeys: () => subscribeToKeyringKeys(context),
|
|
47
|
+
subscribeToCredentialMessages: (request) => subscribeToCredentialMessages(context, request),
|
|
48
|
+
subscribeToParties: () => subscribeToParties(context),
|
|
49
|
+
subscribeToItems: () => subscribeToItems(context),
|
|
50
|
+
subscribeToFeeds: () => subscribeToFeeds(context),
|
|
51
|
+
subscribeToFeed: (request) => subscribeToFeed(context, request),
|
|
52
|
+
getPartySnapshot: async (request) => getPartySnapshot(context, request),
|
|
53
|
+
savePartySnapshot: async (request) => savePartySnapshot(context, request),
|
|
54
|
+
clearSnapshots: async () => {
|
|
55
|
+
await context.echo.snapshotStore.clear();
|
|
56
|
+
},
|
|
57
|
+
getNetworkPeers: async (request) => getNetworkPeers(context, request),
|
|
58
|
+
subscribeToNetworkTopics: () => subscribeToNetworkTopics(context),
|
|
59
|
+
subscribeToSignalStatus: () => subscribeToNetworkStatus(context),
|
|
60
|
+
subscribeToSignalTrace: () => subscribeToSignalTrace(context),
|
|
61
|
+
subscribeToSwarmInfo: () => subscribeToSwarmInfo(context)
|
|
62
|
+
});
|
package/src/devtools/feeds.ts
CHANGED
|
@@ -10,73 +10,69 @@ import { createBatchStream } from '@dxos/feed-store';
|
|
|
10
10
|
import { SubscribeToFeedRequest, SubscribeToFeedResponse, SubscribeToFeedsResponse } from '../proto/gen/dxos/devtools';
|
|
11
11
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
12
12
|
|
|
13
|
-
export const subscribeToFeeds = ({ echo }: DevtoolsServiceDependencies) => {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const partySubscriptions: Record<string, () => void> = {};
|
|
26
|
-
const unsubscribe = echo.queryParties().subscribe((parties) => {
|
|
27
|
-
parties.forEach((party) => {
|
|
28
|
-
if (!partySubscriptions[party.key.toHex()]) {
|
|
29
|
-
// Send updates on timeframe changes.
|
|
30
|
-
partySubscriptions[party.key.toHex()] = party.timeframeUpdate.on(() => update());
|
|
31
|
-
}
|
|
32
|
-
});
|
|
13
|
+
export const subscribeToFeeds = ({ echo }: DevtoolsServiceDependencies) => new Stream<SubscribeToFeedsResponse>(({ next }) => {
|
|
14
|
+
const update = () => {
|
|
15
|
+
const { value: parties } = echo.queryParties();
|
|
16
|
+
next({
|
|
17
|
+
parties: parties.map(party => ({
|
|
18
|
+
key: party.key,
|
|
19
|
+
feeds: party.getFeeds().map(feed => feed.key)
|
|
20
|
+
}))
|
|
21
|
+
});
|
|
22
|
+
};
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
const partySubscriptions: Record<string, () => void> = {};
|
|
25
|
+
const unsubscribe = echo.queryParties().subscribe((parties) => {
|
|
26
|
+
parties.forEach((party) => {
|
|
27
|
+
if (!partySubscriptions[party.key.toHex()]) {
|
|
28
|
+
// Send updates on timeframe changes.
|
|
29
|
+
partySubscriptions[party.key.toHex()] = party.timeframeUpdate.on(() => update());
|
|
30
|
+
}
|
|
36
31
|
});
|
|
37
32
|
|
|
38
|
-
// Send
|
|
33
|
+
// Send feeds for new parties.
|
|
39
34
|
update();
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
unsubscribe();
|
|
43
|
-
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
44
|
-
};
|
|
45
35
|
});
|
|
46
|
-
};
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
) => {
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
// Send initial feeds.
|
|
38
|
+
update();
|
|
39
|
+
|
|
40
|
+
return () => {
|
|
41
|
+
unsubscribe();
|
|
42
|
+
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const subscribeToFeed = ({ echo }: DevtoolsServiceDependencies, { partyKey, feedKey }: SubscribeToFeedRequest) => new Stream<SubscribeToFeedResponse>(({ next }) => {
|
|
47
|
+
if (!partyKey || !feedKey) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let feedStream: Readable;
|
|
52
|
+
setImmediate(async () => {
|
|
53
|
+
const { value: parties } = echo.queryParties();
|
|
54
|
+
const party = parties.find(party => party.key.equals(partyKey));
|
|
55
|
+
if (!party) {
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!party) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const { feed } = await party.feedProvider.createOrOpenReadOnlyFeed(feedKey);
|
|
59
|
+
const feed = await party.getFeeds().find(feed => feed.key.equals(feedKey));
|
|
60
|
+
if (!feed) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
// TODO(wittjosiah): Start from timeframe?
|
|
65
|
+
// TODO(wittjosiah): Bidirectional lazy loading to feed into virtualized table.
|
|
66
|
+
// Tail feed so as to not overload the browser.
|
|
67
|
+
feedStream = new Readable({ objectMode: true })
|
|
68
|
+
.wrap(createBatchStream(feed.feed, { live: true, start: Math.max(0, feed.feed.length - 10) }));
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
70
|
+
feedStream.on('data', blocks => {
|
|
71
|
+
next({ blocks });
|
|
76
72
|
});
|
|
77
|
-
|
|
78
|
-
return () => {
|
|
79
|
-
feedStream?.destroy();
|
|
80
|
-
};
|
|
81
73
|
});
|
|
82
|
-
|
|
74
|
+
|
|
75
|
+
return () => {
|
|
76
|
+
feedStream?.destroy();
|
|
77
|
+
};
|
|
78
|
+
});
|
package/src/devtools/items.ts
CHANGED
|
@@ -37,35 +37,33 @@ const getData = (echo: DevtoolsServiceDependencies['echo']): SubscribeToItemsRes
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const subscribeToItems = ({ echo }: DevtoolsServiceDependencies) => {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const partySubscriptions: Record<string, () => void> = {};
|
|
48
|
-
const unsubscribe = echo.queryParties().subscribe((parties) => {
|
|
49
|
-
parties.forEach(party => {
|
|
50
|
-
if (!partySubscriptions[party.key.toHex()]) {
|
|
51
|
-
const sub = party.database.select().exec().update.on(() => {
|
|
52
|
-
// Send updates on items changes.
|
|
53
|
-
update();
|
|
54
|
-
});
|
|
55
|
-
partySubscriptions[party.key.toHex()] = sub;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
40
|
+
export const subscribeToItems = ({ echo }: DevtoolsServiceDependencies) => new Stream<SubscribeToItemsResponse>(({ next }) => {
|
|
41
|
+
const update = () => {
|
|
42
|
+
const res = getData(echo);
|
|
43
|
+
next(res);
|
|
44
|
+
};
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
const partySubscriptions: Record<string, () => void> = {};
|
|
47
|
+
const unsubscribe = echo.queryParties().subscribe((parties) => {
|
|
48
|
+
parties.forEach(party => {
|
|
49
|
+
if (!partySubscriptions[party.key.toHex()]) {
|
|
50
|
+
const sub = party.database.select().exec().update.on(() => {
|
|
51
|
+
// Send updates on items changes.
|
|
52
|
+
update();
|
|
53
|
+
});
|
|
54
|
+
partySubscriptions[party.key.toHex()] = sub;
|
|
55
|
+
}
|
|
61
56
|
});
|
|
62
57
|
|
|
63
|
-
// Send
|
|
58
|
+
// Send items for new parties.
|
|
64
59
|
update();
|
|
65
|
-
|
|
66
|
-
return () => {
|
|
67
|
-
unsubscribe();
|
|
68
|
-
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
69
|
-
};
|
|
70
60
|
});
|
|
71
|
-
|
|
61
|
+
|
|
62
|
+
// Send initial items.
|
|
63
|
+
update();
|
|
64
|
+
|
|
65
|
+
return () => {
|
|
66
|
+
unsubscribe();
|
|
67
|
+
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
68
|
+
};
|
|
69
|
+
});
|
package/src/devtools/keys.ts
CHANGED
|
@@ -12,34 +12,27 @@ import {
|
|
|
12
12
|
} from '../proto/gen/dxos/devtools';
|
|
13
13
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
14
14
|
|
|
15
|
-
export const subscribeToKeyringKeys = ({ keyring }: DevtoolsServiceDependencies) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
next({ keys });
|
|
20
|
-
});
|
|
15
|
+
export const subscribeToKeyringKeys = ({ keyring }: DevtoolsServiceDependencies) => new Stream<SubscribeToKeyringKeysResponse>(({ next }) => {
|
|
16
|
+
next({ keys: keyring.keys });
|
|
17
|
+
return keyring.keysUpdate.on((keys) => {
|
|
18
|
+
next({ keys });
|
|
21
19
|
});
|
|
22
|
-
};
|
|
20
|
+
});
|
|
23
21
|
|
|
24
|
-
export const subscribeToCredentialMessages = (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const party = partyKey && echo.getParty(partyKey);
|
|
30
|
-
if (!party) {
|
|
31
|
-
throw new Error('Party not found');
|
|
32
|
-
}
|
|
22
|
+
export const subscribeToCredentialMessages = ({ echo }: DevtoolsServiceDependencies, { partyKey }: SubscribeToCredentialMessagesRequest) => new Stream<SubscribeToCredentialMessagesResponse>(({ next }) => {
|
|
23
|
+
const party = partyKey && echo.getParty(partyKey);
|
|
24
|
+
if (!party) {
|
|
25
|
+
throw new Error('Party not found');
|
|
26
|
+
}
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
const update = () => {
|
|
29
|
+
next({ messages: Array.from(party.processor.credentialMessages.values()) });
|
|
30
|
+
};
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const subscriptions = new SubscriptionGroup();
|
|
33
|
+
subscriptions.push(party.processor.keyOrInfoAdded.on(() => update()));
|
|
34
|
+
subscriptions.push(party.processor.feedAdded.on(() => update()));
|
|
35
|
+
update();
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
37
|
+
return () => subscriptions.unsubscribe();
|
|
38
|
+
});
|
package/src/devtools/network.ts
CHANGED
|
@@ -16,65 +16,58 @@ import {
|
|
|
16
16
|
} from '../proto/gen/dxos/devtools';
|
|
17
17
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
18
18
|
|
|
19
|
-
export const subscribeToNetworkStatus = (hook: DevtoolsServiceDependencies) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
hook.networkManager.signal.statusChanged.on(update);
|
|
30
|
-
update();
|
|
31
|
-
});
|
|
32
|
-
};
|
|
19
|
+
export const subscribeToNetworkStatus = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToSignalStatusResponse>(({ next, close }) => {
|
|
20
|
+
const update = () => {
|
|
21
|
+
try {
|
|
22
|
+
const status = hook.networkManager.signal.getStatus();
|
|
23
|
+
next({ servers: status });
|
|
24
|
+
} catch (err: any) {
|
|
25
|
+
close(err);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
hook.networkManager.signal.statusChanged.on(update);
|
|
30
|
+
update();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const subscribeToSignalTrace = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToSignalTraceResponse>(({ next }) => {
|
|
34
|
+
next({ events: [] });
|
|
35
|
+
const trace: SignalApi.CommandTrace[] = [];
|
|
36
|
+
hook.networkManager.signal.commandTrace.on(msg => {
|
|
37
|
+
trace.push(msg);
|
|
38
|
+
next({ events: trace.map((msg) => JSON.stringify(msg)) });
|
|
42
39
|
});
|
|
43
|
-
};
|
|
40
|
+
});
|
|
44
41
|
|
|
45
|
-
export const subscribeToNetworkTopics = (hook: DevtoolsServiceDependencies) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
hook.networkManager.topicsUpdated.on(update);
|
|
42
|
+
export const subscribeToNetworkTopics = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToNetworkTopicsResponse>(({ next, close }) => {
|
|
43
|
+
const update = () => {
|
|
44
|
+
try {
|
|
45
|
+
const topics = hook.networkManager.topics;
|
|
46
|
+
const labeledTopics = topics.map(topic => ({
|
|
47
|
+
topic,
|
|
48
|
+
label: hook.networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
49
|
+
}));
|
|
50
|
+
next({ topics: labeledTopics });
|
|
51
|
+
} catch (err: any) {
|
|
52
|
+
close(err);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
hook.networkManager.topicsUpdated.on(update);
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
57
|
+
update();
|
|
58
|
+
});
|
|
64
59
|
|
|
65
|
-
export const subscribeToSwarmInfo = (hook: DevtoolsServiceDependencies) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
};
|
|
60
|
+
export const subscribeToSwarmInfo = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToSwarmInfoResponse>(({ next }) => {
|
|
61
|
+
const networkManager = hook.networkManager;
|
|
62
|
+
const update = () => {
|
|
63
|
+
const info = networkManager.connectionLog?.swarms;
|
|
64
|
+
if (info) {
|
|
65
|
+
next({ data: info });
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
networkManager.connectionLog?.update.on(update);
|
|
69
|
+
update();
|
|
70
|
+
});
|
|
78
71
|
|
|
79
72
|
export const getNetworkPeers = (hook: DevtoolsServiceDependencies, request: GetNetworkPeersRequest): GetNetworkPeersResponse => {
|
|
80
73
|
if (!request.topic) {
|
package/src/devtools/parties.ts
CHANGED
|
@@ -13,38 +13,36 @@ import {
|
|
|
13
13
|
} from '../proto/gen/dxos/devtools';
|
|
14
14
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
15
15
|
|
|
16
|
-
export const subscribeToParties = ({ echo }: DevtoolsServiceDependencies) => {
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
16
|
+
export const subscribeToParties = ({ echo }: DevtoolsServiceDependencies) => new Stream<SubscribeToPartiesResponse>(({ next }) => {
|
|
17
|
+
const update = () => {
|
|
18
|
+
const { value: parties } = echo.queryParties();
|
|
19
|
+
next({ parties: parties.map(party => party.partyInfo) });
|
|
20
|
+
};
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// Send new parties.
|
|
35
|
-
update();
|
|
22
|
+
const partySubscriptions: Record<string, () => void> = {};
|
|
23
|
+
const timeframeSubscriptions: Record<string, () => void> = {};
|
|
24
|
+
const unsubscribe = echo.queryParties().subscribe((parties) => {
|
|
25
|
+
parties.forEach((party) => {
|
|
26
|
+
if (!partySubscriptions[party.key.toHex()]) {
|
|
27
|
+
// Send updates on party changes.
|
|
28
|
+
partySubscriptions[party.key.toHex()] = party.update.on(() => update());
|
|
29
|
+
timeframeSubscriptions[party.key.toHex()] = party.timeframeUpdate.on(() => update());
|
|
30
|
+
}
|
|
36
31
|
});
|
|
37
32
|
|
|
38
|
-
// Send
|
|
33
|
+
// Send new parties.
|
|
39
34
|
update();
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
unsubscribe();
|
|
43
|
-
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
44
|
-
Object.values(timeframeSubscriptions).forEach(unsubscribe => unsubscribe());
|
|
45
|
-
};
|
|
46
35
|
});
|
|
47
|
-
|
|
36
|
+
|
|
37
|
+
// Send initial parties.
|
|
38
|
+
update();
|
|
39
|
+
|
|
40
|
+
return () => {
|
|
41
|
+
unsubscribe();
|
|
42
|
+
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
43
|
+
Object.values(timeframeSubscriptions).forEach(unsubscribe => unsubscribe());
|
|
44
|
+
};
|
|
45
|
+
});
|
|
48
46
|
|
|
49
47
|
export const getPartySnapshot = async (
|
|
50
48
|
{ echo }: DevtoolsServiceDependencies,
|