@fluidframework/tree 2.61.0 → 2.62.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 +162 -0
- package/api-report/tree.alpha.api.md +26 -21
- package/api-report/tree.beta.api.md +15 -0
- package/api-report/tree.legacy.beta.api.md +18 -0
- package/dist/alpha.d.ts +8 -8
- package/dist/api.d.ts +17 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +24 -0
- package/dist/api.js.map +1 -0
- package/dist/beta.d.ts +5 -0
- package/dist/codec/codec.d.ts +3 -5
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +9 -2
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +0 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +1 -3
- package/dist/codec/index.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 +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +2 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/utils.d.ts +10 -0
- package/dist/core/rebase/utils.d.ts.map +1 -1
- package/dist/core/rebase/utils.js +20 -1
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +1 -1
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/external-utilities/index.d.ts +1 -1
- package/dist/external-utilities/index.d.ts.map +1 -1
- package/dist/external-utilities/index.js +1 -2
- package/dist/external-utilities/index.js.map +1 -1
- package/dist/external-utilities/typeboxValidator.d.ts +0 -13
- package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
- package/dist/external-utilities/typeboxValidator.js +3 -5
- package/dist/external-utilities/typeboxValidator.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -0
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +4 -1
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +15 -8
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/observer.d.ts +32 -0
- package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -0
- package/dist/feature-libraries/flex-tree/observer.js +33 -0
- package/dist/feature-libraries/flex-tree/observer.js.map +1 -0
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +3 -1
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +7 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/index.d.ts +2 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +2 -2
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +21 -6
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +76 -37
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +114 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +140 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +13 -7
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +115 -85
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +3 -0
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchIdCodec.d.ts +11 -0
- package/dist/shared-tree-core/branchIdCodec.d.ts.map +1 -0
- package/dist/shared-tree-core/branchIdCodec.js +18 -0
- package/dist/shared-tree-core/branchIdCodec.js.map +1 -0
- package/dist/shared-tree-core/editManager.d.ts +39 -64
- package/dist/shared-tree-core/editManager.d.ts.map +1 -1
- package/dist/shared-tree-core/editManager.js +455 -295
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +7 -96
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +17 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.js +139 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -0
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +16 -0
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -0
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js +39 -0
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -0
- package/dist/shared-tree-core/editManagerCodecsV5.d.ts +16 -0
- package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -0
- package/dist/shared-tree-core/editManagerCodecsV5.js +58 -0
- package/dist/shared-tree-core/editManagerCodecsV5.js.map +1 -0
- package/dist/shared-tree-core/{editManagerFormat.d.ts → editManagerFormatCommons.d.ts} +31 -7
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -0
- package/dist/shared-tree-core/{editManagerFormat.js → editManagerFormatCommons.js} +13 -12
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +31 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +24 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -0
- package/dist/shared-tree-core/editManagerFormatV5.d.ts +62 -0
- package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -0
- package/dist/shared-tree-core/editManagerFormatV5.js +20 -0
- package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -0
- package/dist/shared-tree-core/index.d.ts +3 -3
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +11 -0
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -0
- package/dist/shared-tree-core/messageCodecV1ToV4.js +59 -0
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -0
- package/dist/shared-tree-core/messageCodecV5.d.ts +11 -0
- package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -0
- package/dist/shared-tree-core/messageCodecV5.js +78 -0
- package/dist/shared-tree-core/messageCodecV5.js.map +1 -0
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +16 -47
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/{messageFormat.d.ts → messageFormatV1ToV4.d.ts} +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -0
- package/dist/shared-tree-core/{messageFormat.js → messageFormatV1ToV4.js} +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -0
- package/dist/shared-tree-core/messageFormatV5.d.ts +42 -0
- package/dist/shared-tree-core/messageFormatV5.d.ts.map +1 -0
- package/dist/shared-tree-core/messageFormatV5.js +20 -0
- package/dist/shared-tree-core/messageFormatV5.js.map +1 -0
- package/dist/shared-tree-core/messageTypes.d.ts +12 -2
- package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
- package/dist/shared-tree-core/messageTypes.js.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +19 -5
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +182 -58
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +17 -0
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +2 -0
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +7 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/treeFactory.d.ts +38 -9
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +44 -9
- package/dist/treeFactory.js.map +1 -1
- package/lib/alpha.d.ts +8 -8
- package/lib/api.d.ts +17 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +22 -0
- package/lib/api.js.map +1 -0
- package/lib/beta.d.ts +5 -0
- package/lib/codec/codec.d.ts +3 -5
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +8 -1
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +0 -1
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +0 -1
- package/lib/codec/index.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/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/utils.d.ts +10 -0
- package/lib/core/rebase/utils.d.ts.map +1 -1
- package/lib/core/rebase/utils.js +18 -0
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +2 -2
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/external-utilities/index.d.ts +1 -1
- package/lib/external-utilities/index.d.ts.map +1 -1
- package/lib/external-utilities/index.js +1 -1
- package/lib/external-utilities/index.js.map +1 -1
- package/lib/external-utilities/typeboxValidator.d.ts +0 -13
- package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
- package/lib/external-utilities/typeboxValidator.js +1 -3
- package/lib/external-utilities/typeboxValidator.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -0
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -0
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +15 -8
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/observer.d.ts +32 -0
- package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -0
- package/lib/feature-libraries/flex-tree/observer.js +40 -0
- package/lib/feature-libraries/flex-tree/observer.js.map +1 -0
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +7 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/index.d.ts +2 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +2 -2
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +21 -6
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +78 -39
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +114 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +143 -4
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +13 -7
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +117 -87
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +3 -0
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchIdCodec.d.ts +11 -0
- package/lib/shared-tree-core/branchIdCodec.d.ts.map +1 -0
- package/lib/shared-tree-core/branchIdCodec.js +13 -0
- package/lib/shared-tree-core/branchIdCodec.js.map +1 -0
- package/lib/shared-tree-core/editManager.d.ts +39 -64
- package/lib/shared-tree-core/editManager.d.ts.map +1 -1
- package/lib/shared-tree-core/editManager.js +455 -295
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +4 -93
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +17 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.js +134 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -0
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +16 -0
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -0
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js +35 -0
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -0
- package/lib/shared-tree-core/editManagerCodecsV5.d.ts +16 -0
- package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +1 -0
- package/lib/shared-tree-core/editManagerCodecsV5.js +54 -0
- package/lib/shared-tree-core/editManagerCodecsV5.js.map +1 -0
- package/lib/shared-tree-core/{editManagerFormat.d.ts → editManagerFormatCommons.d.ts} +31 -7
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -0
- package/lib/shared-tree-core/{editManagerFormat.js → editManagerFormatCommons.js} +10 -11
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +31 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +20 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -0
- package/lib/shared-tree-core/editManagerFormatV5.d.ts +62 -0
- package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -0
- package/lib/shared-tree-core/editManagerFormatV5.js +16 -0
- package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -0
- package/lib/shared-tree-core/index.d.ts +3 -3
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +11 -0
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -0
- package/lib/shared-tree-core/messageCodecV1ToV4.js +55 -0
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -0
- package/lib/shared-tree-core/messageCodecV5.d.ts +11 -0
- package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -0
- package/lib/shared-tree-core/messageCodecV5.js +74 -0
- package/lib/shared-tree-core/messageCodecV5.js.map +1 -0
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +17 -48
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/{messageFormat.d.ts → messageFormatV1ToV4.d.ts} +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -0
- package/lib/shared-tree-core/{messageFormat.js → messageFormatV1ToV4.js} +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -0
- package/lib/shared-tree-core/messageFormatV5.d.ts +42 -0
- package/lib/shared-tree-core/messageFormatV5.d.ts.map +1 -0
- package/lib/shared-tree-core/messageFormatV5.js +16 -0
- package/lib/shared-tree-core/messageFormatV5.js.map +1 -0
- package/lib/shared-tree-core/messageTypes.d.ts +12 -2
- package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
- package/lib/shared-tree-core/messageTypes.js.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +19 -5
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +183 -59
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +17 -0
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +2 -0
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +8 -2
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/treeFactory.d.ts +38 -9
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +41 -8
- package/lib/treeFactory.js.map +1 -1
- package/package.json +25 -25
- package/src/api.ts +30 -0
- package/src/codec/codec.ts +12 -6
- package/src/codec/index.ts +0 -1
- package/src/core/index.ts +1 -0
- package/src/core/rebase/index.ts +1 -0
- package/src/core/rebase/utils.ts +27 -0
- package/src/core/tree/detachedFieldIndex.ts +2 -2
- package/src/external-utilities/index.ts +1 -1
- package/src/external-utilities/typeboxValidator.ts +1 -3
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -0
- package/src/feature-libraries/flex-tree/index.ts +2 -0
- package/src/feature-libraries/flex-tree/lazyNode.ts +13 -3
- package/src/feature-libraries/flex-tree/observer.ts +64 -0
- package/src/feature-libraries/index.ts +3 -0
- package/src/index.ts +6 -4
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +2 -0
- package/src/shared-tree/schematizingTreeView.ts +2 -2
- package/src/shared-tree/sharedTree.ts +116 -52
- package/src/shared-tree/treeAlpha.ts +309 -4
- package/src/shared-tree/treeCheckout.ts +152 -100
- package/src/shared-tree-core/branch.ts +7 -0
- package/src/shared-tree-core/branchIdCodec.ts +28 -0
- package/src/shared-tree-core/editManager.ts +729 -430
- package/src/shared-tree-core/editManagerCodecs.ts +4 -164
- package/src/shared-tree-core/editManagerCodecsCommons.ts +245 -0
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +108 -0
- package/src/shared-tree-core/editManagerCodecsV5.ts +156 -0
- package/src/shared-tree-core/{editManagerFormat.ts → editManagerFormatCommons.ts} +17 -13
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +42 -0
- package/src/shared-tree-core/editManagerFormatV5.ts +35 -0
- package/src/shared-tree-core/index.ts +3 -1
- package/src/shared-tree-core/messageCodecV1ToV4.ts +104 -0
- package/src/shared-tree-core/messageCodecV5.ts +131 -0
- package/src/shared-tree-core/messageCodecs.ts +16 -85
- package/src/shared-tree-core/messageFormatV5.ts +50 -0
- package/src/shared-tree-core/messageTypes.ts +15 -2
- package/src/shared-tree-core/sequenceIdUtils.ts +1 -1
- package/src/shared-tree-core/sharedTreeCore.ts +281 -85
- package/src/simple-tree/api/tree.ts +23 -0
- package/src/simple-tree/core/unhydratedFlexTree.ts +11 -2
- package/src/treeFactory.ts +48 -8
- package/dist/codec/noopValidator.d.ts +0 -13
- package/dist/codec/noopValidator.d.ts.map +0 -1
- package/dist/codec/noopValidator.js +0 -17
- package/dist/codec/noopValidator.js.map +0 -1
- package/dist/shared-tree-core/editManagerFormat.d.ts.map +0 -1
- package/dist/shared-tree-core/editManagerFormat.js.map +0 -1
- package/dist/shared-tree-core/messageFormat.d.ts.map +0 -1
- package/dist/shared-tree-core/messageFormat.js.map +0 -1
- package/docs/user-facing/schema-evolution.md +0 -309
- package/lib/codec/noopValidator.d.ts +0 -13
- package/lib/codec/noopValidator.d.ts.map +0 -1
- package/lib/codec/noopValidator.js +0 -14
- package/lib/codec/noopValidator.js.map +0 -1
- package/lib/shared-tree-core/editManagerFormat.d.ts.map +0 -1
- package/lib/shared-tree-core/editManagerFormat.js.map +0 -1
- package/lib/shared-tree-core/messageFormat.d.ts.map +0 -1
- package/lib/shared-tree-core/messageFormat.js.map +0 -1
- package/src/codec/noopValidator.ts +0 -18
- /package/src/shared-tree-core/{messageFormat.ts → messageFormatV1ToV4.ts} +0 -0
|
@@ -9,9 +9,7 @@ import {
|
|
|
9
9
|
type ICodecFamily,
|
|
10
10
|
type ICodecOptions,
|
|
11
11
|
type IJsonCodec,
|
|
12
|
-
type IMultiFormatCodec,
|
|
13
12
|
makeCodecFamily,
|
|
14
|
-
withSchemaValidation,
|
|
15
13
|
} from "../codec/index.js";
|
|
16
14
|
import { makeVersionDispatchingCodec } from "../codec/index.js";
|
|
17
15
|
import type {
|
|
@@ -20,19 +18,11 @@ import type {
|
|
|
20
18
|
RevisionTag,
|
|
21
19
|
SchemaAndPolicy,
|
|
22
20
|
} from "../core/index.js";
|
|
23
|
-
import {
|
|
24
|
-
type JsonCompatibleReadOnly,
|
|
25
|
-
JsonCompatibleReadOnlySchema,
|
|
26
|
-
mapIterable,
|
|
27
|
-
} from "../util/index.js";
|
|
21
|
+
import type { JsonCompatibleReadOnly } from "../util/index.js";
|
|
28
22
|
|
|
29
23
|
import type { SummaryData } from "./editManager.js";
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
type EncodedCommit,
|
|
33
|
-
EncodedEditManager,
|
|
34
|
-
type SequencedCommit,
|
|
35
|
-
} from "./editManagerFormat.js";
|
|
24
|
+
import { makeV1CodecWithVersion } from "./editManagerCodecsV1toV4.js";
|
|
25
|
+
import { makeV5CodecWithVersion } from "./editManagerCodecsV5.js";
|
|
36
26
|
|
|
37
27
|
export interface EditManagerEncodingContext {
|
|
38
28
|
idCompressor: IIdCompressor;
|
|
@@ -74,156 +64,6 @@ export function makeEditManagerCodecs<TChangeset>(
|
|
|
74
64
|
[2, makeV1CodecWithVersion(changeCodecs.resolve(2), revisionTagCodec, options, 2)],
|
|
75
65
|
[3, makeV1CodecWithVersion(changeCodecs.resolve(3), revisionTagCodec, options, 3)],
|
|
76
66
|
[4, makeV1CodecWithVersion(changeCodecs.resolve(4), revisionTagCodec, options, 4)],
|
|
67
|
+
[5, makeV5CodecWithVersion(changeCodecs.resolve(4), revisionTagCodec, options, 5)],
|
|
77
68
|
]);
|
|
78
69
|
}
|
|
79
|
-
|
|
80
|
-
function makeV1CodecWithVersion<TChangeset>(
|
|
81
|
-
changeCodec: IMultiFormatCodec<
|
|
82
|
-
TChangeset,
|
|
83
|
-
JsonCompatibleReadOnly,
|
|
84
|
-
JsonCompatibleReadOnly,
|
|
85
|
-
ChangeEncodingContext
|
|
86
|
-
>,
|
|
87
|
-
revisionTagCodec: IJsonCodec<
|
|
88
|
-
RevisionTag,
|
|
89
|
-
EncodedRevisionTag,
|
|
90
|
-
EncodedRevisionTag,
|
|
91
|
-
ChangeEncodingContext
|
|
92
|
-
>,
|
|
93
|
-
options: ICodecOptions,
|
|
94
|
-
version: EncodedEditManager<TChangeset>["version"],
|
|
95
|
-
): IJsonCodec<
|
|
96
|
-
SummaryData<TChangeset>,
|
|
97
|
-
JsonCompatibleReadOnly,
|
|
98
|
-
JsonCompatibleReadOnly,
|
|
99
|
-
EditManagerEncodingContext
|
|
100
|
-
> {
|
|
101
|
-
const format = EncodedEditManager(
|
|
102
|
-
changeCodec.json.encodedSchema ?? JsonCompatibleReadOnlySchema,
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const encodeCommit = <T extends Commit<TChangeset>>(
|
|
106
|
-
commit: T,
|
|
107
|
-
context: ChangeEncodingContext,
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
109
|
-
) => ({
|
|
110
|
-
...commit,
|
|
111
|
-
revision: revisionTagCodec.encode(commit.revision, {
|
|
112
|
-
originatorId: commit.sessionId,
|
|
113
|
-
idCompressor: context.idCompressor,
|
|
114
|
-
revision: undefined,
|
|
115
|
-
}),
|
|
116
|
-
change: changeCodec.json.encode(commit.change, { ...context, revision: commit.revision }),
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const decodeCommit = <T extends EncodedCommit<JsonCompatibleReadOnly>>(
|
|
120
|
-
commit: T,
|
|
121
|
-
context: ChangeEncodingContext,
|
|
122
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
123
|
-
) => {
|
|
124
|
-
const revision = revisionTagCodec.decode(commit.revision, {
|
|
125
|
-
originatorId: commit.sessionId,
|
|
126
|
-
idCompressor: context.idCompressor,
|
|
127
|
-
revision: undefined,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
...commit,
|
|
132
|
-
revision,
|
|
133
|
-
change: changeCodec.json.decode(commit.change, { ...context, revision }),
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const codec: IJsonCodec<
|
|
138
|
-
SummaryData<TChangeset>,
|
|
139
|
-
EncodedEditManager<TChangeset>,
|
|
140
|
-
EncodedEditManager<TChangeset>,
|
|
141
|
-
EditManagerEncodingContext
|
|
142
|
-
> = withSchemaValidation(
|
|
143
|
-
format,
|
|
144
|
-
{
|
|
145
|
-
encode: (data, context: EditManagerEncodingContext) => {
|
|
146
|
-
const json: EncodedEditManager<TChangeset> = {
|
|
147
|
-
trunk: data.trunk.map((commit) =>
|
|
148
|
-
encodeCommit(commit, {
|
|
149
|
-
originatorId: commit.sessionId,
|
|
150
|
-
idCompressor: context.idCompressor,
|
|
151
|
-
schema: context.schema,
|
|
152
|
-
revision: undefined,
|
|
153
|
-
}),
|
|
154
|
-
),
|
|
155
|
-
branches: Array.from(data.peerLocalBranches.entries(), ([sessionId, branch]) => [
|
|
156
|
-
sessionId,
|
|
157
|
-
{
|
|
158
|
-
base: revisionTagCodec.encode(branch.base, {
|
|
159
|
-
originatorId: sessionId,
|
|
160
|
-
idCompressor: context.idCompressor,
|
|
161
|
-
revision: undefined,
|
|
162
|
-
}),
|
|
163
|
-
commits: branch.commits.map((commit) =>
|
|
164
|
-
encodeCommit(commit, {
|
|
165
|
-
originatorId: commit.sessionId,
|
|
166
|
-
idCompressor: context.idCompressor,
|
|
167
|
-
schema: context.schema,
|
|
168
|
-
revision: undefined,
|
|
169
|
-
}),
|
|
170
|
-
),
|
|
171
|
-
},
|
|
172
|
-
]),
|
|
173
|
-
version,
|
|
174
|
-
};
|
|
175
|
-
return json;
|
|
176
|
-
},
|
|
177
|
-
decode: (
|
|
178
|
-
json: EncodedEditManager<TChangeset>,
|
|
179
|
-
context: EditManagerEncodingContext,
|
|
180
|
-
): SummaryData<TChangeset> => {
|
|
181
|
-
// TODO: sort out EncodedCommit vs Commit, and make this type check without `any`.
|
|
182
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
-
const trunk: readonly any[] = json.trunk;
|
|
184
|
-
return {
|
|
185
|
-
trunk: trunk.map(
|
|
186
|
-
(commit): SequencedCommit<TChangeset> =>
|
|
187
|
-
// TODO: sort out EncodedCommit vs Commit, and make this type check without `as`.
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
189
|
-
decodeCommit(commit, {
|
|
190
|
-
originatorId: commit.sessionId,
|
|
191
|
-
idCompressor: context.idCompressor,
|
|
192
|
-
revision: undefined,
|
|
193
|
-
}),
|
|
194
|
-
),
|
|
195
|
-
peerLocalBranches: new Map(
|
|
196
|
-
mapIterable(json.branches, ([sessionId, branch]) => [
|
|
197
|
-
sessionId,
|
|
198
|
-
{
|
|
199
|
-
base: revisionTagCodec.decode(branch.base, {
|
|
200
|
-
originatorId: sessionId,
|
|
201
|
-
idCompressor: context.idCompressor,
|
|
202
|
-
revision: undefined,
|
|
203
|
-
}),
|
|
204
|
-
commits: branch.commits.map((commit) =>
|
|
205
|
-
// TODO: sort out EncodedCommit vs Commit, and make this type check without `as`.
|
|
206
|
-
decodeCommit(commit as EncodedCommit<JsonCompatibleReadOnly>, {
|
|
207
|
-
originatorId: commit.sessionId,
|
|
208
|
-
idCompressor: context.idCompressor,
|
|
209
|
-
revision: undefined,
|
|
210
|
-
}),
|
|
211
|
-
),
|
|
212
|
-
},
|
|
213
|
-
]),
|
|
214
|
-
),
|
|
215
|
-
};
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
options.jsonValidator,
|
|
219
|
-
);
|
|
220
|
-
// TODO: makeVersionedValidatedCodec and withSchemaValidation should allow the codec to decode JsonCompatibleReadOnly, or Versioned or something like that,
|
|
221
|
-
// and not leak the internal encoded format in the API surface.
|
|
222
|
-
// Fixing that would remove the need for this cast.
|
|
223
|
-
return codec as unknown as IJsonCodec<
|
|
224
|
-
SummaryData<TChangeset>,
|
|
225
|
-
JsonCompatibleReadOnly,
|
|
226
|
-
JsonCompatibleReadOnly,
|
|
227
|
-
EditManagerEncodingContext
|
|
228
|
-
>;
|
|
229
|
-
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
+
|
|
9
|
+
import type { IJsonCodec, IMultiFormatCodec } from "../codec/index.js";
|
|
10
|
+
import type {
|
|
11
|
+
ChangeEncodingContext,
|
|
12
|
+
EncodedRevisionTag,
|
|
13
|
+
RevisionTag,
|
|
14
|
+
SchemaAndPolicy,
|
|
15
|
+
} from "../core/index.js";
|
|
16
|
+
import { mapIterable, type JsonCompatibleReadOnly, type Mutable } from "../util/index.js";
|
|
17
|
+
import type {
|
|
18
|
+
Commit,
|
|
19
|
+
EncodedCommit,
|
|
20
|
+
EncodedSharedBranch,
|
|
21
|
+
SequencedCommit,
|
|
22
|
+
} from "./editManagerFormatCommons.js";
|
|
23
|
+
import type { SharedBranchSummaryData } from "./editManager.js";
|
|
24
|
+
import { decodeBranchId, encodeBranchId } from "./branchIdCodec.js";
|
|
25
|
+
|
|
26
|
+
export interface EditManagerEncodingContext {
|
|
27
|
+
idCompressor: IIdCompressor;
|
|
28
|
+
readonly schema?: SchemaAndPolicy;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
32
|
+
function encodeCommit<TChangeset, T extends Commit<TChangeset>>(
|
|
33
|
+
changeCodec: IMultiFormatCodec<
|
|
34
|
+
TChangeset,
|
|
35
|
+
JsonCompatibleReadOnly,
|
|
36
|
+
JsonCompatibleReadOnly,
|
|
37
|
+
ChangeEncodingContext
|
|
38
|
+
>,
|
|
39
|
+
revisionTagCodec: IJsonCodec<
|
|
40
|
+
RevisionTag,
|
|
41
|
+
EncodedRevisionTag,
|
|
42
|
+
EncodedRevisionTag,
|
|
43
|
+
ChangeEncodingContext
|
|
44
|
+
>,
|
|
45
|
+
commit: T,
|
|
46
|
+
context: ChangeEncodingContext,
|
|
47
|
+
) {
|
|
48
|
+
return {
|
|
49
|
+
...commit,
|
|
50
|
+
revision: revisionTagCodec.encode(commit.revision, {
|
|
51
|
+
originatorId: commit.sessionId,
|
|
52
|
+
idCompressor: context.idCompressor,
|
|
53
|
+
revision: undefined,
|
|
54
|
+
}),
|
|
55
|
+
change: changeCodec.json.encode(commit.change, { ...context, revision: commit.revision }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
60
|
+
function decodeCommit<TChangeset, T extends EncodedCommit<JsonCompatibleReadOnly>>(
|
|
61
|
+
changeCodec: IMultiFormatCodec<
|
|
62
|
+
TChangeset,
|
|
63
|
+
JsonCompatibleReadOnly,
|
|
64
|
+
JsonCompatibleReadOnly,
|
|
65
|
+
ChangeEncodingContext
|
|
66
|
+
>,
|
|
67
|
+
revisionTagCodec: IJsonCodec<
|
|
68
|
+
RevisionTag,
|
|
69
|
+
EncodedRevisionTag,
|
|
70
|
+
EncodedRevisionTag,
|
|
71
|
+
ChangeEncodingContext
|
|
72
|
+
>,
|
|
73
|
+
commit: T,
|
|
74
|
+
context: ChangeEncodingContext,
|
|
75
|
+
) {
|
|
76
|
+
const revision = revisionTagCodec.decode(commit.revision, {
|
|
77
|
+
originatorId: commit.sessionId,
|
|
78
|
+
idCompressor: context.idCompressor,
|
|
79
|
+
revision: undefined,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
...commit,
|
|
84
|
+
revision,
|
|
85
|
+
change: changeCodec.json.decode(commit.change, { ...context, revision }),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function encodeSharedBranch<TChangeset>(
|
|
90
|
+
changeCodec: IMultiFormatCodec<
|
|
91
|
+
TChangeset,
|
|
92
|
+
JsonCompatibleReadOnly,
|
|
93
|
+
JsonCompatibleReadOnly,
|
|
94
|
+
ChangeEncodingContext
|
|
95
|
+
>,
|
|
96
|
+
revisionTagCodec: IJsonCodec<
|
|
97
|
+
RevisionTag,
|
|
98
|
+
EncodedRevisionTag,
|
|
99
|
+
EncodedRevisionTag,
|
|
100
|
+
ChangeEncodingContext
|
|
101
|
+
>,
|
|
102
|
+
data: SharedBranchSummaryData<TChangeset>,
|
|
103
|
+
context: EditManagerEncodingContext,
|
|
104
|
+
originatorId: SessionId | undefined,
|
|
105
|
+
): EncodedSharedBranch<TChangeset> {
|
|
106
|
+
const json: Mutable<EncodedSharedBranch<TChangeset>> = {
|
|
107
|
+
trunk: data.trunk.map((commit) =>
|
|
108
|
+
encodeCommit(changeCodec, revisionTagCodec, commit, {
|
|
109
|
+
originatorId: commit.sessionId,
|
|
110
|
+
idCompressor: context.idCompressor,
|
|
111
|
+
schema: context.schema,
|
|
112
|
+
revision: undefined,
|
|
113
|
+
}),
|
|
114
|
+
),
|
|
115
|
+
peers: Array.from(data.peerLocalBranches.entries(), ([sessionId, branch]) => [
|
|
116
|
+
sessionId,
|
|
117
|
+
{
|
|
118
|
+
base: revisionTagCodec.encode(branch.base, {
|
|
119
|
+
originatorId: sessionId,
|
|
120
|
+
idCompressor: context.idCompressor,
|
|
121
|
+
revision: undefined,
|
|
122
|
+
}),
|
|
123
|
+
commits: branch.commits.map((commit) =>
|
|
124
|
+
encodeCommit(changeCodec, revisionTagCodec, commit, {
|
|
125
|
+
originatorId: commit.sessionId,
|
|
126
|
+
idCompressor: context.idCompressor,
|
|
127
|
+
schema: context.schema,
|
|
128
|
+
revision: undefined,
|
|
129
|
+
}),
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
]),
|
|
133
|
+
};
|
|
134
|
+
if (data.session !== undefined) {
|
|
135
|
+
json.session = data.session;
|
|
136
|
+
}
|
|
137
|
+
if (data.id !== undefined) {
|
|
138
|
+
json.id = encodeBranchId(context.idCompressor, data.id);
|
|
139
|
+
}
|
|
140
|
+
if (data.name !== undefined) {
|
|
141
|
+
json.name = data.name;
|
|
142
|
+
}
|
|
143
|
+
if (data.author !== undefined) {
|
|
144
|
+
json.author = data.author;
|
|
145
|
+
}
|
|
146
|
+
if (data.base !== undefined) {
|
|
147
|
+
assert(
|
|
148
|
+
originatorId !== undefined,
|
|
149
|
+
0xc62 /* Cannot encode branch base without originatorId */,
|
|
150
|
+
);
|
|
151
|
+
json.base = revisionTagCodec.encode(data.base, {
|
|
152
|
+
originatorId,
|
|
153
|
+
idCompressor: context.idCompressor,
|
|
154
|
+
revision: undefined,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return json;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function decodeSharedBranch<TChangeset>(
|
|
161
|
+
changeCodec: IMultiFormatCodec<
|
|
162
|
+
TChangeset,
|
|
163
|
+
JsonCompatibleReadOnly,
|
|
164
|
+
JsonCompatibleReadOnly,
|
|
165
|
+
ChangeEncodingContext
|
|
166
|
+
>,
|
|
167
|
+
revisionTagCodec: IJsonCodec<
|
|
168
|
+
RevisionTag,
|
|
169
|
+
EncodedRevisionTag,
|
|
170
|
+
EncodedRevisionTag,
|
|
171
|
+
ChangeEncodingContext
|
|
172
|
+
>,
|
|
173
|
+
json: EncodedSharedBranch<TChangeset>,
|
|
174
|
+
context: EditManagerEncodingContext,
|
|
175
|
+
originatorId: SessionId | undefined,
|
|
176
|
+
): SharedBranchSummaryData<TChangeset> {
|
|
177
|
+
// TODO: sort out EncodedCommit vs Commit, and make this type check without `any`.
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
+
const trunk: readonly any[] = json.trunk;
|
|
180
|
+
const data: Mutable<SharedBranchSummaryData<TChangeset>> = {
|
|
181
|
+
trunk: trunk.map(
|
|
182
|
+
(commit): SequencedCommit<TChangeset> =>
|
|
183
|
+
// TODO: sort out EncodedCommit vs Commit, and make this type check without `as`.
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
185
|
+
decodeCommit(changeCodec, revisionTagCodec, commit, {
|
|
186
|
+
originatorId: commit.sessionId,
|
|
187
|
+
idCompressor: context.idCompressor,
|
|
188
|
+
revision: undefined,
|
|
189
|
+
}),
|
|
190
|
+
),
|
|
191
|
+
peerLocalBranches: new Map(
|
|
192
|
+
mapIterable(json.peers, ([sessionId, branch]) => [
|
|
193
|
+
sessionId,
|
|
194
|
+
{
|
|
195
|
+
base: revisionTagCodec.decode(branch.base, {
|
|
196
|
+
originatorId: sessionId,
|
|
197
|
+
idCompressor: context.idCompressor,
|
|
198
|
+
revision: undefined,
|
|
199
|
+
}),
|
|
200
|
+
commits: branch.commits.map((commit) =>
|
|
201
|
+
// TODO: sort out EncodedCommit vs Commit, and make this type check without `as`.
|
|
202
|
+
decodeCommit(
|
|
203
|
+
changeCodec,
|
|
204
|
+
revisionTagCodec,
|
|
205
|
+
commit as EncodedCommit<JsonCompatibleReadOnly>,
|
|
206
|
+
{
|
|
207
|
+
originatorId: commit.sessionId,
|
|
208
|
+
idCompressor: context.idCompressor,
|
|
209
|
+
revision: undefined,
|
|
210
|
+
},
|
|
211
|
+
),
|
|
212
|
+
),
|
|
213
|
+
},
|
|
214
|
+
]),
|
|
215
|
+
),
|
|
216
|
+
};
|
|
217
|
+
if (json.session !== undefined) {
|
|
218
|
+
data.session = json.session;
|
|
219
|
+
}
|
|
220
|
+
if (json.name !== undefined) {
|
|
221
|
+
data.name = json.name;
|
|
222
|
+
}
|
|
223
|
+
if (json.author !== undefined) {
|
|
224
|
+
data.author = json.author;
|
|
225
|
+
}
|
|
226
|
+
if (json.id !== undefined) {
|
|
227
|
+
assert(
|
|
228
|
+
originatorId !== undefined,
|
|
229
|
+
0xc63 /* Cannot decode branch id without originatorId */,
|
|
230
|
+
);
|
|
231
|
+
data.id = decodeBranchId(context.idCompressor, json.id, { originatorId });
|
|
232
|
+
}
|
|
233
|
+
if (json.base !== undefined) {
|
|
234
|
+
assert(
|
|
235
|
+
originatorId !== undefined,
|
|
236
|
+
0xc64 /* Cannot decode branch base without originatorId */,
|
|
237
|
+
);
|
|
238
|
+
data.base = revisionTagCodec.decode(json.base, {
|
|
239
|
+
originatorId,
|
|
240
|
+
idCompressor: context.idCompressor,
|
|
241
|
+
revision: undefined,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return data;
|
|
245
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type ICodecOptions,
|
|
10
|
+
type IJsonCodec,
|
|
11
|
+
type IMultiFormatCodec,
|
|
12
|
+
withSchemaValidation,
|
|
13
|
+
} from "../codec/index.js";
|
|
14
|
+
import type {
|
|
15
|
+
ChangeEncodingContext,
|
|
16
|
+
EncodedRevisionTag,
|
|
17
|
+
RevisionTag,
|
|
18
|
+
SchemaAndPolicy,
|
|
19
|
+
} from "../core/index.js";
|
|
20
|
+
import { type JsonCompatibleReadOnly, JsonCompatibleReadOnlySchema } from "../util/index.js";
|
|
21
|
+
|
|
22
|
+
import type { SummaryData } from "./editManager.js";
|
|
23
|
+
import { EncodedEditManager } from "./editManagerFormatV1toV4.js";
|
|
24
|
+
import { decodeSharedBranch, encodeSharedBranch } from "./editManagerCodecsCommons.js";
|
|
25
|
+
|
|
26
|
+
export interface EditManagerEncodingContext {
|
|
27
|
+
idCompressor: IIdCompressor;
|
|
28
|
+
readonly schema?: SchemaAndPolicy;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function makeV1CodecWithVersion<TChangeset>(
|
|
32
|
+
changeCodec: IMultiFormatCodec<
|
|
33
|
+
TChangeset,
|
|
34
|
+
JsonCompatibleReadOnly,
|
|
35
|
+
JsonCompatibleReadOnly,
|
|
36
|
+
ChangeEncodingContext
|
|
37
|
+
>,
|
|
38
|
+
revisionTagCodec: IJsonCodec<
|
|
39
|
+
RevisionTag,
|
|
40
|
+
EncodedRevisionTag,
|
|
41
|
+
EncodedRevisionTag,
|
|
42
|
+
ChangeEncodingContext
|
|
43
|
+
>,
|
|
44
|
+
options: ICodecOptions,
|
|
45
|
+
version: EncodedEditManager<TChangeset>["version"],
|
|
46
|
+
): IJsonCodec<
|
|
47
|
+
SummaryData<TChangeset>,
|
|
48
|
+
JsonCompatibleReadOnly,
|
|
49
|
+
JsonCompatibleReadOnly,
|
|
50
|
+
EditManagerEncodingContext
|
|
51
|
+
> {
|
|
52
|
+
const format = EncodedEditManager(
|
|
53
|
+
changeCodec.json.encodedSchema ?? JsonCompatibleReadOnlySchema,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const codec: IJsonCodec<
|
|
57
|
+
SummaryData<TChangeset>,
|
|
58
|
+
EncodedEditManager<TChangeset>,
|
|
59
|
+
EncodedEditManager<TChangeset>,
|
|
60
|
+
EditManagerEncodingContext
|
|
61
|
+
> = withSchemaValidation(
|
|
62
|
+
format,
|
|
63
|
+
{
|
|
64
|
+
encode: (data, context: EditManagerEncodingContext) => {
|
|
65
|
+
const mainBranch = encodeSharedBranch(
|
|
66
|
+
changeCodec,
|
|
67
|
+
revisionTagCodec,
|
|
68
|
+
data.main,
|
|
69
|
+
context,
|
|
70
|
+
data.originator,
|
|
71
|
+
);
|
|
72
|
+
const json: EncodedEditManager<TChangeset> = {
|
|
73
|
+
trunk: mainBranch.trunk,
|
|
74
|
+
branches: mainBranch.peers,
|
|
75
|
+
version,
|
|
76
|
+
};
|
|
77
|
+
return json;
|
|
78
|
+
},
|
|
79
|
+
decode: (
|
|
80
|
+
json: EncodedEditManager<TChangeset>,
|
|
81
|
+
context: EditManagerEncodingContext,
|
|
82
|
+
): SummaryData<TChangeset> => {
|
|
83
|
+
return {
|
|
84
|
+
main: decodeSharedBranch(
|
|
85
|
+
changeCodec,
|
|
86
|
+
revisionTagCodec,
|
|
87
|
+
{
|
|
88
|
+
trunk: json.trunk,
|
|
89
|
+
peers: json.branches,
|
|
90
|
+
},
|
|
91
|
+
context,
|
|
92
|
+
undefined, // originatorId is not encoded in v1
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
options.jsonValidator,
|
|
98
|
+
);
|
|
99
|
+
// TODO: makeVersionedValidatedCodec and withSchemaValidation should allow the codec to decode JsonCompatibleReadOnly, or Versioned or something like that,
|
|
100
|
+
// and not leak the internal encoded format in the API surface.
|
|
101
|
+
// Fixing that would remove the need for this cast.
|
|
102
|
+
return codec as unknown as IJsonCodec<
|
|
103
|
+
SummaryData<TChangeset>,
|
|
104
|
+
JsonCompatibleReadOnly,
|
|
105
|
+
JsonCompatibleReadOnly,
|
|
106
|
+
EditManagerEncodingContext
|
|
107
|
+
>;
|
|
108
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type ICodecOptions,
|
|
11
|
+
type IJsonCodec,
|
|
12
|
+
type IMultiFormatCodec,
|
|
13
|
+
withSchemaValidation,
|
|
14
|
+
} from "../codec/index.js";
|
|
15
|
+
import type {
|
|
16
|
+
ChangeEncodingContext,
|
|
17
|
+
EncodedRevisionTag,
|
|
18
|
+
RevisionTag,
|
|
19
|
+
SchemaAndPolicy,
|
|
20
|
+
} from "../core/index.js";
|
|
21
|
+
import {
|
|
22
|
+
type JsonCompatibleReadOnly,
|
|
23
|
+
JsonCompatibleReadOnlySchema,
|
|
24
|
+
type Mutable,
|
|
25
|
+
} from "../util/index.js";
|
|
26
|
+
|
|
27
|
+
import type { SharedBranchSummaryData, SummaryData } from "./editManager.js";
|
|
28
|
+
import { EncodedEditManager } from "./editManagerFormatV5.js";
|
|
29
|
+
import { decodeSharedBranch, encodeSharedBranch } from "./editManagerCodecsCommons.js";
|
|
30
|
+
import type { EncodedSharedBranch } from "./editManagerFormatCommons.js";
|
|
31
|
+
import type { BranchId } from "./branch.js";
|
|
32
|
+
|
|
33
|
+
export interface EditManagerEncodingContext {
|
|
34
|
+
idCompressor: IIdCompressor;
|
|
35
|
+
readonly schema?: SchemaAndPolicy;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function makeV5CodecWithVersion<TChangeset>(
|
|
39
|
+
changeCodec: IMultiFormatCodec<
|
|
40
|
+
TChangeset,
|
|
41
|
+
JsonCompatibleReadOnly,
|
|
42
|
+
JsonCompatibleReadOnly,
|
|
43
|
+
ChangeEncodingContext
|
|
44
|
+
>,
|
|
45
|
+
revisionTagCodec: IJsonCodec<
|
|
46
|
+
RevisionTag,
|
|
47
|
+
EncodedRevisionTag,
|
|
48
|
+
EncodedRevisionTag,
|
|
49
|
+
ChangeEncodingContext
|
|
50
|
+
>,
|
|
51
|
+
options: ICodecOptions,
|
|
52
|
+
version: EncodedEditManager<TChangeset>["version"],
|
|
53
|
+
): IJsonCodec<
|
|
54
|
+
SummaryData<TChangeset>,
|
|
55
|
+
JsonCompatibleReadOnly,
|
|
56
|
+
JsonCompatibleReadOnly,
|
|
57
|
+
EditManagerEncodingContext
|
|
58
|
+
> {
|
|
59
|
+
const format = EncodedEditManager(
|
|
60
|
+
changeCodec.json.encodedSchema ?? JsonCompatibleReadOnlySchema,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const codec: IJsonCodec<
|
|
64
|
+
SummaryData<TChangeset>,
|
|
65
|
+
EncodedEditManager<TChangeset>,
|
|
66
|
+
EncodedEditManager<TChangeset>,
|
|
67
|
+
EditManagerEncodingContext
|
|
68
|
+
> = withSchemaValidation(
|
|
69
|
+
format,
|
|
70
|
+
{
|
|
71
|
+
encode: (data: SummaryData<TChangeset>, context: EditManagerEncodingContext) => {
|
|
72
|
+
const mainBranch = encodeSharedBranch(
|
|
73
|
+
changeCodec,
|
|
74
|
+
revisionTagCodec,
|
|
75
|
+
data.main,
|
|
76
|
+
context,
|
|
77
|
+
data.originator,
|
|
78
|
+
);
|
|
79
|
+
assert(
|
|
80
|
+
data.originator !== undefined,
|
|
81
|
+
0xc65 /* Cannot encode V5 summary without originator */,
|
|
82
|
+
);
|
|
83
|
+
const json: Mutable<EncodedEditManager<TChangeset>> = {
|
|
84
|
+
main: mainBranch,
|
|
85
|
+
originator: data.originator,
|
|
86
|
+
version,
|
|
87
|
+
};
|
|
88
|
+
if (data.branches !== undefined && data.branches.size > 0) {
|
|
89
|
+
const branches: EncodedSharedBranch<TChangeset>[] = [];
|
|
90
|
+
for (const [_, branch] of data.branches) {
|
|
91
|
+
branches.push(
|
|
92
|
+
encodeSharedBranch(
|
|
93
|
+
changeCodec,
|
|
94
|
+
revisionTagCodec,
|
|
95
|
+
branch,
|
|
96
|
+
context,
|
|
97
|
+
data.originator,
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
json.branches = branches;
|
|
102
|
+
}
|
|
103
|
+
return json;
|
|
104
|
+
},
|
|
105
|
+
decode: (
|
|
106
|
+
json: EncodedEditManager<TChangeset>,
|
|
107
|
+
context: EditManagerEncodingContext,
|
|
108
|
+
): SummaryData<TChangeset> => {
|
|
109
|
+
const mainBranch = decodeSharedBranch(
|
|
110
|
+
changeCodec,
|
|
111
|
+
revisionTagCodec,
|
|
112
|
+
json.main,
|
|
113
|
+
context,
|
|
114
|
+
json.originator,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const decoded: Mutable<SummaryData<TChangeset>> = {
|
|
118
|
+
main: mainBranch,
|
|
119
|
+
originator: json.originator,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (json.branches !== undefined) {
|
|
123
|
+
const branches = new Map<BranchId, SharedBranchSummaryData<TChangeset>>();
|
|
124
|
+
for (const branch of json.branches) {
|
|
125
|
+
const decodedBranch = decodeSharedBranch(
|
|
126
|
+
changeCodec,
|
|
127
|
+
revisionTagCodec,
|
|
128
|
+
branch,
|
|
129
|
+
context,
|
|
130
|
+
json.originator,
|
|
131
|
+
);
|
|
132
|
+
assert(
|
|
133
|
+
decodedBranch.id !== undefined,
|
|
134
|
+
0xc66 /* Shared branches must have an id */,
|
|
135
|
+
);
|
|
136
|
+
assert(!branches.has(decodedBranch.id), 0xc67 /* Duplicate shared branch id */);
|
|
137
|
+
branches.set(decodedBranch.id, decodedBranch);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
decoded.branches = branches;
|
|
141
|
+
}
|
|
142
|
+
return decoded;
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
options.jsonValidator,
|
|
146
|
+
);
|
|
147
|
+
// TODO: makeVersionedValidatedCodec and withSchemaValidation should allow the codec to decode JsonCompatibleReadOnly, or Versioned or something like that,
|
|
148
|
+
// and not leak the internal encoded format in the API surface.
|
|
149
|
+
// Fixing that would remove the need for this cast.
|
|
150
|
+
return codec as unknown as IJsonCodec<
|
|
151
|
+
SummaryData<TChangeset>,
|
|
152
|
+
JsonCompatibleReadOnly,
|
|
153
|
+
JsonCompatibleReadOnly,
|
|
154
|
+
EditManagerEncodingContext
|
|
155
|
+
>;
|
|
156
|
+
}
|