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