@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
|
@@ -4,15 +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
|
-
import { MemoizedIdRangeAllocator } from "../memoizedIdRangeAllocator.js";
|
|
12
11
|
import { CrossFieldTarget, getFirstFromCrossFieldMap, setInCrossFieldMap, } from "./crossFieldQueries.js";
|
|
13
12
|
import { NodeAttachState, } from "./fieldChangeHandler.js";
|
|
14
13
|
import { withEditor } from "./fieldKindWithEditor.js";
|
|
15
14
|
import { convertGenericChange, genericFieldKind } from "./genericFieldKind.js";
|
|
15
|
+
import { newCrossFieldKeyTable, } from "./modularChangeTypes.js";
|
|
16
16
|
/**
|
|
17
17
|
* Implementation of ChangeFamily which delegates work in a given field to the appropriate FieldKind
|
|
18
18
|
* as determined by the schema.
|
|
@@ -102,7 +102,7 @@ export class ModularChangeFamily {
|
|
|
102
102
|
nodeChanges: newTupleBTree(),
|
|
103
103
|
nodeToParent: newTupleBTree(),
|
|
104
104
|
nodeAliases: newTupleBTree(),
|
|
105
|
-
crossFieldKeys:
|
|
105
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
else if (hasConflicts(change1)) {
|
|
@@ -121,20 +121,20 @@ export class ModularChangeFamily {
|
|
|
121
121
|
// A collision for a node ID means that that node is referenced in both changesets
|
|
122
122
|
// (since we assume that if two changesets use the same node ID they are referring to the same node),
|
|
123
123
|
// therefore all collisions will be addressed when processing the intersection of the changesets.
|
|
124
|
-
const composedNodeChanges = brand(
|
|
125
|
-
const composedNodeToParent = brand(
|
|
126
|
-
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));
|
|
127
127
|
const crossFieldTable = newComposeTable(change1, change2, composedNodeToParent);
|
|
128
128
|
const composedFields = this.composeFieldMaps(change1.fieldChanges, change2.fieldChanges, undefined, genId, crossFieldTable, revisionMetadata);
|
|
129
129
|
this.composeInvalidatedElements(crossFieldTable, composedFields, composedNodeChanges, composedNodeToParent, composedNodeAliases, genId, revisionMetadata);
|
|
130
130
|
// Currently no field kinds require making changes to cross-field keys during composition, so we can just merge the two tables.
|
|
131
|
-
const composedCrossFieldKeys =
|
|
131
|
+
const composedCrossFieldKeys = RangeMap.union(change1.crossFieldKeys, change2.crossFieldKeys);
|
|
132
132
|
return {
|
|
133
133
|
fieldChanges: composedFields,
|
|
134
134
|
nodeChanges: composedNodeChanges,
|
|
135
135
|
nodeToParent: composedNodeToParent,
|
|
136
136
|
nodeAliases: composedNodeAliases,
|
|
137
|
-
crossFieldKeys:
|
|
137
|
+
crossFieldKeys: composedCrossFieldKeys,
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
composeInvalidatedField(fieldChange, crossFieldTable, genId, revisionMetadata) {
|
|
@@ -300,7 +300,18 @@ export class ModularChangeFamily {
|
|
|
300
300
|
crossFieldTable.composedNodes.add(composedNodeChangeset);
|
|
301
301
|
}
|
|
302
302
|
composeNodeChanges(nodeId, change1, change2, genId, crossFieldTable, revisionMetadata) {
|
|
303
|
+
// WARNING: this composition logic assumes that we never make compositions of the following form:
|
|
304
|
+
// change1: a changeset that impact the existence of a node
|
|
305
|
+
// change2: a node-exists constraint on that node.
|
|
306
|
+
// This is currently enforced by the fact that constraints which apply to the input context are included first in the composition.
|
|
307
|
+
// If that weren't the case, we would need to rebase the status of the constraint backward over the changes from change1.
|
|
303
308
|
const nodeExistsConstraint = change1.nodeExistsConstraint ?? change2.nodeExistsConstraint;
|
|
309
|
+
// WARNING: this composition logic assumes that we never make compositions of the following form:
|
|
310
|
+
// change1: a node-exists-on-revert constraint on a node
|
|
311
|
+
// change2: a changeset that impacts the existence of that node
|
|
312
|
+
// This is currently enforced by the fact that constraints which apply to the revert are included last in the composition.
|
|
313
|
+
// If that weren't the case, we would need to rebase the status of the constraint forward over the changes from change2.
|
|
314
|
+
const nodeExistsConstraintOnRevert = change1.nodeExistsConstraintOnRevert ?? change2.nodeExistsConstraintOnRevert;
|
|
304
315
|
const composedFieldChanges = this.composeFieldMaps(change1.fieldChanges, change2.fieldChanges, nodeId, genId, crossFieldTable, revisionMetadata);
|
|
305
316
|
const composedNodeChange = {};
|
|
306
317
|
if (composedFieldChanges.size > 0) {
|
|
@@ -309,6 +320,9 @@ export class ModularChangeFamily {
|
|
|
309
320
|
if (nodeExistsConstraint !== undefined) {
|
|
310
321
|
composedNodeChange.nodeExistsConstraint = nodeExistsConstraint;
|
|
311
322
|
}
|
|
323
|
+
if (nodeExistsConstraintOnRevert !== undefined) {
|
|
324
|
+
composedNodeChange.nodeExistsConstraintOnRevert = nodeExistsConstraintOnRevert;
|
|
325
|
+
}
|
|
312
326
|
return composedNodeChange;
|
|
313
327
|
}
|
|
314
328
|
/**
|
|
@@ -366,7 +380,8 @@ export class ModularChangeFamily {
|
|
|
366
380
|
crossFieldKeys,
|
|
367
381
|
maxId: genId.getMaxId(),
|
|
368
382
|
revisions: revInfos,
|
|
369
|
-
constraintViolationCount: change.change.
|
|
383
|
+
constraintViolationCount: change.change.constraintViolationCountOnRevert,
|
|
384
|
+
constraintViolationCountOnRevert: change.change.constraintViolationCount,
|
|
370
385
|
destroys,
|
|
371
386
|
});
|
|
372
387
|
}
|
|
@@ -390,6 +405,17 @@ export class ModularChangeFamily {
|
|
|
390
405
|
}
|
|
391
406
|
invertNodeChange(change, id, isRollback, genId, crossFieldTable, revisionMetadata, revisionForInvert) {
|
|
392
407
|
const inverse = {};
|
|
408
|
+
// If the node has a constraint, it should be inverted to a node-exist-on-revert constraint. This ensure that if
|
|
409
|
+
// the inverse is inverted again, the original input constraint will be restored.
|
|
410
|
+
if (change.nodeExistsConstraint !== undefined) {
|
|
411
|
+
inverse.nodeExistsConstraintOnRevert = change.nodeExistsConstraint;
|
|
412
|
+
}
|
|
413
|
+
// The node-exist-on-revert constraint of a node is the constraint that should apply when the a change is reverted.
|
|
414
|
+
// So, it should become the constraint in the inverse. If this constraint is violated when applying the inverse,
|
|
415
|
+
// it will be discarded.
|
|
416
|
+
if (change.nodeExistsConstraintOnRevert !== undefined) {
|
|
417
|
+
inverse.nodeExistsConstraint = change.nodeExistsConstraintOnRevert;
|
|
418
|
+
}
|
|
393
419
|
if (change.fieldChanges !== undefined) {
|
|
394
420
|
inverse.fieldChanges = this.invertFieldMap(change.fieldChanges, id, isRollback, genId, crossFieldTable, revisionMetadata, revisionForInvert);
|
|
395
421
|
}
|
|
@@ -411,12 +437,11 @@ export class ModularChangeFamily {
|
|
|
411
437
|
baseToRebasedNodeId: newTupleBTree(),
|
|
412
438
|
rebasedFields: new Set(),
|
|
413
439
|
rebasedNodeToParent: brand(change.nodeToParent.clone()),
|
|
414
|
-
rebasedCrossFieldKeys:
|
|
440
|
+
rebasedCrossFieldKeys: change.crossFieldKeys.clone(),
|
|
415
441
|
nodeIdPairs: [],
|
|
416
442
|
affectedBaseFields: newTupleBTree(),
|
|
417
443
|
fieldsWithUnattachedChild: new Set(),
|
|
418
444
|
};
|
|
419
|
-
const constraintState = newConstraintState(change.constraintViolationCount ?? 0);
|
|
420
445
|
const getBaseRevisions = () => revisionInfoFromTaggedChange(over).map((info) => info.revision);
|
|
421
446
|
const rebaseMetadata = {
|
|
422
447
|
...revisionMetadata,
|
|
@@ -424,9 +449,11 @@ export class ModularChangeFamily {
|
|
|
424
449
|
getBaseRevisions,
|
|
425
450
|
};
|
|
426
451
|
const rebasedNodes = brand(change.nodeChanges.clone());
|
|
427
|
-
const rebasedFields = this.rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId,
|
|
452
|
+
const rebasedFields = this.rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId, rebaseMetadata);
|
|
428
453
|
this.rebaseInvalidatedElements(rebasedFields, rebasedNodes, crossFieldTable, rebaseMetadata, genId);
|
|
429
|
-
|
|
454
|
+
const constraintState = newConstraintState(change.constraintViolationCount ?? 0);
|
|
455
|
+
const revertConstraintState = newConstraintState(change.constraintViolationCountOnRevert ?? 0);
|
|
456
|
+
this.updateConstraintsForFields(rebasedFields, NodeAttachState.Attached, NodeAttachState.Attached, constraintState, revertConstraintState, rebasedNodes);
|
|
430
457
|
const rebased = makeModularChangeset({
|
|
431
458
|
fieldChanges: this.pruneFieldMap(rebasedFields, rebasedNodes),
|
|
432
459
|
nodeChanges: rebasedNodes,
|
|
@@ -436,6 +463,7 @@ export class ModularChangeFamily {
|
|
|
436
463
|
maxId: idState.maxId,
|
|
437
464
|
revisions: change.revisions,
|
|
438
465
|
constraintViolationCount: constraintState.violationCount,
|
|
466
|
+
constraintViolationCountOnRevert: revertConstraintState.violationCount,
|
|
439
467
|
builds: change.builds,
|
|
440
468
|
destroys: change.destroys,
|
|
441
469
|
refreshers: change.refreshers,
|
|
@@ -444,14 +472,14 @@ export class ModularChangeFamily {
|
|
|
444
472
|
}
|
|
445
473
|
// This performs a first pass on all fields which have both new and base changes.
|
|
446
474
|
// TODO: Can we also handle additional passes in this method?
|
|
447
|
-
rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId,
|
|
475
|
+
rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId, metadata) {
|
|
448
476
|
const change = crossFieldTable.newChange;
|
|
449
477
|
const baseChange = crossFieldTable.baseChange;
|
|
450
478
|
const rebasedFields = this.rebaseFieldMap(change.fieldChanges, baseChange.fieldChanges, undefined, genId, crossFieldTable, metadata);
|
|
451
479
|
// This loop processes all fields which have both base and new changes.
|
|
452
480
|
// Note that the call to `rebaseNodeChange` can add entries to `crossFieldTable.nodeIdPairs`.
|
|
453
481
|
for (const [newId, baseId, _attachState] of crossFieldTable.nodeIdPairs) {
|
|
454
|
-
const rebasedNode = this.rebaseNodeChange(newId, baseId, genId, crossFieldTable, metadata
|
|
482
|
+
const rebasedNode = this.rebaseNodeChange(newId, baseId, genId, crossFieldTable, metadata);
|
|
455
483
|
setInChangeAtomIdMap(rebasedNodes, newId, rebasedNode);
|
|
456
484
|
}
|
|
457
485
|
return rebasedFields;
|
|
@@ -626,7 +654,7 @@ export class ModularChangeFamily {
|
|
|
626
654
|
}
|
|
627
655
|
return rebasedFields;
|
|
628
656
|
}
|
|
629
|
-
rebaseNodeChange(newId, baseId, genId, crossFieldTable, revisionMetadata
|
|
657
|
+
rebaseNodeChange(newId, baseId, genId, crossFieldTable, revisionMetadata) {
|
|
630
658
|
const change = nodeChangeFromId(crossFieldTable.newChange.nodeChanges, newId);
|
|
631
659
|
const over = nodeChangeFromId(crossFieldTable.baseChange.nodeChanges, baseId);
|
|
632
660
|
const baseMap = over?.fieldChanges ?? new Map();
|
|
@@ -640,25 +668,32 @@ export class ModularChangeFamily {
|
|
|
640
668
|
if (change?.nodeExistsConstraint !== undefined) {
|
|
641
669
|
rebasedChange.nodeExistsConstraint = change.nodeExistsConstraint;
|
|
642
670
|
}
|
|
671
|
+
if (change?.nodeExistsConstraintOnRevert !== undefined) {
|
|
672
|
+
rebasedChange.nodeExistsConstraintOnRevert = change.nodeExistsConstraintOnRevert;
|
|
673
|
+
}
|
|
643
674
|
setInChangeAtomIdMap(crossFieldTable.baseToRebasedNodeId, baseId, newId);
|
|
644
675
|
return rebasedChange;
|
|
645
676
|
}
|
|
646
|
-
updateConstraintsForFields(fields,
|
|
677
|
+
updateConstraintsForFields(fields, parentInputAttachState, parentOutputAttachState, constraintState, revertConstraintState, nodes) {
|
|
647
678
|
for (const field of fields.values()) {
|
|
648
679
|
const handler = getChangeHandler(this.fieldKinds, field.fieldKind);
|
|
649
|
-
for (const [nodeId,
|
|
650
|
-
const
|
|
651
|
-
const
|
|
680
|
+
for (const [nodeId, inputIndex, outputIndex] of handler.getNestedChanges(field.change)) {
|
|
681
|
+
const isInputDetached = inputIndex === undefined;
|
|
682
|
+
const inputAttachState = parentInputAttachState === NodeAttachState.Detached || isInputDetached
|
|
683
|
+
? NodeAttachState.Detached
|
|
684
|
+
: NodeAttachState.Attached;
|
|
685
|
+
const isOutputDetached = outputIndex === undefined;
|
|
686
|
+
const outputAttachState = parentOutputAttachState === NodeAttachState.Detached || isOutputDetached
|
|
652
687
|
? NodeAttachState.Detached
|
|
653
688
|
: NodeAttachState.Attached;
|
|
654
|
-
this.updateConstraintsForNode(nodeId,
|
|
689
|
+
this.updateConstraintsForNode(nodeId, inputAttachState, outputAttachState, nodes, constraintState, revertConstraintState);
|
|
655
690
|
}
|
|
656
691
|
}
|
|
657
692
|
}
|
|
658
|
-
updateConstraintsForNode(nodeId,
|
|
693
|
+
updateConstraintsForNode(nodeId, inputAttachState, outputAttachState, nodes, constraintState, revertConstraintState) {
|
|
659
694
|
const node = nodes.get([nodeId.revision, nodeId.localId]) ?? fail("Unknown node ID");
|
|
660
695
|
if (node.nodeExistsConstraint !== undefined) {
|
|
661
|
-
const isNowViolated =
|
|
696
|
+
const isNowViolated = inputAttachState === NodeAttachState.Detached;
|
|
662
697
|
if (node.nodeExistsConstraint.violated !== isNowViolated) {
|
|
663
698
|
node.nodeExistsConstraint = {
|
|
664
699
|
...node.nodeExistsConstraint,
|
|
@@ -667,8 +702,18 @@ export class ModularChangeFamily {
|
|
|
667
702
|
constraintState.violationCount += isNowViolated ? 1 : -1;
|
|
668
703
|
}
|
|
669
704
|
}
|
|
705
|
+
if (node.nodeExistsConstraintOnRevert !== undefined) {
|
|
706
|
+
const isNowViolated = outputAttachState === NodeAttachState.Detached;
|
|
707
|
+
if (node.nodeExistsConstraintOnRevert.violated !== isNowViolated) {
|
|
708
|
+
node.nodeExistsConstraintOnRevert = {
|
|
709
|
+
...node.nodeExistsConstraintOnRevert,
|
|
710
|
+
violated: isNowViolated,
|
|
711
|
+
};
|
|
712
|
+
revertConstraintState.violationCount += isNowViolated ? 1 : -1;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
670
715
|
if (node.fieldChanges !== undefined) {
|
|
671
|
-
this.updateConstraintsForFields(node.fieldChanges,
|
|
716
|
+
this.updateConstraintsForFields(node.fieldChanges, inputAttachState, outputAttachState, constraintState, revertConstraintState, nodes);
|
|
672
717
|
}
|
|
673
718
|
}
|
|
674
719
|
pruneFieldMap(changeset, nodeMap) {
|
|
@@ -777,8 +822,8 @@ export class ModularChangeFamily {
|
|
|
777
822
|
populateCrossFieldKeyTableForFieldMap(table, fields, parent) {
|
|
778
823
|
for (const [fieldKey, fieldChange] of fields) {
|
|
779
824
|
const keys = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).getCrossFieldKeys(fieldChange.change);
|
|
780
|
-
for (const key of keys) {
|
|
781
|
-
table.set(key, { nodeId: parent, field: fieldKey });
|
|
825
|
+
for (const { key, count } of keys) {
|
|
826
|
+
table.set(key, count, { nodeId: parent, field: fieldKey });
|
|
782
827
|
}
|
|
783
828
|
}
|
|
784
829
|
}
|
|
@@ -817,7 +862,7 @@ export class ModularChangeFamily {
|
|
|
817
862
|
numChildren += 1;
|
|
818
863
|
}
|
|
819
864
|
for (const keyRange of handler.getCrossFieldKeys(fieldChange.change)) {
|
|
820
|
-
const fields = getFieldsForCrossFieldKey(change, keyRange);
|
|
865
|
+
const fields = getFieldsForCrossFieldKey(change, keyRange.key, keyRange.count);
|
|
821
866
|
assert(fields.length === 1 &&
|
|
822
867
|
fields[0] !== undefined &&
|
|
823
868
|
areEqualFieldIds(fields[0], fieldId), 0xa4f /* Inconsistent cross field keys */);
|
|
@@ -828,14 +873,15 @@ export class ModularChangeFamily {
|
|
|
828
873
|
}
|
|
829
874
|
ModularChangeFamily.emptyChange = makeModularChangeset();
|
|
830
875
|
function replaceCrossFieldKeyTableRevisions(table, oldRevisions, newRevision, nodeAliases) {
|
|
831
|
-
const updated =
|
|
832
|
-
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
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;
|
|
839
885
|
const normalizedFieldId = normalizeFieldId(field, nodeAliases);
|
|
840
886
|
const updatedNodeId = normalizedFieldId.nodeId !== undefined
|
|
841
887
|
? replaceAtomRevisions(normalizedFieldId.nodeId, oldRevisions, newRevision)
|
|
@@ -844,8 +890,8 @@ function replaceCrossFieldKeyTableRevisions(table, oldRevisions, newRevision, no
|
|
|
844
890
|
...normalizedFieldId,
|
|
845
891
|
nodeId: updatedNodeId,
|
|
846
892
|
};
|
|
847
|
-
updated.set(updatedKey, updatedValue);
|
|
848
|
-
}
|
|
893
|
+
updated.set(updatedKey, entry.length, updatedValue);
|
|
894
|
+
}
|
|
849
895
|
return updated;
|
|
850
896
|
}
|
|
851
897
|
function replaceRevision(revision, oldRevisions, newRevision) {
|
|
@@ -869,9 +915,9 @@ function composeBuildsDestroysAndRefreshers(change1, change2) {
|
|
|
869
915
|
// Note that it would in principle be possible to adopt the later build and exclude from the
|
|
870
916
|
// composition all the changes already reflected on the tree, but that is not something we
|
|
871
917
|
// care to support at this time.
|
|
872
|
-
const allBuilds = brand(
|
|
873
|
-
const allDestroys = brand(
|
|
874
|
-
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));
|
|
875
921
|
if (change1.destroys !== undefined && change2.builds !== undefined) {
|
|
876
922
|
for (const [key, chunk] of change2.builds.entries()) {
|
|
877
923
|
const destroyCount = change1.destroys.get(key);
|
|
@@ -973,7 +1019,7 @@ export function updateRefreshers(change, getDetachedNode, removedRoots, requireR
|
|
|
973
1019
|
refreshers.set([root.major, brand(root.minor)], node);
|
|
974
1020
|
}
|
|
975
1021
|
}
|
|
976
|
-
const { fieldChanges, nodeChanges, maxId, revisions, constraintViolationCount, builds, destroys, } = change;
|
|
1022
|
+
const { fieldChanges, nodeChanges, maxId, revisions, constraintViolationCount, constraintViolationCountOnRevert, builds, destroys, } = change;
|
|
977
1023
|
return makeModularChangeset({
|
|
978
1024
|
fieldChanges,
|
|
979
1025
|
nodeChanges,
|
|
@@ -983,25 +1029,35 @@ export function updateRefreshers(change, getDetachedNode, removedRoots, requireR
|
|
|
983
1029
|
maxId: maxId,
|
|
984
1030
|
revisions,
|
|
985
1031
|
constraintViolationCount,
|
|
1032
|
+
constraintViolationCountOnRevert,
|
|
986
1033
|
builds,
|
|
987
1034
|
destroys,
|
|
988
1035
|
refreshers,
|
|
989
1036
|
});
|
|
990
1037
|
}
|
|
991
1038
|
/**
|
|
1039
|
+
* Converts a change into the delta format.
|
|
1040
|
+
*
|
|
992
1041
|
* @param change - The change to convert into a delta.
|
|
993
1042
|
* @param fieldKinds - The field kinds to delegate to.
|
|
994
1043
|
*/
|
|
995
1044
|
export function intoDelta(taggedChange, fieldKinds) {
|
|
996
1045
|
const change = taggedChange.change;
|
|
997
|
-
const idAllocator = MemoizedIdRangeAllocator.fromNextId();
|
|
998
1046
|
const rootDelta = {};
|
|
1047
|
+
const global = [];
|
|
1048
|
+
const rename = [];
|
|
999
1049
|
if (!hasConflicts(change)) {
|
|
1000
1050
|
// If there are no constraint violations, then tree changes apply.
|
|
1001
|
-
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges,
|
|
1051
|
+
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges, fieldKinds, global, rename);
|
|
1002
1052
|
if (fieldDeltas.size > 0) {
|
|
1003
1053
|
rootDelta.fields = fieldDeltas;
|
|
1004
1054
|
}
|
|
1055
|
+
if (global.length > 0) {
|
|
1056
|
+
rootDelta.global = global;
|
|
1057
|
+
}
|
|
1058
|
+
if (rename.length > 0) {
|
|
1059
|
+
rootDelta.rename = rename;
|
|
1060
|
+
}
|
|
1005
1061
|
}
|
|
1006
1062
|
// Constraint violations should not prevent nodes from being built
|
|
1007
1063
|
if (change.builds && change.builds.size > 0) {
|
|
@@ -1038,22 +1094,24 @@ function copyDetachedNodes(detachedNodes) {
|
|
|
1038
1094
|
/**
|
|
1039
1095
|
* @param change - The change to convert into a delta.
|
|
1040
1096
|
*/
|
|
1041
|
-
function intoDeltaImpl(change, nodeChanges,
|
|
1097
|
+
function intoDeltaImpl(change, nodeChanges, fieldKinds, global, rename) {
|
|
1042
1098
|
const delta = new Map();
|
|
1043
1099
|
for (const [field, fieldChange] of change) {
|
|
1044
|
-
const
|
|
1100
|
+
const { local: fieldChanges, global: fieldGlobal, rename: fieldRename, } = getChangeHandler(fieldKinds, fieldChange.fieldKind).intoDelta(fieldChange.change, (childChange) => {
|
|
1045
1101
|
const nodeChange = nodeChangeFromId(nodeChanges, childChange);
|
|
1046
|
-
return deltaFromNodeChange(nodeChange, nodeChanges,
|
|
1047
|
-
}
|
|
1048
|
-
if (
|
|
1049
|
-
delta.set(field,
|
|
1102
|
+
return deltaFromNodeChange(nodeChange, nodeChanges, fieldKinds, global, rename);
|
|
1103
|
+
});
|
|
1104
|
+
if (fieldChanges !== undefined && fieldChanges.length > 0) {
|
|
1105
|
+
delta.set(field, fieldChanges);
|
|
1050
1106
|
}
|
|
1107
|
+
fieldGlobal?.forEach((c) => global.push(c));
|
|
1108
|
+
fieldRename?.forEach((r) => rename.push(r));
|
|
1051
1109
|
}
|
|
1052
1110
|
return delta;
|
|
1053
1111
|
}
|
|
1054
|
-
function deltaFromNodeChange(change, nodeChanges,
|
|
1112
|
+
function deltaFromNodeChange(change, nodeChanges, fieldKinds, global, rename) {
|
|
1055
1113
|
if (change.fieldChanges !== undefined) {
|
|
1056
|
-
return intoDeltaImpl(change.fieldChanges, nodeChanges,
|
|
1114
|
+
return intoDeltaImpl(change.fieldChanges, nodeChanges, fieldKinds, global, rename);
|
|
1057
1115
|
}
|
|
1058
1116
|
// TODO: update the API to allow undefined to be returned here
|
|
1059
1117
|
return new Map();
|
|
@@ -1085,7 +1143,9 @@ export function rebaseRevisionMetadataFromInfo(revInfos, revisionToRebase, baseR
|
|
|
1085
1143
|
};
|
|
1086
1144
|
}
|
|
1087
1145
|
function isEmptyNodeChangeset(change) {
|
|
1088
|
-
return change.fieldChanges === undefined &&
|
|
1146
|
+
return (change.fieldChanges === undefined &&
|
|
1147
|
+
change.nodeExistsConstraint === undefined &&
|
|
1148
|
+
change.nodeExistsConstraintOnRevert === undefined);
|
|
1089
1149
|
}
|
|
1090
1150
|
export function getFieldKind(fieldKinds, kind) {
|
|
1091
1151
|
if (kind === genericFieldKind.identifier) {
|
|
@@ -1117,10 +1177,10 @@ function newComposeTable(baseChange, newChange, composedNodeToParent) {
|
|
|
1117
1177
|
}
|
|
1118
1178
|
function newCrossFieldTable() {
|
|
1119
1179
|
return {
|
|
1120
|
-
srcTable:
|
|
1121
|
-
dstTable:
|
|
1122
|
-
srcDependents:
|
|
1123
|
-
dstDependents:
|
|
1180
|
+
srcTable: newChangeAtomIdRangeMap(),
|
|
1181
|
+
dstTable: newChangeAtomIdRangeMap(),
|
|
1182
|
+
srcDependents: newChangeAtomIdRangeMap(),
|
|
1183
|
+
dstDependents: newChangeAtomIdRangeMap(),
|
|
1124
1184
|
invalidatedFields: new Set(),
|
|
1125
1185
|
};
|
|
1126
1186
|
}
|
|
@@ -1191,19 +1251,17 @@ class RebaseManager extends CrossFieldManagerI {
|
|
|
1191
1251
|
}
|
|
1192
1252
|
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1193
1253
|
if (invalidateDependents && this.allowInval) {
|
|
1194
|
-
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange,
|
|
1254
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1195
1255
|
target,
|
|
1196
1256
|
revision,
|
|
1197
|
-
id,
|
|
1198
|
-
|
|
1199
|
-
]);
|
|
1257
|
+
localId: id,
|
|
1258
|
+
}, count);
|
|
1200
1259
|
assert(newFieldIds.length === 0, 0x9c6 /* TODO: Modifying a cross-field key from the new changeset is currently unsupported */);
|
|
1201
|
-
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange,
|
|
1260
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1202
1261
|
target,
|
|
1203
1262
|
revision,
|
|
1204
|
-
id,
|
|
1205
|
-
|
|
1206
|
-
]);
|
|
1263
|
+
localId: id,
|
|
1264
|
+
}, count);
|
|
1207
1265
|
assert(baseFieldIds.length > 0, 0x9c7 /* Cross field key not registered in base or new change */);
|
|
1208
1266
|
for (const baseFieldId of baseFieldIds) {
|
|
1209
1267
|
this.table.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
@@ -1215,7 +1273,7 @@ class RebaseManager extends CrossFieldManagerI {
|
|
|
1215
1273
|
setInChangeAtomIdMap(this.table.rebasedNodeToParent, id, this.fieldId);
|
|
1216
1274
|
}
|
|
1217
1275
|
moveKey(target, revision, id, count) {
|
|
1218
|
-
|
|
1276
|
+
this.table.rebasedCrossFieldKeys.set({ target, revision, localId: id }, count, this.fieldId);
|
|
1219
1277
|
}
|
|
1220
1278
|
get table() {
|
|
1221
1279
|
return this.crossFieldTable;
|
|
@@ -1229,24 +1287,22 @@ class ComposeManager extends CrossFieldManagerI {
|
|
|
1229
1287
|
}
|
|
1230
1288
|
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1231
1289
|
if (invalidateDependents && this.allowInval) {
|
|
1232
|
-
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange,
|
|
1290
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1233
1291
|
target,
|
|
1234
1292
|
revision,
|
|
1235
|
-
id,
|
|
1236
|
-
|
|
1237
|
-
]);
|
|
1293
|
+
localId: id,
|
|
1294
|
+
}, count);
|
|
1238
1295
|
if (newFieldIds.length > 0) {
|
|
1239
1296
|
for (const newFieldId of newFieldIds) {
|
|
1240
1297
|
this.table.pendingCompositions.affectedNewFields.set([newFieldId.nodeId?.revision, newFieldId.nodeId?.localId, newFieldId.field], true);
|
|
1241
1298
|
}
|
|
1242
1299
|
}
|
|
1243
1300
|
else {
|
|
1244
|
-
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange,
|
|
1301
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1245
1302
|
target,
|
|
1246
1303
|
revision,
|
|
1247
|
-
id,
|
|
1248
|
-
|
|
1249
|
-
]);
|
|
1304
|
+
localId: id,
|
|
1305
|
+
}, count);
|
|
1250
1306
|
assert(baseFieldIds.length > 0, 0x9c8 /* Cross field key not registered in base or new change */);
|
|
1251
1307
|
for (const baseFieldId of baseFieldIds) {
|
|
1252
1308
|
this.table.pendingCompositions.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
@@ -1284,6 +1340,10 @@ function makeModularChangeset(props = {
|
|
|
1284
1340
|
if (props.constraintViolationCount !== undefined && props.constraintViolationCount > 0) {
|
|
1285
1341
|
changeset.constraintViolationCount = props.constraintViolationCount;
|
|
1286
1342
|
}
|
|
1343
|
+
if (props.constraintViolationCountOnRevert !== undefined &&
|
|
1344
|
+
props.constraintViolationCountOnRevert > 0) {
|
|
1345
|
+
changeset.constraintViolationCountOnRevert = props.constraintViolationCountOnRevert;
|
|
1346
|
+
}
|
|
1287
1347
|
if (props.builds !== undefined && props.builds.size > 0) {
|
|
1288
1348
|
changeset.builds = props.builds;
|
|
1289
1349
|
}
|
|
@@ -1417,13 +1477,27 @@ export class ModularEditBuilder extends EditBuilder {
|
|
|
1417
1477
|
revision,
|
|
1418
1478
|
}), revision));
|
|
1419
1479
|
}
|
|
1480
|
+
addNodeExistsConstraintOnRevert(path, revision) {
|
|
1481
|
+
const nodeChange = {
|
|
1482
|
+
nodeExistsConstraintOnRevert: { violated: false },
|
|
1483
|
+
};
|
|
1484
|
+
this.applyChange(tagChange(buildModularChangesetFromNode({
|
|
1485
|
+
path,
|
|
1486
|
+
nodeChange,
|
|
1487
|
+
nodeChanges: newTupleBTree(),
|
|
1488
|
+
nodeToParent: newTupleBTree(),
|
|
1489
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
1490
|
+
idAllocator: this.idAllocator,
|
|
1491
|
+
revision,
|
|
1492
|
+
}), revision));
|
|
1493
|
+
}
|
|
1420
1494
|
}
|
|
1421
1495
|
function buildModularChangesetFromField(props) {
|
|
1422
1496
|
const { path, fieldChange, nodeChanges, nodeToParent, crossFieldKeys, idAllocator = idAllocatorFromMaxId(), localCrossFieldKeys = [], childId, revision, } = props;
|
|
1423
1497
|
const fieldChanges = new Map([[path.field, fieldChange]]);
|
|
1424
1498
|
if (path.parent === undefined) {
|
|
1425
|
-
for (const key of localCrossFieldKeys) {
|
|
1426
|
-
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 });
|
|
1427
1501
|
}
|
|
1428
1502
|
if (childId !== undefined) {
|
|
1429
1503
|
setInChangeAtomIdMap(nodeToParent, childId, {
|
|
@@ -1444,8 +1518,8 @@ function buildModularChangesetFromField(props) {
|
|
|
1444
1518
|
fieldChanges,
|
|
1445
1519
|
};
|
|
1446
1520
|
const parentId = { localId: brand(idAllocator.allocate()), revision };
|
|
1447
|
-
for (const key of localCrossFieldKeys) {
|
|
1448
|
-
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 });
|
|
1449
1523
|
}
|
|
1450
1524
|
if (childId !== undefined) {
|
|
1451
1525
|
setInChangeAtomIdMap(nodeToParent, childId, {
|
|
@@ -1518,19 +1592,6 @@ function revisionInfoFromTaggedChange(taggedChange) {
|
|
|
1518
1592
|
}
|
|
1519
1593
|
return revInfos;
|
|
1520
1594
|
}
|
|
1521
|
-
function mergeBTrees(tree1, tree2, preferLeft = true) {
|
|
1522
|
-
if (tree1 === undefined) {
|
|
1523
|
-
return tree2 !== undefined ? brand(tree2.clone()) : newTupleBTree();
|
|
1524
|
-
}
|
|
1525
|
-
const result = brand(tree1.clone());
|
|
1526
|
-
if (tree2 === undefined) {
|
|
1527
|
-
return result;
|
|
1528
|
-
}
|
|
1529
|
-
for (const [key, value] of tree2.entries()) {
|
|
1530
|
-
result.set(key, value, !preferLeft);
|
|
1531
|
-
}
|
|
1532
|
-
return result;
|
|
1533
|
-
}
|
|
1534
1595
|
function fieldChangeFromId(fields, nodes, id) {
|
|
1535
1596
|
const fieldMap = fieldMapFromNodeId(fields, nodes, id.nodeId);
|
|
1536
1597
|
return fieldMap.get(id.field) ?? fail("No field exists for the given ID");
|
|
@@ -1581,72 +1642,13 @@ export function getParentFieldId(changeset, nodeId) {
|
|
|
1581
1642
|
assert(parentId !== undefined, 0x9cb /* Parent field should be defined */);
|
|
1582
1643
|
return normalizeFieldId(parentId, changeset.nodeAliases);
|
|
1583
1644
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
// eslint-disable-next-line no-constant-condition
|
|
1589
|
-
while (true) {
|
|
1590
|
-
const entry = getFirstIntersectingCrossFieldEntry(changeset.crossFieldKeys, [
|
|
1591
|
-
target,
|
|
1592
|
-
revision,
|
|
1593
|
-
brand(firstLocalId),
|
|
1594
|
-
count,
|
|
1595
|
-
]);
|
|
1596
|
-
if (entry === undefined) {
|
|
1597
|
-
return fields;
|
|
1598
|
-
}
|
|
1599
|
-
const [[_target, _revision, entryId, entryCount], fieldId] = entry;
|
|
1600
|
-
fields.push(normalizeFieldId(fieldId, changeset.nodeAliases));
|
|
1601
|
-
const entryLastId = entryId + entryCount - 1;
|
|
1602
|
-
if (entryLastId >= lastLocalId) {
|
|
1603
|
-
return fields;
|
|
1604
|
-
}
|
|
1605
|
-
firstLocalId = entryLastId + 1;
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
function getFirstIntersectingCrossFieldEntry(table, [target, revision, id, count]) {
|
|
1609
|
-
const entry = table.nextLowerPair([target, revision, id, Number.POSITIVE_INFINITY]);
|
|
1610
|
-
if (entry === undefined) {
|
|
1611
|
-
return undefined;
|
|
1612
|
-
}
|
|
1613
|
-
const [entryTarget, entryRevision, entryId, entryCount] = entry[0];
|
|
1614
|
-
if (entryTarget !== target || entryRevision !== revision) {
|
|
1615
|
-
return undefined;
|
|
1616
|
-
}
|
|
1617
|
-
const lastQueryId = id + count - 1;
|
|
1618
|
-
const entryLastId = entryId + entryCount - 1;
|
|
1619
|
-
if (entryId > lastQueryId || entryLastId < id) {
|
|
1620
|
-
return undefined;
|
|
1621
|
-
}
|
|
1622
|
-
return entry;
|
|
1623
|
-
}
|
|
1624
|
-
function setInCrossFieldKeyTable(table, target, revision, id, count, value) {
|
|
1625
|
-
let entry = getFirstIntersectingCrossFieldEntry(table, [target, revision, id, count]);
|
|
1626
|
-
const lastQueryId = id + count - 1;
|
|
1627
|
-
while (entry !== undefined) {
|
|
1628
|
-
const [entryKey, entryValue] = entry;
|
|
1629
|
-
table.delete(entryKey);
|
|
1630
|
-
const [_target, _revision, entryId, entryCount] = entryKey;
|
|
1631
|
-
if (entryId < id) {
|
|
1632
|
-
table.set([target, revision, entryId, id - entryId], entryValue);
|
|
1633
|
-
}
|
|
1634
|
-
const lastEntryId = entryId + entryCount - 1;
|
|
1635
|
-
if (lastEntryId > lastQueryId) {
|
|
1636
|
-
table.set([target, revision, brand(lastQueryId + 1), lastEntryId - lastQueryId], entryValue);
|
|
1637
|
-
break;
|
|
1638
|
-
}
|
|
1639
|
-
const nextId = brand(lastEntryId + 1);
|
|
1640
|
-
entry = getFirstIntersectingCrossFieldEntry(table, [
|
|
1641
|
-
target,
|
|
1642
|
-
revision,
|
|
1643
|
-
nextId,
|
|
1644
|
-
lastQueryId - nextId + 1,
|
|
1645
|
-
]);
|
|
1646
|
-
}
|
|
1647
|
-
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));
|
|
1648
1649
|
}
|
|
1649
|
-
|
|
1650
|
+
// This is only exported for use in test utilities.
|
|
1651
|
+
export function normalizeFieldId(fieldId, nodeAliases) {
|
|
1650
1652
|
return fieldId.nodeId !== undefined
|
|
1651
1653
|
? { ...fieldId, nodeId: normalizeNodeId(fieldId.nodeId, nodeAliases) }
|
|
1652
1654
|
: fieldId;
|
|
@@ -1668,36 +1670,6 @@ function normalizeNodeId(nodeId, nodeAliases) {
|
|
|
1668
1670
|
function hasConflicts(change) {
|
|
1669
1671
|
return (change.constraintViolationCount ?? 0) > 0;
|
|
1670
1672
|
}
|
|
1671
|
-
export function newCrossFieldKeyTable() {
|
|
1672
|
-
return newTupleBTree();
|
|
1673
|
-
}
|
|
1674
|
-
export function newTupleBTree(entries) {
|
|
1675
|
-
return brand(new BTree(entries, compareTuples));
|
|
1676
|
-
}
|
|
1677
|
-
// This assumes that the arrays are the same length.
|
|
1678
|
-
function compareTuples(arrayA, arrayB) {
|
|
1679
|
-
for (let i = 0; i < arrayA.length; i++) {
|
|
1680
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1681
|
-
const a = arrayA[i];
|
|
1682
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1683
|
-
const b = arrayB[i];
|
|
1684
|
-
// Less-than and greater-than always return false if either value is undefined,
|
|
1685
|
-
// so we handle undefined separately, treating it as less than all other values.
|
|
1686
|
-
if (a === undefined && b !== undefined) {
|
|
1687
|
-
return -1;
|
|
1688
|
-
}
|
|
1689
|
-
else if (b === undefined && a !== undefined) {
|
|
1690
|
-
return 1;
|
|
1691
|
-
}
|
|
1692
|
-
else if (a < b) {
|
|
1693
|
-
return -1;
|
|
1694
|
-
}
|
|
1695
|
-
else if (a > b) {
|
|
1696
|
-
return 1;
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
return 0;
|
|
1700
|
-
}
|
|
1701
1673
|
function getFromChangeAtomIdMap(map, id) {
|
|
1702
1674
|
return map.get([id.revision, id.localId]);
|
|
1703
1675
|
}
|