@dxos/client-services 0.4.8-next.fff1521 → 0.4.9-main.1057b49
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-VL6WFLTS.mjs → chunk-SUJLI7YP.mjs} +210 -281
- package/dist/lib/browser/chunk-SUJLI7YP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +6 -15
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-K2PCGWBW.cjs → chunk-VWAYL2FO.cjs} +226 -298
- package/dist/lib/node/chunk-VWAYL2FO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -39
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -17
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -5
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +3 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +2 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +5 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -3
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +2 -3
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -37
- package/src/packlets/identity/identity-manager.test.ts +0 -2
- package/src/packlets/identity/identity.test.ts +0 -4
- package/src/packlets/identity/identity.ts +1 -0
- package/src/packlets/indexing/util.ts +2 -2
- package/src/packlets/invitations/space-invitation-protocol.test.ts +3 -12
- package/src/packlets/invitations/space-invitation-protocol.ts +0 -1
- package/src/packlets/services/automerge-host.test.ts +2 -5
- package/src/packlets/services/diagnostics.ts +5 -44
- package/src/packlets/services/service-context.test.ts +3 -76
- package/src/packlets/services/service-context.ts +5 -18
- package/src/packlets/services/service-host.ts +6 -23
- package/src/packlets/spaces/automerge-space-state.ts +9 -0
- package/src/packlets/spaces/data-space-manager.test.ts +3 -145
- package/src/packlets/spaces/data-space-manager.ts +3 -18
- package/src/packlets/spaces/data-space.ts +11 -43
- package/src/packlets/spaces/spaces-service.test.ts +4 -9
- package/src/packlets/spaces/spaces-service.ts +11 -15
- package/src/packlets/testing/test-builder.ts +4 -23
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-VL6WFLTS.mjs.map +0 -7
- package/dist/lib/node/chunk-K2PCGWBW.cjs.map +0 -7
|
@@ -523,6 +523,7 @@ var Identity = class {
|
|
|
523
523
|
await this.space.open(ctx);
|
|
524
524
|
}
|
|
525
525
|
async close(ctx) {
|
|
526
|
+
await this._presence?.destroy();
|
|
526
527
|
await this.authVerifier.close();
|
|
527
528
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
528
529
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -562,7 +563,7 @@ var Identity = class {
|
|
|
562
563
|
getIdentityCredentialSigner() {
|
|
563
564
|
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
564
565
|
F: __dxlog_file2,
|
|
565
|
-
L:
|
|
566
|
+
L: 145,
|
|
566
567
|
S: this,
|
|
567
568
|
A: [
|
|
568
569
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -586,7 +587,7 @@ var Identity = class {
|
|
|
586
587
|
dataFeedKey
|
|
587
588
|
}, {
|
|
588
589
|
F: __dxlog_file2,
|
|
589
|
-
L:
|
|
590
|
+
L: 161,
|
|
590
591
|
S: this,
|
|
591
592
|
C: (f, a) => f(...a)
|
|
592
593
|
});
|
|
@@ -2576,8 +2577,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2576
2577
|
return {
|
|
2577
2578
|
space: {
|
|
2578
2579
|
credential: spaceMemberCredential,
|
|
2579
|
-
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2580
|
-
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2580
|
+
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2581
2581
|
}
|
|
2582
2582
|
};
|
|
2583
2583
|
}
|
|
@@ -2606,7 +2606,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2606
2606
|
async accept(response) {
|
|
2607
2607
|
invariant8(response.space, void 0, {
|
|
2608
2608
|
F: __dxlog_file9,
|
|
2609
|
-
L:
|
|
2609
|
+
L: 107,
|
|
2610
2610
|
S: this,
|
|
2611
2611
|
A: [
|
|
2612
2612
|
"response.space",
|
|
@@ -2617,7 +2617,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2617
2617
|
const assertion = getCredentialAssertion(credential);
|
|
2618
2618
|
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2619
2619
|
F: __dxlog_file9,
|
|
2620
|
-
L:
|
|
2620
|
+
L: 110,
|
|
2621
2621
|
S: this,
|
|
2622
2622
|
A: [
|
|
2623
2623
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2626,7 +2626,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2626
2626
|
});
|
|
2627
2627
|
invariant8(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2628
2628
|
F: __dxlog_file9,
|
|
2629
|
-
L:
|
|
2629
|
+
L: 111,
|
|
2630
2630
|
S: this,
|
|
2631
2631
|
A: [
|
|
2632
2632
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2733,10 +2733,7 @@ ClientRpcServer = _ts_decorate3([
|
|
|
2733
2733
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2734
2734
|
import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
2735
2735
|
import { credentialTypeFilter } from "@dxos/credentials";
|
|
2736
|
-
import { DocumentModel } from "@dxos/document-model";
|
|
2737
|
-
import { TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
2738
2736
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2739
|
-
import { log as log8 } from "@dxos/log";
|
|
2740
2737
|
import { STORAGE_VERSION } from "@dxos/protocols";
|
|
2741
2738
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2742
2739
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
@@ -2772,7 +2769,7 @@ var getPlatform = () => {
|
|
|
2772
2769
|
};
|
|
2773
2770
|
|
|
2774
2771
|
// packages/sdk/client-services/src/version.ts
|
|
2775
|
-
var DXOS_VERSION = "0.4.
|
|
2772
|
+
var DXOS_VERSION = "0.4.9-main.1057b49";
|
|
2776
2773
|
|
|
2777
2774
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2778
2775
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2792,7 +2789,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2792
2789
|
{
|
|
2793
2790
|
invariant9(clientServices.LoggingService, "SystemService is not available.", {
|
|
2794
2791
|
F: __dxlog_file10,
|
|
2795
|
-
L:
|
|
2792
|
+
L: 108,
|
|
2796
2793
|
S: void 0,
|
|
2797
2794
|
A: [
|
|
2798
2795
|
"clientServices.LoggingService",
|
|
@@ -2849,22 +2846,6 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2849
2846
|
diagnostics.config = config.values;
|
|
2850
2847
|
return diagnostics;
|
|
2851
2848
|
};
|
|
2852
|
-
var getProperties = (space) => {
|
|
2853
|
-
let properties = {};
|
|
2854
|
-
try {
|
|
2855
|
-
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === DocumentModel.meta.type && item.state?.type?.itemId === TYPE_PROPERTIES);
|
|
2856
|
-
const state = propertiesItem?.state;
|
|
2857
|
-
properties = state?.data;
|
|
2858
|
-
} catch (err) {
|
|
2859
|
-
log8.warn(err.message, void 0, {
|
|
2860
|
-
F: __dxlog_file10,
|
|
2861
|
-
L: 196,
|
|
2862
|
-
S: void 0,
|
|
2863
|
-
C: (f, a) => f(...a)
|
|
2864
|
-
});
|
|
2865
|
-
}
|
|
2866
|
-
return properties;
|
|
2867
|
-
};
|
|
2868
2849
|
var getSpaceStats = async (space) => {
|
|
2869
2850
|
const stats = {
|
|
2870
2851
|
key: space.key,
|
|
@@ -2884,28 +2865,14 @@ var getSpaceStats = async (space) => {
|
|
|
2884
2865
|
})),
|
|
2885
2866
|
pipeline: {
|
|
2886
2867
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
2887
|
-
|
|
2888
|
-
|
|
2868
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2869
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2889
2870
|
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2890
2871
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2891
2872
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2892
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2893
|
-
// TODO(burdon): Empty?
|
|
2894
|
-
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2895
|
-
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2896
|
-
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2897
|
-
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2898
|
-
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2873
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2899
2874
|
}
|
|
2900
2875
|
};
|
|
2901
|
-
if (space.dataPipeline.itemManager) {
|
|
2902
|
-
Object.assign(stats, {
|
|
2903
|
-
properties: getProperties(space),
|
|
2904
|
-
db: {
|
|
2905
|
-
objects: space.dataPipeline.itemManager.entities.size
|
|
2906
|
-
}
|
|
2907
|
-
});
|
|
2908
|
-
}
|
|
2909
2876
|
if (stats.metrics) {
|
|
2910
2877
|
const { open, ready } = stats.metrics;
|
|
2911
2878
|
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
@@ -2914,14 +2881,14 @@ var getSpaceStats = async (space) => {
|
|
|
2914
2881
|
};
|
|
2915
2882
|
|
|
2916
2883
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2917
|
-
import { Event as
|
|
2884
|
+
import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2918
2885
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2919
2886
|
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2920
2887
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2921
2888
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2922
2889
|
import { failedInvariant, invariant as invariant11 } from "@dxos/invariant";
|
|
2923
2890
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2924
|
-
import { log as
|
|
2891
|
+
import { log as log9 } from "@dxos/log";
|
|
2925
2892
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
2926
2893
|
import { SpaceState, CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
2927
2894
|
import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -2930,12 +2897,14 @@ import { trace as trace6 } from "@dxos/tracing";
|
|
|
2930
2897
|
import { ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
2931
2898
|
|
|
2932
2899
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
2900
|
+
import { Event as Event4 } from "@dxos/async";
|
|
2933
2901
|
import { checkCredentialType } from "@dxos/credentials";
|
|
2934
2902
|
var AutomergeSpaceState = class {
|
|
2935
2903
|
constructor(_onNewRoot) {
|
|
2936
2904
|
this._onNewRoot = _onNewRoot;
|
|
2937
2905
|
this.rootUrl = void 0;
|
|
2938
2906
|
this.lastEpoch = void 0;
|
|
2907
|
+
this.onNewEpoch = new Event4();
|
|
2939
2908
|
this._isProcessingRootDocs = false;
|
|
2940
2909
|
}
|
|
2941
2910
|
async processCredential(credential) {
|
|
@@ -2949,6 +2918,7 @@ var AutomergeSpaceState = class {
|
|
|
2949
2918
|
this._onNewRoot(this.rootUrl);
|
|
2950
2919
|
}
|
|
2951
2920
|
}
|
|
2921
|
+
this.onNewEpoch.emit(credential);
|
|
2952
2922
|
}
|
|
2953
2923
|
startProcessingRootDocs() {
|
|
2954
2924
|
if (this._isProcessingRootDocs) {
|
|
@@ -2959,14 +2929,17 @@ var AutomergeSpaceState = class {
|
|
|
2959
2929
|
}
|
|
2960
2930
|
this._isProcessingRootDocs = true;
|
|
2961
2931
|
}
|
|
2932
|
+
async ensureEpochInitialized() {
|
|
2933
|
+
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
2934
|
+
}
|
|
2962
2935
|
};
|
|
2963
2936
|
|
|
2964
2937
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2965
|
-
import { DeferredTask, Event as
|
|
2938
|
+
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2966
2939
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2967
2940
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2968
2941
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2969
|
-
import { log as
|
|
2942
|
+
import { log as log8 } from "@dxos/log";
|
|
2970
2943
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2971
2944
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2972
2945
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2, entry } from "@dxos/util";
|
|
@@ -2978,7 +2951,7 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
2978
2951
|
var NotarizationPlugin = class {
|
|
2979
2952
|
constructor() {
|
|
2980
2953
|
this._ctx = new Context7();
|
|
2981
|
-
this._extensionOpened = new
|
|
2954
|
+
this._extensionOpened = new Event5();
|
|
2982
2955
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2983
2956
|
this._processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
2984
2957
|
this._processCredentialsTriggers = new ComplexMap2(PublicKey7.hash);
|
|
@@ -2995,7 +2968,7 @@ var NotarizationPlugin = class {
|
|
|
2995
2968
|
* Request credentials to be notarized.
|
|
2996
2969
|
*/
|
|
2997
2970
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2998
|
-
|
|
2971
|
+
log8("notarize", {
|
|
2999
2972
|
credentials
|
|
3000
2973
|
}, {
|
|
3001
2974
|
F: __dxlog_file11,
|
|
@@ -3015,7 +2988,7 @@ var NotarizationPlugin = class {
|
|
|
3015
2988
|
const errors = new Trigger4();
|
|
3016
2989
|
const ctx = this._ctx.derive({
|
|
3017
2990
|
onError: (err) => {
|
|
3018
|
-
|
|
2991
|
+
log8.warn("Notarization error", {
|
|
3019
2992
|
err
|
|
3020
2993
|
}, {
|
|
3021
2994
|
F: __dxlog_file11,
|
|
@@ -3030,7 +3003,7 @@ var NotarizationPlugin = class {
|
|
|
3030
3003
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3031
3004
|
if (timeout !== 0) {
|
|
3032
3005
|
scheduleTask4(ctx, () => {
|
|
3033
|
-
|
|
3006
|
+
log8.warn("Notarization timeout", {
|
|
3034
3007
|
timeout,
|
|
3035
3008
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3036
3009
|
}, {
|
|
@@ -3054,7 +3027,7 @@ var NotarizationPlugin = class {
|
|
|
3054
3027
|
...this._extensions
|
|
3055
3028
|
].find((peer2) => !peersTried.has(peer2));
|
|
3056
3029
|
if (!peer) {
|
|
3057
|
-
|
|
3030
|
+
log8.info("Exhausted all peers to notarize with", {
|
|
3058
3031
|
retryIn: retryTimeout
|
|
3059
3032
|
}, {
|
|
3060
3033
|
F: __dxlog_file11,
|
|
@@ -3067,7 +3040,7 @@ var NotarizationPlugin = class {
|
|
|
3067
3040
|
return;
|
|
3068
3041
|
}
|
|
3069
3042
|
peersTried.add(peer);
|
|
3070
|
-
|
|
3043
|
+
log8("try notarizing", {
|
|
3071
3044
|
peer: peer.localPeerId,
|
|
3072
3045
|
credentialId: credentials.map((credential) => credential.id)
|
|
3073
3046
|
}, {
|
|
@@ -3079,7 +3052,7 @@ var NotarizationPlugin = class {
|
|
|
3079
3052
|
await peer.rpc.NotarizationService.notarize({
|
|
3080
3053
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3081
3054
|
});
|
|
3082
|
-
|
|
3055
|
+
log8("success", void 0, {
|
|
3083
3056
|
F: __dxlog_file11,
|
|
3084
3057
|
L: 147,
|
|
3085
3058
|
S: this,
|
|
@@ -3088,7 +3061,7 @@ var NotarizationPlugin = class {
|
|
|
3088
3061
|
await sleep(successDelay);
|
|
3089
3062
|
} catch (err) {
|
|
3090
3063
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3091
|
-
|
|
3064
|
+
log8.info("error notarizing (recoverable)", err, {
|
|
3092
3065
|
F: __dxlog_file11,
|
|
3093
3066
|
L: 151,
|
|
3094
3067
|
S: this,
|
|
@@ -3106,7 +3079,7 @@ var NotarizationPlugin = class {
|
|
|
3106
3079
|
allNotarized,
|
|
3107
3080
|
errors.wait()
|
|
3108
3081
|
]);
|
|
3109
|
-
|
|
3082
|
+
log8("done", void 0, {
|
|
3110
3083
|
F: __dxlog_file11,
|
|
3111
3084
|
L: 162,
|
|
3112
3085
|
S: this,
|
|
@@ -3171,7 +3144,7 @@ var NotarizationPlugin = class {
|
|
|
3171
3144
|
createExtension() {
|
|
3172
3145
|
const extension = new NotarizationTeleportExtension({
|
|
3173
3146
|
onOpen: async () => {
|
|
3174
|
-
|
|
3147
|
+
log8("extension opened", {
|
|
3175
3148
|
peer: extension.localPeerId
|
|
3176
3149
|
}, {
|
|
3177
3150
|
F: __dxlog_file11,
|
|
@@ -3183,7 +3156,7 @@ var NotarizationPlugin = class {
|
|
|
3183
3156
|
this._extensionOpened.emit();
|
|
3184
3157
|
},
|
|
3185
3158
|
onClose: async () => {
|
|
3186
|
-
|
|
3159
|
+
log8("extension closed", {
|
|
3187
3160
|
peer: extension.localPeerId
|
|
3188
3161
|
}, {
|
|
3189
3162
|
F: __dxlog_file11,
|
|
@@ -3241,7 +3214,6 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3241
3214
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3242
3215
|
}
|
|
3243
3216
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3244
|
-
var ENABLE_FEED_PURGE = false;
|
|
3245
3217
|
var DataSpace = class {
|
|
3246
3218
|
constructor(params) {
|
|
3247
3219
|
this._ctx = new Context8();
|
|
@@ -3254,7 +3226,7 @@ var DataSpace = class {
|
|
|
3254
3226
|
* Error for _state === SpaceState.ERROR.
|
|
3255
3227
|
*/
|
|
3256
3228
|
this.error = void 0;
|
|
3257
|
-
this.stateUpdate = new
|
|
3229
|
+
this.stateUpdate = new Event6();
|
|
3258
3230
|
this.metrics = {};
|
|
3259
3231
|
this._inner = params.inner;
|
|
3260
3232
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -3273,11 +3245,11 @@ var DataSpace = class {
|
|
|
3273
3245
|
});
|
|
3274
3246
|
this._cache = params.cache;
|
|
3275
3247
|
this._state = params.initialState;
|
|
3276
|
-
|
|
3248
|
+
log9("new state", {
|
|
3277
3249
|
state: SpaceState[this._state]
|
|
3278
3250
|
}, {
|
|
3279
3251
|
F: __dxlog_file12,
|
|
3280
|
-
L:
|
|
3252
|
+
L: 132,
|
|
3281
3253
|
S: this,
|
|
3282
3254
|
C: (f, a) => f(...a)
|
|
3283
3255
|
});
|
|
@@ -3295,9 +3267,6 @@ var DataSpace = class {
|
|
|
3295
3267
|
get inner() {
|
|
3296
3268
|
return this._inner;
|
|
3297
3269
|
}
|
|
3298
|
-
get dataPipeline() {
|
|
3299
|
-
return this._inner.dataPipeline;
|
|
3300
|
-
}
|
|
3301
3270
|
get presence() {
|
|
3302
3271
|
return this._presence;
|
|
3303
3272
|
}
|
|
@@ -3326,11 +3295,11 @@ var DataSpace = class {
|
|
|
3326
3295
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3327
3296
|
await this._inner.open(new Context8());
|
|
3328
3297
|
this._state = SpaceState.CONTROL_ONLY;
|
|
3329
|
-
|
|
3298
|
+
log9("new state", {
|
|
3330
3299
|
state: SpaceState[this._state]
|
|
3331
3300
|
}, {
|
|
3332
3301
|
F: __dxlog_file12,
|
|
3333
|
-
L:
|
|
3302
|
+
L: 190,
|
|
3334
3303
|
S: this,
|
|
3335
3304
|
C: (f, a) => f(...a)
|
|
3336
3305
|
});
|
|
@@ -3344,11 +3313,11 @@ var DataSpace = class {
|
|
|
3344
3313
|
async _close() {
|
|
3345
3314
|
await this._callbacks.beforeClose?.();
|
|
3346
3315
|
this._state = SpaceState.CLOSED;
|
|
3347
|
-
|
|
3316
|
+
log9("new state", {
|
|
3348
3317
|
state: SpaceState[this._state]
|
|
3349
3318
|
}, {
|
|
3350
3319
|
F: __dxlog_file12,
|
|
3351
|
-
L:
|
|
3320
|
+
L: 204,
|
|
3352
3321
|
S: this,
|
|
3353
3322
|
C: (f, a) => f(...a)
|
|
3354
3323
|
});
|
|
@@ -3378,26 +3347,26 @@ var DataSpace = class {
|
|
|
3378
3347
|
await this.initializeDataPipeline();
|
|
3379
3348
|
} catch (err) {
|
|
3380
3349
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3381
|
-
|
|
3350
|
+
log9("data pipeline initialization cancelled", err, {
|
|
3382
3351
|
F: __dxlog_file12,
|
|
3383
|
-
L:
|
|
3352
|
+
L: 237,
|
|
3384
3353
|
S: this,
|
|
3385
3354
|
C: (f, a) => f(...a)
|
|
3386
3355
|
});
|
|
3387
3356
|
return;
|
|
3388
3357
|
}
|
|
3389
|
-
|
|
3358
|
+
log9.error("Error initializing data pipeline", err, {
|
|
3390
3359
|
F: __dxlog_file12,
|
|
3391
|
-
L:
|
|
3360
|
+
L: 241,
|
|
3392
3361
|
S: this,
|
|
3393
3362
|
C: (f, a) => f(...a)
|
|
3394
3363
|
});
|
|
3395
3364
|
this._state = SpaceState.ERROR;
|
|
3396
|
-
|
|
3365
|
+
log9("new state", {
|
|
3397
3366
|
state: SpaceState[this._state]
|
|
3398
3367
|
}, {
|
|
3399
3368
|
F: __dxlog_file12,
|
|
3400
|
-
L:
|
|
3369
|
+
L: 243,
|
|
3401
3370
|
S: this,
|
|
3402
3371
|
C: (f, a) => f(...a)
|
|
3403
3372
|
});
|
|
@@ -3413,44 +3382,31 @@ var DataSpace = class {
|
|
|
3413
3382
|
throw new SystemError("Invalid operation");
|
|
3414
3383
|
}
|
|
3415
3384
|
this._state = SpaceState.INITIALIZING;
|
|
3416
|
-
|
|
3385
|
+
log9("new state", {
|
|
3417
3386
|
state: SpaceState[this._state]
|
|
3418
3387
|
}, {
|
|
3419
3388
|
F: __dxlog_file12,
|
|
3420
|
-
L:
|
|
3389
|
+
L: 259,
|
|
3421
3390
|
S: this,
|
|
3422
3391
|
C: (f, a) => f(...a)
|
|
3423
3392
|
});
|
|
3424
3393
|
await this._initializeAndReadControlPipeline();
|
|
3425
3394
|
await sleep2(1);
|
|
3426
3395
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3427
|
-
await this.
|
|
3428
|
-
|
|
3429
|
-
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3430
|
-
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3396
|
+
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3397
|
+
log9("data pipeline ready", void 0, {
|
|
3431
3398
|
F: __dxlog_file12,
|
|
3432
|
-
L:
|
|
3433
|
-
S: this,
|
|
3434
|
-
C: (f, a) => f(...a)
|
|
3435
|
-
});
|
|
3436
|
-
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
3437
|
-
ctx: this._ctx,
|
|
3438
|
-
breakOnStall: false
|
|
3439
|
-
});
|
|
3440
|
-
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3441
|
-
log10("data pipeline ready", void 0, {
|
|
3442
|
-
F: __dxlog_file12,
|
|
3443
|
-
L: 296,
|
|
3399
|
+
L: 271,
|
|
3444
3400
|
S: this,
|
|
3445
3401
|
C: (f, a) => f(...a)
|
|
3446
3402
|
});
|
|
3447
3403
|
await this._callbacks.beforeReady?.();
|
|
3448
3404
|
this._state = SpaceState.READY;
|
|
3449
|
-
|
|
3405
|
+
log9("new state", {
|
|
3450
3406
|
state: SpaceState[this._state]
|
|
3451
3407
|
}, {
|
|
3452
3408
|
F: __dxlog_file12,
|
|
3453
|
-
L:
|
|
3409
|
+
L: 275,
|
|
3454
3410
|
S: this,
|
|
3455
3411
|
C: (f, a) => f(...a)
|
|
3456
3412
|
});
|
|
@@ -3464,9 +3420,9 @@ var DataSpace = class {
|
|
|
3464
3420
|
});
|
|
3465
3421
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3466
3422
|
await this._createWritableFeeds();
|
|
3467
|
-
|
|
3423
|
+
log9("writable feeds created", void 0, {
|
|
3468
3424
|
F: __dxlog_file12,
|
|
3469
|
-
L:
|
|
3425
|
+
L: 291,
|
|
3470
3426
|
S: this,
|
|
3471
3427
|
C: (f, a) => f(...a)
|
|
3472
3428
|
});
|
|
@@ -3524,12 +3480,12 @@ var DataSpace = class {
|
|
|
3524
3480
|
}
|
|
3525
3481
|
}
|
|
3526
3482
|
_onNewAutomergeRoot(rootUrl) {
|
|
3527
|
-
|
|
3483
|
+
log9("loading automerge root doc for space", {
|
|
3528
3484
|
space: this.key,
|
|
3529
3485
|
rootUrl
|
|
3530
3486
|
}, {
|
|
3531
3487
|
F: __dxlog_file12,
|
|
3532
|
-
L:
|
|
3488
|
+
L: 357,
|
|
3533
3489
|
S: this,
|
|
3534
3490
|
C: (f, a) => f(...a)
|
|
3535
3491
|
});
|
|
@@ -3555,13 +3511,13 @@ var DataSpace = class {
|
|
|
3555
3511
|
if (err instanceof ContextDisposedError) {
|
|
3556
3512
|
return;
|
|
3557
3513
|
}
|
|
3558
|
-
|
|
3514
|
+
log9.warn("error loading automerge root doc", {
|
|
3559
3515
|
space: this.key,
|
|
3560
3516
|
rootUrl,
|
|
3561
3517
|
err
|
|
3562
3518
|
}, {
|
|
3563
3519
|
F: __dxlog_file12,
|
|
3564
|
-
L:
|
|
3520
|
+
L: 380,
|
|
3565
3521
|
S: this,
|
|
3566
3522
|
C: (f, a) => f(...a)
|
|
3567
3523
|
});
|
|
@@ -3589,7 +3545,12 @@ var DataSpace = class {
|
|
|
3589
3545
|
case void 0:
|
|
3590
3546
|
case CreateEpochRequest.Migration.NONE:
|
|
3591
3547
|
{
|
|
3592
|
-
epoch =
|
|
3548
|
+
epoch = {
|
|
3549
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3550
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3551
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
|
|
3552
|
+
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
3553
|
+
};
|
|
3593
3554
|
}
|
|
3594
3555
|
break;
|
|
3595
3556
|
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
@@ -3611,7 +3572,7 @@ var DataSpace = class {
|
|
|
3611
3572
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3612
3573
|
invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3613
3574
|
F: __dxlog_file12,
|
|
3614
|
-
L:
|
|
3575
|
+
L: 430,
|
|
3615
3576
|
S: this,
|
|
3616
3577
|
A: [
|
|
3617
3578
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3647,15 +3608,6 @@ var DataSpace = class {
|
|
|
3647
3608
|
receipt.seq
|
|
3648
3609
|
]
|
|
3649
3610
|
]));
|
|
3650
|
-
if (ENABLE_FEED_PURGE) {
|
|
3651
|
-
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3652
|
-
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3653
|
-
if (indexBeforeEpoch === void 0) {
|
|
3654
|
-
continue;
|
|
3655
|
-
}
|
|
3656
|
-
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
3657
|
-
}
|
|
3658
|
-
}
|
|
3659
3611
|
}
|
|
3660
3612
|
async activate() {
|
|
3661
3613
|
if (this._state !== SpaceState.INACTIVE) {
|
|
@@ -3672,11 +3624,11 @@ var DataSpace = class {
|
|
|
3672
3624
|
await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
|
|
3673
3625
|
await this._close();
|
|
3674
3626
|
this._state = SpaceState.INACTIVE;
|
|
3675
|
-
|
|
3627
|
+
log9("new state", {
|
|
3676
3628
|
state: SpaceState[this._state]
|
|
3677
3629
|
}, {
|
|
3678
3630
|
F: __dxlog_file12,
|
|
3679
|
-
L:
|
|
3631
|
+
L: 482,
|
|
3680
3632
|
S: this,
|
|
3681
3633
|
C: (f, a) => f(...a)
|
|
3682
3634
|
});
|
|
@@ -3730,12 +3682,12 @@ DataSpace = _ts_decorate4([
|
|
|
3730
3682
|
], DataSpace);
|
|
3731
3683
|
|
|
3732
3684
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3733
|
-
import { Event as
|
|
3734
|
-
import {
|
|
3685
|
+
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3686
|
+
import { Context as Context9, cancelWithContext as cancelWithContext3 } from "@dxos/context";
|
|
3735
3687
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3736
3688
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3737
3689
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3738
|
-
import { log as
|
|
3690
|
+
import { log as log10 } from "@dxos/log";
|
|
3739
3691
|
import { trace as trace7 } from "@dxos/protocols";
|
|
3740
3692
|
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3741
3693
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
@@ -3826,16 +3778,15 @@ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3826
3778
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3827
3779
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3828
3780
|
var DataSpaceManager = class {
|
|
3829
|
-
constructor(_spaceManager, _metadataStore,
|
|
3781
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, params) {
|
|
3830
3782
|
this._spaceManager = _spaceManager;
|
|
3831
3783
|
this._metadataStore = _metadataStore;
|
|
3832
|
-
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
3833
3784
|
this._keyring = _keyring;
|
|
3834
3785
|
this._signingContext = _signingContext;
|
|
3835
3786
|
this._feedStore = _feedStore;
|
|
3836
3787
|
this._automergeHost = _automergeHost;
|
|
3837
3788
|
this._ctx = new Context9();
|
|
3838
|
-
this.updated = new
|
|
3789
|
+
this.updated = new Event7();
|
|
3839
3790
|
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
3840
3791
|
this._isOpen = false;
|
|
3841
3792
|
this._instanceId = PublicKey9.random().toHex();
|
|
@@ -3848,46 +3799,46 @@ var DataSpaceManager = class {
|
|
|
3848
3799
|
return this._spaces;
|
|
3849
3800
|
}
|
|
3850
3801
|
async open() {
|
|
3851
|
-
|
|
3802
|
+
log10("open", void 0, {
|
|
3852
3803
|
F: __dxlog_file13,
|
|
3853
|
-
L:
|
|
3804
|
+
L: 98,
|
|
3854
3805
|
S: this,
|
|
3855
3806
|
C: (f, a) => f(...a)
|
|
3856
3807
|
});
|
|
3857
|
-
|
|
3808
|
+
log10.trace("dxos.echo.data-space-manager.open", trace7.begin({
|
|
3858
3809
|
id: this._instanceId
|
|
3859
3810
|
}), {
|
|
3860
3811
|
F: __dxlog_file13,
|
|
3861
|
-
L:
|
|
3812
|
+
L: 99,
|
|
3862
3813
|
S: this,
|
|
3863
3814
|
C: (f, a) => f(...a)
|
|
3864
3815
|
});
|
|
3865
|
-
|
|
3816
|
+
log10("metadata loaded", {
|
|
3866
3817
|
spaces: this._metadataStore.spaces.length
|
|
3867
3818
|
}, {
|
|
3868
3819
|
F: __dxlog_file13,
|
|
3869
|
-
L:
|
|
3820
|
+
L: 100,
|
|
3870
3821
|
S: this,
|
|
3871
3822
|
C: (f, a) => f(...a)
|
|
3872
3823
|
});
|
|
3873
3824
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
3874
3825
|
try {
|
|
3875
|
-
|
|
3826
|
+
log10("load space", {
|
|
3876
3827
|
spaceMetadata
|
|
3877
3828
|
}, {
|
|
3878
3829
|
F: __dxlog_file13,
|
|
3879
|
-
L:
|
|
3830
|
+
L: 104,
|
|
3880
3831
|
S: this,
|
|
3881
3832
|
C: (f, a) => f(...a)
|
|
3882
3833
|
});
|
|
3883
3834
|
await this._constructSpace(spaceMetadata);
|
|
3884
3835
|
} catch (err) {
|
|
3885
|
-
|
|
3836
|
+
log10.error("Error loading space", {
|
|
3886
3837
|
spaceMetadata,
|
|
3887
3838
|
err
|
|
3888
3839
|
}, {
|
|
3889
3840
|
F: __dxlog_file13,
|
|
3890
|
-
L:
|
|
3841
|
+
L: 107,
|
|
3891
3842
|
S: this,
|
|
3892
3843
|
C: (f, a) => f(...a)
|
|
3893
3844
|
});
|
|
@@ -3900,19 +3851,19 @@ var DataSpaceManager = class {
|
|
|
3900
3851
|
space.initializeDataPipelineAsync();
|
|
3901
3852
|
}
|
|
3902
3853
|
}
|
|
3903
|
-
|
|
3854
|
+
log10.trace("dxos.echo.data-space-manager.open", trace7.end({
|
|
3904
3855
|
id: this._instanceId
|
|
3905
3856
|
}), {
|
|
3906
3857
|
F: __dxlog_file13,
|
|
3907
|
-
L:
|
|
3858
|
+
L: 120,
|
|
3908
3859
|
S: this,
|
|
3909
3860
|
C: (f, a) => f(...a)
|
|
3910
3861
|
});
|
|
3911
3862
|
}
|
|
3912
3863
|
async close() {
|
|
3913
|
-
|
|
3864
|
+
log10("close", void 0, {
|
|
3914
3865
|
F: __dxlog_file13,
|
|
3915
|
-
L:
|
|
3866
|
+
L: 125,
|
|
3916
3867
|
S: this,
|
|
3917
3868
|
C: (f, a) => f(...a)
|
|
3918
3869
|
});
|
|
@@ -3928,7 +3879,7 @@ var DataSpaceManager = class {
|
|
|
3928
3879
|
async createSpace() {
|
|
3929
3880
|
invariant12(this._isOpen, "Not open.", {
|
|
3930
3881
|
F: __dxlog_file13,
|
|
3931
|
-
L:
|
|
3882
|
+
L: 138,
|
|
3932
3883
|
S: this,
|
|
3933
3884
|
A: [
|
|
3934
3885
|
"this._isOpen",
|
|
@@ -3945,11 +3896,11 @@ var DataSpaceManager = class {
|
|
|
3945
3896
|
dataFeedKey,
|
|
3946
3897
|
state: SpaceState2.ACTIVE
|
|
3947
3898
|
};
|
|
3948
|
-
|
|
3899
|
+
log10("creating space...", {
|
|
3949
3900
|
spaceKey
|
|
3950
3901
|
}, {
|
|
3951
3902
|
F: __dxlog_file13,
|
|
3952
|
-
L:
|
|
3903
|
+
L: 150,
|
|
3953
3904
|
S: this,
|
|
3954
3905
|
C: (f, a) => f(...a)
|
|
3955
3906
|
});
|
|
@@ -3965,7 +3916,7 @@ var DataSpaceManager = class {
|
|
|
3965
3916
|
const memberCredential = credentials[1];
|
|
3966
3917
|
invariant12(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3967
3918
|
F: __dxlog_file13,
|
|
3968
|
-
L:
|
|
3919
|
+
L: 163,
|
|
3969
3920
|
S: this,
|
|
3970
3921
|
A: [
|
|
3971
3922
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3979,17 +3930,17 @@ var DataSpaceManager = class {
|
|
|
3979
3930
|
}
|
|
3980
3931
|
// TODO(burdon): Rename join space.
|
|
3981
3932
|
async acceptSpace(opts) {
|
|
3982
|
-
|
|
3933
|
+
log10("accept space", {
|
|
3983
3934
|
opts
|
|
3984
3935
|
}, {
|
|
3985
3936
|
F: __dxlog_file13,
|
|
3986
|
-
L:
|
|
3937
|
+
L: 175,
|
|
3987
3938
|
S: this,
|
|
3988
3939
|
C: (f, a) => f(...a)
|
|
3989
3940
|
});
|
|
3990
3941
|
invariant12(this._isOpen, "Not open.", {
|
|
3991
3942
|
F: __dxlog_file13,
|
|
3992
|
-
L:
|
|
3943
|
+
L: 176,
|
|
3993
3944
|
S: this,
|
|
3994
3945
|
A: [
|
|
3995
3946
|
"this._isOpen",
|
|
@@ -3998,7 +3949,7 @@ var DataSpaceManager = class {
|
|
|
3998
3949
|
});
|
|
3999
3950
|
invariant12(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4000
3951
|
F: __dxlog_file13,
|
|
4001
|
-
L:
|
|
3952
|
+
L: 177,
|
|
4002
3953
|
S: this,
|
|
4003
3954
|
A: [
|
|
4004
3955
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4029,11 +3980,11 @@ var DataSpaceManager = class {
|
|
|
4029
3980
|
}));
|
|
4030
3981
|
}
|
|
4031
3982
|
async _constructSpace(metadata) {
|
|
4032
|
-
|
|
3983
|
+
log10("construct space", {
|
|
4033
3984
|
metadata
|
|
4034
3985
|
}, {
|
|
4035
3986
|
F: __dxlog_file13,
|
|
4036
|
-
L:
|
|
3987
|
+
L: 210,
|
|
4037
3988
|
S: this,
|
|
4038
3989
|
C: (f, a) => f(...a)
|
|
4039
3990
|
});
|
|
@@ -4069,9 +4020,9 @@ var DataSpaceManager = class {
|
|
|
4069
4020
|
session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
|
|
4070
4021
|
},
|
|
4071
4022
|
onAuthFailure: () => {
|
|
4072
|
-
|
|
4023
|
+
log10.warn("auth failure", void 0, {
|
|
4073
4024
|
F: __dxlog_file13,
|
|
4074
|
-
L:
|
|
4025
|
+
L: 247,
|
|
4075
4026
|
S: this,
|
|
4076
4027
|
C: (f, a) => f(...a)
|
|
4077
4028
|
});
|
|
@@ -4091,23 +4042,22 @@ var DataSpaceManager = class {
|
|
|
4091
4042
|
signingContext: this._signingContext,
|
|
4092
4043
|
callbacks: {
|
|
4093
4044
|
beforeReady: async () => {
|
|
4094
|
-
|
|
4045
|
+
log10("before space ready", {
|
|
4095
4046
|
space: space.key
|
|
4096
4047
|
}, {
|
|
4097
4048
|
F: __dxlog_file13,
|
|
4098
|
-
L:
|
|
4049
|
+
L: 265,
|
|
4099
4050
|
S: this,
|
|
4100
4051
|
C: (f, a) => f(...a)
|
|
4101
4052
|
});
|
|
4102
|
-
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
4103
4053
|
},
|
|
4104
4054
|
afterReady: async () => {
|
|
4105
|
-
|
|
4055
|
+
log10("after space ready", {
|
|
4106
4056
|
space: space.key,
|
|
4107
4057
|
open: this._isOpen
|
|
4108
4058
|
}, {
|
|
4109
4059
|
F: __dxlog_file13,
|
|
4110
|
-
L:
|
|
4060
|
+
L: 268,
|
|
4111
4061
|
S: this,
|
|
4112
4062
|
C: (f, a) => f(...a)
|
|
4113
4063
|
});
|
|
@@ -4116,15 +4066,14 @@ var DataSpaceManager = class {
|
|
|
4116
4066
|
}
|
|
4117
4067
|
},
|
|
4118
4068
|
beforeClose: async () => {
|
|
4119
|
-
|
|
4069
|
+
log10("before space close", {
|
|
4120
4070
|
space: space.key
|
|
4121
4071
|
}, {
|
|
4122
4072
|
F: __dxlog_file13,
|
|
4123
|
-
L:
|
|
4073
|
+
L: 274,
|
|
4124
4074
|
S: this,
|
|
4125
4075
|
C: (f, a) => f(...a)
|
|
4126
4076
|
});
|
|
4127
|
-
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
4128
4077
|
}
|
|
4129
4078
|
},
|
|
4130
4079
|
cache: metadata.cache,
|
|
@@ -4136,9 +4085,6 @@ var DataSpaceManager = class {
|
|
|
4136
4085
|
if (metadata.controlTimeframe) {
|
|
4137
4086
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
4138
4087
|
}
|
|
4139
|
-
if (metadata.dataTimeframe) {
|
|
4140
|
-
dataSpace.dataPipeline.setTargetTimeframe(metadata.dataTimeframe);
|
|
4141
|
-
}
|
|
4142
4088
|
this._spaces.set(metadata.key, dataSpace);
|
|
4143
4089
|
return dataSpace;
|
|
4144
4090
|
}
|
|
@@ -4164,15 +4110,14 @@ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTas
|
|
|
4164
4110
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4165
4111
|
import { raise as raise2 } from "@dxos/debug";
|
|
4166
4112
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4167
|
-
import { log as
|
|
4113
|
+
import { log as log11 } from "@dxos/log";
|
|
4168
4114
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4169
4115
|
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4170
4116
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4171
4117
|
var SpacesServiceImpl = class {
|
|
4172
|
-
constructor(_identityManager, _spaceManager,
|
|
4118
|
+
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4173
4119
|
this._identityManager = _identityManager;
|
|
4174
4120
|
this._spaceManager = _spaceManager;
|
|
4175
|
-
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
4176
4121
|
this._getDataSpaceManager = _getDataSpaceManager;
|
|
4177
4122
|
}
|
|
4178
4123
|
async createSpace() {
|
|
@@ -4204,11 +4149,11 @@ var SpacesServiceImpl = class {
|
|
|
4204
4149
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
4205
4150
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4206
4151
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4207
|
-
|
|
4152
|
+
log11("update", {
|
|
4208
4153
|
spaces
|
|
4209
4154
|
}, {
|
|
4210
4155
|
F: __dxlog_file14,
|
|
4211
|
-
L:
|
|
4156
|
+
L: 77,
|
|
4212
4157
|
S: this,
|
|
4213
4158
|
C: (f, a) => f(...a)
|
|
4214
4159
|
});
|
|
@@ -4227,11 +4172,8 @@ var SpacesServiceImpl = class {
|
|
|
4227
4172
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
4228
4173
|
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.forceTrigger()));
|
|
4229
4174
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
4230
|
-
subscriptions.add(space.
|
|
4175
|
+
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
4231
4176
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
4232
|
-
if (space.dataPipeline.pipelineState) {
|
|
4233
|
-
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
4234
|
-
}
|
|
4235
4177
|
}
|
|
4236
4178
|
};
|
|
4237
4179
|
dataSpaceManager.updated.on(ctx, () => {
|
|
@@ -4294,7 +4236,7 @@ var SpacesServiceImpl = class {
|
|
|
4294
4236
|
} else {
|
|
4295
4237
|
invariant13(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4296
4238
|
F: __dxlog_file14,
|
|
4297
|
-
L:
|
|
4239
|
+
L: 164,
|
|
4298
4240
|
S: this,
|
|
4299
4241
|
A: [
|
|
4300
4242
|
"!credential.id",
|
|
@@ -4303,7 +4245,7 @@ var SpacesServiceImpl = class {
|
|
|
4303
4245
|
});
|
|
4304
4246
|
invariant13(this._identityManager.identity, "Identity is not available", {
|
|
4305
4247
|
F: __dxlog_file14,
|
|
4306
|
-
L:
|
|
4248
|
+
L: 165,
|
|
4307
4249
|
S: this,
|
|
4308
4250
|
A: [
|
|
4309
4251
|
"this._identityManager.identity",
|
|
@@ -4313,7 +4255,7 @@ var SpacesServiceImpl = class {
|
|
|
4313
4255
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4314
4256
|
invariant13(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4315
4257
|
F: __dxlog_file14,
|
|
4316
|
-
L:
|
|
4258
|
+
L: 167,
|
|
4317
4259
|
S: this,
|
|
4318
4260
|
A: [
|
|
4319
4261
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -4345,17 +4287,17 @@ var SpacesServiceImpl = class {
|
|
|
4345
4287
|
state: space.state,
|
|
4346
4288
|
error: space.error ? encodeError(space.error) : void 0,
|
|
4347
4289
|
pipeline: {
|
|
4348
|
-
currentEpoch: space.
|
|
4349
|
-
appliedEpoch: space.
|
|
4290
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4291
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4350
4292
|
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4351
4293
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4352
4294
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4353
4295
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
4354
|
-
dataFeeds:
|
|
4355
|
-
startDataTimeframe:
|
|
4356
|
-
currentDataTimeframe:
|
|
4357
|
-
targetDataTimeframe:
|
|
4358
|
-
totalDataTimeframe:
|
|
4296
|
+
dataFeeds: void 0,
|
|
4297
|
+
startDataTimeframe: void 0,
|
|
4298
|
+
currentDataTimeframe: void 0,
|
|
4299
|
+
targetDataTimeframe: void 0,
|
|
4300
|
+
totalDataTimeframe: void 0
|
|
4359
4301
|
},
|
|
4360
4302
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
4361
4303
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
@@ -4385,13 +4327,13 @@ import { Trigger as Trigger5 } from "@dxos/async";
|
|
|
4385
4327
|
import { Context as Context10 } from "@dxos/context";
|
|
4386
4328
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4387
4329
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4388
|
-
import {
|
|
4330
|
+
import { AutomergeHost, MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
4389
4331
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4390
4332
|
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4391
4333
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4392
4334
|
import { Keyring } from "@dxos/keyring";
|
|
4393
4335
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4394
|
-
import { log as
|
|
4336
|
+
import { log as log12 } from "@dxos/log";
|
|
4395
4337
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace8 } from "@dxos/protocols";
|
|
4396
4338
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4397
4339
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -4414,12 +4356,12 @@ var createLoadDocuments = (automergeHost) => (
|
|
|
4414
4356
|
const handle = automergeHost.repo.find(documentId);
|
|
4415
4357
|
await warnAfterTimeout2(5e3, "to long to load doc", () => handle.whenReady());
|
|
4416
4358
|
const doc = handle.docSync();
|
|
4417
|
-
const
|
|
4359
|
+
const hash = getHeads(doc).join("");
|
|
4418
4360
|
yield [
|
|
4419
4361
|
{
|
|
4420
4362
|
id,
|
|
4421
4363
|
object: doc.objects[objectId],
|
|
4422
|
-
currentHash:
|
|
4364
|
+
currentHash: hash
|
|
4423
4365
|
}
|
|
4424
4366
|
];
|
|
4425
4367
|
}
|
|
@@ -4490,14 +4432,12 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4490
4432
|
}
|
|
4491
4433
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4492
4434
|
var ServiceContext = class {
|
|
4493
|
-
constructor(storage, networkManager, signalManager,
|
|
4435
|
+
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4494
4436
|
this.storage = storage;
|
|
4495
4437
|
this.networkManager = networkManager;
|
|
4496
4438
|
this.signalManager = signalManager;
|
|
4497
|
-
this.modelFactory = modelFactory;
|
|
4498
4439
|
this._runtimeParams = _runtimeParams;
|
|
4499
4440
|
this.initialized = new Trigger5();
|
|
4500
|
-
this.dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
4501
4441
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4502
4442
|
this._instanceId = PublicKey10.random().toHex();
|
|
4503
4443
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -4519,7 +4459,6 @@ var ServiceContext = class {
|
|
|
4519
4459
|
networkManager: this.networkManager,
|
|
4520
4460
|
blobStore: this.blobStore,
|
|
4521
4461
|
metadataStore: this.metadataStore,
|
|
4522
|
-
modelFactory: this.modelFactory,
|
|
4523
4462
|
snapshotStore: this.snapshotStore
|
|
4524
4463
|
});
|
|
4525
4464
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
@@ -4543,17 +4482,17 @@ var ServiceContext = class {
|
|
|
4543
4482
|
}
|
|
4544
4483
|
async open(ctx) {
|
|
4545
4484
|
await this._checkStorageVersion();
|
|
4546
|
-
|
|
4485
|
+
log12("opening...", void 0, {
|
|
4547
4486
|
F: __dxlog_file15,
|
|
4548
|
-
L:
|
|
4487
|
+
L: 151,
|
|
4549
4488
|
S: this,
|
|
4550
4489
|
C: (f, a) => f(...a)
|
|
4551
4490
|
});
|
|
4552
|
-
|
|
4491
|
+
log12.trace("dxos.sdk.service-context.open", trace8.begin({
|
|
4553
4492
|
id: this._instanceId
|
|
4554
4493
|
}), {
|
|
4555
4494
|
F: __dxlog_file15,
|
|
4556
|
-
L:
|
|
4495
|
+
L: 152,
|
|
4557
4496
|
S: this,
|
|
4558
4497
|
C: (f, a) => f(...a)
|
|
4559
4498
|
});
|
|
@@ -4565,25 +4504,25 @@ var ServiceContext = class {
|
|
|
4565
4504
|
if (this.identityManager.identity) {
|
|
4566
4505
|
await this._initialize(ctx);
|
|
4567
4506
|
}
|
|
4568
|
-
|
|
4507
|
+
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4569
4508
|
id: this._instanceId
|
|
4570
4509
|
}), {
|
|
4571
4510
|
F: __dxlog_file15,
|
|
4572
|
-
L:
|
|
4511
|
+
L: 162,
|
|
4573
4512
|
S: this,
|
|
4574
4513
|
C: (f, a) => f(...a)
|
|
4575
4514
|
});
|
|
4576
|
-
|
|
4515
|
+
log12("opened", void 0, {
|
|
4577
4516
|
F: __dxlog_file15,
|
|
4578
|
-
L:
|
|
4517
|
+
L: 163,
|
|
4579
4518
|
S: this,
|
|
4580
4519
|
C: (f, a) => f(...a)
|
|
4581
4520
|
});
|
|
4582
4521
|
}
|
|
4583
4522
|
async close() {
|
|
4584
|
-
|
|
4523
|
+
log12("closing...", void 0, {
|
|
4585
4524
|
F: __dxlog_file15,
|
|
4586
|
-
L:
|
|
4525
|
+
L: 167,
|
|
4587
4526
|
S: this,
|
|
4588
4527
|
C: (f, a) => f(...a)
|
|
4589
4528
|
});
|
|
@@ -4597,12 +4536,11 @@ var ServiceContext = class {
|
|
|
4597
4536
|
await this.feedStore.close();
|
|
4598
4537
|
await this.networkManager.close();
|
|
4599
4538
|
await this.signalManager.close();
|
|
4600
|
-
this.dataServiceSubscriptions.clear();
|
|
4601
4539
|
await this.metadataStore.close();
|
|
4602
4540
|
await this.indexer.destroy();
|
|
4603
|
-
|
|
4541
|
+
log12("closed", void 0, {
|
|
4604
4542
|
F: __dxlog_file15,
|
|
4605
|
-
L:
|
|
4543
|
+
L: 180,
|
|
4606
4544
|
S: this,
|
|
4607
4545
|
C: (f, a) => f(...a)
|
|
4608
4546
|
});
|
|
@@ -4616,7 +4554,7 @@ var ServiceContext = class {
|
|
|
4616
4554
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4617
4555
|
invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4618
4556
|
F: __dxlog_file15,
|
|
4619
|
-
L:
|
|
4557
|
+
L: 191,
|
|
4620
4558
|
S: this,
|
|
4621
4559
|
A: [
|
|
4622
4560
|
"factory",
|
|
@@ -4646,9 +4584,9 @@ var ServiceContext = class {
|
|
|
4646
4584
|
}
|
|
4647
4585
|
// Called when identity is created.
|
|
4648
4586
|
async _initialize(ctx) {
|
|
4649
|
-
|
|
4587
|
+
log12("initializing spaces...", void 0, {
|
|
4650
4588
|
F: __dxlog_file15,
|
|
4651
|
-
L:
|
|
4589
|
+
L: 222,
|
|
4652
4590
|
S: this,
|
|
4653
4591
|
C: (f, a) => f(...a)
|
|
4654
4592
|
});
|
|
@@ -4666,12 +4604,12 @@ var ServiceContext = class {
|
|
|
4666
4604
|
});
|
|
4667
4605
|
}
|
|
4668
4606
|
};
|
|
4669
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.
|
|
4607
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4670
4608
|
await this.dataSpaceManager.open();
|
|
4671
4609
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4672
4610
|
invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4673
4611
|
F: __dxlog_file15,
|
|
4674
|
-
L:
|
|
4612
|
+
L: 246,
|
|
4675
4613
|
S: this,
|
|
4676
4614
|
A: [
|
|
4677
4615
|
"this.dataSpaceManager",
|
|
@@ -4691,33 +4629,33 @@ var ServiceContext = class {
|
|
|
4691
4629
|
return;
|
|
4692
4630
|
}
|
|
4693
4631
|
if (!this.dataSpaceManager) {
|
|
4694
|
-
|
|
4632
|
+
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4695
4633
|
details: assertion
|
|
4696
4634
|
}, {
|
|
4697
4635
|
F: __dxlog_file15,
|
|
4698
|
-
L:
|
|
4636
|
+
L: 262,
|
|
4699
4637
|
S: this,
|
|
4700
4638
|
C: (f, a) => f(...a)
|
|
4701
4639
|
});
|
|
4702
4640
|
return;
|
|
4703
4641
|
}
|
|
4704
4642
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
4705
|
-
|
|
4643
|
+
log12("space already exists, ignoring space admission", {
|
|
4706
4644
|
details: assertion
|
|
4707
4645
|
}, {
|
|
4708
4646
|
F: __dxlog_file15,
|
|
4709
|
-
L:
|
|
4647
|
+
L: 266,
|
|
4710
4648
|
S: this,
|
|
4711
4649
|
C: (f, a) => f(...a)
|
|
4712
4650
|
});
|
|
4713
4651
|
return;
|
|
4714
4652
|
}
|
|
4715
4653
|
try {
|
|
4716
|
-
|
|
4654
|
+
log12("accepting space recorded in halo", {
|
|
4717
4655
|
details: assertion
|
|
4718
4656
|
}, {
|
|
4719
4657
|
F: __dxlog_file15,
|
|
4720
|
-
L:
|
|
4658
|
+
L: 271,
|
|
4721
4659
|
S: this,
|
|
4722
4660
|
C: (f, a) => f(...a)
|
|
4723
4661
|
});
|
|
@@ -4726,9 +4664,9 @@ var ServiceContext = class {
|
|
|
4726
4664
|
genesisFeedKey: assertion.genesisFeedKey
|
|
4727
4665
|
});
|
|
4728
4666
|
} catch (err) {
|
|
4729
|
-
|
|
4667
|
+
log12.catch(err, void 0, {
|
|
4730
4668
|
F: __dxlog_file15,
|
|
4731
|
-
L:
|
|
4669
|
+
L: 277,
|
|
4732
4670
|
S: this,
|
|
4733
4671
|
C: (f, a) => f(...a)
|
|
4734
4672
|
});
|
|
@@ -4776,7 +4714,7 @@ var ServiceRegistry = class {
|
|
|
4776
4714
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4777
4715
|
import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
|
|
4778
4716
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4779
|
-
import { log as
|
|
4717
|
+
import { log as log13, logInfo } from "@dxos/log";
|
|
4780
4718
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
4781
4719
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4782
4720
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4809,28 +4747,28 @@ var Lock = class {
|
|
|
4809
4747
|
message: "acquiring"
|
|
4810
4748
|
});
|
|
4811
4749
|
try {
|
|
4812
|
-
|
|
4750
|
+
log13("aquiring lock...", void 0, {
|
|
4813
4751
|
F: __dxlog_file16,
|
|
4814
4752
|
L: 42,
|
|
4815
4753
|
S: this,
|
|
4816
4754
|
C: (f, a) => f(...a)
|
|
4817
4755
|
});
|
|
4818
4756
|
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4819
|
-
|
|
4757
|
+
log13("acquired lock", void 0, {
|
|
4820
4758
|
F: __dxlog_file16,
|
|
4821
4759
|
L: 44,
|
|
4822
4760
|
S: this,
|
|
4823
4761
|
C: (f, a) => f(...a)
|
|
4824
4762
|
});
|
|
4825
4763
|
} catch {
|
|
4826
|
-
|
|
4764
|
+
log13("stealing lock...", void 0, {
|
|
4827
4765
|
F: __dxlog_file16,
|
|
4828
4766
|
L: 46,
|
|
4829
4767
|
S: this,
|
|
4830
4768
|
C: (f, a) => f(...a)
|
|
4831
4769
|
});
|
|
4832
4770
|
await this._requestLock(true);
|
|
4833
|
-
|
|
4771
|
+
log13("stolen lock", void 0, {
|
|
4834
4772
|
F: __dxlog_file16,
|
|
4835
4773
|
L: 48,
|
|
4836
4774
|
S: this,
|
|
@@ -4847,7 +4785,7 @@ var Lock = class {
|
|
|
4847
4785
|
}
|
|
4848
4786
|
}
|
|
4849
4787
|
async _requestLock(steal = false) {
|
|
4850
|
-
|
|
4788
|
+
log13("requesting lock...", {
|
|
4851
4789
|
steal
|
|
4852
4790
|
}, {
|
|
4853
4791
|
F: __dxlog_file16,
|
|
@@ -4863,14 +4801,14 @@ var Lock = class {
|
|
|
4863
4801
|
acquired.wake();
|
|
4864
4802
|
this._releaseTrigger = new Trigger6();
|
|
4865
4803
|
await this._releaseTrigger.wait();
|
|
4866
|
-
|
|
4804
|
+
log13("releasing lock...", void 0, {
|
|
4867
4805
|
F: __dxlog_file16,
|
|
4868
4806
|
L: 72,
|
|
4869
4807
|
S: this,
|
|
4870
4808
|
C: (f, a) => f(...a)
|
|
4871
4809
|
});
|
|
4872
4810
|
await this._onRelease?.();
|
|
4873
|
-
|
|
4811
|
+
log13("released lock", void 0, {
|
|
4874
4812
|
F: __dxlog_file16,
|
|
4875
4813
|
L: 74,
|
|
4876
4814
|
S: this,
|
|
@@ -4880,7 +4818,7 @@ var Lock = class {
|
|
|
4880
4818
|
await this._onRelease?.();
|
|
4881
4819
|
});
|
|
4882
4820
|
await acquired.wait();
|
|
4883
|
-
|
|
4821
|
+
log13("recieved lock", {
|
|
4884
4822
|
steal
|
|
4885
4823
|
}, {
|
|
4886
4824
|
F: __dxlog_file16,
|
|
@@ -4947,22 +4885,19 @@ var toStorageType = (type) => {
|
|
|
4947
4885
|
};
|
|
4948
4886
|
|
|
4949
4887
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4950
|
-
import { Event as
|
|
4951
|
-
import { clientServiceBundle, defaultKey
|
|
4888
|
+
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4889
|
+
import { Properties, clientServiceBundle, defaultKey } from "@dxos/client-protocol";
|
|
4952
4890
|
import { Context as Context11 } from "@dxos/context";
|
|
4953
|
-
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4954
4891
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4955
|
-
import {
|
|
4892
|
+
import { getAutomergeObjectCore, getRawDoc } from "@dxos/echo-schema";
|
|
4956
4893
|
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4957
4894
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4958
4895
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
4959
|
-
import { log as
|
|
4896
|
+
import { log as log15 } from "@dxos/log";
|
|
4960
4897
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4961
|
-
import {
|
|
4962
|
-
import { createSimplePeerTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
4898
|
+
import { NetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
4963
4899
|
import { trace as trace9 } from "@dxos/protocols";
|
|
4964
4900
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
4965
|
-
import { TextModel } from "@dxos/text-model";
|
|
4966
4901
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace3 } from "@dxos/tracing";
|
|
4967
4902
|
import { assignDeep } from "@dxos/util";
|
|
4968
4903
|
import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
@@ -5050,15 +4985,15 @@ var DevicesServiceImpl = class {
|
|
|
5050
4985
|
};
|
|
5051
4986
|
|
|
5052
4987
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5053
|
-
import { Event as
|
|
4988
|
+
import { Event as Event8 } from "@dxos/async";
|
|
5054
4989
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5055
4990
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
5056
|
-
import { getContextFromEntry, log as
|
|
4991
|
+
import { getContextFromEntry, log as log14 } from "@dxos/log";
|
|
5057
4992
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5058
4993
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
5059
4994
|
var LoggingServiceImpl = class {
|
|
5060
4995
|
constructor() {
|
|
5061
|
-
this._logs = new
|
|
4996
|
+
this._logs = new Event8();
|
|
5062
4997
|
this._started = Date.now();
|
|
5063
4998
|
this._sessionId = PublicKey11.random().toHex();
|
|
5064
4999
|
this._logProcessor = (_config, entry2) => {
|
|
@@ -5066,11 +5001,11 @@ var LoggingServiceImpl = class {
|
|
|
5066
5001
|
};
|
|
5067
5002
|
}
|
|
5068
5003
|
async open() {
|
|
5069
|
-
|
|
5004
|
+
log14.runtimeConfig.processors.push(this._logProcessor);
|
|
5070
5005
|
}
|
|
5071
5006
|
async close() {
|
|
5072
|
-
const index =
|
|
5073
|
-
|
|
5007
|
+
const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5008
|
+
log14.runtimeConfig.processors.splice(index, 1);
|
|
5074
5009
|
}
|
|
5075
5010
|
async controlMetrics({ reset, record }) {
|
|
5076
5011
|
if (reset) {
|
|
@@ -5275,13 +5210,9 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5275
5210
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5276
5211
|
}
|
|
5277
5212
|
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5278
|
-
var createDefaultModelFactory = () => {
|
|
5279
|
-
return new ModelFactory().registerModel(DocumentModel2).registerModel(TextModel);
|
|
5280
|
-
};
|
|
5281
5213
|
var ClientServicesHost = class {
|
|
5282
5214
|
constructor({
|
|
5283
5215
|
config,
|
|
5284
|
-
modelFactory = createDefaultModelFactory(),
|
|
5285
5216
|
transportFactory,
|
|
5286
5217
|
signalManager,
|
|
5287
5218
|
storage,
|
|
@@ -5291,11 +5222,10 @@ var ClientServicesHost = class {
|
|
|
5291
5222
|
runtimeParams
|
|
5292
5223
|
} = {}) {
|
|
5293
5224
|
this._tracingService = TRACE_PROCESSOR2.createTraceSender();
|
|
5294
|
-
this._statusUpdate = new
|
|
5225
|
+
this._statusUpdate = new Event9();
|
|
5295
5226
|
this._opening = false;
|
|
5296
5227
|
this._open = false;
|
|
5297
5228
|
this._storage = storage;
|
|
5298
|
-
this._modelFactory = modelFactory;
|
|
5299
5229
|
this._callbacks = callbacks;
|
|
5300
5230
|
this._runtimeParams = runtimeParams;
|
|
5301
5231
|
if (config) {
|
|
@@ -5366,23 +5296,23 @@ var ClientServicesHost = class {
|
|
|
5366
5296
|
initialize({ config, ...options }) {
|
|
5367
5297
|
invariant16(!this._open, "service host is open", {
|
|
5368
5298
|
F: __dxlog_file18,
|
|
5369
|
-
L:
|
|
5299
|
+
L: 179,
|
|
5370
5300
|
S: this,
|
|
5371
5301
|
A: [
|
|
5372
5302
|
"!this._open",
|
|
5373
5303
|
"'service host is open'"
|
|
5374
5304
|
]
|
|
5375
5305
|
});
|
|
5376
|
-
|
|
5306
|
+
log15("initializing...", void 0, {
|
|
5377
5307
|
F: __dxlog_file18,
|
|
5378
|
-
L:
|
|
5308
|
+
L: 180,
|
|
5379
5309
|
S: this,
|
|
5380
5310
|
C: (f, a) => f(...a)
|
|
5381
5311
|
});
|
|
5382
5312
|
if (config) {
|
|
5383
5313
|
invariant16(!this._config, "config already set", {
|
|
5384
5314
|
F: __dxlog_file18,
|
|
5385
|
-
L:
|
|
5315
|
+
L: 183,
|
|
5386
5316
|
S: this,
|
|
5387
5317
|
A: [
|
|
5388
5318
|
"!this._config",
|
|
@@ -5400,7 +5330,7 @@ var ClientServicesHost = class {
|
|
|
5400
5330
|
this._signalManager = signalManager;
|
|
5401
5331
|
invariant16(!this._networkManager, "network manager already set", {
|
|
5402
5332
|
F: __dxlog_file18,
|
|
5403
|
-
L:
|
|
5333
|
+
L: 199,
|
|
5404
5334
|
S: this,
|
|
5405
5335
|
A: [
|
|
5406
5336
|
"!this._networkManager",
|
|
@@ -5412,9 +5342,9 @@ var ClientServicesHost = class {
|
|
|
5412
5342
|
transportFactory,
|
|
5413
5343
|
signalManager
|
|
5414
5344
|
});
|
|
5415
|
-
|
|
5345
|
+
log15("initialized", void 0, {
|
|
5416
5346
|
F: __dxlog_file18,
|
|
5417
|
-
L:
|
|
5347
|
+
L: 206,
|
|
5418
5348
|
S: this,
|
|
5419
5349
|
C: (f, a) => f(...a)
|
|
5420
5350
|
});
|
|
@@ -5424,17 +5354,17 @@ var ClientServicesHost = class {
|
|
|
5424
5354
|
return;
|
|
5425
5355
|
}
|
|
5426
5356
|
const traceId = PublicKey12.random().toHex();
|
|
5427
|
-
|
|
5357
|
+
log15.trace("dxos.client-services.host.open", trace9.begin({
|
|
5428
5358
|
id: traceId
|
|
5429
5359
|
}), {
|
|
5430
5360
|
F: __dxlog_file18,
|
|
5431
|
-
L:
|
|
5361
|
+
L: 217,
|
|
5432
5362
|
S: this,
|
|
5433
5363
|
C: (f, a) => f(...a)
|
|
5434
5364
|
});
|
|
5435
5365
|
invariant16(this._config, "config not set", {
|
|
5436
5366
|
F: __dxlog_file18,
|
|
5437
|
-
L:
|
|
5367
|
+
L: 219,
|
|
5438
5368
|
S: this,
|
|
5439
5369
|
A: [
|
|
5440
5370
|
"this._config",
|
|
@@ -5443,7 +5373,7 @@ var ClientServicesHost = class {
|
|
|
5443
5373
|
});
|
|
5444
5374
|
invariant16(this._storage, "storage not set", {
|
|
5445
5375
|
F: __dxlog_file18,
|
|
5446
|
-
L:
|
|
5376
|
+
L: 220,
|
|
5447
5377
|
S: this,
|
|
5448
5378
|
A: [
|
|
5449
5379
|
"this._storage",
|
|
@@ -5452,7 +5382,7 @@ var ClientServicesHost = class {
|
|
|
5452
5382
|
});
|
|
5453
5383
|
invariant16(this._signalManager, "signal manager not set", {
|
|
5454
5384
|
F: __dxlog_file18,
|
|
5455
|
-
L:
|
|
5385
|
+
L: 221,
|
|
5456
5386
|
S: this,
|
|
5457
5387
|
A: [
|
|
5458
5388
|
"this._signalManager",
|
|
@@ -5461,7 +5391,7 @@ var ClientServicesHost = class {
|
|
|
5461
5391
|
});
|
|
5462
5392
|
invariant16(this._networkManager, "network manager not set", {
|
|
5463
5393
|
F: __dxlog_file18,
|
|
5464
|
-
L:
|
|
5394
|
+
L: 222,
|
|
5465
5395
|
S: this,
|
|
5466
5396
|
A: [
|
|
5467
5397
|
"this._networkManager",
|
|
@@ -5469,27 +5399,27 @@ var ClientServicesHost = class {
|
|
|
5469
5399
|
]
|
|
5470
5400
|
});
|
|
5471
5401
|
this._opening = true;
|
|
5472
|
-
|
|
5402
|
+
log15("opening...", {
|
|
5473
5403
|
lockKey: this._resourceLock?.lockKey
|
|
5474
5404
|
}, {
|
|
5475
5405
|
F: __dxlog_file18,
|
|
5476
|
-
L:
|
|
5406
|
+
L: 225,
|
|
5477
5407
|
S: this,
|
|
5478
5408
|
C: (f, a) => f(...a)
|
|
5479
5409
|
});
|
|
5480
5410
|
await this._resourceLock?.acquire();
|
|
5481
5411
|
await this._loggingService.open();
|
|
5482
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this.
|
|
5412
|
+
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5483
5413
|
this._serviceRegistry.setServices({
|
|
5484
5414
|
SystemService: this._systemService,
|
|
5485
5415
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5486
5416
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
|
|
5487
5417
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5488
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager,
|
|
5418
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5489
5419
|
await this._serviceContext.initialized.wait();
|
|
5490
5420
|
return this._serviceContext.dataSpaceManager;
|
|
5491
5421
|
}),
|
|
5492
|
-
DataService: new DataServiceImpl(this._serviceContext.
|
|
5422
|
+
DataService: new DataServiceImpl(this._serviceContext.automergeHost),
|
|
5493
5423
|
IndexService: new IndexServiceImpl({
|
|
5494
5424
|
indexer: this._serviceContext.indexer,
|
|
5495
5425
|
automergeHost: this._serviceContext.automergeHost
|
|
@@ -5507,7 +5437,7 @@ var ClientServicesHost = class {
|
|
|
5507
5437
|
await this._serviceContext.open(ctx);
|
|
5508
5438
|
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5509
5439
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5440
|
+
L: 286,
|
|
5511
5441
|
S: this,
|
|
5512
5442
|
A: [
|
|
5513
5443
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5515,11 +5445,11 @@ var ClientServicesHost = class {
|
|
|
5515
5445
|
]
|
|
5516
5446
|
});
|
|
5517
5447
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5518
|
-
|
|
5448
|
+
log15("loaded persistent invitations", {
|
|
5519
5449
|
count: loadedInvitations.invitations?.length
|
|
5520
5450
|
}, {
|
|
5521
5451
|
F: __dxlog_file18,
|
|
5522
|
-
L:
|
|
5452
|
+
L: 289,
|
|
5523
5453
|
S: this,
|
|
5524
5454
|
C: (f, a) => f(...a)
|
|
5525
5455
|
});
|
|
@@ -5537,19 +5467,19 @@ var ClientServicesHost = class {
|
|
|
5537
5467
|
this._open = true;
|
|
5538
5468
|
this._statusUpdate.emit();
|
|
5539
5469
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5540
|
-
|
|
5470
|
+
log15("opened", {
|
|
5541
5471
|
deviceKey
|
|
5542
5472
|
}, {
|
|
5543
5473
|
F: __dxlog_file18,
|
|
5544
|
-
L:
|
|
5474
|
+
L: 306,
|
|
5545
5475
|
S: this,
|
|
5546
5476
|
C: (f, a) => f(...a)
|
|
5547
5477
|
});
|
|
5548
|
-
|
|
5478
|
+
log15.trace("dxos.client-services.host.open", trace9.end({
|
|
5549
5479
|
id: traceId
|
|
5550
5480
|
}), {
|
|
5551
5481
|
F: __dxlog_file18,
|
|
5552
|
-
L:
|
|
5482
|
+
L: 307,
|
|
5553
5483
|
S: this,
|
|
5554
5484
|
C: (f, a) => f(...a)
|
|
5555
5485
|
});
|
|
@@ -5559,11 +5489,11 @@ var ClientServicesHost = class {
|
|
|
5559
5489
|
return;
|
|
5560
5490
|
}
|
|
5561
5491
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5562
|
-
|
|
5492
|
+
log15("closing...", {
|
|
5563
5493
|
deviceKey
|
|
5564
5494
|
}, {
|
|
5565
5495
|
F: __dxlog_file18,
|
|
5566
|
-
L:
|
|
5496
|
+
L: 318,
|
|
5567
5497
|
S: this,
|
|
5568
5498
|
C: (f, a) => f(...a)
|
|
5569
5499
|
});
|
|
@@ -5575,44 +5505,44 @@ var ClientServicesHost = class {
|
|
|
5575
5505
|
await this._serviceContext.close();
|
|
5576
5506
|
this._open = false;
|
|
5577
5507
|
this._statusUpdate.emit();
|
|
5578
|
-
|
|
5508
|
+
log15("closed", {
|
|
5579
5509
|
deviceKey
|
|
5580
5510
|
}, {
|
|
5581
5511
|
F: __dxlog_file18,
|
|
5582
|
-
L:
|
|
5512
|
+
L: 325,
|
|
5583
5513
|
S: this,
|
|
5584
5514
|
C: (f, a) => f(...a)
|
|
5585
5515
|
});
|
|
5586
5516
|
}
|
|
5587
5517
|
async reset() {
|
|
5588
5518
|
const traceId = PublicKey12.random().toHex();
|
|
5589
|
-
|
|
5519
|
+
log15.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5590
5520
|
id: traceId
|
|
5591
5521
|
}), {
|
|
5592
5522
|
F: __dxlog_file18,
|
|
5593
|
-
L:
|
|
5523
|
+
L: 330,
|
|
5594
5524
|
S: this,
|
|
5595
5525
|
C: (f, a) => f(...a)
|
|
5596
5526
|
});
|
|
5597
|
-
|
|
5527
|
+
log15("resetting...", void 0, {
|
|
5598
5528
|
F: __dxlog_file18,
|
|
5599
|
-
L:
|
|
5529
|
+
L: 332,
|
|
5600
5530
|
S: this,
|
|
5601
5531
|
C: (f, a) => f(...a)
|
|
5602
5532
|
});
|
|
5603
5533
|
await this._serviceContext?.close();
|
|
5604
5534
|
await this._storage.reset();
|
|
5605
|
-
|
|
5535
|
+
log15("reset", void 0, {
|
|
5606
5536
|
F: __dxlog_file18,
|
|
5607
|
-
L:
|
|
5537
|
+
L: 335,
|
|
5608
5538
|
S: this,
|
|
5609
5539
|
C: (f, a) => f(...a)
|
|
5610
5540
|
});
|
|
5611
|
-
|
|
5541
|
+
log15.trace("dxos.sdk.client-services-host.reset", trace9.end({
|
|
5612
5542
|
id: traceId
|
|
5613
5543
|
}), {
|
|
5614
5544
|
F: __dxlog_file18,
|
|
5615
|
-
L:
|
|
5545
|
+
L: 336,
|
|
5616
5546
|
S: this,
|
|
5617
5547
|
C: (f, a) => f(...a)
|
|
5618
5548
|
});
|
|
@@ -5627,7 +5557,7 @@ var ClientServicesHost = class {
|
|
|
5627
5557
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5628
5558
|
invariant16(automergeIndex, void 0, {
|
|
5629
5559
|
F: __dxlog_file18,
|
|
5630
|
-
L:
|
|
5560
|
+
L: 351,
|
|
5631
5561
|
S: this,
|
|
5632
5562
|
A: [
|
|
5633
5563
|
"automergeIndex",
|
|
@@ -5695,7 +5625,6 @@ export {
|
|
|
5695
5625
|
Lock,
|
|
5696
5626
|
isLocked,
|
|
5697
5627
|
createStorageObjects,
|
|
5698
|
-
createDefaultModelFactory,
|
|
5699
5628
|
ClientServicesHost
|
|
5700
5629
|
};
|
|
5701
|
-
//# sourceMappingURL=chunk-
|
|
5630
|
+
//# sourceMappingURL=chunk-SUJLI7YP.mjs.map
|