@fluidframework/tree 2.113.0-411909 → 2.114.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 (534) hide show
  1. package/CHANGELOG.md +272 -0
  2. package/api-report/tree.alpha.api.md +19 -0
  3. package/dist/core/change-family/changeFamily.d.ts +15 -4
  4. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  5. package/dist/core/change-family/changeFamily.js.map +1 -1
  6. package/dist/core/change-family/editBuilder.d.ts +2 -3
  7. package/dist/core/change-family/editBuilder.d.ts.map +1 -1
  8. package/dist/core/change-family/editBuilder.js +1 -2
  9. package/dist/core/change-family/editBuilder.js.map +1 -1
  10. package/dist/core/change-family/index.d.ts +1 -1
  11. package/dist/core/change-family/index.d.ts.map +1 -1
  12. package/dist/core/change-family/index.js.map +1 -1
  13. package/dist/core/index.d.ts +3 -2
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/core/tree/delta.d.ts +62 -16
  17. package/dist/core/tree/delta.d.ts.map +1 -1
  18. package/dist/core/tree/delta.js.map +1 -1
  19. package/dist/core/tree/detachedFieldIndex.d.ts +7 -13
  20. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  21. package/dist/core/tree/detachedFieldIndex.js +32 -46
  22. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  23. package/dist/core/tree/index.d.ts +1 -0
  24. package/dist/core/tree/index.d.ts.map +1 -1
  25. package/dist/core/tree/index.js.map +1 -1
  26. package/dist/core/tree/visitorUtils.d.ts +2 -4
  27. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  28. package/dist/core/tree/visitorUtils.js +2 -2
  29. package/dist/core/tree/visitorUtils.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 +5 -2
  33. package/dist/entrypoints/alpha.js.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/uniformChunk.js +10 -2
  36. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  37. package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
  38. package/dist/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
  39. package/dist/feature-libraries/comparison-forest/comparisonForest.js +98 -0
  40. package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
  41. package/dist/feature-libraries/comparison-forest/index.d.ts +6 -0
  42. package/dist/feature-libraries/comparison-forest/index.d.ts.map +1 -0
  43. package/dist/feature-libraries/comparison-forest/index.js +10 -0
  44. package/dist/feature-libraries/comparison-forest/index.js.map +1 -0
  45. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
  46. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  47. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
  48. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  49. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  50. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  51. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  52. package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
  53. package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
  54. package/dist/feature-libraries/default-schema/noChangeCodecs.js +3 -1
  55. package/dist/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
  56. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
  57. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  58. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +18 -6
  59. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -3
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  64. package/dist/feature-libraries/index.d.ts +4 -3
  65. package/dist/feature-libraries/index.d.ts.map +1 -1
  66. package/dist/feature-libraries/index.js +77 -72
  67. package/dist/feature-libraries/index.js.map +1 -1
  68. package/dist/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
  69. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  70. package/dist/feature-libraries/mitigatedChangeFamily.js +12 -0
  71. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  72. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
  73. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  74. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  75. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
  76. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  77. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  78. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  79. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  80. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  81. package/dist/feature-libraries/modular-schema/invert.d.ts +15 -0
  82. package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -0
  83. package/dist/feature-libraries/modular-schema/invert.js +159 -0
  84. package/dist/feature-libraries/modular-schema/invert.js.map +1 -0
  85. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
  86. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  87. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
  88. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  89. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
  90. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  91. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
  92. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  93. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
  94. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  95. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  96. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  97. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  98. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  99. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
  100. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  101. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +53 -406
  102. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  103. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
  104. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
  105. package/dist/feature-libraries/modular-schema/modularChangeUtils.js +205 -0
  106. package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
  107. package/dist/feature-libraries/modular-schema/prune.d.ts +10 -0
  108. package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -0
  109. package/dist/feature-libraries/modular-schema/prune.js +49 -0
  110. package/dist/feature-libraries/modular-schema/prune.js.map +1 -0
  111. package/dist/feature-libraries/optional-field/optionalField.js +1 -1
  112. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  113. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
  114. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  115. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  116. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
  117. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  118. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  119. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
  120. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  121. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  122. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
  123. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  124. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  125. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
  126. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  127. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  128. package/dist/feature-libraries/treeTextCursor.d.ts +15 -0
  129. package/dist/feature-libraries/treeTextCursor.d.ts.map +1 -1
  130. package/dist/feature-libraries/treeTextCursor.js +64 -1
  131. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  132. package/dist/index.d.ts +3 -1
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +5 -1
  135. package/dist/index.js.map +1 -1
  136. package/dist/packageVersion.d.ts +1 -1
  137. package/dist/packageVersion.d.ts.map +1 -1
  138. package/dist/packageVersion.js +1 -1
  139. package/dist/packageVersion.js.map +1 -1
  140. package/dist/shared-tree/serializedChange.d.ts +2 -2
  141. package/dist/shared-tree/serializedChange.d.ts.map +1 -1
  142. package/dist/shared-tree/serializedChange.js.map +1 -1
  143. package/dist/shared-tree/sharedTree.d.ts +6 -3
  144. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  145. package/dist/shared-tree/sharedTree.js +8 -6
  146. package/dist/shared-tree/sharedTree.js.map +1 -1
  147. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
  148. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  149. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  150. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
  151. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  152. package/dist/shared-tree/sharedTreeChangeFamily.js +57 -1
  153. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  154. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
  155. package/dist/shared-tree/transactionMinimize.js +2 -2
  156. package/dist/shared-tree/transactionMinimize.js.map +1 -1
  157. package/dist/shared-tree/transactionPostProcessor.d.ts +2 -1
  158. package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -1
  159. package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
  160. package/dist/shared-tree/treeCheckout.d.ts +8 -7
  161. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  162. package/dist/shared-tree/treeCheckout.js +1 -1
  163. package/dist/shared-tree/treeCheckout.js.map +1 -1
  164. package/dist/shared-tree-core/branch.d.ts +23 -9
  165. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  166. package/dist/shared-tree-core/branch.js +7 -0
  167. package/dist/shared-tree-core/branch.js.map +1 -1
  168. package/dist/shared-tree-core/editManager.d.ts +4 -4
  169. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  170. package/dist/shared-tree-core/editManager.js +2 -0
  171. package/dist/shared-tree-core/editManager.js.map +1 -1
  172. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -14
  173. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  174. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  175. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
  176. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  177. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  178. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
  179. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  180. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  181. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
  182. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  183. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  184. package/dist/shared-tree-core/editManagerSummarizer.d.ts +4 -4
  185. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  186. package/dist/shared-tree-core/editManagerSummarizer.js +0 -1
  187. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  188. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  189. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  190. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  191. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  192. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  193. package/dist/shared-tree-core/messageCodecs.d.ts +8 -1
  194. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  195. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  196. package/dist/shared-tree-core/sharedTreeCore.d.ts +5 -5
  197. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  198. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  199. package/dist/shared-tree-core/transaction.d.ts +10 -10
  200. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  201. package/dist/shared-tree-core/transaction.js +6 -3
  202. package/dist/shared-tree-core/transaction.js.map +1 -1
  203. package/dist/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
  204. package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
  205. package/dist/simple-tree/api/eraseSchemaDetails.js +15 -0
  206. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  207. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +21 -2
  208. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  209. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  210. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
  211. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  212. package/dist/simple-tree/node-kinds/map/mapNode.js +9 -0
  213. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  214. package/dist/text/textDomain.d.ts +12 -0
  215. package/dist/text/textDomain.d.ts.map +1 -1
  216. package/dist/text/textDomain.js +37 -16
  217. package/dist/text/textDomain.js.map +1 -1
  218. package/dist/text/textDomainFormatted.d.ts +155 -61
  219. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  220. package/dist/text/textDomainFormatted.js +147 -71
  221. package/dist/text/textDomainFormatted.js.map +1 -1
  222. package/dist/text/textDomainFormattedDefault.d.ts +37 -14
  223. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -1
  224. package/dist/text/textDomainFormattedDefault.js +13 -5
  225. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  226. package/dist/treeDataStore.d.ts +49 -0
  227. package/dist/treeDataStore.d.ts.map +1 -0
  228. package/dist/treeDataStore.js +57 -0
  229. package/dist/treeDataStore.js.map +1 -0
  230. package/dist/treeFactory.d.ts +8 -3
  231. package/dist/treeFactory.d.ts.map +1 -1
  232. package/dist/treeFactory.js +6 -1
  233. package/dist/treeFactory.js.map +1 -1
  234. package/lib/core/change-family/changeFamily.d.ts +15 -4
  235. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  236. package/lib/core/change-family/changeFamily.js.map +1 -1
  237. package/lib/core/change-family/editBuilder.d.ts +2 -3
  238. package/lib/core/change-family/editBuilder.d.ts.map +1 -1
  239. package/lib/core/change-family/editBuilder.js +1 -2
  240. package/lib/core/change-family/editBuilder.js.map +1 -1
  241. package/lib/core/change-family/index.d.ts +1 -1
  242. package/lib/core/change-family/index.d.ts.map +1 -1
  243. package/lib/core/change-family/index.js.map +1 -1
  244. package/lib/core/index.d.ts +3 -2
  245. package/lib/core/index.d.ts.map +1 -1
  246. package/lib/core/index.js +1 -1
  247. package/lib/core/index.js.map +1 -1
  248. package/lib/core/tree/delta.d.ts +62 -16
  249. package/lib/core/tree/delta.d.ts.map +1 -1
  250. package/lib/core/tree/delta.js.map +1 -1
  251. package/lib/core/tree/detachedFieldIndex.d.ts +7 -13
  252. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  253. package/lib/core/tree/detachedFieldIndex.js +7 -21
  254. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  255. package/lib/core/tree/index.d.ts +1 -0
  256. package/lib/core/tree/index.d.ts.map +1 -1
  257. package/lib/core/tree/index.js.map +1 -1
  258. package/lib/core/tree/visitorUtils.d.ts +2 -4
  259. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  260. package/lib/core/tree/visitorUtils.js +2 -2
  261. package/lib/core/tree/visitorUtils.js.map +1 -1
  262. package/lib/entrypoints/alpha.d.ts +1 -1
  263. package/lib/entrypoints/alpha.d.ts.map +1 -1
  264. package/lib/entrypoints/alpha.js +1 -1
  265. package/lib/entrypoints/alpha.js.map +1 -1
  266. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  267. package/lib/feature-libraries/chunked-forest/uniformChunk.js +10 -2
  268. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  269. package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts +51 -0
  270. package/lib/feature-libraries/comparison-forest/comparisonForest.d.ts.map +1 -0
  271. package/lib/feature-libraries/comparison-forest/comparisonForest.js +94 -0
  272. package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -0
  273. package/lib/feature-libraries/comparison-forest/index.d.ts +6 -0
  274. package/lib/feature-libraries/comparison-forest/index.d.ts.map +1 -0
  275. package/lib/feature-libraries/comparison-forest/index.js +6 -0
  276. package/lib/feature-libraries/comparison-forest/index.js.map +1 -0
  277. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +8 -6
  278. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  279. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
  280. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  281. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  282. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  283. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  284. package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts +2 -2
  285. package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
  286. package/lib/feature-libraries/default-schema/noChangeCodecs.js +3 -1
  287. package/lib/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
  288. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +6 -3
  289. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  290. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +16 -4
  291. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  292. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -3
  293. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  294. package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -3
  295. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  296. package/lib/feature-libraries/index.d.ts +4 -3
  297. package/lib/feature-libraries/index.d.ts.map +1 -1
  298. package/lib/feature-libraries/index.js +2 -1
  299. package/lib/feature-libraries/index.js.map +1 -1
  300. package/lib/feature-libraries/mitigatedChangeFamily.d.ts +1 -1
  301. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  302. package/lib/feature-libraries/mitigatedChangeFamily.js +12 -0
  303. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  304. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -1
  305. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  306. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  307. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +2 -2
  308. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  309. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  310. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  311. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  312. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  313. package/lib/feature-libraries/modular-schema/invert.d.ts +15 -0
  314. package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -0
  315. package/lib/feature-libraries/modular-schema/invert.js +155 -0
  316. package/lib/feature-libraries/modular-schema/invert.js.map +1 -0
  317. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +3 -4
  318. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  319. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +2 -2
  320. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  321. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +9 -9
  322. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  323. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +0 -2
  324. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  325. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +2 -2
  326. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  327. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  328. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  329. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  330. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  331. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -22
  332. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  333. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +16 -367
  334. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  335. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +61 -0
  336. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -0
  337. package/lib/feature-libraries/modular-schema/modularChangeUtils.js +192 -0
  338. package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -0
  339. package/lib/feature-libraries/modular-schema/prune.d.ts +10 -0
  340. package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -0
  341. package/lib/feature-libraries/modular-schema/prune.js +45 -0
  342. package/lib/feature-libraries/modular-schema/prune.js.map +1 -0
  343. package/lib/feature-libraries/optional-field/optionalField.js +1 -1
  344. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  345. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +2 -2
  346. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  347. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  348. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +2 -2
  349. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  350. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  351. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +2 -2
  352. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  353. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  354. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +2 -2
  355. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  356. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  357. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +2 -2
  358. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  359. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  360. package/lib/feature-libraries/treeTextCursor.d.ts +15 -0
  361. package/lib/feature-libraries/treeTextCursor.d.ts.map +1 -1
  362. package/lib/feature-libraries/treeTextCursor.js +62 -1
  363. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  364. package/lib/index.d.ts +3 -1
  365. package/lib/index.d.ts.map +1 -1
  366. package/lib/index.js +2 -1
  367. package/lib/index.js.map +1 -1
  368. package/lib/packageVersion.d.ts +1 -1
  369. package/lib/packageVersion.d.ts.map +1 -1
  370. package/lib/packageVersion.js +1 -1
  371. package/lib/packageVersion.js.map +1 -1
  372. package/lib/shared-tree/serializedChange.d.ts +2 -2
  373. package/lib/shared-tree/serializedChange.d.ts.map +1 -1
  374. package/lib/shared-tree/serializedChange.js.map +1 -1
  375. package/lib/shared-tree/sharedTree.d.ts +6 -3
  376. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  377. package/lib/shared-tree/sharedTree.js +9 -7
  378. package/lib/shared-tree/sharedTree.js.map +1 -1
  379. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +2 -2
  380. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  381. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  382. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +41 -4
  383. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  384. package/lib/shared-tree/sharedTreeChangeFamily.js +55 -0
  385. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  386. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
  387. package/lib/shared-tree/transactionMinimize.js +3 -3
  388. package/lib/shared-tree/transactionMinimize.js.map +1 -1
  389. package/lib/shared-tree/transactionPostProcessor.d.ts +2 -1
  390. package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -1
  391. package/lib/shared-tree/transactionPostProcessor.js.map +1 -1
  392. package/lib/shared-tree/treeCheckout.d.ts +8 -7
  393. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  394. package/lib/shared-tree/treeCheckout.js +1 -1
  395. package/lib/shared-tree/treeCheckout.js.map +1 -1
  396. package/lib/shared-tree-core/branch.d.ts +23 -9
  397. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  398. package/lib/shared-tree-core/branch.js +7 -0
  399. package/lib/shared-tree-core/branch.js.map +1 -1
  400. package/lib/shared-tree-core/editManager.d.ts +4 -4
  401. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  402. package/lib/shared-tree-core/editManager.js +2 -0
  403. package/lib/shared-tree-core/editManager.js.map +1 -1
  404. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -14
  405. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  406. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  407. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +11 -1
  408. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  409. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  410. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +4 -11
  411. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  412. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  413. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  414. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +4 -11
  415. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  416. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  417. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  418. package/lib/shared-tree-core/editManagerSummarizer.d.ts +4 -4
  419. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  420. package/lib/shared-tree-core/editManagerSummarizer.js +0 -1
  421. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  422. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  423. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  424. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  425. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  426. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  427. package/lib/shared-tree-core/messageCodecs.d.ts +8 -1
  428. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  429. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  430. package/lib/shared-tree-core/sharedTreeCore.d.ts +5 -5
  431. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  432. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  433. package/lib/shared-tree-core/transaction.d.ts +10 -10
  434. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  435. package/lib/shared-tree-core/transaction.js +6 -3
  436. package/lib/shared-tree-core/transaction.js.map +1 -1
  437. package/lib/simple-tree/api/eraseSchemaDetails.d.ts +15 -0
  438. package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
  439. package/lib/simple-tree/api/eraseSchemaDetails.js +15 -0
  440. package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  441. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +21 -2
  442. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  443. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  444. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +13 -0
  445. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  446. package/lib/simple-tree/node-kinds/map/mapNode.js +9 -0
  447. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  448. package/lib/text/textDomain.d.ts +12 -0
  449. package/lib/text/textDomain.d.ts.map +1 -1
  450. package/lib/text/textDomain.js +34 -15
  451. package/lib/text/textDomain.js.map +1 -1
  452. package/lib/text/textDomainFormatted.d.ts +155 -61
  453. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  454. package/lib/text/textDomainFormatted.js +148 -73
  455. package/lib/text/textDomainFormatted.js.map +1 -1
  456. package/lib/text/textDomainFormattedDefault.d.ts +37 -14
  457. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -1
  458. package/lib/text/textDomainFormattedDefault.js +14 -6
  459. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  460. package/lib/treeDataStore.d.ts +49 -0
  461. package/lib/treeDataStore.d.ts.map +1 -0
  462. package/lib/treeDataStore.js +52 -0
  463. package/lib/treeDataStore.js.map +1 -0
  464. package/lib/treeFactory.d.ts +8 -3
  465. package/lib/treeFactory.d.ts.map +1 -1
  466. package/lib/treeFactory.js +5 -0
  467. package/lib/treeFactory.js.map +1 -1
  468. package/package.json +25 -24
  469. package/src/core/change-family/changeFamily.ts +32 -4
  470. package/src/core/change-family/editBuilder.ts +1 -2
  471. package/src/core/change-family/index.ts +2 -0
  472. package/src/core/index.ts +9 -6
  473. package/src/core/tree/delta.ts +62 -16
  474. package/src/core/tree/detachedFieldIndex.ts +7 -38
  475. package/src/core/tree/index.ts +2 -0
  476. package/src/core/tree/visitorUtils.ts +3 -17
  477. package/src/entrypoints/alpha.ts +7 -3
  478. package/src/feature-libraries/chunked-forest/uniformChunk.ts +11 -1
  479. package/src/feature-libraries/comparison-forest/comparisonForest.ts +140 -0
  480. package/src/feature-libraries/comparison-forest/index.ts +6 -0
  481. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +20 -6
  482. package/src/feature-libraries/default-schema/index.ts +1 -0
  483. package/src/feature-libraries/default-schema/noChangeCodecs.ts +11 -3
  484. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +33 -5
  485. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -3
  486. package/src/feature-libraries/index.ts +5 -0
  487. package/src/feature-libraries/mitigatedChangeFamily.ts +21 -3
  488. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -1
  489. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +9 -4
  490. package/src/feature-libraries/modular-schema/index.ts +1 -0
  491. package/src/feature-libraries/modular-schema/invert.ts +338 -0
  492. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +3 -5
  493. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +16 -13
  494. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +3 -1
  495. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +2 -1
  496. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +45 -644
  497. package/src/feature-libraries/modular-schema/modularChangeUtils.ts +340 -0
  498. package/src/feature-libraries/modular-schema/prune.ts +69 -0
  499. package/src/feature-libraries/optional-field/optionalField.ts +1 -1
  500. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +4 -2
  501. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -2
  502. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +4 -2
  503. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
  504. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +6 -3
  505. package/src/feature-libraries/treeTextCursor.ts +66 -1
  506. package/src/index.ts +4 -0
  507. package/src/packageVersion.ts +1 -1
  508. package/src/shared-tree/serializedChange.ts +2 -2
  509. package/src/shared-tree/sharedTree.ts +34 -14
  510. package/src/shared-tree/sharedTreeChangeCodecs.ts +11 -3
  511. package/src/shared-tree/sharedTreeChangeFamily.ts +77 -2
  512. package/src/shared-tree/transactionMinimize.ts +7 -3
  513. package/src/shared-tree/transactionPostProcessor.ts +5 -1
  514. package/src/shared-tree/treeCheckout.ts +55 -16
  515. package/src/shared-tree-core/branch.ts +40 -12
  516. package/src/shared-tree-core/editManager.ts +46 -25
  517. package/src/shared-tree-core/editManagerCodecs.ts +9 -21
  518. package/src/shared-tree-core/editManagerCodecsCommons.ts +14 -2
  519. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +18 -21
  520. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +18 -20
  521. package/src/shared-tree-core/editManagerSummarizer.ts +9 -6
  522. package/src/shared-tree-core/messageCodecV1ToV4.ts +3 -3
  523. package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -2
  524. package/src/shared-tree-core/messageCodecs.ts +12 -2
  525. package/src/shared-tree-core/sharedTreeCore.ts +15 -6
  526. package/src/shared-tree-core/transaction.ts +47 -25
  527. package/src/simple-tree/api/eraseSchemaDetails.ts +15 -0
  528. package/src/simple-tree/node-kinds/array/arrayNode.ts +21 -2
  529. package/src/simple-tree/node-kinds/map/mapNode.ts +24 -2
  530. package/src/text/textDomain.ts +29 -6
  531. package/src/text/textDomainFormatted.ts +351 -134
  532. package/src/text/textDomainFormattedDefault.ts +25 -16
  533. package/src/treeDataStore.ts +125 -0
  534. package/src/treeFactory.ts +11 -3
@@ -0,0 +1,338 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
+ import {
8
+ revisionMetadataSourceFromInfo,
9
+ type ChangeAtomId,
10
+ type ChangesetLocalId,
11
+ type FieldKindIdentifier,
12
+ type RevisionInfo,
13
+ type RevisionMetadataSource,
14
+ type RevisionTag,
15
+ type TaggedChange,
16
+ type TreeChunk,
17
+ } from "../../core/index.js";
18
+ import { brand, idAllocatorFromMaxId, type IdAllocator } from "../../util/index.js";
19
+ import {
20
+ newChangeAtomIdBTree,
21
+ setInChangeAtomIdMap,
22
+ type ChangeAtomIdBTree,
23
+ } from "../changeAtomIdBTree.js";
24
+ import {
25
+ newCrossFieldKeyTable,
26
+ type CrossFieldKeyTable,
27
+ type FieldChange,
28
+ type FieldChangeMap,
29
+ type FieldId,
30
+ type ModularChangeset,
31
+ type NodeChangeset,
32
+ type NodeId,
33
+ } from "./modularChangeTypes.js";
34
+ import {
35
+ CrossFieldManagerI,
36
+ getChangeHandler,
37
+ getRevInfoFromTaggedChanges,
38
+ hasConflicts,
39
+ makeModularChangeset,
40
+ newConstraintState,
41
+ newCrossFieldTable,
42
+ updateConstraintsForFields,
43
+ type CrossFieldTable,
44
+ } from "./modularChangeUtils.js";
45
+ import type { CrossFieldTarget } from "./crossFieldQueries.js";
46
+ import type { FlexFieldKind } from "./fieldKind.js";
47
+ import { NodeAttachState } from "./fieldChangeHandler.js";
48
+
49
+ /**
50
+ * @param change - The change to invert.
51
+ * @param isRollback - Whether the inverted change is meant to rollback a change on a branch as is the case when
52
+ * performing a sandwich rebase.
53
+ * @param revisionForInvert - The revision for the invert changeset.
54
+ */
55
+ export function invertModularChange(
56
+ change: TaggedChange<ModularChangeset>,
57
+ isRollback: boolean,
58
+ revisionForInvert: RevisionTag,
59
+ fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
60
+ ): ModularChangeset {
61
+ // Rollback changesets destroy the nodes created by the change being rolled back.
62
+ const destroys = isRollback ? invertBuilds(change.change.builds) : undefined;
63
+
64
+ // Destroys only occur in rollback changesets, which are never inverted.
65
+ assert(
66
+ change.change.destroys === undefined,
67
+ 0x89a /* Unexpected destroys in change to invert */,
68
+ );
69
+
70
+ const revInfos: RevisionInfo[] = isRollback
71
+ ? [{ revision: revisionForInvert, rollbackOf: change.revision }]
72
+ : [{ revision: revisionForInvert }];
73
+
74
+ const noChangeConstraint = change.change.noChangeConstraintOnRevert;
75
+ const noChangeConstraintOnRevert = change.change.noChangeConstraint;
76
+
77
+ if (hasConflicts(change.change)) {
78
+ return makeModularChangeset({
79
+ maxId: change.change.maxId as number,
80
+ revisions: revInfos,
81
+ destroys,
82
+ });
83
+ }
84
+
85
+ const genId: IdAllocator = idAllocatorFromMaxId(change.change.maxId ?? -1);
86
+
87
+ const crossFieldTable: InvertTable = {
88
+ ...newCrossFieldTable<FieldChange>(),
89
+ originalFieldToContext: new Map(),
90
+ invertedNodeToParent: brand(change.change.nodeToParent.clone()),
91
+ };
92
+ const { revInfos: oldRevInfos } = getRevInfoFromTaggedChanges([change]);
93
+ const revisionMetadata = revisionMetadataSourceFromInfo(oldRevInfos);
94
+
95
+ const invertedFields = invertFieldMap(
96
+ change.change.fieldChanges,
97
+ undefined,
98
+ isRollback,
99
+ genId,
100
+ crossFieldTable,
101
+ revisionMetadata,
102
+ revisionForInvert,
103
+ fieldKinds,
104
+ );
105
+
106
+ const invertedNodes = newChangeAtomIdBTree<NodeChangeset>();
107
+ change.change.nodeChanges.forEachPair(([revision, localId], nodeChangeset) => {
108
+ invertedNodes.set(
109
+ [revision, localId],
110
+ invertNodeChange(
111
+ nodeChangeset,
112
+ { revision, localId },
113
+ isRollback,
114
+ genId,
115
+ crossFieldTable,
116
+ revisionMetadata,
117
+ revisionForInvert,
118
+ fieldKinds,
119
+ ),
120
+ );
121
+ });
122
+
123
+ if (crossFieldTable.invalidatedFields.size > 0) {
124
+ const fieldsToUpdate = crossFieldTable.invalidatedFields;
125
+ crossFieldTable.invalidatedFields = new Set();
126
+ for (const fieldChange of fieldsToUpdate) {
127
+ const originalFieldChange = fieldChange.change;
128
+ const context = crossFieldTable.originalFieldToContext.get(fieldChange);
129
+ assert(
130
+ context !== undefined,
131
+ 0x851 /* Should have context for every invalidated field */,
132
+ );
133
+ const { invertedField, fieldId } = context;
134
+
135
+ const amendedChange = getChangeHandler(fieldKinds, fieldChange.fieldKind).rebaser.invert(
136
+ originalFieldChange,
137
+ isRollback,
138
+ genId,
139
+ revisionForInvert,
140
+ new InvertManager(crossFieldTable, fieldChange, fieldId),
141
+ revisionMetadata,
142
+ );
143
+ invertedField.change = brand(amendedChange);
144
+ }
145
+ }
146
+
147
+ const crossFieldKeys = makeCrossFieldKeyTable(invertedFields, invertedNodes, fieldKinds);
148
+
149
+ const constraintState = newConstraintState(0);
150
+ updateConstraintsForFields(
151
+ invertedFields,
152
+ NodeAttachState.Attached,
153
+ constraintState,
154
+ invertedNodes,
155
+ fieldKinds,
156
+ );
157
+
158
+ return makeModularChangeset({
159
+ fieldChanges: invertedFields,
160
+ nodeChanges: invertedNodes,
161
+ nodeToParent: crossFieldTable.invertedNodeToParent,
162
+ nodeAliases: change.change.nodeAliases,
163
+ crossFieldKeys,
164
+ maxId: genId.getMaxId(),
165
+ revisions: revInfos,
166
+ constraintViolationCount: constraintState.violationCount,
167
+ noChangeConstraint,
168
+ noChangeConstraintOnRevert,
169
+ destroys,
170
+ });
171
+ }
172
+
173
+ function invertFieldMap(
174
+ changes: FieldChangeMap,
175
+ parentId: NodeId | undefined,
176
+ isRollback: boolean,
177
+ genId: IdAllocator,
178
+ crossFieldTable: InvertTable,
179
+ revisionMetadata: RevisionMetadataSource,
180
+ revisionForInvert: RevisionTag,
181
+ fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
182
+ ): FieldChangeMap {
183
+ const invertedFields: FieldChangeMap = new Map();
184
+
185
+ for (const [field, fieldChange] of changes) {
186
+ const fieldId = { nodeId: parentId, field };
187
+ const manager = new InvertManager(crossFieldTable, fieldChange, fieldId);
188
+ const invertedChange = getChangeHandler(fieldKinds, fieldChange.fieldKind).rebaser.invert(
189
+ fieldChange.change,
190
+ isRollback,
191
+ genId,
192
+ revisionForInvert,
193
+ manager,
194
+ revisionMetadata,
195
+ );
196
+
197
+ const invertedFieldChange: FieldChange = {
198
+ ...fieldChange,
199
+ change: brand(invertedChange),
200
+ };
201
+ invertedFields.set(field, invertedFieldChange);
202
+
203
+ crossFieldTable.originalFieldToContext.set(fieldChange, {
204
+ fieldId,
205
+ invertedField: invertedFieldChange,
206
+ });
207
+ }
208
+
209
+ return invertedFields;
210
+ }
211
+
212
+ function invertNodeChange(
213
+ change: NodeChangeset,
214
+ id: NodeId,
215
+ isRollback: boolean,
216
+ genId: IdAllocator,
217
+ crossFieldTable: InvertTable,
218
+ revisionMetadata: RevisionMetadataSource,
219
+ revisionForInvert: RevisionTag,
220
+ fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
221
+ ): NodeChangeset {
222
+ const inverse: NodeChangeset = {};
223
+
224
+ // If the node has a constraint, it should be inverted to a node-exist-on-revert constraint. This ensure that if
225
+ // the inverse is inverted again, the original input constraint will be restored.
226
+ if (change.nodeExistsConstraint !== undefined) {
227
+ inverse.nodeExistsConstraintOnRevert = change.nodeExistsConstraint;
228
+ }
229
+
230
+ // The node-exist-on-revert constraint of a node is the constraint that should apply when the a change is reverted.
231
+ // So, it should become the constraint in the inverse. If this constraint is violated when applying the inverse,
232
+ // it will be discarded.
233
+ if (change.nodeExistsConstraintOnRevert !== undefined) {
234
+ inverse.nodeExistsConstraint = change.nodeExistsConstraintOnRevert;
235
+ }
236
+
237
+ if (change.fieldChanges !== undefined) {
238
+ inverse.fieldChanges = invertFieldMap(
239
+ change.fieldChanges,
240
+ id,
241
+ isRollback,
242
+ genId,
243
+ crossFieldTable,
244
+ revisionMetadata,
245
+ revisionForInvert,
246
+ fieldKinds,
247
+ );
248
+ }
249
+
250
+ return inverse;
251
+ }
252
+
253
+ function invertBuilds(
254
+ builds: ChangeAtomIdBTree<TreeChunk> | undefined,
255
+ ): ChangeAtomIdBTree<number> | undefined {
256
+ if (builds !== undefined) {
257
+ return brand(builds.mapValues((chunk) => chunk.topLevelLength));
258
+ }
259
+ return undefined;
260
+ }
261
+
262
+ interface InvertTable extends CrossFieldTable<FieldChange> {
263
+ originalFieldToContext: Map<FieldChange, InvertContext>;
264
+ invertedNodeToParent: ChangeAtomIdBTree<FieldId>;
265
+ }
266
+
267
+ interface InvertContext {
268
+ fieldId: FieldId;
269
+ invertedField: FieldChange;
270
+ }
271
+
272
+ class InvertManager extends CrossFieldManagerI<FieldChange> {
273
+ public constructor(
274
+ table: InvertTable,
275
+ field: FieldChange,
276
+ private readonly fieldId: FieldId,
277
+ allowInval = true,
278
+ ) {
279
+ super(table, field, allowInval);
280
+ }
281
+
282
+ public override onMoveIn(id: ChangeAtomId): void {
283
+ setInChangeAtomIdMap(this.table.invertedNodeToParent, id, this.fieldId);
284
+ }
285
+
286
+ public override moveKey(
287
+ target: CrossFieldTarget,
288
+ revision: RevisionTag | undefined,
289
+ id: ChangesetLocalId,
290
+ count: number,
291
+ ): void {
292
+ assert(false, 0x9c5 /* Keys should not be moved manually during invert */);
293
+ }
294
+
295
+ private get table(): InvertTable {
296
+ return this.crossFieldTable as InvertTable;
297
+ }
298
+ }
299
+
300
+ function makeCrossFieldKeyTable(
301
+ fields: FieldChangeMap,
302
+ nodes: ChangeAtomIdBTree<NodeChangeset>,
303
+ fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
304
+ ): CrossFieldKeyTable {
305
+ const keys: CrossFieldKeyTable = newCrossFieldKeyTable();
306
+ populateCrossFieldKeyTableForFieldMap(keys, fields, undefined, fieldKinds);
307
+ nodes.forEachPair(([revision, localId], node) => {
308
+ if (node.fieldChanges !== undefined) {
309
+ populateCrossFieldKeyTableForFieldMap(
310
+ keys,
311
+ node.fieldChanges,
312
+ {
313
+ revision,
314
+ localId,
315
+ },
316
+ fieldKinds,
317
+ );
318
+ }
319
+ });
320
+
321
+ return keys;
322
+ }
323
+
324
+ function populateCrossFieldKeyTableForFieldMap(
325
+ table: CrossFieldKeyTable,
326
+ fields: FieldChangeMap,
327
+ parent: NodeId | undefined,
328
+ fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
329
+ ): void {
330
+ for (const [fieldKey, fieldChange] of fields) {
331
+ const keys = getChangeHandler(fieldKinds, fieldChange.fieldKind).getCrossFieldKeys(
332
+ fieldChange.change,
333
+ );
334
+ for (const { key, count } of keys) {
335
+ table.set(key, count, { nodeId: parent, field: fieldKey });
336
+ }
337
+ }
338
+ }
@@ -3,9 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { FieldKindIdentifier } from "../../core/index.js";
7
-
8
- import type { FlexFieldKind } from "./fieldKind.js";
6
+ import type { ModularChangeFamily } from "./modularChangeFamily.js";
9
7
  import type { ModularChangeset } from "./modularChangeTypes.js";
10
8
 
11
9
  /**
@@ -22,11 +20,11 @@ import type { ModularChangeset } from "./modularChangeTypes.js";
22
20
  * future change.
23
21
  *
24
22
  * @param change - The change to minimize.
25
- * @param fieldKinds - The field kinds to delegate to when computing the change's delta.
23
+ * @param changeFamily - The change family used to compute the change's delta and identify built nodes.
26
24
  */
27
25
  export function minimizeModularChangeset(
28
26
  change: ModularChangeset,
29
- fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
27
+ changeFamily: ModularChangeFamily,
30
28
  ): ModularChangeset {
31
29
  // TODO: Actually minimize the change. For now this is a no-op that returns the change unchanged.
32
30
  return change;
@@ -16,6 +16,7 @@ import {
16
16
  } from "../../codec/index.js";
17
17
  import type {
18
18
  ChangeEncodingContext,
19
+ ChangeDecodingContext,
19
20
  ChangesetLocalId,
20
21
  EncodedRevisionTag,
21
22
  FieldKey,
@@ -42,7 +43,11 @@ import {
42
43
  } from "../chunked-forest/index.js";
43
44
  import { TreeCompressionStrategy } from "../treeCompressionUtils.js";
44
45
 
45
- import type { FieldChangeEncodingContext, FieldChangeHandler } from "./fieldChangeHandler.js";
46
+ import type {
47
+ FieldChangeEncodingContext,
48
+ FieldChangeDecodingContext,
49
+ FieldChangeHandler,
50
+ } from "./fieldChangeHandler.js";
46
51
  import type {
47
52
  FieldKindConfiguration,
48
53
  FieldKindConfigurationEntry,
@@ -71,14 +76,16 @@ type ModularChangeCodec = IJsonCodec<
71
76
  ModularChangeset,
72
77
  EncodedModularChangesetV1,
73
78
  EncodedModularChangesetV1,
74
- ChangeEncodingContext
79
+ ChangeEncodingContext,
80
+ ChangeDecodingContext
75
81
  >;
76
82
 
77
83
  type FieldCodec = IJsonCodec<
78
84
  FieldChangeset,
79
85
  JsonCompatibleReadOnly,
80
86
  JsonCompatibleReadOnly,
81
- FieldChangeEncodingContext
87
+ FieldChangeEncodingContext,
88
+ FieldChangeDecodingContext
82
89
  >;
83
90
 
84
91
  type FieldChangesetCodecs = Map<
@@ -115,8 +122,6 @@ export function encodeFieldChangesForJson(
115
122
  assert(node !== undefined, 0x92e /* Unknown node ID */);
116
123
  return encodeNodeChangesForJson(node, fieldContext, fieldChangesetCodecs);
117
124
  },
118
-
119
- decodeNode: () => fail(0xb1e /* Should not decode nodes during field encoding */),
120
125
  };
121
126
 
122
127
  return encodeFieldChangesForJsonI(change, fieldContext, fieldChangesetCodecs);
@@ -180,7 +185,7 @@ export function decodeFieldChangesFromJson(
180
185
  encodedChange: EncodedFieldChangeMap,
181
186
  parentId: NodeId | undefined,
182
187
  decoded: ModularChangeset,
183
- context: ChangeEncodingContext,
188
+ context: ChangeDecodingContext,
184
189
  idAllocator: IdAllocator,
185
190
  fieldKinds: FieldKindConfiguration,
186
191
  fieldChangesetCodecs: FieldChangesetCodecs,
@@ -200,11 +205,9 @@ export function decodeFieldChangesFromJson(
200
205
  field: field.fieldKey,
201
206
  };
202
207
 
203
- const fieldContext: FieldChangeEncodingContext = {
208
+ const fieldContext: FieldChangeDecodingContext = {
204
209
  baseContext: context,
205
210
 
206
- encodeNode: () => fail(0xb21 /* Should not encode nodes during field decoding */),
207
-
208
211
  decodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {
209
212
  const nodeId: NodeId = {
210
213
  revision: context.revision,
@@ -252,7 +255,7 @@ export function decodeNodeChangesetFromJson(
252
255
  encodedChange: EncodedNodeChangeset,
253
256
  id: NodeId,
254
257
  decoded: ModularChangeset,
255
- context: ChangeEncodingContext,
258
+ context: ChangeDecodingContext,
256
259
  idAllocator: IdAllocator,
257
260
  fieldKinds: FieldKindConfiguration,
258
261
  fieldChangesetCodecs: FieldChangesetCodecs,
@@ -337,7 +340,7 @@ export function encodeDetachedNodes(
337
340
 
338
341
  export function decodeDetachedNodes(
339
342
  encoded: EncodedBuilds | undefined,
340
- context: ChangeEncodingContext,
343
+ context: ChangeDecodingContext,
341
344
  revisionTagCodec: JsonCodecPart<
342
345
  RevisionTag,
343
346
  typeof RevisionTagSchema,
@@ -430,7 +433,7 @@ export function encodeRevisionInfos(
430
433
 
431
434
  export function decodeRevisionInfos(
432
435
  revisions: readonly EncodedRevisionInfo[] | undefined,
433
- context: ChangeEncodingContext,
436
+ context: ChangeDecodingContext,
434
437
  revisionTagCodec: JsonCodecPart<
435
438
  RevisionTag,
436
439
  typeof RevisionTagSchema,
@@ -509,7 +512,7 @@ export function encodeChange(
509
512
 
510
513
  export function decodeChange(
511
514
  encodedChange: EncodedModularChangesetV1,
512
- context: ChangeEncodingContext,
515
+ context: ChangeDecodingContext,
513
516
  fieldKinds: FieldKindConfiguration,
514
517
  fieldChangesetCodecs: Map<
515
518
  FieldKindIdentifier,
@@ -11,6 +11,7 @@ import {
11
11
  } from "../../codec/index.js";
12
12
  import type {
13
13
  ChangeEncodingContext,
14
+ ChangeDecodingContext,
14
15
  RevisionTag,
15
16
  RevisionTagSchema,
16
17
  } from "../../core/index.js";
@@ -30,7 +31,8 @@ type ModularChangeCodec = IJsonCodec<
30
31
  ModularChangeset,
31
32
  EncodedModularChangesetV2,
32
33
  EncodedModularChangesetV2,
33
- ChangeEncodingContext
34
+ ChangeEncodingContext,
35
+ ChangeDecodingContext
34
36
  >;
35
37
 
36
38
  export function makeModularChangeCodecV2(
@@ -13,6 +13,7 @@ import {
13
13
  } from "../../codec/index.js";
14
14
  import type {
15
15
  ChangeEncodingContext,
16
+ ChangeDecodingContext,
16
17
  RevisionTag,
17
18
  RevisionTagSchema,
18
19
  } from "../../core/index.js";
@@ -35,7 +36,7 @@ export function makeModularChangeCodecFamily(
35
36
  fieldsCodec: FieldBatchCodec,
36
37
  codecOptions: ICodecOptions,
37
38
  chunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,
38
- ): ICodecFamily<ModularChangeset, ChangeEncodingContext> {
39
+ ): ICodecFamily<ModularChangeset, ChangeEncodingContext, ChangeDecodingContext> {
39
40
  return makeCodecFamily(
40
41
  Array.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => {
41
42
  switch (version) {