@fluidframework/tree 2.90.0-378676 → 2.90.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/.vscode/settings.json +6 -5
- package/CHANGELOG.md +95 -0
- package/README.md +1 -1
- package/api-report/tree.alpha.api.md +63 -25
- package/api-report/tree.beta.api.md +30 -0
- package/api-report/tree.legacy.beta.api.md +30 -0
- package/dist/alpha.d.ts +10 -6
- package/dist/beta.d.ts +4 -1
- package/dist/codec/codec.d.ts +2 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +4 -3
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +13 -1
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +18 -3
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/format.d.ts +22 -1
- package/dist/codec/versioned/format.d.ts.map +1 -1
- package/dist/codec/versioned/format.js +16 -3
- package/dist/codec/versioned/format.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -1
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/change-family/changeFamily.d.ts +1 -4
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/change-family/index.d.ts +1 -1
- package/dist/core/change-family/index.d.ts.map +1 -1
- package/dist/core/change-family/index.js.map +1 -1
- package/dist/core/index.d.ts +3 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -8
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +1 -6
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +1 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +78 -1
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -5
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +7 -25
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/tree/delta.d.ts +0 -5
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +1 -13
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +1 -14
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.d.ts +0 -4
- package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/dist/core/tree/index.d.ts +2 -2
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +3 -4
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/pathTree.d.ts +3 -11
- package/dist/core/tree/pathTree.d.ts.map +1 -1
- package/dist/core/tree/pathTree.js +2 -14
- package/dist/core/tree/pathTree.js.map +1 -1
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js +13 -17
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.d.ts +2 -3
- package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.js +2 -15
- package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +22 -44
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +11 -0
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js +2 -4
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -4
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +44 -92
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +70 -220
- 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 +2 -12
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -2
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js +2 -4
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +6 -7
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js +0 -15
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/dist/feature-libraries/deltaUtils.d.ts +0 -1
- package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
- package/dist/feature-libraries/deltaUtils.js +1 -6
- package/dist/feature-libraries/deltaUtils.js.map +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts +0 -9
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +0 -6
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +7 -8
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +8 -39
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/observer.d.ts +17 -0
- package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +5 -12
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +33 -33
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +6 -7
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.js +13 -11
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +31 -48
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/index.js +2 -2
- package/dist/feature-libraries/forest-summary/index.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +6 -6
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +6 -11
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/indexing/index.d.ts +1 -1
- package/dist/feature-libraries/indexing/index.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/index.js.map +1 -1
- package/dist/feature-libraries/indexing/types.d.ts +15 -13
- package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/types.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +24 -100
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js +12 -8
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +51 -85
- 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 +9 -4
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +3 -3
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +3 -2
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +22 -18
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +158 -276
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +0 -8
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +22 -56
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +462 -1390
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +2 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +3 -3
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +10 -49
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -3
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts +32 -13
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +446 -257
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
- package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +28 -57
- package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
- package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/optional-field/requiredField.d.ts +2 -3
- package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/requiredField.js +1 -6
- package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts +7 -6
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +259 -81
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/helperTypes.d.ts +10 -14
- package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
- package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +167 -65
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +56 -4
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js +90 -7
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
- package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +116 -109
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +9 -0
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -0
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +50 -0
- package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -0
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.js +32 -19
- package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -22
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +187 -388
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +62 -20
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.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 +111 -16
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/types.d.ts +74 -37
- package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/types.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts +25 -20
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +320 -159
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +4 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +3 -3
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +4 -4
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +1 -2
- package/dist/shared-tree/schematizeTree.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 +70 -28
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +3 -9
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +8 -11
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +0 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +0 -8
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts +6 -16
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +7 -14
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/tree.js +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +8 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +48 -8
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +46 -16
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +129 -73
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.d.ts +20 -0
- package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
- package/dist/shared-tree/unhydratedTreeContext.js +56 -0
- package/dist/shared-tree/unhydratedTreeContext.js.map +1 -0
- package/dist/shared-tree-core/branch.d.ts +2 -3
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +3 -4
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts +2 -2
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +9 -9
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +0 -4
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +2 -10
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +0 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +0 -6
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +0 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +2 -2
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +1 -3
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +0 -4
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +2 -10
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +0 -1
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +0 -6
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js +0 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +15 -27
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +7 -11
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +4 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
- package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -1
- package/dist/simple-tree/api/identifierIndex.js +1 -1
- package/dist/simple-tree/api/identifierIndex.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -3
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +3 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +3 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.d.ts +15 -13
- package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +4 -4
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +22 -25
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +69 -132
- 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/core/unhydratedFlexTree.d.ts +12 -16
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +8 -59
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +4 -4
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +3 -5
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/common.js +1 -1
- package/dist/simple-tree/node-kinds/common.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +19 -19
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -4
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +47 -54
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +125 -183
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +3 -8
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +13 -27
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/text/textDomain.d.ts +27 -9
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +43 -7
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +14 -8
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +97 -25
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +2 -12
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +1 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/rangeMap.d.ts +11 -22
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +4 -38
- package/dist/util/rangeMap.js.map +1 -1
- package/docs/main/sequence-field/move-composition.md +46 -0
- package/lib/alpha.d.ts +10 -6
- package/lib/beta.d.ts +4 -1
- package/lib/codec/codec.d.ts +2 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +4 -3
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +13 -1
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +18 -3
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/format.d.ts +22 -1
- package/lib/codec/versioned/format.d.ts.map +1 -1
- package/lib/codec/versioned/format.js +15 -2
- package/lib/codec/versioned/format.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/change-family/changeFamily.d.ts +1 -4
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/change-family/index.d.ts +1 -1
- package/lib/core/change-family/index.d.ts.map +1 -1
- package/lib/core/change-family/index.js.map +1 -1
- package/lib/core/index.d.ts +3 -4
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -3
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +1 -6
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +78 -1
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -3
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +7 -25
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/tree/delta.d.ts +0 -5
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +1 -13
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +2 -15
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.d.ts +0 -4
- package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
- package/lib/core/tree/index.d.ts +2 -2
- 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/pathTree.d.ts +3 -11
- package/lib/core/tree/pathTree.d.ts.map +1 -1
- package/lib/core/tree/pathTree.js +1 -12
- package/lib/core/tree/pathTree.js.map +1 -1
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js +13 -17
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.d.ts +2 -3
- package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.js +3 -15
- package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +25 -45
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +11 -0
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +44 -92
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +69 -217
- 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 +2 -12
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -2
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js +1 -2
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +6 -7
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js +0 -15
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/lib/feature-libraries/deltaUtils.d.ts +0 -1
- package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
- package/lib/feature-libraries/deltaUtils.js +1 -5
- package/lib/feature-libraries/deltaUtils.js.map +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts +0 -9
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +0 -6
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +7 -8
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +9 -40
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/observer.d.ts +17 -0
- package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/observer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +5 -12
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +35 -32
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +7 -8
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.js +7 -4
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +30 -47
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/index.js +1 -1
- package/lib/feature-libraries/forest-summary/index.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +6 -6
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +5 -5
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/indexing/index.d.ts +1 -1
- package/lib/feature-libraries/indexing/index.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/index.js.map +1 -1
- package/lib/feature-libraries/indexing/types.d.ts +15 -13
- package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/types.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +24 -100
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js +10 -7
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +51 -85
- 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 +9 -4
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +3 -3
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +22 -18
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +144 -267
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +0 -8
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +22 -56
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +468 -1387
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +2 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +10 -49
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts +32 -13
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +442 -254
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
- package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +26 -55
- package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
- package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/optional-field/requiredField.d.ts +2 -3
- package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/requiredField.js +1 -5
- package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts +7 -6
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +261 -83
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/helperTypes.d.ts +10 -14
- package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
- package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +169 -67
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +56 -4
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js +84 -6
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
- package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +118 -111
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +9 -0
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -0
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +46 -0
- package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -0
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +32 -19
- package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +3 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -22
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +182 -379
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +63 -21
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.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 +111 -16
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/types.d.ts +74 -37
- package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/types.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts +25 -20
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +313 -155
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/index.d.ts +3 -3
- 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 +4 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +4 -4
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +4 -4
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +2 -3
- package/lib/shared-tree/schematizeTree.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 +71 -30
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +3 -9
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +9 -12
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +0 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +0 -8
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts +6 -16
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +6 -12
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/tree.js +1 -1
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +8 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +49 -9
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +46 -16
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +132 -76
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.d.ts +20 -0
- package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
- package/lib/shared-tree/unhydratedTreeContext.js +52 -0
- package/lib/shared-tree/unhydratedTreeContext.js.map +1 -0
- package/lib/shared-tree-core/branch.d.ts +2 -3
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +3 -4
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts +2 -2
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +9 -9
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +0 -4
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +1 -8
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +0 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +0 -6
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +0 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +2 -2
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +2 -2
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +0 -4
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +1 -8
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +0 -1
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +0 -6
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js +0 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +15 -27
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +7 -11
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +4 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
- package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -1
- package/lib/simple-tree/api/identifierIndex.js +2 -2
- package/lib/simple-tree/api/identifierIndex.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -3
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +3 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +3 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.d.ts +15 -13
- package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +22 -25
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +69 -132
- 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/core/unhydratedFlexTree.d.ts +12 -16
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +8 -58
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +4 -4
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +4 -6
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/common.js +2 -2
- package/lib/simple-tree/node-kinds/common.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +20 -20
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +2 -4
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +47 -54
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +125 -184
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +3 -8
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +10 -23
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/text/textDomain.d.ts +27 -9
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +45 -9
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +14 -8
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +80 -8
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +3 -13
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/rangeMap.d.ts +11 -22
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +3 -36
- package/lib/util/rangeMap.js.map +1 -1
- package/package.json +24 -24
- package/src/codec/codec.ts +5 -4
- package/src/codec/index.ts +1 -0
- package/src/codec/versioned/codec.ts +32 -6
- package/src/codec/versioned/format.ts +17 -2
- package/src/codec/versioned/index.ts +1 -1
- package/src/core/change-family/changeFamily.ts +0 -5
- package/src/core/change-family/index.ts +0 -1
- package/src/core/index.ts +3 -10
- package/src/core/rebase/changeRebaser.ts +1 -6
- package/src/core/rebase/index.ts +2 -1
- package/src/core/rebase/types.ts +80 -4
- package/src/core/rebase/utils.ts +7 -31
- package/src/core/tree/delta.ts +0 -6
- package/src/core/tree/detachedFieldIndex.ts +1 -29
- package/src/core/tree/detachedFieldIndexTypes.ts +0 -5
- package/src/core/tree/index.ts +12 -13
- package/src/core/tree/pathTree.ts +4 -16
- package/src/core/tree/visitDelta.ts +11 -31
- package/src/feature-libraries/changeAtomIdBTree.ts +3 -28
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +59 -78
- package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
- package/src/feature-libraries/chunked-forest/codec/index.ts +3 -3
- package/src/feature-libraries/chunked-forest/index.ts +2 -3
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +127 -369
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +4 -13
- package/src/feature-libraries/default-schema/index.ts +5 -16
- package/src/feature-libraries/default-schema/mappedEditBuilder.ts +9 -35
- package/src/feature-libraries/deltaUtils.ts +1 -6
- package/src/feature-libraries/flex-tree/context.ts +0 -17
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -7
- package/src/feature-libraries/flex-tree/lazyField.ts +24 -65
- package/src/feature-libraries/flex-tree/observer.ts +17 -0
- package/src/feature-libraries/forest-summary/codec.ts +46 -56
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -14
- package/src/feature-libraries/forest-summary/formatCommon.ts +14 -19
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +44 -74
- package/src/feature-libraries/forest-summary/index.ts +1 -1
- package/src/feature-libraries/index.ts +11 -26
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +3 -5
- package/src/feature-libraries/indexing/index.ts +1 -1
- package/src/feature-libraries/indexing/types.ts +15 -17
- package/src/feature-libraries/mitigatedChangeFamily.ts +1 -3
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +47 -144
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +58 -113
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +18 -7
- package/src/feature-libraries/modular-schema/index.ts +16 -16
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +329 -604
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +0 -1
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +0 -14
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +748 -2694
- package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +0 -1
- package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +1 -1
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +10 -62
- package/src/feature-libraries/optional-field/optionalField.ts +568 -359
- package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +35 -31
- package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +35 -89
- package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +1 -5
- package/src/feature-libraries/optional-field/requiredField.ts +2 -15
- package/src/feature-libraries/sequence-field/compose.ts +522 -137
- package/src/feature-libraries/sequence-field/helperTypes.ts +19 -34
- package/src/feature-libraries/sequence-field/invert.ts +228 -102
- package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +195 -8
- package/src/feature-libraries/sequence-field/rebase.ts +207 -171
- package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +57 -0
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -26
- package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +3 -8
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +229 -677
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +70 -56
- package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +30 -28
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +131 -21
- package/src/feature-libraries/sequence-field/types.ts +79 -40
- package/src/feature-libraries/sequence-field/utils.ts +370 -211
- package/src/index.ts +6 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +9 -15
- package/src/shared-tree/index.ts +2 -3
- package/src/shared-tree/schematizeTree.ts +8 -21
- package/src/shared-tree/schematizingTreeView.ts +111 -48
- package/src/shared-tree/sharedTree.ts +23 -40
- package/src/shared-tree/sharedTreeChangeCodecs.ts +0 -8
- package/src/shared-tree/sharedTreeChangeFamily.ts +4 -7
- package/src/shared-tree/sharedTreeEditBuilder.ts +8 -43
- package/src/shared-tree/tree.ts +1 -1
- package/src/shared-tree/treeAlpha.ts +64 -11
- package/src/shared-tree/treeCheckout.ts +159 -114
- package/src/shared-tree/unhydratedTreeContext.ts +87 -0
- package/src/shared-tree-core/branch.ts +2 -8
- package/src/shared-tree-core/editManager.ts +2 -16
- package/src/shared-tree-core/editManagerCodecs.ts +1 -11
- package/src/shared-tree-core/editManagerFormatCommons.ts +0 -6
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +1 -3
- package/src/shared-tree-core/index.ts +0 -2
- package/src/shared-tree-core/messageCodecV1ToV4.ts +1 -2
- package/src/shared-tree-core/messageCodecs.ts +1 -11
- package/src/shared-tree-core/messageFormat.ts +0 -6
- package/src/shared-tree-core/messageFormatV1ToV4.ts +1 -3
- package/src/shared-tree-core/sharedTreeCore.ts +1 -4
- package/src/shared-tree-core/transaction.ts +19 -39
- package/src/simple-tree/api/configuration.ts +4 -0
- package/src/simple-tree/api/identifierIndex.ts +4 -4
- package/src/simple-tree/api/index.ts +3 -1
- package/src/simple-tree/api/schemaFactory.ts +3 -2
- package/src/simple-tree/api/simpleTreeIndex.ts +26 -20
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -4
- package/src/simple-tree/api/transactionTypes.ts +24 -26
- package/src/simple-tree/api/tree.ts +92 -131
- package/src/simple-tree/core/unhydratedFlexTree.ts +35 -82
- package/src/simple-tree/fieldSchema.ts +4 -6
- package/src/simple-tree/index.ts +5 -4
- package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -7
- package/src/simple-tree/node-kinds/common.ts +5 -2
- package/src/simple-tree/node-kinds/map/mapNode.ts +4 -4
- package/src/simple-tree/node-kinds/object/objectNode.ts +26 -26
- package/src/simple-tree/node-kinds/record/recordNode.ts +9 -10
- package/src/simple-tree/prepareForInsertion.ts +200 -342
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +15 -35
- package/src/text/textDomain.ts +91 -12
- package/src/text/textDomainFormatted.ts +127 -15
- package/src/treeFactory.ts +4 -16
- package/src/util/index.ts +0 -3
- package/src/util/rangeMap.ts +15 -63
- package/dist/core/schema-view/index.d.ts +0 -6
- package/dist/core/schema-view/index.d.ts.map +0 -1
- package/dist/core/schema-view/index.js +0 -10
- package/dist/core/schema-view/index.js.map +0 -1
- package/dist/core/schema-view/view.d.ts +0 -31
- package/dist/core/schema-view/view.d.ts.map +0 -1
- package/dist/core/schema-view/view.js +0 -18
- package/dist/core/schema-view/view.js.map +0 -1
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +0 -40
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +0 -1
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +0 -153
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV1.d.ts +0 -12
- package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV1.js +0 -10
- package/dist/feature-libraries/forest-summary/formatV1.js.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV2.d.ts +0 -12
- package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV2.js +0 -10
- package/dist/feature-libraries/forest-summary/formatV2.js.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +0 -15
- package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js +0 -296
- package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +0 -74
- package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js +0 -35
- package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js.map +0 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +0 -23
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +0 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +0 -31
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +0 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +0 -12
- package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +0 -1
- package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js +0 -57
- package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js.map +0 -1
- package/lib/core/schema-view/index.d.ts +0 -6
- package/lib/core/schema-view/index.d.ts.map +0 -1
- package/lib/core/schema-view/index.js +0 -6
- package/lib/core/schema-view/index.js.map +0 -1
- package/lib/core/schema-view/view.d.ts +0 -31
- package/lib/core/schema-view/view.d.ts.map +0 -1
- package/lib/core/schema-view/view.js +0 -14
- package/lib/core/schema-view/view.js.map +0 -1
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +0 -40
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +0 -1
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +0 -149
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV1.d.ts +0 -12
- package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV1.js +0 -7
- package/lib/feature-libraries/forest-summary/formatV1.js.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV2.d.ts +0 -12
- package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV2.js +0 -7
- package/lib/feature-libraries/forest-summary/formatV2.js.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +0 -15
- package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js +0 -292
- package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +0 -74
- package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js +0 -32
- package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js.map +0 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +0 -23
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +0 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +0 -27
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +0 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +0 -12
- package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +0 -1
- package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js +0 -53
- package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js.map +0 -1
- package/src/core/schema-view/README.md +0 -9
- package/src/core/schema-view/index.ts +0 -10
- package/src/core/schema-view/view.ts +0 -38
- package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +0 -231
- package/src/feature-libraries/forest-summary/formatV1.ts +0 -11
- package/src/feature-libraries/forest-summary/formatV2.ts +0 -11
- package/src/feature-libraries/modular-schema/modularChangeCodecV3.ts +0 -649
- package/src/feature-libraries/modular-schema/modularChangeFormatV3.ts +0 -67
- package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +0 -45
- package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +0 -94
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.normalizeFieldId = exports.getParentFieldId = exports.ModularEditBuilder = exports.getChangeHandler = exports.getFieldKind = exports.rebaseRevisionMetadataFromInfo = exports.intoDelta = exports.updateRefreshers = exports.relevantRemovedRoots = exports.ModularChangeFamily = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
10
|
const sorted_btree_es6_1 = require("@tylerbu/sorted-btree-es6");
|
|
@@ -72,23 +72,21 @@ class ModularChangeFamily {
|
|
|
72
72
|
return convertedChange;
|
|
73
73
|
}
|
|
74
74
|
compose(changes) {
|
|
75
|
-
const { maxId } = getRevInfoFromTaggedChanges(changes);
|
|
75
|
+
const { revInfos, maxId } = getRevInfoFromTaggedChanges(changes);
|
|
76
76
|
const idState = { maxId };
|
|
77
77
|
const pairwiseDelegate = (left, right) => {
|
|
78
|
-
return this.composePair(left, right, idState);
|
|
78
|
+
return this.composePair(left, right, revInfos, idState);
|
|
79
79
|
};
|
|
80
80
|
const innerChanges = changes.map((change) => change.change);
|
|
81
81
|
return (0, index_js_3.balancedReduce)(innerChanges, pairwiseDelegate, makeModularChangeset);
|
|
82
82
|
}
|
|
83
|
-
composePair(change1, change2, idState) {
|
|
84
|
-
const
|
|
85
|
-
const { fieldChanges, nodeChanges, nodeToParent, nodeAliases, crossFieldKeys, rootNodes } = this.composeAllFields(change1, change2, revInfos, idState);
|
|
83
|
+
composePair(change1, change2, revInfos, idState) {
|
|
84
|
+
const { fieldChanges, nodeChanges, nodeToParent, nodeAliases, crossFieldKeys } = this.composeAllFields(change1, change2, revInfos, idState);
|
|
86
85
|
const { allBuilds, allDestroys, allRefreshers } = composeBuildsDestroysAndRefreshers(change1, change2);
|
|
87
86
|
// The composed changeset has a "no change" constraint if either change has one
|
|
88
87
|
const noChangeConstraint = change1.noChangeConstraint ?? change2.noChangeConstraint;
|
|
89
88
|
const noChangeConstraintOnRevert = change1.noChangeConstraintOnRevert ?? change2.noChangeConstraintOnRevert;
|
|
90
|
-
|
|
91
|
-
rebaseVersion: Math.max(change1.rebaseVersion, change2.rebaseVersion),
|
|
89
|
+
return makeModularChangeset({
|
|
92
90
|
fieldChanges,
|
|
93
91
|
nodeChanges,
|
|
94
92
|
nodeToParent,
|
|
@@ -96,16 +94,12 @@ class ModularChangeFamily {
|
|
|
96
94
|
crossFieldKeys,
|
|
97
95
|
maxId: idState.maxId,
|
|
98
96
|
revisions: revInfos,
|
|
99
|
-
|
|
97
|
+
noChangeConstraint,
|
|
98
|
+
noChangeConstraintOnRevert,
|
|
100
99
|
builds: allBuilds,
|
|
101
100
|
destroys: allDestroys,
|
|
102
101
|
refreshers: allRefreshers,
|
|
103
|
-
noChangeConstraint,
|
|
104
|
-
noChangeConstraintOnRevert,
|
|
105
102
|
});
|
|
106
|
-
// XXX: This is an expensive assert which should be disabled before merging.
|
|
107
|
-
validateChangeset(composed, this.fieldKinds);
|
|
108
|
-
return composed;
|
|
109
103
|
}
|
|
110
104
|
composeAllFields(potentiallyConflictedChange1, potentiallyConflictedChange2, revInfos, idState) {
|
|
111
105
|
// Our current cell ordering scheme in sequences depends on being able to rebase over a change with conflicts.
|
|
@@ -126,50 +120,34 @@ class ModularChangeFamily {
|
|
|
126
120
|
const composedNodeChanges = (0, index_js_3.brand)((0, index_js_3.mergeTupleBTrees)(change1.nodeChanges, change2.nodeChanges));
|
|
127
121
|
const composedNodeToParent = (0, index_js_3.brand)((0, index_js_3.mergeTupleBTrees)(change1.nodeToParent, change2.nodeToParent));
|
|
128
122
|
const composedNodeAliases = (0, index_js_3.brand)((0, index_js_3.mergeTupleBTrees)(change1.nodeAliases, change2.nodeAliases));
|
|
129
|
-
const
|
|
130
|
-
nodeIdsToCompose: [],
|
|
131
|
-
affectedBaseFields: newFieldIdKeyBTree(),
|
|
132
|
-
};
|
|
133
|
-
const movedCrossFieldKeys = (0, modularChangeTypes_js_1.newCrossFieldRangeTable)();
|
|
134
|
-
const removedCrossFieldKeys = (0, modularChangeTypes_js_1.newCrossFieldRangeTable)();
|
|
135
|
-
const composedRoots = composeRootTables(change1, change2, composedNodeToParent, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
136
|
-
const crossFieldTable = newComposeTable(change1, change2, composedRoots, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
123
|
+
const crossFieldTable = newComposeTable(change1, change2, composedNodeToParent);
|
|
137
124
|
const composedFields = this.composeFieldMaps(change1.fieldChanges, change2.fieldChanges, undefined, genId, crossFieldTable, revisionMetadata);
|
|
138
125
|
this.composeInvalidatedElements(crossFieldTable, composedFields, composedNodeChanges, composedNodeToParent, composedNodeAliases, genId, revisionMetadata);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
for (const [nodeId, location] of crossFieldTable.movedNodeToParent.entries()) {
|
|
143
|
-
// Moved nodes are from change2.
|
|
144
|
-
// If there is a corresponding node in change1, then composedNodeToParent will already have the correct entry,
|
|
145
|
-
// because the location of the node is the same in change1 and the composed change
|
|
146
|
-
// (since they have the same input context).
|
|
147
|
-
if (crossFieldTable.newToBaseNodeId.get(nodeId) === undefined) {
|
|
148
|
-
composedNodeToParent.set(nodeId, location);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
126
|
+
// Currently no field kinds require making changes to cross-field keys during composition, so we can just merge the two tables.
|
|
127
|
+
const composedCrossFieldKeys = index_js_3.RangeMap.union(change1.crossFieldKeys, change2.crossFieldKeys);
|
|
151
128
|
return {
|
|
152
129
|
fieldChanges: composedFields,
|
|
153
130
|
nodeChanges: composedNodeChanges,
|
|
154
131
|
nodeToParent: composedNodeToParent,
|
|
155
132
|
nodeAliases: composedNodeAliases,
|
|
156
|
-
crossFieldKeys:
|
|
157
|
-
rootNodes: composedRoots,
|
|
133
|
+
crossFieldKeys: composedCrossFieldKeys,
|
|
158
134
|
};
|
|
159
135
|
}
|
|
160
136
|
composeInvalidatedField(fieldChange, crossFieldTable, genId, revisionMetadata) {
|
|
161
137
|
const context = crossFieldTable.fieldToContext.get(fieldChange);
|
|
162
138
|
(0, internal_1.assert)(context !== undefined, 0x8cc /* Should have context for every invalidated field */);
|
|
163
|
-
const { change1: fieldChange1, change2: fieldChange2, composedChange } = context;
|
|
164
|
-
crossFieldTable.pendingCompositions.affectedBaseFields.delete(fieldIdKeyFromFieldId(context.fieldId));
|
|
139
|
+
const { fieldId, change1: fieldChange1, change2: fieldChange2, composedChange } = context;
|
|
165
140
|
const rebaser = getChangeHandler(this.fieldKinds, composedChange.fieldKind).rebaser;
|
|
166
141
|
const composeNodes = (child1, child2) => {
|
|
167
|
-
if (child1 !== undefined &&
|
|
168
|
-
|
|
142
|
+
if (child1 !== undefined &&
|
|
143
|
+
child2 !== undefined &&
|
|
144
|
+
(0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(crossFieldTable.newToBaseNodeId, child2) === undefined) {
|
|
145
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(crossFieldTable.newToBaseNodeId, child2, child1);
|
|
146
|
+
crossFieldTable.pendingCompositions.nodeIdsToCompose.push([child1, child2]);
|
|
169
147
|
}
|
|
170
148
|
return child1 ?? child2 ?? (0, internal_1.fail)(0xb22 /* Should not compose two undefined nodes */);
|
|
171
149
|
};
|
|
172
|
-
const amendedChange = rebaser.compose(fieldChange1, fieldChange2, composeNodes, genId, new
|
|
150
|
+
const amendedChange = rebaser.compose(fieldChange1, fieldChange2, composeNodes, genId, new ComposeManager(crossFieldTable, fieldChange, fieldId, false), revisionMetadata);
|
|
173
151
|
composedChange.change = (0, index_js_3.brand)(amendedChange);
|
|
174
152
|
}
|
|
175
153
|
/**
|
|
@@ -178,23 +156,32 @@ class ModularChangeFamily {
|
|
|
178
156
|
* - discovering that two node changesets refer to the same node (`nodeIdsToCompose`)
|
|
179
157
|
* - a previously composed field being invalidated by a cross field effect (`invalidatedFields`)
|
|
180
158
|
* - a field which was copied directly from an input changeset being invalidated by a cross field effect
|
|
181
|
-
* (`affectedBaseFields`)
|
|
159
|
+
* (`affectedBaseFields` and `affectedNewFields`)
|
|
182
160
|
*
|
|
183
161
|
* Updating an element may invalidate further elements. This function runs until there is no more invalidation.
|
|
184
162
|
*/
|
|
185
163
|
composeInvalidatedElements(table, composedFields, composedNodes, composedNodeToParent, nodeAliases, genId, metadata) {
|
|
186
164
|
const pending = table.pendingCompositions;
|
|
187
|
-
while (
|
|
188
|
-
|
|
189
|
-
|
|
165
|
+
while (table.invalidatedFields.size > 0 ||
|
|
166
|
+
pending.nodeIdsToCompose.length > 0 ||
|
|
167
|
+
pending.affectedBaseFields.length > 0 ||
|
|
168
|
+
pending.affectedNewFields.length > 0) {
|
|
169
|
+
// Note that the call to `composeNodesById` can add entries to `crossFieldTable.nodeIdPairs`.
|
|
170
|
+
for (const [id1, id2] of pending.nodeIdsToCompose) {
|
|
171
|
+
this.composeNodesById(table.baseChange.nodeChanges, table.newChange.nodeChanges, composedNodes, composedNodeToParent, nodeAliases, id1, id2, genId, table, metadata);
|
|
172
|
+
}
|
|
173
|
+
pending.nodeIdsToCompose.length = 0;
|
|
174
|
+
this.composeAffectedFields(table, table.baseChange, true, pending.affectedBaseFields, composedFields, composedNodes, genId, metadata);
|
|
175
|
+
this.composeAffectedFields(table, table.newChange, false, pending.affectedNewFields, composedFields, composedNodes, genId, metadata);
|
|
176
|
+
this.processInvalidatedCompositions(table, genId, metadata);
|
|
190
177
|
}
|
|
191
178
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
processInvalidatedCompositions(table, genId, metadata) {
|
|
180
|
+
const fieldsToUpdate = table.invalidatedFields;
|
|
181
|
+
table.invalidatedFields = new Set();
|
|
182
|
+
for (const fieldChange of fieldsToUpdate) {
|
|
183
|
+
this.composeInvalidatedField(fieldChange, table, genId, metadata);
|
|
196
184
|
}
|
|
197
|
-
table.pendingCompositions.nodeIdsToCompose.length = 0;
|
|
198
185
|
}
|
|
199
186
|
/**
|
|
200
187
|
* Ensures that each field in `affectedFields` has been updated in the composition output.
|
|
@@ -207,34 +194,39 @@ class ModularChangeFamily {
|
|
|
207
194
|
* If not, they are assumed to be part of the new changeset.
|
|
208
195
|
* @param affectedFields - The set of fields to process.
|
|
209
196
|
*/
|
|
210
|
-
composeAffectedFields(table, change, affectedFields, composedFields, composedNodes, genId, metadata) {
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const fieldId = fieldIdFromFieldIdKey(fieldIdKey);
|
|
215
|
-
const fieldChange = fieldChangeFromId(change, fieldId);
|
|
197
|
+
composeAffectedFields(table, change, areBaseFields, affectedFields, composedFields, composedNodes, genId, metadata) {
|
|
198
|
+
for (const fieldIdKey of affectedFields.keys()) {
|
|
199
|
+
const fieldId = normalizeFieldId(fieldIdFromFieldIdKey(fieldIdKey), change.nodeAliases);
|
|
200
|
+
const fieldChange = fieldChangeFromId(change.fieldChanges, change.nodeChanges, fieldId);
|
|
216
201
|
if (table.fieldToContext.has(fieldChange) ||
|
|
217
202
|
table.newFieldToBaseField.has(fieldChange)) {
|
|
218
|
-
|
|
203
|
+
// This function handles fields which were not part of the intersection of the two changesets but which need to be updated anyway.
|
|
204
|
+
// If we've already processed this field then either it is up to date
|
|
205
|
+
// or there is pending inval which will be handled in processInvalidatedCompositions.
|
|
206
|
+
continue;
|
|
219
207
|
}
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
const emptyChange = this.createEmptyFieldChange(fieldChange.fieldKind);
|
|
209
|
+
const [change1, change2] = areBaseFields
|
|
210
|
+
? [fieldChange, emptyChange]
|
|
211
|
+
: [emptyChange, fieldChange];
|
|
212
|
+
const composedField = this.composeFieldChanges(fieldId, change1, change2, genId, table, metadata);
|
|
213
|
+
if (fieldId.nodeId === undefined) {
|
|
214
|
+
composedFields.set(fieldId.field, composedField);
|
|
215
|
+
continue;
|
|
222
216
|
}
|
|
217
|
+
const nodeId = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(table.newToBaseNodeId, fieldId.nodeId) ?? fieldId.nodeId;
|
|
218
|
+
let nodeChangeset = nodeChangeFromId(composedNodes, nodeId);
|
|
219
|
+
if (!table.composedNodes.has(nodeChangeset)) {
|
|
220
|
+
nodeChangeset = cloneNodeChangeset(nodeChangeset);
|
|
221
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(composedNodes, nodeId, nodeChangeset);
|
|
222
|
+
}
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy
|
|
224
|
+
if (nodeChangeset.fieldChanges === undefined) {
|
|
225
|
+
nodeChangeset.fieldChanges = new Map();
|
|
226
|
+
}
|
|
227
|
+
nodeChangeset.fieldChanges.set(fieldId.field, composedField);
|
|
223
228
|
}
|
|
224
|
-
|
|
225
|
-
composeFieldWithNoNewChange(table, baseFieldChange, fieldId, composedFields, composedNodes, genId, metadata) {
|
|
226
|
-
const emptyChange = this.createEmptyFieldChange(baseFieldChange.fieldKind);
|
|
227
|
-
const composedField = this.composeFieldChanges(fieldId, baseFieldChange, emptyChange, genId, table, metadata);
|
|
228
|
-
if (fieldId.nodeId === undefined) {
|
|
229
|
-
composedFields.set(fieldId.field, composedField);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
const nodeId = normalizeNodeId((0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(table.newToBaseNodeId, fieldId.nodeId) ?? fieldId.nodeId, table.baseChange.nodeAliases);
|
|
233
|
-
// We clone the node changeset before mutating it, as it may be from one of the input changesets.
|
|
234
|
-
const nodeChangeset = cloneNodeChangeset(nodeChangeFromId(composedNodes, table.baseChange.nodeAliases, nodeId));
|
|
235
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(composedNodes, nodeId, nodeChangeset);
|
|
236
|
-
nodeChangeset.fieldChanges ??= new Map();
|
|
237
|
-
nodeChangeset.fieldChanges.set(fieldId.field, composedField);
|
|
229
|
+
affectedFields.clear();
|
|
238
230
|
}
|
|
239
231
|
composeFieldMaps(change1, change2, parentId, genId, crossFieldTable, revisionMetadata) {
|
|
240
232
|
const composedFields = new Map();
|
|
@@ -244,14 +236,6 @@ class ModularChangeFamily {
|
|
|
244
236
|
for (const [field, fieldChange1] of change1) {
|
|
245
237
|
const fieldId = { nodeId: parentId, field };
|
|
246
238
|
const fieldChange2 = change2.get(field);
|
|
247
|
-
const cachedComposedFieldChange = crossFieldTable.fieldToContext.get(fieldChange1)?.composedChange;
|
|
248
|
-
if (fieldChange2 === undefined && cachedComposedFieldChange !== undefined) {
|
|
249
|
-
// This can happen if the field was previous processed in `composeFieldWithNoNewChange`.
|
|
250
|
-
// If `change2` does not have a change for this field, then without this check we would
|
|
251
|
-
// lose the composed field change and instead simply have `change1`'s change.
|
|
252
|
-
composedFields.set(field, cachedComposedFieldChange);
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
239
|
const composedField = fieldChange2 === undefined
|
|
256
240
|
? fieldChange1
|
|
257
241
|
: this.composeFieldChanges(fieldId, fieldChange1, fieldChange2, genId, crossFieldTable, revisionMetadata);
|
|
@@ -271,16 +255,17 @@ class ModularChangeFamily {
|
|
|
271
255
|
* will be added to `crossFieldTable.pendingCompositions.nodeIdsToCompose`.
|
|
272
256
|
*
|
|
273
257
|
* Any fields which had cross-field information sent to them as part of this field composition
|
|
274
|
-
* will be added to `affectedBaseFields` in `crossFieldTable.pendingCompositions`.
|
|
258
|
+
* will be added to either `affectedBaseFields` or `affectedNewFields` in `crossFieldTable.pendingCompositions`.
|
|
275
259
|
*
|
|
276
260
|
* Any composed `FieldChange` which is invalidated by new cross-field information will be added to `crossFieldTable.invalidatedFields`.
|
|
277
261
|
*/
|
|
278
262
|
composeFieldChanges(fieldId, change1, change2, idAllocator, crossFieldTable, revisionMetadata) {
|
|
279
263
|
const { fieldKind, changeHandler, change1: change1Normalized, change2: change2Normalized, } = this.normalizeFieldChanges(change1, change2);
|
|
280
|
-
const manager = new
|
|
264
|
+
const manager = new ComposeManager(crossFieldTable, change1, fieldId);
|
|
281
265
|
const composedChange = changeHandler.rebaser.compose(change1Normalized, change2Normalized, (child1, child2) => {
|
|
282
266
|
if (child1 !== undefined && child2 !== undefined) {
|
|
283
|
-
|
|
267
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(crossFieldTable.newToBaseNodeId, child2, child1);
|
|
268
|
+
crossFieldTable.pendingCompositions.nodeIdsToCompose.push([child1, child2]);
|
|
284
269
|
}
|
|
285
270
|
return child1 ?? child2 ?? (0, internal_1.fail)(0xb23 /* Should not compose two undefined nodes */);
|
|
286
271
|
}, idAllocator, manager, revisionMetadata);
|
|
@@ -297,18 +282,19 @@ class ModularChangeFamily {
|
|
|
297
282
|
crossFieldTable.newFieldToBaseField.set(change2, change1);
|
|
298
283
|
return composedField;
|
|
299
284
|
}
|
|
300
|
-
composeNodesById(
|
|
301
|
-
const nodeChangeset1 = nodeChangeFromId(
|
|
302
|
-
const nodeChangeset2 = nodeChangeFromId(
|
|
285
|
+
composeNodesById(nodeChanges1, nodeChanges2, composedNodes, composedNodeToParent, nodeAliases, id1, id2, idAllocator, crossFieldTable, revisionMetadata) {
|
|
286
|
+
const nodeChangeset1 = nodeChangeFromId(nodeChanges1, id1);
|
|
287
|
+
const nodeChangeset2 = nodeChangeFromId(nodeChanges2, id2);
|
|
303
288
|
const composedNodeChangeset = this.composeNodeChanges(id1, nodeChangeset1, nodeChangeset2, idAllocator, crossFieldTable, revisionMetadata);
|
|
304
289
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(composedNodes, id1, composedNodeChangeset);
|
|
305
290
|
if (!(0, index_js_2.areEqualChangeAtomIds)(id1, id2)) {
|
|
306
291
|
composedNodes.delete([id2.revision, id2.localId]);
|
|
307
292
|
composedNodeToParent.delete([id2.revision, id2.localId]);
|
|
308
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(
|
|
293
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodeAliases, id2, id1);
|
|
309
294
|
// We need to delete id1 to avoid forming a cycle in case id1 already had an alias.
|
|
310
|
-
|
|
295
|
+
nodeAliases.delete([id1.revision, id1.localId]);
|
|
311
296
|
}
|
|
297
|
+
crossFieldTable.composedNodes.add(composedNodeChangeset);
|
|
312
298
|
}
|
|
313
299
|
composeNodeChanges(nodeId, change1, change2, genId, crossFieldTable, revisionMetadata) {
|
|
314
300
|
// WARNING: this composition logic assumes that we never make compositions of the following form:
|
|
@@ -354,24 +340,16 @@ class ModularChangeFamily {
|
|
|
354
340
|
const noChangeConstraintOnRevert = change.change.noChangeConstraint;
|
|
355
341
|
if (hasConflicts(change.change)) {
|
|
356
342
|
return makeModularChangeset({
|
|
357
|
-
rebaseVersion: change.change.rebaseVersion,
|
|
358
343
|
maxId: change.change.maxId,
|
|
359
344
|
revisions: revInfos,
|
|
360
345
|
destroys,
|
|
361
346
|
});
|
|
362
347
|
}
|
|
363
348
|
const genId = (0, index_js_3.idAllocatorFromMaxId)(change.change.maxId ?? -1);
|
|
364
|
-
const invertedNodeToParent = (0, index_js_3.brand)(change.change.nodeToParent.clone());
|
|
365
349
|
const crossFieldTable = {
|
|
366
|
-
|
|
367
|
-
isRollback,
|
|
368
|
-
entries: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
350
|
+
...newCrossFieldTable(),
|
|
369
351
|
originalFieldToContext: new Map(),
|
|
370
|
-
|
|
371
|
-
invertedNodeToParent,
|
|
372
|
-
invalidatedFields: new Set(),
|
|
373
|
-
invertedRoots: invertRootTable(change.change, invertedNodeToParent, isRollback),
|
|
374
|
-
attachToDetachId: (0, index_js_2.newChangeAtomIdTransform)(),
|
|
352
|
+
invertedNodeToParent: (0, index_js_3.brand)(change.change.nodeToParent.clone()),
|
|
375
353
|
};
|
|
376
354
|
const { revInfos: oldRevInfos } = getRevInfoFromTaggedChanges([change]);
|
|
377
355
|
const revisionMetadata = (0, index_js_2.revisionMetadataSourceFromInfo)(oldRevInfos);
|
|
@@ -387,19 +365,16 @@ class ModularChangeFamily {
|
|
|
387
365
|
const originalFieldChange = fieldChange.change;
|
|
388
366
|
const context = crossFieldTable.originalFieldToContext.get(fieldChange);
|
|
389
367
|
(0, internal_1.assert)(context !== undefined, 0x851 /* Should have context for every invalidated field */);
|
|
390
|
-
const { invertedField } = context;
|
|
391
|
-
const amendedChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.invert(originalFieldChange, isRollback, genId, revisionForInvert, new
|
|
368
|
+
const { invertedField, fieldId } = context;
|
|
369
|
+
const amendedChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.invert(originalFieldChange, isRollback, genId, revisionForInvert, new InvertManager(crossFieldTable, fieldChange, fieldId), revisionMetadata);
|
|
392
370
|
invertedField.change = (0, index_js_3.brand)(amendedChange);
|
|
393
371
|
}
|
|
394
372
|
}
|
|
395
373
|
const crossFieldKeys = this.makeCrossFieldKeyTable(invertedFields, invertedNodes);
|
|
396
|
-
this.processInvertRenames(crossFieldTable);
|
|
397
374
|
return makeModularChangeset({
|
|
398
|
-
rebaseVersion: change.change.rebaseVersion,
|
|
399
375
|
fieldChanges: invertedFields,
|
|
400
376
|
nodeChanges: invertedNodes,
|
|
401
377
|
nodeToParent: crossFieldTable.invertedNodeToParent,
|
|
402
|
-
rootNodes: crossFieldTable.invertedRoots,
|
|
403
378
|
nodeAliases: change.change.nodeAliases,
|
|
404
379
|
crossFieldKeys,
|
|
405
380
|
maxId: genId.getMaxId(),
|
|
@@ -415,7 +390,7 @@ class ModularChangeFamily {
|
|
|
415
390
|
const invertedFields = new Map();
|
|
416
391
|
for (const [field, fieldChange] of changes) {
|
|
417
392
|
const fieldId = { nodeId: parentId, field };
|
|
418
|
-
const manager = new
|
|
393
|
+
const manager = new InvertManager(crossFieldTable, fieldChange, fieldId);
|
|
419
394
|
const invertedChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.invert(fieldChange.change, isRollback, genId, revisionForInvert, manager, revisionMetadata);
|
|
420
395
|
const invertedFieldChange = {
|
|
421
396
|
...fieldChange,
|
|
@@ -447,12 +422,6 @@ class ModularChangeFamily {
|
|
|
447
422
|
}
|
|
448
423
|
return inverse;
|
|
449
424
|
}
|
|
450
|
-
processInvertRenames(table) {
|
|
451
|
-
for (const { start: newAttachId, value: originalDetachId, length, } of table.attachToDetachId.entries()) {
|
|
452
|
-
// Note that the detach location is already set in `invertDetach`.
|
|
453
|
-
addNodeRename(table.invertedRoots, originalDetachId, newAttachId, length, undefined);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
425
|
rebase(taggedChange, potentiallyConflictedOver, revisionMetadata) {
|
|
457
426
|
// Our current cell ordering scheme in sequences depends on being able to rebase over a change with conflicts.
|
|
458
427
|
// This means that we must rebase over a muted version of the conflicted changeset.
|
|
@@ -463,26 +432,17 @@ class ModularChangeFamily {
|
|
|
463
432
|
const maxId = Math.max(change.maxId ?? -1, over.change.maxId ?? -1);
|
|
464
433
|
const idState = { maxId };
|
|
465
434
|
const genId = (0, index_js_3.idAllocatorFromState)(idState);
|
|
466
|
-
const affectedBaseFields = newFieldIdKeyBTree();
|
|
467
|
-
const nodesToRebase = [];
|
|
468
|
-
const rebasedNodeToParent = (0, index_js_3.brand)(change.nodeToParent.clone());
|
|
469
|
-
const rebaseVersion = Math.max(change.rebaseVersion, over.change.rebaseVersion);
|
|
470
|
-
const rebasedRootNodes = rebaseRoots(change, over.change, affectedBaseFields, nodesToRebase, rebasedNodeToParent, rebaseVersion);
|
|
471
435
|
const crossFieldTable = {
|
|
472
|
-
|
|
473
|
-
entries: newDetachedEntryMap(),
|
|
436
|
+
...newCrossFieldTable(),
|
|
474
437
|
newChange: change,
|
|
475
438
|
baseChange: over.change,
|
|
476
439
|
baseFieldToContext: new Map(),
|
|
477
|
-
baseRoots: over.change.rootNodes,
|
|
478
|
-
rebasedRootNodes,
|
|
479
440
|
baseToRebasedNodeId: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
480
441
|
rebasedFields: new Set(),
|
|
481
|
-
rebasedNodeToParent,
|
|
482
|
-
|
|
483
|
-
movedDetaches: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
442
|
+
rebasedNodeToParent: (0, index_js_3.brand)(change.nodeToParent.clone()),
|
|
443
|
+
rebasedCrossFieldKeys: change.crossFieldKeys.clone(),
|
|
484
444
|
nodeIdPairs: [],
|
|
485
|
-
affectedBaseFields,
|
|
445
|
+
affectedBaseFields: newFieldIdKeyBTree(),
|
|
486
446
|
fieldsWithUnattachedChild: new Set(),
|
|
487
447
|
};
|
|
488
448
|
const getBaseRevisions = () => revisionInfoFromTaggedChange(over).map((info) => info.revision);
|
|
@@ -492,9 +452,8 @@ class ModularChangeFamily {
|
|
|
492
452
|
getBaseRevisions,
|
|
493
453
|
};
|
|
494
454
|
const rebasedNodes = (0, index_js_3.brand)(change.nodeChanges.clone());
|
|
495
|
-
const rebasedFields = this.rebaseIntersectingFields(
|
|
496
|
-
this.
|
|
497
|
-
fixupRebasedDetachLocations(crossFieldTable);
|
|
455
|
+
const rebasedFields = this.rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId, rebaseMetadata);
|
|
456
|
+
this.rebaseInvalidatedElements(rebasedFields, rebasedNodes, crossFieldTable, rebaseMetadata, genId);
|
|
498
457
|
const constraintState = newConstraintState(change.constraintViolationCount ?? 0);
|
|
499
458
|
const revertConstraintState = newConstraintState(change.constraintViolationCountOnRevert ?? 0);
|
|
500
459
|
let noChangeConstraint = change.noChangeConstraint;
|
|
@@ -502,17 +461,13 @@ class ModularChangeFamily {
|
|
|
502
461
|
noChangeConstraint = { violated: true };
|
|
503
462
|
constraintState.violationCount += 1;
|
|
504
463
|
}
|
|
505
|
-
this.
|
|
506
|
-
const fieldsWithRootMoves = getFieldsWithRootMoves(crossFieldTable.rebasedRootNodes, change.nodeAliases);
|
|
507
|
-
const fieldToRootChanges = getFieldToRootChanges(crossFieldTable.rebasedRootNodes, change.nodeAliases);
|
|
464
|
+
this.updateConstraintsForFields(rebasedFields, fieldChangeHandler_js_1.NodeAttachState.Attached, fieldChangeHandler_js_1.NodeAttachState.Attached, constraintState, revertConstraintState, rebasedNodes);
|
|
508
465
|
const rebased = makeModularChangeset({
|
|
509
|
-
fieldChanges: this.pruneFieldMap(rebasedFields,
|
|
466
|
+
fieldChanges: this.pruneFieldMap(rebasedFields, rebasedNodes),
|
|
510
467
|
nodeChanges: rebasedNodes,
|
|
511
468
|
nodeToParent: crossFieldTable.rebasedNodeToParent,
|
|
512
|
-
rootNodes: this.pruneRoots(crossFieldTable.rebasedRootNodes, rebasedNodes, crossFieldTable.rebasedNodeToParent, change.nodeAliases, fieldsWithRootMoves, fieldToRootChanges),
|
|
513
|
-
// TODO: Do we need to include aliases for node changesets added during rebasing?
|
|
514
469
|
nodeAliases: change.nodeAliases,
|
|
515
|
-
crossFieldKeys:
|
|
470
|
+
crossFieldKeys: crossFieldTable.rebasedCrossFieldKeys,
|
|
516
471
|
maxId: idState.maxId,
|
|
517
472
|
revisions: change.revisions,
|
|
518
473
|
constraintViolationCount: constraintState.violationCount,
|
|
@@ -522,22 +477,15 @@ class ModularChangeFamily {
|
|
|
522
477
|
builds: change.builds,
|
|
523
478
|
destroys: change.destroys,
|
|
524
479
|
refreshers: change.refreshers,
|
|
525
|
-
rebaseVersion,
|
|
526
480
|
});
|
|
527
|
-
// XXX: This is an expensive assert which should be disabled before merging.
|
|
528
|
-
validateChangeset(rebased, this.fieldKinds);
|
|
529
481
|
return rebased;
|
|
530
482
|
}
|
|
531
483
|
// This performs a first pass on all fields which have both new and base changes.
|
|
532
484
|
// TODO: Can we also handle additional passes in this method?
|
|
533
|
-
rebaseIntersectingFields(
|
|
485
|
+
rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId, metadata) {
|
|
534
486
|
const change = crossFieldTable.newChange;
|
|
535
487
|
const baseChange = crossFieldTable.baseChange;
|
|
536
488
|
const rebasedFields = this.rebaseFieldMap(change.fieldChanges, baseChange.fieldChanges, undefined, genId, crossFieldTable, metadata);
|
|
537
|
-
for (const [newChildChange, baseChildChange] of rootChanges) {
|
|
538
|
-
const rebasedNode = this.rebaseNodeChange(newChildChange, baseChildChange, genId, crossFieldTable, metadata);
|
|
539
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(rebasedNodes, newChildChange, rebasedNode);
|
|
540
|
-
}
|
|
541
489
|
// This loop processes all fields which have both base and new changes.
|
|
542
490
|
// Note that the call to `rebaseNodeChange` can add entries to `crossFieldTable.nodeIdPairs`.
|
|
543
491
|
for (const [newId, baseId, _attachState] of crossFieldTable.nodeIdPairs) {
|
|
@@ -546,85 +494,83 @@ class ModularChangeFamily {
|
|
|
546
494
|
}
|
|
547
495
|
return rebasedFields;
|
|
548
496
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
(0, internal_1.assert)(
|
|
558
|
-
if (
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return (0, index_js_2.areEqualChangeAtomIds)(normalizeNodeId(baseChild, crossFieldTable.baseChange.nodeAliases), baseNodeId)
|
|
562
|
-
? baseNodeId
|
|
563
|
-
: undefined;
|
|
564
|
-
};
|
|
565
|
-
const handler = getChangeHandler(this.fieldKinds, baseFieldChange.fieldKind);
|
|
566
|
-
const fieldChange = {
|
|
567
|
-
...baseFieldChange,
|
|
568
|
-
change: (0, index_js_3.brand)(handler.createEmpty()),
|
|
569
|
-
};
|
|
570
|
-
const rebasedNodeId = baseFieldId.nodeId === undefined
|
|
571
|
-
? undefined
|
|
572
|
-
: rebasedNodeIdFromBaseNodeId(crossFieldTable, baseFieldId.nodeId);
|
|
573
|
-
const fieldId = { nodeId: rebasedNodeId, field: baseFieldId.field };
|
|
574
|
-
const rebasedField = handler.rebaser.rebase(fieldChange.change, baseFieldChange.change, rebaseChild, genId, new RebaseNodeManagerI(crossFieldTable, fieldId), metadata, crossFieldTable.rebaseVersion);
|
|
575
|
-
const rebasedFieldChange = {
|
|
576
|
-
...baseFieldChange,
|
|
577
|
-
change: (0, index_js_3.brand)(rebasedField),
|
|
578
|
-
};
|
|
579
|
-
const context = {
|
|
580
|
-
newChange: fieldChange,
|
|
581
|
-
baseChange: baseFieldChange,
|
|
582
|
-
rebasedChange: rebasedFieldChange,
|
|
583
|
-
fieldId,
|
|
584
|
-
baseNodeIds: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
585
|
-
};
|
|
586
|
-
if (baseNodeId !== undefined) {
|
|
587
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(context.baseNodeIds, baseNodeId, true);
|
|
588
|
-
}
|
|
589
|
-
crossFieldTable.baseFieldToContext.set(baseFieldChange, context);
|
|
590
|
-
crossFieldTable.rebasedFields.add(rebasedFieldChange);
|
|
591
|
-
this.attachRebasedField(rebasedFields, rebasedNodes, crossFieldTable, rebasedFieldChange, fieldId, genId, metadata);
|
|
592
|
-
}
|
|
593
|
-
rebaseInvalidatedFields(rebasedFields, rebasedNodes, crossFieldTable, rebaseMetadata, genId) {
|
|
594
|
-
while (crossFieldTable.affectedBaseFields.size > 0) {
|
|
595
|
-
const baseFields = crossFieldTable.affectedBaseFields.clone();
|
|
596
|
-
crossFieldTable.affectedBaseFields.clear();
|
|
597
|
-
for (const baseFieldIdKey of baseFields.keys()) {
|
|
598
|
-
const baseFieldId = normalizeFieldId(fieldIdFromFieldIdKey(baseFieldIdKey), crossFieldTable.baseChange.nodeAliases);
|
|
599
|
-
const baseField = fieldChangeFromId(crossFieldTable.baseChange, baseFieldId);
|
|
600
|
-
(0, internal_1.assert)(baseField !== undefined, 0x9c2 /* Cross field key registered for empty field */);
|
|
601
|
-
const context = crossFieldTable.baseFieldToContext.get(baseField);
|
|
602
|
-
if (context === undefined) {
|
|
603
|
-
this.rebaseFieldWithoutNewChanges(baseField, baseFieldId, crossFieldTable, rebasedFields, rebasedNodes, genId, rebaseMetadata);
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
this.rebaseInvalidatedField(baseField, crossFieldTable, context, rebaseMetadata, genId);
|
|
607
|
-
}
|
|
497
|
+
// This processes fields which have no new changes but have been invalidated by another field.
|
|
498
|
+
rebaseFieldsWithoutNewChanges(rebasedFields, rebasedNodes, crossFieldTable, genId, metadata) {
|
|
499
|
+
const baseChange = crossFieldTable.baseChange;
|
|
500
|
+
for (const [revision, localId, fieldKey] of crossFieldTable.affectedBaseFields.keys()) {
|
|
501
|
+
const baseNodeId = localId === undefined
|
|
502
|
+
? undefined
|
|
503
|
+
: normalizeNodeId({ revision, localId }, baseChange.nodeAliases);
|
|
504
|
+
const baseFieldChange = fieldMapFromNodeId(baseChange.fieldChanges, baseChange.nodeChanges, baseNodeId).get(fieldKey);
|
|
505
|
+
(0, internal_1.assert)(baseFieldChange !== undefined, 0x9c2 /* Cross field key registered for empty field */);
|
|
506
|
+
if (crossFieldTable.baseFieldToContext.has(baseFieldChange)) {
|
|
507
|
+
// This field has already been processed because there were changes to rebase.
|
|
508
|
+
continue;
|
|
608
509
|
}
|
|
510
|
+
// This field has no changes in the new changeset, otherwise it would have been added to
|
|
511
|
+
// `crossFieldTable.baseFieldToContext` when processing fields with both base and new changes.
|
|
512
|
+
const handler = getChangeHandler(this.fieldKinds, baseFieldChange.fieldKind);
|
|
513
|
+
const fieldChange = {
|
|
514
|
+
...baseFieldChange,
|
|
515
|
+
change: (0, index_js_3.brand)(handler.createEmpty()),
|
|
516
|
+
};
|
|
517
|
+
const rebasedNodeId = baseNodeId === undefined
|
|
518
|
+
? undefined
|
|
519
|
+
: rebasedNodeIdFromBaseNodeId(crossFieldTable, baseNodeId);
|
|
520
|
+
const fieldId = { nodeId: rebasedNodeId, field: fieldKey };
|
|
521
|
+
const rebasedField = handler.rebaser.rebase(fieldChange.change, baseFieldChange.change, noNewChangesRebaseChild, genId, new RebaseManager(crossFieldTable, baseFieldChange, fieldId), metadata);
|
|
522
|
+
const rebasedFieldChange = {
|
|
523
|
+
...baseFieldChange,
|
|
524
|
+
change: (0, index_js_3.brand)(rebasedField),
|
|
525
|
+
};
|
|
526
|
+
// TODO: Deduplicate
|
|
527
|
+
crossFieldTable.baseFieldToContext.set(baseFieldChange, {
|
|
528
|
+
newChange: fieldChange,
|
|
529
|
+
baseChange: baseFieldChange,
|
|
530
|
+
rebasedChange: rebasedFieldChange,
|
|
531
|
+
fieldId,
|
|
532
|
+
baseNodeIds: [],
|
|
533
|
+
});
|
|
534
|
+
crossFieldTable.rebasedFields.add(rebasedFieldChange);
|
|
535
|
+
this.attachRebasedField(rebasedFields, rebasedNodes, crossFieldTable, rebasedFieldChange, fieldId, genId, metadata);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
rebaseInvalidatedElements(rebasedFields, rebasedNodes, table, metadata, idAllocator) {
|
|
539
|
+
this.rebaseFieldsWithoutNewChanges(rebasedFields, rebasedNodes, table, idAllocator, metadata);
|
|
540
|
+
this.rebaseFieldsWithUnattachedChild(table, metadata, idAllocator);
|
|
541
|
+
this.rebaseInvalidatedFields(table, metadata, idAllocator);
|
|
542
|
+
}
|
|
543
|
+
rebaseInvalidatedFields(crossFieldTable, rebaseMetadata, genId) {
|
|
544
|
+
const fieldsToUpdate = crossFieldTable.invalidatedFields;
|
|
545
|
+
crossFieldTable.invalidatedFields = new Set();
|
|
546
|
+
for (const field of fieldsToUpdate) {
|
|
547
|
+
this.rebaseInvalidatedField(field, crossFieldTable, rebaseMetadata, genId);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
rebaseFieldsWithUnattachedChild(table, metadata, idAllocator) {
|
|
551
|
+
for (const field of table.fieldsWithUnattachedChild) {
|
|
552
|
+
table.invalidatedFields.delete(field);
|
|
553
|
+
this.rebaseInvalidatedField(field, table, metadata, idAllocator, true);
|
|
609
554
|
}
|
|
610
555
|
}
|
|
611
|
-
rebaseInvalidatedField(baseField, crossFieldTable,
|
|
556
|
+
rebaseInvalidatedField(baseField, crossFieldTable, rebaseMetadata, genId, allowInval = false) {
|
|
557
|
+
const context = crossFieldTable.baseFieldToContext.get(baseField);
|
|
558
|
+
(0, internal_1.assert)(context !== undefined, 0x852 /* Every field should have a context */);
|
|
612
559
|
const { changeHandler, change1: fieldChangeset, change2: baseChangeset, } = this.normalizeFieldChanges(context.newChange, context.baseChange);
|
|
613
560
|
const rebaseChild = (curr, base) => {
|
|
614
561
|
if (curr !== undefined) {
|
|
615
562
|
return curr;
|
|
616
563
|
}
|
|
617
|
-
if (base !== undefined
|
|
618
|
-
|
|
564
|
+
if (base !== undefined) {
|
|
565
|
+
for (const id of context.baseNodeIds) {
|
|
566
|
+
if ((0, index_js_2.areEqualChangeAtomIds)(base, id)) {
|
|
567
|
+
return base;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
619
570
|
}
|
|
620
571
|
return undefined;
|
|
621
572
|
};
|
|
622
|
-
|
|
623
|
-
if (crossFieldTable.fieldsWithUnattachedChild.has(baseField)) {
|
|
624
|
-
crossFieldTable.fieldsWithUnattachedChild.delete(baseField);
|
|
625
|
-
allowInval = true;
|
|
626
|
-
}
|
|
627
|
-
context.rebasedChange.change = (0, index_js_3.brand)(changeHandler.rebaser.rebase(fieldChangeset, baseChangeset, rebaseChild, genId, new RebaseNodeManagerI(crossFieldTable, context.fieldId, allowInval), rebaseMetadata, crossFieldTable.rebaseVersion));
|
|
573
|
+
context.rebasedChange.change = (0, index_js_3.brand)(changeHandler.rebaser.rebase(fieldChangeset, baseChangeset, rebaseChild, genId, new RebaseManager(crossFieldTable, baseField, context.fieldId, allowInval), rebaseMetadata));
|
|
628
574
|
}
|
|
629
575
|
attachRebasedField(rebasedFields, rebasedNodes, table, rebasedField, { nodeId, field: fieldKey }, idAllocator, metadata) {
|
|
630
576
|
if (nodeId === undefined) {
|
|
@@ -633,14 +579,12 @@ class ModularChangeFamily {
|
|
|
633
579
|
}
|
|
634
580
|
const rebasedNode = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(rebasedNodes, nodeId);
|
|
635
581
|
if (rebasedNode !== undefined) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
if (updatedRebasedNode.fieldChanges === undefined) {
|
|
639
|
-
updatedRebasedNode.fieldChanges = new Map([[fieldKey, rebasedField]]);
|
|
582
|
+
if (rebasedNode.fieldChanges === undefined) {
|
|
583
|
+
rebasedNode.fieldChanges = new Map([[fieldKey, rebasedField]]);
|
|
640
584
|
return;
|
|
641
585
|
}
|
|
642
|
-
(0, internal_1.assert)(!
|
|
643
|
-
|
|
586
|
+
(0, internal_1.assert)(!rebasedNode.fieldChanges.has(fieldKey), 0x9c4 /* Expected an empty field */);
|
|
587
|
+
rebasedNode.fieldChanges.set(fieldKey, rebasedField);
|
|
644
588
|
return;
|
|
645
589
|
}
|
|
646
590
|
const newNode = {
|
|
@@ -648,51 +592,39 @@ class ModularChangeFamily {
|
|
|
648
592
|
};
|
|
649
593
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(rebasedNodes, nodeId, newNode);
|
|
650
594
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(table.baseToRebasedNodeId, nodeId, nodeId);
|
|
651
|
-
const
|
|
652
|
-
this.attachRebasedNode(rebasedFields, rebasedNodes, table, nodeId,
|
|
653
|
-
}
|
|
654
|
-
attachRebasedNode(rebasedFields, rebasedNodes, table, baseNodeId,
|
|
655
|
-
|
|
656
|
-
const renamedRoot = firstAttachIdFromDetachId(table.baseChange.rootNodes, parentBase.root, 1).value;
|
|
657
|
-
const attachField = table.baseChange.crossFieldKeys.getFirst({ ...renamedRoot, target: crossFieldQueries_js_1.NodeMoveType.Attach }, 1).value;
|
|
658
|
-
if (attachField === undefined) {
|
|
659
|
-
const baseDetachLocation = table.baseChange.rootNodes.detachLocations.getFirst(parentBase.root, 1).value;
|
|
660
|
-
assignRootChange(table.rebasedRootNodes, table.rebasedNodeToParent, renamedRoot, baseNodeId, baseDetachLocation, table.rebaseVersion);
|
|
661
|
-
// We need to make sure the rebased changeset includes the detach location,
|
|
662
|
-
// so we add that field to `affectedBaseFields` unless it's already been processed.
|
|
663
|
-
if (baseDetachLocation !== undefined &&
|
|
664
|
-
!table.baseFieldToContext.has(fieldChangeFromId(table.baseChange, baseDetachLocation))) {
|
|
665
|
-
table.affectedBaseFields.set(fieldIdKeyFromFieldId(baseDetachLocation), true);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
// The base change inserts this node into `attachField`, so the rebased change should represent this node there.
|
|
670
|
-
const normalizedAttachField = normalizeFieldId(attachField, table.baseChange.nodeAliases);
|
|
671
|
-
const entry = table.entries.getFirst(renamedRoot, 1).value ?? {};
|
|
672
|
-
table.entries.set(renamedRoot, 1, { ...entry, nodeChange: baseNodeId });
|
|
673
|
-
table.affectedBaseFields.set(fieldIdKeyFromFieldId(normalizedAttachField), true);
|
|
674
|
-
this.attachRebasedNode(rebasedFields, rebasedNodes, table, baseNodeId, { field: normalizedAttachField }, idAllocator, metadata);
|
|
675
|
-
}
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
const parentFieldIdBase = parentBase.field;
|
|
679
|
-
const baseFieldChange = fieldChangeFromId(table.baseChange, parentFieldIdBase);
|
|
595
|
+
const parentFieldId = getParentFieldId(table.baseChange, nodeId);
|
|
596
|
+
this.attachRebasedNode(rebasedFields, rebasedNodes, table, nodeId, parentFieldId, idAllocator, metadata);
|
|
597
|
+
}
|
|
598
|
+
attachRebasedNode(rebasedFields, rebasedNodes, table, baseNodeId, parentFieldIdBase, idAllocator, metadata) {
|
|
599
|
+
const baseFieldChange = fieldChangeFromId(table.baseChange.fieldChanges, table.baseChange.nodeChanges, parentFieldIdBase);
|
|
680
600
|
const rebasedFieldId = rebasedFieldIdFromBaseId(table, parentFieldIdBase);
|
|
681
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(table.rebasedNodeToParent, baseNodeId,
|
|
601
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(table.rebasedNodeToParent, baseNodeId, rebasedFieldId);
|
|
682
602
|
const context = table.baseFieldToContext.get(baseFieldChange);
|
|
683
603
|
if (context !== undefined) {
|
|
684
604
|
// We've already processed this field.
|
|
685
|
-
// The new child node will be attached in
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
// This is done by checking whether `context.baseNodeIds` already contained `baseNodeId`.
|
|
689
|
-
if ((0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(context.baseNodeIds, baseNodeId, true)) {
|
|
690
|
-
table.fieldsWithUnattachedChild.add(baseFieldChange);
|
|
691
|
-
table.affectedBaseFields.set(fieldIdKeyFromFieldId(parentFieldIdBase), true);
|
|
692
|
-
}
|
|
605
|
+
// The new child node will be attached in rebaseFieldsWithUnattachedChild.
|
|
606
|
+
context.baseNodeIds.push(baseNodeId);
|
|
607
|
+
table.fieldsWithUnattachedChild.add(baseFieldChange);
|
|
693
608
|
return;
|
|
694
609
|
}
|
|
695
|
-
|
|
610
|
+
const handler = getChangeHandler(this.fieldKinds, baseFieldChange.fieldKind);
|
|
611
|
+
const fieldChange = {
|
|
612
|
+
...baseFieldChange,
|
|
613
|
+
change: (0, index_js_3.brand)(handler.createEmpty()),
|
|
614
|
+
};
|
|
615
|
+
const rebasedChangeset = handler.rebaser.rebase(handler.createEmpty(), baseFieldChange.change, (_idNew, idBase) => idBase !== undefined && (0, index_js_2.areEqualChangeAtomIds)(idBase, baseNodeId)
|
|
616
|
+
? baseNodeId
|
|
617
|
+
: undefined, idAllocator, new RebaseManager(table, baseFieldChange, rebasedFieldId), metadata);
|
|
618
|
+
const rebasedField = { ...baseFieldChange, change: (0, index_js_3.brand)(rebasedChangeset) };
|
|
619
|
+
table.rebasedFields.add(rebasedField);
|
|
620
|
+
table.baseFieldToContext.set(baseFieldChange, {
|
|
621
|
+
newChange: fieldChange,
|
|
622
|
+
baseChange: baseFieldChange,
|
|
623
|
+
rebasedChange: rebasedField,
|
|
624
|
+
fieldId: rebasedFieldId,
|
|
625
|
+
baseNodeIds: [],
|
|
626
|
+
});
|
|
627
|
+
this.attachRebasedField(rebasedFields, rebasedNodes, table, rebasedField, rebasedFieldId, idAllocator, metadata);
|
|
696
628
|
}
|
|
697
629
|
rebaseFieldMap(change, over, parentId, genId, crossFieldTable, revisionMetadata) {
|
|
698
630
|
const rebasedFields = new Map();
|
|
@@ -710,8 +642,8 @@ class ModularChangeFamily {
|
|
|
710
642
|
continue;
|
|
711
643
|
}
|
|
712
644
|
const { fieldKind, changeHandler, change1: fieldChangeset, change2: baseChangeset, } = this.normalizeFieldChanges(fieldChange, baseChange);
|
|
713
|
-
const manager = new
|
|
714
|
-
const rebasedField = changeHandler.rebaser.rebase(fieldChangeset, baseChangeset, rebaseChild, genId, manager, revisionMetadata
|
|
645
|
+
const manager = new RebaseManager(crossFieldTable, baseChange, fieldId);
|
|
646
|
+
const rebasedField = changeHandler.rebaser.rebase(fieldChangeset, baseChangeset, rebaseChild, genId, manager, revisionMetadata);
|
|
715
647
|
const rebasedFieldChange = {
|
|
716
648
|
fieldKind,
|
|
717
649
|
change: (0, index_js_3.brand)(rebasedField),
|
|
@@ -722,15 +654,15 @@ class ModularChangeFamily {
|
|
|
722
654
|
newChange: fieldChange,
|
|
723
655
|
rebasedChange: rebasedFieldChange,
|
|
724
656
|
fieldId,
|
|
725
|
-
baseNodeIds:
|
|
657
|
+
baseNodeIds: [],
|
|
726
658
|
});
|
|
727
659
|
crossFieldTable.rebasedFields.add(rebasedFieldChange);
|
|
728
660
|
}
|
|
729
661
|
return rebasedFields;
|
|
730
662
|
}
|
|
731
663
|
rebaseNodeChange(newId, baseId, genId, crossFieldTable, revisionMetadata) {
|
|
732
|
-
const change = nodeChangeFromId(crossFieldTable.newChange.nodeChanges,
|
|
733
|
-
const over = nodeChangeFromId(crossFieldTable.baseChange.nodeChanges,
|
|
664
|
+
const change = nodeChangeFromId(crossFieldTable.newChange.nodeChanges, newId);
|
|
665
|
+
const over = nodeChangeFromId(crossFieldTable.baseChange.nodeChanges, baseId);
|
|
734
666
|
const baseMap = over?.fieldChanges ?? new Map();
|
|
735
667
|
const fieldChanges = change.fieldChanges !== undefined && over.fieldChanges !== undefined
|
|
736
668
|
? this.rebaseFieldMap(change?.fieldChanges ?? new Map(), baseMap, newId, genId, crossFieldTable, revisionMetadata)
|
|
@@ -748,37 +680,28 @@ class ModularChangeFamily {
|
|
|
748
680
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(crossFieldTable.baseToRebasedNodeId, baseId, newId);
|
|
749
681
|
return rebasedChange;
|
|
750
682
|
}
|
|
751
|
-
updateConstraints(rebasedFields, rebasedNodes, rebasedRoots, constraintState, revertConstraintState) {
|
|
752
|
-
this.updateConstraintsForFields(rebasedFields, fieldChangeHandler_js_1.NodeAttachState.Attached, fieldChangeHandler_js_1.NodeAttachState.Attached, constraintState, revertConstraintState, rebasedNodes);
|
|
753
|
-
for (const [_detachId, nodeId] of rebasedRoots.nodeChanges.entries()) {
|
|
754
|
-
// XXX: This is incorrect if the rebased changeset attaches the node.
|
|
755
|
-
// Efficiently computing whether the changeset attaches the node would require maintaining a mapping from node ID to attach ID.
|
|
756
|
-
const detachedInOutput = true;
|
|
757
|
-
this.updateConstraintsForNode(nodeId, fieldChangeHandler_js_1.NodeAttachState.Detached, detachedInOutput ? fieldChangeHandler_js_1.NodeAttachState.Detached : fieldChangeHandler_js_1.NodeAttachState.Attached, rebasedNodes, constraintState, revertConstraintState);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
683
|
updateConstraintsForFields(fields, parentInputAttachState, parentOutputAttachState, constraintState, revertConstraintState, nodes) {
|
|
761
684
|
for (const field of fields.values()) {
|
|
762
685
|
const handler = getChangeHandler(this.fieldKinds, field.fieldKind);
|
|
763
|
-
for (const [nodeId] of handler.getNestedChanges(field.change)) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
686
|
+
for (const [nodeId, inputIndex, outputIndex] of handler.getNestedChanges(field.change)) {
|
|
687
|
+
const isInputDetached = inputIndex === undefined;
|
|
688
|
+
const inputAttachState = parentInputAttachState === fieldChangeHandler_js_1.NodeAttachState.Detached || isInputDetached
|
|
689
|
+
? fieldChangeHandler_js_1.NodeAttachState.Detached
|
|
690
|
+
: fieldChangeHandler_js_1.NodeAttachState.Attached;
|
|
691
|
+
const isOutputDetached = outputIndex === undefined;
|
|
767
692
|
const outputAttachState = parentOutputAttachState === fieldChangeHandler_js_1.NodeAttachState.Detached || isOutputDetached
|
|
768
693
|
? fieldChangeHandler_js_1.NodeAttachState.Detached
|
|
769
694
|
: fieldChangeHandler_js_1.NodeAttachState.Attached;
|
|
770
|
-
this.updateConstraintsForNode(nodeId,
|
|
695
|
+
this.updateConstraintsForNode(nodeId, inputAttachState, outputAttachState, nodes, constraintState, revertConstraintState);
|
|
771
696
|
}
|
|
772
697
|
}
|
|
773
698
|
}
|
|
774
699
|
updateConstraintsForNode(nodeId, inputAttachState, outputAttachState, nodes, constraintState, revertConstraintState) {
|
|
775
|
-
const node = (
|
|
776
|
-
const updatedNode = { ...node };
|
|
777
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodes, nodeId, updatedNode);
|
|
700
|
+
const node = nodes.get([nodeId.revision, nodeId.localId]) ?? (0, internal_1.fail)(0xb24 /* Unknown node ID */);
|
|
778
701
|
if (node.nodeExistsConstraint !== undefined) {
|
|
779
702
|
const isNowViolated = inputAttachState === fieldChangeHandler_js_1.NodeAttachState.Detached;
|
|
780
703
|
if (node.nodeExistsConstraint.violated !== isNowViolated) {
|
|
781
|
-
|
|
704
|
+
node.nodeExistsConstraint = {
|
|
782
705
|
...node.nodeExistsConstraint,
|
|
783
706
|
violated: isNowViolated,
|
|
784
707
|
};
|
|
@@ -788,7 +711,7 @@ class ModularChangeFamily {
|
|
|
788
711
|
if (node.nodeExistsConstraintOnRevert !== undefined) {
|
|
789
712
|
const isNowViolated = outputAttachState === fieldChangeHandler_js_1.NodeAttachState.Detached;
|
|
790
713
|
if (node.nodeExistsConstraintOnRevert.violated !== isNowViolated) {
|
|
791
|
-
|
|
714
|
+
node.nodeExistsConstraintOnRevert = {
|
|
792
715
|
...node.nodeExistsConstraintOnRevert,
|
|
793
716
|
violated: isNowViolated,
|
|
794
717
|
};
|
|
@@ -799,73 +722,35 @@ class ModularChangeFamily {
|
|
|
799
722
|
this.updateConstraintsForFields(node.fieldChanges, inputAttachState, outputAttachState, constraintState, revertConstraintState, nodes);
|
|
800
723
|
}
|
|
801
724
|
}
|
|
802
|
-
pruneFieldMap(changeset,
|
|
725
|
+
pruneFieldMap(changeset, nodeMap) {
|
|
803
726
|
if (changeset === undefined) {
|
|
804
727
|
return undefined;
|
|
805
728
|
}
|
|
806
729
|
const prunedChangeset = new Map();
|
|
807
730
|
for (const [field, fieldChange] of changeset) {
|
|
808
731
|
const handler = getChangeHandler(this.fieldKinds, fieldChange.fieldKind);
|
|
809
|
-
const prunedFieldChangeset = handler.rebaser.prune(fieldChange.change, (nodeId) => this.pruneNodeChange(nodeId, nodeMap
|
|
810
|
-
|
|
811
|
-
const fieldIdKey = fieldIdKeyFromFieldId(fieldId);
|
|
812
|
-
const rootsWithChanges = fieldsToRootChanges.get(fieldIdKey) ?? [];
|
|
813
|
-
let hasRootWithNodeChange = false;
|
|
814
|
-
for (const rootId of rootsWithChanges) {
|
|
815
|
-
const nodeId = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(roots.nodeChanges, rootId) ?? (0, internal_1.fail)("No root change found");
|
|
816
|
-
const isRootChangeEmpty = this.pruneNodeChange(nodeId, nodeMap, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges) === undefined;
|
|
817
|
-
if (isRootChangeEmpty) {
|
|
818
|
-
roots.nodeChanges.delete([rootId.revision, rootId.localId]);
|
|
819
|
-
tryRemoveDetachLocation(roots, rootId, 1);
|
|
820
|
-
}
|
|
821
|
-
else {
|
|
822
|
-
hasRootWithNodeChange = true;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
const hasRootChanges = hasRootWithNodeChange || fieldsWithRootMoves.get(fieldIdKey) === true;
|
|
826
|
-
if (!handler.isEmpty(prunedFieldChangeset) || hasRootChanges) {
|
|
732
|
+
const prunedFieldChangeset = handler.rebaser.prune(fieldChange.change, (nodeId) => this.pruneNodeChange(nodeId, nodeMap));
|
|
733
|
+
if (!handler.isEmpty(prunedFieldChangeset)) {
|
|
827
734
|
prunedChangeset.set(field, { ...fieldChange, change: (0, index_js_3.brand)(prunedFieldChangeset) });
|
|
828
735
|
}
|
|
829
736
|
}
|
|
830
737
|
return prunedChangeset.size > 0 ? prunedChangeset : undefined;
|
|
831
738
|
}
|
|
832
|
-
|
|
833
|
-
const
|
|
834
|
-
for (const [rootIdKey, nodeId] of roots.nodeChanges.entries()) {
|
|
835
|
-
const rootId = { revision: rootIdKey[0], localId: rootIdKey[1] };
|
|
836
|
-
const hasDetachLocation = roots.detachLocations.getFirst(rootId, 1).value !== undefined;
|
|
837
|
-
// If the root has a detach location it should be pruned by recursion when pruning the field it was detached from.
|
|
838
|
-
const prunedId = hasDetachLocation
|
|
839
|
-
? nodeId
|
|
840
|
-
: this.pruneNodeChange(nodeId, nodeMap, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges);
|
|
841
|
-
if (prunedId !== undefined) {
|
|
842
|
-
pruned.nodeChanges.set(rootIdKey, prunedId);
|
|
843
|
-
}
|
|
844
|
-
tryRemoveDetachLocation(pruned, rootId, 1);
|
|
845
|
-
}
|
|
846
|
-
return pruned;
|
|
847
|
-
}
|
|
848
|
-
pruneNodeChange(nodeId, nodes, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges) {
|
|
849
|
-
const changeset = nodeChangeFromId(nodes, aliases, nodeId);
|
|
739
|
+
pruneNodeChange(nodeId, nodeMap) {
|
|
740
|
+
const changeset = nodeChangeFromId(nodeMap, nodeId);
|
|
850
741
|
const prunedFields = changeset.fieldChanges === undefined
|
|
851
742
|
? undefined
|
|
852
|
-
: this.pruneFieldMap(changeset.fieldChanges,
|
|
743
|
+
: this.pruneFieldMap(changeset.fieldChanges, nodeMap);
|
|
853
744
|
const prunedChange = { ...changeset, fieldChanges: prunedFields };
|
|
854
745
|
if (prunedChange.fieldChanges === undefined) {
|
|
855
746
|
delete prunedChange.fieldChanges;
|
|
856
747
|
}
|
|
857
748
|
if (isEmptyNodeChangeset(prunedChange)) {
|
|
858
|
-
|
|
859
|
-
nodeId.revision,
|
|
860
|
-
nodeId.localId,
|
|
861
|
-
];
|
|
862
|
-
// TODO: Shouldn't we also delete all aliases associated with this node?
|
|
863
|
-
nodes.delete(nodeIdKey);
|
|
864
|
-
nodeToParent.delete(nodeIdKey);
|
|
749
|
+
nodeMap.delete([nodeId.revision, nodeId.localId]);
|
|
865
750
|
return undefined;
|
|
866
751
|
}
|
|
867
752
|
else {
|
|
868
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(
|
|
753
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodeMap, nodeId, prunedChange);
|
|
869
754
|
return nodeId;
|
|
870
755
|
}
|
|
871
756
|
}
|
|
@@ -882,13 +767,12 @@ class ModularChangeFamily {
|
|
|
882
767
|
changeRevision(change, replacer) {
|
|
883
768
|
const updatedFields = this.replaceFieldMapRevisions(change.fieldChanges, replacer);
|
|
884
769
|
const updatedNodes = replaceIdMapRevisions(change.nodeChanges, replacer, (nodeChangeset) => this.replaceNodeChangesetRevisions(nodeChangeset, replacer));
|
|
885
|
-
const updatedNodeToParent = replaceIdMapRevisions(change.nodeToParent, replacer, (
|
|
770
|
+
const updatedNodeToParent = replaceIdMapRevisions(change.nodeToParent, replacer, (fieldId) => replaceFieldIdRevision(normalizeFieldId(fieldId, change.nodeAliases), replacer));
|
|
886
771
|
const updated = {
|
|
887
772
|
...change,
|
|
888
773
|
fieldChanges: updatedFields,
|
|
889
774
|
nodeChanges: updatedNodes,
|
|
890
775
|
nodeToParent: updatedNodeToParent,
|
|
891
|
-
rootNodes: replaceRootTableRevision(change.rootNodes, replacer, change.nodeAliases),
|
|
892
776
|
// We've updated all references to old node IDs, so we no longer need an alias table.
|
|
893
777
|
nodeAliases: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
894
778
|
crossFieldKeys: replaceCrossFieldKeyTableRevisions(change.crossFieldKeys, replacer, change.nodeAliases),
|
|
@@ -921,7 +805,7 @@ class ModularChangeFamily {
|
|
|
921
805
|
return updatedFields;
|
|
922
806
|
}
|
|
923
807
|
makeCrossFieldKeyTable(fields, nodes) {
|
|
924
|
-
const keys = (0, modularChangeTypes_js_1.
|
|
808
|
+
const keys = (0, modularChangeTypes_js_1.newCrossFieldKeyTable)();
|
|
925
809
|
this.populateCrossFieldKeyTableForFieldMap(keys, fields, undefined);
|
|
926
810
|
nodes.forEachPair(([revision, localId], node) => {
|
|
927
811
|
if (node.fieldChanges !== undefined) {
|
|
@@ -941,13 +825,49 @@ class ModularChangeFamily {
|
|
|
941
825
|
}
|
|
942
826
|
}
|
|
943
827
|
}
|
|
944
|
-
buildEditor(mintRevisionTag, changeReceiver
|
|
945
|
-
return new ModularEditBuilder(this, this.fieldKinds, changeReceiver, this.codecOptions
|
|
828
|
+
buildEditor(mintRevisionTag, changeReceiver) {
|
|
829
|
+
return new ModularEditBuilder(this, this.fieldKinds, changeReceiver, this.codecOptions);
|
|
946
830
|
}
|
|
947
831
|
createEmptyFieldChange(fieldKind) {
|
|
948
832
|
const emptyChange = getChangeHandler(this.fieldKinds, fieldKind).createEmpty();
|
|
949
833
|
return { fieldKind, change: (0, index_js_3.brand)(emptyChange) };
|
|
950
834
|
}
|
|
835
|
+
validateChangeset(change) {
|
|
836
|
+
let numNodes = this.validateFieldChanges(change, change.fieldChanges, undefined);
|
|
837
|
+
for (const [[revision, localId], node] of change.nodeChanges.entries()) {
|
|
838
|
+
if (node.fieldChanges === undefined) {
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
const nodeId = { revision, localId };
|
|
842
|
+
const numChildren = this.validateFieldChanges(change, node.fieldChanges, nodeId);
|
|
843
|
+
numNodes += numChildren;
|
|
844
|
+
}
|
|
845
|
+
(0, internal_1.assert)(numNodes === change.nodeChanges.size, 0xa4d /* Node table contains unparented nodes */);
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Asserts that each child and cross field key in each field has a correct entry in
|
|
849
|
+
* `nodeToParent` or `crossFieldKeyTable`.
|
|
850
|
+
* @returns the number of children found.
|
|
851
|
+
*/
|
|
852
|
+
validateFieldChanges(change, fieldChanges, nodeParent) {
|
|
853
|
+
let numChildren = 0;
|
|
854
|
+
for (const [field, fieldChange] of fieldChanges.entries()) {
|
|
855
|
+
const fieldId = { nodeId: nodeParent, field };
|
|
856
|
+
const handler = getChangeHandler(this.fieldKinds, fieldChange.fieldKind);
|
|
857
|
+
for (const [child, _index] of handler.getNestedChanges(fieldChange.change)) {
|
|
858
|
+
const parentFieldId = getParentFieldId(change, child);
|
|
859
|
+
(0, internal_1.assert)(areEqualFieldIds(parentFieldId, fieldId), 0xa4e /* Inconsistent node parentage */);
|
|
860
|
+
numChildren += 1;
|
|
861
|
+
}
|
|
862
|
+
for (const keyRange of handler.getCrossFieldKeys(fieldChange.change)) {
|
|
863
|
+
const fields = getFieldsForCrossFieldKey(change, keyRange.key, keyRange.count);
|
|
864
|
+
(0, internal_1.assert)(fields.length === 1 &&
|
|
865
|
+
fields[0] !== undefined &&
|
|
866
|
+
areEqualFieldIds(fields[0], fieldId), 0xa4f /* Inconsistent cross field keys */);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return numChildren;
|
|
870
|
+
}
|
|
951
871
|
getEffectiveChange(change) {
|
|
952
872
|
if (hasConflicts(change)) {
|
|
953
873
|
return this.muteChange(change);
|
|
@@ -960,8 +880,7 @@ class ModularChangeFamily {
|
|
|
960
880
|
muteChange(change) {
|
|
961
881
|
const muted = {
|
|
962
882
|
...change,
|
|
963
|
-
|
|
964
|
-
crossFieldKeys: (0, modularChangeTypes_js_1.newCrossFieldRangeTable)(),
|
|
883
|
+
crossFieldKeys: (0, modularChangeTypes_js_1.newCrossFieldKeyTable)(),
|
|
965
884
|
fieldChanges: this.muteFieldChanges(change.fieldChanges),
|
|
966
885
|
nodeChanges: (0, index_js_3.brand)(change.nodeChanges.mapValues((v) => this.muteNodeChange(v))),
|
|
967
886
|
};
|
|
@@ -990,7 +909,7 @@ class ModularChangeFamily {
|
|
|
990
909
|
exports.ModularChangeFamily = ModularChangeFamily;
|
|
991
910
|
ModularChangeFamily.emptyChange = makeModularChangeset();
|
|
992
911
|
function replaceCrossFieldKeyTableRevisions(table, replacer, nodeAliases) {
|
|
993
|
-
const updated = (0, modularChangeTypes_js_1.
|
|
912
|
+
const updated = (0, modularChangeTypes_js_1.newCrossFieldKeyTable)();
|
|
994
913
|
for (const entry of table.entries()) {
|
|
995
914
|
const key = entry.start;
|
|
996
915
|
const updatedKey = replacer.getUpdatedAtomId(key, entry.length);
|
|
@@ -1049,19 +968,6 @@ function composeBuildsDestroysAndRefreshers(change1, change2) {
|
|
|
1049
968
|
}
|
|
1050
969
|
}
|
|
1051
970
|
}
|
|
1052
|
-
// It's possible to have a build and a refresher for the same root because an attach operation need not be performed in the same changeset as the corresponding build.
|
|
1053
|
-
if (change1.builds !== undefined && change2.refreshers !== undefined) {
|
|
1054
|
-
for (const [key, chunk] of change2.refreshers.entries()) {
|
|
1055
|
-
(0, internal_1.assert)(chunk.topLevelLength === 1, "Expected refresher chunk to have length 1");
|
|
1056
|
-
const match = change1.builds.getPairOrNextLower(key);
|
|
1057
|
-
if (match !== undefined) {
|
|
1058
|
-
const [buildKey, buildChunk] = match;
|
|
1059
|
-
if (buildKey[0] === key[0] && buildKey[1] + buildChunk.topLevelLength > key[1]) {
|
|
1060
|
-
allRefreshers.delete(key);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
971
|
return { allBuilds, allDestroys, allRefreshers };
|
|
1066
972
|
}
|
|
1067
973
|
function invertBuilds(builds) {
|
|
@@ -1086,45 +992,20 @@ function invertBuilds(builds) {
|
|
|
1086
992
|
* @param fieldKinds - The field kinds to delegate to.
|
|
1087
993
|
*/
|
|
1088
994
|
function* relevantRemovedRoots(change, fieldKinds) {
|
|
1089
|
-
|
|
1090
|
-
addAttachesToSet(change, rootIds);
|
|
1091
|
-
addRenamesToSet(change, rootIds);
|
|
1092
|
-
for (const [[revision, localId]] of change.rootNodes.nodeChanges.entries()) {
|
|
1093
|
-
rootIds.set({ revision, localId }, 1, true);
|
|
1094
|
-
}
|
|
1095
|
-
for (const entry of rootIds.entries()) {
|
|
1096
|
-
for (let offset = 0; offset < entry.length; offset++) {
|
|
1097
|
-
const detachId = (0, index_js_2.offsetChangeAtomId)(entry.start, offset);
|
|
1098
|
-
yield (0, index_js_2.makeDetachedNodeId)(detachId.revision, detachId.localId);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
995
|
+
yield* relevantRemovedRootsFromFields(change.fieldChanges, change.nodeChanges, fieldKinds);
|
|
1101
996
|
}
|
|
1102
997
|
exports.relevantRemovedRoots = relevantRemovedRoots;
|
|
1103
|
-
function
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
continue;
|
|
1108
|
-
}
|
|
1109
|
-
for (const detachIdEntry of change.rootNodes.newToOldId.getAll2(entry.start, entry.length)) {
|
|
1110
|
-
const detachId = detachIdEntry.value ?? (0, index_js_2.offsetChangeAtomId)(entry.start, detachIdEntry.offset);
|
|
1111
|
-
for (const detachEntry of change.crossFieldKeys.getAll2({ ...detachId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, detachIdEntry.length)) {
|
|
1112
|
-
if (detachEntry.value === undefined) {
|
|
1113
|
-
rootIds.set((0, index_js_2.offsetChangeAtomId)(detachId, detachEntry.offset), detachEntry.length, true);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
998
|
+
function* relevantRemovedRootsFromNode(node, nodeChanges, fieldKinds) {
|
|
999
|
+
const nodeChangeset = nodeChangeFromId(nodeChanges, node);
|
|
1000
|
+
if (nodeChangeset.fieldChanges !== undefined) {
|
|
1001
|
+
yield* relevantRemovedRootsFromFields(nodeChangeset.fieldChanges, nodeChanges, fieldKinds);
|
|
1117
1002
|
}
|
|
1118
1003
|
}
|
|
1119
|
-
function
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
if (detachEntry.value === undefined) {
|
|
1125
|
-
rootIds.set(renameEntry.start, renameEntry.length, true);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1004
|
+
function* relevantRemovedRootsFromFields(change, nodeChanges, fieldKinds) {
|
|
1005
|
+
const delegate = (node) => relevantRemovedRootsFromNode(node, nodeChanges, fieldKinds);
|
|
1006
|
+
for (const [_, fieldChange] of change) {
|
|
1007
|
+
const handler = getChangeHandler(fieldKinds, fieldChange.fieldKind);
|
|
1008
|
+
yield* handler.relevantRemovedRoots(fieldChange.change, delegate);
|
|
1128
1009
|
}
|
|
1129
1010
|
}
|
|
1130
1011
|
/**
|
|
@@ -1170,15 +1051,13 @@ function updateRefreshers(change, getDetachedNode, removedRoots, requireRefreshe
|
|
|
1170
1051
|
refreshers.set([root.major, (0, index_js_3.brand)(root.minor)], node);
|
|
1171
1052
|
}
|
|
1172
1053
|
}
|
|
1173
|
-
const {
|
|
1054
|
+
const { fieldChanges, nodeChanges, nodeToParent, nodeAliases, crossFieldKeys, maxId, revisions, constraintViolationCount, constraintViolationCountOnRevert, builds, destroys, } = change;
|
|
1174
1055
|
return makeModularChangeset({
|
|
1175
|
-
rebaseVersion,
|
|
1176
1056
|
fieldChanges,
|
|
1177
1057
|
nodeChanges,
|
|
1178
1058
|
nodeToParent,
|
|
1179
1059
|
nodeAliases,
|
|
1180
1060
|
crossFieldKeys,
|
|
1181
|
-
rootNodes,
|
|
1182
1061
|
maxId: maxId,
|
|
1183
1062
|
revisions,
|
|
1184
1063
|
constraintViolationCount,
|
|
@@ -1198,24 +1077,11 @@ exports.updateRefreshers = updateRefreshers;
|
|
|
1198
1077
|
function intoDelta(taggedChange, fieldKinds) {
|
|
1199
1078
|
const change = taggedChange.change;
|
|
1200
1079
|
const rootDelta = {};
|
|
1080
|
+
const global = [];
|
|
1081
|
+
const rename = [];
|
|
1201
1082
|
if (!hasConflicts(change)) {
|
|
1202
1083
|
// If there are no constraint violations, then tree changes apply.
|
|
1203
|
-
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges,
|
|
1204
|
-
const global = [];
|
|
1205
|
-
for (const [[major, minor], nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
1206
|
-
global.push({
|
|
1207
|
-
id: { major, minor },
|
|
1208
|
-
fields: deltaFromNodeChange(nodeChangeFromId(change.nodeChanges, change.nodeAliases, nodeId), change.nodeChanges, change.nodeAliases, fieldKinds),
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
const rename = [];
|
|
1212
|
-
for (const { start: oldId, value: newId, length, } of change.rootNodes.oldToNewId.entries()) {
|
|
1213
|
-
rename.push({
|
|
1214
|
-
count: length,
|
|
1215
|
-
oldId: (0, index_js_2.makeDetachedNodeId)(oldId.revision, oldId.localId),
|
|
1216
|
-
newId: (0, index_js_2.makeDetachedNodeId)(newId.revision, newId.localId),
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1084
|
+
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges, fieldKinds, global, rename);
|
|
1219
1085
|
if (fieldDeltas.size > 0) {
|
|
1220
1086
|
rootDelta.fields = fieldDeltas;
|
|
1221
1087
|
}
|
|
@@ -1262,22 +1128,28 @@ function copyDetachedNodes(detachedNodes) {
|
|
|
1262
1128
|
/**
|
|
1263
1129
|
* @param change - The change to convert into a delta.
|
|
1264
1130
|
*/
|
|
1265
|
-
function intoDeltaImpl(change, nodeChanges,
|
|
1131
|
+
function intoDeltaImpl(change, nodeChanges, fieldKinds, global, rename) {
|
|
1266
1132
|
const delta = new Map();
|
|
1267
1133
|
for (const [field, fieldChange] of change) {
|
|
1268
|
-
const
|
|
1269
|
-
const nodeChange = nodeChangeFromId(nodeChanges,
|
|
1270
|
-
return deltaFromNodeChange(nodeChange, nodeChanges,
|
|
1134
|
+
const { local: fieldChanges, global: fieldGlobal, rename: fieldRename, } = getChangeHandler(fieldKinds, fieldChange.fieldKind).intoDelta(fieldChange.change, (childChange) => {
|
|
1135
|
+
const nodeChange = nodeChangeFromId(nodeChanges, childChange);
|
|
1136
|
+
return deltaFromNodeChange(nodeChange, nodeChanges, fieldKinds, global, rename);
|
|
1271
1137
|
});
|
|
1272
|
-
if (
|
|
1273
|
-
delta.set(field,
|
|
1138
|
+
if (fieldChanges !== undefined && fieldChanges.marks.length > 0) {
|
|
1139
|
+
delta.set(field, fieldChanges);
|
|
1140
|
+
}
|
|
1141
|
+
for (const c of fieldGlobal ?? []) {
|
|
1142
|
+
global.push(c);
|
|
1143
|
+
}
|
|
1144
|
+
for (const r of fieldRename ?? []) {
|
|
1145
|
+
rename.push(r);
|
|
1274
1146
|
}
|
|
1275
1147
|
}
|
|
1276
1148
|
return delta;
|
|
1277
1149
|
}
|
|
1278
|
-
function deltaFromNodeChange(change, nodeChanges,
|
|
1150
|
+
function deltaFromNodeChange(change, nodeChanges, fieldKinds, global, rename) {
|
|
1279
1151
|
if (change.fieldChanges !== undefined) {
|
|
1280
|
-
return intoDeltaImpl(change.fieldChanges, nodeChanges,
|
|
1152
|
+
return intoDeltaImpl(change.fieldChanges, nodeChanges, fieldKinds, global, rename);
|
|
1281
1153
|
}
|
|
1282
1154
|
// TODO: update the API to allow undefined to be returned here
|
|
1283
1155
|
return new Map();
|
|
@@ -1327,22 +1199,30 @@ function getChangeHandler(fieldKinds, kind) {
|
|
|
1327
1199
|
return getFieldKind(fieldKinds, kind).changeHandler;
|
|
1328
1200
|
}
|
|
1329
1201
|
exports.getChangeHandler = getChangeHandler;
|
|
1330
|
-
function newComposeTable(baseChange, newChange,
|
|
1202
|
+
function newComposeTable(baseChange, newChange, composedNodeToParent) {
|
|
1331
1203
|
return {
|
|
1332
|
-
|
|
1333
|
-
entries: newDetachedEntryMap(),
|
|
1204
|
+
...newCrossFieldTable(),
|
|
1334
1205
|
baseChange,
|
|
1335
1206
|
newChange,
|
|
1336
1207
|
fieldToContext: new Map(),
|
|
1337
1208
|
newFieldToBaseField: new Map(),
|
|
1338
1209
|
newToBaseNodeId: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1339
1210
|
composedNodes: new Set(),
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1211
|
+
composedNodeToParent,
|
|
1212
|
+
pendingCompositions: {
|
|
1213
|
+
nodeIdsToCompose: [],
|
|
1214
|
+
affectedBaseFields: newFieldIdKeyBTree(),
|
|
1215
|
+
affectedNewFields: newFieldIdKeyBTree(),
|
|
1216
|
+
},
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
function newCrossFieldTable() {
|
|
1220
|
+
return {
|
|
1221
|
+
srcTable: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
1222
|
+
dstTable: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
1223
|
+
srcDependents: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
1224
|
+
dstDependents: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
1225
|
+
invalidatedFields: new Set(),
|
|
1346
1226
|
};
|
|
1347
1227
|
}
|
|
1348
1228
|
function newConstraintState(violationCount) {
|
|
@@ -1350,348 +1230,146 @@ function newConstraintState(violationCount) {
|
|
|
1350
1230
|
violationCount,
|
|
1351
1231
|
};
|
|
1352
1232
|
}
|
|
1353
|
-
class
|
|
1354
|
-
constructor(
|
|
1355
|
-
this.
|
|
1356
|
-
this.
|
|
1233
|
+
class CrossFieldManagerI {
|
|
1234
|
+
constructor(crossFieldTable, currentFieldKey, allowInval = true) {
|
|
1235
|
+
this.crossFieldTable = crossFieldTable;
|
|
1236
|
+
this.currentFieldKey = currentFieldKey;
|
|
1237
|
+
this.allowInval = allowInval;
|
|
1357
1238
|
}
|
|
1358
|
-
|
|
1359
|
-
if (
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
else {
|
|
1367
|
-
(0, crossFieldQueries_js_1.setInCrossFieldMap)(this.table.entries, attachEntry.value, count, nodeChange);
|
|
1368
|
-
this.table.invalidatedFields.add(fieldChangeFromId(this.table.change, attachFieldEntry.value));
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
if (!(0, index_js_2.areEqualChangeAtomIds)(detachId, newAttachId)) {
|
|
1372
|
-
for (const entry of doesChangeAttachNodes(this.table.change.crossFieldKeys, detachId, count)) {
|
|
1373
|
-
if (!entry.value) {
|
|
1374
|
-
this.table.attachToDetachId.set(newAttachId, count, detachId);
|
|
1375
|
-
this.table.invertedRoots.detachLocations.set(detachId, count, this.fieldId);
|
|
1239
|
+
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1240
|
+
if (invalidateDependents && this.allowInval) {
|
|
1241
|
+
const lastChangedId = id + count - 1;
|
|
1242
|
+
let firstId = id;
|
|
1243
|
+
while (firstId <= lastChangedId) {
|
|
1244
|
+
const dependentEntry = (0, crossFieldQueries_js_1.getFirstFromCrossFieldMap)(this.getDependents(target), revision, firstId, lastChangedId - firstId + 1);
|
|
1245
|
+
if (dependentEntry.value !== undefined) {
|
|
1246
|
+
this.crossFieldTable.invalidatedFields.add(dependentEntry.value);
|
|
1376
1247
|
}
|
|
1248
|
+
firstId = (0, index_js_3.brand)(firstId + dependentEntry.length);
|
|
1377
1249
|
}
|
|
1378
1250
|
}
|
|
1251
|
+
(0, crossFieldQueries_js_1.setInCrossFieldMap)(this.getMap(target), revision, id, count, newValue);
|
|
1379
1252
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
let result;
|
|
1387
|
-
if (detachEntry.value === undefined) {
|
|
1388
|
-
// This node is detached in the input context of the original change.
|
|
1389
|
-
const nodeIdEntry = (0, changeAtomIdBTree_js_1.rangeQueryChangeAtomIdMap)(this.table.change.rootNodes.nodeChanges, detachIdEntry.value, countToProcess);
|
|
1390
|
-
countToProcess = nodeIdEntry.length;
|
|
1391
|
-
const detachLocationEntry = this.table.change.rootNodes.detachLocations.getFirst(detachIdEntry.value, countToProcess);
|
|
1392
|
-
countToProcess = detachLocationEntry.length;
|
|
1393
|
-
if (this.table.isRollback &&
|
|
1394
|
-
detachLocationEntry.value !== undefined &&
|
|
1395
|
-
!areEqualFieldIds(normalizeFieldId(detachLocationEntry.value, this.table.change.nodeAliases), this.fieldId)) {
|
|
1396
|
-
// These nodes are detached in the input context of the original change,
|
|
1397
|
-
// and the change attaches these nodes in a different location from their detach location.
|
|
1398
|
-
// The rollback change should send them back to that prior detach location.
|
|
1399
|
-
this.table.invertedRoots.outputDetachLocations.set(detachIdEntry.value, countToProcess, detachLocationEntry.value);
|
|
1400
|
-
}
|
|
1401
|
-
result = {
|
|
1402
|
-
value: {
|
|
1403
|
-
nodeChange: nodeIdEntry.value,
|
|
1404
|
-
detachId: detachIdEntry.value,
|
|
1405
|
-
},
|
|
1406
|
-
length: countToProcess,
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
else {
|
|
1410
|
-
const moveEntry = this.table.entries.getFirst(attachId, countToProcess);
|
|
1411
|
-
result = { ...moveEntry, value: { nodeChange: moveEntry.value } };
|
|
1412
|
-
}
|
|
1413
|
-
if (result.value?.nodeChange !== undefined) {
|
|
1414
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(this.table.invertedNodeToParent, result.value.nodeChange, {
|
|
1415
|
-
field: this.fieldId,
|
|
1416
|
-
});
|
|
1253
|
+
get(target, revision, id, count, addDependency) {
|
|
1254
|
+
if (addDependency) {
|
|
1255
|
+
// We assume that if there is already an entry for this ID it is because
|
|
1256
|
+
// a field handler has called compose on the same node multiple times.
|
|
1257
|
+
// In this case we only want to update the latest version, so we overwrite the dependency.
|
|
1258
|
+
(0, crossFieldQueries_js_1.setInCrossFieldMap)(this.getDependents(target), revision, id, count, this.currentFieldKey);
|
|
1417
1259
|
}
|
|
1418
|
-
return
|
|
1260
|
+
return (0, crossFieldQueries_js_1.getFirstFromCrossFieldMap)(this.getMap(target), revision, id, count);
|
|
1261
|
+
}
|
|
1262
|
+
getMap(target) {
|
|
1263
|
+
return target === crossFieldQueries_js_1.CrossFieldTarget.Source
|
|
1264
|
+
? this.crossFieldTable.srcTable
|
|
1265
|
+
: this.crossFieldTable.dstTable;
|
|
1266
|
+
}
|
|
1267
|
+
getDependents(target) {
|
|
1268
|
+
return target === crossFieldQueries_js_1.CrossFieldTarget.Source
|
|
1269
|
+
? this.crossFieldTable.srcDependents
|
|
1270
|
+
: this.crossFieldTable.dstDependents;
|
|
1419
1271
|
}
|
|
1420
1272
|
}
|
|
1421
|
-
class
|
|
1422
|
-
constructor(table, fieldId, allowInval = true) {
|
|
1423
|
-
|
|
1273
|
+
class InvertManager extends CrossFieldManagerI {
|
|
1274
|
+
constructor(table, field, fieldId, allowInval = true) {
|
|
1275
|
+
super(table, field, allowInval);
|
|
1424
1276
|
this.fieldId = fieldId;
|
|
1425
|
-
this.allowInval = allowInval;
|
|
1426
1277
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
countToProcess = newRenameEntry.length;
|
|
1436
|
-
let result;
|
|
1437
|
-
// eslint-disable-next-line unicorn/prefer-ternary
|
|
1438
|
-
if (newNodeId !== undefined || newRenameEntry.value !== undefined) {
|
|
1439
|
-
result = {
|
|
1440
|
-
...newRenameEntry,
|
|
1441
|
-
value: { detachId: newRenameEntry.value, nodeChange: newNodeId },
|
|
1442
|
-
};
|
|
1443
|
-
}
|
|
1444
|
-
else {
|
|
1445
|
-
// This handles the case where the base changeset has moved these nodes,
|
|
1446
|
-
// meaning they were attached in the input context of the base changeset.
|
|
1447
|
-
result = this.table.entries.getFirst(baseAttachId, countToProcess);
|
|
1448
|
-
}
|
|
1449
|
-
// TODO: Consider moving these two checks into a separate method so that this function has no side effects.
|
|
1450
|
-
if (result.value?.detachId !== undefined) {
|
|
1451
|
-
this.table.rebasedDetachLocations.set(result.value.detachId, result.length, this.fieldId);
|
|
1452
|
-
}
|
|
1453
|
-
if (result.value?.nodeChange !== undefined) {
|
|
1454
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(this.table.rebasedNodeToParent, result.value.nodeChange, {
|
|
1455
|
-
field: this.fieldId,
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
|
-
return result;
|
|
1459
|
-
}
|
|
1460
|
-
rebaseOverDetach(baseDetachId, count, newDetachId, nodeChange, cellRename) {
|
|
1461
|
-
let countToProcess = count;
|
|
1462
|
-
const attachIdEntry = firstAttachIdFromDetachId(this.table.baseRoots, baseDetachId, countToProcess);
|
|
1463
|
-
const baseAttachId = attachIdEntry.value;
|
|
1464
|
-
countToProcess = attachIdEntry.length;
|
|
1465
|
-
const attachFieldEntry = getFirstFieldForCrossFieldKey(this.table.baseChange, { ...baseAttachId, target: crossFieldQueries_js_1.NodeMoveType.Attach }, countToProcess);
|
|
1466
|
-
countToProcess = attachFieldEntry.length;
|
|
1467
|
-
const detachedMoveEntry = this.table.baseChange.rootNodes.outputDetachLocations.getFirst(baseDetachId, countToProcess);
|
|
1468
|
-
countToProcess = detachedMoveEntry.length;
|
|
1469
|
-
const destinationField = attachFieldEntry.value ?? detachedMoveEntry.value;
|
|
1470
|
-
if (destinationField !== undefined) {
|
|
1471
|
-
// The base detach is part of a move (or move of detach location) in the base changeset.
|
|
1472
|
-
(0, crossFieldQueries_js_1.setInCrossFieldMap)(this.table.entries, baseAttachId, countToProcess, {
|
|
1473
|
-
nodeChange,
|
|
1474
|
-
detachId: newDetachId,
|
|
1475
|
-
cellRename,
|
|
1476
|
-
});
|
|
1477
|
-
if (nodeChange !== undefined || newDetachId !== undefined) {
|
|
1478
|
-
this.invalidateBaseFields([destinationField]);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
if (attachFieldEntry.value === undefined) {
|
|
1482
|
-
// These nodes are detached in the output context of the base changeset.
|
|
1483
|
-
if (nodeChange !== undefined) {
|
|
1484
|
-
assignRootChange(this.table.rebasedRootNodes, this.table.rebasedNodeToParent, baseAttachId, nodeChange, this.fieldId, this.table.rebaseVersion);
|
|
1485
|
-
}
|
|
1486
|
-
if (newDetachId !== undefined) {
|
|
1487
|
-
addNodeRename(this.table.rebasedRootNodes, baseAttachId, newDetachId, countToProcess, this.fieldId);
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
if (newDetachId !== undefined) {
|
|
1491
|
-
this.table.movedDetaches.set(newDetachId, countToProcess, true);
|
|
1492
|
-
}
|
|
1493
|
-
if (countToProcess < count) {
|
|
1494
|
-
const remainingCount = count - countToProcess;
|
|
1495
|
-
const nextDetachId = newDetachId === undefined
|
|
1496
|
-
? undefined
|
|
1497
|
-
: (0, index_js_2.offsetChangeAtomId)(newDetachId, countToProcess);
|
|
1498
|
-
this.rebaseOverDetach((0, index_js_2.offsetChangeAtomId)(baseDetachId, countToProcess), remainingCount, nextDetachId, nodeChange);
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
addDetach(id, count) {
|
|
1502
|
-
this.table.rebasedDetachLocations.set(id, count, this.fieldId);
|
|
1503
|
-
}
|
|
1504
|
-
removeDetach(id, count) {
|
|
1505
|
-
this.table.movedDetaches.set(id, count, true);
|
|
1506
|
-
}
|
|
1507
|
-
doesBaseAttachNodes(id, count) {
|
|
1508
|
-
let countToProcess = count;
|
|
1509
|
-
const attachEntry = getFirstAttachField(this.table.baseChange.crossFieldKeys, id, countToProcess);
|
|
1510
|
-
countToProcess = attachEntry.length;
|
|
1511
|
-
return { start: id, value: attachEntry.value !== undefined, length: countToProcess };
|
|
1512
|
-
}
|
|
1513
|
-
getBaseRename(id, count) {
|
|
1514
|
-
return this.table.baseChange.rootNodes.oldToNewId.getFirst(id, count);
|
|
1515
|
-
}
|
|
1516
|
-
getNewRenameForBaseRename(baseRenameTo, count) {
|
|
1517
|
-
let countToProcess = count;
|
|
1518
|
-
const inputEntry = firstDetachIdFromAttachId(this.table.baseChange.rootNodes, baseRenameTo, countToProcess);
|
|
1519
|
-
const attachEntry = getFirstAttachField(this.table.baseChange.crossFieldKeys, baseRenameTo, countToProcess);
|
|
1520
|
-
countToProcess = attachEntry.length;
|
|
1521
|
-
if (attachEntry.value !== undefined) {
|
|
1522
|
-
// These nodes are attached in the output context of the base changeset.
|
|
1523
|
-
return { value: undefined, length: countToProcess };
|
|
1524
|
-
}
|
|
1525
|
-
countToProcess = inputEntry.length;
|
|
1526
|
-
const inputId = inputEntry.value;
|
|
1527
|
-
const moveEntry = this.table.entries.getFirst(inputId, countToProcess);
|
|
1528
|
-
countToProcess = moveEntry.length;
|
|
1529
|
-
if (moveEntry.value !== undefined) {
|
|
1530
|
-
return { ...moveEntry, value: moveEntry.value.cellRename ?? moveEntry.value.detachId };
|
|
1531
|
-
}
|
|
1532
|
-
return this.table.newChange.rootNodes.oldToNewId.getFirst(inputId, countToProcess);
|
|
1533
|
-
}
|
|
1534
|
-
invalidateBaseFields(fields) {
|
|
1535
|
-
if (this.allowInval) {
|
|
1536
|
-
for (const fieldId of fields) {
|
|
1537
|
-
this.table.affectedBaseFields.set(fieldIdKeyFromFieldId(fieldId), true);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1278
|
+
onMoveIn(id) {
|
|
1279
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(this.table.invertedNodeToParent, id, this.fieldId);
|
|
1280
|
+
}
|
|
1281
|
+
moveKey(target, revision, id, count) {
|
|
1282
|
+
(0, internal_1.assert)(false, 0x9c5 /* Keys should not be moved manually during invert */);
|
|
1283
|
+
}
|
|
1284
|
+
get table() {
|
|
1285
|
+
return this.crossFieldTable;
|
|
1540
1286
|
}
|
|
1541
1287
|
}
|
|
1542
|
-
|
|
1543
|
-
(
|
|
1544
|
-
|
|
1545
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodeToParent, nodeId, { root: detachId });
|
|
1546
|
-
table.detachLocations.set(detachId, 1, detachLocation);
|
|
1547
|
-
}
|
|
1548
|
-
class ComposeNodeManagerI {
|
|
1549
|
-
constructor(table, fieldId, allowInval = true) {
|
|
1550
|
-
this.table = table;
|
|
1288
|
+
class RebaseManager extends CrossFieldManagerI {
|
|
1289
|
+
constructor(table, currentField, fieldId, allowInval = true) {
|
|
1290
|
+
super(table, currentField, allowInval);
|
|
1551
1291
|
this.fieldId = fieldId;
|
|
1552
|
-
this.allowInval = allowInval;
|
|
1553
1292
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
else {
|
|
1571
|
-
// The base detach was part of a move.
|
|
1572
|
-
// We check if we've previously seen a node change at the move destination.
|
|
1573
|
-
const entry = this.table.entries.getFirst(baseDetachId, countToProcess);
|
|
1574
|
-
result = { value: entry.value, length: entry.length };
|
|
1575
|
-
}
|
|
1576
|
-
// TODO: Consider moving this to a separate method so that this method can be side-effect free.
|
|
1577
|
-
if (result.value?.nodeChange !== undefined) {
|
|
1578
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(this.table.movedNodeToParent, result.value.nodeChange, {
|
|
1579
|
-
field: this.fieldId,
|
|
1580
|
-
});
|
|
1581
|
-
}
|
|
1582
|
-
return result;
|
|
1583
|
-
}
|
|
1584
|
-
composeAttachDetach(baseAttachId, newDetachId, count) {
|
|
1585
|
-
let countToProcess = count;
|
|
1586
|
-
const newAttachEntry = getFirstAttachField(this.table.newChange.crossFieldKeys, newDetachId, countToProcess);
|
|
1587
|
-
countToProcess = newAttachEntry.length;
|
|
1588
|
-
// Both changes can have the same ID if they came from inverse changesets.
|
|
1589
|
-
// If the new detach is part of a move,
|
|
1590
|
-
// then both input changesets contain the attach cross-field key for this ID.
|
|
1591
|
-
// The new attach may still exist in the composed changeset so we do not remove it here.
|
|
1592
|
-
// The new attach will typically cancel with a base detach,
|
|
1593
|
-
// in which case the cross-field key will be removed in `composeDetachAttach`.
|
|
1594
|
-
const hasNewAttachWithBaseAttachId = (0, index_js_2.areEqualChangeAtomIds)(baseAttachId, newDetachId) && newAttachEntry.value !== undefined;
|
|
1595
|
-
if (!hasNewAttachWithBaseAttachId) {
|
|
1596
|
-
this.table.removedCrossFieldKeys.set({ ...baseAttachId, target: crossFieldQueries_js_1.NodeMoveType.Attach }, countToProcess, true);
|
|
1597
|
-
}
|
|
1598
|
-
const baseDetachEntry = getFirstDetachField(this.table.baseChange.crossFieldKeys, baseAttachId, countToProcess);
|
|
1599
|
-
countToProcess = baseDetachEntry.length;
|
|
1600
|
-
const baseRootIdEntry = firstDetachIdFromAttachId(this.table.baseChange.rootNodes, baseAttachId, countToProcess);
|
|
1601
|
-
countToProcess = baseRootIdEntry.length;
|
|
1602
|
-
const baseDetachId = baseRootIdEntry.value;
|
|
1603
|
-
if (baseDetachEntry.value === undefined) {
|
|
1604
|
-
const baseDetachLocationEntry = this.table.baseChange.rootNodes.detachLocations.getFirst(baseDetachId, countToProcess);
|
|
1605
|
-
countToProcess = baseDetachLocationEntry.length;
|
|
1606
|
-
// These nodes were detached in the base change's input context,
|
|
1607
|
-
// so the net effect of the two changes is a rename.
|
|
1608
|
-
appendNodeRename(this.table.composedRootNodes, baseAttachId, newDetachId, baseDetachEntry.length, this.table.baseChange.rootNodes, baseDetachLocationEntry.value ?? this.fieldId);
|
|
1609
|
-
this.table.removedCrossFieldKeys.set({ ...newDetachId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, countToProcess, true);
|
|
1610
|
-
}
|
|
1611
|
-
else {
|
|
1612
|
-
// The base change moves these nodes.
|
|
1613
|
-
const prevEntry = this.table.entries.getFirst(baseAttachId, baseDetachEntry.length).value ?? {};
|
|
1614
|
-
this.table.entries.set(baseAttachId, baseDetachEntry.length, {
|
|
1615
|
-
...prevEntry,
|
|
1616
|
-
detachId: newDetachId,
|
|
1617
|
-
});
|
|
1618
|
-
// The new detach will replace the base detach, so we remove the key for the base detach, unless they have the same ID.
|
|
1619
|
-
if (!(0, index_js_2.areEqualChangeAtomIds)(baseAttachId, newDetachId)) {
|
|
1620
|
-
this.table.removedCrossFieldKeys.set({ ...baseAttachId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, countToProcess, true);
|
|
1621
|
-
}
|
|
1622
|
-
this.table.movedCrossFieldKeys.set({ ...newDetachId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, countToProcess, baseDetachEntry.value);
|
|
1623
|
-
this.invalidateBaseFields([baseDetachEntry.value]);
|
|
1624
|
-
}
|
|
1625
|
-
if (newAttachEntry.value === undefined) {
|
|
1626
|
-
const newOutputDetachLocationEntry = this.table.newChange.rootNodes.outputDetachLocations.getFirst(newDetachId, countToProcess);
|
|
1627
|
-
countToProcess = newOutputDetachLocationEntry.length;
|
|
1628
|
-
this.table.composedRootNodes.outputDetachLocations.set(newDetachId, countToProcess, newOutputDetachLocationEntry.value ?? this.fieldId);
|
|
1629
|
-
}
|
|
1630
|
-
if (countToProcess < count) {
|
|
1631
|
-
const remainingCount = count - countToProcess;
|
|
1632
|
-
this.composeAttachDetach((0, index_js_2.offsetChangeAtomId)(baseAttachId, countToProcess), (0, index_js_2.offsetChangeAtomId)(newDetachId, countToProcess), remainingCount);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
sendNewChangesToBaseSourceLocation(baseAttachId, newChanges) {
|
|
1636
|
-
const { value: baseDetachId } = firstDetachIdFromAttachId(this.table.baseChange.rootNodes, baseAttachId, 1);
|
|
1637
|
-
const detachFields = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1638
|
-
...baseDetachId,
|
|
1639
|
-
target: crossFieldQueries_js_1.NodeMoveType.Detach,
|
|
1640
|
-
}, 1);
|
|
1641
|
-
if (detachFields.length > 0) {
|
|
1642
|
-
// The base attach is part of a move in the base changeset.
|
|
1643
|
-
const prevEntry = this.table.entries.getFirst(baseDetachId, 1).value ?? {};
|
|
1644
|
-
this.table.entries.set(baseDetachId, 1, { ...prevEntry, nodeChange: newChanges });
|
|
1645
|
-
if (newChanges !== undefined) {
|
|
1646
|
-
this.invalidateBaseFields(detachFields);
|
|
1293
|
+
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1294
|
+
if (invalidateDependents && this.allowInval) {
|
|
1295
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1296
|
+
target,
|
|
1297
|
+
revision,
|
|
1298
|
+
localId: id,
|
|
1299
|
+
}, count);
|
|
1300
|
+
(0, internal_1.assert)(newFieldIds.length === 0, 0x9c6 /* TODO: Modifying a cross-field key from the new changeset is currently unsupported */);
|
|
1301
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1302
|
+
target,
|
|
1303
|
+
revision,
|
|
1304
|
+
localId: id,
|
|
1305
|
+
}, count);
|
|
1306
|
+
(0, internal_1.assert)(baseFieldIds.length > 0, 0x9c7 /* Cross field key not registered in base or new change */);
|
|
1307
|
+
for (const baseFieldId of baseFieldIds) {
|
|
1308
|
+
this.table.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
1647
1309
|
}
|
|
1648
1310
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1311
|
+
super.set(target, revision, id, count, newValue, invalidateDependents);
|
|
1312
|
+
}
|
|
1313
|
+
onMoveIn(id) {
|
|
1314
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(this.table.rebasedNodeToParent, id, this.fieldId);
|
|
1315
|
+
}
|
|
1316
|
+
moveKey(target, revision, id, count) {
|
|
1317
|
+
this.table.rebasedCrossFieldKeys.set({ target, revision, localId: id }, count, this.fieldId);
|
|
1318
|
+
}
|
|
1319
|
+
get table() {
|
|
1320
|
+
return this.crossFieldTable;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
// TODO: Deduplicate this with RebaseTable
|
|
1324
|
+
class ComposeManager extends CrossFieldManagerI {
|
|
1325
|
+
constructor(table, currentField, fieldId, allowInval = true) {
|
|
1326
|
+
super(table, currentField, allowInval);
|
|
1327
|
+
this.fieldId = fieldId;
|
|
1328
|
+
}
|
|
1329
|
+
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1330
|
+
if (invalidateDependents && this.allowInval) {
|
|
1331
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1332
|
+
target,
|
|
1333
|
+
revision,
|
|
1334
|
+
localId: id,
|
|
1335
|
+
}, count);
|
|
1336
|
+
if (newFieldIds.length > 0) {
|
|
1337
|
+
for (const newFieldId of newFieldIds) {
|
|
1338
|
+
this.table.pendingCompositions.affectedNewFields.set([newFieldId.nodeId?.revision, newFieldId.nodeId?.localId, newFieldId.field], true);
|
|
1339
|
+
}
|
|
1653
1340
|
}
|
|
1654
1341
|
else {
|
|
1655
|
-
|
|
1342
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1343
|
+
target,
|
|
1344
|
+
revision,
|
|
1345
|
+
localId: id,
|
|
1346
|
+
}, count);
|
|
1347
|
+
(0, internal_1.assert)(baseFieldIds.length > 0, 0x9c8 /* Cross field key not registered in base or new change */);
|
|
1348
|
+
for (const baseFieldId of baseFieldIds) {
|
|
1349
|
+
this.table.pendingCompositions.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
1350
|
+
}
|
|
1656
1351
|
}
|
|
1657
1352
|
}
|
|
1353
|
+
super.set(target, revision, id, count, newValue, invalidateDependents);
|
|
1658
1354
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
this.table.movedCrossFieldKeys.set({ target: crossFieldQueries_js_1.NodeMoveType.Detach, ...newAttachId }, count, this.fieldId);
|
|
1662
|
-
if (!(0, index_js_2.areEqualChangeAtomIds)(baseDetachId, newAttachId)) {
|
|
1663
|
-
// The pin will have `newAttachId` as both its detach and attach ID.
|
|
1664
|
-
// So we remove `baseDetachId` unless that is equal to the pin's detach ID.
|
|
1665
|
-
this.table.removedCrossFieldKeys.set({ target: crossFieldQueries_js_1.NodeMoveType.Detach, ...baseDetachId }, count, true);
|
|
1666
|
-
}
|
|
1667
|
-
// Note that while change2 should already have this key, change1 may have a rollback for the same ID in a different location.
|
|
1668
|
-
// In that case, change1's attach should be canceled out by a detach from change2.
|
|
1669
|
-
// Here we make sure that the composed change has the correct location (this field) for the attach ID.
|
|
1670
|
-
this.table.movedCrossFieldKeys.set({ target: crossFieldQueries_js_1.NodeMoveType.Attach, ...newAttachId }, count, this.fieldId);
|
|
1671
|
-
}
|
|
1672
|
-
else {
|
|
1673
|
-
this.table.removedCrossFieldKeys.set({ target: crossFieldQueries_js_1.NodeMoveType.Detach, ...baseDetachId }, count, true);
|
|
1674
|
-
this.table.removedCrossFieldKeys.set({ target: crossFieldQueries_js_1.NodeMoveType.Attach, ...newAttachId }, count, true);
|
|
1675
|
-
}
|
|
1355
|
+
onMoveIn(id) {
|
|
1356
|
+
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(this.table.composedNodeToParent, id, this.fieldId);
|
|
1676
1357
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
}
|
|
1358
|
+
moveKey(target, revision, id, count) {
|
|
1359
|
+
throw new Error("Moving cross-field keys during compose is currently unsupported");
|
|
1360
|
+
}
|
|
1361
|
+
get table() {
|
|
1362
|
+
return this.crossFieldTable;
|
|
1683
1363
|
}
|
|
1684
1364
|
}
|
|
1685
1365
|
function makeModularChangeset(props) {
|
|
1686
|
-
const p = props ?? { maxId: -1
|
|
1366
|
+
const p = props ?? { maxId: -1 };
|
|
1687
1367
|
const changeset = {
|
|
1688
|
-
rebaseVersion: p.rebaseVersion,
|
|
1689
1368
|
fieldChanges: p.fieldChanges ?? new Map(),
|
|
1690
1369
|
nodeChanges: p.nodeChanges ?? (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1691
|
-
rootNodes: p.rootNodes ?? newRootTable(),
|
|
1692
1370
|
nodeToParent: p.nodeToParent ?? (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1693
1371
|
nodeAliases: p.nodeAliases ?? (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1694
|
-
crossFieldKeys: p.crossFieldKeys ?? (0, modularChangeTypes_js_1.
|
|
1372
|
+
crossFieldKeys: p.crossFieldKeys ?? (0, modularChangeTypes_js_1.newCrossFieldKeyTable)(),
|
|
1695
1373
|
};
|
|
1696
1374
|
if (p.revisions !== undefined && p.revisions.length > 0) {
|
|
1697
1375
|
changeset.revisions = p.revisions;
|
|
@@ -1724,19 +1402,12 @@ function makeModularChangeset(props) {
|
|
|
1724
1402
|
return changeset;
|
|
1725
1403
|
}
|
|
1726
1404
|
class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
1727
|
-
constructor(family, fieldKinds, changeReceiver, codecOptions
|
|
1405
|
+
constructor(family, fieldKinds, changeReceiver, codecOptions) {
|
|
1728
1406
|
super(family, changeReceiver);
|
|
1729
1407
|
this.fieldKinds = fieldKinds;
|
|
1730
1408
|
this.transactionDepth = 0;
|
|
1731
1409
|
this.idAllocator = (0, index_js_3.idAllocatorFromMaxId)();
|
|
1732
1410
|
this.codecOptions = codecOptions;
|
|
1733
|
-
// TODO: make this dependent on the CodecWriteOptions once there is an FF version that supports RebaseVersion 2
|
|
1734
|
-
this.rebaseVersion =
|
|
1735
|
-
editorOptions?.rebaseVersionOverride ??
|
|
1736
|
-
(editorOptions?.enableDetachedRootEditing === true ? 2 : 1);
|
|
1737
|
-
}
|
|
1738
|
-
isInTransaction() {
|
|
1739
|
-
return this.transactionDepth > 0;
|
|
1740
1411
|
}
|
|
1741
1412
|
enterTransaction() {
|
|
1742
1413
|
this.transactionDepth += 1;
|
|
@@ -1784,13 +1455,11 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1784
1455
|
submitChange(field, fieldKind, change, revision) {
|
|
1785
1456
|
const localCrossFieldKeys = getChangeHandler(this.fieldKinds, fieldKind).getCrossFieldKeys(change);
|
|
1786
1457
|
const modularChange = buildModularChangesetFromField({
|
|
1787
|
-
rebaseVersion: this.rebaseVersion,
|
|
1788
1458
|
path: field,
|
|
1789
1459
|
fieldChange: { fieldKind, change },
|
|
1790
1460
|
nodeChanges: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1791
1461
|
nodeToParent: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1792
|
-
crossFieldKeys: (0, modularChangeTypes_js_1.
|
|
1793
|
-
rootNodes: newRootTable(),
|
|
1462
|
+
crossFieldKeys: (0, modularChangeTypes_js_1.newCrossFieldKeyTable)(),
|
|
1794
1463
|
idAllocator: this.idAllocator,
|
|
1795
1464
|
localCrossFieldKeys,
|
|
1796
1465
|
revision,
|
|
@@ -1807,14 +1476,11 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1807
1476
|
revisions.add(change.revision);
|
|
1808
1477
|
return (0, index_js_2.makeAnonChange)(change.type === "global"
|
|
1809
1478
|
? makeModularChangeset({
|
|
1810
|
-
rebaseVersion: this.rebaseVersion,
|
|
1811
1479
|
maxId: this.idAllocator.getMaxId(),
|
|
1812
1480
|
builds: change.builds,
|
|
1813
|
-
rootNodes: renameTableFromRenameDescriptions(change.renames ?? []),
|
|
1814
1481
|
revisions: [{ revision: change.revision }],
|
|
1815
1482
|
})
|
|
1816
1483
|
: buildModularChangesetFromField({
|
|
1817
|
-
rebaseVersion: this.rebaseVersion,
|
|
1818
1484
|
path: change.field,
|
|
1819
1485
|
fieldChange: {
|
|
1820
1486
|
fieldKind: change.fieldKind,
|
|
@@ -1822,8 +1488,7 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1822
1488
|
},
|
|
1823
1489
|
nodeChanges: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1824
1490
|
nodeToParent: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1825
|
-
crossFieldKeys: (0, modularChangeTypes_js_1.
|
|
1826
|
-
rootNodes: newRootTable(),
|
|
1491
|
+
crossFieldKeys: (0, modularChangeTypes_js_1.newCrossFieldKeyTable)(),
|
|
1827
1492
|
idAllocator: this.idAllocator,
|
|
1828
1493
|
localCrossFieldKeys: getChangeHandler(this.fieldKinds, change.fieldKind).getCrossFieldKeys(change.change),
|
|
1829
1494
|
revision: change.revision,
|
|
@@ -1848,13 +1513,11 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1848
1513
|
nodeExistsConstraint: { violated: false },
|
|
1849
1514
|
};
|
|
1850
1515
|
this.applyChange((0, index_js_2.tagChange)(buildModularChangesetFromNode({
|
|
1851
|
-
rebaseVersion: this.rebaseVersion,
|
|
1852
1516
|
path,
|
|
1853
1517
|
nodeChange,
|
|
1854
1518
|
nodeChanges: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1855
1519
|
nodeToParent: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1856
|
-
crossFieldKeys: (0, modularChangeTypes_js_1.
|
|
1857
|
-
rootNodes: newRootTable(),
|
|
1520
|
+
crossFieldKeys: (0, modularChangeTypes_js_1.newCrossFieldKeyTable)(),
|
|
1858
1521
|
idAllocator: this.idAllocator,
|
|
1859
1522
|
revision,
|
|
1860
1523
|
}), revision));
|
|
@@ -1864,13 +1527,11 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1864
1527
|
nodeExistsConstraintOnRevert: { violated: false },
|
|
1865
1528
|
};
|
|
1866
1529
|
this.applyChange((0, index_js_2.tagChange)(buildModularChangesetFromNode({
|
|
1867
|
-
rebaseVersion: this.rebaseVersion,
|
|
1868
1530
|
path,
|
|
1869
1531
|
nodeChange,
|
|
1870
1532
|
nodeChanges: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1871
1533
|
nodeToParent: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
1872
|
-
crossFieldKeys: (0, modularChangeTypes_js_1.
|
|
1873
|
-
rootNodes: newRootTable(),
|
|
1534
|
+
crossFieldKeys: (0, modularChangeTypes_js_1.newCrossFieldKeyTable)(),
|
|
1874
1535
|
idAllocator: this.idAllocator,
|
|
1875
1536
|
revision,
|
|
1876
1537
|
}), revision));
|
|
@@ -1880,7 +1541,6 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1880
1541
|
throw new internal_2.UsageError(`No change constraints require min client version of at least ${index_js_1.FluidClientVersion.v2_80}`);
|
|
1881
1542
|
}
|
|
1882
1543
|
const changeset = makeModularChangeset({
|
|
1883
|
-
rebaseVersion: this.rebaseVersion,
|
|
1884
1544
|
maxId: -1,
|
|
1885
1545
|
noChangeConstraint: { violated: false },
|
|
1886
1546
|
});
|
|
@@ -1891,7 +1551,6 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1891
1551
|
throw new internal_2.UsageError(`No change constraints require min client version of at least ${index_js_1.FluidClientVersion.v2_80}`);
|
|
1892
1552
|
}
|
|
1893
1553
|
const changeset = makeModularChangeset({
|
|
1894
|
-
rebaseVersion: this.rebaseVersion,
|
|
1895
1554
|
maxId: -1,
|
|
1896
1555
|
noChangeConstraintOnRevert: { violated: false },
|
|
1897
1556
|
});
|
|
@@ -1900,28 +1559,23 @@ class ModularEditBuilder extends index_js_2.EditBuilder {
|
|
|
1900
1559
|
}
|
|
1901
1560
|
exports.ModularEditBuilder = ModularEditBuilder;
|
|
1902
1561
|
function buildModularChangesetFromField(props) {
|
|
1903
|
-
const {
|
|
1562
|
+
const { path, fieldChange, nodeChanges, nodeToParent, crossFieldKeys, idAllocator = (0, index_js_3.idAllocatorFromMaxId)(), localCrossFieldKeys = [], childId, revision, } = props;
|
|
1904
1563
|
const fieldChanges = new Map([[path.field, fieldChange]]);
|
|
1905
1564
|
if (path.parent === undefined) {
|
|
1906
|
-
const field = { nodeId: undefined, field: path.field };
|
|
1907
1565
|
for (const { key, count } of localCrossFieldKeys) {
|
|
1908
|
-
crossFieldKeys.set(key, count, field);
|
|
1566
|
+
crossFieldKeys.set(key, count, { nodeId: undefined, field: path.field });
|
|
1909
1567
|
}
|
|
1910
1568
|
if (childId !== undefined) {
|
|
1911
1569
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodeToParent, childId, {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
field: path.field,
|
|
1915
|
-
},
|
|
1570
|
+
nodeId: undefined,
|
|
1571
|
+
field: path.field,
|
|
1916
1572
|
});
|
|
1917
1573
|
}
|
|
1918
1574
|
return makeModularChangeset({
|
|
1919
|
-
rebaseVersion,
|
|
1920
1575
|
fieldChanges,
|
|
1921
1576
|
nodeChanges,
|
|
1922
1577
|
nodeToParent,
|
|
1923
1578
|
crossFieldKeys,
|
|
1924
|
-
rootNodes,
|
|
1925
1579
|
maxId: idAllocator.getMaxId(),
|
|
1926
1580
|
revisions: [{ revision }],
|
|
1927
1581
|
});
|
|
@@ -1930,67 +1584,43 @@ function buildModularChangesetFromField(props) {
|
|
|
1930
1584
|
fieldChanges,
|
|
1931
1585
|
};
|
|
1932
1586
|
const parentId = { localId: (0, index_js_3.brand)(idAllocator.allocate()), revision };
|
|
1933
|
-
const fieldId = { nodeId: parentId, field: path.field };
|
|
1934
1587
|
for (const { key, count } of localCrossFieldKeys) {
|
|
1935
1588
|
crossFieldKeys.set(key, count, { nodeId: parentId, field: path.field });
|
|
1936
1589
|
}
|
|
1937
1590
|
if (childId !== undefined) {
|
|
1938
1591
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodeToParent, childId, {
|
|
1939
|
-
|
|
1592
|
+
nodeId: parentId,
|
|
1593
|
+
field: path.field,
|
|
1940
1594
|
});
|
|
1941
1595
|
}
|
|
1942
1596
|
return buildModularChangesetFromNode({
|
|
1943
|
-
rebaseVersion,
|
|
1944
1597
|
path: path.parent,
|
|
1945
1598
|
nodeChange: nodeChangeset,
|
|
1946
1599
|
nodeChanges,
|
|
1947
1600
|
nodeToParent,
|
|
1948
1601
|
crossFieldKeys,
|
|
1949
|
-
rootNodes,
|
|
1950
1602
|
idAllocator,
|
|
1951
1603
|
revision,
|
|
1952
1604
|
nodeId: parentId,
|
|
1953
1605
|
});
|
|
1954
1606
|
}
|
|
1955
|
-
exports.buildModularChangesetFromField = buildModularChangesetFromField;
|
|
1956
1607
|
function buildModularChangesetFromNode(props) {
|
|
1957
1608
|
const { path, idAllocator, revision, nodeChanges, nodeChange, nodeId = { localId: (0, index_js_3.brand)(idAllocator.allocate()), revision }, } = props;
|
|
1958
1609
|
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(nodeChanges, nodeId, nodeChange);
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
[path.parentIndex, nodeId],
|
|
1974
|
-
]);
|
|
1975
|
-
const fieldChange = {
|
|
1976
|
-
fieldKind: genericFieldKind_js_1.genericFieldKind.identifier,
|
|
1977
|
-
change: fieldChangeset,
|
|
1978
|
-
};
|
|
1979
|
-
return buildModularChangesetFromField({
|
|
1980
|
-
...props,
|
|
1981
|
-
path: { parent: path.parent, field: path.parentField },
|
|
1982
|
-
fieldChange,
|
|
1983
|
-
localCrossFieldKeys: [],
|
|
1984
|
-
childId: nodeId,
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
function renameTableFromRenameDescriptions(renames) {
|
|
1989
|
-
const table = newRootTable();
|
|
1990
|
-
for (const rename of renames) {
|
|
1991
|
-
addNodeRename(table, rename.oldId, rename.newId, rename.count, rename.detachLocation);
|
|
1992
|
-
}
|
|
1993
|
-
return table;
|
|
1610
|
+
const fieldChangeset = genericFieldKind_js_1.genericFieldKind.changeHandler.editor.buildChildChanges([
|
|
1611
|
+
[path.parentIndex, nodeId],
|
|
1612
|
+
]);
|
|
1613
|
+
const fieldChange = {
|
|
1614
|
+
fieldKind: genericFieldKind_js_1.genericFieldKind.identifier,
|
|
1615
|
+
change: fieldChangeset,
|
|
1616
|
+
};
|
|
1617
|
+
return buildModularChangesetFromField({
|
|
1618
|
+
...props,
|
|
1619
|
+
path: { parent: path.parent, field: path.parentField },
|
|
1620
|
+
fieldChange,
|
|
1621
|
+
localCrossFieldKeys: [],
|
|
1622
|
+
childId: nodeId,
|
|
1623
|
+
});
|
|
1994
1624
|
}
|
|
1995
1625
|
function getRevInfoFromTaggedChanges(changes) {
|
|
1996
1626
|
let maxId = -1;
|
|
@@ -2007,6 +1637,18 @@ function getRevInfoFromTaggedChanges(changes) {
|
|
|
2007
1637
|
}
|
|
2008
1638
|
}
|
|
2009
1639
|
}
|
|
1640
|
+
const rolledBackRevisions = [];
|
|
1641
|
+
for (const info of revInfos) {
|
|
1642
|
+
if (info.rollbackOf !== undefined) {
|
|
1643
|
+
rolledBackRevisions.push(info.rollbackOf);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
rolledBackRevisions.reverse();
|
|
1647
|
+
for (const revision of rolledBackRevisions) {
|
|
1648
|
+
if (!revisions.has(revision)) {
|
|
1649
|
+
revInfos.push({ revision });
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
2010
1652
|
return { maxId: (0, index_js_3.brand)(maxId), revInfos };
|
|
2011
1653
|
}
|
|
2012
1654
|
function revisionInfoFromTaggedChange(taggedChange) {
|
|
@@ -2023,16 +1665,15 @@ function revisionInfoFromTaggedChange(taggedChange) {
|
|
|
2023
1665
|
}
|
|
2024
1666
|
return revInfos;
|
|
2025
1667
|
}
|
|
2026
|
-
function fieldChangeFromId(
|
|
2027
|
-
const
|
|
2028
|
-
const fieldMap = fieldMapFromNodeId(change.fieldChanges, change.nodeChanges, change.nodeAliases, fieldId.nodeId);
|
|
1668
|
+
function fieldChangeFromId(fields, nodes, id) {
|
|
1669
|
+
const fieldMap = fieldMapFromNodeId(fields, nodes, id.nodeId);
|
|
2029
1670
|
return fieldMap.get(id.field) ?? (0, internal_1.fail)(0xb25 /* No field exists for the given ID */);
|
|
2030
1671
|
}
|
|
2031
|
-
function fieldMapFromNodeId(rootFieldMap, nodes,
|
|
1672
|
+
function fieldMapFromNodeId(rootFieldMap, nodes, nodeId) {
|
|
2032
1673
|
if (nodeId === undefined) {
|
|
2033
1674
|
return rootFieldMap;
|
|
2034
1675
|
}
|
|
2035
|
-
const node = nodeChangeFromId(nodes,
|
|
1676
|
+
const node = nodeChangeFromId(nodes, nodeId);
|
|
2036
1677
|
(0, internal_1.assert)(node.fieldChanges !== undefined, 0x9c9 /* Expected node to have field changes */);
|
|
2037
1678
|
return node.fieldChanges;
|
|
2038
1679
|
}
|
|
@@ -2045,9 +1686,8 @@ function rebasedFieldIdFromBaseId(table, baseId) {
|
|
|
2045
1686
|
function rebasedNodeIdFromBaseNodeId(table, baseId) {
|
|
2046
1687
|
return (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(table.baseToRebasedNodeId, baseId) ?? baseId;
|
|
2047
1688
|
}
|
|
2048
|
-
function nodeChangeFromId(nodes,
|
|
2049
|
-
const
|
|
2050
|
-
const node = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(nodes, normalizedId);
|
|
1689
|
+
function nodeChangeFromId(nodes, id) {
|
|
1690
|
+
const node = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(nodes, id);
|
|
2051
1691
|
(0, internal_1.assert)(node !== undefined, 0x9ca /* Unknown node ID */);
|
|
2052
1692
|
return node;
|
|
2053
1693
|
}
|
|
@@ -2055,20 +1695,12 @@ function fieldIdFromFieldIdKey([revision, localId, field]) {
|
|
|
2055
1695
|
const nodeId = localId === undefined ? undefined : { revision, localId };
|
|
2056
1696
|
return { nodeId, field };
|
|
2057
1697
|
}
|
|
2058
|
-
function fieldIdKeyFromFieldId(fieldId) {
|
|
2059
|
-
return [fieldId.nodeId?.revision, fieldId.nodeId?.localId, fieldId.field];
|
|
2060
|
-
}
|
|
2061
1698
|
function cloneNodeChangeset(nodeChangeset) {
|
|
2062
1699
|
if (nodeChangeset.fieldChanges !== undefined) {
|
|
2063
1700
|
return { ...nodeChangeset, fieldChanges: new Map(nodeChangeset.fieldChanges) };
|
|
2064
1701
|
}
|
|
2065
1702
|
return { ...nodeChangeset };
|
|
2066
1703
|
}
|
|
2067
|
-
function replaceNodeLocationRevision(location, replacer) {
|
|
2068
|
-
return location.field === undefined
|
|
2069
|
-
? { root: replacer.getUpdatedAtomId(location.root) }
|
|
2070
|
-
: { field: replaceFieldIdRevision(location.field, replacer) };
|
|
2071
|
-
}
|
|
2072
1704
|
function replaceFieldIdRevision(fieldId, replacer) {
|
|
2073
1705
|
if (fieldId.nodeId === undefined) {
|
|
2074
1706
|
return fieldId;
|
|
@@ -2078,34 +1710,17 @@ function replaceFieldIdRevision(fieldId, replacer) {
|
|
|
2078
1710
|
nodeId: replacer.getUpdatedAtomId(fieldId.nodeId),
|
|
2079
1711
|
};
|
|
2080
1712
|
}
|
|
2081
|
-
function
|
|
2082
|
-
const
|
|
2083
|
-
|
|
2084
|
-
(
|
|
2085
|
-
if (location.field !== undefined) {
|
|
2086
|
-
return { field: normalizeFieldId(location.field, changeset.nodeAliases) };
|
|
2087
|
-
}
|
|
2088
|
-
return location;
|
|
1713
|
+
function getParentFieldId(changeset, nodeId) {
|
|
1714
|
+
const parentId = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(changeset.nodeToParent, nodeId);
|
|
1715
|
+
(0, internal_1.assert)(parentId !== undefined, 0x9cb /* Parent field should be defined */);
|
|
1716
|
+
return normalizeFieldId(parentId, changeset.nodeAliases);
|
|
2089
1717
|
}
|
|
2090
|
-
exports.
|
|
1718
|
+
exports.getParentFieldId = getParentFieldId;
|
|
2091
1719
|
function getFieldsForCrossFieldKey(changeset, key, count) {
|
|
2092
1720
|
return changeset.crossFieldKeys
|
|
2093
1721
|
.getAll(key, count)
|
|
2094
1722
|
.map(({ value: fieldId }) => normalizeFieldId(fieldId, changeset.nodeAliases));
|
|
2095
1723
|
}
|
|
2096
|
-
function getFirstFieldForCrossFieldKey(changeset, key, count) {
|
|
2097
|
-
const result = changeset.crossFieldKeys.getFirst(key, count);
|
|
2098
|
-
if (result.value === undefined) {
|
|
2099
|
-
return result;
|
|
2100
|
-
}
|
|
2101
|
-
return { ...result, value: normalizeFieldId(result.value, changeset.nodeAliases) };
|
|
2102
|
-
}
|
|
2103
|
-
function normalizeNodeLocation(location, nodeAliases) {
|
|
2104
|
-
if (location.field !== undefined) {
|
|
2105
|
-
return { field: normalizeFieldId(location.field, nodeAliases) };
|
|
2106
|
-
}
|
|
2107
|
-
return location;
|
|
2108
|
-
}
|
|
2109
1724
|
// This is only exported for use in test utilities.
|
|
2110
1725
|
function normalizeFieldId(fieldId, nodeAliases) {
|
|
2111
1726
|
return fieldId.nodeId === undefined
|
|
@@ -2118,7 +1733,6 @@ exports.normalizeFieldId = normalizeFieldId;
|
|
|
2118
1733
|
*/
|
|
2119
1734
|
function normalizeNodeId(nodeId, nodeAliases) {
|
|
2120
1735
|
let currentId = nodeId;
|
|
2121
|
-
let cycleProbeId = nodeId;
|
|
2122
1736
|
// eslint-disable-next-line no-constant-condition
|
|
2123
1737
|
while (true) {
|
|
2124
1738
|
const dealiased = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(nodeAliases, currentId);
|
|
@@ -2126,567 +1740,25 @@ function normalizeNodeId(nodeId, nodeAliases) {
|
|
|
2126
1740
|
return currentId;
|
|
2127
1741
|
}
|
|
2128
1742
|
currentId = dealiased;
|
|
2129
|
-
if (cycleProbeId !== undefined) {
|
|
2130
|
-
cycleProbeId = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(nodeAliases, cycleProbeId);
|
|
2131
|
-
}
|
|
2132
|
-
if (cycleProbeId !== undefined) {
|
|
2133
|
-
cycleProbeId = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(nodeAliases, cycleProbeId);
|
|
2134
|
-
}
|
|
2135
|
-
(0, internal_1.assert)(!(0, index_js_2.areEqualChangeAtomIdOpts)(cycleProbeId, currentId), "Alias cycle detected");
|
|
2136
1743
|
}
|
|
2137
1744
|
}
|
|
2138
|
-
exports.normalizeNodeId = normalizeNodeId;
|
|
2139
1745
|
function hasConflicts(change) {
|
|
2140
1746
|
return (change.constraintViolationCount ?? 0) > 0;
|
|
2141
1747
|
}
|
|
2142
|
-
function areEqualFieldIds(a, b) {
|
|
2143
|
-
return (0, index_js_2.areEqualChangeAtomIdOpts)(a.nodeId, b.nodeId) && a.field === b.field;
|
|
2144
|
-
}
|
|
2145
|
-
function firstAttachIdFromDetachId(roots, detachId, count) {
|
|
2146
|
-
const result = roots.oldToNewId.getFirst(detachId, count);
|
|
2147
|
-
return { ...result, value: result.value ?? detachId };
|
|
2148
|
-
}
|
|
2149
|
-
function firstDetachIdFromAttachId(roots, attachId, count) {
|
|
2150
|
-
const result = roots.newToOldId.getFirst(attachId, count);
|
|
2151
|
-
return { ...result, start: attachId, value: result.value ?? attachId };
|
|
2152
|
-
}
|
|
2153
|
-
function rebaseCrossFieldKeys(sourceTable, movedDetaches, newDetachLocations) {
|
|
2154
|
-
const rebasedTable = sourceTable.clone();
|
|
2155
|
-
for (const entry of movedDetaches.entries()) {
|
|
2156
|
-
rebasedTable.delete({ ...entry.start, target: crossFieldQueries_js_1.NodeMoveType.Detach }, entry.length);
|
|
2157
|
-
}
|
|
2158
|
-
for (const entry of newDetachLocations.entries()) {
|
|
2159
|
-
rebasedTable.set({ ...entry.start, target: crossFieldQueries_js_1.NodeMoveType.Detach }, entry.length, entry.value);
|
|
2160
|
-
}
|
|
2161
|
-
return rebasedTable;
|
|
2162
|
-
}
|
|
2163
|
-
function newRootTable() {
|
|
2164
|
-
return {
|
|
2165
|
-
newToOldId: (0, index_js_2.newChangeAtomIdTransform)(),
|
|
2166
|
-
oldToNewId: (0, index_js_2.newChangeAtomIdTransform)(),
|
|
2167
|
-
nodeChanges: (0, changeAtomIdBTree_js_1.newChangeAtomIdBTree)(),
|
|
2168
|
-
detachLocations: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
2169
|
-
outputDetachLocations: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
2170
|
-
};
|
|
2171
|
-
}
|
|
2172
|
-
exports.newRootTable = newRootTable;
|
|
2173
|
-
function rebaseRoots(change, base, affectedBaseFields, nodesToRebase, rebasedNodeToParent, rebaseVersion) {
|
|
2174
|
-
const rebasedRoots = newRootTable();
|
|
2175
|
-
for (const renameEntry of change.rootNodes.oldToNewId.entries()) {
|
|
2176
|
-
rebaseRename(change.rootNodes, rebasedRoots, renameEntry, base, affectedBaseFields);
|
|
2177
|
-
}
|
|
2178
|
-
for (const [detachIdKey, nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
2179
|
-
const changes = base.rootNodes.nodeChanges.get(detachIdKey);
|
|
2180
|
-
if (changes !== undefined) {
|
|
2181
|
-
nodesToRebase.push([nodeId, changes]);
|
|
2182
|
-
}
|
|
2183
|
-
const detachId = (0, index_js_2.makeChangeAtomId)(detachIdKey[1], detachIdKey[0]);
|
|
2184
|
-
const attachId = firstAttachIdFromDetachId(base.rootNodes, detachId, 1).value;
|
|
2185
|
-
const baseAttachEntry = base.crossFieldKeys.getFirst({ target: crossFieldQueries_js_1.NodeMoveType.Attach, ...attachId }, 1);
|
|
2186
|
-
if (baseAttachEntry.value === undefined) {
|
|
2187
|
-
const renamedDetachId = firstAttachIdFromDetachId(base.rootNodes, detachId, 1).value;
|
|
2188
|
-
const baseOutputDetachLocation = base.rootNodes.outputDetachLocations.getFirst(renamedDetachId, 1).value;
|
|
2189
|
-
if (baseOutputDetachLocation !== undefined) {
|
|
2190
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(baseOutputDetachLocation), true);
|
|
2191
|
-
}
|
|
2192
|
-
const detachLocation = baseOutputDetachLocation ??
|
|
2193
|
-
change.rootNodes.detachLocations.getFirst(detachId, 1).value;
|
|
2194
|
-
// Note that `baseOutputDetachLocation` may contain a node ID from the base changeset.
|
|
2195
|
-
// We will replace the detach location entry with the node ID from the rebased changeset in `fixupRebasedDetachLocations`
|
|
2196
|
-
assignRootChange(rebasedRoots, rebasedNodeToParent, renamedDetachId, nodeId, detachLocation, rebaseVersion);
|
|
2197
|
-
}
|
|
2198
|
-
else {
|
|
2199
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(baseAttachEntry.value), true);
|
|
2200
|
-
rebasedNodeToParent.delete(detachIdKey);
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2203
|
-
for (const entry of change.rootNodes.outputDetachLocations.entries()) {
|
|
2204
|
-
rebasedRoots.outputDetachLocations.set(entry.start, entry.length, entry.value);
|
|
2205
|
-
}
|
|
2206
|
-
return rebasedRoots;
|
|
2207
|
-
}
|
|
2208
|
-
function rebaseRename(newRoots, rebasedRoots, renameEntry, base, affectedBaseFields) {
|
|
2209
|
-
let count = renameEntry.length;
|
|
2210
|
-
const baseRenameEntry = firstAttachIdFromDetachId(base.rootNodes, renameEntry.start, count);
|
|
2211
|
-
count = baseRenameEntry.length;
|
|
2212
|
-
const baseAttachEntry = base.crossFieldKeys.getFirst({
|
|
2213
|
-
...baseRenameEntry.value,
|
|
2214
|
-
target: crossFieldQueries_js_1.NodeMoveType.Attach,
|
|
2215
|
-
}, count);
|
|
2216
|
-
count = baseAttachEntry.length;
|
|
2217
|
-
if (baseAttachEntry.value === undefined) {
|
|
2218
|
-
const baseOutputDetachLocation = base.rootNodes.outputDetachLocations.getFirst(baseRenameEntry.value, 1).value;
|
|
2219
|
-
if (baseOutputDetachLocation !== undefined) {
|
|
2220
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(baseOutputDetachLocation), true);
|
|
2221
|
-
}
|
|
2222
|
-
const detachEntry = newRoots.detachLocations.getFirst(renameEntry.start, count);
|
|
2223
|
-
count = detachEntry.length;
|
|
2224
|
-
const detachLocation = baseOutputDetachLocation ?? detachEntry.value;
|
|
2225
|
-
// Note that `baseOutputDetachLocation` may contain a node ID from the base changeset.
|
|
2226
|
-
// We will replace the detach location entry with the node ID from the rebased changeset in `fixupRebasedDetachLocations`
|
|
2227
|
-
addNodeRename(rebasedRoots, baseRenameEntry.value, renameEntry.value, count, detachLocation);
|
|
2228
|
-
}
|
|
2229
|
-
else {
|
|
2230
|
-
// This rename represents an intention to detach these nodes.
|
|
2231
|
-
// The rebased change should have a detach in the field where the base change attaches the nodes,
|
|
2232
|
-
// so we need to ensure that field is processed.
|
|
2233
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(normalizeFieldId(baseAttachEntry.value, base.nodeAliases)), true);
|
|
2234
|
-
}
|
|
2235
|
-
const countRemaining = renameEntry.length - count;
|
|
2236
|
-
if (countRemaining > 0) {
|
|
2237
|
-
rebaseRename(newRoots, rebasedRoots, {
|
|
2238
|
-
start: (0, index_js_2.offsetChangeAtomId)(renameEntry.start, count),
|
|
2239
|
-
value: (0, index_js_2.offsetChangeAtomId)(renameEntry.value, count),
|
|
2240
|
-
length: countRemaining,
|
|
2241
|
-
}, base, affectedBaseFields);
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
1748
|
/**
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
1749
|
+
* A rebaseChild callback for fields with no new changes.
|
|
1750
|
+
* Asserts that there are no new changes and returns undefined.
|
|
2247
1751
|
*/
|
|
2248
|
-
function
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
if (normalizedDetachLocation.nodeId !== undefined) {
|
|
2252
|
-
const rebasedNodeId = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(table.baseToRebasedNodeId, normalizedDetachLocation.nodeId);
|
|
2253
|
-
if (rebasedNodeId !== undefined) {
|
|
2254
|
-
table.rebasedRootNodes.detachLocations.set(start, length, {
|
|
2255
|
-
...normalizedDetachLocation,
|
|
2256
|
-
nodeId: rebasedNodeId,
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
function addNodesToCompose(table, id1, id2) {
|
|
2263
|
-
const normalizedId1 = normalizeNodeId(id1, table.baseChange.nodeAliases);
|
|
2264
|
-
const normalizedId2 = normalizeNodeId(id2, table.newChange.nodeAliases);
|
|
2265
|
-
if ((0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(table.newToBaseNodeId, normalizedId2) === undefined) {
|
|
2266
|
-
(0, changeAtomIdBTree_js_1.setInChangeAtomIdMap)(table.newToBaseNodeId, normalizedId2, normalizedId1);
|
|
2267
|
-
table.pendingCompositions.nodeIdsToCompose.push([normalizedId1, normalizedId2]);
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
function composeRevInfos(revisions1, revisions2) {
|
|
2271
|
-
if (revisions1?.length === 1 &&
|
|
2272
|
-
revisions2?.length === 1 &&
|
|
2273
|
-
revisions1[0]?.revision === revisions2[0]?.revision) {
|
|
2274
|
-
// This is a special case where we are composing two changesets from the same transaction.
|
|
2275
|
-
// We return one of the input arrays to avoid duplicating revision entries.
|
|
2276
|
-
return revisions1;
|
|
2277
|
-
}
|
|
2278
|
-
const result = [...(revisions1 ?? []), ...(revisions2 ?? [])];
|
|
2279
|
-
return result;
|
|
2280
|
-
}
|
|
2281
|
-
function composeCrossFieldKeyTables(table1, table2, movedCrossFieldKeys, removedCrossFieldKeys) {
|
|
2282
|
-
const composedTable = index_js_3.RangeMap.union(table1, table2);
|
|
2283
|
-
for (const entry of movedCrossFieldKeys.entries()) {
|
|
2284
|
-
composedTable.set(entry.start, entry.length, entry.value);
|
|
2285
|
-
}
|
|
2286
|
-
for (const entry of removedCrossFieldKeys.entries()) {
|
|
2287
|
-
composedTable.delete(entry.start, entry.length);
|
|
2288
|
-
}
|
|
2289
|
-
return composedTable;
|
|
2290
|
-
}
|
|
2291
|
-
function composeRootTables(change1, change2, composedNodeToParent, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions) {
|
|
2292
|
-
const composedTable = cloneRootTable(change1.rootNodes);
|
|
2293
|
-
for (const renameEntry of change2.rootNodes.oldToNewId.entries()) {
|
|
2294
|
-
composeRename(change1, change2, composedTable, renameEntry.start, renameEntry.value, renameEntry.length, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
2295
|
-
}
|
|
2296
|
-
for (const [[revision2, id2], nodeId2] of change2.rootNodes.nodeChanges.entries()) {
|
|
2297
|
-
const detachId2 = { revision: revision2, localId: id2 };
|
|
2298
|
-
const detachId1 = firstDetachIdFromAttachId(change1.rootNodes, detachId2, 1).value;
|
|
2299
|
-
const nodeId1 = (0, changeAtomIdBTree_js_1.getFromChangeAtomIdMap)(change1.rootNodes.nodeChanges, detachId1);
|
|
2300
|
-
if (nodeId1 === undefined) {
|
|
2301
|
-
const fieldId = getFieldsForCrossFieldKey(change1, { ...detachId1, target: crossFieldQueries_js_1.NodeMoveType.Detach }, 1)[0];
|
|
2302
|
-
if (fieldId === undefined) {
|
|
2303
|
-
assignRootChange(composedTable, composedNodeToParent, detachId1, nodeId2, change1.rootNodes.detachLocations.getFirst(detachId1, 1).value ??
|
|
2304
|
-
change2.rootNodes.detachLocations.getFirst(detachId2, 1).value, Math.max(change1.rebaseVersion, change2.rebaseVersion));
|
|
2305
|
-
}
|
|
2306
|
-
else {
|
|
2307
|
-
// In this case, this node is attached in the input context of change1,
|
|
2308
|
-
// and is represented in detachFieldId.
|
|
2309
|
-
pendingCompositions.affectedBaseFields.set([fieldId.nodeId?.revision, fieldId.nodeId?.localId, fieldId.field], true);
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
else {
|
|
2313
|
-
pendingCompositions.nodeIdsToCompose.push([nodeId1, nodeId2]);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
for (const outputDetachEntry of change1.rootNodes.outputDetachLocations.entries()) {
|
|
2317
|
-
composeOutputDetachLocation(outputDetachEntry.start, outputDetachEntry.length, outputDetachEntry.value, change2, composedTable);
|
|
2318
|
-
}
|
|
2319
|
-
for (const entry of change2.rootNodes.outputDetachLocations.entries()) {
|
|
2320
|
-
composedTable.outputDetachLocations.set(entry.start, entry.length, entry.value);
|
|
2321
|
-
}
|
|
2322
|
-
return composedTable;
|
|
2323
|
-
}
|
|
2324
|
-
function composeOutputDetachLocation(outputDetachId1, count, detachLocation, change2, composedTable) {
|
|
2325
|
-
let countToProcess = count;
|
|
2326
|
-
const renameEntry = firstAttachIdFromDetachId(change2.rootNodes, outputDetachId1, countToProcess);
|
|
2327
|
-
countToProcess = renameEntry.length;
|
|
2328
|
-
const attachEntry = getFirstAttachField(change2.crossFieldKeys, renameEntry.value, countToProcess);
|
|
2329
|
-
countToProcess = attachEntry.length;
|
|
2330
|
-
composedTable.outputDetachLocations.delete(outputDetachId1, countToProcess);
|
|
2331
|
-
if (attachEntry.value === undefined) {
|
|
2332
|
-
// We update the key for the detach location to the renamed ID of the root in the composed output context.
|
|
2333
|
-
composedTable.outputDetachLocations.set(renameEntry.value, countToProcess, detachLocation);
|
|
2334
|
-
}
|
|
2335
|
-
else {
|
|
2336
|
-
// These nodes are attached by `change2` and thus attached in the composed output context,
|
|
2337
|
-
// so there should be no output detach location.
|
|
2338
|
-
}
|
|
2339
|
-
const countRemaining = count - countToProcess;
|
|
2340
|
-
if (countRemaining > 0) {
|
|
2341
|
-
composeOutputDetachLocation((0, index_js_2.offsetChangeAtomId)(outputDetachId1, countToProcess), countRemaining, detachLocation, change2, composedTable);
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
function composeRename(change1, change2, mergedTable, oldId, newId, count, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions) {
|
|
2345
|
-
let countToProcess = count;
|
|
2346
|
-
const detachEntry = getFirstDetachField(change1.crossFieldKeys, oldId, countToProcess);
|
|
2347
|
-
countToProcess = detachEntry.length;
|
|
2348
|
-
if (detachEntry.value === undefined) {
|
|
2349
|
-
// `change1` may also have a rename to `renameEntry.value`, in which case it must refer to a different node.
|
|
2350
|
-
// That node must have been attached by `change1` and detached by `change2`.
|
|
2351
|
-
// The final rename for that node will be created in `composeAttachDetach`.
|
|
2352
|
-
// We delete any such rename for now to avoid colliding with the rename currently being processed.
|
|
2353
|
-
deleteNodeRenameTo(mergedTable, newId, countToProcess);
|
|
2354
|
-
// The nodes were detached before `change`, so we append this rename.
|
|
2355
|
-
appendNodeRename(mergedTable, oldId, newId, countToProcess, change1.rootNodes, change2.rootNodes.detachLocations.getFirst(oldId, countToProcess).value);
|
|
2356
|
-
}
|
|
2357
|
-
else {
|
|
2358
|
-
// `change1` detached these nodes,
|
|
2359
|
-
// so we invalidate the detach location so that the detach's ID can be replaced with the new ID.
|
|
2360
|
-
pendingCompositions.affectedBaseFields.set(fieldIdKeyFromFieldId(detachEntry.value), true);
|
|
2361
|
-
if (!(0, index_js_2.areEqualChangeAtomIds)(oldId, newId)) {
|
|
2362
|
-
// `change1`'s detach will be replaced by `change2`'s detach, so we update the cross-field keys.
|
|
2363
|
-
removedCrossFieldKeys.set({ ...oldId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, countToProcess, true);
|
|
2364
|
-
}
|
|
2365
|
-
movedCrossFieldKeys.set({ ...newId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, countToProcess, detachEntry.value);
|
|
2366
|
-
}
|
|
2367
|
-
if (countToProcess < count) {
|
|
2368
|
-
composeRename(change1, change2, mergedTable, (0, index_js_2.offsetChangeAtomId)(oldId, countToProcess), (0, index_js_2.offsetChangeAtomId)(newId, countToProcess), count - countToProcess, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2371
|
-
function cloneRootTable(table) {
|
|
2372
|
-
return {
|
|
2373
|
-
oldToNewId: table.oldToNewId.clone(),
|
|
2374
|
-
newToOldId: table.newToOldId.clone(),
|
|
2375
|
-
nodeChanges: (0, index_js_3.brand)(table.nodeChanges.clone()),
|
|
2376
|
-
detachLocations: table.detachLocations.clone(),
|
|
2377
|
-
outputDetachLocations: table.outputDetachLocations.clone(),
|
|
2378
|
-
};
|
|
2379
|
-
}
|
|
2380
|
-
exports.cloneRootTable = cloneRootTable;
|
|
2381
|
-
function invertRootTable(change, invertedNodeToParent, isRollback) {
|
|
2382
|
-
const invertedRoots = newRootTable();
|
|
2383
|
-
if (isRollback) {
|
|
2384
|
-
// We only invert renames of nodes which are not attached or detached by this changeset.
|
|
2385
|
-
// When we invert an attach we will create a detach which incorporates the rename.
|
|
2386
|
-
for (const { start: oldId, value: newId, length, } of change.rootNodes.oldToNewId.entries()) {
|
|
2387
|
-
invertRename(change, invertedRoots, oldId, newId, length);
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
for (const [[revision, localId], nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
2391
|
-
const detachId = { revision, localId };
|
|
2392
|
-
const renamedId = firstAttachIdFromDetachId(change.rootNodes, detachId, 1).value;
|
|
2393
|
-
// This checks whether `change` attaches this node.
|
|
2394
|
-
// If it does, the node is not detached in the input context of the inverse, and so should not be included in the root table.
|
|
2395
|
-
if (change.crossFieldKeys.getFirst({ ...renamedId, target: crossFieldQueries_js_1.NodeMoveType.Attach }, 1)
|
|
2396
|
-
.value === undefined) {
|
|
2397
|
-
assignRootChange(invertedRoots, invertedNodeToParent, renamedId, nodeId, change.rootNodes.detachLocations.getFirst(detachId, 1).value, change.rebaseVersion);
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
return invertedRoots;
|
|
2401
|
-
}
|
|
2402
|
-
function invertRename(change, invertedRoots, oldId, newId, length) {
|
|
2403
|
-
for (const detachEntry of doesChangeDetachNodes(change.crossFieldKeys, newId, length)) {
|
|
2404
|
-
(0, internal_1.assert)(!detachEntry.value, "A changeset should not have a rename and detach for the same node.");
|
|
2405
|
-
}
|
|
2406
|
-
let countProcessed = length;
|
|
2407
|
-
const outputDetachEntry = change.rootNodes.outputDetachLocations.getFirst(newId, countProcessed);
|
|
2408
|
-
countProcessed = outputDetachEntry.length;
|
|
2409
|
-
const inputDetachEntry = change.rootNodes.detachLocations.getFirst(oldId, countProcessed);
|
|
2410
|
-
countProcessed = inputDetachEntry.length;
|
|
2411
|
-
const attachEntry = getFirstAttachField(change.crossFieldKeys, newId, countProcessed);
|
|
2412
|
-
countProcessed = attachEntry.length;
|
|
2413
|
-
if (attachEntry.value === undefined) {
|
|
2414
|
-
addNodeRename(invertedRoots, newId, oldId, countProcessed, outputDetachEntry.value ?? inputDetachEntry.value);
|
|
2415
|
-
// The original change moves the detached node, so the inverse should also record a move back to the original location.
|
|
2416
|
-
if (outputDetachEntry.value !== undefined && inputDetachEntry.value !== undefined) {
|
|
2417
|
-
invertedRoots.outputDetachLocations.set(oldId, countProcessed, inputDetachEntry.value);
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
if (countProcessed < length) {
|
|
2421
|
-
invertRename(change, invertedRoots, (0, index_js_2.offsetChangeAtomId)(oldId, countProcessed), (0, index_js_2.offsetChangeAtomId)(newId, countProcessed), length - countProcessed);
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
function doesChangeAttachNodes(table, id, count) {
|
|
2425
|
-
return table
|
|
2426
|
-
.getAll2({ ...id, target: crossFieldQueries_js_1.NodeMoveType.Attach }, count)
|
|
2427
|
-
.map((entry) => ({ ...entry, value: entry.value !== undefined }));
|
|
2428
|
-
}
|
|
2429
|
-
function doesChangeDetachNodes(table, id, count) {
|
|
2430
|
-
return table
|
|
2431
|
-
.getAll2({ ...id, target: crossFieldQueries_js_1.NodeMoveType.Detach }, count)
|
|
2432
|
-
.map((entry) => ({ ...entry, value: entry.value !== undefined }));
|
|
2433
|
-
}
|
|
2434
|
-
function getFirstDetachField(table, id, count) {
|
|
2435
|
-
return table.getFirst({ target: crossFieldQueries_js_1.NodeMoveType.Detach, ...id }, count);
|
|
2436
|
-
}
|
|
2437
|
-
exports.getFirstDetachField = getFirstDetachField;
|
|
2438
|
-
function getFirstAttachField(table, id, count) {
|
|
2439
|
-
return table.getFirst({ target: crossFieldQueries_js_1.NodeMoveType.Attach, ...id }, count);
|
|
2440
|
-
}
|
|
2441
|
-
exports.getFirstAttachField = getFirstAttachField;
|
|
2442
|
-
function addNodeRename(table, oldId, newId, count, detachLocation) {
|
|
2443
|
-
if ((0, index_js_2.areEqualChangeAtomIds)(oldId, newId)) {
|
|
2444
|
-
return;
|
|
2445
|
-
}
|
|
2446
|
-
for (const entry of table.oldToNewId.getAll2(oldId, count)) {
|
|
2447
|
-
(0, internal_1.assert)(entry.value === undefined ||
|
|
2448
|
-
(0, index_js_2.areEqualChangeAtomIds)(entry.value, (0, index_js_2.offsetChangeAtomId)(newId, entry.offset)), "Rename collision detected");
|
|
2449
|
-
}
|
|
2450
|
-
for (const entry of table.newToOldId.getAll2(newId, count)) {
|
|
2451
|
-
(0, internal_1.assert)(entry.value === undefined ||
|
|
2452
|
-
(0, index_js_2.areEqualChangeAtomIds)(entry.value, (0, index_js_2.offsetChangeAtomId)(oldId, entry.offset)), "Rename collision detected");
|
|
2453
|
-
}
|
|
2454
|
-
table.oldToNewId.set(oldId, count, newId);
|
|
2455
|
-
table.newToOldId.set(newId, count, oldId);
|
|
2456
|
-
if (detachLocation !== undefined) {
|
|
2457
|
-
table.detachLocations.set(oldId, count, detachLocation);
|
|
2458
|
-
}
|
|
2459
|
-
}
|
|
2460
|
-
exports.addNodeRename = addNodeRename;
|
|
2461
|
-
/**
|
|
2462
|
-
* Deletes any renames from `id`.
|
|
2463
|
-
*/
|
|
2464
|
-
function deleteNodeRenameFrom(roots, id, count) {
|
|
2465
|
-
for (const entry of roots.oldToNewId.getAll(id, count)) {
|
|
2466
|
-
deleteNodeRenameEntry(roots, entry.start, entry.value, entry.length);
|
|
2467
|
-
}
|
|
2468
|
-
}
|
|
2469
|
-
/**
|
|
2470
|
-
* Deletes any renames to `id`.
|
|
2471
|
-
*/
|
|
2472
|
-
function deleteNodeRenameTo(roots, id, count) {
|
|
2473
|
-
for (const entry of roots.newToOldId.getAll(id, count)) {
|
|
2474
|
-
deleteNodeRenameEntry(roots, entry.value, entry.start, entry.length);
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
function appendNodeRename(composedTable, oldId, newId, count, change1Table, detachLocation) {
|
|
2478
|
-
let countToProcess = count;
|
|
2479
|
-
const rename1Entry = change1Table.newToOldId.getFirst(oldId, countToProcess);
|
|
2480
|
-
countToProcess = rename1Entry.length;
|
|
2481
|
-
if (rename1Entry.value !== undefined) {
|
|
2482
|
-
deleteNodeRenameFrom(composedTable, rename1Entry.value, countToProcess);
|
|
2483
|
-
}
|
|
2484
|
-
addNodeRename(composedTable, rename1Entry.value ?? oldId, newId, countToProcess, detachLocation);
|
|
2485
|
-
tryRemoveDetachLocation(composedTable, newId, countToProcess);
|
|
2486
|
-
if (countToProcess < count) {
|
|
2487
|
-
const countRemaining = count - countToProcess;
|
|
2488
|
-
appendNodeRename(composedTable, (0, index_js_2.offsetChangeAtomId)(oldId, countToProcess), (0, index_js_2.offsetChangeAtomId)(newId, countToProcess), countRemaining, change1Table, detachLocation);
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
function tryRemoveDetachLocation(roots, rootId, count) {
|
|
2492
|
-
let countProcessed = count;
|
|
2493
|
-
const renameEntry = roots.oldToNewId.getFirst(rootId, countProcessed);
|
|
2494
|
-
countProcessed = renameEntry.length;
|
|
2495
|
-
const outputDetachEntry = roots.outputDetachLocations.getFirst(rootId, countProcessed);
|
|
2496
|
-
countProcessed = outputDetachEntry.length;
|
|
2497
|
-
const nodeChangeEntry = (0, changeAtomIdBTree_js_1.rangeQueryChangeAtomIdMap)(roots.nodeChanges, rootId, countProcessed);
|
|
2498
|
-
countProcessed = nodeChangeEntry.length;
|
|
2499
|
-
if (nodeChangeEntry.value === undefined &&
|
|
2500
|
-
renameEntry.value === undefined &&
|
|
2501
|
-
outputDetachEntry.value === undefined) {
|
|
2502
|
-
roots.detachLocations.delete(rootId, countProcessed);
|
|
2503
|
-
}
|
|
2504
|
-
const countRemaining = count - countProcessed;
|
|
2505
|
-
if (countRemaining > 0) {
|
|
2506
|
-
tryRemoveDetachLocation(roots, (0, index_js_2.offsetChangeAtomId)(rootId, countProcessed), countRemaining);
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
/**
|
|
2510
|
-
* Deletes the entry renaming the ID range of length `count` from `oldId` to `newId`.
|
|
2511
|
-
* This function assumes that such an entry exists.
|
|
2512
|
-
*/
|
|
2513
|
-
function deleteNodeRenameEntry(roots, oldId, newId, count) {
|
|
2514
|
-
roots.oldToNewId.delete(oldId, count);
|
|
2515
|
-
roots.newToOldId.delete(newId, count);
|
|
2516
|
-
}
|
|
2517
|
-
function replaceRootTableRevision(table, replacer, nodeAliases) {
|
|
2518
|
-
const oldToNewId = table.oldToNewId.mapEntries((id) => replacer.getUpdatedAtomId(id), (id) => replacer.getUpdatedAtomId(id));
|
|
2519
|
-
const newToOldId = table.newToOldId.mapEntries((id) => replacer.getUpdatedAtomId(id), (id) => replacer.getUpdatedAtomId(id));
|
|
2520
|
-
const nodeChanges = replaceIdMapRevisions(table.nodeChanges, replacer, (nodeId) => replacer.getUpdatedAtomId(normalizeNodeId(nodeId, nodeAliases)));
|
|
2521
|
-
const detachLocations = table.detachLocations.mapEntries((id) => replacer.getUpdatedAtomId(id), (fieldId) => replaceFieldIdRevision(normalizeFieldId(fieldId, nodeAliases), replacer));
|
|
2522
|
-
const outputDetachLocations = table.outputDetachLocations.mapEntries((id) => replacer.getUpdatedAtomId(id), (fieldId) => replaceFieldIdRevision(normalizeFieldId(fieldId, nodeAliases), replacer));
|
|
2523
|
-
return { oldToNewId, newToOldId, nodeChanges, detachLocations, outputDetachLocations };
|
|
2524
|
-
}
|
|
2525
|
-
function newDetachedEntryMap() {
|
|
2526
|
-
return new index_js_3.RangeMap(index_js_2.offsetChangeAtomId, index_js_2.subtractChangeAtomIds, offsetDetachedNodeEntry);
|
|
2527
|
-
}
|
|
2528
|
-
function offsetDetachedNodeEntry(entry, count) {
|
|
2529
|
-
(0, internal_1.assert)(count <= 1 || entry.nodeChange === undefined, "Cannot split an entry with a node change");
|
|
2530
|
-
return entry.detachId === undefined
|
|
2531
|
-
? entry
|
|
2532
|
-
: { ...entry, detachId: (0, index_js_2.offsetChangeAtomId)(entry.detachId, count) };
|
|
2533
|
-
}
|
|
2534
|
-
function getFieldsWithRootMoves(roots, nodeAliases) {
|
|
2535
|
-
const fields = newFieldIdKeyBTree();
|
|
2536
|
-
for (const { start: rootId, value: fieldId, length } of roots.detachLocations.entries()) {
|
|
2537
|
-
let isRootMoved = false;
|
|
2538
|
-
for (const renameEntry of roots.oldToNewId.getAll2(rootId, length)) {
|
|
2539
|
-
if (renameEntry.value !== undefined) {
|
|
2540
|
-
isRootMoved = true;
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
for (const outputDetachEntry of roots.outputDetachLocations.getAll2(rootId, length)) {
|
|
2544
|
-
if (outputDetachEntry.value !== undefined) {
|
|
2545
|
-
isRootMoved = true;
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
|
-
if (isRootMoved) {
|
|
2549
|
-
fields.set(fieldIdKeyFromFieldId(normalizeFieldId(fieldId, nodeAliases)), true);
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
return fields;
|
|
2553
|
-
}
|
|
2554
|
-
function getFieldToRootChanges(roots, nodeAliases) {
|
|
2555
|
-
const fields = newFieldIdKeyBTree();
|
|
2556
|
-
for (const rootIdKey of roots.nodeChanges.keys()) {
|
|
2557
|
-
const rootId = { revision: rootIdKey[0], localId: rootIdKey[1] };
|
|
2558
|
-
const detachLocation = roots.detachLocations.getFirst(rootId, 1).value;
|
|
2559
|
-
if (detachLocation !== undefined) {
|
|
2560
|
-
const fieldIdKey = fieldIdKeyFromFieldId(normalizeFieldId(detachLocation, nodeAliases));
|
|
2561
|
-
let rootsInField = fields.get(fieldIdKey);
|
|
2562
|
-
if (rootsInField === undefined) {
|
|
2563
|
-
rootsInField = [];
|
|
2564
|
-
fields.set(fieldIdKey, rootsInField);
|
|
2565
|
-
}
|
|
2566
|
-
rootsInField.push(rootId);
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
return fields;
|
|
2570
|
-
}
|
|
2571
|
-
function muteRootChanges(roots) {
|
|
2572
|
-
return {
|
|
2573
|
-
oldToNewId: (0, index_js_2.newChangeAtomIdTransform)(),
|
|
2574
|
-
newToOldId: (0, index_js_2.newChangeAtomIdTransform)(),
|
|
2575
|
-
nodeChanges: (0, index_js_3.brand)(roots.nodeChanges.clone()),
|
|
2576
|
-
detachLocations: roots.detachLocations.clone(),
|
|
2577
|
-
outputDetachLocations: (0, index_js_2.newChangeAtomIdRangeMap)(),
|
|
2578
|
-
};
|
|
2579
|
-
}
|
|
2580
|
-
function validateChangeset(change, fieldKinds) {
|
|
2581
|
-
const unreachableNodes = (0, index_js_3.brand)(change.nodeToParent.clone());
|
|
2582
|
-
const unreachableCFKs = change.crossFieldKeys.clone();
|
|
2583
|
-
validateFieldChanges(fieldKinds, change, change.fieldChanges, undefined, unreachableNodes, unreachableCFKs);
|
|
2584
|
-
for (const [[revision, localId], node] of change.nodeChanges.entries()) {
|
|
2585
|
-
if (node.fieldChanges === undefined) {
|
|
2586
|
-
continue;
|
|
2587
|
-
}
|
|
2588
|
-
const nodeId = normalizeNodeId({ revision, localId }, change.nodeAliases);
|
|
2589
|
-
validateFieldChanges(fieldKinds, change, node.fieldChanges, nodeId, unreachableNodes, unreachableCFKs);
|
|
2590
|
-
}
|
|
2591
|
-
for (const [detachIdKey, nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
2592
|
-
const detachId = { revision: detachIdKey[0], localId: detachIdKey[1] };
|
|
2593
|
-
const location = getNodeParent(change, nodeId);
|
|
2594
|
-
(0, internal_1.assert)((0, index_js_2.areEqualChangeAtomIdOpts)(location.root, detachId), "Inconsistent node location");
|
|
2595
|
-
const normalizedNodeId = normalizeNodeId(nodeId, change.nodeAliases);
|
|
2596
|
-
unreachableNodes.delete([normalizedNodeId.revision, normalizedNodeId.localId]);
|
|
2597
|
-
const fieldChanges = nodeChangeFromId(change.nodeChanges, change.nodeAliases, nodeId).fieldChanges;
|
|
2598
|
-
if (fieldChanges !== undefined) {
|
|
2599
|
-
validateFieldChanges(fieldKinds, change, fieldChanges, normalizedNodeId, unreachableNodes, unreachableCFKs);
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
if (!containsRollbacks(change)) {
|
|
2603
|
-
for (const entry of change.crossFieldKeys.entries()) {
|
|
2604
|
-
if (entry.start.target !== crossFieldQueries_js_1.NodeMoveType.Attach) {
|
|
2605
|
-
continue;
|
|
2606
|
-
}
|
|
2607
|
-
validateAttach(change, entry.start, entry.length);
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
(0, internal_1.assert)(unreachableNodes.size === 0, "Unreachable nodes found");
|
|
2611
|
-
(0, internal_1.assert)(unreachableCFKs.entries().length === 0, "Unreachable cross-field keys found");
|
|
2612
|
-
}
|
|
2613
|
-
exports.validateChangeset = validateChangeset;
|
|
2614
|
-
function containsRollbacks(change) {
|
|
2615
|
-
if (change.revisions === undefined) {
|
|
2616
|
-
return false;
|
|
2617
|
-
}
|
|
2618
|
-
for (const revInfo of change.revisions) {
|
|
2619
|
-
if (revInfo.rollbackOf !== undefined) {
|
|
2620
|
-
return true;
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
return false;
|
|
2624
|
-
}
|
|
2625
|
-
function validateAttach(changeset, attachId, count) {
|
|
2626
|
-
let countProcessed = count;
|
|
2627
|
-
const buildEntry = hasBuildForIdRange(changeset.builds, attachId, count);
|
|
2628
|
-
countProcessed = buildEntry.length;
|
|
2629
|
-
const detachEntry = changeset.crossFieldKeys.getFirst({ ...attachId, target: crossFieldQueries_js_1.NodeMoveType.Detach }, countProcessed);
|
|
2630
|
-
countProcessed = detachEntry.length;
|
|
2631
|
-
const renameEntry = changeset.rootNodes.newToOldId.getFirst(attachId, countProcessed);
|
|
2632
|
-
countProcessed = renameEntry.length;
|
|
2633
|
-
// assert(
|
|
2634
|
-
// buildEntry.value || detachEntry.value !== undefined || renameEntry.value !== undefined,
|
|
2635
|
-
// "No build, detach, or rename found for attach",
|
|
2636
|
-
// );
|
|
2637
|
-
if (countProcessed < count) {
|
|
2638
|
-
validateAttach(changeset, (0, index_js_2.offsetChangeAtomId)(attachId, countProcessed), count - countProcessed);
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
function hasBuildForIdRange(builds, id, count) {
|
|
2642
|
-
if (builds === undefined) {
|
|
2643
|
-
return { value: false, length: count };
|
|
2644
|
-
}
|
|
2645
|
-
const prevBuildEntry = builds.nextLowerPair([id.revision, id.localId]);
|
|
2646
|
-
if (prevBuildEntry !== undefined) {
|
|
2647
|
-
const prevBuildKey = {
|
|
2648
|
-
revision: prevBuildEntry[0][0],
|
|
2649
|
-
localId: prevBuildEntry[0][1],
|
|
2650
|
-
};
|
|
2651
|
-
const prevBuildLength = prevBuildEntry[1].topLevelLength;
|
|
2652
|
-
const lastLocalId = prevBuildKey.localId + prevBuildLength - 1;
|
|
2653
|
-
if (prevBuildKey.revision === id.revision && lastLocalId >= id.localId) {
|
|
2654
|
-
return { value: true, length: Math.min(count, lastLocalId - id.localId + 1) };
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
const buildEntry = (0, changeAtomIdBTree_js_1.rangeQueryChangeAtomIdMap)(builds, id, count);
|
|
2658
|
-
const length = buildEntry.value === undefined ? buildEntry.length : buildEntry.value.topLevelLength;
|
|
2659
|
-
const hasBuild = buildEntry.value !== undefined;
|
|
2660
|
-
return { value: hasBuild, length };
|
|
1752
|
+
function noNewChangesRebaseChild(child, _baseChild, _stateChange) {
|
|
1753
|
+
(0, internal_1.assert)(child === undefined, 0x9c3 /* There should be no new changes in this field */);
|
|
1754
|
+
return undefined;
|
|
2661
1755
|
}
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
* and each cross field key has a correct entry in `change.crossFieldKeys`.
|
|
2665
|
-
* @returns the number of children found.
|
|
2666
|
-
*/
|
|
2667
|
-
function validateFieldChanges(fieldKinds, change, fieldChanges, nodeParent, unreachableNodes, unreachableCFKs) {
|
|
2668
|
-
for (const [field, fieldChange] of fieldChanges.entries()) {
|
|
2669
|
-
const fieldId = { nodeId: nodeParent, field };
|
|
2670
|
-
const handler = getChangeHandler(fieldKinds, fieldChange.fieldKind);
|
|
2671
|
-
for (const [child, _index] of handler.getNestedChanges(fieldChange.change)) {
|
|
2672
|
-
const parentFieldId = getNodeParent(change, child);
|
|
2673
|
-
(0, internal_1.assert)(parentFieldId.field !== undefined && areEqualFieldIds(parentFieldId.field, fieldId), 0xa4e /* Inconsistent node parentage */);
|
|
2674
|
-
unreachableNodes.delete([child.revision, child.localId]);
|
|
2675
|
-
}
|
|
2676
|
-
for (const keyRange of handler.getCrossFieldKeys(fieldChange.change)) {
|
|
2677
|
-
const fields = getFieldsForCrossFieldKey(change, keyRange.key, keyRange.count);
|
|
2678
|
-
(0, internal_1.assert)(fields.length > 0, "Unregistered cross-field key");
|
|
2679
|
-
for (const fieldFromLookup of fields) {
|
|
2680
|
-
(0, internal_1.assert)(areEqualFieldIds(fieldFromLookup, fieldId), 0xa4f /* Inconsistent cross field keys */);
|
|
2681
|
-
}
|
|
2682
|
-
unreachableCFKs.delete(keyRange.key, keyRange.count);
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
1756
|
+
function areEqualFieldIds(a, b) {
|
|
1757
|
+
return (0, index_js_2.areEqualChangeAtomIdOpts)(a.nodeId, b.nodeId) && a.field === b.field;
|
|
2685
1758
|
}
|
|
2686
1759
|
function newFieldIdKeyBTree() {
|
|
2687
1760
|
return (0, index_js_3.newTupleBTree)(compareFieldIdKeys);
|
|
2688
1761
|
}
|
|
2689
|
-
exports.newFieldIdKeyBTree = newFieldIdKeyBTree;
|
|
2690
1762
|
const compareFieldIdKeys = (0, index_js_3.createTupleComparator)([
|
|
2691
1763
|
index_js_2.comparePartialRevisions,
|
|
2692
1764
|
index_js_2.comparePartialChangesetLocalIds,
|