@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
@@ -10,14 +10,31 @@ import type { SchemaAndPolicy } from "../../core/index.js";
10
10
  import type { IdentifierHealingConfig, JsonCompatibleReadOnly } from "../../util/index.js";
11
11
  import type { ChangeRebaser, RevisionTag, TaggedChange } from "../rebase/index.js";
12
12
 
13
- export interface ChangeFamily<TEditor extends ChangeFamilyEditor, TChange> {
13
+ export type ProcessChangeFn<TChange, TChangeProcessingContext> =
14
+ TChangeProcessingContext extends never
15
+ ? (change: TChange) => TChange
16
+ : (change: TChange, context: TChangeProcessingContext) => TChange;
17
+
18
+ export interface ChangeFamily<
19
+ TEditor extends ChangeFamilyEditor,
20
+ TChange,
21
+ // For simplicity, may be a concrete ChangeFamily implementation such as
22
+ // ChangeFamilyFoo implements ChangeFamily<EditorFoo, ChangeFoo, ChangeFamilyFoo>
23
+ // to provide all details and helpers that processFn for ChangeFoo
24
+ // may require, but there is no requirement to follow that pattern.
25
+ TChangeProcessingContext = never,
26
+ > {
14
27
  buildEditor(
15
28
  mintRevisionTag: () => RevisionTag,
16
29
  changeReceiver: (change: TaggedChange<TChange>) => void,
17
30
  ): TEditor;
18
31
 
19
32
  readonly rebaser: ChangeRebaser<TChange>;
20
- readonly codecs: ICodecFamily<TChange, ChangeEncodingContext>;
33
+ readonly codecs: ICodecFamily<TChange, ChangeEncodingContext, ChangeDecodingContext>;
34
+
35
+ buildProcessor(
36
+ processFn: ProcessChangeFn<TChange, TChangeProcessingContext>,
37
+ ): (change: TChange) => TChange;
21
38
  }
22
39
 
23
40
  export interface ChangeEncodingContext {
@@ -36,18 +53,29 @@ export interface ChangeEncodingContext {
36
53
  * (possibly broken) attach-summary blob, never when applying ops.
37
54
  */
38
55
  readonly isSummary: boolean;
56
+ }
57
+
58
+ /**
59
+ * Context provided to change codecs when decoding.
60
+ * @remarks
61
+ * The same as {@link ChangeEncodingContext} except that it omits `schema` (only consulted when
62
+ * *encoding*, for schema-aware compression) and adds `healing` (only consulted when *decoding*, to
63
+ * recover unresolvable identifiers from a summary blob).
64
+ */
65
+ export type ChangeDecodingContext = Omit<ChangeEncodingContext, "schema"> & {
39
66
  /**
40
67
  * Heal-on-decode workaround configuration. See {@link IdentifierHealingConfig}.
41
68
  * Only takes effect when `isSummary` is also `true`.
42
69
  */
43
70
  readonly healing?: IdentifierHealingConfig;
44
- }
71
+ };
45
72
 
46
73
  export type ChangeFamilyCodec<TChange> = IJsonCodec<
47
74
  TChange,
48
75
  JsonCompatibleReadOnly,
49
76
  JsonCompatibleReadOnly,
50
- ChangeEncodingContext
77
+ ChangeEncodingContext,
78
+ ChangeDecodingContext
51
79
  >;
52
80
 
53
81
  export interface ChangeFamilyEditor {
@@ -5,11 +5,10 @@
5
5
 
6
6
  import type { TaggedChange } from "../rebase/index.js";
7
7
 
8
- import type { ChangeFamily, ChangeFamilyEditor } from "./changeFamily.js";
8
+ import type { ChangeFamilyEditor } from "./changeFamily.js";
9
9
 
10
10
  export abstract class EditBuilder<TChange> implements ChangeFamilyEditor {
11
11
  public constructor(
12
- protected readonly changeFamily: ChangeFamily<ChangeFamilyEditor, TChange>,
13
12
  private readonly changeReceiver: (change: TaggedChange<TChange>) => void,
14
13
  ) {}
15
14
 
@@ -7,6 +7,8 @@ export type {
7
7
  ChangeFamily,
8
8
  ChangeFamilyEditor,
9
9
  ChangeEncodingContext,
10
+ ChangeDecodingContext,
10
11
  ChangeFamilyCodec,
12
+ ProcessChangeFn,
11
13
  } from "./changeFamily.js";
12
14
  export { EditBuilder } from "./editBuilder.js";
package/src/core/index.ts CHANGED
@@ -83,6 +83,7 @@ export {
83
83
  CursorMarker,
84
84
  isCursor,
85
85
  DetachedFieldIndex,
86
+ type DetachedFieldSummaryData,
86
87
  type ReadOnlyDetachedFieldIndex,
87
88
  type DetachedFieldIndexCheckpoint,
88
89
  type ForestRootId,
@@ -160,13 +161,15 @@ export {
160
161
  SchemaFormatVersion,
161
162
  } from "./schema-stored/index.js";
162
163
 
163
- export {
164
- type ChangeFamily,
165
- type ChangeFamilyCodec,
166
- type ChangeEncodingContext,
167
- type ChangeFamilyEditor,
168
- EditBuilder,
164
+ export type {
165
+ ChangeFamily,
166
+ ChangeFamilyCodec,
167
+ ChangeEncodingContext,
168
+ ChangeDecodingContext,
169
+ ChangeFamilyEditor,
170
+ ProcessChangeFn,
169
171
  } from "./change-family/index.js";
172
+ export { EditBuilder } from "./change-family/index.js";
170
173
 
171
174
  export {
172
175
  areEqualChangeAtomIds,
@@ -67,7 +67,7 @@ import type { TreeChunk } from "./chunk.js";
67
67
  */
68
68
 
69
69
  /**
70
- * Represents the change made to a document.
70
+ * A change made to a document.
71
71
  * Immutable, therefore safe to retain for async processing.
72
72
  */
73
73
  export interface Root<TTrees = ProtoNodes> {
@@ -122,20 +122,50 @@ export interface Root<TTrees = ProtoNodes> {
122
122
  export type ProtoNodes = TreeChunk;
123
123
 
124
124
  /**
125
- * Represents a change being made to a part of the document tree.
125
+ * A change to a contiguous range of a field,
126
+ * including nested changes described by {@link Mark.fields}.
127
+ *
128
+ * @remarks
129
+ * See {@link FieldChanges} for how these marks are applied to a field.
130
+ *
131
+ * The presence of {@link Mark.attach} and {@link Mark.detach} determines the kind of change:
132
+ *
133
+ * - Retain (neither `attach` nor `detach` are set): retains `count` existing nodes.
134
+ * When `count` is `1`, `fields` may describe nested changes to the retained node.
135
+ * - Detach (`detach` only): removes `count` existing nodes.
136
+ * When `count` is `1`, `fields` may describe nested changes to the detached node.
137
+ * - Attach (`attach` only): inserts `count` new nodes.
138
+ * `fields` must be undefined.
139
+ * - Replace (both `attach` and `detach`): replaces `count` existing nodes with `count` attached
140
+ * nodes.
141
+ * When `count` is `1`, `fields` may describe nested changes to the detached node.
126
142
  */
127
143
  export interface Mark {
128
144
  /**
129
- * The number of nodes affected.
130
- * When `isAttachMark(mark)` is true, this is the number of new nodes being attached.
131
- * When `isAttachMark(mark)` is false, this the number of existing nodes affected.
132
- * Must be 1 when `fields` is populated.
145
+ * The number of existing nodes affected, attached nodes added, or both, according to the
146
+ * combination of {@link Mark.attach} and {@link Mark.detach}.
147
+ * Must be `1` when {@link Mark.fields} is populated.
148
+ * @remarks
149
+ * The size of the attached content is never inferred from what is attached: it must be exactly `count`.
150
+ * This means that a single mark can represent replacing a run of `count` nodes with `count` new nodes,
151
+ * but cannot replace a run of one length with a run of another length.
152
+ * Such edits require multiple marks.
153
+ *
154
+ * Must be a positive integer.
155
+ * Marks with a count of `0` are no-ops and should be omitted from {@link FieldChanges}.
133
156
  */
134
157
  readonly count: number;
135
158
 
136
159
  /**
137
- * Modifications to the pre-existing content.
138
- * Must be undefined when `attach` is set but `detach` is not.
160
+ * Nested changes to pre-existing content.
161
+ * @remarks
162
+ * If {@link Mark.detach} is set, these changes apply to the node being detached.
163
+ * Otherwise, they apply to the retained node.
164
+ *
165
+ * May only be set when this mark applies to exactly one pre-existing node.
166
+ * Therefore, `fields` must be undefined if:
167
+ * - {@link Mark.attach} is set and {@link Mark.detach} is not: in this case there are no pre-existing nodes.
168
+ * - {@link Mark.count} is not 1: in this case there is not exactly one node to modify.
139
169
  */
140
170
  readonly fields?: FieldMap;
141
171
 
@@ -154,54 +184,70 @@ export interface Mark {
154
184
  * A globally unique ID for a node in a detached field.
155
185
  */
156
186
  export interface DetachedNodeId {
187
+ /** Revision in which the ID was allocated, if applicable. */
157
188
  readonly major?: RevisionTag;
189
+ /** Identifier within the scope of {@link DetachedNodeId.major}. */
158
190
  readonly minor: number;
159
191
  }
160
192
 
161
193
  export type FieldMap = ReadonlyMap<FieldKey, FieldChanges>;
162
194
 
163
195
  /**
164
- * Represents changes made to a detached node
196
+ * Changes made to a detached node.
165
197
  */
166
198
  export interface DetachedNodeChanges {
199
+ /** ID of the detached node to modify. */
167
200
  readonly id: DetachedNodeId;
201
+ /** Changes to the node's fields. */
168
202
  readonly fields: FieldMap;
169
203
  }
170
204
 
171
205
  /**
172
- * Represents the creation of detached nodes.
206
+ * The creation of detached nodes.
173
207
  *
174
208
  * Tree creation is idempotent: if a tree with the same ID already exists,
175
209
  * then this build is ignored in favor of the existing tree.
176
210
  */
177
211
  export interface DetachedNodeBuild<TTrees = ProtoNodes> {
212
+ /** ID assigned to the first node in {@link DetachedNodeBuild.trees}. */
178
213
  readonly id: DetachedNodeId;
214
+ /** Nodes to create, assigned consecutive IDs by incrementing {@link DetachedNodeId.minor}. */
179
215
  readonly trees: TTrees;
180
216
  }
181
217
 
182
218
  /**
183
- * Represents the destruction of detached nodes
219
+ * The destruction of detached nodes.
184
220
  */
185
221
  export interface DetachedNodeDestruction {
222
+ /** ID of the first detached node to destroy. */
186
223
  readonly id: DetachedNodeId;
224
+ /** Number of consecutively identified nodes to destroy. */
187
225
  readonly count: number;
188
226
  }
189
227
 
190
228
  /**
191
- * Represents a detached node being assigned a new `DetachedNodeId`.
229
+ * A detached node being assigned a new `DetachedNodeId`.
192
230
  */
193
231
  export interface DetachedNodeRename {
232
+ /** Number of consecutively identified nodes to rename. */
194
233
  readonly count: number;
234
+ /** Current ID of the first node. */
195
235
  readonly oldId: DetachedNodeId;
236
+ /** New ID for the first node. */
196
237
  readonly newId: DetachedNodeId;
197
238
  }
198
239
 
199
240
  export interface FieldChanges {
200
241
  /**
201
- * Represents a list of changes to the nodes in the field.
202
- * The index of each mark within the range of nodes, before
203
- * applying any of the changes, is not represented explicitly.
204
- * It corresponds to the sum of `mark.count` values for all previous marks for which `isAttachMark(mark)` is false.
242
+ * A list of changes to the nodes in the field.
243
+ * @remarks
244
+ * This includes changes to the field's nodes and nested changes to those nodes' fields.
245
+ *
246
+ * The index at which each mark applies is implicit. Marks are applied in order, advancing the
247
+ * index according to the kind of {@link Mark} and its {@link Mark.count}.
248
+ *
249
+ * Because this describes changes rather than content, untouched nodes after the final mark are
250
+ * implicitly retained. This is equivalent to a trailing retain mark with the relevant count.
205
251
  */
206
252
  readonly marks: readonly Mark[];
207
253
  }
@@ -4,17 +4,8 @@
4
4
  */
5
5
 
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
- import type { IIdCompressor } from "@fluidframework/id-compressor";
8
-
9
- import {
10
- type CodecWriteOptions,
11
- FluidClientVersion,
12
- FormatValidatorNoOp,
13
- type IJsonCodec,
14
- } from "../../codec/index.js";
15
7
  import {
16
8
  type IdAllocator,
17
- type JsonCompatibleReadOnly,
18
9
  type NestedMap,
19
10
  brand,
20
11
  deleteFromNestedMap,
@@ -24,11 +15,10 @@ import {
24
15
  setInNestedMap,
25
16
  tryGetFromNestedMap,
26
17
  } from "../../util/index.js";
27
- import type { RevisionTag, RevisionTagCodec } from "../rebase/index.js";
18
+ import type { RevisionTag } from "../rebase/index.js";
28
19
  import type { FieldKey } from "../schema-stored/index.js";
29
20
 
30
21
  import type * as Delta from "./delta.js";
31
- import { detachedFieldIndexCodecBuilder } from "./detachedFieldIndexCodecs.js";
32
22
  import type {
33
23
  DetachedField,
34
24
  DetachedFieldSummaryData,
@@ -92,9 +82,6 @@ export class DetachedFieldIndex implements ReadOnlyDetachedFieldIndex {
92
82
  Delta.DetachedNodeId
93
83
  > = new Map();
94
84
 
95
- private readonly codec: IJsonCodec<DetachedFieldSummaryData>;
96
- private readonly options: CodecWriteOptions;
97
-
98
85
  /**
99
86
  * The process for loading `DetachedFieldIndex` data from a summary is split into two steps:
100
87
  * 1. Call {@link loadData}
@@ -112,28 +99,12 @@ export class DetachedFieldIndex implements ReadOnlyDetachedFieldIndex {
112
99
  public constructor(
113
100
  private readonly name: string,
114
101
  private rootIdAllocator: IdAllocator<ForestRootId>,
115
- private readonly revisionTagCodec: RevisionTagCodec,
116
- private readonly idCompressor: IIdCompressor,
117
- options?: CodecWriteOptions,
118
- ) {
119
- this.options = options ?? {
120
- jsonValidator: FormatValidatorNoOp,
121
- minVersionForCollab: FluidClientVersion.v2_0,
122
- };
123
- this.codec = detachedFieldIndexCodecBuilder.build({
124
- ...this.options,
125
- revisionTagCodec,
126
- idCompressor,
127
- });
128
- }
102
+ ) {}
129
103
 
130
104
  public clone(): DetachedFieldIndex {
131
105
  const clone = new DetachedFieldIndex(
132
106
  this.name,
133
107
  idAllocatorFromMaxId(this.rootIdAllocator.getMaxId()) as IdAllocator<ForestRootId>,
134
- this.revisionTagCodec,
135
- this.idCompressor,
136
- this.options,
137
108
  );
138
109
  populateNestedMap(this.detachedNodeToField, clone.detachedNodeToField, true);
139
110
  populateNestedMap(
@@ -307,19 +278,17 @@ export class DetachedFieldIndex implements ReadOnlyDetachedFieldIndex {
307
278
  });
308
279
  }
309
280
 
310
- public encode(): JsonCompatibleReadOnly {
311
- return this.codec.encode({
281
+ public getSummaryData(): DetachedFieldSummaryData {
282
+ return {
312
283
  data: this.detachedNodeToField,
313
284
  maxId: this.rootIdAllocator.getMaxId(),
314
- });
285
+ };
315
286
  }
316
287
 
317
288
  /**
318
- * Loads the tree index from the given string, this overrides any existing data.
289
+ * Loads the tree index from summary data, this overrides any existing data.
319
290
  */
320
- public loadData(data: JsonCompatibleReadOnly): void {
321
- const detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data);
322
-
291
+ public loadData(detachedFieldIndex: DetachedFieldSummaryData): void {
323
292
  this.rootIdAllocator = idAllocatorFromMaxId(
324
293
  detachedFieldIndex.maxId,
325
294
  ) as IdAllocator<ForestRootId>;
@@ -127,6 +127,8 @@ export {
127
127
  type ReadOnlyDetachedFieldIndex,
128
128
  } from "./detachedFieldIndex.js";
129
129
 
130
+ export { type DetachedFieldSummaryData } from "./detachedFieldIndexTypes.js";
131
+
130
132
  export { detachedFieldIndexCodecBuilder } from "./detachedFieldIndexCodecs.js";
131
133
  export { DetachedFieldIndexFormatVersion } from "./detachedFieldIndexFormatCommon.js";
132
134
  export { type FormatV1 } from "./detachedFieldIndexFormatV1.js";
@@ -3,11 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { IIdCompressor } from "@fluidframework/id-compressor";
7
-
8
- import type { CodecWriteOptions } from "../../codec/index.js";
9
6
  import { type IdAllocator, idAllocatorFromMaxId } from "../../util/index.js";
10
- import type { RevisionTag, RevisionTagCodec } from "../rebase/index.js";
7
+ import type { RevisionTag } from "../rebase/index.js";
11
8
  import type { FieldKey } from "../schema-stored/index.js";
12
9
 
13
10
  import type { ITreeCursorSynchronous } from "./cursor.js";
@@ -17,19 +14,8 @@ import type { ForestRootId } from "./detachedFieldIndexTypes.js";
17
14
  import type { PlaceIndex, Range } from "./pathTree.js";
18
15
  import { type DeltaVisitor, visitDelta } from "./visitDelta.js";
19
16
 
20
- export function makeDetachedFieldIndex(
21
- prefix: string = "Temp",
22
- revisionTagCodec: RevisionTagCodec,
23
- idCompressor: IIdCompressor,
24
- options?: CodecWriteOptions,
25
- ): DetachedFieldIndex {
26
- return new DetachedFieldIndex(
27
- prefix,
28
- idAllocatorFromMaxId() as IdAllocator<ForestRootId>,
29
- revisionTagCodec,
30
- idCompressor,
31
- options,
32
- );
17
+ export function makeDetachedFieldIndex(prefix: string = "Temp"): DetachedFieldIndex {
18
+ return new DetachedFieldIndex(prefix, idAllocatorFromMaxId() as IdAllocator<ForestRootId>);
33
19
  }
34
20
 
35
21
  export function applyDelta(
@@ -256,8 +256,9 @@ export {
256
256
  SchemaFactoryAlpha,
257
257
  SchemaStaticsAlpha,
258
258
  SchemaType,
259
- SharedTreeFormatOptions,
260
- SharedTreeOptions,
259
+ SharedTreeAlpha,
260
+ SharedTreeFormatOptions,
261
+ SharedTreeOptions,
261
262
  SimpleAllowedTypeAttributes,
262
263
  SimpleArrayNodeSchema,
263
264
  SimpleFieldSchema,
@@ -283,6 +284,7 @@ export {
283
284
  TreeChangeEventsAlpha,
284
285
  TreeCompressionStrategy,
285
286
  TreeContextAlpha,
287
+ TreeDataStoreOptions,
286
288
  TreeIdentifierUtils,
287
289
  TreeMapNodeAlpha,
288
290
  TreeParsingOptions,
@@ -321,12 +323,14 @@ export {
321
323
  incrementalSummaryHint,
322
324
  independentInitializedView,
323
325
  independentView,
326
+ instantiateTreeFirstTime,
324
327
  minimize,
325
328
  normalizeAllowedTypes,
326
329
  persistedToSimpleSchema,
327
330
  replaceConciseTreeHandles,
328
331
  replaceHandles,
329
332
  replaceVerboseTreeHandles,
330
- trackDirtyNodes
333
+ trackDirtyNodes,
334
+ defineTreeDataStore
331
335
  // #endregion
332
336
  } from "../index.js";
@@ -191,6 +191,17 @@ export class TreeShape {
191
191
  }
192
192
 
193
193
  public equals(other: TreeShape): boolean {
194
+ // Shapes are commonly shared (e.g. all chunks from one chunker reference the same instance), so
195
+ // short-circuit on reference identity to avoid the full structural walk in the common case.
196
+ if (this === other) {
197
+ return true;
198
+ }
199
+
200
+ // A given type usually only has one shape, so check it next to speed up the false case.
201
+ if (this.type !== other.type) {
202
+ return false;
203
+ }
204
+
194
205
  // TODO: either dedupe instances and/or store a collision resistant hash for fast compare.
195
206
 
196
207
  if (
@@ -203,7 +214,6 @@ export class TreeShape {
203
214
  return false;
204
215
  }
205
216
  return (
206
- this.type === other.type &&
207
217
  this.hasValue === other.hasValue &&
208
218
  this.mayContainCompressedIds === other.mayContainCompressedIds
209
219
  );
@@ -0,0 +1,140 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { Listenable } from "@fluidframework/core-interfaces";
7
+
8
+ import {
9
+ type Anchor,
10
+ type AnchorSet,
11
+ type AnnouncedVisitor,
12
+ type DeltaVisitor,
13
+ type FieldAnchor,
14
+ type ForestEvents,
15
+ type IEditableForest,
16
+ type ITreeCursorSynchronous,
17
+ type ITreeSubscriptionCursor,
18
+ type TreeChunk,
19
+ type TreeNavigationResult,
20
+ type TreeStoredSchemaSubscription,
21
+ type UpPath,
22
+ combineVisitors,
23
+ createAnnouncedVisitor,
24
+ } from "../../core/index.js";
25
+ import type { Breakable } from "../../util/index.js";
26
+
27
+ import { assertForestsEqual } from "../treeTextCursor.js";
28
+
29
+ /**
30
+ * An {@link IEditableForest} which wraps two other forests: a `main` forest and a `reference` forest.
31
+ *
32
+ * @remarks
33
+ * All read operations are delegated to `main`, so from the outside a `ComparisonForest` behaves exactly like its `main` forest.
34
+ *
35
+ * When a delta is applied (via {@link IEditableForest.acquireVisitor}), the delta is applied to both `main` and `reference`.
36
+ * Once the visitor is freed, the full contents of both forests (including all detached/removed fields) are compared,
37
+ * and an error is thrown if they differ.
38
+ *
39
+ * This is a testing/debugging aid: it allows validating that a forest implementation (for example the optimized `ChunkedForest`)
40
+ * produces the same results as a simpler reference implementation (for example the `ObjectForest`) for every delta that is applied.
41
+ *
42
+ * @privateRemarks
43
+ * This forest is intentionally expensive: it maintains two full copies of the data and re-reads and
44
+ * structurally compares all of their contents after every delta.
45
+ */
46
+ export class ComparisonForest implements IEditableForest {
47
+ /**
48
+ * @param main - The forest whose behavior is under test.
49
+ * All reads are delegated to this forest, and it is the source of truth for anchors and events.
50
+ * @param reference - The forest to compare against.
51
+ * This forest receives all the same deltas as `main`, and its contents are asserted to match `main` after each delta.
52
+ */
53
+ public constructor(
54
+ public readonly main: IEditableForest,
55
+ public readonly reference: IEditableForest,
56
+ ) {
57
+ this.assertValid();
58
+ }
59
+
60
+ private assertValid(): void {
61
+ assertForestsEqual(this.main, this.reference);
62
+ }
63
+
64
+ public get events(): Listenable<ForestEvents> {
65
+ return this.main.events;
66
+ }
67
+
68
+ public get anchors(): AnchorSet {
69
+ return this.main.anchors;
70
+ }
71
+
72
+ public get isEmpty(): boolean {
73
+ return this.main.isEmpty;
74
+ }
75
+
76
+ public clone(schema: TreeStoredSchemaSubscription, breaker?: Breakable): ComparisonForest {
77
+ this.assertValid();
78
+ return new ComparisonForest(
79
+ this.main.clone(schema, breaker),
80
+ this.reference.clone(schema, breaker),
81
+ );
82
+ }
83
+
84
+ public chunkField(cursor: ITreeCursorSynchronous): TreeChunk[] {
85
+ return this.main.chunkField(cursor);
86
+ }
87
+
88
+ public allocateCursor(source?: string): ITreeSubscriptionCursor {
89
+ // Currently we just use the cursor from "main", but we could use "reference" or a custom cursor ensuring both match in behavior.
90
+ // TODO: Add a custom combined cursor type which validates two cursors match, and use it here.
91
+ return this.main.allocateCursor(source);
92
+ }
93
+
94
+ public forgetAnchor(anchor: Anchor): void {
95
+ this.main.forgetAnchor(anchor);
96
+ }
97
+
98
+ public tryMoveCursorToNode(
99
+ destination: Anchor,
100
+ cursorToMove: ITreeSubscriptionCursor,
101
+ ): TreeNavigationResult {
102
+ return this.main.tryMoveCursorToNode(destination, cursorToMove);
103
+ }
104
+
105
+ public tryMoveCursorToField(
106
+ destination: FieldAnchor,
107
+ cursorToMove: ITreeSubscriptionCursor,
108
+ ): TreeNavigationResult {
109
+ return this.main.tryMoveCursorToField(destination, cursorToMove);
110
+ }
111
+
112
+ public moveCursorToPath(destination: UpPath, cursorToMove: ITreeSubscriptionCursor): void {
113
+ this.main.moveCursorToPath(destination, cursorToMove);
114
+ }
115
+
116
+ public getCursorAboveDetachedFields(): ITreeCursorSynchronous {
117
+ return this.main.getCursorAboveDetachedFields();
118
+ }
119
+
120
+ public registerAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {
121
+ this.main.registerAnnouncedVisitor(visitor);
122
+ }
123
+
124
+ public deregisterAnnouncedVisitor(visitor: () => AnnouncedVisitor): void {
125
+ this.main.deregisterAnnouncedVisitor(visitor);
126
+ }
127
+
128
+ public acquireVisitor(): DeltaVisitor {
129
+ this.assertValid();
130
+ const main = this.main;
131
+ const reference = this.reference;
132
+ const mainVisitor = main.acquireVisitor();
133
+ const referenceVisitor = reference.acquireVisitor();
134
+ // A visitor which does nothing except assert the two forests match once the delta has been fully applied to both.
135
+ const comparisonVisitor = createAnnouncedVisitor({
136
+ free: () => this.assertValid(),
137
+ });
138
+ return combineVisitors([mainVisitor, referenceVisitor, comparisonVisitor]);
139
+ }
140
+ }
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export { ComparisonForest } from "./comparisonForest.js";