@fluidframework/tree 2.13.0 → 2.21.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 +22 -0
- package/api-report/tree.alpha.api.md +22 -12
- package/api-report/tree.beta.api.md +9 -5
- package/api-report/tree.legacy.alpha.api.md +15 -5
- package/api-report/tree.legacy.public.api.md +9 -5
- package/api-report/tree.public.api.md +9 -5
- package/assertTagging.config.mjs +14 -0
- package/dist/alpha.d.ts +3 -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/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/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 -9
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +19 -2
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.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 +4 -4
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +105 -199
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +11 -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.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.js +36 -4
- 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 +5 -2
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/index.d.ts +26 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +3 -1
- 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/shared-tree/index.d.ts +2 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +7 -2
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/publicContracts.d.ts +18 -0
- package/dist/shared-tree/publicContracts.d.ts.map +1 -0
- package/dist/shared-tree/publicContracts.js +24 -0
- package/dist/shared-tree/publicContracts.js.map +1 -0
- package/dist/shared-tree/sharedTree.d.ts +38 -18
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +41 -40
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +12 -8
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +2 -0
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +2 -0
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +4 -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/arrayNode.js +1 -1
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js +1 -1
- package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -2
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -6
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +10 -13
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/proxies.js +1 -1
- package/dist/simple-tree/proxies.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 +2 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +5 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/rangeMap.d.ts +61 -30
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +189 -117
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/utils.d.ts +4 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +7 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +3 -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/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/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 -9
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +19 -2
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.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 +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +74 -166
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +11 -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.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.js +36 -4
- 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 +6 -3
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/index.d.ts +26 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +3 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/index.d.ts +2 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/publicContracts.d.ts +18 -0
- package/lib/shared-tree/publicContracts.d.ts.map +1 -0
- package/lib/shared-tree/publicContracts.js +21 -0
- package/lib/shared-tree/publicContracts.js.map +1 -0
- package/lib/shared-tree/sharedTree.d.ts +38 -18
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +40 -39
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +13 -9
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +2 -0
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -0
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +4 -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/arrayNode.js +1 -1
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
- package/lib/simple-tree/core/getOrCreateNode.js +2 -2
- package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -6
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +9 -11
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/proxies.js +2 -2
- package/lib/simple-tree/proxies.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 +2 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/rangeMap.d.ts +61 -30
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +188 -117
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/utils.d.ts +4 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +7 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +25 -25
- 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/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/modular-schema/crossFieldQueries.ts +12 -13
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +21 -1
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +2 -2
- package/src/feature-libraries/modular-schema/index.ts +2 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +12 -11
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +138 -225
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +40 -27
- package/src/feature-libraries/optional-field/optionalField.ts +3 -3
- 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 +36 -4
- package/src/feature-libraries/treeCursorUtils.ts +10 -3
- package/src/index.ts +36 -6
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +9 -1
- package/src/shared-tree/publicContracts.ts +24 -0
- package/src/shared-tree/sharedTree.ts +63 -46
- package/src/shared-tree/treeCheckout.ts +19 -12
- package/src/simple-tree/api/schemaFactory.ts +2 -0
- package/src/simple-tree/api/tree.ts +4 -0
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/arrayNode.ts +1 -1
- package/src/simple-tree/core/getOrCreateNode.ts +6 -2
- package/src/simple-tree/core/index.ts +1 -1
- package/src/simple-tree/core/treeNodeKernel.ts +16 -14
- package/src/simple-tree/proxies.ts +2 -2
- 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 +3 -0
- package/src/util/rangeMap.ts +237 -143
- package/src/util/utils.ts +10 -3
- package/lib/package.json +0 -3
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { BTree } from "@tylerbu/sorted-btree-es6";
|
|
7
|
-
import { EditBuilder,
|
|
8
|
-
import { brand, fail, idAllocatorFromMaxId, idAllocatorFromState, getOrAddInMapLazy, } from "../../util/index.js";
|
|
7
|
+
import { EditBuilder, makeDetachedNodeId, mapCursorField, replaceAtomRevisions, revisionMetadataSourceFromInfo, areEqualChangeAtomIds, areEqualChangeAtomIdOpts, tagChange, makeAnonChange, newChangeAtomIdRangeMap, } from "../../core/index.js";
|
|
8
|
+
import { brand, fail, idAllocatorFromMaxId, idAllocatorFromState, getOrAddInMapLazy, newTupleBTree, mergeTupleBTrees, RangeMap, } from "../../util/index.js";
|
|
9
9
|
import { chunkFieldSingle, chunkTree, defaultChunkPolicy, } from "../chunked-forest/index.js";
|
|
10
10
|
import { cursorForMapTreeNode, mapTreeFromCursor } from "../mapTreeCursor.js";
|
|
11
11
|
import { CrossFieldTarget, getFirstFromCrossFieldMap, setInCrossFieldMap, } from "./crossFieldQueries.js";
|
|
12
12
|
import { NodeAttachState, } from "./fieldChangeHandler.js";
|
|
13
13
|
import { withEditor } from "./fieldKindWithEditor.js";
|
|
14
14
|
import { convertGenericChange, genericFieldKind } from "./genericFieldKind.js";
|
|
15
|
+
import { newCrossFieldKeyTable, } from "./modularChangeTypes.js";
|
|
15
16
|
/**
|
|
16
17
|
* Implementation of ChangeFamily which delegates work in a given field to the appropriate FieldKind
|
|
17
18
|
* as determined by the schema.
|
|
@@ -101,7 +102,7 @@ export class ModularChangeFamily {
|
|
|
101
102
|
nodeChanges: newTupleBTree(),
|
|
102
103
|
nodeToParent: newTupleBTree(),
|
|
103
104
|
nodeAliases: newTupleBTree(),
|
|
104
|
-
crossFieldKeys:
|
|
105
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
else if (hasConflicts(change1)) {
|
|
@@ -120,20 +121,20 @@ export class ModularChangeFamily {
|
|
|
120
121
|
// A collision for a node ID means that that node is referenced in both changesets
|
|
121
122
|
// (since we assume that if two changesets use the same node ID they are referring to the same node),
|
|
122
123
|
// therefore all collisions will be addressed when processing the intersection of the changesets.
|
|
123
|
-
const composedNodeChanges = brand(
|
|
124
|
-
const composedNodeToParent = brand(
|
|
125
|
-
const composedNodeAliases = brand(
|
|
124
|
+
const composedNodeChanges = brand(mergeTupleBTrees(change1.nodeChanges, change2.nodeChanges));
|
|
125
|
+
const composedNodeToParent = brand(mergeTupleBTrees(change1.nodeToParent, change2.nodeToParent));
|
|
126
|
+
const composedNodeAliases = brand(mergeTupleBTrees(change1.nodeAliases, change2.nodeAliases));
|
|
126
127
|
const crossFieldTable = newComposeTable(change1, change2, composedNodeToParent);
|
|
127
128
|
const composedFields = this.composeFieldMaps(change1.fieldChanges, change2.fieldChanges, undefined, genId, crossFieldTable, revisionMetadata);
|
|
128
129
|
this.composeInvalidatedElements(crossFieldTable, composedFields, composedNodeChanges, composedNodeToParent, composedNodeAliases, genId, revisionMetadata);
|
|
129
130
|
// Currently no field kinds require making changes to cross-field keys during composition, so we can just merge the two tables.
|
|
130
|
-
const composedCrossFieldKeys =
|
|
131
|
+
const composedCrossFieldKeys = RangeMap.union(change1.crossFieldKeys, change2.crossFieldKeys);
|
|
131
132
|
return {
|
|
132
133
|
fieldChanges: composedFields,
|
|
133
134
|
nodeChanges: composedNodeChanges,
|
|
134
135
|
nodeToParent: composedNodeToParent,
|
|
135
136
|
nodeAliases: composedNodeAliases,
|
|
136
|
-
crossFieldKeys:
|
|
137
|
+
crossFieldKeys: composedCrossFieldKeys,
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
140
|
composeInvalidatedField(fieldChange, crossFieldTable, genId, revisionMetadata) {
|
|
@@ -436,7 +437,7 @@ export class ModularChangeFamily {
|
|
|
436
437
|
baseToRebasedNodeId: newTupleBTree(),
|
|
437
438
|
rebasedFields: new Set(),
|
|
438
439
|
rebasedNodeToParent: brand(change.nodeToParent.clone()),
|
|
439
|
-
rebasedCrossFieldKeys:
|
|
440
|
+
rebasedCrossFieldKeys: change.crossFieldKeys.clone(),
|
|
440
441
|
nodeIdPairs: [],
|
|
441
442
|
affectedBaseFields: newTupleBTree(),
|
|
442
443
|
fieldsWithUnattachedChild: new Set(),
|
|
@@ -821,8 +822,8 @@ export class ModularChangeFamily {
|
|
|
821
822
|
populateCrossFieldKeyTableForFieldMap(table, fields, parent) {
|
|
822
823
|
for (const [fieldKey, fieldChange] of fields) {
|
|
823
824
|
const keys = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).getCrossFieldKeys(fieldChange.change);
|
|
824
|
-
for (const key of keys) {
|
|
825
|
-
table.set(key, { nodeId: parent, field: fieldKey });
|
|
825
|
+
for (const { key, count } of keys) {
|
|
826
|
+
table.set(key, count, { nodeId: parent, field: fieldKey });
|
|
826
827
|
}
|
|
827
828
|
}
|
|
828
829
|
}
|
|
@@ -861,7 +862,7 @@ export class ModularChangeFamily {
|
|
|
861
862
|
numChildren += 1;
|
|
862
863
|
}
|
|
863
864
|
for (const keyRange of handler.getCrossFieldKeys(fieldChange.change)) {
|
|
864
|
-
const fields = getFieldsForCrossFieldKey(change, keyRange);
|
|
865
|
+
const fields = getFieldsForCrossFieldKey(change, keyRange.key, keyRange.count);
|
|
865
866
|
assert(fields.length === 1 &&
|
|
866
867
|
fields[0] !== undefined &&
|
|
867
868
|
areEqualFieldIds(fields[0], fieldId), 0xa4f /* Inconsistent cross field keys */);
|
|
@@ -872,14 +873,15 @@ export class ModularChangeFamily {
|
|
|
872
873
|
}
|
|
873
874
|
ModularChangeFamily.emptyChange = makeModularChangeset();
|
|
874
875
|
function replaceCrossFieldKeyTableRevisions(table, oldRevisions, newRevision, nodeAliases) {
|
|
875
|
-
const updated =
|
|
876
|
-
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
876
|
+
const updated = newCrossFieldKeyTable();
|
|
877
|
+
for (const entry of table.entries()) {
|
|
878
|
+
const key = entry.start;
|
|
879
|
+
const updatedKey = {
|
|
880
|
+
target: key.target,
|
|
881
|
+
revision: replaceRevision(key.revision, oldRevisions, newRevision),
|
|
882
|
+
localId: key.localId,
|
|
883
|
+
};
|
|
884
|
+
const field = entry.value;
|
|
883
885
|
const normalizedFieldId = normalizeFieldId(field, nodeAliases);
|
|
884
886
|
const updatedNodeId = normalizedFieldId.nodeId !== undefined
|
|
885
887
|
? replaceAtomRevisions(normalizedFieldId.nodeId, oldRevisions, newRevision)
|
|
@@ -888,8 +890,8 @@ function replaceCrossFieldKeyTableRevisions(table, oldRevisions, newRevision, no
|
|
|
888
890
|
...normalizedFieldId,
|
|
889
891
|
nodeId: updatedNodeId,
|
|
890
892
|
};
|
|
891
|
-
updated.set(updatedKey, updatedValue);
|
|
892
|
-
}
|
|
893
|
+
updated.set(updatedKey, entry.length, updatedValue);
|
|
894
|
+
}
|
|
893
895
|
return updated;
|
|
894
896
|
}
|
|
895
897
|
function replaceRevision(revision, oldRevisions, newRevision) {
|
|
@@ -913,9 +915,9 @@ function composeBuildsDestroysAndRefreshers(change1, change2) {
|
|
|
913
915
|
// Note that it would in principle be possible to adopt the later build and exclude from the
|
|
914
916
|
// composition all the changes already reflected on the tree, but that is not something we
|
|
915
917
|
// care to support at this time.
|
|
916
|
-
const allBuilds = brand(
|
|
917
|
-
const allDestroys = brand(
|
|
918
|
-
const allRefreshers = brand(
|
|
918
|
+
const allBuilds = brand(mergeTupleBTrees(change1.builds ?? newTupleBTree(), change2.builds ?? newTupleBTree(), true));
|
|
919
|
+
const allDestroys = brand(mergeTupleBTrees(change1.destroys ?? newTupleBTree(), change2.destroys ?? newTupleBTree()));
|
|
920
|
+
const allRefreshers = brand(mergeTupleBTrees(change1.refreshers ?? newTupleBTree(), change2.refreshers ?? newTupleBTree(), true));
|
|
919
921
|
if (change1.destroys !== undefined && change2.builds !== undefined) {
|
|
920
922
|
for (const [key, chunk] of change2.builds.entries()) {
|
|
921
923
|
const destroyCount = change1.destroys.get(key);
|
|
@@ -1034,18 +1036,28 @@ export function updateRefreshers(change, getDetachedNode, removedRoots, requireR
|
|
|
1034
1036
|
});
|
|
1035
1037
|
}
|
|
1036
1038
|
/**
|
|
1039
|
+
* Converts a change into the delta format.
|
|
1040
|
+
*
|
|
1037
1041
|
* @param change - The change to convert into a delta.
|
|
1038
1042
|
* @param fieldKinds - The field kinds to delegate to.
|
|
1039
1043
|
*/
|
|
1040
1044
|
export function intoDelta(taggedChange, fieldKinds) {
|
|
1041
1045
|
const change = taggedChange.change;
|
|
1042
1046
|
const rootDelta = {};
|
|
1047
|
+
const global = [];
|
|
1048
|
+
const rename = [];
|
|
1043
1049
|
if (!hasConflicts(change)) {
|
|
1044
1050
|
// If there are no constraint violations, then tree changes apply.
|
|
1045
|
-
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges, fieldKinds);
|
|
1051
|
+
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges, fieldKinds, global, rename);
|
|
1046
1052
|
if (fieldDeltas.size > 0) {
|
|
1047
1053
|
rootDelta.fields = fieldDeltas;
|
|
1048
1054
|
}
|
|
1055
|
+
if (global.length > 0) {
|
|
1056
|
+
rootDelta.global = global;
|
|
1057
|
+
}
|
|
1058
|
+
if (rename.length > 0) {
|
|
1059
|
+
rootDelta.rename = rename;
|
|
1060
|
+
}
|
|
1049
1061
|
}
|
|
1050
1062
|
// Constraint violations should not prevent nodes from being built
|
|
1051
1063
|
if (change.builds && change.builds.size > 0) {
|
|
@@ -1082,22 +1094,24 @@ function copyDetachedNodes(detachedNodes) {
|
|
|
1082
1094
|
/**
|
|
1083
1095
|
* @param change - The change to convert into a delta.
|
|
1084
1096
|
*/
|
|
1085
|
-
function intoDeltaImpl(change, nodeChanges, fieldKinds) {
|
|
1097
|
+
function intoDeltaImpl(change, nodeChanges, fieldKinds, global, rename) {
|
|
1086
1098
|
const delta = new Map();
|
|
1087
1099
|
for (const [field, fieldChange] of change) {
|
|
1088
|
-
const
|
|
1100
|
+
const { local: fieldChanges, global: fieldGlobal, rename: fieldRename, } = getChangeHandler(fieldKinds, fieldChange.fieldKind).intoDelta(fieldChange.change, (childChange) => {
|
|
1089
1101
|
const nodeChange = nodeChangeFromId(nodeChanges, childChange);
|
|
1090
|
-
return deltaFromNodeChange(nodeChange, nodeChanges, fieldKinds);
|
|
1102
|
+
return deltaFromNodeChange(nodeChange, nodeChanges, fieldKinds, global, rename);
|
|
1091
1103
|
});
|
|
1092
|
-
if (
|
|
1093
|
-
delta.set(field,
|
|
1104
|
+
if (fieldChanges !== undefined && fieldChanges.length > 0) {
|
|
1105
|
+
delta.set(field, fieldChanges);
|
|
1094
1106
|
}
|
|
1107
|
+
fieldGlobal?.forEach((c) => global.push(c));
|
|
1108
|
+
fieldRename?.forEach((r) => rename.push(r));
|
|
1095
1109
|
}
|
|
1096
1110
|
return delta;
|
|
1097
1111
|
}
|
|
1098
|
-
function deltaFromNodeChange(change, nodeChanges, fieldKinds) {
|
|
1112
|
+
function deltaFromNodeChange(change, nodeChanges, fieldKinds, global, rename) {
|
|
1099
1113
|
if (change.fieldChanges !== undefined) {
|
|
1100
|
-
return intoDeltaImpl(change.fieldChanges, nodeChanges, fieldKinds);
|
|
1114
|
+
return intoDeltaImpl(change.fieldChanges, nodeChanges, fieldKinds, global, rename);
|
|
1101
1115
|
}
|
|
1102
1116
|
// TODO: update the API to allow undefined to be returned here
|
|
1103
1117
|
return new Map();
|
|
@@ -1163,10 +1177,10 @@ function newComposeTable(baseChange, newChange, composedNodeToParent) {
|
|
|
1163
1177
|
}
|
|
1164
1178
|
function newCrossFieldTable() {
|
|
1165
1179
|
return {
|
|
1166
|
-
srcTable:
|
|
1167
|
-
dstTable:
|
|
1168
|
-
srcDependents:
|
|
1169
|
-
dstDependents:
|
|
1180
|
+
srcTable: newChangeAtomIdRangeMap(),
|
|
1181
|
+
dstTable: newChangeAtomIdRangeMap(),
|
|
1182
|
+
srcDependents: newChangeAtomIdRangeMap(),
|
|
1183
|
+
dstDependents: newChangeAtomIdRangeMap(),
|
|
1170
1184
|
invalidatedFields: new Set(),
|
|
1171
1185
|
};
|
|
1172
1186
|
}
|
|
@@ -1237,19 +1251,17 @@ class RebaseManager extends CrossFieldManagerI {
|
|
|
1237
1251
|
}
|
|
1238
1252
|
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1239
1253
|
if (invalidateDependents && this.allowInval) {
|
|
1240
|
-
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange,
|
|
1254
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1241
1255
|
target,
|
|
1242
1256
|
revision,
|
|
1243
|
-
id,
|
|
1244
|
-
|
|
1245
|
-
]);
|
|
1257
|
+
localId: id,
|
|
1258
|
+
}, count);
|
|
1246
1259
|
assert(newFieldIds.length === 0, 0x9c6 /* TODO: Modifying a cross-field key from the new changeset is currently unsupported */);
|
|
1247
|
-
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange,
|
|
1260
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1248
1261
|
target,
|
|
1249
1262
|
revision,
|
|
1250
|
-
id,
|
|
1251
|
-
|
|
1252
|
-
]);
|
|
1263
|
+
localId: id,
|
|
1264
|
+
}, count);
|
|
1253
1265
|
assert(baseFieldIds.length > 0, 0x9c7 /* Cross field key not registered in base or new change */);
|
|
1254
1266
|
for (const baseFieldId of baseFieldIds) {
|
|
1255
1267
|
this.table.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
@@ -1261,7 +1273,7 @@ class RebaseManager extends CrossFieldManagerI {
|
|
|
1261
1273
|
setInChangeAtomIdMap(this.table.rebasedNodeToParent, id, this.fieldId);
|
|
1262
1274
|
}
|
|
1263
1275
|
moveKey(target, revision, id, count) {
|
|
1264
|
-
|
|
1276
|
+
this.table.rebasedCrossFieldKeys.set({ target, revision, localId: id }, count, this.fieldId);
|
|
1265
1277
|
}
|
|
1266
1278
|
get table() {
|
|
1267
1279
|
return this.crossFieldTable;
|
|
@@ -1275,24 +1287,22 @@ class ComposeManager extends CrossFieldManagerI {
|
|
|
1275
1287
|
}
|
|
1276
1288
|
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1277
1289
|
if (invalidateDependents && this.allowInval) {
|
|
1278
|
-
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange,
|
|
1290
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1279
1291
|
target,
|
|
1280
1292
|
revision,
|
|
1281
|
-
id,
|
|
1282
|
-
|
|
1283
|
-
]);
|
|
1293
|
+
localId: id,
|
|
1294
|
+
}, count);
|
|
1284
1295
|
if (newFieldIds.length > 0) {
|
|
1285
1296
|
for (const newFieldId of newFieldIds) {
|
|
1286
1297
|
this.table.pendingCompositions.affectedNewFields.set([newFieldId.nodeId?.revision, newFieldId.nodeId?.localId, newFieldId.field], true);
|
|
1287
1298
|
}
|
|
1288
1299
|
}
|
|
1289
1300
|
else {
|
|
1290
|
-
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange,
|
|
1301
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1291
1302
|
target,
|
|
1292
1303
|
revision,
|
|
1293
|
-
id,
|
|
1294
|
-
|
|
1295
|
-
]);
|
|
1304
|
+
localId: id,
|
|
1305
|
+
}, count);
|
|
1296
1306
|
assert(baseFieldIds.length > 0, 0x9c8 /* Cross field key not registered in base or new change */);
|
|
1297
1307
|
for (const baseFieldId of baseFieldIds) {
|
|
1298
1308
|
this.table.pendingCompositions.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
@@ -1486,8 +1496,8 @@ function buildModularChangesetFromField(props) {
|
|
|
1486
1496
|
const { path, fieldChange, nodeChanges, nodeToParent, crossFieldKeys, idAllocator = idAllocatorFromMaxId(), localCrossFieldKeys = [], childId, revision, } = props;
|
|
1487
1497
|
const fieldChanges = new Map([[path.field, fieldChange]]);
|
|
1488
1498
|
if (path.parent === undefined) {
|
|
1489
|
-
for (const key of localCrossFieldKeys) {
|
|
1490
|
-
crossFieldKeys.set(key, { nodeId: undefined, field: path.field });
|
|
1499
|
+
for (const { key, count } of localCrossFieldKeys) {
|
|
1500
|
+
crossFieldKeys.set(key, count, { nodeId: undefined, field: path.field });
|
|
1491
1501
|
}
|
|
1492
1502
|
if (childId !== undefined) {
|
|
1493
1503
|
setInChangeAtomIdMap(nodeToParent, childId, {
|
|
@@ -1508,8 +1518,8 @@ function buildModularChangesetFromField(props) {
|
|
|
1508
1518
|
fieldChanges,
|
|
1509
1519
|
};
|
|
1510
1520
|
const parentId = { localId: brand(idAllocator.allocate()), revision };
|
|
1511
|
-
for (const key of localCrossFieldKeys) {
|
|
1512
|
-
crossFieldKeys.set(key, { nodeId: parentId, field: path.field });
|
|
1521
|
+
for (const { key, count } of localCrossFieldKeys) {
|
|
1522
|
+
crossFieldKeys.set(key, count, { nodeId: parentId, field: path.field });
|
|
1513
1523
|
}
|
|
1514
1524
|
if (childId !== undefined) {
|
|
1515
1525
|
setInChangeAtomIdMap(nodeToParent, childId, {
|
|
@@ -1582,19 +1592,6 @@ function revisionInfoFromTaggedChange(taggedChange) {
|
|
|
1582
1592
|
}
|
|
1583
1593
|
return revInfos;
|
|
1584
1594
|
}
|
|
1585
|
-
function mergeBTrees(tree1, tree2, preferLeft = true) {
|
|
1586
|
-
if (tree1 === undefined) {
|
|
1587
|
-
return tree2 !== undefined ? brand(tree2.clone()) : newTupleBTree();
|
|
1588
|
-
}
|
|
1589
|
-
const result = brand(tree1.clone());
|
|
1590
|
-
if (tree2 === undefined) {
|
|
1591
|
-
return result;
|
|
1592
|
-
}
|
|
1593
|
-
for (const [key, value] of tree2.entries()) {
|
|
1594
|
-
result.set(key, value, !preferLeft);
|
|
1595
|
-
}
|
|
1596
|
-
return result;
|
|
1597
|
-
}
|
|
1598
1595
|
function fieldChangeFromId(fields, nodes, id) {
|
|
1599
1596
|
const fieldMap = fieldMapFromNodeId(fields, nodes, id.nodeId);
|
|
1600
1597
|
return fieldMap.get(id.field) ?? fail("No field exists for the given ID");
|
|
@@ -1645,72 +1642,13 @@ export function getParentFieldId(changeset, nodeId) {
|
|
|
1645
1642
|
assert(parentId !== undefined, 0x9cb /* Parent field should be defined */);
|
|
1646
1643
|
return normalizeFieldId(parentId, changeset.nodeAliases);
|
|
1647
1644
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
// eslint-disable-next-line no-constant-condition
|
|
1653
|
-
while (true) {
|
|
1654
|
-
const entry = getFirstIntersectingCrossFieldEntry(changeset.crossFieldKeys, [
|
|
1655
|
-
target,
|
|
1656
|
-
revision,
|
|
1657
|
-
brand(firstLocalId),
|
|
1658
|
-
count,
|
|
1659
|
-
]);
|
|
1660
|
-
if (entry === undefined) {
|
|
1661
|
-
return fields;
|
|
1662
|
-
}
|
|
1663
|
-
const [[_target, _revision, entryId, entryCount], fieldId] = entry;
|
|
1664
|
-
fields.push(normalizeFieldId(fieldId, changeset.nodeAliases));
|
|
1665
|
-
const entryLastId = entryId + entryCount - 1;
|
|
1666
|
-
if (entryLastId >= lastLocalId) {
|
|
1667
|
-
return fields;
|
|
1668
|
-
}
|
|
1669
|
-
firstLocalId = entryLastId + 1;
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
function getFirstIntersectingCrossFieldEntry(table, [target, revision, id, count]) {
|
|
1673
|
-
const entry = table.nextLowerPair([target, revision, id, Number.POSITIVE_INFINITY]);
|
|
1674
|
-
if (entry === undefined) {
|
|
1675
|
-
return undefined;
|
|
1676
|
-
}
|
|
1677
|
-
const [entryTarget, entryRevision, entryId, entryCount] = entry[0];
|
|
1678
|
-
if (entryTarget !== target || entryRevision !== revision) {
|
|
1679
|
-
return undefined;
|
|
1680
|
-
}
|
|
1681
|
-
const lastQueryId = id + count - 1;
|
|
1682
|
-
const entryLastId = entryId + entryCount - 1;
|
|
1683
|
-
if (entryId > lastQueryId || entryLastId < id) {
|
|
1684
|
-
return undefined;
|
|
1685
|
-
}
|
|
1686
|
-
return entry;
|
|
1687
|
-
}
|
|
1688
|
-
function setInCrossFieldKeyTable(table, target, revision, id, count, value) {
|
|
1689
|
-
let entry = getFirstIntersectingCrossFieldEntry(table, [target, revision, id, count]);
|
|
1690
|
-
const lastQueryId = id + count - 1;
|
|
1691
|
-
while (entry !== undefined) {
|
|
1692
|
-
const [entryKey, entryValue] = entry;
|
|
1693
|
-
table.delete(entryKey);
|
|
1694
|
-
const [_target, _revision, entryId, entryCount] = entryKey;
|
|
1695
|
-
if (entryId < id) {
|
|
1696
|
-
table.set([target, revision, entryId, id - entryId], entryValue);
|
|
1697
|
-
}
|
|
1698
|
-
const lastEntryId = entryId + entryCount - 1;
|
|
1699
|
-
if (lastEntryId > lastQueryId) {
|
|
1700
|
-
table.set([target, revision, brand(lastQueryId + 1), lastEntryId - lastQueryId], entryValue);
|
|
1701
|
-
break;
|
|
1702
|
-
}
|
|
1703
|
-
const nextId = brand(lastEntryId + 1);
|
|
1704
|
-
entry = getFirstIntersectingCrossFieldEntry(table, [
|
|
1705
|
-
target,
|
|
1706
|
-
revision,
|
|
1707
|
-
nextId,
|
|
1708
|
-
lastQueryId - nextId + 1,
|
|
1709
|
-
]);
|
|
1710
|
-
}
|
|
1711
|
-
table.set([target, revision, id, count], value);
|
|
1645
|
+
function getFieldsForCrossFieldKey(changeset, key, count) {
|
|
1646
|
+
return changeset.crossFieldKeys
|
|
1647
|
+
.getAll(key, count)
|
|
1648
|
+
.map(({ value: fieldId }) => normalizeFieldId(fieldId, changeset.nodeAliases));
|
|
1712
1649
|
}
|
|
1713
|
-
|
|
1650
|
+
// This is only exported for use in test utilities.
|
|
1651
|
+
export function normalizeFieldId(fieldId, nodeAliases) {
|
|
1714
1652
|
return fieldId.nodeId !== undefined
|
|
1715
1653
|
? { ...fieldId, nodeId: normalizeNodeId(fieldId.nodeId, nodeAliases) }
|
|
1716
1654
|
: fieldId;
|
|
@@ -1732,36 +1670,6 @@ function normalizeNodeId(nodeId, nodeAliases) {
|
|
|
1732
1670
|
function hasConflicts(change) {
|
|
1733
1671
|
return (change.constraintViolationCount ?? 0) > 0;
|
|
1734
1672
|
}
|
|
1735
|
-
export function newCrossFieldKeyTable() {
|
|
1736
|
-
return newTupleBTree();
|
|
1737
|
-
}
|
|
1738
|
-
export function newTupleBTree(entries) {
|
|
1739
|
-
return brand(new BTree(entries, compareTuples));
|
|
1740
|
-
}
|
|
1741
|
-
// This assumes that the arrays are the same length.
|
|
1742
|
-
function compareTuples(arrayA, arrayB) {
|
|
1743
|
-
for (let i = 0; i < arrayA.length; i++) {
|
|
1744
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1745
|
-
const a = arrayA[i];
|
|
1746
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1747
|
-
const b = arrayB[i];
|
|
1748
|
-
// Less-than and greater-than always return false if either value is undefined,
|
|
1749
|
-
// so we handle undefined separately, treating it as less than all other values.
|
|
1750
|
-
if (a === undefined && b !== undefined) {
|
|
1751
|
-
return -1;
|
|
1752
|
-
}
|
|
1753
|
-
else if (b === undefined && a !== undefined) {
|
|
1754
|
-
return 1;
|
|
1755
|
-
}
|
|
1756
|
-
else if (a < b) {
|
|
1757
|
-
return -1;
|
|
1758
|
-
}
|
|
1759
|
-
else if (a > b) {
|
|
1760
|
-
return 1;
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
return 0;
|
|
1764
|
-
}
|
|
1765
1673
|
function getFromChangeAtomIdMap(map, id) {
|
|
1766
1674
|
return map.get([id.revision, id.localId]);
|
|
1767
1675
|
}
|