@fluidframework/tree 2.83.0 → 2.90.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 (412) hide show
  1. package/.vscode/settings.json +6 -5
  2. package/CHANGELOG.md +95 -0
  3. package/README.md +1 -1
  4. package/api-report/tree.alpha.api.md +63 -24
  5. package/api-report/tree.beta.api.md +30 -0
  6. package/api-report/tree.legacy.beta.api.md +30 -0
  7. package/dist/alpha.d.ts +10 -6
  8. package/dist/beta.d.ts +4 -1
  9. package/dist/codec/codec.d.ts +2 -0
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +4 -3
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +1 -1
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -1
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/codec/versioned/codec.d.ts +13 -1
  18. package/dist/codec/versioned/codec.d.ts.map +1 -1
  19. package/dist/codec/versioned/codec.js +18 -3
  20. package/dist/codec/versioned/codec.js.map +1 -1
  21. package/dist/codec/versioned/format.d.ts +22 -1
  22. package/dist/codec/versioned/format.d.ts.map +1 -1
  23. package/dist/codec/versioned/format.js +16 -3
  24. package/dist/codec/versioned/format.js.map +1 -1
  25. package/dist/codec/versioned/index.d.ts +1 -1
  26. package/dist/codec/versioned/index.d.ts.map +1 -1
  27. package/dist/codec/versioned/index.js +2 -1
  28. package/dist/codec/versioned/index.js.map +1 -1
  29. package/dist/core/index.d.ts +1 -2
  30. package/dist/core/index.d.ts.map +1 -1
  31. package/dist/core/index.js +1 -3
  32. package/dist/core/index.js.map +1 -1
  33. package/dist/core/rebase/index.d.ts +1 -1
  34. package/dist/core/rebase/index.d.ts.map +1 -1
  35. package/dist/core/rebase/index.js.map +1 -1
  36. package/dist/core/rebase/types.d.ts +78 -0
  37. package/dist/core/rebase/types.d.ts.map +1 -1
  38. package/dist/core/rebase/types.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
  40. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/codecs.js +22 -44
  42. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/format.js +11 -0
  45. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
  47. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -4
  49. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  51. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/index.js +2 -4
  53. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  54. package/dist/feature-libraries/flex-tree/observer.d.ts +17 -0
  55. package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -1
  56. package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
  57. package/dist/feature-libraries/forest-summary/codec.d.ts +5 -12
  58. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  59. package/dist/feature-libraries/forest-summary/codec.js +33 -33
  60. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  64. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  65. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
  66. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  67. package/dist/feature-libraries/forest-summary/formatCommon.js +13 -11
  68. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  69. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
  70. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  71. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +31 -48
  72. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  73. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  74. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  75. package/dist/feature-libraries/forest-summary/index.js +2 -2
  76. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  77. package/dist/feature-libraries/index.d.ts +3 -3
  78. package/dist/feature-libraries/index.d.ts.map +1 -1
  79. package/dist/feature-libraries/index.js +4 -5
  80. package/dist/feature-libraries/index.js.map +1 -1
  81. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
  82. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  83. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  84. package/dist/feature-libraries/indexing/index.d.ts +1 -1
  85. package/dist/feature-libraries/indexing/index.d.ts.map +1 -1
  86. package/dist/feature-libraries/indexing/index.js.map +1 -1
  87. package/dist/feature-libraries/indexing/types.d.ts +15 -13
  88. package/dist/feature-libraries/indexing/types.d.ts.map +1 -1
  89. package/dist/feature-libraries/indexing/types.js.map +1 -1
  90. package/dist/index.d.ts +3 -3
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +2 -2
  93. package/dist/index.js.map +1 -1
  94. package/dist/legacy.d.ts +4 -1
  95. package/dist/packageVersion.d.ts +1 -1
  96. package/dist/packageVersion.js +1 -1
  97. package/dist/packageVersion.js.map +1 -1
  98. package/dist/shared-tree/independentView.js +2 -2
  99. package/dist/shared-tree/independentView.js.map +1 -1
  100. package/dist/shared-tree/schematizingTreeView.d.ts +5 -0
  101. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  102. package/dist/shared-tree/schematizingTreeView.js +35 -7
  103. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  104. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  105. package/dist/shared-tree/sharedTree.js +7 -7
  106. package/dist/shared-tree/sharedTree.js.map +1 -1
  107. package/dist/shared-tree/tree.js +1 -1
  108. package/dist/shared-tree/tree.js.map +1 -1
  109. package/dist/shared-tree/treeAlpha.d.ts +8 -1
  110. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  111. package/dist/shared-tree/treeAlpha.js +48 -8
  112. package/dist/shared-tree/treeAlpha.js.map +1 -1
  113. package/dist/shared-tree/treeCheckout.d.ts +35 -3
  114. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  115. package/dist/shared-tree/treeCheckout.js +123 -17
  116. package/dist/shared-tree/treeCheckout.js.map +1 -1
  117. package/dist/shared-tree/unhydratedTreeContext.d.ts +20 -0
  118. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
  119. package/dist/shared-tree/unhydratedTreeContext.js +56 -0
  120. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -0
  121. package/dist/shared-tree-core/transaction.d.ts +15 -27
  122. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  123. package/dist/shared-tree-core/transaction.js +7 -11
  124. package/dist/shared-tree-core/transaction.js.map +1 -1
  125. package/dist/simple-tree/api/configuration.d.ts +4 -0
  126. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  127. package/dist/simple-tree/api/configuration.js.map +1 -1
  128. package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
  129. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -1
  130. package/dist/simple-tree/api/identifierIndex.js +1 -1
  131. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  132. package/dist/simple-tree/api/index.d.ts +3 -3
  133. package/dist/simple-tree/api/index.d.ts.map +1 -1
  134. package/dist/simple-tree/api/index.js +2 -2
  135. package/dist/simple-tree/api/index.js.map +1 -1
  136. package/dist/simple-tree/api/schemaFactory.d.ts +3 -2
  137. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  138. package/dist/simple-tree/api/schemaFactory.js +3 -2
  139. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  140. package/dist/simple-tree/api/simpleTreeIndex.d.ts +15 -13
  141. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  142. package/dist/simple-tree/api/simpleTreeIndex.js +4 -4
  143. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  144. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
  145. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  146. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  147. package/dist/simple-tree/api/transactionTypes.d.ts +22 -25
  148. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  149. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  150. package/dist/simple-tree/api/tree.d.ts +69 -132
  151. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  152. package/dist/simple-tree/api/tree.js.map +1 -1
  153. package/dist/simple-tree/index.d.ts +1 -1
  154. package/dist/simple-tree/index.d.ts.map +1 -1
  155. package/dist/simple-tree/index.js +2 -2
  156. package/dist/simple-tree/index.js.map +1 -1
  157. package/dist/text/textDomain.d.ts +27 -9
  158. package/dist/text/textDomain.d.ts.map +1 -1
  159. package/dist/text/textDomain.js +43 -7
  160. package/dist/text/textDomain.js.map +1 -1
  161. package/dist/text/textDomainFormatted.d.ts +14 -8
  162. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  163. package/dist/text/textDomainFormatted.js +97 -25
  164. package/dist/text/textDomainFormatted.js.map +1 -1
  165. package/dist/util/rangeMap.d.ts +1 -0
  166. package/dist/util/rangeMap.d.ts.map +1 -1
  167. package/dist/util/rangeMap.js +5 -6
  168. package/dist/util/rangeMap.js.map +1 -1
  169. package/lib/alpha.d.ts +10 -6
  170. package/lib/beta.d.ts +4 -1
  171. package/lib/codec/codec.d.ts +2 -0
  172. package/lib/codec/codec.d.ts.map +1 -1
  173. package/lib/codec/codec.js +4 -3
  174. package/lib/codec/codec.js.map +1 -1
  175. package/lib/codec/index.d.ts +1 -1
  176. package/lib/codec/index.d.ts.map +1 -1
  177. package/lib/codec/index.js +1 -1
  178. package/lib/codec/index.js.map +1 -1
  179. package/lib/codec/versioned/codec.d.ts +13 -1
  180. package/lib/codec/versioned/codec.d.ts.map +1 -1
  181. package/lib/codec/versioned/codec.js +18 -3
  182. package/lib/codec/versioned/codec.js.map +1 -1
  183. package/lib/codec/versioned/format.d.ts +22 -1
  184. package/lib/codec/versioned/format.d.ts.map +1 -1
  185. package/lib/codec/versioned/format.js +15 -2
  186. package/lib/codec/versioned/format.js.map +1 -1
  187. package/lib/codec/versioned/index.d.ts +1 -1
  188. package/lib/codec/versioned/index.d.ts.map +1 -1
  189. package/lib/codec/versioned/index.js +1 -1
  190. package/lib/codec/versioned/index.js.map +1 -1
  191. package/lib/core/index.d.ts +1 -2
  192. package/lib/core/index.d.ts.map +1 -1
  193. package/lib/core/index.js +0 -1
  194. package/lib/core/index.js.map +1 -1
  195. package/lib/core/rebase/index.d.ts +1 -1
  196. package/lib/core/rebase/index.d.ts.map +1 -1
  197. package/lib/core/rebase/index.js.map +1 -1
  198. package/lib/core/rebase/types.d.ts +78 -0
  199. package/lib/core/rebase/types.d.ts.map +1 -1
  200. package/lib/core/rebase/types.js.map +1 -1
  201. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +8 -7
  202. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  203. package/lib/feature-libraries/chunked-forest/codec/codecs.js +25 -45
  204. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  205. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  206. package/lib/feature-libraries/chunked-forest/codec/format.js +11 -0
  207. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  208. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +3 -2
  209. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  210. package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
  211. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  212. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  213. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  214. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  215. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  216. package/lib/feature-libraries/flex-tree/observer.d.ts +17 -0
  217. package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -1
  218. package/lib/feature-libraries/flex-tree/observer.js.map +1 -1
  219. package/lib/feature-libraries/forest-summary/codec.d.ts +5 -12
  220. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  221. package/lib/feature-libraries/forest-summary/codec.js +35 -32
  222. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  223. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  224. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  225. package/lib/feature-libraries/forest-summary/forestSummarizer.js +7 -8
  226. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  227. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +6 -4
  228. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  229. package/lib/feature-libraries/forest-summary/formatCommon.js +7 -4
  230. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  231. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -14
  232. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  233. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +30 -47
  234. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  235. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  236. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  237. package/lib/feature-libraries/forest-summary/index.js +1 -1
  238. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  239. package/lib/feature-libraries/index.d.ts +3 -3
  240. package/lib/feature-libraries/index.d.ts.map +1 -1
  241. package/lib/feature-libraries/index.js +2 -2
  242. package/lib/feature-libraries/index.js.map +1 -1
  243. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +3 -3
  244. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  245. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  246. package/lib/feature-libraries/indexing/index.d.ts +1 -1
  247. package/lib/feature-libraries/indexing/index.d.ts.map +1 -1
  248. package/lib/feature-libraries/indexing/index.js.map +1 -1
  249. package/lib/feature-libraries/indexing/types.d.ts +15 -13
  250. package/lib/feature-libraries/indexing/types.d.ts.map +1 -1
  251. package/lib/feature-libraries/indexing/types.js.map +1 -1
  252. package/lib/index.d.ts +3 -3
  253. package/lib/index.d.ts.map +1 -1
  254. package/lib/index.js +1 -1
  255. package/lib/index.js.map +1 -1
  256. package/lib/legacy.d.ts +4 -1
  257. package/lib/packageVersion.d.ts +1 -1
  258. package/lib/packageVersion.js +1 -1
  259. package/lib/packageVersion.js.map +1 -1
  260. package/lib/shared-tree/independentView.js +3 -3
  261. package/lib/shared-tree/independentView.js.map +1 -1
  262. package/lib/shared-tree/schematizingTreeView.d.ts +5 -0
  263. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  264. package/lib/shared-tree/schematizingTreeView.js +33 -6
  265. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  266. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  267. package/lib/shared-tree/sharedTree.js +8 -8
  268. package/lib/shared-tree/sharedTree.js.map +1 -1
  269. package/lib/shared-tree/tree.js +1 -1
  270. package/lib/shared-tree/tree.js.map +1 -1
  271. package/lib/shared-tree/treeAlpha.d.ts +8 -1
  272. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  273. package/lib/shared-tree/treeAlpha.js +49 -9
  274. package/lib/shared-tree/treeAlpha.js.map +1 -1
  275. package/lib/shared-tree/treeCheckout.d.ts +35 -3
  276. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  277. package/lib/shared-tree/treeCheckout.js +124 -18
  278. package/lib/shared-tree/treeCheckout.js.map +1 -1
  279. package/lib/shared-tree/unhydratedTreeContext.d.ts +20 -0
  280. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -0
  281. package/lib/shared-tree/unhydratedTreeContext.js +52 -0
  282. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -0
  283. package/lib/shared-tree-core/transaction.d.ts +15 -27
  284. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  285. package/lib/shared-tree-core/transaction.js +7 -11
  286. package/lib/shared-tree-core/transaction.js.map +1 -1
  287. package/lib/simple-tree/api/configuration.d.ts +4 -0
  288. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  289. package/lib/simple-tree/api/configuration.js.map +1 -1
  290. package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
  291. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -1
  292. package/lib/simple-tree/api/identifierIndex.js +2 -2
  293. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  294. package/lib/simple-tree/api/index.d.ts +3 -3
  295. package/lib/simple-tree/api/index.d.ts.map +1 -1
  296. package/lib/simple-tree/api/index.js +1 -1
  297. package/lib/simple-tree/api/index.js.map +1 -1
  298. package/lib/simple-tree/api/schemaFactory.d.ts +3 -2
  299. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  300. package/lib/simple-tree/api/schemaFactory.js +3 -2
  301. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  302. package/lib/simple-tree/api/simpleTreeIndex.d.ts +15 -13
  303. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  304. package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
  305. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  306. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +4 -4
  307. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  308. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  309. package/lib/simple-tree/api/transactionTypes.d.ts +22 -25
  310. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  311. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  312. package/lib/simple-tree/api/tree.d.ts +69 -132
  313. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  314. package/lib/simple-tree/api/tree.js.map +1 -1
  315. package/lib/simple-tree/index.d.ts +1 -1
  316. package/lib/simple-tree/index.d.ts.map +1 -1
  317. package/lib/simple-tree/index.js +1 -1
  318. package/lib/simple-tree/index.js.map +1 -1
  319. package/lib/text/textDomain.d.ts +27 -9
  320. package/lib/text/textDomain.d.ts.map +1 -1
  321. package/lib/text/textDomain.js +45 -9
  322. package/lib/text/textDomain.js.map +1 -1
  323. package/lib/text/textDomainFormatted.d.ts +14 -8
  324. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  325. package/lib/text/textDomainFormatted.js +80 -8
  326. package/lib/text/textDomainFormatted.js.map +1 -1
  327. package/lib/util/rangeMap.d.ts +1 -0
  328. package/lib/util/rangeMap.d.ts.map +1 -1
  329. package/lib/util/rangeMap.js +5 -6
  330. package/lib/util/rangeMap.js.map +1 -1
  331. package/package.json +24 -24
  332. package/src/codec/codec.ts +5 -4
  333. package/src/codec/index.ts +1 -0
  334. package/src/codec/versioned/codec.ts +32 -6
  335. package/src/codec/versioned/format.ts +17 -2
  336. package/src/codec/versioned/index.ts +1 -1
  337. package/src/core/index.ts +2 -6
  338. package/src/core/rebase/index.ts +2 -0
  339. package/src/core/rebase/types.ts +80 -0
  340. package/src/feature-libraries/chunked-forest/codec/codecs.ts +59 -78
  341. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  342. package/src/feature-libraries/chunked-forest/codec/index.ts +3 -3
  343. package/src/feature-libraries/chunked-forest/index.ts +2 -3
  344. package/src/feature-libraries/flex-tree/observer.ts +17 -0
  345. package/src/feature-libraries/forest-summary/codec.ts +46 -56
  346. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -14
  347. package/src/feature-libraries/forest-summary/formatCommon.ts +14 -19
  348. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +44 -74
  349. package/src/feature-libraries/forest-summary/index.ts +1 -1
  350. package/src/feature-libraries/index.ts +2 -4
  351. package/src/feature-libraries/indexing/anchorTreeIndex.ts +3 -5
  352. package/src/feature-libraries/indexing/index.ts +1 -1
  353. package/src/feature-libraries/indexing/types.ts +15 -17
  354. package/src/index.ts +6 -3
  355. package/src/packageVersion.ts +1 -1
  356. package/src/shared-tree/independentView.ts +3 -3
  357. package/src/shared-tree/schematizingTreeView.ts +43 -10
  358. package/src/shared-tree/sharedTree.ts +8 -10
  359. package/src/shared-tree/tree.ts +1 -1
  360. package/src/shared-tree/treeAlpha.ts +64 -11
  361. package/src/shared-tree/treeCheckout.ts +142 -21
  362. package/src/shared-tree/unhydratedTreeContext.ts +87 -0
  363. package/src/shared-tree-core/transaction.ts +19 -39
  364. package/src/simple-tree/api/configuration.ts +4 -0
  365. package/src/simple-tree/api/identifierIndex.ts +4 -4
  366. package/src/simple-tree/api/index.ts +3 -1
  367. package/src/simple-tree/api/schemaFactory.ts +3 -2
  368. package/src/simple-tree/api/simpleTreeIndex.ts +26 -20
  369. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +4 -4
  370. package/src/simple-tree/api/transactionTypes.ts +24 -26
  371. package/src/simple-tree/api/tree.ts +92 -131
  372. package/src/simple-tree/index.ts +4 -2
  373. package/src/text/textDomain.ts +91 -12
  374. package/src/text/textDomainFormatted.ts +127 -15
  375. package/src/util/rangeMap.ts +5 -11
  376. package/dist/core/schema-view/index.d.ts +0 -6
  377. package/dist/core/schema-view/index.d.ts.map +0 -1
  378. package/dist/core/schema-view/index.js +0 -10
  379. package/dist/core/schema-view/index.js.map +0 -1
  380. package/dist/core/schema-view/view.d.ts +0 -31
  381. package/dist/core/schema-view/view.d.ts.map +0 -1
  382. package/dist/core/schema-view/view.js +0 -18
  383. package/dist/core/schema-view/view.js.map +0 -1
  384. package/dist/feature-libraries/forest-summary/formatV1.d.ts +0 -12
  385. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
  386. package/dist/feature-libraries/forest-summary/formatV1.js +0 -10
  387. package/dist/feature-libraries/forest-summary/formatV1.js.map +0 -1
  388. package/dist/feature-libraries/forest-summary/formatV2.d.ts +0 -12
  389. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
  390. package/dist/feature-libraries/forest-summary/formatV2.js +0 -10
  391. package/dist/feature-libraries/forest-summary/formatV2.js.map +0 -1
  392. package/lib/core/schema-view/index.d.ts +0 -6
  393. package/lib/core/schema-view/index.d.ts.map +0 -1
  394. package/lib/core/schema-view/index.js +0 -6
  395. package/lib/core/schema-view/index.js.map +0 -1
  396. package/lib/core/schema-view/view.d.ts +0 -31
  397. package/lib/core/schema-view/view.d.ts.map +0 -1
  398. package/lib/core/schema-view/view.js +0 -14
  399. package/lib/core/schema-view/view.js.map +0 -1
  400. package/lib/feature-libraries/forest-summary/formatV1.d.ts +0 -12
  401. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +0 -1
  402. package/lib/feature-libraries/forest-summary/formatV1.js +0 -7
  403. package/lib/feature-libraries/forest-summary/formatV1.js.map +0 -1
  404. package/lib/feature-libraries/forest-summary/formatV2.d.ts +0 -12
  405. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +0 -1
  406. package/lib/feature-libraries/forest-summary/formatV2.js +0 -7
  407. package/lib/feature-libraries/forest-summary/formatV2.js.map +0 -1
  408. package/src/core/schema-view/README.md +0 -9
  409. package/src/core/schema-view/index.ts +0 -10
  410. package/src/core/schema-view/view.ts +0 -38
  411. package/src/feature-libraries/forest-summary/formatV1.ts +0 -11
  412. package/src/feature-libraries/forest-summary/formatV2.ts +0 -11
@@ -17,7 +17,6 @@ import {
17
17
  type TreeIndexNodes,
18
18
  hasElement,
19
19
  type TreeIndex,
20
- type TreeIndexKey,
21
20
  type KeyFinder,
22
21
  } from "../../feature-libraries/index.js";
23
22
  import type { SchematizingSimpleTreeView } from "../../shared-tree/index.js";
@@ -27,6 +26,7 @@ import {
27
26
  type TreeNode,
28
27
  type TreeNodeSchema,
29
28
  type NodeFromSchema,
29
+ type TreeLeafValue,
30
30
  } from "../core/index.js";
31
31
  import type { ImplicitFieldSchema } from "../fieldSchema.js";
32
32
  import { walkFieldSchema } from "../walkFieldSchema.js";
@@ -35,14 +35,16 @@ import type { TreeView } from "./tree.js";
35
35
  import { treeNodeApi } from "./treeNodeApi.js";
36
36
 
37
37
  /**
38
- * A {@link TreeIndex} that returns tree nodes given their associated keys.
39
- *
38
+ * Value that may be used as keys in a {@link TreeIndex}.
39
+ * @remarks
40
+ * This supports values which have value semantics and are compared by value, just like {@link TreeLeafValue}.
41
+ * This allows using any tree value as a key (for example in an index tracking where those values occur in the tree).
40
42
  * @alpha
41
43
  */
42
- export type SimpleTreeIndex<TKey extends TreeIndexKey, TValue> = TreeIndex<TKey, TValue>;
44
+ export type TreeIndexKey = TreeLeafValue;
43
45
 
44
46
  /**
45
- * Creates a {@link SimpleTreeIndex} with a specified indexer.
47
+ * Creates a {@link TreeIndex} with a specified indexer.
46
48
  *
47
49
  * @param view - the view for the tree being indexed
48
50
  * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema
@@ -52,7 +54,7 @@ export type SimpleTreeIndex<TKey extends TreeIndexKey, TValue> = TreeIndex<TKey,
52
54
  *
53
55
  * @alpha
54
56
  */
55
- export function createSimpleTreeIndex<
57
+ export function createTreeIndex<
56
58
  TFieldSchema extends ImplicitFieldSchema,
57
59
  TKey extends TreeIndexKey,
58
60
  TValue,
@@ -61,9 +63,10 @@ export function createSimpleTreeIndex<
61
63
  indexer: (schema: TreeNodeSchema) => string | undefined,
62
64
  getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,
63
65
  isKeyValid: (key: TreeIndexKey) => key is TKey,
64
- ): SimpleTreeIndex<TKey, TValue>;
66
+ ): TreeIndex<TKey, TValue>;
67
+
65
68
  /**
66
- * Creates a {@link SimpleTreeIndex} with a specified indexer.
69
+ * Creates a {@link TreeIndex} with a specified indexer.
67
70
  *
68
71
  * @param view - the view for the tree being indexed
69
72
  * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema
@@ -74,7 +77,7 @@ export function createSimpleTreeIndex<
74
77
  *
75
78
  * @alpha
76
79
  */
77
- export function createSimpleTreeIndex<
80
+ export function createTreeIndex<
78
81
  TFieldSchema extends ImplicitFieldSchema,
79
82
  TKey extends TreeIndexKey,
80
83
  TValue,
@@ -85,9 +88,10 @@ export function createSimpleTreeIndex<
85
88
  getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,
86
89
  isKeyValid: (key: TreeIndexKey) => key is TKey,
87
90
  indexableSchema: readonly TSchema[],
88
- ): SimpleTreeIndex<TKey, TValue>;
91
+ ): TreeIndex<TKey, TValue>;
92
+
89
93
  /**
90
- * Creates a {@link SimpleTreeIndex} with a specified indexer.
94
+ * Creates a {@link TreeIndex} with a specified indexer.
91
95
  *
92
96
  * @param view - the view for the tree being indexed
93
97
  * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema
@@ -97,7 +101,7 @@ export function createSimpleTreeIndex<
97
101
  *
98
102
  * @alpha
99
103
  */
100
- export function createSimpleTreeIndex<
104
+ export function createTreeIndex<
101
105
  TFieldSchema extends ImplicitFieldSchema,
102
106
  TKey extends TreeIndexKey,
103
107
  TValue,
@@ -106,9 +110,10 @@ export function createSimpleTreeIndex<
106
110
  indexer: Map<TreeNodeSchema, string>,
107
111
  getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,
108
112
  isKeyValid: (key: TreeIndexKey) => key is TKey,
109
- ): SimpleTreeIndex<TKey, TValue>;
113
+ ): TreeIndex<TKey, TValue>;
114
+
110
115
  /**
111
- * Creates a {@link SimpleTreeIndex} with a specified indexer.
116
+ * Creates a {@link TreeIndex} with a specified indexer.
112
117
  *
113
118
  * @param view - the view for the tree being indexed
114
119
  * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema
@@ -119,7 +124,7 @@ export function createSimpleTreeIndex<
119
124
  *
120
125
  * @alpha
121
126
  */
122
- export function createSimpleTreeIndex<
127
+ export function createTreeIndex<
123
128
  TFieldSchema extends ImplicitFieldSchema,
124
129
  TKey extends TreeIndexKey,
125
130
  TValue,
@@ -130,13 +135,14 @@ export function createSimpleTreeIndex<
130
135
  getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,
131
136
  isKeyValid: (key: TreeIndexKey) => key is TKey,
132
137
  indexableSchema: readonly TSchema[],
133
- ): SimpleTreeIndex<TKey, TValue>;
138
+ ): TreeIndex<TKey, TValue>;
139
+
134
140
  /**
135
- * Creates a {@link SimpleTreeIndex} with a specified indexer.
141
+ * Creates a {@link TreeIndex} with a specified indexer.
136
142
  *
137
143
  * @alpha
138
144
  */
139
- export function createSimpleTreeIndex<
145
+ export function createTreeIndex<
140
146
  TFieldSchema extends ImplicitFieldSchema,
141
147
  TKey extends TreeIndexKey,
142
148
  TValue,
@@ -148,7 +154,7 @@ export function createSimpleTreeIndex<
148
154
  | ((nodes: TreeIndexNodes<NodeFromSchema<TreeNodeSchema>>) => TValue),
149
155
  isKeyValid: (key: TreeIndexKey) => key is TKey,
150
156
  indexableSchema?: readonly TreeNodeSchema[],
151
- ): SimpleTreeIndex<TKey, TValue> {
157
+ ): TreeIndex<TKey, TValue> {
152
158
  const indexableSchemaMap = new Map<string, TreeNodeSchema>();
153
159
  if (indexableSchema === undefined) {
154
160
  walkFieldSchema(view.schema, {
@@ -214,7 +220,7 @@ export function createSimpleTreeIndex<
214
220
 
215
221
  // all the type checking guarantees that we put nodes of the correct type in the index
216
222
  // but it's not captured in the type system
217
- return index as SimpleTreeIndex<TKey, TValue>;
223
+ return index as TreeIndex<TKey, TValue>;
218
224
  }
219
225
 
220
226
  function makeGenericKeyFinder<TKey extends TreeIndexKey>(
@@ -167,7 +167,7 @@ export function importCompatibilitySchemaSnapshot(
167
167
  * allowing for greater portability and easier testing.
168
168
  *
169
169
  * @input
170
- * @alpha
170
+ * @beta
171
171
  */
172
172
  export interface SnapshotFileSystem {
173
173
  /**
@@ -245,7 +245,7 @@ export interface CombinedSchemaCompatibilityStatus {
245
245
  /**
246
246
  * The options for {@link snapshotSchemaCompatibility}.
247
247
  * @input
248
- * @alpha
248
+ * @beta
249
249
  */
250
250
  export interface SnapshotSchemaCompatibilityOptions {
251
251
  /**
@@ -447,7 +447,7 @@ export interface SnapshotSchemaCompatibilityOptions {
447
447
  * import fs from "node:fs";
448
448
  * import path from "node:path";
449
449
  *
450
- * import { snapshotSchemaCompatibility } from "@fluidframework/tree/alpha";
450
+ * import { snapshotSchemaCompatibility } from "@fluidframework/tree/beta";
451
451
  *
452
452
  * // The TreeViewConfiguration the application uses, which contains the application's schema.
453
453
  * import { treeViewConfiguration } from "./schema.js";
@@ -485,7 +485,7 @@ export interface SnapshotSchemaCompatibilityOptions {
485
485
  * but it would be nice to better unify how we do that versioning and format validation with our codecs.
486
486
  *
487
487
  * See snapshotCompatibilityChecker.example.mts for the large example included above.
488
- * @alpha
488
+ * @beta
489
489
  */
490
490
  export function snapshotSchemaCompatibility(
491
491
  options: SnapshotSchemaCompatibilityOptions,
@@ -49,22 +49,27 @@ export interface NoChangeConstraint {
49
49
  }
50
50
 
51
51
  /**
52
- * The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.
52
+ * Contains a value returned from a transaction.
53
+ * @alpha
54
+ */
55
+ export interface WithValue<TValue> {
56
+ /** The user-supplied value. */
57
+ value: TValue;
58
+ }
59
+
60
+ /**
61
+ * Contains a value and status returned from a user-supplied {@link TreeBranchAlpha.(runTransaction:1) | transaction callback}.
53
62
  * @alpha
54
63
  */
55
64
  export type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (
56
- | {
65
+ | (WithValue<TSuccessValue> & {
57
66
  /** Indicates that the transaction callback ran successfully. */
58
67
  rollback?: false;
59
- /** The user defined value when the transaction ran successfully. */
60
- value: TSuccessValue;
61
- }
62
- | {
68
+ })
69
+ | (WithValue<TFailureValue> & {
63
70
  /** Indicates that the transaction callback failed and the transaction should be rolled back. */
64
71
  rollback: true;
65
- /** The user defined value when the transaction failed. */
66
- value: TFailureValue;
67
- }
72
+ })
68
73
  ) & {
69
74
  /**
70
75
  * An optional list of {@link TransactionConstraintAlpha | constraints} that will be checked when the commit corresponding
@@ -77,8 +82,7 @@ export type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (
77
82
  };
78
83
 
79
84
  /**
80
- * The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't
81
- * need to return a value. This is the same as {@link TransactionCallbackStatus} but with the `value` field omitted. This
85
+ * The result of a {@link TreeBranchAlpha.(runTransaction:2) | transaction} that doesn't return a value.
82
86
  * @alpha
83
87
  */
84
88
  export type VoidTransactionCallbackStatus = Omit<
@@ -87,25 +91,21 @@ export type VoidTransactionCallbackStatus = Omit<
87
91
  >;
88
92
 
89
93
  /**
90
- * The result of the {@link RunTransaction | RunTransaction} API when it was successful.
94
+ * The result of a {@link TreeBranchAlpha.(runTransaction:1) | transaction} that completed successfully.
91
95
  * @alpha
92
96
  */
93
- export interface TransactionResultSuccess<TSuccessValue> {
94
- /** Indicates that the transaction was successful. */
97
+ export interface TransactionResultSuccess<TSuccessValue> extends WithValue<TSuccessValue> {
98
+ /** The success flag for a transaction that completed without being {@link TransactionCallbackStatus | rolled back}. */
95
99
  success: true;
96
- /** The user defined value when the transaction was successful. */
97
- value: TSuccessValue;
98
100
  }
99
101
 
100
102
  /**
101
- * The result of the {@link RunTransaction | RunTransaction} API when it failed.
103
+ * The result of a {@link TreeBranchAlpha.(runTransaction:1) | transaction} that was rolled back.
102
104
  * @alpha
103
105
  */
104
- export interface TransactionResultFailed<TFailureValue> {
105
- /** Indicates that the transaction failed. */
106
+ export interface TransactionResultFailed<TFailureValue> extends WithValue<TFailureValue> {
107
+ /** The failure flag for a transaction that was {@link TransactionCallbackStatus | rolled back}. */
106
108
  success: false;
107
- /** The user defined value when the transaction failed. */
108
- value: TFailureValue;
109
109
  }
110
110
 
111
111
  /**
@@ -133,17 +133,15 @@ export type TransactionResult =
133
133
  export interface RunTransactionParams {
134
134
  /**
135
135
  * An optional list of {@link TransactionConstraintAlpha | constraints} that are checked just before the transaction begins.
136
+ * @remarks
136
137
  * If any of the constraints are not met when `runTransaction` is called, an error will be thrown.
137
- * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on
138
- * this client and ignored by all other clients.
138
+ * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.
139
139
  */
140
140
  readonly preconditions?: readonly TransactionConstraintAlpha[];
141
141
  /**
142
142
  * A label for this transaction that allows it to be correlated with later edits (e.g. for controlling undo/redo grouping).
143
- *
144
143
  * @remarks
145
- * This label is associated with the commit produced by this transaction, and is surfaced through the
146
- * `label` property of {@link ChangeMetadata} in the `commitApplied` or `changed` event.
144
+ * If this transaction is applied to a {@link TreeBranchAlpha | branch}, the label will be available in the {@link LocalChangeMetadata.label | metadata} of the {@link TreeBranchEvents.changed | `changed`} event.
147
145
  *
148
146
  * If there is a nested transaction, only the outermost transaction label will be used.
149
147
  */
@@ -11,12 +11,18 @@ import type {
11
11
  RevertibleAlphaFactory,
12
12
  RevertibleFactory,
13
13
  } from "../../core/index.js";
14
+ // This is referenced by doc comments.
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ import type { TreeStatus } from "../../feature-libraries/index.js";
14
17
  import type {
15
18
  // This is referenced by doc comments.
16
19
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
17
20
  TreeAlpha,
18
21
  } from "../../shared-tree/index.js";
19
22
  import type { JsonCompatibleReadOnly } from "../../util/index.js";
23
+ // This is referenced by doc comments.
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ import type { Unhydrated } from "../core/index.js";
20
26
  import type {
21
27
  ImplicitFieldSchema,
22
28
  InsertableField,
@@ -35,6 +41,7 @@ import type {
35
41
  TransactionResult,
36
42
  TransactionResultExt,
37
43
  VoidTransactionCallbackStatus,
44
+ WithValue,
38
45
  } from "./transactionTypes.js";
39
46
  import type { VerboseTree } from "./verboseTree.js";
40
47
 
@@ -175,6 +182,80 @@ export interface TreeBranch extends IDisposable {
175
182
  dispose(error?: Error): void;
176
183
  }
177
184
 
185
+ /**
186
+ * Provides additional APIs that may be used to interact with a tree node or a tree node's SharedTree.
187
+ * @alpha
188
+ */
189
+ export interface TreeContextAlpha {
190
+ /**
191
+ * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.
192
+ * @param transaction - A callback run during the transaction to perform user-supplied operations.
193
+ * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.
194
+ * @param params - Optional {@link RunTransactionParams | parameters} for the transaction.
195
+ * @returns A {@link TransactionResultExt | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.
196
+ * @remarks
197
+ * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.
198
+ * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
199
+ *
200
+ * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.
201
+ * Any other/future clients or contexts will process the transaction "squashed", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).
202
+ * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.
203
+ *
204
+ * Using a transaction has the following additional consequences:
205
+ *
206
+ * - If {@link Revertible | reverted } (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
207
+ * Only the "outermost" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.
208
+ * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.
209
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
210
+ *
211
+ * `runTransaction` may be invoked on the context of a {@link TreeStatus.InDocument | hydrated } or {@link Unhydrated | unhydrated } node.
212
+ * Use {@link TreeContextAlpha.isBranch | isBranch() } to check whether this context is associated with a branch and gain {@link TreeBranchAlpha.(runTransaction:1) | access to more transaction capabilities} if so.
213
+ */
214
+ runTransaction<TValue>(
215
+ transaction: () => WithValue<TValue>,
216
+ params?: RunTransactionParams,
217
+ ): TransactionResultExt<TValue, TValue>;
218
+
219
+ /** An overload of {@link TreeContextAlpha.(runTransaction:1) | runTransaction } which does not return a value. */
220
+ runTransaction(transaction: () => void, params?: RunTransactionParams): TransactionResult;
221
+
222
+ /**
223
+ * An asynchronous version of {@link TreeContextAlpha.(runTransaction:1) | runTransaction}.
224
+ * @remarks
225
+ * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.
226
+ * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.
227
+ *
228
+ * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.
229
+ * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.
230
+ *
231
+ * An asynchronous transaction may not be started while any other transaction is in progress in this context.
232
+ */
233
+ runTransactionAsync<TValue>(
234
+ transaction: () => Promise<WithValue<TValue>>,
235
+ params?: RunTransactionParams,
236
+ ): Promise<TransactionResultExt<TValue, TValue>>;
237
+
238
+ /** An overload of {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value. */
239
+ runTransactionAsync(
240
+ transaction: () => Promise<void>,
241
+ params?: RunTransactionParams,
242
+ ): Promise<TransactionResult>;
243
+
244
+ /**
245
+ * True if this context is associated with a {@link TreeBranchAlpha | branch} and false if it is associated with an {@link Unhydrated | unhydrated } node.
246
+ * @remarks If this returns true, the context can be safely inferred or cast to {@link TreeBranchAlpha} to access additional branch-specific APIs.
247
+ * @example
248
+ * ```typescript
249
+ * const context = tree.context(someNode);
250
+ * if (context.isBranch()) {
251
+ * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on TreeBranchAlpha, so this is only accessible if `context` is a branch context.
252
+ * context.root.foo = "bar"; // Edit the root of the SharedTree that `someNode` belongs to.
253
+ * }
254
+ * ```
255
+ */
256
+ isBranch(): this is TreeBranchAlpha;
257
+ }
258
+
178
259
  /**
179
260
  * {@link TreeBranch} with alpha-level APIs.
180
261
  * @remarks
@@ -183,7 +264,7 @@ export interface TreeBranch extends IDisposable {
183
264
  * A branch does not necessarily know the schema of its SharedTree - to convert a branch to a {@link TreeViewAlpha | view with a schema}, use {@link TreeBranchAlpha.hasRootSchema | hasRootSchema()}.
184
265
  * @sealed @alpha
185
266
  */
186
- export interface TreeBranchAlpha extends TreeBranch {
267
+ export interface TreeBranchAlpha extends TreeBranch, TreeContextAlpha {
187
268
  /**
188
269
  * Events for the branch
189
270
  */
@@ -211,75 +292,18 @@ export interface TreeBranchAlpha extends TreeBranch {
211
292
  fork(): TreeBranchAlpha;
212
293
 
213
294
  /**
214
- * Run a synchronous transaction which applies one or more edits to the tree as a single atomic unit.
215
- * @param transaction - The function to run as the body of the transaction.
216
- * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
217
- * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
218
- * abort the transaction and discard any changes it made so far.
219
- * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
220
- * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
221
- * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
222
- *
223
- * - A "success" flag indicating whether the transaction was successful or not.
224
- * - The success or failure value as returned by the transaction function.
225
- *
295
+ * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on a branch of the SharedTree.
296
+ * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatus | value or rollback signal}.
226
297
  * @remarks
227
- * This API will throw an error if the constraints are not met or something unexpected happens.
228
- * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
229
- * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
230
- * However, using a transaction has the following additional consequences:
231
- *
232
- * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
233
- * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
234
- *
235
- * Local change events will be emitted for each change as the transaction is being applied.
236
- * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
237
- *
238
- * Nested transactions:
239
- * This API can be called from within the transaction callback of another `runTransaction` or `runTransactionAsync` call. That will have slightly different behavior:
240
- *
241
- * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
242
- * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
243
- * for the outermost transaction which includes all inner transactions.
244
- * - Undo will undo the outermost transaction and all inner transactions.
245
- * - If a label is provided in the params, only the label for the outermost transaction will be used. All other labels will be ignored.
298
+ * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.
246
299
  */
247
300
  runTransaction<TSuccessValue, TFailureValue>(
248
301
  transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,
249
302
  params?: RunTransactionParams,
250
303
  ): TransactionResultExt<TSuccessValue, TFailureValue>;
304
+
251
305
  /**
252
- * Run a synchronous transaction which applies one or more edits to the tree as a single atomic unit.
253
- * @param transaction - The function to run as the body of the transaction. It may return the following:
254
- *
255
- * - Nothing to indicate that the body of the transaction has successfully run.
256
- * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
257
- * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
258
- * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
259
- *
260
- * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
261
- * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
262
- * transaction was successful or not.
263
- *
264
- * @remarks
265
- * This API will throw an error if the constraints are not met or something unexpected happens.
266
- * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
267
- * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
268
- * However, using a transaction has the following additional consequences:
269
- *
270
- * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
271
- * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
272
- *
273
- * Local change events will be emitted for each change as the transaction is being applied.
274
- * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
275
- *
276
- * Nested transactions:
277
- * This API can be called from within the transaction callback of another `runTransaction` or `runTransactionAsync` call. That will have slightly different behavior:
278
- *
279
- * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
280
- * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
281
- * for the outermost transaction which includes all inner transactions.
282
- * - Undo will undo the outermost transaction and all inner transactions.
306
+ * An overload of {@link TreeBranchAlpha.(runTransaction:1) | runTransaction } which does not return a value.
283
307
  */
284
308
  runTransaction(
285
309
  transaction: () => VoidTransactionCallbackStatus | void,
@@ -287,80 +311,17 @@ export interface TreeBranchAlpha extends TreeBranch {
287
311
  ): TransactionResult;
288
312
 
289
313
  /**
290
- * Run an asynchronous transaction which applies one or more edits to the tree as a single atomic unit.
291
- * @param transaction - The function to run as the body of the transaction.
292
- * It should return a promise that resolves to a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
293
- * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
294
- * abort the transaction and discard any changes it made so far.
295
- * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
296
- * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
297
- * @returns A promise that resolves to a result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
298
- *
299
- * - A "success" flag indicating whether the transaction was successful or not.
300
- * - The success or failure value as returned by the transaction function.
301
- *
302
- * The promise will reject if the constraints are not met or something unexpected happens.
303
- *
304
- * @remarks
305
- * As with synchronous transactions, using an asynchronous transaction has the following consequences:
306
- * - All of the changes in the transaction are treated as a unit, therefore no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.
307
- * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
308
- * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
309
- *
310
- * Unlike with synchronous transactions, using an asynchronous transaction has the following consequences:
311
- * - It is possible that other changes (either from this client by merging a branch or from a remote client) may be applied to the branch while this transaction is in progress.
312
- * These other changes will be not be reflected on the branch until after this transaction completes,
313
- * at which point the transaction changes will be applied after these other changes.
314
- *
315
- * Local change events will be emitted for each change as the transaction is being applied.
316
- * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
317
- *
318
- * Nested transactions:
319
- * This API can be called from within the transaction callback of another `runTransactionAsync` call. That will have slightly different behavior:
320
- *
321
- * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
322
- * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
323
- * for the outermost transaction which includes all inner transactions.
324
- * - Undo will undo the outermost transaction and all inner transactions.
314
+ * An asynchronous version of {@link TreeBranchAlpha.(runTransaction:1) | runTransaction}.
315
+ * @remarks See {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync} for additional information about asynchronous transactions.
325
316
  */
317
+
326
318
  runTransactionAsync<TSuccessValue, TFailureValue>(
327
319
  transaction: () => Promise<TransactionCallbackStatus<TSuccessValue, TFailureValue>>,
328
320
  params?: RunTransactionParams,
329
321
  ): Promise<TransactionResultExt<TSuccessValue, TFailureValue>>;
322
+
330
323
  /**
331
- * Run an asynchronous transaction which applies one or more edits to the tree as a single atomic unit.
332
- * @param transaction - The function to run as the body of the transaction. It must return a promise that can resolve to any of the following:
333
- *
334
- * - Nothing to indicate that the body of the transaction has successfully run.
335
- * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
336
- * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
337
- * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
338
- *
339
- * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
340
- * @returns A promise that resolves to a result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
341
- * transaction was successful or not. The promise will reject if the constraints are not met or something unexpected happens.
342
- *
343
- * @remarks
344
- * As with synchronous transactions, using an asynchronous transaction has the following consequences:
345
- * - All of the changes in the transaction are treated as a unit, therefore no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.
346
- * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
347
- * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
348
- *
349
- * Unlike with synchronous transactions, using an asynchronous transaction has the following consequences:
350
- * - It is possible that other changes (either from this client by merging a branch or from a remote client) may be applied to the branch while this transaction is in progress.
351
- * These other changes will be not be reflected on the branch until after this transaction completes,
352
- * at which point the transaction changes will be applied after these other changes.
353
- *
354
- * Local change events will be emitted for each change as the transaction is being applied.
355
- * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
356
- *
357
- * Nested transactions:
358
- * This API can be called from within the transaction callback of another `runTransactionAsync` call. That will have slightly different behavior:
359
- *
360
- * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
361
- * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
362
- * for the outermost transaction which includes all inner transactions.
363
- * - Undo will undo the outermost transaction and all inner transactions.
324
+ * An overload of {@link TreeBranchAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.
364
325
  */
365
326
  runTransactionAsync(
366
327
  transaction: () => Promise<VoidTransactionCallbackStatus | void>,
@@ -95,10 +95,10 @@ export {
95
95
  importConcise,
96
96
  TreeBeta,
97
97
  type TreeChangeEventsBeta,
98
- type SimpleTreeIndex,
99
98
  type IdentifierIndex,
100
- createSimpleTreeIndex,
99
+ createTreeIndex,
101
100
  createIdentifierIndex,
101
+ type TreeIndexKey,
102
102
  type DirtyTreeStatus,
103
103
  trackDirtyNodes,
104
104
  type DirtyTreeMap,
@@ -201,6 +201,8 @@ export {
201
201
  type SnapshotFileSystem,
202
202
  type SnapshotSchemaCompatibilityOptions,
203
203
  createCustomizedFluidFrameworkScopedFactory,
204
+ type TreeContextAlpha,
205
+ type WithValue,
204
206
  } from "./api/index.js";
205
207
  export type {
206
208
  SimpleTreeSchema,