@fluidframework/tree 2.41.0 → 2.42.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 (416) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +33 -0
  3. package/api-report/tree.alpha.api.md +11 -7
  4. package/dist/alpha.d.ts +1 -0
  5. package/dist/codec/codec.d.ts +23 -3
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/codec/index.d.ts +1 -1
  9. package/dist/codec/index.d.ts.map +1 -1
  10. package/dist/codec/index.js.map +1 -1
  11. package/dist/codec/versioned/codec.d.ts +35 -2
  12. package/dist/codec/versioned/codec.d.ts.map +1 -1
  13. package/dist/codec/versioned/codec.js +38 -3
  14. package/dist/codec/versioned/codec.js.map +1 -1
  15. package/dist/core/tree/detachedFieldIndex.d.ts +2 -2
  16. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  17. package/dist/core/tree/detachedFieldIndex.js +5 -1
  18. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  19. package/dist/core/tree/mapTree.d.ts +2 -1
  20. package/dist/core/tree/mapTree.d.ts.map +1 -1
  21. package/dist/core/tree/mapTree.js +11 -5
  22. package/dist/core/tree/mapTree.js.map +1 -1
  23. package/dist/core/tree/visitorUtils.d.ts +2 -2
  24. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  25. package/dist/core/tree/visitorUtils.js.map +1 -1
  26. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
  27. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  28. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  29. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
  30. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  31. package/dist/feature-libraries/default-schema/schemaChecker.js +4 -3
  32. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  33. package/dist/feature-libraries/flex-tree/context.d.ts +14 -6
  34. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  35. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  36. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +34 -14
  37. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  38. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
  39. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  40. package/dist/feature-libraries/flex-tree/index.d.ts +2 -2
  41. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  42. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  43. package/dist/feature-libraries/flex-tree/lazyField.d.ts +6 -6
  44. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  45. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  46. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -2
  47. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  48. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
  49. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  50. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  51. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  52. package/dist/feature-libraries/forest-summary/forestSummarizer.js +7 -7
  53. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  54. package/dist/feature-libraries/index.d.ts +2 -2
  55. package/dist/feature-libraries/index.d.ts.map +1 -1
  56. package/dist/feature-libraries/index.js +4 -2
  57. package/dist/feature-libraries/index.js.map +1 -1
  58. package/dist/feature-libraries/mapTreeCursor.d.ts +39 -3
  59. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  60. package/dist/feature-libraries/mapTreeCursor.js +45 -7
  61. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  62. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
  63. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  64. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
  65. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  66. package/dist/feature-libraries/treeCursorUtils.d.ts +5 -1
  67. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  68. package/dist/feature-libraries/treeCursorUtils.js +8 -2
  69. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/packageVersion.d.ts +1 -1
  74. package/dist/packageVersion.js +1 -1
  75. package/dist/packageVersion.js.map +1 -1
  76. package/dist/shared-tree/schematizingTreeView.d.ts +11 -1
  77. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  78. package/dist/shared-tree/schematizingTreeView.js +36 -22
  79. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  80. package/dist/shared-tree/sharedTree.d.ts +3 -3
  81. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  82. package/dist/shared-tree/sharedTree.js +1 -0
  83. package/dist/shared-tree/sharedTree.js.map +1 -1
  84. package/dist/shared-tree/tree.d.ts.map +1 -1
  85. package/dist/shared-tree/tree.js +8 -24
  86. package/dist/shared-tree/tree.js.map +1 -1
  87. package/dist/shared-tree/treeAlpha.d.ts +2 -3
  88. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  89. package/dist/shared-tree/treeAlpha.js +13 -15
  90. package/dist/shared-tree/treeAlpha.js.map +1 -1
  91. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  92. package/dist/shared-tree/treeCheckout.js +5 -2
  93. package/dist/shared-tree/treeCheckout.js.map +1 -1
  94. package/dist/simple-tree/api/configuration.d.ts +2 -2
  95. package/dist/simple-tree/api/configuration.js +1 -1
  96. package/dist/simple-tree/api/configuration.js.map +1 -1
  97. package/dist/simple-tree/api/create.d.ts +9 -4
  98. package/dist/simple-tree/api/create.d.ts.map +1 -1
  99. package/dist/simple-tree/api/create.js +29 -16
  100. package/dist/simple-tree/api/create.js.map +1 -1
  101. package/dist/simple-tree/api/customTree.d.ts +4 -0
  102. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  103. package/dist/simple-tree/api/customTree.js +9 -1
  104. package/dist/simple-tree/api/customTree.js.map +1 -1
  105. package/dist/simple-tree/api/index.d.ts +1 -1
  106. package/dist/simple-tree/api/index.d.ts.map +1 -1
  107. package/dist/simple-tree/api/index.js +1 -2
  108. package/dist/simple-tree/api/index.js.map +1 -1
  109. package/dist/simple-tree/api/schemaFactory.d.ts +10 -2
  110. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  111. package/dist/simple-tree/api/schemaFactory.js +38 -9
  112. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  113. package/dist/simple-tree/api/treeNodeApi.d.ts +14 -3
  114. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  115. package/dist/simple-tree/api/treeNodeApi.js +32 -17
  116. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  117. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  118. package/dist/simple-tree/api/verboseTree.js +12 -9
  119. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  120. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  121. package/dist/simple-tree/core/getOrCreateNode.js +2 -1
  122. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  123. package/dist/simple-tree/core/index.d.ts +2 -2
  124. package/dist/simple-tree/core/index.d.ts.map +1 -1
  125. package/dist/simple-tree/core/index.js +3 -4
  126. package/dist/simple-tree/core/index.js.map +1 -1
  127. package/dist/simple-tree/core/treeNodeKernel.d.ts +15 -25
  128. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  129. package/dist/simple-tree/core/treeNodeKernel.js +26 -33
  130. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  131. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +128 -59
  132. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  133. package/dist/simple-tree/core/unhydratedFlexTree.js +169 -182
  134. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  135. package/dist/simple-tree/index.d.ts +3 -3
  136. package/dist/simple-tree/index.d.ts.map +1 -1
  137. package/dist/simple-tree/index.js +5 -5
  138. package/dist/simple-tree/index.js.map +1 -1
  139. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  140. package/dist/simple-tree/node-kinds/array/arrayNode.js +5 -6
  141. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  142. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  143. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  144. package/dist/simple-tree/node-kinds/index.js +1 -2
  145. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  146. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  147. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  148. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  149. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  150. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  151. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  152. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  153. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -14
  154. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  155. package/dist/simple-tree/node-kinds/object/objectNode.js +12 -43
  156. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  157. package/dist/simple-tree/prepareForInsertion.d.ts +20 -6
  158. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  159. package/dist/simple-tree/prepareForInsertion.js +26 -19
  160. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  161. package/dist/simple-tree/schemaTypes.d.ts +8 -8
  162. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  163. package/dist/simple-tree/schemaTypes.js.map +1 -1
  164. package/dist/simple-tree/toStoredSchema.d.ts +6 -1
  165. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  166. package/dist/simple-tree/toStoredSchema.js +6 -3
  167. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  168. package/dist/simple-tree/{toMapTree.d.ts → unhydratedFlexTreeFromInsertable.d.ts} +12 -23
  169. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
  170. package/dist/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +103 -185
  171. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
  172. package/dist/treeFactory.d.ts.map +1 -1
  173. package/dist/treeFactory.js +6 -1
  174. package/dist/treeFactory.js.map +1 -1
  175. package/dist/util/index.d.ts +1 -1
  176. package/dist/util/index.d.ts.map +1 -1
  177. package/dist/util/index.js +2 -1
  178. package/dist/util/index.js.map +1 -1
  179. package/dist/util/utils.d.ts +4 -0
  180. package/dist/util/utils.d.ts.map +1 -1
  181. package/dist/util/utils.js +8 -1
  182. package/dist/util/utils.js.map +1 -1
  183. package/docs/user-facing/schema-evolution.md +1 -1
  184. package/lib/alpha.d.ts +1 -0
  185. package/lib/codec/codec.d.ts +23 -3
  186. package/lib/codec/codec.d.ts.map +1 -1
  187. package/lib/codec/codec.js.map +1 -1
  188. package/lib/codec/index.d.ts +1 -1
  189. package/lib/codec/index.d.ts.map +1 -1
  190. package/lib/codec/index.js.map +1 -1
  191. package/lib/codec/versioned/codec.d.ts +35 -2
  192. package/lib/codec/versioned/codec.d.ts.map +1 -1
  193. package/lib/codec/versioned/codec.js +36 -2
  194. package/lib/codec/versioned/codec.js.map +1 -1
  195. package/lib/core/tree/detachedFieldIndex.d.ts +2 -2
  196. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  197. package/lib/core/tree/detachedFieldIndex.js +6 -2
  198. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  199. package/lib/core/tree/mapTree.d.ts +2 -1
  200. package/lib/core/tree/mapTree.d.ts.map +1 -1
  201. package/lib/core/tree/mapTree.js +11 -5
  202. package/lib/core/tree/mapTree.js.map +1 -1
  203. package/lib/core/tree/visitorUtils.d.ts +2 -2
  204. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  205. package/lib/core/tree/visitorUtils.js.map +1 -1
  206. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -2
  207. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  208. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  209. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +4 -3
  210. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  211. package/lib/feature-libraries/default-schema/schemaChecker.js +4 -3
  212. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  213. package/lib/feature-libraries/flex-tree/context.d.ts +14 -6
  214. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  215. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  216. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +34 -14
  217. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  218. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +4 -0
  219. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  220. package/lib/feature-libraries/flex-tree/index.d.ts +2 -2
  221. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  222. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  223. package/lib/feature-libraries/flex-tree/lazyField.d.ts +6 -6
  224. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  225. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  226. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -2
  227. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  228. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
  229. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  230. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +2 -2
  231. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  232. package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -2
  233. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  234. package/lib/feature-libraries/index.d.ts +2 -2
  235. package/lib/feature-libraries/index.d.ts.map +1 -1
  236. package/lib/feature-libraries/index.js +1 -1
  237. package/lib/feature-libraries/index.js.map +1 -1
  238. package/lib/feature-libraries/mapTreeCursor.d.ts +39 -3
  239. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  240. package/lib/feature-libraries/mapTreeCursor.js +43 -7
  241. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  242. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -1
  243. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  244. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +5 -5
  245. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  246. package/lib/feature-libraries/treeCursorUtils.d.ts +5 -1
  247. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  248. package/lib/feature-libraries/treeCursorUtils.js +8 -2
  249. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  250. package/lib/index.d.ts +1 -1
  251. package/lib/index.d.ts.map +1 -1
  252. package/lib/index.js.map +1 -1
  253. package/lib/packageVersion.d.ts +1 -1
  254. package/lib/packageVersion.js +1 -1
  255. package/lib/packageVersion.js.map +1 -1
  256. package/lib/shared-tree/schematizingTreeView.d.ts +11 -1
  257. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  258. package/lib/shared-tree/schematizingTreeView.js +34 -21
  259. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  260. package/lib/shared-tree/sharedTree.d.ts +3 -3
  261. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  262. package/lib/shared-tree/sharedTree.js +2 -1
  263. package/lib/shared-tree/sharedTree.js.map +1 -1
  264. package/lib/shared-tree/tree.d.ts.map +1 -1
  265. package/lib/shared-tree/tree.js +2 -18
  266. package/lib/shared-tree/tree.js.map +1 -1
  267. package/lib/shared-tree/treeAlpha.d.ts +2 -3
  268. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  269. package/lib/shared-tree/treeAlpha.js +4 -6
  270. package/lib/shared-tree/treeAlpha.js.map +1 -1
  271. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  272. package/lib/shared-tree/treeCheckout.js +6 -3
  273. package/lib/shared-tree/treeCheckout.js.map +1 -1
  274. package/lib/simple-tree/api/configuration.d.ts +2 -2
  275. package/lib/simple-tree/api/configuration.js +1 -1
  276. package/lib/simple-tree/api/configuration.js.map +1 -1
  277. package/lib/simple-tree/api/create.d.ts +9 -4
  278. package/lib/simple-tree/api/create.d.ts.map +1 -1
  279. package/lib/simple-tree/api/create.js +22 -9
  280. package/lib/simple-tree/api/create.js.map +1 -1
  281. package/lib/simple-tree/api/customTree.d.ts +4 -0
  282. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  283. package/lib/simple-tree/api/customTree.js +7 -0
  284. package/lib/simple-tree/api/customTree.js.map +1 -1
  285. package/lib/simple-tree/api/index.d.ts +1 -1
  286. package/lib/simple-tree/api/index.d.ts.map +1 -1
  287. package/lib/simple-tree/api/index.js +1 -1
  288. package/lib/simple-tree/api/index.js.map +1 -1
  289. package/lib/simple-tree/api/schemaFactory.d.ts +10 -2
  290. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  291. package/lib/simple-tree/api/schemaFactory.js +40 -11
  292. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  293. package/lib/simple-tree/api/treeNodeApi.d.ts +14 -3
  294. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  295. package/lib/simple-tree/api/treeNodeApi.js +35 -20
  296. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  297. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  298. package/lib/simple-tree/api/verboseTree.js +13 -10
  299. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  300. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  301. package/lib/simple-tree/core/getOrCreateNode.js +3 -2
  302. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  303. package/lib/simple-tree/core/index.d.ts +2 -2
  304. package/lib/simple-tree/core/index.d.ts.map +1 -1
  305. package/lib/simple-tree/core/index.js +2 -2
  306. package/lib/simple-tree/core/index.js.map +1 -1
  307. package/lib/simple-tree/core/treeNodeKernel.d.ts +15 -25
  308. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  309. package/lib/simple-tree/core/treeNodeKernel.js +24 -32
  310. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  311. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +128 -59
  312. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  313. package/lib/simple-tree/core/unhydratedFlexTree.js +166 -181
  314. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  315. package/lib/simple-tree/index.d.ts +3 -3
  316. package/lib/simple-tree/index.d.ts.map +1 -1
  317. package/lib/simple-tree/index.js +3 -3
  318. package/lib/simple-tree/index.js.map +1 -1
  319. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  320. package/lib/simple-tree/node-kinds/array/arrayNode.js +4 -5
  321. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  322. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  323. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  324. package/lib/simple-tree/node-kinds/index.js +1 -1
  325. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  326. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  327. package/lib/simple-tree/node-kinds/map/mapNode.js +3 -3
  328. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  329. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  330. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  331. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  332. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  333. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -14
  334. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  335. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -33
  336. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  337. package/lib/simple-tree/prepareForInsertion.d.ts +20 -6
  338. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  339. package/lib/simple-tree/prepareForInsertion.js +25 -19
  340. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  341. package/lib/simple-tree/schemaTypes.d.ts +8 -8
  342. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  343. package/lib/simple-tree/schemaTypes.js.map +1 -1
  344. package/lib/simple-tree/toStoredSchema.d.ts +6 -1
  345. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  346. package/lib/simple-tree/toStoredSchema.js +4 -1
  347. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  348. package/lib/simple-tree/{toMapTree.d.ts → unhydratedFlexTreeFromInsertable.d.ts} +12 -23
  349. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -0
  350. package/lib/simple-tree/{toMapTree.js → unhydratedFlexTreeFromInsertable.js} +105 -186
  351. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -0
  352. package/lib/treeFactory.d.ts.map +1 -1
  353. package/lib/treeFactory.js +6 -1
  354. package/lib/treeFactory.js.map +1 -1
  355. package/lib/util/index.d.ts +1 -1
  356. package/lib/util/index.d.ts.map +1 -1
  357. package/lib/util/index.js +1 -1
  358. package/lib/util/index.js.map +1 -1
  359. package/lib/util/utils.d.ts +4 -0
  360. package/lib/util/utils.d.ts.map +1 -1
  361. package/lib/util/utils.js +6 -0
  362. package/lib/util/utils.js.map +1 -1
  363. package/package.json +21 -21
  364. package/src/codec/codec.ts +24 -3
  365. package/src/codec/index.ts +1 -0
  366. package/src/codec/versioned/codec.ts +42 -5
  367. package/src/core/tree/detachedFieldIndex.ts +13 -4
  368. package/src/core/tree/mapTree.ts +22 -7
  369. package/src/core/tree/visitorUtils.ts +2 -2
  370. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +3 -2
  371. package/src/feature-libraries/default-schema/schemaChecker.ts +7 -6
  372. package/src/feature-libraries/flex-tree/context.ts +17 -7
  373. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +36 -15
  374. package/src/feature-libraries/flex-tree/index.ts +4 -0
  375. package/src/feature-libraries/flex-tree/lazyField.ts +8 -6
  376. package/src/feature-libraries/flex-tree/lazyNode.ts +6 -2
  377. package/src/feature-libraries/forest-summary/forestSummarizer.ts +3 -2
  378. package/src/feature-libraries/index.ts +9 -0
  379. package/src/feature-libraries/mapTreeCursor.ts +103 -16
  380. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +9 -5
  381. package/src/feature-libraries/treeCursorUtils.ts +21 -10
  382. package/src/index.ts +1 -0
  383. package/src/packageVersion.ts +1 -1
  384. package/src/shared-tree/schematizingTreeView.ts +40 -22
  385. package/src/shared-tree/sharedTree.ts +9 -3
  386. package/src/shared-tree/tree.ts +5 -20
  387. package/src/shared-tree/treeAlpha.ts +17 -11
  388. package/src/shared-tree/treeCheckout.ts +6 -3
  389. package/src/simple-tree/api/configuration.ts +3 -3
  390. package/src/simple-tree/api/create.ts +49 -19
  391. package/src/simple-tree/api/customTree.ts +10 -0
  392. package/src/simple-tree/api/index.ts +1 -4
  393. package/src/simple-tree/api/schemaFactory.ts +62 -13
  394. package/src/simple-tree/api/treeNodeApi.ts +48 -27
  395. package/src/simple-tree/api/verboseTree.ts +15 -12
  396. package/src/simple-tree/core/getOrCreateNode.ts +4 -2
  397. package/src/simple-tree/core/index.ts +2 -3
  398. package/src/simple-tree/core/treeNodeKernel.ts +37 -54
  399. package/src/simple-tree/core/unhydratedFlexTree.ts +222 -261
  400. package/src/simple-tree/index.ts +3 -3
  401. package/src/simple-tree/node-kinds/array/arrayNode.ts +12 -13
  402. package/src/simple-tree/node-kinds/index.ts +0 -1
  403. package/src/simple-tree/node-kinds/map/mapNode.ts +6 -9
  404. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  405. package/src/simple-tree/node-kinds/object/objectNode.ts +7 -49
  406. package/src/simple-tree/prepareForInsertion.ts +49 -42
  407. package/src/simple-tree/schemaTypes.ts +9 -8
  408. package/src/simple-tree/toStoredSchema.ts +7 -1
  409. package/src/simple-tree/{toMapTree.ts → unhydratedFlexTreeFromInsertable.ts} +134 -226
  410. package/src/treeFactory.ts +6 -1
  411. package/src/util/index.ts +1 -0
  412. package/src/util/utils.ts +7 -0
  413. package/dist/simple-tree/toMapTree.d.ts.map +0 -1
  414. package/dist/simple-tree/toMapTree.js.map +0 -1
  415. package/lib/simple-tree/toMapTree.d.ts.map +0 -1
  416. package/lib/simple-tree/toMapTree.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"forestSummarizer.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAE,KAAK,aAAa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AAE,OAAO,EAClB,UAAU,CAAC,EAAE,OAAO,EACpB,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAIpB,IAAI,CAChB,QAAQ,EAAE,sBAAsB,EAChC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,IAAI,CAAC;CAgChB"}
@@ -8,9 +8,8 @@ exports.ForestSummarizer = void 0;
8
8
  const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  const internal_2 = require("@fluidframework/shared-object-base/internal");
11
- const index_js_1 = require("../../codec/index.js");
12
- const index_js_2 = require("../../core/index.js");
13
- const index_js_3 = require("../../util/index.js");
11
+ const index_js_1 = require("../../core/index.js");
12
+ const index_js_2 = require("../../util/index.js");
14
13
  // eslint-disable-next-line import/no-internal-modules
15
14
  const chunkTree_js_1 = require("../chunked-forest/chunkTree.js");
16
15
  const codec_js_1 = require("./codec.js");
@@ -25,12 +24,13 @@ class ForestSummarizer {
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 = { jsonValidator: index_js_1.noopValidator }, idCompressor) {
27
+ constructor(forest, revisionTagCodec, fieldBatchCodec, encoderContext, options, idCompressor) {
29
28
  this.forest = forest;
30
29
  this.revisionTagCodec = revisionTagCodec;
31
30
  this.encoderContext = encoderContext;
32
31
  this.idCompressor = idCompressor;
33
32
  this.key = "Forest";
33
+ // TODO: this should take in CodecWriteOptions, and use it to pick the write version.
34
34
  this.codec = (0, codec_js_1.makeForestSummarizerCodec)(options, fieldBatchCodec);
35
35
  }
36
36
  /**
@@ -44,7 +44,7 @@ class ForestSummarizer {
44
44
  const rootCursor = this.forest.getCursorAboveDetachedFields();
45
45
  const fieldMap = new Map();
46
46
  // TODO: Encode all detached fields in one operation for better performance and compression
47
- (0, index_js_2.forEachField)(rootCursor, (cursor) => {
47
+ (0, index_js_1.forEachField)(rootCursor, (cursor) => {
48
48
  const key = cursor.getFieldKey();
49
49
  const innerCursor = this.forest.allocateCursor("getTreeString");
50
50
  (0, internal_1.assert)(this.forest.tryMoveCursorToField({ fieldKey: key, parent: undefined }, innerCursor) ===
@@ -68,7 +68,7 @@ class ForestSummarizer {
68
68
  // TODO: this code is parsing data without an optional validator, this should be defined in a typebox schema as part of the
69
69
  // forest summary format.
70
70
  const fields = this.codec.decode(parse(treeBufferString), this.encoderContext);
71
- const allocator = (0, index_js_3.idAllocatorFromMaxId)();
71
+ const allocator = (0, index_js_2.idAllocatorFromMaxId)();
72
72
  const fieldChanges = [];
73
73
  const build = [];
74
74
  for (const [fieldKey, field] of fields) {
@@ -84,7 +84,7 @@ class ForestSummarizer {
84
84
  fieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);
85
85
  }
86
86
  (0, internal_1.assert)(this.forest.isEmpty, 0x797 /* forest must be empty */);
87
- (0, index_js_2.applyDelta)({ build, fields: new Map(fieldChanges) }, undefined, this.forest, (0, index_js_2.makeDetachedFieldIndex)("init", this.revisionTagCodec, this.idCompressor));
87
+ (0, index_js_1.applyDelta)({ build, fields: new Map(fieldChanges) }, undefined, this.forest, (0, index_js_1.makeDetachedFieldIndex)("init", this.revisionTagCodec, this.idCompressor));
88
88
  }
89
89
  }
90
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"forestSummarizer.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/forestSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAO7D,0EAAsF;AAEtF,mDAAyE;AACzE,kDAY6B;AAM7B,kDAA2D;AAC3D,sDAAsD;AACtD,iEAAsF;AAGtF,yCAAyE;AAEzE;;GAEG;AACH,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC;;GAEG;AACH,MAAa,gBAAgB;IAK5B;;OAEG;IACH,YACkB,MAAuB,EACvB,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CAAC,EAAE,CAAC;gBACtE,KAAK,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,OAAO;oBACX,KAAK,EAAE,OAAO;iBACd,CAAC,CAAC;gBACH,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YACrF,CAAC;YAED,IAAA,iBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,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;QACH,CAAC;IACF,CAAC;CACD;AApGD,4CAoGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\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\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { createSingleBlobSummary } from \"@fluidframework/shared-object-base/internal\";\n\nimport { type ICodecOptions, noopValidator } 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 type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport { idAllocatorFromMaxId } from \"../../util/index.js\";\n// eslint-disable-next-line import/no-internal-modules\nimport { chunkFieldSingle, defaultChunkPolicy } from \"../chunked-forest/chunkTree.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { type ForestCodec, makeForestSummarizerCodec } from \"./codec.js\";\nimport type { Format } from \"./format.js\";\n/**\n * The storage key for the blob in the summary containing tree data\n */\nconst treeBlobKey = \"ForestTree\";\n\n/**\n * Provides methods for summarizing and loading a forest.\n */\nexport class ForestSummarizer implements Summarizable {\n\tpublic readonly key = \"Forest\";\n\n\tprivate readonly codec: ForestCodec;\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: ICodecOptions = { jsonValidator: noopValidator },\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t) {\n\t\tthis.codec = makeForestSummarizerCodec(options, fieldBatchCodec);\n\t}\n\n\t/**\n\t * Synchronous monolithic summarization of tree content.\n\t *\n\t * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.\n\t *\n\t * @returns a snapshot of the forest's tree as a string.\n\t */\n\tprivate getTreeString(stringify: SummaryElementStringifier): string {\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\t\tconst encoded = this.codec.encode(fieldMap, this.encoderContext);\n\n\t\tfieldMap.forEach((value) => value.free());\n\t\treturn stringify(encoded);\n\t}\n\n\tpublic getAttachSummary(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(treeBlobKey, this.getTreeString(stringify));\n\t}\n\n\tpublic async summarize(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn createSingleBlobSummary(treeBlobKey, this.getTreeString(stringify));\n\t}\n\n\tpublic async load(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tif (await services.contains(treeBlobKey)) {\n\t\t\tconst treeBuffer = await services.readBlob(treeBlobKey);\n\t\t\tconst treeBufferString = bufferToString(treeBuffer, \"utf8\");\n\t\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\t// forest summary format.\n\t\t\tconst fields = this.codec.decode(parse(treeBufferString) as Format, this.encoderContext);\n\t\t\tconst allocator = idAllocatorFromMaxId();\n\t\t\tconst fieldChanges: [FieldKey, DeltaFieldChanges][] = [];\n\t\t\tconst build: DeltaDetachedNodeBuild[] = [];\n\t\t\tfor (const [fieldKey, field] of fields) {\n\t\t\t\tconst chunked = chunkFieldSingle(field, {\n\t\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\t});\n\t\t\t\tconst buildId = { minor: allocator.allocate(chunked.topLevelLength) };\n\t\t\t\tbuild.push({\n\t\t\t\t\tid: buildId,\n\t\t\t\t\ttrees: chunked,\n\t\t\t\t});\n\t\t\t\tfieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);\n\t\t\t}\n\n\t\t\tassert(this.forest.isEmpty, 0x797 /* forest must be empty */);\n\t\t\tapplyDelta(\n\t\t\t\t{ build, fields: new Map(fieldChanges) },\n\t\t\t\tundefined,\n\t\t\t\tthis.forest,\n\t\t\t\tmakeDetachedFieldIndex(\"init\", this.revisionTagCodec, this.idCompressor),\n\t\t\t);\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,+DAA8D;AAC9D,kEAA6D;AAO7D,0EAAsF;AAGtF,kDAY6B;AAM7B,kDAA2D;AAC3D,sDAAsD;AACtD,iEAAsF;AAGtF,yCAAyE;AAEzE;;GAEG;AACH,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC;;GAEG;AACH,MAAa,gBAAgB;IAK5B;;OAEG;IACH,YACkB,MAAuB,EACvB,gBAAkC,EACnD,eAAgC,EACf,cAAyC,EAC1D,OAA0B,EACT,YAA2B;QAL3B,WAAM,GAAN,MAAM,CAAiB;QACvB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAElC,mBAAc,GAAd,cAAc,CAA2B;QAEzC,iBAAY,GAAZ,YAAY,CAAe;QAb7B,QAAG,GAAG,QAAQ,CAAC;QAe9B,qFAAqF;QACrF,IAAI,CAAC,KAAK,GAAG,IAAA,oCAAyB,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACK,aAAa,CAAC,SAAoC;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC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G,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;QACH,CAAC;IACF,CAAC;CACD;AArGD,4CAqGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\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\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { createSingleBlobSummary } from \"@fluidframework/shared-object-base/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 type {\n\tSummarizable,\n\tSummaryElementParser,\n\tSummaryElementStringifier,\n} from \"../../shared-tree-core/index.js\";\nimport { idAllocatorFromMaxId } from \"../../util/index.js\";\n// eslint-disable-next-line import/no-internal-modules\nimport { chunkFieldSingle, defaultChunkPolicy } from \"../chunked-forest/chunkTree.js\";\nimport type { FieldBatchCodec, FieldBatchEncodingContext } from \"../chunked-forest/index.js\";\n\nimport { type ForestCodec, makeForestSummarizerCodec } from \"./codec.js\";\nimport type { Format } from \"./format.js\";\n/**\n * The storage key for the blob in the summary containing tree data\n */\nconst treeBlobKey = \"ForestTree\";\n\n/**\n * Provides methods for summarizing and loading a forest.\n */\nexport class ForestSummarizer implements Summarizable {\n\tpublic readonly key = \"Forest\";\n\n\tprivate readonly codec: ForestCodec;\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) {\n\t\t// TODO: this should take in CodecWriteOptions, and use it to pick the write version.\n\t\tthis.codec = makeForestSummarizerCodec(options, fieldBatchCodec);\n\t}\n\n\t/**\n\t * Synchronous monolithic summarization of tree content.\n\t *\n\t * TODO: when perf matters, this should be replaced with a chunked async version using a binary format.\n\t *\n\t * @returns a snapshot of the forest's tree as a string.\n\t */\n\tprivate getTreeString(stringify: SummaryElementStringifier): string {\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\t\tconst encoded = this.codec.encode(fieldMap, this.encoderContext);\n\n\t\tfieldMap.forEach((value) => value.free());\n\t\treturn stringify(encoded);\n\t}\n\n\tpublic getAttachSummary(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(treeBlobKey, this.getTreeString(stringify));\n\t}\n\n\tpublic async summarize(\n\t\tstringify: SummaryElementStringifier,\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn createSingleBlobSummary(treeBlobKey, this.getTreeString(stringify));\n\t}\n\n\tpublic async load(\n\t\tservices: IChannelStorageService,\n\t\tparse: SummaryElementParser,\n\t): Promise<void> {\n\t\tif (await services.contains(treeBlobKey)) {\n\t\t\tconst treeBuffer = await services.readBlob(treeBlobKey);\n\t\t\tconst treeBufferString = bufferToString(treeBuffer, \"utf8\");\n\t\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\t// forest summary format.\n\t\t\tconst fields = this.codec.decode(parse(treeBufferString) as Format, this.encoderContext);\n\t\t\tconst allocator = idAllocatorFromMaxId();\n\t\t\tconst fieldChanges: [FieldKey, DeltaFieldChanges][] = [];\n\t\t\tconst build: DeltaDetachedNodeBuild[] = [];\n\t\t\tfor (const [fieldKey, field] of fields) {\n\t\t\t\tconst chunked = chunkFieldSingle(field, {\n\t\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\t});\n\t\t\t\tconst buildId = { minor: allocator.allocate(chunked.topLevelLength) };\n\t\t\t\tbuild.push({\n\t\t\t\t\tid: buildId,\n\t\t\t\t\ttrees: chunked,\n\t\t\t\t});\n\t\t\t\tfieldChanges.push([fieldKey, [{ count: chunked.topLevelLength, attach: buildId }]]);\n\t\t\t}\n\n\t\t\tassert(this.forest.isEmpty, 0x797 /* forest must be empty */);\n\t\t\tapplyDelta(\n\t\t\t\t{ build, fields: new Map(fieldChanges) },\n\t\t\t\tundefined,\n\t\t\t\tthis.forest,\n\t\t\t\tmakeDetachedFieldIndex(\"init\", this.revisionTagCodec, this.idCompressor),\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  export { type DownPath, toDownPath, } from "./editableTreeBinder.js";
6
6
  export { allowsValue, assertAllowedValue, isTreeValue } from "./valueUtilities.js";
7
7
  export { ForestSummarizer } from "./forest-summary/index.js";
8
- export { cursorForMapTreeField, cursorForMapTreeNode, mapTreeFromCursor, mapTreeFieldFromCursor, } from "./mapTreeCursor.js";
8
+ export { cursorForMapTreeField, cursorForMapTreeNode, mapTreeFromCursor, mapTreeFieldFromCursor, type MinimalMapTreeNodeView, mapTreeFieldsWithField, mapTreeWithField, type MapTreeFieldViewGeneric, type MapTreeNodeViewGeneric, } from "./mapTreeCursor.js";
9
9
  export { buildForest } from "./object-forest/index.js";
10
10
  export { SchemaSummarizer, encodeTreeSchema, makeSchemaCodec, makeSchemaCodecs, } from "./schema-index/index.js";
11
11
  export { stackTreeNodeCursor, type CursorAdapter, prefixPath, prefixFieldPath, type CursorWithNode, stackTreeFieldCursor, } from "./treeCursorUtils.js";
@@ -17,7 +17,7 @@ export { mapRootChanges } from "./deltaUtils.js";
17
17
  export { type TreeChunk, chunkTree, chunkFieldSingle, buildChunkedForest, defaultChunkPolicy, type FieldBatch, type FieldBatchCodec, makeTreeChunker, makeFieldBatchCodec, fluidVersionToFieldBatchCodecWriteVersion, type FieldBatchEncodingContext, } from "./chunked-forest/index.js";
18
18
  export { compareLocalNodeIdentifiers, createNodeIdentifierManager, isStableNodeIdentifier, type LocalNodeIdentifier, MockNodeIdentifierManager, type NodeIdentifierManager, nodeKeyTreeIdentifier, type StableNodeIdentifier, } from "./node-identifier/index.js";
19
19
  export { FieldKinds, type Required, type Optional, type Sequence, type Identifier, type Forbidden, type DefaultChangeset, DefaultChangeFamily, DefaultEditBuilder, type IDefaultEditBuilder, type ValueFieldEditBuilder, type OptionalFieldEditBuilder, type SequenceFieldEditBuilder, defaultSchemaPolicy, fieldKinds, fieldKindConfigurations, intoDelta, relevantRemovedRoots, SchemaValidationError, isNodeInSchema, isFieldInSchema, inSchemaOrThrow, } from "./default-schema/index.js";
20
- export { type FlexTreeOptionalField, type FlexTreeRequiredField, type FlexTreeSequenceField, Skip, type FlexTreeContext, type FlexTreeHydratedContext, type FlexTreeTypedField, type FlexTreeEntity, type FlexTreeField, type FlexTreeNode, TreeStatus, Context, type FlexTreeNodeEvents, type FlexTreeUnknownUnboxed, isFlexTreeNode, ContextSlot, flexTreeMarker, assertFlexTreeEntityNotFreed, flexTreeSlot, getSchemaAndPolicy, LazyEntity, treeStatusFromAnchorCache, indexForAt, FlexTreeEntityKind, } from "./flex-tree/index.js";
20
+ export { type FlexTreeOptionalField, type FlexTreeRequiredField, type FlexTreeSequenceField, Skip, type FlexTreeContext, type FlexTreeHydratedContext, type FlexTreeTypedField, type FlexTreeEntity, type FlexTreeField, type FlexTreeNode, TreeStatus, Context, type FlexTreeNodeEvents, type FlexTreeUnknownUnboxed, isFlexTreeNode, ContextSlot, flexTreeMarker, assertFlexTreeEntityNotFreed, flexTreeSlot, getSchemaAndPolicy, LazyEntity, treeStatusFromAnchorCache, indexForAt, FlexTreeEntityKind, type FlexibleNodeContent, type FlexibleFieldContent, type FlexTreeHydratedContextMinimal, type HydratedFlexTreeNode, } from "./flex-tree/index.js";
21
21
  export { TreeCompressionStrategy } from "./treeCompressionUtils.js";
22
22
  export { valueSchemaAllows } from "./valueUtilities.js";
23
23
  export { DetachedFieldIndexSummarizer } from "./detachedFieldIndexSummarizer.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,QAAQ,EACb,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC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B,EAC3B,cAAc,EACd,WAAW,EAEX,cAAc,EACd,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EACN,KAAK,YAAY,EACjB,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EACN,KAAK,SAAS,EACd,eAAe,EACf,UAAU,EACV,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -27,8 +27,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
27
27
  return result;
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.fluidVersionToFieldBatchCodecWriteVersion = exports.makeFieldBatchCodec = exports.makeTreeChunker = exports.defaultChunkPolicy = exports.buildChunkedForest = exports.chunkFieldSingle = exports.chunkTree = exports.mapRootChanges = exports.posetLte = exports.comparePosetElements = exports.PosetComparisonResult = exports.fieldRealizer = exports.isNeverTree = exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = exports.updateRefreshers = exports.EncodedModularChangeset = exports.ModularChangeFamily = exports.FieldKindWithEditor = exports.genericFieldKind = exports.allowsRepoSuperset = exports.FlexFieldKind = exports.CrossFieldTarget = exports.makeModularChangeCodecFamily = exports.ModularEditBuilder = exports.isNeverField = exports.SequenceField = exports.jsonableTreeFromForest = exports.jsonableTreeFromFieldCursor = exports.jsonableTreeFromCursor = exports.cursorForJsonableTreeField = exports.cursorForJsonableTreeNode = exports.stackTreeFieldCursor = exports.prefixFieldPath = exports.prefixPath = exports.stackTreeNodeCursor = exports.makeSchemaCodecs = exports.makeSchemaCodec = exports.encodeTreeSchema = exports.SchemaSummarizer = exports.buildForest = exports.mapTreeFieldFromCursor = exports.mapTreeFromCursor = exports.cursorForMapTreeNode = exports.cursorForMapTreeField = exports.ForestSummarizer = exports.isTreeValue = exports.assertAllowedValue = exports.allowsValue = exports.toDownPath = void 0;
31
- exports.initializeForest = exports.hasElement = exports.AnchorTreeIndex = exports.makeMitigatedChangeFamily = exports.EncodedSchemaChange = exports.makeSchemaChangeCodecs = exports.DetachedFieldIndexSummarizer = exports.valueSchemaAllows = exports.TreeCompressionStrategy = exports.FlexTreeEntityKind = exports.indexForAt = exports.treeStatusFromAnchorCache = exports.LazyEntity = exports.getSchemaAndPolicy = exports.flexTreeSlot = exports.assertFlexTreeEntityNotFreed = exports.flexTreeMarker = exports.ContextSlot = exports.isFlexTreeNode = exports.Context = exports.TreeStatus = exports.Skip = exports.inSchemaOrThrow = exports.isFieldInSchema = exports.isNodeInSchema = exports.SchemaValidationError = exports.relevantRemovedRoots = exports.intoDelta = exports.fieldKindConfigurations = exports.fieldKinds = exports.defaultSchemaPolicy = exports.DefaultEditBuilder = exports.DefaultChangeFamily = exports.FieldKinds = exports.nodeKeyTreeIdentifier = exports.MockNodeIdentifierManager = exports.isStableNodeIdentifier = exports.createNodeIdentifierManager = exports.compareLocalNodeIdentifiers = void 0;
30
+ exports.makeTreeChunker = exports.defaultChunkPolicy = exports.buildChunkedForest = exports.chunkFieldSingle = exports.chunkTree = exports.mapRootChanges = exports.posetLte = exports.comparePosetElements = exports.PosetComparisonResult = exports.fieldRealizer = exports.isNeverTree = exports.isRepoSuperset = exports.getAllowedContentDiscrepancies = exports.updateRefreshers = exports.EncodedModularChangeset = exports.ModularChangeFamily = exports.FieldKindWithEditor = exports.genericFieldKind = exports.allowsRepoSuperset = exports.FlexFieldKind = exports.CrossFieldTarget = exports.makeModularChangeCodecFamily = exports.ModularEditBuilder = exports.isNeverField = exports.SequenceField = exports.jsonableTreeFromForest = exports.jsonableTreeFromFieldCursor = exports.jsonableTreeFromCursor = exports.cursorForJsonableTreeField = exports.cursorForJsonableTreeNode = exports.stackTreeFieldCursor = exports.prefixFieldPath = exports.prefixPath = exports.stackTreeNodeCursor = exports.makeSchemaCodecs = exports.makeSchemaCodec = exports.encodeTreeSchema = exports.SchemaSummarizer = exports.buildForest = exports.mapTreeWithField = exports.mapTreeFieldsWithField = exports.mapTreeFieldFromCursor = exports.mapTreeFromCursor = exports.cursorForMapTreeNode = exports.cursorForMapTreeField = exports.ForestSummarizer = exports.isTreeValue = exports.assertAllowedValue = exports.allowsValue = exports.toDownPath = void 0;
31
+ exports.initializeForest = exports.hasElement = exports.AnchorTreeIndex = exports.makeMitigatedChangeFamily = exports.EncodedSchemaChange = exports.makeSchemaChangeCodecs = exports.DetachedFieldIndexSummarizer = exports.valueSchemaAllows = exports.TreeCompressionStrategy = exports.FlexTreeEntityKind = exports.indexForAt = exports.treeStatusFromAnchorCache = exports.LazyEntity = exports.getSchemaAndPolicy = exports.flexTreeSlot = exports.assertFlexTreeEntityNotFreed = exports.flexTreeMarker = exports.ContextSlot = exports.isFlexTreeNode = exports.Context = exports.TreeStatus = exports.Skip = exports.inSchemaOrThrow = exports.isFieldInSchema = exports.isNodeInSchema = exports.SchemaValidationError = exports.relevantRemovedRoots = exports.intoDelta = exports.fieldKindConfigurations = exports.fieldKinds = exports.defaultSchemaPolicy = exports.DefaultEditBuilder = exports.DefaultChangeFamily = exports.FieldKinds = exports.nodeKeyTreeIdentifier = exports.MockNodeIdentifierManager = exports.isStableNodeIdentifier = exports.createNodeIdentifierManager = exports.compareLocalNodeIdentifiers = exports.fluidVersionToFieldBatchCodecWriteVersion = exports.makeFieldBatchCodec = void 0;
32
32
  var editableTreeBinder_js_1 = require("./editableTreeBinder.js");
33
33
  Object.defineProperty(exports, "toDownPath", { enumerable: true, get: function () { return editableTreeBinder_js_1.toDownPath; } });
34
34
  var valueUtilities_js_1 = require("./valueUtilities.js");
@@ -42,6 +42,8 @@ Object.defineProperty(exports, "cursorForMapTreeField", { enumerable: true, get:
42
42
  Object.defineProperty(exports, "cursorForMapTreeNode", { enumerable: true, get: function () { return mapTreeCursor_js_1.cursorForMapTreeNode; } });
43
43
  Object.defineProperty(exports, "mapTreeFromCursor", { enumerable: true, get: function () { return mapTreeCursor_js_1.mapTreeFromCursor; } });
44
44
  Object.defineProperty(exports, "mapTreeFieldFromCursor", { enumerable: true, get: function () { return mapTreeCursor_js_1.mapTreeFieldFromCursor; } });
45
+ Object.defineProperty(exports, "mapTreeFieldsWithField", { enumerable: true, get: function () { return mapTreeCursor_js_1.mapTreeFieldsWithField; } });
46
+ Object.defineProperty(exports, "mapTreeWithField", { enumerable: true, get: function () { return mapTreeCursor_js_1.mapTreeWithField; } });
45
47
  var index_js_2 = require("./object-forest/index.js");
46
48
  Object.defineProperty(exports, "buildForest", { enumerable: true, get: function () { return index_js_2.buildForest; } });
47
49
  var index_js_3 = require("./schema-index/index.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAGiC;AADhC,mHAAA,UAAU,OAAA;AAEX,yDAAmF;AAA1E,gHAAA,WAAW,OAAA;AAAE,uHAAA,kBAAkB,OAAA;AAAE,gHAAA,WAAW,OAAA;AAErD,sDAA6D;AAApD,4GAAA,gBAAgB,OAAA;AACzB,uDAK4B;AAJ3B,yHAAA,qBAAqB,OAAA;AACrB,wHAAA,oBAAoB,OAAA;AACpB,qHAAA,iBAAiB,OAAA;AACjB,0HAAA,sBAAsB,OAAA;AAEvB,qDAAuD;AAA9C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corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n} from \"./mapTreeCursor.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport {\n\tSchemaSummarizer,\n\tencodeTreeSchema,\n\tmakeSchemaCodec,\n\tmakeSchemaCodecs,\n} from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n\ttype AllowedTypeDiscrepancy,\n\ttype FieldKindDiscrepancy,\n\ttype ValueSchemaDiscrepancy,\n\ttype FieldDiscrepancy,\n\ttype NodeDiscrepancy,\n\ttype NodeKindDiscrepancy,\n\ttype NodeFieldsDiscrepancy,\n\tisNeverTree,\n\ttype LinearExtension,\n\ttype Realizer,\n\tfieldRealizer,\n\tPosetComparisonResult,\n\tcomparePosetElements,\n\tposetLte,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeIdentifiers,\n\tcreateNodeIdentifierManager,\n\tisStableNodeIdentifier,\n\ttype LocalNodeIdentifier,\n\tMockNodeIdentifierManager,\n\ttype NodeIdentifierManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeIdentifier,\n} from \"./node-identifier/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationError,\n\tisNodeInSchema,\n\tisFieldInSchema,\n\tinSchemaOrThrow,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n\nexport {\n\ttype KeyFinder,\n\tAnchorTreeIndex,\n\thasElement,\n\ttype TreeIndex,\n\ttype TreeIndexKey,\n\ttype TreeIndexNodes,\n} from \"./indexing/index.js\";\n\nexport { initializeForest } from \"./initializeForest.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-libraries/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAGiC;AADhC,mHAAA,UAAU,OAAA;AAEX,yDAAmF;AAA1E,gHAAA,WAAW,OAAA;AAAE,u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FAAiF;AAAxE,+IAAA,4BAA4B,OAAA;AAErC,oDAIiC;AAFhC,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AAGpB,uEAAuE;AAA9D,qIAAA,yBAAyB,OAAA;AAElC,iDAO6B;AAL5B,4GAAA,eAAe,OAAA;AACf,uGAAA,UAAU,OAAA;AAMX,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype DownPath,\n\ttoDownPath,\n} from \"./editableTreeBinder.js\";\nexport { allowsValue, assertAllowedValue, isTreeValue } from \"./valueUtilities.js\";\n\nexport { ForestSummarizer } from \"./forest-summary/index.js\";\nexport {\n\tcursorForMapTreeField,\n\tcursorForMapTreeNode,\n\tmapTreeFromCursor,\n\tmapTreeFieldFromCursor,\n\ttype MinimalMapTreeNodeView,\n\tmapTreeFieldsWithField,\n\tmapTreeWithField,\n\ttype MapTreeFieldViewGeneric,\n\ttype MapTreeNodeViewGeneric,\n} from \"./mapTreeCursor.js\";\nexport { buildForest } from \"./object-forest/index.js\";\nexport {\n\tSchemaSummarizer,\n\tencodeTreeSchema,\n\tmakeSchemaCodec,\n\tmakeSchemaCodecs,\n} from \"./schema-index/index.js\";\nexport {\n\tstackTreeNodeCursor,\n\ttype CursorAdapter,\n\tprefixPath,\n\tprefixFieldPath,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n} from \"./treeCursorUtils.js\";\nexport {\n\tcursorForJsonableTreeNode,\n\tcursorForJsonableTreeField,\n\tjsonableTreeFromCursor,\n\tjsonableTreeFromFieldCursor,\n\tjsonableTreeFromForest,\n} from \"./treeTextCursor.js\";\n\n// Split this up into separate import and export for compatibility with API-Extractor.\nimport * as SequenceField from \"./sequence-field/index.js\";\nexport { SequenceField };\n\nexport {\n\tisNeverField,\n\tModularEditBuilder,\n\ttype FieldEditDescription as EditDescription,\n\ttype FieldChangeHandler,\n\ttype FieldChangeRebaser,\n\ttype FieldEditor,\n\ttype FieldChangeMap,\n\ttype FieldChange,\n\ttype FieldChangeset,\n\ttype ToDelta,\n\ttype ModularChangeset,\n\tmakeModularChangeCodecFamily,\n\ttype NodeChangeComposer,\n\ttype NodeChangeInverter,\n\ttype NodeChangeRebaser,\n\ttype NodeChangePruner,\n\ttype CrossFieldManager,\n\tCrossFieldTarget,\n\tFlexFieldKind,\n\ttype FullSchemaPolicy,\n\tallowsRepoSuperset,\n\ttype GenericChangeset,\n\tgenericFieldKind,\n\ttype HasFieldChanges,\n\ttype NodeExistsConstraint,\n\tFieldKindWithEditor,\n\tModularChangeFamily,\n\ttype RelevantRemovedRootsFromChild,\n\tEncodedModularChangeset,\n\tupdateRefreshers,\n\ttype NodeId,\n\ttype FieldChangeEncodingContext,\n\ttype FieldKindConfiguration,\n\ttype FieldKindConfigurationEntry,\n\tgetAllowedContentDiscrepancies,\n\tisRepoSuperset,\n\ttype AllowedTypeDiscrepancy,\n\ttype FieldKindDiscrepancy,\n\ttype ValueSchemaDiscrepancy,\n\ttype FieldDiscrepancy,\n\ttype NodeDiscrepancy,\n\ttype NodeKindDiscrepancy,\n\ttype NodeFieldsDiscrepancy,\n\tisNeverTree,\n\ttype LinearExtension,\n\ttype Realizer,\n\tfieldRealizer,\n\tPosetComparisonResult,\n\tcomparePosetElements,\n\tposetLte,\n} from \"./modular-schema/index.js\";\n\nexport { mapRootChanges } from \"./deltaUtils.js\";\n\nexport {\n\ttype TreeChunk,\n\tchunkTree,\n\tchunkFieldSingle,\n\tbuildChunkedForest,\n\tdefaultChunkPolicy,\n\ttype FieldBatch,\n\ttype FieldBatchCodec,\n\tmakeTreeChunker,\n\tmakeFieldBatchCodec,\n\tfluidVersionToFieldBatchCodecWriteVersion,\n\ttype FieldBatchEncodingContext,\n} from \"./chunked-forest/index.js\";\n\nexport {\n\tcompareLocalNodeIdentifiers,\n\tcreateNodeIdentifierManager,\n\tisStableNodeIdentifier,\n\ttype LocalNodeIdentifier,\n\tMockNodeIdentifierManager,\n\ttype NodeIdentifierManager,\n\tnodeKeyTreeIdentifier,\n\ttype StableNodeIdentifier,\n} from \"./node-identifier/index.js\";\n\nexport {\n\tFieldKinds,\n\ttype Required,\n\ttype Optional,\n\ttype Sequence,\n\ttype Identifier,\n\ttype Forbidden,\n\ttype DefaultChangeset,\n\tDefaultChangeFamily,\n\tDefaultEditBuilder,\n\ttype IDefaultEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\tdefaultSchemaPolicy,\n\tfieldKinds,\n\tfieldKindConfigurations,\n\tintoDelta,\n\trelevantRemovedRoots,\n\tSchemaValidationError,\n\tisNodeInSchema,\n\tisFieldInSchema,\n\tinSchemaOrThrow,\n} from \"./default-schema/index.js\";\n\nexport {\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\tSkip,\n\ttype FlexTreeContext,\n\ttype FlexTreeHydratedContext,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeEntity,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\tTreeStatus,\n\tContext,\n\ttype FlexTreeNodeEvents,\n\ttype FlexTreeUnknownUnboxed,\n\tisFlexTreeNode,\n\tContextSlot,\n\t// Internal\n\tflexTreeMarker,\n\tassertFlexTreeEntityNotFreed,\n\tflexTreeSlot,\n\tgetSchemaAndPolicy,\n\tLazyEntity,\n\ttreeStatusFromAnchorCache,\n\tindexForAt,\n\tFlexTreeEntityKind,\n\ttype FlexibleNodeContent,\n\ttype FlexibleFieldContent,\n\ttype FlexTreeHydratedContextMinimal,\n\ttype HydratedFlexTreeNode,\n} from \"./flex-tree/index.js\";\n\nexport { TreeCompressionStrategy } from \"./treeCompressionUtils.js\";\n\nexport { valueSchemaAllows } from \"./valueUtilities.js\";\n\nexport { DetachedFieldIndexSummarizer } from \"./detachedFieldIndexSummarizer.js\";\n\nexport {\n\ttype SchemaChange,\n\tmakeSchemaChangeCodecs,\n\tEncodedSchemaChange,\n} from \"./schema-edits/index.js\";\n\nexport { makeMitigatedChangeFamily } from \"./mitigatedChangeFamily.js\";\n\nexport {\n\ttype KeyFinder,\n\tAnchorTreeIndex,\n\thasElement,\n\ttype TreeIndex,\n\ttype TreeIndexKey,\n\ttype TreeIndexNodes,\n} from \"./indexing/index.js\";\n\nexport { initializeForest } from \"./initializeForest.js\";\n"]}
@@ -2,16 +2,52 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type DetachedField, type ExclusiveMapTree, type ITreeCursor, type MapTree } from "../core/index.js";
5
+ import { type DetachedField, type ExclusiveMapTree, type FieldKey, type ITreeCursor, type NodeData } from "../core/index.js";
6
6
  import { type CursorWithNode } from "./treeCursorUtils.js";
7
+ /**
8
+ * A generic variant of {@link MapTree} that can be used to strongly type trees implementing a MapTree-like API.
9
+ * @remarks
10
+ * Due to how TypeScript handles recursive generic types, explicitly named extension interfaces work best for parameterizing this, and a default type parameter can't be provided.
11
+ * @see {@link MinimalMapTreeNodeView} for a minimal configuration of this interface.
12
+ */
13
+ export interface MapTreeNodeViewGeneric<TNode> extends NodeData {
14
+ /**
15
+ * The non-empty fields on this node.
16
+ * @remarks
17
+ * This is the subset of map needed to view the tree.
18
+ * Theoretically `Symbol.iterator` and "keys" are redundant.
19
+ */
20
+ readonly fields: Pick<Map<FieldKey, MapTreeFieldViewGeneric<TNode>>, typeof Symbol.iterator | "get">;
21
+ }
22
+ /**
23
+ * A field in {@link MapTreeNodeViewGeneric}.
24
+ */
25
+ export type MapTreeFieldViewGeneric<TNode> = Pick<readonly TNode[], typeof Symbol.iterator | "length">;
26
+ /**
27
+ * Like {@link MapTree} but with the minimal properties needed for reading.
28
+ */
29
+ export interface MinimalMapTreeNodeView extends MapTreeNodeViewGeneric<MinimalMapTreeNodeView> {
30
+ }
7
31
  /**
8
32
  * Returns an {@link ITreeCursorSynchronous} in nodes mode for a single {@link MapTree}.
9
33
  */
10
- export declare function cursorForMapTreeNode(root: MapTree): CursorWithNode<MapTree>;
34
+ export declare function cursorForMapTreeNode<T extends MapTreeNodeViewGeneric<T>>(root: T): CursorWithNode<T>;
35
+ /**
36
+ * Creates an {@link ExclusiveMapTree} with a single field and no value.
37
+ * @remarks
38
+ * This handles ensuring the field is omitted if empty, and defaults to making the node above the root.
39
+ */
40
+ export declare function mapTreeWithField(children: ExclusiveMapTree[], key?: FieldKey, type?: import("../core/index.js").TreeNodeSchemaIdentifier): ExclusiveMapTree;
41
+ /**
42
+ * Creates a Map suitable for use as {@link MapTree.fields} with a single field.
43
+ * @remarks
44
+ * This handles ensuring the field is omitted if empty.
45
+ */
46
+ export declare function mapTreeFieldsWithField<T extends readonly unknown[]>(children: T, key: FieldKey): Map<FieldKey, T>;
11
47
  /**
12
48
  * Returns an {@link ITreeCursorSynchronous} in fields mode for a MapTree field.
13
49
  */
14
- export declare function cursorForMapTreeField(root: readonly MapTree[], detachedField?: DetachedField): CursorWithNode<MapTree>;
50
+ export declare function cursorForMapTreeField<T extends MapTreeNodeViewGeneric<T>>(root: readonly T[], detachedField?: DetachedField): CursorWithNode<T>;
15
51
  /**
16
52
  * Extract a MapTree from the contents of the given ITreeCursor's current node.
17
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mapTreeCursor.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/mapTreeCursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,KAAK,OAAO,EAKZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,KAAK,cAAc,EAGnB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAE3E;AAED;;GAEG;AACH,wBA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AC/B,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,GAAG,WAAe,EAClB,IAAI,sDAAuB,GACzB,gBAAgB,CAKlB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAClE,QAAQ,EAAE,CAAC,EACX,GAAG,EAAE,QAAQ,GACX,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAElB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,sBAAsB,CAAC,CAAC,CAAC,EACxE,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,aAAa,GAAE,aAAyB,GACtC,cAAc,CAAC,CAAC,CAAC,CAQnB;AAsBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,CAevE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,EAAE,CAG9E"}
@@ -4,33 +4,71 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.mapTreeFieldFromCursor = exports.mapTreeFromCursor = exports.cursorForMapTreeField = exports.cursorForMapTreeNode = void 0;
7
+ exports.mapTreeFieldFromCursor = exports.mapTreeFromCursor = exports.cursorForMapTreeField = exports.mapTreeFieldsWithField = exports.mapTreeWithField = exports.cursorForMapTreeNode = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../core/index.js");
10
10
  const treeCursorUtils_js_1 = require("./treeCursorUtils.js");
11
+ {
12
+ }
11
13
  /**
12
14
  * Returns an {@link ITreeCursorSynchronous} in nodes mode for a single {@link MapTree}.
13
15
  */
14
16
  function cursorForMapTreeNode(root) {
15
- return (0, treeCursorUtils_js_1.stackTreeNodeCursor)(adapter, root);
17
+ // There doesn't seem to be a clean way to get TypeScript to type check this without casting
18
+ // without declaring the adapter inside this generic function and needlessly recreating it on every call.
19
+ const adapterTyped = adapter;
20
+ return (0, treeCursorUtils_js_1.stackTreeNodeCursor)(adapterTyped, root);
16
21
  }
17
22
  exports.cursorForMapTreeNode = cursorForMapTreeNode;
23
+ /**
24
+ * Creates an {@link ExclusiveMapTree} with a single field and no value.
25
+ * @remarks
26
+ * This handles ensuring the field is omitted if empty, and defaults to making the node above the root.
27
+ */
28
+ function mapTreeWithField(children, key = index_js_1.rootFieldKey, type = index_js_1.aboveRootPlaceholder) {
29
+ return {
30
+ type,
31
+ fields: mapTreeFieldsWithField(children, key),
32
+ };
33
+ }
34
+ exports.mapTreeWithField = mapTreeWithField;
35
+ /**
36
+ * Creates a Map suitable for use as {@link MapTree.fields} with a single field.
37
+ * @remarks
38
+ * This handles ensuring the field is omitted if empty.
39
+ */
40
+ function mapTreeFieldsWithField(children, key) {
41
+ return new Map(children.length === 0 ? [] : [[key, children]]);
42
+ }
43
+ exports.mapTreeFieldsWithField = mapTreeFieldsWithField;
18
44
  /**
19
45
  * Returns an {@link ITreeCursorSynchronous} in fields mode for a MapTree field.
20
46
  */
21
47
  function cursorForMapTreeField(root, detachedField = index_js_1.rootField) {
22
48
  const key = (0, index_js_1.detachedFieldAsKey)(detachedField);
23
- return (0, treeCursorUtils_js_1.stackTreeFieldCursor)(adapter, {
49
+ const adapterTyped = adapter;
50
+ const dummyRoot = {
24
51
  type: index_js_1.aboveRootPlaceholder,
25
- fields: new Map([[key, root]]),
26
- }, detachedField);
52
+ fields: mapTreeFieldsWithField(root, key),
53
+ };
54
+ return (0, treeCursorUtils_js_1.stackTreeFieldCursor)(adapterTyped, dummyRoot, detachedField);
27
55
  }
28
56
  exports.cursorForMapTreeField = cursorForMapTreeField;
29
57
  const adapter = {
30
58
  value: (node) => node.value,
31
59
  type: (node) => node.type,
32
- keysFromNode: (node) => [...node.fields.keys()], // TODO: don't convert this to array here.
33
- getFieldFromNode: (node, key) => node.fields.get(key) ?? [],
60
+ keysFromNode: (node) => Array.from(node.fields, ([key, field]) => key),
61
+ getFieldFromNode: (node, key) => {
62
+ const field = node.fields.get(key);
63
+ if (field === undefined) {
64
+ return [];
65
+ }
66
+ if (Array.isArray(field)) {
67
+ return field;
68
+ }
69
+ // TODO: this copy could be avoided by using Array.at instead of indexing in `Field`, but that requires ES2022.
70
+ return [...field];
71
+ },
34
72
  };
35
73
  /**
36
74
  * Extract a MapTree from the contents of the given ITreeCursor's current node.
@@ -1 +1 @@
1
- {"version":3,"file":"mapTreeCursor.js","sourceRoot":"","sources":["../../src/feature-libraries/mapTreeCursor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,+CAW0B;AAE1B,6DAK8B;AAE9B;;GAEG;AACH,SAAgB,oBAAoB,CAAC,IAAa;IACjD,OAAO,IAAA,wCAAmB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAFD,oDAEC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACpC,IAAwB,EACxB,gBAA+B,oBAAS;IAExC,MAAM,GAAG,GAAG,IAAA,6BAAkB,EAAC,aAAa,CAAC,CAAC;IAC9C,OAAO,IAAA,yCAAoB,EAC1B,OAAO,EACP;QACC,IAAI,EAAE,+BAAoB;QAC1B,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KAC9B,EACD,aAAa,CACb,CAAC;AACH,CAAC;AAbD,sDAaC;AAED,MAAM,OAAO,GAA2B;IACvC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK;IAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI;IACzB,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,0CAA0C;IAC3F,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE;CAC3D,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAAC,MAAmB;IACpD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACjF,MAAM,MAAM,GAAsC,IAAI,GAAG,EAAE,CAAC;IAC5D,KAAK,IAAI,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;QAC/E,MAAM,KAAK,GAAuB,IAAA,yBAAc,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC5E,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,IAAI,GAAqB;QAC9B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM;KACN,CAAC;IAEF,OAAO,IAAI,CAAC;AACb,CAAC;AAfD,8CAeC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,MAAmB;IACzD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,sCAA8B,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnF,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAClD,CAAC;AAHD,wDAGC","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\";\n\nimport {\n\tCursorLocationType,\n\ttype DetachedField,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype MapTree,\n\taboveRootPlaceholder,\n\tdetachedFieldAsKey,\n\tmapCursorField,\n\trootField,\n} from \"../core/index.js\";\n\nimport {\n\ttype CursorAdapter,\n\ttype CursorWithNode,\n\tstackTreeFieldCursor,\n\tstackTreeNodeCursor,\n} from \"./treeCursorUtils.js\";\n\n/**\n * Returns an {@link ITreeCursorSynchronous} in nodes mode for a single {@link MapTree}.\n */\nexport function cursorForMapTreeNode(root: MapTree): CursorWithNode<MapTree> {\n\treturn stackTreeNodeCursor(adapter, root);\n}\n\n/**\n * Returns an {@link ITreeCursorSynchronous} in fields mode for a MapTree field.\n */\nexport function cursorForMapTreeField(\n\troot: readonly MapTree[],\n\tdetachedField: DetachedField = rootField,\n): CursorWithNode<MapTree> {\n\tconst key = detachedFieldAsKey(detachedField);\n\treturn stackTreeFieldCursor(\n\t\tadapter,\n\t\t{\n\t\t\ttype: aboveRootPlaceholder,\n\t\t\tfields: new Map([[key, root]]),\n\t\t},\n\t\tdetachedField,\n\t);\n}\n\nconst adapter: CursorAdapter<MapTree> = {\n\tvalue: (node) => node.value,\n\ttype: (node) => node.type,\n\tkeysFromNode: (node) => [...node.fields.keys()], // TODO: don't convert this to array here.\n\tgetFieldFromNode: (node, key) => node.fields.get(key) ?? [],\n};\n\n/**\n * Extract a MapTree from the contents of the given ITreeCursor's current node.\n */\nexport function mapTreeFromCursor(cursor: ITreeCursor): ExclusiveMapTree {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x3b7 /* must start at node */);\n\tconst fields: Map<FieldKey, ExclusiveMapTree[]> = new Map();\n\tfor (let inField = cursor.firstField(); inField; inField = cursor.nextField()) {\n\t\tconst field: ExclusiveMapTree[] = mapCursorField(cursor, mapTreeFromCursor);\n\t\tfields.set(cursor.getFieldKey(), field);\n\t}\n\n\tconst node: ExclusiveMapTree = {\n\t\ttype: cursor.type,\n\t\tvalue: cursor.value,\n\t\tfields,\n\t};\n\n\treturn node;\n}\n\n/**\n * Extract an array of MapTrees (a field) from the contents of the given ITreeCursor's current field.\n */\nexport function mapTreeFieldFromCursor(cursor: ITreeCursor): ExclusiveMapTree[] {\n\tassert(cursor.mode === CursorLocationType.Fields, 0xa03 /* must start at field */);\n\treturn mapCursorField(cursor, mapTreeFromCursor);\n}\n"]}
1
+ {"version":3,"file":"mapTreeCursor.js","sourceRoot":"","sources":["../../src/feature-libraries/mapTreeCursor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,+CAa0B;AAE1B,6DAM8B;AAoC9B,CAAC;AAID,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CACnC,IAAO;IAEP,4FAA4F;IAC5F,yGAAyG;IACzG,MAAM,YAAY,GAAG,OAAuE,CAAC;IAC7F,OAAO,IAAA,wCAAmB,EAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAPD,oDAOC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAC/B,QAA4B,EAC5B,GAAG,GAAG,uBAAY,EAClB,IAAI,GAAG,+BAAoB;IAE3B,OAAO;QACN,IAAI;QACJ,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC7C,CAAC;AACH,CAAC;AATD,4CASC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CACrC,QAAW,EACX,GAAa;IAEb,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AALD,wDAKC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACpC,IAAkB,EAClB,gBAA+B,oBAAS;IAExC,MAAM,GAAG,GAAG,IAAA,6BAAkB,EAAC,aAAa,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAG,OAAsC,CAAC;IAC5D,MAAM,SAAS,GAA8B;QAC5C,IAAI,EAAE,+BAAoB;QAC1B,MAAM,EAAE,sBAAsB,CAAC,IAAI,EAAE,GAAG,CAAC;KACzC,CAAC;IACF,OAAO,IAAA,yCAAoB,E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,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,IAAI,GAAqB;QAC9B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM;KACN,CAAC;IAEF,OAAO,IAAI,CAAC;AACb,CAAC;AAfD,8CAeC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,MAAmB;IACzD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,sCAA8B,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnF,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAClD,CAAC;AAHD,wDAGC","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\";\n\nimport {\n\tCursorLocationType,\n\ttype DetachedField,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype MapTree,\n\ttype NodeData,\n\taboveRootPlaceholder,\n\tdetachedFieldAsKey,\n\tmapCursorField,\n\trootField,\n\trootFieldKey,\n} from \"../core/index.js\";\n\nimport {\n\ttype CursorAdapter,\n\ttype CursorWithNode,\n\ttype Field,\n\tstackTreeFieldCursor,\n\tstackTreeNodeCursor,\n} from \"./treeCursorUtils.js\";\nimport type { requireAssignableTo } from \"../util/index.js\";\n\n/**\n * A generic variant of {@link MapTree} that can be used to strongly type trees implementing a MapTree-like API.\n * @remarks\n * Due to how TypeScript handles recursive generic types, explicitly named extension interfaces work best for parameterizing this, and a default type parameter can't be provided.\n * @see {@link MinimalMapTreeNodeView} for a minimal configuration of this interface.\n */\nexport interface MapTreeNodeViewGeneric<TNode> extends NodeData {\n\t/**\n\t * The non-empty fields on this node.\n\t * @remarks\n\t * This is the subset of map needed to view the tree.\n\t * Theoretically `Symbol.iterator` and \"keys\" are redundant.\n\t */\n\treadonly fields: Pick<\n\t\tMap<FieldKey, MapTreeFieldViewGeneric<TNode>>,\n\t\ttypeof Symbol.iterator | \"get\"\n\t>;\n}\n\n/**\n * A field in {@link MapTreeNodeViewGeneric}.\n */\nexport type MapTreeFieldViewGeneric<TNode> = Pick<\n\treadonly TNode[],\n\ttypeof Symbol.iterator | \"length\"\n>;\n\n/**\n * Like {@link MapTree} but with the minimal properties needed for reading.\n */\nexport interface MinimalMapTreeNodeView\n\textends MapTreeNodeViewGeneric<MinimalMapTreeNodeView> {}\n\n{\n\t// Check that these interfaces are subsets of MapTree as intended:\n\ttype _check1 = requireAssignableTo<MapTree, MinimalMapTreeNodeView>;\n\ttype _check2 = requireAssignableTo<MapTree, MapTreeNodeViewGeneric<MapTree>>;\n}\n\n/**\n * Returns an {@link ITreeCursorSynchronous} in nodes mode for a single {@link MapTree}.\n */\nexport function cursorForMapTreeNode<T extends MapTreeNodeViewGeneric<T>>(\n\troot: T,\n): CursorWithNode<T> {\n\t// There doesn't seem to be a clean way to get TypeScript to type check this without casting\n\t// without declaring the adapter inside this generic function and needlessly recreating it on every call.\n\tconst adapterTyped = adapter as CursorAdapter<MapTreeNodeViewGeneric<T>> as CursorAdapter<T>;\n\treturn stackTreeNodeCursor(adapterTyped, root);\n}\n\n/**\n * Creates an {@link ExclusiveMapTree} with a single field and no value.\n * @remarks\n * This handles ensuring the field is omitted if empty, and defaults to making the node above the root.\n */\nexport function mapTreeWithField(\n\tchildren: ExclusiveMapTree[],\n\tkey = rootFieldKey,\n\ttype = aboveRootPlaceholder,\n): ExclusiveMapTree {\n\treturn {\n\t\ttype,\n\t\tfields: mapTreeFieldsWithField(children, key),\n\t};\n}\n\n/**\n * Creates a Map suitable for use as {@link MapTree.fields} with a single field.\n * @remarks\n * This handles ensuring the field is omitted if empty.\n */\nexport function mapTreeFieldsWithField<T extends readonly unknown[]>(\n\tchildren: T,\n\tkey: FieldKey,\n): Map<FieldKey, T> {\n\treturn new Map(children.length === 0 ? [] : [[key, children]]);\n}\n\n/**\n * Returns an {@link ITreeCursorSynchronous} in fields mode for a MapTree field.\n */\nexport function cursorForMapTreeField<T extends MapTreeNodeViewGeneric<T>>(\n\troot: readonly T[],\n\tdetachedField: DetachedField = rootField,\n): CursorWithNode<T> {\n\tconst key = detachedFieldAsKey(detachedField);\n\tconst adapterTyped = adapter as unknown as CursorAdapter<T>;\n\tconst dummyRoot: MapTreeNodeViewGeneric<T> = {\n\t\ttype: aboveRootPlaceholder,\n\t\tfields: mapTreeFieldsWithField(root, key),\n\t};\n\treturn stackTreeFieldCursor(adapterTyped, dummyRoot as T, detachedField);\n}\n\nconst adapter: CursorAdapter<MinimalMapTreeNodeView> = {\n\tvalue: (node) => node.value,\n\ttype: (node) => node.type,\n\tkeysFromNode: (node) => Array.from(node.fields, ([key, field]) => key),\n\tgetFieldFromNode: (node, key): Field<MinimalMapTreeNodeView> => {\n\t\tconst field = node.fields.get(key) as\n\t\t\t| MinimalMapTreeNodeView[]\n\t\t\t| Iterable<MinimalMapTreeNodeView>\n\t\t\t| undefined;\n\t\tif (field === undefined) {\n\t\t\treturn [];\n\t\t}\n\t\tif (Array.isArray(field)) {\n\t\t\treturn field as readonly MinimalMapTreeNodeView[];\n\t\t}\n\t\t// TODO: this copy could be avoided by using Array.at instead of indexing in `Field`, but that requires ES2022.\n\t\treturn [...field] as readonly MinimalMapTreeNodeView[];\n\t},\n};\n\n/**\n * Extract a MapTree from the contents of the given ITreeCursor's current node.\n */\nexport function mapTreeFromCursor(cursor: ITreeCursor): ExclusiveMapTree {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x3b7 /* must start at node */);\n\tconst fields: Map<FieldKey, ExclusiveMapTree[]> = new Map();\n\tfor (let inField = cursor.firstField(); inField; inField = cursor.nextField()) {\n\t\tconst field: ExclusiveMapTree[] = mapCursorField(cursor, mapTreeFromCursor);\n\t\tfields.set(cursor.getFieldKey(), field);\n\t}\n\n\tconst node: ExclusiveMapTree = {\n\t\ttype: cursor.type,\n\t\tvalue: cursor.value,\n\t\tfields,\n\t};\n\n\treturn node;\n}\n\n/**\n * Extract an array of MapTrees (a field) from the contents of the given ITreeCursor's current field.\n */\nexport function mapTreeFieldFromCursor(cursor: ITreeCursor): ExclusiveMapTree[] {\n\tassert(cursor.mode === CursorLocationType.Fields, 0xa03 /* must start at field */);\n\treturn mapCursorField(cursor, mapTreeFromCursor);\n}\n"]}
@@ -8,5 +8,5 @@ import { type FieldBatchCodec } from "../chunked-forest/index.js";
8
8
  import { TreeCompressionStrategy } from "../treeCompressionUtils.js";
9
9
  import type { FieldKindConfiguration } from "./fieldKindConfiguration.js";
10
10
  import { type ModularChangeset } from "./modularChangeTypes.js";
11
- export declare function makeModularChangeCodecFamily(fieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>, revisionTagCodec: IJsonCodec<RevisionTag, EncodedRevisionTag, EncodedRevisionTag, ChangeEncodingContext>, fieldsCodec: FieldBatchCodec, { jsonValidator: validator }: ICodecOptions, chunkCompressionStrategy?: TreeCompressionStrategy): ICodecFamily<ModularChangeset, ChangeEncodingContext>;
11
+ export declare function makeModularChangeCodecFamily(fieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>, revisionTagCodec: IJsonCodec<RevisionTag, EncodedRevisionTag, EncodedRevisionTag, ChangeEncodingContext>, fieldsCodec: FieldBatchCodec, codecOptions: ICodecOptions, chunkCompressionStrategy?: TreeCompressionStrategy): ICodecFamily<ModularChangeset, ChangeEncodingContext>;
12
12
  //# sourceMappingURL=modularChangeCodecs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modularChangeCodecs.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EAKf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACX,qBAAqB,EAErB,kBAAkB,EAKlB,WAAW,EACX,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EACN,KAAK,eAAe,EAIpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,KAAK,EACX,sBAAsB,EAEtB,MAAM,6BAA6B,CAAC;AAWrC,OAAO,EAMN,KAAK,gBAAgB,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,wBAAgB,4BAA4B,CAC3C,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACpE,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,WAAW,EAAE,eAAe,EAC5B,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,aAAa,EAC3C,wBAAwB,GAAE,uBAA4D,GACpF,YAAY,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAavD"}
1
+ {"version":3,"file":"modularChangeCodecs.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EAKf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACX,qBAAqB,EAErB,kBAAkB,EAKlB,WAAW,EACX,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EACN,KAAK,eAAe,EAIpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,KAAK,EACX,sBAAsB,EAEtB,MAAM,6BAA6B,CAAC;AAWrC,OAAO,EAMN,KAAK,gBAAgB,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,wBAAgB,4BAA4B,CAC3C,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACpE,gBAAgB,EAAE,UAAU,CAC3B,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,CACrB,EACD,WAAW,EAAE,eAAe,EAC5B,YAAY,EAAE,aAAa,EAC3B,wBAAwB,GAAE,uBAA4D,GACpF,YAAY,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAavD"}
@@ -13,21 +13,21 @@ const treeCompressionUtils_js_1 = require("../treeCompressionUtils.js");
13
13
  const genericFieldKind_js_1 = require("./genericFieldKind.js");
14
14
  const modularChangeFormat_js_1 = require("./modularChangeFormat.js");
15
15
  const modularChangeTypes_js_1 = require("./modularChangeTypes.js");
16
- function makeModularChangeCodecFamily(fieldKindConfigurations, revisionTagCodec, fieldsCodec, { jsonValidator: validator }, chunkCompressionStrategy = treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed) {
16
+ function makeModularChangeCodecFamily(fieldKindConfigurations, revisionTagCodec, fieldsCodec, codecOptions, chunkCompressionStrategy = treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed) {
17
17
  return (0, index_js_1.makeCodecFamily)(Array.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => [
18
18
  version,
19
- makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, { jsonValidator: validator }, chunkCompressionStrategy),
19
+ makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, codecOptions, chunkCompressionStrategy),
20
20
  ]));
21
21
  }
22
22
  exports.makeModularChangeCodecFamily = makeModularChangeCodecFamily;
23
- function makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, { jsonValidator: validator }, chunkCompressionStrategy = treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed) {
23
+ function makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, codecOptions, chunkCompressionStrategy = treeCompressionUtils_js_1.TreeCompressionStrategy.Compressed) {
24
24
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
25
25
  const getMapEntry = ({ kind, formatVersion }) => {
26
26
  const codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);
27
27
  return {
28
28
  codec,
29
29
  compiledSchema: codec.json.encodedSchema
30
- ? validator.compile(codec.json.encodedSchema)
30
+ ? codecOptions.jsonValidator.compile(codec.json.encodedSchema)
31
31
  : undefined,
32
32
  };
33
33
  };
@@ -282,7 +282,7 @@ function makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, { jso
282
282
  return decoded;
283
283
  },
284
284
  };
285
- return (0, index_js_1.withSchemaValidation)(modularChangeFormat_js_1.EncodedModularChangeset, modularChangeCodec, validator);
285
+ return (0, index_js_1.withSchemaValidation)(modularChangeFormat_js_1.EncodedModularChangeset, modularChangeCodec, codecOptions.jsonValidator);
286
286
  }
287
287
  function getChangeHandler(fieldKinds, fieldKind) {
288
288
  if (fieldKind === genericFieldKind_js_1.genericFieldKind.identifier) {
@@ -1 +1 @@
1
- {"version":3,"file":"modularChangeCodecs.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAwE;AAGxE,mDAQ8B;AAW9B,kDAO6B;AAC7B,yDAKoC;AACpC,wEAAqE;AAOrE,+DAAyD;AACzD,qEAQkC;AAClC,mEASiC;AAEjC,SAAgB,4BAA4B,CAC3C,uBAAoE,EACpE,gBAKC,EACD,WAA4B,EAC5B,EAAE,aAAa,EAAE,SAAS,EAAiB,EAC3C,2BAAoD,iDAAuB,CAAC,UAAU;IAEtF,OAAO,IAAA,0BAAe,EACrB,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;QACxE,OAAO;QACP,sBAAsB,CACrB,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,EAAE,aAAa,EAAE,SAAS,EAAE,EAC5B,wBAAwB,CACxB;KACD,CAAC,CACF,CAAC;AACH,CAAC;AAxBD,oEAwBC;AAgBD,SAAS,sBAAsB,CAC9B,UAAkC,EAClC,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AClB,CAAC;IAED,OAAO,QAAQ,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\ttype SchemaValidationFunction,\n\tmakeCodecFamily,\n\twithSchemaValidation,\n} from \"../../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangesetLocalId,\n\tEncodedRevisionTag,\n\tFieldKey,\n\tFieldKindIdentifier,\n\tITreeCursorSynchronous,\n\tRevisionInfo,\n\tRevisionTag,\n} from \"../../core/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n\tbrand,\n\tidAllocatorFromMaxId,\n\tnewTupleBTree,\n} from \"../../util/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeChunk,\n\tchunkFieldSingle,\n\tdefaultChunkPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport type { FieldChangeEncodingContext, FieldChangeHandler } from \"./fieldChangeHandler.js\";\nimport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\ttype EncodedBuilds,\n\ttype EncodedBuildsArray,\n\ttype EncodedFieldChange,\n\ttype EncodedFieldChangeMap,\n\tEncodedModularChangeset,\n\ttype EncodedNodeChangeset,\n\ttype EncodedRevisionInfo,\n} from \"./modularChangeFormat.js\";\nimport {\n\tnewCrossFieldKeyTable,\n\ttype ChangeAtomIdBTree,\n\ttype FieldChangeMap,\n\ttype FieldChangeset,\n\ttype FieldId,\n\ttype ModularChangeset,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\n\nexport function makeModularChangeCodecFamily(\n\tfieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ICodecFamily<ModularChangeset, ChangeEncodingContext> {\n\treturn makeCodecFamily(\n\t\tArray.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => [\n\t\t\tversion,\n\t\t\tmakeModularChangeCodec(\n\t\t\t\tfieldKinds,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\t{ jsonValidator: validator },\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t\t]),\n\t);\n}\n\ntype ModularChangeCodec = IJsonCodec<\n\tModularChangeset,\n\tEncodedModularChangeset,\n\tEncodedModularChangeset,\n\tChangeEncodingContext\n>;\n\ntype FieldCodec = IMultiFormatCodec<\n\tFieldChangeset,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tFieldChangeEncodingContext\n>;\n\nfunction makeModularChangeCodec(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ModularChangeCodec {\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tconst getMapEntry = ({ kind, formatVersion }: FieldKindConfigurationEntry) => {\n\t\tconst codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);\n\t\treturn {\n\t\t\tcodec,\n\t\t\tcompiledSchema: codec.json.encodedSchema\n\t\t\t\t? validator.compile(codec.json.encodedSchema)\n\t\t\t\t: undefined,\n\t\t};\n\t};\n\n\t/**\n\t * The codec version for the generic field kind.\n\t */\n\tconst genericFieldKindFormatVersion = 1;\n\tconst fieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t> = new Map([\n\t\t[\n\t\t\tgenericFieldKind.identifier,\n\t\t\tgetMapEntry({ kind: genericFieldKind, formatVersion: genericFieldKindFormatVersion }),\n\t\t],\n\t]);\n\n\tfieldKinds.forEach((entry, identifier) => {\n\t\tfieldChangesetCodecs.set(identifier, getMapEntry(entry));\n\t});\n\n\tconst getFieldChangesetCodec = (\n\t\tfieldKind: FieldKindIdentifier,\n\t): {\n\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\tcodec: FieldCodec;\n\t} => {\n\t\tconst entry = fieldChangesetCodecs.get(fieldKind);\n\t\tassert(entry !== undefined, 0x5ea /* Tried to encode unsupported fieldKind */);\n\t\treturn entry;\n\t};\n\n\tfunction encodeFieldChangesForJson(\n\t\tchange: FieldChangeMap,\n\t\tcontext: ChangeEncodingContext,\n\t\tnodeChanges: ChangeAtomIdBTree<NodeChangeset>,\n\t): EncodedFieldChangeMap {\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: (nodeId: NodeId): EncodedNodeChangeset => {\n\t\t\t\tconst node = nodeChanges.get([nodeId.revision, nodeId.localId]);\n\t\t\t\tassert(node !== undefined, 0x92e /* Unknown node ID */);\n\t\t\t\treturn encodeNodeChangesForJson(node, fieldContext);\n\t\t\t},\n\n\t\t\tdecodeNode: () => fail(0xb1e /* Should not decode nodes during field encoding */),\n\t\t};\n\n\t\treturn encodeFieldChangesForJsonI(change, fieldContext);\n\t}\n\n\tfunction encodeFieldChangesForJsonI(\n\t\tchange: FieldChangeMap,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedFieldChangeMap {\n\t\tconst encodedFields: EncodedFieldChangeMap = [];\n\n\t\tfor (const [field, fieldChange] of change) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(fieldChange.fieldKind);\n\t\t\tconst encodedChange = codec.json.encode(fieldChange.change, context);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(encodedChange)) {\n\t\t\t\tfail(0xb1f /* Encoded change didn't pass schema validation. */);\n\t\t\t}\n\n\t\t\tconst fieldKey: FieldKey = field;\n\t\t\tconst encodedField: EncodedFieldChange = {\n\t\t\t\tfieldKey,\n\t\t\t\tfieldKind: fieldChange.fieldKind,\n\t\t\t\tchange: encodedChange,\n\t\t\t};\n\n\t\t\tencodedFields.push(encodedField);\n\t\t}\n\n\t\treturn encodedFields;\n\t}\n\n\tfunction encodeNodeChangesForJson(\n\t\tchange: NodeChangeset,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedNodeChangeset {\n\t\tconst encodedChange: EncodedNodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = change;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tencodedChange.fieldChanges = encodeFieldChangesForJsonI(fieldChanges, context);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tencodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn encodedChange;\n\t}\n\n\tfunction decodeFieldChangesFromJson(\n\t\tencodedChange: EncodedFieldChangeMap,\n\t\tparentId: NodeId | undefined,\n\t\tdecoded: ModularChangeset,\n\t\tcontext: ChangeEncodingContext,\n\t\tidAllocator: IdAllocator,\n\t): FieldChangeMap {\n\t\tconst decodedFields: FieldChangeMap = new Map();\n\t\tfor (const field of encodedChange) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(field.fieldKind);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(field.change)) {\n\t\t\t\tfail(0xb20 /* Encoded change didn't pass schema validation. */);\n\t\t\t}\n\n\t\t\tconst fieldId: FieldId = {\n\t\t\t\tnodeId: parentId,\n\t\t\t\tfield: field.fieldKey,\n\t\t\t};\n\n\t\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\t\tbaseContext: context,\n\n\t\t\t\tencodeNode: () => fail(0xb21 /* Should not encode nodes during field decoding */),\n\n\t\t\t\tdecodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {\n\t\t\t\t\tconst nodeId: NodeId = {\n\t\t\t\t\t\trevision: context.revision,\n\t\t\t\t\t\tlocalId: brand(idAllocator.allocate()),\n\t\t\t\t\t};\n\n\t\t\t\t\tconst node = decodeNodeChangesetFromJson(\n\t\t\t\t\t\tencodedNode,\n\t\t\t\t\t\tnodeId,\n\t\t\t\t\t\tdecoded,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tidAllocator,\n\t\t\t\t\t);\n\n\t\t\t\t\tdecoded.nodeChanges.set([nodeId.revision, nodeId.localId], node);\n\t\t\t\t\tdecoded.nodeToParent.set([nodeId.revision, nodeId.localId], fieldId);\n\t\t\t\t\treturn nodeId;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst fieldChangeset = codec.json.decode(field.change, fieldContext);\n\n\t\t\tconst crossFieldKeys = getChangeHandler(fieldKinds, field.fieldKind).getCrossFieldKeys(\n\t\t\t\tfieldChangeset,\n\t\t\t);\n\n\t\t\tfor (const { key, count } of crossFieldKeys) {\n\t\t\t\tdecoded.crossFieldKeys.set(key, count, fieldId);\n\t\t\t}\n\n\t\t\tconst fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);\n\n\t\t\tdecodedFields.set(fieldKey, {\n\t\t\t\tfieldKind: field.fieldKind,\n\t\t\t\tchange: brand(fieldChangeset),\n\t\t\t});\n\t\t}\n\n\t\treturn decodedFields;\n\t}\n\n\tfunction decodeNodeChangesetFromJson(\n\t\tencodedChange: EncodedNodeChangeset,\n\t\tid: NodeId,\n\t\tdecoded: ModularChangeset,\n\t\tcontext: ChangeEncodingContext,\n\t\tidAllocator: IdAllocator,\n\t): NodeChangeset {\n\t\tconst decodedChange: NodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = encodedChange;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tdecodedChange.fieldChanges = decodeFieldChangesFromJson(\n\t\t\t\tfieldChanges,\n\t\t\t\tid,\n\t\t\t\tdecoded,\n\t\t\t\tcontext,\n\t\t\t\tidAllocator,\n\t\t\t);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tdecodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn decodedChange;\n\t}\n\n\tfunction encodeDetachedNodes(\n\t\tdetachedNodes: ChangeAtomIdBTree<TreeChunk> | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedBuilds | undefined {\n\t\tif (detachedNodes === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst treesToEncode: ITreeCursorSynchronous[] = [];\n\t\tconst buildsArray: EncodedBuildsArray = [];\n\n\t\tlet buildsForRevision:\n\t\t\t| [[ChangesetLocalId, number][], EncodedRevisionTag]\n\t\t\t| [[ChangesetLocalId, number][]]\n\t\t\t| undefined;\n\n\t\tfor (const [[revision, id], chunk] of detachedNodes.entries()) {\n\t\t\tconst encodedRevision = encodeRevisionOpt(revisionTagCodec, revision, context);\n\n\t\t\tif (buildsForRevision === undefined || buildsForRevision[1] !== encodedRevision) {\n\t\t\t\tif (buildsForRevision !== undefined) {\n\t\t\t\t\tbuildsArray.push(buildsForRevision);\n\t\t\t\t}\n\n\t\t\t\tbuildsForRevision = encodedRevision !== undefined ? [[], encodedRevision] : [[]];\n\t\t\t}\n\n\t\t\ttreesToEncode.push(chunk.cursor());\n\t\t\tconst treeIndexInBatch = treesToEncode.length - 1;\n\t\t\tbuildsForRevision?.[0].push([id, treeIndexInBatch]);\n\t\t}\n\n\t\tif (buildsForRevision !== undefined) {\n\t\t\tbuildsArray.push(buildsForRevision);\n\t\t}\n\n\t\treturn buildsArray.length === 0\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tbuilds: buildsArray,\n\t\t\t\t\ttrees: fieldsCodec.encode(treesToEncode, {\n\t\t\t\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t}\n\n\tfunction decodeDetachedNodes(\n\t\tencoded: EncodedBuilds | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): ChangeAtomIdBTree<TreeChunk> | undefined {\n\t\tif (encoded === undefined || encoded.builds.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst chunks = fieldsCodec.decode(encoded.trees, {\n\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\toriginatorId: context.originatorId,\n\t\t\tidCompressor: context.idCompressor,\n\t\t});\n\t\tconst getChunk = (index: number): TreeChunk => {\n\t\t\tassert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);\n\t\t\treturn chunkFieldSingle(chunks[index] ?? oob(), {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t});\n\t\t};\n\n\t\tconst map: ModularChangeset[\"builds\"] = newTupleBTree();\n\t\tencoded.builds.forEach((build) => {\n\t\t\t// EncodedRevisionTag cannot be an array so this ensures that we can isolate the tuple\n\t\t\tconst revision =\n\t\t\t\tbuild[1] === undefined ? context.revision : revisionTagCodec.decode(build[1], context);\n\n\t\t\tconst decodedChunks: [ChangesetLocalId, TreeChunk][] = build[0].map(([i, n]) => [\n\t\t\t\ti,\n\t\t\t\tgetChunk(n),\n\t\t\t]);\n\n\t\t\tfor (const [id, chunk] of decodedChunks) {\n\t\t\t\tmap.set([revision, id], chunk);\n\t\t\t}\n\t\t});\n\n\t\treturn map;\n\t}\n\n\tfunction encodeRevisionInfos(\n\t\trevisions: readonly RevisionInfo[],\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedRevisionInfo[] | undefined {\n\t\tif (context.revision !== undefined) {\n\t\t\tassert(\n\t\t\t\trevisions.length === 1 &&\n\t\t\t\t\trevisions[0] !== undefined &&\n\t\t\t\t\trevisions[0].revision === context.revision &&\n\t\t\t\t\trevisions[0].rollbackOf === undefined,\n\t\t\t\t0x964 /* A tagged change should only contain the tagged revision */,\n\t\t\t);\n\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst encodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst encodedRevision: Mutable<EncodedRevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.encode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tencodedRevision.rollbackOf = revisionTagCodec.encode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tencodedRevisions.push(encodedRevision);\n\t\t}\n\n\t\treturn encodedRevisions;\n\t}\n\n\tfunction decodeRevisionInfos(\n\t\trevisions: readonly EncodedRevisionInfo[] | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): RevisionInfo[] | undefined {\n\t\tif (revisions === undefined) {\n\t\t\treturn context.revision !== undefined ? [{ revision: context.revision }] : undefined;\n\t\t}\n\n\t\tconst decodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst decodedRevision: Mutable<RevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.decode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tdecodedRevision.rollbackOf = revisionTagCodec.decode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tdecodedRevisions.push(decodedRevision);\n\t\t}\n\n\t\treturn decodedRevisions;\n\t}\n\n\tconst modularChangeCodec: ModularChangeCodec = {\n\t\tencode: (change, context) => {\n\t\t\t// Destroys only exist in rollback changesets, which are never sent.\n\t\t\tassert(change.destroys === undefined, 0x899 /* Unexpected changeset with destroys */);\n\t\t\treturn {\n\t\t\t\tmaxId: change.maxId,\n\t\t\t\trevisions:\n\t\t\t\t\tchange.revisions === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: encodeRevisionInfos(change.revisions, context),\n\t\t\t\tchanges: encodeFieldChangesForJson(change.fieldChanges, context, change.nodeChanges),\n\t\t\t\tbuilds: encodeDetachedNodes(change.builds, context),\n\t\t\t\trefreshers: encodeDetachedNodes(change.refreshers, context),\n\t\t\t\tviolations: change.constraintViolationCount,\n\t\t\t};\n\t\t},\n\n\t\tdecode: (encodedChange: EncodedModularChangeset, context) => {\n\t\t\tconst decoded: Mutable<ModularChangeset> = {\n\t\t\t\tfieldChanges: new Map(),\n\t\t\t\tnodeChanges: newTupleBTree(),\n\t\t\t\tnodeToParent: newTupleBTree(),\n\t\t\t\tnodeAliases: newTupleBTree(),\n\t\t\t\tcrossFieldKeys: newCrossFieldKeyTable(),\n\t\t\t};\n\n\t\t\tdecoded.fieldChanges = decodeFieldChangesFromJson(\n\t\t\t\tencodedChange.changes,\n\t\t\t\tundefined,\n\t\t\t\tdecoded,\n\t\t\t\tcontext,\n\t\t\t\tidAllocatorFromMaxId(encodedChange.maxId),\n\t\t\t);\n\n\t\t\tif (encodedChange.builds !== undefined) {\n\t\t\t\tdecoded.builds = decodeDetachedNodes(encodedChange.builds, context);\n\t\t\t}\n\t\t\tif (encodedChange.refreshers !== undefined) {\n\t\t\t\tdecoded.refreshers = decodeDetachedNodes(encodedChange.refreshers, context);\n\t\t\t}\n\n\t\t\tif (encodedChange.violations !== undefined) {\n\t\t\t\tdecoded.constraintViolationCount = encodedChange.violations;\n\t\t\t}\n\n\t\t\tconst decodedRevInfos = decodeRevisionInfos(encodedChange.revisions, context);\n\t\t\tif (decodedRevInfos !== undefined) {\n\t\t\t\tdecoded.revisions = decodedRevInfos;\n\t\t\t}\n\t\t\tif (encodedChange.maxId !== undefined) {\n\t\t\t\tdecoded.maxId = encodedChange.maxId;\n\t\t\t}\n\t\t\treturn decoded;\n\t\t},\n\t};\n\n\treturn withSchemaValidation(EncodedModularChangeset, modularChangeCodec, validator);\n}\n\nfunction getChangeHandler(\n\tfieldKinds: FieldKindConfiguration,\n\tfieldKind: FieldKindIdentifier,\n): FieldChangeHandler<unknown> {\n\tif (fieldKind === genericFieldKind.identifier) {\n\t\treturn genericFieldKind.changeHandler;\n\t}\n\n\tconst handler = fieldKinds.get(fieldKind)?.kind.changeHandler;\n\tassert(handler !== undefined, 0x9c1 /* Unknown field kind */);\n\treturn handler;\n}\n\nfunction encodeRevisionOpt(\n\trevisionCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\trevision: RevisionTag | undefined,\n\tcontext: ChangeEncodingContext,\n): EncodedRevisionTag | undefined {\n\tif (revision === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn revision === context.revision ? undefined : revisionCodec.encode(revision, context);\n}\n"]}
1
+ {"version":3,"file":"modularChangeCodecs.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAwE;AAGxE,mDAQ8B;AAW9B,kDAO6B;AAC7B,yDAKoC;AACpC,wEAAqE;AAOrE,+DAAyD;AACzD,qEAQkC;AAClC,mEASiC;AAEjC,SAAgB,4BAA4B,CAC3C,uBAAoE,EACpE,gBAKC,EACD,WAA4B,EAC5B,YAA2B,EAC3B,2BAAoD,iDAAuB,CAAC,UAAU;IAEtF,OAAO,IAAA,0BAAe,EACrB,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CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;IAC9D,IAAA,iBAAM,EAAC,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB,CACzB,aAKC,EACD,QAAiC,EACjC,OAA8B;IAE9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\ttype SchemaValidationFunction,\n\tmakeCodecFamily,\n\twithSchemaValidation,\n} from \"../../codec/index.js\";\nimport type {\n\tChangeEncodingContext,\n\tChangesetLocalId,\n\tEncodedRevisionTag,\n\tFieldKey,\n\tFieldKindIdentifier,\n\tITreeCursorSynchronous,\n\tRevisionInfo,\n\tRevisionTag,\n} from \"../../core/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n\tbrand,\n\tidAllocatorFromMaxId,\n\tnewTupleBTree,\n} from \"../../util/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeChunk,\n\tchunkFieldSingle,\n\tdefaultChunkPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport type { FieldChangeEncodingContext, FieldChangeHandler } from \"./fieldChangeHandler.js\";\nimport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\ttype EncodedBuilds,\n\ttype EncodedBuildsArray,\n\ttype EncodedFieldChange,\n\ttype EncodedFieldChangeMap,\n\tEncodedModularChangeset,\n\ttype EncodedNodeChangeset,\n\ttype EncodedRevisionInfo,\n} from \"./modularChangeFormat.js\";\nimport {\n\tnewCrossFieldKeyTable,\n\ttype ChangeAtomIdBTree,\n\ttype FieldChangeMap,\n\ttype FieldChangeset,\n\ttype FieldId,\n\ttype ModularChangeset,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\n\nexport function makeModularChangeCodecFamily(\n\tfieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tcodecOptions: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ICodecFamily<ModularChangeset, ChangeEncodingContext> {\n\treturn makeCodecFamily(\n\t\tArray.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => [\n\t\t\tversion,\n\t\t\tmakeModularChangeCodec(\n\t\t\t\tfieldKinds,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\tcodecOptions,\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t\t]),\n\t);\n}\n\ntype ModularChangeCodec = IJsonCodec<\n\tModularChangeset,\n\tEncodedModularChangeset,\n\tEncodedModularChangeset,\n\tChangeEncodingContext\n>;\n\ntype FieldCodec = IMultiFormatCodec<\n\tFieldChangeset,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tFieldChangeEncodingContext\n>;\n\nfunction makeModularChangeCodec(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\tcodecOptions: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ModularChangeCodec {\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tconst getMapEntry = ({ kind, formatVersion }: FieldKindConfigurationEntry) => {\n\t\tconst codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);\n\t\treturn {\n\t\t\tcodec,\n\t\t\tcompiledSchema: codec.json.encodedSchema\n\t\t\t\t? codecOptions.jsonValidator.compile(codec.json.encodedSchema)\n\t\t\t\t: undefined,\n\t\t};\n\t};\n\n\t/**\n\t * The codec version for the generic field kind.\n\t */\n\tconst genericFieldKindFormatVersion = 1;\n\tconst fieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t> = new Map([\n\t\t[\n\t\t\tgenericFieldKind.identifier,\n\t\t\tgetMapEntry({ kind: genericFieldKind, formatVersion: genericFieldKindFormatVersion }),\n\t\t],\n\t]);\n\n\tfieldKinds.forEach((entry, identifier) => {\n\t\tfieldChangesetCodecs.set(identifier, getMapEntry(entry));\n\t});\n\n\tconst getFieldChangesetCodec = (\n\t\tfieldKind: FieldKindIdentifier,\n\t): {\n\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\tcodec: FieldCodec;\n\t} => {\n\t\tconst entry = fieldChangesetCodecs.get(fieldKind);\n\t\tassert(entry !== undefined, 0x5ea /* Tried to encode unsupported fieldKind */);\n\t\treturn entry;\n\t};\n\n\tfunction encodeFieldChangesForJson(\n\t\tchange: FieldChangeMap,\n\t\tcontext: ChangeEncodingContext,\n\t\tnodeChanges: ChangeAtomIdBTree<NodeChangeset>,\n\t): EncodedFieldChangeMap {\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: (nodeId: NodeId): EncodedNodeChangeset => {\n\t\t\t\tconst node = nodeChanges.get([nodeId.revision, nodeId.localId]);\n\t\t\t\tassert(node !== undefined, 0x92e /* Unknown node ID */);\n\t\t\t\treturn encodeNodeChangesForJson(node, fieldContext);\n\t\t\t},\n\n\t\t\tdecodeNode: () => fail(0xb1e /* Should not decode nodes during field encoding */),\n\t\t};\n\n\t\treturn encodeFieldChangesForJsonI(change, fieldContext);\n\t}\n\n\tfunction encodeFieldChangesForJsonI(\n\t\tchange: FieldChangeMap,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedFieldChangeMap {\n\t\tconst encodedFields: EncodedFieldChangeMap = [];\n\n\t\tfor (const [field, fieldChange] of change) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(fieldChange.fieldKind);\n\t\t\tconst encodedChange = codec.json.encode(fieldChange.change, context);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(encodedChange)) {\n\t\t\t\tfail(0xb1f /* Encoded change didn't pass schema validation. */);\n\t\t\t}\n\n\t\t\tconst fieldKey: FieldKey = field;\n\t\t\tconst encodedField: EncodedFieldChange = {\n\t\t\t\tfieldKey,\n\t\t\t\tfieldKind: fieldChange.fieldKind,\n\t\t\t\tchange: encodedChange,\n\t\t\t};\n\n\t\t\tencodedFields.push(encodedField);\n\t\t}\n\n\t\treturn encodedFields;\n\t}\n\n\tfunction encodeNodeChangesForJson(\n\t\tchange: NodeChangeset,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedNodeChangeset {\n\t\tconst encodedChange: EncodedNodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = change;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tencodedChange.fieldChanges = encodeFieldChangesForJsonI(fieldChanges, context);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tencodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn encodedChange;\n\t}\n\n\tfunction decodeFieldChangesFromJson(\n\t\tencodedChange: EncodedFieldChangeMap,\n\t\tparentId: NodeId | undefined,\n\t\tdecoded: ModularChangeset,\n\t\tcontext: ChangeEncodingContext,\n\t\tidAllocator: IdAllocator,\n\t): FieldChangeMap {\n\t\tconst decodedFields: FieldChangeMap = new Map();\n\t\tfor (const field of encodedChange) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(field.fieldKind);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(field.change)) {\n\t\t\t\tfail(0xb20 /* Encoded change didn't pass schema validation. */);\n\t\t\t}\n\n\t\t\tconst fieldId: FieldId = {\n\t\t\t\tnodeId: parentId,\n\t\t\t\tfield: field.fieldKey,\n\t\t\t};\n\n\t\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\t\tbaseContext: context,\n\n\t\t\t\tencodeNode: () => fail(0xb21 /* Should not encode nodes during field decoding */),\n\n\t\t\t\tdecodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {\n\t\t\t\t\tconst nodeId: NodeId = {\n\t\t\t\t\t\trevision: context.revision,\n\t\t\t\t\t\tlocalId: brand(idAllocator.allocate()),\n\t\t\t\t\t};\n\n\t\t\t\t\tconst node = decodeNodeChangesetFromJson(\n\t\t\t\t\t\tencodedNode,\n\t\t\t\t\t\tnodeId,\n\t\t\t\t\t\tdecoded,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tidAllocator,\n\t\t\t\t\t);\n\n\t\t\t\t\tdecoded.nodeChanges.set([nodeId.revision, nodeId.localId], node);\n\t\t\t\t\tdecoded.nodeToParent.set([nodeId.revision, nodeId.localId], fieldId);\n\t\t\t\t\treturn nodeId;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst fieldChangeset = codec.json.decode(field.change, fieldContext);\n\n\t\t\tconst crossFieldKeys = getChangeHandler(fieldKinds, field.fieldKind).getCrossFieldKeys(\n\t\t\t\tfieldChangeset,\n\t\t\t);\n\n\t\t\tfor (const { key, count } of crossFieldKeys) {\n\t\t\t\tdecoded.crossFieldKeys.set(key, count, fieldId);\n\t\t\t}\n\n\t\t\tconst fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);\n\n\t\t\tdecodedFields.set(fieldKey, {\n\t\t\t\tfieldKind: field.fieldKind,\n\t\t\t\tchange: brand(fieldChangeset),\n\t\t\t});\n\t\t}\n\n\t\treturn decodedFields;\n\t}\n\n\tfunction decodeNodeChangesetFromJson(\n\t\tencodedChange: EncodedNodeChangeset,\n\t\tid: NodeId,\n\t\tdecoded: ModularChangeset,\n\t\tcontext: ChangeEncodingContext,\n\t\tidAllocator: IdAllocator,\n\t): NodeChangeset {\n\t\tconst decodedChange: NodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = encodedChange;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tdecodedChange.fieldChanges = decodeFieldChangesFromJson(\n\t\t\t\tfieldChanges,\n\t\t\t\tid,\n\t\t\t\tdecoded,\n\t\t\t\tcontext,\n\t\t\t\tidAllocator,\n\t\t\t);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tdecodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn decodedChange;\n\t}\n\n\tfunction encodeDetachedNodes(\n\t\tdetachedNodes: ChangeAtomIdBTree<TreeChunk> | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedBuilds | undefined {\n\t\tif (detachedNodes === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst treesToEncode: ITreeCursorSynchronous[] = [];\n\t\tconst buildsArray: EncodedBuildsArray = [];\n\n\t\tlet buildsForRevision:\n\t\t\t| [[ChangesetLocalId, number][], EncodedRevisionTag]\n\t\t\t| [[ChangesetLocalId, number][]]\n\t\t\t| undefined;\n\n\t\tfor (const [[revision, id], chunk] of detachedNodes.entries()) {\n\t\t\tconst encodedRevision = encodeRevisionOpt(revisionTagCodec, revision, context);\n\n\t\t\tif (buildsForRevision === undefined || buildsForRevision[1] !== encodedRevision) {\n\t\t\t\tif (buildsForRevision !== undefined) {\n\t\t\t\t\tbuildsArray.push(buildsForRevision);\n\t\t\t\t}\n\n\t\t\t\tbuildsForRevision = encodedRevision !== undefined ? [[], encodedRevision] : [[]];\n\t\t\t}\n\n\t\t\ttreesToEncode.push(chunk.cursor());\n\t\t\tconst treeIndexInBatch = treesToEncode.length - 1;\n\t\t\tbuildsForRevision?.[0].push([id, treeIndexInBatch]);\n\t\t}\n\n\t\tif (buildsForRevision !== undefined) {\n\t\t\tbuildsArray.push(buildsForRevision);\n\t\t}\n\n\t\treturn buildsArray.length === 0\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tbuilds: buildsArray,\n\t\t\t\t\ttrees: fieldsCodec.encode(treesToEncode, {\n\t\t\t\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t}\n\n\tfunction decodeDetachedNodes(\n\t\tencoded: EncodedBuilds | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): ChangeAtomIdBTree<TreeChunk> | undefined {\n\t\tif (encoded === undefined || encoded.builds.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst chunks = fieldsCodec.decode(encoded.trees, {\n\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\toriginatorId: context.originatorId,\n\t\t\tidCompressor: context.idCompressor,\n\t\t});\n\t\tconst getChunk = (index: number): TreeChunk => {\n\t\t\tassert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);\n\t\t\treturn chunkFieldSingle(chunks[index] ?? oob(), {\n\t\t\t\tpolicy: defaultChunkPolicy,\n\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t});\n\t\t};\n\n\t\tconst map: ModularChangeset[\"builds\"] = newTupleBTree();\n\t\tencoded.builds.forEach((build) => {\n\t\t\t// EncodedRevisionTag cannot be an array so this ensures that we can isolate the tuple\n\t\t\tconst revision =\n\t\t\t\tbuild[1] === undefined ? context.revision : revisionTagCodec.decode(build[1], context);\n\n\t\t\tconst decodedChunks: [ChangesetLocalId, TreeChunk][] = build[0].map(([i, n]) => [\n\t\t\t\ti,\n\t\t\t\tgetChunk(n),\n\t\t\t]);\n\n\t\t\tfor (const [id, chunk] of decodedChunks) {\n\t\t\t\tmap.set([revision, id], chunk);\n\t\t\t}\n\t\t});\n\n\t\treturn map;\n\t}\n\n\tfunction encodeRevisionInfos(\n\t\trevisions: readonly RevisionInfo[],\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedRevisionInfo[] | undefined {\n\t\tif (context.revision !== undefined) {\n\t\t\tassert(\n\t\t\t\trevisions.length === 1 &&\n\t\t\t\t\trevisions[0] !== undefined &&\n\t\t\t\t\trevisions[0].revision === context.revision &&\n\t\t\t\t\trevisions[0].rollbackOf === undefined,\n\t\t\t\t0x964 /* A tagged change should only contain the tagged revision */,\n\t\t\t);\n\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst encodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst encodedRevision: Mutable<EncodedRevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.encode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tencodedRevision.rollbackOf = revisionTagCodec.encode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tencodedRevisions.push(encodedRevision);\n\t\t}\n\n\t\treturn encodedRevisions;\n\t}\n\n\tfunction decodeRevisionInfos(\n\t\trevisions: readonly EncodedRevisionInfo[] | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): RevisionInfo[] | undefined {\n\t\tif (revisions === undefined) {\n\t\t\treturn context.revision !== undefined ? [{ revision: context.revision }] : undefined;\n\t\t}\n\n\t\tconst decodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst decodedRevision: Mutable<RevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.decode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tdecodedRevision.rollbackOf = revisionTagCodec.decode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tdecodedRevisions.push(decodedRevision);\n\t\t}\n\n\t\treturn decodedRevisions;\n\t}\n\n\tconst modularChangeCodec: ModularChangeCodec = {\n\t\tencode: (change, context) => {\n\t\t\t// Destroys only exist in rollback changesets, which are never sent.\n\t\t\tassert(change.destroys === undefined, 0x899 /* Unexpected changeset with destroys */);\n\t\t\treturn {\n\t\t\t\tmaxId: change.maxId,\n\t\t\t\trevisions:\n\t\t\t\t\tchange.revisions === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: encodeRevisionInfos(change.revisions, context),\n\t\t\t\tchanges: encodeFieldChangesForJson(change.fieldChanges, context, change.nodeChanges),\n\t\t\t\tbuilds: encodeDetachedNodes(change.builds, context),\n\t\t\t\trefreshers: encodeDetachedNodes(change.refreshers, context),\n\t\t\t\tviolations: change.constraintViolationCount,\n\t\t\t};\n\t\t},\n\n\t\tdecode: (encodedChange: EncodedModularChangeset, context) => {\n\t\t\tconst decoded: Mutable<ModularChangeset> = {\n\t\t\t\tfieldChanges: new Map(),\n\t\t\t\tnodeChanges: newTupleBTree(),\n\t\t\t\tnodeToParent: newTupleBTree(),\n\t\t\t\tnodeAliases: newTupleBTree(),\n\t\t\t\tcrossFieldKeys: newCrossFieldKeyTable(),\n\t\t\t};\n\n\t\t\tdecoded.fieldChanges = decodeFieldChangesFromJson(\n\t\t\t\tencodedChange.changes,\n\t\t\t\tundefined,\n\t\t\t\tdecoded,\n\t\t\t\tcontext,\n\t\t\t\tidAllocatorFromMaxId(encodedChange.maxId),\n\t\t\t);\n\n\t\t\tif (encodedChange.builds !== undefined) {\n\t\t\t\tdecoded.builds = decodeDetachedNodes(encodedChange.builds, context);\n\t\t\t}\n\t\t\tif (encodedChange.refreshers !== undefined) {\n\t\t\t\tdecoded.refreshers = decodeDetachedNodes(encodedChange.refreshers, context);\n\t\t\t}\n\n\t\t\tif (encodedChange.violations !== undefined) {\n\t\t\t\tdecoded.constraintViolationCount = encodedChange.violations;\n\t\t\t}\n\n\t\t\tconst decodedRevInfos = decodeRevisionInfos(encodedChange.revisions, context);\n\t\t\tif (decodedRevInfos !== undefined) {\n\t\t\t\tdecoded.revisions = decodedRevInfos;\n\t\t\t}\n\t\t\tif (encodedChange.maxId !== undefined) {\n\t\t\t\tdecoded.maxId = encodedChange.maxId;\n\t\t\t}\n\t\t\treturn decoded;\n\t\t},\n\t};\n\n\treturn withSchemaValidation(\n\t\tEncodedModularChangeset,\n\t\tmodularChangeCodec,\n\t\tcodecOptions.jsonValidator,\n\t);\n}\n\nfunction getChangeHandler(\n\tfieldKinds: FieldKindConfiguration,\n\tfieldKind: FieldKindIdentifier,\n): FieldChangeHandler<unknown> {\n\tif (fieldKind === genericFieldKind.identifier) {\n\t\treturn genericFieldKind.changeHandler;\n\t}\n\n\tconst handler = fieldKinds.get(fieldKind)?.kind.changeHandler;\n\tassert(handler !== undefined, 0x9c1 /* Unknown field kind */);\n\treturn handler;\n}\n\nfunction encodeRevisionOpt(\n\trevisionCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\trevision: RevisionTag | undefined,\n\tcontext: ChangeEncodingContext,\n): EncodedRevisionTag | undefined {\n\tif (revision === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn revision === context.revision ? undefined : revisionCodec.encode(revision, context);\n}\n"]}