@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/dist/util/rangeMap.js
CHANGED
|
@@ -4,173 +4,227 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.newIntegerRangeMap = exports.RangeMap = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
+
const sorted_btree_es6_1 = require("@tylerbu/sorted-btree-es6");
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* RangeMap represents a mapping from keys of type K to values of type V or undefined.
|
|
12
|
+
* The set of all possible keys is assumed to be fully ordered,
|
|
13
|
+
* and for each key there should be a single next higher key.
|
|
14
|
+
* The values for a range of consecutive keys can be changed or queried in a single operation.
|
|
15
|
+
* The structure of the keys is described by the `offsetKey` and `subtractKeys` functions provided in the constructor.
|
|
11
16
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
class RangeMap {
|
|
18
|
+
/**
|
|
19
|
+
* @param offsetKey - Function which returns a new key which is `offset` keys after `key`.
|
|
20
|
+
* When `offset` is negative, the returned key should come before `key`.
|
|
21
|
+
*
|
|
22
|
+
* @param subtractKeys - Function which returns the difference between `b` and `a`.
|
|
23
|
+
* Offsetting `b` by this difference should return `a`.
|
|
24
|
+
* The difference can be infinite if `a` cannot be reached from `b` by offsetting,
|
|
25
|
+
* but the difference should still be positive if `a` is larger than `b` and negative if smaller.
|
|
26
|
+
*/
|
|
27
|
+
constructor(offsetKey, subtractKeys) {
|
|
28
|
+
this.offsetKey = offsetKey;
|
|
29
|
+
this.subtractKeys = subtractKeys;
|
|
30
|
+
this.tree = new sorted_btree_es6_1.BTree(undefined, subtractKeys);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves all entries from the RangeMap.
|
|
34
|
+
*/
|
|
35
|
+
entries() {
|
|
36
|
+
const entries = [];
|
|
37
|
+
for (const [start, entry] of this.tree.entries()) {
|
|
38
|
+
entries.push({ start, length: entry.length, value: entry.value });
|
|
22
39
|
}
|
|
40
|
+
return entries;
|
|
23
41
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
clear() {
|
|
43
|
+
this.tree.clear();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the values for all keys in the query range.
|
|
47
|
+
*
|
|
48
|
+
* @param start - The first key in the range being queried
|
|
49
|
+
* @param length - The length of the query range
|
|
50
|
+
* @returns A list of entries, each describing the value for some subrange of the query.
|
|
51
|
+
* The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.
|
|
52
|
+
*/
|
|
53
|
+
getAll(start, length) {
|
|
54
|
+
const entries = this.getIntersectingEntries(start, length);
|
|
55
|
+
if (entries.length === 0) {
|
|
56
|
+
return entries;
|
|
34
57
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
const firstEntry = entries[0] ?? (0, internal_1.oob)();
|
|
59
|
+
const lengthBefore = this.subtractKeys(start, firstEntry.start);
|
|
60
|
+
if (lengthBefore > 0) {
|
|
61
|
+
entries[0] = { ...firstEntry, start, length: firstEntry.length - lengthBefore };
|
|
38
62
|
}
|
|
63
|
+
const lastEntry = entries[entries.length - 1] ?? (0, internal_1.oob)();
|
|
64
|
+
const lastEntryKey = this.offsetKey(lastEntry.start, lastEntry.length - 1);
|
|
65
|
+
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
66
|
+
const lengthAfter = this.subtractKeys(lastEntryKey, lastQueryKey);
|
|
67
|
+
if (lengthAfter > 0) {
|
|
68
|
+
entries[entries.length - 1] = { ...lastEntry, length: lastEntry.length - lengthAfter };
|
|
69
|
+
}
|
|
70
|
+
return entries;
|
|
39
71
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the value for some prefix of the query range.
|
|
74
|
+
*
|
|
75
|
+
* @param start - The first key in the query range.
|
|
76
|
+
* @param length - The length of the query range.
|
|
77
|
+
* @returns A RangeQueryResult containing the value associated with `start`,
|
|
78
|
+
* and the number of consecutive keys with that same value (at least 1, at most `length`).
|
|
79
|
+
*/
|
|
80
|
+
getFirst(start, length) {
|
|
81
|
+
{
|
|
82
|
+
// We first check for an entry with a key less than or equal to `start`.
|
|
83
|
+
const entry = this.tree.getPairOrNextLower(start);
|
|
84
|
+
if (entry !== undefined) {
|
|
85
|
+
const entryKey = entry[0];
|
|
86
|
+
const { value, length: entryLength } = entry[1];
|
|
87
|
+
const entryLastKey = this.offsetKey(entryKey, entryLength - 1);
|
|
88
|
+
const overlappingLength = Math.min(this.subtractKeys(entryLastKey, start) + 1, length);
|
|
89
|
+
if (overlappingLength > 0) {
|
|
90
|
+
return { value, start, length: overlappingLength };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
55
93
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
{
|
|
95
|
+
// There is no value associated with `start`.
|
|
96
|
+
// Now we need to determine how many of the following keys are also undefined.
|
|
97
|
+
const key = this.tree.nextHigherKey(start);
|
|
98
|
+
if (key !== undefined) {
|
|
99
|
+
const entryKey = key;
|
|
100
|
+
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
101
|
+
if (this.le(entryKey, lastQueryKey)) {
|
|
102
|
+
return { value: undefined, start, length: this.subtractKeys(entryKey, start) };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { value: undefined, start, length };
|
|
59
106
|
}
|
|
60
107
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const lengthAfterLast = lastEntryKey - end;
|
|
73
|
-
if (lengthBeforeFirst > 0 && lengthAfterLast > 0 && iFirst === iLast) {
|
|
74
|
-
// The new entry fits in the middle of an existing entry.
|
|
75
|
-
// We replace the existing entry with:
|
|
76
|
-
// 1) the portion which comes before `newEntry`
|
|
77
|
-
// 2) `newEntry`
|
|
78
|
-
// 3) the portion which comes after `newEntry`
|
|
79
|
-
map.splice(iFirst, 1, { ...firstEntry, length: lengthBeforeFirst }, newEntry, {
|
|
80
|
-
...lastEntry,
|
|
81
|
-
start: end + 1,
|
|
82
|
-
length: lengthAfterLast,
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (lengthBeforeFirst > 0) {
|
|
87
|
-
map[iFirst] = { ...firstEntry, length: lengthBeforeFirst };
|
|
88
|
-
// The entry at `iFirst` is no longer overlapping with `newEntry`.
|
|
89
|
-
iBefore = iFirst;
|
|
90
|
-
}
|
|
91
|
-
if (lengthAfterLast > 0) {
|
|
92
|
-
map[iLast] = {
|
|
93
|
-
...lastEntry,
|
|
94
|
-
start: end + 1,
|
|
95
|
-
length: lengthAfterLast,
|
|
96
|
-
};
|
|
97
|
-
// The entry at `iLast` is no longer overlapping with `newEntry`.
|
|
98
|
-
iAfter = iLast;
|
|
99
|
-
}
|
|
100
|
-
const numContainedEntries = iAfter - iBefore - 1;
|
|
101
|
-
map.splice(iBefore + 1, numContainedEntries, newEntry);
|
|
102
|
-
}
|
|
103
|
-
exports.setInRangeMap = setInRangeMap;
|
|
104
|
-
/**
|
|
105
|
-
* Delete the keys from `start` to `start + length - 1`
|
|
106
|
-
*
|
|
107
|
-
* 1. If an entry is completely included in the deletion range, the whole entry will be deleted
|
|
108
|
-
* e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]
|
|
109
|
-
* map becomes [[1, 2]] after deletion
|
|
110
|
-
* (Note: the notation [a, b] represents start = a, end = b for simpler visiualization, instead of `b`
|
|
111
|
-
* representing the length)
|
|
112
|
-
*
|
|
113
|
-
* 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted
|
|
114
|
-
* e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]
|
|
115
|
-
* map becomes [[1, 1], [5, 6]] after deletion
|
|
116
|
-
*
|
|
117
|
-
* 3. If an entry completely includes the deletion range, the original entry may be split into two.
|
|
118
|
-
* e.g.: map = [[1, 6]], delete range: [2, 4]
|
|
119
|
-
* map becomes [[1, 1], [5, 6]]
|
|
120
|
-
*
|
|
121
|
-
* TODO: We may find ways to mitigate the code duplication between set and delete, and we need to better
|
|
122
|
-
* document the API. AB#7413
|
|
123
|
-
*/
|
|
124
|
-
function deleteFromRangeMap(map, start, length) {
|
|
125
|
-
const end = start + length - 1;
|
|
126
|
-
let iBefore = -1;
|
|
127
|
-
let iAfter = map.length;
|
|
128
|
-
for (const [i, entry] of map.entries()) {
|
|
129
|
-
const entryLastKey = entry.start + entry.length - 1;
|
|
130
|
-
if (entryLastKey < start) {
|
|
131
|
-
iBefore = i;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the value for a specified range.
|
|
110
|
+
*
|
|
111
|
+
* @param start - The first key in the range being set.
|
|
112
|
+
* @param length - The length of the range.
|
|
113
|
+
* @param value - The value to associate with the range.
|
|
114
|
+
*/
|
|
115
|
+
set(start, length, value) {
|
|
116
|
+
this.delete(start, length);
|
|
117
|
+
if (value !== undefined) {
|
|
118
|
+
this.tree.set(start, { value, length });
|
|
132
119
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Deletes values within a specified range, updating or removing existing entries.
|
|
123
|
+
*
|
|
124
|
+
* 1. If an entry is completely included in the deletion range, the whole entry will be deleted
|
|
125
|
+
* e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]
|
|
126
|
+
* map becomes [[1, 2]] after deletion
|
|
127
|
+
* (Note: the notation [a, b] represents start = a, end = b for simpler visualization, instead of `b`
|
|
128
|
+
* representing the length)
|
|
129
|
+
*
|
|
130
|
+
* 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted
|
|
131
|
+
* e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]
|
|
132
|
+
* map becomes [[1, 1], [5, 6]] after deletion
|
|
133
|
+
*
|
|
134
|
+
* 3. If an entry completely includes the deletion range, the original entry may be split into two.
|
|
135
|
+
* e.g.: map = [[1, 6]], delete range: [2, 4]
|
|
136
|
+
* map becomes [[1, 1], [5, 6]]
|
|
137
|
+
*
|
|
138
|
+
* @param start - The start of the range to delete (inclusive).
|
|
139
|
+
* @param length - The length of the range to delete.
|
|
140
|
+
*/
|
|
141
|
+
delete(start, length) {
|
|
142
|
+
const lastDeleteKey = this.offsetKey(start, length - 1);
|
|
143
|
+
for (const { start: key, length: entryLength, value } of this.getIntersectingEntries(start, length)) {
|
|
144
|
+
this.tree.delete(key);
|
|
145
|
+
const lengthBefore = this.subtractKeys(start, key);
|
|
146
|
+
if (lengthBefore > 0) {
|
|
147
|
+
// A portion of this entry comes before the deletion range, so we reinsert that portion.
|
|
148
|
+
this.tree.set(key, { length: lengthBefore, value });
|
|
149
|
+
}
|
|
150
|
+
const lastEntryKey = this.offsetKey(key, entryLength - 1);
|
|
151
|
+
const lengthAfter = this.subtractKeys(lastEntryKey, lastDeleteKey);
|
|
152
|
+
if (lengthAfter > 0) {
|
|
153
|
+
// A portion of this entry comes after the deletion range, so we reinsert that portion.
|
|
154
|
+
this.tree.set(this.offsetKey(lastDeleteKey, 1), { length: lengthAfter, value });
|
|
155
|
+
}
|
|
136
156
|
}
|
|
137
157
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return;
|
|
158
|
+
clone() {
|
|
159
|
+
const cloned = new RangeMap(this.offsetKey, this.subtractKeys);
|
|
160
|
+
cloned.tree = this.tree.clone();
|
|
161
|
+
return cloned;
|
|
142
162
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Returns a new map which contains the entries from both input maps.
|
|
165
|
+
*/
|
|
166
|
+
static union(a, b) {
|
|
167
|
+
(0, internal_1.assert)(a.offsetKey === b.offsetKey && a.subtractKeys === b.subtractKeys, 0xaae /* Maps should have the same behavior */);
|
|
168
|
+
const merged = new RangeMap(a.offsetKey, a.subtractKeys);
|
|
169
|
+
// TODO: Is there a good pattern that lets us make `tree` readonly?
|
|
170
|
+
merged.tree = a.tree.clone();
|
|
171
|
+
for (const [key, value] of b.tree.entries()) {
|
|
172
|
+
// TODO: Handle key collisions
|
|
173
|
+
merged.tree.set(key, value);
|
|
153
174
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
return merged;
|
|
176
|
+
}
|
|
177
|
+
getIntersectingEntries(start, length) {
|
|
178
|
+
const entries = [];
|
|
179
|
+
const lastQueryKey = this.offsetKey(start, length - 1);
|
|
180
|
+
{
|
|
181
|
+
const entry = this.tree.getPairOrNextLower(start);
|
|
182
|
+
if (entry !== undefined) {
|
|
183
|
+
const key = entry[0];
|
|
184
|
+
const { length: entryLength, value } = entry[1];
|
|
185
|
+
const lastEntryKey = this.offsetKey(key, entryLength - 1);
|
|
186
|
+
if (this.ge(lastEntryKey, start)) {
|
|
187
|
+
entries.push({ start: key, length: entryLength, value });
|
|
188
|
+
}
|
|
161
189
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
190
|
+
}
|
|
191
|
+
{
|
|
192
|
+
let entry = this.tree.nextHigherPair(start);
|
|
193
|
+
while (entry !== undefined) {
|
|
194
|
+
const key = entry[0];
|
|
195
|
+
if (this.gt(key, lastQueryKey)) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
const { length: entryLength, value } = entry[1];
|
|
199
|
+
const lastEntryKey = this.offsetKey(key, entryLength - 1);
|
|
200
|
+
entries.push({ start: key, length: entryLength, value });
|
|
201
|
+
entry = this.tree.nextHigherPair(lastEntryKey);
|
|
171
202
|
}
|
|
172
203
|
}
|
|
204
|
+
return entries;
|
|
173
205
|
}
|
|
206
|
+
gt(a, b) {
|
|
207
|
+
return this.subtractKeys(a, b) > 0;
|
|
208
|
+
}
|
|
209
|
+
ge(a, b) {
|
|
210
|
+
return this.subtractKeys(a, b) >= 0;
|
|
211
|
+
}
|
|
212
|
+
lt(a, b) {
|
|
213
|
+
return this.subtractKeys(a, b) < 0;
|
|
214
|
+
}
|
|
215
|
+
le(a, b) {
|
|
216
|
+
return this.subtractKeys(a, b) <= 0;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.RangeMap = RangeMap;
|
|
220
|
+
function newIntegerRangeMap() {
|
|
221
|
+
return new RangeMap(offsetInteger, subtractIntegers);
|
|
222
|
+
}
|
|
223
|
+
exports.newIntegerRangeMap = newIntegerRangeMap;
|
|
224
|
+
function offsetInteger(key, offset) {
|
|
225
|
+
return key + offset;
|
|
226
|
+
}
|
|
227
|
+
function subtractIntegers(a, b) {
|
|
228
|
+
return a - b;
|
|
174
229
|
}
|
|
175
|
-
exports.deleteFromRangeMap = deleteFromRangeMap;
|
|
176
230
|
//# sourceMappingURL=rangeMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rangeMap.js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E,CAAC;YACjD,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACP,6EAA6E;YAC7E,IAAI,KAAK,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC;gBACzB,+EAA+E;gBAC/E,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;gBACzC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;gBAC5C,OAAO,GAAG,IAAI,CAAC;YAChB,CAAC;YAED,IAAI,YAAY,GAAG,GAAG,EAAE,CAAC;gBACxB,gFAAgF;gBAChF,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC;gBACzB,MAAM,SAAS,GAAG,YAAY,GAAG,GAAG,CAAC;gBACrC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;oBAChD,KAAK,EAAE,QAAQ;oBACf,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,KAAK,CAAC,KAAK;iBAClB,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAxDD,gDAwDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\n/**\n * A map keyed on integers allowing reading and writing contiguous ranges of integer keys.\n *\n * TODO: We should avoid the direct exposure of RangeEntry. AB#7414\n */\nexport type RangeMap<T> = RangeEntry<T>[];\n\nexport interface RangeEntry<T> {\n\tstart: number;\n\tlength: number;\n\tvalue: T;\n}\n\n/**\n * The result of a query about a range of keys.\n */\nexport interface RangeQueryResult<T> {\n\t/**\n\t * The value of the first key in the query range.\n\t */\n\tvalue: T | undefined;\n\n\t/**\n\t * The length of the prefix of the query range which have the same value.\n\t * For example, if a RangeMap has the same value for keys 5, 6, and 7,\n\t * a query about the range [5, 10] would give a result with length 3.\n\t */\n\tlength: number;\n}\n\n/**\n * See comments on `RangeQueryResult`.\n */\nexport function getFromRangeMap<T>(\n\tmap: RangeMap<T>,\n\tstart: number,\n\tlength: number,\n): RangeQueryResult<T> {\n\tfor (const range of map) {\n\t\tif (range.start > start) {\n\t\t\treturn { value: undefined, length: Math.min(range.start - start, length) };\n\t\t}\n\n\t\tconst lastRangeKey = range.start + range.length - 1;\n\t\tif (lastRangeKey >= start) {\n\t\t\t// This range contains `start`.\n\t\t\tconst overlapLength = lastRangeKey - start + 1;\n\t\t\treturn { value: range.value, length: Math.min(overlapLength, length) };\n\t\t}\n\t}\n\n\t// There were no entries intersecting the query range, so the entire query range has undefined value.\n\treturn { value: undefined, length };\n}\n\nexport function getFirstEntryFromRangeMap<T>(\n\tmap: RangeMap<T>,\n\tstart: number,\n\tlength: number,\n): RangeEntry<T> | undefined {\n\tconst lastQueryKey = start + length - 1;\n\tfor (const range of map) {\n\t\tif (range.start > lastQueryKey) {\n\t\t\t// We've passed the end of the query range.\n\t\t\tbreak;\n\t\t}\n\n\t\tconst lastRangeKey = range.start + range.length - 1;\n\t\tif (lastRangeKey >= start) {\n\t\t\treturn range;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Sets the keys from `start` to `start + length - 1` to `value`.\n */\nexport function setInRangeMap<T>(\n\tmap: RangeMap<T>,\n\tstart: number,\n\tlength: number,\n\tvalue: T,\n): void {\n\tconst end = start + length - 1;\n\tconst newEntry: RangeEntry<T> = { start, length, value };\n\n\tlet iBefore = -1;\n\tlet iAfter = map.length;\n\tfor (const [i, entry] of map.entries()) {\n\t\tconst entryLastKey = entry.start + entry.length - 1;\n\t\tif (entryLastKey < start) {\n\t\t\tiBefore = i;\n\t\t} else if (entry.start > end) {\n\t\t\tiAfter = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst numOverlappingEntries = iAfter - iBefore - 1;\n\tif (numOverlappingEntries === 0) {\n\t\tmap.splice(iAfter, 0, newEntry);\n\t\treturn;\n\t}\n\n\tconst iFirst = iBefore + 1;\n\tconst firstEntry = map[iFirst] ?? oob();\n\tconst iLast = iAfter - 1;\n\tconst lastEntry = map[iLast] ?? oob();\n\tconst lengthBeforeFirst = start - firstEntry.start;\n\tconst lastEntryKey = lastEntry.start + lastEntry.length - 1;\n\tconst lengthAfterLast = lastEntryKey - end;\n\n\tif (lengthBeforeFirst > 0 && lengthAfterLast > 0 && iFirst === iLast) {\n\t\t// The new entry fits in the middle of an existing entry.\n\t\t// We replace the existing entry with:\n\t\t// 1) the portion which comes before `newEntry`\n\t\t// 2) `newEntry`\n\t\t// 3) the portion which comes after `newEntry`\n\t\tmap.splice(iFirst, 1, { ...firstEntry, length: lengthBeforeFirst }, newEntry, {\n\t\t\t...lastEntry,\n\t\t\tstart: end + 1,\n\t\t\tlength: lengthAfterLast,\n\t\t});\n\t\treturn;\n\t}\n\n\tif (lengthBeforeFirst > 0) {\n\t\tmap[iFirst] = { ...firstEntry, length: lengthBeforeFirst };\n\n\t\t// The entry at `iFirst` is no longer overlapping with `newEntry`.\n\t\tiBefore = iFirst;\n\t}\n\n\tif (lengthAfterLast > 0) {\n\t\tmap[iLast] = {\n\t\t\t...lastEntry,\n\t\t\tstart: end + 1,\n\t\t\tlength: lengthAfterLast,\n\t\t};\n\n\t\t// The entry at `iLast` is no longer overlapping with `newEntry`.\n\t\tiAfter = iLast;\n\t}\n\n\tconst numContainedEntries = iAfter - iBefore - 1;\n\tmap.splice(iBefore + 1, numContainedEntries, newEntry);\n}\n\n/**\n * Delete the keys from `start` to `start + length - 1`\n *\n * 1. If an entry is completely included in the deletion range, the whole entry will be deleted\n * e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]\n * map becomes [[1, 2]] after deletion\n * (Note: the notation [a, b] represents start = a, end = b for simpler visiualization, instead of `b`\n * representing the length)\n *\n * 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted\n * e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]\n * map becomes [[1, 1], [5, 6]] after deletion\n *\n * 3. If an entry completely includes the deletion range, the original entry may be split into two.\n * e.g.: map = [[1, 6]], delete range: [2, 4]\n * map becomes [[1, 1], [5, 6]]\n *\n * TODO: We may find ways to mitigate the code duplication between set and delete, and we need to better\n * document the API. AB#7413\n */\nexport function deleteFromRangeMap<T>(map: RangeMap<T>, start: number, length: number): void {\n\tconst end = start + length - 1;\n\n\tlet iBefore = -1;\n\tlet iAfter = map.length;\n\n\tfor (const [i, entry] of map.entries()) {\n\t\tconst entryLastKey = entry.start + entry.length - 1;\n\t\tif (entryLastKey < start) {\n\t\t\tiBefore = i;\n\t\t} else if (entry.start > end) {\n\t\t\tiAfter = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst numOverlappingEntries = iAfter - iBefore - 1;\n\n\tif (numOverlappingEntries === 0) {\n\t\t// No entry will be removed\n\t\treturn;\n\t}\n\n\tconst iFirst = iBefore + 1;\n\tconst iLast = iAfter - 1;\n\n\t// Update or remove the overlapping entries\n\tfor (let i = iFirst; i <= iLast; ++i) {\n\t\tconst entry = map[i] ?? oob();\n\t\tconst entryLastKey = entry.start + entry.length - 1;\n\t\tlet isDirty = false;\n\n\t\t// If the entry lies within the range to be deleted, remove it\n\t\tif (entry.start >= start && entryLastKey <= end) {\n\t\t\tmap.splice(i, 1);\n\t\t} else {\n\t\t\t// If the entry partially or completely overlaps with the range to be deleted\n\t\t\tif (entry.start < start) {\n\t\t\t\t// Update the endpoint and length of the portion before the range to be deleted\n\t\t\t\tconst lengthBefore = start - entry.start;\n\t\t\t\tmap[i] = { ...entry, length: lengthBefore };\n\t\t\t\tisDirty = true;\n\t\t\t}\n\n\t\t\tif (entryLastKey > end) {\n\t\t\t\t// Update the startpoint and length of the portion after the range to be deleted\n\t\t\t\tconst newStart = end + 1;\n\t\t\t\tconst newLength = entryLastKey - end;\n\t\t\t\tmap.splice(isDirty ? i + 1 : i, isDirty ? 0 : 1, {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tlength: newLength,\n\t\t\t\t\tvalue: entry.value,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rangeMap.js","sourceRoot":"","sources":["../../src/util/rangeMap.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAClE,gEAAkD;AAElD;;;;;;GAMG;AACH,MAAa,QAAQ;IAGpB;;;;;;;;OAQG;IACH,YACkB,SAAwC,EACxC,YAAoC;QADpC,cAAS,GAAT,SAAS,CAA+B;QACxC,iBAAY,GAAZ,YAAY,CAAwB;QAErD,IAAI,CAAC,IAAI,GAAG,IAAI,wBAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,OAAO;QACb,MAAM,OAAO,GAA4B,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,KAAQ,EAAE,MAAc;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC;QAChB,CAAC;QAED,MAAM,UAAU,G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E,CAAC,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAEO,EAAE,CAAC,CAAI,EAAE,CAAI;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAEO,EAAE,CAAC,CAAI,EAAE,CAAI;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACD;AA/OD,4BA+OC;AA4CD,SAAgB,kBAAkB;IACjC,OAAO,IAAI,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AACtD,CAAC;AAFD,gDAEC;AAED,SAAS,aAAa,CAAC,GAAW,EAAE,MAAc;IACjD,OAAO,GAAG,GAAG,MAAM,CAAC;AACrB,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAS,EAAE,CAAS;IAC7C,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\n/**\n * RangeMap represents a mapping from keys of type K to values of type V or undefined.\n * The set of all possible keys is assumed to be fully ordered,\n * and for each key there should be a single next higher key.\n * The values for a range of consecutive keys can be changed or queried in a single operation.\n * The structure of the keys is described by the `offsetKey` and `subtractKeys` functions provided in the constructor.\n */\nexport class RangeMap<K, V> {\n\tprivate tree: BTree<K, RangeEntry<V>>;\n\n\t/**\n\t * @param offsetKey - Function which returns a new key which is `offset` keys after `key`.\n\t * When `offset` is negative, the returned key should come before `key`.\n\t *\n\t * @param subtractKeys - Function which returns the difference between `b` and `a`.\n\t * Offsetting `b` by this difference should return `a`.\n\t * The difference can be infinite if `a` cannot be reached from `b` by offsetting,\n\t * but the difference should still be positive if `a` is larger than `b` and negative if smaller.\n\t */\n\tpublic constructor(\n\t\tprivate readonly offsetKey: (key: K, offset: number) => K,\n\t\tprivate readonly subtractKeys: (a: K, b: K) => number,\n\t) {\n\t\tthis.tree = new BTree(undefined, subtractKeys);\n\t}\n\n\t/**\n\t * Retrieves all entries from the RangeMap.\n\t */\n\tpublic entries(): RangeQueryEntry<K, V>[] {\n\t\tconst entries: RangeQueryEntry<K, V>[] = [];\n\t\tfor (const [start, entry] of this.tree.entries()) {\n\t\t\tentries.push({ start, length: entry.length, value: entry.value });\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\tpublic clear(): void {\n\t\tthis.tree.clear();\n\t}\n\n\t/**\n\t * Retrieves the values for all keys in the query range.\n\t *\n\t * @param start - The first key in the range being queried\n\t * @param length - The length of the query range\n\t * @returns A list of entries, each describing the value for some subrange of the query.\n\t * The entries are in the same order as the keys, and there is an entry for every key with a non `undefined` value.\n\t */\n\tpublic getAll(start: K, length: number): RangeQueryEntry<K, V>[] {\n\t\tconst entries = this.getIntersectingEntries(start, length);\n\t\tif (entries.length === 0) {\n\t\t\treturn entries;\n\t\t}\n\n\t\tconst firstEntry = entries[0] ?? oob();\n\t\tconst lengthBefore = this.subtractKeys(start, firstEntry.start);\n\t\tif (lengthBefore > 0) {\n\t\t\tentries[0] = { ...firstEntry, start, length: firstEntry.length - lengthBefore };\n\t\t}\n\n\t\tconst lastEntry = entries[entries.length - 1] ?? oob();\n\t\tconst lastEntryKey = this.offsetKey(lastEntry.start, lastEntry.length - 1);\n\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\tconst lengthAfter = this.subtractKeys(lastEntryKey, lastQueryKey);\n\t\tif (lengthAfter > 0) {\n\t\t\tentries[entries.length - 1] = { ...lastEntry, length: lastEntry.length - lengthAfter };\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\t/**\n\t * Retrieves the value for some prefix of the query range.\n\t *\n\t * @param start - The first key in the query range.\n\t * @param length - The length of the query range.\n\t * @returns A RangeQueryResult containing the value associated with `start`,\n\t * and the number of consecutive keys with that same value (at least 1, at most `length`).\n\t */\n\tpublic getFirst(start: K, length: number): RangeQueryResult<K, V> {\n\t\t{\n\t\t\t// We first check for an entry with a key less than or equal to `start`.\n\t\t\tconst entry = this.tree.getPairOrNextLower(start);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst entryKey = entry[0];\n\t\t\t\tconst { value, length: entryLength } = entry[1];\n\n\t\t\t\tconst entryLastKey = this.offsetKey(entryKey, entryLength - 1);\n\t\t\t\tconst overlappingLength = Math.min(this.subtractKeys(entryLastKey, start) + 1, length);\n\t\t\t\tif (overlappingLength > 0) {\n\t\t\t\t\treturn { value, start, length: overlappingLength };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\t// There is no value associated with `start`.\n\t\t\t// Now we need to determine how many of the following keys are also undefined.\n\t\t\tconst key = this.tree.nextHigherKey(start);\n\t\t\tif (key !== undefined) {\n\t\t\t\tconst entryKey = key;\n\n\t\t\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\t\t\tif (this.le(entryKey, lastQueryKey)) {\n\t\t\t\t\treturn { value: undefined, start, length: this.subtractKeys(entryKey, start) };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { value: undefined, start, length };\n\t\t}\n\t}\n\n\t/**\n\t * Sets the value for a specified range.\n\t *\n\t * @param start - The first key in the range being set.\n\t * @param length - The length of the range.\n\t * @param value - The value to associate with the range.\n\t */\n\tpublic set(start: K, length: number, value: V | undefined): void {\n\t\tthis.delete(start, length);\n\t\tif (value !== undefined) {\n\t\t\tthis.tree.set(start, { value, length });\n\t\t}\n\t}\n\n\t/**\n\t * Deletes values within a specified range, updating or removing existing entries.\n\t *\n\t * 1. If an entry is completely included in the deletion range, the whole entry will be deleted\n\t * e.g.: map = [[1, 2], [4, 6]], delete range: [3, 6]\n\t * map becomes [[1, 2]] after deletion\n\t * (Note: the notation [a, b] represents start = a, end = b for simpler visualization, instead of `b`\n\t * representing the length)\n\t *\n\t * 2. If an entry is partially overlapped with the deletion range, the start or end point will be shifted\n\t * e.g.: map = [[1, 2], [4, 6]], delete range: [2, 4]\n\t * map becomes [[1, 1], [5, 6]] after deletion\n\t *\n\t * 3. If an entry completely includes the deletion range, the original entry may be split into two.\n\t * e.g.: map = [[1, 6]], delete range: [2, 4]\n\t * map becomes [[1, 1], [5, 6]]\n\t *\n\t * @param start - The start of the range to delete (inclusive).\n\t * @param length - The length of the range to delete.\n\t */\n\tpublic delete(start: K, length: number): void {\n\t\tconst lastDeleteKey = this.offsetKey(start, length - 1);\n\t\tfor (const { start: key, length: entryLength, value } of this.getIntersectingEntries(\n\t\t\tstart,\n\t\t\tlength,\n\t\t)) {\n\t\t\tthis.tree.delete(key);\n\t\t\tconst lengthBefore = this.subtractKeys(start, key);\n\t\t\tif (lengthBefore > 0) {\n\t\t\t\t// A portion of this entry comes before the deletion range, so we reinsert that portion.\n\t\t\t\tthis.tree.set(key, { length: lengthBefore, value });\n\t\t\t}\n\n\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\t\t\tconst lengthAfter = this.subtractKeys(lastEntryKey, lastDeleteKey);\n\t\t\tif (lengthAfter > 0) {\n\t\t\t\t// A portion of this entry comes after the deletion range, so we reinsert that portion.\n\t\t\t\tthis.tree.set(this.offsetKey(lastDeleteKey, 1), { length: lengthAfter, value });\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic clone(): RangeMap<K, V> {\n\t\tconst cloned = new RangeMap<K, V>(this.offsetKey, this.subtractKeys);\n\t\tcloned.tree = this.tree.clone();\n\t\treturn cloned;\n\t}\n\n\t/**\n\t * Returns a new map which contains the entries from both input maps.\n\t */\n\tpublic static union<K, V>(a: RangeMap<K, V>, b: RangeMap<K, V>): RangeMap<K, V> {\n\t\tassert(\n\t\t\ta.offsetKey === b.offsetKey && a.subtractKeys === b.subtractKeys,\n\t\t\t0xaae /* Maps should have the same behavior */,\n\t\t);\n\n\t\tconst merged = new RangeMap<K, V>(a.offsetKey, a.subtractKeys);\n\n\t\t// TODO: Is there a good pattern that lets us make `tree` readonly?\n\t\tmerged.tree = a.tree.clone();\n\t\tfor (const [key, value] of b.tree.entries()) {\n\t\t\t// TODO: Handle key collisions\n\t\t\tmerged.tree.set(key, value);\n\t\t}\n\n\t\treturn merged;\n\t}\n\n\tprivate getIntersectingEntries(start: K, length: number): RangeQueryEntry<K, V>[] {\n\t\tconst entries: RangeQueryEntry<K, V>[] = [];\n\t\tconst lastQueryKey = this.offsetKey(start, length - 1);\n\t\t{\n\t\t\tconst entry = this.tree.getPairOrNextLower(start);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst key = entry[0];\n\t\t\t\tconst { length: entryLength, value } = entry[1];\n\t\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\t\t\t\tif (this.ge(lastEntryKey, start)) {\n\t\t\t\t\tentries.push({ start: key, length: entryLength, value });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\tlet entry = this.tree.nextHigherPair(start);\n\t\t\twhile (entry !== undefined) {\n\t\t\t\tconst key = entry[0];\n\t\t\t\tif (this.gt(key, lastQueryKey)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst { length: entryLength, value } = entry[1];\n\t\t\t\tconst lastEntryKey = this.offsetKey(key, entryLength - 1);\n\n\t\t\t\tentries.push({ start: key, length: entryLength, value });\n\t\t\t\tentry = this.tree.nextHigherPair(lastEntryKey);\n\t\t\t}\n\t\t}\n\n\t\treturn entries;\n\t}\n\n\tprivate gt(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) > 0;\n\t}\n\n\tprivate ge(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) >= 0;\n\t}\n\n\tprivate lt(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) < 0;\n\t}\n\n\tprivate le(a: K, b: K): boolean {\n\t\treturn this.subtractKeys(a, b) <= 0;\n\t}\n}\n\n/**\n * Represents a contiguous range of values in the RangeMap.\n */\ninterface RangeEntry<V> {\n\t/**\n\t * The length of the range.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The value associated with this range.\n\t */\n\treadonly value: V;\n}\n\n/**\n * Describes the result of a range query, including the value and length of the matching prefix.\n */\nexport interface RangeQueryResult<K, V> {\n\t/**\n\t * The key for the first element in the range.\n\t */\n\treadonly start: K;\n\n\t/**\n\t * The value of the first key in the query range.\n\t * If no matching range is found, this will be undefined.\n\t */\n\treadonly value: V | undefined;\n\n\t/**\n\t * The length of the prefix of the query range which has the same value.\n\t * For example, if a RangeMap has the same value for keys 5, 6, and 7,\n\t * a query about the range [5, 10] would give a result with length 3.\n\t */\n\treadonly length: number;\n}\n\nexport interface RangeQueryEntry<K, V> extends RangeQueryResult<K, V> {\n\treadonly value: V;\n}\n\nexport function newIntegerRangeMap<V>(): RangeMap<number, V> {\n\treturn new RangeMap(offsetInteger, subtractIntegers);\n}\n\nfunction offsetInteger(key: number, offset: number): number {\n\treturn key + offset;\n}\n\nfunction subtractIntegers(a: number, b: number): number {\n\treturn a - b;\n}\n"]}
|
package/dist/util/utils.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface MapGetSet<K, V> {
|
|
|
11
11
|
set(key: K, value: V): void;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Make all transitive properties in T readonly
|
|
14
|
+
* Make all transitive properties in `T` readonly
|
|
15
15
|
*/
|
|
16
16
|
export type RecursiveReadonly<T> = {
|
|
17
17
|
readonly [P in keyof T]: RecursiveReadonly<T[P]>;
|
|
@@ -38,8 +38,11 @@ export type Populated<T> = {
|
|
|
38
38
|
export declare function asMutable<T>(readonly: T): Mutable<T>;
|
|
39
39
|
export declare const clone: typeof structuredClone;
|
|
40
40
|
/**
|
|
41
|
+
* Throw an error with a constant message.
|
|
42
|
+
* @remarks
|
|
43
|
+
* Works like {@link @fluidframework/core-utils/internal#assert}.
|
|
41
44
|
*/
|
|
42
|
-
export declare function fail(message: string): never;
|
|
45
|
+
export declare function fail(message: string | number): never;
|
|
43
46
|
/**
|
|
44
47
|
* Checks whether or not the given object is a `readonly` array.
|
|
45
48
|
*
|
|
@@ -308,4 +311,25 @@ export declare function compareStrings<T extends string>(a: T, b: T): number;
|
|
|
308
311
|
export declare function defineLazyCachedProperty<T extends object, K extends string | number | symbol, V>(obj: T, key: K, get: () => V): typeof obj & {
|
|
309
312
|
[P in K]: V;
|
|
310
313
|
};
|
|
314
|
+
/**
|
|
315
|
+
* Copies a given property from one object to another if and only if the property is defined.
|
|
316
|
+
* @param source - The object to copy the property from.
|
|
317
|
+
* If `source` is undefined or does not have the property defined, then this function will do nothing.
|
|
318
|
+
* @param property - The property to copy.
|
|
319
|
+
* @param destination - The object to copy the property to.
|
|
320
|
+
* @remarks This function is useful for copying properties from one object to another while minimizing the presence of `undefined` values.
|
|
321
|
+
* 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`.
|
|
322
|
+
* This is different from doing `destination.foo = source.foo`, which would define a `"foo"` property on `destination` with the value `undefined`.
|
|
323
|
+
*
|
|
324
|
+
* 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.
|
|
325
|
+
*
|
|
326
|
+
* 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.
|
|
327
|
+
* @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.
|
|
328
|
+
*/
|
|
329
|
+
export declare function copyPropertyIfDefined<S extends object, K extends keyof S, D extends object>(source: S | undefined, property: K, destination: D): asserts destination is K extends keyof S ? D & {
|
|
330
|
+
[P in K]: S[K];
|
|
331
|
+
} : D;
|
|
332
|
+
export declare function copyPropertyIfDefined<S extends object, K extends string | number | symbol, D extends object>(source: S | undefined, property: K, destination: D): asserts destination is K extends keyof S ? D & {
|
|
333
|
+
[P in K]: S[K];
|
|
334
|
+
} : D;
|
|
311
335
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/util/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,eAAe,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC;IAC9B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACxE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEpD;AAED,eAAO,MAAM,KAAK,wBAAkB,CAAC;AAErC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,eAAe,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,W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,EACX,WAAW,EAAE,CAAC,GACZ,OAAO,CAAC,WAAW,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,CAAC,CAAC"}
|
package/dist/util/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.defineLazyCachedProperty = exports.compareStrings = exports.capitalize = exports.disposeSymbol = exports.compareNamed = exports.oneFromSet = exports.invertMap = exports.transformObjectMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.assertValidRangeIndices = exports.isJsonObject = exports.JsonCompatibleReadOnlySchema = exports.count = exports.find = exports.filterIterable = exports.mapIterable = exports.getOrAddEmptyToMap = exports.getOrCreate = exports.compareSets = exports.hasSingle = exports.hasSome = exports.getLast = exports.makeArray = exports.isReadonlyArray = exports.fail = exports.clone = exports.asMutable = void 0;
|
|
10
|
+
exports.copyPropertyIfDefined = exports.defineLazyCachedProperty = exports.compareStrings = exports.capitalize = exports.disposeSymbol = exports.compareNamed = exports.oneFromSet = exports.invertMap = exports.transformObjectMap = exports.objectToMap = exports.assertNonNegativeSafeInteger = exports.assertValidRange = exports.assertValidIndex = exports.assertValidRangeIndices = exports.isJsonObject = exports.JsonCompatibleReadOnlySchema = exports.count = exports.find = exports.filterIterable = exports.mapIterable = exports.getOrAddEmptyToMap = exports.getOrCreate = exports.compareSets = exports.hasSingle = exports.hasSome = exports.getLast = exports.makeArray = exports.isReadonlyArray = exports.fail = exports.clone = exports.asMutable = void 0;
|
|
11
11
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
12
12
|
const typebox_1 = require("@sinclair/typebox");
|
|
13
13
|
const structured_clone_1 = __importDefault(require("@ungap/structured-clone"));
|
|
@@ -23,9 +23,15 @@ function asMutable(readonly) {
|
|
|
23
23
|
exports.asMutable = asMutable;
|
|
24
24
|
exports.clone = structured_clone_1.default;
|
|
25
25
|
/**
|
|
26
|
+
* Throw an error with a constant message.
|
|
27
|
+
* @remarks
|
|
28
|
+
* Works like {@link @fluidframework/core-utils/internal#assert}.
|
|
26
29
|
*/
|
|
27
30
|
function fail(message) {
|
|
28
|
-
|
|
31
|
+
// Declaring this here aliased to a different name avoids the assert tagging objecting to the usages of `assert` below.
|
|
32
|
+
// Since users of `fail` do the assert message tagging instead, suppressing tagging errors here makes sense.
|
|
33
|
+
const assertNoTag = internal_1.assert;
|
|
34
|
+
assertNoTag(false, message);
|
|
29
35
|
}
|
|
30
36
|
exports.fail = fail;
|
|
31
37
|
/**
|
|
@@ -376,4 +382,13 @@ function defineLazyCachedProperty(obj, key, get) {
|
|
|
376
382
|
return obj;
|
|
377
383
|
}
|
|
378
384
|
exports.defineLazyCachedProperty = defineLazyCachedProperty;
|
|
385
|
+
function copyPropertyIfDefined(source, property, destination) {
|
|
386
|
+
if (source !== undefined) {
|
|
387
|
+
const value = source[property];
|
|
388
|
+
if (value !== undefined) {
|
|
389
|
+
destination[property] = value;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
exports.copyPropertyIfDefined = copyPropertyIfDefined;
|
|
379
394
|
//# sourceMappingURL=utils.js.map
|