@dxos/client-services 0.4.8-main.de30065 → 0.4.8-main.e23f3c5

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.
@@ -523,6 +523,7 @@ var Identity = class {
523
523
  await this.space.open(ctx);
524
524
  }
525
525
  async close(ctx) {
526
+ await this._presence?.destroy();
526
527
  await this.authVerifier.close();
527
528
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
528
529
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
@@ -562,7 +563,7 @@ var Identity = class {
562
563
  getIdentityCredentialSigner() {
563
564
  invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
564
565
  F: __dxlog_file2,
565
- L: 144,
566
+ L: 145,
566
567
  S: this,
567
568
  A: [
568
569
  "this._deviceStateMachine.deviceCredentialChain",
@@ -586,7 +587,7 @@ var Identity = class {
586
587
  dataFeedKey
587
588
  }, {
588
589
  F: __dxlog_file2,
589
- L: 160,
590
+ L: 161,
590
591
  S: this,
591
592
  C: (f, a) => f(...a)
592
593
  });
@@ -2772,7 +2773,7 @@ var getPlatform = () => {
2772
2773
  };
2773
2774
 
2774
2775
  // packages/sdk/client-services/src/version.ts
2775
- var DXOS_VERSION = "0.4.8-main.de30065";
2776
+ var DXOS_VERSION = "0.4.8-main.e23f3c5";
2776
2777
 
2777
2778
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2778
2779
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -4382,10 +4383,9 @@ var getChannelId = (channel) => `user-channel/${channel}`;
4382
4383
 
4383
4384
  // packages/sdk/client-services/src/packlets/services/service-context.ts
4384
4385
  import { Trigger as Trigger5 } from "@dxos/async";
4385
- import { getHeads } from "@dxos/automerge/automerge";
4386
4386
  import { Context as Context10 } from "@dxos/context";
4387
4387
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4388
- import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
4388
+ import { failUndefined as failUndefined2 } from "@dxos/debug";
4389
4389
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
4390
4390
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
4391
4391
  import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
@@ -4393,11 +4393,92 @@ import { invariant as invariant14 } from "@dxos/invariant";
4393
4393
  import { Keyring } from "@dxos/keyring";
4394
4394
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4395
4395
  import { log as log13 } from "@dxos/log";
4396
- import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, idCodec, trace as trace8 } from "@dxos/protocols";
4396
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace8 } from "@dxos/protocols";
4397
4397
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
4398
4398
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
4399
4399
  import { trace as Trace2 } from "@dxos/tracing";
4400
4400
  import { safeInstanceof } from "@dxos/util";
4401
+
4402
+ // packages/sdk/client-services/src/packlets/indexing/util.ts
4403
+ import { getHeads } from "@dxos/automerge/automerge";
4404
+ import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
4405
+ import { idCodec } from "@dxos/protocols";
4406
+ var createLoadDocuments = (automergeHost) => (
4407
+ /**
4408
+ * Get object data blobs from Automerge Repo by ids.
4409
+ * @param ids
4410
+ */
4411
+ // TODO(mykola): Unload automerge handles after usage.
4412
+ async function* loadDocuments(ids) {
4413
+ for (const id of ids) {
4414
+ const { documentId, objectId } = idCodec.decode(id);
4415
+ const handle = automergeHost.repo.find(documentId);
4416
+ await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
4417
+ const doc = handle.docSync();
4418
+ const heads = getHeads(doc);
4419
+ yield [
4420
+ {
4421
+ id,
4422
+ object: doc.objects[objectId],
4423
+ currentHash: heads.at(-1)
4424
+ }
4425
+ ];
4426
+ }
4427
+ }
4428
+ );
4429
+ var createGetAllDocuments = (automergeHost) => (
4430
+ /**
4431
+ * Recursively get all object data blobs from Automerge Repo.
4432
+ * @param ids
4433
+ */
4434
+ // TODO(mykola): Unload automerge handles after usage.
4435
+ async function* getAllDocuments() {
4436
+ const visited = /* @__PURE__ */ new Set();
4437
+ async function* getObjectsFromHandle(handle) {
4438
+ if (visited.has(handle.documentId)) {
4439
+ return;
4440
+ }
4441
+ await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
4442
+ const doc = handle.docSync();
4443
+ const heads = getHeads(doc);
4444
+ if (doc.objects) {
4445
+ yield Object.entries(doc.objects).map(([objectId, object]) => {
4446
+ return {
4447
+ id: idCodec.encode({
4448
+ documentId: handle.documentId,
4449
+ objectId
4450
+ }),
4451
+ object,
4452
+ currentHash: heads.at(-1)
4453
+ };
4454
+ });
4455
+ }
4456
+ if (doc.links) {
4457
+ for (const id of Object.values(doc.links)) {
4458
+ if (visited.has(id)) {
4459
+ continue;
4460
+ }
4461
+ const linkHandle = automergeHost.repo.find(id);
4462
+ for await (const result of getObjectsFromHandle(linkHandle)) {
4463
+ yield result;
4464
+ }
4465
+ }
4466
+ }
4467
+ visited.add(handle.documentId);
4468
+ }
4469
+ for (const handle of Object.values(automergeHost.repo.handles)) {
4470
+ if (visited.has(handle.documentId)) {
4471
+ continue;
4472
+ }
4473
+ for await (const result of getObjectsFromHandle(handle)) {
4474
+ yield result;
4475
+ }
4476
+ visited.add(handle.documentId);
4477
+ }
4478
+ }
4479
+ );
4480
+
4481
+ // packages/sdk/client-services/src/packlets/services/service-context.ts
4401
4482
  function _ts_decorate6(decorators, target, key, desc) {
4402
4483
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4403
4484
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -4455,21 +4536,8 @@ var ServiceContext = class {
4455
4536
  directory: storage.createDirectory("index-store")
4456
4537
  }),
4457
4538
  metadataStore: this.indexMetadata,
4458
- loadDocuments: async (ids) => {
4459
- const snapshots = await Promise.all(ids.map(async (id) => {
4460
- const { documentId, objectId } = idCodec.decode(id);
4461
- const handle = this.automergeHost.repo.find(documentId);
4462
- await warnAfterTimeout2(1e3, "to long to load doc", () => handle.whenReady());
4463
- const doc = handle.docSync();
4464
- const heads = getHeads(doc);
4465
- return {
4466
- id,
4467
- object: doc.objects[objectId],
4468
- currentHash: heads.at(-1)
4469
- };
4470
- }));
4471
- return snapshots.filter((snapshot) => snapshot.object);
4472
- }
4539
+ loadDocuments: createLoadDocuments(this.automergeHost),
4540
+ getAllDocuments: createGetAllDocuments(this.automergeHost)
4473
4541
  });
4474
4542
  this.invitations = new InvitationsHandler(this.networkManager);
4475
4543
  this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
@@ -4478,7 +4546,7 @@ var ServiceContext = class {
4478
4546
  await this._checkStorageVersion();
4479
4547
  log13("opening...", void 0, {
4480
4548
  F: __dxlog_file15,
4481
- L: 173,
4549
+ L: 162,
4482
4550
  S: this,
4483
4551
  C: (f, a) => f(...a)
4484
4552
  });
@@ -4486,7 +4554,7 @@ var ServiceContext = class {
4486
4554
  id: this._instanceId
4487
4555
  }), {
4488
4556
  F: __dxlog_file15,
4489
- L: 174,
4557
+ L: 163,
4490
4558
  S: this,
4491
4559
  C: (f, a) => f(...a)
4492
4560
  });
@@ -4502,13 +4570,13 @@ var ServiceContext = class {
4502
4570
  id: this._instanceId
4503
4571
  }), {
4504
4572
  F: __dxlog_file15,
4505
- L: 184,
4573
+ L: 173,
4506
4574
  S: this,
4507
4575
  C: (f, a) => f(...a)
4508
4576
  });
4509
4577
  log13("opened", void 0, {
4510
4578
  F: __dxlog_file15,
4511
- L: 185,
4579
+ L: 174,
4512
4580
  S: this,
4513
4581
  C: (f, a) => f(...a)
4514
4582
  });
@@ -4516,7 +4584,7 @@ var ServiceContext = class {
4516
4584
  async close() {
4517
4585
  log13("closing...", void 0, {
4518
4586
  F: __dxlog_file15,
4519
- L: 189,
4587
+ L: 178,
4520
4588
  S: this,
4521
4589
  C: (f, a) => f(...a)
4522
4590
  });
@@ -4535,7 +4603,7 @@ var ServiceContext = class {
4535
4603
  await this.indexer.destroy();
4536
4604
  log13("closed", void 0, {
4537
4605
  F: __dxlog_file15,
4538
- L: 203,
4606
+ L: 192,
4539
4607
  S: this,
4540
4608
  C: (f, a) => f(...a)
4541
4609
  });
@@ -4549,7 +4617,7 @@ var ServiceContext = class {
4549
4617
  const factory = this._handlerFactories.get(invitation.kind);
4550
4618
  invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
4551
4619
  F: __dxlog_file15,
4552
- L: 214,
4620
+ L: 203,
4553
4621
  S: this,
4554
4622
  A: [
4555
4623
  "factory",
@@ -4581,7 +4649,7 @@ var ServiceContext = class {
4581
4649
  async _initialize(ctx) {
4582
4650
  log13("initializing spaces...", void 0, {
4583
4651
  F: __dxlog_file15,
4584
- L: 245,
4652
+ L: 234,
4585
4653
  S: this,
4586
4654
  C: (f, a) => f(...a)
4587
4655
  });
@@ -4604,7 +4672,7 @@ var ServiceContext = class {
4604
4672
  this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
4605
4673
  invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4606
4674
  F: __dxlog_file15,
4607
- L: 270,
4675
+ L: 259,
4608
4676
  S: this,
4609
4677
  A: [
4610
4678
  "this.dataSpaceManager",
@@ -4628,7 +4696,7 @@ var ServiceContext = class {
4628
4696
  details: assertion
4629
4697
  }, {
4630
4698
  F: __dxlog_file15,
4631
- L: 286,
4699
+ L: 275,
4632
4700
  S: this,
4633
4701
  C: (f, a) => f(...a)
4634
4702
  });
@@ -4639,7 +4707,7 @@ var ServiceContext = class {
4639
4707
  details: assertion
4640
4708
  }, {
4641
4709
  F: __dxlog_file15,
4642
- L: 290,
4710
+ L: 279,
4643
4711
  S: this,
4644
4712
  C: (f, a) => f(...a)
4645
4713
  });
@@ -4650,7 +4718,7 @@ var ServiceContext = class {
4650
4718
  details: assertion
4651
4719
  }, {
4652
4720
  F: __dxlog_file15,
4653
- L: 295,
4721
+ L: 284,
4654
4722
  S: this,
4655
4723
  C: (f, a) => f(...a)
4656
4724
  });
@@ -4661,7 +4729,7 @@ var ServiceContext = class {
4661
4729
  } catch (err) {
4662
4730
  log13.catch(err, void 0, {
4663
4731
  F: __dxlog_file15,
4664
- L: 301,
4732
+ L: 290,
4665
4733
  S: this,
4666
4734
  C: (f, a) => f(...a)
4667
4735
  });
@@ -5631,4 +5699,4 @@ export {
5631
5699
  createDefaultModelFactory,
5632
5700
  ClientServicesHost
5633
5701
  };
5634
- //# sourceMappingURL=chunk-5UOBTTOT.mjs.map
5702
+ //# sourceMappingURL=chunk-NPQIOKNF.mjs.map