@dxos/client-services 0.4.4-next.e0df51e → 0.4.5-main.4000b4b

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_CQJYPSCX_exports = {};
30
- __export(chunk_CQJYPSCX_exports, {
29
+ var chunk_HCRT3ULU_exports = {};
30
+ __export(chunk_HCRT3ULU_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_CQJYPSCX_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_CQJYPSCX_exports);
63
+ module.exports = __toCommonJS(chunk_HCRT3ULU_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");
@@ -238,6 +238,7 @@ var import_protocols14 = require("@dxos/protocols");
238
238
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
239
239
  var import_text_model = require("@dxos/text-model");
240
240
  var import_tracing7 = require("@dxos/tracing");
241
+ var import_util9 = require("@dxos/util");
241
242
  var import_websocket_rpc = require("@dxos/websocket-rpc");
242
243
  var import_async16 = require("@dxos/async");
243
244
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
@@ -246,11 +247,11 @@ var import_async17 = require("@dxos/async");
246
247
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
247
248
  var import_log16 = require("@dxos/log");
248
249
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
249
- var import_util9 = require("@dxos/util");
250
+ var import_util10 = require("@dxos/util");
250
251
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
251
252
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
252
253
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
253
- var import_util10 = require("@dxos/util");
254
+ var import_util11 = require("@dxos/util");
254
255
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
255
256
  return new import_codec_protobuf.Stream(({ next }) => {
256
257
  const subscriptions = new import_async.EventSubscriptions();
@@ -1202,7 +1203,6 @@ IdentityManager = _ts_decorate2([
1202
1203
  import_tracing2.trace.resource()
1203
1204
  ], IdentityManager);
1204
1205
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1205
- var CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT = true;
1206
1206
  var IdentityServiceImpl = class {
1207
1207
  constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1208
1208
  this._createIdentity = _createIdentity;
@@ -1211,7 +1211,7 @@ var IdentityServiceImpl = class {
1211
1211
  this._onProfileUpdate = _onProfileUpdate;
1212
1212
  }
1213
1213
  async createIdentity(request) {
1214
- await this._createIdentity(request.profile ?? {}, request.useAutomerge ?? CREATE_PROFILE_WITH_AUTOMERGE_DEFAULT);
1214
+ await this._createIdentity(request.profile ?? {});
1215
1215
  return this._getIdentity();
1216
1216
  }
1217
1217
  async recoverIdentity(request) {
@@ -1239,7 +1239,7 @@ var IdentityServiceImpl = class {
1239
1239
  async updateProfile(profile) {
1240
1240
  (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1241
1241
  F: __dxlog_file4,
1242
- L: 63,
1242
+ L: 61,
1243
1243
  S: this,
1244
1244
  A: [
1245
1245
  "this._identityManager.identity",
@@ -1253,7 +1253,7 @@ var IdentityServiceImpl = class {
1253
1253
  async signPresentation({ presentation, nonce }) {
1254
1254
  (0, import_invariant3.invariant)(this._identityManager.identity, "Identity not initialized.", {
1255
1255
  F: __dxlog_file4,
1256
- L: 70,
1256
+ L: 68,
1257
1257
  S: this,
1258
1258
  A: [
1259
1259
  "this._identityManager.identity",
@@ -2675,7 +2675,7 @@ var getPlatform = () => {
2675
2675
  };
2676
2676
  }
2677
2677
  };
2678
- var DXOS_VERSION = "0.4.4-next.e0df51e";
2678
+ var DXOS_VERSION = "0.4.5-main.4000b4b";
2679
2679
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2680
2680
  var DEFAULT_TIMEOUT = 1e3;
2681
2681
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -4599,15 +4599,15 @@ var LoggingServiceImpl = class {
4599
4599
  }
4600
4600
  async controlMetrics({ reset, record }) {
4601
4601
  if (reset) {
4602
- import_util9.tracer.clear();
4602
+ import_util10.tracer.clear();
4603
4603
  }
4604
4604
  if (record === true) {
4605
- import_util9.tracer.start();
4605
+ import_util10.tracer.start();
4606
4606
  } else if (record === false) {
4607
- import_util9.tracer.stop();
4607
+ import_util10.tracer.stop();
4608
4608
  }
4609
4609
  return {
4610
- recording: import_util9.tracer.recording
4610
+ recording: import_util10.tracer.recording
4611
4611
  };
4612
4612
  }
4613
4613
  /**
@@ -4615,10 +4615,10 @@ var LoggingServiceImpl = class {
4615
4615
  */
4616
4616
  queryMetrics({ interval = 5e3 }) {
4617
4617
  const getNumericalValues = (key) => {
4618
- const events = import_util9.tracer.get(key) ?? [];
4618
+ const events = import_util10.tracer.get(key) ?? [];
4619
4619
  return {
4620
4620
  key,
4621
- stats: (0, import_util9.numericalValues)(events, "duration")
4621
+ stats: (0, import_util10.numericalValues)(events, "duration")
4622
4622
  };
4623
4623
  };
4624
4624
  return new import_codec_protobuf13.Stream(({ next }) => {
@@ -4656,7 +4656,7 @@ var LoggingServiceImpl = class {
4656
4656
  }
4657
4657
  const record = {
4658
4658
  ...entry2,
4659
- context: (0, import_util9.jsonify)((0, import_log16.getContextFromEntry)(entry2)),
4659
+ context: (0, import_util10.jsonify)((0, import_log16.getContextFromEntry)(entry2)),
4660
4660
  timestamp: /* @__PURE__ */ new Date(),
4661
4661
  meta: {
4662
4662
  // TODO(dmaretskyi): Fix proto.
@@ -4741,7 +4741,7 @@ var SystemServiceImpl = class {
4741
4741
  const diagnostics = await this._getDiagnostics();
4742
4742
  return {
4743
4743
  timestamp: /* @__PURE__ */ new Date(),
4744
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
4744
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)({
4745
4745
  truncate: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4746
4746
  humanize: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4747
4747
  })))
@@ -4788,18 +4788,6 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4788
4788
  var createDefaultModelFactory = () => {
4789
4789
  return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
4790
4790
  };
4791
- var createGenesisMutationFromTypedObject = (obj) => {
4792
- const snapshot = obj[import_echo_schema.base]._createSnapshot();
4793
- return {
4794
- objectId: obj[import_echo_schema.base]._id,
4795
- genesis: {
4796
- modelType: obj[import_echo_schema.base]._modelConstructor.meta.type
4797
- },
4798
- snapshot: {
4799
- model: snapshot
4800
- }
4801
- };
4802
- };
4803
4791
  var ClientServicesHost = class {
4804
4792
  constructor({
4805
4793
  config,
@@ -4886,7 +4874,7 @@ var ClientServicesHost = class {
4886
4874
  initialize({ config, ...options }) {
4887
4875
  (0, import_invariant16.invariant)(!this._open, "service host is open", {
4888
4876
  F: __dxlog_file17,
4889
- L: 201,
4877
+ L: 186,
4890
4878
  S: this,
4891
4879
  A: [
4892
4880
  "!this._open",
@@ -4895,14 +4883,14 @@ var ClientServicesHost = class {
4895
4883
  });
4896
4884
  (0, import_log15.log)("initializing...", void 0, {
4897
4885
  F: __dxlog_file17,
4898
- L: 202,
4886
+ L: 187,
4899
4887
  S: this,
4900
4888
  C: (f, a) => f(...a)
4901
4889
  });
4902
4890
  if (config) {
4903
4891
  (0, import_invariant16.invariant)(!this._config, "config already set", {
4904
4892
  F: __dxlog_file17,
4905
- L: 205,
4893
+ L: 190,
4906
4894
  S: this,
4907
4895
  A: [
4908
4896
  "!this._config",
@@ -4920,7 +4908,7 @@ var ClientServicesHost = class {
4920
4908
  this._signalManager = signalManager;
4921
4909
  (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
4922
4910
  F: __dxlog_file17,
4923
- L: 221,
4911
+ L: 206,
4924
4912
  S: this,
4925
4913
  A: [
4926
4914
  "!this._networkManager",
@@ -4934,7 +4922,7 @@ var ClientServicesHost = class {
4934
4922
  });
4935
4923
  (0, import_log15.log)("initialized", void 0, {
4936
4924
  F: __dxlog_file17,
4937
- L: 228,
4925
+ L: 213,
4938
4926
  S: this,
4939
4927
  C: (f, a) => f(...a)
4940
4928
  });
@@ -4948,13 +4936,13 @@ var ClientServicesHost = class {
4948
4936
  id: traceId
4949
4937
  }), {
4950
4938
  F: __dxlog_file17,
4951
- L: 239,
4939
+ L: 224,
4952
4940
  S: this,
4953
4941
  C: (f, a) => f(...a)
4954
4942
  });
4955
4943
  (0, import_invariant16.invariant)(this._config, "config not set", {
4956
4944
  F: __dxlog_file17,
4957
- L: 241,
4945
+ L: 226,
4958
4946
  S: this,
4959
4947
  A: [
4960
4948
  "this._config",
@@ -4963,7 +4951,7 @@ var ClientServicesHost = class {
4963
4951
  });
4964
4952
  (0, import_invariant16.invariant)(this._storage, "storage not set", {
4965
4953
  F: __dxlog_file17,
4966
- L: 242,
4954
+ L: 227,
4967
4955
  S: this,
4968
4956
  A: [
4969
4957
  "this._storage",
@@ -4972,7 +4960,7 @@ var ClientServicesHost = class {
4972
4960
  });
4973
4961
  (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
4974
4962
  F: __dxlog_file17,
4975
- L: 243,
4963
+ L: 228,
4976
4964
  S: this,
4977
4965
  A: [
4978
4966
  "this._signalManager",
@@ -4981,7 +4969,7 @@ var ClientServicesHost = class {
4981
4969
  });
4982
4970
  (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
4983
4971
  F: __dxlog_file17,
4984
- L: 244,
4972
+ L: 229,
4985
4973
  S: this,
4986
4974
  A: [
4987
4975
  "this._networkManager",
@@ -4993,7 +4981,7 @@ var ClientServicesHost = class {
4993
4981
  lockKey: this._resourceLock?.lockKey
4994
4982
  }, {
4995
4983
  F: __dxlog_file17,
4996
- L: 247,
4984
+ L: 232,
4997
4985
  S: this,
4998
4986
  C: (f, a) => f(...a)
4999
4987
  });
@@ -5002,7 +4990,7 @@ var ClientServicesHost = class {
5002
4990
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
5003
4991
  this._serviceRegistry.setServices({
5004
4992
  SystemService: this._systemService,
5005
- IdentityService: new IdentityServiceImpl((params, useAutomerge) => this._createIdentity(params, useAutomerge), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
4993
+ IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
5006
4994
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
5007
4995
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
5008
4996
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -5039,7 +5027,7 @@ var ClientServicesHost = class {
5039
5027
  deviceKey
5040
5028
  }, {
5041
5029
  F: __dxlog_file17,
5042
- L: 320,
5030
+ L: 305,
5043
5031
  S: this,
5044
5032
  C: (f, a) => f(...a)
5045
5033
  });
@@ -5047,7 +5035,7 @@ var ClientServicesHost = class {
5047
5035
  id: traceId
5048
5036
  }), {
5049
5037
  F: __dxlog_file17,
5050
- L: 321,
5038
+ L: 306,
5051
5039
  S: this,
5052
5040
  C: (f, a) => f(...a)
5053
5041
  });
@@ -5061,7 +5049,7 @@ var ClientServicesHost = class {
5061
5049
  deviceKey
5062
5050
  }, {
5063
5051
  F: __dxlog_file17,
5064
- L: 332,
5052
+ L: 317,
5065
5053
  S: this,
5066
5054
  C: (f, a) => f(...a)
5067
5055
  });
@@ -5077,7 +5065,7 @@ var ClientServicesHost = class {
5077
5065
  deviceKey
5078
5066
  }, {
5079
5067
  F: __dxlog_file17,
5080
- L: 339,
5068
+ L: 324,
5081
5069
  S: this,
5082
5070
  C: (f, a) => f(...a)
5083
5071
  });
@@ -5088,13 +5076,13 @@ var ClientServicesHost = class {
5088
5076
  id: traceId
5089
5077
  }), {
5090
5078
  F: __dxlog_file17,
5091
- L: 344,
5079
+ L: 329,
5092
5080
  S: this,
5093
5081
  C: (f, a) => f(...a)
5094
5082
  });
5095
5083
  (0, import_log15.log)("resetting...", void 0, {
5096
5084
  F: __dxlog_file17,
5097
- L: 346,
5085
+ L: 331,
5098
5086
  S: this,
5099
5087
  C: (f, a) => f(...a)
5100
5088
  });
@@ -5102,7 +5090,7 @@ var ClientServicesHost = class {
5102
5090
  await this._storage.reset();
5103
5091
  (0, import_log15.log)("reset", void 0, {
5104
5092
  F: __dxlog_file17,
5105
- L: 349,
5093
+ L: 334,
5106
5094
  S: this,
5107
5095
  C: (f, a) => f(...a)
5108
5096
  });
@@ -5110,50 +5098,36 @@ var ClientServicesHost = class {
5110
5098
  id: traceId
5111
5099
  }), {
5112
5100
  F: __dxlog_file17,
5113
- L: 350,
5101
+ L: 335,
5114
5102
  S: this,
5115
5103
  C: (f, a) => f(...a)
5116
5104
  });
5117
5105
  await this._callbacks?.onReset?.();
5118
5106
  }
5119
- async _createIdentity(params, useAutomerge) {
5107
+ async _createIdentity(params) {
5120
5108
  const identity = await this._serviceContext.createIdentity(params);
5121
5109
  await this._serviceContext.initialized.wait();
5122
5110
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5123
- const obj = new import_client_protocol5.Properties(void 0, {
5124
- automerge: useAutomerge
5125
- });
5111
+ const obj = new import_client_protocol5.Properties(void 0);
5126
5112
  obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5127
- if (!useAutomerge) {
5128
- await this._serviceRegistry.services.DataService.write({
5129
- spaceKey: space.key,
5130
- batch: {
5131
- objects: [
5132
- createGenesisMutationFromTypedObject(obj)
5133
- ]
5134
- }
5135
- });
5136
- await this._serviceRegistry.services.DataService.flush({
5137
- spaceKey: space.key
5138
- });
5139
- } else {
5140
- const automergeIndex = space.automergeSpaceState.rootUrl;
5141
- (0, import_invariant16.invariant)(automergeIndex, void 0, {
5142
- F: __dxlog_file17,
5143
- L: 375,
5144
- S: this,
5145
- A: [
5146
- "automergeIndex",
5147
- ""
5148
- ]
5149
- });
5150
- const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5151
- await document.whenReady();
5152
- document.change((doc) => {
5153
- doc.objects ??= {};
5154
- doc.objects[obj[import_echo_schema.base]._id] = (0, import_echo_schema.getRawDoc)(obj).handle.docSync();
5155
- });
5156
- }
5113
+ const automergeIndex = space.automergeSpaceState.rootUrl;
5114
+ (0, import_invariant16.invariant)(automergeIndex, void 0, {
5115
+ F: __dxlog_file17,
5116
+ L: 350,
5117
+ S: this,
5118
+ A: [
5119
+ "automergeIndex",
5120
+ ""
5121
+ ]
5122
+ });
5123
+ const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5124
+ await document.whenReady();
5125
+ document.change((doc) => {
5126
+ (0, import_util9.assignDeep)(doc, [
5127
+ "objects",
5128
+ obj[import_echo_schema.base]._id
5129
+ ], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
5130
+ });
5157
5131
  return identity;
5158
5132
  }
5159
5133
  };
@@ -5208,4 +5182,4 @@ ClientServicesHost = _ts_decorate8([
5208
5182
  subscribeToSpaces,
5209
5183
  subscribeToSwarmInfo
5210
5184
  });
5211
- //# sourceMappingURL=chunk-CQJYPSCX.cjs.map
5185
+ //# sourceMappingURL=chunk-HCRT3ULU.cjs.map