@fluidframework/tree 2.50.0 → 2.51.0-347100

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 (597) hide show
  1. package/.vscode/Tree.code-workspace +14 -1
  2. package/.vscode/settings.json +16 -0
  3. package/CHANGELOG.md +2 -2
  4. package/api-report/tree.alpha.api.md +7 -7
  5. package/dist/core/schema-stored/schema.d.ts +14 -1
  6. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  7. package/dist/core/schema-stored/schema.js.map +1 -1
  8. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  9. package/dist/feature-libraries/default-schema/schemaChecker.js +3 -0
  10. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  11. package/dist/feature-libraries/flex-tree/context.d.ts +7 -2
  12. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  13. package/dist/feature-libraries/flex-tree/context.js +4 -4
  14. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  15. package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
  16. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  17. package/dist/feature-libraries/flex-tree/index.js +3 -1
  18. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  19. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyField.js +5 -5
  21. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -1
  23. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyNode.js +5 -3
  25. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  26. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  27. package/dist/feature-libraries/forest-summary/forestSummarizer.js +3 -4
  28. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  29. package/dist/feature-libraries/index.d.ts +1 -1
  30. package/dist/feature-libraries/index.d.ts.map +1 -1
  31. package/dist/feature-libraries/index.js +2 -1
  32. package/dist/feature-libraries/index.js.map +1 -1
  33. package/dist/packageVersion.d.ts +1 -1
  34. package/dist/packageVersion.d.ts.map +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/shared-tree/index.d.ts +0 -1
  38. package/dist/shared-tree/index.d.ts.map +1 -1
  39. package/dist/shared-tree/index.js +1 -3
  40. package/dist/shared-tree/index.js.map +1 -1
  41. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  42. package/dist/shared-tree/schematizeTree.js +2 -6
  43. package/dist/shared-tree/schematizeTree.js.map +1 -1
  44. package/dist/shared-tree/schematizingTreeView.d.ts +11 -13
  45. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  46. package/dist/shared-tree/schematizingTreeView.js +58 -81
  47. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  48. package/dist/shared-tree/sharedTreeChangeTypes.d.ts +1 -1
  49. package/dist/shared-tree/sharedTreeChangeTypes.js.map +1 -1
  50. package/dist/shared-tree/tree.d.ts.map +1 -1
  51. package/dist/shared-tree/tree.js +4 -3
  52. package/dist/shared-tree/tree.js.map +1 -1
  53. package/dist/shared-tree/treeAlpha.d.ts +7 -1
  54. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  55. package/dist/shared-tree/treeAlpha.js.map +1 -1
  56. package/dist/shared-tree/treeCheckout.d.ts +7 -2
  57. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  58. package/dist/shared-tree/treeCheckout.js +4 -1
  59. package/dist/shared-tree/treeCheckout.js.map +1 -1
  60. package/dist/simple-tree/api/conciseTree.d.ts +1 -1
  61. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  62. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  63. package/dist/simple-tree/api/configuration.d.ts +1 -1
  64. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  65. package/dist/simple-tree/api/configuration.js +5 -5
  66. package/dist/simple-tree/api/configuration.js.map +1 -1
  67. package/dist/simple-tree/api/create.d.ts +3 -1
  68. package/dist/simple-tree/api/create.d.ts.map +1 -1
  69. package/dist/simple-tree/api/create.js +2 -0
  70. package/dist/simple-tree/api/create.js.map +1 -1
  71. package/dist/simple-tree/api/customTree.d.ts +1 -2
  72. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  73. package/dist/simple-tree/api/customTree.js.map +1 -1
  74. package/dist/simple-tree/api/getJsonSchema.d.ts +1 -1
  75. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  76. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  77. package/dist/simple-tree/api/getSimpleSchema.d.ts +1 -1
  78. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  79. package/dist/simple-tree/api/identifierIndex.d.ts +1 -1
  80. package/dist/simple-tree/api/identifierIndex.js +2 -2
  81. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  82. package/dist/simple-tree/api/index.d.ts +1 -1
  83. package/dist/simple-tree/api/index.d.ts.map +1 -1
  84. package/dist/simple-tree/api/index.js.map +1 -1
  85. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  86. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  87. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +14 -2
  88. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  89. package/dist/simple-tree/api/schemaCreationUtilities.js +41 -4
  90. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  91. package/dist/simple-tree/api/schemaFactory.d.ts +36 -3
  92. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  93. package/dist/simple-tree/api/schemaFactory.js +18 -18
  94. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  95. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +16 -16
  96. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  97. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  98. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
  99. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  100. package/dist/simple-tree/api/schemaFactoryRecursive.js +2 -2
  101. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  102. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  103. package/dist/simple-tree/api/schemaFromSimple.js +4 -4
  104. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  105. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +2 -2
  106. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  107. package/dist/simple-tree/api/simpleTreeIndex.d.ts +2 -2
  108. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  109. package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
  110. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  111. package/dist/simple-tree/api/storedSchema.d.ts +1 -1
  112. package/dist/simple-tree/api/storedSchema.js +2 -2
  113. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  114. package/dist/simple-tree/api/tree.d.ts +2 -1
  115. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  116. package/dist/simple-tree/api/tree.js.map +1 -1
  117. package/dist/simple-tree/api/treeBeta.d.ts +4 -1
  118. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  119. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  120. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -2
  121. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  122. package/dist/simple-tree/api/treeNodeApi.js +3 -3
  123. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  124. package/dist/simple-tree/api/typesUnsafe.d.ts +2 -3
  125. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  126. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  127. package/dist/simple-tree/api/verboseTree.d.ts +2 -1
  128. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  129. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  130. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +1 -1
  131. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +2 -2
  132. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  133. package/dist/simple-tree/core/allowedTypes.d.ts +316 -0
  134. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -0
  135. package/dist/simple-tree/core/allowedTypes.js +173 -0
  136. package/dist/simple-tree/core/allowedTypes.js.map +1 -0
  137. package/dist/simple-tree/core/context.d.ts +3 -9
  138. package/dist/simple-tree/core/context.d.ts.map +1 -1
  139. package/dist/simple-tree/core/context.js +3 -11
  140. package/dist/simple-tree/core/context.js.map +1 -1
  141. package/dist/simple-tree/core/flexList.d.ts.map +1 -0
  142. package/dist/simple-tree/core/flexList.js.map +1 -0
  143. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  144. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  145. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  146. package/dist/simple-tree/core/index.d.ts +9 -3
  147. package/dist/simple-tree/core/index.d.ts.map +1 -1
  148. package/dist/simple-tree/core/index.js +19 -3
  149. package/dist/simple-tree/core/index.js.map +1 -1
  150. package/dist/simple-tree/core/treeNodeKernel.d.ts +8 -1
  151. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  152. package/dist/simple-tree/core/treeNodeKernel.js +24 -20
  153. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  154. package/dist/simple-tree/core/treeNodeSchema.d.ts +182 -39
  155. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  156. package/dist/simple-tree/core/treeNodeSchema.js +47 -17
  157. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  158. package/dist/simple-tree/{treeNodeValid.d.ts → core/treeNodeValid.d.ts} +18 -4
  159. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -0
  160. package/dist/simple-tree/{treeNodeValid.js → core/treeNodeValid.js} +41 -11
  161. package/dist/simple-tree/core/treeNodeValid.js.map +1 -0
  162. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  163. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  164. package/dist/simple-tree/core/walkSchema.d.ts +2 -1
  165. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  166. package/dist/simple-tree/core/walkSchema.js +6 -2
  167. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  168. package/dist/simple-tree/createContext.d.ts +6 -2
  169. package/dist/simple-tree/createContext.d.ts.map +1 -1
  170. package/dist/simple-tree/createContext.js +15 -3
  171. package/dist/simple-tree/createContext.js.map +1 -1
  172. package/dist/simple-tree/fieldSchema.d.ts +423 -0
  173. package/dist/simple-tree/fieldSchema.d.ts.map +1 -0
  174. package/dist/simple-tree/{schemaTypes.js → fieldSchema.js} +5 -195
  175. package/dist/simple-tree/fieldSchema.js.map +1 -0
  176. package/dist/simple-tree/index.d.ts +5 -5
  177. package/dist/simple-tree/index.d.ts.map +1 -1
  178. package/dist/simple-tree/index.js +11 -11
  179. package/dist/simple-tree/index.js.map +1 -1
  180. package/dist/simple-tree/leafNodeSchema.d.ts +14 -5
  181. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  182. package/dist/simple-tree/leafNodeSchema.js +117 -2
  183. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  184. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
  185. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  186. package/dist/simple-tree/node-kinds/array/arrayNode.js +97 -26
  187. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  188. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +2 -2
  189. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  190. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  191. package/dist/simple-tree/node-kinds/common.d.ts +16 -0
  192. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -0
  193. package/dist/simple-tree/node-kinds/common.js +42 -0
  194. package/dist/simple-tree/node-kinds/common.js.map +1 -0
  195. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  196. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  197. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  198. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +2 -3
  199. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  200. package/dist/simple-tree/node-kinds/map/mapNode.js +64 -26
  201. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  202. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +2 -2
  203. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  204. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  205. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  206. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  207. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  208. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +19 -5
  209. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  210. package/dist/simple-tree/node-kinds/object/objectNode.js +131 -27
  211. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  212. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +11 -4
  213. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  214. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  215. package/dist/simple-tree/node-kinds/record/recordNode.d.ts +2 -2
  216. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  217. package/dist/simple-tree/node-kinds/record/recordNode.js +41 -13
  218. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  219. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
  220. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  221. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  222. package/dist/simple-tree/prepareForInsertion.d.ts +2 -2
  223. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  224. package/dist/simple-tree/prepareForInsertion.js +3 -3
  225. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  226. package/dist/simple-tree/simpleSchema.d.ts +2 -2
  227. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  228. package/dist/simple-tree/simpleSchema.js.map +1 -1
  229. package/dist/simple-tree/toStoredSchema.d.ts +1 -1
  230. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/toStoredSchema.js +6 -7
  232. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  233. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +5 -11
  234. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  235. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +25 -395
  236. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  237. package/dist/simple-tree/unsafeUnknownSchema.d.ts +52 -0
  238. package/dist/simple-tree/unsafeUnknownSchema.d.ts.map +1 -0
  239. package/dist/simple-tree/unsafeUnknownSchema.js +13 -0
  240. package/dist/simple-tree/unsafeUnknownSchema.js.map +1 -0
  241. package/dist/simple-tree/walkFieldSchema.d.ts +1 -1
  242. package/dist/simple-tree/walkFieldSchema.js +2 -2
  243. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  244. package/dist/tableSchema.d.ts +12 -12
  245. package/dist/treeFactory.d.ts +0 -1
  246. package/dist/treeFactory.d.ts.map +1 -1
  247. package/dist/treeFactory.js +0 -1
  248. package/dist/treeFactory.js.map +1 -1
  249. package/lib/core/schema-stored/schema.d.ts +14 -1
  250. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  251. package/lib/core/schema-stored/schema.js.map +1 -1
  252. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  253. package/lib/feature-libraries/default-schema/schemaChecker.js +3 -0
  254. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  255. package/lib/feature-libraries/flex-tree/context.d.ts +7 -2
  256. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  257. package/lib/feature-libraries/flex-tree/context.js +4 -4
  258. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  259. package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
  260. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  261. package/lib/feature-libraries/flex-tree/index.js +1 -0
  262. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  263. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  264. package/lib/feature-libraries/flex-tree/lazyField.js +6 -6
  265. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  266. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -1
  267. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  268. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -1
  269. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  270. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  271. package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -2
  272. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  273. package/lib/feature-libraries/index.d.ts +1 -1
  274. package/lib/feature-libraries/index.d.ts.map +1 -1
  275. package/lib/feature-libraries/index.js +1 -1
  276. package/lib/feature-libraries/index.js.map +1 -1
  277. package/lib/packageVersion.d.ts +1 -1
  278. package/lib/packageVersion.d.ts.map +1 -1
  279. package/lib/packageVersion.js +1 -1
  280. package/lib/packageVersion.js.map +1 -1
  281. package/lib/shared-tree/index.d.ts +0 -1
  282. package/lib/shared-tree/index.d.ts.map +1 -1
  283. package/lib/shared-tree/index.js +0 -1
  284. package/lib/shared-tree/index.js.map +1 -1
  285. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  286. package/lib/shared-tree/schematizeTree.js +2 -6
  287. package/lib/shared-tree/schematizeTree.js.map +1 -1
  288. package/lib/shared-tree/schematizingTreeView.d.ts +11 -13
  289. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  290. package/lib/shared-tree/schematizingTreeView.js +59 -81
  291. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  292. package/lib/shared-tree/sharedTreeChangeTypes.d.ts +1 -1
  293. package/lib/shared-tree/sharedTreeChangeTypes.js.map +1 -1
  294. package/lib/shared-tree/tree.d.ts.map +1 -1
  295. package/lib/shared-tree/tree.js +4 -3
  296. package/lib/shared-tree/tree.js.map +1 -1
  297. package/lib/shared-tree/treeAlpha.d.ts +7 -1
  298. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  299. package/lib/shared-tree/treeAlpha.js.map +1 -1
  300. package/lib/shared-tree/treeCheckout.d.ts +7 -2
  301. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  302. package/lib/shared-tree/treeCheckout.js +5 -2
  303. package/lib/shared-tree/treeCheckout.js.map +1 -1
  304. package/lib/simple-tree/api/conciseTree.d.ts +1 -1
  305. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  306. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  307. package/lib/simple-tree/api/configuration.d.ts +1 -1
  308. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  309. package/lib/simple-tree/api/configuration.js +2 -2
  310. package/lib/simple-tree/api/configuration.js.map +1 -1
  311. package/lib/simple-tree/api/create.d.ts +3 -1
  312. package/lib/simple-tree/api/create.d.ts.map +1 -1
  313. package/lib/simple-tree/api/create.js +2 -0
  314. package/lib/simple-tree/api/create.js.map +1 -1
  315. package/lib/simple-tree/api/customTree.d.ts +1 -2
  316. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  317. package/lib/simple-tree/api/customTree.js.map +1 -1
  318. package/lib/simple-tree/api/getJsonSchema.d.ts +1 -1
  319. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  320. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  321. package/lib/simple-tree/api/getSimpleSchema.d.ts +1 -1
  322. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  323. package/lib/simple-tree/api/identifierIndex.d.ts +1 -1
  324. package/lib/simple-tree/api/identifierIndex.js +1 -1
  325. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  326. package/lib/simple-tree/api/index.d.ts +1 -1
  327. package/lib/simple-tree/api/index.d.ts.map +1 -1
  328. package/lib/simple-tree/api/index.js.map +1 -1
  329. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  330. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  331. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +14 -2
  332. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  333. package/lib/simple-tree/api/schemaCreationUtilities.js +40 -4
  334. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  335. package/lib/simple-tree/api/schemaFactory.d.ts +36 -3
  336. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  337. package/lib/simple-tree/api/schemaFactory.js +2 -2
  338. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  339. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +16 -16
  340. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  341. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  342. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
  343. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  344. package/lib/simple-tree/api/schemaFactoryRecursive.js +1 -1
  345. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  346. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  347. package/lib/simple-tree/api/schemaFromSimple.js +1 -1
  348. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  349. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +1 -1
  350. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  351. package/lib/simple-tree/api/simpleTreeIndex.d.ts +2 -2
  352. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  353. package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
  354. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  355. package/lib/simple-tree/api/storedSchema.d.ts +1 -1
  356. package/lib/simple-tree/api/storedSchema.js +1 -1
  357. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  358. package/lib/simple-tree/api/tree.d.ts +2 -1
  359. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  360. package/lib/simple-tree/api/tree.js.map +1 -1
  361. package/lib/simple-tree/api/treeBeta.d.ts +4 -1
  362. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  363. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  364. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -2
  365. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  366. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  367. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  368. package/lib/simple-tree/api/typesUnsafe.d.ts +2 -3
  369. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  370. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  371. package/lib/simple-tree/api/verboseTree.d.ts +2 -1
  372. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  373. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  374. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +1 -1
  375. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +1 -1
  376. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  377. package/lib/simple-tree/core/allowedTypes.d.ts +316 -0
  378. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -0
  379. package/lib/simple-tree/core/allowedTypes.js +162 -0
  380. package/lib/simple-tree/core/allowedTypes.js.map +1 -0
  381. package/lib/simple-tree/core/context.d.ts +3 -9
  382. package/lib/simple-tree/core/context.d.ts.map +1 -1
  383. package/lib/simple-tree/core/context.js +0 -8
  384. package/lib/simple-tree/core/context.js.map +1 -1
  385. package/lib/simple-tree/core/flexList.d.ts.map +1 -0
  386. package/lib/simple-tree/core/flexList.js.map +1 -0
  387. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  388. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  389. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  390. package/lib/simple-tree/core/index.d.ts +9 -3
  391. package/lib/simple-tree/core/index.d.ts.map +1 -1
  392. package/lib/simple-tree/core/index.js +6 -3
  393. package/lib/simple-tree/core/index.js.map +1 -1
  394. package/lib/simple-tree/core/treeNodeKernel.d.ts +8 -1
  395. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  396. package/lib/simple-tree/core/treeNodeKernel.js +10 -6
  397. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  398. package/lib/simple-tree/core/treeNodeSchema.d.ts +182 -39
  399. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  400. package/lib/simple-tree/core/treeNodeSchema.js +44 -14
  401. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  402. package/lib/simple-tree/{treeNodeValid.d.ts → core/treeNodeValid.d.ts} +18 -4
  403. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -0
  404. package/lib/simple-tree/{treeNodeValid.js → core/treeNodeValid.js} +31 -3
  405. package/lib/simple-tree/core/treeNodeValid.js.map +1 -0
  406. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  407. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  408. package/lib/simple-tree/core/walkSchema.d.ts +2 -1
  409. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  410. package/lib/simple-tree/core/walkSchema.js +7 -3
  411. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  412. package/lib/simple-tree/createContext.d.ts +6 -2
  413. package/lib/simple-tree/createContext.d.ts.map +1 -1
  414. package/lib/simple-tree/createContext.js +13 -2
  415. package/lib/simple-tree/createContext.js.map +1 -1
  416. package/lib/simple-tree/fieldSchema.d.ts +423 -0
  417. package/lib/simple-tree/fieldSchema.d.ts.map +1 -0
  418. package/lib/simple-tree/{schemaTypes.js → fieldSchema.js} +3 -183
  419. package/lib/simple-tree/fieldSchema.js.map +1 -0
  420. package/lib/simple-tree/index.d.ts +5 -5
  421. package/lib/simple-tree/index.d.ts.map +1 -1
  422. package/lib/simple-tree/index.js +2 -2
  423. package/lib/simple-tree/index.js.map +1 -1
  424. package/lib/simple-tree/leafNodeSchema.d.ts +14 -5
  425. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  426. package/lib/simple-tree/leafNodeSchema.js +117 -3
  427. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  428. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
  429. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  430. package/lib/simple-tree/node-kinds/array/arrayNode.js +86 -15
  431. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  432. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +2 -2
  433. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  434. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js +1 -1
  435. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  436. package/lib/simple-tree/node-kinds/common.d.ts +16 -0
  437. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -0
  438. package/lib/simple-tree/node-kinds/common.js +38 -0
  439. package/lib/simple-tree/node-kinds/common.js.map +1 -0
  440. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  441. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  442. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  443. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +2 -3
  444. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  445. package/lib/simple-tree/node-kinds/map/mapNode.js +51 -13
  446. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  447. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +2 -2
  448. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  449. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js +1 -1
  450. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  451. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  452. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  453. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  454. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +19 -5
  455. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  456. package/lib/simple-tree/node-kinds/object/objectNode.js +116 -14
  457. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  458. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +11 -4
  459. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  460. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js +1 -1
  461. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  462. package/lib/simple-tree/node-kinds/record/recordNode.d.ts +2 -2
  463. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  464. package/lib/simple-tree/node-kinds/record/recordNode.js +40 -12
  465. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  466. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
  467. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  468. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js +1 -1
  469. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  470. package/lib/simple-tree/prepareForInsertion.d.ts +2 -2
  471. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  472. package/lib/simple-tree/prepareForInsertion.js +2 -2
  473. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  474. package/lib/simple-tree/simpleSchema.d.ts +2 -2
  475. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  476. package/lib/simple-tree/simpleSchema.js.map +1 -1
  477. package/lib/simple-tree/toStoredSchema.d.ts +1 -1
  478. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  479. package/lib/simple-tree/toStoredSchema.js +2 -3
  480. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  481. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +5 -11
  482. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  483. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +10 -381
  484. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  485. package/lib/simple-tree/unsafeUnknownSchema.d.ts +52 -0
  486. package/lib/simple-tree/unsafeUnknownSchema.d.ts.map +1 -0
  487. package/lib/simple-tree/unsafeUnknownSchema.js +10 -0
  488. package/lib/simple-tree/unsafeUnknownSchema.js.map +1 -0
  489. package/lib/simple-tree/walkFieldSchema.d.ts +1 -1
  490. package/lib/simple-tree/walkFieldSchema.js +1 -1
  491. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  492. package/lib/tableSchema.d.ts +12 -12
  493. package/lib/treeFactory.d.ts +0 -1
  494. package/lib/treeFactory.d.ts.map +1 -1
  495. package/lib/treeFactory.js +0 -1
  496. package/lib/treeFactory.js.map +1 -1
  497. package/package.json +22 -23
  498. package/src/core/schema-stored/schema.ts +14 -1
  499. package/src/feature-libraries/default-schema/schemaChecker.ts +3 -0
  500. package/src/feature-libraries/flex-tree/context.ts +10 -5
  501. package/src/feature-libraries/flex-tree/index.ts +2 -0
  502. package/src/feature-libraries/flex-tree/lazyField.ts +10 -6
  503. package/src/feature-libraries/flex-tree/lazyNode.ts +6 -1
  504. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -2
  505. package/src/feature-libraries/index.ts +1 -0
  506. package/src/packageVersion.ts +1 -1
  507. package/src/shared-tree/index.ts +0 -2
  508. package/src/shared-tree/schematizeTree.ts +2 -6
  509. package/src/shared-tree/schematizingTreeView.ts +72 -107
  510. package/src/shared-tree/sharedTreeChangeTypes.ts +1 -1
  511. package/src/shared-tree/tree.ts +4 -3
  512. package/src/shared-tree/treeAlpha.ts +7 -1
  513. package/src/shared-tree/treeCheckout.ts +15 -2
  514. package/src/simple-tree/api/conciseTree.ts +1 -2
  515. package/src/simple-tree/api/configuration.ts +7 -4
  516. package/src/simple-tree/api/create.ts +3 -1
  517. package/src/simple-tree/api/customTree.ts +1 -2
  518. package/src/simple-tree/api/getJsonSchema.ts +1 -1
  519. package/src/simple-tree/api/getSimpleSchema.ts +1 -1
  520. package/src/simple-tree/api/identifierIndex.ts +1 -1
  521. package/src/simple-tree/api/index.ts +2 -0
  522. package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
  523. package/src/simple-tree/api/schemaCreationUtilities.ts +47 -5
  524. package/src/simple-tree/api/schemaFactory.ts +45 -10
  525. package/src/simple-tree/api/schemaFactoryAlpha.ts +4 -7
  526. package/src/simple-tree/api/schemaFactoryRecursive.ts +9 -4
  527. package/src/simple-tree/api/schemaFromSimple.ts +2 -3
  528. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  529. package/src/simple-tree/api/simpleTreeIndex.ts +8 -3
  530. package/src/simple-tree/api/storedSchema.ts +1 -1
  531. package/src/simple-tree/api/tree.ts +2 -2
  532. package/src/simple-tree/api/treeBeta.ts +4 -1
  533. package/src/simple-tree/api/treeNodeApi.ts +5 -8
  534. package/src/simple-tree/api/typesUnsafe.ts +5 -4
  535. package/src/simple-tree/api/verboseTree.ts +3 -6
  536. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +1 -1
  537. package/src/simple-tree/core/README.md +1 -1
  538. package/src/simple-tree/core/allowedTypes.ts +496 -0
  539. package/src/simple-tree/core/context.ts +3 -10
  540. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  541. package/src/simple-tree/core/index.ts +62 -9
  542. package/src/simple-tree/core/treeNodeKernel.ts +12 -6
  543. package/src/simple-tree/core/treeNodeSchema.ts +247 -63
  544. package/src/simple-tree/{treeNodeValid.ts → core/treeNodeValid.ts} +59 -15
  545. package/src/simple-tree/core/unhydratedFlexTree.ts +1 -1
  546. package/src/simple-tree/core/walkSchema.ts +9 -5
  547. package/src/simple-tree/createContext.ts +26 -2
  548. package/src/simple-tree/fieldSchema.ts +734 -0
  549. package/src/simple-tree/index.ts +32 -30
  550. package/src/simple-tree/leafNodeSchema.ts +137 -5
  551. package/src/simple-tree/node-kinds/array/arrayNode.ts +141 -30
  552. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +5 -7
  553. package/src/simple-tree/node-kinds/common.ts +60 -0
  554. package/src/simple-tree/node-kinds/index.ts +1 -0
  555. package/src/simple-tree/node-kinds/map/mapNode.ts +91 -33
  556. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +5 -7
  557. package/src/simple-tree/node-kinds/object/index.ts +1 -0
  558. package/src/simple-tree/node-kinds/object/objectNode.ts +205 -25
  559. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +22 -5
  560. package/src/simple-tree/node-kinds/record/recordNode.ts +68 -26
  561. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +6 -8
  562. package/src/simple-tree/prepareForInsertion.ts +7 -6
  563. package/src/simple-tree/simpleSchema.ts +2 -2
  564. package/src/simple-tree/toStoredSchema.ts +2 -3
  565. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +12 -494
  566. package/src/simple-tree/unsafeUnknownSchema.ts +70 -0
  567. package/src/simple-tree/walkFieldSchema.ts +1 -1
  568. package/src/treeFactory.ts +0 -1
  569. package/dist/shared-tree/checkoutFlexTreeView.d.ts +0 -58
  570. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +0 -1
  571. package/dist/shared-tree/checkoutFlexTreeView.js +0 -77
  572. package/dist/shared-tree/checkoutFlexTreeView.js.map +0 -1
  573. package/dist/simple-tree/flexList.d.ts.map +0 -1
  574. package/dist/simple-tree/flexList.js.map +0 -1
  575. package/dist/simple-tree/schemaTypes.d.ts +0 -856
  576. package/dist/simple-tree/schemaTypes.d.ts.map +0 -1
  577. package/dist/simple-tree/schemaTypes.js.map +0 -1
  578. package/dist/simple-tree/treeNodeValid.d.ts.map +0 -1
  579. package/dist/simple-tree/treeNodeValid.js.map +0 -1
  580. package/lib/shared-tree/checkoutFlexTreeView.d.ts +0 -58
  581. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +0 -1
  582. package/lib/shared-tree/checkoutFlexTreeView.js +0 -72
  583. package/lib/shared-tree/checkoutFlexTreeView.js.map +0 -1
  584. package/lib/simple-tree/flexList.d.ts.map +0 -1
  585. package/lib/simple-tree/flexList.js.map +0 -1
  586. package/lib/simple-tree/schemaTypes.d.ts +0 -856
  587. package/lib/simple-tree/schemaTypes.d.ts.map +0 -1
  588. package/lib/simple-tree/schemaTypes.js.map +0 -1
  589. package/lib/simple-tree/treeNodeValid.d.ts.map +0 -1
  590. package/lib/simple-tree/treeNodeValid.js.map +0 -1
  591. package/src/shared-tree/checkoutFlexTreeView.ts +0 -100
  592. package/src/simple-tree/schemaTypes.ts +0 -1420
  593. /package/dist/simple-tree/{flexList.d.ts → core/flexList.d.ts} +0 -0
  594. /package/dist/simple-tree/{flexList.js → core/flexList.js} +0 -0
  595. /package/lib/simple-tree/{flexList.d.ts → core/flexList.d.ts} +0 -0
  596. /package/lib/simple-tree/{flexList.js → core/flexList.js} +0 -0
  597. /package/src/simple-tree/{flexList.ts → core/flexList.ts} +0 -0
@@ -16,16 +16,13 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
16
16
  };
17
17
  var _TreeNodeKernel_hydrationState, _TreeNodeKernel_unhydratedEvents;
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.createTreeNodeFromInner = exports.treeNodeFromAnchor = exports.getOrCreateInnerNode = exports.getSimpleContextFromInnerNode = exports.getSimpleNodeSchemaFromInnerNode = exports.tryDisposeTreeNode = exports.simpleTreeNodeSlot = exports.splitInnerNodeType = exports.TreeNodeKernel = exports.tryGetTreeNodeSchema = exports.isTreeNode = exports.getKernel = void 0;
19
+ exports.SimpleContextSlot = exports.createTreeNodeFromInner = exports.treeNodeFromAnchor = exports.getOrCreateInnerNode = exports.getSimpleContextFromInnerNode = exports.getSimpleNodeSchemaFromInnerNode = exports.tryDisposeTreeNode = exports.simpleTreeNodeSlot = exports.splitInnerNodeType = exports.TreeNodeKernel = exports.tryGetTreeNodeSchema = exports.isTreeNode = exports.getKernel = void 0;
20
20
  const client_utils_1 = require("@fluid-internal/client-utils");
21
21
  const internal_1 = require("@fluidframework/core-utils/internal");
22
22
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
23
23
  const index_js_1 = require("../../core/index.js");
24
- // TODO: decide how to deal with dependencies on flex-tree implementation.
25
- // eslint-disable-next-line import/no-internal-modules
26
- const lazyNode_js_1 = require("../../feature-libraries/flex-tree/lazyNode.js");
27
24
  const index_js_2 = require("../../feature-libraries/index.js");
28
- const context_js_1 = require("./context.js");
25
+ const index_js_3 = require("../../feature-libraries/index.js");
29
26
  const unhydratedFlexTree_js_1 = require("./unhydratedFlexTree.js");
30
27
  const treeNodeToKernel = new WeakMap();
31
28
  function getKernel(node) {
@@ -146,7 +143,7 @@ class TreeNodeKernel {
146
143
  get context() {
147
144
  if (isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f"))) {
148
145
  // This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.
149
- return (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f")?.anchorNode.anchorSet.slots.get(context_js_1.SimpleContextSlot) ??
146
+ return (__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f")?.anchorNode.anchorSet.slots.get(exports.SimpleContextSlot) ??
150
147
  (0, internal_1.fail)(0xb40 /* missing simple-tree context */));
151
148
  }
152
149
  return this.initialContext;
@@ -194,20 +191,20 @@ class TreeNodeKernel {
194
191
  }
195
192
  getStatus() {
196
193
  if (this.disposed) {
197
- return index_js_2.TreeStatus.Deleted;
194
+ return index_js_3.TreeStatus.Deleted;
198
195
  }
199
196
  if (!isHydrated(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f"))) {
200
- return index_js_2.TreeStatus.New;
197
+ return index_js_3.TreeStatus.New;
201
198
  }
202
199
  // TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel
203
- const flex = __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode.slots.get(index_js_2.flexTreeSlot);
200
+ const flex = __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode.slots.get(index_js_3.flexTreeSlot);
204
201
  if (flex !== undefined) {
205
- (0, internal_1.assert)(flex instanceof index_js_2.LazyEntity, 0x9b4 /* Unexpected flex node implementation */);
202
+ (0, internal_1.assert)(flex instanceof index_js_3.LazyEntity, 0x9b4 /* Unexpected flex node implementation */);
206
203
  if (flex.isFreed()) {
207
- return index_js_2.TreeStatus.Deleted;
204
+ return index_js_3.TreeStatus.Deleted;
208
205
  }
209
206
  }
210
- return (0, index_js_2.treeStatusFromAnchorCache)(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode);
207
+ return (0, index_js_3.treeStatusFromAnchorCache)(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode);
211
208
  }
212
209
  get events() {
213
210
  // Retrieve the correct events object based on whether this node is pre or post hydration.
@@ -254,19 +251,19 @@ class TreeNodeKernel {
254
251
  // Marinated case -> cooked
255
252
  const anchorNode = __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").anchorNode;
256
253
  // This TreeNode is bound to an anchor node, but it may or may not have an actual flex node yet
257
- const flexNode = anchorNode.slots.get(index_js_2.flexTreeSlot);
254
+ const flexNode = anchorNode.slots.get(index_js_3.flexTreeSlot);
258
255
  if (flexNode !== undefined) {
259
256
  // If the flex node already exists, use it...
260
257
  __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = flexNode;
261
258
  }
262
259
  else {
263
260
  // ...otherwise, the flex node must be created
264
- const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, internal_1.fail)(0xb41 /* missing context */);
261
+ const context = anchorNode.anchorSet.slots.get(index_js_3.ContextSlot) ?? (0, internal_1.fail)(0xb41 /* missing context */);
265
262
  const cursor = context.checkout.forest.allocateCursor("getFlexNode");
266
263
  context.checkout.forest.moveCursorToPath(anchorNode, cursor);
267
- __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = (0, lazyNode_js_1.makeTree)(context, cursor);
264
+ __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode = (0, index_js_2.getOrCreateHydratedFlexTreeNode)(context, cursor);
268
265
  cursor.free();
269
- (0, index_js_2.assertFlexTreeEntityNotFreed)(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
266
+ (0, index_js_3.assertFlexTreeEntityNotFreed)(__classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode);
270
267
  }
271
268
  }
272
269
  return __classPrivateFieldGet(this, _TreeNodeKernel_hydrationState, "f").innerNode;
@@ -326,7 +323,7 @@ function getSimpleContextFromInnerNode(innerNode) {
326
323
  if (innerNode instanceof unhydratedFlexTree_js_1.UnhydratedFlexTreeNode) {
327
324
  return innerNode.simpleContext;
328
325
  }
329
- const context = innerNode.anchorNode.anchorSet.slots.get(context_js_1.SimpleContextSlot);
326
+ const context = innerNode.anchorNode.anchorSet.slots.get(exports.SimpleContextSlot);
330
327
  (0, internal_1.assert)(context !== undefined, 0xa55 /* missing simple tree context */);
331
328
  return context;
332
329
  }
@@ -350,14 +347,14 @@ exports.getOrCreateInnerNode = getOrCreateInnerNode;
350
347
  * Gets a flex node from an anchor node
351
348
  */
352
349
  function flexNodeFromAnchor(anchorNode) {
353
- const flexNode = anchorNode.slots.get(index_js_2.flexTreeSlot);
350
+ const flexNode = anchorNode.slots.get(index_js_3.flexTreeSlot);
354
351
  if (flexNode !== undefined) {
355
352
  return flexNode; // If it does have a flex node, return it...
356
353
  } // ...otherwise, the flex node must be created
357
- const context = anchorNode.anchorSet.slots.get(index_js_2.ContextSlot) ?? (0, internal_1.fail)(0xb45 /* missing context */);
354
+ const context = anchorNode.anchorSet.slots.get(index_js_3.ContextSlot) ?? (0, internal_1.fail)(0xb45 /* missing context */);
358
355
  const cursor = context.checkout.forest.allocateCursor("getFlexNode");
359
356
  context.checkout.forest.moveCursorToPath(anchorNode, cursor);
360
- const newFlexNode = (0, lazyNode_js_1.makeTree)(context, cursor);
357
+ const newFlexNode = (0, index_js_2.getOrCreateHydratedFlexTreeNode)(context, cursor);
361
358
  cursor.free();
362
359
  return newFlexNode;
363
360
  }
@@ -386,4 +383,11 @@ function createTreeNodeFromInner(innerNode) {
386
383
  : classSchema.create(internal);
387
384
  }
388
385
  exports.createTreeNodeFromInner = createTreeNodeFromInner;
386
+ /**
387
+ * Creating multiple simple tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.
388
+ * This slot is used to detect if one already exists and error if creating a second.
389
+ * @remarks
390
+ * See also {@link ContextSlot} in which the flex-tree context is stored.
391
+ */
392
+ exports.SimpleContextSlot = (0, index_js_1.anchorSlot)();
389
393
  //# sourceMappingURL=treeNodeKernel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,+DAA6D;AAE7D,kEAAsF;AACtF,uEAAsE;AAEtE,kDAO6B;AAC7B,0EAA0E;AAC1E,sDAAsD;AACtD,+EAAyE;AACzE,+DAS0C;AAE1C,6CAAqF;AAIrF,mEAAiE;AAEjE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC;AAJD,8BAIC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,gBAAgB,CAAC,GAAG,CAAC,SAAqB,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAiB,CAAC,CAAC;IACvD,OAAO,MAAM,EAAE,MAAM,CAAC;AACvB,CAAC;AAHD,oDAGC;AAqBD,6EAA6E;AAC7E,SAAS,UAAU,CAAC,KAAqB;IACxC,OAAQ,KAAgC,CAAC,UAAU,KAAK,SAAS,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAa,cAAc;IA2B1B;;;;;;;OAOG;IACH,YACiB,IAAc,EACd,MAAsB,EACtC,SAAoB,EACH,cAAuB;Q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QAAQ,CACR,CAAC;AACL,CAAC;AARD,0DAQC","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, Off } from \"@fluidframework/core-interfaces\";\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../../core/index.js\";\n// TODO: decide how to deal with dependencies on flex-tree implementation.\n// eslint-disable-next-line import/no-internal-modules\nimport { makeTree } from \"../../feature-libraries/flex-tree/lazyNode.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n\ttype HydratedFlexTreeNode,\n} from \"../../feature-libraries/index.js\";\n\nimport { SimpleContextSlot, type Context, type HydratedContext } from \"./context.js\";\nimport type { TreeNode } from \"./treeNode.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\nconst treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();\n\nexport function getKernel(node: TreeNode): TreeNodeKernel {\n\tconst kernel = treeNodeToKernel.get(node);\n\tassert(kernel !== undefined, 0x9b1 /* Expected tree node to have kernel */);\n\treturn kernel;\n}\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn treeNodeToKernel.has(candidate as TreeNode);\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode}.\n *\n * Returns undefined for other values.\n * @remarks\n * Does not give schema for a {@link TreeLeafValue}.\n */\nexport function tryGetTreeNodeSchema(value: unknown): undefined | TreeNodeSchema {\n\tconst kernel = treeNodeToKernel.get(value as TreeNode);\n\treturn kernel?.schema;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} before the kernel is hydrated */\ninterface UnhydratedState {\n\toff: Off;\n\treadonly innerNode: UnhydratedFlexTreeNode;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The flex node for this kernel (lazy - undefined if it has not yet been demanded) */\n\tinnerNode?: FlexTreeNode;\n\t/** The {@link AnchorNode} that this node is associated with. */\n\treadonly anchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\treadonly offAnchorNode: Set<Off>;\n}\n\n/** State within a {@link TreeNodeKernel} that is related to the hydration process */\ntype HydrationState = UnhydratedState | HydratedState;\n\n/** True if and only if the given {@link HydrationState} is post-hydration */\nfunction isHydrated(state: HydrationState): state is HydratedState {\n\treturn (state as Partial<HydratedState>).anchorNode !== undefined;\n}\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n */\nexport class TreeNodeKernel {\n\tprivate disposed = false;\n\n\t/**\n\t * Generation number which is incremented any time we have an edit on the node.\n\t * Used during iteration to make sure there has been no edits that were concurrently made.\n\t * @remarks\n\t * This is updated monotonically by this class when edits are applied.\n\t * TODO: update this when applying edits to unhydrated trees.\n\t *\n\t * If TypeScript supported making this immutable from outside the class without making it readonly from inside, that would be used here,\n\t * but they only way to do that is add a separate public accessor and make it private, which was deemed not worth the boilerplate, runtime overhead and bundle size.\n\t */\n\tpublic generationNumber: number = 0;\n\n\t#hydrationState: HydrationState;\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * Since these are usually not used, they are allocated lazily as an optimization.\n\t * The laziness also avoids extra forwarding overhead for events from this kernel's anchor node and also avoids registering for events that are unneeded.\n\t * This means optimizations like skipping processing data in subtrees where no subtreeChanged events are subscribed to would be able to work,\n\t * since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).\n\t */\n\treadonly #unhydratedEvents = new Lazy(createEmitter<KernelEvents>);\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\n\t * @param initialContext - context from when this node was originally crated.\n\t * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.\n\t * @remarks\n\t * Exactly one kernel per TreeNode should be created.\n\t */\n\tpublic constructor(\n\t\tpublic readonly node: TreeNode,\n\t\tpublic readonly schema: TreeNodeSchema,\n\t\tinnerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\n\t\tsplitInnerNodeType(innerNode);\n\n\t\tassert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);\n\t\ttreeNodeToKernel.set(node, this);\n\n\t\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\t// Unhydrated case\n\t\t\tdebugAssert(() => innerNode.treeNode === undefined);\n\t\t\tinnerNode.treeNode = node;\n\t\t\t// Register for change events from the unhydrated flex node.\n\t\t\t// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.\n\t\t\tthis.#hydrationState = {\n\t\t\t\tinnerNode,\n\t\t\t\toff: innerNode.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\tthis.#unhydratedEvents.value.emit(\"childrenChangedAfterBatch\", {\n\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet unhydratedNode: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (unhydratedNode !== undefined) {\n\t\t\t\t\t\tconst treeNode = unhydratedNode.treeNode;\n\t\t\t\t\t\tif (treeNode !== undefined) {\n\t\t\t\t\t\t\tconst kernel = getKernel(treeNode);\n\t\t\t\t\t\t\tkernel.#unhydratedEvents.value.emit(\"subtreeChangedAfterBatch\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst parentNode: FlexTreeNode | undefined =\n\t\t\t\t\t\t\tunhydratedNode.parentField.parent.parent;\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tparentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t\t\t0xb76 /* Unhydrated node's parent should be an unhydrated node */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tunhydratedNode = parentNode;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tthis.#hydrationState = this.createHydratedState(innerNode.anchorNode);\n\t\t\tthis.#hydrationState.innerNode = innerNode;\n\t\t}\n\t}\n\n\tpublic get context(): Context {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\t// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\t\t\tfail(0xb40 /* missing simple-tree context */)\n\t\t\t);\n\t\t}\n\t\treturn this.initialContext;\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the anchor node at the provided path.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link UnhydratedFlexTreeNode} - it is assumed that they are no longer needed once this node has an anchor node.\n\t */\n\tpublic hydrate(anchors: AnchorSet, path: UpPath): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(!isHydrated(this.#hydrationState), 0xa2b /* hydration should only happen once */);\n\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode =\n\t\t\tanchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);\n\n\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\t\tthis.#hydrationState.offAnchorNode.add(() => anchors.forget(anchor));\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#unhydratedEvents.evaluated) {\n\t\t\tconst events = this.#unhydratedEvents.value;\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (events.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrationState.offAnchorNode.add(\n\t\t\t\t\t\t// Argument is forwarded between matching events, so the type should be correct.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tanchorNode.events.on(eventName, (arg: any) => events.emit(eventName, arg)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createHydratedState(anchorNode: AnchorNode): HydratedState {\n\t\tassert(\n\t\t\t!anchorNode.slots.has(simpleTreeNodeSlot),\n\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t);\n\t\tanchorNode.slots.set(simpleTreeNodeSlot, this.node);\n\t\treturn {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.events.on(\"afterDestroy\", () => this.dispose()),\n\t\t\t\t// TODO: this should be triggered on change even for unhydrated nodes.\n\t\t\t\tanchorNode.events.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrationState.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex.isFreed()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrationState.anchorNode);\n\t}\n\n\tpublic get events(): Listenable<KernelEvents> {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\treturn isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode.events\n\t\t\t: this.#unhydratedEvents.value;\n\t}\n\n\tpublic dispose(): void {\n\t\tdebugAssert(() => !this.disposed || \"Cannot dispose a disposed node\");\n\t\tthis.disposed = true;\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\tfor (const off of this.#hydrationState.offAnchorNode) {\n\t\t\t\toff();\n\t\t\t}\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\tpublic isHydrated(): this is { anchorNode: AnchorNode; context: HydratedContext } {\n\t\treturn isHydrated(this.#hydrationState);\n\t}\n\n\tpublic get anchorNode(): AnchorNode | undefined {\n\t\treturn isHydrated(this.#hydrationState) ? this.#hydrationState.anchorNode : undefined;\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target.\n\t * @remarks\n\t * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n\t *\n\t * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n\t * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.\n\t */\n\tpublic getOrCreateInnerNode(): InnerNode {\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\tdebugAssert(\n\t\t\t\t() =>\n\t\t\t\t\tthis.#hydrationState.innerNode?.context.isDisposed() === false ||\n\t\t\t\t\t\"Unhydrated node should never be disposed\",\n\t\t\t);\n\t\t\treturn this.#hydrationState.innerNode; // Unhydrated case\n\t\t}\n\n\t\tif (this.disposed) {\n\t\t\tthrow new UsageError(\"Cannot access a deleted node.\");\n\t\t}\n\n\t\tif (this.#hydrationState.innerNode === undefined) {\n\t\t\t// Marinated case -> cooked\n\t\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t\t// This TreeNode is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\t\tif (flexNode !== undefined) {\n\t\t\t\t// If the flex node already exists, use it...\n\t\t\t\tthis.#hydrationState.innerNode = flexNode;\n\t\t\t} else {\n\t\t\t\t// ...otherwise, the flex node must be created\n\t\t\t\tconst context =\n\t\t\t\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);\n\t\t\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\t\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\t\t\tthis.#hydrationState.innerNode = makeTree(context, cursor);\n\t\t\t\tcursor.free();\n\t\t\t\tassertFlexTreeEntityNotFreed(this.#hydrationState.innerNode);\n\t\t\t}\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n\n\t/**\n\t * Retrieves the {@link UnhydratedFlexTreeNode} if unhydrated. otherwise undefined.\n\t */\n\tpublic getInnerNodeIfUnhydrated(): UnhydratedFlexTreeNode | undefined {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.#hydrationState.innerNode;\n\t}\n}\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a HydratedFlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a UnhydratedFlexTreeNode.\n *\n * For \"marinated\" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.\n */\nexport type InnerNode = FlexTreeNode;\n\n/**\n * Narrows innerNode to either {@link UnhydratedFlexTreeNode} or {@link HydratedFlexTreeNode}.\n */\nexport function splitInnerNodeType(\n\tinnerNode: InnerNode,\n): asserts innerNode is UnhydratedFlexTreeNode | HydratedFlexTreeNode {\n\tassert(\n\t\tinnerNode instanceof UnhydratedFlexTreeNode || innerNode.isHydrated(),\n\t\t0xbc8 /* Invalid inner node type */,\n\t);\n}\n\n/**\n * An anchor slot which associates an anchor with its corresponding {@link TreeNode}, if there is one.\n * @remarks\n * For this to work, we have to require that there is at most a single view using a given AnchorSet.\n * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.\n */\nexport const simpleTreeNodeSlot = anchorSlot<TreeNode>();\n\n/**\n * Dispose a TreeNode (if any) for an existing anchor without disposing the anchor.\n */\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(simpleTreeNodeSlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t\tanchorNode.slots.delete(simpleTreeNodeSlot);\n\t}\n}\n\n/**\n * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.\n */\nexport function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema {\n\tconst context: Context = getSimpleContextFromInnerNode(innerNode);\n\treturn context.schema.get(innerNode.type) ?? fail(0xb3f /* missing schema from context */);\n}\n\n/**\n * Gets the {@link Context} for the {@link InnerNode}.\n */\nexport function getSimpleContextFromInnerNode(innerNode: InnerNode): Context {\n\tsplitInnerNodeType(innerNode);\n\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\treturn innerNode.simpleContext;\n\t}\n\n\tconst context = innerNode.anchorNode.anchorSet.slots.get(SimpleContextSlot);\n\tassert(context !== undefined, 0xa55 /* missing simple tree context */);\n\n\treturn context;\n}\n\n/**\n * Retrieves the flex node associated with the given target.\n * @remarks\n * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n *\n * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n *\n * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.\n */\nexport function getOrCreateInnerNode(treeNode: TreeNode): InnerNode {\n\tconst kernel = getKernel(treeNode);\n\treturn kernel.getOrCreateInnerNode();\n}\n\n/**\n * Gets a flex node from an anchor node\n */\nfunction flexNodeFromAnchor(anchorNode: AnchorNode): HydratedFlexTreeNode {\n\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\tif (flexNode !== undefined) {\n\t\treturn flexNode; // If it does have a flex node, return it...\n\t} // ...otherwise, the flex node must be created\n\tconst context =\n\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);\n\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\tconst newFlexNode = makeTree(context, cursor);\n\tcursor.free();\n\treturn newFlexNode;\n}\n\n/**\n * Gets a tree node from an anchor node\n */\nexport function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue {\n\tconst cached = anchorNode.slots.get(simpleTreeNodeSlot);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst flexNode = flexNodeFromAnchor(anchorNode);\n\treturn createTreeNodeFromInner(flexNode);\n}\n\n/**\n * Constructs a TreeNode from an InnerNode.\n * @remarks\n * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.\n */\nexport function createTreeNodeFromInner(innerNode: InnerNode): TreeNode | TreeValue {\n\tconst classSchema = getSimpleNodeSchemaFromInnerNode(innerNode);\n\tconst internal = innerNode as unknown as InternalTreeNode;\n\treturn typeof classSchema === \"function\"\n\t\t? new classSchema(internal)\n\t\t: (classSchema as { create(data: InternalTreeNode): TreeNode | TreeValue }).create(\n\t\t\t\tinternal,\n\t\t\t);\n}\n"]}
1
+ {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,+DAA6D;AAE7D,kEAAsF;AACtF,uEAAsE;AAEtE,kDAO6B;AAC7B,+DAAmF;AACnF,+DAS0C;AAM1C,mEAAiE;AAEjE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC;AAJD,8BAIC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,gBAAgB,CAAC,GAAG,CAAC,SAAqB,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAiB,CAAC,CAAC;IACvD,OAAO,MAAM,EAAE,MAAM,CAAC;AACvB,CAAC;AAHD,oDAGC;AAqBD,6EAA6E;AAC7E,SAAS,UAAU,CAAC,KAAqB;IACxC,OAAQ,KAAgC,CAAC,UAAU,KAAK,SAAS,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAa,cAAc;IA2B1B;;;;;;;OAOG;IACH,YACiB,IAAc,EACd,MAAsB,EACtC,SAAoB,EACH,cAAuB;QAHxB,SAAI,G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C;AACL,CAAC;AARD,0DAQC;AAED;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG,IAAA,qBAAU,GAAmB,CAAC","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, Off } from \"@fluidframework/core-interfaces\";\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport { getOrCreateHydratedFlexTreeNode } from \"../../feature-libraries/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n\ttype HydratedFlexTreeNode,\n} from \"../../feature-libraries/index.js\";\n\nimport type { Context, HydratedContext } from \"./context.js\";\nimport type { TreeNode } from \"./treeNode.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\nconst treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();\n\nexport function getKernel(node: TreeNode): TreeNodeKernel {\n\tconst kernel = treeNodeToKernel.get(node);\n\tassert(kernel !== undefined, 0x9b1 /* Expected tree node to have kernel */);\n\treturn kernel;\n}\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn treeNodeToKernel.has(candidate as TreeNode);\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode}.\n *\n * Returns undefined for other values.\n * @remarks\n * Does not give schema for a {@link TreeLeafValue}.\n */\nexport function tryGetTreeNodeSchema(value: unknown): undefined | TreeNodeSchema {\n\tconst kernel = treeNodeToKernel.get(value as TreeNode);\n\treturn kernel?.schema;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} before the kernel is hydrated */\ninterface UnhydratedState {\n\toff: Off;\n\treadonly innerNode: UnhydratedFlexTreeNode;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The flex node for this kernel (lazy - undefined if it has not yet been demanded) */\n\tinnerNode?: FlexTreeNode;\n\t/** The {@link AnchorNode} that this node is associated with. */\n\treadonly anchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\treadonly offAnchorNode: Set<Off>;\n}\n\n/** State within a {@link TreeNodeKernel} that is related to the hydration process */\ntype HydrationState = UnhydratedState | HydratedState;\n\n/** True if and only if the given {@link HydrationState} is post-hydration */\nfunction isHydrated(state: HydrationState): state is HydratedState {\n\treturn (state as Partial<HydratedState>).anchorNode !== undefined;\n}\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n */\nexport class TreeNodeKernel {\n\tprivate disposed = false;\n\n\t/**\n\t * Generation number which is incremented any time we have an edit on the node.\n\t * Used during iteration to make sure there has been no edits that were concurrently made.\n\t * @remarks\n\t * This is updated monotonically by this class when edits are applied.\n\t * TODO: update this when applying edits to unhydrated trees.\n\t *\n\t * If TypeScript supported making this immutable from outside the class without making it readonly from inside, that would be used here,\n\t * but they only way to do that is add a separate public accessor and make it private, which was deemed not worth the boilerplate, runtime overhead and bundle size.\n\t */\n\tpublic generationNumber: number = 0;\n\n\t#hydrationState: HydrationState;\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * Since these are usually not used, they are allocated lazily as an optimization.\n\t * The laziness also avoids extra forwarding overhead for events from this kernel's anchor node and also avoids registering for events that are unneeded.\n\t * This means optimizations like skipping processing data in subtrees where no subtreeChanged events are subscribed to would be able to work,\n\t * since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).\n\t */\n\treadonly #unhydratedEvents = new Lazy(createEmitter<KernelEvents>);\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\n\t * @param initialContext - context from when this node was originally crated.\n\t * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.\n\t * @remarks\n\t * Exactly one kernel per TreeNode should be created.\n\t */\n\tpublic constructor(\n\t\tpublic readonly node: TreeNode,\n\t\tpublic readonly schema: TreeNodeSchema,\n\t\tinnerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\n\t\tsplitInnerNodeType(innerNode);\n\n\t\tassert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);\n\t\ttreeNodeToKernel.set(node, this);\n\n\t\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\t// Unhydrated case\n\t\t\tdebugAssert(() => innerNode.treeNode === undefined);\n\t\t\tinnerNode.treeNode = node;\n\t\t\t// Register for change events from the unhydrated flex node.\n\t\t\t// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.\n\t\t\tthis.#hydrationState = {\n\t\t\t\tinnerNode,\n\t\t\t\toff: innerNode.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\tthis.#unhydratedEvents.value.emit(\"childrenChangedAfterBatch\", {\n\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet unhydratedNode: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (unhydratedNode !== undefined) {\n\t\t\t\t\t\tconst treeNode = unhydratedNode.treeNode;\n\t\t\t\t\t\tif (treeNode !== undefined) {\n\t\t\t\t\t\t\tconst kernel = getKernel(treeNode);\n\t\t\t\t\t\t\tkernel.#unhydratedEvents.value.emit(\"subtreeChangedAfterBatch\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst parentNode: FlexTreeNode | undefined =\n\t\t\t\t\t\t\tunhydratedNode.parentField.parent.parent;\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tparentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t\t\t0xb76 /* Unhydrated node's parent should be an unhydrated node */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tunhydratedNode = parentNode;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tthis.#hydrationState = this.createHydratedState(innerNode.anchorNode);\n\t\t\tthis.#hydrationState.innerNode = innerNode;\n\t\t}\n\t}\n\n\tpublic get context(): Context {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\t// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\t\t\tfail(0xb40 /* missing simple-tree context */)\n\t\t\t);\n\t\t}\n\t\treturn this.initialContext;\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the anchor node at the provided path.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link UnhydratedFlexTreeNode} - it is assumed that they are no longer needed once this node has an anchor node.\n\t */\n\tpublic hydrate(anchors: AnchorSet, path: UpPath): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(!isHydrated(this.#hydrationState), 0xa2b /* hydration should only happen once */);\n\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode =\n\t\t\tanchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);\n\n\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\t\tthis.#hydrationState.offAnchorNode.add(() => anchors.forget(anchor));\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#unhydratedEvents.evaluated) {\n\t\t\tconst events = this.#unhydratedEvents.value;\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (events.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrationState.offAnchorNode.add(\n\t\t\t\t\t\t// Argument is forwarded between matching events, so the type should be correct.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tanchorNode.events.on(eventName, (arg: any) => events.emit(eventName, arg)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createHydratedState(anchorNode: AnchorNode): HydratedState {\n\t\tassert(\n\t\t\t!anchorNode.slots.has(simpleTreeNodeSlot),\n\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t);\n\t\tanchorNode.slots.set(simpleTreeNodeSlot, this.node);\n\t\treturn {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.events.on(\"afterDestroy\", () => this.dispose()),\n\t\t\t\t// TODO: this should be triggered on change even for unhydrated nodes.\n\t\t\t\tanchorNode.events.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrationState.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex.isFreed()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrationState.anchorNode);\n\t}\n\n\tpublic get events(): Listenable<KernelEvents> {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\treturn isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode.events\n\t\t\t: this.#unhydratedEvents.value;\n\t}\n\n\tpublic dispose(): void {\n\t\tdebugAssert(() => !this.disposed || \"Cannot dispose a disposed node\");\n\t\tthis.disposed = true;\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\tfor (const off of this.#hydrationState.offAnchorNode) {\n\t\t\t\toff();\n\t\t\t}\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\tpublic isHydrated(): this is { anchorNode: AnchorNode; context: HydratedContext } {\n\t\treturn isHydrated(this.#hydrationState);\n\t}\n\n\tpublic get anchorNode(): AnchorNode | undefined {\n\t\treturn isHydrated(this.#hydrationState) ? this.#hydrationState.anchorNode : undefined;\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target.\n\t * @remarks\n\t * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n\t *\n\t * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n\t * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.\n\t */\n\tpublic getOrCreateInnerNode(): InnerNode {\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\tdebugAssert(\n\t\t\t\t() =>\n\t\t\t\t\tthis.#hydrationState.innerNode?.context.isDisposed() === false ||\n\t\t\t\t\t\"Unhydrated node should never be disposed\",\n\t\t\t);\n\t\t\treturn this.#hydrationState.innerNode; // Unhydrated case\n\t\t}\n\n\t\tif (this.disposed) {\n\t\t\tthrow new UsageError(\"Cannot access a deleted node.\");\n\t\t}\n\n\t\tif (this.#hydrationState.innerNode === undefined) {\n\t\t\t// Marinated case -> cooked\n\t\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t\t// This TreeNode is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\t\tif (flexNode !== undefined) {\n\t\t\t\t// If the flex node already exists, use it...\n\t\t\t\tthis.#hydrationState.innerNode = flexNode;\n\t\t\t} else {\n\t\t\t\t// ...otherwise, the flex node must be created\n\t\t\t\tconst context =\n\t\t\t\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);\n\t\t\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\t\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\t\t\tthis.#hydrationState.innerNode = getOrCreateHydratedFlexTreeNode(context, cursor);\n\t\t\t\tcursor.free();\n\t\t\t\tassertFlexTreeEntityNotFreed(this.#hydrationState.innerNode);\n\t\t\t}\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n\n\t/**\n\t * Retrieves the {@link UnhydratedFlexTreeNode} if unhydrated. otherwise undefined.\n\t */\n\tpublic getInnerNodeIfUnhydrated(): UnhydratedFlexTreeNode | undefined {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.#hydrationState.innerNode;\n\t}\n}\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a HydratedFlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a UnhydratedFlexTreeNode.\n *\n * For \"marinated\" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.\n */\nexport type InnerNode = FlexTreeNode;\n\n/**\n * Narrows innerNode to either {@link UnhydratedFlexTreeNode} or {@link HydratedFlexTreeNode}.\n */\nexport function splitInnerNodeType(\n\tinnerNode: InnerNode,\n): asserts innerNode is UnhydratedFlexTreeNode | HydratedFlexTreeNode {\n\tassert(\n\t\tinnerNode instanceof UnhydratedFlexTreeNode || innerNode.isHydrated(),\n\t\t0xbc8 /* Invalid inner node type */,\n\t);\n}\n\n/**\n * An anchor slot which associates an anchor with its corresponding {@link TreeNode}, if there is one.\n * @remarks\n * For this to work, we have to require that there is at most a single view using a given AnchorSet.\n * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.\n */\nexport const simpleTreeNodeSlot = anchorSlot<TreeNode>();\n\n/**\n * Dispose a TreeNode (if any) for an existing anchor without disposing the anchor.\n */\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(simpleTreeNodeSlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t\tanchorNode.slots.delete(simpleTreeNodeSlot);\n\t}\n}\n\n/**\n * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.\n */\nexport function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema {\n\tconst context: Context = getSimpleContextFromInnerNode(innerNode);\n\treturn context.schema.get(innerNode.type) ?? fail(0xb3f /* missing schema from context */);\n}\n\n/**\n * Gets the {@link Context} for the {@link InnerNode}.\n */\nexport function getSimpleContextFromInnerNode(innerNode: InnerNode): Context {\n\tsplitInnerNodeType(innerNode);\n\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\treturn innerNode.simpleContext;\n\t}\n\n\tconst context = innerNode.anchorNode.anchorSet.slots.get(SimpleContextSlot);\n\tassert(context !== undefined, 0xa55 /* missing simple tree context */);\n\n\treturn context;\n}\n\n/**\n * Retrieves the flex node associated with the given target.\n * @remarks\n * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n *\n * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n *\n * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been deleted.\n */\nexport function getOrCreateInnerNode(treeNode: TreeNode): InnerNode {\n\tconst kernel = getKernel(treeNode);\n\treturn kernel.getOrCreateInnerNode();\n}\n\n/**\n * Gets a flex node from an anchor node\n */\nfunction flexNodeFromAnchor(anchorNode: AnchorNode): HydratedFlexTreeNode {\n\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\tif (flexNode !== undefined) {\n\t\treturn flexNode; // If it does have a flex node, return it...\n\t} // ...otherwise, the flex node must be created\n\tconst context =\n\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);\n\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\tconst newFlexNode = getOrCreateHydratedFlexTreeNode(context, cursor);\n\tcursor.free();\n\treturn newFlexNode;\n}\n\n/**\n * Gets a tree node from an anchor node\n */\nexport function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue {\n\tconst cached = anchorNode.slots.get(simpleTreeNodeSlot);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst flexNode = flexNodeFromAnchor(anchorNode);\n\treturn createTreeNodeFromInner(flexNode);\n}\n\n/**\n * Constructs a TreeNode from an InnerNode.\n * @remarks\n * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.\n */\nexport function createTreeNodeFromInner(innerNode: InnerNode): TreeNode | TreeValue {\n\tconst classSchema = getSimpleNodeSchemaFromInnerNode(innerNode);\n\tconst internal = innerNode as unknown as InternalTreeNode;\n\treturn typeof classSchema === \"function\"\n\t\t? new classSchema(internal)\n\t\t: (classSchema as { create(data: InternalTreeNode): TreeNode | TreeValue }).create(\n\t\t\t\tinternal,\n\t\t\t);\n}\n\n/**\n * Creating multiple simple tree contexts for the same branch, and thus with the same underlying AnchorSet does not work due to how TreeNode caching works.\n * This slot is used to detect if one already exists and error if creating a second.\n * @remarks\n * See also {@link ContextSlot} in which the flex-tree context is stored.\n */\nexport const SimpleContextSlot = anchorSlot<HydratedContext>();\n"]}
@@ -2,11 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { LazyItem } from "../flexList.js";
6
- import type { AllowedTypeMetadata, AllowedTypesMetadata, AnnotatedAllowedTypes, ImplicitAnnotatedAllowedTypes, TreeLeafValue } from "../schemaTypes.js";
5
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
7
6
  import type { SimpleNodeSchemaBase } from "../simpleSchema.js";
8
7
  import type { TreeNode } from "./treeNode.js";
9
8
  import type { InternalTreeNode, Unhydrated } from "./types.js";
9
+ import type { UnionToIntersection } from "../../util/index.js";
10
+ import type { ImplicitAnnotatedAllowedTypes, NormalizedAnnotatedAllowedTypes } from "./allowedTypes.js";
11
+ import type { Context } from "./context.js";
12
+ import type { FieldKey, NodeData } from "../../core/index.js";
13
+ import type { UnhydratedFlexTreeField } from "./unhydratedFlexTree.js";
14
+ import type { FactoryContent } from "../unhydratedFlexTreeFromInsertable.js";
10
15
  /**
11
16
  * Schema for a {@link TreeNode} or {@link TreeLeafValue}.
12
17
  *
@@ -29,38 +34,6 @@ import type { InternalTreeNode, Unhydrated } from "./types.js";
29
34
  * @sealed @public
30
35
  */
31
36
  export type TreeNodeSchema<Name extends string = string, Kind extends NodeKind = NodeKind, TNode extends TreeNode | TreeLeafValue = TreeNode | TreeLeafValue, TBuild = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown, TCustomMetadata = unknown> = (TNode extends TreeNode ? TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info, never, TCustomMetadata> : never) | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info, never, TCustomMetadata>;
32
- /**
33
- * Stores annotations for an individual allowed type.
34
- * @alpha
35
- */
36
- export interface AnnotatedAllowedType<T = LazyItem<TreeNodeSchema>> {
37
- /**
38
- * Annotations for the allowed type.
39
- */
40
- readonly metadata: AllowedTypeMetadata;
41
- /**
42
- * The allowed type the annotations apply to in a particular schema.
43
- */
44
- readonly type: T;
45
- }
46
- /**
47
- * Stores annotations for a set of evaluated annotated allowed types.
48
- * @alpha
49
- */
50
- export interface NormalizedAnnotatedAllowedTypes {
51
- /**
52
- * Annotations that apply to a set of allowed types.
53
- */
54
- readonly metadata: AllowedTypesMetadata;
55
- /**
56
- * All the evaluated allowed types that the annotations apply to. The types themselves are also individually annotated.
57
- */
58
- readonly types: readonly AnnotatedAllowedType<TreeNodeSchema>[];
59
- }
60
- /**
61
- * Checks if the input is an {@link AnnotatedAllowedTypes}.
62
- */
63
- export declare function isAnnotatedAllowedTypes(allowedTypes: ImplicitAnnotatedAllowedTypes): allowedTypes is AnnotatedAllowedTypes;
64
37
  /**
65
38
  * Schema which is not a class.
66
39
  * @remarks
@@ -235,10 +208,61 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
235
208
  */
236
209
  createFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;
237
210
  }
211
+ /**
212
+ * Symbol for use by {@link TreeNodeSchemaCorePrivate}.
213
+ */
214
+ export declare const privateDataSymbol: unique symbol;
238
215
  /**
239
216
  * {@link TreeNodeSchemaCore} extended with some non-exported APIs.
240
217
  */
241
218
  export interface TreeNodeSchemaCorePrivate<Name extends string = string, Kind extends NodeKind = NodeKind, TInsertable = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown, TCustomMetadata = unknown> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable, TCustomMetadata> {
219
+ /**
220
+ * Package private data provided by all {@link TreeNodeSchema}.
221
+ * @remarks
222
+ * Users can add custom statics to schema classes.
223
+ * To reduce the risk of such statics colliding with properties used to implement the schema,
224
+ * some of the private APIs are grouped together under this symbol.
225
+ *
226
+ * Note that there are still some properties which are not under a symbol and thus expose some risk of name collisions.
227
+ * See {@link TreeNodeValid} for some such properties.
228
+ */
229
+ readonly [privateDataSymbol]: TreeNodeSchemaPrivateData;
230
+ }
231
+ /**
232
+ * Package private data provided by all {@link TreeNodeSchema}.
233
+ * @remarks
234
+ * This data needs to be available before lazy schema references are resolved.
235
+ * For data which is only available after lazy schema references are resolved,
236
+ * see {@link TreeNodeSchemaInitializedData}, which can be accessed via {@link TreeNodeSchemaPrivateData.idempotentInitialize}.
237
+ */
238
+ export interface TreeNodeSchemaPrivateData {
239
+ /**
240
+ * All possible annotated allowed types that a field under a node with this schema could have.
241
+ * @remarks
242
+ * In this case "field" includes anything that is a field in the internal (flex-tree) abstraction layer.
243
+ * This includes the content field for arrays, and all the fields for map nodes.
244
+ * If this node does not have fields (and thus is a leaf), the array will be empty.
245
+ *
246
+ * This set cannot be used before the schema in it have been defined:
247
+ * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),
248
+ * users must wait until after the schema are defined to access this array.
249
+ *
250
+ * @privateRemarks
251
+ * If this is stabilized, it will live alongside the childTypes property on {@link TreeNodeSchemaCore}.
252
+ * @system
253
+ */
254
+ readonly childAnnotatedAllowedTypes: readonly ImplicitAnnotatedAllowedTypes[];
255
+ /**
256
+ * Idempotent initialization function that pre-caches data and can dereference lazy schema references.
257
+ */
258
+ idempotentInitialize(): TreeNodeSchemaInitializedData;
259
+ }
260
+ /**
261
+ * Additional data about a given schema which is private to this package.
262
+ * @remarks
263
+ * Created by {@link TreeNodeValid.oneTimeSetup} and can involve dereferencing lazy schema references.
264
+ */
265
+ export interface TreeNodeSchemaInitializedData {
242
266
  /**
243
267
  * All possible annotated allowed types that a field under a node with this schema could have.
244
268
  * @remarks
@@ -255,15 +279,63 @@ export interface TreeNodeSchemaCorePrivate<Name extends string = string, Kind ex
255
279
  * @system
256
280
  */
257
281
  readonly childAnnotatedAllowedTypes: readonly NormalizedAnnotatedAllowedTypes[];
282
+ /**
283
+ * A {@link Context} which can be used for unhydrated nodes of this schema.
284
+ */
285
+ readonly context: Context;
286
+ /**
287
+ * Checks if data might be schema-compatible.
288
+ *
289
+ * @returns false if `data` is incompatible with `type` based on a cheap/shallow check.
290
+ *
291
+ * Note that this may return true for cases where data is incompatible, but it must not return false in cases where the data is compatible.
292
+ */
293
+ shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel;
294
+ /**
295
+ * Convert data to a {@link FlexContent} representation.
296
+ * @remarks
297
+ * Data must be compatible with the schema according to {@link shallowCompatibilityTest}.
298
+ *
299
+ * TODO: use of `allowedTypes` is for fallbacks (for example NaN -\> null).
300
+ * This behavior should be moved to shallowCompatibilityTest instead.
301
+ */
302
+ toFlexContent(data: FactoryContent, allowedTypes: ReadonlySet<TreeNodeSchema>): FlexContent;
258
303
  }
304
+ export type FlexContent = [NodeData, Map<FieldKey, UnhydratedFlexTreeField>];
259
305
  /**
260
- * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} if it is one.
261
- *
306
+ * Indicates a compatibility level for inferring a schema to apply to insertable data.
262
307
  * @remarks
263
- * This function should only be used internally. The result should not be exposed publicly
264
- * in any exported types or API return values.
308
+ * Each schema allowed at a location in the tree has its compatibility level checked against the data being inserted.
309
+ * The compatibility is considered unambiguous if there is a single schema with a higher compatibility than all others.
310
+ *
311
+ * This approach allows adding new compatible formats as a non breaking change.
312
+ * If the new format was already compatible with some other schema, it can still be added as non-breaking as long as a lower compatibility level is used.
313
+ * For example, support for constructing maps from record like objects was added in Fluid Framework 2.2.
314
+ * This format (an object with fields) was already compatible with Object nodes at compatibility level Normal so the new format support for maps was added at compatibility level Low.
315
+ * This ensures that existing code that was using object literals as insertable content where both objects and maps were allowed will continue to work,
316
+ * assuming the objects are intended as ObjectNodes.
317
+ * However new code can now be written using record like objects to construct maps, as long as the schema does not also allow Object nodes which are compatible with the data in that location.
318
+ *
319
+ * @see {@link ITreeConfigurationOptions.preventAmbiguity} for a related setting which interacts with this in a somewhat complex way.
320
+ */
321
+ export declare enum CompatibilityLevel {
322
+ /**
323
+ * Not compatible. Constructor typing indicates incompatibility.
324
+ */
325
+ None = 0,
326
+ /**
327
+ * Additional compatibility cases added in Fluid Framework 2.2.
328
+ */
329
+ Low = 1,
330
+ /**
331
+ * Compatible in Fluid Framework 2.0.
332
+ */
333
+ Normal = 2
334
+ }
335
+ /**
336
+ * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} and get its {@link TreeNodeSchemaPrivateData}.
265
337
  */
266
- export declare function asTreeNodeSchemaCorePrivate(schema: TreeNodeSchemaCore<string, NodeKind, boolean>): TreeNodeSchemaCorePrivate;
338
+ export declare function getTreeNodeSchemaPrivateData(schema: TreeNodeSchemaCore<string, NodeKind, boolean>): TreeNodeSchemaPrivateData;
267
339
  /**
268
340
  * Kind of tree node.
269
341
  * @remarks
@@ -294,4 +366,75 @@ export declare enum NodeKind {
294
366
  */
295
367
  Record = 4
296
368
  }
369
+ /**
370
+ * Metadata associated with a Node Schema.
371
+ *
372
+ * @remarks Specified via {@link NodeSchemaOptions.metadata}.
373
+ *
374
+ * @sealed
375
+ * @public
376
+ */
377
+ export interface NodeSchemaMetadata<out TCustomMetadata = unknown> {
378
+ /**
379
+ * User-defined metadata.
380
+ */
381
+ readonly custom?: TCustomMetadata | undefined;
382
+ /**
383
+ * The description of the Node Schema.
384
+ *
385
+ * @remarks
386
+ *
387
+ * If provided, will be used by the system in scenarios where a description of the kind of node is useful.
388
+ * E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be
389
+ * used as the `description` property.
390
+ */
391
+ readonly description?: string | undefined;
392
+ }
393
+ /**
394
+ * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.
395
+ * @internal
396
+ */
397
+ export declare function isTreeNodeSchemaClass<Name extends string, Kind extends NodeKind, TNode extends TreeNode | TreeLeafValue, TBuild, ImplicitlyConstructable extends boolean, Info>(schema: TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info> | TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>): schema is TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>;
398
+ /**
399
+ * Takes in `TreeNodeSchema[]` and returns a TypedNode union.
400
+ * @privateRemarks
401
+ * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.
402
+ * @public
403
+ */
404
+ export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<string, NodeKind, infer TNode> ? TNode : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode> ? TNode : never;
405
+ /**
406
+ * Data which can be used as a node to be inserted.
407
+ * Either an unhydrated node, or content to build a new node.
408
+ *
409
+ * @see {@link Input}
410
+ *
411
+ * @typeparam TSchemaInput - Schema to process.
412
+ * @typeparam T - Do not specify: default value used as implementation detail.
413
+ * @privateRemarks
414
+ * This can't really be fully correct, since TreeNodeSchema's TNode is generally use covariantly but this code uses it contravariantly.
415
+ * That makes this TreeNodeSchema actually invariant with respect to TNode, but doing that would break all `extends TreeNodeSchema` clauses.
416
+ * As is, this works correctly in most realistic use-cases.
417
+ *
418
+ * One special case this makes is if the result of NodeFromSchema contains TreeNode, this must be an under constrained schema, so the result is set to never.
419
+ * Note that applying UnionToIntersection on the result of NodeFromSchema<T> does not work since it breaks booleans.
420
+ *
421
+ * @public
422
+ */
423
+ export type InsertableTypedNode<TSchema extends TreeNodeSchema, T = UnionToIntersection<TSchema>> = (T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, never, true> ? NodeBuilderData<T> : never) | (T extends TreeNodeSchema ? Unhydrated<TreeNode extends NodeFromSchema<T> ? never : NodeFromSchema<T>> : never);
424
+ /**
425
+ * Given a node's schema, return the corresponding object from which the node could be built.
426
+ * @privateRemarks
427
+ * This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.
428
+ * This works almost the same as using TreeNodeSchema,
429
+ * except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.
430
+ * @system @public
431
+ */
432
+ export type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> = T extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild> ? TBuild : never;
433
+ /**
434
+ * Value that may be stored as a leaf node.
435
+ * @remarks
436
+ * Some limitations apply, see the documentation for {@link SchemaStatics.number} and {@link SchemaStatics.string} for those restrictions.
437
+ * @public
438
+ */
439
+ export type TreeLeafValue = number | string | boolean | IFluidHandle | null;
297
440
  //# sourceMappingURL=treeNodeSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACX,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,aAAa,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MA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AAO,CAAC,IAE9B,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,GAChF,eAAe,CAAC,CAAC,CAAC,GAClB,KAAK,CAAC,GACR,CAAC,CAAC,SAAS,cAAc,GACvB,UAAU,CAAC,QAAQ,SAAS,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,GAC1E,KAAK,CAAC,CAAC;AAEZ;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,IAClF,CAAC,SAAS,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC,GAC3E,MAAM,GACN,KAAK,CAAC;AAEV;;;;;GAKG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,IAAI,CAAC"}
@@ -4,30 +4,52 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.NodeKind = exports.asTreeNodeSchemaCorePrivate = exports.isAnnotatedAllowedTypes = void 0;
7
+ exports.isTreeNodeSchemaClass = exports.NodeKind = exports.getTreeNodeSchemaPrivateData = exports.CompatibilityLevel = exports.privateDataSymbol = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  /**
10
- * Checks if the input is an {@link AnnotatedAllowedTypes}.
10
+ * Symbol for use by {@link TreeNodeSchemaCorePrivate}.
11
11
  */
12
- function isAnnotatedAllowedTypes(allowedTypes) {
13
- return (
14
- // Class based schema, and lazy schema references report type "function": filtering them out with typeof makes narrowing based on members mostly safe
15
- typeof allowedTypes === "object" && "metadata" in allowedTypes && "types" in allowedTypes);
16
- }
17
- exports.isAnnotatedAllowedTypes = isAnnotatedAllowedTypes;
12
+ exports.privateDataSymbol = Symbol("PrivateData");
18
13
  /**
19
- * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} if it is one.
20
- *
14
+ * Indicates a compatibility level for inferring a schema to apply to insertable data.
21
15
  * @remarks
22
- * This function should only be used internally. The result should not be exposed publicly
23
- * in any exported types or API return values.
16
+ * Each schema allowed at a location in the tree has its compatibility level checked against the data being inserted.
17
+ * The compatibility is considered unambiguous if there is a single schema with a higher compatibility than all others.
18
+ *
19
+ * This approach allows adding new compatible formats as a non breaking change.
20
+ * If the new format was already compatible with some other schema, it can still be added as non-breaking as long as a lower compatibility level is used.
21
+ * For example, support for constructing maps from record like objects was added in Fluid Framework 2.2.
22
+ * This format (an object with fields) was already compatible with Object nodes at compatibility level Normal so the new format support for maps was added at compatibility level Low.
23
+ * This ensures that existing code that was using object literals as insertable content where both objects and maps were allowed will continue to work,
24
+ * assuming the objects are intended as ObjectNodes.
25
+ * However new code can now be written using record like objects to construct maps, as long as the schema does not also allow Object nodes which are compatible with the data in that location.
26
+ *
27
+ * @see {@link ITreeConfigurationOptions.preventAmbiguity} for a related setting which interacts with this in a somewhat complex way.
24
28
  */
25
- function asTreeNodeSchemaCorePrivate(schema) {
26
- (0, internal_1.assert)("childAnnotatedAllowedTypes" in schema, 0xbc9 /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */);
27
- (0, internal_1.assert)(Array.isArray(schema.childAnnotatedAllowedTypes), 0xbca /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */);
28
- return schema;
29
+ var CompatibilityLevel;
30
+ (function (CompatibilityLevel) {
31
+ /**
32
+ * Not compatible. Constructor typing indicates incompatibility.
33
+ */
34
+ CompatibilityLevel[CompatibilityLevel["None"] = 0] = "None";
35
+ /**
36
+ * Additional compatibility cases added in Fluid Framework 2.2.
37
+ */
38
+ CompatibilityLevel[CompatibilityLevel["Low"] = 1] = "Low";
39
+ /**
40
+ * Compatible in Fluid Framework 2.0.
41
+ */
42
+ CompatibilityLevel[CompatibilityLevel["Normal"] = 2] = "Normal";
43
+ })(CompatibilityLevel || (exports.CompatibilityLevel = CompatibilityLevel = {}));
44
+ /**
45
+ * Downcasts a {@link TreeNodeSchemaCore} to {@link TreeNodeSchemaCorePrivate} and get its {@link TreeNodeSchemaPrivateData}.
46
+ */
47
+ function getTreeNodeSchemaPrivateData(schema) {
48
+ (0, internal_1.assert)(exports.privateDataSymbol in schema, 0xbc9 /* All implementations of TreeNodeSchemaCore must also implement TreeNodeSchemaCorePrivate */);
49
+ const schemaValid = schema;
50
+ return schemaValid[exports.privateDataSymbol];
29
51
  }
30
- exports.asTreeNodeSchemaCorePrivate = asTreeNodeSchemaCorePrivate;
52
+ exports.getTreeNodeSchemaPrivateData = getTreeNodeSchemaPrivateData;
31
53
  /**
32
54
  * Kind of tree node.
33
55
  * @remarks
@@ -59,4 +81,12 @@ var NodeKind;
59
81
  */
60
82
  NodeKind[NodeKind["Record"] = 4] = "Record";
61
83
  })(NodeKind || (exports.NodeKind = NodeKind = {}));
84
+ /**
85
+ * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.
86
+ * @internal
87
+ */
88
+ function isTreeNodeSchemaClass(schema) {
89
+ return schema.constructor !== undefined;
90
+ }
91
+ exports.isTreeNodeSchemaClass = isTreeNodeSchemaClass;
62
92
  //# sourceMappingURL=treeNodeSchema.js.map