@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
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import type { Format } from "../../feature-libraries/schema-index/index.js";
|
|
15
15
|
import type { JsonCompatible } from "../../util/index.js";
|
|
16
16
|
import type { ImplicitFieldSchema } from "../schemaTypes.js";
|
|
17
|
-
import { toStoredSchema } from "../
|
|
17
|
+
import { toStoredSchema } from "../toStoredSchema.js";
|
|
18
18
|
import type { SchemaCompatibilityStatus } from "./tree.js";
|
|
19
19
|
import { ViewSchema } from "./view.js";
|
|
20
20
|
|
|
@@ -13,13 +13,14 @@ import {
|
|
|
13
13
|
type ImplicitFieldSchema,
|
|
14
14
|
type InsertableField,
|
|
15
15
|
type InsertableTreeFieldFromImplicitField,
|
|
16
|
+
type ReadableField,
|
|
17
|
+
type ReadSchema,
|
|
16
18
|
type TreeFieldFromImplicitField,
|
|
17
|
-
type TreeLeafValue,
|
|
18
19
|
type UnsafeUnknownSchema,
|
|
19
20
|
FieldKind,
|
|
20
21
|
} from "../schemaTypes.js";
|
|
21
|
-
import { NodeKind, type
|
|
22
|
-
import { toStoredSchema } from "../
|
|
22
|
+
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
23
|
+
import { toStoredSchema } from "../toStoredSchema.js";
|
|
23
24
|
import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
24
25
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
25
26
|
import { isObjectNodeSchema, type ObjectNodeSchema } from "../objectNodeTypes.js";
|
|
@@ -29,6 +30,14 @@ import type { MakeNominal } from "../../util/index.js";
|
|
|
29
30
|
import { walkFieldSchema } from "../walkFieldSchema.js";
|
|
30
31
|
/**
|
|
31
32
|
* A tree from which a {@link TreeView} can be created.
|
|
33
|
+
*
|
|
34
|
+
* @privateRemarks
|
|
35
|
+
* TODO:
|
|
36
|
+
* Add stored key versions of {@link TreeAlpha.(exportVerbose:2)}, {@link TreeAlpha.(exportConcise:2)} and {@link TreeAlpha.exportCompressed} here so tree content can be accessed without a view schema.
|
|
37
|
+
* Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).
|
|
38
|
+
* Maybe rename "exportJsonSchema" to align on "concise" terminology.
|
|
39
|
+
* Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).
|
|
40
|
+
* Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).
|
|
32
41
|
* @system @sealed @public
|
|
33
42
|
*/
|
|
34
43
|
export interface ViewableTree {
|
|
@@ -48,7 +57,7 @@ export interface ViewableTree {
|
|
|
48
57
|
* Only one schematized view may exist for a given ITree at a time.
|
|
49
58
|
* If creating a second, the first must be disposed before calling `viewWith` again.
|
|
50
59
|
*
|
|
51
|
-
*
|
|
60
|
+
*
|
|
52
61
|
* TODO: Provide a way to make a generic view schema for any document.
|
|
53
62
|
* TODO: Support adapters for handling out-of-schema data.
|
|
54
63
|
*
|
|
@@ -242,7 +251,7 @@ export class TreeViewConfiguration<
|
|
|
242
251
|
if (ambiguityErrors.length !== 0) {
|
|
243
252
|
// Duplicate errors are common since when two types conflict, both orders error:
|
|
244
253
|
const deduplicated = new Set(ambiguityErrors);
|
|
245
|
-
throw new UsageError(`
|
|
254
|
+
throw new UsageError(`Ambiguous schema found:\n${[...deduplicated].join("\n")}`);
|
|
246
255
|
}
|
|
247
256
|
|
|
248
257
|
// Eagerly perform this conversion to surface errors sooner.
|
|
@@ -350,6 +359,84 @@ export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): v
|
|
|
350
359
|
}
|
|
351
360
|
}
|
|
352
361
|
|
|
362
|
+
/**
|
|
363
|
+
* A collection of functionality associated with a (version-control-style) branch of a SharedTree.
|
|
364
|
+
* @remarks A `TreeBranch` allows for the {@link TreeBranch.fork | creation of branches} and for those branches to later be {@link TreeBranch.merge | merged}.
|
|
365
|
+
*
|
|
366
|
+
* The `TreeBranch` for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.branch`.
|
|
367
|
+
*
|
|
368
|
+
* A branch does not necessarily know the schema of its SharedTree - to convert a branch to a {@link TreeViewAlpha | view with a schema}, use {@link TreeBranch.hasRootSchema | hasRootSchema()}.
|
|
369
|
+
*
|
|
370
|
+
* The branch associated directly with the {@link ITree | SharedTree} is the "main" branch, and all other branches fork (directly or transitively) from that main branch.
|
|
371
|
+
* @sealed @alpha
|
|
372
|
+
*/
|
|
373
|
+
export interface TreeBranch extends IDisposable {
|
|
374
|
+
/**
|
|
375
|
+
* Events for the branch
|
|
376
|
+
*/
|
|
377
|
+
readonly events: Listenable<TreeBranchEvents>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Returns true if this branch has the given schema as its root schema.
|
|
381
|
+
* @remarks This is a type guard which allows this branch to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.
|
|
382
|
+
*
|
|
383
|
+
* To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.
|
|
384
|
+
* For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* if (branch.hasRootSchema(MySchema)) {
|
|
388
|
+
* const { root } = branch; // `branch` is now a TreeViewAlpha<MySchema>
|
|
389
|
+
* // ...
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
hasRootSchema<TSchema extends ImplicitFieldSchema>(
|
|
394
|
+
schema: TSchema,
|
|
395
|
+
): this is TreeViewAlpha<TSchema>;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Fork a new branch off of this branch which is based off of this branch's current state.
|
|
399
|
+
* @remarks Any changes to the tree on the new branch will not apply to this branch until the new branch is e.g. {@link TreeBranch.merge | merged} back into this branch.
|
|
400
|
+
* The branch should be disposed when no longer needed, either {@link TreeBranch.dispose | explicitly} or {@link TreeBranch.merge | implicitly when merging} into another branch.
|
|
401
|
+
*/
|
|
402
|
+
fork(): TreeBranch;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Apply all the new changes on the given branch to this branch.
|
|
406
|
+
* @param branch - a branch which was created by a call to `branch()`.
|
|
407
|
+
* @param disposeMerged - whether or not to dispose `branch` after the merge completes.
|
|
408
|
+
* Defaults to true.
|
|
409
|
+
* The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.
|
|
410
|
+
* @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.
|
|
411
|
+
*/
|
|
412
|
+
merge(branch: TreeBranch, disposeMerged?: boolean): void;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Advance this branch forward such that all new changes on the target branch become part of this branch.
|
|
416
|
+
* @param branch - The branch to rebase onto.
|
|
417
|
+
* @remarks After rebasing, this branch will be "ahead" of the target branch, that is, its unique changes will have been recreated as if they happened after all changes on the target branch.
|
|
418
|
+
* This method may only be called on branches produced via {@link TreeBranch.fork | branch} - attempting to rebase the main branch will throw.
|
|
419
|
+
*
|
|
420
|
+
* Rebasing long-lived branches is important to avoid consuming memory unnecessarily.
|
|
421
|
+
* In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" branch was created or last rebased.
|
|
422
|
+
*
|
|
423
|
+
* The {@link TreeBranch | main branch} cannot be rebased onto another branch - attempting to do so will throw an error.
|
|
424
|
+
*/
|
|
425
|
+
rebaseOnto(branch: TreeBranch): void;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Dispose of this branch, cleaning up any resources associated with it.
|
|
429
|
+
* @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.
|
|
430
|
+
* @remarks Branches can also be automatically disposed when {@link TreeBranch.merge | they are merged} into another branch.
|
|
431
|
+
*
|
|
432
|
+
* Disposing branches is important to avoid consuming memory unnecessarily.
|
|
433
|
+
* In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" branch was created or last {@link TreeBranch.rebaseOnto | rebased}.
|
|
434
|
+
*
|
|
435
|
+
* The {@link TreeBranch | main branch} cannot be disposed - attempting to do so will have no effect.
|
|
436
|
+
*/
|
|
437
|
+
dispose(error?: Error): void;
|
|
438
|
+
}
|
|
439
|
+
|
|
353
440
|
/**
|
|
354
441
|
* An editable view of a (version control style) branch of a shared tree based on some schema.
|
|
355
442
|
*
|
|
@@ -430,21 +517,22 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
|
|
|
430
517
|
|
|
431
518
|
/**
|
|
432
519
|
* {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.
|
|
433
|
-
* @alpha
|
|
520
|
+
* @sealed @alpha
|
|
434
521
|
*/
|
|
435
522
|
export interface TreeViewAlpha<
|
|
436
523
|
in out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
|
|
437
|
-
> extends Omit<
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
> {
|
|
441
|
-
get root(): TSchema extends ImplicitFieldSchema
|
|
442
|
-
? TreeFieldFromImplicitField<TSchema>
|
|
443
|
-
: TreeLeafValue | TreeNode;
|
|
524
|
+
> extends Omit<TreeView<ReadSchema<TSchema>>, "root" | "initialize">,
|
|
525
|
+
TreeBranch {
|
|
526
|
+
get root(): ReadableField<TSchema>;
|
|
444
527
|
|
|
445
528
|
set root(newRoot: InsertableField<TSchema>);
|
|
446
529
|
|
|
530
|
+
readonly events: Listenable<TreeViewEvents & TreeBranchEvents>;
|
|
531
|
+
|
|
447
532
|
initialize(content: InsertableField<TSchema>): void;
|
|
533
|
+
|
|
534
|
+
// Override the base branch method to return a typed view rather than merely a branch.
|
|
535
|
+
fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TSchema>;
|
|
448
536
|
}
|
|
449
537
|
|
|
450
538
|
/**
|
|
@@ -514,7 +602,7 @@ export interface SchemaCompatibilityStatus {
|
|
|
514
602
|
*
|
|
515
603
|
* @remarks
|
|
516
604
|
* It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from
|
|
517
|
-
*
|
|
605
|
+
* branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.
|
|
518
606
|
*/
|
|
519
607
|
readonly canInitialize: boolean;
|
|
520
608
|
|
|
@@ -523,6 +611,42 @@ export interface SchemaCompatibilityStatus {
|
|
|
523
611
|
// - details about the differences between the stored and view schema sufficient for implementing "safe mismatch" policies
|
|
524
612
|
}
|
|
525
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Events for {@link TreeBranch}.
|
|
616
|
+
* @sealed @alpha
|
|
617
|
+
*/
|
|
618
|
+
export interface TreeBranchEvents {
|
|
619
|
+
/**
|
|
620
|
+
* The stored schema for the document has changed.
|
|
621
|
+
*/
|
|
622
|
+
schemaChanged(): void;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Fired when a change is made to the branch. Includes data about the change that is made which listeners
|
|
626
|
+
* can use to filter on changes they care about (e.g. local vs. remote changes).
|
|
627
|
+
*
|
|
628
|
+
* @param data - information about the change
|
|
629
|
+
* @param getRevertible - a function that allows users to get a revertible for the change. If not provided,
|
|
630
|
+
* this change is not revertible.
|
|
631
|
+
*/
|
|
632
|
+
changed(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Fired when:
|
|
636
|
+
* - a local commit is applied outside of a transaction
|
|
637
|
+
* - a local transaction is committed
|
|
638
|
+
*
|
|
639
|
+
* The event is not fired when:
|
|
640
|
+
* - a local commit is applied within a transaction
|
|
641
|
+
* - a remote commit is applied
|
|
642
|
+
*
|
|
643
|
+
* @param data - information about the commit that was applied
|
|
644
|
+
* @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,
|
|
645
|
+
* this commit is not revertible.
|
|
646
|
+
*/
|
|
647
|
+
commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
648
|
+
}
|
|
649
|
+
|
|
526
650
|
/**
|
|
527
651
|
* Events for {@link TreeView}.
|
|
528
652
|
* @sealed @public
|
|
@@ -562,3 +686,13 @@ export interface TreeViewEvents {
|
|
|
562
686
|
*/
|
|
563
687
|
commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
|
|
564
688
|
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.
|
|
692
|
+
* @alpha
|
|
693
|
+
*/
|
|
694
|
+
export function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(
|
|
695
|
+
view: TreeView<TSchema>,
|
|
696
|
+
): TreeViewAlpha<TSchema> {
|
|
697
|
+
return view as TreeViewAlpha<TSchema>;
|
|
698
|
+
}
|
|
@@ -12,14 +12,9 @@ import {
|
|
|
12
12
|
type Unhydrated,
|
|
13
13
|
type WithType,
|
|
14
14
|
} from "../core/index.js";
|
|
15
|
-
import type {
|
|
16
|
-
ImplicitFieldSchema,
|
|
17
|
-
TreeFieldFromImplicitField,
|
|
18
|
-
UnsafeUnknownSchema,
|
|
19
|
-
} from "../schemaTypes.js";
|
|
20
15
|
import { treeNodeApi } from "./treeNodeApi.js";
|
|
21
|
-
import { createFromCursor
|
|
22
|
-
import type {
|
|
16
|
+
import { createFromCursor } from "./create.js";
|
|
17
|
+
import type { ImplicitFieldSchema, TreeFieldFromImplicitField } from "../schemaTypes.js";
|
|
23
18
|
|
|
24
19
|
/**
|
|
25
20
|
* Data included for {@link TreeChangeEventsBeta.nodeChanged}.
|
|
@@ -113,18 +108,40 @@ export const TreeBeta: {
|
|
|
113
108
|
): () => void;
|
|
114
109
|
|
|
115
110
|
/**
|
|
116
|
-
* Clones the persisted data associated with a node.
|
|
111
|
+
* Clones the persisted data associated with a node.
|
|
112
|
+
*
|
|
113
|
+
* @param node - The node to clone.
|
|
114
|
+
* @returns A new unhydrated node with the same persisted data as the original node.
|
|
115
|
+
* @remarks
|
|
116
|
+
* Some key things to note:
|
|
117
|
+
*
|
|
117
118
|
* - Local state, such as properties added to customized schema classes, will not be cloned. However, they will be
|
|
118
119
|
* initialized to their default state just as if the node had been created via its constructor.
|
|
119
120
|
* - Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.
|
|
120
121
|
* - The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.
|
|
121
|
-
*
|
|
122
|
-
* @param node - The node to clone.
|
|
123
|
-
* @returns A new unhydrated node with the same persisted data as the original node.
|
|
124
122
|
*/
|
|
125
|
-
clone<TSchema extends ImplicitFieldSchema>(
|
|
123
|
+
clone<const TSchema extends ImplicitFieldSchema>(
|
|
126
124
|
node: TreeFieldFromImplicitField<TSchema>,
|
|
127
125
|
): TreeFieldFromImplicitField<TSchema>;
|
|
126
|
+
|
|
127
|
+
// TODO: support more clone options
|
|
128
|
+
// /**
|
|
129
|
+
// * Like {@link TreeBeta.create}, except deeply clones existing nodes.
|
|
130
|
+
// * @remarks
|
|
131
|
+
// * This only clones the persisted data associated with a node.
|
|
132
|
+
// * Local state, such as properties added to customized schema classes, will not be cloned:
|
|
133
|
+
// * they will be initialized however they end up after running the constructor, just like if a remote client had inserted the same nodes.
|
|
134
|
+
// */
|
|
135
|
+
// clone<const TSchema extends ImplicitFieldSchema>(
|
|
136
|
+
// original: TreeFieldFromImplicitField<TSchema>,
|
|
137
|
+
// options?: {
|
|
138
|
+
// /**
|
|
139
|
+
// * If set, all identifier's in the cloned tree (See {@link SchemaFactory.identifier}) will be replaced with new ones allocated using the default identifier allocation schema.
|
|
140
|
+
// * Otherwise any identifiers will be preserved as is.
|
|
141
|
+
// */
|
|
142
|
+
// replaceIdentifiers?: true;
|
|
143
|
+
// },
|
|
144
|
+
// ): TreeFieldFromImplicitField<TSchema>;
|
|
128
145
|
} = {
|
|
129
146
|
on<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(
|
|
130
147
|
node: TNode,
|
|
@@ -133,35 +150,18 @@ export const TreeBeta: {
|
|
|
133
150
|
): () => void {
|
|
134
151
|
return treeNodeApi.on(node, eventName, listener);
|
|
135
152
|
},
|
|
136
|
-
clone<TSchema extends ImplicitFieldSchema>(
|
|
153
|
+
clone<const TSchema extends ImplicitFieldSchema>(
|
|
137
154
|
node: TreeFieldFromImplicitField<TSchema>,
|
|
138
155
|
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
139
|
-
|
|
156
|
+
/** The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is. */
|
|
140
157
|
if (!isTreeNode(node)) {
|
|
141
158
|
return node;
|
|
142
159
|
}
|
|
143
160
|
|
|
144
161
|
const kernel = getKernel(node);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (!kernel.isHydrated()) {
|
|
150
|
-
return createFromCursor(
|
|
151
|
-
kernel.schema,
|
|
152
|
-
cursorFromInsertable<UnsafeUnknownSchema>(kernel.schema, node),
|
|
153
|
-
) as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// For hydrated nodes, create a new cursor in the forest and then create a new node from the cursor.
|
|
157
|
-
const forest = kernel.context.flexContext.checkout.forest;
|
|
158
|
-
const cursor = forest.allocateCursor("tree.clone");
|
|
159
|
-
forest.moveCursorToPath(kernel.anchorNode, cursor);
|
|
160
|
-
const clonedNode = createFromCursor(
|
|
161
|
-
kernel.schema,
|
|
162
|
-
cursor as ITreeCursorSynchronous,
|
|
163
|
-
) as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
164
|
-
cursor.free();
|
|
165
|
-
return clonedNode;
|
|
162
|
+
const cursor = kernel.getOrCreateInnerNode().borrowCursor();
|
|
163
|
+
return createFromCursor(kernel.schema, cursor) as Unhydrated<
|
|
164
|
+
TreeFieldFromImplicitField<TSchema>
|
|
165
|
+
>;
|
|
166
166
|
},
|
|
167
167
|
};
|
|
@@ -23,7 +23,7 @@ import type {
|
|
|
23
23
|
TreeNodeSchema,
|
|
24
24
|
TreeNodeSchemaCore,
|
|
25
25
|
} from "../core/index.js";
|
|
26
|
-
import type {
|
|
26
|
+
import type { TreeArrayNode } from "../arrayNode.js";
|
|
27
27
|
import type { FlexListToUnion, LazyItem } from "../flexList.js";
|
|
28
28
|
|
|
29
29
|
/*
|
|
@@ -86,8 +86,7 @@ export type TreeNodeSchemaUnsafe<
|
|
|
86
86
|
export interface TreeNodeSchemaClassUnsafe<
|
|
87
87
|
out Name extends string,
|
|
88
88
|
out Kind extends NodeKind,
|
|
89
|
-
|
|
90
|
-
out TNode extends Unenforced<TreeNode | TreeLeafValue>,
|
|
89
|
+
out TNode extends Unenforced<TreeNode>,
|
|
91
90
|
in TInsertable,
|
|
92
91
|
out ImplicitlyConstructable extends boolean,
|
|
93
92
|
out Info,
|
|
@@ -239,7 +238,8 @@ export type NodeBuilderDataUnsafe<T extends Unenforced<TreeNodeSchema>> =
|
|
|
239
238
|
* @system @sealed @public
|
|
240
239
|
*/
|
|
241
240
|
export interface TreeArrayNodeUnsafe<TAllowedTypes extends Unenforced<ImplicitAllowedTypes>>
|
|
242
|
-
extends
|
|
241
|
+
extends TreeArrayNode<
|
|
242
|
+
TAllowedTypes,
|
|
243
243
|
TreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>,
|
|
244
244
|
InsertableTreeNodeFromImplicitAllowedTypesUnsafe<TAllowedTypes>
|
|
245
245
|
> {}
|
|
@@ -53,6 +53,7 @@ import { getUnhydratedContext } from "../createContext.js";
|
|
|
53
53
|
* @privateRemarks
|
|
54
54
|
* This can store all possible simple trees,
|
|
55
55
|
* but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.
|
|
56
|
+
* @alpha
|
|
56
57
|
*/
|
|
57
58
|
export type VerboseTree<THandle = IFluidHandle> =
|
|
58
59
|
| VerboseTreeNode<THandle>
|
|
@@ -82,6 +83,7 @@ export type VerboseTree<THandle = IFluidHandle> =
|
|
|
82
83
|
* Unlike `JsonableTree`, leaf nodes are not boxed into node objects, and instead have their schema inferred from the value.
|
|
83
84
|
* Additionally, sequence fields can only occur on a node that has a single sequence field (with the empty key)
|
|
84
85
|
* replicating the behavior of simple-tree ArrayNodes.
|
|
86
|
+
* @alpha
|
|
85
87
|
*/
|
|
86
88
|
export interface VerboseTreeNode<THandle = IFluidHandle> {
|
|
87
89
|
/**
|
|
@@ -109,6 +111,7 @@ export interface VerboseTreeNode<THandle = IFluidHandle> {
|
|
|
109
111
|
|
|
110
112
|
/**
|
|
111
113
|
* Options for how to interpret a `VerboseTree<TCustom>` when schema information is available.
|
|
114
|
+
* @alpha
|
|
112
115
|
*/
|
|
113
116
|
export interface ParseOptions<TCustom> {
|
|
114
117
|
/**
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
} from "./core/index.js";
|
|
47
47
|
import { TreeNodeValid, type MostDerivedData } from "./treeNodeValid.js";
|
|
48
48
|
import { getUnhydratedContext } from "./createContext.js";
|
|
49
|
+
import type { Unenforced } from "./api/index.js";
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* A covariant base type for {@link (TreeArrayNode:interface)}.
|
|
@@ -61,15 +62,25 @@ export interface ReadonlyArrayNode<out T = TreeNode | TreeLeafValue>
|
|
|
61
62
|
Awaited<TreeNode & WithType<string, NodeKind.Array>> {}
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
|
-
* A
|
|
65
|
+
* A {@link TreeNode} which implements 'readonly T[]' and the array mutation APIs.
|
|
65
66
|
*
|
|
66
|
-
* @
|
|
67
|
-
*
|
|
67
|
+
* @typeParam TAllowedTypes - Schema for types which are allowed as members of this array.
|
|
68
|
+
* @typeParam T - Use Default: Do not specify. Type of values to read from the array.
|
|
69
|
+
* @typeParam TNew - Use Default: Do not specify. Type of values to write into the array.
|
|
70
|
+
* @typeParam TMoveFrom - Use Default: Do not specify. Type of node from which children can be moved into this array.
|
|
68
71
|
*
|
|
69
|
-
* @
|
|
72
|
+
* @sealed @public
|
|
70
73
|
*/
|
|
71
|
-
export interface
|
|
72
|
-
extends
|
|
74
|
+
export interface TreeArrayNode<
|
|
75
|
+
TAllowedTypes extends Unenforced<ImplicitAllowedTypes> = ImplicitAllowedTypes,
|
|
76
|
+
out T = [TAllowedTypes] extends [ImplicitAllowedTypes]
|
|
77
|
+
? TreeNodeFromImplicitAllowedTypes<TAllowedTypes>
|
|
78
|
+
: TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>,
|
|
79
|
+
in TNew = [TAllowedTypes] extends [ImplicitAllowedTypes]
|
|
80
|
+
? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>
|
|
81
|
+
: InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>,
|
|
82
|
+
in TMoveFrom = ReadonlyArrayNode,
|
|
83
|
+
> extends ReadonlyArrayNode<T> {
|
|
73
84
|
/**
|
|
74
85
|
* Inserts new item(s) at a specified location.
|
|
75
86
|
* @param index - The index at which to insert `value`.
|
|
@@ -369,20 +380,6 @@ export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom = ReadonlyArrayN
|
|
|
369
380
|
values(): IterableIterator<T>;
|
|
370
381
|
}
|
|
371
382
|
|
|
372
|
-
/**
|
|
373
|
-
* A {@link TreeNode} which implements 'readonly T[]' and the array mutation APIs.
|
|
374
|
-
*
|
|
375
|
-
* @typeParam TAllowedTypes - Schema for types which are allowed as members of this array.
|
|
376
|
-
*
|
|
377
|
-
* @sealed @public
|
|
378
|
-
*/
|
|
379
|
-
export interface TreeArrayNode<
|
|
380
|
-
TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
381
|
-
> extends TreeArrayNodeBase<
|
|
382
|
-
TreeNodeFromImplicitAllowedTypes<TAllowedTypes>,
|
|
383
|
-
InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>
|
|
384
|
-
> {}
|
|
385
|
-
|
|
386
383
|
/**
|
|
387
384
|
* A {@link TreeNode} which implements 'readonly T[]' and the array mutation APIs.
|
|
388
385
|
* @public
|
|
@@ -816,9 +813,9 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
816
813
|
>;
|
|
817
814
|
|
|
818
815
|
public constructor(
|
|
819
|
-
input
|
|
816
|
+
input?: Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>> | InternalTreeNode,
|
|
820
817
|
) {
|
|
821
|
-
super(input);
|
|
818
|
+
super(input ?? []);
|
|
822
819
|
}
|
|
823
820
|
|
|
824
821
|
#mapTreesFromFieldData(value: Insertable<T>): ExclusiveMapTree[] {
|
|
@@ -1077,7 +1074,8 @@ export function arraySchema<
|
|
|
1077
1074
|
TreeArrayNode<T> & WithType<TName, NodeKind.Array>,
|
|
1078
1075
|
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
|
|
1079
1076
|
ImplicitlyConstructable,
|
|
1080
|
-
T
|
|
1077
|
+
T,
|
|
1078
|
+
undefined
|
|
1081
1079
|
>;
|
|
1082
1080
|
|
|
1083
1081
|
const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(info));
|
|
@@ -31,7 +31,7 @@ export function getOrCreateNodeFromInnerNode(flexNode: InnerNode): TreeNode | Tr
|
|
|
31
31
|
const node = flexNode as unknown as InternalTreeNode;
|
|
32
32
|
// eslint-disable-next-line unicorn/prefer-ternary
|
|
33
33
|
if (typeof classSchema === "function") {
|
|
34
|
-
return new classSchema(node)
|
|
34
|
+
return new classSchema(node);
|
|
35
35
|
} else {
|
|
36
36
|
return (classSchema as { create(data: FlexTreeNode): TreeValue }).create(flexNode);
|
|
37
37
|
}
|
|
@@ -28,7 +28,9 @@ export type TreeNodeSchema<
|
|
|
28
28
|
ImplicitlyConstructable extends boolean = boolean,
|
|
29
29
|
Info = unknown,
|
|
30
30
|
> =
|
|
31
|
-
|
|
|
31
|
+
| (TNode extends TreeNode
|
|
32
|
+
? TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
|
|
33
|
+
: never)
|
|
32
34
|
| TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -39,16 +41,30 @@ export type TreeNodeSchema<
|
|
|
39
41
|
* Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.
|
|
40
42
|
* @system @sealed @public
|
|
41
43
|
*/
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
export type TreeNodeSchemaNonClass<
|
|
45
|
+
Name extends string = string,
|
|
46
|
+
Kind extends NodeKind = NodeKind,
|
|
47
|
+
TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,
|
|
48
|
+
TInsertable = never,
|
|
49
|
+
ImplicitlyConstructable extends boolean = boolean,
|
|
50
|
+
Info = unknown,
|
|
51
|
+
TConstructorExtra = never,
|
|
52
|
+
> = TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable> &
|
|
53
|
+
(undefined extends TConstructorExtra
|
|
54
|
+
? {
|
|
55
|
+
/**
|
|
56
|
+
* Constructs an {@link Unhydrated} node with this schema.
|
|
57
|
+
* @sealed
|
|
58
|
+
*/
|
|
59
|
+
create(data?: TInsertable | TConstructorExtra): TNode;
|
|
60
|
+
}
|
|
61
|
+
: {
|
|
62
|
+
/**
|
|
63
|
+
* Constructs an {@link Unhydrated} node with this schema.
|
|
64
|
+
* @sealed
|
|
65
|
+
*/
|
|
66
|
+
create(data: TInsertable | TConstructorExtra): TNode;
|
|
67
|
+
});
|
|
52
68
|
|
|
53
69
|
/**
|
|
54
70
|
* Tree node schema which is implemented using a class.
|
|
@@ -95,24 +111,40 @@ export interface TreeNodeSchemaNonClass<
|
|
|
95
111
|
* ```
|
|
96
112
|
* @sealed @public
|
|
97
113
|
*/
|
|
98
|
-
export
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
export type TreeNodeSchemaClass<
|
|
115
|
+
Name extends string = string,
|
|
116
|
+
Kind extends NodeKind = NodeKind,
|
|
117
|
+
TNode extends TreeNode = TreeNode,
|
|
118
|
+
TInsertable = never,
|
|
119
|
+
ImplicitlyConstructable extends boolean = boolean,
|
|
120
|
+
Info = unknown,
|
|
121
|
+
TConstructorExtra = never,
|
|
122
|
+
> = TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable> &
|
|
123
|
+
(undefined extends TConstructorExtra
|
|
124
|
+
? {
|
|
125
|
+
/**
|
|
126
|
+
* Constructs an {@link Unhydrated} node with this schema.
|
|
127
|
+
* @remarks
|
|
128
|
+
* This constructor is also used internally to construct hydrated nodes with a different parameter type.
|
|
129
|
+
* Therefore, overriding this constructor with different argument types is not type-safe and is not supported.
|
|
130
|
+
* @sealed
|
|
131
|
+
*/
|
|
132
|
+
// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
134
|
+
new (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;
|
|
135
|
+
}
|
|
136
|
+
: {
|
|
137
|
+
/**
|
|
138
|
+
* Constructs an {@link Unhydrated} node with this schema.
|
|
139
|
+
* @remarks
|
|
140
|
+
* This constructor is also used internally to construct hydrated nodes with a different parameter type.
|
|
141
|
+
* Therefore, overriding this constructor with different argument types is not type-safe and is not supported.
|
|
142
|
+
* @sealed
|
|
143
|
+
*/
|
|
144
|
+
// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
146
|
+
new (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;
|
|
147
|
+
});
|
|
116
148
|
|
|
117
149
|
/**
|
|
118
150
|
* Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.
|
|
@@ -124,8 +156,25 @@ export type TreeNodeSchemaBoth<
|
|
|
124
156
|
TInsertable = never,
|
|
125
157
|
ImplicitlyConstructable extends boolean = boolean,
|
|
126
158
|
Info = unknown,
|
|
127
|
-
|
|
128
|
-
|
|
159
|
+
TConstructorExtra = never,
|
|
160
|
+
> = TreeNodeSchemaClass<
|
|
161
|
+
Name,
|
|
162
|
+
Kind,
|
|
163
|
+
TNode,
|
|
164
|
+
TInsertable,
|
|
165
|
+
ImplicitlyConstructable,
|
|
166
|
+
Info,
|
|
167
|
+
TConstructorExtra
|
|
168
|
+
> &
|
|
169
|
+
TreeNodeSchemaNonClass<
|
|
170
|
+
Name,
|
|
171
|
+
Kind,
|
|
172
|
+
TNode,
|
|
173
|
+
TInsertable,
|
|
174
|
+
ImplicitlyConstructable,
|
|
175
|
+
Info,
|
|
176
|
+
TConstructorExtra
|
|
177
|
+
>;
|
|
129
178
|
|
|
130
179
|
/**
|
|
131
180
|
* Data common to all tree node schema.
|
|
@@ -138,6 +187,7 @@ export interface TreeNodeSchemaCore<
|
|
|
138
187
|
out Kind extends NodeKind,
|
|
139
188
|
out ImplicitlyConstructable extends boolean,
|
|
140
189
|
out Info = unknown,
|
|
190
|
+
out TInsertable = never,
|
|
141
191
|
> {
|
|
142
192
|
/**
|
|
143
193
|
* Unique (within a document's schema) identifier used to associate nodes with their schema.
|
|
@@ -193,6 +243,24 @@ export interface TreeNodeSchemaCore<
|
|
|
193
243
|
* @system
|
|
194
244
|
*/
|
|
195
245
|
readonly childTypes: ReadonlySet<TreeNodeSchema>;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Constructs an instance of this node type.
|
|
249
|
+
* @remarks
|
|
250
|
+
* Due to TypeScript limitations, the return type of this method can not be very specific.
|
|
251
|
+
* For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.
|
|
252
|
+
* For {@link TreeNodeSchemaNonClass} use `create`.
|
|
253
|
+
*
|
|
254
|
+
* @privateRemarks
|
|
255
|
+
* This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.
|
|
256
|
+
* This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,
|
|
257
|
+
* as long as doing so only adds additional supported cases.
|
|
258
|
+
*
|
|
259
|
+
* This cannot be required to return `TNode`:
|
|
260
|
+
* doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.
|
|
261
|
+
* @sealed @system
|
|
262
|
+
*/
|
|
263
|
+
createFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;
|
|
196
264
|
}
|
|
197
265
|
|
|
198
266
|
/**
|