@fluidframework/tree 2.5.0-302463 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +371 -0
  3. package/api-report/tree.alpha.api.md +151 -57
  4. package/api-report/tree.beta.api.md +29 -25
  5. package/api-report/tree.legacy.alpha.api.md +28 -24
  6. package/api-report/tree.legacy.public.api.md +28 -24
  7. package/api-report/tree.public.api.md +28 -24
  8. package/dist/alpha.d.ts +15 -0
  9. package/dist/codec/codec.d.ts +24 -0
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +26 -1
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/index.d.ts +1 -1
  14. package/dist/codec/index.d.ts.map +1 -1
  15. package/dist/codec/index.js +2 -1
  16. package/dist/codec/index.js.map +1 -1
  17. package/dist/core/rebase/index.d.ts +2 -2
  18. package/dist/core/rebase/index.d.ts.map +1 -1
  19. package/dist/core/rebase/index.js +2 -2
  20. package/dist/core/rebase/index.js.map +1 -1
  21. package/dist/core/rebase/types.d.ts +0 -4
  22. package/dist/core/rebase/types.d.ts.map +1 -1
  23. package/dist/core/rebase/types.js +1 -7
  24. package/dist/core/rebase/types.js.map +1 -1
  25. package/dist/core/rebase/utils.d.ts +1 -0
  26. package/dist/core/rebase/utils.d.ts.map +1 -1
  27. package/dist/core/rebase/utils.js +29 -4
  28. package/dist/core/rebase/utils.js.map +1 -1
  29. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  30. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  31. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  32. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  33. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  34. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -0
  35. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  36. package/dist/index.d.ts +3 -3
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +12 -6
  39. package/dist/index.js.map +1 -1
  40. package/dist/packageVersion.d.ts +1 -1
  41. package/dist/packageVersion.d.ts.map +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/shared-tree/independentView.d.ts +57 -0
  45. package/dist/shared-tree/independentView.d.ts.map +1 -0
  46. package/dist/shared-tree/independentView.js +89 -0
  47. package/dist/shared-tree/independentView.js.map +1 -0
  48. package/dist/shared-tree/index.d.ts +3 -1
  49. package/dist/shared-tree/index.d.ts.map +1 -1
  50. package/dist/shared-tree/index.js +6 -1
  51. package/dist/shared-tree/index.js.map +1 -1
  52. package/dist/shared-tree/schematizingTreeView.d.ts +12 -8
  53. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  54. package/dist/shared-tree/schematizingTreeView.js +28 -0
  55. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  56. package/dist/shared-tree/sharedTree.d.ts +10 -7
  57. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  58. package/dist/shared-tree/sharedTree.js.map +1 -1
  59. package/dist/shared-tree/treeApiAlpha.d.ts +147 -0
  60. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -0
  61. package/dist/shared-tree/treeApiAlpha.js +122 -0
  62. package/dist/shared-tree/treeApiAlpha.js.map +1 -0
  63. package/dist/shared-tree/treeCheckout.d.ts +12 -7
  64. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  65. package/dist/shared-tree/treeCheckout.js +9 -4
  66. package/dist/shared-tree/treeCheckout.js.map +1 -1
  67. package/dist/shared-tree-core/editManager.d.ts +13 -6
  68. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  69. package/dist/shared-tree-core/editManager.js +70 -28
  70. package/dist/shared-tree-core/editManager.js.map +1 -1
  71. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  72. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  73. package/dist/shared-tree-core/sharedTreeCore.js +28 -3
  74. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  75. package/dist/simple-tree/api/conciseTree.d.ts +2 -1
  76. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  77. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  78. package/dist/simple-tree/api/create.d.ts +5 -23
  79. package/dist/simple-tree/api/create.d.ts.map +1 -1
  80. package/dist/simple-tree/api/create.js +4 -19
  81. package/dist/simple-tree/api/create.js.map +1 -1
  82. package/dist/simple-tree/api/customTree.d.ts +1 -0
  83. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  84. package/dist/simple-tree/api/customTree.js.map +1 -1
  85. package/dist/simple-tree/api/index.d.ts +5 -5
  86. package/dist/simple-tree/api/index.d.ts.map +1 -1
  87. package/dist/simple-tree/api/index.js +10 -1
  88. package/dist/simple-tree/api/index.js.map +1 -1
  89. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
  90. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  91. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  92. package/dist/simple-tree/api/schemaFactory.d.ts +11 -11
  93. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  94. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  95. package/dist/simple-tree/api/storedSchema.js +2 -2
  96. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  97. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  98. package/dist/simple-tree/api/tree.d.ts +115 -7
  99. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  100. package/dist/simple-tree/api/tree.js +12 -4
  101. package/dist/simple-tree/api/tree.js.map +1 -1
  102. package/dist/simple-tree/api/treeApiBeta.d.ts +8 -5
  103. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  104. package/dist/simple-tree/api/treeApiBeta.js +3 -15
  105. package/dist/simple-tree/api/treeApiBeta.js.map +1 -1
  106. package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
  107. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  108. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  109. package/dist/simple-tree/api/verboseTree.d.ts +3 -0
  110. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  111. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  112. package/dist/simple-tree/arrayNode.d.ts +1 -1
  113. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  114. package/dist/simple-tree/arrayNode.js +1 -1
  115. package/dist/simple-tree/arrayNode.js.map +1 -1
  116. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  117. package/dist/simple-tree/core/treeNodeSchema.d.ts +45 -9
  118. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  119. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  120. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  121. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  122. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  123. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  124. package/dist/simple-tree/core/withType.d.ts +1 -2
  125. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  126. package/dist/simple-tree/core/withType.js.map +1 -1
  127. package/dist/simple-tree/createContext.js +2 -2
  128. package/dist/simple-tree/createContext.js.map +1 -1
  129. package/dist/simple-tree/index.d.ts +4 -4
  130. package/dist/simple-tree/index.d.ts.map +1 -1
  131. package/dist/simple-tree/index.js +15 -4
  132. package/dist/simple-tree/index.js.map +1 -1
  133. package/dist/simple-tree/leafNodeSchema.d.ts +6 -5
  134. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  135. package/dist/simple-tree/leafNodeSchema.js +3 -0
  136. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  137. package/dist/simple-tree/mapNode.d.ts +1 -1
  138. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  139. package/dist/simple-tree/mapNode.js +3 -0
  140. package/dist/simple-tree/mapNode.js.map +1 -1
  141. package/dist/simple-tree/schemaTypes.d.ts +45 -7
  142. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  143. package/dist/simple-tree/schemaTypes.js +61 -1
  144. package/dist/simple-tree/schemaTypes.js.map +1 -1
  145. package/dist/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  146. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -0
  147. package/dist/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  148. package/dist/simple-tree/toStoredSchema.js.map +1 -0
  149. package/dist/simple-tree/treeNodeValid.d.ts +5 -1
  150. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  151. package/dist/simple-tree/treeNodeValid.js +7 -1
  152. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  153. package/dist/util/index.d.ts +1 -1
  154. package/dist/util/index.d.ts.map +1 -1
  155. package/dist/util/index.js.map +1 -1
  156. package/dist/util/typeCheck.d.ts +9 -0
  157. package/dist/util/typeCheck.d.ts.map +1 -1
  158. package/dist/util/typeCheck.js.map +1 -1
  159. package/dist/util/utils.d.ts +7 -3
  160. package/dist/util/utils.d.ts.map +1 -1
  161. package/dist/util/utils.js +13 -3
  162. package/dist/util/utils.js.map +1 -1
  163. package/lib/alpha.d.ts +15 -0
  164. package/lib/codec/codec.d.ts +24 -0
  165. package/lib/codec/codec.d.ts.map +1 -1
  166. package/lib/codec/codec.js +25 -0
  167. package/lib/codec/codec.js.map +1 -1
  168. package/lib/codec/index.d.ts +1 -1
  169. package/lib/codec/index.d.ts.map +1 -1
  170. package/lib/codec/index.js +1 -1
  171. package/lib/codec/index.js.map +1 -1
  172. package/lib/core/rebase/index.d.ts +2 -2
  173. package/lib/core/rebase/index.d.ts.map +1 -1
  174. package/lib/core/rebase/index.js +2 -2
  175. package/lib/core/rebase/index.js.map +1 -1
  176. package/lib/core/rebase/types.d.ts +0 -4
  177. package/lib/core/rebase/types.d.ts.map +1 -1
  178. package/lib/core/rebase/types.js +0 -5
  179. package/lib/core/rebase/types.js.map +1 -1
  180. package/lib/core/rebase/utils.d.ts +1 -0
  181. package/lib/core/rebase/utils.d.ts.map +1 -1
  182. package/lib/core/rebase/utils.js +27 -3
  183. package/lib/core/rebase/utils.js.map +1 -1
  184. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -1
  185. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  186. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  187. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -1
  188. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  189. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -0
  190. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  191. package/lib/index.d.ts +3 -3
  192. package/lib/index.d.ts.map +1 -1
  193. package/lib/index.js +3 -2
  194. package/lib/index.js.map +1 -1
  195. package/lib/packageVersion.d.ts +1 -1
  196. package/lib/packageVersion.d.ts.map +1 -1
  197. package/lib/packageVersion.js +1 -1
  198. package/lib/packageVersion.js.map +1 -1
  199. package/lib/shared-tree/independentView.d.ts +57 -0
  200. package/lib/shared-tree/independentView.d.ts.map +1 -0
  201. package/lib/shared-tree/independentView.js +84 -0
  202. package/lib/shared-tree/independentView.js.map +1 -0
  203. package/lib/shared-tree/index.d.ts +3 -1
  204. package/lib/shared-tree/index.d.ts.map +1 -1
  205. package/lib/shared-tree/index.js +2 -0
  206. package/lib/shared-tree/index.js.map +1 -1
  207. package/lib/shared-tree/schematizingTreeView.d.ts +12 -8
  208. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  209. package/lib/shared-tree/schematizingTreeView.js +29 -1
  210. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  211. package/lib/shared-tree/sharedTree.d.ts +10 -7
  212. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  213. package/lib/shared-tree/sharedTree.js.map +1 -1
  214. package/lib/shared-tree/treeApiAlpha.d.ts +147 -0
  215. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -0
  216. package/lib/shared-tree/treeApiAlpha.js +119 -0
  217. package/lib/shared-tree/treeApiAlpha.js.map +1 -0
  218. package/lib/shared-tree/treeCheckout.d.ts +12 -7
  219. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  220. package/lib/shared-tree/treeCheckout.js +9 -4
  221. package/lib/shared-tree/treeCheckout.js.map +1 -1
  222. package/lib/shared-tree-core/editManager.d.ts +13 -6
  223. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  224. package/lib/shared-tree-core/editManager.js +70 -28
  225. package/lib/shared-tree-core/editManager.js.map +1 -1
  226. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  227. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  228. package/lib/shared-tree-core/sharedTreeCore.js +29 -4
  229. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  230. package/lib/simple-tree/api/conciseTree.d.ts +2 -1
  231. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  232. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  233. package/lib/simple-tree/api/create.d.ts +5 -23
  234. package/lib/simple-tree/api/create.d.ts.map +1 -1
  235. package/lib/simple-tree/api/create.js +2 -16
  236. package/lib/simple-tree/api/create.js.map +1 -1
  237. package/lib/simple-tree/api/customTree.d.ts +1 -0
  238. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  239. package/lib/simple-tree/api/customTree.js.map +1 -1
  240. package/lib/simple-tree/api/index.d.ts +5 -5
  241. package/lib/simple-tree/api/index.d.ts.map +1 -1
  242. package/lib/simple-tree/api/index.js +5 -3
  243. package/lib/simple-tree/api/index.js.map +1 -1
  244. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +6 -16
  245. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  246. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  247. package/lib/simple-tree/api/schemaFactory.d.ts +11 -11
  248. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  249. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  250. package/lib/simple-tree/api/storedSchema.js +1 -1
  251. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  252. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  253. package/lib/simple-tree/api/tree.d.ts +115 -7
  254. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  255. package/lib/simple-tree/api/tree.js +9 -2
  256. package/lib/simple-tree/api/tree.js.map +1 -1
  257. package/lib/simple-tree/api/treeApiBeta.d.ts +8 -5
  258. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -1
  259. package/lib/simple-tree/api/treeApiBeta.js +4 -16
  260. package/lib/simple-tree/api/treeApiBeta.js.map +1 -1
  261. package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
  262. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  263. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  264. package/lib/simple-tree/api/verboseTree.d.ts +3 -0
  265. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  266. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  267. package/lib/simple-tree/arrayNode.d.ts +1 -1
  268. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  269. package/lib/simple-tree/arrayNode.js +1 -1
  270. package/lib/simple-tree/arrayNode.js.map +1 -1
  271. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  272. package/lib/simple-tree/core/treeNodeSchema.d.ts +45 -9
  273. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  274. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  275. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  276. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  277. package/lib/simple-tree/core/unhydratedFlexTree.js +4 -1
  278. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  279. package/lib/simple-tree/core/withType.d.ts +1 -2
  280. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  281. package/lib/simple-tree/core/withType.js.map +1 -1
  282. package/lib/simple-tree/createContext.js +1 -1
  283. package/lib/simple-tree/createContext.js.map +1 -1
  284. package/lib/simple-tree/index.d.ts +4 -4
  285. package/lib/simple-tree/index.d.ts.map +1 -1
  286. package/lib/simple-tree/index.js +4 -4
  287. package/lib/simple-tree/index.js.map +1 -1
  288. package/lib/simple-tree/leafNodeSchema.d.ts +6 -5
  289. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  290. package/lib/simple-tree/leafNodeSchema.js +3 -0
  291. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  292. package/lib/simple-tree/mapNode.d.ts +1 -1
  293. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  294. package/lib/simple-tree/mapNode.js +3 -0
  295. package/lib/simple-tree/mapNode.js.map +1 -1
  296. package/lib/simple-tree/schemaTypes.d.ts +45 -7
  297. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  298. package/lib/simple-tree/schemaTypes.js +59 -1
  299. package/lib/simple-tree/schemaTypes.js.map +1 -1
  300. package/lib/simple-tree/{toFlexSchema.d.ts → toStoredSchema.d.ts} +1 -1
  301. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -0
  302. package/lib/simple-tree/{toFlexSchema.js → toStoredSchema.js} +1 -1
  303. package/lib/simple-tree/toStoredSchema.js.map +1 -0
  304. package/lib/simple-tree/treeNodeValid.d.ts +5 -1
  305. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  306. package/lib/simple-tree/treeNodeValid.js +7 -1
  307. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  308. package/lib/util/index.d.ts +1 -1
  309. package/lib/util/index.d.ts.map +1 -1
  310. package/lib/util/index.js.map +1 -1
  311. package/lib/util/typeCheck.d.ts +9 -0
  312. package/lib/util/typeCheck.d.ts.map +1 -1
  313. package/lib/util/typeCheck.js.map +1 -1
  314. package/lib/util/utils.d.ts +7 -3
  315. package/lib/util/utils.d.ts.map +1 -1
  316. package/lib/util/utils.js +13 -3
  317. package/lib/util/utils.js.map +1 -1
  318. package/package.json +30 -21
  319. package/src/codec/codec.ts +25 -0
  320. package/src/codec/index.ts +1 -0
  321. package/src/core/rebase/index.ts +1 -1
  322. package/src/core/rebase/types.ts +0 -12
  323. package/src/core/rebase/utils.ts +35 -3
  324. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +9 -0
  325. package/src/feature-libraries/flex-tree/lazyNode.ts +5 -0
  326. package/src/index.ts +20 -5
  327. package/src/packageVersion.ts +1 -1
  328. package/src/shared-tree/independentView.ts +176 -0
  329. package/src/shared-tree/index.ts +9 -1
  330. package/src/shared-tree/schematizingTreeView.ts +58 -11
  331. package/src/shared-tree/sharedTree.ts +29 -11
  332. package/src/shared-tree/treeApiAlpha.ts +401 -0
  333. package/src/shared-tree/treeCheckout.ts +26 -5
  334. package/src/shared-tree-core/editManager.ts +112 -54
  335. package/src/shared-tree-core/sharedTreeCore.ts +37 -8
  336. package/src/simple-tree/api/conciseTree.ts +2 -1
  337. package/src/simple-tree/api/create.ts +21 -58
  338. package/src/simple-tree/api/customTree.ts +1 -0
  339. package/src/simple-tree/api/index.ts +13 -7
  340. package/src/simple-tree/api/schemaCreationUtilities.ts +4 -5
  341. package/src/simple-tree/api/schemaFactory.ts +24 -12
  342. package/src/simple-tree/api/storedSchema.ts +1 -1
  343. package/src/simple-tree/api/tree.ts +136 -14
  344. package/src/simple-tree/api/treeApiBeta.ts +35 -35
  345. package/src/simple-tree/api/typesUnsafe.ts +1 -2
  346. package/src/simple-tree/api/verboseTree.ts +3 -0
  347. package/src/simple-tree/arrayNode.ts +4 -3
  348. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  349. package/src/simple-tree/core/treeNodeSchema.ts +99 -31
  350. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -0
  351. package/src/simple-tree/core/withType.ts +1 -9
  352. package/src/simple-tree/createContext.ts +1 -1
  353. package/src/simple-tree/index.ts +15 -1
  354. package/src/simple-tree/leafNodeSchema.ts +6 -1
  355. package/src/simple-tree/mapNode.ts +7 -1
  356. package/src/simple-tree/schemaTypes.ts +128 -14
  357. package/src/simple-tree/treeNodeValid.ts +11 -1
  358. package/src/util/index.ts +1 -0
  359. package/src/util/typeCheck.ts +13 -0
  360. package/src/util/utils.ts +20 -7
  361. package/dist/simple-tree/toFlexSchema.d.ts.map +0 -1
  362. package/dist/simple-tree/toFlexSchema.js.map +0 -1
  363. package/lib/simple-tree/toFlexSchema.d.ts.map +0 -1
  364. package/lib/simple-tree/toFlexSchema.js.map +0 -1
  365. /package/src/simple-tree/{toFlexSchema.ts → toStoredSchema.ts} +0 -0
@@ -21,6 +21,7 @@
21
21
  "covariantly",
22
22
  "deprioritized",
23
23
  "endregion",
24
+ "fluidframework",
24
25
  "insertable",
25
26
  "reentrantly",
26
27
  "typeparam",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,376 @@
1
1
  # @fluidframework/tree
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ✨ New! Alpha APIs for tree data import and export ([#22566](https://github.com/microsoft/FluidFramework/pull/22566)) [18a23e8816](https://github.com/microsoft/FluidFramework/commit/18a23e8816467f2ed0c9d6d8637b70d99aa48b7a)
8
+
9
+ A collection of new `@alpha` APIs for importing and exporting tree content and schema from SharedTrees has been added to `TreeAlpha`.
10
+ These include import and export APIs for `VerboseTree`, `ConciseTree` and compressed tree formats.
11
+
12
+ `TreeAlpha.create` is also added to allow constructing trees with a more general API instead of having to use the schema constructor directly (since that doesn't handle polymorphic roots, or non-schema aware code).
13
+
14
+ The function `independentInitializedView` has been added to provide a way to combine data from the existing `extractPersistedSchema` and new `TreeAlpha.exportCompressed` back into a `TreeView` in a way which can support safely importing data which could have been exported with a different schema.
15
+ This allows replicating the schema evolution process for Fluid documents stored in a service, but entirely locally without involving any collaboration services.
16
+ `independentView` has also been added, which is similar but handles the case of creating a new view without an existing schema or tree.
17
+
18
+ Together these APIs address several use-cases:
19
+
20
+ 1. Using SharedTree as an in-memory non-collaborative datastore.
21
+ 2. Importing and exporting data from a SharedTree to and from other services or storage locations (such as locally saved files).
22
+ 3. Testing various scenarios without relying on a service.
23
+ 4. Using SharedTree libraries for just the schema system and encode/decode support.
24
+
25
+ - Compilation no longer fails when building with TypeScript's libCheck option ([#22923](https://github.com/microsoft/FluidFramework/pull/22923)) [a1b4cdd45e](https://github.com/microsoft/FluidFramework/commit/a1b4cdd45ee9812e2598ab8d2854333d26a06eb4)
26
+
27
+ When compiling code using Fluid Framework with TypeScript's `libCheck` (meaning without [skipLibCheck](https://www.typescriptlang.org/tsconfig/#skipLibCheck)), two compile errors can be encountered:
28
+
29
+ ```
30
+ > tsc
31
+
32
+ node_modules/@fluidframework/merge-tree/lib/client.d.ts:124:18 - error TS2368: Type parameter name cannot be 'undefined'.
33
+
34
+ 124 walkSegments<undefined>(handler: ISegmentAction<undefined>, start?: number, end?: number, accum?: undefined, splitRange?: boolean): void;
35
+ ~~~~~~~~~
36
+
37
+ node_modules/@fluidframework/tree/lib/util/utils.d.ts:5:29 - error TS7016: Could not find a declaration file for module '@ungap/structured-clone'. 'node_modules/@ungap/structured-clone/esm/index.js' implicitly has an 'any' type.
38
+ Try `npm i --save-dev @types/ungap__structured-clone` if it exists or add a new declaration (.d.ts) file containing `declare module '@ungap/structured-clone';`
39
+
40
+ 5 import structuredClone from "@ungap/structured-clone";
41
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
42
+ ```
43
+
44
+ The first error impacts projects using TypeScript 5.5 or greater and either of the `fluid-framework` or `@fluidframework/merge-tree` packages.
45
+ The second error impacts projects using the `noImplicitAny` tsconfig setting and the `fluid-framework` or `@fluidframework/tree` packages.
46
+
47
+ Both errors have been fixed.
48
+
49
+ This should allow `libCheck` to be reenabled in any impacted projects.
50
+
51
+ - A `.schema` member has been added to the alpha enum schema APIs ([#22874](https://github.com/microsoft/FluidFramework/pull/22874)) [645b9ed695](https://github.com/microsoft/FluidFramework/commit/645b9ed69540338843ad14f1144ff4d1f80d6f09)
52
+
53
+ The return value from `@alpha` APIs `enumFromStrings` and `adaptEnum` now has a property named `schema` which can be used to include it in a parent schema.
54
+ This replaces the use of `typedObjectValues` which has been removed.
55
+
56
+ Use of these APIs now look like:
57
+
58
+ ```typescript
59
+ const schemaFactory = new SchemaFactory("com.myApp");
60
+ const Mode = enumFromStrings(schemaFactory, ["Fun", "Cool"]);
61
+ type Mode = NodeFromSchema<(typeof Mode.schema)[number]>;
62
+ class Parent extends schemaFactory.object("Parent", { mode: Mode.schema }) {}
63
+ ```
64
+
65
+ Previously, the last two lines would have been:
66
+
67
+ ```typescript
68
+ type Mode = NodeFromSchema<(typeof Mode)[keyof typeof Mode]>; // This no longer works
69
+ class Parent extends schemaFactory.object("Parent", { mode: typedObjectValues(Mode) }) {} // This no longer works
70
+ ```
71
+
72
+ - TreeNodeSchemaClass now specifies its TNode as TreeNode ([#22938](https://github.com/microsoft/FluidFramework/pull/22938)) [b669a6efdb](https://github.com/microsoft/FluidFramework/commit/b669a6efdba685c71897cade4f907304f1a73910)
73
+
74
+ `TreeNodeSchemaClass`'s `TNode` parameter was formerly `unknown` and has been improved to be the more specific `TreeNode | TreeLeafValue`.
75
+ This change further narrows this to `TreeNode`.
76
+
77
+ `TreeNodeSchema`, which is more commonly used, still permits `TNode` of `TreeNode | TreeLeafValue`, so this change should have little impact on most code, but in some edge cases it can result in slightly more specific typing.
78
+
79
+ - Array and Map nodes can now be explicitly constructed with undefined or no argument ([#22946](https://github.com/microsoft/FluidFramework/pull/22946)) [176335ce88](https://github.com/microsoft/FluidFramework/commit/176335ce88d005159819c559b445a1655ec429d5)
80
+
81
+ The input parameter to the constructor and `create` methods of Array and Map nodes is now optional. When the optional parameter is omitted, an empty map or array will be created.
82
+
83
+ #### Examples
84
+
85
+ ```typescript
86
+ class Schema extends schemaFactory.array("x", schemaFactory.number) {}
87
+
88
+ // Existing support
89
+ const _fromIterable: Schema = new Schema([]);
90
+
91
+ // New
92
+ const _fromUndefined: Schema = new Schema(undefined);
93
+ const _fromNothing: Schema = new Schema();
94
+ ```
95
+
96
+ ```typescript
97
+ class Schema extends schemaFactory.map("x", schemaFactory.number) {}
98
+
99
+ // Existing support
100
+ const _fromIterable: Schema = new Schema([]);
101
+ const _fromObject: Schema = new Schema({});
102
+
103
+ // New
104
+ const _fromUndefined: Schema = new Schema(undefined);
105
+ const _fromNothing: Schema = new Schema();
106
+ ```
107
+
108
+ ```typescript
109
+ const Schema = schemaFactory.array(schemaFactory.number);
110
+ type Schema = NodeFromSchema<typeof Schema>;
111
+
112
+ // Existing support
113
+ const _fromIterable: Schema = Schema.create([]);
114
+
115
+ // New
116
+ const _fromUndefined: Schema = Schema.create(undefined);
117
+ const _fromNothing: Schema = Schema.create();
118
+ ```
119
+
120
+ ```typescript
121
+ const Schema = schemaFactory.map(schemaFactory.number);
122
+ type Schema = NodeFromSchema<typeof Schema>;
123
+ // Existing support
124
+ const _fromIterable: Schema = Schema.create([]);
125
+ const _fromObject: Schema = Schema.create({});
126
+
127
+ // New
128
+ const _fromUndefined: Schema = Schema.create(undefined);
129
+ const _fromNothing: Schema = Schema.create();
130
+ ```
131
+
132
+ - Typing has been improved when an exact TypeScript type for a schema is not provided ([#22763](https://github.com/microsoft/FluidFramework/pull/22763)) [05197d6d3f](https://github.com/microsoft/FluidFramework/commit/05197d6d3f0189ecd61fd74ec55f6836e6797249)
133
+
134
+ The Tree APIs are designed to be used in a strongly typed way, with the full TypeScript type for the schema always being provided.
135
+ Due to limitations of the TypeScript language, there was no practical way to prevent less descriptive types, like `TreeNodeSchema` or `ImplicitFieldSchema`, from being used where the type of a specific schema was intended.
136
+ Code which does this will encounter several issues with tree APIs, and this change fixes some of those issues.
137
+ This change mainly fixes that `NodeFromSchema<TreeNodeSchema>` used to return `unknown` and now returns `TreeNode | TreeLeafValue`.
138
+
139
+ This change by itself seems mostly harmless, as it just improves the precision of the typing in this one edge case.
140
+ Unfortunately, there are other typing bugs which complicate the situation, causing APIs for inserting data into the tree to also behave poorly when given non-specific types like `TreeNodeSchema`.
141
+ These APIs include cases like `TreeView.initialize`.
142
+
143
+ This incorrectly allowed some usage like taking a type-erased schema and initial tree pair, creating a view of type `TreeView<ImplicitFieldSchema>`, then initializing it.
144
+ With the typing being partly fixed, some unsafe inputs are still allowed when trying to initialize such a view, but some are now prevented.
145
+
146
+ This use-case of modifying trees in code not that is not strongly typed by the exact schema was not intended to be supported.
147
+ Despite this, it did mostly work in some cases, and has some real use-cases (like tests looping over test data consisting of pairs of schema and initial trees).
148
+ To help mitigate the impact of this change, some experimental `@alpha` APIs have been introduced to help address these previously unsupported but somewhat working use-cases.
149
+
150
+ Before this change:
151
+
152
+ ```typescript
153
+ import { TinyliciousClient } from "@fluidframework/tinylicious-client";
154
+ import {
155
+ SchemaFactory,
156
+ SharedTree,
157
+ TreeViewConfiguration,
158
+ type TreeNodeSchema,
159
+ } from "fluid-framework";
160
+
161
+ // Create a ITree instance
162
+ const tinyliciousClient = new TinyliciousClient();
163
+ const { container } = await tinyliciousClient.createContainer({ initialObjects: {} }, "2");
164
+ const tree = await container.create(SharedTree);
165
+
166
+ const schemaFactory = new SchemaFactory("demo");
167
+
168
+ // Bad: This loses the schema aware type information. `: TreeNodeSchema` should be omitted to preserve strong typing.
169
+ const schema: TreeNodeSchema = schemaFactory.array(schemaFactory.number);
170
+ const config = new TreeViewConfiguration({ schema });
171
+
172
+ // This view is typed as `TreeView<TreeNodeSchema>`, which does not work well since it's missing the actual schema type information.
173
+ const view = tree.viewWith(config);
174
+ // Root is typed as `unknown` allowing invalid assignment operations.
175
+ view.root = "invalid";
176
+ view.root = {};
177
+ // Since all assignments are allowed, valid ones still work:
178
+ view.root = [];
179
+ ```
180
+
181
+ After this change:
182
+
183
+ ```typescript
184
+ // Root is now typed as `TreeNode | TreeLeafValue`, still allowing some invalid assignment operations.
185
+ // In the future this should be prevented as well, since the type of the setter in this case should be `never`.
186
+ view.root = "invalid";
187
+ // This no longer compiles:
188
+ view.root = {};
189
+ // This also no longer compiles despite being valid at runtime:
190
+ view.root = [];
191
+ ```
192
+
193
+ For code that wants to continue using an unsafe API, which can result in runtime errors if the data does not follow the schema, a new alternative has been added to address this use-case. A special type `UnsafeUnknownSchema` can now be used to opt into allowing all valid trees to be provided.
194
+ Note that this leaves ensuring the data is in schema up to the user.
195
+ For now these adjusted APIs can be accessed by casting the view to `TreeViewAlpha<UnsafeUnknownSchema>`.
196
+ If stabilized, this option will be added to `TreeView` directly.
197
+
198
+ ```typescript
199
+ const viewAlpha = view as TreeViewAlpha<UnsafeUnknownSchema>;
200
+ viewAlpha.initialize([]);
201
+ viewAlpha.root = [];
202
+ ```
203
+
204
+ Additionally, this seems to have negatively impacted co-recursive schema which declare a co-recursive array as the first schema in the co-recursive cycle.
205
+ Like the TypeScript language our schema system is built on, we don't guarantee exactly which recursive type will compile, but will do our best to ensure useful recursive schema can be created easily.
206
+ In this case a slight change may be required to some recursive schema to get them to compile again:
207
+
208
+ For example this schema used to compile:
209
+
210
+ ```typescript
211
+ class A extends sf.arrayRecursive("A", [() => B]) {}
212
+ {
213
+ type _check = ValidateRecursiveSchema<typeof A>;
214
+ }
215
+ // Used to work, but breaks in this update.
216
+ class B extends sf.object("B", { x: A }) {}
217
+ ```
218
+
219
+ But now you must use the recursive functions like `objectRecursive` for types which are co-recursive with an array in some cases.
220
+ In our example, it can be fixed as follows:
221
+
222
+ ```typescript
223
+ class A extends sf.arrayRecursive("A", [() => B]) {}
224
+ {
225
+ type _check = ValidateRecursiveSchema<typeof A>;
226
+ }
227
+ // Fixed corecursive type, using "Recursive" method variant to declare schema.
228
+ class B extends sf.objectRecursive("B", { x: A }) {}
229
+ {
230
+ type _check = ValidateRecursiveSchema<typeof B>;
231
+ }
232
+ ```
233
+
234
+ Note: while the following pattern may still compile, we recommend using the previous pattern instead since the one below may break in the future.
235
+
236
+ ```typescript
237
+ class B extends sf.objectRecursive("B", { x: [() => A] }) {}
238
+ {
239
+ type _check = ValidateRecursiveSchema<typeof B>;
240
+ }
241
+ // Works, for now, but not recommended.
242
+ class A extends sf.array("A", B) {}
243
+ ```
244
+
245
+ - The strictness of input tree types when inexact schemas are provided has been improved ([#22874](https://github.com/microsoft/FluidFramework/pull/22874)) [645b9ed695](https://github.com/microsoft/FluidFramework/commit/645b9ed69540338843ad14f1144ff4d1f80d6f09)
246
+
247
+ Consider the following code where the type of the schema is not exactly specified:
248
+
249
+ ```typescript
250
+ const schemaFactory = new SchemaFactory("com.myApp");
251
+ class A extends schemaFactory.object("A", {}) {}
252
+ class B extends schemaFactory.array("B", schemaFactory.number) {}
253
+
254
+ // Gives imprecise type (typeof A | typeof B)[]. The desired precise type here is [typeof A, typeof B].
255
+ const schema = [A, B];
256
+
257
+ const config = new TreeViewConfiguration({ schema });
258
+ const view = sharedTree.viewWith(config);
259
+
260
+ // Does not compile since setter for root is typed `never` due to imprecise schema.
261
+ view.root = [];
262
+ ```
263
+
264
+ The assignment of `view.root` is disallowed since a schema with type `(typeof A | typeof B)[]` could be any of:
265
+
266
+ ```typescript
267
+ const schema: (typeof A | typeof B)[] = [A];
268
+ ```
269
+
270
+ ```typescript
271
+ const schema: (typeof A | typeof B)[] = [B];
272
+ ```
273
+
274
+ ```typescript
275
+ const schema: (typeof A | typeof B)[] = [A, B];
276
+ ```
277
+
278
+ The attempted assignment is not compatible with all of these (specifically it is incompatible with the first one) so performing this assignment could make the tree out of schema and is thus disallowed.
279
+
280
+ To avoid this ambiguity and capture the precise type of `[typeof A, typeof B]`, use one of the following patterns:
281
+
282
+ ```typescript
283
+ const schema = [A, B] as const;
284
+ const config = new TreeViewConfiguration({ schema });
285
+ ```
286
+
287
+ ```typescript
288
+ const config = new TreeViewConfiguration({ schema: [A, B] });
289
+ ```
290
+
291
+ To help update existing code which accidentally depended on this bug, an `@alpha` API `unsafeArrayToTuple` has been added.
292
+ Many usages of this API will produce incorrectly typed outputs.
293
+ However, when given `AllowedTypes` arrays which should not contain any unions, but that were accidentally flattened to a single union, it can fix them:
294
+
295
+ ```typescript
296
+ // Gives imprecise type (typeof A | typeof B)[]
297
+ const schemaBad = [A, B];
298
+ // Fixes the type to be [typeof A, typeof B]
299
+ const schema = unsafeArrayToTuple(schemaBad);
300
+
301
+ const config = new TreeViewConfiguration({ schema });
302
+ ```
303
+
304
+ - SharedTree branching API has been improved ([#22970](https://github.com/microsoft/FluidFramework/pull/22970)) [80ed0284f0](https://github.com/microsoft/FluidFramework/commit/80ed0284f01107d2ba8bcf2f3ebaf6175367603a)
305
+
306
+ The alpha SharedTree branching API has been updated to be more accessible and intuitive.
307
+ The branching functions (`branch`, `merge`, `rebaseOnto`, etc.) are now directly available on the view object rather than a separate object.
308
+ In particular, `TreeViewAlpha` is now a `TreeBranch`, which exposes the methods to coordinate branches.
309
+
310
+ The existing `TreeBranch` type has been renamed to `BranchableTree` and is now **deprecated**.
311
+
312
+ See the `TreeBranch` interface for more details.
313
+
314
+ The new API is used e.g. as follows:
315
+
316
+ ```typescript
317
+ const sf = new SchemaFactory("example");
318
+ class StringArray extends sf.array("StringArray", sf.string) {}
319
+
320
+ function example(view: TreeViewAlpha<typeof StringArray>): void {
321
+ // Create a branch
322
+ const branch = view.fork();
323
+ // Modify the branch rather than the main view
324
+ branch.root.insertAtEnd("new string");
325
+ // `view` does not yet contain "new string"
326
+ // ...
327
+ // Later, merge the branch into the main view
328
+ view.merge(branch);
329
+ // `view` now contains "new string"
330
+ }
331
+ ```
332
+
333
+ Here is the equivalent behavior with the previous API, for reference:
334
+
335
+ ```typescript
336
+ const sf = new SchemaFactory("example");
337
+ class StringArray extends sf.array("StringArray", sf.string) {}
338
+
339
+ function example(view: TreeViewAlpha<typeof StringArray>): void {
340
+ // Get the branch for the view
341
+ const branch = getBranch(view);
342
+ const fork = branch.branch();
343
+ // Modify the branch rather than the main view
344
+ fork.root.insertAtEnd("new string");
345
+ // `view` does not yet contain "new string"
346
+ // ...
347
+ // Later, merge the branch into the main view
348
+ branch.merge(fork);
349
+ // `view` now contains "new string"
350
+ }
351
+ ```
352
+
353
+ Additionally, there is a new API to acquire the branch from a node:
354
+
355
+ ```typescript
356
+ // All nodes that have been inserted into the tree belong to a branch - this retrieves that branch
357
+ const branch = TreeAlpha.branch(node);
358
+ ```
359
+
360
+ To convert the branch object to a view with a known schema, use:
361
+
362
+ ```typescript
363
+ if (branch.hasRootSchema(MySchema)) {
364
+ const view = branch; // `branch` is now typed as a `TreeViewAlpha<MySchema>`
365
+ }
366
+ ```
367
+
368
+ Use the following function to expose the alpha APIs on a `TreeView` that is not typed as a `TreeViewAlpha`:
369
+
370
+ ```typescript
371
+ const viewAlpha = asTreeViewAlpha(view);
372
+ ```
373
+
3
374
  ## 2.4.0
4
375
 
5
376
  ### Minor Changes