@dxos/client-services 0.1.25-next.3c6b542 → 0.1.26
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-WF53R6F7.mjs → chunk-R2FEBB66.mjs} +95 -325
- package/dist/lib/browser/chunk-R2FEBB66.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -11
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +3 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +111 -350
- 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 +110 -228
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +4 -11
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -6
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/index.d.ts +0 -2
- package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/services.d.ts +1 -9
- package/dist/types/src/packlets/vault/services.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +1 -2
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +1 -4
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +28 -29
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/identity/authenticator.ts +1 -1
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +1 -1
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +1 -1
- package/src/packlets/invitations/space-invitations-handler.test.ts +1 -1
- package/src/packlets/invitations/space-invitations-handler.ts +1 -1
- package/src/packlets/services/service-context.ts +2 -2
- package/src/packlets/services/service-host.ts +1 -1
- package/src/packlets/spaces/data-space-manager.test.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +4 -4
- package/src/packlets/spaces/data-space.ts +3 -3
- package/src/packlets/spaces/spaces-service.ts +1 -1
- package/src/packlets/testing/test-builder.ts +3 -3
- package/src/packlets/vault/iframe-host-runtime.ts +7 -26
- package/src/packlets/vault/iframe-proxy-runtime.ts +1 -16
- package/src/packlets/vault/index.ts +0 -2
- package/src/packlets/vault/services.ts +1 -17
- package/src/packlets/vault/worker-runtime.ts +1 -3
- package/src/packlets/vault/worker-session.ts +19 -29
- package/dist/lib/browser/chunk-WF53R6F7.mjs.map +0 -7
- package/dist/types/src/packlets/vault/shell-controller.d.ts +0 -24
- package/dist/types/src/packlets/vault/shell-controller.d.ts.map +0 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +0 -45
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +0 -1
- package/src/packlets/vault/shell-controller.ts +0 -78
- package/src/packlets/vault/shell-runtime.ts +0 -133
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { Config } from '@dxos/config';
|
|
6
6
|
import { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';
|
|
7
7
|
import {
|
|
8
|
-
SnapshotStore,
|
|
9
8
|
DataPipelineControllerImpl,
|
|
10
9
|
MetadataStore,
|
|
11
10
|
SigningContext,
|
|
11
|
+
SnapshotStore,
|
|
12
12
|
SpaceManager,
|
|
13
13
|
valueEncoding
|
|
14
|
-
} from '@dxos/echo-
|
|
15
|
-
import { testLocalDatabase } from '@dxos/echo-
|
|
14
|
+
} from '@dxos/echo-db';
|
|
15
|
+
import { testLocalDatabase } from '@dxos/echo-db/testing';
|
|
16
16
|
import { FeedFactory, FeedStore } from '@dxos/feed-store';
|
|
17
17
|
import { Keyring } from '@dxos/keyring';
|
|
18
18
|
import { MemorySignalManager, MemorySignalManagerContext } from '@dxos/messaging';
|
|
@@ -8,17 +8,15 @@ import { log, logInfo } from '@dxos/log';
|
|
|
8
8
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
|
|
9
9
|
import { createWebRTCTransportFactory, NetworkManager } from '@dxos/network-manager';
|
|
10
10
|
import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
|
|
11
|
-
import {
|
|
11
|
+
import { MaybePromise } from '@dxos/util';
|
|
12
12
|
|
|
13
13
|
import { clientServiceBundle, ClientServices, ClientServicesHost } from '../services';
|
|
14
|
-
import { ShellRuntime, ShellRuntimeImpl } from './shell-runtime';
|
|
15
14
|
|
|
16
15
|
const LOCK_KEY = 'DXOS_RESOURCE_LOCK';
|
|
17
16
|
|
|
18
17
|
export type IFrameHostRuntimeParams = {
|
|
19
|
-
configProvider:
|
|
18
|
+
configProvider: () => MaybePromise<Config>;
|
|
20
19
|
appPort: RpcPort;
|
|
21
|
-
shellPort?: RpcPort;
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
/**
|
|
@@ -28,7 +26,7 @@ export type IFrameHostRuntimeParams = {
|
|
|
28
26
|
* This should only be used when SharedWorker is not available.
|
|
29
27
|
*/
|
|
30
28
|
export class IFrameHostRuntime {
|
|
31
|
-
private readonly _configProvider:
|
|
29
|
+
private readonly _configProvider: () => MaybePromise<Config>;
|
|
32
30
|
private readonly _transportFactory = createWebRTCTransportFactory();
|
|
33
31
|
private readonly _ready = new Trigger<Error | undefined>();
|
|
34
32
|
private readonly _getService: <Service>(
|
|
@@ -36,20 +34,16 @@ export class IFrameHostRuntime {
|
|
|
36
34
|
) => Promise<Service>;
|
|
37
35
|
|
|
38
36
|
private readonly _appPort: RpcPort;
|
|
39
|
-
private readonly _shellPort?: RpcPort;
|
|
40
|
-
private _config!: Config;
|
|
41
37
|
private _clientServices!: ClientServicesHost;
|
|
42
38
|
private _clientRpc!: ProtoRpcPeer<ClientServices>;
|
|
43
|
-
private
|
|
39
|
+
private _config!: Config;
|
|
44
40
|
|
|
45
41
|
@logInfo
|
|
46
42
|
public origin?: string;
|
|
47
43
|
|
|
48
|
-
constructor({ configProvider, appPort
|
|
44
|
+
constructor({ configProvider, appPort }: IFrameHostRuntimeParams) {
|
|
49
45
|
this._configProvider = configProvider;
|
|
50
46
|
this._appPort = appPort;
|
|
51
|
-
this._shellPort = shellPort;
|
|
52
|
-
|
|
53
47
|
this._getService = async (find) => {
|
|
54
48
|
const error = await this._ready.wait();
|
|
55
49
|
if (error) {
|
|
@@ -63,24 +57,12 @@ export class IFrameHostRuntime {
|
|
|
63
57
|
|
|
64
58
|
return service;
|
|
65
59
|
};
|
|
66
|
-
|
|
67
|
-
if (this._shellPort) {
|
|
68
|
-
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get services() {
|
|
73
|
-
return this._clientServices;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get shell(): ShellRuntime | undefined {
|
|
77
|
-
return this._shellRuntime;
|
|
78
60
|
}
|
|
79
61
|
|
|
80
62
|
async start() {
|
|
81
63
|
log('starting...');
|
|
82
64
|
try {
|
|
83
|
-
this._config = await
|
|
65
|
+
this._config = await this._configProvider();
|
|
84
66
|
const signalServer = this._config.get('runtime.services.signal.server');
|
|
85
67
|
this._clientServices = new ClientServicesHost({
|
|
86
68
|
lockKey: LOCK_KEY,
|
|
@@ -112,7 +94,7 @@ export class IFrameHostRuntime {
|
|
|
112
94
|
port: this._appPort
|
|
113
95
|
});
|
|
114
96
|
|
|
115
|
-
await Promise.all([this._clientServices.open(), this._clientRpc.open()
|
|
97
|
+
await Promise.all([this._clientServices.open(), this._clientRpc.open()]);
|
|
116
98
|
this._ready.wake(undefined);
|
|
117
99
|
log('started');
|
|
118
100
|
} catch (err: any) {
|
|
@@ -125,7 +107,6 @@ export class IFrameHostRuntime {
|
|
|
125
107
|
log('stopping...');
|
|
126
108
|
await this._clientRpc.close();
|
|
127
109
|
await this._clientServices.close();
|
|
128
|
-
await this._shellRuntime?.close();
|
|
129
110
|
log('stopped');
|
|
130
111
|
}
|
|
131
112
|
}
|
|
@@ -7,14 +7,12 @@ import { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
|
7
7
|
import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
|
|
8
8
|
|
|
9
9
|
import { iframeServiceBundle, WorkerServiceBundle, workerServiceBundle } from './services';
|
|
10
|
-
import { ShellRuntime, ShellRuntimeImpl } from './shell-runtime';
|
|
11
10
|
|
|
12
11
|
// NOTE: Keep as RpcPorts to avoid dependency on @dxos/rpc-tunnel so we don't depend on browser-specific apis.
|
|
13
12
|
export type IFrameProxyRuntimeParams = {
|
|
14
13
|
systemPort: RpcPort;
|
|
15
14
|
workerAppPort: RpcPort;
|
|
16
15
|
windowAppPort: RpcPort;
|
|
17
|
-
shellPort?: RpcPort;
|
|
18
16
|
};
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -24,16 +22,13 @@ export class IFrameProxyRuntime {
|
|
|
24
22
|
private readonly _systemPort: RpcPort;
|
|
25
23
|
private readonly _windowAppPort: RpcPort;
|
|
26
24
|
private readonly _workerAppPort: RpcPort;
|
|
27
|
-
private readonly _shellPort?: RpcPort;
|
|
28
25
|
private readonly _systemRpc: ProtoRpcPeer<WorkerServiceBundle>;
|
|
29
|
-
private readonly _shellRuntime?: ShellRuntimeImpl;
|
|
30
26
|
private readonly _transportService = new WebRTCTransportService();
|
|
31
27
|
|
|
32
|
-
constructor({ systemPort, workerAppPort, windowAppPort
|
|
28
|
+
constructor({ systemPort, workerAppPort, windowAppPort }: IFrameProxyRuntimeParams) {
|
|
33
29
|
this._systemPort = systemPort;
|
|
34
30
|
this._windowAppPort = windowAppPort;
|
|
35
31
|
this._workerAppPort = workerAppPort;
|
|
36
|
-
this._shellPort = shellPort;
|
|
37
32
|
|
|
38
33
|
this._systemRpc = createProtoRpcPeer({
|
|
39
34
|
requested: workerServiceBundle,
|
|
@@ -52,24 +47,14 @@ export class IFrameProxyRuntime {
|
|
|
52
47
|
|
|
53
48
|
this._workerAppPort.subscribe((msg) => this._windowAppPort.send(msg));
|
|
54
49
|
this._windowAppPort.subscribe((msg) => this._workerAppPort.send(msg));
|
|
55
|
-
|
|
56
|
-
if (this._shellPort) {
|
|
57
|
-
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get shell(): ShellRuntime | undefined {
|
|
62
|
-
return this._shellRuntime;
|
|
63
50
|
}
|
|
64
51
|
|
|
65
52
|
async open(origin: string) {
|
|
66
53
|
await this._systemRpc.open();
|
|
67
54
|
await this._systemRpc.rpc.WorkerService.start({ origin });
|
|
68
|
-
await this._shellRuntime?.open();
|
|
69
55
|
}
|
|
70
56
|
|
|
71
57
|
async close() {
|
|
72
|
-
await this._shellRuntime?.close();
|
|
73
58
|
await this._systemRpc.rpc.WorkerService.stop();
|
|
74
59
|
await this._systemRpc.close();
|
|
75
60
|
}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
export * from './iframe-host-runtime';
|
|
6
6
|
export * from './iframe-proxy-runtime';
|
|
7
7
|
export * from './services';
|
|
8
|
-
export * from './shell-controller';
|
|
9
|
-
export * from './shell-runtime';
|
|
10
8
|
export * from './vault-resource-lock';
|
|
11
9
|
export * from './worker-runtime';
|
|
12
10
|
export * from './worker-session';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { schema } from '@dxos/protocols';
|
|
6
|
-
import type { IframeService,
|
|
6
|
+
import type { IframeService, WorkerService } from '@dxos/protocols/proto/dxos/iframe';
|
|
7
7
|
import type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
8
8
|
import { ServiceBundle } from '@dxos/rpc';
|
|
9
9
|
|
|
@@ -24,19 +24,3 @@ export type WorkerServiceBundle = {
|
|
|
24
24
|
export const workerServiceBundle: ServiceBundle<WorkerServiceBundle> = {
|
|
25
25
|
WorkerService: schema.getService('dxos.iframe.WorkerService')
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
export type AppServiceBundle = {
|
|
29
|
-
AppService: AppService;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const appServiceBundle: ServiceBundle<AppServiceBundle> = {
|
|
33
|
-
AppService: schema.getService('dxos.iframe.AppService')
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type ShellServiceBundle = {
|
|
37
|
-
ShellService: ShellService;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const shellServiceBundle: ServiceBundle<ShellServiceBundle> = {
|
|
41
|
-
ShellService: schema.getService('dxos.iframe.ShellService')
|
|
42
|
-
};
|
|
@@ -17,7 +17,6 @@ import { WorkerSession } from './worker-session';
|
|
|
17
17
|
export type CreateSessionParams = {
|
|
18
18
|
appPort: RpcPort;
|
|
19
19
|
systemPort: RpcPort;
|
|
20
|
-
shellPort: RpcPort;
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
/**
|
|
@@ -71,7 +70,7 @@ export class WorkerRuntime {
|
|
|
71
70
|
/**
|
|
72
71
|
* Create a new session.
|
|
73
72
|
*/
|
|
74
|
-
async createSession({ appPort, systemPort
|
|
73
|
+
async createSession({ appPort, systemPort }: CreateSessionParams) {
|
|
75
74
|
const session = new WorkerSession({
|
|
76
75
|
getService: async (find) => {
|
|
77
76
|
const error = await this._ready.wait();
|
|
@@ -88,7 +87,6 @@ export class WorkerRuntime {
|
|
|
88
87
|
},
|
|
89
88
|
appPort,
|
|
90
89
|
systemPort,
|
|
91
|
-
shellPort,
|
|
92
90
|
readySignal: this._ready
|
|
93
91
|
});
|
|
94
92
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import assert from 'node:assert';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { log, logInfo } from '@dxos/log';
|
|
9
9
|
import { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
10
10
|
import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
|
|
@@ -17,7 +17,6 @@ export type WorkerSessionParams = {
|
|
|
17
17
|
getService: <Service>(find: (services: Partial<ClientServices>) => Service | undefined) => Promise<Service>;
|
|
18
18
|
systemPort: RpcPort;
|
|
19
19
|
appPort: RpcPort;
|
|
20
|
-
shellPort: RpcPort;
|
|
21
20
|
readySignal: Trigger<Error | undefined>;
|
|
22
21
|
options?: {
|
|
23
22
|
heartbeatInterval: number;
|
|
@@ -29,7 +28,6 @@ export type WorkerSessionParams = {
|
|
|
29
28
|
*/
|
|
30
29
|
export class WorkerSession {
|
|
31
30
|
private readonly _clientRpc: ProtoRpcPeer<ClientServices>;
|
|
32
|
-
private readonly _shellClientRpc: ProtoRpcPeer<ClientServices>;
|
|
33
31
|
private readonly _iframeRpc: ProtoRpcPeer<IframeServiceBundle>;
|
|
34
32
|
private readonly _startTrigger = new Trigger();
|
|
35
33
|
private readonly _getService: WorkerSessionParams['getService'];
|
|
@@ -47,7 +45,6 @@ export class WorkerSession {
|
|
|
47
45
|
getService,
|
|
48
46
|
systemPort,
|
|
49
47
|
appPort,
|
|
50
|
-
shellPort,
|
|
51
48
|
options = {
|
|
52
49
|
heartbeatInterval: 1_000
|
|
53
50
|
}
|
|
@@ -57,22 +54,23 @@ export class WorkerSession {
|
|
|
57
54
|
this._options = options;
|
|
58
55
|
this._getService = getService;
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
this._clientRpc = createProtoRpcPeer({
|
|
58
|
+
exposed: clientServiceBundle,
|
|
59
|
+
handlers: {
|
|
60
|
+
DataService: async () => await this._getService((services) => services.DataService),
|
|
61
|
+
DevicesService: async () => await this._getService((services) => services.DevicesService),
|
|
62
|
+
DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
|
|
63
|
+
HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
|
|
64
|
+
NetworkService: async () => await this._getService((services) => services.NetworkService),
|
|
65
|
+
ProfileService: async () => await this._getService((services) => services.ProfileService),
|
|
66
|
+
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
67
|
+
SpaceService: async () => await this._getService((services) => services.SpaceService),
|
|
68
|
+
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
69
|
+
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
70
|
+
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
71
|
+
},
|
|
72
|
+
port: appPort
|
|
73
|
+
});
|
|
76
74
|
|
|
77
75
|
this._iframeRpc = createProtoRpcPeer({
|
|
78
76
|
requested: iframeServiceBundle,
|
|
@@ -104,7 +102,7 @@ export class WorkerSession {
|
|
|
104
102
|
|
|
105
103
|
async open() {
|
|
106
104
|
log.info('opening..');
|
|
107
|
-
await Promise.all([this._clientRpc.open(), this._iframeRpc.open()
|
|
105
|
+
await Promise.all([this._clientRpc.open(), this._iframeRpc.open()]);
|
|
108
106
|
|
|
109
107
|
await this._startTrigger.wait({ timeout: 3_000 });
|
|
110
108
|
|
|
@@ -139,12 +137,4 @@ export class WorkerSession {
|
|
|
139
137
|
|
|
140
138
|
await Promise.all([this._clientRpc.close(), this._iframeRpc.close()]);
|
|
141
139
|
}
|
|
142
|
-
|
|
143
|
-
private async _maybeOpenShell() {
|
|
144
|
-
try {
|
|
145
|
-
await asyncTimeout(this._shellClientRpc.open(), 1_000);
|
|
146
|
-
} catch {
|
|
147
|
-
log.info('No shell connected.');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
140
|
}
|