@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
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
SessionIdSchema,
|
|
14
14
|
} from "../core/index.js";
|
|
15
15
|
import { type Brand, brandedNumberType } from "../util/index.js";
|
|
16
|
+
import type { EncodedBranchId } from "./branch.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Contains a single change to the `SharedTree` and associated metadata.
|
|
@@ -67,7 +68,7 @@ export type SequenceId = Static<typeof SequenceId>;
|
|
|
67
68
|
*/
|
|
68
69
|
export interface SequencedCommit<TChangeset> extends Commit<TChangeset>, SequenceId {}
|
|
69
70
|
|
|
70
|
-
const SequencedCommit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
71
|
+
export const SequencedCommit = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
71
72
|
Type.Composite([CommitBase(tChange), SequenceId], noAdditionalProps);
|
|
72
73
|
|
|
73
74
|
/**
|
|
@@ -86,7 +87,7 @@ export interface EncodedSummarySessionBranch<TChangeset> {
|
|
|
86
87
|
readonly commits: Commit<TChangeset>[];
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
const SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
90
|
+
export const SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
90
91
|
Type.Object(
|
|
91
92
|
{
|
|
92
93
|
base: RevisionTagSchema,
|
|
@@ -95,23 +96,26 @@ const SummarySessionBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchem
|
|
|
95
96
|
noAdditionalProps,
|
|
96
97
|
);
|
|
97
98
|
|
|
98
|
-
export interface
|
|
99
|
+
export interface EncodedSharedBranch<TChangeset> {
|
|
100
|
+
readonly id?: EncodedBranchId;
|
|
101
|
+
readonly name?: string;
|
|
102
|
+
readonly author?: string;
|
|
103
|
+
readonly session?: SessionId;
|
|
104
|
+
readonly base?: EncodedRevisionTag;
|
|
99
105
|
readonly trunk: readonly Readonly<SequencedCommit<TChangeset>>[];
|
|
100
|
-
readonly
|
|
101
|
-
readonly version: 1 | 2 | 3 | 4;
|
|
106
|
+
readonly peers: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];
|
|
102
107
|
}
|
|
103
108
|
|
|
104
|
-
export const
|
|
109
|
+
export const EncodedSharedBranch = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
105
110
|
Type.Object(
|
|
106
111
|
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]),
|
|
112
|
+
id: Type.Optional(Type.Number()),
|
|
113
|
+
name: Type.Optional(Type.String()),
|
|
114
|
+
session: Type.Optional(SessionIdSchema),
|
|
115
|
+
author: Type.Optional(Type.String()),
|
|
116
|
+
base: Type.Optional(RevisionTagSchema),
|
|
113
117
|
trunk: Type.Array(SequencedCommit(tChange)),
|
|
114
|
-
|
|
118
|
+
peers: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
|
|
115
119
|
},
|
|
116
120
|
noAdditionalProps,
|
|
117
121
|
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SessionId } from "@fluidframework/id-compressor";
|
|
7
|
+
import { type ObjectOptions, type TSchema, Type } from "@sinclair/typebox";
|
|
8
|
+
|
|
9
|
+
import { SessionIdSchema } from "../core/index.js";
|
|
10
|
+
import {
|
|
11
|
+
type EncodedSummarySessionBranch,
|
|
12
|
+
SequencedCommit,
|
|
13
|
+
SummarySessionBranch,
|
|
14
|
+
} from "./editManagerFormatCommons.js";
|
|
15
|
+
|
|
16
|
+
const noAdditionalProps: ObjectOptions = { additionalProperties: false };
|
|
17
|
+
|
|
18
|
+
// Many of the return types in this module are intentionally derived, rather than explicitly specified.
|
|
19
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
20
|
+
|
|
21
|
+
export interface EncodedEditManager<TChangeset> {
|
|
22
|
+
readonly trunk: readonly Readonly<SequencedCommit<TChangeset>>[];
|
|
23
|
+
readonly branches: readonly [SessionId, Readonly<EncodedSummarySessionBranch<TChangeset>>][];
|
|
24
|
+
readonly version: 1 | 2 | 3 | 4;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
28
|
+
Type.Object(
|
|
29
|
+
{
|
|
30
|
+
version: Type.Union([
|
|
31
|
+
Type.Literal(1),
|
|
32
|
+
Type.Literal(2),
|
|
33
|
+
Type.Literal(3),
|
|
34
|
+
Type.Literal(4),
|
|
35
|
+
]),
|
|
36
|
+
trunk: Type.Array(SequencedCommit(tChange)),
|
|
37
|
+
branches: Type.Array(Type.Tuple([SessionIdSchema, SummarySessionBranch(tChange)])),
|
|
38
|
+
},
|
|
39
|
+
noAdditionalProps,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type ObjectOptions, type TSchema, Type } from "@sinclair/typebox";
|
|
7
|
+
import type { SessionId } from "@fluidframework/id-compressor";
|
|
8
|
+
|
|
9
|
+
import { EncodedSharedBranch } from "./editManagerFormatCommons.js";
|
|
10
|
+
import { SessionIdSchema } from "../core/index.js";
|
|
11
|
+
|
|
12
|
+
const noAdditionalProps: ObjectOptions = { additionalProperties: false };
|
|
13
|
+
|
|
14
|
+
// Many of the return types in this module are intentionally derived, rather than explicitly specified.
|
|
15
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
16
|
+
|
|
17
|
+
export interface EncodedEditManager<TChangeset> {
|
|
18
|
+
readonly version: 5;
|
|
19
|
+
readonly originator: SessionId;
|
|
20
|
+
readonly main: EncodedSharedBranch<TChangeset>;
|
|
21
|
+
readonly branches?: readonly EncodedSharedBranch<TChangeset>[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const EncodedEditManager = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
25
|
+
Type.Object(
|
|
26
|
+
{
|
|
27
|
+
version: Type.Union([Type.Literal(5)]),
|
|
28
|
+
originator: SessionIdSchema,
|
|
29
|
+
main: EncodedSharedBranch(tChange),
|
|
30
|
+
branches: Type.Optional(Type.Array(EncodedSharedBranch(tChange))),
|
|
31
|
+
},
|
|
32
|
+
noAdditionalProps,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
SharedTreeBranch,
|
|
9
9
|
type SharedTreeBranchChange,
|
|
10
10
|
type SharedTreeBranchEvents,
|
|
11
|
+
type BranchId,
|
|
11
12
|
} from "./branch.js";
|
|
12
13
|
|
|
13
14
|
export {
|
|
@@ -44,6 +45,7 @@ export {
|
|
|
44
45
|
EditManager,
|
|
45
46
|
minimumPossibleSequenceNumber,
|
|
46
47
|
type SummaryData,
|
|
48
|
+
type SharedBranchSummaryData,
|
|
47
49
|
} from "./editManager.js";
|
|
48
50
|
export type {
|
|
49
51
|
Commit,
|
|
@@ -51,4 +53,4 @@ export type {
|
|
|
51
53
|
SequencedCommit,
|
|
52
54
|
SummarySessionBranch,
|
|
53
55
|
EncodedCommit,
|
|
54
|
-
} from "./
|
|
56
|
+
} from "./editManagerFormatCommons.js";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type TAnySchema, Type } from "@sinclair/typebox";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
+
|
|
9
|
+
import { type ICodecOptions, type IJsonCodec, withSchemaValidation } from "../codec/index.js";
|
|
10
|
+
import type {
|
|
11
|
+
ChangeEncodingContext,
|
|
12
|
+
ChangeFamilyCodec,
|
|
13
|
+
EncodedRevisionTag,
|
|
14
|
+
RevisionTag,
|
|
15
|
+
} from "../core/index.js";
|
|
16
|
+
import type { JsonCompatibleReadOnly } from "../util/index.js";
|
|
17
|
+
|
|
18
|
+
import { Message } from "./messageFormatV1ToV4.js";
|
|
19
|
+
import type { DecodedMessage } from "./messageTypes.js";
|
|
20
|
+
import type { MessageEncodingContext } from "./messageCodecs.js";
|
|
21
|
+
|
|
22
|
+
export function makeV1ToV4CodecWithVersion<TChangeset>(
|
|
23
|
+
changeCodec: ChangeFamilyCodec<TChangeset>,
|
|
24
|
+
revisionTagCodec: IJsonCodec<
|
|
25
|
+
RevisionTag,
|
|
26
|
+
EncodedRevisionTag,
|
|
27
|
+
EncodedRevisionTag,
|
|
28
|
+
ChangeEncodingContext
|
|
29
|
+
>,
|
|
30
|
+
options: ICodecOptions,
|
|
31
|
+
version: 1 | 2 | 3 | 4,
|
|
32
|
+
): IJsonCodec<
|
|
33
|
+
DecodedMessage<TChangeset>,
|
|
34
|
+
JsonCompatibleReadOnly,
|
|
35
|
+
JsonCompatibleReadOnly,
|
|
36
|
+
MessageEncodingContext
|
|
37
|
+
> {
|
|
38
|
+
return withSchemaValidation<
|
|
39
|
+
DecodedMessage<TChangeset>,
|
|
40
|
+
TAnySchema,
|
|
41
|
+
JsonCompatibleReadOnly,
|
|
42
|
+
JsonCompatibleReadOnly,
|
|
43
|
+
MessageEncodingContext
|
|
44
|
+
>(
|
|
45
|
+
Message(changeCodec.encodedSchema ?? Type.Any()),
|
|
46
|
+
{
|
|
47
|
+
encode: (decoded: DecodedMessage<TChangeset>, context: MessageEncodingContext) => {
|
|
48
|
+
assert(decoded.type === "commit", 0xc68 /* Only commit messages are supported */);
|
|
49
|
+
assert(
|
|
50
|
+
decoded.branchId === "main",
|
|
51
|
+
0xc69 /* Only commit messages to main are supported */,
|
|
52
|
+
);
|
|
53
|
+
const { commit, sessionId: originatorId } = decoded;
|
|
54
|
+
const message: Message = {
|
|
55
|
+
revision: revisionTagCodec.encode(commit.revision, {
|
|
56
|
+
originatorId,
|
|
57
|
+
idCompressor: context.idCompressor,
|
|
58
|
+
revision: undefined,
|
|
59
|
+
}),
|
|
60
|
+
originatorId,
|
|
61
|
+
changeset: changeCodec.encode(commit.change, {
|
|
62
|
+
originatorId,
|
|
63
|
+
schema: context.schema,
|
|
64
|
+
idCompressor: context.idCompressor,
|
|
65
|
+
revision: commit.revision,
|
|
66
|
+
}),
|
|
67
|
+
version,
|
|
68
|
+
};
|
|
69
|
+
return message as unknown as JsonCompatibleReadOnly;
|
|
70
|
+
},
|
|
71
|
+
decode: (
|
|
72
|
+
encoded: JsonCompatibleReadOnly,
|
|
73
|
+
context: MessageEncodingContext,
|
|
74
|
+
): DecodedMessage<TChangeset> => {
|
|
75
|
+
const {
|
|
76
|
+
revision: encodedRevision,
|
|
77
|
+
originatorId,
|
|
78
|
+
changeset,
|
|
79
|
+
} = encoded as unknown as Message;
|
|
80
|
+
|
|
81
|
+
const revision = revisionTagCodec.decode(encodedRevision, {
|
|
82
|
+
originatorId,
|
|
83
|
+
revision: undefined,
|
|
84
|
+
idCompressor: context.idCompressor,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
branchId: "main",
|
|
89
|
+
type: "commit",
|
|
90
|
+
commit: {
|
|
91
|
+
revision,
|
|
92
|
+
change: changeCodec.decode(changeset, {
|
|
93
|
+
originatorId,
|
|
94
|
+
revision,
|
|
95
|
+
idCompressor: context.idCompressor,
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
sessionId: originatorId,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
options.jsonValidator,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type TAnySchema, Type } from "@sinclair/typebox";
|
|
7
|
+
|
|
8
|
+
import { type ICodecOptions, type IJsonCodec, withSchemaValidation } from "../codec/index.js";
|
|
9
|
+
import type {
|
|
10
|
+
ChangeEncodingContext,
|
|
11
|
+
ChangeFamilyCodec,
|
|
12
|
+
EncodedRevisionTag,
|
|
13
|
+
RevisionTag,
|
|
14
|
+
} from "../core/index.js";
|
|
15
|
+
import type { JsonCompatibleReadOnly } from "../util/index.js";
|
|
16
|
+
|
|
17
|
+
import { Message } from "./messageFormatV5.js";
|
|
18
|
+
import type { DecodedMessage } from "./messageTypes.js";
|
|
19
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
20
|
+
import type { MessageEncodingContext } from "./messageCodecs.js";
|
|
21
|
+
import { decodeBranchId, encodeBranchId } from "./branchIdCodec.js";
|
|
22
|
+
|
|
23
|
+
export function makeV5CodecWithVersion<TChangeset>(
|
|
24
|
+
changeCodec: ChangeFamilyCodec<TChangeset>,
|
|
25
|
+
revisionTagCodec: IJsonCodec<
|
|
26
|
+
RevisionTag,
|
|
27
|
+
EncodedRevisionTag,
|
|
28
|
+
EncodedRevisionTag,
|
|
29
|
+
ChangeEncodingContext
|
|
30
|
+
>,
|
|
31
|
+
options: ICodecOptions,
|
|
32
|
+
version: 5,
|
|
33
|
+
): IJsonCodec<
|
|
34
|
+
DecodedMessage<TChangeset>,
|
|
35
|
+
JsonCompatibleReadOnly,
|
|
36
|
+
JsonCompatibleReadOnly,
|
|
37
|
+
MessageEncodingContext
|
|
38
|
+
> {
|
|
39
|
+
return withSchemaValidation<
|
|
40
|
+
DecodedMessage<TChangeset>,
|
|
41
|
+
TAnySchema,
|
|
42
|
+
JsonCompatibleReadOnly,
|
|
43
|
+
JsonCompatibleReadOnly,
|
|
44
|
+
MessageEncodingContext
|
|
45
|
+
>(
|
|
46
|
+
Message(changeCodec.encodedSchema ?? Type.Any()),
|
|
47
|
+
{
|
|
48
|
+
encode: (
|
|
49
|
+
message: DecodedMessage<TChangeset>,
|
|
50
|
+
context: MessageEncodingContext,
|
|
51
|
+
): JsonCompatibleReadOnly => {
|
|
52
|
+
const type = message.type;
|
|
53
|
+
switch (type) {
|
|
54
|
+
case "commit": {
|
|
55
|
+
const changeContext: ChangeEncodingContext = {
|
|
56
|
+
originatorId: message.sessionId,
|
|
57
|
+
schema: context.schema,
|
|
58
|
+
idCompressor: context.idCompressor,
|
|
59
|
+
revision: message.commit.revision,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
revision: revisionTagCodec.encode(message.commit.revision, {
|
|
64
|
+
originatorId: message.sessionId,
|
|
65
|
+
idCompressor: context.idCompressor,
|
|
66
|
+
revision: undefined,
|
|
67
|
+
}),
|
|
68
|
+
originatorId: message.sessionId,
|
|
69
|
+
changeset: changeCodec.encode(message.commit.change, changeContext),
|
|
70
|
+
branchId: encodeBranchId(context.idCompressor, message.branchId),
|
|
71
|
+
version,
|
|
72
|
+
} satisfies Message & JsonCompatibleReadOnly;
|
|
73
|
+
}
|
|
74
|
+
case "branch": {
|
|
75
|
+
return {
|
|
76
|
+
originatorId: message.sessionId,
|
|
77
|
+
branchId: encodeBranchId(context.idCompressor, message.branchId),
|
|
78
|
+
version,
|
|
79
|
+
} satisfies Message & JsonCompatibleReadOnly;
|
|
80
|
+
}
|
|
81
|
+
default:
|
|
82
|
+
unreachableCase(type);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
decode: (
|
|
86
|
+
encoded: JsonCompatibleReadOnly,
|
|
87
|
+
context: MessageEncodingContext,
|
|
88
|
+
): DecodedMessage<TChangeset> => {
|
|
89
|
+
const {
|
|
90
|
+
revision: encodedRevision,
|
|
91
|
+
originatorId,
|
|
92
|
+
changeset,
|
|
93
|
+
branchId: encodedBranchId,
|
|
94
|
+
} = encoded as unknown as Message;
|
|
95
|
+
|
|
96
|
+
const changeContext = {
|
|
97
|
+
originatorId,
|
|
98
|
+
revision: undefined,
|
|
99
|
+
idCompressor: context.idCompressor,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const branchId = decodeBranchId(context.idCompressor, encodedBranchId, changeContext);
|
|
103
|
+
|
|
104
|
+
if (changeset === undefined) {
|
|
105
|
+
return { type: "branch", sessionId: originatorId, branchId };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
assert(
|
|
109
|
+
encodedRevision !== undefined,
|
|
110
|
+
0xc6a /* Commit messages must have a revision */,
|
|
111
|
+
);
|
|
112
|
+
const revision = revisionTagCodec.decode(encodedRevision, changeContext);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
type: "commit",
|
|
116
|
+
commit: {
|
|
117
|
+
revision,
|
|
118
|
+
change: changeCodec.decode(changeset, {
|
|
119
|
+
originatorId,
|
|
120
|
+
revision,
|
|
121
|
+
idCompressor: context.idCompressor,
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
branchId,
|
|
125
|
+
sessionId: originatorId,
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
options.jsonValidator,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -3,28 +3,25 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { type TAnySchema, Type } from "@sinclair/typebox";
|
|
7
|
-
|
|
8
6
|
import {
|
|
9
7
|
type ICodecFamily,
|
|
10
8
|
type ICodecOptions,
|
|
11
9
|
type IJsonCodec,
|
|
12
10
|
makeCodecFamily,
|
|
13
11
|
makeVersionDispatchingCodec,
|
|
14
|
-
withSchemaValidation,
|
|
15
12
|
} from "../codec/index.js";
|
|
16
13
|
import type {
|
|
17
14
|
ChangeEncodingContext,
|
|
18
|
-
ChangeFamilyCodec,
|
|
19
15
|
EncodedRevisionTag,
|
|
20
16
|
RevisionTag,
|
|
21
17
|
SchemaAndPolicy,
|
|
22
18
|
} from "../core/index.js";
|
|
23
19
|
import type { JsonCompatibleReadOnly } from "../util/index.js";
|
|
24
20
|
|
|
25
|
-
import { Message } from "./messageFormat.js";
|
|
26
21
|
import type { DecodedMessage } from "./messageTypes.js";
|
|
27
22
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
23
|
+
import { makeV1ToV4CodecWithVersion } from "./messageCodecV1ToV4.js";
|
|
24
|
+
import { makeV5CodecWithVersion } from "./messageCodecV5.js";
|
|
28
25
|
|
|
29
26
|
export interface MessageEncodingContext {
|
|
30
27
|
idCompressor: IIdCompressor;
|
|
@@ -64,7 +61,7 @@ export function makeMessageCodecs<TChangeset>(
|
|
|
64
61
|
>,
|
|
65
62
|
options: ICodecOptions,
|
|
66
63
|
): ICodecFamily<DecodedMessage<TChangeset>, MessageEncodingContext> {
|
|
67
|
-
const v1Codec =
|
|
64
|
+
const v1Codec = makeV1ToV4CodecWithVersion(
|
|
68
65
|
changeCodecs.resolve(1).json,
|
|
69
66
|
revisionTagCodec,
|
|
70
67
|
options,
|
|
@@ -74,84 +71,18 @@ export function makeMessageCodecs<TChangeset>(
|
|
|
74
71
|
// Back-compat: messages weren't always written with an explicit version field.
|
|
75
72
|
[undefined, v1Codec],
|
|
76
73
|
[1, v1Codec],
|
|
77
|
-
[
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
[
|
|
75
|
+
2,
|
|
76
|
+
makeV1ToV4CodecWithVersion(changeCodecs.resolve(2).json, revisionTagCodec, options, 2),
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
3,
|
|
80
|
+
makeV1ToV4CodecWithVersion(changeCodecs.resolve(3).json, revisionTagCodec, options, 3),
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
4,
|
|
84
|
+
makeV1ToV4CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 4),
|
|
85
|
+
],
|
|
86
|
+
[5, makeV5CodecWithVersion(changeCodecs.resolve(4).json, revisionTagCodec, options, 5)],
|
|
80
87
|
]);
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
function makeV1CodecWithVersion<TChangeset>(
|
|
84
|
-
changeCodec: ChangeFamilyCodec<TChangeset>,
|
|
85
|
-
revisionTagCodec: IJsonCodec<
|
|
86
|
-
RevisionTag,
|
|
87
|
-
EncodedRevisionTag,
|
|
88
|
-
EncodedRevisionTag,
|
|
89
|
-
ChangeEncodingContext
|
|
90
|
-
>,
|
|
91
|
-
options: ICodecOptions,
|
|
92
|
-
version: 1 | 2 | 3 | 4,
|
|
93
|
-
): IJsonCodec<
|
|
94
|
-
DecodedMessage<TChangeset>,
|
|
95
|
-
JsonCompatibleReadOnly,
|
|
96
|
-
JsonCompatibleReadOnly,
|
|
97
|
-
MessageEncodingContext
|
|
98
|
-
> {
|
|
99
|
-
return withSchemaValidation<
|
|
100
|
-
DecodedMessage<TChangeset>,
|
|
101
|
-
TAnySchema,
|
|
102
|
-
JsonCompatibleReadOnly,
|
|
103
|
-
JsonCompatibleReadOnly,
|
|
104
|
-
MessageEncodingContext
|
|
105
|
-
>(
|
|
106
|
-
Message(changeCodec.encodedSchema ?? Type.Any()),
|
|
107
|
-
{
|
|
108
|
-
encode: (
|
|
109
|
-
{ commit, sessionId: originatorId }: DecodedMessage<TChangeset>,
|
|
110
|
-
context: MessageEncodingContext,
|
|
111
|
-
) => {
|
|
112
|
-
const message: Message = {
|
|
113
|
-
revision: revisionTagCodec.encode(commit.revision, {
|
|
114
|
-
originatorId,
|
|
115
|
-
idCompressor: context.idCompressor,
|
|
116
|
-
revision: undefined,
|
|
117
|
-
}),
|
|
118
|
-
originatorId,
|
|
119
|
-
changeset: changeCodec.encode(commit.change, {
|
|
120
|
-
originatorId,
|
|
121
|
-
schema: context.schema,
|
|
122
|
-
idCompressor: context.idCompressor,
|
|
123
|
-
revision: commit.revision,
|
|
124
|
-
}),
|
|
125
|
-
version,
|
|
126
|
-
};
|
|
127
|
-
return message as unknown as JsonCompatibleReadOnly;
|
|
128
|
-
},
|
|
129
|
-
decode: (encoded: JsonCompatibleReadOnly, context: MessageEncodingContext) => {
|
|
130
|
-
const {
|
|
131
|
-
revision: encodedRevision,
|
|
132
|
-
originatorId,
|
|
133
|
-
changeset,
|
|
134
|
-
} = encoded as unknown as Message;
|
|
135
|
-
|
|
136
|
-
const revision = revisionTagCodec.decode(encodedRevision, {
|
|
137
|
-
originatorId,
|
|
138
|
-
revision: undefined,
|
|
139
|
-
idCompressor: context.idCompressor,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
commit: {
|
|
144
|
-
revision,
|
|
145
|
-
change: changeCodec.decode(changeset, {
|
|
146
|
-
originatorId,
|
|
147
|
-
revision,
|
|
148
|
-
idCompressor: context.idCompressor,
|
|
149
|
-
}),
|
|
150
|
-
},
|
|
151
|
-
sessionId: originatorId,
|
|
152
|
-
};
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
options.jsonValidator,
|
|
156
|
-
);
|
|
157
|
-
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SessionId } from "@fluidframework/id-compressor";
|
|
7
|
+
import { type TSchema, Type } from "@sinclair/typebox";
|
|
8
|
+
|
|
9
|
+
import { type EncodedRevisionTag, RevisionTagSchema, SessionIdSchema } from "../core/index.js";
|
|
10
|
+
import type { JsonCompatibleReadOnly } from "../util/index.js";
|
|
11
|
+
import type { EncodedBranchId } from "./branch.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The format of messages that SharedTree sends and receives.
|
|
15
|
+
*/
|
|
16
|
+
export interface Message {
|
|
17
|
+
/**
|
|
18
|
+
* The revision tag for the change in this message
|
|
19
|
+
*/
|
|
20
|
+
readonly revision?: EncodedRevisionTag;
|
|
21
|
+
/**
|
|
22
|
+
* The stable ID that identifies the originator of the message.
|
|
23
|
+
*/
|
|
24
|
+
readonly originatorId: SessionId;
|
|
25
|
+
/**
|
|
26
|
+
* The changeset to be applied.
|
|
27
|
+
*/
|
|
28
|
+
readonly changeset?: JsonCompatibleReadOnly;
|
|
29
|
+
|
|
30
|
+
readonly branchId?: EncodedBranchId;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The version of the message. This controls how the message is encoded.
|
|
34
|
+
*
|
|
35
|
+
* This was not set historically and was added before making any breaking changes to the format.
|
|
36
|
+
* For that reason, absence of a 'version' field is synonymous with version 1.
|
|
37
|
+
*/
|
|
38
|
+
readonly version?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Return type is intentionally derived.
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
43
|
+
export const Message = <ChangeSchema extends TSchema>(tChange: ChangeSchema) =>
|
|
44
|
+
Type.Object({
|
|
45
|
+
revision: Type.Optional(RevisionTagSchema),
|
|
46
|
+
originatorId: SessionIdSchema,
|
|
47
|
+
changeset: Type.Optional(tChange),
|
|
48
|
+
branchId: Type.Optional(Type.Number()),
|
|
49
|
+
version: Type.Optional(Type.Number()),
|
|
50
|
+
});
|
|
@@ -6,8 +6,21 @@
|
|
|
6
6
|
import type { SessionId } from "@fluidframework/id-compressor";
|
|
7
7
|
|
|
8
8
|
import type { GraphCommit } from "../core/index.js";
|
|
9
|
+
import type { BranchId } from "./branch.js";
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
|
|
11
|
+
export type DecodedMessage<TChange> = CommitMessage<TChange> | BranchMessage;
|
|
12
|
+
|
|
13
|
+
export interface MessageBase {
|
|
12
14
|
sessionId: SessionId;
|
|
13
15
|
}
|
|
16
|
+
|
|
17
|
+
export interface CommitMessage<TChange> extends MessageBase {
|
|
18
|
+
type: "commit";
|
|
19
|
+
commit: GraphCommit<TChange>;
|
|
20
|
+
branchId: BranchId;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface BranchMessage extends MessageBase {
|
|
24
|
+
type: "branch";
|
|
25
|
+
branchId: BranchId;
|
|
26
|
+
}
|
|
@@ -7,7 +7,7 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
|
|
8
8
|
import { brand } from "../util/index.js";
|
|
9
9
|
|
|
10
|
-
import type { SequenceId } from "./
|
|
10
|
+
import type { SequenceId } from "./editManagerFormatCommons.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Compares two sequenceIds. Returns a negative number if a \< b, a positive number if a \> b, and 0 if a === b.
|