@dxos/client-services 0.4.10-main.b9b4602 → 0.4.10-main.c2d5db5

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 (48) hide show
  1. package/dist/lib/browser/{chunk-TPPBOJTA.mjs → chunk-KI2OUJI3.mjs} +499 -643
  2. package/dist/lib/browser/chunk-KI2OUJI3.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -9
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-33Q7F4MM.cjs → chunk-Z42MXXA4.cjs} +528 -590
  8. package/dist/lib/node/chunk-Z42MXXA4.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +38 -46
  10. package/dist/lib/node/index.cjs.map +1 -1
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/packlets/testing/index.cjs +6 -6
  13. package/dist/types/src/index.d.ts +0 -1
  14. package/dist/types/src/index.d.ts.map +1 -1
  15. package/dist/types/src/packlets/{diagnostics → services}/diagnostics.d.ts +1 -1
  16. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  17. package/dist/types/src/packlets/services/index.d.ts +1 -1
  18. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts +0 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/util.d.ts +0 -1
  22. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  23. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  24. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +34 -35
  27. package/src/index.ts +0 -1
  28. package/src/packlets/{diagnostics → services}/diagnostics.ts +2 -2
  29. package/src/packlets/services/index.ts +1 -1
  30. package/src/packlets/services/service-host.ts +1 -9
  31. package/src/packlets/services/util.ts +0 -2
  32. package/src/packlets/system/system-service.ts +1 -1
  33. package/src/version.ts +1 -1
  34. package/dist/lib/browser/chunk-TPPBOJTA.mjs.map +0 -7
  35. package/dist/lib/node/chunk-33Q7F4MM.cjs.map +0 -7
  36. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +0 -5
  37. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +0 -1
  38. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +0 -5
  39. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +0 -1
  40. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +0 -15
  41. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +0 -1
  42. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +0 -1
  43. package/dist/types/src/packlets/diagnostics/index.d.ts +0 -4
  44. package/dist/types/src/packlets/diagnostics/index.d.ts.map +0 -1
  45. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +0 -94
  46. package/src/packlets/diagnostics/diagnostics-broadcast.ts +0 -20
  47. package/src/packlets/diagnostics/diagnostics-collector.ts +0 -65
  48. package/src/packlets/diagnostics/index.ts +0 -7
@@ -2730,6 +2730,156 @@ ClientRpcServer = _ts_decorate3([
2730
2730
  trace5.resource()
2731
2731
  ], ClientRpcServer);
2732
2732
 
2733
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2734
+ import { getFirstStreamValue } from "@dxos/codec-protobuf";
2735
+ import { credentialTypeFilter } from "@dxos/credentials";
2736
+ import { invariant as invariant9 } from "@dxos/invariant";
2737
+ import { STORAGE_VERSION } from "@dxos/protocols";
2738
+ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
2739
+ import { TRACE_PROCESSOR } from "@dxos/tracing";
2740
+
2741
+ // packages/sdk/client-services/src/packlets/services/platform.ts
2742
+ import { Platform } from "@dxos/protocols/proto/dxos/client/services";
2743
+ var getPlatform = () => {
2744
+ if (process.browser) {
2745
+ if (typeof window !== "undefined") {
2746
+ const { userAgent } = window.navigator;
2747
+ return {
2748
+ type: Platform.PLATFORM_TYPE.BROWSER,
2749
+ userAgent,
2750
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2751
+ };
2752
+ } else {
2753
+ return {
2754
+ type: Platform.PLATFORM_TYPE.SHARED_WORKER,
2755
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2756
+ };
2757
+ }
2758
+ } else {
2759
+ const { platform: platform2, version, arch } = process;
2760
+ return {
2761
+ type: Platform.PLATFORM_TYPE.NODE,
2762
+ platform: platform2,
2763
+ arch,
2764
+ runtime: version,
2765
+ uptime: Math.floor(process.uptime()),
2766
+ memory: process.memoryUsage()
2767
+ };
2768
+ }
2769
+ };
2770
+
2771
+ // packages/sdk/client-services/src/version.ts
2772
+ var DXOS_VERSION = "0.4.10-main.c2d5db5";
2773
+
2774
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
2775
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2776
+ var DEFAULT_TIMEOUT = 1e3;
2777
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
2778
+ const diagnostics = {
2779
+ created: (/* @__PURE__ */ new Date()).toISOString(),
2780
+ platform: getPlatform(),
2781
+ client: {
2782
+ version: DXOS_VERSION,
2783
+ storage: {
2784
+ version: STORAGE_VERSION
2785
+ }
2786
+ },
2787
+ trace: TRACE_PROCESSOR.getDiagnostics()
2788
+ };
2789
+ {
2790
+ invariant9(clientServices.LoggingService, "SystemService is not available.", {
2791
+ F: __dxlog_file10,
2792
+ L: 108,
2793
+ S: void 0,
2794
+ A: [
2795
+ "clientServices.LoggingService",
2796
+ "'SystemService is not available.'"
2797
+ ]
2798
+ });
2799
+ diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
2800
+ timeout: DEFAULT_TIMEOUT
2801
+ }).catch(() => void 0);
2802
+ }
2803
+ if (typeof navigator !== "undefined" && navigator.storage) {
2804
+ const map = /* @__PURE__ */ new Map();
2805
+ const dir = await navigator.storage.getDirectory();
2806
+ for await (const filename of dir?.keys()) {
2807
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2808
+ if (idx === -1) {
2809
+ continue;
2810
+ }
2811
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2812
+ }
2813
+ diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2814
+ file,
2815
+ count
2816
+ }));
2817
+ }
2818
+ const identity = serviceContext.identityManager.identity;
2819
+ if (identity) {
2820
+ diagnostics.identity = {
2821
+ identityKey: identity.identityKey,
2822
+ spaceKey: identity.space.key,
2823
+ profile: identity.profileDocument
2824
+ };
2825
+ const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
2826
+ timeout: DEFAULT_TIMEOUT
2827
+ }).catch(() => void 0) ?? {};
2828
+ diagnostics.devices = devices;
2829
+ if (serviceContext.dataSpaceManager) {
2830
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2831
+ }
2832
+ const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2833
+ timeout: DEFAULT_TIMEOUT
2834
+ }).catch(() => void 0) ?? {};
2835
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2836
+ feedKey,
2837
+ bytes,
2838
+ length
2839
+ }));
2840
+ const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
2841
+ timeout: DEFAULT_TIMEOUT
2842
+ }).catch(() => void 0);
2843
+ diagnostics.networkStatus = status;
2844
+ diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
2845
+ }
2846
+ diagnostics.config = config.values;
2847
+ return diagnostics;
2848
+ };
2849
+ var getSpaceStats = async (space) => {
2850
+ const stats = {
2851
+ key: space.key,
2852
+ metrics: space.metrics,
2853
+ epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
2854
+ ...credential.subject.assertion,
2855
+ id: credential.id
2856
+ })),
2857
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2858
+ identity: {
2859
+ identityKey: member.key,
2860
+ profile: {
2861
+ displayName: member.assertion.profile?.displayName
2862
+ }
2863
+ },
2864
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
2865
+ })),
2866
+ pipeline: {
2867
+ // TODO(burdon): Pick properties from credentials if needed.
2868
+ currentEpoch: space.automergeSpaceState.lastEpoch,
2869
+ appliedEpoch: space.automergeSpaceState.lastEpoch,
2870
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2871
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2872
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2873
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
2874
+ }
2875
+ };
2876
+ if (stats.metrics) {
2877
+ const { open, ready } = stats.metrics;
2878
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2879
+ }
2880
+ return stats;
2881
+ };
2882
+
2733
2883
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2734
2884
  import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
2735
2885
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
@@ -2738,7 +2888,7 @@ import { timed, warnAfterTimeout } from "@dxos/debug";
2738
2888
  import { TYPE_PROPERTIES } from "@dxos/echo-db";
2739
2889
  import { createMappedFeedWriter } from "@dxos/echo-pipeline";
2740
2890
  import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
2741
- import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
2891
+ import { failedInvariant, invariant as invariant11 } from "@dxos/invariant";
2742
2892
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2743
2893
  import { log as log9 } from "@dxos/log";
2744
2894
  import { CancelledError, SystemError } from "@dxos/protocols";
@@ -2789,13 +2939,13 @@ var AutomergeSpaceState = class {
2789
2939
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2790
2940
  import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
2791
2941
  import { Context as Context7, rejectOnDispose } from "@dxos/context";
2792
- import { invariant as invariant9 } from "@dxos/invariant";
2942
+ import { invariant as invariant10 } from "@dxos/invariant";
2793
2943
  import { PublicKey as PublicKey7 } from "@dxos/keys";
2794
2944
  import { log as log8 } from "@dxos/log";
2795
2945
  import { schema as schema3 } from "@dxos/protocols";
2796
2946
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
2797
2947
  import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
2798
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2948
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2799
2949
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2800
2950
  var DEFAULT_SUCCESS_DELAY = 1e3;
2801
2951
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -2823,13 +2973,13 @@ var NotarizationPlugin = class {
2823
2973
  log8("notarize", {
2824
2974
  credentials
2825
2975
  }, {
2826
- F: __dxlog_file10,
2976
+ F: __dxlog_file11,
2827
2977
  L: 90,
2828
2978
  S: this,
2829
2979
  C: (f, a) => f(...a)
2830
2980
  });
2831
- invariant9(credentials.every((credential) => credential.id), "Credentials must have an id", {
2832
- F: __dxlog_file10,
2981
+ invariant10(credentials.every((credential) => credential.id), "Credentials must have an id", {
2982
+ F: __dxlog_file11,
2833
2983
  L: 91,
2834
2984
  S: this,
2835
2985
  A: [
@@ -2843,7 +2993,7 @@ var NotarizationPlugin = class {
2843
2993
  log8.warn("Notarization error", {
2844
2994
  err
2845
2995
  }, {
2846
- F: __dxlog_file10,
2996
+ F: __dxlog_file11,
2847
2997
  L: 99,
2848
2998
  S: this,
2849
2999
  C: (f, a) => f(...a)
@@ -2859,7 +3009,7 @@ var NotarizationPlugin = class {
2859
3009
  timeout,
2860
3010
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2861
3011
  }, {
2862
- F: __dxlog_file10,
3012
+ F: __dxlog_file11,
2863
3013
  L: 111,
2864
3014
  S: this,
2865
3015
  C: (f, a) => f(...a)
@@ -2882,7 +3032,7 @@ var NotarizationPlugin = class {
2882
3032
  log8.info("Exhausted all peers to notarize with", {
2883
3033
  retryIn: retryTimeout
2884
3034
  }, {
2885
- F: __dxlog_file10,
3035
+ F: __dxlog_file11,
2886
3036
  L: 136,
2887
3037
  S: this,
2888
3038
  C: (f, a) => f(...a)
@@ -2896,7 +3046,7 @@ var NotarizationPlugin = class {
2896
3046
  peer: peer.localPeerId,
2897
3047
  credentialId: credentials.map((credential) => credential.id)
2898
3048
  }, {
2899
- F: __dxlog_file10,
3049
+ F: __dxlog_file11,
2900
3050
  L: 143,
2901
3051
  S: this,
2902
3052
  C: (f, a) => f(...a)
@@ -2905,7 +3055,7 @@ var NotarizationPlugin = class {
2905
3055
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2906
3056
  });
2907
3057
  log8("success", void 0, {
2908
- F: __dxlog_file10,
3058
+ F: __dxlog_file11,
2909
3059
  L: 147,
2910
3060
  S: this,
2911
3061
  C: (f, a) => f(...a)
@@ -2914,7 +3064,7 @@ var NotarizationPlugin = class {
2914
3064
  } catch (err) {
2915
3065
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2916
3066
  log8.info("error notarizing (recoverable)", err, {
2917
- F: __dxlog_file10,
3067
+ F: __dxlog_file11,
2918
3068
  L: 151,
2919
3069
  S: this,
2920
3070
  C: (f, a) => f(...a)
@@ -2932,7 +3082,7 @@ var NotarizationPlugin = class {
2932
3082
  errors.wait()
2933
3083
  ]);
2934
3084
  log8("done", void 0, {
2935
- F: __dxlog_file10,
3085
+ F: __dxlog_file11,
2936
3086
  L: 162,
2937
3087
  S: this,
2938
3088
  C: (f, a) => f(...a)
@@ -2953,8 +3103,8 @@ var NotarizationPlugin = class {
2953
3103
  this._processCredentialsTriggers.delete(credential.id);
2954
3104
  }
2955
3105
  setWriter(writer) {
2956
- invariant9(!this._writer, "Writer already set.", {
2957
- F: __dxlog_file10,
3106
+ invariant10(!this._writer, "Writer already set.", {
3107
+ F: __dxlog_file11,
2958
3108
  L: 181,
2959
3109
  S: this,
2960
3110
  A: [
@@ -2978,8 +3128,8 @@ var NotarizationPlugin = class {
2978
3128
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2979
3129
  }
2980
3130
  for (const credential of request.credentials ?? []) {
2981
- invariant9(credential.id, "Credential must have an id", {
2982
- F: __dxlog_file10,
3131
+ invariant10(credential.id, "Credential must have an id", {
3132
+ F: __dxlog_file11,
2983
3133
  L: 200,
2984
3134
  S: this,
2985
3135
  A: [
@@ -2999,7 +3149,7 @@ var NotarizationPlugin = class {
2999
3149
  log8("extension opened", {
3000
3150
  peer: extension.localPeerId
3001
3151
  }, {
3002
- F: __dxlog_file10,
3152
+ F: __dxlog_file11,
3003
3153
  L: 211,
3004
3154
  S: this,
3005
3155
  C: (f, a) => f(...a)
@@ -3011,7 +3161,7 @@ var NotarizationPlugin = class {
3011
3161
  log8("extension closed", {
3012
3162
  peer: extension.localPeerId
3013
3163
  }, {
3014
- F: __dxlog_file10,
3164
+ F: __dxlog_file11,
3015
3165
  L: 216,
3016
3166
  S: this,
3017
3167
  C: (f, a) => f(...a)
@@ -3065,7 +3215,7 @@ function _ts_decorate4(decorators, target, key, desc) {
3065
3215
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3066
3216
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3067
3217
  }
3068
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3218
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3069
3219
  var DataSpace = class {
3070
3220
  constructor(params) {
3071
3221
  this._ctx = new Context8();
@@ -3100,7 +3250,7 @@ var DataSpace = class {
3100
3250
  log9("new state", {
3101
3251
  state: SpaceState[this._state]
3102
3252
  }, {
3103
- F: __dxlog_file11,
3253
+ F: __dxlog_file12,
3104
3254
  L: 140,
3105
3255
  S: this,
3106
3256
  C: (f, a) => f(...a)
@@ -3150,7 +3300,7 @@ var DataSpace = class {
3150
3300
  log9("new state", {
3151
3301
  state: SpaceState[this._state]
3152
3302
  }, {
3153
- F: __dxlog_file11,
3303
+ F: __dxlog_file12,
3154
3304
  L: 198,
3155
3305
  S: this,
3156
3306
  C: (f, a) => f(...a)
@@ -3168,7 +3318,7 @@ var DataSpace = class {
3168
3318
  log9("new state", {
3169
3319
  state: SpaceState[this._state]
3170
3320
  }, {
3171
- F: __dxlog_file11,
3321
+ F: __dxlog_file12,
3172
3322
  L: 212,
3173
3323
  S: this,
3174
3324
  C: (f, a) => f(...a)
@@ -3200,7 +3350,7 @@ var DataSpace = class {
3200
3350
  } catch (err) {
3201
3351
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
3202
3352
  log9("data pipeline initialization cancelled", err, {
3203
- F: __dxlog_file11,
3353
+ F: __dxlog_file12,
3204
3354
  L: 245,
3205
3355
  S: this,
3206
3356
  C: (f, a) => f(...a)
@@ -3208,7 +3358,7 @@ var DataSpace = class {
3208
3358
  return;
3209
3359
  }
3210
3360
  log9.error("Error initializing data pipeline", err, {
3211
- F: __dxlog_file11,
3361
+ F: __dxlog_file12,
3212
3362
  L: 249,
3213
3363
  S: this,
3214
3364
  C: (f, a) => f(...a)
@@ -3217,7 +3367,7 @@ var DataSpace = class {
3217
3367
  log9("new state", {
3218
3368
  state: SpaceState[this._state]
3219
3369
  }, {
3220
- F: __dxlog_file11,
3370
+ F: __dxlog_file12,
3221
3371
  L: 251,
3222
3372
  S: this,
3223
3373
  C: (f, a) => f(...a)
@@ -3237,7 +3387,7 @@ var DataSpace = class {
3237
3387
  log9("new state", {
3238
3388
  state: SpaceState[this._state]
3239
3389
  }, {
3240
- F: __dxlog_file11,
3390
+ F: __dxlog_file12,
3241
3391
  L: 267,
3242
3392
  S: this,
3243
3393
  C: (f, a) => f(...a)
@@ -3247,7 +3397,7 @@ var DataSpace = class {
3247
3397
  this._automergeSpaceState.startProcessingRootDocs();
3248
3398
  await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3249
3399
  log9("data pipeline ready", void 0, {
3250
- F: __dxlog_file11,
3400
+ F: __dxlog_file12,
3251
3401
  L: 279,
3252
3402
  S: this,
3253
3403
  C: (f, a) => f(...a)
@@ -3257,7 +3407,7 @@ var DataSpace = class {
3257
3407
  log9("new state", {
3258
3408
  state: SpaceState[this._state]
3259
3409
  }, {
3260
- F: __dxlog_file11,
3410
+ F: __dxlog_file12,
3261
3411
  L: 283,
3262
3412
  S: this,
3263
3413
  C: (f, a) => f(...a)
@@ -3273,7 +3423,7 @@ var DataSpace = class {
3273
3423
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3274
3424
  await this._createWritableFeeds();
3275
3425
  log9("writable feeds created", void 0, {
3276
- F: __dxlog_file11,
3426
+ F: __dxlog_file12,
3277
3427
  L: 299,
3278
3428
  S: this,
3279
3429
  C: (f, a) => f(...a)
@@ -3336,7 +3486,7 @@ var DataSpace = class {
3336
3486
  space: this.key,
3337
3487
  rootUrl
3338
3488
  }, {
3339
- F: __dxlog_file11,
3489
+ F: __dxlog_file12,
3340
3490
  L: 365,
3341
3491
  S: this,
3342
3492
  C: (f, a) => f(...a)
@@ -3368,7 +3518,7 @@ var DataSpace = class {
3368
3518
  rootUrl,
3369
3519
  err
3370
3520
  }, {
3371
- F: __dxlog_file11,
3521
+ F: __dxlog_file12,
3372
3522
  L: 388,
3373
3523
  S: this,
3374
3524
  C: (f, a) => f(...a)
@@ -3422,8 +3572,8 @@ var DataSpace = class {
3422
3572
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3423
3573
  await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
3424
3574
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3425
- invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3426
- F: __dxlog_file11,
3575
+ invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3576
+ F: __dxlog_file12,
3427
3577
  L: 438,
3428
3578
  S: this,
3429
3579
  A: [
@@ -3442,7 +3592,7 @@ var DataSpace = class {
3442
3592
  case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3443
3593
  {
3444
3594
  log9.info("Fragmenting", void 0, {
3445
- F: __dxlog_file11,
3595
+ F: __dxlog_file12,
3446
3596
  L: 450,
3447
3597
  S: this,
3448
3598
  C: (f, a) => f(...a)
@@ -3453,8 +3603,8 @@ var DataSpace = class {
3453
3603
  const objects = Object.entries(rootHandle.docSync().objects);
3454
3604
  const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
3455
3605
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3456
- invariant10(properties, "Properties not found", {
3457
- F: __dxlog_file11,
3606
+ invariant11(properties, "Properties not found", {
3607
+ F: __dxlog_file12,
3458
3608
  L: 460,
3459
3609
  S: this,
3460
3610
  A: [
@@ -3469,8 +3619,8 @@ var DataSpace = class {
3469
3619
  ])
3470
3620
  };
3471
3621
  const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3472
- invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3473
- F: __dxlog_file11,
3622
+ invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3623
+ F: __dxlog_file12,
3474
3624
  L: 465,
3475
3625
  S: this,
3476
3626
  A: [
@@ -3539,7 +3689,7 @@ var DataSpace = class {
3539
3689
  log9("new state", {
3540
3690
  state: SpaceState[this._state]
3541
3691
  }, {
3542
- F: __dxlog_file11,
3692
+ F: __dxlog_file12,
3543
3693
  L: 531,
3544
3694
  S: this,
3545
3695
  C: (f, a) => f(...a)
@@ -3597,7 +3747,7 @@ DataSpace = _ts_decorate4([
3597
3747
  import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
3598
3748
  import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
3599
3749
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
3600
- import { invariant as invariant11 } from "@dxos/invariant";
3750
+ import { invariant as invariant12 } from "@dxos/invariant";
3601
3751
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3602
3752
  import { log as log10 } from "@dxos/log";
3603
3753
  import { trace as trace7 } from "@dxos/protocols";
@@ -3608,7 +3758,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsyn
3608
3758
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
3609
3759
  import { createCredential } from "@dxos/credentials";
3610
3760
  import { failUndefined } from "@dxos/debug";
3611
- import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
3761
+ import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
3612
3762
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
3613
3763
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3614
3764
  const credentials = [
@@ -3628,7 +3778,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3628
3778
  assertion: {
3629
3779
  "@type": "dxos.halo.credentials.SpaceMember",
3630
3780
  spaceKey: space.key,
3631
- role: SpaceMember.Role.ADMIN,
3781
+ role: SpaceMember2.Role.ADMIN,
3632
3782
  profile: signingContext.getProfile(),
3633
3783
  genesisFeedKey: space.controlFeedKey ?? failUndefined()
3634
3784
  }
@@ -3686,7 +3836,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3686
3836
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3687
3837
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3688
3838
  }
3689
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3839
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3690
3840
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3691
3841
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3692
3842
  var DataSpaceManager = class {
@@ -3712,7 +3862,7 @@ var DataSpaceManager = class {
3712
3862
  }
3713
3863
  async open() {
3714
3864
  log10("open", void 0, {
3715
- F: __dxlog_file12,
3865
+ F: __dxlog_file13,
3716
3866
  L: 98,
3717
3867
  S: this,
3718
3868
  C: (f, a) => f(...a)
@@ -3720,7 +3870,7 @@ var DataSpaceManager = class {
3720
3870
  log10.trace("dxos.echo.data-space-manager.open", trace7.begin({
3721
3871
  id: this._instanceId
3722
3872
  }), {
3723
- F: __dxlog_file12,
3873
+ F: __dxlog_file13,
3724
3874
  L: 99,
3725
3875
  S: this,
3726
3876
  C: (f, a) => f(...a)
@@ -3728,7 +3878,7 @@ var DataSpaceManager = class {
3728
3878
  log10("metadata loaded", {
3729
3879
  spaces: this._metadataStore.spaces.length
3730
3880
  }, {
3731
- F: __dxlog_file12,
3881
+ F: __dxlog_file13,
3732
3882
  L: 100,
3733
3883
  S: this,
3734
3884
  C: (f, a) => f(...a)
@@ -3738,7 +3888,7 @@ var DataSpaceManager = class {
3738
3888
  log10("load space", {
3739
3889
  spaceMetadata
3740
3890
  }, {
3741
- F: __dxlog_file12,
3891
+ F: __dxlog_file13,
3742
3892
  L: 104,
3743
3893
  S: this,
3744
3894
  C: (f, a) => f(...a)
@@ -3749,7 +3899,7 @@ var DataSpaceManager = class {
3749
3899
  spaceMetadata,
3750
3900
  err
3751
3901
  }, {
3752
- F: __dxlog_file12,
3902
+ F: __dxlog_file13,
3753
3903
  L: 107,
3754
3904
  S: this,
3755
3905
  C: (f, a) => f(...a)
@@ -3766,7 +3916,7 @@ var DataSpaceManager = class {
3766
3916
  log10.trace("dxos.echo.data-space-manager.open", trace7.end({
3767
3917
  id: this._instanceId
3768
3918
  }), {
3769
- F: __dxlog_file12,
3919
+ F: __dxlog_file13,
3770
3920
  L: 120,
3771
3921
  S: this,
3772
3922
  C: (f, a) => f(...a)
@@ -3774,7 +3924,7 @@ var DataSpaceManager = class {
3774
3924
  }
3775
3925
  async close() {
3776
3926
  log10("close", void 0, {
3777
- F: __dxlog_file12,
3927
+ F: __dxlog_file13,
3778
3928
  L: 125,
3779
3929
  S: this,
3780
3930
  C: (f, a) => f(...a)
@@ -3789,8 +3939,8 @@ var DataSpaceManager = class {
3789
3939
  * Creates a new space writing the genesis credentials to the control feed.
3790
3940
  */
3791
3941
  async createSpace() {
3792
- invariant11(this._isOpen, "Not open.", {
3793
- F: __dxlog_file12,
3942
+ invariant12(this._isOpen, "Not open.", {
3943
+ F: __dxlog_file13,
3794
3944
  L: 138,
3795
3945
  S: this,
3796
3946
  A: [
@@ -3811,7 +3961,7 @@ var DataSpaceManager = class {
3811
3961
  log10("creating space...", {
3812
3962
  spaceKey
3813
3963
  }, {
3814
- F: __dxlog_file12,
3964
+ F: __dxlog_file13,
3815
3965
  L: 150,
3816
3966
  S: this,
3817
3967
  C: (f, a) => f(...a)
@@ -3826,8 +3976,8 @@ var DataSpaceManager = class {
3826
3976
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3827
3977
  await this._metadataStore.addSpace(metadata);
3828
3978
  const memberCredential = credentials[1];
3829
- invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3830
- F: __dxlog_file12,
3979
+ invariant12(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3980
+ F: __dxlog_file13,
3831
3981
  L: 163,
3832
3982
  S: this,
3833
3983
  A: [
@@ -3845,13 +3995,13 @@ var DataSpaceManager = class {
3845
3995
  log10("accept space", {
3846
3996
  opts
3847
3997
  }, {
3848
- F: __dxlog_file12,
3998
+ F: __dxlog_file13,
3849
3999
  L: 175,
3850
4000
  S: this,
3851
4001
  C: (f, a) => f(...a)
3852
4002
  });
3853
- invariant11(this._isOpen, "Not open.", {
3854
- F: __dxlog_file12,
4003
+ invariant12(this._isOpen, "Not open.", {
4004
+ F: __dxlog_file13,
3855
4005
  L: 176,
3856
4006
  S: this,
3857
4007
  A: [
@@ -3859,8 +4009,8 @@ var DataSpaceManager = class {
3859
4009
  "'Not open.'"
3860
4010
  ]
3861
4011
  });
3862
- invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3863
- F: __dxlog_file12,
4012
+ invariant12(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4013
+ F: __dxlog_file13,
3864
4014
  L: 177,
3865
4015
  S: this,
3866
4016
  A: [
@@ -3895,7 +4045,7 @@ var DataSpaceManager = class {
3895
4045
  log10("construct space", {
3896
4046
  metadata
3897
4047
  }, {
3898
- F: __dxlog_file12,
4048
+ F: __dxlog_file13,
3899
4049
  L: 210,
3900
4050
  S: this,
3901
4051
  C: (f, a) => f(...a)
@@ -3933,7 +4083,7 @@ var DataSpaceManager = class {
3933
4083
  },
3934
4084
  onAuthFailure: () => {
3935
4085
  log10.warn("auth failure", void 0, {
3936
- F: __dxlog_file12,
4086
+ F: __dxlog_file13,
3937
4087
  L: 247,
3938
4088
  S: this,
3939
4089
  C: (f, a) => f(...a)
@@ -3957,7 +4107,7 @@ var DataSpaceManager = class {
3957
4107
  log10("before space ready", {
3958
4108
  space: space.key
3959
4109
  }, {
3960
- F: __dxlog_file12,
4110
+ F: __dxlog_file13,
3961
4111
  L: 265,
3962
4112
  S: this,
3963
4113
  C: (f, a) => f(...a)
@@ -3968,7 +4118,7 @@ var DataSpaceManager = class {
3968
4118
  space: space.key,
3969
4119
  open: this._isOpen
3970
4120
  }, {
3971
- F: __dxlog_file12,
4121
+ F: __dxlog_file13,
3972
4122
  L: 268,
3973
4123
  S: this,
3974
4124
  C: (f, a) => f(...a)
@@ -3981,7 +4131,7 @@ var DataSpaceManager = class {
3981
4131
  log10("before space close", {
3982
4132
  space: space.key
3983
4133
  }, {
3984
- F: __dxlog_file12,
4134
+ F: __dxlog_file13,
3985
4135
  L: 274,
3986
4136
  S: this,
3987
4137
  C: (f, a) => f(...a)
@@ -4021,11 +4171,11 @@ DataSpaceManager = _ts_decorate5([
4021
4171
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
4022
4172
  import { Stream as Stream10 } from "@dxos/codec-protobuf";
4023
4173
  import { raise as raise2 } from "@dxos/debug";
4024
- import { invariant as invariant12 } from "@dxos/invariant";
4174
+ import { invariant as invariant13 } from "@dxos/invariant";
4025
4175
  import { log as log11 } from "@dxos/log";
4026
4176
  import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
4027
- import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4028
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4177
+ import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4178
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4029
4179
  var SpacesServiceImpl = class {
4030
4180
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
4031
4181
  this._identityManager = _identityManager;
@@ -4064,7 +4214,7 @@ var SpacesServiceImpl = class {
4064
4214
  log11("update", {
4065
4215
  spaces
4066
4216
  }, {
4067
- F: __dxlog_file13,
4217
+ F: __dxlog_file14,
4068
4218
  L: 77,
4069
4219
  S: this,
4070
4220
  C: (f, a) => f(...a)
@@ -4146,8 +4296,8 @@ var SpacesServiceImpl = class {
4146
4296
  }
4147
4297
  });
4148
4298
  } else {
4149
- invariant12(!credential.id, "Id on unsigned credentials is not allowed", {
4150
- F: __dxlog_file13,
4299
+ invariant13(!credential.id, "Id on unsigned credentials is not allowed", {
4300
+ F: __dxlog_file14,
4151
4301
  L: 164,
4152
4302
  S: this,
4153
4303
  A: [
@@ -4155,8 +4305,8 @@ var SpacesServiceImpl = class {
4155
4305
  "'Id on unsigned credentials is not allowed'"
4156
4306
  ]
4157
4307
  });
4158
- invariant12(this._identityManager.identity, "Identity is not available", {
4159
- F: __dxlog_file13,
4308
+ invariant13(this._identityManager.identity, "Identity is not available", {
4309
+ F: __dxlog_file14,
4160
4310
  L: 165,
4161
4311
  S: this,
4162
4312
  A: [
@@ -4165,8 +4315,8 @@ var SpacesServiceImpl = class {
4165
4315
  ]
4166
4316
  });
4167
4317
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4168
- invariant12(credential.issuer.equals(signer.getIssuer()), void 0, {
4169
- F: __dxlog_file13,
4318
+ invariant13(credential.issuer.equals(signer.getIssuer()), void 0, {
4319
+ F: __dxlog_file14,
4170
4320
  L: 167,
4171
4321
  S: this,
4172
4322
  A: [
@@ -4222,7 +4372,7 @@ var SpacesServiceImpl = class {
4222
4372
  identityKey: member.key,
4223
4373
  profile: member.profile ?? {}
4224
4374
  },
4225
- presence: member.removed ? SpaceMember2.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember2.PresenceState.ONLINE : SpaceMember2.PresenceState.OFFLINE,
4375
+ presence: member.removed ? SpaceMember3.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
4226
4376
  peerStates: peers
4227
4377
  };
4228
4378
  }),
@@ -4242,11 +4392,11 @@ import { failUndefined as failUndefined2 } from "@dxos/debug";
4242
4392
  import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
4243
4393
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
4244
4394
  import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
4245
- import { invariant as invariant13 } from "@dxos/invariant";
4395
+ import { invariant as invariant14 } from "@dxos/invariant";
4246
4396
  import { Keyring } from "@dxos/keyring";
4247
4397
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4248
4398
  import { log as log12 } from "@dxos/log";
4249
- import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
4399
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace8 } from "@dxos/protocols";
4250
4400
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
4251
4401
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
4252
4402
  import { trace as Trace2 } from "@dxos/tracing";
@@ -4342,7 +4492,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4342
4492
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4343
4493
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4344
4494
  }
4345
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4495
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4346
4496
  var ServiceContext = class extends Resource {
4347
4497
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4348
4498
  super();
@@ -4397,7 +4547,7 @@ var ServiceContext = class extends Resource {
4397
4547
  async _open(ctx) {
4398
4548
  await this._checkStorageVersion();
4399
4549
  log12("opening...", void 0, {
4400
- F: __dxlog_file14,
4550
+ F: __dxlog_file15,
4401
4551
  L: 156,
4402
4552
  S: this,
4403
4553
  C: (f, a) => f(...a)
@@ -4405,7 +4555,7 @@ var ServiceContext = class extends Resource {
4405
4555
  log12.trace("dxos.sdk.service-context.open", trace8.begin({
4406
4556
  id: this._instanceId
4407
4557
  }), {
4408
- F: __dxlog_file14,
4558
+ F: __dxlog_file15,
4409
4559
  L: 157,
4410
4560
  S: this,
4411
4561
  C: (f, a) => f(...a)
@@ -4421,13 +4571,13 @@ var ServiceContext = class extends Resource {
4421
4571
  log12.trace("dxos.sdk.service-context.open", trace8.end({
4422
4572
  id: this._instanceId
4423
4573
  }), {
4424
- F: __dxlog_file14,
4574
+ F: __dxlog_file15,
4425
4575
  L: 167,
4426
4576
  S: this,
4427
4577
  C: (f, a) => f(...a)
4428
4578
  });
4429
4579
  log12("opened", void 0, {
4430
- F: __dxlog_file14,
4580
+ F: __dxlog_file15,
4431
4581
  L: 168,
4432
4582
  S: this,
4433
4583
  C: (f, a) => f(...a)
@@ -4435,7 +4585,7 @@ var ServiceContext = class extends Resource {
4435
4585
  }
4436
4586
  async _close() {
4437
4587
  log12("closing...", void 0, {
4438
- F: __dxlog_file14,
4588
+ F: __dxlog_file15,
4439
4589
  L: 172,
4440
4590
  S: this,
4441
4591
  C: (f, a) => f(...a)
@@ -4453,7 +4603,7 @@ var ServiceContext = class extends Resource {
4453
4603
  await this.metadataStore.close();
4454
4604
  await this.indexer.destroy();
4455
4605
  log12("closed", void 0, {
4456
- F: __dxlog_file14,
4606
+ F: __dxlog_file15,
4457
4607
  L: 185,
4458
4608
  S: this,
4459
4609
  C: (f, a) => f(...a)
@@ -4466,8 +4616,8 @@ var ServiceContext = class extends Resource {
4466
4616
  }
4467
4617
  getInvitationHandler(invitation) {
4468
4618
  const factory = this._handlerFactories.get(invitation.kind);
4469
- invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
4470
- F: __dxlog_file14,
4619
+ invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
4620
+ F: __dxlog_file15,
4471
4621
  L: 196,
4472
4622
  S: this,
4473
4623
  A: [
@@ -4492,14 +4642,14 @@ var ServiceContext = class extends Resource {
4492
4642
  }
4493
4643
  async _checkStorageVersion() {
4494
4644
  await this.metadataStore.load();
4495
- if (this.metadataStore.version !== STORAGE_VERSION) {
4496
- throw new InvalidStorageVersionError(STORAGE_VERSION, this.metadataStore.version);
4645
+ if (this.metadataStore.version !== STORAGE_VERSION2) {
4646
+ throw new InvalidStorageVersionError(STORAGE_VERSION2, this.metadataStore.version);
4497
4647
  }
4498
4648
  }
4499
4649
  // Called when identity is created.
4500
4650
  async _initialize(ctx) {
4501
4651
  log12("initializing spaces...", void 0, {
4502
- F: __dxlog_file14,
4652
+ F: __dxlog_file15,
4503
4653
  L: 227,
4504
4654
  S: this,
4505
4655
  C: (f, a) => f(...a)
@@ -4521,8 +4671,8 @@ var ServiceContext = class extends Resource {
4521
4671
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4522
4672
  await this.dataSpaceManager.open();
4523
4673
  this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
4524
- invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4525
- F: __dxlog_file14,
4674
+ invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4675
+ F: __dxlog_file15,
4526
4676
  L: 251,
4527
4677
  S: this,
4528
4678
  A: [
@@ -4546,7 +4696,7 @@ var ServiceContext = class extends Resource {
4546
4696
  log12("dataSpaceManager not initialized yet, ignoring space admission", {
4547
4697
  details: assertion
4548
4698
  }, {
4549
- F: __dxlog_file14,
4699
+ F: __dxlog_file15,
4550
4700
  L: 267,
4551
4701
  S: this,
4552
4702
  C: (f, a) => f(...a)
@@ -4557,7 +4707,7 @@ var ServiceContext = class extends Resource {
4557
4707
  log12("space already exists, ignoring space admission", {
4558
4708
  details: assertion
4559
4709
  }, {
4560
- F: __dxlog_file14,
4710
+ F: __dxlog_file15,
4561
4711
  L: 271,
4562
4712
  S: this,
4563
4713
  C: (f, a) => f(...a)
@@ -4568,7 +4718,7 @@ var ServiceContext = class extends Resource {
4568
4718
  log12("accepting space recorded in halo", {
4569
4719
  details: assertion
4570
4720
  }, {
4571
- F: __dxlog_file14,
4721
+ F: __dxlog_file15,
4572
4722
  L: 276,
4573
4723
  S: this,
4574
4724
  C: (f, a) => f(...a)
@@ -4579,7 +4729,7 @@ var ServiceContext = class extends Resource {
4579
4729
  });
4580
4730
  } catch (err) {
4581
4731
  log12.catch(err, void 0, {
4582
- F: __dxlog_file14,
4732
+ F: __dxlog_file15,
4583
4733
  L: 282,
4584
4734
  S: this,
4585
4735
  C: (f, a) => f(...a)
@@ -4625,254 +4775,203 @@ var ServiceRegistry = class {
4625
4775
  }
4626
4776
  };
4627
4777
 
4628
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
4629
- import { getFirstStreamValue } from "@dxos/codec-protobuf";
4630
- import { credentialTypeFilter } from "@dxos/credentials";
4631
- import { invariant as invariant14 } from "@dxos/invariant";
4632
- import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
4633
- import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/services";
4634
- import { TRACE_PROCESSOR } from "@dxos/tracing";
4635
-
4636
- // packages/sdk/client-services/src/version.ts
4637
- var DXOS_VERSION = "0.4.10-main.b9b4602";
4638
-
4639
- // packages/sdk/client-services/src/packlets/services/platform.ts
4640
- import { Platform } from "@dxos/protocols/proto/dxos/client/services";
4641
- var getPlatform = () => {
4642
- if (process.browser) {
4643
- if (typeof window !== "undefined") {
4644
- const { userAgent } = window.navigator;
4645
- return {
4646
- type: Platform.PLATFORM_TYPE.BROWSER,
4647
- userAgent,
4648
- uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
4649
- };
4650
- } else {
4651
- return {
4652
- type: Platform.PLATFORM_TYPE.SHARED_WORKER,
4653
- uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
4654
- };
4655
- }
4656
- } else {
4657
- const { platform: platform2, version, arch } = process;
4658
- return {
4659
- type: Platform.PLATFORM_TYPE.NODE,
4660
- platform: platform2,
4661
- arch,
4662
- runtime: version,
4663
- uptime: Math.floor(process.uptime()),
4664
- memory: process.memoryUsage()
4665
- };
4778
+ // packages/sdk/client-services/src/packlets/locks/browser.ts
4779
+ import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
4780
+ import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
4781
+ import { log as log13, logInfo } from "@dxos/log";
4782
+ function _ts_decorate7(decorators, target, key, desc) {
4783
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4784
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4785
+ r = Reflect.decorate(decorators, target, key, desc);
4786
+ else
4787
+ for (var i = decorators.length - 1; i >= 0; i--)
4788
+ if (d = decorators[i])
4789
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4790
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4791
+ }
4792
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
4793
+ var Message;
4794
+ (function(Message2) {
4795
+ Message2["ACQUIRING"] = "acquiring";
4796
+ })(Message || (Message = {}));
4797
+ var Lock = class {
4798
+ constructor({ lockKey, onAcquire, onRelease }) {
4799
+ this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
4800
+ this._releaseTrigger = new Trigger6();
4801
+ this._lockKey = lockKey;
4802
+ this._onAcquire = onAcquire;
4803
+ this._onRelease = onRelease;
4804
+ this._broadcastChannel.onmessage = this._onMessage.bind(this);
4666
4805
  }
4667
- };
4668
-
4669
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
4670
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
4671
- var DEFAULT_TIMEOUT = 1e3;
4672
- var createDiagnostics = async (clientServices, serviceContext, config) => {
4673
- const diagnostics = {
4674
- created: (/* @__PURE__ */ new Date()).toISOString(),
4675
- platform: getPlatform(),
4676
- client: {
4677
- version: DXOS_VERSION,
4678
- storage: {
4679
- version: STORAGE_VERSION2
4680
- }
4681
- },
4682
- trace: TRACE_PROCESSOR.getDiagnostics()
4683
- };
4684
- {
4685
- invariant14(clientServices.LoggingService, "SystemService is not available.", {
4686
- F: __dxlog_file15,
4687
- L: 108,
4688
- S: void 0,
4689
- A: [
4690
- "clientServices.LoggingService",
4691
- "'SystemService is not available.'"
4692
- ]
4693
- });
4694
- diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
4695
- timeout: DEFAULT_TIMEOUT
4696
- }).catch(() => void 0);
4806
+ get lockKey() {
4807
+ return this._lockKey;
4697
4808
  }
4698
- if (typeof navigator !== "undefined" && navigator.storage) {
4699
- const map = /* @__PURE__ */ new Map();
4700
- const dir = await navigator.storage.getDirectory();
4701
- for await (const filename of dir?.keys()) {
4702
- const idx = filename.indexOf("-", filename.indexOf("-") + 1);
4703
- if (idx === -1) {
4704
- continue;
4705
- }
4706
- map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
4809
+ async acquire() {
4810
+ this._broadcastChannel.postMessage({
4811
+ message: "acquiring"
4812
+ });
4813
+ try {
4814
+ log13("aquiring lock...", void 0, {
4815
+ F: __dxlog_file16,
4816
+ L: 42,
4817
+ S: this,
4818
+ C: (f, a) => f(...a)
4819
+ });
4820
+ await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
4821
+ log13("acquired lock", void 0, {
4822
+ F: __dxlog_file16,
4823
+ L: 44,
4824
+ S: this,
4825
+ C: (f, a) => f(...a)
4826
+ });
4827
+ } catch {
4828
+ log13("stealing lock...", void 0, {
4829
+ F: __dxlog_file16,
4830
+ L: 46,
4831
+ S: this,
4832
+ C: (f, a) => f(...a)
4833
+ });
4834
+ await this._requestLock(true);
4835
+ log13("stolen lock", void 0, {
4836
+ F: __dxlog_file16,
4837
+ L: 48,
4838
+ S: this,
4839
+ C: (f, a) => f(...a)
4840
+ });
4707
4841
  }
4708
- diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
4709
- file,
4710
- count
4711
- }));
4712
4842
  }
4713
- const identity = serviceContext.identityManager.identity;
4714
- if (identity) {
4715
- diagnostics.identity = {
4716
- identityKey: identity.identityKey,
4717
- spaceKey: identity.space.key,
4718
- profile: identity.profileDocument
4719
- };
4720
- const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
4721
- timeout: DEFAULT_TIMEOUT
4722
- }).catch(() => void 0) ?? {};
4723
- diagnostics.devices = devices;
4724
- if (serviceContext.dataSpaceManager) {
4725
- diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
4726
- }
4727
- const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
4728
- timeout: DEFAULT_TIMEOUT
4729
- }).catch(() => void 0) ?? {};
4730
- diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
4731
- feedKey,
4732
- bytes,
4733
- length
4734
- }));
4735
- const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
4736
- timeout: DEFAULT_TIMEOUT
4737
- }).catch(() => void 0);
4738
- diagnostics.networkStatus = status;
4739
- diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
4843
+ async release() {
4844
+ this._releaseTrigger.wake();
4740
4845
  }
4741
- diagnostics.config = config.values;
4742
- return diagnostics;
4743
- };
4744
- var getSpaceStats = async (space) => {
4745
- const stats = {
4746
- key: space.key,
4747
- metrics: space.metrics,
4748
- epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
4749
- ...credential.subject.assertion,
4750
- id: credential.id
4751
- })),
4752
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
4753
- identity: {
4754
- identityKey: member.key,
4755
- profile: {
4756
- displayName: member.assertion.profile?.displayName
4757
- }
4758
- },
4759
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE
4760
- })),
4761
- pipeline: {
4762
- // TODO(burdon): Pick properties from credentials if needed.
4763
- currentEpoch: space.automergeSpaceState.lastEpoch,
4764
- appliedEpoch: space.automergeSpaceState.lastEpoch,
4765
- controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
4766
- currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
4767
- targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
4768
- totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
4846
+ _onMessage(event) {
4847
+ if (event.data.message === "acquiring") {
4848
+ this._releaseTrigger.wake();
4769
4849
  }
4770
- };
4771
- if (stats.metrics) {
4772
- const { open, ready } = stats.metrics;
4773
- stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
4774
4850
  }
4775
- return stats;
4851
+ async _requestLock(steal = false) {
4852
+ log13("requesting lock...", {
4853
+ steal
4854
+ }, {
4855
+ F: __dxlog_file16,
4856
+ L: 63,
4857
+ S: this,
4858
+ C: (f, a) => f(...a)
4859
+ });
4860
+ const acquired = new Trigger6();
4861
+ void navigator.locks.request(this._lockKey, {
4862
+ steal
4863
+ }, async () => {
4864
+ await this._onAcquire?.();
4865
+ acquired.wake();
4866
+ this._releaseTrigger = new Trigger6();
4867
+ await this._releaseTrigger.wait();
4868
+ log13("releasing lock...", void 0, {
4869
+ F: __dxlog_file16,
4870
+ L: 72,
4871
+ S: this,
4872
+ C: (f, a) => f(...a)
4873
+ });
4874
+ await this._onRelease?.();
4875
+ log13("released lock", void 0, {
4876
+ F: __dxlog_file16,
4877
+ L: 74,
4878
+ S: this,
4879
+ C: (f, a) => f(...a)
4880
+ });
4881
+ }).catch(async () => {
4882
+ await this._onRelease?.();
4883
+ });
4884
+ await acquired.wait();
4885
+ log13("recieved lock", {
4886
+ steal
4887
+ }, {
4888
+ F: __dxlog_file16,
4889
+ L: 81,
4890
+ S: this,
4891
+ C: (f, a) => f(...a)
4892
+ });
4893
+ }
4894
+ };
4895
+ _ts_decorate7([
4896
+ logInfo
4897
+ ], Lock.prototype, "lockKey", null);
4898
+ var isLocked = (lockPath) => {
4899
+ throw new Error("Not implemented");
4776
4900
  };
4777
4901
 
4778
- // packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
4779
- import { Trigger as Trigger6 } from "@dxos/async";
4780
- import { log as log13 } from "@dxos/log";
4781
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
4782
- var CHANNEL_NAME = "dxos.diagnostics.broadcast";
4783
- var MessageType;
4784
- (function(MessageType2) {
4785
- MessageType2["PROBE"] = "probe";
4786
- MessageType2["PROBE_ACK"] = "probe-ack";
4787
- MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
4788
- MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
4789
- })(MessageType || (MessageType = {}));
4790
- var createCollectDiagnosticsBroadcastSender = () => {
4791
- return {
4792
- broadcastDiagnosticsRequest: async () => {
4793
- let expectedResponse = "probe-ack";
4794
- let channel;
4795
- try {
4796
- const trigger = new Trigger6();
4797
- channel = new BroadcastChannel(CHANNEL_NAME);
4798
- channel.onmessage = (msg) => {
4799
- if (expectedResponse === msg.data.type) {
4800
- trigger.wake(msg.data);
4801
- }
4802
- };
4803
- channel.postMessage({
4804
- type: "probe"
4805
- });
4806
- await trigger.wait({
4807
- timeout: 200
4808
- });
4809
- expectedResponse = "receive-diagnostics";
4810
- trigger.reset();
4811
- channel.postMessage({
4812
- type: "request-diagnostics"
4813
- });
4814
- const diagnostics = await trigger.wait({
4815
- timeout: 5e3
4816
- });
4817
- return diagnostics.payload;
4818
- } catch (e) {
4819
- const errorDescription = e instanceof Error ? e.message : JSON.stringify(e);
4820
- return {
4821
- expectedResponse,
4822
- errorDescription
4823
- };
4824
- } finally {
4825
- safeClose(channel);
4826
- }
4827
- }
4828
- };
4902
+ // packages/sdk/client-services/src/packlets/storage/storage.ts
4903
+ import { InvalidConfigError } from "@dxos/protocols";
4904
+ import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
4905
+ import { createStorage, StorageType } from "@dxos/random-access-storage";
4906
+
4907
+ // packages/sdk/client-services/src/packlets/storage/util.ts
4908
+ import { DX_DATA } from "@dxos/client-protocol";
4909
+ import { Runtime } from "@dxos/protocols/proto/dxos/config";
4910
+ import { isNode as isNode2 } from "@dxos/util";
4911
+ var getRootPath = (config) => {
4912
+ const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
4913
+ return `${dataRoot}/`;
4914
+ };
4915
+ var isPersistent = (config) => {
4916
+ const { persistent = false } = config ?? {};
4917
+ return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
4829
4918
  };
4830
- var createCollectDiagnosticsBroadcastHandler = (systemService) => {
4831
- let channel;
4919
+
4920
+ // packages/sdk/client-services/src/packlets/storage/storage.ts
4921
+ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
4922
+ var createStorageObjects = (config) => {
4923
+ const { persistent = false, keyStore, dataStore } = config ?? {};
4924
+ if (persistent && dataStore === StorageDriver.RAM) {
4925
+ throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
4926
+ }
4927
+ if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
4928
+ throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
4929
+ }
4930
+ if (persistent && keyStore === StorageDriver.RAM) {
4931
+ throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
4932
+ }
4933
+ if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
4934
+ throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
4935
+ }
4832
4936
  return {
4833
- start: () => {
4834
- channel = new BroadcastChannel(CHANNEL_NAME);
4835
- channel.onmessage = async (message) => {
4836
- try {
4837
- if (message.data.type === "probe") {
4838
- channel?.postMessage({
4839
- type: "probe-ack"
4840
- });
4841
- } else if (message.data.type === "request-diagnostics") {
4842
- const diagnostics = await systemService.getDiagnostics({});
4843
- channel?.postMessage({
4844
- type: "receive-diagnostics",
4845
- payload: diagnostics
4846
- });
4847
- }
4848
- } catch (error) {
4849
- log13.catch(error, void 0, {
4850
- F: __dxlog_file16,
4851
- L: 77,
4852
- S: void 0,
4853
- C: (f, a) => f(...a)
4854
- });
4855
- }
4856
- };
4857
- },
4858
- stop: () => {
4859
- safeClose(channel);
4860
- channel = void 0;
4861
- }
4937
+ storage: createStorage({
4938
+ type: persistent ? toStorageType(dataStore) : StorageType.RAM,
4939
+ root: getRootPath(config)
4940
+ })
4862
4941
  };
4863
4942
  };
4864
- var safeClose = (channel) => {
4865
- try {
4866
- channel?.close();
4867
- } catch (e) {
4943
+ var toStorageType = (type) => {
4944
+ switch (type) {
4945
+ case void 0:
4946
+ return void 0;
4947
+ case StorageDriver.RAM:
4948
+ return StorageType.RAM;
4949
+ case StorageDriver.CHROME:
4950
+ return StorageType.CHROME;
4951
+ case StorageDriver.FIREFOX:
4952
+ return StorageType.FIREFOX;
4953
+ case StorageDriver.IDB:
4954
+ return StorageType.IDB;
4955
+ case StorageDriver.NODE:
4956
+ return StorageType.NODE;
4957
+ case StorageDriver.WEBFS:
4958
+ return StorageType.WEBFS;
4959
+ default:
4960
+ throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4868
4961
  }
4869
4962
  };
4870
4963
 
4871
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
4872
- import { ConfigResource } from "@dxos/config";
4873
- import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
4874
- import { TRACE_PROCESSOR as TRACE_PROCESSOR3 } from "@dxos/tracing";
4875
- import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
4964
+ // packages/sdk/client-services/src/packlets/storage/level.ts
4965
+ import { Level } from "level";
4966
+ import path from "@dxos/node-std/path";
4967
+ import { PublicKey as PublicKey11 } from "@dxos/keys";
4968
+ var createLevel = async (config) => {
4969
+ const persistent = isPersistent(config);
4970
+ const storagePath = persistent ? getRootPath(config) : path.join("tmp", "level", PublicKey11.random().toHex());
4971
+ const level = new Level(storagePath);
4972
+ await level.open();
4973
+ return level;
4974
+ };
4876
4975
 
4877
4976
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4878
4977
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
@@ -4883,7 +4982,7 @@ import * as E from "@dxos/echo-schema";
4883
4982
  import { IndexServiceImpl } from "@dxos/indexing";
4884
4983
  import { invariant as invariant16 } from "@dxos/invariant";
4885
4984
  import { PublicKey as PublicKey13 } from "@dxos/keys";
4886
- import { log as log16 } from "@dxos/log";
4985
+ import { log as log15 } from "@dxos/log";
4887
4986
  import { WebsocketSignalManager } from "@dxos/messaging";
4888
4987
  import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
4889
4988
  import { trace as trace9 } from "@dxos/protocols";
@@ -4974,152 +5073,28 @@ var DevicesServiceImpl = class {
4974
5073
  }
4975
5074
  };
4976
5075
 
4977
- // packages/sdk/client-services/src/packlets/locks/browser.ts
4978
- import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
4979
- import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
4980
- import { log as log14, logInfo } from "@dxos/log";
4981
- function _ts_decorate7(decorators, target, key, desc) {
4982
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4983
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4984
- r = Reflect.decorate(decorators, target, key, desc);
4985
- else
4986
- for (var i = decorators.length - 1; i >= 0; i--)
4987
- if (d = decorators[i])
4988
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4989
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4990
- }
4991
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
4992
- var Message;
4993
- (function(Message2) {
4994
- Message2["ACQUIRING"] = "acquiring";
4995
- })(Message || (Message = {}));
4996
- var Lock = class {
4997
- constructor({ lockKey, onAcquire, onRelease }) {
4998
- this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
4999
- this._releaseTrigger = new Trigger7();
5000
- this._lockKey = lockKey;
5001
- this._onAcquire = onAcquire;
5002
- this._onRelease = onRelease;
5003
- this._broadcastChannel.onmessage = this._onMessage.bind(this);
5004
- }
5005
- get lockKey() {
5006
- return this._lockKey;
5007
- }
5008
- async acquire() {
5009
- this._broadcastChannel.postMessage({
5010
- message: "acquiring"
5011
- });
5012
- try {
5013
- log14("aquiring lock...", void 0, {
5014
- F: __dxlog_file18,
5015
- L: 42,
5016
- S: this,
5017
- C: (f, a) => f(...a)
5018
- });
5019
- await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
5020
- log14("acquired lock", void 0, {
5021
- F: __dxlog_file18,
5022
- L: 44,
5023
- S: this,
5024
- C: (f, a) => f(...a)
5025
- });
5026
- } catch {
5027
- log14("stealing lock...", void 0, {
5028
- F: __dxlog_file18,
5029
- L: 46,
5030
- S: this,
5031
- C: (f, a) => f(...a)
5032
- });
5033
- await this._requestLock(true);
5034
- log14("stolen lock", void 0, {
5035
- F: __dxlog_file18,
5036
- L: 48,
5037
- S: this,
5038
- C: (f, a) => f(...a)
5039
- });
5040
- }
5041
- }
5042
- async release() {
5043
- this._releaseTrigger.wake();
5044
- }
5045
- _onMessage(event) {
5046
- if (event.data.message === "acquiring") {
5047
- this._releaseTrigger.wake();
5048
- }
5049
- }
5050
- async _requestLock(steal = false) {
5051
- log14("requesting lock...", {
5052
- steal
5053
- }, {
5054
- F: __dxlog_file18,
5055
- L: 63,
5056
- S: this,
5057
- C: (f, a) => f(...a)
5058
- });
5059
- const acquired = new Trigger7();
5060
- void navigator.locks.request(this._lockKey, {
5061
- steal
5062
- }, async () => {
5063
- await this._onAcquire?.();
5064
- acquired.wake();
5065
- this._releaseTrigger = new Trigger7();
5066
- await this._releaseTrigger.wait();
5067
- log14("releasing lock...", void 0, {
5068
- F: __dxlog_file18,
5069
- L: 72,
5070
- S: this,
5071
- C: (f, a) => f(...a)
5072
- });
5073
- await this._onRelease?.();
5074
- log14("released lock", void 0, {
5075
- F: __dxlog_file18,
5076
- L: 74,
5077
- S: this,
5078
- C: (f, a) => f(...a)
5079
- });
5080
- }).catch(async () => {
5081
- await this._onRelease?.();
5082
- });
5083
- await acquired.wait();
5084
- log14("recieved lock", {
5085
- steal
5086
- }, {
5087
- F: __dxlog_file18,
5088
- L: 81,
5089
- S: this,
5090
- C: (f, a) => f(...a)
5091
- });
5092
- }
5093
- };
5094
- _ts_decorate7([
5095
- logInfo
5096
- ], Lock.prototype, "lockKey", null);
5097
- var isLocked = (lockPath) => {
5098
- throw new Error("Not implemented");
5099
- };
5100
-
5101
5076
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
5102
5077
  import { Event as Event8 } from "@dxos/async";
5103
5078
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
5104
- import { PublicKey as PublicKey11 } from "@dxos/keys";
5105
- import { getContextFromEntry, log as log15 } from "@dxos/log";
5079
+ import { PublicKey as PublicKey12 } from "@dxos/keys";
5080
+ import { getContextFromEntry, log as log14 } from "@dxos/log";
5106
5081
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
5107
5082
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
5108
5083
  var LoggingServiceImpl = class {
5109
5084
  constructor() {
5110
5085
  this._logs = new Event8();
5111
5086
  this._started = Date.now();
5112
- this._sessionId = PublicKey11.random().toHex();
5087
+ this._sessionId = PublicKey12.random().toHex();
5113
5088
  this._logProcessor = (_config, entry2) => {
5114
5089
  this._logs.emit(entry2);
5115
5090
  };
5116
5091
  }
5117
5092
  async open() {
5118
- log15.runtimeConfig.processors.push(this._logProcessor);
5093
+ log14.runtimeConfig.processors.push(this._logProcessor);
5119
5094
  }
5120
5095
  async close() {
5121
- const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
5122
- log15.runtimeConfig.processors.splice(index, 1);
5096
+ const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
5097
+ log14.runtimeConfig.processors.splice(index, 1);
5123
5098
  }
5124
5099
  async controlMetrics({ reset, record }) {
5125
5100
  if (reset) {
@@ -5255,80 +5230,6 @@ var NetworkServiceImpl = class {
5255
5230
  }
5256
5231
  };
5257
5232
 
5258
- // packages/sdk/client-services/src/packlets/storage/storage.ts
5259
- import { InvalidConfigError } from "@dxos/protocols";
5260
- import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
5261
- import { createStorage, StorageType } from "@dxos/random-access-storage";
5262
-
5263
- // packages/sdk/client-services/src/packlets/storage/util.ts
5264
- import { DX_DATA } from "@dxos/client-protocol";
5265
- import { Runtime } from "@dxos/protocols/proto/dxos/config";
5266
- import { isNode as isNode2 } from "@dxos/util";
5267
- var getRootPath = (config) => {
5268
- const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
5269
- return `${dataRoot}/`;
5270
- };
5271
- var isPersistent = (config) => {
5272
- const { persistent = false } = config ?? {};
5273
- return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
5274
- };
5275
-
5276
- // packages/sdk/client-services/src/packlets/storage/storage.ts
5277
- var StorageDriver = Runtime2.Client.Storage.StorageDriver;
5278
- var createStorageObjects = (config) => {
5279
- const { persistent = false, keyStore, dataStore } = config ?? {};
5280
- if (persistent && dataStore === StorageDriver.RAM) {
5281
- throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
5282
- }
5283
- if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
5284
- throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
5285
- }
5286
- if (persistent && keyStore === StorageDriver.RAM) {
5287
- throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
5288
- }
5289
- if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
5290
- throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
5291
- }
5292
- return {
5293
- storage: createStorage({
5294
- type: persistent ? toStorageType(dataStore) : StorageType.RAM,
5295
- root: getRootPath(config)
5296
- })
5297
- };
5298
- };
5299
- var toStorageType = (type) => {
5300
- switch (type) {
5301
- case void 0:
5302
- return void 0;
5303
- case StorageDriver.RAM:
5304
- return StorageType.RAM;
5305
- case StorageDriver.CHROME:
5306
- return StorageType.CHROME;
5307
- case StorageDriver.FIREFOX:
5308
- return StorageType.FIREFOX;
5309
- case StorageDriver.IDB:
5310
- return StorageType.IDB;
5311
- case StorageDriver.NODE:
5312
- return StorageType.NODE;
5313
- case StorageDriver.WEBFS:
5314
- return StorageType.WEBFS;
5315
- default:
5316
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
5317
- }
5318
- };
5319
-
5320
- // packages/sdk/client-services/src/packlets/storage/level.ts
5321
- import { Level } from "level";
5322
- import path from "@dxos/node-std/path";
5323
- import { PublicKey as PublicKey12 } from "@dxos/keys";
5324
- var createLevel = async (config) => {
5325
- const persistent = isPersistent(config);
5326
- const storagePath = persistent ? getRootPath(config) : path.join("tmp", "level", PublicKey12.random().toHex());
5327
- const level = new Level(storagePath);
5328
- await level.open();
5329
- return level;
5330
- };
5331
-
5332
5233
  // packages/sdk/client-services/src/packlets/system/system-service.ts
5333
5234
  import { Stream as Stream14 } from "@dxos/codec-protobuf";
5334
5235
  import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
@@ -5397,7 +5298,7 @@ function _ts_decorate8(decorators, target, key, desc) {
5397
5298
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5398
5299
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5399
5300
  }
5400
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
5301
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
5401
5302
  var ClientServicesHost = class {
5402
5303
  constructor({
5403
5304
  config,
@@ -5452,7 +5353,6 @@ var ClientServicesHost = class {
5452
5353
  await this.reset();
5453
5354
  }
5454
5355
  });
5455
- this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
5456
5356
  this._loggingService = new LoggingServiceImpl();
5457
5357
  this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
5458
5358
  SystemService: this._systemService,
@@ -5484,24 +5384,24 @@ var ClientServicesHost = class {
5484
5384
  */
5485
5385
  initialize({ config, ...options }) {
5486
5386
  invariant16(!this._open, "service host is open", {
5487
- F: __dxlog_file19,
5488
- L: 188,
5387
+ F: __dxlog_file18,
5388
+ L: 182,
5489
5389
  S: this,
5490
5390
  A: [
5491
5391
  "!this._open",
5492
5392
  "'service host is open'"
5493
5393
  ]
5494
5394
  });
5495
- log16("initializing...", void 0, {
5496
- F: __dxlog_file19,
5497
- L: 189,
5395
+ log15("initializing...", void 0, {
5396
+ F: __dxlog_file18,
5397
+ L: 183,
5498
5398
  S: this,
5499
5399
  C: (f, a) => f(...a)
5500
5400
  });
5501
5401
  if (config) {
5502
5402
  invariant16(!this._config, "config already set", {
5503
- F: __dxlog_file19,
5504
- L: 192,
5403
+ F: __dxlog_file18,
5404
+ L: 186,
5505
5405
  S: this,
5506
5406
  A: [
5507
5407
  "!this._config",
@@ -5514,9 +5414,9 @@ var ClientServicesHost = class {
5514
5414
  }
5515
5415
  }
5516
5416
  if (!options.signalManager) {
5517
- log16.warn("running signaling without telemetry metadata.", void 0, {
5518
- F: __dxlog_file19,
5519
- L: 200,
5417
+ log15.warn("running signaling without telemetry metadata.", void 0, {
5418
+ F: __dxlog_file18,
5419
+ L: 194,
5520
5420
  S: this,
5521
5421
  C: (f, a) => f(...a)
5522
5422
  });
@@ -5526,8 +5426,8 @@ var ClientServicesHost = class {
5526
5426
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5527
5427
  this._signalManager = signalManager;
5528
5428
  invariant16(!this._networkManager, "network manager already set", {
5529
- F: __dxlog_file19,
5530
- L: 211,
5429
+ F: __dxlog_file18,
5430
+ L: 205,
5531
5431
  S: this,
5532
5432
  A: [
5533
5433
  "!this._networkManager",
@@ -5539,9 +5439,9 @@ var ClientServicesHost = class {
5539
5439
  transportFactory,
5540
5440
  signalManager
5541
5441
  });
5542
- log16("initialized", void 0, {
5543
- F: __dxlog_file19,
5544
- L: 218,
5442
+ log15("initialized", void 0, {
5443
+ F: __dxlog_file18,
5444
+ L: 212,
5545
5445
  S: this,
5546
5446
  C: (f, a) => f(...a)
5547
5447
  });
@@ -5551,17 +5451,17 @@ var ClientServicesHost = class {
5551
5451
  return;
5552
5452
  }
5553
5453
  const traceId = PublicKey13.random().toHex();
5554
- log16.trace("dxos.client-services.host.open", trace9.begin({
5454
+ log15.trace("dxos.client-services.host.open", trace9.begin({
5555
5455
  id: traceId
5556
5456
  }), {
5557
- F: __dxlog_file19,
5558
- L: 229,
5457
+ F: __dxlog_file18,
5458
+ L: 223,
5559
5459
  S: this,
5560
5460
  C: (f, a) => f(...a)
5561
5461
  });
5562
5462
  invariant16(this._config, "config not set", {
5563
- F: __dxlog_file19,
5564
- L: 231,
5463
+ F: __dxlog_file18,
5464
+ L: 225,
5565
5465
  S: this,
5566
5466
  A: [
5567
5467
  "this._config",
@@ -5569,8 +5469,8 @@ var ClientServicesHost = class {
5569
5469
  ]
5570
5470
  });
5571
5471
  invariant16(this._storage, "storage not set", {
5572
- F: __dxlog_file19,
5573
- L: 232,
5472
+ F: __dxlog_file18,
5473
+ L: 226,
5574
5474
  S: this,
5575
5475
  A: [
5576
5476
  "this._storage",
@@ -5578,8 +5478,8 @@ var ClientServicesHost = class {
5578
5478
  ]
5579
5479
  });
5580
5480
  invariant16(this._signalManager, "signal manager not set", {
5581
- F: __dxlog_file19,
5582
- L: 233,
5481
+ F: __dxlog_file18,
5482
+ L: 227,
5583
5483
  S: this,
5584
5484
  A: [
5585
5485
  "this._signalManager",
@@ -5587,8 +5487,8 @@ var ClientServicesHost = class {
5587
5487
  ]
5588
5488
  });
5589
5489
  invariant16(this._networkManager, "network manager not set", {
5590
- F: __dxlog_file19,
5591
- L: 234,
5490
+ F: __dxlog_file18,
5491
+ L: 228,
5592
5492
  S: this,
5593
5493
  A: [
5594
5494
  "this._networkManager",
@@ -5596,11 +5496,11 @@ var ClientServicesHost = class {
5596
5496
  ]
5597
5497
  });
5598
5498
  this._opening = true;
5599
- log16("opening...", {
5499
+ log15("opening...", {
5600
5500
  lockKey: this._resourceLock?.lockKey
5601
5501
  }, {
5602
- F: __dxlog_file19,
5603
- L: 237,
5502
+ F: __dxlog_file18,
5503
+ L: 231,
5604
5504
  S: this,
5605
5505
  C: (f, a) => f(...a)
5606
5506
  });
@@ -5636,8 +5536,8 @@ var ClientServicesHost = class {
5636
5536
  });
5637
5537
  await this._serviceContext.open(ctx);
5638
5538
  invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
5639
- F: __dxlog_file19,
5640
- L: 303,
5539
+ F: __dxlog_file18,
5540
+ L: 297,
5641
5541
  S: this,
5642
5542
  A: [
5643
5543
  "this.serviceRegistry.services.InvitationsService",
@@ -5645,11 +5545,11 @@ var ClientServicesHost = class {
5645
5545
  ]
5646
5546
  });
5647
5547
  const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
5648
- log16("loaded persistent invitations", {
5548
+ log15("loaded persistent invitations", {
5649
5549
  count: loadedInvitations.invitations?.length
5650
5550
  }, {
5651
- F: __dxlog_file19,
5652
- L: 306,
5551
+ F: __dxlog_file18,
5552
+ L: 300,
5653
5553
  S: this,
5654
5554
  C: (f, a) => f(...a)
5655
5555
  });
@@ -5663,24 +5563,23 @@ var ClientServicesHost = class {
5663
5563
  });
5664
5564
  void this._devtoolsProxy.open();
5665
5565
  }
5666
- this.diagnosticsBroadcastHandler.start();
5667
5566
  this._opening = false;
5668
5567
  this._open = true;
5669
5568
  this._statusUpdate.emit();
5670
5569
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5671
- log16("opened", {
5570
+ log15("opened", {
5672
5571
  deviceKey
5673
5572
  }, {
5674
- F: __dxlog_file19,
5675
- L: 324,
5573
+ F: __dxlog_file18,
5574
+ L: 317,
5676
5575
  S: this,
5677
5576
  C: (f, a) => f(...a)
5678
5577
  });
5679
- log16.trace("dxos.client-services.host.open", trace9.end({
5578
+ log15.trace("dxos.client-services.host.open", trace9.end({
5680
5579
  id: traceId
5681
5580
  }), {
5682
- F: __dxlog_file19,
5683
- L: 325,
5581
+ F: __dxlog_file18,
5582
+ L: 318,
5684
5583
  S: this,
5685
5584
  C: (f, a) => f(...a)
5686
5585
  });
@@ -5690,15 +5589,14 @@ var ClientServicesHost = class {
5690
5589
  return;
5691
5590
  }
5692
5591
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5693
- log16("closing...", {
5592
+ log15("closing...", {
5694
5593
  deviceKey
5695
5594
  }, {
5696
- F: __dxlog_file19,
5697
- L: 336,
5595
+ F: __dxlog_file18,
5596
+ L: 329,
5698
5597
  S: this,
5699
5598
  C: (f, a) => f(...a)
5700
5599
  });
5701
- this.diagnosticsBroadcastHandler.stop();
5702
5600
  await this._devtoolsProxy?.close();
5703
5601
  this._serviceRegistry.setServices({
5704
5602
  SystemService: this._systemService
@@ -5708,44 +5606,44 @@ var ClientServicesHost = class {
5708
5606
  await this._level?.close();
5709
5607
  this._open = false;
5710
5608
  this._statusUpdate.emit();
5711
- log16("closed", {
5609
+ log15("closed", {
5712
5610
  deviceKey
5713
5611
  }, {
5714
- F: __dxlog_file19,
5715
- L: 345,
5612
+ F: __dxlog_file18,
5613
+ L: 337,
5716
5614
  S: this,
5717
5615
  C: (f, a) => f(...a)
5718
5616
  });
5719
5617
  }
5720
5618
  async reset() {
5721
5619
  const traceId = PublicKey13.random().toHex();
5722
- log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
5620
+ log15.trace("dxos.sdk.client-services-host.reset", trace9.begin({
5723
5621
  id: traceId
5724
5622
  }), {
5725
- F: __dxlog_file19,
5726
- L: 350,
5623
+ F: __dxlog_file18,
5624
+ L: 342,
5727
5625
  S: this,
5728
5626
  C: (f, a) => f(...a)
5729
5627
  });
5730
- log16("resetting...", void 0, {
5731
- F: __dxlog_file19,
5732
- L: 352,
5628
+ log15("resetting...", void 0, {
5629
+ F: __dxlog_file18,
5630
+ L: 344,
5733
5631
  S: this,
5734
5632
  C: (f, a) => f(...a)
5735
5633
  });
5736
5634
  await this._serviceContext?.close();
5737
5635
  await this._storage.reset();
5738
- log16("reset", void 0, {
5739
- F: __dxlog_file19,
5740
- L: 355,
5636
+ log15("reset", void 0, {
5637
+ F: __dxlog_file18,
5638
+ L: 347,
5741
5639
  S: this,
5742
5640
  C: (f, a) => f(...a)
5743
5641
  });
5744
- log16.trace("dxos.sdk.client-services-host.reset", trace9.end({
5642
+ log15.trace("dxos.sdk.client-services-host.reset", trace9.end({
5745
5643
  id: traceId
5746
5644
  }), {
5747
- F: __dxlog_file19,
5748
- L: 356,
5645
+ F: __dxlog_file18,
5646
+ L: 348,
5749
5647
  S: this,
5750
5648
  C: (f, a) => f(...a)
5751
5649
  });
@@ -5757,8 +5655,8 @@ var ClientServicesHost = class {
5757
5655
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5758
5656
  const automergeIndex = space.automergeSpaceState.rootUrl;
5759
5657
  invariant16(automergeIndex, void 0, {
5760
- F: __dxlog_file19,
5761
- L: 368,
5658
+ F: __dxlog_file18,
5659
+ L: 360,
5762
5660
  S: this,
5763
5661
  A: [
5764
5662
  "automergeIndex",
@@ -5807,44 +5705,6 @@ ClientServicesHost = _ts_decorate8([
5807
5705
  Trace3.resource()
5808
5706
  ], ClientServicesHost);
5809
5707
 
5810
- // packages/sdk/client-services/src/packlets/services/util.ts
5811
- import { PublicKey as PublicKey14 } from "@dxos/keys";
5812
- import { humanize } from "@dxos/util";
5813
- var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
5814
-
5815
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
5816
- var DiagnosticsCollector = class {
5817
- static {
5818
- this.broadcastSender = createCollectDiagnosticsBroadcastSender();
5819
- }
5820
- static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5821
- const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5822
- keys: options.humanize ? GetDiagnosticsRequest2.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest2.KEY_OPTION.TRUNCATE : void 0
5823
- });
5824
- const clientDiagnostics = {
5825
- config,
5826
- trace: TRACE_PROCESSOR3.getDiagnostics()
5827
- };
5828
- const diagnostics = serviceDiagnostics != null ? {
5829
- client: clientDiagnostics,
5830
- services: serviceDiagnostics
5831
- } : {
5832
- client: clientDiagnostics,
5833
- broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
5834
- };
5835
- return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer2(options)));
5836
- }
5837
- };
5838
- var findSystemServiceProvider = () => {
5839
- const serviceProviders = TRACE_PROCESSOR3.findByAnnotation(ClientServicesProviderResource);
5840
- const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
5841
- return providerResource?.instance?.deref() ?? null;
5842
- };
5843
- var findConfigs = () => {
5844
- const configs = TRACE_PROCESSOR3.findByAnnotation(ConfigResource);
5845
- return configs.map((r) => r.instance.deref()).filter(nonNullable);
5846
- };
5847
-
5848
5708
  export {
5849
5709
  Buffer,
5850
5710
  subscribeToFeeds,
@@ -5868,20 +5728,16 @@ export {
5868
5728
  InvitationsServiceImpl,
5869
5729
  SpaceInvitationProtocol,
5870
5730
  ClientRpcServer,
5731
+ createDiagnostics,
5871
5732
  DataSpace,
5872
5733
  DataSpaceManager,
5873
5734
  SpacesServiceImpl,
5874
5735
  ServiceContext,
5875
5736
  ServiceRegistry,
5876
- createDiagnostics,
5877
- createCollectDiagnosticsBroadcastSender,
5878
- createCollectDiagnosticsBroadcastHandler,
5879
- DiagnosticsCollector,
5880
5737
  Lock,
5881
5738
  isLocked,
5882
5739
  createStorageObjects,
5883
5740
  createLevel,
5884
- ClientServicesHost,
5885
- ClientServicesProviderResource
5741
+ ClientServicesHost
5886
5742
  };
5887
- //# sourceMappingURL=chunk-TPPBOJTA.mjs.map
5743
+ //# sourceMappingURL=chunk-KI2OUJI3.mjs.map