@fluidframework/tree 2.116.0 → 2.117.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 (362) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/api-report/tree.alpha.api.md +78 -30
  3. package/api-report/tree.beta.api.md +12 -9
  4. package/api-report/tree.legacy.beta.api.md +12 -9
  5. package/dist/codec/codec.d.ts +18 -0
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +18 -0
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/core/index.d.ts +2 -2
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +3 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/rebase/index.d.ts +1 -1
  14. package/dist/core/rebase/index.d.ts.map +1 -1
  15. package/dist/core/rebase/index.js +2 -1
  16. package/dist/core/rebase/index.js.map +1 -1
  17. package/dist/core/rebase/types.d.ts +39 -2
  18. package/dist/core/rebase/types.d.ts.map +1 -1
  19. package/dist/core/rebase/types.js +37 -2
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/rebase/utils.d.ts.map +1 -1
  22. package/dist/core/rebase/utils.js +1 -0
  23. package/dist/core/rebase/utils.js.map +1 -1
  24. package/dist/core/revertible.d.ts +62 -6
  25. package/dist/core/revertible.d.ts.map +1 -1
  26. package/dist/core/revertible.js.map +1 -1
  27. package/dist/entrypoints/alpha.d.ts +1 -1
  28. package/dist/entrypoints/alpha.d.ts.map +1 -1
  29. package/dist/entrypoints/alpha.js.map +1 -1
  30. package/dist/entrypoints/beta.d.ts +1 -1
  31. package/dist/entrypoints/beta.d.ts.map +1 -1
  32. package/dist/entrypoints/beta.js.map +1 -1
  33. package/dist/entrypoints/legacy.d.ts +1 -1
  34. package/dist/entrypoints/legacy.d.ts.map +1 -1
  35. package/dist/entrypoints/legacy.js.map +1 -1
  36. package/dist/feature-libraries/indexing/types.d.ts +1 -1
  37. package/dist/feature-libraries/indexing/types.js.map +1 -1
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/shared-tree/history.d.ts +22 -0
  45. package/dist/shared-tree/history.d.ts.map +1 -0
  46. package/dist/shared-tree/history.js +66 -0
  47. package/dist/shared-tree/history.js.map +1 -0
  48. package/dist/shared-tree/schematizingTreeView.d.ts +12 -7
  49. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  50. package/dist/shared-tree/schematizingTreeView.js +13 -0
  51. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  52. package/dist/shared-tree/sharedTree.d.ts +3 -2
  53. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  54. package/dist/shared-tree/sharedTree.js +2 -0
  55. package/dist/shared-tree/sharedTree.js.map +1 -1
  56. package/dist/shared-tree/tree.js +1 -1
  57. package/dist/shared-tree/tree.js.map +1 -1
  58. package/dist/shared-tree/treeAlpha.d.ts +8 -20
  59. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  60. package/dist/shared-tree/treeAlpha.js +9 -12
  61. package/dist/shared-tree/treeAlpha.js.map +1 -1
  62. package/dist/shared-tree/treeCheckout.d.ts +16 -9
  63. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  64. package/dist/shared-tree/treeCheckout.js +130 -33
  65. package/dist/shared-tree/treeCheckout.js.map +1 -1
  66. package/dist/shared-tree/unhydratedTreeContext.d.ts +3 -2
  67. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  68. package/dist/shared-tree/unhydratedTreeContext.js +3 -0
  69. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  70. package/dist/shared-tree-core/branch.d.ts +16 -2
  71. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  72. package/dist/shared-tree-core/branch.js +20 -2
  73. package/dist/shared-tree-core/branch.js.map +1 -1
  74. package/dist/shared-tree-core/branchCommitCounter.d.ts +31 -0
  75. package/dist/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
  76. package/dist/shared-tree-core/branchCommitCounter.js +79 -0
  77. package/dist/shared-tree-core/branchCommitCounter.js.map +1 -0
  78. package/dist/shared-tree-core/customMetadataCodec.d.ts +9 -0
  79. package/dist/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
  80. package/dist/shared-tree-core/customMetadataCodec.js +37 -0
  81. package/dist/shared-tree-core/customMetadataCodec.js.map +1 -0
  82. package/dist/shared-tree-core/customMetadataFormat.d.ts +18 -0
  83. package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
  84. package/dist/shared-tree-core/customMetadataFormat.js +15 -0
  85. package/dist/shared-tree-core/customMetadataFormat.js.map +1 -0
  86. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  87. package/dist/shared-tree-core/editManager.js +15 -3
  88. package/dist/shared-tree-core/editManager.js.map +1 -1
  89. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  90. package/dist/shared-tree-core/editManagerCodecs.js +5 -0
  91. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  92. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  93. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  94. package/dist/shared-tree-core/editManagerCodecsCommons.js +17 -5
  95. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  96. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  97. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
  98. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  99. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  100. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  101. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  102. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
  103. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  104. package/dist/shared-tree-core/editManagerFormatCommons.js +18 -8
  105. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  106. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
  107. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  108. package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -3
  109. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  110. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
  111. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  112. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
  113. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  114. package/dist/shared-tree-core/index.d.ts +2 -1
  115. package/dist/shared-tree-core/index.d.ts.map +1 -1
  116. package/dist/shared-tree-core/index.js +3 -1
  117. package/dist/shared-tree-core/index.js.map +1 -1
  118. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  119. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  120. package/dist/shared-tree-core/messageCodecV1ToV4.js +12 -3
  121. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  122. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  123. package/dist/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  124. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  125. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  126. package/dist/shared-tree-core/messageCodecs.js +5 -0
  127. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  128. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  129. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  130. package/dist/shared-tree-core/messageFormat.js +6 -0
  131. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  132. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
  133. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  134. package/dist/shared-tree-core/messageFormatV1ToV4.js +10 -2
  135. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  136. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
  137. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  138. package/dist/shared-tree-core/messageFormatVSharedBranches.js +2 -0
  139. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  140. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  141. package/dist/shared-tree-core/sharedTreeCore.js +4 -2
  142. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  143. package/dist/shared-tree-core/transaction.d.ts +9 -0
  144. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  145. package/dist/shared-tree-core/transaction.js +26 -4
  146. package/dist/shared-tree-core/transaction.js.map +1 -1
  147. package/dist/simple-tree/api/index.d.ts +1 -1
  148. package/dist/simple-tree/api/index.d.ts.map +1 -1
  149. package/dist/simple-tree/api/index.js.map +1 -1
  150. package/dist/simple-tree/api/transactionTypes.d.ts +28 -2
  151. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  152. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  153. package/dist/simple-tree/api/tree.d.ts +180 -61
  154. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  155. package/dist/simple-tree/api/tree.js.map +1 -1
  156. package/dist/simple-tree/index.d.ts +1 -1
  157. package/dist/simple-tree/index.d.ts.map +1 -1
  158. package/dist/simple-tree/index.js.map +1 -1
  159. package/dist/tableSchema.js +10 -10
  160. package/dist/tableSchema.js.map +1 -1
  161. package/lib/codec/codec.d.ts +18 -0
  162. package/lib/codec/codec.d.ts.map +1 -1
  163. package/lib/codec/codec.js +18 -0
  164. package/lib/codec/codec.js.map +1 -1
  165. package/lib/core/index.d.ts +2 -2
  166. package/lib/core/index.d.ts.map +1 -1
  167. package/lib/core/index.js +1 -1
  168. package/lib/core/index.js.map +1 -1
  169. package/lib/core/rebase/index.d.ts +1 -1
  170. package/lib/core/rebase/index.d.ts.map +1 -1
  171. package/lib/core/rebase/index.js +1 -1
  172. package/lib/core/rebase/index.js.map +1 -1
  173. package/lib/core/rebase/types.d.ts +39 -2
  174. package/lib/core/rebase/types.d.ts.map +1 -1
  175. package/lib/core/rebase/types.js +35 -1
  176. package/lib/core/rebase/types.js.map +1 -1
  177. package/lib/core/rebase/utils.d.ts.map +1 -1
  178. package/lib/core/rebase/utils.js +1 -0
  179. package/lib/core/rebase/utils.js.map +1 -1
  180. package/lib/core/revertible.d.ts +62 -6
  181. package/lib/core/revertible.d.ts.map +1 -1
  182. package/lib/core/revertible.js.map +1 -1
  183. package/lib/entrypoints/alpha.d.ts +1 -1
  184. package/lib/entrypoints/alpha.d.ts.map +1 -1
  185. package/lib/entrypoints/alpha.js.map +1 -1
  186. package/lib/entrypoints/beta.d.ts +1 -1
  187. package/lib/entrypoints/beta.d.ts.map +1 -1
  188. package/lib/entrypoints/beta.js.map +1 -1
  189. package/lib/entrypoints/legacy.d.ts +1 -1
  190. package/lib/entrypoints/legacy.d.ts.map +1 -1
  191. package/lib/entrypoints/legacy.js.map +1 -1
  192. package/lib/feature-libraries/indexing/types.d.ts +1 -1
  193. package/lib/feature-libraries/indexing/types.js.map +1 -1
  194. package/lib/index.d.ts +2 -2
  195. package/lib/index.d.ts.map +1 -1
  196. package/lib/index.js.map +1 -1
  197. package/lib/packageVersion.d.ts +1 -1
  198. package/lib/packageVersion.js +1 -1
  199. package/lib/packageVersion.js.map +1 -1
  200. package/lib/shared-tree/history.d.ts +22 -0
  201. package/lib/shared-tree/history.d.ts.map +1 -0
  202. package/lib/shared-tree/history.js +62 -0
  203. package/lib/shared-tree/history.js.map +1 -0
  204. package/lib/shared-tree/schematizingTreeView.d.ts +12 -7
  205. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  206. package/lib/shared-tree/schematizingTreeView.js +13 -0
  207. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  208. package/lib/shared-tree/sharedTree.d.ts +3 -2
  209. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  210. package/lib/shared-tree/sharedTree.js +2 -0
  211. package/lib/shared-tree/sharedTree.js.map +1 -1
  212. package/lib/shared-tree/tree.js +1 -1
  213. package/lib/shared-tree/tree.js.map +1 -1
  214. package/lib/shared-tree/treeAlpha.d.ts +8 -20
  215. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  216. package/lib/shared-tree/treeAlpha.js +9 -12
  217. package/lib/shared-tree/treeAlpha.js.map +1 -1
  218. package/lib/shared-tree/treeCheckout.d.ts +16 -9
  219. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  220. package/lib/shared-tree/treeCheckout.js +131 -34
  221. package/lib/shared-tree/treeCheckout.js.map +1 -1
  222. package/lib/shared-tree/unhydratedTreeContext.d.ts +3 -2
  223. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  224. package/lib/shared-tree/unhydratedTreeContext.js +3 -0
  225. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  226. package/lib/shared-tree-core/branch.d.ts +16 -2
  227. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  228. package/lib/shared-tree-core/branch.js +20 -2
  229. package/lib/shared-tree-core/branch.js.map +1 -1
  230. package/lib/shared-tree-core/branchCommitCounter.d.ts +31 -0
  231. package/lib/shared-tree-core/branchCommitCounter.d.ts.map +1 -0
  232. package/lib/shared-tree-core/branchCommitCounter.js +75 -0
  233. package/lib/shared-tree-core/branchCommitCounter.js.map +1 -0
  234. package/lib/shared-tree-core/customMetadataCodec.d.ts +9 -0
  235. package/lib/shared-tree-core/customMetadataCodec.d.ts.map +1 -0
  236. package/lib/shared-tree-core/customMetadataCodec.js +32 -0
  237. package/lib/shared-tree-core/customMetadataCodec.js.map +1 -0
  238. package/lib/shared-tree-core/customMetadataFormat.d.ts +18 -0
  239. package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -0
  240. package/lib/shared-tree-core/customMetadataFormat.js +11 -0
  241. package/lib/shared-tree-core/customMetadataFormat.js.map +1 -0
  242. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  243. package/lib/shared-tree-core/editManager.js +16 -4
  244. package/lib/shared-tree-core/editManager.js.map +1 -1
  245. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  246. package/lib/shared-tree-core/editManagerCodecs.js +5 -0
  247. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  248. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  249. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  250. package/lib/shared-tree-core/editManagerCodecsCommons.js +17 -5
  251. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  252. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  253. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +4 -2
  254. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  255. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  256. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  257. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  258. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +17 -6
  259. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  260. package/lib/shared-tree-core/editManagerFormatCommons.js +18 -8
  261. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  262. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +7 -5
  263. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  264. package/lib/shared-tree-core/editManagerFormatV1toV4.js +4 -3
  265. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  266. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +4 -0
  267. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  268. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +2 -2
  269. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  270. package/lib/shared-tree-core/index.d.ts +2 -1
  271. package/lib/shared-tree-core/index.d.ts.map +1 -1
  272. package/lib/shared-tree-core/index.js +1 -0
  273. package/lib/shared-tree-core/index.js.map +1 -1
  274. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -2
  275. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  276. package/lib/shared-tree-core/messageCodecV1ToV4.js +12 -3
  277. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  278. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  279. package/lib/shared-tree-core/messageCodecVSharedBranches.js +8 -2
  280. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  281. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  282. package/lib/shared-tree-core/messageCodecs.js +5 -0
  283. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  284. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  285. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  286. package/lib/shared-tree-core/messageFormat.js +6 -0
  287. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  288. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +10 -3
  289. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  290. package/lib/shared-tree-core/messageFormatV1ToV4.js +10 -2
  291. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  292. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -0
  293. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  294. package/lib/shared-tree-core/messageFormatVSharedBranches.js +2 -0
  295. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  296. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  297. package/lib/shared-tree-core/sharedTreeCore.js +5 -3
  298. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  299. package/lib/shared-tree-core/transaction.d.ts +9 -0
  300. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  301. package/lib/shared-tree-core/transaction.js +27 -5
  302. package/lib/shared-tree-core/transaction.js.map +1 -1
  303. package/lib/simple-tree/api/index.d.ts +1 -1
  304. package/lib/simple-tree/api/index.d.ts.map +1 -1
  305. package/lib/simple-tree/api/index.js.map +1 -1
  306. package/lib/simple-tree/api/transactionTypes.d.ts +28 -2
  307. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  308. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  309. package/lib/simple-tree/api/tree.d.ts +180 -61
  310. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  311. package/lib/simple-tree/api/tree.js.map +1 -1
  312. package/lib/simple-tree/index.d.ts +1 -1
  313. package/lib/simple-tree/index.d.ts.map +1 -1
  314. package/lib/simple-tree/index.js.map +1 -1
  315. package/lib/tableSchema.js +10 -10
  316. package/lib/tableSchema.js.map +1 -1
  317. package/package.json +23 -23
  318. package/src/codec/codec.ts +19 -0
  319. package/src/core/index.ts +4 -0
  320. package/src/core/rebase/index.ts +2 -0
  321. package/src/core/rebase/types.ts +72 -2
  322. package/src/core/rebase/utils.ts +1 -0
  323. package/src/core/revertible.ts +67 -6
  324. package/src/entrypoints/alpha.ts +8 -0
  325. package/src/entrypoints/beta.ts +1 -0
  326. package/src/entrypoints/legacy.ts +1 -0
  327. package/src/feature-libraries/indexing/types.ts +1 -1
  328. package/src/index.ts +8 -0
  329. package/src/packageVersion.ts +1 -1
  330. package/src/shared-tree/history.ts +99 -0
  331. package/src/shared-tree/schematizingTreeView.ts +25 -8
  332. package/src/shared-tree/sharedTree.ts +5 -2
  333. package/src/shared-tree/tree.ts +1 -1
  334. package/src/shared-tree/treeAlpha.ts +17 -35
  335. package/src/shared-tree/treeCheckout.ts +178 -39
  336. package/src/shared-tree/unhydratedTreeContext.ts +6 -2
  337. package/src/shared-tree-core/branch.ts +34 -2
  338. package/src/shared-tree-core/branchCommitCounter.ts +103 -0
  339. package/src/shared-tree-core/customMetadataCodec.ts +42 -0
  340. package/src/shared-tree-core/customMetadataFormat.ts +39 -0
  341. package/src/shared-tree-core/editManager.ts +22 -3
  342. package/src/shared-tree-core/editManagerCodecs.ts +12 -0
  343. package/src/shared-tree-core/editManagerCodecsCommons.ts +41 -15
  344. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +7 -1
  345. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -0
  346. package/src/shared-tree-core/editManagerFormatCommons.ts +46 -12
  347. package/src/shared-tree-core/editManagerFormatV1toV4.ts +13 -5
  348. package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +2 -2
  349. package/src/shared-tree-core/index.ts +3 -0
  350. package/src/shared-tree-core/messageCodecV1ToV4.ts +18 -5
  351. package/src/shared-tree-core/messageCodecVSharedBranches.ts +9 -2
  352. package/src/shared-tree-core/messageCodecs.ts +12 -0
  353. package/src/shared-tree-core/messageFormat.ts +6 -0
  354. package/src/shared-tree-core/messageFormatV1ToV4.ts +21 -3
  355. package/src/shared-tree-core/messageFormatVSharedBranches.ts +8 -0
  356. package/src/shared-tree-core/sharedTreeCore.ts +5 -2
  357. package/src/shared-tree-core/transaction.ts +56 -4
  358. package/src/simple-tree/api/index.ts +5 -0
  359. package/src/simple-tree/api/transactionTypes.ts +29 -2
  360. package/src/simple-tree/api/tree.ts +199 -60
  361. package/src/simple-tree/index.ts +5 -0
  362. package/src/tableSchema.ts +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree",
3
- "version": "2.116.0",
3
+ "version": "2.117.0",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -101,17 +101,17 @@
101
101
  "temp-directory": "nyc/.nyc_output"
102
102
  },
103
103
  "dependencies": {
104
- "@fluid-internal/client-utils": "~2.116.0",
105
- "@fluidframework/core-interfaces": "~2.116.0",
106
- "@fluidframework/core-utils": "~2.116.0",
107
- "@fluidframework/datastore-definitions": "~2.116.0",
108
- "@fluidframework/driver-definitions": "~2.116.0",
109
- "@fluidframework/id-compressor": "~2.116.0",
110
- "@fluidframework/runtime-definitions": "~2.116.0",
111
- "@fluidframework/runtime-utils": "~2.116.0",
112
- "@fluidframework/shared-object-base": "~2.116.0",
113
- "@fluidframework/telemetry-utils": "~2.116.0",
114
- "@fluidframework/type-factory": "~2.116.0",
104
+ "@fluid-internal/client-utils": "~2.117.0",
105
+ "@fluidframework/core-interfaces": "~2.117.0",
106
+ "@fluidframework/core-utils": "~2.117.0",
107
+ "@fluidframework/datastore-definitions": "~2.117.0",
108
+ "@fluidframework/driver-definitions": "~2.117.0",
109
+ "@fluidframework/id-compressor": "~2.117.0",
110
+ "@fluidframework/runtime-definitions": "~2.117.0",
111
+ "@fluidframework/runtime-utils": "~2.117.0",
112
+ "@fluidframework/shared-object-base": "~2.117.0",
113
+ "@fluidframework/telemetry-utils": "~2.117.0",
114
+ "@fluidframework/type-factory": "~2.117.0",
115
115
  "@sinclair/typebox": "^0.34.13",
116
116
  "@tylerbu/sorted-btree-es6": "^2.1.1",
117
117
  "semver-ts": "^1.0.3",
@@ -121,22 +121,22 @@
121
121
  "devDependencies": {
122
122
  "@arethetypeswrong/cli": "^0.18.5",
123
123
  "@biomejs/biome": "~2.4.5",
124
- "@fluid-internal/mocha-test-setup": "~2.116.0",
125
- "@fluid-private/stochastic-test-utils": "~2.116.0",
126
- "@fluid-private/test-dds-utils": "~2.116.0",
127
- "@fluid-private/test-drivers": "~2.116.0",
124
+ "@fluid-internal/mocha-test-setup": "~2.117.0",
125
+ "@fluid-private/stochastic-test-utils": "~2.117.0",
126
+ "@fluid-private/test-dds-utils": "~2.117.0",
127
+ "@fluid-private/test-drivers": "~2.117.0",
128
128
  "@fluid-tools/benchmark": "^0.59.0",
129
129
  "@fluid-tools/build-cli": "^0.67.0",
130
130
  "@fluidframework/build-common": "^2.0.3",
131
131
  "@fluidframework/build-tools": "^0.67.0",
132
- "@fluidframework/container-definitions": "~2.116.0",
133
- "@fluidframework/container-loader": "~2.116.0",
134
- "@fluidframework/container-runtime": "~2.116.0",
132
+ "@fluidframework/container-definitions": "~2.117.0",
133
+ "@fluidframework/container-loader": "~2.117.0",
134
+ "@fluidframework/container-runtime": "~2.117.0",
135
135
  "@fluidframework/eslint-config-fluid": "^14.0.0",
136
- "@fluidframework/local-driver": "~2.116.0",
137
- "@fluidframework/test-runtime-utils": "~2.116.0",
138
- "@fluidframework/test-utils": "~2.116.0",
139
- "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.114.0",
136
+ "@fluidframework/local-driver": "~2.117.0",
137
+ "@fluidframework/test-runtime-utils": "~2.117.0",
138
+ "@fluidframework/test-utils": "~2.117.0",
139
+ "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.116.0",
140
140
  "@microsoft/api-extractor": "7.58.1",
141
141
  "@types/diff": "^3.5.1",
142
142
  "@types/easy-table": "^0.0.32",
@@ -540,6 +540,25 @@ export const FluidClientVersion = {
540
540
  * - ModularChangeFormatVersion.v5 - written when minVersionForCollab \>= 2.80
541
541
  */
542
542
  v2_80: "2.80.0",
543
+
544
+ /**
545
+ * Fluid Framework Client 2.117 and newer.
546
+ * @remarks
547
+ * New formats introduced in 2.117:
548
+ * - MessageFormatVersion.v7 - written when minVersionForCollab \>= 2.117
549
+ * - EditManagerFormatVersion.v7 - written when minVersionForCollab \>= 2.117
550
+ *
551
+ * @privateRemarks
552
+ * These formats are gated at 2.117.0 rather than 3.0.0 so that they can also be carried by a
553
+ * 2.117.0 minor cut from the last pre-3.0 commit on main, should one be needed for consumers
554
+ * that cannot yet absorb the 3.0 breaking changes. Since 3.0.0 \> 2.117.0, 3.x clients select
555
+ * these formats for any minVersionForCollab at or above 2.117.0 whether or not that release
556
+ * ever ships.
557
+ *
558
+ * Every client at or above 2.117.0 must therefore be able to read and write these formats. A
559
+ * client that maps 2.117.0 to an older format would silently strip metadata when encoding.
560
+ */
561
+ v2_117: "2.117.0",
543
562
  } as const satisfies Record<string, OldestSupportedClientVersion>;
544
563
 
545
564
  /**
package/src/core/index.ts CHANGED
@@ -188,6 +188,7 @@ export {
188
188
  type RemoteChangeMetadata,
189
189
  type ChangeMetadata,
190
190
  type LabelTree,
191
+ type CustomMetadataTree,
191
192
  type TransactionLabels,
192
193
  type RevisionTag,
193
194
  RevisionTagSchema,
@@ -202,6 +203,7 @@ export {
202
203
  tagRollbackInverse,
203
204
  SessionIdSchema,
204
205
  mintCommit,
206
+ flattenCustomMetadata,
205
207
  rebaseBranch,
206
208
  type BranchRebaseResult,
207
209
  rebaseChange,
@@ -236,4 +238,6 @@ export {
236
238
  type RevertibleFactory,
237
239
  type RevertibleAlphaFactory,
238
240
  type RevertibleAlpha,
241
+ type RevertOptionsAlpha,
242
+ type RevertToOptionsAlpha,
239
243
  } from "./revertible.js";
@@ -9,6 +9,7 @@ export {
9
9
  makeChangeAtomId,
10
10
  asChangeAtomId,
11
11
  mintCommit,
12
+ flattenCustomMetadata,
12
13
  type GraphCommit,
13
14
  CommitKind,
14
15
  type CommitMetadata,
@@ -18,6 +19,7 @@ export {
18
19
  type RemoteChangeMetadata,
19
20
  type ChangeMetadata,
20
21
  type LabelTree,
22
+ type CustomMetadataTree,
21
23
  type TransactionLabels,
22
24
  type RevisionTag,
23
25
  RevisionTagSchema,
@@ -15,6 +15,7 @@ import * as Type from "@sinclair/typebox";
15
15
  import {
16
16
  type Brand,
17
17
  type JsonCompatibleReadOnly,
18
+ type JsonCompatibleReadOnlyObject,
18
19
  type NestedMap,
19
20
  RangeMap,
20
21
  brand,
@@ -166,6 +167,74 @@ export interface GraphCommit<TChange> {
166
167
  readonly change: TChange;
167
168
  /** The parent of this commit, on whose change this commit's change is based */
168
169
  readonly parent?: GraphCommit<TChange>;
170
+ /**
171
+ * Arbitrary, application-defined metadata that is persisted alongside this commit.
172
+ * @remarks
173
+ * Set via {@link RunTransactionParamsAlpha.customMetadata}. This is a tree rather than a single
174
+ * object because a commit may be produced by nested transactions.
175
+ * @privateRemarks
176
+ * Always copy this property when copying a commit.
177
+ */
178
+ readonly customMetadata: CustomMetadataTree | undefined;
179
+ }
180
+
181
+ /**
182
+ * A tree representing the nesting structure of transaction metadata.
183
+ *
184
+ * @remarks
185
+ * Each transaction contributes a node whose {@link CustomMetadataTree.metadata} is its
186
+ * {@link RunTransactionParamsAlpha.customMetadata | metadata} (or `undefined` if none was provided).
187
+ * When transactions are nested, inner transaction nodes become
188
+ * {@link CustomMetadataTree.children | children} of outer ones.
189
+ *
190
+ * @sealed @alpha
191
+ */
192
+ export interface CustomMetadataTree {
193
+ /**
194
+ * The metadata supplied by this transaction, or `undefined` if it supplied none.
195
+ */
196
+ readonly metadata: JsonCompatibleReadOnlyObject | undefined;
197
+
198
+ /**
199
+ * The metadata trees of any nested transactions within this one.
200
+ */
201
+ readonly children: readonly CustomMetadataTree[];
202
+ }
203
+
204
+ /**
205
+ * Flattens a {@link CustomMetadataTree} into a single object.
206
+ * @remarks
207
+ * Where two transactions used the same property, the outermost one wins. Among siblings, the later one
208
+ * wins. Returns `undefined` if no transaction in the tree supplied any metadata.
209
+ */
210
+ export function flattenCustomMetadata(
211
+ tree: CustomMetadataTree | undefined,
212
+ ): JsonCompatibleReadOnlyObject | undefined {
213
+ if (tree === undefined) {
214
+ return undefined;
215
+ }
216
+ let flattened: Record<string, JsonCompatibleReadOnly | undefined> | undefined;
217
+ const visit = (node: CustomMetadataTree): void => {
218
+ // Descendants first, so that a containing transaction's metadata wins on conflict.
219
+ for (const child of node.children) {
220
+ visit(child);
221
+ }
222
+ if (node.metadata !== undefined) {
223
+ flattened ??= {};
224
+ // `defineProperty` rather than assignment: assigning the valid JSON key "__proto__" would
225
+ // invoke the inherited setter and set the prototype instead of creating a property.
226
+ for (const key of Object.keys(node.metadata)) {
227
+ Object.defineProperty(flattened, key, {
228
+ value: node.metadata[key],
229
+ writable: true,
230
+ enumerable: true,
231
+ configurable: true,
232
+ });
233
+ }
234
+ }
235
+ };
236
+ visit(tree);
237
+ return flattened;
169
238
  }
170
239
 
171
240
  /**
@@ -210,7 +279,7 @@ export interface LocalChangeMetadata extends CommitMetadata {
210
279
  /**
211
280
  * Returns a serializable object that encodes the change.
212
281
  * @remarks This is only available for local changes.
213
- * This change object can be {@link TreeBranchAlpha.applyChange | applied to another branch} in the same state as the one which generated it.
282
+ * This change object can be {@link UntypedTreeViewAlpha.applyChange | applied to another view} in the same state as the one which generated it.
214
283
  * The change object must be applied to a SharedTree with the same IdCompressor session ID as it was created from.
215
284
  * @privateRemarks
216
285
  * This is a `SerializedChange` from treeCheckout.ts.
@@ -473,11 +542,12 @@ export function mintCommit<TChange>(
473
542
  parent: GraphCommit<TChange>,
474
543
  commit: Omit<GraphCommit<TChange>, "parent">,
475
544
  ): GraphCommit<TChange> {
476
- const { revision, change } = commit;
545
+ const { revision, change, customMetadata } = commit;
477
546
  return {
478
547
  revision,
479
548
  change,
480
549
  parent,
550
+ customMetadata,
481
551
  };
482
552
  }
483
553
 
@@ -303,6 +303,7 @@ export function rebaseBranch<TChange>(
303
303
  revision: c.revision,
304
304
  change,
305
305
  parent: newHead,
306
+ customMetadata: c.customMetadata,
306
307
  };
307
308
  sourceCommits.push(newHead);
308
309
  editsToCompose.push(tagChange(change, c.revision));
@@ -3,7 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { TreeBranch } from "../simple-tree/index.js";
6
+ import type { JsonCompatibleReadOnlyObject } from "../util/index.js";
7
+
8
+ import type { UntypedTreeView } from "../simple-tree/index.js";
7
9
 
8
10
  /**
9
11
  * Allows reversion of a change made to SharedTree.
@@ -21,6 +23,9 @@ export interface Revertible {
21
23
 
22
24
  /**
23
25
  * Reverts the associated change and disposes it.
26
+ *
27
+ * @remarks
28
+ * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.
24
29
  */
25
30
  revert(): void;
26
31
  /**
@@ -29,6 +34,9 @@ export interface Revertible {
29
34
  * @param dispose - If true, the revertible will be disposed after being reverted.
30
35
  * If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped
31
36
  * due to merge conflicts, and one wants to attempt reverting again.
37
+ *
38
+ * @remarks
39
+ * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.
32
40
  */
33
41
  revert(dispose: boolean): void;
34
42
 
@@ -38,6 +46,43 @@ export interface Revertible {
38
46
  dispose(): void;
39
47
  }
40
48
 
49
+ /**
50
+ * Options for {@link RevertibleAlpha.(revert:3) | RevertibleAlpha.revert}.
51
+ *
52
+ * @sealed @alpha
53
+ */
54
+ export interface RevertOptionsAlpha {
55
+ /**
56
+ * If true (the default), the revertible will be disposed after being reverted.
57
+ * If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped
58
+ * due to merge conflicts, and one wants to attempt reverting again.
59
+ */
60
+ readonly dispose?: boolean;
61
+
62
+ /**
63
+ * Arbitrary, application-defined metadata to attach to the commit that the revert produces.
64
+ *
65
+ * @remarks
66
+ * See {@link RunTransactionParamsAlpha.customMetadata} for how this metadata is persisted and read back.
67
+ */
68
+ readonly customMetadata?: JsonCompatibleReadOnlyObject;
69
+ }
70
+
71
+ /**
72
+ * Options for {@link UntypedTreeViewAlpha.revertTo}.
73
+ *
74
+ * @sealed @alpha
75
+ */
76
+ export interface RevertToOptionsAlpha {
77
+ /**
78
+ * Arbitrary, application-defined metadata to attach to the commit that the revert produces.
79
+ *
80
+ * @remarks
81
+ * See {@link RunTransactionParamsAlpha.customMetadata} for how this metadata is persisted and read back.
82
+ */
83
+ readonly customMetadata?: JsonCompatibleReadOnlyObject;
84
+ }
85
+
41
86
  /**
42
87
  * A {@link Revertible} with features that are not yet stable.
43
88
  *
@@ -45,14 +90,30 @@ export interface Revertible {
45
90
  */
46
91
  export interface RevertibleAlpha extends Revertible {
47
92
  /**
48
- * Clones the {@link Revertible} to a target branch.
93
+ * {@inheritDoc Revertible.(revert:1)}
94
+ */
95
+ revert(): void;
96
+ /**
97
+ * {@inheritDoc Revertible.(revert:2)}
98
+ */
99
+ revert(dispose: boolean): void;
100
+ /**
101
+ * Reverts the associated change according to the given options.
102
+ *
103
+ * @remarks
104
+ * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.
105
+ */
106
+ revert(options: RevertOptionsAlpha): void;
107
+
108
+ /**
109
+ * Clones the {@link Revertible} to a target view.
49
110
  *
50
- * @param branch - A target branch to apply the revertible to.
51
- * The target branch must contain the same commit that this revertible is meant to revert, otherwise will throw an error.
111
+ * @param view - A target view to apply the revertible to.
112
+ * The target view must contain the same commit that this revertible is meant to revert, otherwise will throw an error.
52
113
  * @returns A cloned revertible is independent of the original, meaning disposing of one will not affect the other,
53
- * provided they do not belong to the same branch. Both revertibles can be reverted independently.
114
+ * provided they do not belong to the same view. Both revertibles can be reverted independently.
54
115
  */
55
- clone: (branch: TreeBranch) => RevertibleAlpha;
116
+ clone: (view: UntypedTreeView) => RevertibleAlpha;
56
117
  }
57
118
 
58
119
  /**
@@ -148,6 +148,7 @@ export {
148
148
  UnannotateAllowedTypesList,
149
149
  UnannotateAllowedTypesListUnsafe,
150
150
  UnionToTuple,
151
+ UntypedTreeView,
151
152
  VoidTransactionCallbackStatusBeta,
152
153
  WithValue,
153
154
  adaptEnum,
@@ -179,8 +180,10 @@ export {
179
180
  CodecName,
180
181
  CodecWriteOptions,
181
182
  CommitOutcome,
183
+ CommitRevision,
182
184
  Component,
183
185
  CreateIndependentTreeAlphaOptions,
186
+ CustomMetadataTree,
184
187
  DirtyTreeMap,
185
188
  DirtyTreeStatus,
186
189
  ErasedNode,
@@ -256,6 +259,8 @@ export {
256
259
  RemoteChangeMetadata,
257
260
  RevertibleAlpha,
258
261
  RevertibleAlphaFactory,
262
+ RevertOptionsAlpha,
263
+ RevertToOptionsAlpha,
259
264
  RunTransactionParamsAlpha,
260
265
  SchemaFactoryAlpha,
261
266
  SchemaStaticsAlpha,
@@ -284,7 +289,9 @@ export {
284
289
  TreeAlpha,
285
290
  TreeArrayNodeAlpha,
286
291
  TreeBranchAlpha,
292
+ TreeBranchCommitMetadata,
287
293
  TreeBranchEvents,
294
+ TreeBranchHistory,
288
295
  TreeChangeEventsAlpha,
289
296
  TreeCompressionStrategy,
290
297
  TreeContextAlpha,
@@ -297,6 +304,7 @@ export {
297
304
  TreeViewAlpha,
298
305
  TreeViewConfigurationAlpha,
299
306
  UnsafeUnknownSchema,
307
+ UntypedTreeViewAlpha,
300
308
  ValueSchema,
301
309
  VerboseTree,
302
310
  VerboseTreeNode,
@@ -148,6 +148,7 @@ export {
148
148
  UnannotateAllowedTypesList,
149
149
  UnannotateAllowedTypesListUnsafe,
150
150
  UnionToTuple,
151
+ UntypedTreeView,
151
152
  VoidTransactionCallbackStatusBeta,
152
153
  WithValue,
153
154
  adaptEnum,
@@ -148,6 +148,7 @@ export {
148
148
  UnannotateAllowedTypesList,
149
149
  UnannotateAllowedTypesListUnsafe,
150
150
  UnionToTuple,
151
+ UntypedTreeView,
151
152
  VoidTransactionCallbackStatusBeta,
152
153
  WithValue,
153
154
  adaptEnum,
@@ -15,7 +15,7 @@ export type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];
15
15
  /**
16
16
  * An index allows lookup content from a tree using keys.
17
17
  * @remarks
18
- * The index will be kept up to date with the {@link TreeBranchAlpha} it is associated with.
18
+ * The index will be kept up to date with the {@link UntypedTreeViewAlpha} it is associated with.
19
19
  * Keeping an index up to date incurs overhead.
20
20
  * Therefore, indexes should only be created when needed and disposed when no longer needed.
21
21
  * @privateRemarks
package/src/index.ts CHANGED
@@ -18,10 +18,13 @@ export {
18
18
  type RemoteChangeMetadata,
19
19
  type ChangeMetadata,
20
20
  type LabelTree,
21
+ type CustomMetadataTree,
21
22
  type TransactionLabels,
22
23
  type RevertibleFactory,
23
24
  type RevertibleAlphaFactory,
24
25
  type RevertibleAlpha,
26
+ type RevertOptionsAlpha,
27
+ type RevertToOptionsAlpha,
25
28
  } from "./core/index.js";
26
29
 
27
30
  import type {
@@ -91,6 +94,7 @@ export {
91
94
  } from "./shared-tree/index.js";
92
95
 
93
96
  export {
97
+ type CommitRevision,
94
98
  TreeArrayNode,
95
99
  type TreeArrayNodeAlpha,
96
100
  type Unhydrated,
@@ -269,10 +273,14 @@ export {
269
273
  type ReadonlyArrayNode,
270
274
  type InsertableTreeNodeFromAllowedTypes,
271
275
  type Input,
276
+ type UntypedTreeView,
272
277
  type TreeBranch,
273
278
  type TreeBranchAlpha,
279
+ type UntypedTreeViewAlpha,
274
280
  type TreeBranchEvents,
275
281
  asTreeViewAlpha,
282
+ type TreeBranchCommitMetadata,
283
+ type TreeBranchHistory,
276
284
  type NodeSchemaOptions,
277
285
  type NodeSchemaOptionsAlpha,
278
286
  type NodeSchemaMetadata,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.116.0";
9
+ export const pkgVersion = "2.117.0";
@@ -0,0 +1,99 @@
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 type { IIdCompressor } from "@fluidframework/id-compressor";
8
+
9
+ import type { GraphCommit, CustomMetadataTree } from "../core/index.js";
10
+ import { flattenCustomMetadata } from "../core/index.js";
11
+ import { BranchCommitCounter, type SharedTreeBranch } from "../shared-tree-core/index.js";
12
+ import type { TreeBranchCommitMetadata, TreeBranchHistory } from "../simple-tree/index.js";
13
+ import type { JsonCompatibleReadOnlyObject } from "../util/index.js";
14
+
15
+ import type { SharedTreeChange } from "./sharedTreeChangeTypes.js";
16
+ import type { SharedTreeEditBuilder } from "./sharedTreeEditBuilder.js";
17
+
18
+ /**
19
+ * A lazily constructed implementation of {@link TreeBranchCommitMetadata} that wraps a {@link GraphCommit}.
20
+ */
21
+ class LazyTreeBranchCommitMetadata implements TreeBranchCommitMetadata {
22
+ public readonly revision: string;
23
+ private parentCache?: {
24
+ readonly prior: GraphCommit<SharedTreeChange>;
25
+ readonly cached: TreeBranchCommitMetadata;
26
+ };
27
+
28
+ public constructor(
29
+ private readonly commit: GraphCommit<SharedTreeChange>,
30
+ private readonly idCompressor: IIdCompressor,
31
+ ) {
32
+ assert(
33
+ commit.revision !== "root",
34
+ 0xd34 /* Cannot construct metadata for the root commit */,
35
+ );
36
+ this.revision = idCompressor.decompress(commit.revision);
37
+ }
38
+
39
+ public get custom(): JsonCompatibleReadOnlyObject | undefined {
40
+ return flattenCustomMetadata(this.commit.customMetadata);
41
+ }
42
+
43
+ public get customTree(): CustomMetadataTree | undefined {
44
+ return this.commit.customMetadata;
45
+ }
46
+
47
+ public getParent(): TreeBranchCommitMetadata | undefined {
48
+ // The parent of the commit may change over time due to trunk trimming.
49
+ if (this.commit.parent !== this.parentCache?.prior) {
50
+ const { parent } = this.commit;
51
+ this.parentCache =
52
+ parent === undefined || parent.revision === "root"
53
+ ? undefined
54
+ : {
55
+ prior: parent,
56
+ cached: new LazyTreeBranchCommitMetadata(parent, this.idCompressor),
57
+ };
58
+ }
59
+ return this.parentCache?.cached;
60
+ }
61
+ }
62
+
63
+ /**
64
+ * A default implementation of {@link TreeBranchHistory} that wraps a {@link SharedTreeBranch}.
65
+ */
66
+ export class DefaultTreeBranchHistory implements TreeBranchHistory {
67
+ private readonly commitCounter: BranchCommitCounter<
68
+ SharedTreeEditBuilder,
69
+ SharedTreeChange,
70
+ unknown
71
+ >;
72
+
73
+ public constructor(
74
+ private readonly branch: SharedTreeBranch<
75
+ SharedTreeEditBuilder,
76
+ SharedTreeChange,
77
+ unknown
78
+ >,
79
+ private readonly idCompressor: IIdCompressor,
80
+ ) {
81
+ this.commitCounter = new BranchCommitCounter(branch);
82
+ }
83
+
84
+ public dispose(): void {
85
+ this.commitCounter.dispose();
86
+ }
87
+
88
+ public get length(): number {
89
+ return this.commitCounter.count;
90
+ }
91
+
92
+ public getHead(): TreeBranchCommitMetadata | undefined {
93
+ const head = this.branch.getHead();
94
+ if (head.revision === "root") {
95
+ return undefined;
96
+ }
97
+ return new LazyTreeBranchCommitMetadata(head, this.idCompressor);
98
+ }
99
+ }
@@ -12,7 +12,7 @@ import type {
12
12
  import { assert } from "@fluidframework/core-utils/internal";
13
13
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
14
14
 
15
- import { anchorSlot, rootFieldKey } from "../core/index.js";
15
+ import { anchorSlot, rootFieldKey, type RevertToOptionsAlpha } from "../core/index.js";
16
16
  import {
17
17
  type NodeIdentifierManager,
18
18
  defaultSchemaPolicy,
@@ -58,7 +58,8 @@ import {
58
58
  TreeViewConfigurationAlpha,
59
59
  toInitialSchema,
60
60
  toUpgradeSchema,
61
- type TreeBranchAlpha,
61
+ type TreeBranchHistory,
62
+ type UntypedTreeViewAlpha,
62
63
  type TreeSchema,
63
64
  } from "../simple-tree/index.js";
64
65
  import {
@@ -180,7 +181,11 @@ export class SchematizingSimpleTreeView<
180
181
  );
181
182
  }
182
183
 
183
- public isBranch(): this is TreeBranchAlpha {
184
+ public isBranch(): this is UntypedTreeViewAlpha {
185
+ return this.isView();
186
+ }
187
+
188
+ public isView(): this is UntypedTreeViewAlpha {
184
189
  return true;
185
190
  }
186
191
 
@@ -542,28 +547,40 @@ export class SchematizingSimpleTreeView<
542
547
 
543
548
  // #region Branching
544
549
 
545
- public fork(): ReturnType<TreeBranchAlpha["fork"]> &
550
+ public fork(): ReturnType<UntypedTreeViewAlpha["fork"]> &
546
551
  SchematizingSimpleTreeView<TRootSchema> {
547
552
  return this.checkout.fork().viewWith(this.config);
548
553
  }
549
554
 
550
- public merge(context: TreeBranchAlpha, disposeMerged = true): void {
555
+ public rewindTo(revision: string): void {
556
+ this.checkout.rewindTo(revision);
557
+ }
558
+
559
+ public revertTo(revision: string, options?: RevertToOptionsAlpha): void {
560
+ this.checkout.revertTo(revision, options);
561
+ }
562
+
563
+ public merge(context: UntypedTreeViewAlpha, disposeMerged = true): void {
551
564
  this.checkout.merge(context, disposeMerged);
552
565
  }
553
566
 
554
- public rebaseOnto(context: TreeBranchAlpha): void {
567
+ public rebaseOnto(context: UntypedTreeViewAlpha): void {
555
568
  this.checkout.rebaseOnto(context);
556
569
  }
557
570
 
558
- public isMissingEditsFrom(context: TreeBranchAlpha): boolean {
571
+ public isMissingEditsFrom(context: UntypedTreeViewAlpha): boolean {
559
572
  return this.checkout.isMissingEditsFrom(context);
560
573
  }
561
574
 
562
575
  public computeNetChangeIfRebasedOnto(
563
- context: TreeBranchAlpha,
576
+ context: UntypedTreeViewAlpha,
564
577
  ): JsonCompatibleReadOnly | undefined {
565
578
  return this.checkout.computeNetChangeIfRebasedOnto(context);
566
579
  }
567
580
 
568
581
  // #endregion Branching
582
+
583
+ public get branchHistory(): TreeBranchHistory {
584
+ return this.checkout.branchHistory;
585
+ }
569
586
  }