@dxos/client-services 0.4.10-main.cd13a57 → 0.4.10-main.cfbf503

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.
Files changed (47) hide show
  1. package/dist/lib/browser/{chunk-UFFMYQPD.mjs → chunk-PPCSGOUM.mjs} +116 -73
  2. package/dist/lib/browser/{chunk-UFFMYQPD.mjs.map → chunk-PPCSGOUM.mjs.map} +4 -4
  3. package/dist/lib/browser/index.mjs +3 -1
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +6 -4
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-73BOAPSS.cjs → chunk-5O2MOLHJ.cjs} +109 -71
  9. package/dist/lib/node/{chunk-73BOAPSS.cjs.map → chunk-5O2MOLHJ.cjs.map} +4 -4
  10. package/dist/lib/node/index.cjs +39 -37
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +10 -8
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/packlets/indexing/util.d.ts +2 -2
  16. package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-context.d.ts +7 -5
  18. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  22. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  23. package/dist/types/src/packlets/storage/level.d.ts +4 -0
  24. package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
  25. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  26. package/dist/types/src/packlets/storage/util.d.ts +4 -0
  27. package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
  28. package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
  29. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  30. package/dist/types/src/version.d.ts +1 -1
  31. package/package.json +35 -34
  32. package/src/packlets/devices/devices-service.test.ts +1 -1
  33. package/src/packlets/identity/identity-service.test.ts +1 -1
  34. package/src/packlets/indexing/util.ts +4 -4
  35. package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
  36. package/src/packlets/network/network-service.test.ts +1 -1
  37. package/src/packlets/services/service-context.test.ts +5 -5
  38. package/src/packlets/services/service-context.ts +13 -8
  39. package/src/packlets/services/service-host.ts +29 -8
  40. package/src/packlets/services/service-registry.test.ts +1 -1
  41. package/src/packlets/spaces/spaces-service.test.ts +1 -1
  42. package/src/packlets/storage/index.ts +1 -0
  43. package/src/packlets/storage/level.ts +19 -0
  44. package/src/packlets/storage/storage.ts +3 -9
  45. package/src/packlets/storage/util.ts +19 -0
  46. package/src/packlets/testing/test-builder.ts +5 -3
  47. package/src/version.ts +1 -1
@@ -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_73BOAPSS_exports = {};
30
- __export(chunk_73BOAPSS_exports, {
29
+ var chunk_5O2MOLHJ_exports = {};
30
+ __export(chunk_5O2MOLHJ_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -48,6 +48,7 @@ __export(chunk_73BOAPSS_exports, {
48
48
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
49
49
  createAuthProvider: () => createAuthProvider,
50
50
  createDiagnostics: () => createDiagnostics,
51
+ createLevel: () => createLevel,
51
52
  createStorageObjects: () => createStorageObjects,
52
53
  getNetworkPeers: () => getNetworkPeers,
53
54
  invitationExpired: () => invitationExpired,
@@ -60,7 +61,7 @@ __export(chunk_73BOAPSS_exports, {
60
61
  subscribeToSpaces: () => subscribeToSpaces,
61
62
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
63
  });
63
- module.exports = __toCommonJS(chunk_73BOAPSS_exports);
64
+ module.exports = __toCommonJS(chunk_5O2MOLHJ_exports);
64
65
  var import_async = require("@dxos/async");
65
66
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
67
  var import_feed_store = require("@dxos/feed-store");
@@ -223,19 +224,23 @@ var import_protocols13 = require("@dxos/protocols");
223
224
  var import_invariant15 = require("@dxos/invariant");
224
225
  var import_lock_file = require("@dxos/lock-file");
225
226
  var import_log13 = require("@dxos/log");
226
- var import_client_protocol4 = require("@dxos/client-protocol");
227
227
  var import_protocols14 = require("@dxos/protocols");
228
228
  var import_config = require("@dxos/protocols/proto/dxos/config");
229
229
  var import_random_access_storage = require("@dxos/random-access-storage");
230
+ var import_client_protocol4 = require("@dxos/client-protocol");
231
+ var import_config2 = require("@dxos/protocols/proto/dxos/config");
230
232
  var import_util8 = require("@dxos/util");
233
+ var import_level = require("level");
234
+ var import_node_path = __toESM(require("node:path"));
235
+ var import_keys11 = require("@dxos/keys");
231
236
  var import_async16 = require("@dxos/async");
232
237
  var import_client_protocol5 = require("@dxos/client-protocol");
233
238
  var import_context11 = require("@dxos/context");
234
239
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
235
- var import_echo_schema = require("@dxos/echo-schema");
240
+ var E = __toESM(require("@dxos/echo-schema"));
236
241
  var import_indexing2 = require("@dxos/indexing");
237
242
  var import_invariant16 = require("@dxos/invariant");
238
- var import_keys11 = require("@dxos/keys");
243
+ var import_keys12 = require("@dxos/keys");
239
244
  var import_log14 = require("@dxos/log");
240
245
  var import_messaging = require("@dxos/messaging");
241
246
  var import_network_manager2 = require("@dxos/network-manager");
@@ -250,7 +255,7 @@ var import_invariant17 = require("@dxos/invariant");
250
255
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
251
256
  var import_async18 = require("@dxos/async");
252
257
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
253
- var import_keys12 = require("@dxos/keys");
258
+ var import_keys13 = require("@dxos/keys");
254
259
  var import_log15 = require("@dxos/log");
255
260
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
256
261
  var import_util10 = require("@dxos/util");
@@ -2886,7 +2891,7 @@ var getPlatform = () => {
2886
2891
  };
2887
2892
  }
2888
2893
  };
2889
- var DXOS_VERSION = "0.4.10-main.cd13a57";
2894
+ var DXOS_VERSION = "0.4.10-main.cfbf503";
2890
2895
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2891
2896
  var DEFAULT_TIMEOUT = 1e3;
2892
2897
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -4431,7 +4436,7 @@ var SpacesServiceImpl = class {
4431
4436
  }
4432
4437
  };
4433
4438
  var getChannelId = (channel) => `user-channel/${channel}`;
4434
- var createLoadDocuments = (automergeHost) => (
4439
+ var createSelectedDocumentsIterator = (automergeHost) => (
4435
4440
  /**
4436
4441
  * Get object data blobs from Automerge Repo by ids.
4437
4442
  * @param ids
@@ -4444,17 +4449,17 @@ var createLoadDocuments = (automergeHost) => (
4444
4449
  await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4445
4450
  const doc = handle.docSync();
4446
4451
  const hash = (0, import_automerge.getHeads)(doc).join("");
4447
- yield [
4452
+ yield doc.objects?.[objectId] ? [
4448
4453
  {
4449
4454
  id,
4450
4455
  object: doc.objects[objectId],
4451
4456
  currentHash: hash
4452
4457
  }
4453
- ];
4458
+ ] : [];
4454
4459
  }
4455
4460
  }
4456
4461
  );
4457
- var createGetAllDocuments = (automergeHost) => (
4462
+ var createDocumentsIterator = (automergeHost) => (
4458
4463
  /**
4459
4464
  * Recursively get all object data blobs from Automerge Repo.
4460
4465
  * @param ids
@@ -4477,7 +4482,7 @@ var createGetAllDocuments = (automergeHost) => (
4477
4482
  objectId
4478
4483
  }),
4479
4484
  object,
4480
- currentHash: heads.at(-1)
4485
+ currentHash: heads.join("")
4481
4486
  };
4482
4487
  });
4483
4488
  }
@@ -4516,9 +4521,11 @@ function _ts_decorate6(decorators, target, key, desc) {
4516
4521
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4517
4522
  }
4518
4523
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4519
- var ServiceContext = class {
4520
- constructor(storage, networkManager, signalManager, _runtimeParams) {
4524
+ var ServiceContext = class extends import_context10.Resource {
4525
+ constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4526
+ super();
4521
4527
  this.storage = storage;
4528
+ this.level = level;
4522
4529
  this.networkManager = networkManager;
4523
4530
  this.signalManager = signalManager;
4524
4531
  this._runtimeParams = _runtimeParams;
@@ -4548,7 +4555,7 @@ var ServiceContext = class {
4548
4555
  });
4549
4556
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4550
4557
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4551
- directory: storage.createDirectory("index-metadata")
4558
+ db: level.sublevel("index-metadata")
4552
4559
  });
4553
4560
  this.automergeHost = new import_echo_pipeline3.AutomergeHost({
4554
4561
  directory: storage.createDirectory("automerge"),
@@ -4559,17 +4566,17 @@ var ServiceContext = class {
4559
4566
  directory: storage.createDirectory("index-store")
4560
4567
  }),
4561
4568
  metadataStore: this.indexMetadata,
4562
- loadDocuments: createLoadDocuments(this.automergeHost),
4563
- getAllDocuments: createGetAllDocuments(this.automergeHost)
4569
+ loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
4570
+ getAllDocuments: createDocumentsIterator(this.automergeHost)
4564
4571
  });
4565
4572
  this.invitations = new InvitationsHandler(this.networkManager);
4566
4573
  this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4567
4574
  }
4568
- async open(ctx) {
4575
+ async _open(ctx) {
4569
4576
  await this._checkStorageVersion();
4570
4577
  (0, import_log12.log)("opening...", void 0, {
4571
4578
  F: __dxlog_file15,
4572
- L: 151,
4579
+ L: 156,
4573
4580
  S: this,
4574
4581
  C: (f, a) => f(...a)
4575
4582
  });
@@ -4577,7 +4584,7 @@ var ServiceContext = class {
4577
4584
  id: this._instanceId
4578
4585
  }), {
4579
4586
  F: __dxlog_file15,
4580
- L: 152,
4587
+ L: 157,
4581
4588
  S: this,
4582
4589
  C: (f, a) => f(...a)
4583
4590
  });
@@ -4593,21 +4600,21 @@ var ServiceContext = class {
4593
4600
  id: this._instanceId
4594
4601
  }), {
4595
4602
  F: __dxlog_file15,
4596
- L: 162,
4603
+ L: 167,
4597
4604
  S: this,
4598
4605
  C: (f, a) => f(...a)
4599
4606
  });
4600
4607
  (0, import_log12.log)("opened", void 0, {
4601
4608
  F: __dxlog_file15,
4602
- L: 163,
4609
+ L: 168,
4603
4610
  S: this,
4604
4611
  C: (f, a) => f(...a)
4605
4612
  });
4606
4613
  }
4607
- async close() {
4614
+ async _close() {
4608
4615
  (0, import_log12.log)("closing...", void 0, {
4609
4616
  F: __dxlog_file15,
4610
- L: 167,
4617
+ L: 172,
4611
4618
  S: this,
4612
4619
  C: (f, a) => f(...a)
4613
4620
  });
@@ -4625,7 +4632,7 @@ var ServiceContext = class {
4625
4632
  await this.indexer.destroy();
4626
4633
  (0, import_log12.log)("closed", void 0, {
4627
4634
  F: __dxlog_file15,
4628
- L: 180,
4635
+ L: 185,
4629
4636
  S: this,
4630
4637
  C: (f, a) => f(...a)
4631
4638
  });
@@ -4639,7 +4646,7 @@ var ServiceContext = class {
4639
4646
  const factory = this._handlerFactories.get(invitation.kind);
4640
4647
  (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4641
4648
  F: __dxlog_file15,
4642
- L: 191,
4649
+ L: 196,
4643
4650
  S: this,
4644
4651
  A: [
4645
4652
  "factory",
@@ -4671,7 +4678,7 @@ var ServiceContext = class {
4671
4678
  async _initialize(ctx) {
4672
4679
  (0, import_log12.log)("initializing spaces...", void 0, {
4673
4680
  F: __dxlog_file15,
4674
- L: 222,
4681
+ L: 227,
4675
4682
  S: this,
4676
4683
  C: (f, a) => f(...a)
4677
4684
  });
@@ -4694,7 +4701,7 @@ var ServiceContext = class {
4694
4701
  this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4695
4702
  (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4696
4703
  F: __dxlog_file15,
4697
- L: 246,
4704
+ L: 251,
4698
4705
  S: this,
4699
4706
  A: [
4700
4707
  "this.dataSpaceManager",
@@ -4718,7 +4725,7 @@ var ServiceContext = class {
4718
4725
  details: assertion
4719
4726
  }, {
4720
4727
  F: __dxlog_file15,
4721
- L: 262,
4728
+ L: 267,
4722
4729
  S: this,
4723
4730
  C: (f, a) => f(...a)
4724
4731
  });
@@ -4729,7 +4736,7 @@ var ServiceContext = class {
4729
4736
  details: assertion
4730
4737
  }, {
4731
4738
  F: __dxlog_file15,
4732
- L: 266,
4739
+ L: 271,
4733
4740
  S: this,
4734
4741
  C: (f, a) => f(...a)
4735
4742
  });
@@ -4740,7 +4747,7 @@ var ServiceContext = class {
4740
4747
  details: assertion
4741
4748
  }, {
4742
4749
  F: __dxlog_file15,
4743
- L: 271,
4750
+ L: 276,
4744
4751
  S: this,
4745
4752
  C: (f, a) => f(...a)
4746
4753
  });
@@ -4751,7 +4758,7 @@ var ServiceContext = class {
4751
4758
  } catch (err) {
4752
4759
  import_log12.log.catch(err, void 0, {
4753
4760
  F: __dxlog_file15,
4754
- L: 277,
4761
+ L: 282,
4755
4762
  S: this,
4756
4763
  C: (f, a) => f(...a)
4757
4764
  });
@@ -4763,7 +4770,7 @@ var ServiceContext = class {
4763
4770
  };
4764
4771
  _ts_decorate6([
4765
4772
  import_tracing6.trace.span()
4766
- ], ServiceContext.prototype, "open", null);
4773
+ ], ServiceContext.prototype, "_open", null);
4767
4774
  _ts_decorate6([
4768
4775
  import_tracing6.trace.span()
4769
4776
  ], ServiceContext.prototype, "_initialize", null);
@@ -4847,9 +4854,17 @@ _ts_decorate7([
4847
4854
  import_log13.logInfo
4848
4855
  ], Lock.prototype, "lockKey", null);
4849
4856
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4857
+ var getRootPath = (config) => {
4858
+ const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4859
+ return `${dataRoot}/`;
4860
+ };
4861
+ var isPersistent = (config) => {
4862
+ const { persistent = false } = config ?? {};
4863
+ return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
4864
+ };
4850
4865
  var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4851
4866
  var createStorageObjects = (config) => {
4852
- const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4867
+ const { persistent = false, keyStore, dataStore } = config ?? {};
4853
4868
  if (persistent && dataStore === StorageDriver.RAM) {
4854
4869
  throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
4855
4870
  }
@@ -4865,7 +4880,7 @@ var createStorageObjects = (config) => {
4865
4880
  return {
4866
4881
  storage: (0, import_random_access_storage.createStorage)({
4867
4882
  type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
4868
- root: `${dataRoot}/`
4883
+ root: getRootPath(config)
4869
4884
  })
4870
4885
  };
4871
4886
  };
@@ -4889,6 +4904,13 @@ var toStorageType = (type) => {
4889
4904
  throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4890
4905
  }
4891
4906
  };
4907
+ var createLevel = async (config) => {
4908
+ const persistent = isPersistent(config);
4909
+ const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
4910
+ const level = new import_level.Level(storagePath);
4911
+ await level.open();
4912
+ return level;
4913
+ };
4892
4914
  var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4893
4915
  var DevicesServiceImpl = class {
4894
4916
  constructor(_identityManager) {
@@ -4969,7 +4991,7 @@ var LoggingServiceImpl = class {
4969
4991
  constructor() {
4970
4992
  this._logs = new import_async18.Event();
4971
4993
  this._started = Date.now();
4972
- this._sessionId = import_keys12.PublicKey.random().toHex();
4994
+ this._sessionId = import_keys13.PublicKey.random().toHex();
4973
4995
  this._logProcessor = (_config, entry2) => {
4974
4996
  this._logs.emit(entry2);
4975
4997
  };
@@ -5064,12 +5086,12 @@ var LoggingServiceImpl = class {
5064
5086
  });
5065
5087
  }
5066
5088
  };
5067
- var matchFilter = (filter, level, path, options) => {
5089
+ var matchFilter = (filter, level, path2, options) => {
5068
5090
  switch (options) {
5069
5091
  case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5070
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
5092
+ return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5071
5093
  case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
5072
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
5094
+ return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5073
5095
  }
5074
5096
  };
5075
5097
  var shouldLog = (entry2, request) => {
@@ -5260,7 +5282,7 @@ var ClientServicesHost = class {
5260
5282
  initialize({ config, ...options }) {
5261
5283
  (0, import_invariant16.invariant)(!this._open, "service host is open", {
5262
5284
  F: __dxlog_file18,
5263
- L: 179,
5285
+ L: 182,
5264
5286
  S: this,
5265
5287
  A: [
5266
5288
  "!this._open",
@@ -5269,14 +5291,14 @@ var ClientServicesHost = class {
5269
5291
  });
5270
5292
  (0, import_log14.log)("initializing...", void 0, {
5271
5293
  F: __dxlog_file18,
5272
- L: 180,
5294
+ L: 183,
5273
5295
  S: this,
5274
5296
  C: (f, a) => f(...a)
5275
5297
  });
5276
5298
  if (config) {
5277
5299
  (0, import_invariant16.invariant)(!this._config, "config already set", {
5278
5300
  F: __dxlog_file18,
5279
- L: 183,
5301
+ L: 186,
5280
5302
  S: this,
5281
5303
  A: [
5282
5304
  "!this._config",
@@ -5291,7 +5313,7 @@ var ClientServicesHost = class {
5291
5313
  if (!options.signalManager) {
5292
5314
  import_log14.log.warn("running signaling without telemetry metadata.", void 0, {
5293
5315
  F: __dxlog_file18,
5294
- L: 191,
5316
+ L: 194,
5295
5317
  S: this,
5296
5318
  C: (f, a) => f(...a)
5297
5319
  });
@@ -5302,7 +5324,7 @@ var ClientServicesHost = class {
5302
5324
  this._signalManager = signalManager;
5303
5325
  (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5304
5326
  F: __dxlog_file18,
5305
- L: 202,
5327
+ L: 205,
5306
5328
  S: this,
5307
5329
  A: [
5308
5330
  "!this._networkManager",
@@ -5316,7 +5338,7 @@ var ClientServicesHost = class {
5316
5338
  });
5317
5339
  (0, import_log14.log)("initialized", void 0, {
5318
5340
  F: __dxlog_file18,
5319
- L: 209,
5341
+ L: 212,
5320
5342
  S: this,
5321
5343
  C: (f, a) => f(...a)
5322
5344
  });
@@ -5325,18 +5347,18 @@ var ClientServicesHost = class {
5325
5347
  if (this._open) {
5326
5348
  return;
5327
5349
  }
5328
- const traceId = import_keys11.PublicKey.random().toHex();
5350
+ const traceId = import_keys12.PublicKey.random().toHex();
5329
5351
  import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
5330
5352
  id: traceId
5331
5353
  }), {
5332
5354
  F: __dxlog_file18,
5333
- L: 220,
5355
+ L: 223,
5334
5356
  S: this,
5335
5357
  C: (f, a) => f(...a)
5336
5358
  });
5337
5359
  (0, import_invariant16.invariant)(this._config, "config not set", {
5338
5360
  F: __dxlog_file18,
5339
- L: 222,
5361
+ L: 225,
5340
5362
  S: this,
5341
5363
  A: [
5342
5364
  "this._config",
@@ -5345,7 +5367,7 @@ var ClientServicesHost = class {
5345
5367
  });
5346
5368
  (0, import_invariant16.invariant)(this._storage, "storage not set", {
5347
5369
  F: __dxlog_file18,
5348
- L: 223,
5370
+ L: 226,
5349
5371
  S: this,
5350
5372
  A: [
5351
5373
  "this._storage",
@@ -5354,7 +5376,7 @@ var ClientServicesHost = class {
5354
5376
  });
5355
5377
  (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5356
5378
  F: __dxlog_file18,
5357
- L: 224,
5379
+ L: 227,
5358
5380
  S: this,
5359
5381
  A: [
5360
5382
  "this._signalManager",
@@ -5363,7 +5385,7 @@ var ClientServicesHost = class {
5363
5385
  });
5364
5386
  (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5365
5387
  F: __dxlog_file18,
5366
- L: 225,
5388
+ L: 228,
5367
5389
  S: this,
5368
5390
  A: [
5369
5391
  "this._networkManager",
@@ -5375,13 +5397,16 @@ var ClientServicesHost = class {
5375
5397
  lockKey: this._resourceLock?.lockKey
5376
5398
  }, {
5377
5399
  F: __dxlog_file18,
5378
- L: 228,
5400
+ L: 231,
5379
5401
  S: this,
5380
5402
  C: (f, a) => f(...a)
5381
5403
  });
5404
+ if (!this._level) {
5405
+ this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5406
+ }
5382
5407
  await this._resourceLock?.acquire();
5383
5408
  await this._loggingService.open();
5384
- this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
5409
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
5385
5410
  this._serviceRegistry.setServices({
5386
5411
  SystemService: this._systemService,
5387
5412
  IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
@@ -5409,7 +5434,7 @@ var ClientServicesHost = class {
5409
5434
  await this._serviceContext.open(ctx);
5410
5435
  (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5411
5436
  F: __dxlog_file18,
5412
- L: 289,
5437
+ L: 297,
5413
5438
  S: this,
5414
5439
  A: [
5415
5440
  "this.serviceRegistry.services.InvitationsService",
@@ -5421,7 +5446,7 @@ var ClientServicesHost = class {
5421
5446
  count: loadedInvitations.invitations?.length
5422
5447
  }, {
5423
5448
  F: __dxlog_file18,
5424
- L: 292,
5449
+ L: 300,
5425
5450
  S: this,
5426
5451
  C: (f, a) => f(...a)
5427
5452
  });
@@ -5443,7 +5468,7 @@ var ClientServicesHost = class {
5443
5468
  deviceKey
5444
5469
  }, {
5445
5470
  F: __dxlog_file18,
5446
- L: 309,
5471
+ L: 317,
5447
5472
  S: this,
5448
5473
  C: (f, a) => f(...a)
5449
5474
  });
@@ -5451,7 +5476,7 @@ var ClientServicesHost = class {
5451
5476
  id: traceId
5452
5477
  }), {
5453
5478
  F: __dxlog_file18,
5454
- L: 310,
5479
+ L: 318,
5455
5480
  S: this,
5456
5481
  C: (f, a) => f(...a)
5457
5482
  });
@@ -5465,7 +5490,7 @@ var ClientServicesHost = class {
5465
5490
  deviceKey
5466
5491
  }, {
5467
5492
  F: __dxlog_file18,
5468
- L: 321,
5493
+ L: 329,
5469
5494
  S: this,
5470
5495
  C: (f, a) => f(...a)
5471
5496
  });
@@ -5475,30 +5500,31 @@ var ClientServicesHost = class {
5475
5500
  });
5476
5501
  await this._loggingService.close();
5477
5502
  await this._serviceContext.close();
5503
+ await this._level?.close();
5478
5504
  this._open = false;
5479
5505
  this._statusUpdate.emit();
5480
5506
  (0, import_log14.log)("closed", {
5481
5507
  deviceKey
5482
5508
  }, {
5483
5509
  F: __dxlog_file18,
5484
- L: 328,
5510
+ L: 337,
5485
5511
  S: this,
5486
5512
  C: (f, a) => f(...a)
5487
5513
  });
5488
5514
  }
5489
5515
  async reset() {
5490
- const traceId = import_keys11.PublicKey.random().toHex();
5516
+ const traceId = import_keys12.PublicKey.random().toHex();
5491
5517
  import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
5492
5518
  id: traceId
5493
5519
  }), {
5494
5520
  F: __dxlog_file18,
5495
- L: 333,
5521
+ L: 342,
5496
5522
  S: this,
5497
5523
  C: (f, a) => f(...a)
5498
5524
  });
5499
5525
  (0, import_log14.log)("resetting...", void 0, {
5500
5526
  F: __dxlog_file18,
5501
- L: 335,
5527
+ L: 344,
5502
5528
  S: this,
5503
5529
  C: (f, a) => f(...a)
5504
5530
  });
@@ -5506,7 +5532,7 @@ var ClientServicesHost = class {
5506
5532
  await this._storage.reset();
5507
5533
  (0, import_log14.log)("reset", void 0, {
5508
5534
  F: __dxlog_file18,
5509
- L: 338,
5535
+ L: 347,
5510
5536
  S: this,
5511
5537
  C: (f, a) => f(...a)
5512
5538
  });
@@ -5514,7 +5540,7 @@ var ClientServicesHost = class {
5514
5540
  id: traceId
5515
5541
  }), {
5516
5542
  F: __dxlog_file18,
5517
- L: 339,
5543
+ L: 348,
5518
5544
  S: this,
5519
5545
  C: (f, a) => f(...a)
5520
5546
  });
@@ -5524,12 +5550,10 @@ var ClientServicesHost = class {
5524
5550
  const identity = await this._serviceContext.createIdentity(params);
5525
5551
  await this._serviceContext.initialized.wait();
5526
5552
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5527
- const obj = new import_client_protocol5.Properties(void 0);
5528
- obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5529
5553
  const automergeIndex = space.automergeSpaceState.rootUrl;
5530
5554
  (0, import_invariant16.invariant)(automergeIndex, void 0, {
5531
5555
  F: __dxlog_file18,
5532
- L: 354,
5556
+ L: 360,
5533
5557
  S: this,
5534
5558
  A: [
5535
5559
  "automergeIndex",
@@ -5538,12 +5562,25 @@ var ClientServicesHost = class {
5538
5562
  });
5539
5563
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5540
5564
  await document.whenReady();
5565
+ const properties = {
5566
+ system: {
5567
+ type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol5.Properties))
5568
+ },
5569
+ data: {
5570
+ [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5571
+ },
5572
+ meta: {
5573
+ keys: []
5574
+ }
5575
+ };
5576
+ const propertiesId = import_keys12.PublicKey.random().toHex();
5541
5577
  document.change((doc) => {
5542
5578
  (0, import_util9.assignDeep)(doc, [
5543
5579
  "objects",
5544
- (0, import_echo_schema.getAutomergeObjectCore)(obj).id
5545
- ], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
5580
+ propertiesId
5581
+ ], properties);
5546
5582
  });
5583
+ await this._serviceContext.automergeHost.repo.flush();
5547
5584
  return identity;
5548
5585
  }
5549
5586
  };
@@ -5586,6 +5623,7 @@ ClientServicesHost = _ts_decorate8([
5586
5623
  TrustedKeySetAuthVerifier,
5587
5624
  createAuthProvider,
5588
5625
  createDiagnostics,
5626
+ createLevel,
5589
5627
  createStorageObjects,
5590
5628
  getNetworkPeers,
5591
5629
  invitationExpired,
@@ -5598,4 +5636,4 @@ ClientServicesHost = _ts_decorate8([
5598
5636
  subscribeToSpaces,
5599
5637
  subscribeToSwarmInfo
5600
5638
  });
5601
- //# sourceMappingURL=chunk-73BOAPSS.cjs.map
5639
+ //# sourceMappingURL=chunk-5O2MOLHJ.cjs.map