@dxos/client-services 0.4.10-main.3ba6dcf → 0.4.10-main.3c620fb
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-WQ6ASRLV.mjs → chunk-H2TNTLUE.mjs} +707 -515
- package/dist/lib/browser/chunk-H2TNTLUE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11 -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 +11 -5
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-U6EYP6CO.cjs → chunk-OSCHFTM3.cjs} +641 -536
- package/dist/lib/node/chunk-OSCHFTM3.cjs.map +7 -0
- package/dist/lib/node/index.cjs +47 -37
- 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 +15 -9
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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/indexing/util.d.ts +2 -2
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
- 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-context.d.ts +7 -5
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +5 -1
- 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/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts +4 -0
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts +4 -0
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
- 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/packlets/testing/test-builder.d.ts +5 -2
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -34
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.test.ts +1 -1
- 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/identity/identity-service.test.ts +1 -1
- package/src/packlets/indexing/util.ts +4 -4
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- package/src/packlets/network/network-service.test.ts +1 -1
- package/src/packlets/services/automerge-host.test.ts +9 -3
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +9 -6
- package/src/packlets/services/service-context.ts +15 -8
- package/src/packlets/services/service-host.ts +49 -9
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/level.ts +19 -0
- package/src/packlets/storage/storage.ts +3 -9
- package/src/packlets/storage/util.ts +19 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/test-builder.ts +23 -5
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-WQ6ASRLV.mjs.map +0 -7
- package/dist/lib/node/chunk-U6EYP6CO.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.3ba6dcf";
|
|
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
|
}),
|
|
@@ -4386,17 +4236,17 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4386
4236
|
|
|
4387
4237
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4388
4238
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4389
|
-
import { Context as Context10 } from "@dxos/context";
|
|
4239
|
+
import { Context as Context10, Resource } from "@dxos/context";
|
|
4390
4240
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4391
4241
|
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";
|
|
@@ -4406,7 +4256,7 @@ import { safeInstanceof } from "@dxos/util";
|
|
|
4406
4256
|
import { getHeads } from "@dxos/automerge/automerge";
|
|
4407
4257
|
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4408
4258
|
import { idCodec } from "@dxos/protocols";
|
|
4409
|
-
var
|
|
4259
|
+
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4410
4260
|
/**
|
|
4411
4261
|
* Get object data blobs from Automerge Repo by ids.
|
|
4412
4262
|
* @param ids
|
|
@@ -4419,17 +4269,17 @@ var createLoadDocuments = (automergeHost) => (
|
|
|
4419
4269
|
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4420
4270
|
const doc = handle.docSync();
|
|
4421
4271
|
const hash = getHeads(doc).join("");
|
|
4422
|
-
yield [
|
|
4272
|
+
yield doc.objects?.[objectId] ? [
|
|
4423
4273
|
{
|
|
4424
4274
|
id,
|
|
4425
4275
|
object: doc.objects[objectId],
|
|
4426
4276
|
currentHash: hash
|
|
4427
4277
|
}
|
|
4428
|
-
];
|
|
4278
|
+
] : [];
|
|
4429
4279
|
}
|
|
4430
4280
|
}
|
|
4431
4281
|
);
|
|
4432
|
-
var
|
|
4282
|
+
var createDocumentsIterator = (automergeHost) => (
|
|
4433
4283
|
/**
|
|
4434
4284
|
* Recursively get all object data blobs from Automerge Repo.
|
|
4435
4285
|
* @param ids
|
|
@@ -4452,7 +4302,7 @@ var createGetAllDocuments = (automergeHost) => (
|
|
|
4452
4302
|
objectId
|
|
4453
4303
|
}),
|
|
4454
4304
|
object,
|
|
4455
|
-
currentHash: heads.
|
|
4305
|
+
currentHash: heads.join("")
|
|
4456
4306
|
};
|
|
4457
4307
|
});
|
|
4458
4308
|
}
|
|
@@ -4492,10 +4342,12 @@ 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
|
|
4496
|
-
var ServiceContext = class {
|
|
4497
|
-
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4345
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4346
|
+
var ServiceContext = class extends Resource {
|
|
4347
|
+
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4348
|
+
super();
|
|
4498
4349
|
this.storage = storage;
|
|
4350
|
+
this.level = level;
|
|
4499
4351
|
this.networkManager = networkManager;
|
|
4500
4352
|
this.signalManager = signalManager;
|
|
4501
4353
|
this._runtimeParams = _runtimeParams;
|
|
@@ -4525,10 +4377,11 @@ var ServiceContext = class {
|
|
|
4525
4377
|
});
|
|
4526
4378
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4527
4379
|
this.indexMetadata = new IndexMetadataStore({
|
|
4528
|
-
|
|
4380
|
+
db: level.sublevel("index-metadata")
|
|
4529
4381
|
});
|
|
4530
4382
|
this.automergeHost = new AutomergeHost({
|
|
4531
4383
|
directory: storage.createDirectory("automerge"),
|
|
4384
|
+
db: level.sublevel("automerge"),
|
|
4532
4385
|
metadata: this.indexMetadata
|
|
4533
4386
|
});
|
|
4534
4387
|
this.indexer = new Indexer({
|
|
@@ -4536,30 +4389,31 @@ var ServiceContext = class {
|
|
|
4536
4389
|
directory: storage.createDirectory("index-store")
|
|
4537
4390
|
}),
|
|
4538
4391
|
metadataStore: this.indexMetadata,
|
|
4539
|
-
loadDocuments:
|
|
4540
|
-
getAllDocuments:
|
|
4392
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4393
|
+
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4541
4394
|
});
|
|
4542
4395
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4543
4396
|
this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4544
4397
|
}
|
|
4545
|
-
async
|
|
4398
|
+
async _open(ctx) {
|
|
4546
4399
|
await this._checkStorageVersion();
|
|
4547
4400
|
log12("opening...", void 0, {
|
|
4548
|
-
F:
|
|
4549
|
-
L:
|
|
4401
|
+
F: __dxlog_file14,
|
|
4402
|
+
L: 157,
|
|
4550
4403
|
S: this,
|
|
4551
4404
|
C: (f, a) => f(...a)
|
|
4552
4405
|
});
|
|
4553
4406
|
log12.trace("dxos.sdk.service-context.open", trace8.begin({
|
|
4554
4407
|
id: this._instanceId
|
|
4555
4408
|
}), {
|
|
4556
|
-
F:
|
|
4557
|
-
L:
|
|
4409
|
+
F: __dxlog_file14,
|
|
4410
|
+
L: 158,
|
|
4558
4411
|
S: this,
|
|
4559
4412
|
C: (f, a) => f(...a)
|
|
4560
4413
|
});
|
|
4561
4414
|
await this.signalManager.open();
|
|
4562
4415
|
await this.networkManager.open();
|
|
4416
|
+
await this.automergeHost.open();
|
|
4563
4417
|
await this.metadataStore.load();
|
|
4564
4418
|
await this.spaceManager.open();
|
|
4565
4419
|
await this.identityManager.open(ctx);
|
|
@@ -4569,22 +4423,22 @@ var ServiceContext = class {
|
|
|
4569
4423
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4570
4424
|
id: this._instanceId
|
|
4571
4425
|
}), {
|
|
4572
|
-
F:
|
|
4573
|
-
L:
|
|
4426
|
+
F: __dxlog_file14,
|
|
4427
|
+
L: 169,
|
|
4574
4428
|
S: this,
|
|
4575
4429
|
C: (f, a) => f(...a)
|
|
4576
4430
|
});
|
|
4577
4431
|
log12("opened", void 0, {
|
|
4578
|
-
F:
|
|
4579
|
-
L:
|
|
4432
|
+
F: __dxlog_file14,
|
|
4433
|
+
L: 170,
|
|
4580
4434
|
S: this,
|
|
4581
4435
|
C: (f, a) => f(...a)
|
|
4582
4436
|
});
|
|
4583
4437
|
}
|
|
4584
|
-
async
|
|
4438
|
+
async _close() {
|
|
4585
4439
|
log12("closing...", void 0, {
|
|
4586
|
-
F:
|
|
4587
|
-
L:
|
|
4440
|
+
F: __dxlog_file14,
|
|
4441
|
+
L: 174,
|
|
4588
4442
|
S: this,
|
|
4589
4443
|
C: (f, a) => f(...a)
|
|
4590
4444
|
});
|
|
@@ -4601,8 +4455,8 @@ var ServiceContext = class {
|
|
|
4601
4455
|
await this.metadataStore.close();
|
|
4602
4456
|
await this.indexer.destroy();
|
|
4603
4457
|
log12("closed", void 0, {
|
|
4604
|
-
F:
|
|
4605
|
-
L:
|
|
4458
|
+
F: __dxlog_file14,
|
|
4459
|
+
L: 187,
|
|
4606
4460
|
S: this,
|
|
4607
4461
|
C: (f, a) => f(...a)
|
|
4608
4462
|
});
|
|
@@ -4614,9 +4468,9 @@ var ServiceContext = class {
|
|
|
4614
4468
|
}
|
|
4615
4469
|
getInvitationHandler(invitation) {
|
|
4616
4470
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4617
|
-
|
|
4618
|
-
F:
|
|
4619
|
-
L:
|
|
4471
|
+
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4472
|
+
F: __dxlog_file14,
|
|
4473
|
+
L: 198,
|
|
4620
4474
|
S: this,
|
|
4621
4475
|
A: [
|
|
4622
4476
|
"factory",
|
|
@@ -4640,15 +4494,15 @@ var ServiceContext = class {
|
|
|
4640
4494
|
}
|
|
4641
4495
|
async _checkStorageVersion() {
|
|
4642
4496
|
await this.metadataStore.load();
|
|
4643
|
-
if (this.metadataStore.version !==
|
|
4644
|
-
throw new InvalidStorageVersionError(
|
|
4497
|
+
if (this.metadataStore.version !== STORAGE_VERSION) {
|
|
4498
|
+
throw new InvalidStorageVersionError(STORAGE_VERSION, this.metadataStore.version);
|
|
4645
4499
|
}
|
|
4646
4500
|
}
|
|
4647
4501
|
// Called when identity is created.
|
|
4648
4502
|
async _initialize(ctx) {
|
|
4649
4503
|
log12("initializing spaces...", void 0, {
|
|
4650
|
-
F:
|
|
4651
|
-
L:
|
|
4504
|
+
F: __dxlog_file14,
|
|
4505
|
+
L: 229,
|
|
4652
4506
|
S: this,
|
|
4653
4507
|
C: (f, a) => f(...a)
|
|
4654
4508
|
});
|
|
@@ -4669,9 +4523,9 @@ var ServiceContext = class {
|
|
|
4669
4523
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4670
4524
|
await this.dataSpaceManager.open();
|
|
4671
4525
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4672
|
-
|
|
4673
|
-
F:
|
|
4674
|
-
L:
|
|
4526
|
+
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4527
|
+
F: __dxlog_file14,
|
|
4528
|
+
L: 253,
|
|
4675
4529
|
S: this,
|
|
4676
4530
|
A: [
|
|
4677
4531
|
"this.dataSpaceManager",
|
|
@@ -4694,8 +4548,8 @@ var ServiceContext = class {
|
|
|
4694
4548
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4695
4549
|
details: assertion
|
|
4696
4550
|
}, {
|
|
4697
|
-
F:
|
|
4698
|
-
L:
|
|
4551
|
+
F: __dxlog_file14,
|
|
4552
|
+
L: 269,
|
|
4699
4553
|
S: this,
|
|
4700
4554
|
C: (f, a) => f(...a)
|
|
4701
4555
|
});
|
|
@@ -4705,8 +4559,8 @@ var ServiceContext = class {
|
|
|
4705
4559
|
log12("space already exists, ignoring space admission", {
|
|
4706
4560
|
details: assertion
|
|
4707
4561
|
}, {
|
|
4708
|
-
F:
|
|
4709
|
-
L:
|
|
4562
|
+
F: __dxlog_file14,
|
|
4563
|
+
L: 273,
|
|
4710
4564
|
S: this,
|
|
4711
4565
|
C: (f, a) => f(...a)
|
|
4712
4566
|
});
|
|
@@ -4716,8 +4570,8 @@ var ServiceContext = class {
|
|
|
4716
4570
|
log12("accepting space recorded in halo", {
|
|
4717
4571
|
details: assertion
|
|
4718
4572
|
}, {
|
|
4719
|
-
F:
|
|
4720
|
-
L:
|
|
4573
|
+
F: __dxlog_file14,
|
|
4574
|
+
L: 278,
|
|
4721
4575
|
S: this,
|
|
4722
4576
|
C: (f, a) => f(...a)
|
|
4723
4577
|
});
|
|
@@ -4727,8 +4581,8 @@ var ServiceContext = class {
|
|
|
4727
4581
|
});
|
|
4728
4582
|
} catch (err) {
|
|
4729
4583
|
log12.catch(err, void 0, {
|
|
4730
|
-
F:
|
|
4731
|
-
L:
|
|
4584
|
+
F: __dxlog_file14,
|
|
4585
|
+
L: 284,
|
|
4732
4586
|
S: this,
|
|
4733
4587
|
C: (f, a) => f(...a)
|
|
4734
4588
|
});
|
|
@@ -4740,7 +4594,7 @@ var ServiceContext = class {
|
|
|
4740
4594
|
};
|
|
4741
4595
|
_ts_decorate6([
|
|
4742
4596
|
Trace2.span()
|
|
4743
|
-
], ServiceContext.prototype, "
|
|
4597
|
+
], ServiceContext.prototype, "_open", null);
|
|
4744
4598
|
_ts_decorate6([
|
|
4745
4599
|
Trace2.span()
|
|
4746
4600
|
], ServiceContext.prototype, "_initialize", null);
|
|
@@ -4773,189 +4627,265 @@ var ServiceRegistry = class {
|
|
|
4773
4627
|
}
|
|
4774
4628
|
};
|
|
4775
4629
|
|
|
4776
|
-
// packages/sdk/client-services/src/packlets/
|
|
4777
|
-
import {
|
|
4778
|
-
import {
|
|
4779
|
-
import {
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
}
|
|
4804
|
-
get lockKey() {
|
|
4805
|
-
return this._lockKey;
|
|
4806
|
-
}
|
|
4807
|
-
async acquire() {
|
|
4808
|
-
this._broadcastChannel.postMessage({
|
|
4809
|
-
message: "acquiring"
|
|
4810
|
-
});
|
|
4811
|
-
try {
|
|
4812
|
-
log13("aquiring lock...", void 0, {
|
|
4813
|
-
F: __dxlog_file16,
|
|
4814
|
-
L: 42,
|
|
4815
|
-
S: this,
|
|
4816
|
-
C: (f, a) => f(...a)
|
|
4817
|
-
});
|
|
4818
|
-
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4819
|
-
log13("acquired lock", void 0, {
|
|
4820
|
-
F: __dxlog_file16,
|
|
4821
|
-
L: 44,
|
|
4822
|
-
S: this,
|
|
4823
|
-
C: (f, a) => f(...a)
|
|
4824
|
-
});
|
|
4825
|
-
} catch {
|
|
4826
|
-
log13("stealing lock...", void 0, {
|
|
4827
|
-
F: __dxlog_file16,
|
|
4828
|
-
L: 46,
|
|
4829
|
-
S: this,
|
|
4830
|
-
C: (f, a) => f(...a)
|
|
4831
|
-
});
|
|
4832
|
-
await this._requestLock(true);
|
|
4833
|
-
log13("stolen lock", void 0, {
|
|
4834
|
-
F: __dxlog_file16,
|
|
4835
|
-
L: 48,
|
|
4836
|
-
S: this,
|
|
4837
|
-
C: (f, a) => f(...a)
|
|
4838
|
-
});
|
|
4630
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
|
|
4631
|
+
import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
4632
|
+
import { credentialTypeFilter } from "@dxos/credentials";
|
|
4633
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4634
|
+
import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
|
|
4635
|
+
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4636
|
+
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
4637
|
+
|
|
4638
|
+
// packages/sdk/client-services/src/version.ts
|
|
4639
|
+
var DXOS_VERSION = "0.4.10-main.3c620fb";
|
|
4640
|
+
|
|
4641
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4642
|
+
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
4643
|
+
var getPlatform = () => {
|
|
4644
|
+
if (process.browser) {
|
|
4645
|
+
if (typeof window !== "undefined") {
|
|
4646
|
+
const { userAgent } = window.navigator;
|
|
4647
|
+
return {
|
|
4648
|
+
type: Platform.PLATFORM_TYPE.BROWSER,
|
|
4649
|
+
userAgent,
|
|
4650
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4651
|
+
};
|
|
4652
|
+
} else {
|
|
4653
|
+
return {
|
|
4654
|
+
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4655
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4656
|
+
};
|
|
4839
4657
|
}
|
|
4658
|
+
} else {
|
|
4659
|
+
const { platform: platform2, version, arch } = process;
|
|
4660
|
+
return {
|
|
4661
|
+
type: Platform.PLATFORM_TYPE.NODE,
|
|
4662
|
+
platform: platform2,
|
|
4663
|
+
arch,
|
|
4664
|
+
runtime: version,
|
|
4665
|
+
uptime: Math.floor(process.uptime()),
|
|
4666
|
+
memory: process.memoryUsage()
|
|
4667
|
+
};
|
|
4840
4668
|
}
|
|
4841
|
-
|
|
4842
|
-
|
|
4669
|
+
};
|
|
4670
|
+
|
|
4671
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
|
|
4672
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4673
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4674
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4675
|
+
const diagnostics = {
|
|
4676
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4677
|
+
platform: getPlatform(),
|
|
4678
|
+
client: {
|
|
4679
|
+
version: DXOS_VERSION,
|
|
4680
|
+
storage: {
|
|
4681
|
+
version: STORAGE_VERSION2
|
|
4682
|
+
}
|
|
4683
|
+
},
|
|
4684
|
+
trace: TRACE_PROCESSOR.getDiagnostics()
|
|
4685
|
+
};
|
|
4686
|
+
{
|
|
4687
|
+
invariant14(clientServices.LoggingService, "SystemService is not available.", {
|
|
4688
|
+
F: __dxlog_file15,
|
|
4689
|
+
L: 108,
|
|
4690
|
+
S: void 0,
|
|
4691
|
+
A: [
|
|
4692
|
+
"clientServices.LoggingService",
|
|
4693
|
+
"'SystemService is not available.'"
|
|
4694
|
+
]
|
|
4695
|
+
});
|
|
4696
|
+
diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
|
|
4697
|
+
timeout: DEFAULT_TIMEOUT
|
|
4698
|
+
}).catch(() => void 0);
|
|
4843
4699
|
}
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4700
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4701
|
+
const map = /* @__PURE__ */ new Map();
|
|
4702
|
+
const dir = await navigator.storage.getDirectory();
|
|
4703
|
+
for await (const filename of dir?.keys()) {
|
|
4704
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4705
|
+
if (idx === -1) {
|
|
4706
|
+
continue;
|
|
4707
|
+
}
|
|
4708
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4847
4709
|
}
|
|
4710
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4711
|
+
file,
|
|
4712
|
+
count
|
|
4713
|
+
}));
|
|
4848
4714
|
}
|
|
4849
|
-
|
|
4850
|
-
|
|
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
|
-
S: this,
|
|
4877
|
-
C: (f, a) => f(...a)
|
|
4878
|
-
});
|
|
4879
|
-
}).catch(async () => {
|
|
4880
|
-
await this._onRelease?.();
|
|
4881
|
-
});
|
|
4882
|
-
await acquired.wait();
|
|
4883
|
-
log13("recieved lock", {
|
|
4884
|
-
steal
|
|
4885
|
-
}, {
|
|
4886
|
-
F: __dxlog_file16,
|
|
4887
|
-
L: 81,
|
|
4888
|
-
S: this,
|
|
4889
|
-
C: (f, a) => f(...a)
|
|
4890
|
-
});
|
|
4715
|
+
const identity = serviceContext.identityManager.identity;
|
|
4716
|
+
if (identity) {
|
|
4717
|
+
diagnostics.identity = {
|
|
4718
|
+
identityKey: identity.identityKey,
|
|
4719
|
+
spaceKey: identity.space.key,
|
|
4720
|
+
profile: identity.profileDocument
|
|
4721
|
+
};
|
|
4722
|
+
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
4723
|
+
timeout: DEFAULT_TIMEOUT
|
|
4724
|
+
}).catch(() => void 0) ?? {};
|
|
4725
|
+
diagnostics.devices = devices;
|
|
4726
|
+
if (serviceContext.dataSpaceManager) {
|
|
4727
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4728
|
+
}
|
|
4729
|
+
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4730
|
+
timeout: DEFAULT_TIMEOUT
|
|
4731
|
+
}).catch(() => void 0) ?? {};
|
|
4732
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4733
|
+
feedKey,
|
|
4734
|
+
bytes,
|
|
4735
|
+
length
|
|
4736
|
+
}));
|
|
4737
|
+
const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
|
|
4738
|
+
timeout: DEFAULT_TIMEOUT
|
|
4739
|
+
}).catch(() => void 0);
|
|
4740
|
+
diagnostics.networkStatus = status;
|
|
4741
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4891
4742
|
}
|
|
4743
|
+
diagnostics.config = config.values;
|
|
4744
|
+
return diagnostics;
|
|
4892
4745
|
};
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4746
|
+
var getSpaceStats = async (space) => {
|
|
4747
|
+
const stats = {
|
|
4748
|
+
key: space.key,
|
|
4749
|
+
metrics: space.metrics,
|
|
4750
|
+
epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4751
|
+
...credential.subject.assertion,
|
|
4752
|
+
id: credential.id
|
|
4753
|
+
})),
|
|
4754
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4755
|
+
identity: {
|
|
4756
|
+
identityKey: member.key,
|
|
4757
|
+
profile: {
|
|
4758
|
+
displayName: member.assertion.profile?.displayName
|
|
4759
|
+
}
|
|
4760
|
+
},
|
|
4761
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE
|
|
4762
|
+
})),
|
|
4763
|
+
pipeline: {
|
|
4764
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4765
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4766
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4767
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4768
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4769
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4770
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4771
|
+
}
|
|
4772
|
+
};
|
|
4773
|
+
if (stats.metrics) {
|
|
4774
|
+
const { open, ready } = stats.metrics;
|
|
4775
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4776
|
+
}
|
|
4777
|
+
return stats;
|
|
4898
4778
|
};
|
|
4899
4779
|
|
|
4900
|
-
// packages/sdk/client-services/src/packlets/
|
|
4901
|
-
import {
|
|
4902
|
-
import {
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
4914
|
-
}
|
|
4915
|
-
if (persistent && keyStore === StorageDriver.RAM) {
|
|
4916
|
-
throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
4917
|
-
}
|
|
4918
|
-
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
4919
|
-
throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
4920
|
-
}
|
|
4780
|
+
// packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
|
|
4781
|
+
import { Trigger as Trigger6 } from "@dxos/async";
|
|
4782
|
+
import { log as log13 } from "@dxos/log";
|
|
4783
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
|
|
4784
|
+
var CHANNEL_NAME = "dxos.diagnostics.broadcast";
|
|
4785
|
+
var MessageType;
|
|
4786
|
+
(function(MessageType2) {
|
|
4787
|
+
MessageType2["PROBE"] = "probe";
|
|
4788
|
+
MessageType2["PROBE_ACK"] = "probe-ack";
|
|
4789
|
+
MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
|
|
4790
|
+
MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
|
|
4791
|
+
})(MessageType || (MessageType = {}));
|
|
4792
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4921
4793
|
return {
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4794
|
+
broadcastDiagnosticsRequest: async () => {
|
|
4795
|
+
let expectedResponse = "probe-ack";
|
|
4796
|
+
let channel;
|
|
4797
|
+
try {
|
|
4798
|
+
const trigger = new Trigger6();
|
|
4799
|
+
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
4800
|
+
channel.onmessage = (msg) => {
|
|
4801
|
+
if (expectedResponse === msg.data.type) {
|
|
4802
|
+
trigger.wake(msg.data);
|
|
4803
|
+
}
|
|
4804
|
+
};
|
|
4805
|
+
channel.postMessage({
|
|
4806
|
+
type: "probe"
|
|
4807
|
+
});
|
|
4808
|
+
await trigger.wait({
|
|
4809
|
+
timeout: 200
|
|
4810
|
+
});
|
|
4811
|
+
expectedResponse = "receive-diagnostics";
|
|
4812
|
+
trigger.reset();
|
|
4813
|
+
channel.postMessage({
|
|
4814
|
+
type: "request-diagnostics"
|
|
4815
|
+
});
|
|
4816
|
+
const diagnostics = await trigger.wait({
|
|
4817
|
+
timeout: 5e3
|
|
4818
|
+
});
|
|
4819
|
+
return diagnostics.payload;
|
|
4820
|
+
} catch (e) {
|
|
4821
|
+
const errorDescription = e instanceof Error ? e.message : JSON.stringify(e);
|
|
4822
|
+
return {
|
|
4823
|
+
expectedResponse,
|
|
4824
|
+
errorDescription
|
|
4825
|
+
};
|
|
4826
|
+
} finally {
|
|
4827
|
+
safeClose(channel);
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4926
4830
|
};
|
|
4927
4831
|
};
|
|
4928
|
-
var
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4832
|
+
var createCollectDiagnosticsBroadcastHandler = (systemService) => {
|
|
4833
|
+
let channel;
|
|
4834
|
+
return {
|
|
4835
|
+
start: () => {
|
|
4836
|
+
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
4837
|
+
channel.onmessage = async (message) => {
|
|
4838
|
+
try {
|
|
4839
|
+
if (message.data.type === "probe") {
|
|
4840
|
+
channel?.postMessage({
|
|
4841
|
+
type: "probe-ack"
|
|
4842
|
+
});
|
|
4843
|
+
} else if (message.data.type === "request-diagnostics") {
|
|
4844
|
+
const diagnostics = await systemService.getDiagnostics({});
|
|
4845
|
+
channel?.postMessage({
|
|
4846
|
+
type: "receive-diagnostics",
|
|
4847
|
+
payload: diagnostics
|
|
4848
|
+
});
|
|
4849
|
+
}
|
|
4850
|
+
} catch (error) {
|
|
4851
|
+
log13.catch(error, void 0, {
|
|
4852
|
+
F: __dxlog_file16,
|
|
4853
|
+
L: 77,
|
|
4854
|
+
S: void 0,
|
|
4855
|
+
C: (f, a) => f(...a)
|
|
4856
|
+
});
|
|
4857
|
+
}
|
|
4858
|
+
};
|
|
4859
|
+
},
|
|
4860
|
+
stop: () => {
|
|
4861
|
+
safeClose(channel);
|
|
4862
|
+
channel = void 0;
|
|
4863
|
+
}
|
|
4864
|
+
};
|
|
4865
|
+
};
|
|
4866
|
+
var safeClose = (channel) => {
|
|
4867
|
+
try {
|
|
4868
|
+
channel?.close();
|
|
4869
|
+
} catch (e) {
|
|
4946
4870
|
}
|
|
4947
4871
|
};
|
|
4948
4872
|
|
|
4873
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
4874
|
+
import { ConfigResource } from "@dxos/config";
|
|
4875
|
+
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4876
|
+
import { TRACE_PROCESSOR as TRACE_PROCESSOR3 } from "@dxos/tracing";
|
|
4877
|
+
import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
|
|
4878
|
+
|
|
4949
4879
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4950
4880
|
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4951
|
-
import {
|
|
4881
|
+
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4952
4882
|
import { Context as Context11 } from "@dxos/context";
|
|
4953
|
-
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4954
|
-
import
|
|
4883
|
+
import { DataServiceImpl, encodeReference } from "@dxos/echo-pipeline";
|
|
4884
|
+
import * as E from "@dxos/echo-schema";
|
|
4955
4885
|
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4956
4886
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4957
|
-
import { PublicKey as
|
|
4958
|
-
import { log as
|
|
4887
|
+
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
4888
|
+
import { log as log16 } from "@dxos/log";
|
|
4959
4889
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4960
4890
|
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
4961
4891
|
import { trace as trace9 } from "@dxos/protocols";
|
|
@@ -5046,11 +4976,135 @@ var DevicesServiceImpl = class {
|
|
|
5046
4976
|
}
|
|
5047
4977
|
};
|
|
5048
4978
|
|
|
4979
|
+
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4980
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
|
|
4981
|
+
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4982
|
+
import { log as log14, logInfo } from "@dxos/log";
|
|
4983
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4984
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4985
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4986
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4987
|
+
else
|
|
4988
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4989
|
+
if (d = decorators[i])
|
|
4990
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4991
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4992
|
+
}
|
|
4993
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
4994
|
+
var Message;
|
|
4995
|
+
(function(Message2) {
|
|
4996
|
+
Message2["ACQUIRING"] = "acquiring";
|
|
4997
|
+
})(Message || (Message = {}));
|
|
4998
|
+
var Lock = class {
|
|
4999
|
+
constructor({ lockKey, onAcquire, onRelease }) {
|
|
5000
|
+
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
5001
|
+
this._releaseTrigger = new Trigger7();
|
|
5002
|
+
this._lockKey = lockKey;
|
|
5003
|
+
this._onAcquire = onAcquire;
|
|
5004
|
+
this._onRelease = onRelease;
|
|
5005
|
+
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
5006
|
+
}
|
|
5007
|
+
get lockKey() {
|
|
5008
|
+
return this._lockKey;
|
|
5009
|
+
}
|
|
5010
|
+
async acquire() {
|
|
5011
|
+
this._broadcastChannel.postMessage({
|
|
5012
|
+
message: "acquiring"
|
|
5013
|
+
});
|
|
5014
|
+
try {
|
|
5015
|
+
log14("aquiring lock...", void 0, {
|
|
5016
|
+
F: __dxlog_file18,
|
|
5017
|
+
L: 42,
|
|
5018
|
+
S: this,
|
|
5019
|
+
C: (f, a) => f(...a)
|
|
5020
|
+
});
|
|
5021
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5022
|
+
log14("acquired lock", void 0, {
|
|
5023
|
+
F: __dxlog_file18,
|
|
5024
|
+
L: 44,
|
|
5025
|
+
S: this,
|
|
5026
|
+
C: (f, a) => f(...a)
|
|
5027
|
+
});
|
|
5028
|
+
} catch {
|
|
5029
|
+
log14("stealing lock...", void 0, {
|
|
5030
|
+
F: __dxlog_file18,
|
|
5031
|
+
L: 46,
|
|
5032
|
+
S: this,
|
|
5033
|
+
C: (f, a) => f(...a)
|
|
5034
|
+
});
|
|
5035
|
+
await this._requestLock(true);
|
|
5036
|
+
log14("stolen lock", void 0, {
|
|
5037
|
+
F: __dxlog_file18,
|
|
5038
|
+
L: 48,
|
|
5039
|
+
S: this,
|
|
5040
|
+
C: (f, a) => f(...a)
|
|
5041
|
+
});
|
|
5042
|
+
}
|
|
5043
|
+
}
|
|
5044
|
+
async release() {
|
|
5045
|
+
this._releaseTrigger.wake();
|
|
5046
|
+
}
|
|
5047
|
+
_onMessage(event) {
|
|
5048
|
+
if (event.data.message === "acquiring") {
|
|
5049
|
+
this._releaseTrigger.wake();
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
async _requestLock(steal = false) {
|
|
5053
|
+
log14("requesting lock...", {
|
|
5054
|
+
steal
|
|
5055
|
+
}, {
|
|
5056
|
+
F: __dxlog_file18,
|
|
5057
|
+
L: 63,
|
|
5058
|
+
S: this,
|
|
5059
|
+
C: (f, a) => f(...a)
|
|
5060
|
+
});
|
|
5061
|
+
const acquired = new Trigger7();
|
|
5062
|
+
void navigator.locks.request(this._lockKey, {
|
|
5063
|
+
steal
|
|
5064
|
+
}, async () => {
|
|
5065
|
+
await this._onAcquire?.();
|
|
5066
|
+
acquired.wake();
|
|
5067
|
+
this._releaseTrigger = new Trigger7();
|
|
5068
|
+
await this._releaseTrigger.wait();
|
|
5069
|
+
log14("releasing lock...", void 0, {
|
|
5070
|
+
F: __dxlog_file18,
|
|
5071
|
+
L: 72,
|
|
5072
|
+
S: this,
|
|
5073
|
+
C: (f, a) => f(...a)
|
|
5074
|
+
});
|
|
5075
|
+
await this._onRelease?.();
|
|
5076
|
+
log14("released lock", void 0, {
|
|
5077
|
+
F: __dxlog_file18,
|
|
5078
|
+
L: 74,
|
|
5079
|
+
S: this,
|
|
5080
|
+
C: (f, a) => f(...a)
|
|
5081
|
+
});
|
|
5082
|
+
}).catch(async () => {
|
|
5083
|
+
await this._onRelease?.();
|
|
5084
|
+
});
|
|
5085
|
+
await acquired.wait();
|
|
5086
|
+
log14("recieved lock", {
|
|
5087
|
+
steal
|
|
5088
|
+
}, {
|
|
5089
|
+
F: __dxlog_file18,
|
|
5090
|
+
L: 81,
|
|
5091
|
+
S: this,
|
|
5092
|
+
C: (f, a) => f(...a)
|
|
5093
|
+
});
|
|
5094
|
+
}
|
|
5095
|
+
};
|
|
5096
|
+
_ts_decorate7([
|
|
5097
|
+
logInfo
|
|
5098
|
+
], Lock.prototype, "lockKey", null);
|
|
5099
|
+
var isLocked = (lockPath) => {
|
|
5100
|
+
throw new Error("Not implemented");
|
|
5101
|
+
};
|
|
5102
|
+
|
|
5049
5103
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5050
5104
|
import { Event as Event8 } from "@dxos/async";
|
|
5051
5105
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5052
5106
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
5053
|
-
import { getContextFromEntry, log as
|
|
5107
|
+
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
5054
5108
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5055
5109
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
5056
5110
|
var LoggingServiceImpl = class {
|
|
@@ -5063,11 +5117,11 @@ var LoggingServiceImpl = class {
|
|
|
5063
5117
|
};
|
|
5064
5118
|
}
|
|
5065
5119
|
async open() {
|
|
5066
|
-
|
|
5120
|
+
log15.runtimeConfig.processors.push(this._logProcessor);
|
|
5067
5121
|
}
|
|
5068
5122
|
async close() {
|
|
5069
|
-
const index =
|
|
5070
|
-
|
|
5123
|
+
const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5124
|
+
log15.runtimeConfig.processors.splice(index, 1);
|
|
5071
5125
|
}
|
|
5072
5126
|
async controlMetrics({ reset, record }) {
|
|
5073
5127
|
if (reset) {
|
|
@@ -5152,12 +5206,12 @@ var LoggingServiceImpl = class {
|
|
|
5152
5206
|
});
|
|
5153
5207
|
}
|
|
5154
5208
|
};
|
|
5155
|
-
var matchFilter = (filter, level,
|
|
5209
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5156
5210
|
switch (options) {
|
|
5157
5211
|
case QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5158
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5212
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5159
5213
|
case QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5160
|
-
return level === filter.level && (!filter.pattern ||
|
|
5214
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5161
5215
|
}
|
|
5162
5216
|
};
|
|
5163
5217
|
var shouldLog = (entry2, request) => {
|
|
@@ -5203,6 +5257,80 @@ var NetworkServiceImpl = class {
|
|
|
5203
5257
|
}
|
|
5204
5258
|
};
|
|
5205
5259
|
|
|
5260
|
+
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
5261
|
+
import { InvalidConfigError } from "@dxos/protocols";
|
|
5262
|
+
import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
|
|
5263
|
+
import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
5264
|
+
|
|
5265
|
+
// packages/sdk/client-services/src/packlets/storage/util.ts
|
|
5266
|
+
import { DX_DATA } from "@dxos/client-protocol";
|
|
5267
|
+
import { Runtime } from "@dxos/protocols/proto/dxos/config";
|
|
5268
|
+
import { isNode as isNode2 } from "@dxos/util";
|
|
5269
|
+
var getRootPath = (config) => {
|
|
5270
|
+
const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
|
|
5271
|
+
return `${dataRoot}/`;
|
|
5272
|
+
};
|
|
5273
|
+
var isPersistent = (config) => {
|
|
5274
|
+
const { persistent = false } = config ?? {};
|
|
5275
|
+
return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5276
|
+
};
|
|
5277
|
+
|
|
5278
|
+
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
5279
|
+
var StorageDriver = Runtime2.Client.Storage.StorageDriver;
|
|
5280
|
+
var createStorageObjects = (config) => {
|
|
5281
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5282
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5283
|
+
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5284
|
+
}
|
|
5285
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5286
|
+
throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5287
|
+
}
|
|
5288
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5289
|
+
throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5290
|
+
}
|
|
5291
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5292
|
+
throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5293
|
+
}
|
|
5294
|
+
return {
|
|
5295
|
+
storage: createStorage({
|
|
5296
|
+
type: persistent ? toStorageType(dataStore) : StorageType.RAM,
|
|
5297
|
+
root: getRootPath(config)
|
|
5298
|
+
})
|
|
5299
|
+
};
|
|
5300
|
+
};
|
|
5301
|
+
var toStorageType = (type) => {
|
|
5302
|
+
switch (type) {
|
|
5303
|
+
case void 0:
|
|
5304
|
+
return void 0;
|
|
5305
|
+
case StorageDriver.RAM:
|
|
5306
|
+
return StorageType.RAM;
|
|
5307
|
+
case StorageDriver.CHROME:
|
|
5308
|
+
return StorageType.CHROME;
|
|
5309
|
+
case StorageDriver.FIREFOX:
|
|
5310
|
+
return StorageType.FIREFOX;
|
|
5311
|
+
case StorageDriver.IDB:
|
|
5312
|
+
return StorageType.IDB;
|
|
5313
|
+
case StorageDriver.NODE:
|
|
5314
|
+
return StorageType.NODE;
|
|
5315
|
+
case StorageDriver.WEBFS:
|
|
5316
|
+
return StorageType.WEBFS;
|
|
5317
|
+
default:
|
|
5318
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5319
|
+
}
|
|
5320
|
+
};
|
|
5321
|
+
|
|
5322
|
+
// packages/sdk/client-services/src/packlets/storage/level.ts
|
|
5323
|
+
import { Level } from "level";
|
|
5324
|
+
import path from "@dxos/node-std/path";
|
|
5325
|
+
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5326
|
+
var createLevel = async (config) => {
|
|
5327
|
+
const persistent = isPersistent(config);
|
|
5328
|
+
const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey12.random().toHex()}`;
|
|
5329
|
+
const level = new Level(storagePath);
|
|
5330
|
+
await level.open();
|
|
5331
|
+
return level;
|
|
5332
|
+
};
|
|
5333
|
+
|
|
5206
5334
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
5207
5335
|
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
5208
5336
|
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -5271,13 +5399,14 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5271
5399
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5272
5400
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5273
5401
|
}
|
|
5274
|
-
var
|
|
5402
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5275
5403
|
var ClientServicesHost = class {
|
|
5276
5404
|
constructor({
|
|
5277
5405
|
config,
|
|
5278
5406
|
transportFactory,
|
|
5279
5407
|
signalManager,
|
|
5280
5408
|
storage,
|
|
5409
|
+
level,
|
|
5281
5410
|
// TODO(wittjosiah): Turn this on by default.
|
|
5282
5411
|
lockKey,
|
|
5283
5412
|
callbacks,
|
|
@@ -5288,6 +5417,7 @@ var ClientServicesHost = class {
|
|
|
5288
5417
|
this._opening = false;
|
|
5289
5418
|
this._open = false;
|
|
5290
5419
|
this._storage = storage;
|
|
5420
|
+
this._level = level;
|
|
5291
5421
|
this._callbacks = callbacks;
|
|
5292
5422
|
this._runtimeParams = runtimeParams;
|
|
5293
5423
|
if (config) {
|
|
@@ -5326,6 +5456,7 @@ var ClientServicesHost = class {
|
|
|
5326
5456
|
await this.reset();
|
|
5327
5457
|
}
|
|
5328
5458
|
});
|
|
5459
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5329
5460
|
this._loggingService = new LoggingServiceImpl();
|
|
5330
5461
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
5331
5462
|
SystemService: this._systemService,
|
|
@@ -5357,24 +5488,24 @@ var ClientServicesHost = class {
|
|
|
5357
5488
|
*/
|
|
5358
5489
|
initialize({ config, ...options }) {
|
|
5359
5490
|
invariant16(!this._open, "service host is open", {
|
|
5360
|
-
F:
|
|
5361
|
-
L:
|
|
5491
|
+
F: __dxlog_file19,
|
|
5492
|
+
L: 197,
|
|
5362
5493
|
S: this,
|
|
5363
5494
|
A: [
|
|
5364
5495
|
"!this._open",
|
|
5365
5496
|
"'service host is open'"
|
|
5366
5497
|
]
|
|
5367
5498
|
});
|
|
5368
|
-
|
|
5369
|
-
F:
|
|
5370
|
-
L:
|
|
5499
|
+
log16("initializing...", void 0, {
|
|
5500
|
+
F: __dxlog_file19,
|
|
5501
|
+
L: 198,
|
|
5371
5502
|
S: this,
|
|
5372
5503
|
C: (f, a) => f(...a)
|
|
5373
5504
|
});
|
|
5374
5505
|
if (config) {
|
|
5375
5506
|
invariant16(!this._config, "config already set", {
|
|
5376
|
-
F:
|
|
5377
|
-
L:
|
|
5507
|
+
F: __dxlog_file19,
|
|
5508
|
+
L: 201,
|
|
5378
5509
|
S: this,
|
|
5379
5510
|
A: [
|
|
5380
5511
|
"!this._config",
|
|
@@ -5387,9 +5518,9 @@ var ClientServicesHost = class {
|
|
|
5387
5518
|
}
|
|
5388
5519
|
}
|
|
5389
5520
|
if (!options.signalManager) {
|
|
5390
|
-
|
|
5391
|
-
F:
|
|
5392
|
-
L:
|
|
5521
|
+
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5522
|
+
F: __dxlog_file19,
|
|
5523
|
+
L: 209,
|
|
5393
5524
|
S: this,
|
|
5394
5525
|
C: (f, a) => f(...a)
|
|
5395
5526
|
});
|
|
@@ -5399,8 +5530,8 @@ var ClientServicesHost = class {
|
|
|
5399
5530
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5400
5531
|
this._signalManager = signalManager;
|
|
5401
5532
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5402
|
-
F:
|
|
5403
|
-
L:
|
|
5533
|
+
F: __dxlog_file19,
|
|
5534
|
+
L: 220,
|
|
5404
5535
|
S: this,
|
|
5405
5536
|
A: [
|
|
5406
5537
|
"!this._networkManager",
|
|
@@ -5412,9 +5543,9 @@ var ClientServicesHost = class {
|
|
|
5412
5543
|
transportFactory,
|
|
5413
5544
|
signalManager
|
|
5414
5545
|
});
|
|
5415
|
-
|
|
5416
|
-
F:
|
|
5417
|
-
L:
|
|
5546
|
+
log16("initialized", void 0, {
|
|
5547
|
+
F: __dxlog_file19,
|
|
5548
|
+
L: 227,
|
|
5418
5549
|
S: this,
|
|
5419
5550
|
C: (f, a) => f(...a)
|
|
5420
5551
|
});
|
|
@@ -5423,18 +5554,18 @@ var ClientServicesHost = class {
|
|
|
5423
5554
|
if (this._open) {
|
|
5424
5555
|
return;
|
|
5425
5556
|
}
|
|
5426
|
-
const traceId =
|
|
5427
|
-
|
|
5557
|
+
const traceId = PublicKey13.random().toHex();
|
|
5558
|
+
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5428
5559
|
id: traceId
|
|
5429
5560
|
}), {
|
|
5430
|
-
F:
|
|
5431
|
-
L:
|
|
5561
|
+
F: __dxlog_file19,
|
|
5562
|
+
L: 238,
|
|
5432
5563
|
S: this,
|
|
5433
5564
|
C: (f, a) => f(...a)
|
|
5434
5565
|
});
|
|
5435
5566
|
invariant16(this._config, "config not set", {
|
|
5436
|
-
F:
|
|
5437
|
-
L:
|
|
5567
|
+
F: __dxlog_file19,
|
|
5568
|
+
L: 240,
|
|
5438
5569
|
S: this,
|
|
5439
5570
|
A: [
|
|
5440
5571
|
"this._config",
|
|
@@ -5442,8 +5573,8 @@ var ClientServicesHost = class {
|
|
|
5442
5573
|
]
|
|
5443
5574
|
});
|
|
5444
5575
|
invariant16(this._storage, "storage not set", {
|
|
5445
|
-
F:
|
|
5446
|
-
L:
|
|
5576
|
+
F: __dxlog_file19,
|
|
5577
|
+
L: 241,
|
|
5447
5578
|
S: this,
|
|
5448
5579
|
A: [
|
|
5449
5580
|
"this._storage",
|
|
@@ -5451,8 +5582,8 @@ var ClientServicesHost = class {
|
|
|
5451
5582
|
]
|
|
5452
5583
|
});
|
|
5453
5584
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5454
|
-
F:
|
|
5455
|
-
L:
|
|
5585
|
+
F: __dxlog_file19,
|
|
5586
|
+
L: 242,
|
|
5456
5587
|
S: this,
|
|
5457
5588
|
A: [
|
|
5458
5589
|
"this._signalManager",
|
|
@@ -5460,8 +5591,8 @@ var ClientServicesHost = class {
|
|
|
5460
5591
|
]
|
|
5461
5592
|
});
|
|
5462
5593
|
invariant16(this._networkManager, "network manager not set", {
|
|
5463
|
-
F:
|
|
5464
|
-
L:
|
|
5594
|
+
F: __dxlog_file19,
|
|
5595
|
+
L: 243,
|
|
5465
5596
|
S: this,
|
|
5466
5597
|
A: [
|
|
5467
5598
|
"this._networkManager",
|
|
@@ -5469,17 +5600,21 @@ var ClientServicesHost = class {
|
|
|
5469
5600
|
]
|
|
5470
5601
|
});
|
|
5471
5602
|
this._opening = true;
|
|
5472
|
-
|
|
5603
|
+
log16("opening...", {
|
|
5473
5604
|
lockKey: this._resourceLock?.lockKey
|
|
5474
5605
|
}, {
|
|
5475
|
-
F:
|
|
5476
|
-
L:
|
|
5606
|
+
F: __dxlog_file19,
|
|
5607
|
+
L: 246,
|
|
5477
5608
|
S: this,
|
|
5478
5609
|
C: (f, a) => f(...a)
|
|
5479
5610
|
});
|
|
5611
|
+
if (!this._level) {
|
|
5612
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5613
|
+
}
|
|
5614
|
+
await this._level.open();
|
|
5480
5615
|
await this._resourceLock?.acquire();
|
|
5481
5616
|
await this._loggingService.open();
|
|
5482
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5617
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5483
5618
|
this._serviceRegistry.setServices({
|
|
5484
5619
|
SystemService: this._systemService,
|
|
5485
5620
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
@@ -5506,8 +5641,8 @@ var ClientServicesHost = class {
|
|
|
5506
5641
|
});
|
|
5507
5642
|
await this._serviceContext.open(ctx);
|
|
5508
5643
|
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5509
|
-
F:
|
|
5510
|
-
L:
|
|
5644
|
+
F: __dxlog_file19,
|
|
5645
|
+
L: 314,
|
|
5511
5646
|
S: this,
|
|
5512
5647
|
A: [
|
|
5513
5648
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5515,11 +5650,11 @@ var ClientServicesHost = class {
|
|
|
5515
5650
|
]
|
|
5516
5651
|
});
|
|
5517
5652
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5518
|
-
|
|
5653
|
+
log16("loaded persistent invitations", {
|
|
5519
5654
|
count: loadedInvitations.invitations?.length
|
|
5520
5655
|
}, {
|
|
5521
|
-
F:
|
|
5522
|
-
L:
|
|
5656
|
+
F: __dxlog_file19,
|
|
5657
|
+
L: 317,
|
|
5523
5658
|
S: this,
|
|
5524
5659
|
C: (f, a) => f(...a)
|
|
5525
5660
|
});
|
|
@@ -5533,23 +5668,24 @@ var ClientServicesHost = class {
|
|
|
5533
5668
|
});
|
|
5534
5669
|
void this._devtoolsProxy.open();
|
|
5535
5670
|
}
|
|
5671
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5536
5672
|
this._opening = false;
|
|
5537
5673
|
this._open = true;
|
|
5538
5674
|
this._statusUpdate.emit();
|
|
5539
5675
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5540
|
-
|
|
5676
|
+
log16("opened", {
|
|
5541
5677
|
deviceKey
|
|
5542
5678
|
}, {
|
|
5543
|
-
F:
|
|
5544
|
-
L:
|
|
5679
|
+
F: __dxlog_file19,
|
|
5680
|
+
L: 335,
|
|
5545
5681
|
S: this,
|
|
5546
5682
|
C: (f, a) => f(...a)
|
|
5547
5683
|
});
|
|
5548
|
-
|
|
5684
|
+
log16.trace("dxos.client-services.host.open", trace9.end({
|
|
5549
5685
|
id: traceId
|
|
5550
5686
|
}), {
|
|
5551
|
-
F:
|
|
5552
|
-
L:
|
|
5687
|
+
F: __dxlog_file19,
|
|
5688
|
+
L: 336,
|
|
5553
5689
|
S: this,
|
|
5554
5690
|
C: (f, a) => f(...a)
|
|
5555
5691
|
});
|
|
@@ -5559,60 +5695,62 @@ var ClientServicesHost = class {
|
|
|
5559
5695
|
return;
|
|
5560
5696
|
}
|
|
5561
5697
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5562
|
-
|
|
5698
|
+
log16("closing...", {
|
|
5563
5699
|
deviceKey
|
|
5564
5700
|
}, {
|
|
5565
|
-
F:
|
|
5566
|
-
L:
|
|
5701
|
+
F: __dxlog_file19,
|
|
5702
|
+
L: 347,
|
|
5567
5703
|
S: this,
|
|
5568
5704
|
C: (f, a) => f(...a)
|
|
5569
5705
|
});
|
|
5706
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5570
5707
|
await this._devtoolsProxy?.close();
|
|
5571
5708
|
this._serviceRegistry.setServices({
|
|
5572
5709
|
SystemService: this._systemService
|
|
5573
5710
|
});
|
|
5574
5711
|
await this._loggingService.close();
|
|
5575
5712
|
await this._serviceContext.close();
|
|
5713
|
+
await this._level?.close();
|
|
5576
5714
|
this._open = false;
|
|
5577
5715
|
this._statusUpdate.emit();
|
|
5578
|
-
|
|
5716
|
+
log16("closed", {
|
|
5579
5717
|
deviceKey
|
|
5580
5718
|
}, {
|
|
5581
|
-
F:
|
|
5582
|
-
L:
|
|
5719
|
+
F: __dxlog_file19,
|
|
5720
|
+
L: 356,
|
|
5583
5721
|
S: this,
|
|
5584
5722
|
C: (f, a) => f(...a)
|
|
5585
5723
|
});
|
|
5586
5724
|
}
|
|
5587
5725
|
async reset() {
|
|
5588
|
-
const traceId =
|
|
5589
|
-
|
|
5726
|
+
const traceId = PublicKey13.random().toHex();
|
|
5727
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5590
5728
|
id: traceId
|
|
5591
5729
|
}), {
|
|
5592
|
-
F:
|
|
5593
|
-
L:
|
|
5730
|
+
F: __dxlog_file19,
|
|
5731
|
+
L: 361,
|
|
5594
5732
|
S: this,
|
|
5595
5733
|
C: (f, a) => f(...a)
|
|
5596
5734
|
});
|
|
5597
|
-
|
|
5598
|
-
F:
|
|
5599
|
-
L:
|
|
5735
|
+
log16("resetting...", void 0, {
|
|
5736
|
+
F: __dxlog_file19,
|
|
5737
|
+
L: 363,
|
|
5600
5738
|
S: this,
|
|
5601
5739
|
C: (f, a) => f(...a)
|
|
5602
5740
|
});
|
|
5603
5741
|
await this._serviceContext?.close();
|
|
5604
5742
|
await this._storage.reset();
|
|
5605
|
-
|
|
5606
|
-
F:
|
|
5607
|
-
L:
|
|
5743
|
+
log16("reset", void 0, {
|
|
5744
|
+
F: __dxlog_file19,
|
|
5745
|
+
L: 366,
|
|
5608
5746
|
S: this,
|
|
5609
5747
|
C: (f, a) => f(...a)
|
|
5610
5748
|
});
|
|
5611
|
-
|
|
5749
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.end({
|
|
5612
5750
|
id: traceId
|
|
5613
5751
|
}), {
|
|
5614
|
-
F:
|
|
5615
|
-
L:
|
|
5752
|
+
F: __dxlog_file19,
|
|
5753
|
+
L: 367,
|
|
5616
5754
|
S: this,
|
|
5617
5755
|
C: (f, a) => f(...a)
|
|
5618
5756
|
});
|
|
@@ -5622,12 +5760,10 @@ var ClientServicesHost = class {
|
|
|
5622
5760
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5623
5761
|
await this._serviceContext.initialized.wait();
|
|
5624
5762
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5625
|
-
const obj = new Properties(void 0);
|
|
5626
|
-
obj[defaultKey] = identity.identityKey.toHex();
|
|
5627
5763
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5628
5764
|
invariant16(automergeIndex, void 0, {
|
|
5629
|
-
F:
|
|
5630
|
-
L:
|
|
5765
|
+
F: __dxlog_file19,
|
|
5766
|
+
L: 379,
|
|
5631
5767
|
S: this,
|
|
5632
5768
|
A: [
|
|
5633
5769
|
"automergeIndex",
|
|
@@ -5636,12 +5772,25 @@ var ClientServicesHost = class {
|
|
|
5636
5772
|
});
|
|
5637
5773
|
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5638
5774
|
await document.whenReady();
|
|
5775
|
+
const properties = {
|
|
5776
|
+
system: {
|
|
5777
|
+
type: encodeReference(E.getTypeReference(Properties))
|
|
5778
|
+
},
|
|
5779
|
+
data: {
|
|
5780
|
+
[defaultKey]: identity.identityKey.toHex()
|
|
5781
|
+
},
|
|
5782
|
+
meta: {
|
|
5783
|
+
keys: []
|
|
5784
|
+
}
|
|
5785
|
+
};
|
|
5786
|
+
const propertiesId = PublicKey13.random().toHex();
|
|
5639
5787
|
document.change((doc) => {
|
|
5640
5788
|
assignDeep2(doc, [
|
|
5641
5789
|
"objects",
|
|
5642
|
-
|
|
5643
|
-
],
|
|
5790
|
+
propertiesId
|
|
5791
|
+
], properties);
|
|
5644
5792
|
});
|
|
5793
|
+
await this._serviceContext.automergeHost.repo.flush();
|
|
5645
5794
|
return identity;
|
|
5646
5795
|
}
|
|
5647
5796
|
};
|
|
@@ -5663,6 +5812,44 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5663
5812
|
Trace3.resource()
|
|
5664
5813
|
], ClientServicesHost);
|
|
5665
5814
|
|
|
5815
|
+
// packages/sdk/client-services/src/packlets/services/util.ts
|
|
5816
|
+
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
5817
|
+
import { humanize } from "@dxos/util";
|
|
5818
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5819
|
+
|
|
5820
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
5821
|
+
var DiagnosticsCollector = class {
|
|
5822
|
+
static {
|
|
5823
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5824
|
+
}
|
|
5825
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5826
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5827
|
+
keys: options.humanize ? GetDiagnosticsRequest2.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest2.KEY_OPTION.TRUNCATE : void 0
|
|
5828
|
+
});
|
|
5829
|
+
const clientDiagnostics = {
|
|
5830
|
+
config,
|
|
5831
|
+
trace: TRACE_PROCESSOR3.getDiagnostics()
|
|
5832
|
+
};
|
|
5833
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5834
|
+
client: clientDiagnostics,
|
|
5835
|
+
services: serviceDiagnostics
|
|
5836
|
+
} : {
|
|
5837
|
+
client: clientDiagnostics,
|
|
5838
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5839
|
+
};
|
|
5840
|
+
return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer2(options)));
|
|
5841
|
+
}
|
|
5842
|
+
};
|
|
5843
|
+
var findSystemServiceProvider = () => {
|
|
5844
|
+
const serviceProviders = TRACE_PROCESSOR3.findByAnnotation(ClientServicesProviderResource);
|
|
5845
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5846
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5847
|
+
};
|
|
5848
|
+
var findConfigs = () => {
|
|
5849
|
+
const configs = TRACE_PROCESSOR3.findByAnnotation(ConfigResource);
|
|
5850
|
+
return configs.map((r) => r.instance.deref()).filter(nonNullable);
|
|
5851
|
+
};
|
|
5852
|
+
|
|
5666
5853
|
export {
|
|
5667
5854
|
Buffer,
|
|
5668
5855
|
subscribeToFeeds,
|
|
@@ -5686,15 +5873,20 @@ export {
|
|
|
5686
5873
|
InvitationsServiceImpl,
|
|
5687
5874
|
SpaceInvitationProtocol,
|
|
5688
5875
|
ClientRpcServer,
|
|
5689
|
-
createDiagnostics,
|
|
5690
5876
|
DataSpace,
|
|
5691
5877
|
DataSpaceManager,
|
|
5692
5878
|
SpacesServiceImpl,
|
|
5693
5879
|
ServiceContext,
|
|
5694
5880
|
ServiceRegistry,
|
|
5881
|
+
createDiagnostics,
|
|
5882
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5883
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5884
|
+
DiagnosticsCollector,
|
|
5695
5885
|
Lock,
|
|
5696
5886
|
isLocked,
|
|
5697
5887
|
createStorageObjects,
|
|
5698
|
-
|
|
5888
|
+
createLevel,
|
|
5889
|
+
ClientServicesHost,
|
|
5890
|
+
ClientServicesProviderResource
|
|
5699
5891
|
};
|
|
5700
|
-
//# sourceMappingURL=chunk-
|
|
5892
|
+
//# sourceMappingURL=chunk-H2TNTLUE.mjs.map
|