@fluidframework/tree 2.33.2 → 2.40.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 (621) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/CHANGELOG.md +64 -0
  3. package/api-report/tree.alpha.api.md +124 -51
  4. package/api-report/tree.beta.api.md +31 -27
  5. package/api-report/tree.legacy.alpha.api.md +24 -23
  6. package/api-report/tree.legacy.public.api.md +24 -23
  7. package/api-report/tree.public.api.md +24 -23
  8. package/dist/alpha.d.ts +17 -1
  9. package/dist/beta.d.ts +2 -0
  10. package/dist/codec/codec.d.ts +5 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +6 -2
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +2 -1
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/core/index.d.ts +2 -2
  19. package/dist/core/index.d.ts.map +1 -1
  20. package/dist/core/index.js +2 -3
  21. package/dist/core/index.js.map +1 -1
  22. package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  23. package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
  24. package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
  25. package/dist/core/schema-stored/formatV1.js.map +1 -0
  26. package/dist/core/schema-stored/index.d.ts +3 -3
  27. package/dist/core/schema-stored/index.d.ts.map +1 -1
  28. package/dist/core/schema-stored/index.js +3 -3
  29. package/dist/core/schema-stored/index.js.map +1 -1
  30. package/dist/core/schema-stored/schema.d.ts +3 -1
  31. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  32. package/dist/core/schema-stored/schema.js +8 -6
  33. package/dist/core/schema-stored/schema.js.map +1 -1
  34. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  35. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  36. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  37. package/dist/core/schema-view/index.d.ts +1 -1
  38. package/dist/core/schema-view/index.d.ts.map +1 -1
  39. package/dist/core/schema-view/index.js +1 -2
  40. package/dist/core/schema-view/index.js.map +1 -1
  41. package/dist/core/schema-view/view.d.ts +0 -27
  42. package/dist/core/schema-view/view.d.ts.map +1 -1
  43. package/dist/core/schema-view/view.js +1 -35
  44. package/dist/core/schema-view/view.js.map +1 -1
  45. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  46. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  47. package/dist/core/tree/persistedTreeTextFormat.js +1 -1
  48. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  49. package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
  50. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  51. package/dist/feature-libraries/forest-summary/format.js +1 -1
  52. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  53. package/dist/feature-libraries/index.d.ts +1 -1
  54. package/dist/feature-libraries/index.d.ts.map +1 -1
  55. package/dist/feature-libraries/index.js +4 -2
  56. package/dist/feature-libraries/index.js.map +1 -1
  57. package/dist/feature-libraries/mapTreeCursor.d.ts +3 -3
  58. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  59. package/dist/feature-libraries/mapTreeCursor.js +2 -2
  60. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  61. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  62. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  63. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
  64. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  65. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  66. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  67. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
  68. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  69. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  70. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  71. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  72. package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
  73. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  74. package/dist/feature-libraries/schema-index/codec.js +63 -9
  75. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  76. package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  77. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  78. package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
  79. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
  80. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  81. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  82. package/dist/feature-libraries/schema-index/index.js +6 -3
  83. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  84. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  85. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  86. package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
  87. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  88. package/dist/index.d.ts +3 -2
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +10 -8
  91. package/dist/index.js.map +1 -1
  92. package/dist/internalTypes.d.ts +0 -1
  93. package/dist/internalTypes.d.ts.map +1 -1
  94. package/dist/internalTypes.js.map +1 -1
  95. package/dist/jsonDomainSchema.d.ts +2 -2
  96. package/dist/jsonDomainSchema.js +2 -2
  97. package/dist/jsonDomainSchema.js.map +1 -1
  98. package/dist/legacy.d.ts +2 -0
  99. package/dist/packageVersion.d.ts +1 -1
  100. package/dist/packageVersion.js +1 -1
  101. package/dist/packageVersion.js.map +1 -1
  102. package/dist/public.d.ts +2 -0
  103. package/dist/serializableDomainSchema.d.ts +3 -3
  104. package/dist/serializableDomainSchema.js +2 -2
  105. package/dist/serializableDomainSchema.js.map +1 -1
  106. package/dist/shared-tree/independentView.d.ts +1 -1
  107. package/dist/shared-tree/independentView.d.ts.map +1 -1
  108. package/dist/shared-tree/independentView.js +1 -1
  109. package/dist/shared-tree/independentView.js.map +1 -1
  110. package/dist/shared-tree/index.d.ts +4 -3
  111. package/dist/shared-tree/index.d.ts.map +1 -1
  112. package/dist/shared-tree/index.js +6 -5
  113. package/dist/shared-tree/index.js.map +1 -1
  114. package/dist/shared-tree/schematizeTree.d.ts +10 -11
  115. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  116. package/dist/shared-tree/schematizeTree.js +11 -36
  117. package/dist/shared-tree/schematizeTree.js.map +1 -1
  118. package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
  119. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  120. package/dist/shared-tree/schematizingTreeView.js +4 -7
  121. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  122. package/dist/shared-tree/sharedTree.d.ts +28 -3
  123. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  124. package/dist/shared-tree/sharedTree.js +29 -3
  125. package/dist/shared-tree/sharedTree.js.map +1 -1
  126. package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
  127. package/dist/shared-tree/tree.d.ts.map +1 -0
  128. package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
  129. package/dist/shared-tree/tree.js.map +1 -0
  130. package/{lib/shared-tree/treeApiAlpha.d.ts → dist/shared-tree/treeAlpha.d.ts} +24 -14
  131. package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
  132. package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +7 -5
  133. package/dist/shared-tree/treeAlpha.js.map +1 -0
  134. package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  135. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  136. package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
  137. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  138. package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
  139. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  140. package/dist/shared-tree-core/transactionEnricher.js +4 -1
  141. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  142. package/dist/simple-tree/api/conciseTree.d.ts +1 -1
  143. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  144. package/dist/simple-tree/api/configuration.d.ts +177 -0
  145. package/dist/simple-tree/api/configuration.d.ts.map +1 -0
  146. package/dist/simple-tree/api/configuration.js +163 -0
  147. package/dist/simple-tree/api/configuration.js.map +1 -0
  148. package/dist/simple-tree/api/getJsonSchema.js +2 -2
  149. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  150. package/dist/simple-tree/api/index.d.ts +9 -5
  151. package/dist/simple-tree/api/index.d.ts.map +1 -1
  152. package/dist/simple-tree/api/index.js +9 -7
  153. package/dist/simple-tree/api/index.js.map +1 -1
  154. package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  155. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  156. package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
  157. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  158. package/dist/simple-tree/api/schemaFactory.d.ts +25 -10
  159. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  160. package/dist/simple-tree/api/schemaFactory.js +27 -12
  161. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  162. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  163. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  164. package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
  165. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  166. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  167. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  168. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  169. package/dist/simple-tree/api/schemaFromSimple.d.ts +1 -1
  170. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  171. package/dist/simple-tree/api/schemaFromSimple.js +1 -1
  172. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  173. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  174. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  175. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  176. package/dist/simple-tree/api/storedSchema.d.ts +11 -10
  177. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  178. package/dist/simple-tree/api/storedSchema.js +16 -11
  179. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  180. package/dist/simple-tree/api/tree.d.ts +30 -174
  181. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  182. package/dist/simple-tree/api/tree.js +1 -156
  183. package/dist/simple-tree/api/tree.js.map +1 -1
  184. package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +17 -6
  185. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
  186. package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  187. package/dist/simple-tree/api/treeBeta.js.map +1 -0
  188. package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
  189. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  190. package/dist/simple-tree/api/treeChangeEvents.js +7 -0
  191. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
  192. package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
  193. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  194. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  195. package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
  196. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  197. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  198. package/dist/simple-tree/arrayNode.d.ts +30 -2
  199. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  200. package/dist/simple-tree/arrayNode.js +3 -2
  201. package/dist/simple-tree/arrayNode.js.map +1 -1
  202. package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
  203. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  204. package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
  205. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  206. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  207. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  208. package/dist/simple-tree/core/index.d.ts +2 -1
  209. package/dist/simple-tree/core/index.d.ts.map +1 -1
  210. package/dist/simple-tree/core/index.js +5 -5
  211. package/dist/simple-tree/core/index.js.map +1 -1
  212. package/dist/simple-tree/core/treeNode.d.ts +94 -0
  213. package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
  214. package/dist/simple-tree/core/treeNode.js +123 -0
  215. package/dist/simple-tree/core/treeNode.js.map +1 -0
  216. package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
  217. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  218. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  219. package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
  220. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  221. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  222. package/dist/simple-tree/core/types.d.ts +0 -165
  223. package/dist/simple-tree/core/types.d.ts.map +1 -1
  224. package/dist/simple-tree/core/types.js +1 -113
  225. package/dist/simple-tree/core/types.js.map +1 -1
  226. package/dist/simple-tree/core/withType.d.ts +1 -1
  227. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  228. package/dist/simple-tree/core/withType.js.map +1 -1
  229. package/dist/simple-tree/index.d.ts +4 -4
  230. package/dist/simple-tree/index.d.ts.map +1 -1
  231. package/dist/simple-tree/index.js +4 -3
  232. package/dist/simple-tree/index.js.map +1 -1
  233. package/dist/simple-tree/mapNode.d.ts +2 -2
  234. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  235. package/dist/simple-tree/mapNode.js +1 -1
  236. package/dist/simple-tree/mapNode.js.map +1 -1
  237. package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
  238. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
  239. package/dist/simple-tree/mapNodeTypes.js.map +1 -1
  240. package/dist/simple-tree/objectNode.d.ts +18 -5
  241. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  242. package/dist/simple-tree/objectNode.js +4 -3
  243. package/dist/simple-tree/objectNode.js.map +1 -1
  244. package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
  245. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  246. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  247. package/dist/simple-tree/schemaTypes.d.ts +164 -13
  248. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  249. package/dist/simple-tree/schemaTypes.js +107 -8
  250. package/dist/simple-tree/schemaTypes.js.map +1 -1
  251. package/dist/simple-tree/toStoredSchema.d.ts +8 -8
  252. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  253. package/dist/simple-tree/toStoredSchema.js +27 -32
  254. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  255. package/dist/simple-tree/treeNodeValid.js +2 -2
  256. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  257. package/dist/tableSchema.d.ts +455 -125
  258. package/dist/tableSchema.d.ts.map +1 -1
  259. package/dist/tableSchema.js +398 -101
  260. package/dist/tableSchema.js.map +1 -1
  261. package/dist/treeFactory.d.ts +1 -1
  262. package/dist/treeFactory.d.ts.map +1 -1
  263. package/dist/treeFactory.js +30 -75
  264. package/dist/treeFactory.js.map +1 -1
  265. package/dist/util/typeUtils.d.ts +1 -1
  266. package/dist/util/typeUtils.js.map +1 -1
  267. package/lib/alpha.d.ts +17 -1
  268. package/lib/beta.d.ts +2 -0
  269. package/lib/codec/codec.d.ts +5 -1
  270. package/lib/codec/codec.d.ts.map +1 -1
  271. package/lib/codec/codec.js +5 -1
  272. package/lib/codec/codec.js.map +1 -1
  273. package/lib/codec/index.d.ts +1 -1
  274. package/lib/codec/index.d.ts.map +1 -1
  275. package/lib/codec/index.js +1 -1
  276. package/lib/codec/index.js.map +1 -1
  277. package/lib/core/index.d.ts +2 -2
  278. package/lib/core/index.d.ts.map +1 -1
  279. package/lib/core/index.js +2 -2
  280. package/lib/core/index.js.map +1 -1
  281. package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  282. package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
  283. package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
  284. package/lib/core/schema-stored/formatV1.js.map +1 -0
  285. package/lib/core/schema-stored/index.d.ts +3 -3
  286. package/lib/core/schema-stored/index.d.ts.map +1 -1
  287. package/lib/core/schema-stored/index.js +2 -2
  288. package/lib/core/schema-stored/index.js.map +1 -1
  289. package/lib/core/schema-stored/schema.d.ts +3 -1
  290. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  291. package/lib/core/schema-stored/schema.js +3 -1
  292. package/lib/core/schema-stored/schema.js.map +1 -1
  293. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  294. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  295. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  296. package/lib/core/schema-view/index.d.ts +1 -1
  297. package/lib/core/schema-view/index.d.ts.map +1 -1
  298. package/lib/core/schema-view/index.js +1 -1
  299. package/lib/core/schema-view/index.js.map +1 -1
  300. package/lib/core/schema-view/view.d.ts +0 -27
  301. package/lib/core/schema-view/view.d.ts.map +1 -1
  302. package/lib/core/schema-view/view.js +0 -34
  303. package/lib/core/schema-view/view.js.map +1 -1
  304. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  305. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  306. package/lib/core/tree/persistedTreeTextFormat.js +2 -2
  307. package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
  308. package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
  309. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  310. package/lib/feature-libraries/forest-summary/format.js +2 -2
  311. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  312. package/lib/feature-libraries/index.d.ts +1 -1
  313. package/lib/feature-libraries/index.d.ts.map +1 -1
  314. package/lib/feature-libraries/index.js +1 -1
  315. package/lib/feature-libraries/index.js.map +1 -1
  316. package/lib/feature-libraries/mapTreeCursor.d.ts +3 -3
  317. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  318. package/lib/feature-libraries/mapTreeCursor.js +2 -2
  319. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  320. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  321. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  322. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
  323. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  324. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  325. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  326. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
  327. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  328. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  329. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  330. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  331. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  332. package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
  333. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  334. package/lib/feature-libraries/schema-index/codec.js +61 -9
  335. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  336. package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  337. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  338. package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
  339. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
  340. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  341. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  342. package/lib/feature-libraries/schema-index/index.js +2 -2
  343. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  344. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  345. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  346. package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
  347. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  348. package/lib/index.d.ts +3 -2
  349. package/lib/index.d.ts.map +1 -1
  350. package/lib/index.js +1 -0
  351. package/lib/index.js.map +1 -1
  352. package/lib/internalTypes.d.ts +0 -1
  353. package/lib/internalTypes.d.ts.map +1 -1
  354. package/lib/internalTypes.js.map +1 -1
  355. package/lib/jsonDomainSchema.d.ts +2 -2
  356. package/lib/jsonDomainSchema.js +2 -2
  357. package/lib/jsonDomainSchema.js.map +1 -1
  358. package/lib/legacy.d.ts +2 -0
  359. package/lib/packageVersion.d.ts +1 -1
  360. package/lib/packageVersion.js +1 -1
  361. package/lib/packageVersion.js.map +1 -1
  362. package/lib/public.d.ts +2 -0
  363. package/lib/serializableDomainSchema.d.ts +3 -3
  364. package/lib/serializableDomainSchema.js +2 -2
  365. package/lib/serializableDomainSchema.js.map +1 -1
  366. package/lib/shared-tree/independentView.d.ts +1 -1
  367. package/lib/shared-tree/independentView.d.ts.map +1 -1
  368. package/lib/shared-tree/independentView.js +2 -2
  369. package/lib/shared-tree/independentView.js.map +1 -1
  370. package/lib/shared-tree/index.d.ts +4 -3
  371. package/lib/shared-tree/index.d.ts.map +1 -1
  372. package/lib/shared-tree/index.js +3 -3
  373. package/lib/shared-tree/index.js.map +1 -1
  374. package/lib/shared-tree/schematizeTree.d.ts +10 -11
  375. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  376. package/lib/shared-tree/schematizeTree.js +12 -37
  377. package/lib/shared-tree/schematizeTree.js.map +1 -1
  378. package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
  379. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  380. package/lib/shared-tree/schematizingTreeView.js +6 -9
  381. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  382. package/lib/shared-tree/sharedTree.d.ts +28 -3
  383. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  384. package/lib/shared-tree/sharedTree.js +29 -4
  385. package/lib/shared-tree/sharedTree.js.map +1 -1
  386. package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
  387. package/lib/shared-tree/tree.d.ts.map +1 -0
  388. package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
  389. package/lib/shared-tree/tree.js.map +1 -0
  390. package/{dist/shared-tree/treeApiAlpha.d.ts → lib/shared-tree/treeAlpha.d.ts} +24 -14
  391. package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
  392. package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +8 -6
  393. package/lib/shared-tree/treeAlpha.js.map +1 -0
  394. package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  395. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  396. package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
  397. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  398. package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
  399. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  400. package/lib/shared-tree-core/transactionEnricher.js +4 -1
  401. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  402. package/lib/simple-tree/api/conciseTree.d.ts +1 -1
  403. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  404. package/lib/simple-tree/api/configuration.d.ts +177 -0
  405. package/lib/simple-tree/api/configuration.d.ts.map +1 -0
  406. package/lib/simple-tree/api/configuration.js +157 -0
  407. package/lib/simple-tree/api/configuration.js.map +1 -0
  408. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  409. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  410. package/lib/simple-tree/api/index.d.ts +9 -5
  411. package/lib/simple-tree/api/index.d.ts.map +1 -1
  412. package/lib/simple-tree/api/index.js +5 -4
  413. package/lib/simple-tree/api/index.js.map +1 -1
  414. package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  415. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  416. package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
  417. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  418. package/lib/simple-tree/api/schemaFactory.d.ts +25 -10
  419. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  420. package/lib/simple-tree/api/schemaFactory.js +27 -12
  421. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  422. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  423. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  424. package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
  425. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  426. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  427. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  428. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  429. package/lib/simple-tree/api/schemaFromSimple.d.ts +1 -1
  430. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  431. package/lib/simple-tree/api/schemaFromSimple.js +1 -1
  432. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  433. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  434. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  435. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  436. package/lib/simple-tree/api/storedSchema.d.ts +11 -10
  437. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  438. package/lib/simple-tree/api/storedSchema.js +20 -13
  439. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  440. package/lib/simple-tree/api/tree.d.ts +30 -174
  441. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  442. package/lib/simple-tree/api/tree.js +0 -152
  443. package/lib/simple-tree/api/tree.js.map +1 -1
  444. package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +17 -6
  445. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
  446. package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  447. package/lib/simple-tree/api/treeBeta.js.map +1 -0
  448. package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
  449. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  450. package/lib/simple-tree/api/treeChangeEvents.js +6 -0
  451. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
  452. package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
  453. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  454. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  455. package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
  456. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  457. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  458. package/lib/simple-tree/arrayNode.d.ts +30 -2
  459. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  460. package/lib/simple-tree/arrayNode.js +4 -3
  461. package/lib/simple-tree/arrayNode.js.map +1 -1
  462. package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
  463. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  464. package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
  465. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  466. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  467. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  468. package/lib/simple-tree/core/index.d.ts +2 -1
  469. package/lib/simple-tree/core/index.d.ts.map +1 -1
  470. package/lib/simple-tree/core/index.js +1 -1
  471. package/lib/simple-tree/core/index.js.map +1 -1
  472. package/lib/simple-tree/core/treeNode.d.ts +94 -0
  473. package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
  474. package/lib/simple-tree/core/treeNode.js +118 -0
  475. package/lib/simple-tree/core/treeNode.js.map +1 -0
  476. package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
  477. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  478. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  479. package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
  480. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  481. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  482. package/lib/simple-tree/core/types.d.ts +0 -165
  483. package/lib/simple-tree/core/types.d.ts.map +1 -1
  484. package/lib/simple-tree/core/types.js +0 -110
  485. package/lib/simple-tree/core/types.js.map +1 -1
  486. package/lib/simple-tree/core/withType.d.ts +1 -1
  487. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  488. package/lib/simple-tree/core/withType.js.map +1 -1
  489. package/lib/simple-tree/index.d.ts +4 -4
  490. package/lib/simple-tree/index.d.ts.map +1 -1
  491. package/lib/simple-tree/index.js +1 -1
  492. package/lib/simple-tree/index.js.map +1 -1
  493. package/lib/simple-tree/mapNode.d.ts +2 -2
  494. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  495. package/lib/simple-tree/mapNode.js +2 -2
  496. package/lib/simple-tree/mapNode.js.map +1 -1
  497. package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
  498. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
  499. package/lib/simple-tree/mapNodeTypes.js.map +1 -1
  500. package/lib/simple-tree/objectNode.d.ts +18 -5
  501. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  502. package/lib/simple-tree/objectNode.js +5 -4
  503. package/lib/simple-tree/objectNode.js.map +1 -1
  504. package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
  505. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  506. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  507. package/lib/simple-tree/schemaTypes.d.ts +164 -13
  508. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  509. package/lib/simple-tree/schemaTypes.js +96 -8
  510. package/lib/simple-tree/schemaTypes.js.map +1 -1
  511. package/lib/simple-tree/toStoredSchema.d.ts +8 -8
  512. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  513. package/lib/simple-tree/toStoredSchema.js +26 -31
  514. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  515. package/lib/simple-tree/treeNodeValid.js +2 -2
  516. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  517. package/lib/tableSchema.d.ts +455 -125
  518. package/lib/tableSchema.d.ts.map +1 -1
  519. package/lib/tableSchema.js +398 -101
  520. package/lib/tableSchema.js.map +1 -1
  521. package/lib/treeFactory.d.ts +1 -1
  522. package/lib/treeFactory.d.ts.map +1 -1
  523. package/lib/treeFactory.js +30 -75
  524. package/lib/treeFactory.js.map +1 -1
  525. package/lib/util/typeUtils.d.ts +1 -1
  526. package/lib/util/typeUtils.js.map +1 -1
  527. package/package.json +21 -21
  528. package/src/codec/codec.ts +6 -1
  529. package/src/codec/index.ts +1 -0
  530. package/src/core/index.ts +1 -2
  531. package/src/core/schema-stored/index.ts +3 -3
  532. package/src/core/schema-stored/schema.ts +3 -1
  533. package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
  534. package/src/core/schema-view/index.ts +0 -1
  535. package/src/core/schema-view/view.ts +0 -31
  536. package/src/core/tree/persistedTreeTextFormat.ts +2 -2
  537. package/src/feature-libraries/forest-summary/format.ts +2 -2
  538. package/src/feature-libraries/index.ts +7 -1
  539. package/src/feature-libraries/mapTreeCursor.ts +3 -3
  540. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
  541. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
  542. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
  543. package/src/feature-libraries/schema-index/codec.ts +80 -12
  544. package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
  545. package/src/feature-libraries/schema-index/index.ts +7 -2
  546. package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
  547. package/src/index.ts +18 -1
  548. package/src/internalTypes.ts +0 -2
  549. package/src/jsonDomainSchema.ts +2 -2
  550. package/src/packageVersion.ts +1 -1
  551. package/src/serializableDomainSchema.ts +3 -3
  552. package/src/shared-tree/independentView.ts +4 -3
  553. package/src/shared-tree/index.ts +5 -6
  554. package/src/shared-tree/schematizeTree.ts +10 -40
  555. package/src/shared-tree/schematizingTreeView.ts +12 -17
  556. package/src/shared-tree/sharedTree.ts +67 -6
  557. package/src/shared-tree/{treeApi.ts → tree.ts} +75 -51
  558. package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +28 -16
  559. package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
  560. package/src/shared-tree-core/transactionEnricher.ts +4 -1
  561. package/src/simple-tree/api/conciseTree.ts +1 -1
  562. package/src/simple-tree/api/configuration.ts +353 -0
  563. package/src/simple-tree/api/getJsonSchema.ts +1 -1
  564. package/src/simple-tree/api/index.ts +23 -15
  565. package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
  566. package/src/simple-tree/api/schemaFactory.ts +139 -19
  567. package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
  568. package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
  569. package/src/simple-tree/api/schemaFromSimple.ts +2 -2
  570. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  571. package/src/simple-tree/api/storedSchema.ts +32 -17
  572. package/src/simple-tree/api/tree.ts +38 -354
  573. package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +20 -6
  574. package/src/simple-tree/api/treeChangeEvents.ts +84 -0
  575. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  576. package/src/simple-tree/api/typesUnsafe.ts +15 -11
  577. package/src/simple-tree/arrayNode.ts +38 -5
  578. package/src/simple-tree/arrayNodeTypes.ts +8 -7
  579. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  580. package/src/simple-tree/core/index.ts +5 -4
  581. package/src/simple-tree/core/treeNode.ts +163 -0
  582. package/src/simple-tree/core/treeNodeKernel.ts +2 -1
  583. package/src/simple-tree/core/treeNodeSchema.ts +3 -1
  584. package/src/simple-tree/core/types.ts +0 -234
  585. package/src/simple-tree/core/withType.ts +1 -1
  586. package/src/simple-tree/index.ts +19 -2
  587. package/src/simple-tree/mapNode.ts +11 -3
  588. package/src/simple-tree/mapNodeTypes.ts +10 -7
  589. package/src/simple-tree/objectNode.ts +39 -15
  590. package/src/simple-tree/objectNodeTypes.ts +9 -5
  591. package/src/simple-tree/schemaTypes.ts +354 -25
  592. package/src/simple-tree/toStoredSchema.ts +42 -41
  593. package/src/simple-tree/treeNodeValid.ts +2 -2
  594. package/src/tableSchema.ts +1206 -434
  595. package/src/treeFactory.ts +56 -173
  596. package/src/util/typeUtils.ts +1 -1
  597. package/dist/core/schema-stored/format.d.ts.map +0 -1
  598. package/dist/core/schema-stored/format.js.map +0 -1
  599. package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
  600. package/dist/feature-libraries/schema-index/format.js.map +0 -1
  601. package/dist/shared-tree/treeApi.d.ts.map +0 -1
  602. package/dist/shared-tree/treeApi.js.map +0 -1
  603. package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
  604. package/dist/shared-tree/treeApiAlpha.js.map +0 -1
  605. package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  606. package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
  607. package/dist/simple-tree/api/view.d.ts.map +0 -1
  608. package/dist/simple-tree/api/view.js.map +0 -1
  609. package/lib/core/schema-stored/format.d.ts.map +0 -1
  610. package/lib/core/schema-stored/format.js.map +0 -1
  611. package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
  612. package/lib/feature-libraries/schema-index/format.js.map +0 -1
  613. package/lib/shared-tree/treeApi.d.ts.map +0 -1
  614. package/lib/shared-tree/treeApi.js.map +0 -1
  615. package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
  616. package/lib/shared-tree/treeApiAlpha.js.map +0 -1
  617. package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  618. package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
  619. package/lib/simple-tree/api/view.d.ts.map +0 -1
  620. package/lib/simple-tree/api/view.js.map +0 -1
  621. /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
@@ -3,6 +3,39 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type ImplicitFieldSchema, type TreeNode, type TreeNodeApi, type TreeView, rollback, type TransactionConstraint } from "../simple-tree/index.js";
6
+ /**
7
+ * Provides various functions for interacting with {@link TreeNode}s.
8
+ * @remarks
9
+ * This type should only be used via the {@link (Tree:variable)} export.
10
+ * @system @sealed @public
11
+ */
12
+ export interface Tree extends TreeNodeApi {
13
+ /**
14
+ * Run a {@link RunTransaction | transaction}.
15
+ */
16
+ readonly runTransaction: RunTransaction;
17
+ /**
18
+ * Check if the subtree defined by `node` contains `other`.
19
+ *
20
+ * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.
21
+ * @remarks
22
+ * This includes direct and indirect children:
23
+ * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.
24
+ *
25
+ * `node` is considered to contain itself, so the case where `node === other` returns true.
26
+ *
27
+ * This is handy when checking if moving `node` into `other` would create a cycle and would thus be invalid.
28
+ *
29
+ * This check walks the parents of `other` looking for `node`,
30
+ * and thus runs in time proportional to the depth of child in the tree.
31
+ */
32
+ contains(node: TreeNode, other: TreeNode): boolean;
33
+ }
34
+ /**
35
+ * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.
36
+ * @public
37
+ */
38
+ export declare const Tree: Tree;
6
39
  /**
7
40
  * A function which runs a transaction in a SharedTree.
8
41
  * @privateRemarks
@@ -26,7 +59,9 @@ export interface RunTransaction {
26
59
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
27
60
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
28
61
  * However, using a transaction has the following additional consequences:
62
+ *
29
63
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
64
+ *
30
65
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
31
66
  *
32
67
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -44,7 +79,9 @@ export interface RunTransaction {
44
79
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
45
80
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
46
81
  * However, using a transaction has the following additional consequences:
82
+ *
47
83
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
84
+ *
48
85
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
49
86
  *
50
87
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -64,7 +101,9 @@ export interface RunTransaction {
64
101
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
65
102
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
66
103
  * However, using a transaction has the following additional consequences:
104
+ *
67
105
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
106
+ *
68
107
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
69
108
  *
70
109
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -83,7 +122,9 @@ export interface RunTransaction {
83
122
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
84
123
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
85
124
  * However, using a transaction has the following additional consequences:
125
+ *
86
126
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
127
+ *
87
128
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
88
129
  *
89
130
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -101,7 +142,9 @@ export interface RunTransaction {
101
142
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
102
143
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
103
144
  * However, using a transaction has the following additional consequences:
145
+ *
104
146
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
147
+ *
105
148
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
106
149
  *
107
150
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -118,7 +161,9 @@ export interface RunTransaction {
118
161
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
119
162
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
120
163
  * However, using a transaction has the following additional consequences:
164
+ *
121
165
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
166
+ *
122
167
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
123
168
  *
124
169
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -140,7 +185,9 @@ export interface RunTransaction {
140
185
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
141
186
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
142
187
  * However, using a transaction has the following additional consequences:
188
+ *
143
189
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
190
+ *
144
191
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
145
192
  *
146
193
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -161,7 +208,9 @@ export interface RunTransaction {
161
208
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
162
209
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
163
210
  * However, using a transaction has the following additional consequences:
211
+ *
164
212
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
213
+ *
165
214
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
166
215
  *
167
216
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -184,7 +233,9 @@ export interface RunTransaction {
184
233
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
185
234
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
186
235
  * However, using a transaction has the following additional consequences:
236
+ *
187
237
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
238
+ *
188
239
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
189
240
  *
190
241
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -206,7 +257,9 @@ export interface RunTransaction {
206
257
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
207
258
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
208
259
  * However, using a transaction has the following additional consequences:
260
+ *
209
261
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
262
+ *
210
263
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
211
264
  *
212
265
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -227,7 +280,9 @@ export interface RunTransaction {
227
280
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
228
281
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
229
282
  * However, using a transaction has the following additional consequences:
283
+ *
230
284
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
285
+ *
231
286
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
232
287
  *
233
288
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -247,7 +302,9 @@ export interface RunTransaction {
247
302
  * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
248
303
  * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
249
304
  * However, using a transaction has the following additional consequences:
305
+ *
250
306
  * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
307
+ *
251
308
  * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
252
309
  *
253
310
  * Local change events will be emitted for each change as the transaction is being applied.
@@ -256,39 +313,6 @@ export interface RunTransaction {
256
313
  */
257
314
  <TView extends TreeView<any>>(tree: TView, transaction: (root: TView["root"]) => void, preconditions?: readonly TransactionConstraint[]): void;
258
315
  }
259
- /**
260
- * Provides various functions for interacting with {@link TreeNode}s.
261
- * @remarks
262
- * This type should only be used via the public `Tree` export.
263
- * @system @sealed @public
264
- */
265
- export interface TreeApi extends TreeNodeApi {
266
- /**
267
- * Run a {@link RunTransaction | transaction}.
268
- */
269
- readonly runTransaction: RunTransaction;
270
- /**
271
- * Check if the subtree defined by `node` contains `other`.
272
- *
273
- * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.
274
- * @remarks
275
- * This includes direct and indirect children:
276
- * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.
277
- *
278
- * `node` is considered to contain itself, so the case where `node === other` returns true.
279
- *
280
- * This is handy when checking if moving `node` into `other` would create a cycle and thus is invalid.
281
- *
282
- * This check walks the parents of `other` looking for `node`,
283
- * and thus runs in time proportional to the depth of child in the tree.
284
- */
285
- contains(node: TreeNode, other: TreeNode): boolean;
286
- }
287
- /**
288
- * The `Tree` object holds various functions for interacting with {@link TreeNode}s.
289
- * @public
290
- */
291
- export declare const treeApi: TreeApi;
292
316
  /**
293
317
  * Run the given transaction.
294
318
  * @remarks
@@ -296,4 +320,4 @@ export declare const treeApi: TreeApi;
296
320
  * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.
297
321
  */
298
322
  export declare function runTransaction<TNode extends TreeNode, TRoot extends ImplicitFieldSchema, TResult>(treeOrNode: TNode | TreeView<TRoot>, transaction: ((node: TNode) => TResult | typeof rollback) | ((root: TRoot) => TResult | typeof rollback), preconditions?: readonly TransactionConstraint[]): TResult | typeof rollback;
299
- //# sourceMappingURL=treeApi.d.ts.map
323
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KA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AAC,KAAK,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EACpC,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,OAAO,GAAG,OAAO,QAAQ,EAC/D,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAC9C,OAAO,GAAG,OAAO,QAAQ,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,CAAC,KAAK,SAAS,QAAQ,EACtB,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,EAClC,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAC9C,IAAI,CAAC;IACR;;;;;;;;;;;;;;;;;;;;OAoBG;IAGH,CAAC,KAAK,SAAS,QAAQ,CAAC,GAAG,CAAC,EAC3B,IAAI,EAAE,KAAK,EACX,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAC1C,aAAa,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAC9C,IAAI,CAAC;CACR;AAiBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,KAAK,SAAS,QAAQ,EACtB,KAAK,SAAS,mBAAmB,EACjC,OAAO,EAEP,UAAU,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EACnC,WAAW,EACR,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,OAAO,QAAQ,CAAC,GAC5C,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,OAAO,QAAQ,CAAC,EAC/C,aAAa,GAAE,SAAS,qBAAqB,EAAO,GAClD,OAAO,GAAG,OAAO,QAAQ,CAoB3B"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.runTransaction = exports.treeApi = void 0;
7
+ exports.runTransaction = exports.Tree = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
10
  const index_js_1 = require("../feature-libraries/index.js");
@@ -12,10 +12,10 @@ const index_js_2 = require("../simple-tree/index.js");
12
12
  const schematizingTreeView_js_1 = require("./schematizingTreeView.js");
13
13
  const checkoutFlexTreeView_js_1 = require("./checkoutFlexTreeView.js");
14
14
  /**
15
- * The `Tree` object holds various functions for interacting with {@link TreeNode}s.
15
+ * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.
16
16
  * @public
17
17
  */
18
- exports.treeApi = {
18
+ exports.Tree = {
19
19
  ...index_js_2.treeNodeApi,
20
20
  runTransaction: createRunTransaction(),
21
21
  contains(parent, child) {
@@ -24,7 +24,7 @@ exports.treeApi = {
24
24
  if (toCheck === parent) {
25
25
  return true;
26
26
  }
27
- toCheck = exports.treeApi.parent(toCheck);
27
+ toCheck = exports.Tree.parent(toCheck);
28
28
  }
29
29
  return false;
30
30
  },
@@ -72,7 +72,7 @@ function runTransactionInCheckout(checkout, transaction, preconditions) {
72
72
  switch (constraint.type) {
73
73
  case "nodeInDocument": {
74
74
  const node = (0, index_js_2.getOrCreateInnerNode)(constraint.node);
75
- const nodeStatus = exports.treeApi.status(constraint.node);
75
+ const nodeStatus = exports.Tree.status(constraint.node);
76
76
  if (nodeStatus !== index_js_1.TreeStatus.InDocument) {
77
77
  throw new internal_2.UsageError(`Attempted to add a "nodeInDocument" constraint, but the node is not currently in the document. Node status: ${nodeStatus}`);
78
78
  }
@@ -102,4 +102,4 @@ function runTransactionInCheckout(checkout, transaction, preconditions) {
102
102
  }
103
103
  return result;
104
104
  }
105
- //# sourceMappingURL=treeApi.js.map
105
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/shared-tree/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kE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E,CAAC;QAChB,qHAAqH;QACrH,kGAAkG;QAClG,uJAAuJ;QACvJ,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC;IACb,CAAC;IAED,IAAI,MAAM,KAAK,mBAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;SAAM,CAAC;QACP,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { TreeStatus } from \"../feature-libraries/index.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype TreeNode,\n\ttype TreeNodeApi,\n\ttype TreeView,\n\tgetOrCreateInnerNode,\n\ttreeNodeApi,\n\trollback,\n\ttype TransactionConstraint,\n} from \"../simple-tree/index.js\";\n\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport type { ITreeCheckout } from \"./treeCheckout.js\";\nimport { getCheckoutFlexTreeView } from \"./checkoutFlexTreeView.js\";\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the {@link (Tree:variable)} export.\n * @system @sealed @public\n */\nexport interface Tree extends TreeNodeApi {\n\t/**\n\t * Run a {@link RunTransaction | transaction}.\n\t */\n\treadonly runTransaction: RunTransaction;\n\t/**\n\t * Check if the subtree defined by `node` contains `other`.\n\t *\n\t * @returns true if `other` is an inclusive descendant of `node`, and false otherwise.\n\t * @remarks\n\t * This includes direct and indirect children:\n\t * as long as `node` is an ancestor of `other` (occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.\n\t *\n\t * `node` is considered to contain itself, so the case where `node === other` returns true.\n\t *\n\t * This is handy when checking if moving `node` into `other` would create a cycle and would thus be invalid.\n\t *\n\t * This check walks the parents of `other` looking for `node`,\n\t * and thus runs in time proportional to the depth of child in the tree.\n\t */\n\tcontains(node: TreeNode, other: TreeNode): boolean;\n}\n\n/**\n * The {@link (Tree:interface)} singleton which holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const Tree: Tree = {\n\t...treeNodeApi,\n\n\trunTransaction: createRunTransaction(),\n\n\tcontains(parent: TreeNode, child: TreeNode): boolean {\n\t\tlet toCheck: TreeNode | undefined = child;\n\t\twhile (toCheck !== undefined) {\n\t\t\tif (toCheck === parent) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ttoCheck = Tree.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A function which runs a transaction in a SharedTree.\n * @privateRemarks\n * This interface exists so that the (generously) overloaded `Tree.runTransaction` function can have the \"rollback\" property hanging off of it.\n * The rollback property being available on the function itself gives users a convenient option for rolling back a transaction without having to import another symbol.\n * @sealed @public\n */\nexport interface RunTransaction {\n\t/**\n\t * The {@link rollback} object used to roll back a transaction.\n\t */\n\treadonly rollback: typeof rollback;\n\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// TODO: TreeView is invariant over the schema, so to accept any view, `any` is the only real option unless a non generic (or covariant) base type for view is introduced (which is planned).\n\t// This use of any is actually type safe as it is only used as a constraint, and the actual strongly typed view (TView) is passed to the callback.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(tree: TView, transaction: (root: TView[\"root\"]) => void): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode, TResult>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * At any point during the transaction, the function may return the special {@link RunTransaction.rollback | rollback value} (`Tree.runTransaction.rollback`) to abort the transaction and discard any changes it made so far.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @returns The value returned by the inner `transaction` function.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back (whether by an error or by returning the {@link RunTransaction.rollback} | rollback value), a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>, TResult>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => TResult | typeof rollback,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): TResult | typeof rollback;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param node - The node that will be passed to `transaction`.\n\t * This is typically the root node of the subtree that will be modified by the transaction.\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the provided `node`.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t<TNode extends TreeNode>(\n\t\tnode: TNode,\n\t\ttransaction: (node: TNode) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n\t/**\n\t * Apply one or more edits to the tree as a single atomic unit.\n\t * @param tree - The tree which will be edited by the transaction\n\t * @param transaction - The function to run as the body of the transaction.\n\t * This function is passed the root of the tree.\n\t * @param preconditions - An optional list of {@link TransactionConstraint | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, it will throw an error.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on this client and ignored by all other clients.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t * However, using a transaction has the following additional consequences:\n\t *\n\t * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t *\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * Local change events will be emitted for each change as the transaction is being applied.\n\t * If the transaction function throws an error then the transaction will be automatically rolled back (discarding any changes made to the tree so far) before the error is propagated up from this function.\n\t * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.\n\t */\n\t// See comment on previous overload about use of any here.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t<TView extends TreeView<any>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n// TODO: Add more constraint types here\n\n/** Creates a copy of `runTransaction` with the `rollback` property added so as to satisfy the `RunTransaction` interface. */\nfunction createRunTransaction(): RunTransaction {\n\t/** A type-safe helper to add a \"rollback\" property (as required by the `RunTransaction` interface) to a given object */\n\tfunction defineRollbackProperty<T extends object>(\n\t\ttarget: T,\n\t): T & { rollback: typeof rollback } {\n\t\tReflect.defineProperty(target, \"rollback\", { value: rollback });\n\t\treturn target as T & { readonly rollback: typeof rollback };\n\t}\n\n\treturn defineRollbackProperty(runTransaction.bind({}));\n}\n\n/**\n * Run the given transaction.\n * @remarks\n * This API is not publicly exported but is exported outside of this module so that test code may unit test the `Tree.runTransaction` function directly without being restricted to its public API overloads.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to edit content in the error case.\n */\nexport function runTransaction<\n\tTNode extends TreeNode,\n\tTRoot extends ImplicitFieldSchema,\n\tTResult,\n>(\n\ttreeOrNode: TNode | TreeView<TRoot>,\n\ttransaction:\n\t\t| ((node: TNode) => TResult | typeof rollback)\n\t\t| ((root: TRoot) => TResult | typeof rollback),\n\tpreconditions: readonly TransactionConstraint[] = [],\n): TResult | typeof rollback {\n\tif (treeOrNode instanceof SchematizingSimpleTreeView) {\n\t\tconst t = transaction as (root: TRoot) => TResult | typeof rollback;\n\t\treturn runTransactionInCheckout(\n\t\t\ttreeOrNode.checkout,\n\t\t\t() => t(treeOrNode.root as TRoot),\n\t\t\tpreconditions,\n\t\t);\n\t} else {\n\t\tconst node = treeOrNode as TNode;\n\t\tconst t = transaction as (node: TNode) => TResult | typeof rollback;\n\t\tconst context = getOrCreateInnerNode(node).context;\n\t\tif (context.isHydrated() === false) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Transactions cannot be run on Unhydrated nodes. Transactions apply to a TreeView and Unhydrated nodes are not part of a TreeView.\",\n\t\t\t);\n\t\t}\n\t\tconst treeView = getCheckoutFlexTreeView(context);\n\t\treturn runTransactionInCheckout(treeView.checkout, () => t(node), preconditions);\n\t}\n}\n\n/**\n * Run the given transaction.\n * @deprecated This API catches exceptions then tries to modify the tree before rethrowing: this is not robust. Use {@link TreeViewAlpha.runTransaction} instead which does not try to editing content in the error case.\n */\nfunction runTransactionInCheckout<TResult>(\n\tcheckout: ITreeCheckout,\n\ttransaction: () => TResult | typeof rollback,\n\tpreconditions: readonly TransactionConstraint[],\n): TResult | typeof rollback {\n\tcheckout.transaction.start();\n\tfor (const constraint of preconditions) {\n\t\tswitch (constraint.type) {\n\t\t\tcase \"nodeInDocument\": {\n\t\t\t\tconst node = getOrCreateInnerNode(constraint.node);\n\t\t\t\tconst nodeStatus = Tree.status(constraint.node);\n\t\t\t\tif (nodeStatus !== TreeStatus.InDocument) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Attempted to add a \"nodeInDocument\" constraint, but the node is not currently in the document. Node status: ${nodeStatus}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcheckout.editor.addNodeExistsConstraint(node.anchorNode);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(constraint.type);\n\t\t}\n\t}\n\n\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (error) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\t// This might try and modify the tree or trigger events while things are in an inconsistent state.\n\t\t// It is up to the user of runTransaction to ensure that does not cause problems (and they have no robust way to do that, which is why its deprecated).\n\t\tcheckout.transaction.abort();\n\t\tthrow error;\n\t}\n\n\tif (result === rollback) {\n\t\tcheckout.transaction.abort();\n\t} else {\n\t\tcheckout.transaction.commit();\n\t}\n\n\treturn result;\n}\n"]}
@@ -8,10 +8,12 @@ import { type TreeNode, type Unhydrated, type ImplicitFieldSchema, type Insertab
8
8
  import type { JsonCompatible } from "../util/index.js";
9
9
  import { type FluidClientVersion, type ICodecOptions } from "../codec/index.js";
10
10
  /**
11
- * Extensions to {@link Tree} and {@link TreeBeta} which are not yet stable.
12
- * @sealed @alpha
11
+ * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.
12
+ * @remarks
13
+ * Use via the {@link (TreeAlpha:variable)} singleton.
14
+ * @system @sealed @alpha
13
15
  */
14
- export declare const TreeAlpha: {
16
+ export interface TreeAlpha {
15
17
  /**
16
18
  * Retrieve the {@link TreeBranch | branch}, if any, for the given node.
17
19
  * @param node - The node to query
@@ -32,13 +34,13 @@ export declare const TreeAlpha: {
32
34
  * 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.
33
35
  *
34
36
  * Like with {@link TreeNodeSchemaClass}'s constructor, it's an error to provide an existing node to this API.
35
- * For that case, use {@link TreeBeta.clone}.
37
+ * For that case, use {@link (TreeBeta:interface).clone}.
36
38
  * @privateRemarks
37
39
  * 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.
38
40
  */
39
41
  create<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: InsertableField<TSchema>): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
40
42
  /**
41
- * Less type safe version of {@link TreeAlpha.create}, suitable for importing data.
43
+ * Less type safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.
42
44
  * @remarks
43
45
  * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.
44
46
  * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.
@@ -46,8 +48,8 @@ export declare const TreeAlpha: {
46
48
  *
47
49
  * When using this function,
48
50
  * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.
49
- * If the schema is ambiguous, consider using {@link TreeAlpha.create} and {@link Unhydrated} nodes where needed,
50
- * or using {@link TreeAlpha.(importVerbose:1)} and specify all types.
51
+ * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,
52
+ * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.
51
53
  *
52
54
  * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,
53
55
  * but for now most invalid inputs will throw a recoverable error.
@@ -56,7 +58,7 @@ export declare const TreeAlpha: {
56
58
  /**
57
59
  * Construct tree content compatible with a field defined by the provided `schema`.
58
60
  * @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.
59
- * @param data - The data used to construct the field content. See {@link TreeAlpha.(exportVerbose:1)}.
61
+ * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.
60
62
  */
61
63
  importVerbose<const TSchema extends ImplicitFieldSchema>(schema: TSchema, data: VerboseTree | undefined, options?: Partial<TreeEncodingOptions>): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
62
64
  /**
@@ -72,7 +74,7 @@ export declare const TreeAlpha: {
72
74
  * Uses the {@link VerboseTree} format, with an explicit type on every node.
73
75
  *
74
76
  * @remarks
75
- * There are several cases this may be preferred to {@link TreeAlpha.(exportConcise:1)}:
77
+ * There are several cases this may be preferred to {@link (TreeAlpha:interface).(exportConcise:1)}:
76
78
  *
77
79
  * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).
78
80
  * `exportVerbose` will always be unambiguous and thus lossless.
@@ -103,11 +105,11 @@ export declare const TreeAlpha: {
103
105
  idCompressor?: IIdCompressor;
104
106
  }): JsonCompatible<IFluidHandle>;
105
107
  /**
106
- * Import data encoded by {@link TreeAlpha.exportCompressed}.
108
+ * Import data encoded by {@link (TreeAlpha:interface).exportCompressed}.
107
109
  *
108
110
  * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.
109
- * @param compressedData - Data compressed by {@link TreeAlpha.exportCompressed}.
110
- * @param options - If {@link TreeAlpha.exportCompressed} was given an `idCompressor`, it must be provided here.
111
+ * @param compressedData - Data compressed by {@link (TreeAlpha:interface).exportCompressed}.
112
+ * @param options - If {@link (TreeAlpha:interface).exportCompressed} was given an `idCompressor`, it must be provided here.
111
113
  *
112
114
  * @remarks
113
115
  * 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}.
@@ -116,11 +118,19 @@ export declare const TreeAlpha: {
116
118
  * This API could be improved:
117
119
  *
118
120
  * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a "try" version).
121
+ *
119
122
  * 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).
123
+ *
120
124
  * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.
121
125
  */
122
126
  importCompressed<const TSchema extends ImplicitFieldSchema>(schema: TSchema, compressedData: JsonCompatible<IFluidHandle>, options: {
123
127
  idCompressor?: IIdCompressor;
124
128
  } & ICodecOptions): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
125
- };
126
- //# sourceMappingURL=treeApiAlpha.d.ts.map
129
+ }
130
+ /**
131
+ * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.
132
+ * @see {@link (TreeAlpha:interface)}.
133
+ * @alpha
134
+ */
135
+ export declare const TreeAlpha: TreeAlpha;
136
+ //# sourceMappingURL=treeAlpha.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeAlpha.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,UAAU,EAQf,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,KAAK,WAAW,EAIhB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAGhB,KAAK,UAAU,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAiB,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAgB/F;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;OAQG;IACH,M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AaG;IACH,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAAC;IAE1F;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CACf,IAAI,EAAE,QAAQ,GAAG,aAAa,EAC9B,OAAO,EAAE;QAAE,sBAAsB,EAAE,kBAAkB,CAAC;QAAC,YAAY,CAAC,EAAE,aAAa,CAAA;KAAE,GACnF,cAAc,CAAC,YAAY,CAAC,CAAC;IAEhC;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACzD,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,cAAc,CAAC,YAAY,CAAC,EAC5C,OAAO,EAAE;QAAE,YAAY,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,aAAa,GACvD,UAAU,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;CACnD;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,SA4GvB,CAAC"}
@@ -13,9 +13,11 @@ const index_js_2 = require("../codec/index.js");
13
13
  const index_js_3 = require("../feature-libraries/index.js");
14
14
  const independentView_js_1 = require("./independentView.js");
15
15
  const schematizingTreeView_js_1 = require("./schematizingTreeView.js");
16
+ const index_js_4 = require("../codec/index.js");
16
17
  /**
17
- * Extensions to {@link Tree} and {@link TreeBeta} which are not yet stable.
18
- * @sealed @alpha
18
+ * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.
19
+ * @see {@link (TreeAlpha:interface)}.
20
+ * @alpha
19
21
  */
20
22
  exports.TreeAlpha = {
21
23
  branch(node) {
@@ -69,12 +71,12 @@ exports.TreeAlpha = {
69
71
  return result;
70
72
  },
71
73
  importCompressed(schema, compressedData, options) {
74
+ const config = new index_js_1.TreeViewConfigurationAlpha({ schema });
72
75
  const content = {
73
- schema: (0, index_js_1.extractPersistedSchema)(schema),
76
+ schema: (0, index_js_1.extractPersistedSchema)(config, index_js_4.currentVersion),
74
77
  tree: compressedData,
75
78
  idCompressor: options.idCompressor ?? (0, internal_2.createIdCompressor)(),
76
79
  };
77
- const config = new index_js_1.TreeViewConfiguration({ schema });
78
80
  const view = (0, independentView_js_1.independentInitializedView)(config, options, content);
79
81
  return index_js_1.TreeBeta.clone(view.root);
80
82
  },
@@ -107,4 +109,4 @@ const versionToFormat = {
107
109
  v2_2: 1,
108
110
  v2_3: 1,
109
111
  };
110
- //# sourceMappingURL=treeApiAlpha.js.map
112
+ //# sourceMappingURL=treeAlpha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeAlpha.js","sourceRoot":"","sources":["../../src/shared-tree/treeAlpha.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,qEAA4E;AAC5E,uEAAsE;AAItE,sDA2BiC;AAEjC,gDAA+F;AAE/F,4DASuC;AACvC,6DAAoF;AACpF,uEAAiF;AACjF,gDAAmD;AA8JnD;;;;GAIG;AACU,QAAA,SAAS,GAAc;IACnC,MAAM,CAAC,IAAc;QACpB,MAAM,MAAM,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,kCAAQ,CAAC,CAAC;QAC7D,IAAA,iBAAM,EACL,IAAI,YAAY,oDAA0B,EAC1C,KAAK,CAAC,oCAAoC,CAC1C,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,EAAE,+BAAoB;IAE5B,aAAa,CACZ,MAEgC,EAChC,IAA6B;QAM7B,OAAO,IAAA,+BAAoB,EAC1B,MAAM,EACN,IAA4C,CAK5C,CAAC;IACH,CAAC;IAED,aAAa,CACZ,MAAe,EACf,IA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nD,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,IAAA,4BAAiB,EACvB,MAAM,EACN,IAAA,uBAAY,EAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,EACrD,MAAM,CACN,CAAC;AACH,CAAC;AAED,SAAS,+BAA+B,CACvC,IAA8B;IAE9B,IAAI,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAA,+BAAoB,EAC1B,IAAA,uBAAY,EAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,oBAAoB,CAAC,EACtD,IAAI,CACJ,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,CAAC;IAC5D,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,oCAAoC,CAC5C,IAA8B;IAE9B,MAAM,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACrD,mBAAmB;IACnB,MAAM,OAAO,GAAG,IAAA,4BAAiB,EAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,IAAA,gCAAqB,EAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,eAAe,GAAG;IACvB,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACP,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { createIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tgetKernel,\n\ttype TreeNode,\n\ttype Unhydrated,\n\tTreeBeta,\n\ttryGetSchema,\n\tcreateFromCursor,\n\tcreateFromInsertable,\n\tcursorFromInsertable,\n\tFieldKind,\n\tnormalizeFieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype InsertableField,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeLeafValue,\n\ttype UnsafeUnknownSchema,\n\tconciseFromCursor,\n\ttype ConciseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\ttoStoredSchema,\n\textractPersistedSchema,\n\ttype TreeBranch,\n\tTreeViewConfigurationAlpha,\n} from \"../simple-tree/index.js\";\nimport type { JsonCompatible } from \"../util/index.js\";\nimport { noopValidator, type FluidClientVersion, type ICodecOptions } from \"../codec/index.js\";\nimport type { ITreeCursorSynchronous } from \"../core/index.js\";\nimport {\n\tcursorForMapTreeField,\n\tdefaultSchemaPolicy,\n\tisTreeValue,\n\tmakeFieldBatchCodec,\n\tmapTreeFromCursor,\n\tTreeCompressionStrategy,\n\ttype FieldBatch,\n\ttype FieldBatchEncodingContext,\n} from \"../feature-libraries/index.js\";\nimport { independentInitializedView, type ViewContent } from \"./independentView.js\";\nimport { SchematizingSimpleTreeView, ViewSlot } from \"./schematizingTreeView.js\";\nimport { currentVersion } from \"../codec/index.js\";\n\n/**\n * Extensions to {@link (Tree:interface)} and {@link (TreeBeta:interface)} which are not yet stable.\n * @remarks\n * Use via the {@link (TreeAlpha:variable)} singleton.\n * @system @sealed @alpha\n */\nexport interface TreeAlpha {\n\t/**\n\t * Retrieve the {@link TreeBranch | branch}, if any, for the given node.\n\t * @param node - The node to query\n\t * @remarks If the node has already been inserted into the tree, this will return the branch associated with that node's {@link TreeView | view}.\n\t * Otherwise, it will return `undefined` (because the node has not yet been inserted and is therefore not part of a branch or view).\n\t *\n\t * This does not fork a new branch, but rather retrieves the _existing_ branch for the node.\n\t * To create a new branch, use e.g. {@link TreeBranch.fork | `myBranch.fork()`}.\n\t */\n\tbranch(node: TreeNode): TreeBranch | undefined;\n\n\t/**\n\t * Construct tree content that is compatible with the field defined by the provided `schema`.\n\t * @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.\n\t * @param data - The data used to construct the field content.\n\t * @remarks\n\t * When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.\n\t * This function exists as a generalization that can be used in other cases as well,\n\t * 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.\n\t *\n\t * Like with {@link TreeNodeSchemaClass}'s constructor, it's an error to provide an existing node to this API.\n\t * For that case, use {@link (TreeBeta:interface).clone}.\n\t * @privateRemarks\n\t * 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.\n\t */\n\tcreate<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: InsertableField<TSchema>,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Less type safe version of {@link (TreeAlpha:interface).create}, suitable for importing data.\n\t * @remarks\n\t * Due to {@link ConciseTree} relying on type inference from the data, its use is somewhat limited.\n\t * This does not support {@link ConciseTree|ConciseTrees} with customized handle encodings or using persisted keys.\n\t * Use \"compressed\" or \"verbose\" formats for more flexibility.\n\t *\n\t * When using this function,\n\t * it is recommend to ensure your schema is unambiguous with {@link ITreeConfigurationOptions.preventAmbiguity}.\n\t * If the schema is ambiguous, consider using {@link (TreeAlpha:interface).create} and {@link Unhydrated} nodes where needed,\n\t * or using {@link (TreeAlpha:interface).(importVerbose:1)} and specify all types.\n\t *\n\t * Documented (and thus recoverable) error handling/reporting for this is not yet implemented,\n\t * but for now most invalid inputs will throw a recoverable error.\n\t */\n\timportConcise<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t>;\n\n\t/**\n\t * Construct tree content compatible with a field defined by the provided `schema`.\n\t * @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.\n\t * @param data - The data used to construct the field content. See {@link (TreeAlpha:interface).(exportVerbose:1)}.\n\t */\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: Partial<TreeEncodingOptions>,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.\n\t */\n\texportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.\n\t */\n\texportConcise(\n\t\tnode: TreeNode | TreeLeafValue | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): ConciseTree | undefined;\n\n\t/**\n\t * Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for {@link @fluidframework/core-interfaces#IFluidHandle|IFluidHandles}).\n\t * Uses the {@link VerboseTree} format, with an explicit type on every node.\n\t *\n\t * @remarks\n\t * There are several cases this may be preferred to {@link (TreeAlpha:interface).(exportConcise:1)}:\n\t *\n\t * 1. When not using {@link ITreeConfigurationOptions.preventAmbiguity} (or when using `useStableFieldKeys`), `exportConcise` can produce ambiguous data (the type may be unclear on some nodes).\n\t * `exportVerbose` will always be unambiguous and thus lossless.\n\t *\n\t * 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.\n\t *\n\t * 3. When easy access to the type is desired.\n\t */\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree;\n\n\t/**\n\t * Export the content of the provided `tree` in a compressed JSON compatible format.\n\t * @remarks\n\t * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.\n\t *\n\t * Always uses \"stored\" keys.\n\t * See {@link TreeEncodingOptions.useStoredKeys} for details.\n\t * @privateRemarks\n\t * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.\n\t * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,\n\t * Nor get the correct idCompressor from a subtree to use when exporting it.\n\t * Additionally using `createIdCompressor` to make an idCompressor is `@legacy` and thus not intended for use in this API surface.\n\t * It would probably make more sense if we provided a way to get an idCompressor from the context of a node,\n\t * which could be optional (and settable if missing) for un0hydrated nodes and required for hydrated ones.\n\t * 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.\n\t */\n\texportCompressed(\n\t\ttree: TreeNode | TreeLeafValue,\n\t\toptions: { oldestCompatibleClient: FluidClientVersion; idCompressor?: IIdCompressor },\n\t): JsonCompatible<IFluidHandle>;\n\n\t/**\n\t * Import data encoded by {@link (TreeAlpha:interface).exportCompressed}.\n\t *\n\t * @param schema - Schema with which the data must be compatible. This compatibility is not verified and must be ensured by the caller.\n\t * @param compressedData - Data compressed by {@link (TreeAlpha:interface).exportCompressed}.\n\t * @param options - If {@link (TreeAlpha:interface).exportCompressed} was given an `idCompressor`, it must be provided here.\n\t *\n\t * @remarks\n\t * 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}.\n\t *\n\t * @privateRemarks\n\t * This API could be improved:\n\t *\n\t * 1. It could validate that the schema is compatible, and return or throw an error in the invalid case (maybe add a \"try\" version).\n\t *\n\t * 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).\n\t *\n\t * 3. Requiring the caller provide a JsonValidator isn't the most friendly API. It might be practical to provide a default.\n\t */\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: { idCompressor?: IIdCompressor } & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n}\n\n/**\n * Extensions to {@link (Tree:variable)} and {@link (TreeBeta:variable)} which are not yet stable.\n * @see {@link (TreeAlpha:interface)}.\n * @alpha\n */\nexport const TreeAlpha: TreeAlpha = {\n\tbranch(node: TreeNode): TreeBranch | undefined {\n\t\tconst kernel = getKernel(node);\n\t\tif (!kernel.isHydrated()) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);\n\t\tassert(\n\t\t\tview instanceof SchematizingSimpleTreeView,\n\t\t\t0xa5c /* Unexpected view implementation */,\n\t\t);\n\t\treturn view;\n\t},\n\n\tcreate: createFromInsertable,\n\n\timportConcise<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tschema: UnsafeUnknownSchema extends TSchema\n\t\t\t? ImplicitFieldSchema\n\t\t\t: TSchema & ImplicitFieldSchema,\n\t\tdata: ConciseTree | undefined,\n\t): Unhydrated<\n\t\tTSchema extends ImplicitFieldSchema\n\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined\n\t> {\n\t\treturn createFromInsertable<UnsafeUnknownSchema>(\n\t\t\tschema,\n\t\t\tdata as InsertableField<UnsafeUnknownSchema>,\n\t\t) as Unhydrated<\n\t\t\tTSchema extends ImplicitFieldSchema\n\t\t\t\t? TreeFieldFromImplicitField<TSchema>\n\t\t\t\t: TreeNode | TreeLeafValue | undefined\n\t\t>;\n\t},\n\n\timportVerbose<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tdata: VerboseTree | undefined,\n\t\toptions?: TreeEncodingOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\t\t// Create a config which is standalone, and thus can be used without having to refer back to the schema.\n\t\tconst schemalessConfig = applySchemaToParserOptions(schema, config);\n\t\tif (data === undefined) {\n\t\t\tconst field = normalizeFieldSchema(schema);\n\t\t\tif (field.kind !== FieldKind.Optional) {\n\t\t\t\tthrow new UsageError(\"undefined provided for non-optional field.\");\n\t\t\t}\n\t\t\treturn undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;\n\t\t}\n\t\tconst cursor = cursorFromVerbose(data, schemalessConfig);\n\t\treturn createFromCursor(schema, cursor);\n\t},\n\n\texportConcise,\n\n\texportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree {\n\t\tconst config: TreeEncodingOptions = { ...options };\n\n\t\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t\treturn verboseFromCursor(\n\t\t\tcursor,\n\t\t\ttryGetSchema(node) ?? fail(0xace /* invalid input */),\n\t\t\tconfig,\n\t\t);\n\t},\n\n\texportCompressed(\n\t\tnode: TreeNode | TreeLeafValue,\n\t\toptions: {\n\t\t\toldestCompatibleClient: FluidClientVersion;\n\t\t\tidCompressor?: IIdCompressor;\n\t\t},\n\t): JsonCompatible<IFluidHandle> {\n\t\tconst schema = tryGetSchema(node) ?? fail(0xacf /* invalid input */);\n\t\tconst format = versionToFormat[options.oldestCompatibleClient];\n\t\tconst codec = makeFieldBatchCodec({ jsonValidator: noopValidator }, format);\n\t\tconst cursor = borrowFieldCursorFromTreeNodeOrValue(node);\n\t\tconst batch: FieldBatch = [cursor];\n\t\t// If none provided, create a compressor which will not compress anything.\n\t\tconst idCompressor = options.idCompressor ?? createIdCompressor();\n\t\tconst context: FieldBatchEncodingContext = {\n\t\t\tencodeType: TreeCompressionStrategy.Compressed,\n\t\t\tidCompressor,\n\t\t\toriginatorId: idCompressor.localSessionId, // TODO: Why is this needed?\n\t\t\tschema: { schema: toStoredSchema(schema), policy: defaultSchemaPolicy },\n\t\t};\n\t\tconst result = codec.encode(batch, context);\n\t\treturn result;\n\t},\n\n\timportCompressed<const TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t\tcompressedData: JsonCompatible<IFluidHandle>,\n\t\toptions: {\n\t\t\tidCompressor?: IIdCompressor;\n\t\t} & ICodecOptions,\n\t): Unhydrated<TreeFieldFromImplicitField<TSchema>> {\n\t\tconst config = new TreeViewConfigurationAlpha({ schema });\n\t\tconst content: ViewContent = {\n\t\t\tschema: extractPersistedSchema(config, currentVersion),\n\t\t\ttree: compressedData,\n\t\t\tidCompressor: options.idCompressor ?? createIdCompressor(),\n\t\t};\n\t\tconst view = independentInitializedView(config, options, content);\n\t\treturn TreeBeta.clone<TSchema>(view.root);\n\t},\n};\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue,\n\toptions?: TreeEncodingOptions,\n): ConciseTree;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined;\n\nfunction exportConcise(\n\tnode: TreeNode | TreeLeafValue | undefined,\n\toptions?: TreeEncodingOptions,\n): ConciseTree | undefined {\n\tif (node === undefined) {\n\t\treturn undefined;\n\t}\n\tconst config: TreeEncodingOptions = { ...options };\n\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\treturn conciseFromCursor(\n\t\tcursor,\n\t\ttryGetSchema(node) ?? fail(0xacd /* invalid input */),\n\t\tconfig,\n\t);\n}\n\nfunction borrowCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tif (isTreeValue(node)) {\n\t\treturn cursorFromInsertable<UnsafeUnknownSchema>(\n\t\t\ttryGetSchema(node) ?? fail(0xad0 /* missing schema */),\n\t\t\tnode,\n\t\t);\n\t}\n\tconst kernel = getKernel(node);\n\tconst cursor = kernel.getOrCreateInnerNode().borrowCursor();\n\treturn cursor;\n}\n\nfunction borrowFieldCursorFromTreeNodeOrValue(\n\tnode: TreeNode | TreeLeafValue,\n): ITreeCursorSynchronous {\n\tconst cursor = borrowCursorFromTreeNodeOrValue(node);\n\t// TODO: avoid copy\n\tconst mapTree = mapTreeFromCursor(cursor);\n\treturn cursorForMapTreeField([mapTree]);\n}\n\nconst versionToFormat = {\n\tv2_0: 1,\n\tv2_1: 1,\n\tv2_2: 1,\n\tv2_3: 1,\n};\n"]}
@@ -14,7 +14,6 @@ export declare class BranchCommitEnricher<TChange> {
14
14
  /**
15
15
  * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.
16
16
  * @param change - The change to process.
17
- * @param isAttached - Whether or not the SharedTree is attached to the service.
18
17
  */
19
18
  processChange(change: SharedTreeBranchChange<TChange>): void;
20
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"branchCommitEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;GAEG;AACH,qBAAa,oBAAoB,CAAC,OAAO;;gBAoBvC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAMlD;;;;OAIG;IACI,aAAa,CAAC,MAAM,EAAE,sBAAsB,CAAC,OAAO,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@ class BranchCommitEnricher {
47
47
  /**
48
48
  * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.
49
49
  * @param change - The change to process.
50
- * @param isAttached - Whether or not the SharedTree is attached to the service.
51
50
  */
52
51
  processChange(change) {
53
52
  if (change.type === "append") {
@@ -1 +1 @@
1
- {"version":3,"file":"branchCommitEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAA6D;AAC7D,+CAK0B;AAE1B,qEAA+D;AAG/D;;GAEG;AACH,MAAa,oBAAoB;IAmBhC,YACC,OAA+B,EAC/B,QAAiD;QApBzC,4DAAmD;QACnD,iDAAmD;QAC5D;;;;;;WAMG;QACM,gDAAwE,IAAI,GAAG,EAAE,EAAC;QAE3F;;;;WAIG;QACH,kEAAgE;QAM/D,uBAAA,IAAI,kCAAa,QAAQ,MAAA,CAAC;QAC1B,uBAAA,IAAI,6CAAwB,IAAI,4CAAmB,CAAC,OAAO,EAAE,uBAAA,IAAI,sCAAU,CAAC,MAAA,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,MAAuC;QAC3D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC3C,MAAM,SAAS,GACd,uBAAA,IAAI,uDAA2B,EAAE,KAAjC,IAAI,EAA8B,SAAS,CAAC,QAAQ,CAAC;oBACrD,uBAAA,IAAI,sCAAU,CAAC,uBAAuB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAE9E,uBAAA,IAAI,6CAAiB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAA,wBAAa,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;QAED,uBAAA,IAAI,mDAA8B,SAAS,MAAA,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAA4B;QACzC,MAAM,QAAQ,GAAG,uBAAA,IAAI,6CAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnD,IAAA,iBAAM,EAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3D,uBAAA,IAAI,6CAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,uBAAA,IAAI,mDAA8B,uBAAA,IAAI,iDAAqB,CAAC,iBAAiB,EAAE,MAAA,CAAC;IACjF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,UAA0C;QACtE,IAAA,iBAAM,EAAC,uBAAA,IAAI,iDAAqB,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAClF,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAqB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;CACD;AA7FD,oDA6FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ChangeRebaser,\n\ttype GraphCommit,\n\treplaceChange,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\nimport { TransactionEnricher } from \"./transactionEnricher.js\";\nimport type { SharedTreeBranchChange } from \"./branch.js\";\n\n/**\n * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.\n */\nexport class BranchCommitEnricher<TChange> {\n\treadonly #transactionEnricher: TransactionEnricher<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t/**\n\t * Maps each local commit to the corresponding enriched commit.\n\t * @remarks\n\t * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.\n\t * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.\n\t * In the event that an entry is not explicitly removed, it will eventually be {@link WeakMap | dropped from memory} along with the associated commit.\n\t */\n\treadonly #preparedCommits: WeakMap<GraphCommit<TChange>, GraphCommit<TChange>> = new Map();\n\n\t/**\n\t * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.\n\t * Calling this function will compute the composition of that transaction's commits.\n\t * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.\n\t */\n\t#getOuterTransactionChange?: (revision: RevisionTag) => TChange;\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#enricher = enricher;\n\t\tthis.#transactionEnricher = new TransactionEnricher(rebaser, this.#enricher);\n\t}\n\n\t/**\n\t * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.\n\t * @param change - The change to process.\n\t * @param isAttached - Whether or not the SharedTree is attached to the service.\n\t */\n\tpublic processChange(change: SharedTreeBranchChange<TChange>): void {\n\t\tif (change.type === \"append\") {\n\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\tconst newChange =\n\t\t\t\t\tthis.#getOuterTransactionChange?.(newCommit.revision) ??\n\t\t\t\t\tthis.#enricher.updateChangeEnrichments(newCommit.change, newCommit.revision);\n\n\t\t\t\tthis.#preparedCommits.set(newCommit, replaceChange(newCommit, newChange));\n\t\t\t}\n\t\t}\n\n\t\tthis.#getOuterTransactionChange = undefined;\n\t}\n\n\t/**\n\t * Retrieves the enriched version of the given commit.\n\t * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.\n\t * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.\n\t */\n\tpublic enrich(commit: GraphCommit<TChange>): GraphCommit<TChange> {\n\t\tconst prepared = this.#preparedCommits.get(commit);\n\t\tassert(prepared !== undefined, 0x980 /* Unknown commit */);\n\t\tthis.#preparedCommits.delete(commit);\n\t\treturn prepared;\n\t}\n\n\t/**\n\t * Notify the enricher that a new transaction has started.\n\t * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing \"nested transactions\".\n\t */\n\tpublic startTransaction(): void {\n\t\tthis.#transactionEnricher.startTransaction();\n\t}\n\n\t/**\n\t * Commit the current transaction.\n\t * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.\n\t */\n\tpublic commitTransaction(): void {\n\t\tthis.#getOuterTransactionChange = this.#transactionEnricher.commitTransaction();\n\t}\n\n\t/**\n\t * Notify the enricher that the current transaction has been aborted.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic abortTransaction(): void {\n\t\tthis.#transactionEnricher.abortTransaction();\n\t}\n\n\t/**\n\t * Add new transaction commits to the current transaction.\n\t * @param newCommits - The new commits to add.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic addTransactionCommits(newCommits: Iterable<GraphCommit<TChange>>): void {\n\t\tassert(this.#transactionEnricher.isTransacting(), 0xa97 /* Not in transaction */);\n\t\tfor (const commit of newCommits) {\n\t\t\tthis.#transactionEnricher.addTransactionStep(commit);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"branchCommitEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAA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jB,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,uBAAA,IAAI,mDAA8B,uBAAA,IAAI,iDAAqB,CAAC,iBAAiB,EAAE,MAAA,CAAC;IACjF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,UAA0C;QACtE,IAAA,iBAAM,EAAC,uBAAA,IAAI,iDAAqB,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAClF,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAqB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;CACD;AA5FD,oDA4FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ChangeRebaser,\n\ttype GraphCommit,\n\treplaceChange,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\nimport { TransactionEnricher } from \"./transactionEnricher.js\";\nimport type { SharedTreeBranchChange } from \"./branch.js\";\n\n/**\n * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.\n */\nexport class BranchCommitEnricher<TChange> {\n\treadonly #transactionEnricher: TransactionEnricher<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t/**\n\t * Maps each local commit to the corresponding enriched commit.\n\t * @remarks\n\t * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.\n\t * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.\n\t * In the event that an entry is not explicitly removed, it will eventually be {@link WeakMap | dropped from memory} along with the associated commit.\n\t */\n\treadonly #preparedCommits: WeakMap<GraphCommit<TChange>, GraphCommit<TChange>> = new Map();\n\n\t/**\n\t * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.\n\t * Calling this function will compute the composition of that transaction's commits.\n\t * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.\n\t */\n\t#getOuterTransactionChange?: (revision: RevisionTag) => TChange;\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#enricher = enricher;\n\t\tthis.#transactionEnricher = new TransactionEnricher(rebaser, this.#enricher);\n\t}\n\n\t/**\n\t * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.\n\t * @param change - The change to process.\n\t */\n\tpublic processChange(change: SharedTreeBranchChange<TChange>): void {\n\t\tif (change.type === \"append\") {\n\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\tconst newChange =\n\t\t\t\t\tthis.#getOuterTransactionChange?.(newCommit.revision) ??\n\t\t\t\t\tthis.#enricher.updateChangeEnrichments(newCommit.change, newCommit.revision);\n\n\t\t\t\tthis.#preparedCommits.set(newCommit, replaceChange(newCommit, newChange));\n\t\t\t}\n\t\t}\n\n\t\tthis.#getOuterTransactionChange = undefined;\n\t}\n\n\t/**\n\t * Retrieves the enriched version of the given commit.\n\t * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.\n\t * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.\n\t */\n\tpublic enrich(commit: GraphCommit<TChange>): GraphCommit<TChange> {\n\t\tconst prepared = this.#preparedCommits.get(commit);\n\t\tassert(prepared !== undefined, 0x980 /* Unknown commit */);\n\t\tthis.#preparedCommits.delete(commit);\n\t\treturn prepared;\n\t}\n\n\t/**\n\t * Notify the enricher that a new transaction has started.\n\t * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing \"nested transactions\".\n\t */\n\tpublic startTransaction(): void {\n\t\tthis.#transactionEnricher.startTransaction();\n\t}\n\n\t/**\n\t * Commit the current transaction.\n\t * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.\n\t */\n\tpublic commitTransaction(): void {\n\t\tthis.#getOuterTransactionChange = this.#transactionEnricher.commitTransaction();\n\t}\n\n\t/**\n\t * Notify the enricher that the current transaction has been aborted.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic abortTransaction(): void {\n\t\tthis.#transactionEnricher.abortTransaction();\n\t}\n\n\t/**\n\t * Add new transaction commits to the current transaction.\n\t * @param newCommits - The new commits to add.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic addTransactionCommits(newCommits: Iterable<GraphCommit<TChange>>): void {\n\t\tassert(this.#transactionEnricher.isTransacting(), 0xa97 /* Not in transaction */);\n\t\tfor (const commit of newCommits) {\n\t\t\tthis.#transactionEnricher.addTransactionStep(commit);\n\t\t}\n\t}\n}\n"]}
@@ -14,7 +14,7 @@ export declare class TransactionEnricher<TChange> {
14
14
  startTransaction(): void;
15
15
  /**
16
16
  * Commits the current transaction.
17
- * @returns If and only if the closed transaction was the outermost transaction, returns a function which can be used to compute the composed change for that transaction's commits.
17
+ * @returns A function which can be used to compute the composed change for that transaction's commits. Undefined if the transaction is still ongoing or contained no committed changes.
18
18
  */
19
19
  commitTransaction(): ((revision: RevisionTag) => TChange) | undefined;
20
20
  abortTransaction(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transactionEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E;;GAEG;AACH,qBAAa,mBAAmB,CAAC,OAAO;;gBAatC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAM3C,aAAa,IAAI,OAAO;IAIxB,gBAAgB,IAAI,IAAI;IAI/B;;;OAGG;IACI,iBAAiB,IAAI,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,SAAS;IAWrE,gBAAgB,IAAI,IAAI;IAMxB,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;CAQ7D"}
1
+ {"version":3,"file":"transactionEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/transactionEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E;;GAEG;AACH,qBAAa,mBAAmB,CAAC,OAAO;;gBAatC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAM3C,aAAa,IAAI,OAAO;IAIxB,gBAAgB,IAAI,IAAI;IAI/B;;;OAGG;IACI,iBAAiB,IAAI,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,SAAS;IAcrE,gBAAgB,IAAI,IAAI;IAMxB,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;CAQ7D"}