@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
package/src/util/rangeMap.ts
CHANGED
|
@@ -3,232 +3,307 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { oob } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, oob } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { BTree } from "@tylerbu/sorted-btree-es6";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* RangeMap represents a mapping from keys of type K to values of type V or undefined.
|
|
11
|
+
* The set of all possible keys is assumed to be fully ordered,
|
|
12
|
+
* and for each key there should be a single next higher key.
|
|
13
|
+
* The values for a range of consecutive keys can be changed or queried in a single operation.
|
|
14
|
+
* The structure of the keys is described by the `offsetKey` and `subtractKeys` functions provided in the constructor.
|
|
12
15
|
*/
|
|
13
|
-
export
|
|
16
|
+
export class RangeMap<K, V> {
|
|
17
|
+
private tree: BTree<K, RangeEntry<V>>;
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param offsetKey - Function which returns a new key which is `offset` keys after `key`.
|
|
21
|
+
* When `offset` is negative, the returned key should come before `key`.
|
|
22
|
+
*
|
|
23
|
+
* @param subtractKeys - Function which returns the difference between `b` and `a`.
|
|
24
|
+
* Offsetting `b` by this difference should return `a`.
|
|
25
|
+
* The difference can be infinite if `a` cannot be reached from `b` by offsetting,
|
|
26
|
+
* but the difference should still be positive if `a` is larger than `b` and negative if smaller.
|
|
27
|
+
*/
|
|
28
|
+
public constructor(
|
|
29
|
+
private readonly offsetKey: (key: K, offset: number) => K,
|
|
30
|
+
private readonly subtractKeys: (a: K, b: K) => number,
|
|
31
|
+
) {
|
|
32
|
+
this.tree = new BTree(undefined, subtractKeys);
|
|
33
|
+
}
|
|
20
34
|
|
|
21
|
-
/**
|
|
22
|
-
* The result of a query about a range of keys.
|
|
23
|
-
*/
|
|
24
|
-
export interface RangeQueryResult<T> {
|
|
25
35
|
/**
|
|
26
|
-
*
|
|
36
|
+
* Retrieves all entries from the RangeMap.
|
|
27
37
|
*/
|
|
28
|
-
|
|
38
|
+
public entries(): RangeQueryEntry<K, V>[] {
|
|
39
|
+
const entries: RangeQueryEntry<K, V>[] = [];
|
|
40
|
+
for (const [start, entry] of this.tree.entries()) {
|
|
41
|
+
entries.push({ start, length: entry.length, value: entry.value });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return entries;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public clear(): void {
|
|
48
|
+
this.tree.clear();
|
|
49
|
+
}
|
|
29
50
|
|
|
30
51
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
52
|
+
* Retrieves the values for all keys in the query range.
|
|
53
|
+
*
|
|
54
|
+
* @param start - The first key in the range being queried
|
|
55
|
+
* @param length - The length of the query range
|
|
56
|
+
* @returns A list of entries, each describing the value for some subrange of the query.
|
|
57
|
+
* The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.
|
|
34
58
|
*/
|
|
35
|
-
length: number
|
|
36
|
-
|
|
59
|
+
public getAll(start: K, length: number): RangeQueryEntry<K, V>[] {
|
|
60
|
+
const entries = this.getIntersectingEntries(start, length);
|
|
61
|
+
if (entries.length === 0) {
|
|
62
|
+
return entries;
|
|
63
|
+
}
|
|
37
64
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
map: RangeMap<T>,
|
|
43
|
-
start: number,
|
|
44
|
-
length: number,
|
|
45
|
-
): RangeQueryResult<T> {
|
|
46
|
-
for (const range of map) {
|
|
47
|
-
if (range.start > start) {
|
|
48
|
-
return { value: undefined, length: Math.min(range.start - start, length) };
|
|
65
|
+
const firstEntry = entries[0] ?? oob();
|
|
66
|
+
const lengthBefore = this.subtractKeys(start, firstEntry.start);
|
|
67
|
+
if (lengthBefore > 0) {
|
|
68
|
+
entries[0] = { ...firstEntry, start, length: firstEntry.length - lengthBefore };
|
|
49
69
|
}
|
|
50
70
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
const lastEntry = entries[entries.length - 1] ?? oob();
|
|
72
|
+
const lastEntryKey = this.offsetKey(lastEntry.start, lastEntry.length - 1);
|
|
73
|
+
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
74
|
+
const lengthAfter = this.subtractKeys(lastEntryKey, lastQueryKey);
|
|
75
|
+
if (lengthAfter > 0) {
|
|
76
|
+
entries[entries.length - 1] = { ...lastEntry, length: lastEntry.length - lengthAfter };
|
|
56
77
|
}
|
|
78
|
+
|
|
79
|
+
return entries;
|
|
57
80
|
}
|
|
58
81
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the value for some prefix of the query range.
|
|
84
|
+
*
|
|
85
|
+
* @param start - The first key in the query range.
|
|
86
|
+
* @param length - The length of the query range.
|
|
87
|
+
* @returns A RangeQueryResult containing the value associated with `start`,
|
|
88
|
+
* and the number of consecutive keys with that same value (at least 1, at most `length`).
|
|
89
|
+
*/
|
|
90
|
+
public getFirst(start: K, length: number): RangeQueryResult<K, V> {
|
|
91
|
+
{
|
|
92
|
+
// We first check for an entry with a key less than or equal to `start`.
|
|
93
|
+
const entry = this.tree.getPairOrNextLower(start);
|
|
94
|
+
if (entry !== undefined) {
|
|
95
|
+
const entryKey = entry[0];
|
|
96
|
+
const { value, length: entryLength } = entry[1];
|
|
62
97
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
for (const range of map) {
|
|
70
|
-
if (range.start > lastQueryKey) {
|
|
71
|
-
// We've passed the end of the query range.
|
|
72
|
-
break;
|
|
98
|
+
const entryLastKey = this.offsetKey(entryKey, entryLength - 1);
|
|
99
|
+
const overlappingLength = Math.min(this.subtractKeys(entryLastKey, start) + 1, length);
|
|
100
|
+
if (overlappingLength > 0) {
|
|
101
|
+
return { value, start, length: overlappingLength };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
73
104
|
}
|
|
74
105
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
106
|
+
{
|
|
107
|
+
// There is no value associated with `start`.
|
|
108
|
+
// Now we need to determine how many of the following keys are also undefined.
|
|
109
|
+
const key = this.tree.nextHigherKey(start);
|
|
110
|
+
if (key !== undefined) {
|
|
111
|
+
const entryKey = key;
|
|
112
|
+
|
|
113
|
+
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
114
|
+
if (this.le(entryKey, lastQueryKey)) {
|
|
115
|
+
return { value: undefined, start, length: this.subtractKeys(entryKey, start) };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return { value: undefined, start, length };
|
|
78
120
|
}
|
|
79
121
|
}
|
|
80
122
|
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Sets the value for a specified range.
|
|
125
|
+
*
|
|
126
|
+
* @param start - The first key in the range being set.
|
|
127
|
+
* @param length - The length of the range.
|
|
128
|
+
* @param value - The value to associate with the range.
|
|
129
|
+
*/
|
|
130
|
+
public set(start: K, length: number, value: V | undefined): void {
|
|
131
|
+
this.delete(start, length);
|
|
132
|
+
if (value !== undefined) {
|
|
133
|
+
this.tree.set(start, { value, length });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
83
136
|
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Deletes values within a specified range, updating or removing existing entries.
|
|
139
|
+
*
|
|
140
|
+
* 1. If an entry is completely included in the deletion range, the whole entry will be deleted
|
|
141
|
+
* e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]
|
|
142
|
+
* map becomes [[1, 2]] after deletion
|
|
143
|
+
* (Note: the notation [a, b] represents start = a, end = b for simpler visualization, instead of `b`
|
|
144
|
+
* representing the length)
|
|
145
|
+
*
|
|
146
|
+
* 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted
|
|
147
|
+
* e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]
|
|
148
|
+
* map becomes [[1, 1], [5, 6]] after deletion
|
|
149
|
+
*
|
|
150
|
+
* 3. If an entry completely includes the deletion range, the original entry may be split into two.
|
|
151
|
+
* e.g.: map = [[1, 6]], delete range: [2, 4]
|
|
152
|
+
* map becomes [[1, 1], [5, 6]]
|
|
153
|
+
*
|
|
154
|
+
* @param start - The start of the range to delete (inclusive).
|
|
155
|
+
* @param length - The length of the range to delete.
|
|
156
|
+
*/
|
|
157
|
+
public delete(start: K, length: number): void {
|
|
158
|
+
const lastDeleteKey = this.offsetKey(start, length - 1);
|
|
159
|
+
for (const { start: key, length: entryLength, value } of this.getIntersectingEntries(
|
|
160
|
+
start,
|
|
161
|
+
length,
|
|
162
|
+
)) {
|
|
163
|
+
this.tree.delete(key);
|
|
164
|
+
const lengthBefore = this.subtractKeys(start, key);
|
|
165
|
+
if (lengthBefore > 0) {
|
|
166
|
+
// A portion of this entry comes before the deletion range, so we reinsert that portion.
|
|
167
|
+
this.tree.set(key, { length: lengthBefore, value });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const lastEntryKey = this.offsetKey(key, entryLength - 1);
|
|
171
|
+
const lengthAfter = this.subtractKeys(lastEntryKey, lastDeleteKey);
|
|
172
|
+
if (lengthAfter > 0) {
|
|
173
|
+
// A portion of this entry comes after the deletion range, so we reinsert that portion.
|
|
174
|
+
this.tree.set(this.offsetKey(lastDeleteKey, 1), { length: lengthAfter, value });
|
|
175
|
+
}
|
|
105
176
|
}
|
|
106
177
|
}
|
|
107
178
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return;
|
|
179
|
+
public clone(): RangeMap<K, V> {
|
|
180
|
+
const cloned = new RangeMap<K, V>(this.offsetKey, this.subtractKeys);
|
|
181
|
+
cloned.tree = this.tree.clone();
|
|
182
|
+
return cloned;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Returns a new map which contains the entries from both input maps.
|
|
187
|
+
*/
|
|
188
|
+
public static union<K, V>(a: RangeMap<K, V>, b: RangeMap<K, V>): RangeMap<K, V> {
|
|
189
|
+
assert(
|
|
190
|
+
a.offsetKey === b.offsetKey && a.subtractKeys === b.subtractKeys,
|
|
191
|
+
0xaae /* Maps should have the same behavior */,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const merged = new RangeMap<K, V>(a.offsetKey, a.subtractKeys);
|
|
195
|
+
|
|
196
|
+
// TODO: Is there a good pattern that lets us make `tree` readonly?
|
|
197
|
+
merged.tree = a.tree.clone();
|
|
198
|
+
for (const [key, value] of b.tree.entries()) {
|
|
199
|
+
// TODO: Handle key collisions
|
|
200
|
+
merged.tree.set(key, value);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return merged;
|
|
112
204
|
}
|
|
113
205
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
206
|
+
private getIntersectingEntries(start: K, length: number): RangeQueryEntry<K, V>[] {
|
|
207
|
+
const entries: RangeQueryEntry<K, V>[] = [];
|
|
208
|
+
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
209
|
+
{
|
|
210
|
+
const entry = this.tree.getPairOrNextLower(start);
|
|
211
|
+
if (entry !== undefined) {
|
|
212
|
+
const key = entry[0];
|
|
213
|
+
const { length: entryLength, value } = entry[1];
|
|
214
|
+
const lastEntryKey = this.offsetKey(key, entryLength - 1);
|
|
215
|
+
if (this.ge(lastEntryKey, start)) {
|
|
216
|
+
entries.push({ start: key, length: entryLength, value });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
{
|
|
222
|
+
let entry = this.tree.nextHigherPair(start);
|
|
223
|
+
while (entry !== undefined) {
|
|
224
|
+
const key = entry[0];
|
|
225
|
+
if (this.gt(key, lastQueryKey)) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const { length: entryLength, value } = entry[1];
|
|
230
|
+
const lastEntryKey = this.offsetKey(key, entryLength - 1);
|
|
231
|
+
|
|
232
|
+
entries.push({ start: key, length: entryLength, value });
|
|
233
|
+
entry = this.tree.nextHigherPair(lastEntryKey);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return entries;
|
|
134
238
|
}
|
|
135
239
|
|
|
136
|
-
|
|
137
|
-
|
|
240
|
+
private gt(a: K, b: K): boolean {
|
|
241
|
+
return this.subtractKeys(a, b) > 0;
|
|
242
|
+
}
|
|
138
243
|
|
|
139
|
-
|
|
140
|
-
|
|
244
|
+
private ge(a: K, b: K): boolean {
|
|
245
|
+
return this.subtractKeys(a, b) >= 0;
|
|
141
246
|
}
|
|
142
247
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
start: end + 1,
|
|
147
|
-
length: lengthAfterLast,
|
|
148
|
-
};
|
|
248
|
+
private lt(a: K, b: K): boolean {
|
|
249
|
+
return this.subtractKeys(a, b) < 0;
|
|
250
|
+
}
|
|
149
251
|
|
|
150
|
-
|
|
151
|
-
|
|
252
|
+
private le(a: K, b: K): boolean {
|
|
253
|
+
return this.subtractKeys(a, b) <= 0;
|
|
152
254
|
}
|
|
255
|
+
}
|
|
153
256
|
|
|
154
|
-
|
|
155
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Represents a contiguous range of values in the RangeMap.
|
|
259
|
+
*/
|
|
260
|
+
interface RangeEntry<V> {
|
|
261
|
+
/**
|
|
262
|
+
* The length of the range.
|
|
263
|
+
*/
|
|
264
|
+
readonly length: number;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* The value associated with this range.
|
|
268
|
+
*/
|
|
269
|
+
readonly value: V;
|
|
156
270
|
}
|
|
157
271
|
|
|
158
272
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* 1. If an entry is completely included in the deletion range, the whole entry will be deleted
|
|
162
|
-
* e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]
|
|
163
|
-
* map becomes [[1, 2]] after deletion
|
|
164
|
-
* (Note: the notation [a, b] represents start = a, end = b for simpler visiualization, instead of `b`
|
|
165
|
-
* representing the length)
|
|
166
|
-
*
|
|
167
|
-
* 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted
|
|
168
|
-
* e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]
|
|
169
|
-
* map becomes [[1, 1], [5, 6]] after deletion
|
|
170
|
-
*
|
|
171
|
-
* 3. If an entry completely includes the deletion range, the original entry may be split into two.
|
|
172
|
-
* e.g.: map = [[1, 6]], delete range: [2, 4]
|
|
173
|
-
* map becomes [[1, 1], [5, 6]]
|
|
174
|
-
*
|
|
175
|
-
* TODO: We may find ways to mitigate the code duplication between set and delete, and we need to better
|
|
176
|
-
* document the API. AB#7413
|
|
273
|
+
* Describes the result of a range query, including the value and length of the matching prefix.
|
|
177
274
|
*/
|
|
178
|
-
export
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
for (const [i, entry] of map.entries()) {
|
|
185
|
-
const entryLastKey = entry.start + entry.length - 1;
|
|
186
|
-
if (entryLastKey < start) {
|
|
187
|
-
iBefore = i;
|
|
188
|
-
} else if (entry.start > end) {
|
|
189
|
-
iAfter = i;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
275
|
+
export interface RangeQueryResult<K, V> {
|
|
276
|
+
/**
|
|
277
|
+
* The key for the first element in the range.
|
|
278
|
+
*/
|
|
279
|
+
readonly start: K;
|
|
193
280
|
|
|
194
|
-
|
|
281
|
+
/**
|
|
282
|
+
* The value of the first key in the query range.
|
|
283
|
+
* If no matching range is found, this will be undefined.
|
|
284
|
+
*/
|
|
285
|
+
readonly value: V | undefined;
|
|
195
286
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
287
|
+
/**
|
|
288
|
+
* The length of the prefix of the query range which has the same value.
|
|
289
|
+
* For example, if a RangeMap has the same value for keys 5, 6, and 7,
|
|
290
|
+
* a query about the range [5, 10] would give a result with length 3.
|
|
291
|
+
*/
|
|
292
|
+
readonly length: number;
|
|
293
|
+
}
|
|
200
294
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// Update or remove the overlapping entries
|
|
205
|
-
for (let i = iFirst; i <= iLast; ++i) {
|
|
206
|
-
const entry = map[i] ?? oob();
|
|
207
|
-
const entryLastKey = entry.start + entry.length - 1;
|
|
208
|
-
let isDirty = false;
|
|
209
|
-
|
|
210
|
-
// If the entry lies within the range to be deleted, remove it
|
|
211
|
-
if (entry.start >= start && entryLastKey <= end) {
|
|
212
|
-
map.splice(i, 1);
|
|
213
|
-
} else {
|
|
214
|
-
// If the entry partially or completely overlaps with the range to be deleted
|
|
215
|
-
if (entry.start < start) {
|
|
216
|
-
// Update the endpoint and length of the portion before the range to be deleted
|
|
217
|
-
const lengthBefore = start - entry.start;
|
|
218
|
-
map[i] = { ...entry, length: lengthBefore };
|
|
219
|
-
isDirty = true;
|
|
220
|
-
}
|
|
295
|
+
export interface RangeQueryEntry<K, V> extends RangeQueryResult<K, V> {
|
|
296
|
+
readonly value: V;
|
|
297
|
+
}
|
|
221
298
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
}
|
|
299
|
+
export function newIntegerRangeMap<V>(): RangeMap<number, V> {
|
|
300
|
+
return new RangeMap(offsetInteger, subtractIntegers);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function offsetInteger(key: number, offset: number): number {
|
|
304
|
+
return key + offset;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function subtractIntegers(a: number, b: number): number {
|
|
308
|
+
return a - b;
|
|
234
309
|
}
|
package/src/util/utils.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface MapGetSet<K, V> {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Make all transitive properties in T readonly
|
|
19
|
+
* Make all transitive properties in `T` readonly
|
|
20
20
|
*/
|
|
21
21
|
export type RecursiveReadonly<T> = {
|
|
22
22
|
readonly [P in keyof T]: RecursiveReadonly<T[P]>;
|
|
@@ -48,9 +48,16 @@ export function asMutable<T>(readonly: T): Mutable<T> {
|
|
|
48
48
|
export const clone = structuredClone;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
* Throw an error with a constant message.
|
|
52
|
+
* @remarks
|
|
53
|
+
* Works like {@link @fluidframework/core-utils/internal#assert}.
|
|
54
|
+
*/
|
|
55
|
+
export function fail(message: string | number): never {
|
|
56
|
+
// Declaring this here aliased to a different name avoids the assert tagging objecting to the usages of `assert` below.
|
|
57
|
+
// Since users of `fail` do the assert message tagging instead, suppressing tagging errors here makes sense.
|
|
58
|
+
const assertNoTag: (condition: boolean, message: string | number) => asserts condition =
|
|
59
|
+
assert;
|
|
60
|
+
assertNoTag(false, message);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
@@ -563,3 +570,49 @@ export function defineLazyCachedProperty<
|
|
|
563
570
|
});
|
|
564
571
|
return obj as typeof obj & { [P in K]: V };
|
|
565
572
|
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Copies a given property from one object to another if and only if the property is defined.
|
|
576
|
+
* @param source - The object to copy the property from.
|
|
577
|
+
* If `source` is undefined or does not have the property defined, then this function will do nothing.
|
|
578
|
+
* @param property - The property to copy.
|
|
579
|
+
* @param destination - The object to copy the property to.
|
|
580
|
+
* @remarks This function is useful for copying properties from one object to another while minimizing the presence of `undefined` values.
|
|
581
|
+
* If `property` is not present on `source` - or if `property` is present, but has a value of `undefined` - then this function will not modify `destination`.
|
|
582
|
+
* This is different from doing `destination.foo = source.foo`, which would define a `"foo"` property on `destination` with the value `undefined`.
|
|
583
|
+
*
|
|
584
|
+
* If the type of `source` is known to have `property`, then this function asserts that the type of `destination` has `property` as well after the call.
|
|
585
|
+
*
|
|
586
|
+
* This function first reads the property value (if present) from `source` and then sets it on `destination`, as opposed to e.g. directly copying the property descriptor.
|
|
587
|
+
* @privateRemarks The first overload of this function allows auto-complete to suggest property names from `source`, but by having the second overload we still allow for arbitrary property names.
|
|
588
|
+
*/
|
|
589
|
+
export function copyPropertyIfDefined<S extends object, K extends keyof S, D extends object>(
|
|
590
|
+
source: S | undefined,
|
|
591
|
+
property: K,
|
|
592
|
+
destination: D,
|
|
593
|
+
): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D;
|
|
594
|
+
export function copyPropertyIfDefined<
|
|
595
|
+
S extends object,
|
|
596
|
+
K extends string | number | symbol,
|
|
597
|
+
D extends object,
|
|
598
|
+
>(
|
|
599
|
+
source: S | undefined,
|
|
600
|
+
property: K,
|
|
601
|
+
destination: D,
|
|
602
|
+
): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D;
|
|
603
|
+
export function copyPropertyIfDefined<
|
|
604
|
+
S extends object,
|
|
605
|
+
K extends string | number | symbol,
|
|
606
|
+
D extends object,
|
|
607
|
+
>(
|
|
608
|
+
source: S | undefined,
|
|
609
|
+
property: K,
|
|
610
|
+
destination: D,
|
|
611
|
+
): asserts destination is K extends keyof S ? D & { [P in K]: S[K] } : D {
|
|
612
|
+
if (source !== undefined) {
|
|
613
|
+
const value = (source as { [P in K]?: unknown })[property];
|
|
614
|
+
if (value !== undefined) {
|
|
615
|
+
(destination as { [P in K]: unknown })[property] = value;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { ChangesetLocalId, RevisionTag } from "../core/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* A unique ID allocator that returns the output ID for the same input ID.
|
|
8
|
-
*/
|
|
9
|
-
export interface MemoizedIdRangeAllocator {
|
|
10
|
-
/**
|
|
11
|
-
* A unique ID allocator that returns the output ID for the same input ID.
|
|
12
|
-
*
|
|
13
|
-
* "The same" here includes cases where a prior call allocated a range of IDs that partially or fully overlap with the
|
|
14
|
-
* current call.
|
|
15
|
-
* @param revision - The revision associated with the range of IDs to allocate.
|
|
16
|
-
* @param startId - The first ID to allocate.
|
|
17
|
-
* @param count - The number of IDs to allocate. Interpreted as 1 if undefined.
|
|
18
|
-
*/
|
|
19
|
-
allocate(revision: RevisionTag | undefined, startId: ChangesetLocalId, count?: number): IdRange[];
|
|
20
|
-
/**
|
|
21
|
-
* Allocates a new range of IDs.
|
|
22
|
-
*
|
|
23
|
-
* @param count - The number of IDs to allocate. Interpreted as 1 if undefined.
|
|
24
|
-
*/
|
|
25
|
-
mint(count?: number): ChangesetLocalId;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
*/
|
|
29
|
-
export interface IdRange {
|
|
30
|
-
readonly first: ChangesetLocalId;
|
|
31
|
-
readonly count: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
*/
|
|
35
|
-
export declare const MemoizedIdRangeAllocator: {
|
|
36
|
-
fromNextId(nextId?: number): MemoizedIdRangeAllocator;
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=memoizedIdRangeAllocator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memoizedIdRangeAllocator.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/memoizedIdRangeAllocator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAUtE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;;;;;OAQG;IACH,QAAQ,CACP,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,OAAO,EAAE,gBAAgB,EACzB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,EAAE,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACvC;AAED;GACG;AACH,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED;GACG;AACH,eAAO,MAAM,wBAAwB;wBACjB,MAAM,GAAO,wBAAwB;CA4DxD,CAAC"}
|