@fluidframework/tree 2.5.0-302463 → 2.5.0
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/.vscode/settings.json +1 -0
- package/CHANGELOG.md +371 -0
- package/api-report/tree.alpha.api.md +151 -57
- package/api-report/tree.beta.api.md +29 -25
- package/api-report/tree.legacy.alpha.api.md +28 -24
- package/api-report/tree.legacy.public.api.md +28 -24
- package/api-report/tree.public.api.md +28 -24
- package/dist/alpha.d.ts +15 -0
- package/dist/codec/codec.d.ts +24 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +26 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +0 -4
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -7
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +1 -0
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +29 -4
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts +57 -0
- package/dist/shared-tree/independentView.d.ts.map +1 -0
- package/dist/shared-tree/independentView.js +89 -0
- package/dist/shared-tree/independentView.js.map +1 -0
- package/dist/shared-tree/index.d.ts +3 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +6 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +28 -0
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +10 -7
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
- package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
- package/dist/shared-tree/treeApiAlpha.js +122 -0
- package/dist/shared-tree/treeApiAlpha.js.map +1 -0
- package/dist/shared-tree/treeCheckout.d.ts +12 -7
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +9 -4
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +13 -6
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +70 -28
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +28 -3
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +2 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +5 -23
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +4 -19
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +1 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +5 -5
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +10 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +11 -11
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/dist/simple-tree/api/tree.d.ts +115 -7
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +12 -4
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.js +3 -15
- package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +3 -0
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +1 -1
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +45 -9
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +1 -2
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/createContext.js +2 -2
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +15 -4
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +3 -0
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +3 -0
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +45 -7
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +61 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
- package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
- package/dist/simple-tree/toStoredSchema.js.map +1 -0
- package/dist/simple-tree/treeNodeValid.d.ts +5 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +7 -1
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeCheck.d.ts +9 -0
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/utils.d.ts +7 -3
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +13 -3
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +15 -0
- package/lib/codec/codec.d.ts +24 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +25 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +2 -2
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +2 -2
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +0 -4
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -5
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts +1 -0
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +27 -3
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts +57 -0
- package/lib/shared-tree/independentView.d.ts.map +1 -0
- package/lib/shared-tree/independentView.js +84 -0
- package/lib/shared-tree/independentView.js.map +1 -0
- package/lib/shared-tree/index.d.ts +3 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -0
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +29 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +10 -7
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
- package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
- package/lib/shared-tree/treeApiAlpha.js +119 -0
- package/lib/shared-tree/treeApiAlpha.js.map +1 -0
- package/lib/shared-tree/treeCheckout.d.ts +12 -7
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +9 -4
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +13 -6
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +70 -28
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +29 -4
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +2 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +5 -23
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +2 -16
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +1 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +5 -5
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +5 -3
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +11 -11
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +1 -1
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/lib/simple-tree/api/tree.d.ts +115 -7
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +9 -2
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.js +4 -16
- package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +3 -0
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +1 -1
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +45 -9
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +1 -2
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/createContext.js +1 -1
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +3 -0
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +3 -0
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +45 -7
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +59 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
- package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
- package/lib/simple-tree/toStoredSchema.js.map +1 -0
- package/lib/simple-tree/treeNodeValid.d.ts +5 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +7 -1
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/typeCheck.d.ts +9 -0
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/utils.d.ts +7 -3
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +13 -3
- package/lib/util/utils.js.map +1 -1
- package/package.json +30 -21
- package/src/codec/codec.ts +25 -0
- package/src/codec/index.ts +1 -0
- package/src/core/rebase/index.ts +1 -1
- package/src/core/rebase/types.ts +0 -12
- package/src/core/rebase/utils.ts +35 -3
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
- package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
- package/src/index.ts +20 -5
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +176 -0
- package/src/shared-tree/index.ts +9 -1
- package/src/shared-tree/schematizingTreeView.ts +58 -11
- package/src/shared-tree/sharedTree.ts +29 -11
- package/src/shared-tree/treeApiAlpha.ts +401 -0
- package/src/shared-tree/treeCheckout.ts +26 -5
- package/src/shared-tree-core/editManager.ts +112 -54
- package/src/shared-tree-core/sharedTreeCore.ts +37 -8
- package/src/simple-tree/api/conciseTree.ts +2 -1
- package/src/simple-tree/api/create.ts +21 -58
- package/src/simple-tree/api/customTree.ts +1 -0
- package/src/simple-tree/api/index.ts +13 -7
- package/src/simple-tree/api/schemaCreationUtilities.ts +4 -5
- package/src/simple-tree/api/schemaFactory.ts +24 -12
- package/src/simple-tree/api/storedSchema.ts +1 -1
- package/src/simple-tree/api/tree.ts +136 -14
- package/src/simple-tree/api/treeApiBeta.ts +35 -35
- package/src/simple-tree/api/typesUnsafe.ts +1 -2
- package/src/simple-tree/api/verboseTree.ts +3 -0
- package/src/simple-tree/arrayNode.ts +4 -3
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/treeNodeSchema.ts +99 -31
- package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
- package/src/simple-tree/core/withType.ts +1 -9
- package/src/simple-tree/createContext.ts +1 -1
- package/src/simple-tree/index.ts +15 -1
- package/src/simple-tree/leafNodeSchema.ts +6 -1
- package/src/simple-tree/mapNode.ts +7 -1
- package/src/simple-tree/schemaTypes.ts +128 -14
- package/src/simple-tree/treeNodeValid.ts +11 -1
- package/src/util/index.ts +1 -0
- package/src/util/typeCheck.ts +13 -0
- package/src/util/utils.ts +20 -7
- package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
- package/dist/simple-tree/toFlexSchema.js.map +0 -1
- package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
- package/lib/simple-tree/toFlexSchema.js.map +0 -1
- /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
package/src/core/rebase/utils.ts
CHANGED
|
@@ -441,8 +441,9 @@ function rollbackFromCommit<TChange>(
|
|
|
441
441
|
mintRevisionTag: () => RevisionTag,
|
|
442
442
|
cache?: boolean,
|
|
443
443
|
): TaggedChange<TChange, RevisionTag> {
|
|
444
|
-
|
|
445
|
-
|
|
444
|
+
const rollback = Rollback.get(commit);
|
|
445
|
+
if (rollback !== undefined) {
|
|
446
|
+
return rollback;
|
|
446
447
|
}
|
|
447
448
|
const tag = mintRevisionTag();
|
|
448
449
|
const untagged = changeRebaser.invert(commit, true, tag);
|
|
@@ -450,7 +451,7 @@ function rollbackFromCommit<TChange>(
|
|
|
450
451
|
const fullyTaggedRollback = tagRollbackInverse(deeplyTaggedRollback, tag, commit.revision);
|
|
451
452
|
|
|
452
453
|
if (cache === true) {
|
|
453
|
-
commit
|
|
454
|
+
Rollback.set(commit, fullyTaggedRollback);
|
|
454
455
|
}
|
|
455
456
|
return fullyTaggedRollback;
|
|
456
457
|
}
|
|
@@ -620,3 +621,34 @@ export function findCommonAncestor<T extends { parent?: T }>(
|
|
|
620
621
|
}
|
|
621
622
|
return undefined;
|
|
622
623
|
}
|
|
624
|
+
|
|
625
|
+
export function replaceChange<TChange>(
|
|
626
|
+
commit: GraphCommit<TChange>,
|
|
627
|
+
change: TChange,
|
|
628
|
+
): GraphCommit<TChange> {
|
|
629
|
+
const output = { ...commit, change };
|
|
630
|
+
Rollback.set(output, undefined);
|
|
631
|
+
return output;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** Associates rollback data with commits */
|
|
635
|
+
namespace Rollback {
|
|
636
|
+
const map = new WeakMap<GraphCommit<unknown>, TaggedChange<unknown, RevisionTag>>();
|
|
637
|
+
|
|
638
|
+
export function get<TChange>(
|
|
639
|
+
commit: GraphCommit<TChange>,
|
|
640
|
+
): TaggedChange<TChange, RevisionTag> | undefined {
|
|
641
|
+
return map.get(commit) as TaggedChange<TChange, RevisionTag> | undefined;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export function set<TChange>(
|
|
645
|
+
commit: GraphCommit<TChange>,
|
|
646
|
+
rollback: TaggedChange<TChange, RevisionTag> | undefined,
|
|
647
|
+
): void {
|
|
648
|
+
if (rollback === undefined) {
|
|
649
|
+
map.delete(commit);
|
|
650
|
+
} else {
|
|
651
|
+
map.set(commit, rollback);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type FieldKey,
|
|
10
10
|
type FieldKindIdentifier,
|
|
11
11
|
type FieldUpPath,
|
|
12
|
+
type ITreeCursorSynchronous,
|
|
12
13
|
type TreeNodeSchemaIdentifier,
|
|
13
14
|
type TreeValue,
|
|
14
15
|
anchorSlot,
|
|
@@ -184,6 +185,14 @@ export interface FlexTreeNode extends FlexTreeEntity {
|
|
|
184
185
|
* If well-formed, it must follow this schema.
|
|
185
186
|
*/
|
|
186
187
|
readonly schema: TreeNodeSchemaIdentifier;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Get a cursor for the underlying data.
|
|
191
|
+
* @remarks
|
|
192
|
+
* This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.
|
|
193
|
+
* Must not be held onto across edits or any other tree API use.
|
|
194
|
+
*/
|
|
195
|
+
borrowCursor(): ITreeCursorSynchronous;
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
/**
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type AnchorNode,
|
|
11
11
|
CursorLocationType,
|
|
12
12
|
type FieldKey,
|
|
13
|
+
type ITreeCursorSynchronous,
|
|
13
14
|
type FieldKindIdentifier,
|
|
14
15
|
type ITreeSubscriptionCursor,
|
|
15
16
|
type TreeNavigationResult,
|
|
@@ -91,6 +92,10 @@ export class LazyTreeNode extends LazyEntity<Anchor> implements FlexTreeNode {
|
|
|
91
92
|
this.#removeDeleteCallback = anchorNode.on("afterDestroy", cleanupTree);
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
public borrowCursor(): ITreeCursorSynchronous {
|
|
96
|
+
return this[cursorSymbol] as ITreeCursorSynchronous;
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
protected override [tryMoveCursorToAnchorSymbol](
|
|
95
100
|
cursor: ITreeSubscriptionCursor,
|
|
96
101
|
): TreeNavigationResult {
|
package/src/index.ts
CHANGED
|
@@ -58,8 +58,12 @@ export {
|
|
|
58
58
|
rollback,
|
|
59
59
|
type ForestOptions,
|
|
60
60
|
getBranch,
|
|
61
|
-
type
|
|
61
|
+
type BranchableTree,
|
|
62
62
|
type TreeBranchFork,
|
|
63
|
+
independentInitializedView,
|
|
64
|
+
type ViewContent,
|
|
65
|
+
TreeAlpha,
|
|
66
|
+
independentView,
|
|
63
67
|
} from "./shared-tree/index.js";
|
|
64
68
|
|
|
65
69
|
export {
|
|
@@ -133,6 +137,8 @@ export {
|
|
|
133
137
|
type InsertableContent,
|
|
134
138
|
type FactoryContent,
|
|
135
139
|
type FactoryContentObject,
|
|
140
|
+
type ReadableField,
|
|
141
|
+
type ReadSchema,
|
|
136
142
|
// test recursive schema for checking that d.ts files handles schema correctly
|
|
137
143
|
test_RecursiveObject,
|
|
138
144
|
test_RecursiveObject_base,
|
|
@@ -140,8 +146,13 @@ export {
|
|
|
140
146
|
// Beta APIs
|
|
141
147
|
TreeBeta,
|
|
142
148
|
type TreeChangeEventsBeta,
|
|
149
|
+
type VerboseTreeNode,
|
|
150
|
+
type EncodeOptions,
|
|
151
|
+
type ParseOptions,
|
|
152
|
+
type VerboseTree,
|
|
143
153
|
extractPersistedSchema,
|
|
144
154
|
comparePersistedSchema,
|
|
155
|
+
type ConciseTree,
|
|
145
156
|
// Back to normal types
|
|
146
157
|
type JsonTreeSchema,
|
|
147
158
|
type JsonSchemaId,
|
|
@@ -162,16 +173,20 @@ export {
|
|
|
162
173
|
type ReadonlyArrayNode,
|
|
163
174
|
type InsertableTreeNodeFromAllowedTypes,
|
|
164
175
|
type Input,
|
|
176
|
+
type TreeBranch,
|
|
177
|
+
type TreeBranchEvents,
|
|
178
|
+
asTreeViewAlpha,
|
|
165
179
|
} from "./simple-tree/index.js";
|
|
166
180
|
export {
|
|
167
181
|
SharedTree,
|
|
168
182
|
configuredSharedTree,
|
|
169
183
|
} from "./treeFactory.js";
|
|
170
184
|
|
|
171
|
-
export
|
|
172
|
-
ICodecOptions,
|
|
173
|
-
JsonValidator,
|
|
174
|
-
SchemaValidationFunction,
|
|
185
|
+
export {
|
|
186
|
+
type ICodecOptions,
|
|
187
|
+
type JsonValidator,
|
|
188
|
+
type SchemaValidationFunction,
|
|
189
|
+
FluidClientVersion,
|
|
175
190
|
} from "./codec/index.js";
|
|
176
191
|
export { noopValidator } from "./codec/index.js";
|
|
177
192
|
export { typeboxValidator } from "./external-utilities/index.js";
|
package/src/packageVersion.ts
CHANGED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
+
import {
|
|
9
|
+
type IIdCompressor,
|
|
10
|
+
createIdCompressor,
|
|
11
|
+
} from "@fluidframework/id-compressor/internal";
|
|
12
|
+
import type { ICodecOptions } from "../codec/index.js";
|
|
13
|
+
import {
|
|
14
|
+
type RevisionTag,
|
|
15
|
+
RevisionTagCodec,
|
|
16
|
+
TreeStoredSchemaRepository,
|
|
17
|
+
initializeForest,
|
|
18
|
+
type ITreeCursorSynchronous,
|
|
19
|
+
mapCursorField,
|
|
20
|
+
} from "../core/index.js";
|
|
21
|
+
import {
|
|
22
|
+
createNodeKeyManager,
|
|
23
|
+
makeFieldBatchCodec,
|
|
24
|
+
makeSchemaCodec,
|
|
25
|
+
type FieldBatchEncodingContext,
|
|
26
|
+
defaultSchemaPolicy,
|
|
27
|
+
chunkTree,
|
|
28
|
+
defaultChunkPolicy,
|
|
29
|
+
TreeCompressionStrategy,
|
|
30
|
+
} from "../feature-libraries/index.js";
|
|
31
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
32
|
+
import type { Format } from "../feature-libraries/schema-index/format.js";
|
|
33
|
+
import type {
|
|
34
|
+
TreeViewConfiguration,
|
|
35
|
+
ImplicitFieldSchema,
|
|
36
|
+
TreeViewAlpha,
|
|
37
|
+
} from "../simple-tree/index.js";
|
|
38
|
+
import type { JsonCompatibleReadOnly, JsonCompatible } from "../util/index.js";
|
|
39
|
+
import {
|
|
40
|
+
buildConfiguredForest,
|
|
41
|
+
defaultSharedTreeOptions,
|
|
42
|
+
type ForestOptions,
|
|
43
|
+
} from "./sharedTree.js";
|
|
44
|
+
import { createTreeCheckout } from "./treeCheckout.js";
|
|
45
|
+
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create an uninitialized {@link TreeView} that is not tied to any {@link ITree} instance.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Such a view can never experience collaboration or be persisted to to a Fluid Container.
|
|
52
|
+
*
|
|
53
|
+
* This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.
|
|
54
|
+
* @alpha
|
|
55
|
+
*/
|
|
56
|
+
export function independentView<const TSchema extends ImplicitFieldSchema>(
|
|
57
|
+
config: TreeViewConfiguration<TSchema>,
|
|
58
|
+
options: ForestOptions & { idCompressor?: IIdCompressor | undefined },
|
|
59
|
+
): TreeViewAlpha<TSchema> {
|
|
60
|
+
const idCompressor: IIdCompressor = options.idCompressor ?? createIdCompressor();
|
|
61
|
+
const mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();
|
|
62
|
+
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
63
|
+
const schema = new TreeStoredSchemaRepository();
|
|
64
|
+
const forest = buildConfiguredForest(
|
|
65
|
+
options.forest ?? defaultSharedTreeOptions.forest,
|
|
66
|
+
schema,
|
|
67
|
+
idCompressor,
|
|
68
|
+
);
|
|
69
|
+
const checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {
|
|
70
|
+
forest,
|
|
71
|
+
schema,
|
|
72
|
+
});
|
|
73
|
+
const out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(
|
|
74
|
+
checkout,
|
|
75
|
+
config,
|
|
76
|
+
createNodeKeyManager(idCompressor),
|
|
77
|
+
);
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Such a view can never experience collaboration or be persisted to to a Fluid Container.
|
|
85
|
+
*
|
|
86
|
+
* This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
export function independentInitializedView<const TSchema extends ImplicitFieldSchema>(
|
|
90
|
+
config: TreeViewConfiguration<TSchema>,
|
|
91
|
+
options: ForestOptions & ICodecOptions,
|
|
92
|
+
content: ViewContent,
|
|
93
|
+
): TreeViewAlpha<TSchema> {
|
|
94
|
+
const idCompressor: IIdCompressor = content.idCompressor;
|
|
95
|
+
const mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();
|
|
96
|
+
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
97
|
+
|
|
98
|
+
const fieldBatchCodec = makeFieldBatchCodec(options, 1);
|
|
99
|
+
const schemaCodec = makeSchemaCodec(options);
|
|
100
|
+
|
|
101
|
+
const schema = new TreeStoredSchemaRepository(schemaCodec.decode(content.schema as Format));
|
|
102
|
+
const forest = buildConfiguredForest(
|
|
103
|
+
options.forest ?? defaultSharedTreeOptions.forest,
|
|
104
|
+
schema,
|
|
105
|
+
idCompressor,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const context: FieldBatchEncodingContext = {
|
|
109
|
+
encodeType: TreeCompressionStrategy.Compressed,
|
|
110
|
+
idCompressor,
|
|
111
|
+
originatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?
|
|
112
|
+
schema: { schema, policy: defaultSchemaPolicy },
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const fieldCursors = fieldBatchCodec.decode(content.tree as JsonCompatibleReadOnly, context);
|
|
116
|
+
assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
|
|
117
|
+
// Checked above.
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
119
|
+
const cursors = fieldCursorToNodesCursors(fieldCursors[0]!);
|
|
120
|
+
|
|
121
|
+
initializeForest(forest, cursors, revisionTagCodec, idCompressor, false);
|
|
122
|
+
|
|
123
|
+
const checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {
|
|
124
|
+
forest,
|
|
125
|
+
schema,
|
|
126
|
+
});
|
|
127
|
+
const out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(
|
|
128
|
+
checkout,
|
|
129
|
+
config,
|
|
130
|
+
createNodeKeyManager(idCompressor),
|
|
131
|
+
);
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function fieldCursorToNodesCursors(
|
|
136
|
+
fieldCursor: ITreeCursorSynchronous,
|
|
137
|
+
): ITreeCursorSynchronous[] {
|
|
138
|
+
return mapCursorField(fieldCursor, copyNodeCursor);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* TODO: avoid needing this, or optimize it.
|
|
143
|
+
*/
|
|
144
|
+
function copyNodeCursor(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous {
|
|
145
|
+
const copy = chunkTree(cursor, {
|
|
146
|
+
policy: defaultChunkPolicy,
|
|
147
|
+
idCompressor: undefined,
|
|
148
|
+
}).cursor();
|
|
149
|
+
copy.enterNode(0);
|
|
150
|
+
return copy;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The portion of SharedTree data typically persisted by the container.
|
|
155
|
+
* Usable with {@link independentInitializedView} to create a {@link TreeView}
|
|
156
|
+
* without loading a container.
|
|
157
|
+
* @alpha
|
|
158
|
+
*/
|
|
159
|
+
export interface ViewContent {
|
|
160
|
+
/**
|
|
161
|
+
* Compressed tree from {@link TreeAlpha.exportCompressed}.
|
|
162
|
+
* @remarks
|
|
163
|
+
* This is an owning reference:
|
|
164
|
+
* consumers of this content might modify this data in place (for example when applying edits) to avoid copying.
|
|
165
|
+
*/
|
|
166
|
+
readonly tree: JsonCompatible<IFluidHandle>;
|
|
167
|
+
/**
|
|
168
|
+
* Persisted schema from {@link extractPersistedSchema}.
|
|
169
|
+
*/
|
|
170
|
+
readonly schema: JsonCompatible;
|
|
171
|
+
/**
|
|
172
|
+
* IIdCompressor which will be used to decompress any compressed identifiers in `tree`
|
|
173
|
+
* as well as for any other identifiers added to the view.
|
|
174
|
+
*/
|
|
175
|
+
readonly idCompressor: IIdCompressor;
|
|
176
|
+
}
|
package/src/shared-tree/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ export {
|
|
|
26
26
|
type CheckoutEvents,
|
|
27
27
|
type ITransaction,
|
|
28
28
|
type ITreeCheckoutFork,
|
|
29
|
-
type
|
|
29
|
+
type BranchableTree,
|
|
30
30
|
type TreeBranchFork,
|
|
31
31
|
} from "./treeCheckout.js";
|
|
32
32
|
|
|
@@ -46,3 +46,11 @@ export {
|
|
|
46
46
|
type RunTransaction,
|
|
47
47
|
rollback,
|
|
48
48
|
} from "./treeApi.js";
|
|
49
|
+
|
|
50
|
+
export { TreeAlpha } from "./treeApiAlpha.js";
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
independentInitializedView,
|
|
54
|
+
type ViewContent,
|
|
55
|
+
independentView,
|
|
56
|
+
} from "./independentView.js";
|
|
@@ -29,8 +29,6 @@ import {
|
|
|
29
29
|
type FieldSchema,
|
|
30
30
|
type ImplicitFieldSchema,
|
|
31
31
|
type SchemaCompatibilityStatus,
|
|
32
|
-
type InsertableTreeFieldFromImplicitField,
|
|
33
|
-
type TreeFieldFromImplicitField,
|
|
34
32
|
type TreeView,
|
|
35
33
|
type TreeViewEvents,
|
|
36
34
|
getTreeNodeForField,
|
|
@@ -43,13 +41,23 @@ import {
|
|
|
43
41
|
prepareContentForHydration,
|
|
44
42
|
comparePersistedSchemaInternal,
|
|
45
43
|
toStoredSchema,
|
|
44
|
+
type TreeViewAlpha,
|
|
45
|
+
type InsertableField,
|
|
46
|
+
type ReadableField,
|
|
47
|
+
type ReadSchema,
|
|
48
|
+
type UnsafeUnknownSchema,
|
|
49
|
+
type TreeBranch,
|
|
46
50
|
} from "../simple-tree/index.js";
|
|
47
51
|
import { Breakable, breakingClass, disposeSymbol, type WithBreakable } from "../util/index.js";
|
|
48
52
|
|
|
49
53
|
import { canInitialize, ensureSchema, initialize } from "./schematizeTree.js";
|
|
50
54
|
import type { ITreeCheckout, TreeCheckout } from "./treeCheckout.js";
|
|
51
55
|
import { CheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
|
|
52
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
HydratedContext,
|
|
58
|
+
SimpleContextSlot,
|
|
59
|
+
areImplicitFieldSchemaEqual,
|
|
60
|
+
} from "../simple-tree/index.js";
|
|
53
61
|
/**
|
|
54
62
|
* Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already
|
|
55
63
|
* exists and error if creating a second.
|
|
@@ -60,8 +68,9 @@ export const ViewSlot = anchorSlot<TreeView<ImplicitFieldSchema>>();
|
|
|
60
68
|
* Implementation of TreeView wrapping a FlexTreeView.
|
|
61
69
|
*/
|
|
62
70
|
@breakingClass
|
|
63
|
-
export class SchematizingSimpleTreeView<
|
|
64
|
-
|
|
71
|
+
export class SchematizingSimpleTreeView<
|
|
72
|
+
in out TRootSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
|
|
73
|
+
> implements TreeBranch, TreeViewAlpha<TRootSchema>, WithBreakable
|
|
65
74
|
{
|
|
66
75
|
/**
|
|
67
76
|
* The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.
|
|
@@ -96,7 +105,7 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
96
105
|
|
|
97
106
|
public constructor(
|
|
98
107
|
public readonly checkout: TreeCheckout,
|
|
99
|
-
public readonly config: TreeViewConfiguration<TRootSchema
|
|
108
|
+
public readonly config: TreeViewConfiguration<ReadSchema<TRootSchema>>,
|
|
100
109
|
public readonly nodeKeyManager: NodeKeyManager,
|
|
101
110
|
public readonly breaker: Breakable = new Breakable("SchematizingSimpleTreeView"),
|
|
102
111
|
private readonly onDispose?: () => void,
|
|
@@ -130,11 +139,17 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
130
139
|
);
|
|
131
140
|
}
|
|
132
141
|
|
|
133
|
-
public
|
|
142
|
+
public hasRootSchema<TSchema extends ImplicitFieldSchema>(
|
|
143
|
+
schema: TSchema,
|
|
144
|
+
): this is TreeViewAlpha<TSchema> {
|
|
145
|
+
return areImplicitFieldSchemaEqual(this.rootFieldSchema, schema);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public get schema(): ReadSchema<TRootSchema> {
|
|
134
149
|
return this.config.schema;
|
|
135
150
|
}
|
|
136
151
|
|
|
137
|
-
public initialize(content:
|
|
152
|
+
public initialize(content: InsertableField<TRootSchema>): void {
|
|
138
153
|
this.ensureUndisposed();
|
|
139
154
|
|
|
140
155
|
const compatibility = this.compatibility;
|
|
@@ -338,9 +353,13 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
338
353
|
this.checkout.forest.anchors.slots.delete(ViewSlot);
|
|
339
354
|
this.currentCompatibility = undefined;
|
|
340
355
|
this.onDispose?.();
|
|
356
|
+
if (this.checkout.isBranch && !this.checkout.disposed) {
|
|
357
|
+
// All (non-main) branches are 1:1 with views, so if a user manually disposes a view, we should also dispose the checkout/branch.
|
|
358
|
+
this.checkout.dispose();
|
|
359
|
+
}
|
|
341
360
|
}
|
|
342
361
|
|
|
343
|
-
public get root():
|
|
362
|
+
public get root(): ReadableField<TRootSchema> {
|
|
344
363
|
this.breaker.use();
|
|
345
364
|
if (!this.compatibility.canView) {
|
|
346
365
|
throw new UsageError(
|
|
@@ -348,10 +367,10 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
348
367
|
);
|
|
349
368
|
}
|
|
350
369
|
const view = this.getView();
|
|
351
|
-
return getTreeNodeForField(view.flexTree) as
|
|
370
|
+
return getTreeNodeForField(view.flexTree) as ReadableField<TRootSchema>;
|
|
352
371
|
}
|
|
353
372
|
|
|
354
|
-
public set root(newRoot:
|
|
373
|
+
public set root(newRoot: InsertableField<TRootSchema>) {
|
|
355
374
|
this.breaker.use();
|
|
356
375
|
if (!this.compatibility.canView) {
|
|
357
376
|
throw new UsageError(
|
|
@@ -365,6 +384,34 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
365
384
|
newRoot as InsertableContent | undefined,
|
|
366
385
|
);
|
|
367
386
|
}
|
|
387
|
+
|
|
388
|
+
// #region Branching
|
|
389
|
+
|
|
390
|
+
public fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TRootSchema> {
|
|
391
|
+
return this.checkout.branch().viewWith(this.config);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
public merge(context: TreeBranch, disposeMerged = true): void {
|
|
395
|
+
this.checkout.merge(getCheckout(context), disposeMerged);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public rebaseOnto(context: TreeBranch): void {
|
|
399
|
+
getCheckout(context).rebase(this.checkout);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// #endregion Branching
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Get the {@link TreeCheckout} associated with a given {@link TreeBranch}.
|
|
407
|
+
* @remarks Currently, all contexts are also {@link SchematizingSimpleTreeView}s.
|
|
408
|
+
* Other checkout implementations (e.g. not associated with a view) may be supported in the future.
|
|
409
|
+
*/
|
|
410
|
+
function getCheckout(context: TreeBranch): TreeCheckout {
|
|
411
|
+
if (context instanceof SchematizingSimpleTreeView) {
|
|
412
|
+
return context.checkout;
|
|
413
|
+
}
|
|
414
|
+
throw new UsageError("Unsupported context implementation");
|
|
368
415
|
}
|
|
369
416
|
|
|
370
417
|
/**
|
|
@@ -53,8 +53,11 @@ import {
|
|
|
53
53
|
import type {
|
|
54
54
|
ITree,
|
|
55
55
|
ImplicitFieldSchema,
|
|
56
|
+
ReadSchema,
|
|
56
57
|
TreeView,
|
|
58
|
+
TreeViewAlpha,
|
|
57
59
|
TreeViewConfiguration,
|
|
60
|
+
UnsafeUnknownSchema,
|
|
58
61
|
} from "../simple-tree/index.js";
|
|
59
62
|
|
|
60
63
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
@@ -65,7 +68,7 @@ import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
|
|
|
65
68
|
import {
|
|
66
69
|
type CheckoutEvents,
|
|
67
70
|
type TreeCheckout,
|
|
68
|
-
type
|
|
71
|
+
type BranchableTree,
|
|
69
72
|
createTreeCheckout,
|
|
70
73
|
} from "./treeCheckout.js";
|
|
71
74
|
import { breakingClass, throwIfBroken } from "../util/index.js";
|
|
@@ -324,10 +327,21 @@ export class SharedTree
|
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
|
|
330
|
+
// For the new TreeViewAlpha API
|
|
331
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
332
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
333
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>>;
|
|
334
|
+
|
|
335
|
+
// For the old TreeView API
|
|
327
336
|
public viewWith<TRoot extends ImplicitFieldSchema>(
|
|
328
337
|
config: TreeViewConfiguration<TRoot>,
|
|
329
|
-
): SchematizingSimpleTreeView<TRoot>
|
|
330
|
-
|
|
338
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<TRoot>;
|
|
339
|
+
|
|
340
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
341
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
342
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>> {
|
|
343
|
+
return this.checkout.viewWith(config) as SchematizingSimpleTreeView<TRoot> &
|
|
344
|
+
TreeView<ReadSchema<TRoot>>;
|
|
331
345
|
}
|
|
332
346
|
|
|
333
347
|
protected override async loadCore(services: IChannelStorageService): Promise<void> {
|
|
@@ -338,32 +352,36 @@ export class SharedTree
|
|
|
338
352
|
}
|
|
339
353
|
|
|
340
354
|
/**
|
|
341
|
-
* Get a {@link
|
|
355
|
+
* Get a {@link BranchableTree} from a {@link ITree}.
|
|
342
356
|
* @remarks The branch can be used for "version control"-style coordination of edits on the tree.
|
|
343
357
|
* @privateRemarks This function will be removed if/when the branching API becomes public,
|
|
344
358
|
* but it (or something like it) is necessary in the meantime to prevent the alpha types from being exposed as public.
|
|
345
359
|
* @alpha
|
|
360
|
+
* @deprecated This API is superseded by {@link TreeBranch}, which should be used instead.
|
|
346
361
|
*/
|
|
347
|
-
export function getBranch(tree: ITree):
|
|
362
|
+
export function getBranch(tree: ITree): BranchableTree;
|
|
348
363
|
/**
|
|
349
|
-
* Get a {@link
|
|
364
|
+
* Get a {@link BranchableTree} from a {@link TreeView}.
|
|
350
365
|
* @remarks The branch can be used for "version control"-style coordination of edits on the tree.
|
|
351
366
|
* Branches are currently an unstable "alpha" API and are subject to change in the future.
|
|
352
367
|
* @privateRemarks This function will be removed if/when the branching API becomes public,
|
|
353
368
|
* but it (or something like it) is necessary in the meantime to prevent the alpha types from being exposed as public.
|
|
354
369
|
* @alpha
|
|
370
|
+
* @deprecated This API is superseded by {@link TreeBranch}, which should be used instead.
|
|
355
371
|
*/
|
|
356
|
-
export function getBranch<T extends ImplicitFieldSchema>(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
372
|
+
export function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
373
|
+
view: TreeViewAlpha<T>,
|
|
374
|
+
): BranchableTree;
|
|
375
|
+
export function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
376
|
+
treeOrView: ITree | TreeViewAlpha<T>,
|
|
377
|
+
): BranchableTree {
|
|
360
378
|
assert(
|
|
361
379
|
treeOrView instanceof SharedTree || treeOrView instanceof SchematizingSimpleTreeView,
|
|
362
380
|
0xa48 /* Unsupported implementation */,
|
|
363
381
|
);
|
|
364
382
|
const checkout: TreeCheckout = treeOrView.checkout;
|
|
365
383
|
// This cast is safe so long as TreeCheckout supports all the operations on the branch interface.
|
|
366
|
-
return checkout as unknown as
|
|
384
|
+
return checkout as unknown as BranchableTree;
|
|
367
385
|
}
|
|
368
386
|
|
|
369
387
|
/**
|