@dxos/client-services 0.3.11-main.9fa973d → 0.3.11-main.a53382c

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_TJGRH3AQ_exports = {};
30
- __export(chunk_TJGRH3AQ_exports, {
29
+ var chunk_534INJFX_exports = {};
30
+ __export(chunk_534INJFX_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_TJGRH3AQ_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_TJGRH3AQ_exports);
63
+ module.exports = __toCommonJS(chunk_534INJFX_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",
@@ -2559,7 +2560,7 @@ function _ts_decorate3(decorators, target, key, desc) {
2559
2560
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2560
2561
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2561
2562
  }
2562
- var ClientRpcServer = class ClientRpcServer2 {
2563
+ var ClientRpcServer = class {
2563
2564
  constructor(params) {
2564
2565
  this._handlerCache = /* @__PURE__ */ new Map();
2565
2566
  this._callMetrics = new import_tracing3.MapCounter();
@@ -2650,7 +2651,7 @@ var getPlatform = () => {
2650
2651
  };
2651
2652
  }
2652
2653
  };
2653
- var DXOS_VERSION = "0.3.11-main.9fa973d";
2654
+ var DXOS_VERSION = "0.3.11-main.a53382c";
2654
2655
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2655
2656
  var DEFAULT_TIMEOUT = 1e3;
2656
2657
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -3057,7 +3058,7 @@ function _ts_decorate4(decorators, target, key, desc) {
3057
3058
  }
3058
3059
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3059
3060
  var ENABLE_FEED_PURGE = false;
3060
- var DataSpace = class DataSpace2 {
3061
+ var DataSpace = class {
3061
3062
  constructor(params) {
3062
3063
  this._ctx = new import_context6.Context();
3063
3064
  this._notarizationPlugin = new NotarizationPlugin();
@@ -3522,7 +3523,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3522
3523
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3523
3524
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3524
3525
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3525
- var DataSpaceManager = class DataSpaceManager2 {
3526
+ var DataSpaceManager = class {
3526
3527
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3527
3528
  this._spaceManager = _spaceManager;
3528
3529
  this._metadataStore = _metadataStore;
@@ -4069,7 +4070,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4069
4070
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4070
4071
  }
4071
4072
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4072
- var ServiceContext = class ServiceContext2 {
4073
+ var ServiceContext = class {
4073
4074
  constructor(storage, networkManager, signalManager, modelFactory) {
4074
4075
  this.storage = storage;
4075
4076
  this.networkManager = networkManager;
@@ -4683,7 +4684,7 @@ var createGenesisMutationFromTypedObject = (obj) => {
4683
4684
  }
4684
4685
  };
4685
4686
  };
4686
- var ClientServicesHost = class ClientServicesHost2 {
4687
+ var ClientServicesHost = class {
4687
4688
  constructor({
4688
4689
  config,
4689
4690
  modelFactory = createDefaultModelFactory(),
@@ -4885,7 +4886,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4885
4886
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4886
4887
  this._serviceRegistry.setServices({
4887
4888
  SystemService: this._systemService,
4888
- 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)),
4889
4890
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4890
4891
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4891
4892
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4999,25 +5000,44 @@ var ClientServicesHost = class ClientServicesHost2 {
4999
5000
  });
5000
5001
  await this._callbacks?.onReset?.();
5001
5002
  }
5002
- async _createIdentity(params) {
5003
+ async _createIdentity(params, useAutomerge) {
5003
5004
  const identity = await this._serviceContext.createIdentity(params);
5004
5005
  await this._serviceContext.initialized.wait();
5005
5006
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5006
5007
  const obj = new import_client_protocol5.Properties(void 0, {
5007
- automerge: false
5008
+ automerge: useAutomerge
5008
5009
  });
5009
5010
  obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5010
- await this._serviceRegistry.services.DataService.write({
5011
- spaceKey: space.key,
5012
- batch: {
5013
- objects: [
5014
- 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
+ ""
5015
5032
  ]
5016
- }
5017
- });
5018
- await this._serviceRegistry.services.DataService.flush({
5019
- spaceKey: space.key
5020
- });
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
+ }
5021
5041
  return identity;
5022
5042
  }
5023
5043
  };
@@ -5072,4 +5092,4 @@ ClientServicesHost = _ts_decorate8([
5072
5092
  subscribeToSpaces,
5073
5093
  subscribeToSwarmInfo
5074
5094
  });
5075
- //# sourceMappingURL=chunk-TJGRH3AQ.cjs.map
5095
+ //# sourceMappingURL=chunk-534INJFX.cjs.map