@fluidframework/tree 2.10.0 → 2.11.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 +25 -0
- package/api-report/tree.alpha.api.md +47 -16
- package/api-report/tree.beta.api.md +5 -14
- package/api-report/tree.legacy.alpha.api.md +5 -14
- package/api-report/tree.legacy.public.api.md +5 -14
- package/api-report/tree.public.api.md +5 -14
- 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 +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- 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 +11 -8
- 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/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/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/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 +1 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +2 -1
- package/dist/core/tree/index.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/chunkedForest.d.ts +5 -2
- 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/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +2 -2
- package/dist/feature-libraries/chunked-forest/uniformChunk.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 +1 -0
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -1
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +361 -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/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/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/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- 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 +1 -2
- package/dist/shared-tree/index.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 +31 -30
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +3 -0
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +56 -20
- 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 +28 -64
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +152 -129
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +25 -81
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +72 -151
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts +19 -33
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +73 -54
- 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 +2 -2
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +1 -1
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +4 -3
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -2
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +11 -52
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +108 -0
- package/dist/shared-tree-core/transaction.d.ts.map +1 -0
- package/dist/shared-tree-core/transaction.js +99 -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/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 +2 -0
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +5 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/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 +91 -0
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
- package/dist/simple-tree/api/tree.d.ts +4 -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/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 +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +7 -2
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/toMapTree.js +3 -3
- package/dist/simple-tree/toMapTree.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 +5 -4
- package/dist/util/index.js.map +1 -1
- package/dist/util/typeCheck.d.ts +6 -1
- 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 +29 -0
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +13 -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 +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 +1 -1
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +11 -8
- 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/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/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/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 +1 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/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/chunkedForest.d.ts +5 -2
- 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/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -3
- package/lib/feature-libraries/chunked-forest/uniformChunk.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 +1 -0
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -0
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +356 -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/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/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/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.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 +1 -1
- package/lib/shared-tree/index.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 +2 -2
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +3 -0
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +37 -1
- 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 +28 -64
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +140 -116
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +25 -81
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +72 -151
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts +19 -33
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +74 -55
- 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 +1 -1
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +1 -1
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +1 -1
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -2
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +12 -53
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +108 -0
- package/lib/shared-tree-core/transaction.d.ts.map +1 -0
- package/lib/shared-tree-core/transaction.js +95 -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/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 +2 -0
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -0
- package/lib/simple-tree/api/index.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 +87 -0
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
- package/lib/simple-tree/api/tree.d.ts +4 -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/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 +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +7 -2
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/toMapTree.js +5 -5
- package/lib/simple-tree/toMapTree.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 -1
- 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 +29 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +9 -0
- package/lib/util/utils.js.map +1 -1
- package/package.json +22 -22
- package/src/core/forest/forest.ts +12 -1
- package/src/core/index.ts +8 -1
- package/src/core/rebase/utils.ts +12 -10
- package/src/core/revertible.ts +35 -1
- package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
- package/src/core/tree/anchorSet.ts +2 -1
- package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
- package/src/core/tree/index.ts +1 -0
- package/src/core/tree/visitorUtils.ts +56 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +33 -7
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -3
- package/src/feature-libraries/flex-tree/context.ts +1 -1
- package/src/feature-libraries/index.ts +9 -0
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +453 -0
- package/src/feature-libraries/indexing/index.ts +11 -0
- package/src/feature-libraries/indexing/types.ts +37 -0
- 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/index.ts +16 -6
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +0 -2
- package/src/shared-tree/schematizingTreeView.ts +7 -7
- package/src/shared-tree/sharedTree.ts +60 -6
- package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
- package/src/shared-tree/treeCheckout.ts +186 -193
- package/src/shared-tree-core/branch.ts +93 -220
- package/src/shared-tree-core/branchCommitEnricher.ts +69 -64
- package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
- package/src/shared-tree-core/editManager.ts +1 -1
- package/src/shared-tree-core/index.ts +9 -2
- package/src/shared-tree-core/sharedTreeCore.ts +17 -62
- package/src/shared-tree-core/transaction.ts +165 -0
- package/src/shared-tree-core/transactionEnricher.ts +30 -24
- package/src/simple-tree/api/identifierIndex.ts +64 -0
- package/src/simple-tree/api/index.ts +5 -0
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
- package/src/simple-tree/api/simpleTreeIndex.ts +231 -0
- package/src/simple-tree/api/tree.ts +8 -5
- package/src/simple-tree/api/treeNodeApi.ts +1 -1
- 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 +4 -0
- package/src/simple-tree/objectNode.ts +19 -12
- package/src/simple-tree/toMapTree.ts +5 -5
- package/src/util/index.ts +3 -1
- package/src/util/typeCheck.ts +6 -1
- package/src/util/typeCheckTests.ts +11 -1
- package/src/util/utils.ts +38 -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/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/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
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.minimumPossibleSequenceNumber = exports.EditManager = exports.EditManagerSummarizer = exports.makeEditManagerCodec = exports.
|
|
7
|
+
exports.minimumPossibleSequenceNumber = exports.EditManager = exports.EditManagerSummarizer = exports.makeEditManagerCodec = exports.NoOpChangeEnricher = exports.DefaultResubmitMachine = exports.SharedTreeCore = exports.TransactionStack = exports.TransactionResult = exports.getChangeReplaceType = exports.SharedTreeBranch = exports.onForkTransitive = void 0;
|
|
8
8
|
var branch_js_1 = require("./branch.js");
|
|
9
9
|
Object.defineProperty(exports, "onForkTransitive", { enumerable: true, get: function () { return branch_js_1.onForkTransitive; } });
|
|
10
10
|
Object.defineProperty(exports, "SharedTreeBranch", { enumerable: true, get: function () { return branch_js_1.SharedTreeBranch; } });
|
|
11
11
|
Object.defineProperty(exports, "getChangeReplaceType", { enumerable: true, get: function () { return branch_js_1.getChangeReplaceType; } });
|
|
12
|
+
var transaction_js_1 = require("./transaction.js");
|
|
13
|
+
Object.defineProperty(exports, "TransactionResult", { enumerable: true, get: function () { return transaction_js_1.TransactionResult; } });
|
|
14
|
+
Object.defineProperty(exports, "TransactionStack", { enumerable: true, get: function () { return transaction_js_1.TransactionStack; } });
|
|
12
15
|
var sharedTreeCore_js_1 = require("./sharedTreeCore.js");
|
|
13
16
|
Object.defineProperty(exports, "SharedTreeCore", { enumerable: true, get: function () { return sharedTreeCore_js_1.SharedTreeCore; } });
|
|
14
17
|
var defaultResubmitMachine_js_1 = require("./defaultResubmitMachine.js");
|
|
15
18
|
Object.defineProperty(exports, "DefaultResubmitMachine", { enumerable: true, get: function () { return defaultResubmitMachine_js_1.DefaultResubmitMachine; } });
|
|
16
19
|
var changeEnricher_js_1 = require("./changeEnricher.js");
|
|
17
20
|
Object.defineProperty(exports, "NoOpChangeEnricher", { enumerable: true, get: function () { return changeEnricher_js_1.NoOpChangeEnricher; } });
|
|
18
|
-
var transactionStack_js_1 = require("./transactionStack.js");
|
|
19
|
-
Object.defineProperty(exports, "TransactionStack", { enumerable: true, get: function () { return transactionStack_js_1.TransactionStack; } });
|
|
20
21
|
var editManagerCodecs_js_1 = require("./editManagerCodecs.js");
|
|
21
22
|
Object.defineProperty(exports, "makeEditManagerCodec", { enumerable: true, get: function () { return editManagerCodecs_js_1.makeEditManagerCodec; } });
|
|
22
23
|
var editManagerSummarizer_js_1 = require("./editManagerSummarizer.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAMqB;AALpB,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAGhB,iHAAA,oBAAoB,OAAA;AAGrB,yDAM6B;AAJ5B,mHAAA,cAAc,OAAA;AAOf,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAE/B,yDAI6B;AAD5B,uHAAA,kBAAkB,OAAA;AAGnB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-tree-core/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAMqB;AALpB,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAGhB,iHAAA,oBAAoB,OAAA;AAGrB,mDAO0B;AANzB,mHAAA,iBAAiB,OAAA;AAGjB,kHAAA,gBAAgB,OAAA;AAKjB,yDAM6B;AAJ5B,mHAAA,cAAc,OAAA;AAOf,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAE/B,yDAI6B;AAD5B,uHAAA,kBAAkB,OAAA;AAGnB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,mDAI0B;AAHzB,6GAAA,WAAW,OAAA;AACX,+HAAA,6BAA6B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tonForkTransitive,\n\tSharedTreeBranch,\n\ttype SharedTreeBranchChange,\n\ttype SharedTreeBranchEvents,\n\tgetChangeReplaceType,\n} from \"./branch.js\";\n\nexport {\n\tTransactionResult,\n\ttype Transactor,\n\ttype TransactionEvents,\n\tTransactionStack,\n\ttype OnPush,\n\ttype OnPop,\n} from \"./transaction.js\";\n\nexport {\n\ttype ExplicitCoreCodecVersions,\n\tSharedTreeCore,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"./sharedTreeCore.js\";\n\nexport type { ResubmitMachine } from \"./resubmitMachine.js\";\nexport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\n\nexport {\n\ttype ChangeEnricherReadonlyCheckout,\n\ttype ChangeEnricherMutableCheckout,\n\tNoOpChangeEnricher,\n} from \"./changeEnricher.js\";\n\nexport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nexport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nexport {\n\tEditManager,\n\tminimumPossibleSequenceNumber,\n\ttype SummaryData,\n} from \"./editManager.js\";\nexport type {\n\tCommit,\n\tSeqNumber,\n\tSequencedCommit,\n\tSummarySessionBranch,\n\tEncodedCommit,\n} from \"./editManagerFormat.js\";\n"]}
|
|
@@ -7,7 +7,7 @@ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitio
|
|
|
7
7
|
import type { IExperimentalIncrementalSummaryContext, IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
|
|
8
8
|
import { type IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base/internal";
|
|
9
9
|
import type { ICodecOptions } from "../codec/index.js";
|
|
10
|
-
import { type ChangeFamily, type ChangeFamilyEditor, type RevisionTag, type SchemaAndPolicy, type SchemaPolicy, type TreeStoredSchemaRepository } from "../core/index.js";
|
|
10
|
+
import { type ChangeFamily, type ChangeFamilyEditor, type GraphCommit, type RevisionTag, type SchemaAndPolicy, type SchemaPolicy, type TreeStoredSchemaRepository } from "../core/index.js";
|
|
11
11
|
import { type JsonCompatibleReadOnly, Breakable, type WithBreakable } from "../util/index.js";
|
|
12
12
|
import { type SharedTreeBranch } from "./branch.js";
|
|
13
13
|
import { type ChangeEnricherReadonlyCheckout } from "./changeEnricher.js";
|
|
@@ -76,7 +76,7 @@ export declare class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
76
76
|
* @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,
|
|
77
77
|
* and may differ from `commit` due to enrichments like detached tree refreshers.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
protected submitCommit(commit: GraphCommit<TChange>, schemaAndPolicy: ClonableSchemaAndPolicy, isResubmit?: boolean): void;
|
|
80
80
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
81
81
|
/**
|
|
82
82
|
* @returns the head commit of the root local branch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeCore.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,KAAK,EACX,sCAAsC,EACtC,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACN,KAAK,gBAAgB,EACrB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"sharedTreeCore.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,KAAK,EACX,sCAAsC,EACtC,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACN,KAAK,gBAAgB,EACrB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,eAAe,EACpB,KAAK,YAAY,EAEjB,KAAK,0BAA0B,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,EAAE,OAAO,GAAG,sBAAsB;CAiBnE;AASD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,gBAAgB,CACf,SAAS,EAAE,yBAAyB,EACpC,QAAQ,CAAC,EAAE,OAAO,EAClB,UAAU,CAAC,EAAE,OAAO,EACpB,gBAAgB,CAAC,EAAE,iBAAiB,EACpC,yBAAyB,CAAC,EAAE,sCAAsC,GAChE,qBAAqB,CAAC;IAEzB;;;OAGG;IACH,SAAS,CACR,SAAS,EAAE,yBAAyB,EACpC,QAAQ,CAAC,EAAE,OAAO,EAClB,UAAU,CAAC,EAAE,OAAO,EACpB,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAElC;;OAEG;IAGH,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAC;IAEpD;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC"}
|
|
@@ -122,57 +122,17 @@ let SharedTreeCore = (() => {
|
|
|
122
122
|
*/
|
|
123
123
|
const localSessionId = runtime.idCompressor.localSessionId;
|
|
124
124
|
this.editManager = new editManager_js_1.EditManager(changeFamily, localSessionId, this.mintRevisionTag, rebaseLogger);
|
|
125
|
-
this.editManager.localBranch.events.on("transactionStarted", () => {
|
|
126
|
-
this.commitEnricher.startNewTransaction();
|
|
127
|
-
});
|
|
128
|
-
this.editManager.localBranch.events.on("transactionAborted", () => {
|
|
129
|
-
this.commitEnricher.abortCurrentTransaction();
|
|
130
|
-
});
|
|
131
|
-
this.editManager.localBranch.events.on("transactionCommitted", () => {
|
|
132
|
-
this.commitEnricher.commitCurrentTransaction();
|
|
133
|
-
});
|
|
134
125
|
this.editManager.localBranch.events.on("beforeChange", (change) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// Edits submitted before the first attach do not need enrichment because they will not be applied by peers.
|
|
139
|
-
}
|
|
140
|
-
else if (change.type === "append") {
|
|
141
|
-
if (this.getLocalBranch().isTransacting()) {
|
|
142
|
-
for (const newCommit of change.newCommits) {
|
|
143
|
-
this.commitEnricher.ingestTransactionCommit(newCommit);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
for (const newCommit of change.newCommits) {
|
|
148
|
-
this.commitEnricher.prepareCommit(newCommit, false);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else if (change.type === "replace" &&
|
|
153
|
-
(0, branch_js_1.getChangeReplaceType)(change) === "transactionCommit" &&
|
|
154
|
-
!this.getLocalBranch().isTransacting()) {
|
|
155
|
-
(0, internal_1.assert)(change.newCommits.length === 1, 0x983 /* Unexpected number of commits when committing transaction */);
|
|
156
|
-
this.commitEnricher.prepareCommit(change.newCommits[0] ?? (0, internal_1.oob)(), true);
|
|
126
|
+
if (this.detachedRevision === undefined) {
|
|
127
|
+
// Commit enrichment is only necessary for changes that will be submitted as ops, and changes issued while detached are not submitted.
|
|
128
|
+
this.commitEnricher.processChange(change);
|
|
157
129
|
}
|
|
158
130
|
});
|
|
159
131
|
this.editManager.localBranch.events.on("afterChange", (change) => {
|
|
160
|
-
if (this.getLocalBranch().isTransacting()) {
|
|
161
|
-
// We do not submit ops for changes that are part of a transaction.
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
132
|
if (change.type === "append" ||
|
|
165
133
|
(change.type === "replace" && (0, branch_js_1.getChangeReplaceType)(change) === "transactionCommit")) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.submitCommit(newCommit, this.schemaAndPolicy);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
for (const newCommit of change.newCommits) {
|
|
173
|
-
const prepared = this.commitEnricher.getPreparedCommit(newCommit);
|
|
174
|
-
this.submitCommit(prepared, this.schemaAndPolicy);
|
|
175
|
-
}
|
|
134
|
+
for (const commit of change.newCommits) {
|
|
135
|
+
this.submitCommit(commit, this.schemaAndPolicy);
|
|
176
136
|
}
|
|
177
137
|
}
|
|
178
138
|
});
|
|
@@ -238,22 +198,22 @@ let SharedTreeCore = (() => {
|
|
|
238
198
|
* and may differ from `commit` due to enrichments like detached tree refreshers.
|
|
239
199
|
*/
|
|
240
200
|
submitCommit(commit, schemaAndPolicy, isResubmit = false) {
|
|
241
|
-
(0, internal_1.assert)(
|
|
242
|
-
// Edits should not be submitted until all transactions finish
|
|
243
|
-
!this.getLocalBranch().isTransacting() || isResubmit, 0x68b /* Unexpected edit submitted during transaction */);
|
|
244
201
|
(0, internal_1.assert)(this.isAttached() === (this.detachedRevision === undefined), 0x95a /* Detached revision should only be set when not attached */);
|
|
202
|
+
const enrichedCommit = this.detachedRevision === undefined && !isResubmit
|
|
203
|
+
? this.commitEnricher.enrich(commit)
|
|
204
|
+
: commit;
|
|
245
205
|
// Edits submitted before the first attach are treated as sequenced because they will be included
|
|
246
206
|
// in the attach summary that is uploaded to the service.
|
|
247
207
|
// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.
|
|
248
208
|
if (this.detachedRevision !== undefined) {
|
|
249
209
|
const newRevision = (0, index_js_2.brand)(this.detachedRevision + 1);
|
|
250
210
|
this.detachedRevision = newRevision;
|
|
251
|
-
this.editManager.addSequencedChange({ ...
|
|
211
|
+
this.editManager.addSequencedChange({ ...enrichedCommit, sessionId: this.editManager.localSessionId }, newRevision, this.detachedRevision);
|
|
252
212
|
this.editManager.advanceMinimumSequenceNumber(newRevision, false);
|
|
253
213
|
return undefined;
|
|
254
214
|
}
|
|
255
215
|
const message = this.messageCodec.encode({
|
|
256
|
-
commit,
|
|
216
|
+
commit: enrichedCommit,
|
|
257
217
|
sessionId: this.editManager.localSessionId,
|
|
258
218
|
}, {
|
|
259
219
|
idCompressor: this.idCompressor,
|
|
@@ -264,7 +224,7 @@ let SharedTreeCore = (() => {
|
|
|
264
224
|
schema: schemaAndPolicy.schema.clone(),
|
|
265
225
|
policy: schemaAndPolicy.policy,
|
|
266
226
|
});
|
|
267
|
-
this.resubmitMachine.onCommitSubmitted(
|
|
227
|
+
this.resubmitMachine.onCommitSubmitted(enrichedCommit);
|
|
268
228
|
}
|
|
269
229
|
processCore(message, local, localOpMetadata) {
|
|
270
230
|
// Empty context object is passed in, as our decode function is schema-agnostic.
|
|
@@ -305,7 +265,6 @@ let SharedTreeCore = (() => {
|
|
|
305
265
|
this.submitCommit(enrichedCommit, localOpMetadata, true);
|
|
306
266
|
}
|
|
307
267
|
applyStashedOp(content) {
|
|
308
|
-
(0, internal_1.assert)(!this.getLocalBranch().isTransacting(), 0x674 /* Unexpected transaction is open while applying stashed ops */);
|
|
309
268
|
// Empty context object is passed in, as our decode function is schema-agnostic.
|
|
310
269
|
const { commit: { revision, change }, } = this.messageCodec.decode(content, { idCompressor: this.idCompressor });
|
|
311
270
|
this.editManager.localBranch.apply({ change, revision });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeCore.js","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAkE;AAclE,qEAA4E;AAC5E,0EAGqD;AAGrD,+CAW0B;AAC1B,+CAO0B;AAE1B,2CAA0E;AAC1E,qDAA8E;AAC9E,iEAA8D;AAE9D,yEAAmE;AACnE,yDAAmF;AAEnF,2DAA8F;AAE9F,2EAAqE;AACrE,uEAAiE;AACjE,uEAA6E;AAE7E,y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AC,EAAE,CAAC;oBACxE,OAAO,CAAC,EAAE,MAAV,OAAO,CAAC,EAAE,IAAM,EAAE,EAAC;oBACnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;wBAC5B,6FAA6F;wBAC7F,oEAAoE;wBACpE,OAAO,CAAC,EAAE,CAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC1B,CAAC;gBACF,CAAC;YACF,CAAC;YAED,OAAO;gBACN,OAAO;aACP,CAAC;QACH,CAAC;;;;;qCAtNA,wBAAa;QACd,gMAAU,aAAa,6DAuBtB;QAxOF,6KAuaC;;;QAvaY,uDAAc;;;;AAAd,wCAAc;AAya3B,SAAS,sBAAsB,CAC9B,iBAA0B;IAE1B,MAAM,eAAe,GAAG,iBAA4C,CAAC;IACrE,OAAO,eAAe,CAAC,MAAM,KAAK,SAAS,IAAI,eAAe,CAAC,MAAM,KAAK,SAAS,CAAC;AACrF,CAAC;AA6DD;;GAEG;AACH,SAAS,mBAAmB,CAC3B,OAA+B,EAC/B,GAAG,YAAsB;IAEzB,MAAM,KAAK,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAE3C,OAAO;QACN,KAAK,CAAC,QAAQ,CAAC,IAAY;YAC1B,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI;YAClB,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI;YACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../codec/index.js\";\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tfindAncestor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype TaggedChange,\n\ttype TreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tbrand,\n\tBreakable,\n\ttype WithBreakable,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"../util/index.js\";\n\nimport { type SharedTreeBranch, getChangeReplaceType } from \"./branch.js\";\nimport { EditManager, minimumPossibleSequenceNumber } from \"./editManager.js\";\nimport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nimport type { SeqNumber } from \"./editManagerFormat.js\";\nimport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nimport { type MessageEncodingContext, makeMessageCodec } from \"./messageCodecs.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from \"./changeEnricher.js\";\nimport type { ResubmitMachine } from \"./resubmitMachine.js\";\nimport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\nimport { BranchCommitEnricher } from \"./branchCommitEnricher.js\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\n// TODO: Organize this to be adjacent to persisted types.\nconst summarizablesTreeKey = \"indexes\";\n\nexport interface ExplicitCoreCodecVersions {\n\teditManager: number;\n\tmessage: number;\n}\n\nexport interface ClonableSchemaAndPolicy extends SchemaAndPolicy {\n\tschema: TreeStoredSchemaRepository;\n}\n\n/**\n * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.\n */\n@breakingClass\nexport class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>\n\textends SharedObject\n\timplements WithBreakable\n{\n\tpublic readonly breaker: Breakable = new Breakable(\"Shared Tree\");\n\n\tprivate readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;\n\tprivate readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];\n\t/**\n\t * The sequence number that this instance is at.\n\t * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.\n\t * Is `undefined` after (and only after) this instance is attached.\n\t */\n\tprivate detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\tpublic get editor(): TEditor {\n\t\treturn this.getLocalBranch().editor;\n\t}\n\n\t/**\n\t * Gets the revision at the head of the trunk.\n\t */\n\tprotected get trunkHeadRevision(): RevisionTag {\n\t\treturn this.editManager.getTrunkHead().revision;\n\t}\n\n\t/**\n\t * Used to encode/decode messages sent to/received from the Fluid runtime.\n\t *\n\t * @remarks Since there is currently only one format, this can just be cached on the class.\n\t * With more write formats active, it may make sense to keep around the \"usual\" format codec\n\t * (the one for the current persisted configuration) and resolve codecs for different versions\n\t * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window\n\t * and an op needs to be interpreted which isn't written with the current configuration).\n\t */\n\tprivate readonly messageCodec: IJsonCodec<\n\t\tDecodedMessage<TChange>,\n\t\tunknown,\n\t\tunknown,\n\t\tMessageEncodingContext\n\t>;\n\n\tprivate readonly idCompressor: IIdCompressor;\n\n\tprivate readonly resubmitMachine: ResubmitMachine<TChange>;\n\tprotected readonly commitEnricher: BranchCommitEnricher<TChange>;\n\n\tprotected readonly mintRevisionTag: () => RevisionTag;\n\n\tprivate readonly schemaAndPolicy: ClonableSchemaAndPolicy;\n\n\t/**\n\t * @param summarizables - Summarizers for all indexes used by this tree\n\t * @param changeFamily - The change family\n\t * @param editManager - The edit manager\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t * @param telemetryContextPrefix - The property prefix for telemetry pertaining to this object. See {@link ITelemetryContext}\n\t */\n\tpublic constructor(\n\t\tsummarizables: readonly Summarizable[],\n\t\tchangeFamily: ChangeFamily<TEditor, TChange>,\n\t\toptions: ICodecOptions,\n\t\tformatOptions: ExplicitCoreCodecVersions,\n\t\t// Base class arguments\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\ttelemetryContextPrefix: string,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tschemaPolicy: SchemaPolicy,\n\t\tresubmitMachine?: ResubmitMachine<TChange>,\n\t\tenricher?: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.schemaAndPolicy = {\n\t\t\tschema,\n\t\t\tpolicy: schemaPolicy,\n\t\t};\n\n\t\tconst rebaseLogger = createChildLogger({\n\t\t\tlogger: this.logger,\n\t\t\tnamespace: \"Rebase\",\n\t\t});\n\n\t\tassert(\n\t\t\truntime.idCompressor !== undefined,\n\t\t\t0x886 /* IdCompressor must be enabled to use SharedTree */,\n\t\t);\n\t\tthis.idCompressor = runtime.idCompressor;\n\t\tthis.mintRevisionTag = () => this.idCompressor.generateCompressedId();\n\t\t/**\n\t\t * A random ID that uniquely identifies this client in the collab session.\n\t\t * This is sent alongside every op to identify which client the op originated from.\n\t\t * This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.\n\t\t */\n\t\tconst localSessionId = runtime.idCompressor.localSessionId;\n\t\tthis.editManager = new EditManager(\n\t\t\tchangeFamily,\n\t\t\tlocalSessionId,\n\t\t\tthis.mintRevisionTag,\n\t\t\trebaseLogger,\n\t\t);\n\t\tthis.editManager.localBranch.events.on(\"transactionStarted\", () => {\n\t\t\tthis.commitEnricher.startNewTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.events.on(\"transactionAborted\", () => {\n\t\t\tthis.commitEnricher.abortCurrentTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.events.on(\"transactionCommitted\", () => {\n\t\t\tthis.commitEnricher.commitCurrentTransaction();\n\t\t});\n\t\tthis.editManager.localBranch.events.on(\"beforeChange\", (change) => {\n\t\t\t// Ensure that any previously prepared commits that have not been sent are purged.\n\t\t\tthis.commitEnricher.purgePreparedCommits();\n\t\t\tif (this.detachedRevision !== undefined) {\n\t\t\t\t// Edits submitted before the first attach do not need enrichment because they will not be applied by peers.\n\t\t\t} else if (change.type === \"append\") {\n\t\t\t\tif (this.getLocalBranch().isTransacting()) {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.commitEnricher.ingestTransactionCommit(newCommit);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.commitEnricher.prepareCommit(newCommit, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tchange.type === \"replace\" &&\n\t\t\t\tgetChangeReplaceType(change) === \"transactionCommit\" &&\n\t\t\t\t!this.getLocalBranch().isTransacting()\n\t\t\t) {\n\t\t\t\tassert(\n\t\t\t\t\tchange.newCommits.length === 1,\n\t\t\t\t\t0x983 /* Unexpected number of commits when committing transaction */,\n\t\t\t\t);\n\t\t\t\tthis.commitEnricher.prepareCommit(change.newCommits[0] ?? oob(), true);\n\t\t\t}\n\t\t});\n\t\tthis.editManager.localBranch.events.on(\"afterChange\", (change) => {\n\t\t\tif (this.getLocalBranch().isTransacting()) {\n\t\t\t\t// We do not submit ops for changes that are part of a transaction.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tchange.type === \"append\" ||\n\t\t\t\t(change.type === \"replace\" && getChangeReplaceType(change) === \"transactionCommit\")\n\t\t\t) {\n\t\t\t\tif (this.detachedRevision !== undefined) {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tthis.submitCommit(newCommit, this.schemaAndPolicy);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\t\tconst prepared = this.commitEnricher.getPreparedCommit(newCommit);\n\t\t\t\t\t\tthis.submitCommit(prepared, this.schemaAndPolicy);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);\n\t\tconst editManagerCodec = makeEditManagerCodec(\n\t\t\tthis.editManager.changeFamily.codecs,\n\t\t\trevisionTagCodec,\n\t\t\toptions,\n\t\t\tformatOptions.editManager,\n\t\t);\n\t\tthis.summarizables = [\n\t\t\tnew EditManagerSummarizer(\n\t\t\t\tthis.editManager,\n\t\t\t\teditManagerCodec,\n\t\t\t\tthis.idCompressor,\n\t\t\t\tthis.schemaAndPolicy,\n\t\t\t),\n\t\t\t...summarizables,\n\t\t];\n\t\tassert(\n\t\t\tnew Set(this.summarizables.map((e) => e.key)).size === this.summarizables.length,\n\t\t\t0x350 /* Index summary element keys must be unique */,\n\t\t);\n\n\t\tthis.messageCodec = makeMessageCodec(\n\t\t\tchangeFamily.codecs,\n\t\t\tnew RevisionTagCodec(runtime.idCompressor),\n\t\t\toptions,\n\t\t\tformatOptions.message,\n\t\t);\n\n\t\tconst changeEnricher = enricher ?? new NoOpChangeEnricher();\n\t\tthis.resubmitMachine =\n\t\t\tresubmitMachine ??\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\t(change: TaggedChange<TChange>) =>\n\t\t\t\t\tchangeFamily.rebaser.invert(change, true, this.mintRevisionTag()),\n\t\t\t\tchangeEnricher,\n\t\t\t);\n\t\tthis.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);\n\t}\n\n\t// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:\n\t// We might want to not subclass it, or override/reimplement most of its functionality.\n\t@throwIfBroken\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst summarizableBuilder = new SummaryTreeBuilder();\n\t\t// Merge the summaries of all summarizables together under a single ISummaryTree\n\t\tfor (const s of this.summarizables) {\n\t\t\tsummarizableBuilder.addWithStats(\n\t\t\t\ts.key,\n\t\t\t\ts.getAttachSummary(\n\t\t\t\t\t(contents) => serializer.stringify(contents, this.handle),\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\ttelemetryContext,\n\t\t\t\t\tincrementalSummaryContext,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tbuilder.addWithStats(summarizablesTreeKey, summarizableBuilder.getSummaryTree());\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tconst [editManagerSummarizer, ...summarizables] = this.summarizables;\n\t\tconst loadEditManager = this.loadSummarizable(editManagerSummarizer, services);\n\t\tconst loadSummarizables = summarizables.map(async (s) =>\n\t\t\tthis.loadSummarizable(s, services),\n\t\t);\n\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\t// If we are detached but loading from a summary, then we need to update our detached revision to ensure that it is ahead of all detached revisions in the summary.\n\t\t\t// First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.\n\t\t\tawait loadEditManager;\n\t\t\t// Find the most recent detached revision in the summary trunk...\n\t\t\tlet latestDetachedSequenceNumber: SeqNumber | undefined;\n\t\t\tfindAncestor(this.editManager.getTrunkHead(), (c) => {\n\t\t\t\tconst sequenceNumber = this.editManager.getSequenceNumber(c);\n\t\t\t\tif (sequenceNumber !== undefined && sequenceNumber < 0) {\n\t\t\t\t\tlatestDetachedSequenceNumber = sequenceNumber;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\t// ...and set our detached revision to be as it would be if we had been already created that revision.\n\t\t\tthis.detachedRevision = latestDetachedSequenceNumber ?? this.detachedRevision;\n\t\t\tawait Promise.all(loadSummarizables);\n\t\t} else {\n\t\t\tawait Promise.all([loadEditManager, ...loadSummarizables]);\n\t\t}\n\t}\n\n\tprivate async loadSummarizable(\n\t\tsummarizable: Summarizable,\n\t\tservices: IChannelStorageService,\n\t): Promise<void> {\n\t\treturn summarizable.load(\n\t\t\tscopeStorageService(services, summarizablesTreeKey, summarizable.key),\n\t\t\t(contents) => this.serializer.parse(contents),\n\t\t);\n\t}\n\n\t/**\n\t * Submits an op to the Fluid runtime containing the given commit\n\t * @param commit - the commit to submit\n\t * @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,\n\t * and may differ from `commit` due to enrichments like detached tree refreshers.\n\t */\n\n\tprivate submitCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tschemaAndPolicy: ClonableSchemaAndPolicy,\n\t\tisResubmit = false,\n\t): void {\n\t\tassert(\n\t\t\t// Edits should not be submitted until all transactions finish\n\t\t\t!this.getLocalBranch().isTransacting() || isResubmit,\n\t\t\t0x68b /* Unexpected edit submitted during transaction */,\n\t\t);\n\t\tassert(\n\t\t\tthis.isAttached() === (this.detachedRevision === undefined),\n\t\t\t0x95a /* Detached revision should only be set when not attached */,\n\t\t);\n\n\t\t// Edits submitted before the first attach are treated as sequenced because they will be included\n\t\t// in the attach summary that is uploaded to the service.\n\t\t// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tconst newRevision: SeqNumber = brand((this.detachedRevision as number) + 1);\n\t\t\tthis.detachedRevision = newRevision;\n\t\t\tthis.editManager.addSequencedChange(\n\t\t\t\t{ ...commit, sessionId: this.editManager.localSessionId },\n\t\t\t\tnewRevision,\n\t\t\t\tthis.detachedRevision,\n\t\t\t);\n\t\t\tthis.editManager.advanceMinimumSequenceNumber(newRevision, false);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst message = this.messageCodec.encode(\n\t\t\t{\n\t\t\t\tcommit,\n\t\t\t\tsessionId: this.editManager.localSessionId,\n\t\t\t},\n\t\t\t{\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\tschema: schemaAndPolicy,\n\t\t\t},\n\t\t);\n\t\tthis.submitLocalMessage(message, {\n\t\t\t// Clone the schema to ensure that during resubmit the schema has not been mutated by later changes\n\t\t\tschema: schemaAndPolicy.schema.clone(),\n\t\t\tpolicy: schemaAndPolicy.policy,\n\t\t});\n\t\tthis.resubmitMachine.onCommitSubmitted(commit);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst { commit, sessionId } = this.messageCodec.decode(message.contents, {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\n\t\tthis.editManager.addSequencedChange(\n\t\t\t{ ...commit, sessionId },\n\t\t\tbrand(message.sequenceNumber),\n\t\t\tbrand(message.referenceSequenceNumber),\n\t\t);\n\t\tthis.resubmitMachine.onSequencedCommitApplied(local);\n\n\t\tthis.editManager.advanceMinimumSequenceNumber(brand(message.minimumSequenceNumber));\n\t}\n\n\t/**\n\t * @returns the head commit of the root local branch\n\t */\n\tprotected getLocalBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.editManager.localBranch;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override didAttach(): void {\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tthis.detachedRevision = undefined;\n\t\t}\n\t}\n\n\tprotected override reSubmitCore(\n\t\tcontent: JsonCompatibleReadOnly,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\tconst [commit] = this.editManager.findLocalCommit(revision);\n\t\t// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.\n\t\tif (this.resubmitMachine.isInResubmitPhase === false) {\n\t\t\tconst toResubmit = this.editManager.getLocalCommits();\n\t\t\tassert(\n\t\t\t\tcommit === toResubmit[0],\n\t\t\t\t0x95d /* Resubmit phase should start with the oldest local commit */,\n\t\t\t);\n\t\t\tthis.resubmitMachine.prepareForResubmit(toResubmit);\n\t\t}\n\t\tassert(\n\t\t\tisClonableSchemaPolicy(localOpMetadata),\n\t\t\t0x95e /* Local metadata must contain schema and policy. */,\n\t\t);\n\t\tassert(\n\t\t\tthis.resubmitMachine.isInResubmitPhase !== false,\n\t\t\t0x984 /* Invalid resubmit outside of resubmit phase */,\n\t\t);\n\t\tconst enrichedCommit = this.resubmitMachine.peekNextCommit();\n\t\tthis.submitCommit(enrichedCommit, localOpMetadata, true);\n\t}\n\n\tprotected applyStashedOp(content: JsonCompatibleReadOnly): void {\n\t\tassert(\n\t\t\t!this.getLocalBranch().isTransacting(),\n\t\t\t0x674 /* Unexpected transaction is open while applying stashed ops */,\n\t\t);\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision, change },\n\t\t} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });\n\t\tthis.editManager.localBranch.apply({ change, revision });\n\t}\n\n\tpublic override getGCData(fullGC?: boolean): IGarbageCollectionData {\n\t\tconst gcNodes: IGarbageCollectionData[\"gcNodes\"] = super.getGCData(fullGC).gcNodes;\n\t\tfor (const s of this.summarizables) {\n\t\t\tfor (const [id, routes] of Object.entries(s.getGCData(fullGC).gcNodes)) {\n\t\t\t\tgcNodes[id] ??= [];\n\t\t\t\tfor (const route of routes) {\n\t\t\t\t\t// Non null asserting here because we are creating an array at gcNodes[id] if it is undefined\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tgcNodes[id]!.push(route);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n}\n\nfunction isClonableSchemaPolicy(\n\tmaybeSchemaPolicy: unknown,\n): maybeSchemaPolicy is ClonableSchemaAndPolicy {\n\tconst schemaAndPolicy = maybeSchemaPolicy as ClonableSchemaAndPolicy;\n\treturn schemaAndPolicy.schema !== undefined && schemaAndPolicy.policy !== undefined;\n}\n\n/**\n * Specifies the behavior of a component that puts data in a summary.\n */\nexport interface Summarizable {\n\t/**\n\t * Field name in summary json under which this element stores its data.\n\t */\n\treadonly key: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tgetAttachSummary(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tsummarize(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\t// TODO: Change this interface (and the one in ISharedObject, if necessary) to support \"handles within handles\".\n\t// Consider the case of a document with history; the return value here currently grows unboundedly.\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the component to perform custom loading. The storage service is scoped to this component and therefore\n\t * paths in this component will not collide with those in other components, even if they are the same string.\n\t * @param service - Storage used by the component\n\t * @param parse - Parses serialized data from storage into runtime objects for the component\n\t */\n\tload(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;\n}\n\n/**\n * Serializes the given contents into a string acceptable for storing in summaries, i.e. all\n * Fluid handles have been replaced appropriately by an IFluidSerializer\n */\nexport type SummaryElementStringifier = (contents: unknown) => string;\n\n/**\n * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary\n */\nexport type SummaryElementParser = (contents: string) => unknown;\n\n/**\n * Compose an {@link IChannelStorageService} which prefixes all paths before forwarding them to the original service\n */\nfunction scopeStorageService(\n\tservice: IChannelStorageService,\n\t...pathElements: string[]\n): IChannelStorageService {\n\tconst scope = `${pathElements.join(\"/\")}/`;\n\n\treturn {\n\t\tasync readBlob(path: string): Promise<ArrayBufferLike> {\n\t\t\treturn service.readBlob(`${scope}${path}`);\n\t\t},\n\t\tasync contains(path) {\n\t\t\treturn service.contains(`${scope}${path}`);\n\t\t},\n\t\tasync list(path) {\n\t\t\treturn service.list(`${scope}${path}`);\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedTreeCore.js","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA6D;AAc7D,qEAA4E;AAC5E,0EAGqD;AAGrD,+CAW0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,CAAC;IACrE,OAAO,eAAe,CAAC,MAAM,KAAK,SAAS,IAAI,eAAe,CAAC,MAAM,KAAK,SAAS,CAAC;AACrF,CAAC;AA6DD;;GAEG;AACH,SAAS,mBAAmB,CAC3B,OAA+B,EAC/B,GAAG,YAAsB;IAEzB,MAAM,KAAK,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAE3C,OAAO;QACN,KAAK,CAAC,QAAQ,CAAC,IAAY;YAC1B,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI;YAClB,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI;YACd,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../codec/index.js\";\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\tfindAncestor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype TaggedChange,\n\ttype TreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tbrand,\n\tBreakable,\n\ttype WithBreakable,\n\tthrowIfBroken,\n\tbreakingClass,\n} from \"../util/index.js\";\n\nimport { getChangeReplaceType, type SharedTreeBranch } from \"./branch.js\";\nimport { EditManager, minimumPossibleSequenceNumber } from \"./editManager.js\";\nimport { makeEditManagerCodec } from \"./editManagerCodecs.js\";\nimport type { SeqNumber } from \"./editManagerFormat.js\";\nimport { EditManagerSummarizer } from \"./editManagerSummarizer.js\";\nimport { type MessageEncodingContext, makeMessageCodec } from \"./messageCodecs.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\nimport { type ChangeEnricherReadonlyCheckout, NoOpChangeEnricher } from \"./changeEnricher.js\";\nimport type { ResubmitMachine } from \"./resubmitMachine.js\";\nimport { DefaultResubmitMachine } from \"./defaultResubmitMachine.js\";\nimport { BranchCommitEnricher } from \"./branchCommitEnricher.js\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\n// TODO: Organize this to be adjacent to persisted types.\nconst summarizablesTreeKey = \"indexes\";\n\nexport interface ExplicitCoreCodecVersions {\n\teditManager: number;\n\tmessage: number;\n}\n\nexport interface ClonableSchemaAndPolicy extends SchemaAndPolicy {\n\tschema: TreeStoredSchemaRepository;\n}\n\n/**\n * Generic shared tree, which needs to be configured with indexes, field kinds and other configuration.\n */\n@breakingClass\nexport class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>\n\textends SharedObject\n\timplements WithBreakable\n{\n\tpublic readonly breaker: Breakable = new Breakable(\"Shared Tree\");\n\n\tprivate readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;\n\tprivate readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];\n\t/**\n\t * The sequence number that this instance is at.\n\t * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.\n\t * Is `undefined` after (and only after) this instance is attached.\n\t */\n\tprivate detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\tpublic get editor(): TEditor {\n\t\treturn this.getLocalBranch().editor;\n\t}\n\n\t/**\n\t * Gets the revision at the head of the trunk.\n\t */\n\tprotected get trunkHeadRevision(): RevisionTag {\n\t\treturn this.editManager.getTrunkHead().revision;\n\t}\n\n\t/**\n\t * Used to encode/decode messages sent to/received from the Fluid runtime.\n\t *\n\t * @remarks Since there is currently only one format, this can just be cached on the class.\n\t * With more write formats active, it may make sense to keep around the \"usual\" format codec\n\t * (the one for the current persisted configuration) and resolve codecs for different versions\n\t * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window\n\t * and an op needs to be interpreted which isn't written with the current configuration).\n\t */\n\tprivate readonly messageCodec: IJsonCodec<\n\t\tDecodedMessage<TChange>,\n\t\tunknown,\n\t\tunknown,\n\t\tMessageEncodingContext\n\t>;\n\n\tprivate readonly idCompressor: IIdCompressor;\n\n\tprivate readonly resubmitMachine: ResubmitMachine<TChange>;\n\tprotected readonly commitEnricher: BranchCommitEnricher<TChange>;\n\n\tprotected readonly mintRevisionTag: () => RevisionTag;\n\n\tprivate readonly schemaAndPolicy: ClonableSchemaAndPolicy;\n\n\t/**\n\t * @param summarizables - Summarizers for all indexes used by this tree\n\t * @param changeFamily - The change family\n\t * @param editManager - The edit manager\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t * @param telemetryContextPrefix - The property prefix for telemetry pertaining to this object. See {@link ITelemetryContext}\n\t */\n\tpublic constructor(\n\t\tsummarizables: readonly Summarizable[],\n\t\tchangeFamily: ChangeFamily<TEditor, TChange>,\n\t\toptions: ICodecOptions,\n\t\tformatOptions: ExplicitCoreCodecVersions,\n\t\t// Base class arguments\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\ttelemetryContextPrefix: string,\n\t\tschema: TreeStoredSchemaRepository,\n\t\tschemaPolicy: SchemaPolicy,\n\t\tresubmitMachine?: ResubmitMachine<TChange>,\n\t\tenricher?: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.schemaAndPolicy = {\n\t\t\tschema,\n\t\t\tpolicy: schemaPolicy,\n\t\t};\n\n\t\tconst rebaseLogger = createChildLogger({\n\t\t\tlogger: this.logger,\n\t\t\tnamespace: \"Rebase\",\n\t\t});\n\n\t\tassert(\n\t\t\truntime.idCompressor !== undefined,\n\t\t\t0x886 /* IdCompressor must be enabled to use SharedTree */,\n\t\t);\n\t\tthis.idCompressor = runtime.idCompressor;\n\t\tthis.mintRevisionTag = () => this.idCompressor.generateCompressedId();\n\t\t/**\n\t\t * A random ID that uniquely identifies this client in the collab session.\n\t\t * This is sent alongside every op to identify which client the op originated from.\n\t\t * This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.\n\t\t */\n\t\tconst localSessionId = runtime.idCompressor.localSessionId;\n\t\tthis.editManager = new EditManager(\n\t\t\tchangeFamily,\n\t\t\tlocalSessionId,\n\t\t\tthis.mintRevisionTag,\n\t\t\trebaseLogger,\n\t\t);\n\n\t\tthis.editManager.localBranch.events.on(\"beforeChange\", (change) => {\n\t\t\tif (this.detachedRevision === undefined) {\n\t\t\t\t// Commit enrichment is only necessary for changes that will be submitted as ops, and changes issued while detached are not submitted.\n\t\t\t\tthis.commitEnricher.processChange(change);\n\t\t\t}\n\t\t});\n\t\tthis.editManager.localBranch.events.on(\"afterChange\", (change) => {\n\t\t\tif (\n\t\t\t\tchange.type === \"append\" ||\n\t\t\t\t(change.type === \"replace\" && getChangeReplaceType(change) === \"transactionCommit\")\n\t\t\t) {\n\t\t\t\tfor (const commit of change.newCommits) {\n\t\t\t\t\tthis.submitCommit(commit, this.schemaAndPolicy);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);\n\t\tconst editManagerCodec = makeEditManagerCodec(\n\t\t\tthis.editManager.changeFamily.codecs,\n\t\t\trevisionTagCodec,\n\t\t\toptions,\n\t\t\tformatOptions.editManager,\n\t\t);\n\t\tthis.summarizables = [\n\t\t\tnew EditManagerSummarizer(\n\t\t\t\tthis.editManager,\n\t\t\t\teditManagerCodec,\n\t\t\t\tthis.idCompressor,\n\t\t\t\tthis.schemaAndPolicy,\n\t\t\t),\n\t\t\t...summarizables,\n\t\t];\n\t\tassert(\n\t\t\tnew Set(this.summarizables.map((e) => e.key)).size === this.summarizables.length,\n\t\t\t0x350 /* Index summary element keys must be unique */,\n\t\t);\n\n\t\tthis.messageCodec = makeMessageCodec(\n\t\t\tchangeFamily.codecs,\n\t\t\tnew RevisionTagCodec(runtime.idCompressor),\n\t\t\toptions,\n\t\t\tformatOptions.message,\n\t\t);\n\n\t\tconst changeEnricher = enricher ?? new NoOpChangeEnricher();\n\t\tthis.resubmitMachine =\n\t\t\tresubmitMachine ??\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\t(change: TaggedChange<TChange>) =>\n\t\t\t\t\tchangeFamily.rebaser.invert(change, true, this.mintRevisionTag()),\n\t\t\t\tchangeEnricher,\n\t\t\t);\n\t\tthis.commitEnricher = new BranchCommitEnricher(changeFamily.rebaser, changeEnricher);\n\t}\n\n\t// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:\n\t// We might want to not subclass it, or override/reimplement most of its functionality.\n\t@throwIfBroken\n\tprotected summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst summarizableBuilder = new SummaryTreeBuilder();\n\t\t// Merge the summaries of all summarizables together under a single ISummaryTree\n\t\tfor (const s of this.summarizables) {\n\t\t\tsummarizableBuilder.addWithStats(\n\t\t\t\ts.key,\n\t\t\t\ts.getAttachSummary(\n\t\t\t\t\t(contents) => serializer.stringify(contents, this.handle),\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\ttelemetryContext,\n\t\t\t\t\tincrementalSummaryContext,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tbuilder.addWithStats(summarizablesTreeKey, summarizableBuilder.getSummaryTree());\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tconst [editManagerSummarizer, ...summarizables] = this.summarizables;\n\t\tconst loadEditManager = this.loadSummarizable(editManagerSummarizer, services);\n\t\tconst loadSummarizables = summarizables.map(async (s) =>\n\t\t\tthis.loadSummarizable(s, services),\n\t\t);\n\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\t// If we are detached but loading from a summary, then we need to update our detached revision to ensure that it is ahead of all detached revisions in the summary.\n\t\t\t// First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.\n\t\t\tawait loadEditManager;\n\t\t\t// Find the most recent detached revision in the summary trunk...\n\t\t\tlet latestDetachedSequenceNumber: SeqNumber | undefined;\n\t\t\tfindAncestor(this.editManager.getTrunkHead(), (c) => {\n\t\t\t\tconst sequenceNumber = this.editManager.getSequenceNumber(c);\n\t\t\t\tif (sequenceNumber !== undefined && sequenceNumber < 0) {\n\t\t\t\t\tlatestDetachedSequenceNumber = sequenceNumber;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\t// ...and set our detached revision to be as it would be if we had been already created that revision.\n\t\t\tthis.detachedRevision = latestDetachedSequenceNumber ?? this.detachedRevision;\n\t\t\tawait Promise.all(loadSummarizables);\n\t\t} else {\n\t\t\tawait Promise.all([loadEditManager, ...loadSummarizables]);\n\t\t}\n\t}\n\n\tprivate async loadSummarizable(\n\t\tsummarizable: Summarizable,\n\t\tservices: IChannelStorageService,\n\t): Promise<void> {\n\t\treturn summarizable.load(\n\t\t\tscopeStorageService(services, summarizablesTreeKey, summarizable.key),\n\t\t\t(contents) => this.serializer.parse(contents),\n\t\t);\n\t}\n\n\t/**\n\t * Submits an op to the Fluid runtime containing the given commit\n\t * @param commit - the commit to submit\n\t * @returns the submitted commit. This is undefined if the underlying `SharedObject` is not attached,\n\t * and may differ from `commit` due to enrichments like detached tree refreshers.\n\t */\n\tprotected submitCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tschemaAndPolicy: ClonableSchemaAndPolicy,\n\t\tisResubmit = false,\n\t): void {\n\t\tassert(\n\t\t\tthis.isAttached() === (this.detachedRevision === undefined),\n\t\t\t0x95a /* Detached revision should only be set when not attached */,\n\t\t);\n\n\t\tconst enrichedCommit =\n\t\t\tthis.detachedRevision === undefined && !isResubmit\n\t\t\t\t? this.commitEnricher.enrich(commit)\n\t\t\t\t: commit;\n\n\t\t// Edits submitted before the first attach are treated as sequenced because they will be included\n\t\t// in the attach summary that is uploaded to the service.\n\t\t// Until this attach workflow happens, this instance essentially behaves as a centralized data structure.\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tconst newRevision: SeqNumber = brand((this.detachedRevision as number) + 1);\n\t\t\tthis.detachedRevision = newRevision;\n\t\t\tthis.editManager.addSequencedChange(\n\t\t\t\t{ ...enrichedCommit, sessionId: this.editManager.localSessionId },\n\t\t\t\tnewRevision,\n\t\t\t\tthis.detachedRevision,\n\t\t\t);\n\t\t\tthis.editManager.advanceMinimumSequenceNumber(newRevision, false);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst message = this.messageCodec.encode(\n\t\t\t{\n\t\t\t\tcommit: enrichedCommit,\n\t\t\t\tsessionId: this.editManager.localSessionId,\n\t\t\t},\n\t\t\t{\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\tschema: schemaAndPolicy,\n\t\t\t},\n\t\t);\n\t\tthis.submitLocalMessage(message, {\n\t\t\t// Clone the schema to ensure that during resubmit the schema has not been mutated by later changes\n\t\t\tschema: schemaAndPolicy.schema.clone(),\n\t\t\tpolicy: schemaAndPolicy.policy,\n\t\t});\n\t\tthis.resubmitMachine.onCommitSubmitted(enrichedCommit);\n\t}\n\n\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst { commit, sessionId } = this.messageCodec.decode(message.contents, {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\n\t\tthis.editManager.addSequencedChange(\n\t\t\t{ ...commit, sessionId },\n\t\t\tbrand(message.sequenceNumber),\n\t\t\tbrand(message.referenceSequenceNumber),\n\t\t);\n\t\tthis.resubmitMachine.onSequencedCommitApplied(local);\n\n\t\tthis.editManager.advanceMinimumSequenceNumber(brand(message.minimumSequenceNumber));\n\t}\n\n\t/**\n\t * @returns the head commit of the root local branch\n\t */\n\tprotected getLocalBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.editManager.localBranch;\n\t}\n\n\tprotected onDisconnect(): void {}\n\n\tprotected override didAttach(): void {\n\t\tif (this.detachedRevision !== undefined) {\n\t\t\tthis.detachedRevision = undefined;\n\t\t}\n\t}\n\n\tprotected override reSubmitCore(\n\t\tcontent: JsonCompatibleReadOnly,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision },\n\t\t} = this.messageCodec.decode(this.serializer.decode(content), {\n\t\t\tidCompressor: this.idCompressor,\n\t\t});\n\t\tconst [commit] = this.editManager.findLocalCommit(revision);\n\t\t// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.\n\t\tif (this.resubmitMachine.isInResubmitPhase === false) {\n\t\t\tconst toResubmit = this.editManager.getLocalCommits();\n\t\t\tassert(\n\t\t\t\tcommit === toResubmit[0],\n\t\t\t\t0x95d /* Resubmit phase should start with the oldest local commit */,\n\t\t\t);\n\t\t\tthis.resubmitMachine.prepareForResubmit(toResubmit);\n\t\t}\n\t\tassert(\n\t\t\tisClonableSchemaPolicy(localOpMetadata),\n\t\t\t0x95e /* Local metadata must contain schema and policy. */,\n\t\t);\n\t\tassert(\n\t\t\tthis.resubmitMachine.isInResubmitPhase !== false,\n\t\t\t0x984 /* Invalid resubmit outside of resubmit phase */,\n\t\t);\n\t\tconst enrichedCommit = this.resubmitMachine.peekNextCommit();\n\t\tthis.submitCommit(enrichedCommit, localOpMetadata, true);\n\t}\n\n\tprotected applyStashedOp(content: JsonCompatibleReadOnly): void {\n\t\t// Empty context object is passed in, as our decode function is schema-agnostic.\n\t\tconst {\n\t\t\tcommit: { revision, change },\n\t\t} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });\n\t\tthis.editManager.localBranch.apply({ change, revision });\n\t}\n\n\tpublic override getGCData(fullGC?: boolean): IGarbageCollectionData {\n\t\tconst gcNodes: IGarbageCollectionData[\"gcNodes\"] = super.getGCData(fullGC).gcNodes;\n\t\tfor (const s of this.summarizables) {\n\t\t\tfor (const [id, routes] of Object.entries(s.getGCData(fullGC).gcNodes)) {\n\t\t\t\tgcNodes[id] ??= [];\n\t\t\t\tfor (const route of routes) {\n\t\t\t\t\t// Non null asserting here because we are creating an array at gcNodes[id] if it is undefined\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tgcNodes[id]!.push(route);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n}\n\nfunction isClonableSchemaPolicy(\n\tmaybeSchemaPolicy: unknown,\n): maybeSchemaPolicy is ClonableSchemaAndPolicy {\n\tconst schemaAndPolicy = maybeSchemaPolicy as ClonableSchemaAndPolicy;\n\treturn schemaAndPolicy.schema !== undefined && schemaAndPolicy.policy !== undefined;\n}\n\n/**\n * Specifies the behavior of a component that puts data in a summary.\n */\nexport interface Summarizable {\n\t/**\n\t * Field name in summary json under which this element stores its data.\n\t */\n\treadonly key: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tgetAttachSummary(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.\n\t */\n\tsummarize(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\t// TODO: Change this interface (and the one in ISharedObject, if necessary) to support \"handles within handles\".\n\t// Consider the case of a document with history; the return value here currently grows unboundedly.\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the component to perform custom loading. The storage service is scoped to this component and therefore\n\t * paths in this component will not collide with those in other components, even if they are the same string.\n\t * @param service - Storage used by the component\n\t * @param parse - Parses serialized data from storage into runtime objects for the component\n\t */\n\tload(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;\n}\n\n/**\n * Serializes the given contents into a string acceptable for storing in summaries, i.e. all\n * Fluid handles have been replaced appropriately by an IFluidSerializer\n */\nexport type SummaryElementStringifier = (contents: unknown) => string;\n\n/**\n * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary\n */\nexport type SummaryElementParser = (contents: string) => unknown;\n\n/**\n * Compose an {@link IChannelStorageService} which prefixes all paths before forwarding them to the original service\n */\nfunction scopeStorageService(\n\tservice: IChannelStorageService,\n\t...pathElements: string[]\n): IChannelStorageService {\n\tconst scope = `${pathElements.join(\"/\")}/`;\n\n\treturn {\n\t\tasync readBlob(path: string): Promise<ArrayBufferLike> {\n\t\t\treturn service.readBlob(`${scope}${path}`);\n\t\t},\n\t\tasync contains(path) {\n\t\t\treturn service.contains(`${scope}${path}`);\n\t\t},\n\t\tasync list(path) {\n\t\t\treturn service.list(`${scope}${path}`);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { IDisposable, Listenable } from "@fluidframework/core-interfaces";
|
|
6
|
+
/**
|
|
7
|
+
* Describes the result of a transaction.
|
|
8
|
+
* Transactions may either succeed and commit, or fail and abort.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum TransactionResult {
|
|
11
|
+
/**
|
|
12
|
+
* Indicates the transaction failed.
|
|
13
|
+
*/
|
|
14
|
+
Abort = 0,
|
|
15
|
+
/**
|
|
16
|
+
* Indicates the transaction succeeded.
|
|
17
|
+
*/
|
|
18
|
+
Commit = 1
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A simple API for managing transactions.
|
|
22
|
+
*/
|
|
23
|
+
export interface Transactor {
|
|
24
|
+
/**
|
|
25
|
+
* Start a new transaction.
|
|
26
|
+
* If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
|
|
27
|
+
* i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
|
|
28
|
+
*
|
|
29
|
+
* @remarks - Asynchronous transactions are not supported on the root checkout,
|
|
30
|
+
* since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
|
|
31
|
+
* the transaction) is not visible to the application author.
|
|
32
|
+
* Instead,
|
|
33
|
+
*
|
|
34
|
+
* 1. fork the root checkout
|
|
35
|
+
* 2. run the transaction on the fork
|
|
36
|
+
* 3. merge the fork back into the root checkout
|
|
37
|
+
*
|
|
38
|
+
* @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
|
|
39
|
+
* AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
|
|
40
|
+
*/
|
|
41
|
+
start(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Close this transaction by squashing its edits and committing them as a single edit.
|
|
44
|
+
* If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
|
|
45
|
+
*/
|
|
46
|
+
commit(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Close this transaction and revert the state of the tree to what it was before this transaction began.
|
|
49
|
+
*/
|
|
50
|
+
abort(): void;
|
|
51
|
+
/**
|
|
52
|
+
* True if there is at least one transaction currently in progress on this view, otherwise false.
|
|
53
|
+
*/
|
|
54
|
+
isInProgress(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Provides events for changes in transaction progress.
|
|
57
|
+
*/
|
|
58
|
+
events: Listenable<TransactionEvents>;
|
|
59
|
+
}
|
|
60
|
+
export interface TransactionEvents {
|
|
61
|
+
/**
|
|
62
|
+
* Raised just after a transaction has begun.
|
|
63
|
+
* @remarks When this event fires, {@link Transactor.isInProgress} will be true because the transaction has already begun.
|
|
64
|
+
*/
|
|
65
|
+
started(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Raised just before a transaction is aborted.
|
|
68
|
+
* @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.
|
|
69
|
+
*/
|
|
70
|
+
aborting(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Raised just before a transaction is committed.
|
|
73
|
+
* @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.
|
|
74
|
+
*/
|
|
75
|
+
committing(): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
|
|
79
|
+
* @remarks This function may return {@link OnPop | its complement} - another function that will be called when the transaction is popped from the stack.
|
|
80
|
+
* This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.
|
|
81
|
+
*/
|
|
82
|
+
export type OnPush = () => OnPop | void;
|
|
83
|
+
/**
|
|
84
|
+
* A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.
|
|
85
|
+
* @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.
|
|
86
|
+
*/
|
|
87
|
+
export type OnPop = (result: TransactionResult) => void;
|
|
88
|
+
/**
|
|
89
|
+
* An implementation of {@link Transactor} that uses a stack to manage transactions.
|
|
90
|
+
* @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.
|
|
91
|
+
*/
|
|
92
|
+
export declare class TransactionStack implements Transactor, IDisposable {
|
|
93
|
+
#private;
|
|
94
|
+
get events(): Listenable<TransactionEvents>;
|
|
95
|
+
get disposed(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Construct a new {@link TransactionStack}.
|
|
98
|
+
* @param onPush - A {@link OnPush | function} that will be called when a transaction begins.
|
|
99
|
+
*/
|
|
100
|
+
constructor(onPush?: () => OnPop | void);
|
|
101
|
+
isInProgress(): boolean;
|
|
102
|
+
start(): void;
|
|
103
|
+
commit(): void;
|
|
104
|
+
abort(): void;
|
|
105
|
+
dispose(): void;
|
|
106
|
+
private ensureNotDisposed;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction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}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
8
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
9
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var _TransactionStack_stack, _TransactionStack_onPush, _TransactionStack_events, _TransactionStack_disposed;
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.TransactionStack = exports.TransactionResult = void 0;
|
|
20
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
21
|
+
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
22
|
+
/**
|
|
23
|
+
* Describes the result of a transaction.
|
|
24
|
+
* Transactions may either succeed and commit, or fail and abort.
|
|
25
|
+
*/
|
|
26
|
+
var TransactionResult;
|
|
27
|
+
(function (TransactionResult) {
|
|
28
|
+
/**
|
|
29
|
+
* Indicates the transaction failed.
|
|
30
|
+
*/
|
|
31
|
+
TransactionResult[TransactionResult["Abort"] = 0] = "Abort";
|
|
32
|
+
/**
|
|
33
|
+
* Indicates the transaction succeeded.
|
|
34
|
+
*/
|
|
35
|
+
TransactionResult[TransactionResult["Commit"] = 1] = "Commit";
|
|
36
|
+
})(TransactionResult || (exports.TransactionResult = TransactionResult = {}));
|
|
37
|
+
/**
|
|
38
|
+
* An implementation of {@link Transactor} that uses a stack to manage transactions.
|
|
39
|
+
* @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.
|
|
40
|
+
*/
|
|
41
|
+
class TransactionStack {
|
|
42
|
+
get events() {
|
|
43
|
+
return __classPrivateFieldGet(this, _TransactionStack_events, "f");
|
|
44
|
+
}
|
|
45
|
+
get disposed() {
|
|
46
|
+
return __classPrivateFieldGet(this, _TransactionStack_disposed, "f");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Construct a new {@link TransactionStack}.
|
|
50
|
+
* @param onPush - A {@link OnPush | function} that will be called when a transaction begins.
|
|
51
|
+
*/
|
|
52
|
+
constructor(onPush) {
|
|
53
|
+
_TransactionStack_stack.set(this, []);
|
|
54
|
+
_TransactionStack_onPush.set(this, void 0);
|
|
55
|
+
_TransactionStack_events.set(this, (0, client_utils_1.createEmitter)());
|
|
56
|
+
_TransactionStack_disposed.set(this, false);
|
|
57
|
+
__classPrivateFieldSet(this, _TransactionStack_onPush, onPush, "f");
|
|
58
|
+
}
|
|
59
|
+
isInProgress() {
|
|
60
|
+
this.ensureNotDisposed();
|
|
61
|
+
return __classPrivateFieldGet(this, _TransactionStack_stack, "f").length > 0;
|
|
62
|
+
}
|
|
63
|
+
start() {
|
|
64
|
+
this.ensureNotDisposed();
|
|
65
|
+
__classPrivateFieldGet(this, _TransactionStack_stack, "f").push(__classPrivateFieldGet(this, _TransactionStack_onPush, "f")?.call(this));
|
|
66
|
+
__classPrivateFieldGet(this, _TransactionStack_events, "f").emit("started");
|
|
67
|
+
}
|
|
68
|
+
commit() {
|
|
69
|
+
this.ensureNotDisposed();
|
|
70
|
+
if (!this.isInProgress()) {
|
|
71
|
+
throw new internal_1.UsageError("No transaction to commit");
|
|
72
|
+
}
|
|
73
|
+
__classPrivateFieldGet(this, _TransactionStack_events, "f").emit("committing");
|
|
74
|
+
__classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.(TransactionResult.Commit);
|
|
75
|
+
}
|
|
76
|
+
abort() {
|
|
77
|
+
this.ensureNotDisposed();
|
|
78
|
+
if (!this.isInProgress()) {
|
|
79
|
+
throw new internal_1.UsageError("No transaction to abort");
|
|
80
|
+
}
|
|
81
|
+
__classPrivateFieldGet(this, _TransactionStack_events, "f").emit("aborting");
|
|
82
|
+
__classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.(TransactionResult.Abort);
|
|
83
|
+
}
|
|
84
|
+
dispose() {
|
|
85
|
+
this.ensureNotDisposed();
|
|
86
|
+
while (this.isInProgress()) {
|
|
87
|
+
this.abort();
|
|
88
|
+
}
|
|
89
|
+
__classPrivateFieldSet(this, _TransactionStack_disposed, true, "f");
|
|
90
|
+
}
|
|
91
|
+
ensureNotDisposed() {
|
|
92
|
+
if (this.disposed) {
|
|
93
|
+
throw new internal_1.UsageError("Transactor is disposed");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.TransactionStack = TransactionStack;
|
|
98
|
+
_TransactionStack_stack = new WeakMap(), _TransactionStack_onPush = new WeakMap(), _TransactionStack_events = new WeakMap(), _TransactionStack_disposed = new WeakMap();
|
|
99
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,+DAA6D;AAE7D,uEAAsE;AAEtE;;;GAGG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC5B;;OAEG;IACH,2DAAK,CAAA;IAC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E,EAAE,CAAC;YAC1B,MAAM,IAAI,qBAAU,CAAC,yBAAyB,CAAC,CAAC;QACjD,CAAC;QACD,uBAAA,IAAI,gCAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,uBAAA,IAAI,+BAAO,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QACD,uBAAA,IAAI,8BAAa,IAAI,MAAA,CAAC;IACvB,CAAC;IAEO,iBAAiB;QACxB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,qBAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;CACD;AAhED,4CAgEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Describes the result of a transaction.\n * Transactions may either succeed and commit, or fail and abort.\n */\nexport enum TransactionResult {\n\t/**\n\t * Indicates the transaction failed.\n\t */\n\tAbort,\n\t/**\n\t * Indicates the transaction succeeded.\n\t */\n\tCommit,\n}\n\n/**\n * A simple API for managing transactions.\n */\nexport interface Transactor {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): void;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): void;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tisInProgress(): boolean;\n\t/**\n\t * Provides events for changes in transaction progress.\n\t */\n\tevents: Listenable<TransactionEvents>;\n}\n\nexport interface TransactionEvents {\n\t/**\n\t * Raised just after a transaction has begun.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will be true because the transaction has already begun.\n\t */\n\tstarted(): void;\n\t/**\n\t * Raised just before a transaction is aborted.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.\n\t */\n\taborting(): void;\n\t/**\n\t * Raised just before a transaction is committed.\n\t * @remarks When this event fires, {@link Transactor.isInProgress} will still be true because the transaction has not yet ended.\n\t */\n\tcommitting(): void;\n}\n\n/**\n * A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n * @remarks This function may return {@link OnPop | its complement} - another function that will be called when the transaction is popped from the stack.\n * This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.\n */\nexport type OnPush = () => OnPop | void;\n\n/**\n * A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.\n * @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.isInProgress} will be false during its execution.\n */\nexport type OnPop = (result: TransactionResult) => void;\n\n/**\n * An implementation of {@link Transactor} that uses a stack to manage transactions.\n * @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.\n */\nexport class TransactionStack implements Transactor, IDisposable {\n\treadonly #stack: (OnPop | void)[] = [];\n\treadonly #onPush?: () => OnPop | void;\n\n\treadonly #events = createEmitter<TransactionEvents>();\n\tpublic get events(): Listenable<TransactionEvents> {\n\t\treturn this.#events;\n\t}\n\n\t#disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Construct a new {@link TransactionStack}.\n\t * @param onPush - A {@link OnPush | function} that will be called when a transaction begins.\n\t */\n\tpublic constructor(onPush?: () => OnPop | void) {\n\t\tthis.#onPush = onPush;\n\t}\n\n\tpublic isInProgress(): boolean {\n\t\tthis.ensureNotDisposed();\n\t\treturn this.#stack.length > 0;\n\t}\n\n\tpublic start(): void {\n\t\tthis.ensureNotDisposed();\n\t\tthis.#stack.push(this.#onPush?.());\n\t\tthis.#events.emit(\"started\");\n\t}\n\n\tpublic commit(): void {\n\t\tthis.ensureNotDisposed();\n\t\tif (!this.isInProgress()) {\n\t\t\tthrow new UsageError(\"No transaction to commit\");\n\t\t}\n\t\tthis.#events.emit(\"committing\");\n\t\tthis.#stack.pop()?.(TransactionResult.Commit);\n\t}\n\n\tpublic abort(): void {\n\t\tthis.ensureNotDisposed();\n\t\tif (!this.isInProgress()) {\n\t\t\tthrow new UsageError(\"No transaction to abort\");\n\t\t}\n\t\tthis.#events.emit(\"aborting\");\n\t\tthis.#stack.pop()?.(TransactionResult.Abort);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.ensureNotDisposed();\n\t\twhile (this.isInProgress()) {\n\t\t\tthis.abort();\n\t\t}\n\t\tthis.#disposed = true;\n\t}\n\n\tprivate ensureNotDisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthrow new UsageError(\"Transactor is disposed\");\n\t\t}\n\t}\n}\n"]}
|
|
@@ -8,21 +8,16 @@ import type { ChangeEnricherReadonlyCheckout } from "./changeEnricher.js";
|
|
|
8
8
|
* Utility for producing an enriched commit out of multiple transaction steps
|
|
9
9
|
*/
|
|
10
10
|
export declare class TransactionEnricher<TChange> {
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
#private;
|
|
12
|
+
constructor(rebaser: ChangeRebaser<TChange>, enricher: ChangeEnricherReadonlyCheckout<TChange>);
|
|
13
|
+
isTransacting(): boolean;
|
|
14
|
+
startTransaction(): void;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* where the integer at index `i` is the number of commits made before the start of the `i`th transaction scope
|
|
18
|
-
* (therefore, the first element in the array, if present, is always 0)
|
|
16
|
+
* Commits the current transaction.
|
|
17
|
+
* @returns If and only if the closed transaction was the outermost transaction, returns a function which can be used to compute the composed change for that transaction's commits.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
startNewTransaction(): void;
|
|
23
|
-
commitCurrentTransaction(): void;
|
|
24
|
-
abortCurrentTransaction(): void;
|
|
19
|
+
commitTransaction(): ((revision: RevisionTag) => TChange) | undefined;
|
|
20
|
+
abortTransaction(): void;
|
|
25
21
|
addTransactionStep(commit: GraphCommit<TChange>): void;
|
|
26
|
-
getComposedChange(revision: RevisionTag): TChange;
|
|
27
22
|
}
|
|
28
23
|
//# sourceMappingURL=transactionEnricher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transactionEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E;;GAEG;AACH,qBAAa,mBAAmB,CAAC,OAAO
|
|
1
|
+
{"version":3,"file":"transactionEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transactionEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E;;GAEG;AACH,qBAAa,mBAAmB,CAAC,OAAO;;gBAatC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAM3C,aAAa,IAAI,OAAO;IAIxB,gBAAgB,IAAI,IAAI;IAI/B;;;OAGG;IACI,iBAAiB,IAAI,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,SAAS;IAWrE,gBAAgB,IAAI,IAAI;IAMxB,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;CAQ7D"}
|