@dxos/client-services 0.5.9-main.4ed8273 → 0.5.9-main.59deb28
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-YJ5SPRLY.mjs → chunk-GCU4DHSQ.mjs} +586 -455
- package/dist/lib/browser/chunk-GCU4DHSQ.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 +2 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-RQHBQWKH.cjs → chunk-MHRJ6WZU.cjs} +692 -564
- package/dist/lib/node/chunk-MHRJ6WZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -43
- 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 +9 -10
- package/dist/lib/node/packlets/testing/index.cjs.map +2 -2
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
- 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.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +9 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/identity-service.ts +6 -1
- package/src/packlets/services/service-context.ts +1 -4
- package/src/packlets/spaces/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.ts +35 -14
- package/src/packlets/spaces/data-space.ts +73 -145
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +4 -2
- package/src/packlets/testing/test-builder.ts +1 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-YJ5SPRLY.mjs.map +0 -7
- package/dist/lib/node/chunk-RQHBQWKH.cjs.map +0 -7
|
@@ -355,7 +355,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
355
355
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
356
356
|
|
|
357
357
|
// packages/sdk/client-services/src/version.ts
|
|
358
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
358
|
+
var DXOS_VERSION = "0.5.9-main.59deb28";
|
|
359
359
|
|
|
360
360
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
361
361
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -1624,7 +1624,11 @@ var IdentityServiceImpl = class extends Resource {
|
|
|
1624
1624
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
1625
1625
|
if (space.state === SpaceState.CLOSED) {
|
|
1626
1626
|
await space.open();
|
|
1627
|
-
|
|
1627
|
+
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === SpaceState.REQUIRES_MIGRATION);
|
|
1628
|
+
await Promise.race([
|
|
1629
|
+
space.initializeDataPipeline(),
|
|
1630
|
+
requiresMigration
|
|
1631
|
+
]);
|
|
1628
1632
|
}
|
|
1629
1633
|
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1630
1634
|
await identity.updateDefaultSpace(space.id);
|
|
@@ -3683,33 +3687,40 @@ var InvitationsManager = class {
|
|
|
3683
3687
|
};
|
|
3684
3688
|
|
|
3685
3689
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3686
|
-
import { Event as Event6,
|
|
3690
|
+
import { Event as Event6, Mutex as Mutex2, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
3687
3691
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
3688
|
-
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as
|
|
3692
|
+
import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext5 } from "@dxos/context";
|
|
3689
3693
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
3690
|
-
import {
|
|
3691
|
-
import {
|
|
3692
|
-
import { failedInvariant
|
|
3694
|
+
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
3695
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
3696
|
+
import { failedInvariant } from "@dxos/invariant";
|
|
3693
3697
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3694
|
-
import { log as
|
|
3698
|
+
import { log as log14 } from "@dxos/log";
|
|
3695
3699
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
3696
|
-
import {
|
|
3700
|
+
import { SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3697
3701
|
import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3698
3702
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
3699
3703
|
import { trace as trace6 } from "@dxos/tracing";
|
|
3700
|
-
import { ComplexSet as ComplexSet5
|
|
3704
|
+
import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
3701
3705
|
|
|
3702
3706
|
// packages/sdk/client-services/src/packlets/spaces/automerge-space-state.ts
|
|
3703
3707
|
import { Event as Event4 } from "@dxos/async";
|
|
3708
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
3704
3709
|
import { checkCredentialType } from "@dxos/credentials";
|
|
3705
|
-
var AutomergeSpaceState = class {
|
|
3710
|
+
var AutomergeSpaceState = class extends Resource2 {
|
|
3706
3711
|
constructor(_onNewRoot) {
|
|
3712
|
+
super();
|
|
3707
3713
|
this._onNewRoot = _onNewRoot;
|
|
3708
3714
|
this.rootUrl = void 0;
|
|
3709
3715
|
this.lastEpoch = void 0;
|
|
3710
3716
|
this.onNewEpoch = new Event4();
|
|
3711
3717
|
this._isProcessingRootDocs = false;
|
|
3712
3718
|
}
|
|
3719
|
+
async _open(ctx) {
|
|
3720
|
+
}
|
|
3721
|
+
async _close(ctx) {
|
|
3722
|
+
this._isProcessingRootDocs = false;
|
|
3723
|
+
}
|
|
3713
3724
|
async processCredential(credential) {
|
|
3714
3725
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
3715
3726
|
return;
|
|
@@ -3737,16 +3748,162 @@ var AutomergeSpaceState = class {
|
|
|
3737
3748
|
}
|
|
3738
3749
|
};
|
|
3739
3750
|
|
|
3751
|
+
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
3752
|
+
import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
3753
|
+
import { next as am } from "@dxos/automerge/automerge";
|
|
3754
|
+
import { cancelWithContext as cancelWithContext4 } from "@dxos/context";
|
|
3755
|
+
import { convertLegacyReferences, convertLegacySpaceRootDoc, findInlineObjectOfType, migrateDocument } from "@dxos/echo-db";
|
|
3756
|
+
import { AutomergeDocumentLoaderImpl } from "@dxos/echo-pipeline";
|
|
3757
|
+
import { TYPE_PROPERTIES } from "@dxos/echo-schema";
|
|
3758
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3759
|
+
import { log as log12 } from "@dxos/log";
|
|
3760
|
+
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3761
|
+
import { assignDeep } from "@dxos/util";
|
|
3762
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3763
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3764
|
+
switch (context.migration) {
|
|
3765
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3766
|
+
const document = context.repo.create();
|
|
3767
|
+
await context.repo.flush();
|
|
3768
|
+
return {
|
|
3769
|
+
newRoot: document.url
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3773
|
+
if (!context.currentRoot) {
|
|
3774
|
+
throw new Error("Space does not have an automerge root");
|
|
3775
|
+
}
|
|
3776
|
+
const rootHandle = context.repo.find(context.currentRoot);
|
|
3777
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3778
|
+
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3779
|
+
await context.repo.flush();
|
|
3780
|
+
return {
|
|
3781
|
+
newRoot: newRoot.url
|
|
3782
|
+
};
|
|
3783
|
+
}
|
|
3784
|
+
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3785
|
+
log12.info("Fragmenting", void 0, {
|
|
3786
|
+
F: __dxlog_file15,
|
|
3787
|
+
L: 63,
|
|
3788
|
+
S: void 0,
|
|
3789
|
+
C: (f, a) => f(...a)
|
|
3790
|
+
});
|
|
3791
|
+
const currentRootUrl = context.currentRoot;
|
|
3792
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3793
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3794
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3795
|
+
const properties = findInlineObjectOfType(rootHandle.docSync(), TYPE_PROPERTIES);
|
|
3796
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3797
|
+
invariant12(properties, "Properties not found", {
|
|
3798
|
+
F: __dxlog_file15,
|
|
3799
|
+
L: 73,
|
|
3800
|
+
S: void 0,
|
|
3801
|
+
A: [
|
|
3802
|
+
"properties",
|
|
3803
|
+
"'Properties not found'"
|
|
3804
|
+
]
|
|
3805
|
+
});
|
|
3806
|
+
const newSpaceDoc = {
|
|
3807
|
+
...rootHandle.docSync(),
|
|
3808
|
+
objects: Object.fromEntries([
|
|
3809
|
+
properties
|
|
3810
|
+
])
|
|
3811
|
+
};
|
|
3812
|
+
const newRoot = context.repo.create(newSpaceDoc);
|
|
3813
|
+
invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3814
|
+
F: __dxlog_file15,
|
|
3815
|
+
L: 78,
|
|
3816
|
+
S: void 0,
|
|
3817
|
+
A: [
|
|
3818
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3819
|
+
""
|
|
3820
|
+
]
|
|
3821
|
+
});
|
|
3822
|
+
const docLoader = new AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
|
|
3823
|
+
await docLoader.loadSpaceRootDocHandle(ctx, {
|
|
3824
|
+
rootUrl: newRoot.url
|
|
3825
|
+
});
|
|
3826
|
+
otherObjects.forEach(([key, value]) => {
|
|
3827
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3828
|
+
handle.change((doc) => {
|
|
3829
|
+
assignDeep(doc, [
|
|
3830
|
+
"objects",
|
|
3831
|
+
key
|
|
3832
|
+
], value);
|
|
3833
|
+
});
|
|
3834
|
+
});
|
|
3835
|
+
await context.repo.flush();
|
|
3836
|
+
return {
|
|
3837
|
+
newRoot: newRoot.url
|
|
3838
|
+
};
|
|
3839
|
+
}
|
|
3840
|
+
case CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3841
|
+
const currentRootUrl = context.currentRoot;
|
|
3842
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3843
|
+
await cancelWithContext4(ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
3844
|
+
invariant12(rootHandle.docSync(), "Root doc not found", {
|
|
3845
|
+
F: __dxlog_file15,
|
|
3846
|
+
L: 100,
|
|
3847
|
+
S: void 0,
|
|
3848
|
+
A: [
|
|
3849
|
+
"rootHandle.docSync()",
|
|
3850
|
+
"'Root doc not found'"
|
|
3851
|
+
]
|
|
3852
|
+
});
|
|
3853
|
+
const newRootContent = await convertLegacySpaceRootDoc(structuredClone(rootHandle.docSync()));
|
|
3854
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3855
|
+
const handle = context.repo.find(url);
|
|
3856
|
+
await cancelWithContext4(ctx, asyncTimeout2(handle.whenReady(), 1e4));
|
|
3857
|
+
invariant12(handle.docSync(), "Doc not found", {
|
|
3858
|
+
F: __dxlog_file15,
|
|
3859
|
+
L: 107,
|
|
3860
|
+
S: void 0,
|
|
3861
|
+
A: [
|
|
3862
|
+
"handle.docSync()",
|
|
3863
|
+
"'Doc not found'"
|
|
3864
|
+
]
|
|
3865
|
+
});
|
|
3866
|
+
const newDoc = await convertLegacyReferences(structuredClone(handle.docSync()));
|
|
3867
|
+
const migratedDoc = migrateDocument(handle.docSync(), newDoc);
|
|
3868
|
+
const newHandle = context.repo.import(am.save(migratedDoc));
|
|
3869
|
+
newRootContent.links[id] = newHandle.url;
|
|
3870
|
+
}
|
|
3871
|
+
const migratedRoot = migrateDocument(rootHandle.docSync(), newRootContent);
|
|
3872
|
+
const newRoot = context.repo.import(am.save(migratedRoot));
|
|
3873
|
+
await context.repo.flush();
|
|
3874
|
+
return {
|
|
3875
|
+
newRoot: newRoot.url
|
|
3876
|
+
};
|
|
3877
|
+
}
|
|
3878
|
+
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3879
|
+
invariant12(context.newAutomergeRoot, void 0, {
|
|
3880
|
+
F: __dxlog_file15,
|
|
3881
|
+
L: 124,
|
|
3882
|
+
S: void 0,
|
|
3883
|
+
A: [
|
|
3884
|
+
"context.newAutomergeRoot",
|
|
3885
|
+
""
|
|
3886
|
+
]
|
|
3887
|
+
});
|
|
3888
|
+
await context.repo.flush();
|
|
3889
|
+
return {
|
|
3890
|
+
newRoot: context.newAutomergeRoot
|
|
3891
|
+
};
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
return {};
|
|
3895
|
+
};
|
|
3896
|
+
|
|
3740
3897
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
3741
3898
|
import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError3, Trigger as Trigger6 } from "@dxos/async";
|
|
3742
3899
|
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
3743
|
-
import { invariant as
|
|
3900
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3744
3901
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3745
|
-
import { log as
|
|
3902
|
+
import { log as log13 } from "@dxos/log";
|
|
3746
3903
|
import { schema as schema4 } from "@dxos/protocols";
|
|
3747
3904
|
import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
|
|
3748
3905
|
import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
|
|
3749
|
-
var
|
|
3906
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3750
3907
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3751
3908
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3752
3909
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3771,16 +3928,16 @@ var NotarizationPlugin = class {
|
|
|
3771
3928
|
* Request credentials to be notarized.
|
|
3772
3929
|
*/
|
|
3773
3930
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3774
|
-
|
|
3931
|
+
log13("notarize", {
|
|
3775
3932
|
credentials
|
|
3776
3933
|
}, {
|
|
3777
|
-
F:
|
|
3934
|
+
F: __dxlog_file16,
|
|
3778
3935
|
L: 90,
|
|
3779
3936
|
S: this,
|
|
3780
3937
|
C: (f, a) => f(...a)
|
|
3781
3938
|
});
|
|
3782
|
-
|
|
3783
|
-
F:
|
|
3939
|
+
invariant13(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3940
|
+
F: __dxlog_file16,
|
|
3784
3941
|
L: 91,
|
|
3785
3942
|
S: this,
|
|
3786
3943
|
A: [
|
|
@@ -3791,10 +3948,10 @@ var NotarizationPlugin = class {
|
|
|
3791
3948
|
const errors = new Trigger6();
|
|
3792
3949
|
const ctx = this._ctx.derive({
|
|
3793
3950
|
onError: (err) => {
|
|
3794
|
-
|
|
3951
|
+
log13.warn("Notarization error", {
|
|
3795
3952
|
err
|
|
3796
3953
|
}, {
|
|
3797
|
-
F:
|
|
3954
|
+
F: __dxlog_file16,
|
|
3798
3955
|
L: 99,
|
|
3799
3956
|
S: this,
|
|
3800
3957
|
C: (f, a) => f(...a)
|
|
@@ -3806,11 +3963,11 @@ var NotarizationPlugin = class {
|
|
|
3806
3963
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3807
3964
|
if (timeout !== 0) {
|
|
3808
3965
|
scheduleTask4(ctx, () => {
|
|
3809
|
-
|
|
3966
|
+
log13.warn("Notarization timeout", {
|
|
3810
3967
|
timeout,
|
|
3811
3968
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3812
3969
|
}, {
|
|
3813
|
-
F:
|
|
3970
|
+
F: __dxlog_file16,
|
|
3814
3971
|
L: 111,
|
|
3815
3972
|
S: this,
|
|
3816
3973
|
C: (f, a) => f(...a)
|
|
@@ -3830,10 +3987,10 @@ var NotarizationPlugin = class {
|
|
|
3830
3987
|
...this._extensions
|
|
3831
3988
|
].find((peer2) => !peersTried.has(peer2));
|
|
3832
3989
|
if (!peer) {
|
|
3833
|
-
|
|
3990
|
+
log13.info("Exhausted all peers to notarize with", {
|
|
3834
3991
|
retryIn: retryTimeout
|
|
3835
3992
|
}, {
|
|
3836
|
-
F:
|
|
3993
|
+
F: __dxlog_file16,
|
|
3837
3994
|
L: 136,
|
|
3838
3995
|
S: this,
|
|
3839
3996
|
C: (f, a) => f(...a)
|
|
@@ -3843,11 +4000,11 @@ var NotarizationPlugin = class {
|
|
|
3843
4000
|
return;
|
|
3844
4001
|
}
|
|
3845
4002
|
peersTried.add(peer);
|
|
3846
|
-
|
|
4003
|
+
log13("try notarizing", {
|
|
3847
4004
|
peer: peer.localPeerId,
|
|
3848
4005
|
credentialId: credentials.map((credential) => credential.id)
|
|
3849
4006
|
}, {
|
|
3850
|
-
F:
|
|
4007
|
+
F: __dxlog_file16,
|
|
3851
4008
|
L: 143,
|
|
3852
4009
|
S: this,
|
|
3853
4010
|
C: (f, a) => f(...a)
|
|
@@ -3855,8 +4012,8 @@ var NotarizationPlugin = class {
|
|
|
3855
4012
|
await peer.rpc.NotarizationService.notarize({
|
|
3856
4013
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3857
4014
|
});
|
|
3858
|
-
|
|
3859
|
-
F:
|
|
4015
|
+
log13("success", void 0, {
|
|
4016
|
+
F: __dxlog_file16,
|
|
3860
4017
|
L: 147,
|
|
3861
4018
|
S: this,
|
|
3862
4019
|
C: (f, a) => f(...a)
|
|
@@ -3864,8 +4021,8 @@ var NotarizationPlugin = class {
|
|
|
3864
4021
|
await sleep(successDelay);
|
|
3865
4022
|
} catch (err) {
|
|
3866
4023
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3867
|
-
|
|
3868
|
-
F:
|
|
4024
|
+
log13.info("error notarizing (recoverable)", err, {
|
|
4025
|
+
F: __dxlog_file16,
|
|
3869
4026
|
L: 151,
|
|
3870
4027
|
S: this,
|
|
3871
4028
|
C: (f, a) => f(...a)
|
|
@@ -3882,8 +4039,8 @@ var NotarizationPlugin = class {
|
|
|
3882
4039
|
allNotarized,
|
|
3883
4040
|
errors.wait()
|
|
3884
4041
|
]);
|
|
3885
|
-
|
|
3886
|
-
F:
|
|
4042
|
+
log13("done", void 0, {
|
|
4043
|
+
F: __dxlog_file16,
|
|
3887
4044
|
L: 162,
|
|
3888
4045
|
S: this,
|
|
3889
4046
|
C: (f, a) => f(...a)
|
|
@@ -3904,8 +4061,8 @@ var NotarizationPlugin = class {
|
|
|
3904
4061
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3905
4062
|
}
|
|
3906
4063
|
setWriter(writer) {
|
|
3907
|
-
|
|
3908
|
-
F:
|
|
4064
|
+
invariant13(!this._writer, "Writer already set.", {
|
|
4065
|
+
F: __dxlog_file16,
|
|
3909
4066
|
L: 181,
|
|
3910
4067
|
S: this,
|
|
3911
4068
|
A: [
|
|
@@ -3929,8 +4086,8 @@ var NotarizationPlugin = class {
|
|
|
3929
4086
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3930
4087
|
}
|
|
3931
4088
|
for (const credential of request.credentials ?? []) {
|
|
3932
|
-
|
|
3933
|
-
F:
|
|
4089
|
+
invariant13(credential.id, "Credential must have an id", {
|
|
4090
|
+
F: __dxlog_file16,
|
|
3934
4091
|
L: 200,
|
|
3935
4092
|
S: this,
|
|
3936
4093
|
A: [
|
|
@@ -3947,10 +4104,10 @@ var NotarizationPlugin = class {
|
|
|
3947
4104
|
createExtension() {
|
|
3948
4105
|
const extension = new NotarizationTeleportExtension({
|
|
3949
4106
|
onOpen: async () => {
|
|
3950
|
-
|
|
4107
|
+
log13("extension opened", {
|
|
3951
4108
|
peer: extension.localPeerId
|
|
3952
4109
|
}, {
|
|
3953
|
-
F:
|
|
4110
|
+
F: __dxlog_file16,
|
|
3954
4111
|
L: 211,
|
|
3955
4112
|
S: this,
|
|
3956
4113
|
C: (f, a) => f(...a)
|
|
@@ -3959,10 +4116,10 @@ var NotarizationPlugin = class {
|
|
|
3959
4116
|
this._extensionOpened.emit();
|
|
3960
4117
|
},
|
|
3961
4118
|
onClose: async () => {
|
|
3962
|
-
|
|
4119
|
+
log13("extension closed", {
|
|
3963
4120
|
peer: extension.localPeerId
|
|
3964
4121
|
}, {
|
|
3965
|
-
F:
|
|
4122
|
+
F: __dxlog_file16,
|
|
3966
4123
|
L: 216,
|
|
3967
4124
|
S: this,
|
|
3968
4125
|
C: (f, a) => f(...a)
|
|
@@ -4016,7 +4173,70 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4016
4173
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4017
4174
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4018
4175
|
}
|
|
4019
|
-
|
|
4176
|
+
function _using_ctx() {
|
|
4177
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4178
|
+
var err = new Error();
|
|
4179
|
+
err.name = "SuppressedError";
|
|
4180
|
+
err.suppressed = suppressed;
|
|
4181
|
+
err.error = error;
|
|
4182
|
+
return err;
|
|
4183
|
+
}, empty = {}, stack = [];
|
|
4184
|
+
function using(isAwait, value) {
|
|
4185
|
+
if (value != null) {
|
|
4186
|
+
if (Object(value) !== value) {
|
|
4187
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4188
|
+
}
|
|
4189
|
+
if (isAwait) {
|
|
4190
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4191
|
+
}
|
|
4192
|
+
if (dispose == null) {
|
|
4193
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4194
|
+
}
|
|
4195
|
+
if (typeof dispose !== "function") {
|
|
4196
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4197
|
+
}
|
|
4198
|
+
stack.push({
|
|
4199
|
+
v: value,
|
|
4200
|
+
d: dispose,
|
|
4201
|
+
a: isAwait
|
|
4202
|
+
});
|
|
4203
|
+
} else if (isAwait) {
|
|
4204
|
+
stack.push({
|
|
4205
|
+
d: value,
|
|
4206
|
+
a: isAwait
|
|
4207
|
+
});
|
|
4208
|
+
}
|
|
4209
|
+
return value;
|
|
4210
|
+
}
|
|
4211
|
+
return {
|
|
4212
|
+
e: empty,
|
|
4213
|
+
u: using.bind(null, false),
|
|
4214
|
+
a: using.bind(null, true),
|
|
4215
|
+
d: function() {
|
|
4216
|
+
var error = this.e;
|
|
4217
|
+
function next() {
|
|
4218
|
+
while (resource = stack.pop()) {
|
|
4219
|
+
try {
|
|
4220
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4221
|
+
if (resource.a) {
|
|
4222
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4223
|
+
}
|
|
4224
|
+
} catch (e) {
|
|
4225
|
+
return err(e);
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
if (error !== empty)
|
|
4229
|
+
throw error;
|
|
4230
|
+
}
|
|
4231
|
+
function err(e) {
|
|
4232
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4233
|
+
return next();
|
|
4234
|
+
}
|
|
4235
|
+
return next();
|
|
4236
|
+
}
|
|
4237
|
+
};
|
|
4238
|
+
}
|
|
4239
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4020
4240
|
var DataSpace = class {
|
|
4021
4241
|
constructor(params) {
|
|
4022
4242
|
this._ctx = new Context8();
|
|
@@ -4024,7 +4244,9 @@ var DataSpace = class {
|
|
|
4024
4244
|
this._cache = void 0;
|
|
4025
4245
|
// TODO(dmaretskyi): Move into Space?
|
|
4026
4246
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4247
|
+
this._epochProcessingMutex = new Mutex2();
|
|
4027
4248
|
this._state = SpaceState2.CLOSED;
|
|
4249
|
+
this._databaseRoot = null;
|
|
4028
4250
|
/**
|
|
4029
4251
|
* Error for _state === SpaceState.ERROR.
|
|
4030
4252
|
*/
|
|
@@ -4048,11 +4270,11 @@ var DataSpace = class {
|
|
|
4048
4270
|
});
|
|
4049
4271
|
this._cache = params.cache;
|
|
4050
4272
|
this._state = params.initialState;
|
|
4051
|
-
|
|
4273
|
+
log14("new state", {
|
|
4052
4274
|
state: SpaceState2[this._state]
|
|
4053
4275
|
}, {
|
|
4054
|
-
F:
|
|
4055
|
-
L:
|
|
4276
|
+
F: __dxlog_file17,
|
|
4277
|
+
L: 146,
|
|
4056
4278
|
S: this,
|
|
4057
4279
|
C: (f, a) => f(...a)
|
|
4058
4280
|
});
|
|
@@ -4085,6 +4307,9 @@ var DataSpace = class {
|
|
|
4085
4307
|
get automergeSpaceState() {
|
|
4086
4308
|
return this._automergeSpaceState;
|
|
4087
4309
|
}
|
|
4310
|
+
get databaseRoot() {
|
|
4311
|
+
return this._databaseRoot;
|
|
4312
|
+
}
|
|
4088
4313
|
get _automergeInfo() {
|
|
4089
4314
|
return {
|
|
4090
4315
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4101,14 +4326,15 @@ var DataSpace = class {
|
|
|
4101
4326
|
await this._gossip.open();
|
|
4102
4327
|
await this._notarizationPlugin.open();
|
|
4103
4328
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4329
|
+
await this._automergeSpaceState.open();
|
|
4104
4330
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4105
4331
|
await this._inner.open(new Context8());
|
|
4106
4332
|
this._state = SpaceState2.CONTROL_ONLY;
|
|
4107
|
-
|
|
4333
|
+
log14("new state", {
|
|
4108
4334
|
state: SpaceState2[this._state]
|
|
4109
4335
|
}, {
|
|
4110
|
-
F:
|
|
4111
|
-
L:
|
|
4336
|
+
F: __dxlog_file17,
|
|
4337
|
+
L: 217,
|
|
4112
4338
|
S: this,
|
|
4113
4339
|
C: (f, a) => f(...a)
|
|
4114
4340
|
});
|
|
@@ -4122,11 +4348,11 @@ var DataSpace = class {
|
|
|
4122
4348
|
async _close() {
|
|
4123
4349
|
await this._callbacks.beforeClose?.();
|
|
4124
4350
|
this._state = SpaceState2.CLOSED;
|
|
4125
|
-
|
|
4351
|
+
log14("new state", {
|
|
4126
4352
|
state: SpaceState2[this._state]
|
|
4127
4353
|
}, {
|
|
4128
|
-
F:
|
|
4129
|
-
L:
|
|
4354
|
+
F: __dxlog_file17,
|
|
4355
|
+
L: 231,
|
|
4130
4356
|
S: this,
|
|
4131
4357
|
C: (f, a) => f(...a)
|
|
4132
4358
|
});
|
|
@@ -4135,6 +4361,7 @@ var DataSpace = class {
|
|
|
4135
4361
|
await this.authVerifier.close();
|
|
4136
4362
|
await this._inner.close();
|
|
4137
4363
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4364
|
+
await this._automergeSpaceState.close();
|
|
4138
4365
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4139
4366
|
await this._notarizationPlugin.close();
|
|
4140
4367
|
await this._presence.close();
|
|
@@ -4156,26 +4383,26 @@ var DataSpace = class {
|
|
|
4156
4383
|
await this.initializeDataPipeline();
|
|
4157
4384
|
} catch (err) {
|
|
4158
4385
|
if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
|
|
4159
|
-
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4386
|
+
log14("data pipeline initialization cancelled", err, {
|
|
4387
|
+
F: __dxlog_file17,
|
|
4388
|
+
L: 265,
|
|
4162
4389
|
S: this,
|
|
4163
4390
|
C: (f, a) => f(...a)
|
|
4164
4391
|
});
|
|
4165
4392
|
return;
|
|
4166
4393
|
}
|
|
4167
|
-
|
|
4168
|
-
F:
|
|
4169
|
-
L:
|
|
4394
|
+
log14.error("Error initializing data pipeline", err, {
|
|
4395
|
+
F: __dxlog_file17,
|
|
4396
|
+
L: 269,
|
|
4170
4397
|
S: this,
|
|
4171
4398
|
C: (f, a) => f(...a)
|
|
4172
4399
|
});
|
|
4173
4400
|
this._state = SpaceState2.ERROR;
|
|
4174
|
-
|
|
4401
|
+
log14("new state", {
|
|
4175
4402
|
state: SpaceState2[this._state]
|
|
4176
4403
|
}, {
|
|
4177
|
-
F:
|
|
4178
|
-
L:
|
|
4404
|
+
F: __dxlog_file17,
|
|
4405
|
+
L: 271,
|
|
4179
4406
|
S: this,
|
|
4180
4407
|
C: (f, a) => f(...a)
|
|
4181
4408
|
});
|
|
@@ -4191,31 +4418,28 @@ var DataSpace = class {
|
|
|
4191
4418
|
throw new SystemError("Invalid operation");
|
|
4192
4419
|
}
|
|
4193
4420
|
this._state = SpaceState2.INITIALIZING;
|
|
4194
|
-
|
|
4421
|
+
log14("new state", {
|
|
4195
4422
|
state: SpaceState2[this._state]
|
|
4196
4423
|
}, {
|
|
4197
|
-
F:
|
|
4198
|
-
L:
|
|
4424
|
+
F: __dxlog_file17,
|
|
4425
|
+
L: 287,
|
|
4199
4426
|
S: this,
|
|
4200
4427
|
C: (f, a) => f(...a)
|
|
4201
4428
|
});
|
|
4202
4429
|
await this._initializeAndReadControlPipeline();
|
|
4203
4430
|
await sleep2(1);
|
|
4431
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState2.READY);
|
|
4204
4432
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4205
|
-
await
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
L: 290,
|
|
4209
|
-
S: this,
|
|
4210
|
-
C: (f, a) => f(...a)
|
|
4211
|
-
});
|
|
4433
|
+
await ready;
|
|
4434
|
+
}
|
|
4435
|
+
async _enterReadyState() {
|
|
4212
4436
|
await this._callbacks.beforeReady?.();
|
|
4213
4437
|
this._state = SpaceState2.READY;
|
|
4214
|
-
|
|
4438
|
+
log14("new state", {
|
|
4215
4439
|
state: SpaceState2[this._state]
|
|
4216
4440
|
}, {
|
|
4217
|
-
F:
|
|
4218
|
-
L:
|
|
4441
|
+
F: __dxlog_file17,
|
|
4442
|
+
L: 306,
|
|
4219
4443
|
S: this,
|
|
4220
4444
|
C: (f, a) => f(...a)
|
|
4221
4445
|
});
|
|
@@ -4229,9 +4453,9 @@ var DataSpace = class {
|
|
|
4229
4453
|
});
|
|
4230
4454
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4231
4455
|
await this._createWritableFeeds();
|
|
4232
|
-
|
|
4233
|
-
F:
|
|
4234
|
-
L:
|
|
4456
|
+
log14("writable feeds created", void 0, {
|
|
4457
|
+
F: __dxlog_file17,
|
|
4458
|
+
L: 322,
|
|
4235
4459
|
S: this,
|
|
4236
4460
|
C: (f, a) => f(...a)
|
|
4237
4461
|
});
|
|
@@ -4289,12 +4513,12 @@ var DataSpace = class {
|
|
|
4289
4513
|
}
|
|
4290
4514
|
}
|
|
4291
4515
|
_onNewAutomergeRoot(rootUrl) {
|
|
4292
|
-
|
|
4516
|
+
log14("loading automerge root doc for space", {
|
|
4293
4517
|
space: this.key,
|
|
4294
4518
|
rootUrl
|
|
4295
4519
|
}, {
|
|
4296
|
-
F:
|
|
4297
|
-
L:
|
|
4520
|
+
F: __dxlog_file17,
|
|
4521
|
+
L: 388,
|
|
4298
4522
|
S: this,
|
|
4299
4523
|
C: (f, a) => f(...a)
|
|
4300
4524
|
});
|
|
@@ -4302,44 +4526,52 @@ var DataSpace = class {
|
|
|
4302
4526
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4303
4527
|
queueMicrotask(async () => {
|
|
4304
4528
|
try {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
return;
|
|
4310
|
-
}
|
|
4311
|
-
const doc = handle.docSync() ?? failedInvariant();
|
|
4312
|
-
if (!doc.access?.spaceKey) {
|
|
4313
|
-
handle.change((doc2) => {
|
|
4314
|
-
doc2.access = {
|
|
4315
|
-
spaceKey: this.key.toHex()
|
|
4316
|
-
};
|
|
4317
|
-
});
|
|
4318
|
-
}
|
|
4319
|
-
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4320
|
-
await this._echoHost.openSpaceRoot(handle.url);
|
|
4321
|
-
} else {
|
|
4322
|
-
log13.warn("echo database root already exists", {
|
|
4323
|
-
space: this.key,
|
|
4324
|
-
rootUrl
|
|
4325
|
-
}, {
|
|
4326
|
-
F: __dxlog_file16,
|
|
4327
|
-
L: 403,
|
|
4328
|
-
S: this,
|
|
4329
|
-
C: (f, a) => f(...a)
|
|
4529
|
+
try {
|
|
4530
|
+
var _usingCtx = _using_ctx();
|
|
4531
|
+
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4532
|
+
await cancelWithContext5(this._ctx, handle.whenReady());
|
|
4330
4533
|
});
|
|
4534
|
+
if (this._ctx.disposed) {
|
|
4535
|
+
return;
|
|
4536
|
+
}
|
|
4537
|
+
const _guard = (
|
|
4538
|
+
// Ensure only one root is processed at a time.
|
|
4539
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4540
|
+
);
|
|
4541
|
+
const doc = handle.docSync() ?? failedInvariant();
|
|
4542
|
+
if (!doc.access?.spaceKey) {
|
|
4543
|
+
handle.change((doc2) => {
|
|
4544
|
+
doc2.access = {
|
|
4545
|
+
spaceKey: this.key.toHex()
|
|
4546
|
+
};
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4550
|
+
this._databaseRoot = root;
|
|
4551
|
+
if (root.getVersion() !== SpaceDocVersion.CURRENT) {
|
|
4552
|
+
this._state = SpaceState2.REQUIRES_MIGRATION;
|
|
4553
|
+
this.stateUpdate.emit();
|
|
4554
|
+
} else {
|
|
4555
|
+
if (this._state !== SpaceState2.READY) {
|
|
4556
|
+
await this._enterReadyState();
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
} catch (_) {
|
|
4560
|
+
_usingCtx.e = _;
|
|
4561
|
+
} finally {
|
|
4562
|
+
_usingCtx.d();
|
|
4331
4563
|
}
|
|
4332
4564
|
} catch (err) {
|
|
4333
4565
|
if (err instanceof ContextDisposedError3) {
|
|
4334
4566
|
return;
|
|
4335
4567
|
}
|
|
4336
|
-
|
|
4568
|
+
log14.warn("error loading automerge root doc", {
|
|
4337
4569
|
space: this.key,
|
|
4338
4570
|
rootUrl,
|
|
4339
4571
|
err
|
|
4340
4572
|
}, {
|
|
4341
|
-
F:
|
|
4342
|
-
L:
|
|
4573
|
+
F: __dxlog_file17,
|
|
4574
|
+
L: 431,
|
|
4343
4575
|
S: this,
|
|
4344
4576
|
C: (f, a) => f(...a)
|
|
4345
4577
|
});
|
|
@@ -4362,148 +4594,34 @@ var DataSpace = class {
|
|
|
4362
4594
|
});
|
|
4363
4595
|
}
|
|
4364
4596
|
async createEpoch(options) {
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
case CreateEpochRequest.Migration.NONE:
|
|
4369
|
-
{
|
|
4370
|
-
epoch = {
|
|
4371
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4372
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4373
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4374
|
-
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4375
|
-
};
|
|
4376
|
-
}
|
|
4377
|
-
break;
|
|
4378
|
-
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4379
|
-
{
|
|
4380
|
-
const document = this._echoHost.automergeRepo.create();
|
|
4381
|
-
epoch = {
|
|
4382
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4383
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4384
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4385
|
-
automergeRoot: document.url
|
|
4386
|
-
};
|
|
4387
|
-
}
|
|
4388
|
-
break;
|
|
4389
|
-
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4390
|
-
{
|
|
4391
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4392
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4393
|
-
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4394
|
-
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4395
|
-
await this._echoHost.automergeRepo.flush([
|
|
4396
|
-
newRoot.documentId
|
|
4397
|
-
]);
|
|
4398
|
-
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4399
|
-
F: __dxlog_file16,
|
|
4400
|
-
L: 460,
|
|
4401
|
-
S: this,
|
|
4402
|
-
A: [
|
|
4403
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4404
|
-
""
|
|
4405
|
-
]
|
|
4406
|
-
});
|
|
4407
|
-
epoch = {
|
|
4408
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4409
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4410
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4411
|
-
automergeRoot: newRoot.url
|
|
4412
|
-
};
|
|
4413
|
-
}
|
|
4414
|
-
break;
|
|
4415
|
-
case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4416
|
-
{
|
|
4417
|
-
log13.info("Fragmenting", void 0, {
|
|
4418
|
-
F: __dxlog_file16,
|
|
4419
|
-
L: 472,
|
|
4420
|
-
S: this,
|
|
4421
|
-
C: (f, a) => f(...a)
|
|
4422
|
-
});
|
|
4423
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4424
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4425
|
-
await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
|
|
4426
|
-
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4427
|
-
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4428
|
-
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4429
|
-
invariant13(properties, "Properties not found", {
|
|
4430
|
-
F: __dxlog_file16,
|
|
4431
|
-
L: 482,
|
|
4432
|
-
S: this,
|
|
4433
|
-
A: [
|
|
4434
|
-
"properties",
|
|
4435
|
-
"'Properties not found'"
|
|
4436
|
-
]
|
|
4437
|
-
});
|
|
4438
|
-
const newSpaceDoc = {
|
|
4439
|
-
...rootHandle.docSync(),
|
|
4440
|
-
objects: Object.fromEntries([
|
|
4441
|
-
properties
|
|
4442
|
-
])
|
|
4443
|
-
};
|
|
4444
|
-
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4445
|
-
invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4446
|
-
F: __dxlog_file16,
|
|
4447
|
-
L: 487,
|
|
4448
|
-
S: this,
|
|
4449
|
-
A: [
|
|
4450
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4451
|
-
""
|
|
4452
|
-
]
|
|
4453
|
-
});
|
|
4454
|
-
const docLoader = new AutomergeDocumentLoaderImpl(await createIdFromSpaceKey(this.key), this._echoHost.automergeRepo, this.key);
|
|
4455
|
-
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
4456
|
-
rootUrl: newRoot.url
|
|
4457
|
-
});
|
|
4458
|
-
otherObjects.forEach(([key, value]) => {
|
|
4459
|
-
const handle = docLoader.createDocumentForObject(key);
|
|
4460
|
-
handle.change((doc) => {
|
|
4461
|
-
assignDeep(doc, [
|
|
4462
|
-
"objects",
|
|
4463
|
-
key
|
|
4464
|
-
], value);
|
|
4465
|
-
});
|
|
4466
|
-
});
|
|
4467
|
-
epoch = {
|
|
4468
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4469
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4470
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4471
|
-
automergeRoot: newRoot.url
|
|
4472
|
-
};
|
|
4473
|
-
}
|
|
4474
|
-
break;
|
|
4475
|
-
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4476
|
-
{
|
|
4477
|
-
invariant13(options.newAutomergeRoot, void 0, {
|
|
4478
|
-
F: __dxlog_file16,
|
|
4479
|
-
L: 517,
|
|
4480
|
-
S: this,
|
|
4481
|
-
A: [
|
|
4482
|
-
"options.newAutomergeRoot",
|
|
4483
|
-
""
|
|
4484
|
-
]
|
|
4485
|
-
});
|
|
4486
|
-
epoch = {
|
|
4487
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4488
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4489
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4490
|
-
automergeRoot: options.newAutomergeRoot
|
|
4491
|
-
};
|
|
4492
|
-
}
|
|
4493
|
-
break;
|
|
4494
|
-
}
|
|
4495
|
-
if (!epoch) {
|
|
4496
|
-
return;
|
|
4597
|
+
const ctx = this._ctx.derive();
|
|
4598
|
+
if (!options?.migration) {
|
|
4599
|
+
return null;
|
|
4497
4600
|
}
|
|
4601
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4602
|
+
repo: this._echoHost.automergeRepo,
|
|
4603
|
+
spaceId: this.id,
|
|
4604
|
+
spaceKey: this.key,
|
|
4605
|
+
migration: options.migration,
|
|
4606
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4607
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4608
|
+
});
|
|
4609
|
+
const epoch = {
|
|
4610
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4611
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4612
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe3(),
|
|
4613
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4614
|
+
};
|
|
4615
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4616
|
+
subject: this.key,
|
|
4617
|
+
assertion: {
|
|
4618
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4619
|
+
...epoch
|
|
4620
|
+
}
|
|
4621
|
+
});
|
|
4498
4622
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4499
4623
|
credential: {
|
|
4500
|
-
credential
|
|
4501
|
-
subject: this.key,
|
|
4502
|
-
assertion: {
|
|
4503
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4504
|
-
...epoch
|
|
4505
|
-
}
|
|
4506
|
-
})
|
|
4624
|
+
credential
|
|
4507
4625
|
}
|
|
4508
4626
|
});
|
|
4509
4627
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
@@ -4513,6 +4631,7 @@ var DataSpace = class {
|
|
|
4513
4631
|
]
|
|
4514
4632
|
]));
|
|
4515
4633
|
await this._echoHost.updateIndexes();
|
|
4634
|
+
return credential;
|
|
4516
4635
|
}
|
|
4517
4636
|
async activate() {
|
|
4518
4637
|
if (![
|
|
@@ -4534,11 +4653,11 @@ var DataSpace = class {
|
|
|
4534
4653
|
await this._close();
|
|
4535
4654
|
}
|
|
4536
4655
|
this._state = SpaceState2.INACTIVE;
|
|
4537
|
-
|
|
4656
|
+
log14("new state", {
|
|
4538
4657
|
state: SpaceState2[this._state]
|
|
4539
4658
|
}, {
|
|
4540
|
-
F:
|
|
4541
|
-
L:
|
|
4659
|
+
F: __dxlog_file17,
|
|
4660
|
+
L: 512,
|
|
4542
4661
|
S: this,
|
|
4543
4662
|
C: (f, a) => f(...a)
|
|
4544
4663
|
});
|
|
@@ -4593,36 +4712,25 @@ DataSpace = _ts_decorate4([
|
|
|
4593
4712
|
trackLeaks("open", "close"),
|
|
4594
4713
|
trace6.resource()
|
|
4595
4714
|
], DataSpace);
|
|
4596
|
-
var findPropertiesObject = (spaceDoc) => {
|
|
4597
|
-
for (const id in spaceDoc.objects ?? {}) {
|
|
4598
|
-
const obj = spaceDoc.objects[id];
|
|
4599
|
-
if (obj.system.type?.itemId === TYPE_PROPERTIES) {
|
|
4600
|
-
return [
|
|
4601
|
-
id,
|
|
4602
|
-
obj
|
|
4603
|
-
];
|
|
4604
|
-
}
|
|
4605
|
-
}
|
|
4606
|
-
return void 0;
|
|
4607
|
-
};
|
|
4608
4715
|
|
|
4609
4716
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
4610
4717
|
import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
4611
4718
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
4612
|
-
import {
|
|
4719
|
+
import { Context as Context9, cancelWithContext as cancelWithContext6 } from "@dxos/context";
|
|
4613
4720
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4721
|
+
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2 } from "@dxos/echo-db";
|
|
4614
4722
|
import { AuthStatus } from "@dxos/echo-pipeline";
|
|
4615
|
-
import { encodeReference } from "@dxos/echo-protocol";
|
|
4616
|
-
import { getTypeReference } from "@dxos/echo-schema";
|
|
4723
|
+
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
|
|
4724
|
+
import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
|
|
4617
4725
|
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4618
4726
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4619
|
-
import { log as
|
|
4727
|
+
import { log as log15 } from "@dxos/log";
|
|
4620
4728
|
import { trace as Trace2 } from "@dxos/protocols";
|
|
4621
4729
|
import { Invitation as Invitation7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4622
4730
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
4623
4731
|
import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
|
|
4624
4732
|
import { trace as trace7 } from "@dxos/tracing";
|
|
4625
|
-
import {
|
|
4733
|
+
import { ComplexMap as ComplexMap3, assignDeep as assignDeep2, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
|
|
4626
4734
|
|
|
4627
4735
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
4628
4736
|
import { createCredential } from "@dxos/credentials";
|
|
@@ -4705,7 +4813,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4705
4813
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4706
4814
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4707
4815
|
}
|
|
4708
|
-
var
|
|
4816
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4709
4817
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4710
4818
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4711
4819
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4732,7 +4840,7 @@ var DataSpaceManager = class {
|
|
|
4732
4840
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4733
4841
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4734
4842
|
const rootDoc = rootHandle?.docSync();
|
|
4735
|
-
const properties = rootDoc &&
|
|
4843
|
+
const properties = rootDoc && findInlineObjectOfType2(rootDoc, TYPE_PROPERTIES2);
|
|
4736
4844
|
return {
|
|
4737
4845
|
key: space.key.toHex(),
|
|
4738
4846
|
state: SpaceState3[space.state],
|
|
@@ -4752,46 +4860,46 @@ var DataSpaceManager = class {
|
|
|
4752
4860
|
return this._spaces;
|
|
4753
4861
|
}
|
|
4754
4862
|
async open() {
|
|
4755
|
-
|
|
4756
|
-
F:
|
|
4757
|
-
L:
|
|
4863
|
+
log15("open", void 0, {
|
|
4864
|
+
F: __dxlog_file18,
|
|
4865
|
+
L: 146,
|
|
4758
4866
|
S: this,
|
|
4759
4867
|
C: (f, a) => f(...a)
|
|
4760
4868
|
});
|
|
4761
|
-
|
|
4869
|
+
log15.trace("dxos.echo.data-space-manager.open", Trace2.begin({
|
|
4762
4870
|
id: this._instanceId
|
|
4763
4871
|
}), {
|
|
4764
|
-
F:
|
|
4765
|
-
L:
|
|
4872
|
+
F: __dxlog_file18,
|
|
4873
|
+
L: 147,
|
|
4766
4874
|
S: this,
|
|
4767
4875
|
C: (f, a) => f(...a)
|
|
4768
4876
|
});
|
|
4769
|
-
|
|
4877
|
+
log15("metadata loaded", {
|
|
4770
4878
|
spaces: this._metadataStore.spaces.length
|
|
4771
4879
|
}, {
|
|
4772
|
-
F:
|
|
4773
|
-
L:
|
|
4880
|
+
F: __dxlog_file18,
|
|
4881
|
+
L: 148,
|
|
4774
4882
|
S: this,
|
|
4775
4883
|
C: (f, a) => f(...a)
|
|
4776
4884
|
});
|
|
4777
4885
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4778
4886
|
try {
|
|
4779
|
-
|
|
4887
|
+
log15("load space", {
|
|
4780
4888
|
spaceMetadata
|
|
4781
4889
|
}, {
|
|
4782
|
-
F:
|
|
4783
|
-
L:
|
|
4890
|
+
F: __dxlog_file18,
|
|
4891
|
+
L: 152,
|
|
4784
4892
|
S: this,
|
|
4785
4893
|
C: (f, a) => f(...a)
|
|
4786
4894
|
});
|
|
4787
4895
|
await this._constructSpace(spaceMetadata);
|
|
4788
4896
|
} catch (err) {
|
|
4789
|
-
|
|
4897
|
+
log15.error("Error loading space", {
|
|
4790
4898
|
spaceMetadata,
|
|
4791
4899
|
err
|
|
4792
4900
|
}, {
|
|
4793
|
-
F:
|
|
4794
|
-
L:
|
|
4901
|
+
F: __dxlog_file18,
|
|
4902
|
+
L: 155,
|
|
4795
4903
|
S: this,
|
|
4796
4904
|
C: (f, a) => f(...a)
|
|
4797
4905
|
});
|
|
@@ -4799,19 +4907,19 @@ var DataSpaceManager = class {
|
|
|
4799
4907
|
});
|
|
4800
4908
|
this._isOpen = true;
|
|
4801
4909
|
this.updated.emit();
|
|
4802
|
-
|
|
4910
|
+
log15.trace("dxos.echo.data-space-manager.open", Trace2.end({
|
|
4803
4911
|
id: this._instanceId
|
|
4804
4912
|
}), {
|
|
4805
|
-
F:
|
|
4806
|
-
L:
|
|
4913
|
+
F: __dxlog_file18,
|
|
4914
|
+
L: 162,
|
|
4807
4915
|
S: this,
|
|
4808
4916
|
C: (f, a) => f(...a)
|
|
4809
4917
|
});
|
|
4810
4918
|
}
|
|
4811
4919
|
async close() {
|
|
4812
|
-
|
|
4813
|
-
F:
|
|
4814
|
-
L:
|
|
4920
|
+
log15("close", void 0, {
|
|
4921
|
+
F: __dxlog_file18,
|
|
4922
|
+
L: 167,
|
|
4815
4923
|
S: this,
|
|
4816
4924
|
C: (f, a) => f(...a)
|
|
4817
4925
|
});
|
|
@@ -4827,8 +4935,8 @@ var DataSpaceManager = class {
|
|
|
4827
4935
|
*/
|
|
4828
4936
|
async createSpace() {
|
|
4829
4937
|
invariant14(this._isOpen, "Not open.", {
|
|
4830
|
-
F:
|
|
4831
|
-
L:
|
|
4938
|
+
F: __dxlog_file18,
|
|
4939
|
+
L: 181,
|
|
4832
4940
|
S: this,
|
|
4833
4941
|
A: [
|
|
4834
4942
|
"this._isOpen",
|
|
@@ -4845,11 +4953,11 @@ var DataSpaceManager = class {
|
|
|
4845
4953
|
dataFeedKey,
|
|
4846
4954
|
state: SpaceState3.ACTIVE
|
|
4847
4955
|
};
|
|
4848
|
-
|
|
4956
|
+
log15("creating space...", {
|
|
4849
4957
|
spaceKey
|
|
4850
4958
|
}, {
|
|
4851
|
-
F:
|
|
4852
|
-
L:
|
|
4959
|
+
F: __dxlog_file18,
|
|
4960
|
+
L: 193,
|
|
4853
4961
|
S: this,
|
|
4854
4962
|
C: (f, a) => f(...a)
|
|
4855
4963
|
});
|
|
@@ -4860,8 +4968,8 @@ var DataSpaceManager = class {
|
|
|
4860
4968
|
await this._metadataStore.addSpace(metadata);
|
|
4861
4969
|
const memberCredential = credentials[1];
|
|
4862
4970
|
invariant14(getCredentialAssertion3(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4863
|
-
F:
|
|
4864
|
-
L:
|
|
4971
|
+
F: __dxlog_file18,
|
|
4972
|
+
L: 203,
|
|
4865
4973
|
S: this,
|
|
4866
4974
|
A: [
|
|
4867
4975
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4874,9 +4982,31 @@ var DataSpaceManager = class {
|
|
|
4874
4982
|
return space;
|
|
4875
4983
|
}
|
|
4876
4984
|
async isDefaultSpace(space) {
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4985
|
+
if (!space.databaseRoot) {
|
|
4986
|
+
return false;
|
|
4987
|
+
}
|
|
4988
|
+
switch (space.databaseRoot.getVersion()) {
|
|
4989
|
+
case SpaceDocVersion2.CURRENT: {
|
|
4990
|
+
const [_, properties] = findInlineObjectOfType2(space.databaseRoot.docSync(), TYPE_PROPERTIES2) ?? [];
|
|
4991
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4992
|
+
}
|
|
4993
|
+
case SpaceDocVersion2.LEGACY: {
|
|
4994
|
+
const convertedDoc = await convertLegacyReferences2(space.databaseRoot.docSync());
|
|
4995
|
+
const [_, properties] = findInlineObjectOfType2(convertedDoc, LEGACY_TYPE_PROPERTIES) ?? [];
|
|
4996
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4997
|
+
}
|
|
4998
|
+
default:
|
|
4999
|
+
log15.warn("unknown space version", {
|
|
5000
|
+
version: space.databaseRoot.getVersion(),
|
|
5001
|
+
spaceId: space.id
|
|
5002
|
+
}, {
|
|
5003
|
+
F: __dxlog_file18,
|
|
5004
|
+
L: 228,
|
|
5005
|
+
S: this,
|
|
5006
|
+
C: (f, a) => f(...a)
|
|
5007
|
+
});
|
|
5008
|
+
return false;
|
|
5009
|
+
}
|
|
4880
5010
|
}
|
|
4881
5011
|
async createDefaultSpace() {
|
|
4882
5012
|
const space = await this.createSpace();
|
|
@@ -4892,7 +5022,7 @@ var DataSpaceManager = class {
|
|
|
4892
5022
|
keys: []
|
|
4893
5023
|
}
|
|
4894
5024
|
};
|
|
4895
|
-
const propertiesId =
|
|
5025
|
+
const propertiesId = generateEchoId();
|
|
4896
5026
|
document.change((doc) => {
|
|
4897
5027
|
assignDeep2(doc, [
|
|
4898
5028
|
"objects",
|
|
@@ -4905,8 +5035,8 @@ var DataSpaceManager = class {
|
|
|
4905
5035
|
async _getSpaceRootDocument(space) {
|
|
4906
5036
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4907
5037
|
invariant14(automergeIndex, void 0, {
|
|
4908
|
-
F:
|
|
4909
|
-
L:
|
|
5038
|
+
F: __dxlog_file18,
|
|
5039
|
+
L: 261,
|
|
4910
5040
|
S: this,
|
|
4911
5041
|
A: [
|
|
4912
5042
|
"automergeIndex",
|
|
@@ -4919,17 +5049,17 @@ var DataSpaceManager = class {
|
|
|
4919
5049
|
}
|
|
4920
5050
|
// TODO(burdon): Rename join space.
|
|
4921
5051
|
async acceptSpace(opts) {
|
|
4922
|
-
|
|
5052
|
+
log15("accept space", {
|
|
4923
5053
|
opts
|
|
4924
5054
|
}, {
|
|
4925
|
-
F:
|
|
4926
|
-
L:
|
|
5055
|
+
F: __dxlog_file18,
|
|
5056
|
+
L: 270,
|
|
4927
5057
|
S: this,
|
|
4928
5058
|
C: (f, a) => f(...a)
|
|
4929
5059
|
});
|
|
4930
5060
|
invariant14(this._isOpen, "Not open.", {
|
|
4931
|
-
F:
|
|
4932
|
-
L:
|
|
5061
|
+
F: __dxlog_file18,
|
|
5062
|
+
L: 271,
|
|
4933
5063
|
S: this,
|
|
4934
5064
|
A: [
|
|
4935
5065
|
"this._isOpen",
|
|
@@ -4937,8 +5067,8 @@ var DataSpaceManager = class {
|
|
|
4937
5067
|
]
|
|
4938
5068
|
});
|
|
4939
5069
|
invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4940
|
-
F:
|
|
4941
|
-
L:
|
|
5070
|
+
F: __dxlog_file18,
|
|
5071
|
+
L: 272,
|
|
4942
5072
|
S: this,
|
|
4943
5073
|
A: [
|
|
4944
5074
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4964,17 +5094,17 @@ var DataSpaceManager = class {
|
|
|
4964
5094
|
* TODO(dmaretskyi): Consider removing.
|
|
4965
5095
|
*/
|
|
4966
5096
|
async waitUntilSpaceReady(spaceKey) {
|
|
4967
|
-
await
|
|
5097
|
+
await cancelWithContext6(this._ctx, this.updated.waitForCondition(() => {
|
|
4968
5098
|
const space = this._spaces.get(spaceKey);
|
|
4969
5099
|
return !!space && space.state === SpaceState3.READY;
|
|
4970
5100
|
}));
|
|
4971
5101
|
}
|
|
4972
5102
|
async _constructSpace(metadata) {
|
|
4973
|
-
|
|
5103
|
+
log15("construct space", {
|
|
4974
5104
|
metadata
|
|
4975
5105
|
}, {
|
|
4976
|
-
F:
|
|
4977
|
-
L:
|
|
5106
|
+
F: __dxlog_file18,
|
|
5107
|
+
L: 306,
|
|
4978
5108
|
S: this,
|
|
4979
5109
|
C: (f, a) => f(...a)
|
|
4980
5110
|
});
|
|
@@ -5010,9 +5140,9 @@ var DataSpaceManager = class {
|
|
|
5010
5140
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5011
5141
|
},
|
|
5012
5142
|
onAuthFailure: () => {
|
|
5013
|
-
|
|
5014
|
-
F:
|
|
5015
|
-
L:
|
|
5143
|
+
log15.warn("auth failure", void 0, {
|
|
5144
|
+
F: __dxlog_file18,
|
|
5145
|
+
L: 343,
|
|
5016
5146
|
S: this,
|
|
5017
5147
|
C: (f, a) => f(...a)
|
|
5018
5148
|
});
|
|
@@ -5041,22 +5171,22 @@ var DataSpaceManager = class {
|
|
|
5041
5171
|
signingContext: this._signingContext,
|
|
5042
5172
|
callbacks: {
|
|
5043
5173
|
beforeReady: async () => {
|
|
5044
|
-
|
|
5174
|
+
log15("before space ready", {
|
|
5045
5175
|
space: space.key
|
|
5046
5176
|
}, {
|
|
5047
|
-
F:
|
|
5048
|
-
L:
|
|
5177
|
+
F: __dxlog_file18,
|
|
5178
|
+
L: 370,
|
|
5049
5179
|
S: this,
|
|
5050
5180
|
C: (f, a) => f(...a)
|
|
5051
5181
|
});
|
|
5052
5182
|
},
|
|
5053
5183
|
afterReady: async () => {
|
|
5054
|
-
|
|
5184
|
+
log15("after space ready", {
|
|
5055
5185
|
space: space.key,
|
|
5056
5186
|
open: this._isOpen
|
|
5057
5187
|
}, {
|
|
5058
|
-
F:
|
|
5059
|
-
L:
|
|
5188
|
+
F: __dxlog_file18,
|
|
5189
|
+
L: 373,
|
|
5060
5190
|
S: this,
|
|
5061
5191
|
C: (f, a) => f(...a)
|
|
5062
5192
|
});
|
|
@@ -5071,11 +5201,11 @@ var DataSpaceManager = class {
|
|
|
5071
5201
|
}
|
|
5072
5202
|
},
|
|
5073
5203
|
beforeClose: async () => {
|
|
5074
|
-
|
|
5204
|
+
log15("before space close", {
|
|
5075
5205
|
space: space.key
|
|
5076
5206
|
}, {
|
|
5077
|
-
F:
|
|
5078
|
-
L:
|
|
5207
|
+
F: __dxlog_file18,
|
|
5208
|
+
L: 381,
|
|
5079
5209
|
S: this,
|
|
5080
5210
|
C: (f, a) => f(...a)
|
|
5081
5211
|
});
|
|
@@ -5106,17 +5236,17 @@ var DataSpaceManager = class {
|
|
|
5106
5236
|
return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
5107
5237
|
});
|
|
5108
5238
|
sessionsToClose.forEach((session) => {
|
|
5109
|
-
void session.close().catch(
|
|
5239
|
+
void session.close().catch(log15.error);
|
|
5110
5240
|
});
|
|
5111
5241
|
closedSessions += sessionsToClose.length;
|
|
5112
5242
|
}
|
|
5113
|
-
|
|
5243
|
+
log15("processed member role changes", {
|
|
5114
5244
|
roleChangeCount: memberInfo.length,
|
|
5115
5245
|
peersOnline: presence.getPeersOnline().length,
|
|
5116
5246
|
closedSessions
|
|
5117
5247
|
}, {
|
|
5118
|
-
F:
|
|
5119
|
-
L:
|
|
5248
|
+
F: __dxlog_file18,
|
|
5249
|
+
L: 417,
|
|
5120
5250
|
S: this,
|
|
5121
5251
|
C: (f, a) => f(...a)
|
|
5122
5252
|
});
|
|
@@ -5127,15 +5257,15 @@ var DataSpaceManager = class {
|
|
|
5127
5257
|
if (role === SpaceMember6.Role.REMOVED) {
|
|
5128
5258
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5129
5259
|
if (session != null) {
|
|
5130
|
-
|
|
5260
|
+
log15("closing a session with a removed peer", {
|
|
5131
5261
|
peerId: peerState.peerId
|
|
5132
5262
|
}, {
|
|
5133
|
-
F:
|
|
5134
|
-
L:
|
|
5263
|
+
F: __dxlog_file18,
|
|
5264
|
+
L: 431,
|
|
5135
5265
|
S: this,
|
|
5136
5266
|
C: (f, a) => f(...a)
|
|
5137
5267
|
});
|
|
5138
|
-
void session.close().catch(
|
|
5268
|
+
void session.close().catch(log15.error);
|
|
5139
5269
|
}
|
|
5140
5270
|
}
|
|
5141
5271
|
}
|
|
@@ -5198,11 +5328,11 @@ import { createAdmissionCredentials as createAdmissionCredentials2, getCredentia
|
|
|
5198
5328
|
import { raise as raise2 } from "@dxos/debug";
|
|
5199
5329
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
5200
5330
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
5201
|
-
import { log as
|
|
5331
|
+
import { log as log16 } from "@dxos/log";
|
|
5202
5332
|
import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
|
|
5203
5333
|
import { SpaceMember as SpaceMember7, SpaceState as SpaceState4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5204
5334
|
import { trace as trace8 } from "@dxos/tracing";
|
|
5205
|
-
var
|
|
5335
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5206
5336
|
var SpacesServiceImpl = class {
|
|
5207
5337
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5208
5338
|
this._identityManager = _identityManager;
|
|
@@ -5246,8 +5376,8 @@ var SpacesServiceImpl = class {
|
|
|
5246
5376
|
}
|
|
5247
5377
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5248
5378
|
invariant15(credentials[0].credential, void 0, {
|
|
5249
|
-
F:
|
|
5250
|
-
L:
|
|
5379
|
+
F: __dxlog_file19,
|
|
5380
|
+
L: 98,
|
|
5251
5381
|
S: this,
|
|
5252
5382
|
A: [
|
|
5253
5383
|
"credentials[0].credential",
|
|
@@ -5256,8 +5386,8 @@ var SpacesServiceImpl = class {
|
|
|
5256
5386
|
});
|
|
5257
5387
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5258
5388
|
invariant15(getCredentialAssertion4(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5259
|
-
F:
|
|
5260
|
-
L:
|
|
5389
|
+
F: __dxlog_file19,
|
|
5390
|
+
L: 100,
|
|
5261
5391
|
S: this,
|
|
5262
5392
|
A: [
|
|
5263
5393
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5271,11 +5401,11 @@ var SpacesServiceImpl = class {
|
|
|
5271
5401
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
5272
5402
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5273
5403
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5274
|
-
|
|
5404
|
+
log16("update", {
|
|
5275
5405
|
spaces
|
|
5276
5406
|
}, {
|
|
5277
|
-
F:
|
|
5278
|
-
L:
|
|
5407
|
+
F: __dxlog_file19,
|
|
5408
|
+
L: 111,
|
|
5279
5409
|
S: this,
|
|
5280
5410
|
C: (f, a) => f(...a)
|
|
5281
5411
|
});
|
|
@@ -5358,8 +5488,8 @@ var SpacesServiceImpl = class {
|
|
|
5358
5488
|
});
|
|
5359
5489
|
} else {
|
|
5360
5490
|
invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5361
|
-
F:
|
|
5362
|
-
L:
|
|
5491
|
+
F: __dxlog_file19,
|
|
5492
|
+
L: 199,
|
|
5363
5493
|
S: this,
|
|
5364
5494
|
A: [
|
|
5365
5495
|
"!credential.id",
|
|
@@ -5367,8 +5497,8 @@ var SpacesServiceImpl = class {
|
|
|
5367
5497
|
]
|
|
5368
5498
|
});
|
|
5369
5499
|
invariant15(this._identityManager.identity, "Identity is not available", {
|
|
5370
|
-
F:
|
|
5371
|
-
L:
|
|
5500
|
+
F: __dxlog_file19,
|
|
5501
|
+
L: 200,
|
|
5372
5502
|
S: this,
|
|
5373
5503
|
A: [
|
|
5374
5504
|
"this._identityManager.identity",
|
|
@@ -5377,8 +5507,8 @@ var SpacesServiceImpl = class {
|
|
|
5377
5507
|
});
|
|
5378
5508
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5379
5509
|
invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5380
|
-
F:
|
|
5381
|
-
L:
|
|
5510
|
+
F: __dxlog_file19,
|
|
5511
|
+
L: 202,
|
|
5382
5512
|
S: this,
|
|
5383
5513
|
A: [
|
|
5384
5514
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5400,10 +5530,13 @@ var SpacesServiceImpl = class {
|
|
|
5400
5530
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5401
5531
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5402
5532
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError2(spaceKey));
|
|
5403
|
-
await space.createEpoch({
|
|
5533
|
+
const credential = await space.createEpoch({
|
|
5404
5534
|
migration,
|
|
5405
5535
|
newAutomergeRoot: automergeRootUrl
|
|
5406
5536
|
});
|
|
5537
|
+
return {
|
|
5538
|
+
epochCredential: credential ?? void 0
|
|
5539
|
+
};
|
|
5407
5540
|
}
|
|
5408
5541
|
_serializeSpace(space) {
|
|
5409
5542
|
return {
|
|
@@ -5467,7 +5600,7 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
5467
5600
|
|
|
5468
5601
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
5469
5602
|
import { Trigger as Trigger7 } from "@dxos/async";
|
|
5470
|
-
import { Context as Context10, Resource as
|
|
5603
|
+
import { Context as Context10, Resource as Resource3 } from "@dxos/context";
|
|
5471
5604
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
5472
5605
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
5473
5606
|
import { EchoHost } from "@dxos/echo-db";
|
|
@@ -5476,7 +5609,7 @@ import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
|
5476
5609
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5477
5610
|
import { Keyring } from "@dxos/keyring";
|
|
5478
5611
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
5479
|
-
import { log as
|
|
5612
|
+
import { log as log17 } from "@dxos/log";
|
|
5480
5613
|
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
|
|
5481
5614
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5482
5615
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
@@ -5492,8 +5625,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5492
5625
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5493
5626
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5494
5627
|
}
|
|
5495
|
-
var
|
|
5496
|
-
var ServiceContext = class extends
|
|
5628
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5629
|
+
var ServiceContext = class extends Resource3 {
|
|
5497
5630
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5498
5631
|
super();
|
|
5499
5632
|
this.storage = storage;
|
|
@@ -5527,8 +5660,7 @@ var ServiceContext = class extends Resource2 {
|
|
|
5527
5660
|
});
|
|
5528
5661
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5529
5662
|
this.echoHost = new EchoHost({
|
|
5530
|
-
kv: this.level
|
|
5531
|
-
storage: this.storage
|
|
5663
|
+
kv: this.level
|
|
5532
5664
|
});
|
|
5533
5665
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5534
5666
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
@@ -5536,17 +5668,17 @@ var ServiceContext = class extends Resource2 {
|
|
|
5536
5668
|
}
|
|
5537
5669
|
async _open(ctx) {
|
|
5538
5670
|
await this._checkStorageVersion();
|
|
5539
|
-
|
|
5540
|
-
F:
|
|
5541
|
-
L:
|
|
5671
|
+
log17("opening...", void 0, {
|
|
5672
|
+
F: __dxlog_file20,
|
|
5673
|
+
L: 149,
|
|
5542
5674
|
S: this,
|
|
5543
5675
|
C: (f, a) => f(...a)
|
|
5544
5676
|
});
|
|
5545
|
-
|
|
5677
|
+
log17.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
5546
5678
|
id: this._instanceId
|
|
5547
5679
|
}), {
|
|
5548
|
-
F:
|
|
5549
|
-
L:
|
|
5680
|
+
F: __dxlog_file20,
|
|
5681
|
+
L: 150,
|
|
5550
5682
|
S: this,
|
|
5551
5683
|
C: (f, a) => f(...a)
|
|
5552
5684
|
});
|
|
@@ -5560,33 +5692,33 @@ var ServiceContext = class extends Resource2 {
|
|
|
5560
5692
|
await this._initialize(ctx);
|
|
5561
5693
|
}
|
|
5562
5694
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5563
|
-
|
|
5695
|
+
log17("loaded persistent invitations", {
|
|
5564
5696
|
count: loadedInvitations.invitations?.length
|
|
5565
5697
|
}, {
|
|
5566
|
-
F:
|
|
5567
|
-
L:
|
|
5698
|
+
F: __dxlog_file20,
|
|
5699
|
+
L: 163,
|
|
5568
5700
|
S: this,
|
|
5569
5701
|
C: (f, a) => f(...a)
|
|
5570
5702
|
});
|
|
5571
|
-
|
|
5703
|
+
log17.trace("dxos.sdk.service-context.open", trace9.end({
|
|
5572
5704
|
id: this._instanceId
|
|
5573
5705
|
}), {
|
|
5574
|
-
F:
|
|
5575
|
-
L:
|
|
5706
|
+
F: __dxlog_file20,
|
|
5707
|
+
L: 165,
|
|
5576
5708
|
S: this,
|
|
5577
5709
|
C: (f, a) => f(...a)
|
|
5578
5710
|
});
|
|
5579
|
-
|
|
5580
|
-
F:
|
|
5581
|
-
L:
|
|
5711
|
+
log17("opened", void 0, {
|
|
5712
|
+
F: __dxlog_file20,
|
|
5713
|
+
L: 166,
|
|
5582
5714
|
S: this,
|
|
5583
5715
|
C: (f, a) => f(...a)
|
|
5584
5716
|
});
|
|
5585
5717
|
}
|
|
5586
5718
|
async _close(ctx) {
|
|
5587
|
-
|
|
5588
|
-
F:
|
|
5589
|
-
L:
|
|
5719
|
+
log17("closing...", void 0, {
|
|
5720
|
+
F: __dxlog_file20,
|
|
5721
|
+
L: 170,
|
|
5590
5722
|
S: this,
|
|
5591
5723
|
C: (f, a) => f(...a)
|
|
5592
5724
|
});
|
|
@@ -5601,9 +5733,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5601
5733
|
await this.echoHost.close(ctx);
|
|
5602
5734
|
await this.networkManager.close();
|
|
5603
5735
|
await this.signalManager.close();
|
|
5604
|
-
|
|
5605
|
-
F:
|
|
5606
|
-
L:
|
|
5736
|
+
log17("closed", void 0, {
|
|
5737
|
+
F: __dxlog_file20,
|
|
5738
|
+
L: 182,
|
|
5607
5739
|
S: this,
|
|
5608
5740
|
C: (f, a) => f(...a)
|
|
5609
5741
|
});
|
|
@@ -5616,8 +5748,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5616
5748
|
getInvitationHandler(invitation) {
|
|
5617
5749
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5618
5750
|
invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5619
|
-
F:
|
|
5620
|
-
L:
|
|
5751
|
+
F: __dxlog_file20,
|
|
5752
|
+
L: 193,
|
|
5621
5753
|
S: this,
|
|
5622
5754
|
A: [
|
|
5623
5755
|
"factory",
|
|
@@ -5647,9 +5779,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5647
5779
|
}
|
|
5648
5780
|
// Called when identity is created.
|
|
5649
5781
|
async _initialize(ctx) {
|
|
5650
|
-
|
|
5651
|
-
F:
|
|
5652
|
-
L:
|
|
5782
|
+
log17("initializing spaces...", void 0, {
|
|
5783
|
+
F: __dxlog_file20,
|
|
5784
|
+
L: 224,
|
|
5653
5785
|
S: this,
|
|
5654
5786
|
C: (f, a) => f(...a)
|
|
5655
5787
|
});
|
|
@@ -5671,8 +5803,8 @@ var ServiceContext = class extends Resource2 {
|
|
|
5671
5803
|
await this.dataSpaceManager.open();
|
|
5672
5804
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
5673
5805
|
invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5674
|
-
F:
|
|
5675
|
-
L:
|
|
5806
|
+
F: __dxlog_file20,
|
|
5807
|
+
L: 249,
|
|
5676
5808
|
S: this,
|
|
5677
5809
|
A: [
|
|
5678
5810
|
"this.dataSpaceManager",
|
|
@@ -5692,33 +5824,33 @@ var ServiceContext = class extends Resource2 {
|
|
|
5692
5824
|
return;
|
|
5693
5825
|
}
|
|
5694
5826
|
if (!this.dataSpaceManager) {
|
|
5695
|
-
|
|
5827
|
+
log17("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5696
5828
|
details: assertion
|
|
5697
5829
|
}, {
|
|
5698
|
-
F:
|
|
5699
|
-
L:
|
|
5830
|
+
F: __dxlog_file20,
|
|
5831
|
+
L: 265,
|
|
5700
5832
|
S: this,
|
|
5701
5833
|
C: (f, a) => f(...a)
|
|
5702
5834
|
});
|
|
5703
5835
|
return;
|
|
5704
5836
|
}
|
|
5705
5837
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5706
|
-
|
|
5838
|
+
log17("space already exists, ignoring space admission", {
|
|
5707
5839
|
details: assertion
|
|
5708
5840
|
}, {
|
|
5709
|
-
F:
|
|
5710
|
-
L:
|
|
5841
|
+
F: __dxlog_file20,
|
|
5842
|
+
L: 269,
|
|
5711
5843
|
S: this,
|
|
5712
5844
|
C: (f, a) => f(...a)
|
|
5713
5845
|
});
|
|
5714
5846
|
return;
|
|
5715
5847
|
}
|
|
5716
5848
|
try {
|
|
5717
|
-
|
|
5849
|
+
log17("accepting space recorded in halo", {
|
|
5718
5850
|
details: assertion
|
|
5719
5851
|
}, {
|
|
5720
|
-
F:
|
|
5721
|
-
L:
|
|
5852
|
+
F: __dxlog_file20,
|
|
5853
|
+
L: 274,
|
|
5722
5854
|
S: this,
|
|
5723
5855
|
C: (f, a) => f(...a)
|
|
5724
5856
|
});
|
|
@@ -5727,9 +5859,9 @@ var ServiceContext = class extends Resource2 {
|
|
|
5727
5859
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5728
5860
|
});
|
|
5729
5861
|
} catch (err) {
|
|
5730
|
-
|
|
5731
|
-
F:
|
|
5732
|
-
L:
|
|
5862
|
+
log17.catch(err, void 0, {
|
|
5863
|
+
F: __dxlog_file20,
|
|
5864
|
+
L: 280,
|
|
5733
5865
|
S: this,
|
|
5734
5866
|
C: (f, a) => f(...a)
|
|
5735
5867
|
});
|
|
@@ -5777,7 +5909,7 @@ var ServiceRegistry = class {
|
|
|
5777
5909
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
5778
5910
|
import { asyncTimeout as asyncTimeout3, Trigger as Trigger8 } from "@dxos/async";
|
|
5779
5911
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
5780
|
-
import { log as
|
|
5912
|
+
import { log as log18, logInfo } from "@dxos/log";
|
|
5781
5913
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
5782
5914
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5783
5915
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -5788,7 +5920,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5788
5920
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5789
5921
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5790
5922
|
}
|
|
5791
|
-
var
|
|
5923
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
5792
5924
|
var Message;
|
|
5793
5925
|
(function(Message2) {
|
|
5794
5926
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -5810,29 +5942,29 @@ var Lock = class {
|
|
|
5810
5942
|
message: "acquiring"
|
|
5811
5943
|
});
|
|
5812
5944
|
try {
|
|
5813
|
-
|
|
5814
|
-
F:
|
|
5945
|
+
log18("aquiring lock...", void 0, {
|
|
5946
|
+
F: __dxlog_file21,
|
|
5815
5947
|
L: 42,
|
|
5816
5948
|
S: this,
|
|
5817
5949
|
C: (f, a) => f(...a)
|
|
5818
5950
|
});
|
|
5819
5951
|
await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
5820
|
-
|
|
5821
|
-
F:
|
|
5952
|
+
log18("acquired lock", void 0, {
|
|
5953
|
+
F: __dxlog_file21,
|
|
5822
5954
|
L: 44,
|
|
5823
5955
|
S: this,
|
|
5824
5956
|
C: (f, a) => f(...a)
|
|
5825
5957
|
});
|
|
5826
5958
|
} catch {
|
|
5827
|
-
|
|
5828
|
-
F:
|
|
5959
|
+
log18("stealing lock...", void 0, {
|
|
5960
|
+
F: __dxlog_file21,
|
|
5829
5961
|
L: 46,
|
|
5830
5962
|
S: this,
|
|
5831
5963
|
C: (f, a) => f(...a)
|
|
5832
5964
|
});
|
|
5833
5965
|
await this._requestLock(true);
|
|
5834
|
-
|
|
5835
|
-
F:
|
|
5966
|
+
log18("stolen lock", void 0, {
|
|
5967
|
+
F: __dxlog_file21,
|
|
5836
5968
|
L: 48,
|
|
5837
5969
|
S: this,
|
|
5838
5970
|
C: (f, a) => f(...a)
|
|
@@ -5848,10 +5980,10 @@ var Lock = class {
|
|
|
5848
5980
|
}
|
|
5849
5981
|
}
|
|
5850
5982
|
async _requestLock(steal = false) {
|
|
5851
|
-
|
|
5983
|
+
log18("requesting lock...", {
|
|
5852
5984
|
steal
|
|
5853
5985
|
}, {
|
|
5854
|
-
F:
|
|
5986
|
+
F: __dxlog_file21,
|
|
5855
5987
|
L: 63,
|
|
5856
5988
|
S: this,
|
|
5857
5989
|
C: (f, a) => f(...a)
|
|
@@ -5864,15 +5996,15 @@ var Lock = class {
|
|
|
5864
5996
|
acquired.wake();
|
|
5865
5997
|
this._releaseTrigger = new Trigger8();
|
|
5866
5998
|
await this._releaseTrigger.wait();
|
|
5867
|
-
|
|
5868
|
-
F:
|
|
5999
|
+
log18("releasing lock...", void 0, {
|
|
6000
|
+
F: __dxlog_file21,
|
|
5869
6001
|
L: 72,
|
|
5870
6002
|
S: this,
|
|
5871
6003
|
C: (f, a) => f(...a)
|
|
5872
6004
|
});
|
|
5873
6005
|
await this._onRelease?.();
|
|
5874
|
-
|
|
5875
|
-
F:
|
|
6006
|
+
log18("released lock", void 0, {
|
|
6007
|
+
F: __dxlog_file21,
|
|
5876
6008
|
L: 74,
|
|
5877
6009
|
S: this,
|
|
5878
6010
|
C: (f, a) => f(...a)
|
|
@@ -5881,10 +6013,10 @@ var Lock = class {
|
|
|
5881
6013
|
await this._onRelease?.();
|
|
5882
6014
|
});
|
|
5883
6015
|
await acquired.wait();
|
|
5884
|
-
|
|
6016
|
+
log18("recieved lock", {
|
|
5885
6017
|
steal
|
|
5886
6018
|
}, {
|
|
5887
|
-
F:
|
|
6019
|
+
F: __dxlog_file21,
|
|
5888
6020
|
L: 81,
|
|
5889
6021
|
S: this,
|
|
5890
6022
|
C: (f, a) => f(...a)
|
|
@@ -5978,7 +6110,7 @@ import { clientServiceBundle } from "@dxos/client-protocol";
|
|
|
5978
6110
|
import { Context as Context11 } from "@dxos/context";
|
|
5979
6111
|
import { invariant as invariant18 } from "@dxos/invariant";
|
|
5980
6112
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
5981
|
-
import { log as
|
|
6113
|
+
import { log as log20 } from "@dxos/log";
|
|
5982
6114
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
5983
6115
|
import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
|
|
5984
6116
|
import { trace as trace10 } from "@dxos/protocols";
|
|
@@ -5991,7 +6123,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
|
5991
6123
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
5992
6124
|
import { invariant as invariant17 } from "@dxos/invariant";
|
|
5993
6125
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
5994
|
-
var
|
|
6126
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5995
6127
|
var DevicesServiceImpl = class {
|
|
5996
6128
|
constructor(_identityManager) {
|
|
5997
6129
|
this._identityManager = _identityManager;
|
|
@@ -6009,7 +6141,7 @@ var DevicesServiceImpl = class {
|
|
|
6009
6141
|
});
|
|
6010
6142
|
} else {
|
|
6011
6143
|
invariant17(this._identityManager.identity?.presence, "presence not present", {
|
|
6012
|
-
F:
|
|
6144
|
+
F: __dxlog_file22,
|
|
6013
6145
|
L: 32,
|
|
6014
6146
|
S: this,
|
|
6015
6147
|
A: [
|
|
@@ -6119,7 +6251,7 @@ var findConfigs = () => {
|
|
|
6119
6251
|
import { Event as Event8 } from "@dxos/async";
|
|
6120
6252
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
6121
6253
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
6122
|
-
import { getContextFromEntry, log as
|
|
6254
|
+
import { getContextFromEntry, log as log19 } from "@dxos/log";
|
|
6123
6255
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
6124
6256
|
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
6125
6257
|
var LoggingServiceImpl = class {
|
|
@@ -6132,11 +6264,11 @@ var LoggingServiceImpl = class {
|
|
|
6132
6264
|
};
|
|
6133
6265
|
}
|
|
6134
6266
|
async open() {
|
|
6135
|
-
|
|
6267
|
+
log19.runtimeConfig.processors.push(this._logProcessor);
|
|
6136
6268
|
}
|
|
6137
6269
|
async close() {
|
|
6138
|
-
const index =
|
|
6139
|
-
|
|
6270
|
+
const index = log19.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6271
|
+
log19.runtimeConfig.processors.splice(index, 1);
|
|
6140
6272
|
}
|
|
6141
6273
|
async controlMetrics({ reset, record }) {
|
|
6142
6274
|
if (reset) {
|
|
@@ -6340,7 +6472,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6340
6472
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6341
6473
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6342
6474
|
}
|
|
6343
|
-
var
|
|
6475
|
+
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6344
6476
|
var ClientServicesHost = class {
|
|
6345
6477
|
constructor({
|
|
6346
6478
|
config,
|
|
@@ -6429,7 +6561,7 @@ var ClientServicesHost = class {
|
|
|
6429
6561
|
*/
|
|
6430
6562
|
initialize({ config, ...options }) {
|
|
6431
6563
|
invariant18(!this._open, "service host is open", {
|
|
6432
|
-
F:
|
|
6564
|
+
F: __dxlog_file23,
|
|
6433
6565
|
L: 186,
|
|
6434
6566
|
S: this,
|
|
6435
6567
|
A: [
|
|
@@ -6437,15 +6569,15 @@ var ClientServicesHost = class {
|
|
|
6437
6569
|
"'service host is open'"
|
|
6438
6570
|
]
|
|
6439
6571
|
});
|
|
6440
|
-
|
|
6441
|
-
F:
|
|
6572
|
+
log20("initializing...", void 0, {
|
|
6573
|
+
F: __dxlog_file23,
|
|
6442
6574
|
L: 187,
|
|
6443
6575
|
S: this,
|
|
6444
6576
|
C: (f, a) => f(...a)
|
|
6445
6577
|
});
|
|
6446
6578
|
if (config) {
|
|
6447
6579
|
invariant18(!this._config, "config already set", {
|
|
6448
|
-
F:
|
|
6580
|
+
F: __dxlog_file23,
|
|
6449
6581
|
L: 190,
|
|
6450
6582
|
S: this,
|
|
6451
6583
|
A: [
|
|
@@ -6459,8 +6591,8 @@ var ClientServicesHost = class {
|
|
|
6459
6591
|
}
|
|
6460
6592
|
}
|
|
6461
6593
|
if (!options.signalManager) {
|
|
6462
|
-
|
|
6463
|
-
F:
|
|
6594
|
+
log20.warn("running signaling without telemetry metadata.", void 0, {
|
|
6595
|
+
F: __dxlog_file23,
|
|
6464
6596
|
L: 198,
|
|
6465
6597
|
S: this,
|
|
6466
6598
|
C: (f, a) => f(...a)
|
|
@@ -6471,7 +6603,7 @@ var ClientServicesHost = class {
|
|
|
6471
6603
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6472
6604
|
this._signalManager = signalManager;
|
|
6473
6605
|
invariant18(!this._networkManager, "network manager already set", {
|
|
6474
|
-
F:
|
|
6606
|
+
F: __dxlog_file23,
|
|
6475
6607
|
L: 209,
|
|
6476
6608
|
S: this,
|
|
6477
6609
|
A: [
|
|
@@ -6484,8 +6616,8 @@ var ClientServicesHost = class {
|
|
|
6484
6616
|
transportFactory,
|
|
6485
6617
|
signalManager
|
|
6486
6618
|
});
|
|
6487
|
-
|
|
6488
|
-
F:
|
|
6619
|
+
log20("initialized", void 0, {
|
|
6620
|
+
F: __dxlog_file23,
|
|
6489
6621
|
L: 216,
|
|
6490
6622
|
S: this,
|
|
6491
6623
|
C: (f, a) => f(...a)
|
|
@@ -6496,16 +6628,16 @@ var ClientServicesHost = class {
|
|
|
6496
6628
|
return;
|
|
6497
6629
|
}
|
|
6498
6630
|
const traceId = PublicKey16.random().toHex();
|
|
6499
|
-
|
|
6631
|
+
log20.trace("dxos.client-services.host.open", trace10.begin({
|
|
6500
6632
|
id: traceId
|
|
6501
6633
|
}), {
|
|
6502
|
-
F:
|
|
6634
|
+
F: __dxlog_file23,
|
|
6503
6635
|
L: 227,
|
|
6504
6636
|
S: this,
|
|
6505
6637
|
C: (f, a) => f(...a)
|
|
6506
6638
|
});
|
|
6507
6639
|
invariant18(this._config, "config not set", {
|
|
6508
|
-
F:
|
|
6640
|
+
F: __dxlog_file23,
|
|
6509
6641
|
L: 229,
|
|
6510
6642
|
S: this,
|
|
6511
6643
|
A: [
|
|
@@ -6514,7 +6646,7 @@ var ClientServicesHost = class {
|
|
|
6514
6646
|
]
|
|
6515
6647
|
});
|
|
6516
6648
|
invariant18(this._storage, "storage not set", {
|
|
6517
|
-
F:
|
|
6649
|
+
F: __dxlog_file23,
|
|
6518
6650
|
L: 230,
|
|
6519
6651
|
S: this,
|
|
6520
6652
|
A: [
|
|
@@ -6523,7 +6655,7 @@ var ClientServicesHost = class {
|
|
|
6523
6655
|
]
|
|
6524
6656
|
});
|
|
6525
6657
|
invariant18(this._signalManager, "signal manager not set", {
|
|
6526
|
-
F:
|
|
6658
|
+
F: __dxlog_file23,
|
|
6527
6659
|
L: 231,
|
|
6528
6660
|
S: this,
|
|
6529
6661
|
A: [
|
|
@@ -6532,7 +6664,7 @@ var ClientServicesHost = class {
|
|
|
6532
6664
|
]
|
|
6533
6665
|
});
|
|
6534
6666
|
invariant18(this._networkManager, "network manager not set", {
|
|
6535
|
-
F:
|
|
6667
|
+
F: __dxlog_file23,
|
|
6536
6668
|
L: 232,
|
|
6537
6669
|
S: this,
|
|
6538
6670
|
A: [
|
|
@@ -6541,10 +6673,10 @@ var ClientServicesHost = class {
|
|
|
6541
6673
|
]
|
|
6542
6674
|
});
|
|
6543
6675
|
this._opening = true;
|
|
6544
|
-
|
|
6676
|
+
log20("opening...", {
|
|
6545
6677
|
lockKey: this._resourceLock?.lockKey
|
|
6546
6678
|
}, {
|
|
6547
|
-
F:
|
|
6679
|
+
F: __dxlog_file23,
|
|
6548
6680
|
L: 235,
|
|
6549
6681
|
S: this,
|
|
6550
6682
|
C: (f, a) => f(...a)
|
|
@@ -6595,18 +6727,18 @@ var ClientServicesHost = class {
|
|
|
6595
6727
|
this._open = true;
|
|
6596
6728
|
this._statusUpdate.emit();
|
|
6597
6729
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6598
|
-
|
|
6730
|
+
log20("opened", {
|
|
6599
6731
|
deviceKey
|
|
6600
6732
|
}, {
|
|
6601
|
-
F:
|
|
6733
|
+
F: __dxlog_file23,
|
|
6602
6734
|
L: 314,
|
|
6603
6735
|
S: this,
|
|
6604
6736
|
C: (f, a) => f(...a)
|
|
6605
6737
|
});
|
|
6606
|
-
|
|
6738
|
+
log20.trace("dxos.client-services.host.open", trace10.end({
|
|
6607
6739
|
id: traceId
|
|
6608
6740
|
}), {
|
|
6609
|
-
F:
|
|
6741
|
+
F: __dxlog_file23,
|
|
6610
6742
|
L: 315,
|
|
6611
6743
|
S: this,
|
|
6612
6744
|
C: (f, a) => f(...a)
|
|
@@ -6617,10 +6749,10 @@ var ClientServicesHost = class {
|
|
|
6617
6749
|
return;
|
|
6618
6750
|
}
|
|
6619
6751
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6620
|
-
|
|
6752
|
+
log20("closing...", {
|
|
6621
6753
|
deviceKey
|
|
6622
6754
|
}, {
|
|
6623
|
-
F:
|
|
6755
|
+
F: __dxlog_file23,
|
|
6624
6756
|
L: 326,
|
|
6625
6757
|
S: this,
|
|
6626
6758
|
C: (f, a) => f(...a)
|
|
@@ -6635,10 +6767,10 @@ var ClientServicesHost = class {
|
|
|
6635
6767
|
await this._level?.close();
|
|
6636
6768
|
this._open = false;
|
|
6637
6769
|
this._statusUpdate.emit();
|
|
6638
|
-
|
|
6770
|
+
log20("closed", {
|
|
6639
6771
|
deviceKey
|
|
6640
6772
|
}, {
|
|
6641
|
-
F:
|
|
6773
|
+
F: __dxlog_file23,
|
|
6642
6774
|
L: 335,
|
|
6643
6775
|
S: this,
|
|
6644
6776
|
C: (f, a) => f(...a)
|
|
@@ -6646,32 +6778,32 @@ var ClientServicesHost = class {
|
|
|
6646
6778
|
}
|
|
6647
6779
|
async reset() {
|
|
6648
6780
|
const traceId = PublicKey16.random().toHex();
|
|
6649
|
-
|
|
6781
|
+
log20.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
6650
6782
|
id: traceId
|
|
6651
6783
|
}), {
|
|
6652
|
-
F:
|
|
6784
|
+
F: __dxlog_file23,
|
|
6653
6785
|
L: 340,
|
|
6654
6786
|
S: this,
|
|
6655
6787
|
C: (f, a) => f(...a)
|
|
6656
6788
|
});
|
|
6657
|
-
|
|
6658
|
-
F:
|
|
6789
|
+
log20.info("resetting...", void 0, {
|
|
6790
|
+
F: __dxlog_file23,
|
|
6659
6791
|
L: 342,
|
|
6660
6792
|
S: this,
|
|
6661
6793
|
C: (f, a) => f(...a)
|
|
6662
6794
|
});
|
|
6663
6795
|
await this._serviceContext?.close();
|
|
6664
6796
|
await this._storage.reset();
|
|
6665
|
-
|
|
6666
|
-
F:
|
|
6797
|
+
log20.info("reset", void 0, {
|
|
6798
|
+
F: __dxlog_file23,
|
|
6667
6799
|
L: 345,
|
|
6668
6800
|
S: this,
|
|
6669
6801
|
C: (f, a) => f(...a)
|
|
6670
6802
|
});
|
|
6671
|
-
|
|
6803
|
+
log20.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
6672
6804
|
id: traceId
|
|
6673
6805
|
}), {
|
|
6674
|
-
F:
|
|
6806
|
+
F: __dxlog_file23,
|
|
6675
6807
|
L: 346,
|
|
6676
6808
|
S: this,
|
|
6677
6809
|
C: (f, a) => f(...a)
|
|
@@ -6730,7 +6862,6 @@ export {
|
|
|
6730
6862
|
SpaceInvitationProtocol,
|
|
6731
6863
|
InvitationsManager,
|
|
6732
6864
|
DataSpace,
|
|
6733
|
-
findPropertiesObject,
|
|
6734
6865
|
DataSpaceManager,
|
|
6735
6866
|
SpacesServiceImpl,
|
|
6736
6867
|
ServiceContext,
|
|
@@ -6743,4 +6874,4 @@ export {
|
|
|
6743
6874
|
ClientServicesProviderResource,
|
|
6744
6875
|
DiagnosticsCollector
|
|
6745
6876
|
};
|
|
6746
|
-
//# sourceMappingURL=chunk-
|
|
6877
|
+
//# sourceMappingURL=chunk-GCU4DHSQ.mjs.map
|