@fluidframework/tree 2.1.0-276985 → 2.1.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/.eslintrc.cjs +7 -0
- package/.vscode/Tree.code-workspace +9 -2
- package/CHANGELOG.md +38 -0
- package/README.md +55 -12
- package/api-report/tree.alpha.api.md +2 -1
- package/api-report/tree.beta.api.md +2 -1
- package/api-report/tree.public.api.md +2 -1
- package/beta.d.ts +1 -1
- package/dist/beta.d.ts +1 -1
- package/dist/core/forest/editableForest.d.ts +6 -3
- package/dist/core/forest/editableForest.d.ts.map +1 -1
- package/dist/core/forest/editableForest.js +16 -4
- package/dist/core/forest/editableForest.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +3 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +2 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +9 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +1 -0
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +13 -0
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +48 -11
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +144 -20
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.js +13 -4
- package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormat.d.ts +1 -1
- package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormat.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.d.ts +39 -4
- package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/dist/core/tree/index.d.ts +2 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts +3 -1
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js +31 -15
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/core/tree/visitorUtils.d.ts +3 -3
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +4 -4
- package/dist/core/tree/visitorUtils.js.map +1 -1
- package/dist/events/events.d.ts +4 -1
- package/dist/events/events.d.ts.map +1 -1
- package/dist/events/events.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/editableTreeBinder.js +1 -1
- package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +1 -10
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +0 -72
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -51
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +3 -2
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +5 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +1 -2
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -6
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -32
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +1 -5
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +0 -30
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +6 -3
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/discrepancies.js +264 -0
- package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -0
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +2 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +3 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +827 -245
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/node-key/index.d.ts +0 -1
- package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
- package/dist/feature-libraries/node-key/index.js +1 -3
- package/dist/feature-libraries/node-key/index.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts +3 -2
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +5 -4
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +1 -0
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/sequence-field/index.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/index.js +1 -2
- package/dist/feature-libraries/sequence-field/index.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +1 -1
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +6 -1
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts +2 -17
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +31 -39
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
- package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js +2 -0
- package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +4 -2
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +240 -184
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +5 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +157 -90
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/treeApi.js +1 -1
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +10 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +47 -3
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/treeView.d.ts.map +1 -1
- package/dist/shared-tree/treeView.js +7 -3
- package/dist/shared-tree/treeView.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +6 -0
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +3 -0
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -6
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +271 -209
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +4 -0
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +36 -19
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +22 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +2 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +2 -1
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/proxies.d.ts.map +1 -1
- package/dist/simple-tree/proxies.js +9 -25
- package/dist/simple-tree/proxies.js.map +1 -1
- package/dist/simple-tree/proxyBinding.d.ts +4 -0
- package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
- package/dist/simple-tree/proxyBinding.js +23 -1
- package/dist/simple-tree/proxyBinding.js.map +1 -1
- package/dist/simple-tree/schemaFactory.d.ts +16 -1
- package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/schemaFactory.js +32 -4
- package/dist/simple-tree/schemaFactory.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +36 -1
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toFlexSchema.d.ts +2 -2
- package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/dist/simple-tree/toFlexSchema.js +3 -2
- package/dist/simple-tree/toFlexSchema.js.map +1 -1
- package/dist/simple-tree/tree.d.ts +4 -1
- package/dist/simple-tree/tree.d.ts.map +1 -1
- package/dist/simple-tree/tree.js +48 -1
- package/dist/simple-tree/tree.js.map +1 -1
- package/dist/simple-tree/treeNodeApi.d.ts +2 -75
- package/dist/simple-tree/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/treeNodeApi.js +17 -25
- package/dist/simple-tree/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/treeNodeKernel.d.ts +26 -0
- package/dist/simple-tree/treeNodeKernel.d.ts.map +1 -0
- package/dist/simple-tree/treeNodeKernel.js +83 -0
- package/dist/simple-tree/treeNodeKernel.js.map +1 -0
- package/dist/simple-tree/types.d.ts +95 -3
- package/dist/simple-tree/types.d.ts.map +1 -1
- package/dist/simple-tree/types.js +120 -21
- package/dist/simple-tree/types.js.map +1 -1
- package/dist/util/breakable.d.ts +83 -0
- package/dist/util/breakable.d.ts.map +1 -0
- package/dist/util/breakable.js +178 -0
- package/dist/util/breakable.js.map +1 -0
- package/dist/util/index.d.ts +3 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +9 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts +17 -3
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +21 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/utils.d.ts +7 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +15 -1
- package/dist/util/utils.js.map +1 -1
- package/internal.d.ts +1 -1
- package/lib/beta.d.ts +1 -1
- package/lib/core/forest/editableForest.d.ts +6 -3
- package/lib/core/forest/editableForest.d.ts.map +1 -1
- package/lib/core/forest/editableForest.js +17 -5
- package/lib/core/forest/editableForest.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +2 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +7 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +1 -0
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +13 -0
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +48 -11
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +145 -21
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.js +13 -4
- package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormat.d.ts +1 -1
- package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormat.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.d.ts +39 -4
- package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/lib/core/tree/index.d.ts +2 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts +3 -1
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js +31 -15
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/core/tree/visitorUtils.d.ts +3 -3
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +4 -4
- package/lib/core/tree/visitorUtils.js.map +1 -1
- package/lib/events/events.d.ts +4 -1
- package/lib/events/events.d.ts.map +1 -1
- package/lib/events/events.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/editableTreeBinder.js +1 -1
- package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +1 -10
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +2 -74
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -51
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +3 -2
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +2 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +1 -2
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -6
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +13 -34
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +1 -5
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -33
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +3 -3
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/discrepancies.js +260 -0
- package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -0
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +2 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -0
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +826 -247
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/node-key/index.d.ts +0 -1
- package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
- package/lib/feature-libraries/node-key/index.js +0 -1
- package/lib/feature-libraries/node-key/index.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts +3 -2
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +5 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +1 -0
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/sequence-field/index.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/index.js +1 -1
- package/lib/feature-libraries/sequence-field/index.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +1 -1
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +6 -1
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts +2 -17
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +31 -39
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
- package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js +4 -2
- package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -2
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +242 -185
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +5 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +158 -90
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/treeApi.js +1 -1
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +10 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +47 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/treeView.d.ts.map +1 -1
- package/lib/shared-tree/treeView.js +4 -0
- package/lib/shared-tree/treeView.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +6 -0
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +3 -0
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -6
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +273 -210
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +4 -0
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +39 -22
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +22 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +1 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +3 -2
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/proxies.d.ts.map +1 -1
- package/lib/simple-tree/proxies.js +9 -25
- package/lib/simple-tree/proxies.js.map +1 -1
- package/lib/simple-tree/proxyBinding.d.ts +4 -0
- package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
- package/lib/simple-tree/proxyBinding.js +19 -0
- package/lib/simple-tree/proxyBinding.js.map +1 -1
- package/lib/simple-tree/schemaFactory.d.ts +16 -1
- package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/schemaFactory.js +30 -3
- package/lib/simple-tree/schemaFactory.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +36 -1
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toFlexSchema.d.ts +2 -2
- package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
- package/lib/simple-tree/toFlexSchema.js +3 -2
- package/lib/simple-tree/toFlexSchema.js.map +1 -1
- package/lib/simple-tree/tree.d.ts +4 -1
- package/lib/simple-tree/tree.d.ts.map +1 -1
- package/lib/simple-tree/tree.js +44 -0
- package/lib/simple-tree/tree.js.map +1 -1
- package/lib/simple-tree/treeNodeApi.d.ts +2 -75
- package/lib/simple-tree/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/treeNodeApi.js +20 -28
- package/lib/simple-tree/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/treeNodeKernel.d.ts +26 -0
- package/lib/simple-tree/treeNodeKernel.d.ts.map +1 -0
- package/lib/simple-tree/treeNodeKernel.js +79 -0
- package/lib/simple-tree/treeNodeKernel.js.map +1 -0
- package/lib/simple-tree/types.d.ts +95 -3
- package/lib/simple-tree/types.d.ts.map +1 -1
- package/lib/simple-tree/types.js +121 -22
- package/lib/simple-tree/types.js.map +1 -1
- package/lib/util/breakable.d.ts +83 -0
- package/lib/util/breakable.d.ts.map +1 -0
- package/lib/util/breakable.js +171 -0
- package/lib/util/breakable.js.map +1 -0
- package/lib/util/index.d.ts +3 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +3 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/nestedMap.d.ts +17 -3
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +19 -0
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/utils.d.ts +7 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +13 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +29 -27
- package/src/core/forest/editableForest.ts +25 -4
- package/src/core/index.ts +2 -0
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +17 -0
- package/src/core/tree/anchorSet.ts +14 -0
- package/src/core/tree/detachedFieldIndex.ts +217 -35
- package/src/core/tree/detachedFieldIndexCodec.ts +17 -8
- package/src/core/tree/detachedFieldIndexFormat.ts +1 -1
- package/src/core/tree/detachedFieldIndexTypes.ts +41 -5
- package/src/core/tree/index.ts +2 -1
- package/src/core/tree/visitDelta.ts +58 -16
- package/src/core/tree/visitorUtils.ts +7 -4
- package/src/events/events.ts +4 -2
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +1 -1
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
- package/src/feature-libraries/editableTreeBinder.ts +1 -1
- package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +1 -95
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -62
- package/src/feature-libraries/flex-tree/index.ts +7 -2
- package/src/feature-libraries/flex-tree/lazyEntity.ts +0 -3
- package/src/feature-libraries/flex-tree/lazyField.ts +15 -47
- package/src/feature-libraries/flex-tree/lazyNode.ts +1 -48
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -0
- package/src/feature-libraries/index.ts +4 -2
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +18 -0
- package/src/feature-libraries/modular-schema/discrepancies.ts +395 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -2
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -0
- package/src/feature-libraries/modular-schema/index.ts +2 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +81 -35
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1521 -444
- package/src/feature-libraries/modular-schema/modularChangeFormat.ts +2 -0
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +51 -0
- package/src/feature-libraries/node-key/index.ts +0 -1
- package/src/feature-libraries/object-forest/objectForest.ts +7 -3
- package/src/feature-libraries/optional-field/optionalField.ts +1 -0
- package/src/feature-libraries/sequence-field/index.ts +0 -2
- package/src/feature-libraries/sequence-field/invert.ts +1 -1
- package/src/feature-libraries/sequence-field/rebase.ts +7 -1
- package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +2 -1
- package/src/feature-libraries/sequence-field/utils.ts +37 -85
- package/src/feature-libraries/typed-schema/typedTreeSchema.ts +10 -0
- package/src/index.ts +0 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +6 -2
- package/src/shared-tree/sharedTree.ts +12 -1
- package/src/shared-tree/sharedTreeChangeEnricher.ts +1 -1
- package/src/shared-tree/treeApi.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +60 -5
- package/src/shared-tree/treeView.ts +5 -0
- package/src/shared-tree-core/branch.ts +10 -0
- package/src/shared-tree-core/sharedTreeCore.ts +25 -6
- package/src/simple-tree/arrayNode.ts +50 -23
- package/src/simple-tree/index.ts +3 -3
- package/src/simple-tree/leafNodeSchema.ts +1 -1
- package/src/simple-tree/mapNode.ts +2 -2
- package/src/simple-tree/objectNode.ts +9 -3
- package/src/simple-tree/proxies.ts +10 -33
- package/src/simple-tree/proxyBinding.ts +23 -0
- package/src/simple-tree/schemaFactory.ts +37 -2
- package/src/simple-tree/schemaTypes.ts +36 -1
- package/src/simple-tree/toFlexSchema.ts +5 -4
- package/src/simple-tree/tree.ts +68 -4
- package/src/simple-tree/treeNodeApi.ts +29 -111
- package/src/simple-tree/treeNodeKernel.ts +91 -0
- package/src/simple-tree/types.ts +292 -31
- package/src/util/breakable.ts +214 -0
- package/src/util/index.ts +11 -0
- package/src/util/nestedMap.ts +33 -3
- package/src/util/utils.ts +17 -0
- package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
- package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
- package/dist/feature-libraries/node-key/nodeKeyIndex.js +0 -101
- package/dist/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
- package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
- package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
- package/lib/feature-libraries/node-key/nodeKeyIndex.js +0 -97
- package/lib/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
- package/src/feature-libraries/node-key/nodeKeyIndex.ts +0 -132
|
@@ -2,219 +2,276 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
6
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
7
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
8
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
9
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
10
|
+
var _, done = false;
|
|
11
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
12
|
+
var context = {};
|
|
13
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
14
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
15
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
16
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
17
|
+
if (kind === "accessor") {
|
|
18
|
+
if (result === void 0) continue;
|
|
19
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
20
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
21
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
22
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
23
|
+
}
|
|
24
|
+
else if (_ = accept(result)) {
|
|
25
|
+
if (kind === "field") initializers.unshift(_);
|
|
26
|
+
else descriptor[key] = _;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
30
|
+
done = true;
|
|
31
|
+
};
|
|
32
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
33
|
+
var useValue = arguments.length > 2;
|
|
34
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
35
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
36
|
+
}
|
|
37
|
+
return useValue ? value : void 0;
|
|
38
|
+
};
|
|
39
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
40
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
41
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
42
|
+
};
|
|
5
43
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
44
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
45
|
import { AllowedUpdateType, Compatibility } from "../core/index.js";
|
|
8
46
|
import { createEmitter, } from "../events/index.js";
|
|
9
47
|
import { ViewSchema, defaultSchemaPolicy, ContextSlot, cursorForMapTreeNode, } from "../feature-libraries/index.js";
|
|
10
48
|
import { getProxyForField, toFlexSchema, setField, normalizeFieldSchema, mapTreeFromNodeData, prepareContentForHydration, } from "../simple-tree/index.js";
|
|
11
|
-
import { disposeSymbol } from "../util/index.js";
|
|
49
|
+
import { Breakable, breakingClass, disposeSymbol } from "../util/index.js";
|
|
12
50
|
import { canInitialize, ensureSchema, initialize } from "./schematizeTree.js";
|
|
13
51
|
import { CheckoutFlexTreeView } from "./treeView.js";
|
|
14
52
|
/**
|
|
15
53
|
* Implementation of TreeView wrapping a FlexTreeView.
|
|
16
54
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
let SchematizingSimpleTreeView = (() => {
|
|
56
|
+
let _classDecorators = [breakingClass];
|
|
57
|
+
let _classDescriptor;
|
|
58
|
+
let _classExtraInitializers = [];
|
|
59
|
+
let _classThis;
|
|
60
|
+
var SchematizingSimpleTreeView = _classThis = class {
|
|
61
|
+
constructor(checkout, config, nodeKeyManager, breaker = new Breakable("SchematizingSimpleTreeView")) {
|
|
62
|
+
this.checkout = checkout;
|
|
63
|
+
this.config = config;
|
|
64
|
+
this.nodeKeyManager = nodeKeyManager;
|
|
65
|
+
this.breaker = breaker;
|
|
66
|
+
this.events = createEmitter();
|
|
67
|
+
this.unregisterCallbacks = new Set();
|
|
68
|
+
this.disposed = false;
|
|
69
|
+
/**
|
|
70
|
+
* This is set to true while an edit impacting the document schema is in progress.
|
|
71
|
+
* This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.
|
|
72
|
+
* This is useful especially for some initialization edits, since document initialization can involve transient schemas
|
|
73
|
+
* which are implementation details and should not be exposed to the user.
|
|
74
|
+
*/
|
|
75
|
+
this.midUpgrade = false;
|
|
76
|
+
const policy = {
|
|
77
|
+
...defaultSchemaPolicy,
|
|
78
|
+
validateSchema: config.enableSchemaValidation,
|
|
79
|
+
};
|
|
80
|
+
this.rootFieldSchema = normalizeFieldSchema(config.schema);
|
|
81
|
+
this.flexSchema = toFlexSchema(config.schema);
|
|
82
|
+
this.viewSchema = new ViewSchema(policy, {}, this.flexSchema);
|
|
83
|
+
// This must be initialized before `update` can be called.
|
|
84
|
+
this.currentCompatibility = {
|
|
85
|
+
canView: false,
|
|
86
|
+
canUpgrade: true,
|
|
87
|
+
isEquivalent: false,
|
|
88
|
+
canInitialize: true,
|
|
89
|
+
};
|
|
90
|
+
this.update();
|
|
91
|
+
this.unregisterCallbacks.add(this.checkout.events.on("commitApplied", (data, getRevertible) => this.events.emit("commitApplied", data, getRevertible)));
|
|
54
92
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
93
|
+
initialize(content) {
|
|
94
|
+
this.ensureUndisposed();
|
|
95
|
+
const compatibility = this.compatibility;
|
|
96
|
+
if (!compatibility.canInitialize) {
|
|
97
|
+
throw new UsageError("Tree cannot be initialized more than once.");
|
|
98
|
+
}
|
|
99
|
+
this.runSchemaEdit(() => {
|
|
100
|
+
const mapTree = mapTreeFromNodeData(content, this.rootFieldSchema.allowedTypes, this.nodeKeyManager, {
|
|
101
|
+
schema: this.checkout.storedSchema,
|
|
102
|
+
policy: {
|
|
103
|
+
...defaultSchemaPolicy,
|
|
104
|
+
validateSchema: this.config.enableSchemaValidation,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
prepareContentForHydration(mapTree, this.checkout.forest);
|
|
108
|
+
initialize(this.checkout, {
|
|
109
|
+
schema: this.flexSchema,
|
|
110
|
+
initialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),
|
|
111
|
+
});
|
|
62
112
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
113
|
+
}
|
|
114
|
+
upgradeSchema() {
|
|
115
|
+
this.ensureUndisposed();
|
|
116
|
+
const compatibility = this.compatibility;
|
|
117
|
+
if (compatibility.isEquivalent) {
|
|
118
|
+
// No-op
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!compatibility.canUpgrade) {
|
|
122
|
+
throw new UsageError("Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).");
|
|
123
|
+
}
|
|
124
|
+
this.runSchemaEdit(() => {
|
|
125
|
+
const result = ensureSchema(this.viewSchema, AllowedUpdateType.SchemaCompatible, this.checkout, {
|
|
126
|
+
schema: this.flexSchema,
|
|
127
|
+
initialTree: undefined,
|
|
128
|
+
});
|
|
129
|
+
assert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);
|
|
67
130
|
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
upgradeSchema() {
|
|
71
|
-
this.ensureUndisposed();
|
|
72
|
-
const compatibility = this.compatibility;
|
|
73
|
-
if (compatibility.isEquivalent) {
|
|
74
|
-
// No-op
|
|
75
|
-
return;
|
|
76
131
|
}
|
|
77
|
-
|
|
78
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Gets the view. Throws when disposed.
|
|
134
|
+
*/
|
|
135
|
+
getView() {
|
|
136
|
+
this.ensureUndisposed();
|
|
137
|
+
assert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);
|
|
138
|
+
return this.view;
|
|
79
139
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
assert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Gets the view. Throws when disposed.
|
|
90
|
-
*/
|
|
91
|
-
getView() {
|
|
92
|
-
this.ensureUndisposed();
|
|
93
|
-
assert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);
|
|
94
|
-
return this.view;
|
|
95
|
-
}
|
|
96
|
-
ensureUndisposed() {
|
|
97
|
-
if (this.disposed) {
|
|
98
|
-
this.failDisposed();
|
|
140
|
+
ensureUndisposed() {
|
|
141
|
+
if (this.disposed) {
|
|
142
|
+
this.failDisposed();
|
|
143
|
+
}
|
|
99
144
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
failDisposed() {
|
|
146
|
+
throw new UsageError("Accessed a disposed TreeView.");
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Updates `this.view` and the current compatibility status.
|
|
150
|
+
* Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.
|
|
151
|
+
* Handles re-registering for events to call update in the future.
|
|
152
|
+
* @remarks
|
|
153
|
+
* This does not check if the view needs to be replaced, it replaces it unconditionally:
|
|
154
|
+
* callers should do any checking to detect if it's really needed before calling `update`.
|
|
155
|
+
* @privateRemarks
|
|
156
|
+
* This implementation avoids making any edits, which prevents it from being invoked reentrantly.
|
|
157
|
+
* If implicit initialization (or some other edit) is desired, it should be done outside of this method.
|
|
158
|
+
*/
|
|
159
|
+
update() {
|
|
160
|
+
this.disposeView();
|
|
161
|
+
const result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);
|
|
162
|
+
// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.
|
|
163
|
+
// In the near term, this should support viewing documents with additional optional fields in their schema on object types.
|
|
164
|
+
// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility
|
|
165
|
+
// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)
|
|
166
|
+
const canView = result.write === Compatibility.Compatible && result.read === Compatibility.Compatible;
|
|
167
|
+
const canUpgrade = result.read === Compatibility.Compatible;
|
|
168
|
+
const isEquivalent = canView && canUpgrade;
|
|
169
|
+
const compatibility = {
|
|
170
|
+
canView,
|
|
171
|
+
canUpgrade,
|
|
172
|
+
isEquivalent,
|
|
173
|
+
canInitialize: canInitialize(this.checkout),
|
|
174
|
+
};
|
|
175
|
+
let lastRoot = this.compatibility.canView && this.view !== undefined ? this.root : undefined;
|
|
176
|
+
this.currentCompatibility = compatibility;
|
|
177
|
+
if (compatibility.canView) {
|
|
178
|
+
// Trigger "rootChanged" if the root changes in the future.
|
|
179
|
+
// Currently there is no good way to do this as FlexTreeField has no events for changes.
|
|
180
|
+
// this.view.flexTree.on(????)
|
|
181
|
+
// As a workaround for the above, trigger "rootChanged" in "afterBatch"
|
|
182
|
+
// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.
|
|
183
|
+
// TODO: provide a better event: this.view.flexTree.on(????)
|
|
184
|
+
const cleanupCheckOutEvents = this.checkout.events.on("afterBatch", () => {
|
|
185
|
+
// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.
|
|
186
|
+
// Accessing `this.root` in that case can throw. It's OK to ignore this because:
|
|
187
|
+
// - The rootChanged event will already be raised at the end of the current upgrade
|
|
188
|
+
// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade
|
|
189
|
+
// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)
|
|
190
|
+
if (!this.midUpgrade && lastRoot !== this.root) {
|
|
191
|
+
lastRoot = this.root;
|
|
192
|
+
this.events.emit("rootChanged");
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const onViewDispose = () => {
|
|
196
|
+
cleanupCheckOutEvents();
|
|
197
|
+
this.view = undefined;
|
|
198
|
+
if (!this.disposed) {
|
|
199
|
+
this.update();
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
this.view = requireSchema(this.checkout, this.viewSchema, onViewDispose, this.nodeKeyManager);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
153
205
|
this.view = undefined;
|
|
154
|
-
|
|
206
|
+
const unregister = this.checkout.storedSchema.on("afterSchemaChange", () => {
|
|
207
|
+
unregister();
|
|
208
|
+
this.unregisterCallbacks.delete(unregister);
|
|
155
209
|
this.update();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
unregister();
|
|
164
|
-
this.unregisterCallbacks.delete(unregister);
|
|
165
|
-
this.update();
|
|
166
|
-
});
|
|
167
|
-
this.unregisterCallbacks.add(unregister);
|
|
210
|
+
});
|
|
211
|
+
this.unregisterCallbacks.add(unregister);
|
|
212
|
+
}
|
|
213
|
+
if (!this.midUpgrade) {
|
|
214
|
+
this.events.emit("schemaChanged");
|
|
215
|
+
this.events.emit("rootChanged");
|
|
216
|
+
}
|
|
168
217
|
}
|
|
169
|
-
|
|
218
|
+
runSchemaEdit(edit) {
|
|
219
|
+
this.midUpgrade = true;
|
|
220
|
+
try {
|
|
221
|
+
edit();
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
this.midUpgrade = false;
|
|
225
|
+
}
|
|
170
226
|
this.events.emit("schemaChanged");
|
|
171
227
|
this.events.emit("rootChanged");
|
|
172
228
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
finally {
|
|
180
|
-
this.midUpgrade = false;
|
|
229
|
+
disposeView() {
|
|
230
|
+
if (this.view !== undefined) {
|
|
231
|
+
this.view[disposeSymbol]();
|
|
232
|
+
this.view = undefined;
|
|
233
|
+
this.unregisterCallbacks.forEach((unregister) => unregister());
|
|
234
|
+
}
|
|
181
235
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.view[disposeSymbol]();
|
|
188
|
-
this.view = undefined;
|
|
189
|
-
this.unregisterCallbacks.forEach((unregister) => unregister());
|
|
236
|
+
get compatibility() {
|
|
237
|
+
if (!this.currentCompatibility) {
|
|
238
|
+
this.failDisposed();
|
|
239
|
+
}
|
|
240
|
+
return this.currentCompatibility;
|
|
190
241
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.
|
|
242
|
+
dispose() {
|
|
243
|
+
this.disposed = true;
|
|
244
|
+
this.disposeView();
|
|
245
|
+
this.currentCompatibility = undefined;
|
|
195
246
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
get root() {
|
|
204
|
-
if (!this.compatibility.canView) {
|
|
205
|
-
throw new UsageError("Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.");
|
|
247
|
+
get root() {
|
|
248
|
+
this.breaker.use();
|
|
249
|
+
if (!this.compatibility.canView) {
|
|
250
|
+
throw new UsageError("Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.");
|
|
251
|
+
}
|
|
252
|
+
const view = this.getView();
|
|
253
|
+
return getProxyForField(view.flexTree);
|
|
206
254
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
255
|
+
set root(newRoot) {
|
|
256
|
+
this.breaker.use();
|
|
257
|
+
if (!this.compatibility.canView) {
|
|
258
|
+
throw new UsageError("Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.");
|
|
259
|
+
}
|
|
260
|
+
const view = this.getView();
|
|
261
|
+
setField(view.context.root, this.rootFieldSchema, newRoot);
|
|
213
262
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
263
|
+
};
|
|
264
|
+
__setFunctionName(_classThis, "SchematizingSimpleTreeView");
|
|
265
|
+
(() => {
|
|
266
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
267
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
268
|
+
SchematizingSimpleTreeView = _classThis = _classDescriptor.value;
|
|
269
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
270
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
271
|
+
})();
|
|
272
|
+
return SchematizingSimpleTreeView = _classThis;
|
|
273
|
+
})();
|
|
274
|
+
export { SchematizingSimpleTreeView };
|
|
218
275
|
/**
|
|
219
276
|
* Creates a view that self-disposes whenenever the stored schema changes.
|
|
220
277
|
* This may only be called when the schema is already known to be compatible (typically via ensureSchema).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAIN,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGN,UAAU,EACV,mBAAmB,EACnB,WAAW,EACX,oBAAoB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAQN,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,oBAAoB,EAGpB,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAkCtC,YACiB,QAAsB,EACtB,MAA0C,EAC1C,cAA8B;QAF9B,aAAQ,GAAR,QAAQ,CAAc;QACtB,WAAM,GAAN,MAAM,CAAoC;QAC1C,mBAAc,GAAd,cAAc,CAAgB;QAtB/B,WAAM,GAEU,aAAa,EAAE,CAAC;QAI/B,wBAAmB,GAAG,IAAI,GAAG,EAAc,CAAC;QAEtD,aAAQ,GAAG,KAAK,CAAC;QACxB;;;;;WAKG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sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { AllowedUpdateType, Compatibility } from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FlexFieldSchema,\n\ttype NodeKeyManager,\n\tViewSchema,\n\tdefaultSchemaPolicy,\n\tContextSlot,\n\tcursorForMapTreeNode,\n\ttype FlexTreeSchema,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatus,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tgetProxyForField,\n\ttoFlexSchema,\n\tsetField,\n\tnormalizeFieldSchema,\n\ttype InsertableContent,\n\ttype TreeViewConfiguration,\n\tmapTreeFromNodeData,\n\tprepareContentForHydration,\n} from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport { canInitialize, ensureSchema, initialize } from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\nimport { CheckoutFlexTreeView } from \"./treeView.js\";\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\nexport class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema>\n\timplements TreeView<TRootSchema>\n{\n\t/**\n\t * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate view: CheckoutFlexTreeView<FlexFieldSchema> | undefined;\n\n\t/**\n\t * Undefined iff uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatus | undefined;\n\tprivate readonly flexSchema: FlexTreeSchema;\n\tpublic readonly events: Listenable<TreeViewEvents> &\n\t\tIEmitter<TreeViewEvents> &\n\t\tHasListeners<TreeViewEvents> = createEmitter();\n\n\tprivate readonly viewSchema: ViewSchema;\n\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: TreeViewConfiguration<TRootSchema>,\n\t\tpublic readonly nodeKeyManager: NodeKeyManager,\n\t) {\n\t\tconst policy = {\n\t\t\t...defaultSchemaPolicy,\n\t\t\tvalidateSchema: config.enableSchemaValidation,\n\t\t};\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\t\tthis.flexSchema = toFlexSchema(config.schema);\n\n\t\tthis.viewSchema = new ViewSchema(policy, {}, this.flexSchema);\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t};\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"commitApplied\", (data, getRevertible) =>\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic initialize(content: InsertableTreeFieldFromImplicitField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst mapTree = mapTreeFromNodeData(\n\t\t\t\tcontent as InsertableContent,\n\t\t\t\tthis.rootFieldSchema.allowedTypes,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t\t{\n\t\t\t\t\tschema: this.checkout.storedSchema,\n\t\t\t\t\tpolicy: {\n\t\t\t\t\t\t...defaultSchemaPolicy,\n\t\t\t\t\t\tvalidateSchema: this.config.enableSchemaValidation,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tprepareContentForHydration(mapTree, this.checkout.forest);\n\t\t\tinitialize(this.checkout, {\n\t\t\t\tschema: this.flexSchema,\n\t\t\t\tinitialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (compatibility.isEquivalent) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tif (!compatibility.canUpgrade) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst result = ensureSchema(\n\t\t\t\tthis.viewSchema,\n\t\t\t\tAllowedUpdateType.SchemaCompatible,\n\t\t\t\tthis.checkout,\n\t\t\t\t{\n\t\t\t\t\tschema: this.flexSchema,\n\t\t\t\t\tinitialTree: undefined,\n\t\t\t\t},\n\t\t\t);\n\t\t\tassert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);\n\t\t});\n\t}\n\n\t/**\n\t * Gets the view. Throws when disposed.\n\t */\n\tpublic getView(): CheckoutFlexTreeView<FlexFieldSchema> {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.view;\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeView();\n\n\t\tconst result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);\n\n\t\t// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.\n\t\t// In the near term, this should support viewing documents with additional optional fields in their schema on object types.\n\t\t// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility\n\t\t// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)\n\t\tconst canView =\n\t\t\tresult.write === Compatibility.Compatible && result.read === Compatibility.Compatible;\n\t\tconst canUpgrade = result.read === Compatibility.Compatible;\n\t\tconst isEquivalent = canView && canUpgrade;\n\t\tconst compatibility: SchemaCompatibilityStatus = {\n\t\t\tcanView,\n\t\t\tcanUpgrade,\n\t\t\tisEquivalent,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t\tlet lastRoot =\n\t\t\tthis.compatibility.canView && this.view !== undefined ? this.root : undefined;\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tif (compatibility.canView) {\n\t\t\t// Trigger \"rootChanged\" if the root changes in the future.\n\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t// this.view.flexTree.on(????)\n\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\"\n\t\t\t// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.\n\t\t\t// TODO: provide a better event: this.view.flexTree.on(????)\n\t\t\tconst cleanupCheckOutEvents = this.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\tif (!this.midUpgrade && lastRoot !== this.root) {\n\t\t\t\t\tlastRoot = this.root;\n\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst onViewDispose = (): void => {\n\t\t\t\tcleanupCheckOutEvents();\n\t\t\t\tthis.view = undefined;\n\t\t\t\tif (!this.disposed) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.view = requireSchema(\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.viewSchema,\n\t\t\t\tonViewDispose,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.view = undefined;\n\n\t\t\tconst unregister = this.checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\t\t\tunregister();\n\t\t\t\tthis.unregisterCallbacks.delete(unregister);\n\t\t\t\tthis.update();\n\t\t\t});\n\t\t\tthis.unregisterCallbacks.add(unregister);\n\t\t}\n\n\t\tif (!this.midUpgrade) {\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeView(): void {\n\t\tif (this.view !== undefined) {\n\t\t\tthis.view[disposeSymbol]();\n\t\t\tthis.view = undefined;\n\t\t\tthis.unregisterCallbacks.forEach((unregister) => unregister());\n\t\t}\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatus {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeView();\n\t\tthis.currentCompatibility = undefined;\n\t}\n\n\tpublic get root(): TreeFieldFromImplicitField<TRootSchema> {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\treturn getProxyForField(view.flexTree) as TreeFieldFromImplicitField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableTreeFieldFromImplicitField<TRootSchema>) {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\tsetField(view.context.root, this.rootFieldSchema, newRoot as InsertableContent);\n\t}\n}\n\n/**\n * Creates a view that self-disposes whenenever the stored schema changes.\n * This may only be called when the schema is already known to be compatible (typically via ensureSchema).\n */\nexport function requireSchema<TRoot extends FlexFieldSchema>(\n\tcheckout: TreeCheckout,\n\tviewSchema: ViewSchema<TRoot>,\n\tonDispose: () => void,\n\tnodeKeyManager: NodeKeyManager,\n): CheckoutFlexTreeView<TRoot> {\n\tconst slots = checkout.forest.anchors.slots;\n\tassert(!slots.has(ContextSlot), 0x8c2 /* Cannot create second view from checkout */);\n\n\t{\n\t\tconst compatibility = viewSchema.checkCompatibility(checkout.storedSchema);\n\t\tassert(\n\t\t\tcompatibility.write === Compatibility.Compatible &&\n\t\t\t\tcompatibility.read === Compatibility.Compatible,\n\t\t\t0x8c3 /* requireSchema invoked with incompatible schema */,\n\t\t);\n\t}\n\n\tconst view = new CheckoutFlexTreeView(\n\t\tcheckout,\n\t\tviewSchema.schema,\n\t\tnodeKeyManager,\n\t\tonDispose,\n\t);\n\tassert(slots.has(ContextSlot), 0x90d /* Context should be tracked in slot */);\n\n\tconst unregister = checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\tunregister();\n\t\tview[disposeSymbol]();\n\t});\n\n\treturn view;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAIN,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGN,UAAU,EACV,mBAAmB,EACnB,WAAW,EACX,oBAAoB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAQN,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,oBAAoB,EAGpB,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAsB,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD;;GAEG;IAEU,0BAA0B;4BADtC,aAAa;;;;;QAmCb,YACiB,QAAsB,EACtB,MAA0C,EAC1C,cAA8B,EAC9B,UAAqB,IAAI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AAa,CAAC,IAAI,KAAK,aAAa,CAAC,UAAU,EAChD,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,oBAAoB,CACpC,QAAQ,EACR,UAAU,CAAC,MAAM,EACjB,cAAc,EACd,SAAS,CACT,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAE9E,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACrE,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { AllowedUpdateType, Compatibility } from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FlexFieldSchema,\n\ttype NodeKeyManager,\n\tViewSchema,\n\tdefaultSchemaPolicy,\n\tContextSlot,\n\tcursorForMapTreeNode,\n\ttype FlexTreeSchema,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatus,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tgetProxyForField,\n\ttoFlexSchema,\n\tsetField,\n\tnormalizeFieldSchema,\n\ttype InsertableContent,\n\ttype TreeViewConfiguration,\n\tmapTreeFromNodeData,\n\tprepareContentForHydration,\n} from \"../simple-tree/index.js\";\nimport { Breakable, breakingClass, disposeSymbol, type WithBreakable } from \"../util/index.js\";\n\nimport { canInitialize, ensureSchema, initialize } from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\nimport { CheckoutFlexTreeView } from \"./treeView.js\";\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\n@breakingClass\nexport class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema>\n\timplements TreeView<TRootSchema>, WithBreakable\n{\n\t/**\n\t * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate view: CheckoutFlexTreeView<FlexFieldSchema> | undefined;\n\n\t/**\n\t * Undefined iff uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatus | undefined;\n\tprivate readonly flexSchema: FlexTreeSchema;\n\tpublic readonly events: Listenable<TreeViewEvents> &\n\t\tIEmitter<TreeViewEvents> &\n\t\tHasListeners<TreeViewEvents> = createEmitter();\n\n\tprivate readonly viewSchema: ViewSchema;\n\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: TreeViewConfiguration<TRootSchema>,\n\t\tpublic readonly nodeKeyManager: NodeKeyManager,\n\t\tpublic readonly breaker: Breakable = new Breakable(\"SchematizingSimpleTreeView\"),\n\t) {\n\t\tconst policy = {\n\t\t\t...defaultSchemaPolicy,\n\t\t\tvalidateSchema: config.enableSchemaValidation,\n\t\t};\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\t\tthis.flexSchema = toFlexSchema(config.schema);\n\n\t\tthis.viewSchema = new ViewSchema(policy, {}, this.flexSchema);\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t};\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"commitApplied\", (data, getRevertible) =>\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic initialize(content: InsertableTreeFieldFromImplicitField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst mapTree = mapTreeFromNodeData(\n\t\t\t\tcontent as InsertableContent,\n\t\t\t\tthis.rootFieldSchema.allowedTypes,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t\t{\n\t\t\t\t\tschema: this.checkout.storedSchema,\n\t\t\t\t\tpolicy: {\n\t\t\t\t\t\t...defaultSchemaPolicy,\n\t\t\t\t\t\tvalidateSchema: this.config.enableSchemaValidation,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tprepareContentForHydration(mapTree, this.checkout.forest);\n\t\t\tinitialize(this.checkout, {\n\t\t\t\tschema: this.flexSchema,\n\t\t\t\tinitialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (compatibility.isEquivalent) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tif (!compatibility.canUpgrade) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst result = ensureSchema(\n\t\t\t\tthis.viewSchema,\n\t\t\t\tAllowedUpdateType.SchemaCompatible,\n\t\t\t\tthis.checkout,\n\t\t\t\t{\n\t\t\t\t\tschema: this.flexSchema,\n\t\t\t\t\tinitialTree: undefined,\n\t\t\t\t},\n\t\t\t);\n\t\t\tassert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);\n\t\t});\n\t}\n\n\t/**\n\t * Gets the view. Throws when disposed.\n\t */\n\tpublic getView(): CheckoutFlexTreeView<FlexFieldSchema> {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.view;\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeView();\n\n\t\tconst result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);\n\n\t\t// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.\n\t\t// In the near term, this should support viewing documents with additional optional fields in their schema on object types.\n\t\t// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility\n\t\t// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)\n\t\tconst canView =\n\t\t\tresult.write === Compatibility.Compatible && result.read === Compatibility.Compatible;\n\t\tconst canUpgrade = result.read === Compatibility.Compatible;\n\t\tconst isEquivalent = canView && canUpgrade;\n\t\tconst compatibility: SchemaCompatibilityStatus = {\n\t\t\tcanView,\n\t\t\tcanUpgrade,\n\t\t\tisEquivalent,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t\tlet lastRoot =\n\t\t\tthis.compatibility.canView && this.view !== undefined ? this.root : undefined;\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tif (compatibility.canView) {\n\t\t\t// Trigger \"rootChanged\" if the root changes in the future.\n\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t// this.view.flexTree.on(????)\n\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\"\n\t\t\t// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.\n\t\t\t// TODO: provide a better event: this.view.flexTree.on(????)\n\t\t\tconst cleanupCheckOutEvents = this.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\tif (!this.midUpgrade && lastRoot !== this.root) {\n\t\t\t\t\tlastRoot = this.root;\n\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst onViewDispose = (): void => {\n\t\t\t\tcleanupCheckOutEvents();\n\t\t\t\tthis.view = undefined;\n\t\t\t\tif (!this.disposed) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.view = requireSchema(\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.viewSchema,\n\t\t\t\tonViewDispose,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.view = undefined;\n\n\t\t\tconst unregister = this.checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\t\t\tunregister();\n\t\t\t\tthis.unregisterCallbacks.delete(unregister);\n\t\t\t\tthis.update();\n\t\t\t});\n\t\t\tthis.unregisterCallbacks.add(unregister);\n\t\t}\n\n\t\tif (!this.midUpgrade) {\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeView(): void {\n\t\tif (this.view !== undefined) {\n\t\t\tthis.view[disposeSymbol]();\n\t\t\tthis.view = undefined;\n\t\t\tthis.unregisterCallbacks.forEach((unregister) => unregister());\n\t\t}\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatus {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeView();\n\t\tthis.currentCompatibility = undefined;\n\t}\n\n\tpublic get root(): TreeFieldFromImplicitField<TRootSchema> {\n\t\tthis.breaker.use();\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\treturn getProxyForField(view.flexTree) as TreeFieldFromImplicitField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableTreeFieldFromImplicitField<TRootSchema>) {\n\t\tthis.breaker.use();\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\tsetField(view.context.root, this.rootFieldSchema, newRoot as InsertableContent);\n\t}\n}\n\n/**\n * Creates a view that self-disposes whenenever the stored schema changes.\n * This may only be called when the schema is already known to be compatible (typically via ensureSchema).\n */\nexport function requireSchema<TRoot extends FlexFieldSchema>(\n\tcheckout: TreeCheckout,\n\tviewSchema: ViewSchema<TRoot>,\n\tonDispose: () => void,\n\tnodeKeyManager: NodeKeyManager,\n): CheckoutFlexTreeView<TRoot> {\n\tconst slots = checkout.forest.anchors.slots;\n\tassert(!slots.has(ContextSlot), 0x8c2 /* Cannot create second view from checkout */);\n\n\t{\n\t\tconst compatibility = viewSchema.checkCompatibility(checkout.storedSchema);\n\t\tassert(\n\t\t\tcompatibility.write === Compatibility.Compatible &&\n\t\t\t\tcompatibility.read === Compatibility.Compatible,\n\t\t\t0x8c3 /* requireSchema invoked with incompatible schema */,\n\t\t);\n\t}\n\n\tconst view = new CheckoutFlexTreeView(\n\t\tcheckout,\n\t\tviewSchema.schema,\n\t\tnodeKeyManager,\n\t\tonDispose,\n\t);\n\tassert(slots.has(ContextSlot), 0x90d /* Context should be tracked in slot */);\n\n\tconst unregister = checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\tunregister();\n\t\tview[disposeSymbol]();\n\t});\n\n\treturn view;\n}\n"]}
|
|
@@ -154,7 +154,11 @@ export declare enum ForestType {
|
|
|
154
154
|
/**
|
|
155
155
|
* The "ChunkedForest" forest type.
|
|
156
156
|
*/
|
|
157
|
-
Optimized = 1
|
|
157
|
+
Optimized = 1,
|
|
158
|
+
/**
|
|
159
|
+
* The "ObjectForest" forest type with expensive asserts for debugging.
|
|
160
|
+
*/
|
|
161
|
+
Expensive = 2
|
|
158
162
|
}
|
|
159
163
|
export declare const defaultSharedTreeOptions: Required<SharedTreeOptions>;
|
|
160
164
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTree.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAGjF,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACrB,0BAA0B,EAG1B,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EAEN,KAAK,eAAe,EAGpB,uBAAuB,EAUvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGN,cAAc,EACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACX,KAAK,EACL,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,oCAAoC,EAAgB,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAiB,MAAM,2BAA2B,CAAC;AAGtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAuB,KAAK,YAAY,EAAsB,MAAM,mBAAmB,CAAC;AAC/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedTree.d.ts","sourceRoot":"","sources":["../../src/shared-tree/sharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAA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