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

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_TWZLD46U_exports = {};
30
- __export(chunk_TWZLD46U_exports, {
29
+ var chunk_YFFKH75O_exports = {};
30
+ __export(chunk_YFFKH75O_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -61,7 +61,7 @@ __export(chunk_TWZLD46U_exports, {
61
61
  subscribeToSpaces: () => subscribeToSpaces,
62
62
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
63
63
  });
64
- module.exports = __toCommonJS(chunk_TWZLD46U_exports);
64
+ module.exports = __toCommonJS(chunk_YFFKH75O_exports);
65
65
  var import_async = require("@dxos/async");
66
66
  var import_codec_protobuf = require("@dxos/codec-protobuf");
67
67
  var import_feed_store = require("@dxos/feed-store");
@@ -203,12 +203,13 @@ var import_log12 = require("@dxos/log");
203
203
  var import_protocols11 = require("@dxos/protocols");
204
204
  var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
205
205
  var import_async14 = require("@dxos/async");
206
+ var import_automerge = require("@dxos/automerge/automerge");
206
207
  var import_context10 = require("@dxos/context");
207
208
  var import_credentials15 = require("@dxos/credentials");
208
209
  var import_debug6 = require("@dxos/debug");
209
210
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
210
- var import_echo_schema = require("@dxos/echo-schema");
211
211
  var import_feed_store4 = require("@dxos/feed-store");
212
+ var import_indexing = require("@dxos/indexing");
212
213
  var import_invariant14 = require("@dxos/invariant");
213
214
  var import_keyring = require("@dxos/keyring");
214
215
  var import_keys10 = require("@dxos/keys");
@@ -231,7 +232,8 @@ var import_client_protocol5 = require("@dxos/client-protocol");
231
232
  var import_context11 = require("@dxos/context");
232
233
  var import_document_model2 = require("@dxos/document-model");
233
234
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
234
- var import_echo_schema2 = require("@dxos/echo-schema");
235
+ var import_echo_schema = require("@dxos/echo-schema");
236
+ var import_indexing2 = require("@dxos/indexing");
235
237
  var import_invariant16 = require("@dxos/invariant");
236
238
  var import_keys11 = require("@dxos/keys");
237
239
  var import_log15 = require("@dxos/log");
@@ -2886,7 +2888,7 @@ var getPlatform = () => {
2886
2888
  };
2887
2889
  }
2888
2890
  };
2889
- var DXOS_VERSION = "0.4.8-main.c4e8b01";
2891
+ var DXOS_VERSION = "0.4.8-main.ec0899a";
2890
2892
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2891
2893
  var DEFAULT_TIMEOUT = 1e3;
2892
2894
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -4450,9 +4452,6 @@ var ServiceContext = class {
4450
4452
  this._handlerFactories = /* @__PURE__ */ new Map();
4451
4453
  this._instanceId = import_keys10.PublicKey.random().toHex();
4452
4454
  this.metadataStore = new import_echo_pipeline2.MetadataStore(storage.createDirectory("metadata"));
4453
- this.indexMetadata = new import_echo_schema.IndexMetadataStore({
4454
- directory: storage.createDirectory("index-metadata")
4455
- });
4456
4455
  this.snapshotStore = new import_echo_pipeline2.SnapshotStore(storage.createDirectory("snapshots"));
4457
4456
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4458
4457
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
@@ -4475,10 +4474,34 @@ var ServiceContext = class {
4475
4474
  snapshotStore: this.snapshotStore
4476
4475
  });
4477
4476
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4477
+ this.indexMetadata = new import_indexing.IndexMetadataStore({
4478
+ directory: storage.createDirectory("index-metadata")
4479
+ });
4478
4480
  this.automergeHost = new import_echo_pipeline2.AutomergeHost({
4479
4481
  directory: storage.createDirectory("automerge"),
4480
4482
  metadata: this.indexMetadata
4481
4483
  });
4484
+ this.indexer = new import_indexing.Indexer({
4485
+ indexStore: new import_indexing.IndexStore({
4486
+ directory: storage.createDirectory("index-store")
4487
+ }),
4488
+ metadataStore: this.indexMetadata,
4489
+ loadDocuments: async (ids) => {
4490
+ const snapshots = await Promise.all(ids.map(async (id) => {
4491
+ const { documentId, objectId } = import_protocols12.idCodec.decode(id);
4492
+ const handle = this.automergeHost.repo.find(documentId);
4493
+ await (0, import_debug6.warnAfterTimeout)(1e3, "to long to load doc", () => handle.whenReady());
4494
+ const doc = handle.docSync();
4495
+ const heads = (0, import_automerge.getHeads)(doc);
4496
+ return {
4497
+ id,
4498
+ object: doc.objects[objectId],
4499
+ currentHash: heads.at(-1)
4500
+ };
4501
+ }));
4502
+ return snapshots.filter((snapshot) => snapshot.object);
4503
+ }
4504
+ });
4482
4505
  this.invitations = new InvitationsHandler(this.networkManager);
4483
4506
  this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4484
4507
  }
@@ -4486,7 +4509,7 @@ var ServiceContext = class {
4486
4509
  await this._checkStorageVersion();
4487
4510
  (0, import_log13.log)("opening...", void 0, {
4488
4511
  F: __dxlog_file15,
4489
- L: 152,
4512
+ L: 173,
4490
4513
  S: this,
4491
4514
  C: (f, a) => f(...a)
4492
4515
  });
@@ -4494,7 +4517,7 @@ var ServiceContext = class {
4494
4517
  id: this._instanceId
4495
4518
  }), {
4496
4519
  F: __dxlog_file15,
4497
- L: 153,
4520
+ L: 174,
4498
4521
  S: this,
4499
4522
  C: (f, a) => f(...a)
4500
4523
  });
@@ -4510,13 +4533,13 @@ var ServiceContext = class {
4510
4533
  id: this._instanceId
4511
4534
  }), {
4512
4535
  F: __dxlog_file15,
4513
- L: 163,
4536
+ L: 184,
4514
4537
  S: this,
4515
4538
  C: (f, a) => f(...a)
4516
4539
  });
4517
4540
  (0, import_log13.log)("opened", void 0, {
4518
4541
  F: __dxlog_file15,
4519
- L: 164,
4542
+ L: 185,
4520
4543
  S: this,
4521
4544
  C: (f, a) => f(...a)
4522
4545
  });
@@ -4524,7 +4547,7 @@ var ServiceContext = class {
4524
4547
  async close() {
4525
4548
  (0, import_log13.log)("closing...", void 0, {
4526
4549
  F: __dxlog_file15,
4527
- L: 168,
4550
+ L: 189,
4528
4551
  S: this,
4529
4552
  C: (f, a) => f(...a)
4530
4553
  });
@@ -4540,9 +4563,10 @@ var ServiceContext = class {
4540
4563
  await this.signalManager.close();
4541
4564
  this.dataServiceSubscriptions.clear();
4542
4565
  await this.metadataStore.close();
4566
+ await this.indexer.destroy();
4543
4567
  (0, import_log13.log)("closed", void 0, {
4544
4568
  F: __dxlog_file15,
4545
- L: 181,
4569
+ L: 203,
4546
4570
  S: this,
4547
4571
  C: (f, a) => f(...a)
4548
4572
  });
@@ -4556,7 +4580,7 @@ var ServiceContext = class {
4556
4580
  const factory = this._handlerFactories.get(invitation.kind);
4557
4581
  (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4558
4582
  F: __dxlog_file15,
4559
- L: 192,
4583
+ L: 214,
4560
4584
  S: this,
4561
4585
  A: [
4562
4586
  "factory",
@@ -4588,7 +4612,7 @@ var ServiceContext = class {
4588
4612
  async _initialize(ctx) {
4589
4613
  (0, import_log13.log)("initializing spaces...", void 0, {
4590
4614
  F: __dxlog_file15,
4591
- L: 223,
4615
+ L: 245,
4592
4616
  S: this,
4593
4617
  C: (f, a) => f(...a)
4594
4618
  });
@@ -4611,7 +4635,7 @@ var ServiceContext = class {
4611
4635
  this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4612
4636
  (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4613
4637
  F: __dxlog_file15,
4614
- L: 248,
4638
+ L: 270,
4615
4639
  S: this,
4616
4640
  A: [
4617
4641
  "this.dataSpaceManager",
@@ -4635,7 +4659,7 @@ var ServiceContext = class {
4635
4659
  details: assertion
4636
4660
  }, {
4637
4661
  F: __dxlog_file15,
4638
- L: 264,
4662
+ L: 286,
4639
4663
  S: this,
4640
4664
  C: (f, a) => f(...a)
4641
4665
  });
@@ -4646,7 +4670,7 @@ var ServiceContext = class {
4646
4670
  details: assertion
4647
4671
  }, {
4648
4672
  F: __dxlog_file15,
4649
- L: 268,
4673
+ L: 290,
4650
4674
  S: this,
4651
4675
  C: (f, a) => f(...a)
4652
4676
  });
@@ -4657,7 +4681,7 @@ var ServiceContext = class {
4657
4681
  details: assertion
4658
4682
  }, {
4659
4683
  F: __dxlog_file15,
4660
- L: 273,
4684
+ L: 295,
4661
4685
  S: this,
4662
4686
  C: (f, a) => f(...a)
4663
4687
  });
@@ -4668,7 +4692,7 @@ var ServiceContext = class {
4668
4692
  } catch (err) {
4669
4693
  import_log13.log.catch(err, void 0, {
4670
4694
  F: __dxlog_file15,
4671
- L: 279,
4695
+ L: 301,
4672
4696
  S: this,
4673
4697
  C: (f, a) => f(...a)
4674
4698
  });
@@ -5182,7 +5206,7 @@ var ClientServicesHost = class {
5182
5206
  initialize({ config, ...options }) {
5183
5207
  (0, import_invariant16.invariant)(!this._open, "service host is open", {
5184
5208
  F: __dxlog_file18,
5185
- L: 190,
5209
+ L: 191,
5186
5210
  S: this,
5187
5211
  A: [
5188
5212
  "!this._open",
@@ -5191,14 +5215,14 @@ var ClientServicesHost = class {
5191
5215
  });
5192
5216
  (0, import_log15.log)("initializing...", void 0, {
5193
5217
  F: __dxlog_file18,
5194
- L: 191,
5218
+ L: 192,
5195
5219
  S: this,
5196
5220
  C: (f, a) => f(...a)
5197
5221
  });
5198
5222
  if (config) {
5199
5223
  (0, import_invariant16.invariant)(!this._config, "config already set", {
5200
5224
  F: __dxlog_file18,
5201
- L: 194,
5225
+ L: 195,
5202
5226
  S: this,
5203
5227
  A: [
5204
5228
  "!this._config",
@@ -5216,7 +5240,7 @@ var ClientServicesHost = class {
5216
5240
  this._signalManager = signalManager;
5217
5241
  (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5218
5242
  F: __dxlog_file18,
5219
- L: 210,
5243
+ L: 211,
5220
5244
  S: this,
5221
5245
  A: [
5222
5246
  "!this._networkManager",
@@ -5230,7 +5254,7 @@ var ClientServicesHost = class {
5230
5254
  });
5231
5255
  (0, import_log15.log)("initialized", void 0, {
5232
5256
  F: __dxlog_file18,
5233
- L: 217,
5257
+ L: 218,
5234
5258
  S: this,
5235
5259
  C: (f, a) => f(...a)
5236
5260
  });
@@ -5244,13 +5268,13 @@ var ClientServicesHost = class {
5244
5268
  id: traceId
5245
5269
  }), {
5246
5270
  F: __dxlog_file18,
5247
- L: 228,
5271
+ L: 229,
5248
5272
  S: this,
5249
5273
  C: (f, a) => f(...a)
5250
5274
  });
5251
5275
  (0, import_invariant16.invariant)(this._config, "config not set", {
5252
5276
  F: __dxlog_file18,
5253
- L: 230,
5277
+ L: 231,
5254
5278
  S: this,
5255
5279
  A: [
5256
5280
  "this._config",
@@ -5259,7 +5283,7 @@ var ClientServicesHost = class {
5259
5283
  });
5260
5284
  (0, import_invariant16.invariant)(this._storage, "storage not set", {
5261
5285
  F: __dxlog_file18,
5262
- L: 231,
5286
+ L: 232,
5263
5287
  S: this,
5264
5288
  A: [
5265
5289
  "this._storage",
@@ -5268,7 +5292,7 @@ var ClientServicesHost = class {
5268
5292
  });
5269
5293
  (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5270
5294
  F: __dxlog_file18,
5271
- L: 232,
5295
+ L: 233,
5272
5296
  S: this,
5273
5297
  A: [
5274
5298
  "this._signalManager",
@@ -5277,7 +5301,7 @@ var ClientServicesHost = class {
5277
5301
  });
5278
5302
  (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5279
5303
  F: __dxlog_file18,
5280
- L: 233,
5304
+ L: 234,
5281
5305
  S: this,
5282
5306
  A: [
5283
5307
  "this._networkManager",
@@ -5289,7 +5313,7 @@ var ClientServicesHost = class {
5289
5313
  lockKey: this._resourceLock?.lockKey
5290
5314
  }, {
5291
5315
  F: __dxlog_file18,
5292
- L: 236,
5316
+ L: 237,
5293
5317
  S: this,
5294
5318
  C: (f, a) => f(...a)
5295
5319
  });
@@ -5306,6 +5330,10 @@ var ClientServicesHost = class {
5306
5330
  return this._serviceContext.dataSpaceManager;
5307
5331
  }),
5308
5332
  DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
5333
+ IndexService: new import_indexing2.IndexServiceImpl({
5334
+ indexer: this._serviceContext.indexer,
5335
+ automergeHost: this._serviceContext.automergeHost
5336
+ }),
5309
5337
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
5310
5338
  LoggingService: this._loggingService,
5311
5339
  TracingService: this._tracingService,
@@ -5319,7 +5347,7 @@ var ClientServicesHost = class {
5319
5347
  await this._serviceContext.open(ctx);
5320
5348
  (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5321
5349
  F: __dxlog_file18,
5322
- L: 297,
5350
+ L: 303,
5323
5351
  S: this,
5324
5352
  A: [
5325
5353
  "this.serviceRegistry.services.InvitationsService",
@@ -5331,7 +5359,7 @@ var ClientServicesHost = class {
5331
5359
  count: loadedInvitations.invitations?.length
5332
5360
  }, {
5333
5361
  F: __dxlog_file18,
5334
- L: 300,
5362
+ L: 306,
5335
5363
  S: this,
5336
5364
  C: (f, a) => f(...a)
5337
5365
  });
@@ -5353,7 +5381,7 @@ var ClientServicesHost = class {
5353
5381
  deviceKey
5354
5382
  }, {
5355
5383
  F: __dxlog_file18,
5356
- L: 317,
5384
+ L: 323,
5357
5385
  S: this,
5358
5386
  C: (f, a) => f(...a)
5359
5387
  });
@@ -5361,7 +5389,7 @@ var ClientServicesHost = class {
5361
5389
  id: traceId
5362
5390
  }), {
5363
5391
  F: __dxlog_file18,
5364
- L: 318,
5392
+ L: 324,
5365
5393
  S: this,
5366
5394
  C: (f, a) => f(...a)
5367
5395
  });
@@ -5375,7 +5403,7 @@ var ClientServicesHost = class {
5375
5403
  deviceKey
5376
5404
  }, {
5377
5405
  F: __dxlog_file18,
5378
- L: 329,
5406
+ L: 335,
5379
5407
  S: this,
5380
5408
  C: (f, a) => f(...a)
5381
5409
  });
@@ -5391,7 +5419,7 @@ var ClientServicesHost = class {
5391
5419
  deviceKey
5392
5420
  }, {
5393
5421
  F: __dxlog_file18,
5394
- L: 336,
5422
+ L: 342,
5395
5423
  S: this,
5396
5424
  C: (f, a) => f(...a)
5397
5425
  });
@@ -5402,13 +5430,13 @@ var ClientServicesHost = class {
5402
5430
  id: traceId
5403
5431
  }), {
5404
5432
  F: __dxlog_file18,
5405
- L: 341,
5433
+ L: 347,
5406
5434
  S: this,
5407
5435
  C: (f, a) => f(...a)
5408
5436
  });
5409
5437
  (0, import_log15.log)("resetting...", void 0, {
5410
5438
  F: __dxlog_file18,
5411
- L: 343,
5439
+ L: 349,
5412
5440
  S: this,
5413
5441
  C: (f, a) => f(...a)
5414
5442
  });
@@ -5416,7 +5444,7 @@ var ClientServicesHost = class {
5416
5444
  await this._storage.reset();
5417
5445
  (0, import_log15.log)("reset", void 0, {
5418
5446
  F: __dxlog_file18,
5419
- L: 346,
5447
+ L: 352,
5420
5448
  S: this,
5421
5449
  C: (f, a) => f(...a)
5422
5450
  });
@@ -5424,7 +5452,7 @@ var ClientServicesHost = class {
5424
5452
  id: traceId
5425
5453
  }), {
5426
5454
  F: __dxlog_file18,
5427
- L: 347,
5455
+ L: 353,
5428
5456
  S: this,
5429
5457
  C: (f, a) => f(...a)
5430
5458
  });
@@ -5439,7 +5467,7 @@ var ClientServicesHost = class {
5439
5467
  const automergeIndex = space.automergeSpaceState.rootUrl;
5440
5468
  (0, import_invariant16.invariant)(automergeIndex, void 0, {
5441
5469
  F: __dxlog_file18,
5442
- L: 362,
5470
+ L: 368,
5443
5471
  S: this,
5444
5472
  A: [
5445
5473
  "automergeIndex",
@@ -5451,8 +5479,8 @@ var ClientServicesHost = class {
5451
5479
  document.change((doc) => {
5452
5480
  (0, import_util9.assignDeep)(doc, [
5453
5481
  "objects",
5454
- (0, import_echo_schema2.getAutomergeObjectCore)(obj).id
5455
- ], (0, import_echo_schema2.getRawDoc)(obj).handle.docSync());
5482
+ (0, import_echo_schema.getAutomergeObjectCore)(obj).id
5483
+ ], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
5456
5484
  });
5457
5485
  return identity;
5458
5486
  }
@@ -5509,4 +5537,4 @@ ClientServicesHost = _ts_decorate8([
5509
5537
  subscribeToSpaces,
5510
5538
  subscribeToSwarmInfo
5511
5539
  });
5512
- //# sourceMappingURL=chunk-TWZLD46U.cjs.map
5540
+ //# sourceMappingURL=chunk-YFFKH75O.cjs.map