@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
@@ -4,7 +4,12 @@
4
4
  */
5
5
 
6
6
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
7
- import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
7
+ import type {
8
+ IIdCompressor,
9
+ OpSpaceCompressedId,
10
+ SessionId,
11
+ SessionSpaceCompressedId,
12
+ } from "@fluidframework/id-compressor";
8
13
  import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
9
14
  import type { TSchema } from "@sinclair/typebox";
10
15
 
@@ -22,10 +27,15 @@ import {
22
27
  type StoredSchemaCollection,
23
28
  type TreeChunk,
24
29
  } from "../../../core/index.js";
25
- import { brandedNumberType, type Brand } from "../../../util/index.js";
30
+ import {
31
+ brandedNumberType,
32
+ forceDecodeEncodedIdWithoutSession,
33
+ type Brand,
34
+ type IdentifierHealingConfig,
35
+ } from "../../../util/index.js";
26
36
  import { TreeCompressionStrategy } from "../../treeCompressionUtils.js";
27
37
 
28
- import { decode } from "./chunkDecoding.js";
38
+ import { decode, type IdDecodingContext } from "./chunkDecoding.js";
29
39
  import type { FieldBatch } from "./fieldBatch.js";
30
40
  import {
31
41
  EncodedFieldBatchV1,
@@ -97,44 +107,139 @@ export interface IncrementalDecoder {
97
107
  */
98
108
  export interface IncrementalEncoderDecoder extends IncrementalEncoder, IncrementalDecoder {}
99
109
 
110
+ /**
111
+ * Encode-side context for {@link FieldBatchCodec}.
112
+ *
113
+ * Carries only the data the encoder actually consumes. Originator-session
114
+ * lookup, heal flags, and the incremental *decoder* live on
115
+ * {@link FieldBatchDecodingContext}.
116
+ */
100
117
  export interface FieldBatchEncodingContext {
101
118
  readonly encodeType: TreeCompressionStrategy;
102
119
  readonly idCompressor: IIdCompressor;
103
- readonly originatorId: SessionId;
104
120
  readonly schema?: SchemaAndPolicy;
105
121
  /**
106
- * An encoder / decoder for encoding and decoding of incremental fields.
107
- * This will be defined if incremental encoding is supported and enabled.
122
+ * Encoder for incremental fields. Defined when incremental encoding is
123
+ * supported and enabled.
108
124
  */
109
- readonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;
125
+ readonly incrementalEncoder?: IncrementalEncoder;
110
126
  /**
111
- * `true` when encoding to or decoding from a summary blob. `false` for
112
- * op-stream encode/decode paths and for utility encoders that are not
113
- * tied to a persisted document. Healing behavior is gated on this flag.
127
+ * `true` when encoding to a summary blob. `false` for op-stream encode
128
+ * paths and for utility encoders that aren't tied to a persisted document.
129
+ *
130
+ * @remarks
131
+ * Used by the node encoder to decide whether non-finalized op-space ids
132
+ * can be written into the batch (they can't, for summaries).
114
133
  */
115
134
  readonly isSummary: boolean;
135
+ }
136
+
137
+ /**
138
+ * Decode-side context for {@link FieldBatchCodec}.
139
+ *
140
+ * Carries the per-call `resolveEncodedId` function that encapsulates the
141
+ * originator-session lookup and (for the forest-summarizer's legacy heal path)
142
+ * the deterministic UUIDv5 synthesis. Heal and originator-session flags live
143
+ * inside that function, not on this context.
144
+ *
145
+ * Constructed via one of the two named static factories — {@link forOp} or
146
+ * {@link forSummary} — depending on the call site's semantics. The constructor
147
+ * is private; there is no general-purpose builder, because the choice between
148
+ * op-style and summary-style decoding is load-bearing (different invariants
149
+ * apply, and bugs in this area are typically the result of conflating them).
150
+ */
151
+ export class FieldBatchDecodingContext implements IdDecodingContext {
152
+ private constructor(
153
+ /**
154
+ * 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).
155
+ */
156
+ private readonly hasOriginatorSessionId: boolean,
157
+
158
+ public readonly idCompressor: Pick<IIdCompressor, "decompress">,
159
+
160
+ public readonly resolveEncodedId: (
161
+ id: OpSpaceCompressedId,
162
+ ) => SessionSpaceCompressedId | string,
163
+
164
+ /**
165
+ * Decoder for incremental fields. Defined when the encoded batch contains
166
+ * incremental chunks. Only populated on summary-style contexts; op-style
167
+ * contexts always have this undefined.
168
+ */
169
+ public readonly incrementalDecoder?: IncrementalDecoder,
170
+ ) {}
171
+
116
172
  /**
117
- * If `true`, when an op-space compressed ID encountered while decoding
118
- * cannot be resolved by the local id-compressor (e.g. the attach-summary
119
- * blob's originator session state was stripped), a deterministic stable
120
- * UUID derived from `sharedObjectId` is returned instead of throwing.
121
- * @remarks
122
- * Off by default. Used only to recover documents whose attach summary was
123
- * written with non-finalized op-space IDs before the encode-side fix
124
- * shipped. Only takes effect when `isSummary` is also `true`.
125
- * See {@link SharedTreeOptionsBeta.healUnresolvableIdentifiersOnDecode}.
173
+ * Construct a decode context for an op.
174
+ *
175
+ * The originator is the session that produced the encoded form (carried
176
+ * alongside the op envelope by the caller). Heal-on-decode is *not*
177
+ * available — an unresolvable id during op decode indicates a real bug,
178
+ * not a recoverable state, so the resolver throws rather than synthesizing
179
+ * a UUID. Incremental decoding is not used for ops.
126
180
  */
127
- readonly healUnresolvableIdentifiersOnDecode?: boolean;
181
+ public static forOp(opts: {
182
+ readonly idCompressor: IIdCompressor;
183
+ readonly originatorId: SessionId;
184
+ }): FieldBatchDecodingContext {
185
+ const { idCompressor, originatorId } = opts;
186
+ return new FieldBatchDecodingContext(true, idCompressor, (id) =>
187
+ idCompressor.normalizeToSessionSpace(id, originatorId),
188
+ );
189
+ }
190
+
128
191
  /**
129
- * The SharedTree's shared-object id, used as input to the deterministic
130
- * UUID derivation when `healUnresolvableIdentifiersOnDecode` triggers. Required
131
- * for that path; ignored otherwise.
132
- * @remarks
133
- * This allows us to ensure that multiple attaches,
134
- * in the same or different documents, with the same session offsets, get different UUIDs.
192
+ * Construct a decode context for a summary blob.
193
+ *
194
+ * Summaries must contain only ids resolvable without an originator — either
195
+ * finalized op-space ids, or (when {@link IdentifierHealingConfig} is supplied
196
+ * via `healing`) non-final ids that get healed into deterministic UUIDv5
197
+ * strings. Incremental decoding is attached via {@link withIncrementalDecoder}.
198
+ *
199
+ * @privateRemarks
200
+ * In the future (if adding a summary format which includes the session id),
201
+ * this could allow providing an originator ID to allow for op-space compressed identifiers in attach summaries.
202
+ * 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).
203
+ * Since only non-attach summaries can be incremental, incremental summaries should never have non finalized identifiers.
204
+ * `withIncrementalDecoder` has logic to guard against cases which expect session-relative identifiers in incremental chunks,
205
+ * as does the encoding-side assert in the {@link EncoderContext}.
135
206
  */
136
- readonly sharedObjectId?: string;
207
+ public static forSummary(opts: {
208
+ readonly idCompressor: IIdCompressor;
209
+ readonly healing?: IdentifierHealingConfig;
210
+ }): FieldBatchDecodingContext {
211
+ const { idCompressor, healing } = opts;
212
+ return new FieldBatchDecodingContext(false, idCompressor, (id) =>
213
+ forceDecodeEncodedIdWithoutSession(id, idCompressor, healing),
214
+ );
215
+ }
216
+
217
+ /**
218
+ * Returns a copy of this context with `incrementalDecoder` swapped in. Used by
219
+ * the forest summarizer to attach the per-call incremental builder to a base
220
+ * decode context.
221
+ */
222
+ public withIncrementalDecoder(
223
+ incrementalDecoder: IncrementalDecoder,
224
+ ): FieldBatchDecodingContext {
225
+ // As different incremental chunks may come from different sessions,
226
+ // for now we simply enforce that we do not provide an originator session ID
227
+ // when we might be dealing with incremental chunks.
228
+ // This mitigates the risk of using incorrect originator session ID identifiers in incremental chunks.
229
+ // See also private remarks on forSummary.
230
+ assert(
231
+ !this.hasOriginatorSessionId,
232
+ 0xd0c /* withIncrementalDecoder can only be called on contexts without an originator session ID */,
233
+ );
234
+ return new FieldBatchDecodingContext(
235
+ false,
236
+ this.idCompressor,
237
+ this.resolveEncodedId,
238
+ incrementalDecoder,
239
+ );
240
+ }
137
241
  }
242
+
138
243
  /**
139
244
  * @remarks
140
245
  * Fields in this batch currently don't have field schema for the root, which limits optimizations.
@@ -142,7 +247,8 @@ export interface FieldBatchEncodingContext {
142
247
  export type FieldBatchCodec = VersionDispatchingCodec<
143
248
  FieldBatch,
144
249
  FieldBatchEncodingContext,
145
- FieldBatchFormatVersion
250
+ FieldBatchFormatVersion,
251
+ FieldBatchDecodingContext
146
252
  >;
147
253
 
148
254
  /**
@@ -160,7 +266,7 @@ function makeFieldBatchCodecForVersion(
160
266
  isSummary: boolean,
161
267
  ) => EncodedFieldBatchV1OrV2,
162
268
  encodedFieldBatchType: TSchema,
163
- ): CodecAndSchema<FieldBatch, FieldBatchEncodingContext> {
269
+ ): CodecAndSchema<FieldBatch, FieldBatchEncodingContext, FieldBatchDecodingContext> {
164
270
  return {
165
271
  encode: (
166
272
  data: FieldBatch,
@@ -185,7 +291,7 @@ function makeFieldBatchCodecForVersion(
185
291
  0xca0 /* Unsupported FieldBatchFormatVersion for incremental encoding; must be v2 or higher */,
186
292
  );
187
293
  // Incremental encoding is only supported for CompressedIncremental.
188
- incrementalEncoder = context.incrementalEncoderDecoder;
294
+ incrementalEncoder = context.incrementalEncoder;
189
295
  }
190
296
  // fallthrough
191
297
  case TreeCompressionStrategy.Compressed: {
@@ -216,20 +322,10 @@ function makeFieldBatchCodecForVersion(
216
322
  },
217
323
  decode: (
218
324
  data: EncodedFieldBatchV1OrV2,
219
- context: FieldBatchEncodingContext,
325
+ context: FieldBatchDecodingContext,
220
326
  ): FieldBatch => {
221
327
  // TODO: consider checking data is in schema.
222
- return decode(
223
- data,
224
- {
225
- idCompressor: context.idCompressor,
226
- originatorId: context.originatorId,
227
- isSummary: context.isSummary,
228
- healUnresolvableIdentifiersOnDecode: context.healUnresolvableIdentifiersOnDecode,
229
- sharedObjectId: context.sharedObjectId,
230
- },
231
- context.incrementalEncoderDecoder,
232
- ).map((chunk) => chunk.cursor());
328
+ return decode(data, context, context.incrementalDecoder).map((chunk) => chunk.cursor());
233
329
  },
234
330
  schema: encodedFieldBatchType,
235
331
  };
@@ -18,7 +18,13 @@ import {
18
18
  type Value,
19
19
  forEachNode,
20
20
  } from "../../../core/index.js";
21
- import { getOrCreate } from "../../../util/index.js";
21
+ import {
22
+ EncodedIdType,
23
+ encodePossiblyCompressedId,
24
+ getOrCreate,
25
+ type EncodedId,
26
+ type IdEncodingContext,
27
+ } from "../../../util/index.js";
22
28
 
23
29
  import type { Counter, DeduplicationTable } from "./chunkCodecUtilities.js";
24
30
  import {
@@ -520,7 +526,9 @@ export function encodeValue(
520
526
  * - Singletons defined in a static scope.
521
527
  * - Cached in this object for future reuse such that all equivalent Shapes are deduplicated.
522
528
  */
523
- export class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
529
+ export class EncoderContext
530
+ implements NodeEncodeBuilder, FieldEncodeBuilder, IdEncodingContext
531
+ {
524
532
  private readonly nodeEncodersFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> =
525
533
  new Map();
526
534
  private readonly nestedArrayEncoders: Map<NodeEncoder, NestedArrayEncoder> = new Map();
@@ -528,7 +536,7 @@ export class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
528
536
  private readonly nodeEncoderFromPolicy: NodeEncoderPolicy,
529
537
  private readonly fieldEncoderFromPolicy: FieldEncoderPolicy,
530
538
  public readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FieldKindData>,
531
- public readonly idCompressor: IIdCompressor,
539
+ private readonly idCompressor: IIdCompressor,
532
540
  /**
533
541
  * To be used to encode incremental chunks, if any.
534
542
  * @remarks
@@ -540,7 +548,27 @@ export class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
540
548
  * See {@link FieldBatchEncodingContext.isSummary}.
541
549
  */
542
550
  public readonly isSummary: boolean,
543
- ) {}
551
+ ) {
552
+ // Currently we never include originator-dependent identifiers in summaries
553
+ // (there was a bug which violated this for attach-summaries: it has been fixed, see `IdentifierHealingConfig`).
554
+ // If that ever changes (to allow better compressed attach summaries), we need to take special care with incremental summaries.
555
+ // This assert guards against data corruption leaking in via missing session information in incremental summaries,
556
+ // protecting from bugs of potential future optimizations to attach summaries applied to non-attach summaries.
557
+ // Incremental summaries should have no need for originator-dependent identifiers,
558
+ // as they can't be attach summaries which are the only ones which should ever have non-final ids.
559
+ assert(
560
+ isSummary || incrementalEncoder === undefined,
561
+ 0xd0d /* incrementalEncoder cannot be used when encoding originator-dependent identifiers */,
562
+ );
563
+ }
564
+
565
+ public encodePossiblyCompressedId(id: string): string | EncodedId<EncodedIdType> {
566
+ return encodePossiblyCompressedId(
567
+ id,
568
+ this.idCompressor,
569
+ this.isSummary ? EncodedIdType.Originatorless : EncodedIdType.OriginatorDependent,
570
+ );
571
+ }
544
572
 
545
573
  public nodeEncoderFromSchema(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {
546
574
  return getOrCreate(this.nodeEncodersFromSchema, schemaName, () =>
@@ -13,6 +13,7 @@ export type { FieldBatch } from "./fieldBatch.js";
13
13
  export {
14
14
  type FieldBatchCodec,
15
15
  fieldBatchCodecBuilder,
16
+ FieldBatchDecodingContext,
16
17
  type FieldBatchEncodingContext,
17
18
  type IncrementalEncoderDecoder,
18
19
  type IncrementalEncoder,
@@ -4,7 +4,6 @@
4
4
  */
5
5
 
6
6
  import { assert, fail } from "@fluidframework/core-utils/internal";
7
- import { isFinalId, isStableId } from "@fluidframework/id-compressor/internal";
8
7
 
9
8
  import {
10
9
  type FieldKey,
@@ -24,10 +23,11 @@ import {
24
23
  type NodeEncoder,
25
24
  encodeValue,
26
25
  } from "./compressedEncode.js";
27
- import type {
28
- EncodedChunkShape,
29
- EncodedFieldShape,
30
- EncodedValueShape,
26
+ import {
27
+ SpecialField,
28
+ type EncodedChunkShape,
29
+ type EncodedFieldShape,
30
+ type EncodedValueShape,
31
31
  } from "./format/index.js";
32
32
 
33
33
  /**
@@ -69,21 +69,9 @@ export class NodeShapeBasedEncoder extends Shape<EncodedChunkShape> implements N
69
69
  }
70
70
 
71
71
  private getValueToEncode(cursor: ITreeCursorSynchronous, context: EncoderContext): Value {
72
- if (this.value === 0) {
72
+ if (this.value === SpecialField.Identifier) {
73
73
  assert(typeof cursor.value === "string", 0x9aa /* identifier must be type string */);
74
- if (isStableId(cursor.value)) {
75
- const sessionSpaceCompressedId = context.idCompressor.tryRecompress(cursor.value);
76
- if (sessionSpaceCompressedId !== undefined) {
77
- const opSpaceId = context.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);
78
- // Summaries can only contain finalized op-space ids unless they also include the originator's session id somewhere.
79
- // This is not the case for forest summaries at the time of writing, so non-finalized ids are instead written using
80
- // their long form (by falling through to the original cursor value).
81
- // A scenario where such ids can appear in the summary is in the attach summary of a tree being attached to an already-attached container.
82
- if (!context.isSummary || isFinalId(opSpaceId)) {
83
- return opSpaceId;
84
- }
85
- }
86
- }
74
+ return context.encodePossiblyCompressedId(cursor.value);
87
75
  }
88
76
  return cursor.value;
89
77
  }
@@ -20,7 +20,10 @@ export {
20
20
  type FieldBatch,
21
21
  type FieldBatchCodec,
22
22
  fieldBatchCodecBuilder,
23
+ FieldBatchDecodingContext,
23
24
  type FieldBatchEncodingContext,
25
+ type IncrementalDecoder,
26
+ type IncrementalEncoder,
24
27
  type IncrementalEncoderDecoder,
25
28
  type ChunkReferenceId,
26
29
  type IncrementalEncodingPolicy,
@@ -16,6 +16,7 @@ import {
16
16
  import type { FieldKey, ITreeCursorSynchronous } from "../../core/index.js";
17
17
  import {
18
18
  fieldBatchCodecBuilder,
19
+ type FieldBatchDecodingContext,
19
20
  type FieldBatchEncodingContext,
20
21
  } from "../chunked-forest/index.js";
21
22
 
@@ -28,13 +29,14 @@ export type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;
28
29
  export type ForestCodec = VersionDispatchingCodec<
29
30
  FieldSet,
30
31
  FieldBatchEncodingContext,
31
- ForestFormatVersion
32
+ ForestFormatVersion,
33
+ FieldBatchDecodingContext
32
34
  >;
33
35
 
34
36
  function makeForestSummarizerCodec(
35
37
  options: CodecWriteOptions,
36
38
  version: ForestFormatVersion,
37
- ): CodecAndSchema<FieldSet, FieldBatchEncodingContext> {
39
+ ): CodecAndSchema<FieldSet, FieldBatchEncodingContext, FieldBatchDecodingContext> {
38
40
  // Performance: Since multiple places (including multiple versions of this codec) use the field batch codec,
39
41
  // we may end up with multiple copies of it, including compiling its format validation multiple times.
40
42
  // This is not ideal, but is not too bad as it is a small fixed number of copies and thus should not be too expensive.
@@ -55,7 +57,7 @@ function makeForestSummarizerCodec(
55
57
  version,
56
58
  };
57
59
  },
58
- decode: (data: FormatCommon, context: FieldBatchEncodingContext): FieldSet => {
60
+ decode: (data: FormatCommon, context: FieldBatchDecodingContext): FieldSet => {
59
61
  const out: Map<FieldKey, ITreeCursorSynchronous> = new Map();
60
62
  const fields = fieldBatchCodec.decode(data.fields, context);
61
63
  assert(data.keys.length === fields.length, 0x891 /* mismatched lengths */);
@@ -41,6 +41,7 @@ import {
41
41
  import { chunkFieldSingle, defaultChunkPolicy } from "../chunked-forest/chunkTree.js";
42
42
  import {
43
43
  defaultIncrementalEncodingPolicy,
44
+ type FieldBatchDecodingContext,
44
45
  type FieldBatchEncodingContext,
45
46
  type IncrementalEncodingPolicy,
46
47
  } from "../chunked-forest/index.js";
@@ -80,6 +81,7 @@ export class ForestSummarizer
80
81
  private readonly forest: IEditableForest,
81
82
  private readonly revisionTagCodec: RevisionTagCodec,
82
83
  private readonly encoderContext: FieldBatchEncodingContext,
84
+ private readonly decoderContext: FieldBatchDecodingContext,
83
85
  options: CodecWriteOptions,
84
86
  private readonly idCompressor: IIdCompressor,
85
87
  initialSequenceNumber: number,
@@ -160,7 +162,7 @@ export class ForestSummarizer
160
162
  });
161
163
  const encoderContext: FieldBatchEncodingContext = {
162
164
  ...this.encoderContext,
163
- incrementalEncoderDecoder:
165
+ incrementalEncoder:
164
166
  incrementalSummaryBehavior === ForestIncrementalSummaryBehavior.Incremental
165
167
  ? this.incrementalSummaryBuilder
166
168
  : undefined,
@@ -212,10 +214,7 @@ export class ForestSummarizer
212
214
  parse,
213
215
  // TODO: this type cast assumes there are no handles, which should probably be enforced at runtime or the need for this cast should be removed altogether.
214
216
  )) as JsonCompatibleReadOnly,
215
- {
216
- ...this.encoderContext,
217
- incrementalEncoderDecoder: this.incrementalSummaryBuilder,
218
- },
217
+ this.decoderContext.withIncrementalDecoder(this.incrementalSummaryBuilder),
219
218
  );
220
219
  const allocator = idAllocatorFromMaxId();
221
220
  const fieldChanges: [FieldKey, DeltaFieldChanges][] = [];
@@ -109,11 +109,14 @@ export {
109
109
  FieldBatchFormatVersion,
110
110
  makeTreeChunker,
111
111
  fieldBatchCodecBuilder,
112
+ FieldBatchDecodingContext,
112
113
  type FieldBatchEncodingContext,
113
114
  emptyChunk,
114
115
  combineChunks,
115
116
  type IncrementalEncodingPolicy,
116
117
  defaultIncrementalEncodingPolicy,
118
+ type IncrementalDecoder,
119
+ type IncrementalEncoder,
117
120
  } from "./chunked-forest/index.js";
118
121
 
119
122
  export {
@@ -35,6 +35,7 @@ import {
35
35
  import { newChangeAtomIdBTree, type ChangeAtomIdBTree } from "../changeAtomIdBTree.js";
36
36
  import {
37
37
  type FieldBatchCodec,
38
+ FieldBatchDecodingContext,
38
39
  type TreeChunk,
39
40
  chunkFieldSingle,
40
41
  defaultChunkPolicy,
@@ -328,7 +329,6 @@ export function encodeDetachedNodes(
328
329
  trees: fieldsCodec.encode(treesToEncode, {
329
330
  encodeType: chunkCompressionStrategy,
330
331
  schema: context.schema,
331
- originatorId: context.originatorId,
332
332
  idCompressor: context.idCompressor,
333
333
  isSummary: context.isSummary,
334
334
  }),
@@ -350,14 +350,18 @@ export function decodeDetachedNodes(
350
350
  return undefined;
351
351
  }
352
352
 
353
- const chunks = fieldsCodec.decode(encoded.trees, {
354
- encodeType: chunkCompressionStrategy,
355
- originatorId: context.originatorId,
356
- idCompressor: context.idCompressor,
357
- isSummary: context.isSummary,
358
- healUnresolvableIdentifiersOnDecode: context.healUnresolvableIdentifiersOnDecode,
359
- sharedObjectId: context.sharedObjectId,
360
- });
353
+ const chunks = fieldsCodec.decode(
354
+ encoded.trees,
355
+ context.isSummary
356
+ ? FieldBatchDecodingContext.forSummary({
357
+ idCompressor: context.idCompressor,
358
+ healing: context.healing,
359
+ })
360
+ : FieldBatchDecodingContext.forOp({
361
+ idCompressor: context.idCompressor,
362
+ originatorId: context.originatorId,
363
+ }),
364
+ );
361
365
  const getChunk = (index: number): TreeChunk => {
362
366
  assert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);
363
367
  return chunkFieldSingle(chunks[index] ?? oob(), {
@@ -782,6 +782,14 @@ export class ModularChangeFamily
782
782
 
783
783
  const crossFieldKeys = this.makeCrossFieldKeyTable(invertedFields, invertedNodes);
784
784
 
785
+ const constraintState = newConstraintState(0);
786
+ this.updateConstraintsForFields(
787
+ invertedFields,
788
+ NodeAttachState.Attached,
789
+ constraintState,
790
+ invertedNodes,
791
+ );
792
+
785
793
  return makeModularChangeset({
786
794
  fieldChanges: invertedFields,
787
795
  nodeChanges: invertedNodes,
@@ -790,8 +798,7 @@ export class ModularChangeFamily
790
798
  crossFieldKeys,
791
799
  maxId: genId.getMaxId(),
792
800
  revisions: revInfos,
793
- constraintViolationCount: change.change.constraintViolationCountOnRevert,
794
- constraintViolationCountOnRevert: change.change.constraintViolationCount,
801
+ constraintViolationCount: constraintState.violationCount,
795
802
  noChangeConstraint,
796
803
  noChangeConstraintOnRevert,
797
804
  destroys,
@@ -939,9 +946,6 @@ export class ModularChangeFamily
939
946
  );
940
947
 
941
948
  const constraintState = newConstraintState(change.constraintViolationCount ?? 0);
942
- const revertConstraintState = newConstraintState(
943
- change.constraintViolationCountOnRevert ?? 0,
944
- );
945
949
 
946
950
  let noChangeConstraint = change.noChangeConstraint;
947
951
  if (
@@ -956,9 +960,7 @@ export class ModularChangeFamily
956
960
  this.updateConstraintsForFields(
957
961
  rebasedFields,
958
962
  NodeAttachState.Attached,
959
- NodeAttachState.Attached,
960
963
  constraintState,
961
- revertConstraintState,
962
964
  rebasedNodes,
963
965
  );
964
966
 
@@ -971,7 +973,6 @@ export class ModularChangeFamily
971
973
  maxId: idState.maxId,
972
974
  revisions: change.revisions,
973
975
  constraintViolationCount: constraintState.violationCount,
974
- constraintViolationCountOnRevert: revertConstraintState.violationCount,
975
976
  noChangeConstraint,
976
977
  noChangeConstraintOnRevert: change.noChangeConstraintOnRevert,
977
978
  builds: change.builds,
@@ -1410,32 +1411,21 @@ export class ModularChangeFamily
1410
1411
  private updateConstraintsForFields(
1411
1412
  fields: FieldChangeMap,
1412
1413
  parentInputAttachState: NodeAttachState,
1413
- parentOutputAttachState: NodeAttachState,
1414
1414
  constraintState: ConstraintState,
1415
- revertConstraintState: ConstraintState,
1416
1415
  nodes: ChangeAtomIdBTree<NodeChangeset>,
1417
1416
  ): void {
1418
1417
  for (const field of fields.values()) {
1419
1418
  const handler = getChangeHandler(this.fieldKinds, field.fieldKind);
1420
- for (const [nodeId, inputIndex, outputIndex] of handler.getNestedChanges(field.change)) {
1419
+ for (const [nodeId, inputIndex, _outputIndex] of handler.getNestedChanges(
1420
+ field.change,
1421
+ )) {
1421
1422
  const isInputDetached = inputIndex === undefined;
1422
1423
  const inputAttachState =
1423
1424
  parentInputAttachState === NodeAttachState.Detached || isInputDetached
1424
1425
  ? NodeAttachState.Detached
1425
1426
  : NodeAttachState.Attached;
1426
- const isOutputDetached = outputIndex === undefined;
1427
- const outputAttachState =
1428
- parentOutputAttachState === NodeAttachState.Detached || isOutputDetached
1429
- ? NodeAttachState.Detached
1430
- : NodeAttachState.Attached;
1431
- this.updateConstraintsForNode(
1432
- nodeId,
1433
- inputAttachState,
1434
- outputAttachState,
1435
- nodes,
1436
- constraintState,
1437
- revertConstraintState,
1438
- );
1427
+
1428
+ this.updateConstraintsForNode(nodeId, inputAttachState, nodes, constraintState);
1439
1429
  }
1440
1430
  }
1441
1431
  }
@@ -1443,10 +1433,8 @@ export class ModularChangeFamily
1443
1433
  private updateConstraintsForNode(
1444
1434
  nodeId: NodeId,
1445
1435
  inputAttachState: NodeAttachState,
1446
- outputAttachState: NodeAttachState,
1447
1436
  nodes: ChangeAtomIdBTree<NodeChangeset>,
1448
1437
  constraintState: ConstraintState,
1449
- revertConstraintState: ConstraintState,
1450
1438
  ): void {
1451
1439
  const node =
1452
1440
  nodes.get([nodeId.revision, nodeId.localId]) ?? fail(0xb24 /* Unknown node ID */);
@@ -1460,24 +1448,12 @@ export class ModularChangeFamily
1460
1448
  constraintState.violationCount += isNowViolated ? 1 : -1;
1461
1449
  }
1462
1450
  }
1463
- if (node.nodeExistsConstraintOnRevert !== undefined) {
1464
- const isNowViolated = outputAttachState === NodeAttachState.Detached;
1465
- if (node.nodeExistsConstraintOnRevert.violated !== isNowViolated) {
1466
- node.nodeExistsConstraintOnRevert = {
1467
- ...node.nodeExistsConstraintOnRevert,
1468
- violated: isNowViolated,
1469
- };
1470
- revertConstraintState.violationCount += isNowViolated ? 1 : -1;
1471
- }
1472
- }
1473
1451
 
1474
1452
  if (node.fieldChanges !== undefined) {
1475
1453
  this.updateConstraintsForFields(
1476
1454
  node.fieldChanges,
1477
1455
  inputAttachState,
1478
- outputAttachState,
1479
1456
  constraintState,
1480
- revertConstraintState,
1481
1457
  nodes,
1482
1458
  );
1483
1459
  }
@@ -2003,7 +1979,6 @@ export function updateRefreshers(
2003
1979
  maxId,
2004
1980
  revisions,
2005
1981
  constraintViolationCount,
2006
- constraintViolationCountOnRevert,
2007
1982
  builds,
2008
1983
  destroys,
2009
1984
  } = change;
@@ -2017,7 +1992,6 @@ export function updateRefreshers(
2017
1992
  maxId: maxId as number,
2018
1993
  revisions,
2019
1994
  constraintViolationCount,
2020
- constraintViolationCountOnRevert,
2021
1995
  builds,
2022
1996
  destroys,
2023
1997
  refreshers,
@@ -2632,7 +2606,6 @@ function makeModularChangeset(props?: {
2632
2606
  maxId: number;
2633
2607
  revisions?: readonly RevisionInfo[];
2634
2608
  constraintViolationCount?: number;
2635
- constraintViolationCountOnRevert?: number;
2636
2609
  noChangeConstraint?: NoChangeConstraint;
2637
2610
  noChangeConstraintOnRevert?: NoChangeConstraint;
2638
2611
  builds?: ChangeAtomIdBTree<TreeChunk>;
@@ -2657,12 +2630,6 @@ function makeModularChangeset(props?: {
2657
2630
  if (p.constraintViolationCount !== undefined && p.constraintViolationCount > 0) {
2658
2631
  changeset.constraintViolationCount = p.constraintViolationCount;
2659
2632
  }
2660
- if (
2661
- p.constraintViolationCountOnRevert !== undefined &&
2662
- p.constraintViolationCountOnRevert > 0
2663
- ) {
2664
- changeset.constraintViolationCountOnRevert = p.constraintViolationCountOnRevert;
2665
- }
2666
2633
  if (p.noChangeConstraint !== undefined) {
2667
2634
  changeset.noChangeConstraint = p.noChangeConstraint;
2668
2635
  }