@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
@@ -3,17 +3,17 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export { EncodedFieldBatch, FieldBatchFormatVersion } from "./format.js";
6
+ export type { EncodedFieldBatch } from "./format.js";
7
+ export { FieldBatchFormatVersion } from "./format.js";
7
8
  export type { FieldBatch } from "./fieldBatch.js";
8
9
  export {
9
10
  type FieldBatchCodec,
10
- makeFieldBatchCodec,
11
+ fieldBatchCodecBuilder,
11
12
  type FieldBatchEncodingContext,
12
13
  type IncrementalEncoderDecoder,
13
14
  type IncrementalEncoder,
14
15
  type IncrementalDecoder,
15
16
  type ChunkReferenceId,
16
- getCodecTreeForFieldBatchFormat,
17
17
  } from "./codecs.js";
18
18
  export {
19
19
  type IncrementalEncodingPolicy,
@@ -16,12 +16,11 @@ export {
16
16
  } from "./chunkTree.js";
17
17
  export { buildChunkedForest } from "./chunkedForest.js";
18
18
  export {
19
- EncodedFieldBatch,
19
+ type EncodedFieldBatch,
20
20
  FieldBatchFormatVersion,
21
- getCodecTreeForFieldBatchFormat,
22
21
  type FieldBatch,
23
22
  type FieldBatchCodec,
24
- makeFieldBatchCodec,
23
+ fieldBatchCodecBuilder,
25
24
  type FieldBatchEncodingContext,
26
25
  type IncrementalEncoderDecoder,
27
26
  type ChunkReferenceId,
@@ -22,8 +22,25 @@ import type { FlexTreeNode } from "./flexTreeTypes.js";
22
22
  * See {@link withObservation} and {@link currentObserver}.
23
23
  */
24
24
  export interface Observer {
25
+ /**
26
+ * Arbitrary content in `node` subtree might be observed.
27
+ */
28
+ observeNodeDeep(node: FlexTreeNode): void;
29
+ /**
30
+ * Which fields exist (as non-empty) on `node` is being observed.
31
+ * @remarks
32
+ * The set of fields should be considered order independent.
33
+ */
25
34
  observeNodeFields(node: FlexTreeNode): void;
35
+ /**
36
+ * The contents of the `key` field of `node` are being observed.
37
+ * @remarks
38
+ * Any (shallow) change to which children exist in this field, or in what order should invalidate this observation.
39
+ */
26
40
  observeNodeField(node: FlexTreeNode, key: FieldKey): void;
41
+ /**
42
+ * The parent of `node` is being observed.
43
+ */
27
44
  observeParentOf(node: FlexTreeNode): void;
28
45
  }
29
46
 
@@ -4,89 +4,79 @@
4
4
  */
5
5
 
6
6
  import { assert, oob } from "@fluidframework/core-utils/internal";
7
- import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
- import {
9
- getConfigForMinVersionForCollab,
10
- lowestMinVersionForCollab,
11
- } from "@fluidframework/runtime-utils/internal";
12
- import { Type } from "@sinclair/typebox";
7
+ import { lowestMinVersionForCollab } from "@fluidframework/runtime-utils/internal";
13
8
 
14
9
  import {
15
- type CodecTree,
10
+ ClientVersionDispatchingCodecBuilder,
11
+ type CodecAndSchema,
16
12
  type CodecWriteOptions,
17
13
  FluidClientVersion,
18
- type IJsonCodec,
19
- makeVersionedValidatedCodec,
20
14
  } from "../../codec/index.js";
21
15
  import type { FieldKey, ITreeCursorSynchronous } from "../../core/index.js";
22
- import { brand, type JsonCompatibleReadOnly } from "../../util/index.js";
23
- import type { FieldBatchCodec, FieldBatchEncodingContext } from "../chunked-forest/index.js";
16
+ import {
17
+ fieldBatchCodecBuilder,
18
+ type FieldBatchEncodingContext,
19
+ } from "../chunked-forest/index.js";
24
20
 
25
- import { ForestFormatVersion, validVersions, type Format } from "./formatCommon.js";
26
- import { FormatV1 } from "./formatV1.js";
27
- import { FormatV2 } from "./formatV2.js";
21
+ import { ForestFormatVersion, FormatCommon } from "./formatCommon.js";
28
22
 
29
23
  /**
30
24
  * Uses field cursors
31
25
  */
32
26
  export type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;
33
- export type ForestCodec = IJsonCodec<
34
- FieldSet,
35
- Format,
36
- JsonCompatibleReadOnly,
37
- FieldBatchEncodingContext
38
- >;
27
+ export type ForestCodec = ReturnType<typeof forestCodecBuilder.build>;
39
28
 
40
- /**
41
- * Convert a MinimumVersionForCollab to a ForestFormatVersion.
42
- * @param clientVersion - The MinimumVersionForCollab to convert.
43
- * @returns The ForestFormatVersion that corresponds to the provided MinimumVersionForCollab.
44
- */
45
- export function clientVersionToForestFormatVersion(
46
- clientVersion: MinimumVersionForCollab,
47
- ): ForestFormatVersion {
48
- return brand(
49
- getConfigForMinVersionForCollab(clientVersion, {
50
- [lowestMinVersionForCollab]: ForestFormatVersion.v1,
51
- [FluidClientVersion.v2_74]: ForestFormatVersion.v2,
52
- }),
53
- );
54
- }
55
-
56
- export function makeForestSummarizerCodec(
29
+ function makeForestSummarizerCodec(
57
30
  options: CodecWriteOptions,
58
- fieldBatchCodec: FieldBatchCodec,
59
- ): ForestCodec {
60
- const inner = fieldBatchCodec;
61
- const writeVersion = clientVersionToForestFormatVersion(options.minVersionForCollab);
62
- const formatSchema = Type.Union([FormatV1, FormatV2]);
63
- // Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `formatSchema`.
64
- // This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,
65
- // instead of one call per version, then using another utility to select between them based on version.
66
- return makeVersionedValidatedCodec(options, validVersions, formatSchema, {
67
- encode: (data: FieldSet, context: FieldBatchEncodingContext): Format => {
31
+ version: ForestFormatVersion,
32
+ ): CodecAndSchema<FieldSet, FieldBatchEncodingContext> {
33
+ // Performance: Since multiple places (including multiple versions of this codec) use the field batch codec,
34
+ // we may end up with multiple copies of it, including compiling its format validation multiple times.
35
+ // This is not ideal, but is not too bad as it is a small fixed number of copies and thus should not be too expensive.
36
+ // If this becomes problematic a cache could be added for options to codec instances somewhere.
37
+ const fieldBatchCodec = fieldBatchCodecBuilder.build(options);
38
+ const formatSchema = FormatCommon;
39
+ return {
40
+ encode: (data: FieldSet, context: FieldBatchEncodingContext): FormatCommon => {
68
41
  const keys: FieldKey[] = [];
69
42
  const fields: ITreeCursorSynchronous[] = [];
70
43
  for (const [key, value] of data) {
71
44
  keys.push(key);
72
45
  fields.push(value);
73
46
  }
74
- return { keys, fields: inner.encode(fields, context), version: writeVersion };
47
+ return {
48
+ keys,
49
+ fields: fieldBatchCodec.encode(fields, context),
50
+ version,
51
+ };
75
52
  },
76
- decode: (data: Format, context: FieldBatchEncodingContext): FieldSet => {
53
+ decode: (data: FormatCommon, context: FieldBatchEncodingContext): FieldSet => {
77
54
  const out: Map<FieldKey, ITreeCursorSynchronous> = new Map();
78
- const fields = inner.decode(data.fields, context);
55
+ const fields = fieldBatchCodec.decode(data.fields, context);
79
56
  assert(data.keys.length === fields.length, 0x891 /* mismatched lengths */);
80
57
  for (const [index, field] of fields.entries()) {
81
58
  out.set(data.keys[index] ?? oob(), field);
82
59
  }
83
60
  return out;
84
61
  },
85
- });
62
+ schema: formatSchema,
63
+ };
86
64
  }
87
65
 
88
- export function getCodecTreeForForestFormat(
89
- clientVersion: MinimumVersionForCollab,
90
- ): CodecTree {
91
- return { name: "Forest", version: clientVersionToForestFormatVersion(clientVersion) };
92
- }
66
+ /**
67
+ * {@link ClientVersionDispatchingCodecBuilder} for forest summarizer codecs.
68
+ */
69
+ export const forestCodecBuilder = ClientVersionDispatchingCodecBuilder.build("Forest", [
70
+ {
71
+ minVersionForCollab: lowestMinVersionForCollab,
72
+ formatVersion: ForestFormatVersion.v1,
73
+ codec: (options: CodecWriteOptions) =>
74
+ makeForestSummarizerCodec(options, ForestFormatVersion.v1),
75
+ },
76
+ {
77
+ minVersionForCollab: FluidClientVersion.v2_74,
78
+ formatVersion: ForestFormatVersion.v2,
79
+ codec: (options: CodecWriteOptions) =>
80
+ makeForestSummarizerCodec(options, ForestFormatVersion.v2),
81
+ },
82
+ ]);
@@ -41,18 +41,12 @@ import {
41
41
  import { chunkFieldSingle, defaultChunkPolicy } from "../chunked-forest/chunkTree.js";
42
42
  import {
43
43
  defaultIncrementalEncodingPolicy,
44
- type FieldBatchCodec,
45
44
  type FieldBatchEncodingContext,
46
45
  type IncrementalEncodingPolicy,
47
46
  } from "../chunked-forest/index.js";
48
47
  import { TreeCompressionStrategy } from "../treeCompressionUtils.js";
49
48
 
50
- import {
51
- clientVersionToForestFormatVersion,
52
- type ForestCodec,
53
- makeForestSummarizerCodec,
54
- } from "./codec.js";
55
- import { ForestFormatVersion } from "./formatCommon.js";
49
+ import { forestCodecBuilder, type ForestCodec } from "./codec.js";
56
50
  import {
57
51
  ForestIncrementalSummaryBehavior,
58
52
  ForestIncrementalSummaryBuilder,
@@ -85,7 +79,6 @@ export class ForestSummarizer
85
79
  public constructor(
86
80
  private readonly forest: IEditableForest,
87
81
  private readonly revisionTagCodec: RevisionTagCodec,
88
- fieldBatchCodec: FieldBatchCodec,
89
82
  private readonly encoderContext: FieldBatchEncodingContext,
90
83
  options: CodecWriteOptions,
91
84
  private readonly idCompressor: IIdCompressor,
@@ -99,11 +92,8 @@ export class ForestSummarizer
99
92
  true /* supportPreVersioningFormat */,
100
93
  );
101
94
 
102
- this.codec = makeForestSummarizerCodec(options, fieldBatchCodec);
95
+ this.codec = forestCodecBuilder.build(options);
103
96
 
104
- const forestFormatWriteVersion = clientVersionToForestFormatVersion(
105
- options.minVersionForCollab,
106
- );
107
97
  const summaryFormatWriteVersion = minVersionToForestSummaryFormatVersion(
108
98
  options.minVersionForCollab,
109
99
  );
@@ -111,9 +101,10 @@ export class ForestSummarizer
111
101
  summaryFormatWriteVersion,
112
102
  );
113
103
 
114
- // Incremental summary is supported from ForestFormatVersion.v2 and ForestSummaryFormatVersion.v3 onwards.
104
+ // Incremental summary is supported in ForestSummaryFormatVersion.v3 onwards.
105
+ // Note that even in versions that support it, it is possible that the
106
+ // FieldBatchCodec will not use incremental encoding (for example if using its v1 formats which does not support it).
115
107
  const enableIncrementalSummary =
116
- forestFormatWriteVersion >= ForestFormatVersion.v2 &&
117
108
  summaryFormatWriteVersion >= ForestSummaryFormatVersion.v3 &&
118
109
  encoderContext.encodeType === TreeCompressionStrategy.CompressedIncremental;
119
110
  this.incrementalSummaryBuilder = new ForestIncrementalSummaryBuilder(
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { type Static, Type } from "@sinclair/typebox";
7
7
 
8
+ import { versionField } from "../../codec/index.js";
8
9
  import { schemaFormatV1 } from "../../core/index.js";
9
10
  import { strictEnum, type Values, JsonCompatibleReadOnlySchema } from "../../util/index.js";
10
11
 
@@ -13,26 +14,20 @@ import { strictEnum, type Values, JsonCompatibleReadOnlySchema } from "../../uti
13
14
  */
14
15
  export const ForestFormatVersion = strictEnum("ForestFormatVersion", {
15
16
  v1: 1,
16
- /** This format supports incremental encoding */
17
+ /** This format is the same as v1, and was added at the same time as incremental encoding for reasons that no longer apply */
17
18
  v2: 2,
18
19
  });
19
20
  export type ForestFormatVersion = Values<typeof ForestFormatVersion>;
20
21
 
21
- export const validVersions = new Set([...Object.values(ForestFormatVersion)]);
22
-
23
- export const FormatCommon = <const TVersion extends ForestFormatVersion>(
24
- version: TVersion,
25
- // Return type is intentionally derived.
26
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
27
- ) =>
28
- Type.Object(
29
- {
30
- version: Type.Literal(version),
31
- keys: Type.Array(schemaFormatV1.FieldKeySchema),
32
- fields: JsonCompatibleReadOnlySchema, // Uses field batch codec
33
- },
34
- { additionalProperties: false },
35
- );
36
- export type Format<TVersion extends ForestFormatVersion = ForestFormatVersion> = Static<
37
- ReturnType<typeof FormatCommon<TVersion>>
38
- >;
22
+ /**
23
+ * Format used by {@link ForestFormatVersion.v1} and {@link ForestFormatVersion.v2}.
24
+ */
25
+ export const FormatCommon = Type.Object(
26
+ {
27
+ ...versionField,
28
+ keys: Type.Array(schemaFormatV1.FieldKeySchema),
29
+ fields: JsonCompatibleReadOnlySchema, // Uses field batch codec
30
+ },
31
+ { additionalProperties: false },
32
+ );
33
+ export type FormatCommon = Static<typeof FormatCommon>;
@@ -31,18 +31,6 @@ import type {
31
31
 
32
32
  import { summaryContentBlobKey } from "./summaryFormatV3.js";
33
33
 
34
- /**
35
- * State that tells whether a summary is currently being tracked.
36
- */
37
- export const ForestSummaryTrackingState = {
38
- /** A summary is currently being tracked. */
39
- Tracking: "Tracking",
40
- /** A summary is ready to be tracked. */
41
- ReadyToTrack: "ReadyToTrack",
42
- } as const;
43
- export type ForestSummaryTrackingState =
44
- (typeof ForestSummaryTrackingState)[keyof typeof ForestSummaryTrackingState];
45
-
46
34
  /**
47
35
  * The properties of a chunk tracked during the loading process.
48
36
  * These are used to identify a chunk when it is decoded and recreate the tracking state
@@ -144,44 +132,6 @@ export enum ForestIncrementalSummaryBehavior {
144
132
  SingleBlob,
145
133
  }
146
134
 
147
- /**
148
- * Validates that a summary is currently being tracked and that the tracked summary properties are defined.
149
- * @param forestSummaryState - The current state of the forest summary tracking.
150
- * @param trackedSummaryProperties - The properties of the tracked summary, which must be available.
151
- */
152
- function validateTrackingSummary(
153
- forestSummaryState: ForestSummaryTrackingState,
154
- trackedSummaryProperties: TrackedSummaryProperties | undefined,
155
- ): asserts trackedSummaryProperties is TrackedSummaryProperties {
156
- assert(
157
- forestSummaryState === ForestSummaryTrackingState.Tracking,
158
- 0xc22 /* Not tracking a summary */,
159
- );
160
- assert(
161
- trackedSummaryProperties !== undefined,
162
- 0xc23 /* Tracked summary properties must be available when tracking a summary */,
163
- );
164
- }
165
-
166
- /**
167
- * Validates that a summary is ready to be tracked and that the tracked summary properties are undefined.
168
- * @param forestSummaryState - The current state of the forest summary tracking.
169
- * @param trackedSummaryProperties - The properties of the tracked summary, which must be undefined.
170
- */
171
- function validateReadyToTrackSummary(
172
- forestSummaryState: ForestSummaryTrackingState,
173
- trackedSummaryProperties: TrackedSummaryProperties | undefined,
174
- ): asserts trackedSummaryProperties is undefined {
175
- assert(
176
- forestSummaryState === ForestSummaryTrackingState.ReadyToTrack,
177
- 0xc24 /* Already tracking a summary */,
178
- );
179
- assert(
180
- trackedSummaryProperties === undefined,
181
- 0xc25 /* Tracked summary properties must not be available when ready to track */,
182
- );
183
- }
184
-
185
135
  /* eslint-disable jsdoc/check-indentation */
186
136
  /**
187
137
  * Tracks and builds the incremental summary tree for a forest where chunks that support incremental encoding are
@@ -235,19 +185,29 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
235
185
  > = new Map();
236
186
 
237
187
  /**
238
- * The state indicating whether a summary is currently being tracked or not.
188
+ * True when encoding a summary, false otherwise.
189
+ * @remarks
190
+ * Exposed for testing purposes.
239
191
  */
240
- public forestSummaryState: ForestSummaryTrackingState =
241
- ForestSummaryTrackingState.ReadyToTrack;
242
-
192
+ public get isSummarizing(): boolean {
193
+ return this.trackedSummaryProperties !== undefined;
194
+ }
243
195
  /**
244
196
  * The sequence number of the latest summary that was successful.
245
197
  */
246
198
  private latestSummarySequenceNumber: number = -1;
247
199
 
248
200
  /**
249
- * The current state of the summary being tracked.
250
- * This is undefined if no summary is currently being tracked.
201
+ * The current state of the summary being "tracked".
202
+ * @remarks
203
+ * A summary being "tracked" means that a summary is being encoded.
204
+ * This is undefined if no summary is currently being encoded.
205
+ *
206
+ * @privateRemarks
207
+ * This has nothing to do which how content from a summary being loaded is tracked (thats written all in chunkTrackingPropertiesMap).
208
+ * "Tracked" should probably be renamed to "encoded" or "summarizing" or something like that to avoid confusion.
209
+ * Perhaps a better way to clarify this would be to not store this property on this object at all, and have it
210
+ * only exist within the scope of the summary encoding (use an encoding specific object to accumulate any stat necessary during encode).
251
211
  */
252
212
  private trackedSummaryProperties: TrackedSummaryProperties | undefined;
253
213
 
@@ -321,6 +281,15 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
321
281
  await downloadChunkContentsInTree(forestTree, "");
322
282
  }
323
283
 
284
+ /**
285
+ * Asserts that a summary is currently being tracked and that the tracked summary properties are defined.
286
+ * @returns The properties of the tracked summary.
287
+ */
288
+ private requireTrackingSummary(): TrackedSummaryProperties {
289
+ assert(this.trackedSummaryProperties !== undefined, 0xc22 /* Not tracking a summary */);
290
+ return this.trackedSummaryProperties;
291
+ }
292
+
324
293
  /**
325
294
  * Must be called when starting a new forest summary to track it.
326
295
  * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain
@@ -336,6 +305,11 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
336
305
  stringify: SummaryElementStringifier;
337
306
  builder: SummaryTreeBuilder;
338
307
  }): ForestIncrementalSummaryBehavior {
308
+ assert(
309
+ this.trackedSummaryProperties === undefined,
310
+ 0xc24 /* Already tracking a summary */,
311
+ );
312
+
339
313
  const { fullTree, incrementalSummaryContext, stringify, builder } = args;
340
314
  // If there is no incremental summary context, do not summarize incrementally. This happens in two scenarios:
341
315
  // 1. When summarizing a detached container, i.e., the first ever summary.
@@ -344,9 +318,6 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
344
318
  return ForestIncrementalSummaryBehavior.SingleBlob;
345
319
  }
346
320
 
347
- validateReadyToTrackSummary(this.forestSummaryState, this.trackedSummaryProperties);
348
-
349
- this.forestSummaryState = ForestSummaryTrackingState.Tracking;
350
321
  this.latestSummarySequenceNumber = incrementalSummaryContext.latestSummarySequenceNumber;
351
322
  this.trackedSummaryProperties = {
352
323
  summarySequenceNumber: incrementalSummaryContext.summarySequenceNumber,
@@ -368,7 +339,7 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
368
339
  chunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,
369
340
  ): ChunkReferenceId[] {
370
341
  // Validate that a summary is currently being tracked and that the tracked summary properties are defined.
371
- validateTrackingSummary(this.forestSummaryState, this.trackedSummaryProperties);
342
+ const trackedSummaryProperties = this.requireTrackingSummary();
372
343
 
373
344
  const chunkReferenceIds: ChunkReferenceId[] = [];
374
345
  const chunks = this.getChunkAtCursor(cursor);
@@ -383,12 +354,12 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
383
354
  this.latestSummarySequenceNumber,
384
355
  chunk,
385
356
  );
386
- if (previousChunkProperties !== undefined && !this.trackedSummaryProperties.fullTree) {
357
+ if (previousChunkProperties !== undefined && !trackedSummaryProperties.fullTree) {
387
358
  chunkProperties = previousChunkProperties;
388
- this.trackedSummaryProperties.parentSummaryBuilder.addHandle(
359
+ trackedSummaryProperties.parentSummaryBuilder.addHandle(
389
360
  `${chunkProperties.referenceId}`,
390
361
  SummaryType.Tree,
391
- `${this.trackedSummaryProperties.latestSummaryBasePath}/${chunkProperties.summaryPath}`,
362
+ `${trackedSummaryProperties.latestSummaryBasePath}/${chunkProperties.summaryPath}`,
392
363
  );
393
364
  } else {
394
365
  // Generate a new reference ID for the chunk.
@@ -398,23 +369,23 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
398
369
  // for the chunk in its summary properties.
399
370
  // This is done before encoding the chunk so that the summary path is updated correctly when encoding
400
371
  // any incremental chunks that are under this chunk.
401
- this.trackedSummaryProperties.chunkSummaryPath.push(newReferenceId);
372
+ trackedSummaryProperties.chunkSummaryPath.push(newReferenceId);
402
373
 
403
374
  chunkProperties = {
404
375
  referenceId: newReferenceId,
405
- summaryPath: this.trackedSummaryProperties.chunkSummaryPath.join("/"),
376
+ summaryPath: trackedSummaryProperties.chunkSummaryPath.join("/"),
406
377
  };
407
378
 
408
- const parentSummaryBuilder = this.trackedSummaryProperties.parentSummaryBuilder;
379
+ const parentSummaryBuilder = trackedSummaryProperties.parentSummaryBuilder;
409
380
  // Create a new summary builder for this chunk to build its summary tree which will be stored in the
410
381
  // parent's summary tree under its reference ID.
411
382
  // Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that
412
383
  // any incremental chunks in the subtree of this chunk will use that as their parent summary builder.
413
384
  const chunkSummaryBuilder = new SummaryTreeBuilder();
414
- this.trackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;
385
+ trackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;
415
386
  chunkSummaryBuilder.addBlob(
416
387
  summaryContentBlobKey,
417
- this.trackedSummaryProperties.stringify(chunkEncoder(chunk)),
388
+ trackedSummaryProperties.stringify(chunkEncoder(chunk)),
418
389
  );
419
390
 
420
391
  // Add this chunk's summary tree to the parent's summary tree. The summary tree contains its encoded
@@ -425,13 +396,13 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
425
396
  );
426
397
 
427
398
  // Restore the parent summary builder and chunk summary path.
428
- this.trackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;
429
- this.trackedSummaryProperties.chunkSummaryPath.pop();
399
+ trackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;
400
+ trackedSummaryProperties.chunkSummaryPath.pop();
430
401
  }
431
402
 
432
403
  setInNestedMap(
433
404
  this.chunkTrackingPropertiesMap,
434
- this.trackedSummaryProperties.summarySequenceNumber,
405
+ trackedSummaryProperties.summarySequenceNumber,
435
406
  chunk,
436
407
  chunkProperties,
437
408
  );
@@ -469,7 +440,7 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
469
440
  return;
470
441
  }
471
442
 
472
- validateTrackingSummary(this.forestSummaryState, this.trackedSummaryProperties);
443
+ const trackedSummaryProperties = this.requireTrackingSummary();
473
444
 
474
445
  builder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);
475
446
 
@@ -481,7 +452,7 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
481
452
  this.latestSummarySequenceNumber,
482
453
  );
483
454
  const currentSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(
484
- this.trackedSummaryProperties.summarySequenceNumber,
455
+ trackedSummaryProperties.summarySequenceNumber,
485
456
  );
486
457
  if (latestSummaryTrackingMap !== undefined && currentSummaryTrackingMap !== undefined) {
487
458
  for (const [chunk, chunkProperties] of latestSummaryTrackingMap.entries()) {
@@ -499,7 +470,6 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
499
470
  }
500
471
  }
501
472
 
502
- this.forestSummaryState = ForestSummaryTrackingState.ReadyToTrack;
503
473
  this.trackedSummaryProperties = undefined;
504
474
  }
505
475
 
@@ -4,5 +4,5 @@
4
4
  */
5
5
 
6
6
  export { ForestSummarizer } from "./forestSummarizer.js";
7
- export { getCodecTreeForForestFormat } from "./codec.js";
7
+ export { forestCodecBuilder } from "./codec.js";
8
8
  export { ForestFormatVersion } from "./formatCommon.js";
@@ -11,7 +11,7 @@ export { allowsValue, assertAllowedValue, isTreeValue } from "./valueUtilities.j
11
11
 
12
12
  export {
13
13
  ForestSummarizer,
14
- getCodecTreeForForestFormat,
14
+ forestCodecBuilder,
15
15
  ForestFormatVersion,
16
16
  } from "./forest-summary/index.js";
17
17
  export {
@@ -104,9 +104,8 @@ export {
104
104
  type FieldBatch,
105
105
  type FieldBatchCodec,
106
106
  FieldBatchFormatVersion,
107
- getCodecTreeForFieldBatchFormat,
108
107
  makeTreeChunker,
109
- makeFieldBatchCodec,
108
+ fieldBatchCodecBuilder,
110
109
  type FieldBatchEncodingContext,
111
110
  emptyChunk,
112
111
  combineChunks,
@@ -204,7 +203,6 @@ export {
204
203
  AnchorTreeIndex,
205
204
  hasElement,
206
205
  type TreeIndex,
207
- type TreeIndexKey,
208
206
  type TreeIndexNodes,
209
207
  } from "./indexing/index.js";
210
208
 
@@ -27,7 +27,7 @@ import {
27
27
  import { disposeSymbol, getOrCreate } from "../../util/index.js";
28
28
  import { TreeStatus } from "../flex-tree/index.js";
29
29
 
30
- import type { TreeIndex, TreeIndexKey, TreeIndexNodes } from "./types.js";
30
+ import type { TreeIndex, TreeIndexNodes } from "./types.js";
31
31
 
32
32
  /**
33
33
  * A function that gets the value to index a node on, must be pure and functional.
@@ -40,7 +40,7 @@ import type { TreeIndex, TreeIndexKey, TreeIndexNodes } from "./types.js";
40
40
  * but returns the cursor to the state it was in before being passed to the function. It should also not be disposed by this function
41
41
  * and must be disposed elsewhere.
42
42
  */
43
- export type KeyFinder<TKey extends TreeIndexKey> = (tree: ITreeSubscriptionCursor) => TKey;
43
+ export type KeyFinder<TKey> = (tree: ITreeSubscriptionCursor) => TKey;
44
44
 
45
45
  /**
46
46
  * An index from some arbitrary keys to anchor nodes. Keys can be anything that is a {@link TreeValue}.
@@ -50,9 +50,7 @@ export type KeyFinder<TKey extends TreeIndexKey> = (tree: ITreeSubscriptionCurso
50
50
  * Detached nodes are stored in the index but filtered out when any public facing apis are called. This means that
51
51
  * calling {@link keys} will not include any keys that are stored in the index but only map to detached nodes.
52
52
  */
53
- export class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>
54
- implements TreeIndex<TKey, TValue>
55
- {
53
+ export class AnchorTreeIndex<TKey, TValue> implements TreeIndex<TKey, TValue> {
56
54
  public disposed = false;
57
55
  /**
58
56
  * Caches {@link KeyFinder}s for each schema definition. If a schema maps to null, it does not
@@ -8,4 +8,4 @@ export {
8
8
  type KeyFinder,
9
9
  hasElement,
10
10
  } from "./anchorTreeIndex.js";
11
- export type { TreeIndex, TreeIndexKey, TreeIndexNodes } from "./types.js";
11
+ export type { TreeIndex, TreeIndexNodes } from "./types.js";
@@ -3,8 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { IFluidHandle } from "@fluidframework/core-interfaces";
7
-
8
6
  /**
9
7
  * an array of nodes that is guaranteed to have at least one element
10
8
  *
@@ -13,25 +11,25 @@ import type { IFluidHandle } from "@fluidframework/core-interfaces";
13
11
  export type TreeIndexNodes<TNode> = readonly [first: TNode, ...rest: TNode[]];
14
12
 
15
13
  /**
16
- * Value that may be used as keys in a {@link TreeIndex}.
17
- *
14
+ * An index allows lookup content from a tree using keys.
15
+ * @remarks
16
+ * The index will be kept up to date with the {@link TreeBranchAlpha} it is associated with.
17
+ * Keeping an index up to date incurs overhead.
18
+ * Therefore, indexes should only be created when needed and disposed when no longer needed.
18
19
  * @privateRemarks
19
- * no-new-null is disabled for this type so that it supports the TreeValue type.
20
- *
21
- * @alpha
22
- */
23
- // eslint-disable-next-line @rushstack/no-new-null
24
- export type TreeIndexKey = number | string | boolean | IFluidHandle | null;
25
-
26
- /**
27
- * A index where values are keyed on {@link TreeIndexKey}s.
28
- *
20
+ * We have various disposable interfaces. Perhaps this should extend one.
21
+ * Currently all of these indexes are generated on load and exist only in memory (do not persist anything to the document).
22
+ * In the future, we may want to support indexes which persist some content, allowing them to be kept up to date when when only loading part of a tree.
23
+ * Since currently partially loading a tree is not supported, there is no need for this.
24
+ * At some point the low level shared tree index type for persisted indexes could be leveraged to provide user facing extensible sets of persisted indexes.
25
+ * @sealed
29
26
  * @alpha
30
27
  */
31
- export interface TreeIndex<TKey extends TreeIndexKey, TValue>
32
- extends ReadonlyMap<TKey, TValue> {
28
+ export interface TreeIndex<TKey, TValue> extends ReadonlyMap<TKey, TValue> {
33
29
  /**
34
- * Disposes the index such that it can no longer be used and receives no updates from the forest
30
+ * Disposes the index such that it can no longer be used and receives no updates for changes in the tree.
31
+ * @remarks
32
+ * An index may not be used after it is disposed.
35
33
  */
36
34
  dispose(): void;
37
35
  }