@dxos/client-services 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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-J33W6T4Q.mjs → chunk-5A3KX2RY.mjs} +1745 -1208
- package/dist/lib/browser/chunk-5A3KX2RY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +33 -16
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -7
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-34HKLADW.mjs → chunk-FNPO5UMU.mjs} +1745 -1208
- package/dist/lib/node-esm/chunk-FNPO5UMU.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +33 -16
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +14 -7
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +3 -2
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +5 -4
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -6
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +6 -9
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +3 -3
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -4
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -1
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +6 -0
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts +2 -0
- package/dist/types/src/packlets/space-export/space-archive.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +17 -10
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +22 -6
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts +2 -1
- package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/worker/worker-runtime.d.ts +11 -3
- package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -43
- package/src/index.ts +1 -0
- package/src/packlets/agents/edge-agent-manager.ts +8 -5
- package/src/packlets/agents/edge-agent-service.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +5 -5
- package/src/packlets/identity/identity-manager.ts +16 -13
- package/src/packlets/identity/identity-recovery-manager.ts +20 -16
- package/src/packlets/identity/identity-service.test.ts +6 -26
- package/src/packlets/identity/identity-service.ts +5 -76
- package/src/packlets/identity/identity.test.ts +2 -2
- package/src/packlets/identity/identity.ts +7 -29
- package/src/packlets/invitations/edge-invitation-handler.ts +4 -3
- package/src/packlets/invitations/invitations-handler.test.ts +4 -4
- package/src/packlets/invitations/invitations-handler.ts +3 -3
- package/src/packlets/invitations/invitations-manager.ts +37 -14
- package/src/packlets/invitations/invitations-service.ts +4 -4
- package/src/packlets/invitations/space-invitation-protocol.test.ts +17 -16
- package/src/packlets/invitations/space-invitation-protocol.ts +3 -1
- package/src/packlets/logging/logging-service.ts +4 -0
- package/src/packlets/network/network-service.ts +5 -4
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +337 -0
- package/src/packlets/services/platform.ts +7 -1
- package/src/packlets/services/service-context.test.ts +3 -2
- package/src/packlets/services/service-context.ts +106 -31
- package/src/packlets/services/service-host.test.ts +8 -7
- package/src/packlets/services/service-host.ts +9 -7
- package/src/packlets/space-export/space-archive-reader.ts +64 -3
- package/src/packlets/space-export/space-archive-writer.ts +36 -1
- package/src/packlets/space-export/space-archive.test.ts +287 -0
- package/src/packlets/spaces/data-space-manager.test.ts +79 -13
- package/src/packlets/spaces/data-space-manager.ts +71 -103
- package/src/packlets/spaces/data-space.ts +46 -23
- package/src/packlets/spaces/edge-feed-replicator.test.ts +1 -1
- package/src/packlets/spaces/edge-feed-replicator.ts +8 -7
- package/src/packlets/spaces/epoch-migrations.ts +3 -3
- package/src/packlets/spaces/genesis.ts +6 -1
- package/src/packlets/spaces/notarization-plugin.ts +2 -1
- package/src/packlets/spaces/spaces-service.test.ts +9 -6
- package/src/packlets/spaces/spaces-service.ts +30 -8
- package/src/packlets/testing/invitation-utils.ts +3 -2
- package/src/packlets/worker/worker-runtime.ts +14 -6
- package/src/packlets/worker/worker-session.ts +4 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-J33W6T4Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-34HKLADW.mjs.map +0 -7
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +0 -19
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +0 -1
- package/src/packlets/identity/default-space-state-machine.ts +0 -44
|
@@ -37,7 +37,7 @@ export const runEpochMigration = async (ctx: Context, context: MigrationContext)
|
|
|
37
37
|
switch (context.migration) {
|
|
38
38
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
39
39
|
const document = await context.echoHost.createDoc();
|
|
40
|
-
await context.echoHost.flush();
|
|
40
|
+
await context.echoHost.flush(ctx);
|
|
41
41
|
return { newRoot: document.url };
|
|
42
42
|
}
|
|
43
43
|
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
@@ -49,7 +49,7 @@ export const runEpochMigration = async (ctx: Context, context: MigrationContext)
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
const newRoot = await context.echoHost.createDoc(rootHandle.doc());
|
|
52
|
-
await context.echoHost.flush();
|
|
52
|
+
await context.echoHost.flush(ctx);
|
|
53
53
|
return { newRoot: newRoot.url };
|
|
54
54
|
}
|
|
55
55
|
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
@@ -63,7 +63,7 @@ export const runEpochMigration = async (ctx: Context, context: MigrationContext)
|
|
|
63
63
|
invariant(context.newAutomergeRoot);
|
|
64
64
|
|
|
65
65
|
// Defensive programming - it should be the responsibility of the caller to flush the new root.
|
|
66
|
-
await context.echoHost.flush();
|
|
66
|
+
await context.echoHost.flush(ctx);
|
|
67
67
|
return {
|
|
68
68
|
newRoot: context.newAutomergeRoot,
|
|
69
69
|
};
|
|
@@ -6,7 +6,7 @@ import { createCredential } from '@dxos/credentials';
|
|
|
6
6
|
import { failUndefined } from '@dxos/debug';
|
|
7
7
|
import { type Space } from '@dxos/echo-pipeline';
|
|
8
8
|
import { type Keyring } from '@dxos/keyring';
|
|
9
|
-
import { AdmittedFeed, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
9
|
+
import { AdmittedFeed, MembershipPolicy, SpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
10
10
|
import { Timeframe } from '@dxos/timeframe';
|
|
11
11
|
|
|
12
12
|
import { type SigningContext } from './data-space-manager';
|
|
@@ -16,6 +16,8 @@ export const spaceGenesis = async (
|
|
|
16
16
|
signingContext: SigningContext,
|
|
17
17
|
space: Space,
|
|
18
18
|
automergeRoot?: string,
|
|
19
|
+
tags?: string[],
|
|
20
|
+
membershipPolicy?: MembershipPolicy,
|
|
19
21
|
) => {
|
|
20
22
|
// TODO(dmaretskyi): Find a way to reconcile with credential generator.
|
|
21
23
|
const credentials = [
|
|
@@ -26,6 +28,8 @@ export const spaceGenesis = async (
|
|
|
26
28
|
assertion: {
|
|
27
29
|
'@type': 'dxos.halo.credentials.SpaceGenesis',
|
|
28
30
|
spaceKey: space.key,
|
|
31
|
+
tags: tags ?? [],
|
|
32
|
+
membershipPolicy: membershipPolicy ?? MembershipPolicy.INVITE,
|
|
29
33
|
},
|
|
30
34
|
}),
|
|
31
35
|
|
|
@@ -39,6 +43,7 @@ export const spaceGenesis = async (
|
|
|
39
43
|
role: SpaceMember.Role.OWNER,
|
|
40
44
|
profile: signingContext.getProfile(),
|
|
41
45
|
genesisFeedKey: space.controlFeedKey ?? failUndefined(),
|
|
46
|
+
tags: tags ?? [],
|
|
42
47
|
},
|
|
43
48
|
}),
|
|
44
49
|
|
|
@@ -246,6 +246,7 @@ export class NotarizationPlugin extends Resource implements CredentialProcessor
|
|
|
246
246
|
scheduleTask(ctx, async () => {
|
|
247
247
|
try {
|
|
248
248
|
await client.notarizeCredentials(
|
|
249
|
+
ctx,
|
|
249
250
|
this._spaceId,
|
|
250
251
|
{ credentials: encodedCredentials },
|
|
251
252
|
{ retry: { count: MAX_EDGE_RETRIES, timeout: timeouts.retryTimeout, jitter: timeouts.jitter } },
|
|
@@ -302,7 +303,7 @@ export class NotarizationPlugin extends Resource implements CredentialProcessor
|
|
|
302
303
|
private _notarizePendingEdgeCredentials(client: EdgeHttpClient, writer: FeedWriter<Credential>): void {
|
|
303
304
|
scheduleMicroTask(this._ctx, async () => {
|
|
304
305
|
try {
|
|
305
|
-
const response = await client.getCredentialsForNotarization(this._spaceId, {
|
|
306
|
+
const response = await client.getCredentialsForNotarization(this._ctx, this._spaceId, {
|
|
306
307
|
retry: { count: MAX_EDGE_RETRIES },
|
|
307
308
|
});
|
|
308
309
|
|
|
@@ -8,6 +8,7 @@ import { Trigger } from '@dxos/async';
|
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { type Space, type SpacesService } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
+
import { MembershipPolicy } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
11
12
|
|
|
12
13
|
import { type ServiceContext } from '../services';
|
|
13
14
|
import { createServiceContext } from '../testing';
|
|
@@ -33,12 +34,14 @@ describe('SpacesService', () => {
|
|
|
33
34
|
|
|
34
35
|
describe('createSpace', () => {
|
|
35
36
|
test('fails if no identity is available', async () => {
|
|
36
|
-
await expect(spacesService.createSpace()).rejects.toBeInstanceOf(
|
|
37
|
+
await expect(spacesService.createSpace({ membershipPolicy: MembershipPolicy.INVITE })).rejects.toBeInstanceOf(
|
|
38
|
+
Error,
|
|
39
|
+
);
|
|
37
40
|
});
|
|
38
41
|
|
|
39
42
|
test('creates a new space', async () => {
|
|
40
43
|
await serviceContext.createIdentity();
|
|
41
|
-
const space = await spacesService.createSpace();
|
|
44
|
+
const space = await spacesService.createSpace({ membershipPolicy: MembershipPolicy.INVITE });
|
|
42
45
|
expect(space).to.exist;
|
|
43
46
|
expect(space.spaceKey).to.be.instanceof(PublicKey);
|
|
44
47
|
});
|
|
@@ -60,9 +63,9 @@ describe('SpacesService', () => {
|
|
|
60
63
|
test('returns list of existing spaces', async () => {
|
|
61
64
|
await serviceContext.createIdentity();
|
|
62
65
|
const existingSpaces = [
|
|
63
|
-
await spacesService.createSpace(),
|
|
64
|
-
await spacesService.createSpace(),
|
|
65
|
-
await spacesService.createSpace(),
|
|
66
|
+
await spacesService.createSpace({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
67
|
+
await spacesService.createSpace({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
68
|
+
await spacesService.createSpace({ membershipPolicy: MembershipPolicy.INVITE }),
|
|
66
69
|
];
|
|
67
70
|
|
|
68
71
|
const query = spacesService.querySpaces();
|
|
@@ -88,7 +91,7 @@ describe('SpacesService', () => {
|
|
|
88
91
|
expect(await result.wait()).to.be.length(0);
|
|
89
92
|
|
|
90
93
|
result.reset();
|
|
91
|
-
const space = await spacesService.createSpace();
|
|
94
|
+
const space = await spacesService.createSpace({ membershipPolicy: MembershipPolicy.INVITE });
|
|
92
95
|
const spaces = await result.wait();
|
|
93
96
|
expect(spaces).to.be.length(1);
|
|
94
97
|
expect(spaces?.[0].spaceKey.equals(space.spaceKey)).to.be.true;
|
|
@@ -6,6 +6,7 @@ import type { AutomergeUrl } from '@automerge/automerge-repo';
|
|
|
6
6
|
|
|
7
7
|
import { SubscriptionList, UpdateScheduler, scheduleTask } from '@dxos/async';
|
|
8
8
|
import { Stream } from '@dxos/codec-protobuf/stream';
|
|
9
|
+
import { Context } from '@dxos/context';
|
|
9
10
|
import {
|
|
10
11
|
type CredentialProcessor,
|
|
11
12
|
createAdmissionCredentials,
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
type SpacesService,
|
|
46
47
|
type SubscribeMessagesRequest,
|
|
47
48
|
type UpdateMemberRoleRequest,
|
|
49
|
+
type CreateSpaceRequest,
|
|
48
50
|
type UpdateSpaceRequest,
|
|
49
51
|
type WriteCredentialsRequest,
|
|
50
52
|
} from '@dxos/protocols/proto/dxos/client/services';
|
|
@@ -66,10 +68,13 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
66
68
|
private readonly _getDataSpaceManager: Provider<Promise<DataSpaceManager>>,
|
|
67
69
|
) {}
|
|
68
70
|
|
|
69
|
-
async createSpace(): Promise<Space> {
|
|
71
|
+
async createSpace(request: CreateSpaceRequest): Promise<Space> {
|
|
70
72
|
this._requireIdentity();
|
|
71
73
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
72
|
-
const space = await dataSpaceManager.createSpace()
|
|
74
|
+
const space = await dataSpaceManager.createSpace(new Context(), {
|
|
75
|
+
tags: request?.tags,
|
|
76
|
+
membershipPolicy: request?.membershipPolicy,
|
|
77
|
+
});
|
|
73
78
|
await this._updateMetrics();
|
|
74
79
|
return this._serializeSpace(space);
|
|
75
80
|
}
|
|
@@ -81,11 +86,11 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
81
86
|
if (state) {
|
|
82
87
|
switch (state) {
|
|
83
88
|
case SpaceState.SPACE_ACTIVE:
|
|
84
|
-
await space.activate();
|
|
89
|
+
await space.activate(Context.default());
|
|
85
90
|
break;
|
|
86
91
|
|
|
87
92
|
case SpaceState.SPACE_INACTIVE:
|
|
88
|
-
await space.deactivate();
|
|
93
|
+
await space.deactivate(Context.default());
|
|
89
94
|
break;
|
|
90
95
|
default:
|
|
91
96
|
throw new ApiError({ message: 'Invalid space state' });
|
|
@@ -93,7 +98,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
if (edgeReplication !== undefined) {
|
|
96
|
-
await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
|
|
101
|
+
await dataSpaceManager.setSpaceEdgeReplicationSetting(Context.default(), spaceKey, edgeReplication);
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -264,7 +269,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
264
269
|
|
|
265
270
|
async joinBySpaceKey({ spaceKey }: JoinBySpaceKeyRequest): Promise<JoinSpaceResponse> {
|
|
266
271
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
267
|
-
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(spaceKey);
|
|
272
|
+
const credential = await dataSpaceManager.requestSpaceAdmissionCredential(Context.default(), spaceKey);
|
|
268
273
|
return this._joinByAdmission({ credential });
|
|
269
274
|
}
|
|
270
275
|
|
|
@@ -283,6 +288,20 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
283
288
|
await writer.writeDocument(documentId, data);
|
|
284
289
|
}
|
|
285
290
|
|
|
291
|
+
const feeds = await space.getAllFeeds();
|
|
292
|
+
for (const feed of feeds) {
|
|
293
|
+
const archiveBlocks = feed.blocks.map((block) => ({
|
|
294
|
+
actorId: block.actorId,
|
|
295
|
+
sequence: block.sequence,
|
|
296
|
+
prevActorId: block.prevActorId,
|
|
297
|
+
prevSequence: block.prevSequence,
|
|
298
|
+
position: block.position,
|
|
299
|
+
timestamp: block.timestamp,
|
|
300
|
+
data: Buffer.from(block.data).toString('base64'),
|
|
301
|
+
}));
|
|
302
|
+
await writer.writeFeed(feed.feedId, feed.feedNamespace, archiveBlocks);
|
|
303
|
+
}
|
|
304
|
+
|
|
286
305
|
const archive = await writer.finish();
|
|
287
306
|
return { archive };
|
|
288
307
|
}
|
|
@@ -291,7 +310,7 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
291
310
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
292
311
|
const extracted = await extractSpaceArchive(request.archive);
|
|
293
312
|
invariant(extracted.metadata.echo?.currentRootUrl, 'Space archive does not contain a root URL');
|
|
294
|
-
const space = await dataSpaceManager.createSpace({
|
|
313
|
+
const space = await dataSpaceManager.createSpace(Context.default(), {
|
|
295
314
|
documents: extracted.documents,
|
|
296
315
|
rootUrl: extracted.metadata.echo?.currentRootUrl as AutomergeUrl,
|
|
297
316
|
});
|
|
@@ -308,9 +327,10 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
308
327
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
309
328
|
let dataSpace = dataSpaceManager.spaces.get(assertion.spaceKey);
|
|
310
329
|
if (!dataSpace) {
|
|
311
|
-
dataSpace = await dataSpaceManager.acceptSpace({
|
|
330
|
+
dataSpace = await dataSpaceManager.acceptSpace(Context.default(), {
|
|
312
331
|
spaceKey: assertion.spaceKey,
|
|
313
332
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
333
|
+
tags: assertion.tags,
|
|
314
334
|
});
|
|
315
335
|
await myIdentity.controlPipeline.writer.write({ credential: { credential } });
|
|
316
336
|
}
|
|
@@ -363,6 +383,8 @@ export class SpacesServiceImpl implements SpacesService {
|
|
|
363
383
|
}),
|
|
364
384
|
),
|
|
365
385
|
creator: space.inner.spaceState.creator?.key,
|
|
386
|
+
tags: space.tags,
|
|
387
|
+
membershipPolicy: space.membershipPolicy,
|
|
366
388
|
cache: space.cache,
|
|
367
389
|
metrics: space.metrics,
|
|
368
390
|
edgeReplication: space.getEdgeReplicationSetting(),
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
6
|
import { type AuthenticatingInvitation, type CancellableInvitation, InvitationEncoder } from '@dxos/client-protocol';
|
|
7
|
+
import { Context } from '@dxos/context';
|
|
7
8
|
import { invariant } from '@dxos/invariant';
|
|
8
9
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
10
|
import { type DeviceProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
@@ -229,7 +230,7 @@ export const createInvitation = async (
|
|
|
229
230
|
};
|
|
230
231
|
|
|
231
232
|
if (host instanceof ServiceContext) {
|
|
232
|
-
return host.invitationsManager.createInvitation({
|
|
233
|
+
return host.invitationsManager.createInvitation(new Context(), {
|
|
233
234
|
kind: Invitation.Kind.SPACE,
|
|
234
235
|
...options,
|
|
235
236
|
});
|
|
@@ -246,7 +247,7 @@ export const acceptInvitation = (
|
|
|
246
247
|
invitation = sanitizeInvitation(invitation);
|
|
247
248
|
|
|
248
249
|
if (guest instanceof ServiceContext) {
|
|
249
|
-
return guest.invitationsManager.acceptInvitation({
|
|
250
|
+
return guest.invitationsManager.acceptInvitation(new Context(), {
|
|
250
251
|
invitation,
|
|
251
252
|
deviceProfile: guestDeviceProfile,
|
|
252
253
|
});
|
|
@@ -37,6 +37,7 @@ export type CreateSessionProps = {
|
|
|
37
37
|
appPort: RpcPort;
|
|
38
38
|
systemPort: RpcPort;
|
|
39
39
|
shellPort?: RpcPort;
|
|
40
|
+
onClose?: () => Promise<void>;
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
export type WorkerRuntimeOptions = {
|
|
@@ -50,7 +51,11 @@ export type WorkerRuntimeOptions = {
|
|
|
50
51
|
*/
|
|
51
52
|
automaticallyConnectWebrtc?: boolean;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Optional SQLite layer for Effect. Defaults to LocalSqliteOpfsLayer.
|
|
56
|
+
* For testing in Node.js, use `sqliteLayerMemory` from `@dxos/sql-sqlite/platform`.
|
|
57
|
+
*/
|
|
58
|
+
sqliteLayer?: Layer.Layer<SqlClient.SqlClient | SqlExport.SqlExport, unknown>;
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
/**
|
|
@@ -87,16 +92,19 @@ export class WorkerRuntime {
|
|
|
87
92
|
releaseLock,
|
|
88
93
|
onStop,
|
|
89
94
|
automaticallyConnectWebrtc = true,
|
|
90
|
-
|
|
95
|
+
sqliteLayer,
|
|
91
96
|
}: WorkerRuntimeOptions) {
|
|
92
97
|
this._configProvider = configProvider;
|
|
93
98
|
this._acquireLock = acquireLock;
|
|
94
99
|
this._releaseLock = releaseLock;
|
|
95
100
|
this._onStop = onStop;
|
|
96
101
|
this._channel = channel;
|
|
102
|
+
if (sqliteLayer) {
|
|
103
|
+
log.warn('Using testing SQLite layer');
|
|
104
|
+
}
|
|
97
105
|
this._runtime = ManagedRuntime.make(
|
|
98
106
|
SqlTransaction.layer
|
|
99
|
-
.pipe(Layer.provideMerge(LocalSqliteOpfsLayer), Layer.provideMerge(Reactivity.layer))
|
|
107
|
+
.pipe(Layer.provideMerge(sqliteLayer ?? LocalSqliteOpfsLayer), Layer.provideMerge(Reactivity.layer))
|
|
100
108
|
.pipe(Layer.orDie),
|
|
101
109
|
);
|
|
102
110
|
this._clientServices = new ClientServicesHost({
|
|
@@ -105,7 +113,6 @@ export class WorkerRuntime {
|
|
|
105
113
|
},
|
|
106
114
|
runtime: this._runtime.runtimeEffect,
|
|
107
115
|
runtimeProps: {
|
|
108
|
-
enableSqlite,
|
|
109
116
|
// Auto-activate spaces that were previously active after leader changeover.
|
|
110
117
|
autoActivateSpaces: true,
|
|
111
118
|
},
|
|
@@ -169,7 +176,7 @@ export class WorkerRuntime {
|
|
|
169
176
|
this._releaseLock();
|
|
170
177
|
this._broadcastChannel?.close();
|
|
171
178
|
this._broadcastChannel = undefined;
|
|
172
|
-
await this._clientServices.close();
|
|
179
|
+
await this._clientServices.close(Context.default());
|
|
173
180
|
await this._runtime.dispose();
|
|
174
181
|
await this._onStop?.();
|
|
175
182
|
await this._livenessLock.release();
|
|
@@ -178,7 +185,7 @@ export class WorkerRuntime {
|
|
|
178
185
|
/**
|
|
179
186
|
* Create a new session.
|
|
180
187
|
*/
|
|
181
|
-
async createSession({ appPort, systemPort, shellPort }: CreateSessionProps): Promise<WorkerSession> {
|
|
188
|
+
async createSession({ appPort, systemPort, shellPort, onClose }: CreateSessionProps): Promise<WorkerSession> {
|
|
182
189
|
const session = new WorkerSession({
|
|
183
190
|
serviceHost: this._clientServices,
|
|
184
191
|
appPort,
|
|
@@ -198,6 +205,7 @@ export class WorkerRuntime {
|
|
|
198
205
|
this._reconnectWebrtc();
|
|
199
206
|
}
|
|
200
207
|
}
|
|
208
|
+
await onClose?.();
|
|
201
209
|
});
|
|
202
210
|
|
|
203
211
|
await session.open();
|
|
@@ -119,7 +119,7 @@ export class WorkerSession {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
async open(): Promise<void> {
|
|
122
|
-
log
|
|
122
|
+
log('opening...');
|
|
123
123
|
await Promise.all([this._clientRpc.open(), this._iframeRpc.open(), this._maybeOpenShell()]);
|
|
124
124
|
|
|
125
125
|
// Wait until the worker's RPC service has started.
|
|
@@ -130,11 +130,11 @@ export class WorkerSession {
|
|
|
130
130
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
log
|
|
133
|
+
log('opened');
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
async close(): Promise<void> {
|
|
137
|
-
log.
|
|
137
|
+
log.debug('closing...');
|
|
138
138
|
try {
|
|
139
139
|
await this.onClose.callIfSet();
|
|
140
140
|
} catch (err: any) {
|
|
@@ -142,7 +142,7 @@ export class WorkerSession {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
await Promise.all([this._clientRpc.close(), this._iframeRpc.close()]);
|
|
145
|
-
log.
|
|
145
|
+
log.debug('closed');
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
private async _maybeOpenShell(): Promise<void> {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DXOS_VERSION = "0.8.4-main.
|
|
1
|
+
export const DXOS_VERSION = "0.8.4-main.bcb3aa67d6";
|