@fluidframework/tree 2.32.0 → 2.33.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 (339) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/api-report/tree.alpha.api.md +169 -192
  3. package/api-report/tree.beta.api.md +135 -164
  4. package/api-report/tree.legacy.alpha.api.md +138 -167
  5. package/api-report/tree.legacy.public.api.md +135 -164
  6. package/api-report/tree.public.api.md +135 -164
  7. package/dist/alpha.d.ts +3 -11
  8. package/dist/beta.d.ts +2 -11
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +1 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/schema-stored/index.d.ts +1 -1
  14. package/dist/core/schema-stored/index.d.ts.map +1 -1
  15. package/dist/core/schema-stored/index.js +1 -2
  16. package/dist/core/schema-stored/index.js.map +1 -1
  17. package/dist/core/schema-stored/schema.d.ts +4 -11
  18. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  19. package/dist/core/schema-stored/schema.js +7 -14
  20. package/dist/core/schema-stored/schema.js.map +1 -1
  21. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  22. package/dist/core/tree/anchorSet.js +31 -24
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/deltaUtil.d.ts +1 -4
  25. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  26. package/dist/core/tree/deltaUtil.js +1 -13
  27. package/dist/core/tree/deltaUtil.js.map +1 -1
  28. package/dist/core/tree/visitDelta.d.ts +6 -29
  29. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  30. package/dist/core/tree/visitDelta.js +11 -50
  31. package/dist/core/tree/visitDelta.js.map +1 -1
  32. package/dist/core/tree/visitorUtils.d.ts +12 -9
  33. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  34. package/dist/core/tree/visitorUtils.js +19 -32
  35. package/dist/core/tree/visitorUtils.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -11
  38. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
  43. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
  45. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/context.d.ts +5 -0
  49. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/context.js +4 -0
  51. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  52. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  53. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  54. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  55. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  56. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  57. package/dist/feature-libraries/indexing/anchorTreeIndex.js +15 -22
  58. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  59. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  60. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  61. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  62. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  63. package/dist/feature-libraries/object-forest/objectForest.js +1 -7
  64. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  65. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  66. package/dist/feature-libraries/schema-index/codec.js +1 -1
  67. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +3 -2
  71. package/dist/index.js.map +1 -1
  72. package/dist/internalTypes.d.ts +1 -1
  73. package/dist/internalTypes.d.ts.map +1 -1
  74. package/dist/internalTypes.js.map +1 -1
  75. package/dist/jsonDomainSchema.d.ts +6 -6
  76. package/dist/jsonDomainSchema.d.ts.map +1 -1
  77. package/dist/jsonDomainSchema.js.map +1 -1
  78. package/dist/legacy.d.ts +2 -11
  79. package/dist/packageVersion.d.ts +1 -1
  80. package/dist/packageVersion.js +1 -1
  81. package/dist/packageVersion.js.map +1 -1
  82. package/dist/public.d.ts +2 -11
  83. package/dist/serializableDomainSchema.d.ts +5 -5
  84. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  85. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  86. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  87. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  88. package/dist/shared-tree/index.d.ts +3 -2
  89. package/dist/shared-tree/index.d.ts.map +1 -1
  90. package/dist/shared-tree/index.js +2 -2
  91. package/dist/shared-tree/index.js.map +1 -1
  92. package/dist/shared-tree/sharedTree.d.ts +4 -35
  93. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  94. package/dist/shared-tree/sharedTree.js +4 -54
  95. package/dist/shared-tree/sharedTree.js.map +1 -1
  96. package/dist/simple-tree/api/index.d.ts +2 -1
  97. package/dist/simple-tree/api/index.d.ts.map +1 -1
  98. package/dist/simple-tree/api/index.js +3 -1
  99. package/dist/simple-tree/api/index.js.map +1 -1
  100. package/dist/simple-tree/api/schemaFactory.d.ts +28 -28
  101. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  102. package/dist/simple-tree/api/schemaFactory.js +11 -11
  103. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  104. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
  105. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  106. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  107. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
  108. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  109. package/dist/simple-tree/api/schemaFactoryRecursive.js +14 -1
  110. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  111. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  112. package/dist/simple-tree/api/tree.d.ts +1 -14
  113. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  114. package/dist/simple-tree/api/tree.js.map +1 -1
  115. package/dist/simple-tree/api/typesUnsafe.d.ts +237 -220
  116. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  117. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  118. package/dist/simple-tree/arrayNode.d.ts +2 -2
  119. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  120. package/dist/simple-tree/arrayNode.js.map +1 -1
  121. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  122. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  123. package/dist/simple-tree/core/treeNodeKernel.js +39 -24
  124. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  125. package/dist/simple-tree/core/types.d.ts +14 -4
  126. package/dist/simple-tree/core/types.d.ts.map +1 -1
  127. package/dist/simple-tree/core/types.js +14 -4
  128. package/dist/simple-tree/core/types.js.map +1 -1
  129. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  130. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  131. package/dist/simple-tree/core/unhydratedFlexTree.js +3 -0
  132. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  133. package/dist/simple-tree/index.d.ts +1 -1
  134. package/dist/simple-tree/index.d.ts.map +1 -1
  135. package/dist/simple-tree/index.js +3 -2
  136. package/dist/simple-tree/index.js.map +1 -1
  137. package/dist/simple-tree/objectNode.d.ts +9 -2
  138. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  139. package/dist/simple-tree/objectNode.js +3 -0
  140. package/dist/simple-tree/objectNode.js.map +1 -1
  141. package/dist/simple-tree/schemaTypes.d.ts +10 -5
  142. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  143. package/dist/simple-tree/schemaTypes.js +5 -2
  144. package/dist/simple-tree/schemaTypes.js.map +1 -1
  145. package/dist/tableSchema.d.ts +78 -26
  146. package/dist/tableSchema.d.ts.map +1 -1
  147. package/dist/tableSchema.js +53 -24
  148. package/dist/tableSchema.js.map +1 -1
  149. package/dist/treeFactory.d.ts +6 -12
  150. package/dist/treeFactory.d.ts.map +1 -1
  151. package/dist/treeFactory.js +56 -5
  152. package/dist/treeFactory.js.map +1 -1
  153. package/lib/alpha.d.ts +3 -11
  154. package/lib/beta.d.ts +2 -11
  155. package/lib/core/index.d.ts +1 -1
  156. package/lib/core/index.d.ts.map +1 -1
  157. package/lib/core/index.js +1 -1
  158. package/lib/core/index.js.map +1 -1
  159. package/lib/core/schema-stored/index.d.ts +1 -1
  160. package/lib/core/schema-stored/index.d.ts.map +1 -1
  161. package/lib/core/schema-stored/index.js +1 -1
  162. package/lib/core/schema-stored/index.js.map +1 -1
  163. package/lib/core/schema-stored/schema.d.ts +4 -11
  164. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  165. package/lib/core/schema-stored/schema.js +6 -12
  166. package/lib/core/schema-stored/schema.js.map +1 -1
  167. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  168. package/lib/core/tree/anchorSet.js +31 -24
  169. package/lib/core/tree/anchorSet.js.map +1 -1
  170. package/lib/core/tree/deltaUtil.d.ts +1 -4
  171. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  172. package/lib/core/tree/deltaUtil.js +0 -9
  173. package/lib/core/tree/deltaUtil.js.map +1 -1
  174. package/lib/core/tree/visitDelta.d.ts +6 -29
  175. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  176. package/lib/core/tree/visitDelta.js +12 -51
  177. package/lib/core/tree/visitDelta.js.map +1 -1
  178. package/lib/core/tree/visitorUtils.d.ts +12 -9
  179. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  180. package/lib/core/tree/visitorUtils.js +19 -32
  181. package/lib/core/tree/visitorUtils.js.map +1 -1
  182. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  183. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -11
  184. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  185. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  186. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  187. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  188. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts +41 -5
  189. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +1 -1
  190. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +43 -26
  191. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  192. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -1
  193. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  194. package/lib/feature-libraries/flex-tree/context.d.ts +5 -0
  195. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  196. package/lib/feature-libraries/flex-tree/context.js +5 -1
  197. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  198. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  199. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  200. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  201. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  202. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  203. package/lib/feature-libraries/indexing/anchorTreeIndex.js +15 -22
  204. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  205. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  206. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  207. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  208. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  209. package/lib/feature-libraries/object-forest/objectForest.js +1 -7
  210. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  211. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  212. package/lib/feature-libraries/schema-index/codec.js +2 -2
  213. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  214. package/lib/index.d.ts +1 -1
  215. package/lib/index.d.ts.map +1 -1
  216. package/lib/index.js +1 -1
  217. package/lib/index.js.map +1 -1
  218. package/lib/internalTypes.d.ts +1 -1
  219. package/lib/internalTypes.d.ts.map +1 -1
  220. package/lib/internalTypes.js.map +1 -1
  221. package/lib/jsonDomainSchema.d.ts +6 -6
  222. package/lib/jsonDomainSchema.d.ts.map +1 -1
  223. package/lib/jsonDomainSchema.js.map +1 -1
  224. package/lib/legacy.d.ts +2 -11
  225. package/lib/packageVersion.d.ts +1 -1
  226. package/lib/packageVersion.js +1 -1
  227. package/lib/packageVersion.js.map +1 -1
  228. package/lib/public.d.ts +2 -11
  229. package/lib/serializableDomainSchema.d.ts +5 -5
  230. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  231. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  232. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  233. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  234. package/lib/shared-tree/index.d.ts +3 -2
  235. package/lib/shared-tree/index.d.ts.map +1 -1
  236. package/lib/shared-tree/index.js +1 -1
  237. package/lib/shared-tree/index.js.map +1 -1
  238. package/lib/shared-tree/sharedTree.d.ts +4 -35
  239. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  240. package/lib/shared-tree/sharedTree.js +2 -51
  241. package/lib/shared-tree/sharedTree.js.map +1 -1
  242. package/lib/simple-tree/api/index.d.ts +2 -1
  243. package/lib/simple-tree/api/index.d.ts.map +1 -1
  244. package/lib/simple-tree/api/index.js +1 -0
  245. package/lib/simple-tree/api/index.js.map +1 -1
  246. package/lib/simple-tree/api/schemaFactory.d.ts +28 -28
  247. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  248. package/lib/simple-tree/api/schemaFactory.js +11 -11
  249. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  250. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +6 -7
  251. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  252. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  253. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +24 -5
  254. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  255. package/lib/simple-tree/api/schemaFactoryRecursive.js +12 -0
  256. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  257. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  258. package/lib/simple-tree/api/tree.d.ts +1 -14
  259. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  260. package/lib/simple-tree/api/tree.js.map +1 -1
  261. package/lib/simple-tree/api/typesUnsafe.d.ts +237 -220
  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/arrayNode.d.ts +2 -2
  265. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  266. package/lib/simple-tree/arrayNode.js.map +1 -1
  267. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  268. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  269. package/lib/simple-tree/core/treeNodeKernel.js +40 -25
  270. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  271. package/lib/simple-tree/core/types.d.ts +14 -4
  272. package/lib/simple-tree/core/types.d.ts.map +1 -1
  273. package/lib/simple-tree/core/types.js +14 -4
  274. package/lib/simple-tree/core/types.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 +3 -0
  278. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  279. package/lib/simple-tree/index.d.ts +1 -1
  280. package/lib/simple-tree/index.d.ts.map +1 -1
  281. package/lib/simple-tree/index.js +1 -1
  282. package/lib/simple-tree/index.js.map +1 -1
  283. package/lib/simple-tree/objectNode.d.ts +9 -2
  284. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  285. package/lib/simple-tree/objectNode.js +4 -1
  286. package/lib/simple-tree/objectNode.js.map +1 -1
  287. package/lib/simple-tree/schemaTypes.d.ts +10 -5
  288. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  289. package/lib/simple-tree/schemaTypes.js +5 -2
  290. package/lib/simple-tree/schemaTypes.js.map +1 -1
  291. package/lib/tableSchema.d.ts +78 -26
  292. package/lib/tableSchema.d.ts.map +1 -1
  293. package/lib/tableSchema.js +53 -24
  294. package/lib/tableSchema.js.map +1 -1
  295. package/lib/treeFactory.d.ts +6 -12
  296. package/lib/treeFactory.d.ts.map +1 -1
  297. package/lib/treeFactory.js +55 -3
  298. package/lib/treeFactory.js.map +1 -1
  299. package/lib/tsdoc-metadata.json +1 -1
  300. package/package.json +22 -23
  301. package/src/core/index.ts +0 -2
  302. package/src/core/schema-stored/index.ts +0 -2
  303. package/src/core/schema-stored/schema.ts +10 -29
  304. package/src/core/tree/anchorSet.ts +32 -24
  305. package/src/core/tree/deltaUtil.ts +1 -13
  306. package/src/core/tree/visitDelta.ts +24 -81
  307. package/src/core/tree/visitorUtils.ts +43 -53
  308. package/src/feature-libraries/chunked-forest/chunkedForest.ts +7 -22
  309. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
  310. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +45 -27
  311. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -1
  312. package/src/feature-libraries/flex-tree/context.ts +11 -1
  313. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  314. package/src/feature-libraries/indexing/anchorTreeIndex.ts +17 -28
  315. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  316. package/src/feature-libraries/object-forest/objectForest.ts +1 -18
  317. package/src/feature-libraries/schema-index/codec.ts +1 -2
  318. package/src/index.ts +3 -11
  319. package/src/internalTypes.ts +0 -19
  320. package/src/jsonDomainSchema.ts +1 -3
  321. package/src/packageVersion.ts +1 -1
  322. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  323. package/src/shared-tree/index.ts +8 -3
  324. package/src/shared-tree/sharedTree.ts +5 -133
  325. package/src/simple-tree/api/index.ts +2 -22
  326. package/src/simple-tree/api/schemaFactory.ts +40 -54
  327. package/src/simple-tree/api/schemaFactoryAlpha.ts +9 -14
  328. package/src/simple-tree/api/schemaFactoryRecursive.ts +25 -5
  329. package/src/simple-tree/api/tree.ts +1 -14
  330. package/src/simple-tree/api/typesUnsafe.ts +359 -341
  331. package/src/simple-tree/arrayNode.ts +2 -2
  332. package/src/simple-tree/core/treeNodeKernel.ts +46 -28
  333. package/src/simple-tree/core/types.ts +14 -4
  334. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  335. package/src/simple-tree/index.ts +2 -22
  336. package/src/simple-tree/objectNode.ts +13 -4
  337. package/src/simple-tree/schemaTypes.ts +11 -7
  338. package/src/tableSchema.ts +190 -63
  339. package/src/treeFactory.ts +151 -8
@@ -17,6 +17,7 @@ import {
17
17
  TreeArrayNode,
18
18
  type TreeNode,
19
19
  type TreeNodeFromImplicitAllowedTypes,
20
+ type TreeNodeSchema,
20
21
  type TreeNodeSchemaClass,
21
22
  type WithType,
22
23
  } from "./simple-tree/index.js";
@@ -42,22 +43,34 @@ export namespace TableSchema {
42
43
  * @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.
43
44
  * @sealed @internal
44
45
  */
45
- export interface IColumn {
46
+ export interface IColumn<TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
46
47
  /**
47
48
  * The unique identifier of the column.
48
49
  * @remarks Uniquely identifies the node within the entire tree, not just the table.
49
50
  */
50
51
  readonly id: string;
52
+
53
+ /**
54
+ * User-provided column properties.
55
+ */
56
+ get props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;
57
+ set props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);
51
58
  }
52
59
 
53
60
  /**
54
61
  * Factory for creating new table column schema.
62
+ * @privateRemarks
63
+ * TODO:
64
+ * - Add overloads to make propsSchema optional.
65
+ * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
66
+ * the additional properties optional.
55
67
  * @internal
56
68
  */
57
69
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
58
- export function createColumn<const TInputScope extends string | undefined>(
59
- inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
60
- ) {
70
+ export function createColumn<
71
+ const TInputScope extends string | undefined,
72
+ const TPropsSchema extends ImplicitAllowedTypes,
73
+ >(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {
61
74
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
62
75
  type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
63
76
 
@@ -65,17 +78,24 @@ export namespace TableSchema {
65
78
  * {@link Column} fields.
66
79
  * @remarks Extracted for re-use in returned type signature defined later in this function.
67
80
  * The implicit typing is intentional.
81
+ * Note: ideally we would add a satisfies clause here to ensure that this satisfies
82
+ * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
83
+ * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
68
84
  */
69
85
  const columnFields = {
70
86
  id: schemaFactory.identifier,
71
- } as const satisfies Record<string, ImplicitFieldSchema>;
87
+ props: schemaFactory.required(propsSchema),
88
+ } as const;
72
89
 
73
90
  /**
74
91
  * A column in a table.
75
92
  */
76
- class Column extends schemaFactory.object("Column", columnFields) implements IColumn {}
93
+ class Column extends schemaFactory.object("Column", columnFields) {}
94
+
95
+ type ColumnValueType = TreeNode &
96
+ IColumn<TPropsSchema> &
97
+ WithType<ScopedSchemaName<Scope, "Column">>;
77
98
 
78
- type ColumnValueType = TreeNode & IColumn & WithType<ScopedSchemaName<Scope, "Column">>;
79
99
  type ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;
80
100
 
81
101
  // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
@@ -99,9 +119,10 @@ export namespace TableSchema {
99
119
  * Base column schema type.
100
120
  * @sealed @system @internal
101
121
  */
102
- export type ColumnSchemaBase<TScope extends string | undefined> = ReturnType<
103
- typeof createColumn<TScope>
104
- >;
122
+ export type ColumnSchemaBase<
123
+ TScope extends string | undefined,
124
+ TPropsSchema extends ImplicitAllowedTypes,
125
+ > = ReturnType<typeof createColumn<TScope, TPropsSchema>>;
105
126
 
106
127
  // #endregion
107
128
 
@@ -114,7 +135,7 @@ export namespace TableSchema {
114
135
  */
115
136
  export interface IRow<
116
137
  TCellSchema extends ImplicitAllowedTypes,
117
- TColumnSchema extends ImplicitAllowedTypes,
138
+ TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
118
139
  > {
119
140
  /**
120
141
  * The unique identifier of the row.
@@ -123,45 +144,71 @@ export namespace TableSchema {
123
144
  readonly id: string;
124
145
 
125
146
  /**
126
- * Gets the cell in the specified column
147
+ * Gets the cell in the specified column.
127
148
  * @returns The cell if it exists, otherwise undefined.
128
- * @privateRemarks TODO: add overload that takes column ID.
129
149
  */
130
- getCell(
131
- column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>,
132
- ): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
150
+ getCell(column: IColumn): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
151
+ /**
152
+ * Gets the cell in the specified column, denoted by column ID.
153
+ * @returns The cell if it exists, otherwise undefined.
154
+ */
155
+ getCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
133
156
 
134
157
  /**
135
158
  * Sets the cell in the specified column.
136
- * @remarks To delete a cell, call {@link TableSchema.IRow.deleteCell} instead.
137
- * @privateRemarks TODO: add overload that takes column ID.
159
+ * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:1)} instead.
160
+ */
161
+ setCell(
162
+ column: IColumn,
163
+ value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
164
+ ): void;
165
+ /**
166
+ * Sets the cell in the specified column, denoted by column ID.
167
+ * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:2)} instead.
138
168
  */
139
169
  setCell(
140
- column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>,
170
+ columnId: string,
141
171
  value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
142
172
  ): void;
143
173
 
144
174
  /**
145
- * Deletes the cell in the specified column.
146
- * @privateRemarks TODO: add overload that takes column ID.
175
+ * Removes the cell in the specified column.
176
+ * @privateRemarks TODO: return removed cell
147
177
  */
148
- deleteCell(column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>): void;
178
+ removeCell(column: IColumn): void;
179
+ /**
180
+ * Removes the cell in the specified column, denoted by column ID.
181
+ * @privateRemarks TODO: return removed cell
182
+ */
183
+ removeCell(columnId: string): void;
184
+
185
+ /**
186
+ * User-provided row properties.
187
+ */
188
+ get props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;
189
+ set props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);
149
190
  }
150
191
 
151
192
  /**
152
193
  * Factory for creating new table row schema.
153
- * @privateRemarks TODO: add overloads to make column schema optional.
194
+ *
195
+ * @privateRemarks
196
+ * TODO:
197
+ * - Add overloads to make propsSchema optional.
198
+ * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
199
+ * the additional properties optional.
200
+ *
154
201
  * @sealed @internal
155
202
  */
156
203
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
157
204
  export function createRow<
158
205
  const TInputScope extends string | undefined,
159
206
  const TCellSchema extends ImplicitAllowedTypes,
160
- const TColumnSchema extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,
207
+ const TPropsSchema extends ImplicitAllowedTypes,
161
208
  >(
162
209
  inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
163
210
  cellSchema: TCellSchema,
164
- _columnSchema: TColumnSchema,
211
+ propsSchema: TPropsSchema,
165
212
  ) {
166
213
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
167
214
  type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
@@ -169,41 +216,51 @@ export namespace TableSchema {
169
216
  type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
170
217
  type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
171
218
 
172
- type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
173
-
174
219
  /**
175
220
  * {@link Row} fields.
176
221
  * @remarks Extracted for re-use in returned type signature defined later in this function.
177
222
  * The implicit typing is intentional.
223
+ * Note: ideally we would add a satisfies clause here to ensure that this satisfies
224
+ * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
225
+ * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
178
226
  */
179
227
  const rowFields = {
180
228
  id: schemaFactory.identifier,
181
229
  cells: schemaFactory.map("Row.cells", cellSchema),
182
- } as const satisfies Record<string, ImplicitFieldSchema>;
230
+ props: schemaFactory.required(propsSchema),
231
+ } as const;
183
232
 
184
233
  /**
185
234
  * The Row schema - this is a map of Cells where the key is the column id
186
235
  */
187
236
  class Row
188
237
  extends schemaFactory.object("Row", rowFields)
189
- implements IRow<TCellSchema, TColumnSchema>
238
+ implements IRow<TCellSchema, TPropsSchema>
190
239
  {
191
- public getCell(column: ColumnValueType): CellValueType | undefined {
192
- return this.cells.get(column.id) as CellValueType | undefined;
240
+ public getCell(columnOrId: IColumn | string): CellValueType | undefined {
241
+ const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
242
+ return this.cells.get(columnId) as CellValueType | undefined;
193
243
  }
194
244
 
195
- public setCell(column: ColumnValueType, value: CellInsertableType | undefined): void {
196
- this.cells.set(column.id, value);
245
+ public setCell(
246
+ columnOrId: IColumn | string,
247
+ value: CellInsertableType | undefined,
248
+ ): void {
249
+ const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
250
+ this.cells.set(columnId, value);
197
251
  }
198
252
 
199
- public deleteCell(column: ColumnValueType): void {
200
- if (!this.cells.has(column.id)) return;
201
- this.cells.delete(column.id);
253
+ public removeCell(columnOrId: IColumn | string): void {
254
+ const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
255
+ if (!this.cells.has(columnId)) {
256
+ return;
257
+ }
258
+ this.cells.delete(columnId);
202
259
  }
203
260
  }
204
261
 
205
262
  type RowValueType = TreeNode &
206
- IRow<TCellSchema, TColumnSchema> &
263
+ IRow<TCellSchema, TPropsSchema> &
207
264
  WithType<ScopedSchemaName<Scope, "Row">>;
208
265
  type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;
209
266
 
@@ -231,8 +288,8 @@ export namespace TableSchema {
231
288
  export type RowSchemaBase<
232
289
  TScope extends string | undefined,
233
290
  TCellSchema extends ImplicitAllowedTypes,
234
- TColumnSchema extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,
235
- > = ReturnType<typeof createRow<TScope, TCellSchema, TColumnSchema>>;
291
+ TPropsSchema extends ImplicitAllowedTypes,
292
+ > = ReturnType<typeof createRow<TScope, TCellSchema, TPropsSchema>>;
236
293
 
237
294
  // #endregion
238
295
 
@@ -360,7 +417,7 @@ export namespace TableSchema {
360
417
 
361
418
  /**
362
419
  * Sets the cell at the specified location in the table.
363
- * @remarks To delete a cell, call {@link TableSchema.ITable.deleteCell} instead.
420
+ * @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.
364
421
  * @privateRemarks TODO: add overload that takes column/row nodes?
365
422
  */
366
423
  setCell(
@@ -378,37 +435,100 @@ export namespace TableSchema {
378
435
  removeColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;
379
436
 
380
437
  /**
381
- * Deletes 0 or more rows from the table.
438
+ * Removes 0 or more rows from the table.
382
439
  * @privateRemarks TODO: policy for when 1 or more rows are not in the table.
383
440
  */
384
- deleteRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
441
+ removeRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
385
442
 
386
443
  /**
387
- * Deletes all rows from the table.
444
+ * Removes all rows from the table.
388
445
  */
389
- deleteAllRows: () => void;
446
+ removeAllRows: () => void;
390
447
 
391
448
  /**
392
- * Deletes the cell at the specified location in the table.
449
+ * Removes the cell at the specified location in the table.
393
450
  * @privateRemarks TODO: add overload that takes column/row nodes?
394
451
  */
395
- deleteCell: (key: CellKey) => void;
452
+ removeCell: (key: CellKey) => void;
396
453
  }
397
454
 
455
+ /**
456
+ * Factory for creating new table schema without specifying row or column schema.
457
+ * @internal
458
+ */
459
+ export function createTable<
460
+ const TInputScope extends string | undefined,
461
+ const TCell extends ImplicitAllowedTypes,
462
+ >(
463
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
464
+ _cellSchema: TCell,
465
+ ): ReturnType<typeof createTableInternal<TInputScope, TCell>>;
466
+ /**
467
+ * Factory for creating new table schema without specifying row schema
468
+ * @internal
469
+ */
470
+ export function createTable<
471
+ const TInputScope extends string | undefined,
472
+ const TCell extends ImplicitAllowedTypes,
473
+ const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
474
+ >(
475
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
476
+ _cellSchema: TCell,
477
+ columnSchema: TColumn,
478
+ ): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;
398
479
  /**
399
480
  * Factory for creating new table schema.
400
- * @privateRemarks TODO: add overloads to make column/row schema optional.
401
481
  * @internal
402
482
  */
403
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
404
483
  export function createTable<
405
484
  const TInputScope extends string | undefined,
406
485
  const TCell extends ImplicitAllowedTypes,
407
- const TColumn extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,
408
- const TRow extends RowSchemaBase<TInputScope, TCell, TColumn> = RowSchemaBase<
486
+ const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
487
+ const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,
488
+ >(
489
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
490
+ _cellSchema: TCell,
491
+ columnSchema: TColumn,
492
+ rowSchema: TRow,
493
+ ): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;
494
+ /** `createTable` implementation */
495
+ export function createTable<
496
+ const TInputScope extends string | undefined,
497
+ const TCell extends ImplicitAllowedTypes,
498
+ const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
499
+ const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,
500
+ >(
501
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
502
+ _cellSchema: TCell,
503
+ columnSchema?: TColumn,
504
+ rowSchema?: TRow,
505
+ ): TreeNodeSchema {
506
+ const column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);
507
+ return createTableInternal(
508
+ inputSchemaFactory,
509
+ _cellSchema,
510
+ column as TColumn,
511
+ rowSchema ??
512
+ (createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null) as TRow),
513
+ );
514
+ }
515
+
516
+ /**
517
+ * Factory for creating new table schema.
518
+ * @system @internal
519
+ */
520
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
521
+ export function createTableInternal<
522
+ const TInputScope extends string | undefined,
523
+ const TCell extends ImplicitAllowedTypes,
524
+ const TColumn extends ColumnSchemaBase<
525
+ TInputScope,
526
+ ImplicitAllowedTypes
527
+ > = ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
528
+ const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<
409
529
  TInputScope,
410
530
  TCell,
411
- TColumn
531
+ ImplicitAllowedTypes
412
532
  >,
413
533
  >(
414
534
  inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
@@ -467,7 +587,7 @@ export namespace TableSchema {
467
587
  if (row !== undefined) {
468
588
  const column = this.getColumn(columnId);
469
589
  if (column !== undefined) {
470
- return row.getCell(column);
590
+ return row.getCell(column.id);
471
591
  }
472
592
  }
473
593
  // If the cell does not exist return undefined
@@ -520,7 +640,7 @@ export namespace TableSchema {
520
640
  if (row !== undefined) {
521
641
  const column = this.getColumn(columnId);
522
642
  if (column !== undefined) {
523
- row.setCell(column, cell);
643
+ row.setCell(column.id, cell);
524
644
  }
525
645
  }
526
646
  }
@@ -532,22 +652,22 @@ export namespace TableSchema {
532
652
  this.columns.removeAt(index);
533
653
  }
534
654
 
535
- public deleteRows(rows: readonly RowValueType[]): void {
536
- // If there are no rows to delete, do nothing
655
+ public removeRows(rows: readonly RowValueType[]): void {
656
+ // If there are no rows to remove, do nothing
537
657
  if (rows.length === 0) {
538
658
  return;
539
659
  }
540
660
 
541
- // If there is only one row to delete, delete it
661
+ // If there is only one row to remove, remove it
542
662
  if (rows.length === 1) {
543
663
  const index = this.rows.indexOf(rows[0] ?? oob());
544
664
  this.rows.removeAt(index);
545
665
  return;
546
666
  }
547
- // If there are multiple rows to delete, delete them in a transaction
667
+ // If there are multiple rows to remove, remove them in a transaction
548
668
  // This is to avoid the performance issues of deleting multiple rows at once
549
669
  Tree.runTransaction(this, () => {
550
- // Iterate over the rows and delete them
670
+ // Iterate over the rows and remove them
551
671
  for (const row of rows) {
552
672
  const index = this.rows.indexOf(row);
553
673
  this.rows.removeAt(index);
@@ -555,17 +675,17 @@ export namespace TableSchema {
555
675
  });
556
676
  }
557
677
 
558
- public deleteAllRows(): void {
678
+ public removeAllRows(): void {
559
679
  this.rows.removeRange();
560
680
  }
561
681
 
562
- public deleteCell(key: CellKey): void {
682
+ public removeCell(key: CellKey): void {
563
683
  const { columnId, rowId } = key;
564
684
  const row = this.getRow(rowId);
565
685
  if (row !== undefined) {
566
686
  const column = this.getColumn(columnId);
567
687
  if (column !== undefined) {
568
- row.deleteCell(column);
688
+ row.removeCell(column.id);
569
689
  }
570
690
  }
571
691
  }
@@ -601,8 +721,15 @@ export namespace TableSchema {
601
721
  export type TableSchemaBase<
602
722
  TScope extends string | undefined,
603
723
  TCell extends ImplicitAllowedTypes,
604
- TColumn extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,
605
- TRow extends RowSchemaBase<TScope, TCell, TColumn> = RowSchemaBase<TScope, TCell, TColumn>,
724
+ TColumn extends ColumnSchemaBase<TScope, ImplicitAllowedTypes> = ColumnSchemaBase<
725
+ TScope,
726
+ ImplicitAllowedTypes
727
+ >,
728
+ TRow extends RowSchemaBase<TScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<
729
+ TScope,
730
+ TCell,
731
+ ImplicitAllowedTypes
732
+ >,
606
733
  > = ReturnType<typeof createTable<TScope, TCell, TColumn, TRow>>;
607
734
 
608
735
  // #endregion
@@ -8,27 +8,170 @@ import type {
8
8
  IChannelFactory,
9
9
  IFluidDataStoreRuntime,
10
10
  IChannelServices,
11
+ IChannelStorageService,
11
12
  } from "@fluidframework/datastore-definitions/internal";
13
+ import type {
14
+ ITelemetryContext,
15
+ IExperimentalIncrementalSummaryContext,
16
+ ISummaryTreeWithStats,
17
+ IRuntimeMessageCollection,
18
+ } from "@fluidframework/runtime-definitions/internal";
19
+
20
+ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
12
21
  import type { SharedObjectKind } from "@fluidframework/shared-object-base";
13
22
  import {
23
+ type IFluidSerializer,
24
+ type ISharedObject,
14
25
  type ISharedObjectKind,
26
+ SharedObject,
15
27
  createSharedObjectKind,
16
28
  } from "@fluidframework/shared-object-base/internal";
17
29
 
18
- import {
19
- SharedTree as SharedTreeImpl,
20
- type ISharedTree,
21
- type SharedTreeOptions,
22
- type SharedTreeOptionsInternal,
30
+ import type {
31
+ SchematizingSimpleTreeView,
32
+ SharedTreeContentSnapshot,
33
+ SharedTreeOptions,
34
+ SharedTreeOptionsInternal,
35
+ SharedTreeEditBuilder,
36
+ SharedTreeChange,
37
+ ITreePrivate,
23
38
  } from "./shared-tree/index.js";
24
- import type { ITree } from "./simple-tree/index.js";
25
-
39
+ import type {
40
+ ImplicitFieldSchema,
41
+ ITree,
42
+ ReadSchema,
43
+ SimpleTreeSchema,
44
+ TreeView,
45
+ TreeViewConfiguration,
46
+ UnsafeUnknownSchema,
47
+ VerboseTree,
48
+ } from "./simple-tree/index.js";
26
49
  import { SharedTreeFactoryType, SharedTreeAttributes } from "./sharedTreeAttributes.js";
50
+ import { Breakable } from "./util/index.js";
51
+ import { SharedTreeKernel } from "./shared-tree/index.js";
52
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
53
+ import { fail } from "@fluidframework/core-utils/internal";
54
+ import type { SharedTreeCore } from "./shared-tree-core/index.js";
55
+
56
+ /**
57
+ * {@link ITreePrivate} extended with ISharedObject.
58
+ * @remarks
59
+ * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.
60
+ */
61
+ export interface ISharedTree extends ISharedObject, ITreePrivate {}
62
+
63
+ /**
64
+ * Shared object wrapping {@link SharedTreeKernel}.
65
+ */
66
+ class SharedTreeImpl extends SharedObject implements ISharedTree {
67
+ private readonly breaker: Breakable = new Breakable("Shared Tree");
68
+
69
+ public readonly kernel: SharedTreeKernel;
70
+
71
+ public constructor(
72
+ id: string,
73
+ runtime: IFluidDataStoreRuntime,
74
+ attributes: IChannelAttributes,
75
+ optionsParam: SharedTreeOptionsInternal,
76
+ telemetryContextPrefix: string = "fluid_sharedTree_",
77
+ ) {
78
+ super(id, runtime, attributes, telemetryContextPrefix);
79
+ if (runtime.idCompressor === undefined) {
80
+ throw new UsageError("IdCompressor must be enabled to use SharedTree");
81
+ }
82
+ this.kernel = new SharedTreeKernel(
83
+ this.breaker,
84
+ this,
85
+ this.serializer,
86
+ (content, localOpMetadata) => this.submitLocalMessage(content, localOpMetadata),
87
+ () => this.deltaManager.lastSequenceNumber,
88
+ this.logger,
89
+ runtime.idCompressor,
90
+ optionsParam,
91
+ );
92
+ }
93
+
94
+ public summarizeCore(
95
+ serializer: IFluidSerializer,
96
+ telemetryContext?: ITelemetryContext,
97
+ incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
98
+ ): ISummaryTreeWithStats {
99
+ return this.kernel.summarizeCore(serializer, telemetryContext, incrementalSummaryContext);
100
+ }
101
+
102
+ protected processCore(
103
+ message: ISequencedDocumentMessage,
104
+ local: boolean,
105
+ localOpMetadata: unknown,
106
+ ): void {
107
+ fail(0xb75 /* processCore should not be called on SharedTree */);
108
+ }
109
+
110
+ protected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {
111
+ this.kernel.processMessagesCore(messagesCollection);
112
+ }
113
+
114
+ protected onDisconnect(): void {
115
+ this.kernel.onDisconnect();
116
+ }
117
+
118
+ public exportVerbose(): VerboseTree | undefined {
119
+ return this.kernel.exportVerbose();
120
+ }
121
+
122
+ public exportSimpleSchema(): SimpleTreeSchema {
123
+ return this.kernel.exportSimpleSchema();
124
+ }
125
+
126
+ public contentSnapshot(): SharedTreeContentSnapshot {
127
+ return this.kernel.contentSnapshot();
128
+ }
129
+
130
+ // For the new TreeViewAlpha API
131
+ public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
132
+ config: TreeViewConfiguration<ReadSchema<TRoot>>,
133
+ ): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>>;
134
+
135
+ // For the old TreeView API
136
+ public viewWith<TRoot extends ImplicitFieldSchema>(
137
+ config: TreeViewConfiguration<TRoot>,
138
+ ): SchematizingSimpleTreeView<TRoot> & TreeView<TRoot>;
139
+
140
+ public viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(
141
+ config: TreeViewConfiguration<ReadSchema<TRoot>>,
142
+ ): SchematizingSimpleTreeView<TRoot> & TreeView<ReadSchema<TRoot>> {
143
+ return this.kernel.viewWith(config);
144
+ }
145
+
146
+ protected override async loadCore(services: IChannelStorageService): Promise<void> {
147
+ await this.kernel.loadCore(services);
148
+ }
149
+
150
+ protected override didAttach(): void {
151
+ this.kernel.didAttach();
152
+ }
153
+
154
+ protected override applyStashedOp(
155
+ ...args: Parameters<
156
+ SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["applyStashedOp"]
157
+ >
158
+ ): void {
159
+ this.kernel.applyStashedOp(...args);
160
+ }
161
+
162
+ protected override reSubmitCore(
163
+ ...args: Parameters<
164
+ SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>["reSubmitCore"]
165
+ >
166
+ ): void {
167
+ this.kernel.reSubmitCore(...args);
168
+ }
169
+ }
27
170
 
28
171
  /**
29
172
  * A channel factory that creates an {@link ITree}.
30
173
  */
31
- export class TreeFactory implements IChannelFactory<ISharedTree> {
174
+ class TreeFactory implements IChannelFactory<ISharedTree> {
32
175
  public static Type: string = SharedTreeFactoryType;
33
176
  public readonly type: string = SharedTreeFactoryType;
34
177