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