@dxos/client-services 0.3.11-main.d7d4c52 → 0.3.11-main.da09c3c

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",
@@ -1968,6 +1969,7 @@ var InvitationsHandler = class {
1968
1969
  });
1969
1970
  setState({
1970
1971
  ...result,
1972
+ target: invitation.target,
1971
1973
  state: Invitation3.State.SUCCESS
1972
1974
  });
1973
1975
  log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
@@ -2436,7 +2438,7 @@ function _ts_decorate3(decorators, target, key, desc) {
2436
2438
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2437
2439
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2438
2440
  }
2439
- var ClientRpcServer = class ClientRpcServer2 {
2441
+ var ClientRpcServer = class {
2440
2442
  constructor(params) {
2441
2443
  this._handlerCache = /* @__PURE__ */ new Map();
2442
2444
  this._callMetrics = new MapCounter();
@@ -2541,7 +2543,7 @@ var getPlatform = () => {
2541
2543
  };
2542
2544
 
2543
2545
  // packages/sdk/client-services/src/version.ts
2544
- var DXOS_VERSION = "0.3.11-main.d7d4c52";
2546
+ var DXOS_VERSION = "0.3.11-main.da09c3c";
2545
2547
 
2546
2548
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2547
2549
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -2980,7 +2982,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2980
2982
  }
2981
2983
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2982
2984
  var ENABLE_FEED_PURGE = false;
2983
- var DataSpace = class DataSpace2 {
2985
+ var DataSpace = class {
2984
2986
  constructor(params) {
2985
2987
  this._ctx = new Context7();
2986
2988
  this._notarizationPlugin = new NotarizationPlugin();
@@ -3469,7 +3471,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3469
3471
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3470
3472
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3471
3473
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3472
- var DataSpaceManager = class DataSpaceManager2 {
3474
+ var DataSpaceManager = class {
3473
3475
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3474
3476
  this._spaceManager = _spaceManager;
3475
3477
  this._metadataStore = _metadataStore;
@@ -4042,7 +4044,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4042
4044
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4043
4045
  }
4044
4046
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4045
- var ServiceContext = class ServiceContext2 {
4047
+ var ServiceContext = class {
4046
4048
  constructor(storage, networkManager, signalManager, modelFactory) {
4047
4049
  this.storage = storage;
4048
4050
  this.networkManager = networkManager;
@@ -4343,7 +4345,7 @@ var Lock = class {
4343
4345
  }
4344
4346
  async acquire() {
4345
4347
  this._broadcastChannel.postMessage({
4346
- message: Message.ACQUIRING
4348
+ message: "acquiring"
4347
4349
  });
4348
4350
  try {
4349
4351
  log14("aquiring lock...", void 0, {
@@ -4379,7 +4381,7 @@ var Lock = class {
4379
4381
  this._releaseTrigger.wake();
4380
4382
  }
4381
4383
  _onMessage(event) {
4382
- if (event.data.message === Message.ACQUIRING) {
4384
+ if (event.data.message === "acquiring") {
4383
4385
  this._releaseTrigger.wake();
4384
4386
  }
4385
4387
  }
@@ -4489,7 +4491,7 @@ import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protoc
4489
4491
  import { Context as Context10 } from "@dxos/context";
4490
4492
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4491
4493
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4492
- import { base } from "@dxos/echo-schema";
4494
+ import { base, getRawDoc } from "@dxos/echo-schema";
4493
4495
  import { invariant as invariant14 } from "@dxos/invariant";
4494
4496
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4495
4497
  import { log as log16 } from "@dxos/log";
@@ -4776,7 +4778,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
4776
4778
  }
4777
4779
  };
4778
4780
  };
4779
- var ClientServicesHost = class ClientServicesHost2 {
4781
+ var ClientServicesHost = class {
4780
4782
  constructor({
4781
4783
  config,
4782
4784
  modelFactory = createDefaultModelFactory(),
@@ -4978,7 +4980,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4978
4980
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4979
4981
  this._serviceRegistry.setServices({
4980
4982
  SystemService: this._systemService,
4981
- 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)),
4982
4984
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4983
4985
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4984
4986
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -5092,25 +5094,44 @@ var ClientServicesHost = class ClientServicesHost2 {
5092
5094
  });
5093
5095
  await this._callbacks?.onReset?.();
5094
5096
  }
5095
- async _createIdentity(params) {
5097
+ async _createIdentity(params, useAutomerge) {
5096
5098
  const identity = await this._serviceContext.createIdentity(params);
5097
5099
  await this._serviceContext.initialized.wait();
5098
5100
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5099
5101
  const obj = new Properties(void 0, {
5100
- automerge: false
5102
+ automerge: useAutomerge
5101
5103
  });
5102
5104
  obj[defaultKey] = identity.identityKey.toHex();
5103
- await this._serviceRegistry.services.DataService.write({
5104
- spaceKey: space.key,
5105
- batch: {
5106
- objects: [
5107
- 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
+ ""
5108
5126
  ]
5109
- }
5110
- });
5111
- await this._serviceRegistry.services.DataService.flush({
5112
- spaceKey: space.key
5113
- });
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
+ }
5114
5135
  return identity;
5115
5136
  }
5116
5137
  };
@@ -5166,4 +5187,4 @@ export {
5166
5187
  createDefaultModelFactory,
5167
5188
  ClientServicesHost
5168
5189
  };
5169
- //# sourceMappingURL=chunk-CKB4252E.mjs.map
5190
+ //# sourceMappingURL=chunk-BXE3PPJB.mjs.map