@fluidframework/tree 2.93.0 → 2.101.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 +74 -0
- package/INCREMENTAL_SUMMARY.md +89 -0
- package/README.md +6 -0
- package/api-report/tree.alpha.api.md +6 -1
- package/api-report/tree.beta.api.md +3 -1
- package/api-report/tree.legacy.beta.api.md +3 -1
- package/dist/core/change-family/changeFamily.d.ts +23 -0
- package/dist/core/change-family/changeFamily.d.ts.map +1 -1
- package/dist/core/change-family/changeFamily.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +2 -0
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +2 -0
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +25 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +71 -18
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +13 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +31 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +27 -0
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +5 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +10 -2
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +7 -2
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js +0 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +10 -2
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js +15 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -1
- package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +3 -3
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +8 -8
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +6 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +25 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +76 -22
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -14
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js +1 -17
- package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +2 -0
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +35 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +6 -0
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +1 -0
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +2 -0
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +2 -0
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -0
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +14 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsCommons.js +14 -0
- package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -0
- package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -0
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +9 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +20 -5
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js +4 -0
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +4 -0
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +4 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +3 -3
- package/dist/simple-tree/api/schemaFactory.js +3 -3
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +9 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +102 -20
- package/dist/tableSchema.js.map +1 -1
- package/docs/user-facing/isolated-declarations.md +147 -0
- package/lib/core/change-family/changeFamily.d.ts +23 -0
- package/lib/core/change-family/changeFamily.d.ts.map +1 -1
- package/lib/core/change-family/changeFamily.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +2 -0
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +2 -0
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +25 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +72 -19
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +13 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +32 -5
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +27 -0
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +6 -3
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +10 -2
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +8 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js +0 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +10 -2
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js +13 -0
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -1
- package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +3 -3
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +8 -8
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +6 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +26 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +76 -22
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -14
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js +1 -17
- package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +4 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -0
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +35 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +6 -0
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +1 -0
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +2 -0
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +2 -0
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -0
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +14 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsCommons.js +14 -0
- package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -0
- package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -0
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +9 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +20 -5
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js +4 -0
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +4 -0
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +4 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +3 -3
- package/lib/simple-tree/api/schemaFactory.js +3 -3
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +9 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +103 -21
- package/lib/tableSchema.js.map +1 -1
- package/package.json +24 -24
- package/src/core/change-family/changeFamily.ts +25 -0
- package/src/core/tree/detachedFieldIndexCodecV1.ts +2 -0
- package/src/core/tree/detachedFieldIndexCodecV2.ts +2 -0
- package/src/feature-libraries/chunked-forest/basicChunk.ts +76 -20
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +61 -12
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +34 -1
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +9 -3
- package/src/feature-libraries/chunked-forest/codec/format/formatGeneric.ts +0 -1
- package/src/feature-libraries/chunked-forest/codec/format/index.ts +1 -0
- package/src/feature-libraries/chunked-forest/codec/format/versions.ts +15 -0
- package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +9 -1
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -1
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +32 -2
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +116 -31
- package/src/feature-libraries/modular-schema/genericFieldKindFormat.ts +3 -21
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +2 -0
- package/src/shared-tree/sharedTree.ts +41 -1
- package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -0
- package/src/shared-tree/treeAlpha.ts +2 -0
- package/src/shared-tree/treeCheckout.ts +2 -0
- package/src/shared-tree-core/editManagerCodecs.ts +3 -0
- package/src/shared-tree-core/editManagerCodecsCommons.ts +29 -0
- package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -0
- package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -0
- package/src/shared-tree-core/editManagerSummarizer.ts +17 -5
- package/src/shared-tree-core/messageCodecV1ToV4.ts +4 -0
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +5 -1
- package/src/shared-tree-core/sharedTreeCore.ts +8 -1
- package/src/simple-tree/api/schemaFactory.ts +3 -3
- package/src/simple-tree/api/schemaFactoryAlpha.ts +34 -3
- package/src/tableSchema.ts +134 -35
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incrementalSummaryBuilder.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAIxE,OAAO,EACN,KAAK,EACL,cAAc,EACd,mBAAmB,GAGnB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAkF7D;;GAEG;AACH,MAAM,CAAN,IAAY,gCAgBX;AAhBD,WAAY,gCAAgC;IAC3C;;;;OAIG;IACH,qGAAW,CAAA;IACX;;;;;;;OAOG;IACH,mGAAU,CAAA;AACX,CAAC,EAhBW,gCAAgC,KAAhC,gCAAgC,QAgB3C;AAED,4CAA4C;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,2CAA2C;AAC3C,MAAM,OAAO,+BAA+B;IAgB3C;;;;OAIG;IACH,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,wBAAwB,KAAK,SAAS,CAAC;IACpD,CAAC;IA8BD,YACkB,wBAAiC,EACjC,gBAAiE,EAClE,yBAAoD,EACnD,qBAA6B;QAH7B,6BAAwB,GAAxB,wBAAwB,CAAS;QACjC,qBAAgB,GAAhB,gBAAgB,CAAiD;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Y,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;QAEhE,8EAA8E;QAC9E,gFAAgF;QAChF,sFAAsF;QACtF,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,mGAAmG;QACnG,mGAAmG;QACnG,yCAAyC;QACzC,cAAc,CAAC,IAAI,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE;YAClF,WAAW;YACX,WAAW,EAAE,mBAAmB,CAAC,WAAW;SAC5C,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport type { IExperimentalIncrementalSummaryContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ITreeCursorSynchronous } from \"../../core/index.js\";\nimport type { SummaryElementStringifier } from \"../../shared-tree-core/index.js\";\nimport {\n\tbrand,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n\ttype JsonCompatible,\n\ttype NestedMap,\n} from \"../../util/index.js\";\nimport type {\n\tChunkReferenceId,\n\tEncodedFieldBatchV2,\n\tIncrementalEncoderDecoder,\n\tIncrementalEncodingPolicy,\n\tTreeChunk,\n} from \"../chunked-forest/index.js\";\n\nimport { summaryContentBlobKey } from \"./summaryFormatV3.js\";\n\n/**\n * The properties of a chunk tracked during the loading process.\n * These are used to identify a chunk when it is decoded and recreate the tracking state\n * as it was when the summary that the client is loading from was generated.\n *\n * An encoded chunk, paired with a location it can be reused / reloaded from.\n * @remarks\n * This identifies a location in a specific summary where `encodedContents` was loaded from.\n *\n * When summarizing, Fluid always ensures the summary that the summary client is allowed to reuse content from\n * is the one it loaded from, so tracking this on load is sufficient for now:\n * there is no need to track the equivalent data when summarizing.\n */\ninterface ChunkLoadProperties {\n\t/**\n\t * The encoded contents of the chunk.\n\t */\n\treadonly encodedContents: EncodedFieldBatchV2;\n\t/**\n\t * The path for this chunk's contents in the summary tree relative to the forest's summary tree.\n\t * This path is used to generate a summary handle for the chunk if it doesn't change between summaries.\n\t */\n\treadonly summaryPath: string;\n}\n\n/**\n * The properties of a chunk that is tracked for every summary.\n * If a chunk doesn't change between summaries,\n * these properties will be used to generate a summary handle for the chunk.\n */\ninterface ChunkSummaryProperties {\n\t/**\n\t * The reference ID of the chunk which uniquely identifies it under its parent's summary tree.\n\t * The summary for this chunk will be stored against this reference ID as key in the summary tree.\n\t */\n\treadonly referenceId: ChunkReferenceId;\n\t/**\n\t * The path for this chunk's summary in the summary tree relative to the forest's summary tree.\n\t * This path is used to generate a summary handle for the chunk if it doesn't change between summaries.\n\t */\n\treadonly summaryPath: string;\n}\n\n/**\n * The properties of a summary being tracked.\n */\ninterface TrackedSummaryProperties {\n\t/**\n\t * The sequence number of the summary in progress.\n\t */\n\treadonly summarySequenceNumber: number;\n\t/**\n\t * The base path for the latest summary that was successful.\n\t * This is used to generate summary handles.\n\t */\n\treadonly latestSummaryBasePath: string;\n\t/**\n\t * Whether the summary being tracked is a full tree summary.\n\t * If true, the summary will not contain any summary handles. All chunks must be summarized in full.\n\t */\n\treadonly fullTree: boolean;\n\t/**\n\t * Represents the path of a chunk in the summary tree relative to the forest's summary tree.\n\t * Each item in the array is the {@link ChunkReferenceId} of a chunk in the summary tree starting\n\t * from the chunk under forest summary tree.\n\t * When a chunk is summarized, this array will be used to generate the path for the chunk's summary in the\n\t * summary tree.\n\t */\n\treadonly chunkSummaryPath: ChunkReferenceId[];\n\t/**\n\t * The parent summary builder to use to build the incremental summary tree.\n\t * When a chunk is being summarized, it will add its summary to this builder against its reference ID.\n\t */\n\tparentSummaryBuilder: SummaryTreeBuilder;\n\t/**\n\t * Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t */\n\tstringify: SummaryElementStringifier;\n}\n\n/**\n * The behavior of the forest's incremental summary - whether the summary should be a single blob or incremental.\n */\nexport enum ForestIncrementalSummaryBehavior {\n\t/**\n\t * The forest can encode chunks incrementally, i.e., chunks that support incremental encoding will be encoded\n\t * separately - they will be added to a separate tree.\n\t * The incremental summary format is described in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tIncremental,\n\t/**\n\t * The forest should encode all of it's data in a single summary blob.\n\t * @remarks\n\t * The format of the summary will be the same as the old format (pre-incremental summaries) and is fully\n\t * backwards compatible with the old format. The summary will basically look like an incremental summary\n\t * with no incremental fields - it will only contain the \"ForestTree\" blob in the summary format described\n\t * in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tSingleBlob,\n}\n\n/* eslint-disable jsdoc/check-indentation */\n/**\n * Tracks and builds the incremental summary tree for a forest where chunks that support incremental encoding are\n * stored in a separate tree in the summary under its {@link ChunkReferenceId}.\n * The summary tree for a chunk is self-sufficient and can be independently loaded and used to reconstruct the\n * chunk's contents without any additional context from its parent.\n *\n * An example summary tree with incremental summary:\n * Forest\n * ├── contents\n * ├── 0\n * | ├── contents\n * | ├── 1\n * | | ├── contents\n * | | ├── 2\n * | | | ├── contents\n * | ├── 3 - \".../Forest/ForestTree/0/1/3\"\n * ├── 4\n * | ├── contents\n * | ├── ...\n * ├── 5 - \"/.../Forest/ForestTree/5\"\n * - Forest is a summary tree node added by the shared tree and contains the following:\n * - The inline portion of the top-level forest content is stored in a summary blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - For each chunk, the structure of the summary tree is the same as the Forest. It contains the following:\n * - The inline portion of the chunk content is stored in a blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - Chunks that do not change between summaries are summarized as handles in the summary tree.\n *\n * TODO: AB#46752\n * Add strong types for the summary structure to document it better. It will help make it super clear what the actual\n * format is in a way that can easily be linked to, documented and inspected.\n */\n/* eslint-enable jsdoc/check-indentation */\nexport class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecoder {\n\t/**\n\t * The next reference ID to use for a chunk.\n\t */\n\tprivate nextReferenceId: ChunkReferenceId = brand(0);\n\n\t/**\n\t * For a given summary sequence number, keeps track of a chunk's properties that will be used to generate\n\t * a summary handle for the chunk if it does not change between summaries.\n\t */\n\tprivate readonly chunkTrackingPropertiesMap: NestedMap<\n\t\tnumber,\n\t\tTreeChunk,\n\t\tChunkSummaryProperties\n\t> = new Map();\n\n\t/**\n\t * True when encoding a summary, false otherwise.\n\t * @remarks\n\t * Exposed for testing purposes.\n\t */\n\tpublic get isSummarizing(): boolean {\n\t\treturn this.trackedSummaryProperties !== undefined;\n\t}\n\t/**\n\t * The sequence number of the latest summary that was successful.\n\t */\n\tprivate latestSummarySequenceNumber: number = -1;\n\n\t/**\n\t * The current state of the summary being \"tracked\".\n\t * @remarks\n\t * A summary being \"tracked\" means that a summary is being encoded.\n\t * This is undefined if no summary is currently being encoded.\n\t *\n\t * @privateRemarks\n\t * This has nothing to do which how content from a summary being loaded is tracked (thats written all in chunkTrackingPropertiesMap).\n\t * \"Tracked\" should probably be renamed to \"encoded\" or \"summarizing\" or something like that to avoid confusion.\n\t * Perhaps a better way to clarify this would be to not store this property on this object at all, and have it\n\t * only exist within the scope of the summary encoding (use an encoding specific object to accumulate any stat necessary during encode).\n\t */\n\tprivate trackedSummaryProperties: TrackedSummaryProperties | undefined;\n\n\t/**\n\t * A map of chunk reference IDs to their encoded contents. This is typically used during the loading of the\n\t * forest to retrieve the contents of the chunks that were summarized incrementally.\n\t */\n\t/**\n\t * A map of chunk reference IDs to their {@link ChunkLoadProperties}.\n\t * This is used during the loading of the forest to track each chunk that is retrieved and decoded.\n\t */\n\tprivate readonly loadedChunksMap: Map<string, ChunkLoadProperties> = new Map();\n\n\tpublic constructor(\n\t\tprivate readonly enableIncrementalSummary: boolean,\n\t\tprivate readonly getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk[],\n\t\tpublic readonly shouldEncodeIncrementally: IncrementalEncodingPolicy,\n\t\tprivate readonly initialSequenceNumber: number,\n\t) {}\n\n\t/**\n\t * Must be called when the forest is loaded to download the encoded contents of incremental chunks.\n\t * @param services - The channel storage service to use to access the snapshot tree and download the\n\t * contents of the chunks.\n\t * @param readAndParse - A function that reads and parses a blob from the storage service.\n\t */\n\tpublic async load(args: {\n\t\tservices: IChannelStorageService;\n\t\treadAndParseChunk: (chunkBlobPath: string) => Promise<JsonCompatible<IFluidHandle>>;\n\t}): Promise<void> {\n\t\tconst forestTree = args.services.getSnapshotTree?.();\n\t\t// Snapshot tree should be available when loading forest's contents. However, it is an optional function\n\t\t// and may not be implemented by the storage service.\n\t\tif (forestTree === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Downloads the contents of incremental chunks in the given snapshot tree. Also, recursively downloads\n\t\t// the contents of incremental chunks in any sub-trees.\n\t\tconst downloadChunkContentsInTree = async (\n\t\t\tsnapshotTree: ISnapshotTree,\n\t\t\tparentTreeKey: string,\n\t\t): Promise<void> => {\n\t\t\t// All trees in the snapshot tree are for incremental chunks. The key is the chunk's reference ID\n\t\t\t// and the value is the snapshot tree for the chunk.\n\t\t\tfor (const [chunkReferenceId, chunkSnapshotTree] of Object.entries(snapshotTree.trees)) {\n\t\t\t\tconst chunkSubTreePath = `${parentTreeKey}${chunkReferenceId}`;\n\t\t\t\tconst chunkContentsPath = `${chunkSubTreePath}/${summaryContentBlobKey}`;\n\t\t\t\tif (!(await args.services.contains(chunkContentsPath))) {\n\t\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\t`SharedTree: Cannot find contents for incremental chunk ${chunkContentsPath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst chunkContents = (await args.readAndParseChunk(\n\t\t\t\t\tchunkContentsPath,\n\t\t\t\t)) as EncodedFieldBatchV2; // TODO: this should use a codec to validate the data instead of just type casting.\n\t\t\t\tthis.loadedChunksMap.set(chunkReferenceId, {\n\t\t\t\t\tencodedContents: chunkContents,\n\t\t\t\t\tsummaryPath: chunkSubTreePath,\n\t\t\t\t});\n\n\t\t\t\tconst chunkReferenceIdNumber = Number(chunkReferenceId);\n\t\t\t\tthis.nextReferenceId = brand(\n\t\t\t\t\tMath.max(this.nextReferenceId, chunkReferenceIdNumber + 1),\n\t\t\t\t);\n\n\t\t\t\t// Recursively download the contents of chunks in this chunk's sub tree.\n\t\t\t\tawait downloadChunkContentsInTree(chunkSnapshotTree, `${chunkSubTreePath}/`);\n\t\t\t}\n\t\t};\n\t\tawait downloadChunkContentsInTree(forestTree, \"\");\n\t}\n\n\t/**\n\t * Asserts that a summary is currently being tracked and that the tracked summary properties are defined.\n\t * @returns The properties of the tracked summary.\n\t */\n\tprivate requireTrackingSummary(): TrackedSummaryProperties {\n\t\tassert(this.trackedSummaryProperties !== undefined, 0xc22 /* Not tracking a summary */);\n\t\treturn this.trackedSummaryProperties;\n\t}\n\n\t/**\n\t * Must be called when starting a new forest summary to track it.\n\t * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain\n\t * any summary handles. All chunks must be summarized in full.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers\n\t * for the current and latest summaries.\n\t * @param stringify - Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t * @returns the behavior of the forest's incremental summary.\n\t */\n\tpublic startSummary(args: {\n\t\tfullTree: boolean;\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tstringify: SummaryElementStringifier;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): ForestIncrementalSummaryBehavior {\n\t\tassert(\n\t\t\tthis.trackedSummaryProperties === undefined,\n\t\t\t0xc24 /* Already tracking a summary */,\n\t\t);\n\n\t\tconst { fullTree, incrementalSummaryContext, stringify, builder } = args;\n\t\t// If there is no incremental summary context, do not summarize incrementally. This happens in two scenarios:\n\t\t// 1. When summarizing a detached container, i.e., the first ever summary.\n\t\t// 2. When running GC, the default behavior is to call summarize on DDS without incrementalSummaryContext.\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\treturn ForestIncrementalSummaryBehavior.SingleBlob;\n\t\t}\n\n\t\tthis.latestSummarySequenceNumber = incrementalSummaryContext.latestSummarySequenceNumber;\n\t\tthis.trackedSummaryProperties = {\n\t\t\tsummarySequenceNumber: incrementalSummaryContext.summarySequenceNumber,\n\t\t\tlatestSummaryBasePath: incrementalSummaryContext.summaryPath,\n\t\t\tchunkSummaryPath: [],\n\t\t\tparentSummaryBuilder: builder,\n\t\t\tfullTree,\n\t\t\tstringify,\n\t\t};\n\t\treturn ForestIncrementalSummaryBehavior.Incremental;\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.encodeIncrementalField}\n\t * @remarks Returns an empty array if the field has no content.\n\t */\n\tpublic encodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2,\n\t): ChunkReferenceId[] {\n\t\t// Validate that a summary is currently being tracked and that the tracked summary properties are defined.\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tconst chunkReferenceIds: ChunkReferenceId[] = [];\n\t\tconst chunks = this.getChunkAtCursor(cursor);\n\t\tfor (const chunk of chunks) {\n\t\t\tlet chunkProperties: ChunkSummaryProperties;\n\n\t\t\t// Try and get the properties of the chunk from the latest successful summary.\n\t\t\t// If it exists and the summary is not a full tree, use the properties to generate a summary handle.\n\t\t\t// If it does not exist, encode the chunk and generate new properties for it.\n\t\t\tconst previousChunkProperties = tryGetFromNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\tthis.latestSummarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t);\n\t\t\tif (previousChunkProperties !== undefined && !trackedSummaryProperties.fullTree) {\n\t\t\t\tchunkProperties = previousChunkProperties;\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder.addHandle(\n\t\t\t\t\t`${chunkProperties.referenceId}`,\n\t\t\t\t\tSummaryType.Tree,\n\t\t\t\t\t`${trackedSummaryProperties.latestSummaryBasePath}/${chunkProperties.summaryPath}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Generate a new reference ID for the chunk.\n\t\t\t\tconst newReferenceId: ChunkReferenceId = brand(this.nextReferenceId++);\n\n\t\t\t\t// Add the reference ID of this chunk to the chunk summary path and use the path as the summary path\n\t\t\t\t// for the chunk in its summary properties.\n\t\t\t\t// This is done before encoding the chunk so that the summary path is updated correctly when encoding\n\t\t\t\t// any incremental chunks that are under this chunk.\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.push(newReferenceId);\n\n\t\t\t\tchunkProperties = {\n\t\t\t\t\treferenceId: newReferenceId,\n\t\t\t\t\tsummaryPath: trackedSummaryProperties.chunkSummaryPath.join(\"/\"),\n\t\t\t\t};\n\n\t\t\t\tconst parentSummaryBuilder = trackedSummaryProperties.parentSummaryBuilder;\n\t\t\t\t// Create a new summary builder for this chunk to build its summary tree which will be stored in the\n\t\t\t\t// parent's summary tree under its reference ID.\n\t\t\t\t// Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that\n\t\t\t\t// any incremental chunks in the subtree of this chunk will use that as their parent summary builder.\n\t\t\t\tconst chunkSummaryBuilder = new SummaryTreeBuilder();\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;\n\t\t\t\tchunkSummaryBuilder.addBlob(\n\t\t\t\t\tsummaryContentBlobKey,\n\t\t\t\t\ttrackedSummaryProperties.stringify(chunkEncoder(chunk)),\n\t\t\t\t);\n\n\t\t\t\t// Add this chunk's summary tree to the parent's summary tree. The summary tree contains its encoded\n\t\t\t\t// contents and the summary trees of any incremental chunks under it.\n\t\t\t\tparentSummaryBuilder.addWithStats(\n\t\t\t\t\t`${newReferenceId}`,\n\t\t\t\t\tchunkSummaryBuilder.getSummaryTree(),\n\t\t\t\t);\n\n\t\t\t\t// Restore the parent summary builder and chunk summary path.\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.pop();\n\t\t\t}\n\n\t\t\tsetInNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t\tchunkProperties,\n\t\t\t);\n\t\t\tchunkReferenceIds.push(chunkProperties.referenceId);\n\t\t}\n\t\treturn chunkReferenceIds;\n\t}\n\n\t/**\n\t * Must be called after summary generation is complete to finish tracking the summary.\n\t * It clears any tracking state and deletes the tracking properties for summaries that are older than the\n\t * latest successful summary.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers.\n\t * If this is undefined, the summary tree will only contain a summary blob for `forestSummaryRootContent`.\n\t * @param forestSummaryRootContent - The stringified ForestCodec output of top-level Forest content.\n\t * @param forestSummaryRootContentKey - The key to use for the blob containing `forestSummaryRootContent`.\n\t * @param builder - The summary tree builder to use to add the forest's contents. Note that if tracking an incremental\n\t * summary, this builder will be the same as the one tracked in `trackedSummaryProperties`.\n\t * @returns the Forest's summary tree.\n\t */\n\tpublic completeSummary(args: {\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tforestSummaryRootContent: string;\n\t\tforestSummaryRootContentKey: string;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst {\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryRootContent,\n\t\t\tforestSummaryRootContentKey,\n\t\t\tbuilder,\n\t\t} = args;\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\t\t\treturn;\n\t\t}\n\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\n\t\t// Copy over the entries from the latest summary to the current summary.\n\t\t// In the current summary, there can be fields that haven't changed since the latest summary and the chunks\n\t\t// in these fields and in any of its children weren't encoded. So, we need get the entries for these chunks\n\t\t// to be able to incrementally summarize them in the next summary.\n\t\tconst latestSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\tthis.latestSummarySequenceNumber,\n\t\t);\n\t\tconst currentSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t);\n\t\tif (latestSummaryTrackingMap !== undefined && currentSummaryTrackingMap !== undefined) {\n\t\t\tfor (const [chunk, chunkProperties] of latestSummaryTrackingMap.entries()) {\n\t\t\t\tif (!currentSummaryTrackingMap.has(chunk)) {\n\t\t\t\t\tcurrentSummaryTrackingMap.set(chunk, chunkProperties);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Delete tracking for summaries that are older than the latest successful summary because they will\n\t\t// never be referenced again for generating summary handles.\n\t\tfor (const sequenceNumber of this.chunkTrackingPropertiesMap.keys()) {\n\t\t\tif (sequenceNumber < this.latestSummarySequenceNumber) {\n\t\t\t\tthis.chunkTrackingPropertiesMap.delete(sequenceNumber);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackedSummaryProperties = undefined;\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.decodeIncrementalChunk}\n\t */\n\tpublic decodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk,\n\t): TreeChunk {\n\t\tconst ChunkLoadProperties = this.loadedChunksMap.get(`${referenceId}`);\n\t\tassert(ChunkLoadProperties !== undefined, 0xc86 /* Encoded incremental chunk not found */);\n\t\tconst chunk = chunkDecoder(ChunkLoadProperties.encodedContents);\n\n\t\t// Account for the reference about to be added in `chunkTrackingPropertiesMap`\n\t\t// to ensure that no other users of this chunk think they have unique ownership.\n\t\t// This prevents prevent whoever this chunk is returned to from modifying it in-place.\n\t\tchunk.referenceAdded();\n\t\t// Track the decoded chunk. This will recreate the tracking state when the summary that this client\n\t\t// is loaded from was generated. This is needed to ensure that incremental summaries work correctly\n\t\t// when a new client starts to summarize.\n\t\tsetInNestedMap(this.chunkTrackingPropertiesMap, this.initialSequenceNumber, chunk, {\n\t\t\treferenceId,\n\t\t\tsummaryPath: ChunkLoadProperties.summaryPath,\n\t\t});\n\t\treturn chunk;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"incrementalSummaryBuilder.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAIxE,OAAO,EACN,KAAK,EACL,cAAc,EACd,mBAAmB,GAGnB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAqG7D;;GAEG;AACH,MAAM,CAAN,IAAY,gCAgBX;AAhBD,WAAY,gCAAgC;IAC3C;;;;OAIG;IACH,qGAAW,CAAA;IACX;;;;;;;OAOG;IACH,mGAAU,CAAA;AACX,CAAC,EAhBW,gCAAgC,KAAhC,gCAAgC,QAgB3C;AAED,4CAA4C;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,2CAA2C;AAC3C,MAAM,OAAO,+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D;QAC5D,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC;YACrE,IAAI,cAAc,GAAG,IAAI,CAAC,2BAA2B,EAAE,CAAC;gBACvD,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACxD,CAAC;QACF,CAAC;QAED,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,sBAAsB,CAC5B,WAA6B,EAC7B,YAAyD;QAEzD,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,mBAAmB,KAAK,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,YAAY,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;QAEhE,8EAA8E;QAC9E,gFAAgF;QAChF,sFAAsF;QACtF,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,mGAAmG;QACnG,mGAAmG;QACnG,yCAAyC;QACzC,cAAc,CAAC,IAAI,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE;YAClF,WAAW;YACX,iBAAiB,EAAE,mBAAmB,CAAC,iBAAiB;SACxD,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport type { IExperimentalIncrementalSummaryContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ITreeCursorSynchronous } from \"../../core/index.js\";\nimport type { SummaryElementStringifier } from \"../../shared-tree-core/index.js\";\nimport {\n\tbrand,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n\ttype JsonCompatible,\n\ttype NestedMap,\n} from \"../../util/index.js\";\nimport type {\n\tChunkReferenceId,\n\tEncodedFieldBatchV2,\n\tIncrementalEncoderDecoder,\n\tIncrementalEncodingPolicy,\n\tTreeChunk,\n} from \"../chunked-forest/index.js\";\n\nimport { summaryContentBlobKey } from \"./summaryFormatV3.js\";\n\n/**\n * The properties of a chunk tracked during the loading process.\n * These are used to identify a chunk when it is decoded and recreate the tracking state\n * as it was when the summary that the client is loading from was generated.\n *\n * An encoded chunk, paired with a location it can be reused / reloaded from.\n * @remarks\n * This identifies a location in a specific summary where `encodedContents` was loaded from.\n *\n * When summarizing, Fluid always ensures the summary that the summary client is allowed to reuse content from\n * is the one it loaded from, so tracking this on load is sufficient for now:\n * there is no need to track the equivalent data when summarizing.\n */\ninterface ChunkLoadProperties {\n\t/**\n\t * The encoded contents of the chunk.\n\t */\n\treadonly encodedContents: EncodedFieldBatchV2;\n\t/**\n\t * The reference ID of this chunk's parent in the summary tree, or `undefined` if this chunk is\n\t * at the top level (directly under the forest summary tree).\n\t * Stored here so that {@link ForestIncrementalSummaryBuilder.decodeIncrementalChunk} can\n\t * reconstruct the correct {@link ChunkSummaryProperties} without re-parsing a path string.\n\t */\n\treadonly parentReferenceId: ChunkReferenceId | undefined;\n}\n\n/**\n * The properties of a chunk that is tracked for every summary.\n * If a chunk doesn't change between summaries,\n * these properties will be used to generate a summary handle for the chunk.\n */\ninterface ChunkSummaryProperties {\n\t/**\n\t * The reference ID of the chunk which uniquely identifies it under its parent's summary tree.\n\t * The summary for this chunk will be stored against this reference ID as key in the summary tree.\n\t */\n\treadonly referenceId: ChunkReferenceId;\n\t/**\n\t * The reference ID of this chunk's parent in the summary tree, or `undefined` if this chunk\n\t * is at the top level (has no incremental parent).\n\t *\n\t * @remarks\n\t * Storing only the immediate parent (rather than the full path string) keeps every chunk's\n\t * tracking entry correct even when an ancestor is re-encoded and receives a new reference ID.\n\t * The full summary path is computed on demand by {@link ForestIncrementalSummaryBuilder.computeHandlePathInLatestSummary}\n\t * by walking up the parent chain through {@link TrackedSummaryProperties.latestSummaryRefIdMap}.\n\t *\n\t * If a parent chunk is encoded as a handle in the current summary its reference ID is unchanged,\n\t * so its children's `parentReferenceId` values copied forward by `completeSummary` remain valid\n\t * without any additional update.\n\t */\n\treadonly parentReferenceId: ChunkReferenceId | undefined;\n}\n\n/**\n * The properties of a summary being tracked.\n */\ninterface TrackedSummaryProperties {\n\t/**\n\t * The sequence number of the summary in progress.\n\t */\n\treadonly summarySequenceNumber: number;\n\t/**\n\t * The base path for the latest summary that was successful.\n\t * This is used to generate summary handles.\n\t */\n\treadonly latestSummaryBasePath: string;\n\t/**\n\t * Whether the summary being tracked is a full tree summary.\n\t * If true, the summary will not contain any summary handles. All chunks must be summarized in full.\n\t */\n\treadonly fullTree: boolean;\n\t/**\n\t * Represents the path of a chunk in the summary tree relative to the forest's summary tree.\n\t * Each item in the array is the {@link ChunkReferenceId} of a chunk in the summary tree starting\n\t * from the chunk under forest summary tree.\n\t * When a chunk is summarized, this array will be used to generate the path for the chunk's summary in the\n\t * summary tree.\n\t */\n\treadonly chunkSummaryPath: ChunkReferenceId[];\n\t/**\n\t * The parent summary builder to use to build the incremental summary tree.\n\t * When a chunk is being summarized, it will add its summary to this builder against its reference ID.\n\t */\n\tparentSummaryBuilder: SummaryTreeBuilder;\n\t/**\n\t * Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t */\n\tstringify: SummaryElementStringifier;\n\t/**\n\t * Reverse lookup map for the latest summary: maps each chunk's {@link ChunkReferenceId} to its\n\t * {@link ChunkSummaryProperties}.\n\t * Used by {@link ForestIncrementalSummaryBuilder.computeHandlePathInLatestSummary} to traverse\n\t * the parent chain when generating handle paths.\n\t */\n\treadonly latestSummaryRefIdMap: Map<ChunkReferenceId, ChunkSummaryProperties>;\n}\n\n/**\n * The behavior of the forest's incremental summary - whether the summary should be a single blob or incremental.\n */\nexport enum ForestIncrementalSummaryBehavior {\n\t/**\n\t * The forest can encode chunks incrementally, i.e., chunks that support incremental encoding will be encoded\n\t * separately - they will be added to a separate tree.\n\t * The incremental summary format is described in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tIncremental,\n\t/**\n\t * The forest should encode all of it's data in a single summary blob.\n\t * @remarks\n\t * The format of the summary will be the same as the old format (pre-incremental summaries) and is fully\n\t * backwards compatible with the old format. The summary will basically look like an incremental summary\n\t * with no incremental fields - it will only contain the \"ForestTree\" blob in the summary format described\n\t * in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tSingleBlob,\n}\n\n/* eslint-disable jsdoc/check-indentation */\n/**\n * Tracks and builds the incremental summary tree for a forest where chunks that support incremental encoding are\n * stored in a separate tree in the summary under its {@link ChunkReferenceId}.\n * The summary tree for a chunk is self-sufficient and can be independently loaded and used to reconstruct the\n * chunk's contents without any additional context from its parent.\n *\n * An example summary tree with incremental summary:\n * Forest\n * ├── contents\n * ├── 0\n * | ├── contents\n * | ├── 1\n * | | ├── contents\n * | | ├── 2\n * | | | ├── contents\n * | ├── 3 - \".../Forest/ForestTree/0/1/3\"\n * ├── 4\n * | ├── contents\n * | ├── ...\n * ├── 5 - \"/.../Forest/ForestTree/5\"\n * - Forest is a summary tree node added by the shared tree and contains the following:\n * - The inline portion of the top-level forest content is stored in a summary blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - For each chunk, the structure of the summary tree is the same as the Forest. It contains the following:\n * - The inline portion of the chunk content is stored in a blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - Chunks that do not change between summaries are summarized as handles in the summary tree.\n *\n * TODO: AB#46752\n * Add strong types for the summary structure to document it better. It will help make it super clear what the actual\n * format is in a way that can easily be linked to, documented and inspected.\n */\n/* eslint-enable jsdoc/check-indentation */\nexport class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecoder {\n\t/**\n\t * The next reference ID to use for a chunk.\n\t */\n\tprivate nextReferenceId: ChunkReferenceId = brand(0);\n\n\t/**\n\t * For a given summary sequence number, keeps track of a chunk's properties that will be used to generate\n\t * a summary handle for the chunk if it does not change between summaries.\n\t *\n\t * @remarks\n\t * `chunk` (the TreeChunk object) is used as the map key by object identity.\n\t * This assumes each chunk appears at exactly one position in the forest — an invariant that holds because every\n\t * node in a tree has a single parent.\n\t * If the forest ever introduced structural sharing (two positions backed by the same TreeChunk object),\n\t * a second call here would silently overwrite the first entry, causing the first position's handle to point\n\t * to the second position's parent in subsequent summaries. In theory, this should be fine from summary perspective\n\t * because the chunk contents are the same. But, it could lead to confusing handle paths in the summary tree and\n\t * may lead to other unexpected behavior. Adequate tests should be added if structural sharing is introduced.\n\t */\n\tprivate readonly chunkTrackingPropertiesMap: NestedMap<\n\t\tnumber,\n\t\tTreeChunk,\n\t\tChunkSummaryProperties\n\t> = new Map();\n\n\t/**\n\t * True when encoding a summary, false otherwise.\n\t * @remarks\n\t * Exposed for testing purposes.\n\t */\n\tpublic get isSummarizing(): boolean {\n\t\treturn this.trackedSummaryProperties !== undefined;\n\t}\n\t/**\n\t * The sequence number of the latest summary that was successful.\n\t */\n\tprivate latestSummarySequenceNumber: number = -1;\n\n\t/**\n\t * The current state of the summary being \"tracked\".\n\t * @remarks\n\t * A summary being \"tracked\" means that a summary is being encoded.\n\t * This is undefined if no summary is currently being encoded.\n\t *\n\t * @privateRemarks\n\t * This has nothing to do which how content from a summary being loaded is tracked (thats written all in chunkTrackingPropertiesMap).\n\t * \"Tracked\" should probably be renamed to \"encoded\" or \"summarizing\" or something like that to avoid confusion.\n\t * Perhaps a better way to clarify this would be to not store this property on this object at all, and have it\n\t * only exist within the scope of the summary encoding (use an encoding specific object to accumulate any stat necessary during encode).\n\t */\n\tprivate trackedSummaryProperties: TrackedSummaryProperties | undefined;\n\n\t/**\n\t * A map of chunk reference IDs to their encoded contents. This is typically used during the loading of the\n\t * forest to retrieve the contents of the chunks that were summarized incrementally.\n\t */\n\t/**\n\t * A map of chunk reference IDs to their {@link ChunkLoadProperties}.\n\t * This is used during the loading of the forest to track each chunk that is retrieved and decoded.\n\t */\n\tprivate readonly loadedChunksMap: Map<string, ChunkLoadProperties> = new Map();\n\n\tpublic constructor(\n\t\tprivate readonly enableIncrementalSummary: boolean,\n\t\tprivate readonly getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk[],\n\t\tpublic readonly shouldEncodeIncrementally: IncrementalEncodingPolicy,\n\t\tprivate readonly initialSequenceNumber: number,\n\t) {}\n\n\t/**\n\t * Must be called when the forest is loaded to download the encoded contents of incremental chunks.\n\t * @param services - The channel storage service to use to access the snapshot tree and download the\n\t * contents of the chunks.\n\t * @param readAndParse - A function that reads and parses a blob from the storage service.\n\t */\n\tpublic async load(args: {\n\t\tservices: IChannelStorageService;\n\t\treadAndParseChunk: (chunkBlobPath: string) => Promise<JsonCompatible<IFluidHandle>>;\n\t}): Promise<void> {\n\t\tconst forestTree = args.services.getSnapshotTree?.();\n\t\t// Snapshot tree should be available when loading forest's contents. However, it is an optional function\n\t\t// and may not be implemented by the storage service.\n\t\tif (forestTree === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Downloads the contents of incremental chunks in the given snapshot tree. Also, recursively downloads\n\t\t// the contents of incremental chunks in any sub-trees.\n\t\tconst downloadChunkContentsInTree = async (\n\t\t\tsnapshotTree: ISnapshotTree,\n\t\t\tparentPathSegments: string[],\n\t\t\tparentReferenceId: ChunkReferenceId | undefined,\n\t\t): Promise<void> => {\n\t\t\t// All trees in the snapshot tree are for incremental chunks. The key is the chunk's reference ID\n\t\t\t// and the value is the snapshot tree for the chunk.\n\t\t\tfor (const [chunkReferenceId, chunkSnapshotTree] of Object.entries(snapshotTree.trees)) {\n\t\t\t\tconst chunkSubTreeSegments = [...parentPathSegments, chunkReferenceId];\n\t\t\t\tconst chunkSubTreePath = chunkSubTreeSegments.join(\"/\");\n\t\t\t\tconst chunkContentsPath = `${chunkSubTreePath}/${summaryContentBlobKey}`;\n\t\t\t\tif (!(await args.services.contains(chunkContentsPath))) {\n\t\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\t`SharedTree: Cannot find contents for incremental chunk ${chunkContentsPath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst chunkContents = (await args.readAndParseChunk(\n\t\t\t\t\tchunkContentsPath,\n\t\t\t\t)) as EncodedFieldBatchV2; // TODO: this should use a codec to validate the data instead of just type casting.\n\t\t\t\tthis.loadedChunksMap.set(chunkReferenceId, {\n\t\t\t\t\tencodedContents: chunkContents,\n\t\t\t\t\tparentReferenceId,\n\t\t\t\t});\n\n\t\t\t\tconst chunkReferenceIdNumber = Number(chunkReferenceId);\n\t\t\t\tthis.nextReferenceId = brand(\n\t\t\t\t\tMath.max(this.nextReferenceId, chunkReferenceIdNumber + 1),\n\t\t\t\t);\n\n\t\t\t\t// Recursively download the contents of chunks in this chunk's sub tree.\n\t\t\t\tawait downloadChunkContentsInTree(\n\t\t\t\t\tchunkSnapshotTree,\n\t\t\t\t\tchunkSubTreeSegments,\n\t\t\t\t\tbrand(chunkReferenceIdNumber),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\t// parentReferenceId is undefined for the root of the forest tree.\n\t\tawait downloadChunkContentsInTree(forestTree, [], undefined /* parentReferenceId */);\n\t}\n\n\t/**\n\t * Asserts that a summary is currently being tracked and that the tracked summary properties are defined.\n\t * @returns The properties of the tracked summary.\n\t */\n\tprivate requireTrackingSummary(): TrackedSummaryProperties {\n\t\tassert(this.trackedSummaryProperties !== undefined, 0xc22 /* Not tracking a summary */);\n\t\treturn this.trackedSummaryProperties;\n\t}\n\n\t/**\n\t * Must be called when starting a new forest summary to track it.\n\t * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain\n\t * any summary handles. All chunks must be summarized in full.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers\n\t * for the current and latest summaries.\n\t * @param stringify - Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t * @returns the behavior of the forest's incremental summary.\n\t */\n\tpublic startSummary(args: {\n\t\tfullTree: boolean;\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tstringify: SummaryElementStringifier;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): ForestIncrementalSummaryBehavior {\n\t\tassert(\n\t\t\tthis.trackedSummaryProperties === undefined,\n\t\t\t0xc24 /* Already tracking a summary */,\n\t\t);\n\n\t\tconst { fullTree, incrementalSummaryContext, stringify, builder } = args;\n\t\t// If there is no incremental summary context, do not summarize incrementally. This happens in two scenarios:\n\t\t// 1. When summarizing a detached container, i.e., the first ever summary.\n\t\t// 2. When running GC, the default behavior is to call summarize on DDS without incrementalSummaryContext.\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\treturn ForestIncrementalSummaryBehavior.SingleBlob;\n\t\t}\n\n\t\tthis.latestSummarySequenceNumber = incrementalSummaryContext.latestSummarySequenceNumber;\n\n\t\t// Build a reverse lookup map (referenceId → properties) for the latest summary so that\n\t\t// computeHandlePathInLatestSummary can traverse the parent chain without iterating the whole map.\n\t\tconst latestSummaryRefIdMap: Map<ChunkReferenceId, ChunkSummaryProperties> = new Map();\n\t\tconst latestTracking = this.chunkTrackingPropertiesMap.get(\n\t\t\tthis.latestSummarySequenceNumber,\n\t\t);\n\t\tif (latestTracking !== undefined) {\n\t\t\tfor (const properties of latestTracking.values()) {\n\t\t\t\tlatestSummaryRefIdMap.set(properties.referenceId, properties);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackedSummaryProperties = {\n\t\t\tsummarySequenceNumber: incrementalSummaryContext.summarySequenceNumber,\n\t\t\tlatestSummaryBasePath: incrementalSummaryContext.summaryPath,\n\t\t\tchunkSummaryPath: [],\n\t\t\tparentSummaryBuilder: builder,\n\t\t\tfullTree,\n\t\t\tstringify,\n\t\t\tlatestSummaryRefIdMap,\n\t\t};\n\t\treturn ForestIncrementalSummaryBehavior.Incremental;\n\t}\n\n\t/**\n\t * Computes a chunk's path in the latest summary by traversing up the parent chain via\n\t * {@link latestSummaryRefIdMap}.\n\t *\n\t * Each {@link ChunkSummaryProperties.parentReferenceId} points to the chunk's parent as it\n\t * appeared in the summary where the entry was last written. Walking up the chain from the\n\t * chunk to the root produces the full path that can be used in a summary handle path.\n\t */\n\tprivate computeHandlePathInLatestSummary(chunkProperties: ChunkSummaryProperties): string {\n\t\tconst { latestSummaryRefIdMap } = this.requireTrackingSummary();\n\t\tconst pathSegments: string[] = [];\n\t\tlet current: ChunkSummaryProperties | undefined = chunkProperties;\n\t\twhile (current !== undefined) {\n\t\t\tpathSegments.push(`${current.referenceId}`);\n\t\t\tif (current.parentReferenceId === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrent = latestSummaryRefIdMap.get(current.parentReferenceId);\n\t\t\tassert(\n\t\t\t\tcurrent !== undefined,\n\t\t\t\t0xcf7 /* Parent chunk not found in latest summary tracking */,\n\t\t\t);\n\t\t}\n\t\t// Segments are collected leaf-to-root and then reversed. The alternative would be to use unshift\n\t\t// instead of push and reverse. However, using push and reverse is O(n) whereas using unshift would be O(n²).\n\t\treturn pathSegments.reverse().join(\"/\");\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.encodeIncrementalField}\n\t * @remarks Returns an empty array if the field has no content.\n\t */\n\tpublic encodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2,\n\t): ChunkReferenceId[] {\n\t\t// Validate that a summary is currently being tracked and that the tracked summary properties are defined.\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tconst chunkReferenceIds: ChunkReferenceId[] = [];\n\t\tconst chunks = this.getChunkAtCursor(cursor);\n\t\tfor (const chunk of chunks) {\n\t\t\t// Try and get the properties of the chunk from the latest successful summary.\n\t\t\t// If it exists and the summary is not a full tree, use the properties to generate a summary handle.\n\t\t\t// If it does not exist, encode the chunk and generate new properties for it.\n\t\t\tconst previousChunkProperties = tryGetFromNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\tthis.latestSummarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t);\n\t\t\tlet chunkReferenceId: ChunkReferenceId;\n\t\t\tif (previousChunkProperties !== undefined && !trackedSummaryProperties.fullTree) {\n\t\t\t\tchunkReferenceId = previousChunkProperties.referenceId;\n\t\t\t\t// Compute this chunk's path in the latest summary by traversing the parent chain.\n\t\t\t\t// Using parentReferenceId traversal (rather than a stored path string) ensures the\n\t\t\t\t// path is correct even when an ancestor was re-encoded in a prior summary and\n\t\t\t\t// received a new referenceId — the stored summaryPath would have been stale in\n\t\t\t\t// that case.\n\t\t\t\tconst handlePath = this.computeHandlePathInLatestSummary(previousChunkProperties);\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder.addHandle(\n\t\t\t\t\t`${chunkReferenceId}`,\n\t\t\t\t\tSummaryType.Tree,\n\t\t\t\t\t`${trackedSummaryProperties.latestSummaryBasePath}/${handlePath}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Generate a new reference ID for the chunk.\n\t\t\t\tconst newReferenceId: ChunkReferenceId = brand(this.nextReferenceId++);\n\t\t\t\tchunkReferenceId = newReferenceId;\n\n\t\t\t\t// Add the reference ID of this chunk to the chunk summary path before encoding so\n\t\t\t\t// that any incremental chunks in the subtree use the correct parent path.\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.push(newReferenceId);\n\n\t\t\t\tconst parentSummaryBuilder = trackedSummaryProperties.parentSummaryBuilder;\n\t\t\t\t// Create a new summary builder for this chunk to build its summary tree which will be stored in the\n\t\t\t\t// parent's summary tree under its reference ID.\n\t\t\t\t// Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that\n\t\t\t\t// any incremental chunks in the subtree of this chunk will use that as their parent summary builder.\n\t\t\t\tconst chunkSummaryBuilder = new SummaryTreeBuilder();\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;\n\t\t\t\tchunkSummaryBuilder.addBlob(\n\t\t\t\t\tsummaryContentBlobKey,\n\t\t\t\t\ttrackedSummaryProperties.stringify(chunkEncoder(chunk)),\n\t\t\t\t);\n\n\t\t\t\t// Add this chunk's summary tree to the parent's summary tree. The summary tree contains its encoded\n\t\t\t\t// contents and the summary trees of any incremental chunks under it.\n\t\t\t\tparentSummaryBuilder.addWithStats(\n\t\t\t\t\t`${newReferenceId}`,\n\t\t\t\t\tchunkSummaryBuilder.getSummaryTree(),\n\t\t\t\t);\n\n\t\t\t\t// Restore the parent summary builder and chunk summary path.\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.pop();\n\t\t\t}\n\n\t\t\t// Get the parent reference ID from the current chunk summary path.\n\t\t\t// For the root of the forest tree, the parent reference ID is undefined.\n\t\t\t// For all other chunks, the parent reference ID is the last element in the current chunk summary path.\n\t\t\tconst chunkSummaryPathLength = trackedSummaryProperties.chunkSummaryPath.length;\n\t\t\tconst parentReferenceId: ChunkReferenceId | undefined =\n\t\t\t\tchunkSummaryPathLength > 0\n\t\t\t\t\t? trackedSummaryProperties.chunkSummaryPath[chunkSummaryPathLength - 1]\n\t\t\t\t\t: undefined;\n\t\t\tsetInNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t\t{ referenceId: chunkReferenceId, parentReferenceId },\n\t\t\t);\n\t\t\tchunkReferenceIds.push(chunkReferenceId);\n\t\t}\n\t\treturn chunkReferenceIds;\n\t}\n\n\t/**\n\t * Must be called after summary generation is complete to finish tracking the summary.\n\t * It clears any tracking state and deletes the tracking properties for summaries that are older than the\n\t * latest successful summary.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers.\n\t * If this is undefined, the summary tree will only contain a summary blob for `forestSummaryRootContent`.\n\t * @param forestSummaryRootContent - The stringified ForestCodec output of top-level Forest content.\n\t * @param forestSummaryRootContentKey - The key to use for the blob containing `forestSummaryRootContent`.\n\t * @param builder - The summary tree builder to use to add the forest's contents. Note that if tracking an incremental\n\t * summary, this builder will be the same as the one tracked in `trackedSummaryProperties`.\n\t * @returns the Forest's summary tree.\n\t */\n\tpublic completeSummary(args: {\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tforestSummaryRootContent: string;\n\t\tforestSummaryRootContentKey: string;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst {\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryRootContent,\n\t\t\tforestSummaryRootContentKey,\n\t\t\tbuilder,\n\t\t} = args;\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\t\t\treturn;\n\t\t}\n\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\n\t\t// Copy over the entries from the latest summary to the current summary.\n\t\t// In the current summary, there can be fields that haven't changed since the latest summary and the chunks\n\t\t// in these fields and in any of its children weren't encoded. So, we need get the entries for these chunks\n\t\t// to be able to incrementally summarize them in the next summary.\n\t\tconst latestSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\tthis.latestSummarySequenceNumber,\n\t\t);\n\t\tconst currentSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t);\n\t\tif (latestSummaryTrackingMap !== undefined && currentSummaryTrackingMap !== undefined) {\n\t\t\tfor (const [chunk, chunkProperties] of latestSummaryTrackingMap.entries()) {\n\t\t\t\tif (!currentSummaryTrackingMap.has(chunk)) {\n\t\t\t\t\tcurrentSummaryTrackingMap.set(chunk, chunkProperties);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Delete tracking for summaries that are older than the latest successful summary because they will\n\t\t// never be referenced again for generating summary handles.\n\t\tfor (const sequenceNumber of this.chunkTrackingPropertiesMap.keys()) {\n\t\t\tif (sequenceNumber < this.latestSummarySequenceNumber) {\n\t\t\t\tthis.chunkTrackingPropertiesMap.delete(sequenceNumber);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackedSummaryProperties = undefined;\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.decodeIncrementalChunk}\n\t */\n\tpublic decodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk,\n\t): TreeChunk {\n\t\tconst chunkLoadProperties = this.loadedChunksMap.get(`${referenceId}`);\n\t\tassert(chunkLoadProperties !== undefined, 0xc86 /* Encoded incremental chunk not found */);\n\t\tconst chunk = chunkDecoder(chunkLoadProperties.encodedContents);\n\n\t\t// Account for the reference about to be added in `chunkTrackingPropertiesMap`\n\t\t// to ensure that no other users of this chunk think they have unique ownership.\n\t\t// This prevents prevent whoever this chunk is returned to from modifying it in-place.\n\t\tchunk.referenceAdded();\n\t\t// Track the decoded chunk. This will recreate the tracking state when the summary that this client\n\t\t// is loaded from was generated. This is needed to ensure that incremental summaries work correctly\n\t\t// when a new client starts to summarize.\n\t\tsetInNestedMap(this.chunkTrackingPropertiesMap, this.initialSequenceNumber, chunk, {\n\t\t\treferenceId,\n\t\t\tparentReferenceId: chunkLoadProperties.parentReferenceId,\n\t\t});\n\t\treturn chunk;\n\t}\n}\n"]}
|
|
@@ -3,20 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type Static, type TAnySchema, type TSchema } from "@sinclair/typebox";
|
|
6
|
-
/**
|
|
7
|
-
* Note: TS doesn't easily support extracting a generic function's return type until 4.7:
|
|
8
|
-
* https://github.com/microsoft/TypeScript/pull/47607
|
|
9
|
-
* This type is a workaround and can be removed once we're on a version of typescript which
|
|
10
|
-
* supports expressions more like:
|
|
11
|
-
* `Static<ReturnType<typeof EncodedGenericChange<Schema>>>`
|
|
12
|
-
*/
|
|
13
|
-
declare class Wrapper<T extends TSchema> {
|
|
14
|
-
encodedGenericChange(e: T): import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, T]>;
|
|
15
|
-
encodedGenericChangeset(e: T): import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, T]>>;
|
|
16
|
-
}
|
|
17
6
|
export declare const EncodedGenericChange: <NodeChangesetSchema extends TSchema>(tNodeChangeset: NodeChangesetSchema) => import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, NodeChangesetSchema]>;
|
|
18
|
-
export type EncodedGenericChange<Schema extends TSchema = TAnySchema> = Static<ReturnType<
|
|
7
|
+
export type EncodedGenericChange<Schema extends TSchema = TAnySchema> = Static<ReturnType<typeof EncodedGenericChange<Schema>>>;
|
|
19
8
|
export declare const EncodedGenericChangeset: <NodeChangesetSchema extends TSchema>(tNodeChangeset: NodeChangesetSchema) => import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, NodeChangesetSchema]>>;
|
|
20
|
-
export type EncodedGenericChangeset<Schema extends TSchema = TAnySchema> = Static<ReturnType<
|
|
21
|
-
export {};
|
|
9
|
+
export type EncodedGenericChangeset<Schema extends TSchema = TAnySchema> = Static<ReturnType<typeof EncodedGenericChangeset<Schema>>>;
|
|
22
10
|
//# sourceMappingURL=genericFieldKindFormat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genericFieldKindFormat.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/genericFieldKindFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"genericFieldKindFormat.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/genericFieldKindFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAC;AAErF,eAAO,MAAM,oBAAoB,wDAChB,mBAAmB,mGACyC,CAAC;AAE9E,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,OAAO,GAAG,UAAU,IAAI,MAAM,CAC7E,UAAU,CAAC,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAC/C,CAAC;AAEF,eAAO,MAAM,uBAAuB,wDACnB,mBAAmB,uIACiB,CAAC;AAEtD,MAAM,MAAM,uBAAuB,CAAC,MAAM,SAAS,OAAO,GAAG,UAAU,IAAI,MAAM,CAChF,UAAU,CAAC,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAClD,CAAC"}
|
|
@@ -2,25 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { Type } from "@sinclair/typebox";
|
|
6
5
|
// Many of the return types in this module are intentionally derived, rather than explicitly specified.
|
|
7
6
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
8
|
-
|
|
9
|
-
* Note: TS doesn't easily support extracting a generic function's return type until 4.7:
|
|
10
|
-
* https://github.com/microsoft/TypeScript/pull/47607
|
|
11
|
-
* This type is a workaround and can be removed once we're on a version of typescript which
|
|
12
|
-
* supports expressions more like:
|
|
13
|
-
* `Static<ReturnType<typeof EncodedGenericChange<Schema>>>`
|
|
14
|
-
*/
|
|
15
|
-
class Wrapper {
|
|
16
|
-
encodedGenericChange(e) {
|
|
17
|
-
return EncodedGenericChange(e);
|
|
18
|
-
}
|
|
19
|
-
encodedGenericChangeset(e) {
|
|
20
|
-
return EncodedGenericChangeset(e);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
7
|
+
import { Type } from "@sinclair/typebox";
|
|
23
8
|
export const EncodedGenericChange = (tNodeChangeset) => Type.Tuple([Type.Number({ minimum: 0, multipleOf: 1 }), tNodeChangeset]);
|
|
24
9
|
export const EncodedGenericChangeset = (tNodeChangeset) => Type.Array(EncodedGenericChange(tNodeChangeset));
|
|
25
|
-
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
26
10
|
//# sourceMappingURL=genericFieldKindFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genericFieldKindFormat.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/genericFieldKindFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"genericFieldKindFormat.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/genericFieldKindFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uGAAuG;AACvG,qEAAqE;AAErE,OAAO,EAA8C,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,cAAmC,EAClC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AAM9E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACtC,cAAmC,EAClC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Many of the return types in this module are intentionally derived, rather than explicitly specified.\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n\nimport { type Static, type TAnySchema, type TSchema, Type } from \"@sinclair/typebox\";\n\nexport const EncodedGenericChange = <NodeChangesetSchema extends TSchema>(\n\ttNodeChangeset: NodeChangesetSchema,\n) => Type.Tuple([Type.Number({ minimum: 0, multipleOf: 1 }), tNodeChangeset]);\n\nexport type EncodedGenericChange<Schema extends TSchema = TAnySchema> = Static<\n\tReturnType<typeof EncodedGenericChange<Schema>>\n>;\n\nexport const EncodedGenericChangeset = <NodeChangesetSchema extends TSchema>(\n\ttNodeChangeset: NodeChangesetSchema,\n) => Type.Array(EncodedGenericChange(tNodeChangeset));\n\nexport type EncodedGenericChangeset<Schema extends TSchema = TAnySchema> = Static<\n\tReturnType<typeof EncodedGenericChangeset<Schema>>\n>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularChangeCodecV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAG7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACX,qBAAqB,EAIrB,mBAAmB,EAEnB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EAGZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,SAAS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O,EAAE,0BAA0B,EACnC,oBAAoB,EAAE,oBAAoB,GACxC,qBAAqB,CAwBvB;AAED,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,0BAA0B,EACnC,oBAAoB,EAAE,oBAAoB,GACxC,oBAAoB,CAkBtB;AAED,wBAAgB,0BAA0B,CACzC,aAAa,EAAE,qBAAqB,EACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,qBAAqB,EAC9B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,sBAAsB,EAClC,oBAAoB,EAAE,oBAAoB,GACxC,cAAc,CA8DhB;AAED,wBAAgB,2BAA2B,CAC1C,aAAa,EAAE,oBAAoB,EACnC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,qBAAqB,EAC9B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,sBAAsB,EAClC,oBAAoB,EAAE,oBAAoB,GACxC,aAAa,CAqBf;AAED,wBAAgB,mBAAmB,CAClC,aAAa,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS,EACvD,OAAO,EAAE,qBAAqB,EAC9B,gBAAgB,EAAE,aAAa,CAC9B,WAAW,EACX,OAAO,iBAAiB,EACxB,qBAAqB,CACrB,EACD,WAAW,EAAE,eAAe,EAC5B,wBAAwB,EAAE,uBAAuB,GAC/C,aAAa,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"modularChangeCodecV1.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAG7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,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,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACtD,KAAK,EAAE,UAAU,CAAC;CAClB,CACD,EACD,gBAAgB,EAAE,aAAa,CAC9B,WAAW,EACX,OAAO,iBAAiB,EACxB,qBAAqB,CACrB,EACD,WAAW,EAAE,eAAe,EAC5B,wBAAwB,EAAE,uBAAuB,GAC/C,OAAO,CAAC,gBAAgB,CAAC,CAsD3B;AAED,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,sBAAsB,EAClC,gBAAgB,EAAE,aAAa,CAC9B,WAAW,EACX,OAAO,iBAAiB,EACxB,qBAAqB,CACrB,EACD,YAAY,EAAE,aAAa,GACzB,GAAG,CACL,mBAAmB,EACnB;IAAE,cAAc,CAAC,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAC5E,CAmCA;AAED,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,sBAAsB,EAClC,gBAAgB,EAAE,aAAa,CAC9B,WAAW,EACX,OAAO,iBAAiB,EACxB,qBAAqB,CACrB,EACD,WAAW,EAAE,eAAe,EAC5B,YAAY,EAAE,aAAa,EAC3B,wBAAwB,GAAE,uBAA4D,GACpF,kBAAkB,CAkCpB"}
|
|
@@ -138,6 +138,7 @@ export function encodeDetachedNodes(detachedNodes, context, revisionTagCodec, fi
|
|
|
138
138
|
schema: context.schema,
|
|
139
139
|
originatorId: context.originatorId,
|
|
140
140
|
idCompressor: context.idCompressor,
|
|
141
|
+
isSummary: context.isSummary,
|
|
141
142
|
}),
|
|
142
143
|
};
|
|
143
144
|
}
|
|
@@ -149,6 +150,9 @@ export function decodeDetachedNodes(encoded, context, revisionTagCodec, fieldsCo
|
|
|
149
150
|
encodeType: chunkCompressionStrategy,
|
|
150
151
|
originatorId: context.originatorId,
|
|
151
152
|
idCompressor: context.idCompressor,
|
|
153
|
+
isSummary: context.isSummary,
|
|
154
|
+
healUnresolvableIdentifiersOnDecode: context.healUnresolvableIdentifiersOnDecode,
|
|
155
|
+
sharedObjectId: context.sharedObjectId,
|
|
152
156
|
});
|
|
153
157
|
const getChunk = (index) => {
|
|
154
158
|
assert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularChangeCodecV1.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,EAKN,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAY9B,OAAO,EAIN,KAAK,EACL,oBAAoB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAGN,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAOrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAKN,yBAAyB,GAGzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEN,qBAAqB,GAMrB,MAAM,yBAAyB,CAAC;AAwBjC,MAAM,UAAU,sBAAsB,CACrC,SAA8B,EAC9B,oBAA0C;IAK1C,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/E,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,yBAAyB,CACxC,MAAsB,EACtB,OAA8B,EAC9B,WAA6C,EAC7C,oBAA0C;IAE1C,MAAM,YAAY,GAA+B;QAChD,WAAW,EAAE,OAAO;QAEpB,UAAU,EAAE,CAAC,MAAc,EA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O,EACP,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,wBAAwB,CACxB;KACF,CAAC;IAEF,OAAO,oBAAoB,CAC1B,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,CAAC,aAAa,CAC1B,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CACxB,UAAkC,EAClC,SAA8B;IAE9B,IAAI,SAAS,KAAK,gBAAgB,CAAC,UAAU,EAAE,CAAC;QAC/C,OAAO,gBAAgB,CAAC,aAAa,CAAC;IACvC,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;IAC9D,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB,CACzB,aAKC,EACD,QAAiC,EACjC,OAA8B;IAE9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype JsonCodecPart,\n\ttype SchemaValidationFunction,\n\textractJsonValidator,\n\twithSchemaValidation,\n} from \"../../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangesetLocalId,\n\tEncodedRevisionTag,\n\tFieldKey,\n\tFieldKindIdentifier,\n\tITreeCursorSynchronous,\n\tRevisionInfo,\n\tRevisionTag,\n\tRevisionTagSchema,\n} from \"../../core/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n\tbrand,\n\tidAllocatorFromMaxId,\n} from \"../../util/index.js\";\nimport { newChangeAtomIdBTree, type ChangeAtomIdBTree } from \"../changeAtomIdBTree.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeChunk,\n\tchunkFieldSingle,\n\tdefaultChunkPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport type { FieldChangeEncodingContext, FieldChangeHandler } from \"./fieldChangeHandler.js\";\nimport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\ttype EncodedBuilds,\n\ttype EncodedBuildsArray,\n\ttype EncodedFieldChange,\n\ttype EncodedFieldChangeMap,\n\tEncodedModularChangesetV1,\n\ttype EncodedNodeChangeset,\n\ttype EncodedRevisionInfo,\n} from \"./modularChangeFormatV1.js\";\nimport {\n\ttype FieldChangeset,\n\tnewCrossFieldKeyTable,\n\ttype FieldChangeMap,\n\ttype FieldId,\n\ttype ModularChangeset,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\n\ntype ModularChangeCodec = IJsonCodec<\n\tModularChangeset,\n\tEncodedModularChangesetV1,\n\tEncodedModularChangesetV1,\n\tChangeEncodingContext\n>;\n\ntype FieldCodec = IJsonCodec<\n\tFieldChangeset,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tFieldChangeEncodingContext\n>;\n\ntype FieldChangesetCodecs = Map<\n\tFieldKindIdentifier,\n\t{\n\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\tcodec: FieldCodec;\n\t}\n>;\n\nexport function getFieldChangesetCodec(\n\tfieldKind: FieldKindIdentifier,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): {\n\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\tcodec: FieldCodec;\n} {\n\tconst entry = fieldChangesetCodecs.get(fieldKind);\n\tassert(entry !== undefined, 0x5ea /* Tried to encode unsupported fieldKind */);\n\treturn entry;\n}\n\nexport function encodeFieldChangesForJson(\n\tchange: FieldChangeMap,\n\tcontext: ChangeEncodingContext,\n\tnodeChanges: ChangeAtomIdBTree<NodeChangeset>,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): EncodedFieldChangeMap {\n\tconst fieldContext: FieldChangeEncodingContext = {\n\t\tbaseContext: context,\n\n\t\tencodeNode: (nodeId: NodeId): EncodedNodeChangeset => {\n\t\t\tconst node = nodeChanges.get([nodeId.revision, nodeId.localId]);\n\t\t\tassert(node !== undefined, 0x92e /* Unknown node ID */);\n\t\t\treturn encodeNodeChangesForJson(node, fieldContext, fieldChangesetCodecs);\n\t\t},\n\n\t\tdecodeNode: () => fail(0xb1e /* Should not decode nodes during field encoding */),\n\t};\n\n\treturn encodeFieldChangesForJsonI(change, fieldContext, fieldChangesetCodecs);\n}\n\nexport function encodeFieldChangesForJsonI(\n\tchange: FieldChangeMap,\n\tcontext: FieldChangeEncodingContext,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): EncodedFieldChangeMap {\n\tconst encodedFields: EncodedFieldChangeMap = [];\n\n\tfor (const [field, fieldChange] of change) {\n\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(\n\t\t\tfieldChange.fieldKind,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t\tconst encodedChange = codec.encode(fieldChange.change, context);\n\t\tif (compiledSchema !== undefined && !compiledSchema.check(encodedChange)) {\n\t\t\tfail(0xb1f /* Encoded change didn't pass schema validation. */);\n\t\t}\n\n\t\tconst fieldKey: FieldKey = field;\n\t\tconst encodedField: EncodedFieldChange = {\n\t\t\tfieldKey,\n\t\t\tfieldKind: fieldChange.fieldKind,\n\t\t\tchange: encodedChange,\n\t\t};\n\n\t\tencodedFields.push(encodedField);\n\t}\n\n\treturn encodedFields;\n}\n\nexport function encodeNodeChangesForJson(\n\tchange: NodeChangeset,\n\tcontext: FieldChangeEncodingContext,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): EncodedNodeChangeset {\n\tconst encodedChange: EncodedNodeChangeset = {};\n\t// Note: revert constraints are ignored for now because they would only be needed if we supported reverting changes made by peers.\n\tconst { fieldChanges, nodeExistsConstraint } = change;\n\n\tif (fieldChanges !== undefined) {\n\t\tencodedChange.fieldChanges = encodeFieldChangesForJsonI(\n\t\t\tfieldChanges,\n\t\t\tcontext,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t}\n\n\tif (nodeExistsConstraint !== undefined) {\n\t\tencodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t}\n\n\treturn encodedChange;\n}\n\nexport function decodeFieldChangesFromJson(\n\tencodedChange: EncodedFieldChangeMap,\n\tparentId: NodeId | undefined,\n\tdecoded: ModularChangeset,\n\tcontext: ChangeEncodingContext,\n\tidAllocator: IdAllocator,\n\tfieldKinds: FieldKindConfiguration,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): FieldChangeMap {\n\tconst decodedFields: FieldChangeMap = new Map();\n\tfor (const field of encodedChange) {\n\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(\n\t\t\tfield.fieldKind,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t\tif (compiledSchema !== undefined && !compiledSchema.check(field.change)) {\n\t\t\tfail(0xb20 /* Encoded change didn't pass schema validation. */);\n\t\t}\n\n\t\tconst fieldId: FieldId = {\n\t\t\tnodeId: parentId,\n\t\t\tfield: field.fieldKey,\n\t\t};\n\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: () => fail(0xb21 /* Should not encode nodes during field decoding */),\n\n\t\t\tdecodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {\n\t\t\t\tconst nodeId: NodeId = {\n\t\t\t\t\trevision: context.revision,\n\t\t\t\t\tlocalId: brand(idAllocator.allocate()),\n\t\t\t\t};\n\n\t\t\t\tconst node = decodeNodeChangesetFromJson(\n\t\t\t\t\tencodedNode,\n\t\t\t\t\tnodeId,\n\t\t\t\t\tdecoded,\n\t\t\t\t\tcontext,\n\t\t\t\t\tidAllocator,\n\t\t\t\t\tfieldKinds,\n\t\t\t\t\tfieldChangesetCodecs,\n\t\t\t\t);\n\n\t\t\t\tdecoded.nodeChanges.set([nodeId.revision, nodeId.localId], node);\n\t\t\t\tdecoded.nodeToParent.set([nodeId.revision, nodeId.localId], fieldId);\n\t\t\t\treturn nodeId;\n\t\t\t},\n\t\t};\n\n\t\tconst fieldChangeset = codec.decode(field.change, fieldContext);\n\n\t\tconst crossFieldKeys = getChangeHandler(fieldKinds, field.fieldKind).getCrossFieldKeys(\n\t\t\tfieldChangeset,\n\t\t);\n\n\t\tfor (const { key, count } of crossFieldKeys) {\n\t\t\tdecoded.crossFieldKeys.set(key, count, fieldId);\n\t\t}\n\n\t\tconst fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);\n\n\t\tdecodedFields.set(fieldKey, {\n\t\t\tfieldKind: field.fieldKind,\n\t\t\tchange: brand(fieldChangeset),\n\t\t});\n\t}\n\n\treturn decodedFields;\n}\n\nexport function decodeNodeChangesetFromJson(\n\tencodedChange: EncodedNodeChangeset,\n\tid: NodeId,\n\tdecoded: ModularChangeset,\n\tcontext: ChangeEncodingContext,\n\tidAllocator: IdAllocator,\n\tfieldKinds: FieldKindConfiguration,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): NodeChangeset {\n\tconst decodedChange: NodeChangeset = {};\n\tconst { fieldChanges, nodeExistsConstraint } = encodedChange;\n\n\tif (fieldChanges !== undefined) {\n\t\tdecodedChange.fieldChanges = decodeFieldChangesFromJson(\n\t\t\tfieldChanges,\n\t\t\tid,\n\t\t\tdecoded,\n\t\t\tcontext,\n\t\t\tidAllocator,\n\t\t\tfieldKinds,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t}\n\n\tif (nodeExistsConstraint !== undefined) {\n\t\tdecodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t}\n\n\treturn decodedChange;\n}\n\nexport function encodeDetachedNodes(\n\tdetachedNodes: ChangeAtomIdBTree<TreeChunk> | undefined,\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): EncodedBuilds | undefined {\n\tif (detachedNodes === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst treesToEncode: ITreeCursorSynchronous[] = [];\n\tconst buildsArray: EncodedBuildsArray = [];\n\n\tlet buildsForRevision:\n\t\t| [[ChangesetLocalId, number][], EncodedRevisionTag]\n\t\t| [[ChangesetLocalId, number][]]\n\t\t| undefined;\n\n\tfor (const [[revision, id], chunk] of detachedNodes.entries()) {\n\t\tconst encodedRevision = encodeRevisionOpt(revisionTagCodec, revision, context);\n\n\t\tif (buildsForRevision === undefined || buildsForRevision[1] !== encodedRevision) {\n\t\t\tif (buildsForRevision !== undefined) {\n\t\t\t\tbuildsArray.push(buildsForRevision);\n\t\t\t}\n\n\t\t\tbuildsForRevision = encodedRevision === undefined ? [[]] : [[], encodedRevision];\n\t\t}\n\n\t\ttreesToEncode.push(chunk.cursor());\n\t\tconst treeIndexInBatch = treesToEncode.length - 1;\n\t\tbuildsForRevision?.[0].push([id, treeIndexInBatch]);\n\t}\n\n\tif (buildsForRevision !== undefined) {\n\t\tbuildsArray.push(buildsForRevision);\n\t}\n\n\treturn buildsArray.length === 0\n\t\t? undefined\n\t\t: {\n\t\t\t\tbuilds: buildsArray,\n\t\t\t\ttrees: fieldsCodec.encode(treesToEncode, {\n\t\t\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\t\t\tschema: context.schema,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t}),\n\t\t\t};\n}\n\nexport function decodeDetachedNodes(\n\tencoded: EncodedBuilds | undefined,\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): ChangeAtomIdBTree<TreeChunk> | undefined {\n\tif (encoded === undefined || encoded.builds.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tconst chunks = fieldsCodec.decode(encoded.trees, {\n\t\tencodeType: chunkCompressionStrategy,\n\t\toriginatorId: context.originatorId,\n\t\tidCompressor: context.idCompressor,\n\t});\n\tconst getChunk = (index: number): TreeChunk => {\n\t\tassert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);\n\t\treturn chunkFieldSingle(chunks[index] ?? oob(), {\n\t\t\tpolicy: defaultChunkPolicy,\n\t\t\tidCompressor: context.idCompressor,\n\t\t});\n\t};\n\n\tconst map: ModularChangeset[\"builds\"] = newChangeAtomIdBTree();\n\t// eslint-disable-next-line unicorn/no-array-for-each -- Codec internals: minimizing changes to serialization logic\n\tencoded.builds.forEach((build) => {\n\t\t// EncodedRevisionTag cannot be an array so this ensures that we can isolate the tuple\n\t\tconst revision =\n\t\t\tbuild[1] === undefined ? context.revision : revisionTagCodec.decode(build[1], context);\n\n\t\tconst decodedChunks: [ChangesetLocalId, TreeChunk][] = build[0].map(([i, n]) => [\n\t\t\ti,\n\t\t\tgetChunk(n),\n\t\t]);\n\n\t\tfor (const [id, chunk] of decodedChunks) {\n\t\t\tmap.set([revision, id], chunk);\n\t\t}\n\t});\n\n\treturn map;\n}\n\nexport function encodeRevisionInfos(\n\trevisions: readonly RevisionInfo[],\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n): EncodedRevisionInfo[] | undefined {\n\tif (context.revision !== undefined) {\n\t\tassert(\n\t\t\trevisions.length === 1 &&\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- Using optional chaining here would change behavior: `revisions[0]?.rollbackOf === undefined` is true when revisions[0] is undefined, but this check requires revisions[0] to be defined. As currently written, such a change would be safe because context.revision is included in the check and from a couple lines above is confirmed not undefined. But this more verbose form is clearer.\n\t\t\t\trevisions[0] !== undefined &&\n\t\t\t\trevisions[0].revision === context.revision &&\n\t\t\t\trevisions[0].rollbackOf === undefined,\n\t\t\t0x964 /* A tagged change should only contain the tagged revision */,\n\t\t);\n\n\t\treturn undefined;\n\t}\n\n\tconst encodedRevisions = [];\n\tfor (const revision of revisions) {\n\t\tconst encodedRevision: Mutable<EncodedRevisionInfo> = {\n\t\t\trevision: revisionTagCodec.encode(revision.revision, context),\n\t\t};\n\n\t\tif (revision.rollbackOf !== undefined) {\n\t\t\tencodedRevision.rollbackOf = revisionTagCodec.encode(revision.rollbackOf, context);\n\t\t}\n\n\t\tencodedRevisions.push(encodedRevision);\n\t}\n\n\treturn encodedRevisions;\n}\n\nexport function decodeRevisionInfos(\n\trevisions: readonly EncodedRevisionInfo[] | undefined,\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n): RevisionInfo[] | undefined {\n\tif (revisions === undefined) {\n\t\treturn context.revision === undefined ? undefined : [{ revision: context.revision }];\n\t}\n\n\tconst decodedRevisions = [];\n\tfor (const revision of revisions) {\n\t\tconst decodedRevision: Mutable<RevisionInfo> = {\n\t\t\trevision: revisionTagCodec.decode(revision.revision, context),\n\t\t};\n\n\t\tif (revision.rollbackOf !== undefined) {\n\t\t\tdecodedRevision.rollbackOf = revisionTagCodec.decode(revision.rollbackOf, context);\n\t\t}\n\n\t\tdecodedRevisions.push(decodedRevision);\n\t}\n\n\treturn decodedRevisions;\n}\n\nexport function encodeChange(\n\tchange: ModularChangeset,\n\tcontext: ChangeEncodingContext,\n\tfieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t>,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): EncodedModularChangesetV1 {\n\t// Destroys only exist in rollback changesets, which are never sent.\n\tassert(change.destroys === undefined, 0x899 /* Unexpected changeset with destroys */);\n\treturn {\n\t\tmaxId: change.maxId,\n\t\trevisions:\n\t\t\tchange.revisions === undefined\n\t\t\t\t? undefined\n\t\t\t\t: encodeRevisionInfos(change.revisions, context, revisionTagCodec),\n\t\tchanges: encodeFieldChangesForJson(\n\t\t\tchange.fieldChanges,\n\t\t\tcontext,\n\t\t\tchange.nodeChanges,\n\t\t\tfieldChangesetCodecs,\n\t\t),\n\t\tbuilds: encodeDetachedNodes(\n\t\t\tchange.builds,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t),\n\t\trefreshers: encodeDetachedNodes(\n\t\t\tchange.refreshers,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t),\n\t\tviolations: change.constraintViolationCount,\n\t};\n}\n\nexport function decodeChange(\n\tencodedChange: EncodedModularChangesetV1,\n\tcontext: ChangeEncodingContext,\n\tfieldKinds: FieldKindConfiguration,\n\tfieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t>,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): Mutable<ModularChangeset> {\n\tconst decoded: Mutable<ModularChangeset> = {\n\t\tfieldChanges: new Map(),\n\t\tnodeChanges: newChangeAtomIdBTree(),\n\t\tnodeToParent: newChangeAtomIdBTree(),\n\t\tnodeAliases: newChangeAtomIdBTree(),\n\t\tcrossFieldKeys: newCrossFieldKeyTable(),\n\t};\n\n\tdecoded.fieldChanges = decodeFieldChangesFromJson(\n\t\tencodedChange.changes,\n\t\tundefined,\n\t\tdecoded,\n\t\tcontext,\n\t\tidAllocatorFromMaxId(encodedChange.maxId),\n\t\tfieldKinds,\n\t\tfieldChangesetCodecs,\n\t);\n\n\tif (encodedChange.builds !== undefined) {\n\t\tdecoded.builds = decodeDetachedNodes(\n\t\t\tencodedChange.builds,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t}\n\tif (encodedChange.refreshers !== undefined) {\n\t\tdecoded.refreshers = decodeDetachedNodes(\n\t\t\tencodedChange.refreshers,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t}\n\n\tif (encodedChange.violations !== undefined) {\n\t\tdecoded.constraintViolationCount = encodedChange.violations;\n\t}\n\n\tconst decodedRevInfos = decodeRevisionInfos(\n\t\tencodedChange.revisions,\n\t\tcontext,\n\t\trevisionTagCodec,\n\t);\n\tif (decodedRevInfos !== undefined) {\n\t\tdecoded.revisions = decodedRevInfos;\n\t}\n\tif (encodedChange.maxId !== undefined) {\n\t\tdecoded.maxId = encodedChange.maxId;\n\t}\n\treturn decoded;\n}\n\nexport function getFieldChangesetCodecs(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tcodecOptions: ICodecOptions,\n): Map<\n\tFieldKindIdentifier,\n\t{ compiledSchema?: SchemaValidationFunction<TAnySchema>; codec: FieldCodec }\n> {\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tconst getMapEntry = ({ kind, formatVersion }: FieldKindConfigurationEntry) => {\n\t\tconst codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);\n\t\treturn {\n\t\t\tcodec,\n\t\t\tcompiledSchema: codec.encodedSchema\n\t\t\t\t? extractJsonValidator(codecOptions.jsonValidator).compile(codec.encodedSchema)\n\t\t\t\t: undefined,\n\t\t};\n\t};\n\n\t/**\n\t * The codec version for the generic field kind.\n\t */\n\tconst genericFieldKindFormatVersion = 1;\n\tconst fieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t> = new Map([\n\t\t[\n\t\t\tgenericFieldKind.identifier,\n\t\t\tgetMapEntry({ kind: genericFieldKind, formatVersion: genericFieldKindFormatVersion }),\n\t\t],\n\t]);\n\n\t// eslint-disable-next-line unicorn/no-array-for-each -- Map.forEach with (value, key) signature; codec initialization\n\tfieldKinds.forEach((entry, identifier) => {\n\t\tfieldChangesetCodecs.set(identifier, getMapEntry(entry));\n\t});\n\n\treturn fieldChangesetCodecs;\n}\n\nexport function makeModularChangeCodecV1(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tcodecOptions: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ModularChangeCodec {\n\tconst fieldChangesetCodecs = getFieldChangesetCodecs(\n\t\tfieldKinds,\n\t\trevisionTagCodec,\n\t\tcodecOptions,\n\t);\n\n\tconst modularChangeCodec: ModularChangeCodec = {\n\t\tencode: (change, context) =>\n\t\t\tencodeChange(\n\t\t\t\tchange,\n\t\t\t\tcontext,\n\t\t\t\tfieldChangesetCodecs,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t\tdecode: (encodedChange, context) =>\n\t\t\tdecodeChange(\n\t\t\t\tencodedChange,\n\t\t\t\tcontext,\n\t\t\t\tfieldKinds,\n\t\t\t\tfieldChangesetCodecs,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t};\n\n\treturn withSchemaValidation(\n\t\tEncodedModularChangesetV1,\n\t\tmodularChangeCodec,\n\t\tcodecOptions.jsonValidator,\n\t);\n}\n\nfunction getChangeHandler(\n\tfieldKinds: FieldKindConfiguration,\n\tfieldKind: FieldKindIdentifier,\n): FieldChangeHandler<unknown> {\n\tif (fieldKind === genericFieldKind.identifier) {\n\t\treturn genericFieldKind.changeHandler;\n\t}\n\n\tconst handler = fieldKinds.get(fieldKind)?.kind.changeHandler;\n\tassert(handler !== undefined, 0x9c1 /* Unknown field kind */);\n\treturn handler;\n}\n\nfunction encodeRevisionOpt(\n\trevisionCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\trevision: RevisionTag | undefined,\n\tcontext: ChangeEncodingContext,\n): EncodedRevisionTag | undefined {\n\tif (revision === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn revision === context.revision ? undefined : revisionCodec.encode(revision, context);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modularChangeCodecV1.js","sourceRoot":"","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,wBAAwB,CACxB;KACF,CAAC;IAEF,OAAO,oBAAoB,CAC1B,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,CAAC,aAAa,CAC1B,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CACxB,UAAkC,EAClC,SAA8B;IAE9B,IAAI,SAAS,KAAK,gBAAgB,CAAC,UAAU,EAAE,CAAC;QAC/C,OAAO,gBAAgB,CAAC,aAAa,CAAC;IACvC,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;IAC9D,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB,CACzB,aAKC,EACD,QAAiC,EACjC,OAA8B;IAE9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype JsonCodecPart,\n\ttype SchemaValidationFunction,\n\textractJsonValidator,\n\twithSchemaValidation,\n} from \"../../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangesetLocalId,\n\tEncodedRevisionTag,\n\tFieldKey,\n\tFieldKindIdentifier,\n\tITreeCursorSynchronous,\n\tRevisionInfo,\n\tRevisionTag,\n\tRevisionTagSchema,\n} from \"../../core/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n\tbrand,\n\tidAllocatorFromMaxId,\n} from \"../../util/index.js\";\nimport { newChangeAtomIdBTree, type ChangeAtomIdBTree } from \"../changeAtomIdBTree.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeChunk,\n\tchunkFieldSingle,\n\tdefaultChunkPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport type { FieldChangeEncodingContext, FieldChangeHandler } from \"./fieldChangeHandler.js\";\nimport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\ttype EncodedBuilds,\n\ttype EncodedBuildsArray,\n\ttype EncodedFieldChange,\n\ttype EncodedFieldChangeMap,\n\tEncodedModularChangesetV1,\n\ttype EncodedNodeChangeset,\n\ttype EncodedRevisionInfo,\n} from \"./modularChangeFormatV1.js\";\nimport {\n\ttype FieldChangeset,\n\tnewCrossFieldKeyTable,\n\ttype FieldChangeMap,\n\ttype FieldId,\n\ttype ModularChangeset,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\n\ntype ModularChangeCodec = IJsonCodec<\n\tModularChangeset,\n\tEncodedModularChangesetV1,\n\tEncodedModularChangesetV1,\n\tChangeEncodingContext\n>;\n\ntype FieldCodec = IJsonCodec<\n\tFieldChangeset,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tFieldChangeEncodingContext\n>;\n\ntype FieldChangesetCodecs = Map<\n\tFieldKindIdentifier,\n\t{\n\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\tcodec: FieldCodec;\n\t}\n>;\n\nexport function getFieldChangesetCodec(\n\tfieldKind: FieldKindIdentifier,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): {\n\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\tcodec: FieldCodec;\n} {\n\tconst entry = fieldChangesetCodecs.get(fieldKind);\n\tassert(entry !== undefined, 0x5ea /* Tried to encode unsupported fieldKind */);\n\treturn entry;\n}\n\nexport function encodeFieldChangesForJson(\n\tchange: FieldChangeMap,\n\tcontext: ChangeEncodingContext,\n\tnodeChanges: ChangeAtomIdBTree<NodeChangeset>,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): EncodedFieldChangeMap {\n\tconst fieldContext: FieldChangeEncodingContext = {\n\t\tbaseContext: context,\n\n\t\tencodeNode: (nodeId: NodeId): EncodedNodeChangeset => {\n\t\t\tconst node = nodeChanges.get([nodeId.revision, nodeId.localId]);\n\t\t\tassert(node !== undefined, 0x92e /* Unknown node ID */);\n\t\t\treturn encodeNodeChangesForJson(node, fieldContext, fieldChangesetCodecs);\n\t\t},\n\n\t\tdecodeNode: () => fail(0xb1e /* Should not decode nodes during field encoding */),\n\t};\n\n\treturn encodeFieldChangesForJsonI(change, fieldContext, fieldChangesetCodecs);\n}\n\nexport function encodeFieldChangesForJsonI(\n\tchange: FieldChangeMap,\n\tcontext: FieldChangeEncodingContext,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): EncodedFieldChangeMap {\n\tconst encodedFields: EncodedFieldChangeMap = [];\n\n\tfor (const [field, fieldChange] of change) {\n\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(\n\t\t\tfieldChange.fieldKind,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t\tconst encodedChange = codec.encode(fieldChange.change, context);\n\t\tif (compiledSchema !== undefined && !compiledSchema.check(encodedChange)) {\n\t\t\tfail(0xb1f /* Encoded change didn't pass schema validation. */);\n\t\t}\n\n\t\tconst fieldKey: FieldKey = field;\n\t\tconst encodedField: EncodedFieldChange = {\n\t\t\tfieldKey,\n\t\t\tfieldKind: fieldChange.fieldKind,\n\t\t\tchange: encodedChange,\n\t\t};\n\n\t\tencodedFields.push(encodedField);\n\t}\n\n\treturn encodedFields;\n}\n\nexport function encodeNodeChangesForJson(\n\tchange: NodeChangeset,\n\tcontext: FieldChangeEncodingContext,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): EncodedNodeChangeset {\n\tconst encodedChange: EncodedNodeChangeset = {};\n\t// Note: revert constraints are ignored for now because they would only be needed if we supported reverting changes made by peers.\n\tconst { fieldChanges, nodeExistsConstraint } = change;\n\n\tif (fieldChanges !== undefined) {\n\t\tencodedChange.fieldChanges = encodeFieldChangesForJsonI(\n\t\t\tfieldChanges,\n\t\t\tcontext,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t}\n\n\tif (nodeExistsConstraint !== undefined) {\n\t\tencodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t}\n\n\treturn encodedChange;\n}\n\nexport function decodeFieldChangesFromJson(\n\tencodedChange: EncodedFieldChangeMap,\n\tparentId: NodeId | undefined,\n\tdecoded: ModularChangeset,\n\tcontext: ChangeEncodingContext,\n\tidAllocator: IdAllocator,\n\tfieldKinds: FieldKindConfiguration,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): FieldChangeMap {\n\tconst decodedFields: FieldChangeMap = new Map();\n\tfor (const field of encodedChange) {\n\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(\n\t\t\tfield.fieldKind,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t\tif (compiledSchema !== undefined && !compiledSchema.check(field.change)) {\n\t\t\tfail(0xb20 /* Encoded change didn't pass schema validation. */);\n\t\t}\n\n\t\tconst fieldId: FieldId = {\n\t\t\tnodeId: parentId,\n\t\t\tfield: field.fieldKey,\n\t\t};\n\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: () => fail(0xb21 /* Should not encode nodes during field decoding */),\n\n\t\t\tdecodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {\n\t\t\t\tconst nodeId: NodeId = {\n\t\t\t\t\trevision: context.revision,\n\t\t\t\t\tlocalId: brand(idAllocator.allocate()),\n\t\t\t\t};\n\n\t\t\t\tconst node = decodeNodeChangesetFromJson(\n\t\t\t\t\tencodedNode,\n\t\t\t\t\tnodeId,\n\t\t\t\t\tdecoded,\n\t\t\t\t\tcontext,\n\t\t\t\t\tidAllocator,\n\t\t\t\t\tfieldKinds,\n\t\t\t\t\tfieldChangesetCodecs,\n\t\t\t\t);\n\n\t\t\t\tdecoded.nodeChanges.set([nodeId.revision, nodeId.localId], node);\n\t\t\t\tdecoded.nodeToParent.set([nodeId.revision, nodeId.localId], fieldId);\n\t\t\t\treturn nodeId;\n\t\t\t},\n\t\t};\n\n\t\tconst fieldChangeset = codec.decode(field.change, fieldContext);\n\n\t\tconst crossFieldKeys = getChangeHandler(fieldKinds, field.fieldKind).getCrossFieldKeys(\n\t\t\tfieldChangeset,\n\t\t);\n\n\t\tfor (const { key, count } of crossFieldKeys) {\n\t\t\tdecoded.crossFieldKeys.set(key, count, fieldId);\n\t\t}\n\n\t\tconst fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);\n\n\t\tdecodedFields.set(fieldKey, {\n\t\t\tfieldKind: field.fieldKind,\n\t\t\tchange: brand(fieldChangeset),\n\t\t});\n\t}\n\n\treturn decodedFields;\n}\n\nexport function decodeNodeChangesetFromJson(\n\tencodedChange: EncodedNodeChangeset,\n\tid: NodeId,\n\tdecoded: ModularChangeset,\n\tcontext: ChangeEncodingContext,\n\tidAllocator: IdAllocator,\n\tfieldKinds: FieldKindConfiguration,\n\tfieldChangesetCodecs: FieldChangesetCodecs,\n): NodeChangeset {\n\tconst decodedChange: NodeChangeset = {};\n\tconst { fieldChanges, nodeExistsConstraint } = encodedChange;\n\n\tif (fieldChanges !== undefined) {\n\t\tdecodedChange.fieldChanges = decodeFieldChangesFromJson(\n\t\t\tfieldChanges,\n\t\t\tid,\n\t\t\tdecoded,\n\t\t\tcontext,\n\t\t\tidAllocator,\n\t\t\tfieldKinds,\n\t\t\tfieldChangesetCodecs,\n\t\t);\n\t}\n\n\tif (nodeExistsConstraint !== undefined) {\n\t\tdecodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t}\n\n\treturn decodedChange;\n}\n\nexport function encodeDetachedNodes(\n\tdetachedNodes: ChangeAtomIdBTree<TreeChunk> | undefined,\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): EncodedBuilds | undefined {\n\tif (detachedNodes === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst treesToEncode: ITreeCursorSynchronous[] = [];\n\tconst buildsArray: EncodedBuildsArray = [];\n\n\tlet buildsForRevision:\n\t\t| [[ChangesetLocalId, number][], EncodedRevisionTag]\n\t\t| [[ChangesetLocalId, number][]]\n\t\t| undefined;\n\n\tfor (const [[revision, id], chunk] of detachedNodes.entries()) {\n\t\tconst encodedRevision = encodeRevisionOpt(revisionTagCodec, revision, context);\n\n\t\tif (buildsForRevision === undefined || buildsForRevision[1] !== encodedRevision) {\n\t\t\tif (buildsForRevision !== undefined) {\n\t\t\t\tbuildsArray.push(buildsForRevision);\n\t\t\t}\n\n\t\t\tbuildsForRevision = encodedRevision === undefined ? [[]] : [[], encodedRevision];\n\t\t}\n\n\t\ttreesToEncode.push(chunk.cursor());\n\t\tconst treeIndexInBatch = treesToEncode.length - 1;\n\t\tbuildsForRevision?.[0].push([id, treeIndexInBatch]);\n\t}\n\n\tif (buildsForRevision !== undefined) {\n\t\tbuildsArray.push(buildsForRevision);\n\t}\n\n\treturn buildsArray.length === 0\n\t\t? undefined\n\t\t: {\n\t\t\t\tbuilds: buildsArray,\n\t\t\t\ttrees: fieldsCodec.encode(treesToEncode, {\n\t\t\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\t\t\tschema: context.schema,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\tisSummary: context.isSummary,\n\t\t\t\t}),\n\t\t\t};\n}\n\nexport function decodeDetachedNodes(\n\tencoded: EncodedBuilds | undefined,\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): ChangeAtomIdBTree<TreeChunk> | undefined {\n\tif (encoded === undefined || encoded.builds.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tconst chunks = fieldsCodec.decode(encoded.trees, {\n\t\tencodeType: chunkCompressionStrategy,\n\t\toriginatorId: context.originatorId,\n\t\tidCompressor: context.idCompressor,\n\t\tisSummary: context.isSummary,\n\t\thealUnresolvableIdentifiersOnDecode: context.healUnresolvableIdentifiersOnDecode,\n\t\tsharedObjectId: context.sharedObjectId,\n\t});\n\tconst getChunk = (index: number): TreeChunk => {\n\t\tassert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);\n\t\treturn chunkFieldSingle(chunks[index] ?? oob(), {\n\t\t\tpolicy: defaultChunkPolicy,\n\t\t\tidCompressor: context.idCompressor,\n\t\t});\n\t};\n\n\tconst map: ModularChangeset[\"builds\"] = newChangeAtomIdBTree();\n\t// eslint-disable-next-line unicorn/no-array-for-each -- Codec internals: minimizing changes to serialization logic\n\tencoded.builds.forEach((build) => {\n\t\t// EncodedRevisionTag cannot be an array so this ensures that we can isolate the tuple\n\t\tconst revision =\n\t\t\tbuild[1] === undefined ? context.revision : revisionTagCodec.decode(build[1], context);\n\n\t\tconst decodedChunks: [ChangesetLocalId, TreeChunk][] = build[0].map(([i, n]) => [\n\t\t\ti,\n\t\t\tgetChunk(n),\n\t\t]);\n\n\t\tfor (const [id, chunk] of decodedChunks) {\n\t\t\tmap.set([revision, id], chunk);\n\t\t}\n\t});\n\n\treturn map;\n}\n\nexport function encodeRevisionInfos(\n\trevisions: readonly RevisionInfo[],\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n): EncodedRevisionInfo[] | undefined {\n\tif (context.revision !== undefined) {\n\t\tassert(\n\t\t\trevisions.length === 1 &&\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- Using optional chaining here would change behavior: `revisions[0]?.rollbackOf === undefined` is true when revisions[0] is undefined, but this check requires revisions[0] to be defined. As currently written, such a change would be safe because context.revision is included in the check and from a couple lines above is confirmed not undefined. But this more verbose form is clearer.\n\t\t\t\trevisions[0] !== undefined &&\n\t\t\t\trevisions[0].revision === context.revision &&\n\t\t\t\trevisions[0].rollbackOf === undefined,\n\t\t\t0x964 /* A tagged change should only contain the tagged revision */,\n\t\t);\n\n\t\treturn undefined;\n\t}\n\n\tconst encodedRevisions = [];\n\tfor (const revision of revisions) {\n\t\tconst encodedRevision: Mutable<EncodedRevisionInfo> = {\n\t\t\trevision: revisionTagCodec.encode(revision.revision, context),\n\t\t};\n\n\t\tif (revision.rollbackOf !== undefined) {\n\t\t\tencodedRevision.rollbackOf = revisionTagCodec.encode(revision.rollbackOf, context);\n\t\t}\n\n\t\tencodedRevisions.push(encodedRevision);\n\t}\n\n\treturn encodedRevisions;\n}\n\nexport function decodeRevisionInfos(\n\trevisions: readonly EncodedRevisionInfo[] | undefined,\n\tcontext: ChangeEncodingContext,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n): RevisionInfo[] | undefined {\n\tif (revisions === undefined) {\n\t\treturn context.revision === undefined ? undefined : [{ revision: context.revision }];\n\t}\n\n\tconst decodedRevisions = [];\n\tfor (const revision of revisions) {\n\t\tconst decodedRevision: Mutable<RevisionInfo> = {\n\t\t\trevision: revisionTagCodec.decode(revision.revision, context),\n\t\t};\n\n\t\tif (revision.rollbackOf !== undefined) {\n\t\t\tdecodedRevision.rollbackOf = revisionTagCodec.decode(revision.rollbackOf, context);\n\t\t}\n\n\t\tdecodedRevisions.push(decodedRevision);\n\t}\n\n\treturn decodedRevisions;\n}\n\nexport function encodeChange(\n\tchange: ModularChangeset,\n\tcontext: ChangeEncodingContext,\n\tfieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t>,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): EncodedModularChangesetV1 {\n\t// Destroys only exist in rollback changesets, which are never sent.\n\tassert(change.destroys === undefined, 0x899 /* Unexpected changeset with destroys */);\n\treturn {\n\t\tmaxId: change.maxId,\n\t\trevisions:\n\t\t\tchange.revisions === undefined\n\t\t\t\t? undefined\n\t\t\t\t: encodeRevisionInfos(change.revisions, context, revisionTagCodec),\n\t\tchanges: encodeFieldChangesForJson(\n\t\t\tchange.fieldChanges,\n\t\t\tcontext,\n\t\t\tchange.nodeChanges,\n\t\t\tfieldChangesetCodecs,\n\t\t),\n\t\tbuilds: encodeDetachedNodes(\n\t\t\tchange.builds,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t),\n\t\trefreshers: encodeDetachedNodes(\n\t\t\tchange.refreshers,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t),\n\t\tviolations: change.constraintViolationCount,\n\t};\n}\n\nexport function decodeChange(\n\tencodedChange: EncodedModularChangesetV1,\n\tcontext: ChangeEncodingContext,\n\tfieldKinds: FieldKindConfiguration,\n\tfieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t>,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tchunkCompressionStrategy: TreeCompressionStrategy,\n): Mutable<ModularChangeset> {\n\tconst decoded: Mutable<ModularChangeset> = {\n\t\tfieldChanges: new Map(),\n\t\tnodeChanges: newChangeAtomIdBTree(),\n\t\tnodeToParent: newChangeAtomIdBTree(),\n\t\tnodeAliases: newChangeAtomIdBTree(),\n\t\tcrossFieldKeys: newCrossFieldKeyTable(),\n\t};\n\n\tdecoded.fieldChanges = decodeFieldChangesFromJson(\n\t\tencodedChange.changes,\n\t\tundefined,\n\t\tdecoded,\n\t\tcontext,\n\t\tidAllocatorFromMaxId(encodedChange.maxId),\n\t\tfieldKinds,\n\t\tfieldChangesetCodecs,\n\t);\n\n\tif (encodedChange.builds !== undefined) {\n\t\tdecoded.builds = decodeDetachedNodes(\n\t\t\tencodedChange.builds,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t}\n\tif (encodedChange.refreshers !== undefined) {\n\t\tdecoded.refreshers = decodeDetachedNodes(\n\t\t\tencodedChange.refreshers,\n\t\t\tcontext,\n\t\t\trevisionTagCodec,\n\t\t\tfieldsCodec,\n\t\t\tchunkCompressionStrategy,\n\t\t);\n\t}\n\n\tif (encodedChange.violations !== undefined) {\n\t\tdecoded.constraintViolationCount = encodedChange.violations;\n\t}\n\n\tconst decodedRevInfos = decodeRevisionInfos(\n\t\tencodedChange.revisions,\n\t\tcontext,\n\t\trevisionTagCodec,\n\t);\n\tif (decodedRevInfos !== undefined) {\n\t\tdecoded.revisions = decodedRevInfos;\n\t}\n\tif (encodedChange.maxId !== undefined) {\n\t\tdecoded.maxId = encodedChange.maxId;\n\t}\n\treturn decoded;\n}\n\nexport function getFieldChangesetCodecs(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tcodecOptions: ICodecOptions,\n): Map<\n\tFieldKindIdentifier,\n\t{ compiledSchema?: SchemaValidationFunction<TAnySchema>; codec: FieldCodec }\n> {\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tconst getMapEntry = ({ kind, formatVersion }: FieldKindConfigurationEntry) => {\n\t\tconst codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);\n\t\treturn {\n\t\t\tcodec,\n\t\t\tcompiledSchema: codec.encodedSchema\n\t\t\t\t? extractJsonValidator(codecOptions.jsonValidator).compile(codec.encodedSchema)\n\t\t\t\t: undefined,\n\t\t};\n\t};\n\n\t/**\n\t * The codec version for the generic field kind.\n\t */\n\tconst genericFieldKindFormatVersion = 1;\n\tconst fieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t> = new Map([\n\t\t[\n\t\t\tgenericFieldKind.identifier,\n\t\t\tgetMapEntry({ kind: genericFieldKind, formatVersion: genericFieldKindFormatVersion }),\n\t\t],\n\t]);\n\n\t// eslint-disable-next-line unicorn/no-array-for-each -- Map.forEach with (value, key) signature; codec initialization\n\tfieldKinds.forEach((entry, identifier) => {\n\t\tfieldChangesetCodecs.set(identifier, getMapEntry(entry));\n\t});\n\n\treturn fieldChangesetCodecs;\n}\n\nexport function makeModularChangeCodecV1(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: JsonCodecPart<\n\t\tRevisionTag,\n\t\ttypeof RevisionTagSchema,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tcodecOptions: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ModularChangeCodec {\n\tconst fieldChangesetCodecs = getFieldChangesetCodecs(\n\t\tfieldKinds,\n\t\trevisionTagCodec,\n\t\tcodecOptions,\n\t);\n\n\tconst modularChangeCodec: ModularChangeCodec = {\n\t\tencode: (change, context) =>\n\t\t\tencodeChange(\n\t\t\t\tchange,\n\t\t\t\tcontext,\n\t\t\t\tfieldChangesetCodecs,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t\tdecode: (encodedChange, context) =>\n\t\t\tdecodeChange(\n\t\t\t\tencodedChange,\n\t\t\t\tcontext,\n\t\t\t\tfieldKinds,\n\t\t\t\tfieldChangesetCodecs,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t};\n\n\treturn withSchemaValidation(\n\t\tEncodedModularChangesetV1,\n\t\tmodularChangeCodec,\n\t\tcodecOptions.jsonValidator,\n\t);\n}\n\nfunction getChangeHandler(\n\tfieldKinds: FieldKindConfiguration,\n\tfieldKind: FieldKindIdentifier,\n): FieldChangeHandler<unknown> {\n\tif (fieldKind === genericFieldKind.identifier) {\n\t\treturn genericFieldKind.changeHandler;\n\t}\n\n\tconst handler = fieldKinds.get(fieldKind)?.kind.changeHandler;\n\tassert(handler !== undefined, 0x9c1 /* Unknown field kind */);\n\treturn handler;\n}\n\nfunction encodeRevisionOpt(\n\trevisionCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\trevision: RevisionTag | undefined,\n\tcontext: ChangeEncodingContext,\n): EncodedRevisionTag | undefined {\n\tif (revision === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn revision === context.revision ? undefined : revisionCodec.encode(revision, context);\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,YAAY,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.101.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"independentView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/independentView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EACN,KAAK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;;;;;;;;;;;;GAgDG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EAClF,OAAO,CAAC,EAAE,aAAa,GACrB,YAAY,CAEd;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACnF,OAAO,CAAC,EAAE,iCAAiC,GACzC,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,eAAe,GAAG,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"independentView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/independentView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EACN,KAAK,aAAa,EAElB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAgB1E,OAAO,KAAK,EACX,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,YAAY,EAKZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,cAAc,EAGnB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAIN,KAAK,aAAa,EAClB,MAAM,iBAAiB,CAAC;AAGzB;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,aAAa,EAAE,OAAO,CAAC,iBAAiB,CAAC;IACxF;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,aAAa,GAC5D,CACG,CAAC,sBAAsB,GAAG;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;CACf,CAAC,GACF,CAAC,aAAa,GAAG;IACjB;;;OAGG;IACH,OAAO,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;CACpB,CAAC,CACJ,CAAC;AAEH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACxE,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EACtC,OAAO,CAAC,EAAE,sBAAsB,GAC9B,aAAa,CAAC,OAAO,CAAC,CAExB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACnF,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EACtC,OAAO,EAAE,aAAa,GAAG,aAAa,EACtC,OAAO,EAAE,WAAW,GAClB,aAAa,CAAC,OAAO,CAAC,CAIxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EAClF,OAAO,CAAC,EAAE,aAAa,GACrB,YAAY,CAEd;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACnF,OAAO,CAAC,EAAE,iCAAiC,GACzC,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,eAAe,GAAG,oBAAoB,CAAC,CA4EzE;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC5C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;CACrC"}
|
|
@@ -129,6 +129,8 @@ export function createIndependentTreeAlpha(options) {
|
|
|
129
129
|
idCompressor,
|
|
130
130
|
originatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?
|
|
131
131
|
schema: { schema: newSchema, policy: defaultSchemaPolicy },
|
|
132
|
+
// Not a summary blob — this is a synthetic decode of inline content.
|
|
133
|
+
isSummary: false,
|
|
132
134
|
};
|
|
133
135
|
const fieldCursors = fieldBatchCodec.decode(options.content.tree, context);
|
|
134
136
|
assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"independentView.js","sourceRoot":"","sources":["../../src/shared-tree/independentView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAEN,kBAAkB,GAClB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EAEN,gBAAgB,EAChB,0BAA0B,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,EAEtB,mBAAmB,EACnB,uBAAuB,EACvB,gCAAgC,EAChC,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAY9D,OAAO,EAGN,SAAS,EACT,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,GAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAyCvD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC9B,MAAsC,EACtC,OAAgC;IAEhC,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAA2B,CAAC;AACvF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,0BAA0B,CACzC,MAAsC,EACtC,OAAsC,EACtC,OAAoB;IAEpB,OAAO,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MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE7D,MAAM,OAAO,GAA8B;YAC1C,UAAU,EAAE,uBAAuB,CAAC,UAAU;YAC9C,YAAY;YACZ,YAAY,EAAE,YAAY,CAAC,cAAc,EAAE,0CAA0C;YACrF,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE;SAC1D,CAAC;QACF,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAC1C,OAAO,CAAC,OAAO,CAAC,IAA8B,EAC9C,OAAO,CACP,CAAC;QACF,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAElF,MAAM,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAEnF,UAAU,CACT,QAAQ,EACR,SAAS,EACT,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,CACnC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CACtD,CACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,QAAQ,CACP,MAAoC;YAEpC,MAAM,GAAG,GAA2B,IAAI,0BAA0B,CACjE,QAAQ,EACR,MAA6E,EAC7E,2BAA2B,CAAC,YAAY,CAAC,CACzC,CAAC;YACF,OAAO,GAAiC,CAAC;QAC1C,CAAC;QAED,aAAa;YACZ,OAAO,QAAQ,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC;QAED,kBAAkB;YACjB,OAAO,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAClD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IIdCompressor,\n\tcreateIdCompressor,\n} from \"@fluidframework/id-compressor/internal\";\n\nimport type { CodecWriteOptions, ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\tTreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\tcreateNodeIdentifierManager,\n\tfieldBatchCodecBuilder,\n\ttype FieldBatchEncodingContext,\n\tdefaultSchemaPolicy,\n\tTreeCompressionStrategy,\n\tdefaultIncrementalEncodingPolicy,\n\tschemaCodecBuilder,\n} from \"../feature-libraries/index.js\";\nimport { combineChunks } from \"../feature-libraries/index.js\";\nimport type {\n\tTreeViewConfiguration,\n\tImplicitFieldSchema,\n\tTreeViewAlpha,\n\tITreeAlpha,\n\tViewableTree,\n\tTreeView,\n\tReadSchema,\n\tVerboseTree,\n\tSimpleTreeSchema,\n} from \"../simple-tree/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatible,\n\tBreakable,\n\toneFromIterable,\n} from \"../util/index.js\";\n\nimport { initialize, initializerFromChunk } from \"./schematizeTree.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport {\n\tbuildConfiguredForest,\n\tdefaultSharedTreeOptions,\n\texportSimpleSchema,\n\ttype ForestOptions,\n} from \"./sharedTree.js\";\nimport { createTreeCheckout } from \"./treeCheckout.js\";\n\n/**\n * {@link independentView} options.\n * @alpha @input\n */\nexport interface IndependentViewOptions extends ForestOptions, Partial<CodecWriteOptions> {\n\t/**\n\t * Optional ID compressor for generating and compressing identifiers.\n\t * If not provided, a new one will be created.\n\t */\n\tidCompressor?: IIdCompressor | undefined;\n}\n\n/**\n * {@link createIndependentTreeAlpha} options.\n * @alpha\n */\nexport type CreateIndependentTreeAlphaOptions = ForestOptions &\n\t(\n\t\t| (IndependentViewOptions & {\n\t\t\t\t/**\n\t\t\t\t * Optional content for initializing the tree.\n\t\t\t\t * If not provided, the tree will be uninitialized.\n\t\t\t\t */\n\t\t\t\tcontent?: never;\n\t\t })\n\t\t| (ICodecOptions & {\n\t\t\t\t/**\n\t\t\t\t * Content for initializing the tree.\n\t\t\t\t * The content includes the idCompressor, so idCompressor should not be provided at the top level.\n\t\t\t\t */\n\t\t\t\tcontent: ViewContent;\n\t\t\t\t/**\n\t\t\t\t * Should not be provided when content is specified.\n\t\t\t\t * The idCompressor will be obtained from the content.\n\t\t\t\t */\n\t\t\t\tidCompressor?: never;\n\t\t })\n\t);\n\n/**\n * Create an uninitialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @alpha\n */\nexport function independentView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions?: IndependentViewOptions,\n): TreeViewAlpha<TSchema> {\n\treturn createIndependentTreeAlpha(options).viewWith(config) as TreeViewAlpha<TSchema>;\n}\n\n/**\n * Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @privateRemarks\n * TODO: Providing an API which generates a {@link ViewableTree} extended with export options from {@link ITreeAlpha} and maybe even branching APIs would likely be better that just exposing a {@link TreeViewAlpha}.\n * @alpha\n */\nexport function independentInitializedView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & ICodecOptions,\n\tcontent: ViewContent,\n): TreeViewAlpha<TSchema> {\n\treturn createIndependentTreeAlpha({ ...options, content }).viewWith(\n\t\tconfig,\n\t) as TreeViewAlpha<TSchema>;\n}\n\n/**\n * Create a {@link ViewableTree} that is not tied to any Fluid runtimes or services.\n *\n * @remarks\n * Such a tree can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n *\n * @example\n * ```typescript\n * const tree = createIndependentTreeBeta();\n *\n * const stagedConfig = new TreeViewConfiguration({\n * \tschema: SchemaFactoryAlpha.types([\n * \t\tSchemaFactory.number,\n * \t\tSchemaFactoryAlpha.staged(SchemaFactory.string),\n * \t]),\n * });\n * const afterConfig = new TreeViewConfigurationAlpha({\n * \tschema: [SchemaFactory.number, SchemaFactory.string],\n * });\n *\n * // Initialize tree\n * {\n * \tconst view = tree.viewWith(stagedConfig);\n * \tview.initialize(1);\n * \tview.dispose();\n * }\n *\n * // Do schema upgrade\n * {\n * \tconst view = tree.viewWith(afterConfig);\n * \tview.upgradeSchema();\n * \tview.root = \"A\";\n * \tview.dispose();\n * }\n *\n * // Can still view tree with staged schema\n * {\n * \tconst view = tree.viewWith(stagedConfig);\n * \tassert.equal(view.root, \"A\");\n * \tview.dispose();\n * }\n * ```\n * @privateRemarks\n * Before stabilizing this as public, consider if we can instead just expose a better way to create regular Fluid service based SharedTrees for tests.\n * Something like https://github.com/microsoft/FluidFramework/pull/25422 might be a better long term stable/public solution.\n * @beta\n */\nexport function createIndependentTreeBeta<const TSchema extends ImplicitFieldSchema>(\n\toptions?: ForestOptions,\n): ViewableTree {\n\treturn createIndependentTreeAlpha<TSchema>(options);\n}\n\n/**\n * Alpha extensions to {@link createIndependentTreeBeta}.\n *\n * @param options - Configuration options for the independent tree.\n * This can be used to create an uninitialized tree, or `content` can be provided to create an initialized tree.\n * If content is provided, the idCompressor is a required part of it: otherwise it is optional and provided at the top level.\n *\n * @privateRemarks\n * TODO: Support more of {@link ITreeAlpha}, including branching APIs to allow for merges.\n * TODO: Better unify this logic with SharedTreeKernel and SharedTreeCore.\n *\n * Before further stabilizing: consider better ways to handle initialized vs uninitialized trees.\n * Perhaps it would be better to not allow initialize here at all, but expose the ability to load compressed tree content and stored schema via ITree or TreeView?\n * If keeping the option here, maybe a separate function of overload would be better? Or maybe flatten ViewContent inline to deduplicate the idCompressor options?\n * @alpha\n */\nexport function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSchema>(\n\toptions?: CreateIndependentTreeAlphaOptions,\n): ViewableTree & Pick<ITreeAlpha, \"exportVerbose\" | \"exportSimpleSchema\"> {\n\tconst breaker = new Breakable(\"independentView\");\n\tconst idCompressor: IIdCompressor =\n\t\toptions?.idCompressor ?? options?.content?.idCompressor ?? createIdCompressor();\n\tconst mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();\n\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\n\t// To ensure the forest is in schema when constructed, start it with an empty schema and set the schema repository content later.\n\tconst schemaRepository = new TreeStoredSchemaRepository();\n\n\tconst forest = buildConfiguredForest(\n\t\tbreaker,\n\t\toptions?.forest ?? defaultSharedTreeOptions.forest,\n\t\tschemaRepository,\n\t\tidCompressor,\n\t\tdefaultIncrementalEncodingPolicy,\n\t);\n\n\tconst checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {\n\t\tforest,\n\t\tschema: schemaRepository,\n\t\tbreaker,\n\t\tcodecOptions: options,\n\t});\n\n\tif (options?.content !== undefined) {\n\t\tconst schemaCodec = schemaCodecBuilder.buildDecoder(options);\n\t\tconst fieldBatchCodec = fieldBatchCodecBuilder.buildDecoder(options);\n\t\tconst newSchema = schemaCodec.decode(options.content.schema);\n\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?\n\t\t\tschema: { schema: newSchema, policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst fieldCursors = fieldBatchCodec.decode(\n\t\t\toptions.content.tree as JsonCompatibleReadOnly,\n\t\t\tcontext,\n\t\t);\n\t\tassert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);\n\n\t\tconst fieldCursor = oneFromIterable(fieldCursors);\n\t\tassert(fieldCursor !== undefined, 0xc94 /* expected exactly one field in batch */);\n\n\t\tinitialize(\n\t\t\tcheckout,\n\t\t\tnewSchema,\n\t\t\tinitializerFromChunk(checkout, () =>\n\t\t\t\tcombineChunks(checkout.forest.chunkField(fieldCursor)),\n\t\t\t),\n\t\t);\n\t}\n\n\treturn {\n\t\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\t\tconfig: TreeViewConfiguration<TRoot>,\n\t\t): TreeView<TRoot> {\n\t\t\tconst out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(\n\t\t\t\tcheckout,\n\t\t\t\tconfig as TreeViewConfiguration as TreeViewConfiguration<ReadSchema<TSchema>>,\n\t\t\t\tcreateNodeIdentifierManager(idCompressor),\n\t\t\t);\n\t\t\treturn out as unknown as TreeView<TRoot>;\n\t\t},\n\n\t\texportVerbose(): VerboseTree | undefined {\n\t\t\treturn checkout.exportVerbose();\n\t\t},\n\n\t\texportSimpleSchema(): SimpleTreeSchema {\n\t\t\treturn exportSimpleSchema(checkout.storedSchema);\n\t\t},\n\t};\n}\n\n/**\n * The portion of SharedTree data typically persisted by the container.\n * Usable with {@link independentInitializedView} to create a {@link TreeView}\n * without loading a container.\n * @alpha\n */\nexport interface ViewContent {\n\t/**\n\t * Compressed tree from {@link (TreeAlpha:interface).exportCompressed}.\n\t * @remarks\n\t * This is an owning reference:\n\t * consumers of this content might modify this data in place (for example when applying edits) to avoid copying.\n\t */\n\treadonly tree: JsonCompatible<IFluidHandle>;\n\t/**\n\t * Persisted schema from {@link extractPersistedSchema}.\n\t */\n\treadonly schema: JsonCompatible;\n\t/**\n\t * IIdCompressor which will be used to decompress any compressed identifiers in `tree`\n\t * as well as for any other identifiers added to the view.\n\t */\n\treadonly idCompressor: IIdCompressor;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"independentView.js","sourceRoot":"","sources":["../../src/shared-tree/independentView.ts"],"names":[],"m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EAAE;YAC1D,qEAAqE;YACrE,SAAS,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAC1C,OAAO,CAAC,OAAO,CAAC,IAA8B,EAC9C,OAAO,CACP,CAAC;QACF,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAElF,MAAM,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAEnF,UAAU,CACT,QAAQ,EACR,SAAS,EACT,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,CACnC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CACtD,CACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,QAAQ,CACP,MAAoC;YAEpC,MAAM,GAAG,GAA2B,IAAI,0BAA0B,CACjE,QAAQ,EACR,MAA6E,EAC7E,2BAA2B,CAAC,YAAY,CAAC,CACzC,CAAC;YACF,OAAO,GAAiC,CAAC;QAC1C,CAAC;QAED,aAAa;YACZ,OAAO,QAAQ,CAAC,aAAa,EAAE,CAAC;QACjC,CAAC;QAED,kBAAkB;YACjB,OAAO,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAClD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IIdCompressor,\n\tcreateIdCompressor,\n} from \"@fluidframework/id-compressor/internal\";\n\nimport type { CodecWriteOptions, ICodecOptions } from \"../codec/index.js\";\nimport {\n\ttype RevisionTag,\n\tRevisionTagCodec,\n\tTreeStoredSchemaRepository,\n} from \"../core/index.js\";\nimport {\n\tcreateNodeIdentifierManager,\n\tfieldBatchCodecBuilder,\n\ttype FieldBatchEncodingContext,\n\tdefaultSchemaPolicy,\n\tTreeCompressionStrategy,\n\tdefaultIncrementalEncodingPolicy,\n\tschemaCodecBuilder,\n} from \"../feature-libraries/index.js\";\nimport { combineChunks } from \"../feature-libraries/index.js\";\nimport type {\n\tTreeViewConfiguration,\n\tImplicitFieldSchema,\n\tTreeViewAlpha,\n\tITreeAlpha,\n\tViewableTree,\n\tTreeView,\n\tReadSchema,\n\tVerboseTree,\n\tSimpleTreeSchema,\n} from \"../simple-tree/index.js\";\nimport {\n\ttype JsonCompatibleReadOnly,\n\ttype JsonCompatible,\n\tBreakable,\n\toneFromIterable,\n} from \"../util/index.js\";\n\nimport { initialize, initializerFromChunk } from \"./schematizeTree.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport {\n\tbuildConfiguredForest,\n\tdefaultSharedTreeOptions,\n\texportSimpleSchema,\n\ttype ForestOptions,\n} from \"./sharedTree.js\";\nimport { createTreeCheckout } from \"./treeCheckout.js\";\n\n/**\n * {@link independentView} options.\n * @alpha @input\n */\nexport interface IndependentViewOptions extends ForestOptions, Partial<CodecWriteOptions> {\n\t/**\n\t * Optional ID compressor for generating and compressing identifiers.\n\t * If not provided, a new one will be created.\n\t */\n\tidCompressor?: IIdCompressor | undefined;\n}\n\n/**\n * {@link createIndependentTreeAlpha} options.\n * @alpha\n */\nexport type CreateIndependentTreeAlphaOptions = ForestOptions &\n\t(\n\t\t| (IndependentViewOptions & {\n\t\t\t\t/**\n\t\t\t\t * Optional content for initializing the tree.\n\t\t\t\t * If not provided, the tree will be uninitialized.\n\t\t\t\t */\n\t\t\t\tcontent?: never;\n\t\t })\n\t\t| (ICodecOptions & {\n\t\t\t\t/**\n\t\t\t\t * Content for initializing the tree.\n\t\t\t\t * The content includes the idCompressor, so idCompressor should not be provided at the top level.\n\t\t\t\t */\n\t\t\t\tcontent: ViewContent;\n\t\t\t\t/**\n\t\t\t\t * Should not be provided when content is specified.\n\t\t\t\t * The idCompressor will be obtained from the content.\n\t\t\t\t */\n\t\t\t\tidCompressor?: never;\n\t\t })\n\t);\n\n/**\n * Create an uninitialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @alpha\n */\nexport function independentView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions?: IndependentViewOptions,\n): TreeViewAlpha<TSchema> {\n\treturn createIndependentTreeAlpha(options).viewWith(config) as TreeViewAlpha<TSchema>;\n}\n\n/**\n * Create an initialized {@link TreeView} that is not tied to any {@link ITree} instance.\n *\n * @remarks\n * Such a view can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n * @privateRemarks\n * TODO: Providing an API which generates a {@link ViewableTree} extended with export options from {@link ITreeAlpha} and maybe even branching APIs would likely be better that just exposing a {@link TreeViewAlpha}.\n * @alpha\n */\nexport function independentInitializedView<const TSchema extends ImplicitFieldSchema>(\n\tconfig: TreeViewConfiguration<TSchema>,\n\toptions: ForestOptions & ICodecOptions,\n\tcontent: ViewContent,\n): TreeViewAlpha<TSchema> {\n\treturn createIndependentTreeAlpha({ ...options, content }).viewWith(\n\t\tconfig,\n\t) as TreeViewAlpha<TSchema>;\n}\n\n/**\n * Create a {@link ViewableTree} that is not tied to any Fluid runtimes or services.\n *\n * @remarks\n * Such a tree can never experience collaboration or be persisted to to a Fluid Container.\n *\n * This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.\n *\n * @example\n * ```typescript\n * const tree = createIndependentTreeBeta();\n *\n * const stagedConfig = new TreeViewConfiguration({\n * \tschema: SchemaFactoryAlpha.types([\n * \t\tSchemaFactory.number,\n * \t\tSchemaFactoryAlpha.staged(SchemaFactory.string),\n * \t]),\n * });\n * const afterConfig = new TreeViewConfigurationAlpha({\n * \tschema: [SchemaFactory.number, SchemaFactory.string],\n * });\n *\n * // Initialize tree\n * {\n * \tconst view = tree.viewWith(stagedConfig);\n * \tview.initialize(1);\n * \tview.dispose();\n * }\n *\n * // Do schema upgrade\n * {\n * \tconst view = tree.viewWith(afterConfig);\n * \tview.upgradeSchema();\n * \tview.root = \"A\";\n * \tview.dispose();\n * }\n *\n * // Can still view tree with staged schema\n * {\n * \tconst view = tree.viewWith(stagedConfig);\n * \tassert.equal(view.root, \"A\");\n * \tview.dispose();\n * }\n * ```\n * @privateRemarks\n * Before stabilizing this as public, consider if we can instead just expose a better way to create regular Fluid service based SharedTrees for tests.\n * Something like https://github.com/microsoft/FluidFramework/pull/25422 might be a better long term stable/public solution.\n * @beta\n */\nexport function createIndependentTreeBeta<const TSchema extends ImplicitFieldSchema>(\n\toptions?: ForestOptions,\n): ViewableTree {\n\treturn createIndependentTreeAlpha<TSchema>(options);\n}\n\n/**\n * Alpha extensions to {@link createIndependentTreeBeta}.\n *\n * @param options - Configuration options for the independent tree.\n * This can be used to create an uninitialized tree, or `content` can be provided to create an initialized tree.\n * If content is provided, the idCompressor is a required part of it: otherwise it is optional and provided at the top level.\n *\n * @privateRemarks\n * TODO: Support more of {@link ITreeAlpha}, including branching APIs to allow for merges.\n * TODO: Better unify this logic with SharedTreeKernel and SharedTreeCore.\n *\n * Before further stabilizing: consider better ways to handle initialized vs uninitialized trees.\n * Perhaps it would be better to not allow initialize here at all, but expose the ability to load compressed tree content and stored schema via ITree or TreeView?\n * If keeping the option here, maybe a separate function of overload would be better? Or maybe flatten ViewContent inline to deduplicate the idCompressor options?\n * @alpha\n */\nexport function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSchema>(\n\toptions?: CreateIndependentTreeAlphaOptions,\n): ViewableTree & Pick<ITreeAlpha, \"exportVerbose\" | \"exportSimpleSchema\"> {\n\tconst breaker = new Breakable(\"independentView\");\n\tconst idCompressor: IIdCompressor =\n\t\toptions?.idCompressor ?? options?.content?.idCompressor ?? createIdCompressor();\n\tconst mintRevisionTag = (): RevisionTag => idCompressor.generateCompressedId();\n\tconst revisionTagCodec = new RevisionTagCodec(idCompressor);\n\n\t// To ensure the forest is in schema when constructed, start it with an empty schema and set the schema repository content later.\n\tconst schemaRepository = new TreeStoredSchemaRepository();\n\n\tconst forest = buildConfiguredForest(\n\t\tbreaker,\n\t\toptions?.forest ?? defaultSharedTreeOptions.forest,\n\t\tschemaRepository,\n\t\tidCompressor,\n\t\tdefaultIncrementalEncodingPolicy,\n\t);\n\n\tconst checkout = createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, {\n\t\tforest,\n\t\tschema: schemaRepository,\n\t\tbreaker,\n\t\tcodecOptions: options,\n\t});\n\n\tif (options?.content !== undefined) {\n\t\tconst schemaCodec = schemaCodecBuilder.buildDecoder(options);\n\t\tconst fieldBatchCodec = fieldBatchCodecBuilder.buildDecoder(options);\n\t\tconst newSchema = schemaCodec.decode(options.content.schema);\n\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // Is this right? If so, why is is needed?\n\t\t\tschema: { schema: newSchema, policy: defaultSchemaPolicy },\n\t\t\t// Not a summary blob — this is a synthetic decode of inline content.\n\t\t\tisSummary: false,\n\t\t};\n\t\tconst fieldCursors = fieldBatchCodec.decode(\n\t\t\toptions.content.tree as JsonCompatibleReadOnly,\n\t\t\tcontext,\n\t\t);\n\t\tassert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);\n\n\t\tconst fieldCursor = oneFromIterable(fieldCursors);\n\t\tassert(fieldCursor !== undefined, 0xc94 /* expected exactly one field in batch */);\n\n\t\tinitialize(\n\t\t\tcheckout,\n\t\t\tnewSchema,\n\t\t\tinitializerFromChunk(checkout, () =>\n\t\t\t\tcombineChunks(checkout.forest.chunkField(fieldCursor)),\n\t\t\t),\n\t\t);\n\t}\n\n\treturn {\n\t\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\t\tconfig: TreeViewConfiguration<TRoot>,\n\t\t): TreeView<TRoot> {\n\t\t\tconst out: TreeViewAlpha<TSchema> = new SchematizingSimpleTreeView<TSchema>(\n\t\t\t\tcheckout,\n\t\t\t\tconfig as TreeViewConfiguration as TreeViewConfiguration<ReadSchema<TSchema>>,\n\t\t\t\tcreateNodeIdentifierManager(idCompressor),\n\t\t\t);\n\t\t\treturn out as unknown as TreeView<TRoot>;\n\t\t},\n\n\t\texportVerbose(): VerboseTree | undefined {\n\t\t\treturn checkout.exportVerbose();\n\t\t},\n\n\t\texportSimpleSchema(): SimpleTreeSchema {\n\t\t\treturn exportSimpleSchema(checkout.storedSchema);\n\t\t},\n\t};\n}\n\n/**\n * The portion of SharedTree data typically persisted by the container.\n * Usable with {@link independentInitializedView} to create a {@link TreeView}\n * without loading a container.\n * @alpha\n */\nexport interface ViewContent {\n\t/**\n\t * Compressed tree from {@link (TreeAlpha:interface).exportCompressed}.\n\t * @remarks\n\t * This is an owning reference:\n\t * consumers of this content might modify this data in place (for example when applying edits) to avoid copying.\n\t */\n\treadonly tree: JsonCompatible<IFluidHandle>;\n\t/**\n\t * Persisted schema from {@link extractPersistedSchema}.\n\t */\n\treadonly schema: JsonCompatible;\n\t/**\n\t * IIdCompressor which will be used to decompress any compressed identifiers in `tree`\n\t * as well as for any other identifiers added to the view.\n\t */\n\treadonly idCompressor: IIdCompressor;\n}\n"]}
|