@dxos/client-services 0.4.10-main.93fda5f → 0.4.10-main.94e3e06

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.
@@ -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.93fda5f";
2772
+ var DXOS_VERSION = "0.4.10-main.94e3e06";
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";
@@ -2885,7 +2885,9 @@ import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask5, sleep as
2885
2885
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2886
2886
  import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
2887
2887
  import { timed, warnAfterTimeout } from "@dxos/debug";
2888
+ import { TYPE_PROPERTIES } from "@dxos/echo-db";
2888
2889
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2890
+ import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
2889
2891
  import { failedInvariant, invariant as invariant11 } from "@dxos/invariant";
2890
2892
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2891
2893
  import { log as log9 } from "@dxos/log";
@@ -2894,7 +2896,7 @@ import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/clien
2894
2896
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2895
2897
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2896
2898
  import { trace as trace6 } from "@dxos/tracing";
2897
- import { ComplexSet as ComplexSet3 } from "@dxos/util";
2899
+ import { ComplexSet as ComplexSet3, assignDeep } from "@dxos/util";
2898
2900
 
2899
2901
  // packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
2900
2902
  import { Event as Event4 } from "@dxos/async";
@@ -3249,7 +3251,7 @@ var DataSpace = class {
3249
3251
  state: SpaceState[this._state]
3250
3252
  }, {
3251
3253
  F: __dxlog_file12,
3252
- L: 132,
3254
+ L: 140,
3253
3255
  S: this,
3254
3256
  C: (f, a) => f(...a)
3255
3257
  });
@@ -3299,7 +3301,7 @@ var DataSpace = class {
3299
3301
  state: SpaceState[this._state]
3300
3302
  }, {
3301
3303
  F: __dxlog_file12,
3302
- L: 190,
3304
+ L: 198,
3303
3305
  S: this,
3304
3306
  C: (f, a) => f(...a)
3305
3307
  });
@@ -3317,7 +3319,7 @@ var DataSpace = class {
3317
3319
  state: SpaceState[this._state]
3318
3320
  }, {
3319
3321
  F: __dxlog_file12,
3320
- L: 204,
3322
+ L: 212,
3321
3323
  S: this,
3322
3324
  C: (f, a) => f(...a)
3323
3325
  });
@@ -3349,7 +3351,7 @@ var DataSpace = class {
3349
3351
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
3350
3352
  log9("data pipeline initialization cancelled", err, {
3351
3353
  F: __dxlog_file12,
3352
- L: 237,
3354
+ L: 245,
3353
3355
  S: this,
3354
3356
  C: (f, a) => f(...a)
3355
3357
  });
@@ -3357,7 +3359,7 @@ var DataSpace = class {
3357
3359
  }
3358
3360
  log9.error("Error initializing data pipeline", err, {
3359
3361
  F: __dxlog_file12,
3360
- L: 241,
3362
+ L: 249,
3361
3363
  S: this,
3362
3364
  C: (f, a) => f(...a)
3363
3365
  });
@@ -3366,7 +3368,7 @@ var DataSpace = class {
3366
3368
  state: SpaceState[this._state]
3367
3369
  }, {
3368
3370
  F: __dxlog_file12,
3369
- L: 243,
3371
+ L: 251,
3370
3372
  S: this,
3371
3373
  C: (f, a) => f(...a)
3372
3374
  });
@@ -3386,7 +3388,7 @@ var DataSpace = class {
3386
3388
  state: SpaceState[this._state]
3387
3389
  }, {
3388
3390
  F: __dxlog_file12,
3389
- L: 259,
3391
+ L: 267,
3390
3392
  S: this,
3391
3393
  C: (f, a) => f(...a)
3392
3394
  });
@@ -3396,7 +3398,7 @@ var DataSpace = class {
3396
3398
  await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3397
3399
  log9("data pipeline ready", void 0, {
3398
3400
  F: __dxlog_file12,
3399
- L: 271,
3401
+ L: 279,
3400
3402
  S: this,
3401
3403
  C: (f, a) => f(...a)
3402
3404
  });
@@ -3406,7 +3408,7 @@ var DataSpace = class {
3406
3408
  state: SpaceState[this._state]
3407
3409
  }, {
3408
3410
  F: __dxlog_file12,
3409
- L: 275,
3411
+ L: 283,
3410
3412
  S: this,
3411
3413
  C: (f, a) => f(...a)
3412
3414
  });
@@ -3422,7 +3424,7 @@ var DataSpace = class {
3422
3424
  await this._createWritableFeeds();
3423
3425
  log9("writable feeds created", void 0, {
3424
3426
  F: __dxlog_file12,
3425
- L: 291,
3427
+ L: 299,
3426
3428
  S: this,
3427
3429
  C: (f, a) => f(...a)
3428
3430
  });
@@ -3485,7 +3487,7 @@ var DataSpace = class {
3485
3487
  rootUrl
3486
3488
  }, {
3487
3489
  F: __dxlog_file12,
3488
- L: 357,
3490
+ L: 365,
3489
3491
  S: this,
3490
3492
  C: (f, a) => f(...a)
3491
3493
  });
@@ -3517,7 +3519,7 @@ var DataSpace = class {
3517
3519
  err
3518
3520
  }, {
3519
3521
  F: __dxlog_file12,
3520
- L: 380,
3522
+ L: 388,
3521
3523
  S: this,
3522
3524
  C: (f, a) => f(...a)
3523
3525
  });
@@ -3572,13 +3574,73 @@ var DataSpace = class {
3572
3574
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3573
3575
  invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3574
3576
  F: __dxlog_file12,
3575
- L: 430,
3577
+ L: 438,
3578
+ S: this,
3579
+ A: [
3580
+ "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3581
+ ""
3582
+ ]
3583
+ });
3584
+ epoch = {
3585
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3586
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3587
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
3588
+ automergeRoot: newRoot.url
3589
+ };
3590
+ }
3591
+ break;
3592
+ case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3593
+ {
3594
+ log9.info("Fragmenting", void 0, {
3595
+ F: __dxlog_file12,
3596
+ L: 450,
3597
+ S: this,
3598
+ C: (f, a) => f(...a)
3599
+ });
3600
+ const currentRootUrl = this._automergeSpaceState.rootUrl;
3601
+ const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3602
+ await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
3603
+ const objects = Object.entries(rootHandle.docSync().objects);
3604
+ const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
3605
+ const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3606
+ invariant11(properties, "Properties not found", {
3607
+ F: __dxlog_file12,
3608
+ L: 460,
3609
+ S: this,
3610
+ A: [
3611
+ "properties",
3612
+ "'Properties not found'"
3613
+ ]
3614
+ });
3615
+ const newSpaceDoc = {
3616
+ ...rootHandle.docSync(),
3617
+ objects: Object.fromEntries([
3618
+ properties
3619
+ ])
3620
+ };
3621
+ const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3622
+ invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3623
+ F: __dxlog_file12,
3624
+ L: 465,
3576
3625
  S: this,
3577
3626
  A: [
3578
3627
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3579
3628
  ""
3580
3629
  ]
3581
3630
  });
3631
+ const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3632
+ await docLoader.loadSpaceRootDocHandle(this._ctx, {
3633
+ rootUrl: newRoot.url
3634
+ });
3635
+ otherObjects.forEach(([key, value]) => {
3636
+ const handle = docLoader.createDocumentForObject(key);
3637
+ handle.change((doc) => {
3638
+ assignDeep(doc, [
3639
+ "objects",
3640
+ key
3641
+ ], value);
3642
+ });
3643
+ });
3582
3644
  epoch = {
3583
3645
  previousId: this._automergeSpaceState.lastEpoch?.id,
3584
3646
  number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
@@ -3628,7 +3690,7 @@ var DataSpace = class {
3628
3690
  state: SpaceState[this._state]
3629
3691
  }, {
3630
3692
  F: __dxlog_file12,
3631
- L: 482,
3693
+ L: 531,
3632
3694
  S: this,
3633
3695
  C: (f, a) => f(...a)
3634
3696
  });
@@ -4344,7 +4406,7 @@ import { safeInstanceof } from "@dxos/util";
4344
4406
  import { getHeads } from "@dxos/automerge/automerge";
4345
4407
  import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
4346
4408
  import { idCodec } from "@dxos/protocols";
4347
- var createLoadDocuments = (automergeHost) => (
4409
+ var createSelectedDocumentsIterator = (automergeHost) => (
4348
4410
  /**
4349
4411
  * Get object data blobs from Automerge Repo by ids.
4350
4412
  * @param ids
@@ -4357,17 +4419,17 @@ var createLoadDocuments = (automergeHost) => (
4357
4419
  await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
4358
4420
  const doc = handle.docSync();
4359
4421
  const hash = getHeads(doc).join("");
4360
- yield [
4422
+ yield doc.objects?.[objectId] ? [
4361
4423
  {
4362
4424
  id,
4363
4425
  object: doc.objects[objectId],
4364
4426
  currentHash: hash
4365
4427
  }
4366
- ];
4428
+ ] : [];
4367
4429
  }
4368
4430
  }
4369
4431
  );
4370
- var createGetAllDocuments = (automergeHost) => (
4432
+ var createDocumentsIterator = (automergeHost) => (
4371
4433
  /**
4372
4434
  * Recursively get all object data blobs from Automerge Repo.
4373
4435
  * @param ids
@@ -4390,7 +4452,7 @@ var createGetAllDocuments = (automergeHost) => (
4390
4452
  objectId
4391
4453
  }),
4392
4454
  object,
4393
- currentHash: heads.at(-1)
4455
+ currentHash: heads.join("")
4394
4456
  };
4395
4457
  });
4396
4458
  }
@@ -4474,8 +4536,8 @@ var ServiceContext = class {
4474
4536
  directory: storage.createDirectory("index-store")
4475
4537
  }),
4476
4538
  metadataStore: this.indexMetadata,
4477
- loadDocuments: createLoadDocuments(this.automergeHost),
4478
- getAllDocuments: createGetAllDocuments(this.automergeHost)
4539
+ loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
4540
+ getAllDocuments: createDocumentsIterator(this.automergeHost)
4479
4541
  });
4480
4542
  this.invitations = new InvitationsHandler(this.networkManager);
4481
4543
  this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
@@ -4885,11 +4947,12 @@ var toStorageType = (type) => {
4885
4947
  };
4886
4948
 
4887
4949
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4888
- import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
4889
- import { Properties, clientServiceBundle, defaultKey } from "@dxos/client-protocol";
4950
+ import { Event as Event9, sleep as sleep3, synchronized as synchronized3 } from "@dxos/async";
4951
+ import { clientServiceBundle, defaultKey, PropertiesSchema } from "@dxos/client-protocol";
4890
4952
  import { Context as Context11 } from "@dxos/context";
4891
4953
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4892
- import { getAutomergeObjectCore, getRawDoc } from "@dxos/echo-schema";
4954
+ import * as E from "@dxos/echo-schema";
4955
+ import { createRawObjectDoc } from "@dxos/echo-schema";
4893
4956
  import { IndexServiceImpl } from "@dxos/indexing";
4894
4957
  import { invariant as invariant16 } from "@dxos/invariant";
4895
4958
  import { PublicKey as PublicKey12 } from "@dxos/keys";
@@ -4899,7 +4962,7 @@ import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-
4899
4962
  import { trace as trace9 } from "@dxos/protocols";
4900
4963
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
4901
4964
  import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace3 } from "@dxos/tracing";
4902
- import { assignDeep } from "@dxos/util";
4965
+ import { assignDeep as assignDeep2 } from "@dxos/util";
4903
4966
  import { WebsocketRpcClient } from "@dxos/websocket-rpc";
4904
4967
 
4905
4968
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
@@ -5296,7 +5359,7 @@ var ClientServicesHost = class {
5296
5359
  initialize({ config, ...options }) {
5297
5360
  invariant16(!this._open, "service host is open", {
5298
5361
  F: __dxlog_file18,
5299
- L: 179,
5362
+ L: 180,
5300
5363
  S: this,
5301
5364
  A: [
5302
5365
  "!this._open",
@@ -5305,14 +5368,14 @@ var ClientServicesHost = class {
5305
5368
  });
5306
5369
  log15("initializing...", void 0, {
5307
5370
  F: __dxlog_file18,
5308
- L: 180,
5371
+ L: 181,
5309
5372
  S: this,
5310
5373
  C: (f, a) => f(...a)
5311
5374
  });
5312
5375
  if (config) {
5313
5376
  invariant16(!this._config, "config already set", {
5314
5377
  F: __dxlog_file18,
5315
- L: 183,
5378
+ L: 184,
5316
5379
  S: this,
5317
5380
  A: [
5318
5381
  "!this._config",
@@ -5327,7 +5390,7 @@ var ClientServicesHost = class {
5327
5390
  if (!options.signalManager) {
5328
5391
  log15.warn("running signaling without telemetry metadata.", void 0, {
5329
5392
  F: __dxlog_file18,
5330
- L: 191,
5393
+ L: 192,
5331
5394
  S: this,
5332
5395
  C: (f, a) => f(...a)
5333
5396
  });
@@ -5338,7 +5401,7 @@ var ClientServicesHost = class {
5338
5401
  this._signalManager = signalManager;
5339
5402
  invariant16(!this._networkManager, "network manager already set", {
5340
5403
  F: __dxlog_file18,
5341
- L: 202,
5404
+ L: 203,
5342
5405
  S: this,
5343
5406
  A: [
5344
5407
  "!this._networkManager",
@@ -5352,7 +5415,7 @@ var ClientServicesHost = class {
5352
5415
  });
5353
5416
  log15("initialized", void 0, {
5354
5417
  F: __dxlog_file18,
5355
- L: 209,
5418
+ L: 210,
5356
5419
  S: this,
5357
5420
  C: (f, a) => f(...a)
5358
5421
  });
@@ -5366,13 +5429,13 @@ var ClientServicesHost = class {
5366
5429
  id: traceId
5367
5430
  }), {
5368
5431
  F: __dxlog_file18,
5369
- L: 220,
5432
+ L: 221,
5370
5433
  S: this,
5371
5434
  C: (f, a) => f(...a)
5372
5435
  });
5373
5436
  invariant16(this._config, "config not set", {
5374
5437
  F: __dxlog_file18,
5375
- L: 222,
5438
+ L: 223,
5376
5439
  S: this,
5377
5440
  A: [
5378
5441
  "this._config",
@@ -5381,7 +5444,7 @@ var ClientServicesHost = class {
5381
5444
  });
5382
5445
  invariant16(this._storage, "storage not set", {
5383
5446
  F: __dxlog_file18,
5384
- L: 223,
5447
+ L: 224,
5385
5448
  S: this,
5386
5449
  A: [
5387
5450
  "this._storage",
@@ -5390,7 +5453,7 @@ var ClientServicesHost = class {
5390
5453
  });
5391
5454
  invariant16(this._signalManager, "signal manager not set", {
5392
5455
  F: __dxlog_file18,
5393
- L: 224,
5456
+ L: 225,
5394
5457
  S: this,
5395
5458
  A: [
5396
5459
  "this._signalManager",
@@ -5399,7 +5462,7 @@ var ClientServicesHost = class {
5399
5462
  });
5400
5463
  invariant16(this._networkManager, "network manager not set", {
5401
5464
  F: __dxlog_file18,
5402
- L: 225,
5465
+ L: 226,
5403
5466
  S: this,
5404
5467
  A: [
5405
5468
  "this._networkManager",
@@ -5411,7 +5474,7 @@ var ClientServicesHost = class {
5411
5474
  lockKey: this._resourceLock?.lockKey
5412
5475
  }, {
5413
5476
  F: __dxlog_file18,
5414
- L: 228,
5477
+ L: 229,
5415
5478
  S: this,
5416
5479
  C: (f, a) => f(...a)
5417
5480
  });
@@ -5445,7 +5508,7 @@ var ClientServicesHost = class {
5445
5508
  await this._serviceContext.open(ctx);
5446
5509
  invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
5447
5510
  F: __dxlog_file18,
5448
- L: 289,
5511
+ L: 290,
5449
5512
  S: this,
5450
5513
  A: [
5451
5514
  "this.serviceRegistry.services.InvitationsService",
@@ -5457,7 +5520,7 @@ var ClientServicesHost = class {
5457
5520
  count: loadedInvitations.invitations?.length
5458
5521
  }, {
5459
5522
  F: __dxlog_file18,
5460
- L: 292,
5523
+ L: 293,
5461
5524
  S: this,
5462
5525
  C: (f, a) => f(...a)
5463
5526
  });
@@ -5479,7 +5542,7 @@ var ClientServicesHost = class {
5479
5542
  deviceKey
5480
5543
  }, {
5481
5544
  F: __dxlog_file18,
5482
- L: 309,
5545
+ L: 310,
5483
5546
  S: this,
5484
5547
  C: (f, a) => f(...a)
5485
5548
  });
@@ -5487,7 +5550,7 @@ var ClientServicesHost = class {
5487
5550
  id: traceId
5488
5551
  }), {
5489
5552
  F: __dxlog_file18,
5490
- L: 310,
5553
+ L: 311,
5491
5554
  S: this,
5492
5555
  C: (f, a) => f(...a)
5493
5556
  });
@@ -5501,7 +5564,7 @@ var ClientServicesHost = class {
5501
5564
  deviceKey
5502
5565
  }, {
5503
5566
  F: __dxlog_file18,
5504
- L: 321,
5567
+ L: 322,
5505
5568
  S: this,
5506
5569
  C: (f, a) => f(...a)
5507
5570
  });
@@ -5517,7 +5580,7 @@ var ClientServicesHost = class {
5517
5580
  deviceKey
5518
5581
  }, {
5519
5582
  F: __dxlog_file18,
5520
- L: 328,
5583
+ L: 329,
5521
5584
  S: this,
5522
5585
  C: (f, a) => f(...a)
5523
5586
  });
@@ -5528,13 +5591,13 @@ var ClientServicesHost = class {
5528
5591
  id: traceId
5529
5592
  }), {
5530
5593
  F: __dxlog_file18,
5531
- L: 333,
5594
+ L: 334,
5532
5595
  S: this,
5533
5596
  C: (f, a) => f(...a)
5534
5597
  });
5535
5598
  log15("resetting...", void 0, {
5536
5599
  F: __dxlog_file18,
5537
- L: 335,
5600
+ L: 336,
5538
5601
  S: this,
5539
5602
  C: (f, a) => f(...a)
5540
5603
  });
@@ -5542,7 +5605,7 @@ var ClientServicesHost = class {
5542
5605
  await this._storage.reset();
5543
5606
  log15("reset", void 0, {
5544
5607
  F: __dxlog_file18,
5545
- L: 338,
5608
+ L: 339,
5546
5609
  S: this,
5547
5610
  C: (f, a) => f(...a)
5548
5611
  });
@@ -5550,7 +5613,7 @@ var ClientServicesHost = class {
5550
5613
  id: traceId
5551
5614
  }), {
5552
5615
  F: __dxlog_file18,
5553
- L: 339,
5616
+ L: 340,
5554
5617
  S: this,
5555
5618
  C: (f, a) => f(...a)
5556
5619
  });
@@ -5560,12 +5623,10 @@ var ClientServicesHost = class {
5560
5623
  const identity = await this._serviceContext.createIdentity(params);
5561
5624
  await this._serviceContext.initialized.wait();
5562
5625
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5563
- const obj = new Properties(void 0);
5564
- obj[defaultKey] = identity.identityKey.toHex();
5565
5626
  const automergeIndex = space.automergeSpaceState.rootUrl;
5566
5627
  invariant16(automergeIndex, void 0, {
5567
5628
  F: __dxlog_file18,
5568
- L: 354,
5629
+ L: 352,
5569
5630
  S: this,
5570
5631
  A: [
5571
5632
  "automergeIndex",
@@ -5574,12 +5635,18 @@ var ClientServicesHost = class {
5574
5635
  });
5575
5636
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5576
5637
  await document.whenReady();
5638
+ const objectDocument = createRawObjectDoc({
5639
+ [defaultKey]: identity.identityKey.toHex()
5640
+ }, {
5641
+ type: E.getTypeReference(PropertiesSchema)
5642
+ });
5577
5643
  document.change((doc) => {
5578
- assignDeep(doc, [
5644
+ assignDeep2(doc, [
5579
5645
  "objects",
5580
- getAutomergeObjectCore(obj).id
5581
- ], getRawDoc(obj).handle.docSync());
5646
+ objectDocument.id
5647
+ ], objectDocument.handle.docSync());
5582
5648
  });
5649
+ await sleep3(200);
5583
5650
  return identity;
5584
5651
  }
5585
5652
  };
@@ -5635,4 +5702,4 @@ export {
5635
5702
  createStorageObjects,
5636
5703
  ClientServicesHost
5637
5704
  };
5638
- //# sourceMappingURL=chunk-ULO2U4N6.mjs.map
5705
+ //# sourceMappingURL=chunk-WRFCA2FV.mjs.map