@fluidframework/tree 2.1.0-276985 → 2.1.0-281041

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 (437) hide show
  1. package/.eslintrc.cjs +7 -0
  2. package/.vscode/Tree.code-workspace +7 -1
  3. package/README.md +51 -8
  4. package/api-report/tree.alpha.api.md +1 -0
  5. package/api-report/tree.beta.api.md +1 -0
  6. package/api-report/tree.public.api.md +1 -0
  7. package/beta.d.ts +1 -1
  8. package/dist/beta.d.ts +1 -1
  9. package/dist/core/forest/editableForest.d.ts +6 -3
  10. package/dist/core/forest/editableForest.d.ts.map +1 -1
  11. package/dist/core/forest/editableForest.js +14 -4
  12. package/dist/core/forest/editableForest.js.map +1 -1
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +3 -1
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/core/rebase/index.d.ts +1 -1
  18. package/dist/core/rebase/index.d.ts.map +1 -1
  19. package/dist/core/rebase/index.js +3 -1
  20. package/dist/core/rebase/index.js.map +1 -1
  21. package/dist/core/rebase/types.d.ts +2 -0
  22. package/dist/core/rebase/types.d.ts.map +1 -1
  23. package/dist/core/rebase/types.js +9 -1
  24. package/dist/core/rebase/types.js.map +1 -1
  25. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  26. package/dist/core/tree/visitDelta.js.map +1 -1
  27. package/dist/events/events.d.ts +4 -1
  28. package/dist/events/events.d.ts.map +1 -1
  29. package/dist/events/events.js.map +1 -1
  30. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
  31. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  32. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  33. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
  34. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  35. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
  36. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  37. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +0 -20
  38. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  39. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -38
  40. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  41. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  42. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  43. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  44. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  45. package/dist/feature-libraries/flex-tree/lazyField.d.ts +0 -4
  46. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  47. package/dist/feature-libraries/flex-tree/lazyField.js +1 -14
  48. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  49. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +0 -1
  50. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  51. package/dist/feature-libraries/flex-tree/lazyNode.js +0 -3
  52. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  53. package/dist/feature-libraries/index.d.ts +3 -3
  54. package/dist/feature-libraries/index.d.ts.map +1 -1
  55. package/dist/feature-libraries/index.js +2 -2
  56. package/dist/feature-libraries/index.js.map +1 -1
  57. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
  58. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  59. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  60. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
  61. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
  62. package/dist/feature-libraries/modular-schema/discrepancies.js +264 -0
  63. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -0
  64. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
  65. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  66. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  67. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  68. package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -0
  69. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  70. package/dist/feature-libraries/modular-schema/index.d.ts +2 -1
  71. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  72. package/dist/feature-libraries/modular-schema/index.js +3 -1
  73. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  74. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  75. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
  76. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  77. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
  78. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +830 -245
  80. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  81. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  82. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
  83. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  84. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
  85. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  86. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  87. package/dist/feature-libraries/node-key/index.d.ts +0 -1
  88. package/dist/feature-libraries/node-key/index.d.ts.map +1 -1
  89. package/dist/feature-libraries/node-key/index.js +1 -3
  90. package/dist/feature-libraries/node-key/index.js.map +1 -1
  91. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  92. package/dist/feature-libraries/optional-field/optionalField.js +1 -0
  93. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  94. package/dist/feature-libraries/sequence-field/index.d.ts +1 -1
  95. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  96. package/dist/feature-libraries/sequence-field/index.js +1 -2
  97. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  98. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  99. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  100. package/dist/feature-libraries/sequence-field/rebase.js +6 -1
  101. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  102. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  103. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -0
  104. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  105. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -17
  106. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  107. package/dist/feature-libraries/sequence-field/utils.js +31 -39
  108. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  109. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
  110. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  111. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +2 -0
  112. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/packageVersion.d.ts +1 -1
  117. package/dist/packageVersion.js +1 -1
  118. package/dist/packageVersion.js.map +1 -1
  119. package/dist/public.d.ts +1 -1
  120. package/dist/shared-tree/schematizingTreeView.d.ts +4 -2
  121. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  122. package/dist/shared-tree/schematizingTreeView.js +240 -184
  123. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  124. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  125. package/dist/shared-tree/sharedTree.js +150 -90
  126. package/dist/shared-tree/sharedTree.js.map +1 -1
  127. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  128. package/dist/shared-tree/treeCheckout.js +2 -1
  129. package/dist/shared-tree/treeCheckout.js.map +1 -1
  130. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  131. package/dist/shared-tree-core/branch.js +1 -0
  132. package/dist/shared-tree-core/branch.js.map +1 -1
  133. package/dist/shared-tree-core/sharedTreeCore.d.ts +4 -6
  134. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  135. package/dist/shared-tree-core/sharedTreeCore.js +265 -209
  136. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  137. package/dist/simple-tree/arrayNode.d.ts +4 -0
  138. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  139. package/dist/simple-tree/arrayNode.js +36 -19
  140. package/dist/simple-tree/arrayNode.js.map +1 -1
  141. package/dist/simple-tree/leafNodeSchema.d.ts +22 -1
  142. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  143. package/dist/simple-tree/leafNodeSchema.js +2 -1
  144. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  145. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  146. package/dist/simple-tree/mapNode.js.map +1 -1
  147. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  148. package/dist/simple-tree/objectNode.js +2 -1
  149. package/dist/simple-tree/objectNode.js.map +1 -1
  150. package/dist/simple-tree/proxies.d.ts.map +1 -1
  151. package/dist/simple-tree/proxies.js +2 -4
  152. package/dist/simple-tree/proxies.js.map +1 -1
  153. package/dist/simple-tree/schemaFactory.d.ts +16 -1
  154. package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
  155. package/dist/simple-tree/schemaFactory.js +32 -4
  156. package/dist/simple-tree/schemaFactory.js.map +1 -1
  157. package/dist/simple-tree/schemaTypes.d.ts +36 -1
  158. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  159. package/dist/simple-tree/schemaTypes.js.map +1 -1
  160. package/dist/simple-tree/toFlexSchema.d.ts +2 -2
  161. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  162. package/dist/simple-tree/toFlexSchema.js +3 -2
  163. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  164. package/dist/simple-tree/tree.d.ts +4 -1
  165. package/dist/simple-tree/tree.d.ts.map +1 -1
  166. package/dist/simple-tree/tree.js +48 -1
  167. package/dist/simple-tree/tree.js.map +1 -1
  168. package/dist/simple-tree/treeNodeApi.d.ts.map +1 -1
  169. package/dist/simple-tree/treeNodeApi.js +10 -10
  170. package/dist/simple-tree/treeNodeApi.js.map +1 -1
  171. package/dist/simple-tree/types.d.ts +22 -3
  172. package/dist/simple-tree/types.d.ts.map +1 -1
  173. package/dist/simple-tree/types.js +32 -21
  174. package/dist/simple-tree/types.js.map +1 -1
  175. package/dist/util/breakable.d.ts +83 -0
  176. package/dist/util/breakable.d.ts.map +1 -0
  177. package/dist/util/breakable.js +178 -0
  178. package/dist/util/breakable.js.map +1 -0
  179. package/dist/util/index.d.ts +3 -2
  180. package/dist/util/index.d.ts.map +1 -1
  181. package/dist/util/index.js +9 -2
  182. package/dist/util/index.js.map +1 -1
  183. package/dist/util/nestedMap.d.ts +17 -3
  184. package/dist/util/nestedMap.d.ts.map +1 -1
  185. package/dist/util/nestedMap.js +21 -1
  186. package/dist/util/nestedMap.js.map +1 -1
  187. package/dist/util/utils.d.ts +7 -0
  188. package/dist/util/utils.d.ts.map +1 -1
  189. package/dist/util/utils.js +15 -1
  190. package/dist/util/utils.js.map +1 -1
  191. package/internal.d.ts +1 -1
  192. package/lib/beta.d.ts +1 -1
  193. package/lib/core/forest/editableForest.d.ts +6 -3
  194. package/lib/core/forest/editableForest.d.ts.map +1 -1
  195. package/lib/core/forest/editableForest.js +15 -5
  196. package/lib/core/forest/editableForest.js.map +1 -1
  197. package/lib/core/index.d.ts +1 -1
  198. package/lib/core/index.d.ts.map +1 -1
  199. package/lib/core/index.js +1 -1
  200. package/lib/core/index.js.map +1 -1
  201. package/lib/core/rebase/index.d.ts +1 -1
  202. package/lib/core/rebase/index.d.ts.map +1 -1
  203. package/lib/core/rebase/index.js +1 -1
  204. package/lib/core/rebase/index.js.map +1 -1
  205. package/lib/core/rebase/types.d.ts +2 -0
  206. package/lib/core/rebase/types.d.ts.map +1 -1
  207. package/lib/core/rebase/types.js +7 -1
  208. package/lib/core/rebase/types.js.map +1 -1
  209. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  210. package/lib/core/tree/visitDelta.js.map +1 -1
  211. package/lib/events/events.d.ts +4 -1
  212. package/lib/events/events.d.ts.map +1 -1
  213. package/lib/events/events.js.map +1 -1
  214. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +1 -1
  215. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  216. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  217. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
  218. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  219. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
  220. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  221. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +0 -20
  222. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  223. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -38
  224. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  225. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  226. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  227. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  228. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  229. package/lib/feature-libraries/flex-tree/lazyField.d.ts +0 -4
  230. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  231. package/lib/feature-libraries/flex-tree/lazyField.js +1 -14
  232. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  233. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +0 -1
  234. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  235. package/lib/feature-libraries/flex-tree/lazyNode.js +0 -3
  236. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  237. package/lib/feature-libraries/index.d.ts +3 -3
  238. package/lib/feature-libraries/index.d.ts.map +1 -1
  239. package/lib/feature-libraries/index.js +2 -2
  240. package/lib/feature-libraries/index.js.map +1 -1
  241. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +11 -0
  242. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  243. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  244. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +96 -0
  245. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -0
  246. package/lib/feature-libraries/modular-schema/discrepancies.js +260 -0
  247. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -0
  248. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +9 -2
  249. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  250. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  251. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  252. package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -0
  253. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  254. package/lib/feature-libraries/modular-schema/index.d.ts +2 -1
  255. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  256. package/lib/feature-libraries/modular-schema/index.js +1 -0
  257. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  258. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +42 -26
  260. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  261. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +51 -2
  262. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  263. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +829 -247
  264. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  265. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  266. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +2 -0
  267. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  268. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +44 -1
  269. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  270. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  271. package/lib/feature-libraries/node-key/index.d.ts +0 -1
  272. package/lib/feature-libraries/node-key/index.d.ts.map +1 -1
  273. package/lib/feature-libraries/node-key/index.js +0 -1
  274. package/lib/feature-libraries/node-key/index.js.map +1 -1
  275. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  276. package/lib/feature-libraries/optional-field/optionalField.js +1 -0
  277. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  278. package/lib/feature-libraries/sequence-field/index.d.ts +1 -1
  279. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  280. package/lib/feature-libraries/sequence-field/index.js +1 -1
  281. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  282. package/lib/feature-libraries/sequence-field/invert.js +1 -1
  283. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  284. package/lib/feature-libraries/sequence-field/rebase.js +6 -1
  285. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  286. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  287. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -1
  288. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  289. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -17
  290. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  291. package/lib/feature-libraries/sequence-field/utils.js +31 -39
  292. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  293. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +1 -0
  294. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  295. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +4 -2
  296. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  297. package/lib/index.d.ts +1 -1
  298. package/lib/index.d.ts.map +1 -1
  299. package/lib/index.js.map +1 -1
  300. package/lib/packageVersion.d.ts +1 -1
  301. package/lib/packageVersion.js +1 -1
  302. package/lib/packageVersion.js.map +1 -1
  303. package/lib/public.d.ts +1 -1
  304. package/lib/shared-tree/schematizingTreeView.d.ts +4 -2
  305. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  306. package/lib/shared-tree/schematizingTreeView.js +242 -185
  307. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  308. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  309. package/lib/shared-tree/sharedTree.js +151 -90
  310. package/lib/shared-tree/sharedTree.js.map +1 -1
  311. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  312. package/lib/shared-tree/treeCheckout.js +2 -1
  313. package/lib/shared-tree/treeCheckout.js.map +1 -1
  314. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  315. package/lib/shared-tree-core/branch.js +1 -0
  316. package/lib/shared-tree-core/branch.js.map +1 -1
  317. package/lib/shared-tree-core/sharedTreeCore.d.ts +4 -6
  318. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  319. package/lib/shared-tree-core/sharedTreeCore.js +267 -210
  320. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  321. package/lib/simple-tree/arrayNode.d.ts +4 -0
  322. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  323. package/lib/simple-tree/arrayNode.js +38 -21
  324. package/lib/simple-tree/arrayNode.js.map +1 -1
  325. package/lib/simple-tree/leafNodeSchema.d.ts +22 -1
  326. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  327. package/lib/simple-tree/leafNodeSchema.js +1 -1
  328. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  329. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  330. package/lib/simple-tree/mapNode.js.map +1 -1
  331. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  332. package/lib/simple-tree/objectNode.js +3 -2
  333. package/lib/simple-tree/objectNode.js.map +1 -1
  334. package/lib/simple-tree/proxies.d.ts.map +1 -1
  335. package/lib/simple-tree/proxies.js +2 -4
  336. package/lib/simple-tree/proxies.js.map +1 -1
  337. package/lib/simple-tree/schemaFactory.d.ts +16 -1
  338. package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
  339. package/lib/simple-tree/schemaFactory.js +30 -3
  340. package/lib/simple-tree/schemaFactory.js.map +1 -1
  341. package/lib/simple-tree/schemaTypes.d.ts +36 -1
  342. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  343. package/lib/simple-tree/schemaTypes.js.map +1 -1
  344. package/lib/simple-tree/toFlexSchema.d.ts +2 -2
  345. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  346. package/lib/simple-tree/toFlexSchema.js +3 -2
  347. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  348. package/lib/simple-tree/tree.d.ts +4 -1
  349. package/lib/simple-tree/tree.d.ts.map +1 -1
  350. package/lib/simple-tree/tree.js +44 -0
  351. package/lib/simple-tree/tree.js.map +1 -1
  352. package/lib/simple-tree/treeNodeApi.d.ts.map +1 -1
  353. package/lib/simple-tree/treeNodeApi.js +11 -11
  354. package/lib/simple-tree/treeNodeApi.js.map +1 -1
  355. package/lib/simple-tree/types.d.ts +22 -3
  356. package/lib/simple-tree/types.d.ts.map +1 -1
  357. package/lib/simple-tree/types.js +32 -21
  358. package/lib/simple-tree/types.js.map +1 -1
  359. package/lib/util/breakable.d.ts +83 -0
  360. package/lib/util/breakable.d.ts.map +1 -0
  361. package/lib/util/breakable.js +171 -0
  362. package/lib/util/breakable.js.map +1 -0
  363. package/lib/util/index.d.ts +3 -2
  364. package/lib/util/index.d.ts.map +1 -1
  365. package/lib/util/index.js +3 -2
  366. package/lib/util/index.js.map +1 -1
  367. package/lib/util/nestedMap.d.ts +17 -3
  368. package/lib/util/nestedMap.d.ts.map +1 -1
  369. package/lib/util/nestedMap.js +19 -0
  370. package/lib/util/nestedMap.js.map +1 -1
  371. package/lib/util/utils.d.ts +7 -0
  372. package/lib/util/utils.d.ts.map +1 -1
  373. package/lib/util/utils.js +13 -0
  374. package/lib/util/utils.js.map +1 -1
  375. package/package.json +29 -27
  376. package/src/core/forest/editableForest.ts +17 -4
  377. package/src/core/index.ts +2 -0
  378. package/src/core/rebase/index.ts +2 -0
  379. package/src/core/rebase/types.ts +17 -0
  380. package/src/core/tree/visitDelta.ts +1 -0
  381. package/src/events/events.ts +4 -2
  382. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +1 -1
  383. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
  384. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +0 -30
  385. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -43
  386. package/src/feature-libraries/flex-tree/index.ts +0 -1
  387. package/src/feature-libraries/flex-tree/lazyField.ts +1 -21
  388. package/src/feature-libraries/flex-tree/lazyNode.ts +0 -6
  389. package/src/feature-libraries/index.ts +1 -2
  390. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +18 -0
  391. package/src/feature-libraries/modular-schema/discrepancies.ts +395 -0
  392. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +10 -2
  393. package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -0
  394. package/src/feature-libraries/modular-schema/index.ts +2 -0
  395. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +81 -35
  396. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1529 -454
  397. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +2 -0
  398. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +51 -0
  399. package/src/feature-libraries/node-key/index.ts +0 -1
  400. package/src/feature-libraries/optional-field/optionalField.ts +1 -0
  401. package/src/feature-libraries/sequence-field/index.ts +0 -2
  402. package/src/feature-libraries/sequence-field/invert.ts +1 -1
  403. package/src/feature-libraries/sequence-field/rebase.ts +7 -1
  404. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +2 -1
  405. package/src/feature-libraries/sequence-field/utils.ts +37 -85
  406. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +10 -0
  407. package/src/index.ts +0 -1
  408. package/src/packageVersion.ts +1 -1
  409. package/src/shared-tree/schematizingTreeView.ts +6 -2
  410. package/src/shared-tree/sharedTree.ts +4 -0
  411. package/src/shared-tree/treeCheckout.ts +6 -2
  412. package/src/shared-tree-core/branch.ts +1 -0
  413. package/src/shared-tree-core/sharedTreeCore.ts +18 -6
  414. package/src/simple-tree/arrayNode.ts +49 -22
  415. package/src/simple-tree/leafNodeSchema.ts +1 -1
  416. package/src/simple-tree/mapNode.ts +2 -2
  417. package/src/simple-tree/objectNode.ts +9 -3
  418. package/src/simple-tree/proxies.ts +2 -4
  419. package/src/simple-tree/schemaFactory.ts +37 -2
  420. package/src/simple-tree/schemaTypes.ts +36 -1
  421. package/src/simple-tree/toFlexSchema.ts +5 -4
  422. package/src/simple-tree/tree.ts +65 -4
  423. package/src/simple-tree/treeNodeApi.ts +15 -15
  424. package/src/simple-tree/types.ts +60 -30
  425. package/src/util/breakable.ts +214 -0
  426. package/src/util/index.ts +10 -0
  427. package/src/util/nestedMap.ts +33 -3
  428. package/src/util/utils.ts +17 -0
  429. package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
  430. package/dist/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
  431. package/dist/feature-libraries/node-key/nodeKeyIndex.js +0 -101
  432. package/dist/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
  433. package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts +0 -41
  434. package/lib/feature-libraries/node-key/nodeKeyIndex.d.ts.map +0 -1
  435. package/lib/feature-libraries/node-key/nodeKeyIndex.js +0 -97
  436. package/lib/feature-libraries/node-key/nodeKeyIndex.js.map +0 -1
  437. package/src/feature-libraries/node-key/nodeKeyIndex.ts +0 -132
@@ -3,6 +3,44 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
7
+ var useValue = arguments.length > 2;
8
+ for (var i = 0; i < initializers.length; i++) {
9
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
10
+ }
11
+ return useValue ? value : void 0;
12
+ };
13
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
14
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
15
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
16
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
17
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
18
+ var _, done = false;
19
+ for (var i = decorators.length - 1; i >= 0; i--) {
20
+ var context = {};
21
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
22
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
23
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
24
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
25
+ if (kind === "accessor") {
26
+ if (result === void 0) continue;
27
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
28
+ if (_ = accept(result.get)) descriptor.get = _;
29
+ if (_ = accept(result.set)) descriptor.set = _;
30
+ if (_ = accept(result.init)) initializers.unshift(_);
31
+ }
32
+ else if (_ = accept(result)) {
33
+ if (kind === "field") initializers.unshift(_);
34
+ else descriptor[key] = _;
35
+ }
36
+ }
37
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
38
+ done = true;
39
+ };
40
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
41
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
42
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
43
+ };
6
44
  Object.defineProperty(exports, "__esModule", { value: true });
7
45
  exports.SharedTreeFactory = exports.defaultSharedTreeOptions = exports.ForestType = exports.SharedTreeFormatVersion = exports.SharedTree = void 0;
8
46
  const internal_1 = require("@fluidframework/core-utils/internal");
@@ -17,6 +55,7 @@ const schematizingTreeView_js_1 = require("./schematizingTreeView.js");
17
55
  const sharedTreeChangeEnricher_js_1 = require("./sharedTreeChangeEnricher.js");
18
56
  const sharedTreeChangeFamily_js_1 = require("./sharedTreeChangeFamily.js");
19
57
  const treeCheckout_js_1 = require("./treeCheckout.js");
58
+ const index_js_6 = require("../util/index.js");
20
59
  const formatVersionToTopLevelCodecVersions = new Map([
21
60
  [
22
61
  1,
@@ -41,101 +80,122 @@ function getCodecVersions(formatVersion) {
41
80
  *
42
81
  * TODO: detail compatibility requirements.
43
82
  */
44
- class SharedTree extends index_js_5.SharedTreeCore {
45
- get storedSchema() {
46
- return this.checkout.storedSchema;
47
- }
48
- constructor(id, runtime, attributes, optionsParam, telemetryContextPrefix = "fluid_sharedTree_") {
49
- if (runtime.idCompressor === undefined) {
50
- throw new internal_2.UsageError("IdCompressor must be enabled to use SharedTree");
83
+ let SharedTree = (() => {
84
+ let _classDecorators = [index_js_6.breakingClass];
85
+ let _classDescriptor;
86
+ let _classExtraInitializers = [];
87
+ let _classThis;
88
+ let _classSuper = index_js_5.SharedTreeCore;
89
+ let _instanceExtraInitializers = [];
90
+ let _contentSnapshot_decorators;
91
+ var SharedTree = _classThis = class extends _classSuper {
92
+ get storedSchema() {
93
+ return this.checkout.storedSchema;
51
94
  }
52
- const options = { ...exports.defaultSharedTreeOptions, ...optionsParam };
53
- const codecVersions = getCodecVersions(options.formatVersion);
54
- const schema = new index_js_2.TreeStoredSchemaRepository();
55
- const forest = options.forest === ForestType.Optimized
56
- ? (0, index_js_4.buildChunkedForest)((0, index_js_4.makeTreeChunker)(schema, index_js_4.defaultSchemaPolicy))
57
- : (0, index_js_4.buildForest)();
58
- const revisionTagCodec = new index_js_2.RevisionTagCodec(runtime.idCompressor);
59
- const removedRoots = (0, index_js_2.makeDetachedFieldIndex)("repair", revisionTagCodec, runtime.idCompressor, options);
60
- const schemaSummarizer = new index_js_4.SchemaSummarizer(runtime, schema, options, {
61
- getCurrentSeq: () => this.deltaManager.lastSequenceNumber,
62
- });
63
- const fieldBatchCodec = (0, index_js_4.makeFieldBatchCodec)(options, codecVersions.fieldBatch);
64
- const encoderContext = {
65
- schema: {
66
- schema,
67
- policy: index_js_4.defaultSchemaPolicy,
68
- },
69
- encodeType: options.treeEncodeType,
70
- originatorId: runtime.idCompressor.localSessionId,
71
- idCompressor: runtime.idCompressor,
72
- };
73
- const forestSummarizer = new index_js_4.ForestSummarizer(forest, revisionTagCodec, fieldBatchCodec, encoderContext, options, runtime.idCompressor);
74
- const removedRootsSummarizer = new index_js_4.DetachedFieldIndexSummarizer(removedRoots);
75
- const innerChangeFamily = new sharedTreeChangeFamily_js_1.SharedTreeChangeFamily(revisionTagCodec, fieldBatchCodec, options, options.treeEncodeType);
76
- const changeFamily = (0, index_js_4.makeMitigatedChangeFamily)(innerChangeFamily, sharedTreeChangeFamily_js_1.SharedTreeChangeFamily.emptyChange, (error) => {
77
- // TODO:6344 Add telemetry for these errors.
78
- // Rethrowing the error has a different effect depending on the context in which the
79
- // ChangeFamily was invoked:
80
- // - If the ChangeFamily was invoked as part of incoming op processing, rethrowing the error
81
- // will cause the runtime to disconnect the client, log a severe error, and not reconnect.
82
- // This will not cause the host application to crash because it is not on the stack at that time.
83
- // TODO: let the host application know that the client is now disconnected.
84
- // - If the ChangeFamily was invoked as part of dealing with a local change, rethrowing the
85
- // error will cause the host application to crash. This is not ideal, but is better than
86
- // letting the application either send an invalid change to the server or allowing the
87
- // application to continue working when its local branches contain edits that cannot be
88
- // reflected in its views.
89
- // The best course of action for a host application in such a state is to restart.
90
- // TODO: let the host application know about this situation and provide a way to
91
- // programmatically reload the SharedTree container.
92
- throw error;
93
- });
94
- const changeEnricher = new sharedTreeChangeEnricher_js_1.SharedTreeReadonlyChangeEnricher(forest, schema, removedRoots);
95
- super([schemaSummarizer, forestSummarizer, removedRootsSummarizer], changeFamily, options, codecVersions, id, runtime, attributes, telemetryContextPrefix, schema, index_js_4.defaultSchemaPolicy, new index_js_5.DefaultResubmitMachine(changeFamily.rebaser.invert.bind(changeFamily.rebaser), changeEnricher), changeEnricher);
96
- this._events = (0, index_js_3.createEmitter)();
97
- const localBranch = this.getLocalBranch();
98
- this.checkout = (0, treeCheckout_js_1.createTreeCheckout)(runtime.idCompressor, this.mintRevisionTag, revisionTagCodec, {
99
- branch: localBranch,
100
- changeFamily,
101
- schema,
102
- forest,
103
- fieldBatchCodec,
104
- events: this._events,
105
- removedRoots,
106
- chunkCompressionStrategy: options.treeEncodeType,
107
- logger: this.logger,
108
- });
109
- }
110
- contentSnapshot() {
111
- const cursor = this.checkout.forest.allocateCursor("contentSnapshot");
112
- try {
113
- (0, index_js_2.moveToDetachedField)(this.checkout.forest, cursor);
114
- return {
115
- schema: this.storedSchema.clone(),
116
- tree: (0, index_js_4.jsonableTreeFromFieldCursor)(cursor),
117
- removed: this.checkout.getRemovedRoots(),
95
+ constructor(id, runtime, attributes, optionsParam, telemetryContextPrefix = "fluid_sharedTree_") {
96
+ if (runtime.idCompressor === undefined) {
97
+ throw new internal_2.UsageError("IdCompressor must be enabled to use SharedTree");
98
+ }
99
+ const options = { ...exports.defaultSharedTreeOptions, ...optionsParam };
100
+ const codecVersions = getCodecVersions(options.formatVersion);
101
+ const schema = new index_js_2.TreeStoredSchemaRepository();
102
+ const forest = options.forest === ForestType.Optimized
103
+ ? (0, index_js_4.buildChunkedForest)((0, index_js_4.makeTreeChunker)(schema, index_js_4.defaultSchemaPolicy))
104
+ : (0, index_js_4.buildForest)();
105
+ const revisionTagCodec = new index_js_2.RevisionTagCodec(runtime.idCompressor);
106
+ const removedRoots = (0, index_js_2.makeDetachedFieldIndex)("repair", revisionTagCodec, runtime.idCompressor, options);
107
+ const schemaSummarizer = new index_js_4.SchemaSummarizer(runtime, schema, options, {
108
+ getCurrentSeq: () => this.deltaManager.lastSequenceNumber,
109
+ });
110
+ const fieldBatchCodec = (0, index_js_4.makeFieldBatchCodec)(options, codecVersions.fieldBatch);
111
+ const encoderContext = {
112
+ schema: {
113
+ schema,
114
+ policy: index_js_4.defaultSchemaPolicy,
115
+ },
116
+ encodeType: options.treeEncodeType,
117
+ originatorId: runtime.idCompressor.localSessionId,
118
+ idCompressor: runtime.idCompressor,
118
119
  };
120
+ const forestSummarizer = new index_js_4.ForestSummarizer(forest, revisionTagCodec, fieldBatchCodec, encoderContext, options, runtime.idCompressor);
121
+ const removedRootsSummarizer = new index_js_4.DetachedFieldIndexSummarizer(removedRoots);
122
+ const innerChangeFamily = new sharedTreeChangeFamily_js_1.SharedTreeChangeFamily(revisionTagCodec, fieldBatchCodec, options, options.treeEncodeType);
123
+ const changeFamily = (0, index_js_4.makeMitigatedChangeFamily)(innerChangeFamily, sharedTreeChangeFamily_js_1.SharedTreeChangeFamily.emptyChange, (error) => {
124
+ // TODO:6344 Add telemetry for these errors.
125
+ // Rethrowing the error has a different effect depending on the context in which the
126
+ // ChangeFamily was invoked:
127
+ // - If the ChangeFamily was invoked as part of incoming op processing, rethrowing the error
128
+ // will cause the runtime to disconnect the client, log a severe error, and not reconnect.
129
+ // This will not cause the host application to crash because it is not on the stack at that time.
130
+ // TODO: let the host application know that the client is now disconnected.
131
+ // - If the ChangeFamily was invoked as part of dealing with a local change, rethrowing the
132
+ // error will cause the host application to crash. This is not ideal, but is better than
133
+ // letting the application either send an invalid change to the server or allowing the
134
+ // application to continue working when its local branches contain edits that cannot be
135
+ // reflected in its views.
136
+ // The best course of action for a host application in such a state is to restart.
137
+ // TODO: let the host application know about this situation and provide a way to
138
+ // programmatically reload the SharedTree container.
139
+ throw error;
140
+ });
141
+ const changeEnricher = new sharedTreeChangeEnricher_js_1.SharedTreeReadonlyChangeEnricher(forest, schema, removedRoots);
142
+ super([schemaSummarizer, forestSummarizer, removedRootsSummarizer], changeFamily, options, codecVersions, id, runtime, attributes, telemetryContextPrefix, schema, index_js_4.defaultSchemaPolicy, new index_js_5.DefaultResubmitMachine(changeFamily.rebaser.invert.bind(changeFamily.rebaser), changeEnricher), changeEnricher);
143
+ this._events = __runInitializers(this, _instanceExtraInitializers);
144
+ this._events = (0, index_js_3.createEmitter)();
145
+ const localBranch = this.getLocalBranch();
146
+ this.checkout = (0, treeCheckout_js_1.createTreeCheckout)(runtime.idCompressor, this.mintRevisionTag, revisionTagCodec, {
147
+ branch: localBranch,
148
+ changeFamily,
149
+ schema,
150
+ forest,
151
+ fieldBatchCodec,
152
+ events: this._events,
153
+ removedRoots,
154
+ chunkCompressionStrategy: options.treeEncodeType,
155
+ logger: this.logger,
156
+ });
119
157
  }
120
- finally {
121
- cursor.free();
158
+ contentSnapshot() {
159
+ const cursor = this.checkout.forest.allocateCursor("contentSnapshot");
160
+ try {
161
+ (0, index_js_2.moveToDetachedField)(this.checkout.forest, cursor);
162
+ return {
163
+ schema: this.storedSchema.clone(),
164
+ tree: (0, index_js_4.jsonableTreeFromFieldCursor)(cursor),
165
+ removed: this.checkout.getRemovedRoots(),
166
+ };
167
+ }
168
+ finally {
169
+ cursor.free();
170
+ }
122
171
  }
123
- }
124
- schematizeFlexTree(config, onDispose) {
125
- const viewSchema = new index_js_4.ViewSchema(index_js_4.defaultSchemaPolicy, {}, config.schema);
126
- if (!(0, schematizeTree_js_1.ensureSchema)(viewSchema, config.allowedSchemaModifications, this.checkout, config)) {
127
- return undefined;
172
+ schematizeFlexTree(config, onDispose) {
173
+ const viewSchema = new index_js_4.ViewSchema(index_js_4.defaultSchemaPolicy, {}, config.schema);
174
+ if (!(0, schematizeTree_js_1.ensureSchema)(viewSchema, config.allowedSchemaModifications, this.checkout, config)) {
175
+ return undefined;
176
+ }
177
+ return (0, schematizingTreeView_js_1.requireSchema)(this.checkout, viewSchema, onDispose, (0, index_js_4.createNodeKeyManager)(this.runtime.idCompressor));
128
178
  }
129
- return (0, schematizingTreeView_js_1.requireSchema)(this.checkout, viewSchema, onDispose, (0, index_js_4.createNodeKeyManager)(this.runtime.idCompressor));
130
- }
131
- viewWith(config) {
132
- return new schematizingTreeView_js_1.SchematizingSimpleTreeView(this.checkout, config, (0, index_js_4.createNodeKeyManager)(this.runtime.idCompressor));
133
- }
134
- async loadCore(services) {
135
- await super.loadCore(services);
136
- this._events.emit("afterBatch");
137
- }
138
- }
179
+ viewWith(config) {
180
+ return new schematizingTreeView_js_1.SchematizingSimpleTreeView(this.checkout, config, (0, index_js_4.createNodeKeyManager)(this.runtime.idCompressor), this.breaker);
181
+ }
182
+ async loadCore(services) {
183
+ await super.loadCore(services);
184
+ this._events.emit("afterBatch");
185
+ }
186
+ };
187
+ __setFunctionName(_classThis, "SharedTree");
188
+ (() => {
189
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
190
+ _contentSnapshot_decorators = [index_js_6.throwIfBroken];
191
+ __esDecorate(_classThis, null, _contentSnapshot_decorators, { kind: "method", name: "contentSnapshot", static: false, private: false, access: { has: obj => "contentSnapshot" in obj, get: obj => obj.contentSnapshot }, metadata: _metadata }, null, _instanceExtraInitializers);
192
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
193
+ SharedTree = _classThis = _classDescriptor.value;
194
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
195
+ __runInitializers(_classThis, _classExtraInitializers);
196
+ })();
197
+ return SharedTree = _classThis;
198
+ })();
139
199
  exports.SharedTree = SharedTree;
140
200
  /**
141
201
  * Format versions supported by SharedTree.
@@ -1 +1 @@
1
- {"version":3,"file":"sharedTree.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAS7D,uEAAsE;AAEtE,gDAAsE;AACtE,+CAO0B;AAC1B,iDAK4B;AAC5B,4DAeuC;AACvC,2DAIsC;AAOtC,2DAA8F;AAC9F,uEAAsF;AACtF,+EAAiF;AACjF,2EAAqE;AAGrE,uDAA+F;AA0E/F,MAAM,oCAAoC,GAAG,IAAI,GAAG,CAAgC;IACnF;QACC,CAAC;QACD,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;KAC1F;IACD;QACC,CAAC;QACD,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;KAC1F;IACD;QACC,CAAC;QACD,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,E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MAAM,EAAE,UAAU,CAAC,SAAS;IAC5B,cAAc,EAAE,kCAAuB,CAAC,UAAU;IAClD,aAAa,EAAE,+BAAuB,CAAC,EAAE;CACzC,CAAC;AAEF;;GAEG;AACH,MAAa,iBAAiB;IAS7B,YAAoC,UAA6B,EAAE;QAA/B,YAAO,GAAP,OAAO,CAAwB;QARnD,SAAI,GAAW,wCAAwC,CAAC;QAExD,eAAU,GAAuB;YAChD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,qBAAqB,EAAE,OAAO;YAC9B,cAAc,EAAE,OAAO;SACvB,CAAC;IAEoE,CAAC;IAEhE,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,iBAA+C;QAE/C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA3BD,8CA2BC","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 {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type ICodecOptions, noopValidator } from \"../codec/index.js\";\nimport {\n\ttype JsonableTree,\n\tRevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\tmakeDetachedFieldIndex,\n\tmoveToDetachedField,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\tDetachedFieldIndexSummarizer,\n\ttype FlexFieldSchema,\n\tForestSummarizer,\n\tSchemaSummarizer,\n\tTreeCompressionStrategy,\n\tViewSchema,\n\tbuildChunkedForest,\n\tbuildForest,\n\tcreateNodeKeyManager,\n\tdefaultSchemaPolicy,\n\tjsonableTreeFromFieldCursor,\n\tmakeFieldBatchCodec,\n\tmakeMitigatedChangeFamily,\n\tmakeTreeChunker,\n} from \"../feature-libraries/index.js\";\nimport {\n\tDefaultResubmitMachine,\n\ttype ExplicitCoreCodecVersions,\n\tSharedTreeCore,\n} from \"../shared-tree-core/index.js\";\nimport type {\n\tITree,\n\tImplicitFieldSchema,\n\tTreeViewConfiguration,\n} from \"../simple-tree/index.js\";\n\nimport { type InitializeAndSchematizeConfiguration, ensureSchema } from \"./schematizeTree.js\";\nimport { SchematizingSimpleTreeView, requireSchema } from \"./schematizingTreeView.js\";\nimport { SharedTreeReadonlyChangeEnricher } from \"./sharedTreeChangeEnricher.js\";\nimport { SharedTreeChangeFamily } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport { type CheckoutEvents, type TreeCheckout, createTreeCheckout } from \"./treeCheckout.js\";\nimport type { CheckoutFlexTreeView, FlexTreeView } from \"./treeView.js\";\n\n/**\n * Copy of data from an {@link ISharedTree} at some point in time.\n * @remarks\n * This is unrelated to Fluids concept of \"snapshots\".\n * @internal\n */\nexport interface SharedTreeContentSnapshot {\n\t/**\n\t * The schema stored in the document.\n\t *\n\t * @remarks\n\t * Edits to the schema can mutate the schema stored of the tree which took this snapshot (but this snapshot will remain the same)\n\t * This is mainly useful for debugging cases where schematize reports an incompatible view schema.\n\t */\n\treadonly schema: TreeStoredSchema;\n\t/**\n\t * All {@link TreeStatus#InDocument} content.\n\t */\n\treadonly tree: JsonableTree[];\n\t/**\n\t * All {@link TreeStatus#Removed} content.\n\t */\n\treadonly removed: [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Collaboratively editable tree distributed data-structure,\n * powered by {@link @fluidframework/shared-object-base#ISharedObject}.\n *\n * See [the README](../../README.md) for details.\n * @internal\n */\nexport interface ISharedTree extends ISharedObject, ITree {\n\t/**\n\t * Provides a copy of the current content of the tree.\n\t * This can be useful for inspecting the tree when no suitable view schema is available.\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t *\n\t * This does not include everything that is included in a tree summary, since information about how to merge future edits is omitted.\n\t */\n\tcontentSnapshot(): SharedTreeContentSnapshot;\n\n\t/**\n\t * Like {@link ITree.viewWith}, but uses the flex-tree schema system and exposes the tree as a flex-tree.\n\t *\n\t * Returned view is disposed when the stored schema becomes incompatible with the view schema.\n\t * Undefined is returned if the stored data could not be made compatible with the view schema.\n\t */\n\tschematizeFlexTree<TRoot extends FlexFieldSchema>(\n\t\tconfig: InitializeAndSchematizeConfiguration<TRoot>,\n\t\tonDispose: () => void,\n\t): FlexTreeView<TRoot> | undefined;\n}\n\n/**\n * Has an entry for each codec which writes an explicit version into its data.\n *\n * This is used to map the single API entrypoint controlling the format {@link SharedTreeOptions.formatVersion}\n * to a list of write versions that for each codec that should be used for that format.\n *\n * Note that all explicitly versioned codecs should be using the format version from the data to read encoded data.\n *\n * TODO: Plumb these write versions into forest, schema, detached field index codec creation.\n */\ninterface ExplicitCodecVersions extends ExplicitCoreCodecVersions {\n\tforest: number;\n\tschema: number;\n\tdetachedFieldIndex: number;\n\tfieldBatch: number;\n}\n\nconst formatVersionToTopLevelCodecVersions = new Map<number, ExplicitCodecVersions>([\n\t[\n\t\t1,\n\t\t{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 1, message: 1, fieldBatch: 1 },\n\t],\n\t[\n\t\t2,\n\t\t{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 2, message: 2, fieldBatch: 1 },\n\t],\n\t[\n\t\t3,\n\t\t{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 3, message: 3, fieldBatch: 1 },\n\t],\n]);\n\nfunction getCodecVersions(formatVersion: number): ExplicitCodecVersions {\n\tconst versions = formatVersionToTopLevelCodecVersions.get(formatVersion);\n\tassert(versions !== undefined, 0x90e /* Unknown format version */);\n\treturn versions;\n}\n\n/**\n * Shared tree, configured with a good set of indexes and field kinds which will maintain compatibility over time.\n *\n * TODO: detail compatibility requirements.\n */\nexport class SharedTree\n\textends SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>\n\timplements ISharedTree\n{\n\tprivate readonly _events: Listenable<CheckoutEvents> &\n\t\tIEmitter<CheckoutEvents> &\n\t\tHasListeners<CheckoutEvents>;\n\tpublic readonly checkout: TreeCheckout;\n\tpublic get storedSchema(): TreeStoredSchemaRepository {\n\t\treturn this.checkout.storedSchema;\n\t}\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\toptionsParam: SharedTreeOptions,\n\t\ttelemetryContextPrefix: string = \"fluid_sharedTree_\",\n\t) {\n\t\tif (runtime.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst options = { ...defaultSharedTreeOptions, ...optionsParam };\n\t\tconst codecVersions = getCodecVersions(options.formatVersion);\n\t\tconst schema = new TreeStoredSchemaRepository();\n\t\tconst forest =\n\t\t\toptions.forest === ForestType.Optimized\n\t\t\t\t? buildChunkedForest(makeTreeChunker(schema, defaultSchemaPolicy))\n\t\t\t\t: buildForest();\n\t\tconst revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);\n\t\tconst removedRoots = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\truntime.idCompressor,\n\t\t\toptions,\n\t\t);\n\t\tconst schemaSummarizer = new SchemaSummarizer(runtime, schema, options, {\n\t\t\tgetCurrentSeq: () => this.deltaManager.lastSequenceNumber,\n\t\t});\n\t\tconst fieldBatchCodec = makeFieldBatchCodec(options, codecVersions.fieldBatch);\n\n\t\tconst encoderContext = {\n\t\t\tschema: {\n\t\t\t\tschema,\n\t\t\t\tpolicy: defaultSchemaPolicy,\n\t\t\t},\n\t\t\tencodeType: options.treeEncodeType,\n\t\t\toriginatorId: runtime.idCompressor.localSessionId,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t};\n\t\tconst forestSummarizer = new ForestSummarizer(\n\t\t\tforest,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tencoderContext,\n\t\t\toptions,\n\t\t\truntime.idCompressor,\n\t\t);\n\t\tconst removedRootsSummarizer = new DetachedFieldIndexSummarizer(removedRoots);\n\t\tconst innerChangeFamily = new SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\toptions,\n\t\t\toptions.treeEncodeType,\n\t\t);\n\t\tconst changeFamily = makeMitigatedChangeFamily(\n\t\t\tinnerChangeFamily,\n\t\t\tSharedTreeChangeFamily.emptyChange,\n\t\t\t(error: unknown) => {\n\t\t\t\t// TODO:6344 Add telemetry for these errors.\n\t\t\t\t// Rethrowing the error has a different effect depending on the context in which the\n\t\t\t\t// ChangeFamily was invoked:\n\t\t\t\t// - If the ChangeFamily was invoked as part of incoming op processing, rethrowing the error\n\t\t\t\t// will cause the runtime to disconnect the client, log a severe error, and not reconnect.\n\t\t\t\t// This will not cause the host application to crash because it is not on the stack at that time.\n\t\t\t\t// TODO: let the host application know that the client is now disconnected.\n\t\t\t\t// - If the ChangeFamily was invoked as part of dealing with a local change, rethrowing the\n\t\t\t\t// error will cause the host application to crash. This is not ideal, but is better than\n\t\t\t\t// letting the application either send an invalid change to the server or allowing the\n\t\t\t\t// application to continue working when its local branches contain edits that cannot be\n\t\t\t\t// reflected in its views.\n\t\t\t\t// The best course of action for a host application in such a state is to restart.\n\t\t\t\t// TODO: let the host application know about this situation and provide a way to\n\t\t\t\t// programmatically reload the SharedTree container.\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tconst changeEnricher = new SharedTreeReadonlyChangeEnricher(forest, schema, removedRoots);\n\t\tsuper(\n\t\t\t[schemaSummarizer, forestSummarizer, removedRootsSummarizer],\n\t\t\tchangeFamily,\n\t\t\toptions,\n\t\t\tcodecVersions,\n\t\t\tid,\n\t\t\truntime,\n\t\t\tattributes,\n\t\t\ttelemetryContextPrefix,\n\t\t\tschema,\n\t\t\tdefaultSchemaPolicy,\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\tchangeFamily.rebaser.invert.bind(changeFamily.rebaser),\n\t\t\t\tchangeEnricher,\n\t\t\t),\n\t\t\tchangeEnricher,\n\t\t);\n\t\tthis._events = createEmitter<CheckoutEvents>();\n\t\tconst localBranch = this.getLocalBranch();\n\t\tthis.checkout = createTreeCheckout(\n\t\t\truntime.idCompressor,\n\t\t\tthis.mintRevisionTag,\n\t\t\trevisionTagCodec,\n\t\t\t{\n\t\t\t\tbranch: localBranch,\n\t\t\t\tchangeFamily,\n\t\t\t\tschema,\n\t\t\t\tforest,\n\t\t\t\tfieldBatchCodec,\n\t\t\t\tevents: this._events,\n\t\t\t\tremovedRoots,\n\t\t\t\tchunkCompressionStrategy: options.treeEncodeType,\n\t\t\t\tlogger: this.logger,\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic contentSnapshot(): SharedTreeContentSnapshot {\n\t\tconst cursor = this.checkout.forest.allocateCursor(\"contentSnapshot\");\n\t\ttry {\n\t\t\tmoveToDetachedField(this.checkout.forest, cursor);\n\t\t\treturn {\n\t\t\t\tschema: this.storedSchema.clone(),\n\t\t\t\ttree: jsonableTreeFromFieldCursor(cursor),\n\t\t\t\tremoved: this.checkout.getRemovedRoots(),\n\t\t\t};\n\t\t} finally {\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\tpublic schematizeFlexTree<TRoot extends FlexFieldSchema>(\n\t\tconfig: InitializeAndSchematizeConfiguration<TRoot>,\n\t\tonDispose: () => void,\n\t): CheckoutFlexTreeView<TRoot> | undefined {\n\t\tconst viewSchema = new ViewSchema(defaultSchemaPolicy, {}, config.schema);\n\t\tif (!ensureSchema(viewSchema, config.allowedSchemaModifications, this.checkout, config)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn requireSchema(\n\t\t\tthis.checkout,\n\t\t\tviewSchema,\n\t\t\tonDispose,\n\t\t\tcreateNodeKeyManager(this.runtime.idCompressor),\n\t\t);\n\t}\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\treturn new SchematizingSimpleTreeView(\n\t\t\tthis.checkout,\n\t\t\tconfig,\n\t\t\tcreateNodeKeyManager(this.runtime.idCompressor),\n\t\t);\n\t}\n\n\tprotected override async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tawait super.loadCore(services);\n\t\tthis._events.emit(\"afterBatch\");\n\t}\n}\n\n/**\n * Format versions supported by SharedTree.\n *\n * Each version documents a required minimum version of the \\@fluidframework/tree package.\n * @internal\n */\nexport const SharedTreeFormatVersion = {\n\t/**\n\t * Requires \\@fluidframework/tree \\>= 2.0.0.\n\t *\n\t * @deprecated - FF does not currently plan on supporting this format long-term.\n\t * Do not write production documents using this format, as they may not be loadable in the future.\n\t */\n\tv1: 1,\n\n\t/**\n\t * Requires \\@fluidframework/tree \\>= 2.0.0.\n\t */\n\tv2: 2,\n\n\t/**\n\t * Requires \\@fluidframework/tree \\>= 2.0.0.\n\t */\n\tv3: 3,\n} as const;\n\n/**\n * Format versions supported by SharedTree.\n *\n * Each version documents a required minimum version of the \\@fluidframework/tree package.\n * @internal\n * @privateRemarks\n * See packages/dds/tree/docs/main/compatibility.md for information on how to add support for a new format.\n */\nexport type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;\n\n/**\n * @internal\n */\nexport type SharedTreeOptions = Partial<ICodecOptions> &\n\tPartial<SharedTreeFormatOptions> & {\n\t\t/**\n\t\t * The {@link ForestType} indicating which forest type should be created for the SharedTree.\n\t\t */\n\t\tforest?: ForestType;\n\t};\n\n/**\n * Options for configuring the persisted format SharedTree uses.\n * @internal\n */\nexport interface SharedTreeFormatOptions {\n\t/**\n\t * See {@link TreeCompressionStrategy}.\n\t * default: TreeCompressionStrategy.Compressed\n\t */\n\ttreeEncodeType: TreeCompressionStrategy;\n\t/**\n\t * The format version SharedTree should use to persist documents.\n\t *\n\t * This option has compatibility implications for applications using SharedTree.\n\t * Each version documents a required minimum version of \\@fluidframework/tree.\n\t * If this minimum version fails to be met, the SharedTree may fail to load.\n\t * To be safe, application authors should verify that they have saturated this version\n\t * of \\@fluidframework/tree in their ecosystem before changing the format version.\n\t *\n\t * This option defaults to SharedTreeFormatVersion.v2.\n\t */\n\tformatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];\n}\n\n/**\n * Used to distinguish between different forest types.\n * @internal\n */\nexport enum ForestType {\n\t/**\n\t * The \"ObjectForest\" forest type.\n\t */\n\tReference = 0,\n\t/**\n\t * The \"ChunkedForest\" forest type.\n\t */\n\tOptimized = 1,\n}\n\nexport const defaultSharedTreeOptions: Required<SharedTreeOptions> = {\n\tjsonValidator: noopValidator,\n\tforest: ForestType.Reference,\n\ttreeEncodeType: TreeCompressionStrategy.Compressed,\n\tformatVersion: SharedTreeFormatVersion.v3,\n};\n\n/**\n * A channel factory that creates {@link ISharedTree}s.\n */\nexport class SharedTreeFactory implements IChannelFactory<ISharedTree> {\n\tpublic readonly type: string = \"https://graph.microsoft.com/types/tree\";\n\n\tpublic readonly attributes: IChannelAttributes = {\n\t\ttype: this.type,\n\t\tsnapshotFormatVersion: \"0.0.0\",\n\t\tpackageVersion: \"0.0.0\",\n\t};\n\n\tpublic constructor(private readonly options: SharedTreeOptions = {}) {}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<SharedTree> {\n\t\tconst tree = new SharedTree(id, runtime, channelAttributes, this.options);\n\t\tawait tree.load(services);\n\t\treturn tree;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedTree {\n\t\tconst tree = new SharedTree(id, runtime, this.attributes, this.options);\n\t\ttree.initializeLocal();\n\t\treturn tree;\n\t}\n}\n"]}
1
+ {"version":3,"file":"sharedTree.js","sourceRoot":"","sources":["../../src/shared-tree/sharedTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA6D;AAS7D,uEAAsE;AAEtE,gDAAsE;AACtE,+CAO0B;AAC1B,iDAK4B;AAC5B,4DAeuC;AACvC,2DAIsC;AAOtC,2DAA8F;AAC9F,uEAAsF;AACtF,+EAAiF;AACjF,2EAAqE;AAGrE,uDAA+F;AAE/F,+CAAgE;AAyEhE,MAAM,oCAAoC,GAAG,IAAI,GAAG,CAAgC;IACnF;QACC,CAAC;QACD,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;KAC1F;IACD;QACC,CAAC;QACD,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE;KAC1F;IACD;QACC,CAAC;QACD,EAAE,MAA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rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type ICodecOptions, noopValidator } from \"../codec/index.js\";\nimport {\n\ttype JsonableTree,\n\tRevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\tmakeDetachedFieldIndex,\n\tmoveToDetachedField,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\tDetachedFieldIndexSummarizer,\n\ttype FlexFieldSchema,\n\tForestSummarizer,\n\tSchemaSummarizer,\n\tTreeCompressionStrategy,\n\tViewSchema,\n\tbuildChunkedForest,\n\tbuildForest,\n\tcreateNodeKeyManager,\n\tdefaultSchemaPolicy,\n\tjsonableTreeFromFieldCursor,\n\tmakeFieldBatchCodec,\n\tmakeMitigatedChangeFamily,\n\tmakeTreeChunker,\n} from \"../feature-libraries/index.js\";\nimport {\n\tDefaultResubmitMachine,\n\ttype ExplicitCoreCodecVersions,\n\tSharedTreeCore,\n} from \"../shared-tree-core/index.js\";\nimport type {\n\tITree,\n\tImplicitFieldSchema,\n\tTreeViewConfiguration,\n} from \"../simple-tree/index.js\";\n\nimport { type InitializeAndSchematizeConfiguration, ensureSchema } from \"./schematizeTree.js\";\nimport { SchematizingSimpleTreeView, requireSchema } from \"./schematizingTreeView.js\";\nimport { SharedTreeReadonlyChangeEnricher } from \"./sharedTreeChangeEnricher.js\";\nimport { SharedTreeChangeFamily } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport { type CheckoutEvents, type TreeCheckout, createTreeCheckout } from \"./treeCheckout.js\";\nimport type { CheckoutFlexTreeView, FlexTreeView } from \"./treeView.js\";\nimport { breakingClass, throwIfBroken } from \"../util/index.js\";\n\n/**\n * Copy of data from an {@link ISharedTree} at some point in time.\n * @remarks\n * This is unrelated to Fluids concept of \"snapshots\".\n * @internal\n */\nexport interface SharedTreeContentSnapshot {\n\t/**\n\t * The schema stored in the document.\n\t *\n\t * @remarks\n\t * Edits to the schema can mutate the schema stored of the tree which took this snapshot (but this snapshot will remain the same)\n\t * This is mainly useful for debugging cases where schematize reports an incompatible view schema.\n\t */\n\treadonly schema: TreeStoredSchema;\n\t/**\n\t * All {@link TreeStatus#InDocument} content.\n\t */\n\treadonly tree: JsonableTree[];\n\t/**\n\t * All {@link TreeStatus#Removed} content.\n\t */\n\treadonly removed: [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Collaboratively editable tree distributed data-structure,\n * powered by {@link @fluidframework/shared-object-base#ISharedObject}.\n *\n * See [the README](../../README.md) for details.\n * @internal\n */\nexport interface ISharedTree extends ISharedObject, ITree {\n\t/**\n\t * Provides a copy of the current content of the tree.\n\t * This can be useful for inspecting the tree when no suitable view schema is available.\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t *\n\t * This does not include everything that is included in a tree summary, since information about how to merge future edits is omitted.\n\t */\n\tcontentSnapshot(): SharedTreeContentSnapshot;\n\n\t/**\n\t * Like {@link ITree.viewWith}, but uses the flex-tree schema system and exposes the tree as a flex-tree.\n\t *\n\t * Returned view is disposed when the stored schema becomes incompatible with the view schema.\n\t * Undefined is returned if the stored data could not be made compatible with the view schema.\n\t */\n\tschematizeFlexTree<TRoot extends FlexFieldSchema>(\n\t\tconfig: InitializeAndSchematizeConfiguration<TRoot>,\n\t\tonDispose: () => void,\n\t): FlexTreeView<TRoot> | undefined;\n}\n\n/**\n * Has an entry for each codec which writes an explicit version into its data.\n *\n * This is used to map the single API entrypoint controlling the format {@link SharedTreeOptions.formatVersion}\n * to a list of write versions that for each codec that should be used for that format.\n *\n * Note that all explicitly versioned codecs should be using the format version from the data to read encoded data.\n *\n * TODO: Plumb these write versions into forest, schema, detached field index codec creation.\n */\ninterface ExplicitCodecVersions extends ExplicitCoreCodecVersions {\n\tforest: number;\n\tschema: number;\n\tdetachedFieldIndex: number;\n\tfieldBatch: number;\n}\n\nconst formatVersionToTopLevelCodecVersions = new Map<number, ExplicitCodecVersions>([\n\t[\n\t\t1,\n\t\t{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 1, message: 1, fieldBatch: 1 },\n\t],\n\t[\n\t\t2,\n\t\t{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 2, message: 2, fieldBatch: 1 },\n\t],\n\t[\n\t\t3,\n\t\t{ forest: 1, schema: 1, detachedFieldIndex: 1, editManager: 3, message: 3, fieldBatch: 1 },\n\t],\n]);\n\nfunction getCodecVersions(formatVersion: number): ExplicitCodecVersions {\n\tconst versions = formatVersionToTopLevelCodecVersions.get(formatVersion);\n\tassert(versions !== undefined, 0x90e /* Unknown format version */);\n\treturn versions;\n}\n\n/**\n * Shared tree, configured with a good set of indexes and field kinds which will maintain compatibility over time.\n *\n * TODO: detail compatibility requirements.\n */\n@breakingClass\nexport class SharedTree\n\textends SharedTreeCore<SharedTreeEditBuilder, SharedTreeChange>\n\timplements ISharedTree\n{\n\tprivate readonly _events: Listenable<CheckoutEvents> &\n\t\tIEmitter<CheckoutEvents> &\n\t\tHasListeners<CheckoutEvents>;\n\tpublic readonly checkout: TreeCheckout;\n\tpublic get storedSchema(): TreeStoredSchemaRepository {\n\t\treturn this.checkout.storedSchema;\n\t}\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\toptionsParam: SharedTreeOptions,\n\t\ttelemetryContextPrefix: string = \"fluid_sharedTree_\",\n\t) {\n\t\tif (runtime.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst options = { ...defaultSharedTreeOptions, ...optionsParam };\n\t\tconst codecVersions = getCodecVersions(options.formatVersion);\n\t\tconst schema = new TreeStoredSchemaRepository();\n\t\tconst forest =\n\t\t\toptions.forest === ForestType.Optimized\n\t\t\t\t? buildChunkedForest(makeTreeChunker(schema, defaultSchemaPolicy))\n\t\t\t\t: buildForest();\n\t\tconst revisionTagCodec = new RevisionTagCodec(runtime.idCompressor);\n\t\tconst removedRoots = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\truntime.idCompressor,\n\t\t\toptions,\n\t\t);\n\t\tconst schemaSummarizer = new SchemaSummarizer(runtime, schema, options, {\n\t\t\tgetCurrentSeq: () => this.deltaManager.lastSequenceNumber,\n\t\t});\n\t\tconst fieldBatchCodec = makeFieldBatchCodec(options, codecVersions.fieldBatch);\n\n\t\tconst encoderContext = {\n\t\t\tschema: {\n\t\t\t\tschema,\n\t\t\t\tpolicy: defaultSchemaPolicy,\n\t\t\t},\n\t\t\tencodeType: options.treeEncodeType,\n\t\t\toriginatorId: runtime.idCompressor.localSessionId,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t};\n\t\tconst forestSummarizer = new ForestSummarizer(\n\t\t\tforest,\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\tencoderContext,\n\t\t\toptions,\n\t\t\truntime.idCompressor,\n\t\t);\n\t\tconst removedRootsSummarizer = new DetachedFieldIndexSummarizer(removedRoots);\n\t\tconst innerChangeFamily = new SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\tfieldBatchCodec,\n\t\t\toptions,\n\t\t\toptions.treeEncodeType,\n\t\t);\n\t\tconst changeFamily = makeMitigatedChangeFamily(\n\t\t\tinnerChangeFamily,\n\t\t\tSharedTreeChangeFamily.emptyChange,\n\t\t\t(error: unknown) => {\n\t\t\t\t// TODO:6344 Add telemetry for these errors.\n\t\t\t\t// Rethrowing the error has a different effect depending on the context in which the\n\t\t\t\t// ChangeFamily was invoked:\n\t\t\t\t// - If the ChangeFamily was invoked as part of incoming op processing, rethrowing the error\n\t\t\t\t// will cause the runtime to disconnect the client, log a severe error, and not reconnect.\n\t\t\t\t// This will not cause the host application to crash because it is not on the stack at that time.\n\t\t\t\t// TODO: let the host application know that the client is now disconnected.\n\t\t\t\t// - If the ChangeFamily was invoked as part of dealing with a local change, rethrowing the\n\t\t\t\t// error will cause the host application to crash. This is not ideal, but is better than\n\t\t\t\t// letting the application either send an invalid change to the server or allowing the\n\t\t\t\t// application to continue working when its local branches contain edits that cannot be\n\t\t\t\t// reflected in its views.\n\t\t\t\t// The best course of action for a host application in such a state is to restart.\n\t\t\t\t// TODO: let the host application know about this situation and provide a way to\n\t\t\t\t// programmatically reload the SharedTree container.\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tconst changeEnricher = new SharedTreeReadonlyChangeEnricher(forest, schema, removedRoots);\n\t\tsuper(\n\t\t\t[schemaSummarizer, forestSummarizer, removedRootsSummarizer],\n\t\t\tchangeFamily,\n\t\t\toptions,\n\t\t\tcodecVersions,\n\t\t\tid,\n\t\t\truntime,\n\t\t\tattributes,\n\t\t\ttelemetryContextPrefix,\n\t\t\tschema,\n\t\t\tdefaultSchemaPolicy,\n\t\t\tnew DefaultResubmitMachine(\n\t\t\t\tchangeFamily.rebaser.invert.bind(changeFamily.rebaser),\n\t\t\t\tchangeEnricher,\n\t\t\t),\n\t\t\tchangeEnricher,\n\t\t);\n\t\tthis._events = createEmitter<CheckoutEvents>();\n\t\tconst localBranch = this.getLocalBranch();\n\t\tthis.checkout = createTreeCheckout(\n\t\t\truntime.idCompressor,\n\t\t\tthis.mintRevisionTag,\n\t\t\trevisionTagCodec,\n\t\t\t{\n\t\t\t\tbranch: localBranch,\n\t\t\t\tchangeFamily,\n\t\t\t\tschema,\n\t\t\t\tforest,\n\t\t\t\tfieldBatchCodec,\n\t\t\t\tevents: this._events,\n\t\t\t\tremovedRoots,\n\t\t\t\tchunkCompressionStrategy: options.treeEncodeType,\n\t\t\t\tlogger: this.logger,\n\t\t\t},\n\t\t);\n\t}\n\n\t@throwIfBroken\n\tpublic contentSnapshot(): SharedTreeContentSnapshot {\n\t\tconst cursor = this.checkout.forest.allocateCursor(\"contentSnapshot\");\n\t\ttry {\n\t\t\tmoveToDetachedField(this.checkout.forest, cursor);\n\t\t\treturn {\n\t\t\t\tschema: this.storedSchema.clone(),\n\t\t\t\ttree: jsonableTreeFromFieldCursor(cursor),\n\t\t\t\tremoved: this.checkout.getRemovedRoots(),\n\t\t\t};\n\t\t} finally {\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\tpublic schematizeFlexTree<TRoot extends FlexFieldSchema>(\n\t\tconfig: InitializeAndSchematizeConfiguration<TRoot>,\n\t\tonDispose: () => void,\n\t): CheckoutFlexTreeView<TRoot> | undefined {\n\t\tconst viewSchema = new ViewSchema(defaultSchemaPolicy, {}, config.schema);\n\t\tif (!ensureSchema(viewSchema, config.allowedSchemaModifications, this.checkout, config)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn requireSchema(\n\t\t\tthis.checkout,\n\t\t\tviewSchema,\n\t\t\tonDispose,\n\t\t\tcreateNodeKeyManager(this.runtime.idCompressor),\n\t\t);\n\t}\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\treturn new SchematizingSimpleTreeView(\n\t\t\tthis.checkout,\n\t\t\tconfig,\n\t\t\tcreateNodeKeyManager(this.runtime.idCompressor),\n\t\t\tthis.breaker,\n\t\t);\n\t}\n\n\tprotected override async loadCore(services: IChannelStorageService): Promise<void> {\n\t\tawait super.loadCore(services);\n\t\tthis._events.emit(\"afterBatch\");\n\t}\n}\n\n/**\n * Format versions supported by SharedTree.\n *\n * Each version documents a required minimum version of the \\@fluidframework/tree package.\n * @internal\n */\nexport const SharedTreeFormatVersion = {\n\t/**\n\t * Requires \\@fluidframework/tree \\>= 2.0.0.\n\t *\n\t * @deprecated - FF does not currently plan on supporting this format long-term.\n\t * Do not write production documents using this format, as they may not be loadable in the future.\n\t */\n\tv1: 1,\n\n\t/**\n\t * Requires \\@fluidframework/tree \\>= 2.0.0.\n\t */\n\tv2: 2,\n\n\t/**\n\t * Requires \\@fluidframework/tree \\>= 2.0.0.\n\t */\n\tv3: 3,\n} as const;\n\n/**\n * Format versions supported by SharedTree.\n *\n * Each version documents a required minimum version of the \\@fluidframework/tree package.\n * @internal\n * @privateRemarks\n * See packages/dds/tree/docs/main/compatibility.md for information on how to add support for a new format.\n */\nexport type SharedTreeFormatVersion = typeof SharedTreeFormatVersion;\n\n/**\n * @internal\n */\nexport type SharedTreeOptions = Partial<ICodecOptions> &\n\tPartial<SharedTreeFormatOptions> & {\n\t\t/**\n\t\t * The {@link ForestType} indicating which forest type should be created for the SharedTree.\n\t\t */\n\t\tforest?: ForestType;\n\t};\n\n/**\n * Options for configuring the persisted format SharedTree uses.\n * @internal\n */\nexport interface SharedTreeFormatOptions {\n\t/**\n\t * See {@link TreeCompressionStrategy}.\n\t * default: TreeCompressionStrategy.Compressed\n\t */\n\ttreeEncodeType: TreeCompressionStrategy;\n\t/**\n\t * The format version SharedTree should use to persist documents.\n\t *\n\t * This option has compatibility implications for applications using SharedTree.\n\t * Each version documents a required minimum version of \\@fluidframework/tree.\n\t * If this minimum version fails to be met, the SharedTree may fail to load.\n\t * To be safe, application authors should verify that they have saturated this version\n\t * of \\@fluidframework/tree in their ecosystem before changing the format version.\n\t *\n\t * This option defaults to SharedTreeFormatVersion.v2.\n\t */\n\tformatVersion: SharedTreeFormatVersion[keyof SharedTreeFormatVersion];\n}\n\n/**\n * Used to distinguish between different forest types.\n * @internal\n */\nexport enum ForestType {\n\t/**\n\t * The \"ObjectForest\" forest type.\n\t */\n\tReference = 0,\n\t/**\n\t * The \"ChunkedForest\" forest type.\n\t */\n\tOptimized = 1,\n}\n\nexport const defaultSharedTreeOptions: Required<SharedTreeOptions> = {\n\tjsonValidator: noopValidator,\n\tforest: ForestType.Reference,\n\ttreeEncodeType: TreeCompressionStrategy.Compressed,\n\tformatVersion: SharedTreeFormatVersion.v3,\n};\n\n/**\n * A channel factory that creates {@link ISharedTree}s.\n */\nexport class SharedTreeFactory implements IChannelFactory<ISharedTree> {\n\tpublic readonly type: string = \"https://graph.microsoft.com/types/tree\";\n\n\tpublic readonly attributes: IChannelAttributes = {\n\t\ttype: this.type,\n\t\tsnapshotFormatVersion: \"0.0.0\",\n\t\tpackageVersion: \"0.0.0\",\n\t};\n\n\tpublic constructor(private readonly options: SharedTreeOptions = {}) {}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<SharedTree> {\n\t\tconst tree = new SharedTree(id, runtime, channelAttributes, this.options);\n\t\tawait tree.load(services);\n\t\treturn tree;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedTree {\n\t\tconst tree = new SharedTree(id, runtime, this.attributes, this.options);\n\t\ttree.initializeLocal();\n\t\treturn tree;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeCheckout.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,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iB,CAGrC;IAEM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAK9C,IAAI,IAAI,YAAY;IAsBpB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAShC,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAKrC,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAC/B,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;IAgBrD,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAK/C,CAAC,aAAa,CAAC,IAAI,IAAI;IAOvB,eAAe,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE;IAgB/E,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,gBAAgB;CAgDxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,iBAAiB,GAAG,IAAI,GAC5D,iBAAiB,CAMnB"}
@@ -216,6 +216,7 @@ class TreeCheckout {
216
216
  }
217
217
  rebase(view) {
218
218
  this.checkNotDisposed();
219
+ (0, internal_1.assert)(!view.transaction.inProgress(), "A view cannot be rebased while it has a pending transaction");
219
220
  view.branch.rebaseOnto(this.branch);
220
221
  }
221
222
  rebaseOnto(view) {
@@ -224,7 +225,7 @@ class TreeCheckout {
224
225
  }
225
226
  merge(view, disposeView = true) {
226
227
  this.checkNotDisposed();
227
- (0, internal_1.assert)(!this.transaction.inProgress() || disposeView, 0x710 /* A view that is merged into an in-progress transaction must be disposed */);
228
+ (0, internal_1.assert)(!this.transaction.inProgress(), "Views cannot be merged into a view while it has a pending transaction");
228
229
  while (view.transaction.inProgress()) {
229
230
  view.transaction.commit();
230
231
  }
@@ -1 +1 @@
1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C,MAAM,EAAE,CAAC;AAC9B,CAAC;AATD,wCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { noopValidator } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\ttype Revertible,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeAnonChange,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\ttagChange,\n\tvisitDelta,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport { SharedTreeBranch, getChangeReplaceType } from \"../shared-tree-core/index.js\";\nimport { type IDisposable, TransactionResult, disposeSymbol, fail } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n * @internal\n */\nexport interface CheckoutEvents {\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a revertible change has been made to this view.\n\t *\n\t * Applications which subscribe to this event are expected to revert or discard revertibles they acquire (failure to do so will leak memory).\n\t * The provided revertible is inherently bound to the view that raised the event, calling `revert` won't apply to forked views.\n\t *\n\t * @param revertible - The revertible that can be used to revert the change.\n\t */\n\n\t/**\n\t * {@inheritdoc TreeViewEvents.commitApplied}\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Factory for creating a {@link Revertible}.\n * Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.\n *\n * @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.\n * This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,\n * whichever happens first.\n * This is typically used to clean up any resources associated with the `Revertible` in the host application.\n *\n * @sealed @public\n */\nexport type RevertibleFactory = (\n\tonRevertibleDisposed?: (revertible: Revertible) => void,\n) => Revertible;\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n * @internal\n */\nexport interface ITreeCheckout extends AnchorLocator {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: ITransaction;\n\n\t/**\n\t * Spawn a new view which is based off of the current state of this view.\n\t * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.\n\t */\n\tfork(): ITreeCheckoutFork;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * @param disposeView - whether or not to dispose `view` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork, disposeView: boolean): void;\n\n\t/**\n\t * Rebase the given view onto this view.\n\t * @param view - a view which was created by a call to `fork()`. It is modified by this operation.\n\t */\n\trebase(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Events about this view.\n\t */\n\treadonly events: Listenable<CheckoutEvents>;\n\n\t/**\n\t * Events about the root of the tree in this view.\n\t */\n\treadonly rootEvents: Listenable<AnchorSetRootEvents>;\n\n\t/**\n\t * Returns a JsonableTree for each tree that was removed from (and not restored to) the document.\n\t * This list is guaranteed to contain all nodes that are recoverable through undo/redo on this checkout.\n\t * The list may also contain additional nodes.\n\t *\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t */\n\tgetRemovedRoots(): [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Creates a {@link TreeCheckout}.\n * @param args - an object containing optional components that will be used to build the view.\n * Any components not provided will be created by default.\n * @remarks This does not create a {@link SharedTree}, but rather a view with the minimal state\n * and functionality required to implement {@link ITreeCheckout}.\n */\nexport function createTreeCheckout(\n\tidCompressor: IIdCompressor,\n\tmintRevisionTag: () => RevisionTag,\n\trevisionTagCodec: RevisionTagCodec,\n\targs?: {\n\t\tbranch?: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tchangeFamily?: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tschema?: TreeStoredSchemaRepository;\n\t\tforest?: IEditableForest;\n\t\tfieldBatchCodec?: FieldBatchCodec;\n\t\tevents?: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>;\n\t\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t},\n): TreeCheckout {\n\tconst forest = args?.forest ?? buildForest();\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst defaultCodecOptions = { jsonValidator: noopValidator };\n\tconst defaultFieldBatchVersion = 1;\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ??\n\t\t\t\tmakeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),\n\t\t\t{ jsonValidator: noopValidator },\n\t\t\targs?.chunkCompressionStrategy,\n\t\t);\n\tconst branch =\n\t\targs?.branch ??\n\t\tnew SharedTreeBranch(\n\t\t\t{\n\t\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t\t\trevision: \"root\",\n\t\t\t},\n\t\t\tchangeFamily,\n\t\t\t() => idCompressor.generateCompressedId(),\n\t\t);\n\tconst events = args?.events ?? createEmitter();\n\n\tconst transaction = new Transaction(branch);\n\n\treturn new TreeCheckout(\n\t\ttransaction,\n\t\tbranch,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tevents,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t);\n}\n\n/**\n * A collection of functions for managing transactions.\n * Transactions allow edits to be batched into atomic units.\n * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n *\n * To avoid updating observers of the view state with intermediate results during a transaction,\n * use {@link ITreeCheckout#fork} and {@link ISharedTreeFork#merge}.\n * @internal\n */\nexport interface ITransaction {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): TransactionResult.Commit;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): TransactionResult.Abort;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tinProgress(): boolean;\n}\n\nclass Transaction implements ITransaction {\n\tpublic constructor(\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t) {}\n\n\tpublic start(): void {\n\t\tthis.branch.startTransaction();\n\t\tthis.branch.editor.enterTransaction();\n\t}\n\tpublic commit(): TransactionResult.Commit {\n\t\tthis.branch.commitTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Commit;\n\t}\n\tpublic abort(): TransactionResult.Abort {\n\t\tthis.branch.abortTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Abort;\n\t}\n\tpublic inProgress(): boolean {\n\t\treturn this.branch.isTransacting();\n\t}\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n * @internal\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this view over all the new changes in the given view.\n\t * @param view - Either the root view or a view that was created by a call to `fork()`. It is not modified by this operation.\n\t */\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tprivate isDisposed = false;\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<DisposableRevertible>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\tpublic constructor(\n\t\tpublic readonly transaction: ITransaction,\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tpublic readonly events: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tprivate readonly removedRoots: DetachedFieldIndex = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t),\n\t\t/** Optional logger for telemetry. */\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t) {\n\t\t// We subscribe to `beforeChange` rather than `afterChange` here because it's possible that the change is invalid WRT our forest.\n\t\t// For example, a bug in the editor might produce a malformed change object and thus applying the change to the forest will throw an error.\n\t\t// In such a case we will crash here, preventing the change from being added to the commit graph, and preventing `afterChange` from firing.\n\t\t// One important consequence of this is that we will not submit the op containing the invalid change, since op submissions happens in response to `afterChange`.\n\t\tbranch.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\t\t\tfor (const change of event.change.change.changes) {\n\t\t\t\t\tif (change.type === \"data\") {\n\t\t\t\t\t\tconst delta = intoDelta(tagChange(change.innerChange, event.change.revision));\n\t\t\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (change.type === \"schema\") {\n\t\t\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t\t\t// is also valid under the new schema.\n\t\t\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\t\t\t\t\t\t// under the old schema, but these changes will also be rolled back, thereby putting the forest\n\t\t\t\t\t\t// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\t\t\t\t\t\t// Case 2: A branch with a schema change may be rebased such that the schema change (because\n\t\t\t\t\t\t// of a constraint) is no longer applied.\n\t\t\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\t\t\t\t\t\t// ensure that these data changes are muted if they would render some trees invalid under the\n\t\t\t\t\t\t// original (reinstated) schema.\n\t\t\t\t\t\tstoredSchema.apply(change.innerChange.schema.new);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(\"Unknown Shared Tree change type.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.events.emit(\"afterBatch\");\n\t\t\t}\n\t\t\tif (event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\") {\n\t\t\t\tconst transactionRevision = event.newCommits[0].revision;\n\t\t\t\tfor (const transactionStep of event.removedCommits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbranch.on(\"commitApplied\", (data) => {\n\t\t\tconst commit = branch.getHead();\n\t\t\tconst { change, revision } = commit;\n\t\t\tlet withinEventContext = true;\n\n\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t? undefined\n\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a commitApplied event.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple commitApplied event listeners are registered.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to revert a revertible that has been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, data.kind);\n\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, branch.fork());\n\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t};\n\n\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible);\n\t\t\twithinEventContext = false;\n\t\t});\n\t}\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[this.forest.acquireVisitor(), anchorVisitor],\n\t\t\t[anchorVisitor],\n\t\t);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(): void {\n\t\tassert(!this.isDisposed, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this.branch.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic fork(): TreeCheckout {\n\t\tthis.checkNotDisposed();\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this.branch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst transaction = new Transaction(branch);\n\t\treturn new TreeCheckout(\n\t\t\ttransaction,\n\t\t\tbranch,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tcreateEmitter(),\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\tpublic rebase(view: TreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tview.branch.rebaseOnto(this.branch);\n\t}\n\n\tpublic rebaseOnto(view: ITreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tview.rebase(this);\n\t}\n\n\tpublic merge(view: TreeCheckout): void;\n\tpublic merge(view: TreeCheckout, disposeView: boolean): void;\n\tpublic merge(view: TreeCheckout, disposeView = true): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!this.transaction.inProgress() || disposeView,\n\t\t\t0x710 /* A view that is merged into an in-progress transaction must be disposed */,\n\t\t);\n\t\twhile (view.transaction.inProgress()) {\n\t\t\tview.transaction.commit();\n\t\t}\n\t\tthis.branch.merge(view.branch);\n\t\tif (disposeView) {\n\t\t\tview[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.isDisposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis.branch.dispose();\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: DisposableRevertible, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tif (this.branch.isTransacting()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\n\t\tlet change = makeAnonChange(\n\t\t\tthis.changeFamily.rebaser.invert(tagChange(commitToRevert.change, revision), false),\n\t\t);\n\n\t\tconst headCommit = this.branch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = makeAnonChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t);\n\t\t}\n\n\t\tthis.branch.apply(\n\t\t\tchange.change,\n\t\t\tthis.mintRevisionTag(),\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n}\n\n/**\n * Run a synchronous transaction on the given shared tree view.\n * This is a convenience helper around the {@link SharedTreeFork#transaction} APIs.\n * @param view - the view on which to run the transaction\n * @param transaction - the transaction function. This will be executed immediately. It is passed `view` as an argument for convenience.\n * If this function returns an `Abort` result then the transaction will be aborted. Otherwise, it will be committed.\n * @returns whether or not the transaction was committed or aborted\n * @internal\n */\nexport function runSynchronous(\n\tview: ITreeCheckout,\n\ttransaction: (view: ITreeCheckout) => TransactionResult | void,\n): TransactionResult {\n\tview.transaction.start();\n\tconst result = transaction(view);\n\treturn result === TransactionResult.Abort\n\t\t? view.transaction.abort()\n\t\t: view.transaction.commit();\n}\n\ninterface DisposableRevertible extends Revertible {\n\tdispose: () => void;\n}\n"]}
1
+ {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,uEAGkD;AAClD,gDAAkD;AAClD,+CA2B0B;AAC1B,iDAK4B;AAC5B,4DAOuC;AACvC,2DAAsF;AACtF,+CAA4F;AAE5F,2EAAsF;AAmJtF;;;;;;GA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;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAChB,MAAM,CAAC,MAAM,EACb,IAAI,CAAC,eAAe,EAAE,EACtB,IAAI,KAAK,qBAAU,CAAC,OAAO,IAAI,IAAI,KAAK,qBAAU,CAAC,IAAI;YACtD,CAAC,CAAC,qBAAU,CAAC,IAAI;YACjB,CAAC,CAAC,qBAAU,CAAC,IAAI,CAClB,CAAC;QAEF,iEAAiE;QACjE,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,aAAa,GAAG,UAAU,CAAC;QAC/B,OAAO,cAAc,CAAC,QAAQ,KAAK,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3D,SAAS,EAAE,CAAC;YAEZ,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC;YAC1C,IAAA,iBAAM,EAAC,YAAY,KAAK,SAAS,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACjF,aAAa,GAAG,YAAY,CAAC;QAC9B,CAAC;QAED,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IAC3B,CAAC;;AA/TF,oCAgUC;AA9SA;;;GAGG;AACoB,qCAAwB,GAAG,kBAAkB,AAArB,CAAsB;AA4StE;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC7B,IAAmB,EACnB,WAA8D;IAE9D,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,KAAK,4BAAiB,CAAC,KAAK;QACxC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9B,CAAC;AATD,wCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { noopValidator } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\ttype Revertible,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeAnonChange,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\ttagChange,\n\tvisitDelta,\n} from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tbuildForest,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport { SharedTreeBranch, getChangeReplaceType } from \"../shared-tree-core/index.js\";\nimport { type IDisposable, TransactionResult, disposeSymbol, fail } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n * @internal\n */\nexport interface CheckoutEvents {\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a revertible change has been made to this view.\n\t *\n\t * Applications which subscribe to this event are expected to revert or discard revertibles they acquire (failure to do so will leak memory).\n\t * The provided revertible is inherently bound to the view that raised the event, calling `revert` won't apply to forked views.\n\t *\n\t * @param revertible - The revertible that can be used to revert the change.\n\t */\n\n\t/**\n\t * {@inheritdoc TreeViewEvents.commitApplied}\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Factory for creating a {@link Revertible}.\n * Will error if invoked outside the scope of the `commitApplied` event that provides it, or if invoked multiple times.\n *\n * @param onRevertibleDisposed - A callback that will be invoked when the `Revertible` generated by this factory is disposed.\n * This happens when the `Revertible` is disposed manually, or when the `TreeView` that the `Revertible` belongs to is disposed,\n * whichever happens first.\n * This is typically used to clean up any resources associated with the `Revertible` in the host application.\n *\n * @sealed @public\n */\nexport type RevertibleFactory = (\n\tonRevertibleDisposed?: (revertible: Revertible) => void,\n) => Revertible;\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n * @internal\n */\nexport interface ITreeCheckout extends AnchorLocator {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: ITransaction;\n\n\t/**\n\t * Spawn a new view which is based off of the current state of this view.\n\t * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.\n\t */\n\tfork(): ITreeCheckoutFork;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - a view which was created by a call to `fork()`.\n\t * @param disposeView - whether or not to dispose `view` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: ITreeCheckoutFork, disposeView: boolean): void;\n\n\t/**\n\t * Rebase the given view onto this view.\n\t * @param view - a view which was created by a call to `fork()`. It is modified by this operation.\n\t */\n\trebase(view: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema): void;\n\n\t/**\n\t * Events about this view.\n\t */\n\treadonly events: Listenable<CheckoutEvents>;\n\n\t/**\n\t * Events about the root of the tree in this view.\n\t */\n\treadonly rootEvents: Listenable<AnchorSetRootEvents>;\n\n\t/**\n\t * Returns a JsonableTree for each tree that was removed from (and not restored to) the document.\n\t * This list is guaranteed to contain all nodes that are recoverable through undo/redo on this checkout.\n\t * The list may also contain additional nodes.\n\t *\n\t * This is only intended for use in testing and exceptional code paths: it is not performant.\n\t */\n\tgetRemovedRoots(): [string | number | undefined, number, JsonableTree][];\n}\n\n/**\n * Creates a {@link TreeCheckout}.\n * @param args - an object containing optional components that will be used to build the view.\n * Any components not provided will be created by default.\n * @remarks This does not create a {@link SharedTree}, but rather a view with the minimal state\n * and functionality required to implement {@link ITreeCheckout}.\n */\nexport function createTreeCheckout(\n\tidCompressor: IIdCompressor,\n\tmintRevisionTag: () => RevisionTag,\n\trevisionTagCodec: RevisionTagCodec,\n\targs?: {\n\t\tbranch?: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tchangeFamily?: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>;\n\t\tschema?: TreeStoredSchemaRepository;\n\t\tforest?: IEditableForest;\n\t\tfieldBatchCodec?: FieldBatchCodec;\n\t\tevents?: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>;\n\t\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t},\n): TreeCheckout {\n\tconst forest = args?.forest ?? buildForest();\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst defaultCodecOptions = { jsonValidator: noopValidator };\n\tconst defaultFieldBatchVersion = 1;\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ??\n\t\t\t\tmakeFieldBatchCodec(defaultCodecOptions, defaultFieldBatchVersion),\n\t\t\t{ jsonValidator: noopValidator },\n\t\t\targs?.chunkCompressionStrategy,\n\t\t);\n\tconst branch =\n\t\targs?.branch ??\n\t\tnew SharedTreeBranch(\n\t\t\t{\n\t\t\t\tchange: changeFamily.rebaser.compose([]),\n\t\t\t\trevision: \"root\",\n\t\t\t},\n\t\t\tchangeFamily,\n\t\t\t() => idCompressor.generateCompressedId(),\n\t\t);\n\tconst events = args?.events ?? createEmitter();\n\n\tconst transaction = new Transaction(branch);\n\n\treturn new TreeCheckout(\n\t\ttransaction,\n\t\tbranch,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tevents,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t);\n}\n\n/**\n * A collection of functions for managing transactions.\n * Transactions allow edits to be batched into atomic units.\n * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n *\n * To avoid updating observers of the view state with intermediate results during a transaction,\n * use {@link ITreeCheckout#fork} and {@link ISharedTreeFork#merge}.\n * @internal\n */\nexport interface ITransaction {\n\t/**\n\t * Start a new transaction.\n\t * If a transaction is already in progress when this new transaction starts, then this transaction will be \"nested\" inside of it,\n\t * i.e. the outer transaction will still be in progress after this new transaction is committed or aborted.\n\t *\n\t * @remarks - Asynchronous transactions are not supported on the root checkout,\n\t * since it is always kept up-to-date with the latest remote edits and the results of this rebasing (which might invalidate\n\t * the transaction) is not visible to the application author.\n\t * Instead,\n\t *\n\t * 1. fork the root checkout\n\t * 2. run the transaction on the fork\n\t * 3. merge the fork back into the root checkout\n\t *\n\t * @privateRemarks - There is currently no enforcement that asynchronous transactions don't happen on the root checkout.\n\t * AB#6488 tracks adding some enforcement to make it more clear to application authors that this is not supported.\n\t */\n\tstart(): void;\n\t/**\n\t * Close this transaction by squashing its edits and committing them as a single edit.\n\t * If this is the root checkout and there are no ongoing transactions remaining, the squashed edit will be submitted to Fluid.\n\t */\n\tcommit(): TransactionResult.Commit;\n\t/**\n\t * Close this transaction and revert the state of the tree to what it was before this transaction began.\n\t */\n\tabort(): TransactionResult.Abort;\n\t/**\n\t * True if there is at least one transaction currently in progress on this view, otherwise false.\n\t */\n\tinProgress(): boolean;\n}\n\nclass Transaction implements ITransaction {\n\tpublic constructor(\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t) {}\n\n\tpublic start(): void {\n\t\tthis.branch.startTransaction();\n\t\tthis.branch.editor.enterTransaction();\n\t}\n\tpublic commit(): TransactionResult.Commit {\n\t\tthis.branch.commitTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Commit;\n\t}\n\tpublic abort(): TransactionResult.Abort {\n\t\tthis.branch.abortTransaction();\n\t\tthis.branch.editor.exitTransaction();\n\t\treturn TransactionResult.Abort;\n\t}\n\tpublic inProgress(): boolean {\n\t\treturn this.branch.isTransacting();\n\t}\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n * @internal\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this view over all the new changes in the given view.\n\t * @param view - Either the root view or a view that was created by a call to `fork()`. It is not modified by this operation.\n\t */\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tprivate isDisposed = false;\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<DisposableRevertible>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\tpublic constructor(\n\t\tpublic readonly transaction: ITransaction,\n\t\tprivate readonly branch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tpublic readonly events: Listenable<CheckoutEvents> &\n\t\t\tIEmitter<CheckoutEvents> &\n\t\t\tHasListeners<CheckoutEvents>,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tprivate readonly removedRoots: DetachedFieldIndex = makeDetachedFieldIndex(\n\t\t\t\"repair\",\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t),\n\t\t/** Optional logger for telemetry. */\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t) {\n\t\t// We subscribe to `beforeChange` rather than `afterChange` here because it's possible that the change is invalid WRT our forest.\n\t\t// For example, a bug in the editor might produce a malformed change object and thus applying the change to the forest will throw an error.\n\t\t// In such a case we will crash here, preventing the change from being added to the commit graph, and preventing `afterChange` from firing.\n\t\t// One important consequence of this is that we will not submit the op containing the invalid change, since op submissions happens in response to `afterChange`.\n\t\tbranch.on(\"beforeChange\", (event) => {\n\t\t\tif (event.change !== undefined) {\n\t\t\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\t\t\tfor (const change of event.change.change.changes) {\n\t\t\t\t\tif (change.type === \"data\") {\n\t\t\t\t\t\tconst delta = intoDelta(tagChange(change.innerChange, event.change.revision));\n\t\t\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (change.type === \"schema\") {\n\t\t\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t\t\t// is also valid under the new schema.\n\t\t\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\t\t\t\t\t\t// under the old schema, but these changes will also be rolled back, thereby putting the forest\n\t\t\t\t\t\t// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\t\t\t\t\t\t// Case 2: A branch with a schema change may be rebased such that the schema change (because\n\t\t\t\t\t\t// of a constraint) is no longer applied.\n\t\t\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\t\t\t\t\t\t// ensure that these data changes are muted if they would render some trees invalid under the\n\t\t\t\t\t\t// original (reinstated) schema.\n\t\t\t\t\t\tstoredSchema.apply(change.innerChange.schema.new);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(\"Unknown Shared Tree change type.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.events.emit(\"afterBatch\");\n\t\t\t}\n\t\t\tif (event.type === \"replace\" && getChangeReplaceType(event) === \"transactionCommit\") {\n\t\t\t\tconst transactionRevision = event.newCommits[0].revision;\n\t\t\t\tfor (const transactionStep of event.removedCommits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, transactionRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbranch.on(\"commitApplied\", (data) => {\n\t\t\tconst commit = branch.getHead();\n\t\t\tconst { change, revision } = commit;\n\t\t\tlet withinEventContext = true;\n\n\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t? undefined\n\t\t\t\t: (onRevertibleDisposed?: (revertible: Revertible) => void) => {\n\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a commitApplied event.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple commitApplied event listeners are registered.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst revertibleCommits = this.revertibleCommitBranches;\n\t\t\t\t\t\tconst revertible: DisposableRevertible = {\n\t\t\t\t\t\t\tget status(): RevertibleStatus {\n\t\t\t\t\t\t\t\tconst revertibleCommit = revertibleCommits.get(revision);\n\t\t\t\t\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trevert: (release: boolean = true) => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to revert a revertible that has been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst revertMetrics = this.revertRevertible(revision, data.kind);\n\t\t\t\t\t\t\t\tthis.logger?.sendTelemetryEvent({\n\t\t\t\t\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t\t\t\t\t...revertMetrics,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (release) {\n\t\t\t\t\t\t\t\t\trevertible.dispose();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.disposeRevertible(revertible, revision);\n\t\t\t\t\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.revertibleCommitBranches.set(revision, branch.fork());\n\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t};\n\n\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible);\n\t\t\twithinEventContext = false;\n\t\t});\n\t}\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors(\n\t\t\t[this.forest.acquireVisitor(), anchorVisitor],\n\t\t\t[anchorVisitor],\n\t\t);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(): void {\n\t\tassert(!this.isDisposed, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this.branch.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic fork(): TreeCheckout {\n\t\tthis.checkNotDisposed();\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this.branch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst transaction = new Transaction(branch);\n\t\treturn new TreeCheckout(\n\t\t\ttransaction,\n\t\t\tbranch,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tcreateEmitter(),\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\tpublic rebase(view: TreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!view.transaction.inProgress(),\n\t\t\t\"A view cannot be rebased while it has a pending transaction\",\n\t\t);\n\t\tview.branch.rebaseOnto(this.branch);\n\t}\n\n\tpublic rebaseOnto(view: ITreeCheckout): void {\n\t\tthis.checkNotDisposed();\n\t\tview.rebase(this);\n\t}\n\n\tpublic merge(view: TreeCheckout): void;\n\tpublic merge(view: TreeCheckout, disposeView: boolean): void;\n\tpublic merge(view: TreeCheckout, disposeView = true): void {\n\t\tthis.checkNotDisposed();\n\t\tassert(\n\t\t\t!this.transaction.inProgress(),\n\t\t\t\"Views cannot be merged into a view while it has a pending transaction\",\n\t\t);\n\t\twhile (view.transaction.inProgress()) {\n\t\t\tview.transaction.commit();\n\t\t}\n\t\tthis.branch.merge(view.branch);\n\t\tif (disposeView) {\n\t\t\tview[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed();\n\t\tthis.isDisposed = true;\n\t\tthis.purgeRevertibles();\n\t\tthis.branch.dispose();\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: DisposableRevertible, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tif (this.branch.isTransacting()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\n\t\tlet change = makeAnonChange(\n\t\t\tthis.changeFamily.rebaser.invert(tagChange(commitToRevert.change, revision), false),\n\t\t);\n\n\t\tconst headCommit = this.branch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = makeAnonChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t);\n\t\t}\n\n\t\tthis.branch.apply(\n\t\t\tchange.change,\n\t\t\tthis.mintRevisionTag(),\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n}\n\n/**\n * Run a synchronous transaction on the given shared tree view.\n * This is a convenience helper around the {@link SharedTreeFork#transaction} APIs.\n * @param view - the view on which to run the transaction\n * @param transaction - the transaction function. This will be executed immediately. It is passed `view` as an argument for convenience.\n * If this function returns an `Abort` result then the transaction will be aborted. Otherwise, it will be committed.\n * @returns whether or not the transaction was committed or aborted\n * @internal\n */\nexport function runSynchronous(\n\tview: ITreeCheckout,\n\ttransaction: (view: ITreeCheckout) => TransactionResult | void,\n): TransactionResult {\n\tview.transaction.start();\n\tconst result = transaction(view);\n\treturn result === TransactionResult.Abort\n\t\t? view.transaction.abort()\n\t\t: view.transaction.commit();\n}\n\ninterface DisposableRevertible extends Revertible {\n\tdispose: () => void;\n}\n"]}