@fluidframework/tree 2.3.0-288113 → 2.3.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 (869) hide show
  1. package/.dependency-cruiser-known-violations.json +28 -40
  2. package/.vscode/Tree.code-workspace +0 -2
  3. package/CHANGELOG.md +92 -0
  4. package/README.md +6 -0
  5. package/alpha.d.ts +11 -0
  6. package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
  7. package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
  8. package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
  9. package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
  10. package/api-extractor/api-extractor.current.json +8 -0
  11. package/api-extractor/api-extractor.legacy.json +4 -0
  12. package/api-extractor.json +1 -1
  13. package/api-report/tree.alpha.api.md +21 -42
  14. package/api-report/tree.beta.api.md +21 -11
  15. package/api-report/tree.legacy.alpha.api.md +562 -0
  16. package/api-report/tree.legacy.public.api.md +559 -0
  17. package/api-report/tree.public.api.md +8 -13
  18. package/dist/alpha.d.ts +102 -0
  19. package/dist/beta.d.ts +6 -2
  20. package/dist/core/index.d.ts +1 -1
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +2 -2
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
  25. package/dist/core/revertible.d.ts.map +1 -0
  26. package/dist/core/revertible.js.map +1 -0
  27. package/dist/core/schema-stored/format.d.ts +3 -3
  28. package/dist/core/schema-stored/format.js +1 -1
  29. package/dist/core/schema-stored/format.js.map +1 -1
  30. package/dist/core/schema-stored/schema.d.ts +2 -7
  31. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  32. package/dist/core/schema-stored/schema.js +4 -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/tree/anchorSet.d.ts.map +1 -1
  37. package/dist/core/tree/anchorSet.js +6 -2
  38. package/dist/core/tree/anchorSet.js.map +1 -1
  39. package/dist/core/tree/detachedFieldIndex.d.ts +0 -1
  40. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  41. package/dist/core/tree/detachedFieldIndex.js +1 -0
  42. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  43. package/dist/core/tree/visitDelta.d.ts +7 -2
  44. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  45. package/dist/core/tree/visitDelta.js.map +1 -1
  46. package/dist/events/emitter.d.ts +127 -0
  47. package/dist/events/emitter.d.ts.map +1 -0
  48. package/dist/events/{events.js → emitter.js} +48 -30
  49. package/dist/events/emitter.js.map +1 -0
  50. package/dist/events/index.d.ts +2 -1
  51. package/dist/events/index.d.ts.map +1 -1
  52. package/dist/events/index.js +4 -5
  53. package/dist/events/index.js.map +1 -1
  54. package/dist/events/interop.d.ts +36 -0
  55. package/dist/events/interop.d.ts.map +1 -0
  56. package/dist/{core/revertible/index.d.ts → events/interop.js} +3 -2
  57. package/dist/events/interop.js.map +1 -0
  58. package/dist/events/listeners.d.ts +65 -0
  59. package/dist/events/listeners.d.ts.map +1 -0
  60. package/{lib/core/revertible/index.d.ts → dist/events/listeners.js} +3 -2
  61. package/dist/events/listeners.js.map +1 -0
  62. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
  63. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/chunkTree.js +36 -15
  65. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
  67. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/chunkedForest.js +12 -5
  69. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
  71. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/uniformChunk.js +28 -2
  73. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  74. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
  75. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  76. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
  77. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  78. package/dist/feature-libraries/flex-map-tree/index.d.ts +1 -1
  79. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  80. package/dist/feature-libraries/flex-map-tree/index.js +2 -1
  81. package/dist/feature-libraries/flex-map-tree/index.js.map +1 -1
  82. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
  83. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  84. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +82 -103
  85. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  86. package/dist/feature-libraries/flex-tree/context.d.ts +30 -14
  87. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  88. package/dist/feature-libraries/flex-tree/context.js +10 -7
  89. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  90. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
  91. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  92. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +15 -3
  93. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  94. package/dist/feature-libraries/flex-tree/index.d.ts +2 -3
  95. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  96. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  97. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
  98. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  99. package/dist/feature-libraries/flex-tree/lazyEntity.js +2 -10
  100. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  101. package/dist/feature-libraries/flex-tree/lazyField.d.ts +26 -28
  102. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  103. package/dist/feature-libraries/flex-tree/lazyField.js +11 -14
  104. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  105. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
  106. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  107. package/dist/feature-libraries/flex-tree/lazyNode.js +23 -74
  108. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  109. package/dist/feature-libraries/flex-tree/unboxed.d.ts +4 -16
  110. package/dist/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
  111. package/dist/feature-libraries/flex-tree/unboxed.js +7 -41
  112. package/dist/feature-libraries/flex-tree/unboxed.js.map +1 -1
  113. package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -2
  114. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  115. package/dist/feature-libraries/flex-tree/utilities.js +3 -6
  116. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  117. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  118. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -1
  119. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  120. package/dist/feature-libraries/index.d.ts +3 -5
  121. package/dist/feature-libraries/index.d.ts.map +1 -1
  122. package/dist/feature-libraries/index.js +5 -11
  123. package/dist/feature-libraries/index.js.map +1 -1
  124. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  125. package/dist/feature-libraries/modular-schema/comparison.js +3 -6
  126. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  127. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  128. package/dist/feature-libraries/modular-schema/discrepancies.js +3 -13
  129. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  130. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
  131. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -1
  133. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  134. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +12 -5
  135. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  136. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
  137. package/dist/feature-libraries/schema-index/format.d.ts +3 -3
  138. package/dist/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  139. package/dist/feature-libraries/storedToViewSchema.js +2 -4
  140. package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
  141. package/dist/feature-libraries/typed-schema/flexList.d.ts +3 -3
  142. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  143. package/dist/feature-libraries/typed-schema/index.d.ts +2 -2
  144. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  145. package/dist/feature-libraries/typed-schema/index.js +2 -2
  146. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  147. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  148. package/dist/feature-libraries/typed-schema/schemaCollection.js +8 -10
  149. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  150. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
  151. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  152. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +5 -37
  153. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  154. package/dist/feature-libraries/typed-schema/view.d.ts +4 -6
  155. package/dist/feature-libraries/typed-schema/view.d.ts.map +1 -1
  156. package/dist/feature-libraries/typed-schema/view.js +5 -4
  157. package/dist/feature-libraries/typed-schema/view.js.map +1 -1
  158. package/dist/index.d.ts +4 -4
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +33 -36
  161. package/dist/index.js.map +1 -1
  162. package/dist/legacy.d.ts +83 -0
  163. package/dist/packageVersion.d.ts +1 -1
  164. package/dist/packageVersion.d.ts.map +1 -1
  165. package/dist/packageVersion.js +1 -1
  166. package/dist/packageVersion.js.map +1 -1
  167. package/dist/public.d.ts +0 -1
  168. package/dist/shared-tree/checkoutFlexTreeView.d.ts +53 -0
  169. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
  170. package/dist/shared-tree/{treeView.js → checkoutFlexTreeView.js} +28 -6
  171. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -0
  172. package/dist/shared-tree/index.d.ts +3 -3
  173. package/dist/shared-tree/index.d.ts.map +1 -1
  174. package/dist/shared-tree/index.js +2 -2
  175. package/dist/shared-tree/index.js.map +1 -1
  176. package/dist/shared-tree/schematizeTree.d.ts +15 -4
  177. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  178. package/dist/shared-tree/schematizeTree.js +7 -8
  179. package/dist/shared-tree/schematizeTree.js.map +1 -1
  180. package/dist/shared-tree/schematizingTreeView.d.ts +9 -4
  181. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  182. package/dist/shared-tree/schematizingTreeView.js +25 -12
  183. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  184. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  185. package/dist/shared-tree/sharedTree.js +2 -2
  186. package/dist/shared-tree/sharedTree.js.map +1 -1
  187. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
  188. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  189. package/dist/shared-tree/sharedTreeChangeEnricher.js +6 -2
  190. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  191. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
  192. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  193. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -2
  194. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  195. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
  196. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  197. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  198. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  199. package/dist/shared-tree/treeApi.d.ts +1 -3
  200. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  201. package/dist/shared-tree/treeApi.js +6 -4
  202. package/dist/shared-tree/treeApi.js.map +1 -1
  203. package/dist/shared-tree/treeCheckout.d.ts +2 -13
  204. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  205. package/dist/shared-tree/treeCheckout.js +17 -1
  206. package/dist/shared-tree/treeCheckout.js.map +1 -1
  207. package/dist/shared-tree-core/branch.js +1 -1
  208. package/dist/shared-tree-core/branch.js.map +1 -1
  209. package/dist/simple-tree/api/create.d.ts.map +1 -1
  210. package/dist/simple-tree/api/create.js +1 -1
  211. package/dist/simple-tree/api/create.js.map +1 -1
  212. package/{lib/simple-tree → dist/simple-tree/api}/getJsonSchema.d.ts +1 -1
  213. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -0
  214. package/dist/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
  215. package/dist/simple-tree/api/getJsonSchema.js.map +1 -0
  216. package/{lib/simple-tree → dist/simple-tree/api}/getSimpleSchema.d.ts +1 -1
  217. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
  218. package/dist/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
  219. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -0
  220. package/dist/simple-tree/api/index.d.ts +5 -0
  221. package/dist/simple-tree/api/index.d.ts.map +1 -1
  222. package/dist/simple-tree/api/index.js +7 -1
  223. package/dist/simple-tree/api/index.js.map +1 -1
  224. package/{lib/simple-tree → dist/simple-tree/api}/jsonSchema.d.ts +1 -1
  225. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -0
  226. package/dist/simple-tree/api/jsonSchema.js.map +1 -0
  227. package/dist/simple-tree/api/schemaFactory.d.ts +45 -14
  228. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  229. package/dist/simple-tree/api/schemaFactory.js +43 -12
  230. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  231. package/dist/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +4 -4
  232. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -0
  233. package/dist/simple-tree/api/simpleSchema.js.map +1 -0
  234. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
  235. package/dist/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +4 -4
  236. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
  237. package/dist/simple-tree/api/tree.d.ts +1 -21
  238. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  239. package/dist/simple-tree/api/tree.js +3 -38
  240. package/dist/simple-tree/api/tree.js.map +1 -1
  241. package/dist/simple-tree/api/treeApiBeta.d.ts +79 -0
  242. package/dist/simple-tree/api/treeApiBeta.d.ts.map +1 -0
  243. package/dist/simple-tree/api/treeApiBeta.js +26 -0
  244. package/dist/simple-tree/api/treeApiBeta.js.map +1 -0
  245. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -1
  246. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  247. package/dist/simple-tree/api/treeNodeApi.js +21 -19
  248. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  249. package/dist/simple-tree/api/verboseTree.js +2 -2
  250. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  251. package/dist/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
  252. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
  253. package/dist/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +4 -4
  254. package/{lib/simple-tree → dist/simple-tree/api}/viewSchemaToSimpleSchema.js.map +1 -1
  255. package/dist/simple-tree/arrayNode.d.ts +2 -2
  256. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  257. package/dist/simple-tree/arrayNode.js +30 -21
  258. package/dist/simple-tree/arrayNode.js.map +1 -1
  259. package/dist/simple-tree/core/index.d.ts +3 -3
  260. package/dist/simple-tree/core/index.d.ts.map +1 -1
  261. package/dist/simple-tree/core/index.js +4 -1
  262. package/dist/simple-tree/core/index.js.map +1 -1
  263. package/dist/simple-tree/core/schemaCaching.d.ts +5 -0
  264. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -1
  265. package/dist/simple-tree/core/schemaCaching.js +10 -1
  266. package/dist/simple-tree/core/schemaCaching.js.map +1 -1
  267. package/dist/simple-tree/core/treeNodeKernel.d.ts +61 -3
  268. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  269. package/dist/simple-tree/core/treeNodeKernel.js +166 -13
  270. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  271. package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -1
  272. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  273. package/dist/simple-tree/core/types.d.ts +17 -20
  274. package/dist/simple-tree/core/types.d.ts.map +1 -1
  275. package/dist/simple-tree/core/types.js.map +1 -1
  276. package/dist/simple-tree/core/withType.d.ts +3 -2
  277. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  278. package/dist/simple-tree/core/withType.js.map +1 -1
  279. package/dist/simple-tree/index.d.ts +7 -9
  280. package/dist/simple-tree/index.d.ts.map +1 -1
  281. package/dist/simple-tree/index.js +15 -6
  282. package/dist/simple-tree/index.js.map +1 -1
  283. package/dist/simple-tree/leafNodeSchema.d.ts +7 -9
  284. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  285. package/dist/simple-tree/leafNodeSchema.js +13 -11
  286. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  287. package/dist/simple-tree/mapNode.d.ts +1 -1
  288. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  289. package/dist/simple-tree/mapNode.js +38 -29
  290. package/dist/simple-tree/mapNode.js.map +1 -1
  291. package/dist/simple-tree/objectNode.d.ts +9 -7
  292. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  293. package/dist/simple-tree/objectNode.js +37 -31
  294. package/dist/simple-tree/objectNode.js.map +1 -1
  295. package/dist/simple-tree/proxies.d.ts +1 -14
  296. package/dist/simple-tree/proxies.d.ts.map +1 -1
  297. package/dist/simple-tree/proxies.js +12 -15
  298. package/dist/simple-tree/proxies.js.map +1 -1
  299. package/dist/simple-tree/proxyBinding.d.ts +2 -62
  300. package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
  301. package/dist/simple-tree/proxyBinding.js +8 -181
  302. package/dist/simple-tree/proxyBinding.js.map +1 -1
  303. package/dist/simple-tree/schemaTypes.d.ts +7 -7
  304. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  305. package/dist/simple-tree/schemaTypes.js +4 -4
  306. package/dist/simple-tree/schemaTypes.js.map +1 -1
  307. package/dist/simple-tree/toFlexSchema.d.ts +11 -1
  308. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  309. package/dist/simple-tree/toFlexSchema.js +54 -31
  310. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  311. package/dist/simple-tree/toMapTree.d.ts +25 -37
  312. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  313. package/dist/simple-tree/toMapTree.js +53 -16
  314. package/dist/simple-tree/toMapTree.js.map +1 -1
  315. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  316. package/dist/simple-tree/treeNodeValid.js +7 -10
  317. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  318. package/dist/simple-tree/typesUnsafe.d.ts +13 -13
  319. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  320. package/dist/simple-tree/walkSchema.d.ts +26 -0
  321. package/dist/simple-tree/walkSchema.d.ts.map +1 -0
  322. package/dist/simple-tree/walkSchema.js +49 -0
  323. package/dist/simple-tree/walkSchema.js.map +1 -0
  324. package/dist/treeFactory.d.ts +2 -1
  325. package/dist/treeFactory.d.ts.map +1 -1
  326. package/dist/treeFactory.js +2 -1
  327. package/dist/treeFactory.js.map +1 -1
  328. package/dist/util/typeUtils.d.ts +2 -2
  329. package/dist/util/typeUtils.js.map +1 -1
  330. package/legacy.d.ts +11 -0
  331. package/lib/alpha.d.ts +102 -0
  332. package/lib/beta.d.ts +6 -2
  333. package/lib/core/index.d.ts +1 -1
  334. package/lib/core/index.d.ts.map +1 -1
  335. package/lib/core/index.js +1 -1
  336. package/lib/core/index.js.map +1 -1
  337. package/lib/core/{revertible/revertible.d.ts → revertible.d.ts} +12 -0
  338. package/lib/core/revertible.d.ts.map +1 -0
  339. package/lib/core/revertible.js.map +1 -0
  340. package/lib/core/schema-stored/format.d.ts +3 -3
  341. package/lib/core/schema-stored/format.js +1 -1
  342. package/lib/core/schema-stored/format.js.map +1 -1
  343. package/lib/core/schema-stored/schema.d.ts +2 -7
  344. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  345. package/lib/core/schema-stored/schema.js +4 -6
  346. package/lib/core/schema-stored/schema.js.map +1 -1
  347. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  348. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  349. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  350. package/lib/core/tree/anchorSet.js +6 -2
  351. package/lib/core/tree/anchorSet.js.map +1 -1
  352. package/lib/core/tree/detachedFieldIndex.d.ts +0 -1
  353. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  354. package/lib/core/tree/detachedFieldIndex.js +1 -0
  355. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  356. package/lib/core/tree/visitDelta.d.ts +7 -2
  357. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  358. package/lib/core/tree/visitDelta.js.map +1 -1
  359. package/lib/events/emitter.d.ts +127 -0
  360. package/lib/events/emitter.d.ts.map +1 -0
  361. package/lib/events/{events.js → emitter.js} +48 -29
  362. package/lib/events/emitter.js.map +1 -0
  363. package/lib/events/index.d.ts +2 -1
  364. package/lib/events/index.d.ts.map +1 -1
  365. package/lib/events/index.js +1 -1
  366. package/lib/events/index.js.map +1 -1
  367. package/lib/events/interop.d.ts +36 -0
  368. package/lib/events/interop.d.ts.map +1 -0
  369. package/{src/core/revertible/index.ts → lib/events/interop.js} +2 -2
  370. package/lib/events/interop.js.map +1 -0
  371. package/lib/events/listeners.d.ts +65 -0
  372. package/lib/events/listeners.d.ts.map +1 -0
  373. package/lib/{core/revertible/index.js → events/listeners.js} +2 -2
  374. package/lib/events/listeners.js.map +1 -0
  375. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +25 -7
  376. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  377. package/lib/feature-libraries/chunked-forest/chunkTree.js +37 -16
  378. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  379. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +4 -2
  380. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  381. package/lib/feature-libraries/chunked-forest/chunkedForest.js +12 -5
  382. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  383. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +15 -2
  384. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  385. package/lib/feature-libraries/chunked-forest/uniformChunk.js +28 -2
  386. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  387. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +3 -1
  388. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  389. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -4
  390. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  391. package/lib/feature-libraries/flex-map-tree/index.d.ts +1 -1
  392. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  393. package/lib/feature-libraries/flex-map-tree/index.js +1 -1
  394. package/lib/feature-libraries/flex-map-tree/index.js.map +1 -1
  395. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +35 -33
  396. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  397. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +83 -104
  398. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  399. package/lib/feature-libraries/flex-tree/context.d.ts +30 -14
  400. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  401. package/lib/feature-libraries/flex-tree/context.js +10 -7
  402. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  403. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +57 -190
  404. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  405. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +15 -2
  406. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  407. package/lib/feature-libraries/flex-tree/index.d.ts +2 -3
  408. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  409. package/lib/feature-libraries/flex-tree/index.js +1 -1
  410. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  411. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +3 -3
  412. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  413. package/lib/feature-libraries/flex-tree/lazyEntity.js +2 -10
  414. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  415. package/lib/feature-libraries/flex-tree/lazyField.d.ts +26 -28
  416. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  417. package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
  418. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  419. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +5 -26
  420. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  421. package/lib/feature-libraries/flex-tree/lazyNode.js +23 -72
  422. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  423. package/lib/feature-libraries/flex-tree/unboxed.d.ts +4 -16
  424. package/lib/feature-libraries/flex-tree/unboxed.d.ts.map +1 -1
  425. package/lib/feature-libraries/flex-tree/unboxed.js +5 -37
  426. package/lib/feature-libraries/flex-tree/unboxed.js.map +1 -1
  427. package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -2
  428. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  429. package/lib/feature-libraries/flex-tree/utilities.js +3 -6
  430. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  431. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  432. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -1
  433. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  434. package/lib/feature-libraries/index.d.ts +3 -5
  435. package/lib/feature-libraries/index.d.ts.map +1 -1
  436. package/lib/feature-libraries/index.js +5 -5
  437. package/lib/feature-libraries/index.js.map +1 -1
  438. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  439. package/lib/feature-libraries/modular-schema/comparison.js +3 -6
  440. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  441. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  442. package/lib/feature-libraries/modular-schema/discrepancies.js +3 -13
  443. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  444. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -1
  445. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  446. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -1
  447. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  448. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +12 -5
  449. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  450. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +6 -6
  451. package/lib/feature-libraries/schema-index/format.d.ts +3 -3
  452. package/lib/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  453. package/lib/feature-libraries/storedToViewSchema.js +3 -5
  454. package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
  455. package/lib/feature-libraries/typed-schema/flexList.d.ts +3 -3
  456. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  457. package/lib/feature-libraries/typed-schema/index.d.ts +2 -2
  458. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  459. package/lib/feature-libraries/typed-schema/index.js +2 -2
  460. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  461. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  462. package/lib/feature-libraries/typed-schema/schemaCollection.js +9 -11
  463. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  464. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +17 -48
  465. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  466. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +5 -36
  467. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  468. package/lib/feature-libraries/typed-schema/view.d.ts +4 -6
  469. package/lib/feature-libraries/typed-schema/view.d.ts.map +1 -1
  470. package/lib/feature-libraries/typed-schema/view.js +5 -4
  471. package/lib/feature-libraries/typed-schema/view.js.map +1 -1
  472. package/lib/index.d.ts +4 -4
  473. package/lib/index.d.ts.map +1 -1
  474. package/lib/index.js +3 -5
  475. package/lib/index.js.map +1 -1
  476. package/lib/legacy.d.ts +83 -0
  477. package/lib/packageVersion.d.ts +1 -1
  478. package/lib/packageVersion.d.ts.map +1 -1
  479. package/lib/packageVersion.js +1 -1
  480. package/lib/packageVersion.js.map +1 -1
  481. package/lib/public.d.ts +0 -1
  482. package/lib/shared-tree/checkoutFlexTreeView.d.ts +53 -0
  483. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -0
  484. package/lib/shared-tree/{treeView.js → checkoutFlexTreeView.js} +26 -5
  485. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -0
  486. package/lib/shared-tree/index.d.ts +3 -3
  487. package/lib/shared-tree/index.d.ts.map +1 -1
  488. package/lib/shared-tree/index.js +1 -1
  489. package/lib/shared-tree/index.js.map +1 -1
  490. package/lib/shared-tree/schematizeTree.d.ts +15 -4
  491. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  492. package/lib/shared-tree/schematizeTree.js +8 -9
  493. package/lib/shared-tree/schematizeTree.js.map +1 -1
  494. package/lib/shared-tree/schematizingTreeView.d.ts +9 -4
  495. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  496. package/lib/shared-tree/schematizingTreeView.js +26 -13
  497. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  498. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  499. package/lib/shared-tree/sharedTree.js +2 -2
  500. package/lib/shared-tree/sharedTree.js.map +1 -1
  501. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +3 -1
  502. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  503. package/lib/shared-tree/sharedTreeChangeEnricher.js +6 -2
  504. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  505. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -1
  506. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  507. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -2
  508. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  509. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +2 -1
  510. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  511. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  512. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  513. package/lib/shared-tree/treeApi.d.ts +1 -3
  514. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  515. package/lib/shared-tree/treeApi.js +7 -5
  516. package/lib/shared-tree/treeApi.js.map +1 -1
  517. package/lib/shared-tree/treeCheckout.d.ts +2 -13
  518. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  519. package/lib/shared-tree/treeCheckout.js +18 -2
  520. package/lib/shared-tree/treeCheckout.js.map +1 -1
  521. package/lib/shared-tree-core/branch.js +1 -1
  522. package/lib/shared-tree-core/branch.js.map +1 -1
  523. package/lib/simple-tree/api/create.d.ts.map +1 -1
  524. package/lib/simple-tree/api/create.js +2 -2
  525. package/lib/simple-tree/api/create.js.map +1 -1
  526. package/{dist/simple-tree → lib/simple-tree/api}/getJsonSchema.d.ts +1 -1
  527. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -0
  528. package/lib/simple-tree/{getJsonSchema.js → api/getJsonSchema.js} +1 -1
  529. package/lib/simple-tree/api/getJsonSchema.js.map +1 -0
  530. package/{dist/simple-tree → lib/simple-tree/api}/getSimpleSchema.d.ts +1 -1
  531. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -0
  532. package/lib/simple-tree/{getSimpleSchema.js → api/getSimpleSchema.js} +1 -1
  533. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -0
  534. package/lib/simple-tree/api/index.d.ts +5 -0
  535. package/lib/simple-tree/api/index.d.ts.map +1 -1
  536. package/lib/simple-tree/api/index.js +3 -0
  537. package/lib/simple-tree/api/index.js.map +1 -1
  538. package/{dist/simple-tree → lib/simple-tree/api}/jsonSchema.d.ts +1 -1
  539. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -0
  540. package/lib/simple-tree/api/jsonSchema.js.map +1 -0
  541. package/lib/simple-tree/api/schemaFactory.d.ts +45 -14
  542. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  543. package/lib/simple-tree/api/schemaFactory.js +43 -12
  544. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  545. package/lib/simple-tree/{simpleSchema.d.ts → api/simpleSchema.d.ts} +4 -4
  546. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -0
  547. package/lib/simple-tree/api/simpleSchema.js.map +1 -0
  548. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -0
  549. package/lib/simple-tree/{simpleSchemaToJsonSchema.js → api/simpleSchemaToJsonSchema.js} +4 -4
  550. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -0
  551. package/lib/simple-tree/api/tree.d.ts +1 -21
  552. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  553. package/lib/simple-tree/api/tree.js +2 -34
  554. package/lib/simple-tree/api/tree.js.map +1 -1
  555. package/lib/simple-tree/api/treeApiBeta.d.ts +79 -0
  556. package/lib/simple-tree/api/treeApiBeta.d.ts.map +1 -0
  557. package/lib/simple-tree/api/treeApiBeta.js +23 -0
  558. package/lib/simple-tree/api/treeApiBeta.js.map +1 -0
  559. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -1
  560. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  561. package/lib/simple-tree/api/treeNodeApi.js +23 -21
  562. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  563. package/lib/simple-tree/api/verboseTree.js +1 -1
  564. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  565. package/lib/simple-tree/{viewSchemaToSimpleSchema.d.ts → api/viewSchemaToSimpleSchema.d.ts} +1 -1
  566. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -0
  567. package/lib/simple-tree/{viewSchemaToSimpleSchema.js → api/viewSchemaToSimpleSchema.js} +4 -4
  568. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -0
  569. package/lib/simple-tree/arrayNode.d.ts +2 -2
  570. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  571. package/lib/simple-tree/arrayNode.js +33 -24
  572. package/lib/simple-tree/arrayNode.js.map +1 -1
  573. package/lib/simple-tree/core/index.d.ts +3 -3
  574. package/lib/simple-tree/core/index.d.ts.map +1 -1
  575. package/lib/simple-tree/core/index.js +2 -2
  576. package/lib/simple-tree/core/index.js.map +1 -1
  577. package/lib/simple-tree/core/schemaCaching.d.ts +5 -0
  578. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -1
  579. package/lib/simple-tree/core/schemaCaching.js +8 -0
  580. package/lib/simple-tree/core/schemaCaching.js.map +1 -1
  581. package/lib/simple-tree/core/treeNodeKernel.d.ts +61 -3
  582. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  583. package/lib/simple-tree/core/treeNodeKernel.js +156 -5
  584. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  585. package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -1
  586. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  587. package/lib/simple-tree/core/types.d.ts +17 -20
  588. package/lib/simple-tree/core/types.d.ts.map +1 -1
  589. package/lib/simple-tree/core/types.js.map +1 -1
  590. package/lib/simple-tree/core/withType.d.ts +3 -2
  591. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  592. package/lib/simple-tree/core/withType.js.map +1 -1
  593. package/lib/simple-tree/index.d.ts +7 -9
  594. package/lib/simple-tree/index.d.ts.map +1 -1
  595. package/lib/simple-tree/index.js +5 -5
  596. package/lib/simple-tree/index.js.map +1 -1
  597. package/lib/simple-tree/leafNodeSchema.d.ts +7 -9
  598. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  599. package/lib/simple-tree/leafNodeSchema.js +14 -12
  600. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  601. package/lib/simple-tree/mapNode.d.ts +1 -1
  602. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  603. package/lib/simple-tree/mapNode.js +38 -29
  604. package/lib/simple-tree/mapNode.js.map +1 -1
  605. package/lib/simple-tree/objectNode.d.ts +9 -7
  606. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  607. package/lib/simple-tree/objectNode.js +40 -34
  608. package/lib/simple-tree/objectNode.js.map +1 -1
  609. package/lib/simple-tree/proxies.d.ts +1 -14
  610. package/lib/simple-tree/proxies.d.ts.map +1 -1
  611. package/lib/simple-tree/proxies.js +11 -14
  612. package/lib/simple-tree/proxies.js.map +1 -1
  613. package/lib/simple-tree/proxyBinding.d.ts +2 -62
  614. package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
  615. package/lib/simple-tree/proxyBinding.js +6 -174
  616. package/lib/simple-tree/proxyBinding.js.map +1 -1
  617. package/lib/simple-tree/schemaTypes.d.ts +7 -7
  618. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  619. package/lib/simple-tree/schemaTypes.js +4 -4
  620. package/lib/simple-tree/schemaTypes.js.map +1 -1
  621. package/lib/simple-tree/toFlexSchema.d.ts +11 -1
  622. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  623. package/lib/simple-tree/toFlexSchema.js +29 -8
  624. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  625. package/lib/simple-tree/toMapTree.d.ts +25 -37
  626. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  627. package/lib/simple-tree/toMapTree.js +54 -17
  628. package/lib/simple-tree/toMapTree.js.map +1 -1
  629. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  630. package/lib/simple-tree/treeNodeValid.js +8 -11
  631. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  632. package/lib/simple-tree/typesUnsafe.d.ts +13 -13
  633. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  634. package/lib/simple-tree/walkSchema.d.ts +26 -0
  635. package/lib/simple-tree/walkSchema.d.ts.map +1 -0
  636. package/lib/simple-tree/walkSchema.js +43 -0
  637. package/lib/simple-tree/walkSchema.js.map +1 -0
  638. package/lib/treeFactory.d.ts +2 -1
  639. package/lib/treeFactory.d.ts.map +1 -1
  640. package/lib/treeFactory.js +2 -1
  641. package/lib/treeFactory.js.map +1 -1
  642. package/lib/tsdoc-metadata.json +1 -1
  643. package/lib/util/typeUtils.d.ts +2 -2
  644. package/lib/util/typeUtils.js.map +1 -1
  645. package/package.json +57 -25
  646. package/src/core/index.ts +1 -1
  647. package/src/core/{revertible/revertible.ts → revertible.ts} +15 -0
  648. package/src/core/schema-stored/format.ts +1 -1
  649. package/src/core/schema-stored/schema.ts +6 -13
  650. package/src/core/tree/anchorSet.ts +18 -3
  651. package/src/core/tree/detachedFieldIndex.ts +6 -5
  652. package/src/core/tree/visitDelta.ts +7 -2
  653. package/src/events/{events.ts → emitter.ts} +52 -139
  654. package/src/events/index.ts +7 -7
  655. package/src/events/interop.ts +49 -0
  656. package/src/events/listeners.ts +68 -0
  657. package/src/feature-libraries/chunked-forest/chunkTree.ts +63 -18
  658. package/src/feature-libraries/chunked-forest/chunkedForest.ts +18 -4
  659. package/src/feature-libraries/chunked-forest/uniformChunk.ts +33 -0
  660. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +5 -3
  661. package/src/feature-libraries/flex-map-tree/index.ts +1 -0
  662. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +135 -210
  663. package/src/feature-libraries/flex-tree/README.md +4 -75
  664. package/src/feature-libraries/flex-tree/context.ts +37 -16
  665. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +69 -291
  666. package/src/feature-libraries/flex-tree/index.ts +7 -13
  667. package/src/feature-libraries/flex-tree/lazyEntity.ts +2 -11
  668. package/src/feature-libraries/flex-tree/lazyField.ts +49 -73
  669. package/src/feature-libraries/flex-tree/lazyNode.ts +25 -154
  670. package/src/feature-libraries/flex-tree/unboxed.ts +9 -68
  671. package/src/feature-libraries/flex-tree/utilities.ts +4 -8
  672. package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -1
  673. package/src/feature-libraries/index.ts +2 -27
  674. package/src/feature-libraries/modular-schema/comparison.ts +4 -6
  675. package/src/feature-libraries/modular-schema/discrepancies.ts +7 -16
  676. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -1
  677. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +14 -4
  678. package/src/feature-libraries/storedToViewSchema.ts +5 -6
  679. package/src/feature-libraries/typed-schema/flexList.ts +3 -3
  680. package/src/feature-libraries/typed-schema/index.ts +1 -3
  681. package/src/feature-libraries/typed-schema/schemaCollection.ts +15 -17
  682. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +35 -127
  683. package/src/feature-libraries/typed-schema/view.ts +4 -13
  684. package/src/index.ts +4 -8
  685. package/src/packageVersion.ts +1 -1
  686. package/src/shared-tree/checkoutFlexTreeView.ts +89 -0
  687. package/src/shared-tree/index.ts +2 -7
  688. package/src/shared-tree/schematizeTree.ts +23 -12
  689. package/src/shared-tree/schematizingTreeView.ts +34 -24
  690. package/src/shared-tree/sharedTree.ts +6 -1
  691. package/src/shared-tree/sharedTreeChangeEnricher.ts +6 -1
  692. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -1
  693. package/src/shared-tree/sharedTreeEditBuilder.ts +9 -4
  694. package/src/shared-tree/treeApi.ts +10 -10
  695. package/src/shared-tree/treeCheckout.ts +26 -15
  696. package/src/shared-tree-core/branch.ts +1 -1
  697. package/src/simple-tree/ProxyBinding.md +23 -23
  698. package/src/simple-tree/api/create.ts +8 -3
  699. package/src/simple-tree/{getJsonSchema.ts → api/getJsonSchema.ts} +3 -3
  700. package/src/simple-tree/{getSimpleSchema.ts → api/getSimpleSchema.ts} +3 -3
  701. package/src/simple-tree/api/index.ts +20 -0
  702. package/src/simple-tree/{jsonSchema.ts → api/jsonSchema.ts} +1 -1
  703. package/src/simple-tree/api/schemaFactory.ts +44 -13
  704. package/src/simple-tree/{simpleSchema.ts → api/simpleSchema.ts} +4 -4
  705. package/src/simple-tree/{simpleSchemaToJsonSchema.ts → api/simpleSchemaToJsonSchema.ts} +4 -4
  706. package/src/simple-tree/api/tree.ts +2 -71
  707. package/src/simple-tree/api/treeApiBeta.ts +101 -0
  708. package/src/simple-tree/api/treeNodeApi.ts +32 -23
  709. package/src/simple-tree/api/verboseTree.ts +1 -1
  710. package/src/simple-tree/{viewSchemaToSimpleSchema.ts → api/viewSchemaToSimpleSchema.ts} +5 -5
  711. package/src/simple-tree/arrayNode.ts +37 -31
  712. package/src/simple-tree/core/index.ts +4 -1
  713. package/src/simple-tree/core/schemaCaching.ts +10 -0
  714. package/src/simple-tree/core/treeNodeKernel.ts +198 -5
  715. package/src/simple-tree/core/treeNodeSchema.ts +1 -1
  716. package/src/simple-tree/core/types.ts +16 -27
  717. package/src/simple-tree/core/withType.ts +3 -1
  718. package/src/simple-tree/index.ts +29 -21
  719. package/src/simple-tree/leafNodeSchema.ts +24 -28
  720. package/src/simple-tree/mapNode.ts +47 -29
  721. package/src/simple-tree/objectNode.ts +51 -46
  722. package/src/simple-tree/proxies.ts +22 -51
  723. package/src/simple-tree/proxyBinding.ts +3 -254
  724. package/src/simple-tree/schemaTypes.ts +8 -8
  725. package/src/simple-tree/toFlexSchema.ts +40 -7
  726. package/src/simple-tree/toMapTree.ts +113 -79
  727. package/src/simple-tree/treeNodeValid.ts +10 -13
  728. package/src/simple-tree/typesUnsafe.ts +13 -13
  729. package/src/simple-tree/walkSchema.ts +81 -0
  730. package/src/treeFactory.ts +2 -1
  731. package/src/util/typeUtils.ts +2 -2
  732. package/dist/core/revertible/index.d.ts.map +0 -1
  733. package/dist/core/revertible/index.js +0 -10
  734. package/dist/core/revertible/index.js.map +0 -1
  735. package/dist/core/revertible/revertible.d.ts.map +0 -1
  736. package/dist/core/revertible/revertible.js.map +0 -1
  737. package/dist/domains/index.d.ts +0 -8
  738. package/dist/domains/index.d.ts.map +0 -1
  739. package/dist/domains/index.js +0 -20
  740. package/dist/domains/index.js.map +0 -1
  741. package/dist/domains/json/index.d.ts +0 -7
  742. package/dist/domains/json/index.d.ts.map +0 -1
  743. package/dist/domains/json/index.js +0 -17
  744. package/dist/domains/json/index.js.map +0 -1
  745. package/dist/domains/json/jsonCursor.d.ts +0 -52
  746. package/dist/domains/json/jsonCursor.d.ts.map +0 -1
  747. package/dist/domains/json/jsonCursor.js +0 -197
  748. package/dist/domains/json/jsonCursor.js.map +0 -1
  749. package/dist/domains/json/jsonDomainSchema.d.ts +0 -24
  750. package/dist/domains/json/jsonDomainSchema.d.ts.map +0 -1
  751. package/dist/domains/json/jsonDomainSchema.js +0 -32
  752. package/dist/domains/json/jsonDomainSchema.js.map +0 -1
  753. package/dist/domains/leafDomain.d.ts +0 -72
  754. package/dist/domains/leafDomain.d.ts.map +0 -1
  755. package/dist/domains/leafDomain.js +0 -88
  756. package/dist/domains/leafDomain.js.map +0 -1
  757. package/dist/domains/schemaBuilder.d.ts +0 -103
  758. package/dist/domains/schemaBuilder.d.ts.map +0 -1
  759. package/dist/domains/schemaBuilder.js +0 -121
  760. package/dist/domains/schemaBuilder.js.map +0 -1
  761. package/dist/domains/testRecursiveDomain.d.ts +0 -17
  762. package/dist/domains/testRecursiveDomain.d.ts.map +0 -1
  763. package/dist/domains/testRecursiveDomain.js +0 -35
  764. package/dist/domains/testRecursiveDomain.js.map +0 -1
  765. package/dist/events/events.d.ts +0 -207
  766. package/dist/events/events.d.ts.map +0 -1
  767. package/dist/events/events.js.map +0 -1
  768. package/dist/feature-libraries/schemaBuilder.d.ts +0 -31
  769. package/dist/feature-libraries/schemaBuilder.d.ts.map +0 -1
  770. package/dist/feature-libraries/schemaBuilder.js +0 -40
  771. package/dist/feature-libraries/schemaBuilder.js.map +0 -1
  772. package/dist/feature-libraries/schemaBuilderBase.d.ts +0 -191
  773. package/dist/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
  774. package/dist/feature-libraries/schemaBuilderBase.js +0 -201
  775. package/dist/feature-libraries/schemaBuilderBase.js.map +0 -1
  776. package/dist/shared-tree/treeView.d.ts +0 -73
  777. package/dist/shared-tree/treeView.d.ts.map +0 -1
  778. package/dist/shared-tree/treeView.js.map +0 -1
  779. package/dist/simple-tree/getJsonSchema.d.ts.map +0 -1
  780. package/dist/simple-tree/getJsonSchema.js.map +0 -1
  781. package/dist/simple-tree/getSimpleSchema.d.ts.map +0 -1
  782. package/dist/simple-tree/getSimpleSchema.js.map +0 -1
  783. package/dist/simple-tree/jsonSchema.d.ts.map +0 -1
  784. package/dist/simple-tree/jsonSchema.js.map +0 -1
  785. package/dist/simple-tree/simpleSchema.d.ts.map +0 -1
  786. package/dist/simple-tree/simpleSchema.js.map +0 -1
  787. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
  788. package/dist/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
  789. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
  790. package/dist/simple-tree/viewSchemaToSimpleSchema.js.map +0 -1
  791. package/lib/core/revertible/index.d.ts.map +0 -1
  792. package/lib/core/revertible/index.js.map +0 -1
  793. package/lib/core/revertible/revertible.d.ts.map +0 -1
  794. package/lib/core/revertible/revertible.js.map +0 -1
  795. package/lib/domains/index.d.ts +0 -8
  796. package/lib/domains/index.d.ts.map +0 -1
  797. package/lib/domains/index.js +0 -8
  798. package/lib/domains/index.js.map +0 -1
  799. package/lib/domains/json/index.d.ts +0 -7
  800. package/lib/domains/json/index.d.ts.map +0 -1
  801. package/lib/domains/json/index.js +0 -7
  802. package/lib/domains/json/index.js.map +0 -1
  803. package/lib/domains/json/jsonCursor.d.ts +0 -52
  804. package/lib/domains/json/jsonCursor.d.ts.map +0 -1
  805. package/lib/domains/json/jsonCursor.js +0 -192
  806. package/lib/domains/json/jsonCursor.js.map +0 -1
  807. package/lib/domains/json/jsonDomainSchema.d.ts +0 -24
  808. package/lib/domains/json/jsonDomainSchema.d.ts.map +0 -1
  809. package/lib/domains/json/jsonDomainSchema.js +0 -29
  810. package/lib/domains/json/jsonDomainSchema.js.map +0 -1
  811. package/lib/domains/leafDomain.d.ts +0 -72
  812. package/lib/domains/leafDomain.d.ts.map +0 -1
  813. package/lib/domains/leafDomain.js +0 -85
  814. package/lib/domains/leafDomain.js.map +0 -1
  815. package/lib/domains/schemaBuilder.d.ts +0 -103
  816. package/lib/domains/schemaBuilder.d.ts.map +0 -1
  817. package/lib/domains/schemaBuilder.js +0 -117
  818. package/lib/domains/schemaBuilder.js.map +0 -1
  819. package/lib/domains/testRecursiveDomain.d.ts +0 -17
  820. package/lib/domains/testRecursiveDomain.d.ts.map +0 -1
  821. package/lib/domains/testRecursiveDomain.js +0 -32
  822. package/lib/domains/testRecursiveDomain.js.map +0 -1
  823. package/lib/events/events.d.ts +0 -207
  824. package/lib/events/events.d.ts.map +0 -1
  825. package/lib/events/events.js.map +0 -1
  826. package/lib/feature-libraries/schemaBuilder.d.ts +0 -31
  827. package/lib/feature-libraries/schemaBuilder.d.ts.map +0 -1
  828. package/lib/feature-libraries/schemaBuilder.js +0 -36
  829. package/lib/feature-libraries/schemaBuilder.js.map +0 -1
  830. package/lib/feature-libraries/schemaBuilderBase.d.ts +0 -191
  831. package/lib/feature-libraries/schemaBuilderBase.d.ts.map +0 -1
  832. package/lib/feature-libraries/schemaBuilderBase.js +0 -195
  833. package/lib/feature-libraries/schemaBuilderBase.js.map +0 -1
  834. package/lib/shared-tree/treeView.d.ts +0 -73
  835. package/lib/shared-tree/treeView.d.ts.map +0 -1
  836. package/lib/shared-tree/treeView.js.map +0 -1
  837. package/lib/simple-tree/getJsonSchema.d.ts.map +0 -1
  838. package/lib/simple-tree/getJsonSchema.js.map +0 -1
  839. package/lib/simple-tree/getSimpleSchema.d.ts.map +0 -1
  840. package/lib/simple-tree/getSimpleSchema.js.map +0 -1
  841. package/lib/simple-tree/jsonSchema.d.ts.map +0 -1
  842. package/lib/simple-tree/jsonSchema.js.map +0 -1
  843. package/lib/simple-tree/simpleSchema.d.ts.map +0 -1
  844. package/lib/simple-tree/simpleSchema.js.map +0 -1
  845. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts.map +0 -1
  846. package/lib/simple-tree/simpleSchemaToJsonSchema.js.map +0 -1
  847. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts.map +0 -1
  848. package/src/domains/README.md +0 -6
  849. package/src/domains/fence.json +0 -5
  850. package/src/domains/index.ts +0 -19
  851. package/src/domains/json/fence.json +0 -5
  852. package/src/domains/json/index.ts +0 -13
  853. package/src/domains/json/jsonCursor.ts +0 -247
  854. package/src/domains/json/jsonDomainSchema.ts +0 -47
  855. package/src/domains/leafDomain.ts +0 -97
  856. package/src/domains/schemaBuilder.ts +0 -153
  857. package/src/domains/testRecursiveDomain.ts +0 -38
  858. package/src/events/fence.json +0 -5
  859. package/src/feature-libraries/schemaBuilder.ts +0 -45
  860. package/src/feature-libraries/schemaBuilderBase.ts +0 -393
  861. package/src/shared-tree/treeView.ts +0 -113
  862. /package/dist/core/{revertible/revertible.js → revertible.js} +0 -0
  863. /package/dist/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
  864. /package/dist/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
  865. /package/dist/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
  866. /package/lib/core/{revertible/revertible.js → revertible.js} +0 -0
  867. /package/lib/simple-tree/{jsonSchema.js → api/jsonSchema.js} +0 -0
  868. /package/lib/simple-tree/{simpleSchema.js → api/simpleSchema.js} +0 -0
  869. /package/lib/simple-tree/{simpleSchemaToJsonSchema.d.ts → api/simpleSchemaToJsonSchema.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"treeApi.js","sourceRoot":"","sources":["../../src/shared-tree/treeApi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAE9E,4DAAoE;AACpE,sDAOi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AAC,KAAK,EAAE,CAAC;QAC7B,MAAM,CAAC,CAAC;IACT,CAAC;IAED,IAAI,MAAM,KAAK,gBAAQ,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 { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport { Context, TreeStatus } from \"../feature-libraries/index.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype TreeNode,\n\ttype TreeNodeApi,\n\ttype TreeView,\n\tgetOrCreateInnerNode,\n\ttreeNodeApi,\n} from \"../simple-tree/index.js\";\nimport { fail } from \"../util/index.js\";\n\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport type { ITreeCheckout } from \"./treeCheckout.js\";\nimport { contextToTreeView } from \"./treeView.js\";\n\n/**\n * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should \"roll back\".\n * @public\n */\nexport const rollback = Symbol(\"SharedTree Transaction Rollback\");\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t): 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the public `Tree` export.\n * @privateRemarks\n * Due to limitations of API-Extractor link resolution, this type can't be moved into internalTypes but should be considered just an implementation detail of the `Tree` export.\n * @sealed @public\n */\nexport interface TreeApi 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 thus is 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 `Tree` object holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const treeApi: TreeApi = {\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 = treeApi.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A requirement for a SharedTree transaction to succeed.\n * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.\n * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.\n * However, they cannot know what the tree state will be when the transaction is _sequenced_.\n * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.\n * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.\n * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.\n * @public\n */\nexport type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here\n\n/**\n * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.\n * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as \"existing\".\n * @public\n */\nexport interface NodeInDocumentConstraint {\n\treadonly type: \"nodeInDocument\";\n\treadonly node: TreeNode;\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 */\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\tassert(context instanceof Context, 0x901 /* Unsupported context */);\n\t\tconst treeView =\n\t\t\tcontextToTreeView.get(context) ?? fail(\"Expected view to be registered for context\");\n\n\t\treturn runTransactionInCheckout(treeView.checkout, () => t(node), preconditions);\n\t}\n}\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\tassert(\n\t\t\t\t\ttreeApi.status(constraint.node) === TreeStatus.InDocument,\n\t\t\t\t\t0x90f /* Attempted to apply \"nodeExists\" constraint when building a transaction, but the node is not in the document. */,\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\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (e) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\tcheckout.transaction.abort();\n\t\tthrow e;\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"]}
1
+ {"version":3,"file":"treeApi.js","sourceRoot":"","sources":["../../src/shared-tree/treeApi.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAC9E,uEAAsE;AAEtE,4DAA2D;AAC3D,sDAOiC;AAEjC,uEAAuE;AAEvE,uEAAoE;AAEpE;;;GAGG;AACU,QAAA,QAAQ,GAAG,MAAM,CAAC,iCAAiC,CAAC,CAAC;AAqUlE;;;GAGG;AACU,QAAA,OAAO,GAAY;IAC/B,GAAG,sBAAW;IAEd,cAAc,EAAE,oBAAoB,EAAE;IAEtC,QAAQ,CAAC,MAAgB,EAAE,KAAe;QACzC,IAAI,OAAO,GAAyB,KAAK,CAAC;QAC1C,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,GAAG,eAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAC;AAwBF,uCAAuC;AAEvC,6HAA6H;AAC7H,SAAS,oBAAoB;IAC5B,wHAAwH;IACxH,SAAS,sBAAsB,CAC9B,MAAS;QAET,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,gBAAQ,EAAE,CAAC,CAAC;QAChE,OAAO,MAAoD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gBACnD,IAAA,iBAAM,EACL,eAAO,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,qBAAU,CAAC,UAAU,EACzD,KAAK,CAAC,kHAAkH,CACxH,CAAC;gBACF,QAAQ,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACzD,MAAM;YACP,CAAC;YACD;gBACC,IAAA,0BAAe,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IACD,IAAI,MAAsC,CAAC;IAC3C,IAAI,CAAC;QACJ,MAAM,GAAG,WAAW,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,qHAAqH;QACrH,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,CAAC,CAAC;IACT,CAAC;IAED,IAAI,MAAM,KAAK,gBAAQ,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 { assert, 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} 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 * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should \"roll back\".\n * @public\n */\nexport const rollback = Symbol(\"SharedTree Transaction Rollback\");\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t): 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>, 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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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 * - If reverted (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\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<TView extends TreeView<ImplicitFieldSchema>>(\n\t\ttree: TView,\n\t\ttransaction: (root: TView[\"root\"]) => void,\n\t\tpreconditions?: readonly TransactionConstraint[],\n\t): void;\n}\n\n/**\n * Provides various functions for interacting with {@link TreeNode}s.\n * @remarks\n * This type should only be used via the public `Tree` export.\n * @system @sealed @public\n */\nexport interface TreeApi 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 thus is 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 `Tree` object holds various functions for interacting with {@link TreeNode}s.\n * @public\n */\nexport const treeApi: TreeApi = {\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 = treeApi.parent(toCheck);\n\t\t}\n\t\treturn false;\n\t},\n};\n\n/**\n * A requirement for a SharedTree transaction to succeed.\n * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.\n * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.\n * However, they cannot know what the tree state will be when the transaction is _sequenced_.\n * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.\n * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.\n * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.\n * @public\n */\nexport type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here\n\n/**\n * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.\n * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as \"existing\".\n * @public\n */\nexport interface NodeInDocumentConstraint {\n\treadonly type: \"nodeInDocument\";\n\treadonly node: TreeNode;\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 */\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\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\tassert(\n\t\t\t\t\ttreeApi.status(constraint.node) === TreeStatus.InDocument,\n\t\t\t\t\t0x90f /* Attempted to apply \"nodeExists\" constraint when building a transaction, but the node is not in the document. */,\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\tlet result: ReturnType<typeof transaction>;\n\ttry {\n\t\tresult = transaction();\n\t} catch (e) {\n\t\t// If the transaction has an unhandled error, abort and rollback the transaction but continue to propagate the error.\n\t\tcheckout.transaction.abort();\n\t\tthrow e;\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"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { IIdCompressor } from "@fluidframework/id-compressor";
6
6
  import { type ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
7
- import { type Anchor, type AnchorLocator, type AnchorNode, type AnchorSetRootEvents, type ChangeFamily, type CommitMetadata, type DetachedFieldIndex, type IEditableForest, type IForestSubscription, type JsonableTree, type Revertible, type RevisionTag, type RevisionTagCodec, type TreeStoredSchema, TreeStoredSchemaRepository, type TreeStoredSchemaSubscription } from "../core/index.js";
7
+ import { type Anchor, type AnchorLocator, type AnchorNode, type AnchorSetRootEvents, type ChangeFamily, type CommitMetadata, type DetachedFieldIndex, type IEditableForest, type IForestSubscription, type JsonableTree, type RevisionTag, type RevisionTagCodec, type TreeStoredSchema, TreeStoredSchemaRepository, type TreeStoredSchemaSubscription, type RevertibleFactory } from "../core/index.js";
8
8
  import { type HasListeners, type IEmitter, type Listenable } from "../events/index.js";
9
9
  import { type FieldBatchCodec, type TreeCompressionStrategy } from "../feature-libraries/index.js";
10
10
  import { SharedTreeBranch } from "../shared-tree-core/index.js";
@@ -36,18 +36,6 @@ export interface CheckoutEvents {
36
36
  */
37
37
  commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
38
38
  }
39
- /**
40
- * Factory for creating a {@link Revertible}.
41
- * Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.
42
- *
43
- * @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.
44
- * This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,
45
- * whichever happens first.
46
- * This is typically used to clean up any resources associated with the `Revertible` in the host application.
47
- *
48
- * @sealed @public
49
- */
50
- export type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
51
39
  /**
52
40
  * Provides a means for interacting with a SharedTree.
53
41
  * This includes reading data from the tree and running transactions to mutate the tree.
@@ -279,6 +267,7 @@ export declare class TreeCheckout implements ITreeCheckoutFork {
279
267
  private purgeRevertibles;
280
268
  private disposeRevertible;
281
269
  private revertRevertible;
270
+ private assertNoUntrackedRoots;
282
271
  }
283
272
  /**
284
273
  * Run a synchronous transaction on the given shared tree view.
@@ -1 +1 @@
1
- {"version":3,"file":"treeCheckout.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAC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AIrB;IACD,qCAAqC;IACpB,MAAM,CAAC,iCAAqB;IAsJ9C,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,gBAAgB;IAIxB,IAAW,UAAU,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAEvD;IAED,IAAW,MAAM,IAAI,iBAAiB,CAGrC;IAEM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAK9C,IAAI,IAAI,YAAY;IAsBpB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAShC,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAKrC,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAC/B,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;IAgBrD,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAK/C,CAAC,aAAa,CAAC,IAAI,IAAI;IAOvB,eAAe,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE;IAiB/E;;;OAGG;IACI,2BAA2B,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAI/D,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,gBAAgB;IAiDxB,OAAO,CAAC,sBAAsB;CAqB9B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,iBAAiB,GAAG,IAAI,GAC5D,iBAAiB,CAMnB"}
@@ -28,7 +28,7 @@ function createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, arg
28
28
  const defaultFieldBatchVersion = 1;
29
29
  const changeFamily = args?.changeFamily ??
30
30
  new sharedTreeChangeFamily_js_1.SharedTreeChangeFamily(revisionTagCodec, args?.fieldBatchCodec ??
31
- (0, index_js_4.makeFieldBatchCodec)(defaultCodecOptions, defaultFieldBatchVersion), { jsonValidator: index_js_1.noopValidator }, args?.chunkCompressionStrategy);
31
+ (0, index_js_4.makeFieldBatchCodec)(defaultCodecOptions, defaultFieldBatchVersion), { jsonValidator: index_js_1.noopValidator }, args?.chunkCompressionStrategy, idCompressor);
32
32
  const branch = args?.branch ??
33
33
  new index_js_5.SharedTreeBranch({
34
34
  change: changeFamily.rebaser.compose([]),
@@ -284,6 +284,7 @@ class TreeCheckout {
284
284
  this.branch.dispose();
285
285
  }
286
286
  getRemovedRoots() {
287
+ this.assertNoUntrackedRoots();
287
288
  const trees = [];
288
289
  const cursor = this.forest.allocateCursor("getRemovedRoots");
289
290
  for (const { id, root } of this.removedRoots.entries()) {
@@ -342,6 +343,21 @@ class TreeCheckout {
342
343
  }
343
344
  return { age: revertAge };
344
345
  }
346
+ assertNoUntrackedRoots() {
347
+ const cursor = this.forest.getCursorAboveDetachedFields();
348
+ const rootFields = new Set([index_js_2.rootFieldKey]);
349
+ for (const { root } of this.removedRoots.entries()) {
350
+ rootFields.add(this.removedRoots.toFieldKey(root));
351
+ }
352
+ if (!cursor.firstField()) {
353
+ return;
354
+ }
355
+ do {
356
+ const field = cursor.getFieldKey();
357
+ (0, internal_1.assert)(rootFields.has(field), 0xa22 /* Forest has a root field which is unknown to the detached field index */);
358
+ rootFields.delete(field);
359
+ } while (cursor.nextField());
360
+ }
345
361
  }
346
362
  exports.TreeCheckout = TreeCheckout;
347
363
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,uEAGkD;AAClD,gDAAkD;AAClD,+CA2B0B;AAC1B,iDAK4B;AAC5B,4DAOuC;AACvC,2DAAsF;AACtF,+CAA4F;AAE5F,2EAAsF;AAiJtF;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,YAA2B,EA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H,SAAgB,cAAc,CAC7B,IAAmB,EACnB,WAA8D;IAE9D,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,KAAK,4BAAiB,CAAC,KAAK;QACxC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9B,CAAC;AATD,wCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { noopValidator } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\ttype Revertible,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeAnonChange,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\ttagChange,\n\tvisitDelta,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport { SharedTreeBranch, getChangeReplaceType } from \"../shared-tree-core/index.js\";\nimport { type IDisposable, TransactionResult, disposeSymbol, fail } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n */\nexport interface CheckoutEvents {\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a revertible change has been made to this view.\n\t *\n\t * Applications which subscribe to this event are expected to revert or discard revertibles they acquire (failure to do so will leak memory).\n\t * The provided revertible is inherently bound to the view that raised the event, calling `revert` won't apply to forked views.\n\t *\n\t * @param revertible - The revertible that can be used to revert the change.\n\t */\n\n\t/**\n\t * {@inheritdoc TreeViewEvents.commitApplied}\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Factory for creating a {@link Revertible}.\n * Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.\n *\n * @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.\n * This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,\n * whichever happens first.\n * This is typically used to clean up any resources associated with the `Revertible` in the host application.\n *\n * @sealed @public\n */\nexport type RevertibleFactory = (\n\tonRevertibleDisposed?: (revertible: Revertible) => void,\n) => Revertible;\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n */\nexport interface ITreeCheckout extends AnchorLocator {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: ITransaction;\n\n\t/**\n\t * Spawn a new view which is based off of the current state of this view.\n\t * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.\n\t */\n\tfork(): ITreeCheckoutFork;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * @param disposeView - whether or not to dispose `view` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork, disposeView: boolean): void;\n\n\t/**\n\t * Rebase the given view onto this view.\n\t * @param view - a view which was created by a call to `fork()`. It is modified by this operation.\n\t */\n\trebase(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Events about this view.\n\t */\n\treadonly events: Listenable<CheckoutEvents>;\n\n\t/**\n\t * Events about the root of the tree in this view.\n\t */\n\treadonly rootEvents: Listenable<AnchorSetRootEvents>;\n\n\t/**\n\t * Returns a JsonableTree for each tree that was removed from (and not restored to) the document.\n\t * This list is guaranteed to contain all nodes that are recoverable through undo/redo on this checkout.\n\t * The list may also contain additional nodes.\n\t *\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t */\n\tgetRemovedRoots(): [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Creates a {@link TreeCheckout}.\n * @param args - an object containing optional components that will be used to build the view.\n * Any components not provided will be created by default.\n * @remarks This does not create a {@link SharedTree}, but rather a view with the minimal state\n * and functionality required to implement {@link ITreeCheckout}.\n */\nexport function createTreeCheckout(\n\tidCompressor: IIdCompressor,\n\tmintRevisionTag: () => RevisionTag,\n\trevisionTagCodec: RevisionTagCodec,\n\targs?: {\n\t\tbranch?: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tchangeFamily?: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tschema?: TreeStoredSchemaRepository;\n\t\tforest?: IEditableForest;\n\t\tfieldBatchCodec?: FieldBatchCodec;\n\t\tevents?: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>;\n\t\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t},\n): TreeCheckout {\n\tconst forest = args?.forest ?? buildForest();\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst defaultCodecOptions = { jsonValidator: noopValidator };\n\tconst defaultFieldBatchVersion = 1;\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ??\n\t\t\t\tmakeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),\n\t\t\t{ jsonValidator: noopValidator },\n\t\t\targs?.chunkCompressionStrategy,\n\t\t);\n\tconst branch =\n\t\targs?.branch ??\n\t\tnew SharedTreeBranch(\n\t\t\t{\n\t\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t\t\trevision: \"root\",\n\t\t\t},\n\t\t\tchangeFamily,\n\t\t\t() => idCompressor.generateCompressedId(),\n\t\t);\n\tconst events = args?.events ?? createEmitter();\n\n\tconst transaction = new Transaction(branch);\n\n\treturn new TreeCheckout(\n\t\ttransaction,\n\t\tbranch,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tevents,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t);\n}\n\n/**\n * A collection of functions for managing transactions.\n * Transactions allow edits to be batched into atomic units.\n * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n *\n * To avoid updating observers of the view state with intermediate results during a transaction,\n * use {@link ITreeCheckout#fork} and {@link ISharedTreeFork#merge}.\n */\nexport interface ITransaction {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): TransactionResult.Commit;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): TransactionResult.Abort;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tinProgress(): boolean;\n}\n\nclass Transaction implements ITransaction {\n\tpublic constructor(\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t) {}\n\n\tpublic start(): void {\n\t\tthis.branch.startTransaction();\n\t\tthis.branch.editor.enterTransaction();\n\t}\n\tpublic commit(): TransactionResult.Commit {\n\t\tthis.branch.commitTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Commit;\n\t}\n\tpublic abort(): TransactionResult.Abort {\n\t\tthis.branch.abortTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Abort;\n\t}\n\tpublic inProgress(): boolean {\n\t\treturn this.branch.isTransacting();\n\t}\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this view over all the new changes in the given view.\n\t * @param view - Either the root view or a view that was created by a call to `fork()`. It is not modified by this operation.\n\t */\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tprivate isDisposed = false;\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<DisposableRevertible>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * copies of the removed roots used as snapshots for reverting to previous state when transactions are aborted\n\t */\n\tprivate readonly removedRootsSnapshots: DetachedFieldIndex[] = [];\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\tpublic constructor(\n\t\tpublic readonly transaction: ITransaction,\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tpublic readonly events: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tprivate removedRoots: DetachedFieldIndex = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t),\n\t\t/** Optional logger for telemetry. */\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t) {\n\t\t// when a transaction is started, take a snapshot of the current state of removed roots\n\t\tbranch.on(\"transactionStarted\", () => {\n\t\t\tthis.removedRootsSnapshots.push(this.removedRoots.clone());\n\t\t});\n\t\t// when a transaction is committed, the latest snapshot of removed roots can be discarded\n\t\tbranch.on(\"transactionCommitted\", () => {\n\t\t\tthis.removedRootsSnapshots.pop();\n\t\t});\n\t\t// after a transaction is rolled back, revert removed roots back to the latest snapshot\n\t\tbranch.on(\"transactionRolledBack\", () => {\n\t\t\tconst snapshot = this.removedRootsSnapshots.pop();\n\t\t\tassert(snapshot !== undefined, 0x9ae /* a snapshot for removed roots does not exist */);\n\t\t\tthis.removedRoots = snapshot;\n\t\t});\n\n\t\t// We subscribe to `beforeChange` rather than `afterChange` here because it's possible that the change is invalid WRT our forest.\n\t\t// For example, a bug in the editor might produce a malformed change object and thus applying the change to the forest will throw an error.\n\t\t// In such a case we will crash here, preventing the change from being added to the commit graph, and preventing `afterChange` from firing.\n\t\t// One important consequence of this is that we will not submit the op containing the invalid change, since op submissions happens in response to `afterChange`.\n\t\tbranch.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\tconst revision =\n\t\t\t\t\tevent.type === \"replace\"\n\t\t\t\t\t\t? // Change events will always contain new commits\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tevent.newCommits[event.newCommits.length - 1]!.revision\n\t\t\t\t\t\t: event.change.revision;\n\n\t\t\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\t\t\tfor (const change of event.change.change.changes) {\n\t\t\t\t\tif (change.type === \"data\") {\n\t\t\t\t\t\tconst delta = intoDelta(tagChange(change.innerChange, revision));\n\t\t\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (change.type === \"schema\") {\n\t\t\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t\t\t// is also valid under the new schema.\n\t\t\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\t\t\t\t\t\t// under the old schema, but these changes will also be rolled back, thereby putting the forest\n\t\t\t\t\t\t// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\t\t\t\t\t\t// Case 2: A branch with a schema change may be rebased such that the schema change (because\n\t\t\t\t\t\t// of a constraint) is no longer applied.\n\t\t\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\t\t\t\t\t\t// ensure that these data changes are muted if they would render some trees invalid under the\n\t\t\t\t\t\t// original (reinstated) schema.\n\t\t\t\t\t\tstoredSchema.apply(change.innerChange.schema.new);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(\"Unknown Shared Tree change type.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.events.emit(\"afterBatch\");\n\t\t\t}\n\t\t\tif (event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\") {\n\t\t\t\tconst firstCommit = event.newCommits[0] ?? oob();\n\t\t\t\tconst transactionRevision = firstCommit.revision;\n\t\t\t\tfor (const transactionStep of event.removedCommits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbranch.on(\"commitApplied\", (data) => {\n\t\t\tconst commit = branch.getHead();\n\t\t\tconst { change, revision } = commit;\n\t\t\tlet withinEventContext = true;\n\n\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t? undefined\n\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a commitApplied event.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple commitApplied event listeners are registered.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to revert a revertible that has been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, data.kind);\n\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, branch.fork());\n\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t};\n\n\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible);\n\t\t\twithinEventContext = false;\n\t\t});\n\n\t\t// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the\n\t\t// trimmed revisions.\n\t\tbranch.on(\"ancestryTrimmed\", (revisions) => {\n\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\trevisions.forEach((revision) => {\n\t\t\t\t\t// get all the roots last created or used by the revision\n\t\t\t\t\tconst roots = this.removedRoots.getRootsLastTouchedByRevision(revision);\n\n\t\t\t\t\t// get the detached field for the root and delete it from the removed roots\n\t\t\t\t\tfor (const root of roots) {\n\t\t\t\t\t\tvisitor.destroy(this.removedRoots.toFieldKey(root), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.removedRoots.deleteRootsLastTouchedByRevision(revision);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[this.forest.acquireVisitor(), anchorVisitor],\n\t\t\t[anchorVisitor],\n\t\t);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(): void {\n\t\tassert(!this.isDisposed, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this.branch.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic fork(): TreeCheckout {\n\t\tthis.checkNotDisposed();\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this.branch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst transaction = new Transaction(branch);\n\t\treturn new TreeCheckout(\n\t\t\ttransaction,\n\t\t\tbranch,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tcreateEmitter(),\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\tpublic rebase(view: TreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!view.transaction.inProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tview.branch.rebaseOnto(this.branch);\n\t}\n\n\tpublic rebaseOnto(view: ITreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tview.rebase(this);\n\t}\n\n\tpublic merge(view: TreeCheckout): void;\n\tpublic merge(view: TreeCheckout, disposeView: boolean): void;\n\tpublic merge(view: TreeCheckout, disposeView = true): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!this.transaction.inProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (view.transaction.inProgress()) {\n\t\t\tview.transaction.commit();\n\t\t}\n\t\tthis.branch.merge(view.branch);\n\t\tif (disposeView) {\n\t\t\tview[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.isDisposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis.branch.dispose();\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\t/**\n\t * This sets the tip revision as the latest relevant revision for any removed roots that are loaded from a summary.\n\t * This needs to be called right after loading {@link this.removedRoots} from a summary to allow loaded data to be garbage collected.\n\t */\n\tpublic setTipRevisionForLoadedData(revision: RevisionTag): void {\n\t\tthis.removedRoots.setRevisionsForLoadedData(revision);\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: DisposableRevertible, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tif (this.branch.isTransacting()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\n\t\tlet change = makeAnonChange(\n\t\t\tthis.changeFamily.rebaser.invert(tagChange(commitToRevert.change, revision), false),\n\t\t);\n\n\t\tconst headCommit = this.branch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = makeAnonChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t);\n\t\t}\n\n\t\tthis.branch.apply(\n\t\t\tchange.change,\n\t\t\tthis.mintRevisionTag(),\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n}\n\n/**\n * Run a synchronous transaction on the given shared tree view.\n * This is a convenience helper around the {@link SharedTreeFork#transaction} APIs.\n * @param view - the view on which to run the transaction\n * @param transaction - the transaction function. This will be executed immediately. It is passed `view` as an argument for convenience.\n * If this function returns an `Abort` result then the transaction will be aborted. Otherwise, it will be committed.\n * @returns whether or not the transaction was committed or aborted\n */\nexport function runSynchronous(\n\tview: ITreeCheckout,\n\ttransaction: (view: ITreeCheckout) => TransactionResult | void,\n): TransactionResult {\n\tview.transaction.start();\n\tconst result = transaction(view);\n\treturn result === TransactionResult.Abort\n\t\t? view.transaction.abort()\n\t\t: view.transaction.commit();\n}\n\ninterface DisposableRevertible extends Revertible {\n\tdispose: () => void;\n}\n"]}
1
+ {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,uEAGkD;AAClD,gDAAkD;AAClD,+CA6B0B;AAC1B,iDAK4B;AAC5B,4DAOuC;AACvC,2DAAsF;AACtF,+CAA4F;AAE5F,2EAAsF;AAkItF;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,YAA2B,EAC3B,eAAkC,EAClC,gBAAkC,EAClC,IAYC;IAED,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAA,sBAAW,GAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,qCAA0B,EAAE,CAAC;IAChE,MAAM,mBAAmB,GAAG,EAAE,aAAa,EAAE,wBAAa,EAAE,CAAC;IAC7D,MAAM,wBAAwB,GAAG,CAAC,CAAC;IACnC,MAAM,YAAY,GACjB,IAAI,EAAE,YAAY;QAClB,IAAI,kDAAsB,CACzB,gBAAgB,EAChB,IAAI,EAAE,eAAe;YACpB,IAAA,8BAAmB,EAAC,mBAAmB,EAAE,wBAAwB,CAAC,EACnE,EAAE,aAAa,EAAE,wBAAa,EAAE,EAChC,IAAI,EAAE,wBAAwB,EAC9B,YAAY,CACZ,CAAC;IACH,MAAM,MAAM,GACX,IAAI,EAAE,MAAM;QACZ,IAAI,2BAAgB,CACnB;YACC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,E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B,CAAC;;AA5YF,oCA6YC;AAtXA;;;GAGG;AACoB,qCAAwB,GAAG,kBAAkB,AAArB,CAAsB;AAoXtE;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC7B,IAAmB,EACnB,WAA8D;IAE9D,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,KAAK,4BAAiB,CAAC,KAAK;QACxC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9B,CAAC;AATD,wCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { noopValidator } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\ttype Revertible,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeAnonChange,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\trootFieldKey,\n\ttagChange,\n\tvisitDelta,\n\ttype RevertibleFactory,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport { SharedTreeBranch, getChangeReplaceType } from \"../shared-tree-core/index.js\";\nimport { type IDisposable, TransactionResult, disposeSymbol, fail } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n */\nexport interface CheckoutEvents {\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a revertible change has been made to this view.\n\t *\n\t * Applications which subscribe to this event are expected to revert or discard revertibles they acquire (failure to do so will leak memory).\n\t * The provided revertible is inherently bound to the view that raised the event, calling `revert` won't apply to forked views.\n\t *\n\t * @param revertible - The revertible that can be used to revert the change.\n\t */\n\n\t/**\n\t * {@inheritdoc TreeViewEvents.commitApplied}\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n */\nexport interface ITreeCheckout extends AnchorLocator {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: ITransaction;\n\n\t/**\n\t * Spawn a new view which is based off of the current state of this view.\n\t * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.\n\t */\n\tfork(): ITreeCheckoutFork;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * @param disposeView - whether or not to dispose `view` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork, disposeView: boolean): void;\n\n\t/**\n\t * Rebase the given view onto this view.\n\t * @param view - a view which was created by a call to `fork()`. It is modified by this operation.\n\t */\n\trebase(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Events about this view.\n\t */\n\treadonly events: Listenable<CheckoutEvents>;\n\n\t/**\n\t * Events about the root of the tree in this view.\n\t */\n\treadonly rootEvents: Listenable<AnchorSetRootEvents>;\n\n\t/**\n\t * Returns a JsonableTree for each tree that was removed from (and not restored to) the document.\n\t * This list is guaranteed to contain all nodes that are recoverable through undo/redo on this checkout.\n\t * The list may also contain additional nodes.\n\t *\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t */\n\tgetRemovedRoots(): [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Creates a {@link TreeCheckout}.\n * @param args - an object containing optional components that will be used to build the view.\n * Any components not provided will be created by default.\n * @remarks This does not create a {@link SharedTree}, but rather a view with the minimal state\n * and functionality required to implement {@link ITreeCheckout}.\n */\nexport function createTreeCheckout(\n\tidCompressor: IIdCompressor,\n\tmintRevisionTag: () => RevisionTag,\n\trevisionTagCodec: RevisionTagCodec,\n\targs?: {\n\t\tbranch?: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tchangeFamily?: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tschema?: TreeStoredSchemaRepository;\n\t\tforest?: IEditableForest;\n\t\tfieldBatchCodec?: FieldBatchCodec;\n\t\tevents?: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>;\n\t\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t},\n): TreeCheckout {\n\tconst forest = args?.forest ?? buildForest();\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst defaultCodecOptions = { jsonValidator: noopValidator };\n\tconst defaultFieldBatchVersion = 1;\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ??\n\t\t\t\tmakeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),\n\t\t\t{ jsonValidator: noopValidator },\n\t\t\targs?.chunkCompressionStrategy,\n\t\t\tidCompressor,\n\t\t);\n\tconst branch =\n\t\targs?.branch ??\n\t\tnew SharedTreeBranch(\n\t\t\t{\n\t\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t\t\trevision: \"root\",\n\t\t\t},\n\t\t\tchangeFamily,\n\t\t\t() => idCompressor.generateCompressedId(),\n\t\t);\n\tconst events = args?.events ?? createEmitter();\n\n\tconst transaction = new Transaction(branch);\n\n\treturn new TreeCheckout(\n\t\ttransaction,\n\t\tbranch,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tevents,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t);\n}\n\n/**\n * A collection of functions for managing transactions.\n * Transactions allow edits to be batched into atomic units.\n * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n *\n * To avoid updating observers of the view state with intermediate results during a transaction,\n * use {@link ITreeCheckout#fork} and {@link ISharedTreeFork#merge}.\n */\nexport interface ITransaction {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): TransactionResult.Commit;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): TransactionResult.Abort;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tinProgress(): boolean;\n}\n\nclass Transaction implements ITransaction {\n\tpublic constructor(\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t) {}\n\n\tpublic start(): void {\n\t\tthis.branch.startTransaction();\n\t\tthis.branch.editor.enterTransaction();\n\t}\n\tpublic commit(): TransactionResult.Commit {\n\t\tthis.branch.commitTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Commit;\n\t}\n\tpublic abort(): TransactionResult.Abort {\n\t\tthis.branch.abortTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Abort;\n\t}\n\tpublic inProgress(): boolean {\n\t\treturn this.branch.isTransacting();\n\t}\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this view over all the new changes in the given view.\n\t * @param view - Either the root view or a view that was created by a call to `fork()`. It is not modified by this operation.\n\t */\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tprivate isDisposed = false;\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<DisposableRevertible>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * copies of the removed roots used as snapshots for reverting to previous state when transactions are aborted\n\t */\n\tprivate readonly removedRootsSnapshots: DetachedFieldIndex[] = [];\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\tpublic constructor(\n\t\tpublic readonly transaction: ITransaction,\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tpublic readonly events: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tprivate removedRoots: DetachedFieldIndex = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t),\n\t\t/** Optional logger for telemetry. */\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t) {\n\t\t// when a transaction is started, take a snapshot of the current state of removed roots\n\t\tbranch.on(\"transactionStarted\", () => {\n\t\t\tthis.removedRootsSnapshots.push(this.removedRoots.clone());\n\t\t});\n\t\t// when a transaction is committed, the latest snapshot of removed roots can be discarded\n\t\tbranch.on(\"transactionCommitted\", () => {\n\t\t\tthis.removedRootsSnapshots.pop();\n\t\t});\n\t\t// after a transaction is rolled back, revert removed roots back to the latest snapshot\n\t\tbranch.on(\"transactionRolledBack\", () => {\n\t\t\tconst snapshot = this.removedRootsSnapshots.pop();\n\t\t\tassert(snapshot !== undefined, 0x9ae /* a snapshot for removed roots does not exist */);\n\t\t\tthis.removedRoots = snapshot;\n\t\t});\n\n\t\t// We subscribe to `beforeChange` rather than `afterChange` here because it's possible that the change is invalid WRT our forest.\n\t\t// For example, a bug in the editor might produce a malformed change object and thus applying the change to the forest will throw an error.\n\t\t// In such a case we will crash here, preventing the change from being added to the commit graph, and preventing `afterChange` from firing.\n\t\t// One important consequence of this is that we will not submit the op containing the invalid change, since op submissions happens in response to `afterChange`.\n\t\tbranch.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\tconst revision =\n\t\t\t\t\tevent.type === \"replace\"\n\t\t\t\t\t\t? // Change events will always contain new commits\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tevent.newCommits[event.newCommits.length - 1]!.revision\n\t\t\t\t\t\t: event.change.revision;\n\n\t\t\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\t\t\tfor (const change of event.change.change.changes) {\n\t\t\t\t\tif (change.type === \"data\") {\n\t\t\t\t\t\tconst delta = intoDelta(tagChange(change.innerChange, revision));\n\t\t\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (change.type === \"schema\") {\n\t\t\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t\t\t// is also valid under the new schema.\n\t\t\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\t\t\t\t\t\t// under the old schema, but these changes will also be rolled back, thereby putting the forest\n\t\t\t\t\t\t// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\t\t\t\t\t\t// Case 2: A branch with a schema change may be rebased such that the schema change (because\n\t\t\t\t\t\t// of a constraint) is no longer applied.\n\t\t\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\t\t\t\t\t\t// ensure that these data changes are muted if they would render some trees invalid under the\n\t\t\t\t\t\t// original (reinstated) schema.\n\t\t\t\t\t\tstoredSchema.apply(change.innerChange.schema.new);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(\"Unknown Shared Tree change type.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.events.emit(\"afterBatch\");\n\t\t\t}\n\t\t\tif (event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\") {\n\t\t\t\tconst firstCommit = event.newCommits[0] ?? oob();\n\t\t\t\tconst transactionRevision = firstCommit.revision;\n\t\t\t\tfor (const transactionStep of event.removedCommits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbranch.on(\"commitApplied\", (data) => {\n\t\t\tconst commit = branch.getHead();\n\t\t\tconst { change, revision } = commit;\n\t\t\tlet withinEventContext = true;\n\n\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t? undefined\n\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a commitApplied event.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple commitApplied event listeners are registered.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to revert a revertible that has been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, data.kind);\n\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, branch.fork());\n\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t};\n\n\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible);\n\t\t\twithinEventContext = false;\n\t\t});\n\n\t\t// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the\n\t\t// trimmed revisions.\n\t\tbranch.on(\"ancestryTrimmed\", (revisions) => {\n\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\trevisions.forEach((revision) => {\n\t\t\t\t\t// get all the roots last created or used by the revision\n\t\t\t\t\tconst roots = this.removedRoots.getRootsLastTouchedByRevision(revision);\n\n\t\t\t\t\t// get the detached field for the root and delete it from the removed roots\n\t\t\t\t\tfor (const root of roots) {\n\t\t\t\t\t\tvisitor.destroy(this.removedRoots.toFieldKey(root), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.removedRoots.deleteRootsLastTouchedByRevision(revision);\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[this.forest.acquireVisitor(), anchorVisitor],\n\t\t\t[anchorVisitor],\n\t\t);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(): void {\n\t\tassert(!this.isDisposed, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this.branch.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic fork(): TreeCheckout {\n\t\tthis.checkNotDisposed();\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this.branch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst transaction = new Transaction(branch);\n\t\treturn new TreeCheckout(\n\t\t\ttransaction,\n\t\t\tbranch,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tcreateEmitter(),\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\tpublic rebase(view: TreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!view.transaction.inProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tview.branch.rebaseOnto(this.branch);\n\t}\n\n\tpublic rebaseOnto(view: ITreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tview.rebase(this);\n\t}\n\n\tpublic merge(view: TreeCheckout): void;\n\tpublic merge(view: TreeCheckout, disposeView: boolean): void;\n\tpublic merge(view: TreeCheckout, disposeView = true): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!this.transaction.inProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (view.transaction.inProgress()) {\n\t\t\tview.transaction.commit();\n\t\t}\n\t\tthis.branch.merge(view.branch);\n\t\tif (disposeView) {\n\t\t\tview[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.isDisposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis.branch.dispose();\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tthis.assertNoUntrackedRoots();\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\t/**\n\t * This sets the tip revision as the latest relevant revision for any removed roots that are loaded from a summary.\n\t * This needs to be called right after loading {@link this.removedRoots} from a summary to allow loaded data to be garbage collected.\n\t */\n\tpublic setTipRevisionForLoadedData(revision: RevisionTag): void {\n\t\tthis.removedRoots.setRevisionsForLoadedData(revision);\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: DisposableRevertible, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tif (this.branch.isTransacting()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\n\t\tlet change = makeAnonChange(\n\t\t\tthis.changeFamily.rebaser.invert(tagChange(commitToRevert.change, revision), false),\n\t\t);\n\n\t\tconst headCommit = this.branch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = makeAnonChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t);\n\t\t}\n\n\t\tthis.branch.apply(\n\t\t\tchange.change,\n\t\t\tthis.mintRevisionTag(),\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n\n\tprivate assertNoUntrackedRoots(): void {\n\t\tconst cursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst rootFields = new Set([rootFieldKey]);\n\t\tfor (const { root } of this.removedRoots.entries()) {\n\t\t\trootFields.add(this.removedRoots.toFieldKey(root));\n\t\t}\n\n\t\tif (!cursor.firstField()) {\n\t\t\treturn;\n\t\t}\n\n\t\tdo {\n\t\t\tconst field = cursor.getFieldKey();\n\t\t\tassert(\n\t\t\t\trootFields.has(field),\n\t\t\t\t0xa22 /* Forest has a root field which is unknown to the detached field index */,\n\t\t\t);\n\n\t\t\trootFields.delete(field);\n\t\t} while (cursor.nextField());\n\t}\n}\n\n/**\n * Run a synchronous transaction on the given shared tree view.\n * This is a convenience helper around the {@link SharedTreeFork#transaction} APIs.\n * @param view - the view on which to run the transaction\n * @param transaction - the transaction function. This will be executed immediately. It is passed `view` as an argument for convenience.\n * If this function returns an `Abort` result then the transaction will be aborted. Otherwise, it will be committed.\n * @returns whether or not the transaction was committed or aborted\n */\nexport function runSynchronous(\n\tview: ITreeCheckout,\n\ttransaction: (view: ITreeCheckout) => TransactionResult | void,\n): TransactionResult {\n\tview.transaction.start();\n\tconst result = transaction(view);\n\treturn result === TransactionResult.Abort\n\t\t? view.transaction.abort()\n\t\t: view.transaction.commit();\n}\n\ninterface DisposableRevertible extends Revertible {\n\tdispose: () => void;\n}\n"]}
@@ -204,7 +204,7 @@ class SharedTreeBranch extends index_js_2.EventEmitter {
204
204
  for (let i = commits.length - 1; i >= 0; i--) {
205
205
  const revision = this.mintRevisionTag();
206
206
  const commit = commits[i] ?? (0, index_js_3.fail)("This wont run because we are iterating through commits");
207
- const inverse = this.changeFamily.rebaser.changeRevision(this.changeFamily.rebaser.invert(commit, false), revision, commit.revision);
207
+ const inverse = this.changeFamily.rebaser.changeRevision(this.changeFamily.rebaser.invert(commit, true), revision, commit.revision);
208
208
  inverses.push((0, index_js_1.tagRollbackInverse)(inverse, revision, commit.revision));
209
209
  }
210
210
  const change = inverses.length > 0 ? this.changeFamily.rebaser.compose(inverses) : undefined;