@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
@@ -4,53 +4,39 @@
4
4
  */
5
5
  import { type ChangeRebaser, type GraphCommit } from "../core/index.js";
6
6
  import type { ChangeEnricherReadonlyCheckout } from "./changeEnricher.js";
7
+ import { type SharedTreeBranchChange } from "./branch.js";
7
8
  /**
8
9
  * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.
9
10
  */
10
11
  export declare class BranchCommitEnricher<TChange> {
11
- private readonly transactionEnricher;
12
- private readonly enricher;
13
- /**
14
- * Maps each local commit to the corresponding enriched commit.
15
- * Entries are added when the commits are prepared (before being applied and submitted).
16
- * Entries are removed when the commits are retrieved for submission (after being applied).
17
- * It's possible an entry will linger in the map indefinitely if it is never retrieved for submission.
18
- * This would happen if applying a commit were to fail and the commit were not retrieved/purged after the failure.
19
- */
20
- private readonly preparedCommits;
12
+ #private;
21
13
  constructor(rebaser: ChangeRebaser<TChange>, enricher: ChangeEnricherReadonlyCheckout<TChange>);
22
14
  /**
23
- * @returns The number of commits that have been prepared but not yet retrieved.
15
+ * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.
16
+ * @param change - The change to process.
17
+ * @param isAttached - Whether or not the SharedTree is attached to the service.
24
18
  */
25
- get preparedCommitsCount(): number;
26
- startNewTransaction(): void;
27
- commitCurrentTransaction(): void;
28
- abortCurrentTransaction(): void;
19
+ processChange(change: SharedTreeBranchChange<TChange>): void;
29
20
  /**
30
- * Adds a commit to the enricher.
31
- * @param commit - A commit that is part of a transaction.
21
+ * Retrieves the enriched version of the given commit.
22
+ * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.
23
+ * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.
32
24
  */
33
- ingestTransactionCommit(commit: GraphCommit<TChange>): void;
25
+ enrich(commit: GraphCommit<TChange>): GraphCommit<TChange>;
34
26
  /**
35
- * Prepares an enriched commit for later submission (see {@link BranchCommitEnricher.getPreparedCommit}).
36
- * @param commit - The commit to prepare an enriched version of.
37
- * @param concludesOuterTransaction - Whether the commit concludes an outer transaction.
38
- *
39
- * Each call to this method must be followed by a call to {@link BranchCommitEnricher.getPreparedCommit} or
40
- * {@link BranchCommitEnricher.purgePreparedCommits}. Failing to do so will result in a memory leak.
27
+ * Notify the enricher that a new transaction has started.
28
+ * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing "nested transactions".
41
29
  */
42
- prepareCommit(commit: GraphCommit<TChange>, concludesOuterTransaction: boolean): void;
30
+ startTransaction(): void;
43
31
  /**
44
- * @param commit - A commit previously passed to {@link BranchCommitEnricher.prepareCommit}.
45
- * @returns The enriched commit corresponds to the given commit.
32
+ * Commit the current transaction.
33
+ * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.
46
34
  */
47
- getPreparedCommit(commit: GraphCommit<TChange>): GraphCommit<TChange>;
35
+ commitTransaction(): void;
48
36
  /**
49
- * Purges all commits that have been prepared but not been retrieved.
50
- * This should be called to avoid memory leaks if the prepared commits are no longer needed.
51
- *
52
- * Does not affect ingested transaction commits.
37
+ * Notify the enricher that the current transaction has been aborted.
38
+ * @remarks This will throw an error if there is no ongoing transaction.
53
39
  */
54
- purgePreparedCommits(): void;
40
+ abortTransaction(): void;
55
41
  }
56
42
  //# sourceMappingURL=branchCommitEnricher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"branchCommitEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAiB,MAAM,kBAAkB,CAAC;AACvF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAG1E;;GAEG;AACH,qBAAa,oBAAoB,CAAC,OAAO;IACxC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA+B;IACnE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;IACnE;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CACrB;gBAGV,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAMlD;;OAEG;IACH,IAAW,oBAAoB,IAAI,MAAM,CAExC;IAEM,mBAAmB,IAAI,IAAI;IAI3B,wBAAwB,IAAI,IAAI;IAIhC,uBAAuB,IAAI,IAAI;IAItC;;;OAGG;IACI,uBAAuB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAMlE;;;;;;;OAOG;IACI,aAAa,CACnB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAC5B,yBAAyB,EAAE,OAAO,GAChC,IAAI;IAcP;;;OAGG;IACI,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;IAO5E;;;;;OAKG;IACI,oBAAoB,IAAI,IAAI;CAGnC"}
1
+ {"version":3,"file":"branchCommitEnricher.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAwB,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEhF;;GAEG;AACH,qBAAa,oBAAoB,CAAC,OAAO;;gBAoBvC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,QAAQ,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAMlD;;;;OAIG;IACI,aAAa,CAAC,MAAM,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,IAAI;IA2BnE;;;;OAIG;IACI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;IAOjE;;;OAGG;IACI,gBAAgB,IAAI,IAAI;IAI/B;;;OAGG;IACI,iBAAiB,IAAI,IAAI;IAIhC;;;OAGG;IACI,gBAAgB,IAAI,IAAI;CAG/B"}
@@ -2,86 +2,105 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
6
+ if (kind === "m") throw new TypeError("Private method is not writable");
7
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
9
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _BranchCommitEnricher_transactionEnricher, _BranchCommitEnricher_enricher, _BranchCommitEnricher_preparedCommits, _BranchCommitEnricher_getOuterTransactionChange;
5
17
  import { assert } from "@fluidframework/core-utils/internal";
6
- import { replaceChange } from "../core/index.js";
18
+ import { replaceChange, } from "../core/index.js";
7
19
  import { TransactionEnricher } from "./transactionEnricher.js";
20
+ import { getChangeReplaceType } from "./branch.js";
8
21
  /**
9
22
  * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.
10
23
  */
11
24
  export class BranchCommitEnricher {
12
25
  constructor(rebaser, enricher) {
26
+ _BranchCommitEnricher_transactionEnricher.set(this, void 0);
27
+ _BranchCommitEnricher_enricher.set(this, void 0);
13
28
  /**
14
29
  * Maps each local commit to the corresponding enriched commit.
15
- * Entries are added when the commits are prepared (before being applied and submitted).
16
- * Entries are removed when the commits are retrieved for submission (after being applied).
17
- * It's possible an entry will linger in the map indefinitely if it is never retrieved for submission.
18
- * This would happen if applying a commit were to fail and the commit were not retrieved/purged after the failure.
30
+ * @remarks
31
+ * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.
32
+ * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.
33
+ * In the event that an entry is not explicitly removed, it will eventually be {@link WeakMap | dropped from memory} along with the associated commit.
19
34
  */
20
- this.preparedCommits = new Map();
21
- this.enricher = enricher;
22
- this.transactionEnricher = new TransactionEnricher(rebaser, this.enricher);
35
+ _BranchCommitEnricher_preparedCommits.set(this, new Map());
36
+ /**
37
+ * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.
38
+ * Calling this function will compute the composition of that transaction's commits.
39
+ * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.
40
+ */
41
+ _BranchCommitEnricher_getOuterTransactionChange.set(this, void 0);
42
+ __classPrivateFieldSet(this, _BranchCommitEnricher_enricher, enricher, "f");
43
+ __classPrivateFieldSet(this, _BranchCommitEnricher_transactionEnricher, new TransactionEnricher(rebaser, __classPrivateFieldGet(this, _BranchCommitEnricher_enricher, "f")), "f");
23
44
  }
24
45
  /**
25
- * @returns The number of commits that have been prepared but not yet retrieved.
46
+ * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.
47
+ * @param change - The change to process.
48
+ * @param isAttached - Whether or not the SharedTree is attached to the service.
26
49
  */
27
- get preparedCommitsCount() {
28
- return this.preparedCommits.size;
29
- }
30
- startNewTransaction() {
31
- this.transactionEnricher.startNewTransaction();
32
- }
33
- commitCurrentTransaction() {
34
- this.transactionEnricher.commitCurrentTransaction();
35
- }
36
- abortCurrentTransaction() {
37
- this.transactionEnricher.abortCurrentTransaction();
50
+ processChange(change) {
51
+ if (__classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").isTransacting()) {
52
+ if (change.type === "append") {
53
+ for (const commit of change.newCommits) {
54
+ // We do not submit ops for changes that are part of a transaction.
55
+ // But we need to enrich the commits that will be sent if the transaction is committed.
56
+ __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").addTransactionStep(commit);
57
+ }
58
+ }
59
+ }
60
+ else {
61
+ if (change.type === "append" ||
62
+ (change.type === "replace" && getChangeReplaceType(change) === "transactionCommit")) {
63
+ for (const newCommit of change.newCommits) {
64
+ const newChange = __classPrivateFieldGet(this, _BranchCommitEnricher_getOuterTransactionChange, "f")?.call(this, newCommit.revision) ??
65
+ __classPrivateFieldGet(this, _BranchCommitEnricher_enricher, "f").updateChangeEnrichments(newCommit.change, newCommit.revision);
66
+ __classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").set(newCommit, replaceChange(newCommit, newChange));
67
+ }
68
+ }
69
+ }
70
+ __classPrivateFieldSet(this, _BranchCommitEnricher_getOuterTransactionChange, undefined, "f");
38
71
  }
39
72
  /**
40
- * Adds a commit to the enricher.
41
- * @param commit - A commit that is part of a transaction.
73
+ * Retrieves the enriched version of the given commit.
74
+ * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.
75
+ * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.
42
76
  */
43
- ingestTransactionCommit(commit) {
44
- // We do not submit ops for changes that are part of a transaction.
45
- // But we need to enrich the commits that will be sent if the transaction is committed.
46
- this.transactionEnricher.addTransactionStep(commit);
77
+ enrich(commit) {
78
+ const prepared = __classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").get(commit);
79
+ assert(prepared !== undefined, 0x980 /* Unknown commit */);
80
+ __classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").delete(commit);
81
+ return prepared;
47
82
  }
48
83
  /**
49
- * Prepares an enriched commit for later submission (see {@link BranchCommitEnricher.getPreparedCommit}).
50
- * @param commit - The commit to prepare an enriched version of.
51
- * @param concludesOuterTransaction - Whether the commit concludes an outer transaction.
52
- *
53
- * Each call to this method must be followed by a call to {@link BranchCommitEnricher.getPreparedCommit} or
54
- * {@link BranchCommitEnricher.purgePreparedCommits}. Failing to do so will result in a memory leak.
84
+ * Notify the enricher that a new transaction has started.
85
+ * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing "nested transactions".
55
86
  */
56
- prepareCommit(commit, concludesOuterTransaction) {
57
- let enrichedChange;
58
- if (concludesOuterTransaction) {
59
- assert(this.transactionEnricher !== undefined, 0x97f /* Unexpected transaction commit without transaction steps */);
60
- enrichedChange = this.transactionEnricher.getComposedChange(commit.revision);
61
- }
62
- else {
63
- enrichedChange = this.enricher.updateChangeEnrichments(commit.change, commit.revision);
64
- }
65
- this.preparedCommits.set(commit, replaceChange(commit, enrichedChange));
87
+ startTransaction() {
88
+ __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").startTransaction();
66
89
  }
67
90
  /**
68
- * @param commit - A commit previously passed to {@link BranchCommitEnricher.prepareCommit}.
69
- * @returns The enriched commit corresponds to the given commit.
91
+ * Commit the current transaction.
92
+ * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.
70
93
  */
71
- getPreparedCommit(commit) {
72
- const prepared = this.preparedCommits.get(commit);
73
- assert(prepared !== undefined, 0x980 /* Unknown commit */);
74
- this.preparedCommits.delete(commit);
75
- return prepared;
94
+ commitTransaction() {
95
+ __classPrivateFieldSet(this, _BranchCommitEnricher_getOuterTransactionChange, __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").commitTransaction(), "f");
76
96
  }
77
97
  /**
78
- * Purges all commits that have been prepared but not been retrieved.
79
- * This should be called to avoid memory leaks if the prepared commits are no longer needed.
80
- *
81
- * Does not affect ingested transaction commits.
98
+ * Notify the enricher that the current transaction has been aborted.
99
+ * @remarks This will throw an error if there is no ongoing transaction.
82
100
  */
83
- purgePreparedCommits() {
84
- this.preparedCommits.clear();
101
+ abortTransaction() {
102
+ __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").abortTransaction();
85
103
  }
86
104
  }
105
+ _BranchCommitEnricher_transactionEnricher = new WeakMap(), _BranchCommitEnricher_enricher = new WeakMap(), _BranchCommitEnricher_preparedCommits = new WeakMap(), _BranchCommitEnricher_getOuterTransactionChange = new WeakMap();
87
106
  //# sourceMappingURL=branchCommitEnricher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"branchCommitEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAwC,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAahC,YACC,OAA+B,EAC/B,QAAiD;QAZlD;;;;;;WAMG;QACc,oBAAe,GAC/B,IAAI,GAAG,EAAE,CAAC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QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,oBAAoB;QAC1B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type ChangeRebaser, type GraphCommit, replaceChange } from \"../core/index.js\";\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\nimport { TransactionEnricher } from \"./transactionEnricher.js\";\n\n/**\n * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.\n */\nexport class BranchCommitEnricher<TChange> {\n\tprivate readonly transactionEnricher: TransactionEnricher<TChange>;\n\tprivate readonly enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t/**\n\t * Maps each local commit to the corresponding enriched commit.\n\t * Entries are added when the commits are prepared (before being applied and submitted).\n\t * Entries are removed when the commits are retrieved for submission (after being applied).\n\t * It's possible an entry will linger in the map indefinitely if it is never retrieved for submission.\n\t * This would happen if applying a commit were to fail and the commit were not retrieved/purged after the failure.\n\t */\n\tprivate readonly preparedCommits: Map<GraphCommit<TChange>, GraphCommit<TChange>> =\n\t\tnew Map();\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.enricher = enricher;\n\t\tthis.transactionEnricher = new TransactionEnricher(rebaser, this.enricher);\n\t}\n\n\t/**\n\t * @returns The number of commits that have been prepared but not yet retrieved.\n\t */\n\tpublic get preparedCommitsCount(): number {\n\t\treturn this.preparedCommits.size;\n\t}\n\n\tpublic startNewTransaction(): void {\n\t\tthis.transactionEnricher.startNewTransaction();\n\t}\n\n\tpublic commitCurrentTransaction(): void {\n\t\tthis.transactionEnricher.commitCurrentTransaction();\n\t}\n\n\tpublic abortCurrentTransaction(): void {\n\t\tthis.transactionEnricher.abortCurrentTransaction();\n\t}\n\n\t/**\n\t * Adds a commit to the enricher.\n\t * @param commit - A commit that is part of a transaction.\n\t */\n\tpublic ingestTransactionCommit(commit: GraphCommit<TChange>): void {\n\t\t// We do not submit ops for changes that are part of a transaction.\n\t\t// But we need to enrich the commits that will be sent if the transaction is committed.\n\t\tthis.transactionEnricher.addTransactionStep(commit);\n\t}\n\n\t/**\n\t * Prepares an enriched commit for later submission (see {@link BranchCommitEnricher.getPreparedCommit}).\n\t * @param commit - The commit to prepare an enriched version of.\n\t * @param concludesOuterTransaction - Whether the commit concludes an outer transaction.\n\t *\n\t * Each call to this method must be followed by a call to {@link BranchCommitEnricher.getPreparedCommit} or\n\t * {@link BranchCommitEnricher.purgePreparedCommits}. Failing to do so will result in a memory leak.\n\t */\n\tpublic prepareCommit(\n\t\tcommit: GraphCommit<TChange>,\n\t\tconcludesOuterTransaction: boolean,\n\t): void {\n\t\tlet enrichedChange: TChange;\n\t\tif (concludesOuterTransaction) {\n\t\t\tassert(\n\t\t\t\tthis.transactionEnricher !== undefined,\n\t\t\t\t0x97f /* Unexpected transaction commit without transaction steps */,\n\t\t\t);\n\t\t\tenrichedChange = this.transactionEnricher.getComposedChange(commit.revision);\n\t\t} else {\n\t\t\tenrichedChange = this.enricher.updateChangeEnrichments(commit.change, commit.revision);\n\t\t}\n\t\tthis.preparedCommits.set(commit, replaceChange(commit, enrichedChange));\n\t}\n\n\t/**\n\t * @param commit - A commit previously passed to {@link BranchCommitEnricher.prepareCommit}.\n\t * @returns The enriched commit corresponds to the given commit.\n\t */\n\tpublic getPreparedCommit(commit: GraphCommit<TChange>): GraphCommit<TChange> {\n\t\tconst prepared = this.preparedCommits.get(commit);\n\t\tassert(prepared !== undefined, 0x980 /* Unknown commit */);\n\t\tthis.preparedCommits.delete(commit);\n\t\treturn prepared;\n\t}\n\n\t/**\n\t * Purges all commits that have been prepared but not been retrieved.\n\t * This should be called to avoid memory leaks if the prepared commits are no longer needed.\n\t *\n\t * Does not affect ingested transaction commits.\n\t */\n\tpublic purgePreparedCommits(): void {\n\t\tthis.preparedCommits.clear();\n\t}\n}\n"]}
1
+ {"version":3,"file":"branchCommitEnricher.js","sourceRoot":"","sources":["../../src/shared-tree-core/branchCommitEnricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAGN,aAAa,GAEb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAA+B,MAAM,aAAa,CAAC;AAEhF;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAmBhC,YACC,OAA+B,EAC/B,QAAiD;QApBzC,4DAAmD;QACnD,iDAAmD;QAC5D;;;;;;WAMG;QACM,gDAAwE,IAAI,GAAG,EAAE,EAAC;QAE3F;;;;WAIG;QACH,kEAAgE;QAM/D,uBAAA,IAAI,kCAAa,QAAQ,MAAA,CAAC;QAC1B,uBAAA,IAAI,6CAAwB,IAAI,mBAAmB,CAAC,OAAO,EAAE,uBAAA,IAAI,sCAAU,CAAC,MAAA,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,MAAuC;QAC3D,IAAI,uBAAA,IAAI,iDAAqB,CAAC,aAAa,EAAE,EAAE,CAAC;YAC/C,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;oBACxC,mEAAmE;oBACnE,uFAAuF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ACjF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ChangeRebaser,\n\ttype GraphCommit,\n\treplaceChange,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\nimport { TransactionEnricher } from \"./transactionEnricher.js\";\nimport { getChangeReplaceType, type SharedTreeBranchChange } from \"./branch.js\";\n\n/**\n * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.\n */\nexport class BranchCommitEnricher<TChange> {\n\treadonly #transactionEnricher: TransactionEnricher<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t/**\n\t * Maps each local commit to the corresponding enriched commit.\n\t * @remarks\n\t * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.\n\t * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.\n\t * In the event that an entry is not explicitly removed, it will eventually be {@link WeakMap | dropped from memory} along with the associated commit.\n\t */\n\treadonly #preparedCommits: WeakMap<GraphCommit<TChange>, GraphCommit<TChange>> = new Map();\n\n\t/**\n\t * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.\n\t * Calling this function will compute the composition of that transaction's commits.\n\t * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.\n\t */\n\t#getOuterTransactionChange?: (revision: RevisionTag) => TChange;\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#enricher = enricher;\n\t\tthis.#transactionEnricher = new TransactionEnricher(rebaser, this.#enricher);\n\t}\n\n\t/**\n\t * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.\n\t * @param change - The change to process.\n\t * @param isAttached - Whether or not the SharedTree is attached to the service.\n\t */\n\tpublic processChange(change: SharedTreeBranchChange<TChange>): void {\n\t\tif (this.#transactionEnricher.isTransacting()) {\n\t\t\tif (change.type === \"append\") {\n\t\t\t\tfor (const commit of change.newCommits) {\n\t\t\t\t\t// We do not submit ops for changes that are part of a transaction.\n\t\t\t\t\t// But we need to enrich the commits that will be sent if the transaction is committed.\n\t\t\t\t\tthis.#transactionEnricher.addTransactionStep(commit);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (\n\t\t\t\tchange.type === \"append\" ||\n\t\t\t\t(change.type === \"replace\" && getChangeReplaceType(change) === \"transactionCommit\")\n\t\t\t) {\n\t\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\t\tconst newChange =\n\t\t\t\t\t\tthis.#getOuterTransactionChange?.(newCommit.revision) ??\n\t\t\t\t\t\tthis.#enricher.updateChangeEnrichments(newCommit.change, newCommit.revision);\n\n\t\t\t\t\tthis.#preparedCommits.set(newCommit, replaceChange(newCommit, newChange));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.#getOuterTransactionChange = undefined;\n\t}\n\n\t/**\n\t * Retrieves the enriched version of the given commit.\n\t * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.\n\t * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.\n\t */\n\tpublic enrich(commit: GraphCommit<TChange>): GraphCommit<TChange> {\n\t\tconst prepared = this.#preparedCommits.get(commit);\n\t\tassert(prepared !== undefined, 0x980 /* Unknown commit */);\n\t\tthis.#preparedCommits.delete(commit);\n\t\treturn prepared;\n\t}\n\n\t/**\n\t * Notify the enricher that a new transaction has started.\n\t * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing \"nested transactions\".\n\t */\n\tpublic startTransaction(): void {\n\t\tthis.#transactionEnricher.startTransaction();\n\t}\n\n\t/**\n\t * Commit the current transaction.\n\t * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.\n\t */\n\tpublic commitTransaction(): void {\n\t\tthis.#getOuterTransactionChange = this.#transactionEnricher.commitTransaction();\n\t}\n\n\t/**\n\t * Notify the enricher that the current transaction has been aborted.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic abortTransaction(): void {\n\t\tthis.#transactionEnricher.abortTransaction();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultResubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,KAAK,EAAE,8BAA8B,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElF;;GAEG;AACH,qBAAa,sBAAsB,CAAC,OAAO,CAAE,YAAW,eAAe,CAAC,OAAO,CAAC;IAwB9E;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;IA/BrB;;OAEG;IACH,OAAO,CAAC,aAAa,CAA8B;IAEnD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA8B;IAEnD;;;;;;;;;OASG;IACH,OAAO,CAAC,wCAAwC,CAAc;;IAG7D;;OAEG;IACc,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,OAAO;IACzE;;;OAGG;IACc,GAAG,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAGvD,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAWrD,kBAAkB,CAAC,UAAU,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;IAoDrE,cAAc,IAAI,WAAW,CAAC,OAAO,CAAC;IAQ7C,IAAW,iBAAiB,IAAI,OAAO,CAEtC;IAEM,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAavD"}
1
+ {"version":3,"file":"defaultResubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,KAAK,EAAE,8BAA8B,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElF;;GAEG;AACH,qBAAa,sBAAsB,CAAC,OAAO,CAAE,YAAW,eAAe,CAAC,OAAO,CAAC;IAwB9E;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;IA/BrB;;OAEG;IACH,OAAO,CAAC,aAAa,CAA8B;IAEnD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA8B;IAEnD;;;;;;;;;OASG;IACH,OAAO,CAAC,wCAAwC,CAAc;;IAG7D;;OAEG;IACc,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,OAAO;IACzE;;;OAGG;IACc,GAAG,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAGvD,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAWrD,kBAAkB,CAAC,UAAU,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;IAoDrE,cAAc,IAAI,WAAW,CAAC,OAAO,CAAC;IAS7C,IAAW,iBAAiB,IAAI,OAAO,CAEtC;IAEM,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAavD"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert, oob } from "@fluidframework/core-utils/internal";
6
- import { disposeSymbol } from "../util/index.js";
6
+ import { disposeSymbol, hasSome } from "../util/index.js";
7
7
  /**
8
8
  * Default implementation of {@link ResubmitMachine}.
9
9
  */
@@ -88,7 +88,8 @@ export class DefaultResubmitMachine {
88
88
  }
89
89
  peekNextCommit() {
90
90
  assert(this.isInResubmitPhase, 0x982 /* No available commit to resubmit outside of resubmit phase */);
91
- return this.resubmitQueue[0] ?? oob();
91
+ assert(hasSome(this.resubmitQueue), 0xa87 /* Expected resubmit queue to be non-empty */);
92
+ return this.resubmitQueue[0];
92
93
  }
93
94
  get isInResubmitPhase() {
94
95
  return this.resubmitQueue.length !== 0;
@@ -1 +1 @@
1
- {"version":3,"file":"defaultResubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAuBlC;IACC;;OAEG;IACc,YAAwD;IACzE;;;OAGG;IACc,GAA4C;QAL5C,iBAAY,GAAZ,YAAY,CAA4C;QAKxD,QAAG,GAAH,GAAG,CAAyC;QA/B9D;;WAEG;QACK,kBAAa,GAA2B,EAAE,CAAC;QAEnD;;WAEG;QACK,kBAAa,GAA2B,EAAE,CAAC;QAEnD;;;;;;;;;WASG;QACK,6CAAwC,GAAW,CAAC,CAAC,CAAC;IAY3D,CAAC;IAEG,iBAAiB,CAAC,MAA4B;QACpD,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC9C,MAAM,CACL,UAAU,KAAK,MAAM,EACrB,KAAK,CAAC,uDAAuD,CAC7D,CAAC;QACH,CAAC;QACD,IAAI,C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C,wCAAwC,IAAI,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,mCAAmC;YACnC,IAAI,CAAC,wCAAwC,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;CACD","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 { GraphCommit, TaggedChange } from \"../core/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\nimport type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from \"./index.js\";\n\n/**\n * Default implementation of {@link ResubmitMachine}.\n */\nexport class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange> {\n\t/**\n\t * The list of commits (from oldest to most recent) that have been submitted but not sequenced.\n\t */\n\tprivate inFlightQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * The list of commits (from oldest to most recent) that should be resubmitted.\n\t */\n\tprivate resubmitQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has\n\t * undergone rebasing but whose enrichments have not been updated.\n\t * All in-flight commits with an index inferior or equal to this number have stale enrichments.\n\t *\n\t * Is -1 when *any* of the following is true:\n\t * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)\n\t * - None of the in-flight commits have been rebased\n\t * - In-flight commits that have been rebased have all had their enrichments updated\n\t */\n\tprivate latestInFlightCommitWithStaleEnrichments: number = -1;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A function that can create a rollback for a given change.\n\t\t */\n\t\tprivate readonly makeRollback: (change: TaggedChange<TChange>) => TChange,\n\t\t/**\n\t\t * Change enricher that represent the tip of the top-level local branch (i.e., the branch on which in-flight\n\t\t * commits are applied and automatically rebased).\n\t\t */\n\t\tprivate readonly tip: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {}\n\n\tpublic onCommitSubmitted(commit: GraphCommit<TChange>): void {\n\t\tif (this.isInResubmitPhase) {\n\t\t\tconst toResubmit = this.resubmitQueue.shift();\n\t\t\tassert(\n\t\t\t\ttoResubmit === commit,\n\t\t\t\t0x981 /* Unexpected commit submitted during resubmit phase */,\n\t\t\t);\n\t\t}\n\t\tthis.inFlightQueue.push(commit);\n\t}\n\n\tpublic prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {\n\t\tassert(\n\t\t\t!this.isInResubmitPhase,\n\t\t\t0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,\n\t\t);\n\t\tassert(\n\t\t\ttoResubmit.length === this.inFlightQueue.length,\n\t\t\t0x958 /* Unexpected resubmit of more or fewer commits than are in flight */,\n\t\t);\n\t\tif (this.latestInFlightCommitWithStaleEnrichments === -1) {\n\t\t\t// No in-flight commits have stale enrichments, so we can resubmit them as is\n\t\t\tthis.resubmitQueue = this.inFlightQueue;\n\t\t\tthis.inFlightQueue = [];\n\t\t} else {\n\t\t\tconst checkout = this.tip.fork();\n\t\t\t// Roll back the checkout to the state before the oldest commit\n\t\t\tfor (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst rollback = this.makeRollback(commit);\n\t\t\t\t// WARNING: it's not currently possible to roll back past a schema change (see AB#7265).\n\t\t\t\t// Either we have to make it possible to do so, or this logic will have to change to work\n\t\t\t\t// forwards from an earlier fork instead of backwards.\n\t\t\t\tcheckout.applyTipChange(rollback);\n\t\t\t}\n\t\t\t// Update the enrichments of the stale commits\n\t\t\tfor (\n\t\t\t\tlet iCommit = 0;\n\t\t\t\tiCommit <= this.latestInFlightCommitWithStaleEnrichments;\n\t\t\t\tiCommit += 1\n\t\t\t) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst enrichedChange = checkout.updateChangeEnrichments(\n\t\t\t\t\tcommit.change,\n\t\t\t\t\tcommit.revision,\n\t\t\t\t);\n\t\t\t\tconst enrichedCommit = { ...commit, change: enrichedChange };\n\t\t\t\tthis.resubmitQueue.push(enrichedCommit);\n\t\t\t\tif (iCommit < this.latestInFlightCommitWithStaleEnrichments) {\n\t\t\t\t\tcheckout.applyTipChange(enrichedChange, commit.revision);\n\t\t\t\t}\n\t\t\t\tthis.inFlightQueue.shift();\n\t\t\t}\n\t\t\tcheckout[disposeSymbol]();\n\t\t\t// Whatever commits are left do not have stale enrichments\n\t\t\tfor (const commit of this.inFlightQueue) {\n\t\t\t\tthis.resubmitQueue.push(commit);\n\t\t\t}\n\t\t\tthis.inFlightQueue.length = 0;\n\t\t}\n\t\tthis.latestInFlightCommitWithStaleEnrichments = -1;\n\t}\n\n\tpublic peekNextCommit(): GraphCommit<TChange> {\n\t\tassert(\n\t\t\tthis.isInResubmitPhase,\n\t\t\t0x982 /* No available commit to resubmit outside of resubmit phase */,\n\t\t);\n\t\treturn this.resubmitQueue[0] ?? oob();\n\t}\n\n\tpublic get isInResubmitPhase(): boolean {\n\t\treturn this.resubmitQueue.length !== 0;\n\t}\n\n\tpublic onSequencedCommitApplied(isLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\t// The oldest in-flight commit has been sequenced\n\t\t\tassert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);\n\t\t\tthis.inFlightQueue.shift();\n\t\t\tif (this.latestInFlightCommitWithStaleEnrichments >= 0) {\n\t\t\t\tthis.latestInFlightCommitWithStaleEnrichments -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\t// A peer commit has been sequenced\n\t\t\tthis.latestInFlightCommitWithStaleEnrichments = this.inFlightQueue.length - 1;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"defaultResubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AA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C/B,CAAC;QACD,IAAI,CAAC,wCAAwC,GAAG,CAAC,CAAC,CAAC;IACpD,CAAC;IAEM,cAAc;QACpB,MAAM,CACL,IAAI,CAAC,iBAAiB,EACtB,KAAK,CAAC,+DAA+D,CACrE,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,IAAW,iBAAiB;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,wBAAwB,CAAC,OAAgB;QAC/C,IAAI,OAAO,EAAE,CAAC;YACb,iDAAiD;YACjD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACtF,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,wCAAwC,IAAI,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC,wCAAwC,IAAI,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,mCAAmC;YACnC,IAAI,CAAC,wCAAwC,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;CACD","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 { GraphCommit, TaggedChange } from \"../core/index.js\";\nimport { disposeSymbol, hasSome } from \"../util/index.js\";\nimport type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from \"./index.js\";\n\n/**\n * Default implementation of {@link ResubmitMachine}.\n */\nexport class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange> {\n\t/**\n\t * The list of commits (from oldest to most recent) that have been submitted but not sequenced.\n\t */\n\tprivate inFlightQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * The list of commits (from oldest to most recent) that should be resubmitted.\n\t */\n\tprivate resubmitQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has\n\t * undergone rebasing but whose enrichments have not been updated.\n\t * All in-flight commits with an index inferior or equal to this number have stale enrichments.\n\t *\n\t * Is -1 when *any* of the following is true:\n\t * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)\n\t * - None of the in-flight commits have been rebased\n\t * - In-flight commits that have been rebased have all had their enrichments updated\n\t */\n\tprivate latestInFlightCommitWithStaleEnrichments: number = -1;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A function that can create a rollback for a given change.\n\t\t */\n\t\tprivate readonly makeRollback: (change: TaggedChange<TChange>) => TChange,\n\t\t/**\n\t\t * Change enricher that represent the tip of the top-level local branch (i.e., the branch on which in-flight\n\t\t * commits are applied and automatically rebased).\n\t\t */\n\t\tprivate readonly tip: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {}\n\n\tpublic onCommitSubmitted(commit: GraphCommit<TChange>): void {\n\t\tif (this.isInResubmitPhase) {\n\t\t\tconst toResubmit = this.resubmitQueue.shift();\n\t\t\tassert(\n\t\t\t\ttoResubmit === commit,\n\t\t\t\t0x981 /* Unexpected commit submitted during resubmit phase */,\n\t\t\t);\n\t\t}\n\t\tthis.inFlightQueue.push(commit);\n\t}\n\n\tpublic prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {\n\t\tassert(\n\t\t\t!this.isInResubmitPhase,\n\t\t\t0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,\n\t\t);\n\t\tassert(\n\t\t\ttoResubmit.length === this.inFlightQueue.length,\n\t\t\t0x958 /* Unexpected resubmit of more or fewer commits than are in flight */,\n\t\t);\n\t\tif (this.latestInFlightCommitWithStaleEnrichments === -1) {\n\t\t\t// No in-flight commits have stale enrichments, so we can resubmit them as is\n\t\t\tthis.resubmitQueue = this.inFlightQueue;\n\t\t\tthis.inFlightQueue = [];\n\t\t} else {\n\t\t\tconst checkout = this.tip.fork();\n\t\t\t// Roll back the checkout to the state before the oldest commit\n\t\t\tfor (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst rollback = this.makeRollback(commit);\n\t\t\t\t// WARNING: it's not currently possible to roll back past a schema change (see AB#7265).\n\t\t\t\t// Either we have to make it possible to do so, or this logic will have to change to work\n\t\t\t\t// forwards from an earlier fork instead of backwards.\n\t\t\t\tcheckout.applyTipChange(rollback);\n\t\t\t}\n\t\t\t// Update the enrichments of the stale commits\n\t\t\tfor (\n\t\t\t\tlet iCommit = 0;\n\t\t\t\tiCommit <= this.latestInFlightCommitWithStaleEnrichments;\n\t\t\t\tiCommit += 1\n\t\t\t) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst enrichedChange = checkout.updateChangeEnrichments(\n\t\t\t\t\tcommit.change,\n\t\t\t\t\tcommit.revision,\n\t\t\t\t);\n\t\t\t\tconst enrichedCommit = { ...commit, change: enrichedChange };\n\t\t\t\tthis.resubmitQueue.push(enrichedCommit);\n\t\t\t\tif (iCommit < this.latestInFlightCommitWithStaleEnrichments) {\n\t\t\t\t\tcheckout.applyTipChange(enrichedChange, commit.revision);\n\t\t\t\t}\n\t\t\t\tthis.inFlightQueue.shift();\n\t\t\t}\n\t\t\tcheckout[disposeSymbol]();\n\t\t\t// Whatever commits are left do not have stale enrichments\n\t\t\tfor (const commit of this.inFlightQueue) {\n\t\t\t\tthis.resubmitQueue.push(commit);\n\t\t\t}\n\t\t\tthis.inFlightQueue.length = 0;\n\t\t}\n\t\tthis.latestInFlightCommitWithStaleEnrichments = -1;\n\t}\n\n\tpublic peekNextCommit(): GraphCommit<TChange> {\n\t\tassert(\n\t\t\tthis.isInResubmitPhase,\n\t\t\t0x982 /* No available commit to resubmit outside of resubmit phase */,\n\t\t);\n\t\tassert(hasSome(this.resubmitQueue), 0xa87 /* Expected resubmit queue to be non-empty */);\n\t\treturn this.resubmitQueue[0];\n\t}\n\n\tpublic get isInResubmitPhase(): boolean {\n\t\treturn this.resubmitQueue.length !== 0;\n\t}\n\n\tpublic onSequencedCommitApplied(isLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\t// The oldest in-flight commit has been sequenced\n\t\t\tassert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);\n\t\t\tthis.inFlightQueue.shift();\n\t\t\tif (this.latestInFlightCommitWithStaleEnrichments >= 0) {\n\t\t\t\tthis.latestInFlightCommitWithStaleEnrichments -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\t// A peer commit has been sequenced\n\t\t\tthis.latestInFlightCommitWithStaleEnrichments = this.inFlightQueue.length - 1;\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"editManager.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAOhB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACN,gBAAgB,EAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACX,MAAM,EACN,SAAS,EAET,eAAe,EACf,oBAAoB,EACpB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAGN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,eAAO,MAAM,6BAA6B,EAAE,SAA0C,CAAC;AAkBvF;;;GAGG;AAEH,qBAAa,WAAW,CACvB,OAAO,SAAS,kBAAkB,EAClC,UAAU,EACV,aAAa,SAAS,YAAY,CAAC,OAAO,EAAE,U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AqB;IAqB7B,OAAO,CAAC,QAAQ;CAUhB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,UAAU;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;IACvD,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,SAAS,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;CACrF"}
@@ -3,12 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { assert } from "@fluidframework/core-utils/internal";
6
+ import { createEmitter } from "@fluid-internal/client-utils";
6
7
  import { BTree } from "@tylerbu/sorted-btree-es6";
7
8
  import { findAncestor, findCommonAncestor, mintCommit, rebaseChange, tagChange, } from "../core/index.js";
8
9
  import { brand, fail, getOrCreate, mapIterable } from "../util/index.js";
9
10
  import { SharedTreeBranch, getChangeReplaceType, onForkTransitive, } from "./branch.js";
10
11
  import { decrementSequenceId, equalSequenceIds, maxSequenceId, minSequenceId, sequenceIdComparator, } from "./sequenceIdUtils.js";
11
- import { createEmitter } from "../events/index.js";
12
12
  import { TelemetryEventBatcher, measure, } from "@fluidframework/telemetry-utils/internal";
13
13
  export const minimumPossibleSequenceNumber = brand(Number.MIN_SAFE_INTEGER);
14
14
  const minimumPossibleSequenceId = {