@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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
6
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
8
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
+
};
|
|
16
|
+
var _TreeNodeKernel_hydrated, _TreeNodeKernel_events;
|
|
17
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
18
|
+
import { createEmitter } from "../events/index.js";
|
|
19
|
+
import { flexTreeSlot, isFreedSymbol, LazyEntity, TreeStatus, treeStatusFromAnchorCache, } from "../feature-libraries/index.js";
|
|
20
|
+
/**
|
|
21
|
+
* Contains state and an internal API for managing {@link TreeNode}s.
|
|
22
|
+
* @remarks All {@link TreeNode}s have an associated kernel object.
|
|
23
|
+
* The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.
|
|
24
|
+
* When hydration occurs, the kernel is notified via the {@link TreeNodeKernel.hydrate | hydrate} method.
|
|
25
|
+
*/
|
|
26
|
+
export class TreeNodeKernel {
|
|
27
|
+
constructor(node) {
|
|
28
|
+
this.node = node;
|
|
29
|
+
_TreeNodeKernel_hydrated.set(this, void 0);
|
|
30
|
+
_TreeNodeKernel_events.set(this, createEmitter());
|
|
31
|
+
}
|
|
32
|
+
hydrate(anchorNode) {
|
|
33
|
+
const offChildrenChanged = anchorNode.on("childrenChangedAfterBatch", () => {
|
|
34
|
+
__classPrivateFieldGet(this, _TreeNodeKernel_events, "f").emit("nodeChanged");
|
|
35
|
+
});
|
|
36
|
+
const offSubtreeChanged = anchorNode.on("subtreeChangedAfterBatch", () => {
|
|
37
|
+
__classPrivateFieldGet(this, _TreeNodeKernel_events, "f").emit("treeChanged");
|
|
38
|
+
});
|
|
39
|
+
const offAfterDestroy = anchorNode.on("afterDestroy", () => this.dispose());
|
|
40
|
+
__classPrivateFieldSet(this, _TreeNodeKernel_hydrated, {
|
|
41
|
+
anchorNode,
|
|
42
|
+
offAnchorNode: () => {
|
|
43
|
+
offChildrenChanged();
|
|
44
|
+
offSubtreeChanged();
|
|
45
|
+
offAfterDestroy();
|
|
46
|
+
},
|
|
47
|
+
}, "f");
|
|
48
|
+
}
|
|
49
|
+
dehydrate() {
|
|
50
|
+
__classPrivateFieldGet(this, _TreeNodeKernel_hydrated, "f")?.offAnchorNode?.();
|
|
51
|
+
__classPrivateFieldSet(this, _TreeNodeKernel_hydrated, undefined, "f");
|
|
52
|
+
}
|
|
53
|
+
isHydrated() {
|
|
54
|
+
return __classPrivateFieldGet(this, _TreeNodeKernel_hydrated, "f") !== undefined;
|
|
55
|
+
}
|
|
56
|
+
getStatus() {
|
|
57
|
+
if (__classPrivateFieldGet(this, _TreeNodeKernel_hydrated, "f")?.anchorNode === undefined) {
|
|
58
|
+
return TreeStatus.New;
|
|
59
|
+
}
|
|
60
|
+
// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel
|
|
61
|
+
const flex = __classPrivateFieldGet(this, _TreeNodeKernel_hydrated, "f").anchorNode.slots.get(flexTreeSlot);
|
|
62
|
+
if (flex !== undefined) {
|
|
63
|
+
assert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);
|
|
64
|
+
if (flex[isFreedSymbol]()) {
|
|
65
|
+
return TreeStatus.Deleted;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return treeStatusFromAnchorCache(__classPrivateFieldGet(this, _TreeNodeKernel_hydrated, "f").anchorNode);
|
|
69
|
+
}
|
|
70
|
+
on(eventName, listener) {
|
|
71
|
+
return __classPrivateFieldGet(this, _TreeNodeKernel_events, "f").on(eventName, listener);
|
|
72
|
+
}
|
|
73
|
+
dispose() {
|
|
74
|
+
this.dehydrate();
|
|
75
|
+
// TODO: go to the context and remove myself from withAnchors
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_TreeNodeKernel_hydrated = new WeakMap(), _TreeNodeKernel_events = new WeakMap();
|
|
79
|
+
//# sourceMappingURL=treeNodeKernel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../src/simple-tree/treeNodeKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAG9E,OAAO,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EACV,yBAAyB,GACzB,MAAM,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAO1B,YAAmC,IAAc;QAAd,SAAI,GAAJ,IAAI,CAAU;QANjD,2CAGE;QACF,iCAAU,aAAa,EAAoB,EAAC;IAEQ,CAAC;IAE9C,OAAO,CAAC,UAAsB;QACpC,MAAM,kBAAkB,GAAG,UAAU,CAAC,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;YAC1E,uBAAA,IAAI,8BAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAG,UAAU,CAAC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;YACxE,uBAAA,IAAI,8BAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAE5E,uBAAA,IAAI,4BAAa;YAChB,UAAU;YACV,aAAa,EAAE,GAAG,EAAE;gBACnB,kBAAkB,EAAE,CAAC;gBACrB,iBAAiB,EAAE,CAAC;gBACpB,eAAe,EAAE,CAAC;YACnB,CAAC;SACD,MAAA,CAAC;IACH,CAAC;IAEM,SAAS;QACf,uBAAA,IAAI,gCAAU,EAAE,aAAa,EAAE,EAAE,CAAC;QAClC,uBAAA,IAAI,4BAAa,SAAS,MAAA,CAAC;IAC5B,CAAC;IAEM,UAAU;QAChB,OAAO,uBAAA,IAAI,gCAAU,KAAK,SAAS,CAAC;IACrC,CAAC;IAEM,SAAS;QACf,IAAI,uBAAA,IAAI,gCAAU,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9C,OAAO,UAAU,CAAC,GAAG,CAAC;QACvB,CAAC;QAED,qHAAqH;QACrH,MAAM,IAAI,GAAG,uBAAA,IAAI,gCAAU,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC/D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,YAAY,UAAU,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;YACpF,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;gBAC3B,OAAO,UAAU,CAAC,OAAO,CAAC;YAC3B,CAAC;QACF,CAAC;QAED,OAAO,yBAAyB,CAAC,uBAAA,IAAI,gCAAU,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;IAEM,EAAE,CACR,SAAY,EACZ,QAA6B;QAE7B,OAAO,uBAAA,IAAI,8BAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,6DAA6D;IAC9D,CAAC;CACD","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 { createEmitter, type Listenable, type Off } from \"../events/index.js\";\nimport type { TreeChangeEvents, TreeNode } from \"./types.js\";\nimport type { AnchorNode } from \"../core/index.js\";\nimport {\n\tflexTreeSlot,\n\tisFreedSymbol,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n} from \"../feature-libraries/index.js\";\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n * When hydration occurs, the kernel is notified via the {@link TreeNodeKernel.hydrate | hydrate} method.\n */\nexport class TreeNodeKernel implements Listenable<TreeChangeEvents> {\n\t#hydrated?: {\n\t\tanchorNode: AnchorNode;\n\t\toffAnchorNode: Off;\n\t};\n\t#events = createEmitter<TreeChangeEvents>();\n\n\tpublic constructor(public readonly node: TreeNode) {}\n\n\tpublic hydrate(anchorNode: AnchorNode): void {\n\t\tconst offChildrenChanged = anchorNode.on(\"childrenChangedAfterBatch\", () => {\n\t\t\tthis.#events.emit(\"nodeChanged\");\n\t\t});\n\n\t\tconst offSubtreeChanged = anchorNode.on(\"subtreeChangedAfterBatch\", () => {\n\t\t\tthis.#events.emit(\"treeChanged\");\n\t\t});\n\n\t\tconst offAfterDestroy = anchorNode.on(\"afterDestroy\", () => this.dispose());\n\n\t\tthis.#hydrated = {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: () => {\n\t\t\t\toffChildrenChanged();\n\t\t\t\toffSubtreeChanged();\n\t\t\t\toffAfterDestroy();\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic dehydrate(): void {\n\t\tthis.#hydrated?.offAnchorNode?.();\n\t\tthis.#hydrated = undefined;\n\t}\n\n\tpublic isHydrated(): boolean {\n\t\treturn this.#hydrated !== undefined;\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.#hydrated?.anchorNode === undefined) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrated.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex[isFreedSymbol]()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrated.anchorNode);\n\t}\n\n\tpublic on<K extends keyof TreeChangeEvents>(\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): Off {\n\t\treturn this.#events.on(eventName, listener);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.dehydrate();\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { ErasedType } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { type WithType, typeNameSymbol } from "./schemaTypes.js";
|
|
6
|
+
import { type TreeNodeSchema, type WithType, typeNameSymbol } from "./schemaTypes.js";
|
|
7
7
|
import { type FlexTreeNode, type MapTreeNode } from "../feature-libraries/index.js";
|
|
8
8
|
/**
|
|
9
9
|
* Type alias to document which values are un-hydrated.
|
|
@@ -15,6 +15,79 @@ import { type FlexTreeNode, type MapTreeNode } from "../feature-libraries/index.
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export type Unhydrated<T> = T;
|
|
18
|
+
/**
|
|
19
|
+
* A collection of events that can be emitted by a {@link TreeNode}.
|
|
20
|
+
*
|
|
21
|
+
* @privateRemarks
|
|
22
|
+
* TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).
|
|
23
|
+
* Probably have object node and map node specific APIs for this.
|
|
24
|
+
*
|
|
25
|
+
* TODO: ensure that subscription API for fields aligns with API for subscribing to the root.
|
|
26
|
+
*
|
|
27
|
+
* TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.
|
|
28
|
+
* Some ideas:
|
|
29
|
+
*
|
|
30
|
+
* - treeChanged, but with some subtrees/fields/paths excluded
|
|
31
|
+
* - helper to batch several nodeChanged calls to a treeChanged scope
|
|
32
|
+
* - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)
|
|
33
|
+
* - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.
|
|
34
|
+
* Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)
|
|
35
|
+
* to allow efficiently searching for new content (and initial content) of a given type.
|
|
36
|
+
*
|
|
37
|
+
* @sealed @public
|
|
38
|
+
*/
|
|
39
|
+
export interface TreeChangeEvents {
|
|
40
|
+
/**
|
|
41
|
+
* Emitted by a node after a batch of changes has been applied to the tree, if a change affected the node, where a
|
|
42
|
+
* change is:
|
|
43
|
+
*
|
|
44
|
+
* - For an object node, when the value of one of its properties changes (i.e., the property's value is set
|
|
45
|
+
* to something else, including `undefined`).
|
|
46
|
+
*
|
|
47
|
+
* - For an array node, when an element is added, removed, or moved.
|
|
48
|
+
*
|
|
49
|
+
* - For a map node, when an entry is added, updated, or removed.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* This event is not emitted when:
|
|
53
|
+
*
|
|
54
|
+
* - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing
|
|
55
|
+
* elements/entries) will emit this event on the array/map node itself, but not on the node that contains the
|
|
56
|
+
* array/map node as one of its properties.
|
|
57
|
+
*
|
|
58
|
+
* - The node is moved to a different location in the tree or removed from the tree.
|
|
59
|
+
* In this case the event is emitted on the _parent_ node, not the node itself.
|
|
60
|
+
*
|
|
61
|
+
* For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
|
|
62
|
+
* the client that made the original edit.
|
|
63
|
+
*
|
|
64
|
+
* When it is emitted, the tree is guaranteed to be in-schema.
|
|
65
|
+
*
|
|
66
|
+
* @privateRemarks
|
|
67
|
+
* This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.
|
|
68
|
+
* For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the
|
|
69
|
+
* node, or when the node has to be updated due to resolution of a merge conflict
|
|
70
|
+
* (for example a previously applied local change might be undone, then reapplied differently or not at all).
|
|
71
|
+
*/
|
|
72
|
+
nodeChanged(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the
|
|
75
|
+
* subtree rooted at it.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.
|
|
79
|
+
* In that case it is emitted on the _parent_ node, not the node itself.
|
|
80
|
+
*
|
|
81
|
+
* The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties
|
|
82
|
+
* of the node itself.
|
|
83
|
+
*
|
|
84
|
+
* For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in
|
|
85
|
+
* the client that made the original edit.
|
|
86
|
+
*
|
|
87
|
+
* When it is emitted, the tree is guaranteed to be in-schema.
|
|
88
|
+
*/
|
|
89
|
+
treeChanged(): void;
|
|
90
|
+
}
|
|
18
91
|
/**
|
|
19
92
|
* A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.
|
|
20
93
|
*
|
|
@@ -110,15 +183,34 @@ export declare abstract class TreeNodeValid<TInput> extends TreeNode {
|
|
|
110
183
|
* Also used to detect if oneTimeSetup has run.
|
|
111
184
|
*
|
|
112
185
|
* @privateRemarks
|
|
113
|
-
* This defaults to
|
|
186
|
+
* This defaults to "default", which is used to trigger an error if not overridden in the derived class.
|
|
114
187
|
*
|
|
115
188
|
* The value of this on TreeNodeValid must only be overridden by base classes and never modified.
|
|
116
189
|
* Ways to enforce this immutability prevent it from being overridden,
|
|
117
190
|
* so code modifying constructorCached should be extra careful to avoid accidentally modifying the base/inherited value.
|
|
118
191
|
*/
|
|
119
|
-
protected static constructorCached:
|
|
192
|
+
protected static constructorCached: MostDerivedData | "default" | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Indicate that `this` is the most derived version of a schema, and thus the only one allowed to be used (other than by being subclassed a single time).
|
|
195
|
+
*/
|
|
196
|
+
static markMostDerived(this: typeof TreeNodeValid & TreeNodeSchema): MostDerivedData;
|
|
120
197
|
constructor(input: TInput | InternalTreeNode);
|
|
121
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Data cached about the most derived type in a schema's class hierarchy.
|
|
201
|
+
* @remarks
|
|
202
|
+
* The most derived type is the only one allowed to be referenced by other schema or constructed as a node.
|
|
203
|
+
* It has to be discovered lazily (when a node is constructed or when a {@link TreeViewConfiguration} is made),
|
|
204
|
+
* since JavaScript provides no way to find derived classes, or inject static class initialization time logic into base classes.
|
|
205
|
+
* Additionally since schema can reference other schema through lazy references which might be forward or recursive references,
|
|
206
|
+
* this can not be evaluated for one schema when referenced by another schema.
|
|
207
|
+
*
|
|
208
|
+
* See {@link TreeNodeValid.constructorCached} and {@link TreeNodeValid.markMostDerived}.
|
|
209
|
+
*/
|
|
210
|
+
export interface MostDerivedData {
|
|
211
|
+
readonly constructor: typeof TreeNodeValid & TreeNodeSchema;
|
|
212
|
+
oneTimeInitialized: boolean;
|
|
213
|
+
}
|
|
122
214
|
/**
|
|
123
215
|
* A node type internal to `@fluidframework/tree`.
|
|
124
216
|
* @remarks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/simple-tree/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/simple-tree/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EAEN,KAAK,cAAc,EAEnB,KAA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AAK,EAAE,YAAY,GACjB,aAAa,CAAC,CAAC,CAAC;IAInB;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAC9B,IAAI,EAAE,OAAO,aAAa,CAAC,CAAC,CAAC,EAC7B,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,KAAK,EAAE,CAAC,GACN,WAAW;IAId;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI;IAErE;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAS,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,GAAG,SAAS,GAAG,SAAS,CAAa;IAExF;;OAEG;WACW,eAAe,CAAC,IAAI,EAAE,OAAO,aAAa,GAAG,cAAc,GAAG,eAAe;gBAoCxE,KAAK,EAAE,MAAM,GAAG,gBAAgB;CAkCnD;AAID;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,WAAW,EAAE,OAAO,aAAa,GAAG,cAAc,CAAC;IAC5D,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAChB,SAAQ,UAAU,CAAC,uCAAuC,CAAC;CAAG;AAE/D,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,CAGnE"}
|
package/lib/simple-tree/types.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
var _a;
|
|
5
6
|
var _TreeNode_brand;
|
|
6
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
8
|
import { NodeKind, typeNameSymbol, } from "./schemaTypes.js";
|
|
@@ -11,7 +12,7 @@ import { isTreeNode } from "./proxies.js";
|
|
|
11
12
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
12
13
|
import { getFlexSchema } from "./toFlexSchema.js";
|
|
13
14
|
import { fail } from "../util/index.js";
|
|
14
|
-
import { setFlexNode } from "./proxyBinding.js";
|
|
15
|
+
import { getFlexNode, createKernel, setFlexNode } from "./proxyBinding.js";
|
|
15
16
|
import { tryGetSchema } from "./treeNodeApi.js";
|
|
16
17
|
/**
|
|
17
18
|
* A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.
|
|
@@ -126,31 +127,42 @@ export class TreeNodeValid extends TreeNode {
|
|
|
126
127
|
* This is a good place to perform extra validation and cache schema derived data needed for the implementation of the node.
|
|
127
128
|
*/
|
|
128
129
|
static oneTimeSetup() { }
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
assert(schema.constructorCached !== TreeNodeValid, 0x960 /* Schema class schema must override static constructorCached member */);
|
|
136
|
-
throw new UsageError(`Two schema classes were instantiated (${schema.name} and ${schema.constructorCached.name}) which derived from the same SchemaFactory generated class. This is invalid`);
|
|
137
|
-
}
|
|
138
|
-
const flexSchema = getFlexSchema(schema);
|
|
139
|
-
assert(tryGetSimpleNodeSchema(flexSchema) === schema, 0x961 /* Schema class not properly configured */);
|
|
140
|
-
schema.oneTimeSetup();
|
|
130
|
+
/**
|
|
131
|
+
* Indicate that `this` is the most derived version of a schema, and thus the only one allowed to be used (other than by being subclassed a single time).
|
|
132
|
+
*/
|
|
133
|
+
static markMostDerived() {
|
|
134
|
+
assert(this.constructorCached !== "default", 0x95f /* invalid schema class */);
|
|
135
|
+
if (this.constructorCached === undefined) {
|
|
141
136
|
// Set the constructorCached on the layer of the prototype chain that declared it.
|
|
142
137
|
// This is necessary to ensure there is only one subclass of that type used:
|
|
143
138
|
// if constructorCached was simply set on `schema`,
|
|
144
139
|
// then a base classes between `schema` (exclusive) and where `constructorCached` is set (inclusive) and other subclasses of them
|
|
145
140
|
// would not see the stored `constructorCached`, and the validation above against multiple derived classes would not work.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
assert(schemaBase.constructorCached === undefined, 0x962 /* overwriting wrong cache */);
|
|
152
|
-
schemaBase.constructorCached = schema;
|
|
141
|
+
// This is not just an alias of `this`, but a reference to the item in the prototype chain being walked, which happens to start at `this`.
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
143
|
+
let schemaBase = this;
|
|
144
|
+
while (!Object.prototype.hasOwnProperty.call(schemaBase, "constructorCached")) {
|
|
145
|
+
schemaBase = Reflect.getPrototypeOf(schemaBase);
|
|
153
146
|
}
|
|
147
|
+
assert(schemaBase.constructorCached === undefined, 0x962 /* overwriting wrong cache */);
|
|
148
|
+
schemaBase.constructorCached = { constructor: this, oneTimeInitialized: false };
|
|
149
|
+
assert(this.constructorCached === schemaBase.constructorCached, 0x9b5 /* Inheritance should work */);
|
|
150
|
+
return this.constructorCached;
|
|
151
|
+
}
|
|
152
|
+
else if (this.constructorCached.constructor === this) {
|
|
153
|
+
return this.constructorCached;
|
|
154
|
+
}
|
|
155
|
+
throw new UsageError(`Two schema classes were used (${this.name} and ${this.constructorCached.constructor.name}) which derived from the same SchemaFactory generated class (${JSON.stringify(this.identifier)}). This is invalid.`);
|
|
156
|
+
}
|
|
157
|
+
constructor(input) {
|
|
158
|
+
super();
|
|
159
|
+
const schema = this.constructor;
|
|
160
|
+
const cache = schema.markMostDerived();
|
|
161
|
+
if (!cache.oneTimeInitialized) {
|
|
162
|
+
const flexSchema = getFlexSchema(schema);
|
|
163
|
+
assert(tryGetSimpleNodeSchema(flexSchema) === schema, 0x961 /* Schema class not properly configured */);
|
|
164
|
+
schema.oneTimeSetup();
|
|
165
|
+
cache.oneTimeInitialized = true;
|
|
154
166
|
}
|
|
155
167
|
if (isTreeNode(input)) {
|
|
156
168
|
// TODO: update this once we have better support for deep-copying and move operations.
|
|
@@ -161,6 +173,7 @@ export class TreeNodeValid extends TreeNode {
|
|
|
161
173
|
: schema.buildRawNode(this, input);
|
|
162
174
|
assert(tryGetSimpleNodeSchema(node.schema) === schema, 0x83b /* building node with wrong schema */);
|
|
163
175
|
const result = schema.prepareInstance(this, node);
|
|
176
|
+
createKernel(result);
|
|
164
177
|
setFlexNode(result, node);
|
|
165
178
|
return result;
|
|
166
179
|
}
|
|
@@ -177,17 +190,103 @@ export class TreeNodeValid extends TreeNode {
|
|
|
177
190
|
* Also used to detect if oneTimeSetup has run.
|
|
178
191
|
*
|
|
179
192
|
* @privateRemarks
|
|
180
|
-
* This defaults to
|
|
193
|
+
* This defaults to "default", which is used to trigger an error if not overridden in the derived class.
|
|
181
194
|
*
|
|
182
195
|
* The value of this on TreeNodeValid must only be overridden by base classes and never modified.
|
|
183
196
|
* Ways to enforce this immutability prevent it from being overridden,
|
|
184
197
|
* so code modifying constructorCached should be extra careful to avoid accidentally modifying the base/inherited value.
|
|
185
198
|
*/
|
|
186
|
-
TreeNodeValid.constructorCached =
|
|
199
|
+
TreeNodeValid.constructorCached = "default";
|
|
187
200
|
// Class objects are functions (callable), so we need a strong way to distinguish between `schema` and `() => schema` when used as a `LazyItem`.
|
|
188
201
|
markEager(TreeNodeValid);
|
|
189
202
|
export function toFlexTreeNode(node) {
|
|
190
203
|
assert(isFlexTreeNode(node), 0x963 /* Invalid InternalTreeNode */);
|
|
191
204
|
return node;
|
|
192
205
|
}
|
|
206
|
+
// #region NodeJS custom inspect for TreeNodes.
|
|
207
|
+
/**
|
|
208
|
+
* Used to customize "inspect" behavior in NodeJS.
|
|
209
|
+
* See https://nodejs.org/api/util.html#utilinspectcustom for details.
|
|
210
|
+
*
|
|
211
|
+
* VS-Code's debugger also uses this to inspect objects,
|
|
212
|
+
* see https://github.com/microsoft/vscode-js-debug/blob/64df2686c92bac402909dee5c3c389bbb7a81f6d/src/adapter/templates/getStringyProps.ts#L11 for details.
|
|
213
|
+
*/
|
|
214
|
+
const customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
215
|
+
/**
|
|
216
|
+
* Node inspecting function for use with {@link customInspectSymbol}.
|
|
217
|
+
*/
|
|
218
|
+
function inspectNodeFunction(depth, options, inspect) {
|
|
219
|
+
// TODO: replicated from tryGetSchema to avoid cycle.
|
|
220
|
+
// This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.
|
|
221
|
+
const schema = tryGetSimpleNodeSchema(getFlexNode(this).schema);
|
|
222
|
+
const title = `${schema.name}: ${NodeKind[schema.kind]} Node (${schema.identifier})`;
|
|
223
|
+
if (depth < 2) {
|
|
224
|
+
const short = shortContent(this);
|
|
225
|
+
if (short !== undefined) {
|
|
226
|
+
return `${title} ${short}`;
|
|
227
|
+
}
|
|
228
|
+
return title;
|
|
229
|
+
}
|
|
230
|
+
const content = `${title} ${JSON.stringify(this)}`;
|
|
231
|
+
return content;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* If the node has no items, a short JSON string for it.
|
|
235
|
+
*/
|
|
236
|
+
function shortContent(node) {
|
|
237
|
+
if (Object.values(node).length === 0) {
|
|
238
|
+
return JSON.stringify(node);
|
|
239
|
+
}
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Add inherited non-enumerable symbol for NodeJS inspection to all nodes.
|
|
244
|
+
*
|
|
245
|
+
* See {@link customInspectSymbol}.
|
|
246
|
+
*/
|
|
247
|
+
Object.defineProperty(TreeNodeValid.prototype, customInspectSymbol, {
|
|
248
|
+
value: inspectNodeFunction,
|
|
249
|
+
enumerable: false,
|
|
250
|
+
});
|
|
251
|
+
// #endregion
|
|
252
|
+
// #region Browser custom debug format for TreeNodes
|
|
253
|
+
// This section has side-effects, so including it in this file ensures its loaded whenever TreeNodes could exist.
|
|
254
|
+
// Supported in at least Chrome and FireFox, more details at https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
|
|
255
|
+
// For this to work the browser's dev tools generally have to "Enable custom formatters".
|
|
256
|
+
// This formatter is inspired by https://github.com/andrewdavey/immutable-devtools/blob/master/src/createFormatters.js which provides a similar formatter for the immutable.js library.
|
|
257
|
+
const globals = typeof window === "undefined" ? globalThis : window;
|
|
258
|
+
const formatters = ((_a = globals).devtoolsFormatters ?? (_a.devtoolsFormatters = []));
|
|
259
|
+
const nodeFormatter = {
|
|
260
|
+
header(object, config) {
|
|
261
|
+
if (isTreeNode(object)) {
|
|
262
|
+
return ["span", `${inspectNodeFunction.call(object, 1)}`];
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
},
|
|
266
|
+
body(object, config) {
|
|
267
|
+
const children = [];
|
|
268
|
+
for (const [key, value] of Object.entries(object)) {
|
|
269
|
+
children.push(["li", ["span", `${key}: `], formattedReference(value)]);
|
|
270
|
+
}
|
|
271
|
+
// TODO:
|
|
272
|
+
// for array nodes, this isn't great since (at least in FireFox) the list items show up with a prefixed number starting from 1.
|
|
273
|
+
// This looks messy when followed by the array index.
|
|
274
|
+
// Find a way to hide the list index.
|
|
275
|
+
// { style: 'list-style-type: none` } did not seem to work.
|
|
276
|
+
return ["ol", ...children];
|
|
277
|
+
},
|
|
278
|
+
hasBody(object, config) {
|
|
279
|
+
return shortContent(object) === undefined;
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
function formattedReference(object, config) {
|
|
283
|
+
if (typeof object === "undefined") {
|
|
284
|
+
return ["span", "undefined"];
|
|
285
|
+
}
|
|
286
|
+
else if (object === "null") {
|
|
287
|
+
return ["span", "null"];
|
|
288
|
+
}
|
|
289
|
+
return ["object", { object, config }];
|
|
290
|
+
}
|
|
291
|
+
formatters.push(nodeFormatter);
|
|
193
292
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/simple-tree/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,C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CAAC,aAAa,CAAC,CAAC;AAazB,MAAM,UAAU,cAAc,CAAC,IAAsB;IACpD,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACnE,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 type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tNodeKind,\n\ttype TreeNodeSchema,\n\ttype WithType,\n\ttypeNameSymbol,\n} from \"./schemaTypes.js\";\nimport {\n\ttype FlexTreeNode,\n\ttype MapTreeNode,\n\tisFlexTreeNode,\n\tmarkEager,\n} from \"../feature-libraries/index.js\";\nimport { tryGetSimpleNodeSchema } from \"./schemaCaching.js\";\nimport { isTreeNode } from \"./proxies.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { getFlexSchema } from \"./toFlexSchema.js\";\nimport { fail } from \"../util/index.js\";\nimport { setFlexNode } from \"./proxyBinding.js\";\nimport { tryGetSchema } from \"./treeNodeApi.js\";\n\n/**\n * Type alias to document which values are un-hydrated.\n *\n * Un-hydrated values are nodes produced from schema's create functions that haven't been inserted into a tree yet.\n *\n * Since un-hydrated nodes become hydrated when inserted, strong typing can't be used to distinguish them.\n * This no-op wrapper is used instead.\n * @public\n */\nexport type Unhydrated<T> = T;\n\n/**\n * A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.\n *\n * @remarks\n * Base type which all nodes implement.\n *\n * This can be used as a type to indicate/document values which should be tree nodes.\n * Runtime use of this class object (for example when used with `instanceof` or extending it), is not currently supported.\n *\n * Instances of tree nodes must be created by opening an existing document, inserting values into the document,\n * or by using the constructors and create functions of {@link TreeNodeSchema} produced by {@link SchemaFactory}.\n * @privateRemarks\n * This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})\n * and some runtime enforcement of schema class policy (see the the validation in the constructor).\n * This class is however only `type` exported not value exported, preventing the class object from being used,\n * similar to how interfaces work.\n *\n * Not all node implementations include this in their prototype chain (some hide it with a proxy),\n * and thus cause the default/built in `instanceof` to return false despite our type checking and all other APIs treating them as TreeNodes.\n * This class provides a custom `Symbol.hasInstance` to fix `instanceof` for this class and all classes extending it.\n * For now the type-only export prevents use of `instanceof` on this class (but allows it in subclasses like schema classes).\n * @sealed @public\n */\nexport abstract class TreeNode implements WithType {\n\t/**\n\t * This is added to prevent TypeScript from implicitly allowing non-TreeNode types to be used as TreeNodes.\n\t * @remarks\n\t * This field forces TypeScript to use nominal instead of structural typing,\n\t * preventing compiler error messages and tools like \"add missing properties\"\n\t * from adding the [type] field as a solution when using a non-TreeNode object where a TreeNode is required.\n\t * Instead TreeNodes must be created through the appropriate APIs, see the documentation on {@link TreeNode} for details.\n\t *\n\t * @privateRemarks\n\t * This is a JavaScript private field, so is not accessible from outside this class.\n\t * This prevents it from having name collisions with object fields.\n\t * Since this is private, the type of this field is stripped in the d.ts file.\n\t * To get matching type checking within and from outside the package, the least informative type (`unknown`) is used.\n\t * To avoid this having any runtime impact, the field is uninitialized.\n\t *\n\t * Making this field optional results in different type checking within this project than outside of it, since the d.ts file drops the optional aspect of the field.\n\t * This is extra confusing since since the tests get in-project typing for intellisense and separate project checking at build time.\n\t * To avoid all this mess, this field is required, not optional.\n\t *\n\t * Another option would be to use a symbol (possibly as a private field).\n\t * That approach ran into some strange difficulties causing SchemaFactory to fail to compile, and was not investigated further.\n\t *\n\t * The [type] symbol provides a lot of the value this private brand does, but is not all of it:\n\t * someone could manually (or via Intellisense auto-implement completion, or in response to a type error)\n\t * make an object literal with the [type] field and pass it off as a node: this private brand prevents that.\n\t */\n\treadonly #brand!: unknown;\n\n\t/**\n\t * Adds a type symbol for stronger typing.\n\t * @privateRemarks\n\t * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.\n\t */\n\tpublic abstract get [typeNameSymbol](): string;\n\n\t/**\n\t * Provides `instanceof` support for testing if a value is a `TreeNode`.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Due to type-only export, this functionality is not available outside the package.\n\t */\n\tpublic static [Symbol.hasInstance](value: unknown): value is TreeNode;\n\n\t/**\n\t * Provides `instanceof` support for all schema classes with public constructors.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Despite type-only export, this functionality is available outside the package since it is inherited by subclasses.\n\t */\n\tpublic static [Symbol.hasInstance]<\n\t\tTSchema extends abstract new (\n\t\t\t...args: any[]\n\t\t) => TreeNode,\n\t>(this: TSchema, value: unknown): value is InstanceType<TSchema>;\n\n\tpublic static [Symbol.hasInstance](this: { prototype: object }, value: unknown): boolean {\n\t\tconst schema = tryGetSchema(value);\n\n\t\tif (schema === undefined || schema.kind === NodeKind.Leaf) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(\"prototype\" in schema, 0x98a /* expected class based schema */);\n\t\treturn inPrototypeChain(schema.prototype, this.prototype);\n\t}\n\n\tprotected constructor() {\n\t\tif (!inPrototypeChain(Reflect.getPrototypeOf(this), TreeNodeValid.prototype)) {\n\t\t\tthrow new UsageError(\"TreeNodes must extend schema classes created by SchemaFactory\");\n\t\t}\n\t}\n}\n\n/**\n * Check if the prototype derived's prototype chain contains `base`.\n * @param derived - prototype to check\n * @param base - prototype to search for\n * @returns true iff `base` is in the prototype chain starting at `derived`.\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function inPrototypeChain(derived: object | null, base: object): boolean {\n\tlet checking = derived;\n\twhile (checking !== null) {\n\t\tif (base === checking) {\n\t\t\treturn true;\n\t\t}\n\t\tchecking = Reflect.getPrototypeOf(checking);\n\t}\n\treturn false;\n}\n\n/**\n * Class which all {@link TreeNode}s must extend.\n * Since this is not exported, it allows robust detection of attempts to create TreeNodes which do not go through SchemaFactory which is the only place which exposes classes that extend this.\n *\n * This has static members which schema classes can override to provide schema specific functionality.\n * These static members are only intended to be used / overridden by code within this package, and are used by the various node kinds.\n * Access to these static members has to be done via `this.constructor.staticMember` to support the overrides, and thus can only be used in the constructor, after the base constructor has been invoked.\n */\nexport abstract class TreeNodeValid<TInput> extends TreeNode {\n\t/**\n\t * Schema classes can override this to control what happens at the end of the constructor.\n\t * The return value from this is returned from the constructor, allowing substituting a proxy if desired.\n\t *\n\t * This is not simply done in the derived constructor to enable:\n\t * - this class to access the value which is being returned before it's returned from the constructor.\n\t * - the derived class to be provided the input `FlexTreeNode` without relying on a field on the node to hold it.\n\t */\n\tprotected static prepareInstance<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: FlexTreeNode,\n\t): TreeNodeValid<T> {\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Schema classes must override to provide an implementation of RawTreeNode construction.\n\t */\n\tprotected static buildRawNode<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: T,\n\t): MapTreeNode {\n\t\treturn fail(\"Schema must override buildRawNode\");\n\t}\n\n\t/**\n\t * Schema classes can override to provide a callback that is called once when the first node is constructed.\n\t * This is a good place to perform extra validation and cache schema derived data needed for the implementation of the node.\n\t */\n\tprotected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>): void {}\n\n\t/**\n\t * The most derived constructor (the one invoked with the `new` operator, not a parent class constructor invoked with as `super`) used to construct an instance of this type.\n\t * @remarks\n\t * Captured when an instance is constructed.\n\t *\n\t * Used to ensure that some derived class (which must override this member, defaulting it to `undefined`) is only instantiated with a single \"most derived\" class (the constructor actually invoked the the user with `new`).\n\t *\n\t * Typically this is override in the class that statically implements {@link TreeNodeSchema} to enforce that all nodes using that schema use the same class and not different subclasses of it.\n\t *\n\t * Also used to detect if oneTimeSetup has run.\n\t *\n\t * @privateRemarks\n\t * This defaults to TreeNodeValid, which is used to trigger an error if not overridden in the derived class.\n\t *\n\t * The value of this on TreeNodeValid must only be overridden by base classes and never modified.\n\t * Ways to enforce this immutability prevent it from being overridden,\n\t * so code modifying constructorCached should be extra careful to avoid accidentally modifying the base/inherited value.\n\t */\n\tprotected static constructorCached: typeof TreeNodeValid | undefined = TreeNodeValid;\n\n\tpublic constructor(input: TInput | InternalTreeNode) {\n\t\tsuper();\n\t\tconst schema = this.constructor as typeof TreeNodeValid & TreeNodeSchema;\n\t\tassert(\"constructorCached\" in schema, 0x95f /* invalid schema class */);\n\t\tif (schema.constructorCached !== schema) {\n\t\t\tif (schema.constructorCached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tschema.constructorCached !== TreeNodeValid,\n\t\t\t\t\t0x960 /* Schema class schema must override static constructorCached member */,\n\t\t\t\t);\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Two schema classes were instantiated (${schema.name} and ${schema.constructorCached.name}) which derived from the same SchemaFactory generated class. This is invalid`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst flexSchema = getFlexSchema(schema);\n\t\t\tassert(\n\t\t\t\ttryGetSimpleNodeSchema(flexSchema) === schema,\n\t\t\t\t0x961 /* Schema class not properly configured */,\n\t\t\t);\n\t\t\tschema.oneTimeSetup();\n\t\t\t// Set the constructorCached on the layer of the prototype chain that declared it.\n\t\t\t// This is necessary to ensure there is only one subclass of that type used:\n\t\t\t// if constructorCached was simply set on `schema`,\n\t\t\t// then a base classes between `schema` (exclusive) and where `constructorCached` is set (inclusive) and other subclasses of them\n\t\t\t// would not see the stored `constructorCached`, and the validation above against multiple derived classes would not work.\n\t\t\t{\n\t\t\t\tlet schemaBase: typeof TreeNodeValid = schema;\n\t\t\t\twhile (!Object.prototype.hasOwnProperty.call(schemaBase, \"constructorCached\")) {\n\t\t\t\t\tschemaBase = Reflect.getPrototypeOf(schemaBase) as typeof TreeNodeValid;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tschemaBase.constructorCached === undefined,\n\t\t\t\t\t0x962 /* overwriting wrong cache */,\n\t\t\t\t);\n\t\t\t\tschemaBase.constructorCached = schema;\n\t\t\t}\n\t\t}\n\n\t\tif (isTreeNode(input)) {\n\t\t\t// TODO: update this once we have better support for deep-copying and move operations.\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing nodes may not be used as the constructor parameter for a new node. The existing node may be used directly instead of creating a new one, used as a child of the new node (if it has not yet been inserted into the tree). If the desired result is copying the provided node, it must be deep copied (since any child node would be parented under both the new and old nodes). Currently no API is provided to make deep copies, but it can be done manually with object spreads - for example `new Foo({...oldFoo})` will work if all fields of `oldFoo` are leaf nodes.\",\n\t\t\t);\n\t\t}\n\n\t\tconst node: FlexTreeNode = isFlexTreeNode(input)\n\t\t\t? input\n\t\t\t: schema.buildRawNode(this, input);\n\t\tassert(\n\t\t\ttryGetSimpleNodeSchema(node.schema) === schema,\n\t\t\t0x83b /* building node with wrong schema */,\n\t\t);\n\n\t\tconst result = schema.prepareInstance(this, node);\n\t\tsetFlexNode(result, node);\n\t\treturn result;\n\t}\n}\n// Class objects are functions (callable), so we need a strong way to distinguish between `schema` and `() => schema` when used as a `LazyItem`.\nmarkEager(TreeNodeValid);\n\n/**\n * A node type internal to `@fluidframework/tree`.\n * @remarks\n * This type is used in the construction of {@link TreeNode} as an implementation detail, but leaks into the public API due to how schema are implemented.\n * @privateRemarks\n * A {@link FlexTreeNode}. Includes {@link RawTreeNode}s.\n * @sealed @public\n */\nexport interface InternalTreeNode\n\textends ErasedType<\"@fluidframework/tree.InternalTreeNode\"> {}\n\nexport function toFlexTreeNode(node: InternalTreeNode): FlexTreeNode {\n\tassert(isFlexTreeNode(node), 0x963 /* Invalid InternalTreeNode */);\n\treturn node;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/simple-tree/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;AAGH,OAAO,EAAE,MAAM,EAAE,M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B,EAAE,CAAC;QAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAkB,CAAC,EAAE,CAAC;YAC/D,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC;QAED,QAAQ;QACR,+HAA+H;QAC/H,qDAAqD;QACrD,qCAAqC;QACrC,2DAA2D;QAE3D,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,CAAC,MAAM,EAAE,MAAM;QACrB,OAAO,YAAY,CAAC,MAAkC,CAAC,KAAK,SAAS,CAAC;IACvE,CAAC;CACD,CAAC;AAEF,SAAS,kBAAkB,CAC1B,MAAe,EACf,MAAuC;IAEvC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC9B,CAAC;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tNodeKind,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n\ttypeNameSymbol,\n} from \"./schemaTypes.js\";\nimport {\n\ttype FlexTreeNode,\n\ttype MapTreeNode,\n\tisFlexTreeNode,\n\tmarkEager,\n} from \"../feature-libraries/index.js\";\nimport { tryGetSimpleNodeSchema } from \"./schemaCaching.js\";\nimport { isTreeNode } from \"./proxies.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { getFlexSchema } from \"./toFlexSchema.js\";\nimport { fail } from \"../util/index.js\";\nimport { getFlexNode, createKernel, setFlexNode } from \"./proxyBinding.js\";\nimport { tryGetSchema } from \"./treeNodeApi.js\";\n\n/**\n * Type alias to document which values are un-hydrated.\n *\n * Un-hydrated values are nodes produced from schema's create functions that haven't been inserted into a tree yet.\n *\n * Since un-hydrated nodes become hydrated when inserted, strong typing can't be used to distinguish them.\n * This no-op wrapper is used instead.\n * @public\n */\nexport type Unhydrated<T> = T;\n\n/**\n * A collection of events that can be emitted by a {@link TreeNode}.\n *\n * @privateRemarks\n * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).\n * Probably have object node and map node specific APIs for this.\n *\n * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.\n *\n * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.\n * Some ideas:\n *\n * - treeChanged, but with some subtrees/fields/paths excluded\n * - helper to batch several nodeChanged calls to a treeChanged scope\n * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)\n * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.\n * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)\n * to allow efficiently searching for new content (and initial content) of a given type.\n *\n * @sealed @public\n */\nexport interface TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if a change affected the node, where a\n\t * change is:\n\t *\n\t * - For an object node, when the value of one of its properties changes (i.e., the property's value is set\n\t * to something else, including `undefined`).\n\t *\n\t * - For an array node, when an element is added, removed, or moved.\n\t *\n\t * - For a map node, when an entry is added, updated, or removed.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When it is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t */\n\tnodeChanged(): void;\n\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the\n\t * subtree rooted at it.\n\t *\n\t * @remarks\n\t * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.\n\t * In that case it is emitted on the _parent_ node, not the node itself.\n\t *\n\t * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties\n\t * of the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When it is emitted, the tree is guaranteed to be in-schema.\n\t */\n\ttreeChanged(): void;\n}\n\n/**\n * A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.\n *\n * @remarks\n * Base type which all nodes implement.\n *\n * This can be used as a type to indicate/document values which should be tree nodes.\n * Runtime use of this class object (for example when used with `instanceof` or extending it), is not currently supported.\n *\n * Instances of tree nodes must be created by opening an existing document, inserting values into the document,\n * or by using the constructors and create functions of {@link TreeNodeSchema} produced by {@link SchemaFactory}.\n * @privateRemarks\n * This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})\n * and some runtime enforcement of schema class policy (see the the validation in the constructor).\n * This class is however only `type` exported not value exported, preventing the class object from being used,\n * similar to how interfaces work.\n *\n * Not all node implementations include this in their prototype chain (some hide it with a proxy),\n * and thus cause the default/built in `instanceof` to return false despite our type checking and all other APIs treating them as TreeNodes.\n * This class provides a custom `Symbol.hasInstance` to fix `instanceof` for this class and all classes extending it.\n * For now the type-only export prevents use of `instanceof` on this class (but allows it in subclasses like schema classes).\n * @sealed @public\n */\nexport abstract class TreeNode implements WithType {\n\t/**\n\t * This is added to prevent TypeScript from implicitly allowing non-TreeNode types to be used as TreeNodes.\n\t * @remarks\n\t * This field forces TypeScript to use nominal instead of structural typing,\n\t * preventing compiler error messages and tools like \"add missing properties\"\n\t * from adding the [type] field as a solution when using a non-TreeNode object where a TreeNode is required.\n\t * Instead TreeNodes must be created through the appropriate APIs, see the documentation on {@link TreeNode} for details.\n\t *\n\t * @privateRemarks\n\t * This is a JavaScript private field, so is not accessible from outside this class.\n\t * This prevents it from having name collisions with object fields.\n\t * Since this is private, the type of this field is stripped in the d.ts file.\n\t * To get matching type checking within and from outside the package, the least informative type (`unknown`) is used.\n\t * To avoid this having any runtime impact, the field is uninitialized.\n\t *\n\t * Making this field optional results in different type checking within this project than outside of it, since the d.ts file drops the optional aspect of the field.\n\t * This is extra confusing since since the tests get in-project typing for intellisense and separate project checking at build time.\n\t * To avoid all this mess, this field is required, not optional.\n\t *\n\t * Another option would be to use a symbol (possibly as a private field).\n\t * That approach ran into some strange difficulties causing SchemaFactory to fail to compile, and was not investigated further.\n\t *\n\t * The [type] symbol provides a lot of the value this private brand does, but is not all of it:\n\t * someone could manually (or via Intellisense auto-implement completion, or in response to a type error)\n\t * make an object literal with the [type] field and pass it off as a node: this private brand prevents that.\n\t */\n\treadonly #brand!: unknown;\n\n\t/**\n\t * Adds a type symbol for stronger typing.\n\t * @privateRemarks\n\t * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.\n\t */\n\tpublic abstract get [typeNameSymbol](): string;\n\n\t/**\n\t * Provides `instanceof` support for testing if a value is a `TreeNode`.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Due to type-only export, this functionality is not available outside the package.\n\t */\n\tpublic static [Symbol.hasInstance](value: unknown): value is TreeNode;\n\n\t/**\n\t * Provides `instanceof` support for all schema classes with public constructors.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Despite type-only export, this functionality is available outside the package since it is inherited by subclasses.\n\t */\n\tpublic static [Symbol.hasInstance]<\n\t\tTSchema extends abstract new (\n\t\t\t...args: any[]\n\t\t) => TreeNode,\n\t>(this: TSchema, value: unknown): value is InstanceType<TSchema>;\n\n\tpublic static [Symbol.hasInstance](this: { prototype: object }, value: unknown): boolean {\n\t\tconst schema = tryGetSchema(value);\n\n\t\tif (schema === undefined || schema.kind === NodeKind.Leaf) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(\"prototype\" in schema, 0x98a /* expected class based schema */);\n\t\treturn inPrototypeChain(schema.prototype, this.prototype);\n\t}\n\n\tprotected constructor() {\n\t\tif (!inPrototypeChain(Reflect.getPrototypeOf(this), TreeNodeValid.prototype)) {\n\t\t\tthrow new UsageError(\"TreeNodes must extend schema classes created by SchemaFactory\");\n\t\t}\n\t}\n}\n\n/**\n * Check if the prototype derived's prototype chain contains `base`.\n * @param derived - prototype to check\n * @param base - prototype to search for\n * @returns true iff `base` is in the prototype chain starting at `derived`.\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function inPrototypeChain(derived: object | null, base: object): boolean {\n\tlet checking = derived;\n\twhile (checking !== null) {\n\t\tif (base === checking) {\n\t\t\treturn true;\n\t\t}\n\t\tchecking = Reflect.getPrototypeOf(checking);\n\t}\n\treturn false;\n}\n\n/**\n * Class which all {@link TreeNode}s must extend.\n * Since this is not exported, it allows robust detection of attempts to create TreeNodes which do not go through SchemaFactory which is the only place which exposes classes that extend this.\n *\n * This has static members which schema classes can override to provide schema specific functionality.\n * These static members are only intended to be used / overridden by code within this package, and are used by the various node kinds.\n * Access to these static members has to be done via `this.constructor.staticMember` to support the overrides, and thus can only be used in the constructor, after the base constructor has been invoked.\n */\nexport abstract class TreeNodeValid<TInput> extends TreeNode {\n\t/**\n\t * Schema classes can override this to control what happens at the end of the constructor.\n\t * The return value from this is returned from the constructor, allowing substituting a proxy if desired.\n\t *\n\t * This is not simply done in the derived constructor to enable:\n\t * - this class to access the value which is being returned before it's returned from the constructor.\n\t * - the derived class to be provided the input `FlexTreeNode` without relying on a field on the node to hold it.\n\t */\n\tprotected static prepareInstance<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: FlexTreeNode,\n\t): TreeNodeValid<T> {\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Schema classes must override to provide an implementation of RawTreeNode construction.\n\t */\n\tprotected static buildRawNode<T>(\n\t\tthis: typeof TreeNodeValid<T>,\n\t\tinstance: TreeNodeValid<T>,\n\t\tinput: T,\n\t): MapTreeNode {\n\t\treturn fail(\"Schema must override buildRawNode\");\n\t}\n\n\t/**\n\t * Schema classes can override to provide a callback that is called once when the first node is constructed.\n\t * This is a good place to perform extra validation and cache schema derived data needed for the implementation of the node.\n\t */\n\tprotected static oneTimeSetup<T>(this: typeof TreeNodeValid<T>): void {}\n\n\t/**\n\t * The most derived constructor (the one invoked with the `new` operator, not a parent class constructor invoked with as `super`) used to construct an instance of this type.\n\t * @remarks\n\t * Captured when an instance is constructed.\n\t *\n\t * Used to ensure that some derived class (which must override this member, defaulting it to `undefined`) is only instantiated with a single \"most derived\" class (the constructor actually invoked the the user with `new`).\n\t *\n\t * Typically this is override in the class that statically implements {@link TreeNodeSchema} to enforce that all nodes using that schema use the same class and not different subclasses of it.\n\t *\n\t * Also used to detect if oneTimeSetup has run.\n\t *\n\t * @privateRemarks\n\t * This defaults to \"default\", which is used to trigger an error if not overridden in the derived class.\n\t *\n\t * The value of this on TreeNodeValid must only be overridden by base classes and never modified.\n\t * Ways to enforce this immutability prevent it from being overridden,\n\t * so code modifying constructorCached should be extra careful to avoid accidentally modifying the base/inherited value.\n\t */\n\tprotected static constructorCached: MostDerivedData | \"default\" | undefined = \"default\";\n\n\t/**\n\t * Indicate that `this` is the most derived version of a schema, and thus the only one allowed to be used (other than by being subclassed a single time).\n\t */\n\tpublic static markMostDerived(this: typeof TreeNodeValid & TreeNodeSchema): MostDerivedData {\n\t\tassert(this.constructorCached !== \"default\", 0x95f /* invalid schema class */);\n\n\t\tif (this.constructorCached === undefined) {\n\t\t\t// Set the constructorCached on the layer of the prototype chain that declared it.\n\t\t\t// This is necessary to ensure there is only one subclass of that type used:\n\t\t\t// if constructorCached was simply set on `schema`,\n\t\t\t// then a base classes between `schema` (exclusive) and where `constructorCached` is set (inclusive) and other subclasses of them\n\t\t\t// would not see the stored `constructorCached`, and the validation above against multiple derived classes would not work.\n\n\t\t\t// This is not just an alias of `this`, but a reference to the item in the prototype chain being walked, which happens to start at `this`.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\n\t\t\tlet schemaBase: typeof TreeNodeValid = this;\n\t\t\twhile (!Object.prototype.hasOwnProperty.call(schemaBase, \"constructorCached\")) {\n\t\t\t\tschemaBase = Reflect.getPrototypeOf(schemaBase) as typeof TreeNodeValid;\n\t\t\t}\n\t\t\tassert(schemaBase.constructorCached === undefined, 0x962 /* overwriting wrong cache */);\n\t\t\tschemaBase.constructorCached = { constructor: this, oneTimeInitialized: false };\n\t\t\tassert(\n\t\t\t\tthis.constructorCached === schemaBase.constructorCached,\n\t\t\t\t0x9b5 /* Inheritance should work */,\n\t\t\t);\n\t\t\treturn this.constructorCached;\n\t\t} else if (this.constructorCached.constructor === this) {\n\t\t\treturn this.constructorCached;\n\t\t}\n\n\t\tthrow new UsageError(\n\t\t\t`Two schema classes were used (${this.name} and ${\n\t\t\t\tthis.constructorCached.constructor.name\n\t\t\t}) which derived from the same SchemaFactory generated class (${JSON.stringify(\n\t\t\t\tthis.identifier,\n\t\t\t)}). This is invalid.`,\n\t\t);\n\t}\n\n\tpublic constructor(input: TInput | InternalTreeNode) {\n\t\tsuper();\n\t\tconst schema = this.constructor as typeof TreeNodeValid & TreeNodeSchema;\n\t\tconst cache = schema.markMostDerived();\n\t\tif (!cache.oneTimeInitialized) {\n\t\t\tconst flexSchema = getFlexSchema(schema);\n\t\t\tassert(\n\t\t\t\ttryGetSimpleNodeSchema(flexSchema) === schema,\n\t\t\t\t0x961 /* Schema class not properly configured */,\n\t\t\t);\n\t\t\tschema.oneTimeSetup();\n\t\t\tcache.oneTimeInitialized = true;\n\t\t}\n\n\t\tif (isTreeNode(input)) {\n\t\t\t// TODO: update this once we have better support for deep-copying and move operations.\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing nodes may not be used as the constructor parameter for a new node. The existing node may be used directly instead of creating a new one, used as a child of the new node (if it has not yet been inserted into the tree). If the desired result is copying the provided node, it must be deep copied (since any child node would be parented under both the new and old nodes). Currently no API is provided to make deep copies, but it can be done manually with object spreads - for example `new Foo({...oldFoo})` will work if all fields of `oldFoo` are leaf nodes.\",\n\t\t\t);\n\t\t}\n\n\t\tconst node: FlexTreeNode = isFlexTreeNode(input)\n\t\t\t? input\n\t\t\t: schema.buildRawNode(this, input);\n\t\tassert(\n\t\t\ttryGetSimpleNodeSchema(node.schema) === schema,\n\t\t\t0x83b /* building node with wrong schema */,\n\t\t);\n\n\t\tconst result = schema.prepareInstance(this, node);\n\t\tcreateKernel(result);\n\t\tsetFlexNode(result, node);\n\t\treturn result;\n\t}\n}\n// Class objects are functions (callable), so we need a strong way to distinguish between `schema` and `() => schema` when used as a `LazyItem`.\nmarkEager(TreeNodeValid);\n\n/**\n * Data cached about the most derived type in a schema's class hierarchy.\n * @remarks\n * The most derived type is the only one allowed to be referenced by other schema or constructed as a node.\n * It has to be discovered lazily (when a node is constructed or when a {@link TreeViewConfiguration} is made),\n * since JavaScript provides no way to find derived classes, or inject static class initialization time logic into base classes.\n * Additionally since schema can reference other schema through lazy references which might be forward or recursive references,\n * this can not be evaluated for one schema when referenced by another schema.\n *\n * See {@link TreeNodeValid.constructorCached} and {@link TreeNodeValid.markMostDerived}.\n */\nexport interface MostDerivedData {\n\treadonly constructor: typeof TreeNodeValid & TreeNodeSchema;\n\toneTimeInitialized: boolean;\n}\n\n/**\n * A node type internal to `@fluidframework/tree`.\n * @remarks\n * This type is used in the construction of {@link TreeNode} as an implementation detail, but leaks into the public API due to how schema are implemented.\n * @privateRemarks\n * A {@link FlexTreeNode}. Includes {@link RawTreeNode}s.\n * @sealed @public\n */\nexport interface InternalTreeNode\n\textends ErasedType<\"@fluidframework/tree.InternalTreeNode\"> {}\n\nexport function toFlexTreeNode(node: InternalTreeNode): FlexTreeNode {\n\tassert(isFlexTreeNode(node), 0x963 /* Invalid InternalTreeNode */);\n\treturn node;\n}\n\n// #region NodeJS custom inspect for TreeNodes.\n\n/**\n * Used to customize \"inspect\" behavior in NodeJS.\n * See https://nodejs.org/api/util.html#utilinspectcustom for details.\n *\n * VS-Code's debugger also uses this to inspect objects,\n * see https://github.com/microsoft/vscode-js-debug/blob/64df2686c92bac402909dee5c3c389bbb7a81f6d/src/adapter/templates/getStringyProps.ts#L11 for details.\n */\nconst customInspectSymbol = Symbol.for(\"nodejs.util.inspect.custom\");\n\n/**\n * Node inspecting function for use with {@link customInspectSymbol}.\n */\nfunction inspectNodeFunction(\n\tthis: TreeNodeValid<unknown>,\n\tdepth: number,\n\toptions?: unknown,\n\tinspect?: unknown,\n): unknown {\n\t// TODO: replicated from tryGetSchema to avoid cycle.\n\t// This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.\n\tconst schema = tryGetSimpleNodeSchema(getFlexNode(this).schema) as TreeNodeSchemaClass;\n\tconst title = `${schema.name}: ${NodeKind[schema.kind]} Node (${schema.identifier})`;\n\n\tif (depth < 2) {\n\t\tconst short = shortContent(this);\n\t\tif (short !== undefined) {\n\t\t\treturn `${title} ${short}`;\n\t\t}\n\t\treturn title;\n\t}\n\tconst content = `${title} ${JSON.stringify(this)}`;\n\treturn content;\n}\n\n/**\n * If the node has no items, a short JSON string for it.\n */\nfunction shortContent(node: TreeNodeValid<unknown>): string | undefined {\n\tif (Object.values(node).length === 0) {\n\t\treturn JSON.stringify(node);\n\t}\n\treturn undefined;\n}\n\n/**\n * Add inherited non-enumerable symbol for NodeJS inspection to all nodes.\n *\n * See {@link customInspectSymbol}.\n */\nObject.defineProperty(TreeNodeValid.prototype, customInspectSymbol, {\n\tvalue: inspectNodeFunction,\n\tenumerable: false,\n});\n\n// #endregion\n\n// #region Browser custom debug format for TreeNodes\n\n// This section has side-effects, so including it in this file ensures its loaded whenever TreeNodes could exist.\n// Supported in at least Chrome and FireFox, more details at https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n// For this to work the browser's dev tools generally have to \"Enable custom formatters\".\n\n// This formatter is inspired by https://github.com/andrewdavey/immutable-devtools/blob/master/src/createFormatters.js which provides a similar formatter for the immutable.js library.\n\nconst globals = typeof window === \"undefined\" ? globalThis : window;\nconst formatters = ((\n\tglobals as { devtoolsFormatters?: DevtoolsFormatter.DevtoolsFormatter[] }\n).devtoolsFormatters ??= []);\n\nconst nodeFormatter: DevtoolsFormatter.DevtoolsFormatter = {\n\theader(object, config) {\n\t\tif (isTreeNode(object)) {\n\t\t\treturn [\"span\", `${inspectNodeFunction.call(object, 1)}`];\n\t\t}\n\t\treturn null;\n\t},\n\tbody(object, config): DevtoolsFormatter.Item {\n\t\tconst children: DevtoolsFormatter.Item[] = [];\n\t\tfor (const [key, value] of Object.entries(object as TreeNode)) {\n\t\t\tchildren.push([\"li\", [\"span\", `${key}: `], formattedReference(value)]);\n\t\t}\n\n\t\t// TODO:\n\t\t// for array nodes, this isn't great since (at least in FireFox) the list items show up with a prefixed number starting from 1.\n\t\t// This looks messy when followed by the array index.\n\t\t// Find a way to hide the list index.\n\t\t// { style: 'list-style-type: none` } did not seem to work.\n\n\t\treturn [\"ol\", ...children];\n\t},\n\thasBody(object, config) {\n\t\treturn shortContent(object as TreeNodeValid<undefined>) === undefined;\n\t},\n};\n\nfunction formattedReference(\n\tobject: unknown,\n\tconfig?: DevtoolsFormatter.ObjectConfig,\n): DevtoolsFormatter.Item {\n\tif (typeof object === \"undefined\") {\n\t\treturn [\"span\", \"undefined\"];\n\t} else if (object === \"null\") {\n\t\treturn [\"span\", \"null\"];\n\t}\n\n\treturn [\"object\", { object, config }];\n}\n\nformatters.push(nodeFormatter);\n\n// #endregion\n\n// These types are based on https://github.com/BenjaminAster/Better-TypeScript/blob/main/types/devtools-formatters.d.ts\n// however the original package causes multiple compile errors due to some of its other types it used, so the relevant part has been extracted and adjusted to better match our conventions.\ndeclare namespace DevtoolsFormatter {\n\ttype ObjectConfig = Record<string | symbol, unknown>;\n\n\ttype ElementTagName = \"div\" | \"span\" | \"ol\" | \"li\" | \"table\" | \"tr\" | \"td\";\n\n\ttype ElementTemplate = StyledElementTemplate | UnstyledElementTemplate;\n\n\ttype StyledElementTemplate = readonly [\n\t\tElementTagName,\n\t\t{\n\t\t\tstyle?: string;\n\t\t},\n\t\t...Item[],\n\t];\n\n\ttype UnstyledElementTemplate = readonly [ElementTagName, ...Item[]];\n\n\ttype ObjectReference = readonly [\n\t\t\"object\",\n\t\t{\n\t\t\tobject: unknown;\n\t\t\tconfig?: ObjectConfig;\n\t\t},\n\t];\n\n\ttype Item = string | ElementTemplate | ObjectReference;\n\n\tinterface DevtoolsFormatter {\n\t\theader(\n\t\t\tobject?: unknown,\n\t\t\tconfig?: ObjectConfig,\n\t\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\t): Item | null;\n\t\thasBody(object?: unknown, config?: ObjectConfig): boolean;\n\t\tbody(object?: unknown, config?: ObjectConfig): Item;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* An object which can enter a "broken" state where trying to use it is a UsageError.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Breakable {
|
|
9
|
+
private readonly name;
|
|
10
|
+
private brokenBy?;
|
|
11
|
+
constructor(name: string);
|
|
12
|
+
/**
|
|
13
|
+
* Throws if the object is in the broken state.
|
|
14
|
+
* @remarks
|
|
15
|
+
* Can use {@link throwIfBroken} to apply this to a method.
|
|
16
|
+
*/
|
|
17
|
+
use(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Puts this object into the broken state, and throws an error.
|
|
20
|
+
*
|
|
21
|
+
* @throws If already broken by a different error, throws a UsageError, otherwise throws `brokenBy`.
|
|
22
|
+
*/
|
|
23
|
+
break(brokenBy: Error): never;
|
|
24
|
+
/**
|
|
25
|
+
* {@link Breakable.break}, except tolerates `unknown` to be more easily used by catch blocks.
|
|
26
|
+
* @privateRemarks
|
|
27
|
+
* If there is a use-case, this should be made public.
|
|
28
|
+
*/
|
|
29
|
+
private rethrowCaught;
|
|
30
|
+
/**
|
|
31
|
+
* Runs code which should break the object if it throws.
|
|
32
|
+
* @remarks
|
|
33
|
+
* This also throws if already broken like {@link Breakable.use}.
|
|
34
|
+
* Any exceptions this catches are re-thrown.
|
|
35
|
+
* Can use {@link breakingMethod} to apply this to a method.
|
|
36
|
+
*/
|
|
37
|
+
run<TResult>(breaker: () => TResult): TResult;
|
|
38
|
+
/**
|
|
39
|
+
* Clears the existing broken state.
|
|
40
|
+
* @remarks
|
|
41
|
+
* This is rarely safe to to: it is only ok when all objects using this breaker are known to not have been left in an invalid state.
|
|
42
|
+
* This is pretty much only safe in tests which just were checking a specific error was thrown, and which know that error closepath is actually exception safe.
|
|
43
|
+
*/
|
|
44
|
+
clearError(): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Marks an object as being able to be in a broken state (unknown/unspecified/broken state due to unhandled exception).
|
|
48
|
+
* @remarks
|
|
49
|
+
* See decorators {@link breakingMethod} and {@link throwIfBroken} for ease of use.
|
|
50
|
+
*/
|
|
51
|
+
export interface WithBreakable {
|
|
52
|
+
readonly breaker: Breakable;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Decorator for methods which should break the object when they throw.
|
|
56
|
+
* @remarks
|
|
57
|
+
* This also throws if already broken like {@link throwIfBroken}.
|
|
58
|
+
* See {@link Breakable.run} for details.
|
|
59
|
+
*
|
|
60
|
+
* This should be used on methods which modify data that could result in an unsupported/broken state if an exception is thrown while modifying.
|
|
61
|
+
* It is ok for breakingMethods to call each-other.
|
|
62
|
+
* @privateRemarks
|
|
63
|
+
* Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.
|
|
64
|
+
*/
|
|
65
|
+
export declare function breakingMethod<Target extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return), This extends WithBreakable, Args extends never[], Return>(target: Target, context?: ClassMethodDecoratorContext<This, Target>): Target;
|
|
66
|
+
/**
|
|
67
|
+
* Decorator for methods which should throw if the object is in a broken state.
|
|
68
|
+
* @remarks
|
|
69
|
+
* This should be used on methods which read data that could be invalid when the object is broken.
|
|
70
|
+
* @privateRemarks
|
|
71
|
+
* Explicitly capturing the full `Target` type is necessary to make this work with generic methods with unknown numbers of type parameters.
|
|
72
|
+
*/
|
|
73
|
+
export declare function throwIfBroken<Target extends ((...args: any[]) => unknown) & ((this: This, ...args: Args) => Return), This extends WithBreakable, Args extends never[], Return>(target: Target, context: ClassMethodDecoratorContext<This, Target>): Target;
|
|
74
|
+
/**
|
|
75
|
+
* Decorator for classes which should break when their methods throw.
|
|
76
|
+
* @remarks
|
|
77
|
+
* Applies {@link breakingMethod} to all methods declared directly by class or its base classes.
|
|
78
|
+
* Does not include those on derived classes.
|
|
79
|
+
* Does not include getters or setters, or value properties.
|
|
80
|
+
* Methods already marked as {@link breakingMethod} or {@link throwIfBroken} are unaffected.
|
|
81
|
+
*/
|
|
82
|
+
export declare function breakingClass<Target extends abstract new (...args: any[]) => WithBreakable>(target: Target, context: ClassDecoratorContext<Target>): Target;
|
|
83
|
+
//# sourceMappingURL=breakable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakable.d.ts","sourceRoot":"","sources":["../../src/util/breakable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,qBAAa,SAAS;IAGF,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFxC,OAAO,CAAC,QAAQ,CAAC,CAAQ;gBAEW,IAAI,EAAE,MAAM;IAEhD;;;;OAIG;IACI,GAAG,IAAI,IAAI;IAQlB;;;;OAIG;IACI,KAAK,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK;IAUpC;;;;OAIG;IACH,OAAO,CAAC,aAAa;IASrB;;;;;;OAMG;IACI,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,OAAO;IASpD;;;;;OAKG;IACI,UAAU,IAAI,IAAI;CAIzB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC7B,MAAM,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,EACtF,IAAI,SAAS,aAAa,EAC1B,IAAI,SAAS,KAAK,EAAE,EACpB,MAAM,EACL,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,2BAA2B,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,CAe7E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,MAAM,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IA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