@dxos/client-services 0.1.56-main.09ca29d → 0.1.56-main.0e9f69e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-FD4L7N4K.mjs → chunk-II6TDINB.mjs} +782 -511
- package/dist/lib/browser/chunk-II6TDINB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +30 -31
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +31 -46
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +918 -649
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1198 -939
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +12 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +15 -3
- package/src/packlets/identity/identity-manager.ts +27 -6
- package/src/packlets/identity/identity-service.test.ts +17 -2
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +16 -9
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +38 -18
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.test.ts +80 -22
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +3 -2
- package/src/packlets/vault/worker-session.ts +6 -1
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
|
@@ -55,6 +55,12 @@ export type DataSpaceParams = {
|
|
|
55
55
|
cache?: SpaceCache;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Delete feed blocks after an epoch is created.
|
|
60
|
+
*/
|
|
61
|
+
// TODO(dmaretskyi): Disabled till better times https://github.com/dxos/dxos/issues/3949.
|
|
62
|
+
const ENABLE_FEED_PURGE = false;
|
|
63
|
+
|
|
58
64
|
@trackLeaks('open', 'close')
|
|
59
65
|
export class DataSpace {
|
|
60
66
|
private _ctx = new Context();
|
|
@@ -145,7 +151,7 @@ export class DataSpace {
|
|
|
145
151
|
private async _open() {
|
|
146
152
|
await this._notarizationPlugin.open();
|
|
147
153
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
148
|
-
await this._inner.open();
|
|
154
|
+
await this._inner.open(new Context());
|
|
149
155
|
this._state = SpaceState.CONTROL_ONLY;
|
|
150
156
|
this.stateUpdate.emit();
|
|
151
157
|
this.metrics = {};
|
|
@@ -323,10 +329,16 @@ export class DataSpace {
|
|
|
323
329
|
});
|
|
324
330
|
|
|
325
331
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe([[receipt.feedKey, receipt.seq]]));
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
332
|
+
|
|
333
|
+
// Clear feed blocks before epoch.
|
|
334
|
+
if (ENABLE_FEED_PURGE) {
|
|
335
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
336
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
337
|
+
if (indexBeforeEpoch === undefined) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
330
342
|
}
|
|
331
343
|
}
|
|
332
344
|
}
|
|
@@ -6,6 +6,7 @@ import chai, { expect } from 'chai';
|
|
|
6
6
|
import chaiAsPromised from 'chai-as-promised';
|
|
7
7
|
|
|
8
8
|
import { Trigger } from '@dxos/async';
|
|
9
|
+
import { Context } from '@dxos/context';
|
|
9
10
|
import { PublicKey } from '@dxos/keys';
|
|
10
11
|
import { Space, SpacesService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
12
|
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
@@ -22,7 +23,7 @@ describe('SpacesService', () => {
|
|
|
22
23
|
|
|
23
24
|
beforeEach(async () => {
|
|
24
25
|
serviceContext = createServiceContext();
|
|
25
|
-
await serviceContext.open();
|
|
26
|
+
await serviceContext.open(new Context());
|
|
26
27
|
spacesService = new SpacesServiceImpl(
|
|
27
28
|
serviceContext.identityManager,
|
|
28
29
|
serviceContext.spaceManager,
|
|
@@ -6,18 +6,22 @@ import { Event } from '@dxos/async';
|
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
7
7
|
import { Config } from '@dxos/config';
|
|
8
8
|
import {
|
|
9
|
+
GetDiagnosticsRequest,
|
|
9
10
|
SystemService,
|
|
10
11
|
SystemStatus,
|
|
11
12
|
UpdateStatusRequest,
|
|
12
13
|
QueryStatusRequest,
|
|
13
14
|
QueryStatusResponse,
|
|
14
15
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
15
|
-
import { MaybePromise } from '@dxos/util';
|
|
16
|
+
import { jsonKeyReplacer, MaybePromise } from '@dxos/util';
|
|
17
|
+
|
|
18
|
+
import { Diagnostics } from '../services';
|
|
16
19
|
|
|
17
20
|
export type SystemServiceOptions = {
|
|
18
21
|
config?: Config;
|
|
19
22
|
statusUpdate: Event<void>;
|
|
20
23
|
getCurrentStatus: () => SystemStatus;
|
|
24
|
+
getDiagnostics: () => Promise<Partial<Diagnostics>>;
|
|
21
25
|
onUpdateStatus: (status: SystemStatus) => MaybePromise<void>;
|
|
22
26
|
onReset: () => MaybePromise<void>;
|
|
23
27
|
};
|
|
@@ -28,11 +32,20 @@ export class SystemServiceImpl implements SystemService {
|
|
|
28
32
|
private readonly _getCurrentStatus: SystemServiceOptions['getCurrentStatus'];
|
|
29
33
|
private readonly _onUpdateStatus: SystemServiceOptions['onUpdateStatus'];
|
|
30
34
|
private readonly _onReset: SystemServiceOptions['onReset'];
|
|
35
|
+
private readonly _getDiagnostics: SystemServiceOptions['getDiagnostics'];
|
|
31
36
|
|
|
32
|
-
constructor({
|
|
37
|
+
constructor({
|
|
38
|
+
config,
|
|
39
|
+
statusUpdate,
|
|
40
|
+
getDiagnostics,
|
|
41
|
+
onUpdateStatus,
|
|
42
|
+
getCurrentStatus,
|
|
43
|
+
onReset,
|
|
44
|
+
}: SystemServiceOptions) {
|
|
33
45
|
this._config = config;
|
|
34
46
|
this._statusUpdate = statusUpdate;
|
|
35
47
|
this._getCurrentStatus = getCurrentStatus;
|
|
48
|
+
this._getDiagnostics = getDiagnostics;
|
|
36
49
|
this._onUpdateStatus = onUpdateStatus;
|
|
37
50
|
this._onReset = onReset;
|
|
38
51
|
}
|
|
@@ -41,6 +54,25 @@ export class SystemServiceImpl implements SystemService {
|
|
|
41
54
|
return this._config?.values ?? {};
|
|
42
55
|
}
|
|
43
56
|
|
|
57
|
+
/**
|
|
58
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
59
|
+
*/
|
|
60
|
+
async getDiagnostics({ keys }: GetDiagnosticsRequest = {}) {
|
|
61
|
+
const diagnostics = await this._getDiagnostics();
|
|
62
|
+
return {
|
|
63
|
+
timestamp: new Date(),
|
|
64
|
+
diagnostics: JSON.parse(
|
|
65
|
+
JSON.stringify(
|
|
66
|
+
diagnostics,
|
|
67
|
+
jsonKeyReplacer({
|
|
68
|
+
truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
69
|
+
humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE,
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
44
76
|
async updateStatus({ status }: UpdateStatusRequest) {
|
|
45
77
|
await this._onUpdateStatus(status);
|
|
46
78
|
}
|
|
@@ -60,7 +60,7 @@ export const createPeers = async (numPeers: number) => {
|
|
|
60
60
|
return await Promise.all(
|
|
61
61
|
Array.from(Array(numPeers)).map(async () => {
|
|
62
62
|
const peer = createServiceContext({ signalContext });
|
|
63
|
-
await peer.open();
|
|
63
|
+
await peer.open(new Context());
|
|
64
64
|
return peer;
|
|
65
65
|
}),
|
|
66
66
|
);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
6
|
import { PROXY_CONNECTION_TIMEOUT, ShellRuntime } from '@dxos/client-protocol';
|
|
7
7
|
import { Config } from '@dxos/config';
|
|
8
|
+
import { Context } from '@dxos/context';
|
|
8
9
|
import { log, logInfo } from '@dxos/log';
|
|
9
10
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
|
|
10
11
|
import { createWebRTCTransportFactory, TransportFactory } from '@dxos/network-manager';
|
|
@@ -108,7 +109,7 @@ export class IFrameHostRuntime {
|
|
|
108
109
|
...middleware,
|
|
109
110
|
});
|
|
110
111
|
|
|
111
|
-
await Promise.all([this._clientServices.open(), this._clientRpc.open(), this._shellRuntime?.open()]);
|
|
112
|
+
await Promise.all([this._clientServices.open(new Context()), this._clientRpc.open(), this._shellRuntime?.open()]);
|
|
112
113
|
this._ready.wake(undefined);
|
|
113
114
|
log('started');
|
|
114
115
|
} catch (err: any) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
6
|
import { Config } from '@dxos/config';
|
|
7
|
+
import { Context } from '@dxos/context';
|
|
7
8
|
import { log } from '@dxos/log';
|
|
8
9
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
|
|
9
10
|
import { WebRTCTransportProxyFactory } from '@dxos/network-manager';
|
|
@@ -57,12 +58,12 @@ export class WorkerRuntime {
|
|
|
57
58
|
transportFactory: this._transportFactory,
|
|
58
59
|
});
|
|
59
60
|
|
|
60
|
-
await this._clientServices.open();
|
|
61
|
+
await this._clientServices.open(new Context());
|
|
61
62
|
this._ready.wake(undefined);
|
|
62
63
|
log('started');
|
|
63
64
|
} catch (err: any) {
|
|
64
65
|
this._ready.wake(err);
|
|
65
|
-
log.catch(err);
|
|
66
|
+
log.catch('starting', err);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -73,6 +73,7 @@ export class WorkerSession {
|
|
|
73
73
|
port: appPort,
|
|
74
74
|
...middleware,
|
|
75
75
|
});
|
|
76
|
+
|
|
76
77
|
this._shellClientRpc = new ClientRpcServer({
|
|
77
78
|
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
78
79
|
port: shellPort,
|
|
@@ -102,7 +103,7 @@ export class WorkerSession {
|
|
|
102
103
|
},
|
|
103
104
|
},
|
|
104
105
|
port: systemPort,
|
|
105
|
-
timeout:
|
|
106
|
+
timeout: 1_000, // With low timeout heartbeat may fail if the tab's thread is saturated.
|
|
106
107
|
});
|
|
107
108
|
|
|
108
109
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
@@ -112,10 +113,14 @@ export class WorkerSession {
|
|
|
112
113
|
log.info('opening...');
|
|
113
114
|
await Promise.all([this._clientRpc.open(), this._iframeRpc.open(), this._maybeOpenShell()]);
|
|
114
115
|
|
|
116
|
+
// Wait until the worker's RPC service has started.
|
|
115
117
|
await this._startTrigger.wait({ timeout: PROXY_CONNECTION_TIMEOUT });
|
|
118
|
+
|
|
119
|
+
// TODO(burdon): Comment required.
|
|
116
120
|
if (this.lockKey) {
|
|
117
121
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
118
122
|
}
|
|
123
|
+
|
|
119
124
|
log.info('opened');
|
|
120
125
|
}
|
|
121
126
|
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DXOS_VERSION = "0.1.56-main.0e9f69e";
|