@fluidframework/tree 2.4.0 → 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 +12 -1
- package/CHANGELOG.md +371 -0
- package/api-report/tree.alpha.api.md +271 -80
- package/api-report/tree.beta.api.md +100 -51
- package/api-report/tree.legacy.alpha.api.md +99 -50
- package/api-report/tree.legacy.public.api.md +99 -50
- package/api-report/tree.public.api.md +99 -50
- package/dist/alpha.d.ts +32 -2
- package/dist/beta.d.ts +6 -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/events/interop.d.ts +1 -7
- package/dist/events/interop.d.ts.map +1 -1
- package/dist/events/interop.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.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/feature-libraries/object-forest/objectForest.js +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +2 -2
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- 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/legacy.d.ts +6 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +6 -0
- 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/treeApi.d.ts +6 -6
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.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 +11 -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 +80 -33
- 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 +6 -24
- 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 +2 -2
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +7 -7
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +10 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +31 -21
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +16 -12
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +4 -0
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +3 -3
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.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 +122 -5
- 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 +69 -17
- 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 +15 -4
- 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 +51 -11
- 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 +2 -1
- 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 +6 -6
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +15 -5
- 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 +6 -0
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +4 -2
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +210 -18
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +66 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toMapTree.d.ts +4 -2
- package/dist/simple-tree/toMapTree.d.ts.map +1 -1
- package/dist/simple-tree/toMapTree.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 +3 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +3 -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/typeUtils.d.ts +61 -0
- package/dist/util/typeUtils.d.ts.map +1 -1
- package/dist/util/typeUtils.js +27 -0
- package/dist/util/typeUtils.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 +32 -2
- package/lib/beta.d.ts +6 -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/events/interop.d.ts +1 -7
- package/lib/events/interop.d.ts.map +1 -1
- package/lib/events/interop.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.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/feature-libraries/object-forest/objectForest.js +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +2 -2
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- 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/legacy.d.ts +6 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +6 -0
- 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/treeApi.d.ts +6 -6
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.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 +11 -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 +80 -33
- 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 +6 -24
- 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 +2 -2
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +7 -7
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +6 -4
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +30 -19
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +16 -12
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +4 -0
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +3 -3
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.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 +122 -5
- 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 +69 -17
- 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 +15 -4
- 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 +51 -11
- 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 +2 -1
- 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 +6 -6
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +5 -5
- 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 +6 -0
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +4 -2
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +210 -18
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +64 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toMapTree.d.ts +4 -2
- package/lib/simple-tree/toMapTree.d.ts.map +1 -1
- package/lib/simple-tree/toMapTree.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 +3 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- 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/typeUtils.d.ts +61 -0
- package/lib/util/typeUtils.d.ts.map +1 -1
- package/lib/util/typeUtils.js +25 -1
- package/lib/util/typeUtils.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 +55 -30
- 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/events/interop.ts +1 -12
- package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.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/feature-libraries/object-forest/objectForest.ts +1 -1
- package/src/feature-libraries/treeCursorUtils.ts +2 -2
- package/src/index.ts +36 -6
- package/src/internalTypes.ts +4 -0
- 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 +64 -13
- package/src/shared-tree/sharedTree.ts +29 -9
- package/src/shared-tree/treeApi.ts +19 -9
- package/src/shared-tree/treeApiAlpha.ts +401 -0
- package/src/shared-tree/treeCheckout.ts +28 -5
- package/src/shared-tree-core/editManager.ts +126 -59
- 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 +33 -65
- package/src/simple-tree/api/customTree.ts +3 -2
- package/src/simple-tree/api/index.ts +19 -8
- package/src/simple-tree/api/schemaCreationUtilities.ts +59 -37
- package/src/simple-tree/api/schemaFactory.ts +28 -12
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +3 -3
- package/src/simple-tree/api/storedSchema.ts +1 -1
- package/src/simple-tree/api/tree.ts +152 -7
- package/src/simple-tree/api/treeApiBeta.ts +35 -31
- package/src/simple-tree/api/typesUnsafe.ts +125 -30
- package/src/simple-tree/api/verboseTree.ts +3 -0
- package/src/simple-tree/arrayNode.ts +38 -17
- package/src/simple-tree/core/getOrCreateNode.ts +1 -1
- package/src/simple-tree/core/treeNodeSchema.ts +107 -34
- package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
- package/src/simple-tree/core/withType.ts +2 -1
- package/src/simple-tree/createContext.ts +1 -1
- package/src/simple-tree/index.ts +34 -3
- package/src/simple-tree/leafNodeSchema.ts +6 -1
- package/src/simple-tree/mapNode.ts +13 -4
- package/src/simple-tree/objectNode.ts +5 -3
- package/src/simple-tree/schemaTypes.ts +342 -36
- package/src/simple-tree/toMapTree.ts +4 -1
- package/src/simple-tree/treeNodeValid.ts +11 -1
- package/src/util/index.ts +7 -0
- package/src/util/typeCheck.ts +13 -0
- package/src/util/typeUtils.ts +87 -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/.vscode/settings.json
CHANGED
|
@@ -15,7 +15,18 @@
|
|
|
15
15
|
// This extension appears to invoke mocha programmatically, meaning that the enablement of this option in the common
|
|
16
16
|
// mocha test config isn't sufficient; it also needs to be enabled here.
|
|
17
17
|
"mochaExplorer.nodeArgv": ["--conditions", "allow-ff-test-exports"],
|
|
18
|
-
"cSpell.words": [
|
|
18
|
+
"cSpell.words": [
|
|
19
|
+
"contravariance",
|
|
20
|
+
"contravariantly",
|
|
21
|
+
"covariantly",
|
|
22
|
+
"deprioritized",
|
|
23
|
+
"endregion",
|
|
24
|
+
"fluidframework",
|
|
25
|
+
"insertable",
|
|
26
|
+
"reentrantly",
|
|
27
|
+
"typeparam",
|
|
28
|
+
"unhydrated",
|
|
29
|
+
],
|
|
19
30
|
|
|
20
31
|
// Enable biome as default formatter, and disable rules that disagree with it
|
|
21
32
|
"editor.defaultFormatter": "biomejs.biome",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,376 @@
|
|
|
1
1
|
# @fluidframework/tree
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ✨ New! Alpha APIs for tree data import and export ([#22566](https://github.com/microsoft/FluidFramework/pull/22566)) [18a23e8816](https://github.com/microsoft/FluidFramework/commit/18a23e8816467f2ed0c9d6d8637b70d99aa48b7a)
|
|
8
|
+
|
|
9
|
+
A collection of new `@alpha` APIs for importing and exporting tree content and schema from SharedTrees has been added to `TreeAlpha`.
|
|
10
|
+
These include import and export APIs for `VerboseTree`, `ConciseTree` and compressed tree formats.
|
|
11
|
+
|
|
12
|
+
`TreeAlpha.create` is also added to allow constructing trees with a more general API instead of having to use the schema constructor directly (since that doesn't handle polymorphic roots, or non-schema aware code).
|
|
13
|
+
|
|
14
|
+
The function `independentInitializedView` has been added to provide a way to combine data from the existing `extractPersistedSchema` and new `TreeAlpha.exportCompressed` back into a `TreeView` in a way which can support safely importing data which could have been exported with a different schema.
|
|
15
|
+
This allows replicating the schema evolution process for Fluid documents stored in a service, but entirely locally without involving any collaboration services.
|
|
16
|
+
`independentView` has also been added, which is similar but handles the case of creating a new view without an existing schema or tree.
|
|
17
|
+
|
|
18
|
+
Together these APIs address several use-cases:
|
|
19
|
+
|
|
20
|
+
1. Using SharedTree as an in-memory non-collaborative datastore.
|
|
21
|
+
2. Importing and exporting data from a SharedTree to and from other services or storage locations (such as locally saved files).
|
|
22
|
+
3. Testing various scenarios without relying on a service.
|
|
23
|
+
4. Using SharedTree libraries for just the schema system and encode/decode support.
|
|
24
|
+
|
|
25
|
+
- Compilation no longer fails when building with TypeScript's libCheck option ([#22923](https://github.com/microsoft/FluidFramework/pull/22923)) [a1b4cdd45e](https://github.com/microsoft/FluidFramework/commit/a1b4cdd45ee9812e2598ab8d2854333d26a06eb4)
|
|
26
|
+
|
|
27
|
+
When compiling code using Fluid Framework with TypeScript's `libCheck` (meaning without [skipLibCheck](https://www.typescriptlang.org/tsconfig/#skipLibCheck)), two compile errors can be encountered:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
> tsc
|
|
31
|
+
|
|
32
|
+
node_modules/@fluidframework/merge-tree/lib/client.d.ts:124:18 - error TS2368: Type parameter name cannot be 'undefined'.
|
|
33
|
+
|
|
34
|
+
124 walkSegments<undefined>(handler: ISegmentAction<undefined>, start?: number, end?: number, accum?: undefined, splitRange?: boolean): void;
|
|
35
|
+
~~~~~~~~~
|
|
36
|
+
|
|
37
|
+
node_modules/@fluidframework/tree/lib/util/utils.d.ts:5:29 - error TS7016: Could not find a declaration file for module '@ungap/structured-clone'. 'node_modules/@ungap/structured-clone/esm/index.js' implicitly has an 'any' type.
|
|
38
|
+
Try `npm i --save-dev @types/ungap__structured-clone` if it exists or add a new declaration (.d.ts) file containing `declare module '@ungap/structured-clone';`
|
|
39
|
+
|
|
40
|
+
5 import structuredClone from "@ungap/structured-clone";
|
|
41
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The first error impacts projects using TypeScript 5.5 or greater and either of the `fluid-framework` or `@fluidframework/merge-tree` packages.
|
|
45
|
+
The second error impacts projects using the `noImplicitAny` tsconfig setting and the `fluid-framework` or `@fluidframework/tree` packages.
|
|
46
|
+
|
|
47
|
+
Both errors have been fixed.
|
|
48
|
+
|
|
49
|
+
This should allow `libCheck` to be reenabled in any impacted projects.
|
|
50
|
+
|
|
51
|
+
- A `.schema` member has been added to the alpha enum schema APIs ([#22874](https://github.com/microsoft/FluidFramework/pull/22874)) [645b9ed695](https://github.com/microsoft/FluidFramework/commit/645b9ed69540338843ad14f1144ff4d1f80d6f09)
|
|
52
|
+
|
|
53
|
+
The return value from `@alpha` APIs `enumFromStrings` and `adaptEnum` now has a property named `schema` which can be used to include it in a parent schema.
|
|
54
|
+
This replaces the use of `typedObjectValues` which has been removed.
|
|
55
|
+
|
|
56
|
+
Use of these APIs now look like:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const schemaFactory = new SchemaFactory("com.myApp");
|
|
60
|
+
const Mode = enumFromStrings(schemaFactory, ["Fun", "Cool"]);
|
|
61
|
+
type Mode = NodeFromSchema<(typeof Mode.schema)[number]>;
|
|
62
|
+
class Parent extends schemaFactory.object("Parent", { mode: Mode.schema }) {}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Previously, the last two lines would have been:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
type Mode = NodeFromSchema<(typeof Mode)[keyof typeof Mode]>; // This no longer works
|
|
69
|
+
class Parent extends schemaFactory.object("Parent", { mode: typedObjectValues(Mode) }) {} // This no longer works
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- TreeNodeSchemaClass now specifies its TNode as TreeNode ([#22938](https://github.com/microsoft/FluidFramework/pull/22938)) [b669a6efdb](https://github.com/microsoft/FluidFramework/commit/b669a6efdba685c71897cade4f907304f1a73910)
|
|
73
|
+
|
|
74
|
+
`TreeNodeSchemaClass`'s `TNode` parameter was formerly `unknown` and has been improved to be the more specific `TreeNode | TreeLeafValue`.
|
|
75
|
+
This change further narrows this to `TreeNode`.
|
|
76
|
+
|
|
77
|
+
`TreeNodeSchema`, which is more commonly used, still permits `TNode` of `TreeNode | TreeLeafValue`, so this change should have little impact on most code, but in some edge cases it can result in slightly more specific typing.
|
|
78
|
+
|
|
79
|
+
- Array and Map nodes can now be explicitly constructed with undefined or no argument ([#22946](https://github.com/microsoft/FluidFramework/pull/22946)) [176335ce88](https://github.com/microsoft/FluidFramework/commit/176335ce88d005159819c559b445a1655ec429d5)
|
|
80
|
+
|
|
81
|
+
The input parameter to the constructor and `create` methods of Array and Map nodes is now optional. When the optional parameter is omitted, an empty map or array will be created.
|
|
82
|
+
|
|
83
|
+
#### Examples
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
class Schema extends schemaFactory.array("x", schemaFactory.number) {}
|
|
87
|
+
|
|
88
|
+
// Existing support
|
|
89
|
+
const _fromIterable: Schema = new Schema([]);
|
|
90
|
+
|
|
91
|
+
// New
|
|
92
|
+
const _fromUndefined: Schema = new Schema(undefined);
|
|
93
|
+
const _fromNothing: Schema = new Schema();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
class Schema extends schemaFactory.map("x", schemaFactory.number) {}
|
|
98
|
+
|
|
99
|
+
// Existing support
|
|
100
|
+
const _fromIterable: Schema = new Schema([]);
|
|
101
|
+
const _fromObject: Schema = new Schema({});
|
|
102
|
+
|
|
103
|
+
// New
|
|
104
|
+
const _fromUndefined: Schema = new Schema(undefined);
|
|
105
|
+
const _fromNothing: Schema = new Schema();
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const Schema = schemaFactory.array(schemaFactory.number);
|
|
110
|
+
type Schema = NodeFromSchema<typeof Schema>;
|
|
111
|
+
|
|
112
|
+
// Existing support
|
|
113
|
+
const _fromIterable: Schema = Schema.create([]);
|
|
114
|
+
|
|
115
|
+
// New
|
|
116
|
+
const _fromUndefined: Schema = Schema.create(undefined);
|
|
117
|
+
const _fromNothing: Schema = Schema.create();
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const Schema = schemaFactory.map(schemaFactory.number);
|
|
122
|
+
type Schema = NodeFromSchema<typeof Schema>;
|
|
123
|
+
// Existing support
|
|
124
|
+
const _fromIterable: Schema = Schema.create([]);
|
|
125
|
+
const _fromObject: Schema = Schema.create({});
|
|
126
|
+
|
|
127
|
+
// New
|
|
128
|
+
const _fromUndefined: Schema = Schema.create(undefined);
|
|
129
|
+
const _fromNothing: Schema = Schema.create();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- Typing has been improved when an exact TypeScript type for a schema is not provided ([#22763](https://github.com/microsoft/FluidFramework/pull/22763)) [05197d6d3f](https://github.com/microsoft/FluidFramework/commit/05197d6d3f0189ecd61fd74ec55f6836e6797249)
|
|
133
|
+
|
|
134
|
+
The Tree APIs are designed to be used in a strongly typed way, with the full TypeScript type for the schema always being provided.
|
|
135
|
+
Due to limitations of the TypeScript language, there was no practical way to prevent less descriptive types, like `TreeNodeSchema` or `ImplicitFieldSchema`, from being used where the type of a specific schema was intended.
|
|
136
|
+
Code which does this will encounter several issues with tree APIs, and this change fixes some of those issues.
|
|
137
|
+
This change mainly fixes that `NodeFromSchema<TreeNodeSchema>` used to return `unknown` and now returns `TreeNode | TreeLeafValue`.
|
|
138
|
+
|
|
139
|
+
This change by itself seems mostly harmless, as it just improves the precision of the typing in this one edge case.
|
|
140
|
+
Unfortunately, there are other typing bugs which complicate the situation, causing APIs for inserting data into the tree to also behave poorly when given non-specific types like `TreeNodeSchema`.
|
|
141
|
+
These APIs include cases like `TreeView.initialize`.
|
|
142
|
+
|
|
143
|
+
This incorrectly allowed some usage like taking a type-erased schema and initial tree pair, creating a view of type `TreeView<ImplicitFieldSchema>`, then initializing it.
|
|
144
|
+
With the typing being partly fixed, some unsafe inputs are still allowed when trying to initialize such a view, but some are now prevented.
|
|
145
|
+
|
|
146
|
+
This use-case of modifying trees in code not that is not strongly typed by the exact schema was not intended to be supported.
|
|
147
|
+
Despite this, it did mostly work in some cases, and has some real use-cases (like tests looping over test data consisting of pairs of schema and initial trees).
|
|
148
|
+
To help mitigate the impact of this change, some experimental `@alpha` APIs have been introduced to help address these previously unsupported but somewhat working use-cases.
|
|
149
|
+
|
|
150
|
+
Before this change:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { TinyliciousClient } from "@fluidframework/tinylicious-client";
|
|
154
|
+
import {
|
|
155
|
+
SchemaFactory,
|
|
156
|
+
SharedTree,
|
|
157
|
+
TreeViewConfiguration,
|
|
158
|
+
type TreeNodeSchema,
|
|
159
|
+
} from "fluid-framework";
|
|
160
|
+
|
|
161
|
+
// Create a ITree instance
|
|
162
|
+
const tinyliciousClient = new TinyliciousClient();
|
|
163
|
+
const { container } = await tinyliciousClient.createContainer({ initialObjects: {} }, "2");
|
|
164
|
+
const tree = await container.create(SharedTree);
|
|
165
|
+
|
|
166
|
+
const schemaFactory = new SchemaFactory("demo");
|
|
167
|
+
|
|
168
|
+
// Bad: This loses the schema aware type information. `: TreeNodeSchema` should be omitted to preserve strong typing.
|
|
169
|
+
const schema: TreeNodeSchema = schemaFactory.array(schemaFactory.number);
|
|
170
|
+
const config = new TreeViewConfiguration({ schema });
|
|
171
|
+
|
|
172
|
+
// This view is typed as `TreeView<TreeNodeSchema>`, which does not work well since it's missing the actual schema type information.
|
|
173
|
+
const view = tree.viewWith(config);
|
|
174
|
+
// Root is typed as `unknown` allowing invalid assignment operations.
|
|
175
|
+
view.root = "invalid";
|
|
176
|
+
view.root = {};
|
|
177
|
+
// Since all assignments are allowed, valid ones still work:
|
|
178
|
+
view.root = [];
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
After this change:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// Root is now typed as `TreeNode | TreeLeafValue`, still allowing some invalid assignment operations.
|
|
185
|
+
// In the future this should be prevented as well, since the type of the setter in this case should be `never`.
|
|
186
|
+
view.root = "invalid";
|
|
187
|
+
// This no longer compiles:
|
|
188
|
+
view.root = {};
|
|
189
|
+
// This also no longer compiles despite being valid at runtime:
|
|
190
|
+
view.root = [];
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
For code that wants to continue using an unsafe API, which can result in runtime errors if the data does not follow the schema, a new alternative has been added to address this use-case. A special type `UnsafeUnknownSchema` can now be used to opt into allowing all valid trees to be provided.
|
|
194
|
+
Note that this leaves ensuring the data is in schema up to the user.
|
|
195
|
+
For now these adjusted APIs can be accessed by casting the view to `TreeViewAlpha<UnsafeUnknownSchema>`.
|
|
196
|
+
If stabilized, this option will be added to `TreeView` directly.
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const viewAlpha = view as TreeViewAlpha<UnsafeUnknownSchema>;
|
|
200
|
+
viewAlpha.initialize([]);
|
|
201
|
+
viewAlpha.root = [];
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Additionally, this seems to have negatively impacted co-recursive schema which declare a co-recursive array as the first schema in the co-recursive cycle.
|
|
205
|
+
Like the TypeScript language our schema system is built on, we don't guarantee exactly which recursive type will compile, but will do our best to ensure useful recursive schema can be created easily.
|
|
206
|
+
In this case a slight change may be required to some recursive schema to get them to compile again:
|
|
207
|
+
|
|
208
|
+
For example this schema used to compile:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
class A extends sf.arrayRecursive("A", [() => B]) {}
|
|
212
|
+
{
|
|
213
|
+
type _check = ValidateRecursiveSchema<typeof A>;
|
|
214
|
+
}
|
|
215
|
+
// Used to work, but breaks in this update.
|
|
216
|
+
class B extends sf.object("B", { x: A }) {}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
But now you must use the recursive functions like `objectRecursive` for types which are co-recursive with an array in some cases.
|
|
220
|
+
In our example, it can be fixed as follows:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
class A extends sf.arrayRecursive("A", [() => B]) {}
|
|
224
|
+
{
|
|
225
|
+
type _check = ValidateRecursiveSchema<typeof A>;
|
|
226
|
+
}
|
|
227
|
+
// Fixed corecursive type, using "Recursive" method variant to declare schema.
|
|
228
|
+
class B extends sf.objectRecursive("B", { x: A }) {}
|
|
229
|
+
{
|
|
230
|
+
type _check = ValidateRecursiveSchema<typeof B>;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Note: while the following pattern may still compile, we recommend using the previous pattern instead since the one below may break in the future.
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
class B extends sf.objectRecursive("B", { x: [() => A] }) {}
|
|
238
|
+
{
|
|
239
|
+
type _check = ValidateRecursiveSchema<typeof B>;
|
|
240
|
+
}
|
|
241
|
+
// Works, for now, but not recommended.
|
|
242
|
+
class A extends sf.array("A", B) {}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- The strictness of input tree types when inexact schemas are provided has been improved ([#22874](https://github.com/microsoft/FluidFramework/pull/22874)) [645b9ed695](https://github.com/microsoft/FluidFramework/commit/645b9ed69540338843ad14f1144ff4d1f80d6f09)
|
|
246
|
+
|
|
247
|
+
Consider the following code where the type of the schema is not exactly specified:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
const schemaFactory = new SchemaFactory("com.myApp");
|
|
251
|
+
class A extends schemaFactory.object("A", {}) {}
|
|
252
|
+
class B extends schemaFactory.array("B", schemaFactory.number) {}
|
|
253
|
+
|
|
254
|
+
// Gives imprecise type (typeof A | typeof B)[]. The desired precise type here is [typeof A, typeof B].
|
|
255
|
+
const schema = [A, B];
|
|
256
|
+
|
|
257
|
+
const config = new TreeViewConfiguration({ schema });
|
|
258
|
+
const view = sharedTree.viewWith(config);
|
|
259
|
+
|
|
260
|
+
// Does not compile since setter for root is typed `never` due to imprecise schema.
|
|
261
|
+
view.root = [];
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The assignment of `view.root` is disallowed since a schema with type `(typeof A | typeof B)[]` could be any of:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
const schema: (typeof A | typeof B)[] = [A];
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
const schema: (typeof A | typeof B)[] = [B];
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
const schema: (typeof A | typeof B)[] = [A, B];
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
The attempted assignment is not compatible with all of these (specifically it is incompatible with the first one) so performing this assignment could make the tree out of schema and is thus disallowed.
|
|
279
|
+
|
|
280
|
+
To avoid this ambiguity and capture the precise type of `[typeof A, typeof B]`, use one of the following patterns:
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
const schema = [A, B] as const;
|
|
284
|
+
const config = new TreeViewConfiguration({ schema });
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const config = new TreeViewConfiguration({ schema: [A, B] });
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
To help update existing code which accidentally depended on this bug, an `@alpha` API `unsafeArrayToTuple` has been added.
|
|
292
|
+
Many usages of this API will produce incorrectly typed outputs.
|
|
293
|
+
However, when given `AllowedTypes` arrays which should not contain any unions, but that were accidentally flattened to a single union, it can fix them:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
// Gives imprecise type (typeof A | typeof B)[]
|
|
297
|
+
const schemaBad = [A, B];
|
|
298
|
+
// Fixes the type to be [typeof A, typeof B]
|
|
299
|
+
const schema = unsafeArrayToTuple(schemaBad);
|
|
300
|
+
|
|
301
|
+
const config = new TreeViewConfiguration({ schema });
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
- SharedTree branching API has been improved ([#22970](https://github.com/microsoft/FluidFramework/pull/22970)) [80ed0284f0](https://github.com/microsoft/FluidFramework/commit/80ed0284f01107d2ba8bcf2f3ebaf6175367603a)
|
|
305
|
+
|
|
306
|
+
The alpha SharedTree branching API has been updated to be more accessible and intuitive.
|
|
307
|
+
The branching functions (`branch`, `merge`, `rebaseOnto`, etc.) are now directly available on the view object rather than a separate object.
|
|
308
|
+
In particular, `TreeViewAlpha` is now a `TreeBranch`, which exposes the methods to coordinate branches.
|
|
309
|
+
|
|
310
|
+
The existing `TreeBranch` type has been renamed to `BranchableTree` and is now **deprecated**.
|
|
311
|
+
|
|
312
|
+
See the `TreeBranch` interface for more details.
|
|
313
|
+
|
|
314
|
+
The new API is used e.g. as follows:
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
const sf = new SchemaFactory("example");
|
|
318
|
+
class StringArray extends sf.array("StringArray", sf.string) {}
|
|
319
|
+
|
|
320
|
+
function example(view: TreeViewAlpha<typeof StringArray>): void {
|
|
321
|
+
// Create a branch
|
|
322
|
+
const branch = view.fork();
|
|
323
|
+
// Modify the branch rather than the main view
|
|
324
|
+
branch.root.insertAtEnd("new string");
|
|
325
|
+
// `view` does not yet contain "new string"
|
|
326
|
+
// ...
|
|
327
|
+
// Later, merge the branch into the main view
|
|
328
|
+
view.merge(branch);
|
|
329
|
+
// `view` now contains "new string"
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Here is the equivalent behavior with the previous API, for reference:
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
const sf = new SchemaFactory("example");
|
|
337
|
+
class StringArray extends sf.array("StringArray", sf.string) {}
|
|
338
|
+
|
|
339
|
+
function example(view: TreeViewAlpha<typeof StringArray>): void {
|
|
340
|
+
// Get the branch for the view
|
|
341
|
+
const branch = getBranch(view);
|
|
342
|
+
const fork = branch.branch();
|
|
343
|
+
// Modify the branch rather than the main view
|
|
344
|
+
fork.root.insertAtEnd("new string");
|
|
345
|
+
// `view` does not yet contain "new string"
|
|
346
|
+
// ...
|
|
347
|
+
// Later, merge the branch into the main view
|
|
348
|
+
branch.merge(fork);
|
|
349
|
+
// `view` now contains "new string"
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Additionally, there is a new API to acquire the branch from a node:
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// All nodes that have been inserted into the tree belong to a branch - this retrieves that branch
|
|
357
|
+
const branch = TreeAlpha.branch(node);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
To convert the branch object to a view with a known schema, use:
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
if (branch.hasRootSchema(MySchema)) {
|
|
364
|
+
const view = branch; // `branch` is now typed as a `TreeViewAlpha<MySchema>`
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Use the following function to expose the alpha APIs on a `TreeView` that is not typed as a `TreeViewAlpha`:
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
const viewAlpha = asTreeViewAlpha(view);
|
|
372
|
+
```
|
|
373
|
+
|
|
3
374
|
## 2.4.0
|
|
4
375
|
|
|
5
376
|
### Minor Changes
|