@dxos/client 2.33.6 → 2.33.7-dev.40cf0994
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/README.md +1 -1
- package/dist/src/api/client.d.ts +2 -2
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +1 -0
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/invitations/invitation-proxy.js +7 -7
- package/dist/src/api/invitations/invitation-proxy.js.map +1 -1
- package/dist/src/api/proxies/echo-proxy.d.ts.map +1 -1
- package/dist/src/api/proxies/echo-proxy.js +2 -2
- package/dist/src/api/proxies/echo-proxy.js.map +1 -1
- package/dist/src/api/proxies/halo-proxy.d.ts +11 -9
- package/dist/src/api/proxies/halo-proxy.d.ts.map +1 -1
- package/dist/src/api/proxies/halo-proxy.js +13 -9
- package/dist/src/api/proxies/halo-proxy.js.map +1 -1
- package/dist/src/api/proxies/party-proxy.d.ts +1 -1
- package/dist/src/api/proxies/party-proxy.d.ts.map +1 -1
- package/dist/src/api/proxies/party-proxy.js +1 -1
- package/dist/src/api/proxies/party-proxy.js.map +1 -1
- package/dist/src/devtools/devtools-host.d.ts.map +1 -1
- package/dist/src/devtools/devtools-host.js +4 -5
- package/dist/src/devtools/devtools-host.js.map +1 -1
- package/dist/src/devtools/feeds.d.ts +3 -3
- package/dist/src/devtools/feeds.d.ts.map +1 -1
- package/dist/src/devtools/feeds.js +50 -28
- package/dist/src/devtools/feeds.js.map +1 -1
- package/dist/src/devtools/network.js +2 -2
- package/dist/src/devtools/network.js.map +1 -1
- package/dist/src/devtools/parties.d.ts +2 -2
- package/dist/src/devtools/parties.d.ts.map +1 -1
- package/dist/src/devtools/parties.js +14 -2
- package/dist/src/devtools/parties.js.map +1 -1
- package/dist/src/proto/gen/dxos/devtools.d.ts +20 -16
- package/dist/src/proto/gen/dxos/devtools.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/halo/keys.d.ts +9 -9
- package/dist/src/proto/gen/index.d.ts +4 -4
- 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 +2 -2
- package/dist/src/proto/substitutions.d.ts.map +1 -1
- package/dist/src/proto/substitutions.js +2 -2
- package/dist/src/proto/substitutions.js.map +1 -1
- package/dist/src/services/impl/party.d.ts +2 -2
- package/dist/src/services/services.test.js +3 -3
- package/dist/src/services/services.test.js.map +1 -1
- package/dist/src/util/subscription.d.ts.map +1 -1
- package/dist/src/util/subscription.js +1 -1
- package/dist/src/util/subscription.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/api/client.ts +1 -0
- package/src/api/invitations/invitation-proxy.ts +7 -7
- package/src/api/proxies/echo-proxy.ts +5 -3
- package/src/api/proxies/halo-proxy.ts +25 -16
- package/src/api/proxies/party-proxy.ts +3 -2
- package/src/devtools/devtools-host.ts +9 -7
- package/src/devtools/feeds.ts +68 -30
- package/src/devtools/network.ts +1 -1
- package/src/devtools/parties.ts +20 -2
- package/src/proto/gen/dxos/devtools.ts +20 -16
- package/src/proto/gen/dxos/halo/keys.ts +9 -9
- package/src/proto/gen/index.ts +5 -5
- package/src/proto/substitutions.ts +1 -1
- package/src/services/services.test.ts +4 -5
- package/src/util/subscription.ts +2 -1
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client",
|
|
3
|
-
"version": "2.33.
|
|
3
|
+
"version": "2.33.7-dev.40cf0994",
|
|
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.
|
|
14
|
-
"@dxos/codec-protobuf": "2.33.
|
|
15
|
-
"@dxos/config": "2.33.
|
|
16
|
-
"@dxos/credentials": "2.33.
|
|
17
|
-
"@dxos/crypto": "2.33.
|
|
18
|
-
"@dxos/debug": "2.33.
|
|
19
|
-
"@dxos/echo-db": "2.33.
|
|
20
|
-
"@dxos/echo-protocol": "2.33.
|
|
21
|
-
"@dxos/feed-store": "2.33.
|
|
22
|
-
"@dxos/model-factory": "2.33.
|
|
23
|
-
"@dxos/network-manager": "2.33.
|
|
24
|
-
"@dxos/object-model": "2.33.
|
|
25
|
-
"@dxos/protocols": "2.33.
|
|
26
|
-
"@dxos/rpc": "2.33.
|
|
27
|
-
"@dxos/util": "2.33.
|
|
13
|
+
"@dxos/async": "2.33.7-dev.40cf0994",
|
|
14
|
+
"@dxos/codec-protobuf": "2.33.7-dev.40cf0994",
|
|
15
|
+
"@dxos/config": "2.33.7-dev.40cf0994",
|
|
16
|
+
"@dxos/credentials": "2.33.7-dev.40cf0994",
|
|
17
|
+
"@dxos/crypto": "2.33.7-dev.40cf0994",
|
|
18
|
+
"@dxos/debug": "2.33.7-dev.40cf0994",
|
|
19
|
+
"@dxos/echo-db": "2.33.7-dev.40cf0994",
|
|
20
|
+
"@dxos/echo-protocol": "2.33.7-dev.40cf0994",
|
|
21
|
+
"@dxos/feed-store": "2.33.7-dev.40cf0994",
|
|
22
|
+
"@dxos/model-factory": "2.33.7-dev.40cf0994",
|
|
23
|
+
"@dxos/network-manager": "2.33.7-dev.40cf0994",
|
|
24
|
+
"@dxos/object-model": "2.33.7-dev.40cf0994",
|
|
25
|
+
"@dxos/protocols": "2.33.7-dev.40cf0994",
|
|
26
|
+
"@dxos/rpc": "2.33.7-dev.40cf0994",
|
|
27
|
+
"@dxos/util": "2.33.7-dev.40cf0994",
|
|
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.34",
|
|
41
41
|
"@dxos/protocols-toolchain": "2.33.6",
|
|
42
|
-
"@dxos/random-access-multi-storage": "2.33.
|
|
42
|
+
"@dxos/random-access-multi-storage": "2.33.7-dev.40cf0994",
|
|
43
43
|
"@dxos/testutils": "2.33.6",
|
|
44
44
|
"@types/debug": "^4.1.7",
|
|
45
45
|
"@types/jest": "^26.0.7",
|
package/src/api/client.ts
CHANGED
|
@@ -261,6 +261,7 @@ export class Client {
|
|
|
261
261
|
* Registers a new ECHO model.
|
|
262
262
|
* @deprecated
|
|
263
263
|
*/
|
|
264
|
+
// TODO(burdon): Remove (moved to echo).
|
|
264
265
|
registerModel (constructor: ModelConstructor<any>): this {
|
|
265
266
|
this._echo.modelFactory.registerModel(constructor);
|
|
266
267
|
return this;
|
|
@@ -69,11 +69,11 @@ export class InvitationProxy {
|
|
|
69
69
|
reject(err);
|
|
70
70
|
error.emit(err);
|
|
71
71
|
}
|
|
72
|
-
},
|
|
73
|
-
if (
|
|
74
|
-
console.error(error);
|
|
75
|
-
reject(error);
|
|
72
|
+
}, err => {
|
|
73
|
+
if (err) {
|
|
76
74
|
// TODO(rzadp): Handle retry.
|
|
75
|
+
console.error(err);
|
|
76
|
+
reject(error);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -102,10 +102,10 @@ export class InvitationProxy {
|
|
|
102
102
|
// TODO(dmaretskyi): Should result in an error inside the returned Invitation, rejecting the promise in Invitation.wait().
|
|
103
103
|
throwUnhandledRejection(error);
|
|
104
104
|
}
|
|
105
|
-
},
|
|
106
|
-
if (
|
|
105
|
+
}, err => {
|
|
106
|
+
if (err && !(err instanceof RpcClosedError)) {
|
|
107
107
|
// TODO(dmaretskyi): Should result in an error inside the returned Invitation, rejecting the promise in Invitation.wait().
|
|
108
|
-
throwUnhandledRejection(
|
|
108
|
+
throwUnhandledRejection(err);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
|
|
7
7
|
import { Event, latch } from '@dxos/async';
|
|
8
|
-
import { PublicKey } from '@dxos/crypto';
|
|
9
8
|
import { failUndefined } from '@dxos/debug';
|
|
10
9
|
import { InvitationDescriptor, PARTY_ITEM_TYPE, ResultSet } from '@dxos/echo-db';
|
|
11
10
|
import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
12
11
|
import { ModelConstructor, ModelFactory } from '@dxos/model-factory';
|
|
13
12
|
import { ObjectModel } from '@dxos/object-model';
|
|
13
|
+
import { PublicKey } from '@dxos/protocols';
|
|
14
14
|
import { ComplexMap, SubscriptionGroup } from '@dxos/util';
|
|
15
15
|
|
|
16
16
|
import { ClientServiceHost, ClientServiceProvider } from '../../services';
|
|
@@ -119,12 +119,14 @@ export class EchoProxy implements Echo {
|
|
|
119
119
|
|
|
120
120
|
partyProxy._processPartyUpdate(party);
|
|
121
121
|
this._partiesChanged.emit();
|
|
122
|
-
}
|
|
122
|
+
});
|
|
123
|
+
|
|
123
124
|
this._subscriptions.push(() => partyStream.close());
|
|
124
125
|
}
|
|
125
126
|
}
|
|
127
|
+
|
|
126
128
|
this._partiesChanged.emit();
|
|
127
|
-
}
|
|
129
|
+
});
|
|
128
130
|
|
|
129
131
|
this._subscriptions.push(() => partiesStream.close());
|
|
130
132
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
|
-
import { KeyRecord } from '@dxos/credentials';
|
|
7
|
-
import { PublicKey } from '@dxos/crypto';
|
|
6
|
+
import { DeviceInfo, KeyRecord } from '@dxos/credentials';
|
|
8
7
|
import { Contact, CreateProfileOptions, InvitationDescriptor, PartyMember, ResultSet } from '@dxos/echo-db';
|
|
8
|
+
import { PublicKey } from '@dxos/protocols';
|
|
9
9
|
import { SubscriptionGroup } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { Profile, SignRequest, SignResponse } from '../../proto/gen/dxos/client';
|
|
@@ -23,6 +23,9 @@ export interface Halo {
|
|
|
23
23
|
createProfile (options?: CreateProfileOptions): Promise<Profile>
|
|
24
24
|
recoverProfile (seedPhrase: string): Promise<Profile>
|
|
25
25
|
|
|
26
|
+
sign (request: SignRequest): Promise<SignResponse>
|
|
27
|
+
addKeyRecord (keyRecord: KeyRecord): Promise<void>
|
|
28
|
+
|
|
26
29
|
/**
|
|
27
30
|
* @deprecated
|
|
28
31
|
*/
|
|
@@ -32,13 +35,12 @@ export interface Halo {
|
|
|
32
35
|
createInvitation (): Promise<InvitationRequest>
|
|
33
36
|
acceptInvitation (invitationDescriptor: InvitationDescriptor): Invitation
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
queryDevices (): Promise<DeviceInfo[]>
|
|
39
|
+
setDevicePreference (key: string, value: string): Promise<void>
|
|
40
|
+
getDevicePreference (key: string): Promise<string | undefined>
|
|
37
41
|
|
|
38
42
|
setGlobalPreference (key: string, value: string): Promise<void>
|
|
39
43
|
getGlobalPreference (key: string): Promise<string | undefined>
|
|
40
|
-
setDevicePreference (key: string, value: string): Promise<void>
|
|
41
|
-
getDevicePreference (key: string): Promise<string | undefined>
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
/**
|
|
@@ -155,20 +157,17 @@ export class HaloProxy implements Halo {
|
|
|
155
157
|
);
|
|
156
158
|
}
|
|
157
159
|
|
|
158
|
-
async addKeyRecord (keyRecord: KeyRecord) {
|
|
159
|
-
await this._serviceProvider.services.HaloService.addKeyRecord({ keyRecord });
|
|
160
|
-
}
|
|
161
|
-
|
|
162
160
|
async sign (request: SignRequest) {
|
|
163
161
|
return await this._serviceProvider.services.HaloService.sign(request);
|
|
164
162
|
}
|
|
165
163
|
|
|
166
|
-
async
|
|
167
|
-
await this._serviceProvider.services.HaloService.
|
|
164
|
+
async addKeyRecord (keyRecord: KeyRecord) {
|
|
165
|
+
await this._serviceProvider.services.HaloService.addKeyRecord({ keyRecord });
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
// TODO(burdon): Implement.
|
|
169
|
+
async queryDevices (): Promise<DeviceInfo[]> {
|
|
170
|
+
return [];
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
async setDevicePreference (key: string, value: string): Promise<void> {
|
|
@@ -179,6 +178,14 @@ export class HaloProxy implements Halo {
|
|
|
179
178
|
return (await this._serviceProvider.services.HaloService.getDevicePreference({ key })).value;
|
|
180
179
|
}
|
|
181
180
|
|
|
181
|
+
async setGlobalPreference (key: string, value: string): Promise<void> {
|
|
182
|
+
await this._serviceProvider.services.HaloService.setGlobalPreference({ key, value });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async getGlobalPreference (key: string): Promise<string | undefined> {
|
|
186
|
+
return (await this._serviceProvider.services.HaloService.getGlobalPreference({ key })).value;
|
|
187
|
+
}
|
|
188
|
+
|
|
182
189
|
/**
|
|
183
190
|
* Allocate resources and set-up internal subscriptions.
|
|
184
191
|
*
|
|
@@ -192,14 +199,16 @@ export class HaloProxy implements Halo {
|
|
|
192
199
|
profileStream.subscribe(data => {
|
|
193
200
|
this._profile = data.profile;
|
|
194
201
|
this.profileChanged.emit();
|
|
195
|
-
}
|
|
202
|
+
});
|
|
203
|
+
|
|
196
204
|
this._subscriptions.push(() => profileStream.close());
|
|
197
205
|
|
|
198
206
|
const contactsStream = this._serviceProvider.services.HaloService.subscribeContacts();
|
|
199
207
|
contactsStream.subscribe(data => {
|
|
200
208
|
this._contacts = data.contacts as PartyMember[];
|
|
201
209
|
this._contactsChanged.emit();
|
|
202
|
-
}
|
|
210
|
+
});
|
|
211
|
+
|
|
203
212
|
this._subscriptions.push(() => contactsStream.close());
|
|
204
213
|
|
|
205
214
|
await Promise.all([gotProfile, gotContacts]);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { PublicKey } from '@dxos/crypto';
|
|
6
5
|
import { failUndefined } from '@dxos/debug';
|
|
7
6
|
import {
|
|
8
7
|
PARTY_ITEM_TYPE,
|
|
@@ -17,6 +16,7 @@ import {
|
|
|
17
16
|
import { PartyKey, PartySnapshot } from '@dxos/echo-protocol';
|
|
18
17
|
import { ModelFactory } from '@dxos/model-factory';
|
|
19
18
|
import { ObjectModel, ObjectProperties } from '@dxos/object-model';
|
|
19
|
+
import { PublicKey } from '@dxos/protocols';
|
|
20
20
|
|
|
21
21
|
import { Party as PartyProto, PartyDetails } from '../../proto/gen/dxos/client';
|
|
22
22
|
import { ClientServiceHost, ClientServiceProvider, ClientServiceProxy } from '../../services';
|
|
@@ -51,6 +51,7 @@ export interface Party {
|
|
|
51
51
|
setTitle (title: string): Promise<void>
|
|
52
52
|
getTitle (): string
|
|
53
53
|
|
|
54
|
+
// TODO(burdon): Rename (info?)
|
|
54
55
|
getDetails(): Promise<PartyDetails>
|
|
55
56
|
|
|
56
57
|
get properties (): ObjectProperties
|
|
@@ -112,7 +113,7 @@ export class PartyProxy implements Party {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
// TODO(burdon): Getter
|
|
116
|
+
// TODO(burdon): Getter required by react hook.
|
|
116
117
|
get invitationProxy () {
|
|
117
118
|
return this._invitationProxy;
|
|
118
119
|
}
|
|
@@ -9,7 +9,7 @@ import { getConfig } from './config';
|
|
|
9
9
|
import { enableDebugLogging, disableDebugLogging } from './debug-logging';
|
|
10
10
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
11
11
|
import { DevtoolsHostEvents } from './devtools-host-events';
|
|
12
|
-
import {
|
|
12
|
+
import { subscribeToFeeds, subscribeToFeedBlocks } from './feeds';
|
|
13
13
|
import { subscribeToItems } from './items';
|
|
14
14
|
import { subscribeToCredentialMessages, subscribeToKeyringKeys } from './keys';
|
|
15
15
|
import {
|
|
@@ -22,15 +22,17 @@ import {
|
|
|
22
22
|
import { getPartySnapshot, savePartySnapshot, subscribeToParties } from './parties';
|
|
23
23
|
import { resetStorage } from './storage';
|
|
24
24
|
|
|
25
|
-
export const createDevtoolsHost = (
|
|
25
|
+
export const createDevtoolsHost = (
|
|
26
|
+
context: DevtoolsServiceDependencies,
|
|
27
|
+
events: DevtoolsHostEvents
|
|
28
|
+
): DevtoolsHost => ({
|
|
26
29
|
events: () => new Stream<ClientAPIEvent>(({ next }) => {
|
|
27
30
|
events.ready.on(() => {
|
|
28
31
|
next({ ready: {} });
|
|
29
32
|
});
|
|
30
33
|
}),
|
|
31
34
|
getConfig: async () => {
|
|
32
|
-
|
|
33
|
-
return config;
|
|
35
|
+
return getConfig(context);
|
|
34
36
|
},
|
|
35
37
|
resetStorage: async () => {
|
|
36
38
|
await resetStorage(context);
|
|
@@ -45,10 +47,10 @@ export const createDevtoolsHost = (context: DevtoolsServiceDependencies, events:
|
|
|
45
47
|
},
|
|
46
48
|
subscribeToKeyringKeys: () => subscribeToKeyringKeys(context),
|
|
47
49
|
subscribeToCredentialMessages: (request) => subscribeToCredentialMessages(context, request),
|
|
48
|
-
subscribeToParties: () => subscribeToParties(context),
|
|
50
|
+
subscribeToParties: (request) => subscribeToParties(context, request),
|
|
49
51
|
subscribeToItems: () => subscribeToItems(context),
|
|
50
|
-
subscribeToFeeds: () => subscribeToFeeds(context),
|
|
51
|
-
|
|
52
|
+
subscribeToFeeds: (request) => subscribeToFeeds(context, request),
|
|
53
|
+
subscribeToFeedBlocks: (request) => subscribeToFeedBlocks(context, request),
|
|
52
54
|
getPartySnapshot: async (request) => getPartySnapshot(context, request),
|
|
53
55
|
savePartySnapshot: async (request) => savePartySnapshot(context, request),
|
|
54
56
|
clearSnapshots: async () => {
|
package/src/devtools/feeds.ts
CHANGED
|
@@ -6,44 +6,79 @@ import { Readable } from 'readable-stream';
|
|
|
6
6
|
|
|
7
7
|
import { Stream } from '@dxos/codec-protobuf';
|
|
8
8
|
import { createBatchStream } from '@dxos/feed-store';
|
|
9
|
+
import { PublicKey } from '@dxos/protocols';
|
|
9
10
|
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
SubscribeToFeedsRequest,
|
|
13
|
+
SubscribeToFeedsResponse,
|
|
14
|
+
SubscribeToFeedBlocksRequest,
|
|
15
|
+
SubscribeToFeedBlocksResponse
|
|
16
|
+
} from '../proto/gen/dxos/devtools';
|
|
11
17
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
12
18
|
|
|
13
|
-
export const subscribeToFeeds = (
|
|
14
|
-
|
|
19
|
+
export const subscribeToFeeds = (
|
|
20
|
+
{ echo }: DevtoolsServiceDependencies,
|
|
21
|
+
{ partyKey, feedKeys }: SubscribeToFeedsRequest
|
|
22
|
+
) => new Stream<SubscribeToFeedsResponse>(({ next }) => {
|
|
23
|
+
if (!partyKey || feedKeys?.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const feedMap = new Map<PublicKey, { feedKey: PublicKey, stream: Readable, length: number }>();
|
|
28
|
+
|
|
29
|
+
setImmediate(async () => {
|
|
15
30
|
const { value: parties } = echo.queryParties();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}))
|
|
21
|
-
});
|
|
22
|
-
};
|
|
31
|
+
const party = parties.find(party => party.key.equals(partyKey));
|
|
32
|
+
if (!party) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
const feeds = await party.getFeeds();
|
|
37
|
+
feeds
|
|
38
|
+
.filter(feed => !feedKeys?.length || feedKeys.some(feedKey => feedKey.equals(feed.key)))
|
|
39
|
+
.forEach(feed => {
|
|
40
|
+
let feedInfo = feedMap.get(feed.key);
|
|
41
|
+
if (!feedInfo) {
|
|
42
|
+
// TODO(wittjosiah): Start from timeframe?
|
|
43
|
+
// TODO(wittjosiah): Bi-directional lazy loading to feed into virtualized table.
|
|
44
|
+
// Tail feed so as to not overload the browser.
|
|
45
|
+
const feedStream = new Readable({ objectMode: true })
|
|
46
|
+
.wrap(createBatchStream(feed.feed, {
|
|
47
|
+
live: true,
|
|
48
|
+
start: 0
|
|
49
|
+
}));
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
feedStream.on('data', blocks => {
|
|
52
|
+
feedInfo!.length += blocks.length;
|
|
53
|
+
|
|
54
|
+
next({
|
|
55
|
+
feeds: Array.from(feedMap.values()).map(({ feedKey, length }) => ({
|
|
56
|
+
feedKey,
|
|
57
|
+
length
|
|
58
|
+
}))
|
|
59
|
+
});
|
|
60
|
+
});
|
|
36
61
|
|
|
37
|
-
|
|
38
|
-
|
|
62
|
+
feedInfo = {
|
|
63
|
+
feedKey: feed.key,
|
|
64
|
+
stream: feedStream,
|
|
65
|
+
length: 0
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
feedMap.set(feed.key, feedInfo);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
39
72
|
|
|
40
73
|
return () => {
|
|
41
|
-
|
|
42
|
-
Object.values(partySubscriptions).forEach(unsubscribe => unsubscribe());
|
|
74
|
+
feedMap.forEach(({ stream }) => stream.destroy());
|
|
43
75
|
};
|
|
44
76
|
});
|
|
45
77
|
|
|
46
|
-
export const
|
|
78
|
+
export const subscribeToFeedBlocks = (
|
|
79
|
+
{ echo }: DevtoolsServiceDependencies,
|
|
80
|
+
{ partyKey, feedKey, maxBlocks = 10 }: SubscribeToFeedBlocksRequest
|
|
81
|
+
) => new Stream<SubscribeToFeedBlocksResponse>(({ next }) => {
|
|
47
82
|
if (!partyKey || !feedKey) {
|
|
48
83
|
return;
|
|
49
84
|
}
|
|
@@ -56,16 +91,19 @@ export const subscribeToFeed = ({ echo }: DevtoolsServiceDependencies, { partyKe
|
|
|
56
91
|
return;
|
|
57
92
|
}
|
|
58
93
|
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
94
|
+
const descriptor = await party.getFeeds().find(feed => feed.key.equals(feedKey));
|
|
95
|
+
if (!descriptor) {
|
|
61
96
|
return;
|
|
62
97
|
}
|
|
63
98
|
|
|
64
99
|
// TODO(wittjosiah): Start from timeframe?
|
|
65
|
-
// TODO(wittjosiah):
|
|
100
|
+
// TODO(wittjosiah): Bi-directional lazy loading to feed into virtualized table.
|
|
66
101
|
// Tail feed so as to not overload the browser.
|
|
67
102
|
feedStream = new Readable({ objectMode: true })
|
|
68
|
-
.wrap(createBatchStream(
|
|
103
|
+
.wrap(createBatchStream(descriptor.feed, {
|
|
104
|
+
live: true,
|
|
105
|
+
start: Math.max(0, descriptor.feed.length - maxBlocks)
|
|
106
|
+
}));
|
|
69
107
|
|
|
70
108
|
feedStream.on('data', blocks => {
|
|
71
109
|
next({ blocks });
|
package/src/devtools/network.ts
CHANGED
package/src/devtools/parties.ts
CHANGED
|
@@ -9,14 +9,32 @@ import {
|
|
|
9
9
|
GetPartySnapshotResponse,
|
|
10
10
|
SavePartySnapshotRequest,
|
|
11
11
|
SavePartySnapshotResponse,
|
|
12
|
+
SubscribeToPartiesRequest,
|
|
12
13
|
SubscribeToPartiesResponse
|
|
13
14
|
} from '../proto/gen/dxos/devtools';
|
|
14
15
|
import { DevtoolsServiceDependencies } from './devtools-context';
|
|
15
16
|
|
|
16
|
-
export const subscribeToParties = (
|
|
17
|
+
export const subscribeToParties = (
|
|
18
|
+
{ echo }: DevtoolsServiceDependencies,
|
|
19
|
+
{ partyKeys = [] }: SubscribeToPartiesRequest
|
|
20
|
+
) => new Stream<SubscribeToPartiesResponse>(({ next }) => {
|
|
17
21
|
const update = () => {
|
|
18
22
|
const { value: parties } = echo.queryParties();
|
|
19
|
-
|
|
23
|
+
const filteredParties = parties.filter(
|
|
24
|
+
party => !partyKeys?.length || partyKeys.some(partyKey => partyKey.equals(party.key)));
|
|
25
|
+
|
|
26
|
+
next({
|
|
27
|
+
parties: filteredParties.map(party => {
|
|
28
|
+
return {
|
|
29
|
+
key: party.key,
|
|
30
|
+
isOpen: party.isOpen,
|
|
31
|
+
isActive: party.isActive,
|
|
32
|
+
timeframe: party.timeframe,
|
|
33
|
+
feeds: party.getFeeds().map(feed => feed.key),
|
|
34
|
+
properties: party.isOpen ? party.getPropertiesSet().expectOne().model.toObject() : undefined
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
});
|
|
20
38
|
};
|
|
21
39
|
|
|
22
40
|
const partySubscriptions: Record<string, () => void> = {};
|
|
@@ -22,7 +22,7 @@ export interface DevtoolsHost {
|
|
|
22
22
|
subscribeToParties: (request: SubscribeToPartiesRequest) => Stream<SubscribeToPartiesResponse>;
|
|
23
23
|
subscribeToItems: (request: SubscribeToItemsRequest) => Stream<SubscribeToItemsResponse>;
|
|
24
24
|
subscribeToFeeds: (request: SubscribeToFeedsRequest) => Stream<SubscribeToFeedsResponse>;
|
|
25
|
-
|
|
25
|
+
subscribeToFeedBlocks: (request: SubscribeToFeedBlocksRequest) => Stream<SubscribeToFeedBlocksResponse>;
|
|
26
26
|
getPartySnapshot: (request: GetPartySnapshotRequest) => Promise<GetPartySnapshotResponse>;
|
|
27
27
|
savePartySnapshot: (request: SavePartySnapshotRequest) => Promise<SavePartySnapshotResponse>;
|
|
28
28
|
clearSnapshots: (request: ClearSnapshotsRequest) => Promise<void>;
|
|
@@ -79,18 +79,19 @@ export namespace GetNetworkPeersResponse {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
export interface SubscribeToPartiesRequest {
|
|
82
|
+
partyKeys?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>[];
|
|
82
83
|
}
|
|
83
84
|
export interface SubscribeToPartiesResponse {
|
|
84
85
|
parties?: SubscribeToPartiesResponse.PartyInfo[];
|
|
85
86
|
}
|
|
86
87
|
export namespace SubscribeToPartiesResponse {
|
|
87
88
|
export interface PartyInfo {
|
|
88
|
-
key?:
|
|
89
|
+
key?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>;
|
|
89
90
|
isOpen?: boolean;
|
|
90
91
|
isActive?: boolean;
|
|
91
|
-
feedKeys?: number;
|
|
92
|
-
properties?: Partial<Record<string, string>>;
|
|
93
92
|
timeframe?: ReturnType<(typeof substitutions)["dxos.echo.timeframe.TimeframeVector"]["decode"]>;
|
|
93
|
+
feeds?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>[];
|
|
94
|
+
properties?: Partial<Record<string, string>>;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
export interface SubscribeToItemsRequest {
|
|
@@ -99,25 +100,28 @@ export interface SubscribeToItemsResponse {
|
|
|
99
100
|
data?: string;
|
|
100
101
|
}
|
|
101
102
|
export interface SubscribeToFeedsRequest {
|
|
103
|
+
partyKey?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>;
|
|
104
|
+
feedKeys?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>[];
|
|
102
105
|
}
|
|
103
106
|
export interface SubscribeToFeedsResponse {
|
|
104
|
-
|
|
107
|
+
feeds?: SubscribeToFeedsResponse.Feed[];
|
|
105
108
|
}
|
|
106
109
|
export namespace SubscribeToFeedsResponse {
|
|
107
|
-
export interface
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
export interface Feed {
|
|
111
|
+
feedKey?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>;
|
|
112
|
+
length?: number;
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
export interface
|
|
115
|
+
export interface SubscribeToFeedBlocksRequest {
|
|
113
116
|
partyKey?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>;
|
|
114
117
|
feedKey?: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>;
|
|
118
|
+
maxBlocks?: number;
|
|
115
119
|
}
|
|
116
|
-
export interface
|
|
117
|
-
blocks?:
|
|
120
|
+
export interface SubscribeToFeedBlocksResponse {
|
|
121
|
+
blocks?: SubscribeToFeedBlocksResponse.Block[];
|
|
118
122
|
}
|
|
119
|
-
export namespace
|
|
120
|
-
export interface
|
|
123
|
+
export namespace SubscribeToFeedBlocksResponse {
|
|
124
|
+
export interface Block {
|
|
121
125
|
key?: Uint8Array;
|
|
122
126
|
seq?: number;
|
|
123
127
|
sync?: boolean;
|
|
@@ -193,10 +197,10 @@ export namespace SubscribeToSwarmInfoResponse {
|
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
|
-
export interface SetTracingOptionsRequest {
|
|
197
|
-
enable?: boolean;
|
|
198
|
-
}
|
|
199
200
|
export interface TracingService {
|
|
200
201
|
setTracingOptions: (request: SetTracingOptionsRequest) => Promise<void>;
|
|
201
202
|
subscribeToRpcTrace: (request: void) => Stream<dxos_rpc.RpcMessage>;
|
|
202
203
|
}
|
|
204
|
+
export interface SetTracingOptionsRequest {
|
|
205
|
+
enable?: boolean;
|
|
206
|
+
}
|
|
@@ -27,36 +27,36 @@ export interface PrivKey {
|
|
|
27
27
|
}
|
|
28
28
|
export interface KeyRecord {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* The `KeyType` type of the key. This is often unknown for keys from other sources.
|
|
31
31
|
*/
|
|
32
32
|
type: KeyType;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* The public key as a Buffer (required).
|
|
35
35
|
*/
|
|
36
36
|
publicKey: ReturnType<(typeof substitutions)["dxos.halo.keys.PubKey"]["decode"]>;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* The secret key as a Buffer (this will never be visible outside the Keyring).
|
|
39
39
|
*/
|
|
40
40
|
secretKey?: ReturnType<(typeof substitutions)["dxos.halo.keys.PrivKey"]["decode"]>;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Is this key from a Greeting "hint"?
|
|
43
43
|
*/
|
|
44
44
|
hint?: boolean;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
* may be false for "inception keys" such as the Party key.
|
|
46
|
+
* Determines if this is our key?
|
|
47
|
+
* Usually true if `secretKey` is present; may be false for "inception keys" such as the Party key.
|
|
48
48
|
*/
|
|
49
49
|
own?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Is this key to be trusted?
|
|
52
52
|
*/
|
|
53
53
|
trusted?: boolean;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* An RFC-3339 date/time string for when the key was added to the Keyring.
|
|
56
56
|
*/
|
|
57
57
|
added?: string;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* An RFC-3339 date/time string for when the key was created.
|
|
60
60
|
*/
|
|
61
61
|
created?: string;
|
|
62
62
|
}
|