@dxos/client-services 0.4.10-main.c2d5db5 → 0.4.10-main.c42bfdb
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.
- package/dist/lib/browser/{chunk-KI2OUJI3.mjs → chunk-W7UANCHR.mjs} +643 -499
- package/dist/lib/browser/chunk-W7UANCHR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +9 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-Z42MXXA4.cjs → chunk-JSVLZGJM.cjs} +590 -528
- package/dist/lib/node/chunk-JSVLZGJM.cjs.map +7 -0
- package/dist/lib/node/index.cjs +46 -38
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +6 -6
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -34
- package/src/index.ts +1 -0
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-host.ts +9 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-KI2OUJI3.mjs.map +0 -7
- package/dist/lib/node/chunk-Z42MXXA4.cjs.map +0 -7
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
|
@@ -2730,156 +2730,6 @@ 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
|
-
|
|
2883
2733
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2884
2734
|
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2885
2735
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
@@ -2888,7 +2738,7 @@ import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
|
2888
2738
|
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2889
2739
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2890
2740
|
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2891
|
-
import { failedInvariant, invariant as
|
|
2741
|
+
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2892
2742
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2893
2743
|
import { log as log9 } from "@dxos/log";
|
|
2894
2744
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -2939,13 +2789,13 @@ var AutomergeSpaceState = class {
|
|
|
2939
2789
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2940
2790
|
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2941
2791
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2942
|
-
import { invariant as
|
|
2792
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2943
2793
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2944
2794
|
import { log as log8 } from "@dxos/log";
|
|
2945
2795
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2946
2796
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2947
2797
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
2948
|
-
var
|
|
2798
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2949
2799
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2950
2800
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2951
2801
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2973,13 +2823,13 @@ var NotarizationPlugin = class {
|
|
|
2973
2823
|
log8("notarize", {
|
|
2974
2824
|
credentials
|
|
2975
2825
|
}, {
|
|
2976
|
-
F:
|
|
2826
|
+
F: __dxlog_file10,
|
|
2977
2827
|
L: 90,
|
|
2978
2828
|
S: this,
|
|
2979
2829
|
C: (f, a) => f(...a)
|
|
2980
2830
|
});
|
|
2981
|
-
|
|
2982
|
-
F:
|
|
2831
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2832
|
+
F: __dxlog_file10,
|
|
2983
2833
|
L: 91,
|
|
2984
2834
|
S: this,
|
|
2985
2835
|
A: [
|
|
@@ -2993,7 +2843,7 @@ var NotarizationPlugin = class {
|
|
|
2993
2843
|
log8.warn("Notarization error", {
|
|
2994
2844
|
err
|
|
2995
2845
|
}, {
|
|
2996
|
-
F:
|
|
2846
|
+
F: __dxlog_file10,
|
|
2997
2847
|
L: 99,
|
|
2998
2848
|
S: this,
|
|
2999
2849
|
C: (f, a) => f(...a)
|
|
@@ -3009,7 +2859,7 @@ var NotarizationPlugin = class {
|
|
|
3009
2859
|
timeout,
|
|
3010
2860
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3011
2861
|
}, {
|
|
3012
|
-
F:
|
|
2862
|
+
F: __dxlog_file10,
|
|
3013
2863
|
L: 111,
|
|
3014
2864
|
S: this,
|
|
3015
2865
|
C: (f, a) => f(...a)
|
|
@@ -3032,7 +2882,7 @@ var NotarizationPlugin = class {
|
|
|
3032
2882
|
log8.info("Exhausted all peers to notarize with", {
|
|
3033
2883
|
retryIn: retryTimeout
|
|
3034
2884
|
}, {
|
|
3035
|
-
F:
|
|
2885
|
+
F: __dxlog_file10,
|
|
3036
2886
|
L: 136,
|
|
3037
2887
|
S: this,
|
|
3038
2888
|
C: (f, a) => f(...a)
|
|
@@ -3046,7 +2896,7 @@ var NotarizationPlugin = class {
|
|
|
3046
2896
|
peer: peer.localPeerId,
|
|
3047
2897
|
credentialId: credentials.map((credential) => credential.id)
|
|
3048
2898
|
}, {
|
|
3049
|
-
F:
|
|
2899
|
+
F: __dxlog_file10,
|
|
3050
2900
|
L: 143,
|
|
3051
2901
|
S: this,
|
|
3052
2902
|
C: (f, a) => f(...a)
|
|
@@ -3055,7 +2905,7 @@ var NotarizationPlugin = class {
|
|
|
3055
2905
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3056
2906
|
});
|
|
3057
2907
|
log8("success", void 0, {
|
|
3058
|
-
F:
|
|
2908
|
+
F: __dxlog_file10,
|
|
3059
2909
|
L: 147,
|
|
3060
2910
|
S: this,
|
|
3061
2911
|
C: (f, a) => f(...a)
|
|
@@ -3064,7 +2914,7 @@ var NotarizationPlugin = class {
|
|
|
3064
2914
|
} catch (err) {
|
|
3065
2915
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3066
2916
|
log8.info("error notarizing (recoverable)", err, {
|
|
3067
|
-
F:
|
|
2917
|
+
F: __dxlog_file10,
|
|
3068
2918
|
L: 151,
|
|
3069
2919
|
S: this,
|
|
3070
2920
|
C: (f, a) => f(...a)
|
|
@@ -3082,7 +2932,7 @@ var NotarizationPlugin = class {
|
|
|
3082
2932
|
errors.wait()
|
|
3083
2933
|
]);
|
|
3084
2934
|
log8("done", void 0, {
|
|
3085
|
-
F:
|
|
2935
|
+
F: __dxlog_file10,
|
|
3086
2936
|
L: 162,
|
|
3087
2937
|
S: this,
|
|
3088
2938
|
C: (f, a) => f(...a)
|
|
@@ -3103,8 +2953,8 @@ var NotarizationPlugin = class {
|
|
|
3103
2953
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3104
2954
|
}
|
|
3105
2955
|
setWriter(writer) {
|
|
3106
|
-
|
|
3107
|
-
F:
|
|
2956
|
+
invariant9(!this._writer, "Writer already set.", {
|
|
2957
|
+
F: __dxlog_file10,
|
|
3108
2958
|
L: 181,
|
|
3109
2959
|
S: this,
|
|
3110
2960
|
A: [
|
|
@@ -3128,8 +2978,8 @@ var NotarizationPlugin = class {
|
|
|
3128
2978
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3129
2979
|
}
|
|
3130
2980
|
for (const credential of request.credentials ?? []) {
|
|
3131
|
-
|
|
3132
|
-
F:
|
|
2981
|
+
invariant9(credential.id, "Credential must have an id", {
|
|
2982
|
+
F: __dxlog_file10,
|
|
3133
2983
|
L: 200,
|
|
3134
2984
|
S: this,
|
|
3135
2985
|
A: [
|
|
@@ -3149,7 +2999,7 @@ var NotarizationPlugin = class {
|
|
|
3149
2999
|
log8("extension opened", {
|
|
3150
3000
|
peer: extension.localPeerId
|
|
3151
3001
|
}, {
|
|
3152
|
-
F:
|
|
3002
|
+
F: __dxlog_file10,
|
|
3153
3003
|
L: 211,
|
|
3154
3004
|
S: this,
|
|
3155
3005
|
C: (f, a) => f(...a)
|
|
@@ -3161,7 +3011,7 @@ var NotarizationPlugin = class {
|
|
|
3161
3011
|
log8("extension closed", {
|
|
3162
3012
|
peer: extension.localPeerId
|
|
3163
3013
|
}, {
|
|
3164
|
-
F:
|
|
3014
|
+
F: __dxlog_file10,
|
|
3165
3015
|
L: 216,
|
|
3166
3016
|
S: this,
|
|
3167
3017
|
C: (f, a) => f(...a)
|
|
@@ -3215,7 +3065,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3215
3065
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3216
3066
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3217
3067
|
}
|
|
3218
|
-
var
|
|
3068
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3219
3069
|
var DataSpace = class {
|
|
3220
3070
|
constructor(params) {
|
|
3221
3071
|
this._ctx = new Context8();
|
|
@@ -3250,7 +3100,7 @@ var DataSpace = class {
|
|
|
3250
3100
|
log9("new state", {
|
|
3251
3101
|
state: SpaceState[this._state]
|
|
3252
3102
|
}, {
|
|
3253
|
-
F:
|
|
3103
|
+
F: __dxlog_file11,
|
|
3254
3104
|
L: 140,
|
|
3255
3105
|
S: this,
|
|
3256
3106
|
C: (f, a) => f(...a)
|
|
@@ -3300,7 +3150,7 @@ var DataSpace = class {
|
|
|
3300
3150
|
log9("new state", {
|
|
3301
3151
|
state: SpaceState[this._state]
|
|
3302
3152
|
}, {
|
|
3303
|
-
F:
|
|
3153
|
+
F: __dxlog_file11,
|
|
3304
3154
|
L: 198,
|
|
3305
3155
|
S: this,
|
|
3306
3156
|
C: (f, a) => f(...a)
|
|
@@ -3318,7 +3168,7 @@ var DataSpace = class {
|
|
|
3318
3168
|
log9("new state", {
|
|
3319
3169
|
state: SpaceState[this._state]
|
|
3320
3170
|
}, {
|
|
3321
|
-
F:
|
|
3171
|
+
F: __dxlog_file11,
|
|
3322
3172
|
L: 212,
|
|
3323
3173
|
S: this,
|
|
3324
3174
|
C: (f, a) => f(...a)
|
|
@@ -3350,7 +3200,7 @@ var DataSpace = class {
|
|
|
3350
3200
|
} catch (err) {
|
|
3351
3201
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3352
3202
|
log9("data pipeline initialization cancelled", err, {
|
|
3353
|
-
F:
|
|
3203
|
+
F: __dxlog_file11,
|
|
3354
3204
|
L: 245,
|
|
3355
3205
|
S: this,
|
|
3356
3206
|
C: (f, a) => f(...a)
|
|
@@ -3358,7 +3208,7 @@ var DataSpace = class {
|
|
|
3358
3208
|
return;
|
|
3359
3209
|
}
|
|
3360
3210
|
log9.error("Error initializing data pipeline", err, {
|
|
3361
|
-
F:
|
|
3211
|
+
F: __dxlog_file11,
|
|
3362
3212
|
L: 249,
|
|
3363
3213
|
S: this,
|
|
3364
3214
|
C: (f, a) => f(...a)
|
|
@@ -3367,7 +3217,7 @@ var DataSpace = class {
|
|
|
3367
3217
|
log9("new state", {
|
|
3368
3218
|
state: SpaceState[this._state]
|
|
3369
3219
|
}, {
|
|
3370
|
-
F:
|
|
3220
|
+
F: __dxlog_file11,
|
|
3371
3221
|
L: 251,
|
|
3372
3222
|
S: this,
|
|
3373
3223
|
C: (f, a) => f(...a)
|
|
@@ -3387,7 +3237,7 @@ var DataSpace = class {
|
|
|
3387
3237
|
log9("new state", {
|
|
3388
3238
|
state: SpaceState[this._state]
|
|
3389
3239
|
}, {
|
|
3390
|
-
F:
|
|
3240
|
+
F: __dxlog_file11,
|
|
3391
3241
|
L: 267,
|
|
3392
3242
|
S: this,
|
|
3393
3243
|
C: (f, a) => f(...a)
|
|
@@ -3397,7 +3247,7 @@ var DataSpace = class {
|
|
|
3397
3247
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3398
3248
|
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3399
3249
|
log9("data pipeline ready", void 0, {
|
|
3400
|
-
F:
|
|
3250
|
+
F: __dxlog_file11,
|
|
3401
3251
|
L: 279,
|
|
3402
3252
|
S: this,
|
|
3403
3253
|
C: (f, a) => f(...a)
|
|
@@ -3407,7 +3257,7 @@ var DataSpace = class {
|
|
|
3407
3257
|
log9("new state", {
|
|
3408
3258
|
state: SpaceState[this._state]
|
|
3409
3259
|
}, {
|
|
3410
|
-
F:
|
|
3260
|
+
F: __dxlog_file11,
|
|
3411
3261
|
L: 283,
|
|
3412
3262
|
S: this,
|
|
3413
3263
|
C: (f, a) => f(...a)
|
|
@@ -3423,7 +3273,7 @@ var DataSpace = class {
|
|
|
3423
3273
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3424
3274
|
await this._createWritableFeeds();
|
|
3425
3275
|
log9("writable feeds created", void 0, {
|
|
3426
|
-
F:
|
|
3276
|
+
F: __dxlog_file11,
|
|
3427
3277
|
L: 299,
|
|
3428
3278
|
S: this,
|
|
3429
3279
|
C: (f, a) => f(...a)
|
|
@@ -3486,7 +3336,7 @@ var DataSpace = class {
|
|
|
3486
3336
|
space: this.key,
|
|
3487
3337
|
rootUrl
|
|
3488
3338
|
}, {
|
|
3489
|
-
F:
|
|
3339
|
+
F: __dxlog_file11,
|
|
3490
3340
|
L: 365,
|
|
3491
3341
|
S: this,
|
|
3492
3342
|
C: (f, a) => f(...a)
|
|
@@ -3518,7 +3368,7 @@ var DataSpace = class {
|
|
|
3518
3368
|
rootUrl,
|
|
3519
3369
|
err
|
|
3520
3370
|
}, {
|
|
3521
|
-
F:
|
|
3371
|
+
F: __dxlog_file11,
|
|
3522
3372
|
L: 388,
|
|
3523
3373
|
S: this,
|
|
3524
3374
|
C: (f, a) => f(...a)
|
|
@@ -3572,8 +3422,8 @@ var DataSpace = class {
|
|
|
3572
3422
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3573
3423
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3574
3424
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3575
|
-
|
|
3576
|
-
F:
|
|
3425
|
+
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3426
|
+
F: __dxlog_file11,
|
|
3577
3427
|
L: 438,
|
|
3578
3428
|
S: this,
|
|
3579
3429
|
A: [
|
|
@@ -3592,7 +3442,7 @@ var DataSpace = class {
|
|
|
3592
3442
|
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3593
3443
|
{
|
|
3594
3444
|
log9.info("Fragmenting", void 0, {
|
|
3595
|
-
F:
|
|
3445
|
+
F: __dxlog_file11,
|
|
3596
3446
|
L: 450,
|
|
3597
3447
|
S: this,
|
|
3598
3448
|
C: (f, a) => f(...a)
|
|
@@ -3603,8 +3453,8 @@ var DataSpace = class {
|
|
|
3603
3453
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3604
3454
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
3605
3455
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3606
|
-
|
|
3607
|
-
F:
|
|
3456
|
+
invariant10(properties, "Properties not found", {
|
|
3457
|
+
F: __dxlog_file11,
|
|
3608
3458
|
L: 460,
|
|
3609
3459
|
S: this,
|
|
3610
3460
|
A: [
|
|
@@ -3619,8 +3469,8 @@ var DataSpace = class {
|
|
|
3619
3469
|
])
|
|
3620
3470
|
};
|
|
3621
3471
|
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3622
|
-
|
|
3623
|
-
F:
|
|
3472
|
+
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3473
|
+
F: __dxlog_file11,
|
|
3624
3474
|
L: 465,
|
|
3625
3475
|
S: this,
|
|
3626
3476
|
A: [
|
|
@@ -3689,7 +3539,7 @@ var DataSpace = class {
|
|
|
3689
3539
|
log9("new state", {
|
|
3690
3540
|
state: SpaceState[this._state]
|
|
3691
3541
|
}, {
|
|
3692
|
-
F:
|
|
3542
|
+
F: __dxlog_file11,
|
|
3693
3543
|
L: 531,
|
|
3694
3544
|
S: this,
|
|
3695
3545
|
C: (f, a) => f(...a)
|
|
@@ -3747,7 +3597,7 @@ DataSpace = _ts_decorate4([
|
|
|
3747
3597
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3748
3598
|
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3749
3599
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3750
|
-
import { invariant as
|
|
3600
|
+
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3751
3601
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3752
3602
|
import { log as log10 } from "@dxos/log";
|
|
3753
3603
|
import { trace as trace7 } from "@dxos/protocols";
|
|
@@ -3758,7 +3608,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsyn
|
|
|
3758
3608
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
3759
3609
|
import { createCredential } from "@dxos/credentials";
|
|
3760
3610
|
import { failUndefined } from "@dxos/debug";
|
|
3761
|
-
import { AdmittedFeed as AdmittedFeed4, SpaceMember
|
|
3611
|
+
import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3762
3612
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3763
3613
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3764
3614
|
const credentials = [
|
|
@@ -3778,7 +3628,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3778
3628
|
assertion: {
|
|
3779
3629
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3780
3630
|
spaceKey: space.key,
|
|
3781
|
-
role:
|
|
3631
|
+
role: SpaceMember.Role.ADMIN,
|
|
3782
3632
|
profile: signingContext.getProfile(),
|
|
3783
3633
|
genesisFeedKey: space.controlFeedKey ?? failUndefined()
|
|
3784
3634
|
}
|
|
@@ -3836,7 +3686,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3836
3686
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3837
3687
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3838
3688
|
}
|
|
3839
|
-
var
|
|
3689
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3840
3690
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3841
3691
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3842
3692
|
var DataSpaceManager = class {
|
|
@@ -3862,7 +3712,7 @@ var DataSpaceManager = class {
|
|
|
3862
3712
|
}
|
|
3863
3713
|
async open() {
|
|
3864
3714
|
log10("open", void 0, {
|
|
3865
|
-
F:
|
|
3715
|
+
F: __dxlog_file12,
|
|
3866
3716
|
L: 98,
|
|
3867
3717
|
S: this,
|
|
3868
3718
|
C: (f, a) => f(...a)
|
|
@@ -3870,7 +3720,7 @@ var DataSpaceManager = class {
|
|
|
3870
3720
|
log10.trace("dxos.echo.data-space-manager.open", trace7.begin({
|
|
3871
3721
|
id: this._instanceId
|
|
3872
3722
|
}), {
|
|
3873
|
-
F:
|
|
3723
|
+
F: __dxlog_file12,
|
|
3874
3724
|
L: 99,
|
|
3875
3725
|
S: this,
|
|
3876
3726
|
C: (f, a) => f(...a)
|
|
@@ -3878,7 +3728,7 @@ var DataSpaceManager = class {
|
|
|
3878
3728
|
log10("metadata loaded", {
|
|
3879
3729
|
spaces: this._metadataStore.spaces.length
|
|
3880
3730
|
}, {
|
|
3881
|
-
F:
|
|
3731
|
+
F: __dxlog_file12,
|
|
3882
3732
|
L: 100,
|
|
3883
3733
|
S: this,
|
|
3884
3734
|
C: (f, a) => f(...a)
|
|
@@ -3888,7 +3738,7 @@ var DataSpaceManager = class {
|
|
|
3888
3738
|
log10("load space", {
|
|
3889
3739
|
spaceMetadata
|
|
3890
3740
|
}, {
|
|
3891
|
-
F:
|
|
3741
|
+
F: __dxlog_file12,
|
|
3892
3742
|
L: 104,
|
|
3893
3743
|
S: this,
|
|
3894
3744
|
C: (f, a) => f(...a)
|
|
@@ -3899,7 +3749,7 @@ var DataSpaceManager = class {
|
|
|
3899
3749
|
spaceMetadata,
|
|
3900
3750
|
err
|
|
3901
3751
|
}, {
|
|
3902
|
-
F:
|
|
3752
|
+
F: __dxlog_file12,
|
|
3903
3753
|
L: 107,
|
|
3904
3754
|
S: this,
|
|
3905
3755
|
C: (f, a) => f(...a)
|
|
@@ -3916,7 +3766,7 @@ var DataSpaceManager = class {
|
|
|
3916
3766
|
log10.trace("dxos.echo.data-space-manager.open", trace7.end({
|
|
3917
3767
|
id: this._instanceId
|
|
3918
3768
|
}), {
|
|
3919
|
-
F:
|
|
3769
|
+
F: __dxlog_file12,
|
|
3920
3770
|
L: 120,
|
|
3921
3771
|
S: this,
|
|
3922
3772
|
C: (f, a) => f(...a)
|
|
@@ -3924,7 +3774,7 @@ var DataSpaceManager = class {
|
|
|
3924
3774
|
}
|
|
3925
3775
|
async close() {
|
|
3926
3776
|
log10("close", void 0, {
|
|
3927
|
-
F:
|
|
3777
|
+
F: __dxlog_file12,
|
|
3928
3778
|
L: 125,
|
|
3929
3779
|
S: this,
|
|
3930
3780
|
C: (f, a) => f(...a)
|
|
@@ -3939,8 +3789,8 @@ var DataSpaceManager = class {
|
|
|
3939
3789
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3940
3790
|
*/
|
|
3941
3791
|
async createSpace() {
|
|
3942
|
-
|
|
3943
|
-
F:
|
|
3792
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3793
|
+
F: __dxlog_file12,
|
|
3944
3794
|
L: 138,
|
|
3945
3795
|
S: this,
|
|
3946
3796
|
A: [
|
|
@@ -3961,7 +3811,7 @@ var DataSpaceManager = class {
|
|
|
3961
3811
|
log10("creating space...", {
|
|
3962
3812
|
spaceKey
|
|
3963
3813
|
}, {
|
|
3964
|
-
F:
|
|
3814
|
+
F: __dxlog_file12,
|
|
3965
3815
|
L: 150,
|
|
3966
3816
|
S: this,
|
|
3967
3817
|
C: (f, a) => f(...a)
|
|
@@ -3976,8 +3826,8 @@ var DataSpaceManager = class {
|
|
|
3976
3826
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3977
3827
|
await this._metadataStore.addSpace(metadata);
|
|
3978
3828
|
const memberCredential = credentials[1];
|
|
3979
|
-
|
|
3980
|
-
F:
|
|
3829
|
+
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3830
|
+
F: __dxlog_file12,
|
|
3981
3831
|
L: 163,
|
|
3982
3832
|
S: this,
|
|
3983
3833
|
A: [
|
|
@@ -3995,13 +3845,13 @@ var DataSpaceManager = class {
|
|
|
3995
3845
|
log10("accept space", {
|
|
3996
3846
|
opts
|
|
3997
3847
|
}, {
|
|
3998
|
-
F:
|
|
3848
|
+
F: __dxlog_file12,
|
|
3999
3849
|
L: 175,
|
|
4000
3850
|
S: this,
|
|
4001
3851
|
C: (f, a) => f(...a)
|
|
4002
3852
|
});
|
|
4003
|
-
|
|
4004
|
-
F:
|
|
3853
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3854
|
+
F: __dxlog_file12,
|
|
4005
3855
|
L: 176,
|
|
4006
3856
|
S: this,
|
|
4007
3857
|
A: [
|
|
@@ -4009,8 +3859,8 @@ var DataSpaceManager = class {
|
|
|
4009
3859
|
"'Not open.'"
|
|
4010
3860
|
]
|
|
4011
3861
|
});
|
|
4012
|
-
|
|
4013
|
-
F:
|
|
3862
|
+
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3863
|
+
F: __dxlog_file12,
|
|
4014
3864
|
L: 177,
|
|
4015
3865
|
S: this,
|
|
4016
3866
|
A: [
|
|
@@ -4045,7 +3895,7 @@ var DataSpaceManager = class {
|
|
|
4045
3895
|
log10("construct space", {
|
|
4046
3896
|
metadata
|
|
4047
3897
|
}, {
|
|
4048
|
-
F:
|
|
3898
|
+
F: __dxlog_file12,
|
|
4049
3899
|
L: 210,
|
|
4050
3900
|
S: this,
|
|
4051
3901
|
C: (f, a) => f(...a)
|
|
@@ -4083,7 +3933,7 @@ var DataSpaceManager = class {
|
|
|
4083
3933
|
},
|
|
4084
3934
|
onAuthFailure: () => {
|
|
4085
3935
|
log10.warn("auth failure", void 0, {
|
|
4086
|
-
F:
|
|
3936
|
+
F: __dxlog_file12,
|
|
4087
3937
|
L: 247,
|
|
4088
3938
|
S: this,
|
|
4089
3939
|
C: (f, a) => f(...a)
|
|
@@ -4107,7 +3957,7 @@ var DataSpaceManager = class {
|
|
|
4107
3957
|
log10("before space ready", {
|
|
4108
3958
|
space: space.key
|
|
4109
3959
|
}, {
|
|
4110
|
-
F:
|
|
3960
|
+
F: __dxlog_file12,
|
|
4111
3961
|
L: 265,
|
|
4112
3962
|
S: this,
|
|
4113
3963
|
C: (f, a) => f(...a)
|
|
@@ -4118,7 +3968,7 @@ var DataSpaceManager = class {
|
|
|
4118
3968
|
space: space.key,
|
|
4119
3969
|
open: this._isOpen
|
|
4120
3970
|
}, {
|
|
4121
|
-
F:
|
|
3971
|
+
F: __dxlog_file12,
|
|
4122
3972
|
L: 268,
|
|
4123
3973
|
S: this,
|
|
4124
3974
|
C: (f, a) => f(...a)
|
|
@@ -4131,7 +3981,7 @@ var DataSpaceManager = class {
|
|
|
4131
3981
|
log10("before space close", {
|
|
4132
3982
|
space: space.key
|
|
4133
3983
|
}, {
|
|
4134
|
-
F:
|
|
3984
|
+
F: __dxlog_file12,
|
|
4135
3985
|
L: 274,
|
|
4136
3986
|
S: this,
|
|
4137
3987
|
C: (f, a) => f(...a)
|
|
@@ -4171,11 +4021,11 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4171
4021
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
4172
4022
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4173
4023
|
import { raise as raise2 } from "@dxos/debug";
|
|
4174
|
-
import { invariant as
|
|
4024
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4175
4025
|
import { log as log11 } from "@dxos/log";
|
|
4176
4026
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4177
|
-
import { SpaceMember as
|
|
4178
|
-
var
|
|
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";
|
|
4179
4029
|
var SpacesServiceImpl = class {
|
|
4180
4030
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4181
4031
|
this._identityManager = _identityManager;
|
|
@@ -4214,7 +4064,7 @@ var SpacesServiceImpl = class {
|
|
|
4214
4064
|
log11("update", {
|
|
4215
4065
|
spaces
|
|
4216
4066
|
}, {
|
|
4217
|
-
F:
|
|
4067
|
+
F: __dxlog_file13,
|
|
4218
4068
|
L: 77,
|
|
4219
4069
|
S: this,
|
|
4220
4070
|
C: (f, a) => f(...a)
|
|
@@ -4296,8 +4146,8 @@ var SpacesServiceImpl = class {
|
|
|
4296
4146
|
}
|
|
4297
4147
|
});
|
|
4298
4148
|
} else {
|
|
4299
|
-
|
|
4300
|
-
F:
|
|
4149
|
+
invariant12(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4150
|
+
F: __dxlog_file13,
|
|
4301
4151
|
L: 164,
|
|
4302
4152
|
S: this,
|
|
4303
4153
|
A: [
|
|
@@ -4305,8 +4155,8 @@ var SpacesServiceImpl = class {
|
|
|
4305
4155
|
"'Id on unsigned credentials is not allowed'"
|
|
4306
4156
|
]
|
|
4307
4157
|
});
|
|
4308
|
-
|
|
4309
|
-
F:
|
|
4158
|
+
invariant12(this._identityManager.identity, "Identity is not available", {
|
|
4159
|
+
F: __dxlog_file13,
|
|
4310
4160
|
L: 165,
|
|
4311
4161
|
S: this,
|
|
4312
4162
|
A: [
|
|
@@ -4315,8 +4165,8 @@ var SpacesServiceImpl = class {
|
|
|
4315
4165
|
]
|
|
4316
4166
|
});
|
|
4317
4167
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4318
|
-
|
|
4319
|
-
F:
|
|
4168
|
+
invariant12(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4169
|
+
F: __dxlog_file13,
|
|
4320
4170
|
L: 167,
|
|
4321
4171
|
S: this,
|
|
4322
4172
|
A: [
|
|
@@ -4372,7 +4222,7 @@ var SpacesServiceImpl = class {
|
|
|
4372
4222
|
identityKey: member.key,
|
|
4373
4223
|
profile: member.profile ?? {}
|
|
4374
4224
|
},
|
|
4375
|
-
presence: member.removed ?
|
|
4225
|
+
presence: member.removed ? SpaceMember2.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember2.PresenceState.ONLINE : SpaceMember2.PresenceState.OFFLINE,
|
|
4376
4226
|
peerStates: peers
|
|
4377
4227
|
};
|
|
4378
4228
|
}),
|
|
@@ -4392,11 +4242,11 @@ import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
|
4392
4242
|
import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4393
4243
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4394
4244
|
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4395
|
-
import { invariant as
|
|
4245
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4396
4246
|
import { Keyring } from "@dxos/keyring";
|
|
4397
4247
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4398
4248
|
import { log as log12 } from "@dxos/log";
|
|
4399
|
-
import { InvalidStorageVersionError, STORAGE_VERSION
|
|
4249
|
+
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4400
4250
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4401
4251
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4402
4252
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
@@ -4492,7 +4342,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4492
4342
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4493
4343
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4494
4344
|
}
|
|
4495
|
-
var
|
|
4345
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4496
4346
|
var ServiceContext = class extends Resource {
|
|
4497
4347
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4498
4348
|
super();
|
|
@@ -4547,7 +4397,7 @@ var ServiceContext = class extends Resource {
|
|
|
4547
4397
|
async _open(ctx) {
|
|
4548
4398
|
await this._checkStorageVersion();
|
|
4549
4399
|
log12("opening...", void 0, {
|
|
4550
|
-
F:
|
|
4400
|
+
F: __dxlog_file14,
|
|
4551
4401
|
L: 156,
|
|
4552
4402
|
S: this,
|
|
4553
4403
|
C: (f, a) => f(...a)
|
|
@@ -4555,7 +4405,7 @@ var ServiceContext = class extends Resource {
|
|
|
4555
4405
|
log12.trace("dxos.sdk.service-context.open", trace8.begin({
|
|
4556
4406
|
id: this._instanceId
|
|
4557
4407
|
}), {
|
|
4558
|
-
F:
|
|
4408
|
+
F: __dxlog_file14,
|
|
4559
4409
|
L: 157,
|
|
4560
4410
|
S: this,
|
|
4561
4411
|
C: (f, a) => f(...a)
|
|
@@ -4571,13 +4421,13 @@ var ServiceContext = class extends Resource {
|
|
|
4571
4421
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4572
4422
|
id: this._instanceId
|
|
4573
4423
|
}), {
|
|
4574
|
-
F:
|
|
4424
|
+
F: __dxlog_file14,
|
|
4575
4425
|
L: 167,
|
|
4576
4426
|
S: this,
|
|
4577
4427
|
C: (f, a) => f(...a)
|
|
4578
4428
|
});
|
|
4579
4429
|
log12("opened", void 0, {
|
|
4580
|
-
F:
|
|
4430
|
+
F: __dxlog_file14,
|
|
4581
4431
|
L: 168,
|
|
4582
4432
|
S: this,
|
|
4583
4433
|
C: (f, a) => f(...a)
|
|
@@ -4585,7 +4435,7 @@ var ServiceContext = class extends Resource {
|
|
|
4585
4435
|
}
|
|
4586
4436
|
async _close() {
|
|
4587
4437
|
log12("closing...", void 0, {
|
|
4588
|
-
F:
|
|
4438
|
+
F: __dxlog_file14,
|
|
4589
4439
|
L: 172,
|
|
4590
4440
|
S: this,
|
|
4591
4441
|
C: (f, a) => f(...a)
|
|
@@ -4603,7 +4453,7 @@ var ServiceContext = class extends Resource {
|
|
|
4603
4453
|
await this.metadataStore.close();
|
|
4604
4454
|
await this.indexer.destroy();
|
|
4605
4455
|
log12("closed", void 0, {
|
|
4606
|
-
F:
|
|
4456
|
+
F: __dxlog_file14,
|
|
4607
4457
|
L: 185,
|
|
4608
4458
|
S: this,
|
|
4609
4459
|
C: (f, a) => f(...a)
|
|
@@ -4616,8 +4466,8 @@ var ServiceContext = class extends Resource {
|
|
|
4616
4466
|
}
|
|
4617
4467
|
getInvitationHandler(invitation) {
|
|
4618
4468
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4619
|
-
|
|
4620
|
-
F:
|
|
4469
|
+
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4470
|
+
F: __dxlog_file14,
|
|
4621
4471
|
L: 196,
|
|
4622
4472
|
S: this,
|
|
4623
4473
|
A: [
|
|
@@ -4642,14 +4492,14 @@ var ServiceContext = class extends Resource {
|
|
|
4642
4492
|
}
|
|
4643
4493
|
async _checkStorageVersion() {
|
|
4644
4494
|
await this.metadataStore.load();
|
|
4645
|
-
if (this.metadataStore.version !==
|
|
4646
|
-
throw new InvalidStorageVersionError(
|
|
4495
|
+
if (this.metadataStore.version !== STORAGE_VERSION) {
|
|
4496
|
+
throw new InvalidStorageVersionError(STORAGE_VERSION, this.metadataStore.version);
|
|
4647
4497
|
}
|
|
4648
4498
|
}
|
|
4649
4499
|
// Called when identity is created.
|
|
4650
4500
|
async _initialize(ctx) {
|
|
4651
4501
|
log12("initializing spaces...", void 0, {
|
|
4652
|
-
F:
|
|
4502
|
+
F: __dxlog_file14,
|
|
4653
4503
|
L: 227,
|
|
4654
4504
|
S: this,
|
|
4655
4505
|
C: (f, a) => f(...a)
|
|
@@ -4671,8 +4521,8 @@ var ServiceContext = class extends Resource {
|
|
|
4671
4521
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4672
4522
|
await this.dataSpaceManager.open();
|
|
4673
4523
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4674
|
-
|
|
4675
|
-
F:
|
|
4524
|
+
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4525
|
+
F: __dxlog_file14,
|
|
4676
4526
|
L: 251,
|
|
4677
4527
|
S: this,
|
|
4678
4528
|
A: [
|
|
@@ -4696,7 +4546,7 @@ var ServiceContext = class extends Resource {
|
|
|
4696
4546
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4697
4547
|
details: assertion
|
|
4698
4548
|
}, {
|
|
4699
|
-
F:
|
|
4549
|
+
F: __dxlog_file14,
|
|
4700
4550
|
L: 267,
|
|
4701
4551
|
S: this,
|
|
4702
4552
|
C: (f, a) => f(...a)
|
|
@@ -4707,7 +4557,7 @@ var ServiceContext = class extends Resource {
|
|
|
4707
4557
|
log12("space already exists, ignoring space admission", {
|
|
4708
4558
|
details: assertion
|
|
4709
4559
|
}, {
|
|
4710
|
-
F:
|
|
4560
|
+
F: __dxlog_file14,
|
|
4711
4561
|
L: 271,
|
|
4712
4562
|
S: this,
|
|
4713
4563
|
C: (f, a) => f(...a)
|
|
@@ -4718,7 +4568,7 @@ var ServiceContext = class extends Resource {
|
|
|
4718
4568
|
log12("accepting space recorded in halo", {
|
|
4719
4569
|
details: assertion
|
|
4720
4570
|
}, {
|
|
4721
|
-
F:
|
|
4571
|
+
F: __dxlog_file14,
|
|
4722
4572
|
L: 276,
|
|
4723
4573
|
S: this,
|
|
4724
4574
|
C: (f, a) => f(...a)
|
|
@@ -4729,7 +4579,7 @@ var ServiceContext = class extends Resource {
|
|
|
4729
4579
|
});
|
|
4730
4580
|
} catch (err) {
|
|
4731
4581
|
log12.catch(err, void 0, {
|
|
4732
|
-
F:
|
|
4582
|
+
F: __dxlog_file14,
|
|
4733
4583
|
L: 282,
|
|
4734
4584
|
S: this,
|
|
4735
4585
|
C: (f, a) => f(...a)
|
|
@@ -4775,203 +4625,254 @@ var ServiceRegistry = class {
|
|
|
4775
4625
|
}
|
|
4776
4626
|
};
|
|
4777
4627
|
|
|
4778
|
-
// packages/sdk/client-services/src/packlets/
|
|
4779
|
-
import {
|
|
4780
|
-
import {
|
|
4781
|
-
import {
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
}
|
|
4806
|
-
get lockKey() {
|
|
4807
|
-
return this._lockKey;
|
|
4808
|
-
}
|
|
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
|
-
});
|
|
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.c42bfdb";
|
|
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
|
+
};
|
|
4841
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
|
+
};
|
|
4842
4666
|
}
|
|
4843
|
-
|
|
4844
|
-
|
|
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);
|
|
4845
4697
|
}
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
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);
|
|
4849
4707
|
}
|
|
4708
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4709
|
+
file,
|
|
4710
|
+
count
|
|
4711
|
+
}));
|
|
4850
4712
|
}
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
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
|
-
});
|
|
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;
|
|
4893
4740
|
}
|
|
4741
|
+
diagnostics.config = config.values;
|
|
4742
|
+
return diagnostics;
|
|
4894
4743
|
};
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
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
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
if (stats.metrics) {
|
|
4772
|
+
const { open, ready } = stats.metrics;
|
|
4773
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4774
|
+
}
|
|
4775
|
+
return stats;
|
|
4900
4776
|
};
|
|
4901
4777
|
|
|
4902
|
-
// packages/sdk/client-services/src/packlets/
|
|
4903
|
-
import {
|
|
4904
|
-
import {
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
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
|
+
};
|
|
4918
4829
|
};
|
|
4919
|
-
|
|
4920
|
-
|
|
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
|
-
}
|
|
4830
|
+
var createCollectDiagnosticsBroadcastHandler = (systemService) => {
|
|
4831
|
+
let channel;
|
|
4936
4832
|
return {
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
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
|
+
}
|
|
4941
4862
|
};
|
|
4942
4863
|
};
|
|
4943
|
-
var
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
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]}`);
|
|
4864
|
+
var safeClose = (channel) => {
|
|
4865
|
+
try {
|
|
4866
|
+
channel?.close();
|
|
4867
|
+
} catch (e) {
|
|
4961
4868
|
}
|
|
4962
4869
|
};
|
|
4963
4870
|
|
|
4964
|
-
// packages/sdk/client-services/src/packlets/
|
|
4965
|
-
import {
|
|
4966
|
-
import
|
|
4967
|
-
import {
|
|
4968
|
-
|
|
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
|
-
};
|
|
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";
|
|
4975
4876
|
|
|
4976
4877
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4977
4878
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
@@ -4982,7 +4883,7 @@ import * as E from "@dxos/echo-schema";
|
|
|
4982
4883
|
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4983
4884
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4984
4885
|
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
4985
|
-
import { log as
|
|
4886
|
+
import { log as log16 } from "@dxos/log";
|
|
4986
4887
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4987
4888
|
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
4988
4889
|
import { trace as trace9 } from "@dxos/protocols";
|
|
@@ -5073,28 +4974,152 @@ var DevicesServiceImpl = class {
|
|
|
5073
4974
|
}
|
|
5074
4975
|
};
|
|
5075
4976
|
|
|
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
|
+
|
|
5076
5101
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5077
5102
|
import { Event as Event8 } from "@dxos/async";
|
|
5078
5103
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5079
|
-
import { PublicKey as
|
|
5080
|
-
import { getContextFromEntry, log as
|
|
5104
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
5105
|
+
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
5081
5106
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5082
5107
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
5083
5108
|
var LoggingServiceImpl = class {
|
|
5084
5109
|
constructor() {
|
|
5085
5110
|
this._logs = new Event8();
|
|
5086
5111
|
this._started = Date.now();
|
|
5087
|
-
this._sessionId =
|
|
5112
|
+
this._sessionId = PublicKey11.random().toHex();
|
|
5088
5113
|
this._logProcessor = (_config, entry2) => {
|
|
5089
5114
|
this._logs.emit(entry2);
|
|
5090
5115
|
};
|
|
5091
5116
|
}
|
|
5092
5117
|
async open() {
|
|
5093
|
-
|
|
5118
|
+
log15.runtimeConfig.processors.push(this._logProcessor);
|
|
5094
5119
|
}
|
|
5095
5120
|
async close() {
|
|
5096
|
-
const index =
|
|
5097
|
-
|
|
5121
|
+
const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5122
|
+
log15.runtimeConfig.processors.splice(index, 1);
|
|
5098
5123
|
}
|
|
5099
5124
|
async controlMetrics({ reset, record }) {
|
|
5100
5125
|
if (reset) {
|
|
@@ -5230,6 +5255,80 @@ var NetworkServiceImpl = class {
|
|
|
5230
5255
|
}
|
|
5231
5256
|
};
|
|
5232
5257
|
|
|
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
|
+
|
|
5233
5332
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
5234
5333
|
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
5235
5334
|
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -5298,7 +5397,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5298
5397
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5299
5398
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5300
5399
|
}
|
|
5301
|
-
var
|
|
5400
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5302
5401
|
var ClientServicesHost = class {
|
|
5303
5402
|
constructor({
|
|
5304
5403
|
config,
|
|
@@ -5353,6 +5452,7 @@ var ClientServicesHost = class {
|
|
|
5353
5452
|
await this.reset();
|
|
5354
5453
|
}
|
|
5355
5454
|
});
|
|
5455
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5356
5456
|
this._loggingService = new LoggingServiceImpl();
|
|
5357
5457
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
5358
5458
|
SystemService: this._systemService,
|
|
@@ -5384,24 +5484,24 @@ var ClientServicesHost = class {
|
|
|
5384
5484
|
*/
|
|
5385
5485
|
initialize({ config, ...options }) {
|
|
5386
5486
|
invariant16(!this._open, "service host is open", {
|
|
5387
|
-
F:
|
|
5388
|
-
L:
|
|
5487
|
+
F: __dxlog_file19,
|
|
5488
|
+
L: 188,
|
|
5389
5489
|
S: this,
|
|
5390
5490
|
A: [
|
|
5391
5491
|
"!this._open",
|
|
5392
5492
|
"'service host is open'"
|
|
5393
5493
|
]
|
|
5394
5494
|
});
|
|
5395
|
-
|
|
5396
|
-
F:
|
|
5397
|
-
L:
|
|
5495
|
+
log16("initializing...", void 0, {
|
|
5496
|
+
F: __dxlog_file19,
|
|
5497
|
+
L: 189,
|
|
5398
5498
|
S: this,
|
|
5399
5499
|
C: (f, a) => f(...a)
|
|
5400
5500
|
});
|
|
5401
5501
|
if (config) {
|
|
5402
5502
|
invariant16(!this._config, "config already set", {
|
|
5403
|
-
F:
|
|
5404
|
-
L:
|
|
5503
|
+
F: __dxlog_file19,
|
|
5504
|
+
L: 192,
|
|
5405
5505
|
S: this,
|
|
5406
5506
|
A: [
|
|
5407
5507
|
"!this._config",
|
|
@@ -5414,9 +5514,9 @@ var ClientServicesHost = class {
|
|
|
5414
5514
|
}
|
|
5415
5515
|
}
|
|
5416
5516
|
if (!options.signalManager) {
|
|
5417
|
-
|
|
5418
|
-
F:
|
|
5419
|
-
L:
|
|
5517
|
+
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5518
|
+
F: __dxlog_file19,
|
|
5519
|
+
L: 200,
|
|
5420
5520
|
S: this,
|
|
5421
5521
|
C: (f, a) => f(...a)
|
|
5422
5522
|
});
|
|
@@ -5426,8 +5526,8 @@ var ClientServicesHost = class {
|
|
|
5426
5526
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5427
5527
|
this._signalManager = signalManager;
|
|
5428
5528
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5429
|
-
F:
|
|
5430
|
-
L:
|
|
5529
|
+
F: __dxlog_file19,
|
|
5530
|
+
L: 211,
|
|
5431
5531
|
S: this,
|
|
5432
5532
|
A: [
|
|
5433
5533
|
"!this._networkManager",
|
|
@@ -5439,9 +5539,9 @@ var ClientServicesHost = class {
|
|
|
5439
5539
|
transportFactory,
|
|
5440
5540
|
signalManager
|
|
5441
5541
|
});
|
|
5442
|
-
|
|
5443
|
-
F:
|
|
5444
|
-
L:
|
|
5542
|
+
log16("initialized", void 0, {
|
|
5543
|
+
F: __dxlog_file19,
|
|
5544
|
+
L: 218,
|
|
5445
5545
|
S: this,
|
|
5446
5546
|
C: (f, a) => f(...a)
|
|
5447
5547
|
});
|
|
@@ -5451,17 +5551,17 @@ var ClientServicesHost = class {
|
|
|
5451
5551
|
return;
|
|
5452
5552
|
}
|
|
5453
5553
|
const traceId = PublicKey13.random().toHex();
|
|
5454
|
-
|
|
5554
|
+
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5455
5555
|
id: traceId
|
|
5456
5556
|
}), {
|
|
5457
|
-
F:
|
|
5458
|
-
L:
|
|
5557
|
+
F: __dxlog_file19,
|
|
5558
|
+
L: 229,
|
|
5459
5559
|
S: this,
|
|
5460
5560
|
C: (f, a) => f(...a)
|
|
5461
5561
|
});
|
|
5462
5562
|
invariant16(this._config, "config not set", {
|
|
5463
|
-
F:
|
|
5464
|
-
L:
|
|
5563
|
+
F: __dxlog_file19,
|
|
5564
|
+
L: 231,
|
|
5465
5565
|
S: this,
|
|
5466
5566
|
A: [
|
|
5467
5567
|
"this._config",
|
|
@@ -5469,8 +5569,8 @@ var ClientServicesHost = class {
|
|
|
5469
5569
|
]
|
|
5470
5570
|
});
|
|
5471
5571
|
invariant16(this._storage, "storage not set", {
|
|
5472
|
-
F:
|
|
5473
|
-
L:
|
|
5572
|
+
F: __dxlog_file19,
|
|
5573
|
+
L: 232,
|
|
5474
5574
|
S: this,
|
|
5475
5575
|
A: [
|
|
5476
5576
|
"this._storage",
|
|
@@ -5478,8 +5578,8 @@ var ClientServicesHost = class {
|
|
|
5478
5578
|
]
|
|
5479
5579
|
});
|
|
5480
5580
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5481
|
-
F:
|
|
5482
|
-
L:
|
|
5581
|
+
F: __dxlog_file19,
|
|
5582
|
+
L: 233,
|
|
5483
5583
|
S: this,
|
|
5484
5584
|
A: [
|
|
5485
5585
|
"this._signalManager",
|
|
@@ -5487,8 +5587,8 @@ var ClientServicesHost = class {
|
|
|
5487
5587
|
]
|
|
5488
5588
|
});
|
|
5489
5589
|
invariant16(this._networkManager, "network manager not set", {
|
|
5490
|
-
F:
|
|
5491
|
-
L:
|
|
5590
|
+
F: __dxlog_file19,
|
|
5591
|
+
L: 234,
|
|
5492
5592
|
S: this,
|
|
5493
5593
|
A: [
|
|
5494
5594
|
"this._networkManager",
|
|
@@ -5496,11 +5596,11 @@ var ClientServicesHost = class {
|
|
|
5496
5596
|
]
|
|
5497
5597
|
});
|
|
5498
5598
|
this._opening = true;
|
|
5499
|
-
|
|
5599
|
+
log16("opening...", {
|
|
5500
5600
|
lockKey: this._resourceLock?.lockKey
|
|
5501
5601
|
}, {
|
|
5502
|
-
F:
|
|
5503
|
-
L:
|
|
5602
|
+
F: __dxlog_file19,
|
|
5603
|
+
L: 237,
|
|
5504
5604
|
S: this,
|
|
5505
5605
|
C: (f, a) => f(...a)
|
|
5506
5606
|
});
|
|
@@ -5536,8 +5636,8 @@ var ClientServicesHost = class {
|
|
|
5536
5636
|
});
|
|
5537
5637
|
await this._serviceContext.open(ctx);
|
|
5538
5638
|
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5539
|
-
F:
|
|
5540
|
-
L:
|
|
5639
|
+
F: __dxlog_file19,
|
|
5640
|
+
L: 303,
|
|
5541
5641
|
S: this,
|
|
5542
5642
|
A: [
|
|
5543
5643
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5545,11 +5645,11 @@ var ClientServicesHost = class {
|
|
|
5545
5645
|
]
|
|
5546
5646
|
});
|
|
5547
5647
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5548
|
-
|
|
5648
|
+
log16("loaded persistent invitations", {
|
|
5549
5649
|
count: loadedInvitations.invitations?.length
|
|
5550
5650
|
}, {
|
|
5551
|
-
F:
|
|
5552
|
-
L:
|
|
5651
|
+
F: __dxlog_file19,
|
|
5652
|
+
L: 306,
|
|
5553
5653
|
S: this,
|
|
5554
5654
|
C: (f, a) => f(...a)
|
|
5555
5655
|
});
|
|
@@ -5563,23 +5663,24 @@ var ClientServicesHost = class {
|
|
|
5563
5663
|
});
|
|
5564
5664
|
void this._devtoolsProxy.open();
|
|
5565
5665
|
}
|
|
5666
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5566
5667
|
this._opening = false;
|
|
5567
5668
|
this._open = true;
|
|
5568
5669
|
this._statusUpdate.emit();
|
|
5569
5670
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5570
|
-
|
|
5671
|
+
log16("opened", {
|
|
5571
5672
|
deviceKey
|
|
5572
5673
|
}, {
|
|
5573
|
-
F:
|
|
5574
|
-
L:
|
|
5674
|
+
F: __dxlog_file19,
|
|
5675
|
+
L: 324,
|
|
5575
5676
|
S: this,
|
|
5576
5677
|
C: (f, a) => f(...a)
|
|
5577
5678
|
});
|
|
5578
|
-
|
|
5679
|
+
log16.trace("dxos.client-services.host.open", trace9.end({
|
|
5579
5680
|
id: traceId
|
|
5580
5681
|
}), {
|
|
5581
|
-
F:
|
|
5582
|
-
L:
|
|
5682
|
+
F: __dxlog_file19,
|
|
5683
|
+
L: 325,
|
|
5583
5684
|
S: this,
|
|
5584
5685
|
C: (f, a) => f(...a)
|
|
5585
5686
|
});
|
|
@@ -5589,14 +5690,15 @@ var ClientServicesHost = class {
|
|
|
5589
5690
|
return;
|
|
5590
5691
|
}
|
|
5591
5692
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5592
|
-
|
|
5693
|
+
log16("closing...", {
|
|
5593
5694
|
deviceKey
|
|
5594
5695
|
}, {
|
|
5595
|
-
F:
|
|
5596
|
-
L:
|
|
5696
|
+
F: __dxlog_file19,
|
|
5697
|
+
L: 336,
|
|
5597
5698
|
S: this,
|
|
5598
5699
|
C: (f, a) => f(...a)
|
|
5599
5700
|
});
|
|
5701
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5600
5702
|
await this._devtoolsProxy?.close();
|
|
5601
5703
|
this._serviceRegistry.setServices({
|
|
5602
5704
|
SystemService: this._systemService
|
|
@@ -5606,44 +5708,44 @@ var ClientServicesHost = class {
|
|
|
5606
5708
|
await this._level?.close();
|
|
5607
5709
|
this._open = false;
|
|
5608
5710
|
this._statusUpdate.emit();
|
|
5609
|
-
|
|
5711
|
+
log16("closed", {
|
|
5610
5712
|
deviceKey
|
|
5611
5713
|
}, {
|
|
5612
|
-
F:
|
|
5613
|
-
L:
|
|
5714
|
+
F: __dxlog_file19,
|
|
5715
|
+
L: 345,
|
|
5614
5716
|
S: this,
|
|
5615
5717
|
C: (f, a) => f(...a)
|
|
5616
5718
|
});
|
|
5617
5719
|
}
|
|
5618
5720
|
async reset() {
|
|
5619
5721
|
const traceId = PublicKey13.random().toHex();
|
|
5620
|
-
|
|
5722
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5621
5723
|
id: traceId
|
|
5622
5724
|
}), {
|
|
5623
|
-
F:
|
|
5624
|
-
L:
|
|
5725
|
+
F: __dxlog_file19,
|
|
5726
|
+
L: 350,
|
|
5625
5727
|
S: this,
|
|
5626
5728
|
C: (f, a) => f(...a)
|
|
5627
5729
|
});
|
|
5628
|
-
|
|
5629
|
-
F:
|
|
5630
|
-
L:
|
|
5730
|
+
log16("resetting...", void 0, {
|
|
5731
|
+
F: __dxlog_file19,
|
|
5732
|
+
L: 352,
|
|
5631
5733
|
S: this,
|
|
5632
5734
|
C: (f, a) => f(...a)
|
|
5633
5735
|
});
|
|
5634
5736
|
await this._serviceContext?.close();
|
|
5635
5737
|
await this._storage.reset();
|
|
5636
|
-
|
|
5637
|
-
F:
|
|
5638
|
-
L:
|
|
5738
|
+
log16("reset", void 0, {
|
|
5739
|
+
F: __dxlog_file19,
|
|
5740
|
+
L: 355,
|
|
5639
5741
|
S: this,
|
|
5640
5742
|
C: (f, a) => f(...a)
|
|
5641
5743
|
});
|
|
5642
|
-
|
|
5744
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.end({
|
|
5643
5745
|
id: traceId
|
|
5644
5746
|
}), {
|
|
5645
|
-
F:
|
|
5646
|
-
L:
|
|
5747
|
+
F: __dxlog_file19,
|
|
5748
|
+
L: 356,
|
|
5647
5749
|
S: this,
|
|
5648
5750
|
C: (f, a) => f(...a)
|
|
5649
5751
|
});
|
|
@@ -5655,8 +5757,8 @@ var ClientServicesHost = class {
|
|
|
5655
5757
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5656
5758
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5657
5759
|
invariant16(automergeIndex, void 0, {
|
|
5658
|
-
F:
|
|
5659
|
-
L:
|
|
5760
|
+
F: __dxlog_file19,
|
|
5761
|
+
L: 368,
|
|
5660
5762
|
S: this,
|
|
5661
5763
|
A: [
|
|
5662
5764
|
"automergeIndex",
|
|
@@ -5705,6 +5807,44 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5705
5807
|
Trace3.resource()
|
|
5706
5808
|
], ClientServicesHost);
|
|
5707
5809
|
|
|
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
|
+
|
|
5708
5848
|
export {
|
|
5709
5849
|
Buffer,
|
|
5710
5850
|
subscribeToFeeds,
|
|
@@ -5728,16 +5868,20 @@ export {
|
|
|
5728
5868
|
InvitationsServiceImpl,
|
|
5729
5869
|
SpaceInvitationProtocol,
|
|
5730
5870
|
ClientRpcServer,
|
|
5731
|
-
createDiagnostics,
|
|
5732
5871
|
DataSpace,
|
|
5733
5872
|
DataSpaceManager,
|
|
5734
5873
|
SpacesServiceImpl,
|
|
5735
5874
|
ServiceContext,
|
|
5736
5875
|
ServiceRegistry,
|
|
5876
|
+
createDiagnostics,
|
|
5877
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5878
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5879
|
+
DiagnosticsCollector,
|
|
5737
5880
|
Lock,
|
|
5738
5881
|
isLocked,
|
|
5739
5882
|
createStorageObjects,
|
|
5740
5883
|
createLevel,
|
|
5741
|
-
ClientServicesHost
|
|
5884
|
+
ClientServicesHost,
|
|
5885
|
+
ClientServicesProviderResource
|
|
5742
5886
|
};
|
|
5743
|
-
//# sourceMappingURL=chunk-
|
|
5887
|
+
//# sourceMappingURL=chunk-W7UANCHR.mjs.map
|