@dxos/client-services 0.1.56-main.1b4b163 → 0.1.56-main.1deed2f

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 (53) hide show
  1. package/dist/lib/browser/{chunk-TXSXNZYI.mjs → chunk-DNY3UFRX.mjs} +445 -388
  2. package/dist/lib/browser/chunk-DNY3UFRX.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +20 -23
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +31 -46
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +460 -399
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +460 -407
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
  16. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  17. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  18. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/platform.d.ts +3 -2
  21. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  22. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  23. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  24. package/dist/types/src/packlets/services/service-host.d.ts +3 -1
  25. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  26. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  27. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  28. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  29. package/dist/types/src/version.d.ts +1 -1
  30. package/package.json +34 -33
  31. package/src/packlets/devices/devices-service.test.ts +2 -1
  32. package/src/packlets/identity/identity-manager.test.ts +15 -3
  33. package/src/packlets/identity/identity-manager.ts +27 -6
  34. package/src/packlets/identity/identity-service.test.ts +17 -2
  35. package/src/packlets/identity/identity-service.ts +23 -14
  36. package/src/packlets/identity/identity.test.ts +7 -6
  37. package/src/packlets/identity/identity.ts +8 -3
  38. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  39. package/src/packlets/network/network-service.test.ts +2 -1
  40. package/src/packlets/services/client-rpc-server.ts +4 -4
  41. package/src/packlets/services/platform.ts +23 -21
  42. package/src/packlets/services/service-context.test.ts +59 -0
  43. package/src/packlets/services/service-context.ts +14 -6
  44. package/src/packlets/services/service-host.test.ts +6 -5
  45. package/src/packlets/services/service-host.ts +26 -13
  46. package/src/packlets/services/service-registry.test.ts +2 -1
  47. package/src/packlets/spaces/data-space.ts +17 -5
  48. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  49. package/src/packlets/testing/test-builder.ts +1 -1
  50. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  51. package/src/packlets/vault/worker-runtime.ts +2 -1
  52. package/src/version.ts +1 -1
  53. package/dist/lib/browser/chunk-TXSXNZYI.mjs.map +0 -7
@@ -1,11 +1,4 @@
1
1
  import "@dxos/node-std/globals";
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined")
6
- return require.apply(this, arguments);
7
- throw new Error('Dynamic require of "' + x + '" is not supported');
8
- });
9
2
 
10
3
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
11
4
  import { EventSubscriptions } from "@dxos/async";
@@ -19,7 +12,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
19
12
  const feedMap = new ComplexMap(PublicKey.hash);
20
13
  const update = () => {
21
14
  const { feeds } = feedStore;
22
- feeds.filter((feed) => !(feedKeys == null ? void 0 : feedKeys.length) || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
15
+ feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
23
16
  if (!feedMap.has(feed.key)) {
24
17
  feedMap.set(feed.key, feed);
25
18
  feed.on("close", update);
@@ -27,15 +20,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
27
20
  }
28
21
  });
29
22
  next({
30
- feeds: Array.from(feedMap.values()).map((feed) => {
31
- var _a, _b;
32
- return {
33
- feedKey: feed.key,
34
- length: feed.properties.length,
35
- bytes: feed.core.byteLength,
36
- downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
37
- };
38
- })
23
+ feeds: Array.from(feedMap.values()).map((feed) => ({
24
+ feedKey: feed.key,
25
+ length: feed.properties.length,
26
+ bytes: feed.core.byteLength,
27
+ downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
28
+ }))
39
29
  });
40
30
  };
41
31
  subscriptions.add(feedStore.feedOpened.on(update));
@@ -111,13 +101,13 @@ var subscribeToSignal = ({ signalManager }) => new Stream2(({ next }) => {
111
101
  recipient: message.recipient.asUint8Array(),
112
102
  payload: message.payload
113
103
  },
114
- receivedAt: new Date()
104
+ receivedAt: /* @__PURE__ */ new Date()
115
105
  });
116
106
  });
117
107
  signalManager.swarmEvent.on(ctx, (swarmEvent) => {
118
108
  next({
119
109
  swarmEvent: swarmEvent.swarmEvent,
120
- receivedAt: new Date()
110
+ receivedAt: /* @__PURE__ */ new Date()
121
111
  });
122
112
  });
123
113
  return () => {
@@ -128,13 +118,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, clos
128
118
  const update = () => {
129
119
  try {
130
120
  const topics = networkManager.topics;
131
- const labeledTopics = topics.map((topic) => {
132
- var _a, _b;
133
- return {
134
- topic,
135
- label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
136
- };
137
- });
121
+ const labeledTopics = topics.map((topic) => ({
122
+ topic,
123
+ label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
124
+ }));
138
125
  next({
139
126
  topics: labeledTopics
140
127
  });
@@ -146,17 +133,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, clos
146
133
  update();
147
134
  });
148
135
  var subscribeToSwarmInfo = ({ networkManager }) => new Stream2(({ next }) => {
149
- var _a;
150
136
  const update = () => {
151
- var _a2;
152
- const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
137
+ const info = networkManager.connectionLog?.swarms;
153
138
  if (info) {
154
139
  next({
155
140
  data: info
156
141
  });
157
142
  }
158
143
  };
159
- (_a = networkManager.connectionLog) == null ? void 0 : _a.update.on(update);
144
+ networkManager.connectionLog?.update.on(update);
160
145
  update();
161
146
  });
162
147
  var getNetworkPeers = ({ networkManager }, request) => {
@@ -165,7 +150,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
165
150
  }
166
151
  const map = networkManager.getSwarmMap(PublicKey2.from(request.topic));
167
152
  return {
168
- peers: map == null ? void 0 : map.peers.map((peer) => ({
153
+ peers: map?.peers.map((peer) => ({
169
154
  ...peer,
170
155
  connections: peer.connections.map((connection) => connection.asUint8Array())
171
156
  }))
@@ -181,14 +166,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
181
166
  const spaces = [
182
167
  ...context.spaceManager.spaces.values()
183
168
  ];
184
- const filteredSpaces = spaces.filter((space) => !(spaceKeys == null ? void 0 : spaceKeys.length) || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
169
+ const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
185
170
  next({
186
171
  spaces: filteredSpaces.map((space) => {
187
172
  const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
188
173
  return {
189
174
  key: space.key,
190
175
  isOpen: space.isOpen,
191
- timeframe: spaceMetadata == null ? void 0 : spaceMetadata.dataTimeframe,
176
+ timeframe: spaceMetadata?.dataTimeframe,
192
177
  genesisFeed: space.genesisFeedKey,
193
178
  controlFeed: space.controlFeedKey,
194
179
  dataFeed: space.dataFeedKey
@@ -202,7 +187,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
202
187
  await update();
203
188
  });
204
189
  return () => {
205
- unsubscribe == null ? void 0 : unsubscribe();
190
+ unsubscribe?.();
206
191
  clearTimeout(timeout);
207
192
  };
208
193
  });
@@ -261,16 +246,15 @@ var DevtoolsServiceImpl = class {
261
246
  };
262
247
  }
263
248
  async getStorageInfo() {
264
- var _a, _b, _c, _d, _e;
265
- const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
249
+ const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
266
250
  used: 0
267
251
  };
268
252
  const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
269
253
  return {
270
254
  type: this.params.context.storage.type,
271
255
  storageUsage: storageUsage.used,
272
- originUsage: (_d = navigatorInfo == null ? void 0 : navigatorInfo.usage) != null ? _d : 0,
273
- usageQuota: (_e = navigatorInfo == null ? void 0 : navigatorInfo.quota) != null ? _e : 0
256
+ originUsage: navigatorInfo?.usage ?? 0,
257
+ usageQuota: navigatorInfo?.quota ?? 0
274
258
  };
275
259
  }
276
260
  async getBlobs() {
@@ -456,7 +440,7 @@ var TrustedKeySetAuthVerifier = class {
456
440
  return await trigger.wait({
457
441
  timeout: this._params.authTimeout
458
442
  });
459
- } catch (e) {
443
+ } catch {
460
444
  return false;
461
445
  } finally {
462
446
  clear();
@@ -478,8 +462,19 @@ import { writeMessages } from "@dxos/feed-store";
478
462
  import { invariant } from "@dxos/invariant";
479
463
  import { log as log2 } from "@dxos/log";
480
464
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
465
+ import { trace } from "@dxos/tracing";
466
+ function _ts_decorate(decorators, target, key, desc) {
467
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
468
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
469
+ r = Reflect.decorate(decorators, target, key, desc);
470
+ else
471
+ for (var i = decorators.length - 1; i >= 0; i--)
472
+ if (d = decorators[i])
473
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
474
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
475
+ }
481
476
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
482
- var Identity = class {
477
+ var Identity = class Identity2 {
483
478
  constructor({ space, signer, identityKey, deviceKey }) {
484
479
  this.stateUpdate = new Event();
485
480
  this.space = space;
@@ -505,12 +500,12 @@ var Identity = class {
505
500
  get authorizedDeviceKeys() {
506
501
  return this._deviceStateMachine.authorizedDeviceKeys;
507
502
  }
508
- async open() {
503
+ async open(ctx) {
509
504
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
510
505
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
511
- await this.space.open();
506
+ await this.space.open(ctx);
512
507
  }
513
- async close() {
508
+ async close(ctx) {
514
509
  await this.authVerifier.close();
515
510
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
516
511
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
@@ -541,11 +536,10 @@ var Identity = class {
541
536
  return this._deviceStateMachine.deviceCredentialChain;
542
537
  }
543
538
  getAdmissionCredentials() {
544
- var _a, _b;
545
539
  return {
546
540
  deviceKey: this.deviceKey,
547
- controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : failUndefined(),
548
- dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : failUndefined()
541
+ controlFeedKey: this.space.controlFeedKey ?? failUndefined(),
542
+ dataFeedKey: this.space.dataFeedKey ?? failUndefined()
549
543
  };
550
544
  }
551
545
  /**
@@ -555,7 +549,7 @@ var Identity = class {
555
549
  getIdentityCredentialSigner() {
556
550
  invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
557
551
  F: __dxlog_file2,
558
- L: 134,
552
+ L: 139,
559
553
  S: this,
560
554
  A: [
561
555
  "this._deviceStateMachine.deviceCredentialChain",
@@ -579,7 +573,7 @@ var Identity = class {
579
573
  dataFeedKey
580
574
  }, {
581
575
  F: __dxlog_file2,
582
- L: 150,
576
+ L: 155,
583
577
  S: this,
584
578
  C: (f, a) => f(...a)
585
579
  });
@@ -620,18 +614,40 @@ var Identity = class {
620
614
  })));
621
615
  }
622
616
  };
617
+ _ts_decorate([
618
+ trace.span()
619
+ ], Identity.prototype, "open", null);
620
+ _ts_decorate([
621
+ trace.span()
622
+ ], Identity.prototype, "close", null);
623
+ Identity = _ts_decorate([
624
+ trace.resource()
625
+ ], Identity);
623
626
 
624
627
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
625
628
  import { Event as Event2 } from "@dxos/async";
629
+ import { Context as Context3 } from "@dxos/context";
626
630
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
627
631
  import { invariant as invariant2 } from "@dxos/invariant";
628
632
  import { PublicKey as PublicKey3 } from "@dxos/keys";
629
633
  import { log as log3 } from "@dxos/log";
630
- import { trace } from "@dxos/protocols";
634
+ import { trace as trace2 } from "@dxos/protocols";
631
635
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
636
+ import { Timeframe } from "@dxos/timeframe";
637
+ import { trace as Trace } from "@dxos/tracing";
632
638
  import { deferFunction } from "@dxos/util";
639
+ function _ts_decorate2(decorators, target, key, desc) {
640
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
641
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
642
+ r = Reflect.decorate(decorators, target, key, desc);
643
+ else
644
+ for (var i = decorators.length - 1; i >= 0; i--)
645
+ if (d = decorators[i])
646
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
647
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
648
+ }
633
649
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
634
- var IdentityManager = class {
650
+ var IdentityManager = class IdentityManager2 {
635
651
  // TODO(burdon): IdentityManagerParams.
636
652
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
637
653
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -644,14 +660,13 @@ var IdentityManager = class {
644
660
  get identity() {
645
661
  return this._identity;
646
662
  }
647
- async open() {
648
- var _a;
663
+ async open(ctx) {
649
664
  const traceId = PublicKey3.random().toHex();
650
- log3.trace("dxos.halo.identity-manager.open", trace.begin({
665
+ log3.trace("dxos.halo.identity-manager.open", trace2.begin({
651
666
  id: traceId
652
667
  }), {
653
668
  F: __dxlog_file3,
654
- L: 69,
669
+ L: 73,
655
670
  S: this,
656
671
  C: (f, a) => f(...a)
657
672
  });
@@ -661,43 +676,41 @@ var IdentityManager = class {
661
676
  identityRecord
662
677
  }, {
663
678
  F: __dxlog_file3,
664
- L: 73,
679
+ L: 77,
665
680
  S: this,
666
681
  C: (f, a) => f(...a)
667
682
  });
668
683
  if (identityRecord) {
669
684
  this._identity = await this._constructIdentity(identityRecord);
670
- await this._identity.open();
685
+ await this._identity.open(ctx);
671
686
  await this._identity.ready();
672
687
  log3.trace("dxos.halo.identity", {
673
688
  identityKey: identityRecord.identityKey,
674
- displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
689
+ displayName: this._identity.profileDocument?.displayName
675
690
  }, {
676
691
  F: __dxlog_file3,
677
- L: 78,
692
+ L: 82,
678
693
  S: this,
679
694
  C: (f, a) => f(...a)
680
695
  });
681
696
  this.stateUpdate.emit();
682
697
  }
683
- log3.trace("dxos.halo.identity-manager.open", trace.end({
698
+ log3.trace("dxos.halo.identity-manager.open", trace2.end({
684
699
  id: traceId
685
700
  }), {
686
701
  F: __dxlog_file3,
687
- L: 84,
702
+ L: 88,
688
703
  S: this,
689
704
  C: (f, a) => f(...a)
690
705
  });
691
706
  }
692
707
  async close() {
693
- var _a;
694
- await ((_a = this._identity) == null ? void 0 : _a.close());
708
+ await this._identity?.close(new Context3());
695
709
  }
696
710
  async createIdentity({ displayName } = {}) {
697
- var _a;
698
711
  invariant2(!this._identity, "Identity already exists.", {
699
712
  F: __dxlog_file3,
700
- L: 92,
713
+ L: 96,
701
714
  S: this,
702
715
  A: [
703
716
  "!this._identity",
@@ -706,7 +719,7 @@ var IdentityManager = class {
706
719
  });
707
720
  log3("creating identity...", void 0, {
708
721
  F: __dxlog_file3,
709
- L: 93,
722
+ L: 97,
710
723
  S: this,
711
724
  C: (f, a) => f(...a)
712
725
  });
@@ -722,12 +735,12 @@ var IdentityManager = class {
722
735
  }
723
736
  };
724
737
  const identity = await this._constructIdentity(identityRecord);
725
- await identity.open();
738
+ await identity.open(new Context3());
726
739
  {
727
740
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
728
741
  invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
729
742
  F: __dxlog_file3,
730
- L: 112,
743
+ L: 116,
731
744
  S: this,
732
745
  A: [
733
746
  "identityRecord.haloSpace.genesisFeedKey",
@@ -736,7 +749,7 @@ var IdentityManager = class {
736
749
  });
737
750
  invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
738
751
  F: __dxlog_file3,
739
- L: 113,
752
+ L: 117,
740
753
  S: this,
741
754
  A: [
742
755
  "identityRecord.haloSpace.dataFeedKey",
@@ -768,10 +781,10 @@ var IdentityManager = class {
768
781
  await this._identity.ready();
769
782
  log3.trace("dxos.halo.identity", {
770
783
  identityKey: identityRecord.identityKey,
771
- displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
784
+ displayName: this._identity.profileDocument?.displayName
772
785
  }, {
773
786
  F: __dxlog_file3,
774
- L: 148,
787
+ L: 152,
775
788
  S: this,
776
789
  C: (f, a) => f(...a)
777
790
  });
@@ -781,7 +794,7 @@ var IdentityManager = class {
781
794
  deviceKey: identity.deviceKey
782
795
  }, {
783
796
  F: __dxlog_file3,
784
- L: 154,
797
+ L: 158,
785
798
  S: this,
786
799
  C: (f, a) => f(...a)
787
800
  });
@@ -791,18 +804,17 @@ var IdentityManager = class {
791
804
  * Accept an existing identity. Expects it's device key to be authorized (now or later).
792
805
  */
793
806
  async acceptIdentity(params) {
794
- var _a;
795
807
  log3("accepting identity", {
796
808
  params
797
809
  }, {
798
810
  F: __dxlog_file3,
799
- L: 162,
811
+ L: 166,
800
812
  S: this,
801
813
  C: (f, a) => f(...a)
802
814
  });
803
815
  invariant2(!this._identity, "Identity already exists.", {
804
816
  F: __dxlog_file3,
805
- L: 163,
817
+ L: 167,
806
818
  S: this,
807
819
  A: [
808
820
  "!this._identity",
@@ -821,16 +833,16 @@ var IdentityManager = class {
821
833
  }
822
834
  };
823
835
  const identity = await this._constructIdentity(identityRecord);
824
- await identity.open();
836
+ await identity.open(new Context3());
825
837
  this._identity = identity;
826
838
  await this._metadataStore.setIdentityRecord(identityRecord);
827
839
  await this._identity.ready();
828
840
  log3.trace("dxos.halo.identity", {
829
841
  identityKey: identityRecord.identityKey,
830
- displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
842
+ displayName: this._identity.profileDocument?.displayName
831
843
  }, {
832
844
  F: __dxlog_file3,
833
- L: 182,
845
+ L: 186,
834
846
  S: this,
835
847
  C: (f, a) => f(...a)
836
848
  });
@@ -840,16 +852,48 @@ var IdentityManager = class {
840
852
  deviceKey: identity.deviceKey
841
853
  }, {
842
854
  F: __dxlog_file3,
843
- L: 188,
855
+ L: 192,
844
856
  S: this,
845
857
  C: (f, a) => f(...a)
846
858
  });
847
859
  return identity;
848
860
  }
861
+ /**
862
+ * Update the profile document of an existing identity.
863
+ */
864
+ async updateProfile(profile) {
865
+ invariant2(this._identity, "Identity not initialized.", {
866
+ F: __dxlog_file3,
867
+ L: 200,
868
+ S: this,
869
+ A: [
870
+ "this._identity",
871
+ "'Identity not initialized.'"
872
+ ]
873
+ });
874
+ const credential = await this._identity.getIdentityCredentialSigner().createCredential({
875
+ subject: this._identity.identityKey,
876
+ assertion: {
877
+ "@type": "dxos.halo.credentials.IdentityProfile",
878
+ profile
879
+ }
880
+ });
881
+ const receipt = await this._identity.controlPipeline.writer.write({
882
+ credential: {
883
+ credential
884
+ }
885
+ });
886
+ await this._identity.controlPipeline.state.waitUntilTimeframe(new Timeframe([
887
+ [
888
+ receipt.feedKey,
889
+ receipt.seq
890
+ ]
891
+ ]));
892
+ }
849
893
  async _constructIdentity(identityRecord) {
850
894
  invariant2(!this._identity, void 0, {
851
895
  F: __dxlog_file3,
852
- L: 193,
896
+ L: 214,
853
897
  S: this,
854
898
  A: [
855
899
  "!this._identity",
@@ -860,13 +904,13 @@ var IdentityManager = class {
860
904
  identityRecord
861
905
  }, {
862
906
  F: __dxlog_file3,
863
- L: 194,
907
+ L: 215,
864
908
  S: this,
865
909
  C: (f, a) => f(...a)
866
910
  });
867
911
  invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
868
912
  F: __dxlog_file3,
869
- L: 197,
913
+ L: 218,
870
914
  S: this,
871
915
  A: [
872
916
  "identityRecord.haloSpace.controlFeedKey",
@@ -878,7 +922,7 @@ var IdentityManager = class {
878
922
  });
879
923
  invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
880
924
  F: __dxlog_file3,
881
- L: 201,
925
+ L: 222,
882
926
  S: this,
883
927
  A: [
884
928
  "identityRecord.haloSpace.dataFeedKey",
@@ -910,7 +954,7 @@ var IdentityManager = class {
910
954
  identityKey: identityRecord.identityKey
911
955
  }, {
912
956
  F: __dxlog_file3,
913
- L: 225,
957
+ L: 246,
914
958
  S: this,
915
959
  C: (f, a) => f(...a)
916
960
  });
@@ -931,7 +975,7 @@ var IdentityManager = class {
931
975
  onAuthFailure: () => {
932
976
  log3.warn("auth failure", void 0, {
933
977
  F: __dxlog_file3,
934
- L: 244,
978
+ L: 265,
935
979
  S: this,
936
980
  C: (f, a) => f(...a)
937
981
  });
@@ -940,6 +984,12 @@ var IdentityManager = class {
940
984
  });
941
985
  }
942
986
  };
987
+ _ts_decorate2([
988
+ Trace.span()
989
+ ], IdentityManager.prototype, "open", null);
990
+ IdentityManager = _ts_decorate2([
991
+ Trace.resource()
992
+ ], IdentityManager);
943
993
 
944
994
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
945
995
  import { Stream as Stream7 } from "@dxos/codec-protobuf";
@@ -948,12 +998,13 @@ import { todo } from "@dxos/debug";
948
998
  import { invariant as invariant3 } from "@dxos/invariant";
949
999
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
950
1000
  var IdentityServiceImpl = class {
951
- // TODO(wittjosiah): Remove dependency on service context.
952
- constructor(_serviceContext) {
953
- this._serviceContext = _serviceContext;
1001
+ constructor(_createIdentity, _identityManager, _keyring) {
1002
+ this._createIdentity = _createIdentity;
1003
+ this._identityManager = _identityManager;
1004
+ this._keyring = _keyring;
954
1005
  }
955
1006
  async createIdentity(request) {
956
- await this._serviceContext.createIdentity(request);
1007
+ await this._createIdentity(request);
957
1008
  return this._getIdentity();
958
1009
  }
959
1010
  async recoverIdentity(request) {
@@ -965,34 +1016,47 @@ var IdentityServiceImpl = class {
965
1016
  identity: this._getIdentity()
966
1017
  });
967
1018
  emitNext();
968
- return this._serviceContext.identityManager.stateUpdate.on(emitNext);
1019
+ return this._identityManager.stateUpdate.on(emitNext);
969
1020
  });
970
1021
  }
971
1022
  _getIdentity() {
972
- if (!this._serviceContext.identityManager.identity) {
1023
+ if (!this._identityManager.identity) {
973
1024
  return void 0;
974
1025
  }
975
1026
  return {
976
- identityKey: this._serviceContext.identityManager.identity.identityKey,
977
- spaceKey: this._serviceContext.identityManager.identity.space.key,
978
- profile: this._serviceContext.identityManager.identity.profileDocument
1027
+ identityKey: this._identityManager.identity.identityKey,
1028
+ spaceKey: this._identityManager.identity.space.key,
1029
+ profile: this._identityManager.identity.profileDocument
979
1030
  };
980
1031
  }
1032
+ async updateProfile(profile) {
1033
+ invariant3(this._identityManager.identity, "Identity not initialized.", {
1034
+ F: __dxlog_file4,
1035
+ L: 59,
1036
+ S: this,
1037
+ A: [
1038
+ "this._identityManager.identity",
1039
+ "'Identity not initialized.'"
1040
+ ]
1041
+ });
1042
+ await this._identityManager.updateProfile(profile);
1043
+ return this._getIdentity();
1044
+ }
981
1045
  async signPresentation({ presentation, nonce }) {
982
- invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.", {
1046
+ invariant3(this._identityManager.identity, "Identity not initialized.", {
983
1047
  F: __dxlog_file4,
984
- L: 56,
1048
+ L: 65,
985
1049
  S: this,
986
1050
  A: [
987
- "this._serviceContext.identityManager.identity",
1051
+ "this._identityManager.identity",
988
1052
  "'Identity not initialized.'"
989
1053
  ]
990
1054
  });
991
1055
  return await signPresentation({
992
1056
  presentation,
993
- signer: this._serviceContext.keyring,
994
- signerKey: this._serviceContext.identityManager.identity.deviceKey,
995
- chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
1057
+ signer: this._keyring,
1058
+ signerKey: this._identityManager.identity.deviceKey,
1059
+ chain: this._identityManager.identity.deviceCredentialChain,
996
1060
  nonce
997
1061
  });
998
1062
  }
@@ -1091,25 +1155,25 @@ var DeviceInvitationProtocol = class {
1091
1155
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1092
1156
  import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
1093
1157
  import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
1094
- import { Context as Context4 } from "@dxos/context";
1158
+ import { Context as Context5 } from "@dxos/context";
1095
1159
  import { generatePasscode } from "@dxos/credentials";
1096
1160
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
1097
1161
  import { invariant as invariant6 } from "@dxos/invariant";
1098
1162
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1099
1163
  import { log as log5 } from "@dxos/log";
1100
1164
  import { createTeleportProtocolFactory, StarTopology } from "@dxos/network-manager";
1101
- import { trace as trace3 } from "@dxos/protocols";
1165
+ import { trace as trace4 } from "@dxos/protocols";
1102
1166
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1103
1167
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1104
1168
 
1105
1169
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1106
1170
  import { Trigger as Trigger2 } from "@dxos/async";
1107
- import { cancelWithContext, Context as Context3 } from "@dxos/context";
1171
+ import { cancelWithContext, Context as Context4 } from "@dxos/context";
1108
1172
  import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
1109
1173
  import { invariant as invariant5 } from "@dxos/invariant";
1110
1174
  import { PublicKey as PublicKey4 } from "@dxos/keys";
1111
1175
  import { log as log4 } from "@dxos/log";
1112
- import { schema as schema2, trace as trace2 } from "@dxos/protocols";
1176
+ import { schema as schema2, trace as trace3 } from "@dxos/protocols";
1113
1177
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
1114
1178
  import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1115
1179
  import { RpcExtension } from "@dxos/teleport";
@@ -1127,7 +1191,7 @@ var InvitationHostExtension = class extends RpcExtension {
1127
1191
  }
1128
1192
  });
1129
1193
  this._callbacks = _callbacks;
1130
- this._ctx = new Context3();
1194
+ this._ctx = new Context4();
1131
1195
  this._remoteOptionsTrigger = new Trigger2();
1132
1196
  this.invitation = void 0;
1133
1197
  this.guestProfile = void 0;
@@ -1156,7 +1220,7 @@ var InvitationHostExtension = class extends RpcExtension {
1156
1220
  introduce: async (request) => {
1157
1221
  const { profile, invitationId } = request;
1158
1222
  const traceId = PublicKey4.random().toHex();
1159
- log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
1223
+ log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
1160
1224
  id: traceId
1161
1225
  }), {
1162
1226
  F: __dxlog_file6,
@@ -1193,7 +1257,7 @@ var InvitationHostExtension = class extends RpcExtension {
1193
1257
  ...this.invitation,
1194
1258
  state: Invitation2.State.READY_FOR_AUTHENTICATION
1195
1259
  });
1196
- log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
1260
+ log4.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
1197
1261
  id: traceId
1198
1262
  }), {
1199
1263
  F: __dxlog_file6,
@@ -1208,7 +1272,7 @@ var InvitationHostExtension = class extends RpcExtension {
1208
1272
  },
1209
1273
  authenticate: async ({ authCode: code }) => {
1210
1274
  const traceId = PublicKey4.random().toHex();
1211
- log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
1275
+ log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
1212
1276
  id: traceId
1213
1277
  }), {
1214
1278
  F: __dxlog_file6,
@@ -1271,7 +1335,7 @@ var InvitationHostExtension = class extends RpcExtension {
1271
1335
  break;
1272
1336
  }
1273
1337
  }
1274
- log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.end({
1338
+ log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
1275
1339
  id: traceId,
1276
1340
  data: {
1277
1341
  status
@@ -1288,7 +1352,7 @@ var InvitationHostExtension = class extends RpcExtension {
1288
1352
  },
1289
1353
  admit: async (request) => {
1290
1354
  const traceId = PublicKey4.random().toHex();
1291
- log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
1355
+ log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
1292
1356
  id: traceId
1293
1357
  }), {
1294
1358
  F: __dxlog_file6,
@@ -1310,7 +1374,7 @@ var InvitationHostExtension = class extends RpcExtension {
1310
1374
  throw new Error("Not authenticated");
1311
1375
  }
1312
1376
  const response = await this._callbacks.admit(request);
1313
- log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
1377
+ log4.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
1314
1378
  id: traceId
1315
1379
  }), {
1316
1380
  F: __dxlog_file6,
@@ -1328,7 +1392,6 @@ var InvitationHostExtension = class extends RpcExtension {
1328
1392
  };
1329
1393
  }
1330
1394
  async onOpen(context) {
1331
- var _a;
1332
1395
  await super.onOpen(context);
1333
1396
  try {
1334
1397
  await this.rpc.InvitationHostService.options({
@@ -1337,7 +1400,7 @@ var InvitationHostExtension = class extends RpcExtension {
1337
1400
  await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
1338
1401
  timeout: OPTIONS_TIMEOUT
1339
1402
  }));
1340
- if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== Options.Role.GUEST) {
1403
+ if (this._remoteOptions?.role !== Options.Role.GUEST) {
1341
1404
  throw new InvalidInvitationExtensionRoleError(void 0, {
1342
1405
  expected: Options.Role.GUEST,
1343
1406
  remoteOptions: this._remoteOptions
@@ -1363,7 +1426,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1363
1426
  }
1364
1427
  });
1365
1428
  this._callbacks = _callbacks;
1366
- this._ctx = new Context3();
1429
+ this._ctx = new Context4();
1367
1430
  this._remoteOptionsTrigger = new Trigger2();
1368
1431
  }
1369
1432
  async getHandlers() {
@@ -1395,7 +1458,6 @@ var InvitationGuestExtension = class extends RpcExtension {
1395
1458
  };
1396
1459
  }
1397
1460
  async onOpen(context) {
1398
- var _a;
1399
1461
  await super.onOpen(context);
1400
1462
  try {
1401
1463
  log4("begin options", void 0, {
@@ -1416,7 +1478,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1416
1478
  S: this,
1417
1479
  C: (f, a) => f(...a)
1418
1480
  });
1419
- if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== Options.Role.HOST) {
1481
+ if (this._remoteOptions?.role !== Options.Role.HOST) {
1420
1482
  throw new InvalidInvitationExtensionRoleError(void 0, {
1421
1483
  expected: Options.Role.HOST,
1422
1484
  remoteOptions: this._remoteOptions
@@ -1455,9 +1517,8 @@ var InvitationsHandler = class {
1455
1517
  this._networkManager = _networkManager;
1456
1518
  }
1457
1519
  createInvitation(protocol, options) {
1458
- var _a;
1459
- const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options != null ? options : {};
1460
- const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
1520
+ const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options ?? {};
1521
+ const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
1461
1522
  invariant6(protocol, void 0, {
1462
1523
  F: __dxlog_file7,
1463
1524
  L: 76,
@@ -1478,7 +1539,7 @@ var InvitationsHandler = class {
1478
1539
  ...protocol.getInvitationContext()
1479
1540
  };
1480
1541
  const stream = new PushStream();
1481
- const ctx = new Context4({
1542
+ const ctx = new Context5({
1482
1543
  onError: (err) => {
1483
1544
  void ctx.dispose();
1484
1545
  stream.error(err);
@@ -1510,9 +1571,8 @@ var InvitationsHandler = class {
1510
1571
  return invitation;
1511
1572
  },
1512
1573
  admit: async (admissionRequest) => {
1513
- var _a2, _b, _c;
1514
1574
  try {
1515
- const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1575
+ const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1516
1576
  invariant6(deviceKey, void 0, {
1517
1577
  F: __dxlog_file7,
1518
1578
  L: 119,
@@ -1534,7 +1594,7 @@ var InvitationsHandler = class {
1534
1594
  scheduleTask2(ctx, async () => {
1535
1595
  const traceId = PublicKey5.random().toHex();
1536
1596
  try {
1537
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
1597
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
1538
1598
  id: traceId
1539
1599
  }), {
1540
1600
  F: __dxlog_file7,
@@ -1570,7 +1630,7 @@ var InvitationsHandler = class {
1570
1630
  ...invitation,
1571
1631
  state: Invitation3.State.SUCCESS
1572
1632
  });
1573
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
1633
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
1574
1634
  id: traceId
1575
1635
  }), {
1576
1636
  F: __dxlog_file7,
@@ -1601,7 +1661,7 @@ var InvitationsHandler = class {
1601
1661
  });
1602
1662
  stream.error(err);
1603
1663
  }
1604
- log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.error({
1664
+ log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
1605
1665
  id: traceId,
1606
1666
  error: err
1607
1667
  }), {
@@ -1709,7 +1769,7 @@ var InvitationsHandler = class {
1709
1769
  ...newData
1710
1770
  });
1711
1771
  };
1712
- const ctx = new Context4({
1772
+ const ctx = new Context5({
1713
1773
  onError: (err) => {
1714
1774
  if (err instanceof TimeoutError) {
1715
1775
  log5("timeout", {
@@ -1766,7 +1826,7 @@ var InvitationsHandler = class {
1766
1826
  scheduleTask2(ctx, async () => {
1767
1827
  const traceId = PublicKey5.random().toHex();
1768
1828
  try {
1769
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
1829
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
1770
1830
  id: traceId
1771
1831
  }), {
1772
1832
  F: __dxlog_file7,
@@ -1885,7 +1945,7 @@ var InvitationsHandler = class {
1885
1945
  ...result,
1886
1946
  state: Invitation3.State.SUCCESS
1887
1947
  });
1888
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
1948
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
1889
1949
  id: traceId
1890
1950
  }), {
1891
1951
  F: __dxlog_file7,
@@ -1915,7 +1975,7 @@ var InvitationsHandler = class {
1915
1975
  });
1916
1976
  stream.error(err);
1917
1977
  }
1918
- log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.error({
1978
+ log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
1919
1979
  id: traceId,
1920
1980
  error: err
1921
1981
  }), {
@@ -2211,7 +2271,6 @@ var SpaceInvitationProtocol = class {
2211
2271
  };
2212
2272
  }
2213
2273
  async admit(request, guestProfile) {
2214
- var _a;
2215
2274
  invariant8(this._spaceKey, void 0, {
2216
2275
  F: __dxlog_file9,
2217
2276
  L: 42,
@@ -2275,7 +2334,7 @@ var SpaceInvitationProtocol = class {
2275
2334
  space: {
2276
2335
  credential: spaceMemberCredential,
2277
2336
  controlTimeframe: space.inner.controlPipeline.state.timeframe,
2278
- dataTimeframe: (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.timeframe
2337
+ dataTimeframe: space.dataPipeline.pipelineState?.timeframe
2279
2338
  }
2280
2339
  };
2281
2340
  }
@@ -2379,9 +2438,8 @@ var ClientRpcServer = class {
2379
2438
  await this._rpcPeer.close();
2380
2439
  }
2381
2440
  _getServiceHandler(serviceName) {
2382
- var _a;
2383
2441
  if (!this._handlerCache.has(serviceName)) {
2384
- const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : raise(new Error(`Service not available: ${serviceName}`));
2442
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
2385
2443
  const service = this._serviceRegistry.services[key];
2386
2444
  if (!service) {
2387
2445
  throw new Error(`Service not available: ${serviceName}`);
@@ -2402,31 +2460,33 @@ import { STORAGE_VERSION } from "@dxos/protocols";
2402
2460
  import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2403
2461
 
2404
2462
  // packages/sdk/client-services/src/version.ts
2405
- var DXOS_VERSION = "0.1.56-main.1b4b163";
2463
+ var DXOS_VERSION = "0.1.56-main.1deed2f";
2406
2464
 
2407
2465
  // packages/sdk/client-services/src/packlets/services/platform.ts
2408
2466
  var getPlatform = () => {
2409
- if (typeof window !== "undefined") {
2410
- const { userAgent } = window.navigator;
2411
- return {
2412
- type: "browser",
2413
- platform: userAgent
2414
- };
2415
- }
2416
- try {
2417
- const { machine, platform, release } = __require("@dxos/node-std/os");
2467
+ if (process.browser) {
2468
+ if (typeof window !== "undefined") {
2469
+ const { userAgent } = window.navigator;
2470
+ return {
2471
+ type: "browser",
2472
+ userAgent,
2473
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2474
+ };
2475
+ } else {
2476
+ return {
2477
+ type: "shared-worker",
2478
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2479
+ };
2480
+ }
2481
+ } else {
2482
+ const { platform, version, arch } = process;
2418
2483
  return {
2419
2484
  type: "node",
2420
- platform: `${platform()} ${release()} ${machine()}`,
2485
+ platform: `${platform} ${version} ${arch}`,
2421
2486
  runtime: process.version,
2422
2487
  uptime: Math.floor(process.uptime()),
2423
2488
  memory: process.memoryUsage()
2424
2489
  };
2425
- } catch (err) {
2426
- return {
2427
- type: "node",
2428
- platform: ""
2429
- };
2430
2490
  }
2431
2491
  };
2432
2492
 
@@ -2434,9 +2494,8 @@ var getPlatform = () => {
2434
2494
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2435
2495
  var DEFAULT_TIMEOUT = 1e3;
2436
2496
  var createDiagnostics = async (clientServices, serviceContext, config) => {
2437
- var _a, _b, _c;
2438
2497
  const diagnostics = {
2439
- created: new Date().toISOString(),
2498
+ created: (/* @__PURE__ */ new Date()).toISOString(),
2440
2499
  platform: getPlatform(),
2441
2500
  client: {
2442
2501
  version: DXOS_VERSION,
@@ -2466,16 +2525,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2466
2525
  spaceKey: identity.space.key,
2467
2526
  profile: identity.profileDocument
2468
2527
  };
2469
- const { devices } = (_a = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
2528
+ const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
2470
2529
  timeout: DEFAULT_TIMEOUT
2471
- }).catch(() => void 0)) != null ? _a : {};
2530
+ }).catch(() => void 0) ?? {};
2472
2531
  diagnostics.devices = devices;
2473
2532
  if (serviceContext.dataSpaceManager) {
2474
- diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
2533
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2475
2534
  }
2476
- const { feeds = [] } = (_c = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2535
+ const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2477
2536
  timeout: DEFAULT_TIMEOUT
2478
- }).catch(() => void 0)) != null ? _c : {};
2537
+ }).catch(() => void 0) ?? {};
2479
2538
  diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2480
2539
  feedKey,
2481
2540
  bytes,
@@ -2488,12 +2547,9 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2488
2547
  var getProperties = (space) => {
2489
2548
  let properties = {};
2490
2549
  try {
2491
- const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
2492
- var _a, _b;
2493
- return ((_a = item.modelMeta) == null ? void 0 : _a.type) === DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
2494
- });
2495
- const state = propertiesItem == null ? void 0 : propertiesItem.state;
2496
- properties = state == null ? void 0 : state.data;
2550
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
2551
+ const state = propertiesItem?.state;
2552
+ properties = state?.data;
2497
2553
  } catch (err) {
2498
2554
  log8.warn(err.message, void 0, {
2499
2555
  F: __dxlog_file10,
@@ -2505,7 +2561,6 @@ var getProperties = (space) => {
2505
2561
  return properties;
2506
2562
  };
2507
2563
  var getSpaceStats = async (space) => {
2508
- var _a, _b, _c, _d, _e, _f;
2509
2564
  const stats = {
2510
2565
  key: space.key,
2511
2566
  metrics: space.metrics,
@@ -2513,18 +2568,15 @@ var getSpaceStats = async (space) => {
2513
2568
  ...credential.subject.assertion,
2514
2569
  id: credential.id
2515
2570
  })),
2516
- members: Array.from(space.inner.spaceState.members.values()).map((member) => {
2517
- var _a2;
2518
- return {
2519
- identity: {
2520
- identityKey: member.key,
2521
- profile: {
2522
- displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
2523
- }
2524
- },
2525
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
2526
- };
2527
- }),
2571
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2572
+ identity: {
2573
+ identityKey: member.key,
2574
+ profile: {
2575
+ displayName: member.assertion.profile?.displayName
2576
+ }
2577
+ },
2578
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
2579
+ })),
2528
2580
  pipeline: {
2529
2581
  // TODO(burdon): Pick properties from credentials if needed.
2530
2582
  // currentEpoch: space.dataPipeline.currentEpoch,
@@ -2534,11 +2586,11 @@ var getSpaceStats = async (space) => {
2534
2586
  targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2535
2587
  totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
2536
2588
  // TODO(burdon): Empty?
2537
- dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
2538
- startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
2539
- currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
2540
- targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
2541
- totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
2589
+ dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
2590
+ startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
2591
+ currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
2592
+ targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
2593
+ totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
2542
2594
  }
2543
2595
  };
2544
2596
  if (space.dataPipeline.itemManager) {
@@ -2559,7 +2611,7 @@ var getSpaceStats = async (space) => {
2559
2611
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2560
2612
  import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
2561
2613
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
2562
- import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
2614
+ import { cancelWithContext as cancelWithContext2, Context as Context7 } from "@dxos/context";
2563
2615
  import { timed } from "@dxos/debug";
2564
2616
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2565
2617
  import { CancelledError, SystemError } from "@dxos/errors";
@@ -2567,12 +2619,12 @@ import { PublicKey as PublicKey7 } from "@dxos/keys";
2567
2619
  import { log as log10 } from "@dxos/log";
2568
2620
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
2569
2621
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2570
- import { Timeframe } from "@dxos/timeframe";
2622
+ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2571
2623
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2572
2624
 
2573
2625
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2574
2626
  import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
2575
- import { Context as Context5, rejectOnDispose } from "@dxos/context";
2627
+ import { Context as Context6, rejectOnDispose } from "@dxos/context";
2576
2628
  import { invariant as invariant10 } from "@dxos/invariant";
2577
2629
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2578
2630
  import { log as log9 } from "@dxos/log";
@@ -2586,7 +2638,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2586
2638
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2587
2639
  var NotarizationPlugin = class {
2588
2640
  constructor() {
2589
- this._ctx = new Context5();
2641
+ this._ctx = new Context6();
2590
2642
  this._extensionOpened = new Event4();
2591
2643
  this._extensions = /* @__PURE__ */ new Set();
2592
2644
  this._processedCredentials = new ComplexSet(PublicKey6.hash);
@@ -2636,7 +2688,7 @@ var NotarizationPlugin = class {
2636
2688
  errors.throw(err);
2637
2689
  }
2638
2690
  });
2639
- opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2691
+ opCtx?.onDispose(() => ctx.dispose());
2640
2692
  if (timeout !== 0) {
2641
2693
  scheduleTask3(ctx, () => {
2642
2694
  log9.warn("Notarization timeout", {
@@ -2729,11 +2781,10 @@ var NotarizationPlugin = class {
2729
2781
  * Called with credentials arriving from the control pipeline.
2730
2782
  */
2731
2783
  async processCredential(credential) {
2732
- var _a;
2733
2784
  if (!credential.id) {
2734
2785
  return;
2735
2786
  }
2736
- (_a = this._processCredentialsTriggers.get(credential.id)) == null ? void 0 : _a.wake();
2787
+ this._processCredentialsTriggers.get(credential.id)?.wake();
2737
2788
  this._processedCredentials.add(credential.id);
2738
2789
  this._processCredentialsTriggers.delete(credential.id);
2739
2790
  }
@@ -2759,11 +2810,10 @@ var NotarizationPlugin = class {
2759
2810
  * Requests from other peers to notarize credentials.
2760
2811
  */
2761
2812
  async _onNotarize(request) {
2762
- var _a;
2763
2813
  if (!this._writer) {
2764
2814
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2765
2815
  }
2766
- for (const credential of (_a = request.credentials) != null ? _a : []) {
2816
+ for (const credential of request.credentials ?? []) {
2767
2817
  invariant10(credential.id, "Credential must have an id", {
2768
2818
  F: __dxlog_file11,
2769
2819
  L: 200,
@@ -2841,7 +2891,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
2841
2891
  };
2842
2892
 
2843
2893
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2844
- function _ts_decorate(decorators, target, key, desc) {
2894
+ function _ts_decorate3(decorators, target, key, desc) {
2845
2895
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2846
2896
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2847
2897
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2852,9 +2902,10 @@ function _ts_decorate(decorators, target, key, desc) {
2852
2902
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2853
2903
  }
2854
2904
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2905
+ var ENABLE_FEED_PURGE = false;
2855
2906
  var DataSpace = class DataSpace2 {
2856
2907
  constructor(params) {
2857
- this._ctx = new Context6();
2908
+ this._ctx = new Context7();
2858
2909
  this._notarizationPlugin = new NotarizationPlugin();
2859
2910
  this._state = SpaceState.CLOSED;
2860
2911
  /**
@@ -2863,7 +2914,6 @@ var DataSpace = class DataSpace2 {
2863
2914
  this.error = void 0;
2864
2915
  this.stateUpdate = new Event5();
2865
2916
  this.metrics = {};
2866
- var _a;
2867
2917
  this._inner = params.inner;
2868
2918
  this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
2869
2919
  this._gossip = params.gossip;
@@ -2872,7 +2922,7 @@ var DataSpace = class DataSpace2 {
2872
2922
  this._feedStore = params.feedStore;
2873
2923
  this._metadataStore = params.metadataStore;
2874
2924
  this._signingContext = params.signingContext;
2875
- this._callbacks = (_a = params.callbacks) != null ? _a : {};
2925
+ this._callbacks = params.callbacks ?? {};
2876
2926
  this.authVerifier = new TrustedKeySetAuthVerifier({
2877
2927
  trustedKeysProvider: () => new ComplexSet2(PublicKey7.hash, Array.from(this._inner.spaceState.members.keys())),
2878
2928
  update: this._inner.stateUpdate,
@@ -2912,21 +2962,20 @@ var DataSpace = class DataSpace2 {
2912
2962
  async _open() {
2913
2963
  await this._notarizationPlugin.open();
2914
2964
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2915
- await this._inner.open();
2965
+ await this._inner.open(new Context7());
2916
2966
  this._state = SpaceState.CONTROL_ONLY;
2917
2967
  this.stateUpdate.emit();
2918
2968
  this.metrics = {};
2919
- this.metrics.open = new Date();
2969
+ this.metrics.open = /* @__PURE__ */ new Date();
2920
2970
  }
2921
2971
  async close() {
2922
2972
  await this._close();
2923
2973
  }
2924
2974
  async _close() {
2925
- var _a, _b;
2926
- await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2975
+ await this._callbacks.beforeClose?.();
2927
2976
  this._state = SpaceState.CLOSED;
2928
2977
  await this._ctx.dispose();
2929
- this._ctx = new Context6();
2978
+ this._ctx = new Context7();
2930
2979
  await this.authVerifier.close();
2931
2980
  await this._inner.close();
2932
2981
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -2945,13 +2994,13 @@ var DataSpace = class DataSpace2 {
2945
2994
  initializeDataPipelineAsync() {
2946
2995
  scheduleTask4(this._ctx, async () => {
2947
2996
  try {
2948
- this.metrics.pipelineInitBegin = new Date();
2997
+ this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
2949
2998
  await this.initializeDataPipeline();
2950
2999
  } catch (err) {
2951
3000
  if (err instanceof CancelledError) {
2952
3001
  log10("data pipeline initialization cancelled", err, {
2953
3002
  F: __dxlog_file12,
2954
- L: 193,
3003
+ L: 199,
2955
3004
  S: this,
2956
3005
  C: (f, a) => f(...a)
2957
3006
  });
@@ -2959,7 +3008,7 @@ var DataSpace = class DataSpace2 {
2959
3008
  }
2960
3009
  log10.error("Error initializing data pipeline", err, {
2961
3010
  F: __dxlog_file12,
2962
- L: 197,
3011
+ L: 203,
2963
3012
  S: this,
2964
3013
  C: (f, a) => f(...a)
2965
3014
  });
@@ -2967,12 +3016,11 @@ var DataSpace = class DataSpace2 {
2967
3016
  this.error = err;
2968
3017
  this.stateUpdate.emit();
2969
3018
  } finally {
2970
- this.metrics.ready = new Date();
3019
+ this.metrics.ready = /* @__PURE__ */ new Date();
2971
3020
  }
2972
3021
  });
2973
3022
  }
2974
3023
  async initializeDataPipeline() {
2975
- var _a, _b, _c, _d;
2976
3024
  if (this._state !== SpaceState.CONTROL_ONLY) {
2977
3025
  throw new SystemError("Invalid operation");
2978
3026
  }
@@ -2981,11 +3029,11 @@ var DataSpace = class DataSpace2 {
2981
3029
  ctx: this._ctx,
2982
3030
  breakOnStall: false
2983
3031
  });
2984
- this.metrics.controlPipelineReady = new Date();
3032
+ this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
2985
3033
  await this._createWritableFeeds();
2986
3034
  log10("writable feeds created", void 0, {
2987
3035
  F: __dxlog_file12,
2988
- L: 221,
3036
+ L: 227,
2989
3037
  S: this,
2990
3038
  C: (f, a) => f(...a)
2991
3039
  });
@@ -2998,11 +3046,11 @@ var DataSpace = class DataSpace2 {
2998
3046
  }), this._inner.controlPipeline.writer));
2999
3047
  }
3000
3048
  await this._inner.initializeDataPipeline();
3001
- this.metrics.dataPipelineOpen = new Date();
3049
+ this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
3002
3050
  await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3003
3051
  log10("waiting for data pipeline to reach target timeframe", void 0, {
3004
3052
  F: __dxlog_file12,
3005
- L: 242,
3053
+ L: 248,
3006
3054
  S: this,
3007
3055
  C: (f, a) => f(...a)
3008
3056
  });
@@ -3010,17 +3058,17 @@ var DataSpace = class DataSpace2 {
3010
3058
  ctx: this._ctx,
3011
3059
  breakOnStall: false
3012
3060
  });
3013
- this.metrics.dataPipelineReady = new Date();
3061
+ this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3014
3062
  log10("data pipeline ready", void 0, {
3015
3063
  F: __dxlog_file12,
3016
- L: 251,
3064
+ L: 257,
3017
3065
  S: this,
3018
3066
  C: (f, a) => f(...a)
3019
3067
  });
3020
- await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
3068
+ await this._callbacks.beforeReady?.();
3021
3069
  this._state = SpaceState.READY;
3022
3070
  this.stateUpdate.emit();
3023
- await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
3071
+ await this._callbacks.afterReady?.();
3024
3072
  }
3025
3073
  async _createWritableFeeds() {
3026
3074
  const credentials = [];
@@ -3067,7 +3115,6 @@ var DataSpace = class DataSpace2 {
3067
3115
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
3068
3116
  }
3069
3117
  async createEpoch() {
3070
- var _a, _b;
3071
3118
  const epoch = await this.dataPipeline.createEpoch();
3072
3119
  const receipt = await this.inner.controlPipeline.writer.write({
3073
3120
  credential: {
@@ -3080,16 +3127,19 @@ var DataSpace = class DataSpace2 {
3080
3127
  })
3081
3128
  }
3082
3129
  });
3083
- await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe([
3130
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe2([
3084
3131
  [
3085
3132
  receipt.feedKey,
3086
3133
  receipt.seq
3087
3134
  ]
3088
3135
  ]));
3089
- for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
3090
- const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3091
- if (indexBeforeEpoch) {
3092
- await feed.clear(0, indexBeforeEpoch + 1);
3136
+ if (ENABLE_FEED_PURGE) {
3137
+ for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
3138
+ const indexBeforeEpoch = epoch.timeframe.get(feed.key);
3139
+ if (indexBeforeEpoch === void 0) {
3140
+ continue;
3141
+ }
3142
+ await feed.safeClear(0, indexBeforeEpoch + 1);
3093
3143
  }
3094
3144
  }
3095
3145
  }
@@ -3111,33 +3161,33 @@ var DataSpace = class DataSpace2 {
3111
3161
  this.stateUpdate.emit();
3112
3162
  }
3113
3163
  };
3114
- _ts_decorate([
3164
+ _ts_decorate3([
3115
3165
  synchronized
3116
3166
  ], DataSpace.prototype, "open", null);
3117
- _ts_decorate([
3167
+ _ts_decorate3([
3118
3168
  synchronized
3119
3169
  ], DataSpace.prototype, "close", null);
3120
- _ts_decorate([
3170
+ _ts_decorate3([
3121
3171
  timed(1e4)
3122
3172
  ], DataSpace.prototype, "_createWritableFeeds", null);
3123
- _ts_decorate([
3173
+ _ts_decorate3([
3124
3174
  synchronized
3125
3175
  ], DataSpace.prototype, "activate", null);
3126
- _ts_decorate([
3176
+ _ts_decorate3([
3127
3177
  synchronized
3128
3178
  ], DataSpace.prototype, "deactivate", null);
3129
- DataSpace = _ts_decorate([
3179
+ DataSpace = _ts_decorate3([
3130
3180
  trackLeaks("open", "close")
3131
3181
  ], DataSpace);
3132
3182
 
3133
3183
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3134
3184
  import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
3135
- import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
3185
+ import { cancelWithContext as cancelWithContext3, Context as Context8 } from "@dxos/context";
3136
3186
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3137
3187
  import { invariant as invariant11 } from "@dxos/invariant";
3138
3188
  import { PublicKey as PublicKey8 } from "@dxos/keys";
3139
3189
  import { log as log11 } from "@dxos/log";
3140
- import { trace as trace4 } from "@dxos/protocols";
3190
+ import { trace as trace5 } from "@dxos/protocols";
3141
3191
  import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
3142
3192
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
3143
3193
  import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxos/util";
@@ -3146,9 +3196,8 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
3146
3196
  import { createCredential } from "@dxos/credentials";
3147
3197
  import { failUndefined as failUndefined2 } from "@dxos/debug";
3148
3198
  import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
3149
- import { Timeframe as Timeframe2 } from "@dxos/timeframe";
3199
+ import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3150
3200
  var spaceGenesis = async (keyring, signingContext, space) => {
3151
- var _a, _b, _c, _d;
3152
3201
  const credentials = [
3153
3202
  await createCredential({
3154
3203
  signer: keyring,
@@ -3168,11 +3217,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3168
3217
  spaceKey: space.key,
3169
3218
  role: SpaceMember2.Role.ADMIN,
3170
3219
  profile: signingContext.profile,
3171
- genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : failUndefined2()
3220
+ genesisFeedKey: space.controlFeedKey ?? failUndefined2()
3172
3221
  }
3173
3222
  }),
3174
3223
  await signingContext.credentialSigner.createCredential({
3175
- subject: (_b = space.controlFeedKey) != null ? _b : failUndefined2(),
3224
+ subject: space.controlFeedKey ?? failUndefined2(),
3176
3225
  assertion: {
3177
3226
  "@type": "dxos.halo.credentials.AdmittedFeed",
3178
3227
  spaceKey: space.key,
@@ -3182,7 +3231,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3182
3231
  }
3183
3232
  }),
3184
3233
  await signingContext.credentialSigner.createCredential({
3185
- subject: (_c = space.dataFeedKey) != null ? _c : failUndefined2(),
3234
+ subject: space.dataFeedKey ?? failUndefined2(),
3186
3235
  assertion: {
3187
3236
  "@type": "dxos.halo.credentials.AdmittedFeed",
3188
3237
  spaceKey: space.key,
@@ -3192,12 +3241,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3192
3241
  }
3193
3242
  }),
3194
3243
  await signingContext.credentialSigner.createCredential({
3195
- subject: (_d = space.key) != null ? _d : failUndefined2(),
3244
+ subject: space.key ?? failUndefined2(),
3196
3245
  assertion: {
3197
3246
  "@type": "dxos.halo.credentials.Epoch",
3198
3247
  number: 0,
3199
3248
  previousId: void 0,
3200
- timeframe: new Timeframe2(),
3249
+ timeframe: new Timeframe3(),
3201
3250
  snapshotCid: void 0
3202
3251
  }
3203
3252
  })
@@ -3213,7 +3262,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3213
3262
  };
3214
3263
 
3215
3264
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3216
- function _ts_decorate2(decorators, target, key, desc) {
3265
+ function _ts_decorate4(decorators, target, key, desc) {
3217
3266
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3218
3267
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3219
3268
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3232,7 +3281,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3232
3281
  this._keyring = _keyring;
3233
3282
  this._signingContext = _signingContext;
3234
3283
  this._feedStore = _feedStore;
3235
- this._ctx = new Context7();
3284
+ this._ctx = new Context8();
3236
3285
  this.updated = new Event6();
3237
3286
  this._spaces = new ComplexMap3(PublicKey8.hash);
3238
3287
  this._isOpen = false;
@@ -3249,7 +3298,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3249
3298
  S: this,
3250
3299
  C: (f, a) => f(...a)
3251
3300
  });
3252
- log11.trace("dxos.echo.data-space-manager.open", trace4.begin({
3301
+ log11.trace("dxos.echo.data-space-manager.open", trace5.begin({
3253
3302
  id: this._instanceId
3254
3303
  }), {
3255
3304
  F: __dxlog_file13,
@@ -3294,7 +3343,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3294
3343
  }
3295
3344
  this._isOpen = true;
3296
3345
  this.updated.emit();
3297
- log11.trace("dxos.echo.data-space-manager.open", trace4.end({
3346
+ log11.trace("dxos.echo.data-space-manager.open", trace5.end({
3298
3347
  id: this._instanceId
3299
3348
  }), {
3300
3349
  F: __dxlog_file13,
@@ -3528,19 +3577,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3528
3577
  return dataSpace;
3529
3578
  }
3530
3579
  };
3531
- _ts_decorate2([
3580
+ _ts_decorate4([
3532
3581
  synchronized2
3533
3582
  ], DataSpaceManager.prototype, "open", null);
3534
- _ts_decorate2([
3583
+ _ts_decorate4([
3535
3584
  synchronized2
3536
3585
  ], DataSpaceManager.prototype, "close", null);
3537
- _ts_decorate2([
3586
+ _ts_decorate4([
3538
3587
  synchronized2
3539
3588
  ], DataSpaceManager.prototype, "createSpace", null);
3540
- _ts_decorate2([
3589
+ _ts_decorate4([
3541
3590
  synchronized2
3542
3591
  ], DataSpaceManager.prototype, "acceptSpace", null);
3543
- DataSpaceManager = _ts_decorate2([
3592
+ DataSpaceManager = _ts_decorate4([
3544
3593
  trackLeaks2("open", "close")
3545
3594
  ], DataSpaceManager);
3546
3595
 
@@ -3571,9 +3620,8 @@ var SpacesServiceImpl = class {
3571
3620
  return this._serializeSpace(space);
3572
3621
  }
3573
3622
  async updateSpace({ spaceKey, state }) {
3574
- var _a;
3575
3623
  const dataSpaceManager = await this._getDataSpaceManager();
3576
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
3624
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
3577
3625
  if (state) {
3578
3626
  switch (state) {
3579
3627
  case SpaceState3.ACTIVE:
@@ -3637,17 +3685,15 @@ var SpacesServiceImpl = class {
3637
3685
  });
3638
3686
  }
3639
3687
  async postMessage({ spaceKey, channel, message }) {
3640
- var _a;
3641
3688
  const dataSpaceManager = await this._getDataSpaceManager();
3642
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
3689
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
3643
3690
  await space.postMessage(getChannelId(channel), message);
3644
3691
  }
3645
3692
  subscribeMessages({ spaceKey, channel }) {
3646
3693
  return new Stream10(({ ctx, next }) => {
3647
3694
  scheduleTask5(ctx, async () => {
3648
- var _a;
3649
3695
  const dataSpaceManager = await this._getDataSpaceManager();
3650
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
3696
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
3651
3697
  const handle = space.listen(getChannelId(channel), (message) => {
3652
3698
  next(message);
3653
3699
  });
@@ -3657,8 +3703,7 @@ var SpacesServiceImpl = class {
3657
3703
  }
3658
3704
  queryCredentials({ spaceKey }) {
3659
3705
  return new Stream10(({ ctx, next }) => {
3660
- var _a;
3661
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
3706
+ const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
3662
3707
  const processor = {
3663
3708
  processCredential: async (credential) => {
3664
3709
  next(credential);
@@ -3669,9 +3714,8 @@ var SpacesServiceImpl = class {
3669
3714
  });
3670
3715
  }
3671
3716
  async writeCredentials({ spaceKey, credentials }) {
3672
- var _a;
3673
- const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
3674
- for (const credential of credentials != null ? credentials : []) {
3717
+ const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
3718
+ for (const credential of credentials ?? []) {
3675
3719
  await space.controlPipeline.writer.write({
3676
3720
  credential: {
3677
3721
  credential
@@ -3680,13 +3724,11 @@ var SpacesServiceImpl = class {
3680
3724
  }
3681
3725
  }
3682
3726
  async createEpoch({ spaceKey }) {
3683
- var _a;
3684
3727
  const dataSpaceManager = await this._getDataSpaceManager();
3685
- const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
3728
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
3686
3729
  await space.createEpoch();
3687
3730
  }
3688
3731
  _serializeSpace(space) {
3689
- var _a, _b, _c, _d, _e, _f, _g;
3690
3732
  return {
3691
3733
  spaceKey: space.key,
3692
3734
  state: space.state,
@@ -3698,16 +3740,15 @@ var SpacesServiceImpl = class {
3698
3740
  currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
3699
3741
  targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
3700
3742
  totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
3701
- dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
3702
- startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
3703
- currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
3704
- targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
3705
- totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
3743
+ dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
3744
+ startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
3745
+ currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
3746
+ targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
3747
+ totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
3706
3748
  },
3707
3749
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3708
- var _a2, _b2, _c2;
3709
3750
  const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
3710
- const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
3751
+ const isMe = this._identityManager.identity?.identityKey.equals(member.key);
3711
3752
  if (isMe) {
3712
3753
  peers.push(space.presence.getLocalState());
3713
3754
  }
@@ -3715,14 +3756,14 @@ var SpacesServiceImpl = class {
3715
3756
  identity: {
3716
3757
  identityKey: member.key,
3717
3758
  profile: {
3718
- displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : humanize(member.key)
3759
+ displayName: member.assertion.profile?.displayName ?? humanize(member.key)
3719
3760
  }
3720
3761
  },
3721
3762
  presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
3722
3763
  peerStates: peers
3723
3764
  };
3724
3765
  }),
3725
- creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
3766
+ creator: space.inner.spaceState.creator?.key,
3726
3767
  cache: space.cache,
3727
3768
  metrics: space.metrics
3728
3769
  };
@@ -3732,6 +3773,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
3732
3773
 
3733
3774
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3734
3775
  import { Trigger as Trigger5 } from "@dxos/async";
3776
+ import { Context as Context9 } from "@dxos/context";
3735
3777
  import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
3736
3778
  import { failUndefined as failUndefined3 } from "@dxos/debug";
3737
3779
  import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore } from "@dxos/echo-pipeline";
@@ -3740,11 +3782,23 @@ import { invariant as invariant12 } from "@dxos/invariant";
3740
3782
  import { Keyring } from "@dxos/keyring";
3741
3783
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3742
3784
  import { log as log13 } from "@dxos/log";
3743
- import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace5 } from "@dxos/protocols";
3785
+ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/protocols";
3744
3786
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
3745
3787
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
3788
+ import { trace as Trace2 } from "@dxos/tracing";
3789
+ import { safeInstanceof } from "@dxos/util";
3790
+ function _ts_decorate5(decorators, target, key, desc) {
3791
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3792
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3793
+ r = Reflect.decorate(decorators, target, key, desc);
3794
+ else
3795
+ for (var i = decorators.length - 1; i >= 0; i--)
3796
+ if (d = decorators[i])
3797
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3798
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3799
+ }
3746
3800
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3747
- var ServiceContext = class {
3801
+ var ServiceContext = class ServiceContext2 {
3748
3802
  // prettier-ignore
3749
3803
  constructor(storage, networkManager, signalManager, modelFactory) {
3750
3804
  this.storage = storage;
@@ -3778,61 +3832,57 @@ var ServiceContext = class {
3778
3832
  });
3779
3833
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3780
3834
  this.invitations = new InvitationsHandler(this.networkManager);
3781
- this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3782
- var _a;
3783
- return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
3784
- }, this._acceptIdentity.bind(this)));
3835
+ this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
3785
3836
  }
3786
- async open() {
3837
+ async open(ctx) {
3787
3838
  await this._checkStorageVersion();
3788
3839
  log13("opening...", void 0, {
3789
3840
  F: __dxlog_file15,
3790
- L: 127,
3841
+ L: 134,
3791
3842
  S: this,
3792
3843
  C: (f, a) => f(...a)
3793
3844
  });
3794
- log13.trace("dxos.sdk.service-context.open", trace5.begin({
3845
+ log13.trace("dxos.sdk.service-context.open", trace6.begin({
3795
3846
  id: this._instanceId
3796
3847
  }), {
3797
3848
  F: __dxlog_file15,
3798
- L: 128,
3849
+ L: 135,
3799
3850
  S: this,
3800
3851
  C: (f, a) => f(...a)
3801
3852
  });
3802
3853
  await this.signalManager.open();
3803
3854
  await this.networkManager.open();
3804
3855
  await this.spaceManager.open();
3805
- await this.identityManager.open();
3856
+ await this.identityManager.open(ctx);
3806
3857
  if (this.identityManager.identity) {
3807
- await this._initialize();
3858
+ await this._initialize(ctx);
3808
3859
  }
3809
- log13.trace("dxos.sdk.service-context.open", trace5.end({
3860
+ log13.trace("dxos.sdk.service-context.open", trace6.end({
3810
3861
  id: this._instanceId
3811
3862
  }), {
3812
3863
  F: __dxlog_file15,
3813
- L: 136,
3864
+ L: 143,
3814
3865
  S: this,
3815
3866
  C: (f, a) => f(...a)
3816
3867
  });
3817
3868
  log13("opened", void 0, {
3818
3869
  F: __dxlog_file15,
3819
- L: 137,
3870
+ L: 144,
3820
3871
  S: this,
3821
3872
  C: (f, a) => f(...a)
3822
3873
  });
3823
3874
  }
3824
3875
  async close() {
3825
- var _a;
3826
3876
  log13("closing...", void 0, {
3827
3877
  F: __dxlog_file15,
3828
- L: 141,
3878
+ L: 148,
3829
3879
  S: this,
3830
3880
  C: (f, a) => f(...a)
3831
3881
  });
3832
3882
  if (this._deviceSpaceSync && this.identityManager.identity) {
3833
3883
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
3834
3884
  }
3835
- await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
3885
+ await this.dataSpaceManager?.close();
3836
3886
  await this.identityManager.close();
3837
3887
  await this.spaceManager.close();
3838
3888
  await this.feedStore.close();
@@ -3841,21 +3891,21 @@ var ServiceContext = class {
3841
3891
  this.dataServiceSubscriptions.clear();
3842
3892
  log13("closed", void 0, {
3843
3893
  F: __dxlog_file15,
3844
- L: 152,
3894
+ L: 159,
3845
3895
  S: this,
3846
3896
  C: (f, a) => f(...a)
3847
3897
  });
3848
3898
  }
3849
3899
  async createIdentity(params = {}) {
3850
3900
  const identity = await this.identityManager.createIdentity(params);
3851
- await this._initialize();
3901
+ await this._initialize(new Context9());
3852
3902
  return identity;
3853
3903
  }
3854
3904
  getInvitationHandler(invitation) {
3855
3905
  const factory = this._handlerFactories.get(invitation.kind);
3856
3906
  invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
3857
3907
  F: __dxlog_file15,
3858
- L: 164,
3908
+ L: 171,
3859
3909
  S: this,
3860
3910
  A: [
3861
3911
  "factory",
@@ -3866,7 +3916,7 @@ var ServiceContext = class {
3866
3916
  }
3867
3917
  async _acceptIdentity(params) {
3868
3918
  const identity = await this.identityManager.acceptIdentity(params);
3869
- await this._initialize();
3919
+ await this._initialize(new Context9());
3870
3920
  return identity;
3871
3921
  }
3872
3922
  async _checkStorageVersion() {
@@ -3876,15 +3926,14 @@ var ServiceContext = class {
3876
3926
  }
3877
3927
  }
3878
3928
  // Called when identity is created.
3879
- async _initialize() {
3880
- var _a;
3929
+ async _initialize(ctx) {
3881
3930
  log13("initializing spaces...", void 0, {
3882
3931
  F: __dxlog_file15,
3883
- L: 185,
3932
+ L: 193,
3884
3933
  S: this,
3885
3934
  C: (f, a) => f(...a)
3886
3935
  });
3887
- const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined3();
3936
+ const identity = this.identityManager.identity ?? failUndefined3();
3888
3937
  const signingContext = {
3889
3938
  credentialSigner: identity.getIdentityCredentialSigner(),
3890
3939
  identityKey: identity.identityKey,
@@ -3903,7 +3952,7 @@ var ServiceContext = class {
3903
3952
  this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
3904
3953
  invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3905
3954
  F: __dxlog_file15,
3906
- L: 208,
3955
+ L: 216,
3907
3956
  S: this,
3908
3957
  A: [
3909
3958
  "this.dataSpaceManager",
@@ -3927,7 +3976,7 @@ var ServiceContext = class {
3927
3976
  details: assertion
3928
3977
  }, {
3929
3978
  F: __dxlog_file15,
3930
- L: 224,
3979
+ L: 232,
3931
3980
  S: this,
3932
3981
  C: (f, a) => f(...a)
3933
3982
  });
@@ -3938,7 +3987,7 @@ var ServiceContext = class {
3938
3987
  details: assertion
3939
3988
  }, {
3940
3989
  F: __dxlog_file15,
3941
- L: 228,
3990
+ L: 236,
3942
3991
  S: this,
3943
3992
  C: (f, a) => f(...a)
3944
3993
  });
@@ -3949,7 +3998,7 @@ var ServiceContext = class {
3949
3998
  details: assertion
3950
3999
  }, {
3951
4000
  F: __dxlog_file15,
3952
- L: 233,
4001
+ L: 241,
3953
4002
  S: this,
3954
4003
  C: (f, a) => f(...a)
3955
4004
  });
@@ -3960,7 +4009,7 @@ var ServiceContext = class {
3960
4009
  } catch (err) {
3961
4010
  log13.catch(err, void 0, {
3962
4011
  F: __dxlog_file15,
3963
- L: 239,
4012
+ L: 247,
3964
4013
  S: this,
3965
4014
  C: (f, a) => f(...a)
3966
4015
  });
@@ -3970,12 +4019,22 @@ var ServiceContext = class {
3970
4019
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3971
4020
  }
3972
4021
  };
4022
+ _ts_decorate5([
4023
+ Trace2.span()
4024
+ ], ServiceContext.prototype, "open", null);
4025
+ _ts_decorate5([
4026
+ Trace2.span()
4027
+ ], ServiceContext.prototype, "_initialize", null);
4028
+ ServiceContext = _ts_decorate5([
4029
+ safeInstanceof("dxos.client-services.ServiceContext"),
4030
+ Trace2.resource()
4031
+ ], ServiceContext);
3973
4032
 
3974
4033
  // packages/sdk/client-services/src/packlets/locks/browser.ts
3975
4034
  import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
3976
4035
  import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
3977
4036
  import { log as log14, logInfo } from "@dxos/log";
3978
- function _ts_decorate3(decorators, target, key, desc) {
4037
+ function _ts_decorate6(decorators, target, key, desc) {
3979
4038
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3980
4039
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3981
4040
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4020,7 +4079,7 @@ var Lock = class {
4020
4079
  S: this,
4021
4080
  C: (f, a) => f(...a)
4022
4081
  });
4023
- } catch (e) {
4082
+ } catch {
4024
4083
  log14("stealing lock...", void 0, {
4025
4084
  F: __dxlog_file16,
4026
4085
  L: 46,
@@ -4057,8 +4116,7 @@ var Lock = class {
4057
4116
  void navigator.locks.request(this._lockKey, {
4058
4117
  steal
4059
4118
  }, async () => {
4060
- var _a, _b;
4061
- await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
4119
+ await this._onAcquire?.();
4062
4120
  acquired.wake();
4063
4121
  this._releaseTrigger = new Trigger6();
4064
4122
  await this._releaseTrigger.wait();
@@ -4068,7 +4126,7 @@ var Lock = class {
4068
4126
  S: this,
4069
4127
  C: (f, a) => f(...a)
4070
4128
  });
4071
- await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
4129
+ await this._onRelease?.();
4072
4130
  log14("released lock", void 0, {
4073
4131
  F: __dxlog_file16,
4074
4132
  L: 74,
@@ -4076,8 +4134,7 @@ var Lock = class {
4076
4134
  C: (f, a) => f(...a)
4077
4135
  });
4078
4136
  }).catch(async () => {
4079
- var _a;
4080
- await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
4137
+ await this._onRelease?.();
4081
4138
  });
4082
4139
  await acquired.wait();
4083
4140
  log14("recieved lock", {
@@ -4090,7 +4147,7 @@ var Lock = class {
4090
4147
  });
4091
4148
  }
4092
4149
  };
4093
- _ts_decorate3([
4150
+ _ts_decorate6([
4094
4151
  logInfo
4095
4152
  ], Lock.prototype, "lockKey", null);
4096
4153
  var isLocked = (lockPath) => {
@@ -4105,7 +4162,7 @@ import { createStorage, StorageType } from "@dxos/random-access-storage";
4105
4162
  import { isNode } from "@dxos/util";
4106
4163
  var StorageDriver = Runtime.Client.Storage.StorageDriver;
4107
4164
  var createStorageObjects = (config) => {
4108
- const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
4165
+ const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
4109
4166
  if (persistent && storageType === StorageDriver.RAM) {
4110
4167
  throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
4111
4168
  }
@@ -4173,6 +4230,7 @@ var ServiceRegistry = class {
4173
4230
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4174
4231
  import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
4175
4232
  import { clientServiceBundle } from "@dxos/client-protocol";
4233
+ import { Context as Context10 } from "@dxos/context";
4176
4234
  import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
4177
4235
  import { DataServiceImpl } from "@dxos/echo-pipeline";
4178
4236
  import { invariant as invariant13 } from "@dxos/invariant";
@@ -4181,9 +4239,10 @@ import { log as log16 } from "@dxos/log";
4181
4239
  import { WebsocketSignalManager } from "@dxos/messaging";
4182
4240
  import { ModelFactory } from "@dxos/model-factory";
4183
4241
  import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
4184
- import { trace as trace6 } from "@dxos/protocols";
4242
+ import { trace as trace7 } from "@dxos/protocols";
4185
4243
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
4186
4244
  import { TextModel } from "@dxos/text-model";
4245
+ import { TRACE_PROCESSOR, trace as Trace3 } from "@dxos/tracing";
4187
4246
 
4188
4247
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
4189
4248
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
@@ -4199,21 +4258,17 @@ var DevicesServiceImpl = class {
4199
4258
  queryDevices() {
4200
4259
  return new Stream11(({ next }) => {
4201
4260
  const update = () => {
4202
- var _a;
4203
- const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
4261
+ const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
4204
4262
  if (!deviceKeys) {
4205
4263
  next({
4206
4264
  devices: []
4207
4265
  });
4208
4266
  } else {
4209
4267
  next({
4210
- devices: Array.from(deviceKeys.values()).map((key) => {
4211
- var _a2;
4212
- return {
4213
- deviceKey: key,
4214
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
4215
- };
4216
- })
4268
+ devices: Array.from(deviceKeys.values()).map((key) => ({
4269
+ deviceKey: key,
4270
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
4271
+ }))
4217
4272
  });
4218
4273
  }
4219
4274
  };
@@ -4241,7 +4296,7 @@ import { jsonify, numericalValues, tracer } from "@dxos/util";
4241
4296
  var LoggingServiceImpl = class {
4242
4297
  constructor() {
4243
4298
  this._logs = new Event7();
4244
- this._started = new Date();
4299
+ this._started = /* @__PURE__ */ new Date();
4245
4300
  this._logProcessor = (_config, entry2) => {
4246
4301
  this._logs.emit(entry2);
4247
4302
  };
@@ -4271,8 +4326,7 @@ var LoggingServiceImpl = class {
4271
4326
  */
4272
4327
  queryMetrics({ interval = 5e3 }) {
4273
4328
  const getNumericalValues = (key) => {
4274
- var _a;
4275
- const events = (_a = tracer.get(key)) != null ? _a : [];
4329
+ const events = tracer.get(key) ?? [];
4276
4330
  return {
4277
4331
  key,
4278
4332
  stats: numericalValues(events, "duration")
@@ -4281,14 +4335,14 @@ var LoggingServiceImpl = class {
4281
4335
  return new Stream12(({ next }) => {
4282
4336
  const update = () => {
4283
4337
  const metrics = {
4284
- timestamp: new Date(),
4338
+ timestamp: /* @__PURE__ */ new Date(),
4285
4339
  values: [
4286
4340
  getNumericalValues("dxos.echo.pipeline.control"),
4287
4341
  getNumericalValues("dxos.echo.pipeline.data")
4288
4342
  ].filter(Boolean)
4289
4343
  };
4290
4344
  next({
4291
- timestamp: new Date(),
4345
+ timestamp: /* @__PURE__ */ new Date(),
4292
4346
  metrics
4293
4347
  });
4294
4348
  };
@@ -4302,11 +4356,10 @@ var LoggingServiceImpl = class {
4302
4356
  queryLogs(request) {
4303
4357
  return new Stream12(({ ctx, next }) => {
4304
4358
  const handler = (entry2) => {
4305
- var _a, _b, _c, _d, _e;
4306
4359
  if (LOG_PROCESSING > 0) {
4307
4360
  return;
4308
4361
  }
4309
- if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
4362
+ if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
4310
4363
  return;
4311
4364
  }
4312
4365
  if (!shouldLog(entry2, request)) {
@@ -4315,11 +4368,11 @@ var LoggingServiceImpl = class {
4315
4368
  const record = {
4316
4369
  ...entry2,
4317
4370
  context: jsonify(getContextFromEntry(entry2)),
4318
- timestamp: new Date(),
4371
+ timestamp: /* @__PURE__ */ new Date(),
4319
4372
  meta: {
4320
4373
  // TODO(dmaretskyi): Fix proto.
4321
- file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
4322
- line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
4374
+ file: entry2.meta?.F ?? "",
4375
+ line: entry2.meta?.L ?? 0
4323
4376
  }
4324
4377
  };
4325
4378
  try {
@@ -4342,15 +4395,11 @@ var matchFilter = (filter, level, path, options) => {
4342
4395
  }
4343
4396
  };
4344
4397
  var shouldLog = (entry2, request) => {
4345
- var _a;
4346
- const options = (_a = request.options) != null ? _a : QueryLogsRequest.MatchingOptions.INCLUSIVE;
4398
+ const options = request.options ?? QueryLogsRequest.MatchingOptions.INCLUSIVE;
4347
4399
  if (request.filters === void 0) {
4348
4400
  return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
4349
4401
  } else {
4350
- return request.filters.some((filter) => {
4351
- var _a2, _b;
4352
- return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
4353
- });
4402
+ return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
4354
4403
  }
4355
4404
  };
4356
4405
  var LOG_PROCESSING = 0;
@@ -4401,8 +4450,7 @@ var SystemServiceImpl = class {
4401
4450
  this._onReset = onReset;
4402
4451
  }
4403
4452
  async getConfig() {
4404
- var _a, _b;
4405
- return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
4453
+ return this._config?.values ?? {};
4406
4454
  }
4407
4455
  /**
4408
4456
  * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
@@ -4410,7 +4458,7 @@ var SystemServiceImpl = class {
4410
4458
  async getDiagnostics({ keys } = {}) {
4411
4459
  const diagnostics = await this._getDiagnostics();
4412
4460
  return {
4413
- timestamp: new Date(),
4461
+ timestamp: /* @__PURE__ */ new Date(),
4414
4462
  diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
4415
4463
  truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4416
4464
  humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
@@ -4443,7 +4491,7 @@ var SystemServiceImpl = class {
4443
4491
  };
4444
4492
 
4445
4493
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4446
- function _ts_decorate4(decorators, target, key, desc) {
4494
+ function _ts_decorate7(decorators, target, key, desc) {
4447
4495
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4448
4496
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4449
4497
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4457,7 +4505,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4457
4505
  var createDefaultModelFactory = () => {
4458
4506
  return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
4459
4507
  };
4460
- var ClientServicesHost = class {
4508
+ var ClientServicesHost = class ClientServicesHost2 {
4461
4509
  constructor({
4462
4510
  config,
4463
4511
  modelFactory = createDefaultModelFactory(),
@@ -4468,6 +4516,7 @@ var ClientServicesHost = class {
4468
4516
  lockKey,
4469
4517
  callbacks
4470
4518
  } = {}) {
4519
+ this._tracingService = TRACE_PROCESSOR.createTraceSender();
4471
4520
  this._statusUpdate = new Event8();
4472
4521
  this._opening = false;
4473
4522
  this._open = false;
@@ -4486,7 +4535,7 @@ var ClientServicesHost = class {
4486
4535
  lockKey,
4487
4536
  onAcquire: () => {
4488
4537
  if (!this._opening) {
4489
- void this.open();
4538
+ void this.open(new Context10());
4490
4539
  }
4491
4540
  },
4492
4541
  onRelease: () => this.close()
@@ -4500,11 +4549,10 @@ var ClientServicesHost = class {
4500
4549
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4501
4550
  },
4502
4551
  onUpdateStatus: async (status) => {
4503
- var _a, _b;
4504
4552
  if (!this.isOpen && status === SystemStatus.ACTIVE) {
4505
- await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4553
+ await this._resourceLock?.acquire();
4506
4554
  } else if (this.isOpen && status === SystemStatus.INACTIVE) {
4507
- await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4555
+ await this._resourceLock?.release();
4508
4556
  }
4509
4557
  },
4510
4558
  onReset: async () => {
@@ -4513,7 +4561,8 @@ var ClientServicesHost = class {
4513
4561
  });
4514
4562
  this._loggingService = new LoggingServiceImpl();
4515
4563
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
4516
- SystemService: this._systemService
4564
+ SystemService: this._systemService,
4565
+ TracingService: this._tracingService
4517
4566
  });
4518
4567
  }
4519
4568
  get isOpen() {
@@ -4540,26 +4589,25 @@ var ClientServicesHost = class {
4540
4589
  * Can only be called once.
4541
4590
  */
4542
4591
  initialize({ config, ...options }) {
4543
- var _a, _b, _c;
4544
4592
  invariant13(!this._open, "service host is open", {
4545
4593
  F: __dxlog_file17,
4546
- L: 172,
4594
+ L: 181,
4547
4595
  S: this,
4548
4596
  A: [
4549
4597
  "!this._open",
4550
4598
  "'service host is open'"
4551
4599
  ]
4552
4600
  });
4553
- log16.info("initializing...", void 0, {
4601
+ log16("initializing...", void 0, {
4554
4602
  F: __dxlog_file17,
4555
- L: 173,
4603
+ L: 182,
4556
4604
  S: this,
4557
4605
  C: (f, a) => f(...a)
4558
4606
  });
4559
4607
  if (config) {
4560
4608
  invariant13(!this._config, "config already set", {
4561
4609
  F: __dxlog_file17,
4562
- L: 176,
4610
+ L: 185,
4563
4611
  S: this,
4564
4612
  A: [
4565
4613
  "!this._config",
@@ -4572,12 +4620,12 @@ var ClientServicesHost = class {
4572
4620
  }
4573
4621
  }
4574
4622
  const { connectionLog = true, transportFactory = createWebRTCTransportFactory({
4575
- iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4576
- }), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4623
+ iceServers: this._config?.get("runtime.services.ice")
4624
+ }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
4577
4625
  this._signalManager = signalManager;
4578
4626
  invariant13(!this._networkManager, "network manager already set", {
4579
4627
  F: __dxlog_file17,
4580
- L: 192,
4628
+ L: 201,
4581
4629
  S: this,
4582
4630
  A: [
4583
4631
  "!this._networkManager",
@@ -4589,30 +4637,29 @@ var ClientServicesHost = class {
4589
4637
  transportFactory,
4590
4638
  signalManager
4591
4639
  });
4592
- log16.info("initialized", void 0, {
4640
+ log16("initialized", void 0, {
4593
4641
  F: __dxlog_file17,
4594
- L: 199,
4642
+ L: 208,
4595
4643
  S: this,
4596
4644
  C: (f, a) => f(...a)
4597
4645
  });
4598
4646
  }
4599
- async open() {
4600
- var _a, _b, _c;
4647
+ async open(ctx) {
4601
4648
  if (this._open) {
4602
4649
  return;
4603
4650
  }
4604
4651
  const traceId = PublicKey10.random().toHex();
4605
- log16.trace("dxos.client-services.host.open", trace6.begin({
4652
+ log16.trace("dxos.client-services.host.open", trace7.begin({
4606
4653
  id: traceId
4607
4654
  }), {
4608
4655
  F: __dxlog_file17,
4609
- L: 209,
4656
+ L: 219,
4610
4657
  S: this,
4611
4658
  C: (f, a) => f(...a)
4612
4659
  });
4613
4660
  invariant13(this._config, "config not set", {
4614
4661
  F: __dxlog_file17,
4615
- L: 211,
4662
+ L: 221,
4616
4663
  S: this,
4617
4664
  A: [
4618
4665
  "this._config",
@@ -4621,7 +4668,7 @@ var ClientServicesHost = class {
4621
4668
  });
4622
4669
  invariant13(this._storage, "storage not set", {
4623
4670
  F: __dxlog_file17,
4624
- L: 212,
4671
+ L: 222,
4625
4672
  S: this,
4626
4673
  A: [
4627
4674
  "this._storage",
@@ -4630,7 +4677,7 @@ var ClientServicesHost = class {
4630
4677
  });
4631
4678
  invariant13(this._signalManager, "signal manager not set", {
4632
4679
  F: __dxlog_file17,
4633
- L: 213,
4680
+ L: 223,
4634
4681
  S: this,
4635
4682
  A: [
4636
4683
  "this._signalManager",
@@ -4639,7 +4686,7 @@ var ClientServicesHost = class {
4639
4686
  });
4640
4687
  invariant13(this._networkManager, "network manager not set", {
4641
4688
  F: __dxlog_file17,
4642
- L: 214,
4689
+ L: 224,
4643
4690
  S: this,
4644
4691
  A: [
4645
4692
  "this._networkManager",
@@ -4647,20 +4694,20 @@ var ClientServicesHost = class {
4647
4694
  ]
4648
4695
  });
4649
4696
  this._opening = true;
4650
- log16.info("opening...", {
4651
- lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4697
+ log16("opening...", {
4698
+ lockKey: this._resourceLock?.lockKey
4652
4699
  }, {
4653
4700
  F: __dxlog_file17,
4654
- L: 217,
4701
+ L: 227,
4655
4702
  S: this,
4656
4703
  C: (f, a) => f(...a)
4657
4704
  });
4658
- await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
4705
+ await this._resourceLock?.acquire();
4659
4706
  await this._loggingService.open();
4660
4707
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
4661
4708
  this._serviceRegistry.setServices({
4662
4709
  SystemService: this._systemService,
4663
- IdentityService: new IdentityServiceImpl(this._serviceContext),
4710
+ IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
4664
4711
  InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
4665
4712
  DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
4666
4713
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
@@ -4670,6 +4717,7 @@ var ClientServicesHost = class {
4670
4717
  DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4671
4718
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4672
4719
  LoggingService: this._loggingService,
4720
+ TracingService: this._tracingService,
4673
4721
  // TODO(burdon): Move to new protobuf definitions.
4674
4722
  DevtoolsHost: new DevtoolsServiceImpl({
4675
4723
  events: new DevtoolsHostEvents(),
@@ -4677,39 +4725,38 @@ var ClientServicesHost = class {
4677
4725
  context: this._serviceContext
4678
4726
  })
4679
4727
  });
4680
- await this._serviceContext.open();
4728
+ await this._serviceContext.open(ctx);
4681
4729
  this._opening = false;
4682
4730
  this._open = true;
4683
4731
  this._statusUpdate.emit();
4684
- const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4685
- log16.info("opened", {
4732
+ const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
4733
+ log16("opened", {
4686
4734
  deviceKey
4687
4735
  }, {
4688
4736
  F: __dxlog_file17,
4689
- L: 272,
4737
+ L: 284,
4690
4738
  S: this,
4691
4739
  C: (f, a) => f(...a)
4692
4740
  });
4693
- log16.trace("dxos.client-services.host.open", trace6.end({
4741
+ log16.trace("dxos.client-services.host.open", trace7.end({
4694
4742
  id: traceId
4695
4743
  }), {
4696
4744
  F: __dxlog_file17,
4697
- L: 273,
4745
+ L: 285,
4698
4746
  S: this,
4699
4747
  C: (f, a) => f(...a)
4700
4748
  });
4701
4749
  }
4702
4750
  async close() {
4703
- var _a;
4704
4751
  if (!this._open) {
4705
4752
  return;
4706
4753
  }
4707
- const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4708
- log16.info("closing...", {
4754
+ const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
4755
+ log16("closing...", {
4709
4756
  deviceKey
4710
4757
  }, {
4711
4758
  F: __dxlog_file17,
4712
- L: 283,
4759
+ L: 296,
4713
4760
  S: this,
4714
4761
  C: (f, a) => f(...a)
4715
4762
  });
@@ -4720,57 +4767,67 @@ var ClientServicesHost = class {
4720
4767
  await this._serviceContext.close();
4721
4768
  this._open = false;
4722
4769
  this._statusUpdate.emit();
4723
- log16.info("closed", {
4770
+ log16("closed", {
4724
4771
  deviceKey
4725
4772
  }, {
4726
4773
  F: __dxlog_file17,
4727
- L: 289,
4774
+ L: 302,
4728
4775
  S: this,
4729
4776
  C: (f, a) => f(...a)
4730
4777
  });
4731
4778
  }
4732
4779
  async reset() {
4733
- var _a, _b, _c;
4734
4780
  const traceId = PublicKey10.random().toHex();
4735
- log16.trace("dxos.sdk.client-services-host.reset", trace6.begin({
4781
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
4736
4782
  id: traceId
4737
4783
  }), {
4738
4784
  F: __dxlog_file17,
4739
- L: 294,
4785
+ L: 307,
4740
4786
  S: this,
4741
4787
  C: (f, a) => f(...a)
4742
4788
  });
4743
4789
  log16("resetting...", void 0, {
4744
4790
  F: __dxlog_file17,
4745
- L: 296,
4791
+ L: 309,
4746
4792
  S: this,
4747
4793
  C: (f, a) => f(...a)
4748
4794
  });
4749
- await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4795
+ await this._serviceContext?.close();
4750
4796
  await this._storage.reset();
4751
4797
  log16("reset", void 0, {
4752
4798
  F: __dxlog_file17,
4753
- L: 299,
4799
+ L: 312,
4754
4800
  S: this,
4755
4801
  C: (f, a) => f(...a)
4756
4802
  });
4757
- log16.trace("dxos.sdk.client-services-host.reset", trace6.end({
4803
+ log16.trace("dxos.sdk.client-services-host.reset", trace7.end({
4758
4804
  id: traceId
4759
4805
  }), {
4760
4806
  F: __dxlog_file17,
4761
- L: 300,
4807
+ L: 313,
4762
4808
  S: this,
4763
4809
  C: (f, a) => f(...a)
4764
4810
  });
4765
- await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4811
+ await this._callbacks?.onReset?.();
4766
4812
  }
4767
4813
  };
4768
- _ts_decorate4([
4769
- synchronized3
4814
+ _ts_decorate7([
4815
+ Trace3.info()
4816
+ ], ClientServicesHost.prototype, "_opening", void 0);
4817
+ _ts_decorate7([
4818
+ Trace3.info()
4819
+ ], ClientServicesHost.prototype, "_open", void 0);
4820
+ _ts_decorate7([
4821
+ synchronized3,
4822
+ Trace3.span()
4770
4823
  ], ClientServicesHost.prototype, "open", null);
4771
- _ts_decorate4([
4772
- synchronized3
4824
+ _ts_decorate7([
4825
+ synchronized3,
4826
+ Trace3.span()
4773
4827
  ], ClientServicesHost.prototype, "close", null);
4828
+ ClientServicesHost = _ts_decorate7([
4829
+ Trace3.resource()
4830
+ ], ClientServicesHost);
4774
4831
 
4775
4832
  export {
4776
4833
  subscribeToFeeds,
@@ -4805,4 +4862,4 @@ export {
4805
4862
  createDefaultModelFactory,
4806
4863
  ClientServicesHost
4807
4864
  };
4808
- //# sourceMappingURL=chunk-TXSXNZYI.mjs.map
4865
+ //# sourceMappingURL=chunk-DNY3UFRX.mjs.map