@dxos/client-services 0.4.8-main.c4e8b01 → 0.4.8-main.c67d72c

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.
@@ -2772,7 +2772,7 @@ var getPlatform = () => {
2772
2772
  };
2773
2773
 
2774
2774
  // packages/sdk/client-services/src/version.ts
2775
- var DXOS_VERSION = "0.4.8-main.c4e8b01";
2775
+ var DXOS_VERSION = "0.4.8-main.c67d72c";
2776
2776
 
2777
2777
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2778
2778
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -4382,17 +4382,18 @@ var getChannelId = (channel) => `user-channel/${channel}`;
4382
4382
 
4383
4383
  // packages/sdk/client-services/src/packlets/services/service-context.ts
4384
4384
  import { Trigger as Trigger5 } from "@dxos/async";
4385
+ import { getHeads } from "@dxos/automerge/automerge";
4385
4386
  import { Context as Context10 } from "@dxos/context";
4386
4387
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4387
- import { failUndefined as failUndefined2 } from "@dxos/debug";
4388
+ import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
4388
4389
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
4389
- import { IndexMetadataStore } from "@dxos/echo-schema";
4390
4390
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
4391
+ import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
4391
4392
  import { invariant as invariant14 } from "@dxos/invariant";
4392
4393
  import { Keyring } from "@dxos/keyring";
4393
4394
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4394
4395
  import { log as log13 } from "@dxos/log";
4395
- import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace8 } from "@dxos/protocols";
4396
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, idCodec, trace as trace8 } from "@dxos/protocols";
4396
4397
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
4397
4398
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
4398
4399
  import { trace as Trace2 } from "@dxos/tracing";
@@ -4420,9 +4421,6 @@ var ServiceContext = class {
4420
4421
  this._handlerFactories = /* @__PURE__ */ new Map();
4421
4422
  this._instanceId = PublicKey10.random().toHex();
4422
4423
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
4423
- this.indexMetadata = new IndexMetadataStore({
4424
- directory: storage.createDirectory("index-metadata")
4425
- });
4426
4424
  this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
4427
4425
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
4428
4426
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -4445,10 +4443,34 @@ var ServiceContext = class {
4445
4443
  snapshotStore: this.snapshotStore
4446
4444
  });
4447
4445
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4446
+ this.indexMetadata = new IndexMetadataStore({
4447
+ directory: storage.createDirectory("index-metadata")
4448
+ });
4448
4449
  this.automergeHost = new AutomergeHost({
4449
4450
  directory: storage.createDirectory("automerge"),
4450
4451
  metadata: this.indexMetadata
4451
4452
  });
4453
+ this.indexer = new Indexer({
4454
+ indexStore: new IndexStore({
4455
+ directory: storage.createDirectory("index-store")
4456
+ }),
4457
+ 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
+ }
4473
+ });
4452
4474
  this.invitations = new InvitationsHandler(this.networkManager);
4453
4475
  this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
4454
4476
  }
@@ -4456,7 +4478,7 @@ var ServiceContext = class {
4456
4478
  await this._checkStorageVersion();
4457
4479
  log13("opening...", void 0, {
4458
4480
  F: __dxlog_file15,
4459
- L: 152,
4481
+ L: 173,
4460
4482
  S: this,
4461
4483
  C: (f, a) => f(...a)
4462
4484
  });
@@ -4464,7 +4486,7 @@ var ServiceContext = class {
4464
4486
  id: this._instanceId
4465
4487
  }), {
4466
4488
  F: __dxlog_file15,
4467
- L: 153,
4489
+ L: 174,
4468
4490
  S: this,
4469
4491
  C: (f, a) => f(...a)
4470
4492
  });
@@ -4480,13 +4502,13 @@ var ServiceContext = class {
4480
4502
  id: this._instanceId
4481
4503
  }), {
4482
4504
  F: __dxlog_file15,
4483
- L: 163,
4505
+ L: 184,
4484
4506
  S: this,
4485
4507
  C: (f, a) => f(...a)
4486
4508
  });
4487
4509
  log13("opened", void 0, {
4488
4510
  F: __dxlog_file15,
4489
- L: 164,
4511
+ L: 185,
4490
4512
  S: this,
4491
4513
  C: (f, a) => f(...a)
4492
4514
  });
@@ -4494,7 +4516,7 @@ var ServiceContext = class {
4494
4516
  async close() {
4495
4517
  log13("closing...", void 0, {
4496
4518
  F: __dxlog_file15,
4497
- L: 168,
4519
+ L: 189,
4498
4520
  S: this,
4499
4521
  C: (f, a) => f(...a)
4500
4522
  });
@@ -4510,9 +4532,10 @@ var ServiceContext = class {
4510
4532
  await this.signalManager.close();
4511
4533
  this.dataServiceSubscriptions.clear();
4512
4534
  await this.metadataStore.close();
4535
+ await this.indexer.destroy();
4513
4536
  log13("closed", void 0, {
4514
4537
  F: __dxlog_file15,
4515
- L: 181,
4538
+ L: 203,
4516
4539
  S: this,
4517
4540
  C: (f, a) => f(...a)
4518
4541
  });
@@ -4526,7 +4549,7 @@ var ServiceContext = class {
4526
4549
  const factory = this._handlerFactories.get(invitation.kind);
4527
4550
  invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
4528
4551
  F: __dxlog_file15,
4529
- L: 192,
4552
+ L: 214,
4530
4553
  S: this,
4531
4554
  A: [
4532
4555
  "factory",
@@ -4558,7 +4581,7 @@ var ServiceContext = class {
4558
4581
  async _initialize(ctx) {
4559
4582
  log13("initializing spaces...", void 0, {
4560
4583
  F: __dxlog_file15,
4561
- L: 223,
4584
+ L: 245,
4562
4585
  S: this,
4563
4586
  C: (f, a) => f(...a)
4564
4587
  });
@@ -4581,7 +4604,7 @@ var ServiceContext = class {
4581
4604
  this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
4582
4605
  invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4583
4606
  F: __dxlog_file15,
4584
- L: 248,
4607
+ L: 270,
4585
4608
  S: this,
4586
4609
  A: [
4587
4610
  "this.dataSpaceManager",
@@ -4605,7 +4628,7 @@ var ServiceContext = class {
4605
4628
  details: assertion
4606
4629
  }, {
4607
4630
  F: __dxlog_file15,
4608
- L: 264,
4631
+ L: 286,
4609
4632
  S: this,
4610
4633
  C: (f, a) => f(...a)
4611
4634
  });
@@ -4616,7 +4639,7 @@ var ServiceContext = class {
4616
4639
  details: assertion
4617
4640
  }, {
4618
4641
  F: __dxlog_file15,
4619
- L: 268,
4642
+ L: 290,
4620
4643
  S: this,
4621
4644
  C: (f, a) => f(...a)
4622
4645
  });
@@ -4627,7 +4650,7 @@ var ServiceContext = class {
4627
4650
  details: assertion
4628
4651
  }, {
4629
4652
  F: __dxlog_file15,
4630
- L: 273,
4653
+ L: 295,
4631
4654
  S: this,
4632
4655
  C: (f, a) => f(...a)
4633
4656
  });
@@ -4638,7 +4661,7 @@ var ServiceContext = class {
4638
4661
  } catch (err) {
4639
4662
  log13.catch(err, void 0, {
4640
4663
  F: __dxlog_file15,
4641
- L: 279,
4664
+ L: 301,
4642
4665
  S: this,
4643
4666
  C: (f, a) => f(...a)
4644
4667
  });
@@ -4863,6 +4886,7 @@ import { Context as Context11 } from "@dxos/context";
4863
4886
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4864
4887
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4865
4888
  import { getRawDoc, getAutomergeObjectCore } from "@dxos/echo-schema";
4889
+ import { IndexServiceImpl } from "@dxos/indexing";
4866
4890
  import { invariant as invariant16 } from "@dxos/invariant";
4867
4891
  import { PublicKey as PublicKey12 } from "@dxos/keys";
4868
4892
  import { log as log16 } from "@dxos/log";
@@ -5275,7 +5299,7 @@ var ClientServicesHost = class {
5275
5299
  initialize({ config, ...options }) {
5276
5300
  invariant16(!this._open, "service host is open", {
5277
5301
  F: __dxlog_file18,
5278
- L: 190,
5302
+ L: 191,
5279
5303
  S: this,
5280
5304
  A: [
5281
5305
  "!this._open",
@@ -5284,14 +5308,14 @@ var ClientServicesHost = class {
5284
5308
  });
5285
5309
  log16("initializing...", void 0, {
5286
5310
  F: __dxlog_file18,
5287
- L: 191,
5311
+ L: 192,
5288
5312
  S: this,
5289
5313
  C: (f, a) => f(...a)
5290
5314
  });
5291
5315
  if (config) {
5292
5316
  invariant16(!this._config, "config already set", {
5293
5317
  F: __dxlog_file18,
5294
- L: 194,
5318
+ L: 195,
5295
5319
  S: this,
5296
5320
  A: [
5297
5321
  "!this._config",
@@ -5309,7 +5333,7 @@ var ClientServicesHost = class {
5309
5333
  this._signalManager = signalManager;
5310
5334
  invariant16(!this._networkManager, "network manager already set", {
5311
5335
  F: __dxlog_file18,
5312
- L: 210,
5336
+ L: 211,
5313
5337
  S: this,
5314
5338
  A: [
5315
5339
  "!this._networkManager",
@@ -5323,7 +5347,7 @@ var ClientServicesHost = class {
5323
5347
  });
5324
5348
  log16("initialized", void 0, {
5325
5349
  F: __dxlog_file18,
5326
- L: 217,
5350
+ L: 218,
5327
5351
  S: this,
5328
5352
  C: (f, a) => f(...a)
5329
5353
  });
@@ -5337,13 +5361,13 @@ var ClientServicesHost = class {
5337
5361
  id: traceId
5338
5362
  }), {
5339
5363
  F: __dxlog_file18,
5340
- L: 228,
5364
+ L: 229,
5341
5365
  S: this,
5342
5366
  C: (f, a) => f(...a)
5343
5367
  });
5344
5368
  invariant16(this._config, "config not set", {
5345
5369
  F: __dxlog_file18,
5346
- L: 230,
5370
+ L: 231,
5347
5371
  S: this,
5348
5372
  A: [
5349
5373
  "this._config",
@@ -5352,7 +5376,7 @@ var ClientServicesHost = class {
5352
5376
  });
5353
5377
  invariant16(this._storage, "storage not set", {
5354
5378
  F: __dxlog_file18,
5355
- L: 231,
5379
+ L: 232,
5356
5380
  S: this,
5357
5381
  A: [
5358
5382
  "this._storage",
@@ -5361,7 +5385,7 @@ var ClientServicesHost = class {
5361
5385
  });
5362
5386
  invariant16(this._signalManager, "signal manager not set", {
5363
5387
  F: __dxlog_file18,
5364
- L: 232,
5388
+ L: 233,
5365
5389
  S: this,
5366
5390
  A: [
5367
5391
  "this._signalManager",
@@ -5370,7 +5394,7 @@ var ClientServicesHost = class {
5370
5394
  });
5371
5395
  invariant16(this._networkManager, "network manager not set", {
5372
5396
  F: __dxlog_file18,
5373
- L: 233,
5397
+ L: 234,
5374
5398
  S: this,
5375
5399
  A: [
5376
5400
  "this._networkManager",
@@ -5382,7 +5406,7 @@ var ClientServicesHost = class {
5382
5406
  lockKey: this._resourceLock?.lockKey
5383
5407
  }, {
5384
5408
  F: __dxlog_file18,
5385
- L: 236,
5409
+ L: 237,
5386
5410
  S: this,
5387
5411
  C: (f, a) => f(...a)
5388
5412
  });
@@ -5399,6 +5423,10 @@ var ClientServicesHost = class {
5399
5423
  return this._serviceContext.dataSpaceManager;
5400
5424
  }),
5401
5425
  DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
5426
+ IndexService: new IndexServiceImpl({
5427
+ indexer: this._serviceContext.indexer,
5428
+ automergeHost: this._serviceContext.automergeHost
5429
+ }),
5402
5430
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
5403
5431
  LoggingService: this._loggingService,
5404
5432
  TracingService: this._tracingService,
@@ -5412,7 +5440,7 @@ var ClientServicesHost = class {
5412
5440
  await this._serviceContext.open(ctx);
5413
5441
  invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
5414
5442
  F: __dxlog_file18,
5415
- L: 297,
5443
+ L: 303,
5416
5444
  S: this,
5417
5445
  A: [
5418
5446
  "this.serviceRegistry.services.InvitationsService",
@@ -5424,7 +5452,7 @@ var ClientServicesHost = class {
5424
5452
  count: loadedInvitations.invitations?.length
5425
5453
  }, {
5426
5454
  F: __dxlog_file18,
5427
- L: 300,
5455
+ L: 306,
5428
5456
  S: this,
5429
5457
  C: (f, a) => f(...a)
5430
5458
  });
@@ -5446,7 +5474,7 @@ var ClientServicesHost = class {
5446
5474
  deviceKey
5447
5475
  }, {
5448
5476
  F: __dxlog_file18,
5449
- L: 317,
5477
+ L: 323,
5450
5478
  S: this,
5451
5479
  C: (f, a) => f(...a)
5452
5480
  });
@@ -5454,7 +5482,7 @@ var ClientServicesHost = class {
5454
5482
  id: traceId
5455
5483
  }), {
5456
5484
  F: __dxlog_file18,
5457
- L: 318,
5485
+ L: 324,
5458
5486
  S: this,
5459
5487
  C: (f, a) => f(...a)
5460
5488
  });
@@ -5468,7 +5496,7 @@ var ClientServicesHost = class {
5468
5496
  deviceKey
5469
5497
  }, {
5470
5498
  F: __dxlog_file18,
5471
- L: 329,
5499
+ L: 335,
5472
5500
  S: this,
5473
5501
  C: (f, a) => f(...a)
5474
5502
  });
@@ -5484,7 +5512,7 @@ var ClientServicesHost = class {
5484
5512
  deviceKey
5485
5513
  }, {
5486
5514
  F: __dxlog_file18,
5487
- L: 336,
5515
+ L: 342,
5488
5516
  S: this,
5489
5517
  C: (f, a) => f(...a)
5490
5518
  });
@@ -5495,13 +5523,13 @@ var ClientServicesHost = class {
5495
5523
  id: traceId
5496
5524
  }), {
5497
5525
  F: __dxlog_file18,
5498
- L: 341,
5526
+ L: 347,
5499
5527
  S: this,
5500
5528
  C: (f, a) => f(...a)
5501
5529
  });
5502
5530
  log16("resetting...", void 0, {
5503
5531
  F: __dxlog_file18,
5504
- L: 343,
5532
+ L: 349,
5505
5533
  S: this,
5506
5534
  C: (f, a) => f(...a)
5507
5535
  });
@@ -5509,7 +5537,7 @@ var ClientServicesHost = class {
5509
5537
  await this._storage.reset();
5510
5538
  log16("reset", void 0, {
5511
5539
  F: __dxlog_file18,
5512
- L: 346,
5540
+ L: 352,
5513
5541
  S: this,
5514
5542
  C: (f, a) => f(...a)
5515
5543
  });
@@ -5517,7 +5545,7 @@ var ClientServicesHost = class {
5517
5545
  id: traceId
5518
5546
  }), {
5519
5547
  F: __dxlog_file18,
5520
- L: 347,
5548
+ L: 353,
5521
5549
  S: this,
5522
5550
  C: (f, a) => f(...a)
5523
5551
  });
@@ -5532,7 +5560,7 @@ var ClientServicesHost = class {
5532
5560
  const automergeIndex = space.automergeSpaceState.rootUrl;
5533
5561
  invariant16(automergeIndex, void 0, {
5534
5562
  F: __dxlog_file18,
5535
- L: 362,
5563
+ L: 368,
5536
5564
  S: this,
5537
5565
  A: [
5538
5566
  "automergeIndex",
@@ -5603,4 +5631,4 @@ export {
5603
5631
  createDefaultModelFactory,
5604
5632
  ClientServicesHost
5605
5633
  };
5606
- //# sourceMappingURL=chunk-GXE6VKUE.mjs.map
5634
+ //# sourceMappingURL=chunk-EUPRQ6KX.mjs.map