@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.
@@ -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_5EUWM7NI_exports = {};
30
- __export(chunk_5EUWM7NI_exports, {
29
+ var chunk_HZAHSCSR_exports = {};
30
+ __export(chunk_HZAHSCSR_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_5EUWM7NI_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_5EUWM7NI_exports);
63
+ module.exports = __toCommonJS(chunk_HZAHSCSR_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");
@@ -675,7 +675,7 @@ function _ts_decorate(decorators, target, key, desc) {
675
675
  return c > 3 && r && Object.defineProperty(target, key, r), r;
676
676
  }
677
677
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
678
- var Identity = class Identity2 {
678
+ var Identity = class {
679
679
  constructor({ space, signer, identityKey, deviceKey }) {
680
680
  this.stateUpdate = new import_async5.Event();
681
681
  this.space = space;
@@ -843,7 +843,7 @@ function _ts_decorate2(decorators, target, key, desc) {
843
843
  return c > 3 && r && Object.defineProperty(target, key, r), r;
844
844
  }
845
845
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
846
- var IdentityManager = class IdentityManager2 {
846
+ var IdentityManager = class {
847
847
  // TODO(burdon): IdentityManagerParams.
848
848
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
849
849
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -1197,6 +1197,7 @@ IdentityManager = _ts_decorate2([
1197
1197
  import_tracing2.trace.resource()
1198
1198
  ], IdentityManager);
1199
1199
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1200
+ var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
1200
1201
  var IdentityServiceImpl = class {
1201
1202
  constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1202
1203
  this._createIdentity = _createIdentity;
@@ -1205,7 +1206,7 @@ var IdentityServiceImpl = class {
1205
1206
  this._onProfileUpdate = _onProfileUpdate;
1206
1207
  }
1207
1208
  async createIdentity(request) {
1208
- await this._createIdentity(request);
1209
+ await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
1209
1210
  return this._getIdentity();
1210
1211
  }
1211
1212
  async recoverIdentity(request) {
@@ -1233,7 +1234,7 @@ var IdentityServiceImpl = class {
1233
1234
  async updateProfile(profile) {
1234
1235
  (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1235
1236
  F: __dxlog_file4,
1236
- L: 60,
1237
+ L: 63,
1237
1238
  S: this,
1238
1239
  A: [
1239
1240
  "this._identityManager.identity",
@@ -1247,7 +1248,7 @@ var IdentityServiceImpl = class {
1247
1248
  async signPresentation({ presentation, nonce }) {
1248
1249
  (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1249
1250
  F: __dxlog_file4,
1250
- L: 67,
1251
+ L: 70,
1251
1252
  S: this,
1252
1253
  A: [
1253
1254
  "this._identityManager.identity",
@@ -2110,6 +2111,7 @@ var InvitationsHandler = class {
2110
2111
  });
2111
2112
  setState({
2112
2113
  ...result,
2114
+ target: invitation.target,
2113
2115
  state: import_services2.Invitation.State.SUCCESS
2114
2116
  });
2115
2117
  import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols3.trace.end({
@@ -2558,7 +2560,7 @@ function _ts_decorate3(decorators, target, key, desc) {
2558
2560
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2559
2561
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2560
2562
  }
2561
- var ClientRpcServer = class ClientRpcServer2 {
2563
+ var ClientRpcServer = class {
2562
2564
  constructor(params) {
2563
2565
  this._handlerCache = /* @__PURE__ */ new Map();
2564
2566
  this._callMetrics = new import_tracing3.MapCounter();
@@ -2649,7 +2651,7 @@ var getPlatform = () => {
2649
2651
  };
2650
2652
  }
2651
2653
  };
2652
- var DXOS_VERSION = "0.3.11-main.d7d4c52";
2654
+ var DXOS_VERSION = "0.3.11-main.da09c3c";
2653
2655
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2654
2656
  var DEFAULT_TIMEOUT = 1e3;
2655
2657
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -3056,7 +3058,7 @@ function _ts_decorate4(decorators, target, key, desc) {
3056
3058
  }
3057
3059
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3058
3060
  var ENABLE_FEED_PURGE = false;
3059
- var DataSpace = class DataSpace2 {
3061
+ var DataSpace = class {
3060
3062
  constructor(params) {
3061
3063
  this._ctx = new import_context6.Context();
3062
3064
  this._notarizationPlugin = new NotarizationPlugin();
@@ -3521,7 +3523,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3521
3523
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3522
3524
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3523
3525
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3524
- var DataSpaceManager = class DataSpaceManager2 {
3526
+ var DataSpaceManager = class {
3525
3527
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3526
3528
  this._spaceManager = _spaceManager;
3527
3529
  this._metadataStore = _metadataStore;
@@ -4068,7 +4070,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4068
4070
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4069
4071
  }
4070
4072
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4071
- var ServiceContext = class ServiceContext2 {
4073
+ var ServiceContext = class {
4072
4074
  constructor(storage, networkManager, signalManager, modelFactory) {
4073
4075
  this.storage = storage;
4074
4076
  this.networkManager = networkManager;
@@ -4682,7 +4684,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
4682
4684
  }
4683
4685
  };
4684
4686
  };
4685
- var ClientServicesHost = class ClientServicesHost2 {
4687
+ var ClientServicesHost = class {
4686
4688
  constructor({
4687
4689
  config,
4688
4690
  modelFactory = createDefaultModelFactory(),
@@ -4884,7 +4886,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4884
4886
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4885
4887
  this._serviceRegistry.setServices({
4886
4888
  SystemService: this._systemService,
4887
- IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
4889
+ IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
4888
4890
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4889
4891
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4890
4892
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4998,25 +5000,44 @@ var ClientServicesHost = class ClientServicesHost2 {
4998
5000
  });
4999
5001
  await this._callbacks?.onReset?.();
5000
5002
  }
5001
- async _createIdentity(params) {
5003
+ async _createIdentity(params, useAutomerge) {
5002
5004
  const identity = await this._serviceContext.createIdentity(params);
5003
5005
  await this._serviceContext.initialized.wait();
5004
5006
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5005
5007
  const obj = new import_client_protocol5.Properties(void 0, {
5006
- automerge: false
5008
+ automerge: useAutomerge
5007
5009
  });
5008
5010
  obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5009
- await this._serviceRegistry.services.DataService.write({
5010
- spaceKey: space.key,
5011
- batch: {
5012
- objects: [
5013
- createGenesisMutationFromTypedObject(obj)
5011
+ if (!useAutomerge) {
5012
+ await this._serviceRegistry.services.DataService.write({
5013
+ spaceKey: space.key,
5014
+ batch: {
5015
+ objects: [
5016
+ createGenesisMutationFromTypedObject(obj)
5017
+ ]
5018
+ }
5019
+ });
5020
+ await this._serviceRegistry.services.DataService.flush({
5021
+ spaceKey: space.key
5022
+ });
5023
+ } else {
5024
+ const automergeIndex = space.automergeSpaceState.rootUrl;
5025
+ (0, import_invariant15.invariant)(automergeIndex, void 0, {
5026
+ F: __dxlog_file17,
5027
+ L: 375,
5028
+ S: this,
5029
+ A: [
5030
+ "automergeIndex",
5031
+ ""
5014
5032
  ]
5015
- }
5016
- });
5017
- await this._serviceRegistry.services.DataService.flush({
5018
- spaceKey: space.key
5019
- });
5033
+ });
5034
+ const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5035
+ await document.whenReady();
5036
+ document.change((doc) => {
5037
+ doc.objects ??= {};
5038
+ doc.objects[obj[import_echo_schema.base]._id] = (0, import_echo_schema.getRawDoc)(obj).handle.docSync();
5039
+ });
5040
+ }
5020
5041
  return identity;
5021
5042
  }
5022
5043
  };
@@ -5071,4 +5092,4 @@ ClientServicesHost = _ts_decorate8([
5071
5092
  subscribeToSpaces,
5072
5093
  subscribeToSwarmInfo
5073
5094
  });
5074
- //# sourceMappingURL=chunk-5EUWM7NI.cjs.map
5095
+ //# sourceMappingURL=chunk-HZAHSCSR.cjs.map