@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.
Files changed (127) hide show
  1. package/dist/src/api/client.test.js +3 -5
  2. package/dist/src/api/client.test.js.map +1 -1
  3. package/dist/src/api/index.js +5 -1
  4. package/dist/src/api/index.js.map +1 -1
  5. package/dist/src/api/invitations/index.js +5 -1
  6. package/dist/src/api/invitations/index.js.map +1 -1
  7. package/dist/src/api/proxies/index.js +5 -1
  8. package/dist/src/api/proxies/index.js.map +1 -1
  9. package/dist/src/devtools/config.d.ts.map +1 -1
  10. package/dist/src/devtools/config.js +3 -5
  11. package/dist/src/devtools/config.js.map +1 -1
  12. package/dist/src/devtools/devtools-host.d.ts.map +1 -1
  13. package/dist/src/devtools/devtools-host.js +38 -68
  14. package/dist/src/devtools/devtools-host.js.map +1 -1
  15. package/dist/src/devtools/feeds.d.ts.map +1 -1
  16. package/dist/src/devtools/feeds.js +49 -50
  17. package/dist/src/devtools/feeds.js.map +1 -1
  18. package/dist/src/devtools/index.js +5 -1
  19. package/dist/src/devtools/index.js.map +1 -1
  20. package/dist/src/devtools/items.d.ts.map +1 -1
  21. package/dist/src/devtools/items.js +23 -25
  22. package/dist/src/devtools/items.js.map +1 -1
  23. package/dist/src/devtools/keys.d.ts.map +1 -1
  24. package/dist/src/devtools/keys.js +19 -23
  25. package/dist/src/devtools/keys.js.map +1 -1
  26. package/dist/src/devtools/network.d.ts.map +1 -1
  27. package/dist/src/devtools/network.js +51 -59
  28. package/dist/src/devtools/network.js.map +1 -1
  29. package/dist/src/devtools/parties.d.ts.map +1 -1
  30. package/dist/src/devtools/parties.js +23 -25
  31. package/dist/src/devtools/parties.js.map +1 -1
  32. package/dist/src/index.js +5 -1
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/proto/gen/dxos/client.d.ts +15 -15
  35. package/dist/src/proto/gen/dxos/client.d.ts.map +1 -1
  36. package/dist/src/proto/gen/dxos/client.js.map +1 -1
  37. package/dist/src/proto/gen/dxos/config.d.ts +1 -1
  38. package/dist/src/proto/gen/dxos/config.d.ts.map +1 -1
  39. package/dist/src/proto/gen/dxos/config.js.map +1 -1
  40. package/dist/src/proto/gen/dxos/credentials.d.ts +3 -3
  41. package/dist/src/proto/gen/dxos/credentials.d.ts.map +1 -1
  42. package/dist/src/proto/gen/dxos/devtools.d.ts +15 -15
  43. package/dist/src/proto/gen/dxos/devtools.d.ts.map +1 -1
  44. package/dist/src/proto/gen/dxos/echo/feed.d.ts +2 -14
  45. package/dist/src/proto/gen/dxos/echo/feed.d.ts.map +1 -1
  46. package/dist/src/proto/gen/dxos/echo/feed.js.map +1 -1
  47. package/dist/src/proto/gen/dxos/echo/invitation.d.ts.map +1 -1
  48. package/dist/src/proto/gen/dxos/echo/invitation.js.map +1 -1
  49. package/dist/src/proto/gen/dxos/echo/service.d.ts +7 -7
  50. package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
  51. package/dist/src/proto/gen/dxos/echo/snapshot.d.ts +4 -4
  52. package/dist/src/proto/gen/dxos/echo/snapshot.d.ts.map +1 -1
  53. package/dist/src/proto/gen/dxos/echo/timeframe.d.ts +13 -0
  54. package/dist/src/proto/gen/dxos/echo/timeframe.d.ts.map +1 -0
  55. package/dist/src/proto/gen/dxos/echo/timeframe.js +3 -0
  56. package/dist/src/proto/gen/dxos/echo/timeframe.js.map +1 -0
  57. package/dist/src/proto/gen/dxos/halo/keys.d.ts +3 -3
  58. package/dist/src/proto/gen/dxos/halo/keys.d.ts.map +1 -1
  59. package/dist/src/proto/gen/dxos/halo/keys.js.map +1 -1
  60. package/dist/src/proto/gen/dxos/rpc.d.ts +2 -2
  61. package/dist/src/proto/gen/dxos/rpc.d.ts.map +1 -1
  62. package/dist/src/proto/gen/dxos/rpc.js.map +1 -1
  63. package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
  64. package/dist/src/proto/gen/google/protobuf.js.map +1 -1
  65. package/dist/src/proto/gen/index.d.ts +3 -2
  66. package/dist/src/proto/gen/index.d.ts.map +1 -1
  67. package/dist/src/proto/gen/index.js +1 -1
  68. package/dist/src/proto/gen/index.js.map +1 -1
  69. package/dist/src/proto/substitutions.d.ts +1 -1
  70. package/dist/src/services/impl/halo.d.ts.map +1 -1
  71. package/dist/src/services/impl/halo.js +1 -3
  72. package/dist/src/services/impl/halo.js.map +1 -1
  73. package/dist/src/services/impl/index.js +5 -1
  74. package/dist/src/services/impl/index.js.map +1 -1
  75. package/dist/src/services/impl/party.d.ts.map +1 -1
  76. package/dist/src/services/impl/party.js +10 -16
  77. package/dist/src/services/impl/party.js.map +1 -1
  78. package/dist/src/services/impl/profile.d.ts.map +1 -1
  79. package/dist/src/services/impl/profile.js +1 -3
  80. package/dist/src/services/impl/profile.js.map +1 -1
  81. package/dist/src/services/impl/services.d.ts.map +1 -1
  82. package/dist/src/services/impl/services.js +14 -16
  83. package/dist/src/services/impl/services.js.map +1 -1
  84. package/dist/src/services/impl/system.d.ts.map +1 -1
  85. package/dist/src/services/impl/system.js +6 -10
  86. package/dist/src/services/impl/system.js.map +1 -1
  87. package/dist/src/services/index.js +5 -1
  88. package/dist/src/services/index.js.map +1 -1
  89. package/dist/src/services/service-host.js +5 -1
  90. package/dist/src/services/service-host.js.map +1 -1
  91. package/dist/src/util/index.js +5 -1
  92. package/dist/src/util/index.js.map +1 -1
  93. package/dist/src/util/messages.js +2 -2
  94. package/dist/src/util/messages.js.map +1 -1
  95. package/dist/src/util/subscription.d.ts +2 -2
  96. package/dist/src/util/subscription.d.ts.map +1 -1
  97. package/dist/src/util/subscription.js +6 -8
  98. package/dist/src/util/subscription.js.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/package.json +19 -19
  101. package/src/api/client.test.ts +3 -5
  102. package/src/devtools/config.ts +3 -5
  103. package/src/devtools/devtools-host.ts +38 -68
  104. package/src/devtools/feeds.ts +53 -57
  105. package/src/devtools/items.ts +25 -27
  106. package/src/devtools/keys.ts +19 -26
  107. package/src/devtools/network.ts +47 -54
  108. package/src/devtools/parties.ts +25 -27
  109. package/src/proto/gen/dxos/client.ts +16 -15
  110. package/src/proto/gen/dxos/config.ts +2 -1
  111. package/src/proto/gen/dxos/credentials.ts +4 -3
  112. package/src/proto/gen/dxos/devtools.ts +16 -15
  113. package/src/proto/gen/dxos/echo/feed.ts +3 -14
  114. package/src/proto/gen/dxos/echo/invitation.ts +1 -0
  115. package/src/proto/gen/dxos/echo/service.ts +8 -7
  116. package/src/proto/gen/dxos/echo/snapshot.ts +5 -4
  117. package/src/proto/gen/dxos/echo/timeframe.ts +25 -0
  118. package/src/proto/gen/dxos/halo/keys.ts +4 -3
  119. package/src/proto/gen/dxos/rpc.ts +3 -2
  120. package/src/proto/gen/google/protobuf.ts +1 -0
  121. package/src/proto/gen/index.ts +4 -3
  122. package/src/services/impl/halo.ts +1 -3
  123. package/src/services/impl/party.ts +10 -16
  124. package/src/services/impl/profile.ts +1 -3
  125. package/src/services/impl/services.ts +14 -16
  126. package/src/services/impl/system.ts +6 -10
  127. 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.ea3876ba",
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.ea3876ba",
14
- "@dxos/codec-protobuf": "2.33.5-dev.ea3876ba",
15
- "@dxos/config": "2.33.5-dev.ea3876ba",
16
- "@dxos/credentials": "2.33.5-dev.ea3876ba",
17
- "@dxos/crypto": "2.33.5-dev.ea3876ba",
18
- "@dxos/debug": "2.33.5-dev.ea3876ba",
19
- "@dxos/echo-db": "2.33.5-dev.ea3876ba",
20
- "@dxos/echo-protocol": "2.33.5-dev.ea3876ba",
21
- "@dxos/feed-store": "2.33.5-dev.ea3876ba",
22
- "@dxos/model-factory": "2.33.5-dev.ea3876ba",
23
- "@dxos/network-manager": "2.33.5-dev.ea3876ba",
24
- "@dxos/object-model": "2.33.5-dev.ea3876ba",
25
- "@dxos/protocols": "2.33.5-dev.ea3876ba",
26
- "@dxos/rpc": "2.33.5-dev.ea3876ba",
27
- "@dxos/util": "2.33.5-dev.ea3876ba",
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.27",
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.ea3876ba",
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.5.2",
56
+ "typescript": "^4.7.2",
57
57
  "wait-for-expect": "^3.0.2"
58
58
  },
59
59
  "publishConfig": {
@@ -25,7 +25,7 @@ describe('Client', () => {
25
25
  //
26
26
  // Suite is called for local and remote client configurations.
27
27
  //
28
- function testSuite (createClient: () => Promise<Client>) {
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', () => {
@@ -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
- return {
10
- config: JSON.stringify(hook.config.values) // TODO(marik-d): Serialize config with protobuf.
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) : DevtoolsHost => {
26
- return {
27
- events: () => {
28
- return new Stream<ClientAPIEvent>(({ next }) => {
29
- events.ready.on(() => {
30
- next({ ready: {} });
31
- });
32
- });
33
- },
34
- getConfig: async () => {
35
- const config = getConfig(context);
36
- return config;
37
- },
38
- resetStorage: async () => {
39
- await resetStorage(context);
40
- },
41
- enableDebugLogging: async (request) => {
42
- enableDebugLogging(context, request);
43
- return {};
44
- },
45
- disableDebugLogging: async () => {
46
- disableDebugLogging(context);
47
- return {};
48
- },
49
- subscribeToKeyringKeys: () => {
50
- return subscribeToKeyringKeys(context);
51
- },
52
- subscribeToCredentialMessages: (request) => {
53
- return subscribeToCredentialMessages(context, request);
54
- },
55
- subscribeToParties: () => {
56
- return subscribeToParties(context);
57
- },
58
- subscribeToItems: () => {
59
- return subscribeToItems(context);
60
- },
61
- subscribeToFeeds: () => {
62
- return subscribeToFeeds(context);
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
+ });
@@ -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
- return new Stream<SubscribeToFeedsResponse>(({ next }) => {
15
- const update = () => {
16
- const { value: parties } = echo.queryParties();
17
- next({
18
- parties: parties.map(party => ({
19
- key: party.key,
20
- feeds: party.feedProvider.getFeeds().map(feed => feed.key)
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
- // Send feeds for new parties.
35
- update();
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 initial feeds.
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
- export const subscribeToFeed = (
49
- { echo }: DevtoolsServiceDependencies,
50
- { partyKey, feedKey }: SubscribeToFeedRequest
51
- ) => {
52
- return new Stream<SubscribeToFeedResponse>(({ next }) => {
53
- if (!partyKey || !feedKey) {
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
- let feedStream: Readable;
58
- setImmediate(async () => {
59
- const { value: parties } = echo.queryParties();
60
- const party = parties.find(party => party.key.equals(partyKey));
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
- // TODO(wittjosiah): Start from timeframe?
68
- // TODO(wittjosiah): Bidirectional lazy loading to feed into virtualized table.
69
- // Tail feed so as to not overload the browser.
70
- feedStream = new Readable({ objectMode: true })
71
- .wrap(createBatchStream(feed, { live: true, start: Math.max(0, feed.length - 10) }));
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
- feedStream.on('data', blocks => {
74
- next({ blocks });
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
+ });
@@ -37,35 +37,33 @@ const getData = (echo: DevtoolsServiceDependencies['echo']): SubscribeToItemsRes
37
37
  };
38
38
  };
39
39
 
40
- export const subscribeToItems = ({ echo }: DevtoolsServiceDependencies) => {
41
- return new Stream<SubscribeToItemsResponse>(({ next }) => {
42
- const update = () => {
43
- const res = getData(echo);
44
- next(res);
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
- // Send items for new parties.
60
- update();
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 initial items.
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
+ });
@@ -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
- return new Stream<SubscribeToKeyringKeysResponse>(({ next }) => {
17
- next({ keys: keyring.keys });
18
- return keyring.keysUpdate.on((keys) => {
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
- { echo }: DevtoolsServiceDependencies,
26
- { partyKey }: SubscribeToCredentialMessagesRequest
27
- ) => {
28
- return new Stream<SubscribeToCredentialMessagesResponse>(({ next }) => {
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
- const update = () => {
35
- next({ messages: Array.from(party.processor.credentialMessages.values()) });
36
- };
28
+ const update = () => {
29
+ next({ messages: Array.from(party.processor.credentialMessages.values()) });
30
+ };
37
31
 
38
- const subscriptions = new SubscriptionGroup();
39
- subscriptions.push(party.processor.keyOrInfoAdded.on(() => update()));
40
- subscriptions.push(party.processor.feedAdded.on(() => update()));
41
- update();
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
- return () => subscriptions.unsubscribe();
44
- });
45
- };
37
+ return () => subscriptions.unsubscribe();
38
+ });
@@ -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
- return new Stream<SubscribeToSignalStatusResponse>(({ next, close }) => {
21
- const update = () => {
22
- try {
23
- const status = hook.networkManager.signal.getStatus();
24
- next({ servers: status });
25
- } catch (err: any) {
26
- close(err);
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
- export const subscribeToSignalTrace = (hook: DevtoolsServiceDependencies) => {
35
- return new Stream<SubscribeToSignalTraceResponse>(({ next }) => {
36
- next({ events: [] });
37
- const trace: SignalApi.CommandTrace[] = [];
38
- hook.networkManager.signal.commandTrace.on(msg => {
39
- trace.push(msg);
40
- next({ events: trace.map((msg) => JSON.stringify(msg)) });
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
- return new Stream<SubscribeToNetworkTopicsResponse>(({ next, close }) => {
47
- const update = () => {
48
- try {
49
- const topics = hook.networkManager.topics;
50
- const labeledTopics = topics.map(topic => ({
51
- topic,
52
- label: hook.networkManager.getSwarm(topic)?.label ?? topic.toHex()
53
- }));
54
- next({ topics: labeledTopics });
55
- } catch (err: any) {
56
- close(err);
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
- update();
62
- });
63
- };
57
+ update();
58
+ });
64
59
 
65
- export const subscribeToSwarmInfo = (hook: DevtoolsServiceDependencies) => {
66
- return new Stream<SubscribeToSwarmInfoResponse>(({ next }) => {
67
- const networkManager = hook.networkManager;
68
- const update = () => {
69
- const info = networkManager.connectionLog?.swarms;
70
- if (info) {
71
- next({ data: info });
72
- }
73
- };
74
- networkManager.connectionLog?.update.on(update);
75
- update();
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) {
@@ -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
- return new Stream<SubscribeToPartiesResponse>(({ next }) => {
18
- const update = () => {
19
- const { value: parties } = echo.queryParties();
20
- next({ parties: parties.map(party => party.partyInfo) });
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
- const partySubscriptions: Record<string, () => void> = {};
24
- const timeframeSubscriptions: Record<string, () => void> = {};
25
- const unsubscribe = echo.queryParties().subscribe((parties) => {
26
- parties.forEach((party) => {
27
- if (!partySubscriptions[party.key.toHex()]) {
28
- // Send updates on party changes.
29
- partySubscriptions[party.key.toHex()] = party.update.on(() => update());
30
- timeframeSubscriptions[party.key.toHex()] = party.timeframeUpdate.on(() => update());
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 initial parties.
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,