@dxos/client-services 0.4.9-main.76223f7 → 0.4.9-main.7750cb2
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-IVUA3ZSF.mjs → chunk-D6LYSGMU.mjs} +193 -254
- package/dist/lib/browser/chunk-D6LYSGMU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +4 -10
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-XLFW2D2Q.cjs → chunk-FSN25IYL.cjs} +212 -273
- package/dist/lib/node/chunk-FSN25IYL.cjs.map +7 -0
- package/dist/lib/node/index.cjs +38 -38
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +10 -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.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- 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 +37 -37
- 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 +2 -41
- package/src/packlets/services/service-context.test.ts +3 -76
- package/src/packlets/services/service-context.ts +5 -15
- package/src/packlets/services/service-host.ts +1 -5
- 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 +2 -22
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-IVUA3ZSF.mjs.map +0 -7
- package/dist/lib/node/chunk-XLFW2D2Q.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.7750cb2";
|
|
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, {
|
|
3432
|
-
F: __dxlog_file12,
|
|
3433
|
-
L: 288,
|
|
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, {
|
|
3396
|
+
await cancelWithContext2(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3397
|
+
log9("data pipeline ready", void 0, {
|
|
3443
3398
|
F: __dxlog_file12,
|
|
3444
|
-
L:
|
|
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
|
}
|
|
@@ -4498,7 +4439,6 @@ var ServiceContext = class {
|
|
|
4498
4439
|
this.modelFactory = modelFactory;
|
|
4499
4440
|
this._runtimeParams = _runtimeParams;
|
|
4500
4441
|
this.initialized = new Trigger5();
|
|
4501
|
-
this.dataServiceSubscriptions = new DataServiceSubscriptions();
|
|
4502
4442
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4503
4443
|
this._instanceId = PublicKey10.random().toHex();
|
|
4504
4444
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -4544,17 +4484,17 @@ var ServiceContext = class {
|
|
|
4544
4484
|
}
|
|
4545
4485
|
async open(ctx) {
|
|
4546
4486
|
await this._checkStorageVersion();
|
|
4547
|
-
|
|
4487
|
+
log12("opening...", void 0, {
|
|
4548
4488
|
F: __dxlog_file15,
|
|
4549
|
-
L:
|
|
4489
|
+
L: 154,
|
|
4550
4490
|
S: this,
|
|
4551
4491
|
C: (f, a) => f(...a)
|
|
4552
4492
|
});
|
|
4553
|
-
|
|
4493
|
+
log12.trace("dxos.sdk.service-context.open", trace8.begin({
|
|
4554
4494
|
id: this._instanceId
|
|
4555
4495
|
}), {
|
|
4556
4496
|
F: __dxlog_file15,
|
|
4557
|
-
L:
|
|
4497
|
+
L: 155,
|
|
4558
4498
|
S: this,
|
|
4559
4499
|
C: (f, a) => f(...a)
|
|
4560
4500
|
});
|
|
@@ -4566,25 +4506,25 @@ var ServiceContext = class {
|
|
|
4566
4506
|
if (this.identityManager.identity) {
|
|
4567
4507
|
await this._initialize(ctx);
|
|
4568
4508
|
}
|
|
4569
|
-
|
|
4509
|
+
log12.trace("dxos.sdk.service-context.open", trace8.end({
|
|
4570
4510
|
id: this._instanceId
|
|
4571
4511
|
}), {
|
|
4572
4512
|
F: __dxlog_file15,
|
|
4573
|
-
L:
|
|
4513
|
+
L: 165,
|
|
4574
4514
|
S: this,
|
|
4575
4515
|
C: (f, a) => f(...a)
|
|
4576
4516
|
});
|
|
4577
|
-
|
|
4517
|
+
log12("opened", void 0, {
|
|
4578
4518
|
F: __dxlog_file15,
|
|
4579
|
-
L:
|
|
4519
|
+
L: 166,
|
|
4580
4520
|
S: this,
|
|
4581
4521
|
C: (f, a) => f(...a)
|
|
4582
4522
|
});
|
|
4583
4523
|
}
|
|
4584
4524
|
async close() {
|
|
4585
|
-
|
|
4525
|
+
log12("closing...", void 0, {
|
|
4586
4526
|
F: __dxlog_file15,
|
|
4587
|
-
L:
|
|
4527
|
+
L: 170,
|
|
4588
4528
|
S: this,
|
|
4589
4529
|
C: (f, a) => f(...a)
|
|
4590
4530
|
});
|
|
@@ -4598,12 +4538,11 @@ var ServiceContext = class {
|
|
|
4598
4538
|
await this.feedStore.close();
|
|
4599
4539
|
await this.networkManager.close();
|
|
4600
4540
|
await this.signalManager.close();
|
|
4601
|
-
this.dataServiceSubscriptions.clear();
|
|
4602
4541
|
await this.metadataStore.close();
|
|
4603
4542
|
await this.indexer.destroy();
|
|
4604
|
-
|
|
4543
|
+
log12("closed", void 0, {
|
|
4605
4544
|
F: __dxlog_file15,
|
|
4606
|
-
L:
|
|
4545
|
+
L: 183,
|
|
4607
4546
|
S: this,
|
|
4608
4547
|
C: (f, a) => f(...a)
|
|
4609
4548
|
});
|
|
@@ -4617,7 +4556,7 @@ var ServiceContext = class {
|
|
|
4617
4556
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4618
4557
|
invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4619
4558
|
F: __dxlog_file15,
|
|
4620
|
-
L:
|
|
4559
|
+
L: 194,
|
|
4621
4560
|
S: this,
|
|
4622
4561
|
A: [
|
|
4623
4562
|
"factory",
|
|
@@ -4647,9 +4586,9 @@ var ServiceContext = class {
|
|
|
4647
4586
|
}
|
|
4648
4587
|
// Called when identity is created.
|
|
4649
4588
|
async _initialize(ctx) {
|
|
4650
|
-
|
|
4589
|
+
log12("initializing spaces...", void 0, {
|
|
4651
4590
|
F: __dxlog_file15,
|
|
4652
|
-
L:
|
|
4591
|
+
L: 225,
|
|
4653
4592
|
S: this,
|
|
4654
4593
|
C: (f, a) => f(...a)
|
|
4655
4594
|
});
|
|
@@ -4667,12 +4606,12 @@ var ServiceContext = class {
|
|
|
4667
4606
|
});
|
|
4668
4607
|
}
|
|
4669
4608
|
};
|
|
4670
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.
|
|
4609
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4671
4610
|
await this.dataSpaceManager.open();
|
|
4672
4611
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4673
4612
|
invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4674
4613
|
F: __dxlog_file15,
|
|
4675
|
-
L:
|
|
4614
|
+
L: 249,
|
|
4676
4615
|
S: this,
|
|
4677
4616
|
A: [
|
|
4678
4617
|
"this.dataSpaceManager",
|
|
@@ -4692,33 +4631,33 @@ var ServiceContext = class {
|
|
|
4692
4631
|
return;
|
|
4693
4632
|
}
|
|
4694
4633
|
if (!this.dataSpaceManager) {
|
|
4695
|
-
|
|
4634
|
+
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4696
4635
|
details: assertion
|
|
4697
4636
|
}, {
|
|
4698
4637
|
F: __dxlog_file15,
|
|
4699
|
-
L:
|
|
4638
|
+
L: 265,
|
|
4700
4639
|
S: this,
|
|
4701
4640
|
C: (f, a) => f(...a)
|
|
4702
4641
|
});
|
|
4703
4642
|
return;
|
|
4704
4643
|
}
|
|
4705
4644
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
4706
|
-
|
|
4645
|
+
log12("space already exists, ignoring space admission", {
|
|
4707
4646
|
details: assertion
|
|
4708
4647
|
}, {
|
|
4709
4648
|
F: __dxlog_file15,
|
|
4710
|
-
L:
|
|
4649
|
+
L: 269,
|
|
4711
4650
|
S: this,
|
|
4712
4651
|
C: (f, a) => f(...a)
|
|
4713
4652
|
});
|
|
4714
4653
|
return;
|
|
4715
4654
|
}
|
|
4716
4655
|
try {
|
|
4717
|
-
|
|
4656
|
+
log12("accepting space recorded in halo", {
|
|
4718
4657
|
details: assertion
|
|
4719
4658
|
}, {
|
|
4720
4659
|
F: __dxlog_file15,
|
|
4721
|
-
L:
|
|
4660
|
+
L: 274,
|
|
4722
4661
|
S: this,
|
|
4723
4662
|
C: (f, a) => f(...a)
|
|
4724
4663
|
});
|
|
@@ -4727,9 +4666,9 @@ var ServiceContext = class {
|
|
|
4727
4666
|
genesisFeedKey: assertion.genesisFeedKey
|
|
4728
4667
|
});
|
|
4729
4668
|
} catch (err) {
|
|
4730
|
-
|
|
4669
|
+
log12.catch(err, void 0, {
|
|
4731
4670
|
F: __dxlog_file15,
|
|
4732
|
-
L:
|
|
4671
|
+
L: 280,
|
|
4733
4672
|
S: this,
|
|
4734
4673
|
C: (f, a) => f(...a)
|
|
4735
4674
|
});
|
|
@@ -4777,7 +4716,7 @@ var ServiceRegistry = class {
|
|
|
4777
4716
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4778
4717
|
import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
|
|
4779
4718
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4780
|
-
import { log as
|
|
4719
|
+
import { log as log13, logInfo } from "@dxos/log";
|
|
4781
4720
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
4782
4721
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4783
4722
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4810,28 +4749,28 @@ var Lock = class {
|
|
|
4810
4749
|
message: "acquiring"
|
|
4811
4750
|
});
|
|
4812
4751
|
try {
|
|
4813
|
-
|
|
4752
|
+
log13("aquiring lock...", void 0, {
|
|
4814
4753
|
F: __dxlog_file16,
|
|
4815
4754
|
L: 42,
|
|
4816
4755
|
S: this,
|
|
4817
4756
|
C: (f, a) => f(...a)
|
|
4818
4757
|
});
|
|
4819
4758
|
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4820
|
-
|
|
4759
|
+
log13("acquired lock", void 0, {
|
|
4821
4760
|
F: __dxlog_file16,
|
|
4822
4761
|
L: 44,
|
|
4823
4762
|
S: this,
|
|
4824
4763
|
C: (f, a) => f(...a)
|
|
4825
4764
|
});
|
|
4826
4765
|
} catch {
|
|
4827
|
-
|
|
4766
|
+
log13("stealing lock...", void 0, {
|
|
4828
4767
|
F: __dxlog_file16,
|
|
4829
4768
|
L: 46,
|
|
4830
4769
|
S: this,
|
|
4831
4770
|
C: (f, a) => f(...a)
|
|
4832
4771
|
});
|
|
4833
4772
|
await this._requestLock(true);
|
|
4834
|
-
|
|
4773
|
+
log13("stolen lock", void 0, {
|
|
4835
4774
|
F: __dxlog_file16,
|
|
4836
4775
|
L: 48,
|
|
4837
4776
|
S: this,
|
|
@@ -4848,7 +4787,7 @@ var Lock = class {
|
|
|
4848
4787
|
}
|
|
4849
4788
|
}
|
|
4850
4789
|
async _requestLock(steal = false) {
|
|
4851
|
-
|
|
4790
|
+
log13("requesting lock...", {
|
|
4852
4791
|
steal
|
|
4853
4792
|
}, {
|
|
4854
4793
|
F: __dxlog_file16,
|
|
@@ -4864,14 +4803,14 @@ var Lock = class {
|
|
|
4864
4803
|
acquired.wake();
|
|
4865
4804
|
this._releaseTrigger = new Trigger6();
|
|
4866
4805
|
await this._releaseTrigger.wait();
|
|
4867
|
-
|
|
4806
|
+
log13("releasing lock...", void 0, {
|
|
4868
4807
|
F: __dxlog_file16,
|
|
4869
4808
|
L: 72,
|
|
4870
4809
|
S: this,
|
|
4871
4810
|
C: (f, a) => f(...a)
|
|
4872
4811
|
});
|
|
4873
4812
|
await this._onRelease?.();
|
|
4874
|
-
|
|
4813
|
+
log13("released lock", void 0, {
|
|
4875
4814
|
F: __dxlog_file16,
|
|
4876
4815
|
L: 74,
|
|
4877
4816
|
S: this,
|
|
@@ -4881,7 +4820,7 @@ var Lock = class {
|
|
|
4881
4820
|
await this._onRelease?.();
|
|
4882
4821
|
});
|
|
4883
4822
|
await acquired.wait();
|
|
4884
|
-
|
|
4823
|
+
log13("recieved lock", {
|
|
4885
4824
|
steal
|
|
4886
4825
|
}, {
|
|
4887
4826
|
F: __dxlog_file16,
|
|
@@ -4948,16 +4887,16 @@ var toStorageType = (type) => {
|
|
|
4948
4887
|
};
|
|
4949
4888
|
|
|
4950
4889
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4951
|
-
import { Event as
|
|
4890
|
+
import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
|
|
4952
4891
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4953
4892
|
import { Context as Context11 } from "@dxos/context";
|
|
4954
|
-
import { DocumentModel
|
|
4893
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
4955
4894
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4956
4895
|
import { getRawDoc, getAutomergeObjectCore } from "@dxos/echo-schema";
|
|
4957
4896
|
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4958
4897
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4959
4898
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
4960
|
-
import { log as
|
|
4899
|
+
import { log as log15 } from "@dxos/log";
|
|
4961
4900
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4962
4901
|
import { ModelFactory } from "@dxos/model-factory";
|
|
4963
4902
|
import { createSimplePeerTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
@@ -5051,15 +4990,15 @@ var DevicesServiceImpl = class {
|
|
|
5051
4990
|
};
|
|
5052
4991
|
|
|
5053
4992
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
5054
|
-
import { Event as
|
|
4993
|
+
import { Event as Event8 } from "@dxos/async";
|
|
5055
4994
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
5056
4995
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
5057
|
-
import { getContextFromEntry, log as
|
|
4996
|
+
import { getContextFromEntry, log as log14 } from "@dxos/log";
|
|
5058
4997
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
5059
4998
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
5060
4999
|
var LoggingServiceImpl = class {
|
|
5061
5000
|
constructor() {
|
|
5062
|
-
this._logs = new
|
|
5001
|
+
this._logs = new Event8();
|
|
5063
5002
|
this._started = Date.now();
|
|
5064
5003
|
this._sessionId = PublicKey11.random().toHex();
|
|
5065
5004
|
this._logProcessor = (_config, entry2) => {
|
|
@@ -5067,11 +5006,11 @@ var LoggingServiceImpl = class {
|
|
|
5067
5006
|
};
|
|
5068
5007
|
}
|
|
5069
5008
|
async open() {
|
|
5070
|
-
|
|
5009
|
+
log14.runtimeConfig.processors.push(this._logProcessor);
|
|
5071
5010
|
}
|
|
5072
5011
|
async close() {
|
|
5073
|
-
const index =
|
|
5074
|
-
|
|
5012
|
+
const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5013
|
+
log14.runtimeConfig.processors.splice(index, 1);
|
|
5075
5014
|
}
|
|
5076
5015
|
async controlMetrics({ reset, record }) {
|
|
5077
5016
|
if (reset) {
|
|
@@ -5277,7 +5216,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5277
5216
|
}
|
|
5278
5217
|
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5279
5218
|
var createDefaultModelFactory = () => {
|
|
5280
|
-
return new ModelFactory().registerModel(
|
|
5219
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
5281
5220
|
};
|
|
5282
5221
|
var ClientServicesHost = class {
|
|
5283
5222
|
constructor({
|
|
@@ -5292,7 +5231,7 @@ var ClientServicesHost = class {
|
|
|
5292
5231
|
runtimeParams
|
|
5293
5232
|
} = {}) {
|
|
5294
5233
|
this._tracingService = TRACE_PROCESSOR2.createTraceSender();
|
|
5295
|
-
this._statusUpdate = new
|
|
5234
|
+
this._statusUpdate = new Event9();
|
|
5296
5235
|
this._opening = false;
|
|
5297
5236
|
this._open = false;
|
|
5298
5237
|
this._storage = storage;
|
|
@@ -5374,7 +5313,7 @@ var ClientServicesHost = class {
|
|
|
5374
5313
|
"'service host is open'"
|
|
5375
5314
|
]
|
|
5376
5315
|
});
|
|
5377
|
-
|
|
5316
|
+
log15("initializing...", void 0, {
|
|
5378
5317
|
F: __dxlog_file18,
|
|
5379
5318
|
L: 192,
|
|
5380
5319
|
S: this,
|
|
@@ -5413,7 +5352,7 @@ var ClientServicesHost = class {
|
|
|
5413
5352
|
transportFactory,
|
|
5414
5353
|
signalManager
|
|
5415
5354
|
});
|
|
5416
|
-
|
|
5355
|
+
log15("initialized", void 0, {
|
|
5417
5356
|
F: __dxlog_file18,
|
|
5418
5357
|
L: 218,
|
|
5419
5358
|
S: this,
|
|
@@ -5425,7 +5364,7 @@ var ClientServicesHost = class {
|
|
|
5425
5364
|
return;
|
|
5426
5365
|
}
|
|
5427
5366
|
const traceId = PublicKey12.random().toHex();
|
|
5428
|
-
|
|
5367
|
+
log15.trace("dxos.client-services.host.open", trace9.begin({
|
|
5429
5368
|
id: traceId
|
|
5430
5369
|
}), {
|
|
5431
5370
|
F: __dxlog_file18,
|
|
@@ -5470,7 +5409,7 @@ var ClientServicesHost = class {
|
|
|
5470
5409
|
]
|
|
5471
5410
|
});
|
|
5472
5411
|
this._opening = true;
|
|
5473
|
-
|
|
5412
|
+
log15("opening...", {
|
|
5474
5413
|
lockKey: this._resourceLock?.lockKey
|
|
5475
5414
|
}, {
|
|
5476
5415
|
F: __dxlog_file18,
|
|
@@ -5486,11 +5425,11 @@ var ClientServicesHost = class {
|
|
|
5486
5425
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5487
5426
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
|
|
5488
5427
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5489
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager,
|
|
5428
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5490
5429
|
await this._serviceContext.initialized.wait();
|
|
5491
5430
|
return this._serviceContext.dataSpaceManager;
|
|
5492
5431
|
}),
|
|
5493
|
-
DataService: new DataServiceImpl(this._serviceContext.
|
|
5432
|
+
DataService: new DataServiceImpl(this._serviceContext.automergeHost),
|
|
5494
5433
|
IndexService: new IndexServiceImpl({
|
|
5495
5434
|
indexer: this._serviceContext.indexer,
|
|
5496
5435
|
automergeHost: this._serviceContext.automergeHost
|
|
@@ -5508,7 +5447,7 @@ var ClientServicesHost = class {
|
|
|
5508
5447
|
await this._serviceContext.open(ctx);
|
|
5509
5448
|
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5510
5449
|
F: __dxlog_file18,
|
|
5511
|
-
L:
|
|
5450
|
+
L: 299,
|
|
5512
5451
|
S: this,
|
|
5513
5452
|
A: [
|
|
5514
5453
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5516,11 +5455,11 @@ var ClientServicesHost = class {
|
|
|
5516
5455
|
]
|
|
5517
5456
|
});
|
|
5518
5457
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5519
|
-
|
|
5458
|
+
log15("loaded persistent invitations", {
|
|
5520
5459
|
count: loadedInvitations.invitations?.length
|
|
5521
5460
|
}, {
|
|
5522
5461
|
F: __dxlog_file18,
|
|
5523
|
-
L:
|
|
5462
|
+
L: 302,
|
|
5524
5463
|
S: this,
|
|
5525
5464
|
C: (f, a) => f(...a)
|
|
5526
5465
|
});
|
|
@@ -5538,19 +5477,19 @@ var ClientServicesHost = class {
|
|
|
5538
5477
|
this._open = true;
|
|
5539
5478
|
this._statusUpdate.emit();
|
|
5540
5479
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5541
|
-
|
|
5480
|
+
log15("opened", {
|
|
5542
5481
|
deviceKey
|
|
5543
5482
|
}, {
|
|
5544
5483
|
F: __dxlog_file18,
|
|
5545
|
-
L:
|
|
5484
|
+
L: 319,
|
|
5546
5485
|
S: this,
|
|
5547
5486
|
C: (f, a) => f(...a)
|
|
5548
5487
|
});
|
|
5549
|
-
|
|
5488
|
+
log15.trace("dxos.client-services.host.open", trace9.end({
|
|
5550
5489
|
id: traceId
|
|
5551
5490
|
}), {
|
|
5552
5491
|
F: __dxlog_file18,
|
|
5553
|
-
L:
|
|
5492
|
+
L: 320,
|
|
5554
5493
|
S: this,
|
|
5555
5494
|
C: (f, a) => f(...a)
|
|
5556
5495
|
});
|
|
@@ -5560,11 +5499,11 @@ var ClientServicesHost = class {
|
|
|
5560
5499
|
return;
|
|
5561
5500
|
}
|
|
5562
5501
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5563
|
-
|
|
5502
|
+
log15("closing...", {
|
|
5564
5503
|
deviceKey
|
|
5565
5504
|
}, {
|
|
5566
5505
|
F: __dxlog_file18,
|
|
5567
|
-
L:
|
|
5506
|
+
L: 331,
|
|
5568
5507
|
S: this,
|
|
5569
5508
|
C: (f, a) => f(...a)
|
|
5570
5509
|
});
|
|
@@ -5576,44 +5515,44 @@ var ClientServicesHost = class {
|
|
|
5576
5515
|
await this._serviceContext.close();
|
|
5577
5516
|
this._open = false;
|
|
5578
5517
|
this._statusUpdate.emit();
|
|
5579
|
-
|
|
5518
|
+
log15("closed", {
|
|
5580
5519
|
deviceKey
|
|
5581
5520
|
}, {
|
|
5582
5521
|
F: __dxlog_file18,
|
|
5583
|
-
L:
|
|
5522
|
+
L: 338,
|
|
5584
5523
|
S: this,
|
|
5585
5524
|
C: (f, a) => f(...a)
|
|
5586
5525
|
});
|
|
5587
5526
|
}
|
|
5588
5527
|
async reset() {
|
|
5589
5528
|
const traceId = PublicKey12.random().toHex();
|
|
5590
|
-
|
|
5529
|
+
log15.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5591
5530
|
id: traceId
|
|
5592
5531
|
}), {
|
|
5593
5532
|
F: __dxlog_file18,
|
|
5594
|
-
L:
|
|
5533
|
+
L: 343,
|
|
5595
5534
|
S: this,
|
|
5596
5535
|
C: (f, a) => f(...a)
|
|
5597
5536
|
});
|
|
5598
|
-
|
|
5537
|
+
log15("resetting...", void 0, {
|
|
5599
5538
|
F: __dxlog_file18,
|
|
5600
|
-
L:
|
|
5539
|
+
L: 345,
|
|
5601
5540
|
S: this,
|
|
5602
5541
|
C: (f, a) => f(...a)
|
|
5603
5542
|
});
|
|
5604
5543
|
await this._serviceContext?.close();
|
|
5605
5544
|
await this._storage.reset();
|
|
5606
|
-
|
|
5545
|
+
log15("reset", void 0, {
|
|
5607
5546
|
F: __dxlog_file18,
|
|
5608
|
-
L:
|
|
5547
|
+
L: 348,
|
|
5609
5548
|
S: this,
|
|
5610
5549
|
C: (f, a) => f(...a)
|
|
5611
5550
|
});
|
|
5612
|
-
|
|
5551
|
+
log15.trace("dxos.sdk.client-services-host.reset", trace9.end({
|
|
5613
5552
|
id: traceId
|
|
5614
5553
|
}), {
|
|
5615
5554
|
F: __dxlog_file18,
|
|
5616
|
-
L:
|
|
5555
|
+
L: 349,
|
|
5617
5556
|
S: this,
|
|
5618
5557
|
C: (f, a) => f(...a)
|
|
5619
5558
|
});
|
|
@@ -5628,7 +5567,7 @@ var ClientServicesHost = class {
|
|
|
5628
5567
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5629
5568
|
invariant16(automergeIndex, void 0, {
|
|
5630
5569
|
F: __dxlog_file18,
|
|
5631
|
-
L:
|
|
5570
|
+
L: 364,
|
|
5632
5571
|
S: this,
|
|
5633
5572
|
A: [
|
|
5634
5573
|
"automergeIndex",
|
|
@@ -5699,4 +5638,4 @@ export {
|
|
|
5699
5638
|
createDefaultModelFactory,
|
|
5700
5639
|
ClientServicesHost
|
|
5701
5640
|
};
|
|
5702
|
-
//# sourceMappingURL=chunk-
|
|
5641
|
+
//# sourceMappingURL=chunk-D6LYSGMU.mjs.map
|