@fluidframework/tree 2.5.0-302463 → 2.10.0-304831

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 (378) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +371 -0
  3. package/api-report/tree.alpha.api.md +161 -69
  4. package/api-report/tree.beta.api.md +36 -37
  5. package/api-report/tree.legacy.alpha.api.md +35 -36
  6. package/api-report/tree.legacy.public.api.md +35 -36
  7. package/api-report/tree.public.api.md +35 -36
  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 +3 -7
  22. package/dist/core/rebase/types.d.ts.map +1 -1
  23. package/dist/core/rebase/types.js +4 -10
  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/core/revertible.d.ts +1 -1
  30. package/dist/core/revertible.js.map +1 -1
  31. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  32. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  33. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  34. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  35. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  36. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
  37. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  38. package/dist/index.d.ts +3 -3
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +12 -6
  41. package/dist/index.js.map +1 -1
  42. package/dist/internalTypes.d.ts +1 -1
  43. package/dist/internalTypes.d.ts.map +1 -1
  44. package/dist/internalTypes.js.map +1 -1
  45. package/dist/packageVersion.d.ts +1 -1
  46. package/dist/packageVersion.d.ts.map +1 -1
  47. package/dist/packageVersion.js +1 -1
  48. package/dist/packageVersion.js.map +1 -1
  49. package/dist/shared-tree/independentView.d.ts +57 -0
  50. package/dist/shared-tree/independentView.d.ts.map +1 -0
  51. package/dist/shared-tree/independentView.js +89 -0
  52. package/dist/shared-tree/independentView.js.map +1 -0
  53. package/dist/shared-tree/index.d.ts +3 -1
  54. package/dist/shared-tree/index.d.ts.map +1 -1
  55. package/dist/shared-tree/index.js +6 -1
  56. package/dist/shared-tree/index.js.map +1 -1
  57. package/dist/shared-tree/schematizingTreeView.d.ts +13 -9
  58. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  59. package/dist/shared-tree/schematizingTreeView.js +32 -1
  60. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  61. package/dist/shared-tree/sharedTree.d.ts +10 -7
  62. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  63. package/dist/shared-tree/sharedTree.js.map +1 -1
  64. package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
  65. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
  66. package/dist/shared-tree/treeApiAlpha.js +122 -0
  67. package/dist/shared-tree/treeApiAlpha.js.map +1 -0
  68. package/dist/shared-tree/treeCheckout.d.ts +19 -17
  69. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  70. package/dist/shared-tree/treeCheckout.js +16 -7
  71. package/dist/shared-tree/treeCheckout.js.map +1 -1
  72. package/dist/shared-tree-core/editManager.d.ts +13 -6
  73. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  74. package/dist/shared-tree-core/editManager.js +70 -28
  75. package/dist/shared-tree-core/editManager.js.map +1 -1
  76. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  77. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  78. package/dist/shared-tree-core/sharedTreeCore.js +28 -3
  79. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  80. package/dist/simple-tree/api/conciseTree.d.ts +2 -1
  81. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  82. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  83. package/dist/simple-tree/api/create.d.ts +5 -23
  84. package/dist/simple-tree/api/create.d.ts.map +1 -1
  85. package/dist/simple-tree/api/create.js +4 -19
  86. package/dist/simple-tree/api/create.js.map +1 -1
  87. package/dist/simple-tree/api/customTree.d.ts +1 -0
  88. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  89. package/dist/simple-tree/api/customTree.js.map +1 -1
  90. package/dist/simple-tree/api/index.d.ts +5 -5
  91. package/dist/simple-tree/api/index.d.ts.map +1 -1
  92. package/dist/simple-tree/api/index.js +10 -1
  93. package/dist/simple-tree/api/index.js.map +1 -1
  94. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
  95. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  96. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  97. package/dist/simple-tree/api/schemaFactory.d.ts +11 -11
  98. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  99. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  100. package/dist/simple-tree/api/storedSchema.js +2 -2
  101. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  102. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  103. package/dist/simple-tree/api/tree.d.ts +125 -7
  104. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  105. package/dist/simple-tree/api/tree.js +12 -4
  106. package/dist/simple-tree/api/tree.js.map +1 -1
  107. package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
  108. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  109. package/dist/simple-tree/api/treeApiBeta.js +3 -15
  110. package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
  111. package/dist/simple-tree/api/typesUnsafe.d.ts +3 -3
  112. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  113. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  114. package/dist/simple-tree/api/verboseTree.d.ts +3 -0
  115. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  116. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  117. package/dist/simple-tree/arrayNode.d.ts +9 -15
  118. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  119. package/dist/simple-tree/arrayNode.js +1 -1
  120. package/dist/simple-tree/arrayNode.js.map +1 -1
  121. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  122. package/dist/simple-tree/core/treeNodeSchema.d.ts +45 -9
  123. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  124. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  125. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  126. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  127. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  128. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  129. package/dist/simple-tree/core/withType.d.ts +1 -2
  130. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  131. package/dist/simple-tree/core/withType.js.map +1 -1
  132. package/dist/simple-tree/createContext.js +2 -2
  133. package/dist/simple-tree/createContext.js.map +1 -1
  134. package/dist/simple-tree/index.d.ts +5 -5
  135. package/dist/simple-tree/index.d.ts.map +1 -1
  136. package/dist/simple-tree/index.js +15 -4
  137. package/dist/simple-tree/index.js.map +1 -1
  138. package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
  139. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  140. package/dist/simple-tree/leafNodeSchema.js +3 -0
  141. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  142. package/dist/simple-tree/mapNode.d.ts +1 -1
  143. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  144. package/dist/simple-tree/mapNode.js +3 -0
  145. package/dist/simple-tree/mapNode.js.map +1 -1
  146. package/dist/simple-tree/schemaTypes.d.ts +45 -7
  147. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  148. package/dist/simple-tree/schemaTypes.js +61 -1
  149. package/dist/simple-tree/schemaTypes.js.map +1 -1
  150. package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  151. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
  152. package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  153. package/dist/simple-tree/toStoredSchema.js.map +1 -0
  154. package/dist/simple-tree/treeNodeValid.d.ts +5 -1
  155. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  156. package/dist/simple-tree/treeNodeValid.js +7 -1
  157. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  158. package/dist/util/index.d.ts +1 -1
  159. package/dist/util/index.d.ts.map +1 -1
  160. package/dist/util/index.js.map +1 -1
  161. package/dist/util/typeCheck.d.ts +9 -0
  162. package/dist/util/typeCheck.d.ts.map +1 -1
  163. package/dist/util/typeCheck.js.map +1 -1
  164. package/dist/util/utils.d.ts +7 -3
  165. package/dist/util/utils.d.ts.map +1 -1
  166. package/dist/util/utils.js +13 -3
  167. package/dist/util/utils.js.map +1 -1
  168. package/lib/alpha.d.ts +15 -0
  169. package/lib/codec/codec.d.ts +24 -0
  170. package/lib/codec/codec.d.ts.map +1 -1
  171. package/lib/codec/codec.js +25 -0
  172. package/lib/codec/codec.js.map +1 -1
  173. package/lib/codec/index.d.ts +1 -1
  174. package/lib/codec/index.d.ts.map +1 -1
  175. package/lib/codec/index.js +1 -1
  176. package/lib/codec/index.js.map +1 -1
  177. package/lib/core/rebase/index.d.ts +2 -2
  178. package/lib/core/rebase/index.d.ts.map +1 -1
  179. package/lib/core/rebase/index.js +2 -2
  180. package/lib/core/rebase/index.js.map +1 -1
  181. package/lib/core/rebase/types.d.ts +3 -7
  182. package/lib/core/rebase/types.d.ts.map +1 -1
  183. package/lib/core/rebase/types.js +3 -8
  184. package/lib/core/rebase/types.js.map +1 -1
  185. package/lib/core/rebase/utils.d.ts +1 -0
  186. package/lib/core/rebase/utils.d.ts.map +1 -1
  187. package/lib/core/rebase/utils.js +27 -3
  188. package/lib/core/rebase/utils.js.map +1 -1
  189. package/lib/core/revertible.d.ts +1 -1
  190. package/lib/core/revertible.js.map +1 -1
  191. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  192. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  193. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  194. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  195. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  196. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
  197. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  198. package/lib/index.d.ts +3 -3
  199. package/lib/index.d.ts.map +1 -1
  200. package/lib/index.js +3 -2
  201. package/lib/index.js.map +1 -1
  202. package/lib/internalTypes.d.ts +1 -1
  203. package/lib/internalTypes.d.ts.map +1 -1
  204. package/lib/internalTypes.js.map +1 -1
  205. package/lib/packageVersion.d.ts +1 -1
  206. package/lib/packageVersion.d.ts.map +1 -1
  207. package/lib/packageVersion.js +1 -1
  208. package/lib/packageVersion.js.map +1 -1
  209. package/lib/shared-tree/independentView.d.ts +57 -0
  210. package/lib/shared-tree/independentView.d.ts.map +1 -0
  211. package/lib/shared-tree/independentView.js +84 -0
  212. package/lib/shared-tree/independentView.js.map +1 -0
  213. package/lib/shared-tree/index.d.ts +3 -1
  214. package/lib/shared-tree/index.d.ts.map +1 -1
  215. package/lib/shared-tree/index.js +2 -0
  216. package/lib/shared-tree/index.js.map +1 -1
  217. package/lib/shared-tree/schematizingTreeView.d.ts +13 -9
  218. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  219. package/lib/shared-tree/schematizingTreeView.js +33 -2
  220. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  221. package/lib/shared-tree/sharedTree.d.ts +10 -7
  222. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  223. package/lib/shared-tree/sharedTree.js.map +1 -1
  224. package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
  225. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
  226. package/lib/shared-tree/treeApiAlpha.js +119 -0
  227. package/lib/shared-tree/treeApiAlpha.js.map +1 -0
  228. package/lib/shared-tree/treeCheckout.d.ts +19 -17
  229. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  230. package/lib/shared-tree/treeCheckout.js +16 -7
  231. package/lib/shared-tree/treeCheckout.js.map +1 -1
  232. package/lib/shared-tree-core/editManager.d.ts +13 -6
  233. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  234. package/lib/shared-tree-core/editManager.js +70 -28
  235. package/lib/shared-tree-core/editManager.js.map +1 -1
  236. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  237. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  238. package/lib/shared-tree-core/sharedTreeCore.js +29 -4
  239. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  240. package/lib/simple-tree/api/conciseTree.d.ts +2 -1
  241. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  242. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  243. package/lib/simple-tree/api/create.d.ts +5 -23
  244. package/lib/simple-tree/api/create.d.ts.map +1 -1
  245. package/lib/simple-tree/api/create.js +2 -16
  246. package/lib/simple-tree/api/create.js.map +1 -1
  247. package/lib/simple-tree/api/customTree.d.ts +1 -0
  248. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  249. package/lib/simple-tree/api/customTree.js.map +1 -1
  250. package/lib/simple-tree/api/index.d.ts +5 -5
  251. package/lib/simple-tree/api/index.d.ts.map +1 -1
  252. package/lib/simple-tree/api/index.js +5 -3
  253. package/lib/simple-tree/api/index.js.map +1 -1
  254. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
  255. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  256. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  257. package/lib/simple-tree/api/schemaFactory.d.ts +11 -11
  258. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  259. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  260. package/lib/simple-tree/api/storedSchema.js +1 -1
  261. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  262. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  263. package/lib/simple-tree/api/tree.d.ts +125 -7
  264. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  265. package/lib/simple-tree/api/tree.js +9 -2
  266. package/lib/simple-tree/api/tree.js.map +1 -1
  267. package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
  268. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  269. package/lib/simple-tree/api/treeApiBeta.js +4 -16
  270. package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
  271. package/lib/simple-tree/api/typesUnsafe.d.ts +3 -3
  272. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  273. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  274. package/lib/simple-tree/api/verboseTree.d.ts +3 -0
  275. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  276. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  277. package/lib/simple-tree/arrayNode.d.ts +9 -15
  278. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  279. package/lib/simple-tree/arrayNode.js +1 -1
  280. package/lib/simple-tree/arrayNode.js.map +1 -1
  281. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  282. package/lib/simple-tree/core/treeNodeSchema.d.ts +45 -9
  283. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  284. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  285. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  286. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  287. package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
  288. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  289. package/lib/simple-tree/core/withType.d.ts +1 -2
  290. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  291. package/lib/simple-tree/core/withType.js.map +1 -1
  292. package/lib/simple-tree/createContext.js +1 -1
  293. package/lib/simple-tree/createContext.js.map +1 -1
  294. package/lib/simple-tree/index.d.ts +5 -5
  295. package/lib/simple-tree/index.d.ts.map +1 -1
  296. package/lib/simple-tree/index.js +4 -4
  297. package/lib/simple-tree/index.js.map +1 -1
  298. package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
  299. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  300. package/lib/simple-tree/leafNodeSchema.js +3 -0
  301. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  302. package/lib/simple-tree/mapNode.d.ts +1 -1
  303. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  304. package/lib/simple-tree/mapNode.js +3 -0
  305. package/lib/simple-tree/mapNode.js.map +1 -1
  306. package/lib/simple-tree/schemaTypes.d.ts +45 -7
  307. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  308. package/lib/simple-tree/schemaTypes.js +59 -1
  309. package/lib/simple-tree/schemaTypes.js.map +1 -1
  310. package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  311. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
  312. package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  313. package/lib/simple-tree/toStoredSchema.js.map +1 -0
  314. package/lib/simple-tree/treeNodeValid.d.ts +5 -1
  315. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  316. package/lib/simple-tree/treeNodeValid.js +7 -1
  317. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  318. package/lib/util/index.d.ts +1 -1
  319. package/lib/util/index.d.ts.map +1 -1
  320. package/lib/util/index.js.map +1 -1
  321. package/lib/util/typeCheck.d.ts +9 -0
  322. package/lib/util/typeCheck.d.ts.map +1 -1
  323. package/lib/util/typeCheck.js.map +1 -1
  324. package/lib/util/utils.d.ts +7 -3
  325. package/lib/util/utils.d.ts.map +1 -1
  326. package/lib/util/utils.js +13 -3
  327. package/lib/util/utils.js.map +1 -1
  328. package/package.json +26 -53
  329. package/src/codec/codec.ts +25 -0
  330. package/src/codec/index.ts +1 -0
  331. package/src/core/rebase/index.ts +1 -1
  332. package/src/core/rebase/types.ts +3 -15
  333. package/src/core/rebase/utils.ts +35 -3
  334. package/src/core/revertible.ts +1 -1
  335. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
  336. package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
  337. package/src/index.ts +20 -5
  338. package/src/internalTypes.ts +0 -1
  339. package/src/packageVersion.ts +1 -1
  340. package/src/shared-tree/independentView.ts +176 -0
  341. package/src/shared-tree/index.ts +9 -1
  342. package/src/shared-tree/schematizingTreeView.ts +66 -17
  343. package/src/shared-tree/sharedTree.ts +29 -11
  344. package/src/shared-tree/treeApiAlpha.ts +401 -0
  345. package/src/shared-tree/treeCheckout.ts +39 -19
  346. package/src/shared-tree-core/editManager.ts +112 -54
  347. package/src/shared-tree-core/sharedTreeCore.ts +37 -8
  348. package/src/simple-tree/api/conciseTree.ts +2 -1
  349. package/src/simple-tree/api/create.ts +21 -58
  350. package/src/simple-tree/api/customTree.ts +1 -0
  351. package/src/simple-tree/api/index.ts +13 -7
  352. package/src/simple-tree/api/schemaCreationUtilities.ts +4 -5
  353. package/src/simple-tree/api/schemaFactory.ts +24 -12
  354. package/src/simple-tree/api/storedSchema.ts +1 -1
  355. package/src/simple-tree/api/tree.ts +148 -14
  356. package/src/simple-tree/api/treeApiBeta.ts +35 -35
  357. package/src/simple-tree/api/typesUnsafe.ts +4 -4
  358. package/src/simple-tree/api/verboseTree.ts +3 -0
  359. package/src/simple-tree/arrayNode.ts +21 -23
  360. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  361. package/src/simple-tree/core/treeNodeSchema.ts +99 -31
  362. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
  363. package/src/simple-tree/core/withType.ts +1 -9
  364. package/src/simple-tree/createContext.ts +1 -1
  365. package/src/simple-tree/index.ts +15 -2
  366. package/src/simple-tree/leafNodeSchema.ts +6 -1
  367. package/src/simple-tree/mapNode.ts +7 -1
  368. package/src/simple-tree/schemaTypes.ts +128 -14
  369. package/src/simple-tree/treeNodeValid.ts +11 -1
  370. package/src/util/index.ts +1 -0
  371. package/src/util/typeCheck.ts +13 -0
  372. package/src/util/utils.ts +20 -7
  373. package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
  374. package/dist/simple-tree/toFlexSchema.js.map +0 -1
  375. package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
  376. package/lib/simple-tree/toFlexSchema.js.map +0 -1
  377. /package/docs/{main → user-facing}/merge-semantics.md +0 -0
  378. /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
@@ -0,0 +1,401 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
+ import { createIdCompressor } from "@fluidframework/id-compressor/internal";
8
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
10
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
11
+
12
+ import {
13
+ getKernel,
14
+ type TreeNode,
15
+ type Unhydrated,
16
+ TreeBeta,
17
+ tryGetSchema,
18
+ createFromCursor,
19
+ createFromInsertable,
20
+ cursorFromInsertable,
21
+ FieldKind,
22
+ normalizeFieldSchema,
23
+ type ImplicitFieldSchema,
24
+ type InsertableField,
25
+ type TreeFieldFromImplicitField,
26
+ type TreeLeafValue,
27
+ type UnsafeUnknownSchema,
28
+ conciseFromCursor,
29
+ type ConciseTree,
30
+ applySchemaToParserOptions,
31
+ cursorFromVerbose,
32
+ verboseFromCursor,
33
+ type ParseOptions,
34
+ type VerboseTree,
35
+ type VerboseTreeNode,
36
+ toStoredSchema,
37
+ type EncodeOptions,
38
+ extractPersistedSchema,
39
+ TreeViewConfiguration,
40
+ type TreeBranch,
41
+ } from "../simple-tree/index.js";
42
+ import { fail, type JsonCompatible } from "../util/index.js";
43
+ import { noopValidator, type FluidClientVersion, type ICodecOptions } from "../codec/index.js";
44
+ import type { ITreeCursorSynchronous } from "../core/index.js";
45
+ import {
46
+ cursorForMapTreeField,
47
+ defaultSchemaPolicy,
48
+ isTreeValue,
49
+ makeFieldBatchCodec,
50
+ mapTreeFromCursor,
51
+ TreeCompressionStrategy,
52
+ type FieldBatch,
53
+ type FieldBatchEncodingContext,
54
+ } from "../feature-libraries/index.js";
55
+ import { independentInitializedView, type ViewContent } from "./independentView.js";
56
+ import { SchematizingSimpleTreeView, ViewSlot } from "./schematizingTreeView.js";
57
+
58
+ /**
59
+ * Extensions to {@link Tree} and {@link TreeBeta} which are not yet stable.
60
+ * @sealed @alpha
61
+ */
62
+ export const TreeAlpha: {
63
+ /**
64
+ * Retrieve the {@link TreeBranch | branch}, if any, for the given node.
65
+ * @param node - The node to query
66
+ * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.
67
+ * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).
68
+ *
69
+ * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.
70
+ * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.
71
+ */
72
+ branch(node: TreeNode): TreeBranch | undefined;
73
+
74
+ /**
75
+ * Construct tree content that is compatible with the field defined by the provided `schema`.
76
+ * @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.
77
+ * @param data - The data used to construct the field content.
78
+ * @remarks
79
+ * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.
80
+ * This function exists as a generalization that can be used in other cases as well,
81
+ * 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.
82
+ *
83
+ * Like with {@link TreeNodeSchemaClass}'s constructor, it's an error to provide an existing node to this API.
84
+ * For that case, use {@link TreeBeta.clone}.
85
+ * @privateRemarks
86
+ * There should be a way to provide a source for defaulted identifiers, wither via this API or some way to add them to its output later.
87
+ */
88
+ create<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(
89
+ schema: UnsafeUnknownSchema extends TSchema
90
+ ? ImplicitFieldSchema
91
+ : TSchema & ImplicitFieldSchema,
92
+ data: InsertableField<TSchema>,
93
+ ): Unhydrated<
94
+ TSchema extends ImplicitFieldSchema
95
+ ? TreeFieldFromImplicitField<TSchema>
96
+ : TreeNode | TreeLeafValue | undefined
97
+ >;
98
+
99
+ /**
100
+ * Less type safe version of {@link TreeAlpha.create}, suitable for importing data.
101
+ * @remarks
102
+ * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.
103
+ * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.
104
+ * Use "compressed" or "verbose" formats for more flexibility.
105
+ *
106
+ * When using this function,
107
+ * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.
108
+ * If the schema is ambiguous, consider using {@link TreeAlpha.create} and {@link Unhydrated} nodes where needed,
109
+ * or using {@link TreeAlpha.(importVerbose:1)} and specify all types.
110
+ *
111
+ * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,
112
+ * but for now most invalid inputs will throw a recoverable error.
113
+ */
114
+ importConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(
115
+ schema: UnsafeUnknownSchema extends TSchema
116
+ ? ImplicitFieldSchema
117
+ : TSchema & ImplicitFieldSchema,
118
+ data: ConciseTree | undefined,
119
+ ): Unhydrated<
120
+ TSchema extends ImplicitFieldSchema
121
+ ? TreeFieldFromImplicitField<TSchema>
122
+ : TreeNode | TreeLeafValue | undefined
123
+ >;
124
+
125
+ /**
126
+ * Construct tree content compatible with a field defined by the provided `schema`.
127
+ * @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.
128
+ * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:1)}.
129
+ * @remarks
130
+ * This overload requires that any {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} are encoded as actual {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input.
131
+ */
132
+ importVerbose<const TSchema extends ImplicitFieldSchema>(
133
+ schema: TSchema,
134
+ data: VerboseTree | undefined,
135
+ options?: Partial<ParseOptions<IFluidHandle>>,
136
+ ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
137
+
138
+ /**
139
+ * Construct tree content compatible with a field defined by the provided `schema`.
140
+ * @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.
141
+ * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:2)}.
142
+ *
143
+ * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the input `data` are encoded.
144
+ * A converter from this encoding to {@link @fluidframework/core-interfaces#IFluidHandle} is required in `options`.
145
+ */
146
+ importVerbose<const TSchema extends ImplicitFieldSchema, THandle>(
147
+ schema: TSchema,
148
+ data: VerboseTree<THandle> | undefined,
149
+ options: ParseOptions<THandle>,
150
+ ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
151
+
152
+ /**
153
+ * Same as {@link TreeAlpha.(exportConcise:2)}, except leaves handles as is.
154
+ */
155
+ exportConcise(
156
+ node: TreeNode | TreeLeafValue,
157
+ options?: Partial<EncodeOptions<IFluidHandle>>,
158
+ ): ConciseTree;
159
+
160
+ /**
161
+ * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.
162
+ *
163
+ * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.
164
+ * A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.
165
+ */
166
+ exportConcise<THandle>(
167
+ node: TreeNode | TreeLeafValue,
168
+ options: EncodeOptions<THandle>,
169
+ ): ConciseTree<THandle>;
170
+
171
+ /**
172
+ * Same {@link TreeAlpha.(exportVerbose:2)} except leaves handles as is.
173
+ */
174
+ exportVerbose(
175
+ node: TreeNode | TreeLeafValue,
176
+ options?: Partial<EncodeOptions<IFluidHandle>>,
177
+ ): VerboseTree;
178
+
179
+ /**
180
+ * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object.
181
+ * Verbose tree format, with explicit type on every node.
182
+ *
183
+ * @typeparam THandle - How {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles} in the output should be encoded.
184
+ * A converter from from {@link @fluidframework/core-interfaces#IFluidHandle} to this format is required in `options`.
185
+ *
186
+ * @remarks
187
+ * There are several cases this may be preferred to {@link TreeAlpha.(exportConcise:2)}:
188
+ *
189
+ * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).
190
+ * `exportVerbose` will always be unambiguous and thus lossless.
191
+ *
192
+ * 2. When the data might be interpreted without access to the exact same view schema. In such cases, the types may be unknowable if not included.
193
+ *
194
+ * 3. When easy access to the type is desired.
195
+ */
196
+ exportVerbose<T>(node: TreeNode | TreeLeafValue, options: EncodeOptions<T>): VerboseTree<T>;
197
+
198
+ /**
199
+ * Export the content of the provided `tree` in a compressed JSON compatible format.
200
+ * @remarks
201
+ * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.
202
+ *
203
+ * Always uses "stored" keys.
204
+ * See {@link EncodeOptions.useStoredKeys} for details.
205
+ * @privateRemarks
206
+ * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.
207
+ * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,
208
+ * Nor get the correct idCompressor from a subtree to use when exporting it.
209
+ * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.
210
+ * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,
211
+ * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.
212
+ * Add in a stable public APi for creating idCompressors, and a way to get them from a tree (without view schema), and that should address the anticipated use-cases.
213
+ */
214
+ exportCompressed(
215
+ tree: TreeNode | TreeLeafValue,
216
+ options: { oldestCompatibleClient: FluidClientVersion; idCompressor?: IIdCompressor },
217
+ ): JsonCompatible<IFluidHandle>;
218
+
219
+ /**
220
+ * Import data encoded by {@link TreeAlpha.exportCompressed}.
221
+ *
222
+ * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.
223
+ * @param compressedData - Data compressed by {@link TreeAlpha.exportCompressed}.
224
+ * @param options - If {@link TreeAlpha.exportCompressed} was given an `idCompressor`, it must be provided here.
225
+ *
226
+ * @remarks
227
+ * If the data could have been encoded with a different schema, consider encoding the schema along side it using {@link extractPersistedSchema} and loading the data using {@link independentView}.
228
+ *
229
+ * @privateRemarks
230
+ * This API could be improved:
231
+ *
232
+ * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a "try" version).
233
+ * 2. A "try" version of this could return an error if the data isn't in a supported format (as determined by version and/or JasonValidator).
234
+ * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.
235
+ */
236
+ importCompressed<const TSchema extends ImplicitFieldSchema>(
237
+ schema: TSchema,
238
+ compressedData: JsonCompatible<IFluidHandle>,
239
+ options: { idCompressor?: IIdCompressor } & ICodecOptions,
240
+ ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
241
+ } = {
242
+ branch(node: TreeNode): TreeBranch | undefined {
243
+ const kernel = getKernel(node);
244
+ if (!kernel.isHydrated()) {
245
+ return undefined;
246
+ }
247
+ const view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);
248
+ assert(
249
+ view instanceof SchematizingSimpleTreeView,
250
+ 0xa5c /* Unexpected view implementation */,
251
+ );
252
+ return view;
253
+ },
254
+
255
+ create: createFromInsertable,
256
+
257
+ importConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(
258
+ schema: UnsafeUnknownSchema extends TSchema
259
+ ? ImplicitFieldSchema
260
+ : TSchema & ImplicitFieldSchema,
261
+ data: ConciseTree | undefined,
262
+ ): Unhydrated<
263
+ TSchema extends ImplicitFieldSchema
264
+ ? TreeFieldFromImplicitField<TSchema>
265
+ : TreeNode | TreeLeafValue | undefined
266
+ > {
267
+ return createFromInsertable<UnsafeUnknownSchema>(
268
+ schema,
269
+ data as InsertableField<UnsafeUnknownSchema>,
270
+ ) as Unhydrated<
271
+ TSchema extends ImplicitFieldSchema
272
+ ? TreeFieldFromImplicitField<TSchema>
273
+ : TreeNode | TreeLeafValue | undefined
274
+ >;
275
+ },
276
+
277
+ importVerbose<const TSchema extends ImplicitFieldSchema, THandle>(
278
+ schema: TSchema,
279
+ data: VerboseTree<THandle> | undefined,
280
+ options?: Partial<ParseOptions<THandle>>,
281
+ ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
282
+ const config: ParseOptions<THandle> = {
283
+ valueConverter: (input: VerboseTree<THandle>) => {
284
+ return input as TreeLeafValue | VerboseTreeNode<THandle>;
285
+ },
286
+ ...options,
287
+ };
288
+ // Create a config which is standalone, and thus can be used without having to refer back to the schema.
289
+ const schemalessConfig = applySchemaToParserOptions(schema, config);
290
+ if (data === undefined) {
291
+ const field = normalizeFieldSchema(schema);
292
+ if (field.kind !== FieldKind.Optional) {
293
+ throw new UsageError("undefined provided for non-optional field.");
294
+ }
295
+ return undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
296
+ }
297
+ const cursor = cursorFromVerbose<THandle>(data, schemalessConfig);
298
+ return createFromCursor(schema, cursor);
299
+ },
300
+
301
+ exportConcise<T>(
302
+ node: TreeNode | TreeLeafValue,
303
+ options?: Partial<EncodeOptions<T>>,
304
+ ): ConciseTree<T> {
305
+ const config: EncodeOptions<T> = {
306
+ valueConverter(handle: IFluidHandle): T {
307
+ return handle as T;
308
+ },
309
+ ...options,
310
+ };
311
+
312
+ const cursor = borrowCursorFromTreeNodeOrValue(node);
313
+ return conciseFromCursor(cursor, tryGetSchema(node) ?? fail("invalid input"), config);
314
+ },
315
+
316
+ exportVerbose<T>(
317
+ node: TreeNode | TreeLeafValue,
318
+ options?: Partial<EncodeOptions<T>>,
319
+ ): VerboseTree<T> {
320
+ const config: EncodeOptions<T> = {
321
+ valueConverter(handle: IFluidHandle): T {
322
+ return handle as T;
323
+ },
324
+ ...options,
325
+ };
326
+
327
+ const cursor = borrowCursorFromTreeNodeOrValue(node);
328
+ return verboseFromCursor(cursor, tryGetSchema(node) ?? fail("invalid input"), config);
329
+ },
330
+
331
+ exportCompressed(
332
+ node: TreeNode | TreeLeafValue,
333
+ options: {
334
+ oldestCompatibleClient: FluidClientVersion;
335
+ idCompressor?: IIdCompressor;
336
+ },
337
+ ): JsonCompatible<IFluidHandle> {
338
+ const schema = tryGetSchema(node) ?? fail("invalid input");
339
+ const format = versionToFormat[options.oldestCompatibleClient];
340
+ const codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);
341
+ const cursor = borrowFieldCursorFromTreeNodeOrValue(node);
342
+ const batch: FieldBatch = [cursor];
343
+ // If none provided, create a compressor which will not compress anything.
344
+ const idCompressor = options.idCompressor ?? createIdCompressor();
345
+ const context: FieldBatchEncodingContext = {
346
+ encodeType: TreeCompressionStrategy.Compressed,
347
+ idCompressor,
348
+ originatorId: idCompressor.localSessionId, // TODO: Why is this needed?
349
+ schema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },
350
+ };
351
+ const result = codec.encode(batch, context);
352
+ return result;
353
+ },
354
+
355
+ importCompressed<const TSchema extends ImplicitFieldSchema>(
356
+ schema: TSchema,
357
+ compressedData: JsonCompatible<IFluidHandle>,
358
+ options: {
359
+ idCompressor?: IIdCompressor;
360
+ } & ICodecOptions,
361
+ ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
362
+ const content: ViewContent = {
363
+ schema: extractPersistedSchema(schema),
364
+ tree: compressedData,
365
+ idCompressor: options.idCompressor ?? createIdCompressor(),
366
+ };
367
+ const config = new TreeViewConfiguration({ schema });
368
+ const view = independentInitializedView(config, options, content);
369
+ return TreeBeta.clone<TSchema>(view.root);
370
+ },
371
+ };
372
+
373
+ function borrowCursorFromTreeNodeOrValue(
374
+ node: TreeNode | TreeLeafValue,
375
+ ): ITreeCursorSynchronous {
376
+ if (isTreeValue(node)) {
377
+ return cursorFromInsertable<UnsafeUnknownSchema>(
378
+ tryGetSchema(node) ?? fail("missing schema"),
379
+ node,
380
+ );
381
+ }
382
+ const kernel = getKernel(node);
383
+ const cursor = kernel.getOrCreateInnerNode().borrowCursor();
384
+ return cursor;
385
+ }
386
+
387
+ function borrowFieldCursorFromTreeNodeOrValue(
388
+ node: TreeNode | TreeLeafValue,
389
+ ): ITreeCursorSynchronous {
390
+ const cursor = borrowCursorFromTreeNodeOrValue(node);
391
+ // TODO: avoid copy
392
+ const mapTree = mapTreeFromCursor(cursor);
393
+ return cursorForMapTreeField([mapTree]);
394
+ }
395
+
396
+ const versionToFormat = {
397
+ v2_0: 1,
398
+ v2_1: 1,
399
+ v2_2: 1,
400
+ v2_3: 1,
401
+ };
@@ -63,8 +63,10 @@ import type { ISharedTreeEditor, SharedTreeEditBuilder } from "./sharedTreeEditB
63
63
  import type { IDisposable } from "@fluidframework/core-interfaces";
64
64
  import type {
65
65
  ImplicitFieldSchema,
66
+ ReadSchema,
66
67
  TreeView,
67
68
  TreeViewConfiguration,
69
+ UnsafeUnknownSchema,
68
70
  ViewableTree,
69
71
  } from "../simple-tree/index.js";
70
72
  import { SchematizingSimpleTreeView } from "./schematizingTreeView.js";
@@ -83,18 +85,14 @@ export interface CheckoutEvents {
83
85
  afterBatch(): void;
84
86
 
85
87
  /**
86
- * Fired when a revertible change has been made to this view.
88
+ * Fired when a change is made to the branch. Includes data about the change that is made which listeners
89
+ * can use to filter on changes they care about e.g. local vs remote changes.
87
90
  *
88
- * Applications which subscribe to this event are expected to revert or discard revertibles they acquire (failure to do so will leak memory).
89
- * The provided revertible is inherently bound to the view that raised the event, calling `revert` won't apply to forked views.
90
- *
91
- * @param revertible - The revertible that can be used to revert the change.
92
- */
93
-
94
- /**
95
- * {@inheritdoc TreeViewEvents.commitApplied}
91
+ * @param data - information about the change
92
+ * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,
93
+ * this change is not revertible.
96
94
  */
97
- commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
95
+ changed(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
98
96
  }
99
97
 
100
98
  /**
@@ -104,7 +102,7 @@ export interface CheckoutEvents {
104
102
  * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.
105
103
  * @alpha @sealed
106
104
  */
107
- export interface TreeBranch extends ViewableTree {
105
+ export interface BranchableTree extends ViewableTree {
108
106
  /**
109
107
  * Spawn a new branch which is based off of the current state of this branch.
110
108
  * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.
@@ -116,7 +114,7 @@ export interface TreeBranch extends ViewableTree {
116
114
  * @param view - a branch which was created by a call to `branch()`.
117
115
  * It is automatically disposed after the merge completes.
118
116
  * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.
119
- * A "commitApplied" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.
117
+ * A "changed" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.
120
118
  */
121
119
  merge(branch: TreeBranchFork): void;
122
120
 
@@ -136,16 +134,16 @@ export interface TreeBranch extends ViewableTree {
136
134
  }
137
135
 
138
136
  /**
139
- * A {@link TreeBranch | branch} of a SharedTree that has merged from another branch.
137
+ * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.
140
138
  * @remarks This branch should be disposed when it is no longer needed in order to free resources.
141
139
  * @alpha @sealed
142
140
  */
143
- export interface TreeBranchFork extends TreeBranch, IDisposable {
141
+ export interface TreeBranchFork extends BranchableTree, IDisposable {
144
142
  /**
145
143
  * Rebase the changes that have been applied to this branch over all the new changes in the given branch.
146
144
  * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.
147
145
  */
148
- rebaseOnto(branch: TreeBranch): void;
146
+ rebaseOnto(branch: BranchableTree): void;
149
147
  }
150
148
 
151
149
  /**
@@ -283,6 +281,7 @@ export function createTreeCheckout(
283
281
  return new TreeCheckout(
284
282
  transaction,
285
283
  branch,
284
+ false,
286
285
  changeFamily,
287
286
  schema,
288
287
  forest,
@@ -424,6 +423,8 @@ export class TreeCheckout implements ITreeCheckoutFork {
424
423
  public constructor(
425
424
  public readonly transaction: ITransaction,
426
425
  private readonly _branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,
426
+ /** True if and only if this checkout is for a forked branch and not the "main branch" of the tree. */
427
+ public readonly isBranch: boolean,
427
428
  private readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,
428
429
  public readonly storedSchema: TreeStoredSchemaRepository,
429
430
  public readonly forest: IEditableForest,
@@ -527,12 +528,12 @@ export class TreeCheckout implements ITreeCheckoutFork {
527
528
  : (onRevertibleDisposed?: (revertible: Revertible) => void) => {
528
529
  if (!withinEventContext) {
529
530
  throw new UsageError(
530
- "Cannot get a revertible outside of the context of a commitApplied event.",
531
+ "Cannot get a revertible outside of the context of a changed event.",
531
532
  );
532
533
  }
533
534
  if (this.revertibleCommitBranches.get(revision) !== undefined) {
534
535
  throw new UsageError(
535
- "Cannot generate the same revertible more than once. Note that this can happen when multiple commitApplied event listeners are registered.",
536
+ "Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.",
536
537
  );
537
538
  }
538
539
  const revertibleCommits = this.revertibleCommitBranches;
@@ -577,9 +578,12 @@ export class TreeCheckout implements ITreeCheckoutFork {
577
578
  };
578
579
 
579
580
  let withinEventContext = true;
580
- this.events.emit("commitApplied", { isLocal: true, kind }, getRevertible);
581
+ this.events.emit("changed", { isLocal: true, kind }, getRevertible);
581
582
  withinEventContext = false;
582
583
  }
584
+ } else if (event.type === "replace") {
585
+ // TODO: figure out how to plumb through commit kind info for remote changes
586
+ this.events.emit("changed", { isLocal: false, kind: CommitKind.Default });
583
587
  }
584
588
  }
585
589
  });
@@ -622,8 +626,18 @@ export class TreeCheckout implements ITreeCheckoutFork {
622
626
  }
623
627
  }
624
628
 
629
+ // For the new TreeViewAlpha API
630
+ public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
631
+ config: TreeViewConfiguration<ReadSchema<TRoot>>,
632
+ ): SchematizingSimpleTreeView<TRoot>;
633
+
634
+ // For the old TreeView API
625
635
  public viewWith<TRoot extends ImplicitFieldSchema>(
626
636
  config: TreeViewConfiguration<TRoot>,
637
+ ): TreeView<TRoot>;
638
+
639
+ public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
640
+ config: TreeViewConfiguration<ReadSchema<TRoot>>,
627
641
  ): SchematizingSimpleTreeView<TRoot> {
628
642
  const view = new SchematizingSimpleTreeView(
629
643
  this,
@@ -664,6 +678,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
664
678
  return new TreeCheckout(
665
679
  transaction,
666
680
  branch,
681
+ true,
667
682
  this.changeFamily,
668
683
  storedSchema,
669
684
  forest,
@@ -688,6 +703,10 @@ export class TreeCheckout implements ITreeCheckoutFork {
688
703
  !checkout.transaction.inProgress(),
689
704
  0x9af /* A view cannot be rebased while it has a pending transaction */,
690
705
  );
706
+ assert(
707
+ checkout.isBranch,
708
+ 0xa5d /* The main branch cannot be rebased onto another branch. */,
709
+ );
691
710
  checkout._branch.rebaseOnto(this._branch);
692
711
  }
693
712
 
@@ -715,7 +734,8 @@ export class TreeCheckout implements ITreeCheckoutFork {
715
734
  checkout.transaction.commit();
716
735
  }
717
736
  this._branch.merge(checkout._branch);
718
- if (disposeMerged) {
737
+ if (disposeMerged && checkout.isBranch) {
738
+ // Dispose the merged checkout unless it is the main branch.
719
739
  checkout[disposeSymbol]();
720
740
  }
721
741
  }