@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
@@ -2769,7 +2769,7 @@ var getPlatform = () => {
2769
2769
  };
2770
2770
 
2771
2771
  // packages/sdk/client-services/src/version.ts
2772
- var DXOS_VERSION = "0.4.10-main.cd13a57";
2772
+ var DXOS_VERSION = "0.4.10-main.cfbf503";
2773
2773
 
2774
2774
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2775
2775
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -4386,7 +4386,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
4386
4386
 
4387
4387
  // packages/sdk/client-services/src/packlets/services/service-context.ts
4388
4388
  import { Trigger as Trigger5 } from "@dxos/async";
4389
- import { Context as Context10 } from "@dxos/context";
4389
+ import { Context as Context10, Resource } from "@dxos/context";
4390
4390
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4391
4391
  import { failUndefined as failUndefined2 } from "@dxos/debug";
4392
4392
  import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
@@ -4406,7 +4406,7 @@ import { safeInstanceof } from "@dxos/util";
4406
4406
  import { getHeads } from "@dxos/automerge/automerge";
4407
4407
  import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
4408
4408
  import { idCodec } from "@dxos/protocols";
4409
- var createLoadDocuments = (automergeHost) => (
4409
+ var createSelectedDocumentsIterator = (automergeHost) => (
4410
4410
  /**
4411
4411
  * Get object data blobs from Automerge Repo by ids.
4412
4412
  * @param ids
@@ -4419,17 +4419,17 @@ var createLoadDocuments = (automergeHost) => (
4419
4419
  await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
4420
4420
  const doc = handle.docSync();
4421
4421
  const hash = getHeads(doc).join("");
4422
- yield [
4422
+ yield doc.objects?.[objectId] ? [
4423
4423
  {
4424
4424
  id,
4425
4425
  object: doc.objects[objectId],
4426
4426
  currentHash: hash
4427
4427
  }
4428
- ];
4428
+ ] : [];
4429
4429
  }
4430
4430
  }
4431
4431
  );
4432
- var createGetAllDocuments = (automergeHost) => (
4432
+ var createDocumentsIterator = (automergeHost) => (
4433
4433
  /**
4434
4434
  * Recursively get all object data blobs from Automerge Repo.
4435
4435
  * @param ids
@@ -4452,7 +4452,7 @@ var createGetAllDocuments = (automergeHost) => (
4452
4452
  objectId
4453
4453
  }),
4454
4454
  object,
4455
- currentHash: heads.at(-1)
4455
+ currentHash: heads.join("")
4456
4456
  };
4457
4457
  });
4458
4458
  }
@@ -4493,9 +4493,11 @@ function _ts_decorate6(decorators, target, key, desc) {
4493
4493
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4494
4494
  }
4495
4495
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4496
- var ServiceContext = class {
4497
- constructor(storage, networkManager, signalManager, _runtimeParams) {
4496
+ var ServiceContext = class extends Resource {
4497
+ constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4498
+ super();
4498
4499
  this.storage = storage;
4500
+ this.level = level;
4499
4501
  this.networkManager = networkManager;
4500
4502
  this.signalManager = signalManager;
4501
4503
  this._runtimeParams = _runtimeParams;
@@ -4525,7 +4527,7 @@ var ServiceContext = class {
4525
4527
  });
4526
4528
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4527
4529
  this.indexMetadata = new IndexMetadataStore({
4528
- directory: storage.createDirectory("index-metadata")
4530
+ db: level.sublevel("index-metadata")
4529
4531
  });
4530
4532
  this.automergeHost = new AutomergeHost({
4531
4533
  directory: storage.createDirectory("automerge"),
@@ -4536,17 +4538,17 @@ var ServiceContext = class {
4536
4538
  directory: storage.createDirectory("index-store")
4537
4539
  }),
4538
4540
  metadataStore: this.indexMetadata,
4539
- loadDocuments: createLoadDocuments(this.automergeHost),
4540
- getAllDocuments: createGetAllDocuments(this.automergeHost)
4541
+ loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
4542
+ getAllDocuments: createDocumentsIterator(this.automergeHost)
4541
4543
  });
4542
4544
  this.invitations = new InvitationsHandler(this.networkManager);
4543
4545
  this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
4544
4546
  }
4545
- async open(ctx) {
4547
+ async _open(ctx) {
4546
4548
  await this._checkStorageVersion();
4547
4549
  log12("opening...", void 0, {
4548
4550
  F: __dxlog_file15,
4549
- L: 151,
4551
+ L: 156,
4550
4552
  S: this,
4551
4553
  C: (f, a) => f(...a)
4552
4554
  });
@@ -4554,7 +4556,7 @@ var ServiceContext = class {
4554
4556
  id: this._instanceId
4555
4557
  }), {
4556
4558
  F: __dxlog_file15,
4557
- L: 152,
4559
+ L: 157,
4558
4560
  S: this,
4559
4561
  C: (f, a) => f(...a)
4560
4562
  });
@@ -4570,21 +4572,21 @@ var ServiceContext = class {
4570
4572
  id: this._instanceId
4571
4573
  }), {
4572
4574
  F: __dxlog_file15,
4573
- L: 162,
4575
+ L: 167,
4574
4576
  S: this,
4575
4577
  C: (f, a) => f(...a)
4576
4578
  });
4577
4579
  log12("opened", void 0, {
4578
4580
  F: __dxlog_file15,
4579
- L: 163,
4581
+ L: 168,
4580
4582
  S: this,
4581
4583
  C: (f, a) => f(...a)
4582
4584
  });
4583
4585
  }
4584
- async close() {
4586
+ async _close() {
4585
4587
  log12("closing...", void 0, {
4586
4588
  F: __dxlog_file15,
4587
- L: 167,
4589
+ L: 172,
4588
4590
  S: this,
4589
4591
  C: (f, a) => f(...a)
4590
4592
  });
@@ -4602,7 +4604,7 @@ var ServiceContext = class {
4602
4604
  await this.indexer.destroy();
4603
4605
  log12("closed", void 0, {
4604
4606
  F: __dxlog_file15,
4605
- L: 180,
4607
+ L: 185,
4606
4608
  S: this,
4607
4609
  C: (f, a) => f(...a)
4608
4610
  });
@@ -4616,7 +4618,7 @@ var ServiceContext = class {
4616
4618
  const factory = this._handlerFactories.get(invitation.kind);
4617
4619
  invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
4618
4620
  F: __dxlog_file15,
4619
- L: 191,
4621
+ L: 196,
4620
4622
  S: this,
4621
4623
  A: [
4622
4624
  "factory",
@@ -4648,7 +4650,7 @@ var ServiceContext = class {
4648
4650
  async _initialize(ctx) {
4649
4651
  log12("initializing spaces...", void 0, {
4650
4652
  F: __dxlog_file15,
4651
- L: 222,
4653
+ L: 227,
4652
4654
  S: this,
4653
4655
  C: (f, a) => f(...a)
4654
4656
  });
@@ -4671,7 +4673,7 @@ var ServiceContext = class {
4671
4673
  this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
4672
4674
  invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4673
4675
  F: __dxlog_file15,
4674
- L: 246,
4676
+ L: 251,
4675
4677
  S: this,
4676
4678
  A: [
4677
4679
  "this.dataSpaceManager",
@@ -4695,7 +4697,7 @@ var ServiceContext = class {
4695
4697
  details: assertion
4696
4698
  }, {
4697
4699
  F: __dxlog_file15,
4698
- L: 262,
4700
+ L: 267,
4699
4701
  S: this,
4700
4702
  C: (f, a) => f(...a)
4701
4703
  });
@@ -4706,7 +4708,7 @@ var ServiceContext = class {
4706
4708
  details: assertion
4707
4709
  }, {
4708
4710
  F: __dxlog_file15,
4709
- L: 266,
4711
+ L: 271,
4710
4712
  S: this,
4711
4713
  C: (f, a) => f(...a)
4712
4714
  });
@@ -4717,7 +4719,7 @@ var ServiceContext = class {
4717
4719
  details: assertion
4718
4720
  }, {
4719
4721
  F: __dxlog_file15,
4720
- L: 271,
4722
+ L: 276,
4721
4723
  S: this,
4722
4724
  C: (f, a) => f(...a)
4723
4725
  });
@@ -4728,7 +4730,7 @@ var ServiceContext = class {
4728
4730
  } catch (err) {
4729
4731
  log12.catch(err, void 0, {
4730
4732
  F: __dxlog_file15,
4731
- L: 277,
4733
+ L: 282,
4732
4734
  S: this,
4733
4735
  C: (f, a) => f(...a)
4734
4736
  });
@@ -4740,7 +4742,7 @@ var ServiceContext = class {
4740
4742
  };
4741
4743
  _ts_decorate6([
4742
4744
  Trace2.span()
4743
- ], ServiceContext.prototype, "open", null);
4745
+ ], ServiceContext.prototype, "_open", null);
4744
4746
  _ts_decorate6([
4745
4747
  Trace2.span()
4746
4748
  ], ServiceContext.prototype, "_initialize", null);
@@ -4898,14 +4900,27 @@ var isLocked = (lockPath) => {
4898
4900
  };
4899
4901
 
4900
4902
  // packages/sdk/client-services/src/packlets/storage/storage.ts
4901
- import { DX_DATA } from "@dxos/client-protocol";
4902
4903
  import { InvalidConfigError } from "@dxos/protocols";
4903
- import { Runtime } from "@dxos/protocols/proto/dxos/config";
4904
+ import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
4904
4905
  import { createStorage, StorageType } from "@dxos/random-access-storage";
4906
+
4907
+ // packages/sdk/client-services/src/packlets/storage/util.ts
4908
+ import { DX_DATA } from "@dxos/client-protocol";
4909
+ import { Runtime } from "@dxos/protocols/proto/dxos/config";
4905
4910
  import { isNode as isNode2 } from "@dxos/util";
4906
- var StorageDriver = Runtime.Client.Storage.StorageDriver;
4911
+ var getRootPath = (config) => {
4912
+ const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
4913
+ return `${dataRoot}/`;
4914
+ };
4915
+ var isPersistent = (config) => {
4916
+ const { persistent = false } = config ?? {};
4917
+ return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
4918
+ };
4919
+
4920
+ // packages/sdk/client-services/src/packlets/storage/storage.ts
4921
+ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
4907
4922
  var createStorageObjects = (config) => {
4908
- const { persistent = false, keyStore, dataStore, dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
4923
+ const { persistent = false, keyStore, dataStore } = config ?? {};
4909
4924
  if (persistent && dataStore === StorageDriver.RAM) {
4910
4925
  throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
4911
4926
  }
@@ -4921,7 +4936,7 @@ var createStorageObjects = (config) => {
4921
4936
  return {
4922
4937
  storage: createStorage({
4923
4938
  type: persistent ? toStorageType(dataStore) : StorageType.RAM,
4924
- root: `${dataRoot}/`
4939
+ root: getRootPath(config)
4925
4940
  })
4926
4941
  };
4927
4942
  };
@@ -4946,15 +4961,27 @@ var toStorageType = (type) => {
4946
4961
  }
4947
4962
  };
4948
4963
 
4964
+ // packages/sdk/client-services/src/packlets/storage/level.ts
4965
+ import { Level } from "level";
4966
+ import path from "@dxos/node-std/path";
4967
+ import { PublicKey as PublicKey11 } from "@dxos/keys";
4968
+ var createLevel = async (config) => {
4969
+ const persistent = isPersistent(config);
4970
+ const storagePath = persistent ? getRootPath(config) : path.join("tmp", "level", PublicKey11.random().toHex());
4971
+ const level = new Level(storagePath);
4972
+ await level.open();
4973
+ return level;
4974
+ };
4975
+
4949
4976
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4950
4977
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
4951
- import { Properties, clientServiceBundle, defaultKey } from "@dxos/client-protocol";
4978
+ import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
4952
4979
  import { Context as Context11 } from "@dxos/context";
4953
- import { DataServiceImpl } from "@dxos/echo-pipeline";
4954
- import { getAutomergeObjectCore, getRawDoc } from "@dxos/echo-schema";
4980
+ import { DataServiceImpl, encodeReference } from "@dxos/echo-pipeline";
4981
+ import * as E from "@dxos/echo-schema";
4955
4982
  import { IndexServiceImpl } from "@dxos/indexing";
4956
4983
  import { invariant as invariant16 } from "@dxos/invariant";
4957
- import { PublicKey as PublicKey12 } from "@dxos/keys";
4984
+ import { PublicKey as PublicKey13 } from "@dxos/keys";
4958
4985
  import { log as log15 } from "@dxos/log";
4959
4986
  import { WebsocketSignalManager } from "@dxos/messaging";
4960
4987
  import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
@@ -5049,7 +5076,7 @@ var DevicesServiceImpl = class {
5049
5076
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
5050
5077
  import { Event as Event8 } from "@dxos/async";
5051
5078
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
5052
- import { PublicKey as PublicKey11 } from "@dxos/keys";
5079
+ import { PublicKey as PublicKey12 } from "@dxos/keys";
5053
5080
  import { getContextFromEntry, log as log14 } from "@dxos/log";
5054
5081
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
5055
5082
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
@@ -5057,7 +5084,7 @@ var LoggingServiceImpl = class {
5057
5084
  constructor() {
5058
5085
  this._logs = new Event8();
5059
5086
  this._started = Date.now();
5060
- this._sessionId = PublicKey11.random().toHex();
5087
+ this._sessionId = PublicKey12.random().toHex();
5061
5088
  this._logProcessor = (_config, entry2) => {
5062
5089
  this._logs.emit(entry2);
5063
5090
  };
@@ -5152,12 +5179,12 @@ var LoggingServiceImpl = class {
5152
5179
  });
5153
5180
  }
5154
5181
  };
5155
- var matchFilter = (filter, level, path, options) => {
5182
+ var matchFilter = (filter, level, path2, options) => {
5156
5183
  switch (options) {
5157
5184
  case QueryLogsRequest.MatchingOptions.INCLUSIVE:
5158
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
5185
+ return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5159
5186
  case QueryLogsRequest.MatchingOptions.EXPLICIT:
5160
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
5187
+ return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5161
5188
  }
5162
5189
  };
5163
5190
  var shouldLog = (entry2, request) => {
@@ -5358,7 +5385,7 @@ var ClientServicesHost = class {
5358
5385
  initialize({ config, ...options }) {
5359
5386
  invariant16(!this._open, "service host is open", {
5360
5387
  F: __dxlog_file18,
5361
- L: 179,
5388
+ L: 182,
5362
5389
  S: this,
5363
5390
  A: [
5364
5391
  "!this._open",
@@ -5367,14 +5394,14 @@ var ClientServicesHost = class {
5367
5394
  });
5368
5395
  log15("initializing...", void 0, {
5369
5396
  F: __dxlog_file18,
5370
- L: 180,
5397
+ L: 183,
5371
5398
  S: this,
5372
5399
  C: (f, a) => f(...a)
5373
5400
  });
5374
5401
  if (config) {
5375
5402
  invariant16(!this._config, "config already set", {
5376
5403
  F: __dxlog_file18,
5377
- L: 183,
5404
+ L: 186,
5378
5405
  S: this,
5379
5406
  A: [
5380
5407
  "!this._config",
@@ -5389,7 +5416,7 @@ var ClientServicesHost = class {
5389
5416
  if (!options.signalManager) {
5390
5417
  log15.warn("running signaling without telemetry metadata.", void 0, {
5391
5418
  F: __dxlog_file18,
5392
- L: 191,
5419
+ L: 194,
5393
5420
  S: this,
5394
5421
  C: (f, a) => f(...a)
5395
5422
  });
@@ -5400,7 +5427,7 @@ var ClientServicesHost = class {
5400
5427
  this._signalManager = signalManager;
5401
5428
  invariant16(!this._networkManager, "network manager already set", {
5402
5429
  F: __dxlog_file18,
5403
- L: 202,
5430
+ L: 205,
5404
5431
  S: this,
5405
5432
  A: [
5406
5433
  "!this._networkManager",
@@ -5414,7 +5441,7 @@ var ClientServicesHost = class {
5414
5441
  });
5415
5442
  log15("initialized", void 0, {
5416
5443
  F: __dxlog_file18,
5417
- L: 209,
5444
+ L: 212,
5418
5445
  S: this,
5419
5446
  C: (f, a) => f(...a)
5420
5447
  });
@@ -5423,18 +5450,18 @@ var ClientServicesHost = class {
5423
5450
  if (this._open) {
5424
5451
  return;
5425
5452
  }
5426
- const traceId = PublicKey12.random().toHex();
5453
+ const traceId = PublicKey13.random().toHex();
5427
5454
  log15.trace("dxos.client-services.host.open", trace9.begin({
5428
5455
  id: traceId
5429
5456
  }), {
5430
5457
  F: __dxlog_file18,
5431
- L: 220,
5458
+ L: 223,
5432
5459
  S: this,
5433
5460
  C: (f, a) => f(...a)
5434
5461
  });
5435
5462
  invariant16(this._config, "config not set", {
5436
5463
  F: __dxlog_file18,
5437
- L: 222,
5464
+ L: 225,
5438
5465
  S: this,
5439
5466
  A: [
5440
5467
  "this._config",
@@ -5443,7 +5470,7 @@ var ClientServicesHost = class {
5443
5470
  });
5444
5471
  invariant16(this._storage, "storage not set", {
5445
5472
  F: __dxlog_file18,
5446
- L: 223,
5473
+ L: 226,
5447
5474
  S: this,
5448
5475
  A: [
5449
5476
  "this._storage",
@@ -5452,7 +5479,7 @@ var ClientServicesHost = class {
5452
5479
  });
5453
5480
  invariant16(this._signalManager, "signal manager not set", {
5454
5481
  F: __dxlog_file18,
5455
- L: 224,
5482
+ L: 227,
5456
5483
  S: this,
5457
5484
  A: [
5458
5485
  "this._signalManager",
@@ -5461,7 +5488,7 @@ var ClientServicesHost = class {
5461
5488
  });
5462
5489
  invariant16(this._networkManager, "network manager not set", {
5463
5490
  F: __dxlog_file18,
5464
- L: 225,
5491
+ L: 228,
5465
5492
  S: this,
5466
5493
  A: [
5467
5494
  "this._networkManager",
@@ -5473,13 +5500,16 @@ var ClientServicesHost = class {
5473
5500
  lockKey: this._resourceLock?.lockKey
5474
5501
  }, {
5475
5502
  F: __dxlog_file18,
5476
- L: 228,
5503
+ L: 231,
5477
5504
  S: this,
5478
5505
  C: (f, a) => f(...a)
5479
5506
  });
5507
+ if (!this._level) {
5508
+ this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5509
+ }
5480
5510
  await this._resourceLock?.acquire();
5481
5511
  await this._loggingService.open();
5482
- this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
5512
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
5483
5513
  this._serviceRegistry.setServices({
5484
5514
  SystemService: this._systemService,
5485
5515
  IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
@@ -5507,7 +5537,7 @@ var ClientServicesHost = class {
5507
5537
  await this._serviceContext.open(ctx);
5508
5538
  invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
5509
5539
  F: __dxlog_file18,
5510
- L: 289,
5540
+ L: 297,
5511
5541
  S: this,
5512
5542
  A: [
5513
5543
  "this.serviceRegistry.services.InvitationsService",
@@ -5519,7 +5549,7 @@ var ClientServicesHost = class {
5519
5549
  count: loadedInvitations.invitations?.length
5520
5550
  }, {
5521
5551
  F: __dxlog_file18,
5522
- L: 292,
5552
+ L: 300,
5523
5553
  S: this,
5524
5554
  C: (f, a) => f(...a)
5525
5555
  });
@@ -5541,7 +5571,7 @@ var ClientServicesHost = class {
5541
5571
  deviceKey
5542
5572
  }, {
5543
5573
  F: __dxlog_file18,
5544
- L: 309,
5574
+ L: 317,
5545
5575
  S: this,
5546
5576
  C: (f, a) => f(...a)
5547
5577
  });
@@ -5549,7 +5579,7 @@ var ClientServicesHost = class {
5549
5579
  id: traceId
5550
5580
  }), {
5551
5581
  F: __dxlog_file18,
5552
- L: 310,
5582
+ L: 318,
5553
5583
  S: this,
5554
5584
  C: (f, a) => f(...a)
5555
5585
  });
@@ -5563,7 +5593,7 @@ var ClientServicesHost = class {
5563
5593
  deviceKey
5564
5594
  }, {
5565
5595
  F: __dxlog_file18,
5566
- L: 321,
5596
+ L: 329,
5567
5597
  S: this,
5568
5598
  C: (f, a) => f(...a)
5569
5599
  });
@@ -5573,30 +5603,31 @@ var ClientServicesHost = class {
5573
5603
  });
5574
5604
  await this._loggingService.close();
5575
5605
  await this._serviceContext.close();
5606
+ await this._level?.close();
5576
5607
  this._open = false;
5577
5608
  this._statusUpdate.emit();
5578
5609
  log15("closed", {
5579
5610
  deviceKey
5580
5611
  }, {
5581
5612
  F: __dxlog_file18,
5582
- L: 328,
5613
+ L: 337,
5583
5614
  S: this,
5584
5615
  C: (f, a) => f(...a)
5585
5616
  });
5586
5617
  }
5587
5618
  async reset() {
5588
- const traceId = PublicKey12.random().toHex();
5619
+ const traceId = PublicKey13.random().toHex();
5589
5620
  log15.trace("dxos.sdk.client-services-host.reset", trace9.begin({
5590
5621
  id: traceId
5591
5622
  }), {
5592
5623
  F: __dxlog_file18,
5593
- L: 333,
5624
+ L: 342,
5594
5625
  S: this,
5595
5626
  C: (f, a) => f(...a)
5596
5627
  });
5597
5628
  log15("resetting...", void 0, {
5598
5629
  F: __dxlog_file18,
5599
- L: 335,
5630
+ L: 344,
5600
5631
  S: this,
5601
5632
  C: (f, a) => f(...a)
5602
5633
  });
@@ -5604,7 +5635,7 @@ var ClientServicesHost = class {
5604
5635
  await this._storage.reset();
5605
5636
  log15("reset", void 0, {
5606
5637
  F: __dxlog_file18,
5607
- L: 338,
5638
+ L: 347,
5608
5639
  S: this,
5609
5640
  C: (f, a) => f(...a)
5610
5641
  });
@@ -5612,7 +5643,7 @@ var ClientServicesHost = class {
5612
5643
  id: traceId
5613
5644
  }), {
5614
5645
  F: __dxlog_file18,
5615
- L: 339,
5646
+ L: 348,
5616
5647
  S: this,
5617
5648
  C: (f, a) => f(...a)
5618
5649
  });
@@ -5622,12 +5653,10 @@ var ClientServicesHost = class {
5622
5653
  const identity = await this._serviceContext.createIdentity(params);
5623
5654
  await this._serviceContext.initialized.wait();
5624
5655
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5625
- const obj = new Properties(void 0);
5626
- obj[defaultKey] = identity.identityKey.toHex();
5627
5656
  const automergeIndex = space.automergeSpaceState.rootUrl;
5628
5657
  invariant16(automergeIndex, void 0, {
5629
5658
  F: __dxlog_file18,
5630
- L: 354,
5659
+ L: 360,
5631
5660
  S: this,
5632
5661
  A: [
5633
5662
  "automergeIndex",
@@ -5636,12 +5665,25 @@ var ClientServicesHost = class {
5636
5665
  });
5637
5666
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5638
5667
  await document.whenReady();
5668
+ const properties = {
5669
+ system: {
5670
+ type: encodeReference(E.getTypeReference(Properties))
5671
+ },
5672
+ data: {
5673
+ [defaultKey]: identity.identityKey.toHex()
5674
+ },
5675
+ meta: {
5676
+ keys: []
5677
+ }
5678
+ };
5679
+ const propertiesId = PublicKey13.random().toHex();
5639
5680
  document.change((doc) => {
5640
5681
  assignDeep2(doc, [
5641
5682
  "objects",
5642
- getAutomergeObjectCore(obj).id
5643
- ], getRawDoc(obj).handle.docSync());
5683
+ propertiesId
5684
+ ], properties);
5644
5685
  });
5686
+ await this._serviceContext.automergeHost.repo.flush();
5645
5687
  return identity;
5646
5688
  }
5647
5689
  };
@@ -5695,6 +5737,7 @@ export {
5695
5737
  Lock,
5696
5738
  isLocked,
5697
5739
  createStorageObjects,
5740
+ createLevel,
5698
5741
  ClientServicesHost
5699
5742
  };
5700
- //# sourceMappingURL=chunk-UFFMYQPD.mjs.map
5743
+ //# sourceMappingURL=chunk-PPCSGOUM.mjs.map