@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
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import type {
|
|
8
|
-
HasListeners,
|
|
9
|
-
IEmitter,
|
|
10
|
-
Listenable,
|
|
11
|
-
} from "@fluidframework/core-interfaces/internal";
|
|
7
|
+
import type { Listenable } from "@fluidframework/core-interfaces/internal";
|
|
12
8
|
import { createEmitter } from "@fluid-internal/client-utils";
|
|
13
9
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
14
10
|
import {
|
|
@@ -44,6 +40,7 @@ import {
|
|
|
44
40
|
visitDelta,
|
|
45
41
|
type RevertibleAlphaFactory,
|
|
46
42
|
type RevertibleAlpha,
|
|
43
|
+
type GraphCommit,
|
|
47
44
|
} from "../core/index.js";
|
|
48
45
|
import {
|
|
49
46
|
type FieldBatchCodec,
|
|
@@ -55,15 +52,14 @@ import {
|
|
|
55
52
|
makeFieldBatchCodec,
|
|
56
53
|
} from "../feature-libraries/index.js";
|
|
57
54
|
import {
|
|
55
|
+
SquashingTransactionStack,
|
|
58
56
|
SharedTreeBranch,
|
|
59
57
|
TransactionResult,
|
|
60
|
-
TransactionStack,
|
|
61
|
-
getChangeReplaceType,
|
|
62
58
|
onForkTransitive,
|
|
63
59
|
type SharedTreeBranchChange,
|
|
64
60
|
type Transactor,
|
|
65
61
|
} from "../shared-tree-core/index.js";
|
|
66
|
-
import { Breakable, disposeSymbol, fail,
|
|
62
|
+
import { Breakable, disposeSymbol, fail, getOrCreate } from "../util/index.js";
|
|
67
63
|
|
|
68
64
|
import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamily.js";
|
|
69
65
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
@@ -84,10 +80,21 @@ import { getCheckout, SchematizingSimpleTreeView } from "./schematizingTreeView.
|
|
|
84
80
|
* Events for {@link ITreeCheckout}.
|
|
85
81
|
*/
|
|
86
82
|
export interface CheckoutEvents {
|
|
83
|
+
/**
|
|
84
|
+
* The view is currently in a consistent state, but a batch of changes is about to be processed.
|
|
85
|
+
* @remarks Once this event fires, it is not safe to access the FlexTree, Forest and AnchorSet again until the corresponding {@link CheckoutEvents.afterBatch} fires.
|
|
86
|
+
* Every call to `beforeBatch` will be followed by a corresponding call to `afterBatch` (before any more calls to `beforeBatch`).
|
|
87
|
+
* @param change - The {@link SharedTreeBranchChange | change} to the checkout's active branch that is about to be processed.
|
|
88
|
+
* May be empty if the changes were produced by e.g. a rebase or the initial loading of the document.
|
|
89
|
+
*/
|
|
90
|
+
beforeBatch(change: SharedTreeBranchChange<SharedTreeChange>): void;
|
|
91
|
+
|
|
87
92
|
/**
|
|
88
93
|
* A batch of changes has finished processing and the view is in a consistent state.
|
|
89
|
-
* It is once again safe to access the FlexTree, Forest and AnchorSet.
|
|
94
|
+
* @remarks It is once again safe to access the FlexTree, Forest and AnchorSet.
|
|
90
95
|
*
|
|
96
|
+
* While every call to `beforeBatch` will be followed by a corresponding call to `afterBatch`, the converse is not true.
|
|
97
|
+
* This event may be fired without a preceding `beforeBatch` event if the checkout's branch and forest were directly updated via e.g. a summary load rather than via normal application of changes.
|
|
91
98
|
* @remarks
|
|
92
99
|
* This is mainly useful for knowing when to do followup work scheduled during events from Anchors.
|
|
93
100
|
*/
|
|
@@ -260,9 +267,6 @@ export function createTreeCheckout(
|
|
|
260
267
|
schema?: TreeStoredSchemaRepository;
|
|
261
268
|
forest?: IEditableForest;
|
|
262
269
|
fieldBatchCodec?: FieldBatchCodec;
|
|
263
|
-
events?: Listenable<CheckoutEvents> &
|
|
264
|
-
IEmitter<CheckoutEvents> &
|
|
265
|
-
HasListeners<CheckoutEvents>;
|
|
266
270
|
removedRoots?: DetachedFieldIndex;
|
|
267
271
|
chunkCompressionStrategy?: TreeCompressionStrategy;
|
|
268
272
|
logger?: ITelemetryLoggerExt;
|
|
@@ -293,7 +297,6 @@ export function createTreeCheckout(
|
|
|
293
297
|
changeFamily,
|
|
294
298
|
() => idCompressor.generateCompressedId(),
|
|
295
299
|
);
|
|
296
|
-
const events = args?.events ?? createEmitter();
|
|
297
300
|
|
|
298
301
|
return new TreeCheckout(
|
|
299
302
|
branch,
|
|
@@ -301,7 +304,6 @@ export function createTreeCheckout(
|
|
|
301
304
|
changeFamily,
|
|
302
305
|
schema,
|
|
303
306
|
forest,
|
|
304
|
-
events,
|
|
305
307
|
mintRevisionTag,
|
|
306
308
|
revisionTagCodec,
|
|
307
309
|
idCompressor,
|
|
@@ -363,16 +365,16 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
363
365
|
*/
|
|
364
366
|
public static readonly revertTelemetryEventName = "RevertRevertible";
|
|
365
367
|
|
|
368
|
+
readonly #events = createEmitter<CheckoutEvents>();
|
|
369
|
+
public events: Listenable<CheckoutEvents> = this.#events;
|
|
370
|
+
|
|
366
371
|
public constructor(
|
|
367
|
-
|
|
372
|
+
branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,
|
|
368
373
|
/** True if and only if this checkout is for a forked branch and not the "main branch" of the tree. */
|
|
369
374
|
public readonly isBranch: boolean,
|
|
370
375
|
private readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,
|
|
371
376
|
public readonly storedSchema: TreeStoredSchemaRepository,
|
|
372
377
|
public readonly forest: IEditableForest,
|
|
373
|
-
public readonly events: Listenable<CheckoutEvents> &
|
|
374
|
-
IEmitter<CheckoutEvents> &
|
|
375
|
-
HasListeners<CheckoutEvents>,
|
|
376
378
|
private readonly mintRevisionTag: () => RevisionTag,
|
|
377
379
|
private readonly revisionTagCodec: RevisionTagCodec,
|
|
378
380
|
private readonly idCompressor: IIdCompressor,
|
|
@@ -385,121 +387,162 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
385
387
|
private readonly logger?: ITelemetryLoggerExt,
|
|
386
388
|
private readonly breaker: Breakable = new Breakable("TreeCheckout"),
|
|
387
389
|
) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
let revision: RevisionTag | undefined;
|
|
395
|
-
if (event.type === "replace") {
|
|
396
|
-
assert(
|
|
397
|
-
hasSome(event.newCommits),
|
|
398
|
-
0xa81 /* Expected new commit for non no-op change event */,
|
|
399
|
-
);
|
|
400
|
-
revision = getLast(event.newCommits).revision;
|
|
401
|
-
} else {
|
|
402
|
-
revision = event.change.revision;
|
|
390
|
+
this.#transaction = new SquashingTransactionStack(
|
|
391
|
+
branch,
|
|
392
|
+
(commits) => {
|
|
393
|
+
const revision = this.mintRevisionTag();
|
|
394
|
+
for (const transactionStep of commits) {
|
|
395
|
+
this.removedRoots.updateMajor(transactionStep.revision, revision);
|
|
403
396
|
}
|
|
404
397
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
398
|
+
const squashedChange = this.changeFamily.rebaser.compose(commits);
|
|
399
|
+
const change = this.changeFamily.rebaser.changeRevision(squashedChange, revision);
|
|
400
|
+
return tagChange(change, revision);
|
|
401
|
+
},
|
|
402
|
+
() => {
|
|
403
|
+
// Keep track of all the forks created during the transaction so that we can dispose them when the transaction ends.
|
|
404
|
+
// This is a policy decision that we think is useful for the user, but it is not necessary for correctness.
|
|
405
|
+
const forks = new Set<TreeCheckout>();
|
|
406
|
+
const onDisposeUnSubscribes: (() => void)[] = [];
|
|
407
|
+
const onForkUnSubscribe = onForkTransitive(this, (fork) => {
|
|
408
|
+
forks.add(fork);
|
|
409
|
+
onDisposeUnSubscribes.push(fork.events.on("dispose", () => forks.delete(fork)));
|
|
410
|
+
});
|
|
411
|
+
// When each transaction is started, take a snapshot of the current state of removed roots
|
|
412
|
+
const removedRootsSnapshot = this.removedRoots.clone();
|
|
413
|
+
return (result) => {
|
|
414
|
+
switch (result) {
|
|
415
|
+
case TransactionResult.Abort:
|
|
416
|
+
this.removedRoots = removedRootsSnapshot;
|
|
417
|
+
break;
|
|
418
|
+
case TransactionResult.Commit:
|
|
419
|
+
if (!this.transaction.isInProgress()) {
|
|
420
|
+
// The changes in a transaction squash commit have already applied to the checkout and are known to be valid, so we can validate the squash commit automatically.
|
|
421
|
+
this.validateCommit(this.#transaction.branch.getHead());
|
|
422
|
+
}
|
|
423
|
+
break;
|
|
424
|
+
default:
|
|
425
|
+
unreachableCase(result);
|
|
431
426
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
427
|
+
|
|
428
|
+
forks.forEach((fork) => fork.dispose());
|
|
429
|
+
onDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());
|
|
430
|
+
onForkUnSubscribe();
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
branch.events.on("afterChange", (event) => {
|
|
437
436
|
// The following logic allows revertibles to be generated for the change.
|
|
438
|
-
// Currently only appends (including merges
|
|
439
|
-
if (
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
: (onRevertibleDisposed?: (revertible: RevertibleAlpha) => void) => {
|
|
453
|
-
if (!withinEventContext) {
|
|
454
|
-
throw new UsageError(
|
|
455
|
-
"Cannot get a revertible outside of the context of a changed event.",
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
if (this.revertibleCommitBranches.get(revision) !== undefined) {
|
|
459
|
-
throw new UsageError(
|
|
460
|
-
"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.",
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
const revertible = this.createRevertible(
|
|
464
|
-
revision,
|
|
465
|
-
kind,
|
|
466
|
-
this,
|
|
467
|
-
onRevertibleDisposed,
|
|
437
|
+
// Currently only appends (including merges and transaction commits) are supported.
|
|
438
|
+
if (event.type === "append") {
|
|
439
|
+
// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.
|
|
440
|
+
// Figure out a way to generate revertibles before the commits are garbage collected.
|
|
441
|
+
for (const commit of event.newCommits) {
|
|
442
|
+
const kind = event.type === "append" ? event.kind : CommitKind.Default;
|
|
443
|
+
const { change, revision } = commit;
|
|
444
|
+
|
|
445
|
+
const getRevertible = hasSchemaChange(change)
|
|
446
|
+
? undefined
|
|
447
|
+
: (onRevertibleDisposed?: (revertible: RevertibleAlpha) => void) => {
|
|
448
|
+
if (!withinEventContext) {
|
|
449
|
+
throw new UsageError(
|
|
450
|
+
"Cannot get a revertible outside of the context of a changed event.",
|
|
468
451
|
);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
452
|
+
}
|
|
453
|
+
if (this.revertibleCommitBranches.get(revision) !== undefined) {
|
|
454
|
+
throw new UsageError(
|
|
455
|
+
"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.",
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
const revertible = this.createRevertible(
|
|
459
|
+
revision,
|
|
460
|
+
kind,
|
|
461
|
+
this,
|
|
462
|
+
onRevertibleDisposed,
|
|
463
|
+
);
|
|
464
|
+
this.revertibleCommitBranches.set(
|
|
465
|
+
revision,
|
|
466
|
+
this.#transaction.activeBranch.fork(commit),
|
|
467
|
+
);
|
|
468
|
+
this.revertibles.add(revertible);
|
|
469
|
+
return revertible;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
let withinEventContext = true;
|
|
473
|
+
this.#events.emit("changed", { isLocal: true, kind }, getRevertible);
|
|
474
|
+
withinEventContext = false;
|
|
481
475
|
}
|
|
476
|
+
} else if (this.isRemoteChangeEvent(event)) {
|
|
477
|
+
// TODO: figure out how to plumb through commit kind info for remote changes
|
|
478
|
+
this.#events.emit("changed", { isLocal: false, kind: CommitKind.Default });
|
|
482
479
|
}
|
|
483
480
|
});
|
|
484
481
|
|
|
482
|
+
this.#transaction.activeBranchEvents.on("afterChange", this.onAfterChange);
|
|
483
|
+
this.#transaction.activeBranchEvents.on("ancestryTrimmed", this.onAncestryTrimmed);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
private readonly onAfterChange = (event: SharedTreeBranchChange<SharedTreeChange>): void => {
|
|
487
|
+
this.#events.emit("beforeBatch", event);
|
|
488
|
+
if (event.change !== undefined) {
|
|
489
|
+
const revision =
|
|
490
|
+
event.type === "rebase"
|
|
491
|
+
? this.#transaction.activeBranch.getHead().revision
|
|
492
|
+
: event.change.revision;
|
|
493
|
+
|
|
494
|
+
// Conflicts due to schema will be empty and thus are not applied.
|
|
495
|
+
for (const change of event.change.change.changes) {
|
|
496
|
+
if (change.type === "data") {
|
|
497
|
+
const delta = intoDelta(tagChange(change.innerChange, revision));
|
|
498
|
+
this.withCombinedVisitor((visitor) => {
|
|
499
|
+
visitDelta(delta, visitor, this.removedRoots, revision);
|
|
500
|
+
});
|
|
501
|
+
} else if (change.type === "schema") {
|
|
502
|
+
// Schema changes from a current to a new schema are expected to be backwards compatible.
|
|
503
|
+
// This guarantees that all data in the forest (which is valid before the schema change)
|
|
504
|
+
// is also valid under the new schema.
|
|
505
|
+
// Note however, that such schema changes may in some cases be rolled back:
|
|
506
|
+
// Case 1: A transaction with a schema change may be aborted.
|
|
507
|
+
// The transaction may have made some data changes that would render some trees invalid
|
|
508
|
+
// under the old schema, but these changes will also be rolled back, thereby putting the forest
|
|
509
|
+
// back in the state before the transaction, which is valid under the original (reinstated) schema.
|
|
510
|
+
// Case 2: A branch with a schema change may be rebased such that the schema change (because
|
|
511
|
+
// of a constraint) is no longer applied.
|
|
512
|
+
// Such a branch may contain data changes that would render some trees invalid under the
|
|
513
|
+
// original schema. These data changes may not necessarily be rolled back.
|
|
514
|
+
// They will however be rebased over the rollback of the schema change. This rebasing will
|
|
515
|
+
// ensure that these data changes are muted if they would render some trees invalid under the
|
|
516
|
+
// original (reinstated) schema.
|
|
517
|
+
this.storedSchema.apply(change.innerChange.schema.new);
|
|
518
|
+
} else {
|
|
519
|
+
fail("Unknown Shared Tree change type.");
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
this.#events.emit("afterBatch");
|
|
524
|
+
if (event.type === "append") {
|
|
525
|
+
event.newCommits.forEach((commit) => this.validateCommit(commit));
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
private readonly onAncestryTrimmed = (revisions: RevisionTag[]): void => {
|
|
485
530
|
// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the
|
|
486
531
|
// trimmed revisions.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
532
|
+
this.withCombinedVisitor((visitor) => {
|
|
533
|
+
revisions.forEach((revision) => {
|
|
534
|
+
// get all the roots last created or used by the revision
|
|
535
|
+
const roots = this.removedRoots.getRootsLastTouchedByRevision(revision);
|
|
536
|
+
|
|
537
|
+
// get the detached field for the root and delete it from the removed roots
|
|
538
|
+
for (const root of roots) {
|
|
539
|
+
visitor.destroy(this.removedRoots.toFieldKey(root), 1);
|
|
540
|
+
}
|
|
497
541
|
|
|
498
|
-
|
|
499
|
-
});
|
|
542
|
+
this.removedRoots.deleteRootsLastTouchedByRevision(revision);
|
|
500
543
|
});
|
|
501
544
|
});
|
|
502
|
-
}
|
|
545
|
+
};
|
|
503
546
|
|
|
504
547
|
private withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {
|
|
505
548
|
const anchorVisitor = this.forest.anchors.acquireVisitor();
|
|
@@ -622,7 +665,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
622
665
|
|
|
623
666
|
public get editor(): ISharedTreeEditor {
|
|
624
667
|
this.checkNotDisposed();
|
|
625
|
-
return this.
|
|
668
|
+
return this.#transaction.activeBranchEditor;
|
|
626
669
|
}
|
|
627
670
|
|
|
628
671
|
public locate(anchor: Anchor): AnchorNode | undefined {
|
|
@@ -643,53 +686,14 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
643
686
|
* To avoid updating observers of the view state with intermediate results during a transaction,
|
|
644
687
|
* use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.
|
|
645
688
|
*/
|
|
646
|
-
readonly #transaction
|
|
647
|
-
// Keep track of the commit that each transaction was on when it started
|
|
648
|
-
// TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.
|
|
649
|
-
const startCommit = this._branch.getHead();
|
|
650
|
-
// Keep track of all the forks created during the transaction so that we can dispose them when the transaction ends.
|
|
651
|
-
// This is a policy decision that we think is useful for the user, but it is not necessary for correctness.
|
|
652
|
-
const forks = new Set<TreeCheckout>();
|
|
653
|
-
const onDisposeUnSubscribes: (() => void)[] = [];
|
|
654
|
-
const onForkUnSubscribe = onForkTransitive(this, (fork) => {
|
|
655
|
-
forks.add(fork);
|
|
656
|
-
onDisposeUnSubscribes.push(fork.events.on("dispose", () => forks.delete(fork)));
|
|
657
|
-
});
|
|
658
|
-
// When each transaction is started, take a snapshot of the current state of removed roots
|
|
659
|
-
const removedRoots = this.removedRoots.clone();
|
|
660
|
-
this._branch.editor.enterTransaction();
|
|
661
|
-
return (result) => {
|
|
662
|
-
this._branch.editor.exitTransaction();
|
|
663
|
-
switch (result) {
|
|
664
|
-
case TransactionResult.Abort:
|
|
665
|
-
this._branch.removeAfter(startCommit);
|
|
666
|
-
// If a transaction is rolled back, revert removed roots back to the latest snapshot
|
|
667
|
-
this.removedRoots = removedRoots;
|
|
668
|
-
break;
|
|
669
|
-
case TransactionResult.Commit: {
|
|
670
|
-
const removedCommits = this._branch.squashAfter(startCommit);
|
|
671
|
-
const transactionRevision = this._branch.getHead().revision;
|
|
672
|
-
for (const transactionStep of removedCommits) {
|
|
673
|
-
this.removedRoots.updateMajor(transactionStep.revision, transactionRevision);
|
|
674
|
-
}
|
|
675
|
-
break;
|
|
676
|
-
}
|
|
677
|
-
default:
|
|
678
|
-
unreachableCase(result);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
forks.forEach((fork) => fork.dispose());
|
|
682
|
-
onDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());
|
|
683
|
-
onForkUnSubscribe();
|
|
684
|
-
};
|
|
685
|
-
});
|
|
689
|
+
readonly #transaction: SquashingTransactionStack<SharedTreeEditBuilder, SharedTreeChange>;
|
|
686
690
|
|
|
687
691
|
public branch(): TreeCheckout {
|
|
688
692
|
this.checkNotDisposed(
|
|
689
693
|
"The parent branch has already been disposed and can no longer create new branches.",
|
|
690
694
|
);
|
|
691
695
|
const anchors = new AnchorSet();
|
|
692
|
-
const branch = this.
|
|
696
|
+
const branch = this.#transaction.activeBranch.fork();
|
|
693
697
|
const storedSchema = this.storedSchema.clone();
|
|
694
698
|
const forest = this.forest.clone(storedSchema, anchors);
|
|
695
699
|
const checkout = new TreeCheckout(
|
|
@@ -698,7 +702,6 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
698
702
|
this.changeFamily,
|
|
699
703
|
storedSchema,
|
|
700
704
|
forest,
|
|
701
|
-
createEmitter(),
|
|
702
705
|
this.mintRevisionTag,
|
|
703
706
|
this.revisionTagCodec,
|
|
704
707
|
this.idCompressor,
|
|
@@ -706,7 +709,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
706
709
|
this.logger,
|
|
707
710
|
this.breaker,
|
|
708
711
|
);
|
|
709
|
-
this
|
|
712
|
+
this.#events.emit("fork", checkout);
|
|
710
713
|
return checkout;
|
|
711
714
|
}
|
|
712
715
|
|
|
@@ -726,7 +729,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
726
729
|
0xa5d /* The main branch cannot be rebased onto another branch. */,
|
|
727
730
|
);
|
|
728
731
|
|
|
729
|
-
checkout.
|
|
732
|
+
checkout.#transaction.activeBranch.rebaseOnto(this.#transaction.activeBranch);
|
|
730
733
|
}
|
|
731
734
|
|
|
732
735
|
public rebaseOnto(checkout: ITreeCheckout): void {
|
|
@@ -752,7 +755,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
752
755
|
while (checkout.transaction.isInProgress()) {
|
|
753
756
|
checkout.transaction.commit();
|
|
754
757
|
}
|
|
755
|
-
this.
|
|
758
|
+
this.#transaction.activeBranch.merge(checkout.#transaction.activeBranch);
|
|
756
759
|
if (disposeMerged && checkout.isBranch) {
|
|
757
760
|
// Dispose the merged checkout unless it is the main branch.
|
|
758
761
|
checkout[disposeSymbol]();
|
|
@@ -773,13 +776,13 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
773
776
|
"The branch has already been disposed and cannot be disposed again.",
|
|
774
777
|
);
|
|
775
778
|
this.disposed = true;
|
|
779
|
+
this.#transaction.branch.dispose();
|
|
776
780
|
this.#transaction.dispose();
|
|
777
781
|
this.purgeRevertibles();
|
|
778
|
-
this._branch.dispose();
|
|
779
782
|
for (const view of this.views) {
|
|
780
783
|
view.dispose();
|
|
781
784
|
}
|
|
782
|
-
this
|
|
785
|
+
this.#events.emit("dispose");
|
|
783
786
|
}
|
|
784
787
|
|
|
785
788
|
public getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {
|
|
@@ -800,11 +803,16 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
800
803
|
}
|
|
801
804
|
|
|
802
805
|
/**
|
|
803
|
-
* This
|
|
804
|
-
* This
|
|
806
|
+
* This must be called on the root/main checkout after loading from a summary.
|
|
807
|
+
* @remarks This pattern is necessary because the EditManager skips the normal process of applying commits to branches when loading a summary.
|
|
808
|
+
* Instead, it simply {@link SharedTreeBranch#setHead | mutates} the branches directly which does not propagate the typical events throughout the rest of the system.
|
|
805
809
|
*/
|
|
806
|
-
public
|
|
807
|
-
this.
|
|
810
|
+
public load(): void {
|
|
811
|
+
// Set the tip revision as the latest relevant revision for any removed roots that are loaded from a summary - this allows them to be garbage collected later.
|
|
812
|
+
// When a load happens, the head of the trunk and the head of the local/main branch must be the same (this is enforced by SharedTree).
|
|
813
|
+
this.removedRoots.setRevisionsForLoadedData(this.#transaction.branch.getHead().revision);
|
|
814
|
+
// The content of the checkout (e.g. the forest) has (maybe) changed, so fire an afterBatch event.
|
|
815
|
+
this.#events.emit("afterBatch");
|
|
808
816
|
}
|
|
809
817
|
|
|
810
818
|
private purgeRevertibles(): void {
|
|
@@ -834,7 +842,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
834
842
|
revisionForInvert,
|
|
835
843
|
);
|
|
836
844
|
|
|
837
|
-
const headCommit = this.
|
|
845
|
+
const headCommit = this.#transaction.activeBranch.getHead();
|
|
838
846
|
// Rebase the inverted change onto any commits that occurred after the undoable commits.
|
|
839
847
|
if (commitToRevert !== headCommit) {
|
|
840
848
|
change = tagChange(
|
|
@@ -849,7 +857,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
849
857
|
);
|
|
850
858
|
}
|
|
851
859
|
|
|
852
|
-
this.
|
|
860
|
+
this.#transaction.activeBranch.apply(
|
|
853
861
|
change,
|
|
854
862
|
kind === CommitKind.Default || kind === CommitKind.Redo
|
|
855
863
|
? CommitKind.Undo
|
|
@@ -901,8 +909,49 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
901
909
|
!this.isBranch &&
|
|
902
910
|
// Remote changes are applied to the main branch by rebasing it onto the trunk.
|
|
903
911
|
// No other rebases are allowed on the main branch, so we can use this to detect remote changes.
|
|
904
|
-
event.type === "
|
|
905
|
-
getChangeReplaceType(event) === "rebase"
|
|
912
|
+
event.type === "rebase"
|
|
906
913
|
);
|
|
907
914
|
}
|
|
915
|
+
|
|
916
|
+
// #region Commit Validation
|
|
917
|
+
|
|
918
|
+
/** Used to maintain the contract of {@link onCommitValid}(). */
|
|
919
|
+
#validatedCommits = new WeakMap<
|
|
920
|
+
GraphCommit<SharedTreeChange>,
|
|
921
|
+
((commit: GraphCommit<SharedTreeChange>) => void)[] | true
|
|
922
|
+
>();
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Registers a function to be called when the given commit is validated.
|
|
926
|
+
* @remarks A commit is validated by the checkout after it has been applied to the checkout's state (e.g. it has an effect on the forest).
|
|
927
|
+
* If the commit applies successfully (i.e. it does not raise any unexpected errors), the commit is considered valid and the registered function is called.
|
|
928
|
+
* If the commit does not apply successfully (because it causes an unexpected error), the function is not called (and the checkout will left in an error state).
|
|
929
|
+
*
|
|
930
|
+
* If the commit has already been validated when this function is called, the function is called immediately and this function returns `true`.
|
|
931
|
+
* Otherwise, the function is registered to be called later and this function returns `false`.
|
|
932
|
+
*/
|
|
933
|
+
public onCommitValid(
|
|
934
|
+
commit: GraphCommit<SharedTreeChange>,
|
|
935
|
+
fn: (commit: GraphCommit<SharedTreeChange>) => void,
|
|
936
|
+
): boolean {
|
|
937
|
+
const validated = getOrCreate(this.#validatedCommits, commit, () => []);
|
|
938
|
+
if (validated === true) {
|
|
939
|
+
fn(commit);
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
validated.push(fn);
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/** Mark the given commit as "validated" according to the contract of {@link onCommitValid}(). */
|
|
948
|
+
private validateCommit(commit: GraphCommit<SharedTreeChange>): void {
|
|
949
|
+
const validated = getOrCreate(this.#validatedCommits, commit, () => []);
|
|
950
|
+
if (validated !== true) {
|
|
951
|
+
validated.forEach((fn) => fn(commit));
|
|
952
|
+
this.#validatedCommits.set(commit, true);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// #endregion Commit Validation
|
|
908
957
|
}
|