@fluidframework/tree 2.83.0 → 2.90.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/.vscode/settings.json +6 -5
- package/CHANGELOG.md +95 -0
- package/README.md +1 -1
- package/api-report/tree.alpha.api.md +63 -24
- package/api-report/tree.beta.api.md +30 -0
- package/api-report/tree.legacy.beta.api.md +30 -0
- package/dist/alpha.d.ts +10 -6
- package/dist/beta.d.ts +4 -1
- package/dist/codec/codec.d.ts +2 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +4 -3
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -1
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +13 -1
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +18 -3
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/format.d.ts +22 -1
- package/dist/codec/versioned/format.d.ts.map +1 -1
- package/dist/codec/versioned/format.js +16 -3
- package/dist/codec/versioned/format.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -1
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +78 -0
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +22 -44
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +11 -0
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js +2 -4
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -4
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/observer.d.ts +17 -0
- package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +5 -12
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +33 -33
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +6 -7
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.js +13 -11
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +31 -48
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/index.js +2 -2
- package/dist/feature-libraries/forest-summary/index.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -5
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
- package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/indexing/index.d.ts +1 -1
- package/dist/feature-libraries/indexing/index.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/index.js.map +1 -1
- package/dist/feature-libraries/indexing/types.d.ts +15 -13
- package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
- package/dist/feature-libraries/indexing/types.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +4 -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/independentView.js +2 -2
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +5 -0
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +35 -7
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +7 -7
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/tree.js +1 -1
- package/dist/shared-tree/tree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +8 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +48 -8
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +35 -3
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +123 -17
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree/unhydratedTreeContext.d.ts +20 -0
- package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
- package/dist/shared-tree/unhydratedTreeContext.js +56 -0
- package/dist/shared-tree/unhydratedTreeContext.js.map +1 -0
- package/dist/shared-tree-core/transaction.d.ts +15 -27
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +7 -11
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +4 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
- package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -1
- package/dist/simple-tree/api/identifierIndex.js +1 -1
- package/dist/simple-tree/api/identifierIndex.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -3
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +3 -2
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +3 -2
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.d.ts +15 -13
- package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +4 -4
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +22 -25
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +69 -132
- 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/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/text/textDomain.d.ts +27 -9
- package/dist/text/textDomain.d.ts.map +1 -1
- package/dist/text/textDomain.js +43 -7
- package/dist/text/textDomain.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +14 -8
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +97 -25
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/util/rangeMap.d.ts +1 -0
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +5 -6
- package/dist/util/rangeMap.js.map +1 -1
- package/lib/alpha.d.ts +10 -6
- package/lib/beta.d.ts +4 -1
- package/lib/codec/codec.d.ts +2 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +4 -3
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +13 -1
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +18 -3
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/format.d.ts +22 -1
- package/lib/codec/versioned/format.d.ts.map +1 -1
- package/lib/codec/versioned/format.js +15 -2
- package/lib/codec/versioned/format.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/index.d.ts +1 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +0 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +78 -0
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +25 -45
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +11 -0
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/observer.d.ts +17 -0
- package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/observer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +5 -12
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +35 -32
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +7 -8
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.js +7 -4
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +30 -47
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/index.js +1 -1
- package/lib/feature-libraries/forest-summary/index.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
- package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/indexing/index.d.ts +1 -1
- package/lib/feature-libraries/indexing/index.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/index.js.map +1 -1
- package/lib/feature-libraries/indexing/types.d.ts +15 -13
- package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
- package/lib/feature-libraries/indexing/types.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +4 -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/independentView.js +3 -3
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +5 -0
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +33 -6
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +8 -8
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/tree.js +1 -1
- package/lib/shared-tree/tree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +8 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +49 -9
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +35 -3
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +124 -18
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree/unhydratedTreeContext.d.ts +20 -0
- package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
- package/lib/shared-tree/unhydratedTreeContext.js +52 -0
- package/lib/shared-tree/unhydratedTreeContext.js.map +1 -0
- package/lib/shared-tree-core/transaction.d.ts +15 -27
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +7 -11
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +4 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
- package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -1
- package/lib/simple-tree/api/identifierIndex.js +2 -2
- package/lib/simple-tree/api/identifierIndex.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -3
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +3 -2
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +3 -2
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.d.ts +15 -13
- package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +22 -25
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +69 -132
- 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/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/text/textDomain.d.ts +27 -9
- package/lib/text/textDomain.d.ts.map +1 -1
- package/lib/text/textDomain.js +45 -9
- package/lib/text/textDomain.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +14 -8
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +80 -8
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/util/rangeMap.d.ts +1 -0
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +5 -6
- package/lib/util/rangeMap.js.map +1 -1
- package/package.json +24 -24
- package/src/codec/codec.ts +5 -4
- package/src/codec/index.ts +1 -0
- package/src/codec/versioned/codec.ts +32 -6
- package/src/codec/versioned/format.ts +17 -2
- package/src/codec/versioned/index.ts +1 -1
- package/src/core/index.ts +2 -6
- package/src/core/rebase/index.ts +2 -0
- package/src/core/rebase/types.ts +80 -0
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +59 -78
- package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
- package/src/feature-libraries/chunked-forest/codec/index.ts +3 -3
- package/src/feature-libraries/chunked-forest/index.ts +2 -3
- package/src/feature-libraries/flex-tree/observer.ts +17 -0
- package/src/feature-libraries/forest-summary/codec.ts +46 -56
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -14
- package/src/feature-libraries/forest-summary/formatCommon.ts +14 -19
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +44 -74
- package/src/feature-libraries/forest-summary/index.ts +1 -1
- package/src/feature-libraries/index.ts +2 -4
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +3 -5
- package/src/feature-libraries/indexing/index.ts +1 -1
- package/src/feature-libraries/indexing/types.ts +15 -17
- package/src/index.ts +6 -3
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +3 -3
- package/src/shared-tree/schematizingTreeView.ts +43 -10
- package/src/shared-tree/sharedTree.ts +8 -10
- package/src/shared-tree/tree.ts +1 -1
- package/src/shared-tree/treeAlpha.ts +64 -11
- package/src/shared-tree/treeCheckout.ts +142 -21
- package/src/shared-tree/unhydratedTreeContext.ts +87 -0
- package/src/shared-tree-core/transaction.ts +19 -39
- package/src/simple-tree/api/configuration.ts +4 -0
- package/src/simple-tree/api/identifierIndex.ts +4 -4
- package/src/simple-tree/api/index.ts +3 -1
- package/src/simple-tree/api/schemaFactory.ts +3 -2
- package/src/simple-tree/api/simpleTreeIndex.ts +26 -20
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -4
- package/src/simple-tree/api/transactionTypes.ts +24 -26
- package/src/simple-tree/api/tree.ts +92 -131
- package/src/simple-tree/index.ts +4 -2
- package/src/text/textDomain.ts +91 -12
- package/src/text/textDomainFormatted.ts +127 -15
- package/src/util/rangeMap.ts +5 -11
- package/dist/core/schema-view/index.d.ts +0 -6
- package/dist/core/schema-view/index.d.ts.map +0 -1
- package/dist/core/schema-view/index.js +0 -10
- package/dist/core/schema-view/index.js.map +0 -1
- package/dist/core/schema-view/view.d.ts +0 -31
- package/dist/core/schema-view/view.d.ts.map +0 -1
- package/dist/core/schema-view/view.js +0 -18
- package/dist/core/schema-view/view.js.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV1.d.ts +0 -12
- package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV1.js +0 -10
- package/dist/feature-libraries/forest-summary/formatV1.js.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV2.d.ts +0 -12
- package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
- package/dist/feature-libraries/forest-summary/formatV2.js +0 -10
- package/dist/feature-libraries/forest-summary/formatV2.js.map +0 -1
- package/lib/core/schema-view/index.d.ts +0 -6
- package/lib/core/schema-view/index.d.ts.map +0 -1
- package/lib/core/schema-view/index.js +0 -6
- package/lib/core/schema-view/index.js.map +0 -1
- package/lib/core/schema-view/view.d.ts +0 -31
- package/lib/core/schema-view/view.d.ts.map +0 -1
- package/lib/core/schema-view/view.js +0 -14
- package/lib/core/schema-view/view.js.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV1.d.ts +0 -12
- package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV1.js +0 -7
- package/lib/feature-libraries/forest-summary/formatV1.js.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV2.d.ts +0 -12
- package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
- package/lib/feature-libraries/forest-summary/formatV2.js +0 -7
- package/lib/feature-libraries/forest-summary/formatV2.js.map +0 -1
- package/src/core/schema-view/README.md +0 -9
- package/src/core/schema-view/index.ts +0 -10
- package/src/core/schema-view/view.ts +0 -38
- package/src/feature-libraries/forest-summary/formatV1.ts +0 -11
- package/src/feature-libraries/forest-summary/formatV2.ts +0 -11
|
@@ -55,6 +55,8 @@ import {
|
|
|
55
55
|
LeafNodeStoredSchema,
|
|
56
56
|
diffHistories,
|
|
57
57
|
type ChangeMetadata,
|
|
58
|
+
type LabelTree,
|
|
59
|
+
type TransactionLabels,
|
|
58
60
|
type ChangeEncodingContext,
|
|
59
61
|
type ReadOnlyDetachedFieldIndex,
|
|
60
62
|
makeAnonChange,
|
|
@@ -67,9 +69,9 @@ import {
|
|
|
67
69
|
buildForest,
|
|
68
70
|
createNodeIdentifierManager,
|
|
69
71
|
defaultSchemaPolicy,
|
|
72
|
+
fieldBatchCodecBuilder,
|
|
70
73
|
intoDelta,
|
|
71
74
|
jsonableTreeFromCursor,
|
|
72
|
-
makeFieldBatchCodec,
|
|
73
75
|
} from "../feature-libraries/index.js";
|
|
74
76
|
import {
|
|
75
77
|
SquashingTransactionStack,
|
|
@@ -108,6 +110,36 @@ import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamil
|
|
|
108
110
|
import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
|
|
109
111
|
import type { ISharedTreeEditor, SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
|
|
110
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Yields all defined (non-`undefined`) labels from a {@link LabelTree}, depth-first.
|
|
115
|
+
*/
|
|
116
|
+
function* collectTreeLabels(node: LabelTree): IterableIterator<unknown> {
|
|
117
|
+
if (node.label !== undefined) {
|
|
118
|
+
yield node.label;
|
|
119
|
+
}
|
|
120
|
+
for (const child of node.sublabels) {
|
|
121
|
+
yield* collectTreeLabels(child);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Builds the labels set for a change event from the label tree.
|
|
127
|
+
* If the tree exists and contains at least one defined label, returns a set of all
|
|
128
|
+
* values with the tree attached. Otherwise returns an empty set.
|
|
129
|
+
*/
|
|
130
|
+
function buildLabelsSet(labelTreeNode: LabelTree | undefined): TransactionLabels {
|
|
131
|
+
const set: Set<unknown> & { tree?: LabelTree } = new Set<unknown>();
|
|
132
|
+
if (labelTreeNode !== undefined) {
|
|
133
|
+
for (const value of collectTreeLabels(labelTreeNode)) {
|
|
134
|
+
set.add(value);
|
|
135
|
+
}
|
|
136
|
+
if (set.size > 0) {
|
|
137
|
+
set.tree = labelTreeNode;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return set;
|
|
141
|
+
}
|
|
142
|
+
|
|
111
143
|
/**
|
|
112
144
|
* Events for {@link ITreeCheckout}.
|
|
113
145
|
*/
|
|
@@ -322,7 +354,7 @@ export function createTreeCheckout(
|
|
|
322
354
|
args?.changeFamily ??
|
|
323
355
|
new SharedTreeChangeFamily(
|
|
324
356
|
revisionTagCodec,
|
|
325
|
-
args?.fieldBatchCodec ??
|
|
357
|
+
args?.fieldBatchCodec ?? fieldBatchCodecBuilder.build(codecOptions),
|
|
326
358
|
codecOptions,
|
|
327
359
|
args?.chunkCompressionStrategy,
|
|
328
360
|
idCompressor,
|
|
@@ -389,12 +421,22 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
389
421
|
private editLock: EditLock;
|
|
390
422
|
|
|
391
423
|
/**
|
|
392
|
-
*
|
|
424
|
+
* Root of the mutable label tree tracking transaction nesting.
|
|
393
425
|
*
|
|
394
426
|
* @remarks
|
|
395
|
-
*
|
|
427
|
+
* The label tree is always isomorphic to the actual transaction tree — every transaction
|
|
428
|
+
* (whether labeled or not) gets its own node. To find the "current" (deepest open) node,
|
|
429
|
+
* walk down the right side of the tree, stopping at {@link TreeCheckout.mostRecentlyClosedLabelNode}.
|
|
430
|
+
*
|
|
431
|
+
* Cleared by {@link TreeCheckout.runWithTransactionLabel} after the commit event is emitted.
|
|
432
|
+
*/
|
|
433
|
+
private labelTreeNode: LabelTree | undefined;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Points to the most recently closed (committed) label node.
|
|
437
|
+
* Used by {@link TreeCheckout.currentLabelNode} to stop descending past committed nodes.
|
|
396
438
|
*/
|
|
397
|
-
private
|
|
439
|
+
private mostRecentlyClosedLabelNode: LabelTree | undefined;
|
|
398
440
|
|
|
399
441
|
private readonly views = new Set<TreeView<ImplicitFieldSchema>>();
|
|
400
442
|
|
|
@@ -447,6 +489,82 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
447
489
|
this.registerForBranchEvents();
|
|
448
490
|
}
|
|
449
491
|
|
|
492
|
+
/**
|
|
493
|
+
* Pushes a new label node for a transaction nesting level.
|
|
494
|
+
*
|
|
495
|
+
* @param label - The label for this transaction level.
|
|
496
|
+
*
|
|
497
|
+
* @remarks
|
|
498
|
+
* Called at the start of each transaction (including nested ones).
|
|
499
|
+
* Creates a new {@link LabelTree} node as a child of the current deepest node (if any),
|
|
500
|
+
* or as the root if this is the outermost transaction.
|
|
501
|
+
*/
|
|
502
|
+
public pushLabelFrame(label: unknown): void {
|
|
503
|
+
const node: LabelTree = { label, sublabels: [] };
|
|
504
|
+
if (this.labelTreeNode === undefined) {
|
|
505
|
+
this.labelTreeNode = node;
|
|
506
|
+
} else {
|
|
507
|
+
const current = this.currentLabelNode();
|
|
508
|
+
assert(current !== undefined, 0xcdb /* Expected current label node to exist */);
|
|
509
|
+
current.sublabels.push(node);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Returns the deepest open node on the right side of the label tree, which corresponds
|
|
515
|
+
* to the current (most recently pushed, not yet committed or aborted) transaction.
|
|
516
|
+
* Returns `undefined` when {@link TreeCheckout.labelTreeNode} is not set.
|
|
517
|
+
*/
|
|
518
|
+
private currentLabelNode(): LabelTree | undefined {
|
|
519
|
+
if (this.labelTreeNode === undefined) {
|
|
520
|
+
return undefined;
|
|
521
|
+
}
|
|
522
|
+
// Walk down the right spine of the tree. Only one closed node is ever reachable
|
|
523
|
+
// during this traversal, so a single pointer (mostRecentlyClosedLabelNode) suffices
|
|
524
|
+
// to stop descending past committed nodes.
|
|
525
|
+
let node: LabelTree = this.labelTreeNode;
|
|
526
|
+
while (node.sublabels.length > 0) {
|
|
527
|
+
const lastChild = node.sublabels[node.sublabels.length - 1];
|
|
528
|
+
assert(lastChild !== undefined, 0xcdc /* Expected label tree node to have children */);
|
|
529
|
+
if (lastChild === this.mostRecentlyClosedLabelNode) {
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
node = lastChild;
|
|
533
|
+
}
|
|
534
|
+
return node;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Pops the current label frame from the label tree.
|
|
539
|
+
* @param aborted - If true, the node is removed from the tree (transaction was aborted).
|
|
540
|
+
* If false, the node is kept in the tree but marked as closed (transaction was committed).
|
|
541
|
+
*/
|
|
542
|
+
public popLabelFrame(aborted: boolean): void {
|
|
543
|
+
const node = this.currentLabelNode();
|
|
544
|
+
if (node === undefined) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (aborted) {
|
|
549
|
+
if (node === this.labelTreeNode) {
|
|
550
|
+
this.labelTreeNode = undefined;
|
|
551
|
+
this.mostRecentlyClosedLabelNode = undefined;
|
|
552
|
+
} else {
|
|
553
|
+
// Temporarily mark node as closed so currentLabelNode() returns its parent.
|
|
554
|
+
this.mostRecentlyClosedLabelNode = node;
|
|
555
|
+
const parent = this.currentLabelNode();
|
|
556
|
+
assert(parent !== undefined, 0xcdd /* Expected parent label node to exist */);
|
|
557
|
+
parent.sublabels.pop();
|
|
558
|
+
// Point to the parent's new last child (guaranteed closed if it exists),
|
|
559
|
+
// or undefined if the parent has no more children.
|
|
560
|
+
const newLastChild = parent.sublabels[parent.sublabels.length - 1];
|
|
561
|
+
this.mostRecentlyClosedLabelNode = newLastChild;
|
|
562
|
+
}
|
|
563
|
+
} else {
|
|
564
|
+
this.mostRecentlyClosedLabelNode = node;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
450
568
|
/**
|
|
451
569
|
* Helper method for {@link SchematizingSimpleTreeView.runTransaction} to properly clear transaction labels once the function completes.
|
|
452
570
|
*
|
|
@@ -463,15 +581,16 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
463
581
|
fn: (label?: TLabel) => TResult,
|
|
464
582
|
label: TLabel | undefined,
|
|
465
583
|
): TResult {
|
|
466
|
-
// If a transaction label is already set, nesting is occurring, so we should not override it.
|
|
467
|
-
if (this.transactionLabel !== undefined) {
|
|
468
|
-
return fn(this.transactionLabel as TLabel);
|
|
469
|
-
}
|
|
470
|
-
this.transactionLabel = label;
|
|
471
584
|
try {
|
|
472
|
-
return fn(
|
|
585
|
+
return fn(label);
|
|
473
586
|
} finally {
|
|
474
|
-
|
|
587
|
+
// Only clear the label tree when the outermost transaction has completed.
|
|
588
|
+
// Inner transactions' commits don't fire the "changed" event, so the label tree
|
|
589
|
+
// must remain intact until the outermost commit reads it.
|
|
590
|
+
if (this.transaction.size === 0) {
|
|
591
|
+
this.labelTreeNode = undefined;
|
|
592
|
+
this.mostRecentlyClosedLabelNode = undefined;
|
|
593
|
+
}
|
|
475
594
|
}
|
|
476
595
|
}
|
|
477
596
|
|
|
@@ -514,7 +633,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
514
633
|
if (viewUpdate !== undefined) {
|
|
515
634
|
this.applyChange(viewUpdate, newHead.revision);
|
|
516
635
|
}
|
|
517
|
-
if (
|
|
636
|
+
if (this.transaction.size === 0) {
|
|
518
637
|
// The changes in a transaction squash commit have already applied to the checkout and are known to be valid, so we can validate the squash commit automatically.
|
|
519
638
|
this.validateCommit(newHead);
|
|
520
639
|
}
|
|
@@ -611,7 +730,8 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
611
730
|
} satisfies SerializedChange;
|
|
612
731
|
},
|
|
613
732
|
getRevertible: (onDisposed) => getRevertible?.(onDisposed),
|
|
614
|
-
label: this.
|
|
733
|
+
label: this.labelTreeNode?.label,
|
|
734
|
+
labels: buildLabelsSet(this.labelTreeNode),
|
|
615
735
|
};
|
|
616
736
|
|
|
617
737
|
this.#events.emit("changed", metadata, getRevertible);
|
|
@@ -622,6 +742,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
622
742
|
this.#events.emit("changed", {
|
|
623
743
|
isLocal: false,
|
|
624
744
|
kind: CommitKind.Default,
|
|
745
|
+
labels: new Set<unknown>(),
|
|
625
746
|
});
|
|
626
747
|
}
|
|
627
748
|
};
|
|
@@ -870,7 +991,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
870
991
|
"The parent branch has already been disposed and can no longer create new branches.",
|
|
871
992
|
);
|
|
872
993
|
// Branching after an unfinished transaction would expose the application to a state where its invariants may be violated.
|
|
873
|
-
if (this.transaction.
|
|
994
|
+
if (this.transaction.size > 0) {
|
|
874
995
|
throw new UsageError("A view cannot be forked while it has a pending transaction.");
|
|
875
996
|
}
|
|
876
997
|
|
|
@@ -902,7 +1023,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
902
1023
|
): void {
|
|
903
1024
|
// TODO: Dispose old branch, if necessary
|
|
904
1025
|
assert(
|
|
905
|
-
|
|
1026
|
+
this.#transaction.size === 0,
|
|
906
1027
|
0xc55 /* Cannot switch branches during a transaction */,
|
|
907
1028
|
);
|
|
908
1029
|
const diff = diffHistories(
|
|
@@ -932,12 +1053,12 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
932
1053
|
);
|
|
933
1054
|
this.editLock.checkUnlocked("Rebasing");
|
|
934
1055
|
|
|
935
|
-
if (this.transaction.
|
|
1056
|
+
if (this.transaction.size > 0) {
|
|
936
1057
|
throw new UsageError(
|
|
937
1058
|
"Views cannot be rebased onto a view that has a pending transaction.",
|
|
938
1059
|
);
|
|
939
1060
|
}
|
|
940
|
-
if (checkout.transaction.
|
|
1061
|
+
if (checkout.transaction.size > 0) {
|
|
941
1062
|
throw new UsageError("A view cannot be rebased while it has a pending transaction.");
|
|
942
1063
|
}
|
|
943
1064
|
|
|
@@ -966,12 +1087,12 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
966
1087
|
"The source of the branch merge has been disposed and cannot be merged.",
|
|
967
1088
|
);
|
|
968
1089
|
this.editLock.checkUnlocked("Merging");
|
|
969
|
-
if (this.transaction.
|
|
1090
|
+
if (this.transaction.size > 0) {
|
|
970
1091
|
throw new UsageError(
|
|
971
1092
|
"Views cannot be merged into a view while it has a pending transaction.",
|
|
972
1093
|
);
|
|
973
1094
|
}
|
|
974
|
-
if (checkout.transaction.
|
|
1095
|
+
if (checkout.transaction.size > 0) {
|
|
975
1096
|
throw new UsageError(
|
|
976
1097
|
"Views with an open transaction cannot be merged into another view.",
|
|
977
1098
|
);
|
|
@@ -1057,7 +1178,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
1057
1178
|
|
|
1058
1179
|
private revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {
|
|
1059
1180
|
this.editLock.checkUnlocked("Reverting a commit");
|
|
1060
|
-
if (this.transaction.
|
|
1181
|
+
if (this.transaction.size > 0) {
|
|
1061
1182
|
throw new UsageError("Undo is not yet supported during transactions.");
|
|
1062
1183
|
}
|
|
1063
1184
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
TreeContextAlpha,
|
|
10
|
+
TreeBranchAlpha,
|
|
11
|
+
RunTransactionParams,
|
|
12
|
+
TransactionResult,
|
|
13
|
+
TransactionResultExt,
|
|
14
|
+
WithValue,
|
|
15
|
+
} from "../simple-tree/index.js";
|
|
16
|
+
|
|
17
|
+
import { assertValidConstraint } from "./schematizingTreeView.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A {@link TreeContextAlpha | tree context} that can be used for e.g. unhydrated nodes.
|
|
21
|
+
*/
|
|
22
|
+
export class UnhydratedTreeContext implements TreeContextAlpha {
|
|
23
|
+
public static instance = new UnhydratedTreeContext();
|
|
24
|
+
private transactionCount = 0;
|
|
25
|
+
private constructor() {}
|
|
26
|
+
|
|
27
|
+
public isBranch(): this is TreeBranchAlpha {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public runTransaction<TValue>(
|
|
32
|
+
t: () => WithValue<TValue>,
|
|
33
|
+
params?: RunTransactionParams,
|
|
34
|
+
): TransactionResultExt<TValue, TValue>;
|
|
35
|
+
public runTransaction(t: () => void, _params?: RunTransactionParams): TransactionResult;
|
|
36
|
+
public runTransaction(
|
|
37
|
+
t: () => WithValue<unknown> | void,
|
|
38
|
+
params?: RunTransactionParams,
|
|
39
|
+
): TransactionResultExt<unknown, unknown> | TransactionResult {
|
|
40
|
+
for (const constraint of params?.preconditions ?? []) {
|
|
41
|
+
assertValidConstraint(constraint, false);
|
|
42
|
+
}
|
|
43
|
+
this.transactionCount += 1;
|
|
44
|
+
try {
|
|
45
|
+
return UnhydratedTreeContext.wrapTransactionResult(t());
|
|
46
|
+
} finally {
|
|
47
|
+
this.transactionCount -= 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public runTransactionAsync<TValue>(
|
|
52
|
+
t: () => Promise<WithValue<TValue>>,
|
|
53
|
+
params?: RunTransactionParams,
|
|
54
|
+
): Promise<TransactionResultExt<TValue, TValue>>;
|
|
55
|
+
public runTransactionAsync(
|
|
56
|
+
t: () => Promise<void>,
|
|
57
|
+
params?: RunTransactionParams,
|
|
58
|
+
): Promise<TransactionResult>;
|
|
59
|
+
public async runTransactionAsync(
|
|
60
|
+
t: () => Promise<WithValue<unknown> | void>,
|
|
61
|
+
params?: RunTransactionParams,
|
|
62
|
+
): Promise<TransactionResultExt<unknown, unknown> | TransactionResult> {
|
|
63
|
+
if (this.transactionCount > 0) {
|
|
64
|
+
throw new UsageError(
|
|
65
|
+
"An asynchronous transaction cannot be started while another transaction is already in progress.",
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
for (const constraint of params?.preconditions ?? []) {
|
|
69
|
+
assertValidConstraint(constraint, false);
|
|
70
|
+
}
|
|
71
|
+
this.transactionCount += 1;
|
|
72
|
+
try {
|
|
73
|
+
return UnhydratedTreeContext.wrapTransactionResult(await t());
|
|
74
|
+
} finally {
|
|
75
|
+
this.transactionCount -= 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private static wrapTransactionResult<TValue>(
|
|
80
|
+
value: WithValue<TValue> | void,
|
|
81
|
+
): TransactionResultExt<TValue, TValue> | TransactionResult {
|
|
82
|
+
if (value?.value !== undefined) {
|
|
83
|
+
return { success: true, value: value.value };
|
|
84
|
+
}
|
|
85
|
+
return { success: true };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -44,27 +44,14 @@ export enum TransactionResult {
|
|
|
44
44
|
export interface Transactor {
|
|
45
45
|
/**
|
|
46
46
|
* Start a new transaction.
|
|
47
|
+
* @remarks
|
|
47
48
|
* If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
|
|
48
49
|
* i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
|
|
49
|
-
* @param isAsync - Whether the transaction is asynchronous.
|
|
50
|
-
* An error will be thrown if an asynchronous transaction is started while a synchronous transaction is in progress.
|
|
51
|
-
*
|
|
52
|
-
* @remarks Asynchronous transactions are not supported on the root checkout,
|
|
53
|
-
* since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
|
|
54
|
-
* the transaction) is not visible to the application author.
|
|
55
|
-
* Instead,
|
|
56
|
-
*
|
|
57
|
-
* 1. fork the root checkout
|
|
58
|
-
* 2. run the transaction on the fork
|
|
59
|
-
* 3. merge the fork back into the root checkout
|
|
60
|
-
*
|
|
61
|
-
* @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
|
|
62
|
-
* AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
|
|
63
50
|
*/
|
|
64
|
-
start(
|
|
51
|
+
start(): void;
|
|
65
52
|
/**
|
|
66
53
|
* Close this transaction by squashing its edits and committing them as a single edit.
|
|
67
|
-
* If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
|
|
54
|
+
* @remarks If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
|
|
68
55
|
*/
|
|
69
56
|
commit(): void;
|
|
70
57
|
/**
|
|
@@ -72,9 +59,10 @@ export interface Transactor {
|
|
|
72
59
|
*/
|
|
73
60
|
abort(): void;
|
|
74
61
|
/**
|
|
75
|
-
*
|
|
62
|
+
* The number of transactions currently in progress, including any nested transactions.
|
|
63
|
+
* @remarks This is 0 when no transaction is in progress, 1 when a single transaction is in progress, 2 when a transaction is nested inside another, etc.
|
|
76
64
|
*/
|
|
77
|
-
|
|
65
|
+
size: number;
|
|
78
66
|
/**
|
|
79
67
|
* Provides events for changes in transaction progress.
|
|
80
68
|
*/
|
|
@@ -84,17 +72,17 @@ export interface Transactor {
|
|
|
84
72
|
export interface TransactionEvents {
|
|
85
73
|
/**
|
|
86
74
|
* Raised just after a transaction has begun.
|
|
87
|
-
* @remarks When this event fires, {@link Transactor.
|
|
75
|
+
* @remarks When this event fires, {@link Transactor.size} will be greater than 0 because the transaction has already begun.
|
|
88
76
|
*/
|
|
89
77
|
started(): void;
|
|
90
78
|
/**
|
|
91
79
|
* Raised just before a transaction is aborted.
|
|
92
|
-
* @remarks When this event fires, {@link Transactor.
|
|
80
|
+
* @remarks When this event fires, {@link Transactor.size} will still be greater than 0 because the transaction has not yet ended.
|
|
93
81
|
*/
|
|
94
82
|
aborting(): void;
|
|
95
83
|
/**
|
|
96
84
|
* Raised just before a transaction is committed.
|
|
97
|
-
* @remarks When this event fires, {@link Transactor.
|
|
85
|
+
* @remarks When this event fires, {@link Transactor.size} will still be greater than 0 because the transaction has not yet ended.
|
|
98
86
|
*/
|
|
99
87
|
committing(): void;
|
|
100
88
|
}
|
|
@@ -122,13 +110,13 @@ export interface Callbacks {
|
|
|
122
110
|
/**
|
|
123
111
|
* A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
|
|
124
112
|
* @remarks This function may return other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto the stack.
|
|
125
|
-
* This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.
|
|
113
|
+
* This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
|
|
126
114
|
*/
|
|
127
115
|
export type OnPush = () => Callbacks | void;
|
|
128
116
|
|
|
129
117
|
/**
|
|
130
118
|
* A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.
|
|
131
|
-
* @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.
|
|
119
|
+
* @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
|
|
132
120
|
*/
|
|
133
121
|
export type OnPop = (result: TransactionResult) => void;
|
|
134
122
|
|
|
@@ -138,8 +126,6 @@ export type OnPop = (result: TransactionResult) => void;
|
|
|
138
126
|
interface TransactionStackFrame {
|
|
139
127
|
/** The callbacks provided when this transaction frame was pushed onto the stack. */
|
|
140
128
|
readonly callbacks: Callbacks;
|
|
141
|
-
/** Whether this transaction frame is asynchronous. */
|
|
142
|
-
readonly isAsync: boolean;
|
|
143
129
|
}
|
|
144
130
|
|
|
145
131
|
/**
|
|
@@ -168,31 +154,25 @@ export class TransactionStack implements Transactor, IDisposable {
|
|
|
168
154
|
this.#onPush = onPush;
|
|
169
155
|
}
|
|
170
156
|
|
|
171
|
-
public
|
|
157
|
+
public get size(): number {
|
|
172
158
|
this.ensureNotDisposed();
|
|
173
|
-
return this.#stack.length
|
|
159
|
+
return this.#stack.length;
|
|
174
160
|
}
|
|
175
161
|
|
|
176
|
-
public start(
|
|
162
|
+
public start(): void {
|
|
177
163
|
this.ensureNotDisposed();
|
|
178
164
|
const last = getLast(this.#stack);
|
|
179
|
-
if (last !== undefined && !last.isAsync && isAsync) {
|
|
180
|
-
throw new UsageError(
|
|
181
|
-
"An asynchronous transaction cannot be started while a synchronous transaction is in progress.",
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
165
|
const onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;
|
|
185
166
|
const { onPush, onPop } = onPushCurrent?.() ?? {};
|
|
186
167
|
this.#stack.push({
|
|
187
168
|
callbacks: { onPop, onPush: onPush ?? onPushCurrent },
|
|
188
|
-
isAsync,
|
|
189
169
|
});
|
|
190
170
|
this.#events.emit("started");
|
|
191
171
|
}
|
|
192
172
|
|
|
193
173
|
public commit(): void {
|
|
194
174
|
this.ensureNotDisposed();
|
|
195
|
-
if (
|
|
175
|
+
if (this.size === 0) {
|
|
196
176
|
throw new UsageError("No transaction to commit");
|
|
197
177
|
}
|
|
198
178
|
this.#events.emit("committing");
|
|
@@ -201,7 +181,7 @@ export class TransactionStack implements Transactor, IDisposable {
|
|
|
201
181
|
|
|
202
182
|
public abort(): void {
|
|
203
183
|
this.ensureNotDisposed();
|
|
204
|
-
if (
|
|
184
|
+
if (this.size === 0) {
|
|
205
185
|
throw new UsageError("No transaction to abort");
|
|
206
186
|
}
|
|
207
187
|
this.#events.emit("aborting");
|
|
@@ -210,7 +190,7 @@ export class TransactionStack implements Transactor, IDisposable {
|
|
|
210
190
|
|
|
211
191
|
public dispose(): void {
|
|
212
192
|
this.ensureNotDisposed();
|
|
213
|
-
while (this.
|
|
193
|
+
while (this.size > 0) {
|
|
214
194
|
this.abort();
|
|
215
195
|
}
|
|
216
196
|
this.#disposed = true;
|
|
@@ -225,7 +205,7 @@ export class TransactionStack implements Transactor, IDisposable {
|
|
|
225
205
|
|
|
226
206
|
/**
|
|
227
207
|
* A function that will be called when a transaction is popped from the {@link SquashingTransactionStack | stack}.
|
|
228
|
-
* @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.
|
|
208
|
+
* @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
|
|
229
209
|
* @param result - The result of the transaction.
|
|
230
210
|
* @param viewUpdate - The change that needs to be applied to the view to keep it up-to-date with the branch after the transaction ends.
|
|
231
211
|
* This is needed in asynchronous transactions where new commits have been added to the branch while the transaction was in progress.
|
|
@@ -328,7 +308,7 @@ export class SquashingTransactionStack<
|
|
|
328
308
|
|
|
329
309
|
// Invoked when an outer transaction ends
|
|
330
310
|
const onOuterTransactionPop: OnPop = (result) => {
|
|
331
|
-
assert(
|
|
311
|
+
assert(this.size === 0, 0xcae /* The outer transaction should be ending */);
|
|
332
312
|
transactionBranch.editor.exitTransaction();
|
|
333
313
|
|
|
334
314
|
const sourcePath: GraphCommit<TChange>[] = [];
|
|
@@ -147,6 +147,10 @@ export interface ITreeViewConfiguration<
|
|
|
147
147
|
> extends ITreeConfigurationOptions {
|
|
148
148
|
/**
|
|
149
149
|
* The schema which the application wants to view the tree with.
|
|
150
|
+
* @remarks
|
|
151
|
+
* Use {@link SchemaFactory} to construct the schema.
|
|
152
|
+
* Changes to this schema between different versions have important compatibility implications.
|
|
153
|
+
* See the {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution | documentation on schema evolution} for more details.
|
|
150
154
|
*/
|
|
151
155
|
readonly schema: TSchema;
|
|
152
156
|
}
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { TreeIndex } from "../../feature-libraries/index.js";
|
|
9
9
|
import type { TreeNode } from "../core/index.js";
|
|
10
10
|
import { FieldKind, type ImplicitFieldSchema } from "../fieldSchema.js";
|
|
11
11
|
import { ObjectNodeSchema } from "../node-kinds/index.js";
|
|
12
12
|
import { walkFieldSchema } from "../walkFieldSchema.js";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { createTreeIndex, type TreeIndexKey } from "./simpleTreeIndex.js";
|
|
15
15
|
import type { TreeView } from "./tree.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -19,7 +19,7 @@ import type { TreeView } from "./tree.js";
|
|
|
19
19
|
*
|
|
20
20
|
* @alpha
|
|
21
21
|
*/
|
|
22
|
-
export type IdentifierIndex =
|
|
22
|
+
export type IdentifierIndex = TreeIndex<string, TreeNode>;
|
|
23
23
|
|
|
24
24
|
function isStringKey(key: TreeIndexKey): key is string {
|
|
25
25
|
return typeof key === "string";
|
|
@@ -49,7 +49,7 @@ export function createIdentifierIndex<TSchema extends ImplicitFieldSchema>(
|
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
return
|
|
52
|
+
return createTreeIndex(
|
|
53
53
|
view,
|
|
54
54
|
(schemus) => identifierFields.get(schemus.identifier),
|
|
55
55
|
(nodes) => {
|
|
@@ -22,6 +22,7 @@ export type {
|
|
|
22
22
|
TreeBranch,
|
|
23
23
|
TreeBranchAlpha,
|
|
24
24
|
TreeBranchEvents,
|
|
25
|
+
TreeContextAlpha,
|
|
25
26
|
ITreeAlpha,
|
|
26
27
|
} from "./tree.js";
|
|
27
28
|
export { asTreeViewAlpha } from "./tree.js";
|
|
@@ -141,7 +142,7 @@ export {
|
|
|
141
142
|
TreeBeta,
|
|
142
143
|
type TreeChangeEventsBeta,
|
|
143
144
|
} from "./treeBeta.js";
|
|
144
|
-
export {
|
|
145
|
+
export { createTreeIndex, type TreeIndexKey } from "./simpleTreeIndex.js";
|
|
145
146
|
export {
|
|
146
147
|
createIdentifierIndex,
|
|
147
148
|
type IdentifierIndex,
|
|
@@ -164,6 +165,7 @@ export {
|
|
|
164
165
|
type TransactionResultExt,
|
|
165
166
|
type TransactionResultSuccess,
|
|
166
167
|
type TransactionResultFailed,
|
|
168
|
+
type WithValue,
|
|
167
169
|
rollback,
|
|
168
170
|
} from "./transactionTypes.js";
|
|
169
171
|
|
|
@@ -226,12 +226,13 @@ export const SchemaFactory_base = classWithStatics(schemaStaticsPublic);
|
|
|
226
226
|
* @remarks
|
|
227
227
|
* For details related to inputting data constrained by schema (including via assignment), and how non-exact schema types are handled in general refer to {@link Input}.
|
|
228
228
|
* For information about recursive schema support, see methods postfixed with "recursive" and {@link ValidateRecursiveSchema}.
|
|
229
|
-
* To apply schema defined with this factory to a tree, see {@link
|
|
229
|
+
* To apply schema defined with this factory to a tree, see {@link TreeViewConfiguration} and {@link ViewableTree.viewWith}.
|
|
230
|
+
* See the {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution | documentation on schema evolution} for how to handle changes to schema over time.
|
|
230
231
|
*
|
|
231
232
|
* All schema produced by this factory get a {@link TreeNodeSchemaCore.identifier|unique identifier} by combining the {@link SchemaFactory.scope} with the schema's `Name`.
|
|
232
233
|
* The `Name` part may be explicitly provided as a parameter, or inferred as a structural combination of the provided types.
|
|
233
234
|
* The APIs which use this second approach, structural naming, also deduplicate all equivalent calls.
|
|
234
|
-
*
|
|
235
|
+
* Therefore two calls to `array(allowedTypes)` with the same allowedTypes will return the same {@link TreeNodeSchema} instance.
|
|
235
236
|
* On the other hand, two calls to `array(name, allowedTypes)` will always return different {@link TreeNodeSchema} instances
|
|
236
237
|
* and it is an error to use both in the same tree (since their identifiers are not unique).
|
|
237
238
|
*
|