@dxos/client-services 0.1.52 → 0.1.53-main.00be1a9
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-C3SPTMW3.mjs → chunk-RKD47ENR.mjs} +678 -638
- package/dist/lib/browser/chunk-RKD47ENR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +94 -119
- 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 +6 -6
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +739 -726
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +650 -612
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.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.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- 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 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/packlets/devtools/devtools.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +2 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/logging/logging-service.ts +4 -4
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +19 -10
- package/src/packlets/spaces/data-space-manager.ts +5 -6
- package/src/packlets/spaces/notarization-plugin.ts +4 -4
- package/src/packlets/spaces/spaces-service.ts +20 -24
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +1 -2
- package/src/packlets/vault/iframe-host-runtime.ts +2 -2
- package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
- package/src/packlets/vault/shell-runtime.ts +3 -49
- package/src/packlets/vault/worker-session.ts +2 -2
- package/dist/lib/browser/chunk-C3SPTMW3.mjs.map +0 -7
|
@@ -33,7 +33,7 @@ export class LoggingServiceImpl implements LoggingService {
|
|
|
33
33
|
|
|
34
34
|
// Prevent logging feedback loop from logging service.
|
|
35
35
|
if (
|
|
36
|
-
entry.meta?.
|
|
36
|
+
entry.meta?.F.includes('logging-service') ||
|
|
37
37
|
(entry.context &&
|
|
38
38
|
Object.values(entry.context).some((value) => typeof value === 'string' && value.includes('LoggingService')))
|
|
39
39
|
) {
|
|
@@ -50,8 +50,8 @@ export class LoggingServiceImpl implements LoggingService {
|
|
|
50
50
|
timestamp: new Date(),
|
|
51
51
|
meta: {
|
|
52
52
|
// TODO(dmaretskyi): Fix proto.
|
|
53
|
-
file: entry.meta?.
|
|
54
|
-
line: entry.meta?.
|
|
53
|
+
file: entry.meta?.F ?? '',
|
|
54
|
+
line: entry.meta?.L ?? 0,
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -94,7 +94,7 @@ const shouldLog = (entry: NaturalLogEntry, request: QueryLogsRequest): boolean =
|
|
|
94
94
|
if (request.filters === undefined) {
|
|
95
95
|
return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
96
96
|
} else {
|
|
97
|
-
return request.filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.
|
|
97
|
+
return request.filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? '', options));
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
|
|
@@ -36,7 +36,7 @@ describe('services/ServiceContext', () => {
|
|
|
36
36
|
await device2.dataSpaceManager!.waitUntilSpaceReady(space1!.key);
|
|
37
37
|
const space2 = await device2.dataSpaceManager!.spaces.get(space1.key);
|
|
38
38
|
await syncItemsLocal(space1.dataPipeline, space2!.dataPipeline);
|
|
39
|
-
});
|
|
39
|
+
}).tag('flaky');
|
|
40
40
|
|
|
41
41
|
test('joined space is synchronized on device invitations', async () => {
|
|
42
42
|
const networkContext = new MemorySignalManagerContext();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { CredentialConsumer, getCredentialAssertion } from '@dxos/credentials';
|
|
@@ -161,7 +161,7 @@ export class ServiceContext {
|
|
|
161
161
|
|
|
162
162
|
getInvitationHandler(invitation: Partial<Invitation> & Pick<Invitation, 'kind'>): InvitationProtocol {
|
|
163
163
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
164
|
-
|
|
164
|
+
invariant(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
165
165
|
return factory(invitation);
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -205,7 +205,7 @@ export class ServiceContext {
|
|
|
205
205
|
await this.dataSpaceManager.open();
|
|
206
206
|
|
|
207
207
|
this._handlerFactories.set(Invitation.Kind.SPACE, (invitation) => {
|
|
208
|
-
|
|
208
|
+
invariant(this.dataSpaceManager, 'dataSpaceManager not initialized yet');
|
|
209
209
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
210
210
|
});
|
|
211
211
|
this.initialized.wake();
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
|
-
import { Event } from '@dxos/async';
|
|
8
|
-
import { clientServiceBundle, ClientServices
|
|
7
|
+
import { Event, synchronized } from '@dxos/async';
|
|
8
|
+
import { clientServiceBundle, ClientServices } from '@dxos/client-protocol';
|
|
9
9
|
import { Config } from '@dxos/config';
|
|
10
|
+
import { DocumentModel } from '@dxos/document-model';
|
|
10
11
|
import { DataServiceImpl } from '@dxos/echo-pipeline';
|
|
11
12
|
import { PublicKey } from '@dxos/keys';
|
|
12
13
|
import { log } from '@dxos/log';
|
|
@@ -16,6 +17,7 @@ import { createWebRTCTransportFactory, NetworkManager, TransportFactory } from '
|
|
|
16
17
|
import { trace } from '@dxos/protocols';
|
|
17
18
|
import { SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
18
19
|
import { Storage } from '@dxos/random-access-storage';
|
|
20
|
+
import { TextModel } from '@dxos/text-model';
|
|
19
21
|
|
|
20
22
|
import { DevicesServiceImpl } from '../devices';
|
|
21
23
|
import { DevtoolsServiceImpl, DevtoolsHostEvents } from '../devtools';
|
|
@@ -30,6 +32,11 @@ import { SystemServiceImpl } from '../system';
|
|
|
30
32
|
import { ServiceContext } from './service-context';
|
|
31
33
|
import { ServiceRegistry } from './service-registry';
|
|
32
34
|
|
|
35
|
+
// TODO(burdon): Factor out to spaces.
|
|
36
|
+
export const createDefaultModelFactory = () => {
|
|
37
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
38
|
+
};
|
|
39
|
+
|
|
33
40
|
export type ClientServicesHostParams = {
|
|
34
41
|
/**
|
|
35
42
|
* Can be omitted if `initialize` is later called.
|
|
@@ -150,10 +157,10 @@ export class ClientServicesHost {
|
|
|
150
157
|
* Can only be called once.
|
|
151
158
|
*/
|
|
152
159
|
initialize({ config, ...options }: InitializeOptions) {
|
|
153
|
-
|
|
160
|
+
invariant(!this._open, 'service host is open');
|
|
154
161
|
|
|
155
162
|
if (config) {
|
|
156
|
-
|
|
163
|
+
invariant(!this._config, 'config already set');
|
|
157
164
|
|
|
158
165
|
this._config = config;
|
|
159
166
|
if (!this._storage) {
|
|
@@ -170,7 +177,7 @@ export class ClientServicesHost {
|
|
|
170
177
|
} = options;
|
|
171
178
|
this._signalManager = signalManager;
|
|
172
179
|
|
|
173
|
-
|
|
180
|
+
invariant(!this._networkManager, 'network manager already set');
|
|
174
181
|
this._networkManager = new NetworkManager({
|
|
175
182
|
log: connectionLog,
|
|
176
183
|
transportFactory,
|
|
@@ -178,6 +185,7 @@ export class ClientServicesHost {
|
|
|
178
185
|
});
|
|
179
186
|
}
|
|
180
187
|
|
|
188
|
+
@synchronized
|
|
181
189
|
async open() {
|
|
182
190
|
if (this._open) {
|
|
183
191
|
return;
|
|
@@ -186,10 +194,10 @@ export class ClientServicesHost {
|
|
|
186
194
|
const traceId = PublicKey.random().toHex();
|
|
187
195
|
log.trace('dxos.sdk.client-services-host.open', trace.begin({ id: traceId }));
|
|
188
196
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
invariant(this._config, 'config not set');
|
|
198
|
+
invariant(this._storage, 'storage not set');
|
|
199
|
+
invariant(this._signalManager, 'signal manager not set');
|
|
200
|
+
invariant(this._networkManager, 'network manager not set');
|
|
193
201
|
|
|
194
202
|
this._opening = true;
|
|
195
203
|
log('opening...', { lockKey: this._resourceLock?.lockKey });
|
|
@@ -251,6 +259,7 @@ export class ClientServicesHost {
|
|
|
251
259
|
log.trace('dxos.sdk.client-services-host.open', trace.end({ id: traceId }));
|
|
252
260
|
}
|
|
253
261
|
|
|
262
|
+
@synchronized
|
|
254
263
|
async close() {
|
|
255
264
|
if (!this._open) {
|
|
256
265
|
return;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
7
|
import { Event, synchronized, trackLeaks } from '@dxos/async';
|
|
8
8
|
import { cancelWithContext, Context } from '@dxos/context';
|
|
@@ -112,7 +112,7 @@ export class DataSpaceManager {
|
|
|
112
112
|
*/
|
|
113
113
|
@synchronized
|
|
114
114
|
async createSpace() {
|
|
115
|
-
|
|
115
|
+
invariant(this._isOpen, 'Not open.');
|
|
116
116
|
const spaceKey = await this._keyring.createKey();
|
|
117
117
|
const controlFeedKey = await this._keyring.createKey();
|
|
118
118
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -130,7 +130,7 @@ export class DataSpaceManager {
|
|
|
130
130
|
await this._metadataStore.addSpace(metadata);
|
|
131
131
|
|
|
132
132
|
const memberCredential = credentials[1];
|
|
133
|
-
|
|
133
|
+
invariant(getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember');
|
|
134
134
|
await this._signingContext.recordCredential(memberCredential);
|
|
135
135
|
|
|
136
136
|
await space.initializeDataPipeline();
|
|
@@ -143,8 +143,8 @@ export class DataSpaceManager {
|
|
|
143
143
|
@synchronized
|
|
144
144
|
async acceptSpace(opts: AcceptSpaceOptions): Promise<DataSpace> {
|
|
145
145
|
log('accept space', { opts });
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
invariant(this._isOpen, 'Not open.');
|
|
147
|
+
invariant(!this._spaces.has(opts.spaceKey), 'Space already exists.');
|
|
148
148
|
|
|
149
149
|
const metadata: SpaceMetadata = {
|
|
150
150
|
key: opts.spaceKey,
|
|
@@ -155,7 +155,6 @@ export class DataSpaceManager {
|
|
|
155
155
|
|
|
156
156
|
const space = await this._constructSpace(metadata);
|
|
157
157
|
await this._metadataStore.addSpace(metadata);
|
|
158
|
-
|
|
159
158
|
space.initializeDataPipelineAsync();
|
|
160
159
|
|
|
161
160
|
this.updated.emit();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
7
|
import { DeferredTask, Event, scheduleTask, sleep, TimeoutError, Trigger } from '@dxos/async';
|
|
8
8
|
import { Context, rejectOnDispose } from '@dxos/context';
|
|
@@ -85,7 +85,7 @@ export class NotarizationPlugin implements CredentialProcessor {
|
|
|
85
85
|
successDelay = DEFAULT_SUCCESS_DELAY,
|
|
86
86
|
}: NotarizeParams) {
|
|
87
87
|
log('notarize', { credentials });
|
|
88
|
-
|
|
88
|
+
invariant(
|
|
89
89
|
credentials.every((credential) => credential.id),
|
|
90
90
|
'Credentials must have an id',
|
|
91
91
|
);
|
|
@@ -175,7 +175,7 @@ export class NotarizationPlugin implements CredentialProcessor {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
setWriter(writer: FeedWriter<Credential>) {
|
|
178
|
-
|
|
178
|
+
invariant(!this._writer, 'Writer already set.');
|
|
179
179
|
this._writer = writer;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -194,7 +194,7 @@ export class NotarizationPlugin implements CredentialProcessor {
|
|
|
194
194
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
195
195
|
}
|
|
196
196
|
for (const credential of request.credentials ?? []) {
|
|
197
|
-
|
|
197
|
+
invariant(credential.id, 'Credential must have an id');
|
|
198
198
|
if (this._processedCredentials.has(credential.id)) {
|
|
199
199
|
continue;
|
|
200
200
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { EventSubscriptions, scheduleTask } from '@dxos/async';
|
|
5
|
+
import { EventSubscriptions, UpdateScheduler, scheduleTask } from '@dxos/async';
|
|
6
6
|
import { Stream } from '@dxos/codec-protobuf';
|
|
7
7
|
import { raise, todo } from '@dxos/debug';
|
|
8
8
|
import { DataServiceSubscriptions, SpaceManager, SpaceNotFoundError } from '@dxos/echo-pipeline';
|
|
@@ -28,8 +28,6 @@ import { IdentityManager } from '../identity';
|
|
|
28
28
|
import { DataSpace } from './data-space';
|
|
29
29
|
import { DataSpaceManager } from './data-space-manager';
|
|
30
30
|
|
|
31
|
-
const TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
32
|
-
|
|
33
31
|
export class SpacesServiceImpl implements SpacesService {
|
|
34
32
|
constructor(
|
|
35
33
|
private readonly _identityManager: IdentityManager,
|
|
@@ -45,7 +43,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
45
43
|
|
|
46
44
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
47
45
|
const space = await dataSpaceManager.createSpace();
|
|
48
|
-
return this.
|
|
46
|
+
return this._serializeSpace(space);
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
async updateSpace(request: UpdateSpaceRequest) {
|
|
@@ -54,12 +52,16 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
54
52
|
|
|
55
53
|
querySpaces(): Stream<QuerySpacesResponse> {
|
|
56
54
|
return new Stream<QuerySpacesResponse>(({ next, ctx }) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
const scheduler = new UpdateScheduler(
|
|
56
|
+
ctx,
|
|
57
|
+
async () => {
|
|
58
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
59
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
60
|
+
log('update', { spaces });
|
|
61
|
+
next({ spaces });
|
|
62
|
+
},
|
|
63
|
+
{ maxFrequency: 2 },
|
|
64
|
+
);
|
|
63
65
|
|
|
64
66
|
scheduleTask(ctx, async () => {
|
|
65
67
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -72,31 +74,25 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
72
74
|
subscriptions.clear();
|
|
73
75
|
|
|
74
76
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
75
|
-
subscriptions.add(space.stateUpdate.on(ctx,
|
|
76
|
-
subscriptions.add(space.presence.updated.on(ctx,
|
|
77
|
-
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx,
|
|
77
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
|
|
78
|
+
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
79
|
+
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
78
80
|
|
|
79
81
|
// Pipeline progress.
|
|
80
|
-
space.inner.controlPipeline.state.timeframeUpdate
|
|
81
|
-
.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME)
|
|
82
|
-
.on(ctx, onUpdate);
|
|
82
|
+
space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
|
|
83
83
|
if (space.dataPipeline.pipelineState) {
|
|
84
|
-
subscriptions.add(
|
|
85
|
-
space.dataPipeline.pipelineState.timeframeUpdate
|
|
86
|
-
.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME)
|
|
87
|
-
.on(ctx, onUpdate),
|
|
88
|
-
);
|
|
84
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
};
|
|
92
88
|
|
|
93
89
|
dataSpaceManager.updated.on(ctx, () => {
|
|
94
90
|
subscribeSpaces();
|
|
95
|
-
|
|
91
|
+
scheduler.trigger();
|
|
96
92
|
});
|
|
97
93
|
subscribeSpaces();
|
|
98
94
|
|
|
99
|
-
|
|
95
|
+
scheduler.trigger();
|
|
100
96
|
});
|
|
101
97
|
|
|
102
98
|
if (!this._identityManager.identity) {
|
|
@@ -151,7 +147,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
151
147
|
await space.createEpoch();
|
|
152
148
|
}
|
|
153
149
|
|
|
154
|
-
private
|
|
150
|
+
private _serializeSpace(space: DataSpace): Space {
|
|
155
151
|
return {
|
|
156
152
|
spaceKey: space.key,
|
|
157
153
|
state: space.state,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { AuthenticatingInvitationObservable, CancellableInvitationObservable } from '@dxos/client-protocol';
|
|
@@ -82,7 +82,7 @@ export const performInvitation = ({
|
|
|
82
82
|
if (hooks?.guest?.onConnecting?.(guestObservable)) {
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
invariant(hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!));
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { createDefaultModelFactory } from '@dxos/client-protocol';
|
|
6
5
|
import { Config } from '@dxos/config';
|
|
7
6
|
import { Context } from '@dxos/context';
|
|
8
7
|
import { createCredentialSignerWithChain, CredentialGenerator } from '@dxos/credentials';
|
|
@@ -15,7 +14,7 @@ import { MemoryTransportFactory, NetworkManager } from '@dxos/network-manager';
|
|
|
15
14
|
import { createStorage, Storage, StorageType } from '@dxos/random-access-storage';
|
|
16
15
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
17
16
|
|
|
18
|
-
import { ClientServicesHost, ServiceContext } from '../services';
|
|
17
|
+
import { ClientServicesHost, createDefaultModelFactory, ServiceContext } from '../services';
|
|
19
18
|
import { SigningContext } from '../spaces';
|
|
20
19
|
|
|
21
20
|
//
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
|
-
import { PROXY_CONNECTION_TIMEOUT } from '@dxos/client-protocol';
|
|
6
|
+
import { PROXY_CONNECTION_TIMEOUT, ShellRuntime } from '@dxos/client-protocol';
|
|
7
7
|
import { Config } from '@dxos/config';
|
|
8
8
|
import { log, logInfo } from '@dxos/log';
|
|
9
9
|
import { MemorySignalManager, MemorySignalManagerContext, WebsocketSignalManager } from '@dxos/messaging';
|
|
@@ -13,7 +13,7 @@ import { getAsyncValue, MaybePromise, Provider } from '@dxos/util';
|
|
|
13
13
|
|
|
14
14
|
import { ClientServicesHost } from '../services';
|
|
15
15
|
import { ClientRpcServer, ClientRpcServerParams } from '../services/client-rpc-server';
|
|
16
|
-
import {
|
|
16
|
+
import { ShellRuntimeImpl } from './shell-runtime';
|
|
17
17
|
|
|
18
18
|
const LOCK_KEY = 'DXOS_RESOURCE_LOCK';
|
|
19
19
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
|
-
import { iframeServiceBundle, workerServiceBundle, WorkerServiceBundle } from '@dxos/client-protocol';
|
|
6
|
+
import { iframeServiceBundle, ShellRuntime, workerServiceBundle, WorkerServiceBundle } from '@dxos/client-protocol';
|
|
7
7
|
import { Config } from '@dxos/config';
|
|
8
8
|
import { RemoteServiceConnectionError } from '@dxos/errors';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
@@ -12,7 +12,7 @@ import { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
|
12
12
|
import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
|
|
13
13
|
import { getAsyncValue, MaybePromise, Provider } from '@dxos/util';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { ShellRuntimeImpl } from './shell-runtime';
|
|
16
16
|
|
|
17
17
|
// NOTE: Keep as RpcPorts to avoid dependency on @dxos/rpc-tunnel so we don't depend on browser-specific apis.
|
|
18
18
|
export type IFrameProxyRuntimeParams = {
|
|
@@ -2,23 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
|
-
import { appServiceBundle, AppServiceBundle, shellServiceBundle } from '@dxos/client-protocol';
|
|
8
|
+
import { appServiceBundle, AppServiceBundle, ShellRuntime, shellServiceBundle } from '@dxos/client-protocol';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { AppContextRequest, LayoutRequest, ShellLayout } from '@dxos/protocols/proto/dxos/iframe';
|
|
11
11
|
import { createProtoRpcPeer, ProtoRpcPeer, RpcPort } from '@dxos/rpc';
|
|
12
12
|
|
|
13
|
-
export interface ShellRuntime {
|
|
14
|
-
layoutUpdate: Event<LayoutRequest>;
|
|
15
|
-
layout: ShellLayout;
|
|
16
|
-
invitationCode?: string;
|
|
17
|
-
spaceKey?: PublicKey;
|
|
18
|
-
setLayout: (layout: ShellLayout, options?: Omit<LayoutRequest, 'layout'>) => void;
|
|
19
|
-
setAppContext: (context: AppContextRequest) => Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
13
|
/**
|
|
23
14
|
* Endpoint that handles shell services.
|
|
24
15
|
*/
|
|
@@ -51,7 +42,7 @@ export class ShellRuntimeImpl implements ShellRuntime {
|
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
async setAppContext(context: AppContextRequest) {
|
|
54
|
-
|
|
45
|
+
invariant(this._appRpc, 'runtime not open');
|
|
55
46
|
|
|
56
47
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
57
48
|
}
|
|
@@ -81,40 +72,3 @@ export class ShellRuntimeImpl implements ShellRuntime {
|
|
|
81
72
|
this._appRpc = undefined;
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
|
-
|
|
85
|
-
export class MemoryShellRuntime implements ShellRuntime {
|
|
86
|
-
readonly layoutUpdate = new Event<LayoutRequest>();
|
|
87
|
-
readonly contextUpdate = new Event<AppContextRequest>();
|
|
88
|
-
private _layout: ShellLayout;
|
|
89
|
-
private _invitationCode?: string;
|
|
90
|
-
private _spaceKey?: PublicKey;
|
|
91
|
-
|
|
92
|
-
constructor({ layout, invitationCode, spaceKey }: Partial<LayoutRequest> & Partial<AppContextRequest> = {}) {
|
|
93
|
-
this._layout = layout ?? ShellLayout.DEFAULT;
|
|
94
|
-
this._invitationCode = invitationCode;
|
|
95
|
-
this._spaceKey = spaceKey;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get layout() {
|
|
99
|
-
return this._layout;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
get invitationCode() {
|
|
103
|
-
return this._invitationCode;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
get spaceKey() {
|
|
107
|
-
return this._spaceKey;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
setLayout(layout: ShellLayout, options: Omit<LayoutRequest, 'layout'> = {}) {
|
|
111
|
-
this._layout = layout;
|
|
112
|
-
this._invitationCode = options.invitationCode;
|
|
113
|
-
this._spaceKey = options.spaceKey;
|
|
114
|
-
this.layoutUpdate.emit({ layout, ...options });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async setAppContext(context: AppContextRequest) {
|
|
118
|
-
this.contextUpdate.emit(context);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
6
|
|
|
7
7
|
import { asyncTimeout, Trigger } from '@dxos/async';
|
|
8
8
|
import {
|
|
@@ -48,7 +48,7 @@ export class WorkerSession {
|
|
|
48
48
|
public bridgeService?: BridgeService;
|
|
49
49
|
|
|
50
50
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }: WorkerSessionParams) {
|
|
51
|
-
|
|
51
|
+
invariant(serviceHost);
|
|
52
52
|
this._serviceHost = serviceHost;
|
|
53
53
|
|
|
54
54
|
const middleware: Pick<ClientRpcServerParams, 'handleCall' | 'handleStream'> = {
|