@fluidframework/tree 2.10.0 → 2.12.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 (776) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/api-report/tree.alpha.api.md +49 -18
  3. package/api-report/tree.beta.api.md +6 -15
  4. package/api-report/tree.legacy.alpha.api.md +6 -15
  5. package/api-report/tree.legacy.public.api.md +6 -15
  6. package/api-report/tree.public.api.md +6 -15
  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 +3 -3
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js +6 -3
  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 +13 -17
  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/format.d.ts +0 -3
  23. package/dist/core/schema-stored/format.d.ts.map +1 -1
  24. package/dist/core/schema-stored/format.js.map +1 -1
  25. package/dist/core/schema-stored/schema.d.ts +12 -10
  26. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  27. package/dist/core/schema-stored/schema.js +3 -5
  28. package/dist/core/schema-stored/schema.js.map +1 -1
  29. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  30. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  31. package/dist/core/schema-stored/storedSchemaRepository.js +5 -5
  32. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  33. package/dist/core/schema-view/index.d.ts +1 -1
  34. package/dist/core/schema-view/index.d.ts.map +1 -1
  35. package/dist/core/schema-view/index.js +1 -2
  36. package/dist/core/schema-view/index.js.map +1 -1
  37. package/dist/core/schema-view/view.d.ts +0 -7
  38. package/dist/core/schema-view/view.d.ts.map +1 -1
  39. package/dist/core/schema-view/view.js +1 -12
  40. package/dist/core/schema-view/view.js.map +1 -1
  41. package/dist/core/tree/anchorSet.d.ts +2 -2
  42. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  43. package/dist/core/tree/anchorSet.js +21 -21
  44. package/dist/core/tree/anchorSet.js.map +1 -1
  45. package/{lib/feature-libraries/chunked-forest → dist/core/tree}/chunk.d.ts +2 -1
  46. package/dist/core/tree/chunk.d.ts.map +1 -0
  47. package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.js +2 -2
  48. package/dist/core/tree/chunk.js.map +1 -0
  49. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  50. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  51. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  52. package/dist/core/tree/index.d.ts +2 -1
  53. package/dist/core/tree/index.d.ts.map +1 -1
  54. package/dist/core/tree/index.js +6 -1
  55. package/dist/core/tree/index.js.map +1 -1
  56. package/dist/core/tree/treeTextFormat.d.ts +0 -5
  57. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  58. package/dist/core/tree/treeTextFormat.js.map +1 -1
  59. package/dist/core/tree/types.d.ts +0 -5
  60. package/dist/core/tree/types.d.ts.map +1 -1
  61. package/dist/core/tree/types.js +0 -1
  62. package/dist/core/tree/types.js.map +1 -1
  63. package/dist/core/tree/visitorUtils.d.ts +25 -1
  64. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  65. package/dist/core/tree/visitorUtils.js +29 -1
  66. package/dist/core/tree/visitorUtils.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  68. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -14
  70. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  72. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -3
  74. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  75. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -3
  76. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  77. package/dist/feature-libraries/chunked-forest/chunkedForest.js +24 -14
  78. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  80. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  81. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  83. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  88. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  89. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  90. package/dist/feature-libraries/chunked-forest/emptyChunk.js +2 -3
  91. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  92. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  93. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  94. package/dist/feature-libraries/chunked-forest/index.js +5 -5
  95. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  97. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +2 -2
  99. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  100. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  101. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  102. package/dist/feature-libraries/chunked-forest/uniformChunk.js +14 -14
  103. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  104. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  105. package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
  106. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  107. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  108. package/dist/feature-libraries/default-schema/schemaChecker.js +2 -1
  109. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  110. package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
  111. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  112. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  113. package/dist/feature-libraries/index.d.ts +2 -1
  114. package/dist/feature-libraries/index.d.ts.map +1 -1
  115. package/dist/feature-libraries/index.js +9 -2
  116. package/dist/feature-libraries/index.js.map +1 -1
  117. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +139 -0
  118. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  119. package/dist/feature-libraries/indexing/anchorTreeIndex.js +387 -0
  120. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  121. package/dist/feature-libraries/indexing/index.d.ts +7 -0
  122. package/dist/feature-libraries/indexing/index.d.ts.map +1 -0
  123. package/dist/feature-libraries/indexing/index.js +11 -0
  124. package/dist/feature-libraries/indexing/index.js.map +1 -0
  125. package/dist/feature-libraries/indexing/types.d.ts +32 -0
  126. package/dist/feature-libraries/indexing/types.d.ts.map +1 -0
  127. package/dist/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  128. package/dist/feature-libraries/indexing/types.js.map +1 -0
  129. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  130. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  131. package/dist/feature-libraries/modular-schema/discrepancies.js +32 -33
  132. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  133. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  134. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  135. package/dist/feature-libraries/modular-schema/index.js +5 -1
  136. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  137. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  138. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  139. package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -1
  140. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  141. package/dist/feature-libraries/object-forest/objectForest.d.ts +5 -2
  142. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  143. package/dist/feature-libraries/object-forest/objectForest.js +21 -11
  144. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  145. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  146. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  147. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  148. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  149. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  150. package/dist/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  151. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  152. package/dist/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  153. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  154. package/dist/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  155. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  156. package/dist/feature-libraries/sequence-field/invert.js +2 -2
  157. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  158. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +3 -2
  159. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  160. package/dist/feature-libraries/sequence-field/types.d.ts +0 -1
  161. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  162. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  163. package/dist/index.d.ts +6 -7
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +3 -13
  166. package/dist/index.js.map +1 -1
  167. package/dist/packageVersion.d.ts +1 -1
  168. package/dist/packageVersion.js +1 -1
  169. package/dist/packageVersion.js.map +1 -1
  170. package/dist/shared-tree/index.d.ts +2 -2
  171. package/dist/shared-tree/index.d.ts.map +1 -1
  172. package/dist/shared-tree/index.js +1 -2
  173. package/dist/shared-tree/index.js.map +1 -1
  174. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  175. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  176. package/dist/shared-tree/schematizeTree.js +6 -6
  177. package/dist/shared-tree/schematizeTree.js.map +1 -1
  178. package/dist/shared-tree/schematizingTreeView.d.ts +7 -1
  179. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  180. package/dist/shared-tree/schematizingTreeView.js +35 -38
  181. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  182. package/dist/shared-tree/sharedTree.d.ts +27 -6
  183. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  184. package/dist/shared-tree/sharedTree.js +146 -21
  185. package/dist/shared-tree/sharedTree.js.map +1 -1
  186. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  187. package/dist/shared-tree/sharedTreeChangeFamily.js +3 -3
  188. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  189. package/dist/shared-tree/treeCheckout.d.ts +59 -72
  190. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  191. package/dist/shared-tree/treeCheckout.js +243 -188
  192. package/dist/shared-tree/treeCheckout.js.map +1 -1
  193. package/dist/shared-tree-core/branch.d.ts +29 -107
  194. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  195. package/dist/shared-tree-core/branch.js +51 -195
  196. package/dist/shared-tree-core/branch.js.map +1 -1
  197. package/dist/shared-tree-core/branchCommitEnricher.d.ts +24 -32
  198. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  199. package/dist/shared-tree-core/branchCommitEnricher.js +70 -53
  200. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  201. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  202. package/dist/shared-tree-core/defaultResubmitMachine.js +2 -1
  203. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  204. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  205. package/dist/shared-tree-core/editManager.js +4 -4
  206. package/dist/shared-tree-core/editManager.js.map +1 -1
  207. package/dist/shared-tree-core/index.d.ts +3 -3
  208. package/dist/shared-tree-core/index.d.ts.map +1 -1
  209. package/dist/shared-tree-core/index.js +5 -4
  210. package/dist/shared-tree-core/index.js.map +1 -1
  211. package/dist/shared-tree-core/sharedTreeCore.d.ts +3 -10
  212. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  213. package/dist/shared-tree-core/sharedTreeCore.js +14 -67
  214. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  215. package/dist/shared-tree-core/transaction.d.ts +146 -0
  216. package/dist/shared-tree-core/transaction.d.ts.map +1 -0
  217. package/dist/shared-tree-core/transaction.js +211 -0
  218. package/dist/shared-tree-core/transaction.js.map +1 -0
  219. package/dist/shared-tree-core/transactionEnricher.d.ts +8 -13
  220. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  221. package/dist/shared-tree-core/transactionEnricher.js +41 -21
  222. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  223. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  224. package/dist/simple-tree/api/conciseTree.js +1 -1
  225. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  226. package/dist/simple-tree/api/create.d.ts.map +1 -1
  227. package/dist/simple-tree/api/create.js +5 -1
  228. package/dist/simple-tree/api/create.js.map +1 -1
  229. package/dist/simple-tree/api/customTree.d.ts +14 -2
  230. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  231. package/dist/simple-tree/api/customTree.js +53 -3
  232. package/dist/simple-tree/api/customTree.js.map +1 -1
  233. package/dist/simple-tree/api/identifierIndex.d.ts +21 -0
  234. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -0
  235. package/dist/simple-tree/api/identifierIndex.js +45 -0
  236. package/dist/simple-tree/api/identifierIndex.js.map +1 -0
  237. package/dist/simple-tree/api/index.d.ts +4 -2
  238. package/dist/simple-tree/api/index.d.ts.map +1 -1
  239. package/dist/simple-tree/api/index.js +8 -1
  240. package/dist/simple-tree/api/index.js.map +1 -1
  241. package/dist/simple-tree/api/schemaFactory.d.ts +48 -0
  242. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  243. package/dist/simple-tree/api/schemaFactory.js +5 -2
  244. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  245. package/dist/simple-tree/api/simpleSchema.d.ts +3 -1
  246. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  247. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  248. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +9 -7
  249. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  250. package/dist/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  251. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  252. package/dist/simple-tree/api/simpleTreeIndex.js +93 -0
  253. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -0
  254. package/dist/simple-tree/api/storedSchema.d.ts +4 -4
  255. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  256. package/dist/simple-tree/api/storedSchema.js +8 -21
  257. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  258. package/dist/simple-tree/api/tree.d.ts +5 -5
  259. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  260. package/dist/simple-tree/api/tree.js.map +1 -1
  261. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  262. package/dist/simple-tree/api/verboseTree.js +1 -1
  263. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  264. package/dist/simple-tree/api/view.d.ts +14 -9
  265. package/dist/simple-tree/api/view.d.ts.map +1 -1
  266. package/dist/simple-tree/api/view.js +129 -40
  267. package/dist/simple-tree/api/view.js.map +1 -1
  268. package/dist/simple-tree/core/index.d.ts +1 -1
  269. package/dist/simple-tree/core/index.d.ts.map +1 -1
  270. package/dist/simple-tree/core/index.js +2 -1
  271. package/dist/simple-tree/core/index.js.map +1 -1
  272. package/dist/simple-tree/core/treeNodeKernel.d.ts +6 -2
  273. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  274. package/dist/simple-tree/core/treeNodeKernel.js +53 -22
  275. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  276. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  277. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  278. package/dist/simple-tree/core/unhydratedFlexTree.js +2 -2
  279. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  280. package/dist/simple-tree/index.d.ts +2 -2
  281. package/dist/simple-tree/index.d.ts.map +1 -1
  282. package/dist/simple-tree/index.js +7 -2
  283. package/dist/simple-tree/index.js.map +1 -1
  284. package/dist/simple-tree/leafNodeSchema.d.ts +0 -15
  285. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  286. package/dist/simple-tree/leafNodeSchema.js +0 -15
  287. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  288. package/dist/simple-tree/objectNode.d.ts +15 -5
  289. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  290. package/dist/simple-tree/objectNode.js +18 -2
  291. package/dist/simple-tree/objectNode.js.map +1 -1
  292. package/dist/simple-tree/objectNodeTypes.d.ts +4 -0
  293. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  294. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  295. package/dist/simple-tree/schemaTypes.d.ts +4 -2
  296. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  297. package/dist/simple-tree/schemaTypes.js.map +1 -1
  298. package/dist/simple-tree/toMapTree.js +3 -3
  299. package/dist/simple-tree/toMapTree.js.map +1 -1
  300. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  301. package/dist/simple-tree/toStoredSchema.js +18 -13
  302. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  303. package/dist/util/brand.d.ts +0 -2
  304. package/dist/util/brand.d.ts.map +1 -1
  305. package/dist/util/brand.js +0 -1
  306. package/dist/util/brand.js.map +1 -1
  307. package/dist/util/index.d.ts +1 -2
  308. package/dist/util/index.d.ts.map +1 -1
  309. package/dist/util/index.js +6 -4
  310. package/dist/util/index.js.map +1 -1
  311. package/dist/util/typeCheck.d.ts +6 -3
  312. package/dist/util/typeCheck.d.ts.map +1 -1
  313. package/dist/util/typeCheck.js.map +1 -1
  314. package/dist/util/typeCheckTests.d.ts +14 -2
  315. package/dist/util/typeCheckTests.d.ts.map +1 -1
  316. package/dist/util/typeCheckTests.js.map +1 -1
  317. package/dist/util/utils.d.ts +42 -0
  318. package/dist/util/utils.d.ts.map +1 -1
  319. package/dist/util/utils.js +35 -1
  320. package/dist/util/utils.js.map +1 -1
  321. package/lib/alpha.d.ts +9 -0
  322. package/lib/core/forest/forest.d.ts +10 -2
  323. package/lib/core/forest/forest.d.ts.map +1 -1
  324. package/lib/core/forest/forest.js.map +1 -1
  325. package/lib/core/index.d.ts +3 -3
  326. package/lib/core/index.d.ts.map +1 -1
  327. package/lib/core/index.js +3 -3
  328. package/lib/core/index.js.map +1 -1
  329. package/lib/core/rebase/utils.d.ts +1 -1
  330. package/lib/core/rebase/utils.d.ts.map +1 -1
  331. package/lib/core/rebase/utils.js +13 -17
  332. package/lib/core/rebase/utils.js.map +1 -1
  333. package/lib/core/revertible.d.ts +30 -1
  334. package/lib/core/revertible.d.ts.map +1 -1
  335. package/lib/core/revertible.js.map +1 -1
  336. package/lib/core/schema-stored/format.d.ts +0 -3
  337. package/lib/core/schema-stored/format.d.ts.map +1 -1
  338. package/lib/core/schema-stored/format.js.map +1 -1
  339. package/lib/core/schema-stored/schema.d.ts +12 -10
  340. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  341. package/lib/core/schema-stored/schema.js +3 -5
  342. package/lib/core/schema-stored/schema.js.map +1 -1
  343. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  344. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  345. package/lib/core/schema-stored/storedSchemaRepository.js +1 -1
  346. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  347. package/lib/core/schema-view/index.d.ts +1 -1
  348. package/lib/core/schema-view/index.d.ts.map +1 -1
  349. package/lib/core/schema-view/index.js +1 -1
  350. package/lib/core/schema-view/index.js.map +1 -1
  351. package/lib/core/schema-view/view.d.ts +0 -7
  352. package/lib/core/schema-view/view.d.ts.map +1 -1
  353. package/lib/core/schema-view/view.js +0 -11
  354. package/lib/core/schema-view/view.js.map +1 -1
  355. package/lib/core/tree/anchorSet.d.ts +2 -2
  356. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  357. package/lib/core/tree/anchorSet.js +1 -1
  358. package/lib/core/tree/anchorSet.js.map +1 -1
  359. package/{dist/feature-libraries/chunked-forest → lib/core/tree}/chunk.d.ts +2 -1
  360. package/lib/core/tree/chunk.d.ts.map +1 -0
  361. package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.js +1 -1
  362. package/lib/core/tree/chunk.js.map +1 -0
  363. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  364. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  365. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  366. package/lib/core/tree/index.d.ts +2 -1
  367. package/lib/core/tree/index.d.ts.map +1 -1
  368. package/lib/core/tree/index.js +2 -1
  369. package/lib/core/tree/index.js.map +1 -1
  370. package/lib/core/tree/treeTextFormat.d.ts +0 -5
  371. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  372. package/lib/core/tree/treeTextFormat.js.map +1 -1
  373. package/lib/core/tree/types.d.ts +0 -5
  374. package/lib/core/tree/types.d.ts.map +1 -1
  375. package/lib/core/tree/types.js +0 -1
  376. package/lib/core/tree/types.js.map +1 -1
  377. package/lib/core/tree/visitorUtils.d.ts +25 -1
  378. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  379. package/lib/core/tree/visitorUtils.js +27 -0
  380. package/lib/core/tree/visitorUtils.js.map +1 -1
  381. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  382. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  383. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  384. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  385. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  386. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  387. package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -2
  388. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  389. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +5 -3
  390. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  391. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -8
  392. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  393. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  394. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  395. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  396. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  397. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  398. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  399. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  400. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  401. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  402. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  403. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  404. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -2
  405. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  406. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  407. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  408. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  409. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  410. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  411. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  412. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
  413. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  414. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  415. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  416. package/lib/feature-libraries/chunked-forest/uniformChunk.js +4 -4
  417. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  418. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  419. package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
  420. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  421. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  422. package/lib/feature-libraries/default-schema/schemaChecker.js +2 -1
  423. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  424. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  425. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  426. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  427. package/lib/feature-libraries/index.d.ts +2 -1
  428. package/lib/feature-libraries/index.d.ts.map +1 -1
  429. package/lib/feature-libraries/index.js +2 -1
  430. package/lib/feature-libraries/index.js.map +1 -1
  431. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +139 -0
  432. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -0
  433. package/lib/feature-libraries/indexing/anchorTreeIndex.js +382 -0
  434. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -0
  435. package/lib/feature-libraries/indexing/index.d.ts +7 -0
  436. package/lib/feature-libraries/indexing/index.d.ts.map +1 -0
  437. package/lib/{events → feature-libraries/indexing}/index.js +1 -1
  438. package/lib/feature-libraries/indexing/index.js.map +1 -0
  439. package/lib/feature-libraries/indexing/types.d.ts +32 -0
  440. package/lib/feature-libraries/indexing/types.d.ts.map +1 -0
  441. package/lib/{events/interop.js → feature-libraries/indexing/types.js} +1 -1
  442. package/lib/feature-libraries/indexing/types.js.map +1 -0
  443. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  444. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  445. package/lib/feature-libraries/modular-schema/discrepancies.js +25 -28
  446. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  447. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  448. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  449. package/lib/feature-libraries/modular-schema/index.js +1 -1
  450. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  451. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  452. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  453. package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -1
  454. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  455. package/lib/feature-libraries/object-forest/objectForest.d.ts +5 -2
  456. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  457. package/lib/feature-libraries/object-forest/objectForest.js +15 -5
  458. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  459. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  460. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  461. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  462. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  463. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  464. package/lib/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  465. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  466. package/lib/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  467. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  468. package/lib/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  469. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  470. package/lib/feature-libraries/sequence-field/invert.js +4 -4
  471. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  472. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -3
  473. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  474. package/lib/feature-libraries/sequence-field/types.d.ts +0 -1
  475. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  476. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  477. package/lib/index.d.ts +6 -7
  478. package/lib/index.d.ts.map +1 -1
  479. package/lib/index.js +3 -4
  480. package/lib/index.js.map +1 -1
  481. package/lib/packageVersion.d.ts +1 -1
  482. package/lib/packageVersion.js +1 -1
  483. package/lib/packageVersion.js.map +1 -1
  484. package/lib/shared-tree/index.d.ts +2 -2
  485. package/lib/shared-tree/index.d.ts.map +1 -1
  486. package/lib/shared-tree/index.js +1 -1
  487. package/lib/shared-tree/index.js.map +1 -1
  488. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  489. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  490. package/lib/shared-tree/schematizeTree.js +7 -7
  491. package/lib/shared-tree/schematizeTree.js.map +1 -1
  492. package/lib/shared-tree/schematizingTreeView.d.ts +7 -1
  493. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  494. package/lib/shared-tree/schematizingTreeView.js +12 -16
  495. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  496. package/lib/shared-tree/sharedTree.d.ts +27 -6
  497. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  498. package/lib/shared-tree/sharedTree.js +135 -10
  499. package/lib/shared-tree/sharedTree.js.map +1 -1
  500. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  501. package/lib/shared-tree/sharedTreeChangeFamily.js +5 -5
  502. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  503. package/lib/shared-tree/treeCheckout.d.ts +59 -72
  504. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  505. package/lib/shared-tree/treeCheckout.js +233 -177
  506. package/lib/shared-tree/treeCheckout.js.map +1 -1
  507. package/lib/shared-tree-core/branch.d.ts +29 -107
  508. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  509. package/lib/shared-tree-core/branch.js +50 -193
  510. package/lib/shared-tree-core/branch.js.map +1 -1
  511. package/lib/shared-tree-core/branchCommitEnricher.d.ts +24 -32
  512. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  513. package/lib/shared-tree-core/branchCommitEnricher.js +71 -54
  514. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  515. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  516. package/lib/shared-tree-core/defaultResubmitMachine.js +3 -2
  517. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  518. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  519. package/lib/shared-tree-core/editManager.js +4 -4
  520. package/lib/shared-tree-core/editManager.js.map +1 -1
  521. package/lib/shared-tree-core/index.d.ts +3 -3
  522. package/lib/shared-tree-core/index.d.ts.map +1 -1
  523. package/lib/shared-tree-core/index.js +2 -2
  524. package/lib/shared-tree-core/index.js.map +1 -1
  525. package/lib/shared-tree-core/sharedTreeCore.d.ts +3 -10
  526. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  527. package/lib/shared-tree-core/sharedTreeCore.js +15 -68
  528. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  529. package/lib/shared-tree-core/transaction.d.ts +146 -0
  530. package/lib/shared-tree-core/transaction.d.ts.map +1 -0
  531. package/lib/shared-tree-core/transaction.js +206 -0
  532. package/lib/shared-tree-core/transaction.js.map +1 -0
  533. package/lib/shared-tree-core/transactionEnricher.d.ts +8 -13
  534. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  535. package/lib/shared-tree-core/transactionEnricher.js +41 -21
  536. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  537. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  538. package/lib/simple-tree/api/conciseTree.js +2 -2
  539. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  540. package/lib/simple-tree/api/create.d.ts.map +1 -1
  541. package/lib/simple-tree/api/create.js +5 -1
  542. package/lib/simple-tree/api/create.js.map +1 -1
  543. package/lib/simple-tree/api/customTree.d.ts +14 -2
  544. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  545. package/lib/simple-tree/api/customTree.js +50 -2
  546. package/lib/simple-tree/api/customTree.js.map +1 -1
  547. package/lib/simple-tree/api/identifierIndex.d.ts +21 -0
  548. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -0
  549. package/lib/simple-tree/api/identifierIndex.js +41 -0
  550. package/lib/simple-tree/api/identifierIndex.js.map +1 -0
  551. package/lib/simple-tree/api/index.d.ts +4 -2
  552. package/lib/simple-tree/api/index.d.ts.map +1 -1
  553. package/lib/simple-tree/api/index.js +4 -1
  554. package/lib/simple-tree/api/index.js.map +1 -1
  555. package/lib/simple-tree/api/schemaFactory.d.ts +48 -0
  556. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  557. package/lib/simple-tree/api/schemaFactory.js +4 -1
  558. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  559. package/lib/simple-tree/api/simpleSchema.d.ts +3 -1
  560. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  561. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  562. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +11 -9
  563. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  564. package/lib/simple-tree/api/simpleTreeIndex.d.ts +65 -0
  565. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -0
  566. package/lib/simple-tree/api/simpleTreeIndex.js +89 -0
  567. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -0
  568. package/lib/simple-tree/api/storedSchema.d.ts +4 -4
  569. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  570. package/lib/simple-tree/api/storedSchema.js +5 -18
  571. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  572. package/lib/simple-tree/api/tree.d.ts +5 -5
  573. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  574. package/lib/simple-tree/api/tree.js.map +1 -1
  575. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  576. package/lib/simple-tree/api/verboseTree.js +2 -2
  577. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  578. package/lib/simple-tree/api/view.d.ts +14 -9
  579. package/lib/simple-tree/api/view.d.ts.map +1 -1
  580. package/lib/simple-tree/api/view.js +131 -42
  581. package/lib/simple-tree/api/view.js.map +1 -1
  582. package/lib/simple-tree/core/index.d.ts +1 -1
  583. package/lib/simple-tree/core/index.d.ts.map +1 -1
  584. package/lib/simple-tree/core/index.js +1 -1
  585. package/lib/simple-tree/core/index.js.map +1 -1
  586. package/lib/simple-tree/core/treeNodeKernel.d.ts +6 -2
  587. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  588. package/lib/simple-tree/core/treeNodeKernel.js +31 -1
  589. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  590. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  591. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  592. package/lib/simple-tree/core/unhydratedFlexTree.js +1 -1
  593. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  594. package/lib/simple-tree/index.d.ts +2 -2
  595. package/lib/simple-tree/index.d.ts.map +1 -1
  596. package/lib/simple-tree/index.js +2 -2
  597. package/lib/simple-tree/index.js.map +1 -1
  598. package/lib/simple-tree/leafNodeSchema.d.ts +0 -15
  599. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  600. package/lib/simple-tree/leafNodeSchema.js +0 -15
  601. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  602. package/lib/simple-tree/objectNode.d.ts +15 -5
  603. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  604. package/lib/simple-tree/objectNode.js +16 -1
  605. package/lib/simple-tree/objectNode.js.map +1 -1
  606. package/lib/simple-tree/objectNodeTypes.d.ts +4 -0
  607. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  608. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  609. package/lib/simple-tree/schemaTypes.d.ts +4 -2
  610. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  611. package/lib/simple-tree/schemaTypes.js.map +1 -1
  612. package/lib/simple-tree/toMapTree.js +5 -5
  613. package/lib/simple-tree/toMapTree.js.map +1 -1
  614. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  615. package/lib/simple-tree/toStoredSchema.js +19 -14
  616. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  617. package/lib/util/brand.d.ts +0 -2
  618. package/lib/util/brand.d.ts.map +1 -1
  619. package/lib/util/brand.js +0 -1
  620. package/lib/util/brand.js.map +1 -1
  621. package/lib/util/index.d.ts +1 -2
  622. package/lib/util/index.d.ts.map +1 -1
  623. package/lib/util/index.js +1 -2
  624. package/lib/util/index.js.map +1 -1
  625. package/lib/util/typeCheck.d.ts +6 -3
  626. package/lib/util/typeCheck.d.ts.map +1 -1
  627. package/lib/util/typeCheck.js.map +1 -1
  628. package/lib/util/typeCheckTests.d.ts +14 -2
  629. package/lib/util/typeCheckTests.d.ts.map +1 -1
  630. package/lib/util/typeCheckTests.js.map +1 -1
  631. package/lib/util/utils.d.ts +42 -0
  632. package/lib/util/utils.d.ts.map +1 -1
  633. package/lib/util/utils.js +30 -0
  634. package/lib/util/utils.js.map +1 -1
  635. package/package.json +23 -23
  636. package/src/core/forest/forest.ts +12 -1
  637. package/src/core/index.ts +13 -2
  638. package/src/core/rebase/utils.ts +28 -29
  639. package/src/core/revertible.ts +35 -1
  640. package/src/core/schema-stored/format.ts +0 -3
  641. package/src/core/schema-stored/schema.ts +13 -10
  642. package/src/core/schema-stored/storedSchemaRepository.ts +2 -1
  643. package/src/core/schema-view/index.ts +0 -1
  644. package/src/core/schema-view/view.ts +0 -11
  645. package/src/core/tree/anchorSet.ts +2 -1
  646. package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
  647. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  648. package/src/core/tree/index.ts +9 -0
  649. package/src/core/tree/treeTextFormat.ts +0 -5
  650. package/src/core/tree/types.ts +0 -5
  651. package/src/core/tree/visitorUtils.ts +56 -1
  652. package/src/feature-libraries/chunked-forest/basicChunk.ts +4 -2
  653. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -1
  654. package/src/feature-libraries/chunked-forest/chunkedForest.ts +35 -8
  655. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +1 -2
  656. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -2
  657. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  658. package/src/feature-libraries/chunked-forest/emptyChunk.ts +4 -2
  659. package/src/feature-libraries/chunked-forest/index.ts +1 -1
  660. package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
  661. package/src/feature-libraries/chunked-forest/uniformChunk.ts +7 -4
  662. package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
  663. package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
  664. package/src/feature-libraries/flex-tree/context.ts +1 -1
  665. package/src/feature-libraries/index.ts +22 -0
  666. package/src/feature-libraries/indexing/anchorTreeIndex.ts +482 -0
  667. package/src/feature-libraries/indexing/index.ts +11 -0
  668. package/src/feature-libraries/indexing/types.ts +37 -0
  669. package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
  670. package/src/feature-libraries/modular-schema/index.ts +13 -0
  671. package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
  672. package/src/feature-libraries/object-forest/objectForest.ts +22 -4
  673. package/src/feature-libraries/sequence-field/invert.ts +4 -4
  674. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +4 -4
  675. package/src/feature-libraries/sequence-field/types.ts +0 -1
  676. package/src/index.ts +17 -35
  677. package/src/packageVersion.ts +1 -1
  678. package/src/shared-tree/index.ts +1 -2
  679. package/src/shared-tree/schematizeTree.ts +6 -10
  680. package/src/shared-tree/schematizingTreeView.ts +18 -28
  681. package/src/shared-tree/sharedTree.ts +216 -30
  682. package/src/shared-tree/sharedTreeChangeFamily.ts +5 -4
  683. package/src/shared-tree/treeCheckout.ts +341 -299
  684. package/src/shared-tree-core/branch.ts +80 -300
  685. package/src/shared-tree-core/branchCommitEnricher.ts +66 -62
  686. package/src/shared-tree-core/defaultResubmitMachine.ts +3 -2
  687. package/src/shared-tree-core/editManager.ts +4 -9
  688. package/src/shared-tree-core/index.ts +11 -3
  689. package/src/shared-tree-core/sharedTreeCore.ts +23 -79
  690. package/src/shared-tree-core/transaction.ts +310 -0
  691. package/src/shared-tree-core/transactionEnricher.ts +30 -24
  692. package/src/simple-tree/api/conciseTree.ts +2 -2
  693. package/src/simple-tree/api/create.ts +5 -1
  694. package/src/simple-tree/api/customTree.ts +69 -1
  695. package/src/simple-tree/api/identifierIndex.ts +64 -0
  696. package/src/simple-tree/api/index.ts +17 -2
  697. package/src/simple-tree/api/schemaFactory.ts +62 -1
  698. package/src/simple-tree/api/simpleSchema.ts +3 -1
  699. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -18
  700. package/src/simple-tree/api/simpleTreeIndex.ts +233 -0
  701. package/src/simple-tree/api/storedSchema.ts +7 -22
  702. package/src/simple-tree/api/tree.ts +14 -5
  703. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  704. package/src/simple-tree/api/verboseTree.ts +2 -2
  705. package/src/simple-tree/api/view.ts +197 -51
  706. package/src/simple-tree/core/index.ts +1 -0
  707. package/src/simple-tree/core/treeNodeKernel.ts +37 -2
  708. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -1
  709. package/src/simple-tree/index.ts +10 -0
  710. package/src/simple-tree/leafNodeSchema.ts +0 -19
  711. package/src/simple-tree/objectNode.ts +45 -14
  712. package/src/simple-tree/objectNodeTypes.ts +5 -0
  713. package/src/simple-tree/schemaTypes.ts +7 -2
  714. package/src/simple-tree/toMapTree.ts +5 -5
  715. package/src/simple-tree/toStoredSchema.ts +25 -19
  716. package/src/util/brand.ts +0 -2
  717. package/src/util/index.ts +4 -1
  718. package/src/util/typeCheck.ts +6 -3
  719. package/src/util/typeCheckTests.ts +11 -1
  720. package/src/util/utils.ts +64 -0
  721. package/dist/events/emitter.d.ts +0 -139
  722. package/dist/events/emitter.d.ts.map +0 -1
  723. package/dist/events/emitter.js +0 -165
  724. package/dist/events/emitter.js.map +0 -1
  725. package/dist/events/index.d.ts +0 -7
  726. package/dist/events/index.d.ts.map +0 -1
  727. package/dist/events/index.js +0 -11
  728. package/dist/events/index.js.map +0 -1
  729. package/dist/events/interop.d.ts +0 -30
  730. package/dist/events/interop.d.ts.map +0 -1
  731. package/dist/events/interop.js.map +0 -1
  732. package/dist/events/listeners.d.ts +0 -76
  733. package/dist/events/listeners.d.ts.map +0 -1
  734. package/dist/events/listeners.js +0 -7
  735. package/dist/events/listeners.js.map +0 -1
  736. package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  737. package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
  738. package/dist/shared-tree-core/transactionStack.d.ts +0 -29
  739. package/dist/shared-tree-core/transactionStack.d.ts.map +0 -1
  740. package/dist/shared-tree-core/transactionStack.js +0 -41
  741. package/dist/shared-tree-core/transactionStack.js.map +0 -1
  742. package/dist/util/transactionResult.d.ts +0 -19
  743. package/dist/util/transactionResult.d.ts.map +0 -1
  744. package/dist/util/transactionResult.js +0 -23
  745. package/dist/util/transactionResult.js.map +0 -1
  746. package/lib/events/emitter.d.ts +0 -139
  747. package/lib/events/emitter.d.ts.map +0 -1
  748. package/lib/events/emitter.js +0 -160
  749. package/lib/events/emitter.js.map +0 -1
  750. package/lib/events/index.d.ts +0 -7
  751. package/lib/events/index.d.ts.map +0 -1
  752. package/lib/events/index.js.map +0 -1
  753. package/lib/events/interop.d.ts +0 -30
  754. package/lib/events/interop.d.ts.map +0 -1
  755. package/lib/events/interop.js.map +0 -1
  756. package/lib/events/listeners.d.ts +0 -76
  757. package/lib/events/listeners.d.ts.map +0 -1
  758. package/lib/events/listeners.js +0 -6
  759. package/lib/events/listeners.js.map +0 -1
  760. package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  761. package/lib/feature-libraries/chunked-forest/chunk.js.map +0 -1
  762. package/lib/shared-tree-core/transactionStack.d.ts +0 -29
  763. package/lib/shared-tree-core/transactionStack.d.ts.map +0 -1
  764. package/lib/shared-tree-core/transactionStack.js +0 -37
  765. package/lib/shared-tree-core/transactionStack.js.map +0 -1
  766. package/lib/util/transactionResult.d.ts +0 -19
  767. package/lib/util/transactionResult.d.ts.map +0 -1
  768. package/lib/util/transactionResult.js +0 -20
  769. package/lib/util/transactionResult.js.map +0 -1
  770. package/src/events/README.md +0 -3
  771. package/src/events/emitter.ts +0 -256
  772. package/src/events/index.ts +0 -19
  773. package/src/events/interop.ts +0 -38
  774. package/src/events/listeners.ts +0 -80
  775. package/src/shared-tree-core/transactionStack.ts +0 -45
  776. package/src/util/transactionResult.ts +0 -19
@@ -2,86 +2,103 @@
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";
8
20
  /**
9
21
  * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.
10
22
  */
11
23
  export class BranchCommitEnricher {
12
24
  constructor(rebaser, enricher) {
25
+ _BranchCommitEnricher_transactionEnricher.set(this, void 0);
26
+ _BranchCommitEnricher_enricher.set(this, void 0);
13
27
  /**
14
28
  * 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.
29
+ * @remarks
30
+ * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.
31
+ * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.
32
+ * 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
33
  */
20
- this.preparedCommits = new Map();
21
- this.enricher = enricher;
22
- this.transactionEnricher = new TransactionEnricher(rebaser, this.enricher);
34
+ _BranchCommitEnricher_preparedCommits.set(this, new Map());
35
+ /**
36
+ * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.
37
+ * Calling this function will compute the composition of that transaction's commits.
38
+ * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.
39
+ */
40
+ _BranchCommitEnricher_getOuterTransactionChange.set(this, void 0);
41
+ __classPrivateFieldSet(this, _BranchCommitEnricher_enricher, enricher, "f");
42
+ __classPrivateFieldSet(this, _BranchCommitEnricher_transactionEnricher, new TransactionEnricher(rebaser, __classPrivateFieldGet(this, _BranchCommitEnricher_enricher, "f")), "f");
23
43
  }
24
44
  /**
25
- * @returns The number of commits that have been prepared but not yet retrieved.
45
+ * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.
46
+ * @param change - The change to process.
47
+ * @param isAttached - Whether or not the SharedTree is attached to the service.
26
48
  */
27
- get preparedCommitsCount() {
28
- return this.preparedCommits.size;
29
- }
30
- startNewTransaction() {
31
- this.transactionEnricher.startNewTransaction();
32
- }
33
- commitCurrentTransaction() {
34
- this.transactionEnricher.commitCurrentTransaction();
49
+ processChange(change) {
50
+ if (change.type === "append") {
51
+ for (const newCommit of change.newCommits) {
52
+ const newChange = __classPrivateFieldGet(this, _BranchCommitEnricher_getOuterTransactionChange, "f")?.call(this, newCommit.revision) ??
53
+ __classPrivateFieldGet(this, _BranchCommitEnricher_enricher, "f").updateChangeEnrichments(newCommit.change, newCommit.revision);
54
+ __classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").set(newCommit, replaceChange(newCommit, newChange));
55
+ }
56
+ }
57
+ __classPrivateFieldSet(this, _BranchCommitEnricher_getOuterTransactionChange, undefined, "f");
35
58
  }
36
- abortCurrentTransaction() {
37
- this.transactionEnricher.abortCurrentTransaction();
59
+ /**
60
+ * Retrieves the enriched version of the given commit.
61
+ * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.
62
+ * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.
63
+ */
64
+ enrich(commit) {
65
+ const prepared = __classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").get(commit);
66
+ assert(prepared !== undefined, 0x980 /* Unknown commit */);
67
+ __classPrivateFieldGet(this, _BranchCommitEnricher_preparedCommits, "f").delete(commit);
68
+ return prepared;
38
69
  }
39
70
  /**
40
- * Adds a commit to the enricher.
41
- * @param commit - A commit that is part of a transaction.
71
+ * Notify the enricher that a new transaction has started.
72
+ * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing "nested transactions".
42
73
  */
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);
74
+ startTransaction() {
75
+ __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").startTransaction();
47
76
  }
48
77
  /**
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.
78
+ * Commit the current transaction.
79
+ * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.
55
80
  */
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));
81
+ commitTransaction() {
82
+ __classPrivateFieldSet(this, _BranchCommitEnricher_getOuterTransactionChange, __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").commitTransaction(), "f");
66
83
  }
67
84
  /**
68
- * @param commit - A commit previously passed to {@link BranchCommitEnricher.prepareCommit}.
69
- * @returns The enriched commit corresponds to the given commit.
85
+ * Notify the enricher that the current transaction has been aborted.
86
+ * @remarks This will throw an error if there is no ongoing transaction.
70
87
  */
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;
88
+ abortTransaction() {
89
+ __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").abortTransaction();
76
90
  }
77
91
  /**
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.
92
+ * Add new transaction commits to the current transaction.
93
+ * @param newCommits - The new commits to add.
94
+ * @remarks This will throw an error if there is no ongoing transaction.
82
95
  */
83
- purgePreparedCommits() {
84
- this.preparedCommits.clear();
96
+ addTransactionCommits(newCommits) {
97
+ assert(__classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").isTransacting(), 0xa97 /* Not in transaction */);
98
+ for (const commit of newCommits) {
99
+ __classPrivateFieldGet(this, _BranchCommitEnricher_transactionEnricher, "f").addTransactionStep(commit);
100
+ }
85
101
  }
86
102
  }
103
+ _BranchCommitEnricher_transactionEnricher = new WeakMap(), _BranchCommitEnricher_enricher = new WeakMap(), _BranchCommitEnricher_preparedCommits = new WeakMap(), _BranchCommitEnricher_getOuterTransactionChange = new WeakMap();
87
104
  //# 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;QAMV,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC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,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;AAG/D;;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,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC3C,MAAM,SAAS,GACd,uBAAA,IAAI,uDAA2B,EAAE,KAAjC,IAAI,EAA8B,SAAS,CAAC,QAAQ,CAAC;oBACrD,uBAAA,IAAI,sCAAU,CAAC,uBAAuB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAE9E,uBAAA,IAAI,6CAAiB,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;QAED,uBAAA,IAAI,mDAA8B,SAAS,MAAA,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAA4B;QACzC,MAAM,QAAQ,GAAG,uBAAA,IAAI,6CAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC3D,uBAAA,IAAI,6CAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,uBAAA,IAAI,mDAA8B,uBAAA,IAAI,iDAAqB,CAAC,iBAAiB,EAAE,MAAA,CAAC;IACjF,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACtB,uBAAA,IAAI,iDAAqB,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,UAA0C;QACtE,MAAM,CAAC,uBAAA,IAAI,iDAAqB,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAClF,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAqB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ChangeRebaser,\n\ttype GraphCommit,\n\treplaceChange,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport type { ChangeEnricherReadonlyCheckout } from \"./changeEnricher.js\";\nimport { TransactionEnricher } from \"./transactionEnricher.js\";\nimport type { SharedTreeBranchChange } from \"./branch.js\";\n\n/**\n * Utility for enriching commits from a {@link Branch} before these commits are applied and submitted.\n */\nexport class BranchCommitEnricher<TChange> {\n\treadonly #transactionEnricher: TransactionEnricher<TChange>;\n\treadonly #enricher: ChangeEnricherReadonlyCheckout<TChange>;\n\t/**\n\t * Maps each local commit to the corresponding enriched commit.\n\t * @remarks\n\t * Entries are added when the commits are {@link BranchCommitEnricher.processChange | processed during a change}.\n\t * Each entry is removed when it is {@link BranchCommitEnricher.enrich | retrieved}.\n\t * In the event that an entry is not explicitly removed, it will eventually be {@link WeakMap | dropped from memory} along with the associated commit.\n\t */\n\treadonly #preparedCommits: WeakMap<GraphCommit<TChange>, GraphCommit<TChange>> = new Map();\n\n\t/**\n\t * If defined, a top-level transaction has been {@link BranchCommitEnricher.commitTransaction | committed} since the last {@link BranchCommitEnricher.processChange | change has been processed}.\n\t * Calling this function will compute the composition of that transaction's commits.\n\t * @remarks This function will be reset to undefined after each {@link BranchCommitEnricher.processChange | change is processed}.\n\t */\n\t#getOuterTransactionChange?: (revision: RevisionTag) => TChange;\n\n\tpublic constructor(\n\t\trebaser: ChangeRebaser<TChange>,\n\t\tenricher: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {\n\t\tthis.#enricher = enricher;\n\t\tthis.#transactionEnricher = new TransactionEnricher(rebaser, this.#enricher);\n\t}\n\n\t/**\n\t * Process the given change, preparing new commits for {@link BranchCommitEnricher.enrich | enrichment}.\n\t * @param change - The change to process.\n\t * @param isAttached - Whether or not the SharedTree is attached to the service.\n\t */\n\tpublic processChange(change: SharedTreeBranchChange<TChange>): void {\n\t\tif (change.type === \"append\") {\n\t\t\tfor (const newCommit of change.newCommits) {\n\t\t\t\tconst newChange =\n\t\t\t\t\tthis.#getOuterTransactionChange?.(newCommit.revision) ??\n\t\t\t\t\tthis.#enricher.updateChangeEnrichments(newCommit.change, newCommit.revision);\n\n\t\t\t\tthis.#preparedCommits.set(newCommit, replaceChange(newCommit, newChange));\n\t\t\t}\n\t\t}\n\n\t\tthis.#getOuterTransactionChange = undefined;\n\t}\n\n\t/**\n\t * Retrieves the enriched version of the given commit.\n\t * @param commit - A commit {@link BranchCommitEnricher.processChange | processed during the most recent change}.\n\t * @remarks A commit can only be enriched once - subsequent calls to this method with the same commit will throw an error.\n\t */\n\tpublic enrich(commit: GraphCommit<TChange>): GraphCommit<TChange> {\n\t\tconst prepared = this.#preparedCommits.get(commit);\n\t\tassert(prepared !== undefined, 0x980 /* Unknown commit */);\n\t\tthis.#preparedCommits.delete(commit);\n\t\treturn prepared;\n\t}\n\n\t/**\n\t * Notify the enricher that a new transaction has started.\n\t * @remarks This may be called multiple times without calling {@link BranchCommitEnricher.commitTransaction | commitTransaction}, producing \"nested transactions\".\n\t */\n\tpublic startTransaction(): void {\n\t\tthis.#transactionEnricher.startTransaction();\n\t}\n\n\t/**\n\t * Commit the current transaction.\n\t * @remarks This should be called _before_ the corresponding transaction commit change is {@link BranchCommitEnricher.processChange | processed}.\n\t */\n\tpublic commitTransaction(): void {\n\t\tthis.#getOuterTransactionChange = this.#transactionEnricher.commitTransaction();\n\t}\n\n\t/**\n\t * Notify the enricher that the current transaction has been aborted.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic abortTransaction(): void {\n\t\tthis.#transactionEnricher.abortTransaction();\n\t}\n\n\t/**\n\t * Add new transaction commits to the current transaction.\n\t * @param newCommits - The new commits to add.\n\t * @remarks This will throw an error if there is no ongoing transaction.\n\t */\n\tpublic addTransactionCommits(newCommits: Iterable<GraphCommit<TChange>>): void {\n\t\tassert(this.#transactionEnricher.isTransacting(), 0xa97 /* Not in transaction */);\n\t\tfor (const commit of newCommits) {\n\t\t\tthis.#transactionEnricher.addTransactionStep(commit);\n\t\t}\n\t}\n}\n"]}
@@ -1 +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,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAEM,kBAAkB,CAAC,UAA2C;QACpE,MAAM,CACL,CAAC,IAAI,CAAC,iBAAiB,EACvB,KAAK,CAAC,mEAAmE,CACzE,CAAC;QACF,MAAM,CACL,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAC/C,KAAK,CAAC,qEAAqE,CAC3E,CAAC;QACF,IAAI,IAAI,CAAC,wCAAwC,KAAK,CAAC,CAAC,EAAE,CAAC;YAC1D,6EAA6E;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ACD,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC1B,0DAA0D;YAC1D,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/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,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IACvC,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 } 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;AAElE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG1D;;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,GA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,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,UAAU,CAAC;aAgFtC,YAAY,EAAE,aAAa;aAC3B,cAAc,EAAE,SAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAhFjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IAEjE,uFAAuF;IACvF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwC;IAE9D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG1B;IACJ;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAG1B;IAEF;;;;OAIG;IACH,OAAO,CAAC,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{ 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
- import { SharedTreeBranch, getChangeReplaceType, onForkTransitive, } from "./branch.js";
10
+ import { SharedTreeBranch, 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 = {
@@ -118,12 +118,12 @@ export class EditManager {
118
118
  this.trackBranch(branch);
119
119
  // Whenever the branch is rebased, update our record of its base trunk commit
120
120
  const offBeforeRebase = branch.events.on("beforeChange", (args) => {
121
- if (args.type === "replace" && getChangeReplaceType(args) === "rebase") {
121
+ if (args.type === "rebase") {
122
122
  this.untrackBranch(branch);
123
123
  }
124
124
  });
125
125
  const offAfterRebase = branch.events.on("afterChange", (args) => {
126
- if (args.type === "replace" && getChangeReplaceType(args) === "rebase") {
126
+ if (args.type === "rebase") {
127
127
  this.trackBranch(branch);
128
128
  this.trimTrunk();
129
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"editManager.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAKN,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,YAAY,EAEZ,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAgB,KAAK,EAAE,IAAI,EAAE,WAAW,EAA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,MAAM,CAAC,iBAAiB;aACtC;YACF,CAAC,CAAC,QAAQ,CAAC;QAEb,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC/D,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACvE,OAAO,MAAM,CAAC;IACf,CAAC;IAEO,QAAQ,CAAC,cAAyB;QACzC,MAAM,eAAe,GAAe;YACnC,cAAc;SACd,CAAC;QACF,MAAM,aAAa,GAAe;YACjC,cAAc,EAAE,KAAK,CAAE,cAAyB,GAAG,CAAC,CAAC;SACrD,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;CACD;AAUD;;GAEG;AACH,SAAS,eAAe,CACvB,UAAmB,EACnB,cAAuB;IAEvB,MAAM,IAAI,GAAc,EAAE,CAAC;IAC3B,MAAM,CACL,kBAAkB,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,SAAS,EACpE,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","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 { SessionId } from \"@fluidframework/id-compressor\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseChange,\n\ttype RebaseStatsWithDuration,\n\ttagChange,\n} from \"../core/index.js\";\nimport { type Mutable, brand, fail, getOrCreate, mapIterable } from \"../util/index.js\";\n\nimport {\n\tSharedTreeBranch,\n\ttype BranchTrimmingEvents,\n\tgetChangeReplaceType,\n\tonForkTransitive,\n} from \"./branch.js\";\nimport type {\n\tCommit,\n\tSeqNumber,\n\tSequenceId,\n\tSequencedCommit,\n\tSummarySessionBranch,\n} from \"./editManagerFormat.js\";\nimport {\n\tdecrementSequenceId,\n\tequalSequenceIds,\n\tmaxSequenceId,\n\tminSequenceId,\n\tsequenceIdComparator,\n} from \"./sequenceIdUtils.js\";\nimport { createEmitter } from \"../events/index.js\";\nimport {\n\tTelemetryEventBatcher,\n\tmeasure,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport const minimumPossibleSequenceNumber: SeqNumber = brand(Number.MIN_SAFE_INTEGER);\nconst minimumPossibleSequenceId: SequenceId = {\n\tsequenceNumber: minimumPossibleSequenceNumber,\n};\n\n/**\n * A special revision tag for the initial {@link EditManager.trunkBase} commit.\n * @remarks This tag is used to supply the _initial_ trunk base with a known revision.\n * The trunk base may advance over time, after which point the trunk base will have a different revision.\n * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.\n */\nconst rootRevision = \"root\" as const satisfies RevisionTag;\n\n/**\n * Max number of telemetry log call that may be aggregated before being sent.\n */\nconst maxRebaseStatsAggregationCount = 1000;\n\n/**\n * Represents a local branch of a document and interprets the effect on the document of adding sequenced changes,\n * which were based on a given session's branch, to the document history\n */\n// TODO: Try to reduce this to a single type parameter\nexport class EditManager<\n\tTEditor extends ChangeFamilyEditor,\n\tTChangeset,\n\tTChangeFamily extends ChangeFamily<TEditor, TChangeset>,\n> {\n\tprivate readonly _events = createEmitter<BranchTrimmingEvents>();\n\n\t/** The \"trunk\" branch. The trunk represents the list of received sequenced changes. */\n\tprivate readonly trunk: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Records extra data associated with commits in the {@link trunk}.\n\t * This does not include an entry for the {@link trunkBase}.\n\t */\n\tprivate readonly trunkMetadata = new Map<\n\t\tRevisionTag,\n\t\t{ sequenceId: SequenceId; sessionId: SessionId }\n\t>();\n\t/**\n\t * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.\n\t * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.\n\t */\n\tprivate readonly sequenceMap = new BTree<SequenceId, GraphCommit<TChangeset>>(\n\t\tundefined,\n\t\tsequenceIdComparator,\n\t);\n\n\t/**\n\t * Branches are maintained to represent the local change list that the issuing client had\n\t * at the time of submitting the latest known edit on the branch.\n\t * This means the head commit of each branch is always in its original (non-rebased) form.\n\t */\n\tprivate readonly peerLocalBranches: Map<SessionId, SharedTreeBranch<TEditor, TChangeset>> =\n\t\tnew Map();\n\n\t/**\n\t * This branch holds the changes made by this client which have not yet been confirmed as sequenced changes.\n\t */\n\tpublic readonly localBranch: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on\n\t * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.\n\t *\n\t * @remarks\n\t * This does not include the local branch.\n\t */\n\tprivate readonly trunkBranches = new BTree<\n\t\tSequenceId,\n\t\tSet<SharedTreeBranch<TEditor, TChangeset>>\n\t>(undefined, sequenceIdComparator);\n\n\t/**\n\t * The sequence number of the newest commit on the trunk that has been received by all peers.\n\t * Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tprivate minimumSequenceNumber = minimumPossibleSequenceNumber;\n\n\t/**\n\t * A special commit that is a \"base\" (tail) of the trunk, though not part of the trunk itself.\n\t * This makes it possible to model the trunk in the same way as any other branch (it branches off of a base commit)\n\t * which allows it to use branching APIs to interact with the other branches.\n\t * Each time trunk eviction occurs, the most recent evicted commit becomes the new `trunkBase`.\n\t */\n\tprivate trunkBase: GraphCommit<TChangeset>;\n\n\t/**\n\t * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.\n\t * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.\n\t */\n\tprivate readonly localCommits: GraphCommit<TChangeset>[] = [];\n\n\tprivate readonly telemetryEventBatcher:\n\t\t| TelemetryEventBatcher<keyof RebaseStatsWithDuration>\n\t\t| undefined;\n\n\t/**\n\t * @param changeFamily - the change family of changes on the trunk and local branch\n\t * @param localSessionId - the id of the local session that will be used for local commits\n\t */\n\tpublic constructor(\n\t\tpublic readonly changeFamily: TChangeFamily,\n\t\tpublic readonly localSessionId: SessionId,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tlogger?: ITelemetryLoggerExt,\n\t) {\n\t\tthis.trunkBase = {\n\t\t\trevision: rootRevision,\n\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t};\n\t\tthis.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);\n\n\t\tif (logger !== undefined) {\n\t\t\tthis.telemetryEventBatcher = new TelemetryEventBatcher(\n\t\t\t\t{\n\t\t\t\t\teventName: \"rebaseProcessing\",\n\t\t\t\t\tcategory: \"performance\",\n\t\t\t\t},\n\t\t\t\tlogger,\n\t\t\t\tmaxRebaseStatsAggregationCount,\n\t\t\t);\n\t\t}\n\n\t\tthis.trunk = new SharedTreeBranch(\n\t\t\tthis.trunkBase,\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\t\tthis.localBranch = new SharedTreeBranch(\n\t\t\tthis.trunk.getHead(),\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\n\t\tthis.localBranch.events.on(\"afterChange\", (event) => {\n\t\t\tif (event.type === \"append\") {\n\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\tthis.localCommits.push(commit);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.localCommits.length = 0;\n\t\t\t\tfindCommonAncestor(\n\t\t\t\t\t[this.localBranch.getHead(), this.localCommits],\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have\n\t\t// an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits\n\t\t// they require and therefore we monitor them explicitly.\n\t\tonForkTransitive(this.localBranch, (fork) => this.registerBranch(fork));\n\t}\n\n\t/**\n\t * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered\n\t * branches remain usable even as the minimum sequence number advances.\n\t *\n\t * TODO#AB6926: Refactor local branch management into a separate class that encapsulates `trunkBranches` and everything\n\t * that touches it.\n\t * TODO#AB6925: Maintain the divergence point between each branch and the trunk so that we don't have to recompute\n\t * it so often.\n\t */\n\tprivate registerBranch(branch: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tthis.trackBranch(branch);\n\t\t// Whenever the branch is rebased, update our record of its base trunk commit\n\t\tconst offBeforeRebase = branch.events.on(\"beforeChange\", (args) => {\n\t\t\tif (args.type === \"replace\" && getChangeReplaceType(args) === \"rebase\") {\n\t\t\t\tthis.untrackBranch(branch);\n\t\t\t}\n\t\t});\n\t\tconst offAfterRebase = branch.events.on(\"afterChange\", (args) => {\n\t\t\tif (args.type === \"replace\" && getChangeReplaceType(args) === \"rebase\") {\n\t\t\t\tthis.trackBranch(branch);\n\t\t\t\tthis.trimTrunk();\n\t\t\t}\n\t\t});\n\t\t// When the branch is disposed, update our branch set and trim the trunk\n\t\tconst offDispose = branch.events.on(\"dispose\", () => {\n\t\t\tthis.untrackBranch(branch);\n\t\t\tthis.trimTrunk();\n\t\t\toffBeforeRebase();\n\t\t\toffAfterRebase();\n\t\t\toffDispose();\n\t\t});\n\t}\n\n\tprivate trackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\n\t\tassert(!branches.has(b), 0x670 /* Branch was registered more than once */);\n\t\tbranches.add(b);\n\t}\n\n\tprivate untrackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches =\n\t\t\tthis.trunkBranches.get(sequenceId) ?? fail(\"Expected branch to be tracked\");\n\n\t\tassert(branches.delete(b), 0x671 /* Expected branch to be tracked */);\n\t\tif (branches.size === 0) {\n\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t}\n\t}\n\n\t/**\n\t * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.\n\t * @param sequenceId - The sequence id of the new trunk commit\n\t * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.\n\t * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.\n\t * The first commit will be \"the same\" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.\n\t * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.\n\t * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.\n\t */\n\tprivate fastForwardNextLocalCommit(sequenceId: SequenceId): void {\n\t\t// First, push the local commit to the trunk.\n\t\t// We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.\n\t\tconst firstLocalCommit = this.localCommits.shift();\n\t\tassert(\n\t\t\tfirstLocalCommit !== undefined,\n\t\t\t0x6b5 /* Received a sequenced change from the local session despite having no local changes */,\n\t\t);\n\n\t\tconst previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());\n\t\tthis.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);\n\n\t\t// Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.\n\t\t// In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)\n\t\t// and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.\n\t\t// Intuitively, this makes sense because:\n\t\t// 1. The trunk's head just advanced forward by some (sequence) amount.\n\t\t// 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).\n\t\t// 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.\n\t\t// This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).\n\t\tconst currentBranches = this.trunkBranches.get(previousSequenceId);\n\t\tif (currentBranches !== undefined) {\n\t\t\tconst newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\t\t\tfor (const branch of currentBranches) {\n\t\t\t\t// Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).\n\t\t\t\t// We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.\n\t\t\t\tif (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {\n\t\t\t\t\tnewBranches.add(branch);\n\t\t\t\t\tcurrentBranches.delete(branch);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Clean up our trunk branches map by removing any empty sets.\n\t\t\tif (currentBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(previousSequenceId);\n\t\t\t}\n\t\t\tif (newBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.\n\t */\n\tpublic getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {\n\t\treturn this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;\n\t}\n\n\t/**\n\t * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,\n\t * if they are not retained by revertibles or local branches.\n\t * @param minimumSequenceNumber - the sequence number of the newest commit that all peers (including this one) have received and applied to their trunks.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tpublic advanceMinimumSequenceNumber(\n\t\tminimumSequenceNumber: SeqNumber,\n\t\ttrimTrunk = true,\n\t): void {\n\t\tif (minimumSequenceNumber === this.minimumSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tminimumSequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x476 /* number must be larger or equal to current minimumSequenceNumber. */,\n\t\t);\n\n\t\tthis.minimumSequenceNumber = minimumSequenceNumber;\n\t\tif (trimTrunk) {\n\t\t\tthis.trimTrunk();\n\t\t}\n\t}\n\n\t/**\n\t * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine\n\t * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.\n\t */\n\tprivate trimTrunk(): void {\n\t\t/** The sequence id of the most recent commit on the trunk that will be trimmed */\n\t\tlet trunkTailSequenceId: SequenceId = {\n\t\t\tsequenceNumber: this.minimumSequenceNumber,\n\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t};\n\t\t// If there are any outstanding registered branches, get the one that is the oldest (has the \"most behind\" trunk base)\n\t\tconst minimumBranchBaseSequenceId = this.trunkBranches.minKey();\n\t\tif (minimumBranchBaseSequenceId !== undefined) {\n\t\t\t// If that branch is behind the minimum sequence id, we only want to evict commits older than it,\n\t\t\t// even if those commits are behind the minimum sequence id\n\t\t\tconst sequenceIdBeforeMinimumBranchBase = decrementSequenceId(\n\t\t\t\tminimumBranchBaseSequenceId,\n\t\t\t);\n\t\t\ttrunkTailSequenceId = minSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tsequenceIdBeforeMinimumBranchBase,\n\t\t\t);\n\t\t}\n\n\t\tconst [sequenceId, latestEvicted] = this.getClosestTrunkCommit(\n\t\t\tmaxSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tthis.sequenceMap.minKey() ?? minimumPossibleSequenceId,\n\t\t\t),\n\t\t);\n\n\t\t// Don't do any work if the commit found by the search is already the tail of the trunk\n\t\tif (latestEvicted !== this.trunkBase) {\n\t\t\t// The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,\n\t\t\t// so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.\n\t\t\tfor (const [, branch] of this.peerLocalBranches) {\n\t\t\t\tbranch.rebaseOnto(this.trunk, latestEvicted);\n\t\t\t}\n\n\t\t\t// This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires\n\t\t\t// regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain\n\t\t\t// that there are no outstanding references to any of the commits being removed (other than the references via\n\t\t\t// the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased\n\t\t\t// to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at\n\t\t\t// `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.\n\t\t\t// We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that\n\t\t\t// have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.\n\t\t\tconst newTrunkBase = latestEvicted as Mutable<typeof latestEvicted>;\n\t\t\t// The metadata for new trunk base revision needs to be deleted before modifying it.\n\t\t\tthis.trunkMetadata.delete(newTrunkBase.revision);\n\t\t\t// collect the revisions that will be trimmed to send as part of the branch trimmed event\n\t\t\tconst trimmedRevisions: RevisionTag[] = getPathFromBase(\n\t\t\t\tnewTrunkBase,\n\t\t\t\tthis.trunkBase,\n\t\t\t).map((c) => c.revision);\n\t\t\t// Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.\n\t\t\tdelete newTrunkBase.parent;\n\t\t\tthis.trunkBase = newTrunkBase;\n\n\t\t\t// Update any state that is derived from trunk commits\n\t\t\tthis.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {\n\t\t\t\t// Cleanup look-aside data for each evicted commit\n\t\t\t\tthis.trunkMetadata.delete(commit.revision);\n\t\t\t\t// Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`\n\t\t\t\tif (equalSequenceIds(s, sequenceId)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommit === newTrunkBase,\n\t\t\t\t\t\t0x729 /* Expected last evicted commit to be new trunk base */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tReflect.defineProperty(commit, \"change\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5e /* Should not access 'change' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"revision\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5f /* Should not access 'revision' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"parent\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa60 /* Should not access 'parent' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\treturn { delete: true };\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;\n\t\t\tassert(\n\t\t\t\tthis.sequenceMap.size === trunkSize + 1,\n\t\t\t\t0x744 /* The size of the sequenceMap must have one element more than the trunk */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.trunkMetadata.size === trunkSize,\n\t\t\t\t0x745 /* The size of the trunkMetadata must be the same as the trunk */,\n\t\t\t);\n\n\t\t\tthis._events.emit(\"ancestryTrimmed\", trimmedRevisions);\n\t\t}\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn (\n\t\t\tthis.trunk.getHead() === this.trunkBase &&\n\t\t\tthis.peerLocalBranches.size === 0 &&\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead() &&\n\t\t\tthis.minimumSequenceNumber === minimumPossibleSequenceNumber\n\t\t);\n\t}\n\n\tpublic getSummaryData(): SummaryData<TChangeset> {\n\t\t// The assert below is acceptable at present because summarization only ever occurs on a client with no\n\t\t// local/in-flight changes.\n\t\t// In the future we may wish to relax this constraint. For that to work, the current implementation of\n\t\t// `EditManager` would have to be amended in one of two ways:\n\t\t// A) Changes made by the local session should be represented by a branch in `EditManager.branches`.\n\t\t// B) The contents of such a branch should be computed on demand based on the trunk.\n\t\t// Note that option (A) would be a simple change to `addSequencedChange` whereas (B) would likely require\n\t\t// rebasing trunk changes over the inverse of trunk changes.\n\t\tassert(\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead(),\n\t\t\t0x428 /* Clients with local changes cannot be used to generate summaries */,\n\t\t);\n\n\t\t// Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.\n\t\tthis.trimTrunk();\n\n\t\tlet oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];\n\t\tassert(\n\t\t\toldestCommitInCollabWindow.parent !== undefined ||\n\t\t\t\toldestCommitInCollabWindow === this.trunkBase,\n\t\t\t0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */,\n\t\t);\n\n\t\t// Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists\n\t\toldestCommitInCollabWindow =\n\t\t\toldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;\n\n\t\tconst trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(\n\t\t\t(c) => {\n\t\t\t\tassert(\n\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t0xa61 /* Serialized trunk should not include the trunk base */,\n\t\t\t\t);\n\t\t\t\tconst metadata =\n\t\t\t\t\tthis.trunkMetadata.get(c.revision) ?? fail(\"Expected metadata for trunk commit\");\n\t\t\t\tconst commit: SequencedCommit<TChangeset> = {\n\t\t\t\t\tchange: c.change,\n\t\t\t\t\trevision: c.revision,\n\t\t\t\t\tsequenceNumber: metadata.sequenceId.sequenceNumber,\n\t\t\t\t\tsessionId: metadata.sessionId,\n\t\t\t\t};\n\t\t\t\tif (metadata.sequenceId.indexInBatch !== undefined) {\n\t\t\t\t\tcommit.indexInBatch = metadata.sequenceId.indexInBatch;\n\t\t\t\t}\n\t\t\t\treturn commit;\n\t\t\t},\n\t\t);\n\n\t\tconst peerLocalBranches = new Map<SessionId, SummarySessionBranch<TChangeset>>(\n\t\t\tmapIterable(this.peerLocalBranches.entries(), ([sessionId, branch]) => {\n\t\t\t\tconst branchPath: GraphCommit<TChangeset>[] = [];\n\t\t\t\tconst ancestor =\n\t\t\t\t\tfindCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??\n\t\t\t\t\tfail(\"Expected branch to be based on trunk\");\n\n\t\t\t\tconst base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;\n\t\t\t\treturn [\n\t\t\t\t\tsessionId,\n\t\t\t\t\t{\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tcommits: branchPath.map((c) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t\t\t\t0xa62 /* Serialized branch should not include the trunk base */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst commit: Commit<TChangeset> = {\n\t\t\t\t\t\t\t\tchange: c.change,\n\t\t\t\t\t\t\t\trevision: c.revision,\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn commit;\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t\t);\n\n\t\treturn { trunk, peerLocalBranches };\n\t}\n\n\tpublic loadSummaryData(data: SummaryData<TChangeset>): void {\n\t\tassert(\n\t\t\tthis.isEmpty(),\n\t\t\t0x68a /* Attempted to load from summary after edit manager was already mutated */,\n\t\t);\n\t\t// Record the tags of each trunk commit as we generate the trunk so they can be looked up quickly\n\t\t// when hydrating the peer branches below\n\t\tconst trunkRevisionCache = new Map<RevisionTag, GraphCommit<TChangeset>>();\n\t\ttrunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);\n\t\tthis.trunk.setHead(\n\t\t\tdata.trunk.reduce((base, c) => {\n\t\t\t\tconst sequenceId: SequenceId =\n\t\t\t\t\tc.indexInBatch === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t\tindexInBatch: c.indexInBatch,\n\t\t\t\t\t\t\t};\n\t\t\t\tconst commit = mintCommit(base, c);\n\t\t\t\tthis.sequenceMap.set(sequenceId, commit);\n\t\t\t\tthis.trunkMetadata.set(c.revision, {\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tsessionId: c.sessionId,\n\t\t\t\t});\n\t\t\t\ttrunkRevisionCache.set(c.revision, commit);\n\t\t\t\treturn commit;\n\t\t\t}, this.trunkBase),\n\t\t);\n\n\t\tthis.localBranch.setHead(this.trunk.getHead());\n\n\t\tfor (const [sessionId, branch] of data.peerLocalBranches) {\n\t\t\tconst commit =\n\t\t\t\ttrunkRevisionCache.get(branch.base) ??\n\t\t\t\tfail(\"Expected summary branch to be based off of a revision in the trunk\");\n\n\t\t\tthis.peerLocalBranches.set(\n\t\t\t\tsessionId,\n\t\t\t\tnew SharedTreeBranch(\n\t\t\t\t\tbranch.commits.reduce(mintCommit, commit),\n\t\t\t\t\tthis.changeFamily,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {\n\t\tconst id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;\n\t\tif (id === undefined) {\n\t\t\tassert(\n\t\t\t\ttrunkCommitOrTrunkBase === this.trunkBase,\n\t\t\t\t0xa63 /* Commit must be either be on the trunk or be the trunk base */,\n\t\t\t);\n\t\t\treturn minimumPossibleSequenceId;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic getTrunkChanges(): readonly TChangeset[] {\n\t\treturn this.getTrunkCommits().map((c) => c.change);\n\t}\n\n\tpublic getTrunkCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn getPathFromBase(this.trunk.getHead(), this.trunkBase);\n\t}\n\n\tpublic getTrunkHead(): GraphCommit<TChangeset> {\n\t\treturn this.trunk.getHead();\n\t}\n\n\tpublic getLocalChanges(): readonly TChangeset[] {\n\t\treturn this.getLocalCommits().map((c) => c.change);\n\t}\n\n\tpublic getLocalCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn this.localCommits;\n\t}\n\n\t/**\n\t * @returns The length of the longest branch maintained by this EditManager.\n\t * This may be the length of a peer branch or the local branch.\n\t * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would\n\t * have length zero.\n\t */\n\tpublic getLongestBranchLength(): number {\n\t\tlet max = 0;\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tfor (const branch of this.peerLocalBranches.values()) {\n\t\t\tconst branchPath = getPathFromBase(branch.getHead(), trunkHead);\n\t\t\tif (branchPath.length > max) {\n\t\t\t\tmax = branchPath.length;\n\t\t\t}\n\t\t}\n\t\tconst localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);\n\t\treturn Math.max(max, localPath.length);\n\t}\n\n\tpublic addSequencedChange(\n\t\tnewCommit: Commit<TChangeset>,\n\t\tsequenceNumber: SeqNumber,\n\t\treferenceSequenceNumber: SeqNumber,\n\t): void {\n\t\tassert(\n\t\t\tsequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,\n\t\t);\n\n\t\tassert(\n\t\t\tsequenceNumber >= // This is \">=\", not \">\" because changes in the same batch will have the same sequence number\n\t\t\t\t(this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),\n\t\t\t0xa64 /* Attempted to sequence change with an outdated sequence number */,\n\t\t);\n\n\t\tconst commitsSequenceNumber = this.getBatch(sequenceNumber);\n\t\tconst sequenceId: SequenceId =\n\t\t\tcommitsSequenceNumber.length === 0\n\t\t\t\t? {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\tindexInBatch: commitsSequenceNumber.length,\n\t\t\t\t\t};\n\n\t\tif (newCommit.sessionId === this.localSessionId) {\n\t\t\treturn this.fastForwardNextLocalCommit(sequenceId);\n\t\t}\n\n\t\t// Get the revision that the remote change is based on\n\t\tconst [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);\n\t\t// Rebase that branch over the part of the trunk up to the base revision\n\t\t// This will be a no-op if the sending client has not advanced since the last time we received an edit from it\n\t\tconst peerLocalBranch = getOrCreate(\n\t\t\tthis.peerLocalBranches,\n\t\t\tnewCommit.sessionId,\n\t\t\t() => new SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag),\n\t\t);\n\t\tpeerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);\n\n\t\tif (peerLocalBranch.getHead() === this.trunk.getHead()) {\n\t\t\t// If the branch is fully caught up and empty after being rebased, then push to the trunk directly\n\t\t\tthis.pushCommitToTrunk(sequenceId, newCommit);\n\t\t\tpeerLocalBranch.setHead(this.trunk.getHead());\n\t\t} else {\n\t\t\t// Otherwise, rebase the change over the trunk and append it, and append the original change to the peer branch.\n\t\t\tconst { duration, output: newChangeFullyRebased } = measure(() =>\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tnewCommit,\n\t\t\t\t\tpeerLocalBranch.getHead(),\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tthis.telemetryEventBatcher?.accumulateAndLog({\n\t\t\t\tduration,\n\t\t\t\t...newChangeFullyRebased.telemetryProperties,\n\t\t\t});\n\n\t\t\tpeerLocalBranch.apply(tagChange(newCommit.change, newCommit.revision));\n\t\t\tthis.pushCommitToTrunk(sequenceId, {\n\t\t\t\t...newCommit,\n\t\t\t\tchange: newChangeFullyRebased.change,\n\t\t\t});\n\t\t}\n\n\t\tthis.localBranch.rebaseOnto(this.trunk);\n\t}\n\n\tpublic findLocalCommit(\n\t\trevision: RevisionTag,\n\t): [commit: GraphCommit<TChangeset>, commitsAfter: GraphCommit<TChangeset>[]] {\n\t\tconst commits: GraphCommit<TChangeset>[] = [];\n\t\tconst commit = findAncestor(\n\t\t\t[this.localBranch.getHead(), commits],\n\t\t\t(c) => c.revision === revision,\n\t\t);\n\t\tassert(commit !== undefined, 0x599 /* Expected local branch to contain revision */);\n\t\treturn [commit, commits];\n\t}\n\n\tprivate pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {\n\t\tconst mintedCommit = mintCommit(this.trunk.getHead(), commit);\n\t\tthis.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);\n\t}\n\n\tprivate pushGraphCommitToTrunk(\n\t\tsequenceId: SequenceId,\n\t\tgraphCommit: GraphCommit<TChangeset>,\n\t\tsessionId: SessionId,\n\t): void {\n\t\tthis.trunk.setHead(graphCommit);\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tthis.sequenceMap.set(sequenceId, trunkHead);\n\t\tthis.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });\n\t}\n\n\t/**\n\t * Finds the most recent trunk commit that was sequenced at or before the given point.\n\t * @param searchBy - the sequence number or the sequence id to search for\n\t * @remarks Fails if there is no eligible commit.\n\t * @returns the closest commit and its sequence id\n\t */\n\tprivate getClosestTrunkCommit(searchBy: SeqNumber): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(searchBy: SequenceId): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(\n\t\tsearchBy: SeqNumber | SequenceId,\n\t): [SequenceId, GraphCommit<TChangeset>] {\n\t\tconst sequenceId: SequenceId =\n\t\t\ttypeof searchBy === \"number\"\n\t\t\t\t? {\n\t\t\t\t\t\t// This is to make sure that the correct commit is selected in this 2 scenarios:\n\t\t\t\t\t\t// 1) The commit is unique for that sequence number\n\t\t\t\t\t\t// 2) There are more than one commit for the same sequence number, in this case we need to select the last one.\n\t\t\t\t\t\tsequenceNumber: searchBy,\n\t\t\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t\t\t}\n\t\t\t\t: searchBy;\n\n\t\tconst commit = this.sequenceMap.getPairOrNextLower(sequenceId);\n\t\tassert(commit !== undefined, 0x746 /* sequence id has been evicted */);\n\t\treturn commit;\n\t}\n\n\tprivate getBatch(sequenceNumber: SeqNumber): [SequenceId, GraphCommit<TChangeset>][] {\n\t\tconst startSequenceId: SequenceId = {\n\t\t\tsequenceNumber,\n\t\t};\n\t\tconst endSequenceId: SequenceId = {\n\t\t\tsequenceNumber: brand((sequenceNumber as number) + 1),\n\t\t};\n\n\t\treturn this.sequenceMap.getRange(startSequenceId, endSequenceId, false);\n\t}\n}\n\n/**\n * The in-memory data that summaries contain\n */\nexport interface SummaryData<TChangeset> {\n\treadonly trunk: readonly SequencedCommit<TChangeset>[];\n\treadonly peerLocalBranches: ReadonlyMap<SessionId, SummarySessionBranch<TChangeset>>;\n}\n\n/**\n * @returns the path from the base of a branch to its head\n */\nfunction getPathFromBase<TCommit extends { parent?: TCommit }>(\n\tbranchHead: TCommit,\n\tbaseBranchHead: TCommit,\n): TCommit[] {\n\tconst path: TCommit[] = [];\n\tassert(\n\t\tfindCommonAncestor([branchHead, path], baseBranchHead) !== undefined,\n\t\t0x573 /* Expected branches to be related */,\n\t);\n\treturn path;\n}\n"]}
1
+ {"version":3,"file":"editManager.js","sourceRoot":"","sources":["../../src/shared-tree-core/editManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAKN,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,YAAY,EAEZ,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAgB,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAA6B,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ5F,OAAO,EACN,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,qBAAqB,EACrB,OAAO,GAEP,MAAM,0CAA0C,CAAC;AAElD,MAAM,CAAC,MAAM,6BAA6B,GAAc,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvF,MAAM,yBAAyB,GAAe;IAC7C,cAAc,EAAE,6BAA6B;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,YAAY,GAAG,MAAqC,CAAC;AAE3D;;GAEG;AACH,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAE5C;;;GAGG;AACH,sDAAsD;AACtD,MAAM,OAAO,WAAW;IA8EvB;;;OAGG;I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IACF,OAAO,IAAI,CAAC;AACb,CAAC","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 { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport {\n\ttype ChangeFamily,\n\ttype ChangeFamilyEditor,\n\ttype GraphCommit,\n\ttype RevisionTag,\n\tfindAncestor,\n\tfindCommonAncestor,\n\tmintCommit,\n\trebaseChange,\n\ttype RebaseStatsWithDuration,\n\ttagChange,\n} from \"../core/index.js\";\nimport { type Mutable, brand, fail, getOrCreate, mapIterable } from \"../util/index.js\";\n\nimport { SharedTreeBranch, type BranchTrimmingEvents, onForkTransitive } from \"./branch.js\";\nimport type {\n\tCommit,\n\tSeqNumber,\n\tSequenceId,\n\tSequencedCommit,\n\tSummarySessionBranch,\n} from \"./editManagerFormat.js\";\nimport {\n\tdecrementSequenceId,\n\tequalSequenceIds,\n\tmaxSequenceId,\n\tminSequenceId,\n\tsequenceIdComparator,\n} from \"./sequenceIdUtils.js\";\nimport {\n\tTelemetryEventBatcher,\n\tmeasure,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nexport const minimumPossibleSequenceNumber: SeqNumber = brand(Number.MIN_SAFE_INTEGER);\nconst minimumPossibleSequenceId: SequenceId = {\n\tsequenceNumber: minimumPossibleSequenceNumber,\n};\n\n/**\n * A special revision tag for the initial {@link EditManager.trunkBase} commit.\n * @remarks This tag is used to supply the _initial_ trunk base with a known revision.\n * The trunk base may advance over time, after which point the trunk base will have a different revision.\n * When {@link EditManager.getSummaryData | serializing} and deserializing, peer branches that include the trunk base commit in their history will always use this tag.\n */\nconst rootRevision = \"root\" as const satisfies RevisionTag;\n\n/**\n * Max number of telemetry log call that may be aggregated before being sent.\n */\nconst maxRebaseStatsAggregationCount = 1000;\n\n/**\n * Represents a local branch of a document and interprets the effect on the document of adding sequenced changes,\n * which were based on a given session's branch, to the document history\n */\n// TODO: Try to reduce this to a single type parameter\nexport class EditManager<\n\tTEditor extends ChangeFamilyEditor,\n\tTChangeset,\n\tTChangeFamily extends ChangeFamily<TEditor, TChangeset>,\n> {\n\tprivate readonly _events = createEmitter<BranchTrimmingEvents>();\n\n\t/** The \"trunk\" branch. The trunk represents the list of received sequenced changes. */\n\tprivate readonly trunk: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Records extra data associated with commits in the {@link trunk}.\n\t * This does not include an entry for the {@link trunkBase}.\n\t */\n\tprivate readonly trunkMetadata = new Map<\n\t\tRevisionTag,\n\t\t{ sequenceId: SequenceId; sessionId: SessionId }\n\t>();\n\t/**\n\t * A map from a sequence id to the commit in the {@link trunk} which has that sequence id.\n\t * This also includes an entry for the {@link trunkBase} which always has the lowest key in the map.\n\t */\n\tprivate readonly sequenceMap = new BTree<SequenceId, GraphCommit<TChangeset>>(\n\t\tundefined,\n\t\tsequenceIdComparator,\n\t);\n\n\t/**\n\t * Branches are maintained to represent the local change list that the issuing client had\n\t * at the time of submitting the latest known edit on the branch.\n\t * This means the head commit of each branch is always in its original (non-rebased) form.\n\t */\n\tprivate readonly peerLocalBranches: Map<SessionId, SharedTreeBranch<TEditor, TChangeset>> =\n\t\tnew Map();\n\n\t/**\n\t * This branch holds the changes made by this client which have not yet been confirmed as sequenced changes.\n\t */\n\tpublic readonly localBranch: SharedTreeBranch<TEditor, TChangeset>;\n\n\t/**\n\t * Tracks where on the trunk all registered branches are based. Each key is the sequence id of a commit on\n\t * the trunk, and the value is the set of all branches who have that commit as their common ancestor with the trunk.\n\t *\n\t * @remarks\n\t * This does not include the local branch.\n\t */\n\tprivate readonly trunkBranches = new BTree<\n\t\tSequenceId,\n\t\tSet<SharedTreeBranch<TEditor, TChangeset>>\n\t>(undefined, sequenceIdComparator);\n\n\t/**\n\t * The sequence number of the newest commit on the trunk that has been received by all peers.\n\t * Defaults to {@link minimumPossibleSequenceNumber} if no commits have been received.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tprivate minimumSequenceNumber = minimumPossibleSequenceNumber;\n\n\t/**\n\t * A special commit that is a \"base\" (tail) of the trunk, though not part of the trunk itself.\n\t * This makes it possible to model the trunk in the same way as any other branch (it branches off of a base commit)\n\t * which allows it to use branching APIs to interact with the other branches.\n\t * Each time trunk eviction occurs, the most recent evicted commit becomes the new `trunkBase`.\n\t */\n\tprivate trunkBase: GraphCommit<TChangeset>;\n\n\t/**\n\t * The list of commits (from oldest to most recent) that are on the local branch but not on the trunk.\n\t * When a local commit is sequenced, the first commit in this list shifted onto the tip of the trunk.\n\t */\n\tprivate readonly localCommits: GraphCommit<TChangeset>[] = [];\n\n\tprivate readonly telemetryEventBatcher:\n\t\t| TelemetryEventBatcher<keyof RebaseStatsWithDuration>\n\t\t| undefined;\n\n\t/**\n\t * @param changeFamily - the change family of changes on the trunk and local branch\n\t * @param localSessionId - the id of the local session that will be used for local commits\n\t */\n\tpublic constructor(\n\t\tpublic readonly changeFamily: TChangeFamily,\n\t\tpublic readonly localSessionId: SessionId,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tlogger?: ITelemetryLoggerExt,\n\t) {\n\t\tthis.trunkBase = {\n\t\t\trevision: rootRevision,\n\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t};\n\t\tthis.sequenceMap.set(minimumPossibleSequenceId, this.trunkBase);\n\n\t\tif (logger !== undefined) {\n\t\t\tthis.telemetryEventBatcher = new TelemetryEventBatcher(\n\t\t\t\t{\n\t\t\t\t\teventName: \"rebaseProcessing\",\n\t\t\t\t\tcategory: \"performance\",\n\t\t\t\t},\n\t\t\t\tlogger,\n\t\t\t\tmaxRebaseStatsAggregationCount,\n\t\t\t);\n\t\t}\n\n\t\tthis.trunk = new SharedTreeBranch(\n\t\t\tthis.trunkBase,\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\t\tthis.localBranch = new SharedTreeBranch(\n\t\t\tthis.trunk.getHead(),\n\t\t\tchangeFamily,\n\t\t\tmintRevisionTag,\n\t\t\tthis._events,\n\t\t\tthis.telemetryEventBatcher,\n\t\t);\n\n\t\tthis.localBranch.events.on(\"afterChange\", (event) => {\n\t\t\tif (event.type === \"append\") {\n\t\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\t\tthis.localCommits.push(commit);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.localCommits.length = 0;\n\t\t\t\tfindCommonAncestor(\n\t\t\t\t\t[this.localBranch.getHead(), this.localCommits],\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// Track all forks of the local branch for purposes of trunk eviction. Unlike the local branch, they have\n\t\t// an unknown lifetime and rebase frequency, so we can not make any assumptions about which trunk commits\n\t\t// they require and therefore we monitor them explicitly.\n\t\tonForkTransitive(this.localBranch, (fork) => this.registerBranch(fork));\n\t}\n\n\t/**\n\t * Make the given branch known to the `EditManager`. The `EditManager` will ensure that all registered\n\t * branches remain usable even as the minimum sequence number advances.\n\t *\n\t * TODO#AB6926: Refactor local branch management into a separate class that encapsulates `trunkBranches` and everything\n\t * that touches it.\n\t * TODO#AB6925: Maintain the divergence point between each branch and the trunk so that we don't have to recompute\n\t * it so often.\n\t */\n\tprivate registerBranch(branch: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tthis.trackBranch(branch);\n\t\t// Whenever the branch is rebased, update our record of its base trunk commit\n\t\tconst offBeforeRebase = branch.events.on(\"beforeChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.untrackBranch(branch);\n\t\t\t}\n\t\t});\n\t\tconst offAfterRebase = branch.events.on(\"afterChange\", (args) => {\n\t\t\tif (args.type === \"rebase\") {\n\t\t\t\tthis.trackBranch(branch);\n\t\t\t\tthis.trimTrunk();\n\t\t\t}\n\t\t});\n\t\t// When the branch is disposed, update our branch set and trim the trunk\n\t\tconst offDispose = branch.events.on(\"dispose\", () => {\n\t\t\tthis.untrackBranch(branch);\n\t\t\tthis.trimTrunk();\n\t\t\toffBeforeRebase();\n\t\t\toffAfterRebase();\n\t\t\toffDispose();\n\t\t});\n\t}\n\n\tprivate trackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\n\t\tassert(!branches.has(b), 0x670 /* Branch was registered more than once */);\n\t\tbranches.add(b);\n\t}\n\n\tprivate untrackBranch(b: SharedTreeBranch<TEditor, TChangeset>): void {\n\t\tconst trunkCommit =\n\t\t\tfindCommonAncestor(this.trunk.getHead(), b.getHead()) ??\n\t\t\tfail(\"Expected branch to be related to trunk\");\n\t\tconst sequenceId = this.getCommitSequenceId(trunkCommit);\n\t\tconst branches =\n\t\t\tthis.trunkBranches.get(sequenceId) ?? fail(\"Expected branch to be tracked\");\n\n\t\tassert(branches.delete(b), 0x671 /* Expected branch to be tracked */);\n\t\tif (branches.size === 0) {\n\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t}\n\t}\n\n\t/**\n\t * Promote the oldest un-sequenced commit on the local branch to the head of the trunk.\n\t * @param sequenceId - The sequence id of the new trunk commit\n\t * @remarks This method is a performance optimization for the scenario where this client receives its own change back after sequencing.\n\t * The normal (not optimized) process in this case would be to apply the new sequenced commit to the trunk and then rebase the local branch over the trunk.\n\t * The first commit will be \"the same\" (as in, it will have the same revision) as the commit that was just sequenced, so the rebase will be a no-op.\n\t * Because the rebase is a no-op, we can skip it entirely and simply remove the commit from the local branch and append it to the trunk.\n\t * Avoiding the overhead of the rebase process, even when it's a no-op, has real measured performance benefits and is worth the added complexity here.\n\t */\n\tprivate fastForwardNextLocalCommit(sequenceId: SequenceId): void {\n\t\t// First, push the local commit to the trunk.\n\t\t// We are mutating our `localCommits` cache here, but there is no need to actually change the `localBranch` itself because it will simply catch up later if/when it next rebases.\n\t\tconst firstLocalCommit = this.localCommits.shift();\n\t\tassert(\n\t\t\tfirstLocalCommit !== undefined,\n\t\t\t0x6b5 /* Received a sequenced change from the local session despite having no local changes */,\n\t\t);\n\n\t\tconst previousSequenceId = this.getCommitSequenceId(this.trunk.getHead());\n\t\tthis.pushGraphCommitToTrunk(sequenceId, firstLocalCommit, this.localSessionId);\n\n\t\t// Next, we need to update the sequence IDs that our local branches (user's branches, not peer branches) are associated with.\n\t\t// In particular, if a local branch is based on the previous trunk head (the branch's first ancestor in the trunk is the commit that was the head before we pushed the new commit)\n\t\t// and also branches off of the local branch (it has an ancestor that is part of the local branch), it needs to have its sequence number advanced to be that of the new trunk head.\n\t\t// Intuitively, this makes sense because:\n\t\t// 1. The trunk's head just advanced forward by some (sequence) amount.\n\t\t// 2. The local branch is always rebased to be branching off of the head of the trunk (not literally in this case, because of the optimization, but in effect).\n\t\t// 3. Therefore, the entire local branch just advanced forward by some (sequence) amount, and any commits downstream of it which track the sequence numbers of their base commits on the trunk should also advance.\n\t\t// This update is not necessarily required for all local branches, since some may have fallen behind the local branch and are based on older trunk commits (such branches do not need updating).\n\t\tconst currentBranches = this.trunkBranches.get(previousSequenceId);\n\t\tif (currentBranches !== undefined) {\n\t\t\tconst newBranches = getOrCreate(this.trunkBranches, sequenceId, () => new Set());\n\t\t\tfor (const branch of currentBranches) {\n\t\t\t\t// Check every branch associated with the old sequence ID and advance it if it is based on the local branch (specifically, on the local branch as it was before we pushed its first commit to the trunk).\n\t\t\t\t// We validate this by checking if the branch's head is a descendant of the local commit that we just pushed.\n\t\t\t\tif (findAncestor(branch.getHead(), (c) => c === firstLocalCommit) !== undefined) {\n\t\t\t\t\tnewBranches.add(branch);\n\t\t\t\t\tcurrentBranches.delete(branch);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Clean up our trunk branches map by removing any empty sets.\n\t\t\tif (currentBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(previousSequenceId);\n\t\t\t}\n\t\t\tif (newBranches.size === 0) {\n\t\t\t\tthis.trunkBranches.delete(sequenceId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return the sequence number at which the given commit was sequenced on the trunk, or undefined if the commit is not part of the trunk.\n\t */\n\tpublic getSequenceNumber(trunkCommit: GraphCommit<TChangeset>): SeqNumber | undefined {\n\t\treturn this.trunkMetadata.get(trunkCommit.revision)?.sequenceId.sequenceNumber;\n\t}\n\n\t/**\n\t * Advances the minimum sequence number, and removes all commits from the trunk which lie outside the collaboration window,\n\t * if they are not retained by revertibles or local branches.\n\t * @param minimumSequenceNumber - the sequence number of the newest commit that all peers (including this one) have received and applied to their trunks.\n\t *\n\t * @remarks If there are more than one commit with the same sequence number we assume this refers to the last commit in the batch.\n\t */\n\tpublic advanceMinimumSequenceNumber(\n\t\tminimumSequenceNumber: SeqNumber,\n\t\ttrimTrunk = true,\n\t): void {\n\t\tif (minimumSequenceNumber === this.minimumSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\tminimumSequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x476 /* number must be larger or equal to current minimumSequenceNumber. */,\n\t\t);\n\n\t\tthis.minimumSequenceNumber = minimumSequenceNumber;\n\t\tif (trimTrunk) {\n\t\t\tthis.trimTrunk();\n\t\t}\n\t}\n\n\t/**\n\t * Examines the latest known minimum sequence number and the trunk bases of any registered branches to determine\n\t * if any commits on the trunk are unreferenced and unneeded for future computation; those found are evicted from the trunk.\n\t */\n\tprivate trimTrunk(): void {\n\t\t/** The sequence id of the most recent commit on the trunk that will be trimmed */\n\t\tlet trunkTailSequenceId: SequenceId = {\n\t\t\tsequenceNumber: this.minimumSequenceNumber,\n\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t};\n\t\t// If there are any outstanding registered branches, get the one that is the oldest (has the \"most behind\" trunk base)\n\t\tconst minimumBranchBaseSequenceId = this.trunkBranches.minKey();\n\t\tif (minimumBranchBaseSequenceId !== undefined) {\n\t\t\t// If that branch is behind the minimum sequence id, we only want to evict commits older than it,\n\t\t\t// even if those commits are behind the minimum sequence id\n\t\t\tconst sequenceIdBeforeMinimumBranchBase = decrementSequenceId(\n\t\t\t\tminimumBranchBaseSequenceId,\n\t\t\t);\n\t\t\ttrunkTailSequenceId = minSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tsequenceIdBeforeMinimumBranchBase,\n\t\t\t);\n\t\t}\n\n\t\tconst [sequenceId, latestEvicted] = this.getClosestTrunkCommit(\n\t\t\tmaxSequenceId(\n\t\t\t\ttrunkTailSequenceId,\n\t\t\t\tthis.sequenceMap.minKey() ?? minimumPossibleSequenceId,\n\t\t\t),\n\t\t);\n\n\t\t// Don't do any work if the commit found by the search is already the tail of the trunk\n\t\tif (latestEvicted !== this.trunkBase) {\n\t\t\t// The minimum sequence number informs us that all peer branches are at least caught up to the tail commit,\n\t\t\t// so rebase them accordingly. This is necessary to prevent peer branches from referencing any evicted commits.\n\t\t\tfor (const [, branch] of this.peerLocalBranches) {\n\t\t\t\tbranch.rebaseOnto(this.trunk, latestEvicted);\n\t\t\t}\n\n\t\t\t// This mutation is a performance hack. If commits are truly immutable, then changing the trunk's tail requires\n\t\t\t// regenerating the entire commit graph. Instead, we can simply chop off the tail like this if we're certain\n\t\t\t// that there are no outstanding references to any of the commits being removed (other than the references via\n\t\t\t// the trunk). The peer branches have been rebased to the head of the trunk, the local branch is already rebased\n\t\t\t// to the head of the trunk, and all other branches are tracked by `trunkBranches` and known to be ahead of or at\n\t\t\t// `newTrunkBase`. Therefore, no branches should have unique references to any of the commits being evicted here.\n\t\t\t// We mutate the most recent of the evicted commits to become the new trunk base. That way, any other commits that\n\t\t\t// have parent pointers to the latest evicted commit will stay linked, even though that it is no longer part of the trunk.\n\t\t\tconst newTrunkBase = latestEvicted as Mutable<typeof latestEvicted>;\n\t\t\t// The metadata for new trunk base revision needs to be deleted before modifying it.\n\t\t\tthis.trunkMetadata.delete(newTrunkBase.revision);\n\t\t\t// collect the revisions that will be trimmed to send as part of the branch trimmed event\n\t\t\tconst trimmedRevisions: RevisionTag[] = getPathFromBase(\n\t\t\t\tnewTrunkBase,\n\t\t\t\tthis.trunkBase,\n\t\t\t).map((c) => c.revision);\n\t\t\t// Dropping the parent field removes (transitively) all references to the evicted commits so they can be garbage collected.\n\t\t\tdelete newTrunkBase.parent;\n\t\t\tthis.trunkBase = newTrunkBase;\n\n\t\t\t// Update any state that is derived from trunk commits\n\t\t\tthis.sequenceMap.editRange(minimumPossibleSequenceId, sequenceId, true, (s, commit) => {\n\t\t\t\t// Cleanup look-aside data for each evicted commit\n\t\t\t\tthis.trunkMetadata.delete(commit.revision);\n\t\t\t\t// Delete all evicted commits from `sequenceMap` except for the latest one, which is the new `trunkBase`\n\t\t\t\tif (equalSequenceIds(s, sequenceId)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tcommit === newTrunkBase,\n\t\t\t\t\t\t0x729 /* Expected last evicted commit to be new trunk base */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tReflect.defineProperty(commit, \"change\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5e /* Should not access 'change' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"revision\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa5f /* Should not access 'revision' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tReflect.defineProperty(commit, \"parent\", {\n\t\t\t\t\t\tget: () =>\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t0xa60 /* Should not access 'parent' property of an evicted commit */,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\treturn { delete: true };\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst trunkSize = getPathFromBase(this.trunk.getHead(), this.trunkBase).length;\n\t\t\tassert(\n\t\t\t\tthis.sequenceMap.size === trunkSize + 1,\n\t\t\t\t0x744 /* The size of the sequenceMap must have one element more than the trunk */,\n\t\t\t);\n\t\t\tassert(\n\t\t\t\tthis.trunkMetadata.size === trunkSize,\n\t\t\t\t0x745 /* The size of the trunkMetadata must be the same as the trunk */,\n\t\t\t);\n\n\t\t\tthis._events.emit(\"ancestryTrimmed\", trimmedRevisions);\n\t\t}\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn (\n\t\t\tthis.trunk.getHead() === this.trunkBase &&\n\t\t\tthis.peerLocalBranches.size === 0 &&\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead() &&\n\t\t\tthis.minimumSequenceNumber === minimumPossibleSequenceNumber\n\t\t);\n\t}\n\n\tpublic getSummaryData(): SummaryData<TChangeset> {\n\t\t// The assert below is acceptable at present because summarization only ever occurs on a client with no\n\t\t// local/in-flight changes.\n\t\t// In the future we may wish to relax this constraint. For that to work, the current implementation of\n\t\t// `EditManager` would have to be amended in one of two ways:\n\t\t// A) Changes made by the local session should be represented by a branch in `EditManager.branches`.\n\t\t// B) The contents of such a branch should be computed on demand based on the trunk.\n\t\t// Note that option (A) would be a simple change to `addSequencedChange` whereas (B) would likely require\n\t\t// rebasing trunk changes over the inverse of trunk changes.\n\t\tassert(\n\t\t\tthis.localBranch.getHead() === this.trunk.getHead(),\n\t\t\t0x428 /* Clients with local changes cannot be used to generate summaries */,\n\t\t);\n\n\t\t// Trimming the trunk before serializing ensures that the trunk data in the summary is as minimal as possible.\n\t\tthis.trimTrunk();\n\n\t\tlet oldestCommitInCollabWindow = this.getClosestTrunkCommit(this.minimumSequenceNumber)[1];\n\t\tassert(\n\t\t\toldestCommitInCollabWindow.parent !== undefined ||\n\t\t\t\toldestCommitInCollabWindow === this.trunkBase,\n\t\t\t0x8c7 /* Expected oldest commit in collab window to have a parent or be the trunk base */,\n\t\t);\n\n\t\t// Path construction is exclusive, so we need to use the parent of the oldest commit in the window if it exists\n\t\toldestCommitInCollabWindow =\n\t\t\toldestCommitInCollabWindow.parent ?? oldestCommitInCollabWindow;\n\n\t\tconst trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map(\n\t\t\t(c) => {\n\t\t\t\tassert(\n\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t0xa61 /* Serialized trunk should not include the trunk base */,\n\t\t\t\t);\n\t\t\t\tconst metadata =\n\t\t\t\t\tthis.trunkMetadata.get(c.revision) ?? fail(\"Expected metadata for trunk commit\");\n\t\t\t\tconst commit: SequencedCommit<TChangeset> = {\n\t\t\t\t\tchange: c.change,\n\t\t\t\t\trevision: c.revision,\n\t\t\t\t\tsequenceNumber: metadata.sequenceId.sequenceNumber,\n\t\t\t\t\tsessionId: metadata.sessionId,\n\t\t\t\t};\n\t\t\t\tif (metadata.sequenceId.indexInBatch !== undefined) {\n\t\t\t\t\tcommit.indexInBatch = metadata.sequenceId.indexInBatch;\n\t\t\t\t}\n\t\t\t\treturn commit;\n\t\t\t},\n\t\t);\n\n\t\tconst peerLocalBranches = new Map<SessionId, SummarySessionBranch<TChangeset>>(\n\t\t\tmapIterable(this.peerLocalBranches.entries(), ([sessionId, branch]) => {\n\t\t\t\tconst branchPath: GraphCommit<TChangeset>[] = [];\n\t\t\t\tconst ancestor =\n\t\t\t\t\tfindCommonAncestor([branch.getHead(), branchPath], this.trunk.getHead()) ??\n\t\t\t\t\tfail(\"Expected branch to be based on trunk\");\n\n\t\t\t\tconst base = ancestor === this.trunkBase ? rootRevision : ancestor.revision;\n\t\t\t\treturn [\n\t\t\t\t\tsessionId,\n\t\t\t\t\t{\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tcommits: branchPath.map((c) => {\n\t\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\t\tc !== this.trunkBase,\n\t\t\t\t\t\t\t\t0xa62 /* Serialized branch should not include the trunk base */,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst commit: Commit<TChangeset> = {\n\t\t\t\t\t\t\t\tchange: c.change,\n\t\t\t\t\t\t\t\trevision: c.revision,\n\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn commit;\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t\t);\n\n\t\treturn { trunk, peerLocalBranches };\n\t}\n\n\tpublic loadSummaryData(data: SummaryData<TChangeset>): void {\n\t\tassert(\n\t\t\tthis.isEmpty(),\n\t\t\t0x68a /* Attempted to load from summary after edit manager was already mutated */,\n\t\t);\n\t\t// Record the tags of each trunk commit as we generate the trunk so they can be looked up quickly\n\t\t// when hydrating the peer branches below\n\t\tconst trunkRevisionCache = new Map<RevisionTag, GraphCommit<TChangeset>>();\n\t\ttrunkRevisionCache.set(this.trunkBase.revision, this.trunkBase);\n\t\tthis.trunk.setHead(\n\t\t\tdata.trunk.reduce((base, c) => {\n\t\t\t\tconst sequenceId: SequenceId =\n\t\t\t\t\tc.indexInBatch === undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsequenceNumber: c.sequenceNumber,\n\t\t\t\t\t\t\t\tindexInBatch: c.indexInBatch,\n\t\t\t\t\t\t\t};\n\t\t\t\tconst commit = mintCommit(base, c);\n\t\t\t\tthis.sequenceMap.set(sequenceId, commit);\n\t\t\t\tthis.trunkMetadata.set(c.revision, {\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tsessionId: c.sessionId,\n\t\t\t\t});\n\t\t\t\ttrunkRevisionCache.set(c.revision, commit);\n\t\t\t\treturn commit;\n\t\t\t}, this.trunkBase),\n\t\t);\n\n\t\tthis.localBranch.setHead(this.trunk.getHead());\n\n\t\tfor (const [sessionId, branch] of data.peerLocalBranches) {\n\t\t\tconst commit =\n\t\t\t\ttrunkRevisionCache.get(branch.base) ??\n\t\t\t\tfail(\"Expected summary branch to be based off of a revision in the trunk\");\n\n\t\t\tthis.peerLocalBranches.set(\n\t\t\t\tsessionId,\n\t\t\t\tnew SharedTreeBranch(\n\t\t\t\t\tbranch.commits.reduce(mintCommit, commit),\n\t\t\t\t\tthis.changeFamily,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate getCommitSequenceId(trunkCommitOrTrunkBase: GraphCommit<TChangeset>): SequenceId {\n\t\tconst id = this.trunkMetadata.get(trunkCommitOrTrunkBase.revision)?.sequenceId;\n\t\tif (id === undefined) {\n\t\t\tassert(\n\t\t\t\ttrunkCommitOrTrunkBase === this.trunkBase,\n\t\t\t\t0xa63 /* Commit must be either be on the trunk or be the trunk base */,\n\t\t\t);\n\t\t\treturn minimumPossibleSequenceId;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic getTrunkChanges(): readonly TChangeset[] {\n\t\treturn this.getTrunkCommits().map((c) => c.change);\n\t}\n\n\tpublic getTrunkCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn getPathFromBase(this.trunk.getHead(), this.trunkBase);\n\t}\n\n\tpublic getTrunkHead(): GraphCommit<TChangeset> {\n\t\treturn this.trunk.getHead();\n\t}\n\n\tpublic getLocalChanges(): readonly TChangeset[] {\n\t\treturn this.getLocalCommits().map((c) => c.change);\n\t}\n\n\tpublic getLocalCommits(): readonly GraphCommit<TChangeset>[] {\n\t\treturn this.localCommits;\n\t}\n\n\t/**\n\t * @returns The length of the longest branch maintained by this EditManager.\n\t * This may be the length of a peer branch or the local branch.\n\t * The length is counted from the lowest common ancestor with the trunk such that a fully sequenced branch would\n\t * have length zero.\n\t */\n\tpublic getLongestBranchLength(): number {\n\t\tlet max = 0;\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tfor (const branch of this.peerLocalBranches.values()) {\n\t\t\tconst branchPath = getPathFromBase(branch.getHead(), trunkHead);\n\t\t\tif (branchPath.length > max) {\n\t\t\t\tmax = branchPath.length;\n\t\t\t}\n\t\t}\n\t\tconst localPath = getPathFromBase(this.localBranch.getHead(), trunkHead);\n\t\treturn Math.max(max, localPath.length);\n\t}\n\n\tpublic addSequencedChange(\n\t\tnewCommit: Commit<TChangeset>,\n\t\tsequenceNumber: SeqNumber,\n\t\treferenceSequenceNumber: SeqNumber,\n\t): void {\n\t\tassert(\n\t\t\tsequenceNumber > this.minimumSequenceNumber,\n\t\t\t0x713 /* Expected change sequence number to exceed the last known minimum sequence number */,\n\t\t);\n\n\t\tassert(\n\t\t\tsequenceNumber >= // This is \">=\", not \">\" because changes in the same batch will have the same sequence number\n\t\t\t\t(this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber),\n\t\t\t0xa64 /* Attempted to sequence change with an outdated sequence number */,\n\t\t);\n\n\t\tconst commitsSequenceNumber = this.getBatch(sequenceNumber);\n\t\tconst sequenceId: SequenceId =\n\t\t\tcommitsSequenceNumber.length === 0\n\t\t\t\t? {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tsequenceNumber,\n\t\t\t\t\t\tindexInBatch: commitsSequenceNumber.length,\n\t\t\t\t\t};\n\n\t\tif (newCommit.sessionId === this.localSessionId) {\n\t\t\treturn this.fastForwardNextLocalCommit(sequenceId);\n\t\t}\n\n\t\t// Get the revision that the remote change is based on\n\t\tconst [, baseRevisionInTrunk] = this.getClosestTrunkCommit(referenceSequenceNumber);\n\t\t// Rebase that branch over the part of the trunk up to the base revision\n\t\t// This will be a no-op if the sending client has not advanced since the last time we received an edit from it\n\t\tconst peerLocalBranch = getOrCreate(\n\t\t\tthis.peerLocalBranches,\n\t\t\tnewCommit.sessionId,\n\t\t\t() => new SharedTreeBranch(baseRevisionInTrunk, this.changeFamily, this.mintRevisionTag),\n\t\t);\n\t\tpeerLocalBranch.rebaseOnto(this.trunk, baseRevisionInTrunk);\n\n\t\tif (peerLocalBranch.getHead() === this.trunk.getHead()) {\n\t\t\t// If the branch is fully caught up and empty after being rebased, then push to the trunk directly\n\t\t\tthis.pushCommitToTrunk(sequenceId, newCommit);\n\t\t\tpeerLocalBranch.setHead(this.trunk.getHead());\n\t\t} else {\n\t\t\t// Otherwise, rebase the change over the trunk and append it, and append the original change to the peer branch.\n\t\t\tconst { duration, output: newChangeFullyRebased } = measure(() =>\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tnewCommit,\n\t\t\t\t\tpeerLocalBranch.getHead(),\n\t\t\t\t\tthis.trunk.getHead(),\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tthis.telemetryEventBatcher?.accumulateAndLog({\n\t\t\t\tduration,\n\t\t\t\t...newChangeFullyRebased.telemetryProperties,\n\t\t\t});\n\n\t\t\tpeerLocalBranch.apply(tagChange(newCommit.change, newCommit.revision));\n\t\t\tthis.pushCommitToTrunk(sequenceId, {\n\t\t\t\t...newCommit,\n\t\t\t\tchange: newChangeFullyRebased.change,\n\t\t\t});\n\t\t}\n\n\t\tthis.localBranch.rebaseOnto(this.trunk);\n\t}\n\n\tpublic findLocalCommit(\n\t\trevision: RevisionTag,\n\t): [commit: GraphCommit<TChangeset>, commitsAfter: GraphCommit<TChangeset>[]] {\n\t\tconst commits: GraphCommit<TChangeset>[] = [];\n\t\tconst commit = findAncestor(\n\t\t\t[this.localBranch.getHead(), commits],\n\t\t\t(c) => c.revision === revision,\n\t\t);\n\t\tassert(commit !== undefined, 0x599 /* Expected local branch to contain revision */);\n\t\treturn [commit, commits];\n\t}\n\n\tprivate pushCommitToTrunk(sequenceId: SequenceId, commit: Commit<TChangeset>): void {\n\t\tconst mintedCommit = mintCommit(this.trunk.getHead(), commit);\n\t\tthis.pushGraphCommitToTrunk(sequenceId, mintedCommit, commit.sessionId);\n\t}\n\n\tprivate pushGraphCommitToTrunk(\n\t\tsequenceId: SequenceId,\n\t\tgraphCommit: GraphCommit<TChangeset>,\n\t\tsessionId: SessionId,\n\t): void {\n\t\tthis.trunk.setHead(graphCommit);\n\t\tconst trunkHead = this.trunk.getHead();\n\t\tthis.sequenceMap.set(sequenceId, trunkHead);\n\t\tthis.trunkMetadata.set(trunkHead.revision, { sequenceId, sessionId });\n\t}\n\n\t/**\n\t * Finds the most recent trunk commit that was sequenced at or before the given point.\n\t * @param searchBy - the sequence number or the sequence id to search for\n\t * @remarks Fails if there is no eligible commit.\n\t * @returns the closest commit and its sequence id\n\t */\n\tprivate getClosestTrunkCommit(searchBy: SeqNumber): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(searchBy: SequenceId): [SequenceId, GraphCommit<TChangeset>];\n\tprivate getClosestTrunkCommit(\n\t\tsearchBy: SeqNumber | SequenceId,\n\t): [SequenceId, GraphCommit<TChangeset>] {\n\t\tconst sequenceId: SequenceId =\n\t\t\ttypeof searchBy === \"number\"\n\t\t\t\t? {\n\t\t\t\t\t\t// This is to make sure that the correct commit is selected in this 2 scenarios:\n\t\t\t\t\t\t// 1) The commit is unique for that sequence number\n\t\t\t\t\t\t// 2) There are more than one commit for the same sequence number, in this case we need to select the last one.\n\t\t\t\t\t\tsequenceNumber: searchBy,\n\t\t\t\t\t\tindexInBatch: Number.POSITIVE_INFINITY,\n\t\t\t\t\t}\n\t\t\t\t: searchBy;\n\n\t\tconst commit = this.sequenceMap.getPairOrNextLower(sequenceId);\n\t\tassert(commit !== undefined, 0x746 /* sequence id has been evicted */);\n\t\treturn commit;\n\t}\n\n\tprivate getBatch(sequenceNumber: SeqNumber): [SequenceId, GraphCommit<TChangeset>][] {\n\t\tconst startSequenceId: SequenceId = {\n\t\t\tsequenceNumber,\n\t\t};\n\t\tconst endSequenceId: SequenceId = {\n\t\t\tsequenceNumber: brand((sequenceNumber as number) + 1),\n\t\t};\n\n\t\treturn this.sequenceMap.getRange(startSequenceId, endSequenceId, false);\n\t}\n}\n\n/**\n * The in-memory data that summaries contain\n */\nexport interface SummaryData<TChangeset> {\n\treadonly trunk: readonly SequencedCommit<TChangeset>[];\n\treadonly peerLocalBranches: ReadonlyMap<SessionId, SummarySessionBranch<TChangeset>>;\n}\n\n/**\n * @returns the path from the base of a branch to its head\n */\nfunction getPathFromBase<TCommit extends { parent?: TCommit }>(\n\tbranchHead: TCommit,\n\tbaseBranchHead: TCommit,\n): TCommit[] {\n\tconst path: TCommit[] = [];\n\tassert(\n\t\tfindCommonAncestor([branchHead, path], baseBranchHead) !== undefined,\n\t\t0x573 /* Expected branches to be related */,\n\t);\n\treturn path;\n}\n"]}
@@ -2,12 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { onForkTransitive, SharedTreeBranch, type SharedTreeBranchChange, type SharedTreeBranchEvents, getChangeReplaceType, } from "./branch.js";
6
- export { type ExplicitCoreCodecVersions, SharedTreeCore, type Summarizable, type SummaryElementParser, type SummaryElementStringifier, } from "./sharedTreeCore.js";
5
+ export { onForkTransitive, SharedTreeBranch, type SharedTreeBranchChange, type SharedTreeBranchEvents, } from "./branch.js";
6
+ export { TransactionResult, type Transactor, type TransactionEvents, TransactionStack, SquashingTransactionStack, type OnPush, type OnPop, } from "./transaction.js";
7
+ export { type ExplicitCoreCodecVersions, SharedTreeCore, type Summarizable, type SummaryElementParser, type SummaryElementStringifier, type ClonableSchemaAndPolicy, } from "./sharedTreeCore.js";
7
8
  export type { ResubmitMachine } from "./resubmitMachine.js";
8
9
  export { DefaultResubmitMachine } from "./defaultResubmitMachine.js";
9
10
  export { type ChangeEnricherReadonlyCheckout, type ChangeEnricherMutableCheckout, NoOpChangeEnricher, } from "./changeEnricher.js";
10
- export { TransactionStack } from "./transactionStack.js";
11
11
  export { makeEditManagerCodec } from "./editManagerCodecs.js";
12
12
  export { EditManagerSummarizer } from "./editManagerSummarizer.js";
13
13
  export { EditManager, minimumPossibleSequenceNumber, type SummaryData, } from "./editManager.js";