@fluidframework/tree 2.81.1 → 2.83.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 +168 -0
- package/README.md +33 -5
- package/api-report/tree.alpha.api.md +75 -39
- package/api-report/tree.beta.api.md +164 -3
- package/api-report/tree.legacy.beta.api.md +164 -3
- package/api-report/tree.legacy.public.api.md +2 -1
- package/api-report/tree.public.api.md +2 -1
- package/dist/alpha.d.ts +10 -4
- package/dist/beta.d.ts +4 -0
- package/dist/codec/codec.d.ts +18 -45
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +12 -50
- 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 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +20 -7
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +56 -30
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +3 -2
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.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 +4 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +23 -3
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +30 -16
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/formatV1.d.ts +2 -2
- package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
- package/dist/core/schema-stored/formatV1.js +0 -5
- package/dist/core/schema-stored/formatV1.js.map +1 -1
- package/dist/core/schema-stored/formatV2.d.ts +11 -10
- package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
- package/dist/core/schema-stored/formatV2.js +1 -6
- package/dist/core/schema-stored/formatV2.js.map +1 -1
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/delta.d.ts +9 -7
- package/dist/core/tree/delta.d.ts.map +1 -1
- package/dist/core/tree/delta.js.map +1 -1
- package/dist/core/tree/deltaUtil.js +1 -1
- package/dist/core/tree/deltaUtil.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/visitDelta.js +2 -2
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/extensibleUnionNode.d.ts +97 -0
- package/dist/extensibleUnionNode.d.ts.map +1 -0
- package/dist/extensibleUnionNode.js +89 -0
- package/dist/extensibleUnionNode.js.map +1 -0
- package/dist/feature-libraries/changeAtomIdBTree.d.ts +4 -2
- package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.js +9 -1
- package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -4
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +20 -21
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +2 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +7 -1
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +4 -42
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.js +1 -2
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -41
- package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
- package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -41
- package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
- package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.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 -3
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +42 -22
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +2 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +3 -3
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +13 -9
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +30 -7
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +38 -27
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +6 -4
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +4 -4
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.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/replaceRevisions.js +16 -16
- package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- 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.d.ts +36 -13
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +1 -0
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +1 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +10 -0
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +25 -9
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +3 -3
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +8 -32
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +39 -5
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
- package/dist/shared-tree/tree.d.ts +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 +1 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +20 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +41 -7
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js +2 -2
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +2 -2
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +14 -3
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +59 -16
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/versionedSummarizer.js +1 -1
- package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +2 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +4 -3
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
- package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js +16 -1
- package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +10 -0
- 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 +82 -7
- 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/treeBeta.d.ts +1 -1
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +29 -0
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -3
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +47 -14
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/index.js +2 -1
- package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts +1 -1
- package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/index.js +2 -1
- package/dist/simple-tree/node-kinds/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +33 -7
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/dist/tableSchema.d.ts +71 -48
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +200 -98
- package/dist/tableSchema.js.map +1 -1
- package/dist/text/textDomainFormatted.d.ts +3 -3
- package/dist/text/textDomainFormatted.d.ts.map +1 -1
- package/dist/text/textDomainFormatted.js +48 -32
- package/dist/text/textDomainFormatted.js.map +1 -1
- package/dist/util/bTreeUtils.d.ts +30 -4
- package/dist/util/bTreeUtils.d.ts.map +1 -1
- package/dist/util/bTreeUtils.js +35 -23
- package/dist/util/bTreeUtils.js.map +1 -1
- package/dist/util/brand.d.ts.map +1 -1
- package/dist/util/brand.js.map +1 -1
- package/dist/util/brandedMap.d.ts.map +1 -1
- package/dist/util/brandedMap.js.map +1 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +2 -1
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +6 -3
- package/dist/util/index.js.map +1 -1
- package/dist/util/opaque.d.ts.map +1 -1
- package/dist/util/opaque.js.map +1 -1
- package/dist/util/rangeMap.d.ts +3 -2
- package/dist/util/rangeMap.d.ts.map +1 -1
- package/dist/util/rangeMap.js +12 -7
- package/dist/util/rangeMap.js.map +1 -1
- package/dist/util/readSnapshotBlob.d.ts +1 -1
- package/dist/util/readSnapshotBlob.d.ts.map +1 -1
- package/dist/util/readSnapshotBlob.js.map +1 -1
- package/dist/util/typeCheck.d.ts.map +1 -1
- package/dist/util/typeCheck.js.map +1 -1
- package/dist/util/utils.d.ts +20 -16
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +49 -17
- package/dist/util/utils.js.map +1 -1
- package/eslint.config.mts +0 -9
- package/lib/alpha.d.ts +10 -4
- package/lib/beta.d.ts +4 -0
- package/lib/codec/codec.d.ts +18 -45
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +10 -47
- 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 +20 -7
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +59 -33
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +3 -2
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.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 +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +23 -3
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +27 -15
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/formatV1.d.ts +2 -2
- package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
- package/lib/core/schema-stored/formatV1.js +0 -5
- package/lib/core/schema-stored/formatV1.js.map +1 -1
- package/lib/core/schema-stored/formatV2.d.ts +11 -10
- package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
- package/lib/core/schema-stored/formatV2.js +1 -6
- package/lib/core/schema-stored/formatV2.js.map +1 -1
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js +2 -0
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/delta.d.ts +9 -7
- package/lib/core/tree/delta.d.ts.map +1 -1
- package/lib/core/tree/delta.js.map +1 -1
- package/lib/core/tree/deltaUtil.js +1 -1
- package/lib/core/tree/deltaUtil.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/visitDelta.js +2 -2
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/extensibleUnionNode.d.ts +97 -0
- package/lib/extensibleUnionNode.d.ts.map +1 -0
- package/lib/extensibleUnionNode.js +86 -0
- package/lib/extensibleUnionNode.js.map +1 -0
- package/lib/feature-libraries/changeAtomIdBTree.d.ts +4 -2
- package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.js +7 -0
- package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +5 -5
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -3
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +4 -5
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +2 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +8 -2
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -3
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +4 -42
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.js +2 -3
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -41
- package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
- package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -41
- package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
- package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.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 +3 -3
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +41 -21
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +3 -3
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +14 -10
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +11 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +29 -6
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +41 -30
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +10 -127
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -4
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +3 -79
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +6 -4
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +4 -4
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +2 -2
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -16
- package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- 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.d.ts +36 -13
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +1 -0
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +1 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +10 -0
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +25 -9
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +3 -3
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +10 -34
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +11 -3
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +40 -6
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFormat.d.ts +4 -4
- package/lib/shared-tree/tree.d.ts +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 +1 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +20 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +41 -7
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js +2 -2
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +2 -2
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +14 -3
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +61 -18
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/versionedSummarizer.js +1 -1
- package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +2 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -2
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts +9 -0
- package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCreationUtilities.js +14 -0
- package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +10 -0
- 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 +82 -7
- 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/treeBeta.d.ts +1 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -0
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +29 -0
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +63 -0
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +46 -14
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/index.js +1 -1
- package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts +1 -1
- package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/index.js +1 -1
- package/lib/simple-tree/node-kinds/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +34 -8
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/tableSchema.d.ts +71 -48
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +201 -99
- package/lib/tableSchema.js.map +1 -1
- package/lib/text/textDomainFormatted.d.ts +3 -3
- package/lib/text/textDomainFormatted.d.ts.map +1 -1
- package/lib/text/textDomainFormatted.js +30 -14
- package/lib/text/textDomainFormatted.js.map +1 -1
- package/lib/util/bTreeUtils.d.ts +30 -4
- package/lib/util/bTreeUtils.d.ts.map +1 -1
- package/lib/util/bTreeUtils.js +33 -22
- package/lib/util/bTreeUtils.js.map +1 -1
- package/lib/util/brand.d.ts.map +1 -1
- package/lib/util/brand.js.map +1 -1
- package/lib/util/brandedMap.d.ts.map +1 -1
- package/lib/util/brandedMap.js.map +1 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +2 -1
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/opaque.d.ts.map +1 -1
- package/lib/util/opaque.js.map +1 -1
- package/lib/util/rangeMap.d.ts +3 -2
- package/lib/util/rangeMap.d.ts.map +1 -1
- package/lib/util/rangeMap.js +12 -7
- package/lib/util/rangeMap.js.map +1 -1
- package/lib/util/readSnapshotBlob.d.ts +1 -1
- package/lib/util/readSnapshotBlob.d.ts.map +1 -1
- package/lib/util/readSnapshotBlob.js.map +1 -1
- package/lib/util/typeCheck.d.ts.map +1 -1
- package/lib/util/typeCheck.js.map +1 -1
- package/lib/util/utils.d.ts +20 -16
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +44 -15
- package/lib/util/utils.js.map +1 -1
- package/package.json +24 -24
- package/src/codec/codec.ts +33 -116
- package/src/codec/index.ts +2 -3
- package/src/codec/versioned/codec.ts +127 -95
- package/src/core/index.ts +3 -1
- package/src/core/rebase/changeRebaser.ts +3 -2
- package/src/core/rebase/index.ts +3 -1
- package/src/core/rebase/types.ts +51 -13
- package/src/core/schema-stored/formatV1.ts +2 -4
- package/src/core/schema-stored/formatV2.ts +9 -7
- package/src/core/schema-stored/index.ts +2 -0
- package/src/core/schema-stored/schema.ts +4 -1
- package/src/core/tree/anchorSet.ts +1 -3
- package/src/core/tree/delta.ts +9 -7
- package/src/core/tree/deltaUtil.ts +1 -1
- package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
- package/src/core/tree/visitDelta.ts +2 -2
- package/src/extensibleUnionNode.ts +177 -0
- package/src/feature-libraries/changeAtomIdBTree.ts +17 -2
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +5 -6
- package/src/feature-libraries/default-schema/index.ts +0 -1
- package/src/feature-libraries/forest-summary/codec.ts +15 -9
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +15 -3
- package/src/feature-libraries/forest-summary/formatCommon.ts +7 -6
- package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
- package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +4 -5
- package/src/feature-libraries/index.ts +3 -2
- package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +57 -31
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -1
- package/src/feature-libraries/modular-schema/index.ts +4 -1
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +12 -12
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +32 -7
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +54 -33
- package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -4
- package/src/feature-libraries/optional-field/optionalField.ts +1 -1
- package/src/feature-libraries/optional-field/requiredField.ts +2 -4
- package/src/feature-libraries/schema-index/codec.ts +7 -5
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -1
- package/src/feature-libraries/sequence-field/invert.ts +2 -2
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +17 -10
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +1 -1
- package/src/index.ts +14 -9
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +42 -6
- package/src/shared-tree/index.ts +2 -0
- package/src/shared-tree/schematizingTreeView.ts +63 -18
- package/src/shared-tree/sharedTree.ts +19 -37
- package/src/shared-tree/sharedTreeChangeCodecs.ts +45 -11
- package/src/shared-tree/tree.ts +2 -2
- package/src/shared-tree/treeAlpha.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +52 -7
- package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
- package/src/shared-tree-core/editManagerSummarizer.ts +1 -1
- package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -3
- package/src/shared-tree-core/messageCodecs.ts +2 -6
- package/src/shared-tree-core/transaction.ts +125 -23
- package/src/shared-tree-core/versionedSummarizer.ts +3 -2
- package/src/simple-tree/api/index.ts +3 -2
- package/src/simple-tree/api/schemaCreationUtilities.ts +35 -5
- package/src/simple-tree/api/simpleTreeIndex.ts +1 -1
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
- package/src/simple-tree/api/transactionTypes.ts +10 -0
- package/src/simple-tree/api/tree.ts +89 -7
- package/src/simple-tree/api/treeBeta.ts +1 -1
- package/src/simple-tree/core/allowedTypes.ts +1 -1
- package/src/simple-tree/core/treeNodeSchema.ts +5 -8
- package/src/simple-tree/core/unhydratedFlexTree.ts +43 -1
- package/src/simple-tree/index.ts +5 -2
- package/src/simple-tree/leafNodeSchema.ts +3 -2
- package/src/simple-tree/node-kinds/array/arrayNode.ts +99 -19
- package/src/simple-tree/node-kinds/array/index.ts +2 -0
- package/src/simple-tree/node-kinds/index.ts +2 -0
- package/src/simple-tree/node-kinds/object/objectNode.ts +19 -18
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +51 -10
- package/src/tableSchema.ts +280 -140
- package/src/text/textDomainFormatted.ts +37 -17
- package/src/util/bTreeUtils.ts +55 -32
- package/src/util/brand.ts +4 -12
- package/src/util/brandedMap.ts +2 -6
- package/src/util/breakable.ts +3 -2
- package/src/util/index.ts +9 -3
- package/src/util/opaque.ts +2 -6
- package/src/util/rangeMap.ts +20 -11
- package/src/util/readSnapshotBlob.ts +3 -3
- package/src/util/typeCheck.ts +11 -9
- package/src/util/utils.ts +57 -28
- package/api-extractor-lint.json +0 -4
- package/biome.jsonc +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editManagerCodecsVSharedBranches.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerCodecsVSharedBranches.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,
|
|
1
|
+
{"version":3,"file":"editManagerCodecsVSharedBranches.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerCodecsVSharedBranches.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,gDAA8F;AAO9F,+CAI0B;AAI1B,+EAAuF;AAEvF,+FAA2E;AAO3E,SAAgB,kCAAkC,CACjD,WAKC,EACD,gBAKC,EACD,OAAsB,EACtB,OAAkD;IAOlD,MAAM,MAAM,GAAG,IAAA,wDAAkB,EAAC,WAAW,CAAC,aAAa,IAAI,uCAA4B,CAAC,CAAC;IAE7F,MAAM,KAAK,GAKP,IAAA,+BAAoB,EACvB,MAAM,EACN;QACC,MAAM,EAAE,CAAC,IAA6B,EAAE,OAAmC,EAAE,EAAE;YAC9E,MAAM,UAAU,GAAG,IAAA,gDAAkB,EACpC,WAAW,EACX,gBAAgB,EAChB,IAAI,CAAC,IAAI,EACT,OAAO,EACP,IAAI,CAAC,UAAU,CACf,CAAC;YACF,IAAA,iBAAM,EACL,IAAI,CAAC,UAAU,KAAK,SAAS,EAC7B,KAAK,CAAC,8DAA8D,CACpE,CAAC;YACF,MAAM,IAAI,GAA4C;gBACrD,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,OAAO;aACP,CAAC;YACF,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC3D,MAAM,QAAQ,GAAsC,EAAE,CAAC;gBACvD,KAAK,MAAM,CAAC,CAAC,EAA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D,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;IACF,2JAA2J;IAC3J,+DAA+D;IAC/D,mDAAmD;IACnD,OAAO,KAKN,CAAC;AACH,CAAC;AApHD,gFAoHC","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 { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlySchema,\n\ttype Mutable,\n} from \"../util/index.js\";\n\nimport type { BranchId } from \"./branch.js\";\nimport type { SharedBranchSummaryData, SummaryData } from \"./editManager.js\";\nimport { decodeSharedBranch, encodeSharedBranch } from \"./editManagerCodecsCommons.js\";\nimport type { EncodedSharedBranch } from \"./editManagerFormatCommons.js\";\nimport { EncodedEditManager } from \"./editManagerFormatVSharedBranches.js\";\n\nexport interface EditManagerEncodingContext {\n\tidCompressor: IIdCompressor;\n\treadonly schema?: SchemaAndPolicy;\n}\n\nexport function makeSharedBranchesCodecWithVersion<TChangeset>(\n\tchangeCodec: IJsonCodec<\n\t\tTChangeset,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tChangeEncodingContext\n\t>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion: EncodedEditManager<TChangeset>[\"version\"],\n): IJsonCodec<\n\tSummaryData<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tEditManagerEncodingContext\n> {\n\tconst format = EncodedEditManager(changeCodec.encodedSchema ?? JsonCompatibleReadOnlySchema);\n\n\tconst codec: IJsonCodec<\n\t\tSummaryData<TChangeset>,\n\t\tEncodedEditManager<TChangeset>,\n\t\tEncodedEditManager<TChangeset>,\n\t\tEditManagerEncodingContext\n\t> = withSchemaValidation(\n\t\tformat,\n\t\t{\n\t\t\tencode: (data: SummaryData<TChangeset>, context: EditManagerEncodingContext) => {\n\t\t\t\tconst mainBranch = encodeSharedBranch(\n\t\t\t\t\tchangeCodec,\n\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\tdata.main,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdata.originator,\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tdata.originator !== undefined,\n\t\t\t\t\t0xca5 /* Cannot encode vSharedBranches summary without originator */,\n\t\t\t\t);\n\t\t\t\tconst json: Mutable<EncodedEditManager<TChangeset>> = {\n\t\t\t\t\tmain: mainBranch,\n\t\t\t\t\toriginator: data.originator,\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\tif (data.branches !== undefined && data.branches.size > 0) {\n\t\t\t\t\tconst branches: EncodedSharedBranch<TChangeset>[] = [];\n\t\t\t\t\tfor (const [_, branch] of data.branches) {\n\t\t\t\t\t\tbranches.push(\n\t\t\t\t\t\t\tencodeSharedBranch(\n\t\t\t\t\t\t\t\tchangeCodec,\n\t\t\t\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tdata.originator,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tjson.branches = branches;\n\t\t\t\t}\n\t\t\t\treturn json;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tjson: EncodedEditManager<TChangeset>,\n\t\t\t\tcontext: EditManagerEncodingContext,\n\t\t\t): SummaryData<TChangeset> => {\n\t\t\t\tconst mainBranch = decodeSharedBranch(\n\t\t\t\t\tchangeCodec,\n\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\tjson.main,\n\t\t\t\t\tcontext,\n\t\t\t\t\tjson.originator,\n\t\t\t\t);\n\n\t\t\t\tconst decoded: Mutable<SummaryData<TChangeset>> = {\n\t\t\t\t\tmain: mainBranch,\n\t\t\t\t\toriginator: json.originator,\n\t\t\t\t};\n\n\t\t\t\tif (json.branches !== undefined) {\n\t\t\t\t\tconst branches = new Map<BranchId, SharedBranchSummaryData<TChangeset>>();\n\t\t\t\t\tfor (const branch of json.branches) {\n\t\t\t\t\t\tconst decodedBranch = decodeSharedBranch(\n\t\t\t\t\t\t\tchangeCodec,\n\t\t\t\t\t\t\trevisionTagCodec,\n\t\t\t\t\t\t\tbranch,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tjson.originator,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tdecodedBranch.id !== undefined,\n\t\t\t\t\t\t\t0xc66 /* Shared branches must have an id */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(!branches.has(decodedBranch.id), 0xc67 /* Duplicate shared branch id */);\n\t\t\t\t\t\tbranches.set(decodedBranch.id, decodedBranch);\n\t\t\t\t\t}\n\n\t\t\t\t\tdecoded.branches = branches;\n\t\t\t\t}\n\t\t\t\treturn decoded;\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n\t// TODO: makeVersionedValidatedCodec and withSchemaValidation should allow the codec to decode JsonCompatibleReadOnly, or Versioned or something like that,\n\t// and not leak the internal encoded format in the API surface.\n\t// Fixing that would remove the need for this cast.\n\treturn codec as unknown as IJsonCodec<\n\t\tSummaryData<TChangeset>,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tEditManagerEncodingContext\n\t>;\n}\n"]}
|
|
@@ -64,7 +64,7 @@ class EditManagerSummarizer extends versionedSummarizer_js_1.VersionedSummarizer
|
|
|
64
64
|
// This detects any data that could have been accidentally added through
|
|
65
65
|
// invalid means and is about to be overwritten.
|
|
66
66
|
(0, internal_1.assert)(this.editManager.isEmpty(), 0x42c /* There should not already be stored EditManager data when loading from summary */);
|
|
67
|
-
const summary = parse((0, client_utils_1.bufferToString)(schemaBuffer, "
|
|
67
|
+
const summary = parse((0, client_utils_1.bufferToString)(schemaBuffer, "utf8"));
|
|
68
68
|
const data = this.codec.decode(summary, { idCompressor: this.idCompressor });
|
|
69
69
|
this.editManager.loadSummaryData(data);
|
|
70
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editManagerSummarizer.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAqB7D,qEAA+D;AAElD,QAAA,SAAS,GAAG,QAAQ,CAAC;AAElC;;GAEG;AACH,IAAkB,+BAajB;AAbD,WAAkB,+BAA+B;IAChD;;OAEG;IACH,iFAAM,CAAA;IACN;;OAEG;IACH,iFAAM,CAAA;IACN;;OAEG;IACH,2FAAY,CAAA;AACb,CAAC,EAbiB,+BAA+B,+CAA/B,+BAA+B,QAahD;AAED,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAkC;;;CAGlE,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,2CAA2C,CACnD,OAAgC;IAEhC,2EAA2E;IAC3E,kDAA0C;AAC3C,CAAC;AAED;;GAEG;AACH,MAAa,qBACZ,SAAQ,4CAAoD;IAI5D,YACkB,WAIhB,EACgB,KAKhB,EACgB,YAA2B,EAC5C,mBAA4C,EAC3B,eAAiC;QAElD,KAAK,CACJ,qBAAqB,CAAC,GAAG,EACzB,2CAA2C,CAAC,mBAAmB,CAAC,EAChE,iBAAiB,EACjB,IAAI,CAAC,gCAAgC,CACrC,CAAC;QApBe,gBAAW,GAAX,WAAW,CAI3B;QACgB,UAAK,GAAL,KAAK,CAKrB;QACgB,iBAAY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,CAAC,YAAY,CAC3B,QAAgC,EAChC,KAA2B;QAE3B,MAAM,YAAY,GAAoB,MAAM,QAAQ,CAAC,QAAQ,CAAC,iBAAS,CAAC,CAAC;QAEzE,gEAAgE;QAChE,wEAAwE;QACxE,gDAAgD;QAChD,IAAA,iBAAM,EACL,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAC1B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,MAAM,OAAO,GAAG,KAAK,CAAC,IAAA,6BAAc,EAAC,YAAY,EAAE,MAAM,CAAC,CAA2B,CAAC;QACtF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;;AAhEF,sDAiEC;AA7DuB,yBAAG,GAAG,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { IJsonCodec } from \"../codec/index.js\";\nimport type { ChangeFamily, ChangeFamilyEditor, SchemaAndPolicy } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport type { EditManager, SummaryData } from \"./editManager.js\";\nimport type { EditManagerEncodingContext } from \"./editManagerCodecs.js\";\nimport type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"./summaryTypes.js\";\nimport { VersionedSummarizer } from \"./versionedSummarizer.js\";\n\nexport const stringKey = \"String\";\n\n/**\n * The versions for the edit manager summary format.\n */\nexport const enum EditManagerSummaryFormatVersion {\n\t/**\n\t * This version represents summary format before summary versioning was introduced.\n\t */\n\tv1 = 1,\n\t/**\n\t * This version adds metadata to the summary. This is backward compatible with version 1.\n\t */\n\tv2 = 2,\n\t/**\n\t * The latest version of the summary. Must be updated when a new version is added.\n\t */\n\tvLatest = v2,\n}\n\nconst supportedVersions = new Set<EditManagerSummaryFormatVersion>([\n\tEditManagerSummaryFormatVersion.v1,\n\tEditManagerSummaryFormatVersion.v2,\n]);\n\n/**\n * Returns the summary version to use as per the given minimum version for collab.\n */\nfunction minVersionToEditManagerSummaryFormatVersion(\n\tversion: MinimumVersionForCollab,\n): EditManagerSummaryFormatVersion {\n\t// Currently, version 2 is written which adds metadata blob to the summary.\n\treturn EditManagerSummaryFormatVersion.v2;\n}\n\n/**\n * Provides methods for summarizing and loading an `EditManager`\n */\nexport class EditManagerSummarizer<TChangeset>\n\textends VersionedSummarizer<EditManagerSummaryFormatVersion>\n\timplements Summarizable\n{\n\tpublic static readonly key = \"EditManager\";\n\tpublic constructor(\n\t\tprivate readonly editManager: EditManager<\n\t\t\tChangeFamilyEditor,\n\t\t\tTChangeset,\n\t\t\tChangeFamily<ChangeFamilyEditor, TChangeset>\n\t\t>,\n\t\tprivate readonly codec: IJsonCodec<\n\t\t\tSummaryData<TChangeset>,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tEditManagerEncodingContext\n\t\t>,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t\tprivate readonly schemaAndPolicy?: SchemaAndPolicy,\n\t) {\n\t\tsuper(\n\t\t\tEditManagerSummarizer.key,\n\t\t\tminVersionToEditManagerSummaryFormatVersion(minVersionForCollab),\n\t\t\tsupportedVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\t}\n\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { stringify, builder } = props;\n\t\tconst context: EditManagerEncodingContext =\n\t\t\tthis.schemaAndPolicy === undefined\n\t\t\t\t? { idCompressor: this.idCompressor }\n\t\t\t\t: { schema: this.schemaAndPolicy, idCompressor: this.idCompressor };\n\t\tconst jsonCompatible = this.codec.encode(this.editManager.getSummaryData(), context);\n\t\tconst dataString = stringify(jsonCompatible);\n\t\tbuilder.addBlob(stringKey, dataString);\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tconst schemaBuffer: ArrayBufferLike = await services.readBlob(stringKey);\n\n\t\t// After the awaits, validate that the data is in a clean state.\n\t\t// This detects any data that could have been accidentally added through\n\t\t// invalid means and is about to be overwritten.\n\t\tassert(\n\t\t\tthis.editManager.isEmpty(),\n\t\t\t0x42c /* There should not already be stored EditManager data when loading from summary */,\n\t\t);\n\n\t\tconst summary = parse(bufferToString(schemaBuffer, \"utf8\")) as JsonCompatibleReadOnly;\n\t\tconst data = this.codec.decode(summary, { idCompressor: this.idCompressor });\n\t\tthis.editManager.loadSummaryData(data);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageCodecV1ToV4.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"messageCodecV1ToV4.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,wBAAgB,0BAA0B,CAAC,UAAU,EACpD,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAC1C,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,OAAO,EAAE,aAAa,EACtB,OAAO,EACJ,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC9B,OAAO,oBAAoB,CAAC,EAAE,GAC/B,UAAU,CACZ,cAAc,CAAC,UAAU,CAAC,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,CACtB,CAmEA"}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.makeV1ToV4CodecWithVersion = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
-
const typebox_1 = require("@sinclair/typebox");
|
|
10
9
|
const index_js_1 = require("../codec/index.js");
|
|
10
|
+
const index_js_2 = require("../util/index.js");
|
|
11
11
|
const messageFormatV1ToV4_js_1 = require("./messageFormatV1ToV4.js");
|
|
12
12
|
function makeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version) {
|
|
13
|
-
return (0, index_js_1.withSchemaValidation)((0, messageFormatV1ToV4_js_1.Message)(changeCodec.encodedSchema ??
|
|
13
|
+
return (0, index_js_1.withSchemaValidation)((0, messageFormatV1ToV4_js_1.Message)(changeCodec.encodedSchema ?? index_js_2.JsonCompatibleReadOnlySchema), {
|
|
14
14
|
encode: (decoded, context) => {
|
|
15
15
|
(0, internal_1.assert)(decoded.type === "commit", 0xc68 /* Only commit messages are supported */);
|
|
16
16
|
(0, internal_1.assert)(decoded.branchId === "main", 0xc69 /* Only commit messages to main are supported */);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageCodecV1ToV4.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;
|
|
1
|
+
{"version":3,"file":"messageCodecV1ToV4.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecV1ToV4.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,gDAA8F;AAQ9F,+CAAgE;AAIhE,qEAAmD;AAGnD,SAAgB,0BAA0B,CACzC,WAA0C,EAC1C,gBAKC,EACD,OAAsB,EACtB,OAKiC;IAOjC,OAAO,IAAA,+BAAoB,EAO1B,IAAA,gCAAO,EAAC,WAAW,CAAC,aAAa,IAAI,uCAA4B,CAAC,EAClE;QACC,MAAM,EAAE,CAAC,OAAmC,EAAE,OAA+B,EAAE,EAAE;YAChF,IAAA,iBAAM,EAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,KAAK,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AAC;KACD,EACD,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC;AAvFD,gEAuFC","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 { TAnySchema } from \"@sinclair/typebox\";\n\nimport { type ICodecOptions, type IJsonCodec, withSchemaValidation } from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangeFamilyCodec,\n\tEncodedRevisionTag,\n\tRevisionTag,\n} from \"../core/index.js\";\nimport type { JsonCompatibleReadOnly } from \"../util/index.js\";\nimport { JsonCompatibleReadOnlySchema } from \"../util/index.js\";\n\nimport type { MessageEncodingContext } from \"./messageCodecs.js\";\nimport type { MessageFormatVersion } from \"./messageFormat.js\";\nimport { Message } from \"./messageFormatV1ToV4.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\n\nexport function makeV1ToV4CodecWithVersion<TChangeset>(\n\tchangeCodec: ChangeFamilyCodec<TChangeset>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n\tversion:\n\t\t| typeof MessageFormatVersion.v1\n\t\t| typeof MessageFormatVersion.v2\n\t\t| typeof MessageFormatVersion.v3\n\t\t| typeof MessageFormatVersion.v4\n\t\t| typeof MessageFormatVersion.v6,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\treturn withSchemaValidation<\n\t\tDecodedMessage<TChangeset>,\n\t\tTAnySchema | typeof JsonCompatibleReadOnlySchema,\n\t\tJsonCompatibleReadOnly,\n\t\tJsonCompatibleReadOnly,\n\t\tMessageEncodingContext\n\t>(\n\t\tMessage(changeCodec.encodedSchema ?? JsonCompatibleReadOnlySchema),\n\t\t{\n\t\t\tencode: (decoded: DecodedMessage<TChangeset>, context: MessageEncodingContext) => {\n\t\t\t\tassert(decoded.type === \"commit\", 0xc68 /* Only commit messages are supported */);\n\t\t\t\tassert(\n\t\t\t\t\tdecoded.branchId === \"main\",\n\t\t\t\t\t0xc69 /* Only commit messages to main are supported */,\n\t\t\t\t);\n\t\t\t\tconst { commit, sessionId: originatorId } = decoded;\n\t\t\t\tconst message: Message = {\n\t\t\t\t\trevision: revisionTagCodec.encode(commit.revision, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: undefined,\n\t\t\t\t\t}),\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset: changeCodec.encode(commit.change, {\n\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\trevision: commit.revision,\n\t\t\t\t\t}),\n\t\t\t\t\tversion,\n\t\t\t\t};\n\t\t\t\treturn message as unknown as JsonCompatibleReadOnly;\n\t\t\t},\n\t\t\tdecode: (\n\t\t\t\tencoded: JsonCompatibleReadOnly,\n\t\t\t\tcontext: MessageEncodingContext,\n\t\t\t): DecodedMessage<TChangeset> => {\n\t\t\t\tconst {\n\t\t\t\t\trevision: encodedRevision,\n\t\t\t\t\toriginatorId,\n\t\t\t\t\tchangeset,\n\t\t\t\t} = encoded as unknown as Message;\n\n\t\t\t\tconst revision = revisionTagCodec.decode(encodedRevision, {\n\t\t\t\t\toriginatorId,\n\t\t\t\t\trevision: undefined,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tbranchId: \"main\",\n\t\t\t\t\ttype: \"commit\",\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tchange: changeCodec.decode(changeset, {\n\t\t\t\t\t\t\toriginatorId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tsessionId: originatorId,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toptions.jsonValidator,\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageCodecs.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAG3B,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAkB,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI/E,OAAO,EAAE,oBAAoB,EAAyB,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACtC,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE,eAAe,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAClD,aAAa,EAAE,uBAAuB,EACtC,oBAAoB,CAAC,EAAE,oBAAoB,GACzC,oBAAoB,CAStB;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAChC,mBAAmB,EAAE,uBAAuB,KACxC,oBAAoB,CAAC;CAC1B;AASD;;GAEG;AACH,wBAAgB,6CAA6C,CAC5D,aAAa,EAAE,uBAAuB,GACpC,oBAA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AsB,CAAC,CA8ClE;AAED,wBAAgB,sCAAsC,CACrD,aAAa,EAAE,uBAAuB,EACtC,YAAY,EAAE,SAAS,GACrB,SAAS,CAMX"}
|
|
@@ -61,7 +61,7 @@ function makeMessageCodecs(changeCodecs, dependentChangeFormatVersion, revisionT
|
|
|
61
61
|
case (0, index_js_2.unbrand)(messageFormat_js_1.MessageFormatVersion.v3):
|
|
62
62
|
case (0, index_js_2.unbrand)(messageFormat_js_1.MessageFormatVersion.v4):
|
|
63
63
|
case (0, index_js_2.unbrand)(messageFormat_js_1.MessageFormatVersion.v6): {
|
|
64
|
-
const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version))
|
|
64
|
+
const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
|
|
65
65
|
return [
|
|
66
66
|
version,
|
|
67
67
|
(0, messageCodecV1ToV4_js_1.makeV1ToV4CodecWithVersion)(changeCodec, revisionTagCodec, options, version),
|
|
@@ -71,7 +71,7 @@ function makeMessageCodecs(changeCodecs, dependentChangeFormatVersion, revisionT
|
|
|
71
71
|
return [version, (0, index_js_1.makeDiscontinuedCodecVersion)(options, version, "2.74.0")];
|
|
72
72
|
}
|
|
73
73
|
case (0, index_js_2.unbrand)(messageFormat_js_1.MessageFormatVersion.vSharedBranches): {
|
|
74
|
-
const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version))
|
|
74
|
+
const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
|
|
75
75
|
return [
|
|
76
76
|
version,
|
|
77
77
|
(0, messageCodecVSharedBranches_js_1.makeSharedBranchesCodecWithVersion)(changeCodec, revisionTagCodec, options, version),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageCodecs.js","sourceRoot":"","sources":["../../src/shared-tree-core/messageCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsE;AAGtE,qEAGgD;AAEhD,gDAY2B;AAO3B,+CAA+E;AAE/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;YACH,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,IAAA,0BAAe,EAAC,QAAQ,CAAC,CAAC;AAClC,CAAC;AAxDD,8CAwDC;AAED,SAAgB,sCAAsC,CACrD,aAAsC,EACtC,YAAuB;IAEvB,OAAO;QACN,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,mCAAmC,CAAC,aAAa,CAAC;QAC3D,QAAQ,EAAE,CAAC,YAAY,CAAC;KACxB,CAAC;AACH,CAAC;AATD,wFASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\ttype DependentFormatVersion,\n\tFluidClientVersion,\n\ttype FormatVersion,\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeDiscontinuedCodecVersion,\n\tmakeVersionDispatchingCodec,\n} from \"../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tEncodedRevisionTag,\n\tRevisionTag,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport { brand, unbrand, type JsonCompatibleReadOnly } from \"../util/index.js\";\n\nimport { makeV1ToV4CodecWithVersion } from \"./messageCodecV1ToV4.js\";\nimport { makeSharedBranchesCodecWithVersion } from \"./messageCodecVSharedBranches.js\";\nimport { MessageFormatVersion, messageFormatVersions } from \"./messageFormat.js\";\nimport type { DecodedMessage } from \"./messageTypes.js\";\n\nexport interface MessageEncodingContext {\n\tidCompressor: IIdCompressor;\n\tschema?: SchemaAndPolicy;\n}\n\n/**\n * Convert a MinimumVersionForCollab to a MessageFormatVersion.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The MessageFormatVersion that corresponds to the provided MinimumVersionForCollab.\n */\nexport function clientVersionToMessageFormatVersion(\n\tclientVersion: MinimumVersionForCollab,\n\twriteVersionOverride?: MessageFormatVersion,\n): MessageFormatVersion {\n\tconst compatibleVersion: MessageFormatVersion = brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: MessageFormatVersion.v3,\n\t\t\t[FluidClientVersion.v2_43]: MessageFormatVersion.v4,\n\t\t\t[FluidClientVersion.v2_80]: MessageFormatVersion.v6,\n\t\t}),\n\t);\n\treturn writeVersionOverride ?? compatibleVersion;\n}\n\nexport interface MessageCodecOptions {\n\treadonly messageFormatSelector?: (\n\t\tminVersionForCollab: MinimumVersionForCollab,\n\t) => MessageFormatVersion;\n}\n\nfunction messageFormatVersionFromOptions(\n\toptions: MessageCodecOptions & CodecWriteOptions,\n): MessageFormatVersion {\n\tconst selector = options.messageFormatSelector ?? clientVersionToMessageFormatVersion;\n\treturn selector(options.minVersionForCollab);\n}\n\n/**\n * Returns the version that should be used for testing shared branches.\n */\nexport function messageFormatVersionSelectorForSharedBranches(\n\tclientVersion: MinimumVersionForCollab,\n): MessageFormatVersion {\n\treturn brand(MessageFormatVersion.vSharedBranches);\n}\n\nexport function makeMessageCodec<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\tdependentChangeFormatVersion: DependentFormatVersion<MessageFormatVersion>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: MessageCodecOptions & CodecWriteOptions,\n): IJsonCodec<\n\tDecodedMessage<TChangeset>,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tMessageEncodingContext\n> {\n\tconst family = makeMessageCodecs(\n\t\tchangeCodecs,\n\t\tdependentChangeFormatVersion,\n\t\trevisionTagCodec,\n\t\toptions,\n\t);\n\tconst writeVersion = messageFormatVersionFromOptions(options);\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\n/**\n * @privateRemarks Exported for testing.\n */\nexport function makeMessageCodecs<TChangeset>(\n\tchangeCodecs: ICodecFamily<TChangeset, ChangeEncodingContext>,\n\tdependentChangeFormatVersion: DependentFormatVersion<MessageFormatVersion>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\toptions: ICodecOptions,\n): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {\n\tconst registry: [\n\t\tFormatVersion,\n\t\tIJsonCodec<\n\t\t\tDecodedMessage<TChangeset>,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tJsonCompatibleReadOnly,\n\t\t\tMessageEncodingContext\n\t\t>,\n\t][] = [...messageFormatVersions].map((version) => {\n\t\tswitch (version) {\n\t\t\tcase unbrand(MessageFormatVersion.undefined):\n\t\t\tcase unbrand(MessageFormatVersion.v1):\n\t\t\tcase unbrand(MessageFormatVersion.v2): {\n\t\t\t\tconst versionOrUndefined =\n\t\t\t\t\tversion === unbrand(MessageFormatVersion.undefined) ? undefined : version;\n\t\t\t\treturn [\n\t\t\t\t\tversionOrUndefined,\n\t\t\t\t\tmakeDiscontinuedCodecVersion(options, versionOrUndefined, \"2.73.0\"),\n\t\t\t\t];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.v3):\n\t\t\tcase unbrand(MessageFormatVersion.v4):\n\t\t\tcase unbrand(MessageFormatVersion.v6): {\n\t\t\t\tconst changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));\n\t\t\t\treturn [\n\t\t\t\t\tversion,\n\t\t\t\t\tmakeV1ToV4CodecWithVersion(changeCodec, revisionTagCodec, options, version),\n\t\t\t\t];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.v5): {\n\t\t\t\treturn [version, makeDiscontinuedCodecVersion(options, version, \"2.74.0\")];\n\t\t\t}\n\t\t\tcase unbrand(MessageFormatVersion.vSharedBranches): {\n\t\t\t\tconst changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));\n\t\t\t\treturn [\n\t\t\t\t\tversion,\n\t\t\t\t\tmakeSharedBranchesCodecWithVersion(changeCodec, revisionTagCodec, options, version),\n\t\t\t\t];\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(version);\n\t\t\t}\n\t\t}\n\t});\n\treturn makeCodecFamily(registry);\n}\n\nexport function getCodecTreeForMessageFormatWithChange(\n\tclientVersion: MinimumVersionForCollab,\n\tchangeFormat: CodecTree,\n): CodecTree {\n\treturn {\n\t\tname: \"Message\",\n\t\tversion: clientVersionToMessageFormatVersion(clientVersion),\n\t\tchildren: [changeFormat],\n\t};\n}\n"]}
|
|
@@ -27,6 +27,8 @@ export interface Transactor {
|
|
|
27
27
|
* Start a new transaction.
|
|
28
28
|
* If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
|
|
29
29
|
* i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
|
|
30
|
+
* @param isAsync - Whether the transaction is asynchronous.
|
|
31
|
+
* An error will be thrown if an asynchronous transaction is started while a synchronous transaction is in progress.
|
|
30
32
|
*
|
|
31
33
|
* @remarks Asynchronous transactions are not supported on the root checkout,
|
|
32
34
|
* since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate
|
|
@@ -40,7 +42,7 @@ export interface Transactor {
|
|
|
40
42
|
* @privateRemarks There is currently no enforcement that asynchronous transactions don't happen on the root checkout.
|
|
41
43
|
* AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.
|
|
42
44
|
*/
|
|
43
|
-
start(): void;
|
|
45
|
+
start(isAsync: boolean): void;
|
|
44
46
|
/**
|
|
45
47
|
* Close this transaction by squashing its edits and committing them as a single edit.
|
|
46
48
|
* If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
|
|
@@ -120,12 +122,21 @@ export declare class TransactionStack implements Transactor, IDisposable {
|
|
|
120
122
|
*/
|
|
121
123
|
constructor(onPush?: OnPush);
|
|
122
124
|
isInProgress(): boolean;
|
|
123
|
-
start(): void;
|
|
125
|
+
start(isAsync: boolean): void;
|
|
124
126
|
commit(): void;
|
|
125
127
|
abort(): void;
|
|
126
128
|
dispose(): void;
|
|
127
129
|
private ensureNotDisposed;
|
|
128
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* A function that will be called when a transaction is popped from the {@link SquashingTransactionStack | stack}.
|
|
133
|
+
* @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.
|
|
134
|
+
* @param result - The result of the transaction.
|
|
135
|
+
* @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.
|
|
136
|
+
* This is needed in asynchronous transactions where new commits have been added to the branch while the transaction was in progress.
|
|
137
|
+
* This will be `undefined` if no such change is necessary.
|
|
138
|
+
*/
|
|
139
|
+
export type OnPopWithViewUpdate<TChange> = (result: TransactionResult, viewUpdate: TChange | undefined) => void;
|
|
129
140
|
/**
|
|
130
141
|
* An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.
|
|
131
142
|
* @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.
|
|
@@ -156,7 +167,7 @@ export declare class SquashingTransactionStack<TEditor extends ChangeFamilyEdito
|
|
|
156
167
|
* @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.
|
|
157
168
|
* @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
|
|
158
169
|
*/
|
|
159
|
-
constructor(branch: SharedTreeBranch<TEditor, TChange>, mintRevisionTag: () => RevisionTag, onPush?: () =>
|
|
170
|
+
constructor(branch: SharedTreeBranch<TEditor, TChange>, mintRevisionTag: () => RevisionTag, onPush?: () => OnPopWithViewUpdate<TChange> | void);
|
|
160
171
|
/** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */
|
|
161
172
|
private setTransactionBranch;
|
|
162
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI/E,OAAO,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI/E,OAAO,EAON,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE5E;;;GAGG;AACH,oBAAY,iBAAiB;IAC5B;;OAEG;IACH,KAAK,IAAA;IACL;;OAEG;IACH,MAAM,IAAA;CACN;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,MAAM,IAAI,IAAI,CAAC;IACf;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC;IACxB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED,MAAM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H,IAAW,YAAY,IAAI,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAE5D;IAED;;;;OAIG;IACH,IAAW,kBAAkB,IAAI,UAAU,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAqBpF;IAQD;;;;OAIG;gBAEc,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,EAC1D,eAAe,EAAE,MAAM,WAAW,EAClC,MAAM,CAAC,EAAE,MAAM,mBAAmB,CAAC,OAAO,CAAC,GAAG,IAAI;IAqJnD,sGAAsG;IACtG,OAAO,CAAC,oBAAoB;CAY5B"}
|
|
@@ -63,11 +63,18 @@ class TransactionStack {
|
|
|
63
63
|
this.ensureNotDisposed();
|
|
64
64
|
return __classPrivateFieldGet(this, _TransactionStack_stack, "f").length > 0;
|
|
65
65
|
}
|
|
66
|
-
start() {
|
|
66
|
+
start(isAsync) {
|
|
67
67
|
this.ensureNotDisposed();
|
|
68
|
-
const
|
|
68
|
+
const last = (0, index_js_2.getLast)(__classPrivateFieldGet(this, _TransactionStack_stack, "f"));
|
|
69
|
+
if (last !== undefined && !last.isAsync && isAsync) {
|
|
70
|
+
throw new internal_2.UsageError("An asynchronous transaction cannot be started while a synchronous transaction is in progress.");
|
|
71
|
+
}
|
|
72
|
+
const onPushCurrent = last === undefined ? __classPrivateFieldGet(this, _TransactionStack_onPush, "f") : last.callbacks.onPush;
|
|
69
73
|
const { onPush, onPop } = onPushCurrent?.() ?? {};
|
|
70
|
-
__classPrivateFieldGet(this, _TransactionStack_stack, "f").push({
|
|
74
|
+
__classPrivateFieldGet(this, _TransactionStack_stack, "f").push({
|
|
75
|
+
callbacks: { onPop, onPush: onPush ?? onPushCurrent },
|
|
76
|
+
isAsync,
|
|
77
|
+
});
|
|
71
78
|
__classPrivateFieldGet(this, _TransactionStack_events, "f").emit("started");
|
|
72
79
|
}
|
|
73
80
|
commit() {
|
|
@@ -76,7 +83,7 @@ class TransactionStack {
|
|
|
76
83
|
throw new internal_2.UsageError("No transaction to commit");
|
|
77
84
|
}
|
|
78
85
|
__classPrivateFieldGet(this, _TransactionStack_events, "f").emit("committing");
|
|
79
|
-
__classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.onPop?.(TransactionResult.Commit);
|
|
86
|
+
__classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.callbacks.onPop?.(TransactionResult.Commit);
|
|
80
87
|
}
|
|
81
88
|
abort() {
|
|
82
89
|
this.ensureNotDisposed();
|
|
@@ -84,7 +91,7 @@ class TransactionStack {
|
|
|
84
91
|
throw new internal_2.UsageError("No transaction to abort");
|
|
85
92
|
}
|
|
86
93
|
__classPrivateFieldGet(this, _TransactionStack_events, "f").emit("aborting");
|
|
87
|
-
__classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.onPop?.(TransactionResult.Abort);
|
|
94
|
+
__classPrivateFieldGet(this, _TransactionStack_stack, "f").pop()?.callbacks.onPop?.(TransactionResult.Abort);
|
|
88
95
|
}
|
|
89
96
|
dispose() {
|
|
90
97
|
this.ensureNotDisposed();
|
|
@@ -147,8 +154,8 @@ class SquashingTransactionStack extends TransactionStack {
|
|
|
147
154
|
// Invoked when an outer transaction starts
|
|
148
155
|
() => {
|
|
149
156
|
// Keep track of the commit that each transaction was on when it started
|
|
150
|
-
// TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.
|
|
151
157
|
const startHead = this.activeBranch.getHead();
|
|
158
|
+
const rebaser = this.branch.changeFamily.rebaser;
|
|
152
159
|
const outerOnPop = onPush?.();
|
|
153
160
|
let transactionRevision;
|
|
154
161
|
const transactionBranch = this.branch.fork(startHead,
|
|
@@ -160,22 +167,58 @@ class SquashingTransactionStack extends TransactionStack {
|
|
|
160
167
|
const onOuterTransactionPop = (result) => {
|
|
161
168
|
(0, internal_1.assert)(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);
|
|
162
169
|
transactionBranch.editor.exitTransaction();
|
|
170
|
+
const sourcePath = [];
|
|
171
|
+
const targetPath = [];
|
|
172
|
+
const ancestor = (0, index_js_1.findCommonAncestor)([startHead, sourcePath], [branch.getHead(), targetPath]);
|
|
173
|
+
(0, internal_1.assert)(ancestor !== undefined, 0xcce /* branches must be related */);
|
|
174
|
+
const transactionSteps = [];
|
|
175
|
+
(0, index_js_1.findAncestor)([transactionBranch.getHead(), transactionSteps], (c) => c === startHead);
|
|
176
|
+
let viewUpdate;
|
|
163
177
|
switch (result) {
|
|
164
178
|
case TransactionResult.Abort: {
|
|
165
|
-
// When a transaction is aborted, roll back all the transaction's changes on the current branch
|
|
179
|
+
// When a transaction is aborted, roll back all the transaction's changes on the current branch.
|
|
180
|
+
// It is important that this happens before and separately from updating the view because the `TreeCheckout` needs to
|
|
181
|
+
// revert some internal (state to match what it was before the transaction began) before applying the view update (if any).
|
|
166
182
|
transactionBranch.removeAfter(startHead);
|
|
183
|
+
// If changes were made on `branch` since the transaction began, the view will need to be updated to reflect those changes.
|
|
184
|
+
if (targetPath.length > 0) {
|
|
185
|
+
viewUpdate = (0, index_js_1.diffHistories)(rebaser, startHead, this.branch.getHead(), mintRevisionTag);
|
|
186
|
+
}
|
|
167
187
|
break;
|
|
168
188
|
}
|
|
169
189
|
case TransactionResult.Commit: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (removedCommits.length > 0) {
|
|
174
|
-
for (const commit of removedCommits) {
|
|
190
|
+
if (transactionSteps.length > 0) {
|
|
191
|
+
(0, internal_1.assert)(transactionRevision !== undefined, 0xccf /* Expected transaction revision in the presence of transaction steps */);
|
|
192
|
+
for (const commit of transactionSteps) {
|
|
175
193
|
(0, internal_1.assert)(commit.revision === transactionRevision, 0xcaf /* Unexpected commit in transaction */);
|
|
176
194
|
}
|
|
177
|
-
|
|
178
|
-
|
|
195
|
+
// Squash all the new commits on the transaction branch into a new commit on the original branch
|
|
196
|
+
const squash = rebaser.compose(transactionSteps);
|
|
197
|
+
if (targetPath.length === 0) {
|
|
198
|
+
// No changes were made on the original branch since the transaction began
|
|
199
|
+
// The transaction commit can be applied directly
|
|
200
|
+
this.branch.apply((0, index_js_1.tagChange)(squash, transactionRevision));
|
|
201
|
+
// The view is already up-to-date so there's nothing more to do
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
// Some changes were made on `branch` since the transaction began
|
|
205
|
+
const unrebasedHead = (0, index_js_1.mintCommit)(startHead, {
|
|
206
|
+
change: squash,
|
|
207
|
+
revision: transactionRevision,
|
|
208
|
+
});
|
|
209
|
+
// We need to rebase the transaction commit on top of the new changes
|
|
210
|
+
const rebased = (0, index_js_1.rebaseBranch)(mintRevisionTag, rebaser, unrebasedHead, branch.getHead());
|
|
211
|
+
(0, internal_1.assert)(rebased.newSourceHead.revision === transactionRevision, 0xcd0 /* The transaction commit should be rebased to the tip */);
|
|
212
|
+
this.branch.apply(rebased.newSourceHead);
|
|
213
|
+
viewUpdate = rebased.sourceChange;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
if (targetPath.length > 0) {
|
|
218
|
+
// Changes were made on `branch` since the transaction began.
|
|
219
|
+
// The view will need to be updated to reflect those changes.
|
|
220
|
+
viewUpdate = (0, index_js_1.diffHistories)(rebaser, startHead, this.branch.getHead(), mintRevisionTag);
|
|
221
|
+
}
|
|
179
222
|
}
|
|
180
223
|
break;
|
|
181
224
|
}
|
|
@@ -185,7 +228,7 @@ class SquashingTransactionStack extends TransactionStack {
|
|
|
185
228
|
}
|
|
186
229
|
transactionBranch.dispose();
|
|
187
230
|
this.setTransactionBranch(undefined);
|
|
188
|
-
outerOnPop?.(result);
|
|
231
|
+
outerOnPop?.(result, viewUpdate);
|
|
189
232
|
};
|
|
190
233
|
// Invoked when a nested transaction begins
|
|
191
234
|
const onNestedTransactionPush = () => {
|
|
@@ -209,7 +252,7 @@ class SquashingTransactionStack extends TransactionStack {
|
|
|
209
252
|
(0, internal_1.unreachableCase)(result);
|
|
210
253
|
}
|
|
211
254
|
}
|
|
212
|
-
nestedOuterOnPop?.(result);
|
|
255
|
+
nestedOuterOnPop?.(result, undefined);
|
|
213
256
|
},
|
|
214
257
|
};
|
|
215
258
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,+DAA6D;AAE7D,kEAA8E;AAC9E,uEAAsE;AAEtE,+CAM0B;AAC1B,+CAAiE;AAIjE;;;GAGG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC5B;;OAEG;IACH,2DAAK,CAAA;IACL;;OAEG;IACH,6DAAM,CAAA;AACP,CAAC,EATW,iBAAiB,iCAAjB,iBAAiB,QAS5B;AA8FD;;;GAGG;AACH,MAAa,gBAAgB;IAK5B,IAAW,MAAM;QAChB,OAAO,uBAAA,IAAI,gCAAQ,CAAC;IACrB,CAAC;IAGD,IAAW,QAAQ;QAClB,OAAO,uBAAA,IAAI,kCAAU,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,YAAmB,MAAe;QAjBzB,kCAAsB,EAAE,EAAC;QACzB,2CAAiB;QAEjB,mCAAU,IAAA,4BAAa,GAAqB,EAAC;QAKtD,qCAAY,KAAK,EAAC;QAUjB,uBAAA,IAAI,4BAAW,MAAM,MAAA,CAAC;IACvB,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,uBAAA,IAAI,+BAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,IAAA,kBAAO,EAAC,uBAAA,IAAI,+BAAO,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,uBAAA,IAAI,+BAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,uBAAA,IAAI,gCAAQ,CAAC;QACxF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;gCACT,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;4BACzB,CAAC;wBACF,CAAC;wBACD,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC;oBAC5B,CAAC;iBACD,CAAC;YACH,CAAC,CAAC;YACF,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC;QAC1E,CAAC,CACD,CAAC;QApFc,WAAM,GAAN,MAAM,CAAoC;QA5D3D,+DAAwD;QAExD;;;;WAIG;QACa,uBAAkB,GAAG,IAAI,KAAK,CAAU,EAAwB,EAAE;YACjF,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE;gBACvB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;YAC3D,CAAC;SACD,CAAC,CAAC;QAoCM,wDAAsB,IAAI,GAAG,EAKnC,EAAC;IA6FJ,CAAC;IAED,sGAAsG;IAC9F,oBAAoB,CAC3B,iBAAiE;QAEjE,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC;QAC1C,uBAAA,IAAI,gDAAsB,iBAAiB,MAAA,CAAC;QAC5C,KAAK,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,uBAAA,IAAI,qDAAoB,EAAE,CAAC;YAC/D,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAClC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBAChD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD;AApKD,8DAoKC","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 { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tfindAncestor,\n\ttagChange,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport { getLast, getOrCreate, hasSome } from \"../util/index.js\";\n\nimport type { SharedTreeBranch, SharedTreeBranchEvents } from \"./branch.js\";\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 * Callbacks for transaction lifecycle events.\n */\nexport interface Callbacks {\n\t/**\n\t * Called when the current transaction is popped from the {@link TransactionStack | stack}.\n\t */\n\treadonly onPop?: OnPop;\n\t/**\n\t * Called when a nested transaction is pushed onto the {@link TransactionStack | stack}.\n\t * @remarks\n\t * Transactions may be arbitrarily nested (by {@link TransactionStack.start | start}ing a transaction within a transaction that is already in progress).\n\t * The `OnPush` callback for an (outer) transaction may optionally return another `OnPush` callback that is associated with any nested (inner) transaction(s).\n\t * In that case, the inner `OnPush` will be called when those inner transactions are pushed and the outer `OnPush` will not be called.\n\t * Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.\n\t * The event \"bubbles up\" to (and no further past) its first registered callback.\n\t */\n\treadonly onPush?: OnPush;\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 other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto 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 = () => Callbacks | 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: Callbacks[] = [];\n\treadonly #onPush?: OnPush;\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?: OnPush) {\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\tconst onPushCurrent = hasSome(this.#stack) ? getLast(this.#stack).onPush : this.#onPush;\n\t\tconst { onPush, onPop } = onPushCurrent?.() ?? {};\n\t\tthis.#stack.push({ onPop, onPush: onPush ?? onPushCurrent });\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()?.onPop?.(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()?.onPop?.(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\n/**\n * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.\n * @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.\n * This class provides conveniences for interacting with the {@link SquashingTransactionStack.activeBranch | active branch} in a way that is stable across transaction boundaries.\n * For example, see {@link SquashingTransactionStack.activeBranchEditor | activeBranchEditor} and {@link SquashingTransactionStack.activeBranchEvents | activeBranchEvents}.\n */\nexport class SquashingTransactionStack<\n\tTEditor extends ChangeFamilyEditor,\n\tTChange,\n> extends TransactionStack {\n\t#transactionBranch?: SharedTreeBranch<TEditor, TChange>;\n\n\t/**\n\t * An editor for whichever branch is currently the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks This editor can safely be held on to across transaction boundaries, as it will properly delegate to the correct branch.\n\t * In contrast, it is not safe to hold onto e.g. `activeBranch.editor` across transaction boundaries, since the active branch may change.\n\t */\n\tpublic readonly activeBranchEditor = new Proxy<TEditor>({} as unknown as TEditor, {\n\t\tget: (_, p, receiver) => {\n\t\t\treturn Reflect.get(this.activeBranch.editor, p, receiver);\n\t\t},\n\t});\n\n\t/**\n\t * Get the \"active branch\" for this transactor - either the transaction branch if a transaction is in progress, or the original branch otherwise.\n\t */\n\tpublic get activeBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.#transactionBranch ?? this.branch;\n\t}\n\n\t/**\n\t * Provides events for changes in the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks When the active branch changes, the listeners for these events will automatically be transferred to the new active branch.\n\t * In contrast, binding an event to the {@link SquashingTransactionStack.activeBranch | active branch} directly will not automatically transfer the listener when the active branch changes.\n\t */\n\tpublic get activeBranchEvents(): Listenable<SharedTreeBranchEvents<TEditor, TChange>> {\n\t\tconst off = (\n\t\t\teventName: keyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\t\tlistener: SharedTreeBranchEvents<TEditor, TChange>[typeof eventName],\n\t\t): void => {\n\t\t\tthis.activeBranch.events.off(eventName, listener);\n\t\t\tconst listeners = this.#activeBranchEvents.get(eventName);\n\t\t\tif (listeners?.delete(listener) === true && listeners.size === 0) {\n\t\t\t\tthis.#activeBranchEvents.delete(eventName);\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\ton: (eventName, listener) => {\n\t\t\t\tconst listeners = getOrCreate(this.#activeBranchEvents, eventName, () => new Set());\n\t\t\t\tlisteners.add(listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t\treturn () => off(eventName, listener);\n\t\t\t},\n\t\t\toff,\n\t\t};\n\t}\n\treadonly #activeBranchEvents = new Map<\n\t\tkeyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\tSet<\n\t\t\tSharedTreeBranchEvents<TEditor, TChange>[keyof SharedTreeBranchEvents<TEditor, TChange>]\n\t\t>\n\t>();\n\n\t/**\n\t * Construct a new {@link SquashingTransactionStack}.\n\t * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.\n\t * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly branch: SharedTreeBranch<TEditor, TChange>,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tonPush?: () => OnPop | void,\n\t) {\n\t\tsuper(\n\t\t\t// Invoked when an outer transaction starts\n\t\t\t(): Callbacks => {\n\t\t\t\t// Keep track of the commit that each transaction was on when it started\n\t\t\t\t// TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.\n\t\t\t\tconst startHead = this.activeBranch.getHead();\n\t\t\t\tconst outerOnPop = onPush?.();\n\t\t\t\tlet transactionRevision: RevisionTag | undefined;\n\t\t\t\tconst transactionBranch = this.branch.fork(\n\t\t\t\t\tstartHead,\n\t\t\t\t\t// Lazily mint the revision tag for the transaction when it is first needed\n\t\t\t\t\t() => (transactionRevision ??= mintRevisionTag()),\n\t\t\t\t);\n\t\t\t\tthis.setTransactionBranch(transactionBranch);\n\t\t\t\ttransactionBranch.editor.enterTransaction();\n\t\t\t\t// Invoked when an outer transaction ends\n\t\t\t\tconst onOuterTransactionPop: OnPop = (result) => {\n\t\t\t\t\tassert(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);\n\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch\n\t\t\t\t\t\t\ttransactionBranch.removeAfter(startHead);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\t// ...squash all the new commits on the transaction branch into a new commit on the original branch\n\t\t\t\t\t\t\tconst removedCommits: GraphCommit<TChange>[] = [];\n\t\t\t\t\t\t\tfindAncestor(\n\t\t\t\t\t\t\t\t[transactionBranch.getHead(), removedCommits],\n\t\t\t\t\t\t\t\t(c) => c === startHead,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (removedCommits.length > 0) {\n\t\t\t\t\t\t\t\tfor (const commit of removedCommits) {\n\t\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\t\tcommit.revision === transactionRevision,\n\t\t\t\t\t\t\t\t\t\t0xcaf /* Unexpected commit in transaction */,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst squash = this.branch.changeFamily.rebaser.compose(removedCommits);\n\t\t\t\t\t\t\t\tthis.branch.apply(tagChange(squash, transactionRevision));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttransactionBranch.dispose();\n\t\t\t\t\tthis.setTransactionBranch(undefined);\n\t\t\t\t\touterOnPop?.(result);\n\t\t\t\t};\n\t\t\t\t// Invoked when a nested transaction begins\n\t\t\t\tconst onNestedTransactionPush: OnPush = () => {\n\t\t\t\t\tconst nestedStartHead = this.activeBranch.getHead();\n\t\t\t\t\tconst nestedOuterOnPop = onPush?.();\n\t\t\t\t\ttransactionBranch.editor.enterTransaction();\n\t\t\t\t\treturn {\n\t\t\t\t\t\t// Invoked when a nested transaction ends\n\t\t\t\t\t\tonPop: (result) => {\n\t\t\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\t\t\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch\n\t\t\t\t\t\t\t\t\ttransactionBranch.removeAfter(nestedStartHead);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnestedOuterOnPop?.(result);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\treturn { onPop: onOuterTransactionPop, onPush: onNestedTransactionPush };\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */\n\tprivate setTransactionBranch(\n\t\ttransactionBranch: SharedTreeBranch<TEditor, TChange> | undefined,\n\t): void {\n\t\tconst oldActiveBranch = this.activeBranch;\n\t\tthis.#transactionBranch = transactionBranch;\n\t\tfor (const [eventName, listeners] of this.#activeBranchEvents) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\toldActiveBranch.events.off(eventName, listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/shared-tree-core/transaction.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,+DAA6D;AAE7D,kEAA8E;AAC9E,uEAAsE;AAEtE,+CAU0B;AAC1B,+CAAwD;AAIxD;;;GAGG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC5B;;OAEG;IACH,2DAAK,CAAA;IACL;;OAEG;IACH,6DAAM,CAAA;AACP,CAAC,EATW,iBAAiB,iCAAjB,iBAAiB,QAS5B;AA0GD;;;GAGG;AACH,MAAa,gBAAgB;IAK5B,IAAW,MAAM;QAChB,OAAO,uBAAA,IAAI,gCAAQ,CAAC;IACrB,CAAC;IAGD,IAAW,QAAQ;QAClB,OAAO,uBAAA,IAAI,kCAAU,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,YAAmB,MAAe;QAjBzB,kCAAkC,EAAE,EAAC;QACrC,2CAAiB;QAEjB,mCAAU,IAAA,4BAAa,GAAqB,EAAC;QAKtD,qCAAY,KAAK,EAAC;QAUjB,uBAAA,IAAI,4BAAW,MAAM,MAAA,CAAC;IACvB,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,uBAAA,IAAI,+BAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,OAAgB;QAC5B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,IAAA,kBAAO,EAAC,uBAAA,IAAI,+BAAO,CAAC,CAAC;QAClC,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,EAAE,CAAC;YACpD,MAAM,IAAI,qBAAU,CACnB,+FAA+F,CAC/F,CAAC;QACH,CAAC;QACD,MAAM,aAAa,GA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eAAe,GAAG,IAAI,CAAC,YAAY,CAAC;QAC1C,uBAAA,IAAI,gDAAsB,iBAAiB,MAAA,CAAC;QAC5C,KAAK,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,uBAAA,IAAI,qDAAoB,EAAE,CAAC;YAC/D,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAClC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBAChD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD;AApOD,8DAoOC","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 { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tdiffHistories,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseBranch,\n\ttagChange,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport { getLast, getOrCreate } from \"../util/index.js\";\n\nimport type { SharedTreeBranch, SharedTreeBranchEvents } from \"./branch.js\";\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 * @param isAsync - Whether the transaction is asynchronous.\n\t * An error will be thrown if an asynchronous transaction is started while a synchronous transaction is in progress.\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(isAsync: boolean): 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 * Callbacks for transaction lifecycle events.\n */\nexport interface Callbacks {\n\t/**\n\t * Called when the current transaction is popped from the {@link TransactionStack | stack}.\n\t */\n\treadonly onPop?: OnPop;\n\t/**\n\t * Called when a nested transaction is pushed onto the {@link TransactionStack | stack}.\n\t * @remarks\n\t * Transactions may be arbitrarily nested (by {@link TransactionStack.start | start}ing a transaction within a transaction that is already in progress).\n\t * The `OnPush` callback for an (outer) transaction may optionally return another `OnPush` callback that is associated with any nested (inner) transaction(s).\n\t * In that case, the inner `OnPush` will be called when those inner transactions are pushed and the outer `OnPush` will not be called.\n\t * Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.\n\t * The event \"bubbles up\" to (and no further past) its first registered callback.\n\t */\n\treadonly onPush?: OnPush;\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 other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto 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 = () => Callbacks | 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 * A frame in the transaction stack.\n */\ninterface TransactionStackFrame {\n\t/** The callbacks provided when this transaction frame was pushed onto the stack. */\n\treadonly callbacks: Callbacks;\n\t/** Whether this transaction frame is asynchronous. */\n\treadonly isAsync: boolean;\n}\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: TransactionStackFrame[] = [];\n\treadonly #onPush?: OnPush;\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?: OnPush) {\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(isAsync: boolean): void {\n\t\tthis.ensureNotDisposed();\n\t\tconst last = getLast(this.#stack);\n\t\tif (last !== undefined && !last.isAsync && isAsync) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"An asynchronous transaction cannot be started while a synchronous transaction is in progress.\",\n\t\t\t);\n\t\t}\n\t\tconst onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;\n\t\tconst { onPush, onPop } = onPushCurrent?.() ?? {};\n\t\tthis.#stack.push({\n\t\t\tcallbacks: { onPop, onPush: onPush ?? onPushCurrent },\n\t\t\tisAsync,\n\t\t});\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()?.callbacks.onPop?.(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()?.callbacks.onPop?.(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\n/**\n * A function that will be called when a transaction is popped from the {@link SquashingTransactionStack | 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 * @param result - The result of the transaction.\n * @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.\n * This is needed in asynchronous transactions where new commits have been added to the branch while the transaction was in progress.\n * This will be `undefined` if no such change is necessary.\n */\nexport type OnPopWithViewUpdate<TChange> = (\n\tresult: TransactionResult,\n\tviewUpdate: TChange | undefined,\n) => void;\n\n/**\n * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.\n * @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.\n * This class provides conveniences for interacting with the {@link SquashingTransactionStack.activeBranch | active branch} in a way that is stable across transaction boundaries.\n * For example, see {@link SquashingTransactionStack.activeBranchEditor | activeBranchEditor} and {@link SquashingTransactionStack.activeBranchEvents | activeBranchEvents}.\n */\nexport class SquashingTransactionStack<\n\tTEditor extends ChangeFamilyEditor,\n\tTChange,\n> extends TransactionStack {\n\t#transactionBranch?: SharedTreeBranch<TEditor, TChange>;\n\n\t/**\n\t * An editor for whichever branch is currently the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks This editor can safely be held on to across transaction boundaries, as it will properly delegate to the correct branch.\n\t * In contrast, it is not safe to hold onto e.g. `activeBranch.editor` across transaction boundaries, since the active branch may change.\n\t */\n\tpublic readonly activeBranchEditor = new Proxy<TEditor>({} as unknown as TEditor, {\n\t\tget: (_, p, receiver) => {\n\t\t\treturn Reflect.get(this.activeBranch.editor, p, receiver);\n\t\t},\n\t});\n\n\t/**\n\t * Get the \"active branch\" for this transactor - either the transaction branch if a transaction is in progress, or the original branch otherwise.\n\t */\n\tpublic get activeBranch(): SharedTreeBranch<TEditor, TChange> {\n\t\treturn this.#transactionBranch ?? this.branch;\n\t}\n\n\t/**\n\t * Provides events for changes in the {@link SquashingTransactionStack.activeBranch | active branch}.\n\t * @remarks When the active branch changes, the listeners for these events will automatically be transferred to the new active branch.\n\t * In contrast, binding an event to the {@link SquashingTransactionStack.activeBranch | active branch} directly will not automatically transfer the listener when the active branch changes.\n\t */\n\tpublic get activeBranchEvents(): Listenable<SharedTreeBranchEvents<TEditor, TChange>> {\n\t\tconst off = (\n\t\t\teventName: keyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\t\tlistener: SharedTreeBranchEvents<TEditor, TChange>[typeof eventName],\n\t\t): void => {\n\t\t\tthis.activeBranch.events.off(eventName, listener);\n\t\t\tconst listeners = this.#activeBranchEvents.get(eventName);\n\t\t\tif (listeners?.delete(listener) === true && listeners.size === 0) {\n\t\t\t\tthis.#activeBranchEvents.delete(eventName);\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\ton: (eventName, listener) => {\n\t\t\t\tconst listeners = getOrCreate(this.#activeBranchEvents, eventName, () => new Set());\n\t\t\t\tlisteners.add(listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t\treturn () => off(eventName, listener);\n\t\t\t},\n\t\t\toff,\n\t\t};\n\t}\n\treadonly #activeBranchEvents = new Map<\n\t\tkeyof SharedTreeBranchEvents<TEditor, TChange>,\n\t\tSet<\n\t\t\tSharedTreeBranchEvents<TEditor, TChange>[keyof SharedTreeBranchEvents<TEditor, TChange>]\n\t\t>\n\t>();\n\n\t/**\n\t * Construct a new {@link SquashingTransactionStack}.\n\t * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.\n\t * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly branch: SharedTreeBranch<TEditor, TChange>,\n\t\tmintRevisionTag: () => RevisionTag,\n\t\tonPush?: () => OnPopWithViewUpdate<TChange> | void,\n\t) {\n\t\tsuper(\n\t\t\t// Invoked when an outer transaction starts\n\t\t\t(): Callbacks => {\n\t\t\t\t// Keep track of the commit that each transaction was on when it started\n\t\t\t\tconst startHead = this.activeBranch.getHead();\n\t\t\t\tconst rebaser = this.branch.changeFamily.rebaser;\n\t\t\t\tconst outerOnPop = onPush?.();\n\t\t\t\tlet transactionRevision: RevisionTag | undefined;\n\t\t\t\tconst transactionBranch = this.branch.fork(\n\t\t\t\t\tstartHead,\n\t\t\t\t\t// Lazily mint the revision tag for the transaction when it is first needed\n\t\t\t\t\t() => (transactionRevision ??= mintRevisionTag()),\n\t\t\t\t);\n\t\t\t\tthis.setTransactionBranch(transactionBranch);\n\t\t\t\ttransactionBranch.editor.enterTransaction();\n\n\t\t\t\t// Invoked when an outer transaction ends\n\t\t\t\tconst onOuterTransactionPop: OnPop = (result) => {\n\t\t\t\t\tassert(!this.isInProgress(), 0xcae /* The outer transaction should be ending */);\n\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\n\t\t\t\t\tconst sourcePath: GraphCommit<TChange>[] = [];\n\t\t\t\t\tconst targetPath: GraphCommit<TChange>[] = [];\n\t\t\t\t\tconst ancestor = findCommonAncestor(\n\t\t\t\t\t\t[startHead, sourcePath],\n\t\t\t\t\t\t[branch.getHead(), targetPath],\n\t\t\t\t\t);\n\t\t\t\t\tassert(ancestor !== undefined, 0xcce /* branches must be related */);\n\n\t\t\t\t\tconst transactionSteps: GraphCommit<TChange>[] = [];\n\t\t\t\t\tfindAncestor(\n\t\t\t\t\t\t[transactionBranch.getHead(), transactionSteps],\n\t\t\t\t\t\t(c) => c === startHead,\n\t\t\t\t\t);\n\n\t\t\t\t\tlet viewUpdate: TChange | undefined;\n\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch.\n\t\t\t\t\t\t\t// It is important that this happens before and separately from updating the view because the `TreeCheckout` needs to\n\t\t\t\t\t\t\t// revert some internal (state to match what it was before the transaction began) before applying the view update (if any).\n\t\t\t\t\t\t\ttransactionBranch.removeAfter(startHead);\n\t\t\t\t\t\t\t// If changes were made on `branch` since the transaction began, the view will need to be updated to reflect those changes.\n\t\t\t\t\t\t\tif (targetPath.length > 0) {\n\t\t\t\t\t\t\t\tviewUpdate = diffHistories(\n\t\t\t\t\t\t\t\t\trebaser,\n\t\t\t\t\t\t\t\t\tstartHead,\n\t\t\t\t\t\t\t\t\tthis.branch.getHead(),\n\t\t\t\t\t\t\t\t\tmintRevisionTag,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\tif (transactionSteps.length > 0) {\n\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\ttransactionRevision !== undefined,\n\t\t\t\t\t\t\t\t\t0xccf /* Expected transaction revision in the presence of transaction steps */,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tfor (const commit of transactionSteps) {\n\t\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\t\tcommit.revision === transactionRevision,\n\t\t\t\t\t\t\t\t\t\t0xcaf /* Unexpected commit in transaction */,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Squash all the new commits on the transaction branch into a new commit on the original branch\n\t\t\t\t\t\t\t\tconst squash = rebaser.compose(transactionSteps);\n\n\t\t\t\t\t\t\t\tif (targetPath.length === 0) {\n\t\t\t\t\t\t\t\t\t// No changes were made on the original branch since the transaction began\n\t\t\t\t\t\t\t\t\t// The transaction commit can be applied directly\n\t\t\t\t\t\t\t\t\tthis.branch.apply(tagChange(squash, transactionRevision));\n\t\t\t\t\t\t\t\t\t// The view is already up-to-date so there's nothing more to do\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Some changes were made on `branch` since the transaction began\n\t\t\t\t\t\t\t\t\tconst unrebasedHead = mintCommit(startHead, {\n\t\t\t\t\t\t\t\t\t\tchange: squash,\n\t\t\t\t\t\t\t\t\t\trevision: transactionRevision,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t// We need to rebase the transaction commit on top of the new changes\n\t\t\t\t\t\t\t\t\tconst rebased = rebaseBranch(\n\t\t\t\t\t\t\t\t\t\tmintRevisionTag,\n\t\t\t\t\t\t\t\t\t\trebaser,\n\t\t\t\t\t\t\t\t\t\tunrebasedHead,\n\t\t\t\t\t\t\t\t\t\tbranch.getHead(),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\t\t\trebased.newSourceHead.revision === transactionRevision,\n\t\t\t\t\t\t\t\t\t\t0xcd0 /* The transaction commit should be rebased to the tip */,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthis.branch.apply(rebased.newSourceHead);\n\t\t\t\t\t\t\t\t\tviewUpdate = rebased.sourceChange;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (targetPath.length > 0) {\n\t\t\t\t\t\t\t\t\t// Changes were made on `branch` since the transaction began.\n\t\t\t\t\t\t\t\t\t// The view will need to be updated to reflect those changes.\n\t\t\t\t\t\t\t\t\tviewUpdate = diffHistories(\n\t\t\t\t\t\t\t\t\t\trebaser,\n\t\t\t\t\t\t\t\t\t\tstartHead,\n\t\t\t\t\t\t\t\t\t\tthis.branch.getHead(),\n\t\t\t\t\t\t\t\t\t\tmintRevisionTag,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttransactionBranch.dispose();\n\t\t\t\t\tthis.setTransactionBranch(undefined);\n\t\t\t\t\touterOnPop?.(result, viewUpdate);\n\t\t\t\t};\n\t\t\t\t// Invoked when a nested transaction begins\n\t\t\t\tconst onNestedTransactionPush: OnPush = () => {\n\t\t\t\t\tconst nestedStartHead = this.activeBranch.getHead();\n\t\t\t\t\tconst nestedOuterOnPop = onPush?.();\n\t\t\t\t\ttransactionBranch.editor.enterTransaction();\n\t\t\t\t\treturn {\n\t\t\t\t\t\t// Invoked when a nested transaction ends\n\t\t\t\t\t\tonPop: (result) => {\n\t\t\t\t\t\t\ttransactionBranch.editor.exitTransaction();\n\t\t\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\t\t\tcase TransactionResult.Abort: {\n\t\t\t\t\t\t\t\t\t// When a transaction is aborted, roll back all the transaction's changes on the current branch\n\t\t\t\t\t\t\t\t\ttransactionBranch.removeAfter(nestedStartHead);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnestedOuterOnPop?.(result, undefined);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\treturn { onPop: onOuterTransactionPop, onPush: onNestedTransactionPush };\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Updates the transaction branch (and therefore the active branch) and rebinds the branch events. */\n\tprivate setTransactionBranch(\n\t\ttransactionBranch: SharedTreeBranch<TEditor, TChange> | undefined,\n\t): void {\n\t\tconst oldActiveBranch = this.activeBranch;\n\t\tthis.#transactionBranch = transactionBranch;\n\t\tfor (const [eventName, listeners] of this.#activeBranchEvents) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\toldActiveBranch.events.off(eventName, listener);\n\t\t\t\tthis.activeBranch.events.on(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionedSummarizer.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/version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AW,CAAC,QAAQ,CAAC;IACzD;;;;;OAKG;IACc,0BAA0B,EAAE,OAAO;IASrD;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE;QAC3C,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;QACnE,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI;IAER;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC9B,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB;IAC3B;;;OAGG;IACH,OAAO,EAAE,QAAQ,GAAG,SAAS,GAC3B,OAAO,CAAC,IAAI,CAAC;IAET,SAAS,CAAC,KAAK,EAAE;QACvB,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;KACnE,GAAG,qBAAqB;IAUZ,IAAI,CAChB,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAkBhB"}
|
|
@@ -48,7 +48,7 @@ class VersionedSummarizer {
|
|
|
48
48
|
async load(services, parse) {
|
|
49
49
|
let version;
|
|
50
50
|
if (await services.contains(summaryTypes_js_1.summarizablesMetadataKey)) {
|
|
51
|
-
const metadata = await (0, index_js_1.readAndParseSnapshotBlob)(summaryTypes_js_1.summarizablesMetadataKey, services, (contents) => parse(contents));
|
|
51
|
+
const metadata = (await (0, index_js_1.readAndParseSnapshotBlob)(summaryTypes_js_1.summarizablesMetadataKey, services, (contents) => parse(contents)));
|
|
52
52
|
version = metadata.version;
|
|
53
53
|
if (!this.supportedVersions.has(version)) {
|
|
54
54
|
throw new internal_3.UsageError(`Cannot read version ${version} of shared tree summary.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionedSummarizer.js","sourceRoot":"","sources":["../../src/shared-tree-core/versionedSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAO7D,qEAA4E;AAC5E,uEAAsE;AAEtE,+CAA4D;AAE5D,uDAM2B;AAE3B;;;;GAIG;AACH,MAAsB,mBAAmB;IACxC;IACC,+BAA+B;IACf,GAAW;IAC3B,0EAA0E;IACzD,YAAsB;IACvC,4FAA4F;IAC3E,iBAAwC;IACzD;;;;;OAKG;IACc,0BAAmC;QAXpC,QAAG,GAAH,GAAG,CAAQ;QAEV,iBAAY,GAAZ,YAAY,CAAU;QAEtB,sBAAiB,GAAjB,iBAAiB,CAAuB;QAOxC,+BAA0B,GAA1B,0BAA0B,CAAS;QAEpD,IAAA,iBAAM,EACL,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAC7C,KAAK,CAAC,0CAA0C,EAChD,GAAG,EAAE,CAAC,iBAAiB,IAAI,CAAC,YAAY,yCAAyC,GAAG,GAAG,CACvF,CAAC;IACH,CAAC;IA4BM,SAAS,CAAC,KAMhB;QACA,MAAM,OAAO,GAAG,IAAI,6BAAkB,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAmC;YAChD,OAAO,EAAE,IAAI,CAAC,YAAY;SAC1B,CAAC;QACF,OAAO,CAAC,OAAO,CAAC,0CAAwB,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,IAAI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AAC;IACjC,CAAC;IAEM,KAAK,CAAC,IAAI,CAChB,QAAgC,EAChC,KAA2B;QAE3B,IAAI,OAA6B,CAAC;QAClC,IAAI,MAAM,QAAQ,CAAC,QAAQ,CAAC,0CAAwB,CAAC,EAAE,CAAC;YACvD,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,mCAAwB,EAC/C,0CAAwB,EACxB,QAAQ,EACR,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAE7B,CAAmC,CAAC;YACrC,OAAO,GAAG,QAAQ,CAAC,OAAmB,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,qBAAU,CAAC,uBAAuB,OAAO,0BAA0B,CAAC,CAAC;YAChF,CAAC;QACF,CAAC;aAAM,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAC7C,MAAM,IAAI,qBAAU,CAAC,iEAAiE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACD;AAtFD,kDAsFC","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 { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { readAndParseSnapshotBlob } from \"../util/index.js\";\n\nimport {\n\tsummarizablesMetadataKey,\n\ttype SharedTreeSummarizableMetadata,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"./summaryTypes.js\";\n\n/**\n * Utility for implementing {@link Summarizable}s classes with versioning.\n * It handles versioning of summaries - writing version metadata to summaries\n * and checking version compatibility when loading.\n */\nexport abstract class VersionedSummarizer<TVersion extends number> implements Summarizable {\n\tpublic constructor(\n\t\t/** {@link Summarizable.key} */\n\t\tpublic readonly key: string,\n\t\t/** The format version of the summary to write in the summary metadata. */\n\t\tprivate readonly writeVersion: TVersion,\n\t\t/** The set of supported versions that a summary can have for this summarizer to load it. */\n\t\tprivate readonly supportedVersions: ReadonlySet<TVersion>,\n\t\t/**\n\t\t * Whether to support loading summaries before versioning was added, i.e., summaries without metadata blob.\n\t\t * @remarks\n\t\t * This version may not be supported if the support for the version before metadata blob was dropped.\n\t\t * In that case, this will not be present in `supportedVersions` and an error will be thrown during load.\n\t\t */\n\t\tprivate readonly supportPreVersioningFormat: boolean,\n\t) {\n\t\tassert(\n\t\t\tthis.supportedVersions.has(this.writeVersion),\n\t\t\t0xca6 /* Unsupported write version requested. */,\n\t\t\t() => `Write version ${this.writeVersion} requested but not supported with key ${key}.`,\n\t\t);\n\t}\n\n\t/**\n\t * The summarize function that derived classes must implement. They should use the passed summary tree builder to\n\t * add their summary data.\n\t */\n\tprotected abstract summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void;\n\n\t/**\n\t * The load function that derived classes must implement to load their summary data.\n\t */\n\tprotected abstract loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t\t/**\n\t\t * The format version of the summary being loaded, or undefined if this is pre-versioning format,\n\t\t * i.e., the summary has no version metadata.\n\t\t */\n\t\tversion: TVersion | undefined,\n\t): Promise<void>;\n\n\tpublic summarize(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t}): ISummaryTreeWithStats {\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tconst metadata: SharedTreeSummarizableMetadata = {\n\t\t\tversion: this.writeVersion,\n\t\t};\n\t\tbuilder.addBlob(summarizablesMetadataKey, props.stringify(metadata));\n\t\tthis.summarizeInternal({ ...props, builder });\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic async load(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tlet version: TVersion | undefined;\n\t\tif (await services.contains(summarizablesMetadataKey)) {\n\t\t\tconst metadata = (await readAndParseSnapshotBlob(\n\t\t\t\tsummarizablesMetadataKey,\n\t\t\t\tservices,\n\t\t\t\t(contents) => parse(contents),\n\t\t\t\t// TODO: this type cast should use a codec to validate the data instead of just type casting.\n\t\t\t)) as SharedTreeSummarizableMetadata;\n\t\t\tversion = metadata.version as TVersion;\n\t\t\tif (!this.supportedVersions.has(version)) {\n\t\t\t\tthrow new UsageError(`Cannot read version ${version} of shared tree summary.`);\n\t\t\t}\n\t\t} else if (!this.supportPreVersioningFormat) {\n\t\t\tthrow new UsageError(`Cannot read summary without versioning for shared tree summary.`);\n\t\t}\n\t\tawait this.loadInternal(services, parse, version);\n\t}\n}\n"]}
|