@fluidframework/tree 2.4.0 → 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 (446) hide show
  1. package/.vscode/settings.json +12 -1
  2. package/CHANGELOG.md +371 -0
  3. package/api-report/tree.alpha.api.md +271 -80
  4. package/api-report/tree.beta.api.md +100 -51
  5. package/api-report/tree.legacy.alpha.api.md +99 -50
  6. package/api-report/tree.legacy.public.api.md +99 -50
  7. package/api-report/tree.public.api.md +99 -50
  8. package/dist/alpha.d.ts +32 -2
  9. package/dist/beta.d.ts +6 -0
  10. package/dist/codec/codec.d.ts +24 -0
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +26 -1
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +2 -1
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/core/rebase/index.d.ts +2 -2
  19. package/dist/core/rebase/index.d.ts.map +1 -1
  20. package/dist/core/rebase/index.js +2 -2
  21. package/dist/core/rebase/index.js.map +1 -1
  22. package/dist/core/rebase/types.d.ts +0 -4
  23. package/dist/core/rebase/types.d.ts.map +1 -1
  24. package/dist/core/rebase/types.js +1 -7
  25. package/dist/core/rebase/types.js.map +1 -1
  26. package/dist/core/rebase/utils.d.ts +1 -0
  27. package/dist/core/rebase/utils.d.ts.map +1 -1
  28. package/dist/core/rebase/utils.js +29 -4
  29. package/dist/core/rebase/utils.js.map +1 -1
  30. package/dist/events/interop.d.ts +1 -7
  31. package/dist/events/interop.d.ts.map +1 -1
  32. package/dist/events/interop.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  34. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  36. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  37. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  38. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  39. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  40. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  41. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  42. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
  43. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  44. package/dist/feature-libraries/object-forest/objectForest.js +1 -1
  45. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  46. package/dist/feature-libraries/treeCursorUtils.js +2 -2
  47. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  48. package/dist/index.d.ts +4 -4
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +12 -7
  51. package/dist/index.js.map +1 -1
  52. package/dist/internalTypes.d.ts +1 -1
  53. package/dist/internalTypes.d.ts.map +1 -1
  54. package/dist/internalTypes.js.map +1 -1
  55. package/dist/legacy.d.ts +6 -0
  56. package/dist/packageVersion.d.ts +1 -1
  57. package/dist/packageVersion.js +1 -1
  58. package/dist/packageVersion.js.map +1 -1
  59. package/dist/public.d.ts +6 -0
  60. package/dist/shared-tree/independentView.d.ts +57 -0
  61. package/dist/shared-tree/independentView.d.ts.map +1 -0
  62. package/dist/shared-tree/independentView.js +89 -0
  63. package/dist/shared-tree/independentView.js.map +1 -0
  64. package/dist/shared-tree/index.d.ts +3 -1
  65. package/dist/shared-tree/index.d.ts.map +1 -1
  66. package/dist/shared-tree/index.js +6 -1
  67. package/dist/shared-tree/index.js.map +1 -1
  68. package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
  69. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  70. package/dist/shared-tree/schematizingTreeView.js +28 -0
  71. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  72. package/dist/shared-tree/sharedTree.d.ts +10 -7
  73. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  74. package/dist/shared-tree/sharedTree.js.map +1 -1
  75. package/dist/shared-tree/treeApi.d.ts +6 -6
  76. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  77. package/dist/shared-tree/treeApi.js.map +1 -1
  78. package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
  79. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
  80. package/dist/shared-tree/treeApiAlpha.js +122 -0
  81. package/dist/shared-tree/treeApiAlpha.js.map +1 -0
  82. package/dist/shared-tree/treeCheckout.d.ts +12 -7
  83. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  84. package/dist/shared-tree/treeCheckout.js +11 -4
  85. package/dist/shared-tree/treeCheckout.js.map +1 -1
  86. package/dist/shared-tree-core/editManager.d.ts +13 -6
  87. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  88. package/dist/shared-tree-core/editManager.js +80 -33
  89. package/dist/shared-tree-core/editManager.js.map +1 -1
  90. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  91. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  92. package/dist/shared-tree-core/sharedTreeCore.js +28 -3
  93. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  94. package/dist/simple-tree/api/conciseTree.d.ts +2 -1
  95. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  96. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  97. package/dist/simple-tree/api/create.d.ts +6 -24
  98. package/dist/simple-tree/api/create.d.ts.map +1 -1
  99. package/dist/simple-tree/api/create.js +4 -19
  100. package/dist/simple-tree/api/create.js.map +1 -1
  101. package/dist/simple-tree/api/customTree.d.ts +1 -0
  102. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  103. package/dist/simple-tree/api/customTree.js +2 -2
  104. package/dist/simple-tree/api/customTree.js.map +1 -1
  105. package/dist/simple-tree/api/index.d.ts +7 -7
  106. package/dist/simple-tree/api/index.d.ts.map +1 -1
  107. package/dist/simple-tree/api/index.js +10 -2
  108. package/dist/simple-tree/api/index.js.map +1 -1
  109. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
  110. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  111. package/dist/simple-tree/api/schemaCreationUtilities.js +31 -21
  112. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  113. package/dist/simple-tree/api/schemaFactory.d.ts +16 -12
  114. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  115. package/dist/simple-tree/api/schemaFactory.js +4 -0
  116. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  117. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +3 -3
  118. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  119. package/dist/simple-tree/api/storedSchema.js +2 -2
  120. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  121. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  122. package/dist/simple-tree/api/tree.d.ts +122 -5
  123. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  124. package/dist/simple-tree/api/tree.js +12 -4
  125. package/dist/simple-tree/api/tree.js.map +1 -1
  126. package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
  127. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  128. package/dist/simple-tree/api/treeApiBeta.js +3 -15
  129. package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
  130. package/dist/simple-tree/api/typesUnsafe.d.ts +69 -17
  131. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  132. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  133. package/dist/simple-tree/api/verboseTree.d.ts +3 -0
  134. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  135. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  136. package/dist/simple-tree/arrayNode.d.ts +15 -4
  137. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  138. package/dist/simple-tree/arrayNode.js +1 -1
  139. package/dist/simple-tree/arrayNode.js.map +1 -1
  140. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  141. package/dist/simple-tree/core/treeNodeSchema.d.ts +51 -11
  142. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  143. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  144. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  145. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  146. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  147. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  148. package/dist/simple-tree/core/withType.d.ts +2 -1
  149. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  150. package/dist/simple-tree/core/withType.js.map +1 -1
  151. package/dist/simple-tree/createContext.js +2 -2
  152. package/dist/simple-tree/createContext.js.map +1 -1
  153. package/dist/simple-tree/index.d.ts +6 -6
  154. package/dist/simple-tree/index.d.ts.map +1 -1
  155. package/dist/simple-tree/index.js +15 -5
  156. package/dist/simple-tree/index.js.map +1 -1
  157. package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
  158. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  159. package/dist/simple-tree/leafNodeSchema.js +3 -0
  160. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  161. package/dist/simple-tree/mapNode.d.ts +1 -1
  162. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  163. package/dist/simple-tree/mapNode.js +6 -0
  164. package/dist/simple-tree/mapNode.js.map +1 -1
  165. package/dist/simple-tree/objectNode.d.ts +4 -2
  166. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  167. package/dist/simple-tree/objectNode.js.map +1 -1
  168. package/dist/simple-tree/schemaTypes.d.ts +210 -18
  169. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  170. package/dist/simple-tree/schemaTypes.js +66 -1
  171. package/dist/simple-tree/schemaTypes.js.map +1 -1
  172. package/dist/simple-tree/toMapTree.d.ts +4 -2
  173. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  174. package/dist/simple-tree/toMapTree.js.map +1 -1
  175. package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  176. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
  177. package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  178. package/dist/simple-tree/toStoredSchema.js.map +1 -0
  179. package/dist/simple-tree/treeNodeValid.d.ts +5 -1
  180. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  181. package/dist/simple-tree/treeNodeValid.js +7 -1
  182. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  183. package/dist/util/index.d.ts +3 -2
  184. package/dist/util/index.d.ts.map +1 -1
  185. package/dist/util/index.js +3 -1
  186. package/dist/util/index.js.map +1 -1
  187. package/dist/util/typeCheck.d.ts +9 -0
  188. package/dist/util/typeCheck.d.ts.map +1 -1
  189. package/dist/util/typeCheck.js.map +1 -1
  190. package/dist/util/typeUtils.d.ts +61 -0
  191. package/dist/util/typeUtils.d.ts.map +1 -1
  192. package/dist/util/typeUtils.js +27 -0
  193. package/dist/util/typeUtils.js.map +1 -1
  194. package/dist/util/utils.d.ts +7 -3
  195. package/dist/util/utils.d.ts.map +1 -1
  196. package/dist/util/utils.js +13 -3
  197. package/dist/util/utils.js.map +1 -1
  198. package/lib/alpha.d.ts +32 -2
  199. package/lib/beta.d.ts +6 -0
  200. package/lib/codec/codec.d.ts +24 -0
  201. package/lib/codec/codec.d.ts.map +1 -1
  202. package/lib/codec/codec.js +25 -0
  203. package/lib/codec/codec.js.map +1 -1
  204. package/lib/codec/index.d.ts +1 -1
  205. package/lib/codec/index.d.ts.map +1 -1
  206. package/lib/codec/index.js +1 -1
  207. package/lib/codec/index.js.map +1 -1
  208. package/lib/core/rebase/index.d.ts +2 -2
  209. package/lib/core/rebase/index.d.ts.map +1 -1
  210. package/lib/core/rebase/index.js +2 -2
  211. package/lib/core/rebase/index.js.map +1 -1
  212. package/lib/core/rebase/types.d.ts +0 -4
  213. package/lib/core/rebase/types.d.ts.map +1 -1
  214. package/lib/core/rebase/types.js +0 -5
  215. package/lib/core/rebase/types.js.map +1 -1
  216. package/lib/core/rebase/utils.d.ts +1 -0
  217. package/lib/core/rebase/utils.d.ts.map +1 -1
  218. package/lib/core/rebase/utils.js +27 -3
  219. package/lib/core/rebase/utils.js.map +1 -1
  220. package/lib/events/interop.d.ts +1 -7
  221. package/lib/events/interop.d.ts.map +1 -1
  222. package/lib/events/interop.js.map +1 -1
  223. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  224. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  225. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  226. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  227. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  228. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  229. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  230. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  231. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  232. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
  233. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  234. package/lib/feature-libraries/object-forest/objectForest.js +1 -1
  235. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  236. package/lib/feature-libraries/treeCursorUtils.js +2 -2
  237. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  238. package/lib/index.d.ts +4 -4
  239. package/lib/index.d.ts.map +1 -1
  240. package/lib/index.js +4 -3
  241. package/lib/index.js.map +1 -1
  242. package/lib/internalTypes.d.ts +1 -1
  243. package/lib/internalTypes.d.ts.map +1 -1
  244. package/lib/internalTypes.js.map +1 -1
  245. package/lib/legacy.d.ts +6 -0
  246. package/lib/packageVersion.d.ts +1 -1
  247. package/lib/packageVersion.js +1 -1
  248. package/lib/packageVersion.js.map +1 -1
  249. package/lib/public.d.ts +6 -0
  250. package/lib/shared-tree/independentView.d.ts +57 -0
  251. package/lib/shared-tree/independentView.d.ts.map +1 -0
  252. package/lib/shared-tree/independentView.js +84 -0
  253. package/lib/shared-tree/independentView.js.map +1 -0
  254. package/lib/shared-tree/index.d.ts +3 -1
  255. package/lib/shared-tree/index.d.ts.map +1 -1
  256. package/lib/shared-tree/index.js +2 -0
  257. package/lib/shared-tree/index.js.map +1 -1
  258. package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
  259. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  260. package/lib/shared-tree/schematizingTreeView.js +29 -1
  261. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  262. package/lib/shared-tree/sharedTree.d.ts +10 -7
  263. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  264. package/lib/shared-tree/sharedTree.js.map +1 -1
  265. package/lib/shared-tree/treeApi.d.ts +6 -6
  266. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  267. package/lib/shared-tree/treeApi.js.map +1 -1
  268. package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
  269. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
  270. package/lib/shared-tree/treeApiAlpha.js +119 -0
  271. package/lib/shared-tree/treeApiAlpha.js.map +1 -0
  272. package/lib/shared-tree/treeCheckout.d.ts +12 -7
  273. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  274. package/lib/shared-tree/treeCheckout.js +11 -4
  275. package/lib/shared-tree/treeCheckout.js.map +1 -1
  276. package/lib/shared-tree-core/editManager.d.ts +13 -6
  277. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  278. package/lib/shared-tree-core/editManager.js +80 -33
  279. package/lib/shared-tree-core/editManager.js.map +1 -1
  280. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  281. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  282. package/lib/shared-tree-core/sharedTreeCore.js +29 -4
  283. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  284. package/lib/simple-tree/api/conciseTree.d.ts +2 -1
  285. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  286. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  287. package/lib/simple-tree/api/create.d.ts +6 -24
  288. package/lib/simple-tree/api/create.d.ts.map +1 -1
  289. package/lib/simple-tree/api/create.js +2 -16
  290. package/lib/simple-tree/api/create.js.map +1 -1
  291. package/lib/simple-tree/api/customTree.d.ts +1 -0
  292. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  293. package/lib/simple-tree/api/customTree.js +2 -2
  294. package/lib/simple-tree/api/customTree.js.map +1 -1
  295. package/lib/simple-tree/api/index.d.ts +7 -7
  296. package/lib/simple-tree/api/index.d.ts.map +1 -1
  297. package/lib/simple-tree/api/index.js +6 -4
  298. package/lib/simple-tree/api/index.js.map +1 -1
  299. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +25 -27
  300. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  301. package/lib/simple-tree/api/schemaCreationUtilities.js +30 -19
  302. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  303. package/lib/simple-tree/api/schemaFactory.d.ts +16 -12
  304. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  305. package/lib/simple-tree/api/schemaFactory.js +4 -0
  306. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  307. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +3 -3
  308. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  309. package/lib/simple-tree/api/storedSchema.js +1 -1
  310. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  311. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  312. package/lib/simple-tree/api/tree.d.ts +122 -5
  313. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  314. package/lib/simple-tree/api/tree.js +9 -2
  315. package/lib/simple-tree/api/tree.js.map +1 -1
  316. package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
  317. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  318. package/lib/simple-tree/api/treeApiBeta.js +4 -16
  319. package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
  320. package/lib/simple-tree/api/typesUnsafe.d.ts +69 -17
  321. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  322. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  323. package/lib/simple-tree/api/verboseTree.d.ts +3 -0
  324. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  325. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  326. package/lib/simple-tree/arrayNode.d.ts +15 -4
  327. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  328. package/lib/simple-tree/arrayNode.js +1 -1
  329. package/lib/simple-tree/arrayNode.js.map +1 -1
  330. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  331. package/lib/simple-tree/core/treeNodeSchema.d.ts +51 -11
  332. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  333. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  334. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  335. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  336. package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
  337. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  338. package/lib/simple-tree/core/withType.d.ts +2 -1
  339. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  340. package/lib/simple-tree/core/withType.js.map +1 -1
  341. package/lib/simple-tree/createContext.js +1 -1
  342. package/lib/simple-tree/createContext.js.map +1 -1
  343. package/lib/simple-tree/index.d.ts +6 -6
  344. package/lib/simple-tree/index.d.ts.map +1 -1
  345. package/lib/simple-tree/index.js +5 -5
  346. package/lib/simple-tree/index.js.map +1 -1
  347. package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
  348. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  349. package/lib/simple-tree/leafNodeSchema.js +3 -0
  350. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  351. package/lib/simple-tree/mapNode.d.ts +1 -1
  352. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  353. package/lib/simple-tree/mapNode.js +6 -0
  354. package/lib/simple-tree/mapNode.js.map +1 -1
  355. package/lib/simple-tree/objectNode.d.ts +4 -2
  356. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  357. package/lib/simple-tree/objectNode.js.map +1 -1
  358. package/lib/simple-tree/schemaTypes.d.ts +210 -18
  359. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  360. package/lib/simple-tree/schemaTypes.js +64 -1
  361. package/lib/simple-tree/schemaTypes.js.map +1 -1
  362. package/lib/simple-tree/toMapTree.d.ts +4 -2
  363. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  364. package/lib/simple-tree/toMapTree.js.map +1 -1
  365. package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  366. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
  367. package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  368. package/lib/simple-tree/toStoredSchema.js.map +1 -0
  369. package/lib/simple-tree/treeNodeValid.d.ts +5 -1
  370. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  371. package/lib/simple-tree/treeNodeValid.js +7 -1
  372. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  373. package/lib/util/index.d.ts +3 -2
  374. package/lib/util/index.d.ts.map +1 -1
  375. package/lib/util/index.js +1 -0
  376. package/lib/util/index.js.map +1 -1
  377. package/lib/util/typeCheck.d.ts +9 -0
  378. package/lib/util/typeCheck.d.ts.map +1 -1
  379. package/lib/util/typeCheck.js.map +1 -1
  380. package/lib/util/typeUtils.d.ts +61 -0
  381. package/lib/util/typeUtils.d.ts.map +1 -1
  382. package/lib/util/typeUtils.js +25 -1
  383. package/lib/util/typeUtils.js.map +1 -1
  384. package/lib/util/utils.d.ts +7 -3
  385. package/lib/util/utils.d.ts.map +1 -1
  386. package/lib/util/utils.js +13 -3
  387. package/lib/util/utils.js.map +1 -1
  388. package/package.json +55 -30
  389. package/src/codec/codec.ts +25 -0
  390. package/src/codec/index.ts +1 -0
  391. package/src/core/rebase/index.ts +1 -1
  392. package/src/core/rebase/types.ts +0 -12
  393. package/src/core/rebase/utils.ts +35 -3
  394. package/src/events/interop.ts +1 -12
  395. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  396. package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
  397. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
  398. package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
  399. package/src/feature-libraries/object-forest/objectForest.ts +1 -1
  400. package/src/feature-libraries/treeCursorUtils.ts +2 -2
  401. package/src/index.ts +36 -6
  402. package/src/internalTypes.ts +4 -0
  403. package/src/packageVersion.ts +1 -1
  404. package/src/shared-tree/independentView.ts +176 -0
  405. package/src/shared-tree/index.ts +9 -1
  406. package/src/shared-tree/schematizingTreeView.ts +64 -13
  407. package/src/shared-tree/sharedTree.ts +29 -9
  408. package/src/shared-tree/treeApi.ts +19 -9
  409. package/src/shared-tree/treeApiAlpha.ts +401 -0
  410. package/src/shared-tree/treeCheckout.ts +28 -5
  411. package/src/shared-tree-core/editManager.ts +126 -59
  412. package/src/shared-tree-core/sharedTreeCore.ts +37 -8
  413. package/src/simple-tree/api/conciseTree.ts +2 -1
  414. package/src/simple-tree/api/create.ts +33 -65
  415. package/src/simple-tree/api/customTree.ts +3 -2
  416. package/src/simple-tree/api/index.ts +19 -8
  417. package/src/simple-tree/api/schemaCreationUtilities.ts +59 -37
  418. package/src/simple-tree/api/schemaFactory.ts +28 -12
  419. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +3 -3
  420. package/src/simple-tree/api/storedSchema.ts +1 -1
  421. package/src/simple-tree/api/tree.ts +152 -7
  422. package/src/simple-tree/api/treeApiBeta.ts +35 -31
  423. package/src/simple-tree/api/typesUnsafe.ts +125 -30
  424. package/src/simple-tree/api/verboseTree.ts +3 -0
  425. package/src/simple-tree/arrayNode.ts +38 -17
  426. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  427. package/src/simple-tree/core/treeNodeSchema.ts +107 -34
  428. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
  429. package/src/simple-tree/core/withType.ts +2 -1
  430. package/src/simple-tree/createContext.ts +1 -1
  431. package/src/simple-tree/index.ts +34 -3
  432. package/src/simple-tree/leafNodeSchema.ts +6 -1
  433. package/src/simple-tree/mapNode.ts +13 -4
  434. package/src/simple-tree/objectNode.ts +5 -3
  435. package/src/simple-tree/schemaTypes.ts +342 -36
  436. package/src/simple-tree/toMapTree.ts +4 -1
  437. package/src/simple-tree/treeNodeValid.ts +11 -1
  438. package/src/util/index.ts +7 -0
  439. package/src/util/typeCheck.ts +13 -0
  440. package/src/util/typeUtils.ts +87 -0
  441. package/src/util/utils.ts +20 -7
  442. package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
  443. package/dist/simple-tree/toFlexSchema.js.map +0 -1
  444. package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
  445. package/lib/simple-tree/toFlexSchema.js.map +0 -1
  446. /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
@@ -53,6 +53,14 @@ const minimumPossibleSequenceId: SequenceId = {
53
53
  sequenceNumber: minimumPossibleSequenceNumber,
54
54
  };
55
55
 
56
+ /**
57
+ * A special revision tag for the initial {@link EditManager.trunkBase} commit.
58
+ * @remarks This tag is used to supply the _initial_ trunk base with a known revision.
59
+ * The trunk base may advance over time, after which point the trunk base will have a different revision.
60
+ * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.
61
+ */
62
+ const rootRevision = "root" as const satisfies RevisionTag;
63
+
56
64
  /**
57
65
  * Max number of telemetry log call that may be aggregated before being sent.
58
66
  */
@@ -152,7 +160,7 @@ export class EditManager<
152
160
  logger?: ITelemetryLoggerExt,
153
161
  ) {
154
162
  this.trunkBase = {
155
- revision: "root",
163
+ revision: rootRevision,
156
164
  change: changeFamily.rebaser.compose([]),
157
165
  };
158
166
  this.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);
@@ -262,30 +270,62 @@ export class EditManager<
262
270
  }
263
271
 
264
272
  /**
265
- * Updates the `trunkBranches` map to reflect the fact that a new local commit was fast-forwarded to the trunk.
266
- * @param priorTrunkCommit - The trunk head prior to the fast-forward.
267
- * @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.
268
280
  */
269
- private fastForwardBranches(
270
- priorTrunkCommit: GraphCommit<TChangeset>,
271
- newId: SequenceId,
272
- ): void {
273
- const currentId = this.getCommitSequenceId(priorTrunkCommit);
274
- 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);
275
302
  if (currentBranches !== undefined) {
276
- const newBranches = getOrCreate(this.trunkBranches, newId, () => new Set());
303
+ const newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());
277
304
  for (const branch of currentBranches) {
278
- 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) {
279
308
  newBranches.add(branch);
280
309
  currentBranches.delete(branch);
281
310
  }
282
311
  }
312
+ // Clean up our trunk branches map by removing any empty sets.
283
313
  if (currentBranches.size === 0) {
284
- this.trunkBranches.delete(currentId);
314
+ this.trunkBranches.delete(previousSequenceId);
315
+ }
316
+ if (newBranches.size === 0) {
317
+ this.trunkBranches.delete(sequenceId);
285
318
  }
286
319
  }
287
320
  }
288
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
+
289
329
  /**
290
330
  * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,
291
331
  * if they are not retained by revertibles or local branches.
@@ -293,7 +333,10 @@ export class EditManager<
293
333
  *
294
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.
295
335
  */
296
- public advanceMinimumSequenceNumber(minimumSequenceNumber: SeqNumber): void {
336
+ public advanceMinimumSequenceNumber(
337
+ minimumSequenceNumber: SeqNumber,
338
+ trimTrunk = true,
339
+ ): void {
297
340
  if (minimumSequenceNumber === this.minimumSequenceNumber) {
298
341
  return;
299
342
  }
@@ -304,16 +347,17 @@ export class EditManager<
304
347
  );
305
348
 
306
349
  this.minimumSequenceNumber = minimumSequenceNumber;
307
- this.trimTrunk();
350
+ if (trimTrunk) {
351
+ this.trimTrunk();
352
+ }
308
353
  }
309
354
 
310
355
  /**
311
356
  * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine
312
357
  * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.
313
- * @returns the number of commits that were removed from the trunk
314
358
  */
315
359
  private trimTrunk(): void {
316
- /** 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 */
317
361
  let trunkTailSequenceId: SequenceId = {
318
362
  sequenceNumber: this.minimumSequenceNumber,
319
363
  indexInBatch: Number.POSITIVE_INFINITY,
@@ -363,34 +407,45 @@ export class EditManager<
363
407
  newTrunkBase,
364
408
  this.trunkBase,
365
409
  ).map((c) => c.revision);
366
- // Copying the revision of the old trunk base into the new trunk base means we don't need to write out the original
367
- // revision to summaries. All clients agree that the trunk base always has the same hardcoded revision.
368
- newTrunkBase.revision = this.trunkBase.revision;
369
- // Overwriting the change is not strictly necessary, but done here for consistency (so all trunk bases are deeply equal).
370
- newTrunkBase.change = this.trunkBase.change;
371
410
  // Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.
372
411
  delete newTrunkBase.parent;
373
412
  this.trunkBase = newTrunkBase;
374
413
 
375
414
  // Update any state that is derived from trunk commits
376
- this.sequenceMap.editRange(
377
- minimumPossibleSequenceId,
378
- sequenceId,
379
- true,
380
- (s, { revision }) => {
381
- // Cleanup look-aside data for each evicted commit
382
- this.trunkMetadata.delete(revision);
383
- // Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`
384
- if (equalSequenceIds(s, sequenceId)) {
385
- assert(
386
- revision === newTrunkBase.revision,
387
- 0x729 /* Expected last evicted commit to be new trunk base */,
388
- );
389
- } else {
390
- return { delete: true };
391
- }
392
- },
393
- );
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
+ });
394
449
 
395
450
  const trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;
396
451
  assert(
@@ -429,6 +484,9 @@ export class EditManager<
429
484
  0x428 /* Clients with local changes cannot be used to generate summaries */,
430
485
  );
431
486
 
487
+ // Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.
488
+ this.trimTrunk();
489
+
432
490
  let oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];
433
491
  assert(
434
492
  oldestCommitInCollabWindow.parent !== undefined ||
@@ -442,6 +500,10 @@ export class EditManager<
442
500
 
443
501
  const trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(
444
502
  (c) => {
503
+ assert(
504
+ c !== this.trunkBase,
505
+ 0xa61 /* Serialized trunk should not include the trunk base */,
506
+ );
445
507
  const metadata =
446
508
  this.trunkMetadata.get(c.revision) ?? fail("Expected metadata for trunk commit");
447
509
  const commit: SequencedCommit<TChangeset> = {
@@ -464,11 +526,16 @@ export class EditManager<
464
526
  findCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??
465
527
  fail("Expected branch to be based on trunk");
466
528
 
529
+ const base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;
467
530
  return [
468
531
  sessionId,
469
532
  {
470
- base: ancestor.revision,
533
+ base,
471
534
  commits: branchPath.map((c) => {
535
+ assert(
536
+ c !== this.trunkBase,
537
+ 0xa62 /* Serialized branch should not include the trunk base */,
538
+ );
472
539
  const commit: Commit<TChangeset> = {
473
540
  change: c.change,
474
541
  revision: c.revision,
@@ -533,8 +600,16 @@ export class EditManager<
533
600
  }
534
601
  }
535
602
 
536
- private getCommitSequenceId(commit: GraphCommit<TChangeset>): SequenceId {
537
- 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;
538
613
  }
539
614
 
540
615
  public getTrunkChanges(): readonly TChangeset[] {
@@ -586,6 +661,12 @@ export class EditManager<
586
661
  0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,
587
662
  );
588
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
+
589
670
  const commitsSequenceNumber = this.getBatch(sequenceNumber);
590
671
  const sequenceId: SequenceId =
591
672
  commitsSequenceNumber.length === 0
@@ -598,17 +679,7 @@ export class EditManager<
598
679
  };
599
680
 
600
681
  if (newCommit.sessionId === this.localSessionId) {
601
- const headTrunkCommit = this.trunk.getHead();
602
- const firstLocalCommit = this.localCommits.shift();
603
- assert(
604
- firstLocalCommit !== undefined,
605
- 0x6b5 /* Received a sequenced change from the local session despite having no local changes */,
606
- );
607
-
608
- // The first local branch commit is already rebased over the trunk, so we can push it directly to the trunk.
609
- this.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);
610
- this.fastForwardBranches(headTrunkCommit, sequenceId);
611
- return;
682
+ return this.fastForwardNextLocalCommit(sequenceId);
612
683
  }
613
684
 
614
685
  // Get the revision that the remote change is based on
@@ -665,11 +736,7 @@ export class EditManager<
665
736
  return [commit, commits];
666
737
  }
667
738
 
668
- private pushCommitToTrunk(
669
- sequenceId: SequenceId,
670
- commit: Commit<TChangeset>,
671
- local = false,
672
- ): void {
739
+ private pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {
673
740
  const mintedCommit = mintCommit(this.trunk.getHead(), commit);
674
741
  this.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);
675
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,21 +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
- InsertableTreeFieldFromImplicitField,
14
11
  TreeFieldFromImplicitField,
15
12
  FieldSchema,
16
13
  FieldKind,
14
+ UnsafeUnknownSchema,
15
+ InsertableField,
16
+ TreeLeafValue,
17
17
  } from "../schemaTypes.js";
18
18
  import {
19
19
  getOrCreateNodeFromInnerNode,
20
20
  UnhydratedFlexTreeNode,
21
+ type TreeNode,
21
22
  type Unhydrated,
22
23
  } from "../core/index.js";
23
24
  import {
@@ -28,15 +29,8 @@ import {
28
29
  type NodeKeyManager,
29
30
  } from "../../feature-libraries/index.js";
30
31
  import { isFieldInSchema } from "../../feature-libraries/index.js";
31
- import { toStoredSchema } from "../toFlexSchema.js";
32
- import { inSchemaOrThrow, mapTreeFromNodeData, type InsertableContent } from "../toMapTree.js";
33
- import {
34
- applySchemaToParserOptions,
35
- cursorFromVerbose,
36
- type ParseOptions,
37
- type VerboseTree,
38
- type VerboseTreeNode,
39
- } from "./verboseTree.js";
32
+ import { toStoredSchema } from "../toStoredSchema.js";
33
+ import { inSchemaOrThrow, mapTreeFromNodeData } from "../toMapTree.js";
40
34
  import { getUnhydratedContext } from "../createContext.js";
41
35
 
42
36
  /**
@@ -49,18 +43,28 @@ import { getUnhydratedContext } from "../createContext.js";
49
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.
50
44
  *
51
45
  * Like with {@link TreeNodeSchemaClass}'s constructor, its an error to provide an existing node to this API.
52
- * TODO: For that case, use we should provide `Tree.clone`.
53
- * @privateRemarks
54
- * This could be exposed as a public `Tree.create` function.
46
+ * For that case, use {@link TreeBeta.clone}.
55
47
  */
56
- export function createFromInsertable<TSchema extends ImplicitFieldSchema>(
57
- schema: TSchema,
58
- data: InsertableTreeFieldFromImplicitField<TSchema>,
48
+ export function createFromInsertable<
49
+ const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
50
+ >(
51
+ schema: UnsafeUnknownSchema extends TSchema
52
+ ? ImplicitFieldSchema
53
+ : TSchema & ImplicitFieldSchema,
54
+ data: InsertableField<TSchema>,
59
55
  context?: NodeKeyManager | undefined,
60
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
56
+ ): Unhydrated<
57
+ TSchema extends ImplicitFieldSchema
58
+ ? TreeFieldFromImplicitField<TSchema>
59
+ : TreeNode | TreeLeafValue | undefined
60
+ > {
61
61
  const cursor = cursorFromInsertable(schema, data, context);
62
62
  const result = cursor === undefined ? undefined : createFromCursor(schema, cursor);
63
- return result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
63
+ return result as Unhydrated<
64
+ TSchema extends ImplicitFieldSchema
65
+ ? TreeFieldFromImplicitField<TSchema>
66
+ : TreeNode | TreeLeafValue | undefined
67
+ >;
64
68
  }
65
69
 
66
70
  /**
@@ -72,9 +76,13 @@ export function createFromInsertable<TSchema extends ImplicitFieldSchema>(
72
76
  * this is the same as invoking its constructor except that an unhydrated node can also be provided and the returned value is a cursor.
73
77
  * When `undefined` is provided (for an optional field), `undefined` is returned.
74
78
  */
75
- export function cursorFromInsertable<TSchema extends ImplicitFieldSchema>(
76
- schema: TSchema,
77
- data: InsertableTreeFieldFromImplicitField<TSchema>,
79
+ export function cursorFromInsertable<
80
+ TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,
81
+ >(
82
+ schema: UnsafeUnknownSchema extends TSchema
83
+ ? ImplicitFieldSchema
84
+ : TSchema & ImplicitFieldSchema,
85
+ data: InsertableField<TSchema>,
78
86
  context?: NodeKeyManager | undefined,
79
87
  ):
80
88
  | ITreeCursorSynchronous
@@ -87,7 +95,7 @@ export function cursorFromInsertable<TSchema extends ImplicitFieldSchema>(
87
95
  };
88
96
 
89
97
  const mapTree = mapTreeFromNodeData(
90
- data as InsertableContent | undefined,
98
+ data as InsertableField<UnsafeUnknownSchema>,
91
99
  schema,
92
100
  context,
93
101
  schemaValidationPolicy,
@@ -102,50 +110,10 @@ export function cursorFromInsertable<TSchema extends ImplicitFieldSchema>(
102
110
  return cursorForMapTreeNode(mapTree);
103
111
  }
104
112
 
105
- /**
106
- * Construct tree content compatible with a field defined by the provided `schema`.
107
- * @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.
108
- * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.
109
- * @privateRemarks
110
- * This could be exposed as a public `Tree.createFromVerbose` function.
111
- */
112
- export function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(
113
- schema: TSchema,
114
- data: VerboseTreeNode<THandle> | undefined,
115
- options: ParseOptions<THandle>,
116
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
117
-
118
- /**
119
- * Construct tree content compatible with a field defined by the provided `schema`.
120
- * @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.
121
- * @param data - The data used to construct the field content. See `Tree.cloneToJSONVerbose`.
122
- */
123
- export function createFromVerbose<TSchema extends ImplicitFieldSchema>(
124
- schema: TSchema,
125
- data: VerboseTreeNode | undefined,
126
- options?: Partial<ParseOptions<IFluidHandle>>,
127
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
128
-
129
- export function createFromVerbose<TSchema extends ImplicitFieldSchema, THandle>(
130
- schema: TSchema,
131
- data: VerboseTreeNode<THandle> | undefined,
132
- options?: Partial<ParseOptions<THandle>>,
133
- ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
134
- const config: ParseOptions<THandle> = {
135
- valueConverter: (input: VerboseTree<THandle>) => {
136
- return input as TreeLeafValue | VerboseTreeNode<THandle>;
137
- },
138
- ...options,
139
- };
140
- const schemalessConfig = applySchemaToParserOptions(schema, config);
141
- const cursor = cursorFromVerbose(data, schemalessConfig);
142
- return createFromCursor(schema, cursor);
143
- }
144
-
145
113
  /**
146
114
  * Creates an unhydrated simple-tree field from a cursor in nodes mode.
147
115
  */
148
- export function createFromCursor<TSchema extends ImplicitFieldSchema>(
116
+ export function createFromCursor<const TSchema extends ImplicitFieldSchema>(
149
117
  schema: TSchema,
150
118
  cursor: ITreeCursorSynchronous | undefined,
151
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
  /**
@@ -102,8 +103,8 @@ export function customFromCursorInner<TChild, THandle>(
102
103
  const storedKey = reader.getFieldKey();
103
104
  const key =
104
105
  isObjectNodeSchema(nodeSchema) && !options.useStoredKeys
105
- ? nodeSchema.storedKeyToPropertyKey.get(storedKey) ??
106
- fail("missing property key")
106
+ ? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??
107
+ fail("missing property key"))
107
108
  : storedKey;
108
109
  // Length is checked above.
109
110
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -12,6 +12,10 @@ export {
12
12
  type ITreeViewConfiguration,
13
13
  type SchemaCompatibilityStatus,
14
14
  type ITreeConfigurationOptions,
15
+ type TreeViewAlpha,
16
+ type TreeBranch,
17
+ type TreeBranchEvents,
18
+ asTreeViewAlpha,
15
19
  } from "./tree.js";
16
20
  export { SchemaFactory, type ScopedSchemaName } from "./schemaFactory.js";
17
21
  export type {
@@ -22,10 +26,9 @@ export {
22
26
  adaptEnum,
23
27
  enumFromStrings,
24
28
  singletonSchema,
25
- typedObjectValues,
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,
@@ -62,17 +65,25 @@ export type {
62
65
  NodeBuilderDataUnsafe,
63
66
  NodeFromSchemaUnsafe,
64
67
  ReadonlyMapInlined,
68
+ TreeNodeSchemaClassUnsafe,
69
+ TreeNodeSchemaUnsafe,
70
+ AllowedTypesUnsafe,
71
+ TreeNodeSchemaNonClassUnsafe,
72
+ InsertableTreeNodeFromAllowedTypesUnsafe,
65
73
  } from "./typesUnsafe.js";
66
74
 
67
- export type {
68
- VerboseTreeNode,
69
- ParseOptions,
70
- VerboseTree,
75
+ export {
76
+ type VerboseTreeNode,
77
+ type ParseOptions,
78
+ type VerboseTree,
79
+ applySchemaToParserOptions,
80
+ cursorFromVerbose,
81
+ verboseFromCursor,
71
82
  } from "./verboseTree.js";
72
83
 
73
84
  export type { EncodeOptions } from "./customTree.js";
74
85
 
75
- export type { ConciseTree } from "./conciseTree.js";
86
+ export { type ConciseTree, conciseFromCursor } from "./conciseTree.js";
76
87
 
77
88
  export { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from "./treeApiBeta.js";
78
89