@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
@@ -12,13 +12,16 @@ export {
12
12
  } from "./branch.js";
13
13
 
14
14
  export {
15
- TransactionResult,
16
- type Transactor,
15
+ type ChangeProcessor,
16
+ type OnPop,
17
+ type OnPush,
18
+ type SquashingTransactionOptions,
17
19
  type TransactionEvents,
18
- TransactionStack,
20
+ type Transactor,
21
+ ChangeProcessorApplicability,
19
22
  SquashingTransactionStack,
20
- type OnPush,
21
- type OnPop,
23
+ TransactionResult,
24
+ TransactionStack,
22
25
  } from "./transaction.js";
23
26
 
24
27
  export {
@@ -197,8 +197,9 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
197
197
  this.idCompressor,
198
198
  options.minVersionForCollab,
199
199
  this.schemaAndPolicy,
200
- options.healUnresolvableIdentifiersOnDecode,
201
- sharedObject.id,
200
+ options.healUnresolvableIdentifiersOnDecode === true
201
+ ? { sharedObjectId: sharedObject.id }
202
+ : undefined,
202
203
  ),
203
204
  ...summarizables,
204
205
  ];
@@ -40,15 +40,17 @@ export enum TransactionResult {
40
40
 
41
41
  /**
42
42
  * A simple API for managing transactions.
43
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
43
44
  */
44
- export interface Transactor {
45
+ export interface Transactor<TOptions> {
45
46
  /**
46
47
  * Start a new transaction.
48
+ * @param options - Options controlling how the transaction is committed.
47
49
  * @remarks
48
50
  * If a transaction is already in progress when this new transaction starts, then this transaction will be "nested" inside of it,
49
51
  * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.
50
52
  */
51
- start(): void;
53
+ start(options?: TOptions): void;
52
54
  /**
53
55
  * Close this transaction by squashing its edits and committing them as a single edit.
54
56
  * @remarks If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.
@@ -89,8 +91,9 @@ export interface TransactionEvents {
89
91
 
90
92
  /**
91
93
  * Callbacks for transaction lifecycle events.
94
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
92
95
  */
93
- export interface Callbacks {
96
+ export interface Callbacks<TOptions> {
94
97
  /**
95
98
  * Called when the current transaction is popped from the {@link TransactionStack | stack}.
96
99
  */
@@ -104,37 +107,42 @@ export interface Callbacks {
104
107
  * Put another way, a transaction always results in a call to exactly one `OnPush` callback - whichever is closest to the transaction.
105
108
  * The event "bubbles up" to (and no further past) its first registered callback.
106
109
  */
107
- readonly onPush?: OnPush;
110
+ readonly onPush?: OnPush<TOptions>;
108
111
  }
109
112
 
110
113
  /**
111
114
  * A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
112
115
  * @remarks This function may return other functions that will be called when the transaction is popped from the stack or a nested transaction is pushed onto the stack.
113
116
  * This function runs just before the transaction begins, so if this is the beginning of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
117
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
118
+ * @param options - The options passed to {@link Transactor.start | start}.
114
119
  */
115
- export type OnPush = () => Callbacks | void;
120
+ export type OnPush<TOptions> = (options?: TOptions) => Callbacks<TOptions> | void;
116
121
 
117
122
  /**
118
123
  * A function that will be called when a transaction is popped from the {@link TransactionStack | stack}.
119
124
  * @remarks This function runs just after the transaction ends, so if this is the end of an outermost (not nested) transaction then {@link Transactor.size} will be 0 during its execution.
125
+ * @param result - The result of the transaction.
120
126
  */
121
127
  export type OnPop = (result: TransactionResult) => void;
122
128
 
123
129
  /**
124
130
  * A frame in the transaction stack.
131
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
125
132
  */
126
- interface TransactionStackFrame {
133
+ interface TransactionStackFrame<TOptions> {
127
134
  /** The callbacks provided when this transaction frame was pushed onto the stack. */
128
- readonly callbacks: Callbacks;
135
+ readonly callbacks: Callbacks<TOptions>;
129
136
  }
130
137
 
131
138
  /**
132
139
  * An implementation of {@link Transactor} that uses a stack to manage transactions.
133
140
  * @remarks Using a stack allows transactions to nest - i.e. an inner transaction may be started while an outer transaction is already in progress.
141
+ * @typeParam TOptions - The type of the options passed to {@link Transactor.start | start}.
134
142
  */
135
- export class TransactionStack implements Transactor, IDisposable {
136
- readonly #stack: TransactionStackFrame[] = [];
137
- readonly #onPush?: OnPush;
143
+ export class TransactionStack<TOptions> implements Transactor<TOptions>, IDisposable {
144
+ readonly #stack: TransactionStackFrame<TOptions>[] = [];
145
+ readonly #onPush?: OnPush<TOptions>;
138
146
 
139
147
  readonly #events = createEmitter<TransactionEvents>();
140
148
  public get events(): Listenable<TransactionEvents> {
@@ -150,7 +158,7 @@ export class TransactionStack implements Transactor, IDisposable {
150
158
  * Construct a new {@link TransactionStack}.
151
159
  * @param onPush - A {@link OnPush | function} that will be called when a transaction begins.
152
160
  */
153
- public constructor(onPush?: OnPush) {
161
+ public constructor(onPush?: OnPush<TOptions>) {
154
162
  this.#onPush = onPush;
155
163
  }
156
164
 
@@ -159,11 +167,11 @@ export class TransactionStack implements Transactor, IDisposable {
159
167
  return this.#stack.length;
160
168
  }
161
169
 
162
- public start(): void {
170
+ public start(options?: TOptions): void {
163
171
  this.ensureNotDisposed();
164
172
  const last = getLast(this.#stack);
165
173
  const onPushCurrent = last === undefined ? this.#onPush : last.callbacks.onPush;
166
- const { onPush, onPop } = onPushCurrent?.() ?? {};
174
+ const { onPush, onPop } = onPushCurrent?.(options) ?? {};
167
175
  this.#stack.push({
168
176
  callbacks: { onPop, onPush: onPush ?? onPushCurrent },
169
177
  });
@@ -216,6 +224,73 @@ export type OnPopWithViewUpdate<TChange> = (
216
224
  viewUpdate: TChange | undefined,
217
225
  ) => void;
218
226
 
227
+ /**
228
+ * Informs the caller of {@link ChangeProcessor} what context it should be invoked for.
229
+ * @remarks This is purely a recommendation to the caller of the processor and
230
+ * not a strict rule.
231
+ */
232
+ export enum ChangeProcessorApplicability {
233
+ /**
234
+ * Invoke the processor if no later (outer) instance of this change processor
235
+ * may be applied to related changes before changes are "visible".
236
+ *
237
+ * @remarks
238
+ * This designation is meant for processors that only need to be applied
239
+ * once to a set of related changes independent of scope or nesting,
240
+ * with the understanding that the processor should still be applied no
241
+ * later than when the changes are "visible" (e.g. committed to a branch).
242
+ * For example, a processor that removes extraneous information from a
243
+ * change (e.g. data for nodes that were both created and removed within a
244
+ * transaction) only needs to be applied once to the squashed change
245
+ * produced by the outermost transaction.
246
+ */
247
+ IfOutermost,
248
+ /**
249
+ * Invoke the processor in all contexts.
250
+ */
251
+ Always,
252
+ }
253
+
254
+ /**
255
+ * Processes a change altering its representation.
256
+ *
257
+ * @remarks
258
+ * A change processor receives a change and returns a change with the
259
+ * same observable effect but otherwise transformed.
260
+ *
261
+ * Currently this is the internal counterpart of the type-erased post-processor
262
+ * exposed on the public transaction API. The public boundary type-erases this
263
+ * (see the conversion helpers in the `shared-tree` layer) so that its internal
264
+ * change representation does not leak into the public API.
265
+ */
266
+ export interface ChangeProcessor<TChange> {
267
+ /**
268
+ * Informs what context it should be invoked for.
269
+ */
270
+ readonly applicability: ChangeProcessorApplicability;
271
+ /**
272
+ * Processes the given change, returning a change with the same observable effect.
273
+ */
274
+ readonly processChange: (change: TChange) => TChange;
275
+ }
276
+
277
+ /**
278
+ * Options for {@link Transactor.start | starting} a transaction.
279
+ */
280
+ export interface SquashingTransactionOptions<TChange> {
281
+ /**
282
+ * An optional {@link ChangeProcessor} applied to the squashed change produced when a transaction that was started
283
+ * with this option is committed.
284
+ *
285
+ * @remarks
286
+ * When omitted, the transaction's edits are squashed without any post-processing.
287
+ *
288
+ * How often the processor is invoked across nested transactions is governed by its
289
+ * {@link ChangeProcessor.applicability | applicability}.
290
+ */
291
+ readonly postProcessor?: ChangeProcessor<TChange>;
292
+ }
293
+
219
294
  /**
220
295
  * An implementation of {@link Transactor} that {@link TransactionStack | uses a stack} and a {@link SharedTreeBranch | branch} to manage transactions.
221
296
  * @remarks Given a branch, this class will fork the branch when a transaction begins and squash the forked branch back into the original branch when the transaction ends.
@@ -225,7 +300,7 @@ export type OnPopWithViewUpdate<TChange> = (
225
300
  export class SquashingTransactionStack<
226
301
  TEditor extends ChangeFamilyEditor,
227
302
  TChange,
228
- > extends TransactionStack {
303
+ > extends TransactionStack<SquashingTransactionOptions<TChange>> {
229
304
  #transactionBranch?: SharedTreeBranch<TEditor, TChange>;
230
305
 
231
306
  /**
@@ -284,15 +359,41 @@ export class SquashingTransactionStack<
284
359
  * Construct a new {@link SquashingTransactionStack}.
285
360
  * @param branch - The {@link SquashingTransactionStack.branch | branch} that will be forked off of when a transaction begins.
286
361
  * @param onPush - A function that will be called when a transaction is pushed to the {@link TransactionStack | stack}.
362
+ * @remarks To post-process the squashed change produced when a transaction is committed (for example, to "minimize"
363
+ * it so that it contains no extraneous information), start the transaction with a
364
+ * {@link SquashingTransactionOptions.postProcessor | post-processor}. The post-processor is injected via the transaction
365
+ * options rather than baked into this stack, so different transactions may supply different post-processors (or none).
287
366
  */
288
367
  public constructor(
289
368
  public readonly branch: SharedTreeBranch<TEditor, TChange>,
290
369
  mintRevisionTag: () => RevisionTag,
291
370
  onPush?: () => OnPopWithViewUpdate<TChange> | void,
292
371
  ) {
372
+ // A stack of the post-processors to apply when each in-progress transaction commits, ordered from outermost to
373
+ // innermost. Each in-progress transaction contributes exactly one entry: either the processor to apply when it
374
+ // commits, or `undefined` when none should be applied.
375
+ const postProcessorStack: (ChangeProcessor<TChange> | undefined)[] = [];
376
+ // Determines the entry to push for a transaction that was started with the given `requested` processor (if any).
377
+ // A processor with "outermost" applicability that is already active in an enclosing transaction resolves to
378
+ // `undefined` so that it is only applied once (at the outermost transaction that supplied it).
379
+ const resolvePostProcessor = (
380
+ requested: ChangeProcessor<TChange> | undefined,
381
+ ): ChangeProcessor<TChange> | undefined => {
382
+ if (
383
+ requested?.applicability === ChangeProcessorApplicability.IfOutermost &&
384
+ postProcessorStack.includes(requested)
385
+ ) {
386
+ return undefined;
387
+ }
388
+ return requested;
389
+ };
390
+
293
391
  super(
294
392
  // Invoked when an outer transaction starts
295
- (): Callbacks => {
393
+ (
394
+ startOptions?: SquashingTransactionOptions<TChange>,
395
+ ): Callbacks<SquashingTransactionOptions<TChange>> => {
396
+ postProcessorStack.push(resolvePostProcessor(startOptions?.postProcessor));
296
397
  // Keep track of the commit that each transaction was on when it started
297
398
  const startHead = this.activeBranch.getHead();
298
399
  const rebaser = this.branch.changeFamily.rebaser;
@@ -309,6 +410,7 @@ export class SquashingTransactionStack<
309
410
  // Invoked when an outer transaction ends
310
411
  const onOuterTransactionPop: OnPop = (result) => {
311
412
  assert(this.size === 0, 0xcae /* The outer transaction should be ending */);
413
+ const postProcessor = postProcessorStack.pop();
312
414
  transactionBranch.editor.exitTransaction();
313
415
 
314
416
  const sourcePath: GraphCommit<TChange>[] = [];
@@ -357,16 +459,20 @@ export class SquashingTransactionStack<
357
459
  }
358
460
  // Squash all the new commits on the transaction branch into a new commit on the original branch
359
461
  const squash = rebaser.compose(transactionSteps);
462
+ // Apply this transaction's post-processor (if any) to the squashed change (for example, to
463
+ // "minimize" it so that it contains no extraneous information).
464
+ const change =
465
+ postProcessor === undefined ? squash : postProcessor.processChange(squash);
360
466
 
361
467
  if (targetPath.length === 0) {
362
468
  // No changes were made on the original branch since the transaction began
363
469
  // The transaction commit can be applied directly
364
- this.branch.apply(tagChange(squash, transactionRevision));
470
+ this.branch.apply(tagChange(change, transactionRevision));
365
471
  // The view is already up-to-date so there's nothing more to do
366
472
  } else {
367
473
  // Some changes were made on `branch` since the transaction began
368
474
  const unrebasedHead = mintCommit(startHead, {
369
- change: squash,
475
+ change,
370
476
  revision: transactionRevision,
371
477
  });
372
478
  // We need to rebase the transaction commit on top of the new changes
@@ -407,13 +513,17 @@ export class SquashingTransactionStack<
407
513
  outerOnPop?.(result, viewUpdate);
408
514
  };
409
515
  // Invoked when a nested transaction begins
410
- const onNestedTransactionPush: OnPush = () => {
516
+ const onNestedTransactionPush: OnPush<SquashingTransactionOptions<TChange>> = (
517
+ nestedStartOptions,
518
+ ) => {
519
+ postProcessorStack.push(resolvePostProcessor(nestedStartOptions?.postProcessor));
411
520
  const nestedStartHead = this.activeBranch.getHead();
412
521
  const nestedOuterOnPop = onPush?.();
413
522
  transactionBranch.editor.enterTransaction();
414
523
  return {
415
524
  // Invoked when a nested transaction ends
416
525
  onPop: (result) => {
526
+ const nestedPostProcessor = postProcessorStack.pop();
417
527
  transactionBranch.editor.exitTransaction();
418
528
  switch (result) {
419
529
  case TransactionResult.Abort: {
@@ -422,6 +532,26 @@ export class SquashingTransactionStack<
422
532
  break;
423
533
  }
424
534
  case TransactionResult.Commit: {
535
+ // When this nested transaction supplied a post-processor that should be applied here, squash its
536
+ // edits into a single (post-processed) commit on the transaction branch rather than leaving them to
537
+ // be squashed only when the outermost transaction is committed.
538
+ if (nestedPostProcessor !== undefined) {
539
+ const nestedSteps: GraphCommit<TChange>[] = [];
540
+ findAncestor(
541
+ [transactionBranch.getHead(), nestedSteps],
542
+ (c) => c === nestedStartHead,
543
+ );
544
+ if (nestedSteps.length > 0) {
545
+ assert(
546
+ transactionRevision !== undefined,
547
+ 0xd07 /* Expected transaction revision in the presence of transaction steps */,
548
+ );
549
+ const squash = rebaser.compose(nestedSteps);
550
+ const processedSquash = nestedPostProcessor.processChange(squash);
551
+ transactionBranch.removeAfter(nestedStartHead);
552
+ transactionBranch.apply(tagChange(processedSquash, transactionRevision));
553
+ }
554
+ }
425
555
  break;
426
556
  }
427
557
  default: {
@@ -179,19 +179,23 @@ export {
179
179
  } from "./storedSchema.js";
180
180
 
181
181
  export {
182
+ type NoChangeConstraint,
183
+ type NodeInDocumentConstraint,
184
+ rollback,
185
+ type RunTransactionParamsAlpha,
186
+ type RunTransactionParamsBeta,
187
+ type TransactionCallbackStatusAlpha,
188
+ type TransactionCallbackStatusBeta,
182
189
  type TransactionConstraint,
183
190
  type TransactionConstraintAlpha,
184
- type NodeInDocumentConstraint,
185
- type NoChangeConstraint,
186
- type RunTransactionParams,
187
- type VoidTransactionCallbackStatus,
188
- type TransactionCallbackStatus,
189
- type TransactionResult,
190
- type TransactionResultExt,
191
- type TransactionResultSuccess,
191
+ type TransactionPostProcessor,
192
192
  type TransactionResultFailed,
193
+ type TransactionResultSuccess,
194
+ type TransactionValueResult,
195
+ type TransactionVoidResult,
196
+ type VoidTransactionCallbackStatusAlpha,
197
+ type VoidTransactionCallbackStatusBeta,
193
198
  type WithValue,
194
- rollback,
195
199
  } from "./transactionTypes.js";
196
200
 
197
201
  export { generateSchemaFromSimpleSchema } from "./schemaFromSimple.js";
@@ -78,7 +78,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
78
78
  }
79
79
 
80
80
  /**
81
- * Converts an enum into a collection of schema which can be used in a union.
81
+ * Converts an enum into a collection of schemas which can be used in a union.
82
82
  *
83
83
  * @typeParam TScope - The scope of the provided factory.
84
84
  * There is a known issue where if a factory is provided that is typed as a {@link SchemaFactoryAlpha}, and its scope contains a "." character,
@@ -88,7 +88,7 @@ export function singletonSchema<TScope extends string, TName extends string | nu
88
88
  * @remarks
89
89
  * The string value of the enum is used as the name of the schema: callers must ensure that it is stable and unique.
90
90
  * Numeric enums values have the value implicitly converted into a string.
91
- * Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other schema.
91
+ * Consider making a dedicated schema factory with a nested scope (for example using {@link SchemaFactoryBeta.scopedFactory}) to avoid the enum members colliding with other schemas.
92
92
  * @example
93
93
  * ```typescript
94
94
  * const schemaFactory = new SchemaFactory("com.myApp");
@@ -213,7 +213,7 @@ export function enumEntries(
213
213
  }
214
214
 
215
215
  /**
216
- * Converts an array of distinct strings into a collection of schema which can be used like an enum style union.
216
+ * Converts an array of distinct strings into a collection of schemas which can be used like an enum style union.
217
217
  * @remarks
218
218
  * The returned collection is also a function which can be used to convert strings into {@link Unhydrated} nodes in the union.
219
219
  * Each node type has a `.value` getter which returns the associated string.
@@ -339,7 +339,7 @@ export class SchemaFactory<
339
339
  /**
340
340
  * Construct a SchemaFactory with a given {@link SchemaFactory.scope|scope}.
341
341
  * @remarks
342
- * There are no restrictions on mixing schema from different schema factories.
342
+ * There are no restrictions on mixing schemas from different schema factories.
343
343
  * Typically each library will create one or more SchemaFactories and use them to define its schema.
344
344
  */
345
345
  public constructor(
@@ -698,7 +698,7 @@ export class SchemaFactory<
698
698
  const same = compareSets({ a: inputTypes, b: outputTypes });
699
699
  if (!same) {
700
700
  throw new UsageError(
701
- `Structurally named schema collision: two schema named "${fullName}" were defined with different input schema.`,
701
+ `Structurally named schema collision: two schemas named "${fullName}" were defined with different input schemas.`,
702
702
  );
703
703
  }
704
704
  return structural;
@@ -422,11 +422,11 @@ export interface SnapshotSchemaCompatibilityOptions {
422
422
  * Libraries which export schema for use by others will need to take special care to ensure the stability contract they offer their users aligns which what is validated by this utility.
423
423
  *
424
424
  * This utility only tests compatibility of the historical snapshots against the current schema; it does not test them against each-other.
425
- * Generally any historical schema should have been tested against the ones before them at the time they were current.
425
+ * Generally any historical schemas should have been tested against the ones before them at the time they were current.
426
426
  * If for some reason a version of a schema made it into production that was not compatible with a previous version,
427
427
  * that can still be represented here (but may require manually generating a snapshot for that version)
428
428
  * and this will still allow testing that all historical version can be upgraded to the current one.
429
- * If a sufficiently incompatible historical schema were used in production, it may be impossible to make a single schema which can accommodate all of them:
429
+ * If a sufficiently incompatible historical schemas were used in production, it may be impossible to make a single schema which can accommodate all of them:
430
430
  * this utility can be used to confirm that is the case, as well as to avoid the problem in the first place by testing schema before each one is deployed.
431
431
  *
432
432
  * @example Mocha test which validates the current `config` can collaborate with all historical version back to 2.0.0, and load and update any versions older than that.
@@ -3,6 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import type { ErasedType } from "@fluidframework/core-interfaces";
7
+
6
8
  import type { TreeNode } from "../core/index.js";
7
9
 
8
10
  /**
@@ -50,87 +52,148 @@ export interface NoChangeConstraint {
50
52
 
51
53
  /**
52
54
  * Contains a value returned from a transaction.
53
- * @alpha
55
+ * @input
56
+ * @beta
54
57
  */
55
58
  export interface WithValue<TValue> {
56
59
  /** The user-supplied value. */
57
- value: TValue;
60
+ readonly value: TValue;
58
61
  }
59
62
 
60
63
  /**
61
- * Contains a value and status returned from a user-supplied {@link TreeBranchAlpha.(runTransaction:1) | transaction callback}.
62
- * @alpha
64
+ * Contains a value and status returned from a user-supplied {@link TreeViewBeta.runTransaction | transaction callback}.
65
+ * @input
66
+ * @beta
63
67
  */
64
- export type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (
68
+ export type TransactionCallbackStatusBeta<TSuccessValue, TFailureValue> =
65
69
  | (WithValue<TSuccessValue> & {
66
70
  /** Indicates that the transaction callback ran successfully. */
67
- rollback?: false;
71
+ readonly rollback?: false;
68
72
  })
69
73
  | (WithValue<TFailureValue> & {
70
74
  /** Indicates that the transaction callback failed and the transaction should be rolled back. */
71
- rollback: true;
72
- })
73
- ) & {
74
- /**
75
- * An optional list of {@link TransactionConstraintAlpha | constraints} that will be checked when the commit corresponding
76
- * to this transaction is reverted. If any of these constraints are not met when the revert is being applied either
77
- * locally or on remote clients, the revert will be ignored.
78
- * These constraints must also be met at the time they are first introduced. If they are not met after the transaction
79
- * callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.
80
- */
81
- preconditionsOnRevert?: readonly TransactionConstraintAlpha[];
82
- };
75
+ readonly rollback: true;
76
+ });
77
+
78
+ /**
79
+ * The result of a {@link TreeViewBeta.runTransaction | transaction} that doesn't return a value.
80
+ * @input
81
+ * @beta
82
+ */
83
+ export type VoidTransactionCallbackStatusBeta = Omit<
84
+ TransactionCallbackStatusBeta<unknown, unknown>,
85
+ "value"
86
+ >;
87
+
88
+ /**
89
+ * {@link TransactionCallbackStatusBeta} extended with alpha-only {@link TransactionConstraintAlpha | constraint} options.
90
+ * @input
91
+ * @alpha
92
+ */
93
+ export type TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue> =
94
+ TransactionCallbackStatusBeta<TSuccessValue, TFailureValue> & {
95
+ /**
96
+ * An optional list of {@link TransactionConstraintAlpha | constraints} that will be checked when the commit corresponding
97
+ * to this transaction is reverted. If any of these constraints are not met when the revert is being applied either
98
+ * locally or on remote clients, the revert will be ignored.
99
+ * These constraints must also be met at the time they are first introduced. If they are not met after the transaction
100
+ * callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.
101
+ */
102
+ readonly preconditionsOnRevert?: readonly TransactionConstraintAlpha[];
103
+ };
83
104
 
84
105
  /**
85
106
  * The result of a {@link TreeBranchAlpha.(runTransaction:2) | transaction} that doesn't return a value.
107
+ * @input
86
108
  * @alpha
87
109
  */
88
- export type VoidTransactionCallbackStatus = Omit<
89
- TransactionCallbackStatus<unknown, unknown>,
110
+ export type VoidTransactionCallbackStatusAlpha = Omit<
111
+ TransactionCallbackStatusAlpha<unknown, unknown>,
90
112
  "value"
91
113
  >;
92
114
 
93
115
  /**
94
- * The result of a {@link TreeBranchAlpha.(runTransaction:1) | transaction} that completed successfully.
95
- * @alpha
116
+ * The result of a {@link TreeViewBeta.(runTransaction:1) | transaction} that completed successfully.
117
+ * @sealed
118
+ * @beta
96
119
  */
97
120
  export interface TransactionResultSuccess<TSuccessValue> extends WithValue<TSuccessValue> {
98
- /** The success flag for a transaction that completed without being {@link TransactionCallbackStatus | rolled back}. */
99
- success: true;
121
+ /** The success flag for a transaction that completed without being {@link TransactionCallbackStatusBeta | rolled back}. */
122
+ readonly success: true;
100
123
  }
101
124
 
102
125
  /**
103
- * The result of a {@link TreeBranchAlpha.(runTransaction:1) | transaction} that was rolled back.
104
- * @alpha
126
+ * The result of a {@link TreeViewBeta.runTransaction | transaction} that was rolled back.
127
+ * @sealed
128
+ * @beta
105
129
  */
106
130
  export interface TransactionResultFailed<TFailureValue> extends WithValue<TFailureValue> {
107
- /** The failure flag for a transaction that was {@link TransactionCallbackStatus | rolled back}. */
108
- success: false;
131
+ /** The failure flag for a transaction that was {@link TransactionCallbackStatusBeta | rolled back}. */
132
+ readonly success: false;
109
133
  }
110
134
 
111
135
  /**
112
136
  * The result of the {@link RunTransaction | RunTransaction} API.
113
- * @alpha
137
+ * @sealed
138
+ * @beta
114
139
  */
115
- export type TransactionResultExt<TSuccessValue, TFailureValue> =
140
+ export type TransactionValueResult<TSuccessValue, TFailureValue> =
116
141
  | TransactionResultSuccess<TSuccessValue>
117
142
  | TransactionResultFailed<TFailureValue>;
118
143
 
119
144
  /**
120
- * The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionResultExt}
145
+ * The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionValueResult}
121
146
  * but with the `value` field omitted. This is useful when the transaction callback doesn't need to return a value.
122
- * @alpha
147
+ * @sealed
148
+ * @beta
123
149
  */
124
- export type TransactionResult =
150
+ export type TransactionVoidResult =
125
151
  | Omit<TransactionResultSuccess<unknown>, "value">
126
152
  | Omit<TransactionResultFailed<unknown>, "value">;
127
153
 
128
154
  /**
129
- * The parameters for the {@link RunTransaction | RunTransaction} API.
155
+ * A type-erased function that post-processes the change produced when a transaction is committed.
156
+ *
157
+ * @remarks
158
+ * Supply one via {@link RunTransactionParamsAlpha.postProcessor} to process/alter
159
+ * the change that a transaction produces. For example a post-processor could
160
+ * remove extraneous information, so that the resulting squashed change contains
161
+ * no extraneous information.
162
+ *
163
+ * This type intentionally hides its internal representation: its concrete shape
164
+ * is an implementation detail of `@fluidframework/tree`. Obtain a value of this
165
+ * type from a `@fluidframework/tree` helper or constant rather than constructing
166
+ * one directly.
167
+ *
130
168
  * @alpha
169
+ * @sealed
170
+ * @system
171
+ */
172
+ export interface TransactionPostProcessor
173
+ extends ErasedType<"@fluidframework/tree.TransactionPostProcessor"> {}
174
+
175
+ /**
176
+ * The parameters for the {@link RunTransaction | RunTransaction} API.
177
+ * @input
178
+ * @beta
179
+ */
180
+ export interface RunTransactionParamsBeta {
181
+ /**
182
+ * A label for this transaction that allows it to be correlated with later edits (e.g. for controlling undo/redo grouping).
183
+ * @remarks
184
+ * If this transaction is applied to a {@link TreeBranchAlpha | branch}, the label will be available in the {@link LocalChangeMetadata.label | metadata} of the {@link TreeBranchEvents.changed | `changed`} event.
185
+ *
186
+ * If there is a nested transaction, only the outermost transaction label will be used.
187
+ */
188
+ readonly label?: unknown;
189
+ }
190
+
191
+ /**
192
+ * The parameters for the {@link RunTransaction | RunTransaction} API, extended with alpha-only {@link TransactionConstraintAlpha | constraint} options.
131
193
  * @input
194
+ * @alpha
132
195
  */
133
- export interface RunTransactionParams {
196
+ export interface RunTransactionParamsAlpha extends RunTransactionParamsBeta {
134
197
  /**
135
198
  * An optional list of {@link TransactionConstraintAlpha | constraints} that are checked just before the transaction begins.
136
199
  * @remarks
@@ -138,12 +201,21 @@ export interface RunTransactionParams {
138
201
  * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.
139
202
  */
140
203
  readonly preconditions?: readonly TransactionConstraintAlpha[];
204
+
141
205
  /**
142
- * A label for this transaction that allows it to be correlated with later edits (e.g. for controlling undo/redo grouping).
206
+ * An optional {@link TransactionPostProcessor | post-processor} applied to
207
+ * the change produced when this transaction is committed.
143
208
  * @remarks
144
- * If this transaction is applied to a {@link TreeBranchAlpha | branch}, the label will be available in the {@link LocalChangeMetadata.label | metadata} of the {@link TreeBranchEvents.changed | `changed`} event.
209
+ * When omitted, the transaction's edits are squashed without any such processing.
145
210
  *
146
- * If there is a nested transaction, only the outermost transaction label will be used.
211
+ * Specific post-processors are applied according to their own rules for
212
+ * optimization and other post-processing tasks in a transaction stack. For
213
+ * example a "minimization" post-processor may be applied once for the
214
+ * outermost transaction in a stack as it will process all nested edits and
215
+ * there is no benefit from multiple applications.
216
+ *
217
+ * Note: minimization is not yet implemented. Supplying a post-processor currently has no observable effect beyond
218
+ * reserving the behavior; a real post-processor will be provided in a future change.
147
219
  */
148
- readonly label?: unknown;
220
+ readonly postProcessor?: TransactionPostProcessor;
149
221
  }