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