@fluidframework/tree 2.0.0-dev-rc.3.0.0.253463 → 2.0.0-dev-rc.3.0.0.254274

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 (400) hide show
  1. package/api-report/tree.api.md +23 -11
  2. package/dist/core/rebase/utils.d.ts.map +1 -1
  3. package/dist/core/rebase/utils.js +5 -4
  4. package/dist/core/rebase/utils.js.map +1 -1
  5. package/dist/core/revertible/revertible.d.ts +12 -3
  6. package/dist/core/revertible/revertible.d.ts.map +1 -1
  7. package/dist/core/revertible/revertible.js +1 -0
  8. package/dist/core/revertible/revertible.js.map +1 -1
  9. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  10. package/dist/core/tree/anchorSet.js +7 -1
  11. package/dist/core/tree/anchorSet.js.map +1 -1
  12. package/dist/core/tree/visitDelta.js +4 -7
  13. package/dist/core/tree/visitDelta.js.map +1 -1
  14. package/dist/domains/schemaBuilder.d.ts +23 -6
  15. package/dist/domains/schemaBuilder.d.ts.map +1 -1
  16. package/dist/domains/schemaBuilder.js +23 -6
  17. package/dist/domains/schemaBuilder.js.map +1 -1
  18. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  19. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  20. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  21. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  22. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  23. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  24. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
  25. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  26. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -1
  27. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  29. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  30. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +10 -0
  31. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  32. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +13 -3
  33. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  34. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  35. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  36. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  37. package/dist/feature-libraries/flex-tree/lazyField.d.ts +10 -1
  38. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  39. package/dist/feature-libraries/flex-tree/lazyField.js +24 -2
  40. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  41. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +1 -2
  42. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  43. package/dist/feature-libraries/flex-tree/lazyNode.js +2 -3
  44. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  45. package/dist/feature-libraries/index.d.ts +1 -1
  46. package/dist/feature-libraries/index.d.ts.map +1 -1
  47. package/dist/feature-libraries/index.js.map +1 -1
  48. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +3 -6
  49. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  50. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  51. package/dist/feature-libraries/optional-field/optionalFieldCodecV0.d.ts +2 -2
  52. package/dist/feature-libraries/optional-field/optionalFieldCodecV0.d.ts.map +1 -1
  53. package/dist/feature-libraries/optional-field/optionalFieldCodecV0.js.map +1 -1
  54. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +2 -2
  55. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +1 -1
  56. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js.map +1 -1
  57. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +1 -1
  58. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  59. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  60. package/dist/feature-libraries/sequence-field/compose.d.ts +8 -12
  61. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  62. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  63. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +2 -2
  64. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  65. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  66. package/dist/feature-libraries/sequence-field/index.d.ts +5 -5
  67. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  68. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  69. package/dist/feature-libraries/sequence-field/invert.d.ts +1 -2
  70. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  71. package/dist/feature-libraries/sequence-field/invert.js +1 -3
  72. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  73. package/dist/feature-libraries/sequence-field/markListFactory.d.ts +4 -4
  74. package/dist/feature-libraries/sequence-field/markListFactory.d.ts.map +1 -1
  75. package/dist/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  76. package/dist/feature-libraries/sequence-field/markQueue.d.ts +6 -6
  77. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  78. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  79. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +12 -12
  80. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  81. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  82. package/dist/feature-libraries/sequence-field/prune.d.ts +2 -2
  83. package/dist/feature-libraries/sequence-field/prune.d.ts.map +1 -1
  84. package/dist/feature-libraries/sequence-field/prune.js.map +1 -1
  85. package/dist/feature-libraries/sequence-field/rebase.d.ts +2 -3
  86. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  87. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  88. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +2 -2
  89. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
  90. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  91. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -2
  92. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  93. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +1 -3
  94. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  95. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +17 -17
  96. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  97. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  98. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -3
  99. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  100. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  101. package/dist/feature-libraries/sequence-field/types.d.ts +6 -7
  102. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  103. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  104. package/dist/feature-libraries/sequence-field/utils.d.ts +32 -32
  105. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  106. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  107. package/dist/index.d.ts +2 -2
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/packageVersion.d.ts +1 -1
  111. package/dist/packageVersion.js +1 -1
  112. package/dist/packageVersion.js.map +1 -1
  113. package/dist/shared-tree/index.d.ts +1 -1
  114. package/dist/shared-tree/index.d.ts.map +1 -1
  115. package/dist/shared-tree/index.js.map +1 -1
  116. package/dist/shared-tree/schematizingTreeView.d.ts +4 -2
  117. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  118. package/dist/shared-tree/schematizingTreeView.js +8 -1
  119. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  120. package/dist/shared-tree/sharedTree.d.ts +2 -2
  121. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  122. package/dist/shared-tree/sharedTree.js.map +1 -1
  123. package/dist/shared-tree/treeApi.d.ts +18 -2
  124. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  125. package/dist/shared-tree/treeApi.js +10 -0
  126. package/dist/shared-tree/treeApi.js.map +1 -1
  127. package/dist/shared-tree/treeCheckout.d.ts +13 -10
  128. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  129. package/dist/shared-tree/treeCheckout.js +7 -4
  130. package/dist/shared-tree/treeCheckout.js.map +1 -1
  131. package/dist/simple-tree/index.d.ts +3 -3
  132. package/dist/simple-tree/index.d.ts.map +1 -1
  133. package/dist/simple-tree/index.js +4 -1
  134. package/dist/simple-tree/index.js.map +1 -1
  135. package/dist/simple-tree/objectNode.d.ts +7 -3
  136. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  137. package/dist/simple-tree/objectNode.js +25 -27
  138. package/dist/simple-tree/objectNode.js.map +1 -1
  139. package/dist/simple-tree/proxies.d.ts.map +1 -1
  140. package/dist/simple-tree/proxies.js +5 -0
  141. package/dist/simple-tree/proxies.js.map +1 -1
  142. package/dist/simple-tree/schemaFactory.d.ts +4 -0
  143. package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
  144. package/dist/simple-tree/schemaFactory.js +6 -0
  145. package/dist/simple-tree/schemaFactory.js.map +1 -1
  146. package/dist/simple-tree/schemaFactoryRecursive.d.ts +3 -3
  147. package/dist/simple-tree/schemaFactoryRecursive.d.ts.map +1 -1
  148. package/dist/simple-tree/schemaFactoryRecursive.js.map +1 -1
  149. package/dist/simple-tree/schemaTypes.d.ts +7 -1
  150. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  151. package/dist/simple-tree/schemaTypes.js +6 -0
  152. package/dist/simple-tree/schemaTypes.js.map +1 -1
  153. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  154. package/dist/simple-tree/toFlexSchema.js +1 -0
  155. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  156. package/dist/simple-tree/toMapTree.d.ts +1 -1
  157. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  158. package/dist/simple-tree/toMapTree.js +74 -50
  159. package/dist/simple-tree/toMapTree.js.map +1 -1
  160. package/dist/simple-tree/tree.d.ts +7 -11
  161. package/dist/simple-tree/tree.d.ts.map +1 -1
  162. package/dist/simple-tree/tree.js.map +1 -1
  163. package/dist/simple-tree/treeApi.d.ts +5 -0
  164. package/dist/simple-tree/treeApi.d.ts.map +1 -1
  165. package/dist/simple-tree/treeApi.js +11 -0
  166. package/dist/simple-tree/treeApi.js.map +1 -1
  167. package/dist/tree-alpha.d.ts +66 -17
  168. package/dist/tree-beta.d.ts +66 -17
  169. package/dist/tree-public.d.ts +64 -15
  170. package/dist/tree-untrimmed.d.ts +72 -27
  171. package/dist/util/referenceCounting.d.ts +1 -1
  172. package/dist/util/referenceCounting.d.ts.map +1 -1
  173. package/dist/util/referenceCounting.js +1 -1
  174. package/dist/util/referenceCounting.js.map +1 -1
  175. package/lib/core/rebase/utils.d.ts.map +1 -1
  176. package/lib/core/rebase/utils.js +5 -4
  177. package/lib/core/rebase/utils.js.map +1 -1
  178. package/lib/core/revertible/revertible.d.ts +12 -3
  179. package/lib/core/revertible/revertible.d.ts.map +1 -1
  180. package/lib/core/revertible/revertible.js +1 -0
  181. package/lib/core/revertible/revertible.js.map +1 -1
  182. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  183. package/lib/core/tree/anchorSet.js +7 -1
  184. package/lib/core/tree/anchorSet.js.map +1 -1
  185. package/lib/core/tree/visitDelta.js +4 -7
  186. package/lib/core/tree/visitDelta.js.map +1 -1
  187. package/lib/domains/schemaBuilder.d.ts +23 -6
  188. package/lib/domains/schemaBuilder.d.ts.map +1 -1
  189. package/lib/domains/schemaBuilder.js +23 -6
  190. package/lib/domains/schemaBuilder.js.map +1 -1
  191. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  192. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  193. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  194. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  195. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  196. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  197. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
  198. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  199. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -1
  200. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  201. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  202. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  203. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +10 -0
  204. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  205. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  206. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  207. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  208. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  209. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  210. package/lib/feature-libraries/flex-tree/lazyField.d.ts +10 -1
  211. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  212. package/lib/feature-libraries/flex-tree/lazyField.js +21 -1
  213. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  214. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +1 -2
  215. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  216. package/lib/feature-libraries/flex-tree/lazyNode.js +2 -2
  217. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  218. package/lib/feature-libraries/index.d.ts +1 -1
  219. package/lib/feature-libraries/index.d.ts.map +1 -1
  220. package/lib/feature-libraries/index.js.map +1 -1
  221. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +3 -6
  222. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  223. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  224. package/lib/feature-libraries/optional-field/optionalFieldCodecV0.d.ts +2 -2
  225. package/lib/feature-libraries/optional-field/optionalFieldCodecV0.d.ts.map +1 -1
  226. package/lib/feature-libraries/optional-field/optionalFieldCodecV0.js +1 -1
  227. package/lib/feature-libraries/optional-field/optionalFieldCodecV0.js.map +1 -1
  228. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +2 -2
  229. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +1 -1
  230. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js.map +1 -1
  231. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +1 -1
  232. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  233. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  234. package/lib/feature-libraries/sequence-field/compose.d.ts +8 -12
  235. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  236. package/lib/feature-libraries/sequence-field/compose.js +1 -1
  237. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  238. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +2 -2
  239. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  240. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  241. package/lib/feature-libraries/sequence-field/index.d.ts +5 -5
  242. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  243. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  244. package/lib/feature-libraries/sequence-field/invert.d.ts +1 -2
  245. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  246. package/lib/feature-libraries/sequence-field/invert.js +1 -3
  247. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  248. package/lib/feature-libraries/sequence-field/markListFactory.d.ts +4 -4
  249. package/lib/feature-libraries/sequence-field/markListFactory.d.ts.map +1 -1
  250. package/lib/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  251. package/lib/feature-libraries/sequence-field/markQueue.d.ts +6 -6
  252. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  253. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  254. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +12 -12
  255. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  256. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  257. package/lib/feature-libraries/sequence-field/prune.d.ts +2 -2
  258. package/lib/feature-libraries/sequence-field/prune.d.ts.map +1 -1
  259. package/lib/feature-libraries/sequence-field/prune.js.map +1 -1
  260. package/lib/feature-libraries/sequence-field/rebase.d.ts +2 -3
  261. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  262. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  263. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +2 -2
  264. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +1 -1
  265. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  266. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -2
  267. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  268. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +1 -3
  269. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  270. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +17 -17
  271. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  272. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  273. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -3
  274. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  275. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  276. package/lib/feature-libraries/sequence-field/types.d.ts +6 -7
  277. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  278. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  279. package/lib/feature-libraries/sequence-field/utils.d.ts +32 -32
  280. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  281. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  282. package/lib/index.d.ts +2 -2
  283. package/lib/index.d.ts.map +1 -1
  284. package/lib/index.js.map +1 -1
  285. package/lib/packageVersion.d.ts +1 -1
  286. package/lib/packageVersion.js +1 -1
  287. package/lib/packageVersion.js.map +1 -1
  288. package/lib/shared-tree/index.d.ts +1 -1
  289. package/lib/shared-tree/index.d.ts.map +1 -1
  290. package/lib/shared-tree/index.js.map +1 -1
  291. package/lib/shared-tree/schematizingTreeView.d.ts +4 -2
  292. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  293. package/lib/shared-tree/schematizingTreeView.js +9 -2
  294. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  295. package/lib/shared-tree/sharedTree.d.ts +2 -2
  296. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  297. package/lib/shared-tree/sharedTree.js.map +1 -1
  298. package/lib/shared-tree/treeApi.d.ts +18 -2
  299. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  300. package/lib/shared-tree/treeApi.js +11 -1
  301. package/lib/shared-tree/treeApi.js.map +1 -1
  302. package/lib/shared-tree/treeCheckout.d.ts +13 -10
  303. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  304. package/lib/shared-tree/treeCheckout.js +7 -4
  305. package/lib/shared-tree/treeCheckout.js.map +1 -1
  306. package/lib/simple-tree/index.d.ts +3 -3
  307. package/lib/simple-tree/index.d.ts.map +1 -1
  308. package/lib/simple-tree/index.js +2 -1
  309. package/lib/simple-tree/index.js.map +1 -1
  310. package/lib/simple-tree/objectNode.d.ts +7 -3
  311. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  312. package/lib/simple-tree/objectNode.js +24 -27
  313. package/lib/simple-tree/objectNode.js.map +1 -1
  314. package/lib/simple-tree/proxies.d.ts.map +1 -1
  315. package/lib/simple-tree/proxies.js +5 -0
  316. package/lib/simple-tree/proxies.js.map +1 -1
  317. package/lib/simple-tree/schemaFactory.d.ts +4 -0
  318. package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
  319. package/lib/simple-tree/schemaFactory.js +6 -0
  320. package/lib/simple-tree/schemaFactory.js.map +1 -1
  321. package/lib/simple-tree/schemaFactoryRecursive.d.ts +3 -3
  322. package/lib/simple-tree/schemaFactoryRecursive.d.ts.map +1 -1
  323. package/lib/simple-tree/schemaFactoryRecursive.js.map +1 -1
  324. package/lib/simple-tree/schemaTypes.d.ts +7 -1
  325. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  326. package/lib/simple-tree/schemaTypes.js +6 -0
  327. package/lib/simple-tree/schemaTypes.js.map +1 -1
  328. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  329. package/lib/simple-tree/toFlexSchema.js +1 -0
  330. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  331. package/lib/simple-tree/toMapTree.d.ts +1 -1
  332. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  333. package/lib/simple-tree/toMapTree.js +75 -51
  334. package/lib/simple-tree/toMapTree.js.map +1 -1
  335. package/lib/simple-tree/tree.d.ts +7 -11
  336. package/lib/simple-tree/tree.d.ts.map +1 -1
  337. package/lib/simple-tree/tree.js.map +1 -1
  338. package/lib/simple-tree/treeApi.d.ts +5 -0
  339. package/lib/simple-tree/treeApi.d.ts.map +1 -1
  340. package/lib/simple-tree/treeApi.js +12 -1
  341. package/lib/simple-tree/treeApi.js.map +1 -1
  342. package/lib/tree-alpha.d.ts +66 -17
  343. package/lib/tree-beta.d.ts +66 -17
  344. package/lib/tree-public.d.ts +64 -15
  345. package/lib/tree-untrimmed.d.ts +72 -27
  346. package/lib/util/referenceCounting.d.ts +1 -1
  347. package/lib/util/referenceCounting.d.ts.map +1 -1
  348. package/lib/util/referenceCounting.js +1 -1
  349. package/lib/util/referenceCounting.js.map +1 -1
  350. package/package.json +20 -20
  351. package/src/core/rebase/utils.ts +5 -4
  352. package/src/core/revertible/revertible.ts +15 -3
  353. package/src/core/tree/anchorSet.ts +7 -1
  354. package/src/core/tree/visitDelta.ts +4 -7
  355. package/src/domains/schemaBuilder.ts +25 -6
  356. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  357. package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
  358. package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
  359. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +26 -2
  360. package/src/feature-libraries/default-schema/index.ts +1 -0
  361. package/src/feature-libraries/flex-tree/lazyField.ts +45 -4
  362. package/src/feature-libraries/flex-tree/lazyNode.ts +2 -4
  363. package/src/feature-libraries/index.ts +1 -0
  364. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +3 -6
  365. package/src/feature-libraries/optional-field/optionalFieldCodecV0.ts +7 -11
  366. package/src/feature-libraries/optional-field/optionalFieldCodecV1.ts +6 -7
  367. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +3 -3
  368. package/src/feature-libraries/sequence-field/compose.ts +79 -82
  369. package/src/feature-libraries/sequence-field/helperTypes.ts +2 -2
  370. package/src/feature-libraries/sequence-field/index.ts +4 -5
  371. package/src/feature-libraries/sequence-field/invert.ts +30 -41
  372. package/src/feature-libraries/sequence-field/markListFactory.ts +4 -4
  373. package/src/feature-libraries/sequence-field/markQueue.ts +8 -8
  374. package/src/feature-libraries/sequence-field/moveEffectTable.ts +24 -24
  375. package/src/feature-libraries/sequence-field/prune.ts +3 -7
  376. package/src/feature-libraries/sequence-field/rebase.ts +73 -81
  377. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +5 -8
  378. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +11 -14
  379. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +32 -55
  380. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -6
  381. package/src/feature-libraries/sequence-field/types.ts +6 -8
  382. package/src/feature-libraries/sequence-field/utils.ts +44 -54
  383. package/src/index.ts +2 -0
  384. package/src/packageVersion.ts +1 -1
  385. package/src/shared-tree/index.ts +1 -0
  386. package/src/shared-tree/schematizingTreeView.ts +20 -6
  387. package/src/shared-tree/sharedTree.ts +2 -8
  388. package/src/shared-tree/treeApi.ts +40 -5
  389. package/src/shared-tree/treeCheckout.ts +23 -15
  390. package/src/simple-tree/index.ts +3 -1
  391. package/src/simple-tree/objectNode.ts +57 -49
  392. package/src/simple-tree/proxies.ts +6 -0
  393. package/src/simple-tree/schemaFactory.ts +7 -0
  394. package/src/simple-tree/schemaFactoryRecursive.ts +5 -2
  395. package/src/simple-tree/schemaTypes.ts +6 -0
  396. package/src/simple-tree/toFlexSchema.ts +1 -0
  397. package/src/simple-tree/toMapTree.ts +83 -65
  398. package/src/simple-tree/tree.ts +8 -12
  399. package/src/simple-tree/treeApi.ts +22 -0
  400. package/src/util/referenceCounting.ts +2 -2
@@ -202,8 +202,7 @@ export type ChangesetLocalId = Brand<number, "ChangesetLocalId">;
202
202
  // @internal
203
203
  export interface CheckoutEvents {
204
204
  afterBatch(): void;
205
- commitApplied(data: CommitMetadata, getRevertible?: () => Revertible): void;
206
- revertibleDisposed(revertible: Revertible): void;
205
+ commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
207
206
  }
208
207
 
209
208
  // @internal
@@ -472,6 +471,7 @@ export type FieldKey = Brand<string, "tree.FieldKey">;
472
471
 
473
472
  // @public
474
473
  export enum FieldKind {
474
+ Identifier = 2,
475
475
  Optional = 0,
476
476
  Required = 1
477
477
  }
@@ -493,6 +493,7 @@ export const FieldKinds: {
493
493
  readonly optional: Optional;
494
494
  readonly sequence: Sequence;
495
495
  readonly nodeKey: NodeKeyFieldKind;
496
+ readonly identifier: Identifier;
496
497
  readonly forbidden: Forbidden;
497
498
  };
498
499
 
@@ -946,6 +947,10 @@ export interface IDefaultEditBuilder {
946
947
  valueField(field: FieldUpPath): ValueFieldEditBuilder;
947
948
  }
948
949
 
950
+ // @internal (undocumented)
951
+ export interface Identifier extends FlexFieldKind<"Identifier", Multiplicity.Single> {
952
+ }
953
+
949
954
  // @public
950
955
  export interface IDisposable {
951
956
  [disposeSymbol](): void;
@@ -1085,7 +1090,7 @@ export interface ITransaction {
1085
1090
 
1086
1091
  // @public
1087
1092
  export interface ITree extends IChannel {
1088
- schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TreeFieldFromImplicitField<TRoot>>;
1093
+ schematize<TRoot extends ImplicitFieldSchema>(config: TreeConfiguration<TRoot>): TreeView<TRoot>;
1089
1094
  }
1090
1095
 
1091
1096
  // @internal
@@ -1490,11 +1495,15 @@ export type RestrictiveReadonlyRecord<K extends symbol | string, T> = {
1490
1495
 
1491
1496
  // @public
1492
1497
  export interface Revertible {
1493
- release(): void;
1498
+ [disposeSymbol](): void;
1494
1499
  revert(): void;
1500
+ revert(dispose: boolean): void;
1495
1501
  readonly status: RevertibleStatus;
1496
1502
  }
1497
1503
 
1504
+ // @public
1505
+ export type RevertibleFactory = (onRevertibleDisposed?: (revertible: Revertible) => void) => Revertible;
1506
+
1498
1507
  // @public
1499
1508
  export enum RevertibleStatus {
1500
1509
  Disposed = 1,
@@ -1576,6 +1585,7 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
1576
1585
  // @deprecated
1577
1586
  fixRecursiveReference<T extends AllowedTypes>(...types: T): void;
1578
1587
  readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject<unknown> & IFluidLoadable>, IFluidHandle<FluidObject<unknown> & IFluidLoadable>>;
1588
+ get identifier(): FieldSchema<FieldKind.Identifier>;
1579
1589
  map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchema<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
1580
1590
  map<Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
1581
1591
  namedArray_internal<Name extends TName | string, const T extends ImplicitAllowedTypes, const ImplicitlyConstructable extends boolean>(name: Name, allowedTypes: T, customizable: boolean, implicitlyConstructable: ImplicitlyConstructable): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Array, TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T>;
@@ -1778,8 +1788,9 @@ export interface TreeAdapter {
1778
1788
 
1779
1789
  // @public
1780
1790
  export interface TreeApi extends TreeNodeApi {
1791
+ contains(node: TreeNode, other: TreeNode): boolean;
1781
1792
  runTransaction<TNode extends TreeNode>(node: TNode, transaction: (node: TNode) => void | "rollback"): void;
1782
- runTransaction<TRoot>(tree: TreeView<TRoot>, transaction: (root: TRoot) => void | "rollback"): void;
1793
+ runTransaction<TView extends TreeView<ImplicitFieldSchema>>(tree: TView, transaction: (root: TView["root"]) => void | "rollback"): void;
1783
1794
  }
1784
1795
 
1785
1796
  // @public
@@ -1903,6 +1914,7 @@ export interface TreeNodeApi {
1903
1914
  on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
1904
1915
  parent(node: TreeNode): TreeNode | undefined;
1905
1916
  schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
1917
+ shortId(node: TreeNode): number | undefined;
1906
1918
  readonly status: (node: TreeNode) => TreeStatus;
1907
1919
  }
1908
1920
 
@@ -2008,18 +2020,18 @@ export type TreeValue<TSchema extends ValueSchema = ValueSchema> = [
2008
2020
  ][_InlineTrick];
2009
2021
 
2010
2022
  // @public
2011
- export interface TreeView<in out TRoot> extends IDisposable {
2023
+ export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {
2012
2024
  readonly error?: SchemaIncompatible;
2013
2025
  readonly events: ISubscribable<TreeViewEvents>;
2014
- readonly root: TRoot;
2026
+ get root(): TreeFieldFromImplicitField<TSchema>;
2027
+ set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
2015
2028
  upgradeSchema(): void;
2016
2029
  }
2017
2030
 
2018
2031
  // @public
2019
2032
  export interface TreeViewEvents {
2020
2033
  afterBatch(): void;
2021
- commitApplied(data: CommitMetadata, getRevertible?: () => Revertible): void;
2022
- revertibleDisposed(revertible: Revertible): void;
2034
+ commitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;
2023
2035
  rootChanged(): void;
2024
2036
  }
2025
2037
 
@@ -2069,11 +2081,11 @@ export type UpPathDefault = UpPath;
2069
2081
 
2070
2082
  // @beta
2071
2083
  export type ValidateRecursiveSchema<T extends TreeNodeSchemaClass<string, NodeKind.Array | NodeKind.Map | NodeKind.Object, TreeNode & WithType<T["identifier"]>, {
2072
- [NodeKind.Object]: T["info"] extends RestrictiveReadonlyRecord<string, FieldSchema> ? InsertableObjectFromSchemaRecord<T["info"]> : unknown;
2084
+ [NodeKind.Object]: T["info"] extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema> ? InsertableObjectFromSchemaRecord<T["info"]> : unknown;
2073
2085
  [NodeKind.Array]: T["info"] extends ImplicitAllowedTypes ? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>> : unknown;
2074
2086
  [NodeKind.Map]: T["info"] extends ImplicitAllowedTypes ? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>]> : unknown;
2075
2087
  }[T["kind"]], false, {
2076
- [NodeKind.Object]: RestrictiveReadonlyRecord<string, FieldSchema>;
2088
+ [NodeKind.Object]: RestrictiveReadonlyRecord<string, ImplicitFieldSchema>;
2077
2089
  [NodeKind.Array]: ImplicitAllowedTypes;
2078
2090
  [NodeKind.Map]: ImplicitAllowedTypes;
2079
2091
  }[T["kind"]]>> = true;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/rebase/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,YAAY,EAIZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO;IACtC;;;;OAIG;IACH,oBAAoB,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7C;;;;OAIG;IACH,aAAa,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IACtC;;;;OAIG;IACH,aAAa,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO;IAC1C;;OAEG;IACH,QAA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ACpD,UAAU,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EACnE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAC1B,CAAC,GAAG,SAAS,CAAC;AA0BjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS;IAAE,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,EAC1D,WAAW,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EACzD,WAAW,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,GACvD,CAAC,GAAG,SAAS,CA+Df"}
@@ -85,10 +85,9 @@ function rebaseBranch(mintRevisionTag, changeRebaser, sourceHead, targetCommit,
85
85
  const revisionMetadata = revisionMetadataSourceFromInfo(revInfos);
86
86
  let currentComposedEdit = (0, changeRebaser_js_1.makeAnonChange)(changeRebaser.compose(targetRebasePath));
87
87
  for (const c of sourcePath) {
88
- const editsToCompose = [
89
- (0, changeRebaser_js_1.tagRollbackInverse)(changeRebaser.invert(c, true), mintRevisionTag(), c.revision),
90
- currentComposedEdit,
91
- ];
88
+ const inverseTag = mintRevisionTag();
89
+ const inverse = (0, changeRebaser_js_1.tagRollbackInverse)(changeRebaser.invert(c, true), inverseTag, c.revision);
90
+ const editsToCompose = [inverse, currentComposedEdit];
92
91
  if (sourceSet.has(c.revision)) {
93
92
  const change = changeRebaser.rebase(c.change, currentComposedEdit, revisionMetadata);
94
93
  newHead = {
@@ -100,6 +99,8 @@ function rebaseBranch(mintRevisionTag, changeRebaser, sourceHead, targetCommit,
100
99
  editsToCompose.push((0, changeRebaser_js_1.tagChange)(change, c.revision));
101
100
  }
102
101
  currentComposedEdit = (0, changeRebaser_js_1.makeAnonChange)(changeRebaser.compose(editsToCompose));
102
+ revInfos.unshift({ revision: inverseTag, rollbackOf: inverse.rollbackOf });
103
+ revInfos.push({ revision: c.revision });
103
104
  }
104
105
  return {
105
106
  newSourceHead: newHead,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/rebase/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,yDAQ4B;AAC5B,yCAAkE;AAqIlE,SAAgB,YAAY,CAC3B,eAAkC,EAClC,aAAqC,EACrC,UAAgC,EAChC,YAAkC,EAClC,UAAU,GAAG,YAAY;IAEzB,4CAA4C;IAC5C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IACxF,IAAA,iBAAM,EAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAErE,oDAAoD;IACpD,MAAM,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC;IAC1E,IAAI,iBAAiB,KAAK,CAAC,CAAC,EAAE;QAC7B,6GAA6G;QAC7G,uGAAuG;QACvG,oDAAoD;QACpD,IAAA,iBAAM,EACL,kBAAkB,CAAC,YAAY,EAAE,UAAU,CAAC,KAAK,SAAS,EAC1D,KAAK,CAAC,2CAA2C,CACjD,CAAC;QACF,OAAO;YACN,aAAa,EAAE,UAAU;YACzB,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE;SACnF,CAAC;KACF;IAED,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C,CAAC,CAAC;YACf,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SACb;KACD;IAED,IAAI,KAAK,KAAK,SAAS,EAAE;QACxB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;KACjB;IACD,IAAI,KAAK,KAAK,SAAS,EAAE;QACxB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;KACjB;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAlED,gDAkEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { Mutable } from \"../../util/index.js\";\n\nimport {\n\tChangeRebaser,\n\tRevisionInfo,\n\tRevisionMetadataSource,\n\tTaggedChange,\n\tmakeAnonChange,\n\ttagChange,\n\ttagRollbackInverse,\n} from \"./changeRebaser.js\";\nimport { GraphCommit, RevisionTag, mintCommit } from \"./types.js\";\n\n/**\n * Contains information about how the commit graph changed as the result of rebasing a source branch onto another target branch.\n * @remarks\n * ```text\n * Consider the commit graph below containing two branches, X and Y, with head commits C and E, respectively.\n * Branch Y branches off of Branch X at their common ancestor commit A, i.e. \"Y is based off of X at commit A\".\n *\n * A ─ B ─ C ← Branch X\n * └─ D ─ E ← Branch Y\n *\n * Branch Y is then rebased onto Branch X. This results in the following commit graph:\n *\n * A ─ B ─ C ← Branch X\n * └─ D'─ E'← Branch Y\n *\n * Commits D' and E' are the rebased versions of commits D and E, respectively. This results in:\n * deletedSourceCommits: [D, E],\n * targetCommits: [B, C],\n * sourceCommits: [D', E']\n * ```\n */\nexport interface RebasedCommits<TChange> {\n\t/**\n\t * The commits on the original source branch that were rebased. These are no longer referenced by the source branch and have\n\t * been replaced with new versions on the new source branch, see {@link sourceCommits}. In the case that the source\n\t * branch was already ahead of the target branch before the rebase, this list will be empty.\n\t */\n\tdeletedSourceCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the target branch that the source branch's commits were rebased over. These are now the direct\n\t * ancestors of {@link sourceCommits}. In the case that the source branch was already ahead of the target branch\n\t * before the rebase, this list will be empty.\n\t */\n\ttargetCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the source branch that are not also on the target branch after the rebase operation. In the case that the\n\t * source branch was already ahead of the target branch before the rebase, these are the same commits that were already on\n\t * the source branch before the rebase, otherwise these are the new, rebased versions of {@link deletedSourceCommits}.\n\t */\n\tsourceCommits: GraphCommit<TChange>[];\n}\n\nexport interface BranchRebaseResult<TChange> {\n\t/**\n\t * The head of a rebased source branch.\n\t */\n\treadonly newSourceHead: GraphCommit<TChange>;\n\t/**\n\t * A thunk that computes the cumulative change to the source branch (undefined if no change occurred)\n\t */\n\treadonly sourceChange: TChange | undefined;\n\t/**\n\t * Details about how the commits on the source branch changed\n\t */\n\treadonly commits: RebasedCommits<TChange>;\n}\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `targetHead`\n * @param targetHead - the commit to rebase the source branch onto\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. For example:\n * ```\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (B')-(D) <- Branch Y\n * //\n * // As Branch Y is rebased onto Branch X, commits B and B' cancel out so there is no version of B on the new rebased source branch\n * //\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (D') <- Branch Y'\n * //\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `newBase`\n * @param targetCommit - the commit on the target branch to rebase the source branch onto.\n * @param targetHead - the head of the branch that `newBase` belongs to. Must be `newBase` or a descendent of `newBase`.\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. Additionally, this function will rebase\n * the source branch _farther_ than `newBase` if the source branch's next commits after `newBase` match those on the target branch.\n * For example:\n * ```\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (B')-(D')-(F) <- Branch Y\n * //\n * // If Branch Y is rebased onto commit C of Branch X, the branches must at least look like this afterwards (B was cancelled out):\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (D'')-(F') <- Branch Y'\n * //\n * // But this function will recognize that B is equivalent to B' and D is equivalent to D', and instead produce:\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (F') <- Branch Y'\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead = targetCommit,\n): BranchRebaseResult<TChange> {\n\t// Get both source and target as path arrays\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tconst ancestor = findCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]);\n\tassert(ancestor !== undefined, 0x675 /* branches must be related */);\n\n\t// Find where `targetCommit` is in the target branch\n\tconst targetCommitIndex = targetPath.findIndex((r) => r === targetCommit);\n\tif (targetCommitIndex === -1) {\n\t\t// If the targetCommit is not in the target path, then it is either disjoint from `target` or it is behind/at\n\t\t// the commit where source and target diverge (ancestor), in which case there is nothing more to rebase\n\t\t// TODO: Ideally, this would be an \"assertExpensive\"\n\t\tassert(\n\t\t\tfindCommonAncestor(targetCommit, targetHead) !== undefined,\n\t\t\t0x676 /* target commit is not in target branch */,\n\t\t);\n\t\treturn {\n\t\t\tnewSourceHead: sourceHead,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: { deletedSourceCommits: [], targetCommits: [], sourceCommits: sourcePath },\n\t\t};\n\t}\n\n\t// Iterate through the target path and look for commits that are also present on the source branch (i.e. they\n\t// have matching tags). Each commit found in the target branch can be skipped when processing the source branch\n\t// because it has already been rebased onto the target. In the case that one or more of these commits are present\n\t// directly after `targetCommit`, then the new base can be advanced further without having to do any work.\n\tconst sourceSet = new Set(sourcePath.map((r) => r.revision));\n\tlet newBaseIndex = targetCommitIndex;\n\n\tfor (let i = 0; i < targetPath.length; i += 1) {\n\t\tconst { revision } = targetPath[i];\n\t\tif (sourceSet.has(revision)) {\n\t\t\tsourceSet.delete(revision);\n\t\t\tnewBaseIndex = Math.max(newBaseIndex, i);\n\t\t} else if (i > targetCommitIndex) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/** The commit on the target branch that the new source branch branches off of (i.e. the new common ancestor) */\n\tconst newBase = targetPath[newBaseIndex];\n\t// Figure out how much of the trunk to start rebasing over.\n\tconst targetCommits = targetPath.slice(0, newBaseIndex + 1);\n\tconst deletedSourceCommits = [...sourcePath];\n\n\t// If the source and target rebase path begin with a range that has all the same revisions, remove it; it is\n\t// equivalent on both branches and doesn't need to be rebased.\n\tconst targetRebasePath = [...targetCommits];\n\tconst minLength = Math.min(sourcePath.length, targetRebasePath.length);\n\tfor (let i = 0; i < minLength; i++) {\n\t\tif (sourcePath[0].revision === targetRebasePath[0].revision) {\n\t\t\tsourcePath.shift();\n\t\t\ttargetRebasePath.shift();\n\t\t}\n\t}\n\n\tconst sourceCommits: GraphCommit<TChange>[] = [];\n\n\t// If all commits that are about to be rebased over on the target branch already comprise the start of the source branch,\n\t// are in the same order, and have no other commits interleaving them, then no rebasing needs to occur. Those commits can\n\t// simply be removed from the source branch, and the remaining commits on the source branch are reparented off of the new\n\t// base commit.\n\tif (targetRebasePath.length === 0) {\n\t\tfor (const c of sourcePath) {\n\t\t\tsourceCommits.push(mintCommit(sourceCommits[sourceCommits.length - 1] ?? newBase, c));\n\t\t}\n\t\treturn {\n\t\t\tnewSourceHead: sourceCommits[sourceCommits.length - 1] ?? newBase,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: {\n\t\t\t\tdeletedSourceCommits,\n\t\t\t\ttargetCommits,\n\t\t\t\tsourceCommits,\n\t\t\t},\n\t\t};\n\t}\n\n\t// For each source commit, rebase backwards over the inverses of any commits already rebased, and then\n\t// rebase forwards over the rest of the commits up to the new base before advancing the new base.\n\tlet newHead = newBase;\n\tconst revInfos = getRevInfoFromTaggedChanges(targetRebasePath);\n\t// Note that the `revisionMetadata` gets updated as `revInfos` gets updated.\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(revInfos);\n\tlet currentComposedEdit = makeAnonChange(changeRebaser.compose(targetRebasePath));\n\tfor (const c of sourcePath) {\n\t\tconst editsToCompose: TaggedChange<TChange>[] = [\n\t\t\ttagRollbackInverse(changeRebaser.invert(c, true), mintRevisionTag(), c.revision),\n\t\t\tcurrentComposedEdit,\n\t\t];\n\t\tif (sourceSet.has(c.revision)) {\n\t\t\tconst change = changeRebaser.rebase(c.change, currentComposedEdit, revisionMetadata);\n\t\t\tnewHead = {\n\t\t\t\trevision: c.revision,\n\t\t\t\tchange,\n\t\t\t\tparent: newHead,\n\t\t\t};\n\t\t\tsourceCommits.push(newHead);\n\t\t\teditsToCompose.push(tagChange(change, c.revision));\n\t\t}\n\t\tcurrentComposedEdit = makeAnonChange(changeRebaser.compose(editsToCompose));\n\t}\n\n\treturn {\n\t\tnewSourceHead: newHead,\n\t\tsourceChange: currentComposedEdit.change,\n\t\tcommits: {\n\t\t\tdeletedSourceCommits,\n\t\t\ttargetCommits,\n\t\t\tsourceCommits,\n\t\t},\n\t};\n}\n\n/**\n * \"Sandwich/Horseshoe Rebase\" a change over the given source and target branches\n * @param changeRebaser - the change rebaser responsible for rebasing the change over the commits in each branch\n * @param change - the change to rebase\n * @param sourceHead - the head of the branch that `change` is based on\n * @param targetHead - the branch to rebase `change` onto\n * @returns the rebased change\n *\n * @remarks inverses will be cached.\n */\nexport function rebaseChange<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchange: TChange,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n): TChange {\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tassert(\n\t\tfindCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]) !== undefined,\n\t\t0x576 /* branch A and branch B must be related */,\n\t);\n\n\tconst inverses = sourcePath.map((commit) =>\n\t\tinverseFromCommit(changeRebaser, commit, mintRevisionTag, true),\n\t);\n\tinverses.reverse();\n\treturn rebaseChangeOverChanges(changeRebaser, change, [...inverses, ...targetPath]);\n}\n\n/**\n * @internal\n */\nexport function revisionMetadataSourceFromInfo(\n\trevInfos: readonly RevisionInfo[],\n): RevisionMetadataSource {\n\tconst getIndex = (revision: RevisionTag): number | undefined => {\n\t\tconst index = revInfos.findIndex((revInfo) => revInfo.revision === revision);\n\t\treturn index >= 0 ? index : undefined;\n\t};\n\tconst tryGetInfo = (revision: RevisionTag | undefined): RevisionInfo | undefined => {\n\t\tif (revision === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst index = getIndex(revision);\n\t\treturn index === undefined ? undefined : revInfos[index];\n\t};\n\n\tconst hasRollback = (revision: RevisionTag): boolean => {\n\t\treturn revInfos.find((info) => info.rollbackOf === revision) !== undefined;\n\t};\n\n\treturn { getIndex, tryGetInfo, hasRollback };\n}\n\nexport function rebaseChangeOverChanges<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchangeToRebase: TChange,\n\tchangesToRebaseOver: TaggedChange<TChange>[],\n) {\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(\n\t\tgetRevInfoFromTaggedChanges(changesToRebaseOver),\n\t);\n\n\treturn changesToRebaseOver.reduce(\n\t\t(a, b) => changeRebaser.rebase(a, b, revisionMetadata),\n\t\tchangeToRebase,\n\t);\n}\n\n// TODO: Deduplicate\nfunction getRevInfoFromTaggedChanges(changes: TaggedChange<unknown>[]): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tfor (const taggedChange of changes) {\n\t\trevInfos.push(...revisionInfoFromTaggedChange(taggedChange));\n\t}\n\n\treturn revInfos;\n}\n\n// TODO: Deduplicate\nfunction revisionInfoFromTaggedChange(taggedChange: TaggedChange<unknown>): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tif (taggedChange.revision !== undefined) {\n\t\tconst info: Mutable<RevisionInfo> = { revision: taggedChange.revision };\n\t\tif (taggedChange.rollbackOf !== undefined) {\n\t\t\tinfo.rollbackOf = taggedChange.rollbackOf;\n\t\t}\n\t\trevInfos.push(info);\n\t}\n\treturn revInfos;\n}\n\nfunction inverseFromCommit<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tcommit: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n\tcache?: boolean,\n): TaggedChange<TChange> {\n\tconst inverse = commit.inverse ?? changeRebaser.invert(commit, true);\n\tif (cache === true && commit.inverse === undefined) {\n\t\tcommit.inverse = inverse;\n\t}\n\n\treturn tagRollbackInverse(inverse, mintRevisionTag(), commit.revision);\n}\n\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T, path?: T[]],\n): T;\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors. Returns\n * `undefined` if `descendant` is undefined.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n): T | undefined;\n/**\n * Find an ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the ancestor found by `predicate`,\n * but otherwise including `descendant`).\n * @param predicate - a function which will be evaluated on every ancestor of `descendant` until it returns true.\n * @returns the closest ancestor of `descendant` that satisfies `predicate`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * id: string;\n * parent?: Parented;\n * }\n * const g = { id: \"g\" }; // Grandparent\n * const p = { parent: g, id: \"p\" }; // Parent\n * const c = { parent: p, id: \"c\" }; // Child\n * const path: Parented[] = [];\n * const ancestor = findAncestor<Parented>([c, path], (n) => n.id === \"g\");\n * // ancestor === g\n * // path === [p, c]\n * ```\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean,\n): T | undefined;\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean = (t) => t.parent === undefined,\n): T | undefined {\n\tlet d: T | undefined;\n\tlet path: T[] | undefined;\n\tif (Array.isArray(descendant)) {\n\t\t[d, path] = descendant;\n\t} else {\n\t\td = descendant;\n\t}\n\tfor (let cur = d; cur !== undefined; cur = cur.parent) {\n\t\tif (predicate(cur)) {\n\t\t\tpath?.reverse();\n\t\t\treturn cur;\n\t\t}\n\t\tpath?.push(cur);\n\t}\n\n\tif (path !== undefined) {\n\t\tpath.length = 0;\n\t}\n\treturn undefined;\n}\n\n/**\n * Find a common ancestor between two descendants that are linked by parent pointers.\n * @param descendantA - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantA` (not including the ancestor).\n * @param descendantB - another descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantB` (not including the ancestor).\n * @returns the common ancestor of `descendantA` and `descendantB`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * parent?: Parented;\n * }\n * const shared = {};\n * const a = { parent: shared };\n * const b1 = { parent: shared };\n * const b2 = { parent: b1 };\n * const pathB: Parented[] = []\n * const ancestor = findCommonAncestor<Parented>(a, [b2, pathB]);\n * // ancestor === shared\n * // pathB === [b1, b2]\n * ```\n */\nexport function findCommonAncestor<T extends { parent?: T }>(\n\tdescendantA: T | [descendantA: T, path?: T[]] | undefined,\n\tdescendantB: T | [descendantB: T, path?: T[]] | undefined,\n): T | undefined {\n\tlet a: T | undefined;\n\tlet b: T | undefined;\n\tlet pathA: T[] | undefined;\n\tlet pathB: T[] | undefined;\n\tif (Array.isArray(descendantA)) {\n\t\t[a, pathA] = descendantA;\n\t\tassert(pathA === undefined || pathA.length === 0, 0x578 /* Path A must be empty */);\n\t} else {\n\t\ta = descendantA;\n\t}\n\tif (Array.isArray(descendantB)) {\n\t\t[b, pathB] = descendantB;\n\t\tassert(pathB === undefined || pathB.length === 0, 0x579 /* Path B must be empty */);\n\t} else {\n\t\tb = descendantB;\n\t}\n\n\tif (a === b) {\n\t\treturn a;\n\t}\n\n\tconst reversePaths = () => {\n\t\tpathA?.reverse();\n\t\tpathB?.reverse();\n\t};\n\n\tconst visited = new Set();\n\twhile (a !== undefined || b !== undefined) {\n\t\tif (a !== undefined) {\n\t\t\tif (visited.has(a)) {\n\t\t\t\tif (pathB !== undefined) {\n\t\t\t\t\tpathB.length = pathB.findIndex((r) => Object.is(r, a));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn a;\n\t\t\t}\n\t\t\tvisited.add(a);\n\t\t\tpathA?.push(a);\n\t\t\ta = a.parent;\n\t\t}\n\n\t\tif (b !== undefined) {\n\t\t\tif (visited.has(b)) {\n\t\t\t\tif (pathA !== undefined) {\n\t\t\t\t\tpathA.length = pathA.findIndex((r) => Object.is(r, b));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn b;\n\t\t\t}\n\t\t\tvisited.add(b);\n\t\t\tpathB?.push(b);\n\t\t\tb = b.parent;\n\t\t}\n\t}\n\n\tif (pathA !== undefined) {\n\t\tpathA.length = 0;\n\t}\n\tif (pathB !== undefined) {\n\t\tpathB.length = 0;\n\t}\n\treturn undefined;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/rebase/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,yDAQ4B;AAC5B,yCAAkE;AAqIlE,SAAgB,YAAY,CAC3B,eAAkC,EAClC,aAAqC,EACrC,UAAgC,EAChC,YAAkC,EAClC,UAAU,GAAG,YAAY;IAEzB,4CAA4C;IAC5C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,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,CAAC;AAClB,CAAC;AAlED,gDAkEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { Mutable } from \"../../util/index.js\";\n\nimport {\n\tChangeRebaser,\n\tRevisionInfo,\n\tRevisionMetadataSource,\n\tTaggedChange,\n\tmakeAnonChange,\n\ttagChange,\n\ttagRollbackInverse,\n} from \"./changeRebaser.js\";\nimport { GraphCommit, RevisionTag, mintCommit } from \"./types.js\";\n\n/**\n * Contains information about how the commit graph changed as the result of rebasing a source branch onto another target branch.\n * @remarks\n * ```text\n * Consider the commit graph below containing two branches, X and Y, with head commits C and E, respectively.\n * Branch Y branches off of Branch X at their common ancestor commit A, i.e. \"Y is based off of X at commit A\".\n *\n * A ─ B ─ C ← Branch X\n * └─ D ─ E ← Branch Y\n *\n * Branch Y is then rebased onto Branch X. This results in the following commit graph:\n *\n * A ─ B ─ C ← Branch X\n * └─ D'─ E'← Branch Y\n *\n * Commits D' and E' are the rebased versions of commits D and E, respectively. This results in:\n * deletedSourceCommits: [D, E],\n * targetCommits: [B, C],\n * sourceCommits: [D', E']\n * ```\n */\nexport interface RebasedCommits<TChange> {\n\t/**\n\t * The commits on the original source branch that were rebased. These are no longer referenced by the source branch and have\n\t * been replaced with new versions on the new source branch, see {@link sourceCommits}. In the case that the source\n\t * branch was already ahead of the target branch before the rebase, this list will be empty.\n\t */\n\tdeletedSourceCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the target branch that the source branch's commits were rebased over. These are now the direct\n\t * ancestors of {@link sourceCommits}. In the case that the source branch was already ahead of the target branch\n\t * before the rebase, this list will be empty.\n\t */\n\ttargetCommits: GraphCommit<TChange>[];\n\t/**\n\t * All commits on the source branch that are not also on the target branch after the rebase operation. In the case that the\n\t * source branch was already ahead of the target branch before the rebase, these are the same commits that were already on\n\t * the source branch before the rebase, otherwise these are the new, rebased versions of {@link deletedSourceCommits}.\n\t */\n\tsourceCommits: GraphCommit<TChange>[];\n}\n\nexport interface BranchRebaseResult<TChange> {\n\t/**\n\t * The head of a rebased source branch.\n\t */\n\treadonly newSourceHead: GraphCommit<TChange>;\n\t/**\n\t * A thunk that computes the cumulative change to the source branch (undefined if no change occurred)\n\t */\n\treadonly sourceChange: TChange | undefined;\n\t/**\n\t * Details about how the commits on the source branch changed\n\t */\n\treadonly commits: RebasedCommits<TChange>;\n}\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `targetHead`\n * @param targetHead - the commit to rebase the source branch onto\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. For example:\n * ```\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (B')-(D) <- Branch Y\n * //\n * // As Branch Y is rebased onto Branch X, commits B and B' cancel out so there is no version of B on the new rebased source branch\n * //\n * // (A)-(B)-(C) <- Branch X\n * // \\\n * // (D') <- Branch Y'\n * //\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\n\n/**\n * Rebases a source branch onto another commit in a target branch.\n *\n * A \"branch\" is defined as a \"head\" commit and all ancestors of that commit, i.e. one linked list in a graph of commits.\n *\n * The source and target branch must share an ancestor.\n * @param changeRebaser - the change rebaser responsible for rebasing the changes in the commits of each branch\n * @param sourceHead - the head of the source branch, which will be rebased onto `newBase`\n * @param targetCommit - the commit on the target branch to rebase the source branch onto.\n * @param targetHead - the head of the branch that `newBase` belongs to. Must be `newBase` or a descendent of `newBase`.\n * @returns a {@link BranchRebaseResult}\n * @remarks While a single branch must not have multiple commits with the same revision tag (that will result in undefined\n * behavior), there may be a commit on the source branch with the same revision tag as a commit on the target branch. If such\n * a pair is encountered while rebasing, it will be \"cancelled out\" in the new branch. Additionally, this function will rebase\n * the source branch _farther_ than `newBase` if the source branch's next commits after `newBase` match those on the target branch.\n * For example:\n * ```\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (B')-(D')-(F) <- Branch Y\n * //\n * // If Branch Y is rebased onto commit C of Branch X, the branches must at least look like this afterwards (B was cancelled out):\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (D'')-(F') <- Branch Y'\n * //\n * // But this function will recognize that B is equivalent to B' and D is equivalent to D', and instead produce:\n * //\n * // (A)-(B)-(C)-(D)-(E) <- Branch X\n * // \\\n * // (F') <- Branch Y'\n * ```\n */\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n): BranchRebaseResult<TChange>;\nexport function rebaseBranch<TChange>(\n\tmintRevisionTag: () => RevisionTag,\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetCommit: GraphCommit<TChange>,\n\ttargetHead = targetCommit,\n): BranchRebaseResult<TChange> {\n\t// Get both source and target as path arrays\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tconst ancestor = findCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]);\n\tassert(ancestor !== undefined, 0x675 /* branches must be related */);\n\n\t// Find where `targetCommit` is in the target branch\n\tconst targetCommitIndex = targetPath.findIndex((r) => r === targetCommit);\n\tif (targetCommitIndex === -1) {\n\t\t// If the targetCommit is not in the target path, then it is either disjoint from `target` or it is behind/at\n\t\t// the commit where source and target diverge (ancestor), in which case there is nothing more to rebase\n\t\t// TODO: Ideally, this would be an \"assertExpensive\"\n\t\tassert(\n\t\t\tfindCommonAncestor(targetCommit, targetHead) !== undefined,\n\t\t\t0x676 /* target commit is not in target branch */,\n\t\t);\n\t\treturn {\n\t\t\tnewSourceHead: sourceHead,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: { deletedSourceCommits: [], targetCommits: [], sourceCommits: sourcePath },\n\t\t};\n\t}\n\n\t// Iterate through the target path and look for commits that are also present on the source branch (i.e. they\n\t// have matching tags). Each commit found in the target branch can be skipped when processing the source branch\n\t// because it has already been rebased onto the target. In the case that one or more of these commits are present\n\t// directly after `targetCommit`, then the new base can be advanced further without having to do any work.\n\tconst sourceSet = new Set(sourcePath.map((r) => r.revision));\n\tlet newBaseIndex = targetCommitIndex;\n\n\tfor (let i = 0; i < targetPath.length; i += 1) {\n\t\tconst { revision } = targetPath[i];\n\t\tif (sourceSet.has(revision)) {\n\t\t\tsourceSet.delete(revision);\n\t\t\tnewBaseIndex = Math.max(newBaseIndex, i);\n\t\t} else if (i > targetCommitIndex) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/** The commit on the target branch that the new source branch branches off of (i.e. the new common ancestor) */\n\tconst newBase = targetPath[newBaseIndex];\n\t// Figure out how much of the trunk to start rebasing over.\n\tconst targetCommits = targetPath.slice(0, newBaseIndex + 1);\n\tconst deletedSourceCommits = [...sourcePath];\n\n\t// If the source and target rebase path begin with a range that has all the same revisions, remove it; it is\n\t// equivalent on both branches and doesn't need to be rebased.\n\tconst targetRebasePath = [...targetCommits];\n\tconst minLength = Math.min(sourcePath.length, targetRebasePath.length);\n\tfor (let i = 0; i < minLength; i++) {\n\t\tif (sourcePath[0].revision === targetRebasePath[0].revision) {\n\t\t\tsourcePath.shift();\n\t\t\ttargetRebasePath.shift();\n\t\t}\n\t}\n\n\tconst sourceCommits: GraphCommit<TChange>[] = [];\n\n\t// If all commits that are about to be rebased over on the target branch already comprise the start of the source branch,\n\t// are in the same order, and have no other commits interleaving them, then no rebasing needs to occur. Those commits can\n\t// simply be removed from the source branch, and the remaining commits on the source branch are reparented off of the new\n\t// base commit.\n\tif (targetRebasePath.length === 0) {\n\t\tfor (const c of sourcePath) {\n\t\t\tsourceCommits.push(mintCommit(sourceCommits[sourceCommits.length - 1] ?? newBase, c));\n\t\t}\n\t\treturn {\n\t\t\tnewSourceHead: sourceCommits[sourceCommits.length - 1] ?? newBase,\n\t\t\tsourceChange: undefined,\n\t\t\tcommits: {\n\t\t\t\tdeletedSourceCommits,\n\t\t\t\ttargetCommits,\n\t\t\t\tsourceCommits,\n\t\t\t},\n\t\t};\n\t}\n\n\t// For each source commit, rebase backwards over the inverses of any commits already rebased, and then\n\t// rebase forwards over the rest of the commits up to the new base before advancing the new base.\n\tlet newHead = newBase;\n\tconst revInfos = getRevInfoFromTaggedChanges(targetRebasePath);\n\t// Note that the `revisionMetadata` gets updated as `revInfos` gets updated.\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(revInfos);\n\tlet currentComposedEdit = makeAnonChange(changeRebaser.compose(targetRebasePath));\n\tfor (const c of sourcePath) {\n\t\tconst inverseTag = mintRevisionTag();\n\t\tconst inverse = tagRollbackInverse(changeRebaser.invert(c, true), inverseTag, c.revision);\n\t\tconst editsToCompose: TaggedChange<TChange>[] = [inverse, currentComposedEdit];\n\t\tif (sourceSet.has(c.revision)) {\n\t\t\tconst change = changeRebaser.rebase(c.change, currentComposedEdit, revisionMetadata);\n\t\t\tnewHead = {\n\t\t\t\trevision: c.revision,\n\t\t\t\tchange,\n\t\t\t\tparent: newHead,\n\t\t\t};\n\t\t\tsourceCommits.push(newHead);\n\t\t\teditsToCompose.push(tagChange(change, c.revision));\n\t\t}\n\t\tcurrentComposedEdit = makeAnonChange(changeRebaser.compose(editsToCompose));\n\t\trevInfos.unshift({ revision: inverseTag, rollbackOf: inverse.rollbackOf });\n\t\trevInfos.push({ revision: c.revision });\n\t}\n\n\treturn {\n\t\tnewSourceHead: newHead,\n\t\tsourceChange: currentComposedEdit.change,\n\t\tcommits: {\n\t\t\tdeletedSourceCommits,\n\t\t\ttargetCommits,\n\t\t\tsourceCommits,\n\t\t},\n\t};\n}\n\n/**\n * \"Sandwich/Horseshoe Rebase\" a change over the given source and target branches\n * @param changeRebaser - the change rebaser responsible for rebasing the change over the commits in each branch\n * @param change - the change to rebase\n * @param sourceHead - the head of the branch that `change` is based on\n * @param targetHead - the branch to rebase `change` onto\n * @returns the rebased change\n *\n * @remarks inverses will be cached.\n */\nexport function rebaseChange<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchange: TChange,\n\tsourceHead: GraphCommit<TChange>,\n\ttargetHead: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n): TChange {\n\tconst sourcePath: GraphCommit<TChange>[] = [];\n\tconst targetPath: GraphCommit<TChange>[] = [];\n\tassert(\n\t\tfindCommonAncestor([sourceHead, sourcePath], [targetHead, targetPath]) !== undefined,\n\t\t0x576 /* branch A and branch B must be related */,\n\t);\n\n\tconst inverses = sourcePath.map((commit) =>\n\t\tinverseFromCommit(changeRebaser, commit, mintRevisionTag, true),\n\t);\n\tinverses.reverse();\n\treturn rebaseChangeOverChanges(changeRebaser, change, [...inverses, ...targetPath]);\n}\n\n/**\n * @internal\n */\nexport function revisionMetadataSourceFromInfo(\n\trevInfos: readonly RevisionInfo[],\n): RevisionMetadataSource {\n\tconst getIndex = (revision: RevisionTag): number | undefined => {\n\t\tconst index = revInfos.findIndex((revInfo) => revInfo.revision === revision);\n\t\treturn index >= 0 ? index : undefined;\n\t};\n\tconst tryGetInfo = (revision: RevisionTag | undefined): RevisionInfo | undefined => {\n\t\tif (revision === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst index = getIndex(revision);\n\t\treturn index === undefined ? undefined : revInfos[index];\n\t};\n\n\tconst hasRollback = (revision: RevisionTag): boolean => {\n\t\treturn revInfos.find((info) => info.rollbackOf === revision) !== undefined;\n\t};\n\n\treturn { getIndex, tryGetInfo, hasRollback };\n}\n\nexport function rebaseChangeOverChanges<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tchangeToRebase: TChange,\n\tchangesToRebaseOver: TaggedChange<TChange>[],\n) {\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(\n\t\tgetRevInfoFromTaggedChanges(changesToRebaseOver),\n\t);\n\n\treturn changesToRebaseOver.reduce(\n\t\t(a, b) => changeRebaser.rebase(a, b, revisionMetadata),\n\t\tchangeToRebase,\n\t);\n}\n\n// TODO: Deduplicate\nfunction getRevInfoFromTaggedChanges(changes: TaggedChange<unknown>[]): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tfor (const taggedChange of changes) {\n\t\trevInfos.push(...revisionInfoFromTaggedChange(taggedChange));\n\t}\n\n\treturn revInfos;\n}\n\n// TODO: Deduplicate\nfunction revisionInfoFromTaggedChange(taggedChange: TaggedChange<unknown>): RevisionInfo[] {\n\tconst revInfos: RevisionInfo[] = [];\n\tif (taggedChange.revision !== undefined) {\n\t\tconst info: Mutable<RevisionInfo> = { revision: taggedChange.revision };\n\t\tif (taggedChange.rollbackOf !== undefined) {\n\t\t\tinfo.rollbackOf = taggedChange.rollbackOf;\n\t\t}\n\t\trevInfos.push(info);\n\t}\n\treturn revInfos;\n}\n\nfunction inverseFromCommit<TChange>(\n\tchangeRebaser: ChangeRebaser<TChange>,\n\tcommit: GraphCommit<TChange>,\n\tmintRevisionTag: () => RevisionTag,\n\tcache?: boolean,\n): TaggedChange<TChange> {\n\tconst inverse = commit.inverse ?? changeRebaser.invert(commit, true);\n\tif (cache === true && commit.inverse === undefined) {\n\t\tcommit.inverse = inverse;\n\t}\n\n\treturn tagRollbackInverse(inverse, mintRevisionTag(), commit.revision);\n}\n\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T, path?: T[]],\n): T;\n/**\n * Find the furthest ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the furthest ancestor,\n * but otherwise including `descendant`).\n * @returns the furthest ancestor of `descendant`, or `descendant` itself if `descendant` has no ancestors. Returns\n * `undefined` if `descendant` is undefined.\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n): T | undefined;\n/**\n * Find an ancestor of some descendant.\n * @param descendant - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of ancestry for `descendant` from most distant to closest (not including the ancestor found by `predicate`,\n * but otherwise including `descendant`).\n * @param predicate - a function which will be evaluated on every ancestor of `descendant` until it returns true.\n * @returns the closest ancestor of `descendant` that satisfies `predicate`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * id: string;\n * parent?: Parented;\n * }\n * const g = { id: \"g\" }; // Grandparent\n * const p = { parent: g, id: \"p\" }; // Parent\n * const c = { parent: p, id: \"c\" }; // Child\n * const path: Parented[] = [];\n * const ancestor = findAncestor<Parented>([c, path], (n) => n.id === \"g\");\n * // ancestor === g\n * // path === [p, c]\n * ```\n */\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean,\n): T | undefined;\nexport function findAncestor<T extends { parent?: T }>(\n\tdescendant: T | [descendant: T | undefined, path?: T[]] | undefined,\n\tpredicate: (t: T) => boolean = (t) => t.parent === undefined,\n): T | undefined {\n\tlet d: T | undefined;\n\tlet path: T[] | undefined;\n\tif (Array.isArray(descendant)) {\n\t\t[d, path] = descendant;\n\t} else {\n\t\td = descendant;\n\t}\n\tfor (let cur = d; cur !== undefined; cur = cur.parent) {\n\t\tif (predicate(cur)) {\n\t\t\tpath?.reverse();\n\t\t\treturn cur;\n\t\t}\n\t\tpath?.push(cur);\n\t}\n\n\tif (path !== undefined) {\n\t\tpath.length = 0;\n\t}\n\treturn undefined;\n}\n\n/**\n * Find a common ancestor between two descendants that are linked by parent pointers.\n * @param descendantA - a descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantA` (not including the ancestor).\n * @param descendantB - another descendant. If an empty `path` array is included, it will be populated\n * with the chain of commits from the ancestor to `descendantB` (not including the ancestor).\n * @returns the common ancestor of `descendantA` and `descendantB`, or `undefined` if no such ancestor exists.\n *\n * @example\n *\n * ```typescript\n * interface Parented {\n * parent?: Parented;\n * }\n * const shared = {};\n * const a = { parent: shared };\n * const b1 = { parent: shared };\n * const b2 = { parent: b1 };\n * const pathB: Parented[] = []\n * const ancestor = findCommonAncestor<Parented>(a, [b2, pathB]);\n * // ancestor === shared\n * // pathB === [b1, b2]\n * ```\n */\nexport function findCommonAncestor<T extends { parent?: T }>(\n\tdescendantA: T | [descendantA: T, path?: T[]] | undefined,\n\tdescendantB: T | [descendantB: T, path?: T[]] | undefined,\n): T | undefined {\n\tlet a: T | undefined;\n\tlet b: T | undefined;\n\tlet pathA: T[] | undefined;\n\tlet pathB: T[] | undefined;\n\tif (Array.isArray(descendantA)) {\n\t\t[a, pathA] = descendantA;\n\t\tassert(pathA === undefined || pathA.length === 0, 0x578 /* Path A must be empty */);\n\t} else {\n\t\ta = descendantA;\n\t}\n\tif (Array.isArray(descendantB)) {\n\t\t[b, pathB] = descendantB;\n\t\tassert(pathB === undefined || pathB.length === 0, 0x579 /* Path B must be empty */);\n\t} else {\n\t\tb = descendantB;\n\t}\n\n\tif (a === b) {\n\t\treturn a;\n\t}\n\n\tconst reversePaths = () => {\n\t\tpathA?.reverse();\n\t\tpathB?.reverse();\n\t};\n\n\tconst visited = new Set();\n\twhile (a !== undefined || b !== undefined) {\n\t\tif (a !== undefined) {\n\t\t\tif (visited.has(a)) {\n\t\t\t\tif (pathB !== undefined) {\n\t\t\t\t\tpathB.length = pathB.findIndex((r) => Object.is(r, a));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn a;\n\t\t\t}\n\t\t\tvisited.add(a);\n\t\t\tpathA?.push(a);\n\t\t\ta = a.parent;\n\t\t}\n\n\t\tif (b !== undefined) {\n\t\t\tif (visited.has(b)) {\n\t\t\t\tif (pathA !== undefined) {\n\t\t\t\t\tpathA.length = pathA.findIndex((r) => Object.is(r, b));\n\t\t\t\t}\n\t\t\t\treversePaths();\n\t\t\t\treturn b;\n\t\t\t}\n\t\t\tvisited.add(b);\n\t\t\tpathB?.push(b);\n\t\t\tb = b.parent;\n\t\t}\n\t}\n\n\tif (pathA !== undefined) {\n\t\tpathA.length = 0;\n\t}\n\tif (pathB !== undefined) {\n\t\tpathB.length = 0;\n\t}\n\treturn undefined;\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { disposeSymbol } from "../../util/index.js";
5
6
  /**
6
7
  * Allows reversion of a change made to SharedTree.
7
8
  *
@@ -16,13 +17,21 @@ export interface Revertible {
16
17
  */
17
18
  readonly status: RevertibleStatus;
18
19
  /**
19
- * Reverts the associated change.
20
+ * Reverts the associated change and disposes it.
20
21
  */
21
22
  revert(): void;
22
23
  /**
23
- * Releases this revertible so that it can no longer be used.
24
+ * Reverts the associated change and optionally disposes it.
25
+ *
26
+ * @param dispose - If true, the revertible will be disposed after being reverted.
27
+ * If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped
28
+ * due to merge conflicts, and one wants to attempt reverting again.
24
29
  */
25
- release(): void;
30
+ revert(dispose: boolean): void;
31
+ /**
32
+ * Disposes this revertible, allowing associated resources to be released.
33
+ */
34
+ [disposeSymbol](): void;
26
35
  }
27
36
  /**
28
37
  * The status of a {@link Revertible}.
@@ -1 +1 @@
1
- {"version":3,"file":"revertible.d.ts","sourceRoot":"","sources":["../../../src/core/revertible/revertible.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IACf;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;GAIG;AACH,oBAAY,gBAAgB;IAC3B,sCAAsC;IACtC,KAAK,IAAA;IACL,0EAA0E;IAC1E,QAAQ,IAAA;CACR"}
1
+ {"version":3,"file":"revertible.d.ts","sourceRoot":"","sources":["../../../src/core/revertible/revertible.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IACf;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,oBAAY,gBAAgB;IAC3B,sCAAsC;IACtC,KAAK,IAAA;IACL,0EAA0E;IAC1E,QAAQ,IAAA;CACR"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RevertibleStatus = void 0;
8
+ const index_js_1 = require("../../util/index.js");
8
9
  /**
9
10
  * The status of a {@link Revertible}.
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"revertible.js","sourceRoot":"","sources":["../../../src/core/revertible/revertible.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyBH;;;;GAIG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,sCAAsC;IACtC,yDAAK,CAAA;IACL,0EAA0E;IAC1E,+DAAQ,CAAA;AACT,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Allows reversion of a change made to SharedTree.\n *\n * @remarks\n * Applications wanting to implement undo/redo support might typically maintain two stacks of Revertibles, with optional eviction policy to free up memory.\n *\n * @public\n */\nexport interface Revertible {\n\t/**\n\t * The current status of the revertible.\n\t */\n\treadonly status: RevertibleStatus;\n\t/**\n\t * Reverts the associated change.\n\t */\n\trevert(): void;\n\t/**\n\t * Releases this revertible so that it can no longer be used.\n\t */\n\trelease(): void;\n}\n\n/**\n * The status of a {@link Revertible}.\n *\n * @public\n */\nexport enum RevertibleStatus {\n\t/** The revertible can be reverted. */\n\tValid,\n\t/** The revertible has been disposed. Reverting it will have no effect. */\n\tDisposed,\n}\n"]}
1
+ {"version":3,"file":"revertible.js","sourceRoot":"","sources":["../../../src/core/revertible/revertible.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAAoD;AAmCpD;;;;GAIG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,sCAAsC;IACtC,yDAAK,CAAA;IACL,0EAA0E;IAC1E,+DAAQ,CAAA;AACT,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { disposeSymbol } from \"../../util/index.js\";\n\n/**\n * Allows reversion of a change made to SharedTree.\n *\n * @remarks\n * Applications wanting to implement undo/redo support might typically maintain two stacks of Revertibles, with optional eviction policy to free up memory.\n *\n * @public\n */\nexport interface Revertible {\n\t/**\n\t * The current status of the revertible.\n\t */\n\treadonly status: RevertibleStatus;\n\n\t/**\n\t * Reverts the associated change and disposes it.\n\t */\n\trevert(): void;\n\t/**\n\t * Reverts the associated change and optionally disposes it.\n\t *\n\t * @param dispose - If true, the revertible will be disposed after being reverted.\n\t * If false, the revertible will remain valid. This can be useful for scenarios where the revert may be dropped\n\t * due to merge conflicts, and one wants to attempt reverting again.\n\t */\n\trevert(dispose: boolean): void;\n\n\t/**\n\t * Disposes this revertible, allowing associated resources to be released.\n\t */\n\t[disposeSymbol](): void;\n}\n\n/**\n * The status of a {@link Revertible}.\n *\n * @public\n */\nexport enum RevertibleStatus {\n\t/** The revertible can be reverted. */\n\tValid,\n\t/** The revertible has been disposed. Reverting it will have no effect. */\n\tDisposed,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"anchorSet.d.ts","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAiB,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,KAAK,EACL,UAAU,EACV,gBAAgB,EAChB,MAAM,EAKN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAON,MAAM,EACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAY,KAAK,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAOrD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;C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AAC,qBAAqB;IAkB7B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAQtB;;;;;;;;;;OAUG;IACI,cAAc,IAAI,gBAAgB,GAAG,YAAY;CAqVxD"}
@@ -380,6 +380,7 @@ class AnchorSet {
380
380
  */
381
381
  acquireVisitor() {
382
382
  (0, internal_1.assert)(this.activeVisitor === undefined, 0x767 /* Must release existing visitor before acquiring another */);
383
+ const referencedPathNodes = [];
383
384
  const visitor = {
384
385
  anchorSet: this,
385
386
  // Run `withNode` on anchorNode for parent if there is such an anchorNode.
@@ -395,6 +396,8 @@ class AnchorSet {
395
396
  // Delta traversal should early out in this case because no work is needed (and all move outs are known to not contain anchors).
396
397
  this.parent = this.anchorSet.internalizePath(this.parent);
397
398
  if (this.parent instanceof PathNode) {
399
+ this.parent.addRef();
400
+ referencedPathNodes.push(this.parent);
398
401
  withNode(this.parent);
399
402
  }
400
403
  }
@@ -407,6 +410,9 @@ class AnchorSet {
407
410
  parent: undefined,
408
411
  free() {
409
412
  (0, internal_1.assert)(this.anchorSet.activeVisitor !== undefined, 0x768 /* Multiple free calls for same visitor */);
413
+ for (const node of referencedPathNodes) {
414
+ node.removeRef();
415
+ }
410
416
  this.anchorSet.activeVisitor = undefined;
411
417
  },
412
418
  notifyChildrenChanging() {
@@ -789,7 +795,7 @@ class PathNode extends index_js_2.ReferenceCountedBase {
789
795
  }
790
796
  // Called when refcount is set to 0.
791
797
  // Node may be kept alive by children or events after this point.
792
- dispose() {
798
+ onUnreferenced() {
793
799
  this.considerDispose();
794
800
  }
795
801
  /**