@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
@@ -6,6 +6,6 @@ export { uniformChunk, ChunkShape } from "./uniformChunk.js";
6
6
  export { type TreeChunk, dummyRoot } from "../../core/index.js";
7
7
  export { chunkTree, defaultChunkPolicy, makeTreeChunker, type IChunker, chunkFieldSingle, chunkField, combineChunks, } from "./chunkTree.js";
8
8
  export { buildChunkedForest } from "./chunkedForest.js";
9
- export { EncodedFieldBatch, FieldBatchFormatVersion, getCodecTreeForFieldBatchFormat, type FieldBatch, type FieldBatchCodec, makeFieldBatchCodec, type FieldBatchEncodingContext, type IncrementalEncoderDecoder, type ChunkReferenceId, type IncrementalEncodingPolicy, defaultIncrementalEncodingPolicy, } from "./codec/index.js";
9
+ export { type EncodedFieldBatch, FieldBatchFormatVersion, type FieldBatch, type FieldBatchCodec, fieldBatchCodecBuilder, type FieldBatchEncodingContext, type IncrementalEncoderDecoder, type ChunkReferenceId, type IncrementalEncodingPolicy, defaultIncrementalEncodingPolicy, } from "./codec/index.js";
10
10
  export { emptyChunk } from "./emptyChunk.js";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,+BAA+B,EAC/B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,gCAAgC,GAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,KAAK,QAAQ,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,gCAAgC,GAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.emptyChunk = exports.defaultIncrementalEncodingPolicy = exports.makeFieldBatchCodec = exports.getCodecTreeForFieldBatchFormat = exports.FieldBatchFormatVersion = exports.EncodedFieldBatch = exports.buildChunkedForest = exports.combineChunks = exports.chunkField = exports.chunkFieldSingle = exports.makeTreeChunker = exports.defaultChunkPolicy = exports.chunkTree = exports.dummyRoot = exports.ChunkShape = exports.uniformChunk = void 0;
7
+ exports.emptyChunk = exports.defaultIncrementalEncodingPolicy = exports.fieldBatchCodecBuilder = exports.FieldBatchFormatVersion = exports.buildChunkedForest = exports.combineChunks = exports.chunkField = exports.chunkFieldSingle = exports.makeTreeChunker = exports.defaultChunkPolicy = exports.chunkTree = exports.dummyRoot = exports.ChunkShape = exports.uniformChunk = void 0;
8
8
  var uniformChunk_js_1 = require("./uniformChunk.js");
9
9
  Object.defineProperty(exports, "uniformChunk", { enumerable: true, get: function () { return uniformChunk_js_1.uniformChunk; } });
10
10
  Object.defineProperty(exports, "ChunkShape", { enumerable: true, get: function () { return uniformChunk_js_1.ChunkShape; } });
@@ -20,10 +20,8 @@ Object.defineProperty(exports, "combineChunks", { enumerable: true, get: functio
20
20
  var chunkedForest_js_1 = require("./chunkedForest.js");
21
21
  Object.defineProperty(exports, "buildChunkedForest", { enumerable: true, get: function () { return chunkedForest_js_1.buildChunkedForest; } });
22
22
  var index_js_2 = require("./codec/index.js");
23
- Object.defineProperty(exports, "EncodedFieldBatch", { enumerable: true, get: function () { return index_js_2.EncodedFieldBatch; } });
24
23
  Object.defineProperty(exports, "FieldBatchFormatVersion", { enumerable: true, get: function () { return index_js_2.FieldBatchFormatVersion; } });
25
- Object.defineProperty(exports, "getCodecTreeForFieldBatchFormat", { enumerable: true, get: function () { return index_js_2.getCodecTreeForFieldBatchFormat; } });
26
- Object.defineProperty(exports, "makeFieldBatchCodec", { enumerable: true, get: function () { return index_js_2.makeFieldBatchCodec; } });
24
+ Object.defineProperty(exports, "fieldBatchCodecBuilder", { enumerable: true, get: function () { return index_js_2.fieldBatchCodecBuilder; } });
27
25
  Object.defineProperty(exports, "defaultIncrementalEncodingPolicy", { enumerable: true, get: function () { return index_js_2.defaultIncrementalEncodingPolicy; } });
28
26
  var emptyChunk_js_1 = require("./emptyChunk.js");
29
27
  Object.defineProperty(exports, "emptyChunk", { enumerable: true, get: function () { return emptyChunk_js_1.emptyChunk; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAA6D;AAApD,+GAAA,YAAY,OAAA;AAAE,6GAAA,UAAU,OAAA;AACjC,gDAAgE;AAAvC,qGAAA,SAAS,OAAA;AAClC,+CAQwB;AAPvB,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AAEf,gHAAA,gBAAgB,OAAA;AAChB,0GAAA,UAAU,OAAA;AACV,6GAAA,aAAa,OAAA;AAEd,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,6CAY0B;AAXzB,6GAAA,iBAAiB,OAAA;AACjB,mHAAA,uBAAuB,OAAA;AACvB,2HAAA,+BAA+B,OAAA;AAG/B,+GAAA,mBAAmB,OAAA;AAKnB,4HAAA,gCAAgC,OAAA;AAEjC,iDAA6C;AAApC,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { uniformChunk, ChunkShape } from \"./uniformChunk.js\";\nexport { type TreeChunk, dummyRoot } from \"../../core/index.js\";\nexport {\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tmakeTreeChunker,\n\ttype IChunker,\n\tchunkFieldSingle,\n\tchunkField,\n\tcombineChunks,\n} from \"./chunkTree.js\";\nexport { buildChunkedForest } from \"./chunkedForest.js\";\nexport {\n\tEncodedFieldBatch,\n\tFieldBatchFormatVersion,\n\tgetCodecTreeForFieldBatchFormat,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeFieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n\ttype IncrementalEncoderDecoder,\n\ttype ChunkReferenceId,\n\ttype IncrementalEncodingPolicy,\n\tdefaultIncrementalEncodingPolicy,\n} from \"./codec/index.js\";\nexport { emptyChunk } from \"./emptyChunk.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAA6D;AAApD,+GAAA,YAAY,OAAA;AAAE,6GAAA,UAAU,OAAA;AACjC,gDAAgE;AAAvC,qGAAA,SAAS,OAAA;AAClC,+CAQwB;AAPvB,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AAEf,gHAAA,gBAAgB,OAAA;AAChB,0GAAA,UAAU,OAAA;AACV,6GAAA,aAAa,OAAA;AAEd,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,6CAW0B;AATzB,mHAAA,uBAAuB,OAAA;AAGvB,kHAAA,sBAAsB,OAAA;AAKtB,4HAAA,gCAAgC,OAAA;AAEjC,iDAA6C;AAApC,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { uniformChunk, ChunkShape } from \"./uniformChunk.js\";\nexport { type TreeChunk, dummyRoot } from \"../../core/index.js\";\nexport {\n\tchunkTree,\n\tdefaultChunkPolicy,\n\tmakeTreeChunker,\n\ttype IChunker,\n\tchunkFieldSingle,\n\tchunkField,\n\tcombineChunks,\n} from \"./chunkTree.js\";\nexport { buildChunkedForest } from \"./chunkedForest.js\";\nexport {\n\ttype EncodedFieldBatch,\n\tFieldBatchFormatVersion,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tfieldBatchCodecBuilder,\n\ttype FieldBatchEncodingContext,\n\ttype IncrementalEncoderDecoder,\n\ttype ChunkReferenceId,\n\ttype IncrementalEncodingPolicy,\n\tdefaultIncrementalEncodingPolicy,\n} from \"./codec/index.js\";\nexport { emptyChunk } from \"./emptyChunk.js\";\n"]}
@@ -10,8 +10,25 @@ import type { FlexTreeNode } from "./flexTreeTypes.js";
10
10
  * See {@link withObservation} and {@link currentObserver}.
11
11
  */
12
12
  export interface Observer {
13
+ /**
14
+ * Arbitrary content in `node` subtree might be observed.
15
+ */
16
+ observeNodeDeep(node: FlexTreeNode): void;
17
+ /**
18
+ * Which fields exist (as non-empty) on `node` is being observed.
19
+ * @remarks
20
+ * The set of fields should be considered order independent.
21
+ */
13
22
  observeNodeFields(node: FlexTreeNode): void;
23
+ /**
24
+ * The contents of the `key` field of `node` are being observed.
25
+ * @remarks
26
+ * Any (shallow) change to which children exist in this field, or in what order should invalidate this observation.
27
+ */
14
28
  observeNodeField(node: FlexTreeNode, key: FieldKey): void;
29
+ /**
30
+ * The parent of `node` is being observed.
31
+ */
15
32
  observeParentOf(node: FlexTreeNode): void;
16
33
  }
17
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/observer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASvD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACxB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5C,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1D,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,eAAO,IAAI,eAAe,EAAE,QAAQ,GAAG,SAAS,CAAC;AAgBjD;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAOnF"}
1
+ {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/observer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASvD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1C;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5C;;;;OAIG;IACH,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1D;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,eAAO,IAAI,eAAe,EAAE,QAAQ,GAAG,SAAS,CAAC;AAgBjD;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAOnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"observer.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/observer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAoClE,MAAM,aAAa,GAA6B,EAAE,CAAC;AAEnD,SAAS,WAAW,CAAC,WAAiC;IACrD,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChC,uBAAe,GAAG,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa;IACrB,IAAA,sBAAW,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,+BAA+B,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;IACnC,IAAA,sBAAW,EAAC,GAAG,EAAE,CAAC,MAAM,KAAK,uBAAe,IAAI,2BAA2B,CAAC,CAAC;IAC7E,uBAAe,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAI,WAAiC,EAAE,CAAU;IAC/E,WAAW,CAAC,WAAW,CAAC,CAAC;IACzB,IAAI,CAAC;QACJ,OAAO,CAAC,EAAE,CAAC;IACZ,CAAC;YAAS,CAAC;QACV,aAAa,EAAE,CAAC;IACjB,CAAC;AACF,CAAC;AAPD,0CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { debugAssert } from \"@fluidframework/core-utils/internal\";\n\nimport type { FieldKey } from \"../../core/index.js\";\n\nimport type { FlexTreeNode } from \"./flexTreeTypes.js\";\n\n/*\n * This file sets up a static observation tracking system.\n *\n * This library used to contain a more general variant of this which was deleted in https://github.com/microsoft/FluidFramework/pull/18659.\n * This pattern somewhat resembles the approach in https://github.com/tc39/proposal-signals.\n */\n\n/**\n * An object informed about observation made to trees.\n * @remarks\n * See {@link withObservation} and {@link currentObserver}.\n */\nexport interface Observer {\n\tobserveNodeFields(node: FlexTreeNode): void;\n\tobserveNodeField(node: FlexTreeNode, key: FieldKey): void;\n\tobserveParentOf(node: FlexTreeNode): void;\n}\n\n/**\n * The current observer, if any.\n * @remarks\n * Set via {@link setObserver} as used by {@link withObservation}.\n * It should not be assigned in any other way.\n * @privateRemarks\n * This is exported directly as a property instead of via a getter for reduced overhead (less code, faster access) as this is used on some hot paths and its performance matters.\n * The case where this is undefined (no observation) is particularly important for performance as we do not want to regress code which is not using this feature very much.\n * Since it is not exported outside the package, this seems like a fine tradeoff, but could be reevaluated with some benchmarking if needed.\n */\nexport let currentObserver: Observer | undefined;\n\nconst observerStack: (Observer | undefined)[] = [];\n\nfunction setObserver(newObserver: Observer | undefined): void {\n\tobserverStack.push(newObserver);\n\tcurrentObserver = newObserver;\n}\n\nfunction clearObserver(): void {\n\tdebugAssert(() => observerStack.length > 0 || \"Empty Observer stack on clear\");\n\tconst popped = observerStack.pop();\n\tdebugAssert(() => popped === currentObserver || \"Mismatched observer stack\");\n\tcurrentObserver = observerStack[observerStack.length - 1];\n}\n\n/**\n * For the duration of `f`, pushes `newObserver` onto the observer stack, making it the {@link currentObserver}.\n */\nexport function withObservation<T>(newObserver: Observer | undefined, f: () => T): T {\n\tsetObserver(newObserver);\n\ttry {\n\t\treturn f();\n\t} finally {\n\t\tclearObserver();\n\t}\n}\n"]}
1
+ {"version":3,"file":"observer.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/observer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAqDlE,MAAM,aAAa,GAA6B,EAAE,CAAC;AAEnD,SAAS,WAAW,CAAC,WAAiC;IACrD,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChC,uBAAe,GAAG,WAAW,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa;IACrB,IAAA,sBAAW,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,+BAA+B,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;IACnC,IAAA,sBAAW,EAAC,GAAG,EAAE,CAAC,MAAM,KAAK,uBAAe,IAAI,2BAA2B,CAAC,CAAC;IAC7E,uBAAe,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAI,WAAiC,EAAE,CAAU;IAC/E,WAAW,CAAC,WAAW,CAAC,CAAC;IACzB,IAAI,CAAC;QACJ,OAAO,CAAC,EAAE,CAAC;IACZ,CAAC;YAAS,CAAC;QACV,aAAa,EAAE,CAAC;IACjB,CAAC;AACF,CAAC;AAPD,0CAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { debugAssert } from \"@fluidframework/core-utils/internal\";\n\nimport type { FieldKey } from \"../../core/index.js\";\n\nimport type { FlexTreeNode } from \"./flexTreeTypes.js\";\n\n/*\n * This file sets up a static observation tracking system.\n *\n * This library used to contain a more general variant of this which was deleted in https://github.com/microsoft/FluidFramework/pull/18659.\n * This pattern somewhat resembles the approach in https://github.com/tc39/proposal-signals.\n */\n\n/**\n * An object informed about observation made to trees.\n * @remarks\n * See {@link withObservation} and {@link currentObserver}.\n */\nexport interface Observer {\n\t/**\n\t * Arbitrary content in `node` subtree might be observed.\n\t */\n\tobserveNodeDeep(node: FlexTreeNode): void;\n\t/**\n\t * Which fields exist (as non-empty) on `node` is being observed.\n\t * @remarks\n\t * The set of fields should be considered order independent.\n\t */\n\tobserveNodeFields(node: FlexTreeNode): void;\n\t/**\n\t * The contents of the `key` field of `node` are being observed.\n\t * @remarks\n\t * Any (shallow) change to which children exist in this field, or in what order should invalidate this observation.\n\t */\n\tobserveNodeField(node: FlexTreeNode, key: FieldKey): void;\n\t/**\n\t * The parent of `node` is being observed.\n\t */\n\tobserveParentOf(node: FlexTreeNode): void;\n}\n\n/**\n * The current observer, if any.\n * @remarks\n * Set via {@link setObserver} as used by {@link withObservation}.\n * It should not be assigned in any other way.\n * @privateRemarks\n * This is exported directly as a property instead of via a getter for reduced overhead (less code, faster access) as this is used on some hot paths and its performance matters.\n * The case where this is undefined (no observation) is particularly important for performance as we do not want to regress code which is not using this feature very much.\n * Since it is not exported outside the package, this seems like a fine tradeoff, but could be reevaluated with some benchmarking if needed.\n */\nexport let currentObserver: Observer | undefined;\n\nconst observerStack: (Observer | undefined)[] = [];\n\nfunction setObserver(newObserver: Observer | undefined): void {\n\tobserverStack.push(newObserver);\n\tcurrentObserver = newObserver;\n}\n\nfunction clearObserver(): void {\n\tdebugAssert(() => observerStack.length > 0 || \"Empty Observer stack on clear\");\n\tconst popped = observerStack.pop();\n\tdebugAssert(() => popped === currentObserver || \"Mismatched observer stack\");\n\tcurrentObserver = observerStack[observerStack.length - 1];\n}\n\n/**\n * For the duration of `f`, pushes `newObserver` onto the observer stack, making it the {@link currentObserver}.\n */\nexport function withObservation<T>(newObserver: Observer | undefined, f: () => T): T {\n\tsetObserver(newObserver);\n\ttry {\n\t\treturn f();\n\t} finally {\n\t\tclearObserver();\n\t}\n}\n"]}
@@ -2,23 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
6
- import { type CodecTree, type CodecWriteOptions, type IJsonCodec } from "../../codec/index.js";
5
+ import { ClientVersionDispatchingCodecBuilder, type CodecWriteOptions } from "../../codec/index.js";
7
6
  import type { FieldKey, ITreeCursorSynchronous } from "../../core/index.js";
8
- import { type JsonCompatibleReadOnly } from "../../util/index.js";
9
- import type { FieldBatchCodec, FieldBatchEncodingContext } from "../chunked-forest/index.js";
10
- import { ForestFormatVersion, type Format } from "./formatCommon.js";
7
+ import { type FieldBatchEncodingContext } from "../chunked-forest/index.js";
11
8
  /**
12
9
  * Uses field cursors
13
10
  */
14
11
  export type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;
15
- export type ForestCodec = IJsonCodec<FieldSet, Format, JsonCompatibleReadOnly, FieldBatchEncodingContext>;
12
+ export type ForestCodec = ReturnType<typeof forestCodecBuilder.build>;
16
13
  /**
17
- * Convert a MinimumVersionForCollab to a ForestFormatVersion.
18
- * @param clientVersion - The MinimumVersionForCollab to convert.
19
- * @returns The ForestFormatVersion that corresponds to the provided MinimumVersionForCollab.
14
+ * {@link ClientVersionDispatchingCodecBuilder} for forest summarizer codecs.
20
15
  */
21
- export declare function clientVersionToForestFormatVersion(clientVersion: MinimumVersionForCollab): ForestFormatVersion;
22
- export declare function makeForestSummarizerCodec(options: CodecWriteOptions, fieldBatchCodec: FieldBatchCodec): ForestCodec;
23
- export declare function getCodecTreeForForestFormat(clientVersion: MinimumVersionForCollab): CodecTree;
16
+ export declare const forestCodecBuilder: ClientVersionDispatchingCodecBuilder<"Forest", FieldSet, FieldBatchEncodingContext, import("../../util/brand.js").Brand<1, "ForestFormatVersion"> | import("../../util/brand.js").Brand<2, "ForestFormatVersion">, CodecWriteOptions>;
24
17
  //# sourceMappingURL=codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,UAAU,EAEf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAS,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAiB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIpF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,WAAW,GAAG,UAAU,CACnC,QAAQ,EACR,MAAM,EACN,sBAAsB,EACtB,yBAAyB,CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kCAAkC,CACjD,aAAa,EAAE,uBAAuB,GACpC,mBAAmB,CAOrB;AAED,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,iBAAiB,EAC1B,eAAe,EAAE,eAAe,GAC9B,WAAW,CA2Bb;AAED,wBAAgB,2BAA2B,CAC1C,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAEX"}
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,oCAAoC,EAEpC,KAAK,iBAAiB,EAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAEN,KAAK,yBAAyB,EAC9B,MAAM,4BAA4B,CAAC;AAIpC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAuCtE;;GAEG;AACH,eAAO,MAAM,kBAAkB,uOAa7B,CAAC"}
@@ -4,35 +4,20 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getCodecTreeForForestFormat = exports.makeForestSummarizerCodec = exports.clientVersionToForestFormatVersion = void 0;
7
+ exports.forestCodecBuilder = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/runtime-utils/internal");
10
- const typebox_1 = require("@sinclair/typebox");
11
10
  const index_js_1 = require("../../codec/index.js");
12
- const index_js_2 = require("../../util/index.js");
11
+ const index_js_2 = require("../chunked-forest/index.js");
13
12
  const formatCommon_js_1 = require("./formatCommon.js");
14
- const formatV1_js_1 = require("./formatV1.js");
15
- const formatV2_js_1 = require("./formatV2.js");
16
- /**
17
- * Convert a MinimumVersionForCollab to a ForestFormatVersion.
18
- * @param clientVersion - The MinimumVersionForCollab to convert.
19
- * @returns The ForestFormatVersion that corresponds to the provided MinimumVersionForCollab.
20
- */
21
- function clientVersionToForestFormatVersion(clientVersion) {
22
- return (0, index_js_2.brand)((0, internal_2.getConfigForMinVersionForCollab)(clientVersion, {
23
- [internal_2.lowestMinVersionForCollab]: formatCommon_js_1.ForestFormatVersion.v1,
24
- [index_js_1.FluidClientVersion.v2_74]: formatCommon_js_1.ForestFormatVersion.v2,
25
- }));
26
- }
27
- exports.clientVersionToForestFormatVersion = clientVersionToForestFormatVersion;
28
- function makeForestSummarizerCodec(options, fieldBatchCodec) {
29
- const inner = fieldBatchCodec;
30
- const writeVersion = clientVersionToForestFormatVersion(options.minVersionForCollab);
31
- const formatSchema = typebox_1.Type.Union([formatV1_js_1.FormatV1, formatV2_js_1.FormatV2]);
32
- // Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `formatSchema`.
33
- // This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,
34
- // instead of one call per version, then using another utility to select between them based on version.
35
- return (0, index_js_1.makeVersionedValidatedCodec)(options, formatCommon_js_1.validVersions, formatSchema, {
13
+ function makeForestSummarizerCodec(options, version) {
14
+ // Performance: Since multiple places (including multiple versions of this codec) use the field batch codec,
15
+ // we may end up with multiple copies of it, including compiling its format validation multiple times.
16
+ // 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.
17
+ // If this becomes problematic a cache could be added for options to codec instances somewhere.
18
+ const fieldBatchCodec = index_js_2.fieldBatchCodecBuilder.build(options);
19
+ const formatSchema = formatCommon_js_1.FormatCommon;
20
+ return {
36
21
  encode: (data, context) => {
37
22
  const keys = [];
38
23
  const fields = [];
@@ -40,22 +25,37 @@ function makeForestSummarizerCodec(options, fieldBatchCodec) {
40
25
  keys.push(key);
41
26
  fields.push(value);
42
27
  }
43
- return { keys, fields: inner.encode(fields, context), version: writeVersion };
28
+ return {
29
+ keys,
30
+ fields: fieldBatchCodec.encode(fields, context),
31
+ version,
32
+ };
44
33
  },
45
34
  decode: (data, context) => {
46
35
  const out = new Map();
47
- const fields = inner.decode(data.fields, context);
36
+ const fields = fieldBatchCodec.decode(data.fields, context);
48
37
  (0, internal_1.assert)(data.keys.length === fields.length, 0x891 /* mismatched lengths */);
49
38
  for (const [index, field] of fields.entries()) {
50
39
  out.set(data.keys[index] ?? (0, internal_1.oob)(), field);
51
40
  }
52
41
  return out;
53
42
  },
54
- });
43
+ schema: formatSchema,
44
+ };
55
45
  }
56
- exports.makeForestSummarizerCodec = makeForestSummarizerCodec;
57
- function getCodecTreeForForestFormat(clientVersion) {
58
- return { name: "Forest", version: clientVersionToForestFormatVersion(clientVersion) };
59
- }
60
- exports.getCodecTreeForForestFormat = getCodecTreeForForestFormat;
46
+ /**
47
+ * {@link ClientVersionDispatchingCodecBuilder} for forest summarizer codecs.
48
+ */
49
+ exports.forestCodecBuilder = index_js_1.ClientVersionDispatchingCodecBuilder.build("Forest", [
50
+ {
51
+ minVersionForCollab: internal_2.lowestMinVersionForCollab,
52
+ formatVersion: formatCommon_js_1.ForestFormatVersion.v1,
53
+ codec: (options) => makeForestSummarizerCodec(options, formatCommon_js_1.ForestFormatVersion.v1),
54
+ },
55
+ {
56
+ minVersionForCollab: index_js_1.FluidClientVersion.v2_74,
57
+ formatVersion: formatCommon_js_1.ForestFormatVersion.v2,
58
+ codec: (options) => makeForestSummarizerCodec(options, formatCommon_js_1.ForestFormatVersion.v2),
59
+ },
60
+ ]);
61
61
  //# sourceMappingURL=codec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,qEAGgD;AAChD,+CAAyC;AAEzC,mDAM8B;AAE9B,kDAAyE;AAGzE,uDAAoF;AACpF,+CAAyC;AACzC,+CAAyC;AAazC;;;;GAIG;AACH,SAAgB,kCAAkC,CACjD,aAAsC;IAEtC,OAAO,IAAA,gBAAK,EACX,IAAA,0CAA+B,EAAC,aAAa,EAAE;QAC9C,CAAC,oCAAyB,CAAC,EAAE,qCAAmB,CAAC,EAAE;QACnD,CAAC,6BAAkB,CAAC,KAAK,CAAC,EAAE,qCAAmB,CAAC,EAAE;KAClD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,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC/C,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAA,cAAG,GAAE,EAAE,KAAK,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,GAAG,CAAC;QACZ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA9BD,8DA8BC;AAED,SAAgB,2BAA2B,CAC1C,aAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,kCAAkC,CAAC,aAAa,CAAC,EAAE,CAAC;AACvF,CAAC;AAJD,kEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\nimport { Type } from \"@sinclair/typebox\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../codec/index.js\";\nimport type { FieldKey, ITreeCursorSynchronous } from \"../../core/index.js\";\nimport { brand, type JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { ForestFormatVersion, validVersions, type Format } from \"./formatCommon.js\";\nimport { FormatV1 } from \"./formatV1.js\";\nimport { FormatV2 } from \"./formatV2.js\";\n\n/**\n * Uses field cursors\n */\nexport type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;\nexport type ForestCodec = IJsonCodec<\n\tFieldSet,\n\tFormat,\n\tJsonCompatibleReadOnly,\n\tFieldBatchEncodingContext\n>;\n\n/**\n * Convert a MinimumVersionForCollab to a ForestFormatVersion.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The ForestFormatVersion that corresponds to the provided MinimumVersionForCollab.\n */\nexport function clientVersionToForestFormatVersion(\n\tclientVersion: MinimumVersionForCollab,\n): ForestFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: ForestFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_74]: ForestFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeForestSummarizerCodec(\n\toptions: CodecWriteOptions,\n\tfieldBatchCodec: FieldBatchCodec,\n): ForestCodec {\n\tconst inner = fieldBatchCodec;\n\tconst writeVersion = clientVersionToForestFormatVersion(options.minVersionForCollab);\n\tconst formatSchema = Type.Union([FormatV1, FormatV2]);\n\t// Both the encode and decode logic here support both v1 and v2, as does `validVersions` and `formatSchema`.\n\t// This makes this use of makeVersionedValidatedCodec atypical as it is a single call being used to make a codec that supports all versions,\n\t// instead of one call per version, then using another utility to select between them based on version.\n\treturn makeVersionedValidatedCodec(options, validVersions, formatSchema, {\n\t\tencode: (data: FieldSet, context: FieldBatchEncodingContext): Format => {\n\t\t\tconst keys: FieldKey[] = [];\n\t\t\tconst fields: ITreeCursorSynchronous[] = [];\n\t\t\tfor (const [key, value] of data) {\n\t\t\t\tkeys.push(key);\n\t\t\t\tfields.push(value);\n\t\t\t}\n\t\t\treturn { keys, fields: inner.encode(fields, context), version: writeVersion };\n\t\t},\n\t\tdecode: (data: Format, context: FieldBatchEncodingContext): FieldSet => {\n\t\t\tconst out: Map<FieldKey, ITreeCursorSynchronous> = new Map();\n\t\t\tconst fields = inner.decode(data.fields, context);\n\t\t\tassert(data.keys.length === fields.length, 0x891 /* mismatched lengths */);\n\t\t\tfor (const [index, field] of fields.entries()) {\n\t\t\t\tout.set(data.keys[index] ?? oob(), field);\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\t});\n}\n\nexport function getCodecTreeForForestFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn { name: \"Forest\", version: clientVersionToForestFormatVersion(clientVersion) };\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAClE,qEAAmF;AAEnF,mDAK8B;AAE9B,yDAGoC;AAEpC,uDAAsE;AAQtE,SAAS,yBAAyB,CACjC,OAA0B,EAC1B,OAA4B;IAE5B,4GAA4G;IAC5G,sGAAsG;IACtG,sHAAsH;IACtH,+FAA+F;IAC/F,MAAM,eAAe,GAAG,iCAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,8BAAY,CAAC;IAClC,OAAO;QACN,MAAM,EAAE,CAAC,IAAc,EAAE,OAAkC,EAAgB,EAAE;YAC5E,MAAM,IAAI,GAAe,EAAE,CAAC;YAC5B,MAAM,MAAM,GAA6B,EAAE,CAAC;YAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;gBACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;YACD,OAAO;gBACN,IAAI;gBACJ,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAC/C,OAAO;aACP,CAAC;QACH,CAAC;QACD,MAAM,EAAE,CAAC,IAAkB,EAAE,OAAkC,EAAY,EAAE;YAC5E,MAAM,GAAG,GAA0C,IAAI,GAAG,EAAE,CAAC;YAC7D,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5D,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC3E,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC/C,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAA,cAAG,GAAE,EAAE,KAAK,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,EAAE,YAAY;KACpB,CAAC;AACH,CAAC;AAED;;GAEG;AACU,QAAA,kBAAkB,GAAG,+CAAoC,CAAC,KAAK,CAAC,QAAQ,EAAE;IACtF;QACC,mBAAmB,EAAE,oCAAyB;QAC9C,aAAa,EAAE,qCAAmB,CAAC,EAAE;QACrC,KAAK,EAAE,CAAC,OAA0B,EAAE,EAAE,CACrC,yBAAyB,CAAC,OAAO,EAAE,qCAAmB,CAAC,EAAE,CAAC;KAC3D;IACD;QACC,mBAAmB,EAAE,6BAAkB,CAAC,KAAK;QAC7C,aAAa,EAAE,qCAAmB,CAAC,EAAE;QACrC,KAAK,EAAE,CAAC,OAA0B,EAAE,EAAE,CACrC,yBAAyB,CAAC,OAAO,EAAE,qCAAmB,CAAC,EAAE,CAAC;KAC3D;CACD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecAndSchema,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n} from \"../../codec/index.js\";\nimport type { FieldKey, ITreeCursorSynchronous } from \"../../core/index.js\";\nimport {\n\tfieldBatchCodecBuilder,\n\ttype FieldBatchEncodingContext,\n} from \"../chunked-forest/index.js\";\n\nimport { ForestFormatVersion, FormatCommon } from \"./formatCommon.js\";\n\n/**\n * Uses field cursors\n */\nexport type FieldSet = ReadonlyMap<FieldKey, ITreeCursorSynchronous>;\nexport type ForestCodec = ReturnType<typeof forestCodecBuilder.build>;\n\nfunction makeForestSummarizerCodec(\n\toptions: CodecWriteOptions,\n\tversion: ForestFormatVersion,\n): CodecAndSchema<FieldSet, FieldBatchEncodingContext> {\n\t// Performance: Since multiple places (including multiple versions of this codec) use the field batch codec,\n\t// we may end up with multiple copies of it, including compiling its format validation multiple times.\n\t// 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.\n\t// If this becomes problematic a cache could be added for options to codec instances somewhere.\n\tconst fieldBatchCodec = fieldBatchCodecBuilder.build(options);\n\tconst formatSchema = FormatCommon;\n\treturn {\n\t\tencode: (data: FieldSet, context: FieldBatchEncodingContext): FormatCommon => {\n\t\t\tconst keys: FieldKey[] = [];\n\t\t\tconst fields: ITreeCursorSynchronous[] = [];\n\t\t\tfor (const [key, value] of data) {\n\t\t\t\tkeys.push(key);\n\t\t\t\tfields.push(value);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkeys,\n\t\t\t\tfields: fieldBatchCodec.encode(fields, context),\n\t\t\t\tversion,\n\t\t\t};\n\t\t},\n\t\tdecode: (data: FormatCommon, context: FieldBatchEncodingContext): FieldSet => {\n\t\t\tconst out: Map<FieldKey, ITreeCursorSynchronous> = new Map();\n\t\t\tconst fields = fieldBatchCodec.decode(data.fields, context);\n\t\t\tassert(data.keys.length === fields.length, 0x891 /* mismatched lengths */);\n\t\t\tfor (const [index, field] of fields.entries()) {\n\t\t\t\tout.set(data.keys[index] ?? oob(), field);\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\t\tschema: formatSchema,\n\t};\n}\n\n/**\n * {@link ClientVersionDispatchingCodecBuilder} for forest summarizer codecs.\n */\nexport const forestCodecBuilder = ClientVersionDispatchingCodecBuilder.build(\"Forest\", [\n\t{\n\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\tformatVersion: ForestFormatVersion.v1,\n\t\tcodec: (options: CodecWriteOptions) =>\n\t\t\tmakeForestSummarizerCodec(options, ForestFormatVersion.v1),\n\t},\n\t{\n\t\tminVersionForCollab: FluidClientVersion.v2_74,\n\t\tformatVersion: ForestFormatVersion.v2,\n\t\tcodec: (options: CodecWriteOptions) =>\n\t\t\tmakeForestSummarizerCodec(options, ForestFormatVersion.v2),\n\t},\n]);\n"]}
@@ -9,7 +9,7 @@ import type { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal"
9
9
  import type { CodecWriteOptions } from "../../codec/index.js";
10
10
  import { type IEditableForest, type RevisionTagCodec } from "../../core/index.js";
11
11
  import { VersionedSummarizer, type Summarizable, type SummaryElementParser, type SummaryElementStringifier } from "../../shared-tree-core/index.js";
12
- import { type FieldBatchCodec, type FieldBatchEncodingContext, type IncrementalEncodingPolicy } from "../chunked-forest/index.js";
12
+ import { type FieldBatchEncodingContext, type IncrementalEncodingPolicy } from "../chunked-forest/index.js";
13
13
  import { ForestSummaryFormatVersion } from "./summaryFormatCommon.js";
14
14
  /**
15
15
  * Provides methods for summarizing and loading a forest.
@@ -25,7 +25,7 @@ export declare class ForestSummarizer extends VersionedSummarizer<ForestSummaryF
25
25
  /**
26
26
  * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.
27
27
  */
28
- constructor(forest: IEditableForest, revisionTagCodec: RevisionTagCodec, fieldBatchCodec: FieldBatchCodec, encoderContext: FieldBatchEncodingContext, options: CodecWriteOptions, idCompressor: IIdCompressor, initialSequenceNumber: number, shouldEncodeIncrementally?: IncrementalEncodingPolicy);
28
+ constructor(forest: IEditableForest, revisionTagCodec: RevisionTagCodec, encoderContext: FieldBatchEncodingContext, options: CodecWriteOptions, idCompressor: IIdCompressor, initialSequenceNumber: number, shouldEncodeIncrementally?: IncrementalEncodingPolicy);
29
29
  /**
30
30
  * Summarization of the forest's tree content.
31
31
  * @returns a summary tree containing the forest's tree content.
@@ -1 +1 @@
1
- {"version":3,"file":"forestSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libra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AQpC,OAAO,EACN,0BAA0B,EAG1B,MAAM,0BAA0B,CAAC;AAMlC;;GAEG;AACH,qBAAa,gBACZ,SAAQ,mBAAmB,CAAC,0BAA0B,CACtD,YAAW,YAAY;IAWtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAE/B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAb9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IAEpC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAkC;IAC5E,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAS;IAErD;;OAEG;gBAEe,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,yBAAyB,EAC1D,OAAO,EAAE,iBAAiB,EACT,YAAY,EAAE,aAAa,EAC5C,qBAAqB,EAAE,MAAM,EAC7B,yBAAyB,GAAE,yBAA4D;IAgCxF;;;;;;;;;OASG;IACH,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE;QAClC,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;QACnE,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI;cA8CQ,YAAY,CAC3B,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,0BAA0B,GAAG,SAAS,GAC7C,OAAO,CAAC,IAAI,CAAC;CA8DhB"}
@@ -14,7 +14,6 @@ const chunkTree_js_1 = require("../chunked-forest/chunkTree.js");
14
14
  const index_js_4 = require("../chunked-forest/index.js");
15
15
  const treeCompressionUtils_js_1 = require("../treeCompressionUtils.js");
16
16
  const codec_js_1 = require("./codec.js");
17
- const formatCommon_js_1 = require("./formatCommon.js");
18
17
  const incrementalSummaryBuilder_js_1 = require("./incrementalSummaryBuilder.js");
19
18
  const summaryFormatCommon_js_1 = require("./summaryFormatCommon.js");
20
19
  const summaryTypes_js_1 = require("./summaryTypes.js");
@@ -25,19 +24,19 @@ class ForestSummarizer extends index_js_2.VersionedSummarizer {
25
24
  /**
26
25
  * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.
27
26
  */
28
- constructor(forest, revisionTagCodec, fieldBatchCodec, encoderContext, options, idCompressor, initialSequenceNumber, shouldEncodeIncrementally = index_js_4.defaultIncrementalEncodingPolicy) {
27
+ constructor(forest, revisionTagCodec, encoderContext, options, idCompressor, initialSequenceNumber, shouldEncodeIncrementally = index_js_4.defaultIncrementalEncodingPolicy) {
29
28
  super(summaryFormatCommon_js_1.forestSummaryKey, (0, summaryTypes_js_1.minVersionToForestSummaryFormatVersion)(options.minVersionForCollab), summaryFormatCommon_js_1.supportedForestSummaryFormatVersions, true /* supportPreVersioningFormat */);
30
29
  this.forest = forest;
31
30
  this.revisionTagCodec = revisionTagCodec;
32
31
  this.encoderContext = encoderContext;
33
32
  this.idCompressor = idCompressor;
34
- this.codec = (0, codec_js_1.makeForestSummarizerCodec)(options, fieldBatchCodec);
35
- const forestFormatWriteVersion = (0, codec_js_1.clientVersionToForestFormatVersion)(options.minVersionForCollab);
33
+ this.codec = codec_js_1.forestCodecBuilder.build(options);
36
34
  const summaryFormatWriteVersion = (0, summaryTypes_js_1.minVersionToForestSummaryFormatVersion)(options.minVersionForCollab);
37
35
  this.forestRootSummaryContentKey = (0, summaryTypes_js_1.getForestRootSummaryContentKey)(summaryFormatWriteVersion);
38
- // Incremental summary is supported from ForestFormatVersion.v2 and ForestSummaryFormatVersion.v3 onwards.
39
- const enableIncrementalSummary = forestFormatWriteVersion >= formatCommon_js_1.ForestFormatVersion.v2 &&
40
- summaryFormatWriteVersion >= summaryFormatCommon_js_1.ForestSummaryFormatVersion.v3 &&
36
+ // Incremental summary is supported in ForestSummaryFormatVersion.v3 onwards.
37
+ // Note that even in versions that support it, it is possible that the
38
+ // FieldBatchCodec will not use incremental encoding (for example if using its v1 formats which does not support it).
39
+ const enableIncrementalSummary = summaryFormatWriteVersion >= summaryFormatCommon_js_1.ForestSummaryFormatVersion.v3 &&
41
40
  encoderContext.encodeType === treeCompressionUtils_js_1.TreeCompressionStrategy.CompressedIncremental;
42
41
  this.incrementalSummaryBuilder = new incrementalSummaryBuilder_js_1.ForestIncrementalSummaryBuilder(enableIncrementalSummary, (cursor) => this.forest.chunkField(cursor), shouldEncodeIncrementally, initialSequenceNumber);
43
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"forestSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAU7D,kDAY6B;AAC7B,8DAKyC;AACzC,kDAI6B;AAC7B,wDAAwD;AACxD,iEAAsF;AACtF,yDAKoC;AACpC,wEAAqE;AAErE,yCAIoB;AACpB,uDAAwD;AACxD,iFAGwC;AACxC,qEAIkC;AAClC,uDAG2B;AAE3B;;GAEG;AACH,MAAa,gBACZ,SAAQ,8BAA+C;IAQvD;;OAEG;IACH,YACkB,MAAuB,EACvB,gBAAkC,EACnD,eAAgC,EACf,cAAyC,EAC1D,OAA0B,EACT,YAA2B,EAC5C,qBAA6B,EAC7B,4BAAuD,2CAAgC;QAEvF,KAAK,CACJ,yCAAgB,EAChB,IAAA,wDAAsC,EAAC,OAAO,CAAC,mBAAmB,CAAC,EACnE,6DAAoC,EACpC,IAAI,CAAC,gCAAgC,CACrC,CAAC;QAde,WAAM,GAAN,MAAM,CAAiB;QACvB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAElC,mBAAc,GAAd,cAAc,CAA2B;QAEzC,iBAAY,GAAZ,YAAY,CAAe;QAW5C,IAAI,CAAC,KAAK,GAAG,IAAA,oCAAyB,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AAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9D,IAAA,qBAAU,EACT,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,EAAE,EACxC,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAA,iCAAsB,EAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,CACxE,CAAC;IACH,CAAC;CACD;AAvLD,4CAuLC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { CodecWriteOptions } from \"../../codec/index.js\";\nimport {\n\ttype DeltaDetachedNodeBuild,\n\ttype DeltaFieldChanges,\n\ttype FieldKey,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype RevisionTagCodec,\n\tTreeNavigationResult,\n\tapplyDelta,\n\tforEachField,\n\tmakeDetachedFieldIndex,\n} from \"../../core/index.js\";\nimport {\n\tVersionedSummarizer,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport {\n\tidAllocatorFromMaxId,\n\treadAndParseSnapshotBlob,\n\ttype JsonCompatibleReadOnly,\n} from \"../../util/index.js\";\n// eslint-disable-next-line import-x/no-internal-modules\nimport { chunkFieldSingle, defaultChunkPolicy } from \"../chunked-forest/chunkTree.js\";\nimport {\n\tdefaultIncrementalEncodingPolicy,\n\ttype FieldBatchCodec,\n\ttype FieldBatchEncodingContext,\n\ttype IncrementalEncodingPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport {\n\tclientVersionToForestFormatVersion,\n\ttype ForestCodec,\n\tmakeForestSummarizerCodec,\n} from \"./codec.js\";\nimport { ForestFormatVersion } from \"./formatCommon.js\";\nimport {\n\tForestIncrementalSummaryBehavior,\n\tForestIncrementalSummaryBuilder,\n} from \"./incrementalSummaryBuilder.js\";\nimport {\n\tForestSummaryFormatVersion,\n\tforestSummaryKey,\n\tsupportedForestSummaryFormatVersions,\n} from \"./summaryFormatCommon.js\";\nimport {\n\tminVersionToForestSummaryFormatVersion,\n\tgetForestRootSummaryContentKey,\n} from \"./summaryTypes.js\";\n\n/**\n * Provides methods for summarizing and loading a forest.\n */\nexport class ForestSummarizer\n\textends VersionedSummarizer<ForestSummaryFormatVersion>\n\timplements Summarizable\n{\n\tprivate readonly codec: ForestCodec;\n\n\tprivate readonly incrementalSummaryBuilder: ForestIncrementalSummaryBuilder;\n\tprivate readonly forestRootSummaryContentKey: string;\n\n\t/**\n\t * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IEditableForest,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tfieldBatchCodec: FieldBatchCodec,\n\t\tprivate readonly encoderContext: FieldBatchEncodingContext,\n\t\toptions: CodecWriteOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tinitialSequenceNumber: number,\n\t\tshouldEncodeIncrementally: IncrementalEncodingPolicy = defaultIncrementalEncodingPolicy,\n\t) {\n\t\tsuper(\n\t\t\tforestSummaryKey,\n\t\t\tminVersionToForestSummaryFormatVersion(options.minVersionForCollab),\n\t\t\tsupportedForestSummaryFormatVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\n\t\tthis.codec = makeForestSummarizerCodec(options, fieldBatchCodec);\n\n\t\tconst forestFormatWriteVersion = clientVersionToForestFormatVersion(\n\t\t\toptions.minVersionForCollab,\n\t\t);\n\t\tconst summaryFormatWriteVersion = minVersionToForestSummaryFormatVersion(\n\t\t\toptions.minVersionForCollab,\n\t\t);\n\t\tthis.forestRootSummaryContentKey = getForestRootSummaryContentKey(\n\t\t\tsummaryFormatWriteVersion,\n\t\t);\n\n\t\t// Incremental summary is supported from ForestFormatVersion.v2 and ForestSummaryFormatVersion.v3 onwards.\n\t\tconst enableIncrementalSummary =\n\t\t\tforestFormatWriteVersion >= ForestFormatVersion.v2 &&\n\t\t\tsummaryFormatWriteVersion >= ForestSummaryFormatVersion.v3 &&\n\t\t\tencoderContext.encodeType === TreeCompressionStrategy.CompressedIncremental;\n\t\tthis.incrementalSummaryBuilder = new ForestIncrementalSummaryBuilder(\n\t\t\tenableIncrementalSummary,\n\t\t\t(cursor: ITreeCursorSynchronous) => this.forest.chunkField(cursor),\n\t\t\tshouldEncodeIncrementally,\n\t\t\tinitialSequenceNumber,\n\t\t);\n\t}\n\n\t/**\n\t * Summarization of the forest's tree content.\n\t * @returns a summary tree containing the forest's tree content.\n\t * @remarks\n\t * If incremental summary is disabled, all the content will be added to a single summary blob.\n\t * If incremental summary is enabled, the summary will be a tree.\n\t * See {@link ForestIncrementalSummaryBuilder} for details of what this tree looks like.\n\t *\n\t * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.\n\t */\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { stringify, fullTree = false, incrementalSummaryContext, builder } = props;\n\n\t\tconst rootCursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst fieldMap: Map<FieldKey, ITreeCursorSynchronous & ITreeSubscriptionCursor> =\n\t\t\tnew Map();\n\t\t// TODO: Encode all detached fields in one operation for better performance and compression\n\t\tforEachField(rootCursor, (cursor) => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tconst innerCursor = this.forest.allocateCursor(\"getTreeString\");\n\t\t\tassert(\n\t\t\t\tthis.forest.tryMoveCursorToField({ fieldKey: key, parent: undefined }, innerCursor) ===\n\t\t\t\t\tTreeNavigationResult.Ok,\n\t\t\t\t0x892 /* failed to navigate to field */,\n\t\t\t);\n\t\t\tfieldMap.set(key, innerCursor as ITreeCursorSynchronous & ITreeSubscriptionCursor);\n\t\t});\n\n\t\t// Let the incremental summary builder know that we are starting a new summary.\n\t\t// It returns whether incremental encoding is enabled.\n\t\tconst incrementalSummaryBehavior = this.incrementalSummaryBuilder.startSummary({\n\t\t\tfullTree,\n\t\t\tincrementalSummaryContext,\n\t\t\tstringify,\n\t\t\tbuilder,\n\t\t});\n\t\tconst encoderContext: FieldBatchEncodingContext = {\n\t\t\t...this.encoderContext,\n\t\t\tincrementalEncoderDecoder:\n\t\t\t\tincrementalSummaryBehavior === ForestIncrementalSummaryBehavior.Incremental\n\t\t\t\t\t? this.incrementalSummaryBuilder\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tconst encoded = this.codec.encode(fieldMap, encoderContext);\n\t\tfor (const value of fieldMap.values()) {\n\t\t\tvalue.free();\n\t\t}\n\n\t\tthis.incrementalSummaryBuilder.completeSummary({\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryRootContent: stringify(encoded),\n\t\t\tforestSummaryRootContentKey: this.forestRootSummaryContentKey,\n\t\t\tbuilder,\n\t\t});\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t\tversion: ForestSummaryFormatVersion | undefined,\n\t): Promise<void> {\n\t\t// Get the key of the summary blob where the top-level forest content is stored based on the summary format version.\n\t\t// If the summary was generated as `ForestIncrementalSummaryBehavior.SingleBlob`, this blob will contain all\n\t\t// of forest's contents.\n\t\t// If the summary was generated as `ForestIncrementalSummaryBehavior.Incremental`, this blob will contain only\n\t\t// the top-level forest node's contents.\n\t\t// The contents of the incremental chunks will be in separate tree nodes and will be read later during decoding.\n\t\tconst forestSummaryRootContentKey = getForestRootSummaryContentKey(version);\n\t\tassert(\n\t\t\tawait services.contains(forestSummaryRootContentKey),\n\t\t\t0xc21 /* Forest summary content missing in snapshot */,\n\t\t);\n\n\t\t// Load the incremental summary builder so that it can download any incremental chunks in the\n\t\t// snapshot.\n\t\tawait this.incrementalSummaryBuilder.load({\n\t\t\tservices,\n\t\t\treadAndParseChunk: async (chunkBlobPath: string) =>\n\t\t\t\treadAndParseSnapshotBlob(chunkBlobPath, services, parse),\n\t\t});\n\n\t\t// TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the\n\t\t// forest summary format.\n\t\tconst fields = this.codec.decode(\n\t\t\t(await readAndParseSnapshotBlob(\n\t\t\t\tforestSummaryRootContentKey,\n\t\t\t\tservices,\n\t\t\t\tparse,\n\t\t\t\t// TODO: this type cast assumes there are no handles, which should probably be enforced at runtime or the need for this cast should be removed altogether.\n\t\t\t)) as JsonCompatibleReadOnly,\n\t\t\t{\n\t\t\t\t...this.encoderContext,\n\t\t\t\tincrementalEncoderDecoder: this.incrementalSummaryBuilder,\n\t\t\t},\n\t\t);\n\t\tconst allocator = idAllocatorFromMaxId();\n\t\tconst fieldChanges: [FieldKey, DeltaFieldChanges][] = [];\n\t\tconst build: DeltaDetachedNodeBuild[] = [];\n\t\tfor (const [fieldKey, field] of fields) {\n\t\t\tconst chunked = chunkFieldSingle(field, {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t\tconst buildId = { minor: allocator.allocate(chunked.topLevelLength) };\n\t\t\tbuild.push({\n\t\t\t\tid: buildId,\n\t\t\t\ttrees: chunked,\n\t\t\t});\n\t\t\tfieldChanges.push([\n\t\t\t\tfieldKey,\n\t\t\t\t{ marks: [{ count: chunked.topLevelLength, attach: buildId }] },\n\t\t\t]);\n\t\t}\n\n\t\tassert(this.forest.isEmpty, 0x797 /* forest must be empty */);\n\t\tapplyDelta(\n\t\t\t{ build, fields: new Map(fieldChanges) },\n\t\t\tundefined,\n\t\t\tthis.forest,\n\t\t\tmakeDetachedFieldIndex(\"init\", this.revisionTagCodec, this.idCompressor),\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"forestSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAU7D,kDAY6B;AAC7B,8DAKyC;AACzC,kDAI6B;AAC7B,wDAAwD;AACxD,iEAAsF;AACtF,yDAIoC;AACpC,wEAAqE;AAErE,yCAAkE;AAClE,iFAGwC;AACxC,qEAIkC;AAClC,uDAG2B;AAE3B;;GAEG;AACH,MAAa,gBACZ,SAAQ,8BAA+C;IAQvD;;OAEG;IACH,YACkB,MAAuB,EACvB,gBAAkC,EAClC,cAAyC,EAC1D,OAA0B,EACT,YAA2B,EAC5C,qBAA6B,EAC7B,4BAAuD,2CAAgC;QAEvF,KAAK,CACJ,yCAAgB,EAChB,IAAA,wDAAsC,EAAC,OAAO,CAAC,mBAAmB,CAAC,EACnE,6DAAoC,EACpC,IAAI,CAAC,gCAAgC,CACrC,CAAC;QAbe,WAAM,GAAN,MAAM,CAAiB;QACvB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,mBAAc,GAAd,cAAc,CAA2B;QAEzC,iBAAY,GAAZ,YAAY,CAAe;QAW5C,IAAI,CAAC,KAAK,GAAG,6BAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE/C,MAAM,yBAAyB,GAAG,IAAA,wDAAsC,EACvE,OAAO,CAAC,mBAAmB,CAC3B,CAAC;QACF,IAAI,CAAC,2BAA2B,GAAG,IAAA,gDAA8B,EAChE,yBAAyB,CACzB,CAAC;QAEF,6EAA6E;QAC7E,s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CACD;AApLD,4CAoLC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type {\n\tIExperimentalIncrementalSummaryContext,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport type { CodecWriteOptions } from \"../../codec/index.js\";\nimport {\n\ttype DeltaDetachedNodeBuild,\n\ttype DeltaFieldChanges,\n\ttype FieldKey,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype RevisionTagCodec,\n\tTreeNavigationResult,\n\tapplyDelta,\n\tforEachField,\n\tmakeDetachedFieldIndex,\n} from \"../../core/index.js\";\nimport {\n\tVersionedSummarizer,\n\ttype Summarizable,\n\ttype SummaryElementParser,\n\ttype SummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport {\n\tidAllocatorFromMaxId,\n\treadAndParseSnapshotBlob,\n\ttype JsonCompatibleReadOnly,\n} from \"../../util/index.js\";\n// eslint-disable-next-line import-x/no-internal-modules\nimport { chunkFieldSingle, defaultChunkPolicy } from \"../chunked-forest/chunkTree.js\";\nimport {\n\tdefaultIncrementalEncodingPolicy,\n\ttype FieldBatchEncodingContext,\n\ttype IncrementalEncodingPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport { forestCodecBuilder, type ForestCodec } from \"./codec.js\";\nimport {\n\tForestIncrementalSummaryBehavior,\n\tForestIncrementalSummaryBuilder,\n} from \"./incrementalSummaryBuilder.js\";\nimport {\n\tForestSummaryFormatVersion,\n\tforestSummaryKey,\n\tsupportedForestSummaryFormatVersions,\n} from \"./summaryFormatCommon.js\";\nimport {\n\tminVersionToForestSummaryFormatVersion,\n\tgetForestRootSummaryContentKey,\n} from \"./summaryTypes.js\";\n\n/**\n * Provides methods for summarizing and loading a forest.\n */\nexport class ForestSummarizer\n\textends VersionedSummarizer<ForestSummaryFormatVersion>\n\timplements Summarizable\n{\n\tprivate readonly codec: ForestCodec;\n\n\tprivate readonly incrementalSummaryBuilder: ForestIncrementalSummaryBuilder;\n\tprivate readonly forestRootSummaryContentKey: string;\n\n\t/**\n\t * @param encoderContext - The schema if provided here must be mutated by the caller to keep it up to date.\n\t */\n\tpublic constructor(\n\t\tprivate readonly forest: IEditableForest,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly encoderContext: FieldBatchEncodingContext,\n\t\toptions: CodecWriteOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tinitialSequenceNumber: number,\n\t\tshouldEncodeIncrementally: IncrementalEncodingPolicy = defaultIncrementalEncodingPolicy,\n\t) {\n\t\tsuper(\n\t\t\tforestSummaryKey,\n\t\t\tminVersionToForestSummaryFormatVersion(options.minVersionForCollab),\n\t\t\tsupportedForestSummaryFormatVersions,\n\t\t\ttrue /* supportPreVersioningFormat */,\n\t\t);\n\n\t\tthis.codec = forestCodecBuilder.build(options);\n\n\t\tconst summaryFormatWriteVersion = minVersionToForestSummaryFormatVersion(\n\t\t\toptions.minVersionForCollab,\n\t\t);\n\t\tthis.forestRootSummaryContentKey = getForestRootSummaryContentKey(\n\t\t\tsummaryFormatWriteVersion,\n\t\t);\n\n\t\t// Incremental summary is supported in ForestSummaryFormatVersion.v3 onwards.\n\t\t// Note that even in versions that support it, it is possible that the\n\t\t// FieldBatchCodec will not use incremental encoding (for example if using its v1 formats which does not support it).\n\t\tconst enableIncrementalSummary =\n\t\t\tsummaryFormatWriteVersion >= ForestSummaryFormatVersion.v3 &&\n\t\t\tencoderContext.encodeType === TreeCompressionStrategy.CompressedIncremental;\n\t\tthis.incrementalSummaryBuilder = new ForestIncrementalSummaryBuilder(\n\t\t\tenableIncrementalSummary,\n\t\t\t(cursor: ITreeCursorSynchronous) => this.forest.chunkField(cursor),\n\t\t\tshouldEncodeIncrementally,\n\t\t\tinitialSequenceNumber,\n\t\t);\n\t}\n\n\t/**\n\t * Summarization of the forest's tree content.\n\t * @returns a summary tree containing the forest's tree content.\n\t * @remarks\n\t * If incremental summary is disabled, all the content will be added to a single summary blob.\n\t * If incremental summary is enabled, the summary will be a tree.\n\t * See {@link ForestIncrementalSummaryBuilder} for details of what this tree looks like.\n\t *\n\t * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.\n\t */\n\tprotected summarizeInternal(props: {\n\t\tstringify: SummaryElementStringifier;\n\t\tfullTree?: boolean;\n\t\ttrackState?: boolean;\n\t\ttelemetryContext?: ITelemetryContext;\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst { stringify, fullTree = false, incrementalSummaryContext, builder } = props;\n\n\t\tconst rootCursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst fieldMap: Map<FieldKey, ITreeCursorSynchronous & ITreeSubscriptionCursor> =\n\t\t\tnew Map();\n\t\t// TODO: Encode all detached fields in one operation for better performance and compression\n\t\tforEachField(rootCursor, (cursor) => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tconst innerCursor = this.forest.allocateCursor(\"getTreeString\");\n\t\t\tassert(\n\t\t\t\tthis.forest.tryMoveCursorToField({ fieldKey: key, parent: undefined }, innerCursor) ===\n\t\t\t\t\tTreeNavigationResult.Ok,\n\t\t\t\t0x892 /* failed to navigate to field */,\n\t\t\t);\n\t\t\tfieldMap.set(key, innerCursor as ITreeCursorSynchronous & ITreeSubscriptionCursor);\n\t\t});\n\n\t\t// Let the incremental summary builder know that we are starting a new summary.\n\t\t// It returns whether incremental encoding is enabled.\n\t\tconst incrementalSummaryBehavior = this.incrementalSummaryBuilder.startSummary({\n\t\t\tfullTree,\n\t\t\tincrementalSummaryContext,\n\t\t\tstringify,\n\t\t\tbuilder,\n\t\t});\n\t\tconst encoderContext: FieldBatchEncodingContext = {\n\t\t\t...this.encoderContext,\n\t\t\tincrementalEncoderDecoder:\n\t\t\t\tincrementalSummaryBehavior === ForestIncrementalSummaryBehavior.Incremental\n\t\t\t\t\t? this.incrementalSummaryBuilder\n\t\t\t\t\t: undefined,\n\t\t};\n\t\tconst encoded = this.codec.encode(fieldMap, encoderContext);\n\t\tfor (const value of fieldMap.values()) {\n\t\t\tvalue.free();\n\t\t}\n\n\t\tthis.incrementalSummaryBuilder.completeSummary({\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryRootContent: stringify(encoded),\n\t\t\tforestSummaryRootContentKey: this.forestRootSummaryContentKey,\n\t\t\tbuilder,\n\t\t});\n\t}\n\n\tprotected async loadInternal(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t\tversion: ForestSummaryFormatVersion | undefined,\n\t): Promise<void> {\n\t\t// Get the key of the summary blob where the top-level forest content is stored based on the summary format version.\n\t\t// If the summary was generated as `ForestIncrementalSummaryBehavior.SingleBlob`, this blob will contain all\n\t\t// of forest's contents.\n\t\t// If the summary was generated as `ForestIncrementalSummaryBehavior.Incremental`, this blob will contain only\n\t\t// the top-level forest node's contents.\n\t\t// The contents of the incremental chunks will be in separate tree nodes and will be read later during decoding.\n\t\tconst forestSummaryRootContentKey = getForestRootSummaryContentKey(version);\n\t\tassert(\n\t\t\tawait services.contains(forestSummaryRootContentKey),\n\t\t\t0xc21 /* Forest summary content missing in snapshot */,\n\t\t);\n\n\t\t// Load the incremental summary builder so that it can download any incremental chunks in the\n\t\t// snapshot.\n\t\tawait this.incrementalSummaryBuilder.load({\n\t\t\tservices,\n\t\t\treadAndParseChunk: async (chunkBlobPath: string) =>\n\t\t\t\treadAndParseSnapshotBlob(chunkBlobPath, services, parse),\n\t\t});\n\n\t\t// TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the\n\t\t// forest summary format.\n\t\tconst fields = this.codec.decode(\n\t\t\t(await readAndParseSnapshotBlob(\n\t\t\t\tforestSummaryRootContentKey,\n\t\t\t\tservices,\n\t\t\t\tparse,\n\t\t\t\t// TODO: this type cast assumes there are no handles, which should probably be enforced at runtime or the need for this cast should be removed altogether.\n\t\t\t)) as JsonCompatibleReadOnly,\n\t\t\t{\n\t\t\t\t...this.encoderContext,\n\t\t\t\tincrementalEncoderDecoder: this.incrementalSummaryBuilder,\n\t\t\t},\n\t\t);\n\t\tconst allocator = idAllocatorFromMaxId();\n\t\tconst fieldChanges: [FieldKey, DeltaFieldChanges][] = [];\n\t\tconst build: DeltaDetachedNodeBuild[] = [];\n\t\tfor (const [fieldKey, field] of fields) {\n\t\t\tconst chunked = chunkFieldSingle(field, {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t});\n\t\t\tconst buildId = { minor: allocator.allocate(chunked.topLevelLength) };\n\t\t\tbuild.push({\n\t\t\t\tid: buildId,\n\t\t\t\ttrees: chunked,\n\t\t\t});\n\t\t\tfieldChanges.push([\n\t\t\t\tfieldKey,\n\t\t\t\t{ marks: [{ count: chunked.topLevelLength, attach: buildId }] },\n\t\t\t]);\n\t\t}\n\n\t\tassert(this.forest.isEmpty, 0x797 /* forest must be empty */);\n\t\tapplyDelta(\n\t\t\t{ build, fields: new Map(fieldChanges) },\n\t\t\tundefined,\n\t\t\tthis.forest,\n\t\t\tmakeDetachedFieldIndex(\"init\", this.revisionTagCodec, this.idCompressor),\n\t\t);\n\t}\n}\n"]}
@@ -13,11 +13,13 @@ export declare const ForestFormatVersion: {
13
13
  readonly v2: import("../../util/brand.js").Brand<2, "ForestFormatVersion">;
14
14
  };
15
15
  export type ForestFormatVersion = Values<typeof ForestFormatVersion>;
16
- export declare const validVersions: Set<import("../../util/brand.js").Brand<1, "ForestFormatVersion"> | import("../../util/brand.js").Brand<2, "ForestFormatVersion">>;
17
- export declare const FormatCommon: <const TVersion extends ForestFormatVersion>(version: TVersion) => import("@sinclair/typebox").TObject<{
18
- version: import("@sinclair/typebox").TLiteral<TVersion>;
16
+ /**
17
+ * Format used by {@link ForestFormatVersion.v1} and {@link ForestFormatVersion.v2}.
18
+ */
19
+ export declare const FormatCommon: import("@sinclair/typebox").TObject<{
19
20
  keys: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnsafe<schemaFormatV1.FieldKey>>;
20
21
  fields: import("@sinclair/typebox").TUnsafe<import("../../util/utils.js").JsonCompatibleReadOnly>;
22
+ version: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TString]>;
21
23
  }>;
22
- export type Format<TVersion extends ForestFormatVersion = ForestFormatVersion> = Static<ReturnType<typeof FormatCommon<TVersion>>>;
24
+ export type FormatCommon = Static<typeof FormatCommon>;
23
25
  //# sourceMappingURL=formatCommon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatCommon.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAc,KAAK,MAAM,EAAgC,MAAM,qBAAqB,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAI9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,eAAO,MAAM,aAAa,oIAAmD,CAAC;AAE9E,eAAO,MAAM,YAAY,wDACf,QAAQ;;;;EAWhB,CAAC;AACH,MAAM,MAAM,MAAM,CAAC,QAAQ,SAAS,mBAAmB,GAAG,mBAAmB,IAAI,MAAM,CACtF,UAAU,CAAC,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,CACzC,CAAC"}
1
+ {"version":3,"file":"formatCommon.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAc,KAAK,MAAM,EAAgC,MAAM,qBAAqB,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAI9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY;;;;EAOxB,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -4,23 +4,25 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FormatCommon = exports.validVersions = exports.ForestFormatVersion = void 0;
7
+ exports.FormatCommon = exports.ForestFormatVersion = void 0;
8
8
  const typebox_1 = require("@sinclair/typebox");
9
- const index_js_1 = require("../../core/index.js");
10
- const index_js_2 = require("../../util/index.js");
9
+ const index_js_1 = require("../../codec/index.js");
10
+ const index_js_2 = require("../../core/index.js");
11
+ const index_js_3 = require("../../util/index.js");
11
12
  /**
12
13
  * The format version for the forest.
13
14
  */
14
- exports.ForestFormatVersion = (0, index_js_2.strictEnum)("ForestFormatVersion", {
15
+ exports.ForestFormatVersion = (0, index_js_3.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
- exports.validVersions = new Set([...Object.values(exports.ForestFormatVersion)]);
20
- const FormatCommon = (version) => typebox_1.Type.Object({
21
- version: typebox_1.Type.Literal(version),
22
- keys: typebox_1.Type.Array(index_js_1.schemaFormatV1.FieldKeySchema),
23
- fields: index_js_2.JsonCompatibleReadOnlySchema, // Uses field batch codec
20
+ /**
21
+ * Format used by {@link ForestFormatVersion.v1} and {@link ForestFormatVersion.v2}.
22
+ */
23
+ exports.FormatCommon = typebox_1.Type.Object({
24
+ ...index_js_1.versionField,
25
+ keys: typebox_1.Type.Array(index_js_2.schemaFormatV1.FieldKeySchema),
26
+ fields: index_js_3.JsonCompatibleReadOnlySchema, // Uses field batch codec
24
27
  }, { additionalProperties: false });
25
- exports.FormatCommon = FormatCommon;
26
28
  //# sourceMappingURL=formatCommon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatCommon.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,kDAAqD;AACrD,kDAA4F;AAE5F;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAU,EAAC,qBAAqB,EAAE;IACpE,EAAE,EAAE,CAAC;IACL,gDAAgD;IAChD,EAAE,EAAE,CAAC;CACL,CAAC,CAAC;AAGU,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,YAAY,GAAG,CAC3B,OAAiB,EAGhB,EAAE,CACH,cAAI,CAAC,MAAM,CACV;IACC,OAAO,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,IAAI,EAAE,cAAI,CAAC,KAAK,CAAC,yBAAc,CAAC,cAAc,CAAC;IAC/C,MAAM,EAAE,uCAA4B,EAAE,yBAAyB;CAC/D,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAZU,QAAA,YAAY,gBAYtB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, Type } from \"@sinclair/typebox\";\n\nimport { schemaFormatV1 } from \"../../core/index.js\";\nimport { strictEnum, type Values, JsonCompatibleReadOnlySchema } from \"../../util/index.js\";\n\n/**\n * The format version for the forest.\n */\nexport const ForestFormatVersion = strictEnum(\"ForestFormatVersion\", {\n\tv1: 1,\n\t/** This format supports incremental encoding */\n\tv2: 2,\n});\nexport type ForestFormatVersion = Values<typeof ForestFormatVersion>;\n\nexport const validVersions = new Set([...Object.values(ForestFormatVersion)]);\n\nexport const FormatCommon = <const TVersion extends ForestFormatVersion>(\n\tversion: TVersion,\n\t// Return type is intentionally derived.\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n) =>\n\tType.Object(\n\t\t{\n\t\t\tversion: Type.Literal(version),\n\t\t\tkeys: Type.Array(schemaFormatV1.FieldKeySchema),\n\t\t\tfields: JsonCompatibleReadOnlySchema, // Uses field batch codec\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\nexport type Format<TVersion extends ForestFormatVersion = ForestFormatVersion> = Static<\n\tReturnType<typeof FormatCommon<TVersion>>\n>;\n"]}
1
+ {"version":3,"file":"formatCommon.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/formatCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAsD;AAEtD,mDAAoD;AACpD,kDAAqD;AACrD,kDAA4F;AAE5F;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAU,EAAC,qBAAqB,EAAE;IACpE,EAAE,EAAE,CAAC;IACL,6HAA6H;IAC7H,EAAE,EAAE,CAAC;CACL,CAAC,CAAC;AAGH;;GAEG;AACU,QAAA,YAAY,GAAG,cAAI,CAAC,MAAM,CACtC;IACC,GAAG,uBAAY;IACf,IAAI,EAAE,cAAI,CAAC,KAAK,CAAC,yBAAc,CAAC,cAAc,CAAC;IAC/C,MAAM,EAAE,uCAA4B,EAAE,yBAAyB;CAC/D,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type Static, Type } from \"@sinclair/typebox\";\n\nimport { versionField } from \"../../codec/index.js\";\nimport { schemaFormatV1 } from \"../../core/index.js\";\nimport { strictEnum, type Values, JsonCompatibleReadOnlySchema } from \"../../util/index.js\";\n\n/**\n * The format version for the forest.\n */\nexport const ForestFormatVersion = strictEnum(\"ForestFormatVersion\", {\n\tv1: 1,\n\t/** This format is the same as v1, and was added at the same time as incremental encoding for reasons that no longer apply */\n\tv2: 2,\n});\nexport type ForestFormatVersion = Values<typeof ForestFormatVersion>;\n\n/**\n * Format used by {@link ForestFormatVersion.v1} and {@link ForestFormatVersion.v2}.\n */\nexport const FormatCommon = Type.Object(\n\t{\n\t\t...versionField,\n\t\tkeys: Type.Array(schemaFormatV1.FieldKeySchema),\n\t\tfields: JsonCompatibleReadOnlySchema, // Uses field batch codec\n\t},\n\t{ additionalProperties: false },\n);\nexport type FormatCommon = Static<typeof FormatCommon>;\n"]}
@@ -10,16 +10,6 @@ import type { ITreeCursorSynchronous } from "../../core/index.js";
10
10
  import type { SummaryElementStringifier } from "../../shared-tree-core/index.js";
11
11
  import { type JsonCompatible } from "../../util/index.js";
12
12
  import type { ChunkReferenceId, EncodedFieldBatch, IncrementalEncoderDecoder, IncrementalEncodingPolicy, TreeChunk } from "../chunked-forest/index.js";
13
- /**
14
- * State that tells whether a summary is currently being tracked.
15
- */
16
- export declare const ForestSummaryTrackingState: {
17
- /** A summary is currently being tracked. */
18
- readonly Tracking: "Tracking";
19
- /** A summary is ready to be tracked. */
20
- readonly ReadyToTrack: "ReadyToTrack";
21
- };
22
- export type ForestSummaryTrackingState = (typeof ForestSummaryTrackingState)[keyof typeof ForestSummaryTrackingState];
23
13
  /**
24
14
  * The behavior of the forest's incremental summary - whether the summary should be a single blob or incremental.
25
15
  */
@@ -89,16 +79,26 @@ export declare class ForestIncrementalSummaryBuilder implements IncrementalEncod
89
79
  */
90
80
  private readonly chunkTrackingPropertiesMap;
91
81
  /**
92
- * The state indicating whether a summary is currently being tracked or not.
82
+ * True when encoding a summary, false otherwise.
83
+ * @remarks
84
+ * Exposed for testing purposes.
93
85
  */
94
- forestSummaryState: ForestSummaryTrackingState;
86
+ get isSummarizing(): boolean;
95
87
  /**
96
88
  * The sequence number of the latest summary that was successful.
97
89
  */
98
90
  private latestSummarySequenceNumber;
99
91
  /**
100
- * The current state of the summary being tracked.
101
- * This is undefined if no summary is currently being tracked.
92
+ * The current state of the summary being "tracked".
93
+ * @remarks
94
+ * A summary being "tracked" means that a summary is being encoded.
95
+ * This is undefined if no summary is currently being encoded.
96
+ *
97
+ * @privateRemarks
98
+ * This has nothing to do which how content from a summary being loaded is tracked (thats written all in chunkTrackingPropertiesMap).
99
+ * "Tracked" should probably be renamed to "encoded" or "summarizing" or something like that to avoid confusion.
100
+ * Perhaps a better way to clarify this would be to not store this property on this object at all, and have it
101
+ * only exist within the scope of the summary encoding (use an encoding specific object to accumulate any stat necessary during encode).
102
102
  */
103
103
  private trackedSummaryProperties;
104
104
  /**
@@ -121,6 +121,11 @@ export declare class ForestIncrementalSummaryBuilder implements IncrementalEncod
121
121
  services: IChannelStorageService;
122
122
  readAndParseChunk: (chunkBlobPath: string) => Promise<JsonCompatible<IFluidHandle>>;
123
123
  }): Promise<void>;
124
+ /**
125
+ * Asserts that a summary is currently being tracked and that the tracked summary properties are defined.
126
+ * @returns The properties of the tracked summary.
127
+ */
128
+ private requireTrackingSummary;
124
129
  /**
125
130
  * Must be called when starting a new forest summary to track it.
126
131
  * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain
@@ -1 +1 @@
1
- {"version":3,"file":"incrementalSummaryBuilder.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM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AAO,CAAC,QAAQ,CAAC,eAAe,CAA+C;gBAG7D,wBAAwB,EAAE,OAAO,EACjC,gBAAgB,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,SAAS,EAAE,EAClE,yBAAyB,EAAE,yBAAyB,EACnD,qBAAqB,EAAE,MAAM;IAG/C;;;;;OAKG;IACU,IAAI,CAAC,IAAI,EAAE;QACvB,QAAQ,EAAE,sBAAsB,CAAC;QACjC,iBAAiB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;KACpF,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CjB;;;;;;;;OAQG;IACI,YAAY,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,OAAO,CAAC;QAClB,yBAAyB,EAAE,sCAAsC,GAAG,SAAS,CAAC;QAC9E,SAAS,EAAE,yBAAyB,CAAC;QACrC,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,gCAAgC;IAwBpC;;;OAGG;IACI,sBAAsB,CAC5B,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,iBAAiB,GACnD,gBAAgB,EAAE;IA0ErB;;;;;;;;;;;OAWG;IACI,eAAe,CAAC,IAAI,EAAE;QAC5B,yBAAyB,EAAE,sCAAsC,GAAG,SAAS,CAAC;QAC9E,wBAAwB,EAAE,MAAM,CAAC;QACjC,2BAA2B,EAAE,MAAM,CAAC;QACpC,OAAO,EAAE,kBAAkB,CAAC;KAC5B,GAAG,IAAI;IA8CR;;OAEG;IACI,sBAAsB,CAC5B,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,SAAS,GACrD,SAAS;CAkBZ"}
1
+ {"version":3,"file":"incrementalSummaryBuilder.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":"AAAA;;;G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