@fluidframework/tree 2.10.0 → 2.11.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 (465) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/api-report/tree.alpha.api.md +47 -16
  3. package/api-report/tree.beta.api.md +5 -14
  4. package/api-report/tree.legacy.alpha.api.md +5 -14
  5. package/api-report/tree.legacy.public.api.md +5 -14
  6. package/api-report/tree.public.api.md +5 -14
  7. package/dist/alpha.d.ts +9 -0
  8. package/dist/core/forest/forest.d.ts +10 -2
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js.map +1 -1
  11. package/dist/core/index.d.ts +2 -2
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js +3 -2
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/rebase/utils.d.ts +1 -1
  16. package/dist/core/rebase/utils.d.ts.map +1 -1
  17. package/dist/core/rebase/utils.js +11 -8
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/revertible.d.ts +30 -1
  20. package/dist/core/revertible.d.ts.map +1 -1
  21. package/dist/core/revertible.js.map +1 -1
  22. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  23. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  24. package/dist/core/schema-stored/storedSchemaRepository.js +5 -5
  25. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  26. package/dist/core/tree/anchorSet.d.ts +2 -2
  27. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  28. package/dist/core/tree/anchorSet.js +21 -21
  29. package/dist/core/tree/anchorSet.js.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  31. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  32. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  33. package/dist/core/tree/index.d.ts +1 -1
  34. package/dist/core/tree/index.d.ts.map +1 -1
  35. package/dist/core/tree/index.js +2 -1
  36. package/dist/core/tree/index.js.map +1 -1
  37. package/dist/core/tree/visitorUtils.d.ts +25 -1
  38. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  39. package/dist/core/tree/visitorUtils.js +29 -1
  40. package/dist/core/tree/visitorUtils.js.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -2
  42. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/chunkedForest.js +24 -14
  44. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/uniformChunk.js +2 -2
  47. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  48. package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
  49. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  50. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  51. package/dist/feature-libraries/index.d.ts +1 -0
  52. package/dist/feature-libraries/index.d.ts.map +1 -1
  53. package/dist/feature-libraries/index.js +4 -1
  54. package/dist/feature-libraries/index.js.map +1 -1
  55. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
  56. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  57. package/dist/feature-libraries/indexing/anchorTreeIndex.js +361 -0
  58. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  59. package/dist/feature-libraries/indexing/index.d.ts +7 -0
  60. package/dist/feature-libraries/indexing/index.d.ts.map +1 -0
  61. package/dist/feature-libraries/indexing/index.js +11 -0
  62. package/dist/feature-libraries/indexing/index.js.map +1 -0
  63. package/dist/feature-libraries/indexing/types.d.ts +32 -0
  64. package/dist/feature-libraries/indexing/types.d.ts.map +1 -0
  65. package/dist/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  66. package/dist/feature-libraries/indexing/types.js.map +1 -0
  67. package/dist/feature-libraries/object-forest/objectForest.d.ts +5 -2
  68. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  69. package/dist/feature-libraries/object-forest/objectForest.js +21 -11
  70. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  71. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  72. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  73. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  74. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +3 -2
  75. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  76. package/dist/index.d.ts +4 -4
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +4 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/packageVersion.d.ts +1 -1
  81. package/dist/packageVersion.js +1 -1
  82. package/dist/packageVersion.js.map +1 -1
  83. package/dist/shared-tree/index.d.ts +1 -1
  84. package/dist/shared-tree/index.d.ts.map +1 -1
  85. package/dist/shared-tree/index.js +1 -2
  86. package/dist/shared-tree/index.js.map +1 -1
  87. package/dist/shared-tree/schematizingTreeView.d.ts +7 -1
  88. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  89. package/dist/shared-tree/schematizingTreeView.js +31 -30
  90. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  91. package/dist/shared-tree/sharedTree.d.ts +3 -0
  92. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  93. package/dist/shared-tree/sharedTree.js +56 -20
  94. package/dist/shared-tree/sharedTree.js.map +1 -1
  95. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  96. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -3
  97. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  98. package/dist/shared-tree/treeCheckout.d.ts +28 -64
  99. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  100. package/dist/shared-tree/treeCheckout.js +152 -129
  101. package/dist/shared-tree/treeCheckout.js.map +1 -1
  102. package/dist/shared-tree-core/branch.d.ts +25 -81
  103. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  104. package/dist/shared-tree-core/branch.js +72 -151
  105. package/dist/shared-tree-core/branch.js.map +1 -1
  106. package/dist/shared-tree-core/branchCommitEnricher.d.ts +19 -33
  107. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  108. package/dist/shared-tree-core/branchCommitEnricher.js +73 -54
  109. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  110. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  111. package/dist/shared-tree-core/defaultResubmitMachine.js +2 -1
  112. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  113. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  114. package/dist/shared-tree-core/editManager.js +2 -2
  115. package/dist/shared-tree-core/editManager.js.map +1 -1
  116. package/dist/shared-tree-core/index.d.ts +1 -1
  117. package/dist/shared-tree-core/index.d.ts.map +1 -1
  118. package/dist/shared-tree-core/index.js +4 -3
  119. package/dist/shared-tree-core/index.js.map +1 -1
  120. package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -2
  121. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  122. package/dist/shared-tree-core/sharedTreeCore.js +11 -52
  123. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  124. package/dist/shared-tree-core/transaction.d.ts +108 -0
  125. package/dist/shared-tree-core/transaction.d.ts.map +1 -0
  126. package/dist/shared-tree-core/transaction.js +99 -0
  127. package/dist/shared-tree-core/transaction.js.map +1 -0
  128. package/dist/shared-tree-core/transactionEnricher.d.ts +8 -13
  129. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  130. package/dist/shared-tree-core/transactionEnricher.js +41 -21
  131. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  132. package/dist/simple-tree/api/identifierIndex.d.ts +21 -0
  133. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -0
  134. package/dist/simple-tree/api/identifierIndex.js +45 -0
  135. package/dist/simple-tree/api/identifierIndex.js.map +1 -0
  136. package/dist/simple-tree/api/index.d.ts +2 -0
  137. package/dist/simple-tree/api/index.d.ts.map +1 -1
  138. package/dist/simple-tree/api/index.js +5 -1
  139. package/dist/simple-tree/api/index.js.map +1 -1
  140. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +9 -7
  141. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  142. package/dist/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  143. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  144. package/dist/simple-tree/api/simpleTreeIndex.js +91 -0
  145. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
  146. package/dist/simple-tree/api/tree.d.ts +4 -5
  147. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  148. package/dist/simple-tree/api/tree.js.map +1 -1
  149. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  150. package/dist/simple-tree/core/index.d.ts +1 -1
  151. package/dist/simple-tree/core/index.d.ts.map +1 -1
  152. package/dist/simple-tree/core/index.js +2 -1
  153. package/dist/simple-tree/core/index.js.map +1 -1
  154. package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -2
  155. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  156. package/dist/simple-tree/core/treeNodeKernel.js +53 -22
  157. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  158. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  159. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  160. package/dist/simple-tree/core/unhydratedFlexTree.js +2 -2
  161. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  162. package/dist/simple-tree/index.d.ts +1 -1
  163. package/dist/simple-tree/index.d.ts.map +1 -1
  164. package/dist/simple-tree/index.js +4 -2
  165. package/dist/simple-tree/index.js.map +1 -1
  166. package/dist/simple-tree/objectNode.d.ts +7 -2
  167. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  168. package/dist/simple-tree/objectNode.js.map +1 -1
  169. package/dist/simple-tree/toMapTree.js +3 -3
  170. package/dist/simple-tree/toMapTree.js.map +1 -1
  171. package/dist/util/index.d.ts +1 -2
  172. package/dist/util/index.d.ts.map +1 -1
  173. package/dist/util/index.js +5 -4
  174. package/dist/util/index.js.map +1 -1
  175. package/dist/util/typeCheck.d.ts +6 -1
  176. package/dist/util/typeCheck.d.ts.map +1 -1
  177. package/dist/util/typeCheck.js.map +1 -1
  178. package/dist/util/typeCheckTests.d.ts +14 -2
  179. package/dist/util/typeCheckTests.d.ts.map +1 -1
  180. package/dist/util/typeCheckTests.js.map +1 -1
  181. package/dist/util/utils.d.ts +29 -0
  182. package/dist/util/utils.d.ts.map +1 -1
  183. package/dist/util/utils.js +13 -1
  184. package/dist/util/utils.js.map +1 -1
  185. package/lib/alpha.d.ts +9 -0
  186. package/lib/core/forest/forest.d.ts +10 -2
  187. package/lib/core/forest/forest.d.ts.map +1 -1
  188. package/lib/core/forest/forest.js.map +1 -1
  189. package/lib/core/index.d.ts +2 -2
  190. package/lib/core/index.d.ts.map +1 -1
  191. package/lib/core/index.js +2 -2
  192. package/lib/core/index.js.map +1 -1
  193. package/lib/core/rebase/utils.d.ts +1 -1
  194. package/lib/core/rebase/utils.d.ts.map +1 -1
  195. package/lib/core/rebase/utils.js +11 -8
  196. package/lib/core/rebase/utils.js.map +1 -1
  197. package/lib/core/revertible.d.ts +30 -1
  198. package/lib/core/revertible.d.ts.map +1 -1
  199. package/lib/core/revertible.js.map +1 -1
  200. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  201. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  202. package/lib/core/schema-stored/storedSchemaRepository.js +1 -1
  203. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  204. package/lib/core/tree/anchorSet.d.ts +2 -2
  205. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  206. package/lib/core/tree/anchorSet.js +1 -1
  207. package/lib/core/tree/anchorSet.js.map +1 -1
  208. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  209. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  210. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  211. package/lib/core/tree/index.d.ts +1 -1
  212. package/lib/core/tree/index.d.ts.map +1 -1
  213. package/lib/core/tree/index.js +1 -1
  214. package/lib/core/tree/index.js.map +1 -1
  215. package/lib/core/tree/visitorUtils.d.ts +25 -1
  216. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  217. package/lib/core/tree/visitorUtils.js +27 -0
  218. package/lib/core/tree/visitorUtils.js.map +1 -1
  219. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -2
  220. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  221. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -8
  222. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  223. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  224. package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -3
  225. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  226. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  227. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  228. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  229. package/lib/feature-libraries/index.d.ts +1 -0
  230. package/lib/feature-libraries/index.d.ts.map +1 -1
  231. package/lib/feature-libraries/index.js +1 -0
  232. package/lib/feature-libraries/index.js.map +1 -1
  233. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +132 -0
  234. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  235. package/lib/feature-libraries/indexing/anchorTreeIndex.js +356 -0
  236. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  237. package/lib/feature-libraries/indexing/index.d.ts +7 -0
  238. package/lib/feature-libraries/indexing/index.d.ts.map +1 -0
  239. package/lib/{events → feature-libraries/indexing}/index.js +1 -1
  240. package/lib/feature-libraries/indexing/index.js.map +1 -0
  241. package/lib/feature-libraries/indexing/types.d.ts +32 -0
  242. package/lib/feature-libraries/indexing/types.d.ts.map +1 -0
  243. package/lib/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  244. package/lib/feature-libraries/indexing/types.js.map +1 -0
  245. package/lib/feature-libraries/object-forest/objectForest.d.ts +5 -2
  246. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  247. package/lib/feature-libraries/object-forest/objectForest.js +15 -5
  248. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  249. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  250. package/lib/feature-libraries/sequence-field/invert.js +4 -4
  251. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  252. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -3
  253. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  254. package/lib/index.d.ts +4 -4
  255. package/lib/index.d.ts.map +1 -1
  256. package/lib/index.js +1 -1
  257. package/lib/index.js.map +1 -1
  258. package/lib/packageVersion.d.ts +1 -1
  259. package/lib/packageVersion.js +1 -1
  260. package/lib/packageVersion.js.map +1 -1
  261. package/lib/shared-tree/index.d.ts +1 -1
  262. package/lib/shared-tree/index.d.ts.map +1 -1
  263. package/lib/shared-tree/index.js +1 -1
  264. package/lib/shared-tree/index.js.map +1 -1
  265. package/lib/shared-tree/schematizingTreeView.d.ts +7 -1
  266. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  267. package/lib/shared-tree/schematizingTreeView.js +2 -2
  268. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  269. package/lib/shared-tree/sharedTree.d.ts +3 -0
  270. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  271. package/lib/shared-tree/sharedTree.js +37 -1
  272. package/lib/shared-tree/sharedTree.js.map +1 -1
  273. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  274. package/lib/shared-tree/sharedTreeChangeFamily.js +5 -5
  275. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  276. package/lib/shared-tree/treeCheckout.d.ts +28 -64
  277. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  278. package/lib/shared-tree/treeCheckout.js +140 -116
  279. package/lib/shared-tree/treeCheckout.js.map +1 -1
  280. package/lib/shared-tree-core/branch.d.ts +25 -81
  281. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  282. package/lib/shared-tree-core/branch.js +72 -151
  283. package/lib/shared-tree-core/branch.js.map +1 -1
  284. package/lib/shared-tree-core/branchCommitEnricher.d.ts +19 -33
  285. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  286. package/lib/shared-tree-core/branchCommitEnricher.js +74 -55
  287. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  288. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  289. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  290. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  291. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  292. package/lib/shared-tree-core/editManager.js +1 -1
  293. package/lib/shared-tree-core/editManager.js.map +1 -1
  294. package/lib/shared-tree-core/index.d.ts +1 -1
  295. package/lib/shared-tree-core/index.d.ts.map +1 -1
  296. package/lib/shared-tree-core/index.js +1 -1
  297. package/lib/shared-tree-core/index.js.map +1 -1
  298. package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -2
  299. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  300. package/lib/shared-tree-core/sharedTreeCore.js +12 -53
  301. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  302. package/lib/shared-tree-core/transaction.d.ts +108 -0
  303. package/lib/shared-tree-core/transaction.d.ts.map +1 -0
  304. package/lib/shared-tree-core/transaction.js +95 -0
  305. package/lib/shared-tree-core/transaction.js.map +1 -0
  306. package/lib/shared-tree-core/transactionEnricher.d.ts +8 -13
  307. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  308. package/lib/shared-tree-core/transactionEnricher.js +41 -21
  309. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  310. package/lib/simple-tree/api/identifierIndex.d.ts +21 -0
  311. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -0
  312. package/lib/simple-tree/api/identifierIndex.js +41 -0
  313. package/lib/simple-tree/api/identifierIndex.js.map +1 -0
  314. package/lib/simple-tree/api/index.d.ts +2 -0
  315. package/lib/simple-tree/api/index.d.ts.map +1 -1
  316. package/lib/simple-tree/api/index.js +2 -0
  317. package/lib/simple-tree/api/index.js.map +1 -1
  318. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +11 -9
  319. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  320. package/lib/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  321. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  322. package/lib/simple-tree/api/simpleTreeIndex.js +87 -0
  323. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
  324. package/lib/simple-tree/api/tree.d.ts +4 -5
  325. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  326. package/lib/simple-tree/api/tree.js.map +1 -1
  327. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  328. package/lib/simple-tree/core/index.d.ts +1 -1
  329. package/lib/simple-tree/core/index.d.ts.map +1 -1
  330. package/lib/simple-tree/core/index.js +1 -1
  331. package/lib/simple-tree/core/index.js.map +1 -1
  332. package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -2
  333. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  334. package/lib/simple-tree/core/treeNodeKernel.js +31 -1
  335. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  336. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  337. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  338. package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
  339. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  340. package/lib/simple-tree/index.d.ts +1 -1
  341. package/lib/simple-tree/index.d.ts.map +1 -1
  342. package/lib/simple-tree/index.js +1 -1
  343. package/lib/simple-tree/index.js.map +1 -1
  344. package/lib/simple-tree/objectNode.d.ts +7 -2
  345. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  346. package/lib/simple-tree/objectNode.js.map +1 -1
  347. package/lib/simple-tree/toMapTree.js +5 -5
  348. package/lib/simple-tree/toMapTree.js.map +1 -1
  349. package/lib/util/index.d.ts +1 -2
  350. package/lib/util/index.d.ts.map +1 -1
  351. package/lib/util/index.js +1 -2
  352. package/lib/util/index.js.map +1 -1
  353. package/lib/util/typeCheck.d.ts +6 -1
  354. package/lib/util/typeCheck.d.ts.map +1 -1
  355. package/lib/util/typeCheck.js.map +1 -1
  356. package/lib/util/typeCheckTests.d.ts +14 -2
  357. package/lib/util/typeCheckTests.d.ts.map +1 -1
  358. package/lib/util/typeCheckTests.js.map +1 -1
  359. package/lib/util/utils.d.ts +29 -0
  360. package/lib/util/utils.d.ts.map +1 -1
  361. package/lib/util/utils.js +9 -0
  362. package/lib/util/utils.js.map +1 -1
  363. package/package.json +22 -22
  364. package/src/core/forest/forest.ts +12 -1
  365. package/src/core/index.ts +8 -1
  366. package/src/core/rebase/utils.ts +12 -10
  367. package/src/core/revertible.ts +35 -1
  368. package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
  369. package/src/core/tree/anchorSet.ts +2 -1
  370. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  371. package/src/core/tree/index.ts +1 -0
  372. package/src/core/tree/visitorUtils.ts +56 -1
  373. package/src/feature-libraries/chunked-forest/chunkedForest.ts +33 -7
  374. package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -3
  375. package/src/feature-libraries/flex-tree/context.ts +1 -1
  376. package/src/feature-libraries/index.ts +9 -0
  377. package/src/feature-libraries/indexing/anchorTreeIndex.ts +453 -0
  378. package/src/feature-libraries/indexing/index.ts +11 -0
  379. package/src/feature-libraries/indexing/types.ts +37 -0
  380. package/src/feature-libraries/object-forest/objectForest.ts +22 -4
  381. package/src/feature-libraries/sequence-field/invert.ts +4 -4
  382. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -4
  383. package/src/index.ts +16 -6
  384. package/src/packageVersion.ts +1 -1
  385. package/src/shared-tree/index.ts +0 -2
  386. package/src/shared-tree/schematizingTreeView.ts +7 -7
  387. package/src/shared-tree/sharedTree.ts +60 -6
  388. package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
  389. package/src/shared-tree/treeCheckout.ts +186 -193
  390. package/src/shared-tree-core/branch.ts +93 -220
  391. package/src/shared-tree-core/branchCommitEnricher.ts +69 -64
  392. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  393. package/src/shared-tree-core/editManager.ts +1 -1
  394. package/src/shared-tree-core/index.ts +9 -2
  395. package/src/shared-tree-core/sharedTreeCore.ts +17 -62
  396. package/src/shared-tree-core/transaction.ts +165 -0
  397. package/src/shared-tree-core/transactionEnricher.ts +30 -24
  398. package/src/simple-tree/api/identifierIndex.ts +64 -0
  399. package/src/simple-tree/api/index.ts +5 -0
  400. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
  401. package/src/simple-tree/api/simpleTreeIndex.ts +231 -0
  402. package/src/simple-tree/api/tree.ts +8 -5
  403. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  404. package/src/simple-tree/core/index.ts +1 -0
  405. package/src/simple-tree/core/treeNodeKernel.ts +37 -2
  406. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -1
  407. package/src/simple-tree/index.ts +4 -0
  408. package/src/simple-tree/objectNode.ts +19 -12
  409. package/src/simple-tree/toMapTree.ts +5 -5
  410. package/src/util/index.ts +3 -1
  411. package/src/util/typeCheck.ts +6 -1
  412. package/src/util/typeCheckTests.ts +11 -1
  413. package/src/util/utils.ts +38 -0
  414. package/dist/events/emitter.d.ts +0 -139
  415. package/dist/events/emitter.d.ts.map +0 -1
  416. package/dist/events/emitter.js +0 -165
  417. package/dist/events/emitter.js.map +0 -1
  418. package/dist/events/index.d.ts +0 -7
  419. package/dist/events/index.d.ts.map +0 -1
  420. package/dist/events/index.js +0 -11
  421. package/dist/events/index.js.map +0 -1
  422. package/dist/events/interop.d.ts +0 -30
  423. package/dist/events/interop.d.ts.map +0 -1
  424. package/dist/events/interop.js.map +0 -1
  425. package/dist/events/listeners.d.ts +0 -76
  426. package/dist/events/listeners.d.ts.map +0 -1
  427. package/dist/events/listeners.js +0 -7
  428. package/dist/events/listeners.js.map +0 -1
  429. package/dist/shared-tree-core/transactionStack.d.ts +0 -29
  430. package/dist/shared-tree-core/transactionStack.d.ts.map +0 -1
  431. package/dist/shared-tree-core/transactionStack.js +0 -41
  432. package/dist/shared-tree-core/transactionStack.js.map +0 -1
  433. package/dist/util/transactionResult.d.ts +0 -19
  434. package/dist/util/transactionResult.d.ts.map +0 -1
  435. package/dist/util/transactionResult.js +0 -23
  436. package/dist/util/transactionResult.js.map +0 -1
  437. package/lib/events/emitter.d.ts +0 -139
  438. package/lib/events/emitter.d.ts.map +0 -1
  439. package/lib/events/emitter.js +0 -160
  440. package/lib/events/emitter.js.map +0 -1
  441. package/lib/events/index.d.ts +0 -7
  442. package/lib/events/index.d.ts.map +0 -1
  443. package/lib/events/index.js.map +0 -1
  444. package/lib/events/interop.d.ts +0 -30
  445. package/lib/events/interop.d.ts.map +0 -1
  446. package/lib/events/interop.js.map +0 -1
  447. package/lib/events/listeners.d.ts +0 -76
  448. package/lib/events/listeners.d.ts.map +0 -1
  449. package/lib/events/listeners.js +0 -6
  450. package/lib/events/listeners.js.map +0 -1
  451. package/lib/shared-tree-core/transactionStack.d.ts +0 -29
  452. package/lib/shared-tree-core/transactionStack.d.ts.map +0 -1
  453. package/lib/shared-tree-core/transactionStack.js +0 -37
  454. package/lib/shared-tree-core/transactionStack.js.map +0 -1
  455. package/lib/util/transactionResult.d.ts +0 -19
  456. package/lib/util/transactionResult.d.ts.map +0 -1
  457. package/lib/util/transactionResult.js +0 -20
  458. package/lib/util/transactionResult.js.map +0 -1
  459. package/src/events/README.md +0 -3
  460. package/src/events/emitter.ts +0 -256
  461. package/src/events/index.ts +0 -19
  462. package/src/events/interop.ts +0 -38
  463. package/src/events/listeners.ts +0 -80
  464. package/src/shared-tree-core/transactionStack.ts +0 -45
  465. package/src/util/transactionResult.ts +0 -19
@@ -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,+CA4B0B;AAC1B,iDAK4B;AAC5B,4DAQuC;AACvC,2DAIsC;AACtC,+CAAqF;AAErF,2EAAsF;AAYtF,uEAAuE;AA2JvE;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,YAA2B,EAC3B,eAAkC,EAClC,gBAAkC,EAClC,IAaC;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,mBAA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K,CAAC,IAAI,KAAK,SAAS;YACxB,IAAA,+BAAoB,EAAC,KAAK,CAAC,KAAK,mBAAmB,CACnD,CAAC;IACH,CAAC;;AA/eF,oCAgfC;AAvdA;;;GAGG;AACoB,qCAAwB,GAAG,kBAAkB,AAArB,CAAsB;AAqdtE;;;;;;;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\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\tcreateNodeKeyManager,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport {\n\tSharedTreeBranch,\n\tgetChangeReplaceType,\n\ttype SharedTreeBranchChange,\n} from \"../shared-tree-core/index.js\";\nimport { Breakable, 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\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport type {\n\tImplicitFieldSchema,\n\tReadSchema,\n\tTreeView,\n\tTreeViewConfiguration,\n\tUnsafeUnknownSchema,\n\tViewableTree,\n} from \"../simple-tree/index.js\";\nimport { SchematizingSimpleTreeView } from \"./schematizingTreeView.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 change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about e.g. local vs remote changes.\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * A \"version control\"-style branch of a SharedTree.\n * @remarks Branches may be used to coordinate edits to a SharedTree, e.g. via merge and rebase operations.\n * Changes applied to a branch of a branch only apply to that branch and are isolated from other branches.\n * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.\n * @alpha @sealed\n */\nexport interface BranchableTree extends ViewableTree {\n\t/**\n\t * Spawn a new branch which is based off of the current state of this branch.\n\t * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.\n\t */\n\tbranch(): TreeBranchFork;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param view - a branch which was created by a call to `branch()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t * A \"changed\" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.\n\t */\n\tmerge(branch: TreeBranchFork): void;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranchFork, disposeMerged: boolean): void;\n\n\t/**\n\t * Rebase the given branch onto this branch.\n\t * @param branch - a branch which was created by a call to `branch()`. It is modified by this operation.\n\t */\n\trebase(branch: TreeBranchFork): void;\n}\n\n/**\n * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.\n * @remarks This branch should be disposed when it is no longer needed in order to free resources.\n * @alpha @sealed\n */\nexport interface TreeBranchFork extends BranchableTree, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this branch over all the new changes in the given branch.\n\t * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.\n\t */\n\trebaseOnto(branch: BranchableTree): 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, ViewableTree {\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\tbranch(): ITreeCheckoutFork;\n\n\tmerge(checkout: ITreeCheckoutFork): void;\n\n\tmerge(checkout: ITreeCheckoutFork, disposeMerged: boolean): void;\n\n\trebase(checkout: 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\tbreaker?: Breakable;\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\tfalse,\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\targs?.breaker,\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#branch} 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 {\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\tpublic disposed = false;\n\n\tprivate readonly views = new Set<TreeView<ImplicitFieldSchema>>();\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\t/** True if and only if this checkout is for a forked branch and not the \"main branch\" of the tree. */\n\t\tpublic readonly isBranch: boolean,\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\tprivate readonly breaker: Breakable = new Breakable(\"TreeCheckout\"),\n\t) {\n\t\t// when a transaction is started, take a snapshot of the current state of removed roots\n\t\t_branch.events.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\t_branch.events.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\t_branch.events.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\t_branch.events.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\t_branch.events.on(\"afterChange\", (event) => {\n\t\t\t// The following logic allows revertibles to be generated for the change.\n\t\t\t// Currently only appends (including merges) and transaction commits are supported.\n\t\t\tif (!_branch.isTransacting()) {\n\t\t\t\tif (\n\t\t\t\t\tevent.type === \"append\" ||\n\t\t\t\t\t(event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\")\n\t\t\t\t) {\n\t\t\t\t\t// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.\n\t\t\t\t\t// Figure out a way to generate revertibles before the commits are garbage collected.\n\t\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\t\tconst kind = event.type === \"append\" ? event.kind : CommitKind.Default;\n\t\t\t\t\t\tconst { change, revision } = commit;\n\n\t\t\t\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a changed event.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\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\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, kind);\n\t\t\t\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\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\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, _branch.fork(commit));\n\t\t\t\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\tlet withinEventContext = true;\n\t\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: true, kind }, getRevertible);\n\t\t\t\t\t\twithinEventContext = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (this.isRemoteChangeEvent(event)) {\n\t\t\t\t\t// TODO: figure out how to plumb through commit kind info for remote changes\n\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: false, kind: CommitKind.Default });\n\t\t\t\t}\n\t\t\t}\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\t_branch.events.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(usageError?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (usageError !== undefined) {\n\t\t\t\tthrow new UsageError(usageError);\n\t\t\t}\n\t\t\tassert(false, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t\t}\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\tconst view = new SchematizingSimpleTreeView(\n\t\t\tthis,\n\t\t\tconfig,\n\t\t\tcreateNodeKeyManager(this.idCompressor),\n\t\t\tthis.breaker,\n\t\t\t() => {\n\t\t\t\tthis.views.delete(view);\n\t\t\t},\n\t\t);\n\t\tthis.views.add(view);\n\t\treturn view;\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors.events;\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 branch(): TreeCheckout {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The parent branch has already been disposed and can no longer create new branches.\",\n\t\t);\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\ttrue,\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\tthis.breaker,\n\t\t);\n\t}\n\n\tpublic rebase(checkout: TreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tassert(\n\t\t\t!checkout.transaction.inProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tassert(\n\t\t\tcheckout.isBranch,\n\t\t\t0xa5d /* The main branch cannot be rebased onto another branch. */,\n\t\t);\n\t\tcheckout._branch.rebaseOnto(this._branch);\n\t}\n\n\tpublic rebaseOnto(checkout: ITreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.rebase(this);\n\t}\n\n\tpublic merge(checkout: TreeCheckout): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged: boolean): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged = true): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch merge has been disposed and cannot be merged.\",\n\t\t);\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 (checkout.transaction.inProgress()) {\n\t\t\tcheckout.transaction.commit();\n\t\t}\n\t\tthis._branch.merge(checkout._branch);\n\t\tif (disposeMerged && checkout.isBranch) {\n\t\t\t// Dispose the merged checkout unless it is the main branch.\n\t\t\tcheckout[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 dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The branch has already been disposed and cannot be disposed again.\",\n\t\t);\n\t\tthis.disposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis._branch.dispose();\n\t\tfor (const view of this.views) {\n\t\t\tview.dispose();\n\t\t}\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\t\tconst revisionForInvert = this.mintRevisionTag();\n\n\t\tlet change = tagChange(\n\t\t\tthis.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert),\n\t\t\trevisionForInvert,\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 = tagChange(\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\trevisionForInvert,\n\t\t\t);\n\t\t}\n\n\t\tthis._branch.apply(\n\t\t\tchange,\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\t/**\n\t * `true` iff the given branch change event is due to a remote change\n\t */\n\tprivate isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {\n\t\treturn (\n\t\t\t// remote changes are only ever applied to the main branch\n\t\t\t!this.isBranch &&\n\t\t\t// remote changes are applied to the main branch by rebasing it onto the trunk,\n\t\t\t// no other rebases are allowed on the main branch so this means any replaces that are not\n\t\t\t// transaction commits are remote changes\n\t\t\tevent.type === \"replace\" &&\n\t\t\tgetChangeReplaceType(event) !== \"transactionCommit\"\n\t\t);\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,kEAA8E;AAM9E,+DAA6D;AAE7D,uEAGkD;AAClD,gDAAkD;AAClD,+CA4B0B;AAC1B,4DAQuC;AACvC,2DAQsC;AACtC,+CAAoF;AAEpF,2EAAsF;AAatF,uEAAoF;AAqKpF;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,YAA2B,EAC3B,eAAkC,EAClC,gBAAkC,EAClC,IAaC;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,Y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,KAAK,CAAC,KAAK,QAAQ,CACxC,CAAC;IACH,CAAC;;AAvjBF,oCAwjBC;AApiBA;;;GAGG;AACoB,qCAAwB,GAAG,kBAAkB,AAArB,CAAsB","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 type {\n\tHasListeners,\n\tIEmitter,\n\tListenable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\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\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\trootFieldKey,\n\ttagChange,\n\tvisitDelta,\n\ttype RevertibleAlphaFactory,\n\ttype RevertibleAlpha,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tcreateNodeKeyManager,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport {\n\tSharedTreeBranch,\n\tTransactionResult,\n\tTransactionStack,\n\tgetChangeReplaceType,\n\tonForkTransitive,\n\ttype SharedTreeBranchChange,\n\ttype Transactor,\n} from \"../shared-tree-core/index.js\";\nimport { Breakable, disposeSymbol, fail, getLast, hasSome } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport type {\n\tImplicitFieldSchema,\n\tReadSchema,\n\tTreeView,\n\tTreeViewConfiguration,\n\tUnsafeUnknownSchema,\n\tViewableTree,\n\tTreeBranch,\n} from \"../simple-tree/index.js\";\nimport { getCheckout, SchematizingSimpleTreeView } from \"./schematizingTreeView.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 change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about e.g. local vs remote changes.\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;\n\n\t/**\n\t * Fired when a new branch is created from this checkout.\n\t */\n\tfork(branch: ITreeCheckout): void;\n\n\t/**\n\t * Fired when the checkout is disposed.\n\t */\n\tdispose(): void;\n}\n\n/**\n * A \"version control\"-style branch of a SharedTree.\n * @remarks Branches may be used to coordinate edits to a SharedTree, e.g. via merge and rebase operations.\n * Changes applied to a branch of a branch only apply to that branch and are isolated from other branches.\n * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.\n * @alpha @sealed\n */\nexport interface BranchableTree extends ViewableTree {\n\t/**\n\t * Spawn a new branch which is based off of the current state of this branch.\n\t * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.\n\t */\n\tbranch(): TreeBranchFork;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param view - a branch which was created by a call to `branch()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t * A \"changed\" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.\n\t */\n\tmerge(branch: TreeBranchFork): void;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranchFork, disposeMerged: boolean): void;\n\n\t/**\n\t * Rebase the given branch onto this branch.\n\t * @param branch - a branch which was created by a call to `branch()`. It is modified by this operation.\n\t */\n\trebase(branch: TreeBranchFork): void;\n}\n\n/**\n * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.\n * @remarks This branch should be disposed when it is no longer needed in order to free resources.\n * @alpha @sealed\n */\nexport interface TreeBranchFork extends BranchableTree, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this branch over all the new changes in the given branch.\n\t * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.\n\t */\n\trebaseOnto(branch: BranchableTree): 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, ViewableTree {\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: Transactor;\n\n\tbranch(): ITreeCheckoutFork;\n\n\tmerge(checkout: ITreeCheckoutFork): void;\n\n\tmerge(checkout: ITreeCheckoutFork, disposeMerged: boolean): void;\n\n\trebase(checkout: 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\tbreaker?: Breakable;\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\treturn new TreeCheckout(\n\t\tbranch,\n\t\tfalse,\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\targs?.breaker,\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 {\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\tpublic disposed = false;\n\n\tprivate readonly views = new Set<TreeView<ImplicitFieldSchema>>();\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<RevertibleAlpha>();\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 * 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\tprivate readonly _branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\t/** True if and only if this checkout is for a forked branch and not the \"main branch\" of the tree. */\n\t\tpublic readonly isBranch: boolean,\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\tprivate readonly breaker: Breakable = new Breakable(\"TreeCheckout\"),\n\t) {\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\t_branch.events.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\tlet revision: RevisionTag | undefined;\n\t\t\t\tif (event.type === \"replace\") {\n\t\t\t\t\tassert(\n\t\t\t\t\t\thasSome(event.newCommits),\n\t\t\t\t\t\t0xa81 /* Expected new commit for non no-op change event */,\n\t\t\t\t\t);\n\t\t\t\t\trevision = getLast(event.newCommits).revision;\n\t\t\t\t} else {\n\t\t\t\t\trevision = event.change.revision;\n\t\t\t\t}\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});\n\t\t_branch.events.on(\"afterChange\", (event) => {\n\t\t\t// The following logic allows revertibles to be generated for the change.\n\t\t\t// Currently only appends (including merges) and transaction commits are supported.\n\t\t\tif (!this.transaction.isInProgress()) {\n\t\t\t\tif (\n\t\t\t\t\tevent.type === \"append\" ||\n\t\t\t\t\t(event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\")\n\t\t\t\t) {\n\t\t\t\t\t// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.\n\t\t\t\t\t// Figure out a way to generate revertibles before the commits are garbage collected.\n\t\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\t\tconst kind = event.type === \"append\" ? event.kind : CommitKind.Default;\n\t\t\t\t\t\tconst { change, revision } = commit;\n\n\t\t\t\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: (onRevertibleDisposed?: (revertible: RevertibleAlpha) => void) => {\n\t\t\t\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a changed event.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst revertible = this.createRevertible(\n\t\t\t\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\t\t\tonRevertibleDisposed,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, _branch.fork(commit));\n\t\t\t\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\tlet withinEventContext = true;\n\t\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: true, kind }, getRevertible);\n\t\t\t\t\t\twithinEventContext = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (this.isRemoteChangeEvent(event)) {\n\t\t\t\t\t// TODO: figure out how to plumb through commit kind info for remote changes\n\t\t\t\t\tthis.events.emit(\"changed\", { isLocal: false, kind: CommitKind.Default });\n\t\t\t\t}\n\t\t\t}\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\t_branch.events.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(usageError?: string): void {\n\t\tif (this.disposed) {\n\t\t\tif (usageError !== undefined) {\n\t\t\t\tthrow new UsageError(usageError);\n\t\t\t}\n\t\t\tassert(false, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a {@link RevertibleAlpha} object that can undo a specific change in the tree's history.\n\t * Revision must exist in the given {@link TreeCheckout}'s branch.\n\t *\n\t * @param revision - The revision tag identifying the change to be made revertible.\n\t * @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).\n\t * @param checkout - The {@link TreeCheckout} instance this revertible belongs to.\n\t * @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.\n\t * @returns - {@link RevertibleAlpha}\n\t */\n\tprivate createRevertible(\n\t\trevision: RevisionTag,\n\t\tkind: CommitKind,\n\t\tcheckout: TreeCheckout,\n\t\tonRevertibleDisposed: ((revertible: RevertibleAlpha) => void) | undefined,\n\t): RevertibleAlpha {\n\t\tconst commitBranches = checkout.revertibleCommitBranches;\n\n\t\tconst revertible: RevertibleAlpha = {\n\t\t\tget status(): RevertibleStatus {\n\t\t\t\tconst revertibleCommit = commitBranches.get(revision);\n\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t},\n\t\t\trevert: (release: boolean = true) => {\n\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\tthrow new UsageError(\"Unable to revert a revertible that has been disposed.\");\n\t\t\t\t}\n\n\t\t\t\tconst revertMetrics = checkout.revertRevertible(revision, kind);\n\t\t\t\tcheckout.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t...revertMetrics,\n\t\t\t\t});\n\n\t\t\t\tif (release) {\n\t\t\t\t\trevertible.dispose();\n\t\t\t\t}\n\t\t\t},\n\t\t\tclone: (forkedBranch: TreeBranch) => {\n\t\t\t\tif (forkedBranch === undefined) {\n\t\t\t\t\treturn this.createRevertible(revision, kind, checkout, onRevertibleDisposed);\n\t\t\t\t}\n\n\t\t\t\t// TODO:#23442: When a revertible is cloned for a forked branch, optimize to create a fork of a revertible branch once per revision NOT once per revision per checkout.\n\t\t\t\tconst forkedCheckout = getCheckout(forkedBranch);\n\t\t\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\t\t\tassert(\n\t\t\t\t\trevertibleBranch !== undefined,\n\t\t\t\t\t0xa82 /* change to revert does not exist on the given forked branch */,\n\t\t\t\t);\n\t\t\t\tforkedCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());\n\n\t\t\t\treturn this.createRevertible(revision, kind, forkedCheckout, onRevertibleDisposed);\n\t\t\t},\n\t\t\tdispose: () => {\n\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcheckout.disposeRevertible(revertible, revision);\n\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t},\n\t\t};\n\n\t\treturn revertible;\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\tconst view = new SchematizingSimpleTreeView(\n\t\t\tthis,\n\t\t\tconfig,\n\t\t\tcreateNodeKeyManager(this.idCompressor),\n\t\t\tthis.breaker,\n\t\t\t() => {\n\t\t\t\tthis.views.delete(view);\n\t\t\t},\n\t\t);\n\t\tthis.views.add(view);\n\t\treturn view;\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors.events;\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 get transaction(): Transactor {\n\t\treturn this.#transaction;\n\t}\n\t/**\n\t * The {@link Transactor} for this checkout.\n\t * @remarks In the context of a checkout, transactions allow edits to be batched into atomic units.\n\t * 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\t * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n\t * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n\t *\n\t * To avoid updating observers of the view state with intermediate results during a transaction,\n\t * use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.\n\t */\n\treadonly #transaction = new TransactionStack(() => {\n\t\t// Keep track of the commit that each transaction was on when it started\n\t\t// TODO:#8603: This may need to be computed differently if we allow rebasing during a transaction.\n\t\tconst startCommit = this._branch.getHead();\n\t\t// Keep track of all the forks created during the transaction so that we can dispose them when the transaction ends.\n\t\t// This is a policy decision that we think is useful for the user, but it is not necessary for correctness.\n\t\tconst forks = new Set<TreeCheckout>();\n\t\tconst onDisposeUnSubscribes: (() => void)[] = [];\n\t\tconst onForkUnSubscribe = onForkTransitive(this, (fork) => {\n\t\t\tforks.add(fork);\n\t\t\tonDisposeUnSubscribes.push(fork.events.on(\"dispose\", () => forks.delete(fork)));\n\t\t});\n\t\t// When each transaction is started, take a snapshot of the current state of removed roots\n\t\tconst removedRoots = this.removedRoots.clone();\n\t\tthis._branch.editor.enterTransaction();\n\t\treturn (result) => {\n\t\t\tthis._branch.editor.exitTransaction();\n\t\t\tswitch (result) {\n\t\t\t\tcase TransactionResult.Abort:\n\t\t\t\t\tthis._branch.removeAfter(startCommit);\n\t\t\t\t\t// If a transaction is rolled back, revert removed roots back to the latest snapshot\n\t\t\t\t\tthis.removedRoots = removedRoots;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TransactionResult.Commit: {\n\t\t\t\t\tconst removedCommits = this._branch.squashAfter(startCommit);\n\t\t\t\t\tconst transactionRevision = this._branch.getHead().revision;\n\t\t\t\t\tfor (const transactionStep of removedCommits) {\n\t\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(result);\n\t\t\t}\n\n\t\t\tforks.forEach((fork) => fork.dispose());\n\t\t\tonDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());\n\t\t\tonForkUnSubscribe();\n\t\t};\n\t});\n\n\tpublic branch(): TreeCheckout {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The parent branch has already been disposed and can no longer create new branches.\",\n\t\t);\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 checkout = new TreeCheckout(\n\t\t\tbranch,\n\t\t\ttrue,\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\tthis.breaker,\n\t\t);\n\t\tthis.events.emit(\"fork\", checkout);\n\t\treturn checkout;\n\t}\n\n\tpublic rebase(checkout: TreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tassert(\n\t\t\t!checkout.transaction.isInProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tassert(\n\t\t\tcheckout.isBranch,\n\t\t\t0xa5d /* The main branch cannot be rebased onto another branch. */,\n\t\t);\n\n\t\tcheckout._branch.rebaseOnto(this._branch);\n\t}\n\n\tpublic rebaseOnto(checkout: ITreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.rebase(this);\n\t}\n\n\tpublic merge(checkout: TreeCheckout): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged: boolean): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged = true): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tassert(\n\t\t\t!this.transaction.isInProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (checkout.transaction.isInProgress()) {\n\t\t\tcheckout.transaction.commit();\n\t\t}\n\t\tthis._branch.merge(checkout._branch);\n\t\tif (disposeMerged && checkout.isBranch) {\n\t\t\t// Dispose the merged checkout unless it is the main branch.\n\t\t\tcheckout[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 dispose(): void {\n\t\tthis[disposeSymbol]();\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The branch has already been disposed and cannot be disposed again.\",\n\t\t);\n\t\tthis.disposed = true;\n\t\tthis.#transaction.dispose();\n\t\tthis.purgeRevertibles();\n\t\tthis._branch.dispose();\n\t\tfor (const view of this.views) {\n\t\t\tview.dispose();\n\t\t}\n\t\tthis.events.emit(\"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: RevertibleAlpha, 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.transaction.isInProgress()) {\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\t\tconst revisionForInvert = this.mintRevisionTag();\n\n\t\tlet change = tagChange(\n\t\t\tthis.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert),\n\t\t\trevisionForInvert,\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 = tagChange(\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\trevisionForInvert,\n\t\t\t);\n\t\t}\n\n\t\tthis._branch.apply(\n\t\t\tchange,\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\t/**\n\t * `true` iff the given branch change event is due to a remote change\n\t */\n\tprivate isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {\n\t\treturn (\n\t\t\t// Remote changes are only ever applied to the main branch\n\t\t\t!this.isBranch &&\n\t\t\t// Remote changes are applied to the main branch by rebasing it onto the trunk.\n\t\t\t// No other rebases are allowed on the main branch, so we can use this to detect remote changes.\n\t\t\tevent.type === \"replace\" &&\n\t\t\tgetChangeReplaceType(event) === \"rebase\"\n\t\t);\n\t}\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { type TelemetryEventBatcher } from "@fluidframework/telemetry-utils/internal";
6
6
  import { type BranchRebaseResult, type ChangeFamily, type ChangeFamilyEditor, CommitKind, type GraphCommit, type RevisionTag, type TaggedChange, type RebaseStatsWithDuration } from "../core/index.js";
7
- import { type Listenable } from "../events/index.js";
7
+ import type { Listenable } from "@fluidframework/core-interfaces";
8
8
  /**
9
9
  * Describes a change to a `SharedTreeBranch`. Various operations can mutate the head of the branch;
10
10
  * this change format describes each in terms of the "removed commits" (all commits which were present
@@ -24,11 +24,11 @@ export type SharedTreeBranchChange<TChange> = {
24
24
  type: "append";
25
25
  kind: CommitKind;
26
26
  change: TaggedChange<TChange>;
27
- newCommits: readonly GraphCommit<TChange>[];
27
+ newCommits: readonly [GraphCommit<TChange>, ...GraphCommit<TChange>[]];
28
28
  } | {
29
29
  type: "remove";
30
30
  change: TaggedChange<TChange> | undefined;
31
- removedCommits: readonly GraphCommit<TChange>[];
31
+ removedCommits: readonly [GraphCommit<TChange>, ...GraphCommit<TChange>[]];
32
32
  } | {
33
33
  type: "replace";
34
34
  change: TaggedChange<TChange> | undefined;
@@ -64,30 +64,6 @@ export interface SharedTreeBranchEvents<TEditor extends ChangeFamilyEditor, TCha
64
64
  * Fired after this branch is disposed
65
65
  */
66
66
  dispose(): void;
67
- /**
68
- * Fired after a new transaction is started.
69
- * @param isOuterTransaction - true iff the transaction being started is the outermost transaction
70
- * as opposed to a nested transaction.
71
- */
72
- transactionStarted(isOuterTransaction: boolean): void;
73
- /**
74
- * Fired after the current transaction is aborted.
75
- * @param isOuterTransaction - true iff the transaction being aborted is the outermost transaction
76
- * as opposed to a nested transaction.
77
- */
78
- transactionAborted(isOuterTransaction: boolean): void;
79
- /**
80
- * Fired after the current transaction is completely rolled back.
81
- * @param isOuterTransaction - true iff the transaction being aborted is the outermost transaction
82
- * as opposed to a nested transaction.
83
- */
84
- transactionRolledBack(isOuterTransaction: boolean): void;
85
- /**
86
- * Fired after the current transaction is committed.
87
- * @param isOuterTransaction - true iff the transaction being committed is the outermost transaction
88
- * as opposed to a nested transaction.
89
- */
90
- transactionCommitted(isOuterTransaction: boolean): void;
91
67
  }
92
68
  /**
93
69
  * Events related to branch trimming.
@@ -117,30 +93,6 @@ export declare class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChang
117
93
  private readonly telemetryEventBatcher?;
118
94
  readonly events: Listenable<SharedTreeBranchEvents<TEditor, TChange>>;
119
95
  readonly editor: TEditor;
120
- private readonly transactions;
121
- /**
122
- * After pushing a starting revision to the transaction stack, this branch might be rebased
123
- * over commits which are children of that starting revision. When the transaction is committed,
124
- * those rebased-over commits should not be included in the transaction's squash commit, even though
125
- * they exist between the starting revision and the final commit within the transaction.
126
- *
127
- * Whenever `rebaseOnto` is called during a transaction, this map is augmented with an entry from the
128
- * original merge-base to the new merge-base.
129
- *
130
- * This state need only be retained for the lifetime of the transaction.
131
- *
132
- * TODO: This strategy might need to be revisited when adding better support for async transactions.
133
- * Since:
134
- *
135
- * 1. Transactionality is guaranteed primarily by squashing at commit time
136
- * 2. Branches may be rebased with an ongoing transaction
137
- *
138
- * a rebase operation might invalidate only a portion of a transaction's commits, thus defeating the
139
- * purpose of transactionality.
140
- *
141
- * AB#6483 and children items track this work.
142
- */
143
- private readonly initialTransactionRevToRebasedRev;
144
96
  private disposed;
145
97
  private readonly unsubscribeBranchTrimmer?;
146
98
  /**
@@ -152,7 +104,9 @@ export declare class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChang
152
104
  */
153
105
  constructor(head: GraphCommit<TChange>, changeFamily: ChangeFamily<TEditor, TChange>, mintRevisionTag: () => RevisionTag, branchTrimmer?: Listenable<BranchTrimmingEvents> | undefined, telemetryEventBatcher?: TelemetryEventBatcher<keyof RebaseStatsWithDuration> | undefined);
154
106
  /**
155
- * Sets the head of this branch. Emits no change events.
107
+ * Sets the head of this branch.
108
+ * @remarks This is a "manual override" of sorts, for when the branch needs to be set to a certain state without going through the usual flow of edits.
109
+ * This might be necessary as a performance optimization, or to prevent parts of the system updating incorrectly (this method emits no change events!).
156
110
  */
157
111
  setHead(head: GraphCommit<TChange>): void;
158
112
  /**
@@ -166,34 +120,6 @@ export declare class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChang
166
120
  * @returns the commit at the head of this branch.
167
121
  */
168
122
  getHead(): GraphCommit<TChange>;
169
- /**
170
- * Begin a transaction on this branch. If the transaction is committed via {@link commitTransaction},
171
- * all commits made since this call will be squashed into a single head commit.
172
- */
173
- startTransaction(): void;
174
- /**
175
- * Commit the current transaction. There must be a transaction in progress that was begun via {@link startTransaction}.
176
- * If there are commits in the current transaction, they will be squashed into a new single head commit.
177
- * @returns the commits that were squashed and the new squash commit if a squash occurred, otherwise `undefined`.
178
- * @remarks If the transaction had no changes applied during its lifetime, then no squash occurs (i.e. this method is a no-op).
179
- * Even if the transaction contained only one change, it will still be replaced with an (equivalent) squash change.
180
- */
181
- commitTransaction(): [squashedCommits: GraphCommit<TChange>[], newCommit: GraphCommit<TChange>] | undefined;
182
- /**
183
- * Cancel the current transaction. There must be a transaction in progress that was begun via
184
- * {@link startTransaction}. All commits made during the transaction will be removed.
185
- * @returns the change to this branch resulting in the removal of the commits, and a list of the
186
- * commits that were removed.
187
- */
188
- abortTransaction(): [
189
- change: TChange | undefined,
190
- abortedCommits: GraphCommit<TChange>[]
191
- ];
192
- /**
193
- * True iff this branch is in the middle of a transaction that was begin via {@link startTransaction}
194
- */
195
- isTransacting(): boolean;
196
- private popTransaction;
197
123
  /**
198
124
  * Spawn a new branch that is based off of the current state of this branch.
199
125
  * @param commit - The commit to base the new branch off of. Defaults to the head of this branch.
@@ -210,6 +136,20 @@ export declare class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChang
210
136
  * @returns the result of the rebase or undefined if nothing changed
211
137
  */
212
138
  rebaseOnto(branch: SharedTreeBranch<TEditor, TChange>, upTo?: GraphCommit<TChange>): BranchRebaseResult<TChange> | undefined;
139
+ /**
140
+ * Remove a range of commits from this branch.
141
+ * @param commit - All commits after (but not including) this commit will be removed.
142
+ * @returns The net change to this branch and the commits that were removed from this branch.
143
+ */
144
+ removeAfter(commit: GraphCommit<TChange>): [change: TaggedChange<TChange> | undefined, removedCommits: GraphCommit<TChange>[]];
145
+ /**
146
+ * Replace a range of commits on this branch with a single commit composed of equivalent changes.
147
+ * @param commit - All commits after (but not including) this commit will be squashed.
148
+ * @returns The commits that were squashed and removed from this branch.
149
+ * @remarks The commits after `commit` will be removed from this branch, and the squash commit will become the new head of this branch.
150
+ * The change event emitted by this operation will have a `change` property that is undefined, since no net change occurred.
151
+ */
152
+ squashAfter(commit: GraphCommit<TChange>): GraphCommit<TChange>[];
213
153
  /**
214
154
  * Apply all the divergent changes on the given branch to this branch.
215
155
  *
@@ -239,5 +179,9 @@ export declare class SharedTreeBranch<TEditor extends ChangeFamilyEditor, TChang
239
179
  * @returns a function which when called will deregister all registrations (including transitive) created by this function.
240
180
  * The deregister function has undefined behavior if called more than once.
241
181
  */
242
- export declare function onForkTransitive<T extends SharedTreeBranch<ChangeFamilyEditor, any>>(branch: T, onFork: (fork: T) => void): () => void;
182
+ export declare function onForkTransitive<T extends {
183
+ events: Listenable<{
184
+ fork(t: T): void;
185
+ }>;
186
+ }>(branch: T, onFork: (fork: T) => void): () => void;
243
187
  //# sourceMappingURL=branch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/branch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,qBAAqB,EAAW,MAAM,0CAA0C,CAAC;AAE/F,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EAMjB,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKpE;;;;;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