@dxos/client-services 0.4.7 → 0.4.8-main.0602afb

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.
Files changed (38) hide show
  1. package/dist/lib/browser/{chunk-NI6XJLUJ.mjs → chunk-WAR4XN64.mjs} +348 -160
  2. package/dist/lib/browser/chunk-WAR4XN64.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +3 -1
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-RH65IX2V.cjs → chunk-S4SHWFEU.cjs} +323 -134
  8. package/dist/lib/node/chunk-S4SHWFEU.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +39 -37
  10. package/dist/lib/node/index.cjs.map +1 -1
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  13. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +1 -0
  14. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  15. package/dist/types/src/packlets/invitations/invitations-service.d.ts +9 -1
  16. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  18. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
  21. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  24. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/dist/types/src/version.d.ts.map +1 -1
  27. package/package.json +37 -35
  28. package/src/packlets/identity/identity-manager.ts +1 -1
  29. package/src/packlets/invitations/invitations-handler.ts +37 -2
  30. package/src/packlets/invitations/invitations-service.ts +83 -5
  31. package/src/packlets/services/service-context.ts +26 -4
  32. package/src/packlets/services/service-host.ts +15 -2
  33. package/src/packlets/spaces/automerge-space-state.ts +15 -0
  34. package/src/packlets/spaces/data-space.ts +33 -11
  35. package/src/packlets/spaces/spaces-service.ts +2 -2
  36. package/src/version.ts +1 -5
  37. package/dist/lib/browser/chunk-NI6XJLUJ.mjs.map +0 -7
  38. package/dist/lib/node/chunk-RH65IX2V.cjs.map +0 -7
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { Event, scheduleTask, sleep, synchronized, trackLeaks } from '@dxos/async';
5
+ import { Event, asyncTimeout, scheduleTask, sleep, synchronized, trackLeaks } from '@dxos/async';
6
6
  import { AUTH_TIMEOUT } from '@dxos/client-protocol';
7
7
  import { cancelWithContext, Context, ContextDisposedError } from '@dxos/context';
8
8
  import { timed, warnAfterTimeout } from '@dxos/debug';
@@ -15,7 +15,7 @@ import {
15
15
  type AutomergeHost,
16
16
  } from '@dxos/echo-pipeline';
17
17
  import { type FeedStore } from '@dxos/feed-store';
18
- import { failedInvariant } from '@dxos/invariant';
18
+ import { failedInvariant, invariant } from '@dxos/invariant';
19
19
  import { type Keyring } from '@dxos/keyring';
20
20
  import { PublicKey } from '@dxos/keys';
21
21
  import { log } from '@dxos/log';
@@ -276,6 +276,8 @@ export class DataSpace {
276
276
  // Allow other tasks to run before loading the data pipeline.
277
277
  await sleep(1);
278
278
 
279
+ this._automergeSpaceState.startProcessingRootDocs();
280
+
279
281
  await this._inner.initializeDataPipeline();
280
282
 
281
283
  this.metrics.dataPipelineOpen = new Date();
@@ -423,18 +425,38 @@ export class DataSpace {
423
425
  case undefined:
424
426
  case CreateEpochRequest.Migration.NONE:
425
427
  {
428
+ // TODO(dmaretskyi): Unify epoch construction.
426
429
  epoch = await this.dataPipeline.createEpoch();
427
430
  }
428
431
  break;
429
- case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
430
- const document = this._automergeHost.repo.create();
431
- epoch = {
432
- previousId: this._automergeSpaceState.lastEpoch?.id,
433
- number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
434
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe(),
435
- automergeRoot: document.url,
436
- };
437
- }
432
+ case CreateEpochRequest.Migration.INIT_AUTOMERGE:
433
+ {
434
+ const document = this._automergeHost.repo.create();
435
+ // TODO(dmaretskyi): Unify epoch construction.
436
+ epoch = {
437
+ previousId: this._automergeSpaceState.lastEpoch?.id,
438
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
439
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe(),
440
+ automergeRoot: document.url,
441
+ };
442
+ }
443
+ break;
444
+ case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
445
+ {
446
+ const currentRootUrl = this._automergeSpaceState.rootUrl;
447
+ const rootHandle = this._automergeHost.repo.find(currentRootUrl as any);
448
+ await cancelWithContext(this._ctx, asyncTimeout(rootHandle.whenReady(), 10_000));
449
+ const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
450
+ invariant(typeof newRoot.url === 'string' && newRoot.url.length > 0);
451
+ // TODO(dmaretskyi): Unify epoch construction.
452
+ epoch = {
453
+ previousId: this._automergeSpaceState.lastEpoch?.id,
454
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
455
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe(),
456
+ automergeRoot: newRoot.url,
457
+ };
458
+ }
459
+ break;
438
460
  }
439
461
 
440
462
  if (!epoch) {
@@ -178,10 +178,10 @@ export class SpacesServiceImpl implements SpacesService {
178
178
  }
179
179
  }
180
180
 
181
- async createEpoch({ spaceKey }: CreateEpochRequest) {
181
+ async createEpoch({ spaceKey, migration }: CreateEpochRequest) {
182
182
  const dataSpaceManager = await this._getDataSpaceManager();
183
183
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise(new SpaceNotFoundError(spaceKey));
184
- await space.createEpoch();
184
+ await space.createEpoch({ migration });
185
185
  }
186
186
 
187
187
  private _serializeSpace(space: DataSpace): Space {
package/src/version.ts CHANGED
@@ -1,5 +1 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export const DXOS_VERSION = '0.4.7'; // {x-release-please-version}
1
+ export const DXOS_VERSION = "0.4.8-main.0602afb";