@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/src/events/interop.ts
CHANGED
|
@@ -5,21 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import type { IEvent } from "@fluidframework/core-interfaces";
|
|
7
7
|
import type { Listeners } from "./listeners.js";
|
|
8
|
+
import type { UnionToIntersection } from "../util/index.js";
|
|
8
9
|
|
|
9
10
|
// TODO: this file is currently unused. Use it or remove it.
|
|
10
11
|
|
|
11
|
-
/**
|
|
12
|
-
* Convert a union of types to an intersection of those types. Useful for `TransformEvents`.
|
|
13
|
-
* @privateRemarks
|
|
14
|
-
* First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.
|
|
15
|
-
* Then the constraint on the type parameter in this new context is inferred, giving the intersection.
|
|
16
|
-
*/
|
|
17
|
-
export type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (
|
|
18
|
-
k: infer U,
|
|
19
|
-
) => unknown
|
|
20
|
-
? U
|
|
21
|
-
: never;
|
|
22
|
-
|
|
23
12
|
/**
|
|
24
13
|
* Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable
|
|
25
14
|
* by an IEventProvider from `@fluidframework/core-interfaces`.
|
|
@@ -253,7 +253,7 @@ export class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor
|
|
|
253
253
|
return {
|
|
254
254
|
field:
|
|
255
255
|
this.indexStack.length === 1
|
|
256
|
-
? prefix?.rootFieldOverride ?? this.getFieldKey()
|
|
256
|
+
? (prefix?.rootFieldOverride ?? this.getFieldKey())
|
|
257
257
|
: this.getFieldKey(),
|
|
258
258
|
parent: this.getOffsetPath(1, prefix),
|
|
259
259
|
};
|
|
@@ -533,7 +533,7 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
|
|
|
533
533
|
this.indexOfField =
|
|
534
534
|
fieldInfo === undefined
|
|
535
535
|
? fieldMap.size
|
|
536
|
-
: fieldInfo.indexOfParentField ?? fail("children should have parents");
|
|
536
|
+
: (fieldInfo.indexOfParentField ?? fail("children should have parents"));
|
|
537
537
|
this.fieldKey = key;
|
|
538
538
|
this.mode = CursorLocationType.Fields;
|
|
539
539
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type FieldKey,
|
|
10
10
|
type FieldKindIdentifier,
|
|
11
11
|
type FieldUpPath,
|
|
12
|
+
type ITreeCursorSynchronous,
|
|
12
13
|
type TreeNodeSchemaIdentifier,
|
|
13
14
|
type TreeValue,
|
|
14
15
|
anchorSlot,
|
|
@@ -184,6 +185,14 @@ export interface FlexTreeNode extends FlexTreeEntity {
|
|
|
184
185
|
* If well-formed, it must follow this schema.
|
|
185
186
|
*/
|
|
186
187
|
readonly schema: TreeNodeSchemaIdentifier;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Get a cursor for the underlying data.
|
|
191
|
+
* @remarks
|
|
192
|
+
* This cursor might be one the node uses in its implementation, and thus must be returned to its original location before using any other APIs to interact with the tree.
|
|
193
|
+
* Must not be held onto across edits or any other tree API use.
|
|
194
|
+
*/
|
|
195
|
+
borrowCursor(): ITreeCursorSynchronous;
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
/**
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type AnchorNode,
|
|
11
11
|
CursorLocationType,
|
|
12
12
|
type FieldKey,
|
|
13
|
+
type ITreeCursorSynchronous,
|
|
13
14
|
type FieldKindIdentifier,
|
|
14
15
|
type ITreeSubscriptionCursor,
|
|
15
16
|
type TreeNavigationResult,
|
|
@@ -91,6 +92,10 @@ export class LazyTreeNode extends LazyEntity<Anchor> implements FlexTreeNode {
|
|
|
91
92
|
this.#removeDeleteCallback = anchorNode.on("afterDestroy", cleanupTree);
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
public borrowCursor(): ITreeCursorSynchronous {
|
|
96
|
+
return this[cursorSymbol] as ITreeCursorSynchronous;
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
protected override [tryMoveCursorToAnchorSymbol](
|
|
95
100
|
cursor: ITreeSubscriptionCursor,
|
|
96
101
|
): TreeNavigationResult {
|
|
@@ -140,7 +140,7 @@ export class ObjectForest implements IEditableForest {
|
|
|
140
140
|
);
|
|
141
141
|
if (this.currentCursors.size > 1) {
|
|
142
142
|
const unexpectedSources = [...this.currentCursors].flatMap((c) =>
|
|
143
|
-
c === cursor ? [] : c.source ?? null,
|
|
143
|
+
c === cursor ? [] : (c.source ?? null),
|
|
144
144
|
);
|
|
145
145
|
|
|
146
146
|
throw new Error(
|
|
@@ -194,7 +194,7 @@ class StackCursor<TNode> extends SynchronousCursor implements CursorWithNode<TNo
|
|
|
194
194
|
return {
|
|
195
195
|
field:
|
|
196
196
|
this.indexStack.length === 1
|
|
197
|
-
? prefix?.rootFieldOverride ?? this.getFieldKey()
|
|
197
|
+
? (prefix?.rootFieldOverride ?? this.getFieldKey())
|
|
198
198
|
: this.getFieldKey(),
|
|
199
199
|
parent: this.getOffsetPath(1, prefix),
|
|
200
200
|
};
|
|
@@ -427,7 +427,7 @@ export function prefixFieldPath(
|
|
|
427
427
|
return path;
|
|
428
428
|
}
|
|
429
429
|
return {
|
|
430
|
-
field: path.parent === undefined ? prefix.rootFieldOverride ?? path.field : path.field,
|
|
430
|
+
field: path.parent === undefined ? (prefix.rootFieldOverride ?? path.field) : path.field,
|
|
431
431
|
parent: prefixPath(prefix, path.parent),
|
|
432
432
|
};
|
|
433
433
|
}
|
package/src/index.ts
CHANGED
|
@@ -58,8 +58,12 @@ export {
|
|
|
58
58
|
rollback,
|
|
59
59
|
type ForestOptions,
|
|
60
60
|
getBranch,
|
|
61
|
-
type
|
|
61
|
+
type BranchableTree,
|
|
62
62
|
type TreeBranchFork,
|
|
63
|
+
independentInitializedView,
|
|
64
|
+
type ViewContent,
|
|
65
|
+
TreeAlpha,
|
|
66
|
+
independentView,
|
|
63
67
|
} from "./shared-tree/index.js";
|
|
64
68
|
|
|
65
69
|
export {
|
|
@@ -114,6 +118,8 @@ export {
|
|
|
114
118
|
type InsertableObjectFromSchemaRecordUnsafe,
|
|
115
119
|
type InsertableTreeFieldFromImplicitFieldUnsafe,
|
|
116
120
|
type FieldSchemaUnsafe,
|
|
121
|
+
type TreeNodeSchemaClassUnsafe,
|
|
122
|
+
type InsertableTreeNodeFromAllowedTypesUnsafe,
|
|
117
123
|
// System types (not in Internal types for various reasons, like doc links or cannot be named errors).
|
|
118
124
|
type typeSchemaSymbol,
|
|
119
125
|
type TreeNodeSchemaNonClass,
|
|
@@ -124,7 +130,15 @@ export {
|
|
|
124
130
|
adaptEnum,
|
|
125
131
|
enumFromStrings,
|
|
126
132
|
singletonSchema,
|
|
127
|
-
|
|
133
|
+
type UnsafeUnknownSchema,
|
|
134
|
+
type TreeViewAlpha,
|
|
135
|
+
type InsertableField,
|
|
136
|
+
type Insertable,
|
|
137
|
+
type InsertableContent,
|
|
138
|
+
type FactoryContent,
|
|
139
|
+
type FactoryContentObject,
|
|
140
|
+
type ReadableField,
|
|
141
|
+
type ReadSchema,
|
|
128
142
|
// test recursive schema for checking that d.ts files handles schema correctly
|
|
129
143
|
test_RecursiveObject,
|
|
130
144
|
test_RecursiveObject_base,
|
|
@@ -132,8 +146,13 @@ export {
|
|
|
132
146
|
// Beta APIs
|
|
133
147
|
TreeBeta,
|
|
134
148
|
type TreeChangeEventsBeta,
|
|
149
|
+
type VerboseTreeNode,
|
|
150
|
+
type EncodeOptions,
|
|
151
|
+
type ParseOptions,
|
|
152
|
+
type VerboseTree,
|
|
135
153
|
extractPersistedSchema,
|
|
136
154
|
comparePersistedSchema,
|
|
155
|
+
type ConciseTree,
|
|
137
156
|
// Back to normal types
|
|
138
157
|
type JsonTreeSchema,
|
|
139
158
|
type JsonSchemaId,
|
|
@@ -151,16 +170,23 @@ export {
|
|
|
151
170
|
getJsonSchema,
|
|
152
171
|
type LazyItem,
|
|
153
172
|
type Unenforced,
|
|
173
|
+
type ReadonlyArrayNode,
|
|
174
|
+
type InsertableTreeNodeFromAllowedTypes,
|
|
175
|
+
type Input,
|
|
176
|
+
type TreeBranch,
|
|
177
|
+
type TreeBranchEvents,
|
|
178
|
+
asTreeViewAlpha,
|
|
154
179
|
} from "./simple-tree/index.js";
|
|
155
180
|
export {
|
|
156
181
|
SharedTree,
|
|
157
182
|
configuredSharedTree,
|
|
158
183
|
} from "./treeFactory.js";
|
|
159
184
|
|
|
160
|
-
export
|
|
161
|
-
ICodecOptions,
|
|
162
|
-
JsonValidator,
|
|
163
|
-
SchemaValidationFunction,
|
|
185
|
+
export {
|
|
186
|
+
type ICodecOptions,
|
|
187
|
+
type JsonValidator,
|
|
188
|
+
type SchemaValidationFunction,
|
|
189
|
+
FluidClientVersion,
|
|
164
190
|
} from "./codec/index.js";
|
|
165
191
|
export { noopValidator } from "./codec/index.js";
|
|
166
192
|
export { typeboxValidator } from "./external-utilities/index.js";
|
|
@@ -171,6 +197,10 @@ export {
|
|
|
171
197
|
type RestrictiveReadonlyRecord,
|
|
172
198
|
type RestrictiveStringRecord,
|
|
173
199
|
type MakeNominal,
|
|
200
|
+
type IsUnion,
|
|
201
|
+
type UnionToIntersection,
|
|
202
|
+
type UnionToTuple,
|
|
203
|
+
type PopUnion,
|
|
174
204
|
} from "./util/index.js";
|
|
175
205
|
|
|
176
206
|
import * as InternalTypes from "./internalTypes.js";
|
package/src/internalTypes.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export type { _InlineTrick, FlattenKeys } from "./util/index.js";
|
|
11
11
|
export type {
|
|
12
12
|
ApplyKind,
|
|
13
|
+
ApplyKindInput,
|
|
13
14
|
NodeBuilderData,
|
|
14
15
|
FieldHasDefault,
|
|
15
16
|
TreeArrayNodeBase,
|
|
@@ -33,6 +34,9 @@ export type {
|
|
|
33
34
|
NodeBuilderDataUnsafe,
|
|
34
35
|
NodeFromSchemaUnsafe,
|
|
35
36
|
ReadonlyMapInlined,
|
|
37
|
+
TreeNodeSchemaUnsafe,
|
|
38
|
+
AllowedTypesUnsafe,
|
|
39
|
+
TreeNodeSchemaNonClassUnsafe,
|
|
36
40
|
} from "./simple-tree/index.js";
|
|
37
41
|
export type { FlexList, FlexListToUnion, ExtractItemType } from "./simple-tree/index.js";
|
|
38
42
|
|
package/src/packageVersion.ts
CHANGED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
+
import {
|
|
9
|
+
type IIdCompressor,
|
|
10
|
+
createIdCompressor,
|
|
11
|
+
} from "@fluidframework/id-compressor/internal";
|
|
12
|
+
import type { ICodecOptions } from "../codec/index.js";
|
|
13
|
+
import {
|
|
14
|
+
type RevisionTag,
|
|
15
|
+
RevisionTagCodec,
|
|
16
|
+
TreeStoredSchemaRepository,
|
|
17
|
+
initializeForest,
|
|
18
|
+
type ITreeCursorSynchronous,
|
|
19
|
+
mapCursorField,
|
|
20
|
+
} from "../core/index.js";
|
|
21
|
+
import {
|
|
22
|
+
createNodeKeyManager,
|
|
23
|
+
makeFieldBatchCodec,
|
|
24
|
+
makeSchemaCodec,
|
|
25
|
+
type FieldBatchEncodingContext,
|
|
26
|
+
defaultSchemaPolicy,
|
|
27
|
+
chunkTree,
|
|
28
|
+
defaultChunkPolicy,
|
|
29
|
+
TreeCompressionStrategy,
|
|
30
|
+
} from "../feature-libraries/index.js";
|
|
31
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
32
|
+
import type { Format } from "../feature-libraries/schema-index/format.js";
|
|
33
|
+
import type {
|
|
34
|
+
TreeViewConfiguration,
|
|
35
|
+
ImplicitFieldSchema,
|
|
36
|
+
TreeViewAlpha,
|
|
37
|
+
} from "../simple-tree/index.js";
|
|
38
|
+
import type { JsonCompatibleReadOnly, JsonCompatible } from "../util/index.js";
|
|
39
|
+
import {
|
|
40
|
+
buildConfiguredForest,
|
|
41
|
+
defaultSharedTreeOptions,
|
|
42
|
+
type ForestOptions,
|
|
43
|
+
} from "./sharedTree.js";
|
|
44
|
+
import { createTreeCheckout } from "./treeCheckout.js";
|
|
45
|
+
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create an uninitialized {@link TreeView} that is not tied to any {@link ITree} instance.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Such a view can never experience collaboration or be persisted to to a Fluid Container.
|
|
52
|
+
*
|
|
53
|
+
* This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.
|
|
54
|
+
* @alpha
|
|
55
|
+
*/
|
|
56
|
+
export function independentView<const TSchema extends ImplicitFieldSchema>(
|
|
57
|
+
config: TreeViewConfiguration<TSchema>,
|
|
58
|
+
options: ForestOptions & { idCompressor?: IIdCompressor | undefined },
|
|
59
|
+
): TreeViewAlpha<TSchema> {
|
|
60
|
+
const idCompressor: IIdCompressor = options.idCompressor ?? createIdCompressor();
|
|
61
|
+
const mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();
|
|
62
|
+
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
63
|
+
const schema = new TreeStoredSchemaRepository();
|
|
64
|
+
const forest = buildConfiguredForest(
|
|
65
|
+
options.forest ?? defaultSharedTreeOptions.forest,
|
|
66
|
+
schema,
|
|
67
|
+
idCompressor,
|
|
68
|
+
);
|
|
69
|
+
const checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {
|
|
70
|
+
forest,
|
|
71
|
+
schema,
|
|
72
|
+
});
|
|
73
|
+
const out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(
|
|
74
|
+
checkout,
|
|
75
|
+
config,
|
|
76
|
+
createNodeKeyManager(idCompressor),
|
|
77
|
+
);
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Such a view can never experience collaboration or be persisted to to a Fluid Container.
|
|
85
|
+
*
|
|
86
|
+
* This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
export function independentInitializedView<const TSchema extends ImplicitFieldSchema>(
|
|
90
|
+
config: TreeViewConfiguration<TSchema>,
|
|
91
|
+
options: ForestOptions & ICodecOptions,
|
|
92
|
+
content: ViewContent,
|
|
93
|
+
): TreeViewAlpha<TSchema> {
|
|
94
|
+
const idCompressor: IIdCompressor = content.idCompressor;
|
|
95
|
+
const mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();
|
|
96
|
+
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
97
|
+
|
|
98
|
+
const fieldBatchCodec = makeFieldBatchCodec(options, 1);
|
|
99
|
+
const schemaCodec = makeSchemaCodec(options);
|
|
100
|
+
|
|
101
|
+
const schema = new TreeStoredSchemaRepository(schemaCodec.decode(content.schema as Format));
|
|
102
|
+
const forest = buildConfiguredForest(
|
|
103
|
+
options.forest ?? defaultSharedTreeOptions.forest,
|
|
104
|
+
schema,
|
|
105
|
+
idCompressor,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const context: FieldBatchEncodingContext = {
|
|
109
|
+
encodeType: TreeCompressionStrategy.Compressed,
|
|
110
|
+
idCompressor,
|
|
111
|
+
originatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?
|
|
112
|
+
schema: { schema, policy: defaultSchemaPolicy },
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const fieldCursors = fieldBatchCodec.decode(content.tree as JsonCompatibleReadOnly, context);
|
|
116
|
+
assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
|
|
117
|
+
// Checked above.
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
119
|
+
const cursors = fieldCursorToNodesCursors(fieldCursors[0]!);
|
|
120
|
+
|
|
121
|
+
initializeForest(forest, cursors, revisionTagCodec, idCompressor, false);
|
|
122
|
+
|
|
123
|
+
const checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {
|
|
124
|
+
forest,
|
|
125
|
+
schema,
|
|
126
|
+
});
|
|
127
|
+
const out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(
|
|
128
|
+
checkout,
|
|
129
|
+
config,
|
|
130
|
+
createNodeKeyManager(idCompressor),
|
|
131
|
+
);
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function fieldCursorToNodesCursors(
|
|
136
|
+
fieldCursor: ITreeCursorSynchronous,
|
|
137
|
+
): ITreeCursorSynchronous[] {
|
|
138
|
+
return mapCursorField(fieldCursor, copyNodeCursor);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* TODO: avoid needing this, or optimize it.
|
|
143
|
+
*/
|
|
144
|
+
function copyNodeCursor(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous {
|
|
145
|
+
const copy = chunkTree(cursor, {
|
|
146
|
+
policy: defaultChunkPolicy,
|
|
147
|
+
idCompressor: undefined,
|
|
148
|
+
}).cursor();
|
|
149
|
+
copy.enterNode(0);
|
|
150
|
+
return copy;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The portion of SharedTree data typically persisted by the container.
|
|
155
|
+
* Usable with {@link independentInitializedView} to create a {@link TreeView}
|
|
156
|
+
* without loading a container.
|
|
157
|
+
* @alpha
|
|
158
|
+
*/
|
|
159
|
+
export interface ViewContent {
|
|
160
|
+
/**
|
|
161
|
+
* Compressed tree from {@link TreeAlpha.exportCompressed}.
|
|
162
|
+
* @remarks
|
|
163
|
+
* This is an owning reference:
|
|
164
|
+
* consumers of this content might modify this data in place (for example when applying edits) to avoid copying.
|
|
165
|
+
*/
|
|
166
|
+
readonly tree: JsonCompatible<IFluidHandle>;
|
|
167
|
+
/**
|
|
168
|
+
* Persisted schema from {@link extractPersistedSchema}.
|
|
169
|
+
*/
|
|
170
|
+
readonly schema: JsonCompatible;
|
|
171
|
+
/**
|
|
172
|
+
* IIdCompressor which will be used to decompress any compressed identifiers in `tree`
|
|
173
|
+
* as well as for any other identifiers added to the view.
|
|
174
|
+
*/
|
|
175
|
+
readonly idCompressor: IIdCompressor;
|
|
176
|
+
}
|
package/src/shared-tree/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ export {
|
|
|
26
26
|
type CheckoutEvents,
|
|
27
27
|
type ITransaction,
|
|
28
28
|
type ITreeCheckoutFork,
|
|
29
|
-
type
|
|
29
|
+
type BranchableTree,
|
|
30
30
|
type TreeBranchFork,
|
|
31
31
|
} from "./treeCheckout.js";
|
|
32
32
|
|
|
@@ -46,3 +46,11 @@ export {
|
|
|
46
46
|
type RunTransaction,
|
|
47
47
|
rollback,
|
|
48
48
|
} from "./treeApi.js";
|
|
49
|
+
|
|
50
|
+
export { TreeAlpha } from "./treeApiAlpha.js";
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
independentInitializedView,
|
|
54
|
+
type ViewContent,
|
|
55
|
+
independentView,
|
|
56
|
+
} from "./independentView.js";
|
|
@@ -29,8 +29,6 @@ import {
|
|
|
29
29
|
type FieldSchema,
|
|
30
30
|
type ImplicitFieldSchema,
|
|
31
31
|
type SchemaCompatibilityStatus,
|
|
32
|
-
type InsertableTreeFieldFromImplicitField,
|
|
33
|
-
type TreeFieldFromImplicitField,
|
|
34
32
|
type TreeView,
|
|
35
33
|
type TreeViewEvents,
|
|
36
34
|
getTreeNodeForField,
|
|
@@ -43,13 +41,23 @@ import {
|
|
|
43
41
|
prepareContentForHydration,
|
|
44
42
|
comparePersistedSchemaInternal,
|
|
45
43
|
toStoredSchema,
|
|
44
|
+
type TreeViewAlpha,
|
|
45
|
+
type InsertableField,
|
|
46
|
+
type ReadableField,
|
|
47
|
+
type ReadSchema,
|
|
48
|
+
type UnsafeUnknownSchema,
|
|
49
|
+
type TreeBranch,
|
|
46
50
|
} from "../simple-tree/index.js";
|
|
47
51
|
import { Breakable, breakingClass, disposeSymbol, type WithBreakable } from "../util/index.js";
|
|
48
52
|
|
|
49
53
|
import { canInitialize, ensureSchema, initialize } from "./schematizeTree.js";
|
|
50
54
|
import type { ITreeCheckout, TreeCheckout } from "./treeCheckout.js";
|
|
51
55
|
import { CheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
|
|
52
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
HydratedContext,
|
|
58
|
+
SimpleContextSlot,
|
|
59
|
+
areImplicitFieldSchemaEqual,
|
|
60
|
+
} from "../simple-tree/index.js";
|
|
53
61
|
/**
|
|
54
62
|
* Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already
|
|
55
63
|
* exists and error if creating a second.
|
|
@@ -60,8 +68,9 @@ export const ViewSlot = anchorSlot<TreeView<ImplicitFieldSchema>>();
|
|
|
60
68
|
* Implementation of TreeView wrapping a FlexTreeView.
|
|
61
69
|
*/
|
|
62
70
|
@breakingClass
|
|
63
|
-
export class SchematizingSimpleTreeView<
|
|
64
|
-
|
|
71
|
+
export class SchematizingSimpleTreeView<
|
|
72
|
+
in out TRootSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
|
|
73
|
+
> implements TreeBranch, TreeViewAlpha<TRootSchema>, WithBreakable
|
|
65
74
|
{
|
|
66
75
|
/**
|
|
67
76
|
* The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.
|
|
@@ -96,7 +105,7 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
96
105
|
|
|
97
106
|
public constructor(
|
|
98
107
|
public readonly checkout: TreeCheckout,
|
|
99
|
-
public readonly config: TreeViewConfiguration<TRootSchema
|
|
108
|
+
public readonly config: TreeViewConfiguration<ReadSchema<TRootSchema>>,
|
|
100
109
|
public readonly nodeKeyManager: NodeKeyManager,
|
|
101
110
|
public readonly breaker: Breakable = new Breakable("SchematizingSimpleTreeView"),
|
|
102
111
|
private readonly onDispose?: () => void,
|
|
@@ -130,11 +139,17 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
130
139
|
);
|
|
131
140
|
}
|
|
132
141
|
|
|
133
|
-
public
|
|
142
|
+
public hasRootSchema<TSchema extends ImplicitFieldSchema>(
|
|
143
|
+
schema: TSchema,
|
|
144
|
+
): this is TreeViewAlpha<TSchema> {
|
|
145
|
+
return areImplicitFieldSchemaEqual(this.rootFieldSchema, schema);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public get schema(): ReadSchema<TRootSchema> {
|
|
134
149
|
return this.config.schema;
|
|
135
150
|
}
|
|
136
151
|
|
|
137
|
-
public initialize(content:
|
|
152
|
+
public initialize(content: InsertableField<TRootSchema>): void {
|
|
138
153
|
this.ensureUndisposed();
|
|
139
154
|
|
|
140
155
|
const compatibility = this.compatibility;
|
|
@@ -144,7 +159,7 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
144
159
|
|
|
145
160
|
this.runSchemaEdit(() => {
|
|
146
161
|
const mapTree = mapTreeFromNodeData(
|
|
147
|
-
content as InsertableContent,
|
|
162
|
+
content as InsertableContent | undefined,
|
|
148
163
|
this.rootFieldSchema,
|
|
149
164
|
this.nodeKeyManager,
|
|
150
165
|
{
|
|
@@ -338,9 +353,13 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
338
353
|
this.checkout.forest.anchors.slots.delete(ViewSlot);
|
|
339
354
|
this.currentCompatibility = undefined;
|
|
340
355
|
this.onDispose?.();
|
|
356
|
+
if (this.checkout.isBranch && !this.checkout.disposed) {
|
|
357
|
+
// All (non-main) branches are 1:1 with views, so if a user manually disposes a view, we should also dispose the checkout/branch.
|
|
358
|
+
this.checkout.dispose();
|
|
359
|
+
}
|
|
341
360
|
}
|
|
342
361
|
|
|
343
|
-
public get root():
|
|
362
|
+
public get root(): ReadableField<TRootSchema> {
|
|
344
363
|
this.breaker.use();
|
|
345
364
|
if (!this.compatibility.canView) {
|
|
346
365
|
throw new UsageError(
|
|
@@ -348,10 +367,10 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
348
367
|
);
|
|
349
368
|
}
|
|
350
369
|
const view = this.getView();
|
|
351
|
-
return getTreeNodeForField(view.flexTree) as
|
|
370
|
+
return getTreeNodeForField(view.flexTree) as ReadableField<TRootSchema>;
|
|
352
371
|
}
|
|
353
372
|
|
|
354
|
-
public set root(newRoot:
|
|
373
|
+
public set root(newRoot: InsertableField<TRootSchema>) {
|
|
355
374
|
this.breaker.use();
|
|
356
375
|
if (!this.compatibility.canView) {
|
|
357
376
|
throw new UsageError(
|
|
@@ -359,8 +378,40 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
359
378
|
);
|
|
360
379
|
}
|
|
361
380
|
const view = this.getView();
|
|
362
|
-
setField(
|
|
381
|
+
setField(
|
|
382
|
+
view.context.root,
|
|
383
|
+
this.rootFieldSchema,
|
|
384
|
+
newRoot as InsertableContent | undefined,
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// #region Branching
|
|
389
|
+
|
|
390
|
+
public fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TRootSchema> {
|
|
391
|
+
return this.checkout.branch().viewWith(this.config);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
public merge(context: TreeBranch, disposeMerged = true): void {
|
|
395
|
+
this.checkout.merge(getCheckout(context), disposeMerged);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public rebaseOnto(context: TreeBranch): void {
|
|
399
|
+
getCheckout(context).rebase(this.checkout);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// #endregion Branching
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Get the {@link TreeCheckout} associated with a given {@link TreeBranch}.
|
|
407
|
+
* @remarks Currently, all contexts are also {@link SchematizingSimpleTreeView}s.
|
|
408
|
+
* Other checkout implementations (e.g. not associated with a view) may be supported in the future.
|
|
409
|
+
*/
|
|
410
|
+
function getCheckout(context: TreeBranch): TreeCheckout {
|
|
411
|
+
if (context instanceof SchematizingSimpleTreeView) {
|
|
412
|
+
return context.checkout;
|
|
363
413
|
}
|
|
414
|
+
throw new UsageError("Unsupported context implementation");
|
|
364
415
|
}
|
|
365
416
|
|
|
366
417
|
/**
|
|
@@ -53,8 +53,11 @@ import {
|
|
|
53
53
|
import type {
|
|
54
54
|
ITree,
|
|
55
55
|
ImplicitFieldSchema,
|
|
56
|
+
ReadSchema,
|
|
56
57
|
TreeView,
|
|
58
|
+
TreeViewAlpha,
|
|
57
59
|
TreeViewConfiguration,
|
|
60
|
+
UnsafeUnknownSchema,
|
|
58
61
|
} from "../simple-tree/index.js";
|
|
59
62
|
|
|
60
63
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
@@ -65,7 +68,7 @@ import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
|
|
|
65
68
|
import {
|
|
66
69
|
type CheckoutEvents,
|
|
67
70
|
type TreeCheckout,
|
|
68
|
-
type
|
|
71
|
+
type BranchableTree,
|
|
69
72
|
createTreeCheckout,
|
|
70
73
|
} from "./treeCheckout.js";
|
|
71
74
|
import { breakingClass, throwIfBroken } from "../util/index.js";
|
|
@@ -324,10 +327,21 @@ export class SharedTree
|
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
|
|
330
|
+
// For the new TreeViewAlpha API
|
|
331
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
332
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
333
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>>;
|
|
334
|
+
|
|
335
|
+
// For the old TreeView API
|
|
327
336
|
public viewWith<TRoot extends ImplicitFieldSchema>(
|
|
328
337
|
config: TreeViewConfiguration<TRoot>,
|
|
329
|
-
): SchematizingSimpleTreeView<TRoot>
|
|
330
|
-
|
|
338
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<TRoot>;
|
|
339
|
+
|
|
340
|
+
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
341
|
+
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
342
|
+
): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>> {
|
|
343
|
+
return this.checkout.viewWith(config) as SchematizingSimpleTreeView<TRoot> &
|
|
344
|
+
TreeView<ReadSchema<TRoot>>;
|
|
331
345
|
}
|
|
332
346
|
|
|
333
347
|
protected override async loadCore(services: IChannelStorageService): Promise<void> {
|
|
@@ -338,30 +352,36 @@ export class SharedTree
|
|
|
338
352
|
}
|
|
339
353
|
|
|
340
354
|
/**
|
|
341
|
-
* Get a {@link
|
|
355
|
+
* Get a {@link BranchableTree} from a {@link ITree}.
|
|
342
356
|
* @remarks The branch can be used for "version control"-style coordination of edits on the tree.
|
|
343
357
|
* @privateRemarks This function will be removed if/when the branching API becomes public,
|
|
344
358
|
* but it (or something like it) is necessary in the meantime to prevent the alpha types from being exposed as public.
|
|
345
359
|
* @alpha
|
|
360
|
+
* @deprecated This API is superseded by {@link TreeBranch}, which should be used instead.
|
|
346
361
|
*/
|
|
347
|
-
export function getBranch(tree: ITree):
|
|
362
|
+
export function getBranch(tree: ITree): BranchableTree;
|
|
348
363
|
/**
|
|
349
|
-
* Get a {@link
|
|
364
|
+
* Get a {@link BranchableTree} from a {@link TreeView}.
|
|
350
365
|
* @remarks The branch can be used for "version control"-style coordination of edits on the tree.
|
|
351
366
|
* Branches are currently an unstable "alpha" API and are subject to change in the future.
|
|
352
367
|
* @privateRemarks This function will be removed if/when the branching API becomes public,
|
|
353
368
|
* but it (or something like it) is necessary in the meantime to prevent the alpha types from being exposed as public.
|
|
354
369
|
* @alpha
|
|
370
|
+
* @deprecated This API is superseded by {@link TreeBranch}, which should be used instead.
|
|
355
371
|
*/
|
|
356
|
-
export function getBranch
|
|
357
|
-
|
|
372
|
+
export function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
373
|
+
view: TreeViewAlpha<T>,
|
|
374
|
+
): BranchableTree;
|
|
375
|
+
export function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
376
|
+
treeOrView: ITree | TreeViewAlpha<T>,
|
|
377
|
+
): BranchableTree {
|
|
358
378
|
assert(
|
|
359
379
|
treeOrView instanceof SharedTree || treeOrView instanceof SchematizingSimpleTreeView,
|
|
360
380
|
0xa48 /* Unsupported implementation */,
|
|
361
381
|
);
|
|
362
382
|
const checkout: TreeCheckout = treeOrView.checkout;
|
|
363
383
|
// This cast is safe so long as TreeCheckout supports all the operations on the branch interface.
|
|
364
|
-
return checkout as unknown as
|
|
384
|
+
return checkout as unknown as BranchableTree;
|
|
365
385
|
}
|
|
366
386
|
|
|
367
387
|
/**
|