@fluidframework/tree 2.5.0-302463 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +371 -0
- package/api-report/tree.alpha.api.md +151 -57
- package/api-report/tree.beta.api.md +29 -25
- package/api-report/tree.legacy.alpha.api.md +28 -24
- package/api-report/tree.legacy.public.api.md +28 -24
- package/api-report/tree.public.api.md +28 -24
- package/dist/alpha.d.ts +15 -0
- package/dist/codec/codec.d.ts +24 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +26 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +0 -4
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -7
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +1 -0
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +29 -4
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts +57 -0
- package/dist/shared-tree/independentView.d.ts.map +1 -0
- package/dist/shared-tree/independentView.js +89 -0
- package/dist/shared-tree/independentView.js.map +1 -0
- package/dist/shared-tree/index.d.ts +3 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +6 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +28 -0
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +10 -7
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
- package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
- package/dist/shared-tree/treeApiAlpha.js +122 -0
- package/dist/shared-tree/treeApiAlpha.js.map +1 -0
- package/dist/shared-tree/treeCheckout.d.ts +12 -7
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +9 -4
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +13 -6
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +70 -28
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +28 -3
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +2 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +5 -23
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +4 -19
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +1 -0
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +5 -5
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +10 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +11 -11
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/dist/simple-tree/api/tree.d.ts +115 -7
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +12 -4
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeApiBeta.js +3 -15
- package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +3 -0
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +1 -1
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +45 -9
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +1 -2
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/createContext.js +2 -2
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +15 -4
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +3 -0
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +3 -0
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +45 -7
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +61 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
- package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
- package/dist/simple-tree/toStoredSchema.js.map +1 -0
- package/dist/simple-tree/treeNodeValid.d.ts +5 -1
- package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +7 -1
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeCheck.d.ts +9 -0
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/utils.d.ts +7 -3
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +13 -3
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +15 -0
- package/lib/codec/codec.d.ts +24 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +25 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +2 -2
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +2 -2
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +0 -4
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -5
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts +1 -0
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +27 -3
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts +57 -0
- package/lib/shared-tree/independentView.d.ts.map +1 -0
- package/lib/shared-tree/independentView.js +84 -0
- package/lib/shared-tree/independentView.js.map +1 -0
- package/lib/shared-tree/index.d.ts +3 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -0
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +29 -1
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +10 -7
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
- package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
- package/lib/shared-tree/treeApiAlpha.js +119 -0
- package/lib/shared-tree/treeApiAlpha.js.map +1 -0
- package/lib/shared-tree/treeCheckout.d.ts +12 -7
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +9 -4
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +13 -6
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +70 -28
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +29 -4
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +2 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +5 -23
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +2 -16
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +1 -0
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +5 -5
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +5 -3
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +11 -11
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +1 -1
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/lib/simple-tree/api/tree.d.ts +115 -7
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +9 -2
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeApiBeta.js +4 -16
- package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +3 -0
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +1 -1
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +45 -9
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +1 -2
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/createContext.js +1 -1
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +4 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +3 -0
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +3 -0
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +45 -7
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +59 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
- package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
- package/lib/simple-tree/toStoredSchema.js.map +1 -0
- package/lib/simple-tree/treeNodeValid.d.ts +5 -1
- package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +7 -1
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/typeCheck.d.ts +9 -0
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/utils.d.ts +7 -3
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +13 -3
- package/lib/util/utils.js.map +1 -1
- package/package.json +30 -21
- package/src/codec/codec.ts +25 -0
- package/src/codec/index.ts +1 -0
- package/src/core/rebase/index.ts +1 -1
- package/src/core/rebase/types.ts +0 -12
- package/src/core/rebase/utils.ts +35 -3
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
- package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
- package/src/index.ts +20 -5
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +176 -0
- package/src/shared-tree/index.ts +9 -1
- package/src/shared-tree/schematizingTreeView.ts +58 -11
- package/src/shared-tree/sharedTree.ts +29 -11
- package/src/shared-tree/treeApiAlpha.ts +401 -0
- package/src/shared-tree/treeCheckout.ts +26 -5
- package/src/shared-tree-core/editManager.ts +112 -54
- package/src/shared-tree-core/sharedTreeCore.ts +37 -8
- package/src/simple-tree/api/conciseTree.ts +2 -1
- package/src/simple-tree/api/create.ts +21 -58
- package/src/simple-tree/api/customTree.ts +1 -0
- package/src/simple-tree/api/index.ts +13 -7
- package/src/simple-tree/api/schemaCreationUtilities.ts +4 -5
- package/src/simple-tree/api/schemaFactory.ts +24 -12
- package/src/simple-tree/api/storedSchema.ts +1 -1
- package/src/simple-tree/api/tree.ts +136 -14
- package/src/simple-tree/api/treeApiBeta.ts +35 -35
- package/src/simple-tree/api/typesUnsafe.ts +1 -2
- package/src/simple-tree/api/verboseTree.ts +3 -0
- package/src/simple-tree/arrayNode.ts +4 -3
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/treeNodeSchema.ts +99 -31
- package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
- package/src/simple-tree/core/withType.ts +1 -9
- package/src/simple-tree/createContext.ts +1 -1
- package/src/simple-tree/index.ts +15 -1
- package/src/simple-tree/leafNodeSchema.ts +6 -1
- package/src/simple-tree/mapNode.ts +7 -1
- package/src/simple-tree/schemaTypes.ts +128 -14
- package/src/simple-tree/treeNodeValid.ts +11 -1
- package/src/util/index.ts +1 -0
- package/src/util/typeCheck.ts +13 -0
- package/src/util/utils.ts +20 -7
- package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
- package/dist/simple-tree/toFlexSchema.js.map +0 -1
- package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
- package/lib/simple-tree/toFlexSchema.js.map +0 -1
- /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
package/src/simple-tree/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export {
|
|
|
23
23
|
HydratedContext,
|
|
24
24
|
SimpleContextSlot,
|
|
25
25
|
getOrCreateInnerNode,
|
|
26
|
+
getKernel,
|
|
26
27
|
} from "./core/index.js";
|
|
27
28
|
export {
|
|
28
29
|
type ITree,
|
|
@@ -97,6 +98,15 @@ export {
|
|
|
97
98
|
type TreeNodeSchemaNonClassUnsafe,
|
|
98
99
|
type InsertableTreeNodeFromAllowedTypesUnsafe,
|
|
99
100
|
type TreeViewAlpha,
|
|
101
|
+
type TreeBranch,
|
|
102
|
+
type TreeBranchEvents,
|
|
103
|
+
tryGetSchema,
|
|
104
|
+
applySchemaToParserOptions,
|
|
105
|
+
cursorFromVerbose,
|
|
106
|
+
verboseFromCursor,
|
|
107
|
+
conciseFromCursor,
|
|
108
|
+
createFromCursor,
|
|
109
|
+
asTreeViewAlpha,
|
|
100
110
|
} from "./api/index.js";
|
|
101
111
|
export {
|
|
102
112
|
type NodeFromSchema,
|
|
@@ -116,6 +126,8 @@ export {
|
|
|
116
126
|
type DefaultProvider,
|
|
117
127
|
type FieldProps,
|
|
118
128
|
normalizeFieldSchema,
|
|
129
|
+
areFieldSchemaEqual,
|
|
130
|
+
areImplicitFieldSchemaEqual,
|
|
119
131
|
type ApplyKind,
|
|
120
132
|
type FieldSchemaMetadata,
|
|
121
133
|
type InsertableField,
|
|
@@ -124,6 +136,8 @@ export {
|
|
|
124
136
|
type ApplyKindInput,
|
|
125
137
|
type InsertableTreeNodeFromAllowedTypes,
|
|
126
138
|
type Input,
|
|
139
|
+
type ReadableField,
|
|
140
|
+
type ReadSchema,
|
|
127
141
|
} from "./schemaTypes.js";
|
|
128
142
|
export {
|
|
129
143
|
getTreeNodeForField,
|
|
@@ -149,7 +163,7 @@ export {
|
|
|
149
163
|
type FactoryContent,
|
|
150
164
|
type FactoryContentObject,
|
|
151
165
|
} from "./toMapTree.js";
|
|
152
|
-
export { toStoredSchema, getStoredSchema } from "./
|
|
166
|
+
export { toStoredSchema, getStoredSchema } from "./toStoredSchema.js";
|
|
153
167
|
export {
|
|
154
168
|
numberSchema,
|
|
155
169
|
stringSchema,
|
|
@@ -40,6 +40,10 @@ export class LeafNodeSchema<Name extends string, const T extends ValueSchema>
|
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
public createFromInsertable(data: TreeValue<T>): TreeValue<T> {
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
public constructor(name: Name, t: T) {
|
|
44
48
|
this.identifier = name;
|
|
45
49
|
this.info = t;
|
|
@@ -56,7 +60,8 @@ function makeLeaf<Name extends string, const T extends ValueSchema>(
|
|
|
56
60
|
`com.fluidframework.leaf.${Name}`,
|
|
57
61
|
NodeKind.Leaf,
|
|
58
62
|
TreeValue<T>,
|
|
59
|
-
TreeValue<T
|
|
63
|
+
TreeValue<T>,
|
|
64
|
+
true
|
|
60
65
|
> {
|
|
61
66
|
// Names in this domain follow https://en.wikipedia.org/wiki/Reverse_domain_name_notation
|
|
62
67
|
return new LeafNodeSchema(`com.fluidframework.leaf.${name}`, t);
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
type Context,
|
|
34
34
|
UnhydratedFlexTreeNode,
|
|
35
35
|
getOrCreateInnerNode,
|
|
36
|
+
type InternalTreeNode,
|
|
36
37
|
} from "./core/index.js";
|
|
37
38
|
import {
|
|
38
39
|
mapTreeFromNodeData,
|
|
@@ -142,6 +143,10 @@ abstract class CustomMapNodeBase<const T extends ImplicitAllowedTypes> extends T
|
|
|
142
143
|
> {
|
|
143
144
|
public static readonly kind = NodeKind.Map;
|
|
144
145
|
|
|
146
|
+
public constructor(input?: InternalTreeNode | MapNodeInsertableData<T> | undefined) {
|
|
147
|
+
super(input ?? []);
|
|
148
|
+
}
|
|
149
|
+
|
|
145
150
|
public [Symbol.iterator](): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<T>]> {
|
|
146
151
|
return this.entries();
|
|
147
152
|
}
|
|
@@ -293,7 +298,8 @@ export function mapSchema<
|
|
|
293
298
|
TreeMapNode<T> & WithType<TName, NodeKind.Map>,
|
|
294
299
|
MapNodeInsertableData<T>,
|
|
295
300
|
ImplicitlyConstructable,
|
|
296
|
-
T
|
|
301
|
+
T,
|
|
302
|
+
undefined
|
|
297
303
|
> = Schema;
|
|
298
304
|
return schemaErased;
|
|
299
305
|
}
|
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
brand,
|
|
14
14
|
isReadonlyArray,
|
|
15
15
|
type UnionToIntersection,
|
|
16
|
+
compareSets,
|
|
17
|
+
type requireTrue,
|
|
18
|
+
type areOnlyKeys,
|
|
16
19
|
} from "../util/index.js";
|
|
17
20
|
import type {
|
|
18
21
|
Unhydrated,
|
|
@@ -20,6 +23,7 @@ import type {
|
|
|
20
23
|
TreeNodeSchema,
|
|
21
24
|
TreeNodeSchemaClass,
|
|
22
25
|
TreeNode,
|
|
26
|
+
TreeNodeSchemaCore,
|
|
23
27
|
} from "./core/index.js";
|
|
24
28
|
import type { FieldKey } from "../core/index.js";
|
|
25
29
|
import type { InsertableContent } from "./toMapTree.js";
|
|
@@ -36,8 +40,17 @@ export function isTreeNodeSchemaClass<
|
|
|
36
40
|
ImplicitlyConstructable extends boolean,
|
|
37
41
|
Info,
|
|
38
42
|
>(
|
|
39
|
-
schema:
|
|
40
|
-
|
|
43
|
+
schema:
|
|
44
|
+
| TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
|
|
45
|
+
| TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>,
|
|
46
|
+
): schema is TreeNodeSchemaClass<
|
|
47
|
+
Name,
|
|
48
|
+
Kind,
|
|
49
|
+
TNode & TreeNode,
|
|
50
|
+
TBuild,
|
|
51
|
+
ImplicitlyConstructable,
|
|
52
|
+
Info
|
|
53
|
+
> {
|
|
41
54
|
return schema.constructor !== undefined;
|
|
42
55
|
}
|
|
43
56
|
|
|
@@ -368,6 +381,87 @@ export function normalizeAllowedTypes(
|
|
|
368
381
|
return normalized;
|
|
369
382
|
}
|
|
370
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.
|
|
386
|
+
* @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:
|
|
387
|
+
* 1. They have the same {@link FieldKind | kinds}.
|
|
388
|
+
* 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.
|
|
389
|
+
* 3. They have the same exact set of allowed types. The allowed types must be (respectively) reference equal.
|
|
390
|
+
*
|
|
391
|
+
* For example, comparing an ImplicitFieldSchema that is a {@link TreeNodeSchema} to an ImplicitFieldSchema that is a {@link FieldSchema}
|
|
392
|
+
* will return true if they are the same kind, the FieldSchema has exactly one allowed type (the TreeNodeSchema), and they have equivalent FieldProps.
|
|
393
|
+
*/
|
|
394
|
+
export function areImplicitFieldSchemaEqual(
|
|
395
|
+
a: ImplicitFieldSchema,
|
|
396
|
+
b: ImplicitFieldSchema,
|
|
397
|
+
): boolean {
|
|
398
|
+
return areFieldSchemaEqual(normalizeFieldSchema(a), normalizeFieldSchema(b));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Returns true if the given {@link FieldSchema} are equivalent, otherwise false.
|
|
403
|
+
* @remarks Two FieldSchema are considered equivalent if all of the following are true:
|
|
404
|
+
* 1. They have the same {@link FieldKind | kinds}.
|
|
405
|
+
* 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.
|
|
406
|
+
* 3. They have the same exact set of allowed types. The allowed types must be reference equal.
|
|
407
|
+
*/
|
|
408
|
+
export function areFieldSchemaEqual(a: FieldSchema, b: FieldSchema): boolean {
|
|
409
|
+
if (a === b) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (a.kind !== b.kind) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (!areFieldPropsEqual(a.props, b.props)) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return compareSets({ a: a.allowedTypeSet, b: b.allowedTypeSet });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Returns true if the given {@link FieldProps} are equivalent, otherwise false.
|
|
426
|
+
* @remarks FieldProps are considered equivalent if their keys and default providers are reference equal, and their metadata are {@link areMetadataEqual | equivalent}.
|
|
427
|
+
*/
|
|
428
|
+
function areFieldPropsEqual(a: FieldProps | undefined, b: FieldProps | undefined): boolean {
|
|
429
|
+
// If any new fields are added to FieldProps, this check will stop compiling as a reminder that this function needs to be updated.
|
|
430
|
+
type _keys = requireTrue<areOnlyKeys<FieldProps, "key" | "defaultProvider" | "metadata">>;
|
|
431
|
+
|
|
432
|
+
if (a === b) {
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (a?.key !== b?.key || a?.defaultProvider !== b?.defaultProvider) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (!areMetadataEqual(a?.metadata, b?.metadata)) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Returns true if the given {@link FieldSchemaMetadata} are equivalent, otherwise false.
|
|
449
|
+
* @remarks FieldSchemaMetadata are considered equivalent if their custom data and descriptions are (respectively) reference equal.
|
|
450
|
+
*/
|
|
451
|
+
function areMetadataEqual(
|
|
452
|
+
a: FieldSchemaMetadata | undefined,
|
|
453
|
+
b: FieldSchemaMetadata | undefined,
|
|
454
|
+
): boolean {
|
|
455
|
+
// If any new fields are added to FieldSchemaMetadata, this check will stop compiling as a reminder that this function needs to be updated.
|
|
456
|
+
type _keys = requireTrue<areOnlyKeys<FieldSchemaMetadata, "custom" | "description">>;
|
|
457
|
+
|
|
458
|
+
if (a === b) {
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return a?.custom === b?.custom && a?.description === b?.description;
|
|
463
|
+
}
|
|
464
|
+
|
|
371
465
|
function evaluateLazySchema(value: LazyItem<TreeNodeSchema>): TreeNodeSchema {
|
|
372
466
|
const evaluatedSchema = isLazy(value) ? value() : value;
|
|
373
467
|
if (evaluatedSchema === undefined) {
|
|
@@ -482,6 +576,31 @@ export type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownS
|
|
|
482
576
|
? InsertableContent | undefined
|
|
483
577
|
: never;
|
|
484
578
|
|
|
579
|
+
/**
|
|
580
|
+
* Content which could be read from a field within a tree.
|
|
581
|
+
*
|
|
582
|
+
* @remarks
|
|
583
|
+
* Extended version of {@link TreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.
|
|
584
|
+
* Since reading from fields with non-exact schema is still safe, this is only useful (compared to {@link TreeFieldFromImplicitField}) when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}
|
|
585
|
+
* for use
|
|
586
|
+
* @system @alpha
|
|
587
|
+
*/
|
|
588
|
+
export type ReadableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =
|
|
589
|
+
TreeFieldFromImplicitField<ReadSchema<TSchema>>;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Adapter to remove {@link (UnsafeUnknownSchema:type)} from a schema type so it can be used with types for generating APIs for reading data.
|
|
593
|
+
*
|
|
594
|
+
* @remarks
|
|
595
|
+
* Since reading with non-exact schema is still safe, this is mainly useful when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}.
|
|
596
|
+
* @system @alpha
|
|
597
|
+
*/
|
|
598
|
+
export type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [
|
|
599
|
+
TSchema,
|
|
600
|
+
] extends [ImplicitFieldSchema]
|
|
601
|
+
? TSchema
|
|
602
|
+
: ImplicitFieldSchema;
|
|
603
|
+
|
|
485
604
|
/**
|
|
486
605
|
* Suitable for output.
|
|
487
606
|
* For input must error on side of excluding undefined instead.
|
|
@@ -654,20 +773,15 @@ export type InsertableTypedNode<
|
|
|
654
773
|
/**
|
|
655
774
|
* Given a node's schema, return the corresponding object from which the node could be built.
|
|
656
775
|
* @privateRemarks
|
|
657
|
-
*
|
|
658
|
-
* This
|
|
659
|
-
*
|
|
660
|
-
* These factory functions can also take a FlexTreeNode, but this is not exposed in the public facing types.
|
|
776
|
+
* This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.
|
|
777
|
+
* This works almost the same as using TreeNodeSchema,
|
|
778
|
+
* except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.
|
|
661
779
|
* @system @public
|
|
662
780
|
*/
|
|
663
|
-
export type NodeBuilderData<T extends
|
|
664
|
-
string,
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
infer TBuild
|
|
668
|
-
>
|
|
669
|
-
? TBuild
|
|
670
|
-
: never;
|
|
781
|
+
export type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> =
|
|
782
|
+
T extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild>
|
|
783
|
+
? TBuild
|
|
784
|
+
: never;
|
|
671
785
|
|
|
672
786
|
/**
|
|
673
787
|
* Value that may be stored as a leaf node.
|
|
@@ -133,7 +133,7 @@ export abstract class TreeNodeValid<TInput> extends TreeNode {
|
|
|
133
133
|
* @remarks
|
|
134
134
|
* When used as TreeNodeSchemaNonClass and subclassed,
|
|
135
135
|
* does not actually have the correct compile time type for the return value due to TypeScript limitations.
|
|
136
|
-
* This is why this is not exposed as part of
|
|
136
|
+
* This is why this is not exposed as part of TreeNodeSchemaClass where subclassing is allowed.
|
|
137
137
|
*/
|
|
138
138
|
public static create<TInput, TOut, TThis extends new (args: TInput) => TOut>(
|
|
139
139
|
this: TThis,
|
|
@@ -142,6 +142,16 @@ export abstract class TreeNodeValid<TInput> extends TreeNode {
|
|
|
142
142
|
return new this(input);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* @see {@link TreeNodeSchemaCore.createFromInsertable}.
|
|
147
|
+
*/
|
|
148
|
+
public static createFromInsertable<TInput, TOut, TThis extends new (args: TInput) => TOut>(
|
|
149
|
+
this: TThis,
|
|
150
|
+
input: TInput,
|
|
151
|
+
): TOut {
|
|
152
|
+
return new this(input);
|
|
153
|
+
}
|
|
154
|
+
|
|
145
155
|
public constructor(input: TInput | InternalTreeNode) {
|
|
146
156
|
super(privateToken);
|
|
147
157
|
const schema = this.constructor as typeof TreeNodeValid & TreeNodeSchema;
|
package/src/util/index.ts
CHANGED
package/src/util/typeCheck.ts
CHANGED
|
@@ -190,3 +190,16 @@ export type isAny<T> = boolean extends (T extends never ? true : false) ? true :
|
|
|
190
190
|
* `type _check = requireAssignableTo<T, Expected>;`
|
|
191
191
|
*/
|
|
192
192
|
export type requireAssignableTo<_A extends B, B> = true;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Returns a type parameter that is true iff the `Keys` union includes all the keys of `T`.
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* type _check = requireTrue<areOnlyKeys<{a: number, b: number}, 'a' | 'b'>> // true`
|
|
199
|
+
* type _check = requireTrue<areOnlyKeys<{a: number, b: number}, 'a'>> // false`
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export type areOnlyKeys<T, Keys extends keyof T> = isAssignableTo<
|
|
203
|
+
Record<string, never>,
|
|
204
|
+
Omit<T, Keys>
|
|
205
|
+
>;
|
package/src/util/utils.ts
CHANGED
|
@@ -105,18 +105,26 @@ export function compareSets<T>({
|
|
|
105
105
|
}): boolean {
|
|
106
106
|
for (const item of a.keys()) {
|
|
107
107
|
if (!b.has(item)) {
|
|
108
|
-
if (aExtra
|
|
108
|
+
if (aExtra !== undefined) {
|
|
109
|
+
if (!aExtra(item)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
109
113
|
return false;
|
|
110
114
|
}
|
|
111
115
|
} else {
|
|
112
|
-
if (same && !same(item)) {
|
|
116
|
+
if (same !== undefined && !same(item)) {
|
|
113
117
|
return false;
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
for (const item of b.keys()) {
|
|
118
122
|
if (!a.has(item)) {
|
|
119
|
-
if (bExtra
|
|
123
|
+
if (bExtra !== undefined) {
|
|
124
|
+
if (!bExtra(item)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
120
128
|
return false;
|
|
121
129
|
}
|
|
122
130
|
}
|
|
@@ -219,19 +227,24 @@ export function count(iterable: Iterable<unknown>): number {
|
|
|
219
227
|
|
|
220
228
|
/**
|
|
221
229
|
* Use for Json compatible data.
|
|
230
|
+
*
|
|
231
|
+
* @typeparam TExtra - Type permitted in addition to the normal JSON types.
|
|
232
|
+
* Commonly used for to allow {@link @fluidframework/core-interfaces#IFluidHandle} within the otherwise JSON compatible content.
|
|
233
|
+
*
|
|
222
234
|
* @remarks
|
|
223
235
|
* This does not robustly forbid non json comparable data via type checking,
|
|
224
236
|
* but instead mostly restricts access to it.
|
|
225
237
|
* @alpha
|
|
226
238
|
*/
|
|
227
|
-
export type JsonCompatible =
|
|
239
|
+
export type JsonCompatible<TExtra = never> =
|
|
228
240
|
| string
|
|
229
241
|
| number
|
|
230
242
|
| boolean
|
|
231
243
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
232
244
|
| null
|
|
233
|
-
| JsonCompatible[]
|
|
234
|
-
| JsonCompatibleObject
|
|
245
|
+
| JsonCompatible<TExtra>[]
|
|
246
|
+
| JsonCompatibleObject<TExtra>
|
|
247
|
+
| TExtra;
|
|
235
248
|
|
|
236
249
|
/**
|
|
237
250
|
* Use for Json object compatible data.
|
|
@@ -240,7 +253,7 @@ export type JsonCompatible =
|
|
|
240
253
|
* but instead mostly restricts access to it.
|
|
241
254
|
* @alpha
|
|
242
255
|
*/
|
|
243
|
-
export type JsonCompatibleObject = { [P in string]?: JsonCompatible };
|
|
256
|
+
export type JsonCompatibleObject<TExtra = never> = { [P in string]?: JsonCompatible<TExtra> };
|
|
244
257
|
|
|
245
258
|
/**
|
|
246
259
|
* Use for readonly view of Json compatible data.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toFlexSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAGN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAM1B;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,CAoB1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAY/E;AAQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,CAK7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,oBAAoB,CAgC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toFlexSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAC9E,uEAAsE;AAEtE,+CAY0B;AAC1B,4DAA+E;AAC/E,+CAAgE;AAChE,8CAAgE;AAChE,qDAK0B;AAC1B,6DAAuD;AACvD,2DAAqD;AACrD,6DAA0D;AAC1D,+CAAuD;AAEvD;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAyB;IACvD,MAAM,UAAU,GAAwD,IAAI,GAAG,EAAE,CAAC;IAClF,IAAA,oCAAe,EAAC,IAAI,EAAE;QACrB,IAAI,CAAC,MAAM;YACV,IAAI,UAAU,CAAC,GAAG,CAAC,IAAA,gBAAK,EAAC,MAAM,CAAC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AAC;aACrC,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,mBAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,iCAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,mBAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,IAAA,iBAAM,EAAC,IAAA,uCAAkB,EAAC,MAAM,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;YAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;gBAChD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,iCAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD;YACC,IAAA,0BAAe,EAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC;AAhCD,0CAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, fail, isReadonlyArray } from \"../util/index.js\";\nimport { NodeKind, type TreeNodeSchema } from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n} from \"./schemaTypes.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"./objectNodeTypes.js\";\nimport { normalizeFlexListEager } from \"./flexList.js\";\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\twalkFieldSchema(root, {\n\t\tnode(schema) {\n\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tnodeSchema.set(brand(schema.identifier), getStoredSchema(schema));\n\t\t},\n\t});\n\n\treturn {\n\t\tnodeSchema,\n\t\trootFieldSchema: convertField(root),\n\t};\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: ImplicitFieldSchema): TreeFieldStoredSchema {\n\tlet kind: FieldKindIdentifier;\n\tlet allowedTypes: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind = convertFieldKind.get(schema.kind)?.identifier ?? fail(\"Invalid field kind\");\n\t\tallowedTypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required.identifier;\n\t\tallowedTypes = schema;\n\t}\n\tconst types = convertAllowedTypes(allowedTypes);\n\treturn { kind, types };\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.\n */\nexport function convertAllowedTypes(schema: ImplicitAllowedTypes): TreeTypeSet {\n\tif (isReadonlyArray(schema)) {\n\t\treturn new Set(normalizeFlexListEager(schema).map((item) => brand(item.identifier)));\n\t}\n\treturn new Set([brand(schema.identifier)]);\n}\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n */\nexport function getStoredSchema(schema: TreeNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);\n\t\t\treturn new LeafNodeStoredSchema(schema.info);\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst types = convertAllowedTypes(fieldInfo);\n\t\t\treturn new MapNodeStoredSchema({ kind: FieldKinds.optional.identifier, types });\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes: convertAllowedTypes(fieldInfo),\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tassert(isObjectNodeSchema(schema), 0xa4b /* invalid kind */);\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const field of schema.flexKeyMap.values()) {\n\t\t\t\tfields.set(field.storedKey, convertField(field.schema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(kind);\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toFlexSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAGN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAM1B;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,CAoB1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CAY/E;AAQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,CAK7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,oBAAoB,CAgC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toFlexSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAQtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAuB,MAAM,iBAAiB,CAA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D,MAAM,KAAK,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC7C,OAAO,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACrB,MAAM,SAAS,GAAG,MAAM,CAAC,IAA4B,CAAC;YACtD,MAAM,KAAK,GAAG;gBACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;gBACpC,KAAK,EAAE,mBAAmB,CAAC,SAAS,CAAC;aACrC,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;YAC/D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;gBAChD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD;YACC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, fail, isReadonlyArray } from \"../util/index.js\";\nimport { NodeKind, type TreeNodeSchema } from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n} from \"./schemaTypes.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"./objectNodeTypes.js\";\nimport { normalizeFlexListEager } from \"./flexList.js\";\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\twalkFieldSchema(root, {\n\t\tnode(schema) {\n\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tnodeSchema.set(brand(schema.identifier), getStoredSchema(schema));\n\t\t},\n\t});\n\n\treturn {\n\t\tnodeSchema,\n\t\trootFieldSchema: convertField(root),\n\t};\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: ImplicitFieldSchema): TreeFieldStoredSchema {\n\tlet kind: FieldKindIdentifier;\n\tlet allowedTypes: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind = convertFieldKind.get(schema.kind)?.identifier ?? fail(\"Invalid field kind\");\n\t\tallowedTypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required.identifier;\n\t\tallowedTypes = schema;\n\t}\n\tconst types = convertAllowedTypes(allowedTypes);\n\treturn { kind, types };\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link TreeTypeSet}.\n */\nexport function convertAllowedTypes(schema: ImplicitAllowedTypes): TreeTypeSet {\n\tif (isReadonlyArray(schema)) {\n\t\treturn new Set(normalizeFlexListEager(schema).map((item) => brand(item.identifier)));\n\t}\n\treturn new Set([brand(schema.identifier)]);\n}\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n */\nexport function getStoredSchema(schema: TreeNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);\n\t\t\treturn new LeafNodeStoredSchema(schema.info);\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst types = convertAllowedTypes(fieldInfo);\n\t\t\treturn new MapNodeStoredSchema({ kind: FieldKinds.optional.identifier, types });\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes: convertAllowedTypes(fieldInfo),\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tassert(isObjectNodeSchema(schema), 0xa4b /* invalid kind */);\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const field of schema.flexKeyMap.values()) {\n\t\t\t\tfields.set(field.storedKey, convertField(field.schema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields);\n\t\t}\n\t\tdefault:\n\t\t\tunreachableCase(kind);\n\t}\n}\n"]}
|
|
File without changes
|