@fluidframework/tree 2.103.0 → 2.111.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.
Files changed (530) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +109 -0
  3. package/api-report/tree.alpha.api.md +60 -34
  4. package/api-report/tree.beta.api.md +49 -3
  5. package/api-report/tree.legacy.beta.api.md +49 -3
  6. package/dist/codec/versioned/format.js +2 -24
  7. package/dist/codec/versioned/format.js.map +1 -1
  8. package/dist/core/change-family/changeFamily.d.ts +3 -10
  9. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  10. package/dist/core/change-family/changeFamily.js.map +1 -1
  11. package/dist/core/rebase/types.d.ts +2 -2
  12. package/dist/core/rebase/types.js +2 -24
  13. package/dist/core/rebase/types.js.map +1 -1
  14. package/dist/core/schema-stored/formatV1.js +2 -24
  15. package/dist/core/schema-stored/formatV1.js.map +1 -1
  16. package/dist/core/schema-stored/formatV2.js +2 -24
  17. package/dist/core/schema-stored/formatV2.js.map +1 -1
  18. package/dist/core/schema-stored/index.js +3 -25
  19. package/dist/core/schema-stored/index.js.map +1 -1
  20. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  21. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  22. package/dist/core/tree/anchorSet.js +4 -8
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/detachedFieldIndexFormatCommon.js +2 -24
  25. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  26. package/dist/core/tree/detachedFieldIndexFormatV2.js +2 -24
  27. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  28. package/dist/core/tree/persistedTreeTextFormat.js +2 -24
  29. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  30. package/dist/entrypoints/alpha.d.ts +1 -1
  31. package/dist/entrypoints/alpha.d.ts.map +1 -1
  32. package/dist/entrypoints/alpha.js.map +1 -1
  33. package/dist/entrypoints/beta.d.ts +1 -1
  34. package/dist/entrypoints/beta.d.ts.map +1 -1
  35. package/dist/entrypoints/beta.js.map +1 -1
  36. package/dist/entrypoints/internal.js +2 -15
  37. package/dist/entrypoints/internal.js.map +1 -1
  38. package/dist/entrypoints/legacy.d.ts +1 -1
  39. package/dist/entrypoints/legacy.d.ts.map +1 -1
  40. package/dist/entrypoints/legacy.js.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/chunkedForest.js +7 -11
  42. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +19 -14
  44. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +13 -32
  46. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +85 -28
  48. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/codecs.js +83 -9
  50. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  51. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
  52. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  53. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +11 -0
  54. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js +2 -24
  56. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js +2 -24
  58. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +2 -24
  60. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js +2 -24
  62. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
  66. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
  70. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  72. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/index.js +2 -1
  74. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  75. package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -19
  76. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  77. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -13
  78. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  79. package/dist/feature-libraries/forest-summary/codec.d.ts +3 -3
  80. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  81. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  82. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
  83. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  84. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -6
  85. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  86. package/dist/feature-libraries/forest-summary/formatCommon.js +2 -24
  87. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  88. package/dist/feature-libraries/index.d.ts +1 -1
  89. package/dist/feature-libraries/index.d.ts.map +1 -1
  90. package/dist/feature-libraries/index.js +4 -25
  91. package/dist/feature-libraries/index.js.map +1 -1
  92. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js +2 -24
  93. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
  94. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  95. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -9
  96. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  97. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  98. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +10 -30
  99. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  100. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +2 -24
  101. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  102. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +2 -24
  103. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -5
  105. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  106. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  107. package/dist/feature-libraries/object-forest/objectForest.js +11 -55
  108. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  109. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +2 -24
  110. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
  111. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +2 -24
  112. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
  113. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +2 -24
  114. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  115. package/dist/feature-libraries/schema-index/formatV1.js +2 -24
  116. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
  117. package/dist/feature-libraries/schema-index/formatV2.js +2 -24
  118. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  119. package/dist/feature-libraries/sequence-field/formatV1.js +2 -24
  120. package/dist/feature-libraries/sequence-field/formatV1.js.map +1 -1
  121. package/dist/feature-libraries/sequence-field/formatV2.js +2 -24
  122. package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -1
  123. package/dist/feature-libraries/sequence-field/formatV3.js +2 -24
  124. package/dist/feature-libraries/sequence-field/formatV3.js.map +1 -1
  125. package/dist/index.d.ts +2 -2
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +4 -25
  128. package/dist/index.js.map +1 -1
  129. package/dist/packageVersion.d.ts +1 -1
  130. package/dist/packageVersion.js +1 -1
  131. package/dist/packageVersion.js.map +1 -1
  132. package/dist/shared-tree/independentView.d.ts.map +1 -1
  133. package/dist/shared-tree/independentView.js +4 -7
  134. package/dist/shared-tree/independentView.js.map +1 -1
  135. package/dist/shared-tree/index.d.ts +1 -1
  136. package/dist/shared-tree/index.d.ts.map +1 -1
  137. package/dist/shared-tree/index.js.map +1 -1
  138. package/dist/shared-tree/schematizingTreeView.d.ts +6 -5
  139. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  140. package/dist/shared-tree/schematizingTreeView.js +7 -41
  141. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  142. package/dist/shared-tree/sharedTree.d.ts +5 -1
  143. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  144. package/dist/shared-tree/sharedTree.js +13 -49
  145. package/dist/shared-tree/sharedTree.js.map +1 -1
  146. package/dist/shared-tree/sharedTreeChangeFormat.js +2 -24
  147. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  148. package/dist/shared-tree/transactionPostProcessor.d.ts +28 -0
  149. package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -0
  150. package/dist/shared-tree/transactionPostProcessor.js +28 -0
  151. package/dist/shared-tree/transactionPostProcessor.js.map +1 -0
  152. package/dist/shared-tree/treeAlpha.js +3 -3
  153. package/dist/shared-tree/treeAlpha.js.map +1 -1
  154. package/dist/shared-tree/treeCheckout.d.ts +28 -15
  155. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  156. package/dist/shared-tree/treeCheckout.js +124 -145
  157. package/dist/shared-tree/treeCheckout.js.map +1 -1
  158. package/dist/shared-tree/unhydratedTreeContext.d.ts +5 -5
  159. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  160. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  161. package/dist/shared-tree-core/branch.js +13 -17
  162. package/dist/shared-tree-core/branch.js.map +1 -1
  163. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -2
  164. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  165. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  166. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
  167. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  168. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -4
  169. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  170. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
  171. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  172. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  173. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
  174. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  175. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  176. package/dist/shared-tree-core/editManagerFormatCommons.js +2 -24
  177. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  178. package/dist/shared-tree-core/editManagerFormatV1toV4.js +2 -24
  179. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  180. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +2 -24
  181. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  182. package/dist/shared-tree-core/editManagerSummarizer.d.ts +5 -9
  183. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  184. package/dist/shared-tree-core/editManagerSummarizer.js +5 -10
  185. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  186. package/dist/shared-tree-core/index.d.ts +1 -1
  187. package/dist/shared-tree-core/index.d.ts.map +1 -1
  188. package/dist/shared-tree-core/index.js +3 -2
  189. package/dist/shared-tree-core/index.js.map +1 -1
  190. package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -24
  191. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  192. package/dist/shared-tree-core/messageFormatV1ToV4.js +2 -24
  193. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  194. package/dist/shared-tree-core/messageFormatVSharedBranches.js +2 -24
  195. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  196. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  197. package/dist/shared-tree-core/sharedTreeCore.js +9 -44
  198. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  199. package/dist/shared-tree-core/transaction.d.ts +84 -9
  200. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  201. package/dist/shared-tree-core/transaction.js +94 -37
  202. package/dist/shared-tree-core/transaction.js.map +1 -1
  203. package/dist/simple-tree/api/index.d.ts +1 -1
  204. package/dist/simple-tree/api/index.d.ts.map +1 -1
  205. package/dist/simple-tree/api/index.js.map +1 -1
  206. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  207. package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
  208. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  209. package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
  210. package/dist/simple-tree/api/schemaFactory.js +2 -2
  211. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  212. package/dist/simple-tree/api/simpleSchemaCodec.js +2 -24
  213. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  214. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
  215. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +4 -26
  216. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  217. package/dist/simple-tree/api/transactionTypes.d.ts +91 -28
  218. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  219. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  220. package/dist/simple-tree/api/tree.d.ts +96 -22
  221. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  222. package/dist/simple-tree/api/tree.js.map +1 -1
  223. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  224. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  225. package/dist/simple-tree/core/treeNodeKernel.js +83 -93
  226. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  227. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -7
  228. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  229. package/dist/simple-tree/core/unhydratedFlexTree.js +6 -10
  230. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  231. package/dist/simple-tree/index.d.ts +1 -1
  232. package/dist/simple-tree/index.d.ts.map +1 -1
  233. package/dist/simple-tree/index.js.map +1 -1
  234. package/dist/simple-tree/leafNodeSchema.js +2 -12
  235. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  236. package/dist/simple-tree/node-kinds/array/arrayNode.js +2 -6
  237. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  238. package/dist/simple-tree/simpleSchemaFormatV1.js +2 -24
  239. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  240. package/dist/tableSchema.d.ts +50 -4
  241. package/dist/tableSchema.d.ts.map +1 -1
  242. package/dist/tableSchema.js +202 -106
  243. package/dist/tableSchema.js.map +1 -1
  244. package/dist/text/index.d.ts +1 -0
  245. package/dist/text/index.d.ts.map +1 -1
  246. package/dist/text/index.js +3 -1
  247. package/dist/text/index.js.map +1 -1
  248. package/dist/text/textDomainFormatted.d.ts +69 -758
  249. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  250. package/dist/text/textDomainFormatted.js +275 -322
  251. package/dist/text/textDomainFormatted.js.map +1 -1
  252. package/dist/text/textDomainFormattedDefault.d.ts +273 -0
  253. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -0
  254. package/dist/text/textDomainFormattedDefault.js +94 -0
  255. package/dist/text/textDomainFormattedDefault.js.map +1 -0
  256. package/dist/util/arrayUtilities.d.ts +20 -0
  257. package/dist/util/arrayUtilities.d.ts.map +1 -1
  258. package/dist/util/arrayUtilities.js +24 -1
  259. package/dist/util/arrayUtilities.js.map +1 -1
  260. package/dist/util/compressedIds.d.ts +118 -0
  261. package/dist/util/compressedIds.d.ts.map +1 -0
  262. package/dist/util/compressedIds.js +133 -0
  263. package/dist/util/compressedIds.js.map +1 -0
  264. package/dist/util/index.d.ts +2 -1
  265. package/dist/util/index.d.ts.map +1 -1
  266. package/dist/util/index.js +11 -2
  267. package/dist/util/index.js.map +1 -1
  268. package/dist/util/rangeMap.d.ts +13 -0
  269. package/dist/util/rangeMap.d.ts.map +1 -1
  270. package/dist/util/rangeMap.js +69 -8
  271. package/dist/util/rangeMap.js.map +1 -1
  272. package/dist/util/typeboxBrand.js +2 -24
  273. package/dist/util/typeboxBrand.js.map +1 -1
  274. package/dist/util/utils.js +2 -24
  275. package/dist/util/utils.js.map +1 -1
  276. package/eslint.config.mts +0 -30
  277. package/lib/core/change-family/changeFamily.d.ts +3 -10
  278. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  279. package/lib/core/change-family/changeFamily.js.map +1 -1
  280. package/lib/core/rebase/types.d.ts +2 -2
  281. package/lib/core/rebase/types.js.map +1 -1
  282. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  283. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  284. package/lib/core/tree/anchorSet.js +1 -5
  285. package/lib/core/tree/anchorSet.js.map +1 -1
  286. package/lib/entrypoints/alpha.d.ts +1 -1
  287. package/lib/entrypoints/alpha.d.ts.map +1 -1
  288. package/lib/entrypoints/alpha.js.map +1 -1
  289. package/lib/entrypoints/beta.d.ts +1 -1
  290. package/lib/entrypoints/beta.d.ts.map +1 -1
  291. package/lib/entrypoints/beta.js.map +1 -1
  292. package/lib/entrypoints/legacy.d.ts +1 -1
  293. package/lib/entrypoints/legacy.d.ts.map +1 -1
  294. package/lib/entrypoints/legacy.js.map +1 -1
  295. package/lib/feature-libraries/chunked-forest/chunkedForest.js +1 -5
  296. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  297. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +19 -14
  298. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +14 -33
  300. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  301. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +85 -28
  302. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/codec/codecs.js +82 -9
  304. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  305. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
  306. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  307. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +12 -1
  308. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  309. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  310. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
  314. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
  316. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  318. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  319. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  320. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  321. package/lib/feature-libraries/flex-tree/lazyEntity.js +1 -11
  322. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  323. package/lib/feature-libraries/flex-tree/lazyNode.js +1 -11
  324. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  325. package/lib/feature-libraries/forest-summary/codec.d.ts +3 -3
  326. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  327. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  328. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
  329. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  330. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -6
  331. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  332. package/lib/feature-libraries/index.d.ts +1 -1
  333. package/lib/feature-libraries/index.d.ts.map +1 -1
  334. package/lib/feature-libraries/index.js +1 -1
  335. package/lib/feature-libraries/index.js.map +1 -1
  336. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  337. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -10
  338. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  339. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  340. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +10 -30
  341. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -5
  343. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  344. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  345. package/lib/feature-libraries/object-forest/objectForest.js +1 -45
  346. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  347. package/lib/index.d.ts +2 -2
  348. package/lib/index.d.ts.map +1 -1
  349. package/lib/index.js +1 -1
  350. package/lib/index.js.map +1 -1
  351. package/lib/packageVersion.d.ts +1 -1
  352. package/lib/packageVersion.js +1 -1
  353. package/lib/packageVersion.js.map +1 -1
  354. package/lib/shared-tree/independentView.d.ts.map +1 -1
  355. package/lib/shared-tree/independentView.js +5 -8
  356. package/lib/shared-tree/independentView.js.map +1 -1
  357. package/lib/shared-tree/index.d.ts +1 -1
  358. package/lib/shared-tree/index.d.ts.map +1 -1
  359. package/lib/shared-tree/index.js.map +1 -1
  360. package/lib/shared-tree/schematizingTreeView.d.ts +6 -5
  361. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  362. package/lib/shared-tree/schematizingTreeView.js +4 -38
  363. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  364. package/lib/shared-tree/sharedTree.d.ts +5 -1
  365. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  366. package/lib/shared-tree/sharedTree.js +9 -45
  367. package/lib/shared-tree/sharedTree.js.map +1 -1
  368. package/lib/shared-tree/transactionPostProcessor.d.ts +28 -0
  369. package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -0
  370. package/lib/shared-tree/transactionPostProcessor.js +23 -0
  371. package/lib/shared-tree/transactionPostProcessor.js.map +1 -0
  372. package/lib/shared-tree/treeAlpha.js +3 -3
  373. package/lib/shared-tree/treeAlpha.js.map +1 -1
  374. package/lib/shared-tree/treeCheckout.d.ts +28 -15
  375. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  376. package/lib/shared-tree/treeCheckout.js +80 -101
  377. package/lib/shared-tree/treeCheckout.js.map +1 -1
  378. package/lib/shared-tree/unhydratedTreeContext.d.ts +5 -5
  379. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  380. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  381. package/lib/shared-tree-core/branch.js +1 -5
  382. package/lib/shared-tree-core/branch.js.map +1 -1
  383. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -2
  384. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  385. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  386. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
  387. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  388. package/lib/shared-tree-core/editManagerCodecsCommons.js +3 -5
  389. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  390. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
  391. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  392. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  393. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
  394. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  395. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  396. package/lib/shared-tree-core/editManagerSummarizer.d.ts +5 -9
  397. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  398. package/lib/shared-tree-core/editManagerSummarizer.js +5 -10
  399. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  400. package/lib/shared-tree-core/index.d.ts +1 -1
  401. package/lib/shared-tree-core/index.d.ts.map +1 -1
  402. package/lib/shared-tree-core/index.js +1 -1
  403. package/lib/shared-tree-core/index.js.map +1 -1
  404. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  405. package/lib/shared-tree-core/sharedTreeCore.js +4 -39
  406. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  407. package/lib/shared-tree-core/transaction.d.ts +84 -9
  408. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  409. package/lib/shared-tree-core/transaction.js +74 -17
  410. package/lib/shared-tree-core/transaction.js.map +1 -1
  411. package/lib/simple-tree/api/index.d.ts +1 -1
  412. package/lib/simple-tree/api/index.d.ts.map +1 -1
  413. package/lib/simple-tree/api/index.js.map +1 -1
  414. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  415. package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
  416. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  417. package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
  418. package/lib/simple-tree/api/schemaFactory.js +2 -2
  419. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  420. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
  421. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  422. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  423. package/lib/simple-tree/api/transactionTypes.d.ts +91 -28
  424. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  425. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  426. package/lib/simple-tree/api/tree.d.ts +96 -22
  427. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  428. package/lib/simple-tree/api/tree.js.map +1 -1
  429. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  430. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  431. package/lib/simple-tree/core/treeNodeKernel.js +1 -11
  432. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  433. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -7
  434. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  435. package/lib/simple-tree/core/unhydratedFlexTree.js +1 -5
  436. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  437. package/lib/simple-tree/index.d.ts +1 -1
  438. package/lib/simple-tree/index.d.ts.map +1 -1
  439. package/lib/simple-tree/index.js.map +1 -1
  440. package/lib/simple-tree/leafNodeSchema.js +1 -11
  441. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  442. package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -5
  443. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  444. package/lib/tableSchema.d.ts +50 -4
  445. package/lib/tableSchema.d.ts.map +1 -1
  446. package/lib/tableSchema.js +171 -75
  447. package/lib/tableSchema.js.map +1 -1
  448. package/lib/text/index.d.ts +1 -0
  449. package/lib/text/index.d.ts.map +1 -1
  450. package/lib/text/index.js +1 -0
  451. package/lib/text/index.js.map +1 -1
  452. package/lib/text/textDomainFormatted.d.ts +69 -758
  453. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  454. package/lib/text/textDomainFormatted.js +277 -324
  455. package/lib/text/textDomainFormatted.js.map +1 -1
  456. package/lib/text/textDomainFormattedDefault.d.ts +273 -0
  457. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -0
  458. package/lib/text/textDomainFormattedDefault.js +91 -0
  459. package/lib/text/textDomainFormattedDefault.js.map +1 -0
  460. package/lib/util/arrayUtilities.d.ts +20 -0
  461. package/lib/util/arrayUtilities.d.ts.map +1 -1
  462. package/lib/util/arrayUtilities.js +22 -0
  463. package/lib/util/arrayUtilities.js.map +1 -1
  464. package/lib/util/compressedIds.d.ts +118 -0
  465. package/lib/util/compressedIds.d.ts.map +1 -0
  466. package/lib/util/compressedIds.js +124 -0
  467. package/lib/util/compressedIds.js.map +1 -0
  468. package/lib/util/index.d.ts +2 -1
  469. package/lib/util/index.d.ts.map +1 -1
  470. package/lib/util/index.js +2 -1
  471. package/lib/util/index.js.map +1 -1
  472. package/lib/util/rangeMap.d.ts +13 -0
  473. package/lib/util/rangeMap.d.ts.map +1 -1
  474. package/lib/util/rangeMap.js +69 -8
  475. package/lib/util/rangeMap.js.map +1 -1
  476. package/package.json +25 -24
  477. package/src/core/change-family/changeFamily.ts +3 -12
  478. package/src/core/rebase/types.ts +2 -2
  479. package/src/core/schema-stored/storedSchemaRepository.ts +2 -2
  480. package/src/entrypoints/alpha.ts +12 -8
  481. package/src/entrypoints/beta.ts +8 -0
  482. package/src/entrypoints/legacy.ts +8 -0
  483. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +35 -64
  484. package/src/feature-libraries/chunked-forest/codec/codecs.ts +138 -42
  485. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +32 -4
  486. package/src/feature-libraries/chunked-forest/codec/index.ts +1 -0
  487. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +7 -19
  488. package/src/feature-libraries/chunked-forest/index.ts +3 -0
  489. package/src/feature-libraries/forest-summary/codec.ts +5 -3
  490. package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -5
  491. package/src/feature-libraries/index.ts +3 -0
  492. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +13 -9
  493. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +14 -47
  494. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +0 -5
  495. package/src/index.ts +13 -8
  496. package/src/packageVersion.ts +1 -1
  497. package/src/shared-tree/independentView.ts +5 -10
  498. package/src/shared-tree/index.ts +1 -0
  499. package/src/shared-tree/schematizingTreeView.ts +29 -25
  500. package/src/shared-tree/sharedTree.ts +18 -10
  501. package/src/shared-tree/transactionPostProcessor.ts +40 -0
  502. package/src/shared-tree/treeAlpha.ts +3 -3
  503. package/src/shared-tree/treeCheckout.ts +120 -95
  504. package/src/shared-tree/unhydratedTreeContext.ts +18 -15
  505. package/src/shared-tree-core/editManagerCodecs.ts +3 -2
  506. package/src/shared-tree-core/editManagerCodecsCommons.ts +10 -14
  507. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -2
  508. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -2
  509. package/src/shared-tree-core/editManagerSummarizer.ts +5 -9
  510. package/src/shared-tree-core/index.ts +8 -5
  511. package/src/shared-tree-core/sharedTreeCore.ts +3 -2
  512. package/src/shared-tree-core/transaction.ts +148 -18
  513. package/src/simple-tree/api/index.ts +13 -9
  514. package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
  515. package/src/simple-tree/api/schemaFactory.ts +2 -2
  516. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +2 -2
  517. package/src/simple-tree/api/transactionTypes.ts +111 -39
  518. package/src/simple-tree/api/tree.ts +152 -47
  519. package/src/simple-tree/api/treeBeta.ts +2 -0
  520. package/src/simple-tree/core/treeNodeSchema.ts +7 -7
  521. package/src/simple-tree/index.ts +12 -8
  522. package/src/tableSchema.ts +306 -80
  523. package/src/text/index.ts +1 -0
  524. package/src/text/textDomainFormatted.ts +520 -415
  525. package/src/text/textDomainFormattedDefault.ts +150 -0
  526. package/src/util/arrayUtilities.ts +35 -0
  527. package/src/util/compressedIds.ts +216 -0
  528. package/src/util/index.ts +17 -0
  529. package/src/util/rangeMap.ts +108 -9
  530. package/tsconfig.json +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAMnF,qEAAmE;AACnE,+BAAoC;AAEpC,sDAAuE;AAOvE,qDAAiE;AACjE,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AAGnC,gDAe2B;AAsB3B;;;GAGG;AACH,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAEhE;;GAEG;AACH,SAAgB,MAAM,CACrB,KAA8B,EAC9B,iBAAoC,EACpC,kBAAuC;IAEvC,OAAO,IAAA,gCAAa,EAC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AAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAA,yCAAgB,EAAC,MAAM,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"@fluidframework/id-compressor\";\nimport { isFinalId } from \"@fluidframework/id-compressor/internal\";\nimport { v5 as uuidV5 } from \"uuid\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex, brand } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Referenced by doc comments\nimport type { FieldBatchEncodingContext, IncrementalDecoder } from \"./codecs.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedChunkShapeV2,\n\ttype EncodedFieldBatchV1OrV2,\n\ttype EncodedFieldBatchV2,\n\ttype EncodedIncrementalChunkShape,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedSpecializedNodeShape,\n\ttype EncodedValueShape,\n\ttype ShapeIndex,\n\tSpecialField,\n\tsupportsIncrementalEncoding,\n} from \"./format/index.js\";\n\nexport interface IdDecodingContext {\n\tidCompressor: IIdCompressor;\n\t/**\n\t * The creator of any local Ids to be decoded.\n\t */\n\toriginatorId: SessionId;\n\t/**\n\t * {@inheritdoc FieldBatchEncodingContext.isSummary}\n\t */\n\tisSummary: boolean;\n\t/**\n\t * See {@link FieldBatchEncodingContext.healUnresolvableIdentifiersOnDecode}.\n\t */\n\thealUnresolvableIdentifiersOnDecode?: boolean;\n\t/**\n\t * See {@link FieldBatchEncodingContext.sharedObjectId}.\n\t */\n\tsharedObjectId?: string;\n}\n\n/**\n * Random v4 UUID generated as a namespace for the \"heal an unresolvable identifier into a stable UUID\"\n * path in {@link readValue}. This scheme requires consensus across all clients to function.\n */\nconst healingNamespace = \"f8a89df3-6882-400f-b913-4c1f6f0157bd\";\n\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatchV1OrV2,\n\tidDecodingContext: IdDecodingContext,\n\tincrementalDecoder?: IncrementalDecoder,\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext, incrementalDecoder),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\n/**\n * Resolves `shapeIndex` to a fully-resolved {@link EncodedNodeShape}, normalizing away any\n * specialized node shapes (`f`) along the way by applying their overlays via\n * {@link applySpecialization} until a concrete node shape is reached.\n *\n * @param input - The index of the shape to resolve, which must be a concrete or specialized node shape.\n * @param context - The decoding context containing the shape definitions.\n * @param pendingResolution - (Internal) A set of shape indices visited so far in the current resolution chain, used to detect cycles in the specialization chain. Most callers should not provide this argument.\n *\n * @remarks\n * Exported for testing.\n */\nexport function normalizeToNodeShape(\n\tinput: EncodedNodeShape | EncodedSpecializedNodeShape,\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tpendingResolution: Set<ShapeIndex> = new Set(),\n): EncodedNodeShape {\n\tif (!(\"base\" in input)) {\n\t\treturn input;\n\t}\n\n\tconst baseIndex = input.base;\n\tassert(!pendingResolution.has(baseIndex), 0xcfb /* cyclic specialized node shape chain */);\n\tpendingResolution.add(baseIndex);\n\tconst encoded = context.shapes[baseIndex];\n\tassert(encoded !== undefined, 0xcfc /* shape index out of bounds */);\n\n\tconst baseShape = encoded.c ?? (\"f\" in encoded ? encoded.f : undefined);\n\tassert(\n\t\tbaseShape !== undefined,\n\t\t0xcfd /* shape at index must be a concrete (c) or specialized (f) node shape */,\n\t);\n\n\treturn applySpecialization(\n\t\tnormalizeToNodeShape(baseShape, context, pendingResolution),\n\t\tinput,\n\t\tcontext,\n\t);\n}\n\n/**\n * Produces a specialized {@link EncodedNodeShape} by overlaying `overrides` onto `base`.\n *\n * See {@link EncodedSpecializedNodeShape} for the override/inherit/clear semantics.\n *\n * @remarks\n * Exported for testing.\n */\nexport function applySpecialization(\n\tbase: EncodedNodeShape,\n\toverrides: EncodedSpecializedNodeShape,\n\tcontext: DecoderContext<EncodedChunkShape>,\n): EncodedNodeShape {\n\tconst fields = [...(base.fields ?? [])];\n\tconst indexFromKey = new Map<FieldKey, number>();\n\tfor (const [i, [keyEncoded]] of fields.entries()) {\n\t\tconst key = context.identifier<FieldKey>(keyEncoded);\n\t\tassert(!indexFromKey.has(key), 0xcfe /* duplicate field key in base node shape */);\n\t\tindexFromKey.set(key, i);\n\t}\n\n\t// Replace fields in base with overrides, append new keys in overrides in the order they are specified.\n\tconst seenOverrideKeys = new Set<FieldKey>();\n\tfor (const [keyEncoded, shapeIndex] of overrides.fields ?? []) {\n\t\tconst key = context.identifier<FieldKey>(keyEncoded);\n\t\tassert(\n\t\t\t!seenOverrideKeys.has(key),\n\t\t\t0xcff /* duplicate field key in specialized node shape */,\n\t\t);\n\t\tseenOverrideKeys.add(key);\n\t\tconst existingIndex = indexFromKey.get(key);\n\t\tif (existingIndex === undefined) {\n\t\t\tfields.push([keyEncoded, shapeIndex]);\n\t\t} else {\n\t\t\tconst index = fields[existingIndex];\n\t\t\tassert(index !== undefined, 0xd00 /* expected existing field index */);\n\t\t\tfields[existingIndex] = [index[0], shapeIndex];\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: base.type,\n\t\tvalue: resolveOverride(overrides.value, base.value),\n\t\tfields: fields.length > 0 ? fields : undefined,\n\t\textraFields: resolveOverride(overrides.extraFields, base.extraFields),\n\t};\n}\n\n/**\n * Resolves an override against a base value.\n *\n * @param override - `undefined` means the override is absent (inherit from base); `null` is the\n * explicit-clear sentinel needed because JSON.stringify drops `undefined`-valued properties, making\n * property-presence indistinguishable from absent on the wire.\n * @param baseValue - The value to inherit when the override is absent.\n */\nfunction resolveOverride<T>(\n\t// eslint-disable-next-line @rushstack/no-new-null\n\toverride: T | null | undefined,\n\tbaseValue: T | undefined,\n): T | undefined {\n\tif (override === undefined) {\n\t\treturn baseValue;\n\t}\n\tif (override === null) {\n\t\treturn undefined;\n\t}\n\treturn override;\n}\n\n/**\n * Decoder for {@link EncodedSpecializedNodeShape}s.\n * Applies the specialization's field overrides to the resolved base node shape, then delegates\n * to a {@link NodeDecoder} built from the resulting shape.\n */\nexport class SpecializedNodeDecoder implements ChunkDecoder {\n\tprivate readonly inner: NodeDecoder;\n\tpublic constructor(\n\t\tshape: EncodedSpecializedNodeShape,\n\t\tcontext: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.inner = new NodeDecoder(normalizeToNodeShape(shape, context), context);\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\treturn this.inner.decode(decoders, stream);\n\t}\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n\te(\n\t\tshape: EncodedIncrementalChunkShape,\n\t\tcontext: DecoderContext<EncodedChunkShapeV2>,\n\t): ChunkDecoder {\n\t\treturn new IncrementalChunkDecoder(context);\n\t},\n\tf(shape: EncodedSpecializedNodeShape, context): ChunkDecoder {\n\t\treturn new SpecializedNodeDecoder(shape, context);\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\tif (typeof streamValue === \"string\") {\n\t\t\t\treturn streamValue;\n\t\t\t}\n\t\t\tconst idCompressor = idDecodingContext.idCompressor;\n\t\t\t// OpSpaceCompressedIds are negative, and require a session-id to compute their value.\n\t\t\t// Due to a bug, we have some special casing for them (see below).\n\t\t\tif (\n\t\t\t\tidDecodingContext.isSummary === true &&\n\t\t\t\t!isFinalId(streamValue as OpSpaceCompressedId)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tidDecodingContext.healUnresolvableIdentifiersOnDecode === true &&\n\t\t\t\t\tidDecodingContext.sharedObjectId !== undefined\n\t\t\t\t) {\n\t\t\t\t\t// Documents written before the encode-side fix for non-finalized identifier\n\t\t\t\t\t// values can persist negative op-space IDs that are no\n\t\t\t\t\t// longer resolvable once the originating session's local state has been stripped.\n\t\t\t\t\t// When loading such a summary with the heal-on-decode option on, synthesize a deterministic\n\t\t\t\t\t// stable UUID so all readers of the same blob agree on the resulting value.\n\t\t\t\t\t//\n\t\t\t\t\t// The heal path is intentionally restricted to summary loads — an\n\t\t\t\t\t// unresolvable ID encountered while applying an op should still surface as\n\t\t\t\t\t// an error, since it indicates a real bug rather than a recoverable state.\n\t\t\t\t\treturn uuidV5(\n\t\t\t\t\t\t`${idDecodingContext.sharedObjectId}|${streamValue}`,\n\t\t\t\t\t\thealingNamespace,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// See `SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode` for details on this error.\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Summary could not be loaded due incorrectly encoded identifier. See SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode for mitigation.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn idCompressor.decompress(\n\t\t\t\tidCompressor.normalizeToSessionSpace(\n\t\t\t\t\tstreamValue as OpSpaceCompressedId,\n\t\t\t\t\tidDecodingContext.originatorId,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0: {\n\t\t\treturn emptyChunk;\n\t\t}\n\t\tcase 1: {\n\t\t\treturn chunks[0] ?? oob();\n\t\t}\n\t\tdefault: {\n\t\t\treturn new SequenceChunk(chunks);\n\t\t}\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedIncrementalChunkShape}s.\n */\nexport class IncrementalChunkDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly context: DecoderContext<EncodedChunkShapeV2>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.context.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\n\t\tconst chunkDecoder = (batch: EncodedFieldBatchV2): TreeChunk => {\n\t\t\tassert(\n\t\t\t\tsupportsIncrementalEncoding(batch.version),\n\t\t\t\t0xc9f /* Unsupported FieldBatchFormatVersion for incremental chunks; must be v2 or higher */,\n\t\t\t);\n\t\t\tconst context = new DecoderContext(\n\t\t\t\tbatch.identifiers,\n\t\t\t\tbatch.shapes,\n\t\t\t\tthis.context.idDecodingContext,\n\t\t\t\tthis.context.incrementalDecoder,\n\t\t\t);\n\t\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\n\t\t\treturn aggregateChunks(chunks);\n\t\t};\n\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\treturn this.context.incrementalDecoder.decodeIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t\tchunkDecoder,\n\t\t);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `context`).\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length > 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const decoder of this.fieldDecoders) {\n\t\t\tconst [key, content] = decoder(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.context);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chunkDecoding.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/chunkDecoding.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmF;AAOnF,sDAAuE;AAOvE,qDAA+F;AAC/F,oDAA8C;AAC9C,oDAA8C;AAC9C,0DAAoD;AAEpD,qEASkC;AAClC,uEAImC;AAEnC,gDAe2B;AA2B3B;;GAEG;AACH,SAAgB,MAAM,CACrB,KAA8B,EAC9B,iBAAoC,EACpC,kBAAuC;IAEvC,OAAO,IAAA,gCAAa,EACnB,cAAc,EACd,IAAI,wCAAc,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,EAC1F,KAAK,EACL,kBAAU,CACV,CAAC;AACH,CAAC;AAXD,wBAWC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CACnC,KAAqD,EACrD,OAA0C,EAC1C,oBAAqC,IAAI,GAAG,EAAE;IAE9C,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;IAC7B,IAAA,iBAAM,EAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC3F,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAErE,MAAM,SAAS,GAAG,OAAO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AC;YAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAA,yCAAgB,EAAC,MAAM,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3C,MAAM,GAAG,GAAa,IAAA,8CAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACF,CAAC;QAED,OAAO,IAAI,0BAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACD;AAnDD,kCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionSpaceCompressedId,\n} from \"@fluidframework/id-compressor\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../../codec/index.js\";\nimport type {\n\tFieldKey,\n\tTreeNodeSchemaIdentifier,\n\tValue,\n\tTreeChunk,\n} from \"../../../core/index.js\";\nimport { assertValidIndex, brand, decompressIdentifierIfNeeded } from \"../../../util/index.js\";\nimport { BasicChunk } from \"../basicChunk.js\";\nimport { emptyChunk } from \"../emptyChunk.js\";\nimport { SequenceChunk } from \"../sequenceChunk.js\";\n\nimport {\n\ttype ChunkDecoder,\n\ttype StreamCursor,\n\tgetChecked,\n\treadStream,\n\treadStreamBoolean,\n\treadStreamNumber,\n\treadStreamStream,\n\treadStreamValue,\n} from \"./chunkCodecUtilities.js\";\nimport {\n\tDecoderContext,\n\tdecode as genericDecode,\n\treadStreamIdentifier,\n} from \"./chunkDecodingGeneric.js\";\nimport type { IncrementalDecoder } from \"./codecs.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedChunkShapeV2,\n\ttype EncodedFieldBatchV1OrV2,\n\ttype EncodedFieldBatchV2,\n\ttype EncodedIncrementalChunkShape,\n\ttype EncodedInlineArrayShape,\n\ttype EncodedNestedArrayShape,\n\ttype EncodedNodeShape,\n\ttype EncodedSpecializedNodeShape,\n\ttype EncodedValueShape,\n\ttype ShapeIndex,\n\tSpecialField,\n\tsupportsIncrementalEncoding,\n} from \"./format/index.js\";\n\n/**\n * Context for decoding identifiers.\n * @remarks\n * See {@link FieldBatchDecodingContext} for the production implementation of this.\n *\n * This intentionally avoids exposing anything which depends on the underlying id-compressor's session ID to avoid confusion with the session ID of the compressor which encoded the data.\n * If the session ID of the encoder which encoded the data is known, that information is baked into `resolveEncodedId`.\n */\nexport interface IdDecodingContext {\n\t/**\n\t * Compressor which can decompress session-space identifiers from {@link resolveEncodedId} as needed.\n\t */\n\treadonly idCompressor: Pick<IIdCompressor, \"decompress\">;\n\t/**\n\t * Resolves an encoded op-space identifier to either a session-space ID\n\t * (which {@link idCompressor} can decompress if needed)\n\t * or a string (which passes through unchanged).\n\t * @remarks\n\t * In contexts where non-final identifiers can't be supported (where no originator session is available),\n\t * if a non-final identifier is encountered, this may throw or perform a data healing workaround.\n\t * See {@link FieldBatchDecodingContext.forOp} and {@link FieldBatchDecodingContext.forSummary} for details.\n\t */\n\treadonly resolveEncodedId: (id: OpSpaceCompressedId) => SessionSpaceCompressedId | string;\n}\n\n/**\n * Decode `chunk` into a TreeChunk.\n */\nexport function decode(\n\tchunk: EncodedFieldBatchV1OrV2,\n\tidDecodingContext: IdDecodingContext,\n\tincrementalDecoder?: IncrementalDecoder,\n): TreeChunk[] {\n\treturn genericDecode(\n\t\tdecoderLibrary,\n\t\tnew DecoderContext(chunk.identifiers, chunk.shapes, idDecodingContext, incrementalDecoder),\n\t\tchunk,\n\t\tanyDecoder,\n\t);\n}\n\n/**\n * Resolves `shapeIndex` to a fully-resolved {@link EncodedNodeShape}, normalizing away any\n * specialized node shapes (`f`) along the way by applying their overlays via\n * {@link applySpecialization} until a concrete node shape is reached.\n *\n * @param input - The index of the shape to resolve, which must be a concrete or specialized node shape.\n * @param context - The decoding context containing the shape definitions.\n * @param pendingResolution - (Internal) A set of shape indices visited so far in the current resolution chain, used to detect cycles in the specialization chain. Most callers should not provide this argument.\n *\n * @remarks\n * Exported for testing.\n */\nexport function normalizeToNodeShape(\n\tinput: EncodedNodeShape | EncodedSpecializedNodeShape,\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tpendingResolution: Set<ShapeIndex> = new Set(),\n): EncodedNodeShape {\n\tif (!(\"base\" in input)) {\n\t\treturn input;\n\t}\n\n\tconst baseIndex = input.base;\n\tassert(!pendingResolution.has(baseIndex), 0xcfb /* cyclic specialized node shape chain */);\n\tpendingResolution.add(baseIndex);\n\tconst encoded = context.shapes[baseIndex];\n\tassert(encoded !== undefined, 0xcfc /* shape index out of bounds */);\n\n\tconst baseShape = encoded.c ?? (\"f\" in encoded ? encoded.f : undefined);\n\tassert(\n\t\tbaseShape !== undefined,\n\t\t0xcfd /* shape at index must be a concrete (c) or specialized (f) node shape */,\n\t);\n\n\treturn applySpecialization(\n\t\tnormalizeToNodeShape(baseShape, context, pendingResolution),\n\t\tinput,\n\t\tcontext,\n\t);\n}\n\n/**\n * Produces a specialized {@link EncodedNodeShape} by overlaying `overrides` onto `base`.\n *\n * See {@link EncodedSpecializedNodeShape} for the override/inherit/clear semantics.\n *\n * @remarks\n * Exported for testing.\n */\nexport function applySpecialization(\n\tbase: EncodedNodeShape,\n\toverrides: EncodedSpecializedNodeShape,\n\tcontext: DecoderContext<EncodedChunkShape>,\n): EncodedNodeShape {\n\tconst fields = [...(base.fields ?? [])];\n\tconst indexFromKey = new Map<FieldKey, number>();\n\tfor (const [i, [keyEncoded]] of fields.entries()) {\n\t\tconst key = context.identifier<FieldKey>(keyEncoded);\n\t\tassert(!indexFromKey.has(key), 0xcfe /* duplicate field key in base node shape */);\n\t\tindexFromKey.set(key, i);\n\t}\n\n\t// Replace fields in base with overrides, append new keys in overrides in the order they are specified.\n\tconst seenOverrideKeys = new Set<FieldKey>();\n\tfor (const [keyEncoded, shapeIndex] of overrides.fields ?? []) {\n\t\tconst key = context.identifier<FieldKey>(keyEncoded);\n\t\tassert(\n\t\t\t!seenOverrideKeys.has(key),\n\t\t\t0xcff /* duplicate field key in specialized node shape */,\n\t\t);\n\t\tseenOverrideKeys.add(key);\n\t\tconst existingIndex = indexFromKey.get(key);\n\t\tif (existingIndex === undefined) {\n\t\t\tfields.push([keyEncoded, shapeIndex]);\n\t\t} else {\n\t\t\tconst index = fields[existingIndex];\n\t\t\tassert(index !== undefined, 0xd00 /* expected existing field index */);\n\t\t\tfields[existingIndex] = [index[0], shapeIndex];\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: base.type,\n\t\tvalue: resolveOverride(overrides.value, base.value),\n\t\tfields: fields.length > 0 ? fields : undefined,\n\t\textraFields: resolveOverride(overrides.extraFields, base.extraFields),\n\t};\n}\n\n/**\n * Resolves an override against a base value.\n *\n * @param override - `undefined` means the override is absent (inherit from base); `null` is the\n * explicit-clear sentinel needed because JSON.stringify drops `undefined`-valued properties, making\n * property-presence indistinguishable from absent on the wire.\n * @param baseValue - The value to inherit when the override is absent.\n */\nfunction resolveOverride<T>(\n\t// eslint-disable-next-line @rushstack/no-new-null\n\toverride: T | null | undefined,\n\tbaseValue: T | undefined,\n): T | undefined {\n\tif (override === undefined) {\n\t\treturn baseValue;\n\t}\n\tif (override === null) {\n\t\treturn undefined;\n\t}\n\treturn override;\n}\n\n/**\n * Decoder for {@link EncodedSpecializedNodeShape}s.\n * Applies the specialization's field overrides to the resolved base node shape, then delegates\n * to a {@link NodeDecoder} built from the resulting shape.\n */\nexport class SpecializedNodeDecoder implements ChunkDecoder {\n\tprivate readonly inner: NodeDecoder;\n\tpublic constructor(\n\t\tshape: EncodedSpecializedNodeShape,\n\t\tcontext: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.inner = new NodeDecoder(normalizeToNodeShape(shape, context), context);\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\treturn this.inner.decode(decoders, stream);\n\t}\n}\n\nconst decoderLibrary = new DiscriminatedUnionDispatcher<\n\tEncodedChunkShape,\n\t[context: DecoderContext<EncodedChunkShape>],\n\tChunkDecoder\n>({\n\ta(shape: EncodedNestedArrayShape, context): ChunkDecoder {\n\t\treturn new NestedArrayDecoder(shape);\n\t},\n\tb(shape: EncodedInlineArrayShape, context): ChunkDecoder {\n\t\treturn new InlineArrayDecoder(shape);\n\t},\n\tc(shape: EncodedNodeShape, context): ChunkDecoder {\n\t\treturn new NodeDecoder(shape, context);\n\t},\n\td(shape: EncodedAnyShape): ChunkDecoder {\n\t\treturn anyDecoder;\n\t},\n\te(\n\t\tshape: EncodedIncrementalChunkShape,\n\t\tcontext: DecoderContext<EncodedChunkShapeV2>,\n\t): ChunkDecoder {\n\t\treturn new IncrementalChunkDecoder(context);\n\t},\n\tf(shape: EncodedSpecializedNodeShape, context): ChunkDecoder {\n\t\treturn new SpecializedNodeDecoder(shape, context);\n\t},\n});\n\n/**\n * Decode a node's value from `stream` using its shape.\n */\nexport function readValue(\n\tstream: StreamCursor,\n\tshape: EncodedValueShape,\n\tidDecodingContext: IdDecodingContext,\n): Value {\n\tif (shape === undefined) {\n\t\treturn readStreamBoolean(stream) ? readStreamValue(stream) : undefined;\n\t} else {\n\t\tif (shape === true) {\n\t\t\treturn readStreamValue(stream);\n\t\t} else if (shape === false) {\n\t\t\treturn undefined;\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x734 /* expected a single constant for value */);\n\t\t\treturn shape[0] as Value;\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the decoding of identifier fields.\n\t\t\tconst streamValue = readStream(stream);\n\t\t\tassert(\n\t\t\t\ttypeof streamValue === \"number\" || typeof streamValue === \"string\",\n\t\t\t\t0x997 /* identifier must be string or number. */,\n\t\t\t);\n\t\t\t// Strings (StableId UUIDs, heal-synthesized v5 UUIDs, or arbitrary user\n\t\t\t// identifier strings) are already in the stored form and pass through.\n\t\t\t// Op-space compressed ids are resolved by the caller-supplied\n\t\t\t// `resolveEncodedId`, which encapsulates the originator lookup, finalized-id\n\t\t\t// normalization, and (for the forest summarizer's heal path) UUIDv5 synthesis.\n\t\t\tconst sessionIdOrString: SessionSpaceCompressedId | string =\n\t\t\t\ttypeof streamValue === \"string\"\n\t\t\t\t\t? streamValue\n\t\t\t\t\t: idDecodingContext.resolveEncodedId(streamValue as OpSpaceCompressedId);\n\t\t\t// Performance:\n\t\t\t// Currently, we just fully expand the identifier here rather than keeping it in the SessionSpaceCompressedId format.\n\t\t\t// Avoiding this expansion, and keeping the in memory format using SessionSpaceCompressedId would be a good optimization for the future.\n\t\t\t// Keeping this optimization possible is why `resolveEncodedId` doesn't simply return a string.\n\t\t\treturn decompressIdentifierIfNeeded(sessionIdOrString, idDecodingContext.idCompressor);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"decoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk} into an array.\n *\n * Unwraps {@link SequenceChunk}s, and wraps other chunks.\n */\nexport function deaggregateChunks(chunk: TreeChunk): TreeChunk[] {\n\tif (chunk === emptyChunk) {\n\t\treturn [];\n\t}\n\t// TODO: when handling of SequenceChunks has better performance (for example in cursors),\n\t// consider keeping SequenceChunks here if they are longer than some threshold.\n\tif (chunk instanceof SequenceChunk) {\n\t\t// Could return [] here, however the logic in this file is designed to never produce an empty SequenceChunk, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 0, 0x735 /* Unexpected empty sequence */);\n\t\t// Logic in this file is designed to never produce an unneeded (single item) SequenceChunks, so its better to throw an error here to detect bugs.\n\t\tassert(chunk.subChunks.length > 1, 0x736 /* Unexpected single item sequence */);\n\n\t\tfor (const sub of chunk.subChunks) {\n\t\t\t// The logic in this file is designed to never produce an nested SequenceChunks or emptyChunk, so its better to throw an error here to detect bugs.\n\t\t\tassert(!(sub instanceof SequenceChunk), 0x737 /* unexpected nested sequence */);\n\t\t\tassert(sub !== emptyChunk, 0x738 /* unexpected empty chunk */);\n\n\t\t\tsub.referenceAdded();\n\t\t}\n\n\t\tchunk.referenceRemoved();\n\t\treturn chunk.subChunks;\n\t} else {\n\t\treturn [chunk];\n\t}\n}\n\n/**\n * Normalize a {@link TreeChunk}[] into a single TreeChunk.\n *\n * Avoids creating nested or less than 2 child {@link SequenceChunk}s.\n */\nexport function aggregateChunks(input: TreeChunk[]): TreeChunk {\n\tconst chunks = input.flatMap(deaggregateChunks);\n\tswitch (chunks.length) {\n\t\tcase 0: {\n\t\t\treturn emptyChunk;\n\t\t}\n\t\tcase 1: {\n\t\t\treturn chunks[0] ?? oob();\n\t\t}\n\t\tdefault: {\n\t\t\treturn new SequenceChunk(chunks);\n\t\t}\n\t}\n}\n\n/**\n * Decoder for {@link EncodedNestedArrayShape}s.\n */\nexport class NestedArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedNestedArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst decoder = decoders[this.shape] ?? oob();\n\n\t\t// TODO: uniform chunk fast path\n\t\tconst chunks: TreeChunk[] = [];\n\n\t\tconst data = readStream(stream);\n\t\tif (typeof data === \"number\") {\n\t\t\t// This case means that the array contained only 0-sized items, and was thus encoded as the length of the array.\n\t\t\tconst inner = { data: [], offset: 0 };\n\t\t\tfor (let index = 0; index < data; index++) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tArray.isArray(data),\n\t\t\t\t0x739 /* expected number of array for encoding of nested array */,\n\t\t\t);\n\t\t\tconst inner = { data, offset: 0 };\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tchunks.push(decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedInlineArrayShape}s.\n */\nexport class InlineArrayDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly shape: EncodedInlineArrayShape) {}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst length = this.shape.length;\n\t\tconst decoder = decoders[this.shape.shape] ?? oob();\n\t\tconst chunks: TreeChunk[] = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tchunks.push(decoder.decode(decoders, stream));\n\t\t}\n\t\treturn aggregateChunks(chunks);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedIncrementalChunkShape}s.\n */\nexport class IncrementalChunkDecoder implements ChunkDecoder {\n\tpublic constructor(private readonly context: DecoderContext<EncodedChunkShapeV2>) {}\n\tpublic decode(_: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tassert(\n\t\t\tthis.context.incrementalDecoder !== undefined,\n\t\t\t0xc27 /* incremental decoder not available for incremental field decoding */,\n\t\t);\n\n\t\tconst chunkDecoder = (batch: EncodedFieldBatchV2): TreeChunk => {\n\t\t\tassert(\n\t\t\t\tsupportsIncrementalEncoding(batch.version),\n\t\t\t\t0xc9f /* Unsupported FieldBatchFormatVersion for incremental chunks; must be v2 or higher */,\n\t\t\t);\n\t\t\tconst context = new DecoderContext(\n\t\t\t\tbatch.identifiers,\n\t\t\t\tbatch.shapes,\n\t\t\t\tthis.context.idDecodingContext,\n\t\t\t\tthis.context.incrementalDecoder,\n\t\t\t);\n\t\t\tconst chunks = genericDecode(decoderLibrary, context, batch, anyDecoder);\n\t\t\treturn aggregateChunks(chunks);\n\t\t};\n\n\t\tconst chunkReferenceId = readStreamNumber(stream);\n\t\treturn this.context.incrementalDecoder.decodeIncrementalChunk(\n\t\t\tbrand(chunkReferenceId),\n\t\t\tchunkDecoder,\n\t\t);\n\t}\n}\n\n/**\n * Decoder for {@link EncodedAnyShape}s.\n */\nexport const anyDecoder: ChunkDecoder = {\n\tdecode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst shapeIndex = readStreamNumber(stream);\n\t\tconst decoder = getChecked(decoders, shapeIndex);\n\t\treturn decoder.decode(decoders, stream);\n\t},\n};\n\n/**\n * Decoder for field.\n */\ntype BasicFieldDecoder = (\n\tdecoders: readonly ChunkDecoder[],\n\tstream: StreamCursor,\n) => [FieldKey, TreeChunk];\n\n/**\n * Get a decoder for fields of a provided (via `shape` and `context`).\n */\nfunction fieldDecoder(\n\tcontext: DecoderContext<EncodedChunkShape>,\n\tkey: FieldKey,\n\tshape: number,\n): BasicFieldDecoder {\n\tassertValidIndex(shape, context.shapes);\n\treturn (decoders, stream) => {\n\t\tconst decoder = decoders[shape] ?? oob();\n\t\treturn [key, decoder.decode(decoders, stream)];\n\t};\n}\n\n/**\n * Decoder for {@link EncodedNodeShape}s.\n */\nexport class NodeDecoder implements ChunkDecoder {\n\tprivate readonly type?: TreeNodeSchemaIdentifier;\n\tprivate readonly fieldDecoders: readonly BasicFieldDecoder[];\n\tpublic constructor(\n\t\tprivate readonly shape: EncodedNodeShape,\n\t\tprivate readonly context: DecoderContext<EncodedChunkShape>,\n\t) {\n\t\tthis.type = shape.type === undefined ? undefined : context.identifier(shape.type);\n\n\t\tconst fieldDecoders: BasicFieldDecoder[] = [];\n\t\tfor (const [fieldKey, fieldShape] of shape.fields ?? []) {\n\t\t\tconst key: FieldKey = context.identifier(fieldKey);\n\t\t\tfieldDecoders.push(fieldDecoder(context, key, fieldShape));\n\t\t}\n\t\tthis.fieldDecoders = fieldDecoders;\n\t}\n\tpublic decode(decoders: readonly ChunkDecoder[], stream: StreamCursor): TreeChunk {\n\t\tconst type: TreeNodeSchemaIdentifier =\n\t\t\tthis.type ?? readStreamIdentifier(stream, this.context);\n\t\t// TODO: Consider typechecking against stored schema in here somewhere.\n\n\t\tconst value = readValue(stream, this.shape.value, this.context.idDecodingContext);\n\t\tconst fields: Map<FieldKey, TreeChunk[]> = new Map();\n\n\t\t// Helper to add fields, but with unneeded array chunks removed.\n\t\tfunction addField(key: FieldKey, data: TreeChunk): void {\n\t\t\t// TODO: when handling of ArrayChunks has better performance (for example in cursors),\n\t\t\t// consider keeping array chunks here if they are longer than some threshold.\n\t\t\tconst chunks = deaggregateChunks(data);\n\n\t\t\tif (chunks.length > 0) {\n\t\t\t\tfields.set(key, chunks);\n\t\t\t}\n\t\t}\n\n\t\tfor (const decoder of this.fieldDecoders) {\n\t\t\tconst [key, content] = decoder(decoders, stream);\n\t\t\taddField(key, content);\n\t\t}\n\n\t\tif (this.shape.extraFields !== undefined) {\n\t\t\tconst decoder = decoders[this.shape.extraFields] ?? oob();\n\t\t\tconst inner = readStreamStream(stream);\n\t\t\twhile (inner.offset !== inner.data.length) {\n\t\t\t\tconst key: FieldKey = readStreamIdentifier(inner, this.context);\n\t\t\t\taddField(key, decoder.decode(decoders, inner));\n\t\t\t}\n\t\t}\n\n\t\treturn new BasicChunk(type, fields, value);\n\t}\n}\n"]}
@@ -2,11 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
5
+ import type { IIdCompressor, OpSpaceCompressedId, SessionId, SessionSpaceCompressedId } from "@fluidframework/id-compressor";
6
6
  import { VersionDispatchingCodecBuilder, type VersionDispatchingCodec } from "../../../codec/index.js";
7
7
  import { type ITreeCursorSynchronous, type SchemaAndPolicy, type TreeChunk } from "../../../core/index.js";
8
- import { type Brand } from "../../../util/index.js";
8
+ import { type Brand, type IdentifierHealingConfig } from "../../../util/index.js";
9
9
  import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
10
+ import { type IdDecodingContext } from "./chunkDecoding.js";
10
11
  import type { FieldBatch } from "./fieldBatch.js";
11
12
  import { EncodedFieldBatchV2, FieldBatchFormatVersion } from "./format/index.js";
12
13
  import type { IncrementalEncodingPolicy } from "./incrementalEncodingPolicy.js";
@@ -60,51 +61,107 @@ export interface IncrementalDecoder {
60
61
  */
61
62
  export interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {
62
63
  }
64
+ /**
65
+ * Encode-side context for {@link FieldBatchCodec}.
66
+ *
67
+ * Carries only the data the encoder actually consumes. Originator-session
68
+ * lookup, heal flags, and the incremental *decoder* live on
69
+ * {@link FieldBatchDecodingContext}.
70
+ */
63
71
  export interface FieldBatchEncodingContext {
64
72
  readonly encodeType: TreeCompressionStrategy;
65
73
  readonly idCompressor: IIdCompressor;
66
- readonly originatorId: SessionId;
67
74
  readonly schema?: SchemaAndPolicy;
68
75
  /**
69
- * An encoder / decoder for encoding and decoding of incremental fields.
70
- * This will be defined if incremental encoding is supported and enabled.
76
+ * Encoder for incremental fields. Defined when incremental encoding is
77
+ * supported and enabled.
71
78
  */
72
- readonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;
79
+ readonly incrementalEncoder?: IncrementalEncoder;
73
80
  /**
74
- * `true` when encoding to or decoding from a summary blob. `false` for
75
- * op-stream encode/decode paths and for utility encoders that are not
76
- * tied to a persisted document. Healing behavior is gated on this flag.
81
+ * `true` when encoding to a summary blob. `false` for op-stream encode
82
+ * paths and for utility encoders that aren't tied to a persisted document.
83
+ *
84
+ * @remarks
85
+ * Used by the node encoder to decide whether non-finalized op-space ids
86
+ * can be written into the batch (they can't, for summaries).
77
87
  */
78
88
  readonly isSummary: boolean;
89
+ }
90
+ /**
91
+ * Decode-side context for {@link FieldBatchCodec}.
92
+ *
93
+ * Carries the per-call `resolveEncodedId` function that encapsulates the
94
+ * originator-session lookup and (for the forest-summarizer's legacy heal path)
95
+ * the deterministic UUIDv5 synthesis. Heal and originator-session flags live
96
+ * inside that function, not on this context.
97
+ *
98
+ * Constructed via one of the two named static factories — {@link forOp} or
99
+ * {@link forSummary} — depending on the call site's semantics. The constructor
100
+ * is private; there is no general-purpose builder, because the choice between
101
+ * op-style and summary-style decoding is load-bearing (different invariants
102
+ * apply, and bugs in this area are typically the result of conflating them).
103
+ */
104
+ export declare class FieldBatchDecodingContext implements IdDecodingContext {
79
105
  /**
80
- * If `true`, when an op-space compressed ID encountered while decoding
81
- * cannot be resolved by the local id-compressor (e.g. the attach-summary
82
- * blob's originator session state was stripped), a deterministic stable
83
- * UUID derived from `sharedObjectId` is returned instead of throwing.
84
- * @remarks
85
- * Off by default. Used only to recover documents whose attach summary was
86
- * written with non-finalized op-space IDs before the encode-side fix
87
- * shipped. Only takes effect when `isSummary` is also `true`.
88
- * See {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}.
106
+ * Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).
89
107
  */
90
- readonly healUnresolvableIdentifiersOnDecode?: boolean;
108
+ private readonly hasOriginatorSessionId;
109
+ readonly idCompressor: Pick<IIdCompressor, "decompress">;
110
+ readonly resolveEncodedId: (id: OpSpaceCompressedId) => SessionSpaceCompressedId | string;
91
111
  /**
92
- * The SharedTree's shared-object id, used as input to the deterministic
93
- * UUID derivation when `healUnresolvableIdentifiersOnDecode` triggers. Required
94
- * for that path; ignored otherwise.
95
- * @remarks
96
- * This allows us to ensure that multiple attaches,
97
- * in the same or different documents, with the same session offsets, get different UUIDs.
112
+ * Decoder for incremental fields. Defined when the encoded batch contains
113
+ * incremental chunks. Only populated on summary-style contexts; op-style
114
+ * contexts always have this undefined.
115
+ */
116
+ readonly incrementalDecoder?: IncrementalDecoder | undefined;
117
+ private constructor();
118
+ /**
119
+ * Construct a decode context for an op.
120
+ *
121
+ * The originator is the session that produced the encoded form (carried
122
+ * alongside the op envelope by the caller). Heal-on-decode is *not*
123
+ * available — an unresolvable id during op decode indicates a real bug,
124
+ * not a recoverable state, so the resolver throws rather than synthesizing
125
+ * a UUID. Incremental decoding is not used for ops.
126
+ */
127
+ static forOp(opts: {
128
+ readonly idCompressor: IIdCompressor;
129
+ readonly originatorId: SessionId;
130
+ }): FieldBatchDecodingContext;
131
+ /**
132
+ * Construct a decode context for a summary blob.
133
+ *
134
+ * Summaries must contain only ids resolvable without an originator — either
135
+ * finalized op-space ids, or (when {@link IdentifierHealingConfig} is supplied
136
+ * via `healing`) non-final ids that get healed into deterministic UUIDv5
137
+ * strings. Incremental decoding is attached via {@link withIncrementalDecoder}.
138
+ *
139
+ * @privateRemarks
140
+ * In the future (if adding a summary format which includes the session id),
141
+ * this could allow providing an originator ID to allow for op-space compressed identifiers in attach summaries.
142
+ * Non-attach summaries should only have finalized compressed identifiers (due to only being made by summary clients which never allocate identifiers since they never edit).
143
+ * Since only non-attach summaries can be incremental, incremental summaries should never have non finalized identifiers.
144
+ * `withIncrementalDecoder` has logic to guard against cases which expect session-relative identifiers in incremental chunks,
145
+ * as does the encoding-side assert in the {@link EncoderContext}.
146
+ */
147
+ static forSummary(opts: {
148
+ readonly idCompressor: IIdCompressor;
149
+ readonly healing?: IdentifierHealingConfig;
150
+ }): FieldBatchDecodingContext;
151
+ /**
152
+ * Returns a copy of this context with `incrementalDecoder` swapped in. Used by
153
+ * the forest summarizer to attach the per-call incremental builder to a base
154
+ * decode context.
98
155
  */
99
- readonly sharedObjectId?: string;
156
+ withIncrementalDecoder(incrementalDecoder: IncrementalDecoder): FieldBatchDecodingContext;
100
157
  }
101
158
  /**
102
159
  * @remarks
103
160
  * Fields in this batch currently don't have field schema for the root, which limits optimizations.
104
161
  */
105
- export type FieldBatchCodec = VersionDispatchingCodec<FieldBatch, FieldBatchEncodingContext, FieldBatchFormatVersion>;
162
+ export type FieldBatchCodec = VersionDispatchingCodec<FieldBatch, FieldBatchEncodingContext, FieldBatchFormatVersion, FieldBatchDecodingContext>;
106
163
  /**
107
164
  * {@link VersionDispatchingCodecBuilder} for field batch codecs.
108
165
  */
109
- export declare const fieldBatchCodecBuilder: VersionDispatchingCodecBuilder<import("../../../codec/codec.js").ICodecOptions, FieldBatch, FieldBatchEncodingContext, Brand<1, "FieldBatchFormatVersion"> | Brand<2, "FieldBatchFormatVersion">, "FieldBatch", FieldBatchEncodingContext>;
166
+ export declare const fieldBatchCodecBuilder: VersionDispatchingCodecBuilder<import("../../../codec/codec.js").ICodecOptions, FieldBatch, FieldBatchEncodingContext, Brand<1, "FieldBatchFormatVersion"> | Brand<2, "FieldBatchFormatVersion">, "FieldBatch", FieldBatchDecodingContext>;
110
167
  //# sourceMappingURL=codecs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI9E,OAAO,EACN,8BAA8B,EAE9B,KAAK,uBAAuB,EAE5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EAGpB,KAAK,SAAS,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEN,mBAAmB,EACnB,uBAAuB,EAGvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAIhF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAGxE;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,yBAAyB,EAAE,yBAAyB,CAAC;IACrD;;;;;;;OAOG;IACH,sBAAsB,CACrB,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,mBAAmB,GACrD,gBAAgB,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,sBAAsB,CACrB,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,SAAS,GACvD,SAAS,CAAC;CACb;AACD;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB,EAAE,kBAAkB;CAAG;AAE5F,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,mCAAmC,CAAC,EAAE,OAAO,CAAC;IACvD;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CACjC;AACD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,uBAAuB,CACpD,UAAU,EACV,yBAAyB,EACzB,uBAAuB,CACvB,CAAC;AA4FF;;GAEG;AACH,eAAO,MAAM,sBAAsB,4OAqBjC,CAAC"}
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,wBAAwB,EACx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Builder = void 0;
7
+ exports.fieldBatchCodecBuilder = exports.FieldBatchDecodingContext = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/runtime-utils/internal");
10
10
  const index_js_1 = require("../../../codec/index.js");
@@ -15,6 +15,86 @@ const index_js_3 = require("./format/index.js");
15
15
  const schemaBasedEncode_js_1 = require("./schemaBasedEncode.js");
16
16
  const uncompressedEncode_js_1 = require("./uncompressedEncode.js");
17
17
  const ChunkReferenceId = (0, index_js_2.brandedNumberType)({ multipleOf: 1, minimum: 0 });
18
+ /**
19
+ * Decode-side context for {@link FieldBatchCodec}.
20
+ *
21
+ * Carries the per-call `resolveEncodedId` function that encapsulates the
22
+ * originator-session lookup and (for the forest-summarizer's legacy heal path)
23
+ * the deterministic UUIDv5 synthesis. Heal and originator-session flags live
24
+ * inside that function, not on this context.
25
+ *
26
+ * Constructed via one of the two named static factories — {@link forOp} or
27
+ * {@link forSummary} — depending on the call site's semantics. The constructor
28
+ * is private; there is no general-purpose builder, because the choice between
29
+ * op-style and summary-style decoding is load-bearing (different invariants
30
+ * apply, and bugs in this area are typically the result of conflating them).
31
+ */
32
+ class FieldBatchDecodingContext {
33
+ constructor(
34
+ /**
35
+ * Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).
36
+ */
37
+ hasOriginatorSessionId, idCompressor, resolveEncodedId,
38
+ /**
39
+ * Decoder for incremental fields. Defined when the encoded batch contains
40
+ * incremental chunks. Only populated on summary-style contexts; op-style
41
+ * contexts always have this undefined.
42
+ */
43
+ incrementalDecoder) {
44
+ this.hasOriginatorSessionId = hasOriginatorSessionId;
45
+ this.idCompressor = idCompressor;
46
+ this.resolveEncodedId = resolveEncodedId;
47
+ this.incrementalDecoder = incrementalDecoder;
48
+ }
49
+ /**
50
+ * Construct a decode context for an op.
51
+ *
52
+ * The originator is the session that produced the encoded form (carried
53
+ * alongside the op envelope by the caller). Heal-on-decode is *not*
54
+ * available — an unresolvable id during op decode indicates a real bug,
55
+ * not a recoverable state, so the resolver throws rather than synthesizing
56
+ * a UUID. Incremental decoding is not used for ops.
57
+ */
58
+ static forOp(opts) {
59
+ const { idCompressor, originatorId } = opts;
60
+ return new FieldBatchDecodingContext(true, idCompressor, (id) => idCompressor.normalizeToSessionSpace(id, originatorId));
61
+ }
62
+ /**
63
+ * Construct a decode context for a summary blob.
64
+ *
65
+ * Summaries must contain only ids resolvable without an originator — either
66
+ * finalized op-space ids, or (when {@link IdentifierHealingConfig} is supplied
67
+ * via `healing`) non-final ids that get healed into deterministic UUIDv5
68
+ * strings. Incremental decoding is attached via {@link withIncrementalDecoder}.
69
+ *
70
+ * @privateRemarks
71
+ * In the future (if adding a summary format which includes the session id),
72
+ * this could allow providing an originator ID to allow for op-space compressed identifiers in attach summaries.
73
+ * Non-attach summaries should only have finalized compressed identifiers (due to only being made by summary clients which never allocate identifiers since they never edit).
74
+ * Since only non-attach summaries can be incremental, incremental summaries should never have non finalized identifiers.
75
+ * `withIncrementalDecoder` has logic to guard against cases which expect session-relative identifiers in incremental chunks,
76
+ * as does the encoding-side assert in the {@link EncoderContext}.
77
+ */
78
+ static forSummary(opts) {
79
+ const { idCompressor, healing } = opts;
80
+ return new FieldBatchDecodingContext(false, idCompressor, (id) => (0, index_js_2.forceDecodeEncodedIdWithoutSession)(id, idCompressor, healing));
81
+ }
82
+ /**
83
+ * Returns a copy of this context with `incrementalDecoder` swapped in. Used by
84
+ * the forest summarizer to attach the per-call incremental builder to a base
85
+ * decode context.
86
+ */
87
+ withIncrementalDecoder(incrementalDecoder) {
88
+ // As different incremental chunks may come from different sessions,
89
+ // for now we simply enforce that we do not provide an originator session ID
90
+ // when we might be dealing with incremental chunks.
91
+ // This mitigates the risk of using incorrect originator session ID identifiers in incremental chunks.
92
+ // See also private remarks on forSummary.
93
+ (0, internal_1.assert)(!this.hasOriginatorSessionId, 0xd0c /* withIncrementalDecoder can only be called on contexts without an originator session ID */);
94
+ return new FieldBatchDecodingContext(false, this.idCompressor, this.resolveEncodedId, incrementalDecoder);
95
+ }
96
+ }
97
+ exports.FieldBatchDecodingContext = FieldBatchDecodingContext;
18
98
  /**
19
99
  * Creates the encode/decode functions for a specific FieldBatch format version.
20
100
  */
@@ -34,7 +114,7 @@ function makeFieldBatchCodecForVersion(version, uncompressedEncodeFn, schemaComp
34
114
  case treeCompressionUtils_js_1.TreeCompressionStrategy.CompressedIncremental: {
35
115
  (0, internal_1.assert)((0, index_js_3.supportsIncrementalEncoding)(version), 0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */);
36
116
  // Incremental encoding is only supported for CompressedIncremental.
37
- incrementalEncoder = context.incrementalEncoderDecoder;
117
+ incrementalEncoder = context.incrementalEncoder;
38
118
  }
39
119
  // fallthrough
40
120
  case treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed: {
@@ -57,13 +137,7 @@ function makeFieldBatchCodecForVersion(version, uncompressedEncodeFn, schemaComp
57
137
  },
58
138
  decode: (data, context) => {
59
139
  // TODO: consider checking data is in schema.
60
- return (0, chunkDecoding_js_1.decode)(data, {
61
- idCompressor: context.idCompressor,
62
- originatorId: context.originatorId,
63
- isSummary: context.isSummary,
64
- healUnresolvableIdentifiersOnDecode: context.healUnresolvableIdentifiersOnDecode,
65
- sharedObjectId: context.sharedObjectId,
66
- }, context.incrementalEncoderDecoder).map((chunk) => chunk.cursor());
140
+ return (0, chunkDecoding_js_1.decode)(data, context, context.incrementalDecoder).map((chunk) => chunk.cursor());
67
141
  },
68
142
  schema: encodedFieldBatchType,
69
143
  };
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAE9E,qEAAmF;AAGnF,sDAKiC;AASjC,qDAAuE;AACvE,2EAAwE;AAExE,yDAA4C;AAE5C,gDAM2B;AAE3B,iEAA4F;AAC5F,mEAAqF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c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\nimport type { TSchema } from \"@sinclair/typebox\";\n\nimport {\n\tVersionDispatchingCodecBuilder,\n\ttype CodecAndSchema,\n\ttype VersionDispatchingCodec,\n\tFluidClientVersion,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype StoredSchemaCollection,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport { brandedNumberType, type Brand } from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\tEncodedFieldBatchV1,\n\tEncodedFieldBatchV2,\n\tFieldBatchFormatVersion,\n\tsupportsIncrementalEncoding,\n\ttype EncodedFieldBatchV1OrV2,\n} from \"./format/index.js\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk,\n\t): TreeChunk;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly originatorId: SessionId;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * An encoder / decoder for encoding and decoding of incremental fields.\n\t * This will be defined if incremental encoding is supported and enabled.\n\t */\n\treadonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;\n\t/**\n\t * `true` when encoding to or decoding from a summary blob. `false` for\n\t * op-stream encode/decode paths and for utility encoders that are not\n\t * tied to a persisted document. Healing behavior is gated on this flag.\n\t */\n\treadonly isSummary: boolean;\n\t/**\n\t * If `true`, when an op-space compressed ID encountered while decoding\n\t * cannot be resolved by the local id-compressor (e.g. the attach-summary\n\t * blob's originator session state was stripped), a deterministic stable\n\t * UUID derived from `sharedObjectId` is returned instead of throwing.\n\t * @remarks\n\t * Off by default. Used only to recover documents whose attach summary was\n\t * written with non-finalized op-space IDs before the encode-side fix\n\t * shipped. Only takes effect when `isSummary` is also `true`.\n\t * See {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}.\n\t */\n\treadonly healUnresolvableIdentifiersOnDecode?: boolean;\n\t/**\n\t * The SharedTree's shared-object id, used as input to the deterministic\n\t * UUID derivation when `healUnresolvableIdentifiersOnDecode` triggers. Required\n\t * for that path; ignored otherwise.\n\t * @remarks\n\t * This allows us to ensure that multiple attaches,\n\t * in the same or different documents, with the same session offsets, get different UUIDs.\n\t */\n\treadonly sharedObjectId?: string;\n}\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = VersionDispatchingCodec<\n\tFieldBatch,\n\tFieldBatchEncodingContext,\n\tFieldBatchFormatVersion\n>;\n\n/**\n * Creates the encode/decode functions for a specific FieldBatch format version.\n */\nfunction makeFieldBatchCodecForVersion(\n\tversion: FieldBatchFormatVersion,\n\tuncompressedEncodeFn: (batch: FieldBatch) => EncodedFieldBatchV1OrV2,\n\tschemaCompressedEncodeFn: (\n\t\tschema: StoredSchemaCollection,\n\t\tpolicy: SchemaPolicy,\n\t\tfieldBatch: FieldBatch,\n\t\tidCompressor: IIdCompressor,\n\t\tincrementalEncoder: IncrementalEncoder | undefined,\n\t\tisSummary: boolean,\n\t) => EncodedFieldBatchV1OrV2,\n\tencodedFieldBatchType: TSchema,\n): CodecAndSchema<FieldBatch, FieldBatchEncodingContext> {\n\treturn {\n\t\tencode: (\n\t\t\tdata: FieldBatch,\n\t\t\tcontext: FieldBatchEncodingContext,\n\t\t): EncodedFieldBatchV1OrV2 => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatchV1OrV2;\n\t\t\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed: {\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TreeCompressionStrategy.CompressedIncremental: {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsupportsIncrementalEncoding(version),\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoderDecoder;\n\t\t\t\t}\n\t\t\t\t// fallthrough\n\t\t\t\tcase TreeCompressionStrategy.Compressed: {\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema === undefined) {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tencoded = schemaCompressedEncodeFn(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\tincrementalEncoder,\n\t\t\t\t\t\t\tcontext.isSummary,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (\n\t\t\tdata: EncodedFieldBatchV1OrV2,\n\t\t\tcontext: FieldBatchEncodingContext,\n\t\t): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(\n\t\t\t\tdata,\n\t\t\t\t{\n\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\tisSummary: context.isSummary,\n\t\t\t\t\thealUnresolvableIdentifiersOnDecode: context.healUnresolvableIdentifiersOnDecode,\n\t\t\t\t\tsharedObjectId: context.sharedObjectId,\n\t\t\t\t},\n\t\t\t\tcontext.incrementalEncoderDecoder,\n\t\t\t).map((chunk) => chunk.cursor());\n\t\t},\n\t\tschema: encodedFieldBatchType,\n\t};\n}\n\n/**\n * {@link VersionDispatchingCodecBuilder} for field batch codecs.\n */\nexport const fieldBatchCodecBuilder = VersionDispatchingCodecBuilder.build(\"FieldBatch\", [\n\t{\n\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\tformatVersion: FieldBatchFormatVersion.v1,\n\t\tcodec: makeFieldBatchCodecForVersion(\n\t\t\tFieldBatchFormatVersion.v1,\n\t\t\tuncompressedEncodeV1,\n\t\t\tschemaCompressedEncodeV1,\n\t\t\tEncodedFieldBatchV1,\n\t\t),\n\t},\n\t{\n\t\tminVersionForCollab: FluidClientVersion.v2_73,\n\t\tformatVersion: FieldBatchFormatVersion.v2,\n\t\tcodec: makeFieldBatchCodecForVersion(\n\t\t\tFieldBatchFormatVersion.v2,\n\t\t\tuncompressedEncodeV2,\n\t\t\tschemaCompressedEncodeV2,\n\t\t\tEncodedFieldBatchV2,\n\t\t),\n\t},\n]);\n"]}
1
+ {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/codecs.ts"],"names":[],"mappings":";AAAA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AM,CAAC;wBACP,OAAO,GAAG,wBAAwB,CACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EACrB,IAAI,EACJ,OAAO,CAAC,YAAY,EACpB,kBAAkB,EAClB,OAAO,CAAC,SAAS,CACjB,CAAC;oBACH,CAAC;oBAED,MAAM;gBACP,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACT,IAAA,0BAAe,EAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBACrC,CAAC;YACF,CAAC;YAED,oDAAoD;YACpD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CACP,IAA6B,EAC7B,OAAkC,EACrB,EAAE;YACf,6CAA6C;YAC7C,OAAO,IAAA,yBAAM,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,EAAE,qBAAqB;KAC7B,CAAC;AACH,CAAC;AAED;;GAEG;AACU,QAAA,sBAAsB,GAAG,yCAA8B,CAAC,KAAK,CAAC,YAAY,EAAE;IACxF;QACC,mBAAmB,EAAE,oCAAyB;QAC9C,aAAa,EAAE,kCAAuB,CAAC,EAAE;QACzC,KAAK,EAAE,6BAA6B,CACnC,kCAAuB,CAAC,EAAE,EAC1B,4CAAoB,EACpB,+CAAwB,EACxB,8BAAmB,CACnB;KACD;IACD;QACC,mBAAmB,EAAE,6BAAkB,CAAC,KAAK;QAC7C,aAAa,EAAE,kCAAuB,CAAC,EAAE;QACzC,KAAK,EAAE,6BAA6B,CACnC,kCAAuB,CAAC,EAAE,EAC1B,4CAAoB,EACpB,+CAAwB,EACxB,8BAAmB,CACnB;KACD;CACD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIIdCompressor,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n} from \"@fluidframework/id-compressor\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\nimport type { TSchema } from \"@sinclair/typebox\";\n\nimport {\n\tVersionDispatchingCodecBuilder,\n\ttype CodecAndSchema,\n\ttype VersionDispatchingCodec,\n\tFluidClientVersion,\n} from \"../../../codec/index.js\";\nimport {\n\tCursorLocationType,\n\ttype ITreeCursorSynchronous,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n\ttype StoredSchemaCollection,\n\ttype TreeChunk,\n} from \"../../../core/index.js\";\nimport {\n\tbrandedNumberType,\n\tforceDecodeEncodedIdWithoutSession,\n\ttype Brand,\n\ttype IdentifierHealingConfig,\n} from \"../../../util/index.js\";\nimport { TreeCompressionStrategy } from \"../../treeCompressionUtils.js\";\n\nimport { decode, type IdDecodingContext } from \"./chunkDecoding.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\tEncodedFieldBatchV1,\n\tEncodedFieldBatchV2,\n\tFieldBatchFormatVersion,\n\tsupportsIncrementalEncoding,\n\ttype EncodedFieldBatchV1OrV2,\n} from \"./format/index.js\";\nimport type { IncrementalEncodingPolicy } from \"./incrementalEncodingPolicy.js\";\nimport { schemaCompressedEncodeV1, schemaCompressedEncodeV2 } from \"./schemaBasedEncode.js\";\nimport { uncompressedEncodeV1, uncompressedEncodeV2 } from \"./uncompressedEncode.js\";\n\n/**\n * Reference ID for a chunk that is incrementally encoded.\n */\nexport type ChunkReferenceId = Brand<number, \"forest.ChunkReferenceId\">;\nconst ChunkReferenceId = brandedNumberType<ChunkReferenceId>({ multipleOf: 1, minimum: 0 });\n\n/**\n * Properties for incremental encoding.\n * Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.\n * @remarks\n * This supports features like incremental summarization where the summary from these fields can be re-used if\n * unchanged between summaries.\n * Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes\n * list and identifier table) and does not rely on context from its parent.\n */\nexport interface IncrementalEncoder {\n\t/**\n\t * Returns whether a node / field should be incrementally encoded.\n\t * @remarks See {@link IncrementalEncodingPolicy}.\n\t */\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * Called to encode an incremental field at the cursor.\n\t * The chunks for this field are encoded separately from the main buffer.\n\t * @param cursor - The cursor pointing to the field to encode.\n\t * @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.\n\t * @returns The reference IDs of the encoded chunks in the field.\n\t * This is used to retrieve the encoded chunks later.\n\t */\n\tencodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2,\n\t): ChunkReferenceId[];\n}\n\n/**\n * Properties for incremental decoding.\n *\n * Fields that had their chunks incrementally encoded will retrieve them by calling `getEncodedIncrementalChunk`.\n * @remarks\n * See {@link IncrementalEncoder} for more details.\n */\nexport interface IncrementalDecoder {\n\t/**\n\t * Called to decode an incremental chunk with the given reference ID.\n\t * @param referenceId - The reference ID of the chunk to decode.\n\t * @param chunkDecoder - A function that decodes the chunk.\n\t * @returns The decoded chunk.\n\t */\n\tdecodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk,\n\t): TreeChunk;\n}\n/**\n * Combines the properties of {@link IncrementalEncoder} and {@link IncrementalDecoder}.\n */\nexport interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}\n\n/**\n * Encode-side context for {@link FieldBatchCodec}.\n *\n * Carries only the data the encoder actually consumes. Originator-session\n * lookup, heal flags, and the incremental *decoder* live on\n * {@link FieldBatchDecodingContext}.\n */\nexport interface FieldBatchEncodingContext {\n\treadonly encodeType: TreeCompressionStrategy;\n\treadonly idCompressor: IIdCompressor;\n\treadonly schema?: SchemaAndPolicy;\n\t/**\n\t * Encoder for incremental fields. Defined when incremental encoding is\n\t * supported and enabled.\n\t */\n\treadonly incrementalEncoder?: IncrementalEncoder;\n\t/**\n\t * `true` when encoding to a summary blob. `false` for op-stream encode\n\t * paths and for utility encoders that aren't tied to a persisted document.\n\t *\n\t * @remarks\n\t * Used by the node encoder to decide whether non-finalized op-space ids\n\t * can be written into the batch (they can't, for summaries).\n\t */\n\treadonly isSummary: boolean;\n}\n\n/**\n * Decode-side context for {@link FieldBatchCodec}.\n *\n * Carries the per-call `resolveEncodedId` function that encapsulates the\n * originator-session lookup and (for the forest-summarizer's legacy heal path)\n * the deterministic UUIDv5 synthesis. Heal and originator-session flags live\n * inside that function, not on this context.\n *\n * Constructed via one of the two named static factories — {@link forOp} or\n * {@link forSummary} — depending on the call site's semantics. The constructor\n * is private; there is no general-purpose builder, because the choice between\n * op-style and summary-style decoding is load-bearing (different invariants\n * apply, and bugs in this area are typically the result of conflating them).\n */\nexport class FieldBatchDecodingContext implements IdDecodingContext {\n\tprivate constructor(\n\t\t/**\n\t\t * Used internally to prevent the use of this decoder in incremental chunks if it has a session id (which would be wrong in those chunks).\n\t\t */\n\t\tprivate readonly hasOriginatorSessionId: boolean,\n\n\t\tpublic readonly idCompressor: Pick<IIdCompressor, \"decompress\">,\n\n\t\tpublic readonly resolveEncodedId: (\n\t\t\tid: OpSpaceCompressedId,\n\t\t) => SessionSpaceCompressedId | string,\n\n\t\t/**\n\t\t * Decoder for incremental fields. Defined when the encoded batch contains\n\t\t * incremental chunks. Only populated on summary-style contexts; op-style\n\t\t * contexts always have this undefined.\n\t\t */\n\t\tpublic readonly incrementalDecoder?: IncrementalDecoder,\n\t) {}\n\n\t/**\n\t * Construct a decode context for an op.\n\t *\n\t * The originator is the session that produced the encoded form (carried\n\t * alongside the op envelope by the caller). Heal-on-decode is *not*\n\t * available — an unresolvable id during op decode indicates a real bug,\n\t * not a recoverable state, so the resolver throws rather than synthesizing\n\t * a UUID. Incremental decoding is not used for ops.\n\t */\n\tpublic static forOp(opts: {\n\t\treadonly idCompressor: IIdCompressor;\n\t\treadonly originatorId: SessionId;\n\t}): FieldBatchDecodingContext {\n\t\tconst { idCompressor, originatorId } = opts;\n\t\treturn new FieldBatchDecodingContext(true, idCompressor, (id) =>\n\t\t\tidCompressor.normalizeToSessionSpace(id, originatorId),\n\t\t);\n\t}\n\n\t/**\n\t * Construct a decode context for a summary blob.\n\t *\n\t * Summaries must contain only ids resolvable without an originator — either\n\t * finalized op-space ids, or (when {@link IdentifierHealingConfig} is supplied\n\t * via `healing`) non-final ids that get healed into deterministic UUIDv5\n\t * strings. Incremental decoding is attached via {@link withIncrementalDecoder}.\n\t *\n\t * @privateRemarks\n\t * In the future (if adding a summary format which includes the session id),\n\t * this could allow providing an originator ID to allow for op-space compressed identifiers in attach summaries.\n\t * Non-attach summaries should only have finalized compressed identifiers (due to only being made by summary clients which never allocate identifiers since they never edit).\n\t * Since only non-attach summaries can be incremental, incremental summaries should never have non finalized identifiers.\n\t * `withIncrementalDecoder` has logic to guard against cases which expect session-relative identifiers in incremental chunks,\n\t * as does the encoding-side assert in the {@link EncoderContext}.\n\t */\n\tpublic static forSummary(opts: {\n\t\treadonly idCompressor: IIdCompressor;\n\t\treadonly healing?: IdentifierHealingConfig;\n\t}): FieldBatchDecodingContext {\n\t\tconst { idCompressor, healing } = opts;\n\t\treturn new FieldBatchDecodingContext(false, idCompressor, (id) =>\n\t\t\tforceDecodeEncodedIdWithoutSession(id, idCompressor, healing),\n\t\t);\n\t}\n\n\t/**\n\t * Returns a copy of this context with `incrementalDecoder` swapped in. Used by\n\t * the forest summarizer to attach the per-call incremental builder to a base\n\t * decode context.\n\t */\n\tpublic withIncrementalDecoder(\n\t\tincrementalDecoder: IncrementalDecoder,\n\t): FieldBatchDecodingContext {\n\t\t// As different incremental chunks may come from different sessions,\n\t\t// for now we simply enforce that we do not provide an originator session ID\n\t\t// when we might be dealing with incremental chunks.\n\t\t// This mitigates the risk of using incorrect originator session ID identifiers in incremental chunks.\n\t\t// See also private remarks on forSummary.\n\t\tassert(\n\t\t\t!this.hasOriginatorSessionId,\n\t\t\t0xd0c /* withIncrementalDecoder can only be called on contexts without an originator session ID */,\n\t\t);\n\t\treturn new FieldBatchDecodingContext(\n\t\t\tfalse,\n\t\t\tthis.idCompressor,\n\t\t\tthis.resolveEncodedId,\n\t\t\tincrementalDecoder,\n\t\t);\n\t}\n}\n\n/**\n * @remarks\n * Fields in this batch currently don't have field schema for the root, which limits optimizations.\n */\nexport type FieldBatchCodec = VersionDispatchingCodec<\n\tFieldBatch,\n\tFieldBatchEncodingContext,\n\tFieldBatchFormatVersion,\n\tFieldBatchDecodingContext\n>;\n\n/**\n * Creates the encode/decode functions for a specific FieldBatch format version.\n */\nfunction makeFieldBatchCodecForVersion(\n\tversion: FieldBatchFormatVersion,\n\tuncompressedEncodeFn: (batch: FieldBatch) => EncodedFieldBatchV1OrV2,\n\tschemaCompressedEncodeFn: (\n\t\tschema: StoredSchemaCollection,\n\t\tpolicy: SchemaPolicy,\n\t\tfieldBatch: FieldBatch,\n\t\tidCompressor: IIdCompressor,\n\t\tincrementalEncoder: IncrementalEncoder | undefined,\n\t\tisSummary: boolean,\n\t) => EncodedFieldBatchV1OrV2,\n\tencodedFieldBatchType: TSchema,\n): CodecAndSchema<FieldBatch, FieldBatchEncodingContext, FieldBatchDecodingContext> {\n\treturn {\n\t\tencode: (\n\t\t\tdata: FieldBatch,\n\t\t\tcontext: FieldBatchEncodingContext,\n\t\t): EncodedFieldBatchV1OrV2 => {\n\t\t\tfor (const cursor of data) {\n\t\t\t\tassert(\n\t\t\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t\t\t0x8a3 /* FieldBatch expects fields cursors */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet encoded: EncodedFieldBatchV1OrV2;\n\t\t\tlet incrementalEncoder: IncrementalEncoder | undefined;\n\t\t\tswitch (context.encodeType) {\n\t\t\t\tcase TreeCompressionStrategy.Uncompressed: {\n\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase TreeCompressionStrategy.CompressedIncremental: {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsupportsIncrementalEncoding(version),\n\t\t\t\t\t\t0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,\n\t\t\t\t\t);\n\t\t\t\t\t// Incremental encoding is only supported for CompressedIncremental.\n\t\t\t\t\tincrementalEncoder = context.incrementalEncoder;\n\t\t\t\t}\n\t\t\t\t// fallthrough\n\t\t\t\tcase TreeCompressionStrategy.Compressed: {\n\t\t\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\t\t\tif (context.schema === undefined) {\n\t\t\t\t\t\t// TODO: consider enabling a somewhat compressed but not schema accelerated encode.\n\t\t\t\t\t\tencoded = uncompressedEncodeFn(data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tencoded = schemaCompressedEncodeFn(\n\t\t\t\t\t\t\tcontext.schema.schema,\n\t\t\t\t\t\t\tcontext.schema.policy,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\tcontext.idCompressor,\n\t\t\t\t\t\t\tincrementalEncoder,\n\t\t\t\t\t\t\tcontext.isSummary,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(context.encodeType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: consider checking input data was in schema.\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (\n\t\t\tdata: EncodedFieldBatchV1OrV2,\n\t\t\tcontext: FieldBatchDecodingContext,\n\t\t): FieldBatch => {\n\t\t\t// TODO: consider checking data is in schema.\n\t\t\treturn decode(data, context, context.incrementalDecoder).map((chunk) => chunk.cursor());\n\t\t},\n\t\tschema: encodedFieldBatchType,\n\t};\n}\n\n/**\n * {@link VersionDispatchingCodecBuilder} for field batch codecs.\n */\nexport const fieldBatchCodecBuilder = VersionDispatchingCodecBuilder.build(\"FieldBatch\", [\n\t{\n\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\tformatVersion: FieldBatchFormatVersion.v1,\n\t\tcodec: makeFieldBatchCodecForVersion(\n\t\t\tFieldBatchFormatVersion.v1,\n\t\t\tuncompressedEncodeV1,\n\t\t\tschemaCompressedEncodeV1,\n\t\t\tEncodedFieldBatchV1,\n\t\t),\n\t},\n\t{\n\t\tminVersionForCollab: FluidClientVersion.v2_73,\n\t\tformatVersion: FieldBatchFormatVersion.v2,\n\t\tcodec: makeFieldBatchCodecForVersion(\n\t\t\tFieldBatchFormatVersion.v2,\n\t\t\tuncompressedEncodeV2,\n\t\t\tschemaCompressedEncodeV2,\n\t\t\tEncodedFieldBatchV2,\n\t\t),\n\t},\n]);\n"]}
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { IIdCompressor } from "@fluidframework/id-compressor";
6
6
  import { type FieldKey, type FieldKindData, type FieldKindIdentifier, type ITreeCursorSynchronous, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier, type Value } from "../../../core/index.js";
7
+ import { EncodedIdType, type EncodedId, type IdEncodingContext } from "../../../util/index.js";
7
8
  import type { Counter, DeduplicationTable } from "./chunkCodecUtilities.js";
8
9
  import { type BufferFormat as BufferFormatGeneric, Shape as ShapeGeneric } from "./chunkEncodingGeneric.js";
9
10
  import type { IncrementalEncoder } from "./codecs.js";
@@ -167,11 +168,11 @@ export declare function encodeValue(value: Value, shape: EncodedValueShape, outp
167
168
  * - Singletons defined in a static scope.
168
169
  * - Cached in this object for future reuse such that all equivalent Shapes are deduplicated.
169
170
  */
170
- export declare class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
171
+ export declare class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder, IdEncodingContext {
171
172
  private readonly nodeEncoderFromPolicy;
172
173
  private readonly fieldEncoderFromPolicy;
173
174
  readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FieldKindData>;
174
- readonly idCompressor: IIdCompressor;
175
+ private readonly idCompressor;
175
176
  /**
176
177
  * To be used to encode incremental chunks, if any.
177
178
  * @remarks
@@ -196,6 +197,7 @@ export declare class EncoderContext implements NodeEncodeBuilder, FieldEncodeBui
196
197
  * See {@link FieldBatchEncodingContext.isSummary}.
197
198
  */
198
199
  isSummary: boolean);
200
+ encodePossiblyCompressedId(id: string): string | EncodedId<EncodedIdType>;
199
201
  nodeEncoderFromSchema(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;
200
202
  fieldEncoderFromSchema(fieldSchema: TreeFieldStoredSchema): FieldEncoder;
201
203
  nestedArrayEncoder(inner: NodeEncoder): NestedArrayEncoder;
@@ -1 +1 @@
1
- {"version":3,"file":"compressedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAE3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,IAAI,YAAY,EAErB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAA6B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EAC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sB,CAAC,MAAM,EAAE,qBAAqB,GAAG,YAAY,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAChC,WAAW,EAAE,iBAAiB,EAC9B,MAAM,EAAE,qBAAqB,KACzB,YAAY,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC/B,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,wBAAwB,KAChC,WAAW,CAAC"}
1
+ {"version":3,"file":"compressedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAE3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,aAAa,EAGb,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,IAAI,YAAY,EAErB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAA6B,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAG5B,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE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sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,YAAY,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAChC,WAAW,EAAE,iBAAiB,EAC9B,MAAM,EAAE,qBAAqB,KACzB,YAAY,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC/B,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,wBAAwB,KAChC,WAAW,CAAC"}
@@ -322,6 +322,17 @@ class EncoderContext {
322
322
  this.isSummary = isSummary;
323
323
  this.nodeEncodersFromSchema = new Map();
324
324
  this.nestedArrayEncoders = new Map();
325
+ // Currently we never include originator-dependent identifiers in summaries
326
+ // (there was a bug which violated this for attach-summaries: it has been fixed, see `IdentifierHealingConfig`).
327
+ // If that ever changes (to allow better compressed attach summaries), we need to take special care with incremental summaries.
328
+ // This assert guards against data corruption leaking in via missing session information in incremental summaries,
329
+ // protecting from bugs of potential future optimizations to attach summaries applied to non-attach summaries.
330
+ // Incremental summaries should have no need for originator-dependent identifiers,
331
+ // as they can't be attach summaries which are the only ones which should ever have non-final ids.
332
+ (0, internal_1.assert)(isSummary || incrementalEncoder === undefined, 0xd0d /* incrementalEncoder cannot be used when encoding originator-dependent identifiers */);
333
+ }
334
+ encodePossiblyCompressedId(id) {
335
+ return (0, index_js_2.encodePossiblyCompressedId)(id, this.idCompressor, this.isSummary ? index_js_2.EncodedIdType.Originatorless : index_js_2.EncodedIdType.OriginatorDependent);
325
336
  }
326
337
  nodeEncoderFromSchema(schemaName) {
327
338
  return (0, index_js_2.getOrCreate)(this.nodeEncodersFromSchema, schemaName, () => this.nodeEncoderFromPolicy(this, schemaName));