@dxos/client-services 0.4.7-main.aa6dc1f → 0.4.7-main.b51ad3a

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.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_Z5XDOC7V_exports = {};
30
- __export(chunk_Z5XDOC7V_exports, {
29
+ var chunk_UGRBM6TA_exports = {};
30
+ __export(chunk_UGRBM6TA_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_Z5XDOC7V_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_Z5XDOC7V_exports);
63
+ module.exports = __toCommonJS(chunk_UGRBM6TA_exports);
64
64
  var import_async = require("@dxos/async");
65
65
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
66
  var import_feed_store = require("@dxos/feed-store");
@@ -2784,7 +2784,7 @@ var getPlatform = () => {
2784
2784
  };
2785
2785
  }
2786
2786
  };
2787
- var DXOS_VERSION = "0.4.7-main.aa6dc1f";
2787
+ var DXOS_VERSION = "0.4.7-main.b51ad3a";
2788
2788
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2789
2789
  var DEFAULT_TIMEOUT = 1e3;
2790
2790
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -2927,6 +2927,7 @@ var AutomergeSpaceState = class {
2927
2927
  this._onNewRoot = _onNewRoot;
2928
2928
  this.rootUrl = void 0;
2929
2929
  this.lastEpoch = void 0;
2930
+ this._isProcessingRootDocs = false;
2930
2931
  }
2931
2932
  async processCredential(credential) {
2932
2933
  if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
@@ -2935,8 +2936,19 @@ var AutomergeSpaceState = class {
2935
2936
  this.lastEpoch = credential;
2936
2937
  if (credential.subject.assertion.automergeRoot) {
2937
2938
  this.rootUrl = credential.subject.assertion.automergeRoot;
2939
+ if (this._isProcessingRootDocs) {
2940
+ this._onNewRoot(this.rootUrl);
2941
+ }
2942
+ }
2943
+ }
2944
+ startProcessingRootDocs() {
2945
+ if (this._isProcessingRootDocs) {
2946
+ return;
2947
+ }
2948
+ if (this.rootUrl) {
2938
2949
  this._onNewRoot(this.rootUrl);
2939
2950
  }
2951
+ this._isProcessingRootDocs = true;
2940
2952
  }
2941
2953
  };
2942
2954
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
@@ -3386,12 +3398,13 @@ var DataSpace = class {
3386
3398
  });
3387
3399
  await this._initializeAndReadControlPipeline();
3388
3400
  await (0, import_async10.sleep)(1);
3401
+ this._automergeSpaceState.startProcessingRootDocs();
3389
3402
  await this._inner.initializeDataPipeline();
3390
3403
  this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
3391
3404
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3392
3405
  (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
3393
3406
  F: __dxlog_file12,
3394
- L: 286,
3407
+ L: 288,
3395
3408
  S: this,
3396
3409
  C: (f, a) => f(...a)
3397
3410
  });
@@ -3402,7 +3415,7 @@ var DataSpace = class {
3402
3415
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3403
3416
  (0, import_log9.log)("data pipeline ready", void 0, {
3404
3417
  F: __dxlog_file12,
3405
- L: 294,
3418
+ L: 296,
3406
3419
  S: this,
3407
3420
  C: (f, a) => f(...a)
3408
3421
  });
@@ -3412,7 +3425,7 @@ var DataSpace = class {
3412
3425
  state: import_services9.SpaceState[this._state]
3413
3426
  }, {
3414
3427
  F: __dxlog_file12,
3415
- L: 298,
3428
+ L: 300,
3416
3429
  S: this,
3417
3430
  C: (f, a) => f(...a)
3418
3431
  });
@@ -3428,7 +3441,7 @@ var DataSpace = class {
3428
3441
  await this._createWritableFeeds();
3429
3442
  (0, import_log9.log)("writable feeds created", void 0, {
3430
3443
  F: __dxlog_file12,
3431
- L: 314,
3444
+ L: 316,
3432
3445
  S: this,
3433
3446
  C: (f, a) => f(...a)
3434
3447
  });
@@ -3491,7 +3504,7 @@ var DataSpace = class {
3491
3504
  rootUrl
3492
3505
  }, {
3493
3506
  F: __dxlog_file12,
3494
- L: 380,
3507
+ L: 382,
3495
3508
  S: this,
3496
3509
  C: (f, a) => f(...a)
3497
3510
  });
@@ -3523,7 +3536,7 @@ var DataSpace = class {
3523
3536
  err
3524
3537
  }, {
3525
3538
  F: __dxlog_file12,
3526
- L: 403,
3539
+ L: 405,
3527
3540
  S: this,
3528
3541
  C: (f, a) => f(...a)
3529
3542
  });
@@ -3554,15 +3567,40 @@ var DataSpace = class {
3554
3567
  epoch = await this.dataPipeline.createEpoch();
3555
3568
  }
3556
3569
  break;
3557
- case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3558
- const document = this._automergeHost.repo.create();
3559
- epoch = {
3560
- previousId: this._automergeSpaceState.lastEpoch?.id,
3561
- number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3562
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3563
- automergeRoot: document.url
3564
- };
3565
- }
3570
+ case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3571
+ {
3572
+ const document = this._automergeHost.repo.create();
3573
+ epoch = {
3574
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3575
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3576
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3577
+ automergeRoot: document.url
3578
+ };
3579
+ }
3580
+ break;
3581
+ case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3582
+ {
3583
+ const currentRootUrl = this._automergeSpaceState.rootUrl;
3584
+ const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3585
+ await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3586
+ const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3587
+ (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3588
+ F: __dxlog_file12,
3589
+ L: 450,
3590
+ S: this,
3591
+ A: [
3592
+ "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3593
+ ""
3594
+ ]
3595
+ });
3596
+ epoch = {
3597
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3598
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3599
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3600
+ automergeRoot: newRoot.url
3601
+ };
3602
+ }
3603
+ break;
3566
3604
  }
3567
3605
  if (!epoch) {
3568
3606
  return;
@@ -3613,7 +3651,7 @@ var DataSpace = class {
3613
3651
  state: import_services9.SpaceState[this._state]
3614
3652
  }, {
3615
3653
  F: __dxlog_file12,
3616
- L: 492,
3654
+ L: 514,
3617
3655
  S: this,
3618
3656
  C: (f, a) => f(...a)
3619
3657
  });
@@ -4240,10 +4278,12 @@ var SpacesServiceImpl = class {
4240
4278
  }
4241
4279
  }
4242
4280
  }
4243
- async createEpoch({ spaceKey }) {
4281
+ async createEpoch({ spaceKey, migration }) {
4244
4282
  const dataSpaceManager = await this._getDataSpaceManager();
4245
4283
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4246
- await space.createEpoch();
4284
+ await space.createEpoch({
4285
+ migration
4286
+ });
4247
4287
  }
4248
4288
  _serializeSpace(space) {
4249
4289
  return {
@@ -5348,4 +5388,4 @@ ClientServicesHost = _ts_decorate8([
5348
5388
  subscribeToSpaces,
5349
5389
  subscribeToSwarmInfo
5350
5390
  });
5351
- //# sourceMappingURL=chunk-Z5XDOC7V.cjs.map
5391
+ //# sourceMappingURL=chunk-UGRBM6TA.cjs.map