@dxos/client 2.33.5-dev.ea3876ba → 2.33.5-dev.ebc105f7
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/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/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/proto/gen/dxos/client.d.ts +1 -1
- 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.map +1 -1
- package/dist/src/proto/gen/dxos/config.js.map +1 -1
- package/dist/src/proto/gen/dxos/credentials.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/devtools.d.ts +1 -1
- package/dist/src/proto/gen/dxos/devtools.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/feed.d.ts +1 -13
- 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 +1 -1
- package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/snapshot.d.ts +1 -1
- 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.map +1 -1
- package/dist/src/proto/gen/dxos/halo/keys.js.map +1 -1
- 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 +4 -4
- 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/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/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 +18 -18
- 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 +46 -54
- package/src/devtools/parties.ts +25 -27
- package/src/proto/gen/dxos/client.ts +2 -1
- package/src/proto/gen/dxos/config.ts +1 -0
- package/src/proto/gen/dxos/credentials.ts +1 -0
- package/src/proto/gen/dxos/devtools.ts +2 -1
- package/src/proto/gen/dxos/echo/feed.ts +2 -13
- package/src/proto/gen/dxos/echo/invitation.ts +1 -0
- package/src/proto/gen/dxos/echo/service.ts +2 -1
- package/src/proto/gen/dxos/echo/snapshot.ts +2 -1
- package/src/proto/gen/dxos/echo/timeframe.ts +25 -0
- package/src/proto/gen/dxos/halo/keys.ts +1 -0
- package/src/proto/gen/dxos/rpc.ts +1 -0
- package/src/proto/gen/google/protobuf.ts +5 -4
- 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/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,57 @@ 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
|
-
|
|
30
|
-
|
|
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
|
+
};
|
|
28
|
+
hook.networkManager.signal.statusChanged.on(update);
|
|
29
|
+
update();
|
|
30
|
+
});
|
|
33
31
|
|
|
34
|
-
export const subscribeToSignalTrace = (hook: DevtoolsServiceDependencies) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
next({ events: trace.map((msg) => JSON.stringify(msg)) });
|
|
41
|
-
});
|
|
32
|
+
export const subscribeToSignalTrace = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToSignalTraceResponse>(({ next }) => {
|
|
33
|
+
next({ events: [] });
|
|
34
|
+
const trace: SignalApi.CommandTrace[] = [];
|
|
35
|
+
hook.networkManager.signal.commandTrace.on(msg => {
|
|
36
|
+
trace.push(msg);
|
|
37
|
+
next({ events: trace.map((msg) => JSON.stringify(msg)) });
|
|
42
38
|
});
|
|
43
|
-
};
|
|
39
|
+
});
|
|
44
40
|
|
|
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);
|
|
41
|
+
export const subscribeToNetworkTopics = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToNetworkTopicsResponse>(({ next, close }) => {
|
|
42
|
+
const update = () => {
|
|
43
|
+
try {
|
|
44
|
+
const topics = hook.networkManager.topics;
|
|
45
|
+
const labeledTopics = topics.map(topic => ({
|
|
46
|
+
topic,
|
|
47
|
+
label: hook.networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
48
|
+
}));
|
|
49
|
+
next({ topics: labeledTopics });
|
|
50
|
+
} catch (err: any) {
|
|
51
|
+
close(err);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
hook.networkManager.topicsUpdated.on(update);
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
56
|
+
update();
|
|
57
|
+
});
|
|
64
58
|
|
|
65
|
-
export const subscribeToSwarmInfo = (hook: DevtoolsServiceDependencies) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
};
|
|
59
|
+
export const subscribeToSwarmInfo = (hook: DevtoolsServiceDependencies) => new Stream<SubscribeToSwarmInfoResponse>(({ next }) => {
|
|
60
|
+
const networkManager = hook.networkManager;
|
|
61
|
+
const update = () => {
|
|
62
|
+
const info = networkManager.connectionLog?.swarms;
|
|
63
|
+
if (info) {
|
|
64
|
+
next({ data: info });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
networkManager.connectionLog?.update.on(update);
|
|
68
|
+
update();
|
|
69
|
+
});
|
|
78
70
|
|
|
79
71
|
export const getNetworkPeers = (hook: DevtoolsServiceDependencies, request: GetNetworkPeersRequest): GetNetworkPeersResponse => {
|
|
80
72
|
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,
|
|
@@ -7,6 +7,7 @@ import * as dxos_echo_feed from "./echo/feed";
|
|
|
7
7
|
import * as dxos_echo_invitation from "./echo/invitation";
|
|
8
8
|
import * as dxos_echo_service from "./echo/service";
|
|
9
9
|
import * as dxos_echo_snapshot from "./echo/snapshot";
|
|
10
|
+
import * as dxos_echo_timeframe from "./echo/timeframe";
|
|
10
11
|
import * as dxos_halo_keys from "./halo/keys";
|
|
11
12
|
import * as dxos_rpc from "./rpc";
|
|
12
13
|
import * as google_protobuf from "../google/protobuf";
|
|
@@ -137,7 +138,7 @@ export interface PartyDetails {
|
|
|
137
138
|
/**
|
|
138
139
|
* The timeframe of mutations processed by the client.
|
|
139
140
|
*/
|
|
140
|
-
processedTimeframe: ReturnType<typeof substitutions["dxos.echo.
|
|
141
|
+
processedTimeframe: ReturnType<typeof substitutions["dxos.echo.timeframe.TimeframeVector"]["decode"]>;
|
|
141
142
|
}
|
|
142
143
|
export interface SubscribePartyResponse {
|
|
143
144
|
party?: Party;
|
|
@@ -7,6 +7,7 @@ import * as dxos_echo_feed from "./echo/feed";
|
|
|
7
7
|
import * as dxos_echo_invitation from "./echo/invitation";
|
|
8
8
|
import * as dxos_echo_service from "./echo/service";
|
|
9
9
|
import * as dxos_echo_snapshot from "./echo/snapshot";
|
|
10
|
+
import * as dxos_echo_timeframe from "./echo/timeframe";
|
|
10
11
|
import * as dxos_halo_keys from "./halo/keys";
|
|
11
12
|
import * as dxos_rpc from "./rpc";
|
|
12
13
|
import * as google_protobuf from "../google/protobuf";
|
|
@@ -7,6 +7,7 @@ import * as dxos_echo_feed from "./echo/feed";
|
|
|
7
7
|
import * as dxos_echo_invitation from "./echo/invitation";
|
|
8
8
|
import * as dxos_echo_service from "./echo/service";
|
|
9
9
|
import * as dxos_echo_snapshot from "./echo/snapshot";
|
|
10
|
+
import * as dxos_echo_timeframe from "./echo/timeframe";
|
|
10
11
|
import * as dxos_halo_keys from "./halo/keys";
|
|
11
12
|
import * as dxos_rpc from "./rpc";
|
|
12
13
|
import * as google_protobuf from "../google/protobuf";
|
|
@@ -7,6 +7,7 @@ import * as dxos_echo_feed from "./echo/feed";
|
|
|
7
7
|
import * as dxos_echo_invitation from "./echo/invitation";
|
|
8
8
|
import * as dxos_echo_service from "./echo/service";
|
|
9
9
|
import * as dxos_echo_snapshot from "./echo/snapshot";
|
|
10
|
+
import * as dxos_echo_timeframe from "./echo/timeframe";
|
|
10
11
|
import * as dxos_halo_keys from "./halo/keys";
|
|
11
12
|
import * as dxos_rpc from "./rpc";
|
|
12
13
|
import * as google_protobuf from "../google/protobuf";
|
|
@@ -89,7 +90,7 @@ export namespace SubscribeToPartiesResponse {
|
|
|
89
90
|
isActive?: boolean;
|
|
90
91
|
feedKeys?: number;
|
|
91
92
|
properties?: Partial<Record<string, string>>;
|
|
92
|
-
timeframe?: ReturnType<typeof substitutions["dxos.echo.
|
|
93
|
+
timeframe?: ReturnType<typeof substitutions["dxos.echo.timeframe.TimeframeVector"]["decode"]>;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
export interface SubscribeToItemsRequest {
|