@fluidframework/tree 2.42.0 → 2.43.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 (542) hide show
  1. package/CHANGELOG.md +189 -0
  2. package/api-report/tree.alpha.api.md +72 -25
  3. package/api-report/tree.beta.api.md +34 -0
  4. package/api-report/tree.legacy.alpha.api.md +1 -0
  5. package/api-report/tree.legacy.public.api.md +1 -0
  6. package/api-report/tree.public.api.md +1 -0
  7. package/dist/alpha.d.ts +12 -6
  8. package/dist/beta.d.ts +6 -1
  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 +5 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/schema-stored/formatV2.d.ts +80 -0
  14. package/dist/core/schema-stored/formatV2.d.ts.map +1 -0
  15. package/dist/core/schema-stored/formatV2.js +55 -0
  16. package/dist/core/schema-stored/formatV2.js.map +1 -0
  17. package/dist/core/schema-stored/index.d.ts +3 -1
  18. package/dist/core/schema-stored/index.d.ts.map +1 -1
  19. package/dist/core/schema-stored/index.js +5 -2
  20. package/dist/core/schema-stored/index.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +49 -17
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +65 -22
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
  26. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  27. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +13 -9
  28. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
  30. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +6 -6
  32. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  34. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
  36. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  37. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
  38. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  39. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
  40. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  41. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +24 -25
  42. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  43. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  44. package/dist/feature-libraries/flex-tree/index.d.ts +0 -1
  45. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  46. package/dist/feature-libraries/flex-tree/index.js +1 -7
  47. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
  49. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/lazyEntity.js +3 -0
  51. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  52. package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -2
  53. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  54. package/dist/feature-libraries/flex-tree/lazyField.js +2 -5
  55. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  56. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
  57. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  58. package/dist/feature-libraries/flex-tree/lazyNode.js +15 -7
  59. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -5
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  64. package/dist/feature-libraries/index.d.ts +2 -2
  65. package/dist/feature-libraries/index.d.ts.map +1 -1
  66. package/dist/feature-libraries/index.js +1 -2
  67. package/dist/feature-libraries/index.js.map +1 -1
  68. package/dist/feature-libraries/mapTreeCursor.d.ts +16 -2
  69. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  70. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  71. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  72. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
  73. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  74. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  75. package/dist/feature-libraries/object-forest/objectForest.js +2 -0
  76. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  77. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  78. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
  79. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  80. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
  81. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  82. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  83. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  84. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  85. package/dist/feature-libraries/schema-index/codec.js +59 -9
  86. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  87. package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
  88. package/dist/feature-libraries/schema-index/formatV2.d.ts +42 -0
  89. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
  90. package/dist/feature-libraries/schema-index/formatV2.js +26 -0
  91. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -0
  92. package/dist/feature-libraries/schema-index/index.d.ts +2 -1
  93. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  94. package/dist/feature-libraries/schema-index/index.js +4 -2
  95. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  96. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
  97. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  98. package/dist/feature-libraries/schema-index/schemaSummarizer.js +6 -6
  99. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  100. package/dist/index.d.ts +2 -2
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js.map +1 -1
  103. package/dist/packageVersion.d.ts +1 -1
  104. package/dist/packageVersion.js +1 -1
  105. package/dist/packageVersion.js.map +1 -1
  106. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  107. package/dist/shared-tree/schematizeTree.js +1 -0
  108. package/dist/shared-tree/schematizeTree.js.map +1 -1
  109. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  110. package/dist/shared-tree/schematizingTreeView.js +3 -3
  111. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  112. package/dist/shared-tree/sharedTree.d.ts +5 -1
  113. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  114. package/dist/shared-tree/sharedTree.js +34 -5
  115. package/dist/shared-tree/sharedTree.js.map +1 -1
  116. package/dist/shared-tree/treeAlpha.d.ts +39 -1
  117. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  118. package/dist/shared-tree/treeAlpha.js +117 -11
  119. package/dist/shared-tree/treeAlpha.js.map +1 -1
  120. package/dist/shared-tree-core/editManagerSummarizer.d.ts +8 -3
  121. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  122. package/dist/shared-tree-core/editManagerSummarizer.js +2 -5
  123. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  124. package/dist/shared-tree-core/sharedTreeCore.d.ts +18 -7
  125. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  126. package/dist/shared-tree-core/sharedTreeCore.js +15 -2
  127. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  128. package/dist/simple-tree/api/configuration.d.ts +15 -3
  129. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  130. package/dist/simple-tree/api/configuration.js +40 -22
  131. package/dist/simple-tree/api/configuration.js.map +1 -1
  132. package/dist/simple-tree/api/index.d.ts +1 -1
  133. package/dist/simple-tree/api/index.d.ts.map +1 -1
  134. package/dist/simple-tree/api/index.js +4 -4
  135. package/dist/simple-tree/api/index.js.map +1 -1
  136. package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
  137. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  138. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  139. package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
  140. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  141. package/dist/simple-tree/api/schemaFactory.d.ts +15 -11
  142. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  143. package/dist/simple-tree/api/schemaFactory.js +4 -0
  144. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  145. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
  146. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  147. package/dist/simple-tree/api/schemaFactoryAlpha.js +31 -4
  148. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  149. package/dist/simple-tree/api/storedSchema.js +2 -2
  150. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  151. package/dist/simple-tree/api/treeChangeEvents.d.ts +8 -3
  152. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  153. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  154. package/dist/simple-tree/api/treeNodeApi.d.ts +3 -0
  155. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  156. package/dist/simple-tree/api/treeNodeApi.js +1 -1
  157. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  158. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  159. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
  160. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  161. package/dist/simple-tree/core/context.d.ts +3 -3
  162. package/dist/simple-tree/core/context.d.ts.map +1 -1
  163. package/dist/simple-tree/core/context.js.map +1 -1
  164. package/dist/simple-tree/core/getOrCreateNode.d.ts +9 -0
  165. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  166. package/dist/simple-tree/core/getOrCreateNode.js +12 -1
  167. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  168. package/dist/simple-tree/core/index.d.ts +2 -2
  169. package/dist/simple-tree/core/index.d.ts.map +1 -1
  170. package/dist/simple-tree/core/index.js +3 -1
  171. package/dist/simple-tree/core/index.js.map +1 -1
  172. package/dist/simple-tree/core/treeNodeKernel.js +2 -2
  173. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  174. package/dist/simple-tree/core/treeNodeSchema.d.ts +68 -1
  175. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  176. package/dist/simple-tree/core/treeNodeSchema.js +24 -1
  177. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  178. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
  179. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  180. package/dist/simple-tree/core/unhydratedFlexTree.js +12 -31
  181. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  182. package/dist/simple-tree/core/walkSchema.d.ts +3 -3
  183. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  184. package/dist/simple-tree/core/walkSchema.js +9 -5
  185. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  186. package/dist/simple-tree/createContext.js +1 -1
  187. package/dist/simple-tree/createContext.js.map +1 -1
  188. package/dist/simple-tree/getTreeNodeForField.d.ts +1 -1
  189. package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  190. package/dist/simple-tree/getTreeNodeForField.js +3 -3
  191. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  192. package/dist/simple-tree/index.d.ts +6 -6
  193. package/dist/simple-tree/index.d.ts.map +1 -1
  194. package/dist/simple-tree/index.js +8 -5
  195. package/dist/simple-tree/index.js.map +1 -1
  196. package/dist/simple-tree/leafNodeSchema.d.ts +4 -1
  197. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  198. package/dist/simple-tree/leafNodeSchema.js +1 -0
  199. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  200. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
  201. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  202. package/dist/simple-tree/node-kinds/array/arrayNode.js +21 -16
  203. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  204. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
  205. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  206. package/dist/simple-tree/node-kinds/map/mapNode.js +11 -5
  207. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  208. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
  209. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  210. package/dist/simple-tree/node-kinds/object/objectNode.js +12 -7
  211. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  212. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  213. package/dist/simple-tree/prepareForInsertion.js +5 -1
  214. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  215. package/dist/simple-tree/schemaTypes.d.ts +63 -30
  216. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  217. package/dist/simple-tree/schemaTypes.js +73 -40
  218. package/dist/simple-tree/schemaTypes.js.map +1 -1
  219. package/dist/simple-tree/simpleSchema.d.ts +22 -4
  220. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  221. package/dist/simple-tree/simpleSchema.js.map +1 -1
  222. package/dist/simple-tree/toStoredSchema.d.ts +4 -0
  223. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  224. package/dist/simple-tree/toStoredSchema.js +15 -4
  225. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  226. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  227. package/dist/simple-tree/treeNodeValid.js +1 -2
  228. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  229. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  230. package/dist/simple-tree/walkFieldSchema.js +1 -1
  231. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  232. package/dist/tableSchema.d.ts +1 -1
  233. package/dist/util/typeUtils.d.ts +2 -2
  234. package/dist/util/typeUtils.js.map +1 -1
  235. package/dist/util/utils.d.ts +2 -0
  236. package/dist/util/utils.d.ts.map +1 -1
  237. package/dist/util/utils.js.map +1 -1
  238. package/lib/alpha.d.ts +12 -6
  239. package/lib/beta.d.ts +6 -1
  240. package/lib/core/index.d.ts +1 -1
  241. package/lib/core/index.d.ts.map +1 -1
  242. package/lib/core/index.js +1 -1
  243. package/lib/core/index.js.map +1 -1
  244. package/lib/core/schema-stored/formatV2.d.ts +80 -0
  245. package/lib/core/schema-stored/formatV2.d.ts.map +1 -0
  246. package/lib/core/schema-stored/formatV2.js +52 -0
  247. package/lib/core/schema-stored/formatV2.js.map +1 -0
  248. package/lib/core/schema-stored/index.d.ts +3 -1
  249. package/lib/core/schema-stored/index.d.ts.map +1 -1
  250. package/lib/core/schema-stored/index.js +3 -1
  251. package/lib/core/schema-stored/index.js.map +1 -1
  252. package/lib/core/schema-stored/schema.d.ts +49 -17
  253. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  254. package/lib/core/schema-stored/schema.js +63 -21
  255. package/lib/core/schema-stored/schema.js.map +1 -1
  256. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +9 -7
  257. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  258. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +11 -7
  259. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  260. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +3 -3
  261. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  262. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +7 -7
  263. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  264. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +1 -1
  265. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  266. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +3 -3
  267. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  268. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +8 -3
  269. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  270. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -5
  271. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  272. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +24 -25
  273. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  274. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  275. package/lib/feature-libraries/flex-tree/index.d.ts +0 -1
  276. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  277. package/lib/feature-libraries/flex-tree/index.js +0 -1
  278. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  279. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -2
  280. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  281. package/lib/feature-libraries/flex-tree/lazyEntity.js +3 -0
  282. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  283. package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -2
  284. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  285. package/lib/feature-libraries/flex-tree/lazyField.js +3 -6
  286. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  287. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -5
  288. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  289. package/lib/feature-libraries/flex-tree/lazyNode.js +15 -7
  290. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  291. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +8 -3
  292. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  293. package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -5
  294. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  295. package/lib/feature-libraries/index.d.ts +2 -2
  296. package/lib/feature-libraries/index.d.ts.map +1 -1
  297. package/lib/feature-libraries/index.js +1 -1
  298. package/lib/feature-libraries/index.js.map +1 -1
  299. package/lib/feature-libraries/mapTreeCursor.d.ts +16 -2
  300. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  301. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  302. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +1 -1
  303. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +2 -0
  304. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +1 -1
  305. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  306. package/lib/feature-libraries/object-forest/objectForest.js +2 -0
  307. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  308. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  309. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -4
  310. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  311. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -36
  312. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  313. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  314. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  315. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  316. package/lib/feature-libraries/schema-index/codec.js +60 -10
  317. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  318. package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
  319. package/lib/feature-libraries/schema-index/formatV2.d.ts +42 -0
  320. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -0
  321. package/lib/feature-libraries/schema-index/formatV2.js +23 -0
  322. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -0
  323. package/lib/feature-libraries/schema-index/index.d.ts +2 -1
  324. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  325. package/lib/feature-libraries/schema-index/index.js +2 -1
  326. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  327. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +7 -2
  328. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  329. package/lib/feature-libraries/schema-index/schemaSummarizer.js +6 -6
  330. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  331. package/lib/index.d.ts +2 -2
  332. package/lib/index.d.ts.map +1 -1
  333. package/lib/index.js.map +1 -1
  334. package/lib/packageVersion.d.ts +1 -1
  335. package/lib/packageVersion.js +1 -1
  336. package/lib/packageVersion.js.map +1 -1
  337. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  338. package/lib/shared-tree/schematizeTree.js +1 -0
  339. package/lib/shared-tree/schematizeTree.js.map +1 -1
  340. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  341. package/lib/shared-tree/schematizingTreeView.js +4 -4
  342. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  343. package/lib/shared-tree/sharedTree.d.ts +5 -1
  344. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  345. package/lib/shared-tree/sharedTree.js +34 -5
  346. package/lib/shared-tree/sharedTree.js.map +1 -1
  347. package/lib/shared-tree/treeAlpha.d.ts +39 -1
  348. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  349. package/lib/shared-tree/treeAlpha.js +111 -5
  350. package/lib/shared-tree/treeAlpha.js.map +1 -1
  351. package/lib/shared-tree-core/editManagerSummarizer.d.ts +8 -3
  352. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  353. package/lib/shared-tree-core/editManagerSummarizer.js +2 -5
  354. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  355. package/lib/shared-tree-core/sharedTreeCore.d.ts +18 -7
  356. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  357. package/lib/shared-tree-core/sharedTreeCore.js +15 -2
  358. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  359. package/lib/simple-tree/api/configuration.d.ts +15 -3
  360. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  361. package/lib/simple-tree/api/configuration.js +42 -24
  362. package/lib/simple-tree/api/configuration.js.map +1 -1
  363. package/lib/simple-tree/api/index.d.ts +1 -1
  364. package/lib/simple-tree/api/index.d.ts.map +1 -1
  365. package/lib/simple-tree/api/index.js +1 -1
  366. package/lib/simple-tree/api/index.js.map +1 -1
  367. package/lib/simple-tree/api/schemaCompatibilityTester.js +1 -1
  368. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  369. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  370. package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
  371. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  372. package/lib/simple-tree/api/schemaFactory.d.ts +15 -11
  373. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  374. package/lib/simple-tree/api/schemaFactory.js +4 -0
  375. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  376. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +41 -11
  377. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  378. package/lib/simple-tree/api/schemaFactoryAlpha.js +31 -4
  379. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  380. package/lib/simple-tree/api/storedSchema.js +2 -2
  381. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  382. package/lib/simple-tree/api/treeChangeEvents.d.ts +8 -3
  383. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  384. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  385. package/lib/simple-tree/api/treeNodeApi.d.ts +3 -0
  386. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  387. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  388. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  389. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  390. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +5 -0
  391. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  392. package/lib/simple-tree/core/context.d.ts +3 -3
  393. package/lib/simple-tree/core/context.d.ts.map +1 -1
  394. package/lib/simple-tree/core/context.js.map +1 -1
  395. package/lib/simple-tree/core/getOrCreateNode.d.ts +9 -0
  396. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  397. package/lib/simple-tree/core/getOrCreateNode.js +10 -0
  398. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  399. package/lib/simple-tree/core/index.d.ts +2 -2
  400. package/lib/simple-tree/core/index.d.ts.map +1 -1
  401. package/lib/simple-tree/core/index.js +2 -2
  402. package/lib/simple-tree/core/index.js.map +1 -1
  403. package/lib/simple-tree/core/treeNodeKernel.js +2 -2
  404. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  405. package/lib/simple-tree/core/treeNodeSchema.d.ts +68 -1
  406. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  407. package/lib/simple-tree/core/treeNodeSchema.js +21 -0
  408. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  409. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +5 -9
  410. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  411. package/lib/simple-tree/core/unhydratedFlexTree.js +15 -34
  412. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  413. package/lib/simple-tree/core/walkSchema.d.ts +3 -3
  414. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  415. package/lib/simple-tree/core/walkSchema.js +9 -5
  416. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  417. package/lib/simple-tree/createContext.js +1 -1
  418. package/lib/simple-tree/createContext.js.map +1 -1
  419. package/lib/simple-tree/getTreeNodeForField.d.ts +1 -1
  420. package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
  421. package/lib/simple-tree/getTreeNodeForField.js +1 -1
  422. package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
  423. package/lib/simple-tree/index.d.ts +6 -6
  424. package/lib/simple-tree/index.d.ts.map +1 -1
  425. package/lib/simple-tree/index.js +4 -4
  426. package/lib/simple-tree/index.js.map +1 -1
  427. package/lib/simple-tree/leafNodeSchema.d.ts +4 -1
  428. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  429. package/lib/simple-tree/leafNodeSchema.js +2 -1
  430. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  431. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -1
  432. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  433. package/lib/simple-tree/node-kinds/array/arrayNode.js +13 -8
  434. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  435. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +3 -2
  436. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  437. package/lib/simple-tree/node-kinds/map/mapNode.js +14 -8
  438. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  439. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -2
  440. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  441. package/lib/simple-tree/node-kinds/object/objectNode.js +14 -9
  442. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  443. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  444. package/lib/simple-tree/prepareForInsertion.js +5 -1
  445. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  446. package/lib/simple-tree/schemaTypes.d.ts +63 -30
  447. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  448. package/lib/simple-tree/schemaTypes.js +70 -36
  449. package/lib/simple-tree/schemaTypes.js.map +1 -1
  450. package/lib/simple-tree/simpleSchema.d.ts +22 -4
  451. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  452. package/lib/simple-tree/simpleSchema.js.map +1 -1
  453. package/lib/simple-tree/toStoredSchema.d.ts +4 -0
  454. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  455. package/lib/simple-tree/toStoredSchema.js +15 -4
  456. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  457. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  458. package/lib/simple-tree/treeNodeValid.js +1 -2
  459. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  460. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  461. package/lib/simple-tree/walkFieldSchema.js +1 -1
  462. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  463. package/lib/tableSchema.d.ts +1 -1
  464. package/lib/util/typeUtils.d.ts +2 -2
  465. package/lib/util/typeUtils.js.map +1 -1
  466. package/lib/util/utils.d.ts +2 -0
  467. package/lib/util/utils.d.ts.map +1 -1
  468. package/lib/util/utils.js.map +1 -1
  469. package/package.json +23 -23
  470. package/src/core/index.ts +3 -1
  471. package/src/core/schema-stored/formatV2.ts +78 -0
  472. package/src/core/schema-stored/index.ts +4 -1
  473. package/src/core/schema-stored/schema.ts +123 -33
  474. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +16 -11
  475. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -7
  476. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +4 -4
  477. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +9 -16
  478. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +33 -30
  479. package/src/feature-libraries/flex-tree/index.ts +0 -8
  480. package/src/feature-libraries/flex-tree/lazyEntity.ts +5 -1
  481. package/src/feature-libraries/flex-tree/lazyField.ts +5 -8
  482. package/src/feature-libraries/flex-tree/lazyNode.ts +17 -8
  483. package/src/feature-libraries/forest-summary/forestSummarizer.ts +9 -16
  484. package/src/feature-libraries/index.ts +1 -1
  485. package/src/feature-libraries/mapTreeCursor.ts +17 -8
  486. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +2 -0
  487. package/src/feature-libraries/object-forest/objectForest.ts +3 -0
  488. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +11 -6
  489. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -3
  490. package/src/feature-libraries/schema-index/codec.ts +73 -14
  491. package/src/feature-libraries/schema-index/formatV2.ts +30 -0
  492. package/src/feature-libraries/schema-index/index.ts +2 -1
  493. package/src/feature-libraries/schema-index/schemaSummarizer.ts +11 -18
  494. package/src/index.ts +6 -0
  495. package/src/packageVersion.ts +1 -1
  496. package/src/shared-tree/schematizeTree.ts +1 -0
  497. package/src/shared-tree/schematizingTreeView.ts +8 -5
  498. package/src/shared-tree/sharedTree.ts +42 -12
  499. package/src/shared-tree/treeAlpha.ts +196 -6
  500. package/src/shared-tree-core/editManagerSummarizer.ts +9 -16
  501. package/src/shared-tree-core/sharedTreeCore.ts +33 -24
  502. package/src/simple-tree/api/configuration.ts +59 -27
  503. package/src/simple-tree/api/index.ts +3 -3
  504. package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
  505. package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
  506. package/src/simple-tree/api/schemaFactory.ts +16 -11
  507. package/src/simple-tree/api/schemaFactoryAlpha.ts +53 -8
  508. package/src/simple-tree/api/storedSchema.ts +4 -4
  509. package/src/simple-tree/api/treeChangeEvents.ts +8 -3
  510. package/src/simple-tree/api/treeNodeApi.ts +5 -2
  511. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +5 -0
  512. package/src/simple-tree/core/context.ts +3 -3
  513. package/src/simple-tree/core/getOrCreateNode.ts +14 -0
  514. package/src/simple-tree/core/index.ts +7 -1
  515. package/src/simple-tree/core/treeNodeKernel.ts +2 -2
  516. package/src/simple-tree/core/treeNodeSchema.ts +113 -1
  517. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -44
  518. package/src/simple-tree/core/walkSchema.ts +16 -7
  519. package/src/simple-tree/createContext.ts +1 -1
  520. package/src/simple-tree/getTreeNodeForField.ts +3 -1
  521. package/src/simple-tree/index.ts +12 -5
  522. package/src/simple-tree/leafNodeSchema.ts +9 -1
  523. package/src/simple-tree/node-kinds/array/arrayNode.ts +20 -9
  524. package/src/simple-tree/node-kinds/map/mapNode.ts +21 -6
  525. package/src/simple-tree/node-kinds/object/objectNode.ts +29 -12
  526. package/src/simple-tree/prepareForInsertion.ts +5 -1
  527. package/src/simple-tree/schemaTypes.ts +151 -71
  528. package/src/simple-tree/simpleSchema.ts +27 -5
  529. package/src/simple-tree/toStoredSchema.ts +17 -4
  530. package/src/simple-tree/treeNodeValid.ts +1 -1
  531. package/src/simple-tree/walkFieldSchema.ts +5 -1
  532. package/src/util/typeUtils.ts +2 -2
  533. package/src/util/utils.ts +2 -0
  534. package/dist/feature-libraries/flex-tree/navigation.d.ts +0 -46
  535. package/dist/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
  536. package/dist/feature-libraries/flex-tree/navigation.js +0 -104
  537. package/dist/feature-libraries/flex-tree/navigation.js.map +0 -1
  538. package/lib/feature-libraries/flex-tree/navigation.d.ts +0 -46
  539. package/lib/feature-libraries/flex-tree/navigation.d.ts.map +0 -1
  540. package/lib/feature-libraries/flex-tree/navigation.js +0 -97
  541. package/lib/feature-libraries/flex-tree/navigation.js.map +0 -1
  542. package/src/feature-libraries/flex-tree/navigation.ts +0 -121
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2TH;;;;;GAKG;AACH,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAG,CAAA;IACH;;OAEG;IACH,yCAAK,CAAA;IACL;;;;OAIG;IACH,2CAAM,CAAA;IACN;;OAEG;IACH,uCAAI,CAAA;AACL,CAAC,EAnBW,QAAQ,wBAAR,QAAQ,QAmBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport type { SimpleNodeSchemaBase } from \"../simpleSchema.js\";\n\nimport type { TreeNode } from \"./treeNode.js\";\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a {@link TreeNode} or {@link TreeLeafValue}.\n *\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * Use {@link SchemaFactory} to define schema.\n * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.\n * @privateRemarks\n * TODO:\n * The long lists of type parameters here are awkward to deal with.\n * Switching to (or adding an option to use)\n * an interface based pattern with unordered named parameters for types like this would be a good idea.\n * The related `@system` types should be simple to port to the new pattern, but stable public one like this will need to support both:\n * the new one could either be added as a system type, or be recommended to replace this one (deprecating it).\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> =\n\t| (TNode extends TreeNode\n\t\t\t? TreeNodeSchemaClass<\n\t\t\t\t\tName,\n\t\t\t\t\tKind,\n\t\t\t\t\tTNode,\n\t\t\t\t\tTBuild,\n\t\t\t\t\tImplicitlyConstructable,\n\t\t\t\t\tInfo,\n\t\t\t\t\tnever,\n\t\t\t\t\tTCustomMetadata\n\t\t\t\t>\n\t\t\t: never)\n\t| TreeNodeSchemaNonClass<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tTNode,\n\t\t\tTBuild,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t >;\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport type TreeNodeSchemaNonClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data?: TInsertable | TConstructorExtra): TNode;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data: TInsertable | TConstructorExtra): TNode;\n\t\t\t});\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n *\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport type TreeNodeSchemaClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t});\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode,\n\tTInsertable,\n\tImplicitlyConstructable,\n\tInfo,\n\tTConstructorExtra,\n\tTCustomMetadata\n> &\n\tTreeNodeSchemaNonClass<\n\t\tName,\n\t\tKind,\n\t\tTNode,\n\t\tTInsertable,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTConstructorExtra,\n\t\tTCustomMetadata\n\t>;\n\n/**\n * Data common to all tree node schema.\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n\tout TInsertable = never,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<Kind, TCustomMetadata> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n\n\t/**\n\t * Constructs an instance of this node type.\n\t * @remarks\n\t * Due to TypeScript limitations, the return type of this method can not be very specific.\n\t * For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.\n\t * For {@link TreeNodeSchemaNonClass} use `create`.\n\t *\n\t * @privateRemarks\n\t * This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.\n\t * This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,\n\t * as long as doing so only adds additional supported cases.\n\t *\n\t * This cannot be required to return `TNode`:\n\t * doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.\n\t * @sealed @system\n\t */\n\tcreateFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf,\n}\n"]}
1
+ {"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAiG7D;;GAEG;AACH,SAAgB,uBAAuB,CACtC,YAA2C;IAE3C,OAAO;IACN,qJAAqJ;IACrJ,OAAO,YAAY,KAAK,QAAQ,IAAI,UAAU,IAAI,YAAY,IAAI,OAAO,IAAI,YAAY,CACzF,CAAC;AACH,CAAC;AAPD,0DAOC;AAySD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAC1C,MAAqD;IAErD,IAAA,iBAAM,EACL,4BAA4B,IAAI,MAAM,EACtC,KAAK,CAAC,6FAA6F,CACnG,CAAC;IACF,IAAA,iBAAM,EACL,KAAK,CAAC,OAAO,CAAE,MAAoC,CAAC,0BAA0B,CAAC,EAC/E,KAAK,CAAC,6FAA6F,CACnG,CAAC;IACF,OAAO,MAAmC,CAAC;AAC5C,CAAC;AAZD,kEAYC;AAED;;;;;GAKG;AACH,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAG,CAAA;IACH;;OAEG;IACH,yCAAK,CAAA;IACL;;;;OAIG;IACH,2CAAM,CAAA;IACN;;OAEG;IACH,uCAAI,CAAA;AACL,CAAC,EAnBW,QAAQ,wBAAR,QAAQ,QAmBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { LazyItem } from \"../flexList.js\";\nimport type {\n\tAllowedTypeMetadata,\n\tAllowedTypesMetadata,\n\tAnnotatedAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tTreeLeafValue,\n} from \"../schemaTypes.js\";\nimport type { SimpleNodeSchemaBase } from \"../simpleSchema.js\";\n\nimport type { TreeNode } from \"./treeNode.js\";\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a {@link TreeNode} or {@link TreeLeafValue}.\n *\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * Use {@link SchemaFactory} to define schema.\n * Use `Tree.schema(value)` to lookup the schema for a {@link TreeNode} or {@link TreeLeafValue}.\n * @privateRemarks\n * TODO:\n * The long lists of type parameters here are awkward to deal with.\n * Switching to (or adding an option to use)\n * an interface based pattern with unordered named parameters for types like this would be a good idea.\n * The related `@system` types should be simple to port to the new pattern, but stable public one like this will need to support both:\n * the new one could either be added as a system type, or be recommended to replace this one (deprecating it).\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> =\n\t| (TNode extends TreeNode\n\t\t\t? TreeNodeSchemaClass<\n\t\t\t\t\tName,\n\t\t\t\t\tKind,\n\t\t\t\t\tTNode,\n\t\t\t\t\tTBuild,\n\t\t\t\t\tImplicitlyConstructable,\n\t\t\t\t\tInfo,\n\t\t\t\t\tnever,\n\t\t\t\t\tTCustomMetadata\n\t\t\t\t>\n\t\t\t: never)\n\t| TreeNodeSchemaNonClass<\n\t\t\tName,\n\t\t\tKind,\n\t\t\tTNode,\n\t\t\tTBuild,\n\t\t\tImplicitlyConstructable,\n\t\t\tInfo,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t >;\n\n/**\n * Stores annotations for an individual allowed type.\n * @alpha\n */\nexport interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {\n\t/**\n\t * Annotations for the allowed type.\n\t */\n\treadonly metadata: AllowedTypeMetadata;\n\t/**\n\t * The allowed type the annotations apply to in a particular schema.\n\t */\n\treadonly type: T;\n}\n\n/**\n * Stores annotations for a set of evaluated annotated allowed types.\n * @alpha\n */\nexport interface NormalizedAnnotatedAllowedTypes {\n\t/**\n\t * Annotations that apply to a set of allowed types.\n\t */\n\treadonly metadata: AllowedTypesMetadata;\n\t/**\n\t * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.\n\t */\n\treadonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];\n}\n\n/**\n * Checks if the input is an {@link AnnotatedAllowedTypes}.\n */\nexport function isAnnotatedAllowedTypes(\n\tallowedTypes: ImplicitAnnotatedAllowedTypes,\n): allowedTypes is AnnotatedAllowedTypes {\n\treturn (\n\t\t// Class based schema, and lazy schema references report type \"function\": filtering them out with typeof makes narrowing based on members mostly safe\n\t\ttypeof allowedTypes === \"object\" && \"metadata\" in allowedTypes && \"types\" in allowedTypes\n\t);\n}\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport type TreeNodeSchemaNonClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data?: TInsertable | TConstructorExtra): TNode;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @privateRemarks\n\t\t\t\t * Also allows InternalTreeNode.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\tcreate(data: TInsertable | TConstructorExtra): TNode;\n\t\t\t});\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n *\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport type TreeNodeSchemaClass<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaCore<\n\tName,\n\tKind,\n\tImplicitlyConstructable,\n\tInfo,\n\tTInsertable,\n\tTCustomMetadata\n> &\n\t(undefined extends TConstructorExtra\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data?: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t}\n\t\t: {\n\t\t\t\t/**\n\t\t\t\t * Constructs an {@link Unhydrated} node with this schema.\n\t\t\t\t * @remarks\n\t\t\t\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t\t\t\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t\t\t\t * @sealed\n\t\t\t\t */\n\t\t\t\t// The approach suggested by the linter here is more concise, but ir break intellisense for the constructor.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t\t\t\tnew (data: TInsertable | InternalTreeNode | TConstructorExtra): Unhydrated<TNode>;\n\t\t\t});\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode extends TreeNode = TreeNode,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTConstructorExtra = never,\n\tTCustomMetadata = unknown,\n> = TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode,\n\tTInsertable,\n\tImplicitlyConstructable,\n\tInfo,\n\tTConstructorExtra,\n\tTCustomMetadata\n> &\n\tTreeNodeSchemaNonClass<\n\t\tName,\n\t\tKind,\n\t\tTNode,\n\t\tTInsertable,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTConstructorExtra,\n\t\tTCustomMetadata\n\t>;\n\n/**\n * Data common to all tree node schema.\n *\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n *\n * @privateRemarks\n * All implementations must implement {@link TreeNodeSchemaCorePrivate} as well.\n *\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n\tout TInsertable = never,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<Kind, TCustomMetadata> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n\n\t/**\n\t * Constructs an instance of this node type.\n\t * @remarks\n\t * Due to TypeScript limitations, the return type of this method can not be very specific.\n\t * For {@link TreeNodeSchemaClass} prefer using the constructor directly for better typing.\n\t * For {@link TreeNodeSchemaNonClass} use `create`.\n\t *\n\t * @privateRemarks\n\t * This method signature provides a way to infer `TInsertable` without relying on the constructor, and to construct nodes from schema of unknown kind.\n\t * This makes customizations of the constructor not impact the typing of insertable content, allowing customization of the constructor,\n\t * as long as doing so only adds additional supported cases.\n\t *\n\t * This cannot be required to return `TNode`:\n\t * doing so breaks sub-classing of schema since they don't overload this method with a more specific return type.\n\t * @sealed @system\n\t */\n\tcreateFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;\n}\n\n/**\n * {@link TreeNodeSchemaCore} extended with some non-exported APIs.\n */\nexport interface TreeNodeSchemaCorePrivate<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n\tTCustomMetadata = unknown,\n> extends TreeNodeSchemaCore<\n\t\tName,\n\t\tKind,\n\t\tImplicitlyConstructable,\n\t\tInfo,\n\t\tTInsertable,\n\t\tTCustomMetadata\n\t> {\n\t/**\n\t * All possible annotated allowed types that a field under a node with this schema could have.\n\t * @remarks\n\t * In this case \"field\" includes anything that is a field in the internal (flex-tree) abstraction layer.\n\t * This includes the content field for arrays, and all the fields for map nodes.\n\t * If this node does not have fields (and thus is a leaf), the array will be empty.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this array.\n\t *\n\t * @privateRemarks\n\t * If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.\n\t * @system\n\t */\n\treadonly childAnnotatedAllowedTypes: readonly NormalizedAnnotatedAllowedTypes[];\n}\n\n/**\n * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} if it is one.\n *\n * @remarks\n * This function should only be used internally. The result should not be exposed publicly\n * in any exported types or API return values.\n */\nexport function asTreeNodeSchemaCorePrivate(\n\tschema: TreeNodeSchemaCore<string, NodeKind, boolean>,\n): TreeNodeSchemaCorePrivate {\n\tassert(\n\t\t\"childAnnotatedAllowedTypes\" in schema,\n\t\t0xbc9 /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */,\n\t);\n\tassert(\n\t\tArray.isArray((schema as TreeNodeSchemaCorePrivate).childAnnotatedAllowedTypes),\n\t\t0xbca /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */,\n\t);\n\treturn schema as TreeNodeSchemaCorePrivate;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf,\n}\n"]}
@@ -4,16 +4,13 @@
4
4
  */
5
5
  import type { Listenable } from "@fluidframework/core-interfaces";
6
6
  import { type AnchorEvents, type FieldKey, type FieldKindIdentifier, type ITreeCursorSynchronous, type NodeData, type NormalizedFieldUpPath, type SchemaPolicy, type TreeNodeSchemaIdentifier, type TreeNodeStoredSchema, type TreeStoredSchema, type TreeValue, type Value } from "../../core/index.js";
7
- import { type FlexTreeContext, FlexTreeEntityKind, type FlexTreeField, type FlexTreeNode, type FlexTreeOptionalField, type FlexTreeSequenceField, type FlexTreeTypedField, type FlexTreeUnknownUnboxed, flexTreeMarker, type FlexTreeHydratedContext, type FlexFieldKind, type FlexibleNodeContent, type FlexTreeHydratedContextMinimal, type FlexibleFieldContent, type MapTreeFieldViewGeneric, type MapTreeNodeViewGeneric, type HydratedFlexTreeNode } from "../../feature-libraries/index.js";
7
+ import { type FlexTreeContext, FlexTreeEntityKind, type FlexTreeField, type FlexTreeNode, type FlexTreeOptionalField, type FlexTreeSequenceField, type FlexTreeTypedField, type FlexTreeUnknownUnboxed, flexTreeMarker, type FlexTreeHydratedContext, type FlexFieldKind, type FlexibleNodeContent, type FlexTreeHydratedContextMinimal, type FlexibleFieldContent, type MapTreeFieldViewGeneric, type MapTreeNodeViewGeneric, type HydratedFlexTreeNode, type MinimalFieldMap } from "../../feature-libraries/index.js";
8
8
  import type { Context } from "./context.js";
9
9
  import type { ContextualFieldProvider } from "../schemaTypes.js";
10
10
  import type { TreeNode } from "./treeNode.js";
11
11
  type UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, "childrenChangedAfterBatch">;
12
12
  /** A node's parent field and its index in that field */
13
- interface LocationInField {
14
- readonly parent: FlexTreeField;
15
- readonly index: number;
16
- }
13
+ type LocationInField = FlexTreeNode["parentField"];
17
14
  /**
18
15
  * The {@link Unhydrated} implementation of {@link FlexTreeNode}.
19
16
  */
@@ -79,7 +76,8 @@ export declare class UnhydratedFlexTreeNode implements FlexTreeNode, MapTreeNode
79
76
  * Due to having to detect if a field is empty, this forces the evaluation of any pending defaults in the fields.
80
77
  * Use {@link allFieldsLazy} to avoid evaluating pending defaults.
81
78
  */
82
- readonly fields: Pick<Map<FieldKey, UnhydratedFlexTreeField>, typeof Symbol.iterator | "get">;
79
+ readonly fields: MinimalFieldMap<UnhydratedFlexTreeField>;
80
+ [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeField>;
83
81
  /**
84
82
  * Gets all fields, without filtering out empty ones.
85
83
  * @remarks
@@ -87,7 +85,6 @@ export declare class UnhydratedFlexTreeNode implements FlexTreeNode, MapTreeNode
87
85
  */
88
86
  get allFieldsLazy(): ReadonlyMap<FieldKey, UnhydratedFlexTreeField>;
89
87
  get type(): TreeNodeSchemaIdentifier;
90
- get schema(): TreeNodeSchemaIdentifier;
91
88
  private getOrCreateField;
92
89
  /**
93
90
  * Set this node's parentage (see {@link FlexTreeNode.parentField}).
@@ -106,7 +103,6 @@ export declare class UnhydratedFlexTreeNode implements FlexTreeNode, MapTreeNode
106
103
  borrowCursor(): ITreeCursorSynchronous;
107
104
  tryGetField(key: FieldKey): UnhydratedFlexTreeField | undefined;
108
105
  getBoxed(key: string): UnhydratedFlexTreeField;
109
- boxedIterator(): IterableIterator<FlexTreeField>;
110
106
  keys(): IterableIterator<FieldKey>;
111
107
  get value(): Value;
112
108
  emitChangedEvent(key: FieldKey): void;
@@ -152,6 +148,7 @@ export declare class UnhydratedFlexTreeField implements FlexTreeField, MapTreeFi
152
148
  * Note that any fields using a {@link ConstantFieldProvider} should be evaluated before constructing the UnhydratedFlexTreeField.
153
149
  */
154
150
  lazyChildren: UnhydratedFlexTreeNode[] | ContextualFieldProvider);
151
+ borrowCursor(): ITreeCursorSynchronous;
155
152
  private getPendingDefault;
156
153
  /**
157
154
  * Populate pending default (if present) using the provided context.
@@ -167,7 +164,6 @@ export declare class UnhydratedFlexTreeField implements FlexTreeField, MapTreeFi
167
164
  get children(): UnhydratedFlexTreeNode[];
168
165
  get length(): number;
169
166
  is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2>;
170
- boxedIterator(): IterableIterator<UnhydratedFlexTreeNode>;
171
167
  boxedAt(index: number): FlexTreeNode | undefined;
172
168
  [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeNode>;
173
169
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAIlE,OAAO,EACN,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,eAAe,EACpB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAE1B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAC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uBACR,YAAW,qBAAqB;IAEhC,SAAgB,MAAM;qEACQ,IAAI;kDAgBT,sBAAsB,EAAE;MAWE;IAE5C,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAOrD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;CAGnF;AAID,gDAAgD;AAChD,wBAAgB,WAAW,CAC1B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,GAC5D,uBAAuB,CAezB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAM7D"}
@@ -70,6 +70,9 @@ class UnhydratedFlexTreeNode {
70
70
  field.parent = this;
71
71
  }
72
72
  }
73
+ [(_a = index_js_2.flexTreeMarker, Symbol.iterator)]() {
74
+ return (0, index_js_3.mapIterable)(this.fields, ([, field]) => field)[Symbol.iterator]();
75
+ }
73
76
  /**
74
77
  * Gets all fields, without filtering out empty ones.
75
78
  * @remarks
@@ -81,9 +84,6 @@ class UnhydratedFlexTreeNode {
81
84
  get type() {
82
85
  return this.data.type;
83
86
  }
84
- get schema() {
85
- return this.data.type;
86
- }
87
87
  getOrCreateField(key) {
88
88
  return (0, index_js_3.getOrCreate)(this.fieldsAll, key, () => {
89
89
  const stored = this.storedSchema.getFieldSchema(key).kind;
@@ -135,9 +135,6 @@ class UnhydratedFlexTreeNode {
135
135
  const fieldKey = (0, index_js_3.brand)(key);
136
136
  return this.getOrCreateField(fieldKey);
137
137
  }
138
- boxedIterator() {
139
- return Array.from(this.fields, ([key, field]) => field)[Symbol.iterator]();
140
- }
141
138
  keys() {
142
139
  return Array.from(this.fields, ([key]) => key)[Symbol.iterator]();
143
140
  }
@@ -149,7 +146,6 @@ class UnhydratedFlexTreeNode {
149
146
  }
150
147
  }
151
148
  exports.UnhydratedFlexTreeNode = UnhydratedFlexTreeNode;
152
- _a = index_js_2.flexTreeMarker;
153
149
  /**
154
150
  * Implementation of `FlexTreeContext`.
155
151
  *
@@ -179,31 +175,16 @@ exports.UnhydratedContext = UnhydratedContext;
179
175
  * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.
180
176
  * It has the "empty" schema and it will always contain zero children if queried.
181
177
  * Any nodes with this location will have a dummy parent index of `-1`.
178
+ *
179
+ * TODO: make this make sense.
182
180
  */
183
181
  const unparentedLocation = {
184
182
  parent: {
185
- [index_js_2.flexTreeMarker]: index_js_2.FlexTreeEntityKind.Field,
186
- length: 0,
187
- key: index_js_1.EmptyKey,
183
+ key: index_js_1.dummyRoot,
188
184
  parent: undefined,
189
- is(kind) {
190
- return this.schema === kind.identifier;
191
- },
192
- boxedIterator() {
193
- return [].values();
194
- },
195
- boxedAt(index) {
196
- return undefined;
197
- },
198
- schema: (0, index_js_3.brand)(index_js_1.forbiddenFieldKindIdentifier),
199
- get context() {
200
- return (0, internal_1.fail)(0xb48 /* unsupported */);
201
- },
202
- getFieldPath() {
203
- (0, internal_1.fail)(0xb49 /* unsupported */);
204
- },
185
+ schema: (0, index_js_3.brand)(index_js_2.FieldKinds.optional.identifier),
205
186
  },
206
- index: -1,
187
+ index: 0,
207
188
  };
208
189
  /**
209
190
  * The {@link Unhydrated} implementation of {@link FlexTreeField}.
@@ -232,6 +213,9 @@ class UnhydratedFlexTreeField {
232
213
  }
233
214
  }
234
215
  }
216
+ borrowCursor() {
217
+ return (0, index_js_2.cursorForMapTreeField)(this.children);
218
+ }
235
219
  getPendingDefault() {
236
220
  return !Array.isArray(this.lazyChildren) ? this.lazyChildren : undefined;
237
221
  }
@@ -268,9 +252,6 @@ class UnhydratedFlexTreeField {
268
252
  is(kind) {
269
253
  return this.schema === kind.identifier;
270
254
  }
271
- boxedIterator() {
272
- return this.children[Symbol.iterator]();
273
- }
274
255
  boxedAt(index) {
275
256
  const i = (0, index_js_2.indexForAt)(index, this.length);
276
257
  if (i === undefined) {
@@ -280,7 +261,7 @@ class UnhydratedFlexTreeField {
280
261
  return m;
281
262
  }
282
263
  [(_b = index_js_2.flexTreeMarker, Symbol.iterator)]() {
283
- return this.boxedIterator();
264
+ return this.children[Symbol.iterator]();
284
265
  }
285
266
  /**
286
267
  * Mutate this field.
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTree.js","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA6D;AAE7D,kEAAwE;AACxE,uEAAsE;AAEtE,kDAe6B;AAC7B,+DAyB0C;AAC1C,kDAAyE;AAiBzE;;GAEG;AACH,MAAa,sBAAsB;IAG3B,UAAU;QAChB,OAAO,KAAK,CAAC;IACd,CAAC;IAID,IAAW,YAAY;QACtB,OAAO,CACN,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,oBAAoB,CAAC,CACtF,CAAC;IACH,CAAC;IAeD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;IACvC,CAAC;IAED;;OAEG;IACH;IACC;;OAEG;IACa,IAAc;IAC9B;;;;OAIG;IACc,SAAiD;IAClE;;;;;OAKG;IACa,aAAsB;QAbtB,SAAI,GAAJ,IAAI,CAAU;QAMb,cAAS,GAAT,SAAS,CAAwC;QAOlD,kBAAa,GAAb,aAAa,CAAS;QAjD/B,aAAQ,GAAG,kBAAkB,CAAC;QAkBtB,QAAgB,GAAG,6BAAkB,CAAC,IAAa,CAAC;QAEnD,YAAO,GAAG,IAAA,4BAAa,GAAgC,CAAC;QAoCzE;;;;;;WAMG;QACa,WAAM,GAGlB;YACH,GAAG,EAAE,CAA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AClB,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IACM,GAAG,CAAI,UAA+D;QAC5E,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;CACD;AA5CD,0DA4CC;AAED,oBAAoB;AAEpB,gDAAgD;AAChD,SAAgB,WAAW,CAC1B,GAAG,IAA2D;IAE9D,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACjB,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;QACpC,KAAK,qBAAU,CAAC,UAAU,CAAC,UAAU;YACpC,OAAO,IAAI,uBAAuB,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7C,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU;YAClC,OAAO,IAAI,uBAAuB,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7C,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU;YAClC,OAAO,IAAI,uBAAuB,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7C,KAAK,qBAAU,CAAC,SAAS,CAAC,UAAU;YACnC,mHAAmH;YACnH,OAAO,IAAI,uBAAuB,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7C;YACC,OAAO,IAAA,eAAI,EAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;AACF,CAAC;AAjBD,kCAiBC;AAED,SAAgB,qBAAqB,CAAC,OAAgB;IACrD,OAAO,IAAI,qBAAU,CACpB,GACC,OAAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC;AAND,sDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorEvents,\n\tEmptyKey,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tforbiddenFieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype NodeData,\n\ttype NormalizedFieldUpPath,\n\ttype SchemaPolicy,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeValue,\n\ttype Value,\n} from \"../../core/index.js\";\nimport {\n\ttype FlexTreeContext,\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tindexForAt,\n\ttype FlexTreeHydratedContext,\n\ttype FlexFieldKind,\n\tFieldKinds,\n\ttype SequenceFieldEditBuilder,\n\tcursorForMapTreeNode,\n\ttype OptionalFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype FlexibleNodeContent,\n\ttype FlexTreeHydratedContextMinimal,\n\ttype FlexibleFieldContent,\n\ttype MapTreeFieldViewGeneric,\n\ttype MapTreeNodeViewGeneric,\n\ttype HydratedFlexTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport { brand, filterIterable, getOrCreate } from \"../../util/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport type { ContextualFieldProvider } from \"../schemaTypes.js\";\nimport type { TreeNode } from \"./treeNode.js\";\n\ninterface UnhydratedTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<FlexibleFieldContent, UnhydratedFlexTreeNode[]> {}\n\ntype UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, \"childrenChangedAfterBatch\">;\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: FlexTreeField;\n\treadonly index: number;\n}\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeNode}.\n */\nexport class UnhydratedFlexTreeNode\n\timplements FlexTreeNode, MapTreeNodeViewGeneric<UnhydratedFlexTreeNode>\n{\n\tpublic isHydrated(): this is HydratedFlexTreeNode {\n\t\treturn false;\n\t}\n\n\tprivate location = unparentedLocation;\n\n\tpublic get storedSchema(): TreeNodeStoredSchema {\n\t\treturn (\n\t\t\tthis.context.schema.nodeSchema.get(this.data.type) ?? fail(0xb46 /* missing schema */)\n\t\t);\n\t}\n\n\t/**\n\t * Cache storing the {@link TreeNode} for this inner node.\n\t * @remarks\n\t * When creating a `TreeNode` for this `UnhydratedFlexTreeNode`, cache the `TreeNode` in this property.\n\t * Currently this is done by {@link TreeNodeKernel}.\n\t *\n\t * See {@link getOrCreateNodeFromInnerNode} how to get the `TreeNode`, even if not already created, regardless of hydration status.\n\t */\n\tpublic treeNode: TreeNode | undefined;\n\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\tprivate readonly _events = createEmitter<UnhydratedFlexTreeNodeEvents>();\n\tpublic get events(): Listenable<UnhydratedFlexTreeNodeEvents> {\n\t\treturn this._events;\n\t}\n\n\tpublic get context(): FlexTreeContext {\n\t\treturn this.simpleContext.flexContext;\n\t}\n\n\t/**\n\t * Create a new UnhydratedFlexTreeNode.\n\t */\n\tpublic constructor(\n\t\t/**\n\t\t * The {@link NodeData} for this node.\n\t\t */\n\t\tpublic readonly data: NodeData,\n\t\t/**\n\t\t * All {@link UnhydratedFlexTreeField} for this node that have been created so far.\n\t\t * @remarks\n\t\t * This includes all non-empty fields, but also any empty fields which have been previously requested.\n\t\t */\n\t\tprivate readonly fieldsAll: Map<FieldKey, UnhydratedFlexTreeField>,\n\t\t/**\n\t\t * The {@link Context} for this node.\n\t\t * @remarks\n\t\t * Provides access to all schema reachable from this node.\n\t\t * See {@link getUnhydratedContext}.\n\t\t */\n\t\tpublic readonly simpleContext: Context,\n\t) {\n\t\tfor (const [_key, field] of this.fieldsAll) {\n\t\t\tfield.parent = this;\n\t\t}\n\t}\n\n\t/**\n\t * The non-empty fields on this node.\n\t * @remarks\n\t * This is needed to implement {@link MapTreeNodeViewGeneric.fields}, which must omit empty fields.\n\t * Due to having to detect if a field is empty, this forces the evaluation of any pending defaults in the fields.\n\t * Use {@link allFieldsLazy} to avoid evaluating pending defaults.\n\t */\n\tpublic readonly fields: Pick<\n\t\tMap<FieldKey, UnhydratedFlexTreeField>,\n\t\ttypeof Symbol.iterator | \"get\"\n\t> = {\n\t\tget: (key: FieldKey): UnhydratedFlexTreeField | undefined => this.tryGetField(key),\n\t\t[Symbol.iterator]: (): IterableIterator<[FieldKey, UnhydratedFlexTreeField]> =>\n\t\t\tfilterIterable(this.fieldsAll, ([, field]) => field.length > 0),\n\t};\n\n\t/**\n\t * Gets all fields, without filtering out empty ones.\n\t * @remarks\n\t * This avoids forcing the evaluating of pending defaults in the fields, and also saves a copy on access.\n\t */\n\tpublic get allFieldsLazy(): ReadonlyMap<FieldKey, UnhydratedFlexTreeField> {\n\t\treturn this.fieldsAll;\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.data.type;\n\t}\n\n\tpublic get schema(): TreeNodeSchemaIdentifier {\n\t\treturn this.data.type;\n\t}\n\n\tprivate getOrCreateField(key: FieldKey): UnhydratedFlexTreeField {\n\t\treturn getOrCreate(this.fieldsAll, key, () => {\n\t\t\tconst stored = this.storedSchema.getFieldSchema(key).kind;\n\t\t\tconst field = createField(this.context, stored, key, []);\n\t\t\tfield.parent = this;\n\t\t\treturn field;\n\t\t});\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField, index: number): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tif (this.location !== unparentedLocation) {\n\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t}\n\t\t\tlet unhydratedNode: UnhydratedFlexTreeNode | undefined = parent.parent;\n\t\t\twhile (unhydratedNode !== undefined) {\n\t\t\t\tif (unhydratedNode === this) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"A node may not be inserted into a location that is under itself\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst parentNode: FlexTreeNode | undefined = unhydratedNode.parentField.parent.parent;\n\t\t\t\tassert(\n\t\t\t\t\tparentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t0xb77 /* Unhydrated node's parent should be an unhydrated node */,\n\t\t\t\t);\n\t\t\t\tunhydratedNode = parentNode;\n\t\t\t}\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic borrowCursor(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeNode<MapTreeNodeViewGeneric<UnhydratedFlexTreeNode>>(this);\n\t}\n\n\tpublic tryGetField(key: FieldKey): UnhydratedFlexTreeField | undefined {\n\t\tconst field = this.fieldsAll.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn field;\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): UnhydratedFlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn this.getOrCreateField(fieldKey);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn Array.from(this.fields, ([key, field]) => field)[Symbol.iterator]();\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn Array.from(this.fields, ([key]) => key)[Symbol.iterator]();\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.data.value;\n\t}\n\n\tpublic emitChangedEvent(key: FieldKey): void {\n\t\tthis._events.emit(\"childrenChangedAfterBatch\", { changedFields: new Set([key]) });\n\t}\n}\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class UnhydratedContext implements FlexTreeContext {\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly schema: TreeStoredSchema,\n\t) {}\n\n\tpublic isDisposed(): boolean {\n\t\treturn false;\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn false;\n\t}\n}\n\n// #region Fields\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link UnhydratedFlexTreeNode}s.\n * @remarks This exists because {@link UnhydratedFlexTreeNode.parentField} must return a field.\n * If a {@link UnhydratedFlexTreeNode} is created without a parent, its {@link UnhydratedFlexTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TKind2 extends FlexFieldKind>(kind: TKind2) {\n\t\t\treturn this.schema === kind.identifier;\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: brand(forbiddenFieldKindIdentifier),\n\t\tget context(): never {\n\t\t\treturn fail(0xb48 /* unsupported */);\n\t\t},\n\t\tgetFieldPath() {\n\t\t\tfail(0xb49 /* unsupported */);\n\t\t},\n\t},\n\tindex: -1,\n};\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeField}.\n */\nexport class UnhydratedFlexTreeField\n\timplements FlexTreeField, MapTreeFieldViewGeneric<UnhydratedFlexTreeNode>\n{\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic parent: UnhydratedFlexTreeNode | undefined = undefined;\n\n\tpublic constructor(\n\t\tpublic readonly context: FlexTreeContext,\n\t\tpublic readonly schema: FieldKindIdentifier,\n\t\tpublic readonly key: FieldKey,\n\t\t/**\n\t\t * The children of this field.\n\t\t * @remarks\n\t\t * This is either an array of {@link UnhydratedFlexTreeNode}s or a {@link ContextualFieldProvider} that will be used to populate the children lazily (after which it will become an array).\n\t\t * See {@link fillPendingDefaults}.\n\t\t * Note that any fields using a {@link ConstantFieldProvider} should be evaluated before constructing the UnhydratedFlexTreeField.\n\t\t */\n\t\tprivate lazyChildren: UnhydratedFlexTreeNode[] | ContextualFieldProvider,\n\t) {\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tif (Array.isArray(lazyChildren)) {\n\t\t\tfor (const [i, child] of lazyChildren.entries()) {\n\t\t\t\tchild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getPendingDefault(): ContextualFieldProvider | undefined {\n\t\treturn !Array.isArray(this.lazyChildren) ? this.lazyChildren : undefined;\n\t}\n\n\t/**\n\t * Populate pending default (if present) using the provided context.\n\t * @remarks\n\t * This apply to just this field: caller will likely want to recursively walk the tree.\n\t * @see {@link pendingDefault}.\n\t */\n\tpublic fillPendingDefaults(context: FlexTreeHydratedContextMinimal): void {\n\t\tconst provider = this.getPendingDefault();\n\t\tif (provider) {\n\t\t\tconst content = provider(context);\n\t\t\tthis.lazyChildren = content;\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if this field has a pending default due to defined defined using a {@link ContextualFieldProvider}.\n\t */\n\tpublic get pendingDefault(): boolean {\n\t\treturn this.getPendingDefault() !== undefined;\n\t}\n\n\tpublic get children(): UnhydratedFlexTreeNode[] {\n\t\tconst provider = this.getPendingDefault();\n\t\tif (provider) {\n\t\t\tconst content = provider(\"UseGlobalContext\");\n\t\t\tthis.lazyChildren = content;\n\t\t}\n\t\treturn this.lazyChildren as UnhydratedFlexTreeNode[];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.children.length;\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\treturn this.schema === kind.identifier;\n\t}\n\n\tpublic boxedIterator(): IterableIterator<UnhydratedFlexTreeNode> {\n\t\treturn this.children[Symbol.iterator]();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.children[i];\n\t\treturn m;\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeNode> {\n\t\treturn this.boxedIterator();\n\t}\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(\n\t\tedit: (mapTrees: UnhydratedFlexTreeNode[]) => void | UnhydratedFlexTreeNode[],\n\t): void {\n\t\t// Clear parents for all old map trees.\n\t\tfor (const tree of this.children) {\n\t\t\ttree.adoptBy(undefined);\n\t\t}\n\n\t\tthis.lazyChildren = edit(this.children) ?? this.children;\n\n\t\t// Set parents for all new map trees.\n\t\tfor (const [index, tree] of this.children.entries()) {\n\t\t\ttree.adoptBy(this, index);\n\t\t}\n\n\t\tthis.parent?.emitChangedEvent(this.key);\n\t}\n\n\tpublic getFieldPath(): NormalizedFieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n\n\t/** Unboxes leaf nodes to their values */\n\tprotected unboxed(index: number): TreeValue | UnhydratedFlexTreeNode {\n\t\tconst child = this.children[index] ?? oob();\n\t\tconst value = child.value;\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\t\treturn child;\n\t}\n}\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeOptionalField}.\n */\nexport class UnhydratedOptionalField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeOptionalField\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: FlexibleNodeContent | undefined): void => {\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tnewContent instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t0xbb7 /* Expected unhydrated node */,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t} satisfies OptionalFieldEditBuilder<FlexibleNodeContent> &\n\t\tValueFieldEditBuilder<FlexibleNodeContent>;\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\tconst value = this.children[0];\n\t\tif (value !== undefined) {\n\t\t\treturn this.unboxed(0);\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass UnhydratedRequiredField\n\textends UnhydratedOptionalField\n\timplements FlexTreeRequiredField\n{\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\t// This cannot use ?? since null is a legal value here.\n\t\tassert(\n\t\t\tsuper.content !== undefined,\n\t\t\t0xa57 /* Expected EagerMapTree required field to have a value */,\n\t\t);\n\t\treturn super.content;\n\t}\n}\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeSequenceField}.\n */\nexport class UnhydratedSequenceField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeSequenceField\n{\n\tpublic readonly editor = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (const c of newContent) {\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tassert(c instanceof UnhydratedFlexTreeNode, 0xbb8 /* Expected unhydrated node */);\n\t\t\t}\n\t\t\tconst newContentChecked = newContent as readonly UnhydratedFlexTreeNode[];\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContentChecked);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContentChecked, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): UnhydratedFlexTreeNode[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.children[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t}\n\t\t\tlet removed: UnhydratedFlexTreeNode[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(0xb4a /* Expected removed to be set by edit */);\n\t\t},\n\t} satisfies UnhydratedTreeSequenceFieldEditBuilder;\n\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.unboxed(i);\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n}\n\n// #endregion Fields\n\n/** Creates a field with the given attributes */\nexport function createField(\n\t...args: ConstructorParameters<typeof UnhydratedFlexTreeField>\n): UnhydratedFlexTreeField {\n\tswitch (args[1]) {\n\t\tcase FieldKinds.required.identifier:\n\t\tcase FieldKinds.identifier.identifier:\n\t\t\treturn new UnhydratedRequiredField(...args);\n\t\tcase FieldKinds.optional.identifier:\n\t\t\treturn new UnhydratedOptionalField(...args);\n\t\tcase FieldKinds.sequence.identifier:\n\t\t\treturn new UnhydratedSequenceField(...args);\n\t\tcase FieldKinds.forbidden.identifier:\n\t\t\t// TODO: this seems to used by unknown optional fields. They should probably use \"optional\" not \"Forbidden\" schema.\n\t\t\treturn new UnhydratedFlexTreeField(...args);\n\t\tdefault:\n\t\t\treturn fail(0xb9d /* unsupported field kind */);\n\t}\n}\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
1
+ {"version":3,"file":"unhydratedFlexTree.js","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+DAA6D;AAE7D,kEAAwE;AACxE,uEAAsE;AAEtE,kDAc6B;AAC7B,+DA2B0C;AAC1C,kDAAsF;AActF;;GAEG;AACH,MAAa,sBAAsB;IAG3B,UAAU;QAChB,OAAO,KAAK,CAAC;IACd,CAAC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E,CAAC;AACH,CAAC;AAND,sDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorEvents,\n\tdummyRoot,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype NodeData,\n\ttype NormalizedFieldUpPath,\n\ttype SchemaPolicy,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeValue,\n\ttype Value,\n} from \"../../core/index.js\";\nimport {\n\ttype FlexTreeContext,\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tindexForAt,\n\ttype FlexTreeHydratedContext,\n\ttype FlexFieldKind,\n\tFieldKinds,\n\ttype SequenceFieldEditBuilder,\n\tcursorForMapTreeNode,\n\ttype OptionalFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n\ttype FlexibleNodeContent,\n\ttype FlexTreeHydratedContextMinimal,\n\ttype FlexibleFieldContent,\n\ttype MapTreeFieldViewGeneric,\n\ttype MapTreeNodeViewGeneric,\n\ttype HydratedFlexTreeNode,\n\tcursorForMapTreeField,\n\ttype MinimalFieldMap,\n} from \"../../feature-libraries/index.js\";\nimport { brand, filterIterable, getOrCreate, mapIterable } from \"../../util/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport type { ContextualFieldProvider } from \"../schemaTypes.js\";\nimport type { TreeNode } from \"./treeNode.js\";\n\ninterface UnhydratedTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<FlexibleFieldContent, UnhydratedFlexTreeNode[]> {}\n\ntype UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, \"childrenChangedAfterBatch\">;\n\n/** A node's parent field and its index in that field */\ntype LocationInField = FlexTreeNode[\"parentField\"];\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeNode}.\n */\nexport class UnhydratedFlexTreeNode\n\timplements FlexTreeNode, MapTreeNodeViewGeneric<UnhydratedFlexTreeNode>\n{\n\tpublic isHydrated(): this is HydratedFlexTreeNode {\n\t\treturn false;\n\t}\n\n\tprivate location = unparentedLocation;\n\n\tpublic get storedSchema(): TreeNodeStoredSchema {\n\t\treturn (\n\t\t\tthis.context.schema.nodeSchema.get(this.data.type) ?? fail(0xb46 /* missing schema */)\n\t\t);\n\t}\n\n\t/**\n\t * Cache storing the {@link TreeNode} for this inner node.\n\t * @remarks\n\t * When creating a `TreeNode` for this `UnhydratedFlexTreeNode`, cache the `TreeNode` in this property.\n\t * Currently this is done by {@link TreeNodeKernel}.\n\t *\n\t * See {@link getOrCreateNodeFromInnerNode} how to get the `TreeNode`, even if not already created, regardless of hydration status.\n\t */\n\tpublic treeNode: TreeNode | undefined;\n\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\tprivate readonly _events = createEmitter<UnhydratedFlexTreeNodeEvents>();\n\tpublic get events(): Listenable<UnhydratedFlexTreeNodeEvents> {\n\t\treturn this._events;\n\t}\n\n\tpublic get context(): FlexTreeContext {\n\t\treturn this.simpleContext.flexContext;\n\t}\n\n\t/**\n\t * Create a new UnhydratedFlexTreeNode.\n\t */\n\tpublic constructor(\n\t\t/**\n\t\t * The {@link NodeData} for this node.\n\t\t */\n\t\tpublic readonly data: NodeData,\n\t\t/**\n\t\t * All {@link UnhydratedFlexTreeField} for this node that have been created so far.\n\t\t * @remarks\n\t\t * This includes all non-empty fields, but also any empty fields which have been previously requested.\n\t\t */\n\t\tprivate readonly fieldsAll: Map<FieldKey, UnhydratedFlexTreeField>,\n\t\t/**\n\t\t * The {@link Context} for this node.\n\t\t * @remarks\n\t\t * Provides access to all schema reachable from this node.\n\t\t * See {@link getUnhydratedContext}.\n\t\t */\n\t\tpublic readonly simpleContext: Context,\n\t) {\n\t\tfor (const [_key, field] of this.fieldsAll) {\n\t\t\tfield.parent = this;\n\t\t}\n\t}\n\n\t/**\n\t * The non-empty fields on this node.\n\t * @remarks\n\t * This is needed to implement {@link MapTreeNodeViewGeneric.fields}, which must omit empty fields.\n\t * Due to having to detect if a field is empty, this forces the evaluation of any pending defaults in the fields.\n\t * Use {@link allFieldsLazy} to avoid evaluating pending defaults.\n\t */\n\tpublic readonly fields: MinimalFieldMap<UnhydratedFlexTreeField> = {\n\t\tget: (key: FieldKey): UnhydratedFlexTreeField | undefined => this.tryGetField(key),\n\t\t[Symbol.iterator]: (): IterableIterator<[FieldKey, UnhydratedFlexTreeField]> =>\n\t\t\tfilterIterable(this.fieldsAll, ([, field]) => field.length > 0),\n\t};\n\n\tpublic [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeField> {\n\t\treturn mapIterable(this.fields, ([, field]) => field)[Symbol.iterator]();\n\t}\n\n\t/**\n\t * Gets all fields, without filtering out empty ones.\n\t * @remarks\n\t * This avoids forcing the evaluating of pending defaults in the fields, and also saves a copy on access.\n\t */\n\tpublic get allFieldsLazy(): ReadonlyMap<FieldKey, UnhydratedFlexTreeField> {\n\t\treturn this.fieldsAll;\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.data.type;\n\t}\n\n\tprivate getOrCreateField(key: FieldKey): UnhydratedFlexTreeField {\n\t\treturn getOrCreate(this.fieldsAll, key, () => {\n\t\t\tconst stored = this.storedSchema.getFieldSchema(key).kind;\n\t\t\tconst field = createField(this.context, stored, key, []);\n\t\t\tfield.parent = this;\n\t\t\treturn field;\n\t\t});\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField, index: number): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tif (this.location !== unparentedLocation) {\n\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t}\n\t\t\tlet unhydratedNode: UnhydratedFlexTreeNode | undefined = parent.parent;\n\t\t\twhile (unhydratedNode !== undefined) {\n\t\t\t\tif (unhydratedNode === this) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"A node may not be inserted into a location that is under itself\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst parentNode: FlexTreeNode | undefined = unhydratedNode.parentField.parent.parent;\n\t\t\t\tassert(\n\t\t\t\t\tparentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t0xb77 /* Unhydrated node's parent should be an unhydrated node */,\n\t\t\t\t);\n\t\t\t\tunhydratedNode = parentNode;\n\t\t\t}\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic borrowCursor(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeNode<MapTreeNodeViewGeneric<UnhydratedFlexTreeNode>>(this);\n\t}\n\n\tpublic tryGetField(key: FieldKey): UnhydratedFlexTreeField | undefined {\n\t\tconst field = this.fieldsAll.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn field;\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): UnhydratedFlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn this.getOrCreateField(fieldKey);\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\treturn Array.from(this.fields, ([key]) => key)[Symbol.iterator]();\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.data.value;\n\t}\n\n\tpublic emitChangedEvent(key: FieldKey): void {\n\t\tthis._events.emit(\"childrenChangedAfterBatch\", { changedFields: new Set([key]) });\n\t}\n}\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class UnhydratedContext implements FlexTreeContext {\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly schema: TreeStoredSchema,\n\t) {}\n\n\tpublic isDisposed(): boolean {\n\t\treturn false;\n\t}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn false;\n\t}\n}\n\n// #region Fields\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link UnhydratedFlexTreeNode}s.\n * @remarks This exists because {@link UnhydratedFlexTreeNode.parentField} must return a field.\n * If a {@link UnhydratedFlexTreeNode} is created without a parent, its {@link UnhydratedFlexTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n *\n * TODO: make this make sense.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\tkey: dummyRoot,\n\t\tparent: undefined,\n\t\tschema: brand(FieldKinds.optional.identifier),\n\t},\n\tindex: 0,\n};\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeField}.\n */\nexport class UnhydratedFlexTreeField\n\timplements FlexTreeField, MapTreeFieldViewGeneric<UnhydratedFlexTreeNode>\n{\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic parent: UnhydratedFlexTreeNode | undefined = undefined;\n\n\tpublic constructor(\n\t\tpublic readonly context: FlexTreeContext,\n\t\tpublic readonly schema: FieldKindIdentifier,\n\t\tpublic readonly key: FieldKey,\n\t\t/**\n\t\t * The children of this field.\n\t\t * @remarks\n\t\t * This is either an array of {@link UnhydratedFlexTreeNode}s or a {@link ContextualFieldProvider} that will be used to populate the children lazily (after which it will become an array).\n\t\t * See {@link fillPendingDefaults}.\n\t\t * Note that any fields using a {@link ConstantFieldProvider} should be evaluated before constructing the UnhydratedFlexTreeField.\n\t\t */\n\t\tprivate lazyChildren: UnhydratedFlexTreeNode[] | ContextualFieldProvider,\n\t) {\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tif (Array.isArray(lazyChildren)) {\n\t\t\tfor (const [i, child] of lazyChildren.entries()) {\n\t\t\t\tchild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic borrowCursor(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeField<MapTreeNodeViewGeneric<UnhydratedFlexTreeNode>>(\n\t\t\tthis.children,\n\t\t);\n\t}\n\n\tprivate getPendingDefault(): ContextualFieldProvider | undefined {\n\t\treturn !Array.isArray(this.lazyChildren) ? this.lazyChildren : undefined;\n\t}\n\n\t/**\n\t * Populate pending default (if present) using the provided context.\n\t * @remarks\n\t * This apply to just this field: caller will likely want to recursively walk the tree.\n\t * @see {@link pendingDefault}.\n\t */\n\tpublic fillPendingDefaults(context: FlexTreeHydratedContextMinimal): void {\n\t\tconst provider = this.getPendingDefault();\n\t\tif (provider) {\n\t\t\tconst content = provider(context);\n\t\t\tthis.lazyChildren = content;\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if this field has a pending default due to defined defined using a {@link ContextualFieldProvider}.\n\t */\n\tpublic get pendingDefault(): boolean {\n\t\treturn this.getPendingDefault() !== undefined;\n\t}\n\n\tpublic get children(): UnhydratedFlexTreeNode[] {\n\t\tconst provider = this.getPendingDefault();\n\t\tif (provider) {\n\t\t\tconst content = provider(\"UseGlobalContext\");\n\t\t\tthis.lazyChildren = content;\n\t\t}\n\t\treturn this.lazyChildren as UnhydratedFlexTreeNode[];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.children.length;\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\treturn this.schema === kind.identifier;\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.children[i];\n\t\treturn m;\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<UnhydratedFlexTreeNode> {\n\t\treturn this.children[Symbol.iterator]();\n\t}\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(\n\t\tedit: (mapTrees: UnhydratedFlexTreeNode[]) => void | UnhydratedFlexTreeNode[],\n\t): void {\n\t\t// Clear parents for all old map trees.\n\t\tfor (const tree of this.children) {\n\t\t\ttree.adoptBy(undefined);\n\t\t}\n\n\t\tthis.lazyChildren = edit(this.children) ?? this.children;\n\n\t\t// Set parents for all new map trees.\n\t\tfor (const [index, tree] of this.children.entries()) {\n\t\t\ttree.adoptBy(this, index);\n\t\t}\n\n\t\tthis.parent?.emitChangedEvent(this.key);\n\t}\n\n\tpublic getFieldPath(): NormalizedFieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n\n\t/** Unboxes leaf nodes to their values */\n\tprotected unboxed(index: number): TreeValue | UnhydratedFlexTreeNode {\n\t\tconst child = this.children[index] ?? oob();\n\t\tconst value = child.value;\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\t\treturn child;\n\t}\n}\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeOptionalField}.\n */\nexport class UnhydratedOptionalField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeOptionalField\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: FlexibleNodeContent | undefined): void => {\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tnewContent instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t0xbb7 /* Expected unhydrated node */,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t} satisfies OptionalFieldEditBuilder<FlexibleNodeContent> &\n\t\tValueFieldEditBuilder<FlexibleNodeContent>;\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\tconst value = this.children[0];\n\t\tif (value !== undefined) {\n\t\t\treturn this.unboxed(0);\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass UnhydratedRequiredField\n\textends UnhydratedOptionalField\n\timplements FlexTreeRequiredField\n{\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\t// This cannot use ?? since null is a legal value here.\n\t\tassert(\n\t\t\tsuper.content !== undefined,\n\t\t\t0xa57 /* Expected EagerMapTree required field to have a value */,\n\t\t);\n\t\treturn super.content;\n\t}\n}\n\n/**\n * The {@link Unhydrated} implementation of {@link FlexTreeSequenceField}.\n */\nexport class UnhydratedSequenceField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeSequenceField\n{\n\tpublic readonly editor = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (const c of newContent) {\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tassert(c instanceof UnhydratedFlexTreeNode, 0xbb8 /* Expected unhydrated node */);\n\t\t\t}\n\t\t\tconst newContentChecked = newContent as readonly UnhydratedFlexTreeNode[];\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContentChecked);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContentChecked, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): UnhydratedFlexTreeNode[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.children[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t}\n\t\t\tlet removed: UnhydratedFlexTreeNode[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(0xb4a /* Expected removed to be set by edit */);\n\t\t},\n\t} satisfies UnhydratedTreeSequenceFieldEditBuilder;\n\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.unboxed(i);\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n}\n\n// #endregion Fields\n\n/** Creates a field with the given attributes */\nexport function createField(\n\t...args: ConstructorParameters<typeof UnhydratedFlexTreeField>\n): UnhydratedFlexTreeField {\n\tswitch (args[1]) {\n\t\tcase FieldKinds.required.identifier:\n\t\tcase FieldKinds.identifier.identifier:\n\t\t\treturn new UnhydratedRequiredField(...args);\n\t\tcase FieldKinds.optional.identifier:\n\t\t\treturn new UnhydratedOptionalField(...args);\n\t\tcase FieldKinds.sequence.identifier:\n\t\t\treturn new UnhydratedSequenceField(...args);\n\t\tcase FieldKinds.forbidden.identifier:\n\t\t\t// TODO: this seems to used by unknown optional fields. They should probably use \"optional\" not \"Forbidden\" schema.\n\t\t\treturn new UnhydratedFlexTreeField(...args);\n\t\tdefault:\n\t\t\treturn fail(0xb9d /* unsupported field kind */);\n\t}\n}\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { TreeNodeSchema } from "./treeNodeSchema.js";
5
+ import { type NormalizedAnnotatedAllowedTypes, type TreeNodeSchema } from "./treeNodeSchema.js";
6
6
  /**
7
7
  * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.
8
8
  */
@@ -10,7 +10,7 @@ export declare function walkNodeSchema(schema: TreeNodeSchema, visitor: SchemaVi
10
10
  /**
11
11
  * Traverses all {@link TreeNodeSchema} schema reachable from `allowedTypes`, applying the visitor pattern.
12
12
  */
13
- export declare function walkAllowedTypes(allowedTypes: Iterable<TreeNodeSchema>, visitor: SchemaVisitor, visitedSet?: Set<TreeNodeSchema>): void;
13
+ export declare function walkAllowedTypes(annotatedAllowedTypes: NormalizedAnnotatedAllowedTypes, visitor: SchemaVisitor, visitedSet?: Set<TreeNodeSchema>): void;
14
14
  /**
15
15
  * Callbacks for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.
16
16
  */
@@ -25,6 +25,6 @@ export interface SchemaVisitor {
25
25
  *
26
26
  * This includes every field, but also the allowed types array for maps and arrays and the root if starting at {@link walkAllowedTypes}.
27
27
  */
28
- allowedTypes?: (allowedTypes: Iterable<TreeNodeSchema>) => void;
28
+ allowedTypes?: (allowedTypes: NormalizedAnnotatedAllowedTypes) => void;
29
29
  }
30
30
  //# sourceMappingURL=walkSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"walkSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/walkSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,GAC7B,IAAI,CAaN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,EACtC,OAAO,EAAE,aAAa,EACtB,UAAU,GAAE,GAAG,CAAC,cAAc,CAAa,GACzC,IAAI,CAKN;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACxC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;CAChE"}
1
+ {"version":3,"file":"walkSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/walkSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,+BAA+B,EACpC,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,GAC7B,IAAI,CAkBN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,qBAAqB,EAAE,+BAA+B,EACtD,OAAO,EAAE,aAAa,EACtB,UAAU,GAAE,GAAG,CAAC,cAAc,CAAa,GACzC,IAAI,CAKN;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACxC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,+BAA+B,KAAK,IAAI,CAAC;CACvE"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.walkAllowedTypes = exports.walkNodeSchema = void 0;
8
+ const treeNodeSchema_js_1 = require("./treeNodeSchema.js");
8
9
  /**
9
10
  * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.
10
11
  */
@@ -13,7 +14,10 @@ function walkNodeSchema(schema, visitor, visitedSet) {
13
14
  return;
14
15
  }
15
16
  visitedSet.add(schema);
16
- walkAllowedTypes(schema.childTypes, visitor, visitedSet);
17
+ const annotatedAllowedTypes = (0, treeNodeSchema_js_1.asTreeNodeSchemaCorePrivate)(schema).childAnnotatedAllowedTypes;
18
+ for (const fieldAllowedTypes of annotatedAllowedTypes) {
19
+ walkAllowedTypes(fieldAllowedTypes, visitor, visitedSet);
20
+ }
17
21
  // This visit is done at the end so the traversal order is most inner types first.
18
22
  // This was picked since when fixing errors,
19
23
  // working from the inner types out to the types that use them will probably go better than the reverse.
@@ -24,11 +28,11 @@ exports.walkNodeSchema = walkNodeSchema;
24
28
  /**
25
29
  * Traverses all {@link TreeNodeSchema} schema reachable from `allowedTypes`, applying the visitor pattern.
26
30
  */
27
- function walkAllowedTypes(allowedTypes, visitor, visitedSet = new Set()) {
28
- for (const childType of allowedTypes) {
29
- walkNodeSchema(childType, visitor, visitedSet);
31
+ function walkAllowedTypes(annotatedAllowedTypes, visitor, visitedSet = new Set()) {
32
+ for (const { type } of annotatedAllowedTypes.types) {
33
+ walkNodeSchema(type, visitor, visitedSet);
30
34
  }
31
- visitor.allowedTypes?.(allowedTypes);
35
+ visitor.allowedTypes?.(annotatedAllowedTypes);
32
36
  }
33
37
  exports.walkAllowedTypes = walkAllowedTypes;
34
38
  //# sourceMappingURL=walkSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"walkSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/walkSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACH,SAAgB,cAAc,CAC7B,MAAsB,EACtB,OAAsB,EACtB,UAA+B;IAE/B,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO;IACR,CAAC;IACD,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEvB,gBAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAEzD,kFAAkF;IAClF,4CAA4C;IAC5C,wGAAwG;IACxG,gIAAgI;IAChI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAjBD,wCAiBC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC/B,YAAsC,EACtC,OAAsB,EACtB,aAAkC,IAAI,GAAG,EAAE;IAE3C,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE,CAAC;QACtC,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;AATD,4CASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\n\n/**\n * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.\n */\nexport function walkNodeSchema(\n\tschema: TreeNodeSchema,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema>,\n): void {\n\tif (visitedSet.has(schema)) {\n\t\treturn;\n\t}\n\tvisitedSet.add(schema);\n\n\twalkAllowedTypes(schema.childTypes, visitor, visitedSet);\n\n\t// This visit is done at the end so the traversal order is most inner types first.\n\t// This was picked since when fixing errors,\n\t// working from the inner types out to the types that use them will probably go better than the reverse.\n\t// This does not however ensure all types referenced by a type are visited before it, since in recursive cases thats impossible.\n\tvisitor.node?.(schema);\n}\n\n/**\n * Traverses all {@link TreeNodeSchema} schema reachable from `allowedTypes`, applying the visitor pattern.\n */\nexport function walkAllowedTypes(\n\tallowedTypes: Iterable<TreeNodeSchema>,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema> = new Set(),\n): void {\n\tfor (const childType of allowedTypes) {\n\t\twalkNodeSchema(childType, visitor, visitedSet);\n\t}\n\tvisitor.allowedTypes?.(allowedTypes);\n}\n\n/**\n * Callbacks for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.\n */\nexport interface SchemaVisitor {\n\t/**\n\t * Called once for each node schema.\n\t */\n\tnode?: (schema: TreeNodeSchema) => void;\n\t/**\n\t * Called once for each set of allowed types.\n\t * Includes implicit allowed types (when a single type was used instead of an array).\n\t *\n\t * This includes every field, but also the allowed types array for maps and arrays and the root if starting at {@link walkAllowedTypes}.\n\t */\n\tallowedTypes?: (allowedTypes: Iterable<TreeNodeSchema>) => void;\n}\n"]}
1
+ {"version":3,"file":"walkSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/walkSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAI6B;AAE7B;;GAEG;AACH,SAAgB,cAAc,CAC7B,MAAsB,EACtB,OAAsB,EACtB,UAA+B;IAE/B,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO;IACR,CAAC;IAED,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEvB,MAAM,qBAAqB,GAAG,IAAA,+CAA2B,EAAC,MAAM,CAAC,CAAC,0BAA0B,CAAC;IAE7F,KAAK,MAAM,iBAAiB,IAAI,qBAAqB,EAAE,CAAC;QACvD,gBAAgB,CAAC,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,kFAAkF;IAClF,4CAA4C;IAC5C,wGAAwG;IACxG,gIAAgI;IAChI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAtBD,wCAsBC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC/B,qBAAsD,EACtD,OAAsB,EACtB,aAAkC,IAAI,GAAG,EAAE;IAE3C,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACpD,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,CAAC,YAAY,EAAE,CAAC,qBAAqB,CAAC,CAAC;AAC/C,CAAC;AATD,4CASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tasTreeNodeSchemaCorePrivate,\n\ttype NormalizedAnnotatedAllowedTypes,\n\ttype TreeNodeSchema,\n} from \"./treeNodeSchema.js\";\n\n/**\n * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.\n */\nexport function walkNodeSchema(\n\tschema: TreeNodeSchema,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema>,\n): void {\n\tif (visitedSet.has(schema)) {\n\t\treturn;\n\t}\n\n\tvisitedSet.add(schema);\n\n\tconst annotatedAllowedTypes = asTreeNodeSchemaCorePrivate(schema).childAnnotatedAllowedTypes;\n\n\tfor (const fieldAllowedTypes of annotatedAllowedTypes) {\n\t\twalkAllowedTypes(fieldAllowedTypes, visitor, visitedSet);\n\t}\n\n\t// This visit is done at the end so the traversal order is most inner types first.\n\t// This was picked since when fixing errors,\n\t// working from the inner types out to the types that use them will probably go better than the reverse.\n\t// This does not however ensure all types referenced by a type are visited before it, since in recursive cases thats impossible.\n\tvisitor.node?.(schema);\n}\n\n/**\n * Traverses all {@link TreeNodeSchema} schema reachable from `allowedTypes`, applying the visitor pattern.\n */\nexport function walkAllowedTypes(\n\tannotatedAllowedTypes: NormalizedAnnotatedAllowedTypes,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema> = new Set(),\n): void {\n\tfor (const { type } of annotatedAllowedTypes.types) {\n\t\twalkNodeSchema(type, visitor, visitedSet);\n\t}\n\tvisitor.allowedTypes?.(annotatedAllowedTypes);\n}\n\n/**\n * Callbacks for use in {@link walkFieldSchema} / {@link walkAllowedTypes} / {@link walkNodeSchema}.\n */\nexport interface SchemaVisitor {\n\t/**\n\t * Called once for each node schema.\n\t */\n\tnode?: (schema: TreeNodeSchema) => void;\n\t/**\n\t * Called once for each set of allowed types.\n\t * Includes implicit allowed types (when a single type was used instead of an array).\n\t *\n\t * This includes every field, but also the allowed types array for maps and arrays and the root if starting at {@link walkAllowedTypes}.\n\t */\n\tallowedTypes?: (allowedTypes: NormalizedAnnotatedAllowedTypes) => void;\n}\n"]}
@@ -18,7 +18,7 @@ function getUnhydratedContext(schema) {
18
18
  return (0, index_js_2.getOrCreate)(contextCache, schema, (s) => {
19
19
  const normalized = (0, schemaTypes_js_1.normalizeFieldSchema)(schema);
20
20
  const flexContext = new index_js_3.UnhydratedContext(index_js_1.defaultSchemaPolicy, (0, toStoredSchema_js_1.toStoredSchema)(schema));
21
- return new index_js_3.Context(normalized.allowedTypeSet, flexContext);
21
+ return new index_js_3.Context(normalized.annotatedAllowedTypesNormalized, flexContext);
22
22
  });
23
23
  }
24
24
  exports.getUnhydratedContext = getUnhydratedContext;
@@ -1 +1 @@
1
- {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../src/simple-tree/createContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAAoE;AACpE,+CAA+C;AAE/C,8CAA6D;AAC7D,qDAAkF;AAClF,2DAAqD;AAErD,MAAM,YAAY,GAA0C,IAAI,OAAO,EAAE,CAAC;AAE1E;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAA2B;IAC/D,OAAO,IAAA,sBAAW,EAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;QAC9C,MAAM,UAAU,GAAG,IAAA,qCAAoB,EAAC,MAAM,CAAC,CAAC;QAEhD,MAAM,WAAW,GAAG,IAAI,4BAAiB,CAAC,8BAAmB,EAAE,IAAA,kCAAc,EAAC,MAAM,CAAC,CAAC,CAAC;QACvF,OAAO,IAAI,kBAAO,CAAC,UAAU,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC;AAPD,oDAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { defaultSchemaPolicy } from \"../feature-libraries/index.js\";\nimport { getOrCreate } from \"../util/index.js\";\n\nimport { Context, UnhydratedContext } from \"./core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"./schemaTypes.js\";\nimport { toStoredSchema } from \"./toStoredSchema.js\";\n\nconst contextCache: WeakMap<ImplicitFieldSchema, Context> = new WeakMap();\n\n/**\n * Utility for creating {@link Context}s for unhydrated nodes.\n */\nexport function getUnhydratedContext(schema: ImplicitFieldSchema): Context {\n\treturn getOrCreate(contextCache, schema, (s) => {\n\t\tconst normalized = normalizeFieldSchema(schema);\n\n\t\tconst flexContext = new UnhydratedContext(defaultSchemaPolicy, toStoredSchema(schema));\n\t\treturn new Context(normalized.allowedTypeSet, flexContext);\n\t});\n}\n"]}
1
+ {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../src/simple-tree/createContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAAoE;AACpE,+CAA+C;AAE/C,8CAA6D;AAC7D,qDAAkF;AAClF,2DAAqD;AAErD,MAAM,YAAY,GAA0C,IAAI,OAAO,EAAE,CAAC;AAE1E;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAA2B;IAC/D,OAAO,IAAA,sBAAW,EAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;QAC9C,MAAM,UAAU,GAAG,IAAA,qCAAoB,EAAC,MAAM,CAAC,CAAC;QAEhD,MAAM,WAAW,GAAG,IAAI,4BAAiB,CAAC,8BAAmB,EAAE,IAAA,kCAAc,EAAC,MAAM,CAAC,CAAC,CAAC;QACvF,OAAO,IAAI,kBAAO,CAAC,UAAU,CAAC,+BAA+B,EAAE,WAAW,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACJ,CAAC;AAPD,oDAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { defaultSchemaPolicy } from \"../feature-libraries/index.js\";\nimport { getOrCreate } from \"../util/index.js\";\n\nimport { Context, UnhydratedContext } from \"./core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"./schemaTypes.js\";\nimport { toStoredSchema } from \"./toStoredSchema.js\";\n\nconst contextCache: WeakMap<ImplicitFieldSchema, Context> = new WeakMap();\n\n/**\n * Utility for creating {@link Context}s for unhydrated nodes.\n */\nexport function getUnhydratedContext(schema: ImplicitFieldSchema): Context {\n\treturn getOrCreate(contextCache, schema, (s) => {\n\t\tconst normalized = normalizeFieldSchema(schema);\n\n\t\tconst flexContext = new UnhydratedContext(defaultSchemaPolicy, toStoredSchema(schema));\n\t\treturn new Context(normalized.annotatedAllowedTypesNormalized, flexContext);\n\t});\n}\n"]}
@@ -8,5 +8,5 @@ import { type TreeNode } from "./core/index.js";
8
8
  /**
9
9
  * Retrieve the associated {@link TreeNode} for the given field's content.
10
10
  */
11
- export declare function getTreeNodeForField(field: FlexTreeField): TreeNode | TreeValue | undefined;
11
+ export declare function tryGetTreeNodeForField(field: FlexTreeField): TreeNode | TreeValue | undefined;
12
12
  //# sourceMappingURL=getTreeNodeForField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTreeNodeForField.d.ts","sourceRoot":"","sources":["../../src/simple-tree/getTreeNodeForField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEN,KAAK,aAAa,EAIlB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,KAAK,QAAQ,EAAgC,MAAM,iBAAiB,CAAC;AAE9E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CA0B1F"}
1
+ {"version":3,"file":"getTreeNodeForField.d.ts","sourceRoot":"","sources":["../../src/simple-tree/getTreeNodeForField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEN,KAAK,aAAa,EAIlB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,KAAK,QAAQ,EAAgC,MAAM,iBAAiB,CAAC;AAE9E;;GAEG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,aAAa,GAClB,QAAQ,GAAG,SAAS,GAAG,SAAS,CA0BlC"}
@@ -4,14 +4,14 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getTreeNodeForField = void 0;
7
+ exports.tryGetTreeNodeForField = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../feature-libraries/index.js");
10
10
  const index_js_2 = require("./core/index.js");
11
11
  /**
12
12
  * Retrieve the associated {@link TreeNode} for the given field's content.
13
13
  */
14
- function getTreeNodeForField(field) {
14
+ function tryGetTreeNodeForField(field) {
15
15
  function tryToUnboxLeaves(flexField) {
16
16
  const maybeContent = flexField.content;
17
17
  return (0, index_js_1.isFlexTreeNode)(maybeContent)
@@ -35,5 +35,5 @@ function getTreeNodeForField(field) {
35
35
  (0, internal_1.fail)(0xadf /* invalid field kind */);
36
36
  }
37
37
  }
38
- exports.getTreeNodeForField = getTreeNodeForField;
38
+ exports.tryGetTreeNodeForField = tryGetTreeNodeForField;
39
39
  //# sourceMappingURL=getTreeNodeForField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTreeNodeForField.js","sourceRoot":"","sources":["../../src/simple-tree/getTreeNodeForField.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAG3D,4DAMuC;AAEvC,8CAA8E;AAE9E;;GAEG;AACH,SAAgB,mBAAmB,CAAC,KAAoB;IACvD,SAAS,gBAAgB,CACxB,SAAwD;QAExD,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC;QACvC,OAAO,IAAA,yBAAc,EAAC,YAAY,CAAC;YAClC,CAAC,CAAC,IAAA,uCAA4B,EAAC,YAAY,CAAC;YAC5C,CAAC,CAAC,YAAY,CAAC;IACjB,CAAC;IACD,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YACrC,MAAM,UAAU,GAAG,KAA8B,CAAC;YAClD,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YACrC,MAAM,UAAU,GAAG,KAA8B,CAAC;YAClD,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,qBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YACvC,4DAA4D;YAC5D,OAAQ,KAA+B,CAAC,OAAiB,CAAC;QAC3D,CAAC;QAED;YACC,IAAA,eAAI,EAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,CAAC;AACF,CAAC;AA1BD,kDA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport type { TreeValue } from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexTreeField,\n\tisFlexTreeNode,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeOptionalField,\n} from \"../feature-libraries/index.js\";\n\nimport { type TreeNode, getOrCreateNodeFromInnerNode } from \"./core/index.js\";\n\n/**\n * Retrieve the associated {@link TreeNode} for the given field's content.\n */\nexport function getTreeNodeForField(field: FlexTreeField): TreeNode | TreeValue | undefined {\n\tfunction tryToUnboxLeaves(\n\t\tflexField: FlexTreeOptionalField | FlexTreeRequiredField,\n\t): TreeNode | TreeValue | undefined {\n\t\tconst maybeContent = flexField.content;\n\t\treturn isFlexTreeNode(maybeContent)\n\t\t\t? getOrCreateNodeFromInnerNode(maybeContent)\n\t\t\t: maybeContent;\n\t}\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\treturn tryToUnboxLeaves(typedField);\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\treturn tryToUnboxLeaves(typedField);\n\t\t}\n\t\tcase FieldKinds.identifier.identifier: {\n\t\t\t// Identifier fields are just value fields that hold strings\n\t\t\treturn (field as FlexTreeRequiredField).content as string;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(0xadf /* invalid field kind */);\n\t}\n}\n"]}
1
+ {"version":3,"file":"getTreeNodeForField.js","sourceRoot":"","sources":["../../src/simple-tree/getTreeNodeForField.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAG3D,4DAMuC;AAEvC,8CAA8E;AAE9E;;GAEG;AACH,SAAgB,sBAAsB,CACrC,KAAoB;IAEpB,SAAS,gBAAgB,CACxB,SAAwD;QAExD,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC;QACvC,OAAO,IAAA,yBAAc,EAAC,YAAY,CAAC;YAClC,CAAC,CAAC,IAAA,uCAA4B,EAAC,YAAY,CAAC;YAC5C,CAAC,CAAC,YAAY,CAAC;IACjB,CAAC;IACD,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YACrC,MAAM,UAAU,GAAG,KAA8B,CAAC;YAClD,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YACrC,MAAM,UAAU,GAAG,KAA8B,CAAC;YAClD,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,qBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YACvC,4DAA4D;YAC5D,OAAQ,KAA+B,CAAC,OAAiB,CAAC;QAC3D,CAAC;QAED;YACC,IAAA,eAAI,EAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,CAAC;AACF,CAAC;AA5BD,wDA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport type { TreeValue } from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexTreeField,\n\tisFlexTreeNode,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeOptionalField,\n} from \"../feature-libraries/index.js\";\n\nimport { type TreeNode, getOrCreateNodeFromInnerNode } from \"./core/index.js\";\n\n/**\n * Retrieve the associated {@link TreeNode} for the given field's content.\n */\nexport function tryGetTreeNodeForField(\n\tfield: FlexTreeField,\n): TreeNode | TreeValue | undefined {\n\tfunction tryToUnboxLeaves(\n\t\tflexField: FlexTreeOptionalField | FlexTreeRequiredField,\n\t): TreeNode | TreeValue | undefined {\n\t\tconst maybeContent = flexField.content;\n\t\treturn isFlexTreeNode(maybeContent)\n\t\t\t? getOrCreateNodeFromInnerNode(maybeContent)\n\t\t\t: maybeContent;\n\t}\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\treturn tryToUnboxLeaves(typedField);\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\treturn tryToUnboxLeaves(typedField);\n\t\t}\n\t\tcase FieldKinds.identifier.identifier: {\n\t\t\t// Identifier fields are just value fields that hold strings\n\t\t\treturn (field as FlexTreeRequiredField).content as string;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(0xadf /* invalid field kind */);\n\t}\n}\n"]}