@fluidframework/tree 2.32.0 → 2.33.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 (339) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/api-report/tree.alpha.api.md +169 -192
  3. package/api-report/tree.beta.api.md +135 -164
  4. package/api-report/tree.legacy.alpha.api.md +138 -167
  5. package/api-report/tree.legacy.public.api.md +135 -164
  6. package/api-report/tree.public.api.md +135 -164
  7. package/dist/alpha.d.ts +3 -11
  8. package/dist/beta.d.ts +2 -11
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +1 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/schema-stored/index.d.ts +1 -1
  14. package/dist/core/schema-stored/index.d.ts.map +1 -1
  15. package/dist/core/schema-stored/index.js +1 -2
  16. package/dist/core/schema-stored/index.js.map +1 -1
  17. package/dist/core/schema-stored/schema.d.ts +4 -11
  18. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  19. package/dist/core/schema-stored/schema.js +7 -14
  20. package/dist/core/schema-stored/schema.js.map +1 -1
  21. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  22. package/dist/core/tree/anchorSet.js +31 -24
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/deltaUtil.d.ts +1 -4
  25. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  26. package/dist/core/tree/deltaUtil.js +1 -13
  27. package/dist/core/tree/deltaUtil.js.map +1 -1
  28. package/dist/core/tree/visitDelta.d.ts +6 -29
  29. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  30. package/dist/core/tree/visitDelta.js +11 -50
  31. package/dist/core/tree/visitDelta.js.map +1 -1
  32. package/dist/core/tree/visitorUtils.d.ts +12 -9
  33. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  34. package/dist/core/tree/visitorUtils.js +19 -32
  35. package/dist/core/tree/visitorUtils.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -11
  38. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
  43. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
  45. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/context.d.ts +5 -0
  49. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/context.js +4 -0
  51. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  52. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  53. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  54. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  55. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  56. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  57. package/dist/feature-libraries/indexing/anchorTreeIndex.js +15 -22
  58. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  59. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  60. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  61. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  62. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  63. package/dist/feature-libraries/object-forest/objectForest.js +1 -7
  64. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  65. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  66. package/dist/feature-libraries/schema-index/codec.js +1 -1
  67. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +3 -2
  71. package/dist/index.js.map +1 -1
  72. package/dist/internalTypes.d.ts +1 -1
  73. package/dist/internalTypes.d.ts.map +1 -1
  74. package/dist/internalTypes.js.map +1 -1
  75. package/dist/jsonDomainSchema.d.ts +6 -6
  76. package/dist/jsonDomainSchema.d.ts.map +1 -1
  77. package/dist/jsonDomainSchema.js.map +1 -1
  78. package/dist/legacy.d.ts +2 -11
  79. package/dist/packageVersion.d.ts +1 -1
  80. package/dist/packageVersion.js +1 -1
  81. package/dist/packageVersion.js.map +1 -1
  82. package/dist/public.d.ts +2 -11
  83. package/dist/serializableDomainSchema.d.ts +5 -5
  84. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  85. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  86. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  87. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  88. package/dist/shared-tree/index.d.ts +3 -2
  89. package/dist/shared-tree/index.d.ts.map +1 -1
  90. package/dist/shared-tree/index.js +2 -2
  91. package/dist/shared-tree/index.js.map +1 -1
  92. package/dist/shared-tree/sharedTree.d.ts +4 -35
  93. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  94. package/dist/shared-tree/sharedTree.js +4 -54
  95. package/dist/shared-tree/sharedTree.js.map +1 -1
  96. package/dist/simple-tree/api/index.d.ts +2 -1
  97. package/dist/simple-tree/api/index.d.ts.map +1 -1
  98. package/dist/simple-tree/api/index.js +3 -1
  99. package/dist/simple-tree/api/index.js.map +1 -1
  100. package/dist/simple-tree/api/schemaFactory.d.ts +28 -28
  101. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  102. package/dist/simple-tree/api/schemaFactory.js +11 -11
  103. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  104. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
  105. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  106. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  107. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
  108. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  109. package/dist/simple-tree/api/schemaFactoryRecursive.js +14 -1
  110. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  111. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  112. package/dist/simple-tree/api/tree.d.ts +1 -14
  113. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  114. package/dist/simple-tree/api/tree.js.map +1 -1
  115. package/dist/simple-tree/api/typesUnsafe.d.ts +237 -220
  116. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  117. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  118. package/dist/simple-tree/arrayNode.d.ts +2 -2
  119. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  120. package/dist/simple-tree/arrayNode.js.map +1 -1
  121. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  122. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  123. package/dist/simple-tree/core/treeNodeKernel.js +39 -24
  124. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  125. package/dist/simple-tree/core/types.d.ts +14 -4
  126. package/dist/simple-tree/core/types.d.ts.map +1 -1
  127. package/dist/simple-tree/core/types.js +14 -4
  128. package/dist/simple-tree/core/types.js.map +1 -1
  129. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  130. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  131. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  132. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  133. package/dist/simple-tree/index.d.ts +1 -1
  134. package/dist/simple-tree/index.d.ts.map +1 -1
  135. package/dist/simple-tree/index.js +3 -2
  136. package/dist/simple-tree/index.js.map +1 -1
  137. package/dist/simple-tree/objectNode.d.ts +9 -2
  138. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  139. package/dist/simple-tree/objectNode.js +3 -0
  140. package/dist/simple-tree/objectNode.js.map +1 -1
  141. package/dist/simple-tree/schemaTypes.d.ts +10 -5
  142. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  143. package/dist/simple-tree/schemaTypes.js +5 -2
  144. package/dist/simple-tree/schemaTypes.js.map +1 -1
  145. package/dist/tableSchema.d.ts +78 -26
  146. package/dist/tableSchema.d.ts.map +1 -1
  147. package/dist/tableSchema.js +53 -24
  148. package/dist/tableSchema.js.map +1 -1
  149. package/dist/treeFactory.d.ts +6 -12
  150. package/dist/treeFactory.d.ts.map +1 -1
  151. package/dist/treeFactory.js +56 -5
  152. package/dist/treeFactory.js.map +1 -1
  153. package/lib/alpha.d.ts +3 -11
  154. package/lib/beta.d.ts +2 -11
  155. package/lib/core/index.d.ts +1 -1
  156. package/lib/core/index.d.ts.map +1 -1
  157. package/lib/core/index.js +1 -1
  158. package/lib/core/index.js.map +1 -1
  159. package/lib/core/schema-stored/index.d.ts +1 -1
  160. package/lib/core/schema-stored/index.d.ts.map +1 -1
  161. package/lib/core/schema-stored/index.js +1 -1
  162. package/lib/core/schema-stored/index.js.map +1 -1
  163. package/lib/core/schema-stored/schema.d.ts +4 -11
  164. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  165. package/lib/core/schema-stored/schema.js +6 -12
  166. package/lib/core/schema-stored/schema.js.map +1 -1
  167. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  168. package/lib/core/tree/anchorSet.js +31 -24
  169. package/lib/core/tree/anchorSet.js.map +1 -1
  170. package/lib/core/tree/deltaUtil.d.ts +1 -4
  171. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  172. package/lib/core/tree/deltaUtil.js +0 -9
  173. package/lib/core/tree/deltaUtil.js.map +1 -1
  174. package/lib/core/tree/visitDelta.d.ts +6 -29
  175. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  176. package/lib/core/tree/visitDelta.js +12 -51
  177. package/lib/core/tree/visitDelta.js.map +1 -1
  178. package/lib/core/tree/visitorUtils.d.ts +12 -9
  179. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  180. package/lib/core/tree/visitorUtils.js +19 -32
  181. package/lib/core/tree/visitorUtils.js.map +1 -1
  182. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  183. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -11
  184. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  185. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  186. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  187. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  188. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
  189. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  190. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
  191. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  192. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
  193. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  194. package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
  195. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  196. package/lib/feature-libraries/flex-tree/context.js +5 -1
  197. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  198. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  199. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  200. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  201. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  202. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  203. package/lib/feature-libraries/indexing/anchorTreeIndex.js +15 -22
  204. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  205. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  206. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  207. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  208. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  209. package/lib/feature-libraries/object-forest/objectForest.js +1 -7
  210. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  211. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  212. package/lib/feature-libraries/schema-index/codec.js +2 -2
  213. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  214. package/lib/index.d.ts +1 -1
  215. package/lib/index.d.ts.map +1 -1
  216. package/lib/index.js +1 -1
  217. package/lib/index.js.map +1 -1
  218. package/lib/internalTypes.d.ts +1 -1
  219. package/lib/internalTypes.d.ts.map +1 -1
  220. package/lib/internalTypes.js.map +1 -1
  221. package/lib/jsonDomainSchema.d.ts +6 -6
  222. package/lib/jsonDomainSchema.d.ts.map +1 -1
  223. package/lib/jsonDomainSchema.js.map +1 -1
  224. package/lib/legacy.d.ts +2 -11
  225. package/lib/packageVersion.d.ts +1 -1
  226. package/lib/packageVersion.js +1 -1
  227. package/lib/packageVersion.js.map +1 -1
  228. package/lib/public.d.ts +2 -11
  229. package/lib/serializableDomainSchema.d.ts +5 -5
  230. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  231. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  232. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  233. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  234. package/lib/shared-tree/index.d.ts +3 -2
  235. package/lib/shared-tree/index.d.ts.map +1 -1
  236. package/lib/shared-tree/index.js +1 -1
  237. package/lib/shared-tree/index.js.map +1 -1
  238. package/lib/shared-tree/sharedTree.d.ts +4 -35
  239. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  240. package/lib/shared-tree/sharedTree.js +2 -51
  241. package/lib/shared-tree/sharedTree.js.map +1 -1
  242. package/lib/simple-tree/api/index.d.ts +2 -1
  243. package/lib/simple-tree/api/index.d.ts.map +1 -1
  244. package/lib/simple-tree/api/index.js +1 -0
  245. package/lib/simple-tree/api/index.js.map +1 -1
  246. package/lib/simple-tree/api/schemaFactory.d.ts +28 -28
  247. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  248. package/lib/simple-tree/api/schemaFactory.js +11 -11
  249. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  250. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
  251. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  252. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  253. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
  254. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  255. package/lib/simple-tree/api/schemaFactoryRecursive.js +12 -0
  256. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  257. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  258. package/lib/simple-tree/api/tree.d.ts +1 -14
  259. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  260. package/lib/simple-tree/api/tree.js.map +1 -1
  261. package/lib/simple-tree/api/typesUnsafe.d.ts +237 -220
  262. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  263. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  264. package/lib/simple-tree/arrayNode.d.ts +2 -2
  265. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  266. package/lib/simple-tree/arrayNode.js.map +1 -1
  267. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  268. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  269. package/lib/simple-tree/core/treeNodeKernel.js +40 -25
  270. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  271. package/lib/simple-tree/core/types.d.ts +14 -4
  272. package/lib/simple-tree/core/types.d.ts.map +1 -1
  273. package/lib/simple-tree/core/types.js +14 -4
  274. package/lib/simple-tree/core/types.js.map +1 -1
  275. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  276. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  277. package/lib/simple-tree/core/unhydratedFlexTree.js +3 -0
  278. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  279. package/lib/simple-tree/index.d.ts +1 -1
  280. package/lib/simple-tree/index.d.ts.map +1 -1
  281. package/lib/simple-tree/index.js +1 -1
  282. package/lib/simple-tree/index.js.map +1 -1
  283. package/lib/simple-tree/objectNode.d.ts +9 -2
  284. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  285. package/lib/simple-tree/objectNode.js +4 -1
  286. package/lib/simple-tree/objectNode.js.map +1 -1
  287. package/lib/simple-tree/schemaTypes.d.ts +10 -5
  288. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  289. package/lib/simple-tree/schemaTypes.js +5 -2
  290. package/lib/simple-tree/schemaTypes.js.map +1 -1
  291. package/lib/tableSchema.d.ts +78 -26
  292. package/lib/tableSchema.d.ts.map +1 -1
  293. package/lib/tableSchema.js +53 -24
  294. package/lib/tableSchema.js.map +1 -1
  295. package/lib/treeFactory.d.ts +6 -12
  296. package/lib/treeFactory.d.ts.map +1 -1
  297. package/lib/treeFactory.js +55 -3
  298. package/lib/treeFactory.js.map +1 -1
  299. package/lib/tsdoc-metadata.json +1 -1
  300. package/package.json +22 -23
  301. package/src/core/index.ts +0 -2
  302. package/src/core/schema-stored/index.ts +0 -2
  303. package/src/core/schema-stored/schema.ts +10 -29
  304. package/src/core/tree/anchorSet.ts +32 -24
  305. package/src/core/tree/deltaUtil.ts +1 -13
  306. package/src/core/tree/visitDelta.ts +24 -81
  307. package/src/core/tree/visitorUtils.ts +43 -53
  308. package/src/feature-libraries/chunked-forest/chunkedForest.ts +7 -22
  309. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
  310. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +45 -27
  311. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -1
  312. package/src/feature-libraries/flex-tree/context.ts +11 -1
  313. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  314. package/src/feature-libraries/indexing/anchorTreeIndex.ts +17 -28
  315. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  316. package/src/feature-libraries/object-forest/objectForest.ts +1 -18
  317. package/src/feature-libraries/schema-index/codec.ts +1 -2
  318. package/src/index.ts +3 -11
  319. package/src/internalTypes.ts +0 -19
  320. package/src/jsonDomainSchema.ts +1 -3
  321. package/src/packageVersion.ts +1 -1
  322. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  323. package/src/shared-tree/index.ts +8 -3
  324. package/src/shared-tree/sharedTree.ts +5 -133
  325. package/src/simple-tree/api/index.ts +2 -22
  326. package/src/simple-tree/api/schemaFactory.ts +40 -54
  327. package/src/simple-tree/api/schemaFactoryAlpha.ts +9 -14
  328. package/src/simple-tree/api/schemaFactoryRecursive.ts +25 -5
  329. package/src/simple-tree/api/tree.ts +1 -14
  330. package/src/simple-tree/api/typesUnsafe.ts +359 -341
  331. package/src/simple-tree/arrayNode.ts +2 -2
  332. package/src/simple-tree/core/treeNodeKernel.ts +46 -28
  333. package/src/simple-tree/core/types.ts +14 -4
  334. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  335. package/src/simple-tree/index.ts +2 -22
  336. package/src/simple-tree/objectNode.ts +13 -4
  337. package/src/simple-tree/schemaTypes.ts +11 -7
  338. package/src/tableSchema.ts +190 -63
  339. package/src/treeFactory.ts +151 -8
@@ -1 +1 @@
1
- {"version":3,"file":"compressedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,IAAI,YAAY,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EAGtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAUnB;AAED,MAAM,MAAM,YAAY,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,KAAK,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,C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W,WAAW;IAC3B,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAAC;CAC3D;AAED,MAAM,MAAM,gBAAgB,GAAG,CAC9B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,qBAAqB,KACxB,YAAY,CAAC;AAElB,MAAM,MAAM,eAAe,GAAG,CAC7B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,wBAAwB,KAChC,WAAW,CAAC"}
1
+ {"version":3,"file":"compressedEncode.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,KAAK,EAEV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,IAAI,YAAY,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EAGtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAUnB;AAED,MAAM,MAAM,YAAY,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,KAAK,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAE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AAM,WAAW,UAAU;IAC1B,aAAa,CAAC,UAAU,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACjE;AAED,MAAM,WAAW,WAAW;IAC3B,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAAC;CAC3D;AAED,MAAM,MAAM,gBAAgB,GAAG,CAC9B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,qBAAqB,KACxB,YAAY,CAAC;AAElB,MAAM,MAAM,eAAe,GAAG,CAC7B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,wBAAwB,KAChC,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"compressedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,qDASgC;AAChC,qDAAqD;AAIrD,uEAImC;AAEnC,2CAQqB;AAGrB;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC/B,UAAsB,EACtB,KAAmB;IAEnB,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,uBAAe,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAA,oDAA0B,EAAC,mBAAO,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AAbD,4CAaC;AAoED;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAAoB;IAClD,OAAO;QACN,WAAW,CACV,MAA8B,EAC9B,MAAoB,EACpB,YAA0B;YAE1B,IAAA,sBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAA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IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7D,CAAC;CACD;AAvBD,oCAuBC;AAoBD,MAAM,gBAAgB;IAGrB,YACiB,KAAiB,EACjB,KAA4B,EAC3B,YAA8B;QAF/B,UAAK,GAAL,KAAK,CAAY;QACjB,UAAK,GAAL,KAAK,CAAuB;QAC3B,iBAAY,GAAZ,YAAY,CAAkB;IAC7C,CAAC;IACG,WAAW,CACjB,MAA8B,EAC9B,KAAmB,EACnB,YAA0B;QAE1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,OAAO;QAClB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype Value,\n\tforEachNode,\n} from \"../../../core/index.js\";\nimport { getOrCreate } from \"../../../util/index.js\";\nimport type { FlexFieldKind } from \"../../modular-schema/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport {\n\ttype BufferFormat as BufferFormatGeneric,\n\tShape as ShapeGeneric,\n\thandleShapesAndIdentifiers,\n} from \"./chunkEncodingGeneric.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedNestedArray,\n\ttype EncodedValueShape,\n\tSpecialField,\n\tversion,\n} from \"./format.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `FieldBatch` into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n *\n * Most of the compression strategy comes from the policy provided via `cache`.\n */\nexport function compressedEncode(\n\tfieldBatch: FieldBatch,\n\tcache: EncoderCache,\n): EncodedFieldBatch {\n\tconst batchBuffer: BufferFormat[] = [];\n\n\t// Populate buffer, including shape and identifier references\n\tfor (const cursor of fieldBatch) {\n\t\tconst buffer: BufferFormat = [];\n\t\tanyFieldEncoder.encodeField(cursor, cache, buffer);\n\t\tbatchBuffer.push(buffer);\n\t}\n\treturn handleShapesAndIdentifiers(version, batchBuffer);\n}\n\nexport type BufferFormat = BufferFormatGeneric<EncodedChunkShape>;\nexport type Shape = ShapeGeneric<EncodedChunkShape>;\n\n/**\n * Like {@link FieldEncoder}, except data will be prefixed with the key.\n */\nexport interface KeyedFieldEncoder {\n\treadonly key: FieldKey;\n\treadonly shape: FieldEncoder;\n}\n\n/**\n * An encoder with an associated shape.\n */\nexport interface Encoder {\n\t/**\n\t * The shape which describes how the encoded data is laid out.\n\t * Used by decoders to interpret the output of `encodeNode`.\n\t */\n\treadonly shape: Shape;\n}\n\n/**\n * An encoder for a specific shape of node.\n *\n * Can only be used with compatible nodes.\n */\nexport interface NodeEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Does not move cursor.\n\t */\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a run of nodes.\n */\nexport interface NodesEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Moves cursor however many nodes it encodes.\n\t */\n\tencodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a field.\n */\nexport interface FieldEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Fields mode. Encodes entire field.\n\t */\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Makes a {@link FieldEncoder} which runs `encoder` on every node in the field.\n * This does not encode the number nodes: the user of this may need to encode that elsewhere.\n */\nexport function asFieldEncoder(encoder: NodeEncoder): FieldEncoder {\n\treturn {\n\t\tencodeField(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tforEachNode(cursor, () => encoder.encodeNode(cursor, shapes, outputBuffer));\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Adapt a {@link NodeEncoder} to a {@link NodesEncoder} which invokes `encoder` once.\n */\nexport function asNodesEncoder(encoder: NodeEncoder): NodesEncoder {\n\treturn {\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tencoder.encodeNode(cursor, shapes, outputBuffer);\n\t\t\tcursor.nextNode();\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Encodes a chunk with {@link EncodedAnyShape} by prefixing the data with its shape.\n */\nexport class AnyShape extends ShapeGeneric<EncodedChunkShape> {\n\tprivate constructor() {\n\t\tsuper();\n\t}\n\tpublic static readonly instance = new AnyShape();\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst encodedAnyShape: EncodedAnyShape = 0;\n\t\treturn { d: encodedAnyShape };\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {}\n\n\tpublic static encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: FieldEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodeEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNode(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodesEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNodes(cursor, cache, outputBuffer);\n\t}\n}\n\n/**\n * Encodes a single node polymorphically.\n */\nexport const anyNodeEncoder: NodeEncoder = {\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunk content.\n\t\tconst shape = cache.shapeFromTree(cursor.type);\n\t\tAnyShape.encodeNode(cursor, cache, outputBuffer, shape);\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a field polymorphically.\n */\nexport const anyFieldEncoder: FieldEncoder = {\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunks.\n\n\t\tif (cursor.getFieldLength() === 0) {\n\t\t\tconst shape = InlineArrayShape.empty;\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t} else if (cursor.getFieldLength() === 1) {\n\t\t\t// Fast path chunk of size one size one at least: skip nested array.\n\t\t\tcursor.enterNode(0);\n\t\t\tanyNodeEncoder.encodeNode(cursor, cache, outputBuffer);\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// TODO: more efficient encoding for common cases.\n\t\t\t// Could try to find more specific shape compatible with all children than `anyNodeEncoder`.\n\n\t\t\tconst shape = cache.nestedArray(anyNodeEncoder);\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t}\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a chunk using {@link EncodedInlineArray}.\n */\nexport class InlineArrayShape\n\textends ShapeGeneric<EncodedChunkShape>\n\timplements NodesEncoder, FieldEncoder\n{\n\tpublic static readonly empty: InlineArrayShape = new InlineArrayShape(0, {\n\t\tget shape() {\n\t\t\t// Not actually used, makes count work without adding an additional shape.\n\t\t\treturn InlineArrayShape.empty;\n\t\t},\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tfail(0xb4d /* Empty array should not encode any nodes */);\n\t\t},\n\t});\n\n\t/**\n\t * @param length - number of invocations of `inner`.\n\t */\n\tpublic constructor(\n\t\tpublic readonly length: number,\n\t\tpublic readonly inner: NodesEncoder,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Linter is wrong about this loop being for-of compatible.\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-for-of\n\t\tfor (let index = 0; index < this.length; index++) {\n\t\t\tthis.inner.encodeNodes(cursor, shapes, outputBuffer);\n\t\t}\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Its possible individual items from this array encode multiple nodes, so don't assume === here.\n\t\tassert(\n\t\t\tcursor.getFieldLength() >= this.length,\n\t\t\t0x73c /* unexpected length for fixed length array */,\n\t\t);\n\t\tcursor.firstNode();\n\t\tthis.encodeNodes(cursor, shapes, outputBuffer);\n\t\tassert(\n\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t0x73d /* should return to fields mode when finished encoding */,\n\t\t);\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tb: {\n\t\t\t\tlength: this.length,\n\t\t\t\tshape: shapes.valueToIndex.get(this.inner.shape) ?? fail(0xb4e /* missing shape */),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n\n\tpublic get shape(): this {\n\t\treturn this;\n\t}\n}\n\n/**\n * Encodes a field as a nested array with the {@link EncodedNestedArray} shape.\n */\nexport class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {\n\tpublic readonly shape: Shape;\n\n\tpublic constructor(public readonly inner: NodeEncoder) {\n\t\tsuper();\n\t\tthis.shape = this;\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tconst buffer: BufferFormat = [];\n\t\tlet allNonZeroSize = true;\n\t\tconst length = cursor.getFieldLength();\n\t\tforEachNode(cursor, () => {\n\t\t\tconst before = buffer.length;\n\t\t\tthis.inner.encodeNode(cursor, cache, buffer);\n\t\t\tallNonZeroSize &&= buffer.length - before !== 0;\n\t\t});\n\t\tif (buffer.length === 0) {\n\t\t\t// This relies on the number of inner chunks being the same as the number of nodes.\n\t\t\t// If making inner a `NodesEncoder`, this code will have to be adjusted accordingly.\n\t\t\toutputBuffer.push(length);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tallNonZeroSize,\n\t\t\t\t0x73e /* either all or none of the members of a nested array must be 0 sized, or there is no way the decoder could process the content correctly. */,\n\t\t\t);\n\t\t\toutputBuffer.push(buffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst shape: EncodedNestedArray =\n\t\t\tshapes.valueToIndex.get(this.inner.shape) ??\n\t\t\tfail(0xb4f /* index for shape not found in table */);\n\t\treturn {\n\t\t\ta: shape,\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n}\n\n/**\n * Encode `value` with `shape` into `outputBuffer`.\n *\n * Requires that `value` is compatible with `shape`.\n */\nexport function encodeValue(\n\tvalue: Value,\n\tshape: EncodedValueShape,\n\toutputBuffer: BufferFormat,\n): void {\n\tif (shape === undefined) {\n\t\tif (value !== undefined) {\n\t\t\toutputBuffer.push(true, value);\n\t\t} else {\n\t\t\toutputBuffer.push(false);\n\t\t}\n\t} else {\n\t\tif (shape === true) {\n\t\t\tassert(value !== undefined, 0x78d /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else if (shape === false) {\n\t\t\tassert(value === undefined, 0x73f /* incompatible value shape: expected no value */);\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x740 /* expected a single constant for value */);\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the encoding of identifier fields.\n\t\t\tassert(value !== undefined, 0x998 /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"Encoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\nexport class EncoderCache implements TreeShaper, FieldShaper {\n\tprivate readonly shapesFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> = new Map();\n\tprivate readonly nestedArrays: Map<NodeEncoder, NestedArrayShape> = new Map();\n\tpublic constructor(\n\t\tprivate readonly treeEncoder: TreeShapePolicy,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t\tpublic readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\t\tpublic readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic shapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {\n\t\treturn getOrCreate(this.shapesFromSchema, schemaName, () =>\n\t\t\tthis.treeEncoder(this, schemaName),\n\t\t);\n\t}\n\n\tpublic nestedArray(inner: NodeEncoder): NestedArrayShape {\n\t\treturn getOrCreate(this.nestedArrays, inner, () => new NestedArrayShape(inner));\n\t}\n\n\tpublic shapeFromField(field: TreeFieldStoredSchema): FieldEncoder {\n\t\treturn new LazyFieldEncoder(this, field, this.fieldEncoder);\n\t}\n}\n\nexport interface TreeShaper {\n\tshapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;\n}\n\nexport interface FieldShaper {\n\tshapeFromField(field: TreeFieldStoredSchema): FieldEncoder;\n}\n\nexport type FieldShapePolicy = (\n\ttreeShaper: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n) => FieldEncoder;\n\nexport type TreeShapePolicy = (\n\tfieldShaper: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n) => NodeEncoder;\n\nclass LazyFieldEncoder implements FieldEncoder {\n\tprivate encoderLazy: FieldEncoder | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly cache: TreeShaper,\n\t\tpublic readonly field: TreeFieldStoredSchema,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t) {}\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tthis.encoder.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tprivate get encoder(): FieldEncoder {\n\t\tif (this.encoderLazy === undefined) {\n\t\t\tthis.encoderLazy = this.fieldEncoder(this.cache, this.field);\n\t\t}\n\t\treturn this.encoderLazy;\n\t}\n\n\tpublic get shape(): Shape {\n\t\treturn this.encoder.shape;\n\t}\n}\n"]}
1
+ {"version":3,"file":"compressedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/compressedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,qDASgC;AAChC,qDAAqD;AAIrD,uEAImC;AAEnC,2CAQqB;AAGrB;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAC/B,UAAsB,EACtB,KAAmB;IAEnB,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QACjC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,uBAAe,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAA,oDAA0B,EAAC,mBAAO,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AAbD,4CAaC;AAoED;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAAoB;IAClD,OAAO;QACN,WAAW,CACV,MAA8B,EAC9B,MAAoB,EACpB,YAA0B;YAE1B,IAAA,sBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,EAAE,OAAO,CAAC,KAAK;KACpB,CAAC;AACH,CAAC;AAXD,wCAWC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,OAAoB;IAClD,OAAO;QACN,WAAW,CACV,MAA8B,EAC9B,MA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K,CAAY;QACjB,UAAK,GAAL,KAAK,CAAuB;QAC3B,iBAAY,GAAZ,YAAY,CAAkB;IAC7C,CAAC;IACG,WAAW,CACjB,MAA8B,EAC9B,KAAmB,EACnB,YAA0B;QAE1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,OAAO;QAClB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype Value,\n\tforEachNode,\n} from \"../../../core/index.js\";\nimport { getOrCreate } from \"../../../util/index.js\";\nimport type { FlexFieldKind } from \"../../modular-schema/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport {\n\ttype BufferFormat as BufferFormatGeneric,\n\tShape as ShapeGeneric,\n\thandleShapesAndIdentifiers,\n} from \"./chunkEncodingGeneric.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport {\n\ttype EncodedAnyShape,\n\ttype EncodedChunkShape,\n\ttype EncodedFieldBatch,\n\ttype EncodedNestedArray,\n\ttype EncodedValueShape,\n\tSpecialField,\n\tversion,\n} from \"./format.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `FieldBatch` into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n *\n * Most of the compression strategy comes from the policy provided via `cache`.\n */\nexport function compressedEncode(\n\tfieldBatch: FieldBatch,\n\tcache: EncoderCache,\n): EncodedFieldBatch {\n\tconst batchBuffer: BufferFormat[] = [];\n\n\t// Populate buffer, including shape and identifier references\n\tfor (const cursor of fieldBatch) {\n\t\tconst buffer: BufferFormat = [];\n\t\tanyFieldEncoder.encodeField(cursor, cache, buffer);\n\t\tbatchBuffer.push(buffer);\n\t}\n\treturn handleShapesAndIdentifiers(version, batchBuffer);\n}\n\nexport type BufferFormat = BufferFormatGeneric<EncodedChunkShape>;\nexport type Shape = ShapeGeneric<EncodedChunkShape>;\n\n/**\n * Like {@link FieldEncoder}, except data will be prefixed with the key.\n */\nexport interface KeyedFieldEncoder {\n\treadonly key: FieldKey;\n\treadonly encoder: FieldEncoder;\n}\n\n/**\n * An encoder with an associated shape.\n */\nexport interface Encoder {\n\t/**\n\t * The shape which describes how the encoded data is laid out.\n\t * Used by decoders to interpret the output of `encodeNode`.\n\t */\n\treadonly shape: Shape;\n}\n\n/**\n * An encoder for a specific shape of node.\n *\n * Can only be used with compatible nodes.\n */\nexport interface NodeEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Does not move cursor.\n\t */\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a run of nodes.\n */\nexport interface NodesEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Nodes mode. Moves cursor however many nodes it encodes.\n\t */\n\tencodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Like {@link NodeEncoder}, except encodes a field.\n */\nexport interface FieldEncoder extends Encoder {\n\t/**\n\t * @param cursor - in Fields mode. Encodes entire field.\n\t */\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void;\n}\n\n/**\n * Makes a {@link FieldEncoder} which runs `encoder` on every node in the field.\n * This does not encode the number nodes: the user of this may need to encode that elsewhere.\n */\nexport function asFieldEncoder(encoder: NodeEncoder): FieldEncoder {\n\treturn {\n\t\tencodeField(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tforEachNode(cursor, () => encoder.encodeNode(cursor, shapes, outputBuffer));\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Adapt a {@link NodeEncoder} to a {@link NodesEncoder} which invokes `encoder` once.\n */\nexport function asNodesEncoder(encoder: NodeEncoder): NodesEncoder {\n\treturn {\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tencoder.encodeNode(cursor, shapes, outputBuffer);\n\t\t\tcursor.nextNode();\n\t\t},\n\t\tshape: encoder.shape,\n\t};\n}\n\n/**\n * Encodes a chunk with {@link EncodedAnyShape} by prefixing the data with its shape.\n */\nexport class AnyShape extends ShapeGeneric<EncodedChunkShape> {\n\tprivate constructor() {\n\t\tsuper();\n\t}\n\tpublic static readonly instance = new AnyShape();\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst encodedAnyShape: EncodedAnyShape = 0;\n\t\treturn { d: encodedAnyShape };\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {}\n\n\tpublic static encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: FieldEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodeEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNode(cursor, cache, outputBuffer);\n\t}\n\n\tpublic static encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t\tshape: NodesEncoder,\n\t): void {\n\t\toutputBuffer.push(shape.shape);\n\t\tshape.encodeNodes(cursor, cache, outputBuffer);\n\t}\n}\n\n/**\n * Encodes a single node polymorphically.\n */\nexport const anyNodeEncoder: NodeEncoder = {\n\tencodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunk content.\n\t\tconst shape = cache.shapeFromTree(cursor.type);\n\t\tAnyShape.encodeNode(cursor, cache, outputBuffer, shape);\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a field polymorphically.\n */\nexport const anyFieldEncoder: FieldEncoder = {\n\tencodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// TODO: Fast path uniform chunks.\n\n\t\tif (cursor.getFieldLength() === 0) {\n\t\t\tconst shape = InlineArrayShape.empty;\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t} else if (cursor.getFieldLength() === 1) {\n\t\t\t// Fast path chunk of size one size one at least: skip nested array.\n\t\t\tcursor.enterNode(0);\n\t\t\tanyNodeEncoder.encodeNode(cursor, cache, outputBuffer);\n\t\t\tcursor.exitNode();\n\t\t} else {\n\t\t\t// TODO: more efficient encoding for common cases.\n\t\t\t// Could try to find more specific shape compatible with all children than `anyNodeEncoder`.\n\n\t\t\tconst shape = cache.nestedArray(anyNodeEncoder);\n\t\t\tAnyShape.encodeField(cursor, cache, outputBuffer, shape);\n\t\t}\n\t},\n\n\tshape: AnyShape.instance,\n};\n\n/**\n * Encodes a chunk using {@link EncodedInlineArray}.\n */\nexport class InlineArrayShape\n\textends ShapeGeneric<EncodedChunkShape>\n\timplements NodesEncoder, FieldEncoder\n{\n\tpublic static readonly empty: InlineArrayShape = new InlineArrayShape(0, {\n\t\tget shape() {\n\t\t\t// Not actually used, makes count work without adding an additional shape.\n\t\t\treturn InlineArrayShape.empty;\n\t\t},\n\t\tencodeNodes(\n\t\t\tcursor: ITreeCursorSynchronous,\n\t\t\tshapes: EncoderCache,\n\t\t\toutputBuffer: BufferFormat,\n\t\t): void {\n\t\t\tfail(0xb4d /* Empty array should not encode any nodes */);\n\t\t},\n\t});\n\n\t/**\n\t * @param length - number of invocations of `inner`.\n\t */\n\tpublic constructor(\n\t\tpublic readonly length: number,\n\t\tpublic readonly inner: NodesEncoder,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic encodeNodes(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Linter is wrong about this loop being for-of compatible.\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-for-of\n\t\tfor (let index = 0; index < this.length; index++) {\n\t\t\tthis.inner.encodeNodes(cursor, shapes, outputBuffer);\n\t\t}\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tshapes: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\t// Its possible individual items from this array encode multiple nodes, so don't assume === here.\n\t\tassert(\n\t\t\tcursor.getFieldLength() >= this.length,\n\t\t\t0x73c /* unexpected length for fixed length array */,\n\t\t);\n\t\tcursor.firstNode();\n\t\tthis.encodeNodes(cursor, shapes, outputBuffer);\n\t\tassert(\n\t\t\tcursor.mode === CursorLocationType.Fields,\n\t\t\t0x73d /* should return to fields mode when finished encoding */,\n\t\t);\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tb: {\n\t\t\t\tlength: this.length,\n\t\t\t\tshape: shapes.valueToIndex.get(this.inner.shape) ?? fail(0xb4e /* missing shape */),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n\n\tpublic get shape(): this {\n\t\treturn this;\n\t}\n}\n\n/**\n * Encodes a field as a nested array with the {@link EncodedNestedArray} shape.\n */\nexport class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> implements FieldEncoder {\n\tpublic readonly shape: Shape;\n\n\tpublic constructor(public readonly inner: NodeEncoder) {\n\t\tsuper();\n\t\tthis.shape = this;\n\t}\n\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tconst buffer: BufferFormat = [];\n\t\tlet allNonZeroSize = true;\n\t\tconst length = cursor.getFieldLength();\n\t\tforEachNode(cursor, () => {\n\t\t\tconst before = buffer.length;\n\t\t\tthis.inner.encodeNode(cursor, cache, buffer);\n\t\t\tallNonZeroSize &&= buffer.length - before !== 0;\n\t\t});\n\t\tif (buffer.length === 0) {\n\t\t\t// This relies on the number of inner chunks being the same as the number of nodes.\n\t\t\t// If making inner a `NodesEncoder`, this code will have to be adjusted accordingly.\n\t\t\toutputBuffer.push(length);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tallNonZeroSize,\n\t\t\t\t0x73e /* either all or none of the members of a nested array must be 0 sized, or there is no way the decoder could process the content correctly. */,\n\t\t\t);\n\t\t\toutputBuffer.push(buffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape>,\n\t): EncodedChunkShape {\n\t\tconst shape: EncodedNestedArray =\n\t\t\tshapes.valueToIndex.get(this.inner.shape) ??\n\t\t\tfail(0xb4f /* index for shape not found in table */);\n\t\treturn {\n\t\t\ta: shape,\n\t\t};\n\t}\n\n\tpublic count(identifiers: Counter<string>, shapes: (shape: Shape) => void): void {\n\t\tshapes(this.inner.shape);\n\t}\n}\n\n/**\n * Encode `value` with `shape` into `outputBuffer`.\n *\n * Requires that `value` is compatible with `shape`.\n */\nexport function encodeValue(\n\tvalue: Value,\n\tshape: EncodedValueShape,\n\toutputBuffer: BufferFormat,\n): void {\n\tif (shape === undefined) {\n\t\tif (value !== undefined) {\n\t\t\toutputBuffer.push(true, value);\n\t\t} else {\n\t\t\toutputBuffer.push(false);\n\t\t}\n\t} else {\n\t\tif (shape === true) {\n\t\t\tassert(value !== undefined, 0x78d /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else if (shape === false) {\n\t\t\tassert(value === undefined, 0x73f /* incompatible value shape: expected no value */);\n\t\t} else if (Array.isArray(shape)) {\n\t\t\tassert(shape.length === 1, 0x740 /* expected a single constant for value */);\n\t\t} else if (shape === SpecialField.Identifier) {\n\t\t\t// This case is a special case handling the encoding of identifier fields.\n\t\t\tassert(value !== undefined, 0x998 /* required value must not be missing */);\n\t\t\toutputBuffer.push(value);\n\t\t} else {\n\t\t\t// EncodedCounter case:\n\t\t\tunreachableCase(shape, \"Encoding values as deltas is not yet supported\");\n\t\t}\n\t}\n}\n\nexport class EncoderCache implements TreeShaper, FieldShaper {\n\tprivate readonly shapesFromSchema: Map<TreeNodeSchemaIdentifier, NodeEncoder> = new Map();\n\tprivate readonly nestedArrays: Map<NodeEncoder, NestedArrayShape> = new Map();\n\tpublic constructor(\n\t\tprivate readonly treeEncoder: TreeShapePolicy,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t\tpublic readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n\t\tpublic readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic shapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {\n\t\treturn getOrCreate(this.shapesFromSchema, schemaName, () =>\n\t\t\tthis.treeEncoder(this, schemaName),\n\t\t);\n\t}\n\n\tpublic nestedArray(inner: NodeEncoder): NestedArrayShape {\n\t\treturn getOrCreate(this.nestedArrays, inner, () => new NestedArrayShape(inner));\n\t}\n\n\tpublic shapeFromField(field: TreeFieldStoredSchema): FieldEncoder {\n\t\treturn new LazyFieldEncoder(this, field, this.fieldEncoder);\n\t}\n}\n\nexport interface TreeShaper {\n\tshapeFromTree(schemaName: TreeNodeSchemaIdentifier): NodeEncoder;\n}\n\nexport interface FieldShaper {\n\tshapeFromField(field: TreeFieldStoredSchema): FieldEncoder;\n}\n\nexport type FieldShapePolicy = (\n\ttreeShaper: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n) => FieldEncoder;\n\nexport type TreeShapePolicy = (\n\tfieldShaper: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n) => NodeEncoder;\n\nclass LazyFieldEncoder implements FieldEncoder {\n\tprivate encoderLazy: FieldEncoder | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly cache: TreeShaper,\n\t\tpublic readonly field: TreeFieldStoredSchema,\n\t\tprivate readonly fieldEncoder: FieldShapePolicy,\n\t) {}\n\tpublic encodeField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat,\n\t): void {\n\t\tthis.encoder.encodeField(cursor, cache, outputBuffer);\n\t}\n\n\tprivate get encoder(): FieldEncoder {\n\t\tif (this.encoderLazy === undefined) {\n\t\t\tthis.encoderLazy = this.fieldEncoder(this.cache, this.field);\n\t\t}\n\t\treturn this.encoderLazy;\n\t}\n\n\tpublic get shape(): Shape {\n\t\treturn this.encoder.shape;\n\t}\n}\n"]}
@@ -10,15 +10,51 @@ import type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from "./
10
10
  export declare class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {
11
11
  readonly type: undefined | TreeNodeSchemaIdentifier;
12
12
  readonly value: EncodedValueShape;
13
- readonly fields: readonly KeyedFieldEncoder[];
14
- readonly extraLocal: undefined | FieldEncoder;
15
- private readonly explicitKeys;
16
- constructor(type: undefined | TreeNodeSchemaIdentifier, value: EncodedValueShape, fields: readonly KeyedFieldEncoder[], extraLocal: undefined | FieldEncoder);
13
+ /**
14
+ * Encoders for a specific set of fields, by key, in the order they will be encoded.
15
+ * These are fields for which specialized encoding is provided as an optimization.
16
+ * Using these for a given field instead of falling back to {@link NodeShape.specializedFieldEncoders} is often more efficient:
17
+ * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.
18
+ * Instead, this information is here, and thus is encoded only once as part of the node shape.
19
+ * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).
20
+ *
21
+ * Any fields not included here will be encoded using {@link NodeShape.otherFieldsEncoder}.
22
+ * If {@link NodeShape.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.
23
+ */
24
+ readonly specializedFieldEncoders: readonly KeyedFieldEncoder[];
25
+ /**
26
+ * Encoder for all other fields that are not in {@link NodeShape.specializedFieldEncoders}. These fields must
27
+ * be encoded after the specialized fields.
28
+ */
29
+ readonly otherFieldsEncoder: undefined | FieldEncoder;
30
+ /**
31
+ * Set of keys for fields that are encoded using {@link NodeShape.specializedFieldEncoders}.
32
+ * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.
33
+ */
34
+ private readonly specializedFieldKeys;
35
+ constructor(type: undefined | TreeNodeSchemaIdentifier, value: EncodedValueShape,
36
+ /**
37
+ * Encoders for a specific set of fields, by key, in the order they will be encoded.
38
+ * These are fields for which specialized encoding is provided as an optimization.
39
+ * Using these for a given field instead of falling back to {@link NodeShape.specializedFieldEncoders} is often more efficient:
40
+ * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.
41
+ * Instead, this information is here, and thus is encoded only once as part of the node shape.
42
+ * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).
43
+ *
44
+ * Any fields not included here will be encoded using {@link NodeShape.otherFieldsEncoder}.
45
+ * If {@link NodeShape.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.
46
+ */
47
+ specializedFieldEncoders: readonly KeyedFieldEncoder[],
48
+ /**
49
+ * Encoder for all other fields that are not in {@link NodeShape.specializedFieldEncoders}. These fields must
50
+ * be encoded after the specialized fields.
51
+ */
52
+ otherFieldsEncoder: undefined | FieldEncoder);
17
53
  private getValueToEncode;
18
54
  encodeNode(cursor: ITreeCursorSynchronous, cache: EncoderCache, outputBuffer: BufferFormat<EncodedChunkShape>): void;
19
55
  encodeShape(identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedChunkShape;
20
56
  count(identifiers: Counter<string>, shapes: (shape: Shape<EncodedChunkShape>) => void): void;
21
57
  get shape(): NodeShape;
22
58
  }
23
- export declare function encodeFieldShapes(fields: readonly KeyedFieldEncoder[], identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedFieldShape[] | undefined;
59
+ export declare function encodeFieldShapes(fieldEncoders: readonly KeyedFieldEncoder[], identifiers: DeduplicationTable<string>, shapes: DeduplicationTable<Shape<EncodedChunkShape>>): EncodedFieldShape[] | undefined;
24
60
  //# sourceMappingURL=nodeShape.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeShape.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAG7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAA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EAC9B,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,YAAY,CAAC,iBAAiB,CAAC,GAC3C,IAAI;IAgCA,WAAW,CACjB,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAClD,iBAAiB;IAWb,KAAK,CACX,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI,GAC/C,IAAI;IAeP,IAAW,KAAK,IAAI,SAAS,CAE5B;CACD;AAED,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAClD,iBAAiB,EAAE,GAAG,SAAS,CAUjC"}
@@ -12,13 +12,30 @@ const chunkEncodingGeneric_js_1 = require("./chunkEncodingGeneric.js");
12
12
  const compressedEncode_js_1 = require("./compressedEncode.js");
13
13
  const internal_2 = require("@fluidframework/id-compressor/internal");
14
14
  class NodeShape extends chunkEncodingGeneric_js_1.Shape {
15
- constructor(type, value, fields, extraLocal) {
15
+ constructor(type, value,
16
+ /**
17
+ * Encoders for a specific set of fields, by key, in the order they will be encoded.
18
+ * These are fields for which specialized encoding is provided as an optimization.
19
+ * Using these for a given field instead of falling back to {@link NodeShape.specializedFieldEncoders} is often more efficient:
20
+ * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.
21
+ * Instead, this information is here, and thus is encoded only once as part of the node shape.
22
+ * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).
23
+ *
24
+ * Any fields not included here will be encoded using {@link NodeShape.otherFieldsEncoder}.
25
+ * If {@link NodeShape.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.
26
+ */
27
+ specializedFieldEncoders,
28
+ /**
29
+ * Encoder for all other fields that are not in {@link NodeShape.specializedFieldEncoders}. These fields must
30
+ * be encoded after the specialized fields.
31
+ */
32
+ otherFieldsEncoder) {
16
33
  super();
17
34
  this.type = type;
18
35
  this.value = value;
19
- this.fields = fields;
20
- this.extraLocal = extraLocal;
21
- this.explicitKeys = new Set(this.fields.map((f) => f.key));
36
+ this.specializedFieldEncoders = specializedFieldEncoders;
37
+ this.otherFieldsEncoder = otherFieldsEncoder;
38
+ this.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));
22
39
  }
23
40
  getValueToEncode(cursor, cache) {
24
41
  if (this.value === 0) {
@@ -40,22 +57,22 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
40
57
  (0, internal_1.assert)(cursor.type === this.type, 0x741 /* type must match shape */);
41
58
  }
42
59
  (0, compressedEncode_js_1.encodeValue)(this.getValueToEncode(cursor, cache), this.value, outputBuffer);
43
- for (const field of this.fields) {
44
- cursor.enterField((0, index_js_2.brand)(field.key));
45
- field.shape.encodeField(cursor, cache, outputBuffer);
60
+ for (const fieldEncoder of this.specializedFieldEncoders) {
61
+ cursor.enterField((0, index_js_2.brand)(fieldEncoder.key));
62
+ fieldEncoder.encoder.encodeField(cursor, cache, outputBuffer);
46
63
  cursor.exitField();
47
64
  }
48
- const localBuffer = [];
65
+ const otherFieldsBuffer = [];
49
66
  (0, index_js_1.forEachField)(cursor, () => {
50
67
  const key = cursor.getFieldKey();
51
- if (!this.explicitKeys.has(key)) {
52
- (0, internal_1.assert)(this.extraLocal !== undefined, 0x742 /* had extra local fields when shape does not support them */);
53
- localBuffer.push(new chunkEncodingGeneric_js_1.IdentifierToken(key));
54
- this.extraLocal.encodeField(cursor, cache, localBuffer);
68
+ if (!this.specializedFieldKeys.has(key)) {
69
+ (0, internal_1.assert)(this.otherFieldsEncoder !== undefined, 0x742 /* had extra local fields when shape does not support them */);
70
+ otherFieldsBuffer.push(new chunkEncodingGeneric_js_1.IdentifierToken(key));
71
+ this.otherFieldsEncoder.encodeField(cursor, cache, otherFieldsBuffer);
55
72
  }
56
73
  });
57
- if (this.extraLocal !== undefined) {
58
- outputBuffer.push(localBuffer);
74
+ if (this.otherFieldsEncoder !== undefined) {
75
+ outputBuffer.push(otherFieldsBuffer);
59
76
  }
60
77
  }
61
78
  encodeShape(identifiers, shapes) {
@@ -63,8 +80,8 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
63
80
  c: {
64
81
  type: encodeOptionalIdentifier(this.type, identifiers),
65
82
  value: this.value,
66
- fields: encodeFieldShapes(this.fields, identifiers, shapes),
67
- extraFields: encodeOptionalFieldShape(this.extraLocal, shapes),
83
+ fields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),
84
+ extraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),
68
85
  },
69
86
  };
70
87
  }
@@ -72,12 +89,12 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
72
89
  if (this.type !== undefined) {
73
90
  identifiers.add(this.type);
74
91
  }
75
- for (const field of this.fields) {
76
- identifiers.add(field.key);
77
- shapes(field.shape.shape);
92
+ for (const fieldEncoder of this.specializedFieldEncoders) {
93
+ identifiers.add(fieldEncoder.key);
94
+ shapes(fieldEncoder.encoder.shape);
78
95
  }
79
- if (this.extraLocal !== undefined) {
80
- shapes(this.extraLocal.shape);
96
+ if (this.otherFieldsEncoder !== undefined) {
97
+ shapes(this.otherFieldsEncoder.shape);
81
98
  }
82
99
  }
83
100
  get shape() {
@@ -85,15 +102,15 @@ class NodeShape extends chunkEncodingGeneric_js_1.Shape {
85
102
  }
86
103
  }
87
104
  exports.NodeShape = NodeShape;
88
- function encodeFieldShapes(fields, identifiers, shapes) {
89
- if (fields.length === 0) {
105
+ function encodeFieldShapes(fieldEncoders, identifiers, shapes) {
106
+ if (fieldEncoders.length === 0) {
90
107
  return undefined;
91
108
  }
92
- return fields.map((field) => [
109
+ return fieldEncoders.map((fieldEncoder) => [
93
110
  // key
94
- encodeIdentifier(field.key, identifiers),
111
+ encodeIdentifier(fieldEncoder.key, identifiers),
95
112
  // shape
96
- shapes.valueToIndex.get(field.shape.shape) ?? (0, internal_1.fail)(0xb50 /* missing shape */),
113
+ shapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? (0, internal_1.fail)(0xb50 /* missing shape */),
97
114
  ]);
98
115
  }
99
116
  exports.encodeFieldShapes = encodeFieldShapes;
@@ -1 +1 @@
1
- {"version":3,"file":"nodeShape.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAE/B,qEAAoE;AAEpE,MAAa,SAAU,SAAQ,+BAAwB;IAItD,YACiB,IAA0C,EAC1C,KAAwB,EACxB,MAAoC,EACpC,UAAoC;QAEpD,KAAK,EAAE,CAAC;QALQ,SAAI,GAAJ,IAAI,CAAsC;QAC1C,UAAK,GAAL,KAAK,CAAmB;QACxB,WAAM,GAAN,MAAM,CAA8B;QACpC,eAAU,GAAV,UAAU,CAA0B;QAGpD,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;IAEO,gBAAgB,CAAC,MAA8B,EAAE,KAAmB;QAC3E,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YACtB,IAAA,iBAAM,EAAC,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACrF,IAAI,IAAA,qBAAU,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,wBAAwB,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC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ft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderCache,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nexport class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t// TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\tprivate readonly explicitKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\tpublic readonly fields: readonly KeyedFieldEncoder[],\n\t\tpublic readonly extraLocal: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.explicitKeys = new Set(this.fields.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, cache: EncoderCache): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = cache.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn cache.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, cache), this.value, outputBuffer);\n\t\tfor (const field of this.fields) {\n\t\t\tcursor.enterField(brand(field.key));\n\t\t\tfield.shape.encodeField(cursor, cache, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst localBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.explicitKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.extraLocal !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\tlocalBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.extraLocal.encodeField(cursor, cache, localBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.extraLocal !== undefined) {\n\t\t\toutputBuffer.push(localBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.fields, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.extraLocal, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const field of this.fields) {\n\t\t\tidentifiers.add(field.key);\n\t\t\tshapes(field.shape.shape);\n\t\t}\n\n\t\tif (this.extraLocal !== undefined) {\n\t\t\tshapes(this.extraLocal.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): NodeShape {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfields: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fields.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fields.map((field) => [\n\t\t// key\n\t\tencodeIdentifier(field.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(field.shape.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tshape: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn shape === undefined ? undefined : dedupShape(shape.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
1
+ {"version":3,"file":"nodeShape.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeShape.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAE/B,qEA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GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC;KACtF,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAS,gBAAgB,CACxB,UAAkB,EAClB,WAAuC;IAEvC,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderCache,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type { EncodedChunkShape, EncodedFieldShape, EncodedValueShape } from \"./format.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nexport class NodeShape extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t/**\n\t * Set of keys for fields that are encoded using {@link NodeShape.specializedFieldEncoders}.\n\t * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\t */\n\tprivate readonly specializedFieldKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\t/**\n\t\t * Encoders for a specific set of fields, by key, in the order they will be encoded.\n\t\t * These are fields for which specialized encoding is provided as an optimization.\n\t\t * Using these for a given field instead of falling back to {@link NodeShape.specializedFieldEncoders} is often more efficient:\n\t\t * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.\n\t\t * Instead, this information is here, and thus is encoded only once as part of the node shape.\n\t\t * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).\n\t\t *\n\t\t * Any fields not included here will be encoded using {@link NodeShape.otherFieldsEncoder}.\n\t\t * If {@link NodeShape.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.\n\t\t */\n\t\tpublic readonly specializedFieldEncoders: readonly KeyedFieldEncoder[],\n\t\t/**\n\t\t * Encoder for all other fields that are not in {@link NodeShape.specializedFieldEncoders}. These fields must\n\t\t * be encoded after the specialized fields.\n\t\t */\n\t\tpublic readonly otherFieldsEncoder: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, cache: EncoderCache): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = cache.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\treturn cache.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcache: EncoderCache,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, cache), this.value, outputBuffer);\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tcursor.enterField(brand(fieldEncoder.key));\n\t\t\tfieldEncoder.encoder.encodeField(cursor, cache, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst otherFieldsBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.specializedFieldKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.otherFieldsEncoder !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\totherFieldsBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.otherFieldsEncoder.encodeField(cursor, cache, otherFieldsBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\toutputBuffer.push(otherFieldsBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic count(\n\t\tidentifiers: Counter<string>,\n\t\tshapes: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tidentifiers.add(fieldEncoder.key);\n\t\t\tshapes(fieldEncoder.encoder.shape);\n\t\t}\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\tshapes(this.otherFieldsEncoder.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): NodeShape {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfieldEncoders: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fieldEncoders.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fieldEncoders.map((fieldEncoder) => [\n\t\t// key\n\t\tencodeIdentifier(fieldEncoder.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tshape: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn shape === undefined ? undefined : dedupShape(shape.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
@@ -60,7 +60,7 @@ function treeShaper(fullSchema, policy, fieldHandler, schemaName) {
60
60
  // to reduce encoded size.
61
61
  const objectNodeFields = [];
62
62
  for (const [key, field] of schema.objectNodeFields ?? []) {
63
- objectNodeFields.push({ key, shape: fieldHandler.shapeFromField(field) });
63
+ objectNodeFields.push({ key, encoder: fieldHandler.shapeFromField(field) });
64
64
  }
65
65
  const shape = new nodeShape_js_1.NodeShape(schemaName, false, objectNodeFields, undefined);
66
66
  return shape;
@@ -1 +1 @@
1
- {"version":3,"file":"schemaBasedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,qDAUgC;AAGhC,+DAS+B;AAE/B,2CAA2F;AAC3F,iDAA2C;AAG3C;;;;;GAKG;AACH,SAAgB,sBAAsB,CACrC,MAA8B,EAC9B,MAAwB,EACxB,UAAsB,EACtB,YAA2B;IAE3B,OAAO,IAAA,sCAAgB,EAAC,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC/E,CAAC;AAPD,wDAOC;AAED,SAAgB,UAAU,CACzB,MAA8B,EAC9B,MAAwB,EACxB,YAA2B;IAE3B,MAAM,KAAK,GAAiB,IAAI,kCAAY,CAC3C,CAAC,YAAyB,EAAE,UAAoC,EAAE,EAAE,CACnE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,EACrD,CAAC,WAAuB,EAAE,KAA4B,EAAE,EAAE,CACzD,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM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AAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAC7C,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAA,eAAI,EAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACzC,CAAC;AAzCD,gCAyCC;AAED,SAAgB,UAAU,CAAI,GAA+B;IAC5D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAVD,gCAUC;AAED,SAAS,oBAAoB,CAAC,MAA+B;IAC5D,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,SAAS;YACb,OAAO,KAAK,CAAC;QACd,KAAK,sBAAW,CAAC,MAAM,CAAC;QACxB,KAAK,sBAAW,CAAC,MAAM,CAAC;QACxB,KAAK,sBAAW,CAAC,OAAO,CAAC;QACzB,KAAK,sBAAW,CAAC,WAAW;YAC3B,OAAO,IAAI,CAAC;QACb,KAAK,sBAAW,CAAC,IAAI;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QACf;YACC,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\tValueSchema,\n\tMultiplicity,\n\tidentifierFieldKindIdentifier,\n} from \"../../../core/index.js\";\nimport type { FullSchemaPolicy } from \"../../modular-schema/index.js\";\n\nimport {\n\tEncoderCache,\n\ttype FieldEncoder,\n\ttype FieldShaper,\n\ttype KeyedFieldEncoder,\n\ttype TreeShaper,\n\tanyNodeEncoder,\n\tasFieldEncoder,\n\tcompressedEncode,\n} from \"./compressedEncode.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { type EncodedFieldBatch, type EncodedValueShape, SpecialField } from \"./format.js\";\nimport { NodeShape } from \"./nodeShape.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `fieldBatch` in into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n * TODO: This function should eventually also take in the root FieldSchema to more efficiently compress the nodes.\n */\nexport function schemaCompressedEncode(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldBatch: FieldBatch,\n\tidCompressor: IIdCompressor,\n): EncodedFieldBatch {\n\treturn compressedEncode(fieldBatch, buildCache(schema, policy, idCompressor));\n}\n\nexport function buildCache(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tidCompressor: IIdCompressor,\n): EncoderCache {\n\tconst cache: EncoderCache = new EncoderCache(\n\t\t(fieldHandler: FieldShaper, schemaName: TreeNodeSchemaIdentifier) =>\n\t\t\ttreeShaper(schema, policy, fieldHandler, schemaName),\n\t\t(treeHandler: TreeShaper, field: TreeFieldStoredSchema) =>\n\t\t\tfieldShaper(treeHandler, field, cache, schema),\n\t\tpolicy.fieldKinds,\n\t\tidCompressor,\n\t);\n\treturn cache;\n}\n\n/**\n * Selects shapes to use to encode fields.\n */\nexport function fieldShaper(\n\ttreeHandler: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n\tcache: EncoderCache,\n\tstoredSchema: StoredSchemaCollection,\n): FieldEncoder {\n\tconst kind = cache.fieldShapes.get(field.kind) ?? fail(0xb52 /* missing FieldKind */);\n\tconst type = oneFromSet(field.types);\n\tconst nodeEncoder = type !== undefined ? treeHandler.shapeFromTree(type) : anyNodeEncoder;\n\tif (kind.multiplicity === Multiplicity.Single) {\n\t\tif (field.kind === identifierFieldKindIdentifier) {\n\t\t\tassert(type !== undefined, 0x999 /* field type must be defined in identifier field */);\n\t\t\tconst nodeSchema = storedSchema.nodeSchema.get(type);\n\t\t\tassert(nodeSchema !== undefined, 0x99a /* nodeSchema must be defined */);\n\t\t\tassert(\n\t\t\t\tnodeSchema instanceof LeafNodeStoredSchema,\n\t\t\t\t0x99b /* nodeSchema must be LeafNodeStoredSchema */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tnodeSchema.leafValue === ValueSchema.String,\n\t\t\t\t0x99c /* identifier field can only be type string */,\n\t\t\t);\n\t\t\tconst identifierNodeEncoder = new NodeShape(\n\t\t\t\ttype,\n\t\t\t\tSpecialField.Identifier,\n\t\t\t\t[],\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\treturn asFieldEncoder(identifierNodeEncoder);\n\t\t}\n\t\treturn asFieldEncoder(nodeEncoder);\n\t} else {\n\t\treturn cache.nestedArray(nodeEncoder);\n\t}\n}\n\n/**\n * Selects shapes to use to encode trees.\n */\nexport function treeShaper(\n\tfullSchema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldHandler: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n): NodeShape {\n\tconst schema =\n\t\tfullSchema.nodeSchema.get(schemaName) ?? fail(0xb53 /* missing node schema */);\n\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t// TODO:Performance:\n\t\t// consider moving some optional and sequence fields to extra fields if they are commonly empty\n\t\t// to reduce encoded size.\n\n\t\tconst objectNodeFields: KeyedFieldEncoder[] = [];\n\t\tfor (const [key, field] of schema.objectNodeFields ?? []) {\n\t\t\tobjectNodeFields.push({ key, shape: fieldHandler.shapeFromField(field) });\n\t\t}\n\n\t\tconst shape = new NodeShape(schemaName, false, objectNodeFields, undefined);\n\t\treturn shape;\n\t}\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tvalueShapeFromSchema(schema.leafValue),\n\t\t\t[],\n\t\t\tundefined,\n\t\t);\n\t\treturn shape;\n\t}\n\tif (schema instanceof MapNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tfalse,\n\t\t\t[],\n\t\t\tfieldHandler.shapeFromField(schema.mapFields),\n\t\t);\n\t\treturn shape;\n\t}\n\tfail(0xb54 /* unsupported node kind */);\n}\n\nexport function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {\n\tif (set === undefined) {\n\t\treturn undefined;\n\t}\n\tif (set.size !== 1) {\n\t\treturn undefined;\n\t}\n\tfor (const item of set) {\n\t\treturn item;\n\t}\n}\n\nfunction valueShapeFromSchema(schema: ValueSchema | undefined): undefined | EncodedValueShape {\n\tswitch (schema) {\n\t\tcase undefined:\n\t\t\treturn false;\n\t\tcase ValueSchema.Number:\n\t\tcase ValueSchema.String:\n\t\tcase ValueSchema.Boolean:\n\t\tcase ValueSchema.FluidHandle:\n\t\t\treturn true;\n\t\tcase ValueSchema.Null:\n\t\t\treturn [null];\n\t\tdefault:\n\t\t\tunreachableCase(schema);\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaBasedEncode.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAoF;AAEpF,qDAUgC;AAGhC,+DAS+B;AAE/B,2CAA2F;AAC3F,iDAA2C;AAG3C;;;;;GAKG;AACH,SAAgB,sBAAsB,CACrC,MAA8B,EAC9B,MAAwB,EACxB,UAAsB,EACtB,YAA2B;IAE3B,OAAO,IAAA,sCAAgB,EAAC,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC/E,CAAC;AAPD,wDAOC;AAED,SAAgB,UAAU,CACzB,MAA8B,EAC9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KAAK,GAAG,IAAI,wBAAS,CAC1B,UAAU,EACV,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,EACtC,EAAE,EACF,SAAS,CACT,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,MAAM,YAAY,8BAAmB,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,IAAI,wBAAS,CAC1B,UAAU,EACV,KAAK,EACL,EAAE,EACF,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAC7C,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAA,eAAI,EAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACzC,CAAC;AAzCD,gCAyCC;AAED,SAAgB,UAAU,CAAI,GAA+B;IAC5D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAVD,gCAUC;AAED,SAAS,oBAAoB,CAAC,MAA+B;IAC5D,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,SAAS;YACb,OAAO,KAAK,CAAC;QACd,KAAK,sBAAW,CAAC,MAAM,CAAC;QACxB,KAAK,sBAAW,CAAC,MAAM,CAAC;QACxB,KAAK,sBAAW,CAAC,OAAO,CAAC;QACzB,KAAK,sBAAW,CAAC,WAAW;YAC3B,OAAO,IAAI,CAAC;QACb,KAAK,sBAAW,CAAC,IAAI;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QACf;YACC,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype StoredSchemaCollection,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\tValueSchema,\n\tMultiplicity,\n\tidentifierFieldKindIdentifier,\n} from \"../../../core/index.js\";\nimport type { FullSchemaPolicy } from \"../../modular-schema/index.js\";\n\nimport {\n\tEncoderCache,\n\ttype FieldEncoder,\n\ttype FieldShaper,\n\ttype KeyedFieldEncoder,\n\ttype TreeShaper,\n\tanyNodeEncoder,\n\tasFieldEncoder,\n\tcompressedEncode,\n} from \"./compressedEncode.js\";\nimport type { FieldBatch } from \"./fieldBatch.js\";\nimport { type EncodedFieldBatch, type EncodedValueShape, SpecialField } from \"./format.js\";\nimport { NodeShape } from \"./nodeShape.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\n/**\n * Encode data from `fieldBatch` in into an `EncodedChunk`.\n *\n * Optimized for encoded size and encoding performance.\n * TODO: This function should eventually also take in the root FieldSchema to more efficiently compress the nodes.\n */\nexport function schemaCompressedEncode(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldBatch: FieldBatch,\n\tidCompressor: IIdCompressor,\n): EncodedFieldBatch {\n\treturn compressedEncode(fieldBatch, buildCache(schema, policy, idCompressor));\n}\n\nexport function buildCache(\n\tschema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tidCompressor: IIdCompressor,\n): EncoderCache {\n\tconst cache: EncoderCache = new EncoderCache(\n\t\t(fieldHandler: FieldShaper, schemaName: TreeNodeSchemaIdentifier) =>\n\t\t\ttreeShaper(schema, policy, fieldHandler, schemaName),\n\t\t(treeHandler: TreeShaper, field: TreeFieldStoredSchema) =>\n\t\t\tfieldShaper(treeHandler, field, cache, schema),\n\t\tpolicy.fieldKinds,\n\t\tidCompressor,\n\t);\n\treturn cache;\n}\n\n/**\n * Selects shapes to use to encode fields.\n */\nexport function fieldShaper(\n\ttreeHandler: TreeShaper,\n\tfield: TreeFieldStoredSchema,\n\tcache: EncoderCache,\n\tstoredSchema: StoredSchemaCollection,\n): FieldEncoder {\n\tconst kind = cache.fieldShapes.get(field.kind) ?? fail(0xb52 /* missing FieldKind */);\n\tconst type = oneFromSet(field.types);\n\tconst nodeEncoder = type !== undefined ? treeHandler.shapeFromTree(type) : anyNodeEncoder;\n\tif (kind.multiplicity === Multiplicity.Single) {\n\t\tif (field.kind === identifierFieldKindIdentifier) {\n\t\t\tassert(type !== undefined, 0x999 /* field type must be defined in identifier field */);\n\t\t\tconst nodeSchema = storedSchema.nodeSchema.get(type);\n\t\t\tassert(nodeSchema !== undefined, 0x99a /* nodeSchema must be defined */);\n\t\t\tassert(\n\t\t\t\tnodeSchema instanceof LeafNodeStoredSchema,\n\t\t\t\t0x99b /* nodeSchema must be LeafNodeStoredSchema */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tnodeSchema.leafValue === ValueSchema.String,\n\t\t\t\t0x99c /* identifier field can only be type string */,\n\t\t\t);\n\t\t\tconst identifierNodeEncoder = new NodeShape(\n\t\t\t\ttype,\n\t\t\t\tSpecialField.Identifier,\n\t\t\t\t[],\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\treturn asFieldEncoder(identifierNodeEncoder);\n\t\t}\n\t\treturn asFieldEncoder(nodeEncoder);\n\t} else {\n\t\treturn cache.nestedArray(nodeEncoder);\n\t}\n}\n\n/**\n * Selects shapes to use to encode trees.\n */\nexport function treeShaper(\n\tfullSchema: StoredSchemaCollection,\n\tpolicy: FullSchemaPolicy,\n\tfieldHandler: FieldShaper,\n\tschemaName: TreeNodeSchemaIdentifier,\n): NodeShape {\n\tconst schema =\n\t\tfullSchema.nodeSchema.get(schemaName) ?? fail(0xb53 /* missing node schema */);\n\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\t// TODO:Performance:\n\t\t// consider moving some optional and sequence fields to extra fields if they are commonly empty\n\t\t// to reduce encoded size.\n\n\t\tconst objectNodeFields: KeyedFieldEncoder[] = [];\n\t\tfor (const [key, field] of schema.objectNodeFields ?? []) {\n\t\t\tobjectNodeFields.push({ key, encoder: fieldHandler.shapeFromField(field) });\n\t\t}\n\n\t\tconst shape = new NodeShape(schemaName, false, objectNodeFields, undefined);\n\t\treturn shape;\n\t}\n\tif (schema instanceof LeafNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tvalueShapeFromSchema(schema.leafValue),\n\t\t\t[],\n\t\t\tundefined,\n\t\t);\n\t\treturn shape;\n\t}\n\tif (schema instanceof MapNodeStoredSchema) {\n\t\tconst shape = new NodeShape(\n\t\t\tschemaName,\n\t\t\tfalse,\n\t\t\t[],\n\t\t\tfieldHandler.shapeFromField(schema.mapFields),\n\t\t);\n\t\treturn shape;\n\t}\n\tfail(0xb54 /* unsupported node kind */);\n}\n\nexport function oneFromSet<T>(set: ReadonlySet<T> | undefined): T | undefined {\n\tif (set === undefined) {\n\t\treturn undefined;\n\t}\n\tif (set.size !== 1) {\n\t\treturn undefined;\n\t}\n\tfor (const item of set) {\n\t\treturn item;\n\t}\n}\n\nfunction valueShapeFromSchema(schema: ValueSchema | undefined): undefined | EncodedValueShape {\n\tswitch (schema) {\n\t\tcase undefined:\n\t\t\treturn false;\n\t\tcase ValueSchema.Number:\n\t\tcase ValueSchema.String:\n\t\tcase ValueSchema.Boolean:\n\t\tcase ValueSchema.FluidHandle:\n\t\t\treturn true;\n\t\tcase ValueSchema.Null:\n\t\t\treturn [null];\n\t\tdefault:\n\t\t\tunreachableCase(schema);\n\t}\n}\n"]}
@@ -29,6 +29,10 @@ export interface FlexTreeContext {
29
29
  * If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.
30
30
  */
31
31
  isHydrated(): this is FlexTreeHydratedContext;
32
+ /**
33
+ * If true, none of the nodes in this context can be used.
34
+ */
35
+ isDisposed(): boolean;
32
36
  }
33
37
  /**
34
38
  * A common context of a "forest" of FlexTrees.
@@ -71,6 +75,7 @@ export declare class Context implements FlexTreeHydratedContext, IDisposable {
71
75
  */
72
76
  constructor(schemaPolicy: SchemaPolicy, checkout: ITreeCheckout, nodeKeyManager: NodeIdentifierManager);
73
77
  isHydrated(): this is FlexTreeHydratedContext;
78
+ isDisposed(): boolean;
74
79
  get schema(): TreeStoredSchema;
75
80
  /**
76
81
  * Called before editing.
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAGrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpC;;;;;OAKG;IACH,UAAU,IAAI,IAAI,IAAI,uBAAuB,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC/D,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IAC1C;;OAEG;IACH,IAAI,IAAI,IAAI,aAAa,CAAC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QAAQ,CAAS;IAEzB;;;;OAIG;gBAEc,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,qBAAqB;IAe/C,UAAU,IAAI,IAAI,IAAI,uBAAuB;IAK7C,UAAU,IAAI,OAAO;IAI5B,IAAW,MAAM,IAAI,gBAAgB,CAEpC;IAED;;;OAGG;IACH,OAAO,CAAC,cAAc;IAQf,CAAC,aAAa,CAAC,IAAI,IAAI;IAa9B;;;;;OAKG;IACI,KAAK,IAAI,IAAI;IAQpB,IAAW,IAAI,IAAI,aAAa,CAO/B;IAED,IAAW,MAAM,IAAI,UAAU,CAAC,YAAY,CAAC,CAE5C;CACD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,qBAAqB,GACnC,OAAO,CAET"}
@@ -41,8 +41,12 @@ class Context {
41
41
  this.checkout.forest.anchors.slots.set(exports.ContextSlot, this);
42
42
  }
43
43
  isHydrated() {
44
+ (0, internal_1.debugAssert)(() => !this.disposed || "Disposed");
44
45
  return true;
45
46
  }
47
+ isDisposed() {
48
+ return this.disposed;
49
+ }
46
50
  get schema() {
47
51
  return this.checkout.storedSchema;
48
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/context.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAM6B;AAE7B,kDAAsE;AAKtE,iDAA2C;AA8C3C;;;GAGG;AACU,QAAA,WAAW,GAAG,IAAA,qBAAU,GAAW,CAAC;AAEjD;;;;GAIG;AACH,MAAa,OAAO;IAOnB;;;;OAIG;IACH,YACiB,YAA0B,EAC1B,QAAuB,EACvB,cAAqC;QAFrC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAAe;QACvB,mBAAc,GAAd,cAAc,CAAuB;QAdtC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ChB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;CACD;AAzFD,0BAyFC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC7B,MAAoB,EACpB,QAAuB,EACvB,cAAqC;IAErC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAND,wCAMC","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\ttype ForestEvents,\n\ttype SchemaPolicy,\n\ttype TreeStoredSchema,\n\tanchorSlot,\n\tmoveToDetachedField,\n} from \"../../core/index.js\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { type IDisposable, disposeSymbol } from \"../../util/index.js\";\nimport type { NodeIdentifierManager } from \"../node-identifier/index.js\";\n\nimport type { FlexTreeField } from \"./flexTreeTypes.js\";\nimport type { LazyEntity } from \"./lazyEntity.js\";\nimport { makeField } from \"./lazyField.js\";\nimport type { ITreeCheckout } from \"../../shared-tree/index.js\";\n\n/**\n * Context for FlexTrees.\n */\nexport interface FlexTreeContext {\n\t/**\n\t * Schema used within this context.\n\t * All data must conform to these schema.\n\t */\n\treadonly schema: TreeStoredSchema;\n\n\t/**\n\t * SchemaPolicy used within this context.\n\t */\n\treadonly schemaPolicy: SchemaPolicy;\n\n\t/**\n\t * If true, this context is the canonical context instance for a given view,\n\t * and its schema include all schema from the document.\n\t *\n\t * If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.\n\t */\n\tisHydrated(): this is FlexTreeHydratedContext;\n}\n\n/**\n * A common context of a \"forest\" of FlexTrees.\n * It handles group operations like transforming cursors into anchors for edits.\n */\nexport interface FlexTreeHydratedContext extends FlexTreeContext {\n\treadonly events: Listenable<ForestEvents>;\n\t/**\n\t * Gets the root field of the tree.\n\t */\n\tget root(): FlexTreeField;\n\n\treadonly nodeKeyManager: NodeIdentifierManager;\n\n\t/**\n\t * The checkout object associated with this context.\n\t */\n\treadonly checkout: ITreeCheckout;\n}\n\n/**\n * Creating multiple flex tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.\n * This slot is used to detect if one already exists and error if creating a second.\n */\nexport const ContextSlot = anchorSlot<Context>();\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class Context implements FlexTreeHydratedContext, IDisposable {\n\tpublic readonly withCursors: Set<LazyEntity> = new Set();\n\tpublic readonly withAnchors: Set<LazyEntity> = new Set();\n\n\tprivate readonly eventUnregister: (() => void)[];\n\tprivate disposed = false;\n\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t * @param checkout - The checkout.\n\t * @param nodeKeyManager - An object which handles node key generation and conversion\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly checkout: ITreeCheckout,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t) {\n\t\tthis.eventUnregister = [\n\t\t\tthis.checkout.forest.events.on(\"beforeChange\", () => {\n\t\t\t\tthis.prepareForEdit();\n\t\t\t}),\n\t\t];\n\n\t\tassert(\n\t\t\t!this.checkout.forest.anchors.slots.has(ContextSlot),\n\t\t\t0x92b /* Cannot create second flex-tree from checkout */,\n\t\t);\n\t\tthis.checkout.forest.anchors.slots.set(ContextSlot, this);\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn true;\n\t}\n\n\tpublic get schema(): TreeStoredSchema {\n\t\treturn this.checkout.storedSchema;\n\t}\n\n\t/**\n\t * Called before editing.\n\t * Clears all cursors so editing can proceed.\n\t */\n\tprivate prepareForEdit(): void {\n\t\tassert(this.disposed === false, 0x802 /* use after dispose */);\n\t\tfor (const target of this.withCursors) {\n\t\t\ttarget.prepareForEdit();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x773 /* prepareForEdit should remove all cursors */);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tassert(this.disposed === false, 0x803 /* double dispose */);\n\t\tthis.disposed = true;\n\t\tthis.clear();\n\t\tfor (const unregister of this.eventUnregister) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.eventUnregister.length = 0;\n\n\t\tconst deleted = this.checkout.forest.anchors.slots.delete(ContextSlot);\n\t\tassert(deleted, 0x8c4 /* unexpected dispose */);\n\t}\n\n\t/**\n\t * Release any cursors and anchors held by tree entities created in this context.\n\t * Ensures the cashed references to those entities on the Anchors are also cleared.\n\t * The tree entities are invalid to use after this, but the context may still be used\n\t * to create new trees starting from the root.\n\t */\n\tpublic clear(): void {\n\t\tfor (const target of this.withAnchors) {\n\t\t\ttarget[disposeSymbol]();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x774 /* free should remove all cursors */);\n\t\tassert(this.withAnchors.size === 0, 0x775 /* free should remove all anchors */);\n\t}\n\n\tpublic get root(): FlexTreeField {\n\t\tassert(this.disposed === false, 0x804 /* use after dispose */);\n\t\tconst cursor = this.checkout.forest.allocateCursor(\"root\");\n\t\tmoveToDetachedField(this.checkout.forest, cursor);\n\t\tconst field = makeField(this, this.schema.rootFieldSchema.kind, cursor);\n\t\tcursor.free();\n\t\treturn field;\n\t}\n\n\tpublic get events(): Listenable<ForestEvents> {\n\t\treturn this.checkout.forest.events;\n\t}\n}\n\n/**\n * A simple API for a Forest to interact with the tree.\n *\n * @param forest - the Forest\n * @param editor - an editor that makes changes to the forest.\n * @param nodeKeyManager - an object which handles node key generation and conversion.\n * @returns {@link FlexTreeContext} which is used to manage the cursors and anchors within the FlexTrees:\n * This is necessary for supporting using this tree across edits to the forest, and not leaking memory.\n */\nexport function getTreeContext(\n\tschema: SchemaPolicy,\n\tcheckout: ITreeCheckout,\n\tnodeKeyManager: NodeIdentifierManager,\n): Context {\n\treturn new Context(schema, checkout, nodeKeyManager);\n}\n"]}
1
+ {"version":3,"file":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AI,KAAK,CAAC,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACjF,CAAC;IAED,IAAW,IAAI;QACd,IAAA,iBAAM,EAAC,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAA,8BAAmB,EAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,IAAA,wBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxE,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;CACD;AA9FD,0BA8FC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC7B,MAAoB,EACpB,QAAuB,EACvB,cAAqC;IAErC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAND,wCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, debugAssert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype ForestEvents,\n\ttype SchemaPolicy,\n\ttype TreeStoredSchema,\n\tanchorSlot,\n\tmoveToDetachedField,\n} from \"../../core/index.js\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { type IDisposable, disposeSymbol } from \"../../util/index.js\";\nimport type { NodeIdentifierManager } from \"../node-identifier/index.js\";\n\nimport type { FlexTreeField } from \"./flexTreeTypes.js\";\nimport type { LazyEntity } from \"./lazyEntity.js\";\nimport { makeField } from \"./lazyField.js\";\nimport type { ITreeCheckout } from \"../../shared-tree/index.js\";\n\n/**\n * Context for FlexTrees.\n */\nexport interface FlexTreeContext {\n\t/**\n\t * Schema used within this context.\n\t * All data must conform to these schema.\n\t */\n\treadonly schema: TreeStoredSchema;\n\n\t/**\n\t * SchemaPolicy used within this context.\n\t */\n\treadonly schemaPolicy: SchemaPolicy;\n\n\t/**\n\t * If true, this context is the canonical context instance for a given view,\n\t * and its schema include all schema from the document.\n\t *\n\t * If false, this context was created for use in a unhydrated tree, and the full document schema is unknown.\n\t */\n\tisHydrated(): this is FlexTreeHydratedContext;\n\n\t/**\n\t * If true, none of the nodes in this context can be used.\n\t */\n\tisDisposed(): boolean;\n}\n\n/**\n * A common context of a \"forest\" of FlexTrees.\n * It handles group operations like transforming cursors into anchors for edits.\n */\nexport interface FlexTreeHydratedContext extends FlexTreeContext {\n\treadonly events: Listenable<ForestEvents>;\n\t/**\n\t * Gets the root field of the tree.\n\t */\n\tget root(): FlexTreeField;\n\n\treadonly nodeKeyManager: NodeIdentifierManager;\n\n\t/**\n\t * The checkout object associated with this context.\n\t */\n\treadonly checkout: ITreeCheckout;\n}\n\n/**\n * Creating multiple flex tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.\n * This slot is used to detect if one already exists and error if creating a second.\n */\nexport const ContextSlot = anchorSlot<Context>();\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class Context implements FlexTreeHydratedContext, IDisposable {\n\tpublic readonly withCursors: Set<LazyEntity> = new Set();\n\tpublic readonly withAnchors: Set<LazyEntity> = new Set();\n\n\tprivate readonly eventUnregister: (() => void)[];\n\tprivate disposed = false;\n\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t * @param checkout - The checkout.\n\t * @param nodeKeyManager - An object which handles node key generation and conversion\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly checkout: ITreeCheckout,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t) {\n\t\tthis.eventUnregister = [\n\t\t\tthis.checkout.forest.events.on(\"beforeChange\", () => {\n\t\t\t\tthis.prepareForEdit();\n\t\t\t}),\n\t\t];\n\n\t\tassert(\n\t\t\t!this.checkout.forest.anchors.slots.has(ContextSlot),\n\t\t\t0x92b /* Cannot create second flex-tree from checkout */,\n\t\t);\n\t\tthis.checkout.forest.anchors.slots.set(ContextSlot, this);\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\tdebugAssert(() => !this.disposed || \"Disposed\");\n\t\treturn true;\n\t}\n\n\tpublic isDisposed(): boolean {\n\t\treturn this.disposed;\n\t}\n\n\tpublic get schema(): TreeStoredSchema {\n\t\treturn this.checkout.storedSchema;\n\t}\n\n\t/**\n\t * Called before editing.\n\t * Clears all cursors so editing can proceed.\n\t */\n\tprivate prepareForEdit(): void {\n\t\tassert(this.disposed === false, 0x802 /* use after dispose */);\n\t\tfor (const target of this.withCursors) {\n\t\t\ttarget.prepareForEdit();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x773 /* prepareForEdit should remove all cursors */);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tassert(this.disposed === false, 0x803 /* double dispose */);\n\t\tthis.disposed = true;\n\t\tthis.clear();\n\t\tfor (const unregister of this.eventUnregister) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.eventUnregister.length = 0;\n\n\t\tconst deleted = this.checkout.forest.anchors.slots.delete(ContextSlot);\n\t\tassert(deleted, 0x8c4 /* unexpected dispose */);\n\t}\n\n\t/**\n\t * Release any cursors and anchors held by tree entities created in this context.\n\t * Ensures the cashed references to those entities on the Anchors are also cleared.\n\t * The tree entities are invalid to use after this, but the context may still be used\n\t * to create new trees starting from the root.\n\t */\n\tpublic clear(): void {\n\t\tfor (const target of this.withAnchors) {\n\t\t\ttarget[disposeSymbol]();\n\t\t}\n\t\tassert(this.withCursors.size === 0, 0x774 /* free should remove all cursors */);\n\t\tassert(this.withAnchors.size === 0, 0x775 /* free should remove all anchors */);\n\t}\n\n\tpublic get root(): FlexTreeField {\n\t\tassert(this.disposed === false, 0x804 /* use after dispose */);\n\t\tconst cursor = this.checkout.forest.allocateCursor(\"root\");\n\t\tmoveToDetachedField(this.checkout.forest, cursor);\n\t\tconst field = makeField(this, this.schema.rootFieldSchema.kind, cursor);\n\t\tcursor.free();\n\t\treturn field;\n\t}\n\n\tpublic get events(): Listenable<ForestEvents> {\n\t\treturn this.checkout.forest.events;\n\t}\n}\n\n/**\n * A simple API for a Forest to interact with the tree.\n *\n * @param forest - the Forest\n * @param editor - an editor that makes changes to the forest.\n * @param nodeKeyManager - an object which handles node key generation and conversion.\n * @returns {@link FlexTreeContext} which is used to manage the cursors and anchors within the FlexTrees:\n * This is necessary for supporting using this tree across edits to the forest, and not leaking memory.\n */\nexport function getTreeContext(\n\tschema: SchemaPolicy,\n\tcheckout: ITreeCheckout,\n\tnodeKeyManager: NodeIdentifierManager,\n): Context {\n\treturn new Context(schema, checkout, nodeKeyManager);\n}\n"]}
@@ -62,6 +62,14 @@ export declare enum TreeStatus {
62
62
  Removed = 1,
63
63
  /**
64
64
  * Is removed and cannot be added back to the original document tree.
65
+ * @remarks
66
+ * Nodes can enter this state for multiple reasons:
67
+ * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.
68
+ * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.
69
+ * @privateRemarks
70
+ * There was planned work (AB#17948) to make the first reason a node could become "Deleted" impossible,
71
+ * at least as an opt in feature,
72
+ * by lifetime extending all nodes which are still possible to reach automatically.
65
73
  */
66
74
  Deleted = 2,
67
75
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"flexTreeTypes.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,UAAU,EACf,KAA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CAAC;CAC/D;AAMD;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,IAAI,SAAS,aAAa,IACxD,IAAI,SAAS,OAAO,UAAU,CAAC,QAAQ,GACpC,qBAAqB,GACrB,IAAI,SAAS,OAAO,UAAU,CAAC,QAAQ,GACtC,qBAAqB,GACrB,IAAI,SAAS,OAAO,UAAU,CAAC,QAAQ,GACtC,qBAAqB,GACrB,aAAa,CAAC;AAIpB;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,YAAY,CAAC"}
@@ -45,6 +45,14 @@ var TreeStatus;
45
45
  TreeStatus[TreeStatus["Removed"] = 1] = "Removed";
46
46
  /**
47
47
  * Is removed and cannot be added back to the original document tree.
48
+ * @remarks
49
+ * Nodes can enter this state for multiple reasons:
50
+ * - The node was removed and nothing (e.g. undo/redo history) kept it from being cleaned up.
51
+ * - The {@link TreeView} was disposed or had a schema change which made the tree incompatible.
52
+ * @privateRemarks
53
+ * There was planned work (AB#17948) to make the first reason a node could become "Deleted" impossible,
54
+ * at least as an opt in feature,
55
+ * by lifetime extending all nodes which are still possible to reach automatically.
48
56
  */
49
57
  TreeStatus[TreeStatus["Deleted"] = 2] = "Deleted";
50
58
  /**