@fluidframework/tree 2.21.0 → 2.22.1
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/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/api-report/tree.alpha.api.md +29 -4
- package/api-report/tree.beta.api.md +29 -4
- package/api-report/tree.legacy.alpha.api.md +29 -4
- package/api-report/tree.legacy.public.api.md +29 -4
- package/api-report/tree.public.api.md +29 -4
- package/dist/alpha.d.ts +1 -0
- package/dist/beta.d.ts +1 -0
- package/dist/core/forest/editableForest.js +1 -1
- package/dist/core/forest/editableForest.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +2 -5
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +1 -151
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -2
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/pathTree.d.ts +0 -11
- package/dist/core/tree/pathTree.d.ts.map +1 -1
- package/dist/core/tree/pathTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
- package/dist/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/treeEvents.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +0 -9
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -19
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +11 -12
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +7 -3
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -11
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -0
- package/dist/shared-tree/index.d.ts +1 -3
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +1 -7
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +4 -5
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +9 -10
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +39 -39
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +81 -52
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +2 -2
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js +9 -3
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +3 -3
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +3 -2
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.js +1 -1
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +1 -2
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +0 -9
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts +12 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js +25 -7
- package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +25 -30
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +20 -49
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +156 -63
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +179 -86
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -0
- package/dist/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +23 -2
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +2 -2
- package/dist/simple-tree/schemaTypes.js +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +1 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/treeFactory.d.ts +16 -5
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +21 -12
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts +1 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/rangeMap.d.ts +1 -1
- package/dist/util/rangeMap.js +1 -1
- package/dist/util/rangeMap.js.map +1 -1
- package/lib/alpha.d.ts +1 -0
- package/lib/beta.d.ts +1 -0
- package/lib/core/forest/editableForest.js +1 -1
- package/lib/core/forest/editableForest.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +2 -5
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +1 -151
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -2
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/pathTree.d.ts +0 -11
- package/lib/core/tree/pathTree.d.ts.map +1 -1
- package/lib/core/tree/pathTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
- package/lib/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/treeEvents.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +0 -9
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -19
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +11 -12
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +7 -3
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -11
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -0
- package/lib/shared-tree/index.d.ts +1 -3
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -3
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -5
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +4 -5
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +39 -39
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +79 -50
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +2 -2
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js +8 -2
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +3 -3
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +4 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.js +2 -2
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +1 -2
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +0 -9
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts +12 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js +23 -5
- package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +25 -30
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +19 -48
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +156 -63
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +178 -85
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -0
- package/lib/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +23 -2
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +2 -2
- package/lib/simple-tree/schemaTypes.js +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +1 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/treeFactory.d.ts +16 -5
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +20 -11
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts +1 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/rangeMap.d.ts +1 -1
- package/lib/util/rangeMap.js +1 -1
- package/lib/util/rangeMap.js.map +1 -1
- package/package.json +21 -21
- package/src/core/forest/editableForest.ts +1 -1
- package/src/core/index.ts +0 -3
- package/src/core/tree/anchorSet.ts +4 -197
- package/src/core/tree/index.ts +0 -3
- package/src/core/tree/pathTree.ts +0 -13
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +0 -11
- package/src/feature-libraries/flex-tree/treeEvents.ts +2 -4
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +0 -11
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +6 -2
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -35
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +9 -42
- package/src/feature-libraries/optional-field/optionalField.ts +10 -3
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -16
- package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +13 -2
- package/src/index.ts +15 -12
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +3 -19
- package/src/shared-tree/schematizingTreeView.ts +18 -16
- package/src/shared-tree/sharedTree.ts +203 -100
- package/src/shared-tree/treeApi.ts +10 -1
- package/src/shared-tree/treeCheckout.ts +11 -8
- package/src/shared-tree-core/editManager.ts +2 -2
- package/src/shared-tree-core/editManagerSummarizer.ts +0 -11
- package/src/shared-tree-core/sequenceIdUtils.ts +26 -5
- package/src/shared-tree-core/sharedTreeCore.ts +30 -87
- package/src/simple-tree/api/index.ts +15 -0
- package/src/simple-tree/api/schemaFactory.ts +203 -89
- package/src/{shared-tree → simple-tree/api}/transactionTypes.ts +1 -1
- package/src/simple-tree/api/tree.ts +31 -6
- package/src/simple-tree/index.ts +12 -0
- package/src/simple-tree/schemaTypes.ts +2 -2
- package/src/treeFactory.ts +29 -11
- package/src/util/breakable.ts +1 -1
- package/src/util/rangeMap.ts +1 -1
- package/dist/core/tree/visitPath.d.ts +0 -101
- package/dist/core/tree/visitPath.d.ts.map +0 -1
- package/dist/core/tree/visitPath.js +0 -7
- package/dist/core/tree/visitPath.js.map +0 -1
- package/dist/shared-tree/publicContracts.d.ts +0 -18
- package/dist/shared-tree/publicContracts.d.ts.map +0 -1
- package/dist/shared-tree/publicContracts.js +0 -24
- package/dist/shared-tree/publicContracts.js.map +0 -1
- package/dist/shared-tree/transactionTypes.d.ts.map +0 -1
- package/lib/core/tree/visitPath.d.ts +0 -101
- package/lib/core/tree/visitPath.d.ts.map +0 -1
- package/lib/core/tree/visitPath.js +0 -6
- package/lib/core/tree/visitPath.js.map +0 -1
- package/lib/shared-tree/publicContracts.d.ts +0 -18
- package/lib/shared-tree/publicContracts.d.ts.map +0 -1
- package/lib/shared-tree/publicContracts.js +0 -21
- package/lib/shared-tree/publicContracts.js.map +0 -1
- package/lib/shared-tree/transactionTypes.d.ts.map +0 -1
- package/src/core/tree/visitPath.ts +0 -124
- package/src/shared-tree/publicContracts.ts +0 -24
- /package/dist/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
- /package/lib/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
|
@@ -4,16 +4,33 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
ErasedType,
|
|
9
|
+
IFluidHandle,
|
|
10
|
+
IFluidLoadable,
|
|
11
|
+
} from "@fluidframework/core-interfaces/internal";
|
|
8
12
|
import type {
|
|
9
13
|
IChannelAttributes,
|
|
10
|
-
IChannelFactory,
|
|
11
14
|
IFluidDataStoreRuntime,
|
|
12
|
-
IChannelServices,
|
|
13
15
|
IChannelStorageService,
|
|
16
|
+
IChannel,
|
|
14
17
|
} from "@fluidframework/datastore-definitions/internal";
|
|
15
|
-
import
|
|
16
|
-
|
|
18
|
+
import {
|
|
19
|
+
SharedObject,
|
|
20
|
+
type IFluidSerializer,
|
|
21
|
+
type ISharedObject,
|
|
22
|
+
} from "@fluidframework/shared-object-base/internal";
|
|
23
|
+
import {
|
|
24
|
+
UsageError,
|
|
25
|
+
type ITelemetryLoggerExt,
|
|
26
|
+
} from "@fluidframework/telemetry-utils/internal";
|
|
27
|
+
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
28
|
+
import type {
|
|
29
|
+
ITelemetryContext,
|
|
30
|
+
IExperimentalIncrementalSummaryContext,
|
|
31
|
+
ISummaryTreeWithStats,
|
|
32
|
+
} from "@fluidframework/runtime-definitions/internal";
|
|
33
|
+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
17
34
|
|
|
18
35
|
import { type ICodecOptions, noopValidator } from "../codec/index.js";
|
|
19
36
|
import {
|
|
@@ -74,6 +91,7 @@ import {
|
|
|
74
91
|
FieldKind,
|
|
75
92
|
type CustomTreeNode,
|
|
76
93
|
type CustomTreeValue,
|
|
94
|
+
type ITreeAlpha,
|
|
77
95
|
} from "../simple-tree/index.js";
|
|
78
96
|
|
|
79
97
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
@@ -82,12 +100,16 @@ import { SharedTreeChangeFamily } from "./sharedTreeChangeFamily.js";
|
|
|
82
100
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
83
101
|
import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
|
|
84
102
|
import { type TreeCheckout, type BranchableTree, createTreeCheckout } from "./treeCheckout.js";
|
|
85
|
-
import {
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
import {
|
|
104
|
+
Breakable,
|
|
105
|
+
breakingClass,
|
|
106
|
+
fail,
|
|
107
|
+
throwIfBroken,
|
|
108
|
+
type WithBreakable,
|
|
109
|
+
} from "../util/index.js";
|
|
88
110
|
|
|
89
111
|
/**
|
|
90
|
-
* Copy of data from an {@link
|
|
112
|
+
* Copy of data from an {@link ITreePrivate} at some point in time.
|
|
91
113
|
* @remarks
|
|
92
114
|
* This is unrelated to Fluids concept of "snapshots".
|
|
93
115
|
*/
|
|
@@ -111,30 +133,26 @@ export interface SharedTreeContentSnapshot {
|
|
|
111
133
|
}
|
|
112
134
|
|
|
113
135
|
/**
|
|
114
|
-
*
|
|
136
|
+
* Information about a Fluid channel.
|
|
137
|
+
* @privateRemarks
|
|
138
|
+
* This is distinct from {@link IChannel} as it omits the APIs used by the runtime to manage the channel and instead only has things which are useful (and safe) to expose to users of the channel.
|
|
115
139
|
* @internal
|
|
116
140
|
*/
|
|
117
|
-
export
|
|
118
|
-
/**
|
|
119
|
-
* Exports root in the same format as {@link TreeAlpha.(exportVerbose:1)} using stored keys.
|
|
120
|
-
* @privateRemarks
|
|
121
|
-
* TODO:
|
|
122
|
-
* This should probably get promoted to a public API on ITree eventually.
|
|
123
|
-
*/
|
|
124
|
-
exportVerbose(): VerboseTree | undefined;
|
|
141
|
+
export type IChannelView = Pick<IChannel, "id" | "attributes" | "isAttached">;
|
|
125
142
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
exportSimpleSchema(): SimpleTreeSchema;
|
|
132
|
-
}
|
|
143
|
+
/**
|
|
144
|
+
* {@link ITree} extended with some non-public APIs.
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
export interface ITreeInternal extends IChannelView, ITreeAlpha {}
|
|
133
148
|
|
|
134
149
|
/**
|
|
135
150
|
* {@link ITreeInternal} extended with some non-exported APIs.
|
|
151
|
+
* @remarks
|
|
152
|
+
* This allows access to the tree content using the internal data model used at the storage and "flex" layers,
|
|
153
|
+
* and should only be needed for testing and debugging this package's internals.
|
|
136
154
|
*/
|
|
137
|
-
export interface
|
|
155
|
+
export interface ITreePrivate extends ITreeInternal {
|
|
138
156
|
/**
|
|
139
157
|
* Provides a copy of the current content of the tree.
|
|
140
158
|
* This can be useful for inspecting the tree when no suitable view schema is available.
|
|
@@ -145,6 +163,13 @@ export interface ISharedTree extends ISharedObject, ITreeInternal {
|
|
|
145
163
|
contentSnapshot(): SharedTreeContentSnapshot;
|
|
146
164
|
}
|
|
147
165
|
|
|
166
|
+
/**
|
|
167
|
+
* {@link ITreePrivate} extended with ISharedObject.
|
|
168
|
+
* @remarks
|
|
169
|
+
* This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.
|
|
170
|
+
*/
|
|
171
|
+
export interface ISharedTree extends ISharedObject, ITreePrivate {}
|
|
172
|
+
|
|
148
173
|
/**
|
|
149
174
|
* Has an entry for each codec which writes an explicit version into its data.
|
|
150
175
|
*
|
|
@@ -188,20 +213,20 @@ function getCodecVersions(formatVersion: number): ExplicitCodecVersions {
|
|
|
188
213
|
}
|
|
189
214
|
|
|
190
215
|
/**
|
|
191
|
-
* Shared
|
|
192
|
-
*
|
|
193
|
-
* TODO: detail compatibility requirements.
|
|
216
|
+
* Shared object wrapping {@link SharedTreeKernel}.
|
|
194
217
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
218
|
+
export class SharedTree extends SharedObject implements ISharedTree, WithBreakable {
|
|
219
|
+
public readonly breaker: Breakable = new Breakable("Shared Tree");
|
|
220
|
+
|
|
221
|
+
public get checkout(): TreeCheckout {
|
|
222
|
+
return this.kernel.checkout;
|
|
223
|
+
}
|
|
201
224
|
public get storedSchema(): TreeStoredSchemaRepository {
|
|
202
225
|
return this.checkout.storedSchema;
|
|
203
226
|
}
|
|
204
227
|
|
|
228
|
+
private readonly kernel: SharedTreeKernel;
|
|
229
|
+
|
|
205
230
|
public constructor(
|
|
206
231
|
id: string,
|
|
207
232
|
runtime: IFluidDataStoreRuntime,
|
|
@@ -209,23 +234,132 @@ export class SharedTree
|
|
|
209
234
|
optionsParam: SharedTreeOptionsInternal,
|
|
210
235
|
telemetryContextPrefix: string = "fluid_sharedTree_",
|
|
211
236
|
) {
|
|
237
|
+
super(id, runtime, attributes, telemetryContextPrefix);
|
|
212
238
|
if (runtime.idCompressor === undefined) {
|
|
213
239
|
throw new UsageError("IdCompressor must be enabled to use SharedTree");
|
|
214
240
|
}
|
|
241
|
+
this.kernel = new SharedTreeKernel(
|
|
242
|
+
this.breaker,
|
|
243
|
+
this,
|
|
244
|
+
this.serializer,
|
|
245
|
+
(content, localOpMetadata) => this.submitLocalMessage(content, localOpMetadata),
|
|
246
|
+
() => this.deltaManager.lastSequenceNumber,
|
|
247
|
+
this.logger,
|
|
248
|
+
runtime.idCompressor,
|
|
249
|
+
optionsParam,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
public get editor(): SharedTreeEditBuilder {
|
|
254
|
+
return this.kernel.getEditor();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public summarizeCore(
|
|
258
|
+
serializer: IFluidSerializer,
|
|
259
|
+
telemetryContext?: ITelemetryContext,
|
|
260
|
+
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
|
|
261
|
+
): ISummaryTreeWithStats {
|
|
262
|
+
return this.kernel.summarizeCore(serializer, telemetryContext, incrementalSummaryContext);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
protected processCore(
|
|
266
|
+
message: ISequencedDocumentMessage,
|
|
267
|
+
local: boolean,
|
|
268
|
+
localOpMetadata: unknown,
|
|
269
|
+
): void {
|
|
270
|
+
this.kernel.processCore(message, local, localOpMetadata);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
protected onDisconnect(): void {}
|
|
274
|
+
|
|
275
|
+
public exportVerbose(): VerboseTree | undefined {
|
|
276
|
+
return this.kernel.exportVerbose();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public exportSimpleSchema(): SimpleTreeSchema {
|
|
280
|
+
return this.kernel.exportSimpleSchema();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public contentSnapshot(): SharedTreeContentSnapshot {
|
|
284
|
+
return this.kernel.contentSnapshot();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// For the new TreeViewAlpha API
|
|
288
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
289
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
290
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>>;
|
|
291
|
+
|
|
292
|
+
// For the old TreeView API
|
|
293
|
+
public viewWith<TRoot extends ImplicitFieldSchema>(
|
|
294
|
+
config: TreeViewConfiguration<TRoot>,
|
|
295
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<TRoot>;
|
|
296
|
+
|
|
297
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
298
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
299
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>> {
|
|
300
|
+
return this.kernel.viewWith(config);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
protected override async loadCore(services: IChannelStorageService): Promise<void> {
|
|
304
|
+
await this.kernel.loadCore(services);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
protected override didAttach(): void {
|
|
308
|
+
this.kernel.didAttach();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
protected override applyStashedOp(
|
|
312
|
+
...args: Parameters<
|
|
313
|
+
SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["applyStashedOp"]
|
|
314
|
+
>
|
|
315
|
+
): void {
|
|
316
|
+
this.kernel.applyStashedOp(...args);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
protected override reSubmitCore(
|
|
320
|
+
...args: Parameters<
|
|
321
|
+
SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["reSubmitCore"]
|
|
322
|
+
>
|
|
323
|
+
): void {
|
|
324
|
+
this.kernel.reSubmitCore(...args);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* SharedTreeCore, configured with a good set of indexes and field kinds which will maintain compatibility over time.
|
|
330
|
+
*
|
|
331
|
+
* TODO: detail compatibility requirements.
|
|
332
|
+
*/
|
|
333
|
+
@breakingClass
|
|
334
|
+
class SharedTreeKernel extends SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange> {
|
|
335
|
+
public readonly checkout: TreeCheckout;
|
|
336
|
+
public get storedSchema(): TreeStoredSchemaRepository {
|
|
337
|
+
return this.checkout.storedSchema;
|
|
338
|
+
}
|
|
215
339
|
|
|
340
|
+
public constructor(
|
|
341
|
+
breaker: Breakable,
|
|
342
|
+
sharedObject: IChannelView & IFluidLoadable,
|
|
343
|
+
serializer: IFluidSerializer,
|
|
344
|
+
submitLocalMessage: (content: unknown, localOpMetadata?: unknown) => void,
|
|
345
|
+
lastSequenceNumber: () => number | undefined,
|
|
346
|
+
logger: ITelemetryLoggerExt | undefined,
|
|
347
|
+
idCompressor: IIdCompressor,
|
|
348
|
+
optionsParam: SharedTreeOptionsInternal,
|
|
349
|
+
) {
|
|
216
350
|
const options = { ...defaultSharedTreeOptions, ...optionsParam };
|
|
217
351
|
const codecVersions = getCodecVersions(options.formatVersion);
|
|
218
352
|
const schema = new TreeStoredSchemaRepository();
|
|
219
|
-
const forest = buildConfiguredForest(options.forest, schema,
|
|
220
|
-
const revisionTagCodec = new RevisionTagCodec(
|
|
353
|
+
const forest = buildConfiguredForest(options.forest, schema, idCompressor);
|
|
354
|
+
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
221
355
|
const removedRoots = makeDetachedFieldIndex(
|
|
222
356
|
"repair",
|
|
223
357
|
revisionTagCodec,
|
|
224
|
-
|
|
358
|
+
idCompressor,
|
|
225
359
|
options,
|
|
226
360
|
);
|
|
227
|
-
const schemaSummarizer = new SchemaSummarizer(
|
|
228
|
-
getCurrentSeq:
|
|
361
|
+
const schemaSummarizer = new SchemaSummarizer(schema, options, {
|
|
362
|
+
getCurrentSeq: lastSequenceNumber,
|
|
229
363
|
});
|
|
230
364
|
const fieldBatchCodec = makeFieldBatchCodec(options, codecVersions.fieldBatch);
|
|
231
365
|
|
|
@@ -235,8 +369,8 @@ export class SharedTree
|
|
|
235
369
|
policy: defaultSchemaPolicy,
|
|
236
370
|
},
|
|
237
371
|
encodeType: options.treeEncodeType,
|
|
238
|
-
originatorId:
|
|
239
|
-
idCompressor
|
|
372
|
+
originatorId: idCompressor.localSessionId,
|
|
373
|
+
idCompressor,
|
|
240
374
|
};
|
|
241
375
|
const forestSummarizer = new ForestSummarizer(
|
|
242
376
|
forest,
|
|
@@ -244,7 +378,7 @@ export class SharedTree
|
|
|
244
378
|
fieldBatchCodec,
|
|
245
379
|
encoderContext,
|
|
246
380
|
options,
|
|
247
|
-
|
|
381
|
+
idCompressor,
|
|
248
382
|
);
|
|
249
383
|
const removedRootsSummarizer = new DetachedFieldIndexSummarizer(removedRoots);
|
|
250
384
|
const innerChangeFamily = new SharedTreeChangeFamily(
|
|
@@ -252,7 +386,7 @@ export class SharedTree
|
|
|
252
386
|
fieldBatchCodec,
|
|
253
387
|
options,
|
|
254
388
|
options.treeEncodeType,
|
|
255
|
-
|
|
389
|
+
idCompressor,
|
|
256
390
|
);
|
|
257
391
|
const changeFamily = makeMitigatedChangeFamily(
|
|
258
392
|
innerChangeFamily,
|
|
@@ -278,14 +412,16 @@ export class SharedTree
|
|
|
278
412
|
);
|
|
279
413
|
const changeEnricher = new SharedTreeReadonlyChangeEnricher(forest, schema, removedRoots);
|
|
280
414
|
super(
|
|
415
|
+
breaker,
|
|
416
|
+
sharedObject,
|
|
417
|
+
serializer,
|
|
418
|
+
submitLocalMessage,
|
|
419
|
+
logger,
|
|
281
420
|
[schemaSummarizer, forestSummarizer, removedRootsSummarizer],
|
|
282
421
|
changeFamily,
|
|
283
422
|
options,
|
|
284
423
|
codecVersions,
|
|
285
|
-
|
|
286
|
-
runtime,
|
|
287
|
-
attributes,
|
|
288
|
-
telemetryContextPrefix,
|
|
424
|
+
idCompressor,
|
|
289
425
|
schema,
|
|
290
426
|
defaultSchemaPolicy,
|
|
291
427
|
new DefaultResubmitMachine(
|
|
@@ -296,44 +432,39 @@ export class SharedTree
|
|
|
296
432
|
changeEnricher,
|
|
297
433
|
);
|
|
298
434
|
const localBranch = this.getLocalBranch();
|
|
299
|
-
this.checkout = createTreeCheckout(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
logger: this.logger,
|
|
312
|
-
breaker: this.breaker,
|
|
313
|
-
disposeForksAfterTransaction: options.disposeForksAfterTransaction,
|
|
314
|
-
},
|
|
315
|
-
);
|
|
435
|
+
this.checkout = createTreeCheckout(idCompressor, this.mintRevisionTag, revisionTagCodec, {
|
|
436
|
+
branch: localBranch,
|
|
437
|
+
changeFamily,
|
|
438
|
+
schema,
|
|
439
|
+
forest,
|
|
440
|
+
fieldBatchCodec,
|
|
441
|
+
removedRoots,
|
|
442
|
+
chunkCompressionStrategy: options.treeEncodeType,
|
|
443
|
+
logger,
|
|
444
|
+
breaker: this.breaker,
|
|
445
|
+
disposeForksAfterTransaction: options.disposeForksAfterTransaction,
|
|
446
|
+
});
|
|
316
447
|
|
|
317
448
|
this.checkout.transaction.events.on("started", () => {
|
|
318
|
-
if (
|
|
449
|
+
if (sharedObject.isAttached()) {
|
|
319
450
|
// It is currently forbidden to attach during a transaction, so transaction state changes can be ignored until after attaching.
|
|
320
451
|
this.commitEnricher.startTransaction();
|
|
321
452
|
}
|
|
322
453
|
});
|
|
323
454
|
this.checkout.transaction.events.on("aborting", () => {
|
|
324
|
-
if (
|
|
455
|
+
if (sharedObject.isAttached()) {
|
|
325
456
|
// It is currently forbidden to attach during a transaction, so transaction state changes can be ignored until after attaching.
|
|
326
457
|
this.commitEnricher.abortTransaction();
|
|
327
458
|
}
|
|
328
459
|
});
|
|
329
460
|
this.checkout.transaction.events.on("committing", () => {
|
|
330
|
-
if (
|
|
461
|
+
if (sharedObject.isAttached()) {
|
|
331
462
|
// It is currently forbidden to attach during a transaction, so transaction state changes can be ignored until after attaching.
|
|
332
463
|
this.commitEnricher.commitTransaction();
|
|
333
464
|
}
|
|
334
465
|
});
|
|
335
466
|
this.checkout.events.on("beforeBatch", (event) => {
|
|
336
|
-
if (event.type === "append" &&
|
|
467
|
+
if (event.type === "append" && sharedObject.isAttached()) {
|
|
337
468
|
if (this.checkout.transaction.isInProgress()) {
|
|
338
469
|
this.commitEnricher.addTransactionCommits(event.newCommits);
|
|
339
470
|
}
|
|
@@ -402,12 +533,12 @@ export class SharedTree
|
|
|
402
533
|
TreeView<ReadSchema<TRoot>>;
|
|
403
534
|
}
|
|
404
535
|
|
|
405
|
-
|
|
536
|
+
public override async loadCore(services: IChannelStorageService): Promise<void> {
|
|
406
537
|
await super.loadCore(services);
|
|
407
538
|
this.checkout.load();
|
|
408
539
|
}
|
|
409
540
|
|
|
410
|
-
|
|
541
|
+
public override didAttach(): void {
|
|
411
542
|
if (this.checkout.transaction.isInProgress()) {
|
|
412
543
|
// Attaching during a transaction is not currently supported.
|
|
413
544
|
// At least part of of the system is known to not handle this case correctly - commit enrichment - and there may be others.
|
|
@@ -418,7 +549,7 @@ export class SharedTree
|
|
|
418
549
|
super.didAttach();
|
|
419
550
|
}
|
|
420
551
|
|
|
421
|
-
|
|
552
|
+
public override applyStashedOp(
|
|
422
553
|
...args: Parameters<
|
|
423
554
|
SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["applyStashedOp"]
|
|
424
555
|
>
|
|
@@ -642,34 +773,6 @@ export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
|
|
|
642
773
|
disposeForksAfterTransaction: true,
|
|
643
774
|
};
|
|
644
775
|
|
|
645
|
-
/**
|
|
646
|
-
* A channel factory that creates {@link ISharedTree}s.
|
|
647
|
-
*/
|
|
648
|
-
export class SharedTreeFactory implements IChannelFactory<ISharedTree> {
|
|
649
|
-
public readonly type: string = SharedTreeFactoryType;
|
|
650
|
-
|
|
651
|
-
public readonly attributes: IChannelAttributes = SharedTreeAttributes;
|
|
652
|
-
|
|
653
|
-
public constructor(private readonly options: SharedTreeOptionsInternal = {}) {}
|
|
654
|
-
|
|
655
|
-
public async load(
|
|
656
|
-
runtime: IFluidDataStoreRuntime,
|
|
657
|
-
id: string,
|
|
658
|
-
services: IChannelServices,
|
|
659
|
-
channelAttributes: Readonly<IChannelAttributes>,
|
|
660
|
-
): Promise<SharedTree> {
|
|
661
|
-
const tree = new SharedTree(id, runtime, channelAttributes, this.options);
|
|
662
|
-
await tree.load(services);
|
|
663
|
-
return tree;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
public create(runtime: IFluidDataStoreRuntime, id: string): SharedTree {
|
|
667
|
-
const tree = new SharedTree(id, runtime, this.attributes, this.options);
|
|
668
|
-
tree.initializeLocal();
|
|
669
|
-
return tree;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
776
|
function verboseFromCursor(
|
|
674
777
|
reader: ITreeCursor,
|
|
675
778
|
schema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,
|
|
@@ -14,12 +14,13 @@ import {
|
|
|
14
14
|
type TreeView,
|
|
15
15
|
getOrCreateInnerNode,
|
|
16
16
|
treeNodeApi,
|
|
17
|
+
rollback,
|
|
18
|
+
type TransactionConstraint,
|
|
17
19
|
} from "../simple-tree/index.js";
|
|
18
20
|
|
|
19
21
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
20
22
|
import type { ITreeCheckout } from "./treeCheckout.js";
|
|
21
23
|
import { getCheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
|
|
22
|
-
import { rollback, type TransactionConstraint } from "./transactionTypes.js";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* A function which runs a transaction in a SharedTree.
|
|
@@ -394,6 +395,7 @@ function createRunTransaction(): RunTransaction {
|
|
|
394
395
|
* Run the given transaction.
|
|
395
396
|
* @remarks
|
|
396
397
|
* This API is not publicly exported but is exported outside of this module so that test code may unit test the `Tree.runTransaction` function directly without being restricted to its public API overloads.
|
|
398
|
+
* @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.
|
|
397
399
|
*/
|
|
398
400
|
export function runTransaction<
|
|
399
401
|
TNode extends TreeNode,
|
|
@@ -427,6 +429,10 @@ export function runTransaction<
|
|
|
427
429
|
}
|
|
428
430
|
}
|
|
429
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Run the given transaction.
|
|
434
|
+
* @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to editing content in the error case.
|
|
435
|
+
*/
|
|
430
436
|
function runTransactionInCheckout<TResult>(
|
|
431
437
|
checkout: ITreeCheckout,
|
|
432
438
|
transaction: () => TResult | typeof rollback,
|
|
@@ -450,11 +456,14 @@ function runTransactionInCheckout<TResult>(
|
|
|
450
456
|
unreachableCase(constraint.type);
|
|
451
457
|
}
|
|
452
458
|
}
|
|
459
|
+
|
|
453
460
|
let result: ReturnType<typeof transaction>;
|
|
454
461
|
try {
|
|
455
462
|
result = transaction();
|
|
456
463
|
} catch (error) {
|
|
457
464
|
// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.
|
|
465
|
+
// This might try and modify the tree or trigger events while things are in an inconsistent state.
|
|
466
|
+
// It is up to the user of runTransaction to ensure that does not cause problems (and they have no robust way to do that, which is why its deprecated).
|
|
458
467
|
checkout.transaction.abort();
|
|
459
468
|
throw error;
|
|
460
469
|
}
|
|
@@ -60,7 +60,13 @@ import {
|
|
|
60
60
|
type SharedTreeBranchChange,
|
|
61
61
|
type Transactor,
|
|
62
62
|
} from "../shared-tree-core/index.js";
|
|
63
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
Breakable,
|
|
65
|
+
disposeSymbol,
|
|
66
|
+
fail,
|
|
67
|
+
getOrCreate,
|
|
68
|
+
type WithBreakable,
|
|
69
|
+
} from "../util/index.js";
|
|
64
70
|
|
|
65
71
|
import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamily.js";
|
|
66
72
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
@@ -182,7 +188,7 @@ export interface TreeBranchFork extends BranchableTree, IDisposable {
|
|
|
182
188
|
* API for interacting with a {@link SharedTreeBranch}.
|
|
183
189
|
* Implementations of this interface must implement the {@link branchKey} property.
|
|
184
190
|
*/
|
|
185
|
-
export interface ITreeCheckout extends AnchorLocator, ViewableTree {
|
|
191
|
+
export interface ITreeCheckout extends AnchorLocator, ViewableTree, WithBreakable {
|
|
186
192
|
/**
|
|
187
193
|
* Read and Write access for schema stored in the document.
|
|
188
194
|
*
|
|
@@ -391,7 +397,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
391
397
|
),
|
|
392
398
|
/** Optional logger for telemetry. */
|
|
393
399
|
private readonly logger?: ITelemetryLoggerExt,
|
|
394
|
-
|
|
400
|
+
public readonly breaker: Breakable = new Breakable("TreeCheckout"),
|
|
395
401
|
private readonly disposeForksAfterTransaction = true,
|
|
396
402
|
) {
|
|
397
403
|
this.#transaction = new SquashingTransactionStack(
|
|
@@ -549,15 +555,13 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
549
555
|
|
|
550
556
|
private withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {
|
|
551
557
|
const anchorVisitor = this.forest.anchors.acquireVisitor();
|
|
552
|
-
const combinedVisitor = combineVisitors(
|
|
553
|
-
[this.forest.acquireVisitor(), anchorVisitor],
|
|
554
|
-
[anchorVisitor],
|
|
555
|
-
);
|
|
558
|
+
const combinedVisitor = combineVisitors([this.forest.acquireVisitor(), anchorVisitor]);
|
|
556
559
|
fn(combinedVisitor);
|
|
557
560
|
combinedVisitor.free();
|
|
558
561
|
}
|
|
559
562
|
|
|
560
563
|
private checkNotDisposed(usageError?: string): void {
|
|
564
|
+
this.breaker.use();
|
|
561
565
|
if (this.disposed) {
|
|
562
566
|
if (usageError !== undefined) {
|
|
563
567
|
throw new UsageError(usageError);
|
|
@@ -659,7 +663,6 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
659
663
|
this,
|
|
660
664
|
config,
|
|
661
665
|
createNodeKeyManager(this.idCompressor),
|
|
662
|
-
this.breaker,
|
|
663
666
|
() => {
|
|
664
667
|
this.views.delete(view);
|
|
665
668
|
},
|
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
SummarySessionBranch,
|
|
32
32
|
} from "./editManagerFormat.js";
|
|
33
33
|
import {
|
|
34
|
-
|
|
34
|
+
getUpperBoundOfPreviousSequenceId,
|
|
35
35
|
equalSequenceIds,
|
|
36
36
|
maxSequenceId,
|
|
37
37
|
minSequenceId,
|
|
@@ -362,7 +362,7 @@ export class EditManager<
|
|
|
362
362
|
if (minimumBranchBaseSequenceId !== undefined) {
|
|
363
363
|
// If that branch is behind the minimum sequence id, we only want to evict commits older than it,
|
|
364
364
|
// even if those commits are behind the minimum sequence id
|
|
365
|
-
const sequenceIdBeforeMinimumBranchBase =
|
|
365
|
+
const sequenceIdBeforeMinimumBranchBase = getUpperBoundOfPreviousSequenceId(
|
|
366
366
|
minimumBranchBaseSequenceId,
|
|
367
367
|
);
|
|
368
368
|
trunkTailSequenceId = minSequenceId(
|
|
@@ -7,7 +7,6 @@ import { bufferToString } from "@fluid-internal/client-utils";
|
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
9
9
|
import type {
|
|
10
|
-
IGarbageCollectionData,
|
|
11
10
|
ISummaryTreeWithStats,
|
|
12
11
|
ITelemetryContext,
|
|
13
12
|
} from "@fluidframework/runtime-definitions/internal";
|
|
@@ -78,16 +77,6 @@ export class EditManagerSummarizer<TChangeset> implements Summarizable {
|
|
|
78
77
|
return createSingleBlobSummary(stringKey, dataString);
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
public getGCData(fullGC?: boolean): IGarbageCollectionData {
|
|
82
|
-
// TODO: Properly implement garbage collection. Right now, garbage collection is performed automatically
|
|
83
|
-
// by the code in SharedObject (from which SharedTreeCore extends). The `runtime.uploadBlob` API delegates
|
|
84
|
-
// to the `BlobManager`, which automatically populates the summary with ISummaryAttachment entries for each
|
|
85
|
-
// blob.
|
|
86
|
-
return {
|
|
87
|
-
gcNodes: {},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
80
|
public async load(
|
|
92
81
|
services: IChannelStorageService,
|
|
93
82
|
parse: SummaryElementParser,
|
|
@@ -3,25 +3,46 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
7
|
import { brand } from "../util/index.js";
|
|
7
8
|
|
|
8
9
|
import type { SequenceId } from "./editManagerFormat.js";
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Compares two sequenceIds. Returns a negative number if a \< b, a positive number if a \> b, and 0 if a === b.
|
|
13
|
+
* Note that this handles cases where indexInBatch is Number.POSITIVE_INFINITY.
|
|
14
|
+
*/
|
|
10
15
|
export const sequenceIdComparator = (a: SequenceId, b: SequenceId): number =>
|
|
11
16
|
a.sequenceNumber !== b.sequenceNumber
|
|
12
17
|
? a.sequenceNumber - b.sequenceNumber
|
|
13
|
-
:
|
|
18
|
+
: a.indexInBatch === b.indexInBatch
|
|
19
|
+
? 0
|
|
20
|
+
: (a.indexInBatch ?? 0) - (b.indexInBatch ?? 0);
|
|
14
21
|
export const equalSequenceIds = (a: SequenceId, b: SequenceId): boolean =>
|
|
15
22
|
sequenceIdComparator(a, b) === 0;
|
|
16
23
|
export const minSequenceId = (a: SequenceId, b: SequenceId): SequenceId =>
|
|
17
24
|
sequenceIdComparator(a, b) < 0 ? a : b;
|
|
18
25
|
export const maxSequenceId = (a: SequenceId, b: SequenceId): SequenceId =>
|
|
19
26
|
sequenceIdComparator(a, b) > 0 ? a : b;
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Returns the upper bound (maximum possible) sequenceId that can occur just before the given sequenceId.
|
|
29
|
+
* Some examples:
|
|
30
|
+
* 1. sequenceId = \{ sequenceNumber: 1, indexInBatch: 2 \}. The upper bound is \{ sequenceNumber: 1, indexInBatch: 1 \}.
|
|
31
|
+
* 2. sequenceId = \{ sequenceNumber: 2 \}. The upper bound is \{ sequenceNumber: 1, indexInBatch: Number.POSITIVE_INFINITY \}.
|
|
32
|
+
* The indexInBatch value of the previous commit will depend on how many ops were in the previous batch of messages received.
|
|
33
|
+
*/
|
|
34
|
+
export const getUpperBoundOfPreviousSequenceId = (sequenceId: SequenceId): SequenceId => {
|
|
35
|
+
assert(
|
|
36
|
+
sequenceId.indexInBatch === undefined || Number.isFinite(sequenceId.indexInBatch),
|
|
37
|
+
0xabc /* indexInBatch must not be infinity */,
|
|
38
|
+
);
|
|
39
|
+
return sequenceId.indexInBatch === undefined || sequenceId.indexInBatch === 0
|
|
22
40
|
? {
|
|
41
|
+
sequenceNumber: brand(sequenceId.sequenceNumber - 1),
|
|
42
|
+
indexInBatch: Number.POSITIVE_INFINITY,
|
|
43
|
+
}
|
|
44
|
+
: {
|
|
23
45
|
sequenceNumber: brand(sequenceId.sequenceNumber),
|
|
24
46
|
indexInBatch: sequenceId.indexInBatch - 1,
|
|
25
|
-
}
|
|
26
|
-
: { sequenceNumber: brand(sequenceId.sequenceNumber - 1) };
|
|
47
|
+
};
|
|
27
48
|
};
|