@fluidframework/tree 2.12.0 → 2.20.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/CHANGELOG.md +154 -0
- package/api-report/tree.alpha.api.md +108 -22
- package/api-report/tree.beta.api.md +31 -15
- package/api-report/tree.legacy.alpha.api.md +31 -15
- package/api-report/tree.legacy.public.api.md +31 -15
- package/api-report/tree.public.api.md +31 -15
- package/assertTagging.config.mjs +14 -0
- package/dist/alpha.d.ts +14 -0
- package/dist/beta.d.ts +2 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +5 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +5 -4
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +29 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +10 -0
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +22 -1
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/tree/delta.d.ts +21 -26
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/deltaUtil.d.ts +1 -3
- package/dist/core/tree/deltaUtil.d.ts.map +1 -1
- package/dist/core/tree/deltaUtil.js +2 -14
- package/dist/core/tree/deltaUtil.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +1 -3
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js +82 -80
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
- 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.map +1 -1
- package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
- package/dist/feature-libraries/deltaUtils.js +13 -0
- package/dist/feature-libraries/deltaUtils.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 -6
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +0 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +2 -4
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +5 -5
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js +2 -3
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +30 -6
- 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 +2 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +8 -8
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -4
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +186 -216
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +23 -20
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js +20 -0
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts +3 -3
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +24 -4
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +4 -4
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -3
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +50 -9
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +4 -1
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +27 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +2 -0
- package/dist/package.json +2 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/shared-tree/index.d.ts +3 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +6 -3
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +10 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +43 -0
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +44 -21
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +41 -35
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/transactionTypes.d.ts +105 -0
- package/dist/shared-tree/transactionTypes.d.ts.map +1 -0
- package/dist/shared-tree/transactionTypes.js +13 -0
- package/dist/shared-tree/transactionTypes.js.map +1 -0
- package/dist/shared-tree/treeApi.d.ts +1 -25
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js +4 -8
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +4 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +142 -23
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -0
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/jsonSchema.d.ts +6 -0
- package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/jsonSchema.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +21 -12
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +5 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js +90 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
- package/dist/simple-tree/api/simpleSchema.d.ts +5 -1
- package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +13 -10
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/dist/simple-tree/api/tree.d.ts +60 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -11
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +2 -2
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +3 -2
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +10 -6
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +5 -5
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +2 -2
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +2 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +2 -2
- 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/objectNodeTypes.d.ts +2 -2
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +47 -1
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toMapTree.js +1 -1
- package/dist/simple-tree/toMapTree.js.map +1 -1
- package/dist/util/bTreeUtils.d.ts +10 -0
- package/dist/util/bTreeUtils.d.ts.map +1 -0
- package/dist/util/bTreeUtils.js +52 -0
- package/dist/util/bTreeUtils.js.map +1 -0
- package/dist/util/idAllocator.d.ts +0 -2
- package/dist/util/idAllocator.d.ts.map +1 -1
- package/dist/util/idAllocator.js +0 -2
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/index.d.ts +3 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +7 -5
- package/dist/util/index.js.map +1 -1
- package/dist/util/rangeMap.d.ts +95 -43
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +202 -148
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/utils.d.ts +26 -2
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +17 -2
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +14 -0
- package/lib/beta.d.ts +2 -0
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +2 -2
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +2 -2
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +5 -4
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +26 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts +10 -0
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +20 -0
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/tree/delta.d.ts +21 -26
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/deltaUtil.d.ts +1 -3
- package/lib/core/tree/deltaUtil.d.ts.map +1 -1
- package/lib/core/tree/deltaUtil.js +1 -12
- package/lib/core/tree/deltaUtil.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js +82 -80
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
- 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.map +1 -1
- package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
- package/lib/feature-libraries/deltaUtils.js +13 -0
- package/lib/feature-libraries/deltaUtils.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 -6
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +0 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +0 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +5 -5
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js +2 -3
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +30 -6
- 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 +2 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -4
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +158 -186
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +23 -20
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js +18 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts +3 -3
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +24 -4
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +4 -4
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +2 -3
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +50 -9
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +4 -1
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +27 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +2 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +2 -0
- package/lib/shared-tree/index.d.ts +3 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +3 -2
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +10 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +46 -3
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +44 -21
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +40 -34
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/transactionTypes.d.ts +105 -0
- package/lib/shared-tree/transactionTypes.d.ts.map +1 -0
- package/lib/shared-tree/transactionTypes.js +10 -0
- package/lib/shared-tree/transactionTypes.js.map +1 -0
- package/lib/shared-tree/treeApi.d.ts +1 -25
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js +1 -5
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +4 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +143 -24
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -0
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/jsonSchema.d.ts +6 -0
- package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/jsonSchema.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +21 -12
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +5 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js +86 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
- package/lib/simple-tree/api/simpleSchema.d.ts +5 -1
- package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +14 -11
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
- package/lib/simple-tree/api/tree.d.ts +60 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +1 -1
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +12 -12
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +2 -2
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +3 -2
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +10 -6
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- 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 +5 -5
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +2 -2
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +2 -1
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +2 -2
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +2 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +2 -2
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +47 -1
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toMapTree.js +1 -1
- package/lib/simple-tree/toMapTree.js.map +1 -1
- package/lib/util/bTreeUtils.d.ts +10 -0
- package/lib/util/bTreeUtils.d.ts.map +1 -0
- package/lib/util/bTreeUtils.js +47 -0
- package/lib/util/bTreeUtils.js.map +1 -0
- package/lib/util/idAllocator.d.ts +0 -2
- package/lib/util/idAllocator.d.ts.map +1 -1
- package/lib/util/idAllocator.js +0 -2
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/index.d.ts +3 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +3 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/rangeMap.d.ts +95 -43
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +200 -144
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/utils.d.ts +26 -2
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +15 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +24 -24
- package/src/core/index.ts +5 -2
- package/src/core/rebase/index.ts +5 -0
- package/src/core/rebase/types.ts +33 -5
- package/src/core/rebase/utils.ts +27 -0
- package/src/core/tree/delta.ts +21 -26
- package/src/core/tree/deltaUtil.ts +1 -16
- package/src/core/tree/index.ts +0 -2
- package/src/core/tree/visitDelta.ts +108 -97
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +14 -1
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +2 -2
- package/src/feature-libraries/deltaUtils.ts +13 -0
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -6
- package/src/feature-libraries/index.ts +0 -1
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +12 -13
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +33 -9
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +6 -4
- package/src/feature-libraries/modular-schema/index.ts +3 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +12 -11
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +254 -248
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +51 -26
- package/src/feature-libraries/optional-field/optionalField.ts +37 -8
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +1 -1
- package/src/feature-libraries/sequence-field/rebase.ts +9 -3
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +1 -1
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +1 -1
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +3 -4
- package/src/feature-libraries/sequence-field/utils.ts +54 -11
- package/src/feature-libraries/treeCursorUtils.ts +6 -1
- package/src/index.ts +45 -6
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +16 -3
- package/src/shared-tree/schematizingTreeView.ts +91 -2
- package/src/shared-tree/sharedTree.ts +69 -44
- package/src/shared-tree/transactionTypes.ts +125 -0
- package/src/shared-tree/treeApi.ts +1 -28
- package/src/shared-tree/treeCheckout.ts +166 -25
- package/src/shared-tree-core/sharedTreeCore.ts +1 -1
- package/src/simple-tree/api/index.ts +1 -0
- package/src/simple-tree/api/jsonSchema.ts +7 -0
- package/src/simple-tree/api/schemaFactory.ts +33 -6
- package/src/simple-tree/api/schemaFactoryAlpha.ts +253 -0
- package/src/simple-tree/api/simpleSchema.ts +6 -1
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +22 -12
- package/src/simple-tree/api/tree.ts +76 -4
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +19 -13
- package/src/simple-tree/arrayNode.ts +8 -2
- package/src/simple-tree/core/treeNodeSchema.ts +51 -7
- package/src/simple-tree/index.ts +3 -0
- package/src/simple-tree/mapNode.ts +7 -1
- package/src/simple-tree/objectNode.ts +7 -1
- package/src/simple-tree/objectNodeTypes.ts +4 -1
- package/src/simple-tree/schemaTypes.ts +50 -1
- package/src/simple-tree/toMapTree.ts +1 -1
- package/src/util/bTreeUtils.ts +60 -0
- package/src/util/idAllocator.ts +0 -2
- package/src/util/index.ts +5 -6
- package/src/util/rangeMap.ts +259 -184
- package/src/util/utils.ts +57 -4
- package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
- package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
- package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -74
- package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
- package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
- package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
- package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -71
- package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
- package/lib/package.json +0 -3
- package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -112
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert
|
|
7
|
-
import type { IFluidHandle } from "@fluidframework/core-interfaces/internal";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import type { ErasedType, IFluidHandle } from "@fluidframework/core-interfaces/internal";
|
|
8
8
|
import type {
|
|
9
9
|
IChannelAttributes,
|
|
10
10
|
IChannelFactory,
|
|
@@ -186,30 +186,6 @@ function getCodecVersions(formatVersion: number): ExplicitCodecVersions {
|
|
|
186
186
|
return versions;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
/**
|
|
190
|
-
* Build and return a forest of the requested type.
|
|
191
|
-
*/
|
|
192
|
-
export function buildConfiguredForest(
|
|
193
|
-
type: ForestType,
|
|
194
|
-
schema: TreeStoredSchemaSubscription,
|
|
195
|
-
idCompressor: IIdCompressor,
|
|
196
|
-
): IEditableForest {
|
|
197
|
-
switch (type) {
|
|
198
|
-
case ForestType.Optimized:
|
|
199
|
-
return buildChunkedForest(
|
|
200
|
-
makeTreeChunker(schema, defaultSchemaPolicy),
|
|
201
|
-
undefined,
|
|
202
|
-
idCompressor,
|
|
203
|
-
);
|
|
204
|
-
case ForestType.Reference:
|
|
205
|
-
return buildForest();
|
|
206
|
-
case ForestType.Expensive:
|
|
207
|
-
return buildForest(undefined, true);
|
|
208
|
-
default:
|
|
209
|
-
unreachableCase(type);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
189
|
/**
|
|
214
190
|
* Shared tree, configured with a good set of indexes and field kinds which will maintain compatibility over time.
|
|
215
191
|
*
|
|
@@ -229,7 +205,7 @@ export class SharedTree
|
|
|
229
205
|
id: string,
|
|
230
206
|
runtime: IFluidDataStoreRuntime,
|
|
231
207
|
attributes: IChannelAttributes,
|
|
232
|
-
optionsParam:
|
|
208
|
+
optionsParam: SharedTreeOptionsInternal,
|
|
233
209
|
telemetryContextPrefix: string = "fluid_sharedTree_",
|
|
234
210
|
) {
|
|
235
211
|
if (runtime.idCompressor === undefined) {
|
|
@@ -333,6 +309,7 @@ export class SharedTree
|
|
|
333
309
|
chunkCompressionStrategy: options.treeEncodeType,
|
|
334
310
|
logger: this.logger,
|
|
335
311
|
breaker: this.breaker,
|
|
312
|
+
disposeForksAfterTransaction: options.disposeForksAfterTransaction,
|
|
336
313
|
},
|
|
337
314
|
);
|
|
338
315
|
|
|
@@ -459,7 +436,7 @@ export class SharedTree
|
|
|
459
436
|
): void {
|
|
460
437
|
assert(
|
|
461
438
|
!this.checkout.transaction.isInProgress(),
|
|
462
|
-
|
|
439
|
+
0xaa6 /* Cannot submit a commit while a transaction is in progress */,
|
|
463
440
|
);
|
|
464
441
|
if (isResubmit) {
|
|
465
442
|
return super.submitCommit(commit, schemaAndPolicy, isResubmit);
|
|
@@ -555,6 +532,9 @@ export type SharedTreeOptions = Partial<ICodecOptions> &
|
|
|
555
532
|
Partial<SharedTreeFormatOptions> &
|
|
556
533
|
ForestOptions;
|
|
557
534
|
|
|
535
|
+
export interface SharedTreeOptionsInternal extends SharedTreeOptions {
|
|
536
|
+
disposeForksAfterTransaction?: boolean;
|
|
537
|
+
}
|
|
558
538
|
/**
|
|
559
539
|
* Configuration options for SharedTree's internal tree storage.
|
|
560
540
|
* @alpha
|
|
@@ -592,28 +572,73 @@ export interface SharedTreeFormatOptions {
|
|
|
592
572
|
|
|
593
573
|
/**
|
|
594
574
|
* Used to distinguish between different forest types.
|
|
575
|
+
* @remarks
|
|
576
|
+
* Current options are {@link ForestTypeReference}, {@link ForestTypeOptimized} and {@link ForestTypeExpensiveDebug}.
|
|
577
|
+
* @sealed @alpha
|
|
578
|
+
*/
|
|
579
|
+
export interface ForestType extends ErasedType<"ForestType"> {}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Reference implementation of forest.
|
|
583
|
+
* @remarks
|
|
584
|
+
* A simple implementation with minimal complexity and moderate debuggability, validation and performance.
|
|
585
|
+
* @privateRemarks
|
|
586
|
+
* The "ObjectForest" forest type.
|
|
595
587
|
* @alpha
|
|
596
588
|
*/
|
|
597
|
-
export
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
589
|
+
export const ForestTypeReference = toForestType(() => buildForest());
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Optimized implementation of forest.
|
|
593
|
+
* @remarks
|
|
594
|
+
* A complex optimized forest implementation, which has minimal validation and debuggability to optimize for performance.
|
|
595
|
+
* Uses an internal representation optimized for size designed to scale to larger datasets with reduced overhead.
|
|
596
|
+
* @privateRemarks
|
|
597
|
+
* The "ChunkedForest" forest type.
|
|
598
|
+
* @alpha
|
|
599
|
+
*/
|
|
600
|
+
export const ForestTypeOptimized = toForestType(
|
|
601
|
+
(schema: TreeStoredSchemaSubscription, idCompressor: IIdCompressor) =>
|
|
602
|
+
buildChunkedForest(makeTreeChunker(schema, defaultSchemaPolicy), undefined, idCompressor),
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Slow implementation of forest intended only for debugging.
|
|
607
|
+
* @remarks
|
|
608
|
+
* Includes validation with scales poorly.
|
|
609
|
+
* May be asymptotically slower than {@link ForestTypeReference}, and may perform very badly with larger data sizes.
|
|
610
|
+
* @privateRemarks
|
|
611
|
+
* The "ObjectForest" forest type with expensive asserts for debugging.
|
|
612
|
+
* @alpha
|
|
613
|
+
*/
|
|
614
|
+
export const ForestTypeExpensiveDebug = toForestType(() => buildForest(undefined, true));
|
|
615
|
+
|
|
616
|
+
type ForestFactory = (
|
|
617
|
+
schema: TreeStoredSchemaSubscription,
|
|
618
|
+
idCompressor: IIdCompressor,
|
|
619
|
+
) => IEditableForest;
|
|
620
|
+
|
|
621
|
+
function toForestType(factory: ForestFactory): ForestType {
|
|
622
|
+
return factory as unknown as ForestType;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Build and return a forest of the requested type.
|
|
627
|
+
*/
|
|
628
|
+
export function buildConfiguredForest(
|
|
629
|
+
factory: ForestType,
|
|
630
|
+
schema: TreeStoredSchemaSubscription,
|
|
631
|
+
idCompressor: IIdCompressor,
|
|
632
|
+
): IEditableForest {
|
|
633
|
+
return (factory as unknown as ForestFactory)(schema, idCompressor);
|
|
610
634
|
}
|
|
611
635
|
|
|
612
|
-
export const defaultSharedTreeOptions: Required<
|
|
636
|
+
export const defaultSharedTreeOptions: Required<SharedTreeOptionsInternal> = {
|
|
613
637
|
jsonValidator: noopValidator,
|
|
614
|
-
forest:
|
|
638
|
+
forest: ForestTypeReference,
|
|
615
639
|
treeEncodeType: TreeCompressionStrategy.Compressed,
|
|
616
640
|
formatVersion: SharedTreeFormatVersion.v3,
|
|
641
|
+
disposeForksAfterTransaction: true,
|
|
617
642
|
};
|
|
618
643
|
|
|
619
644
|
/**
|
|
@@ -628,7 +653,7 @@ export class SharedTreeFactory implements IChannelFactory<ISharedTree> {
|
|
|
628
653
|
packageVersion: "0.0.0",
|
|
629
654
|
};
|
|
630
655
|
|
|
631
|
-
public constructor(private readonly options:
|
|
656
|
+
public constructor(private readonly options: SharedTreeOptionsInternal = {}) {}
|
|
632
657
|
|
|
633
658
|
public async load(
|
|
634
659
|
runtime: IFluidDataStoreRuntime,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { TreeNode } from "../simple-tree/index.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const rollback = Symbol("SharedTree Transaction Rollback");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A requirement for a SharedTree transaction to succeed.
|
|
16
|
+
* @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.
|
|
17
|
+
* In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.
|
|
18
|
+
* However, they cannot know what the tree state will be when the transaction is _sequenced_.
|
|
19
|
+
* There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.
|
|
20
|
+
* Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.
|
|
21
|
+
* All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.
|
|
28
|
+
* @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as "existing".
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export interface NodeInDocumentConstraint {
|
|
32
|
+
readonly type: "nodeInDocument";
|
|
33
|
+
readonly node: TreeNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.
|
|
38
|
+
* @alpha
|
|
39
|
+
*/
|
|
40
|
+
export type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (
|
|
41
|
+
| {
|
|
42
|
+
/** Indicates that the transaction callback ran successfully. */
|
|
43
|
+
rollback?: false;
|
|
44
|
+
/** The user defined value when the transaction ran successfully. */
|
|
45
|
+
value: TSuccessValue;
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
/** Indicates that the transaction callback failed and the transaction should be rolled back. */
|
|
49
|
+
rollback: true;
|
|
50
|
+
/** The user defined value when the transaction failed. */
|
|
51
|
+
value: TFailureValue;
|
|
52
|
+
}
|
|
53
|
+
) & {
|
|
54
|
+
/**
|
|
55
|
+
* An optional list of {@link TransactionConstraint | constraints} that will be checked when the commit corresponding
|
|
56
|
+
* to this transaction is reverted. If any of these constraints are not met when the revert is being applied either
|
|
57
|
+
* locally or on remote clients, the revert will be ignored.
|
|
58
|
+
* These constraints must also be met at the time they are first introduced. If they are not met after the transaction
|
|
59
|
+
* callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.
|
|
60
|
+
*/
|
|
61
|
+
preconditionsOnRevert?: readonly TransactionConstraint[];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't
|
|
66
|
+
* need to return a value. This is the same as {@link TransactionCallbackStatus} but with the `value` field omitted. This
|
|
67
|
+
* @alpha
|
|
68
|
+
*/
|
|
69
|
+
export type VoidTransactionCallbackStatus = Omit<
|
|
70
|
+
TransactionCallbackStatus<unknown, unknown>,
|
|
71
|
+
"value"
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The result of the {@link RunTransaction | RunTransaction} API when it was successful.
|
|
76
|
+
* @alpha
|
|
77
|
+
*/
|
|
78
|
+
export interface TransactionResultSuccess<TSuccessValue> {
|
|
79
|
+
/** Indicates that the transaction was successful. */
|
|
80
|
+
success: true;
|
|
81
|
+
/** The user defined value when the transaction was successful. */
|
|
82
|
+
value: TSuccessValue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The result of the {@link RunTransaction | RunTransaction} API when it failed.
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
export interface TransactionResultFailed<TFailureValue> {
|
|
90
|
+
/** Indicates that the transaction failed. */
|
|
91
|
+
success: false;
|
|
92
|
+
/** The user defined value when the transaction failed. */
|
|
93
|
+
value: TFailureValue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The result of the {@link RunTransaction | RunTransaction} API.
|
|
98
|
+
* @alpha
|
|
99
|
+
*/
|
|
100
|
+
export type TransactionResultExt<TSuccessValue, TFailureValue> =
|
|
101
|
+
| TransactionResultSuccess<TSuccessValue>
|
|
102
|
+
| TransactionResultFailed<TFailureValue>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionResultExt}
|
|
106
|
+
* but with the `value` field omitted. This is useful when the transaction callback doesn't need to return a value.
|
|
107
|
+
* @alpha
|
|
108
|
+
*/
|
|
109
|
+
export type TransactionResult =
|
|
110
|
+
| Omit<TransactionResultSuccess<unknown>, "value">
|
|
111
|
+
| Omit<TransactionResultFailed<unknown>, "value">;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The parameters for the {@link RunTransaction | RunTransaction} API.
|
|
115
|
+
* @alpha
|
|
116
|
+
*/
|
|
117
|
+
export interface RunTransactionParams {
|
|
118
|
+
/**
|
|
119
|
+
* An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.
|
|
120
|
+
* If any of the constraints are not met when `runTransaction` is called, an error will be thrown.
|
|
121
|
+
* If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on
|
|
122
|
+
* this client and ignored by all other clients.
|
|
123
|
+
*/
|
|
124
|
+
readonly preconditions?: readonly TransactionConstraint[];
|
|
125
|
+
}
|
|
@@ -19,12 +19,7 @@ import {
|
|
|
19
19
|
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
20
20
|
import type { ITreeCheckout } from "./treeCheckout.js";
|
|
21
21
|
import { getCheckoutFlexTreeView } from "./checkoutFlexTreeView.js";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export const rollback = Symbol("SharedTree Transaction Rollback");
|
|
22
|
+
import { rollback, type TransactionConstraint } from "./transactionTypes.js";
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
25
|
* A function which runs a transaction in a SharedTree.
|
|
@@ -380,28 +375,6 @@ export const treeApi: TreeApi = {
|
|
|
380
375
|
},
|
|
381
376
|
};
|
|
382
377
|
|
|
383
|
-
/**
|
|
384
|
-
* A requirement for a SharedTree transaction to succeed.
|
|
385
|
-
* @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.
|
|
386
|
-
* In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.
|
|
387
|
-
* However, they cannot know what the tree state will be when the transaction is _sequenced_.
|
|
388
|
-
* There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.
|
|
389
|
-
* Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.
|
|
390
|
-
* All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.
|
|
391
|
-
* @public
|
|
392
|
-
*/
|
|
393
|
-
export type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.
|
|
397
|
-
* @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as "existing".
|
|
398
|
-
* @public
|
|
399
|
-
*/
|
|
400
|
-
export interface NodeInDocumentConstraint {
|
|
401
|
-
readonly type: "nodeInDocument";
|
|
402
|
-
readonly node: TreeNode;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
378
|
// TODO: Add more constraint types here
|
|
406
379
|
|
|
407
380
|
/** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
type RevertibleAlphaFactory,
|
|
42
42
|
type RevertibleAlpha,
|
|
43
43
|
type GraphCommit,
|
|
44
|
+
isAncestor,
|
|
44
45
|
} from "../core/index.js";
|
|
45
46
|
import {
|
|
46
47
|
type FieldBatchCodec,
|
|
@@ -73,6 +74,7 @@ import type {
|
|
|
73
74
|
UnsafeUnknownSchema,
|
|
74
75
|
ViewableTree,
|
|
75
76
|
TreeBranch,
|
|
77
|
+
TreeChangeEvents,
|
|
76
78
|
} from "../simple-tree/index.js";
|
|
77
79
|
import { getCheckout, SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
78
80
|
|
|
@@ -271,6 +273,7 @@ export function createTreeCheckout(
|
|
|
271
273
|
chunkCompressionStrategy?: TreeCompressionStrategy;
|
|
272
274
|
logger?: ITelemetryLoggerExt;
|
|
273
275
|
breaker?: Breakable;
|
|
276
|
+
disposeForksAfterTransaction?: boolean;
|
|
274
277
|
},
|
|
275
278
|
): TreeCheckout {
|
|
276
279
|
const forest = args?.forest ?? buildForest();
|
|
@@ -310,6 +313,7 @@ export function createTreeCheckout(
|
|
|
310
313
|
args?.removedRoots,
|
|
311
314
|
args?.logger,
|
|
312
315
|
args?.breaker,
|
|
316
|
+
args?.disposeForksAfterTransaction,
|
|
313
317
|
);
|
|
314
318
|
}
|
|
315
319
|
|
|
@@ -342,6 +346,8 @@ export interface RevertMetrics {
|
|
|
342
346
|
export class TreeCheckout implements ITreeCheckoutFork {
|
|
343
347
|
public disposed = false;
|
|
344
348
|
|
|
349
|
+
private readonly editLock: EditLock;
|
|
350
|
+
|
|
345
351
|
private readonly views = new Set<TreeView<ImplicitFieldSchema>>();
|
|
346
352
|
|
|
347
353
|
/**
|
|
@@ -386,6 +392,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
386
392
|
/** Optional logger for telemetry. */
|
|
387
393
|
private readonly logger?: ITelemetryLoggerExt,
|
|
388
394
|
private readonly breaker: Breakable = new Breakable("TreeCheckout"),
|
|
395
|
+
private readonly disposeForksAfterTransaction = true,
|
|
389
396
|
) {
|
|
390
397
|
this.#transaction = new SquashingTransactionStack(
|
|
391
398
|
branch,
|
|
@@ -400,14 +407,9 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
400
407
|
return tagChange(change, revision);
|
|
401
408
|
},
|
|
402
409
|
() => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
const onDisposeUnSubscribes: (() => void)[] = [];
|
|
407
|
-
const onForkUnSubscribe = onForkTransitive(this, (fork) => {
|
|
408
|
-
forks.add(fork);
|
|
409
|
-
onDisposeUnSubscribes.push(fork.events.on("dispose", () => forks.delete(fork)));
|
|
410
|
-
});
|
|
410
|
+
const disposeForks = this.disposeForksAfterTransaction
|
|
411
|
+
? trackForksForDisposal(this)
|
|
412
|
+
: undefined;
|
|
411
413
|
// When each transaction is started, take a snapshot of the current state of removed roots
|
|
412
414
|
const removedRootsSnapshot = this.removedRoots.clone();
|
|
413
415
|
return (result) => {
|
|
@@ -424,14 +426,13 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
424
426
|
default:
|
|
425
427
|
unreachableCase(result);
|
|
426
428
|
}
|
|
427
|
-
|
|
428
|
-
forks.forEach((fork) => fork.dispose());
|
|
429
|
-
onDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());
|
|
430
|
-
onForkUnSubscribe();
|
|
429
|
+
disposeForks?.();
|
|
431
430
|
};
|
|
432
431
|
},
|
|
433
432
|
);
|
|
434
433
|
|
|
434
|
+
this.editLock = new EditLock(this.#transaction.activeBranchEditor);
|
|
435
|
+
|
|
435
436
|
branch.events.on("afterChange", (event) => {
|
|
436
437
|
// The following logic allows revertibles to be generated for the change.
|
|
437
438
|
// Currently only appends (including merges and transaction commits) are supported.
|
|
@@ -484,6 +485,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
484
485
|
}
|
|
485
486
|
|
|
486
487
|
private readonly onAfterChange = (event: SharedTreeBranchChange<SharedTreeChange>): void => {
|
|
488
|
+
this.editLock.lock();
|
|
487
489
|
this.#events.emit("beforeBatch", event);
|
|
488
490
|
if (event.change !== undefined) {
|
|
489
491
|
const revision =
|
|
@@ -521,6 +523,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
521
523
|
}
|
|
522
524
|
}
|
|
523
525
|
this.#events.emit("afterBatch");
|
|
526
|
+
this.editLock.unlock();
|
|
524
527
|
if (event.type === "append") {
|
|
525
528
|
event.newCommits.forEach((commit) => this.validateCommit(commit));
|
|
526
529
|
}
|
|
@@ -603,21 +606,27 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
603
606
|
revertible.dispose();
|
|
604
607
|
}
|
|
605
608
|
},
|
|
606
|
-
clone: (
|
|
607
|
-
if (forkedBranch === undefined) {
|
|
608
|
-
return this.createRevertible(revision, kind, checkout, onRevertibleDisposed);
|
|
609
|
-
}
|
|
610
|
-
|
|
609
|
+
clone: (targetBranch: TreeBranch) => {
|
|
611
610
|
// TODO:#23442: When a revertible is cloned for a forked branch, optimize to create a fork of a revertible branch once per revision NOT once per revision per checkout.
|
|
612
|
-
const
|
|
611
|
+
const targetCheckout = getCheckout(targetBranch);
|
|
612
|
+
|
|
613
613
|
const revertibleBranch = this.revertibleCommitBranches.get(revision);
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
614
|
+
if (revertibleBranch === undefined) {
|
|
615
|
+
throw new UsageError("Unable to clone a revertible that has been disposed.");
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const commitToRevert = revertibleBranch.getHead();
|
|
619
|
+
const activeBranchHead = targetCheckout.#transaction.activeBranch.getHead();
|
|
620
|
+
|
|
621
|
+
if (isAncestor(commitToRevert, activeBranchHead, true) === false) {
|
|
622
|
+
throw new UsageError(
|
|
623
|
+
"Cannot clone revertible for a commit that is not present on the given branch.",
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
targetCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());
|
|
619
628
|
|
|
620
|
-
return this.createRevertible(revision, kind,
|
|
629
|
+
return this.createRevertible(revision, kind, targetCheckout, onRevertibleDisposed);
|
|
621
630
|
},
|
|
622
631
|
dispose: () => {
|
|
623
632
|
if (revertible.status === RevertibleStatus.Disposed) {
|
|
@@ -665,7 +674,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
665
674
|
|
|
666
675
|
public get editor(): ISharedTreeEditor {
|
|
667
676
|
this.checkNotDisposed();
|
|
668
|
-
return this
|
|
677
|
+
return this.editLock.editor;
|
|
669
678
|
}
|
|
670
679
|
|
|
671
680
|
public locate(anchor: Anchor): AnchorNode | undefined {
|
|
@@ -692,6 +701,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
692
701
|
this.checkNotDisposed(
|
|
693
702
|
"The parent branch has already been disposed and can no longer create new branches.",
|
|
694
703
|
);
|
|
704
|
+
this.editLock.checkUnlocked("Branching");
|
|
695
705
|
const anchors = new AnchorSet();
|
|
696
706
|
const branch = this.#transaction.activeBranch.fork();
|
|
697
707
|
const storedSchema = this.storedSchema.clone();
|
|
@@ -708,6 +718,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
708
718
|
this.removedRoots.clone(),
|
|
709
719
|
this.logger,
|
|
710
720
|
this.breaker,
|
|
721
|
+
this.disposeForksAfterTransaction,
|
|
711
722
|
);
|
|
712
723
|
this.#events.emit("fork", checkout);
|
|
713
724
|
return checkout;
|
|
@@ -720,6 +731,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
720
731
|
checkout.checkNotDisposed(
|
|
721
732
|
"The source of the branch rebase has been disposed and cannot be rebased.",
|
|
722
733
|
);
|
|
734
|
+
this.editLock.checkUnlocked("Rebasing");
|
|
723
735
|
assert(
|
|
724
736
|
!checkout.transaction.isInProgress(),
|
|
725
737
|
0x9af /* A view cannot be rebased while it has a pending transaction */,
|
|
@@ -748,6 +760,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
748
760
|
checkout.checkNotDisposed(
|
|
749
761
|
"The source of the branch merge has been disposed and cannot be merged.",
|
|
750
762
|
);
|
|
763
|
+
this.editLock.checkUnlocked("Merging");
|
|
751
764
|
assert(
|
|
752
765
|
!this.transaction.isInProgress(),
|
|
753
766
|
0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,
|
|
@@ -768,6 +781,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
768
781
|
}
|
|
769
782
|
|
|
770
783
|
public dispose(): void {
|
|
784
|
+
this.editLock.checkUnlocked("Disposing a view");
|
|
771
785
|
this[disposeSymbol]();
|
|
772
786
|
}
|
|
773
787
|
|
|
@@ -955,3 +969,130 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
955
969
|
|
|
956
970
|
// #endregion Commit Validation
|
|
957
971
|
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* A helper class that assists {@link TreeCheckout} in preventing functionality from being used while the tree is in the middle of being edited.
|
|
975
|
+
*/
|
|
976
|
+
class EditLock {
|
|
977
|
+
/**
|
|
978
|
+
* Edits the tree by calling the methods of the editor passed into the {@link EditLock} constructor.
|
|
979
|
+
* @remarks Edits will throw an error if the lock is currently locked.
|
|
980
|
+
*/
|
|
981
|
+
public editor: ISharedTreeEditor;
|
|
982
|
+
private locked = false;
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* @param editor - an editor which will be used to create a new editor that is monitored to determine if any changes are happening to the tree.
|
|
986
|
+
* Use {@link EditLock.editor} in place of the original editor to ensure that changes are monitored.
|
|
987
|
+
*/
|
|
988
|
+
public constructor(editor: ISharedTreeEditor) {
|
|
989
|
+
const checkLock = (): void => this.checkUnlocked("Editing the tree");
|
|
990
|
+
this.editor = {
|
|
991
|
+
get schema() {
|
|
992
|
+
return editor.schema;
|
|
993
|
+
},
|
|
994
|
+
valueField(...fieldArgs) {
|
|
995
|
+
const valueField = editor.valueField(...fieldArgs);
|
|
996
|
+
return {
|
|
997
|
+
set(...editArgs) {
|
|
998
|
+
checkLock();
|
|
999
|
+
valueField.set(...editArgs);
|
|
1000
|
+
},
|
|
1001
|
+
};
|
|
1002
|
+
},
|
|
1003
|
+
optionalField(...fieldArgs) {
|
|
1004
|
+
const optionalField = editor.optionalField(...fieldArgs);
|
|
1005
|
+
return {
|
|
1006
|
+
set(...editArgs) {
|
|
1007
|
+
checkLock();
|
|
1008
|
+
optionalField.set(...editArgs);
|
|
1009
|
+
},
|
|
1010
|
+
};
|
|
1011
|
+
},
|
|
1012
|
+
sequenceField(...fieldArgs) {
|
|
1013
|
+
const sequenceField = editor.sequenceField(...fieldArgs);
|
|
1014
|
+
return {
|
|
1015
|
+
insert(...editArgs) {
|
|
1016
|
+
checkLock();
|
|
1017
|
+
sequenceField.insert(...editArgs);
|
|
1018
|
+
},
|
|
1019
|
+
remove(...editArgs) {
|
|
1020
|
+
checkLock();
|
|
1021
|
+
sequenceField.remove(...editArgs);
|
|
1022
|
+
},
|
|
1023
|
+
};
|
|
1024
|
+
},
|
|
1025
|
+
move(...moveArgs) {
|
|
1026
|
+
checkLock();
|
|
1027
|
+
editor.move(...moveArgs);
|
|
1028
|
+
},
|
|
1029
|
+
addNodeExistsConstraint(path) {
|
|
1030
|
+
editor.addNodeExistsConstraint(path);
|
|
1031
|
+
},
|
|
1032
|
+
addNodeExistsConstraintOnRevert(path) {
|
|
1033
|
+
editor.addNodeExistsConstraintOnRevert(path);
|
|
1034
|
+
},
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Prevent further changes from being made to {@link EditLock.editor} until {@link EditLock.unlock} is called.
|
|
1040
|
+
* @remarks May only be called when the lock is not already locked.
|
|
1041
|
+
*/
|
|
1042
|
+
public lock(): void {
|
|
1043
|
+
if (this.locked) {
|
|
1044
|
+
debugger;
|
|
1045
|
+
}
|
|
1046
|
+
assert(!this.locked, 0xaa7 /* Checkout has already been locked */);
|
|
1047
|
+
this.locked = true;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Throws an error if the lock is currently locked.
|
|
1052
|
+
* @param action - The current action being performed by the user.
|
|
1053
|
+
* This must start with a capital letter, as it shows up as the first part of the error message and we want it to look nice.
|
|
1054
|
+
*/
|
|
1055
|
+
public checkUnlocked<T extends string>(action: T extends Capitalize<T> ? T : never): void {
|
|
1056
|
+
if (this.locked) {
|
|
1057
|
+
// These type assertions ensure that the event name strings used here match the actual event names
|
|
1058
|
+
const nodeChanged: keyof TreeChangeEvents = "nodeChanged";
|
|
1059
|
+
const treeChanged: keyof TreeChangeEvents = "treeChanged";
|
|
1060
|
+
throw new UsageError(
|
|
1061
|
+
`${action} is forbidden during a ${nodeChanged} or ${treeChanged} event`,
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Allow changes to be made to {@link EditLock.editor} again.
|
|
1068
|
+
* @remarks May only be called when the lock is currently locked.
|
|
1069
|
+
*/
|
|
1070
|
+
public unlock(): void {
|
|
1071
|
+
assert(this.locked, 0xaa8 /* Checkout has not been locked */);
|
|
1072
|
+
this.locked = false;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Keeps track of all new forks created until the returned function is invoked, which will dispose all of those for.
|
|
1078
|
+
* The returned function may only be called once.
|
|
1079
|
+
*
|
|
1080
|
+
* @param checkout - The tree checkout for which you want to monitor forks for disposal.
|
|
1081
|
+
* @returns a function which can be called to dispose all of the tracked forks.
|
|
1082
|
+
*/
|
|
1083
|
+
function trackForksForDisposal(checkout: TreeCheckout): () => void {
|
|
1084
|
+
const forks = new Set<TreeCheckout>();
|
|
1085
|
+
const onDisposeUnSubscribes: (() => void)[] = [];
|
|
1086
|
+
const onForkUnSubscribe = onForkTransitive(checkout, (fork) => {
|
|
1087
|
+
forks.add(fork);
|
|
1088
|
+
onDisposeUnSubscribes.push(fork.events.on("dispose", () => forks.delete(fork)));
|
|
1089
|
+
});
|
|
1090
|
+
let disposed = false;
|
|
1091
|
+
return () => {
|
|
1092
|
+
assert(!disposed, 0xaa9 /* Forks may only be disposed once */);
|
|
1093
|
+
forks.forEach((fork) => fork.dispose());
|
|
1094
|
+
onDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());
|
|
1095
|
+
onForkUnSubscribe();
|
|
1096
|
+
disposed = true;
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
@@ -259,7 +259,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
259
259
|
protected async loadCore(services: IChannelStorageService): Promise<void> {
|
|
260
260
|
assert(
|
|
261
261
|
this.editManager.localBranch.getHead() === this.editManager.getTrunkHead(),
|
|
262
|
-
|
|
262
|
+
0xaaa /* All local changes should be applied to the trunk before loading from summary */,
|
|
263
263
|
);
|
|
264
264
|
const [editManagerSummarizer, ...summarizables] = this.summarizables;
|
|
265
265
|
const loadEditManager = this.loadSummarizable(editManagerSummarizer, services);
|
|
@@ -58,6 +58,13 @@ export interface JsonNodeSchemaBase<
|
|
|
58
58
|
* {@inheritDoc JsonSchemaType}
|
|
59
59
|
*/
|
|
60
60
|
readonly type: TJsonSchemaType;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Description of the node schema.
|
|
64
|
+
* @remarks Derived from {@link NodeSchemaMetadata.description}.
|
|
65
|
+
* @see {@link https://json-schema.org/draft/2020-12/json-schema-validation#name-title-and-description}
|
|
66
|
+
*/
|
|
67
|
+
readonly description?: string | undefined;
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
/**
|