@fluidframework/tree 2.5.0-302463 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +371 -0
  3. package/api-report/tree.alpha.api.md +151 -57
  4. package/api-report/tree.beta.api.md +29 -25
  5. package/api-report/tree.legacy.alpha.api.md +28 -24
  6. package/api-report/tree.legacy.public.api.md +28 -24
  7. package/api-report/tree.public.api.md +28 -24
  8. package/dist/alpha.d.ts +15 -0
  9. package/dist/codec/codec.d.ts +24 -0
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +26 -1
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +1 -1
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -1
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/core/rebase/index.d.ts +2 -2
  18. package/dist/core/rebase/index.d.ts.map +1 -1
  19. package/dist/core/rebase/index.js +2 -2
  20. package/dist/core/rebase/index.js.map +1 -1
  21. package/dist/core/rebase/types.d.ts +0 -4
  22. package/dist/core/rebase/types.d.ts.map +1 -1
  23. package/dist/core/rebase/types.js +1 -7
  24. package/dist/core/rebase/types.js.map +1 -1
  25. package/dist/core/rebase/utils.d.ts +1 -0
  26. package/dist/core/rebase/utils.d.ts.map +1 -1
  27. package/dist/core/rebase/utils.js +29 -4
  28. package/dist/core/rebase/utils.js.map +1 -1
  29. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  30. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  31. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  32. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  33. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  34. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
  35. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  36. package/dist/index.d.ts +3 -3
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +12 -6
  39. package/dist/index.js.map +1 -1
  40. package/dist/packageVersion.d.ts +1 -1
  41. package/dist/packageVersion.d.ts.map +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/shared-tree/independentView.d.ts +57 -0
  45. package/dist/shared-tree/independentView.d.ts.map +1 -0
  46. package/dist/shared-tree/independentView.js +89 -0
  47. package/dist/shared-tree/independentView.js.map +1 -0
  48. package/dist/shared-tree/index.d.ts +3 -1
  49. package/dist/shared-tree/index.d.ts.map +1 -1
  50. package/dist/shared-tree/index.js +6 -1
  51. package/dist/shared-tree/index.js.map +1 -1
  52. package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
  53. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  54. package/dist/shared-tree/schematizingTreeView.js +28 -0
  55. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  56. package/dist/shared-tree/sharedTree.d.ts +10 -7
  57. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  58. package/dist/shared-tree/sharedTree.js.map +1 -1
  59. package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
  60. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
  61. package/dist/shared-tree/treeApiAlpha.js +122 -0
  62. package/dist/shared-tree/treeApiAlpha.js.map +1 -0
  63. package/dist/shared-tree/treeCheckout.d.ts +12 -7
  64. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  65. package/dist/shared-tree/treeCheckout.js +9 -4
  66. package/dist/shared-tree/treeCheckout.js.map +1 -1
  67. package/dist/shared-tree-core/editManager.d.ts +13 -6
  68. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  69. package/dist/shared-tree-core/editManager.js +70 -28
  70. package/dist/shared-tree-core/editManager.js.map +1 -1
  71. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  72. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  73. package/dist/shared-tree-core/sharedTreeCore.js +28 -3
  74. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  75. package/dist/simple-tree/api/conciseTree.d.ts +2 -1
  76. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  77. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  78. package/dist/simple-tree/api/create.d.ts +5 -23
  79. package/dist/simple-tree/api/create.d.ts.map +1 -1
  80. package/dist/simple-tree/api/create.js +4 -19
  81. package/dist/simple-tree/api/create.js.map +1 -1
  82. package/dist/simple-tree/api/customTree.d.ts +1 -0
  83. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  84. package/dist/simple-tree/api/customTree.js.map +1 -1
  85. package/dist/simple-tree/api/index.d.ts +5 -5
  86. package/dist/simple-tree/api/index.d.ts.map +1 -1
  87. package/dist/simple-tree/api/index.js +10 -1
  88. package/dist/simple-tree/api/index.js.map +1 -1
  89. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
  90. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  91. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  92. package/dist/simple-tree/api/schemaFactory.d.ts +11 -11
  93. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  94. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  95. package/dist/simple-tree/api/storedSchema.js +2 -2
  96. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  97. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  98. package/dist/simple-tree/api/tree.d.ts +115 -7
  99. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  100. package/dist/simple-tree/api/tree.js +12 -4
  101. package/dist/simple-tree/api/tree.js.map +1 -1
  102. package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
  103. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  104. package/dist/simple-tree/api/treeApiBeta.js +3 -15
  105. package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
  106. package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
  107. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  108. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  109. package/dist/simple-tree/api/verboseTree.d.ts +3 -0
  110. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  111. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  112. package/dist/simple-tree/arrayNode.d.ts +1 -1
  113. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  114. package/dist/simple-tree/arrayNode.js +1 -1
  115. package/dist/simple-tree/arrayNode.js.map +1 -1
  116. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  117. package/dist/simple-tree/core/treeNodeSchema.d.ts +45 -9
  118. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  119. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  120. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  121. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  122. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  123. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  124. package/dist/simple-tree/core/withType.d.ts +1 -2
  125. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  126. package/dist/simple-tree/core/withType.js.map +1 -1
  127. package/dist/simple-tree/createContext.js +2 -2
  128. package/dist/simple-tree/createContext.js.map +1 -1
  129. package/dist/simple-tree/index.d.ts +4 -4
  130. package/dist/simple-tree/index.d.ts.map +1 -1
  131. package/dist/simple-tree/index.js +15 -4
  132. package/dist/simple-tree/index.js.map +1 -1
  133. package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
  134. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  135. package/dist/simple-tree/leafNodeSchema.js +3 -0
  136. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  137. package/dist/simple-tree/mapNode.d.ts +1 -1
  138. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  139. package/dist/simple-tree/mapNode.js +3 -0
  140. package/dist/simple-tree/mapNode.js.map +1 -1
  141. package/dist/simple-tree/schemaTypes.d.ts +45 -7
  142. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  143. package/dist/simple-tree/schemaTypes.js +61 -1
  144. package/dist/simple-tree/schemaTypes.js.map +1 -1
  145. package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  146. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
  147. package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  148. package/dist/simple-tree/toStoredSchema.js.map +1 -0
  149. package/dist/simple-tree/treeNodeValid.d.ts +5 -1
  150. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  151. package/dist/simple-tree/treeNodeValid.js +7 -1
  152. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  153. package/dist/util/index.d.ts +1 -1
  154. package/dist/util/index.d.ts.map +1 -1
  155. package/dist/util/index.js.map +1 -1
  156. package/dist/util/typeCheck.d.ts +9 -0
  157. package/dist/util/typeCheck.d.ts.map +1 -1
  158. package/dist/util/typeCheck.js.map +1 -1
  159. package/dist/util/utils.d.ts +7 -3
  160. package/dist/util/utils.d.ts.map +1 -1
  161. package/dist/util/utils.js +13 -3
  162. package/dist/util/utils.js.map +1 -1
  163. package/lib/alpha.d.ts +15 -0
  164. package/lib/codec/codec.d.ts +24 -0
  165. package/lib/codec/codec.d.ts.map +1 -1
  166. package/lib/codec/codec.js +25 -0
  167. package/lib/codec/codec.js.map +1 -1
  168. package/lib/codec/index.d.ts +1 -1
  169. package/lib/codec/index.d.ts.map +1 -1
  170. package/lib/codec/index.js +1 -1
  171. package/lib/codec/index.js.map +1 -1
  172. package/lib/core/rebase/index.d.ts +2 -2
  173. package/lib/core/rebase/index.d.ts.map +1 -1
  174. package/lib/core/rebase/index.js +2 -2
  175. package/lib/core/rebase/index.js.map +1 -1
  176. package/lib/core/rebase/types.d.ts +0 -4
  177. package/lib/core/rebase/types.d.ts.map +1 -1
  178. package/lib/core/rebase/types.js +0 -5
  179. package/lib/core/rebase/types.js.map +1 -1
  180. package/lib/core/rebase/utils.d.ts +1 -0
  181. package/lib/core/rebase/utils.d.ts.map +1 -1
  182. package/lib/core/rebase/utils.js +27 -3
  183. package/lib/core/rebase/utils.js.map +1 -1
  184. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  185. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  186. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  187. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  188. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  189. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
  190. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  191. package/lib/index.d.ts +3 -3
  192. package/lib/index.d.ts.map +1 -1
  193. package/lib/index.js +3 -2
  194. package/lib/index.js.map +1 -1
  195. package/lib/packageVersion.d.ts +1 -1
  196. package/lib/packageVersion.d.ts.map +1 -1
  197. package/lib/packageVersion.js +1 -1
  198. package/lib/packageVersion.js.map +1 -1
  199. package/lib/shared-tree/independentView.d.ts +57 -0
  200. package/lib/shared-tree/independentView.d.ts.map +1 -0
  201. package/lib/shared-tree/independentView.js +84 -0
  202. package/lib/shared-tree/independentView.js.map +1 -0
  203. package/lib/shared-tree/index.d.ts +3 -1
  204. package/lib/shared-tree/index.d.ts.map +1 -1
  205. package/lib/shared-tree/index.js +2 -0
  206. package/lib/shared-tree/index.js.map +1 -1
  207. package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
  208. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  209. package/lib/shared-tree/schematizingTreeView.js +29 -1
  210. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  211. package/lib/shared-tree/sharedTree.d.ts +10 -7
  212. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  213. package/lib/shared-tree/sharedTree.js.map +1 -1
  214. package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
  215. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
  216. package/lib/shared-tree/treeApiAlpha.js +119 -0
  217. package/lib/shared-tree/treeApiAlpha.js.map +1 -0
  218. package/lib/shared-tree/treeCheckout.d.ts +12 -7
  219. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  220. package/lib/shared-tree/treeCheckout.js +9 -4
  221. package/lib/shared-tree/treeCheckout.js.map +1 -1
  222. package/lib/shared-tree-core/editManager.d.ts +13 -6
  223. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  224. package/lib/shared-tree-core/editManager.js +70 -28
  225. package/lib/shared-tree-core/editManager.js.map +1 -1
  226. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  227. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  228. package/lib/shared-tree-core/sharedTreeCore.js +29 -4
  229. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  230. package/lib/simple-tree/api/conciseTree.d.ts +2 -1
  231. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  232. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  233. package/lib/simple-tree/api/create.d.ts +5 -23
  234. package/lib/simple-tree/api/create.d.ts.map +1 -1
  235. package/lib/simple-tree/api/create.js +2 -16
  236. package/lib/simple-tree/api/create.js.map +1 -1
  237. package/lib/simple-tree/api/customTree.d.ts +1 -0
  238. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  239. package/lib/simple-tree/api/customTree.js.map +1 -1
  240. package/lib/simple-tree/api/index.d.ts +5 -5
  241. package/lib/simple-tree/api/index.d.ts.map +1 -1
  242. package/lib/simple-tree/api/index.js +5 -3
  243. package/lib/simple-tree/api/index.js.map +1 -1
  244. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
  245. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  246. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  247. package/lib/simple-tree/api/schemaFactory.d.ts +11 -11
  248. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  249. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  250. package/lib/simple-tree/api/storedSchema.js +1 -1
  251. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  252. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  253. package/lib/simple-tree/api/tree.d.ts +115 -7
  254. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  255. package/lib/simple-tree/api/tree.js +9 -2
  256. package/lib/simple-tree/api/tree.js.map +1 -1
  257. package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
  258. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  259. package/lib/simple-tree/api/treeApiBeta.js +4 -16
  260. package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
  261. package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
  262. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  263. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  264. package/lib/simple-tree/api/verboseTree.d.ts +3 -0
  265. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  266. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  267. package/lib/simple-tree/arrayNode.d.ts +1 -1
  268. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  269. package/lib/simple-tree/arrayNode.js +1 -1
  270. package/lib/simple-tree/arrayNode.js.map +1 -1
  271. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  272. package/lib/simple-tree/core/treeNodeSchema.d.ts +45 -9
  273. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  274. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  275. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  276. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  277. package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
  278. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  279. package/lib/simple-tree/core/withType.d.ts +1 -2
  280. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  281. package/lib/simple-tree/core/withType.js.map +1 -1
  282. package/lib/simple-tree/createContext.js +1 -1
  283. package/lib/simple-tree/createContext.js.map +1 -1
  284. package/lib/simple-tree/index.d.ts +4 -4
  285. package/lib/simple-tree/index.d.ts.map +1 -1
  286. package/lib/simple-tree/index.js +4 -4
  287. package/lib/simple-tree/index.js.map +1 -1
  288. package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
  289. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  290. package/lib/simple-tree/leafNodeSchema.js +3 -0
  291. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  292. package/lib/simple-tree/mapNode.d.ts +1 -1
  293. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  294. package/lib/simple-tree/mapNode.js +3 -0
  295. package/lib/simple-tree/mapNode.js.map +1 -1
  296. package/lib/simple-tree/schemaTypes.d.ts +45 -7
  297. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  298. package/lib/simple-tree/schemaTypes.js +59 -1
  299. package/lib/simple-tree/schemaTypes.js.map +1 -1
  300. package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  301. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
  302. package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  303. package/lib/simple-tree/toStoredSchema.js.map +1 -0
  304. package/lib/simple-tree/treeNodeValid.d.ts +5 -1
  305. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  306. package/lib/simple-tree/treeNodeValid.js +7 -1
  307. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  308. package/lib/util/index.d.ts +1 -1
  309. package/lib/util/index.d.ts.map +1 -1
  310. package/lib/util/index.js.map +1 -1
  311. package/lib/util/typeCheck.d.ts +9 -0
  312. package/lib/util/typeCheck.d.ts.map +1 -1
  313. package/lib/util/typeCheck.js.map +1 -1
  314. package/lib/util/utils.d.ts +7 -3
  315. package/lib/util/utils.d.ts.map +1 -1
  316. package/lib/util/utils.js +13 -3
  317. package/lib/util/utils.js.map +1 -1
  318. package/package.json +30 -21
  319. package/src/codec/codec.ts +25 -0
  320. package/src/codec/index.ts +1 -0
  321. package/src/core/rebase/index.ts +1 -1
  322. package/src/core/rebase/types.ts +0 -12
  323. package/src/core/rebase/utils.ts +35 -3
  324. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
  325. package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
  326. package/src/index.ts +20 -5
  327. package/src/packageVersion.ts +1 -1
  328. package/src/shared-tree/independentView.ts +176 -0
  329. package/src/shared-tree/index.ts +9 -1
  330. package/src/shared-tree/schematizingTreeView.ts +58 -11
  331. package/src/shared-tree/sharedTree.ts +29 -11
  332. package/src/shared-tree/treeApiAlpha.ts +401 -0
  333. package/src/shared-tree/treeCheckout.ts +26 -5
  334. package/src/shared-tree-core/editManager.ts +112 -54
  335. package/src/shared-tree-core/sharedTreeCore.ts +37 -8
  336. package/src/simple-tree/api/conciseTree.ts +2 -1
  337. package/src/simple-tree/api/create.ts +21 -58
  338. package/src/simple-tree/api/customTree.ts +1 -0
  339. package/src/simple-tree/api/index.ts +13 -7
  340. package/src/simple-tree/api/schemaCreationUtilities.ts +4 -5
  341. package/src/simple-tree/api/schemaFactory.ts +24 -12
  342. package/src/simple-tree/api/storedSchema.ts +1 -1
  343. package/src/simple-tree/api/tree.ts +136 -14
  344. package/src/simple-tree/api/treeApiBeta.ts +35 -35
  345. package/src/simple-tree/api/typesUnsafe.ts +1 -2
  346. package/src/simple-tree/api/verboseTree.ts +3 -0
  347. package/src/simple-tree/arrayNode.ts +4 -3
  348. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  349. package/src/simple-tree/core/treeNodeSchema.ts +99 -31
  350. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
  351. package/src/simple-tree/core/withType.ts +1 -9
  352. package/src/simple-tree/createContext.ts +1 -1
  353. package/src/simple-tree/index.ts +15 -1
  354. package/src/simple-tree/leafNodeSchema.ts +6 -1
  355. package/src/simple-tree/mapNode.ts +7 -1
  356. package/src/simple-tree/schemaTypes.ts +128 -14
  357. package/src/simple-tree/treeNodeValid.ts +11 -1
  358. package/src/util/index.ts +1 -0
  359. package/src/util/typeCheck.ts +13 -0
  360. package/src/util/utils.ts +20 -7
  361. package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
  362. package/dist/simple-tree/toFlexSchema.js.map +0 -1
  363. package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
  364. package/lib/simple-tree/toFlexSchema.js.map +0 -1
  365. /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
@@ -270,30 +270,62 @@ export class EditManager<
270
270
  }
271
271
 
272
272
  /**
273
- * Updates the `trunkBranches` map to reflect the fact that a new local commit was fast-forwarded to the trunk.
274
- * @param priorTrunkCommit - The trunk head prior to the fast-forward.
275
- * @param newId - The ID of the new trunk head.
273
+ * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.
274
+ * @param sequenceId - The sequence id of the new trunk commit
275
+ * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.
276
+ * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.
277
+ * The first commit will be "the same" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.
278
+ * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.
279
+ * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.
276
280
  */
277
- private fastForwardBranches(
278
- priorTrunkCommit: GraphCommit<TChangeset>,
279
- newId: SequenceId,
280
- ): void {
281
- const currentId = this.getCommitSequenceId(priorTrunkCommit);
282
- const currentBranches = this.trunkBranches.get(currentId);
281
+ private fastForwardNextLocalCommit(sequenceId: SequenceId): void {
282
+ // First, push the local commit to the trunk.
283
+ // We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.
284
+ const firstLocalCommit = this.localCommits.shift();
285
+ assert(
286
+ firstLocalCommit !== undefined,
287
+ 0x6b5 /* Received a sequenced change from the local session despite having no local changes */,
288
+ );
289
+
290
+ const previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());
291
+ this.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);
292
+
293
+ // Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.
294
+ // In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)
295
+ // and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.
296
+ // Intuitively, this makes sense because:
297
+ // 1. The trunk's head just advanced forward by some (sequence) amount.
298
+ // 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).
299
+ // 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.
300
+ // This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).
301
+ const currentBranches = this.trunkBranches.get(previousSequenceId);
283
302
  if (currentBranches !== undefined) {
284
- const newBranches = getOrCreate(this.trunkBranches, newId, () => new Set());
303
+ const newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());
285
304
  for (const branch of currentBranches) {
286
- if (branch.getHead() !== priorTrunkCommit) {
305
+ // Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).
306
+ // We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.
307
+ if (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {
287
308
  newBranches.add(branch);
288
309
  currentBranches.delete(branch);
289
310
  }
290
311
  }
312
+ // Clean up our trunk branches map by removing any empty sets.
291
313
  if (currentBranches.size === 0) {
292
- this.trunkBranches.delete(currentId);
314
+ this.trunkBranches.delete(previousSequenceId);
315
+ }
316
+ if (newBranches.size === 0) {
317
+ this.trunkBranches.delete(sequenceId);
293
318
  }
294
319
  }
295
320
  }
296
321
 
322
+ /**
323
+ * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.
324
+ */
325
+ public getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {
326
+ return this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;
327
+ }
328
+
297
329
  /**
298
330
  * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,
299
331
  * if they are not retained by revertibles or local branches.
@@ -301,7 +333,10 @@ export class EditManager<
301
333
  *
302
334
  * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.
303
335
  */
304
- public advanceMinimumSequenceNumber(minimumSequenceNumber: SeqNumber): void {
336
+ public advanceMinimumSequenceNumber(
337
+ minimumSequenceNumber: SeqNumber,
338
+ trimTrunk = true,
339
+ ): void {
305
340
  if (minimumSequenceNumber === this.minimumSequenceNumber) {
306
341
  return;
307
342
  }
@@ -312,16 +347,17 @@ export class EditManager<
312
347
  );
313
348
 
314
349
  this.minimumSequenceNumber = minimumSequenceNumber;
315
- this.trimTrunk();
350
+ if (trimTrunk) {
351
+ this.trimTrunk();
352
+ }
316
353
  }
317
354
 
318
355
  /**
319
356
  * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine
320
357
  * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.
321
- * @returns the number of commits that were removed from the trunk
322
358
  */
323
359
  private trimTrunk(): void {
324
- /** The sequence id of the oldest commit on the trunk that will be retained */
360
+ /** The sequence id of the most recent commit on the trunk that will be trimmed */
325
361
  let trunkTailSequenceId: SequenceId = {
326
362
  sequenceNumber: this.minimumSequenceNumber,
327
363
  indexInBatch: Number.POSITIVE_INFINITY,
@@ -376,24 +412,40 @@ export class EditManager<
376
412
  this.trunkBase = newTrunkBase;
377
413
 
378
414
  // Update any state that is derived from trunk commits
379
- this.sequenceMap.editRange(
380
- minimumPossibleSequenceId,
381
- sequenceId,
382
- true,
383
- (s, { revision }) => {
384
- // Cleanup look-aside data for each evicted commit
385
- this.trunkMetadata.delete(revision);
386
- // Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`
387
- if (equalSequenceIds(s, sequenceId)) {
388
- assert(
389
- revision === newTrunkBase.revision,
390
- 0x729 /* Expected last evicted commit to be new trunk base */,
391
- );
392
- } else {
393
- return { delete: true };
394
- }
395
- },
396
- );
415
+ this.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {
416
+ // Cleanup look-aside data for each evicted commit
417
+ this.trunkMetadata.delete(commit.revision);
418
+ // Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`
419
+ if (equalSequenceIds(s, sequenceId)) {
420
+ assert(
421
+ commit === newTrunkBase,
422
+ 0x729 /* Expected last evicted commit to be new trunk base */,
423
+ );
424
+ } else {
425
+ Reflect.defineProperty(commit, "change", {
426
+ get: () =>
427
+ assert(
428
+ false,
429
+ 0xa5e /* Should not access 'change' property of an evicted commit */,
430
+ ),
431
+ });
432
+ Reflect.defineProperty(commit, "revision", {
433
+ get: () =>
434
+ assert(
435
+ false,
436
+ 0xa5f /* Should not access 'revision' property of an evicted commit */,
437
+ ),
438
+ });
439
+ Reflect.defineProperty(commit, "parent", {
440
+ get: () =>
441
+ assert(
442
+ false,
443
+ 0xa60 /* Should not access 'parent' property of an evicted commit */,
444
+ ),
445
+ });
446
+ return { delete: true };
447
+ }
448
+ });
397
449
 
398
450
  const trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;
399
451
  assert(
@@ -432,6 +484,9 @@ export class EditManager<
432
484
  0x428 /* Clients with local changes cannot be used to generate summaries */,
433
485
  );
434
486
 
487
+ // Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.
488
+ this.trimTrunk();
489
+
435
490
  let oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];
436
491
  assert(
437
492
  oldestCommitInCollabWindow.parent !== undefined ||
@@ -445,7 +500,10 @@ export class EditManager<
445
500
 
446
501
  const trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(
447
502
  (c) => {
448
- assert(c !== this.trunkBase, "Serialized trunk should not include the trunk base");
503
+ assert(
504
+ c !== this.trunkBase,
505
+ 0xa61 /* Serialized trunk should not include the trunk base */,
506
+ );
449
507
  const metadata =
450
508
  this.trunkMetadata.get(c.revision) ?? fail("Expected metadata for trunk commit");
451
509
  const commit: SequencedCommit<TChangeset> = {
@@ -476,7 +534,7 @@ export class EditManager<
476
534
  commits: branchPath.map((c) => {
477
535
  assert(
478
536
  c !== this.trunkBase,
479
- "Serialized branch should not include the trunk base",
537
+ 0xa62 /* Serialized branch should not include the trunk base */,
480
538
  );
481
539
  const commit: Commit<TChangeset> = {
482
540
  change: c.change,
@@ -542,8 +600,16 @@ export class EditManager<
542
600
  }
543
601
  }
544
602
 
545
- private getCommitSequenceId(commit: GraphCommit<TChangeset>): SequenceId {
546
- return this.trunkMetadata.get(commit.revision)?.sequenceId ?? minimumPossibleSequenceId;
603
+ private getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {
604
+ const id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;
605
+ if (id === undefined) {
606
+ assert(
607
+ trunkCommitOrTrunkBase === this.trunkBase,
608
+ 0xa63 /* Commit must be either be on the trunk or be the trunk base */,
609
+ );
610
+ return minimumPossibleSequenceId;
611
+ }
612
+ return id;
547
613
  }
548
614
 
549
615
  public getTrunkChanges(): readonly TChangeset[] {
@@ -595,6 +661,12 @@ export class EditManager<
595
661
  0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,
596
662
  );
597
663
 
664
+ assert(
665
+ sequenceNumber >= // This is ">=", not ">" because changes in the same batch will have the same sequence number
666
+ (this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),
667
+ 0xa64 /* Attempted to sequence change with an outdated sequence number */,
668
+ );
669
+
598
670
  const commitsSequenceNumber = this.getBatch(sequenceNumber);
599
671
  const sequenceId: SequenceId =
600
672
  commitsSequenceNumber.length === 0
@@ -607,17 +679,7 @@ export class EditManager<
607
679
  };
608
680
 
609
681
  if (newCommit.sessionId === this.localSessionId) {
610
- const headTrunkCommit = this.trunk.getHead();
611
- const firstLocalCommit = this.localCommits.shift();
612
- assert(
613
- firstLocalCommit !== undefined,
614
- 0x6b5 /* Received a sequenced change from the local session despite having no local changes */,
615
- );
616
-
617
- // The first local branch commit is already rebased over the trunk, so we can push it directly to the trunk.
618
- this.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);
619
- this.fastForwardBranches(headTrunkCommit, sequenceId);
620
- return;
682
+ return this.fastForwardNextLocalCommit(sequenceId);
621
683
  }
622
684
 
623
685
  // Get the revision that the remote change is based on
@@ -674,11 +736,7 @@ export class EditManager<
674
736
  return [commit, commits];
675
737
  }
676
738
 
677
- private pushCommitToTrunk(
678
- sequenceId: SequenceId,
679
- commit: Commit<TChangeset>,
680
- local = false,
681
- ): void {
739
+ private pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {
682
740
  const mintedCommit = mintCommit(this.trunk.getHead(), commit);
683
741
  this.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);
684
742
  }
@@ -27,6 +27,7 @@ import type { ICodecOptions, IJsonCodec } from "../codec/index.js";
27
27
  import {
28
28
  type ChangeFamily,
29
29
  type ChangeFamilyEditor,
30
+ findAncestor,
30
31
  type GraphCommit,
31
32
  type RevisionTag,
32
33
  RevisionTagCodec,
@@ -80,7 +81,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
80
81
  public readonly breaker: Breakable = new Breakable("Shared Tree");
81
82
 
82
83
  private readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;
83
- private readonly summarizables: readonly Summarizable[];
84
+ private readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];
84
85
  /**
85
86
  * The sequence number that this instance is at.
86
87
  * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.
@@ -308,14 +309,42 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
308
309
  }
309
310
 
310
311
  protected async loadCore(services: IChannelStorageService): Promise<void> {
311
- const loadSummaries = this.summarizables.map(async (summaryElement) =>
312
- summaryElement.load(
313
- scopeStorageService(services, summarizablesTreeKey, summaryElement.key),
314
- (contents) => this.serializer.parse(contents),
315
- ),
312
+ const [editManagerSummarizer, ...summarizables] = this.summarizables;
313
+ const loadEditManager = this.loadSummarizable(editManagerSummarizer, services);
314
+ const loadSummarizables = summarizables.map(async (s) =>
315
+ this.loadSummarizable(s, services),
316
316
  );
317
317
 
318
- await Promise.all(loadSummaries);
318
+ if (this.detachedRevision !== undefined) {
319
+ // If we are detached but loading from a summary, then we need to update our detached revision to ensure that it is ahead of all detached revisions in the summary.
320
+ // First, finish loading the edit manager so that we can inspect the sequence numbers of the commits on the trunk.
321
+ await loadEditManager;
322
+ // Find the most recent detached revision in the summary trunk...
323
+ let latestDetachedSequenceNumber: SeqNumber | undefined;
324
+ findAncestor(this.editManager.getTrunkHead(), (c) => {
325
+ const sequenceNumber = this.editManager.getSequenceNumber(c);
326
+ if (sequenceNumber !== undefined && sequenceNumber < 0) {
327
+ latestDetachedSequenceNumber = sequenceNumber;
328
+ return true;
329
+ }
330
+ return false;
331
+ });
332
+ // ...and set our detached revision to be as it would be if we had been already created that revision.
333
+ this.detachedRevision = latestDetachedSequenceNumber ?? this.detachedRevision;
334
+ await Promise.all(loadSummarizables);
335
+ } else {
336
+ await Promise.all([loadEditManager, ...loadSummarizables]);
337
+ }
338
+ }
339
+
340
+ private async loadSummarizable(
341
+ summarizable: Summarizable,
342
+ services: IChannelStorageService,
343
+ ): Promise<void> {
344
+ return summarizable.load(
345
+ scopeStorageService(services, summarizablesTreeKey, summarizable.key),
346
+ (contents) => this.serializer.parse(contents),
347
+ );
319
348
  }
320
349
 
321
350
  /**
@@ -351,7 +380,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
351
380
  newRevision,
352
381
  this.detachedRevision,
353
382
  );
354
- this.editManager.advanceMinimumSequenceNumber(newRevision);
383
+ this.editManager.advanceMinimumSequenceNumber(newRevision, false);
355
384
  return undefined;
356
385
  }
357
386
  const message = this.messageCodec.encode(
@@ -16,13 +16,14 @@ import { getUnhydratedContext } from "../createContext.js";
16
16
  * @remarks
17
17
  * This is "concise" meaning that explicit type information is omitted.
18
18
  * If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},
19
- * types will be lossless and compatible with {@link TreeBeta.create} (unless the options are used to customize it).
19
+ * types will be lossless and compatible with {@link TreeAlpha.create} (unless the options are used to customize it).
20
20
  *
21
21
  * Every {@link TreeNode} is an array or object.
22
22
  * Any IFluidHandle values have been replaced by `THandle`.
23
23
  * @privateRemarks
24
24
  * This can store all possible simple trees,
25
25
  * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.
26
+ * @alpha
26
27
  */
27
28
  export type ConciseTree<THandle = IFluidHandle> =
28
29
  | Exclude<TreeLeafValue, IFluidHandle>
@@ -3,22 +3,22 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { IFluidHandle } from "@fluidframework/core-interfaces";
7
6
  import { assert } from "@fluidframework/core-utils/internal";
8
7
 
9
8
  import type { ITreeCursorSynchronous, SchemaAndPolicy } from "../../core/index.js";
10
9
  import type {
11
- TreeLeafValue,
12
10
  ImplicitFieldSchema,
13
11
  TreeFieldFromImplicitField,
14
12
  FieldSchema,
15
13
  FieldKind,
16
14
  UnsafeUnknownSchema,
17
15
  InsertableField,
16
+ TreeLeafValue,
18
17
  } from "../schemaTypes.js";
19
18
  import {
20
19
  getOrCreateNodeFromInnerNode,
21
20
  UnhydratedFlexTreeNode,
21
+ type TreeNode,
22
22
  type Unhydrated,
23
23
  } from "../core/index.js";
24
24
  import {
@@ -29,15 +29,8 @@ import {
29
29
  type NodeKeyManager,
30
30
  } from "../../feature-libraries/index.js";
31
31
  import { isFieldInSchema } from "../../feature-libraries/index.js";
32
- import { toStoredSchema } from "../toFlexSchema.js";
32
+ import { toStoredSchema } from "../toStoredSchema.js";
33
33
  import { inSchemaOrThrow, mapTreeFromNodeData } from "../toMapTree.js";
34
- import {
35
- applySchemaToParserOptions,
36
- cursorFromVerbose,
37
- type ParseOptions,
38
- type VerboseTree,
39
- type VerboseTreeNode,
40
- } from "./verboseTree.js";
41
34
  import { getUnhydratedContext } from "../createContext.js";
42
35
 
43
36
  /**
@@ -50,18 +43,28 @@ import { getUnhydratedContext } from "../createContext.js";
50
43
  * such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.
51
44
  *
52
45
  * Like with {@link TreeNodeSchemaClass}'s constructor, its an error to provide an existing node to this API.
53
- * TODO: For that case, use we should provide `Tree.clone`.
54
- * @privateRemarks
55
- * This could be exposed as a public `Tree.create` function.
46
+ * For that case, use {@link TreeBeta.clone}.
56
47
  */
57
- export function createFromInsertable<TSchema extends ImplicitFieldSchema>(
58
- schema: TSchema,
48
+ export function createFromInsertable<
49
+ const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
50
+ >(
51
+ schema: UnsafeUnknownSchema extends TSchema
52
+ ? ImplicitFieldSchema
53
+ : TSchema & ImplicitFieldSchema,
59
54
  data: InsertableField<TSchema>,
60
55
  context?: NodeKeyManager | undefined,
61
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
56
+ ): Unhydrated<
57
+ TSchema extends ImplicitFieldSchema
58
+ ? TreeFieldFromImplicitField<TSchema>
59
+ : TreeNode | TreeLeafValue | undefined
60
+ > {
62
61
  const cursor = cursorFromInsertable(schema, data, context);
63
62
  const result = cursor === undefined ? undefined : createFromCursor(schema, cursor);
64
- return result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
63
+ return result as Unhydrated<
64
+ TSchema extends ImplicitFieldSchema
65
+ ? TreeFieldFromImplicitField<TSchema>
66
+ : TreeNode | TreeLeafValue | undefined
67
+ >;
65
68
  }
66
69
 
67
70
  /**
@@ -107,50 +110,10 @@ export function cursorFromInsertable<
107
110
  return cursorForMapTreeNode(mapTree);
108
111
  }
109
112
 
110
- /**
111
- * Construct tree content compatible with a field defined by the provided `schema`.
112
- * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
113
- * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.
114
- * @privateRemarks
115
- * This could be exposed as a public `Tree.createFromVerbose` function.
116
- */
117
- export function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(
118
- schema: TSchema,
119
- data: VerboseTreeNode<THandle> | undefined,
120
- options: ParseOptions<THandle>,
121
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
122
-
123
- /**
124
- * Construct tree content compatible with a field defined by the provided `schema`.
125
- * @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
126
- * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.
127
- */
128
- export function createFromVerbose<TSchema extends ImplicitFieldSchema>(
129
- schema: TSchema,
130
- data: VerboseTreeNode | undefined,
131
- options?: Partial<ParseOptions<IFluidHandle>>,
132
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
133
-
134
- export function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(
135
- schema: TSchema,
136
- data: VerboseTreeNode<THandle> | undefined,
137
- options?: Partial<ParseOptions<THandle>>,
138
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
139
- const config: ParseOptions<THandle> = {
140
- valueConverter: (input: VerboseTree<THandle>) => {
141
- return input as TreeLeafValue | VerboseTreeNode<THandle>;
142
- },
143
- ...options,
144
- };
145
- const schemalessConfig = applySchemaToParserOptions(schema, config);
146
- const cursor = cursorFromVerbose(data, schemalessConfig);
147
- return createFromCursor(schema, cursor);
148
- }
149
-
150
113
  /**
151
114
  * Creates an unhydrated simple-tree field from a cursor in nodes mode.
152
115
  */
153
- export function createFromCursor<TSchema extends ImplicitFieldSchema>(
116
+ export function createFromCursor<const TSchema extends ImplicitFieldSchema>(
154
117
  schema: TSchema,
155
118
  cursor: ITreeCursorSynchronous | undefined,
156
119
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
@@ -28,6 +28,7 @@ import { isObjectNodeSchema } from "../objectNodeTypes.js";
28
28
 
29
29
  /**
30
30
  * Options for how to encode a tree.
31
+ * @alpha
31
32
  */
32
33
  export interface EncodeOptions<TCustom> {
33
34
  /**
@@ -13,6 +13,9 @@ export {
13
13
  type SchemaCompatibilityStatus,
14
14
  type ITreeConfigurationOptions,
15
15
  type TreeViewAlpha,
16
+ type TreeBranch,
17
+ type TreeBranchEvents,
18
+ asTreeViewAlpha,
16
19
  } from "./tree.js";
17
20
  export { SchemaFactory, type ScopedSchemaName } from "./schemaFactory.js";
18
21
  export type {
@@ -24,8 +27,8 @@ export {
24
27
  enumFromStrings,
25
28
  singletonSchema,
26
29
  } from "./schemaCreationUtilities.js";
27
- export { treeNodeApi, type TreeNodeApi } from "./treeNodeApi.js";
28
- export { createFromInsertable, cursorFromInsertable } from "./create.js";
30
+ export { treeNodeApi, type TreeNodeApi, tryGetSchema } from "./treeNodeApi.js";
31
+ export { createFromInsertable, cursorFromInsertable, createFromCursor } from "./create.js";
29
32
  export type { SimpleTreeSchema } from "./simpleSchema.js";
30
33
  export {
31
34
  type JsonSchemaId,
@@ -69,15 +72,18 @@ export type {
69
72
  InsertableTreeNodeFromAllowedTypesUnsafe,
70
73
  } from "./typesUnsafe.js";
71
74
 
72
- export type {
73
- VerboseTreeNode,
74
- ParseOptions,
75
- VerboseTree,
75
+ export {
76
+ type VerboseTreeNode,
77
+ type ParseOptions,
78
+ type VerboseTree,
79
+ applySchemaToParserOptions,
80
+ cursorFromVerbose,
81
+ verboseFromCursor,
76
82
  } from "./verboseTree.js";
77
83
 
78
84
  export type { EncodeOptions } from "./customTree.js";
79
85
 
80
- export type { ConciseTree } from "./conciseTree.js";
86
+ export { type ConciseTree, conciseFromCursor } from "./conciseTree.js";
81
87
 
82
88
  export { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from "./treeApiBeta.js";
83
89
 
@@ -62,11 +62,10 @@ export function singletonSchema<TScope extends string, TName extends string | nu
62
62
  NodeKind.Object,
63
63
  SingletonNodeType,
64
64
  Record<string, never>,
65
- true
66
- > &
67
- (new (
68
- data?: InternalTreeNode | Record<string, never>,
69
- ) => SingletonNodeType) = SingletonSchema;
65
+ true,
66
+ Record<string, never>,
67
+ undefined
68
+ > = SingletonSchema;
70
69
 
71
70
  return toReturn;
72
71
  }
@@ -341,7 +341,8 @@ export class SchemaFactory<
341
341
  TreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map>,
342
342
  MapNodeInsertableData<T>,
343
343
  true,
344
- T
344
+ T,
345
+ undefined
345
346
  >;
346
347
 
347
348
  /**
@@ -363,7 +364,8 @@ export class SchemaFactory<
363
364
  TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,
364
365
  MapNodeInsertableData<T>,
365
366
  true,
366
- T
367
+ T,
368
+ undefined
367
369
  >;
368
370
 
369
371
  /**
@@ -395,7 +397,8 @@ export class SchemaFactory<
395
397
  TreeMapNode<T>,
396
398
  MapNodeInsertableData<T>,
397
399
  true,
398
- T
400
+ T,
401
+ undefined
399
402
  >;
400
403
  }
401
404
  // To actually have type safety, assign to the type this method should return before implicitly upcasting when returning.
@@ -405,7 +408,8 @@ export class SchemaFactory<
405
408
  TreeMapNode<T>,
406
409
  MapNodeInsertableData<T>,
407
410
  true,
408
- T
411
+ T,
412
+ undefined
409
413
  > = this.namedMap(nameOrAllowedTypes as TName, allowedTypes, true, true);
410
414
  return out;
411
415
  }
@@ -430,7 +434,8 @@ export class SchemaFactory<
430
434
  TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,
431
435
  MapNodeInsertableData<T>,
432
436
  ImplicitlyConstructable,
433
- T
437
+ T,
438
+ undefined
434
439
  > {
435
440
  return mapSchema(
436
441
  this.scoped(name),
@@ -482,7 +487,8 @@ export class SchemaFactory<
482
487
  TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, `Array<${string}>`>, NodeKind.Array>,
483
488
  Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
484
489
  true,
485
- T
490
+ T,
491
+ undefined
486
492
  >;
487
493
 
488
494
  /**
@@ -506,7 +512,8 @@ export class SchemaFactory<
506
512
  TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,
507
513
  Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
508
514
  true,
509
- T
515
+ T,
516
+ undefined
510
517
  >;
511
518
 
512
519
  /**
@@ -535,7 +542,8 @@ export class SchemaFactory<
535
542
  TreeArrayNode<T>,
536
543
  Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
537
544
  true,
538
- T
545
+ T,
546
+ undefined
539
547
  >;
540
548
  }
541
549
  const out: TreeNodeSchemaBoth<
@@ -544,7 +552,8 @@ export class SchemaFactory<
544
552
  TreeArrayNode<T>,
545
553
  Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
546
554
  true,
547
- T
555
+ T,
556
+ undefined
548
557
  > = this.namedArray(nameOrAllowedTypes as TName, allowedTypes, true, true);
549
558
  return out;
550
559
  }
@@ -573,7 +582,8 @@ export class SchemaFactory<
573
582
  TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>, NodeKind.Array>,
574
583
  Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
575
584
  ImplicitlyConstructable,
576
- T
585
+ T,
586
+ undefined
577
587
  > {
578
588
  return arraySchema(this.scoped(name), allowedTypes, implicitlyConstructable, customizable);
579
589
  }
@@ -747,7 +757,8 @@ export class SchemaFactory<
747
757
  [Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;
748
758
  },
749
759
  false,
750
- T
760
+ T,
761
+ undefined
751
762
  >;
752
763
  }
753
764
 
@@ -793,7 +804,8 @@ export class SchemaFactory<
793
804
  // Ideally this would be included, but doing so breaks recursive types.
794
805
  // | RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,
795
806
  false,
796
- T
807
+ T,
808
+ undefined
797
809
  >;
798
810
  }
799
811
  }