@fluidframework/tree 2.10.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 +29 -0
- package/api-report/tree.alpha.api.md +49 -18
- package/api-report/tree.beta.api.md +6 -15
- package/api-report/tree.legacy.alpha.api.md +6 -15
- package/api-report/tree.legacy.public.api.md +6 -15
- package/api-report/tree.public.api.md +6 -15
- package/dist/alpha.d.ts +9 -0
- package/dist/core/forest/forest.d.ts +10 -2
- package/dist/core/forest/forest.d.ts.map +1 -1
- package/dist/core/forest/forest.js.map +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +1 -1
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +13 -17
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/revertible.d.ts +30 -1
- package/dist/core/revertible.d.ts.map +1 -1
- package/dist/core/revertible.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-stored/storedSchemaRepository.d.ts +2 -2
- package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/dist/core/schema-stored/storedSchemaRepository.js +5 -5
- package/dist/core/schema-stored/storedSchemaRepository.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/core/tree/anchorSet.d.ts +2 -2
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +21 -21
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/{lib/feature-libraries/chunked-forest → dist/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/detachedFieldIndexCodec.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
- package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/dist/core/tree/index.d.ts +2 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +6 -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/core/tree/visitorUtils.d.ts +25 -1
- package/dist/core/tree/visitorUtils.d.ts.map +1 -1
- package/dist/core/tree/visitorUtils.js +29 -1
- package/dist/core/tree/visitorUtils.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 +5 -3
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +24 -14
- 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 +14 -14
- 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/flex-tree/context.d.ts +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +2 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +9 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +139 -0
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +387 -0
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
- package/dist/feature-libraries/indexing/index.d.ts +7 -0
- package/dist/feature-libraries/indexing/index.d.ts.map +1 -0
- package/dist/feature-libraries/indexing/index.js +11 -0
- package/dist/feature-libraries/indexing/index.js.map +1 -0
- package/dist/feature-libraries/indexing/types.d.ts +32 -0
- package/dist/feature-libraries/indexing/types.d.ts.map +1 -0
- package/dist/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
- package/dist/feature-libraries/indexing/types.js.map +1 -0
- 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/object-forest/objectForest.d.ts +5 -2
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +21 -11
- package/dist/feature-libraries/object-forest/objectForest.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/invert.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +2 -2
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +3 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- 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 +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -13
- 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 +2 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +1 -2
- 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 +7 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +35 -38
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +27 -6
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +146 -21
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +3 -3
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +59 -72
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +243 -188
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +29 -107
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +51 -195
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +24 -32
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +70 -53
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js +2 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +4 -4
- 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 +5 -4
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +3 -10
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +14 -67
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +146 -0
- package/dist/shared-tree-core/transaction.d.ts.map +1 -0
- package/dist/shared-tree-core/transaction.js +211 -0
- package/dist/shared-tree-core/transaction.js.map +1 -0
- package/dist/shared-tree-core/transactionEnricher.d.ts +8 -13
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +41 -21
- package/dist/shared-tree-core/transactionEnricher.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/identifierIndex.d.ts +21 -0
- package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -0
- package/dist/simple-tree/api/identifierIndex.js +45 -0
- package/dist/simple-tree/api/identifierIndex.js.map +1 -0
- package/dist/simple-tree/api/index.d.ts +4 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +8 -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/simpleSchemaToJsonSchema.js +9 -7
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.d.ts +65 -0
- package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
- package/dist/simple-tree/api/simpleTreeIndex.js +93 -0
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
- 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 +5 -5
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js.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/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -2
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +53 -22
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +2 -2
- package/dist/simple-tree/core/unhydratedFlexTree.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 +7 -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 +15 -5
- 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/toMapTree.js +3 -3
- package/dist/simple-tree/toMapTree.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 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +6 -4
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeCheck.d.ts +6 -3
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/typeCheckTests.d.ts +14 -2
- package/dist/util/typeCheckTests.d.ts.map +1 -1
- package/dist/util/typeCheckTests.js.map +1 -1
- package/dist/util/utils.d.ts +42 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +35 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +9 -0
- package/lib/core/forest/forest.d.ts +10 -2
- package/lib/core/forest/forest.d.ts.map +1 -1
- package/lib/core/forest/forest.js.map +1 -1
- package/lib/core/index.d.ts +3 -3
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +3 -3
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/utils.d.ts +1 -1
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +13 -17
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/revertible.d.ts +30 -1
- package/lib/core/revertible.d.ts.map +1 -1
- package/lib/core/revertible.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-stored/storedSchemaRepository.d.ts +2 -2
- package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.js +1 -1
- package/lib/core/schema-stored/storedSchemaRepository.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/core/tree/anchorSet.d.ts +2 -2
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +1 -1
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/{dist/feature-libraries/chunked-forest → lib/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/detachedFieldIndexCodec.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
- package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
- package/lib/core/tree/index.d.ts +2 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +2 -1
- 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/core/tree/visitorUtils.d.ts +25 -1
- package/lib/core/tree/visitorUtils.d.ts.map +1 -1
- package/lib/core/tree/visitorUtils.js +27 -0
- package/lib/core/tree/visitorUtils.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 +5 -3
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -8
- 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 +4 -4
- 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/flex-tree/context.d.ts +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +2 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +139 -0
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +382 -0
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
- package/lib/feature-libraries/indexing/index.d.ts +7 -0
- package/lib/feature-libraries/indexing/index.d.ts.map +1 -0
- package/lib/{events → feature-libraries/indexing}/index.js +1 -1
- package/lib/feature-libraries/indexing/index.js.map +1 -0
- package/lib/feature-libraries/indexing/types.d.ts +32 -0
- package/lib/feature-libraries/indexing/types.d.ts.map +1 -0
- package/lib/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
- package/lib/feature-libraries/indexing/types.js.map +1 -0
- 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/object-forest/objectForest.d.ts +5 -2
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +15 -5
- package/lib/feature-libraries/object-forest/objectForest.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/invert.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +4 -4
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -3
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- 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 +6 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -4
- 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 +2 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +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 +7 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +12 -16
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +27 -6
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +135 -10
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +5 -5
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +59 -72
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +233 -177
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +29 -107
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +50 -193
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +24 -32
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +71 -54
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +4 -4
- 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 +3 -10
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +15 -68
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +146 -0
- package/lib/shared-tree-core/transaction.d.ts.map +1 -0
- package/lib/shared-tree-core/transaction.js +206 -0
- package/lib/shared-tree-core/transaction.js.map +1 -0
- package/lib/shared-tree-core/transactionEnricher.d.ts +8 -13
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +41 -21
- package/lib/shared-tree-core/transactionEnricher.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/identifierIndex.d.ts +21 -0
- package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -0
- package/lib/simple-tree/api/identifierIndex.js +41 -0
- package/lib/simple-tree/api/identifierIndex.js.map +1 -0
- package/lib/simple-tree/api/index.d.ts +4 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +4 -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/simpleSchemaToJsonSchema.js +11 -9
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.d.ts +65 -0
- package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
- package/lib/simple-tree/api/simpleTreeIndex.js +89 -0
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
- 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 +5 -5
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js.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/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -2
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +31 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.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 +15 -5
- 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/toMapTree.js +5 -5
- package/lib/simple-tree/toMapTree.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 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/typeCheck.d.ts +6 -3
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/typeCheckTests.d.ts +14 -2
- package/lib/util/typeCheckTests.d.ts.map +1 -1
- package/lib/util/typeCheckTests.js.map +1 -1
- package/lib/util/utils.d.ts +42 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +30 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +23 -23
- package/src/core/forest/forest.ts +12 -1
- package/src/core/index.ts +13 -2
- package/src/core/rebase/utils.ts +28 -29
- package/src/core/revertible.ts +35 -1
- package/src/core/schema-stored/format.ts +0 -3
- package/src/core/schema-stored/schema.ts +13 -10
- package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
- package/src/core/schema-view/index.ts +0 -1
- package/src/core/schema-view/view.ts +0 -11
- package/src/core/tree/anchorSet.ts +2 -1
- package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
- package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
- package/src/core/tree/index.ts +9 -0
- package/src/core/tree/treeTextFormat.ts +0 -5
- package/src/core/tree/types.ts +0 -5
- package/src/core/tree/visitorUtils.ts +56 -1
- 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 +35 -8
- 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 +7 -4
- package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
- package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
- package/src/feature-libraries/flex-tree/context.ts +1 -1
- package/src/feature-libraries/index.ts +22 -0
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +482 -0
- package/src/feature-libraries/indexing/index.ts +11 -0
- package/src/feature-libraries/indexing/types.ts +37 -0
- 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/object-forest/objectForest.ts +22 -4
- package/src/feature-libraries/sequence-field/invert.ts +4 -4
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -4
- package/src/feature-libraries/sequence-field/types.ts +0 -1
- package/src/index.ts +17 -35
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +1 -2
- package/src/shared-tree/schematizeTree.ts +6 -10
- package/src/shared-tree/schematizingTreeView.ts +18 -28
- package/src/shared-tree/sharedTree.ts +216 -30
- package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
- package/src/shared-tree/treeCheckout.ts +341 -299
- package/src/shared-tree-core/branch.ts +80 -300
- package/src/shared-tree-core/branchCommitEnricher.ts +66 -62
- package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
- package/src/shared-tree-core/editManager.ts +4 -9
- package/src/shared-tree-core/index.ts +11 -3
- package/src/shared-tree-core/sharedTreeCore.ts +23 -79
- package/src/shared-tree-core/transaction.ts +310 -0
- package/src/shared-tree-core/transactionEnricher.ts +30 -24
- 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/identifierIndex.ts +64 -0
- package/src/simple-tree/api/index.ts +17 -2
- package/src/simple-tree/api/schemaFactory.ts +62 -1
- package/src/simple-tree/api/simpleSchema.ts +3 -1
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
- package/src/simple-tree/api/simpleTreeIndex.ts +233 -0
- package/src/simple-tree/api/storedSchema.ts +7 -22
- package/src/simple-tree/api/tree.ts +14 -5
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- package/src/simple-tree/api/verboseTree.ts +2 -2
- package/src/simple-tree/api/view.ts +197 -51
- package/src/simple-tree/core/index.ts +1 -0
- package/src/simple-tree/core/treeNodeKernel.ts +37 -2
- package/src/simple-tree/core/unhydratedFlexTree.ts +2 -1
- package/src/simple-tree/index.ts +10 -0
- package/src/simple-tree/leafNodeSchema.ts +0 -19
- package/src/simple-tree/objectNode.ts +45 -14
- package/src/simple-tree/objectNodeTypes.ts +5 -0
- package/src/simple-tree/schemaTypes.ts +7 -2
- package/src/simple-tree/toMapTree.ts +5 -5
- package/src/simple-tree/toStoredSchema.ts +25 -19
- package/src/util/brand.ts +0 -2
- package/src/util/index.ts +4 -1
- package/src/util/typeCheck.ts +6 -3
- package/src/util/typeCheckTests.ts +11 -1
- package/src/util/utils.ts +64 -0
- package/dist/events/emitter.d.ts +0 -139
- package/dist/events/emitter.d.ts.map +0 -1
- package/dist/events/emitter.js +0 -165
- package/dist/events/emitter.js.map +0 -1
- package/dist/events/index.d.ts +0 -7
- package/dist/events/index.d.ts.map +0 -1
- package/dist/events/index.js +0 -11
- package/dist/events/index.js.map +0 -1
- package/dist/events/interop.d.ts +0 -30
- package/dist/events/interop.d.ts.map +0 -1
- package/dist/events/interop.js.map +0 -1
- package/dist/events/listeners.d.ts +0 -76
- package/dist/events/listeners.d.ts.map +0 -1
- package/dist/events/listeners.js +0 -7
- package/dist/events/listeners.js.map +0 -1
- package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
- package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
- package/dist/shared-tree-core/transactionStack.d.ts +0 -29
- package/dist/shared-tree-core/transactionStack.d.ts.map +0 -1
- package/dist/shared-tree-core/transactionStack.js +0 -41
- package/dist/shared-tree-core/transactionStack.js.map +0 -1
- package/dist/util/transactionResult.d.ts +0 -19
- package/dist/util/transactionResult.d.ts.map +0 -1
- package/dist/util/transactionResult.js +0 -23
- package/dist/util/transactionResult.js.map +0 -1
- package/lib/events/emitter.d.ts +0 -139
- package/lib/events/emitter.d.ts.map +0 -1
- package/lib/events/emitter.js +0 -160
- package/lib/events/emitter.js.map +0 -1
- package/lib/events/index.d.ts +0 -7
- package/lib/events/index.d.ts.map +0 -1
- package/lib/events/index.js.map +0 -1
- package/lib/events/interop.d.ts +0 -30
- package/lib/events/interop.d.ts.map +0 -1
- package/lib/events/interop.js.map +0 -1
- package/lib/events/listeners.d.ts +0 -76
- package/lib/events/listeners.d.ts.map +0 -1
- package/lib/events/listeners.js +0 -6
- package/lib/events/listeners.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
- package/lib/shared-tree-core/transactionStack.d.ts +0 -29
- package/lib/shared-tree-core/transactionStack.d.ts.map +0 -1
- package/lib/shared-tree-core/transactionStack.js +0 -37
- package/lib/shared-tree-core/transactionStack.js.map +0 -1
- package/lib/util/transactionResult.d.ts +0 -19
- package/lib/util/transactionResult.d.ts.map +0 -1
- package/lib/util/transactionResult.js +0 -20
- package/lib/util/transactionResult.js.map +0 -1
- package/src/events/README.md +0 -3
- package/src/events/emitter.ts +0 -256
- package/src/events/index.ts +0 -19
- package/src/events/interop.ts +0 -38
- package/src/events/listeners.ts +0 -80
- package/src/shared-tree-core/transactionStack.ts +0 -45
- package/src/util/transactionResult.ts +0 -19
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert,
|
|
6
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import type { Listenable } from "@fluidframework/core-interfaces/internal";
|
|
8
|
+
import { createEmitter } from "@fluid-internal/client-utils";
|
|
7
9
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
8
10
|
import {
|
|
9
11
|
UsageError,
|
|
@@ -24,7 +26,6 @@ import {
|
|
|
24
26
|
type IEditableForest,
|
|
25
27
|
type IForestSubscription,
|
|
26
28
|
type JsonableTree,
|
|
27
|
-
type Revertible,
|
|
28
29
|
RevertibleStatus,
|
|
29
30
|
type RevisionTag,
|
|
30
31
|
type RevisionTagCodec,
|
|
@@ -37,14 +38,10 @@ import {
|
|
|
37
38
|
rootFieldKey,
|
|
38
39
|
tagChange,
|
|
39
40
|
visitDelta,
|
|
40
|
-
type
|
|
41
|
+
type RevertibleAlphaFactory,
|
|
42
|
+
type RevertibleAlpha,
|
|
43
|
+
type GraphCommit,
|
|
41
44
|
} from "../core/index.js";
|
|
42
|
-
import {
|
|
43
|
-
type HasListeners,
|
|
44
|
-
type IEmitter,
|
|
45
|
-
type Listenable,
|
|
46
|
-
createEmitter,
|
|
47
|
-
} from "../events/index.js";
|
|
48
45
|
import {
|
|
49
46
|
type FieldBatchCodec,
|
|
50
47
|
type TreeCompressionStrategy,
|
|
@@ -55,11 +52,14 @@ import {
|
|
|
55
52
|
makeFieldBatchCodec,
|
|
56
53
|
} from "../feature-libraries/index.js";
|
|
57
54
|
import {
|
|
55
|
+
SquashingTransactionStack,
|
|
58
56
|
SharedTreeBranch,
|
|
59
|
-
|
|
57
|
+
TransactionResult,
|
|
58
|
+
onForkTransitive,
|
|
60
59
|
type SharedTreeBranchChange,
|
|
60
|
+
type Transactor,
|
|
61
61
|
} from "../shared-tree-core/index.js";
|
|
62
|
-
import { Breakable,
|
|
62
|
+
import { Breakable, disposeSymbol, fail, getOrCreate } from "../util/index.js";
|
|
63
63
|
|
|
64
64
|
import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamily.js";
|
|
65
65
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
@@ -72,17 +72,29 @@ import type {
|
|
|
72
72
|
TreeViewConfiguration,
|
|
73
73
|
UnsafeUnknownSchema,
|
|
74
74
|
ViewableTree,
|
|
75
|
+
TreeBranch,
|
|
75
76
|
} from "../simple-tree/index.js";
|
|
76
|
-
import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
77
|
+
import { getCheckout, SchematizingSimpleTreeView } from "./schematizingTreeView.js";
|
|
77
78
|
|
|
78
79
|
/**
|
|
79
80
|
* Events for {@link ITreeCheckout}.
|
|
80
81
|
*/
|
|
81
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
|
+
|
|
82
92
|
/**
|
|
83
93
|
* A batch of changes has finished processing and the view is in a consistent state.
|
|
84
|
-
* 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.
|
|
85
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.
|
|
86
98
|
* @remarks
|
|
87
99
|
* This is mainly useful for knowing when to do followup work scheduled during events from Anchors.
|
|
88
100
|
*/
|
|
@@ -96,7 +108,17 @@ export interface CheckoutEvents {
|
|
|
96
108
|
* @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,
|
|
97
109
|
* this change is not revertible.
|
|
98
110
|
*/
|
|
99
|
-
changed(data: CommitMetadata, getRevertible?:
|
|
111
|
+
changed(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Fired when a new branch is created from this checkout.
|
|
115
|
+
*/
|
|
116
|
+
fork(branch: ITreeCheckout): void;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Fired when the checkout is disposed.
|
|
120
|
+
*/
|
|
121
|
+
dispose(): void;
|
|
100
122
|
}
|
|
101
123
|
|
|
102
124
|
/**
|
|
@@ -192,7 +214,7 @@ export interface ITreeCheckout extends AnchorLocator, ViewableTree {
|
|
|
192
214
|
/**
|
|
193
215
|
* A collection of functions for managing transactions.
|
|
194
216
|
*/
|
|
195
|
-
readonly transaction:
|
|
217
|
+
readonly transaction: Transactor;
|
|
196
218
|
|
|
197
219
|
branch(): ITreeCheckoutFork;
|
|
198
220
|
|
|
@@ -245,9 +267,6 @@ export function createTreeCheckout(
|
|
|
245
267
|
schema?: TreeStoredSchemaRepository;
|
|
246
268
|
forest?: IEditableForest;
|
|
247
269
|
fieldBatchCodec?: FieldBatchCodec;
|
|
248
|
-
events?: Listenable<CheckoutEvents> &
|
|
249
|
-
IEmitter<CheckoutEvents> &
|
|
250
|
-
HasListeners<CheckoutEvents>;
|
|
251
270
|
removedRoots?: DetachedFieldIndex;
|
|
252
271
|
chunkCompressionStrategy?: TreeCompressionStrategy;
|
|
253
272
|
logger?: ITelemetryLoggerExt;
|
|
@@ -278,18 +297,13 @@ export function createTreeCheckout(
|
|
|
278
297
|
changeFamily,
|
|
279
298
|
() => idCompressor.generateCompressedId(),
|
|
280
299
|
);
|
|
281
|
-
const events = args?.events ?? createEmitter();
|
|
282
|
-
|
|
283
|
-
const transaction = new Transaction(branch);
|
|
284
300
|
|
|
285
301
|
return new TreeCheckout(
|
|
286
|
-
transaction,
|
|
287
302
|
branch,
|
|
288
303
|
false,
|
|
289
304
|
changeFamily,
|
|
290
305
|
schema,
|
|
291
306
|
forest,
|
|
292
|
-
events,
|
|
293
307
|
mintRevisionTag,
|
|
294
308
|
revisionTagCodec,
|
|
295
309
|
idCompressor,
|
|
@@ -299,74 +313,6 @@ export function createTreeCheckout(
|
|
|
299
313
|
);
|
|
300
314
|
}
|
|
301
315
|
|
|
302
|
-
/**
|
|
303
|
-
* A collection of functions for managing transactions.
|
|
304
|
-
* Transactions allow edits to be batched into atomic units.
|
|
305
|
-
* Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.
|
|
306
|
-
* If the transaction is aborted, the local state will be reset to what it was before the transaction began.
|
|
307
|
-
* Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.
|
|
308
|
-
*
|
|
309
|
-
* To avoid updating observers of the view state with intermediate results during a transaction,
|
|
310
|
-
* use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.
|
|
311
|
-
*/
|
|
312
|
-
export interface ITransaction {
|
|
313
|
-
/**
|
|
314
|
-
* Start a new transaction.
|
|
315
|
-
* If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
|
|
316
|
-
* i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
|
|
317
|
-
*
|
|
318
|
-
* @remarks - Asynchronous transactions are not supported on the root checkout,
|
|
319
|
-
* since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
|
|
320
|
-
* the transaction) is not visible to the application author.
|
|
321
|
-
* Instead,
|
|
322
|
-
*
|
|
323
|
-
* 1. fork the root checkout
|
|
324
|
-
* 2. run the transaction on the fork
|
|
325
|
-
* 3. merge the fork back into the root checkout
|
|
326
|
-
*
|
|
327
|
-
* @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
|
|
328
|
-
* AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
|
|
329
|
-
*/
|
|
330
|
-
start(): void;
|
|
331
|
-
/**
|
|
332
|
-
* Close this transaction by squashing its edits and committing them as a single edit.
|
|
333
|
-
* If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
|
|
334
|
-
*/
|
|
335
|
-
commit(): TransactionResult.Commit;
|
|
336
|
-
/**
|
|
337
|
-
* Close this transaction and revert the state of the tree to what it was before this transaction began.
|
|
338
|
-
*/
|
|
339
|
-
abort(): TransactionResult.Abort;
|
|
340
|
-
/**
|
|
341
|
-
* True if there is at least one transaction currently in progress on this view, otherwise false.
|
|
342
|
-
*/
|
|
343
|
-
inProgress(): boolean;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
class Transaction implements ITransaction {
|
|
347
|
-
public constructor(
|
|
348
|
-
private readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,
|
|
349
|
-
) {}
|
|
350
|
-
|
|
351
|
-
public start(): void {
|
|
352
|
-
this.branch.startTransaction();
|
|
353
|
-
this.branch.editor.enterTransaction();
|
|
354
|
-
}
|
|
355
|
-
public commit(): TransactionResult.Commit {
|
|
356
|
-
this.branch.commitTransaction();
|
|
357
|
-
this.branch.editor.exitTransaction();
|
|
358
|
-
return TransactionResult.Commit;
|
|
359
|
-
}
|
|
360
|
-
public abort(): TransactionResult.Abort {
|
|
361
|
-
this.branch.abortTransaction();
|
|
362
|
-
this.branch.editor.exitTransaction();
|
|
363
|
-
return TransactionResult.Abort;
|
|
364
|
-
}
|
|
365
|
-
public inProgress(): boolean {
|
|
366
|
-
return this.branch.isTransacting();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
316
|
/**
|
|
371
317
|
* Branch (like in a version control system) of SharedTree.
|
|
372
318
|
*
|
|
@@ -401,7 +347,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
401
347
|
/**
|
|
402
348
|
* Set of revertibles maintained for automatic disposal
|
|
403
349
|
*/
|
|
404
|
-
private readonly revertibles = new Set<
|
|
350
|
+
private readonly revertibles = new Set<RevertibleAlpha>();
|
|
405
351
|
|
|
406
352
|
/**
|
|
407
353
|
* Each branch's head commit corresponds to a revertible commit.
|
|
@@ -413,28 +359,22 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
413
359
|
SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>
|
|
414
360
|
>();
|
|
415
361
|
|
|
416
|
-
/**
|
|
417
|
-
* copies of the removed roots used as snapshots for reverting to previous state when transactions are aborted
|
|
418
|
-
*/
|
|
419
|
-
private readonly removedRootsSnapshots: DetachedFieldIndex[] = [];
|
|
420
|
-
|
|
421
362
|
/**
|
|
422
363
|
* The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.
|
|
423
364
|
* @privateRemarks Exposed for testing purposes.
|
|
424
365
|
*/
|
|
425
366
|
public static readonly revertTelemetryEventName = "RevertRevertible";
|
|
426
367
|
|
|
368
|
+
readonly #events = createEmitter<CheckoutEvents>();
|
|
369
|
+
public events: Listenable<CheckoutEvents> = this.#events;
|
|
370
|
+
|
|
427
371
|
public constructor(
|
|
428
|
-
|
|
429
|
-
private readonly _branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,
|
|
372
|
+
branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,
|
|
430
373
|
/** True if and only if this checkout is for a forked branch and not the "main branch" of the tree. */
|
|
431
374
|
public readonly isBranch: boolean,
|
|
432
375
|
private readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,
|
|
433
376
|
public readonly storedSchema: TreeStoredSchemaRepository,
|
|
434
377
|
public readonly forest: IEditableForest,
|
|
435
|
-
public readonly events: Listenable<CheckoutEvents> &
|
|
436
|
-
IEmitter<CheckoutEvents> &
|
|
437
|
-
HasListeners<CheckoutEvents>,
|
|
438
378
|
private readonly mintRevisionTag: () => RevisionTag,
|
|
439
379
|
private readonly revisionTagCodec: RevisionTagCodec,
|
|
440
380
|
private readonly idCompressor: IIdCompressor,
|
|
@@ -447,169 +387,162 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
447
387
|
private readonly logger?: ITelemetryLoggerExt,
|
|
448
388
|
private readonly breaker: Breakable = new Breakable("TreeCheckout"),
|
|
449
389
|
) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
});
|
|
458
|
-
// after a transaction is rolled back, revert removed roots back to the latest snapshot
|
|
459
|
-
_branch.events.on("transactionRolledBack", () => {
|
|
460
|
-
const snapshot = this.removedRootsSnapshots.pop();
|
|
461
|
-
assert(snapshot !== undefined, 0x9ae /* a snapshot for removed roots does not exist */);
|
|
462
|
-
this.removedRoots = snapshot;
|
|
463
|
-
});
|
|
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);
|
|
396
|
+
}
|
|
464
397
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
//
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
// back in the state before the transaction, which is valid under the original (reinstated) schema.
|
|
494
|
-
// Case 2: A branch with a schema change may be rebased such that the schema change (because
|
|
495
|
-
// of a constraint) is no longer applied.
|
|
496
|
-
// Such a branch may contain data changes that would render some trees invalid under the
|
|
497
|
-
// original schema. These data changes may not necessarily be rolled back.
|
|
498
|
-
// They will however be rebased over the rollback of the schema change. This rebasing will
|
|
499
|
-
// ensure that these data changes are muted if they would render some trees invalid under the
|
|
500
|
-
// original (reinstated) schema.
|
|
501
|
-
storedSchema.apply(change.innerChange.schema.new);
|
|
502
|
-
} else {
|
|
503
|
-
fail("Unknown Shared Tree change type.");
|
|
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);
|
|
504
426
|
}
|
|
427
|
+
|
|
428
|
+
forks.forEach((fork) => fork.dispose());
|
|
429
|
+
onDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());
|
|
430
|
+
onForkUnSubscribe();
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
branch.events.on("afterChange", (event) => {
|
|
436
|
+
// The following logic allows revertibles to be generated for the change.
|
|
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.",
|
|
451
|
+
);
|
|
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;
|
|
505
475
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const firstCommit = event.newCommits[0] ?? oob();
|
|
510
|
-
const transactionRevision = firstCommit.revision;
|
|
511
|
-
for (const transactionStep of event.removedCommits) {
|
|
512
|
-
this.removedRoots.updateMajor(transactionStep.revision, transactionRevision);
|
|
513
|
-
}
|
|
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 });
|
|
514
479
|
}
|
|
515
480
|
});
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
const revertMetrics = this.revertRevertible(revision, kind);
|
|
559
|
-
this.logger?.sendTelemetryEvent({
|
|
560
|
-
eventName: TreeCheckout.revertTelemetryEventName,
|
|
561
|
-
...revertMetrics,
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
if (release) {
|
|
565
|
-
revertible.dispose();
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
dispose: () => {
|
|
569
|
-
if (revertible.status === RevertibleStatus.Disposed) {
|
|
570
|
-
throw new UsageError(
|
|
571
|
-
"Unable to dispose a revertible that has already been disposed.",
|
|
572
|
-
);
|
|
573
|
-
}
|
|
574
|
-
this.disposeRevertible(revertible, revision);
|
|
575
|
-
onRevertibleDisposed?.(revertible);
|
|
576
|
-
},
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
this.revertibleCommitBranches.set(revision, _branch.fork(commit));
|
|
580
|
-
this.revertibles.add(revertible);
|
|
581
|
-
return revertible;
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
let withinEventContext = true;
|
|
585
|
-
this.events.emit("changed", { isLocal: true, kind }, getRevertible);
|
|
586
|
-
withinEventContext = false;
|
|
587
|
-
}
|
|
588
|
-
} else if (this.isRemoteChangeEvent(event)) {
|
|
589
|
-
// TODO: figure out how to plumb through commit kind info for remote changes
|
|
590
|
-
this.events.emit("changed", { isLocal: false, kind: CommitKind.Default });
|
|
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.");
|
|
591
520
|
}
|
|
592
521
|
}
|
|
593
|
-
}
|
|
522
|
+
}
|
|
523
|
+
this.#events.emit("afterBatch");
|
|
524
|
+
if (event.type === "append") {
|
|
525
|
+
event.newCommits.forEach((commit) => this.validateCommit(commit));
|
|
526
|
+
}
|
|
527
|
+
};
|
|
594
528
|
|
|
529
|
+
private readonly onAncestryTrimmed = (revisions: RevisionTag[]): void => {
|
|
595
530
|
// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the
|
|
596
531
|
// trimmed revisions.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
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
|
+
}
|
|
607
541
|
|
|
608
|
-
|
|
609
|
-
});
|
|
542
|
+
this.removedRoots.deleteRootsLastTouchedByRevision(revision);
|
|
610
543
|
});
|
|
611
544
|
});
|
|
612
|
-
}
|
|
545
|
+
};
|
|
613
546
|
|
|
614
547
|
private withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {
|
|
615
548
|
const anchorVisitor = this.forest.anchors.acquireVisitor();
|
|
@@ -630,6 +563,76 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
630
563
|
}
|
|
631
564
|
}
|
|
632
565
|
|
|
566
|
+
/**
|
|
567
|
+
* Creates a {@link RevertibleAlpha} object that can undo a specific change in the tree's history.
|
|
568
|
+
* Revision must exist in the given {@link TreeCheckout}'s branch.
|
|
569
|
+
*
|
|
570
|
+
* @param revision - The revision tag identifying the change to be made revertible.
|
|
571
|
+
* @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).
|
|
572
|
+
* @param checkout - The {@link TreeCheckout} instance this revertible belongs to.
|
|
573
|
+
* @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.
|
|
574
|
+
* @returns - {@link RevertibleAlpha}
|
|
575
|
+
*/
|
|
576
|
+
private createRevertible(
|
|
577
|
+
revision: RevisionTag,
|
|
578
|
+
kind: CommitKind,
|
|
579
|
+
checkout: TreeCheckout,
|
|
580
|
+
onRevertibleDisposed: ((revertible: RevertibleAlpha) => void) | undefined,
|
|
581
|
+
): RevertibleAlpha {
|
|
582
|
+
const commitBranches = checkout.revertibleCommitBranches;
|
|
583
|
+
|
|
584
|
+
const revertible: RevertibleAlpha = {
|
|
585
|
+
get status(): RevertibleStatus {
|
|
586
|
+
const revertibleCommit = commitBranches.get(revision);
|
|
587
|
+
return revertibleCommit === undefined
|
|
588
|
+
? RevertibleStatus.Disposed
|
|
589
|
+
: RevertibleStatus.Valid;
|
|
590
|
+
},
|
|
591
|
+
revert: (release: boolean = true) => {
|
|
592
|
+
if (revertible.status === RevertibleStatus.Disposed) {
|
|
593
|
+
throw new UsageError("Unable to revert a revertible that has been disposed.");
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const revertMetrics = checkout.revertRevertible(revision, kind);
|
|
597
|
+
checkout.logger?.sendTelemetryEvent({
|
|
598
|
+
eventName: TreeCheckout.revertTelemetryEventName,
|
|
599
|
+
...revertMetrics,
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
if (release) {
|
|
603
|
+
revertible.dispose();
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
clone: (forkedBranch: TreeBranch) => {
|
|
607
|
+
if (forkedBranch === undefined) {
|
|
608
|
+
return this.createRevertible(revision, kind, checkout, onRevertibleDisposed);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// TODO:#23442: When a revertible is cloned for a forked branch, optimize to create a fork of a revertible branch once per revision NOT once per revision per checkout.
|
|
612
|
+
const forkedCheckout = getCheckout(forkedBranch);
|
|
613
|
+
const revertibleBranch = this.revertibleCommitBranches.get(revision);
|
|
614
|
+
assert(
|
|
615
|
+
revertibleBranch !== undefined,
|
|
616
|
+
0xa82 /* change to revert does not exist on the given forked branch */,
|
|
617
|
+
);
|
|
618
|
+
forkedCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());
|
|
619
|
+
|
|
620
|
+
return this.createRevertible(revision, kind, forkedCheckout, onRevertibleDisposed);
|
|
621
|
+
},
|
|
622
|
+
dispose: () => {
|
|
623
|
+
if (revertible.status === RevertibleStatus.Disposed) {
|
|
624
|
+
throw new UsageError(
|
|
625
|
+
"Unable to dispose a revertible that has already been disposed.",
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
checkout.disposeRevertible(revertible, revision);
|
|
629
|
+
onRevertibleDisposed?.(revertible);
|
|
630
|
+
},
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
return revertible;
|
|
634
|
+
}
|
|
635
|
+
|
|
633
636
|
// For the new TreeViewAlpha API
|
|
634
637
|
public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
|
|
635
638
|
config: TreeViewConfiguration<ReadSchema<TRoot>>,
|
|
@@ -662,7 +665,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
662
665
|
|
|
663
666
|
public get editor(): ISharedTreeEditor {
|
|
664
667
|
this.checkNotDisposed();
|
|
665
|
-
return this.
|
|
668
|
+
return this.#transaction.activeBranchEditor;
|
|
666
669
|
}
|
|
667
670
|
|
|
668
671
|
public locate(anchor: Anchor): AnchorNode | undefined {
|
|
@@ -670,23 +673,35 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
670
673
|
return this.forest.anchors.locate(anchor);
|
|
671
674
|
}
|
|
672
675
|
|
|
676
|
+
public get transaction(): Transactor {
|
|
677
|
+
return this.#transaction;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* The {@link Transactor} for this checkout.
|
|
681
|
+
* @remarks In the context of a checkout, transactions allow edits to be batched into atomic units.
|
|
682
|
+
* Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.
|
|
683
|
+
* If the transaction is aborted, the local state will be reset to what it was before the transaction began.
|
|
684
|
+
* Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.
|
|
685
|
+
*
|
|
686
|
+
* To avoid updating observers of the view state with intermediate results during a transaction,
|
|
687
|
+
* use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.
|
|
688
|
+
*/
|
|
689
|
+
readonly #transaction: SquashingTransactionStack<SharedTreeEditBuilder, SharedTreeChange>;
|
|
690
|
+
|
|
673
691
|
public branch(): TreeCheckout {
|
|
674
692
|
this.checkNotDisposed(
|
|
675
693
|
"The parent branch has already been disposed and can no longer create new branches.",
|
|
676
694
|
);
|
|
677
695
|
const anchors = new AnchorSet();
|
|
678
|
-
const branch = this.
|
|
696
|
+
const branch = this.#transaction.activeBranch.fork();
|
|
679
697
|
const storedSchema = this.storedSchema.clone();
|
|
680
698
|
const forest = this.forest.clone(storedSchema, anchors);
|
|
681
|
-
const
|
|
682
|
-
return new TreeCheckout(
|
|
683
|
-
transaction,
|
|
699
|
+
const checkout = new TreeCheckout(
|
|
684
700
|
branch,
|
|
685
701
|
true,
|
|
686
702
|
this.changeFamily,
|
|
687
703
|
storedSchema,
|
|
688
704
|
forest,
|
|
689
|
-
createEmitter(),
|
|
690
705
|
this.mintRevisionTag,
|
|
691
706
|
this.revisionTagCodec,
|
|
692
707
|
this.idCompressor,
|
|
@@ -694,6 +709,8 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
694
709
|
this.logger,
|
|
695
710
|
this.breaker,
|
|
696
711
|
);
|
|
712
|
+
this.#events.emit("fork", checkout);
|
|
713
|
+
return checkout;
|
|
697
714
|
}
|
|
698
715
|
|
|
699
716
|
public rebase(checkout: TreeCheckout): void {
|
|
@@ -704,14 +721,15 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
704
721
|
"The source of the branch rebase has been disposed and cannot be rebased.",
|
|
705
722
|
);
|
|
706
723
|
assert(
|
|
707
|
-
!checkout.transaction.
|
|
724
|
+
!checkout.transaction.isInProgress(),
|
|
708
725
|
0x9af /* A view cannot be rebased while it has a pending transaction */,
|
|
709
726
|
);
|
|
710
727
|
assert(
|
|
711
728
|
checkout.isBranch,
|
|
712
729
|
0xa5d /* The main branch cannot be rebased onto another branch. */,
|
|
713
730
|
);
|
|
714
|
-
|
|
731
|
+
|
|
732
|
+
checkout.#transaction.activeBranch.rebaseOnto(this.#transaction.activeBranch);
|
|
715
733
|
}
|
|
716
734
|
|
|
717
735
|
public rebaseOnto(checkout: ITreeCheckout): void {
|
|
@@ -731,13 +749,13 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
731
749
|
"The source of the branch merge has been disposed and cannot be merged.",
|
|
732
750
|
);
|
|
733
751
|
assert(
|
|
734
|
-
!this.transaction.
|
|
752
|
+
!this.transaction.isInProgress(),
|
|
735
753
|
0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,
|
|
736
754
|
);
|
|
737
|
-
while (checkout.transaction.
|
|
755
|
+
while (checkout.transaction.isInProgress()) {
|
|
738
756
|
checkout.transaction.commit();
|
|
739
757
|
}
|
|
740
|
-
this.
|
|
758
|
+
this.#transaction.activeBranch.merge(checkout.#transaction.activeBranch);
|
|
741
759
|
if (disposeMerged && checkout.isBranch) {
|
|
742
760
|
// Dispose the merged checkout unless it is the main branch.
|
|
743
761
|
checkout[disposeSymbol]();
|
|
@@ -758,11 +776,13 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
758
776
|
"The branch has already been disposed and cannot be disposed again.",
|
|
759
777
|
);
|
|
760
778
|
this.disposed = true;
|
|
779
|
+
this.#transaction.branch.dispose();
|
|
780
|
+
this.#transaction.dispose();
|
|
761
781
|
this.purgeRevertibles();
|
|
762
|
-
this._branch.dispose();
|
|
763
782
|
for (const view of this.views) {
|
|
764
783
|
view.dispose();
|
|
765
784
|
}
|
|
785
|
+
this.#events.emit("dispose");
|
|
766
786
|
}
|
|
767
787
|
|
|
768
788
|
public getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {
|
|
@@ -783,11 +803,16 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
783
803
|
}
|
|
784
804
|
|
|
785
805
|
/**
|
|
786
|
-
* This
|
|
787
|
-
* 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.
|
|
788
809
|
*/
|
|
789
|
-
public
|
|
790
|
-
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");
|
|
791
816
|
}
|
|
792
817
|
|
|
793
818
|
private purgeRevertibles(): void {
|
|
@@ -796,14 +821,14 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
796
821
|
}
|
|
797
822
|
}
|
|
798
823
|
|
|
799
|
-
private disposeRevertible(revertible:
|
|
824
|
+
private disposeRevertible(revertible: RevertibleAlpha, revision: RevisionTag): void {
|
|
800
825
|
this.revertibleCommitBranches.get(revision)?.dispose();
|
|
801
826
|
this.revertibleCommitBranches.delete(revision);
|
|
802
827
|
this.revertibles.delete(revertible);
|
|
803
828
|
}
|
|
804
829
|
|
|
805
830
|
private revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {
|
|
806
|
-
if (this.
|
|
831
|
+
if (this.transaction.isInProgress()) {
|
|
807
832
|
throw new UsageError("Undo is not yet supported during transactions.");
|
|
808
833
|
}
|
|
809
834
|
|
|
@@ -817,7 +842,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
817
842
|
revisionForInvert,
|
|
818
843
|
);
|
|
819
844
|
|
|
820
|
-
const headCommit = this.
|
|
845
|
+
const headCommit = this.#transaction.activeBranch.getHead();
|
|
821
846
|
// Rebase the inverted change onto any commits that occurred after the undoable commits.
|
|
822
847
|
if (commitToRevert !== headCommit) {
|
|
823
848
|
change = tagChange(
|
|
@@ -832,7 +857,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
832
857
|
);
|
|
833
858
|
}
|
|
834
859
|
|
|
835
|
-
this.
|
|
860
|
+
this.#transaction.activeBranch.apply(
|
|
836
861
|
change,
|
|
837
862
|
kind === CommitKind.Default || kind === CommitKind.Redo
|
|
838
863
|
? CommitKind.Undo
|
|
@@ -880,36 +905,53 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
880
905
|
*/
|
|
881
906
|
private isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {
|
|
882
907
|
return (
|
|
883
|
-
//
|
|
908
|
+
// Remote changes are only ever applied to the main branch
|
|
884
909
|
!this.isBranch &&
|
|
885
|
-
//
|
|
886
|
-
//
|
|
887
|
-
|
|
888
|
-
event.type === "replace" &&
|
|
889
|
-
getChangeReplaceType(event) !== "transactionCommit"
|
|
910
|
+
// Remote changes are applied to the main branch by rebasing it onto the trunk.
|
|
911
|
+
// No other rebases are allowed on the main branch, so we can use this to detect remote changes.
|
|
912
|
+
event.type === "rebase"
|
|
890
913
|
);
|
|
891
914
|
}
|
|
892
|
-
}
|
|
893
915
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
)
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
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
|
+
}
|
|
912
955
|
|
|
913
|
-
|
|
914
|
-
dispose: () => void;
|
|
956
|
+
// #endregion Commit Validation
|
|
915
957
|
}
|