@fluidframework/tree 2.5.0-302463 → 2.10.0-304831
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 +161 -69
- package/api-report/tree.beta.api.md +36 -37
- package/api-report/tree.legacy.alpha.api.md +35 -36
- package/api-report/tree.legacy.public.api.md +35 -36
- package/api-report/tree.public.api.md +35 -36
- 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 +3 -7
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +4 -10
- 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/core/revertible.d.ts +1 -1
- package/dist/core/revertible.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/internalTypes.d.ts +1 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.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 +13 -9
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +32 -1
- 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 +19 -17
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +16 -7
- 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 +125 -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 +3 -3
- 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 +9 -15
- 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 +5 -5
- 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 +3 -7
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +3 -8
- 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/core/revertible.d.ts +1 -1
- package/lib/core/revertible.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/internalTypes.d.ts +1 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.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 +13 -9
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +33 -2
- 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 +19 -17
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +16 -7
- 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 +125 -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 +3 -3
- 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 +9 -15
- 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 +5 -5
- 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 +26 -53
- 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 +3 -15
- package/src/core/rebase/utils.ts +35 -3
- package/src/core/revertible.ts +1 -1
- 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/internalTypes.ts +0 -1
- 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 +66 -17
- package/src/shared-tree/sharedTree.ts +29 -11
- package/src/shared-tree/treeApiAlpha.ts +401 -0
- package/src/shared-tree/treeCheckout.ts +39 -19
- 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 +148 -14
- package/src/simple-tree/api/treeApiBeta.ts +35 -35
- package/src/simple-tree/api/typesUnsafe.ts +4 -4
- package/src/simple-tree/api/verboseTree.ts +3 -0
- package/src/simple-tree/arrayNode.ts +21 -23
- 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 -2
- 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/docs/{main → user-facing}/merge-semantics.md +0 -0
- /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { createIdCompressor } from "@fluidframework/id-compressor/internal";
|
|
8
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
10
|
+
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
getKernel,
|
|
14
|
+
type TreeNode,
|
|
15
|
+
type Unhydrated,
|
|
16
|
+
TreeBeta,
|
|
17
|
+
tryGetSchema,
|
|
18
|
+
createFromCursor,
|
|
19
|
+
createFromInsertable,
|
|
20
|
+
cursorFromInsertable,
|
|
21
|
+
FieldKind,
|
|
22
|
+
normalizeFieldSchema,
|
|
23
|
+
type ImplicitFieldSchema,
|
|
24
|
+
type InsertableField,
|
|
25
|
+
type TreeFieldFromImplicitField,
|
|
26
|
+
type TreeLeafValue,
|
|
27
|
+
type UnsafeUnknownSchema,
|
|
28
|
+
conciseFromCursor,
|
|
29
|
+
type ConciseTree,
|
|
30
|
+
applySchemaToParserOptions,
|
|
31
|
+
cursorFromVerbose,
|
|
32
|
+
verboseFromCursor,
|
|
33
|
+
type ParseOptions,
|
|
34
|
+
type VerboseTree,
|
|
35
|
+
type VerboseTreeNode,
|
|
36
|
+
toStoredSchema,
|
|
37
|
+
type EncodeOptions,
|
|
38
|
+
extractPersistedSchema,
|
|
39
|
+
TreeViewConfiguration,
|
|
40
|
+
type TreeBranch,
|
|
41
|
+
} from "../simple-tree/index.js";
|
|
42
|
+
import { fail, type JsonCompatible } from "../util/index.js";
|
|
43
|
+
import { noopValidator, type FluidClientVersion, type ICodecOptions } from "../codec/index.js";
|
|
44
|
+
import type { ITreeCursorSynchronous } from "../core/index.js";
|
|
45
|
+
import {
|
|
46
|
+
cursorForMapTreeField,
|
|
47
|
+
defaultSchemaPolicy,
|
|
48
|
+
isTreeValue,
|
|
49
|
+
makeFieldBatchCodec,
|
|
50
|
+
mapTreeFromCursor,
|
|
51
|
+
TreeCompressionStrategy,
|
|
52
|
+
type FieldBatch,
|
|
53
|
+
type FieldBatchEncodingContext,
|
|
54
|
+
} from "../feature-libraries/index.js";
|
|
55
|
+
import { independentInitializedView, type ViewContent } from "./independentView.js";
|
|
56
|
+
import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Extensions to {@link Tree} and {@link TreeBeta} which are not yet stable.
|
|
60
|
+
* @sealed @alpha
|
|
61
|
+
*/
|
|
62
|
+
export const TreeAlpha: {
|
|
63
|
+
/**
|
|
64
|
+
* Retrieve the {@link TreeBranch | branch}, if any, for the given node.
|
|
65
|
+
* @param node - The node to query
|
|
66
|
+
* @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.
|
|
67
|
+
* Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).
|
|
68
|
+
*
|
|
69
|
+
* This does not fork a new branch, but rather retrieves the _existing_ branch for the node.
|
|
70
|
+
* To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.
|
|
71
|
+
*/
|
|
72
|
+
branch(node: TreeNode): TreeBranch | undefined;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Construct tree content that is compatible with the field defined by the provided `schema`.
|
|
76
|
+
* @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
|
|
77
|
+
* @param data - The data used to construct the field content.
|
|
78
|
+
* @remarks
|
|
79
|
+
* When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.
|
|
80
|
+
* This function exists as a generalization that can be used in other cases as well,
|
|
81
|
+
* such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.
|
|
82
|
+
*
|
|
83
|
+
* Like with {@link TreeNodeSchemaClass}'s constructor, it's an error to provide an existing node to this API.
|
|
84
|
+
* For that case, use {@link TreeBeta.clone}.
|
|
85
|
+
* @privateRemarks
|
|
86
|
+
* There should be a way to provide a source for defaulted identifiers, wither via this API or some way to add them to its output later.
|
|
87
|
+
*/
|
|
88
|
+
create<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
89
|
+
schema: UnsafeUnknownSchema extends TSchema
|
|
90
|
+
? ImplicitFieldSchema
|
|
91
|
+
: TSchema & ImplicitFieldSchema,
|
|
92
|
+
data: InsertableField<TSchema>,
|
|
93
|
+
): Unhydrated<
|
|
94
|
+
TSchema extends ImplicitFieldSchema
|
|
95
|
+
? TreeFieldFromImplicitField<TSchema>
|
|
96
|
+
: TreeNode | TreeLeafValue | undefined
|
|
97
|
+
>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Less type safe version of {@link TreeAlpha.create}, suitable for importing data.
|
|
101
|
+
* @remarks
|
|
102
|
+
* Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.
|
|
103
|
+
* This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.
|
|
104
|
+
* Use "compressed" or "verbose" formats for more flexibility.
|
|
105
|
+
*
|
|
106
|
+
* When using this function,
|
|
107
|
+
* it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.
|
|
108
|
+
* If the schema is ambiguous, consider using {@link TreeAlpha.create} and {@link Unhydrated} nodes where needed,
|
|
109
|
+
* or using {@link TreeAlpha.(importVerbose:1)} and specify all types.
|
|
110
|
+
*
|
|
111
|
+
* Documented (and thus recoverable) error handling/reporting for this is not yet implemented,
|
|
112
|
+
* but for now most invalid inputs will throw a recoverable error.
|
|
113
|
+
*/
|
|
114
|
+
importConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
115
|
+
schema: UnsafeUnknownSchema extends TSchema
|
|
116
|
+
? ImplicitFieldSchema
|
|
117
|
+
: TSchema & ImplicitFieldSchema,
|
|
118
|
+
data: ConciseTree | undefined,
|
|
119
|
+
): Unhydrated<
|
|
120
|
+
TSchema extends ImplicitFieldSchema
|
|
121
|
+
? TreeFieldFromImplicitField<TSchema>
|
|
122
|
+
: TreeNode | TreeLeafValue | undefined
|
|
123
|
+
>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Construct tree content compatible with a field defined by the provided `schema`.
|
|
127
|
+
* @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
|
|
128
|
+
* @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:1)}.
|
|
129
|
+
* @remarks
|
|
130
|
+
* This overload requires that any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} are encoded as actual {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input.
|
|
131
|
+
*/
|
|
132
|
+
importVerbose<const TSchema extends ImplicitFieldSchema>(
|
|
133
|
+
schema: TSchema,
|
|
134
|
+
data: VerboseTree | undefined,
|
|
135
|
+
options?: Partial<ParseOptions<IFluidHandle>>,
|
|
136
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Construct tree content compatible with a field defined by the provided `schema`.
|
|
140
|
+
* @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
|
|
141
|
+
* @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:2)}.
|
|
142
|
+
*
|
|
143
|
+
* @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input `data` are encoded.
|
|
144
|
+
* A converter from this encoding to {@link @fluidframework/core-interfaces#IFluidHandle} is required in `options`.
|
|
145
|
+
*/
|
|
146
|
+
importVerbose<const TSchema extends ImplicitFieldSchema, THandle>(
|
|
147
|
+
schema: TSchema,
|
|
148
|
+
data: VerboseTree<THandle> | undefined,
|
|
149
|
+
options: ParseOptions<THandle>,
|
|
150
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Same as {@link TreeAlpha.(exportConcise:2)}, except leaves handles as is.
|
|
154
|
+
*/
|
|
155
|
+
exportConcise(
|
|
156
|
+
node: TreeNode | TreeLeafValue,
|
|
157
|
+
options?: Partial<EncodeOptions<IFluidHandle>>,
|
|
158
|
+
): ConciseTree;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.
|
|
162
|
+
*
|
|
163
|
+
* @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.
|
|
164
|
+
* A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.
|
|
165
|
+
*/
|
|
166
|
+
exportConcise<THandle>(
|
|
167
|
+
node: TreeNode | TreeLeafValue,
|
|
168
|
+
options: EncodeOptions<THandle>,
|
|
169
|
+
): ConciseTree<THandle>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Same {@link TreeAlpha.(exportVerbose:2)} except leaves handles as is.
|
|
173
|
+
*/
|
|
174
|
+
exportVerbose(
|
|
175
|
+
node: TreeNode | TreeLeafValue,
|
|
176
|
+
options?: Partial<EncodeOptions<IFluidHandle>>,
|
|
177
|
+
): VerboseTree;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object.
|
|
181
|
+
* Verbose tree format, with explicit type on every node.
|
|
182
|
+
*
|
|
183
|
+
* @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.
|
|
184
|
+
* A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* There are several cases this may be preferred to {@link TreeAlpha.(exportConcise:2)}:
|
|
188
|
+
*
|
|
189
|
+
* 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).
|
|
190
|
+
* `exportVerbose` will always be unambiguous and thus lossless.
|
|
191
|
+
*
|
|
192
|
+
* 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.
|
|
193
|
+
*
|
|
194
|
+
* 3. When easy access to the type is desired.
|
|
195
|
+
*/
|
|
196
|
+
exportVerbose<T>(node: TreeNode | TreeLeafValue, options: EncodeOptions<T>): VerboseTree<T>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Export the content of the provided `tree` in a compressed JSON compatible format.
|
|
200
|
+
* @remarks
|
|
201
|
+
* If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.
|
|
202
|
+
*
|
|
203
|
+
* Always uses "stored" keys.
|
|
204
|
+
* See {@link EncodeOptions.useStoredKeys} for details.
|
|
205
|
+
* @privateRemarks
|
|
206
|
+
* TODO: It is currently not clear how to work with the idCompressors correctly in the package API.
|
|
207
|
+
* Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,
|
|
208
|
+
* Nor get the correct idCompressor from a subtree to use when exporting it.
|
|
209
|
+
* Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.
|
|
210
|
+
* It would probably make more sense if we provided a way to get an idCompressor from the context of a node,
|
|
211
|
+
* which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.
|
|
212
|
+
* Add in a stable public APi for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.
|
|
213
|
+
*/
|
|
214
|
+
exportCompressed(
|
|
215
|
+
tree: TreeNode | TreeLeafValue,
|
|
216
|
+
options: { oldestCompatibleClient: FluidClientVersion; idCompressor?: IIdCompressor },
|
|
217
|
+
): JsonCompatible<IFluidHandle>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Import data encoded by {@link TreeAlpha.exportCompressed}.
|
|
221
|
+
*
|
|
222
|
+
* @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.
|
|
223
|
+
* @param compressedData - Data compressed by {@link TreeAlpha.exportCompressed}.
|
|
224
|
+
* @param options - If {@link TreeAlpha.exportCompressed} was given an `idCompressor`, it must be provided here.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.
|
|
228
|
+
*
|
|
229
|
+
* @privateRemarks
|
|
230
|
+
* This API could be improved:
|
|
231
|
+
*
|
|
232
|
+
* 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a "try" version).
|
|
233
|
+
* 2. A "try" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).
|
|
234
|
+
* 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.
|
|
235
|
+
*/
|
|
236
|
+
importCompressed<const TSchema extends ImplicitFieldSchema>(
|
|
237
|
+
schema: TSchema,
|
|
238
|
+
compressedData: JsonCompatible<IFluidHandle>,
|
|
239
|
+
options: { idCompressor?: IIdCompressor } & ICodecOptions,
|
|
240
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
241
|
+
} = {
|
|
242
|
+
branch(node: TreeNode): TreeBranch | undefined {
|
|
243
|
+
const kernel = getKernel(node);
|
|
244
|
+
if (!kernel.isHydrated()) {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
const view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);
|
|
248
|
+
assert(
|
|
249
|
+
view instanceof SchematizingSimpleTreeView,
|
|
250
|
+
0xa5c /* Unexpected view implementation */,
|
|
251
|
+
);
|
|
252
|
+
return view;
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
create: createFromInsertable,
|
|
256
|
+
|
|
257
|
+
importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
258
|
+
schema: UnsafeUnknownSchema extends TSchema
|
|
259
|
+
? ImplicitFieldSchema
|
|
260
|
+
: TSchema & ImplicitFieldSchema,
|
|
261
|
+
data: ConciseTree | undefined,
|
|
262
|
+
): Unhydrated<
|
|
263
|
+
TSchema extends ImplicitFieldSchema
|
|
264
|
+
? TreeFieldFromImplicitField<TSchema>
|
|
265
|
+
: TreeNode | TreeLeafValue | undefined
|
|
266
|
+
> {
|
|
267
|
+
return createFromInsertable<UnsafeUnknownSchema>(
|
|
268
|
+
schema,
|
|
269
|
+
data as InsertableField<UnsafeUnknownSchema>,
|
|
270
|
+
) as Unhydrated<
|
|
271
|
+
TSchema extends ImplicitFieldSchema
|
|
272
|
+
? TreeFieldFromImplicitField<TSchema>
|
|
273
|
+
: TreeNode | TreeLeafValue | undefined
|
|
274
|
+
>;
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
importVerbose<const TSchema extends ImplicitFieldSchema, THandle>(
|
|
278
|
+
schema: TSchema,
|
|
279
|
+
data: VerboseTree<THandle> | undefined,
|
|
280
|
+
options?: Partial<ParseOptions<THandle>>,
|
|
281
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
282
|
+
const config: ParseOptions<THandle> = {
|
|
283
|
+
valueConverter: (input: VerboseTree<THandle>) => {
|
|
284
|
+
return input as TreeLeafValue | VerboseTreeNode<THandle>;
|
|
285
|
+
},
|
|
286
|
+
...options,
|
|
287
|
+
};
|
|
288
|
+
// Create a config which is standalone, and thus can be used without having to refer back to the schema.
|
|
289
|
+
const schemalessConfig = applySchemaToParserOptions(schema, config);
|
|
290
|
+
if (data === undefined) {
|
|
291
|
+
const field = normalizeFieldSchema(schema);
|
|
292
|
+
if (field.kind !== FieldKind.Optional) {
|
|
293
|
+
throw new UsageError("undefined provided for non-optional field.");
|
|
294
|
+
}
|
|
295
|
+
return undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
296
|
+
}
|
|
297
|
+
const cursor = cursorFromVerbose<THandle>(data, schemalessConfig);
|
|
298
|
+
return createFromCursor(schema, cursor);
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
exportConcise<T>(
|
|
302
|
+
node: TreeNode | TreeLeafValue,
|
|
303
|
+
options?: Partial<EncodeOptions<T>>,
|
|
304
|
+
): ConciseTree<T> {
|
|
305
|
+
const config: EncodeOptions<T> = {
|
|
306
|
+
valueConverter(handle: IFluidHandle): T {
|
|
307
|
+
return handle as T;
|
|
308
|
+
},
|
|
309
|
+
...options,
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const cursor = borrowCursorFromTreeNodeOrValue(node);
|
|
313
|
+
return conciseFromCursor(cursor, tryGetSchema(node) ?? fail("invalid input"), config);
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
exportVerbose<T>(
|
|
317
|
+
node: TreeNode | TreeLeafValue,
|
|
318
|
+
options?: Partial<EncodeOptions<T>>,
|
|
319
|
+
): VerboseTree<T> {
|
|
320
|
+
const config: EncodeOptions<T> = {
|
|
321
|
+
valueConverter(handle: IFluidHandle): T {
|
|
322
|
+
return handle as T;
|
|
323
|
+
},
|
|
324
|
+
...options,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const cursor = borrowCursorFromTreeNodeOrValue(node);
|
|
328
|
+
return verboseFromCursor(cursor, tryGetSchema(node) ?? fail("invalid input"), config);
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
exportCompressed(
|
|
332
|
+
node: TreeNode | TreeLeafValue,
|
|
333
|
+
options: {
|
|
334
|
+
oldestCompatibleClient: FluidClientVersion;
|
|
335
|
+
idCompressor?: IIdCompressor;
|
|
336
|
+
},
|
|
337
|
+
): JsonCompatible<IFluidHandle> {
|
|
338
|
+
const schema = tryGetSchema(node) ?? fail("invalid input");
|
|
339
|
+
const format = versionToFormat[options.oldestCompatibleClient];
|
|
340
|
+
const codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);
|
|
341
|
+
const cursor = borrowFieldCursorFromTreeNodeOrValue(node);
|
|
342
|
+
const batch: FieldBatch = [cursor];
|
|
343
|
+
// If none provided, create a compressor which will not compress anything.
|
|
344
|
+
const idCompressor = options.idCompressor ?? createIdCompressor();
|
|
345
|
+
const context: FieldBatchEncodingContext = {
|
|
346
|
+
encodeType: TreeCompressionStrategy.Compressed,
|
|
347
|
+
idCompressor,
|
|
348
|
+
originatorId: idCompressor.localSessionId, // TODO: Why is this needed?
|
|
349
|
+
schema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },
|
|
350
|
+
};
|
|
351
|
+
const result = codec.encode(batch, context);
|
|
352
|
+
return result;
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
importCompressed<const TSchema extends ImplicitFieldSchema>(
|
|
356
|
+
schema: TSchema,
|
|
357
|
+
compressedData: JsonCompatible<IFluidHandle>,
|
|
358
|
+
options: {
|
|
359
|
+
idCompressor?: IIdCompressor;
|
|
360
|
+
} & ICodecOptions,
|
|
361
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
362
|
+
const content: ViewContent = {
|
|
363
|
+
schema: extractPersistedSchema(schema),
|
|
364
|
+
tree: compressedData,
|
|
365
|
+
idCompressor: options.idCompressor ?? createIdCompressor(),
|
|
366
|
+
};
|
|
367
|
+
const config = new TreeViewConfiguration({ schema });
|
|
368
|
+
const view = independentInitializedView(config, options, content);
|
|
369
|
+
return TreeBeta.clone<TSchema>(view.root);
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
function borrowCursorFromTreeNodeOrValue(
|
|
374
|
+
node: TreeNode | TreeLeafValue,
|
|
375
|
+
): ITreeCursorSynchronous {
|
|
376
|
+
if (isTreeValue(node)) {
|
|
377
|
+
return cursorFromInsertable<UnsafeUnknownSchema>(
|
|
378
|
+
tryGetSchema(node) ?? fail("missing schema"),
|
|
379
|
+
node,
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
const kernel = getKernel(node);
|
|
383
|
+
const cursor = kernel.getOrCreateInnerNode().borrowCursor();
|
|
384
|
+
return cursor;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function borrowFieldCursorFromTreeNodeOrValue(
|
|
388
|
+
node: TreeNode | TreeLeafValue,
|
|
389
|
+
): ITreeCursorSynchronous {
|
|
390
|
+
const cursor = borrowCursorFromTreeNodeOrValue(node);
|
|
391
|
+
// TODO: avoid copy
|
|
392
|
+
const mapTree = mapTreeFromCursor(cursor);
|
|
393
|
+
return cursorForMapTreeField([mapTree]);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const versionToFormat = {
|
|
397
|
+
v2_0: 1,
|
|
398
|
+
v2_1: 1,
|
|
399
|
+
v2_2: 1,
|
|
400
|
+
v2_3: 1,
|
|
401
|
+
};
|
|
@@ -63,8 +63,10 @@ import type { ISharedTreeEditor, SharedTreeEditBuilder } from "./sharedTreeEditB
|
|
|
63
63
|
import type { IDisposable } from "@fluidframework/core-interfaces";
|
|
64
64
|
import type {
|
|
65
65
|
ImplicitFieldSchema,
|
|
66
|
+
ReadSchema,
|
|
66
67
|
TreeView,
|
|
67
68
|
TreeViewConfiguration,
|
|
69
|
+
UnsafeUnknownSchema,
|
|
68
70
|
ViewableTree,
|
|
69
71
|
} from "../simple-tree/index.js";
|
|
70
72
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
@@ -83,18 +85,14 @@ export interface CheckoutEvents {
|
|
|
83
85
|
afterBatch(): void;
|
|
84
86
|
|
|
85
87
|
/**
|
|
86
|
-
* Fired when a
|
|
88
|
+
* Fired when a change is made to the branch. Includes data about the change that is made which listeners
|
|
89
|
+
* can use to filter on changes they care about e.g. local vs remote changes.
|
|
87
90
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @param revertible - The revertible that can be used to revert the change.
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* {@inheritdoc TreeViewEvents.commitApplied}
|
|
91
|
+
* @param data - information about the change
|
|
92
|
+
* @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,
|
|
93
|
+
* this change is not revertible.
|
|
96
94
|
*/
|
|
97
|
-
|
|
95
|
+
changed(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
/**
|
|
@@ -104,7 +102,7 @@ export interface CheckoutEvents {
|
|
|
104
102
|
* Changes may be synchronized across branches via merge and rebase operations provided on the branch object.
|
|
105
103
|
* @alpha @sealed
|
|
106
104
|
*/
|
|
107
|
-
export interface
|
|
105
|
+
export interface BranchableTree extends ViewableTree {
|
|
108
106
|
/**
|
|
109
107
|
* Spawn a new branch which is based off of the current state of this branch.
|
|
110
108
|
* Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.
|
|
@@ -116,7 +114,7 @@ export interface TreeBranch extends ViewableTree {
|
|
|
116
114
|
* @param view - a branch which was created by a call to `branch()`.
|
|
117
115
|
* It is automatically disposed after the merge completes.
|
|
118
116
|
* @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.
|
|
119
|
-
* A "
|
|
117
|
+
* A "changed" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.
|
|
120
118
|
*/
|
|
121
119
|
merge(branch: TreeBranchFork): void;
|
|
122
120
|
|
|
@@ -136,16 +134,16 @@ export interface TreeBranch extends ViewableTree {
|
|
|
136
134
|
}
|
|
137
135
|
|
|
138
136
|
/**
|
|
139
|
-
* A {@link
|
|
137
|
+
* A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.
|
|
140
138
|
* @remarks This branch should be disposed when it is no longer needed in order to free resources.
|
|
141
139
|
* @alpha @sealed
|
|
142
140
|
*/
|
|
143
|
-
export interface TreeBranchFork extends
|
|
141
|
+
export interface TreeBranchFork extends BranchableTree, IDisposable {
|
|
144
142
|
/**
|
|
145
143
|
* Rebase the changes that have been applied to this branch over all the new changes in the given branch.
|
|
146
144
|
* @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.
|
|
147
145
|
*/
|
|
148
|
-
rebaseOnto(branch:
|
|
146
|
+
rebaseOnto(branch: BranchableTree): void;
|
|
149
147
|
}
|
|
150
148
|
|
|
151
149
|
/**
|
|
@@ -283,6 +281,7 @@ export function createTreeCheckout(
|
|
|
283
281
|
return new TreeCheckout(
|
|
284
282
|
transaction,
|
|
285
283
|
branch,
|
|
284
|
+
false,
|
|
286
285
|
changeFamily,
|
|
287
286
|
schema,
|
|
288
287
|
forest,
|
|
@@ -424,6 +423,8 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
424
423
|
public constructor(
|
|
425
424
|
public readonly transaction: ITransaction,
|
|
426
425
|
private readonly _branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,
|
|
426
|
+
/** True if and only if this checkout is for a forked branch and not the "main branch" of the tree. */
|
|
427
|
+
public readonly isBranch: boolean,
|
|
427
428
|
private readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,
|
|
428
429
|
public readonly storedSchema: TreeStoredSchemaRepository,
|
|
429
430
|
public readonly forest: IEditableForest,
|
|
@@ -527,12 +528,12 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
527
528
|
: (onRevertibleDisposed?: (revertible: Revertible) => void) => {
|
|
528
529
|
if (!withinEventContext) {
|
|
529
530
|
throw new UsageError(
|
|
530
|
-
"Cannot get a revertible outside of the context of a
|
|
531
|
+
"Cannot get a revertible outside of the context of a changed event.",
|
|
531
532
|
);
|
|
532
533
|
}
|
|
533
534
|
if (this.revertibleCommitBranches.get(revision) !== undefined) {
|
|
534
535
|
throw new UsageError(
|
|
535
|
-
"Cannot generate the same revertible more than once. Note that this can happen when multiple
|
|
536
|
+
"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.",
|
|
536
537
|
);
|
|
537
538
|
}
|
|
538
539
|
const revertibleCommits = this.revertibleCommitBranches;
|
|
@@ -577,9 +578,12 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
577
578
|
};
|
|
578
579
|
|
|
579
580
|
let withinEventContext = true;
|
|
580
|
-
this.events.emit("
|
|
581
|
+
this.events.emit("changed", { isLocal: true, kind }, getRevertible);
|
|
581
582
|
withinEventContext = false;
|
|
582
583
|
}
|
|
584
|
+
} else if (event.type === "replace") {
|
|
585
|
+
// TODO: figure out how to plumb through commit kind info for remote changes
|
|
586
|
+
this.events.emit("changed", { isLocal: false, kind: CommitKind.Default });
|
|
583
587
|
}
|
|
584
588
|
}
|
|
585
589
|
});
|
|
@@ -622,8 +626,18 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
622
626
|
}
|
|
623
627
|
}
|
|
624
628
|
|
|
629
|
+
// For the new TreeViewAlpha API
|
|
630
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
631
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
632
|
+
): SchematizingSimpleTreeView<TRoot>;
|
|
633
|
+
|
|
634
|
+
// For the old TreeView API
|
|
625
635
|
public viewWith<TRoot extends ImplicitFieldSchema>(
|
|
626
636
|
config: TreeViewConfiguration<TRoot>,
|
|
637
|
+
): TreeView<TRoot>;
|
|
638
|
+
|
|
639
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
640
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
627
641
|
): SchematizingSimpleTreeView<TRoot> {
|
|
628
642
|
const view = new SchematizingSimpleTreeView(
|
|
629
643
|
this,
|
|
@@ -664,6 +678,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
664
678
|
return new TreeCheckout(
|
|
665
679
|
transaction,
|
|
666
680
|
branch,
|
|
681
|
+
true,
|
|
667
682
|
this.changeFamily,
|
|
668
683
|
storedSchema,
|
|
669
684
|
forest,
|
|
@@ -688,6 +703,10 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
688
703
|
!checkout.transaction.inProgress(),
|
|
689
704
|
0x9af /* A view cannot be rebased while it has a pending transaction */,
|
|
690
705
|
);
|
|
706
|
+
assert(
|
|
707
|
+
checkout.isBranch,
|
|
708
|
+
0xa5d /* The main branch cannot be rebased onto another branch. */,
|
|
709
|
+
);
|
|
691
710
|
checkout._branch.rebaseOnto(this._branch);
|
|
692
711
|
}
|
|
693
712
|
|
|
@@ -715,7 +734,8 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
715
734
|
checkout.transaction.commit();
|
|
716
735
|
}
|
|
717
736
|
this._branch.merge(checkout._branch);
|
|
718
|
-
if (disposeMerged) {
|
|
737
|
+
if (disposeMerged && checkout.isBranch) {
|
|
738
|
+
// Dispose the merged checkout unless it is the main branch.
|
|
719
739
|
checkout[disposeSymbol]();
|
|
720
740
|
}
|
|
721
741
|
}
|