@fluidframework/tree 2.74.0-370705 → 2.80.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/.eslintrc.cjs +1 -16
- package/.vscode/settings.json +2 -0
- package/CHANGELOG.md +29 -0
- package/api-report/tree.alpha.api.md +39 -17
- package/assertTagging.config.mjs +1 -1
- package/dist/alpha.d.ts +7 -0
- package/dist/codec/codec.d.ts +63 -20
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +50 -24
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +2 -2
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +80 -22
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +137 -15
- package/dist/codec/versioned/codec.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 -2
- 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 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -8
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +37 -8
- 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 +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +1 -3
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +27 -5
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -16
- 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 +10 -28
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +4 -7
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +5 -5
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +3 -4
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +1 -8
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +12 -65
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
- package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +4 -4
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.js +2 -2
- package/dist/core/tree/detachedFieldIndexFormatCommon.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 +4 -5
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/mapTree.js +1 -1
- package/dist/core/tree/mapTree.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/sparseTree.d.ts.map +1 -1
- package/dist/core/tree/sparseTree.js +1 -0
- package/dist/core/tree/sparseTree.js.map +1 -1
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js +5 -9
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/dist/feature-libraries/changeAtomIdBTree.js +16 -0
- package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -8
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +1 -4
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +5 -5
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +4 -4
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +54 -93
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +81 -245
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +6 -5
- 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 -5
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +8 -7
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js +6 -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 +16 -47
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +8 -2
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +13 -11
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +18 -9
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +61 -0
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/{format.js → formatCommon.js} +9 -6
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -0
- package/dist/feature-libraries/forest-summary/{format.d.ts → formatV1.d.ts} +6 -14
- package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV1.js +11 -0
- package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV2.d.ts +51 -0
- package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV2.js +11 -0
- package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +7 -15
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +11 -20
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts +1 -2
- package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/index.js +3 -5
- package/dist/feature-libraries/forest-summary/index.js.map +1 -1
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.d.ts +35 -0
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.js +43 -0
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.js.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts +11 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.js +14 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.js.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.d.ts +18 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.js +21 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.js.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryTypes.d.ts +7 -37
- package/dist/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/summaryTypes.js +23 -45
- package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +5 -4
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +10 -12
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/dist/feature-libraries/mapTreeCursor.js +0 -1
- package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +12 -3
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +13 -10
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +21 -97
- package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js +7 -4
- package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +52 -20
- 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 +13 -7
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +7 -5
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +7 -7
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +41 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +263 -336
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +7 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +8 -390
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +24 -11
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +27 -55
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +622 -1433
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +3 -4
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +4 -4
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +14 -48
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +10 -21
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +18 -48
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -24
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +4 -4
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/index.d.ts +2 -2
- package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/index.js +2 -1
- package/dist/feature-libraries/optional-field/index.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts +26 -5
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +447 -218
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +33 -24
- 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/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -4
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +28 -70
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -1
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +2 -5
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +11 -6
- package/dist/feature-libraries/schemaChecker.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 +264 -84
- 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/index.d.ts +3 -2
- package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/index.js +3 -1
- package/dist/feature-libraries/sequence-field/index.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 +169 -66
- 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 +93 -8
- 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 +127 -113
- 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 +2 -2
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.js +49 -27
- 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 -0
- 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 -358
- 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 +10 -10
- 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 +115 -17
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/types.d.ts +59 -30
- 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 +24 -15
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +334 -127
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +7 -7
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/feature-libraries/treeTextCursor.js +2 -2
- package/dist/feature-libraries/treeTextCursor.js.map +1 -1
- package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/valueUtilities.js +16 -8
- package/dist/feature-libraries/valueUtilities.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -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 +1 -1
- 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 +9 -5
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +56 -41
- 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 +57 -50
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +11 -11
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +5 -3
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +7 -6
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +23 -24
- 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/treeAlpha.d.ts +35 -29
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +21 -23
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +17 -12
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +85 -66
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +5 -4
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +7 -6
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.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 +10 -10
- 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 +13 -16
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +9 -44
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +8 -8
- 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 +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +3 -2
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +2 -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/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.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 +15 -19
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +10 -50
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +9 -8
- 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 +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
- package/dist/shared-tree-core/sequenceIdUtils.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 +13 -9
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +25 -8
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +65 -30
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +3 -3
- package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
- package/dist/shared-tree-core/versionedSummarizer.d.ts +6 -1
- package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/versionedSummarizer.js +4 -3
- package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
- package/dist/simple-tree/api/configuration.js +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +13 -9
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +21 -17
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts +89 -0
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -0
- package/dist/simple-tree/api/eraseSchemaDetails.js +97 -0
- package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -0
- package/dist/simple-tree/api/index.d.ts +2 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +5 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +12 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +18 -9
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +3 -5
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
- 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 +15 -2
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +21 -13
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +14 -9
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNode.js +1 -0
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +6 -3
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +15 -15
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +28 -74
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +1 -1
- package/dist/simple-tree/createContext.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/getTreeNodeForField.d.ts.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +2 -1
- package/dist/simple-tree/getTreeNodeForField.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 +5 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +9 -6
- package/dist/simple-tree/leafNodeSchema.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 +18 -20
- 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 +21 -22
- 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 +4 -7
- 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/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +12 -8
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +4 -13
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +11 -29
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/tableSchema.d.ts +3 -14
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +2 -2
- package/dist/tableSchema.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/bTreeUtils.js +1 -1
- package/dist/util/bTreeUtils.js.map +1 -1
- package/dist/util/brand.d.ts +49 -0
- package/dist/util/brand.d.ts.map +1 -1
- package/dist/util/brand.js +47 -1
- package/dist/util/brand.js.map +1 -1
- package/dist/util/breakable.js +7 -9
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/idAllocator.d.ts.map +1 -1
- package/dist/util/idAllocator.js +1 -2
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +4 -3
- package/dist/util/index.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +1 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/rangeMap.d.ts +12 -24
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +6 -46
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +16 -15
- package/dist/util/utils.js.map +1 -1
- package/docs/main/sequence-field/move-composition.md +46 -0
- package/eslint.config.mts +83 -0
- package/lib/alpha.d.ts +7 -0
- package/lib/codec/codec.d.ts +63 -20
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +44 -18
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +2 -2
- 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 +80 -22
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +138 -15
- package/lib/codec/versioned/codec.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 -3
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +37 -8
- 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 +2 -2
- 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 +27 -5
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -13
- 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 +10 -28
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +4 -7
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +6 -6
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +3 -4
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +1 -8
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +14 -67
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
- package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +4 -4
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.js +3 -3
- package/lib/core/tree/detachedFieldIndexFormatCommon.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 +2 -2
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/mapTree.js +1 -1
- package/lib/core/tree/mapTree.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/sparseTree.d.ts.map +1 -1
- package/lib/core/tree/sparseTree.js +1 -0
- package/lib/core/tree/sparseTree.js.map +1 -1
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js +5 -9
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/lib/feature-libraries/changeAtomIdBTree.js +11 -0
- package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +2 -9
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -4
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +20 -12
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +5 -5
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +5 -5
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +54 -93
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +82 -243
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +6 -5
- 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 +8 -7
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js +6 -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 +17 -48
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +8 -2
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +12 -11
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +19 -10
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +61 -0
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/{format.js → formatCommon.js} +8 -6
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -0
- package/lib/feature-libraries/forest-summary/{format.d.ts → formatV1.d.ts} +6 -14
- package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV1.js +8 -0
- package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV2.d.ts +51 -0
- package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV2.js +8 -0
- package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +7 -15
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +11 -20
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts +1 -2
- package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/index.js +1 -2
- package/lib/feature-libraries/forest-summary/index.js.map +1 -1
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.d.ts +35 -0
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.js +40 -0
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.js.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts +11 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.js +11 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.js.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.d.ts +18 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.js +18 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.js.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryTypes.d.ts +7 -37
- package/lib/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/summaryTypes.js +20 -43
- package/lib/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +5 -4
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +5 -4
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
- package/lib/feature-libraries/mapTreeCursor.js +1 -2
- package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +12 -3
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +13 -10
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +21 -97
- package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js +5 -3
- package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +52 -20
- 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 +14 -8
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +7 -5
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +5 -4
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +41 -9
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +248 -334
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +7 -9
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +10 -392
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +24 -11
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +27 -55
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +549 -1352
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +3 -4
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +14 -48
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +10 -21
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +18 -48
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js +2 -20
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +4 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/index.d.ts +2 -2
- package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/index.js +1 -1
- package/lib/feature-libraries/optional-field/index.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts +26 -5
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +445 -218
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +33 -24
- 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/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +16 -5
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +29 -67
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -1
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +11 -6
- package/lib/feature-libraries/schemaChecker.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 +266 -86
- 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/index.d.ts +3 -2
- package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/index.js +1 -0
- package/lib/feature-libraries/sequence-field/index.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 +171 -68
- 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 +87 -7
- 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 +129 -115
- 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 +2 -2
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +50 -28
- 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 +2 -0
- 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 +183 -350
- 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 +10 -10
- 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 +115 -17
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/types.d.ts +59 -30
- 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 +24 -15
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +327 -123
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +7 -7
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/feature-libraries/treeTextCursor.js +2 -2
- package/lib/feature-libraries/treeTextCursor.js.map +1 -1
- package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/valueUtilities.js +16 -8
- package/lib/feature-libraries/valueUtilities.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/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 +2 -2
- 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 +9 -5
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +59 -44
- 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 +26 -19
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +11 -11
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +6 -4
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +7 -6
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +24 -25
- 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/treeAlpha.d.ts +35 -29
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +21 -23
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +17 -12
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +89 -70
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +5 -4
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +7 -6
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
- package/lib/shared-tree-core/branchCommitEnricher.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 +10 -10
- 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 +13 -15
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +9 -44
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +9 -9
- 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 +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +3 -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/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.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 +15 -18
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +10 -50
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +9 -8
- 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 +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
- package/lib/shared-tree-core/sequenceIdUtils.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 +13 -9
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +25 -8
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +67 -32
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +3 -3
- package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
- package/lib/shared-tree-core/versionedSummarizer.d.ts +6 -1
- package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/versionedSummarizer.js +4 -3
- package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
- package/lib/simple-tree/api/configuration.js +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +13 -9
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +21 -17
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts +89 -0
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -0
- package/lib/simple-tree/api/eraseSchemaDetails.js +92 -0
- package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -0
- package/lib/simple-tree/api/index.d.ts +2 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +12 -8
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +18 -9
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +5 -9
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
- 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 +15 -2
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +21 -13
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +14 -9
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNode.js +1 -0
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +6 -3
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +15 -15
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +28 -73
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +1 -1
- package/lib/simple-tree/createContext.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/getTreeNodeForField.d.ts.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +2 -1
- package/lib/simple-tree/getTreeNodeForField.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/leafNodeSchema.js +9 -6
- package/lib/simple-tree/leafNodeSchema.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 +19 -21
- 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 +22 -23
- 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 +4 -7
- 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 +124 -183
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +12 -8
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +4 -13
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +9 -26
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/tableSchema.d.ts +3 -14
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +3 -3
- package/lib/tableSchema.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/bTreeUtils.js +1 -1
- package/lib/util/bTreeUtils.js.map +1 -1
- package/lib/util/brand.d.ts +49 -0
- package/lib/util/brand.d.ts.map +1 -1
- package/lib/util/brand.js +44 -0
- package/lib/util/brand.js.map +1 -1
- package/lib/util/breakable.js +7 -9
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/idAllocator.d.ts.map +1 -1
- package/lib/util/idAllocator.js +1 -2
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +1 -1
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/rangeMap.d.ts +12 -24
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +5 -44
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +16 -15
- package/lib/util/utils.js.map +1 -1
- package/package.json +33 -32
- package/src/codec/codec.ts +82 -26
- package/src/codec/index.ts +4 -1
- package/src/codec/versioned/codec.ts +340 -22
- package/src/codec/versioned/index.ts +3 -1
- package/src/core/change-family/changeFamily.ts +0 -5
- package/src/core/change-family/index.ts +0 -1
- package/src/core/index.ts +4 -6
- package/src/core/rebase/changeRebaser.ts +41 -12
- package/src/core/rebase/index.ts +2 -2
- package/src/core/rebase/types.ts +32 -26
- package/src/core/rebase/utils.ts +10 -34
- package/src/core/schema-stored/schema.ts +8 -10
- package/src/core/tree/anchorSet.ts +3 -4
- package/src/core/tree/detachedFieldIndex.ts +14 -91
- package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
- package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
- package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
- package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
- package/src/core/tree/detachedFieldIndexFormatCommon.ts +4 -7
- package/src/core/tree/index.ts +2 -3
- package/src/core/tree/mapTree.ts +1 -1
- package/src/core/tree/pathTree.ts +4 -16
- package/src/core/tree/sparseTree.ts +1 -0
- package/src/core/tree/treeTextFormat.ts +5 -9
- package/src/feature-libraries/changeAtomIdBTree.ts +24 -0
- package/src/feature-libraries/chunked-forest/basicChunk.ts +2 -8
- package/src/feature-libraries/chunked-forest/chunkTree.ts +1 -6
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -5
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +20 -11
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/format.ts +6 -9
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +163 -403
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +9 -7
- package/src/feature-libraries/default-schema/index.ts +5 -17
- package/src/feature-libraries/default-schema/mappedEditBuilder.ts +15 -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 +31 -74
- package/src/feature-libraries/forest-summary/codec.ts +25 -13
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +37 -12
- package/src/feature-libraries/forest-summary/{format.ts → formatCommon.ts} +10 -11
- package/src/feature-libraries/forest-summary/formatV1.ts +12 -0
- package/src/feature-libraries/forest-summary/formatV2.ts +12 -0
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +18 -21
- package/src/feature-libraries/forest-summary/index.ts +1 -2
- package/src/feature-libraries/forest-summary/summaryFormatCommon.ts +41 -0
- package/src/feature-libraries/forest-summary/summaryFormatV1ToV2.ts +11 -0
- package/src/feature-libraries/forest-summary/summaryFormatV3.ts +18 -0
- package/src/feature-libraries/forest-summary/summaryTypes.ts +26 -46
- package/src/feature-libraries/index.ts +18 -27
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
- package/src/feature-libraries/mapTreeCursor.ts +1 -2
- package/src/feature-libraries/mitigatedChangeFamily.ts +12 -9
- package/src/feature-libraries/modular-schema/comparison.ts +14 -10
- package/src/feature-libraries/modular-schema/crossFieldQueries.ts +44 -142
- package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +58 -40
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +23 -13
- package/src/feature-libraries/modular-schema/index.ts +18 -21
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +543 -572
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +44 -745
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +37 -51
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +862 -2636
- package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +3 -4
- package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +17 -45
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +18 -97
- package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
- package/src/feature-libraries/object-forest/objectForest.ts +4 -4
- package/src/feature-libraries/optional-field/index.ts +3 -1
- package/src/feature-libraries/optional-field/optionalField.ts +566 -321
- package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +38 -24
- package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +35 -89
- package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +1 -5
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +19 -5
- package/src/feature-libraries/schema-index/codec.ts +30 -92
- package/src/feature-libraries/schema-index/index.ts +2 -4
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
- package/src/feature-libraries/schemaChecker.ts +11 -6
- package/src/feature-libraries/sequence-field/compose.ts +527 -138
- package/src/feature-libraries/sequence-field/helperTypes.ts +19 -34
- package/src/feature-libraries/sequence-field/index.ts +9 -0
- package/src/feature-libraries/sequence-field/invert.ts +229 -103
- package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +198 -9
- package/src/feature-libraries/sequence-field/rebase.ts +218 -175
- package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +57 -0
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +76 -59
- package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +2 -0
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +228 -643
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +70 -56
- package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +27 -25
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +135 -22
- package/src/feature-libraries/sequence-field/types.ts +64 -34
- package/src/feature-libraries/sequence-field/utils.ts +382 -150
- package/src/feature-libraries/treeCursorUtils.ts +7 -7
- package/src/feature-libraries/treeTextCursor.ts +2 -2
- package/src/feature-libraries/valueUtilities.ts +16 -8
- package/src/index.ts +7 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +1 -2
- package/src/shared-tree/index.ts +2 -3
- package/src/shared-tree/schematizeTree.ts +8 -21
- package/src/shared-tree/schematizingTreeView.ts +96 -63
- package/src/shared-tree/sharedTree.ts +29 -29
- package/src/shared-tree/sharedTreeChangeCodecs.ts +12 -15
- package/src/shared-tree/sharedTreeChangeEnricher.ts +4 -4
- package/src/shared-tree/sharedTreeChangeFamily.ts +34 -34
- package/src/shared-tree/sharedTreeEditBuilder.ts +9 -39
- package/src/shared-tree/treeAlpha.ts +60 -51
- package/src/shared-tree/treeCheckout.ts +158 -132
- package/src/shared-tree-core/branch.ts +10 -11
- package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
- package/src/shared-tree-core/editManager.ts +3 -17
- package/src/shared-tree-core/editManagerCodecs.ts +13 -18
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +1 -1
- package/src/shared-tree-core/editManagerFormatCommons.ts +12 -15
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +2 -2
- package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
- package/src/shared-tree-core/index.ts +3 -2
- package/src/shared-tree-core/messageCodecV1ToV4.ts +1 -1
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
- package/src/shared-tree-core/messageCodecs.ts +15 -21
- package/src/shared-tree-core/messageFormat.ts +12 -15
- package/src/shared-tree-core/messageFormatV1ToV4.ts +2 -2
- package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
- package/src/shared-tree-core/sharedTreeCore.ts +12 -11
- package/src/shared-tree-core/transaction.ts +115 -56
- package/src/shared-tree-core/transactionEnricher.ts +5 -6
- package/src/shared-tree-core/versionedSummarizer.ts +10 -3
- package/src/simple-tree/api/configuration.ts +1 -1
- package/src/simple-tree/api/customTree.ts +14 -10
- package/src/simple-tree/api/discrepancies.ts +23 -17
- package/src/simple-tree/api/eraseSchemaDetails.ts +123 -0
- package/src/simple-tree/api/index.ts +6 -0
- package/src/simple-tree/api/schemaFactory.ts +11 -7
- package/src/simple-tree/api/schemaFromSimple.ts +18 -9
- package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -13
- package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
- package/src/simple-tree/api/storedSchema.ts +12 -9
- package/src/simple-tree/api/transactionTypes.ts +19 -4
- package/src/simple-tree/api/tree.ts +16 -1
- package/src/simple-tree/api/treeNodeApi.ts +21 -13
- package/src/simple-tree/api/verboseTree.ts +14 -9
- package/src/simple-tree/core/treeNode.ts +1 -0
- package/src/simple-tree/core/treeNodeKernel.ts +6 -3
- package/src/simple-tree/core/unhydratedFlexTree.ts +58 -104
- package/src/simple-tree/createContext.ts +4 -1
- package/src/simple-tree/fieldSchema.ts +4 -6
- package/src/simple-tree/getTreeNodeForField.ts +2 -1
- package/src/simple-tree/index.ts +5 -2
- package/src/simple-tree/leafNodeSchema.ts +8 -5
- package/src/simple-tree/node-kinds/array/arrayNode.ts +28 -30
- 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 +28 -29
- package/src/simple-tree/node-kinds/record/recordNode.ts +11 -13
- package/src/simple-tree/prepareForInsertion.ts +200 -343
- package/src/simple-tree/toStoredSchema.ts +12 -8
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +14 -42
- package/src/tableSchema.ts +13 -18
- package/src/treeFactory.ts +5 -14
- package/src/util/bTreeUtils.ts +1 -1
- package/src/util/brand.ts +61 -0
- package/src/util/breakable.ts +9 -9
- package/src/util/idAllocator.ts +1 -2
- package/src/util/index.ts +3 -3
- package/src/util/nestedMap.ts +1 -3
- package/src/util/rangeMap.ts +18 -72
- package/src/util/utils.ts +14 -13
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +0 -36
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +0 -1
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +0 -126
- package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +0 -1
- package/dist/feature-libraries/forest-summary/format.d.ts.map +0 -1
- package/dist/feature-libraries/forest-summary/format.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/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +0 -36
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +0 -1
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +0 -122
- package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +0 -1
- package/lib/feature-libraries/forest-summary/format.d.ts.map +0 -1
- package/lib/feature-libraries/forest-summary/format.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/feature-libraries/default-schema/locationBasedEditBuilder.ts +0 -180
- package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +0 -45
- package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +0 -94
|
@@ -4,19 +4,24 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { BTree } from "@tylerbu/sorted-btree-es6";
|
|
7
|
-
import {
|
|
7
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
import { FluidClientVersion, } from "../../codec/index.js";
|
|
9
|
+
import { EditBuilder, makeDetachedNodeId, revisionMetadataSourceFromInfo, areEqualChangeAtomIds, areEqualChangeAtomIdOpts, tagChange, makeAnonChange, newChangeAtomIdRangeMap, mapTaggedChange, } from "../../core/index.js";
|
|
8
10
|
import { brand, idAllocatorFromMaxId, idAllocatorFromState, getOrCreate, newTupleBTree, mergeTupleBTrees, RangeMap, balancedReduce, } from "../../util/index.js";
|
|
9
|
-
import { CrossFieldTarget, setInCrossFieldMap, } from "./crossFieldQueries.js";
|
|
11
|
+
import { CrossFieldTarget, getFirstFromCrossFieldMap, setInCrossFieldMap, } from "./crossFieldQueries.js";
|
|
10
12
|
import { NodeAttachState, } from "./fieldChangeHandler.js";
|
|
11
13
|
import { convertGenericChange, genericFieldKind } from "./genericFieldKind.js";
|
|
12
|
-
import {
|
|
14
|
+
import { newCrossFieldKeyTable, } from "./modularChangeTypes.js";
|
|
15
|
+
import { getFromChangeAtomIdMap, setInChangeAtomIdMap, } from "../changeAtomIdBTree.js";
|
|
16
|
+
import { lt } from "semver-ts";
|
|
13
17
|
/**
|
|
14
18
|
* Implementation of ChangeFamily which delegates work in a given field to the appropriate FieldKind
|
|
15
19
|
* as determined by the schema.
|
|
16
20
|
*/
|
|
17
21
|
export class ModularChangeFamily {
|
|
18
|
-
constructor(fieldKinds, codecs) {
|
|
22
|
+
constructor(fieldKinds, codecs, codecOptions) {
|
|
19
23
|
this.codecs = codecs;
|
|
24
|
+
this.codecOptions = codecOptions;
|
|
20
25
|
this.fieldKinds = fieldKinds;
|
|
21
26
|
}
|
|
22
27
|
get rebaser() {
|
|
@@ -31,9 +36,9 @@ export class ModularChangeFamily {
|
|
|
31
36
|
*/
|
|
32
37
|
normalizeFieldChanges(change1, change2) {
|
|
33
38
|
// TODO: Handle the case where changes have conflicting field kinds
|
|
34
|
-
const kind = change1.fieldKind
|
|
35
|
-
?
|
|
36
|
-
:
|
|
39
|
+
const kind = change1.fieldKind === genericFieldKind.identifier
|
|
40
|
+
? change2.fieldKind
|
|
41
|
+
: change1.fieldKind;
|
|
37
42
|
if (kind === genericFieldKind.identifier) {
|
|
38
43
|
// Both changes are generic
|
|
39
44
|
return {
|
|
@@ -64,19 +69,21 @@ export class ModularChangeFamily {
|
|
|
64
69
|
return convertedChange;
|
|
65
70
|
}
|
|
66
71
|
compose(changes) {
|
|
67
|
-
const { maxId } = getRevInfoFromTaggedChanges(changes);
|
|
72
|
+
const { revInfos, maxId } = getRevInfoFromTaggedChanges(changes);
|
|
68
73
|
const idState = { maxId };
|
|
69
74
|
const pairwiseDelegate = (left, right) => {
|
|
70
|
-
return this.composePair(left, right, idState);
|
|
75
|
+
return this.composePair(left, right, revInfos, idState);
|
|
71
76
|
};
|
|
72
77
|
const innerChanges = changes.map((change) => change.change);
|
|
73
78
|
return balancedReduce(innerChanges, pairwiseDelegate, makeModularChangeset);
|
|
74
79
|
}
|
|
75
|
-
composePair(change1, change2, idState) {
|
|
76
|
-
const
|
|
77
|
-
const { fieldChanges, nodeChanges, nodeToParent, nodeAliases, crossFieldKeys, rootNodes } = this.composeAllFields(change1, change2, revInfos, idState);
|
|
80
|
+
composePair(change1, change2, revInfos, idState) {
|
|
81
|
+
const { fieldChanges, nodeChanges, nodeToParent, nodeAliases, crossFieldKeys } = this.composeAllFields(change1, change2, revInfos, idState);
|
|
78
82
|
const { allBuilds, allDestroys, allRefreshers } = composeBuildsDestroysAndRefreshers(change1, change2);
|
|
79
|
-
|
|
83
|
+
// The composed changeset has a "no change" constraint if either change has one
|
|
84
|
+
const noChangeConstraint = change1.noChangeConstraint ?? change2.noChangeConstraint;
|
|
85
|
+
const noChangeConstraintOnRevert = change1.noChangeConstraintOnRevert ?? change2.noChangeConstraintOnRevert;
|
|
86
|
+
return makeModularChangeset({
|
|
80
87
|
fieldChanges,
|
|
81
88
|
nodeChanges,
|
|
82
89
|
nodeToParent,
|
|
@@ -84,14 +91,12 @@ export class ModularChangeFamily {
|
|
|
84
91
|
crossFieldKeys,
|
|
85
92
|
maxId: idState.maxId,
|
|
86
93
|
revisions: revInfos,
|
|
87
|
-
|
|
94
|
+
noChangeConstraint,
|
|
95
|
+
noChangeConstraintOnRevert,
|
|
88
96
|
builds: allBuilds,
|
|
89
97
|
destroys: allDestroys,
|
|
90
98
|
refreshers: allRefreshers,
|
|
91
99
|
});
|
|
92
|
-
// XXX: This is an expensive assert which should be disabled before merging.
|
|
93
|
-
this.validateChangeset(composed);
|
|
94
|
-
return composed;
|
|
95
100
|
}
|
|
96
101
|
composeAllFields(potentiallyConflictedChange1, potentiallyConflictedChange2, revInfos, idState) {
|
|
97
102
|
// Our current cell ordering scheme in sequences depends on being able to rebase over a change with conflicts.
|
|
@@ -112,50 +117,34 @@ export class ModularChangeFamily {
|
|
|
112
117
|
const composedNodeChanges = brand(mergeTupleBTrees(change1.nodeChanges, change2.nodeChanges));
|
|
113
118
|
const composedNodeToParent = brand(mergeTupleBTrees(change1.nodeToParent, change2.nodeToParent));
|
|
114
119
|
const composedNodeAliases = brand(mergeTupleBTrees(change1.nodeAliases, change2.nodeAliases));
|
|
115
|
-
const
|
|
116
|
-
nodeIdsToCompose: [],
|
|
117
|
-
affectedBaseFields: newTupleBTree(),
|
|
118
|
-
};
|
|
119
|
-
const movedCrossFieldKeys = newCrossFieldRangeTable();
|
|
120
|
-
const removedCrossFieldKeys = newCrossFieldRangeTable();
|
|
121
|
-
const composedRoots = composeRootTables(change1, change2, composedNodeToParent, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
122
|
-
const crossFieldTable = newComposeTable(change1, change2, composedRoots, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
120
|
+
const crossFieldTable = newComposeTable(change1, change2, composedNodeToParent);
|
|
123
121
|
const composedFields = this.composeFieldMaps(change1.fieldChanges, change2.fieldChanges, undefined, genId, crossFieldTable, revisionMetadata);
|
|
124
122
|
this.composeInvalidatedElements(crossFieldTable, composedFields, composedNodeChanges, composedNodeToParent, composedNodeAliases, genId, revisionMetadata);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
for (const [nodeId, location] of crossFieldTable.movedNodeToParent.entries()) {
|
|
129
|
-
// Moved nodes are from change2.
|
|
130
|
-
// If there is a corresponding node in change1, then composedNodeToParent will already have the correct entry,
|
|
131
|
-
// because the location of the node is the same in change1 and the composed change
|
|
132
|
-
// (since they have the same input context).
|
|
133
|
-
if (crossFieldTable.newToBaseNodeId.get(nodeId) === undefined) {
|
|
134
|
-
composedNodeToParent.set(nodeId, location);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
123
|
+
// Currently no field kinds require making changes to cross-field keys during composition, so we can just merge the two tables.
|
|
124
|
+
const composedCrossFieldKeys = RangeMap.union(change1.crossFieldKeys, change2.crossFieldKeys);
|
|
137
125
|
return {
|
|
138
126
|
fieldChanges: composedFields,
|
|
139
127
|
nodeChanges: composedNodeChanges,
|
|
140
128
|
nodeToParent: composedNodeToParent,
|
|
141
129
|
nodeAliases: composedNodeAliases,
|
|
142
|
-
crossFieldKeys:
|
|
143
|
-
rootNodes: composedRoots,
|
|
130
|
+
crossFieldKeys: composedCrossFieldKeys,
|
|
144
131
|
};
|
|
145
132
|
}
|
|
146
133
|
composeInvalidatedField(fieldChange, crossFieldTable, genId, revisionMetadata) {
|
|
147
134
|
const context = crossFieldTable.fieldToContext.get(fieldChange);
|
|
148
135
|
assert(context !== undefined, 0x8cc /* Should have context for every invalidated field */);
|
|
149
|
-
const { change1: fieldChange1, change2: fieldChange2, composedChange } = context;
|
|
150
|
-
crossFieldTable.pendingCompositions.affectedBaseFields.delete(fieldIdKeyFromFieldId(context.fieldId));
|
|
136
|
+
const { fieldId, change1: fieldChange1, change2: fieldChange2, composedChange } = context;
|
|
151
137
|
const rebaser = getChangeHandler(this.fieldKinds, composedChange.fieldKind).rebaser;
|
|
152
138
|
const composeNodes = (child1, child2) => {
|
|
153
|
-
if (child1 !== undefined &&
|
|
154
|
-
|
|
139
|
+
if (child1 !== undefined &&
|
|
140
|
+
child2 !== undefined &&
|
|
141
|
+
getFromChangeAtomIdMap(crossFieldTable.newToBaseNodeId, child2) === undefined) {
|
|
142
|
+
setInChangeAtomIdMap(crossFieldTable.newToBaseNodeId, child2, child1);
|
|
143
|
+
crossFieldTable.pendingCompositions.nodeIdsToCompose.push([child1, child2]);
|
|
155
144
|
}
|
|
156
145
|
return child1 ?? child2 ?? fail(0xb22 /* Should not compose two undefined nodes */);
|
|
157
146
|
};
|
|
158
|
-
const amendedChange = rebaser.compose(fieldChange1, fieldChange2, composeNodes, genId, new
|
|
147
|
+
const amendedChange = rebaser.compose(fieldChange1, fieldChange2, composeNodes, genId, new ComposeManager(crossFieldTable, fieldChange, fieldId, false), revisionMetadata);
|
|
159
148
|
composedChange.change = brand(amendedChange);
|
|
160
149
|
}
|
|
161
150
|
/**
|
|
@@ -164,23 +153,32 @@ export class ModularChangeFamily {
|
|
|
164
153
|
* - discovering that two node changesets refer to the same node (`nodeIdsToCompose`)
|
|
165
154
|
* - a previously composed field being invalidated by a cross field effect (`invalidatedFields`)
|
|
166
155
|
* - a field which was copied directly from an input changeset being invalidated by a cross field effect
|
|
167
|
-
* (`affectedBaseFields`)
|
|
156
|
+
* (`affectedBaseFields` and `affectedNewFields`)
|
|
168
157
|
*
|
|
169
158
|
* Updating an element may invalidate further elements. This function runs until there is no more invalidation.
|
|
170
159
|
*/
|
|
171
160
|
composeInvalidatedElements(table, composedFields, composedNodes, composedNodeToParent, nodeAliases, genId, metadata) {
|
|
172
161
|
const pending = table.pendingCompositions;
|
|
173
|
-
while (
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
while (table.invalidatedFields.size > 0 ||
|
|
163
|
+
pending.nodeIdsToCompose.length > 0 ||
|
|
164
|
+
pending.affectedBaseFields.length > 0 ||
|
|
165
|
+
pending.affectedNewFields.length > 0) {
|
|
166
|
+
// Note that the call to `composeNodesById` can add entries to `crossFieldTable.nodeIdPairs`.
|
|
167
|
+
for (const [id1, id2] of pending.nodeIdsToCompose) {
|
|
168
|
+
this.composeNodesById(table.baseChange.nodeChanges, table.newChange.nodeChanges, composedNodes, composedNodeToParent, nodeAliases, id1, id2, genId, table, metadata);
|
|
169
|
+
}
|
|
170
|
+
pending.nodeIdsToCompose.length = 0;
|
|
171
|
+
this.composeAffectedFields(table, table.baseChange, true, pending.affectedBaseFields, composedFields, composedNodes, genId, metadata);
|
|
172
|
+
this.composeAffectedFields(table, table.newChange, false, pending.affectedNewFields, composedFields, composedNodes, genId, metadata);
|
|
173
|
+
this.processInvalidatedCompositions(table, genId, metadata);
|
|
176
174
|
}
|
|
177
175
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
processInvalidatedCompositions(table, genId, metadata) {
|
|
177
|
+
const fieldsToUpdate = table.invalidatedFields;
|
|
178
|
+
table.invalidatedFields = new Set();
|
|
179
|
+
for (const fieldChange of fieldsToUpdate) {
|
|
180
|
+
this.composeInvalidatedField(fieldChange, table, genId, metadata);
|
|
182
181
|
}
|
|
183
|
-
table.pendingCompositions.nodeIdsToCompose.length = 0;
|
|
184
182
|
}
|
|
185
183
|
/**
|
|
186
184
|
* Ensures that each field in `affectedFields` has been updated in the composition output.
|
|
@@ -193,36 +191,38 @@ export class ModularChangeFamily {
|
|
|
193
191
|
* If not, they are assumed to be part of the new changeset.
|
|
194
192
|
* @param affectedFields - The set of fields to process.
|
|
195
193
|
*/
|
|
196
|
-
composeAffectedFields(table, change, affectedFields, composedFields, composedNodes, genId, metadata) {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const fieldId = fieldIdFromFieldIdKey(fieldIdKey);
|
|
201
|
-
const fieldChange = fieldChangeFromId(change, fieldId);
|
|
194
|
+
composeAffectedFields(table, change, areBaseFields, affectedFields, composedFields, composedNodes, genId, metadata) {
|
|
195
|
+
for (const fieldIdKey of affectedFields.keys()) {
|
|
196
|
+
const fieldId = normalizeFieldId(fieldIdFromFieldIdKey(fieldIdKey), change.nodeAliases);
|
|
197
|
+
const fieldChange = fieldChangeFromId(change.fieldChanges, change.nodeChanges, fieldId);
|
|
202
198
|
if (table.fieldToContext.has(fieldChange) ||
|
|
203
199
|
table.newFieldToBaseField.has(fieldChange)) {
|
|
204
|
-
|
|
200
|
+
// This function handles fields which were not part of the intersection of the two changesets but which need to be updated anyway.
|
|
201
|
+
// If we've already processed this field then either it is up to date
|
|
202
|
+
// or there is pending inval which will be handled in processInvalidatedCompositions.
|
|
203
|
+
continue;
|
|
205
204
|
}
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
const emptyChange = this.createEmptyFieldChange(fieldChange.fieldKind);
|
|
206
|
+
const [change1, change2] = areBaseFields
|
|
207
|
+
? [fieldChange, emptyChange]
|
|
208
|
+
: [emptyChange, fieldChange];
|
|
209
|
+
const composedField = this.composeFieldChanges(fieldId, change1, change2, genId, table, metadata);
|
|
210
|
+
if (fieldId.nodeId === undefined) {
|
|
211
|
+
composedFields.set(fieldId.field, composedField);
|
|
212
|
+
continue;
|
|
208
213
|
}
|
|
214
|
+
const nodeId = getFromChangeAtomIdMap(table.newToBaseNodeId, fieldId.nodeId) ?? fieldId.nodeId;
|
|
215
|
+
let nodeChangeset = nodeChangeFromId(composedNodes, nodeId);
|
|
216
|
+
if (!table.composedNodes.has(nodeChangeset)) {
|
|
217
|
+
nodeChangeset = cloneNodeChangeset(nodeChangeset);
|
|
218
|
+
setInChangeAtomIdMap(composedNodes, nodeId, nodeChangeset);
|
|
219
|
+
}
|
|
220
|
+
if (nodeChangeset.fieldChanges === undefined) {
|
|
221
|
+
nodeChangeset.fieldChanges = new Map();
|
|
222
|
+
}
|
|
223
|
+
nodeChangeset.fieldChanges.set(fieldId.field, composedField);
|
|
209
224
|
}
|
|
210
|
-
|
|
211
|
-
composeFieldWithNoNewChange(table, baseFieldChange, fieldId, composedFields, composedNodes, genId, metadata) {
|
|
212
|
-
const emptyChange = this.createEmptyFieldChange(baseFieldChange.fieldKind);
|
|
213
|
-
const composedField = this.composeFieldChanges(fieldId, baseFieldChange, emptyChange, genId, table, metadata);
|
|
214
|
-
if (fieldId.nodeId === undefined) {
|
|
215
|
-
composedFields.set(fieldId.field, composedField);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const nodeId = normalizeNodeId(getFromChangeAtomIdMap(table.newToBaseNodeId, fieldId.nodeId) ?? fieldId.nodeId, table.baseChange.nodeAliases);
|
|
219
|
-
// We clone the node changeset before mutating it, as it may be from one of the input changesets.
|
|
220
|
-
const nodeChangeset = cloneNodeChangeset(nodeChangeFromId(composedNodes, table.baseChange.nodeAliases, nodeId));
|
|
221
|
-
setInChangeAtomIdMap(composedNodes, nodeId, nodeChangeset);
|
|
222
|
-
if (nodeChangeset.fieldChanges === undefined) {
|
|
223
|
-
nodeChangeset.fieldChanges = new Map();
|
|
224
|
-
}
|
|
225
|
-
nodeChangeset.fieldChanges.set(fieldId.field, composedField);
|
|
225
|
+
affectedFields.clear();
|
|
226
226
|
}
|
|
227
227
|
composeFieldMaps(change1, change2, parentId, genId, crossFieldTable, revisionMetadata) {
|
|
228
228
|
const composedFields = new Map();
|
|
@@ -232,17 +232,9 @@ export class ModularChangeFamily {
|
|
|
232
232
|
for (const [field, fieldChange1] of change1) {
|
|
233
233
|
const fieldId = { nodeId: parentId, field };
|
|
234
234
|
const fieldChange2 = change2.get(field);
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// If `change2` does not have a change for this field, then without this check we would
|
|
239
|
-
// lose the composed field change and instead simply have `change1`'s change.
|
|
240
|
-
composedFields.set(field, cachedComposedFieldChange);
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
const composedField = fieldChange2 !== undefined
|
|
244
|
-
? this.composeFieldChanges(fieldId, fieldChange1, fieldChange2, genId, crossFieldTable, revisionMetadata)
|
|
245
|
-
: fieldChange1;
|
|
235
|
+
const composedField = fieldChange2 === undefined
|
|
236
|
+
? fieldChange1
|
|
237
|
+
: this.composeFieldChanges(fieldId, fieldChange1, fieldChange2, genId, crossFieldTable, revisionMetadata);
|
|
246
238
|
composedFields.set(field, composedField);
|
|
247
239
|
}
|
|
248
240
|
for (const [field, fieldChange2] of change2) {
|
|
@@ -259,16 +251,17 @@ export class ModularChangeFamily {
|
|
|
259
251
|
* will be added to `crossFieldTable.pendingCompositions.nodeIdsToCompose`.
|
|
260
252
|
*
|
|
261
253
|
* Any fields which had cross-field information sent to them as part of this field composition
|
|
262
|
-
* will be added to `affectedBaseFields` in `crossFieldTable.pendingCompositions`.
|
|
254
|
+
* will be added to either `affectedBaseFields` or `affectedNewFields` in `crossFieldTable.pendingCompositions`.
|
|
263
255
|
*
|
|
264
256
|
* Any composed `FieldChange` which is invalidated by new cross-field information will be added to `crossFieldTable.invalidatedFields`.
|
|
265
257
|
*/
|
|
266
258
|
composeFieldChanges(fieldId, change1, change2, idAllocator, crossFieldTable, revisionMetadata) {
|
|
267
259
|
const { fieldKind, changeHandler, change1: change1Normalized, change2: change2Normalized, } = this.normalizeFieldChanges(change1, change2);
|
|
268
|
-
const manager = new
|
|
260
|
+
const manager = new ComposeManager(crossFieldTable, change1, fieldId);
|
|
269
261
|
const composedChange = changeHandler.rebaser.compose(change1Normalized, change2Normalized, (child1, child2) => {
|
|
270
262
|
if (child1 !== undefined && child2 !== undefined) {
|
|
271
|
-
|
|
263
|
+
setInChangeAtomIdMap(crossFieldTable.newToBaseNodeId, child2, child1);
|
|
264
|
+
crossFieldTable.pendingCompositions.nodeIdsToCompose.push([child1, child2]);
|
|
272
265
|
}
|
|
273
266
|
return child1 ?? child2 ?? fail(0xb23 /* Should not compose two undefined nodes */);
|
|
274
267
|
}, idAllocator, manager, revisionMetadata);
|
|
@@ -285,18 +278,19 @@ export class ModularChangeFamily {
|
|
|
285
278
|
crossFieldTable.newFieldToBaseField.set(change2, change1);
|
|
286
279
|
return composedField;
|
|
287
280
|
}
|
|
288
|
-
composeNodesById(
|
|
289
|
-
const nodeChangeset1 = nodeChangeFromId(
|
|
290
|
-
const nodeChangeset2 = nodeChangeFromId(
|
|
281
|
+
composeNodesById(nodeChanges1, nodeChanges2, composedNodes, composedNodeToParent, nodeAliases, id1, id2, idAllocator, crossFieldTable, revisionMetadata) {
|
|
282
|
+
const nodeChangeset1 = nodeChangeFromId(nodeChanges1, id1);
|
|
283
|
+
const nodeChangeset2 = nodeChangeFromId(nodeChanges2, id2);
|
|
291
284
|
const composedNodeChangeset = this.composeNodeChanges(id1, nodeChangeset1, nodeChangeset2, idAllocator, crossFieldTable, revisionMetadata);
|
|
292
285
|
setInChangeAtomIdMap(composedNodes, id1, composedNodeChangeset);
|
|
293
286
|
if (!areEqualChangeAtomIds(id1, id2)) {
|
|
294
287
|
composedNodes.delete([id2.revision, id2.localId]);
|
|
295
288
|
composedNodeToParent.delete([id2.revision, id2.localId]);
|
|
296
|
-
setInChangeAtomIdMap(
|
|
289
|
+
setInChangeAtomIdMap(nodeAliases, id2, id1);
|
|
297
290
|
// We need to delete id1 to avoid forming a cycle in case id1 already had an alias.
|
|
298
|
-
|
|
291
|
+
nodeAliases.delete([id1.revision, id1.localId]);
|
|
299
292
|
}
|
|
293
|
+
crossFieldTable.composedNodes.add(composedNodeChangeset);
|
|
300
294
|
}
|
|
301
295
|
composeNodeChanges(nodeId, change1, change2, genId, crossFieldTable, revisionMetadata) {
|
|
302
296
|
// WARNING: this composition logic assumes that we never make compositions of the following form:
|
|
@@ -327,8 +321,8 @@ export class ModularChangeFamily {
|
|
|
327
321
|
/**
|
|
328
322
|
* @param change - The change to invert.
|
|
329
323
|
* @param isRollback - Whether the inverted change is meant to rollback a change on a branch as is the case when
|
|
330
|
-
* @param revisionForInvert - The revision for the invert changeset.
|
|
331
324
|
* performing a sandwich rebase.
|
|
325
|
+
* @param revisionForInvert - The revision for the invert changeset.
|
|
332
326
|
*/
|
|
333
327
|
invert(change, isRollback, revisionForInvert) {
|
|
334
328
|
// Rollback changesets destroy the nodes created by the change being rolled back.
|
|
@@ -338,6 +332,8 @@ export class ModularChangeFamily {
|
|
|
338
332
|
const revInfos = isRollback
|
|
339
333
|
? [{ revision: revisionForInvert, rollbackOf: change.revision }]
|
|
340
334
|
: [{ revision: revisionForInvert }];
|
|
335
|
+
const noChangeConstraint = change.change.noChangeConstraintOnRevert;
|
|
336
|
+
const noChangeConstraintOnRevert = change.change.noChangeConstraint;
|
|
341
337
|
if (hasConflicts(change.change)) {
|
|
342
338
|
return makeModularChangeset({
|
|
343
339
|
maxId: change.change.maxId,
|
|
@@ -347,14 +343,9 @@ export class ModularChangeFamily {
|
|
|
347
343
|
}
|
|
348
344
|
const genId = idAllocatorFromMaxId(change.change.maxId ?? -1);
|
|
349
345
|
const crossFieldTable = {
|
|
350
|
-
|
|
351
|
-
entries: newChangeAtomIdRangeMap(),
|
|
346
|
+
...newCrossFieldTable(),
|
|
352
347
|
originalFieldToContext: new Map(),
|
|
353
|
-
invertRevision: revisionForInvert,
|
|
354
348
|
invertedNodeToParent: brand(change.change.nodeToParent.clone()),
|
|
355
|
-
invalidatedFields: new Set(),
|
|
356
|
-
invertedRoots: invertRootTable(change.change, isRollback),
|
|
357
|
-
attachToDetachId: newChangeAtomIdTransform(),
|
|
358
349
|
};
|
|
359
350
|
const { revInfos: oldRevInfos } = getRevInfoFromTaggedChanges([change]);
|
|
360
351
|
const revisionMetadata = revisionMetadataSourceFromInfo(oldRevInfos);
|
|
@@ -370,24 +361,24 @@ export class ModularChangeFamily {
|
|
|
370
361
|
const originalFieldChange = fieldChange.change;
|
|
371
362
|
const context = crossFieldTable.originalFieldToContext.get(fieldChange);
|
|
372
363
|
assert(context !== undefined, 0x851 /* Should have context for every invalidated field */);
|
|
373
|
-
const { invertedField } = context;
|
|
374
|
-
const amendedChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.invert(originalFieldChange, isRollback, genId, revisionForInvert, new
|
|
364
|
+
const { invertedField, fieldId } = context;
|
|
365
|
+
const amendedChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.invert(originalFieldChange, isRollback, genId, revisionForInvert, new InvertManager(crossFieldTable, fieldChange, fieldId), revisionMetadata);
|
|
375
366
|
invertedField.change = brand(amendedChange);
|
|
376
367
|
}
|
|
377
368
|
}
|
|
378
369
|
const crossFieldKeys = this.makeCrossFieldKeyTable(invertedFields, invertedNodes);
|
|
379
|
-
this.processInvertRenames(crossFieldTable);
|
|
380
370
|
return makeModularChangeset({
|
|
381
371
|
fieldChanges: invertedFields,
|
|
382
372
|
nodeChanges: invertedNodes,
|
|
383
373
|
nodeToParent: crossFieldTable.invertedNodeToParent,
|
|
384
|
-
rootNodes: crossFieldTable.invertedRoots,
|
|
385
374
|
nodeAliases: change.change.nodeAliases,
|
|
386
375
|
crossFieldKeys,
|
|
387
376
|
maxId: genId.getMaxId(),
|
|
388
377
|
revisions: revInfos,
|
|
389
378
|
constraintViolationCount: change.change.constraintViolationCountOnRevert,
|
|
390
379
|
constraintViolationCountOnRevert: change.change.constraintViolationCount,
|
|
380
|
+
noChangeConstraint,
|
|
381
|
+
noChangeConstraintOnRevert,
|
|
391
382
|
destroys,
|
|
392
383
|
});
|
|
393
384
|
}
|
|
@@ -395,7 +386,7 @@ export class ModularChangeFamily {
|
|
|
395
386
|
const invertedFields = new Map();
|
|
396
387
|
for (const [field, fieldChange] of changes) {
|
|
397
388
|
const fieldId = { nodeId: parentId, field };
|
|
398
|
-
const manager = new
|
|
389
|
+
const manager = new InvertManager(crossFieldTable, fieldChange, fieldId);
|
|
399
390
|
const invertedChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.invert(fieldChange.change, isRollback, genId, revisionForInvert, manager, revisionMetadata);
|
|
400
391
|
const invertedFieldChange = {
|
|
401
392
|
...fieldChange,
|
|
@@ -427,12 +418,6 @@ export class ModularChangeFamily {
|
|
|
427
418
|
}
|
|
428
419
|
return inverse;
|
|
429
420
|
}
|
|
430
|
-
processInvertRenames(table) {
|
|
431
|
-
for (const { start: newAttachId, value: originalDetachId, length, } of table.attachToDetachId.entries()) {
|
|
432
|
-
// Note that the detach location is already set in `invertDetach`.
|
|
433
|
-
addNodeRename(table.invertedRoots, originalDetachId, newAttachId, length, undefined);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
421
|
rebase(taggedChange, potentiallyConflictedOver, revisionMetadata) {
|
|
437
422
|
// Our current cell ordering scheme in sequences depends on being able to rebase over a change with conflicts.
|
|
438
423
|
// This means that we must rebase over a muted version of the conflicted changeset.
|
|
@@ -443,26 +428,17 @@ export class ModularChangeFamily {
|
|
|
443
428
|
const maxId = Math.max(change.maxId ?? -1, over.change.maxId ?? -1);
|
|
444
429
|
const idState = { maxId };
|
|
445
430
|
const genId = idAllocatorFromState(idState);
|
|
446
|
-
const affectedBaseFields = newTupleBTree();
|
|
447
|
-
const nodesToRebase = [];
|
|
448
|
-
const rebasedNodeToParent = brand(change.nodeToParent.clone());
|
|
449
|
-
const rebaseVersion = Math.max(change.rebaseVersion, over.change.rebaseVersion);
|
|
450
|
-
const rebasedRootNodes = rebaseRoots(change, over.change, affectedBaseFields, nodesToRebase, rebasedNodeToParent, rebaseVersion);
|
|
451
431
|
const crossFieldTable = {
|
|
452
|
-
|
|
453
|
-
entries: newDetachedEntryMap(),
|
|
432
|
+
...newCrossFieldTable(),
|
|
454
433
|
newChange: change,
|
|
455
434
|
baseChange: over.change,
|
|
456
435
|
baseFieldToContext: new Map(),
|
|
457
|
-
baseRoots: over.change.rootNodes,
|
|
458
|
-
rebasedRootNodes,
|
|
459
436
|
baseToRebasedNodeId: newTupleBTree(),
|
|
460
437
|
rebasedFields: new Set(),
|
|
461
|
-
rebasedNodeToParent,
|
|
462
|
-
|
|
463
|
-
movedDetaches: newChangeAtomIdRangeMap(),
|
|
438
|
+
rebasedNodeToParent: brand(change.nodeToParent.clone()),
|
|
439
|
+
rebasedCrossFieldKeys: change.crossFieldKeys.clone(),
|
|
464
440
|
nodeIdPairs: [],
|
|
465
|
-
affectedBaseFields,
|
|
441
|
+
affectedBaseFields: newTupleBTree(),
|
|
466
442
|
fieldsWithUnattachedChild: new Set(),
|
|
467
443
|
};
|
|
468
444
|
const getBaseRevisions = () => revisionInfoFromTaggedChange(over).map((info) => info.revision);
|
|
@@ -472,45 +448,40 @@ export class ModularChangeFamily {
|
|
|
472
448
|
getBaseRevisions,
|
|
473
449
|
};
|
|
474
450
|
const rebasedNodes = brand(change.nodeChanges.clone());
|
|
475
|
-
const rebasedFields = this.rebaseIntersectingFields(
|
|
476
|
-
this.
|
|
477
|
-
fixupRebasedDetachLocations(crossFieldTable);
|
|
451
|
+
const rebasedFields = this.rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId, rebaseMetadata);
|
|
452
|
+
this.rebaseInvalidatedElements(rebasedFields, rebasedNodes, crossFieldTable, rebaseMetadata, genId);
|
|
478
453
|
const constraintState = newConstraintState(change.constraintViolationCount ?? 0);
|
|
479
454
|
const revertConstraintState = newConstraintState(change.constraintViolationCountOnRevert ?? 0);
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
455
|
+
let noChangeConstraint = change.noChangeConstraint;
|
|
456
|
+
if (noChangeConstraint !== undefined && !noChangeConstraint.violated) {
|
|
457
|
+
noChangeConstraint = { violated: true };
|
|
458
|
+
constraintState.violationCount += 1;
|
|
459
|
+
}
|
|
460
|
+
this.updateConstraintsForFields(rebasedFields, NodeAttachState.Attached, NodeAttachState.Attached, constraintState, revertConstraintState, rebasedNodes);
|
|
483
461
|
const rebased = makeModularChangeset({
|
|
484
|
-
fieldChanges: this.pruneFieldMap(rebasedFields,
|
|
462
|
+
fieldChanges: this.pruneFieldMap(rebasedFields, rebasedNodes),
|
|
485
463
|
nodeChanges: rebasedNodes,
|
|
486
464
|
nodeToParent: crossFieldTable.rebasedNodeToParent,
|
|
487
|
-
rootNodes: this.pruneRoots(crossFieldTable.rebasedRootNodes, rebasedNodes, crossFieldTable.rebasedNodeToParent, change.nodeAliases, fieldsWithRootMoves, fieldToRootChanges),
|
|
488
|
-
// TODO: Do we need to include aliases for node changesets added during rebasing?
|
|
489
465
|
nodeAliases: change.nodeAliases,
|
|
490
|
-
crossFieldKeys:
|
|
466
|
+
crossFieldKeys: crossFieldTable.rebasedCrossFieldKeys,
|
|
491
467
|
maxId: idState.maxId,
|
|
492
468
|
revisions: change.revisions,
|
|
493
469
|
constraintViolationCount: constraintState.violationCount,
|
|
494
470
|
constraintViolationCountOnRevert: revertConstraintState.violationCount,
|
|
471
|
+
noChangeConstraint,
|
|
472
|
+
noChangeConstraintOnRevert: change.noChangeConstraintOnRevert,
|
|
495
473
|
builds: change.builds,
|
|
496
474
|
destroys: change.destroys,
|
|
497
475
|
refreshers: change.refreshers,
|
|
498
|
-
rebaseVersion,
|
|
499
476
|
});
|
|
500
|
-
// XXX: This is an expensive assert which should be disabled before merging.
|
|
501
|
-
this.validateChangeset(rebased);
|
|
502
477
|
return rebased;
|
|
503
478
|
}
|
|
504
479
|
// This performs a first pass on all fields which have both new and base changes.
|
|
505
480
|
// TODO: Can we also handle additional passes in this method?
|
|
506
|
-
rebaseIntersectingFields(
|
|
481
|
+
rebaseIntersectingFields(crossFieldTable, rebasedNodes, genId, metadata) {
|
|
507
482
|
const change = crossFieldTable.newChange;
|
|
508
483
|
const baseChange = crossFieldTable.baseChange;
|
|
509
484
|
const rebasedFields = this.rebaseFieldMap(change.fieldChanges, baseChange.fieldChanges, undefined, genId, crossFieldTable, metadata);
|
|
510
|
-
for (const [newChildChange, baseChildChange] of rootChanges) {
|
|
511
|
-
const rebasedNode = this.rebaseNodeChange(newChildChange, baseChildChange, genId, crossFieldTable, metadata);
|
|
512
|
-
setInChangeAtomIdMap(rebasedNodes, newChildChange, rebasedNode);
|
|
513
|
-
}
|
|
514
485
|
// This loop processes all fields which have both base and new changes.
|
|
515
486
|
// Note that the call to `rebaseNodeChange` can add entries to `crossFieldTable.nodeIdPairs`.
|
|
516
487
|
for (const [newId, baseId, _attachState] of crossFieldTable.nodeIdPairs) {
|
|
@@ -519,85 +490,87 @@ export class ModularChangeFamily {
|
|
|
519
490
|
}
|
|
520
491
|
return rebasedFields;
|
|
521
492
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
assert(
|
|
531
|
-
if (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return areEqualChangeAtomIds(normalizeNodeId(baseChild, crossFieldTable.baseChange.nodeAliases), baseNodeId)
|
|
535
|
-
? baseNodeId
|
|
536
|
-
: undefined;
|
|
537
|
-
};
|
|
538
|
-
const handler = getChangeHandler(this.fieldKinds, baseFieldChange.fieldKind);
|
|
539
|
-
const fieldChange = {
|
|
540
|
-
...baseFieldChange,
|
|
541
|
-
change: brand(handler.createEmpty()),
|
|
542
|
-
};
|
|
543
|
-
const rebasedNodeId = baseFieldId.nodeId !== undefined
|
|
544
|
-
? rebasedNodeIdFromBaseNodeId(crossFieldTable, baseFieldId.nodeId)
|
|
545
|
-
: undefined;
|
|
546
|
-
const fieldId = { nodeId: rebasedNodeId, field: baseFieldId.field };
|
|
547
|
-
const rebasedField = handler.rebaser.rebase(fieldChange.change, baseFieldChange.change, rebaseChild, genId, new RebaseNodeManagerI(crossFieldTable, fieldId), metadata, crossFieldTable.rebaseVersion);
|
|
548
|
-
const rebasedFieldChange = {
|
|
549
|
-
...baseFieldChange,
|
|
550
|
-
change: brand(rebasedField),
|
|
551
|
-
};
|
|
552
|
-
const context = {
|
|
553
|
-
newChange: fieldChange,
|
|
554
|
-
baseChange: baseFieldChange,
|
|
555
|
-
rebasedChange: rebasedFieldChange,
|
|
556
|
-
fieldId,
|
|
557
|
-
baseNodeIds: newTupleBTree(),
|
|
558
|
-
};
|
|
559
|
-
if (baseNodeId !== undefined) {
|
|
560
|
-
setInChangeAtomIdMap(context.baseNodeIds, baseNodeId, true);
|
|
561
|
-
}
|
|
562
|
-
crossFieldTable.baseFieldToContext.set(baseFieldChange, context);
|
|
563
|
-
crossFieldTable.rebasedFields.add(rebasedFieldChange);
|
|
564
|
-
this.attachRebasedField(rebasedFields, rebasedNodes, crossFieldTable, rebasedFieldChange, fieldId, genId, metadata);
|
|
565
|
-
}
|
|
566
|
-
rebaseInvalidatedFields(rebasedFields, rebasedNodes, crossFieldTable, rebaseMetadata, genId) {
|
|
567
|
-
while (crossFieldTable.affectedBaseFields.size > 0) {
|
|
568
|
-
const baseFields = crossFieldTable.affectedBaseFields.clone();
|
|
569
|
-
crossFieldTable.affectedBaseFields.clear();
|
|
570
|
-
for (const baseFieldIdKey of baseFields.keys()) {
|
|
571
|
-
const baseFieldId = normalizeFieldId(fieldIdFromFieldIdKey(baseFieldIdKey), crossFieldTable.baseChange.nodeAliases);
|
|
572
|
-
const baseField = fieldChangeFromId(crossFieldTable.baseChange, baseFieldId);
|
|
573
|
-
assert(baseField !== undefined, 0x9c2 /* Cross field key registered for empty field */);
|
|
574
|
-
const context = crossFieldTable.baseFieldToContext.get(baseField);
|
|
575
|
-
if (context === undefined) {
|
|
576
|
-
this.rebaseFieldWithoutNewChanges(baseField, baseFieldId, crossFieldTable, rebasedFields, rebasedNodes, genId, rebaseMetadata);
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
this.rebaseInvalidatedField(baseField, crossFieldTable, context, rebaseMetadata, genId);
|
|
580
|
-
}
|
|
493
|
+
// This processes fields which have no new changes but have been invalidated by another field.
|
|
494
|
+
rebaseFieldsWithoutNewChanges(rebasedFields, rebasedNodes, crossFieldTable, genId, metadata) {
|
|
495
|
+
const baseChange = crossFieldTable.baseChange;
|
|
496
|
+
for (const [revision, localId, fieldKey] of crossFieldTable.affectedBaseFields.keys()) {
|
|
497
|
+
const baseNodeId = localId === undefined
|
|
498
|
+
? undefined
|
|
499
|
+
: normalizeNodeId({ revision, localId }, baseChange.nodeAliases);
|
|
500
|
+
const baseFieldChange = fieldMapFromNodeId(baseChange.fieldChanges, baseChange.nodeChanges, baseNodeId).get(fieldKey);
|
|
501
|
+
assert(baseFieldChange !== undefined, 0x9c2 /* Cross field key registered for empty field */);
|
|
502
|
+
if (crossFieldTable.baseFieldToContext.has(baseFieldChange)) {
|
|
503
|
+
// This field has already been processed because there were changes to rebase.
|
|
504
|
+
continue;
|
|
581
505
|
}
|
|
506
|
+
// This field has no changes in the new changeset, otherwise it would have been added to
|
|
507
|
+
// `crossFieldTable.baseFieldToContext` when processing fields with both base and new changes.
|
|
508
|
+
const rebaseChild = (child, baseChild, stateChange) => {
|
|
509
|
+
assert(child === undefined, 0x9c3 /* There should be no new changes in this field */);
|
|
510
|
+
return undefined;
|
|
511
|
+
};
|
|
512
|
+
const handler = getChangeHandler(this.fieldKinds, baseFieldChange.fieldKind);
|
|
513
|
+
const fieldChange = {
|
|
514
|
+
...baseFieldChange,
|
|
515
|
+
change: 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, rebaseChild, genId, new RebaseManager(crossFieldTable, baseFieldChange, fieldId), metadata);
|
|
522
|
+
const rebasedFieldChange = {
|
|
523
|
+
...baseFieldChange,
|
|
524
|
+
change: 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);
|
|
582
536
|
}
|
|
583
537
|
}
|
|
584
|
-
|
|
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);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
rebaseInvalidatedField(baseField, crossFieldTable, rebaseMetadata, genId, allowInval = false) {
|
|
557
|
+
const context = crossFieldTable.baseFieldToContext.get(baseField);
|
|
558
|
+
assert(context !== undefined, 0x852 /* Every field should have a context */);
|
|
585
559
|
const { changeHandler, change1: fieldChangeset, change2: baseChangeset, } = this.normalizeFieldChanges(context.newChange, context.baseChange);
|
|
586
560
|
const rebaseChild = (curr, base) => {
|
|
587
561
|
if (curr !== undefined) {
|
|
588
562
|
return curr;
|
|
589
563
|
}
|
|
590
|
-
if (base !== undefined
|
|
591
|
-
|
|
564
|
+
if (base !== undefined) {
|
|
565
|
+
for (const id of context.baseNodeIds) {
|
|
566
|
+
if (areEqualChangeAtomIds(base, id)) {
|
|
567
|
+
return base;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
592
570
|
}
|
|
593
571
|
return undefined;
|
|
594
572
|
};
|
|
595
|
-
|
|
596
|
-
if (crossFieldTable.fieldsWithUnattachedChild.has(baseField)) {
|
|
597
|
-
crossFieldTable.fieldsWithUnattachedChild.delete(baseField);
|
|
598
|
-
allowInval = true;
|
|
599
|
-
}
|
|
600
|
-
context.rebasedChange.change = brand(changeHandler.rebaser.rebase(fieldChangeset, baseChangeset, rebaseChild, genId, new RebaseNodeManagerI(crossFieldTable, context.fieldId, allowInval), rebaseMetadata, crossFieldTable.rebaseVersion));
|
|
573
|
+
context.rebasedChange.change = brand(changeHandler.rebaser.rebase(fieldChangeset, baseChangeset, rebaseChild, genId, new RebaseManager(crossFieldTable, baseField, context.fieldId, allowInval), rebaseMetadata));
|
|
601
574
|
}
|
|
602
575
|
attachRebasedField(rebasedFields, rebasedNodes, table, rebasedField, { nodeId, field: fieldKey }, idAllocator, metadata) {
|
|
603
576
|
if (nodeId === undefined) {
|
|
@@ -606,14 +579,12 @@ export class ModularChangeFamily {
|
|
|
606
579
|
}
|
|
607
580
|
const rebasedNode = getFromChangeAtomIdMap(rebasedNodes, nodeId);
|
|
608
581
|
if (rebasedNode !== undefined) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
if (updatedRebasedNode.fieldChanges === undefined) {
|
|
612
|
-
updatedRebasedNode.fieldChanges = new Map([[fieldKey, rebasedField]]);
|
|
582
|
+
if (rebasedNode.fieldChanges === undefined) {
|
|
583
|
+
rebasedNode.fieldChanges = new Map([[fieldKey, rebasedField]]);
|
|
613
584
|
return;
|
|
614
585
|
}
|
|
615
|
-
assert(!
|
|
616
|
-
|
|
586
|
+
assert(!rebasedNode.fieldChanges.has(fieldKey), 0x9c4 /* Expected an empty field */);
|
|
587
|
+
rebasedNode.fieldChanges.set(fieldKey, rebasedField);
|
|
617
588
|
return;
|
|
618
589
|
}
|
|
619
590
|
const newNode = {
|
|
@@ -621,51 +592,39 @@ export class ModularChangeFamily {
|
|
|
621
592
|
};
|
|
622
593
|
setInChangeAtomIdMap(rebasedNodes, nodeId, newNode);
|
|
623
594
|
setInChangeAtomIdMap(table.baseToRebasedNodeId, nodeId, nodeId);
|
|
624
|
-
const
|
|
625
|
-
this.attachRebasedNode(rebasedFields, rebasedNodes, table, nodeId,
|
|
626
|
-
}
|
|
627
|
-
attachRebasedNode(rebasedFields, rebasedNodes, table, baseNodeId,
|
|
628
|
-
|
|
629
|
-
const renamedRoot = firstAttachIdFromDetachId(table.baseChange.rootNodes, parentBase.root, 1).value;
|
|
630
|
-
const attachField = table.baseChange.crossFieldKeys.getFirst({ ...renamedRoot, target: CrossFieldTarget.Destination }, 1).value;
|
|
631
|
-
if (attachField !== undefined) {
|
|
632
|
-
// The base change inserts this node into `attachField`, so the rebased change should represent this node there.
|
|
633
|
-
const normalizedAttachField = normalizeFieldId(attachField, table.baseChange.nodeAliases);
|
|
634
|
-
const entry = table.entries.getFirst(renamedRoot, 1).value ?? {};
|
|
635
|
-
table.entries.set(renamedRoot, 1, { ...entry, nodeChange: baseNodeId });
|
|
636
|
-
table.affectedBaseFields.set(fieldIdKeyFromFieldId(normalizedAttachField), true);
|
|
637
|
-
this.attachRebasedNode(rebasedFields, rebasedNodes, table, baseNodeId, { field: normalizedAttachField }, idAllocator, metadata);
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
const baseDetachLocation = table.baseChange.rootNodes.detachLocations.getFirst(parentBase.root, 1).value;
|
|
641
|
-
assignRootChange(table.rebasedRootNodes, table.rebasedNodeToParent, renamedRoot, baseNodeId, baseDetachLocation, table.rebaseVersion);
|
|
642
|
-
// We need to make sure the rebased changeset includes the detach location,
|
|
643
|
-
// so we add that field to `affectedBaseFields` unless it's already been processed.
|
|
644
|
-
if (baseDetachLocation !== undefined &&
|
|
645
|
-
!table.baseFieldToContext.has(fieldChangeFromId(table.baseChange, baseDetachLocation))) {
|
|
646
|
-
table.affectedBaseFields.set(fieldIdKeyFromFieldId(baseDetachLocation), true);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
const parentFieldIdBase = parentBase.field;
|
|
652
|
-
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);
|
|
653
600
|
const rebasedFieldId = rebasedFieldIdFromBaseId(table, parentFieldIdBase);
|
|
654
|
-
setInChangeAtomIdMap(table.rebasedNodeToParent, baseNodeId,
|
|
601
|
+
setInChangeAtomIdMap(table.rebasedNodeToParent, baseNodeId, rebasedFieldId);
|
|
655
602
|
const context = table.baseFieldToContext.get(baseFieldChange);
|
|
656
603
|
if (context !== undefined) {
|
|
657
604
|
// We've already processed this field.
|
|
658
|
-
// The new child node will be attached in
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
// This is done by checking whether `context.baseNodeIds` already contained `baseNodeId`.
|
|
662
|
-
if (setInChangeAtomIdMap(context.baseNodeIds, baseNodeId, true)) {
|
|
663
|
-
table.fieldsWithUnattachedChild.add(baseFieldChange);
|
|
664
|
-
table.affectedBaseFields.set(fieldIdKeyFromFieldId(parentFieldIdBase), true);
|
|
665
|
-
}
|
|
605
|
+
// The new child node will be attached in rebaseFieldsWithUnattachedChild.
|
|
606
|
+
context.baseNodeIds.push(baseNodeId);
|
|
607
|
+
table.fieldsWithUnattachedChild.add(baseFieldChange);
|
|
666
608
|
return;
|
|
667
609
|
}
|
|
668
|
-
|
|
610
|
+
const handler = getChangeHandler(this.fieldKinds, baseFieldChange.fieldKind);
|
|
611
|
+
const fieldChange = {
|
|
612
|
+
...baseFieldChange,
|
|
613
|
+
change: brand(handler.createEmpty()),
|
|
614
|
+
};
|
|
615
|
+
const rebasedChangeset = handler.rebaser.rebase(handler.createEmpty(), baseFieldChange.change, (_idNew, idBase) => idBase !== undefined && areEqualChangeAtomIds(idBase, baseNodeId)
|
|
616
|
+
? baseNodeId
|
|
617
|
+
: undefined, idAllocator, new RebaseManager(table, baseFieldChange, rebasedFieldId), metadata);
|
|
618
|
+
const rebasedField = { ...baseFieldChange, change: 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);
|
|
669
628
|
}
|
|
670
629
|
rebaseFieldMap(change, over, parentId, genId, crossFieldTable, revisionMetadata) {
|
|
671
630
|
const rebasedFields = new Map();
|
|
@@ -683,8 +642,8 @@ export class ModularChangeFamily {
|
|
|
683
642
|
continue;
|
|
684
643
|
}
|
|
685
644
|
const { fieldKind, changeHandler, change1: fieldChangeset, change2: baseChangeset, } = this.normalizeFieldChanges(fieldChange, baseChange);
|
|
686
|
-
const manager = new
|
|
687
|
-
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);
|
|
688
647
|
const rebasedFieldChange = {
|
|
689
648
|
fieldKind,
|
|
690
649
|
change: brand(rebasedField),
|
|
@@ -695,15 +654,15 @@ export class ModularChangeFamily {
|
|
|
695
654
|
newChange: fieldChange,
|
|
696
655
|
rebasedChange: rebasedFieldChange,
|
|
697
656
|
fieldId,
|
|
698
|
-
baseNodeIds:
|
|
657
|
+
baseNodeIds: [],
|
|
699
658
|
});
|
|
700
659
|
crossFieldTable.rebasedFields.add(rebasedFieldChange);
|
|
701
660
|
}
|
|
702
661
|
return rebasedFields;
|
|
703
662
|
}
|
|
704
663
|
rebaseNodeChange(newId, baseId, genId, crossFieldTable, revisionMetadata) {
|
|
705
|
-
const change = nodeChangeFromId(crossFieldTable.newChange.nodeChanges,
|
|
706
|
-
const over = nodeChangeFromId(crossFieldTable.baseChange.nodeChanges,
|
|
664
|
+
const change = nodeChangeFromId(crossFieldTable.newChange.nodeChanges, newId);
|
|
665
|
+
const over = nodeChangeFromId(crossFieldTable.baseChange.nodeChanges, baseId);
|
|
707
666
|
const baseMap = over?.fieldChanges ?? new Map();
|
|
708
667
|
const fieldChanges = change.fieldChanges !== undefined && over.fieldChanges !== undefined
|
|
709
668
|
? this.rebaseFieldMap(change?.fieldChanges ?? new Map(), baseMap, newId, genId, crossFieldTable, revisionMetadata)
|
|
@@ -721,37 +680,28 @@ export class ModularChangeFamily {
|
|
|
721
680
|
setInChangeAtomIdMap(crossFieldTable.baseToRebasedNodeId, baseId, newId);
|
|
722
681
|
return rebasedChange;
|
|
723
682
|
}
|
|
724
|
-
updateConstraints(rebasedFields, rebasedNodes, rebasedRoots, constraintState, revertConstraintState) {
|
|
725
|
-
this.updateConstraintsForFields(rebasedFields, NodeAttachState.Attached, NodeAttachState.Attached, constraintState, revertConstraintState, rebasedNodes);
|
|
726
|
-
for (const [_detachId, nodeId] of rebasedRoots.nodeChanges.entries()) {
|
|
727
|
-
// XXX: This is incorrect if the rebased changeset attaches the node.
|
|
728
|
-
// Efficiently computing whether the changeset attaches the node would require maintaining a mapping from node ID to attach ID.
|
|
729
|
-
const detachedInOutput = true;
|
|
730
|
-
this.updateConstraintsForNode(nodeId, NodeAttachState.Detached, detachedInOutput ? NodeAttachState.Detached : NodeAttachState.Attached, rebasedNodes, constraintState, revertConstraintState);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
683
|
updateConstraintsForFields(fields, parentInputAttachState, parentOutputAttachState, constraintState, revertConstraintState, nodes) {
|
|
734
684
|
for (const field of fields.values()) {
|
|
735
685
|
const handler = getChangeHandler(this.fieldKinds, field.fieldKind);
|
|
736
|
-
for (const [nodeId] of handler.getNestedChanges(field.change)) {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
686
|
+
for (const [nodeId, inputIndex, outputIndex] of handler.getNestedChanges(field.change)) {
|
|
687
|
+
const isInputDetached = inputIndex === undefined;
|
|
688
|
+
const inputAttachState = parentInputAttachState === NodeAttachState.Detached || isInputDetached
|
|
689
|
+
? NodeAttachState.Detached
|
|
690
|
+
: NodeAttachState.Attached;
|
|
691
|
+
const isOutputDetached = outputIndex === undefined;
|
|
740
692
|
const outputAttachState = parentOutputAttachState === NodeAttachState.Detached || isOutputDetached
|
|
741
693
|
? NodeAttachState.Detached
|
|
742
694
|
: NodeAttachState.Attached;
|
|
743
|
-
this.updateConstraintsForNode(nodeId,
|
|
695
|
+
this.updateConstraintsForNode(nodeId, inputAttachState, outputAttachState, nodes, constraintState, revertConstraintState);
|
|
744
696
|
}
|
|
745
697
|
}
|
|
746
698
|
}
|
|
747
699
|
updateConstraintsForNode(nodeId, inputAttachState, outputAttachState, nodes, constraintState, revertConstraintState) {
|
|
748
|
-
const node =
|
|
749
|
-
const updatedNode = { ...node };
|
|
750
|
-
setInChangeAtomIdMap(nodes, nodeId, updatedNode);
|
|
700
|
+
const node = nodes.get([nodeId.revision, nodeId.localId]) ?? fail(0xb24 /* Unknown node ID */);
|
|
751
701
|
if (node.nodeExistsConstraint !== undefined) {
|
|
752
702
|
const isNowViolated = inputAttachState === NodeAttachState.Detached;
|
|
753
703
|
if (node.nodeExistsConstraint.violated !== isNowViolated) {
|
|
754
|
-
|
|
704
|
+
node.nodeExistsConstraint = {
|
|
755
705
|
...node.nodeExistsConstraint,
|
|
756
706
|
violated: isNowViolated,
|
|
757
707
|
};
|
|
@@ -761,7 +711,7 @@ export class ModularChangeFamily {
|
|
|
761
711
|
if (node.nodeExistsConstraintOnRevert !== undefined) {
|
|
762
712
|
const isNowViolated = outputAttachState === NodeAttachState.Detached;
|
|
763
713
|
if (node.nodeExistsConstraintOnRevert.violated !== isNowViolated) {
|
|
764
|
-
|
|
714
|
+
node.nodeExistsConstraintOnRevert = {
|
|
765
715
|
...node.nodeExistsConstraintOnRevert,
|
|
766
716
|
violated: isNowViolated,
|
|
767
717
|
};
|
|
@@ -772,134 +722,87 @@ export class ModularChangeFamily {
|
|
|
772
722
|
this.updateConstraintsForFields(node.fieldChanges, inputAttachState, outputAttachState, constraintState, revertConstraintState, nodes);
|
|
773
723
|
}
|
|
774
724
|
}
|
|
775
|
-
pruneFieldMap(changeset,
|
|
725
|
+
pruneFieldMap(changeset, nodeMap) {
|
|
776
726
|
if (changeset === undefined) {
|
|
777
727
|
return undefined;
|
|
778
728
|
}
|
|
779
729
|
const prunedChangeset = new Map();
|
|
780
730
|
for (const [field, fieldChange] of changeset) {
|
|
781
731
|
const handler = getChangeHandler(this.fieldKinds, fieldChange.fieldKind);
|
|
782
|
-
const prunedFieldChangeset = handler.rebaser.prune(fieldChange.change, (nodeId) => this.pruneNodeChange(nodeId, nodeMap
|
|
783
|
-
|
|
784
|
-
const fieldIdKey = fieldIdKeyFromFieldId(fieldId);
|
|
785
|
-
const rootsWithChanges = fieldsToRootChanges.get(fieldIdKey) ?? [];
|
|
786
|
-
let hasRootWithNodeChange = false;
|
|
787
|
-
for (const rootId of rootsWithChanges) {
|
|
788
|
-
const nodeId = getFromChangeAtomIdMap(roots.nodeChanges, rootId) ?? fail("No root change found");
|
|
789
|
-
const isRootChangeEmpty = this.pruneNodeChange(nodeId, nodeMap, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges) === undefined;
|
|
790
|
-
if (isRootChangeEmpty) {
|
|
791
|
-
roots.nodeChanges.delete([rootId.revision, rootId.localId]);
|
|
792
|
-
tryRemoveDetachLocation(roots, rootId, 1);
|
|
793
|
-
}
|
|
794
|
-
else {
|
|
795
|
-
hasRootWithNodeChange = true;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
const hasRootChanges = hasRootWithNodeChange || fieldsWithRootMoves.get(fieldIdKey) === true;
|
|
799
|
-
if (!handler.isEmpty(prunedFieldChangeset) || hasRootChanges) {
|
|
732
|
+
const prunedFieldChangeset = handler.rebaser.prune(fieldChange.change, (nodeId) => this.pruneNodeChange(nodeId, nodeMap));
|
|
733
|
+
if (!handler.isEmpty(prunedFieldChangeset)) {
|
|
800
734
|
prunedChangeset.set(field, { ...fieldChange, change: brand(prunedFieldChangeset) });
|
|
801
735
|
}
|
|
802
736
|
}
|
|
803
737
|
return prunedChangeset.size > 0 ? prunedChangeset : undefined;
|
|
804
738
|
}
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
// If the root has a detach location it should be pruned by recursion when pruning the field it was detached from.
|
|
811
|
-
const prunedId = hasDetachLocation
|
|
812
|
-
? nodeId
|
|
813
|
-
: this.pruneNodeChange(nodeId, nodeMap, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges);
|
|
814
|
-
if (prunedId !== undefined) {
|
|
815
|
-
pruned.nodeChanges.set(rootIdKey, prunedId);
|
|
816
|
-
}
|
|
817
|
-
tryRemoveDetachLocation(pruned, rootId, 1);
|
|
818
|
-
}
|
|
819
|
-
return pruned;
|
|
820
|
-
}
|
|
821
|
-
pruneNodeChange(nodeId, nodes, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges) {
|
|
822
|
-
const changeset = nodeChangeFromId(nodes, aliases, nodeId);
|
|
823
|
-
const prunedFields = changeset.fieldChanges !== undefined
|
|
824
|
-
? this.pruneFieldMap(changeset.fieldChanges, nodeId, nodes, nodeToParent, aliases, roots, fieldsWithRootMoves, fieldsToRootChanges)
|
|
825
|
-
: undefined;
|
|
739
|
+
pruneNodeChange(nodeId, nodeMap) {
|
|
740
|
+
const changeset = nodeChangeFromId(nodeMap, nodeId);
|
|
741
|
+
const prunedFields = changeset.fieldChanges === undefined
|
|
742
|
+
? undefined
|
|
743
|
+
: this.pruneFieldMap(changeset.fieldChanges, nodeMap);
|
|
826
744
|
const prunedChange = { ...changeset, fieldChanges: prunedFields };
|
|
827
745
|
if (prunedChange.fieldChanges === undefined) {
|
|
828
746
|
delete prunedChange.fieldChanges;
|
|
829
747
|
}
|
|
830
748
|
if (isEmptyNodeChangeset(prunedChange)) {
|
|
831
|
-
|
|
832
|
-
// TODO: Shouldn't we also delete all aliases associated with this node?
|
|
833
|
-
nodes.delete(nodeIdKey);
|
|
834
|
-
nodeToParent.delete(nodeIdKey);
|
|
749
|
+
nodeMap.delete([nodeId.revision, nodeId.localId]);
|
|
835
750
|
return undefined;
|
|
836
751
|
}
|
|
837
752
|
else {
|
|
838
|
-
setInChangeAtomIdMap(
|
|
753
|
+
setInChangeAtomIdMap(nodeMap, nodeId, prunedChange);
|
|
839
754
|
return nodeId;
|
|
840
755
|
}
|
|
841
756
|
}
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const updatedFields = this.replaceFieldMapRevisions(change.fieldChanges, oldRevisions, newRevision);
|
|
847
|
-
const updatedNodes = newTupleBTree();
|
|
848
|
-
for (const [[revision, id], nodeChangeset] of change.nodeChanges.entries()) {
|
|
849
|
-
updatedNodes.set([replaceRevision(revision, oldRevisions, newRevision), id], this.replaceNodeChangesetRevisions(nodeChangeset, oldRevisions, newRevision));
|
|
850
|
-
}
|
|
851
|
-
const updatedNodeToParent = newTupleBTree();
|
|
852
|
-
for (const [[revision, id], location] of change.nodeToParent.entries()) {
|
|
853
|
-
updatedNodeToParent.set([replaceRevision(revision, oldRevisions, newRevision), id], replaceNodeLocationRevision(normalizeNodeLocation(location, change.nodeAliases), oldRevisions, newRevision));
|
|
757
|
+
getRevisions(change) {
|
|
758
|
+
const aggregated = new Set();
|
|
759
|
+
for (const revInfo of change.revisions ?? [{ revision: undefined }]) {
|
|
760
|
+
aggregated.add(revInfo.revision);
|
|
854
761
|
}
|
|
762
|
+
return aggregated;
|
|
763
|
+
}
|
|
764
|
+
changeRevision(change, replacer) {
|
|
765
|
+
const updatedFields = this.replaceFieldMapRevisions(change.fieldChanges, replacer);
|
|
766
|
+
const updatedNodes = replaceIdMapRevisions(change.nodeChanges, replacer, (nodeChangeset) => this.replaceNodeChangesetRevisions(nodeChangeset, replacer));
|
|
767
|
+
const updatedNodeToParent = replaceIdMapRevisions(change.nodeToParent, replacer, (fieldId) => replaceFieldIdRevision(normalizeFieldId(fieldId, change.nodeAliases), replacer));
|
|
855
768
|
const updated = {
|
|
856
769
|
...change,
|
|
857
770
|
fieldChanges: updatedFields,
|
|
858
771
|
nodeChanges: updatedNodes,
|
|
859
772
|
nodeToParent: updatedNodeToParent,
|
|
860
|
-
rootNodes: replaceRootTableRevision(change.rootNodes, oldRevisions, newRevision, change.nodeAliases),
|
|
861
773
|
// We've updated all references to old node IDs, so we no longer need an alias table.
|
|
862
774
|
nodeAliases: newTupleBTree(),
|
|
863
|
-
crossFieldKeys: change.crossFieldKeys
|
|
775
|
+
crossFieldKeys: replaceCrossFieldKeyTableRevisions(change.crossFieldKeys, replacer, change.nodeAliases),
|
|
864
776
|
};
|
|
865
777
|
if (change.builds !== undefined) {
|
|
866
|
-
updated.builds = replaceIdMapRevisions(change.builds,
|
|
778
|
+
updated.builds = replaceIdMapRevisions(change.builds, replacer);
|
|
867
779
|
}
|
|
868
780
|
if (change.destroys !== undefined) {
|
|
869
|
-
updated.destroys = replaceIdMapRevisions(change.destroys,
|
|
781
|
+
updated.destroys = replaceIdMapRevisions(change.destroys, replacer);
|
|
870
782
|
}
|
|
871
783
|
if (change.refreshers !== undefined) {
|
|
872
|
-
updated.refreshers = replaceIdMapRevisions(change.refreshers,
|
|
873
|
-
}
|
|
874
|
-
if (newRevision !== undefined) {
|
|
875
|
-
const revInfo = { revision: newRevision };
|
|
876
|
-
if (rollbackOf !== undefined) {
|
|
877
|
-
revInfo.rollbackOf = rollbackOf;
|
|
878
|
-
}
|
|
879
|
-
updated.revisions = [revInfo];
|
|
880
|
-
}
|
|
881
|
-
else {
|
|
882
|
-
delete updated.revisions;
|
|
784
|
+
updated.refreshers = replaceIdMapRevisions(change.refreshers, replacer);
|
|
883
785
|
}
|
|
786
|
+
updated.revisions = [{ revision: replacer.updatedRevision }];
|
|
884
787
|
return updated;
|
|
885
788
|
}
|
|
886
|
-
replaceNodeChangesetRevisions(nodeChangeset,
|
|
789
|
+
replaceNodeChangesetRevisions(nodeChangeset, replacer) {
|
|
887
790
|
const updated = { ...nodeChangeset };
|
|
888
791
|
if (nodeChangeset.fieldChanges !== undefined) {
|
|
889
|
-
updated.fieldChanges = this.replaceFieldMapRevisions(nodeChangeset.fieldChanges,
|
|
792
|
+
updated.fieldChanges = this.replaceFieldMapRevisions(nodeChangeset.fieldChanges, replacer);
|
|
890
793
|
}
|
|
891
794
|
return updated;
|
|
892
795
|
}
|
|
893
|
-
replaceFieldMapRevisions(fields,
|
|
796
|
+
replaceFieldMapRevisions(fields, replacer) {
|
|
894
797
|
const updatedFields = new Map();
|
|
895
798
|
for (const [field, fieldChange] of fields) {
|
|
896
|
-
const updatedFieldChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.replaceRevisions(fieldChange.change,
|
|
799
|
+
const updatedFieldChange = getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.replaceRevisions(fieldChange.change, replacer);
|
|
897
800
|
updatedFields.set(field, { ...fieldChange, change: brand(updatedFieldChange) });
|
|
898
801
|
}
|
|
899
802
|
return updatedFields;
|
|
900
803
|
}
|
|
901
804
|
makeCrossFieldKeyTable(fields, nodes) {
|
|
902
|
-
const keys =
|
|
805
|
+
const keys = newCrossFieldKeyTable();
|
|
903
806
|
this.populateCrossFieldKeyTableForFieldMap(keys, fields, undefined);
|
|
904
807
|
nodes.forEachPair(([revision, localId], node) => {
|
|
905
808
|
if (node.fieldChanges !== undefined) {
|
|
@@ -919,61 +822,48 @@ export class ModularChangeFamily {
|
|
|
919
822
|
}
|
|
920
823
|
}
|
|
921
824
|
}
|
|
922
|
-
buildEditor(changeReceiver) {
|
|
923
|
-
return new ModularEditBuilder(this, this.fieldKinds, changeReceiver);
|
|
825
|
+
buildEditor(mintRevisionTag, changeReceiver) {
|
|
826
|
+
return new ModularEditBuilder(this, this.fieldKinds, changeReceiver, this.codecOptions);
|
|
924
827
|
}
|
|
925
828
|
createEmptyFieldChange(fieldKind) {
|
|
926
829
|
const emptyChange = getChangeHandler(this.fieldKinds, fieldKind).createEmpty();
|
|
927
830
|
return { fieldKind, change: brand(emptyChange) };
|
|
928
831
|
}
|
|
929
832
|
validateChangeset(change) {
|
|
930
|
-
|
|
931
|
-
const unreachableCFKs = change.crossFieldKeys.clone();
|
|
932
|
-
this.validateFieldChanges(change, change.fieldChanges, undefined, unreachableNodes, unreachableCFKs);
|
|
833
|
+
let numNodes = this.validateFieldChanges(change, change.fieldChanges, undefined);
|
|
933
834
|
for (const [[revision, localId], node] of change.nodeChanges.entries()) {
|
|
934
835
|
if (node.fieldChanges === undefined) {
|
|
935
836
|
continue;
|
|
936
837
|
}
|
|
937
|
-
const nodeId =
|
|
938
|
-
this.validateFieldChanges(change, node.fieldChanges, nodeId
|
|
939
|
-
|
|
940
|
-
for (const [detachIdKey, nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
941
|
-
const detachId = { revision: detachIdKey[0], localId: detachIdKey[1] };
|
|
942
|
-
const location = getNodeParent(change, nodeId);
|
|
943
|
-
assert(areEqualChangeAtomIdOpts(location.root, detachId), "Inconsistent node location");
|
|
944
|
-
const normalizedNodeId = normalizeNodeId(nodeId, change.nodeAliases);
|
|
945
|
-
unreachableNodes.delete([normalizedNodeId.revision, normalizedNodeId.localId]);
|
|
946
|
-
const fieldChanges = nodeChangeFromId(change.nodeChanges, change.nodeAliases, nodeId).fieldChanges;
|
|
947
|
-
if (fieldChanges !== undefined) {
|
|
948
|
-
this.validateFieldChanges(change, fieldChanges, normalizedNodeId, unreachableNodes, unreachableCFKs);
|
|
949
|
-
}
|
|
838
|
+
const nodeId = { revision, localId };
|
|
839
|
+
const numChildren = this.validateFieldChanges(change, node.fieldChanges, nodeId);
|
|
840
|
+
numNodes += numChildren;
|
|
950
841
|
}
|
|
951
|
-
assert(
|
|
952
|
-
assert(unreachableCFKs.entries().length === 0, "Unreachable cross-field keys found");
|
|
842
|
+
assert(numNodes === change.nodeChanges.size, 0xa4d /* Node table contains unparented nodes */);
|
|
953
843
|
}
|
|
954
844
|
/**
|
|
955
|
-
* Asserts that each
|
|
956
|
-
*
|
|
845
|
+
* Asserts that each child and cross field key in each field has a correct entry in
|
|
846
|
+
* `nodeToParent` or `crossFieldKeyTable`.
|
|
957
847
|
* @returns the number of children found.
|
|
958
848
|
*/
|
|
959
|
-
validateFieldChanges(change, fieldChanges, nodeParent
|
|
849
|
+
validateFieldChanges(change, fieldChanges, nodeParent) {
|
|
850
|
+
let numChildren = 0;
|
|
960
851
|
for (const [field, fieldChange] of fieldChanges.entries()) {
|
|
961
852
|
const fieldId = { nodeId: nodeParent, field };
|
|
962
853
|
const handler = getChangeHandler(this.fieldKinds, fieldChange.fieldKind);
|
|
963
854
|
for (const [child, _index] of handler.getNestedChanges(fieldChange.change)) {
|
|
964
|
-
const parentFieldId =
|
|
965
|
-
assert(
|
|
966
|
-
|
|
855
|
+
const parentFieldId = getParentFieldId(change, child);
|
|
856
|
+
assert(areEqualFieldIds(parentFieldId, fieldId), 0xa4e /* Inconsistent node parentage */);
|
|
857
|
+
numChildren += 1;
|
|
967
858
|
}
|
|
968
859
|
for (const keyRange of handler.getCrossFieldKeys(fieldChange.change)) {
|
|
969
860
|
const fields = getFieldsForCrossFieldKey(change, keyRange.key, keyRange.count);
|
|
970
|
-
assert(fields.length
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
unreachableCFKs.delete(keyRange.key, keyRange.count);
|
|
861
|
+
assert(fields.length === 1 &&
|
|
862
|
+
fields[0] !== undefined &&
|
|
863
|
+
areEqualFieldIds(fields[0], fieldId), 0xa4f /* Inconsistent cross field keys */);
|
|
975
864
|
}
|
|
976
865
|
}
|
|
866
|
+
return numChildren;
|
|
977
867
|
}
|
|
978
868
|
getEffectiveChange(change) {
|
|
979
869
|
if (hasConflicts(change)) {
|
|
@@ -987,8 +877,7 @@ export class ModularChangeFamily {
|
|
|
987
877
|
muteChange(change) {
|
|
988
878
|
const muted = {
|
|
989
879
|
...change,
|
|
990
|
-
|
|
991
|
-
crossFieldKeys: newCrossFieldRangeTable(),
|
|
880
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
992
881
|
fieldChanges: this.muteFieldChanges(change.fieldChanges),
|
|
993
882
|
nodeChanges: brand(change.nodeChanges.mapValues((v) => this.muteNodeChange(v))),
|
|
994
883
|
};
|
|
@@ -1015,20 +904,29 @@ export class ModularChangeFamily {
|
|
|
1015
904
|
}
|
|
1016
905
|
}
|
|
1017
906
|
ModularChangeFamily.emptyChange = makeModularChangeset();
|
|
1018
|
-
function
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
907
|
+
function replaceCrossFieldKeyTableRevisions(table, replacer, nodeAliases) {
|
|
908
|
+
const updated = newCrossFieldKeyTable();
|
|
909
|
+
for (const entry of table.entries()) {
|
|
910
|
+
const key = entry.start;
|
|
911
|
+
const updatedKey = replacer.getUpdatedAtomId(key);
|
|
912
|
+
const field = entry.value;
|
|
913
|
+
const normalizedFieldId = normalizeFieldId(field, nodeAliases);
|
|
914
|
+
const updatedNodeId = normalizedFieldId.nodeId === undefined
|
|
915
|
+
? undefined
|
|
916
|
+
: replacer.getUpdatedAtomId(normalizedFieldId.nodeId);
|
|
917
|
+
const updatedValue = {
|
|
918
|
+
...normalizedFieldId,
|
|
919
|
+
nodeId: updatedNodeId,
|
|
920
|
+
};
|
|
921
|
+
updated.set(updatedKey, entry.length, updatedValue);
|
|
922
|
+
}
|
|
923
|
+
return updated;
|
|
1027
924
|
}
|
|
1028
|
-
function replaceIdMapRevisions(map,
|
|
925
|
+
function replaceIdMapRevisions(map, replacer, valueMapper = (value) => value) {
|
|
1029
926
|
const updated = newTupleBTree();
|
|
1030
|
-
for (const [[revision,
|
|
1031
|
-
|
|
927
|
+
for (const [[revision, localId], value] of map.entries()) {
|
|
928
|
+
const newAtom = replacer.getUpdatedAtomId({ revision, localId });
|
|
929
|
+
updated.set([newAtom.revision, newAtom.localId], valueMapper(value));
|
|
1032
930
|
}
|
|
1033
931
|
return updated;
|
|
1034
932
|
}
|
|
@@ -1066,19 +964,6 @@ function composeBuildsDestroysAndRefreshers(change1, change2) {
|
|
|
1066
964
|
}
|
|
1067
965
|
}
|
|
1068
966
|
}
|
|
1069
|
-
// 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.
|
|
1070
|
-
if (change1.builds !== undefined && change2.refreshers !== undefined) {
|
|
1071
|
-
for (const [key, chunk] of change2.refreshers.entries()) {
|
|
1072
|
-
assert(chunk.topLevelLength === 1, "Expected refresher chunk to have length 1");
|
|
1073
|
-
const match = change1.builds.getPairOrNextLower(key);
|
|
1074
|
-
if (match !== undefined) {
|
|
1075
|
-
const [buildKey, buildChunk] = match;
|
|
1076
|
-
if (buildKey[0] === key[0] && buildKey[1] + buildChunk.topLevelLength > key[1]) {
|
|
1077
|
-
allRefreshers.delete(key);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
967
|
return { allBuilds, allDestroys, allRefreshers };
|
|
1083
968
|
}
|
|
1084
969
|
function invertBuilds(builds) {
|
|
@@ -1103,51 +988,18 @@ function invertBuilds(builds) {
|
|
|
1103
988
|
* @param fieldKinds - The field kinds to delegate to.
|
|
1104
989
|
*/
|
|
1105
990
|
export function* relevantRemovedRoots(change, fieldKinds) {
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
for (const [
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
yield makeDetachedNodeId(detachId.revision, detachId.localId);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
export function* getBuildIds(change) {
|
|
1120
|
-
if (change.builds !== undefined) {
|
|
1121
|
-
for (const [[revision, localId]] of change.builds.entries()) {
|
|
1122
|
-
yield makeDetachedNodeId(revision, localId);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
function addAttachesToSet(change, rootIds) {
|
|
1127
|
-
// This includes each attach which does not have a corresponding detach.
|
|
1128
|
-
for (const entry of change.crossFieldKeys.entries()) {
|
|
1129
|
-
if (entry.start.target !== CrossFieldTarget.Destination) {
|
|
1130
|
-
continue;
|
|
1131
|
-
}
|
|
1132
|
-
for (const detachIdEntry of change.rootNodes.newToOldId.getAll2(entry.start, entry.length)) {
|
|
1133
|
-
const detachId = detachIdEntry.value ?? offsetChangeAtomId(entry.start, detachIdEntry.offset);
|
|
1134
|
-
for (const detachEntry of change.crossFieldKeys.getAll2({ ...detachId, target: CrossFieldTarget.Source }, detachIdEntry.length)) {
|
|
1135
|
-
if (detachEntry.value === undefined) {
|
|
1136
|
-
rootIds.set(offsetChangeAtomId(detachId, detachEntry.offset), detachEntry.length, true);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
function addRenamesToSet(change, rootIds) {
|
|
1143
|
-
for (const renameEntry of change.rootNodes.oldToNewId.entries()) {
|
|
1144
|
-
for (const detachEntry of change.crossFieldKeys.getAll2({ ...renameEntry.start, target: CrossFieldTarget.Source }, renameEntry.length)) {
|
|
1145
|
-
// We only want to include renames of nodes which are detached in the input context of the changeset.
|
|
1146
|
-
// So if there is a detach for the node, the rename is not relevant.
|
|
1147
|
-
if (detachEntry.value === undefined) {
|
|
1148
|
-
rootIds.set(renameEntry.start, renameEntry.length, true);
|
|
991
|
+
yield* relevantRemovedRootsFromFields(change.fieldChanges, change.nodeChanges, fieldKinds);
|
|
992
|
+
}
|
|
993
|
+
function* relevantRemovedRootsFromFields(change, nodeChanges, fieldKinds) {
|
|
994
|
+
for (const [_, fieldChange] of change) {
|
|
995
|
+
const handler = getChangeHandler(fieldKinds, fieldChange.fieldKind);
|
|
996
|
+
const delegate = function* (node) {
|
|
997
|
+
const nodeChangeset = nodeChangeFromId(nodeChanges, node);
|
|
998
|
+
if (nodeChangeset.fieldChanges !== undefined) {
|
|
999
|
+
yield* relevantRemovedRootsFromFields(nodeChangeset.fieldChanges, nodeChanges, fieldKinds);
|
|
1149
1000
|
}
|
|
1150
|
-
}
|
|
1001
|
+
};
|
|
1002
|
+
yield* handler.relevantRemovedRoots(fieldChange.change, delegate);
|
|
1151
1003
|
}
|
|
1152
1004
|
}
|
|
1153
1005
|
/**
|
|
@@ -1193,14 +1045,13 @@ export function updateRefreshers(change, getDetachedNode, removedRoots, requireR
|
|
|
1193
1045
|
refreshers.set([root.major, brand(root.minor)], node);
|
|
1194
1046
|
}
|
|
1195
1047
|
}
|
|
1196
|
-
const { fieldChanges, nodeChanges, maxId, revisions, constraintViolationCount, constraintViolationCountOnRevert, builds, destroys, } = change;
|
|
1048
|
+
const { fieldChanges, nodeChanges, nodeToParent, nodeAliases, crossFieldKeys, maxId, revisions, constraintViolationCount, constraintViolationCountOnRevert, builds, destroys, } = change;
|
|
1197
1049
|
return makeModularChangeset({
|
|
1198
1050
|
fieldChanges,
|
|
1199
1051
|
nodeChanges,
|
|
1200
|
-
nodeToParent
|
|
1201
|
-
nodeAliases
|
|
1202
|
-
|
|
1203
|
-
crossFieldKeys: change.crossFieldKeys,
|
|
1052
|
+
nodeToParent,
|
|
1053
|
+
nodeAliases,
|
|
1054
|
+
crossFieldKeys,
|
|
1204
1055
|
maxId: maxId,
|
|
1205
1056
|
revisions,
|
|
1206
1057
|
constraintViolationCount,
|
|
@@ -1219,24 +1070,11 @@ export function updateRefreshers(change, getDetachedNode, removedRoots, requireR
|
|
|
1219
1070
|
export function intoDelta(taggedChange, fieldKinds) {
|
|
1220
1071
|
const change = taggedChange.change;
|
|
1221
1072
|
const rootDelta = {};
|
|
1073
|
+
const global = [];
|
|
1074
|
+
const rename = [];
|
|
1222
1075
|
if (!hasConflicts(change)) {
|
|
1223
1076
|
// If there are no constraint violations, then tree changes apply.
|
|
1224
|
-
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges,
|
|
1225
|
-
const global = [];
|
|
1226
|
-
for (const [[major, minor], nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
1227
|
-
global.push({
|
|
1228
|
-
id: { major, minor },
|
|
1229
|
-
fields: deltaFromNodeChange(nodeChangeFromId(change.nodeChanges, change.nodeAliases, nodeId), change.nodeChanges, change.nodeAliases, fieldKinds),
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
const rename = [];
|
|
1233
|
-
for (const { start: oldId, value: newId, length, } of change.rootNodes.oldToNewId.entries()) {
|
|
1234
|
-
rename.push({
|
|
1235
|
-
count: length,
|
|
1236
|
-
oldId: makeDetachedNodeId(oldId.revision, oldId.localId),
|
|
1237
|
-
newId: makeDetachedNodeId(newId.revision, newId.localId),
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1077
|
+
const fieldDeltas = intoDeltaImpl(change.fieldChanges, change.nodeChanges, fieldKinds, global, rename);
|
|
1240
1078
|
if (fieldDeltas.size > 0) {
|
|
1241
1079
|
rootDelta.fields = fieldDeltas;
|
|
1242
1080
|
}
|
|
@@ -1282,22 +1120,24 @@ function copyDetachedNodes(detachedNodes) {
|
|
|
1282
1120
|
/**
|
|
1283
1121
|
* @param change - The change to convert into a delta.
|
|
1284
1122
|
*/
|
|
1285
|
-
function intoDeltaImpl(change, nodeChanges,
|
|
1123
|
+
function intoDeltaImpl(change, nodeChanges, fieldKinds, global, rename) {
|
|
1286
1124
|
const delta = new Map();
|
|
1287
1125
|
for (const [field, fieldChange] of change) {
|
|
1288
|
-
const
|
|
1289
|
-
const nodeChange = nodeChangeFromId(nodeChanges,
|
|
1290
|
-
return deltaFromNodeChange(nodeChange, nodeChanges,
|
|
1126
|
+
const { local: fieldChanges, global: fieldGlobal, rename: fieldRename, } = getChangeHandler(fieldKinds, fieldChange.fieldKind).intoDelta(fieldChange.change, (childChange) => {
|
|
1127
|
+
const nodeChange = nodeChangeFromId(nodeChanges, childChange);
|
|
1128
|
+
return deltaFromNodeChange(nodeChange, nodeChanges, fieldKinds, global, rename);
|
|
1291
1129
|
});
|
|
1292
|
-
if (
|
|
1293
|
-
delta.set(field,
|
|
1130
|
+
if (fieldChanges !== undefined && fieldChanges.length > 0) {
|
|
1131
|
+
delta.set(field, fieldChanges);
|
|
1294
1132
|
}
|
|
1133
|
+
fieldGlobal?.forEach((c) => global.push(c));
|
|
1134
|
+
fieldRename?.forEach((r) => rename.push(r));
|
|
1295
1135
|
}
|
|
1296
1136
|
return delta;
|
|
1297
1137
|
}
|
|
1298
|
-
function deltaFromNodeChange(change, nodeChanges,
|
|
1138
|
+
function deltaFromNodeChange(change, nodeChanges, fieldKinds, global, rename) {
|
|
1299
1139
|
if (change.fieldChanges !== undefined) {
|
|
1300
|
-
return intoDeltaImpl(change.fieldChanges, nodeChanges,
|
|
1140
|
+
return intoDeltaImpl(change.fieldChanges, nodeChanges, fieldKinds, global, rename);
|
|
1301
1141
|
}
|
|
1302
1142
|
// TODO: update the API to allow undefined to be returned here
|
|
1303
1143
|
return new Map();
|
|
@@ -1344,22 +1184,30 @@ export function getFieldKind(fieldKinds, kind) {
|
|
|
1344
1184
|
export function getChangeHandler(fieldKinds, kind) {
|
|
1345
1185
|
return getFieldKind(fieldKinds, kind).changeHandler;
|
|
1346
1186
|
}
|
|
1347
|
-
function newComposeTable(baseChange, newChange,
|
|
1187
|
+
function newComposeTable(baseChange, newChange, composedNodeToParent) {
|
|
1348
1188
|
return {
|
|
1349
|
-
|
|
1350
|
-
entries: newDetachedEntryMap(),
|
|
1189
|
+
...newCrossFieldTable(),
|
|
1351
1190
|
baseChange,
|
|
1352
1191
|
newChange,
|
|
1353
1192
|
fieldToContext: new Map(),
|
|
1354
1193
|
newFieldToBaseField: new Map(),
|
|
1355
1194
|
newToBaseNodeId: newTupleBTree(),
|
|
1356
1195
|
composedNodes: new Set(),
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1196
|
+
composedNodeToParent,
|
|
1197
|
+
pendingCompositions: {
|
|
1198
|
+
nodeIdsToCompose: [],
|
|
1199
|
+
affectedBaseFields: newTupleBTree(),
|
|
1200
|
+
affectedNewFields: newTupleBTree(),
|
|
1201
|
+
},
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
function newCrossFieldTable() {
|
|
1205
|
+
return {
|
|
1206
|
+
srcTable: newChangeAtomIdRangeMap(),
|
|
1207
|
+
dstTable: newChangeAtomIdRangeMap(),
|
|
1208
|
+
srcDependents: newChangeAtomIdRangeMap(),
|
|
1209
|
+
dstDependents: newChangeAtomIdRangeMap(),
|
|
1210
|
+
invalidatedFields: new Set(),
|
|
1363
1211
|
};
|
|
1364
1212
|
}
|
|
1365
1213
|
function newConstraintState(violationCount) {
|
|
@@ -1367,354 +1215,147 @@ function newConstraintState(violationCount) {
|
|
|
1367
1215
|
violationCount,
|
|
1368
1216
|
};
|
|
1369
1217
|
}
|
|
1370
|
-
class
|
|
1371
|
-
constructor(
|
|
1372
|
-
this.
|
|
1373
|
-
this.
|
|
1218
|
+
class CrossFieldManagerI {
|
|
1219
|
+
constructor(crossFieldTable, currentFieldKey, allowInval = true) {
|
|
1220
|
+
this.crossFieldTable = crossFieldTable;
|
|
1221
|
+
this.currentFieldKey = currentFieldKey;
|
|
1222
|
+
this.allowInval = allowInval;
|
|
1374
1223
|
}
|
|
1375
|
-
|
|
1376
|
-
if (
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1384
|
-
else {
|
|
1385
|
-
assignRootChange(this.table.invertedRoots, this.table.invertedNodeToParent, attachEntry.value, nodeChange, this.fieldId, this.table.change.rebaseVersion);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
if (!areEqualChangeAtomIds(detachId, newAttachId)) {
|
|
1389
|
-
for (const entry of doesChangeAttachNodes(this.table.change.crossFieldKeys, detachId, count)) {
|
|
1390
|
-
if (!entry.value) {
|
|
1391
|
-
this.table.attachToDetachId.set(newAttachId, count, detachId);
|
|
1392
|
-
this.table.invertedRoots.detachLocations.set(detachId, count, this.fieldId);
|
|
1224
|
+
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1225
|
+
if (invalidateDependents && this.allowInval) {
|
|
1226
|
+
const lastChangedId = id + count - 1;
|
|
1227
|
+
let firstId = id;
|
|
1228
|
+
while (firstId <= lastChangedId) {
|
|
1229
|
+
const dependentEntry = getFirstFromCrossFieldMap(this.getDependents(target), revision, firstId, lastChangedId - firstId + 1);
|
|
1230
|
+
if (dependentEntry.value !== undefined) {
|
|
1231
|
+
this.crossFieldTable.invalidatedFields.add(dependentEntry.value);
|
|
1393
1232
|
}
|
|
1233
|
+
firstId = brand(firstId + dependentEntry.length);
|
|
1394
1234
|
}
|
|
1395
1235
|
}
|
|
1236
|
+
setInCrossFieldMap(this.getMap(target), revision, id, count, newValue);
|
|
1396
1237
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
let result;
|
|
1404
|
-
if (detachEntry.value !== undefined) {
|
|
1405
|
-
const moveEntry = this.table.entries.getFirst(attachId, countToProcess);
|
|
1406
|
-
result = { ...moveEntry, value: { nodeChange: moveEntry.value } };
|
|
1407
|
-
}
|
|
1408
|
-
else {
|
|
1409
|
-
// This node is detached in the input context of the original change.
|
|
1410
|
-
const nodeIdEntry = rangeQueryChangeAtomIdMap(this.table.change.rootNodes.nodeChanges, detachIdEntry.value, countToProcess);
|
|
1411
|
-
countToProcess = nodeIdEntry.length;
|
|
1412
|
-
result = {
|
|
1413
|
-
value: { nodeChange: nodeIdEntry.value, detachId: detachIdEntry.value },
|
|
1414
|
-
length: countToProcess,
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
if (result.value?.nodeChange !== undefined) {
|
|
1418
|
-
setInChangeAtomIdMap(this.table.invertedNodeToParent, result.value.nodeChange, {
|
|
1419
|
-
field: this.fieldId,
|
|
1420
|
-
});
|
|
1238
|
+
get(target, revision, id, count, addDependency) {
|
|
1239
|
+
if (addDependency) {
|
|
1240
|
+
// We assume that if there is already an entry for this ID it is because
|
|
1241
|
+
// a field handler has called compose on the same node multiple times.
|
|
1242
|
+
// In this case we only want to update the latest version, so we overwrite the dependency.
|
|
1243
|
+
setInCrossFieldMap(this.getDependents(target), revision, id, count, this.currentFieldKey);
|
|
1421
1244
|
}
|
|
1422
|
-
return
|
|
1245
|
+
return getFirstFromCrossFieldMap(this.getMap(target), revision, id, count);
|
|
1246
|
+
}
|
|
1247
|
+
getMap(target) {
|
|
1248
|
+
return target === CrossFieldTarget.Source
|
|
1249
|
+
? this.crossFieldTable.srcTable
|
|
1250
|
+
: this.crossFieldTable.dstTable;
|
|
1251
|
+
}
|
|
1252
|
+
getDependents(target) {
|
|
1253
|
+
return target === CrossFieldTarget.Source
|
|
1254
|
+
? this.crossFieldTable.srcDependents
|
|
1255
|
+
: this.crossFieldTable.dstDependents;
|
|
1423
1256
|
}
|
|
1424
1257
|
}
|
|
1425
|
-
class
|
|
1426
|
-
constructor(table, fieldId, allowInval = true) {
|
|
1427
|
-
|
|
1258
|
+
class InvertManager extends CrossFieldManagerI {
|
|
1259
|
+
constructor(table, field, fieldId, allowInval = true) {
|
|
1260
|
+
super(table, field, allowInval);
|
|
1428
1261
|
this.fieldId = fieldId;
|
|
1429
|
-
this.allowInval = allowInval;
|
|
1430
1262
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
const detachEntry = firstDetachIdFromAttachId(this.table.baseChange.rootNodes, baseAttachId, countToProcess);
|
|
1434
|
-
countToProcess = detachEntry.length;
|
|
1435
|
-
const nodeEntry = rangeQueryChangeAtomIdMap(this.table.newChange.rootNodes.nodeChanges, detachEntry.value, countToProcess);
|
|
1436
|
-
countToProcess = nodeEntry.length;
|
|
1437
|
-
const newNodeId = nodeEntry.value;
|
|
1438
|
-
const newRenameEntry = this.table.newChange.rootNodes.oldToNewId.getFirst(detachEntry.value, countToProcess);
|
|
1439
|
-
countToProcess = newRenameEntry.length;
|
|
1440
|
-
let result;
|
|
1441
|
-
// eslint-disable-next-line unicorn/prefer-ternary
|
|
1442
|
-
if (newNodeId !== undefined || newRenameEntry.value !== undefined) {
|
|
1443
|
-
result = {
|
|
1444
|
-
...newRenameEntry,
|
|
1445
|
-
value: { detachId: newRenameEntry.value, nodeChange: newNodeId },
|
|
1446
|
-
};
|
|
1447
|
-
}
|
|
1448
|
-
else {
|
|
1449
|
-
// This handles the case where the base changeset has moved these nodes,
|
|
1450
|
-
// meaning they were attached in the input context of the base changeset.
|
|
1451
|
-
result = this.table.entries.getFirst(baseAttachId, countToProcess);
|
|
1452
|
-
}
|
|
1453
|
-
// TODO: Consider moving these two checks into a separate method so that this function has no side effects.
|
|
1454
|
-
if (result.value?.detachId !== undefined) {
|
|
1455
|
-
this.table.rebasedDetachLocations.set(result.value.detachId, result.length, this.fieldId);
|
|
1456
|
-
}
|
|
1457
|
-
if (result.value?.nodeChange !== undefined) {
|
|
1458
|
-
setInChangeAtomIdMap(this.table.rebasedNodeToParent, result.value.nodeChange, {
|
|
1459
|
-
field: this.fieldId,
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
return result;
|
|
1463
|
-
}
|
|
1464
|
-
rebaseOverDetach(baseDetachId, count, newDetachId, nodeChange, cellRename) {
|
|
1465
|
-
let countToProcess = count;
|
|
1466
|
-
const attachIdEntry = firstAttachIdFromDetachId(this.table.baseRoots, baseDetachId, countToProcess);
|
|
1467
|
-
const baseAttachId = attachIdEntry.value;
|
|
1468
|
-
countToProcess = attachIdEntry.length;
|
|
1469
|
-
const attachFieldEntry = getFirstFieldForCrossFieldKey(this.table.baseChange, { ...baseAttachId, target: CrossFieldTarget.Destination }, countToProcess);
|
|
1470
|
-
countToProcess = attachFieldEntry.length;
|
|
1471
|
-
const detachedMoveEntry = this.table.baseChange.rootNodes.outputDetachLocations.getFirst(baseDetachId, countToProcess);
|
|
1472
|
-
countToProcess = detachedMoveEntry.length;
|
|
1473
|
-
const destinationField = attachFieldEntry.value ?? detachedMoveEntry.value;
|
|
1474
|
-
if (destinationField !== undefined) {
|
|
1475
|
-
// The base detach is part of a move (or move of detach location) in the base changeset.
|
|
1476
|
-
setInCrossFieldMap(this.table.entries, baseAttachId, countToProcess, {
|
|
1477
|
-
nodeChange,
|
|
1478
|
-
detachId: newDetachId,
|
|
1479
|
-
cellRename,
|
|
1480
|
-
});
|
|
1481
|
-
if (nodeChange !== undefined || newDetachId !== undefined) {
|
|
1482
|
-
this.invalidateBaseFields([destinationField]);
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
if (attachFieldEntry.value === undefined) {
|
|
1486
|
-
// These nodes are detached in the output context of the base changeset.
|
|
1487
|
-
if (nodeChange !== undefined) {
|
|
1488
|
-
assignRootChange(this.table.rebasedRootNodes, this.table.rebasedNodeToParent, baseAttachId, nodeChange, this.fieldId, this.table.rebaseVersion);
|
|
1489
|
-
}
|
|
1490
|
-
if (newDetachId !== undefined) {
|
|
1491
|
-
addNodeRename(this.table.rebasedRootNodes, baseAttachId, newDetachId, countToProcess, this.fieldId);
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
if (newDetachId !== undefined) {
|
|
1495
|
-
this.table.movedDetaches.set(newDetachId, countToProcess, true);
|
|
1496
|
-
}
|
|
1497
|
-
if (countToProcess < count) {
|
|
1498
|
-
const remainingCount = count - countToProcess;
|
|
1499
|
-
const nextDetachId = newDetachId !== undefined
|
|
1500
|
-
? offsetChangeAtomId(newDetachId, countToProcess)
|
|
1501
|
-
: undefined;
|
|
1502
|
-
this.rebaseOverDetach(offsetChangeAtomId(baseDetachId, countToProcess), remainingCount, nextDetachId, nodeChange);
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
addDetach(id, count) {
|
|
1506
|
-
this.table.rebasedDetachLocations.set(id, count, this.fieldId);
|
|
1507
|
-
}
|
|
1508
|
-
removeDetach(id, count) {
|
|
1509
|
-
this.table.movedDetaches.set(id, count, true);
|
|
1510
|
-
}
|
|
1511
|
-
doesBaseAttachNodes(id, count) {
|
|
1512
|
-
let countToProcess = count;
|
|
1513
|
-
const attachEntry = getFirstAttachField(this.table.baseChange.crossFieldKeys, id, countToProcess);
|
|
1514
|
-
countToProcess = attachEntry.length;
|
|
1515
|
-
return { start: id, value: attachEntry.value !== undefined, length: countToProcess };
|
|
1516
|
-
}
|
|
1517
|
-
getBaseRename(id, count) {
|
|
1518
|
-
return this.table.baseChange.rootNodes.oldToNewId.getFirst(id, count);
|
|
1519
|
-
}
|
|
1520
|
-
getNewRenameForBaseRename(baseRenameTo, count) {
|
|
1521
|
-
let countToProcess = count;
|
|
1522
|
-
const inputEntry = firstDetachIdFromAttachId(this.table.baseChange.rootNodes, baseRenameTo, countToProcess);
|
|
1523
|
-
const attachEntry = getFirstAttachField(this.table.baseChange.crossFieldKeys, baseRenameTo, countToProcess);
|
|
1524
|
-
countToProcess = attachEntry.length;
|
|
1525
|
-
if (attachEntry.value !== undefined) {
|
|
1526
|
-
// These nodes are attached in the output context of the base changeset.
|
|
1527
|
-
return { value: undefined, length: countToProcess };
|
|
1528
|
-
}
|
|
1529
|
-
countToProcess = inputEntry.length;
|
|
1530
|
-
const inputId = inputEntry.value;
|
|
1531
|
-
const moveEntry = this.table.entries.getFirst(inputId, countToProcess);
|
|
1532
|
-
countToProcess = moveEntry.length;
|
|
1533
|
-
if (moveEntry.value !== undefined) {
|
|
1534
|
-
return { ...moveEntry, value: moveEntry.value.cellRename ?? moveEntry.value.detachId };
|
|
1535
|
-
}
|
|
1536
|
-
return this.table.newChange.rootNodes.oldToNewId.getFirst(inputId, countToProcess);
|
|
1537
|
-
}
|
|
1538
|
-
invalidateBaseFields(fields) {
|
|
1539
|
-
if (this.allowInval) {
|
|
1540
|
-
for (const fieldId of fields) {
|
|
1541
|
-
this.table.affectedBaseFields.set(fieldIdKeyFromFieldId(fieldId), true);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1263
|
+
onMoveIn(id) {
|
|
1264
|
+
setInChangeAtomIdMap(this.table.invertedNodeToParent, id, this.fieldId);
|
|
1544
1265
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
setInChangeAtomIdMap(nodeToParent, nodeId, { root: detachId });
|
|
1266
|
+
moveKey(target, revision, id, count) {
|
|
1267
|
+
assert(false, 0x9c5 /* Keys should not be moved manually during invert */);
|
|
1268
|
+
}
|
|
1269
|
+
get table() {
|
|
1270
|
+
return this.crossFieldTable;
|
|
1551
1271
|
}
|
|
1552
|
-
table.detachLocations.set(detachId, 1, detachLocation);
|
|
1553
1272
|
}
|
|
1554
|
-
class
|
|
1555
|
-
constructor(table, fieldId, allowInval = true) {
|
|
1556
|
-
|
|
1273
|
+
class RebaseManager extends CrossFieldManagerI {
|
|
1274
|
+
constructor(table, currentField, fieldId, allowInval = true) {
|
|
1275
|
+
super(table, currentField, allowInval);
|
|
1557
1276
|
this.fieldId = fieldId;
|
|
1558
|
-
this.allowInval = allowInval;
|
|
1559
1277
|
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
countToProcess = newRenameEntry.length;
|
|
1577
|
-
result = {
|
|
1578
|
-
value: { nodeChange: rootEntry.value, detachId: newRenameEntry.value },
|
|
1579
|
-
length: countToProcess,
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
// TODO: Consider moving this to a separate method so that this method can be side-effect free.
|
|
1583
|
-
if (result.value?.nodeChange !== undefined) {
|
|
1584
|
-
setInChangeAtomIdMap(this.table.movedNodeToParent, result.value.nodeChange, {
|
|
1585
|
-
field: this.fieldId,
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1588
|
-
return result;
|
|
1589
|
-
}
|
|
1590
|
-
composeAttachDetach(baseAttachId, newDetachId, count) {
|
|
1591
|
-
let countToProcess = count;
|
|
1592
|
-
const newAttachEntry = getFirstAttachField(this.table.newChange.crossFieldKeys, newDetachId, countToProcess);
|
|
1593
|
-
countToProcess = newAttachEntry.length;
|
|
1594
|
-
// Both changes can have the same ID if they came from inverse changesets.
|
|
1595
|
-
// If the new detach is part of a move,
|
|
1596
|
-
// then both input changesets contain the attach cross-field key for this ID.
|
|
1597
|
-
// The new attach may still exist in the composed changeset so we do not remove it here.
|
|
1598
|
-
// The new attach will typically cancel with a base detach,
|
|
1599
|
-
// in which case the cross-field key will be removed in `composeDetachAttach`.
|
|
1600
|
-
const hasNewAttachWithBaseAttachId = areEqualChangeAtomIds(baseAttachId, newDetachId) && newAttachEntry.value !== undefined;
|
|
1601
|
-
if (!hasNewAttachWithBaseAttachId) {
|
|
1602
|
-
this.table.removedCrossFieldKeys.set({ ...baseAttachId, target: CrossFieldTarget.Destination }, countToProcess, true);
|
|
1603
|
-
}
|
|
1604
|
-
const baseDetachEntry = getFirstDetachField(this.table.baseChange.crossFieldKeys, baseAttachId, countToProcess);
|
|
1605
|
-
countToProcess = baseDetachEntry.length;
|
|
1606
|
-
const baseRootIdEntry = firstDetachIdFromAttachId(this.table.baseChange.rootNodes, baseAttachId, countToProcess);
|
|
1607
|
-
countToProcess = baseRootIdEntry.length;
|
|
1608
|
-
const baseDetachId = baseRootIdEntry.value;
|
|
1609
|
-
if (baseDetachEntry.value !== undefined) {
|
|
1610
|
-
// The base change moves these nodes.
|
|
1611
|
-
const prevEntry = this.table.entries.getFirst(baseAttachId, baseDetachEntry.length).value ?? {};
|
|
1612
|
-
this.table.entries.set(baseAttachId, baseDetachEntry.length, {
|
|
1613
|
-
...prevEntry,
|
|
1614
|
-
detachId: newDetachId,
|
|
1615
|
-
});
|
|
1616
|
-
// The new detach will replace the base detach, so we remove the key for the base detach, unless they have the same ID.
|
|
1617
|
-
if (!areEqualChangeAtomIds(baseAttachId, newDetachId)) {
|
|
1618
|
-
this.table.removedCrossFieldKeys.set({ ...baseAttachId, target: CrossFieldTarget.Source }, countToProcess, true);
|
|
1278
|
+
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1279
|
+
if (invalidateDependents && this.allowInval) {
|
|
1280
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1281
|
+
target,
|
|
1282
|
+
revision,
|
|
1283
|
+
localId: id,
|
|
1284
|
+
}, count);
|
|
1285
|
+
assert(newFieldIds.length === 0, 0x9c6 /* TODO: Modifying a cross-field key from the new changeset is currently unsupported */);
|
|
1286
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1287
|
+
target,
|
|
1288
|
+
revision,
|
|
1289
|
+
localId: id,
|
|
1290
|
+
}, count);
|
|
1291
|
+
assert(baseFieldIds.length > 0, 0x9c7 /* Cross field key not registered in base or new change */);
|
|
1292
|
+
for (const baseFieldId of baseFieldIds) {
|
|
1293
|
+
this.table.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
1619
1294
|
}
|
|
1620
|
-
this.table.movedCrossFieldKeys.set({ ...newDetachId, target: CrossFieldTarget.Source }, countToProcess, baseDetachEntry.value);
|
|
1621
|
-
this.invalidateBaseFields([baseDetachEntry.value]);
|
|
1622
1295
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
this.invalidateBaseFields(detachFields);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
else {
|
|
1656
|
-
const baseNodeId = getFromChangeAtomIdMap(this.table.baseChange.rootNodes.nodeChanges, baseDetachId);
|
|
1657
|
-
if (baseNodeId !== undefined) {
|
|
1658
|
-
addNodesToCompose(this.table, baseNodeId, newChanges);
|
|
1296
|
+
super.set(target, revision, id, count, newValue, invalidateDependents);
|
|
1297
|
+
}
|
|
1298
|
+
onMoveIn(id) {
|
|
1299
|
+
setInChangeAtomIdMap(this.table.rebasedNodeToParent, id, this.fieldId);
|
|
1300
|
+
}
|
|
1301
|
+
moveKey(target, revision, id, count) {
|
|
1302
|
+
this.table.rebasedCrossFieldKeys.set({ target, revision, localId: id }, count, this.fieldId);
|
|
1303
|
+
}
|
|
1304
|
+
get table() {
|
|
1305
|
+
return this.crossFieldTable;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
// TODO: Deduplicate this with RebaseTable
|
|
1309
|
+
class ComposeManager extends CrossFieldManagerI {
|
|
1310
|
+
constructor(table, currentField, fieldId, allowInval = true) {
|
|
1311
|
+
super(table, currentField, allowInval);
|
|
1312
|
+
this.fieldId = fieldId;
|
|
1313
|
+
}
|
|
1314
|
+
set(target, revision, id, count, newValue, invalidateDependents) {
|
|
1315
|
+
if (invalidateDependents && this.allowInval) {
|
|
1316
|
+
const newFieldIds = getFieldsForCrossFieldKey(this.table.newChange, {
|
|
1317
|
+
target,
|
|
1318
|
+
revision,
|
|
1319
|
+
localId: id,
|
|
1320
|
+
}, count);
|
|
1321
|
+
if (newFieldIds.length > 0) {
|
|
1322
|
+
for (const newFieldId of newFieldIds) {
|
|
1323
|
+
this.table.pendingCompositions.affectedNewFields.set([newFieldId.nodeId?.revision, newFieldId.nodeId?.localId, newFieldId.field], true);
|
|
1324
|
+
}
|
|
1659
1325
|
}
|
|
1660
1326
|
else {
|
|
1661
|
-
|
|
1327
|
+
const baseFieldIds = getFieldsForCrossFieldKey(this.table.baseChange, {
|
|
1328
|
+
target,
|
|
1329
|
+
revision,
|
|
1330
|
+
localId: id,
|
|
1331
|
+
}, count);
|
|
1332
|
+
assert(baseFieldIds.length > 0, 0x9c8 /* Cross field key not registered in base or new change */);
|
|
1333
|
+
for (const baseFieldId of baseFieldIds) {
|
|
1334
|
+
this.table.pendingCompositions.affectedBaseFields.set([baseFieldId.nodeId?.revision, baseFieldId.nodeId?.localId, baseFieldId.field], true);
|
|
1335
|
+
}
|
|
1662
1336
|
}
|
|
1663
1337
|
}
|
|
1338
|
+
super.set(target, revision, id, count, newValue, invalidateDependents);
|
|
1664
1339
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
const isReattachOfSameNodes = areEqualChangeAtomIds(renamedDetachEntry.value, newAttachId);
|
|
1668
|
-
return { ...renamedDetachEntry, value: isReattachOfSameNodes };
|
|
1669
|
-
}
|
|
1670
|
-
composeDetachAttach(baseDetachId, newAttachId, count, composeToPin) {
|
|
1671
|
-
const areSameEntry = this.areSameNodes(baseDetachId, newAttachId, count);
|
|
1672
|
-
const countToProcess = areSameEntry.length;
|
|
1673
|
-
if (areSameEntry.value) {
|
|
1674
|
-
// These nodes have been moved back to their original location, so the composed changeset should not have any renames for them.
|
|
1675
|
-
// Note that deleting the rename from `this.table.composedRootNodes` would change the result of this method
|
|
1676
|
-
// if it were rerun due to the field being invalidated, so we instead record that the rename should be deleted later.
|
|
1677
|
-
this.table.renamesToDelete.set(baseDetachId, countToProcess, true);
|
|
1678
|
-
}
|
|
1679
|
-
if (composeToPin) {
|
|
1680
|
-
this.table.movedCrossFieldKeys.set({ target: CrossFieldTarget.Source, ...newAttachId }, countToProcess, this.fieldId);
|
|
1681
|
-
if (!areEqualChangeAtomIds(baseDetachId, newAttachId)) {
|
|
1682
|
-
// The pin will have `newAttachId` as both its detach and attach ID.
|
|
1683
|
-
// So we remove `baseDetachId` unless that is equal to the pin's detach ID.
|
|
1684
|
-
this.table.removedCrossFieldKeys.set({ target: CrossFieldTarget.Source, ...baseDetachId }, countToProcess, true);
|
|
1685
|
-
}
|
|
1686
|
-
// Note that while change2 should already have this key, change1 may have a rollback for the same ID in a different location.
|
|
1687
|
-
// In that case, change1's attach should be canceled out by a detach from change2.
|
|
1688
|
-
// Here we make sure that the composed change has the correct location (this field) for the attach ID.
|
|
1689
|
-
this.table.movedCrossFieldKeys.set({ target: CrossFieldTarget.Destination, ...newAttachId }, countToProcess, this.fieldId);
|
|
1690
|
-
}
|
|
1691
|
-
else {
|
|
1692
|
-
this.table.removedCrossFieldKeys.set({ target: CrossFieldTarget.Source, ...baseDetachId }, countToProcess, true);
|
|
1693
|
-
this.table.removedCrossFieldKeys.set({ target: CrossFieldTarget.Destination, ...newAttachId }, countToProcess, true);
|
|
1694
|
-
}
|
|
1695
|
-
if (countToProcess < count) {
|
|
1696
|
-
this.composeAttachDetach(offsetChangeAtomId(baseDetachId, countToProcess), offsetChangeAtomId(newAttachId, countToProcess), count - countToProcess);
|
|
1697
|
-
}
|
|
1340
|
+
onMoveIn(id) {
|
|
1341
|
+
setInChangeAtomIdMap(this.table.composedNodeToParent, id, this.fieldId);
|
|
1698
1342
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1343
|
+
moveKey(target, revision, id, count) {
|
|
1344
|
+
throw new Error("Moving cross-field keys during compose is currently unsupported");
|
|
1345
|
+
}
|
|
1346
|
+
get table() {
|
|
1347
|
+
return this.crossFieldTable;
|
|
1705
1348
|
}
|
|
1706
1349
|
}
|
|
1707
1350
|
function makeModularChangeset(props = {
|
|
1708
1351
|
maxId: -1,
|
|
1709
1352
|
}) {
|
|
1710
1353
|
const changeset = {
|
|
1711
|
-
rebaseVersion: props.rebaseVersion ?? 1,
|
|
1712
1354
|
fieldChanges: props.fieldChanges ?? new Map(),
|
|
1713
1355
|
nodeChanges: props.nodeChanges ?? newTupleBTree(),
|
|
1714
|
-
rootNodes: props.rootNodes ?? newRootTable(),
|
|
1715
1356
|
nodeToParent: props.nodeToParent ?? newTupleBTree(),
|
|
1716
1357
|
nodeAliases: props.nodeAliases ?? newTupleBTree(),
|
|
1717
|
-
crossFieldKeys: props.crossFieldKeys ??
|
|
1358
|
+
crossFieldKeys: props.crossFieldKeys ?? newCrossFieldKeyTable(),
|
|
1718
1359
|
};
|
|
1719
1360
|
if (props.revisions !== undefined && props.revisions.length > 0) {
|
|
1720
1361
|
changeset.revisions = props.revisions;
|
|
@@ -1729,6 +1370,12 @@ function makeModularChangeset(props = {
|
|
|
1729
1370
|
props.constraintViolationCountOnRevert > 0) {
|
|
1730
1371
|
changeset.constraintViolationCountOnRevert = props.constraintViolationCountOnRevert;
|
|
1731
1372
|
}
|
|
1373
|
+
if (props.noChangeConstraint !== undefined) {
|
|
1374
|
+
changeset.noChangeConstraint = props.noChangeConstraint;
|
|
1375
|
+
}
|
|
1376
|
+
if (props.noChangeConstraintOnRevert !== undefined) {
|
|
1377
|
+
changeset.noChangeConstraintOnRevert = props.noChangeConstraintOnRevert;
|
|
1378
|
+
}
|
|
1732
1379
|
if (props.builds !== undefined && props.builds.size > 0) {
|
|
1733
1380
|
changeset.builds = props.builds;
|
|
1734
1381
|
}
|
|
@@ -1741,14 +1388,12 @@ function makeModularChangeset(props = {
|
|
|
1741
1388
|
return changeset;
|
|
1742
1389
|
}
|
|
1743
1390
|
export class ModularEditBuilder extends EditBuilder {
|
|
1744
|
-
constructor(family, fieldKinds, changeReceiver) {
|
|
1391
|
+
constructor(family, fieldKinds, changeReceiver, codecOptions) {
|
|
1745
1392
|
super(family, changeReceiver);
|
|
1746
1393
|
this.fieldKinds = fieldKinds;
|
|
1747
1394
|
this.transactionDepth = 0;
|
|
1748
1395
|
this.idAllocator = idAllocatorFromMaxId();
|
|
1749
|
-
|
|
1750
|
-
isInTransaction() {
|
|
1751
|
-
return this.transactionDepth > 0;
|
|
1396
|
+
this.codecOptions = codecOptions;
|
|
1752
1397
|
}
|
|
1753
1398
|
enterTransaction() {
|
|
1754
1399
|
this.transactionDepth += 1;
|
|
@@ -1800,8 +1445,7 @@ export class ModularEditBuilder extends EditBuilder {
|
|
|
1800
1445
|
fieldChange: { fieldKind, change },
|
|
1801
1446
|
nodeChanges: newTupleBTree(),
|
|
1802
1447
|
nodeToParent: newTupleBTree(),
|
|
1803
|
-
crossFieldKeys:
|
|
1804
|
-
rootNodes: newRootTable(),
|
|
1448
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
1805
1449
|
idAllocator: this.idAllocator,
|
|
1806
1450
|
localCrossFieldKeys,
|
|
1807
1451
|
revision,
|
|
@@ -1820,7 +1464,6 @@ export class ModularEditBuilder extends EditBuilder {
|
|
|
1820
1464
|
? makeModularChangeset({
|
|
1821
1465
|
maxId: this.idAllocator.getMaxId(),
|
|
1822
1466
|
builds: change.builds,
|
|
1823
|
-
rootNodes: renameTableFromRenameDescriptions(change.renames ?? []),
|
|
1824
1467
|
revisions: [{ revision: change.revision }],
|
|
1825
1468
|
})
|
|
1826
1469
|
: buildModularChangesetFromField({
|
|
@@ -1831,14 +1474,13 @@ export class ModularEditBuilder extends EditBuilder {
|
|
|
1831
1474
|
},
|
|
1832
1475
|
nodeChanges: newTupleBTree(),
|
|
1833
1476
|
nodeToParent: newTupleBTree(),
|
|
1834
|
-
crossFieldKeys:
|
|
1835
|
-
rootNodes: newRootTable(),
|
|
1477
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
1836
1478
|
idAllocator: this.idAllocator,
|
|
1837
1479
|
localCrossFieldKeys: getChangeHandler(this.fieldKinds, change.fieldKind).getCrossFieldKeys(change.change),
|
|
1838
1480
|
revision: change.revision,
|
|
1839
1481
|
}));
|
|
1840
1482
|
});
|
|
1841
|
-
const revInfo =
|
|
1483
|
+
const revInfo = [...revisions].map((revision) => ({ revision }));
|
|
1842
1484
|
const composedChange = {
|
|
1843
1485
|
...this.changeFamily.rebaser.compose(changeMaps),
|
|
1844
1486
|
revisions: revInfo,
|
|
@@ -1861,8 +1503,7 @@ export class ModularEditBuilder extends EditBuilder {
|
|
|
1861
1503
|
nodeChange,
|
|
1862
1504
|
nodeChanges: newTupleBTree(),
|
|
1863
1505
|
nodeToParent: newTupleBTree(),
|
|
1864
|
-
crossFieldKeys:
|
|
1865
|
-
rootNodes: newRootTable(),
|
|
1506
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
1866
1507
|
idAllocator: this.idAllocator,
|
|
1867
1508
|
revision,
|
|
1868
1509
|
}), revision));
|
|
@@ -1876,27 +1517,43 @@ export class ModularEditBuilder extends EditBuilder {
|
|
|
1876
1517
|
nodeChange,
|
|
1877
1518
|
nodeChanges: newTupleBTree(),
|
|
1878
1519
|
nodeToParent: newTupleBTree(),
|
|
1879
|
-
crossFieldKeys:
|
|
1880
|
-
rootNodes: newRootTable(),
|
|
1520
|
+
crossFieldKeys: newCrossFieldKeyTable(),
|
|
1881
1521
|
idAllocator: this.idAllocator,
|
|
1882
1522
|
revision,
|
|
1883
1523
|
}), revision));
|
|
1884
1524
|
}
|
|
1525
|
+
addNoChangeConstraint(revision) {
|
|
1526
|
+
if (lt(this.codecOptions.minVersionForCollab, FluidClientVersion.v2_80)) {
|
|
1527
|
+
throw new UsageError(`No change constraints require min client version of at least ${FluidClientVersion.v2_80}`);
|
|
1528
|
+
}
|
|
1529
|
+
const changeset = makeModularChangeset({
|
|
1530
|
+
maxId: -1,
|
|
1531
|
+
noChangeConstraint: { violated: false },
|
|
1532
|
+
});
|
|
1533
|
+
this.applyChange(tagChange(changeset, revision));
|
|
1534
|
+
}
|
|
1535
|
+
addNoChangeConstraintOnRevert(revision) {
|
|
1536
|
+
if (lt(this.codecOptions.minVersionForCollab, FluidClientVersion.v2_80)) {
|
|
1537
|
+
throw new UsageError(`No change constraints require min client version of at least ${FluidClientVersion.v2_80}`);
|
|
1538
|
+
}
|
|
1539
|
+
const changeset = makeModularChangeset({
|
|
1540
|
+
maxId: -1,
|
|
1541
|
+
noChangeConstraintOnRevert: { violated: false },
|
|
1542
|
+
});
|
|
1543
|
+
this.applyChange(tagChange(changeset, revision));
|
|
1544
|
+
}
|
|
1885
1545
|
}
|
|
1886
|
-
|
|
1887
|
-
const { path, fieldChange, nodeChanges, nodeToParent, crossFieldKeys,
|
|
1546
|
+
function buildModularChangesetFromField(props) {
|
|
1547
|
+
const { path, fieldChange, nodeChanges, nodeToParent, crossFieldKeys, idAllocator = idAllocatorFromMaxId(), localCrossFieldKeys = [], childId, revision, } = props;
|
|
1888
1548
|
const fieldChanges = new Map([[path.field, fieldChange]]);
|
|
1889
1549
|
if (path.parent === undefined) {
|
|
1890
|
-
const field = { nodeId: undefined, field: path.field };
|
|
1891
1550
|
for (const { key, count } of localCrossFieldKeys) {
|
|
1892
|
-
crossFieldKeys.set(key, count, field);
|
|
1551
|
+
crossFieldKeys.set(key, count, { nodeId: undefined, field: path.field });
|
|
1893
1552
|
}
|
|
1894
1553
|
if (childId !== undefined) {
|
|
1895
1554
|
setInChangeAtomIdMap(nodeToParent, childId, {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
field: path.field,
|
|
1899
|
-
},
|
|
1555
|
+
nodeId: undefined,
|
|
1556
|
+
field: path.field,
|
|
1900
1557
|
});
|
|
1901
1558
|
}
|
|
1902
1559
|
return makeModularChangeset({
|
|
@@ -1904,7 +1561,6 @@ export function buildModularChangesetFromField(props) {
|
|
|
1904
1561
|
nodeChanges,
|
|
1905
1562
|
nodeToParent,
|
|
1906
1563
|
crossFieldKeys,
|
|
1907
|
-
rootNodes,
|
|
1908
1564
|
maxId: idAllocator.getMaxId(),
|
|
1909
1565
|
revisions: [{ revision }],
|
|
1910
1566
|
});
|
|
@@ -1913,13 +1569,13 @@ export function buildModularChangesetFromField(props) {
|
|
|
1913
1569
|
fieldChanges,
|
|
1914
1570
|
};
|
|
1915
1571
|
const parentId = { localId: brand(idAllocator.allocate()), revision };
|
|
1916
|
-
const fieldId = { nodeId: parentId, field: path.field };
|
|
1917
1572
|
for (const { key, count } of localCrossFieldKeys) {
|
|
1918
1573
|
crossFieldKeys.set(key, count, { nodeId: parentId, field: path.field });
|
|
1919
1574
|
}
|
|
1920
1575
|
if (childId !== undefined) {
|
|
1921
1576
|
setInChangeAtomIdMap(nodeToParent, childId, {
|
|
1922
|
-
|
|
1577
|
+
nodeId: parentId,
|
|
1578
|
+
field: path.field,
|
|
1923
1579
|
});
|
|
1924
1580
|
}
|
|
1925
1581
|
return buildModularChangesetFromNode({
|
|
@@ -1928,57 +1584,55 @@ export function buildModularChangesetFromField(props) {
|
|
|
1928
1584
|
nodeChanges,
|
|
1929
1585
|
nodeToParent,
|
|
1930
1586
|
crossFieldKeys,
|
|
1931
|
-
rootNodes,
|
|
1932
1587
|
idAllocator,
|
|
1933
1588
|
revision,
|
|
1934
1589
|
nodeId: parentId,
|
|
1935
1590
|
});
|
|
1936
1591
|
}
|
|
1937
1592
|
function buildModularChangesetFromNode(props) {
|
|
1938
|
-
const { path, nodeId = { localId: brand(
|
|
1939
|
-
setInChangeAtomIdMap(
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
]);
|
|
1955
|
-
const fieldChange = {
|
|
1956
|
-
fieldKind: genericFieldKind.identifier,
|
|
1957
|
-
change: fieldChangeset,
|
|
1958
|
-
};
|
|
1959
|
-
return buildModularChangesetFromField({
|
|
1960
|
-
...props,
|
|
1961
|
-
path: { parent: path.parent, field: path.parentField },
|
|
1962
|
-
fieldChange,
|
|
1963
|
-
localCrossFieldKeys: [],
|
|
1964
|
-
childId: nodeId,
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
function renameTableFromRenameDescriptions(renames) {
|
|
1969
|
-
const table = newRootTable();
|
|
1970
|
-
for (const rename of renames) {
|
|
1971
|
-
addNodeRename(table, rename.oldId, rename.newId, rename.count, rename.detachLocation);
|
|
1972
|
-
}
|
|
1973
|
-
return table;
|
|
1593
|
+
const { path, idAllocator, revision, nodeChanges, nodeChange, nodeId = { localId: brand(idAllocator.allocate()), revision }, } = props;
|
|
1594
|
+
setInChangeAtomIdMap(nodeChanges, nodeId, nodeChange);
|
|
1595
|
+
const fieldChangeset = genericFieldKind.changeHandler.editor.buildChildChanges([
|
|
1596
|
+
[path.parentIndex, nodeId],
|
|
1597
|
+
]);
|
|
1598
|
+
const fieldChange = {
|
|
1599
|
+
fieldKind: genericFieldKind.identifier,
|
|
1600
|
+
change: fieldChangeset,
|
|
1601
|
+
};
|
|
1602
|
+
return buildModularChangesetFromField({
|
|
1603
|
+
...props,
|
|
1604
|
+
path: { parent: path.parent, field: path.parentField },
|
|
1605
|
+
fieldChange,
|
|
1606
|
+
localCrossFieldKeys: [],
|
|
1607
|
+
childId: nodeId,
|
|
1608
|
+
});
|
|
1974
1609
|
}
|
|
1975
1610
|
function getRevInfoFromTaggedChanges(changes) {
|
|
1976
1611
|
let maxId = -1;
|
|
1977
1612
|
const revInfos = [];
|
|
1613
|
+
const revisions = new Set();
|
|
1978
1614
|
for (const taggedChange of changes) {
|
|
1979
1615
|
const change = taggedChange.change;
|
|
1980
1616
|
maxId = Math.max(change.maxId ?? -1, maxId);
|
|
1981
|
-
|
|
1617
|
+
const infosToAdd = revisionInfoFromTaggedChange(taggedChange);
|
|
1618
|
+
for (const info of infosToAdd) {
|
|
1619
|
+
if (!revisions.has(info.revision)) {
|
|
1620
|
+
revisions.add(info.revision);
|
|
1621
|
+
revInfos.push(info);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
const rolledBackRevisions = [];
|
|
1626
|
+
for (const info of revInfos) {
|
|
1627
|
+
if (info.rollbackOf !== undefined) {
|
|
1628
|
+
rolledBackRevisions.push(info.rollbackOf);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
rolledBackRevisions.reverse();
|
|
1632
|
+
for (const revision of rolledBackRevisions) {
|
|
1633
|
+
if (!revisions.has(revision)) {
|
|
1634
|
+
revInfos.push({ revision });
|
|
1635
|
+
}
|
|
1982
1636
|
}
|
|
1983
1637
|
return { maxId: brand(maxId), revInfos };
|
|
1984
1638
|
}
|
|
@@ -1996,16 +1650,15 @@ function revisionInfoFromTaggedChange(taggedChange) {
|
|
|
1996
1650
|
}
|
|
1997
1651
|
return revInfos;
|
|
1998
1652
|
}
|
|
1999
|
-
function fieldChangeFromId(
|
|
2000
|
-
const
|
|
2001
|
-
const fieldMap = fieldMapFromNodeId(change.fieldChanges, change.nodeChanges, change.nodeAliases, fieldId.nodeId);
|
|
1653
|
+
function fieldChangeFromId(fields, nodes, id) {
|
|
1654
|
+
const fieldMap = fieldMapFromNodeId(fields, nodes, id.nodeId);
|
|
2002
1655
|
return fieldMap.get(id.field) ?? fail(0xb25 /* No field exists for the given ID */);
|
|
2003
1656
|
}
|
|
2004
|
-
function fieldMapFromNodeId(rootFieldMap, nodes,
|
|
1657
|
+
function fieldMapFromNodeId(rootFieldMap, nodes, nodeId) {
|
|
2005
1658
|
if (nodeId === undefined) {
|
|
2006
1659
|
return rootFieldMap;
|
|
2007
1660
|
}
|
|
2008
|
-
const node = nodeChangeFromId(nodes,
|
|
1661
|
+
const node = nodeChangeFromId(nodes, nodeId);
|
|
2009
1662
|
assert(node.fieldChanges !== undefined, 0x9c9 /* Expected node to have field changes */);
|
|
2010
1663
|
return node.fieldChanges;
|
|
2011
1664
|
}
|
|
@@ -2018,78 +1671,51 @@ function rebasedFieldIdFromBaseId(table, baseId) {
|
|
|
2018
1671
|
function rebasedNodeIdFromBaseNodeId(table, baseId) {
|
|
2019
1672
|
return getFromChangeAtomIdMap(table.baseToRebasedNodeId, baseId) ?? baseId;
|
|
2020
1673
|
}
|
|
2021
|
-
function nodeChangeFromId(nodes,
|
|
2022
|
-
const
|
|
2023
|
-
const node = getFromChangeAtomIdMap(nodes, normalizedId);
|
|
1674
|
+
function nodeChangeFromId(nodes, id) {
|
|
1675
|
+
const node = getFromChangeAtomIdMap(nodes, id);
|
|
2024
1676
|
assert(node !== undefined, 0x9ca /* Unknown node ID */);
|
|
2025
1677
|
return node;
|
|
2026
1678
|
}
|
|
2027
1679
|
function fieldIdFromFieldIdKey([revision, localId, field]) {
|
|
2028
|
-
const nodeId = localId
|
|
1680
|
+
const nodeId = localId === undefined ? undefined : { revision, localId };
|
|
2029
1681
|
return { nodeId, field };
|
|
2030
1682
|
}
|
|
2031
|
-
function fieldIdKeyFromFieldId(fieldId) {
|
|
2032
|
-
return [fieldId.nodeId?.revision, fieldId.nodeId?.localId, fieldId.field];
|
|
2033
|
-
}
|
|
2034
1683
|
function cloneNodeChangeset(nodeChangeset) {
|
|
2035
1684
|
if (nodeChangeset.fieldChanges !== undefined) {
|
|
2036
1685
|
return { ...nodeChangeset, fieldChanges: new Map(nodeChangeset.fieldChanges) };
|
|
2037
1686
|
}
|
|
2038
1687
|
return { ...nodeChangeset };
|
|
2039
1688
|
}
|
|
2040
|
-
function
|
|
2041
|
-
return location.field !== undefined
|
|
2042
|
-
? { field: replaceFieldIdRevision(location.field, oldRevisions, newRevision) }
|
|
2043
|
-
: { root: replaceAtomRevisions(location.root, oldRevisions, newRevision) };
|
|
2044
|
-
}
|
|
2045
|
-
function replaceFieldIdRevision(fieldId, oldRevisions, newRevision) {
|
|
1689
|
+
function replaceFieldIdRevision(fieldId, replacer) {
|
|
2046
1690
|
if (fieldId.nodeId === undefined) {
|
|
2047
1691
|
return fieldId;
|
|
2048
1692
|
}
|
|
2049
1693
|
return {
|
|
2050
1694
|
...fieldId,
|
|
2051
|
-
nodeId:
|
|
1695
|
+
nodeId: replacer.getUpdatedAtomId(fieldId.nodeId),
|
|
2052
1696
|
};
|
|
2053
1697
|
}
|
|
2054
|
-
export function
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
if (location.field !== undefined) {
|
|
2059
|
-
return { field: normalizeFieldId(location.field, changeset.nodeAliases) };
|
|
2060
|
-
}
|
|
2061
|
-
return location;
|
|
1698
|
+
export function getParentFieldId(changeset, nodeId) {
|
|
1699
|
+
const parentId = getFromChangeAtomIdMap(changeset.nodeToParent, nodeId);
|
|
1700
|
+
assert(parentId !== undefined, 0x9cb /* Parent field should be defined */);
|
|
1701
|
+
return normalizeFieldId(parentId, changeset.nodeAliases);
|
|
2062
1702
|
}
|
|
2063
1703
|
function getFieldsForCrossFieldKey(changeset, key, count) {
|
|
2064
1704
|
return changeset.crossFieldKeys
|
|
2065
1705
|
.getAll(key, count)
|
|
2066
1706
|
.map(({ value: fieldId }) => normalizeFieldId(fieldId, changeset.nodeAliases));
|
|
2067
1707
|
}
|
|
2068
|
-
function getFirstFieldForCrossFieldKey(changeset, key, count) {
|
|
2069
|
-
const result = changeset.crossFieldKeys.getFirst(key, count);
|
|
2070
|
-
if (result.value === undefined) {
|
|
2071
|
-
return result;
|
|
2072
|
-
}
|
|
2073
|
-
return { ...result, value: normalizeFieldId(result.value, changeset.nodeAliases) };
|
|
2074
|
-
}
|
|
2075
|
-
function normalizeNodeLocation(location, nodeAliases) {
|
|
2076
|
-
if (location.field !== undefined) {
|
|
2077
|
-
return { field: normalizeFieldId(location.field, nodeAliases) };
|
|
2078
|
-
}
|
|
2079
|
-
return location;
|
|
2080
|
-
}
|
|
2081
1708
|
// This is only exported for use in test utilities.
|
|
2082
1709
|
export function normalizeFieldId(fieldId, nodeAliases) {
|
|
2083
|
-
return fieldId.nodeId
|
|
2084
|
-
?
|
|
2085
|
-
: fieldId;
|
|
1710
|
+
return fieldId.nodeId === undefined
|
|
1711
|
+
? fieldId
|
|
1712
|
+
: { ...fieldId, nodeId: normalizeNodeId(fieldId.nodeId, nodeAliases) };
|
|
2086
1713
|
}
|
|
2087
1714
|
/**
|
|
2088
1715
|
* @returns The canonical form of nodeId, according to nodeAliases
|
|
2089
1716
|
*/
|
|
2090
|
-
|
|
1717
|
+
function normalizeNodeId(nodeId, nodeAliases) {
|
|
2091
1718
|
let currentId = nodeId;
|
|
2092
|
-
let cycleProbeId = nodeId;
|
|
2093
1719
|
// eslint-disable-next-line no-constant-condition
|
|
2094
1720
|
while (true) {
|
|
2095
1721
|
const dealiased = getFromChangeAtomIdMap(nodeAliases, currentId);
|
|
@@ -2097,13 +1723,6 @@ export function normalizeNodeId(nodeId, nodeAliases) {
|
|
|
2097
1723
|
return currentId;
|
|
2098
1724
|
}
|
|
2099
1725
|
currentId = dealiased;
|
|
2100
|
-
if (cycleProbeId !== undefined) {
|
|
2101
|
-
cycleProbeId = getFromChangeAtomIdMap(nodeAliases, cycleProbeId);
|
|
2102
|
-
}
|
|
2103
|
-
if (cycleProbeId !== undefined) {
|
|
2104
|
-
cycleProbeId = getFromChangeAtomIdMap(nodeAliases, cycleProbeId);
|
|
2105
|
-
}
|
|
2106
|
-
assert(!areEqualChangeAtomIdOpts(cycleProbeId, currentId), "Alias cycle detected");
|
|
2107
1726
|
}
|
|
2108
1727
|
}
|
|
2109
1728
|
function hasConflicts(change) {
|
|
@@ -2112,426 +1731,4 @@ function hasConflicts(change) {
|
|
|
2112
1731
|
function areEqualFieldIds(a, b) {
|
|
2113
1732
|
return areEqualChangeAtomIdOpts(a.nodeId, b.nodeId) && a.field === b.field;
|
|
2114
1733
|
}
|
|
2115
|
-
function firstAttachIdFromDetachId(roots, detachId, count) {
|
|
2116
|
-
const result = roots.oldToNewId.getFirst(detachId, count);
|
|
2117
|
-
return { ...result, value: result.value ?? detachId };
|
|
2118
|
-
}
|
|
2119
|
-
function firstDetachIdFromAttachId(roots, attachId, count) {
|
|
2120
|
-
const result = roots.newToOldId.getFirst(attachId, count);
|
|
2121
|
-
return { ...result, start: attachId, value: result.value ?? attachId };
|
|
2122
|
-
}
|
|
2123
|
-
function rebaseCrossFieldKeys(sourceTable, movedDetaches, newDetachLocations) {
|
|
2124
|
-
const rebasedTable = sourceTable.clone();
|
|
2125
|
-
for (const entry of movedDetaches.entries()) {
|
|
2126
|
-
rebasedTable.delete({ ...entry.start, target: CrossFieldTarget.Source }, entry.length);
|
|
2127
|
-
}
|
|
2128
|
-
for (const entry of newDetachLocations.entries()) {
|
|
2129
|
-
rebasedTable.set({ ...entry.start, target: CrossFieldTarget.Source }, entry.length, entry.value);
|
|
2130
|
-
}
|
|
2131
|
-
return rebasedTable;
|
|
2132
|
-
}
|
|
2133
|
-
export function newRootTable() {
|
|
2134
|
-
return {
|
|
2135
|
-
newToOldId: newChangeAtomIdTransform(),
|
|
2136
|
-
oldToNewId: newChangeAtomIdTransform(),
|
|
2137
|
-
nodeChanges: newTupleBTree(),
|
|
2138
|
-
detachLocations: newChangeAtomIdRangeMap(),
|
|
2139
|
-
outputDetachLocations: newChangeAtomIdRangeMap(),
|
|
2140
|
-
};
|
|
2141
|
-
}
|
|
2142
|
-
function rebaseRoots(change, base, affectedBaseFields, nodesToRebase, rebasedNodeToParent, rebaseVersion) {
|
|
2143
|
-
const rebasedRoots = newRootTable();
|
|
2144
|
-
for (const renameEntry of change.rootNodes.oldToNewId.entries()) {
|
|
2145
|
-
rebaseRename(change.rootNodes, rebasedRoots, renameEntry, base, affectedBaseFields);
|
|
2146
|
-
}
|
|
2147
|
-
for (const [detachIdKey, nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
2148
|
-
const changes = base.rootNodes.nodeChanges.get(detachIdKey);
|
|
2149
|
-
if (changes !== undefined) {
|
|
2150
|
-
nodesToRebase.push([nodeId, changes]);
|
|
2151
|
-
}
|
|
2152
|
-
const detachId = makeChangeAtomId(detachIdKey[1], detachIdKey[0]);
|
|
2153
|
-
const attachId = firstAttachIdFromDetachId(base.rootNodes, detachId, 1).value;
|
|
2154
|
-
const baseAttachEntry = base.crossFieldKeys.getFirst({ target: CrossFieldTarget.Destination, ...attachId }, 1);
|
|
2155
|
-
if (baseAttachEntry.value !== undefined) {
|
|
2156
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(baseAttachEntry.value), true);
|
|
2157
|
-
rebasedNodeToParent.delete(detachIdKey);
|
|
2158
|
-
}
|
|
2159
|
-
else {
|
|
2160
|
-
const renamedDetachId = firstAttachIdFromDetachId(base.rootNodes, detachId, 1).value;
|
|
2161
|
-
const baseOutputDetachLocation = base.rootNodes.outputDetachLocations.getFirst(renamedDetachId, 1).value;
|
|
2162
|
-
if (baseOutputDetachLocation !== undefined) {
|
|
2163
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(baseOutputDetachLocation), true);
|
|
2164
|
-
}
|
|
2165
|
-
const detachLocation = baseOutputDetachLocation ??
|
|
2166
|
-
change.rootNodes.detachLocations.getFirst(detachId, 1).value;
|
|
2167
|
-
// Note that `baseOutputDetachLocation` may contain a node ID from the base changeset.
|
|
2168
|
-
// We will replace the detach location entry with the node ID from the rebased changeset in `fixupRebasedDetachLocations`
|
|
2169
|
-
assignRootChange(rebasedRoots, rebasedNodeToParent, renamedDetachId, nodeId, detachLocation, rebaseVersion);
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
for (const entry of change.rootNodes.outputDetachLocations.entries()) {
|
|
2173
|
-
rebasedRoots.outputDetachLocations.set(entry.start, entry.length, entry.value);
|
|
2174
|
-
}
|
|
2175
|
-
return rebasedRoots;
|
|
2176
|
-
}
|
|
2177
|
-
function rebaseRename(newRoots, rebasedRoots, renameEntry, base, affectedBaseFields) {
|
|
2178
|
-
let count = renameEntry.length;
|
|
2179
|
-
const baseRenameEntry = firstAttachIdFromDetachId(base.rootNodes, renameEntry.start, count);
|
|
2180
|
-
count = baseRenameEntry.length;
|
|
2181
|
-
const baseAttachEntry = base.crossFieldKeys.getFirst({
|
|
2182
|
-
...baseRenameEntry.value,
|
|
2183
|
-
target: CrossFieldTarget.Destination,
|
|
2184
|
-
}, count);
|
|
2185
|
-
count = baseAttachEntry.length;
|
|
2186
|
-
if (baseAttachEntry.value !== undefined) {
|
|
2187
|
-
// This rename represents an intention to detach these nodes.
|
|
2188
|
-
// The rebased change should have a detach in the field where the base change attaches the nodes,
|
|
2189
|
-
// so we need to ensure that field is processed.
|
|
2190
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(normalizeFieldId(baseAttachEntry.value, base.nodeAliases)), true);
|
|
2191
|
-
}
|
|
2192
|
-
else {
|
|
2193
|
-
const baseOutputDetachLocation = base.rootNodes.outputDetachLocations.getFirst(baseRenameEntry.value, 1).value;
|
|
2194
|
-
if (baseOutputDetachLocation !== undefined) {
|
|
2195
|
-
affectedBaseFields.set(fieldIdKeyFromFieldId(baseOutputDetachLocation), true);
|
|
2196
|
-
}
|
|
2197
|
-
const detachEntry = newRoots.detachLocations.getFirst(renameEntry.start, count);
|
|
2198
|
-
count = detachEntry.length;
|
|
2199
|
-
const detachLocation = baseOutputDetachLocation ?? detachEntry.value;
|
|
2200
|
-
// Note that `baseOutputDetachLocation` may contain a node ID from the base changeset.
|
|
2201
|
-
// We will replace the detach location entry with the node ID from the rebased changeset in `fixupRebasedDetachLocations`
|
|
2202
|
-
addNodeRename(rebasedRoots, baseRenameEntry.value, renameEntry.value, count, detachLocation);
|
|
2203
|
-
}
|
|
2204
|
-
const countRemaining = renameEntry.length - count;
|
|
2205
|
-
if (countRemaining > 0) {
|
|
2206
|
-
rebaseRename(newRoots, rebasedRoots, {
|
|
2207
|
-
start: offsetChangeAtomId(renameEntry.start, count),
|
|
2208
|
-
value: offsetChangeAtomId(renameEntry.value, count),
|
|
2209
|
-
length: countRemaining,
|
|
2210
|
-
}, base, affectedBaseFields);
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
/**
|
|
2214
|
-
* For each root detach location, replaces any node ID from the base changeset
|
|
2215
|
-
* with the corresponding ID in the new changeset.
|
|
2216
|
-
*/
|
|
2217
|
-
function fixupRebasedDetachLocations(table) {
|
|
2218
|
-
for (const { start, length, value: detachLocation, } of table.rebasedRootNodes.detachLocations.entries()) {
|
|
2219
|
-
const normalizedDetachLocation = normalizeFieldId(detachLocation, table.baseChange.nodeAliases);
|
|
2220
|
-
if (normalizedDetachLocation.nodeId !== undefined) {
|
|
2221
|
-
const rebasedNodeId = getFromChangeAtomIdMap(table.baseToRebasedNodeId, normalizedDetachLocation.nodeId);
|
|
2222
|
-
if (rebasedNodeId !== undefined) {
|
|
2223
|
-
table.rebasedRootNodes.detachLocations.set(start, length, {
|
|
2224
|
-
...normalizedDetachLocation,
|
|
2225
|
-
nodeId: rebasedNodeId,
|
|
2226
|
-
});
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
function addNodesToCompose(table, id1, id2) {
|
|
2232
|
-
const normalizedId1 = normalizeNodeId(id1, table.baseChange.nodeAliases);
|
|
2233
|
-
const normalizedId2 = normalizeNodeId(id2, table.newChange.nodeAliases);
|
|
2234
|
-
if (getFromChangeAtomIdMap(table.newToBaseNodeId, normalizedId2) === undefined) {
|
|
2235
|
-
setInChangeAtomIdMap(table.newToBaseNodeId, normalizedId2, normalizedId1);
|
|
2236
|
-
table.pendingCompositions.nodeIdsToCompose.push([normalizedId1, normalizedId2]);
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
function composeRevInfos(revisions1, revisions2) {
|
|
2240
|
-
const result = [...(revisions1 ?? []), ...(revisions2 ?? [])];
|
|
2241
|
-
return result;
|
|
2242
|
-
}
|
|
2243
|
-
function composeCrossFieldKeyTables(table1, table2, movedCrossFieldKeys, removedCrossFieldKeys) {
|
|
2244
|
-
const composedTable = RangeMap.union(table1, table2);
|
|
2245
|
-
for (const entry of movedCrossFieldKeys.entries()) {
|
|
2246
|
-
composedTable.set(entry.start, entry.length, entry.value);
|
|
2247
|
-
}
|
|
2248
|
-
for (const entry of removedCrossFieldKeys.entries()) {
|
|
2249
|
-
composedTable.delete(entry.start, entry.length);
|
|
2250
|
-
}
|
|
2251
|
-
return composedTable;
|
|
2252
|
-
}
|
|
2253
|
-
function composeRootTables(change1, change2, composedNodeToParent, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions) {
|
|
2254
|
-
const composedTable = cloneRootTable(change1.rootNodes);
|
|
2255
|
-
for (const renameEntry of change2.rootNodes.oldToNewId.entries()) {
|
|
2256
|
-
composeRename(change1, change2, composedTable, renameEntry.start, renameEntry.value, renameEntry.length, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
2257
|
-
}
|
|
2258
|
-
for (const [[revision2, id2], nodeId2] of change2.rootNodes.nodeChanges.entries()) {
|
|
2259
|
-
const detachId2 = { revision: revision2, localId: id2 };
|
|
2260
|
-
const detachId1 = firstDetachIdFromAttachId(change1.rootNodes, detachId2, 1).value;
|
|
2261
|
-
const nodeId1 = getFromChangeAtomIdMap(change1.rootNodes.nodeChanges, detachId1);
|
|
2262
|
-
if (nodeId1 !== undefined) {
|
|
2263
|
-
pendingCompositions.nodeIdsToCompose.push([nodeId1, nodeId2]);
|
|
2264
|
-
}
|
|
2265
|
-
else {
|
|
2266
|
-
const fieldId = getFieldsForCrossFieldKey(change1, { ...detachId1, target: CrossFieldTarget.Source }, 1)[0];
|
|
2267
|
-
if (fieldId !== undefined) {
|
|
2268
|
-
// In this case, this node is attached in the input context of change1,
|
|
2269
|
-
// and is represented in detachFieldId.
|
|
2270
|
-
pendingCompositions.affectedBaseFields.set([fieldId.nodeId?.revision, fieldId.nodeId?.localId, fieldId.field], true);
|
|
2271
|
-
}
|
|
2272
|
-
else {
|
|
2273
|
-
assignRootChange(composedTable, composedNodeToParent, detachId1, nodeId2, change1.rootNodes.detachLocations.getFirst(detachId1, 1).value ??
|
|
2274
|
-
change2.rootNodes.detachLocations.getFirst(detachId2, 1).value, Math.max(change1.rebaseVersion, change2.rebaseVersion));
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
}
|
|
2278
|
-
for (const outputDetachEntry of change1.rootNodes.outputDetachLocations.entries()) {
|
|
2279
|
-
composeOutputDetachLocation(outputDetachEntry.start, outputDetachEntry.length, outputDetachEntry.value, change2, composedTable);
|
|
2280
|
-
}
|
|
2281
|
-
for (const entry of change2.rootNodes.outputDetachLocations.entries()) {
|
|
2282
|
-
composedTable.outputDetachLocations.set(entry.start, entry.length, entry.value);
|
|
2283
|
-
}
|
|
2284
|
-
return composedTable;
|
|
2285
|
-
}
|
|
2286
|
-
function composeOutputDetachLocation(outputDetachId1, count, detachLocation, change2, composedTable) {
|
|
2287
|
-
let countToProcess = count;
|
|
2288
|
-
const renameEntry = firstAttachIdFromDetachId(change2.rootNodes, outputDetachId1, countToProcess);
|
|
2289
|
-
countToProcess = renameEntry.length;
|
|
2290
|
-
const attachEntry = getFirstAttachField(change2.crossFieldKeys, renameEntry.value, countToProcess);
|
|
2291
|
-
countToProcess = attachEntry.length;
|
|
2292
|
-
composedTable.outputDetachLocations.delete(outputDetachId1, countToProcess);
|
|
2293
|
-
if (attachEntry.value === undefined) {
|
|
2294
|
-
// We update the key for the detach location to the renamed ID of the root in the composed output context.
|
|
2295
|
-
composedTable.outputDetachLocations.set(renameEntry.value, countToProcess, detachLocation);
|
|
2296
|
-
}
|
|
2297
|
-
else {
|
|
2298
|
-
// These nodes are attached by `change2` and thus attached in the composed output context,
|
|
2299
|
-
// so there should be no output detach location.
|
|
2300
|
-
}
|
|
2301
|
-
const countRemaining = count - countToProcess;
|
|
2302
|
-
if (countRemaining > 0) {
|
|
2303
|
-
composeOutputDetachLocation(offsetChangeAtomId(outputDetachId1, countToProcess), countRemaining, detachLocation, change2, composedTable);
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
function composeRename(change1, change2, mergedTable, oldId, newId, count, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions) {
|
|
2307
|
-
let countToProcess = count;
|
|
2308
|
-
const detachEntry = getFirstDetachField(change1.crossFieldKeys, oldId, countToProcess);
|
|
2309
|
-
countToProcess = detachEntry.length;
|
|
2310
|
-
if (detachEntry.value !== undefined) {
|
|
2311
|
-
// `change1` detached these nodes,
|
|
2312
|
-
// so we invalidate the detach location so that the detach's ID can be replaced with the new ID.
|
|
2313
|
-
pendingCompositions.affectedBaseFields.set(fieldIdKeyFromFieldId(detachEntry.value), true);
|
|
2314
|
-
if (!areEqualChangeAtomIds(oldId, newId)) {
|
|
2315
|
-
// `change1`'s detach will be replaced by `change2`'s detach, so we update the cross-field keys.
|
|
2316
|
-
removedCrossFieldKeys.set({ ...oldId, target: CrossFieldTarget.Source }, countToProcess, true);
|
|
2317
|
-
}
|
|
2318
|
-
movedCrossFieldKeys.set({ ...newId, target: CrossFieldTarget.Source }, countToProcess, detachEntry.value);
|
|
2319
|
-
}
|
|
2320
|
-
else {
|
|
2321
|
-
// `change1` may also have a rename to `renameEntry.value`, in which case it must refer to a different node.
|
|
2322
|
-
// That node must have been attached by `change1` and detached by `change2`.
|
|
2323
|
-
// The final rename for that node will be created in `composeAttachDetach`.
|
|
2324
|
-
// We delete any such rename for now to avoid colliding with the rename currently being processed.
|
|
2325
|
-
deleteNodeRenameTo(mergedTable, newId, countToProcess);
|
|
2326
|
-
// The nodes were detached before `change`, so we append this rename.
|
|
2327
|
-
appendNodeRename(mergedTable, oldId, newId, countToProcess, change1.rootNodes, change2.rootNodes.detachLocations.getFirst(oldId, countToProcess).value);
|
|
2328
|
-
}
|
|
2329
|
-
if (countToProcess < count) {
|
|
2330
|
-
composeRename(change1, change2, mergedTable, offsetChangeAtomId(oldId, countToProcess), offsetChangeAtomId(newId, countToProcess), count - countToProcess, movedCrossFieldKeys, removedCrossFieldKeys, pendingCompositions);
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
export function cloneRootTable(table) {
|
|
2334
|
-
return {
|
|
2335
|
-
oldToNewId: table.oldToNewId.clone(),
|
|
2336
|
-
newToOldId: table.newToOldId.clone(),
|
|
2337
|
-
nodeChanges: brand(table.nodeChanges.clone()),
|
|
2338
|
-
detachLocations: table.detachLocations.clone(),
|
|
2339
|
-
outputDetachLocations: table.outputDetachLocations.clone(),
|
|
2340
|
-
};
|
|
2341
|
-
}
|
|
2342
|
-
function invertRootTable(change, isRollback) {
|
|
2343
|
-
const invertedRoots = newRootTable();
|
|
2344
|
-
for (const [[revision, localId], nodeId] of change.rootNodes.nodeChanges.entries()) {
|
|
2345
|
-
const detachId = { revision, localId };
|
|
2346
|
-
const renamedId = firstAttachIdFromDetachId(change.rootNodes, detachId, 1).value;
|
|
2347
|
-
// This checks whether `change` attaches this node.
|
|
2348
|
-
// 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.
|
|
2349
|
-
if (change.crossFieldKeys.getFirst({ ...renamedId, target: CrossFieldTarget.Destination }, 1)
|
|
2350
|
-
.value === undefined) {
|
|
2351
|
-
assignRootChange(invertedRoots, undefined, renamedId, nodeId, change.rootNodes.detachLocations.getFirst(detachId, 1).value, change.rebaseVersion);
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
if (isRollback) {
|
|
2355
|
-
// We only invert renames of nodes which are not attached or detached by this changeset.
|
|
2356
|
-
// When we invert an attach we will create a detach which incorporates the rename.
|
|
2357
|
-
for (const { start: oldId, value: newId, length, } of change.rootNodes.oldToNewId.entries()) {
|
|
2358
|
-
invertRename(change, invertedRoots, oldId, newId, length);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return invertedRoots;
|
|
2362
|
-
}
|
|
2363
|
-
function invertRename(change, invertedRoots, oldId, newId, length) {
|
|
2364
|
-
for (const detachEntry of doesChangeDetachNodes(change.crossFieldKeys, newId, length)) {
|
|
2365
|
-
assert(!detachEntry.value, "A changeset should not have a rename and detach for the same node.");
|
|
2366
|
-
}
|
|
2367
|
-
let countProcessed = length;
|
|
2368
|
-
const attachEntry = getFirstAttachField(change.crossFieldKeys, newId, countProcessed);
|
|
2369
|
-
countProcessed = attachEntry.length;
|
|
2370
|
-
if (attachEntry.value === undefined) {
|
|
2371
|
-
const outputDetachEntry = change.rootNodes.outputDetachLocations.getFirst(newId, countProcessed);
|
|
2372
|
-
countProcessed = outputDetachEntry.length;
|
|
2373
|
-
const inputDetachEntry = change.rootNodes.detachLocations.getFirst(oldId, countProcessed);
|
|
2374
|
-
countProcessed = inputDetachEntry.length;
|
|
2375
|
-
addNodeRename(invertedRoots, newId, oldId, countProcessed, outputDetachEntry.value ?? inputDetachEntry.value);
|
|
2376
|
-
}
|
|
2377
|
-
if (countProcessed < length) {
|
|
2378
|
-
invertRename(change, invertedRoots, offsetChangeAtomId(oldId, countProcessed), offsetChangeAtomId(newId, countProcessed), length - countProcessed);
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
function doesChangeAttachNodes(table, id, count) {
|
|
2382
|
-
return table
|
|
2383
|
-
.getAll2({ ...id, target: CrossFieldTarget.Destination }, count)
|
|
2384
|
-
.map((entry) => ({ ...entry, value: entry.value !== undefined }));
|
|
2385
|
-
}
|
|
2386
|
-
function doesChangeDetachNodes(table, id, count) {
|
|
2387
|
-
return table
|
|
2388
|
-
.getAll2({ ...id, target: CrossFieldTarget.Source }, count)
|
|
2389
|
-
.map((entry) => ({ ...entry, value: entry.value !== undefined }));
|
|
2390
|
-
}
|
|
2391
|
-
export function getFirstDetachField(table, id, count) {
|
|
2392
|
-
return table.getFirst({ target: CrossFieldTarget.Source, ...id }, count);
|
|
2393
|
-
}
|
|
2394
|
-
export function getFirstAttachField(table, id, count) {
|
|
2395
|
-
return table.getFirst({ target: CrossFieldTarget.Destination, ...id }, count);
|
|
2396
|
-
}
|
|
2397
|
-
export function addNodeRename(table, oldId, newId, count, detachLocation) {
|
|
2398
|
-
if (areEqualChangeAtomIds(oldId, newId)) {
|
|
2399
|
-
return;
|
|
2400
|
-
}
|
|
2401
|
-
for (const entry of table.oldToNewId.getAll2(oldId, count)) {
|
|
2402
|
-
assert(entry.value === undefined ||
|
|
2403
|
-
areEqualChangeAtomIds(entry.value, offsetChangeAtomId(newId, entry.offset)), "Rename collision detected");
|
|
2404
|
-
}
|
|
2405
|
-
for (const entry of table.newToOldId.getAll2(newId, count)) {
|
|
2406
|
-
assert(entry.value === undefined ||
|
|
2407
|
-
areEqualChangeAtomIds(entry.value, offsetChangeAtomId(oldId, entry.offset)), "Rename collision detected");
|
|
2408
|
-
}
|
|
2409
|
-
table.oldToNewId.set(oldId, count, newId);
|
|
2410
|
-
table.newToOldId.set(newId, count, oldId);
|
|
2411
|
-
if (detachLocation !== undefined) {
|
|
2412
|
-
table.detachLocations.set(oldId, count, detachLocation);
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
/**
|
|
2416
|
-
* Deletes any renames from `id`.
|
|
2417
|
-
*/
|
|
2418
|
-
function deleteNodeRenameFrom(roots, id, count) {
|
|
2419
|
-
for (const entry of roots.oldToNewId.getAll(id, count)) {
|
|
2420
|
-
deleteNodeRenameEntry(roots, entry.start, entry.value, entry.length);
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
/**
|
|
2424
|
-
* Deletes any renames to `id`.
|
|
2425
|
-
*/
|
|
2426
|
-
function deleteNodeRenameTo(roots, id, count) {
|
|
2427
|
-
for (const entry of roots.newToOldId.getAll(id, count)) {
|
|
2428
|
-
deleteNodeRenameEntry(roots, entry.value, entry.start, entry.length);
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
|
-
function appendNodeRename(composedTable, oldId, newId, count, change1Table, detachLocation) {
|
|
2432
|
-
let countToProcess = count;
|
|
2433
|
-
const rename1Entry = change1Table.newToOldId.getFirst(oldId, countToProcess);
|
|
2434
|
-
countToProcess = rename1Entry.length;
|
|
2435
|
-
if (rename1Entry.value !== undefined) {
|
|
2436
|
-
deleteNodeRenameFrom(composedTable, rename1Entry.value, countToProcess);
|
|
2437
|
-
}
|
|
2438
|
-
addNodeRename(composedTable, rename1Entry.value ?? oldId, newId, countToProcess, detachLocation);
|
|
2439
|
-
tryRemoveDetachLocation(composedTable, newId, countToProcess);
|
|
2440
|
-
if (countToProcess < count) {
|
|
2441
|
-
const countRemaining = count - countToProcess;
|
|
2442
|
-
appendNodeRename(composedTable, offsetChangeAtomId(oldId, countToProcess), offsetChangeAtomId(newId, countToProcess), countRemaining, change1Table, detachLocation);
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
function tryRemoveDetachLocation(roots, rootId, count) {
|
|
2446
|
-
let countProcessed = count;
|
|
2447
|
-
const renameEntry = roots.oldToNewId.getFirst(rootId, countProcessed);
|
|
2448
|
-
countProcessed = renameEntry.length;
|
|
2449
|
-
const outputDetachEntry = roots.outputDetachLocations.getFirst(rootId, countProcessed);
|
|
2450
|
-
countProcessed = outputDetachEntry.length;
|
|
2451
|
-
const nodeChangeEntry = rangeQueryChangeAtomIdMap(roots.nodeChanges, rootId, countProcessed);
|
|
2452
|
-
countProcessed = nodeChangeEntry.length;
|
|
2453
|
-
if (nodeChangeEntry.value === undefined &&
|
|
2454
|
-
renameEntry.value === undefined &&
|
|
2455
|
-
outputDetachEntry.value === undefined) {
|
|
2456
|
-
roots.detachLocations.delete(rootId, countProcessed);
|
|
2457
|
-
}
|
|
2458
|
-
const countRemaining = count - countProcessed;
|
|
2459
|
-
if (countRemaining > 0) {
|
|
2460
|
-
tryRemoveDetachLocation(roots, offsetChangeAtomId(rootId, countProcessed), countRemaining);
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
/**
|
|
2464
|
-
* Deletes the entry renaming the ID range of length `count` from `oldId` to `newId`.
|
|
2465
|
-
* This function assumes that such an entry exists.
|
|
2466
|
-
*/
|
|
2467
|
-
function deleteNodeRenameEntry(roots, oldId, newId, count) {
|
|
2468
|
-
roots.oldToNewId.delete(oldId, count);
|
|
2469
|
-
roots.newToOldId.delete(newId, count);
|
|
2470
|
-
}
|
|
2471
|
-
function replaceRootTableRevision(table, oldRevisions, newRevision, nodeAliases) {
|
|
2472
|
-
const oldToNewId = table.oldToNewId.mapEntries((id) => replaceAtomRevisions(id, oldRevisions, newRevision), (id) => replaceAtomRevisions(id, oldRevisions, newRevision));
|
|
2473
|
-
const newToOldId = table.newToOldId.mapEntries((id) => replaceAtomRevisions(id, oldRevisions, newRevision), (id) => replaceAtomRevisions(id, oldRevisions, newRevision));
|
|
2474
|
-
const nodeChanges = newTupleBTree([...table.nodeChanges.entries()].map(([[revision, id], nodeId]) => [
|
|
2475
|
-
[oldRevisions.has(revision) ? newRevision : revision, id],
|
|
2476
|
-
replaceAtomRevisions(normalizeNodeId(nodeId, nodeAliases), oldRevisions, newRevision),
|
|
2477
|
-
]));
|
|
2478
|
-
const detachLocations = table.detachLocations.mapEntries((id) => replaceAtomRevisions(id, oldRevisions, newRevision), (fieldId) => replaceFieldIdRevision(normalizeFieldId(fieldId, nodeAliases), oldRevisions, newRevision));
|
|
2479
|
-
const outputDetachLocations = table.outputDetachLocations.mapEntries((id) => replaceAtomRevisions(id, oldRevisions, newRevision), (fieldId) => replaceFieldIdRevision(normalizeFieldId(fieldId, nodeAliases), oldRevisions, newRevision));
|
|
2480
|
-
return { oldToNewId, newToOldId, nodeChanges, detachLocations, outputDetachLocations };
|
|
2481
|
-
}
|
|
2482
|
-
function newDetachedEntryMap() {
|
|
2483
|
-
return new RangeMap(offsetChangeAtomId, subtractChangeAtomIds, offsetDetachedNodeEntry);
|
|
2484
|
-
}
|
|
2485
|
-
function offsetDetachedNodeEntry(entry, count) {
|
|
2486
|
-
assert(count <= 1 || entry.nodeChange === undefined, "Cannot split an entry with a node change");
|
|
2487
|
-
return entry.detachId !== undefined
|
|
2488
|
-
? { ...entry, detachId: offsetChangeAtomId(entry.detachId, count) }
|
|
2489
|
-
: entry;
|
|
2490
|
-
}
|
|
2491
|
-
function getFieldsWithRootMoves(roots, nodeAliases) {
|
|
2492
|
-
const fields = newTupleBTree();
|
|
2493
|
-
for (const { start: rootId, value: fieldId, length } of roots.detachLocations.entries()) {
|
|
2494
|
-
let isRootMoved = false;
|
|
2495
|
-
for (const renameEntry of roots.oldToNewId.getAll2(rootId, length)) {
|
|
2496
|
-
if (renameEntry.value !== undefined) {
|
|
2497
|
-
isRootMoved = true;
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
for (const outputDetachEntry of roots.outputDetachLocations.getAll2(rootId, length)) {
|
|
2501
|
-
if (outputDetachEntry.value !== undefined) {
|
|
2502
|
-
isRootMoved = true;
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
if (isRootMoved) {
|
|
2506
|
-
fields.set(fieldIdKeyFromFieldId(normalizeFieldId(fieldId, nodeAliases)), true);
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
return fields;
|
|
2510
|
-
}
|
|
2511
|
-
function getFieldToRootChanges(roots, nodeAliases) {
|
|
2512
|
-
const fields = newTupleBTree();
|
|
2513
|
-
for (const rootIdKey of roots.nodeChanges.keys()) {
|
|
2514
|
-
const rootId = { revision: rootIdKey[0], localId: rootIdKey[1] };
|
|
2515
|
-
const detachLocation = roots.detachLocations.getFirst(rootId, 1).value;
|
|
2516
|
-
if (detachLocation !== undefined) {
|
|
2517
|
-
const fieldIdKey = fieldIdKeyFromFieldId(normalizeFieldId(detachLocation, nodeAliases));
|
|
2518
|
-
let rootsInField = fields.get(fieldIdKey);
|
|
2519
|
-
if (rootsInField === undefined) {
|
|
2520
|
-
rootsInField = [];
|
|
2521
|
-
fields.set(fieldIdKey, rootsInField);
|
|
2522
|
-
}
|
|
2523
|
-
rootsInField.push(rootId);
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
return fields;
|
|
2527
|
-
}
|
|
2528
|
-
function muteRootChanges(roots) {
|
|
2529
|
-
return {
|
|
2530
|
-
oldToNewId: newChangeAtomIdTransform(),
|
|
2531
|
-
newToOldId: newChangeAtomIdTransform(),
|
|
2532
|
-
nodeChanges: brand(roots.nodeChanges.clone()),
|
|
2533
|
-
detachLocations: roots.detachLocations.clone(),
|
|
2534
|
-
outputDetachLocations: newChangeAtomIdRangeMap(),
|
|
2535
|
-
};
|
|
2536
|
-
}
|
|
2537
1734
|
//# sourceMappingURL=modularChangeFamily.js.map
|