@fluidframework/tree 2.3.1 → 2.4.0-297027

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 (674) hide show
  1. package/api-report/tree.alpha.api.md +77 -38
  2. package/api-report/tree.beta.api.md +50 -30
  3. package/api-report/tree.legacy.alpha.api.md +50 -30
  4. package/api-report/tree.legacy.public.api.md +50 -30
  5. package/api-report/tree.public.api.md +50 -30
  6. package/dist/alpha.d.ts +7 -0
  7. package/dist/beta.d.ts +4 -0
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.d.ts.map +1 -1
  10. package/dist/core/index.js +2 -1
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/core/rebase/index.d.ts +1 -1
  13. package/dist/core/rebase/index.d.ts.map +1 -1
  14. package/dist/core/rebase/index.js +2 -1
  15. package/dist/core/rebase/index.js.map +1 -1
  16. package/dist/core/rebase/types.d.ts +1 -0
  17. package/dist/core/rebase/types.d.ts.map +1 -1
  18. package/dist/core/rebase/types.js +8 -1
  19. package/dist/core/rebase/types.js.map +1 -1
  20. package/dist/core/schema-stored/schema.d.ts +7 -0
  21. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  22. package/dist/core/schema-stored/schema.js +9 -0
  23. package/dist/core/schema-stored/schema.js.map +1 -1
  24. package/dist/core/tree/anchorSet.d.ts +1 -2
  25. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  26. package/dist/core/tree/anchorSet.js +2 -2
  27. package/dist/core/tree/anchorSet.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  29. package/dist/core/tree/detachedFieldIndex.js +13 -2
  30. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  31. package/dist/core/tree/detachedFieldIndexTypes.d.ts +1 -1
  32. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  33. package/dist/feature-libraries/editableTreeBinder.d.ts +3 -230
  34. package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  35. package/dist/feature-libraries/editableTreeBinder.js +1 -539
  36. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  37. package/dist/feature-libraries/flex-tree/context.d.ts +7 -14
  38. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  39. package/dist/feature-libraries/flex-tree/context.js +3 -3
  40. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  41. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -16
  42. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  43. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  44. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +2 -3
  45. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  46. package/dist/feature-libraries/flex-tree/lazyEntity.js +1 -2
  47. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/lazyField.d.ts +10 -15
  49. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/lazyField.js +18 -20
  51. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  52. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -5
  53. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  54. package/dist/feature-libraries/flex-tree/lazyNode.js +13 -23
  55. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  56. package/dist/feature-libraries/flex-tree/utilities.js +1 -1
  57. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  58. package/dist/feature-libraries/index.d.ts +4 -7
  59. package/dist/feature-libraries/index.d.ts.map +1 -1
  60. package/dist/feature-libraries/index.js +5 -31
  61. package/dist/feature-libraries/index.js.map +1 -1
  62. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +7 -0
  63. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  64. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +61 -17
  65. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  66. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  67. package/dist/feature-libraries/sequence-field/compose.js +3 -0
  68. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  69. package/dist/feature-libraries/sequence-field/formatV1.d.ts +18 -18
  70. package/dist/feature-libraries/sequence-field/formatV2.d.ts +18 -18
  71. package/dist/feature-libraries/sequence-field/formatV3.d.ts +27 -27
  72. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  73. package/dist/feature-libraries/sequence-field/utils.js +1 -4
  74. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  75. package/dist/feature-libraries/typed-schema/flexList.d.ts +1 -46
  76. package/dist/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  77. package/dist/feature-libraries/typed-schema/flexList.js +1 -13
  78. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  79. package/dist/feature-libraries/typed-schema/index.d.ts +2 -4
  80. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  81. package/dist/feature-libraries/typed-schema/index.js +1 -19
  82. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  83. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -212
  84. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  85. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +0 -266
  86. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  87. package/dist/index.d.ts +3 -3
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +2 -1
  90. package/dist/index.js.map +1 -1
  91. package/dist/internalTypes.d.ts +1 -1
  92. package/dist/internalTypes.d.ts.map +1 -1
  93. package/dist/internalTypes.js.map +1 -1
  94. package/dist/legacy.d.ts +4 -0
  95. package/dist/packageVersion.d.ts +1 -1
  96. package/dist/packageVersion.d.ts.map +1 -1
  97. package/dist/packageVersion.js +1 -1
  98. package/dist/packageVersion.js.map +1 -1
  99. package/dist/public.d.ts +4 -0
  100. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  101. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  102. package/dist/shared-tree/checkoutFlexTreeView.js +1 -1
  103. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  104. package/dist/shared-tree/index.d.ts +3 -3
  105. package/dist/shared-tree/index.d.ts.map +1 -1
  106. package/dist/shared-tree/index.js +2 -3
  107. package/dist/shared-tree/index.js.map +1 -1
  108. package/dist/shared-tree/schematizeTree.d.ts +1 -40
  109. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  110. package/dist/shared-tree/schematizeTree.js +2 -11
  111. package/dist/shared-tree/schematizeTree.js.map +1 -1
  112. package/dist/shared-tree/schematizingTreeView.d.ts +9 -7
  113. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  114. package/dist/shared-tree/schematizingTreeView.js +19 -8
  115. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  116. package/dist/shared-tree/sharedTree.d.ts +19 -2
  117. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  118. package/dist/shared-tree/sharedTree.js +10 -2
  119. package/dist/shared-tree/sharedTree.js.map +1 -1
  120. package/dist/shared-tree/treeCheckout.d.ts +71 -41
  121. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  122. package/dist/shared-tree/treeCheckout.js +116 -84
  123. package/dist/shared-tree/treeCheckout.js.map +1 -1
  124. package/dist/shared-tree-core/branch.d.ts +8 -11
  125. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  126. package/dist/shared-tree-core/branch.js +12 -15
  127. package/dist/shared-tree-core/branch.js.map +1 -1
  128. package/dist/simple-tree/api/create.d.ts +1 -1
  129. package/dist/simple-tree/api/create.d.ts.map +1 -1
  130. package/dist/simple-tree/api/create.js +11 -13
  131. package/dist/simple-tree/api/create.js.map +1 -1
  132. package/dist/simple-tree/api/getJsonSchema.d.ts +3 -3
  133. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  134. package/dist/simple-tree/api/getJsonSchema.js +1 -1
  135. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  136. package/dist/simple-tree/api/getSimpleSchema.d.ts +2 -2
  137. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  138. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  139. package/dist/simple-tree/api/index.d.ts +2 -1
  140. package/dist/simple-tree/api/index.d.ts.map +1 -1
  141. package/dist/simple-tree/api/index.js +3 -1
  142. package/dist/simple-tree/api/index.js.map +1 -1
  143. package/dist/simple-tree/api/jsonSchema.d.ts +13 -14
  144. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
  145. package/dist/simple-tree/api/jsonSchema.js.map +1 -1
  146. package/dist/simple-tree/api/schemaFactory.d.ts +14 -8
  147. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  148. package/dist/simple-tree/api/schemaFactory.js +21 -2
  149. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  150. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +3 -3
  151. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  152. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  153. package/dist/simple-tree/api/simpleSchema.d.ts +18 -10
  154. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  155. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  156. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  157. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +30 -17
  158. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  159. package/dist/simple-tree/api/tree.d.ts +16 -6
  160. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  161. package/dist/simple-tree/api/tree.js +4 -4
  162. package/dist/simple-tree/api/tree.js.map +1 -1
  163. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  164. package/dist/simple-tree/api/treeNodeApi.js +8 -6
  165. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  166. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  167. package/dist/simple-tree/api/verboseTree.js +6 -10
  168. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  169. package/{lib/feature-libraries/typed-schema → dist/simple-tree/api}/view.d.ts +4 -11
  170. package/dist/simple-tree/api/view.d.ts.map +1 -0
  171. package/dist/{feature-libraries/typed-schema → simple-tree/api}/view.js +9 -9
  172. package/dist/simple-tree/api/view.js.map +1 -0
  173. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -2
  174. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  175. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -1
  176. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  177. package/dist/simple-tree/arrayNode.d.ts +147 -14
  178. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  179. package/dist/simple-tree/arrayNode.js +32 -20
  180. package/dist/simple-tree/arrayNode.js.map +1 -1
  181. package/dist/simple-tree/core/context.d.ts +55 -0
  182. package/dist/simple-tree/core/context.d.ts.map +1 -0
  183. package/dist/simple-tree/core/context.js +60 -0
  184. package/dist/simple-tree/core/context.js.map +1 -0
  185. package/dist/simple-tree/core/getOrCreateNode.d.ts +15 -0
  186. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -0
  187. package/dist/simple-tree/core/getOrCreateNode.js +36 -0
  188. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -0
  189. package/dist/simple-tree/core/index.d.ts +7 -3
  190. package/dist/simple-tree/core/index.d.ts.map +1 -1
  191. package/dist/simple-tree/core/index.js +16 -7
  192. package/dist/simple-tree/core/index.js.map +1 -1
  193. package/dist/simple-tree/core/schemaCaching.d.ts +5 -13
  194. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
  195. package/dist/simple-tree/core/schemaCaching.js +16 -45
  196. package/dist/simple-tree/core/schemaCaching.js.map +1 -1
  197. package/dist/simple-tree/core/treeNodeKernel.d.ts +29 -7
  198. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  199. package/dist/simple-tree/core/treeNodeKernel.js +94 -58
  200. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  201. package/dist/simple-tree/core/treeNodeSchema.d.ts +24 -0
  202. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  203. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  204. package/dist/simple-tree/core/types.d.ts +0 -5
  205. package/dist/simple-tree/core/types.d.ts.map +1 -1
  206. package/dist/simple-tree/core/types.js.map +1 -1
  207. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +139 -0
  208. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -0
  209. package/dist/{feature-libraries/flex-map-tree/mapTreeNode.js → simple-tree/core/unhydratedFlexTree.js} +112 -132
  210. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -0
  211. package/dist/simple-tree/{walkSchema.d.ts → core/walkSchema.d.ts} +8 -4
  212. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -0
  213. package/dist/simple-tree/core/walkSchema.js +34 -0
  214. package/dist/simple-tree/core/walkSchema.js.map +1 -0
  215. package/dist/simple-tree/createContext.d.ts +11 -0
  216. package/dist/simple-tree/createContext.d.ts.map +1 -0
  217. package/dist/simple-tree/createContext.js +25 -0
  218. package/dist/simple-tree/createContext.js.map +1 -0
  219. package/dist/simple-tree/index.d.ts +4 -5
  220. package/dist/simple-tree/index.d.ts.map +1 -1
  221. package/dist/simple-tree/index.js +7 -7
  222. package/dist/simple-tree/index.js.map +1 -1
  223. package/dist/simple-tree/leafNodeSchema.d.ts +1 -0
  224. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  225. package/dist/simple-tree/leafNodeSchema.js +1 -2
  226. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  227. package/dist/simple-tree/mapNode.d.ts +4 -4
  228. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  229. package/dist/simple-tree/mapNode.js +9 -5
  230. package/dist/simple-tree/mapNode.js.map +1 -1
  231. package/dist/simple-tree/objectNode.d.ts +8 -8
  232. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  233. package/dist/simple-tree/objectNode.js +33 -14
  234. package/dist/simple-tree/objectNode.js.map +1 -1
  235. package/dist/simple-tree/objectNodeTypes.d.ts +7 -3
  236. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  237. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  238. package/dist/simple-tree/proxies.d.ts +1 -2
  239. package/dist/simple-tree/proxies.d.ts.map +1 -1
  240. package/dist/simple-tree/proxies.js +6 -22
  241. package/dist/simple-tree/proxies.js.map +1 -1
  242. package/dist/simple-tree/schemaTypes.d.ts +44 -4
  243. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  244. package/dist/simple-tree/schemaTypes.js +10 -0
  245. package/dist/simple-tree/schemaTypes.js.map +1 -1
  246. package/dist/simple-tree/toFlexSchema.d.ts +6 -36
  247. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  248. package/dist/simple-tree/toFlexSchema.js +58 -142
  249. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  250. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  251. package/dist/simple-tree/toMapTree.js +2 -2
  252. package/dist/simple-tree/toMapTree.js.map +1 -1
  253. package/dist/simple-tree/treeNodeValid.d.ts +13 -5
  254. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  255. package/dist/simple-tree/treeNodeValid.js +19 -10
  256. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  257. package/dist/simple-tree/typesUnsafe.d.ts +4 -4
  258. package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
  259. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  260. package/dist/simple-tree/walkFieldSchema.d.ts +11 -0
  261. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -0
  262. package/dist/simple-tree/walkFieldSchema.js +17 -0
  263. package/dist/simple-tree/walkFieldSchema.js.map +1 -0
  264. package/dist/util/index.d.ts +1 -1
  265. package/dist/util/index.d.ts.map +1 -1
  266. package/dist/util/index.js.map +1 -1
  267. package/dist/util/typeUtils.d.ts +14 -45
  268. package/dist/util/typeUtils.d.ts.map +1 -1
  269. package/dist/util/typeUtils.js.map +1 -1
  270. package/lib/alpha.d.ts +7 -0
  271. package/lib/beta.d.ts +4 -0
  272. package/lib/core/index.d.ts +1 -1
  273. package/lib/core/index.d.ts.map +1 -1
  274. package/lib/core/index.js +1 -1
  275. package/lib/core/index.js.map +1 -1
  276. package/lib/core/rebase/index.d.ts +1 -1
  277. package/lib/core/rebase/index.d.ts.map +1 -1
  278. package/lib/core/rebase/index.js +1 -1
  279. package/lib/core/rebase/index.js.map +1 -1
  280. package/lib/core/rebase/types.d.ts +1 -0
  281. package/lib/core/rebase/types.d.ts.map +1 -1
  282. package/lib/core/rebase/types.js +6 -0
  283. package/lib/core/rebase/types.js.map +1 -1
  284. package/lib/core/schema-stored/schema.d.ts +7 -0
  285. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  286. package/lib/core/schema-stored/schema.js +9 -0
  287. package/lib/core/schema-stored/schema.js.map +1 -1
  288. package/lib/core/tree/anchorSet.d.ts +1 -2
  289. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  290. package/lib/core/tree/anchorSet.js +2 -2
  291. package/lib/core/tree/anchorSet.js.map +1 -1
  292. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  293. package/lib/core/tree/detachedFieldIndex.js +13 -2
  294. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  295. package/lib/core/tree/detachedFieldIndexTypes.d.ts +1 -1
  296. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  297. package/lib/feature-libraries/editableTreeBinder.d.ts +3 -230
  298. package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  299. package/lib/feature-libraries/editableTreeBinder.js +1 -532
  300. package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
  301. package/lib/feature-libraries/flex-tree/context.d.ts +7 -14
  302. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  303. package/lib/feature-libraries/flex-tree/context.js +3 -3
  304. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  305. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -16
  306. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  307. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  308. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +2 -3
  309. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  310. package/lib/feature-libraries/flex-tree/lazyEntity.js +1 -2
  311. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  312. package/lib/feature-libraries/flex-tree/lazyField.d.ts +10 -15
  313. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  314. package/lib/feature-libraries/flex-tree/lazyField.js +18 -20
  315. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  316. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -5
  317. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  318. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -23
  319. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  320. package/lib/feature-libraries/flex-tree/utilities.js +1 -1
  321. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  322. package/lib/feature-libraries/index.d.ts +4 -7
  323. package/lib/feature-libraries/index.d.ts.map +1 -1
  324. package/lib/feature-libraries/index.js +4 -6
  325. package/lib/feature-libraries/index.js.map +1 -1
  326. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +7 -0
  327. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  328. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +62 -18
  329. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  330. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  331. package/lib/feature-libraries/sequence-field/compose.js +3 -0
  332. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  333. package/lib/feature-libraries/sequence-field/formatV1.d.ts +18 -18
  334. package/lib/feature-libraries/sequence-field/formatV2.d.ts +18 -18
  335. package/lib/feature-libraries/sequence-field/formatV3.d.ts +27 -27
  336. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  337. package/lib/feature-libraries/sequence-field/utils.js +2 -5
  338. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  339. package/lib/feature-libraries/typed-schema/flexList.d.ts +1 -46
  340. package/lib/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  341. package/lib/feature-libraries/typed-schema/flexList.js +0 -11
  342. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  343. package/lib/feature-libraries/typed-schema/index.d.ts +2 -4
  344. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  345. package/lib/feature-libraries/typed-schema/index.js +0 -3
  346. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  347. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +0 -212
  348. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  349. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +1 -253
  350. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  351. package/lib/index.d.ts +3 -3
  352. package/lib/index.d.ts.map +1 -1
  353. package/lib/index.js +1 -1
  354. package/lib/index.js.map +1 -1
  355. package/lib/internalTypes.d.ts +1 -1
  356. package/lib/internalTypes.d.ts.map +1 -1
  357. package/lib/internalTypes.js.map +1 -1
  358. package/lib/legacy.d.ts +4 -0
  359. package/lib/packageVersion.d.ts +1 -1
  360. package/lib/packageVersion.d.ts.map +1 -1
  361. package/lib/packageVersion.js +1 -1
  362. package/lib/packageVersion.js.map +1 -1
  363. package/lib/public.d.ts +4 -0
  364. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  365. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  366. package/lib/shared-tree/checkoutFlexTreeView.js +1 -1
  367. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  368. package/lib/shared-tree/index.d.ts +3 -3
  369. package/lib/shared-tree/index.d.ts.map +1 -1
  370. package/lib/shared-tree/index.js +1 -2
  371. package/lib/shared-tree/index.js.map +1 -1
  372. package/lib/shared-tree/schematizeTree.d.ts +1 -40
  373. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  374. package/lib/shared-tree/schematizeTree.js +1 -9
  375. package/lib/shared-tree/schematizeTree.js.map +1 -1
  376. package/lib/shared-tree/schematizingTreeView.d.ts +9 -7
  377. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  378. package/lib/shared-tree/schematizingTreeView.js +22 -11
  379. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  380. package/lib/shared-tree/sharedTree.d.ts +19 -2
  381. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  382. package/lib/shared-tree/sharedTree.js +10 -3
  383. package/lib/shared-tree/sharedTree.js.map +1 -1
  384. package/lib/shared-tree/treeCheckout.d.ts +71 -41
  385. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  386. package/lib/shared-tree/treeCheckout.js +118 -86
  387. package/lib/shared-tree/treeCheckout.js.map +1 -1
  388. package/lib/shared-tree-core/branch.d.ts +8 -11
  389. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  390. package/lib/shared-tree-core/branch.js +12 -15
  391. package/lib/shared-tree-core/branch.js.map +1 -1
  392. package/lib/simple-tree/api/create.d.ts +1 -1
  393. package/lib/simple-tree/api/create.d.ts.map +1 -1
  394. package/lib/simple-tree/api/create.js +14 -16
  395. package/lib/simple-tree/api/create.js.map +1 -1
  396. package/lib/simple-tree/api/getJsonSchema.d.ts +3 -3
  397. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  398. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  399. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  400. package/lib/simple-tree/api/getSimpleSchema.d.ts +2 -2
  401. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  402. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  403. package/lib/simple-tree/api/index.d.ts +2 -1
  404. package/lib/simple-tree/api/index.d.ts.map +1 -1
  405. package/lib/simple-tree/api/index.js +1 -0
  406. package/lib/simple-tree/api/index.js.map +1 -1
  407. package/lib/simple-tree/api/jsonSchema.d.ts +13 -14
  408. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
  409. package/lib/simple-tree/api/jsonSchema.js.map +1 -1
  410. package/lib/simple-tree/api/schemaFactory.d.ts +14 -8
  411. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  412. package/lib/simple-tree/api/schemaFactory.js +21 -2
  413. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  414. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +3 -3
  415. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  416. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  417. package/lib/simple-tree/api/simpleSchema.d.ts +18 -10
  418. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  419. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  420. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  421. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +31 -18
  422. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  423. package/lib/simple-tree/api/tree.d.ts +16 -6
  424. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  425. package/lib/simple-tree/api/tree.js +4 -4
  426. package/lib/simple-tree/api/tree.js.map +1 -1
  427. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  428. package/lib/simple-tree/api/treeNodeApi.js +10 -8
  429. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  430. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  431. package/lib/simple-tree/api/verboseTree.js +6 -10
  432. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  433. package/{dist/feature-libraries/typed-schema → lib/simple-tree/api}/view.d.ts +4 -11
  434. package/lib/simple-tree/api/view.d.ts.map +1 -0
  435. package/lib/{feature-libraries/typed-schema → simple-tree/api}/view.js +9 -9
  436. package/lib/simple-tree/api/view.js.map +1 -0
  437. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +2 -2
  438. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  439. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +11 -1
  440. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  441. package/lib/simple-tree/arrayNode.d.ts +147 -14
  442. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  443. package/lib/simple-tree/arrayNode.js +37 -25
  444. package/lib/simple-tree/arrayNode.js.map +1 -1
  445. package/lib/simple-tree/core/context.d.ts +55 -0
  446. package/lib/simple-tree/core/context.d.ts.map +1 -0
  447. package/lib/simple-tree/core/context.js +55 -0
  448. package/lib/simple-tree/core/context.js.map +1 -0
  449. package/lib/simple-tree/core/getOrCreateNode.d.ts +15 -0
  450. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -0
  451. package/lib/simple-tree/core/getOrCreateNode.js +32 -0
  452. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -0
  453. package/lib/simple-tree/core/index.d.ts +7 -3
  454. package/lib/simple-tree/core/index.d.ts.map +1 -1
  455. package/lib/simple-tree/core/index.js +6 -2
  456. package/lib/simple-tree/core/index.js.map +1 -1
  457. package/lib/simple-tree/core/schemaCaching.d.ts +5 -13
  458. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
  459. package/lib/simple-tree/core/schemaCaching.js +13 -39
  460. package/lib/simple-tree/core/schemaCaching.js.map +1 -1
  461. package/lib/simple-tree/core/treeNodeKernel.d.ts +29 -7
  462. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  463. package/lib/simple-tree/core/treeNodeKernel.js +89 -54
  464. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  465. package/lib/simple-tree/core/treeNodeSchema.d.ts +24 -0
  466. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  467. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  468. package/lib/simple-tree/core/types.d.ts +0 -5
  469. package/lib/simple-tree/core/types.d.ts.map +1 -1
  470. package/lib/simple-tree/core/types.js.map +1 -1
  471. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +139 -0
  472. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -0
  473. package/lib/{feature-libraries/flex-map-tree/mapTreeNode.js → simple-tree/core/unhydratedFlexTree.js} +110 -128
  474. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -0
  475. package/lib/simple-tree/{walkSchema.d.ts → core/walkSchema.d.ts} +8 -4
  476. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -0
  477. package/lib/simple-tree/core/walkSchema.js +29 -0
  478. package/lib/simple-tree/core/walkSchema.js.map +1 -0
  479. package/lib/simple-tree/createContext.d.ts +11 -0
  480. package/lib/simple-tree/createContext.d.ts.map +1 -0
  481. package/lib/simple-tree/createContext.js +21 -0
  482. package/lib/simple-tree/createContext.js.map +1 -0
  483. package/lib/simple-tree/index.d.ts +4 -5
  484. package/lib/simple-tree/index.d.ts.map +1 -1
  485. package/lib/simple-tree/index.js +3 -4
  486. package/lib/simple-tree/index.js.map +1 -1
  487. package/lib/simple-tree/leafNodeSchema.d.ts +1 -0
  488. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  489. package/lib/simple-tree/leafNodeSchema.js +3 -4
  490. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  491. package/lib/simple-tree/mapNode.d.ts +4 -4
  492. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  493. package/lib/simple-tree/mapNode.js +12 -8
  494. package/lib/simple-tree/mapNode.js.map +1 -1
  495. package/lib/simple-tree/objectNode.d.ts +8 -8
  496. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  497. package/lib/simple-tree/objectNode.js +36 -17
  498. package/lib/simple-tree/objectNode.js.map +1 -1
  499. package/lib/simple-tree/objectNodeTypes.d.ts +7 -3
  500. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  501. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  502. package/lib/simple-tree/proxies.d.ts +1 -2
  503. package/lib/simple-tree/proxies.d.ts.map +1 -1
  504. package/lib/simple-tree/proxies.js +7 -22
  505. package/lib/simple-tree/proxies.js.map +1 -1
  506. package/lib/simple-tree/schemaTypes.d.ts +44 -4
  507. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  508. package/lib/simple-tree/schemaTypes.js +10 -0
  509. package/lib/simple-tree/schemaTypes.js.map +1 -1
  510. package/lib/simple-tree/toFlexSchema.d.ts +6 -36
  511. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  512. package/lib/simple-tree/toFlexSchema.js +61 -142
  513. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  514. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  515. package/lib/simple-tree/toMapTree.js +4 -4
  516. package/lib/simple-tree/toMapTree.js.map +1 -1
  517. package/lib/simple-tree/treeNodeValid.d.ts +13 -5
  518. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  519. package/lib/simple-tree/treeNodeValid.js +21 -12
  520. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  521. package/lib/simple-tree/typesUnsafe.d.ts +4 -4
  522. package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
  523. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  524. package/lib/simple-tree/walkFieldSchema.d.ts +11 -0
  525. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -0
  526. package/lib/simple-tree/walkFieldSchema.js +13 -0
  527. package/lib/simple-tree/walkFieldSchema.js.map +1 -0
  528. package/lib/util/index.d.ts +1 -1
  529. package/lib/util/index.d.ts.map +1 -1
  530. package/lib/util/index.js.map +1 -1
  531. package/lib/util/typeUtils.d.ts +14 -45
  532. package/lib/util/typeUtils.d.ts.map +1 -1
  533. package/lib/util/typeUtils.js.map +1 -1
  534. package/package.json +41 -22
  535. package/src/core/index.ts +1 -0
  536. package/src/core/rebase/index.ts +1 -0
  537. package/src/core/rebase/types.ts +11 -0
  538. package/src/core/schema-stored/schema.ts +18 -0
  539. package/src/core/tree/anchorSet.ts +3 -4
  540. package/src/core/tree/detachedFieldIndex.ts +14 -3
  541. package/src/core/tree/detachedFieldIndexTypes.ts +1 -1
  542. package/src/feature-libraries/editableTreeBinder.ts +2 -915
  543. package/src/feature-libraries/flex-tree/context.ts +7 -20
  544. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -18
  545. package/src/feature-libraries/flex-tree/lazyEntity.ts +1 -4
  546. package/src/feature-libraries/flex-tree/lazyField.ts +22 -78
  547. package/src/feature-libraries/flex-tree/lazyNode.ts +24 -39
  548. package/src/feature-libraries/flex-tree/utilities.ts +1 -1
  549. package/src/feature-libraries/index.ts +3 -71
  550. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +97 -10
  551. package/src/feature-libraries/sequence-field/compose.ts +3 -0
  552. package/src/feature-libraries/sequence-field/utils.ts +2 -4
  553. package/src/feature-libraries/typed-schema/flexList.ts +3 -84
  554. package/src/feature-libraries/typed-schema/index.ts +1 -33
  555. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +0 -458
  556. package/src/index.ts +7 -0
  557. package/src/internalTypes.ts +0 -1
  558. package/src/packageVersion.ts +1 -1
  559. package/src/shared-tree/checkoutFlexTreeView.ts +3 -3
  560. package/src/shared-tree/index.ts +4 -8
  561. package/src/shared-tree/schematizeTree.ts +2 -56
  562. package/src/shared-tree/schematizingTreeView.ts +38 -15
  563. package/src/shared-tree/sharedTree.ts +36 -8
  564. package/src/shared-tree/treeCheckout.ts +225 -128
  565. package/src/shared-tree-core/branch.ts +15 -26
  566. package/src/simple-tree/api/create.ts +18 -20
  567. package/src/simple-tree/api/getJsonSchema.ts +3 -3
  568. package/src/simple-tree/api/getSimpleSchema.ts +2 -2
  569. package/src/simple-tree/api/index.ts +2 -0
  570. package/src/simple-tree/api/jsonSchema.ts +19 -17
  571. package/src/simple-tree/api/schemaFactory.ts +53 -18
  572. package/src/simple-tree/api/schemaFactoryRecursive.ts +3 -6
  573. package/src/simple-tree/api/simpleSchema.ts +20 -10
  574. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +40 -19
  575. package/src/simple-tree/api/tree.ts +20 -9
  576. package/src/simple-tree/api/treeNodeApi.ts +12 -10
  577. package/src/simple-tree/api/verboseTree.ts +6 -12
  578. package/src/{feature-libraries/typed-schema → simple-tree/api}/view.ts +9 -22
  579. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +18 -4
  580. package/src/simple-tree/arrayNode.ts +202 -53
  581. package/src/simple-tree/core/context.ts +78 -0
  582. package/src/simple-tree/core/getOrCreateNode.ts +38 -0
  583. package/src/simple-tree/core/index.ts +11 -7
  584. package/src/simple-tree/core/schemaCaching.ts +13 -50
  585. package/src/simple-tree/core/treeNodeKernel.ts +117 -78
  586. package/src/simple-tree/core/treeNodeSchema.ts +35 -1
  587. package/src/simple-tree/core/types.ts +0 -5
  588. package/src/{feature-libraries/flex-map-tree/mapTreeNode.ts → simple-tree/core/unhydratedFlexTree.ts} +167 -210
  589. package/src/simple-tree/{walkSchema.ts → core/walkSchema.ts} +12 -34
  590. package/src/simple-tree/createContext.ts +24 -0
  591. package/src/simple-tree/index.ts +6 -2
  592. package/src/simple-tree/leafNodeSchema.ts +3 -9
  593. package/src/simple-tree/mapNode.ts +20 -17
  594. package/src/simple-tree/objectNode.ts +63 -38
  595. package/src/simple-tree/objectNodeTypes.ts +8 -5
  596. package/src/simple-tree/proxies.ts +8 -26
  597. package/src/simple-tree/schemaTypes.ts +55 -5
  598. package/src/simple-tree/toFlexSchema.ts +71 -204
  599. package/src/simple-tree/toMapTree.ts +5 -5
  600. package/src/simple-tree/treeNodeValid.ts +28 -22
  601. package/src/simple-tree/typesUnsafe.ts +4 -4
  602. package/src/simple-tree/walkFieldSchema.ts +19 -0
  603. package/src/util/index.ts +1 -5
  604. package/src/util/typeUtils.ts +14 -56
  605. package/dist/feature-libraries/fieldGenerator.d.ts +0 -43
  606. package/dist/feature-libraries/fieldGenerator.d.ts.map +0 -1
  607. package/dist/feature-libraries/fieldGenerator.js +0 -13
  608. package/dist/feature-libraries/fieldGenerator.js.map +0 -1
  609. package/dist/feature-libraries/flex-map-tree/index.d.ts +0 -6
  610. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +0 -1
  611. package/dist/feature-libraries/flex-map-tree/index.js +0 -14
  612. package/dist/feature-libraries/flex-map-tree/index.js.map +0 -1
  613. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -157
  614. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +0 -1
  615. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +0 -1
  616. package/dist/feature-libraries/storedToViewSchema.d.ts +0 -17
  617. package/dist/feature-libraries/storedToViewSchema.d.ts.map +0 -1
  618. package/dist/feature-libraries/storedToViewSchema.js +0 -67
  619. package/dist/feature-libraries/storedToViewSchema.js.map +0 -1
  620. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts +0 -58
  621. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +0 -1
  622. package/dist/feature-libraries/typed-schema/schemaCollection.js +0 -160
  623. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +0 -1
  624. package/dist/feature-libraries/typed-schema/typeUtils.d.ts +0 -15
  625. package/dist/feature-libraries/typed-schema/typeUtils.d.ts.map +0 -1
  626. package/dist/feature-libraries/typed-schema/typeUtils.js +0 -14
  627. package/dist/feature-libraries/typed-schema/typeUtils.js.map +0 -1
  628. package/dist/feature-libraries/typed-schema/view.d.ts.map +0 -1
  629. package/dist/feature-libraries/typed-schema/view.js.map +0 -1
  630. package/dist/simple-tree/getSimpleFieldSchema.d.ts +0 -14
  631. package/dist/simple-tree/getSimpleFieldSchema.d.ts.map +0 -1
  632. package/dist/simple-tree/getSimpleFieldSchema.js +0 -29
  633. package/dist/simple-tree/getSimpleFieldSchema.js.map +0 -1
  634. package/dist/simple-tree/walkSchema.d.ts.map +0 -1
  635. package/dist/simple-tree/walkSchema.js +0 -49
  636. package/dist/simple-tree/walkSchema.js.map +0 -1
  637. package/lib/feature-libraries/fieldGenerator.d.ts +0 -43
  638. package/lib/feature-libraries/fieldGenerator.d.ts.map +0 -1
  639. package/lib/feature-libraries/fieldGenerator.js +0 -12
  640. package/lib/feature-libraries/fieldGenerator.js.map +0 -1
  641. package/lib/feature-libraries/flex-map-tree/index.d.ts +0 -6
  642. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +0 -1
  643. package/lib/feature-libraries/flex-map-tree/index.js +0 -6
  644. package/lib/feature-libraries/flex-map-tree/index.js.map +0 -1
  645. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -157
  646. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +0 -1
  647. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +0 -1
  648. package/lib/feature-libraries/storedToViewSchema.d.ts +0 -17
  649. package/lib/feature-libraries/storedToViewSchema.d.ts.map +0 -1
  650. package/lib/feature-libraries/storedToViewSchema.js +0 -62
  651. package/lib/feature-libraries/storedToViewSchema.js.map +0 -1
  652. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts +0 -58
  653. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +0 -1
  654. package/lib/feature-libraries/typed-schema/schemaCollection.js +0 -153
  655. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +0 -1
  656. package/lib/feature-libraries/typed-schema/typeUtils.d.ts +0 -15
  657. package/lib/feature-libraries/typed-schema/typeUtils.d.ts.map +0 -1
  658. package/lib/feature-libraries/typed-schema/typeUtils.js +0 -10
  659. package/lib/feature-libraries/typed-schema/typeUtils.js.map +0 -1
  660. package/lib/feature-libraries/typed-schema/view.d.ts.map +0 -1
  661. package/lib/feature-libraries/typed-schema/view.js.map +0 -1
  662. package/lib/simple-tree/getSimpleFieldSchema.d.ts +0 -14
  663. package/lib/simple-tree/getSimpleFieldSchema.d.ts.map +0 -1
  664. package/lib/simple-tree/getSimpleFieldSchema.js +0 -25
  665. package/lib/simple-tree/getSimpleFieldSchema.js.map +0 -1
  666. package/lib/simple-tree/walkSchema.d.ts.map +0 -1
  667. package/lib/simple-tree/walkSchema.js +0 -43
  668. package/lib/simple-tree/walkSchema.js.map +0 -1
  669. package/src/feature-libraries/fieldGenerator.ts +0 -47
  670. package/src/feature-libraries/flex-map-tree/index.ts +0 -14
  671. package/src/feature-libraries/storedToViewSchema.ts +0 -100
  672. package/src/feature-libraries/typed-schema/schemaCollection.ts +0 -254
  673. package/src/feature-libraries/typed-schema/typeUtils.ts +0 -29
  674. package/src/simple-tree/getSimpleFieldSchema.ts +0 -36
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,aAAa,GAKb,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,UAAU,GAKV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,4BAA4B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OAAO,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAAsB;IACxD,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tcreateEmitter,\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\ttype Off,\n} from \"../../events/index.js\";\nimport type { TreeNode, Unhydrated } from \"./types.js\";\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tisFlexTreeNode,\n\tisFreedSymbol,\n\tisMapTreeNode,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n\ttype MapTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport { fail } from \"../../util/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\";\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/**\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 * When hydration occurs, the kernel is notified via the {@link TreeNodeKernel.hydrate | hydrate} method.\n */\nexport class TreeNodeKernel implements Listenable<KernelEvents> {\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#hydrated?: {\n\t\tanchorNode: AnchorNode;\n\t\toffAnchorNode: Set<Off>;\n\t};\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * As an optimization these are allocated lazily as they are usually unused.\n\t */\n\t#preHydrationEvents?: Listenable<KernelEvents> &\n\t\tIEmitter<KernelEvents> &\n\t\tHasListeners<KernelEvents>;\n\n\t/**\n\t * Get the listener.\n\t * @remarks\n\t * If before hydration, allocates and uses `#preHydrationEvents`, otherwise the anchorNode.\n\t * This design avoids allocating `#preHydrationEvents` if unneeded.\n\t *\n\t * This design also avoids extra forwarding overhead for events from anchorNode and also\n\t * 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 this code does not unconditionally subscribe to those events (like a design simply forwarding all events would).\n\t */\n\tget #events(): Listenable<KernelEvents> {\n\t\tif (this.#hydrated === undefined) {\n\t\t\tthis.#preHydrationEvents ??= createEmitter<KernelEvents>();\n\t\t\treturn this.#preHydrationEvents;\n\t\t} else {\n\t\t\treturn this.#hydrated.anchorNode;\n\t\t}\n\t}\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\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\tprivate innerNode: InnerNode,\n\t) {\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 (isMapTreeNode(innerNode)) {\n\t\t\t// Unhydrated case\n\t\t\tmapTreeNodeToProxy.set(innerNode, node);\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tassert(\n\t\t\t\t!innerNode.anchorNode.slots.has(proxySlot),\n\t\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t\t);\n\t\t\tthis.hydrate(innerNode.anchorNode);\n\t\t}\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the given anchor node.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link MapTreeNode} - it is assumed that they are no longer needed once the proxy has an anchor node.\n\t */\n\tpublic hydrate(anchorNode: AnchorNode): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(this.#hydrated === undefined, 0xa2b /* hydration should only happen once */);\n\n\t\t// If the this node is raw and thus has a MapTreeNode, forget it:\n\t\tif (isMapTreeNode(this.innerNode)) {\n\t\t\tmapTreeNodeToProxy.delete(this.innerNode);\n\t\t}\n\n\t\t// However, it's fine for an anchor node to rotate through different proxies when the content at that place in the tree is replaced.\n\t\tanchorNode.slots.set(proxySlot, this.node);\n\n\t\tthis.#hydrated = {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.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.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#preHydrationEvents !== undefined) {\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (this.#preHydrationEvents.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrated.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.on(eventName, (arg: any) =>\n\t\t\t\t\t\t\tthis.#preHydrationEvents?.emit(eventName, arg),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic isHydrated(): boolean {\n\t\tassert(!this.disposed, 0xa2c /* cannot use a disposed node */);\n\t\treturn this.#hydrated !== undefined;\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (this.#hydrated?.anchorNode === undefined) {\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.#hydrated.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[isFreedSymbol]()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrated.anchorNode);\n\t}\n\n\tpublic on<K extends keyof KernelEvents>(eventName: K, listener: KernelEvents[K]): Off {\n\t\treturn this.#events.on(eventName, listener);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tfor (const off of this.#hydrated?.offAnchorNode ?? []) {\n\t\t\toff();\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target via {@link setInnerNode}.\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\tpublic getOrCreateInnerNode(allowFreed = false): InnerNode {\n\t\tif (!isMapTreeNode(this.innerNode)) {\n\t\t\t// Cooked case\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\tif (this.#hydrated === undefined) {\n\t\t\t// Unhydrated case\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrated.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\tif (flexNode !== undefined) {\n\t\t\tthis.innerNode = flexNode;\n\t\t\treturn flexNode; // If it does have a flex node, return it...\n\t\t} // ...otherwise, the flex node must be created\n\t\tconst context = anchorNode.anchorSet.slots.get(ContextSlot) ?? fail(\"missing context\");\n\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\tconst newFlexNode = makeTree(context, cursor);\n\t\tcursor.free();\n\t\tthis.innerNode = newFlexNode;\n\t\t// Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode\n\t\tanchorForgetters?.get(this.node)?.();\n\t\tif (!allowFreed) {\n\t\t\tassertFlexTreeEntityNotFreed(newFlexNode);\n\t\t}\n\t\treturn newFlexNode;\n\t}\n\n\t/**\n\t * Creates an anchor node and associates it with the given proxy.\n\t * @privateRemarks\n\t * Use `forgetters` to cleanup the anchor allocated by this function once the anchor is no longer needed.\n\t * In practice, this happens when either the anchor node is destroyed, or another anchor to the same node is created by a new flex node.\n\t *\n\t * The FlexTreeNode holds a reference to the same anchor, and has a lifetime at least as long as the simple-tree,\n\t * so this would be unnecessary except for the case of \"marinated\" nodes, which have an anchor,\n\t * but might not have a FlexTreeNode.\n\t * Handling this case is an optimization assuming that this extra anchor reference is cheaper than eagerly creating FlexTreeNodes.\n\t */\n\tpublic anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {\n\t\tassert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode = anchors.locate(anchor) ?? fail(\"Expected anchor node to be present\");\n\t\tthis.hydrate(anchorNode);\n\t\tconst forget = (): void => {\n\t\t\tif (anchors.locate(anchor)) {\n\t\t\t\tanchors.forget(anchor);\n\t\t\t}\n\t\t\tanchorForgetters.delete(this.node);\n\t\t\toff();\n\t\t};\n\t\tanchorForgetters.set(this.node, forget);\n\t\tconst off = anchorNode.on(\"afterDestroy\", forget);\n\t\treturn anchorNode;\n\t}\n\n\t/**\n\t * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n\t * @remarks\n\t * If `target` is a unhydrated node, returns its MapTreeNode.\n\t * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n\t * If the target is not a node, or a marinated node with no FlexTreeNode for its anchor, returns undefined.\n\t */\n\tpublic tryGetInnerNode(): InnerNode | undefined {\n\t\tif (isFlexTreeNode(this.innerNode)) {\n\t\t\t// Cooked case\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\tif (this.#hydrated === undefined) {\n\t\t\t// Unhydrated case\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrated.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\treturn anchorNode.slots.get(flexTreeSlot);\n\t}\n}\n\n/**\n * Used by {@link anchorProxy} as an optimization to ensure that only one anchor is remembered at a time for a given anchor node\n */\nconst anchorForgetters = new WeakMap<TreeNode, () => void>();\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a FlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a MapTreeNode.\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 *\n * @remarks\n * Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.\n * TODO: Code should be migrating toward using this type to distinguish to two use-cases.\n *\n * TODO: The inconsistent handling of \"marinated\" cases should be cleaned up.\n * Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?\n */\nexport type InnerNode = FlexTreeNode | MapTreeNode;\n\n/**\n * {@inheritdoc proxyToMapTreeNode}\n */\nconst mapTreeNodeToProxy = new WeakMap<MapTreeNode, TreeNode>();\n\n/**\n * An anchor slot which associates an anchor with its corresponding 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 */\nconst proxySlot = anchorSlot<TreeNode>();\n\n/**\n * Retrieves the proxy associated with the given flex node via {@link setInnerNode}, if any.\n */\nexport function tryGetCachedTreeNode(flexNode: InnerNode): TreeNode | undefined {\n\tif (isMapTreeNode(flexNode)) {\n\t\t// Unhydrated case\n\t\treturn mapTreeNodeToProxy.get(flexNode);\n\t}\n\t// Hydrated case\n\treturn flexNode.anchorNode.slots.get(proxySlot);\n}\n\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(proxySlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t}\n}\n"]}
1
+ {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAA6B,MAAM,uBAAuB,CAAC;AAEjF,OAAO,EACN,UAAU,GAKV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,EACV,UAAU,EACV,yBAAyB,GAEzB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,0EAA0E;AAC1E,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAgB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAA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,CAAC;IAEF,MAAM,OAAO,GACZ,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAC1D,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter, type Listenable, type Off } from \"../../events/index.js\";\nimport type { TreeNode, Unhydrated } from \"./types.js\";\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tisFlexTreeNode,\n\tisFreedSymbol,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\nimport { fail } from \"../../util/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 { SimpleContextSlot, type Context } from \"./context.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 */\ntype UnhydratedState = Off;\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The {@link AnchorNode} that this node is associated with. */\n\tanchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\toffAnchorNode: 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 typeof state === \"object\";\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 * When hydration occurs, the kernel is notified via the {@link TreeNodeKernel.hydrate | hydrate} method.\n */\nexport class TreeNodeKernel implements Listenable<KernelEvents> {\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\tprivate innerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\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\tmapTreeNodeToProxy.set(innerNode, 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 = innerNode.events.on(\n\t\t\t\t\"childrenChangedAfterBatch\",\n\t\t\t\t({ 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 n: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (n !== undefined) {\n\t\t\t\t\t\tconst treeNode = mapTreeNodeToProxy.get(n);\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\t// This cast is safe because the parent (if it exists) of an unhydrated flex node is always another unhydrated flex node.\n\t\t\t\t\t\tn = n.parentField.parent.parent as UnhydratedFlexTreeNode | undefined;\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\tassert(\n\t\t\t\t!innerNode.anchorNode.slots.has(proxySlot),\n\t\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t\t);\n\t\t\tthis.hydrate(innerNode.anchorNode);\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(\"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 given anchor node.\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 the proxy has an anchor node.\n\t */\n\tpublic hydrate(anchorNode: AnchorNode): 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\t// If the this node is raw and thus has a MapTreeNode, forget it:\n\t\tif (this.innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\tmapTreeNodeToProxy.delete(this.innerNode);\n\t\t}\n\n\t\t// However, it's fine for an anchor node to rotate through different proxies when the content at that place in the tree is replaced.\n\t\tanchorNode.slots.set(proxySlot, this.node);\n\t\tthis.#hydrationState = {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.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.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\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.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\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[isFreedSymbol]()) {\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 on<K extends keyof KernelEvents>(eventName: K, listener: KernelEvents[K]): Off {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\tconst events: Listenable<KernelEvents> = isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode\n\t\t\t: this.#unhydratedEvents.value;\n\n\t\treturn events.on(eventName, listener);\n\t}\n\n\tpublic dispose(): void {\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\t/**\n\t * Retrieves the flex node associated with the given target via {@link setInnerNode}.\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\tpublic getOrCreateInnerNode(allowFreed = false): InnerNode {\n\t\tif (!(this.innerNode instanceof UnhydratedFlexTreeNode)) {\n\t\t\t// Cooked case\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\tif (flexNode !== undefined) {\n\t\t\tthis.innerNode = flexNode;\n\t\t\treturn flexNode; // If it does have a flex node, return it...\n\t\t} // ...otherwise, the flex node must be created\n\t\tconst context = anchorNode.anchorSet.slots.get(ContextSlot) ?? fail(\"missing context\");\n\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\tconst newFlexNode = makeTree(context, cursor);\n\t\tcursor.free();\n\t\tthis.innerNode = newFlexNode;\n\t\t// Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode\n\t\tanchorForgetters?.get(this.node)?.();\n\t\tif (!allowFreed) {\n\t\t\tassertFlexTreeEntityNotFreed(newFlexNode);\n\t\t}\n\t\treturn newFlexNode;\n\t}\n\n\t/**\n\t * Creates an anchor node and associates it with the given proxy.\n\t * @privateRemarks\n\t * Use `forgetters` to cleanup the anchor allocated by this function once the anchor is no longer needed.\n\t * In practice, this happens when either the anchor node is destroyed, or another anchor to the same node is created by a new flex node.\n\t *\n\t * The FlexTreeNode holds a reference to the same anchor, and has a lifetime at least as long as the simple-tree,\n\t * so this would be unnecessary except for the case of \"marinated\" nodes, which have an anchor,\n\t * but might not have a FlexTreeNode.\n\t * Handling this case is an optimization assuming that this extra anchor reference is cheaper than eagerly creating FlexTreeNodes.\n\t */\n\tpublic anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {\n\t\tassert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode = anchors.locate(anchor) ?? fail(\"Expected anchor node to be present\");\n\t\tthis.hydrate(anchorNode);\n\t\tconst forget = (): void => {\n\t\t\tif (anchors.locate(anchor)) {\n\t\t\t\tanchors.forget(anchor);\n\t\t\t}\n\t\t\tanchorForgetters.delete(this.node);\n\t\t\toff();\n\t\t};\n\t\tanchorForgetters.set(this.node, forget);\n\t\tconst off = anchorNode.on(\"afterDestroy\", forget);\n\t\treturn anchorNode;\n\t}\n\n\t/**\n\t * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n\t * @remarks\n\t * If `target` is a unhydrated node, returns its MapTreeNode.\n\t * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n\t * If the target is not a node, or a marinated node with no FlexTreeNode for its anchor, returns undefined.\n\t */\n\tpublic tryGetInnerNode(): InnerNode | undefined {\n\t\tif (isFlexTreeNode(this.innerNode)) {\n\t\t\t// Cooked case\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn this.innerNode;\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\treturn anchorNode.slots.get(flexTreeSlot);\n\t}\n}\n\n/**\n * Used by {@link anchorProxy} as an optimization to ensure that only one anchor is remembered at a time for a given anchor node\n */\nconst anchorForgetters = new WeakMap<TreeNode, () => void>();\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a FlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a MapTreeNode.\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 *\n * @remarks\n * Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.\n * TODO: Code should be migrating toward using this type to distinguish to two use-cases.\n *\n * TODO: The inconsistent handling of \"marinated\" cases should be cleaned up.\n * Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?\n */\nexport type InnerNode = FlexTreeNode | UnhydratedFlexTreeNode;\n\n/**\n * {@inheritdoc proxyToMapTreeNode}\n */\nexport const mapTreeNodeToProxy = new WeakMap<UnhydratedFlexTreeNode, TreeNode>();\n\n/**\n * An anchor slot which associates an anchor with its corresponding 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 proxySlot = anchorSlot<TreeNode>();\n\n/**\n * Retrieves the node associated with the given MapTreeNode node if any.\n */\nexport function tryGetTreeNodeFromMapNode(\n\tflexNode: UnhydratedFlexTreeNode,\n): TreeNode | undefined {\n\treturn mapTreeNodeToProxy.get(flexNode);\n}\n\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(proxySlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t}\n}\n\n/**\n * Lookup a TreeNodeSchema from a Hydrated FlexTreeNode.\n * @privateRemarks\n * This provides a way to access simple tree schema from the flex tree without depending on {@link FlexTreeSchema} which is in the process of being removed.\n * This is currently limited to hydrated nodes: this limitation will have to be fixed before {@link FlexTreeSchema} can be fully removed.\n */\nexport function getTreeNodeSchemaFromHydratedFlexNode(flexNode: FlexTreeNode): TreeNodeSchema {\n\tassert(\n\t\tflexNode.context.isHydrated(),\n\t\t\"getTreeNodeSchemaFromHydratedFlexNode only allows hydrated flex tree nodes\",\n\t);\n\n\tconst context =\n\t\tflexNode.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\tfail(\"Missing SimpleContextSlot\");\n\n\treturn context.schema.get(flexNode.schema) ?? fail(\"Missing schema\");\n}\n"]}
@@ -81,6 +81,10 @@ export interface TreeNodeSchemaClass<out Name extends string = string, out Kind
81
81
  */
82
82
  new (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;
83
83
  }
84
+ /**
85
+ * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.
86
+ */
87
+ export type TreeNodeSchemaBoth<Name extends string = string, Kind extends NodeKind = NodeKind, TNode = unknown, TInsertable = never, ImplicitlyConstructable extends boolean = boolean, Info = unknown> = TreeNodeSchemaClass<Name, Kind, TNode, TInsertable, ImplicitlyConstructable, Info> & TreeNodeSchemaNonClass<Name, Kind, TNode, TInsertable, ImplicitlyConstructable, Info>;
84
88
  /**
85
89
  * Data common to all tree node schema.
86
90
  * @remarks
@@ -119,6 +123,26 @@ export interface TreeNodeSchemaCore<out Name extends string, out Kind extends No
119
123
  * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.
120
124
  */
121
125
  readonly implicitlyConstructable: ImplicitlyConstructable;
126
+ /**
127
+ * All possible schema that a direct child of a node with this schema could have.
128
+ *
129
+ * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,
130
+ * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.
131
+ * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.
132
+ * @remarks
133
+ * Some kinds of nodes may have additional restrictions on children:
134
+ * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.
135
+ *
136
+ * This set cannot be used before the schema in it have been defined:
137
+ * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),
138
+ * users must wait until after the schema are defined to access this set.
139
+ * @privateRemarks
140
+ * Currently there isn't much use for this in the public API,
141
+ * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.
142
+ * To keep options option, this is marked `@system` for now.
143
+ * @system
144
+ */
145
+ readonly childTypes: ReadonlySet<TreeNodeSchema>;
122
146
  }
123
147
  /**
124
148
  * Kind of tree node.
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,CACzB,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,IAAI,SAAS,QAAQ,GAAG,QAAQ,EAChC,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,KAAK,EACd,uBAAuB,SAAS,OAAO,GAAG,OAAO,EACjD,IAAI,GAAG,OAAO,IAEZ,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAA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KG;AACH,MAAM,WAAW,kBAAkB,CAClC,GAAG,CAAC,IAAI,SAAS,MAAM,EACvB,GAAG,CAAC,IAAI,SAAS,QAAQ,EACzB,GAAG,CAAC,uBAAuB,SAAS,OAAO,EAC3C,GAAG,CAAC,IAAI,GAAG,OAAO;IAElB;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;;;;;;;;OASG;IACH,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAE1D;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;CACjD;AAED;;;;;GAKG;AACH,oBAAY,QAAQ;IACnB;;OAEG;IACH,GAAG,IAAA;IACH;;OAEG;IACH,KAAK,IAAA;IACL;;;;OAIG;IACH,MAAM,IAAA;IACN;;OAEG;IACH,IAAI,IAAA;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2JH;;;;;GAKG;AACH,MAAM,CAAN,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAG,CAAA;IACH;;OAEG;IACH,yCAAK,CAAA;IACL;;;;OAIG;IACH,2CAAM,CAAA;IACN;;OAEG;IACH,uCAAI,CAAA;AACL,CAAC,EAnBW,QAAQ,KAAR,QAAQ,QAmBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a tree node.\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode = unknown,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n> =\n\t| TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t| TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport interface TreeNodeSchemaNonClass<\n\tout Name extends string = string,\n\tout Kind extends NodeKind = NodeKind,\n\tout TNode = unknown,\n\tin TInsertable = never,\n\tout ImplicitlyConstructable extends boolean = boolean,\n\tout Info = unknown,\n> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {\n\tcreate(data: TInsertable): TNode;\n}\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport interface TreeNodeSchemaClass<\n\tout Name extends string = string,\n\tout Kind extends NodeKind = NodeKind,\n\tout TNode = unknown,\n\tin TInsertable = never,\n\tout ImplicitlyConstructable extends boolean = boolean,\n\tout Info = unknown,\n> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {\n\t/**\n\t * Constructs an {@link Unhydrated} node with this schema.\n\t * @remarks\n\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t * @sealed\n\t */\n\tnew (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;\n}\n/**\n * Data common to all tree node schema.\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n * @sealed @public\n */\n\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\treadonly kind: Kind;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf,\n}\n"]}
1
+ {"version":3,"file":"treeNodeSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6LH;;;;;GAKG;AACH,MAAM,CAAN,IAAY,QAmBX;AAnBD,WAAY,QAAQ;IACnB;;OAEG;IACH,qCAAG,CAAA;IACH;;OAEG;IACH,yCAAK,CAAA;IACL;;;;OAIG;IACH,2CAAM,CAAA;IACN;;OAEG;IACH,uCAAI,CAAA;AACL,CAAC,EAnBW,QAAQ,KAAR,QAAQ,QAmBnB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { InternalTreeNode, Unhydrated } from \"./types.js\";\n\n/**\n * Schema for a tree node.\n * @typeParam Name - The full (including scope) name/identifier for the schema.\n * @typeParam Kind - Which kind of node this schema is for.\n * @typeParam TNode - API for nodes that use this schema.\n * @typeParam TBuild - Data which can be used to construct an {@link Unhydrated} node of this type.\n * @typeParam Info - Data used when defining this schema.\n * @remarks\n * Captures the schema both as runtime data and compile time type information.\n * @sealed @public\n */\nexport type TreeNodeSchema<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode = unknown,\n\tTBuild = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n> =\n\t| TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t| TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;\n\n/**\n * Schema which is not a class.\n * @remarks\n * This is used for schema which cannot have their instances constructed using constructors, like leaf schema.\n * @privateRemarks\n * Non-class based schema can have issues with recursive types due to https://github.com/microsoft/TypeScript/issues/55832.\n * @system @sealed @public\n */\nexport interface TreeNodeSchemaNonClass<\n\tout Name extends string = string,\n\tout Kind extends NodeKind = NodeKind,\n\tout TNode = unknown,\n\tin TInsertable = never,\n\tout ImplicitlyConstructable extends boolean = boolean,\n\tout Info = unknown,\n> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {\n\tcreate(data: TInsertable): TNode;\n}\n\n/**\n * Tree node schema which is implemented using a class.\n * @remarks\n * Instances of this class are nodes in the tree.\n * This is also a constructor so that it can be subclassed.\n *\n * Using classes in this way allows introducing a named type and a named value at the same time, helping keep the runtime and compile time information together and easy to refer to un a uniform way.\n * Additionally, this works around https://github.com/microsoft/TypeScript/issues/55832 which causes similar patterns with less explicit types to infer \"any\" in the d.ts file.\n *\n * When sub-classing a a `TreeNodeSchemaClass`, some extra rules must be followed:\n *\n * - Only ever use a single class from the schema's class hierarchy within a document and its schema.\n * For example, if using {@link SchemaFactory.object} you can do:\n * ```typescript\n * // Recommended \"customizable\" object schema pattern.\n * class Good extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \tpublic exampleCustomMethod(): void {\n * \t\tthis.exampleField++;\n * \t}\n * }\n * ```\n * But should avoid:\n * ```typescript\n * // This by itself is ok, and opts into \"POJO mode\".\n * const base = schemaFactory.object(\"A\", {});\n * // This is a bad pattern since it leaves two classes in scope which derive from the same SchemaFactory defined class.\n * // If both get used, its an error!\n * class Invalid extends base {}\n * ```\n * - Do not modify the constructor input parameter types or values:\n * ```typescript\n * class Invalid extends schemaFactory.object(\"A\", {\n * \texampleField: schemaFactory.number,\n * }) {\n * \t// This Modifies the type of the constructor input.\n * \t// This is unsupported due to programmatic access to the constructor being used internally.\n * \tpublic constructor(a: number) {\n * \t\tsuper({ exampleField: a });\n * \t}\n * }\n * ```\n * @sealed @public\n */\nexport interface TreeNodeSchemaClass<\n\tout Name extends string = string,\n\tout Kind extends NodeKind = NodeKind,\n\tout TNode = unknown,\n\tin TInsertable = never,\n\tout ImplicitlyConstructable extends boolean = boolean,\n\tout Info = unknown,\n> extends TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info> {\n\t/**\n\t * Constructs an {@link Unhydrated} node with this schema.\n\t * @remarks\n\t * This constructor is also used internally to construct hydrated nodes with a different parameter type.\n\t * Therefore, overriding this constructor with different argument types is not type-safe and is not supported.\n\t * @sealed\n\t */\n\tnew (data: TInsertable | InternalTreeNode): Unhydrated<TNode>;\n}\n\n/**\n * Internal helper for utilities that return schema which can be used in class and non class formats depending on the API exposing it.\n */\nexport type TreeNodeSchemaBoth<\n\tName extends string = string,\n\tKind extends NodeKind = NodeKind,\n\tTNode = unknown,\n\tTInsertable = never,\n\tImplicitlyConstructable extends boolean = boolean,\n\tInfo = unknown,\n> = TreeNodeSchemaClass<Name, Kind, TNode, TInsertable, ImplicitlyConstructable, Info> &\n\tTreeNodeSchemaNonClass<Name, Kind, TNode, TInsertable, ImplicitlyConstructable, Info>;\n\n/**\n * Data common to all tree node schema.\n * @remarks\n * Implementation detail of {@link TreeNodeSchema} which should be accessed instead of referring to this type directly.\n * @sealed @public\n */\nexport interface TreeNodeSchemaCore<\n\tout Name extends string,\n\tout Kind extends NodeKind,\n\tout ImplicitlyConstructable extends boolean,\n\tout Info = unknown,\n> {\n\t/**\n\t * Unique (within a document's schema) identifier used to associate nodes with their schema.\n\t * @remarks\n\t * This is used when encoding nodes, and when decoding nodes to re-associate them with the schema.\n\t * Since this decoding may happen in a different version of the application (or even a different application altogether),\n\t * this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier).\n\t * Any time the semantics change such that data would be misinterpreted if the old semantics were applied\n\t * (for example the units of a value are changed),\n\t * it is best practice to pick a new identifier.\n\t */\n\treadonly identifier: Name;\n\treadonly kind: Kind;\n\n\t/**\n\t * Data used to define this schema.\n\t *\n\t * @remarks\n\t * The format depends on the kind of node it is for.\n\t * For example, the \"object\" node kind could store the field schema here.\n\t */\n\treadonly info: Info;\n\n\t/**\n\t * When constructing insertable content,\n\t * data that could be passed to the node's constructor can be used instead of an {@link Unhydrated} node\n\t * iff implicitlyConstructable is true.\n\t * @privateRemarks\n\t * Currently the logic for traversing insertable content,\n\t * both to build trees and to hydrate them does not defer to the schema classes to handle the policy,\n\t * so if their constructors differ from what is supported, some cases will not work.\n\t * Setting this to false adjusts the insertable types to disallow cases which could be impacted by these inconsistencies.\n\t */\n\treadonly implicitlyConstructable: ImplicitlyConstructable;\n\n\t/**\n\t * All possible schema that a direct child of a node with this schema could have.\n\t *\n\t * Equivalently, this is also all schema directly referenced when defining this schema's allowed child types,\n\t * which is also the same as the set of schema referenced directly by the `Info` type parameter and the `info` property.\n\t * This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.\n\t * @remarks\n\t * Some kinds of nodes may have additional restrictions on children:\n\t * this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.\n\t *\n\t * This set cannot be used before the schema in it have been defined:\n\t * more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined),\n\t * users must wait until after the schema are defined to access this set.\n\t * @privateRemarks\n\t * Currently there isn't much use for this in the public API,\n\t * and it's possible this will want to be tweaked or renamed as part of a larger schema reflection API surface that might be added later.\n\t * To keep options option, this is marked `@system` for now.\n\t * @system\n\t */\n\treadonly childTypes: ReadonlySet<TreeNodeSchema>;\n}\n\n/**\n * Kind of tree node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum NodeKind {\n\t/**\n\t * A node which serves as a map, storing children under string keys.\n\t */\n\tMap,\n\t/**\n\t * A node which serves as an array, storing children in an ordered sequence.\n\t */\n\tArray,\n\t/**\n\t * A node which stores a heterogenous collection of children in named fields.\n\t * @remarks\n\t * Each field gets its own schema.\n\t */\n\tObject,\n\t/**\n\t * A node which stores a single leaf value.\n\t */\n\tLeaf,\n}\n"]}
@@ -24,11 +24,6 @@ export type Unhydrated<T> = T;
24
24
  /**
25
25
  * A collection of events that can be emitted by a {@link TreeNode}.
26
26
  *
27
- * @remarks
28
- * Currently, events can be subscribed to for {@link Unhydrated} nodes, however no events will be triggered for the nodes until after they are hydrated.
29
- * This is considered a known issue, and should be fixed in future versions.
30
- * Do not rely on the fact that editing unhydrated nodes does not trigger their events.
31
- *
32
27
  * @privateRemarks
33
28
  * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).
34
29
  * Probably have object node and map node specific APIs for this.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAErF,OAAO,EA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AO,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;OAOG;IACH,YAAsB,KAAc;QArFpC;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACM,kCAAiB;QA4DzB,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YAC5B,MAAM,IAAI,UAAU,CAAC,+DAA+D,CAAC,CAAC;QACvF,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,kDAAkD;AAClD,MAAM,UAAU,gBAAgB,CAAC,OAAsB,EAAE,IAAY;IACpE,IAAI,QAAQ,GAAG,OAAO,CAAC;IACvB,OAAO,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACb,CAAC;QACD,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAaD,MAAM,UAAU,cAAc,CAAC,IAAsB;IACpD,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACnE,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\n\nimport { NodeKind, type TreeNodeSchemaClass } from \"./treeNodeSchema.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { type WithType, typeNameSymbol, type typeSchemaSymbol } from \"./withType.js\";\nimport { tryGetTreeNodeSchema } from \"./treeNodeKernel.js\";\nimport { isFlexTreeNode, type FlexTreeNode } from \"../../feature-libraries/index.js\";\n\n/**\n * Type alias to document which values are un-hydrated.\n *\n * Un-hydrated values are nodes produced from schema's create functions that haven't been inserted into a tree yet.\n *\n * Since un-hydrated nodes become hydrated when inserted, strong typing can't be used to distinguish them.\n * This no-op wrapper is used instead.\n * @remarks\n * Nodes which are Unhydrated report {@link TreeStatus}.new from `Tree.status(node)`.\n * @privateRemarks\n * TODO: Linking tree status is failing in intellisense and linking directly to its .new item is failing in API extractor as well.\n * WOuld be nice to have a working link here.\n * @public\n */\nexport type Unhydrated<T> = T;\n\n/**\n * A collection of events that can be emitted by a {@link TreeNode}.\n *\n * @remarks\n * Currently, events can be subscribed to for {@link Unhydrated} nodes, however no events will be triggered for the nodes until after they are hydrated.\n * This is considered a known issue, and should be fixed in future versions.\n * Do not rely on the fact that editing unhydrated nodes does not trigger their events.\n *\n * @privateRemarks\n * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).\n * Probably have object node and map node specific APIs for this.\n *\n * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.\n *\n * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.\n * Some ideas:\n *\n * - treeChanged, but with some subtrees/fields/paths excluded\n * - helper to batch several nodeChanged calls to a treeChanged scope\n * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)\n * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.\n * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)\n * to allow efficiently searching for new content (and initial content) of a given type.\n *\n * @sealed @public\n */\nexport interface TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.\n\t * users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.\n\t * This parameter exists to capture this fact in the type system.\n\t * Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t */\n\tnodeChanged(unstable?: unknown): void;\n\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the\n\t * subtree rooted at it.\n\t *\n\t * @remarks\n\t * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.\n\t * In that case it is emitted on the _parent_ node, not the node itself.\n\t *\n\t * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties\n\t * of the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When it is emitted, the tree is guaranteed to be in-schema.\n\t */\n\ttreeChanged(): void;\n}\n\n/**\n * A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.\n *\n * @remarks\n * Base type which all nodes implement.\n *\n * This can be used as a type to indicate/document values which should be tree nodes.\n * Runtime use of this class object (for example when used with `instanceof` or extending it), is not currently supported.\n *\n * Instances of tree nodes must be created by opening an existing document, inserting values into the document,\n * or by using the constructors and create functions of {@link TreeNodeSchema} produced by {@link SchemaFactory}.\n * @privateRemarks\n * This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})\n * and some runtime enforcement of schema class policy (see the the validation in the constructor).\n * This class is however only `type` exported not value exported, preventing the class object from being used,\n * similar to how interfaces work.\n *\n * Not all node implementations include this in their prototype chain (some hide it with a proxy),\n * and thus cause the default/built in `instanceof` to return false despite our type checking and all other APIs treating them as TreeNodes.\n * This class provides a custom `Symbol.hasInstance` to fix `instanceof` for this class and all classes extending it.\n * For now the type-only export prevents use of `instanceof` on this class (but allows it in subclasses like schema classes).\n * @sealed @public\n */\nexport abstract class TreeNode implements WithType {\n\t/**\n\t * This is added to prevent TypeScript from implicitly allowing non-TreeNode types to be used as TreeNodes.\n\t * @remarks\n\t * This field forces TypeScript to use nominal instead of structural typing,\n\t * preventing compiler error messages and tools like \"add missing properties\"\n\t * from adding the [type] field as a solution when using a non-TreeNode object where a TreeNode is required.\n\t * Instead TreeNodes must be created through the appropriate APIs, see the documentation on {@link TreeNode} for details.\n\t *\n\t * @privateRemarks\n\t * This is a JavaScript private field, so is not accessible from outside this class.\n\t * This prevents it from having name collisions with object fields.\n\t * Since this is private, the type of this field is stripped in the d.ts file.\n\t * To get matching type checking within and from outside the package, the least informative type (`unknown`) is used.\n\t * To avoid this having any runtime impact, the field is uninitialized.\n\t *\n\t * Making this field optional results in different type checking within this project than outside of it, since the d.ts file drops the optional aspect of the field.\n\t * This is extra confusing since since the tests get in-project typing for intellisense and separate project checking at build time.\n\t * To avoid all this mess, this field is required, not optional.\n\t *\n\t * Another option would be to use a symbol (possibly as a private field).\n\t * That approach ran into some strange difficulties causing SchemaFactory to fail to compile, and was not investigated further.\n\t *\n\t * The [type] symbol provides a lot of the value this private brand does, but is not all of it:\n\t * someone could manually (or via Intellisense auto-implement completion, or in response to a type error)\n\t * make an object literal with the [type] field and pass it off as a node: this private brand prevents that.\n\t */\n\treadonly #brand!: unknown;\n\n\t/**\n\t * Adds a type symbol for stronger typing.\n\t * @privateRemarks\n\t * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.\n\t * @deprecated Use {@link typeSchemaSymbol} instead.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic abstract get [typeNameSymbol](): string;\n\n\t/**\n\t * Adds a type symbol for stronger typing.\n\t * @privateRemarks\n\t * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.\n\t */\n\tpublic abstract get [typeSchemaSymbol](): TreeNodeSchemaClass;\n\n\t/**\n\t * Provides `instanceof` support for testing if a value is a `TreeNode`.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Due to type-only export, this functionality is not available outside the package.\n\t */\n\tpublic static [Symbol.hasInstance](value: unknown): value is TreeNode;\n\n\t/**\n\t * Provides `instanceof` support for all schema classes with public constructors.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Despite type-only export, this functionality is available outside the package since it is inherited by subclasses.\n\t */\n\tpublic static [Symbol.hasInstance]<\n\t\tTSchema extends abstract new (\n\t\t\t...args: any[]\n\t\t) => TreeNode,\n\t>(this: TSchema, value: unknown): value is InstanceType<TSchema>;\n\n\tpublic static [Symbol.hasInstance](this: { prototype: object }, value: unknown): boolean {\n\t\tconst schema = tryGetTreeNodeSchema(value);\n\n\t\tif (schema === undefined || schema.kind === NodeKind.Leaf) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(\"prototype\" in schema, 0x98a /* expected class based schema */);\n\t\treturn inPrototypeChain(schema.prototype, this.prototype);\n\t}\n\n\t/**\n\t * TreeNodes must extend schema classes created by SchemaFactory, and therefore this constructor should not be invoked directly by code outside this package.\n\t * @privateRemarks\n\t * `token` must be the {@link privateToken} value, which is not package exported.\n\t * This is used to detect invalid subclasses.\n\t *\n\t * All valid subclass should use {@link TreeNodeValid}, but this code doesn't directly reference it to avoid cyclic dependencies.\n\t */\n\tprotected constructor(token: unknown) {\n\t\tif (token !== privateToken) {\n\t\t\tthrow new UsageError(\"TreeNodes must extend schema classes created by SchemaFactory\");\n\t\t}\n\t}\n}\n\n/**\n * `token` to pass to {@link TreeNode}'s constructor used to detect invalid subclasses.\n */\nexport const privateToken = {};\n\n/**\n * Check if the prototype derived's prototype chain contains `base`.\n * @param derived - prototype to check\n * @param base - prototype to search for\n * @returns true iff `base` is in the prototype chain starting at `derived`.\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function inPrototypeChain(derived: object | null, base: object): boolean {\n\tlet checking = derived;\n\twhile (checking !== null) {\n\t\tif (base === checking) {\n\t\t\treturn true;\n\t\t}\n\t\tchecking = Reflect.getPrototypeOf(checking);\n\t}\n\treturn false;\n}\n\n/**\n * A node type internal to `@fluidframework/tree`.\n * @remarks\n * This type is used in the construction of {@link TreeNode} as an implementation detail, but leaks into the public API due to how schema are implemented.\n * @privateRemarks\n * A {@link FlexTreeNode}. Includes {@link RawTreeNode}s.\n * @sealed @public\n */\nexport interface InternalTreeNode\n\textends ErasedType<\"@fluidframework/tree.InternalTreeNode\"> {}\n\nexport function toFlexTreeNode(node: InternalTreeNode): FlexTreeNode {\n\tassert(isFlexTreeNode(node), 0x963 /* Invalid InternalTreeNode */);\n\treturn node;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/simple-tree/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAGtE,OAAO,EAAE,QAAQ,EAA4B,MAAM,qBAAqB,CAA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CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAaD,MAAM,UAAU,cAAc,CAAC,IAAsB;IACpD,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACnE,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\n\nimport { NodeKind, type TreeNodeSchemaClass } from \"./treeNodeSchema.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { type WithType, typeNameSymbol, type typeSchemaSymbol } from \"./withType.js\";\nimport { tryGetTreeNodeSchema } from \"./treeNodeKernel.js\";\nimport { isFlexTreeNode, type FlexTreeNode } from \"../../feature-libraries/index.js\";\n\n/**\n * Type alias to document which values are un-hydrated.\n *\n * Un-hydrated values are nodes produced from schema's create functions that haven't been inserted into a tree yet.\n *\n * Since un-hydrated nodes become hydrated when inserted, strong typing can't be used to distinguish them.\n * This no-op wrapper is used instead.\n * @remarks\n * Nodes which are Unhydrated report {@link TreeStatus}.new from `Tree.status(node)`.\n * @privateRemarks\n * TODO: Linking tree status is failing in intellisense and linking directly to its .new item is failing in API extractor as well.\n * WOuld be nice to have a working link here.\n * @public\n */\nexport type Unhydrated<T> = T;\n\n/**\n * A collection of events that can be emitted by a {@link TreeNode}.\n *\n * @privateRemarks\n * TODO: add a way to subscribe to a specific field (for nodeChanged and treeChanged).\n * Probably have object node and map node specific APIs for this.\n *\n * TODO: ensure that subscription API for fields aligns with API for subscribing to the root.\n *\n * TODO: add more wider area (avoid needing tons of nodeChanged registration) events for use-cases other than treeChanged.\n * Some ideas:\n *\n * - treeChanged, but with some subtrees/fields/paths excluded\n * - helper to batch several nodeChanged calls to a treeChanged scope\n * - parent change (ex: registration on the parent field for a specific index: maybe allow it for a range. Ex: node event takes optional field and optional index range?)\n * - new content inserted into subtree. Either provide event for this and/or enough info to treeChanged to find and search the new sub-trees.\n * Add separate (non event related) API to efficiently scan tree for given set of types (using low level cursor and schema based filtering)\n * to allow efficiently searching for new content (and initial content) of a given type.\n *\n * @sealed @public\n */\nexport interface TreeChangeEvents {\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, if any of the changes affected the node.\n\t *\n\t * - Object nodes define a change as being when the value of one of its properties changes (i.e., the property's value is set, including when set to `undefined`).\n\t *\n\t * - Array nodes define a change as when an element is added, removed, moved or replaced.\n\t *\n\t * - Map nodes define a change as when an entry is added, updated, or removed.\n\t *\n\t * @param unstable - Future versions of this API (such as the one in beta on TreeBeta) may use this argument to provide additional data to the event.\n\t * users of this event should ensure that they do not provide a listener callback which has an optional parameter in this position, since unexpected data might get provided to it.\n\t * This parameter exists to capture this fact in the type system.\n\t * Using an inline lambda expression as the listener callback is a good pattern to avoid cases like this were arguments are added from breaking due to optional arguments.\n\t *\n\t * @remarks\n\t * This event is not emitted when:\n\t *\n\t * - Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing\n\t * elements/entries) will emit this event on the array/map node itself, but not on the node that contains the\n\t * array/map node as one of its properties.\n\t *\n\t * - The node is moved to a different location in the tree or removed from the tree.\n\t * In this case the event is emitted on the _parent_ node, not the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When the event is emitted, the tree is guaranteed to be in-schema.\n\t *\n\t * @privateRemarks\n\t * This event occurs whenever the apparent contents of the node instance change, regardless of what caused the change.\n\t * For example, it will fire when the local client reassigns a child, when part of a remote edit is applied to the\n\t * node, or when the node has to be updated due to resolution of a merge conflict\n\t * (for example a previously applied local change might be undone, then reapplied differently or not at all).\n\t *\n\t * TODO: define and document event ordering (ex: bottom up, with nodeChanged before treeChange on each level).\n\t */\n\tnodeChanged(unstable?: unknown): void;\n\n\t/**\n\t * Emitted by a node after a batch of changes has been applied to the tree, when something changed anywhere in the\n\t * subtree rooted at it.\n\t *\n\t * @remarks\n\t * This event is not emitted when the node itself is moved to a different location in the tree or removed from the tree.\n\t * In that case it is emitted on the _parent_ node, not the node itself.\n\t *\n\t * The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties\n\t * of the node itself.\n\t *\n\t * For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in\n\t * the client that made the original edit.\n\t *\n\t * When it is emitted, the tree is guaranteed to be in-schema.\n\t */\n\ttreeChanged(): void;\n}\n\n/**\n * A non-{@link NodeKind.Leaf|leaf} SharedTree node. Includes objects, arrays, and maps.\n *\n * @remarks\n * Base type which all nodes implement.\n *\n * This can be used as a type to indicate/document values which should be tree nodes.\n * Runtime use of this class object (for example when used with `instanceof` or extending it), is not currently supported.\n *\n * Instances of tree nodes must be created by opening an existing document, inserting values into the document,\n * or by using the constructors and create functions of {@link TreeNodeSchema} produced by {@link SchemaFactory}.\n * @privateRemarks\n * This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})\n * and some runtime enforcement of schema class policy (see the the validation in the constructor).\n * This class is however only `type` exported not value exported, preventing the class object from being used,\n * similar to how interfaces work.\n *\n * Not all node implementations include this in their prototype chain (some hide it with a proxy),\n * and thus cause the default/built in `instanceof` to return false despite our type checking and all other APIs treating them as TreeNodes.\n * This class provides a custom `Symbol.hasInstance` to fix `instanceof` for this class and all classes extending it.\n * For now the type-only export prevents use of `instanceof` on this class (but allows it in subclasses like schema classes).\n * @sealed @public\n */\nexport abstract class TreeNode implements WithType {\n\t/**\n\t * This is added to prevent TypeScript from implicitly allowing non-TreeNode types to be used as TreeNodes.\n\t * @remarks\n\t * This field forces TypeScript to use nominal instead of structural typing,\n\t * preventing compiler error messages and tools like \"add missing properties\"\n\t * from adding the [type] field as a solution when using a non-TreeNode object where a TreeNode is required.\n\t * Instead TreeNodes must be created through the appropriate APIs, see the documentation on {@link TreeNode} for details.\n\t *\n\t * @privateRemarks\n\t * This is a JavaScript private field, so is not accessible from outside this class.\n\t * This prevents it from having name collisions with object fields.\n\t * Since this is private, the type of this field is stripped in the d.ts file.\n\t * To get matching type checking within and from outside the package, the least informative type (`unknown`) is used.\n\t * To avoid this having any runtime impact, the field is uninitialized.\n\t *\n\t * Making this field optional results in different type checking within this project than outside of it, since the d.ts file drops the optional aspect of the field.\n\t * This is extra confusing since since the tests get in-project typing for intellisense and separate project checking at build time.\n\t * To avoid all this mess, this field is required, not optional.\n\t *\n\t * Another option would be to use a symbol (possibly as a private field).\n\t * That approach ran into some strange difficulties causing SchemaFactory to fail to compile, and was not investigated further.\n\t *\n\t * The [type] symbol provides a lot of the value this private brand does, but is not all of it:\n\t * someone could manually (or via Intellisense auto-implement completion, or in response to a type error)\n\t * make an object literal with the [type] field and pass it off as a node: this private brand prevents that.\n\t */\n\treadonly #brand!: unknown;\n\n\t/**\n\t * Adds a type symbol for stronger typing.\n\t * @privateRemarks\n\t * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.\n\t * @deprecated Use {@link typeSchemaSymbol} instead.\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic abstract get [typeNameSymbol](): string;\n\n\t/**\n\t * Adds a type symbol for stronger typing.\n\t * @privateRemarks\n\t * Subclasses provide more specific strings for this to get strong typing of otherwise type compatible nodes.\n\t */\n\tpublic abstract get [typeSchemaSymbol](): TreeNodeSchemaClass;\n\n\t/**\n\t * Provides `instanceof` support for testing if a value is a `TreeNode`.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Due to type-only export, this functionality is not available outside the package.\n\t */\n\tpublic static [Symbol.hasInstance](value: unknown): value is TreeNode;\n\n\t/**\n\t * Provides `instanceof` support for all schema classes with public constructors.\n\t * @remarks\n\t * For more options, like including leaf values or narrowing to collections of schema, use `is` or `schema` from {@link TreeNodeApi}.\n\t * @privateRemarks\n\t * Despite type-only export, this functionality is available outside the package since it is inherited by subclasses.\n\t */\n\tpublic static [Symbol.hasInstance]<\n\t\tTSchema extends abstract new (\n\t\t\t...args: any[]\n\t\t) => TreeNode,\n\t>(this: TSchema, value: unknown): value is InstanceType<TSchema>;\n\n\tpublic static [Symbol.hasInstance](this: { prototype: object }, value: unknown): boolean {\n\t\tconst schema = tryGetTreeNodeSchema(value);\n\n\t\tif (schema === undefined || schema.kind === NodeKind.Leaf) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(\"prototype\" in schema, 0x98a /* expected class based schema */);\n\t\treturn inPrototypeChain(schema.prototype, this.prototype);\n\t}\n\n\t/**\n\t * TreeNodes must extend schema classes created by SchemaFactory, and therefore this constructor should not be invoked directly by code outside this package.\n\t * @privateRemarks\n\t * `token` must be the {@link privateToken} value, which is not package exported.\n\t * This is used to detect invalid subclasses.\n\t *\n\t * All valid subclass should use {@link TreeNodeValid}, but this code doesn't directly reference it to avoid cyclic dependencies.\n\t */\n\tprotected constructor(token: unknown) {\n\t\tif (token !== privateToken) {\n\t\t\tthrow new UsageError(\"TreeNodes must extend schema classes created by SchemaFactory\");\n\t\t}\n\t}\n}\n\n/**\n * `token` to pass to {@link TreeNode}'s constructor used to detect invalid subclasses.\n */\nexport const privateToken = {};\n\n/**\n * Check if the prototype derived's prototype chain contains `base`.\n * @param derived - prototype to check\n * @param base - prototype to search for\n * @returns true iff `base` is in the prototype chain starting at `derived`.\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function inPrototypeChain(derived: object | null, base: object): boolean {\n\tlet checking = derived;\n\twhile (checking !== null) {\n\t\tif (base === checking) {\n\t\t\treturn true;\n\t\t}\n\t\tchecking = Reflect.getPrototypeOf(checking);\n\t}\n\treturn false;\n}\n\n/**\n * A node type internal to `@fluidframework/tree`.\n * @remarks\n * This type is used in the construction of {@link TreeNode} as an implementation detail, but leaks into the public API due to how schema are implemented.\n * @privateRemarks\n * A {@link FlexTreeNode}. Includes {@link RawTreeNode}s.\n * @sealed @public\n */\nexport interface InternalTreeNode\n\textends ErasedType<\"@fluidframework/tree.InternalTreeNode\"> {}\n\nexport function toFlexTreeNode(node: InternalTreeNode): FlexTreeNode {\n\tassert(isFlexTreeNode(node), 0x963 /* Invalid InternalTreeNode */);\n\treturn node;\n}\n"]}
@@ -0,0 +1,139 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type AnchorEvents, type AnchorNode, type ExclusiveMapTree, type FieldKey, type FieldKindIdentifier, type FieldUpPath, type MapTree, type SchemaPolicy, type TreeNodeSchemaIdentifier, type TreeNodeStoredSchema, type TreeStoredSchema, type Value } from "../../core/index.js";
6
+ import { type FlexTreeContext, FlexTreeEntityKind, type FlexTreeField, type FlexTreeNode, type FlexTreeSequenceField, type FlexTreeTypedField, type FlexTreeUnknownUnboxed, flexTreeMarker, type FlexTreeHydratedContext, type FlexFieldKind, type SequenceFieldEditBuilder } from "../../feature-libraries/index.js";
7
+ import type { Context } from "./context.js";
8
+ import { type Listenable } from "../../events/index.js";
9
+ interface UnhydratedTreeSequenceFieldEditBuilder extends SequenceFieldEditBuilder<ExclusiveMapTree[]> {
10
+ /**
11
+ * Issues a change which removes `count` elements starting at the given `index`.
12
+ * @param index - The index of the first removed element.
13
+ * @param count - The number of elements to remove.
14
+ * @returns the MapTrees that were removed
15
+ */
16
+ remove(index: number, count: number): ExclusiveMapTree[];
17
+ }
18
+ type UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, "childrenChangedAfterBatch">;
19
+ /** A node's parent field and its index in that field */
20
+ interface LocationInField {
21
+ readonly parent: FlexTreeField;
22
+ readonly index: number;
23
+ }
24
+ /**
25
+ * An unhydrated implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.
26
+ * @remarks
27
+ * MapTreeNodes are unconditionally cached -
28
+ * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `UnhydratedFlexTreeNode` object.
29
+ *
30
+ * Create a `UnhydratedFlexTreeNode` by calling {@link getOrCreate}.
31
+ */
32
+ export declare class UnhydratedFlexTreeNode implements UnhydratedFlexTreeNode {
33
+ readonly simpleContext: Context;
34
+ /** The underlying {@link MapTree} that this `UnhydratedFlexTreeNode` reads its data from */
35
+ readonly mapTree: ExclusiveMapTree;
36
+ private location;
37
+ get schema(): TreeNodeSchemaIdentifier;
38
+ get storedSchema(): TreeNodeStoredSchema;
39
+ readonly [flexTreeMarker]: FlexTreeEntityKind.Node;
40
+ private readonly _events;
41
+ get events(): Listenable<UnhydratedFlexTreeNodeEvents>;
42
+ /**
43
+ * Create a {@link UnhydratedFlexTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.
44
+ * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to
45
+ * @param mapTree - the {@link MapTree} containing the data for this node.
46
+ * @remarks It must conform to the `nodeSchema`.
47
+ */
48
+ static getOrCreate(context: Context, mapTree: ExclusiveMapTree): UnhydratedFlexTreeNode;
49
+ get context(): FlexTreeContext;
50
+ /**
51
+ * Create a new UnhydratedFlexTreeNode.
52
+ * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not
53
+ * @remarks This class (and its subclasses) should not be directly constructed outside of this module.
54
+ * Instead, use {@link getOrCreateNode} to create a UnhydratedFlexTreeNode from a {@link MapTree}.
55
+ * A `UnhydratedFlexTreeNode` may never be constructed more than once for the same {@link MapTree} object.
56
+ * Instead, it should always be acquired via {@link getOrCreateNode}.
57
+ */
58
+ constructor(simpleContext: Context,
59
+ /** The underlying {@link MapTree} that this `UnhydratedFlexTreeNode` reads its data from */
60
+ mapTree: ExclusiveMapTree, location?: LocationInField);
61
+ get type(): TreeNodeSchemaIdentifier;
62
+ /**
63
+ * Set this node's parentage (see {@link FlexTreeNode.parentField}).
64
+ * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).
65
+ * However, a node with a parent may not be directly re-assigned a different parent.
66
+ * That likely indicates either an attempted multi-parenting or an attempt to "move" the node, neither of which are supported.
67
+ * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.
68
+ */
69
+ adoptBy(parent: undefined): void;
70
+ adoptBy(parent: UnhydratedFlexTreeField, index: number): void;
71
+ /**
72
+ * The field this tree is in, and the index within that field.
73
+ * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.
74
+ */
75
+ get parentField(): LocationInField;
76
+ tryGetField(key: FieldKey): UnhydratedFlexTreeField | undefined;
77
+ getBoxed(key: string): FlexTreeField;
78
+ boxedIterator(): IterableIterator<FlexTreeField>;
79
+ keys(): IterableIterator<FieldKey>;
80
+ get value(): Value;
81
+ get anchorNode(): AnchorNode;
82
+ private walkTree;
83
+ private emitChangedEvent;
84
+ }
85
+ /**
86
+ * Implementation of `FlexTreeContext`.
87
+ *
88
+ * @remarks An editor is required to edit the FlexTree.
89
+ */
90
+ export declare class UnhydratedContext implements FlexTreeContext {
91
+ readonly schemaPolicy: SchemaPolicy;
92
+ readonly schema: TreeStoredSchema;
93
+ /**
94
+ * @param flexSchema - Schema to use when working with the tree.
95
+ */
96
+ constructor(schemaPolicy: SchemaPolicy, schema: TreeStoredSchema);
97
+ isHydrated(): this is FlexTreeHydratedContext;
98
+ }
99
+ declare class UnhydratedFlexTreeField implements FlexTreeField {
100
+ readonly simpleContext: Context;
101
+ readonly schema: FieldKindIdentifier;
102
+ readonly key: FieldKey;
103
+ readonly parent: UnhydratedFlexTreeNode;
104
+ readonly onEdit?: (() => void) | undefined;
105
+ [flexTreeMarker]: FlexTreeEntityKind.Field;
106
+ get context(): FlexTreeContext;
107
+ constructor(simpleContext: Context, schema: FieldKindIdentifier, key: FieldKey, parent: UnhydratedFlexTreeNode, onEdit?: (() => void) | undefined);
108
+ get mapTrees(): readonly ExclusiveMapTree[];
109
+ get length(): number;
110
+ is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2>;
111
+ boxedIterator(): IterableIterator<FlexTreeNode>;
112
+ boxedAt(index: number): FlexTreeNode | undefined;
113
+ /**
114
+ * Mutate this field.
115
+ * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.
116
+ * The function may mutate the array in place or return a new array.
117
+ * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.
118
+ * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.
119
+ * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.
120
+ */
121
+ protected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void;
122
+ getFieldPath(): FieldUpPath;
123
+ /** Unboxes leaf nodes to their values */
124
+ protected unboxed(index: number): FlexTreeUnknownUnboxed;
125
+ }
126
+ export declare class UnhydratedTreeSequenceField extends UnhydratedFlexTreeField implements FlexTreeSequenceField {
127
+ readonly editor: UnhydratedTreeSequenceFieldEditBuilder;
128
+ at(index: number): FlexTreeUnknownUnboxed | undefined;
129
+ map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[];
130
+ [Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed>;
131
+ }
132
+ /**
133
+ * If there exists a {@link UnhydratedFlexTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.
134
+ * @remarks {@link UnhydratedFlexTreeNode | UnhydratedFlexTreeNodes} are created via {@link getOrCreateNode}.
135
+ */
136
+ export declare function tryUnhydratedFlexTreeNode(mapTree: MapTree): UnhydratedFlexTreeNode | undefined;
137
+ export declare function unsupportedUsageError(message?: string): Error;
138
+ export {};
139
+ //# sourceMappingURL=unhydratedFlexTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unhydratedFlexTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,KAAK,gBAAgB,EACrB,KAA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