@fluidframework/tree 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/api-report/tree.alpha.api.md +2 -2
- package/api-report/tree.beta.api.md +1 -1
- package/api-report/tree.legacy.alpha.api.md +1 -1
- package/api-report/tree.legacy.public.api.md +1 -1
- package/api-report/tree.public.api.md +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +2 -9
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/schema-stored/format.d.ts +0 -3
- package/dist/core/schema-stored/format.d.ts.map +1 -1
- package/dist/core/schema-stored/format.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +12 -10
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -5
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/schema-view/index.d.ts +1 -1
- package/dist/core/schema-view/index.d.ts.map +1 -1
- package/dist/core/schema-view/index.js +1 -2
- package/dist/core/schema-view/index.js.map +1 -1
- package/dist/core/schema-view/view.d.ts +0 -7
- package/dist/core/schema-view/view.d.ts.map +1 -1
- package/dist/core/schema-view/view.js +1 -12
- package/dist/core/schema-view/view.js.map +1 -1
- package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
- package/dist/core/tree/chunk.d.ts.map +1 -0
- package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.js +2 -2
- package/dist/core/tree/chunk.js.map +1 -0
- package/dist/core/tree/index.d.ts +1 -0
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +5 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/treeTextFormat.d.ts +0 -5
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/core/tree/types.d.ts +0 -5
- package/dist/core/tree/types.d.ts.map +1 -1
- package/dist/core/tree/types.js +0 -1
- package/dist/core/tree/types.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -14
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -3
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/emptyChunk.js +2 -3
- package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +5 -5
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/sequenceChunk.js +2 -2
- package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +13 -13
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
- package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js +2 -1
- package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +6 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +31 -5
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
- package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/discrepancies.js +32 -33
- package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +5 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -1
- package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
- package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
- package/dist/feature-libraries/sequence-field/formatV1.d.ts +99 -99
- package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV2.d.ts +76 -76
- package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/formatV3.d.ts +54 -54
- package/dist/feature-libraries/sequence-field/types.d.ts +0 -1
- 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/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -14
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/index.d.ts +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 +1 -1
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +6 -6
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +8 -12
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +25 -7
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +104 -15
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +35 -12
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +159 -127
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +13 -35
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +12 -77
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +7 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +16 -18
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +2 -2
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +3 -3
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +2 -2
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -9
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +4 -16
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +38 -0
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +118 -6
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +5 -1
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +14 -2
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +53 -3
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +4 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +48 -0
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +5 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/simpleSchema.d.ts +3 -1
- package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +3 -1
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +4 -4
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +8 -21
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +1 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/api/view.d.ts +14 -9
- package/dist/simple-tree/api/view.d.ts.map +1 -1
- package/dist/simple-tree/api/view.js +129 -40
- package/dist/simple-tree/api/view.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +0 -15
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +0 -15
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +8 -3
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +18 -2
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +4 -0
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +4 -2
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +18 -13
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/util/brand.d.ts +0 -2
- package/dist/util/brand.d.ts.map +1 -1
- package/dist/util/brand.js +0 -1
- package/dist/util/brand.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeCheck.d.ts +0 -2
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/utils.d.ts +13 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +23 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +3 -10
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/schema-stored/format.d.ts +0 -3
- package/lib/core/schema-stored/format.d.ts.map +1 -1
- package/lib/core/schema-stored/format.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +12 -10
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -5
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/schema-view/index.d.ts +1 -1
- package/lib/core/schema-view/index.d.ts.map +1 -1
- package/lib/core/schema-view/index.js +1 -1
- package/lib/core/schema-view/index.js.map +1 -1
- package/lib/core/schema-view/view.d.ts +0 -7
- package/lib/core/schema-view/view.d.ts.map +1 -1
- package/lib/core/schema-view/view.js +0 -11
- package/lib/core/schema-view/view.js.map +1 -1
- package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
- package/lib/core/tree/chunk.d.ts.map +1 -0
- package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.js +1 -1
- package/lib/core/tree/chunk.js.map +1 -0
- package/lib/core/tree/index.d.ts +1 -0
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -0
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/treeTextFormat.d.ts +0 -5
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/core/tree/types.d.ts +0 -5
- package/lib/core/tree/types.d.ts.map +1 -1
- package/lib/core/tree/types.js +0 -1
- package/lib/core/tree/types.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -2
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -2
- package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.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/defaultSchema.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
- package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js +2 -1
- package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +31 -5
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
- package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/discrepancies.js +25 -28
- package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -1
- package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
- package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
- package/lib/feature-libraries/sequence-field/formatV1.d.ts +99 -99
- package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV2.d.ts +76 -76
- package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/formatV3.d.ts +54 -54
- package/lib/feature-libraries/sequence-field/types.d.ts +0 -1
- 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/index.d.ts +4 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/index.d.ts +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 +1 -1
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +7 -7
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +10 -14
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +25 -7
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +105 -16
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +35 -12
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +161 -129
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +13 -35
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +12 -76
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +7 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +16 -18
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +3 -3
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +3 -3
- 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/sharedTreeCore.d.ts +2 -9
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +4 -16
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +38 -0
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +112 -1
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js +2 -2
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +5 -1
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +14 -2
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +50 -2
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +48 -0
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +4 -1
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/simpleSchema.d.ts +3 -1
- package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +3 -1
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +4 -4
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +5 -18
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +1 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +2 -2
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/api/view.d.ts +14 -9
- package/lib/simple-tree/api/view.d.ts.map +1 -1
- package/lib/simple-tree/api/view.js +131 -42
- package/lib/simple-tree/api/view.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +0 -15
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +0 -15
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +8 -3
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +16 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +4 -0
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +4 -2
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +19 -14
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/util/brand.d.ts +0 -2
- package/lib/util/brand.d.ts.map +1 -1
- package/lib/util/brand.js +0 -1
- package/lib/util/brand.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/typeCheck.d.ts +0 -2
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/utils.d.ts +13 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +21 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +22 -22
- package/src/core/index.ts +5 -1
- package/src/core/rebase/utils.ts +17 -20
- package/src/core/schema-stored/format.ts +0 -3
- package/src/core/schema-stored/schema.ts +13 -10
- package/src/core/schema-view/index.ts +0 -1
- package/src/core/schema-view/view.ts +0 -11
- package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
- package/src/core/tree/index.ts +8 -0
- package/src/core/tree/treeTextFormat.ts +0 -5
- package/src/core/tree/types.ts +0 -5
- package/src/feature-libraries/chunked-forest/basicChunk.ts +4 -2
- package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +1 -2
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -2
- package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
- package/src/feature-libraries/chunked-forest/emptyChunk.ts +4 -2
- package/src/feature-libraries/chunked-forest/index.ts +1 -1
- package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +4 -1
- package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
- package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
- package/src/feature-libraries/index.ts +13 -0
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +34 -5
- package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
- package/src/feature-libraries/modular-schema/index.ts +13 -0
- package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
- package/src/feature-libraries/sequence-field/types.ts +0 -1
- package/src/index.ts +1 -29
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +1 -0
- package/src/shared-tree/schematizeTree.ts +6 -10
- package/src/shared-tree/schematizingTreeView.ts +11 -21
- package/src/shared-tree/sharedTree.ts +173 -41
- package/src/shared-tree/treeCheckout.ts +224 -175
- package/src/shared-tree-core/branch.ts +29 -122
- package/src/shared-tree-core/branchCommitEnricher.ts +19 -20
- package/src/shared-tree-core/editManager.ts +3 -8
- package/src/shared-tree-core/index.ts +2 -1
- package/src/shared-tree-core/sharedTreeCore.ts +8 -19
- package/src/shared-tree-core/transaction.ts +145 -0
- package/src/simple-tree/api/conciseTree.ts +2 -2
- package/src/simple-tree/api/create.ts +5 -1
- package/src/simple-tree/api/customTree.ts +69 -1
- package/src/simple-tree/api/index.ts +12 -2
- package/src/simple-tree/api/schemaFactory.ts +62 -1
- package/src/simple-tree/api/simpleSchema.ts +3 -1
- package/src/simple-tree/api/simpleTreeIndex.ts +2 -0
- package/src/simple-tree/api/storedSchema.ts +7 -22
- package/src/simple-tree/api/tree.ts +6 -0
- package/src/simple-tree/api/verboseTree.ts +2 -2
- package/src/simple-tree/api/view.ts +197 -51
- package/src/simple-tree/index.ts +6 -0
- package/src/simple-tree/leafNodeSchema.ts +0 -19
- package/src/simple-tree/objectNode.ts +26 -2
- package/src/simple-tree/objectNodeTypes.ts +5 -0
- package/src/simple-tree/schemaTypes.ts +7 -2
- package/src/simple-tree/toStoredSchema.ts +25 -19
- package/src/util/brand.ts +0 -2
- package/src/util/index.ts +1 -0
- package/src/util/typeCheck.ts +0 -2
- package/src/util/utils.ts +26 -0
- package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
- package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
- package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
- package/lib/feature-libraries/chunked-forest/chunk.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/shared-tree-core/branch.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,kEAA6D;AAC7D,uEAA+F;AAE/F,+CAc0B;AAE1B,+DAA6D;AAE7D,+CAA2C;AAoC3C;;GAEG;AACH,SAAgB,oBAAoB,CACnC,MAA6D;IAE7D,uHAAuH;IACvH,oGAAoG;IACpG,2DAA2D;IAC3D,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,iGAAiG;IACjG,0FAA0F;IAC1F,EAAE;IACF,+DAA+D;IAC/D,gEAAgE;IAChE,EAAE;IACF,uEAAuE;IACvE,IAAA,iBAAM,EACL,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,EACtC,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACF,IAAA,iBAAM,EACL,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,EAClC,KAAK,CAAC,sEAAsE,CAC5E,CAAC;IACF,IACC,MAAM,CAAC,cAAc,CAA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AE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAC3C,CAAC;AAZD,4CAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type TelemetryEventBatcher, measure } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype BranchRebaseResult,\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tCommitKind,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\tfindAncestor,\n\tmakeAnonChange,\n\tmintCommit,\n\trebaseBranch,\n\ttagRollbackInverse,\n\ttype RebaseStatsWithDuration,\n} from \"../core/index.js\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\n\nimport { hasSome } from \"../util/index.js\";\n\n/**\n * Describes a change to a `SharedTreeBranch`. Various operations can mutate the head of the branch;\n * this change format describes each in terms of the \"removed commits\" (all commits which were present\n * on the branch before the operation but are no longer present after) and the \"new commits\" (all\n * commits which are present on the branch after the operation that were not present before). Each of\n * the following event types also provides a `change` which contains the net change to the branch\n * (or is undefined if there was no net change):\n * * Append - when one or more commits are appended to the head of the branch, for example via\n * a change applied by the branch's editor, or as a result of merging another branch into this one\n * * Remove - when one or more commits are removed from the head of the branch. This occurs\n * when a transaction is aborted and all commits pending in that transaction are removed.\n * * Replace - when an operation simultaneously removes and appends commits. For example, when this\n * branch is rebased and some commits are removed and replaced with rebased versions, or when a\n * transaction completes and all pending commits are replaced with a single squash commit.\n */\nexport type SharedTreeBranchChange<TChange> =\n\t| {\n\t\t\ttype: \"append\";\n\t\t\tkind: CommitKind;\n\t\t\tchange: TaggedChange<TChange>;\n\t\t\tnewCommits: readonly [GraphCommit<TChange>, ...GraphCommit<TChange>[]];\n\t }\n\t| {\n\t\t\ttype: \"remove\";\n\t\t\tchange: TaggedChange<TChange> | undefined;\n\t\t\tremovedCommits: readonly [GraphCommit<TChange>, ...GraphCommit<TChange>[]];\n\t }\n\t| {\n\t\t\ttype: \"replace\";\n\t\t\tchange: TaggedChange<TChange> | undefined;\n\t\t\tremovedCommits: readonly GraphCommit<TChange>[];\n\t\t\tnewCommits: readonly GraphCommit<TChange>[];\n\t };\n\n/**\n * Returns the operation that caused the given {@link SharedTreeBranchChange}.\n */\nexport function getChangeReplaceType(\n\tchange: SharedTreeBranchChange<unknown> & { type: \"replace\" },\n): \"transactionCommit\" | \"rebase\" {\n\t// The \"replace\" variant of the change event is emitted by two operations: committing a transaction and doing a rebase.\n\t// Committing a transaction will always remove one or more commits (the commits that were squashed),\n\t// and will add exactly one new commit (the squash commit).\n\tif (change.removedCommits.length === 0 || change.newCommits.length !== 1) {\n\t\treturn \"rebase\";\n\t}\n\n\t// There is only one case in which a rebase both removes commits and adds exactly one new commit.\n\t// This occurs when there is exactly one divergent, but equivalent, commit on each branch:\n\t//\n\t// A ─ B (branch X)\t -- rebase Y onto X --> A ─ B (branch X)\n\t// └─ B' (branch Y) └─ (branch Y)\n\t//\n\t// B' is removed and replaced by B because both have the same revision.\n\tassert(\n\t\tchange.removedCommits[0] !== undefined,\n\t\t0x9e4 /* This wont run due to the length check above */,\n\t);\n\tassert(\n\t\tchange.newCommits[0] !== undefined,\n\t\t0x9e5 /* This wont run because a replace operation always has new commits */,\n\t);\n\tif (\n\t\tchange.removedCommits.length === 1 &&\n\t\tchange.removedCommits[0].revision === change.newCommits[0].revision\n\t) {\n\t\treturn \"rebase\";\n\t}\n\n\treturn \"transactionCommit\";\n}\n\n/**\n * The events emitted by a `SharedTreeBranch`\n */\nexport interface SharedTreeBranchEvents<TEditor extends ChangeFamilyEditor, TChange>\n\textends BranchTrimmingEvents {\n\t/**\n\t * Fired just before the head of this branch changes.\n\t * @param change - the change to this branch's state and commits\n\t */\n\tbeforeChange(change: SharedTreeBranchChange<TChange>): void;\n\n\t/**\n\t * Fired just after the head of this branch changes.\n\t * @param change - the change to this branch's state and commits\n\t */\n\tafterChange(change: SharedTreeBranchChange<TChange>): void;\n\n\t/**\n\t * Fired when this branch forks\n\t * @param fork - the new branch that forked off of this branch\n\t */\n\tfork(fork: SharedTreeBranch<TEditor, TChange>): void;\n\n\t/**\n\t * Fired after this branch is disposed\n\t */\n\tdispose(): void;\n}\n\n/**\n * Events related to branch trimming.\n *\n * @remarks\n * Trimming is a very specific kind of mutation which is the only allowed mutations to branches.\n * References to commits from other commits are removed so that the commit objects can be GC'd by the JS engine.\n * This happens by changing a commit's parent property to undefined, which drops all commits that are in its \"ancestry\".\n * It is done as a performance optimization when it is determined that commits are no longer needed for future computation.\n */\nexport interface BranchTrimmingEvents {\n\t/**\n\t * Fired when some contiguous range of commits beginning with the \"global tail\" of this branch are trimmed from the branch.\n\t * This happens by deleting the parent pointer to the last commit in that range. This event can be fired at any time.\n\t */\n\tancestryTrimmed(trimmedRevisions: RevisionTag[]): void;\n}\n\n/**\n * A branch of changes that can be applied to a SharedTree.\n */\nexport class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChange> {\n\treadonly #events = createEmitter<SharedTreeBranchEvents<TEditor, TChange>>();\n\tpublic readonly events: Listenable<SharedTreeBranchEvents<TEditor, TChange>> = this.#events;\n\tpublic readonly editor: TEditor;\n\tprivate disposed = false;\n\tprivate readonly unsubscribeBranchTrimmer?: () => void;\n\t/**\n\t * Construct a new branch.\n\t * @param head - the head of the branch\n\t * @param changeFamily - determines the set of changes that this branch can commit\n\t * @param branchTrimmer - an optional event emitter that informs the branch it has been trimmed. If this is not supplied, then the branch must\n\t * never be trimmed. See {@link BranchTrimmingEvents} for details on trimming.\n\t */\n\tpublic constructor(\n\t\tprivate head: GraphCommit<TChange>,\n\t\tpublic readonly changeFamily: ChangeFamily<TEditor, TChange>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly branchTrimmer?: Listenable<BranchTrimmingEvents>,\n\t\tprivate readonly telemetryEventBatcher?: TelemetryEventBatcher<\n\t\t\tkeyof RebaseStatsWithDuration\n\t\t>,\n\t) {\n\t\tthis.editor = this.changeFamily.buildEditor(mintRevisionTag, (change) =>\n\t\t\tthis.apply(change),\n\t\t);\n\t\tthis.unsubscribeBranchTrimmer = branchTrimmer?.on(\"ancestryTrimmed\", (commit) => {\n\t\t\tthis.#events.emit(\"ancestryTrimmed\", commit);\n\t\t});\n\t}\n\n\t/**\n\t * Sets the head of this branch.\n\t * @remarks This is a \"manual override\" of sorts, for when the branch needs to be set to a certain state without going through the usual flow of edits.\n\t * This might be necessary as a performance optimization, or to prevent parts of the system updating incorrectly (this method emits no change events!).\n\t */\n\tpublic setHead(head: GraphCommit<TChange>): void {\n\t\tthis.assertNotDisposed();\n\t\tthis.head = head;\n\t}\n\n\t/**\n\t * Apply a change to this branch.\n\t * @param taggedChange - the change to apply\n\t * @param kind - the kind of change to apply\n\t * @returns the change that was applied and the new head commit of the branch\n\t */\n\tpublic apply(\n\t\ttaggedChange: TaggedChange<TChange>,\n\t\tkind: CommitKind = CommitKind.Default,\n\t): [change: TChange, newCommit: GraphCommit<TChange>] {\n\t\tthis.assertNotDisposed();\n\n\t\tconst revisionTag = taggedChange.revision;\n\t\tassert(revisionTag !== undefined, 0xa49 /* Revision tag must be provided */);\n\n\t\tconst newHead = mintCommit(this.head, {\n\t\t\trevision: revisionTag,\n\t\t\tchange: taggedChange.change,\n\t\t});\n\n\t\tconst changeEvent = {\n\t\t\ttype: \"append\",\n\t\t\tkind,\n\t\t\tchange: taggedChange,\n\t\t\tnewCommits: [newHead],\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = newHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t\treturn [taggedChange.change, newHead];\n\t}\n\n\t/**\n\t * @returns the commit at the head of this branch.\n\t */\n\tpublic getHead(): GraphCommit<TChange> {\n\t\treturn this.head;\n\t}\n\n\t/**\n\t * Spawn a new branch that is based off of the current state of this branch.\n\t * @param commit - The commit to base the new branch off of. Defaults to the head of this branch.\n\t * @remarks Changes made to the new branch will not be applied to this branch until the new branch is {@link SharedTreeBranch.merge | merged} back in.\n\t * Forks created during a transaction will be disposed when the transaction ends.\n\t */\n\tpublic fork(commit: GraphCommit<TChange> = this.head): SharedTreeBranch<TEditor, TChange> {\n\t\tthis.assertNotDisposed();\n\t\tconst fork = new SharedTreeBranch(\n\t\t\tcommit,\n\t\t\tthis.changeFamily,\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.branchTrimmer,\n\t\t);\n\t\tthis.#events.emit(\"fork\", fork);\n\t\treturn fork;\n\t}\n\n\t/**\n\t * Rebase the changes that have been applied to this branch over divergent changes in the given branch.\n\t * After this operation completes, this branch will be based off of `branch`.\n\t *\n\t * @param branch - the branch to rebase onto\n\t * @param upTo - the furthest commit on `branch` over which to rebase (inclusive). Defaults to the head commit of `branch`.\n\t * @returns the result of the rebase or undefined if nothing changed\n\t */\n\tpublic rebaseOnto(\n\t\tbranch: SharedTreeBranch<TEditor, TChange>,\n\t\tupTo = branch.getHead(),\n\t): BranchRebaseResult<TChange> | undefined {\n\t\tthis.assertNotDisposed();\n\n\t\t// Rebase this branch onto the given branch\n\t\tconst rebaseResult = this.rebaseBranch(this, branch, upTo);\n\t\tif (rebaseResult === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// The net change to this branch is provided by the `rebaseBranch` API\n\t\tconst { newSourceHead, commits } = rebaseResult;\n\t\tconst { deletedSourceCommits, targetCommits, sourceCommits } = commits;\n\t\tassert(hasSome(targetCommits), 0xa83 /* Expected commit(s) for a non no-op rebase */);\n\n\t\tconst newCommits = targetCommits.concat(sourceCommits);\n\t\tconst changeEvent = {\n\t\t\ttype: \"replace\",\n\t\t\tget change() {\n\t\t\t\tconst change = rebaseResult.sourceChange;\n\t\t\t\treturn change === undefined ? undefined : makeAnonChange(change);\n\t\t\t},\n\t\t\tremovedCommits: deletedSourceCommits,\n\t\t\tnewCommits,\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = newSourceHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t\treturn rebaseResult;\n\t}\n\n\t/**\n\t * Remove a range of commits from this branch.\n\t * @param commit - All commits after (but not including) this commit will be removed.\n\t * @returns The net change to this branch and the commits that were removed from this branch.\n\t */\n\tpublic removeAfter(\n\t\tcommit: GraphCommit<TChange>,\n\t): [change: TaggedChange<TChange> | undefined, removedCommits: GraphCommit<TChange>[]] {\n\t\tif (commit === this.head) {\n\t\t\treturn [undefined, []];\n\t\t}\n\n\t\tconst removedCommits: GraphCommit<TChange>[] = [];\n\t\tconst inverses: TaggedChange<TChange>[] = [];\n\t\tfindAncestor([this.head, removedCommits], (c) => {\n\t\t\t// TODO: Pull this side effect out if/when more diverse ancestry walking helpers are available\n\t\t\tif (c !== commit) {\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst inverse = this.changeFamily.rebaser.changeRevision(\n\t\t\t\t\tthis.changeFamily.rebaser.invert(c, true, revision),\n\t\t\t\t\trevision,\n\t\t\t\t\tc.revision,\n\t\t\t\t);\n\n\t\t\t\tinverses.push(tagRollbackInverse(inverse, revision, c.revision));\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\t\tassert(hasSome(removedCommits), 0xa84 /* Commit must be in the branch's ancestry */);\n\n\t\tconst change = makeAnonChange(this.changeFamily.rebaser.compose(inverses));\n\t\tconst changeEvent = {\n\t\t\ttype: \"remove\",\n\t\t\tchange,\n\t\t\tremovedCommits,\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = commit;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t\treturn [change, removedCommits];\n\t}\n\n\t/**\n\t * Replace a range of commits on this branch with a single commit composed of equivalent changes.\n\t * @param commit - All commits after (but not including) this commit will be squashed.\n\t * @returns The commits that were squashed and removed from this branch.\n\t * @remarks The commits after `commit` will be removed from this branch, and the squash commit will become the new head of this branch.\n\t * The change event emitted by this operation will have a `change` property that is undefined, since no net change occurred.\n\t */\n\tpublic squashAfter(commit: GraphCommit<TChange>): GraphCommit<TChange>[] {\n\t\tif (commit === this.head) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst removedCommits: GraphCommit<TChange>[] = [];\n\t\tfindAncestor([this.head, removedCommits], (c) => c === commit);\n\t\tassert(hasSome(removedCommits), 0xa85 /* Commit must be in the branch's ancestry */);\n\n\t\tconst squashedChange = this.changeFamily.rebaser.compose(removedCommits);\n\t\tconst revision = this.mintRevisionTag();\n\t\tconst newHead = mintCommit(commit, {\n\t\t\trevision,\n\t\t\tchange: this.changeFamily.rebaser.changeRevision(squashedChange, revision),\n\t\t});\n\n\t\tconst changeEvent = {\n\t\t\ttype: \"replace\",\n\t\t\tchange: undefined,\n\t\t\tremovedCommits,\n\t\t\tnewCommits: [newHead],\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = newHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t\treturn removedCommits;\n\t}\n\n\t/**\n\t * Apply all the divergent changes on the given branch to this branch.\n\t *\n\t * @param branch - the branch to merge into this branch\n\t * @returns the net change to this branch and the commits that were added to this branch by the merge,\n\t * or undefined if nothing changed\n\t */\n\tpublic merge(\n\t\tbranch: SharedTreeBranch<TEditor, TChange>,\n\t): [change: TChange, newCommits: GraphCommit<TChange>[]] | undefined {\n\t\tthis.assertNotDisposed();\n\t\tbranch.assertNotDisposed();\n\n\t\tif (branch === this) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Rebase the given branch onto this branch\n\t\tconst rebaseResult = this.rebaseBranch(branch, this);\n\t\tif (rebaseResult === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Compute the net change to this branch\n\t\tconst sourceCommits = rebaseResult.commits.sourceCommits;\n\t\tassert(hasSome(sourceCommits), 0xa86 /* Expected source commits in non no-op merge */);\n\t\tconst change = this.changeFamily.rebaser.compose(sourceCommits);\n\t\tconst taggedChange = makeAnonChange(change);\n\t\tconst changeEvent = {\n\t\t\ttype: \"append\",\n\t\t\tkind: CommitKind.Default,\n\t\t\tget change(): TaggedChange<TChange> {\n\t\t\t\treturn taggedChange;\n\t\t\t},\n\t\t\tnewCommits: sourceCommits,\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = rebaseResult.newSourceHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t\treturn [change, sourceCommits];\n\t}\n\n\t/** Rebase `branchHead` onto `onto`, but return undefined if nothing changed */\n\tprivate rebaseBranch(\n\t\tbranch: SharedTreeBranch<TEditor, TChange>,\n\t\tonto: SharedTreeBranch<TEditor, TChange>,\n\t\tupTo = onto.getHead(),\n\t): BranchRebaseResult<TChange> | undefined {\n\t\tconst { head } = branch;\n\t\tif (head === upTo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { duration, output } = measure(() =>\n\t\t\trebaseBranch(\n\t\t\t\tthis.mintRevisionTag,\n\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\thead,\n\t\t\t\tupTo,\n\t\t\t\tonto.getHead(),\n\t\t\t),\n\t\t);\n\n\t\tthis.telemetryEventBatcher?.accumulateAndLog({ duration, ...output.telemetryProperties });\n\n\t\tif (this.head === output.newSourceHead) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\t/**\n\t * Dispose this branch, freezing its state.\n\t *\n\t * @remarks\n\t * Attempts to further mutate the branch will error.\n\t * Any transactions in progress will be aborted.\n\t * Calling dispose more than once has no effect.\n\t */\n\tpublic dispose(): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.unsubscribeBranchTrimmer?.();\n\n\t\tthis.disposed = true;\n\t\tthis.#events.emit(\"dispose\");\n\t}\n\n\tprivate assertNotDisposed(): void {\n\t\tassert(!this.disposed, 0x66e /* Branch is disposed */);\n\t}\n}\n\n/**\n * Registers an event listener that fires when the given branch forks.\n * The listener will also fire when any of those forks fork, and when those forks of forks fork, and so on.\n * @param branch - the branch that will be listened to for forks\n * @param onFork - the fork event listener\n * @returns a function which when called will deregister all registrations (including transitive) created by this function.\n * The deregister function has undefined behavior if called more than once.\n */\n// Branches are invariant over TChange\nexport function onForkTransitive<T extends { events: Listenable<{ fork(t: T): void }> }>(\n\tbranch: T,\n\tonFork: (fork: T) => void,\n): () => void {\n\tconst offs: (() => void)[] = [];\n\toffs.push(\n\t\tbranch.events.on(\"fork\", (fork: T) => {\n\t\t\toffs.push(onForkTransitive(fork, onFork));\n\t\t\tonFork(fork);\n\t\t}),\n\t);\n\treturn () => offs.forEach((off) => off());\n}\n"]}
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/shared-tree-core/branch.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,kEAA6D;AAC7D,uEAA+F;AAE/F,+CAc0B;AAE1B,+DAA6D;AAE7D,+CAAqE;AA0ErE;;GAEG;AACH,MAAa,gBAAgB;IAM5B;;;;;;OAMG;IACH,YACS,IAA0B,EAClB,YAA4C,EAC3C,eAAkC,EAClC,aAAgD,EAChD,qBAEhB;QANO,SAAI,GAAJ,IAAI,CAAsB;QAClB,iBAAY,GAAZ,YAAY,CAAgC;QAC3C,oBAAe,GAAf,eAAe,CAAmB;QAClC,kBAAa,GAAb,aAAa,CAAmC;QAChD,0BAAqB,GAArB,qBAAqB,CAErC;QAnBO,mCAAU,IAAA,4BAAa,GAA4C,EAAC;QAC7D,WAAM,GAAyD,uBAAA,IAAI,gCAAQ,CAAC;QAEpF,aAAQ,GAAG,KAAK,CAAC;QAkBxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CACvE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAClB,CAAC;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IAAI,CAAC,IAAI,CACR,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAO,EAAE,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,CAAC;IACd,CAAC,CAAC,CACF,CAAC;IACF,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAC3C,CAAC;AAZD,4CAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type TelemetryEventBatcher, measure } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype BranchRebaseResult,\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tCommitKind,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\tfindAncestor,\n\tmakeAnonChange,\n\tmintCommit,\n\trebaseBranch,\n\ttagRollbackInverse,\n\ttype RebaseStatsWithDuration,\n} from \"../core/index.js\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\n\nimport { hasSome, defineLazyCachedProperty } from \"../util/index.js\";\n\n/**\n * Describes a change to a `SharedTreeBranch`. Each of the following event types provides a `change` which contains the net change to the branch (or is undefined if there was no net change):\n * * Append - when one or more commits are appended to the head of the branch, for example via\n * a change applied by the branch's editor, or as a result of merging another branch into this one\n * * Remove - when one or more commits are removed from the head of the branch.\n * * Rebase - when a rebase operation adds commits from another branch and replaces existing commits with their rebased versions.\n */\nexport type SharedTreeBranchChange<TChange> =\n\t| {\n\t\t\ttype: \"append\";\n\t\t\tkind: CommitKind;\n\t\t\tchange: TaggedChange<TChange>;\n\t\t\t/** The commits appended to the head of the branch by this operation */\n\t\t\tnewCommits: readonly [GraphCommit<TChange>, ...GraphCommit<TChange>[]];\n\t }\n\t| {\n\t\t\ttype: \"remove\";\n\t\t\tchange: TaggedChange<TChange>;\n\t\t\t/** The commits removed from the head of the branch by this operation */\n\t\t\tremovedCommits: readonly [GraphCommit<TChange>, ...GraphCommit<TChange>[]];\n\t }\n\t| {\n\t\t\ttype: \"rebase\";\n\t\t\tchange: TaggedChange<TChange> | undefined;\n\t };\n\n/**\n * The events emitted by a `SharedTreeBranch`\n */\nexport interface SharedTreeBranchEvents<TEditor extends ChangeFamilyEditor, TChange>\n\textends BranchTrimmingEvents {\n\t/**\n\t * Fired just before the head of this branch changes.\n\t * @param change - the change to this branch's state and commits\n\t */\n\tbeforeChange(change: SharedTreeBranchChange<TChange>): void;\n\n\t/**\n\t * Fired just after the head of this branch changes.\n\t * @param change - the change to this branch's state and commits\n\t */\n\tafterChange(change: SharedTreeBranchChange<TChange>): void;\n\n\t/**\n\t * Fired when this branch forks\n\t * @param fork - the new branch that forked off of this branch\n\t */\n\tfork(fork: SharedTreeBranch<TEditor, TChange>): void;\n\n\t/**\n\t * Fired after this branch is disposed\n\t */\n\tdispose(): void;\n}\n\n/**\n * Events related to branch trimming.\n *\n * @remarks\n * Trimming is a very specific kind of mutation which is the only allowed mutations to branches.\n * References to commits from other commits are removed so that the commit objects can be GC'd by the JS engine.\n * This happens by changing a commit's parent property to undefined, which drops all commits that are in its \"ancestry\".\n * It is done as a performance optimization when it is determined that commits are no longer needed for future computation.\n */\nexport interface BranchTrimmingEvents {\n\t/**\n\t * Fired when some contiguous range of commits beginning with the \"global tail\" of this branch are trimmed from the branch.\n\t * This happens by deleting the parent pointer to the last commit in that range. This event can be fired at any time.\n\t */\n\tancestryTrimmed(trimmedRevisions: RevisionTag[]): void;\n}\n\n/**\n * A branch of changes that can be applied to a SharedTree.\n */\nexport class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChange> {\n\treadonly #events = createEmitter<SharedTreeBranchEvents<TEditor, TChange>>();\n\tpublic readonly events: Listenable<SharedTreeBranchEvents<TEditor, TChange>> = this.#events;\n\tpublic readonly editor: TEditor;\n\tprivate disposed = false;\n\tprivate readonly unsubscribeBranchTrimmer?: () => void;\n\t/**\n\t * Construct a new branch.\n\t * @param head - the head of the branch\n\t * @param changeFamily - determines the set of changes that this branch can commit\n\t * @param branchTrimmer - an optional event emitter that informs the branch it has been trimmed. If this is not supplied, then the branch must\n\t * never be trimmed. See {@link BranchTrimmingEvents} for details on trimming.\n\t */\n\tpublic constructor(\n\t\tprivate head: GraphCommit<TChange>,\n\t\tpublic readonly changeFamily: ChangeFamily<TEditor, TChange>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly branchTrimmer?: Listenable<BranchTrimmingEvents>,\n\t\tprivate readonly telemetryEventBatcher?: TelemetryEventBatcher<\n\t\t\tkeyof RebaseStatsWithDuration\n\t\t>,\n\t) {\n\t\tthis.editor = this.changeFamily.buildEditor(mintRevisionTag, (change) =>\n\t\t\tthis.apply(change),\n\t\t);\n\t\tthis.unsubscribeBranchTrimmer = branchTrimmer?.on(\"ancestryTrimmed\", (commit) => {\n\t\t\tthis.#events.emit(\"ancestryTrimmed\", commit);\n\t\t});\n\t}\n\n\t/**\n\t * Sets the head of this branch.\n\t * @remarks This is a \"manual override\" of sorts, for when the branch needs to be set to a certain state without going through the usual flow of edits.\n\t * This might be necessary as a performance optimization, or to prevent parts of the system updating incorrectly (this method emits no change events!).\n\t */\n\tpublic setHead(head: GraphCommit<TChange>): void {\n\t\tthis.assertNotDisposed();\n\t\tthis.head = head;\n\t}\n\n\t/**\n\t * Apply a change to this branch.\n\t * @param change - the change to apply\n\t * @param kind - the kind of change to apply\n\t * @returns the change that was applied and the new head commit of the branch\n\t */\n\tpublic apply(change: TaggedChange<TChange>, kind: CommitKind = CommitKind.Default): void {\n\t\tthis.assertNotDisposed();\n\n\t\tconst revisionTag = change.revision;\n\t\tassert(revisionTag !== undefined, 0xa49 /* Revision tag must be provided */);\n\n\t\tconst newHead = mintCommit(this.head, {\n\t\t\trevision: revisionTag,\n\t\t\tchange: change.change,\n\t\t});\n\n\t\tconst changeEvent = {\n\t\t\ttype: \"append\",\n\t\t\tkind,\n\t\t\tchange,\n\t\t\tnewCommits: [newHead],\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = newHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t}\n\n\t/**\n\t * @returns the commit at the head of this branch.\n\t */\n\tpublic getHead(): GraphCommit<TChange> {\n\t\treturn this.head;\n\t}\n\n\t/**\n\t * Spawn a new branch that is based off of the current state of this branch.\n\t * @param commit - The commit to base the new branch off of. Defaults to the head of this branch.\n\t * @remarks Changes made to the new branch will not be applied to this branch until the new branch is {@link SharedTreeBranch.merge | merged} back in.\n\t * Forks created during a transaction will be disposed when the transaction ends.\n\t */\n\tpublic fork(commit: GraphCommit<TChange> = this.head): SharedTreeBranch<TEditor, TChange> {\n\t\tthis.assertNotDisposed();\n\t\tconst fork = new SharedTreeBranch(\n\t\t\tcommit,\n\t\t\tthis.changeFamily,\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.branchTrimmer,\n\t\t);\n\t\tthis.#events.emit(\"fork\", fork);\n\t\treturn fork;\n\t}\n\n\t/**\n\t * Rebase the changes that have been applied to this branch over divergent changes in the given branch.\n\t * After this operation completes, this branch will be based off of `branch`.\n\t *\n\t * @param branch - the branch to rebase onto\n\t * @param upTo - the furthest commit on `branch` over which to rebase (inclusive). Defaults to the head commit of `branch`.\n\t * @returns the result of the rebase or undefined if nothing changed\n\t */\n\tpublic rebaseOnto(\n\t\tbranch: SharedTreeBranch<TEditor, TChange>,\n\t\tupTo = branch.getHead(),\n\t): void {\n\t\tthis.assertNotDisposed();\n\n\t\t// Rebase this branch onto the given branch\n\t\tconst rebaseResult = this.rebaseBranch(this, branch, upTo);\n\t\tif (rebaseResult === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The net change to this branch is provided by the `rebaseBranch` API\n\t\tconst { newSourceHead, commits } = rebaseResult;\n\t\tconst { deletedSourceCommits, targetCommits, sourceCommits } = commits;\n\t\tassert(hasSome(targetCommits), 0xa83 /* Expected commit(s) for a non no-op rebase */);\n\n\t\tconst newCommits = targetCommits.concat(sourceCommits);\n\t\tconst changeEvent = {\n\t\t\ttype: \"rebase\",\n\t\t\tget change() {\n\t\t\t\tconst change = rebaseResult.sourceChange;\n\t\t\t\treturn change === undefined ? undefined : makeAnonChange(change);\n\t\t\t},\n\t\t\tremovedCommits: deletedSourceCommits,\n\t\t\tnewCommits,\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = newSourceHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t}\n\n\t/**\n\t * Remove a range of commits from this branch.\n\t * @param commit - All commits after (but not including) this commit will be removed.\n\t * @returns The net change to this branch and the commits that were removed from this branch.\n\t */\n\tpublic removeAfter(commit: GraphCommit<TChange>): void {\n\t\tif (commit === this.head) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst removedCommits: GraphCommit<TChange>[] = [];\n\t\tconst inverses: TaggedChange<TChange>[] = [];\n\t\tfindAncestor([this.head, removedCommits], (c) => {\n\t\t\t// TODO: Pull this side effect out if/when more diverse ancestry walking helpers are available\n\t\t\tif (c !== commit) {\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tconst inverse = this.changeFamily.rebaser.changeRevision(\n\t\t\t\t\tthis.changeFamily.rebaser.invert(c, true, revision),\n\t\t\t\t\trevision,\n\t\t\t\t\tc.revision,\n\t\t\t\t);\n\n\t\t\t\tinverses.push(tagRollbackInverse(inverse, revision, c.revision));\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\t\tassert(hasSome(removedCommits), 0xa84 /* Commit must be in the branch's ancestry */);\n\n\t\tconst change = makeAnonChange(this.changeFamily.rebaser.compose(inverses));\n\t\tconst changeEvent = {\n\t\t\ttype: \"remove\",\n\t\t\tchange,\n\t\t\tremovedCommits,\n\t\t} as const;\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = commit;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t}\n\n\t/**\n\t * Apply all the divergent changes on the given branch to this branch.\n\t *\n\t * @param branch - the branch to merge into this branch\n\t * @returns the net change to this branch and the commits that were added to this branch by the merge,\n\t * or undefined if nothing changed\n\t */\n\tpublic merge(branch: SharedTreeBranch<TEditor, TChange>): void {\n\t\tthis.assertNotDisposed();\n\t\tbranch.assertNotDisposed();\n\n\t\tif (branch === this) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Rebase the given branch onto this branch\n\t\tconst rebaseResult = this.rebaseBranch(branch, this);\n\t\tif (rebaseResult === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Compute the net change to this branch\n\t\tconst sourceCommits = rebaseResult.commits.sourceCommits;\n\t\tassert(hasSome(sourceCommits), 0xa86 /* Expected source commits in non no-op merge */);\n\t\tconst { rebaser } = this.changeFamily;\n\t\tconst changeEvent = defineLazyCachedProperty(\n\t\t\t{\n\t\t\t\ttype: \"append\",\n\t\t\t\tkind: CommitKind.Default,\n\t\t\t\tnewCommits: sourceCommits,\n\t\t\t} as const,\n\t\t\t\"change\",\n\t\t\t() => makeAnonChange(rebaser.compose(sourceCommits)),\n\t\t);\n\n\t\tthis.#events.emit(\"beforeChange\", changeEvent);\n\t\tthis.head = rebaseResult.newSourceHead;\n\t\tthis.#events.emit(\"afterChange\", changeEvent);\n\t}\n\n\t/** Rebase `branchHead` onto `onto`, but return undefined if nothing changed */\n\tprivate rebaseBranch(\n\t\tbranch: SharedTreeBranch<TEditor, TChange>,\n\t\tonto: SharedTreeBranch<TEditor, TChange>,\n\t\tupTo = onto.getHead(),\n\t): BranchRebaseResult<TChange> | undefined {\n\t\tconst { head } = branch;\n\t\tif (head === upTo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { duration, output } = measure(() =>\n\t\t\trebaseBranch(\n\t\t\t\tthis.mintRevisionTag,\n\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\thead,\n\t\t\t\tupTo,\n\t\t\t\tonto.getHead(),\n\t\t\t),\n\t\t);\n\n\t\tthis.telemetryEventBatcher?.accumulateAndLog({ duration, ...output.telemetryProperties });\n\n\t\tif (this.head === output.newSourceHead) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\t/**\n\t * Dispose this branch, freezing its state.\n\t *\n\t * @remarks\n\t * Attempts to further mutate the branch will error.\n\t * Any transactions in progress will be aborted.\n\t * Calling dispose more than once has no effect.\n\t */\n\tpublic dispose(): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.unsubscribeBranchTrimmer?.();\n\n\t\tthis.disposed = true;\n\t\tthis.#events.emit(\"dispose\");\n\t}\n\n\tprivate assertNotDisposed(): void {\n\t\tassert(!this.disposed, 0x66e /* Branch is disposed */);\n\t}\n}\n\n/**\n * Registers an event listener that fires when the given branch forks.\n * The listener will also fire when any of those forks fork, and when those forks of forks fork, and so on.\n * @param branch - the branch that will be listened to for forks\n * @param onFork - the fork event listener\n * @returns a function which when called will deregister all registrations (including transitive) created by this function.\n * The deregister function has undefined behavior if called more than once.\n */\n// Branches are invariant over TChange\nexport function onForkTransitive<T extends { events: Listenable<{ fork(t: T): void }> }>(\n\tbranch: T,\n\tonFork: (fork: T) => void,\n): () => void {\n\tconst offs: (() => void)[] = [];\n\toffs.push(\n\t\tbranch.events.on(\"fork\", (fork: T) => {\n\t\t\toffs.push(onForkTransitive(fork, onFork));\n\t\t\tonFork(fork);\n\t\t}),\n\t);\n\treturn () => offs.forEach((off) => off());\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ChangeRebaser, type GraphCommit } from "../core/index.js";
|
|
6
6
|
import type { ChangeEnricherReadonlyCheckout } from "./changeEnricher.js";
|
|
7
|
-
import {
|
|
7
|
+
import type { SharedTreeBranchChange } from "./branch.js";
|
|
8
8
|
/**
|
|
9
9
|
* Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.
|
|
10
10
|
*/
|
|
@@ -38,5 +38,11 @@ export declare class BranchCommitEnricher<TChange> {
|
|
|
38
38
|
* @remarks This will throw an error if there is no ongoing transaction.
|
|
39
39
|
*/
|
|
40
40
|
abortTransaction(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Add new transaction commits to the current transaction.
|
|
43
|
+
* @param newCommits - The new commits to add.
|
|
44
|
+
* @remarks This will throw an error if there is no ongoing transaction.
|
|
45
|
+
*/
|
|
46
|
+
addTransactionCommits(newCommits: Iterable<GraphCommit<TChange>>): void;
|
|
41
47
|
}
|
|
42
48
|
//# sourceMappingURL=branchCommitEnricher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branchCommitEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,
|
|
1
|
+
{"version":3,"file":"branchCommitEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;GAEG;AACH,qBAAa,oBAAoB,CAAC,OAAO;;gBAoBvC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAMlD;;;;OAIG;IACI,aAAa,CAAC,MAAM,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,IAAI;IAcnE;;;;OAIG;IACI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;IAOjE;;;OAGG;IACI,gBAAgB,IAAI,IAAI;IAI/B;;;OAGG;IACI,iBAAiB,IAAI,IAAI;IAIhC;;;OAGG;IACI,gBAAgB,IAAI,IAAI;IAI/B;;;;OAIG;IACI,qBAAqB,CAAC,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI;CAM9E"}
|
|
@@ -20,7 +20,6 @@ exports.BranchCommitEnricher = void 0;
|
|
|
20
20
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
21
21
|
const index_js_1 = require("../core/index.js");
|
|
22
22
|
const transactionEnricher_js_1 = require("./transactionEnricher.js");
|
|
23
|
-
const branch_js_1 = require("./branch.js");
|
|
24
23
|
/**
|
|
25
24
|
* Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.
|
|
26
25
|
*/
|
|
@@ -51,23 +50,11 @@ class BranchCommitEnricher {
|
|
|
51
50
|
* @param isAttached - Whether or not the SharedTree is attached to the service.
|
|
52
51
|
*/
|
|
53
52
|
processChange(change) {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
__classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").addTransactionStep(commit);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (change.type === "append" ||
|
|
65
|
-
(change.type === "replace" && (0, branch_js_1.getChangeReplaceType)(change) === "transactionCommit")) {
|
|
66
|
-
for (const newCommit of change.newCommits) {
|
|
67
|
-
const newChange = __classPrivateFieldGet(this, _BranchCommitEnricher_getOuterTransactionChange, "f")?.call(this, newCommit.revision) ??
|
|
68
|
-
__classPrivateFieldGet(this, _BranchCommitEnricher_enricher, "f").updateChangeEnrichments(newCommit.change, newCommit.revision);
|
|
69
|
-
__classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").set(newCommit, (0, index_js_1.replaceChange)(newCommit, newChange));
|
|
70
|
-
}
|
|
53
|
+
if (change.type === "append") {
|
|
54
|
+
for (const newCommit of change.newCommits) {
|
|
55
|
+
const newChange = __classPrivateFieldGet(this, _BranchCommitEnricher_getOuterTransactionChange, "f")?.call(this, newCommit.revision) ??
|
|
56
|
+
__classPrivateFieldGet(this, _BranchCommitEnricher_enricher, "f").updateChangeEnrichments(newCommit.change, newCommit.revision);
|
|
57
|
+
__classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").set(newCommit, (0, index_js_1.replaceChange)(newCommit, newChange));
|
|
71
58
|
}
|
|
72
59
|
}
|
|
73
60
|
__classPrivateFieldSet(this, _BranchCommitEnricher_getOuterTransactionChange, undefined, "f");
|
|
@@ -104,6 +91,17 @@ class BranchCommitEnricher {
|
|
|
104
91
|
abortTransaction() {
|
|
105
92
|
__classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").abortTransaction();
|
|
106
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Add new transaction commits to the current transaction.
|
|
96
|
+
* @param newCommits - The new commits to add.
|
|
97
|
+
* @remarks This will throw an error if there is no ongoing transaction.
|
|
98
|
+
*/
|
|
99
|
+
addTransactionCommits(newCommits) {
|
|
100
|
+
(0, internal_1.assert)(__classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").isTransacting(), 0xa97 /* Not in transaction */);
|
|
101
|
+
for (const commit of newCommits) {
|
|
102
|
+
__classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").addTransactionStep(commit);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
107
105
|
}
|
|
108
106
|
exports.BranchCommitEnricher = BranchCommitEnricher;
|
|
109
107
|
_BranchCommitEnricher_transactionEnricher = new WeakMap(), _BranchCommitEnricher_enricher = new WeakMap(), _BranchCommitEnricher_preparedCommits = new WeakMap(), _BranchCommitEnricher_getOuterTransactionChange = new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branchCommitEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAA6D;AAC7D,+CAK0B;AAE1B,qEAA+D;
|
|
1
|
+
{"version":3,"file":"branchCommitEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAA6D;AAC7D,+CAK0B;AAE1B,qEAA+D;AAG/D;;GAEG;AACH,MAAa,oBAAoB;IAmBhC,YACC,OAA+B,EAC/B,QAAiD;QApBzC,4DAAmD;QACnD,iDAAmD;QAC5D;;;;;;WAMG;QACM,gDAAwE,IAAI,GAAG,EAAE,EAAC;QAE3F;;;;WAIG;QACH,kEAAgE;QAM/D,uBAAA,IAAI,kCAAa,QAAQ,MAAA,CAAC;QAC1B,uBAAA,IAAI,6CAAwB,IAAI,4CAAmB,CAAC,OAAO,EAAE,uBAAA,IAAI,sCAAU,CAAC,MAAA,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,MAAuC;QAC3D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC3C,MAAM,SAAS,GACd,uBAAA,IAAI,uDAA2B,EAAE,KAAjC,IAAI,EAA8B,SAAS,CAAC,QAAQ,CAAC;oBACrD,uBAAA,IAAI,sCAAU,CAAC,uBAAuB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAE9E,uBAAA,IAAI,6CAAiB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAA,wBAAa,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;QAED,uBAAA,IAAI,mDAA8B,SAAS,MAAA,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAA4B;QACzC,MAAM,QAAQ,GAAG,uBAAA,IAAI,6CAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnD,IAAA,iBAAM,EAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3D,uBAAA,IAAI,6CAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,uBAAA,IAAI,mDAA8B,uBAAA,IAAI,iDAAqB,CAAC,iBAAiB,EAAE,MAAA,CAAC;IACjF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,UAA0C;QACtE,IAAA,iBAAM,EAAC,uBAAA,IAAI,iDAAqB,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAClF,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAqB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;CACD;AA7FD,oDA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ChangeRebaser,\n\ttype GraphCommit,\n\treplaceChange,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\nimport { TransactionEnricher } from \"./transactionEnricher.js\";\nimport type { SharedTreeBranchChange } from \"./branch.js\";\n\n/**\n * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.\n */\nexport class BranchCommitEnricher<TChange> {\n\treadonly #transactionEnricher: TransactionEnricher<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t/**\n\t * Maps each local commit to the corresponding enriched commit.\n\t * @remarks\n\t * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.\n\t * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.\n\t * In the event that an entry is not explicitly removed, it will eventually be {@link WeakMap | dropped from memory} along with the associated commit.\n\t */\n\treadonly #preparedCommits: WeakMap<GraphCommit<TChange>, GraphCommit<TChange>> = new Map();\n\n\t/**\n\t * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.\n\t * Calling this function will compute the composition of that transaction's commits.\n\t * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.\n\t */\n\t#getOuterTransactionChange?: (revision: RevisionTag) => TChange;\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#enricher = enricher;\n\t\tthis.#transactionEnricher = new TransactionEnricher(rebaser, this.#enricher);\n\t}\n\n\t/**\n\t * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.\n\t * @param change - The change to process.\n\t * @param isAttached - Whether or not the SharedTree is attached to the service.\n\t */\n\tpublic processChange(change: SharedTreeBranchChange<TChange>): void {\n\t\tif (change.type === \"append\") {\n\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\tconst newChange =\n\t\t\t\t\tthis.#getOuterTransactionChange?.(newCommit.revision) ??\n\t\t\t\t\tthis.#enricher.updateChangeEnrichments(newCommit.change, newCommit.revision);\n\n\t\t\t\tthis.#preparedCommits.set(newCommit, replaceChange(newCommit, newChange));\n\t\t\t}\n\t\t}\n\n\t\tthis.#getOuterTransactionChange = undefined;\n\t}\n\n\t/**\n\t * Retrieves the enriched version of the given commit.\n\t * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.\n\t * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.\n\t */\n\tpublic enrich(commit: GraphCommit<TChange>): GraphCommit<TChange> {\n\t\tconst prepared = this.#preparedCommits.get(commit);\n\t\tassert(prepared !== undefined, 0x980 /* Unknown commit */);\n\t\tthis.#preparedCommits.delete(commit);\n\t\treturn prepared;\n\t}\n\n\t/**\n\t * Notify the enricher that a new transaction has started.\n\t * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing \"nested transactions\".\n\t */\n\tpublic startTransaction(): void {\n\t\tthis.#transactionEnricher.startTransaction();\n\t}\n\n\t/**\n\t * Commit the current transaction.\n\t * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.\n\t */\n\tpublic commitTransaction(): void {\n\t\tthis.#getOuterTransactionChange = this.#transactionEnricher.commitTransaction();\n\t}\n\n\t/**\n\t * Notify the enricher that the current transaction has been aborted.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic abortTransaction(): void {\n\t\tthis.#transactionEnricher.abortTransaction();\n\t}\n\n\t/**\n\t * Add new transaction commits to the current transaction.\n\t * @param newCommits - The new commits to add.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic addTransactionCommits(newCommits: Iterable<GraphCommit<TChange>>): void {\n\t\tassert(this.#transactionEnricher.isTransacting(), 0xa97 /* Not in transaction */);\n\t\tfor (const commit of newCommits) {\n\t\t\tthis.#transactionEnricher.addTransactionStep(commit);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editManager.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAOhB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,
|
|
1
|
+
{"version":3,"file":"editManager.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAOhB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAA+C,MAAM,aAAa,CAAC;AAC5F,OAAO,KAAK,EACX,MAAM,EACN,SAAS,EAET,eAAe,EACf,oBAAoB,EACpB,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAGN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,eAAO,MAAM,6BAA6B,EAAE,SAA0C,CAAC;AAkBvF;;;GAGG;AAEH,qBAAa,WAAW,CACvB,OAAO,SAAS,kBAAkB,EAClC,UAAU,EACV,aAAa,SAAS,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC;aAgFtC,YAAY,EAAE,aAAa;aAC3B,cAAc,EAAE,SAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAhFjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IAEjE,uFAAuF;IACvF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwC;IAE9D;;;OAGG;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AW,CAAC,UAAU,CAAC,EAAE;IAIrD,YAAY,IAAI,WAAW,CAAC,UAAU,CAAC;IAIvC,eAAe,IAAI,SAAS,UAAU,EAAE;IAIxC,eAAe,IAAI,SAAS,WAAW,CAAC,UAAU,CAAC,EAAE;IAI5D;;;;;OAKG;IACI,sBAAsB,IAAI,MAAM;IAahC,kBAAkB,CACxB,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,EAC7B,cAAc,EAAE,SAAS,EACzB,uBAAuB,EAAE,SAAS,GAChC,IAAI;IAqEA,eAAe,CACrB,QAAQ,EAAE,WAAW,GACnB,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;IAU7E,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,sBAAsB;IAW9B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAqB7B,OAAO,CAAC,QAAQ;CAUhB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,UAAU;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;IACvD,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,SAAS,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;CACrF"}
|
|
@@ -121,12 +121,12 @@ class EditManager {
|
|
|
121
121
|
this.trackBranch(branch);
|
|
122
122
|
// Whenever the branch is rebased, update our record of its base trunk commit
|
|
123
123
|
const offBeforeRebase = branch.events.on("beforeChange", (args) => {
|
|
124
|
-
if (args.type === "
|
|
124
|
+
if (args.type === "rebase") {
|
|
125
125
|
this.untrackBranch(branch);
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
const offAfterRebase = branch.events.on("afterChange", (args) => {
|
|
129
|
-
if (args.type === "
|
|
129
|
+
if (args.type === "rebase") {
|
|
130
130
|
this.trackBranch(branch);
|
|
131
131
|
this.trimTrunk();
|
|
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AE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;IACvE,CAAC;IAUO,qBAAqB,CAC5B,QAAgC;QAEhC,MAAM,UAAU,GACf,OAAO,QAAQ,KAAK,QAAQ;YAC3B,CAAC,CAAC;gBACA,gFAAgF;gBAChF,mDAAmD;gBACnD,+GAA+G;gBAC/G,cAAc,EAAE,QAAQ;gBACxB,YAAY,EAAE,MAAM,CAAC,iBAAiB;aACtC;YACF,CAAC,CAAC,QAAQ,CAAC;QAEb,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACvE,OAAO,MAAM,CAAC;IACf,CAAC;IAEO,QAAQ,CAAC,cAAyB;QACzC,MAAM,eAAe,GAAe;YACnC,cAAc;SACd,CAAC;QACF,MAAM,aAAa,GAAe;YACjC,cAAc,EAAE,IAAA,gBAAK,EAAE,cAAyB,GAAG,CAAC,CAAC;SACrD,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;CACD;AA9sBD,kCA8sBC;AAUD;;GAEG;AACH,SAAS,eAAe,CACvB,UAAmB,EACnB,cAAuB;IAEvB,MAAM,IAAI,GAAc,EAAE,CAAC;IAC3B,IAAA,iBAAM,EACL,IAAA,6BAAkB,EAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,SAAS,EACpE,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseChange,\n\ttype RebaseStatsWithDuration,\n\ttagChange,\n} from \"../core/index.js\";\nimport { type Mutable, brand, fail, getOrCreate, mapIterable } from \"../util/index.js\";\n\nimport {\n\tSharedTreeBranch,\n\ttype BranchTrimmingEvents,\n\tgetChangeReplaceType,\n\tonForkTransitive,\n} from \"./branch.js\";\nimport type {\n\tCommit,\n\tSeqNumber,\n\tSequenceId,\n\tSequencedCommit,\n\tSummarySessionBranch,\n} from \"./editManagerFormat.js\";\nimport {\n\tdecrementSequenceId,\n\tequalSequenceIds,\n\tmaxSequenceId,\n\tminSequenceId,\n\tsequenceIdComparator,\n} from \"./sequenceIdUtils.js\";\nimport {\n\tTelemetryEventBatcher,\n\tmeasure,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport const minimumPossibleSequenceNumber: SeqNumber = brand(Number.MIN_SAFE_INTEGER);\nconst minimumPossibleSequenceId: SequenceId = {\n\tsequenceNumber: minimumPossibleSequenceNumber,\n};\n\n/**\n * A special revision tag for the initial {@link EditManager.trunkBase} commit.\n * @remarks This tag is used to supply the _initial_ trunk base with a known revision.\n * The trunk base may advance over time, after which point the trunk base will have a different revision.\n * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.\n */\nconst rootRevision = \"root\" as const satisfies RevisionTag;\n\n/**\n * Max number of telemetry log call that may be aggregated before being sent.\n */\nconst maxRebaseStatsAggregationCount = 1000;\n\n/**\n * Represents a local branch of a document and interprets the effect on the document of adding sequenced changes,\n * which were based on a given session's branch, to the document history\n */\n// TODO: Try to reduce this to a single type parameter\nexport class EditManager<\n\tTEditor extends ChangeFamilyEditor,\n\tTChangeset,\n\tTChangeFamily extends ChangeFamily<TEditor, TChangeset>,\n> {\n\tprivate readonly _events = createEmitter<BranchTrimmingEvents>();\n\n\t/** The \"trunk\" branch. The trunk represents the list of received sequenced changes. */\n\tprivate readonly trunk: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Records extra data associated with commits in the {@link trunk}.\n\t * This does not include an entry for the {@link trunkBase}.\n\t */\n\tprivate readonly trunkMetadata = new Map<\n\t\tRevisionTag,\n\t\t{ sequenceId: SequenceId; sessionId: SessionId }\n\t>();\n\t/**\n\t * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.\n\t * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.\n\t */\n\tprivate readonly sequenceMap = new BTree<SequenceId, GraphCommit<TChangeset>>(\n\t\tundefined,\n\t\tsequenceIdComparator,\n\t);\n\n\t/**\n\t * Branches are maintained to represent the local change list that the issuing client had\n\t * at the time of submitting the latest known edit on the branch.\n\t * This means the head commit of each branch is always in its original (non-rebased) form.\n\t */\n\tprivate readonly peerLocalBranches: Map<SessionId, SharedTreeBranch<TEditor, TChangeset>> =\n\t\tnew Map();\n\n\t/**\n\t * This branch holds the changes made by this client which have not yet been confirmed as sequenced changes.\n\t */\n\tpublic readonly localBranch: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on\n\t * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.\n\t *\n\t * @remarks\n\t * This does not include the local branch.\n\t */\n\tprivate readonly trunkBranches = new BTree<\n\t\tSequenceId,\n\t\tSet<SharedTreeBranch<TEditor, TChangeset>>\n\t>(undefined, sequenceIdComparator);\n\n\t/**\n\t * The sequence number of the newest commit on the trunk that has been received by all peers.\n\t * Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tprivate minimumSequenceNumber = minimumPossibleSequenceNumber;\n\n\t/**\n\t * A special commit that is a \"base\" (tail) of the trunk, though not part of the trunk itself.\n\t * This makes it possible to model the trunk in the same way as any other branch (it branches off of a base commit)\n\t * which allows it to use branching APIs to interact with the other branches.\n\t * Each time trunk eviction occurs, the most recent evicted commit becomes the new `trunkBase`.\n\t */\n\tprivate trunkBase: GraphCommit<TChangeset>;\n\n\t/**\n\t * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.\n\t * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.\n\t */\n\tprivate readonly localCommits: GraphCommit<TChangeset>[] = [];\n\n\tprivate readonly telemetryEventBatcher:\n\t\t| TelemetryEventBatcher<keyof RebaseStatsWithDuration>\n\t\t| undefined;\n\n\t/**\n\t * @param changeFamily - the change family of changes on the trunk and local branch\n\t * @param localSessionId - the id of the local session that will be used for local commits\n\t */\n\tpublic constructor(\n\t\tpublic readonly changeFamily: TChangeFamily,\n\t\tpublic readonly localSessionId: SessionId,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tlogger?: ITelemetryLoggerExt,\n\t) {\n\t\tthis.trunkBase = {\n\t\t\trevision: rootRevision,\n\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t};\n\t\tthis.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);\n\n\t\tif (logger !== undefined) {\n\t\t\tthis.telemetryEventBatcher = new TelemetryEventBatcher(\n\t\t\t\t{\n\t\t\t\t\teventName: \"rebaseProcessing\",\n\t\t\t\t\tcategory: \"performance\",\n\t\t\t\t},\n\t\t\t\tlogger,\n\t\t\t\tmaxRebaseStatsAggregationCount,\n\t\t\t);\n\t\t}\n\n\t\tthis.trunk = new SharedTreeBranch(\n\t\t\tthis.trunkBase,\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\t\tthis.localBranch = new SharedTreeBranch(\n\t\t\tthis.trunk.getHead(),\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\n\t\tthis.localBranch.events.on(\"afterChange\", (event) => {\n\t\t\tif (event.type === \"append\") {\n\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\tthis.localCommits.push(commit);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.localCommits.length = 0;\n\t\t\t\tfindCommonAncestor(\n\t\t\t\t\t[this.localBranch.getHead(), this.localCommits],\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have\n\t\t// an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits\n\t\t// they require and therefore we monitor them explicitly.\n\t\tonForkTransitive(this.localBranch, (fork) => this.registerBranch(fork));\n\t}\n\n\t/**\n\t * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered\n\t * branches remain usable even as the minimum sequence number advances.\n\t *\n\t * TODO#AB6926: Refactor local branch management into a separate class that encapsulates `trunkBranches` and everything\n\t * that touches it.\n\t * TODO#AB6925: Maintain the divergence point between each branch and the trunk so that we don't have to recompute\n\t * it so often.\n\t */\n\tprivate registerBranch(branch: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tthis.trackBranch(branch);\n\t\t// Whenever the branch is rebased, update our record of its base trunk commit\n\t\tconst offBeforeRebase = branch.events.on(\"beforeChange\", (args) => {\n\t\t\tif (args.type === \"replace\" && getChangeReplaceType(args) === \"rebase\") {\n\t\t\t\tthis.untrackBranch(branch);\n\t\t\t}\n\t\t});\n\t\tconst offAfterRebase = branch.events.on(\"afterChange\", (args) => {\n\t\t\tif (args.type === \"replace\" && getChangeReplaceType(args) === \"rebase\") {\n\t\t\t\tthis.trackBranch(branch);\n\t\t\t\tthis.trimTrunk();\n\t\t\t}\n\t\t});\n\t\t// When the branch is disposed, update our branch set and trim the trunk\n\t\tconst offDispose = branch.events.on(\"dispose\", () => {\n\t\t\tthis.untrackBranch(branch);\n\t\t\tthis.trimTrunk();\n\t\t\toffBeforeRebase();\n\t\t\toffAfterRebase();\n\t\t\toffDispose();\n\t\t});\n\t}\n\n\tprivate trackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\n\t\tassert(!branches.has(b), 0x670 /* Branch was registered more than once */);\n\t\tbranches.add(b);\n\t}\n\n\tprivate untrackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches =\n\t\t\tthis.trunkBranches.get(sequenceId) ?? fail(\"Expected branch to be tracked\");\n\n\t\tassert(branches.delete(b), 0x671 /* Expected branch to be tracked */);\n\t\tif (branches.size === 0) {\n\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t}\n\t}\n\n\t/**\n\t * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.\n\t * @param sequenceId - The sequence id of the new trunk commit\n\t * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.\n\t * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.\n\t * The first commit will be \"the same\" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.\n\t * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.\n\t * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.\n\t */\n\tprivate fastForwardNextLocalCommit(sequenceId: SequenceId): void {\n\t\t// First, push the local commit to the trunk.\n\t\t// We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.\n\t\tconst firstLocalCommit = this.localCommits.shift();\n\t\tassert(\n\t\t\tfirstLocalCommit !== undefined,\n\t\t\t0x6b5 /* Received a sequenced change from the local session despite having no local changes */,\n\t\t);\n\n\t\tconst previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());\n\t\tthis.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);\n\n\t\t// Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.\n\t\t// In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)\n\t\t// and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.\n\t\t// Intuitively, this makes sense because:\n\t\t// 1. The trunk's head just advanced forward by some (sequence) amount.\n\t\t// 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).\n\t\t// 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.\n\t\t// This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).\n\t\tconst currentBranches = this.trunkBranches.get(previousSequenceId);\n\t\tif (currentBranches !== undefined) {\n\t\t\tconst newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\t\t\tfor (const branch of currentBranches) {\n\t\t\t\t// Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).\n\t\t\t\t// We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.\n\t\t\t\tif (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {\n\t\t\t\t\tnewBranches.add(branch);\n\t\t\t\t\tcurrentBranches.delete(branch);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Clean up our trunk branches map by removing any empty sets.\n\t\t\tif (currentBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(previousSequenceId);\n\t\t\t}\n\t\t\tif (newBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.\n\t */\n\tpublic getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {\n\t\treturn this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;\n\t}\n\n\t/**\n\t * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,\n\t * if they are not retained by revertibles or local branches.\n\t * @param minimumSequenceNumber - the sequence number of the newest commit that all peers (including this one) have received and applied to their trunks.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tpublic advanceMinimumSequenceNumber(\n\t\tminimumSequenceNumber: SeqNumber,\n\t\ttrimTrunk = true,\n\t): void {\n\t\tif (minimumSequenceNumber === this.minimumSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tminimumSequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x476 /* number must be larger or equal to current minimumSequenceNumber. */,\n\t\t);\n\n\t\tthis.minimumSequenceNumber = minimumSequenceNumber;\n\t\tif (trimTrunk) {\n\t\t\tthis.trimTrunk();\n\t\t}\n\t}\n\n\t/**\n\t * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine\n\t * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.\n\t */\n\tprivate trimTrunk(): void {\n\t\t/** The sequence id of the most recent commit on the trunk that will be trimmed */\n\t\tlet trunkTailSequenceId: SequenceId = {\n\t\t\tsequenceNumber: this.minimumSequenceNumber,\n\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t};\n\t\t// If there are any outstanding registered branches, get the one that is the oldest (has the \"most behind\" trunk base)\n\t\tconst minimumBranchBaseSequenceId = this.trunkBranches.minKey();\n\t\tif (minimumBranchBaseSequenceId !== undefined) {\n\t\t\t// If that branch is behind the minimum sequence id, we only want to evict commits older than it,\n\t\t\t// even if those commits are behind the minimum sequence id\n\t\t\tconst sequenceIdBeforeMinimumBranchBase = decrementSequenceId(\n\t\t\t\tminimumBranchBaseSequenceId,\n\t\t\t);\n\t\t\ttrunkTailSequenceId = minSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tsequenceIdBeforeMinimumBranchBase,\n\t\t\t);\n\t\t}\n\n\t\tconst [sequenceId, latestEvicted] = this.getClosestTrunkCommit(\n\t\t\tmaxSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tthis.sequenceMap.minKey() ?? minimumPossibleSequenceId,\n\t\t\t),\n\t\t);\n\n\t\t// Don't do any work if the commit found by the search is already the tail of the trunk\n\t\tif (latestEvicted !== this.trunkBase) {\n\t\t\t// The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,\n\t\t\t// so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.\n\t\t\tfor (const [, branch] of this.peerLocalBranches) {\n\t\t\t\tbranch.rebaseOnto(this.trunk, latestEvicted);\n\t\t\t}\n\n\t\t\t// This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires\n\t\t\t// regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain\n\t\t\t// that there are no outstanding references to any of the commits being removed (other than the references via\n\t\t\t// the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased\n\t\t\t// to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at\n\t\t\t// `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.\n\t\t\t// We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that\n\t\t\t// have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.\n\t\t\tconst newTrunkBase = latestEvicted as Mutable<typeof latestEvicted>;\n\t\t\t// The metadata for new trunk base revision needs to be deleted before modifying it.\n\t\t\tthis.trunkMetadata.delete(newTrunkBase.revision);\n\t\t\t// collect the revisions that will be trimmed to send as part of the branch trimmed event\n\t\t\tconst trimmedRevisions: RevisionTag[] = getPathFromBase(\n\t\t\t\tnewTrunkBase,\n\t\t\t\tthis.trunkBase,\n\t\t\t).map((c) => c.revision);\n\t\t\t// Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.\n\t\t\tdelete newTrunkBase.parent;\n\t\t\tthis.trunkBase = newTrunkBase;\n\n\t\t\t// Update any state that is derived from trunk commits\n\t\t\tthis.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {\n\t\t\t\t// Cleanup look-aside data for each evicted commit\n\t\t\t\tthis.trunkMetadata.delete(commit.revision);\n\t\t\t\t// Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`\n\t\t\t\tif (equalSequenceIds(s, sequenceId)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommit === newTrunkBase,\n\t\t\t\t\t\t0x729 /* Expected last evicted commit to be new trunk base */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tReflect.defineProperty(commit, \"change\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5e /* Should not access 'change' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"revision\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5f /* Should not access 'revision' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"parent\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa60 /* Should not access 'parent' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\treturn { delete: true };\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;\n\t\t\tassert(\n\t\t\t\tthis.sequenceMap.size === trunkSize + 1,\n\t\t\t\t0x744 /* The size of the sequenceMap must have one element more than the trunk */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.trunkMetadata.size === trunkSize,\n\t\t\t\t0x745 /* The size of the trunkMetadata must be the same as the trunk */,\n\t\t\t);\n\n\t\t\tthis._events.emit(\"ancestryTrimmed\", trimmedRevisions);\n\t\t}\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn (\n\t\t\tthis.trunk.getHead() === this.trunkBase &&\n\t\t\tthis.peerLocalBranches.size === 0 &&\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead() &&\n\t\t\tthis.minimumSequenceNumber === minimumPossibleSequenceNumber\n\t\t);\n\t}\n\n\tpublic getSummaryData(): SummaryData<TChangeset> {\n\t\t// The assert below is acceptable at present because summarization only ever occurs on a client with no\n\t\t// local/in-flight changes.\n\t\t// In the future we may wish to relax this constraint. For that to work, the current implementation of\n\t\t// `EditManager` would have to be amended in one of two ways:\n\t\t// A) Changes made by the local session should be represented by a branch in `EditManager.branches`.\n\t\t// B) The contents of such a branch should be computed on demand based on the trunk.\n\t\t// Note that option (A) would be a simple change to `addSequencedChange` whereas (B) would likely require\n\t\t// rebasing trunk changes over the inverse of trunk changes.\n\t\tassert(\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead(),\n\t\t\t0x428 /* Clients with local changes cannot be used to generate summaries */,\n\t\t);\n\n\t\t// Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.\n\t\tthis.trimTrunk();\n\n\t\tlet oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];\n\t\tassert(\n\t\t\toldestCommitInCollabWindow.parent !== undefined ||\n\t\t\t\toldestCommitInCollabWindow === this.trunkBase,\n\t\t\t0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */,\n\t\t);\n\n\t\t// Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists\n\t\toldestCommitInCollabWindow =\n\t\t\toldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;\n\n\t\tconst trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(\n\t\t\t(c) => {\n\t\t\t\tassert(\n\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t0xa61 /* Serialized trunk should not include the trunk base */,\n\t\t\t\t);\n\t\t\t\tconst metadata =\n\t\t\t\t\tthis.trunkMetadata.get(c.revision) ?? fail(\"Expected metadata for trunk commit\");\n\t\t\t\tconst commit: SequencedCommit<TChangeset> = {\n\t\t\t\t\tchange: c.change,\n\t\t\t\t\trevision: c.revision,\n\t\t\t\t\tsequenceNumber: metadata.sequenceId.sequenceNumber,\n\t\t\t\t\tsessionId: metadata.sessionId,\n\t\t\t\t};\n\t\t\t\tif (metadata.sequenceId.indexInBatch !== undefined) {\n\t\t\t\t\tcommit.indexInBatch = metadata.sequenceId.indexInBatch;\n\t\t\t\t}\n\t\t\t\treturn commit;\n\t\t\t},\n\t\t);\n\n\t\tconst peerLocalBranches = new Map<SessionId, SummarySessionBranch<TChangeset>>(\n\t\t\tmapIterable(this.peerLocalBranches.entries(), ([sessionId, branch]) => {\n\t\t\t\tconst branchPath: GraphCommit<TChangeset>[] = [];\n\t\t\t\tconst ancestor =\n\t\t\t\t\tfindCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??\n\t\t\t\t\tfail(\"Expected branch to be based on trunk\");\n\n\t\t\t\tconst base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;\n\t\t\t\treturn [\n\t\t\t\t\tsessionId,\n\t\t\t\t\t{\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tcommits: branchPath.map((c) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t\t\t\t0xa62 /* Serialized branch should not include the trunk base */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst commit: Commit<TChangeset> = {\n\t\t\t\t\t\t\t\tchange: c.change,\n\t\t\t\t\t\t\t\trevision: c.revision,\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn commit;\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t\t);\n\n\t\treturn { trunk, peerLocalBranches };\n\t}\n\n\tpublic loadSummaryData(data: SummaryData<TChangeset>): void {\n\t\tassert(\n\t\t\tthis.isEmpty(),\n\t\t\t0x68a /* Attempted to load from summary after edit manager was already mutated */,\n\t\t);\n\t\t// Record the tags of each trunk commit as we generate the trunk so they can be looked up quickly\n\t\t// when hydrating the peer branches below\n\t\tconst trunkRevisionCache = new Map<RevisionTag, GraphCommit<TChangeset>>();\n\t\ttrunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);\n\t\tthis.trunk.setHead(\n\t\t\tdata.trunk.reduce((base, c) => {\n\t\t\t\tconst sequenceId: SequenceId =\n\t\t\t\t\tc.indexInBatch === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t\tindexInBatch: c.indexInBatch,\n\t\t\t\t\t\t\t};\n\t\t\t\tconst commit = mintCommit(base, c);\n\t\t\t\tthis.sequenceMap.set(sequenceId, commit);\n\t\t\t\tthis.trunkMetadata.set(c.revision, {\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tsessionId: c.sessionId,\n\t\t\t\t});\n\t\t\t\ttrunkRevisionCache.set(c.revision, commit);\n\t\t\t\treturn commit;\n\t\t\t}, this.trunkBase),\n\t\t);\n\n\t\tthis.localBranch.setHead(this.trunk.getHead());\n\n\t\tfor (const [sessionId, branch] of data.peerLocalBranches) {\n\t\t\tconst commit =\n\t\t\t\ttrunkRevisionCache.get(branch.base) ??\n\t\t\t\tfail(\"Expected summary branch to be based off of a revision in the trunk\");\n\n\t\t\tthis.peerLocalBranches.set(\n\t\t\t\tsessionId,\n\t\t\t\tnew SharedTreeBranch(\n\t\t\t\t\tbranch.commits.reduce(mintCommit, commit),\n\t\t\t\t\tthis.changeFamily,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {\n\t\tconst id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;\n\t\tif (id === undefined) {\n\t\t\tassert(\n\t\t\t\ttrunkCommitOrTrunkBase === this.trunkBase,\n\t\t\t\t0xa63 /* Commit must be either be on the trunk or be the trunk base */,\n\t\t\t);\n\t\t\treturn minimumPossibleSequenceId;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic getTrunkChanges(): readonly TChangeset[] {\n\t\treturn this.getTrunkCommits().map((c) => c.change);\n\t}\n\n\tpublic getTrunkCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn getPathFromBase(this.trunk.getHead(), this.trunkBase);\n\t}\n\n\tpublic getTrunkHead(): GraphCommit<TChangeset> {\n\t\treturn this.trunk.getHead();\n\t}\n\n\tpublic getLocalChanges(): readonly TChangeset[] {\n\t\treturn this.getLocalCommits().map((c) => c.change);\n\t}\n\n\tpublic getLocalCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn this.localCommits;\n\t}\n\n\t/**\n\t * @returns The length of the longest branch maintained by this EditManager.\n\t * This may be the length of a peer branch or the local branch.\n\t * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would\n\t * have length zero.\n\t */\n\tpublic getLongestBranchLength(): number {\n\t\tlet max = 0;\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tfor (const branch of this.peerLocalBranches.values()) {\n\t\t\tconst branchPath = getPathFromBase(branch.getHead(), trunkHead);\n\t\t\tif (branchPath.length > max) {\n\t\t\t\tmax = branchPath.length;\n\t\t\t}\n\t\t}\n\t\tconst localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);\n\t\treturn Math.max(max, localPath.length);\n\t}\n\n\tpublic addSequencedChange(\n\t\tnewCommit: Commit<TChangeset>,\n\t\tsequenceNumber: SeqNumber,\n\t\treferenceSequenceNumber: SeqNumber,\n\t): void {\n\t\tassert(\n\t\t\tsequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,\n\t\t);\n\n\t\tassert(\n\t\t\tsequenceNumber >= // This is \">=\", not \">\" because changes in the same batch will have the same sequence number\n\t\t\t\t(this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),\n\t\t\t0xa64 /* Attempted to sequence change with an outdated sequence number */,\n\t\t);\n\n\t\tconst commitsSequenceNumber = this.getBatch(sequenceNumber);\n\t\tconst sequenceId: SequenceId =\n\t\t\tcommitsSequenceNumber.length === 0\n\t\t\t\t? {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\tindexInBatch: commitsSequenceNumber.length,\n\t\t\t\t\t};\n\n\t\tif (newCommit.sessionId === this.localSessionId) {\n\t\t\treturn this.fastForwardNextLocalCommit(sequenceId);\n\t\t}\n\n\t\t// Get the revision that the remote change is based on\n\t\tconst [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);\n\t\t// Rebase that branch over the part of the trunk up to the base revision\n\t\t// This will be a no-op if the sending client has not advanced since the last time we received an edit from it\n\t\tconst peerLocalBranch = getOrCreate(\n\t\t\tthis.peerLocalBranches,\n\t\t\tnewCommit.sessionId,\n\t\t\t() => new SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag),\n\t\t);\n\t\tpeerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);\n\n\t\tif (peerLocalBranch.getHead() === this.trunk.getHead()) {\n\t\t\t// If the branch is fully caught up and empty after being rebased, then push to the trunk directly\n\t\t\tthis.pushCommitToTrunk(sequenceId, newCommit);\n\t\t\tpeerLocalBranch.setHead(this.trunk.getHead());\n\t\t} else {\n\t\t\t// Otherwise, rebase the change over the trunk and append it, and append the original change to the peer branch.\n\t\t\tconst { duration, output: newChangeFullyRebased } = measure(() =>\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tnewCommit,\n\t\t\t\t\tpeerLocalBranch.getHead(),\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tthis.telemetryEventBatcher?.accumulateAndLog({\n\t\t\t\tduration,\n\t\t\t\t...newChangeFullyRebased.telemetryProperties,\n\t\t\t});\n\n\t\t\tpeerLocalBranch.apply(tagChange(newCommit.change, newCommit.revision));\n\t\t\tthis.pushCommitToTrunk(sequenceId, {\n\t\t\t\t...newCommit,\n\t\t\t\tchange: newChangeFullyRebased.change,\n\t\t\t});\n\t\t}\n\n\t\tthis.localBranch.rebaseOnto(this.trunk);\n\t}\n\n\tpublic findLocalCommit(\n\t\trevision: RevisionTag,\n\t): [commit: GraphCommit<TChangeset>, commitsAfter: GraphCommit<TChangeset>[]] {\n\t\tconst commits: GraphCommit<TChangeset>[] = [];\n\t\tconst commit = findAncestor(\n\t\t\t[this.localBranch.getHead(), commits],\n\t\t\t(c) => c.revision === revision,\n\t\t);\n\t\tassert(commit !== undefined, 0x599 /* Expected local branch to contain revision */);\n\t\treturn [commit, commits];\n\t}\n\n\tprivate pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {\n\t\tconst mintedCommit = mintCommit(this.trunk.getHead(), commit);\n\t\tthis.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);\n\t}\n\n\tprivate pushGraphCommitToTrunk(\n\t\tsequenceId: SequenceId,\n\t\tgraphCommit: GraphCommit<TChangeset>,\n\t\tsessionId: SessionId,\n\t): void {\n\t\tthis.trunk.setHead(graphCommit);\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tthis.sequenceMap.set(sequenceId, trunkHead);\n\t\tthis.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });\n\t}\n\n\t/**\n\t * Finds the most recent trunk commit that was sequenced at or before the given point.\n\t * @param searchBy - the sequence number or the sequence id to search for\n\t * @remarks Fails if there is no eligible commit.\n\t * @returns the closest commit and its sequence id\n\t */\n\tprivate getClosestTrunkCommit(searchBy: SeqNumber): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(searchBy: SequenceId): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(\n\t\tsearchBy: SeqNumber | SequenceId,\n\t): [SequenceId, GraphCommit<TChangeset>] {\n\t\tconst sequenceId: SequenceId =\n\t\t\ttypeof searchBy === \"number\"\n\t\t\t\t? {\n\t\t\t\t\t\t// This is to make sure that the correct commit is selected in this 2 scenarios:\n\t\t\t\t\t\t// 1) The commit is unique for that sequence number\n\t\t\t\t\t\t// 2) There are more than one commit for the same sequence number, in this case we need to select the last one.\n\t\t\t\t\t\tsequenceNumber: searchBy,\n\t\t\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t\t\t}\n\t\t\t\t: searchBy;\n\n\t\tconst commit = this.sequenceMap.getPairOrNextLower(sequenceId);\n\t\tassert(commit !== undefined, 0x746 /* sequence id has been evicted */);\n\t\treturn commit;\n\t}\n\n\tprivate getBatch(sequenceNumber: SeqNumber): [SequenceId, GraphCommit<TChangeset>][] {\n\t\tconst startSequenceId: SequenceId = {\n\t\t\tsequenceNumber,\n\t\t};\n\t\tconst endSequenceId: SequenceId = {\n\t\t\tsequenceNumber: brand((sequenceNumber as number) + 1),\n\t\t};\n\n\t\treturn this.sequenceMap.getRange(startSequenceId, endSequenceId, false);\n\t}\n}\n\n/**\n * The in-memory data that summaries contain\n */\nexport interface SummaryData<TChangeset> {\n\treadonly trunk: readonly SequencedCommit<TChangeset>[];\n\treadonly peerLocalBranches: ReadonlyMap<SessionId, SummarySessionBranch<TChangeset>>;\n}\n\n/**\n * @returns the path from the base of a branch to its head\n */\nfunction getPathFromBase<TCommit extends { parent?: TCommit }>(\n\tbranchHead: TCommit,\n\tbaseBranchHead: TCommit,\n): TCommit[] {\n\tconst path: TCommit[] = [];\n\tassert(\n\t\tfindCommonAncestor([branchHead, path], baseBranchHead) !== undefined,\n\t\t0x573 /* Expected branches to be related */,\n\t);\n\treturn path;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"editManager.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,+DAA6D;AAE7D,gEAAkD;AAElD,+CAW0B;AAC1B,+CAAuF;AAEvF,2CAA4F;AAQ5F,6DAM8B;AAC9B,uEAIkD;AAErC,QAAA,6BAA6B,GAAc,IAAA,gBAAK,EAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvF,MAAM,yBAAyB,GAAe;IAC7C,cAAc,EAAE,qCAA6B;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,YAAY,GAAG,MAAqC,CAAC;AAE3D;;GAEG;AACH,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAE5C;;;GAGG;AACH,sDAAsD;AACtD,MAAa,WAAW;IA8EvB;;;OAGG;IACH,YACiB,YAA2B,EAC3B,cAAyB,EACxB,eAAkC,EACnD,MAA4B;QAHZ,iBAAY,GAAZ,YAAY,CAAe;QAC3B,mBAAc,GAAd,cAAc,CAAW;QACxB,oBAAe,GAAf,eAAe,CAAmB;QAhFn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UAAmB,EACnB,cAAuB;IAEvB,MAAM,IAAI,GAAc,EAAE,CAAC;IAC3B,IAAA,iBAAM,EACL,IAAA,6BAAkB,EAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,SAAS,EACpE,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseChange,\n\ttype RebaseStatsWithDuration,\n\ttagChange,\n} from \"../core/index.js\";\nimport { type Mutable, brand, fail, getOrCreate, mapIterable } from \"../util/index.js\";\n\nimport { SharedTreeBranch, type BranchTrimmingEvents, onForkTransitive } from \"./branch.js\";\nimport type {\n\tCommit,\n\tSeqNumber,\n\tSequenceId,\n\tSequencedCommit,\n\tSummarySessionBranch,\n} from \"./editManagerFormat.js\";\nimport {\n\tdecrementSequenceId,\n\tequalSequenceIds,\n\tmaxSequenceId,\n\tminSequenceId,\n\tsequenceIdComparator,\n} from \"./sequenceIdUtils.js\";\nimport {\n\tTelemetryEventBatcher,\n\tmeasure,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport const minimumPossibleSequenceNumber: SeqNumber = brand(Number.MIN_SAFE_INTEGER);\nconst minimumPossibleSequenceId: SequenceId = {\n\tsequenceNumber: minimumPossibleSequenceNumber,\n};\n\n/**\n * A special revision tag for the initial {@link EditManager.trunkBase} commit.\n * @remarks This tag is used to supply the _initial_ trunk base with a known revision.\n * The trunk base may advance over time, after which point the trunk base will have a different revision.\n * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.\n */\nconst rootRevision = \"root\" as const satisfies RevisionTag;\n\n/**\n * Max number of telemetry log call that may be aggregated before being sent.\n */\nconst maxRebaseStatsAggregationCount = 1000;\n\n/**\n * Represents a local branch of a document and interprets the effect on the document of adding sequenced changes,\n * which were based on a given session's branch, to the document history\n */\n// TODO: Try to reduce this to a single type parameter\nexport class EditManager<\n\tTEditor extends ChangeFamilyEditor,\n\tTChangeset,\n\tTChangeFamily extends ChangeFamily<TEditor, TChangeset>,\n> {\n\tprivate readonly _events = createEmitter<BranchTrimmingEvents>();\n\n\t/** The \"trunk\" branch. The trunk represents the list of received sequenced changes. */\n\tprivate readonly trunk: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Records extra data associated with commits in the {@link trunk}.\n\t * This does not include an entry for the {@link trunkBase}.\n\t */\n\tprivate readonly trunkMetadata = new Map<\n\t\tRevisionTag,\n\t\t{ sequenceId: SequenceId; sessionId: SessionId }\n\t>();\n\t/**\n\t * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.\n\t * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.\n\t */\n\tprivate readonly sequenceMap = new BTree<SequenceId, GraphCommit<TChangeset>>(\n\t\tundefined,\n\t\tsequenceIdComparator,\n\t);\n\n\t/**\n\t * Branches are maintained to represent the local change list that the issuing client had\n\t * at the time of submitting the latest known edit on the branch.\n\t * This means the head commit of each branch is always in its original (non-rebased) form.\n\t */\n\tprivate readonly peerLocalBranches: Map<SessionId, SharedTreeBranch<TEditor, TChangeset>> =\n\t\tnew Map();\n\n\t/**\n\t * This branch holds the changes made by this client which have not yet been confirmed as sequenced changes.\n\t */\n\tpublic readonly localBranch: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on\n\t * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.\n\t *\n\t * @remarks\n\t * This does not include the local branch.\n\t */\n\tprivate readonly trunkBranches = new BTree<\n\t\tSequenceId,\n\t\tSet<SharedTreeBranch<TEditor, TChangeset>>\n\t>(undefined, sequenceIdComparator);\n\n\t/**\n\t * The sequence number of the newest commit on the trunk that has been received by all peers.\n\t * Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tprivate minimumSequenceNumber = minimumPossibleSequenceNumber;\n\n\t/**\n\t * A special commit that is a \"base\" (tail) of the trunk, though not part of the trunk itself.\n\t * This makes it possible to model the trunk in the same way as any other branch (it branches off of a base commit)\n\t * which allows it to use branching APIs to interact with the other branches.\n\t * Each time trunk eviction occurs, the most recent evicted commit becomes the new `trunkBase`.\n\t */\n\tprivate trunkBase: GraphCommit<TChangeset>;\n\n\t/**\n\t * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.\n\t * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.\n\t */\n\tprivate readonly localCommits: GraphCommit<TChangeset>[] = [];\n\n\tprivate readonly telemetryEventBatcher:\n\t\t| TelemetryEventBatcher<keyof RebaseStatsWithDuration>\n\t\t| undefined;\n\n\t/**\n\t * @param changeFamily - the change family of changes on the trunk and local branch\n\t * @param localSessionId - the id of the local session that will be used for local commits\n\t */\n\tpublic constructor(\n\t\tpublic readonly changeFamily: TChangeFamily,\n\t\tpublic readonly localSessionId: SessionId,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tlogger?: ITelemetryLoggerExt,\n\t) {\n\t\tthis.trunkBase = {\n\t\t\trevision: rootRevision,\n\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t};\n\t\tthis.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);\n\n\t\tif (logger !== undefined) {\n\t\t\tthis.telemetryEventBatcher = new TelemetryEventBatcher(\n\t\t\t\t{\n\t\t\t\t\teventName: \"rebaseProcessing\",\n\t\t\t\t\tcategory: \"performance\",\n\t\t\t\t},\n\t\t\t\tlogger,\n\t\t\t\tmaxRebaseStatsAggregationCount,\n\t\t\t);\n\t\t}\n\n\t\tthis.trunk = new SharedTreeBranch(\n\t\t\tthis.trunkBase,\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\t\tthis.localBranch = new SharedTreeBranch(\n\t\t\tthis.trunk.getHead(),\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\n\t\tthis.localBranch.events.on(\"afterChange\", (event) => {\n\t\t\tif (event.type === \"append\") {\n\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\tthis.localCommits.push(commit);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.localCommits.length = 0;\n\t\t\t\tfindCommonAncestor(\n\t\t\t\t\t[this.localBranch.getHead(), this.localCommits],\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have\n\t\t// an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits\n\t\t// they require and therefore we monitor them explicitly.\n\t\tonForkTransitive(this.localBranch, (fork) => this.registerBranch(fork));\n\t}\n\n\t/**\n\t * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered\n\t * branches remain usable even as the minimum sequence number advances.\n\t *\n\t * TODO#AB6926: Refactor local branch management into a separate class that encapsulates `trunkBranches` and everything\n\t * that touches it.\n\t * TODO#AB6925: Maintain the divergence point between each branch and the trunk so that we don't have to recompute\n\t * it so often.\n\t */\n\tprivate registerBranch(branch: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tthis.trackBranch(branch);\n\t\t// Whenever the branch is rebased, update our record of its base trunk commit\n\t\tconst offBeforeRebase = branch.events.on(\"beforeChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.untrackBranch(branch);\n\t\t\t}\n\t\t});\n\t\tconst offAfterRebase = branch.events.on(\"afterChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.trackBranch(branch);\n\t\t\t\tthis.trimTrunk();\n\t\t\t}\n\t\t});\n\t\t// When the branch is disposed, update our branch set and trim the trunk\n\t\tconst offDispose = branch.events.on(\"dispose\", () => {\n\t\t\tthis.untrackBranch(branch);\n\t\t\tthis.trimTrunk();\n\t\t\toffBeforeRebase();\n\t\t\toffAfterRebase();\n\t\t\toffDispose();\n\t\t});\n\t}\n\n\tprivate trackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\n\t\tassert(!branches.has(b), 0x670 /* Branch was registered more than once */);\n\t\tbranches.add(b);\n\t}\n\n\tprivate untrackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches =\n\t\t\tthis.trunkBranches.get(sequenceId) ?? fail(\"Expected branch to be tracked\");\n\n\t\tassert(branches.delete(b), 0x671 /* Expected branch to be tracked */);\n\t\tif (branches.size === 0) {\n\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t}\n\t}\n\n\t/**\n\t * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.\n\t * @param sequenceId - The sequence id of the new trunk commit\n\t * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.\n\t * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.\n\t * The first commit will be \"the same\" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.\n\t * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.\n\t * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.\n\t */\n\tprivate fastForwardNextLocalCommit(sequenceId: SequenceId): void {\n\t\t// First, push the local commit to the trunk.\n\t\t// We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.\n\t\tconst firstLocalCommit = this.localCommits.shift();\n\t\tassert(\n\t\t\tfirstLocalCommit !== undefined,\n\t\t\t0x6b5 /* Received a sequenced change from the local session despite having no local changes */,\n\t\t);\n\n\t\tconst previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());\n\t\tthis.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);\n\n\t\t// Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.\n\t\t// In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)\n\t\t// and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.\n\t\t// Intuitively, this makes sense because:\n\t\t// 1. The trunk's head just advanced forward by some (sequence) amount.\n\t\t// 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).\n\t\t// 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.\n\t\t// This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).\n\t\tconst currentBranches = this.trunkBranches.get(previousSequenceId);\n\t\tif (currentBranches !== undefined) {\n\t\t\tconst newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\t\t\tfor (const branch of currentBranches) {\n\t\t\t\t// Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).\n\t\t\t\t// We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.\n\t\t\t\tif (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {\n\t\t\t\t\tnewBranches.add(branch);\n\t\t\t\t\tcurrentBranches.delete(branch);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Clean up our trunk branches map by removing any empty sets.\n\t\t\tif (currentBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(previousSequenceId);\n\t\t\t}\n\t\t\tif (newBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.\n\t */\n\tpublic getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {\n\t\treturn this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;\n\t}\n\n\t/**\n\t * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,\n\t * if they are not retained by revertibles or local branches.\n\t * @param minimumSequenceNumber - the sequence number of the newest commit that all peers (including this one) have received and applied to their trunks.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tpublic advanceMinimumSequenceNumber(\n\t\tminimumSequenceNumber: SeqNumber,\n\t\ttrimTrunk = true,\n\t): void {\n\t\tif (minimumSequenceNumber === this.minimumSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tminimumSequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x476 /* number must be larger or equal to current minimumSequenceNumber. */,\n\t\t);\n\n\t\tthis.minimumSequenceNumber = minimumSequenceNumber;\n\t\tif (trimTrunk) {\n\t\t\tthis.trimTrunk();\n\t\t}\n\t}\n\n\t/**\n\t * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine\n\t * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.\n\t */\n\tprivate trimTrunk(): void {\n\t\t/** The sequence id of the most recent commit on the trunk that will be trimmed */\n\t\tlet trunkTailSequenceId: SequenceId = {\n\t\t\tsequenceNumber: this.minimumSequenceNumber,\n\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t};\n\t\t// If there are any outstanding registered branches, get the one that is the oldest (has the \"most behind\" trunk base)\n\t\tconst minimumBranchBaseSequenceId = this.trunkBranches.minKey();\n\t\tif (minimumBranchBaseSequenceId !== undefined) {\n\t\t\t// If that branch is behind the minimum sequence id, we only want to evict commits older than it,\n\t\t\t// even if those commits are behind the minimum sequence id\n\t\t\tconst sequenceIdBeforeMinimumBranchBase = decrementSequenceId(\n\t\t\t\tminimumBranchBaseSequenceId,\n\t\t\t);\n\t\t\ttrunkTailSequenceId = minSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tsequenceIdBeforeMinimumBranchBase,\n\t\t\t);\n\t\t}\n\n\t\tconst [sequenceId, latestEvicted] = this.getClosestTrunkCommit(\n\t\t\tmaxSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tthis.sequenceMap.minKey() ?? minimumPossibleSequenceId,\n\t\t\t),\n\t\t);\n\n\t\t// Don't do any work if the commit found by the search is already the tail of the trunk\n\t\tif (latestEvicted !== this.trunkBase) {\n\t\t\t// The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,\n\t\t\t// so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.\n\t\t\tfor (const [, branch] of this.peerLocalBranches) {\n\t\t\t\tbranch.rebaseOnto(this.trunk, latestEvicted);\n\t\t\t}\n\n\t\t\t// This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires\n\t\t\t// regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain\n\t\t\t// that there are no outstanding references to any of the commits being removed (other than the references via\n\t\t\t// the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased\n\t\t\t// to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at\n\t\t\t// `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.\n\t\t\t// We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that\n\t\t\t// have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.\n\t\t\tconst newTrunkBase = latestEvicted as Mutable<typeof latestEvicted>;\n\t\t\t// The metadata for new trunk base revision needs to be deleted before modifying it.\n\t\t\tthis.trunkMetadata.delete(newTrunkBase.revision);\n\t\t\t// collect the revisions that will be trimmed to send as part of the branch trimmed event\n\t\t\tconst trimmedRevisions: RevisionTag[] = getPathFromBase(\n\t\t\t\tnewTrunkBase,\n\t\t\t\tthis.trunkBase,\n\t\t\t).map((c) => c.revision);\n\t\t\t// Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.\n\t\t\tdelete newTrunkBase.parent;\n\t\t\tthis.trunkBase = newTrunkBase;\n\n\t\t\t// Update any state that is derived from trunk commits\n\t\t\tthis.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {\n\t\t\t\t// Cleanup look-aside data for each evicted commit\n\t\t\t\tthis.trunkMetadata.delete(commit.revision);\n\t\t\t\t// Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`\n\t\t\t\tif (equalSequenceIds(s, sequenceId)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommit === newTrunkBase,\n\t\t\t\t\t\t0x729 /* Expected last evicted commit to be new trunk base */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tReflect.defineProperty(commit, \"change\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5e /* Should not access 'change' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"revision\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5f /* Should not access 'revision' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"parent\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa60 /* Should not access 'parent' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\treturn { delete: true };\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;\n\t\t\tassert(\n\t\t\t\tthis.sequenceMap.size === trunkSize + 1,\n\t\t\t\t0x744 /* The size of the sequenceMap must have one element more than the trunk */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.trunkMetadata.size === trunkSize,\n\t\t\t\t0x745 /* The size of the trunkMetadata must be the same as the trunk */,\n\t\t\t);\n\n\t\t\tthis._events.emit(\"ancestryTrimmed\", trimmedRevisions);\n\t\t}\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn (\n\t\t\tthis.trunk.getHead() === this.trunkBase &&\n\t\t\tthis.peerLocalBranches.size === 0 &&\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead() &&\n\t\t\tthis.minimumSequenceNumber === minimumPossibleSequenceNumber\n\t\t);\n\t}\n\n\tpublic getSummaryData(): SummaryData<TChangeset> {\n\t\t// The assert below is acceptable at present because summarization only ever occurs on a client with no\n\t\t// local/in-flight changes.\n\t\t// In the future we may wish to relax this constraint. For that to work, the current implementation of\n\t\t// `EditManager` would have to be amended in one of two ways:\n\t\t// A) Changes made by the local session should be represented by a branch in `EditManager.branches`.\n\t\t// B) The contents of such a branch should be computed on demand based on the trunk.\n\t\t// Note that option (A) would be a simple change to `addSequencedChange` whereas (B) would likely require\n\t\t// rebasing trunk changes over the inverse of trunk changes.\n\t\tassert(\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead(),\n\t\t\t0x428 /* Clients with local changes cannot be used to generate summaries */,\n\t\t);\n\n\t\t// Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.\n\t\tthis.trimTrunk();\n\n\t\tlet oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];\n\t\tassert(\n\t\t\toldestCommitInCollabWindow.parent !== undefined ||\n\t\t\t\toldestCommitInCollabWindow === this.trunkBase,\n\t\t\t0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */,\n\t\t);\n\n\t\t// Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists\n\t\toldestCommitInCollabWindow =\n\t\t\toldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;\n\n\t\tconst trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(\n\t\t\t(c) => {\n\t\t\t\tassert(\n\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t0xa61 /* Serialized trunk should not include the trunk base */,\n\t\t\t\t);\n\t\t\t\tconst metadata =\n\t\t\t\t\tthis.trunkMetadata.get(c.revision) ?? fail(\"Expected metadata for trunk commit\");\n\t\t\t\tconst commit: SequencedCommit<TChangeset> = {\n\t\t\t\t\tchange: c.change,\n\t\t\t\t\trevision: c.revision,\n\t\t\t\t\tsequenceNumber: metadata.sequenceId.sequenceNumber,\n\t\t\t\t\tsessionId: metadata.sessionId,\n\t\t\t\t};\n\t\t\t\tif (metadata.sequenceId.indexInBatch !== undefined) {\n\t\t\t\t\tcommit.indexInBatch = metadata.sequenceId.indexInBatch;\n\t\t\t\t}\n\t\t\t\treturn commit;\n\t\t\t},\n\t\t);\n\n\t\tconst peerLocalBranches = new Map<SessionId, SummarySessionBranch<TChangeset>>(\n\t\t\tmapIterable(this.peerLocalBranches.entries(), ([sessionId, branch]) => {\n\t\t\t\tconst branchPath: GraphCommit<TChangeset>[] = [];\n\t\t\t\tconst ancestor =\n\t\t\t\t\tfindCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??\n\t\t\t\t\tfail(\"Expected branch to be based on trunk\");\n\n\t\t\t\tconst base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;\n\t\t\t\treturn [\n\t\t\t\t\tsessionId,\n\t\t\t\t\t{\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tcommits: branchPath.map((c) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t\t\t\t0xa62 /* Serialized branch should not include the trunk base */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst commit: Commit<TChangeset> = {\n\t\t\t\t\t\t\t\tchange: c.change,\n\t\t\t\t\t\t\t\trevision: c.revision,\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn commit;\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t\t);\n\n\t\treturn { trunk, peerLocalBranches };\n\t}\n\n\tpublic loadSummaryData(data: SummaryData<TChangeset>): void {\n\t\tassert(\n\t\t\tthis.isEmpty(),\n\t\t\t0x68a /* Attempted to load from summary after edit manager was already mutated */,\n\t\t);\n\t\t// Record the tags of each trunk commit as we generate the trunk so they can be looked up quickly\n\t\t// when hydrating the peer branches below\n\t\tconst trunkRevisionCache = new Map<RevisionTag, GraphCommit<TChangeset>>();\n\t\ttrunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);\n\t\tthis.trunk.setHead(\n\t\t\tdata.trunk.reduce((base, c) => {\n\t\t\t\tconst sequenceId: SequenceId =\n\t\t\t\t\tc.indexInBatch === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t\tindexInBatch: c.indexInBatch,\n\t\t\t\t\t\t\t};\n\t\t\t\tconst commit = mintCommit(base, c);\n\t\t\t\tthis.sequenceMap.set(sequenceId, commit);\n\t\t\t\tthis.trunkMetadata.set(c.revision, {\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tsessionId: c.sessionId,\n\t\t\t\t});\n\t\t\t\ttrunkRevisionCache.set(c.revision, commit);\n\t\t\t\treturn commit;\n\t\t\t}, this.trunkBase),\n\t\t);\n\n\t\tthis.localBranch.setHead(this.trunk.getHead());\n\n\t\tfor (const [sessionId, branch] of data.peerLocalBranches) {\n\t\t\tconst commit =\n\t\t\t\ttrunkRevisionCache.get(branch.base) ??\n\t\t\t\tfail(\"Expected summary branch to be based off of a revision in the trunk\");\n\n\t\t\tthis.peerLocalBranches.set(\n\t\t\t\tsessionId,\n\t\t\t\tnew SharedTreeBranch(\n\t\t\t\t\tbranch.commits.reduce(mintCommit, commit),\n\t\t\t\t\tthis.changeFamily,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {\n\t\tconst id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;\n\t\tif (id === undefined) {\n\t\t\tassert(\n\t\t\t\ttrunkCommitOrTrunkBase === this.trunkBase,\n\t\t\t\t0xa63 /* Commit must be either be on the trunk or be the trunk base */,\n\t\t\t);\n\t\t\treturn minimumPossibleSequenceId;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic getTrunkChanges(): readonly TChangeset[] {\n\t\treturn this.getTrunkCommits().map((c) => c.change);\n\t}\n\n\tpublic getTrunkCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn getPathFromBase(this.trunk.getHead(), this.trunkBase);\n\t}\n\n\tpublic getTrunkHead(): GraphCommit<TChangeset> {\n\t\treturn this.trunk.getHead();\n\t}\n\n\tpublic getLocalChanges(): readonly TChangeset[] {\n\t\treturn this.getLocalCommits().map((c) => c.change);\n\t}\n\n\tpublic getLocalCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn this.localCommits;\n\t}\n\n\t/**\n\t * @returns The length of the longest branch maintained by this EditManager.\n\t * This may be the length of a peer branch or the local branch.\n\t * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would\n\t * have length zero.\n\t */\n\tpublic getLongestBranchLength(): number {\n\t\tlet max = 0;\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tfor (const branch of this.peerLocalBranches.values()) {\n\t\t\tconst branchPath = getPathFromBase(branch.getHead(), trunkHead);\n\t\t\tif (branchPath.length > max) {\n\t\t\t\tmax = branchPath.length;\n\t\t\t}\n\t\t}\n\t\tconst localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);\n\t\treturn Math.max(max, localPath.length);\n\t}\n\n\tpublic addSequencedChange(\n\t\tnewCommit: Commit<TChangeset>,\n\t\tsequenceNumber: SeqNumber,\n\t\treferenceSequenceNumber: SeqNumber,\n\t): void {\n\t\tassert(\n\t\t\tsequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,\n\t\t);\n\n\t\tassert(\n\t\t\tsequenceNumber >= // This is \">=\", not \">\" because changes in the same batch will have the same sequence number\n\t\t\t\t(this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),\n\t\t\t0xa64 /* Attempted to sequence change with an outdated sequence number */,\n\t\t);\n\n\t\tconst commitsSequenceNumber = this.getBatch(sequenceNumber);\n\t\tconst sequenceId: SequenceId =\n\t\t\tcommitsSequenceNumber.length === 0\n\t\t\t\t? {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\tindexInBatch: commitsSequenceNumber.length,\n\t\t\t\t\t};\n\n\t\tif (newCommit.sessionId === this.localSessionId) {\n\t\t\treturn this.fastForwardNextLocalCommit(sequenceId);\n\t\t}\n\n\t\t// Get the revision that the remote change is based on\n\t\tconst [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);\n\t\t// Rebase that branch over the part of the trunk up to the base revision\n\t\t// This will be a no-op if the sending client has not advanced since the last time we received an edit from it\n\t\tconst peerLocalBranch = getOrCreate(\n\t\t\tthis.peerLocalBranches,\n\t\t\tnewCommit.sessionId,\n\t\t\t() => new SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag),\n\t\t);\n\t\tpeerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);\n\n\t\tif (peerLocalBranch.getHead() === this.trunk.getHead()) {\n\t\t\t// If the branch is fully caught up and empty after being rebased, then push to the trunk directly\n\t\t\tthis.pushCommitToTrunk(sequenceId, newCommit);\n\t\t\tpeerLocalBranch.setHead(this.trunk.getHead());\n\t\t} else {\n\t\t\t// Otherwise, rebase the change over the trunk and append it, and append the original change to the peer branch.\n\t\t\tconst { duration, output: newChangeFullyRebased } = measure(() =>\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tnewCommit,\n\t\t\t\t\tpeerLocalBranch.getHead(),\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tthis.telemetryEventBatcher?.accumulateAndLog({\n\t\t\t\tduration,\n\t\t\t\t...newChangeFullyRebased.telemetryProperties,\n\t\t\t});\n\n\t\t\tpeerLocalBranch.apply(tagChange(newCommit.change, newCommit.revision));\n\t\t\tthis.pushCommitToTrunk(sequenceId, {\n\t\t\t\t...newCommit,\n\t\t\t\tchange: newChangeFullyRebased.change,\n\t\t\t});\n\t\t}\n\n\t\tthis.localBranch.rebaseOnto(this.trunk);\n\t}\n\n\tpublic findLocalCommit(\n\t\trevision: RevisionTag,\n\t): [commit: GraphCommit<TChangeset>, commitsAfter: GraphCommit<TChangeset>[]] {\n\t\tconst commits: GraphCommit<TChangeset>[] = [];\n\t\tconst commit = findAncestor(\n\t\t\t[this.localBranch.getHead(), commits],\n\t\t\t(c) => c.revision === revision,\n\t\t);\n\t\tassert(commit !== undefined, 0x599 /* Expected local branch to contain revision */);\n\t\treturn [commit, commits];\n\t}\n\n\tprivate pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {\n\t\tconst mintedCommit = mintCommit(this.trunk.getHead(), commit);\n\t\tthis.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);\n\t}\n\n\tprivate pushGraphCommitToTrunk(\n\t\tsequenceId: SequenceId,\n\t\tgraphCommit: GraphCommit<TChangeset>,\n\t\tsessionId: SessionId,\n\t): void {\n\t\tthis.trunk.setHead(graphCommit);\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tthis.sequenceMap.set(sequenceId, trunkHead);\n\t\tthis.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });\n\t}\n\n\t/**\n\t * Finds the most recent trunk commit that was sequenced at or before the given point.\n\t * @param searchBy - the sequence number or the sequence id to search for\n\t * @remarks Fails if there is no eligible commit.\n\t * @returns the closest commit and its sequence id\n\t */\n\tprivate getClosestTrunkCommit(searchBy: SeqNumber): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(searchBy: SequenceId): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(\n\t\tsearchBy: SeqNumber | SequenceId,\n\t): [SequenceId, GraphCommit<TChangeset>] {\n\t\tconst sequenceId: SequenceId =\n\t\t\ttypeof searchBy === \"number\"\n\t\t\t\t? {\n\t\t\t\t\t\t// This is to make sure that the correct commit is selected in this 2 scenarios:\n\t\t\t\t\t\t// 1) The commit is unique for that sequence number\n\t\t\t\t\t\t// 2) There are more than one commit for the same sequence number, in this case we need to select the last one.\n\t\t\t\t\t\tsequenceNumber: searchBy,\n\t\t\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t\t\t}\n\t\t\t\t: searchBy;\n\n\t\tconst commit = this.sequenceMap.getPairOrNextLower(sequenceId);\n\t\tassert(commit !== undefined, 0x746 /* sequence id has been evicted */);\n\t\treturn commit;\n\t}\n\n\tprivate getBatch(sequenceNumber: SeqNumber): [SequenceId, GraphCommit<TChangeset>][] {\n\t\tconst startSequenceId: SequenceId = {\n\t\t\tsequenceNumber,\n\t\t};\n\t\tconst endSequenceId: SequenceId = {\n\t\t\tsequenceNumber: brand((sequenceNumber as number) + 1),\n\t\t};\n\n\t\treturn this.sequenceMap.getRange(startSequenceId, endSequenceId, false);\n\t}\n}\n\n/**\n * The in-memory data that summaries contain\n */\nexport interface SummaryData<TChangeset> {\n\treadonly trunk: readonly SequencedCommit<TChangeset>[];\n\treadonly peerLocalBranches: ReadonlyMap<SessionId, SummarySessionBranch<TChangeset>>;\n}\n\n/**\n * @returns the path from the base of a branch to its head\n */\nfunction getPathFromBase<TCommit extends { parent?: TCommit }>(\n\tbranchHead: TCommit,\n\tbaseBranchHead: TCommit,\n): TCommit[] {\n\tconst path: TCommit[] = [];\n\tassert(\n\t\tfindCommonAncestor([branchHead, path], baseBranchHead) !== undefined,\n\t\t0x573 /* Expected branches to be related */,\n\t);\n\treturn path;\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { onForkTransitive, SharedTreeBranch, type SharedTreeBranchChange, type SharedTreeBranchEvents,
|
|
6
|
-
export { TransactionResult, type Transactor, type TransactionEvents, TransactionStack, type OnPush, type OnPop, } from "./transaction.js";
|
|
7
|
-
export { type ExplicitCoreCodecVersions, SharedTreeCore, type Summarizable, type SummaryElementParser, type SummaryElementStringifier, } from "./sharedTreeCore.js";
|
|
5
|
+
export { onForkTransitive, SharedTreeBranch, type SharedTreeBranchChange, type SharedTreeBranchEvents, } from "./branch.js";
|
|
6
|
+
export { TransactionResult, type Transactor, type TransactionEvents, TransactionStack, SquashingTransactionStack, type OnPush, type OnPop, } from "./transaction.js";
|
|
7
|
+
export { type ExplicitCoreCodecVersions, SharedTreeCore, type Summarizable, type SummaryElementParser, type SummaryElementStringifier, type ClonableSchemaAndPolicy, } from "./sharedTreeCore.js";
|
|
8
8
|
export type { ResubmitMachine } from "./resubmitMachine.js";
|
|
9
9
|
export { DefaultResubmitMachine } from "./defaultResubmitMachine.js";
|
|
10
10
|
export { type ChangeEnricherReadonlyCheckout, type ChangeEnricherMutableCheckout, NoOpChangeEnricher, } from "./changeEnricher.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,KAAK,MAAM,EACX,KAAK,KAAK,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,KAAK,yBAAyB,EAC9B,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EACN,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,kBAAkB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,KAAK,WAAW,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,MAAM,EACN,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,aAAa,GACb,MAAM,wBAAwB,CAAC"}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.minimumPossibleSequenceNumber = exports.EditManager = exports.EditManagerSummarizer = exports.makeEditManagerCodec = exports.NoOpChangeEnricher = exports.DefaultResubmitMachine = exports.SharedTreeCore = exports.
|
|
7
|
+
exports.minimumPossibleSequenceNumber = exports.EditManager = exports.EditManagerSummarizer = exports.makeEditManagerCodec = exports.NoOpChangeEnricher = exports.DefaultResubmitMachine = exports.SharedTreeCore = exports.SquashingTransactionStack = exports.TransactionStack = exports.TransactionResult = exports.SharedTreeBranch = exports.onForkTransitive = void 0;
|
|
8
8
|
var branch_js_1 = require("./branch.js");
|
|
9
9
|
Object.defineProperty(exports, "onForkTransitive", { enumerable: true, get: function () { return branch_js_1.onForkTransitive; } });
|
|
10
10
|
Object.defineProperty(exports, "SharedTreeBranch", { enumerable: true, get: function () { return branch_js_1.SharedTreeBranch; } });
|
|
11
|
-
Object.defineProperty(exports, "getChangeReplaceType", { enumerable: true, get: function () { return branch_js_1.getChangeReplaceType; } });
|
|
12
11
|
var transaction_js_1 = require("./transaction.js");
|
|
13
12
|
Object.defineProperty(exports, "TransactionResult", { enumerable: true, get: function () { return transaction_js_1.TransactionResult; } });
|
|
14
13
|
Object.defineProperty(exports, "TransactionStack", { enumerable: true, get: function () { return transaction_js_1.TransactionStack; } });
|
|
14
|
+
Object.defineProperty(exports, "SquashingTransactionStack", { enumerable: true, get: function () { return transaction_js_1.SquashingTransactionStack; } });
|
|
15
15
|
var sharedTreeCore_js_1 = require("./sharedTreeCore.js");
|
|
16
16
|
Object.defineProperty(exports, "SharedTreeCore", { enumerable: true, get: function () { return sharedTreeCore_js_1.SharedTreeCore; } });
|
|
17
17
|
var defaultResubmitMachine_js_1 = require("./defaultResubmitMachine.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAKqB;AAJpB,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAKjB,mDAQ0B;AAPzB,mHAAA,iBAAiB,OAAA;AAGjB,kHAAA,gBAAgB,OAAA;AAChB,2HAAA,yBAAyB,OAAA;AAK1B,yDAO6B;AAL5B,mHAAA,cAAc,OAAA;AAQf,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAE/B,yDAI6B;AAD5B,uHAAA,kBAAkB,OAAA;AAGnB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,mDAI0B;AAHzB,6GAAA,WAAW,OAAA;AACX,+HAAA,6BAA6B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tonForkTransitive,\n\tSharedTreeBranch,\n\ttype SharedTreeBranchChange,\n\ttype SharedTreeBranchEvents,\n} from \"./branch.js\";\n\nexport {\n\tTransactionResult,\n\ttype Transactor,\n\ttype TransactionEvents,\n\tTransactionStack,\n\tSquashingTransactionStack,\n\ttype OnPush,\n\ttype OnPop,\n} from \"./transaction.js\";\n\nexport {\n\ttype ExplicitCoreCodecVersions,\n\tSharedTreeCore,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n\ttype ClonableSchemaAndPolicy,\n} from \"./sharedTreeCore.js\";\n\nexport type { ResubmitMachine } from \"./resubmitMachine.js\";\nexport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\n\nexport {\n\ttype ChangeEnricherReadonlyCheckout,\n\ttype ChangeEnricherMutableCheckout,\n\tNoOpChangeEnricher,\n} from \"./changeEnricher.js\";\n\nexport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nexport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nexport {\n\tEditManager,\n\tminimumPossibleSequenceNumber,\n\ttype SummaryData,\n} from \"./editManager.js\";\nexport type {\n\tCommit,\n\tSeqNumber,\n\tSequencedCommit,\n\tSummarySessionBranch,\n\tEncodedCommit,\n} from \"./editManagerFormat.js\";\n"]}
|