@dxos/client-services 0.4.9 → 0.4.10-main.06ef97a
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-RQ33OGAG.mjs → chunk-XCFXYSCO.mjs} +788 -531
- package/dist/lib/browser/chunk-XCFXYSCO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +58 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +6 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-CBSM4HU4.cjs → chunk-ENGA4MHO.cjs} +726 -556
- package/dist/lib/node/chunk-ENGA4MHO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +95 -57
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +10 -8
- 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 +2 -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/spaces/data-space.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 +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +5 -5
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -0
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +2 -0
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +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/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +5 -5
- package/src/packlets/services/service-context.ts +13 -8
- package/src/packlets/services/service-host.ts +41 -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.ts +51 -2
- 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 +5 -3
- package/src/packlets/vault/shared-worker-connection.ts +3 -8
- package/src/packlets/vault/worker-runtime.ts +27 -2
- package/src/packlets/vault/worker-session.ts +6 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-RQ33OGAG.mjs.map +0 -7
- package/dist/lib/node/chunk-CBSM4HU4.cjs.map +0 -7
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
|
@@ -2730,163 +2730,15 @@ 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.9";
|
|
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";
|
|
2886
2736
|
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2887
2737
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2738
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2888
2739
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2889
|
-
import {
|
|
2740
|
+
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
2741
|
+
import { failedInvariant, invariant as invariant10 } from "@dxos/invariant";
|
|
2890
2742
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2891
2743
|
import { log as log9 } from "@dxos/log";
|
|
2892
2744
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -2894,7 +2746,7 @@ import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/clien
|
|
|
2894
2746
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
2895
2747
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
2896
2748
|
import { trace as trace6 } from "@dxos/tracing";
|
|
2897
|
-
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
2749
|
+
import { ComplexSet as ComplexSet3, assignDeep } from "@dxos/util";
|
|
2898
2750
|
|
|
2899
2751
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2900
2752
|
import { Event as Event4 } from "@dxos/async";
|
|
@@ -2937,13 +2789,13 @@ var AutomergeSpaceState = class {
|
|
|
2937
2789
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2938
2790
|
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2939
2791
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2940
|
-
import { invariant as
|
|
2792
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2941
2793
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2942
2794
|
import { log as log8 } from "@dxos/log";
|
|
2943
2795
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2944
2796
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2945
2797
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
2946
|
-
var
|
|
2798
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2947
2799
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2948
2800
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2949
2801
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2971,13 +2823,13 @@ var NotarizationPlugin = class {
|
|
|
2971
2823
|
log8("notarize", {
|
|
2972
2824
|
credentials
|
|
2973
2825
|
}, {
|
|
2974
|
-
F:
|
|
2826
|
+
F: __dxlog_file10,
|
|
2975
2827
|
L: 90,
|
|
2976
2828
|
S: this,
|
|
2977
2829
|
C: (f, a) => f(...a)
|
|
2978
2830
|
});
|
|
2979
|
-
|
|
2980
|
-
F:
|
|
2831
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2832
|
+
F: __dxlog_file10,
|
|
2981
2833
|
L: 91,
|
|
2982
2834
|
S: this,
|
|
2983
2835
|
A: [
|
|
@@ -2991,7 +2843,7 @@ var NotarizationPlugin = class {
|
|
|
2991
2843
|
log8.warn("Notarization error", {
|
|
2992
2844
|
err
|
|
2993
2845
|
}, {
|
|
2994
|
-
F:
|
|
2846
|
+
F: __dxlog_file10,
|
|
2995
2847
|
L: 99,
|
|
2996
2848
|
S: this,
|
|
2997
2849
|
C: (f, a) => f(...a)
|
|
@@ -3007,7 +2859,7 @@ var NotarizationPlugin = class {
|
|
|
3007
2859
|
timeout,
|
|
3008
2860
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3009
2861
|
}, {
|
|
3010
|
-
F:
|
|
2862
|
+
F: __dxlog_file10,
|
|
3011
2863
|
L: 111,
|
|
3012
2864
|
S: this,
|
|
3013
2865
|
C: (f, a) => f(...a)
|
|
@@ -3030,7 +2882,7 @@ var NotarizationPlugin = class {
|
|
|
3030
2882
|
log8.info("Exhausted all peers to notarize with", {
|
|
3031
2883
|
retryIn: retryTimeout
|
|
3032
2884
|
}, {
|
|
3033
|
-
F:
|
|
2885
|
+
F: __dxlog_file10,
|
|
3034
2886
|
L: 136,
|
|
3035
2887
|
S: this,
|
|
3036
2888
|
C: (f, a) => f(...a)
|
|
@@ -3044,7 +2896,7 @@ var NotarizationPlugin = class {
|
|
|
3044
2896
|
peer: peer.localPeerId,
|
|
3045
2897
|
credentialId: credentials.map((credential) => credential.id)
|
|
3046
2898
|
}, {
|
|
3047
|
-
F:
|
|
2899
|
+
F: __dxlog_file10,
|
|
3048
2900
|
L: 143,
|
|
3049
2901
|
S: this,
|
|
3050
2902
|
C: (f, a) => f(...a)
|
|
@@ -3053,7 +2905,7 @@ var NotarizationPlugin = class {
|
|
|
3053
2905
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3054
2906
|
});
|
|
3055
2907
|
log8("success", void 0, {
|
|
3056
|
-
F:
|
|
2908
|
+
F: __dxlog_file10,
|
|
3057
2909
|
L: 147,
|
|
3058
2910
|
S: this,
|
|
3059
2911
|
C: (f, a) => f(...a)
|
|
@@ -3062,7 +2914,7 @@ var NotarizationPlugin = class {
|
|
|
3062
2914
|
} catch (err) {
|
|
3063
2915
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3064
2916
|
log8.info("error notarizing (recoverable)", err, {
|
|
3065
|
-
F:
|
|
2917
|
+
F: __dxlog_file10,
|
|
3066
2918
|
L: 151,
|
|
3067
2919
|
S: this,
|
|
3068
2920
|
C: (f, a) => f(...a)
|
|
@@ -3080,7 +2932,7 @@ var NotarizationPlugin = class {
|
|
|
3080
2932
|
errors.wait()
|
|
3081
2933
|
]);
|
|
3082
2934
|
log8("done", void 0, {
|
|
3083
|
-
F:
|
|
2935
|
+
F: __dxlog_file10,
|
|
3084
2936
|
L: 162,
|
|
3085
2937
|
S: this,
|
|
3086
2938
|
C: (f, a) => f(...a)
|
|
@@ -3101,8 +2953,8 @@ var NotarizationPlugin = class {
|
|
|
3101
2953
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3102
2954
|
}
|
|
3103
2955
|
setWriter(writer) {
|
|
3104
|
-
|
|
3105
|
-
F:
|
|
2956
|
+
invariant9(!this._writer, "Writer already set.", {
|
|
2957
|
+
F: __dxlog_file10,
|
|
3106
2958
|
L: 181,
|
|
3107
2959
|
S: this,
|
|
3108
2960
|
A: [
|
|
@@ -3126,8 +2978,8 @@ var NotarizationPlugin = class {
|
|
|
3126
2978
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3127
2979
|
}
|
|
3128
2980
|
for (const credential of request.credentials ?? []) {
|
|
3129
|
-
|
|
3130
|
-
F:
|
|
2981
|
+
invariant9(credential.id, "Credential must have an id", {
|
|
2982
|
+
F: __dxlog_file10,
|
|
3131
2983
|
L: 200,
|
|
3132
2984
|
S: this,
|
|
3133
2985
|
A: [
|
|
@@ -3147,7 +2999,7 @@ var NotarizationPlugin = class {
|
|
|
3147
2999
|
log8("extension opened", {
|
|
3148
3000
|
peer: extension.localPeerId
|
|
3149
3001
|
}, {
|
|
3150
|
-
F:
|
|
3002
|
+
F: __dxlog_file10,
|
|
3151
3003
|
L: 211,
|
|
3152
3004
|
S: this,
|
|
3153
3005
|
C: (f, a) => f(...a)
|
|
@@ -3159,7 +3011,7 @@ var NotarizationPlugin = class {
|
|
|
3159
3011
|
log8("extension closed", {
|
|
3160
3012
|
peer: extension.localPeerId
|
|
3161
3013
|
}, {
|
|
3162
|
-
F:
|
|
3014
|
+
F: __dxlog_file10,
|
|
3163
3015
|
L: 216,
|
|
3164
3016
|
S: this,
|
|
3165
3017
|
C: (f, a) => f(...a)
|
|
@@ -3213,7 +3065,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3213
3065
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3214
3066
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3215
3067
|
}
|
|
3216
|
-
var
|
|
3068
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3217
3069
|
var DataSpace = class {
|
|
3218
3070
|
constructor(params) {
|
|
3219
3071
|
this._ctx = new Context8();
|
|
@@ -3248,8 +3100,8 @@ var DataSpace = class {
|
|
|
3248
3100
|
log9("new state", {
|
|
3249
3101
|
state: SpaceState[this._state]
|
|
3250
3102
|
}, {
|
|
3251
|
-
F:
|
|
3252
|
-
L:
|
|
3103
|
+
F: __dxlog_file11,
|
|
3104
|
+
L: 140,
|
|
3253
3105
|
S: this,
|
|
3254
3106
|
C: (f, a) => f(...a)
|
|
3255
3107
|
});
|
|
@@ -3298,8 +3150,8 @@ var DataSpace = class {
|
|
|
3298
3150
|
log9("new state", {
|
|
3299
3151
|
state: SpaceState[this._state]
|
|
3300
3152
|
}, {
|
|
3301
|
-
F:
|
|
3302
|
-
L:
|
|
3153
|
+
F: __dxlog_file11,
|
|
3154
|
+
L: 198,
|
|
3303
3155
|
S: this,
|
|
3304
3156
|
C: (f, a) => f(...a)
|
|
3305
3157
|
});
|
|
@@ -3316,8 +3168,8 @@ var DataSpace = class {
|
|
|
3316
3168
|
log9("new state", {
|
|
3317
3169
|
state: SpaceState[this._state]
|
|
3318
3170
|
}, {
|
|
3319
|
-
F:
|
|
3320
|
-
L:
|
|
3171
|
+
F: __dxlog_file11,
|
|
3172
|
+
L: 212,
|
|
3321
3173
|
S: this,
|
|
3322
3174
|
C: (f, a) => f(...a)
|
|
3323
3175
|
});
|
|
@@ -3348,16 +3200,16 @@ var DataSpace = class {
|
|
|
3348
3200
|
} catch (err) {
|
|
3349
3201
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3350
3202
|
log9("data pipeline initialization cancelled", err, {
|
|
3351
|
-
F:
|
|
3352
|
-
L:
|
|
3203
|
+
F: __dxlog_file11,
|
|
3204
|
+
L: 245,
|
|
3353
3205
|
S: this,
|
|
3354
3206
|
C: (f, a) => f(...a)
|
|
3355
3207
|
});
|
|
3356
3208
|
return;
|
|
3357
3209
|
}
|
|
3358
3210
|
log9.error("Error initializing data pipeline", err, {
|
|
3359
|
-
F:
|
|
3360
|
-
L:
|
|
3211
|
+
F: __dxlog_file11,
|
|
3212
|
+
L: 249,
|
|
3361
3213
|
S: this,
|
|
3362
3214
|
C: (f, a) => f(...a)
|
|
3363
3215
|
});
|
|
@@ -3365,8 +3217,8 @@ var DataSpace = class {
|
|
|
3365
3217
|
log9("new state", {
|
|
3366
3218
|
state: SpaceState[this._state]
|
|
3367
3219
|
}, {
|
|
3368
|
-
F:
|
|
3369
|
-
L:
|
|
3220
|
+
F: __dxlog_file11,
|
|
3221
|
+
L: 251,
|
|
3370
3222
|
S: this,
|
|
3371
3223
|
C: (f, a) => f(...a)
|
|
3372
3224
|
});
|
|
@@ -3385,8 +3237,8 @@ var DataSpace = class {
|
|
|
3385
3237
|
log9("new state", {
|
|
3386
3238
|
state: SpaceState[this._state]
|
|
3387
3239
|
}, {
|
|
3388
|
-
F:
|
|
3389
|
-
L:
|
|
3240
|
+
F: __dxlog_file11,
|
|
3241
|
+
L: 267,
|
|
3390
3242
|
S: this,
|
|
3391
3243
|
C: (f, a) => f(...a)
|
|
3392
3244
|
});
|
|
@@ -3395,8 +3247,8 @@ var DataSpace = class {
|
|
|
3395
3247
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3396
3248
|
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3397
3249
|
log9("data pipeline ready", void 0, {
|
|
3398
|
-
F:
|
|
3399
|
-
L:
|
|
3250
|
+
F: __dxlog_file11,
|
|
3251
|
+
L: 279,
|
|
3400
3252
|
S: this,
|
|
3401
3253
|
C: (f, a) => f(...a)
|
|
3402
3254
|
});
|
|
@@ -3405,8 +3257,8 @@ var DataSpace = class {
|
|
|
3405
3257
|
log9("new state", {
|
|
3406
3258
|
state: SpaceState[this._state]
|
|
3407
3259
|
}, {
|
|
3408
|
-
F:
|
|
3409
|
-
L:
|
|
3260
|
+
F: __dxlog_file11,
|
|
3261
|
+
L: 283,
|
|
3410
3262
|
S: this,
|
|
3411
3263
|
C: (f, a) => f(...a)
|
|
3412
3264
|
});
|
|
@@ -3421,8 +3273,8 @@ var DataSpace = class {
|
|
|
3421
3273
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3422
3274
|
await this._createWritableFeeds();
|
|
3423
3275
|
log9("writable feeds created", void 0, {
|
|
3424
|
-
F:
|
|
3425
|
-
L:
|
|
3276
|
+
F: __dxlog_file11,
|
|
3277
|
+
L: 299,
|
|
3426
3278
|
S: this,
|
|
3427
3279
|
C: (f, a) => f(...a)
|
|
3428
3280
|
});
|
|
@@ -3484,8 +3336,8 @@ var DataSpace = class {
|
|
|
3484
3336
|
space: this.key,
|
|
3485
3337
|
rootUrl
|
|
3486
3338
|
}, {
|
|
3487
|
-
F:
|
|
3488
|
-
L:
|
|
3339
|
+
F: __dxlog_file11,
|
|
3340
|
+
L: 365,
|
|
3489
3341
|
S: this,
|
|
3490
3342
|
C: (f, a) => f(...a)
|
|
3491
3343
|
});
|
|
@@ -3516,8 +3368,8 @@ var DataSpace = class {
|
|
|
3516
3368
|
rootUrl,
|
|
3517
3369
|
err
|
|
3518
3370
|
}, {
|
|
3519
|
-
F:
|
|
3520
|
-
L:
|
|
3371
|
+
F: __dxlog_file11,
|
|
3372
|
+
L: 388,
|
|
3521
3373
|
S: this,
|
|
3522
3374
|
C: (f, a) => f(...a)
|
|
3523
3375
|
});
|
|
@@ -3570,15 +3422,75 @@ var DataSpace = class {
|
|
|
3570
3422
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3571
3423
|
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3572
3424
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3573
|
-
|
|
3574
|
-
F:
|
|
3575
|
-
L:
|
|
3425
|
+
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3426
|
+
F: __dxlog_file11,
|
|
3427
|
+
L: 438,
|
|
3428
|
+
S: this,
|
|
3429
|
+
A: [
|
|
3430
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3431
|
+
""
|
|
3432
|
+
]
|
|
3433
|
+
});
|
|
3434
|
+
epoch = {
|
|
3435
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3436
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3437
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
|
|
3438
|
+
automergeRoot: newRoot.url
|
|
3439
|
+
};
|
|
3440
|
+
}
|
|
3441
|
+
break;
|
|
3442
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3443
|
+
{
|
|
3444
|
+
log9.info("Fragmenting", void 0, {
|
|
3445
|
+
F: __dxlog_file11,
|
|
3446
|
+
L: 450,
|
|
3447
|
+
S: this,
|
|
3448
|
+
C: (f, a) => f(...a)
|
|
3449
|
+
});
|
|
3450
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3451
|
+
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3452
|
+
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3453
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3454
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === TYPE_PROPERTIES);
|
|
3455
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3456
|
+
invariant10(properties, "Properties not found", {
|
|
3457
|
+
F: __dxlog_file11,
|
|
3458
|
+
L: 460,
|
|
3459
|
+
S: this,
|
|
3460
|
+
A: [
|
|
3461
|
+
"properties",
|
|
3462
|
+
"'Properties not found'"
|
|
3463
|
+
]
|
|
3464
|
+
});
|
|
3465
|
+
const newSpaceDoc = {
|
|
3466
|
+
...rootHandle.docSync(),
|
|
3467
|
+
objects: Object.fromEntries([
|
|
3468
|
+
properties
|
|
3469
|
+
])
|
|
3470
|
+
};
|
|
3471
|
+
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3472
|
+
invariant10(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3473
|
+
F: __dxlog_file11,
|
|
3474
|
+
L: 465,
|
|
3576
3475
|
S: this,
|
|
3577
3476
|
A: [
|
|
3578
3477
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3579
3478
|
""
|
|
3580
3479
|
]
|
|
3581
3480
|
});
|
|
3481
|
+
const docLoader = new AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3482
|
+
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3483
|
+
rootUrl: newRoot.url
|
|
3484
|
+
});
|
|
3485
|
+
otherObjects.forEach(([key, value]) => {
|
|
3486
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3487
|
+
handle.change((doc) => {
|
|
3488
|
+
assignDeep(doc, [
|
|
3489
|
+
"objects",
|
|
3490
|
+
key
|
|
3491
|
+
], value);
|
|
3492
|
+
});
|
|
3493
|
+
});
|
|
3582
3494
|
epoch = {
|
|
3583
3495
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3584
3496
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3627,8 +3539,8 @@ var DataSpace = class {
|
|
|
3627
3539
|
log9("new state", {
|
|
3628
3540
|
state: SpaceState[this._state]
|
|
3629
3541
|
}, {
|
|
3630
|
-
F:
|
|
3631
|
-
L:
|
|
3542
|
+
F: __dxlog_file11,
|
|
3543
|
+
L: 531,
|
|
3632
3544
|
S: this,
|
|
3633
3545
|
C: (f, a) => f(...a)
|
|
3634
3546
|
});
|
|
@@ -3685,7 +3597,7 @@ DataSpace = _ts_decorate4([
|
|
|
3685
3597
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3686
3598
|
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3687
3599
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3688
|
-
import { invariant as
|
|
3600
|
+
import { invariant as invariant11 } from "@dxos/invariant";
|
|
3689
3601
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3690
3602
|
import { log as log10 } from "@dxos/log";
|
|
3691
3603
|
import { trace as trace7 } from "@dxos/protocols";
|
|
@@ -3696,7 +3608,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsyn
|
|
|
3696
3608
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
3697
3609
|
import { createCredential } from "@dxos/credentials";
|
|
3698
3610
|
import { failUndefined } from "@dxos/debug";
|
|
3699
|
-
import { AdmittedFeed as AdmittedFeed4, SpaceMember
|
|
3611
|
+
import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3700
3612
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3701
3613
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3702
3614
|
const credentials = [
|
|
@@ -3716,7 +3628,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3716
3628
|
assertion: {
|
|
3717
3629
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3718
3630
|
spaceKey: space.key,
|
|
3719
|
-
role:
|
|
3631
|
+
role: SpaceMember.Role.ADMIN,
|
|
3720
3632
|
profile: signingContext.getProfile(),
|
|
3721
3633
|
genesisFeedKey: space.controlFeedKey ?? failUndefined()
|
|
3722
3634
|
}
|
|
@@ -3774,7 +3686,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3774
3686
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3775
3687
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3776
3688
|
}
|
|
3777
|
-
var
|
|
3689
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3778
3690
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3779
3691
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3780
3692
|
var DataSpaceManager = class {
|
|
@@ -3800,7 +3712,7 @@ var DataSpaceManager = class {
|
|
|
3800
3712
|
}
|
|
3801
3713
|
async open() {
|
|
3802
3714
|
log10("open", void 0, {
|
|
3803
|
-
F:
|
|
3715
|
+
F: __dxlog_file12,
|
|
3804
3716
|
L: 98,
|
|
3805
3717
|
S: this,
|
|
3806
3718
|
C: (f, a) => f(...a)
|
|
@@ -3808,7 +3720,7 @@ var DataSpaceManager = class {
|
|
|
3808
3720
|
log10.trace("dxos.echo.data-space-manager.open", trace7.begin({
|
|
3809
3721
|
id: this._instanceId
|
|
3810
3722
|
}), {
|
|
3811
|
-
F:
|
|
3723
|
+
F: __dxlog_file12,
|
|
3812
3724
|
L: 99,
|
|
3813
3725
|
S: this,
|
|
3814
3726
|
C: (f, a) => f(...a)
|
|
@@ -3816,7 +3728,7 @@ var DataSpaceManager = class {
|
|
|
3816
3728
|
log10("metadata loaded", {
|
|
3817
3729
|
spaces: this._metadataStore.spaces.length
|
|
3818
3730
|
}, {
|
|
3819
|
-
F:
|
|
3731
|
+
F: __dxlog_file12,
|
|
3820
3732
|
L: 100,
|
|
3821
3733
|
S: this,
|
|
3822
3734
|
C: (f, a) => f(...a)
|
|
@@ -3826,7 +3738,7 @@ var DataSpaceManager = class {
|
|
|
3826
3738
|
log10("load space", {
|
|
3827
3739
|
spaceMetadata
|
|
3828
3740
|
}, {
|
|
3829
|
-
F:
|
|
3741
|
+
F: __dxlog_file12,
|
|
3830
3742
|
L: 104,
|
|
3831
3743
|
S: this,
|
|
3832
3744
|
C: (f, a) => f(...a)
|
|
@@ -3837,7 +3749,7 @@ var DataSpaceManager = class {
|
|
|
3837
3749
|
spaceMetadata,
|
|
3838
3750
|
err
|
|
3839
3751
|
}, {
|
|
3840
|
-
F:
|
|
3752
|
+
F: __dxlog_file12,
|
|
3841
3753
|
L: 107,
|
|
3842
3754
|
S: this,
|
|
3843
3755
|
C: (f, a) => f(...a)
|
|
@@ -3854,7 +3766,7 @@ var DataSpaceManager = class {
|
|
|
3854
3766
|
log10.trace("dxos.echo.data-space-manager.open", trace7.end({
|
|
3855
3767
|
id: this._instanceId
|
|
3856
3768
|
}), {
|
|
3857
|
-
F:
|
|
3769
|
+
F: __dxlog_file12,
|
|
3858
3770
|
L: 120,
|
|
3859
3771
|
S: this,
|
|
3860
3772
|
C: (f, a) => f(...a)
|
|
@@ -3862,7 +3774,7 @@ var DataSpaceManager = class {
|
|
|
3862
3774
|
}
|
|
3863
3775
|
async close() {
|
|
3864
3776
|
log10("close", void 0, {
|
|
3865
|
-
F:
|
|
3777
|
+
F: __dxlog_file12,
|
|
3866
3778
|
L: 125,
|
|
3867
3779
|
S: this,
|
|
3868
3780
|
C: (f, a) => f(...a)
|
|
@@ -3877,8 +3789,8 @@ var DataSpaceManager = class {
|
|
|
3877
3789
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3878
3790
|
*/
|
|
3879
3791
|
async createSpace() {
|
|
3880
|
-
|
|
3881
|
-
F:
|
|
3792
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3793
|
+
F: __dxlog_file12,
|
|
3882
3794
|
L: 138,
|
|
3883
3795
|
S: this,
|
|
3884
3796
|
A: [
|
|
@@ -3899,7 +3811,7 @@ var DataSpaceManager = class {
|
|
|
3899
3811
|
log10("creating space...", {
|
|
3900
3812
|
spaceKey
|
|
3901
3813
|
}, {
|
|
3902
|
-
F:
|
|
3814
|
+
F: __dxlog_file12,
|
|
3903
3815
|
L: 150,
|
|
3904
3816
|
S: this,
|
|
3905
3817
|
C: (f, a) => f(...a)
|
|
@@ -3914,8 +3826,8 @@ var DataSpaceManager = class {
|
|
|
3914
3826
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3915
3827
|
await this._metadataStore.addSpace(metadata);
|
|
3916
3828
|
const memberCredential = credentials[1];
|
|
3917
|
-
|
|
3918
|
-
F:
|
|
3829
|
+
invariant11(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3830
|
+
F: __dxlog_file12,
|
|
3919
3831
|
L: 163,
|
|
3920
3832
|
S: this,
|
|
3921
3833
|
A: [
|
|
@@ -3933,13 +3845,13 @@ var DataSpaceManager = class {
|
|
|
3933
3845
|
log10("accept space", {
|
|
3934
3846
|
opts
|
|
3935
3847
|
}, {
|
|
3936
|
-
F:
|
|
3848
|
+
F: __dxlog_file12,
|
|
3937
3849
|
L: 175,
|
|
3938
3850
|
S: this,
|
|
3939
3851
|
C: (f, a) => f(...a)
|
|
3940
3852
|
});
|
|
3941
|
-
|
|
3942
|
-
F:
|
|
3853
|
+
invariant11(this._isOpen, "Not open.", {
|
|
3854
|
+
F: __dxlog_file12,
|
|
3943
3855
|
L: 176,
|
|
3944
3856
|
S: this,
|
|
3945
3857
|
A: [
|
|
@@ -3947,8 +3859,8 @@ var DataSpaceManager = class {
|
|
|
3947
3859
|
"'Not open.'"
|
|
3948
3860
|
]
|
|
3949
3861
|
});
|
|
3950
|
-
|
|
3951
|
-
F:
|
|
3862
|
+
invariant11(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3863
|
+
F: __dxlog_file12,
|
|
3952
3864
|
L: 177,
|
|
3953
3865
|
S: this,
|
|
3954
3866
|
A: [
|
|
@@ -3983,7 +3895,7 @@ var DataSpaceManager = class {
|
|
|
3983
3895
|
log10("construct space", {
|
|
3984
3896
|
metadata
|
|
3985
3897
|
}, {
|
|
3986
|
-
F:
|
|
3898
|
+
F: __dxlog_file12,
|
|
3987
3899
|
L: 210,
|
|
3988
3900
|
S: this,
|
|
3989
3901
|
C: (f, a) => f(...a)
|
|
@@ -4021,7 +3933,7 @@ var DataSpaceManager = class {
|
|
|
4021
3933
|
},
|
|
4022
3934
|
onAuthFailure: () => {
|
|
4023
3935
|
log10.warn("auth failure", void 0, {
|
|
4024
|
-
F:
|
|
3936
|
+
F: __dxlog_file12,
|
|
4025
3937
|
L: 247,
|
|
4026
3938
|
S: this,
|
|
4027
3939
|
C: (f, a) => f(...a)
|
|
@@ -4045,7 +3957,7 @@ var DataSpaceManager = class {
|
|
|
4045
3957
|
log10("before space ready", {
|
|
4046
3958
|
space: space.key
|
|
4047
3959
|
}, {
|
|
4048
|
-
F:
|
|
3960
|
+
F: __dxlog_file12,
|
|
4049
3961
|
L: 265,
|
|
4050
3962
|
S: this,
|
|
4051
3963
|
C: (f, a) => f(...a)
|
|
@@ -4056,7 +3968,7 @@ var DataSpaceManager = class {
|
|
|
4056
3968
|
space: space.key,
|
|
4057
3969
|
open: this._isOpen
|
|
4058
3970
|
}, {
|
|
4059
|
-
F:
|
|
3971
|
+
F: __dxlog_file12,
|
|
4060
3972
|
L: 268,
|
|
4061
3973
|
S: this,
|
|
4062
3974
|
C: (f, a) => f(...a)
|
|
@@ -4069,7 +3981,7 @@ var DataSpaceManager = class {
|
|
|
4069
3981
|
log10("before space close", {
|
|
4070
3982
|
space: space.key
|
|
4071
3983
|
}, {
|
|
4072
|
-
F:
|
|
3984
|
+
F: __dxlog_file12,
|
|
4073
3985
|
L: 274,
|
|
4074
3986
|
S: this,
|
|
4075
3987
|
C: (f, a) => f(...a)
|
|
@@ -4109,11 +4021,11 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4109
4021
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
4110
4022
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4111
4023
|
import { raise as raise2 } from "@dxos/debug";
|
|
4112
|
-
import { invariant as
|
|
4024
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4113
4025
|
import { log as log11 } from "@dxos/log";
|
|
4114
4026
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4115
|
-
import { SpaceMember as
|
|
4116
|
-
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";
|
|
4117
4029
|
var SpacesServiceImpl = class {
|
|
4118
4030
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4119
4031
|
this._identityManager = _identityManager;
|
|
@@ -4152,7 +4064,7 @@ var SpacesServiceImpl = class {
|
|
|
4152
4064
|
log11("update", {
|
|
4153
4065
|
spaces
|
|
4154
4066
|
}, {
|
|
4155
|
-
F:
|
|
4067
|
+
F: __dxlog_file13,
|
|
4156
4068
|
L: 77,
|
|
4157
4069
|
S: this,
|
|
4158
4070
|
C: (f, a) => f(...a)
|
|
@@ -4234,8 +4146,8 @@ var SpacesServiceImpl = class {
|
|
|
4234
4146
|
}
|
|
4235
4147
|
});
|
|
4236
4148
|
} else {
|
|
4237
|
-
|
|
4238
|
-
F:
|
|
4149
|
+
invariant12(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4150
|
+
F: __dxlog_file13,
|
|
4239
4151
|
L: 164,
|
|
4240
4152
|
S: this,
|
|
4241
4153
|
A: [
|
|
@@ -4243,8 +4155,8 @@ var SpacesServiceImpl = class {
|
|
|
4243
4155
|
"'Id on unsigned credentials is not allowed'"
|
|
4244
4156
|
]
|
|
4245
4157
|
});
|
|
4246
|
-
|
|
4247
|
-
F:
|
|
4158
|
+
invariant12(this._identityManager.identity, "Identity is not available", {
|
|
4159
|
+
F: __dxlog_file13,
|
|
4248
4160
|
L: 165,
|
|
4249
4161
|
S: this,
|
|
4250
4162
|
A: [
|
|
@@ -4253,8 +4165,8 @@ var SpacesServiceImpl = class {
|
|
|
4253
4165
|
]
|
|
4254
4166
|
});
|
|
4255
4167
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4256
|
-
|
|
4257
|
-
F:
|
|
4168
|
+
invariant12(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4169
|
+
F: __dxlog_file13,
|
|
4258
4170
|
L: 167,
|
|
4259
4171
|
S: this,
|
|
4260
4172
|
A: [
|
|
@@ -4310,7 +4222,7 @@ var SpacesServiceImpl = class {
|
|
|
4310
4222
|
identityKey: member.key,
|
|
4311
4223
|
profile: member.profile ?? {}
|
|
4312
4224
|
},
|
|
4313
|
-
presence: member.removed ?
|
|
4225
|
+
presence: member.removed ? SpaceMember2.PresenceState.REMOVED : isMe || peers.length > 0 ? SpaceMember2.PresenceState.ONLINE : SpaceMember2.PresenceState.OFFLINE,
|
|
4314
4226
|
peerStates: peers
|
|
4315
4227
|
};
|
|
4316
4228
|
}),
|
|
@@ -4324,17 +4236,17 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4324
4236
|
|
|
4325
4237
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4326
4238
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4327
|
-
import { Context as Context10 } from "@dxos/context";
|
|
4239
|
+
import { Context as Context10, Resource } from "@dxos/context";
|
|
4328
4240
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4329
4241
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4330
4242
|
import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4331
4243
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4332
4244
|
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4333
|
-
import { invariant as
|
|
4245
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4334
4246
|
import { Keyring } from "@dxos/keyring";
|
|
4335
4247
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4336
4248
|
import { log as log12 } from "@dxos/log";
|
|
4337
|
-
import { InvalidStorageVersionError, STORAGE_VERSION
|
|
4249
|
+
import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace8 } from "@dxos/protocols";
|
|
4338
4250
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4339
4251
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4340
4252
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
@@ -4344,7 +4256,7 @@ import { safeInstanceof } from "@dxos/util";
|
|
|
4344
4256
|
import { getHeads } from "@dxos/automerge/automerge";
|
|
4345
4257
|
import { warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4346
4258
|
import { idCodec } from "@dxos/protocols";
|
|
4347
|
-
var
|
|
4259
|
+
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4348
4260
|
/**
|
|
4349
4261
|
* Get object data blobs from Automerge Repo by ids.
|
|
4350
4262
|
* @param ids
|
|
@@ -4357,17 +4269,17 @@ var createLoadDocuments = (automergeHost) => (
|
|
|
4357
4269
|
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4358
4270
|
const doc = handle.docSync();
|
|
4359
4271
|
const hash = getHeads(doc).join("");
|
|
4360
|
-
yield [
|
|
4272
|
+
yield doc.objects?.[objectId] ? [
|
|
4361
4273
|
{
|
|
4362
4274
|
id,
|
|
4363
4275
|
object: doc.objects[objectId],
|
|
4364
4276
|
currentHash: hash
|
|
4365
4277
|
}
|
|
4366
|
-
];
|
|
4278
|
+
] : [];
|
|
4367
4279
|
}
|
|
4368
4280
|
}
|
|
4369
4281
|
);
|
|
4370
|
-
var
|
|
4282
|
+
var createDocumentsIterator = (automergeHost) => (
|
|
4371
4283
|
/**
|
|
4372
4284
|
* Recursively get all object data blobs from Automerge Repo.
|
|
4373
4285
|
* @param ids
|
|
@@ -4390,7 +4302,7 @@ var createGetAllDocuments = (automergeHost) => (
|
|
|
4390
4302
|
objectId
|
|
4391
4303
|
}),
|
|
4392
4304
|
object,
|
|
4393
|
-
currentHash: heads.
|
|
4305
|
+
currentHash: heads.join("")
|
|
4394
4306
|
};
|
|
4395
4307
|
});
|
|
4396
4308
|
}
|
|
@@ -4430,10 +4342,12 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4430
4342
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4431
4343
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4432
4344
|
}
|
|
4433
|
-
var
|
|
4434
|
-
var ServiceContext = class {
|
|
4435
|
-
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();
|
|
4436
4349
|
this.storage = storage;
|
|
4350
|
+
this.level = level;
|
|
4437
4351
|
this.networkManager = networkManager;
|
|
4438
4352
|
this.signalManager = signalManager;
|
|
4439
4353
|
this._runtimeParams = _runtimeParams;
|
|
@@ -4463,7 +4377,7 @@ var ServiceContext = class {
|
|
|
4463
4377
|
});
|
|
4464
4378
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4465
4379
|
this.indexMetadata = new IndexMetadataStore({
|
|
4466
|
-
|
|
4380
|
+
db: level.sublevel("index-metadata")
|
|
4467
4381
|
});
|
|
4468
4382
|
this.automergeHost = new AutomergeHost({
|
|
4469
4383
|
directory: storage.createDirectory("automerge"),
|
|
@@ -4474,25 +4388,25 @@ var ServiceContext = class {
|
|
|
4474
4388
|
directory: storage.createDirectory("index-store")
|
|
4475
4389
|
}),
|
|
4476
4390
|
metadataStore: this.indexMetadata,
|
|
4477
|
-
loadDocuments:
|
|
4478
|
-
getAllDocuments:
|
|
4391
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4392
|
+
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4479
4393
|
});
|
|
4480
4394
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4481
4395
|
this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4482
4396
|
}
|
|
4483
|
-
async
|
|
4397
|
+
async _open(ctx) {
|
|
4484
4398
|
await this._checkStorageVersion();
|
|
4485
4399
|
log12("opening...", void 0, {
|
|
4486
|
-
F:
|
|
4487
|
-
L:
|
|
4400
|
+
F: __dxlog_file14,
|
|
4401
|
+
L: 156,
|
|
4488
4402
|
S: this,
|
|
4489
4403
|
C: (f, a) => f(...a)
|
|
4490
4404
|
});
|
|
4491
4405
|
log12.trace("dxos.sdk.service-context.open", trace8.begin({
|
|
4492
4406
|
id: this._instanceId
|
|
4493
4407
|
}), {
|
|
4494
|
-
F:
|
|
4495
|
-
L:
|
|
4408
|
+
F: __dxlog_file14,
|
|
4409
|
+
L: 157,
|
|
4496
4410
|
S: this,
|
|
4497
4411
|
C: (f, a) => f(...a)
|
|
4498
4412
|
});
|
|
@@ -4507,22 +4421,22 @@ var ServiceContext = class {
|
|
|
4507
4421
|
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4508
4422
|
id: this._instanceId
|
|
4509
4423
|
}), {
|
|
4510
|
-
F:
|
|
4511
|
-
L:
|
|
4424
|
+
F: __dxlog_file14,
|
|
4425
|
+
L: 167,
|
|
4512
4426
|
S: this,
|
|
4513
4427
|
C: (f, a) => f(...a)
|
|
4514
4428
|
});
|
|
4515
4429
|
log12("opened", void 0, {
|
|
4516
|
-
F:
|
|
4517
|
-
L:
|
|
4430
|
+
F: __dxlog_file14,
|
|
4431
|
+
L: 168,
|
|
4518
4432
|
S: this,
|
|
4519
4433
|
C: (f, a) => f(...a)
|
|
4520
4434
|
});
|
|
4521
4435
|
}
|
|
4522
|
-
async
|
|
4436
|
+
async _close() {
|
|
4523
4437
|
log12("closing...", void 0, {
|
|
4524
|
-
F:
|
|
4525
|
-
L:
|
|
4438
|
+
F: __dxlog_file14,
|
|
4439
|
+
L: 172,
|
|
4526
4440
|
S: this,
|
|
4527
4441
|
C: (f, a) => f(...a)
|
|
4528
4442
|
});
|
|
@@ -4539,8 +4453,8 @@ var ServiceContext = class {
|
|
|
4539
4453
|
await this.metadataStore.close();
|
|
4540
4454
|
await this.indexer.destroy();
|
|
4541
4455
|
log12("closed", void 0, {
|
|
4542
|
-
F:
|
|
4543
|
-
L:
|
|
4456
|
+
F: __dxlog_file14,
|
|
4457
|
+
L: 185,
|
|
4544
4458
|
S: this,
|
|
4545
4459
|
C: (f, a) => f(...a)
|
|
4546
4460
|
});
|
|
@@ -4552,9 +4466,9 @@ var ServiceContext = class {
|
|
|
4552
4466
|
}
|
|
4553
4467
|
getInvitationHandler(invitation) {
|
|
4554
4468
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4555
|
-
|
|
4556
|
-
F:
|
|
4557
|
-
L:
|
|
4469
|
+
invariant13(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4470
|
+
F: __dxlog_file14,
|
|
4471
|
+
L: 196,
|
|
4558
4472
|
S: this,
|
|
4559
4473
|
A: [
|
|
4560
4474
|
"factory",
|
|
@@ -4578,15 +4492,15 @@ var ServiceContext = class {
|
|
|
4578
4492
|
}
|
|
4579
4493
|
async _checkStorageVersion() {
|
|
4580
4494
|
await this.metadataStore.load();
|
|
4581
|
-
if (this.metadataStore.version !==
|
|
4582
|
-
throw new InvalidStorageVersionError(
|
|
4495
|
+
if (this.metadataStore.version !== STORAGE_VERSION) {
|
|
4496
|
+
throw new InvalidStorageVersionError(STORAGE_VERSION, this.metadataStore.version);
|
|
4583
4497
|
}
|
|
4584
4498
|
}
|
|
4585
4499
|
// Called when identity is created.
|
|
4586
4500
|
async _initialize(ctx) {
|
|
4587
4501
|
log12("initializing spaces...", void 0, {
|
|
4588
|
-
F:
|
|
4589
|
-
L:
|
|
4502
|
+
F: __dxlog_file14,
|
|
4503
|
+
L: 227,
|
|
4590
4504
|
S: this,
|
|
4591
4505
|
C: (f, a) => f(...a)
|
|
4592
4506
|
});
|
|
@@ -4607,9 +4521,9 @@ var ServiceContext = class {
|
|
|
4607
4521
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4608
4522
|
await this.dataSpaceManager.open();
|
|
4609
4523
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4610
|
-
|
|
4611
|
-
F:
|
|
4612
|
-
L:
|
|
4524
|
+
invariant13(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4525
|
+
F: __dxlog_file14,
|
|
4526
|
+
L: 251,
|
|
4613
4527
|
S: this,
|
|
4614
4528
|
A: [
|
|
4615
4529
|
"this.dataSpaceManager",
|
|
@@ -4632,8 +4546,8 @@ var ServiceContext = class {
|
|
|
4632
4546
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4633
4547
|
details: assertion
|
|
4634
4548
|
}, {
|
|
4635
|
-
F:
|
|
4636
|
-
L:
|
|
4549
|
+
F: __dxlog_file14,
|
|
4550
|
+
L: 267,
|
|
4637
4551
|
S: this,
|
|
4638
4552
|
C: (f, a) => f(...a)
|
|
4639
4553
|
});
|
|
@@ -4643,8 +4557,8 @@ var ServiceContext = class {
|
|
|
4643
4557
|
log12("space already exists, ignoring space admission", {
|
|
4644
4558
|
details: assertion
|
|
4645
4559
|
}, {
|
|
4646
|
-
F:
|
|
4647
|
-
L:
|
|
4560
|
+
F: __dxlog_file14,
|
|
4561
|
+
L: 271,
|
|
4648
4562
|
S: this,
|
|
4649
4563
|
C: (f, a) => f(...a)
|
|
4650
4564
|
});
|
|
@@ -4654,8 +4568,8 @@ var ServiceContext = class {
|
|
|
4654
4568
|
log12("accepting space recorded in halo", {
|
|
4655
4569
|
details: assertion
|
|
4656
4570
|
}, {
|
|
4657
|
-
F:
|
|
4658
|
-
L:
|
|
4571
|
+
F: __dxlog_file14,
|
|
4572
|
+
L: 276,
|
|
4659
4573
|
S: this,
|
|
4660
4574
|
C: (f, a) => f(...a)
|
|
4661
4575
|
});
|
|
@@ -4665,8 +4579,8 @@ var ServiceContext = class {
|
|
|
4665
4579
|
});
|
|
4666
4580
|
} catch (err) {
|
|
4667
4581
|
log12.catch(err, void 0, {
|
|
4668
|
-
F:
|
|
4669
|
-
L:
|
|
4582
|
+
F: __dxlog_file14,
|
|
4583
|
+
L: 282,
|
|
4670
4584
|
S: this,
|
|
4671
4585
|
C: (f, a) => f(...a)
|
|
4672
4586
|
});
|
|
@@ -4678,7 +4592,7 @@ var ServiceContext = class {
|
|
|
4678
4592
|
};
|
|
4679
4593
|
_ts_decorate6([
|
|
4680
4594
|
Trace2.span()
|
|
4681
|
-
], ServiceContext.prototype, "
|
|
4595
|
+
], ServiceContext.prototype, "_open", null);
|
|
4682
4596
|
_ts_decorate6([
|
|
4683
4597
|
Trace2.span()
|
|
4684
4598
|
], ServiceContext.prototype, "_initialize", null);
|
|
@@ -4711,10 +4625,359 @@ var ServiceRegistry = class {
|
|
|
4711
4625
|
}
|
|
4712
4626
|
};
|
|
4713
4627
|
|
|
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.06ef97a";
|
|
4638
|
+
|
|
4639
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
4640
|
+
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
4641
|
+
var getPlatform = () => {
|
|
4642
|
+
if (process.browser) {
|
|
4643
|
+
if (typeof window !== "undefined") {
|
|
4644
|
+
const { userAgent } = window.navigator;
|
|
4645
|
+
return {
|
|
4646
|
+
type: Platform.PLATFORM_TYPE.BROWSER,
|
|
4647
|
+
userAgent,
|
|
4648
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4649
|
+
};
|
|
4650
|
+
} else {
|
|
4651
|
+
return {
|
|
4652
|
+
type: Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4653
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
} else {
|
|
4657
|
+
const { platform: platform2, version, arch } = process;
|
|
4658
|
+
return {
|
|
4659
|
+
type: Platform.PLATFORM_TYPE.NODE,
|
|
4660
|
+
platform: platform2,
|
|
4661
|
+
arch,
|
|
4662
|
+
runtime: version,
|
|
4663
|
+
uptime: Math.floor(process.uptime()),
|
|
4664
|
+
memory: process.memoryUsage()
|
|
4665
|
+
};
|
|
4666
|
+
}
|
|
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);
|
|
4697
|
+
}
|
|
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);
|
|
4707
|
+
}
|
|
4708
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4709
|
+
file,
|
|
4710
|
+
count
|
|
4711
|
+
}));
|
|
4712
|
+
}
|
|
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;
|
|
4740
|
+
}
|
|
4741
|
+
diagnostics.config = config.values;
|
|
4742
|
+
return diagnostics;
|
|
4743
|
+
};
|
|
4744
|
+
var getSpaceStats = async (space) => {
|
|
4745
|
+
const stats = {
|
|
4746
|
+
key: space.key,
|
|
4747
|
+
metrics: space.metrics,
|
|
4748
|
+
epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4749
|
+
...credential.subject.assertion,
|
|
4750
|
+
id: credential.id
|
|
4751
|
+
})),
|
|
4752
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4753
|
+
identity: {
|
|
4754
|
+
identityKey: member.key,
|
|
4755
|
+
profile: {
|
|
4756
|
+
displayName: member.assertion.profile?.displayName
|
|
4757
|
+
}
|
|
4758
|
+
},
|
|
4759
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE
|
|
4760
|
+
})),
|
|
4761
|
+
pipeline: {
|
|
4762
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4763
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4764
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4765
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4766
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4767
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4768
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
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;
|
|
4776
|
+
};
|
|
4777
|
+
|
|
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
|
+
};
|
|
4829
|
+
};
|
|
4830
|
+
var createCollectDiagnosticsBroadcastHandler = (systemService) => {
|
|
4831
|
+
let channel;
|
|
4832
|
+
return {
|
|
4833
|
+
start: () => {
|
|
4834
|
+
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
4835
|
+
channel.onmessage = async (message) => {
|
|
4836
|
+
try {
|
|
4837
|
+
if (message.data.type === "probe") {
|
|
4838
|
+
channel?.postMessage({
|
|
4839
|
+
type: "probe-ack"
|
|
4840
|
+
});
|
|
4841
|
+
} else if (message.data.type === "request-diagnostics") {
|
|
4842
|
+
const diagnostics = await systemService.getDiagnostics({});
|
|
4843
|
+
channel?.postMessage({
|
|
4844
|
+
type: "receive-diagnostics",
|
|
4845
|
+
payload: diagnostics
|
|
4846
|
+
});
|
|
4847
|
+
}
|
|
4848
|
+
} catch (error) {
|
|
4849
|
+
log13.catch(error, void 0, {
|
|
4850
|
+
F: __dxlog_file16,
|
|
4851
|
+
L: 77,
|
|
4852
|
+
S: void 0,
|
|
4853
|
+
C: (f, a) => f(...a)
|
|
4854
|
+
});
|
|
4855
|
+
}
|
|
4856
|
+
};
|
|
4857
|
+
},
|
|
4858
|
+
stop: () => {
|
|
4859
|
+
safeClose(channel);
|
|
4860
|
+
channel = void 0;
|
|
4861
|
+
}
|
|
4862
|
+
};
|
|
4863
|
+
};
|
|
4864
|
+
var safeClose = (channel) => {
|
|
4865
|
+
try {
|
|
4866
|
+
channel?.close();
|
|
4867
|
+
} catch (e) {
|
|
4868
|
+
}
|
|
4869
|
+
};
|
|
4870
|
+
|
|
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";
|
|
4876
|
+
|
|
4877
|
+
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4878
|
+
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4879
|
+
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4880
|
+
import { Context as Context11 } from "@dxos/context";
|
|
4881
|
+
import { DataServiceImpl, encodeReference } from "@dxos/echo-pipeline";
|
|
4882
|
+
import * as E from "@dxos/echo-schema";
|
|
4883
|
+
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4884
|
+
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4885
|
+
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
4886
|
+
import { log as log16 } from "@dxos/log";
|
|
4887
|
+
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4888
|
+
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
4889
|
+
import { trace as trace9 } from "@dxos/protocols";
|
|
4890
|
+
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4891
|
+
import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace3 } from "@dxos/tracing";
|
|
4892
|
+
import { assignDeep as assignDeep2 } from "@dxos/util";
|
|
4893
|
+
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
4894
|
+
|
|
4895
|
+
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4896
|
+
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
4897
|
+
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
4898
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4899
|
+
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4900
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4901
|
+
var DevicesServiceImpl = class {
|
|
4902
|
+
constructor(_identityManager) {
|
|
4903
|
+
this._identityManager = _identityManager;
|
|
4904
|
+
}
|
|
4905
|
+
async updateDevice(profile) {
|
|
4906
|
+
return this._identityManager.updateDeviceProfile(profile);
|
|
4907
|
+
}
|
|
4908
|
+
queryDevices() {
|
|
4909
|
+
return new Stream11(({ next }) => {
|
|
4910
|
+
const update = () => {
|
|
4911
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4912
|
+
if (!deviceKeys) {
|
|
4913
|
+
next({
|
|
4914
|
+
devices: []
|
|
4915
|
+
});
|
|
4916
|
+
} else {
|
|
4917
|
+
invariant15(this._identityManager.identity?.presence, "presence not present", {
|
|
4918
|
+
F: __dxlog_file17,
|
|
4919
|
+
L: 32,
|
|
4920
|
+
S: this,
|
|
4921
|
+
A: [
|
|
4922
|
+
"this._identityManager.identity?.presence",
|
|
4923
|
+
"'presence not present'"
|
|
4924
|
+
]
|
|
4925
|
+
});
|
|
4926
|
+
const peers = this._identityManager.identity.presence.getPeersOnline();
|
|
4927
|
+
next({
|
|
4928
|
+
devices: Array.from(deviceKeys.entries()).map(([key, profile]) => {
|
|
4929
|
+
const isMe = this._identityManager.identity?.deviceKey.equals(key);
|
|
4930
|
+
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4931
|
+
return {
|
|
4932
|
+
deviceKey: key,
|
|
4933
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind2.CURRENT : DeviceKind2.TRUSTED,
|
|
4934
|
+
profile,
|
|
4935
|
+
presence: isMe ? Device2.PresenceState.ONLINE : peerState ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE
|
|
4936
|
+
};
|
|
4937
|
+
})
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
};
|
|
4941
|
+
let identitySubscribed = false;
|
|
4942
|
+
let presenceSubscribed = false;
|
|
4943
|
+
const subscribeIdentity = () => {
|
|
4944
|
+
if (!identitySubscribed) {
|
|
4945
|
+
this._identityManager.identity?.stateUpdate.on(() => {
|
|
4946
|
+
update();
|
|
4947
|
+
});
|
|
4948
|
+
identitySubscribed = true;
|
|
4949
|
+
}
|
|
4950
|
+
};
|
|
4951
|
+
const subscribePresence = () => {
|
|
4952
|
+
if (!presenceSubscribed) {
|
|
4953
|
+
this._identityManager.identity?.presence?.updated.on(() => {
|
|
4954
|
+
update();
|
|
4955
|
+
});
|
|
4956
|
+
presenceSubscribed = true;
|
|
4957
|
+
}
|
|
4958
|
+
};
|
|
4959
|
+
const subscriptions = new EventSubscriptions3();
|
|
4960
|
+
if (this._identityManager.identity) {
|
|
4961
|
+
subscribeIdentity();
|
|
4962
|
+
subscribePresence();
|
|
4963
|
+
}
|
|
4964
|
+
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
4965
|
+
update();
|
|
4966
|
+
if (this._identityManager.identity) {
|
|
4967
|
+
subscribeIdentity();
|
|
4968
|
+
subscribePresence();
|
|
4969
|
+
}
|
|
4970
|
+
}));
|
|
4971
|
+
update();
|
|
4972
|
+
return () => subscriptions.clear();
|
|
4973
|
+
});
|
|
4974
|
+
}
|
|
4975
|
+
};
|
|
4976
|
+
|
|
4714
4977
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4715
|
-
import { asyncTimeout as asyncTimeout2, Trigger as
|
|
4978
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger7 } from "@dxos/async";
|
|
4716
4979
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4717
|
-
import { log as
|
|
4980
|
+
import { log as log14, logInfo } from "@dxos/log";
|
|
4718
4981
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
4719
4982
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4720
4983
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4725,7 +4988,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
4725
4988
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4726
4989
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4727
4990
|
}
|
|
4728
|
-
var
|
|
4991
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
4729
4992
|
var Message;
|
|
4730
4993
|
(function(Message2) {
|
|
4731
4994
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -4733,7 +4996,7 @@ var Message;
|
|
|
4733
4996
|
var Lock = class {
|
|
4734
4997
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
4735
4998
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
4736
|
-
this._releaseTrigger = new
|
|
4999
|
+
this._releaseTrigger = new Trigger7();
|
|
4737
5000
|
this._lockKey = lockKey;
|
|
4738
5001
|
this._onAcquire = onAcquire;
|
|
4739
5002
|
this._onRelease = onRelease;
|
|
@@ -4747,29 +5010,29 @@ var Lock = class {
|
|
|
4747
5010
|
message: "acquiring"
|
|
4748
5011
|
});
|
|
4749
5012
|
try {
|
|
4750
|
-
|
|
4751
|
-
F:
|
|
5013
|
+
log14("aquiring lock...", void 0, {
|
|
5014
|
+
F: __dxlog_file18,
|
|
4752
5015
|
L: 42,
|
|
4753
5016
|
S: this,
|
|
4754
5017
|
C: (f, a) => f(...a)
|
|
4755
5018
|
});
|
|
4756
5019
|
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4757
|
-
|
|
4758
|
-
F:
|
|
5020
|
+
log14("acquired lock", void 0, {
|
|
5021
|
+
F: __dxlog_file18,
|
|
4759
5022
|
L: 44,
|
|
4760
5023
|
S: this,
|
|
4761
5024
|
C: (f, a) => f(...a)
|
|
4762
5025
|
});
|
|
4763
5026
|
} catch {
|
|
4764
|
-
|
|
4765
|
-
F:
|
|
5027
|
+
log14("stealing lock...", void 0, {
|
|
5028
|
+
F: __dxlog_file18,
|
|
4766
5029
|
L: 46,
|
|
4767
5030
|
S: this,
|
|
4768
5031
|
C: (f, a) => f(...a)
|
|
4769
5032
|
});
|
|
4770
5033
|
await this._requestLock(true);
|
|
4771
|
-
|
|
4772
|
-
F:
|
|
5034
|
+
log14("stolen lock", void 0, {
|
|
5035
|
+
F: __dxlog_file18,
|
|
4773
5036
|
L: 48,
|
|
4774
5037
|
S: this,
|
|
4775
5038
|
C: (f, a) => f(...a)
|
|
@@ -4785,31 +5048,31 @@ var Lock = class {
|
|
|
4785
5048
|
}
|
|
4786
5049
|
}
|
|
4787
5050
|
async _requestLock(steal = false) {
|
|
4788
|
-
|
|
5051
|
+
log14("requesting lock...", {
|
|
4789
5052
|
steal
|
|
4790
5053
|
}, {
|
|
4791
|
-
F:
|
|
5054
|
+
F: __dxlog_file18,
|
|
4792
5055
|
L: 63,
|
|
4793
5056
|
S: this,
|
|
4794
5057
|
C: (f, a) => f(...a)
|
|
4795
5058
|
});
|
|
4796
|
-
const acquired = new
|
|
5059
|
+
const acquired = new Trigger7();
|
|
4797
5060
|
void navigator.locks.request(this._lockKey, {
|
|
4798
5061
|
steal
|
|
4799
5062
|
}, async () => {
|
|
4800
5063
|
await this._onAcquire?.();
|
|
4801
5064
|
acquired.wake();
|
|
4802
|
-
this._releaseTrigger = new
|
|
5065
|
+
this._releaseTrigger = new Trigger7();
|
|
4803
5066
|
await this._releaseTrigger.wait();
|
|
4804
|
-
|
|
4805
|
-
F:
|
|
5067
|
+
log14("releasing lock...", void 0, {
|
|
5068
|
+
F: __dxlog_file18,
|
|
4806
5069
|
L: 72,
|
|
4807
5070
|
S: this,
|
|
4808
5071
|
C: (f, a) => f(...a)
|
|
4809
5072
|
});
|
|
4810
5073
|
await this._onRelease?.();
|
|
4811
|
-
|
|
4812
|
-
F:
|
|
5074
|
+
log14("released lock", void 0, {
|
|
5075
|
+
F: __dxlog_file18,
|
|
4813
5076
|
L: 74,
|
|
4814
5077
|
S: this,
|
|
4815
5078
|
C: (f, a) => f(...a)
|
|
@@ -4818,10 +5081,10 @@ var Lock = class {
|
|
|
4818
5081
|
await this._onRelease?.();
|
|
4819
5082
|
});
|
|
4820
5083
|
await acquired.wait();
|
|
4821
|
-
|
|
5084
|
+
log14("recieved lock", {
|
|
4822
5085
|
steal
|
|
4823
5086
|
}, {
|
|
4824
|
-
F:
|
|
5087
|
+
F: __dxlog_file18,
|
|
4825
5088
|
L: 81,
|
|
4826
5089
|
S: this,
|
|
4827
5090
|
C: (f, a) => f(...a)
|
|
@@ -4835,160 +5098,11 @@ var isLocked = (lockPath) => {
|
|
|
4835
5098
|
throw new Error("Not implemented");
|
|
4836
5099
|
};
|
|
4837
5100
|
|
|
4838
|
-
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
4839
|
-
import { DX_DATA } from "@dxos/client-protocol";
|
|
4840
|
-
import { InvalidConfigError } from "@dxos/protocols";
|
|
4841
|
-
import { Runtime } from "@dxos/protocols/proto/dxos/config";
|
|
4842
|
-
import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
4843
|
-
import { isNode as isNode2 } from "@dxos/util";
|
|
4844
|
-
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
4845
|
-
var createStorageObjects = (config) => {
|
|
4846
|
-
const { persistent = false, keyStore, dataStore, dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
|
|
4847
|
-
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4848
|
-
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4849
|
-
}
|
|
4850
|
-
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
4851
|
-
throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
4852
|
-
}
|
|
4853
|
-
if (persistent && keyStore === StorageDriver.RAM) {
|
|
4854
|
-
throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
4855
|
-
}
|
|
4856
|
-
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
4857
|
-
throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
4858
|
-
}
|
|
4859
|
-
return {
|
|
4860
|
-
storage: createStorage({
|
|
4861
|
-
type: persistent ? toStorageType(dataStore) : StorageType.RAM,
|
|
4862
|
-
root: `${dataRoot}/`
|
|
4863
|
-
})
|
|
4864
|
-
};
|
|
4865
|
-
};
|
|
4866
|
-
var toStorageType = (type) => {
|
|
4867
|
-
switch (type) {
|
|
4868
|
-
case void 0:
|
|
4869
|
-
return void 0;
|
|
4870
|
-
case StorageDriver.RAM:
|
|
4871
|
-
return StorageType.RAM;
|
|
4872
|
-
case StorageDriver.CHROME:
|
|
4873
|
-
return StorageType.CHROME;
|
|
4874
|
-
case StorageDriver.FIREFOX:
|
|
4875
|
-
return StorageType.FIREFOX;
|
|
4876
|
-
case StorageDriver.IDB:
|
|
4877
|
-
return StorageType.IDB;
|
|
4878
|
-
case StorageDriver.NODE:
|
|
4879
|
-
return StorageType.NODE;
|
|
4880
|
-
case StorageDriver.WEBFS:
|
|
4881
|
-
return StorageType.WEBFS;
|
|
4882
|
-
default:
|
|
4883
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4884
|
-
}
|
|
4885
|
-
};
|
|
4886
|
-
|
|
4887
|
-
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4888
|
-
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4889
|
-
import { Properties, clientServiceBundle, defaultKey } from "@dxos/client-protocol";
|
|
4890
|
-
import { Context as Context11 } from "@dxos/context";
|
|
4891
|
-
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4892
|
-
import { getAutomergeObjectCore, getRawDoc } from "@dxos/echo-schema";
|
|
4893
|
-
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4894
|
-
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4895
|
-
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
4896
|
-
import { log as log15 } from "@dxos/log";
|
|
4897
|
-
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4898
|
-
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
4899
|
-
import { trace as trace9 } from "@dxos/protocols";
|
|
4900
|
-
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4901
|
-
import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace3 } from "@dxos/tracing";
|
|
4902
|
-
import { assignDeep } from "@dxos/util";
|
|
4903
|
-
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
4904
|
-
|
|
4905
|
-
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4906
|
-
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
4907
|
-
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
4908
|
-
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4909
|
-
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4910
|
-
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4911
|
-
var DevicesServiceImpl = class {
|
|
4912
|
-
constructor(_identityManager) {
|
|
4913
|
-
this._identityManager = _identityManager;
|
|
4914
|
-
}
|
|
4915
|
-
async updateDevice(profile) {
|
|
4916
|
-
return this._identityManager.updateDeviceProfile(profile);
|
|
4917
|
-
}
|
|
4918
|
-
queryDevices() {
|
|
4919
|
-
return new Stream11(({ next }) => {
|
|
4920
|
-
const update = () => {
|
|
4921
|
-
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4922
|
-
if (!deviceKeys) {
|
|
4923
|
-
next({
|
|
4924
|
-
devices: []
|
|
4925
|
-
});
|
|
4926
|
-
} else {
|
|
4927
|
-
invariant15(this._identityManager.identity?.presence, "presence not present", {
|
|
4928
|
-
F: __dxlog_file17,
|
|
4929
|
-
L: 32,
|
|
4930
|
-
S: this,
|
|
4931
|
-
A: [
|
|
4932
|
-
"this._identityManager.identity?.presence",
|
|
4933
|
-
"'presence not present'"
|
|
4934
|
-
]
|
|
4935
|
-
});
|
|
4936
|
-
const peers = this._identityManager.identity.presence.getPeersOnline();
|
|
4937
|
-
next({
|
|
4938
|
-
devices: Array.from(deviceKeys.entries()).map(([key, profile]) => {
|
|
4939
|
-
const isMe = this._identityManager.identity?.deviceKey.equals(key);
|
|
4940
|
-
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4941
|
-
return {
|
|
4942
|
-
deviceKey: key,
|
|
4943
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind2.CURRENT : DeviceKind2.TRUSTED,
|
|
4944
|
-
profile,
|
|
4945
|
-
presence: isMe ? Device2.PresenceState.ONLINE : peerState ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE
|
|
4946
|
-
};
|
|
4947
|
-
})
|
|
4948
|
-
});
|
|
4949
|
-
}
|
|
4950
|
-
};
|
|
4951
|
-
let identitySubscribed = false;
|
|
4952
|
-
let presenceSubscribed = false;
|
|
4953
|
-
const subscribeIdentity = () => {
|
|
4954
|
-
if (!identitySubscribed) {
|
|
4955
|
-
this._identityManager.identity?.stateUpdate.on(() => {
|
|
4956
|
-
update();
|
|
4957
|
-
});
|
|
4958
|
-
identitySubscribed = true;
|
|
4959
|
-
}
|
|
4960
|
-
};
|
|
4961
|
-
const subscribePresence = () => {
|
|
4962
|
-
if (!presenceSubscribed) {
|
|
4963
|
-
this._identityManager.identity?.presence?.updated.on(() => {
|
|
4964
|
-
update();
|
|
4965
|
-
});
|
|
4966
|
-
presenceSubscribed = true;
|
|
4967
|
-
}
|
|
4968
|
-
};
|
|
4969
|
-
const subscriptions = new EventSubscriptions3();
|
|
4970
|
-
if (this._identityManager.identity) {
|
|
4971
|
-
subscribeIdentity();
|
|
4972
|
-
subscribePresence();
|
|
4973
|
-
}
|
|
4974
|
-
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
4975
|
-
update();
|
|
4976
|
-
if (this._identityManager.identity) {
|
|
4977
|
-
subscribeIdentity();
|
|
4978
|
-
subscribePresence();
|
|
4979
|
-
}
|
|
4980
|
-
}));
|
|
4981
|
-
update();
|
|
4982
|
-
return () => subscriptions.clear();
|
|
4983
|
-
});
|
|
4984
|
-
}
|
|
4985
|
-
};
|
|
4986
|
-
|
|
4987
5101
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
4988
5102
|
import { Event as Event8 } from "@dxos/async";
|
|
4989
5103
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
4990
5104
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4991
|
-
import { getContextFromEntry, log as
|
|
5105
|
+
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
4992
5106
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
4993
5107
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
4994
5108
|
var LoggingServiceImpl = class {
|
|
@@ -5001,11 +5115,11 @@ var LoggingServiceImpl = class {
|
|
|
5001
5115
|
};
|
|
5002
5116
|
}
|
|
5003
5117
|
async open() {
|
|
5004
|
-
|
|
5118
|
+
log15.runtimeConfig.processors.push(this._logProcessor);
|
|
5005
5119
|
}
|
|
5006
5120
|
async close() {
|
|
5007
|
-
const index =
|
|
5008
|
-
|
|
5121
|
+
const index = log15.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5122
|
+
log15.runtimeConfig.processors.splice(index, 1);
|
|
5009
5123
|
}
|
|
5010
5124
|
async controlMetrics({ reset, record }) {
|
|
5011
5125
|
if (reset) {
|
|
@@ -5090,12 +5204,12 @@ var LoggingServiceImpl = class {
|
|
|
5090
5204
|
});
|
|
5091
5205
|
}
|
|
5092
5206
|
};
|
|
5093
|
-
var matchFilter = (filter, level,
|
|
5207
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5094
5208
|
switch (options) {
|
|
5095
5209
|
case QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5096
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5210
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5097
5211
|
case QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5098
|
-
return level === filter.level && (!filter.pattern ||
|
|
5212
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5099
5213
|
}
|
|
5100
5214
|
};
|
|
5101
5215
|
var shouldLog = (entry2, request) => {
|
|
@@ -5141,6 +5255,80 @@ var NetworkServiceImpl = class {
|
|
|
5141
5255
|
}
|
|
5142
5256
|
};
|
|
5143
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
|
+
|
|
5144
5332
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
5145
5333
|
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
5146
5334
|
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -5209,7 +5397,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5209
5397
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5210
5398
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5211
5399
|
}
|
|
5212
|
-
var
|
|
5400
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5213
5401
|
var ClientServicesHost = class {
|
|
5214
5402
|
constructor({
|
|
5215
5403
|
config,
|
|
@@ -5264,6 +5452,7 @@ var ClientServicesHost = class {
|
|
|
5264
5452
|
await this.reset();
|
|
5265
5453
|
}
|
|
5266
5454
|
});
|
|
5455
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5267
5456
|
this._loggingService = new LoggingServiceImpl();
|
|
5268
5457
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
5269
5458
|
SystemService: this._systemService,
|
|
@@ -5295,24 +5484,24 @@ var ClientServicesHost = class {
|
|
|
5295
5484
|
*/
|
|
5296
5485
|
initialize({ config, ...options }) {
|
|
5297
5486
|
invariant16(!this._open, "service host is open", {
|
|
5298
|
-
F:
|
|
5299
|
-
L:
|
|
5487
|
+
F: __dxlog_file19,
|
|
5488
|
+
L: 188,
|
|
5300
5489
|
S: this,
|
|
5301
5490
|
A: [
|
|
5302
5491
|
"!this._open",
|
|
5303
5492
|
"'service host is open'"
|
|
5304
5493
|
]
|
|
5305
5494
|
});
|
|
5306
|
-
|
|
5307
|
-
F:
|
|
5308
|
-
L:
|
|
5495
|
+
log16("initializing...", void 0, {
|
|
5496
|
+
F: __dxlog_file19,
|
|
5497
|
+
L: 189,
|
|
5309
5498
|
S: this,
|
|
5310
5499
|
C: (f, a) => f(...a)
|
|
5311
5500
|
});
|
|
5312
5501
|
if (config) {
|
|
5313
5502
|
invariant16(!this._config, "config already set", {
|
|
5314
|
-
F:
|
|
5315
|
-
L:
|
|
5503
|
+
F: __dxlog_file19,
|
|
5504
|
+
L: 192,
|
|
5316
5505
|
S: this,
|
|
5317
5506
|
A: [
|
|
5318
5507
|
"!this._config",
|
|
@@ -5324,13 +5513,21 @@ var ClientServicesHost = class {
|
|
|
5324
5513
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
5325
5514
|
}
|
|
5326
5515
|
}
|
|
5516
|
+
if (!options.signalManager) {
|
|
5517
|
+
log16.warn("running signaling without telemetry metadata.", void 0, {
|
|
5518
|
+
F: __dxlog_file19,
|
|
5519
|
+
L: 200,
|
|
5520
|
+
S: this,
|
|
5521
|
+
C: (f, a) => f(...a)
|
|
5522
|
+
});
|
|
5523
|
+
}
|
|
5327
5524
|
const { connectionLog = true, transportFactory = createSimplePeerTransportFactory({
|
|
5328
5525
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5329
5526
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5330
5527
|
this._signalManager = signalManager;
|
|
5331
5528
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5332
|
-
F:
|
|
5333
|
-
L:
|
|
5529
|
+
F: __dxlog_file19,
|
|
5530
|
+
L: 211,
|
|
5334
5531
|
S: this,
|
|
5335
5532
|
A: [
|
|
5336
5533
|
"!this._networkManager",
|
|
@@ -5342,9 +5539,9 @@ var ClientServicesHost = class {
|
|
|
5342
5539
|
transportFactory,
|
|
5343
5540
|
signalManager
|
|
5344
5541
|
});
|
|
5345
|
-
|
|
5346
|
-
F:
|
|
5347
|
-
L:
|
|
5542
|
+
log16("initialized", void 0, {
|
|
5543
|
+
F: __dxlog_file19,
|
|
5544
|
+
L: 218,
|
|
5348
5545
|
S: this,
|
|
5349
5546
|
C: (f, a) => f(...a)
|
|
5350
5547
|
});
|
|
@@ -5353,18 +5550,18 @@ var ClientServicesHost = class {
|
|
|
5353
5550
|
if (this._open) {
|
|
5354
5551
|
return;
|
|
5355
5552
|
}
|
|
5356
|
-
const traceId =
|
|
5357
|
-
|
|
5553
|
+
const traceId = PublicKey13.random().toHex();
|
|
5554
|
+
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5358
5555
|
id: traceId
|
|
5359
5556
|
}), {
|
|
5360
|
-
F:
|
|
5361
|
-
L:
|
|
5557
|
+
F: __dxlog_file19,
|
|
5558
|
+
L: 229,
|
|
5362
5559
|
S: this,
|
|
5363
5560
|
C: (f, a) => f(...a)
|
|
5364
5561
|
});
|
|
5365
5562
|
invariant16(this._config, "config not set", {
|
|
5366
|
-
F:
|
|
5367
|
-
L:
|
|
5563
|
+
F: __dxlog_file19,
|
|
5564
|
+
L: 231,
|
|
5368
5565
|
S: this,
|
|
5369
5566
|
A: [
|
|
5370
5567
|
"this._config",
|
|
@@ -5372,8 +5569,8 @@ var ClientServicesHost = class {
|
|
|
5372
5569
|
]
|
|
5373
5570
|
});
|
|
5374
5571
|
invariant16(this._storage, "storage not set", {
|
|
5375
|
-
F:
|
|
5376
|
-
L:
|
|
5572
|
+
F: __dxlog_file19,
|
|
5573
|
+
L: 232,
|
|
5377
5574
|
S: this,
|
|
5378
5575
|
A: [
|
|
5379
5576
|
"this._storage",
|
|
@@ -5381,8 +5578,8 @@ var ClientServicesHost = class {
|
|
|
5381
5578
|
]
|
|
5382
5579
|
});
|
|
5383
5580
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5384
|
-
F:
|
|
5385
|
-
L:
|
|
5581
|
+
F: __dxlog_file19,
|
|
5582
|
+
L: 233,
|
|
5386
5583
|
S: this,
|
|
5387
5584
|
A: [
|
|
5388
5585
|
"this._signalManager",
|
|
@@ -5390,8 +5587,8 @@ var ClientServicesHost = class {
|
|
|
5390
5587
|
]
|
|
5391
5588
|
});
|
|
5392
5589
|
invariant16(this._networkManager, "network manager not set", {
|
|
5393
|
-
F:
|
|
5394
|
-
L:
|
|
5590
|
+
F: __dxlog_file19,
|
|
5591
|
+
L: 234,
|
|
5395
5592
|
S: this,
|
|
5396
5593
|
A: [
|
|
5397
5594
|
"this._networkManager",
|
|
@@ -5399,17 +5596,20 @@ var ClientServicesHost = class {
|
|
|
5399
5596
|
]
|
|
5400
5597
|
});
|
|
5401
5598
|
this._opening = true;
|
|
5402
|
-
|
|
5599
|
+
log16("opening...", {
|
|
5403
5600
|
lockKey: this._resourceLock?.lockKey
|
|
5404
5601
|
}, {
|
|
5405
|
-
F:
|
|
5406
|
-
L:
|
|
5602
|
+
F: __dxlog_file19,
|
|
5603
|
+
L: 237,
|
|
5407
5604
|
S: this,
|
|
5408
5605
|
C: (f, a) => f(...a)
|
|
5409
5606
|
});
|
|
5607
|
+
if (!this._level) {
|
|
5608
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5609
|
+
}
|
|
5410
5610
|
await this._resourceLock?.acquire();
|
|
5411
5611
|
await this._loggingService.open();
|
|
5412
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5612
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5413
5613
|
this._serviceRegistry.setServices({
|
|
5414
5614
|
SystemService: this._systemService,
|
|
5415
5615
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
@@ -5436,8 +5636,8 @@ var ClientServicesHost = class {
|
|
|
5436
5636
|
});
|
|
5437
5637
|
await this._serviceContext.open(ctx);
|
|
5438
5638
|
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5439
|
-
F:
|
|
5440
|
-
L:
|
|
5639
|
+
F: __dxlog_file19,
|
|
5640
|
+
L: 303,
|
|
5441
5641
|
S: this,
|
|
5442
5642
|
A: [
|
|
5443
5643
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5445,11 +5645,11 @@ var ClientServicesHost = class {
|
|
|
5445
5645
|
]
|
|
5446
5646
|
});
|
|
5447
5647
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5448
|
-
|
|
5648
|
+
log16("loaded persistent invitations", {
|
|
5449
5649
|
count: loadedInvitations.invitations?.length
|
|
5450
5650
|
}, {
|
|
5451
|
-
F:
|
|
5452
|
-
L:
|
|
5651
|
+
F: __dxlog_file19,
|
|
5652
|
+
L: 306,
|
|
5453
5653
|
S: this,
|
|
5454
5654
|
C: (f, a) => f(...a)
|
|
5455
5655
|
});
|
|
@@ -5463,23 +5663,24 @@ var ClientServicesHost = class {
|
|
|
5463
5663
|
});
|
|
5464
5664
|
void this._devtoolsProxy.open();
|
|
5465
5665
|
}
|
|
5666
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5466
5667
|
this._opening = false;
|
|
5467
5668
|
this._open = true;
|
|
5468
5669
|
this._statusUpdate.emit();
|
|
5469
5670
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5470
|
-
|
|
5671
|
+
log16("opened", {
|
|
5471
5672
|
deviceKey
|
|
5472
5673
|
}, {
|
|
5473
|
-
F:
|
|
5474
|
-
L:
|
|
5674
|
+
F: __dxlog_file19,
|
|
5675
|
+
L: 324,
|
|
5475
5676
|
S: this,
|
|
5476
5677
|
C: (f, a) => f(...a)
|
|
5477
5678
|
});
|
|
5478
|
-
|
|
5679
|
+
log16.trace("dxos.client-services.host.open", trace9.end({
|
|
5479
5680
|
id: traceId
|
|
5480
5681
|
}), {
|
|
5481
|
-
F:
|
|
5482
|
-
L:
|
|
5682
|
+
F: __dxlog_file19,
|
|
5683
|
+
L: 325,
|
|
5483
5684
|
S: this,
|
|
5484
5685
|
C: (f, a) => f(...a)
|
|
5485
5686
|
});
|
|
@@ -5489,60 +5690,62 @@ var ClientServicesHost = class {
|
|
|
5489
5690
|
return;
|
|
5490
5691
|
}
|
|
5491
5692
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5492
|
-
|
|
5693
|
+
log16("closing...", {
|
|
5493
5694
|
deviceKey
|
|
5494
5695
|
}, {
|
|
5495
|
-
F:
|
|
5496
|
-
L:
|
|
5696
|
+
F: __dxlog_file19,
|
|
5697
|
+
L: 336,
|
|
5497
5698
|
S: this,
|
|
5498
5699
|
C: (f, a) => f(...a)
|
|
5499
5700
|
});
|
|
5701
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5500
5702
|
await this._devtoolsProxy?.close();
|
|
5501
5703
|
this._serviceRegistry.setServices({
|
|
5502
5704
|
SystemService: this._systemService
|
|
5503
5705
|
});
|
|
5504
5706
|
await this._loggingService.close();
|
|
5505
5707
|
await this._serviceContext.close();
|
|
5708
|
+
await this._level?.close();
|
|
5506
5709
|
this._open = false;
|
|
5507
5710
|
this._statusUpdate.emit();
|
|
5508
|
-
|
|
5711
|
+
log16("closed", {
|
|
5509
5712
|
deviceKey
|
|
5510
5713
|
}, {
|
|
5511
|
-
F:
|
|
5512
|
-
L:
|
|
5714
|
+
F: __dxlog_file19,
|
|
5715
|
+
L: 345,
|
|
5513
5716
|
S: this,
|
|
5514
5717
|
C: (f, a) => f(...a)
|
|
5515
5718
|
});
|
|
5516
5719
|
}
|
|
5517
5720
|
async reset() {
|
|
5518
|
-
const traceId =
|
|
5519
|
-
|
|
5721
|
+
const traceId = PublicKey13.random().toHex();
|
|
5722
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5520
5723
|
id: traceId
|
|
5521
5724
|
}), {
|
|
5522
|
-
F:
|
|
5523
|
-
L:
|
|
5725
|
+
F: __dxlog_file19,
|
|
5726
|
+
L: 350,
|
|
5524
5727
|
S: this,
|
|
5525
5728
|
C: (f, a) => f(...a)
|
|
5526
5729
|
});
|
|
5527
|
-
|
|
5528
|
-
F:
|
|
5529
|
-
L:
|
|
5730
|
+
log16("resetting...", void 0, {
|
|
5731
|
+
F: __dxlog_file19,
|
|
5732
|
+
L: 352,
|
|
5530
5733
|
S: this,
|
|
5531
5734
|
C: (f, a) => f(...a)
|
|
5532
5735
|
});
|
|
5533
5736
|
await this._serviceContext?.close();
|
|
5534
5737
|
await this._storage.reset();
|
|
5535
|
-
|
|
5536
|
-
F:
|
|
5537
|
-
L:
|
|
5738
|
+
log16("reset", void 0, {
|
|
5739
|
+
F: __dxlog_file19,
|
|
5740
|
+
L: 355,
|
|
5538
5741
|
S: this,
|
|
5539
5742
|
C: (f, a) => f(...a)
|
|
5540
5743
|
});
|
|
5541
|
-
|
|
5744
|
+
log16.trace("dxos.sdk.client-services-host.reset", trace9.end({
|
|
5542
5745
|
id: traceId
|
|
5543
5746
|
}), {
|
|
5544
|
-
F:
|
|
5545
|
-
L:
|
|
5747
|
+
F: __dxlog_file19,
|
|
5748
|
+
L: 356,
|
|
5546
5749
|
S: this,
|
|
5547
5750
|
C: (f, a) => f(...a)
|
|
5548
5751
|
});
|
|
@@ -5552,12 +5755,10 @@ var ClientServicesHost = class {
|
|
|
5552
5755
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5553
5756
|
await this._serviceContext.initialized.wait();
|
|
5554
5757
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5555
|
-
const obj = new Properties(void 0);
|
|
5556
|
-
obj[defaultKey] = identity.identityKey.toHex();
|
|
5557
5758
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5558
5759
|
invariant16(automergeIndex, void 0, {
|
|
5559
|
-
F:
|
|
5560
|
-
L:
|
|
5760
|
+
F: __dxlog_file19,
|
|
5761
|
+
L: 368,
|
|
5561
5762
|
S: this,
|
|
5562
5763
|
A: [
|
|
5563
5764
|
"automergeIndex",
|
|
@@ -5566,12 +5767,25 @@ var ClientServicesHost = class {
|
|
|
5566
5767
|
});
|
|
5567
5768
|
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5568
5769
|
await document.whenReady();
|
|
5770
|
+
const properties = {
|
|
5771
|
+
system: {
|
|
5772
|
+
type: encodeReference(E.getTypeReference(Properties))
|
|
5773
|
+
},
|
|
5774
|
+
data: {
|
|
5775
|
+
[defaultKey]: identity.identityKey.toHex()
|
|
5776
|
+
},
|
|
5777
|
+
meta: {
|
|
5778
|
+
keys: []
|
|
5779
|
+
}
|
|
5780
|
+
};
|
|
5781
|
+
const propertiesId = PublicKey13.random().toHex();
|
|
5569
5782
|
document.change((doc) => {
|
|
5570
|
-
|
|
5783
|
+
assignDeep2(doc, [
|
|
5571
5784
|
"objects",
|
|
5572
|
-
|
|
5573
|
-
],
|
|
5785
|
+
propertiesId
|
|
5786
|
+
], properties);
|
|
5574
5787
|
});
|
|
5788
|
+
await this._serviceContext.automergeHost.repo.flush();
|
|
5575
5789
|
return identity;
|
|
5576
5790
|
}
|
|
5577
5791
|
};
|
|
@@ -5593,6 +5807,44 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5593
5807
|
Trace3.resource()
|
|
5594
5808
|
], ClientServicesHost);
|
|
5595
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
|
+
|
|
5596
5848
|
export {
|
|
5597
5849
|
Buffer,
|
|
5598
5850
|
subscribeToFeeds,
|
|
@@ -5616,15 +5868,20 @@ export {
|
|
|
5616
5868
|
InvitationsServiceImpl,
|
|
5617
5869
|
SpaceInvitationProtocol,
|
|
5618
5870
|
ClientRpcServer,
|
|
5619
|
-
createDiagnostics,
|
|
5620
5871
|
DataSpace,
|
|
5621
5872
|
DataSpaceManager,
|
|
5622
5873
|
SpacesServiceImpl,
|
|
5623
5874
|
ServiceContext,
|
|
5624
5875
|
ServiceRegistry,
|
|
5876
|
+
createDiagnostics,
|
|
5877
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5878
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5879
|
+
DiagnosticsCollector,
|
|
5625
5880
|
Lock,
|
|
5626
5881
|
isLocked,
|
|
5627
5882
|
createStorageObjects,
|
|
5628
|
-
|
|
5883
|
+
createLevel,
|
|
5884
|
+
ClientServicesHost,
|
|
5885
|
+
ClientServicesProviderResource
|
|
5629
5886
|
};
|
|
5630
|
-
//# sourceMappingURL=chunk-
|
|
5887
|
+
//# sourceMappingURL=chunk-XCFXYSCO.mjs.map
|