@dxos/client-services 0.4.7-main.b23cefb → 0.4.7-main.b51ad3a

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 (36) hide show
  1. package/dist/lib/browser/{chunk-Q4ZW7SKD.mjs → chunk-W4YHONPO.mjs} +122 -70
  2. package/dist/lib/browser/{chunk-Q4ZW7SKD.mjs.map → chunk-W4YHONPO.mjs.map} +3 -3
  3. package/dist/lib/browser/index.mjs +4 -2
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +4 -2
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-QTXFCLVV.cjs → chunk-UGRBM6TA.cjs} +97 -45
  9. package/dist/lib/node/chunk-UGRBM6TA.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +40 -38
  11. package/dist/lib/node/index.cjs.map +2 -2
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +11 -9
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -0
  16. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-context.d.ts +2 -0
  18. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
  20. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  23. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  24. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +35 -35
  27. package/src/packlets/logging/logging-service.ts +9 -2
  28. package/src/packlets/services/automerge-host.test.ts +1 -1
  29. package/src/packlets/services/service-context.ts +7 -1
  30. package/src/packlets/spaces/automerge-space-state.ts +15 -0
  31. package/src/packlets/spaces/data-space.ts +33 -11
  32. package/src/packlets/spaces/spaces-service.ts +3 -5
  33. package/src/packlets/testing/test-builder.ts +1 -1
  34. package/src/packlets/vault/shared-worker-connection.ts +2 -0
  35. package/src/version.ts +1 -1
  36. package/dist/lib/node/chunk-QTXFCLVV.cjs.map +0 -7
@@ -2671,7 +2671,7 @@ var getPlatform = () => {
2671
2671
  };
2672
2672
 
2673
2673
  // packages/sdk/client-services/src/version.ts
2674
- var DXOS_VERSION = "0.4.7-main.b23cefb";
2674
+ var DXOS_VERSION = "0.4.7-main.b51ad3a";
2675
2675
 
2676
2676
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2677
2677
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -2813,12 +2813,12 @@ var getSpaceStats = async (space) => {
2813
2813
  };
2814
2814
 
2815
2815
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2816
- import { Event as Event5, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
2816
+ import { Event as Event5, asyncTimeout, scheduleTask as scheduleTask4, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
2817
2817
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2818
2818
  import { cancelWithContext as cancelWithContext2, Context as Context7, ContextDisposedError } from "@dxos/context";
2819
2819
  import { timed, warnAfterTimeout } from "@dxos/debug";
2820
2820
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2821
- import { failedInvariant } from "@dxos/invariant";
2821
+ import { failedInvariant, invariant as invariant11 } from "@dxos/invariant";
2822
2822
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2823
2823
  import { log as log10 } from "@dxos/log";
2824
2824
  import { CancelledError, SystemError } from "@dxos/protocols";
@@ -2835,6 +2835,7 @@ var AutomergeSpaceState = class {
2835
2835
  this._onNewRoot = _onNewRoot;
2836
2836
  this.rootUrl = void 0;
2837
2837
  this.lastEpoch = void 0;
2838
+ this._isProcessingRootDocs = false;
2838
2839
  }
2839
2840
  async processCredential(credential) {
2840
2841
  if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
@@ -2843,8 +2844,19 @@ var AutomergeSpaceState = class {
2843
2844
  this.lastEpoch = credential;
2844
2845
  if (credential.subject.assertion.automergeRoot) {
2845
2846
  this.rootUrl = credential.subject.assertion.automergeRoot;
2847
+ if (this._isProcessingRootDocs) {
2848
+ this._onNewRoot(this.rootUrl);
2849
+ }
2850
+ }
2851
+ }
2852
+ startProcessingRootDocs() {
2853
+ if (this._isProcessingRootDocs) {
2854
+ return;
2855
+ }
2856
+ if (this.rootUrl) {
2846
2857
  this._onNewRoot(this.rootUrl);
2847
2858
  }
2859
+ this._isProcessingRootDocs = true;
2848
2860
  }
2849
2861
  };
2850
2862
 
@@ -3310,12 +3322,13 @@ var DataSpace = class {
3310
3322
  });
3311
3323
  await this._initializeAndReadControlPipeline();
3312
3324
  await sleep2(1);
3325
+ this._automergeSpaceState.startProcessingRootDocs();
3313
3326
  await this._inner.initializeDataPipeline();
3314
3327
  this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
3315
3328
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3316
3329
  log10("waiting for data pipeline to reach target timeframe", void 0, {
3317
3330
  F: __dxlog_file12,
3318
- L: 286,
3331
+ L: 288,
3319
3332
  S: this,
3320
3333
  C: (f, a) => f(...a)
3321
3334
  });
@@ -3326,7 +3339,7 @@ var DataSpace = class {
3326
3339
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3327
3340
  log10("data pipeline ready", void 0, {
3328
3341
  F: __dxlog_file12,
3329
- L: 294,
3342
+ L: 296,
3330
3343
  S: this,
3331
3344
  C: (f, a) => f(...a)
3332
3345
  });
@@ -3336,7 +3349,7 @@ var DataSpace = class {
3336
3349
  state: SpaceState[this._state]
3337
3350
  }, {
3338
3351
  F: __dxlog_file12,
3339
- L: 298,
3352
+ L: 300,
3340
3353
  S: this,
3341
3354
  C: (f, a) => f(...a)
3342
3355
  });
@@ -3352,7 +3365,7 @@ var DataSpace = class {
3352
3365
  await this._createWritableFeeds();
3353
3366
  log10("writable feeds created", void 0, {
3354
3367
  F: __dxlog_file12,
3355
- L: 314,
3368
+ L: 316,
3356
3369
  S: this,
3357
3370
  C: (f, a) => f(...a)
3358
3371
  });
@@ -3415,7 +3428,7 @@ var DataSpace = class {
3415
3428
  rootUrl
3416
3429
  }, {
3417
3430
  F: __dxlog_file12,
3418
- L: 380,
3431
+ L: 382,
3419
3432
  S: this,
3420
3433
  C: (f, a) => f(...a)
3421
3434
  });
@@ -3447,7 +3460,7 @@ var DataSpace = class {
3447
3460
  err
3448
3461
  }, {
3449
3462
  F: __dxlog_file12,
3450
- L: 403,
3463
+ L: 405,
3451
3464
  S: this,
3452
3465
  C: (f, a) => f(...a)
3453
3466
  });
@@ -3478,15 +3491,40 @@ var DataSpace = class {
3478
3491
  epoch = await this.dataPipeline.createEpoch();
3479
3492
  }
3480
3493
  break;
3481
- case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3482
- const document = this._automergeHost.repo.create();
3483
- epoch = {
3484
- previousId: this._automergeSpaceState.lastEpoch?.id,
3485
- number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3486
- timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
3487
- automergeRoot: document.url
3488
- };
3489
- }
3494
+ case CreateEpochRequest.Migration.INIT_AUTOMERGE:
3495
+ {
3496
+ const document = this._automergeHost.repo.create();
3497
+ epoch = {
3498
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3499
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3500
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
3501
+ automergeRoot: document.url
3502
+ };
3503
+ }
3504
+ break;
3505
+ case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3506
+ {
3507
+ const currentRootUrl = this._automergeSpaceState.rootUrl;
3508
+ const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3509
+ await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
3510
+ const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3511
+ invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3512
+ F: __dxlog_file12,
3513
+ L: 450,
3514
+ S: this,
3515
+ A: [
3516
+ "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3517
+ ""
3518
+ ]
3519
+ });
3520
+ epoch = {
3521
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3522
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3523
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
3524
+ automergeRoot: newRoot.url
3525
+ };
3526
+ }
3527
+ break;
3490
3528
  }
3491
3529
  if (!epoch) {
3492
3530
  return;
@@ -3537,7 +3575,7 @@ var DataSpace = class {
3537
3575
  state: SpaceState[this._state]
3538
3576
  }, {
3539
3577
  F: __dxlog_file12,
3540
- L: 492,
3578
+ L: 514,
3541
3579
  S: this,
3542
3580
  C: (f, a) => f(...a)
3543
3581
  });
@@ -3594,7 +3632,7 @@ DataSpace = _ts_decorate4([
3594
3632
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
3595
3633
  import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
3596
3634
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3597
- import { invariant as invariant11 } from "@dxos/invariant";
3635
+ import { invariant as invariant12 } from "@dxos/invariant";
3598
3636
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3599
3637
  import { log as log11 } from "@dxos/log";
3600
3638
  import { trace as trace7 } from "@dxos/protocols";
@@ -3787,7 +3825,7 @@ var DataSpaceManager = class {
3787
3825
  * Creates a new space writing the genesis credentials to the control feed.
3788
3826
  */
3789
3827
  async createSpace() {
3790
- invariant11(this._isOpen, "Not open.", {
3828
+ invariant12(this._isOpen, "Not open.", {
3791
3829
  F: __dxlog_file13,
3792
3830
  L: 145,
3793
3831
  S: this,
@@ -3824,7 +3862,7 @@ var DataSpaceManager = class {
3824
3862
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3825
3863
  await this._metadataStore.addSpace(metadata);
3826
3864
  const memberCredential = credentials[1];
3827
- invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3865
+ invariant12(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3828
3866
  F: __dxlog_file13,
3829
3867
  L: 170,
3830
3868
  S: this,
@@ -3848,7 +3886,7 @@ var DataSpaceManager = class {
3848
3886
  S: this,
3849
3887
  C: (f, a) => f(...a)
3850
3888
  });
3851
- invariant11(this._isOpen, "Not open.", {
3889
+ invariant12(this._isOpen, "Not open.", {
3852
3890
  F: __dxlog_file13,
3853
3891
  L: 183,
3854
3892
  S: this,
@@ -3857,7 +3895,7 @@ var DataSpaceManager = class {
3857
3895
  "'Not open.'"
3858
3896
  ]
3859
3897
  });
3860
- invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3898
+ invariant12(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3861
3899
  F: __dxlog_file13,
3862
3900
  L: 184,
3863
3901
  S: this,
@@ -4024,7 +4062,7 @@ DataSpaceManager = _ts_decorate5([
4024
4062
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
4025
4063
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
4026
4064
  import { raise as raise2 } from "@dxos/debug";
4027
- import { invariant as invariant12 } from "@dxos/invariant";
4065
+ import { invariant as invariant13 } from "@dxos/invariant";
4028
4066
  import { log as log12 } from "@dxos/log";
4029
4067
  import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
4030
4068
  import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
@@ -4153,7 +4191,7 @@ var SpacesServiceImpl = class {
4153
4191
  }
4154
4192
  });
4155
4193
  } else {
4156
- invariant12(!credential.id, "Id on unsigned credentials is not allowed", {
4194
+ invariant13(!credential.id, "Id on unsigned credentials is not allowed", {
4157
4195
  F: __dxlog_file14,
4158
4196
  L: 168,
4159
4197
  S: this,
@@ -4162,7 +4200,7 @@ var SpacesServiceImpl = class {
4162
4200
  "'Id on unsigned credentials is not allowed'"
4163
4201
  ]
4164
4202
  });
4165
- invariant12(this._identityManager.identity, "Identity is not available", {
4203
+ invariant13(this._identityManager.identity, "Identity is not available", {
4166
4204
  F: __dxlog_file14,
4167
4205
  L: 169,
4168
4206
  S: this,
@@ -4172,7 +4210,7 @@ var SpacesServiceImpl = class {
4172
4210
  ]
4173
4211
  });
4174
4212
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4175
- invariant12(credential.issuer.equals(signer.getIssuer()), void 0, {
4213
+ invariant13(credential.issuer.equals(signer.getIssuer()), void 0, {
4176
4214
  F: __dxlog_file14,
4177
4215
  L: 171,
4178
4216
  S: this,
@@ -4193,10 +4231,12 @@ var SpacesServiceImpl = class {
4193
4231
  }
4194
4232
  }
4195
4233
  }
4196
- async createEpoch({ spaceKey }) {
4234
+ async createEpoch({ spaceKey, migration }) {
4197
4235
  const dataSpaceManager = await this._getDataSpaceManager();
4198
4236
  const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
4199
- await space.createEpoch();
4237
+ await space.createEpoch({
4238
+ migration
4239
+ });
4200
4240
  }
4201
4241
  _serializeSpace(space) {
4202
4242
  return {
@@ -4225,9 +4265,7 @@ var SpacesServiceImpl = class {
4225
4265
  return {
4226
4266
  identity: {
4227
4267
  identityKey: member.key,
4228
- profile: {
4229
- displayName: member.profile?.displayName
4230
- }
4268
+ profile: member.profile ?? {}
4231
4269
  },
4232
4270
  presence: member.removed ? SpaceMember3.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
4233
4271
  peerStates: peers
@@ -4247,8 +4285,9 @@ import { Context as Context9 } from "@dxos/context";
4247
4285
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4248
4286
  import { failUndefined as failUndefined2 } from "@dxos/debug";
4249
4287
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
4288
+ import { IndexMetadataStore } from "@dxos/echo-schema";
4250
4289
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
4251
- import { invariant as invariant13 } from "@dxos/invariant";
4290
+ import { invariant as invariant14 } from "@dxos/invariant";
4252
4291
  import { Keyring } from "@dxos/keyring";
4253
4292
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4254
4293
  import { log as log13 } from "@dxos/log";
@@ -4280,6 +4319,9 @@ var ServiceContext = class {
4280
4319
  this._handlerFactories = /* @__PURE__ */ new Map();
4281
4320
  this._instanceId = PublicKey10.random().toHex();
4282
4321
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
4322
+ this.indexMetadata = new IndexMetadataStore({
4323
+ directory: storage.createDirectory("index-metadata")
4324
+ });
4283
4325
  this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
4284
4326
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
4285
4327
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -4302,7 +4344,10 @@ var ServiceContext = class {
4302
4344
  snapshotStore: this.snapshotStore
4303
4345
  });
4304
4346
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4305
- this.automergeHost = new AutomergeHost(storage.createDirectory("automerge"));
4347
+ this.automergeHost = new AutomergeHost({
4348
+ directory: storage.createDirectory("automerge"),
4349
+ metadata: this.indexMetadata
4350
+ });
4306
4351
  this.invitations = new InvitationsHandler(this.networkManager);
4307
4352
  this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
4308
4353
  }
@@ -4310,7 +4355,7 @@ var ServiceContext = class {
4310
4355
  await this._checkStorageVersion();
4311
4356
  log13("opening...", void 0, {
4312
4357
  F: __dxlog_file15,
4313
- L: 146,
4358
+ L: 152,
4314
4359
  S: this,
4315
4360
  C: (f, a) => f(...a)
4316
4361
  });
@@ -4318,7 +4363,7 @@ var ServiceContext = class {
4318
4363
  id: this._instanceId
4319
4364
  }), {
4320
4365
  F: __dxlog_file15,
4321
- L: 147,
4366
+ L: 153,
4322
4367
  S: this,
4323
4368
  C: (f, a) => f(...a)
4324
4369
  });
@@ -4334,13 +4379,13 @@ var ServiceContext = class {
4334
4379
  id: this._instanceId
4335
4380
  }), {
4336
4381
  F: __dxlog_file15,
4337
- L: 157,
4382
+ L: 163,
4338
4383
  S: this,
4339
4384
  C: (f, a) => f(...a)
4340
4385
  });
4341
4386
  log13("opened", void 0, {
4342
4387
  F: __dxlog_file15,
4343
- L: 158,
4388
+ L: 164,
4344
4389
  S: this,
4345
4390
  C: (f, a) => f(...a)
4346
4391
  });
@@ -4348,7 +4393,7 @@ var ServiceContext = class {
4348
4393
  async close() {
4349
4394
  log13("closing...", void 0, {
4350
4395
  F: __dxlog_file15,
4351
- L: 162,
4396
+ L: 168,
4352
4397
  S: this,
4353
4398
  C: (f, a) => f(...a)
4354
4399
  });
@@ -4366,7 +4411,7 @@ var ServiceContext = class {
4366
4411
  await this.metadataStore.close();
4367
4412
  log13("closed", void 0, {
4368
4413
  F: __dxlog_file15,
4369
- L: 175,
4414
+ L: 181,
4370
4415
  S: this,
4371
4416
  C: (f, a) => f(...a)
4372
4417
  });
@@ -4378,9 +4423,9 @@ var ServiceContext = class {
4378
4423
  }
4379
4424
  getInvitationHandler(invitation) {
4380
4425
  const factory = this._handlerFactories.get(invitation.kind);
4381
- invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
4426
+ invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
4382
4427
  F: __dxlog_file15,
4383
- L: 186,
4428
+ L: 192,
4384
4429
  S: this,
4385
4430
  A: [
4386
4431
  "factory",
@@ -4412,7 +4457,7 @@ var ServiceContext = class {
4412
4457
  async _initialize(ctx) {
4413
4458
  log13("initializing spaces...", void 0, {
4414
4459
  F: __dxlog_file15,
4415
- L: 217,
4460
+ L: 223,
4416
4461
  S: this,
4417
4462
  C: (f, a) => f(...a)
4418
4463
  });
@@ -4433,9 +4478,9 @@ var ServiceContext = class {
4433
4478
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4434
4479
  await this.dataSpaceManager.open();
4435
4480
  this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
4436
- invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4481
+ invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4437
4482
  F: __dxlog_file15,
4438
- L: 242,
4483
+ L: 248,
4439
4484
  S: this,
4440
4485
  A: [
4441
4486
  "this.dataSpaceManager",
@@ -4459,7 +4504,7 @@ var ServiceContext = class {
4459
4504
  details: assertion
4460
4505
  }, {
4461
4506
  F: __dxlog_file15,
4462
- L: 258,
4507
+ L: 264,
4463
4508
  S: this,
4464
4509
  C: (f, a) => f(...a)
4465
4510
  });
@@ -4470,7 +4515,7 @@ var ServiceContext = class {
4470
4515
  details: assertion
4471
4516
  }, {
4472
4517
  F: __dxlog_file15,
4473
- L: 262,
4518
+ L: 268,
4474
4519
  S: this,
4475
4520
  C: (f, a) => f(...a)
4476
4521
  });
@@ -4481,7 +4526,7 @@ var ServiceContext = class {
4481
4526
  details: assertion
4482
4527
  }, {
4483
4528
  F: __dxlog_file15,
4484
- L: 267,
4529
+ L: 273,
4485
4530
  S: this,
4486
4531
  C: (f, a) => f(...a)
4487
4532
  });
@@ -4492,7 +4537,7 @@ var ServiceContext = class {
4492
4537
  } catch (err) {
4493
4538
  log13.catch(err, void 0, {
4494
4539
  F: __dxlog_file15,
4495
- L: 273,
4540
+ L: 279,
4496
4541
  S: this,
4497
4542
  C: (f, a) => f(...a)
4498
4543
  });
@@ -4538,7 +4583,7 @@ var ServiceRegistry = class {
4538
4583
  };
4539
4584
 
4540
4585
  // packages/sdk/client-services/src/packlets/locks/browser.ts
4541
- import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
4586
+ import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
4542
4587
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
4543
4588
  import { log as log14, logInfo } from "@dxos/log";
4544
4589
  function _ts_decorate7(decorators, target, key, desc) {
@@ -4579,7 +4624,7 @@ var Lock = class {
4579
4624
  S: this,
4580
4625
  C: (f, a) => f(...a)
4581
4626
  });
4582
- await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
4627
+ await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
4583
4628
  log14("acquired lock", void 0, {
4584
4629
  F: __dxlog_file16,
4585
4630
  L: 44,
@@ -4717,8 +4762,8 @@ import { Context as Context10 } from "@dxos/context";
4717
4762
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4718
4763
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4719
4764
  import { getRawDoc, getAutomergeObjectCore } from "@dxos/echo-schema";
4720
- import { invariant as invariant15 } from "@dxos/invariant";
4721
- import { PublicKey as PublicKey11 } from "@dxos/keys";
4765
+ import { invariant as invariant16 } from "@dxos/invariant";
4766
+ import { PublicKey as PublicKey12 } from "@dxos/keys";
4722
4767
  import { log as log16 } from "@dxos/log";
4723
4768
  import { WebsocketSignalManager } from "@dxos/messaging";
4724
4769
  import { ModelFactory } from "@dxos/model-factory";
@@ -4733,7 +4778,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
4733
4778
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
4734
4779
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
4735
4780
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
4736
- import { invariant as invariant14 } from "@dxos/invariant";
4781
+ import { invariant as invariant15 } from "@dxos/invariant";
4737
4782
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
4738
4783
  var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4739
4784
  var DevicesServiceImpl = class {
@@ -4752,7 +4797,7 @@ var DevicesServiceImpl = class {
4752
4797
  devices: []
4753
4798
  });
4754
4799
  } else {
4755
- invariant14(this._identityManager.identity?.presence, "presence not present", {
4800
+ invariant15(this._identityManager.identity?.presence, "presence not present", {
4756
4801
  F: __dxlog_file17,
4757
4802
  L: 32,
4758
4803
  S: this,
@@ -4815,13 +4860,15 @@ var DevicesServiceImpl = class {
4815
4860
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
4816
4861
  import { Event as Event7 } from "@dxos/async";
4817
4862
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
4863
+ import { PublicKey as PublicKey11 } from "@dxos/keys";
4818
4864
  import { getContextFromEntry, log as log15 } from "@dxos/log";
4819
4865
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
4820
- import { jsonify, numericalValues, tracer } from "@dxos/util";
4866
+ import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
4821
4867
  var LoggingServiceImpl = class {
4822
4868
  constructor() {
4823
4869
  this._logs = new Event7();
4824
- this._started = /* @__PURE__ */ new Date();
4870
+ this._started = Date.now();
4871
+ this._sessionId = PublicKey11.random().toHex();
4825
4872
  this._logProcessor = (_config, entry2) => {
4826
4873
  this._logs.emit(entry2);
4827
4874
  };
@@ -4897,7 +4944,12 @@ var LoggingServiceImpl = class {
4897
4944
  meta: {
4898
4945
  // TODO(dmaretskyi): Fix proto.
4899
4946
  file: entry2.meta?.F ?? "",
4900
- line: entry2.meta?.L ?? 0
4947
+ line: entry2.meta?.L ?? 0,
4948
+ scope: {
4949
+ hostSessionId: this._sessionId,
4950
+ uptimeSeconds: (Date.now() - this._started) / 1e3,
4951
+ name: getDebugName(entry2.meta?.S)
4952
+ }
4901
4953
  }
4902
4954
  };
4903
4955
  try {
@@ -5120,7 +5172,7 @@ var ClientServicesHost = class {
5120
5172
  * Can only be called once.
5121
5173
  */
5122
5174
  initialize({ config, ...options }) {
5123
- invariant15(!this._open, "service host is open", {
5175
+ invariant16(!this._open, "service host is open", {
5124
5176
  F: __dxlog_file18,
5125
5177
  L: 190,
5126
5178
  S: this,
@@ -5136,7 +5188,7 @@ var ClientServicesHost = class {
5136
5188
  C: (f, a) => f(...a)
5137
5189
  });
5138
5190
  if (config) {
5139
- invariant15(!this._config, "config already set", {
5191
+ invariant16(!this._config, "config already set", {
5140
5192
  F: __dxlog_file18,
5141
5193
  L: 194,
5142
5194
  S: this,
@@ -5154,7 +5206,7 @@ var ClientServicesHost = class {
5154
5206
  iceServers: this._config?.get("runtime.services.ice")
5155
5207
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5156
5208
  this._signalManager = signalManager;
5157
- invariant15(!this._networkManager, "network manager already set", {
5209
+ invariant16(!this._networkManager, "network manager already set", {
5158
5210
  F: __dxlog_file18,
5159
5211
  L: 210,
5160
5212
  S: this,
@@ -5179,7 +5231,7 @@ var ClientServicesHost = class {
5179
5231
  if (this._open) {
5180
5232
  return;
5181
5233
  }
5182
- const traceId = PublicKey11.random().toHex();
5234
+ const traceId = PublicKey12.random().toHex();
5183
5235
  log16.trace("dxos.client-services.host.open", trace9.begin({
5184
5236
  id: traceId
5185
5237
  }), {
@@ -5188,7 +5240,7 @@ var ClientServicesHost = class {
5188
5240
  S: this,
5189
5241
  C: (f, a) => f(...a)
5190
5242
  });
5191
- invariant15(this._config, "config not set", {
5243
+ invariant16(this._config, "config not set", {
5192
5244
  F: __dxlog_file18,
5193
5245
  L: 230,
5194
5246
  S: this,
@@ -5197,7 +5249,7 @@ var ClientServicesHost = class {
5197
5249
  "'config not set'"
5198
5250
  ]
5199
5251
  });
5200
- invariant15(this._storage, "storage not set", {
5252
+ invariant16(this._storage, "storage not set", {
5201
5253
  F: __dxlog_file18,
5202
5254
  L: 231,
5203
5255
  S: this,
@@ -5206,7 +5258,7 @@ var ClientServicesHost = class {
5206
5258
  "'storage not set'"
5207
5259
  ]
5208
5260
  });
5209
- invariant15(this._signalManager, "signal manager not set", {
5261
+ invariant16(this._signalManager, "signal manager not set", {
5210
5262
  F: __dxlog_file18,
5211
5263
  L: 232,
5212
5264
  S: this,
@@ -5215,7 +5267,7 @@ var ClientServicesHost = class {
5215
5267
  "'signal manager not set'"
5216
5268
  ]
5217
5269
  });
5218
- invariant15(this._networkManager, "network manager not set", {
5270
+ invariant16(this._networkManager, "network manager not set", {
5219
5271
  F: __dxlog_file18,
5220
5272
  L: 233,
5221
5273
  S: this,
@@ -5319,7 +5371,7 @@ var ClientServicesHost = class {
5319
5371
  });
5320
5372
  }
5321
5373
  async reset() {
5322
- const traceId = PublicKey11.random().toHex();
5374
+ const traceId = PublicKey12.random().toHex();
5323
5375
  log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
5324
5376
  id: traceId
5325
5377
  }), {
@@ -5359,7 +5411,7 @@ var ClientServicesHost = class {
5359
5411
  const obj = new Properties(void 0);
5360
5412
  obj[defaultKey] = identity.identityKey.toHex();
5361
5413
  const automergeIndex = space.automergeSpaceState.rootUrl;
5362
- invariant15(automergeIndex, void 0, {
5414
+ invariant16(automergeIndex, void 0, {
5363
5415
  F: __dxlog_file18,
5364
5416
  L: 355,
5365
5417
  S: this,
@@ -5431,4 +5483,4 @@ export {
5431
5483
  createDefaultModelFactory,
5432
5484
  ClientServicesHost
5433
5485
  };
5434
- //# sourceMappingURL=chunk-Q4ZW7SKD.mjs.map
5486
+ //# sourceMappingURL=chunk-W4YHONPO.mjs.map