@dxos/client-services 0.3.11-main.cf6cc01 → 0.3.11-main.d56f337

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.
@@ -483,7 +483,7 @@ function _ts_decorate(decorators, target, key, desc) {
483
483
  return c > 3 && r && Object.defineProperty(target, key, r), r;
484
484
  }
485
485
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
486
- var Identity = class Identity2 {
486
+ var Identity = class {
487
487
  constructor({ space, signer, identityKey, deviceKey }) {
488
488
  this.stateUpdate = new Event();
489
489
  this.space = space;
@@ -665,7 +665,7 @@ function _ts_decorate2(decorators, target, key, desc) {
665
665
  return c > 3 && r && Object.defineProperty(target, key, r), r;
666
666
  }
667
667
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
668
- var IdentityManager = class IdentityManager2 {
668
+ var IdentityManager = class {
669
669
  // TODO(burdon): IdentityManagerParams.
670
670
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
671
671
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -1025,6 +1025,7 @@ import { signPresentation } from "@dxos/credentials";
1025
1025
  import { todo } from "@dxos/debug";
1026
1026
  import { invariant as invariant3 } from "@dxos/invariant";
1027
1027
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1028
+ var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
1028
1029
  var IdentityServiceImpl = class {
1029
1030
  constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1030
1031
  this._createIdentity = _createIdentity;
@@ -1033,7 +1034,7 @@ var IdentityServiceImpl = class {
1033
1034
  this._onProfileUpdate = _onProfileUpdate;
1034
1035
  }
1035
1036
  async createIdentity(request) {
1036
- await this._createIdentity(request);
1037
+ await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
1037
1038
  return this._getIdentity();
1038
1039
  }
1039
1040
  async recoverIdentity(request) {
@@ -1061,7 +1062,7 @@ var IdentityServiceImpl = class {
1061
1062
  async updateProfile(profile) {
1062
1063
  invariant3(this._identityManager.identity, "Identity not initialized.", {
1063
1064
  F: __dxlog_file4,
1064
- L: 60,
1065
+ L: 63,
1065
1066
  S: this,
1066
1067
  A: [
1067
1068
  "this._identityManager.identity",
@@ -1075,7 +1076,7 @@ var IdentityServiceImpl = class {
1075
1076
  async signPresentation({ presentation, nonce }) {
1076
1077
  invariant3(this._identityManager.identity, "Identity not initialized.", {
1077
1078
  F: __dxlog_file4,
1078
- L: 67,
1079
+ L: 70,
1079
1080
  S: this,
1080
1081
  A: [
1081
1082
  "this._identityManager.identity",
@@ -2437,7 +2438,7 @@ function _ts_decorate3(decorators, target, key, desc) {
2437
2438
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2438
2439
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2439
2440
  }
2440
- var ClientRpcServer = class ClientRpcServer2 {
2441
+ var ClientRpcServer = class {
2441
2442
  constructor(params) {
2442
2443
  this._handlerCache = /* @__PURE__ */ new Map();
2443
2444
  this._callMetrics = new MapCounter();
@@ -2542,7 +2543,7 @@ var getPlatform = () => {
2542
2543
  };
2543
2544
 
2544
2545
  // packages/sdk/client-services/src/version.ts
2545
- var DXOS_VERSION = "0.3.11-main.cf6cc01";
2546
+ var DXOS_VERSION = "0.3.11-main.d56f337";
2546
2547
 
2547
2548
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2548
2549
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -2981,7 +2982,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2981
2982
  }
2982
2983
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2983
2984
  var ENABLE_FEED_PURGE = false;
2984
- var DataSpace = class DataSpace2 {
2985
+ var DataSpace = class {
2985
2986
  constructor(params) {
2986
2987
  this._ctx = new Context7();
2987
2988
  this._notarizationPlugin = new NotarizationPlugin();
@@ -3470,7 +3471,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3470
3471
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3471
3472
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3472
3473
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3473
- var DataSpaceManager = class DataSpaceManager2 {
3474
+ var DataSpaceManager = class {
3474
3475
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3475
3476
  this._spaceManager = _spaceManager;
3476
3477
  this._metadataStore = _metadataStore;
@@ -4043,7 +4044,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4043
4044
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4044
4045
  }
4045
4046
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4046
- var ServiceContext = class ServiceContext2 {
4047
+ var ServiceContext = class {
4047
4048
  constructor(storage, networkManager, signalManager, modelFactory) {
4048
4049
  this.storage = storage;
4049
4050
  this.networkManager = networkManager;
@@ -4344,7 +4345,7 @@ var Lock = class {
4344
4345
  }
4345
4346
  async acquire() {
4346
4347
  this._broadcastChannel.postMessage({
4347
- message: Message.ACQUIRING
4348
+ message: "acquiring"
4348
4349
  });
4349
4350
  try {
4350
4351
  log14("aquiring lock...", void 0, {
@@ -4380,7 +4381,7 @@ var Lock = class {
4380
4381
  this._releaseTrigger.wake();
4381
4382
  }
4382
4383
  _onMessage(event) {
4383
- if (event.data.message === Message.ACQUIRING) {
4384
+ if (event.data.message === "acquiring") {
4384
4385
  this._releaseTrigger.wake();
4385
4386
  }
4386
4387
  }
@@ -4490,7 +4491,7 @@ import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protoc
4490
4491
  import { Context as Context10 } from "@dxos/context";
4491
4492
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4492
4493
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4493
- import { base } from "@dxos/echo-schema";
4494
+ import { base, getRawDoc } from "@dxos/echo-schema";
4494
4495
  import { invariant as invariant14 } from "@dxos/invariant";
4495
4496
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4496
4497
  import { log as log16 } from "@dxos/log";
@@ -4777,7 +4778,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
4777
4778
  }
4778
4779
  };
4779
4780
  };
4780
- var ClientServicesHost = class ClientServicesHost2 {
4781
+ var ClientServicesHost = class {
4781
4782
  constructor({
4782
4783
  config,
4783
4784
  modelFactory = createDefaultModelFactory(),
@@ -4979,7 +4980,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4979
4980
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4980
4981
  this._serviceRegistry.setServices({
4981
4982
  SystemService: this._systemService,
4982
- IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
4983
+ IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
4983
4984
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4984
4985
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4985
4986
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -5093,25 +5094,44 @@ var ClientServicesHost = class ClientServicesHost2 {
5093
5094
  });
5094
5095
  await this._callbacks?.onReset?.();
5095
5096
  }
5096
- async _createIdentity(params) {
5097
+ async _createIdentity(params, useAutomerge) {
5097
5098
  const identity = await this._serviceContext.createIdentity(params);
5098
5099
  await this._serviceContext.initialized.wait();
5099
5100
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5100
5101
  const obj = new Properties(void 0, {
5101
- automerge: false
5102
+ automerge: useAutomerge
5102
5103
  });
5103
5104
  obj[defaultKey] = identity.identityKey.toHex();
5104
- await this._serviceRegistry.services.DataService.write({
5105
- spaceKey: space.key,
5106
- batch: {
5107
- objects: [
5108
- createGenesisMutationFromTypedObject(obj)
5105
+ if (!useAutomerge) {
5106
+ await this._serviceRegistry.services.DataService.write({
5107
+ spaceKey: space.key,
5108
+ batch: {
5109
+ objects: [
5110
+ createGenesisMutationFromTypedObject(obj)
5111
+ ]
5112
+ }
5113
+ });
5114
+ await this._serviceRegistry.services.DataService.flush({
5115
+ spaceKey: space.key
5116
+ });
5117
+ } else {
5118
+ const automergeIndex = space.automergeSpaceState.rootUrl;
5119
+ invariant14(automergeIndex, void 0, {
5120
+ F: __dxlog_file17,
5121
+ L: 375,
5122
+ S: this,
5123
+ A: [
5124
+ "automergeIndex",
5125
+ ""
5109
5126
  ]
5110
- }
5111
- });
5112
- await this._serviceRegistry.services.DataService.flush({
5113
- spaceKey: space.key
5114
- });
5127
+ });
5128
+ const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5129
+ await document.whenReady();
5130
+ document.change((doc) => {
5131
+ doc.objects ??= {};
5132
+ doc.objects[obj[base]._id] = getRawDoc(obj).handle.docSync();
5133
+ });
5134
+ }
5115
5135
  return identity;
5116
5136
  }
5117
5137
  };
@@ -5167,4 +5187,4 @@ export {
5167
5187
  createDefaultModelFactory,
5168
5188
  ClientServicesHost
5169
5189
  };
5170
- //# sourceMappingURL=chunk-RCTGQMFJ.mjs.map
5190
+ //# sourceMappingURL=chunk-DUTSCN4V.mjs.map