@fluidframework/tree 2.74.0-365691 → 2.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (856) hide show
  1. package/.vscode/settings.json +4 -2
  2. package/CHANGELOG.md +11 -0
  3. package/api-report/tree.alpha.api.md +125 -87
  4. package/api-report/tree.beta.api.md +0 -1
  5. package/api-report/tree.legacy.beta.api.md +0 -1
  6. package/api-report/tree.legacy.public.api.md +0 -1
  7. package/api-report/tree.public.api.md +0 -1
  8. package/assertTagging.config.mjs +1 -1
  9. package/dist/alpha.d.ts +6 -2
  10. package/dist/codec/codec.d.ts +41 -13
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +46 -19
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/versioned/codec.d.ts +1 -1
  15. package/dist/codec/versioned/codec.d.ts.map +1 -1
  16. package/dist/codec/versioned/codec.js.map +1 -1
  17. package/dist/codec/versioned/format.d.ts +4 -1
  18. package/dist/codec/versioned/format.d.ts.map +1 -1
  19. package/dist/codec/versioned/format.js +4 -1
  20. package/dist/codec/versioned/format.js.map +1 -1
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js +4 -3
  24. package/dist/core/index.js.map +1 -1
  25. package/dist/core/rebase/index.d.ts +1 -1
  26. package/dist/core/rebase/index.d.ts.map +1 -1
  27. package/dist/core/rebase/index.js.map +1 -1
  28. package/dist/core/rebase/types.d.ts +20 -1
  29. package/dist/core/rebase/types.d.ts.map +1 -1
  30. package/dist/core/rebase/types.js.map +1 -1
  31. package/dist/core/schema-stored/schema.d.ts +4 -7
  32. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  33. package/dist/core/schema-stored/schema.js +2 -2
  34. package/dist/core/schema-stored/schema.js.map +1 -1
  35. package/dist/core/tree/detachedFieldIndex.d.ts +34 -13
  36. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  37. package/dist/core/tree/detachedFieldIndex.js +12 -12
  38. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  39. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +4 -4
  40. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  41. package/dist/core/tree/detachedFieldIndexFormatCommon.js +2 -2
  42. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  43. package/dist/core/tree/index.d.ts +3 -2
  44. package/dist/core/tree/index.d.ts.map +1 -1
  45. package/dist/core/tree/index.js +3 -0
  46. package/dist/core/tree/index.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  49. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +5 -5
  51. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/format.js +4 -4
  53. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +14 -6
  55. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +7 -2
  58. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  59. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +3 -3
  60. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  61. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +22 -26
  62. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  63. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +30 -8
  64. package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  65. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +41 -11
  66. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  67. package/dist/feature-libraries/forest-summary/codec.d.ts +7 -1
  68. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  69. package/dist/feature-libraries/forest-summary/codec.js +13 -11
  70. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  71. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +10 -13
  72. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  73. package/dist/feature-libraries/forest-summary/forestSummarizer.js +35 -31
  74. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  75. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +61 -0
  76. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -0
  77. package/dist/feature-libraries/forest-summary/formatCommon.js +27 -0
  78. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -0
  79. package/dist/feature-libraries/forest-summary/formatV1.d.ts +51 -0
  80. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -0
  81. package/dist/feature-libraries/forest-summary/formatV1.js +11 -0
  82. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -0
  83. package/dist/feature-libraries/forest-summary/formatV2.d.ts +51 -0
  84. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -0
  85. package/dist/feature-libraries/forest-summary/formatV2.js +11 -0
  86. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -0
  87. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +18 -24
  88. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  89. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +21 -43
  90. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  91. package/dist/feature-libraries/forest-summary/index.d.ts +2 -2
  92. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  93. package/dist/feature-libraries/forest-summary/index.js +3 -4
  94. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  95. package/dist/feature-libraries/forest-summary/summaryFormatCommon.d.ts +35 -0
  96. package/dist/feature-libraries/forest-summary/summaryFormatCommon.d.ts.map +1 -0
  97. package/dist/feature-libraries/forest-summary/summaryFormatCommon.js +43 -0
  98. package/dist/feature-libraries/forest-summary/summaryFormatCommon.js.map +1 -0
  99. package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts +11 -0
  100. package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts.map +1 -0
  101. package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.js +14 -0
  102. package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.js.map +1 -0
  103. package/dist/feature-libraries/forest-summary/summaryFormatV3.d.ts +18 -0
  104. package/dist/feature-libraries/forest-summary/summaryFormatV3.d.ts.map +1 -0
  105. package/dist/feature-libraries/forest-summary/summaryFormatV3.js +21 -0
  106. package/dist/feature-libraries/forest-summary/summaryFormatV3.js.map +1 -0
  107. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts +17 -0
  108. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -0
  109. package/dist/feature-libraries/forest-summary/summaryTypes.js +35 -0
  110. package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -0
  111. package/dist/feature-libraries/index.d.ts +1 -1
  112. package/dist/feature-libraries/index.d.ts.map +1 -1
  113. package/dist/feature-libraries/index.js +3 -2
  114. package/dist/feature-libraries/index.js.map +1 -1
  115. package/dist/feature-libraries/modular-schema/comparison.d.ts +18 -2
  116. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  117. package/dist/feature-libraries/modular-schema/comparison.js +54 -3
  118. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  119. package/dist/feature-libraries/modular-schema/fieldKind.d.ts +25 -13
  120. package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  121. package/dist/feature-libraries/modular-schema/fieldKind.js +0 -21
  122. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  123. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  124. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -1
  125. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  126. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  127. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  128. package/dist/feature-libraries/modular-schema/index.js +2 -1
  129. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  130. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  131. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +2 -3
  132. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  133. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  134. package/dist/feature-libraries/schema-index/codec.js +4 -4
  135. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  136. package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
  137. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -1
  138. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +27 -8
  139. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  140. package/dist/feature-libraries/schema-index/schemaSummarizer.js +42 -16
  141. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  142. package/dist/index.d.ts +2 -2
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +5 -3
  145. package/dist/index.js.map +1 -1
  146. package/dist/packageVersion.d.ts +1 -1
  147. package/dist/packageVersion.d.ts.map +1 -1
  148. package/dist/packageVersion.js +1 -1
  149. package/dist/packageVersion.js.map +1 -1
  150. package/dist/shared-tree/independentView.d.ts +1 -1
  151. package/dist/shared-tree/independentView.d.ts.map +1 -1
  152. package/dist/shared-tree/independentView.js +1 -1
  153. package/dist/shared-tree/independentView.js.map +1 -1
  154. package/dist/shared-tree/schematizingTreeView.d.ts +2 -1
  155. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  156. package/dist/shared-tree/schematizingTreeView.js +3 -0
  157. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  158. package/dist/shared-tree/sharedTree.d.ts +2 -2
  159. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  160. package/dist/shared-tree/sharedTree.js +4 -4
  161. package/dist/shared-tree/sharedTree.js.map +1 -1
  162. package/dist/shared-tree/sharedTreeChangeCodecs.js +2 -2
  163. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  164. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +20 -8
  165. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  166. package/dist/shared-tree/sharedTreeChangeEnricher.js +25 -11
  167. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  168. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  169. package/dist/shared-tree/treeAlpha.js +1 -1
  170. package/dist/shared-tree/treeAlpha.js.map +1 -1
  171. package/dist/shared-tree/treeCheckout.d.ts +10 -5
  172. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  173. package/dist/shared-tree/treeCheckout.js +72 -17
  174. package/dist/shared-tree/treeCheckout.js.map +1 -1
  175. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  176. package/dist/shared-tree-core/editManagerCodecs.js +10 -8
  177. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  178. package/{lib/shared-tree-core/editManagerCodecsV5.d.ts → dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts} +3 -3
  179. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -0
  180. package/dist/shared-tree-core/{editManagerCodecsV5.js → editManagerCodecsVSharedBranches.js} +7 -7
  181. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -0
  182. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +8 -30
  183. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  184. package/dist/shared-tree-core/editManagerFormatCommons.js +18 -9
  185. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  186. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +1 -1
  187. package/dist/shared-tree-core/{editManagerFormatV5.d.ts → editManagerFormatVSharedBranches.d.ts} +3 -3
  188. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -0
  189. package/dist/shared-tree-core/{editManagerFormatV5.js → editManagerFormatVSharedBranches.js} +2 -2
  190. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -0
  191. package/dist/shared-tree-core/editManagerSummarizer.d.ts +29 -9
  192. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  193. package/dist/shared-tree-core/editManagerSummarizer.js +41 -13
  194. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  195. package/dist/shared-tree-core/index.d.ts +5 -2
  196. package/dist/shared-tree-core/index.d.ts.map +1 -1
  197. package/dist/shared-tree-core/index.js +7 -1
  198. package/dist/shared-tree-core/index.js.map +1 -1
  199. package/{lib/shared-tree-core/messageCodecV5.d.ts → dist/shared-tree-core/messageCodecVSharedBranches.d.ts} +2 -2
  200. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -0
  201. package/dist/shared-tree-core/{messageCodecV5.js → messageCodecVSharedBranches.js} +6 -6
  202. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -0
  203. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  204. package/dist/shared-tree-core/messageCodecs.js +12 -10
  205. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  206. package/dist/shared-tree-core/messageFormat.d.ts +9 -36
  207. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  208. package/dist/shared-tree-core/messageFormat.js +19 -9
  209. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  210. package/{lib/shared-tree-core/messageFormatV5.d.ts → dist/shared-tree-core/messageFormatVSharedBranches.d.ts} +5 -7
  211. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -0
  212. package/dist/shared-tree-core/{messageFormatV5.js → messageFormatVSharedBranches.js} +3 -2
  213. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -0
  214. package/dist/shared-tree-core/sharedTreeCore.d.ts +13 -47
  215. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  216. package/dist/shared-tree-core/sharedTreeCore.js +29 -17
  217. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  218. package/dist/shared-tree-core/summaryTypes.d.ts +94 -0
  219. package/dist/shared-tree-core/summaryTypes.d.ts.map +1 -0
  220. package/dist/shared-tree-core/summaryTypes.js +47 -0
  221. package/dist/shared-tree-core/summaryTypes.js.map +1 -0
  222. package/dist/shared-tree-core/versionedSummarizer.d.ts +72 -0
  223. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -0
  224. package/dist/shared-tree-core/versionedSummarizer.js +64 -0
  225. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -0
  226. package/dist/simple-tree/api/configuration.d.ts +3 -26
  227. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  228. package/dist/simple-tree/api/configuration.js +10 -21
  229. package/dist/simple-tree/api/configuration.js.map +1 -1
  230. package/dist/simple-tree/api/dirtyIndex.d.ts +11 -0
  231. package/dist/simple-tree/api/dirtyIndex.d.ts.map +1 -1
  232. package/dist/simple-tree/api/dirtyIndex.js +7 -0
  233. package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
  234. package/dist/simple-tree/api/discrepancies.d.ts +1 -1
  235. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  236. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  237. package/dist/simple-tree/api/eraseSchemaDetails.d.ts +89 -0
  238. package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -0
  239. package/dist/simple-tree/api/eraseSchemaDetails.js +97 -0
  240. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -0
  241. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -3
  242. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  243. package/dist/simple-tree/api/getSimpleSchema.js +9 -3
  244. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  245. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  246. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
  247. package/dist/simple-tree/api/incrementalAllowedTypes.js +7 -0
  248. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  249. package/dist/simple-tree/api/index.d.ts +4 -4
  250. package/dist/simple-tree/api/index.d.ts.map +1 -1
  251. package/dist/simple-tree/api/index.js +8 -5
  252. package/dist/simple-tree/api/index.js.map +1 -1
  253. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  254. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  255. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  256. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +5 -5
  257. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  258. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  259. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  260. package/dist/simple-tree/api/schemaFactoryRecursive.js +0 -1
  261. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  262. package/dist/simple-tree/api/schemaFromSimple.d.ts +6 -1
  263. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  264. package/dist/simple-tree/api/schemaFromSimple.js +5 -0
  265. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  266. package/dist/simple-tree/api/schemaStatics.d.ts +12 -12
  267. package/dist/simple-tree/api/simpleSchemaCodec.d.ts +15 -3
  268. package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
  269. package/dist/simple-tree/api/simpleSchemaCodec.js +18 -6
  270. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  271. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  272. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  273. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  274. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +8 -1
  275. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  276. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +13 -8
  277. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  278. package/dist/simple-tree/api/storedSchema.d.ts +1 -1
  279. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  280. package/dist/simple-tree/api/storedSchema.js +1 -2
  281. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  282. package/dist/simple-tree/api/tree.d.ts +15 -2
  283. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  284. package/dist/simple-tree/api/tree.js.map +1 -1
  285. package/dist/simple-tree/api/typesUnsafe.d.ts +3 -3
  286. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  287. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  288. package/dist/simple-tree/core/allowedTypes.d.ts +2 -2
  289. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  290. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  291. package/dist/simple-tree/core/index.d.ts +1 -1
  292. package/dist/simple-tree/core/index.d.ts.map +1 -1
  293. package/dist/simple-tree/core/index.js +2 -3
  294. package/dist/simple-tree/core/index.js.map +1 -1
  295. package/dist/simple-tree/core/toStored.d.ts +17 -15
  296. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  297. package/dist/simple-tree/core/toStored.js +5 -40
  298. package/dist/simple-tree/core/toStored.js.map +1 -1
  299. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  300. package/dist/simple-tree/core/treeNode.js +1 -0
  301. package/dist/simple-tree/core/treeNode.js.map +1 -1
  302. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  303. package/dist/simple-tree/core/walkSchema.js +4 -0
  304. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  305. package/dist/simple-tree/createContext.d.ts.map +1 -1
  306. package/dist/simple-tree/createContext.js +20 -5
  307. package/dist/simple-tree/createContext.js.map +1 -1
  308. package/dist/simple-tree/fieldSchema.d.ts +3 -3
  309. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  310. package/dist/simple-tree/fieldSchema.js.map +1 -1
  311. package/dist/simple-tree/index.d.ts +6 -5
  312. package/dist/simple-tree/index.d.ts.map +1 -1
  313. package/dist/simple-tree/index.js +16 -11
  314. package/dist/simple-tree/index.js.map +1 -1
  315. package/dist/simple-tree/leafNodeSchema.d.ts +5 -5
  316. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  317. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  318. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  319. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
  320. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  321. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  322. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  323. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  324. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
  325. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  326. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  327. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +2 -2
  328. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  329. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  330. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  331. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  332. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -3
  333. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  334. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  335. package/dist/simple-tree/simpleSchema.d.ts +55 -23
  336. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  337. package/dist/simple-tree/simpleSchema.js +17 -0
  338. package/dist/simple-tree/simpleSchema.js.map +1 -1
  339. package/dist/simple-tree/simpleSchemaFormatV1.d.ts +1 -1
  340. package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
  341. package/dist/simple-tree/simpleSchemaFormatV1.js +8 -1
  342. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  343. package/dist/simple-tree/toStoredSchema.d.ts +58 -11
  344. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  345. package/dist/simple-tree/toStoredSchema.js +205 -30
  346. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  347. package/dist/simple-tree/treeSchema.d.ts +23 -0
  348. package/dist/simple-tree/treeSchema.d.ts.map +1 -0
  349. package/dist/simple-tree/treeSchema.js +25 -0
  350. package/dist/simple-tree/treeSchema.js.map +1 -0
  351. package/dist/tableSchema.d.ts +107 -64
  352. package/dist/tableSchema.d.ts.map +1 -1
  353. package/dist/tableSchema.js +161 -60
  354. package/dist/tableSchema.js.map +1 -1
  355. package/dist/util/brand.d.ts +49 -0
  356. package/dist/util/brand.d.ts.map +1 -1
  357. package/dist/util/brand.js +47 -1
  358. package/dist/util/brand.js.map +1 -1
  359. package/dist/util/index.d.ts +2 -1
  360. package/dist/util/index.d.ts.map +1 -1
  361. package/dist/util/index.js +6 -2
  362. package/dist/util/index.js.map +1 -1
  363. package/dist/util/readSnapshotBlob.d.ts +13 -0
  364. package/dist/util/readSnapshotBlob.d.ts.map +1 -0
  365. package/dist/util/readSnapshotBlob.js +18 -0
  366. package/dist/util/readSnapshotBlob.js.map +1 -0
  367. package/eslint.config.mts +98 -0
  368. package/lib/alpha.d.ts +6 -2
  369. package/lib/codec/codec.d.ts +41 -13
  370. package/lib/codec/codec.d.ts.map +1 -1
  371. package/lib/codec/codec.js +40 -13
  372. package/lib/codec/codec.js.map +1 -1
  373. package/lib/codec/versioned/codec.d.ts +1 -1
  374. package/lib/codec/versioned/codec.d.ts.map +1 -1
  375. package/lib/codec/versioned/codec.js.map +1 -1
  376. package/lib/codec/versioned/format.d.ts +4 -1
  377. package/lib/codec/versioned/format.d.ts.map +1 -1
  378. package/lib/codec/versioned/format.js +4 -1
  379. package/lib/codec/versioned/format.js.map +1 -1
  380. package/lib/core/index.d.ts +2 -2
  381. package/lib/core/index.d.ts.map +1 -1
  382. package/lib/core/index.js +1 -1
  383. package/lib/core/index.js.map +1 -1
  384. package/lib/core/rebase/index.d.ts +1 -1
  385. package/lib/core/rebase/index.d.ts.map +1 -1
  386. package/lib/core/rebase/index.js.map +1 -1
  387. package/lib/core/rebase/types.d.ts +20 -1
  388. package/lib/core/rebase/types.d.ts.map +1 -1
  389. package/lib/core/rebase/types.js.map +1 -1
  390. package/lib/core/schema-stored/schema.d.ts +4 -7
  391. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  392. package/lib/core/schema-stored/schema.js +3 -3
  393. package/lib/core/schema-stored/schema.js.map +1 -1
  394. package/lib/core/tree/detachedFieldIndex.d.ts +34 -13
  395. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  396. package/lib/core/tree/detachedFieldIndex.js +12 -12
  397. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  398. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +4 -4
  399. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  400. package/lib/core/tree/detachedFieldIndexFormatCommon.js +3 -3
  401. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  402. package/lib/core/tree/index.d.ts +3 -2
  403. package/lib/core/tree/index.d.ts.map +1 -1
  404. package/lib/core/tree/index.js +2 -1
  405. package/lib/core/tree/index.js.map +1 -1
  406. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  407. package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -3
  408. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  409. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +5 -5
  410. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  411. package/lib/feature-libraries/chunked-forest/codec/format.js +5 -5
  412. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  413. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +14 -6
  414. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -1
  415. package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -1
  416. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +7 -2
  417. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  418. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +3 -3
  419. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  420. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +23 -27
  421. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  422. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +30 -8
  423. package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
  424. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +38 -8
  425. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  426. package/lib/feature-libraries/forest-summary/codec.d.ts +7 -1
  427. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  428. package/lib/feature-libraries/forest-summary/codec.js +12 -11
  429. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  430. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +10 -13
  431. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  432. package/lib/feature-libraries/forest-summary/forestSummarizer.js +33 -29
  433. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  434. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +61 -0
  435. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -0
  436. package/lib/feature-libraries/forest-summary/formatCommon.js +23 -0
  437. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -0
  438. package/lib/feature-libraries/forest-summary/formatV1.d.ts +51 -0
  439. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -0
  440. package/lib/feature-libraries/forest-summary/formatV1.js +8 -0
  441. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -0
  442. package/lib/feature-libraries/forest-summary/formatV2.d.ts +51 -0
  443. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -0
  444. package/lib/feature-libraries/forest-summary/formatV2.js +8 -0
  445. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -0
  446. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +18 -24
  447. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  448. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +20 -42
  449. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  450. package/lib/feature-libraries/forest-summary/index.d.ts +2 -2
  451. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  452. package/lib/feature-libraries/forest-summary/index.js +2 -2
  453. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  454. package/lib/feature-libraries/forest-summary/summaryFormatCommon.d.ts +35 -0
  455. package/lib/feature-libraries/forest-summary/summaryFormatCommon.d.ts.map +1 -0
  456. package/lib/feature-libraries/forest-summary/summaryFormatCommon.js +40 -0
  457. package/lib/feature-libraries/forest-summary/summaryFormatCommon.js.map +1 -0
  458. package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts +11 -0
  459. package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts.map +1 -0
  460. package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.js +11 -0
  461. package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.js.map +1 -0
  462. package/lib/feature-libraries/forest-summary/summaryFormatV3.d.ts +18 -0
  463. package/lib/feature-libraries/forest-summary/summaryFormatV3.d.ts.map +1 -0
  464. package/lib/feature-libraries/forest-summary/summaryFormatV3.js +18 -0
  465. package/lib/feature-libraries/forest-summary/summaryFormatV3.js.map +1 -0
  466. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts +17 -0
  467. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -0
  468. package/lib/feature-libraries/forest-summary/summaryTypes.js +30 -0
  469. package/lib/feature-libraries/forest-summary/summaryTypes.js.map +1 -0
  470. package/lib/feature-libraries/index.d.ts +1 -1
  471. package/lib/feature-libraries/index.d.ts.map +1 -1
  472. package/lib/feature-libraries/index.js +1 -1
  473. package/lib/feature-libraries/index.js.map +1 -1
  474. package/lib/feature-libraries/modular-schema/comparison.d.ts +18 -2
  475. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  476. package/lib/feature-libraries/modular-schema/comparison.js +55 -5
  477. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  478. package/lib/feature-libraries/modular-schema/fieldKind.d.ts +25 -13
  479. package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  480. package/lib/feature-libraries/modular-schema/fieldKind.js +0 -21
  481. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  482. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  483. package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -1
  484. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  485. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  486. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  487. package/lib/feature-libraries/modular-schema/index.js +1 -1
  488. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  489. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  490. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +2 -3
  491. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  492. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  493. package/lib/feature-libraries/schema-index/codec.js +5 -5
  494. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  495. package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
  496. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -1
  497. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +27 -8
  498. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  499. package/lib/feature-libraries/schema-index/schemaSummarizer.js +38 -12
  500. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  501. package/lib/index.d.ts +2 -2
  502. package/lib/index.d.ts.map +1 -1
  503. package/lib/index.js +1 -1
  504. package/lib/index.js.map +1 -1
  505. package/lib/packageVersion.d.ts +1 -1
  506. package/lib/packageVersion.d.ts.map +1 -1
  507. package/lib/packageVersion.js +1 -1
  508. package/lib/packageVersion.js.map +1 -1
  509. package/lib/shared-tree/independentView.d.ts +1 -1
  510. package/lib/shared-tree/independentView.d.ts.map +1 -1
  511. package/lib/shared-tree/independentView.js +2 -2
  512. package/lib/shared-tree/independentView.js.map +1 -1
  513. package/lib/shared-tree/schematizingTreeView.d.ts +2 -1
  514. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  515. package/lib/shared-tree/schematizingTreeView.js +3 -0
  516. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  517. package/lib/shared-tree/sharedTree.d.ts +2 -2
  518. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  519. package/lib/shared-tree/sharedTree.js +4 -4
  520. package/lib/shared-tree/sharedTree.js.map +1 -1
  521. package/lib/shared-tree/sharedTreeChangeCodecs.js +2 -2
  522. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  523. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +20 -8
  524. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  525. package/lib/shared-tree/sharedTreeChangeEnricher.js +25 -11
  526. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  527. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  528. package/lib/shared-tree/treeAlpha.js +2 -2
  529. package/lib/shared-tree/treeAlpha.js.map +1 -1
  530. package/lib/shared-tree/treeCheckout.d.ts +10 -5
  531. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  532. package/lib/shared-tree/treeCheckout.js +73 -18
  533. package/lib/shared-tree/treeCheckout.js.map +1 -1
  534. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  535. package/lib/shared-tree-core/editManagerCodecs.js +11 -9
  536. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  537. package/{dist/shared-tree-core/editManagerCodecsV5.d.ts → lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts} +3 -3
  538. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -0
  539. package/lib/shared-tree-core/{editManagerCodecsV5.js → editManagerCodecsVSharedBranches.js} +4 -4
  540. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -0
  541. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +8 -30
  542. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  543. package/lib/shared-tree-core/editManagerFormatCommons.js +19 -10
  544. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  545. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +1 -1
  546. package/lib/shared-tree-core/{editManagerFormatV5.d.ts → editManagerFormatVSharedBranches.d.ts} +3 -3
  547. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -0
  548. package/lib/shared-tree-core/{editManagerFormatV5.js → editManagerFormatVSharedBranches.js} +2 -2
  549. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -0
  550. package/lib/shared-tree-core/editManagerSummarizer.d.ts +29 -9
  551. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  552. package/lib/shared-tree-core/editManagerSummarizer.js +39 -11
  553. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  554. package/lib/shared-tree-core/index.d.ts +5 -2
  555. package/lib/shared-tree-core/index.d.ts.map +1 -1
  556. package/lib/shared-tree-core/index.js +3 -1
  557. package/lib/shared-tree-core/index.js.map +1 -1
  558. package/{dist/shared-tree-core/messageCodecV5.d.ts → lib/shared-tree-core/messageCodecVSharedBranches.d.ts} +2 -2
  559. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -0
  560. package/lib/shared-tree-core/{messageCodecV5.js → messageCodecVSharedBranches.js} +3 -3
  561. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -0
  562. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  563. package/lib/shared-tree-core/messageCodecs.js +13 -11
  564. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  565. package/lib/shared-tree-core/messageFormat.d.ts +9 -36
  566. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  567. package/lib/shared-tree-core/messageFormat.js +19 -9
  568. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  569. package/{dist/shared-tree-core/messageFormatV5.d.ts → lib/shared-tree-core/messageFormatVSharedBranches.d.ts} +5 -7
  570. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -0
  571. package/lib/shared-tree-core/{messageFormatV5.js → messageFormatVSharedBranches.js} +3 -2
  572. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -0
  573. package/lib/shared-tree-core/sharedTreeCore.d.ts +13 -47
  574. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  575. package/lib/shared-tree-core/sharedTreeCore.js +27 -15
  576. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  577. package/lib/shared-tree-core/summaryTypes.d.ts +94 -0
  578. package/lib/shared-tree-core/summaryTypes.d.ts.map +1 -0
  579. package/lib/shared-tree-core/summaryTypes.js +43 -0
  580. package/lib/shared-tree-core/summaryTypes.js.map +1 -0
  581. package/lib/shared-tree-core/versionedSummarizer.d.ts +72 -0
  582. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -0
  583. package/lib/shared-tree-core/versionedSummarizer.js +60 -0
  584. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -0
  585. package/lib/simple-tree/api/configuration.d.ts +3 -26
  586. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  587. package/lib/simple-tree/api/configuration.js +14 -25
  588. package/lib/simple-tree/api/configuration.js.map +1 -1
  589. package/lib/simple-tree/api/dirtyIndex.d.ts +11 -0
  590. package/lib/simple-tree/api/dirtyIndex.d.ts.map +1 -1
  591. package/lib/simple-tree/api/dirtyIndex.js +7 -0
  592. package/lib/simple-tree/api/dirtyIndex.js.map +1 -1
  593. package/lib/simple-tree/api/discrepancies.d.ts +1 -1
  594. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  595. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  596. package/lib/simple-tree/api/eraseSchemaDetails.d.ts +89 -0
  597. package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -0
  598. package/lib/simple-tree/api/eraseSchemaDetails.js +92 -0
  599. package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -0
  600. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -3
  601. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  602. package/lib/simple-tree/api/getSimpleSchema.js +9 -3
  603. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  604. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  605. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
  606. package/lib/simple-tree/api/incrementalAllowedTypes.js +8 -1
  607. package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  608. package/lib/simple-tree/api/index.d.ts +4 -4
  609. package/lib/simple-tree/api/index.d.ts.map +1 -1
  610. package/lib/simple-tree/api/index.js +3 -3
  611. package/lib/simple-tree/api/index.js.map +1 -1
  612. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  613. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  614. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  615. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +5 -5
  616. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  617. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  618. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  619. package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -1
  620. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  621. package/lib/simple-tree/api/schemaFromSimple.d.ts +6 -1
  622. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  623. package/lib/simple-tree/api/schemaFromSimple.js +5 -0
  624. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  625. package/lib/simple-tree/api/schemaStatics.d.ts +12 -12
  626. package/lib/simple-tree/api/simpleSchemaCodec.d.ts +15 -3
  627. package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
  628. package/lib/simple-tree/api/simpleSchemaCodec.js +15 -3
  629. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  630. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  631. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  632. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  633. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +8 -1
  634. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  635. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +15 -10
  636. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  637. package/lib/simple-tree/api/storedSchema.d.ts +1 -1
  638. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  639. package/lib/simple-tree/api/storedSchema.js +1 -2
  640. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  641. package/lib/simple-tree/api/tree.d.ts +15 -2
  642. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  643. package/lib/simple-tree/api/tree.js.map +1 -1
  644. package/lib/simple-tree/api/typesUnsafe.d.ts +3 -3
  645. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  646. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  647. package/lib/simple-tree/core/allowedTypes.d.ts +2 -2
  648. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  649. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  650. package/lib/simple-tree/core/index.d.ts +1 -1
  651. package/lib/simple-tree/core/index.d.ts.map +1 -1
  652. package/lib/simple-tree/core/index.js +1 -1
  653. package/lib/simple-tree/core/index.js.map +1 -1
  654. package/lib/simple-tree/core/toStored.d.ts +17 -15
  655. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  656. package/lib/simple-tree/core/toStored.js +4 -37
  657. package/lib/simple-tree/core/toStored.js.map +1 -1
  658. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  659. package/lib/simple-tree/core/treeNode.js +1 -0
  660. package/lib/simple-tree/core/treeNode.js.map +1 -1
  661. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  662. package/lib/simple-tree/core/walkSchema.js +5 -1
  663. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  664. package/lib/simple-tree/createContext.d.ts.map +1 -1
  665. package/lib/simple-tree/createContext.js +20 -5
  666. package/lib/simple-tree/createContext.js.map +1 -1
  667. package/lib/simple-tree/fieldSchema.d.ts +3 -3
  668. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  669. package/lib/simple-tree/fieldSchema.js.map +1 -1
  670. package/lib/simple-tree/index.d.ts +6 -5
  671. package/lib/simple-tree/index.d.ts.map +1 -1
  672. package/lib/simple-tree/index.js +5 -4
  673. package/lib/simple-tree/index.js.map +1 -1
  674. package/lib/simple-tree/leafNodeSchema.d.ts +5 -5
  675. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  676. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  677. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  678. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
  679. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  680. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  681. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  682. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  683. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
  684. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  685. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  686. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +2 -2
  687. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  688. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  689. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  690. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  691. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -3
  692. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  693. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  694. package/lib/simple-tree/simpleSchema.d.ts +55 -23
  695. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  696. package/lib/simple-tree/simpleSchema.js +16 -1
  697. package/lib/simple-tree/simpleSchema.js.map +1 -1
  698. package/lib/simple-tree/simpleSchemaFormatV1.d.ts +1 -1
  699. package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
  700. package/lib/simple-tree/simpleSchemaFormatV1.js +8 -1
  701. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  702. package/lib/simple-tree/toStoredSchema.d.ts +58 -11
  703. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  704. package/lib/simple-tree/toStoredSchema.js +204 -31
  705. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  706. package/lib/simple-tree/treeSchema.d.ts +23 -0
  707. package/lib/simple-tree/treeSchema.d.ts.map +1 -0
  708. package/lib/simple-tree/treeSchema.js +21 -0
  709. package/lib/simple-tree/treeSchema.js.map +1 -0
  710. package/lib/tableSchema.d.ts +107 -64
  711. package/lib/tableSchema.d.ts.map +1 -1
  712. package/lib/tableSchema.js +162 -61
  713. package/lib/tableSchema.js.map +1 -1
  714. package/lib/util/brand.d.ts +49 -0
  715. package/lib/util/brand.d.ts.map +1 -1
  716. package/lib/util/brand.js +44 -0
  717. package/lib/util/brand.js.map +1 -1
  718. package/lib/util/index.d.ts +2 -1
  719. package/lib/util/index.d.ts.map +1 -1
  720. package/lib/util/index.js +2 -1
  721. package/lib/util/index.js.map +1 -1
  722. package/lib/util/readSnapshotBlob.d.ts +13 -0
  723. package/lib/util/readSnapshotBlob.d.ts.map +1 -0
  724. package/lib/util/readSnapshotBlob.js +14 -0
  725. package/lib/util/readSnapshotBlob.js.map +1 -0
  726. package/package.json +24 -23
  727. package/src/codec/codec.ts +44 -14
  728. package/src/codec/versioned/codec.ts +1 -1
  729. package/src/codec/versioned/format.ts +4 -1
  730. package/src/core/index.ts +4 -1
  731. package/src/core/rebase/index.ts +1 -0
  732. package/src/core/rebase/types.ts +25 -0
  733. package/src/core/schema-stored/schema.ts +5 -7
  734. package/src/core/tree/detachedFieldIndex.ts +54 -13
  735. package/src/core/tree/detachedFieldIndexFormatCommon.ts +4 -7
  736. package/src/core/tree/index.ts +7 -2
  737. package/src/feature-libraries/chunked-forest/codec/codecs.ts +3 -2
  738. package/src/feature-libraries/chunked-forest/codec/format.ts +6 -9
  739. package/src/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.ts +15 -7
  740. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -9
  741. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +22 -33
  742. package/src/feature-libraries/detachedFieldIndexSummarizer.ts +62 -15
  743. package/src/feature-libraries/forest-summary/codec.ts +22 -10
  744. package/src/feature-libraries/forest-summary/forestSummarizer.ts +77 -44
  745. package/src/feature-libraries/forest-summary/{format.ts → formatCommon.ts} +12 -13
  746. package/src/feature-libraries/forest-summary/formatV1.ts +12 -0
  747. package/src/feature-libraries/forest-summary/formatV2.ts +12 -0
  748. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +37 -56
  749. package/src/feature-libraries/forest-summary/index.ts +2 -2
  750. package/src/feature-libraries/forest-summary/summaryFormatCommon.ts +41 -0
  751. package/src/feature-libraries/forest-summary/summaryFormatV1ToV2.ts +11 -0
  752. package/src/feature-libraries/forest-summary/summaryFormatV3.ts +18 -0
  753. package/src/feature-libraries/forest-summary/summaryTypes.ts +41 -0
  754. package/src/feature-libraries/index.ts +1 -1
  755. package/src/feature-libraries/modular-schema/comparison.ts +64 -5
  756. package/src/feature-libraries/modular-schema/fieldKind.ts +24 -40
  757. package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -1
  758. package/src/feature-libraries/modular-schema/index.ts +1 -0
  759. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +2 -3
  760. package/src/feature-libraries/schema-index/codec.ts +7 -9
  761. package/src/feature-libraries/schema-index/schemaSummarizer.ts +59 -18
  762. package/src/index.ts +6 -2
  763. package/src/packageVersion.ts +1 -1
  764. package/src/shared-tree/independentView.ts +2 -3
  765. package/src/shared-tree/schematizingTreeView.ts +5 -0
  766. package/src/shared-tree/sharedTree.ts +20 -9
  767. package/src/shared-tree/sharedTreeChangeCodecs.ts +2 -2
  768. package/src/shared-tree/sharedTreeChangeEnricher.ts +31 -11
  769. package/src/shared-tree/treeAlpha.ts +2 -3
  770. package/src/shared-tree/treeCheckout.ts +103 -20
  771. package/src/shared-tree-core/editManagerCodecs.ts +11 -9
  772. package/src/shared-tree-core/{editManagerCodecsV5.ts → editManagerCodecsVSharedBranches.ts} +3 -3
  773. package/src/shared-tree-core/editManagerFormatCommons.ts +22 -16
  774. package/src/shared-tree-core/{editManagerFormatV5.ts → editManagerFormatVSharedBranches.ts} +2 -2
  775. package/src/shared-tree-core/editManagerSummarizer.ts +58 -16
  776. package/src/shared-tree-core/index.ts +12 -3
  777. package/src/shared-tree-core/{messageCodecV5.ts → messageCodecVSharedBranches.ts} +3 -3
  778. package/src/shared-tree-core/messageCodecs.ts +13 -11
  779. package/src/shared-tree-core/messageFormat.ts +23 -16
  780. package/src/shared-tree-core/{messageFormatV5.ts → messageFormatVSharedBranches.ts} +4 -6
  781. package/src/shared-tree-core/sharedTreeCore.ts +63 -75
  782. package/src/shared-tree-core/summaryTypes.ts +122 -0
  783. package/src/shared-tree-core/versionedSummarizer.ts +114 -0
  784. package/src/simple-tree/api/configuration.ts +21 -68
  785. package/src/simple-tree/api/dirtyIndex.ts +11 -0
  786. package/src/simple-tree/api/discrepancies.ts +1 -1
  787. package/src/simple-tree/api/eraseSchemaDetails.ts +123 -0
  788. package/src/simple-tree/api/getSimpleSchema.ts +13 -6
  789. package/src/simple-tree/api/incrementalAllowedTypes.ts +15 -3
  790. package/src/simple-tree/api/index.ts +7 -4
  791. package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
  792. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -2
  793. package/src/simple-tree/api/schemaFactoryRecursive.ts +0 -2
  794. package/src/simple-tree/api/schemaFromSimple.ts +11 -5
  795. package/src/simple-tree/api/simpleSchemaCodec.ts +17 -3
  796. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  797. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +18 -10
  798. package/src/simple-tree/api/storedSchema.ts +2 -2
  799. package/src/simple-tree/api/tree.ts +16 -1
  800. package/src/simple-tree/api/typesUnsafe.ts +7 -3
  801. package/src/simple-tree/core/allowedTypes.ts +3 -3
  802. package/src/simple-tree/core/index.ts +2 -2
  803. package/src/simple-tree/core/toStored.ts +22 -55
  804. package/src/simple-tree/core/treeNode.ts +1 -0
  805. package/src/simple-tree/core/walkSchema.ts +6 -0
  806. package/src/simple-tree/createContext.ts +29 -11
  807. package/src/simple-tree/fieldSchema.ts +10 -3
  808. package/src/simple-tree/index.ts +12 -10
  809. package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -2
  810. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +3 -3
  811. package/src/simple-tree/node-kinds/map/mapNode.ts +5 -2
  812. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +3 -3
  813. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +6 -2
  814. package/src/simple-tree/node-kinds/record/recordNode.ts +5 -2
  815. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +3 -3
  816. package/src/simple-tree/simpleSchema.ts +79 -32
  817. package/src/simple-tree/simpleSchemaFormatV1.ts +9 -1
  818. package/src/simple-tree/toStoredSchema.ts +319 -61
  819. package/src/simple-tree/treeSchema.ts +54 -0
  820. package/src/tableSchema.ts +487 -173
  821. package/src/util/brand.ts +61 -0
  822. package/src/util/index.ts +5 -0
  823. package/src/util/readSnapshotBlob.ts +23 -0
  824. package/dist/feature-libraries/forest-summary/format.d.ts +0 -23
  825. package/dist/feature-libraries/forest-summary/format.d.ts.map +0 -1
  826. package/dist/feature-libraries/forest-summary/format.js +0 -24
  827. package/dist/feature-libraries/forest-summary/format.js.map +0 -1
  828. package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +0 -1
  829. package/dist/shared-tree-core/editManagerCodecsV5.js.map +0 -1
  830. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +0 -1
  831. package/dist/shared-tree-core/editManagerFormatV5.js.map +0 -1
  832. package/dist/shared-tree-core/messageCodecV5.d.ts.map +0 -1
  833. package/dist/shared-tree-core/messageCodecV5.js.map +0 -1
  834. package/dist/shared-tree-core/messageFormatV5.d.ts.map +0 -1
  835. package/dist/shared-tree-core/messageFormatV5.js.map +0 -1
  836. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +0 -40
  837. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +0 -1
  838. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +0 -177
  839. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +0 -1
  840. package/lib/feature-libraries/forest-summary/format.d.ts +0 -23
  841. package/lib/feature-libraries/forest-summary/format.d.ts.map +0 -1
  842. package/lib/feature-libraries/forest-summary/format.js +0 -21
  843. package/lib/feature-libraries/forest-summary/format.js.map +0 -1
  844. package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +0 -1
  845. package/lib/shared-tree-core/editManagerCodecsV5.js.map +0 -1
  846. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +0 -1
  847. package/lib/shared-tree-core/editManagerFormatV5.js.map +0 -1
  848. package/lib/shared-tree-core/messageCodecV5.d.ts.map +0 -1
  849. package/lib/shared-tree-core/messageCodecV5.js.map +0 -1
  850. package/lib/shared-tree-core/messageFormatV5.d.ts.map +0 -1
  851. package/lib/shared-tree-core/messageFormatV5.js.map +0 -1
  852. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +0 -40
  853. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +0 -1
  854. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +0 -171
  855. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +0 -1
  856. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +0 -209
@@ -21,10 +21,11 @@ import { FluidClientVersion, FormatValidatorNoOp } from "../codec/index.js";
21
21
  import { AnchorSet, CommitKind, RevertibleStatus, TreeStoredSchemaRepository, combineVisitors, makeDetachedFieldIndex, rebaseChange, rootFieldKey, tagChange, visitDelta, isAncestor, moveToDetachedField, LeafNodeStoredSchema, diffHistories, } from "../core/index.js";
22
22
  import { allowsRepoSuperset, buildForest, createNodeIdentifierManager, defaultSchemaPolicy, intoDelta, jsonableTreeFromCursor, makeFieldBatchCodec, } from "../feature-libraries/index.js";
23
23
  import { SquashingTransactionStack, SharedTreeBranch, TransactionResult, onForkTransitive, } from "../shared-tree-core/index.js";
24
- import { Breakable, disposeSymbol, getOrCreate } from "../util/index.js";
24
+ import { Breakable, disposeSymbol, getOrCreate, } from "../util/index.js";
25
25
  import { SharedTreeChangeFamily, hasSchemaChange } from "./sharedTreeChangeFamily.js";
26
26
  import { customFromCursorStored, } from "../simple-tree/index.js";
27
27
  import { getCheckout, SchematizingSimpleTreeView } from "./schematizingTreeView.js";
28
+ import { isStableId } from "@fluidframework/id-compressor/internal";
28
29
  /**
29
30
  * Creates a {@link TreeCheckout}.
30
31
  * @param args - an object containing optional components that will be used to build the view.
@@ -57,7 +58,7 @@ export function createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCod
57
58
  export class TreeCheckout {
58
59
  constructor(branch,
59
60
  /** True if and only if this checkout is for a branch which is persisted and shared with other clients. */
60
- isSharedBranch, changeFamily, storedSchema, forest, mintRevisionTag, revisionTagCodec, idCompressor, removedRoots = makeDetachedFieldIndex("repair", revisionTagCodec, idCompressor),
61
+ isSharedBranch, changeFamily, storedSchema, forest, mintRevisionTag, revisionTagCodec, idCompressor, _removedRoots = makeDetachedFieldIndex("repair", revisionTagCodec, idCompressor),
61
62
  /** Optional logger for telemetry. */
62
63
  logger, breaker = new Breakable("TreeCheckout"), disposeForksAfterTransaction = true) {
63
64
  this.isSharedBranch = isSharedBranch;
@@ -67,7 +68,7 @@ export class TreeCheckout {
67
68
  this.mintRevisionTag = mintRevisionTag;
68
69
  this.revisionTagCodec = revisionTagCodec;
69
70
  this.idCompressor = idCompressor;
70
- this.removedRoots = removedRoots;
71
+ this._removedRoots = _removedRoots;
71
72
  this.logger = logger;
72
73
  this.breaker = breaker;
73
74
  this.disposeForksAfterTransaction = disposeForksAfterTransaction;
@@ -109,7 +110,28 @@ export class TreeCheckout {
109
110
  return revertible;
110
111
  };
111
112
  let withinEventContext = true;
112
- __classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("changed", { isLocal: true, kind }, getRevertible);
113
+ const metadata = {
114
+ kind,
115
+ isLocal: true,
116
+ getChange: () => {
117
+ const context = {
118
+ idCompressor: this.idCompressor,
119
+ originatorId: this.idCompressor.localSessionId,
120
+ revision,
121
+ };
122
+ const encodedChange = this.changeFamily.codecs
123
+ .resolve(4)
124
+ .json.encode(change, context);
125
+ assert(commit.parent !== undefined, 0xca4 /* Expected applied commit to be parented */);
126
+ return {
127
+ version: 1,
128
+ revision,
129
+ originatorId: this.idCompressor.localSessionId,
130
+ change: encodedChange,
131
+ };
132
+ },
133
+ };
134
+ __classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("changed", metadata, getRevertible);
113
135
  withinEventContext = false;
114
136
  }
115
137
  }
@@ -139,12 +161,12 @@ export class TreeCheckout {
139
161
  this.withCombinedVisitor((visitor) => {
140
162
  revisions.forEach((revision) => {
141
163
  // get all the roots last created or used by the revision
142
- const roots = this.removedRoots.getRootsLastTouchedByRevision(revision);
164
+ const roots = this._removedRoots.getRootsLastTouchedByRevision(revision);
143
165
  // get the detached field for the root and delete it from the removed roots
144
166
  for (const root of roots) {
145
- visitor.destroy(this.removedRoots.toFieldKey(root), 1);
167
+ visitor.destroy(this._removedRoots.toFieldKey(root), 1);
146
168
  }
147
- this.removedRoots.deleteRootsLastTouchedByRevision(revision);
169
+ this._removedRoots.deleteRootsLastTouchedByRevision(revision);
148
170
  });
149
171
  });
150
172
  };
@@ -166,6 +188,9 @@ export class TreeCheckout {
166
188
  this.editLock = new EditLock(__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEditor);
167
189
  this.registerForBranchEvents();
168
190
  }
191
+ get removedRoots() {
192
+ return this._removedRoots;
193
+ }
169
194
  registerForBranchEvents() {
170
195
  __classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.events.on("afterChange", this.onAfterBranchChange);
171
196
  __classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEvents.on("afterChange", this.onAfterChange);
@@ -180,7 +205,7 @@ export class TreeCheckout {
180
205
  return new SquashingTransactionStack(branch, (commits) => {
181
206
  const revision = this.mintRevisionTag();
182
207
  for (const transactionStep of commits) {
183
- this.removedRoots.updateMajor(transactionStep.revision, revision);
208
+ this._removedRoots.updateMajor(transactionStep.revision, revision);
184
209
  }
185
210
  const squashedChange = this.changeFamily.rebaser.compose(commits);
186
211
  const change = this.changeFamily.rebaser.changeRevision(squashedChange, revision);
@@ -189,12 +214,12 @@ export class TreeCheckout {
189
214
  const disposeForks = this.disposeForksAfterTransaction
190
215
  ? trackForksForDisposal(this)
191
216
  : undefined;
192
- // When each transaction is started, take a snapshot of the current state of removed roots
193
- const removedRootsSnapshot = this.removedRoots.clone();
217
+ // When each transaction is started, make a restorable checkpoint of the current state of removed roots
218
+ const restoreRemovedRoots = this._removedRoots.createCheckpoint();
194
219
  return (result) => {
195
220
  switch (result) {
196
221
  case TransactionResult.Abort:
197
- this.removedRoots = removedRootsSnapshot;
222
+ restoreRemovedRoots();
198
223
  break;
199
224
  case TransactionResult.Commit:
200
225
  if (!this.transaction.isInProgress()) {
@@ -229,6 +254,25 @@ export class TreeCheckout {
229
254
  cursor.free();
230
255
  }
231
256
  }
257
+ /**
258
+ * Applies the given serialized change (as was produced via a `"changed"` event of another checkout) to this checkout.
259
+ */
260
+ applySerializedChange(serializedChange) {
261
+ if (!isSerializedChange(serializedChange)) {
262
+ throw new UsageError(`Cannot apply change. Invalid serialized change format.`);
263
+ }
264
+ const { revision, originatorId, change } = serializedChange;
265
+ if (originatorId !== this.idCompressor.localSessionId) {
266
+ throw new UsageError(`Cannot apply change. A serialized changed must be applied to the same SharedTree as it was created from.`);
267
+ }
268
+ const context = {
269
+ idCompressor: this.idCompressor,
270
+ originatorId: this.idCompressor.localSessionId,
271
+ revision,
272
+ };
273
+ const decodedChange = this.changeFamily.codecs.resolve(4).json.decode(change, context);
274
+ this.applyChange(decodedChange, revision);
275
+ }
232
276
  // Revision is the revision of the commit, if any, which caused this change.
233
277
  applyChange(change, revision) {
234
278
  // Conflicts due to schema will be empty and thus are not applied.
@@ -236,7 +280,7 @@ export class TreeCheckout {
236
280
  if (innerChange.type === "data") {
237
281
  const delta = intoDelta(tagChange(innerChange.innerChange, revision));
238
282
  this.withCombinedVisitor((visitor) => {
239
- visitDelta(delta, visitor, this.removedRoots, revision);
283
+ visitDelta(delta, visitor, this._removedRoots, revision);
240
284
  });
241
285
  }
242
286
  else if (innerChange.type === "schema") {
@@ -362,7 +406,7 @@ export class TreeCheckout {
362
406
  const branch = __classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranch.fork();
363
407
  const storedSchema = this.storedSchema.clone();
364
408
  const forest = this.forest.clone(storedSchema, anchors);
365
- const checkout = new TreeCheckout(branch, false, this.changeFamily, storedSchema, forest, this.mintRevisionTag, this.revisionTagCodec, this.idCompressor, this.removedRoots.clone(), this.logger, this.breaker, this.disposeForksAfterTransaction);
409
+ const checkout = new TreeCheckout(branch, false, this.changeFamily, storedSchema, forest, this.mintRevisionTag, this.revisionTagCodec, this.idCompressor, this._removedRoots.clone(), this.logger, this.breaker, this.disposeForksAfterTransaction);
366
410
  __classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("fork", checkout);
367
411
  return checkout;
368
412
  }
@@ -430,8 +474,8 @@ export class TreeCheckout {
430
474
  this.assertNoUntrackedRoots();
431
475
  const trees = [];
432
476
  const cursor = this.forest.allocateCursor("getRemovedRoots");
433
- for (const { id, root } of this.removedRoots.entries()) {
434
- const parentField = this.removedRoots.toFieldKey(root);
477
+ for (const { id, root } of this._removedRoots.entries()) {
478
+ const parentField = this._removedRoots.toFieldKey(root);
435
479
  this.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);
436
480
  const tree = jsonableTreeFromCursor(cursor);
437
481
  // This method is used for tree consistency comparison.
@@ -450,7 +494,7 @@ export class TreeCheckout {
450
494
  load() {
451
495
  // Set the tip revision as the latest relevant revision for any removed roots that are loaded from a summary - this allows them to be garbage collected later.
452
496
  // When a load happens, the head of the trunk and the head of the local/main branch must be the same (this is enforced by SharedTree).
453
- this.removedRoots.setRevisionsForLoadedData(__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead().revision);
497
+ this._removedRoots.setRevisionsForLoadedData(__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead().revision);
454
498
  // The content of the checkout (e.g. the forest) has (maybe) changed, so fire an afterBatch event.
455
499
  __classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("afterBatch");
456
500
  }
@@ -496,8 +540,8 @@ export class TreeCheckout {
496
540
  assertNoUntrackedRoots() {
497
541
  const cursor = this.forest.getCursorAboveDetachedFields();
498
542
  const rootFields = new Set([rootFieldKey]);
499
- for (const { root } of this.removedRoots.entries()) {
500
- rootFields.add(this.removedRoots.toFieldKey(root));
543
+ for (const { root } of this._removedRoots.entries()) {
544
+ rootFields.add(this._removedRoots.toFieldKey(root));
501
545
  }
502
546
  if (!cursor.firstField()) {
503
547
  return;
@@ -676,4 +720,15 @@ function verboseFromCursor(reader, schema) {
676
720
  fields: fields,
677
721
  };
678
722
  }
723
+ function isSerializedChange(value) {
724
+ if (typeof value !== "object" || value === null) {
725
+ return false;
726
+ }
727
+ const change = value;
728
+ return (change.version === 1 &&
729
+ (change.revision === "root" || typeof change.revision === "number") &&
730
+ typeof change.originatorId === "string" &&
731
+ isStableId(change.originatorId) &&
732
+ change.change !== undefined);
733
+ }
679
734
  //# sourceMappingURL=treeCheckout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EACN,UAAU,GAEV,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAIN,SAAS,EAGT,UAAU,EAOV,gBAAgB,EAIhB,0BAA0B,EAE1B,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,UAAU,EAIV,UAAU,EACV,mBAAmB,EAInB,oBAAoB,EACpB,aAAa,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGN,kBAAkB,EAClB,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,SAAS,EACT,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GAGhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AAE7F,OAAO,EAAE,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AU,GACf,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAChF,IAAI,UAAU,YAAY,oBAAoB,EAAE,CAAC;QAChD,OAAO,MAAyB,CAAC;IAClC,CAAC;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAsC;KAC9C,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidHandle, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { FluidClientVersion, FormatValidatorNoOp } from \"../codec/index.js\";\nimport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\ttype AnchorNode,\n\tAnchorSet,\n\ttype AnchorSetRootEvents,\n\ttype ChangeFamily,\n\tCommitKind,\n\ttype CommitMetadata,\n\ttype DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\trootFieldKey,\n\ttagChange,\n\tvisitDelta,\n\ttype RevertibleAlphaFactory,\n\ttype RevertibleAlpha,\n\ttype GraphCommit,\n\tisAncestor,\n\tmoveToDetachedField,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\tLeafNodeStoredSchema,\n\tdiffHistories,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tallowsRepoSuperset,\n\tbuildForest,\n\tcreateNodeIdentifierManager,\n\tdefaultSchemaPolicy,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport {\n\tSquashingTransactionStack,\n\tSharedTreeBranch,\n\tTransactionResult,\n\tonForkTransitive,\n\ttype SharedTreeBranchChange,\n\ttype Transactor,\n} from \"../shared-tree-core/index.js\";\nimport { Breakable, disposeSymbol, getOrCreate, type WithBreakable } from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype ReadSchema,\n\ttype TreeView,\n\ttype TreeViewConfiguration,\n\ttype UnsafeUnknownSchema,\n\ttype ViewableTree,\n\ttype TreeBranch,\n\ttype TreeChangeEvents,\n\ttype VerboseTree,\n\tcustomFromCursorStored,\n\ttype CustomTreeValue,\n\ttype CustomTreeNode,\n} from \"../simple-tree/index.js\";\nimport { getCheckout, SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\n\n/**\n * Events for {@link ITreeCheckout}.\n */\nexport interface CheckoutEvents {\n\t/**\n\t * The view is currently in a consistent state, but a batch of changes is about to be processed.\n\t * @remarks Once this event fires, it is not safe to access the FlexTree, Forest and AnchorSet again until the corresponding {@link CheckoutEvents.afterBatch} fires.\n\t * Every call to `beforeBatch` will be followed by a corresponding call to `afterBatch` (before any more calls to `beforeBatch`).\n\t * @param change - The {@link SharedTreeBranchChange | change} to the checkout's active branch that is about to be processed.\n\t * May be empty if the changes were produced by e.g. a rebase or the initial loading of the document.\n\t */\n\tbeforeBatch(change: SharedTreeBranchChange<SharedTreeChange>): void;\n\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * @remarks It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * While every call to `beforeBatch` will be followed by a corresponding call to `afterBatch`, the converse is not true.\n\t * This event may be fired without a preceding `beforeBatch` event if the checkout's branch and forest were directly updated via e.g. a summary load rather than via normal application of changes.\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about e.g. local vs remote changes.\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: CommitMetadata, getRevertible?: RevertibleAlphaFactory): void;\n\n\t/**\n\t * Fired when a new branch is created from this checkout.\n\t */\n\tfork(branch: ITreeCheckout): void;\n\n\t/**\n\t * Fired when the checkout is disposed.\n\t */\n\tdispose(): void;\n}\n\n/**\n * A \"version control\"-style branch of a SharedTree.\n * @remarks Branches may be used to coordinate edits to a SharedTree, e.g. via merge and rebase operations.\n * Changes applied to a branch of a branch only apply to that branch and are isolated from other branches.\n * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.\n * @alpha @sealed\n */\nexport interface BranchableTree extends ViewableTree {\n\t/**\n\t * Spawn a new branch which is based off of the current state of this branch.\n\t * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.\n\t */\n\tbranch(): TreeBranchFork;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param view - a branch which was created by a call to `branch()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t * A \"changed\" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.\n\t */\n\tmerge(branch: TreeBranchFork): void;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranchFork, disposeMerged: boolean): void;\n\n\t/**\n\t * Rebase the given branch onto this branch.\n\t * @param branch - a branch which was created by a call to `branch()`. It is modified by this operation.\n\t */\n\trebase(branch: TreeBranchFork): void;\n}\n\n/**\n * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.\n * @remarks This branch should be disposed when it is no longer needed in order to free resources.\n * @alpha @sealed\n */\nexport interface TreeBranchFork extends BranchableTree, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this branch over all the new changes in the given branch.\n\t * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.\n\t */\n\trebaseOnto(branch: BranchableTree): void;\n}\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n */\nexport interface ITreeCheckout extends AnchorLocator, ViewableTree, WithBreakable {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: Transactor;\n\n\tbranch(): ITreeCheckoutFork;\n\n\tmerge(checkout: ITreeCheckoutFork): void;\n\n\tmerge(checkout: ITreeCheckoutFork, disposeMerged: boolean): void;\n\n\trebase(checkout: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t *\n\t * @param newSchema - The new schema to replace the existing schema.\n\t * @param allowNonSupersetSchema - Whether to allow non-superset schemas.\n\t * Defaults to false.\n\t * If false, an assert will be thrown if the new schema does not permit all possible documents which were permitted under the old schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema, allowNonSupersetSchema?: true): 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\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t\tbreaker?: Breakable;\n\t\tdisposeForksAfterTransaction?: boolean;\n\t},\n): TreeCheckout {\n\tconst breaker = args?.breaker ?? new Breakable(\"TreeCheckout\");\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst forest = args?.forest ?? buildForest(breaker, schema);\n\tconst defaultCodecOptions = {\n\t\tjsonValidator: FormatValidatorNoOp,\n\t\tminVersionForCollab: FluidClientVersion.v2_0,\n\t};\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ?? makeFieldBatchCodec(defaultCodecOptions),\n\t\t\tdefaultCodecOptions,\n\t\t\targs?.chunkCompressionStrategy,\n\t\t\tidCompressor,\n\t\t);\n\n\t// TODO: If a branch is passed in, is it supposed to be local main?\n\t// Otherwise shouldn't we set `isSharedBranch` to false?\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\n\treturn new TreeCheckout(\n\t\tbranch,\n\t\ttrue,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t\tbreaker,\n\t\targs?.disposeForksAfterTransaction,\n\t);\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout {\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tpublic disposed = false;\n\n\tprivate editLock: EditLock;\n\n\tprivate readonly views = new Set<TreeView<ImplicitFieldSchema>>();\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<RevertibleAlpha>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\treadonly #events = createEmitter<CheckoutEvents>();\n\tpublic events: Listenable<CheckoutEvents> = this.#events;\n\n\tpublic constructor(\n\t\tbranch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\t/** True if and only if this checkout is for a branch which is persisted and shared with other clients. */\n\t\tpublic readonly isSharedBranch: boolean,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\n\t\tprivate readonly mintRevisionTag: () => RevisionTag,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\tpublic 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\tpublic readonly breaker: Breakable = new Breakable(\"TreeCheckout\"),\n\t\tpublic readonly disposeForksAfterTransaction = true,\n\t) {\n\t\tthis.#transaction = this.createTransactionStack(branch);\n\t\tthis.editLock = new EditLock(this.#transaction.activeBranchEditor);\n\t\tthis.registerForBranchEvents();\n\t}\n\n\tprivate registerForBranchEvents(): void {\n\t\tthis.#transaction.branch.events.on(\"afterChange\", this.onAfterBranchChange);\n\t\tthis.#transaction.activeBranchEvents.on(\"afterChange\", this.onAfterChange);\n\t\tthis.#transaction.activeBranchEvents.on(\"ancestryTrimmed\", this.onAncestryTrimmed);\n\t}\n\n\tprivate unregisterFromBranchEvents(): void {\n\t\tthis.#transaction.branch.events.off(\"afterChange\", this.onAfterBranchChange);\n\t\tthis.#transaction.activeBranchEvents.off(\"afterChange\", this.onAfterChange);\n\t\tthis.#transaction.activeBranchEvents.off(\"ancestryTrimmed\", this.onAncestryTrimmed);\n\t}\n\n\tprivate createTransactionStack(\n\t\tbranch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t): SquashingTransactionStack<SharedTreeEditBuilder, SharedTreeChange> {\n\t\treturn new SquashingTransactionStack(\n\t\t\tbranch,\n\t\t\t(commits) => {\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tfor (const transactionStep of commits) {\n\t\t\t\t\tthis.removedRoots.updateMajor(transactionStep.revision, revision);\n\t\t\t\t}\n\n\t\t\t\tconst squashedChange = this.changeFamily.rebaser.compose(commits);\n\t\t\t\tconst change = this.changeFamily.rebaser.changeRevision(squashedChange, revision);\n\t\t\t\treturn tagChange(change, revision);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tconst disposeForks = this.disposeForksAfterTransaction\n\t\t\t\t\t? trackForksForDisposal(this)\n\t\t\t\t\t: undefined;\n\t\t\t\t// When each transaction is started, take a snapshot of the current state of removed roots\n\t\t\t\tconst removedRootsSnapshot = this.removedRoots.clone();\n\t\t\t\treturn (result) => {\n\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\tcase TransactionResult.Abort:\n\t\t\t\t\t\t\tthis.removedRoots = removedRootsSnapshot;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TransactionResult.Commit:\n\t\t\t\t\t\t\tif (!this.transaction.isInProgress()) {\n\t\t\t\t\t\t\t\t// The changes in a transaction squash commit have already applied to the checkout and are known to be valid, so we can validate the squash commit automatically.\n\t\t\t\t\t\t\t\tthis.validateCommit(this.#transaction.branch.getHead());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t}\n\t\t\t\t\tdisposeForks?.();\n\t\t\t\t};\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic exportVerbose(): VerboseTree | undefined {\n\t\tconst cursor = this.forest.allocateCursor(\"contentSnapshot\");\n\t\ttry {\n\t\t\tmoveToDetachedField(this.forest, cursor);\n\t\t\tconst length = cursor.getFieldLength();\n\t\t\tif (length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t} else if (length === 1) {\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\treturn verboseFromCursor(cursor, this.storedSchema.nodeSchema);\n\t\t\t} else {\n\t\t\t\tfail(0xac8 /* Invalid document root length */);\n\t\t\t}\n\t\t} finally {\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\tprivate readonly onAfterBranchChange = (\n\t\tevent: SharedTreeBranchChange<SharedTreeChange>,\n\t): void => {\n\t\t// The following logic allows revertibles to be generated for the change.\n\t\t// Currently only appends (including merges and transaction commits) are supported.\n\t\tif (event.type === \"append\") {\n\t\t\t// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.\n\t\t\t// Figure out a way to generate revertibles before the commits are garbage collected.\n\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\tconst kind = event.type === \"append\" ? event.kind : CommitKind.Default;\n\t\t\t\tconst { change, revision } = commit;\n\n\t\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t\t? undefined\n\t\t\t\t\t: (onRevertibleDisposed?: (revertible: RevertibleAlpha) => void) => {\n\t\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a changed event.\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst revertible = this.createRevertible(\n\t\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\tonRevertibleDisposed,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.revertibleCommitBranches.set(\n\t\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\t\tthis.#transaction.activeBranch.fork(commit),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t\t};\n\n\t\t\t\tlet withinEventContext = true;\n\t\t\t\tthis.#events.emit(\"changed\", { isLocal: true, kind }, getRevertible);\n\t\t\t\twithinEventContext = false;\n\t\t\t}\n\t\t} else if (this.isRemoteChangeEvent(event)) {\n\t\t\t// TODO: figure out how to plumb through commit kind info for remote changes\n\t\t\tthis.#events.emit(\"changed\", { isLocal: false, kind: CommitKind.Default });\n\t\t}\n\t};\n\n\tprivate readonly onAfterChange = (event: SharedTreeBranchChange<SharedTreeChange>): void => {\n\t\tthis.editLock.lock();\n\t\tthis.#events.emit(\"beforeBatch\", event);\n\t\tif (event.change !== undefined) {\n\t\t\tconst revision =\n\t\t\t\tevent.type === \"rebase\"\n\t\t\t\t\t? this.#transaction.activeBranch.getHead().revision\n\t\t\t\t\t: event.change.revision;\n\n\t\t\tthis.applyChange(event.change.change, revision);\n\t\t}\n\t\tthis.#events.emit(\"afterBatch\");\n\t\tthis.editLock.unlock();\n\t\tif (event.type === \"append\") {\n\t\t\tevent.newCommits.forEach((commit) => this.validateCommit(commit));\n\t\t}\n\t};\n\n\t// Revision is the revision of the commit, if any, which caused this change.\n\tprivate applyChange(change: SharedTreeChange, revision?: RevisionTag): void {\n\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\tfor (const innerChange of change.changes) {\n\t\t\tif (innerChange.type === \"data\") {\n\t\t\t\tconst delta = intoDelta(tagChange(innerChange.innerChange, revision));\n\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\tvisitDelta(delta, visitor, this.removedRoots, revision);\n\t\t\t\t});\n\t\t\t} else if (innerChange.type === \"schema\") {\n\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t// is also valid under the new schema.\n\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\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// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\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// of a constraint) is no longer applied.\n\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\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// original (reinstated) schema.\n\t\t\t\tthis.storedSchema.apply(innerChange.innerChange.schema.new);\n\t\t\t} else {\n\t\t\t\tfail(0xad1 /* Unknown Shared Tree change type. */);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly onAncestryTrimmed = (revisions: RevisionTag[]): void => {\n\t\t// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the\n\t\t// trimmed revisions.\n\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\trevisions.forEach((revision) => {\n\t\t\t\t// get all the roots last created or used by the revision\n\t\t\t\tconst roots = this.removedRoots.getRootsLastTouchedByRevision(revision);\n\n\t\t\t\t// get the detached field for the root and delete it from the removed roots\n\t\t\t\tfor (const root of roots) {\n\t\t\t\t\tvisitor.destroy(this.removedRoots.toFieldKey(root), 1);\n\t\t\t\t}\n\n\t\t\t\tthis.removedRoots.deleteRootsLastTouchedByRevision(revision);\n\t\t\t});\n\t\t});\n\t};\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors([this.forest.acquireVisitor(), anchorVisitor]);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(usageError?: string): void {\n\t\tthis.breaker.use();\n\t\tif (this.disposed) {\n\t\t\tif (usageError !== undefined) {\n\t\t\t\tthrow new UsageError(usageError);\n\t\t\t}\n\t\t\tassert(false, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a {@link RevertibleAlpha} object that can undo a specific change in the tree's history.\n\t * Revision must exist in the given {@link TreeCheckout}'s branch.\n\t *\n\t * @param revision - The revision tag identifying the change to be made revertible.\n\t * @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).\n\t * @param checkout - The {@link TreeCheckout} instance this revertible belongs to.\n\t * @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.\n\t * @returns A {@link RevertibleAlpha} object.\n\t */\n\tprivate createRevertible(\n\t\trevision: RevisionTag,\n\t\tkind: CommitKind,\n\t\tcheckout: TreeCheckout,\n\t\tonRevertibleDisposed: ((revertible: RevertibleAlpha) => void) | undefined,\n\t): RevertibleAlpha {\n\t\tconst commitBranches = checkout.revertibleCommitBranches;\n\n\t\tconst revertible: RevertibleAlpha = {\n\t\t\tget status(): RevertibleStatus {\n\t\t\t\tconst revertibleCommit = commitBranches.get(revision);\n\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t},\n\t\t\trevert: (release: boolean = true) => {\n\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\tthrow new UsageError(\"Unable to revert a revertible that has been disposed.\");\n\t\t\t\t}\n\n\t\t\t\tconst revertMetrics = checkout.revertRevertible(revision, kind);\n\t\t\t\tcheckout.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t...revertMetrics,\n\t\t\t\t});\n\n\t\t\t\tif (release) {\n\t\t\t\t\trevertible.dispose();\n\t\t\t\t}\n\t\t\t},\n\t\t\tclone: (targetBranch: TreeBranch) => {\n\t\t\t\t// TODO:#23442: When a revertible is cloned for a forked branch, optimize to create a fork of a revertible branch once per revision NOT once per revision per checkout.\n\t\t\t\tconst targetCheckout = getCheckout(targetBranch);\n\n\t\t\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\t\t\tif (revertibleBranch === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Unable to clone a revertible that has been disposed.\");\n\t\t\t\t}\n\n\t\t\t\tconst commitToRevert = revertibleBranch.getHead();\n\t\t\t\tconst activeBranchHead = targetCheckout.#transaction.activeBranch.getHead();\n\n\t\t\t\tif (isAncestor(commitToRevert, activeBranchHead, true) === false) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Cannot clone revertible for a commit that is not present on the given branch.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttargetCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());\n\n\t\t\t\treturn this.createRevertible(revision, kind, targetCheckout, onRevertibleDisposed);\n\t\t\t},\n\t\t\tdispose: () => {\n\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcheckout.disposeRevertible(revertible, revision);\n\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t},\n\t\t};\n\n\t\treturn revertible;\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\tconst view = new SchematizingSimpleTreeView(\n\t\t\tthis,\n\t\t\tconfig,\n\t\t\tcreateNodeIdentifierManager(this.idCompressor),\n\t\t\t() => {\n\t\t\t\tthis.views.delete(view);\n\t\t\t},\n\t\t);\n\t\tthis.views.add(view);\n\t\treturn view;\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors.events;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this.editLock.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic get transaction(): Transactor {\n\t\treturn this.#transaction;\n\t}\n\t/**\n\t * The {@link Transactor} for this checkout.\n\t * @remarks In the context of a checkout, transactions allow edits to be batched into atomic units.\n\t * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n\t * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n\t * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n\t *\n\t * To avoid updating observers of the view state with intermediate results during a transaction,\n\t * use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.\n\t */\n\t#transaction: SquashingTransactionStack<SharedTreeEditBuilder, SharedTreeChange>;\n\n\tpublic branch(): TreeCheckout {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The parent branch has already been disposed and can no longer create new branches.\",\n\t\t);\n\t\tthis.editLock.checkUnlocked(\"Branching\");\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this.#transaction.activeBranch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst checkout = new TreeCheckout(\n\t\t\tbranch,\n\t\t\tfalse,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t\tthis.breaker,\n\t\t\tthis.disposeForksAfterTransaction,\n\t\t);\n\t\tthis.#events.emit(\"fork\", checkout);\n\t\treturn checkout;\n\t}\n\n\tpublic switchBranch(\n\t\tbranch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t): void {\n\t\t// TODO: Dispose old branch, if necessary\n\t\tassert(\n\t\t\t!this.#transaction.isInProgress(),\n\t\t\t0xc55 /* Cannot switch branches during a transaction */,\n\t\t);\n\t\tconst diff = diffHistories(\n\t\t\tthis.changeFamily.rebaser,\n\t\t\tthis.#transaction.branch.getHead(),\n\t\t\tbranch.getHead(),\n\t\t\tthis.mintRevisionTag,\n\t\t);\n\n\t\tthis.unregisterFromBranchEvents();\n\n\t\tthis.#transaction = this.createTransactionStack(branch);\n\t\tthis.editLock = new EditLock(this.#transaction.activeBranchEditor);\n\t\tthis.registerForBranchEvents();\n\n\t\t// TODO: Rework eventing\n\t\tthis.applyChange(diff);\n\t\tthis.#events.emit(\"afterBatch\");\n\t}\n\n\tpublic rebase(checkout: TreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tthis.editLock.checkUnlocked(\"Rebasing\");\n\t\tassert(\n\t\t\t!checkout.transaction.isInProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tassert(\n\t\t\t!checkout.isSharedBranch,\n\t\t\t0xa5d /* Shared branches cannot be rebased onto another branch. */,\n\t\t);\n\n\t\tcheckout.#transaction.activeBranch.rebaseOnto(this.#transaction.activeBranch);\n\t}\n\n\tpublic rebaseOnto(checkout: ITreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.rebase(this);\n\t}\n\n\tpublic merge(checkout: TreeCheckout): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged: boolean): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged = true): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tthis.editLock.checkUnlocked(\"Merging\");\n\t\tassert(\n\t\t\t!this.transaction.isInProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (checkout.transaction.isInProgress()) {\n\t\t\tcheckout.transaction.commit();\n\t\t}\n\t\tthis.#transaction.activeBranch.merge(checkout.#transaction.activeBranch);\n\t\tif (disposeMerged && !checkout.isSharedBranch) {\n\t\t\t// Dispose the merged checkout unless it is a shared branch.\n\t\t\tcheckout[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema, allowNonSupersetSchema?: true): void {\n\t\tthis.checkNotDisposed();\n\t\tif (allowNonSupersetSchema !== true) {\n\t\t\tassert(\n\t\t\t\tallowsRepoSuperset(defaultSchemaPolicy, this.storedSchema.clone(), newSchema),\n\t\t\t\t0xbe6 /* New schema must allow all documents allowed by old schema */,\n\t\t\t);\n\t\t}\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.editLock.checkUnlocked(\"Disposing a view\");\n\t\tthis[disposeSymbol]();\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The branch has already been disposed and cannot be disposed again.\",\n\t\t);\n\t\tthis.disposed = true;\n\t\tthis.#transaction.branch.dispose();\n\t\tthis.#transaction.dispose();\n\t\tthis.purgeRevertibles();\n\t\tfor (const view of this.views) {\n\t\t\tview.dispose();\n\t\t}\n\t\tthis.#events.emit(\"dispose\");\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tthis.assertNoUntrackedRoots();\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this.removedRoots.entries()) {\n\t\t\tconst parentField = this.removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\t/**\n\t * This must be called on the root/main checkout after loading from a summary.\n\t * @remarks This pattern is necessary because the EditManager skips the normal process of applying commits to branches when loading a summary.\n\t * Instead, it simply {@link SharedTreeBranch#setHead | mutates} the branches directly which does not propagate the typical events throughout the rest of the system.\n\t */\n\tpublic load(): void {\n\t\t// Set the tip revision as the latest relevant revision for any removed roots that are loaded from a summary - this allows them to be garbage collected later.\n\t\t// When a load happens, the head of the trunk and the head of the local/main branch must be the same (this is enforced by SharedTree).\n\t\tthis.removedRoots.setRevisionsForLoadedData(this.#transaction.branch.getHead().revision);\n\t\t// The content of the checkout (e.g. the forest) has (maybe) changed, so fire an afterBatch event.\n\t\tthis.#events.emit(\"afterBatch\");\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: RevertibleAlpha, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tthis.editLock.checkUnlocked(\"Reverting a commit\");\n\t\tif (this.transaction.isInProgress()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\t\tconst revisionForInvert = this.mintRevisionTag();\n\n\t\tlet change = tagChange(\n\t\t\tthis.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert),\n\t\t\trevisionForInvert,\n\t\t);\n\n\t\tconst headCommit = this.#transaction.activeBranch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = tagChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t\trevisionForInvert,\n\t\t\t);\n\t\t}\n\n\t\tthis.#transaction.activeBranch.apply(\n\t\t\tchange,\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n\n\tprivate assertNoUntrackedRoots(): void {\n\t\tconst cursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst rootFields = new Set([rootFieldKey]);\n\t\tfor (const { root } of this.removedRoots.entries()) {\n\t\t\trootFields.add(this.removedRoots.toFieldKey(root));\n\t\t}\n\n\t\tif (!cursor.firstField()) {\n\t\t\treturn;\n\t\t}\n\n\t\tdo {\n\t\t\tconst field = cursor.getFieldKey();\n\t\t\tassert(\n\t\t\t\trootFields.has(field),\n\t\t\t\t0xa22 /* Forest has a root field which is unknown to the detached field index */,\n\t\t\t);\n\n\t\t\trootFields.delete(field);\n\t\t} while (cursor.nextField());\n\t}\n\n\t/**\n\t * `true` iff the given branch change event is due to a remote change\n\t */\n\tprivate isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {\n\t\treturn (\n\t\t\t// Remote changes are only ever applied to shared branches\n\t\t\tthis.isSharedBranch &&\n\t\t\t// Remote changes are applied to the branch by rebasing it onto the trunk.\n\t\t\t// No other rebases are allowed on shared branches, so we can use this to detect remote changes.\n\t\t\tevent.type === \"rebase\"\n\t\t);\n\t}\n\n\t// #region Commit Validation\n\n\t/** Used to maintain the contract of {@link onCommitValid}(). */\n\treadonly #validatedCommits = new WeakMap<\n\t\tGraphCommit<SharedTreeChange>,\n\t\t((commit: GraphCommit<SharedTreeChange>) => void)[] | true\n\t>();\n\n\t/**\n\t * Registers a function to be called when the given commit is validated.\n\t * @remarks A commit is validated by the checkout after it has been applied to the checkout's state (e.g. it has an effect on the forest).\n\t * If the commit applies successfully (i.e. it does not raise any unexpected errors), the commit is considered valid and the registered function is called.\n\t * If the commit does not apply successfully (because it causes an unexpected error), the function is not called (and the checkout will left in an error state).\n\t *\n\t * If the commit has already been validated when this function is called, the function is called immediately and this function returns `true`.\n\t * Otherwise, the function is registered to be called later and this function returns `false`.\n\t */\n\tpublic onCommitValid(\n\t\tcommit: GraphCommit<SharedTreeChange>,\n\t\tfn: (commit: GraphCommit<SharedTreeChange>) => void,\n\t): boolean {\n\t\tconst validated = getOrCreate(this.#validatedCommits, commit, () => []);\n\t\tif (validated === true) {\n\t\t\tfn(commit);\n\t\t\treturn true;\n\t\t}\n\n\t\tvalidated.push(fn);\n\t\treturn false;\n\t}\n\n\t/** Mark the given commit as \"validated\" according to the contract of {@link onCommitValid}(). */\n\tprivate validateCommit(commit: GraphCommit<SharedTreeChange>): void {\n\t\tconst validated = getOrCreate(this.#validatedCommits, commit, () => []);\n\t\tif (validated !== true) {\n\t\t\tvalidated.forEach((fn) => fn(commit));\n\t\t\tthis.#validatedCommits.set(commit, true);\n\t\t}\n\t}\n\n\t// #endregion Commit Validation\n}\n\n/**\n * A helper class that assists {@link TreeCheckout} in preventing functionality from being used while the tree is in the middle of being edited.\n */\nclass EditLock {\n\t/**\n\t * Edits the tree by calling the methods of the editor passed into the {@link EditLock} constructor.\n\t * @remarks Edits will throw an error if the lock is currently locked.\n\t */\n\tpublic readonly editor: ISharedTreeEditor;\n\tprivate locked = false;\n\n\t/**\n\t * @param editor - an editor which will be used to create a new editor that is monitored to determine if any changes are happening to the tree.\n\t * Use {@link EditLock.editor} in place of the original editor to ensure that changes are monitored.\n\t */\n\tpublic constructor(editor: ISharedTreeEditor) {\n\t\tconst checkLock = (): void => this.checkUnlocked(\"Editing the tree\");\n\t\tthis.editor = {\n\t\t\tget schema() {\n\t\t\t\treturn editor.schema;\n\t\t\t},\n\t\t\tvalueField(...fieldArgs) {\n\t\t\t\tconst valueField = editor.valueField(...fieldArgs);\n\t\t\t\treturn {\n\t\t\t\t\tset(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\tvalueField.set(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\toptionalField(...fieldArgs) {\n\t\t\t\tconst optionalField = editor.optionalField(...fieldArgs);\n\t\t\t\treturn {\n\t\t\t\t\tset(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\toptionalField.set(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tsequenceField(...fieldArgs) {\n\t\t\t\tconst sequenceField = editor.sequenceField(...fieldArgs);\n\t\t\t\treturn {\n\t\t\t\t\tinsert(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\tsequenceField.insert(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t\tremove(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\tsequenceField.remove(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tmove(...moveArgs) {\n\t\t\t\tcheckLock();\n\t\t\t\teditor.move(...moveArgs);\n\t\t\t},\n\t\t\taddNodeExistsConstraint(path) {\n\t\t\t\teditor.addNodeExistsConstraint(path);\n\t\t\t},\n\t\t\taddNodeExistsConstraintOnRevert(path) {\n\t\t\t\teditor.addNodeExistsConstraintOnRevert(path);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Prevent further changes from being made to {@link EditLock.editor} until {@link EditLock.unlock} is called.\n\t * @remarks May only be called when the lock is not already locked.\n\t */\n\tpublic lock(): void {\n\t\tif (this.locked) {\n\t\t\tdebugger;\n\t\t}\n\t\tassert(!this.locked, 0xaa7 /* Checkout has already been locked */);\n\t\tthis.locked = true;\n\t}\n\n\t/**\n\t * Throws an error if the lock is currently locked.\n\t * @param action - The current action being performed by the user.\n\t * This must start with a capital letter, as it shows up as the first part of the error message and we want it to look nice.\n\t */\n\tpublic checkUnlocked<T extends string>(action: T extends Capitalize<T> ? T : never): void {\n\t\tif (this.locked) {\n\t\t\t// These type assertions ensure that the event name strings used here match the actual event names\n\t\t\tconst nodeChanged: keyof TreeChangeEvents = \"nodeChanged\";\n\t\t\tconst treeChanged: keyof TreeChangeEvents = \"treeChanged\";\n\t\t\tthrow new UsageError(\n\t\t\t\t`${action} is forbidden during a ${nodeChanged} or ${treeChanged} event`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Allow changes to be made to {@link EditLock.editor} again.\n\t * @remarks May only be called when the lock is currently locked.\n\t */\n\tpublic unlock(): void {\n\t\tassert(this.locked, 0xaa8 /* Checkout has not been locked */);\n\t\tthis.locked = false;\n\t}\n}\n\n/**\n * Keeps track of all new forks created until the returned function is invoked, which will dispose all of those for.\n * The returned function may only be called once.\n *\n * @param checkout - The tree checkout for which you want to monitor forks for disposal.\n * @returns a function which can be called to dispose all of the tracked forks.\n */\nfunction trackForksForDisposal(checkout: TreeCheckout): () => void {\n\tconst forks = new Set<TreeCheckout>();\n\tconst onDisposeUnSubscribes: (() => void)[] = [];\n\tconst onForkUnSubscribe = onForkTransitive(checkout, (fork) => {\n\t\tforks.add(fork);\n\t\tonDisposeUnSubscribes.push(fork.events.on(\"dispose\", () => forks.delete(fork)));\n\t});\n\tlet disposed = false;\n\treturn () => {\n\t\tassert(!disposed, 0xaa9 /* Forks may only be disposed once */);\n\t\tforks.forEach((fork) => fork.dispose());\n\t\tonDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());\n\t\tonForkUnSubscribe();\n\t\tdisposed = true;\n\t};\n}\n\nfunction verboseFromCursor(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n): VerboseTree {\n\tconst fields = customFromCursorStored(reader, schema, verboseFromCursor);\n\tconst nodeSchema =\n\t\tschema.get(reader.type) ?? fail(0xac9 /* missing schema for type in cursor */);\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn fields as CustomTreeValue;\n\t}\n\n\treturn {\n\t\ttype: reader.type,\n\t\tfields: fields as CustomTreeNode<IFluidHandle>,\n\t};\n}\n"]}
1
+ {"version":3,"file":"treeCheckout.js","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EACN,UAAU,GAEV,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAIN,SAAS,EAGT,UAAU,EAMV,gBAAgB,EAIhB,0BAA0B,EAE1B,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,S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,YAAY,KAAK,QAAQ;QACvC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC;QAC/B,MAAM,CAAC,MAAM,KAAK,SAAS,CAC3B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidHandle, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { IIdCompressor, SessionId } from \"@fluidframework/id-compressor\";\nimport {\n\tUsageError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { FluidClientVersion, FormatValidatorNoOp } 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 DeltaVisitor,\n\ttype DetachedFieldIndex,\n\ttype IEditableForest,\n\ttype IForestSubscription,\n\ttype JsonableTree,\n\tRevertibleStatus,\n\ttype RevisionTag,\n\ttype RevisionTagCodec,\n\ttype TreeStoredSchema,\n\tTreeStoredSchemaRepository,\n\ttype TreeStoredSchemaSubscription,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n\trebaseChange,\n\trootFieldKey,\n\ttagChange,\n\tvisitDelta,\n\ttype RevertibleAlphaFactory,\n\ttype RevertibleAlpha,\n\ttype GraphCommit,\n\tisAncestor,\n\tmoveToDetachedField,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\tLeafNodeStoredSchema,\n\tdiffHistories,\n\ttype ChangeMetadata,\n\ttype ChangeEncodingContext,\n\ttype ReadOnlyDetachedFieldIndex,\n} from \"../core/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeCompressionStrategy,\n\tallowsRepoSuperset,\n\tbuildForest,\n\tcreateNodeIdentifierManager,\n\tdefaultSchemaPolicy,\n\tintoDelta,\n\tjsonableTreeFromCursor,\n\tmakeFieldBatchCodec,\n} from \"../feature-libraries/index.js\";\nimport {\n\tSquashingTransactionStack,\n\tSharedTreeBranch,\n\tTransactionResult,\n\tonForkTransitive,\n\ttype SharedTreeBranchChange,\n\ttype Transactor,\n} from \"../shared-tree-core/index.js\";\nimport {\n\tBreakable,\n\tdisposeSymbol,\n\tgetOrCreate,\n\ttype JsonCompatibleReadOnly,\n\ttype WithBreakable,\n} from \"../util/index.js\";\n\nimport { SharedTreeChangeFamily, hasSchemaChange } from \"./sharedTreeChangeFamily.js\";\nimport type { SharedTreeChange } from \"./sharedTreeChangeTypes.js\";\nimport type { ISharedTreeEditor, SharedTreeEditBuilder } from \"./sharedTreeEditBuilder.js\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype ReadSchema,\n\ttype TreeView,\n\ttype TreeViewConfiguration,\n\ttype UnsafeUnknownSchema,\n\ttype ViewableTree,\n\ttype TreeBranch,\n\ttype TreeChangeEvents,\n\ttype VerboseTree,\n\tcustomFromCursorStored,\n\ttype CustomTreeValue,\n\ttype CustomTreeNode,\n} from \"../simple-tree/index.js\";\nimport { getCheckout, SchematizingSimpleTreeView } from \"./schematizingTreeView.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\n/**\n * Events for {@link ITreeCheckout}.\n */\nexport interface CheckoutEvents {\n\t/**\n\t * The view is currently in a consistent state, but a batch of changes is about to be processed.\n\t * @remarks Once this event fires, it is not safe to access the FlexTree, Forest and AnchorSet again until the corresponding {@link CheckoutEvents.afterBatch} fires.\n\t * Every call to `beforeBatch` will be followed by a corresponding call to `afterBatch` (before any more calls to `beforeBatch`).\n\t * @param change - The {@link SharedTreeBranchChange | change} to the checkout's active branch that is about to be processed.\n\t * May be empty if the changes were produced by e.g. a rebase or the initial loading of the document.\n\t */\n\tbeforeBatch(change: SharedTreeBranchChange<SharedTreeChange>): void;\n\n\t/**\n\t * A batch of changes has finished processing and the view is in a consistent state.\n\t * @remarks It is once again safe to access the FlexTree, Forest and AnchorSet.\n\t *\n\t * While every call to `beforeBatch` will be followed by a corresponding call to `afterBatch`, the converse is not true.\n\t * This event may be fired without a preceding `beforeBatch` event if the checkout's branch and forest were directly updated via e.g. a summary load rather than via normal application of changes.\n\t * @remarks\n\t * This is mainly useful for knowing when to do followup work scheduled during events from Anchors.\n\t */\n\tafterBatch(): void;\n\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about e.g. local vs remote changes.\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function provided that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;\n\n\t/**\n\t * Fired when a new branch is created from this checkout.\n\t */\n\tfork(branch: ITreeCheckout): void;\n\n\t/**\n\t * Fired when the checkout is disposed.\n\t */\n\tdispose(): void;\n}\n\n/**\n * A \"version control\"-style branch of a SharedTree.\n * @remarks Branches may be used to coordinate edits to a SharedTree, e.g. via merge and rebase operations.\n * Changes applied to a branch of a branch only apply to that branch and are isolated from other branches.\n * Changes may be synchronized across branches via merge and rebase operations provided on the branch object.\n * @alpha @sealed\n */\nexport interface BranchableTree extends ViewableTree {\n\t/**\n\t * Spawn a new branch which is based off of the current state of this branch.\n\t * Any mutations of the new branch will not apply to this branch until the new branch is merged back into this branch via `merge()`.\n\t */\n\tbranch(): TreeBranchFork;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param view - a branch which was created by a call to `branch()`.\n\t * It is automatically disposed after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t * A \"changed\" event and a corresponding {@link Revertible} will be emitted on this branch for each new change merged from 'branch'.\n\t */\n\tmerge(branch: TreeBranchFork): void;\n\n\t/**\n\t * Apply all the new changes on the given branch to this branch.\n\t * @param branch - a branch which was created by a call to `branch()`.\n\t * @param disposeMerged - whether or not to dispose `branch` after the merge completes.\n\t * @remarks All ongoing transactions (if any) in `branch` will be committed before the merge.\n\t */\n\tmerge(branch: TreeBranchFork, disposeMerged: boolean): void;\n\n\t/**\n\t * Rebase the given branch onto this branch.\n\t * @param branch - a branch which was created by a call to `branch()`. It is modified by this operation.\n\t */\n\trebase(branch: TreeBranchFork): void;\n}\n\n/**\n * A {@link BranchableTree | branch} of a SharedTree that has merged from another branch.\n * @remarks This branch should be disposed when it is no longer needed in order to free resources.\n * @alpha @sealed\n */\nexport interface TreeBranchFork extends BranchableTree, IDisposable {\n\t/**\n\t * Rebase the changes that have been applied to this branch over all the new changes in the given branch.\n\t * @param branch - Either the root branch or a branch that was created by a call to `branch()`. It is not modified by this operation.\n\t */\n\trebaseOnto(branch: BranchableTree): void;\n}\n\n/**\n * Provides a means for interacting with a SharedTree.\n * This includes reading data from the tree and running transactions to mutate the tree.\n * @remarks This interface should not have any implementations other than those provided by the SharedTree package libraries.\n * @privateRemarks\n * API for interacting with a {@link SharedTreeBranch}.\n * Implementations of this interface must implement the {@link branchKey} property.\n */\nexport interface ITreeCheckout extends AnchorLocator, ViewableTree, WithBreakable {\n\t/**\n\t * Read and Write access for schema stored in the document.\n\t *\n\t * These APIs are temporary and will be replaced with different abstractions (View Schema based) in a different place later.\n\t *\n\t * TODO:\n\t * Editing of this should be moved into transactions with the rest of tree editing to they can be intermixed.\n\t * This will be done after the relations between views, branches and Indexes are figured out.\n\t *\n\t * TODO:\n\t * Public APIs for dealing with schema should be in terms of View Schema, and schema update policies.\n\t * The actual stored schema should be hidden (or ar least not be the most prominent way to interact with schema).\n\t *\n\t * TODO:\n\t * Something should ensure the document contents are always in schema.\n\t */\n\treadonly storedSchema: TreeStoredSchemaSubscription;\n\t/**\n\t * Current contents.\n\t * Updated by edits (local and remote).\n\t * Use `editor` to create a local edit.\n\t */\n\treadonly forest: IForestSubscription;\n\n\t/**\n\t * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.\n\t * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.\n\t */\n\treadonly editor: ISharedTreeEditor;\n\n\t/**\n\t * A collection of functions for managing transactions.\n\t */\n\treadonly transaction: Transactor;\n\n\tbranch(): ITreeCheckoutFork;\n\n\tmerge(checkout: ITreeCheckoutFork): void;\n\n\tmerge(checkout: ITreeCheckoutFork, disposeMerged: boolean): void;\n\n\trebase(checkout: ITreeCheckoutFork): void;\n\n\t/**\n\t * Replaces all schema with the provided schema.\n\t * Can over-write preexisting schema, and removes unmentioned schema.\n\t *\n\t * @param newSchema - The new schema to replace the existing schema.\n\t * @param allowNonSupersetSchema - Whether to allow non-superset schemas.\n\t * Defaults to false.\n\t * If false, an assert will be thrown if the new schema does not permit all possible documents which were permitted under the old schema.\n\t */\n\tupdateSchema(newSchema: TreeStoredSchema, allowNonSupersetSchema?: true): 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\tremovedRoots?: DetachedFieldIndex;\n\t\tchunkCompressionStrategy?: TreeCompressionStrategy;\n\t\tlogger?: ITelemetryLoggerExt;\n\t\tbreaker?: Breakable;\n\t\tdisposeForksAfterTransaction?: boolean;\n\t},\n): TreeCheckout {\n\tconst breaker = args?.breaker ?? new Breakable(\"TreeCheckout\");\n\tconst schema = args?.schema ?? new TreeStoredSchemaRepository();\n\tconst forest = args?.forest ?? buildForest(breaker, schema);\n\tconst defaultCodecOptions = {\n\t\tjsonValidator: FormatValidatorNoOp,\n\t\tminVersionForCollab: FluidClientVersion.v2_0,\n\t};\n\tconst changeFamily =\n\t\targs?.changeFamily ??\n\t\tnew SharedTreeChangeFamily(\n\t\t\trevisionTagCodec,\n\t\t\targs?.fieldBatchCodec ?? makeFieldBatchCodec(defaultCodecOptions),\n\t\t\tdefaultCodecOptions,\n\t\t\targs?.chunkCompressionStrategy,\n\t\t\tidCompressor,\n\t\t);\n\n\t// TODO: If a branch is passed in, is it supposed to be local main?\n\t// Otherwise shouldn't we set `isSharedBranch` to false?\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\n\treturn new TreeCheckout(\n\t\tbranch,\n\t\ttrue,\n\t\tchangeFamily,\n\t\tschema,\n\t\tforest,\n\t\tmintRevisionTag,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\targs?.removedRoots,\n\t\targs?.logger,\n\t\tbreaker,\n\t\targs?.disposeForksAfterTransaction,\n\t);\n}\n\n/**\n * Branch (like in a version control system) of SharedTree.\n *\n * {@link ITreeCheckout} that has forked off of the main trunk/branch.\n */\nexport interface ITreeCheckoutFork extends ITreeCheckout {\n\trebaseOnto(view: ITreeCheckout): void;\n}\n\n/**\n * Metrics derived from a revert operation.\n *\n * @see {@link TreeCheckout.revertRevertible}.\n */\nexport interface RevertMetrics {\n\t/**\n\t * The age of the revertible commit relative to the head of the branch to which the reversion will be applied.\n\t */\n\treadonly age: number;\n\n\t// TODO: add other stats as needed for telemetry, etc.\n}\n\n/**\n * An implementation of {@link ITreeCheckoutFork}.\n */\nexport class TreeCheckout implements ITreeCheckoutFork {\n\tpublic disposed = false;\n\n\tprivate editLock: EditLock;\n\n\tprivate readonly views = new Set<TreeView<ImplicitFieldSchema>>();\n\n\t/**\n\t * Set of revertibles maintained for automatic disposal\n\t */\n\tprivate readonly revertibles = new Set<RevertibleAlpha>();\n\n\t/**\n\t * Each branch's head commit corresponds to a revertible commit.\n\t * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from\n\t * being reverted.\n\t */\n\tprivate readonly revertibleCommitBranches = new Map<\n\t\tRevisionTag,\n\t\tSharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>\n\t>();\n\n\t/**\n\t * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.\n\t * @privateRemarks Exposed for testing purposes.\n\t */\n\tpublic static readonly revertTelemetryEventName = \"RevertRevertible\";\n\n\treadonly #events = createEmitter<CheckoutEvents>();\n\tpublic events: Listenable<CheckoutEvents> = this.#events;\n\n\tpublic constructor(\n\t\tbranch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t\t/** True if and only if this checkout is for a branch which is persisted and shared with other clients. */\n\t\tpublic readonly isSharedBranch: boolean,\n\t\tprivate readonly changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>,\n\t\tpublic readonly storedSchema: TreeStoredSchemaRepository,\n\t\tpublic readonly forest: IEditableForest,\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\tpublic readonly breaker: Breakable = new Breakable(\"TreeCheckout\"),\n\t\tpublic readonly disposeForksAfterTransaction = true,\n\t) {\n\t\tthis.#transaction = this.createTransactionStack(branch);\n\t\tthis.editLock = new EditLock(this.#transaction.activeBranchEditor);\n\t\tthis.registerForBranchEvents();\n\t}\n\n\tpublic get removedRoots(): ReadOnlyDetachedFieldIndex {\n\t\treturn this._removedRoots;\n\t}\n\n\tprivate registerForBranchEvents(): void {\n\t\tthis.#transaction.branch.events.on(\"afterChange\", this.onAfterBranchChange);\n\t\tthis.#transaction.activeBranchEvents.on(\"afterChange\", this.onAfterChange);\n\t\tthis.#transaction.activeBranchEvents.on(\"ancestryTrimmed\", this.onAncestryTrimmed);\n\t}\n\n\tprivate unregisterFromBranchEvents(): void {\n\t\tthis.#transaction.branch.events.off(\"afterChange\", this.onAfterBranchChange);\n\t\tthis.#transaction.activeBranchEvents.off(\"afterChange\", this.onAfterChange);\n\t\tthis.#transaction.activeBranchEvents.off(\"ancestryTrimmed\", this.onAncestryTrimmed);\n\t}\n\n\tprivate createTransactionStack(\n\t\tbranch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t): SquashingTransactionStack<SharedTreeEditBuilder, SharedTreeChange> {\n\t\treturn new SquashingTransactionStack(\n\t\t\tbranch,\n\t\t\t(commits) => {\n\t\t\t\tconst revision = this.mintRevisionTag();\n\t\t\t\tfor (const transactionStep of commits) {\n\t\t\t\t\tthis._removedRoots.updateMajor(transactionStep.revision, revision);\n\t\t\t\t}\n\n\t\t\t\tconst squashedChange = this.changeFamily.rebaser.compose(commits);\n\t\t\t\tconst change = this.changeFamily.rebaser.changeRevision(squashedChange, revision);\n\t\t\t\treturn tagChange(change, revision);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tconst disposeForks = this.disposeForksAfterTransaction\n\t\t\t\t\t? trackForksForDisposal(this)\n\t\t\t\t\t: undefined;\n\t\t\t\t// When each transaction is started, make a restorable checkpoint of the current state of removed roots\n\t\t\t\tconst restoreRemovedRoots = this._removedRoots.createCheckpoint();\n\t\t\t\treturn (result) => {\n\t\t\t\t\tswitch (result) {\n\t\t\t\t\t\tcase TransactionResult.Abort:\n\t\t\t\t\t\t\trestoreRemovedRoots();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TransactionResult.Commit:\n\t\t\t\t\t\t\tif (!this.transaction.isInProgress()) {\n\t\t\t\t\t\t\t\t// The changes in a transaction squash commit have already applied to the checkout and are known to be valid, so we can validate the squash commit automatically.\n\t\t\t\t\t\t\t\tthis.validateCommit(this.#transaction.branch.getHead());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tunreachableCase(result);\n\t\t\t\t\t}\n\t\t\t\t\tdisposeForks?.();\n\t\t\t\t};\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic exportVerbose(): VerboseTree | undefined {\n\t\tconst cursor = this.forest.allocateCursor(\"contentSnapshot\");\n\t\ttry {\n\t\t\tmoveToDetachedField(this.forest, cursor);\n\t\t\tconst length = cursor.getFieldLength();\n\t\t\tif (length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t} else if (length === 1) {\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\treturn verboseFromCursor(cursor, this.storedSchema.nodeSchema);\n\t\t\t} else {\n\t\t\t\tfail(0xac8 /* Invalid document root length */);\n\t\t\t}\n\t\t} finally {\n\t\t\tcursor.free();\n\t\t}\n\t}\n\n\tprivate readonly onAfterBranchChange = (\n\t\tevent: SharedTreeBranchChange<SharedTreeChange>,\n\t): void => {\n\t\t// The following logic allows revertibles to be generated for the change.\n\t\t// Currently only appends (including merges and transaction commits) are supported.\n\t\tif (event.type === \"append\") {\n\t\t\t// TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.\n\t\t\t// Figure out a way to generate revertibles before the commits are garbage collected.\n\t\t\tfor (const commit of event.newCommits) {\n\t\t\t\tconst kind = event.type === \"append\" ? event.kind : CommitKind.Default;\n\t\t\t\tconst { change, revision } = commit;\n\n\t\t\t\tconst getRevertible = hasSchemaChange(change)\n\t\t\t\t\t? undefined\n\t\t\t\t\t: (onRevertibleDisposed?: (revertible: RevertibleAlpha) => void) => {\n\t\t\t\t\t\t\tif (!withinEventContext) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\"Cannot get a revertible outside of the context of a changed event.\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (this.revertibleCommitBranches.get(revision) !== undefined) {\n\t\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t\t\"Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst revertible = this.createRevertible(\n\t\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\tonRevertibleDisposed,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.revertibleCommitBranches.set(\n\t\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\t\tthis.#transaction.activeBranch.fork(commit),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.revertibles.add(revertible);\n\t\t\t\t\t\t\treturn revertible;\n\t\t\t\t\t\t};\n\n\t\t\t\tlet withinEventContext = true;\n\n\t\t\t\tconst metadata: ChangeMetadata = {\n\t\t\t\t\tkind,\n\t\t\t\t\tisLocal: true,\n\t\t\t\t\tgetChange: () => {\n\t\t\t\t\t\tconst context: ChangeEncodingContext = {\n\t\t\t\t\t\t\tidCompressor: this.idCompressor,\n\t\t\t\t\t\t\toriginatorId: this.idCompressor.localSessionId,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst encodedChange = this.changeFamily.codecs\n\t\t\t\t\t\t\t.resolve(4)\n\t\t\t\t\t\t\t.json.encode(change, context);\n\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tcommit.parent !== undefined,\n\t\t\t\t\t\t\t0xca4 /* Expected applied commit to be parented */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\toriginatorId: this.idCompressor.localSessionId,\n\t\t\t\t\t\t\tchange: encodedChange,\n\t\t\t\t\t\t} satisfies SerializedChange;\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tthis.#events.emit(\"changed\", metadata, getRevertible);\n\t\t\t\twithinEventContext = false;\n\t\t\t}\n\t\t} else if (this.isRemoteChangeEvent(event)) {\n\t\t\t// TODO: figure out how to plumb through commit kind info for remote changes\n\t\t\tthis.#events.emit(\"changed\", { isLocal: false, kind: CommitKind.Default });\n\t\t}\n\t};\n\n\tprivate readonly onAfterChange = (event: SharedTreeBranchChange<SharedTreeChange>): void => {\n\t\tthis.editLock.lock();\n\t\tthis.#events.emit(\"beforeBatch\", event);\n\t\tif (event.change !== undefined) {\n\t\t\tconst revision =\n\t\t\t\tevent.type === \"rebase\"\n\t\t\t\t\t? this.#transaction.activeBranch.getHead().revision\n\t\t\t\t\t: event.change.revision;\n\n\t\t\tthis.applyChange(event.change.change, revision);\n\t\t}\n\t\tthis.#events.emit(\"afterBatch\");\n\t\tthis.editLock.unlock();\n\t\tif (event.type === \"append\") {\n\t\t\tevent.newCommits.forEach((commit) => this.validateCommit(commit));\n\t\t}\n\t};\n\n\t/**\n\t * Applies the given serialized change (as was produced via a `\"changed\"` event of another checkout) to this checkout.\n\t */\n\tpublic applySerializedChange(serializedChange: JsonCompatibleReadOnly): void {\n\t\tif (!isSerializedChange(serializedChange)) {\n\t\t\tthrow new UsageError(`Cannot apply change. Invalid serialized change format.`);\n\t\t}\n\t\tconst { revision, originatorId, change } = serializedChange;\n\t\tif (originatorId !== this.idCompressor.localSessionId) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Cannot apply change. A serialized changed must be applied to the same SharedTree as it was created from.`,\n\t\t\t);\n\t\t}\n\t\tconst context: ChangeEncodingContext = {\n\t\t\tidCompressor: this.idCompressor,\n\t\t\toriginatorId: this.idCompressor.localSessionId,\n\t\t\trevision,\n\t\t};\n\t\tconst decodedChange = this.changeFamily.codecs.resolve(4).json.decode(change, context);\n\t\tthis.applyChange(decodedChange, revision);\n\t}\n\n\t// Revision is the revision of the commit, if any, which caused this change.\n\tprivate applyChange(change: SharedTreeChange, revision?: RevisionTag): void {\n\t\t// Conflicts due to schema will be empty and thus are not applied.\n\t\tfor (const innerChange of change.changes) {\n\t\t\tif (innerChange.type === \"data\") {\n\t\t\t\tconst delta = intoDelta(tagChange(innerChange.innerChange, revision));\n\t\t\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\t\t\tvisitDelta(delta, visitor, this._removedRoots, revision);\n\t\t\t\t});\n\t\t\t} else if (innerChange.type === \"schema\") {\n\t\t\t\t// Schema changes from a current to a new schema are expected to be backwards compatible.\n\t\t\t\t// This guarantees that all data in the forest (which is valid before the schema change)\n\t\t\t\t// is also valid under the new schema.\n\t\t\t\t// Note however, that such schema changes may in some cases be rolled back:\n\t\t\t\t// Case 1: A transaction with a schema change may be aborted.\n\t\t\t\t// The transaction may have made some data changes that would render some trees invalid\n\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// back in the state before the transaction, which is valid under the original (reinstated) schema.\n\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// of a constraint) is no longer applied.\n\t\t\t\t// Such a branch may contain data changes that would render some trees invalid under the\n\t\t\t\t// original schema. These data changes may not necessarily be rolled back.\n\t\t\t\t// They will however be rebased over the rollback of the schema change. This rebasing will\n\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// original (reinstated) schema.\n\t\t\t\tthis.storedSchema.apply(innerChange.innerChange.schema.new);\n\t\t\t} else {\n\t\t\t\tfail(0xad1 /* Unknown Shared Tree change type. */);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly onAncestryTrimmed = (revisions: RevisionTag[]): void => {\n\t\t// When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the\n\t\t// trimmed revisions.\n\t\tthis.withCombinedVisitor((visitor) => {\n\t\t\trevisions.forEach((revision) => {\n\t\t\t\t// get all the roots last created or used by the revision\n\t\t\t\tconst roots = this._removedRoots.getRootsLastTouchedByRevision(revision);\n\n\t\t\t\t// get the detached field for the root and delete it from the removed roots\n\t\t\t\tfor (const root of roots) {\n\t\t\t\t\tvisitor.destroy(this._removedRoots.toFieldKey(root), 1);\n\t\t\t\t}\n\n\t\t\t\tthis._removedRoots.deleteRootsLastTouchedByRevision(revision);\n\t\t\t});\n\t\t});\n\t};\n\n\tprivate withCombinedVisitor(fn: (visitor: DeltaVisitor) => void): void {\n\t\tconst anchorVisitor = this.forest.anchors.acquireVisitor();\n\t\tconst combinedVisitor = combineVisitors([this.forest.acquireVisitor(), anchorVisitor]);\n\t\tfn(combinedVisitor);\n\t\tcombinedVisitor.free();\n\t}\n\n\tprivate checkNotDisposed(usageError?: string): void {\n\t\tthis.breaker.use();\n\t\tif (this.disposed) {\n\t\t\tif (usageError !== undefined) {\n\t\t\t\tthrow new UsageError(usageError);\n\t\t\t}\n\t\t\tassert(false, 0x911 /* Invalid operation on a disposed TreeCheckout */);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a {@link RevertibleAlpha} object that can undo a specific change in the tree's history.\n\t * Revision must exist in the given {@link TreeCheckout}'s branch.\n\t *\n\t * @param revision - The revision tag identifying the change to be made revertible.\n\t * @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).\n\t * @param checkout - The {@link TreeCheckout} instance this revertible belongs to.\n\t * @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.\n\t * @returns A {@link RevertibleAlpha} object.\n\t */\n\tprivate createRevertible(\n\t\trevision: RevisionTag,\n\t\tkind: CommitKind,\n\t\tcheckout: TreeCheckout,\n\t\tonRevertibleDisposed: ((revertible: RevertibleAlpha) => void) | undefined,\n\t): RevertibleAlpha {\n\t\tconst commitBranches = checkout.revertibleCommitBranches;\n\n\t\tconst revertible: RevertibleAlpha = {\n\t\t\tget status(): RevertibleStatus {\n\t\t\t\tconst revertibleCommit = commitBranches.get(revision);\n\t\t\t\treturn revertibleCommit === undefined\n\t\t\t\t\t? RevertibleStatus.Disposed\n\t\t\t\t\t: RevertibleStatus.Valid;\n\t\t\t},\n\t\t\trevert: (release: boolean = true) => {\n\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\tthrow new UsageError(\"Unable to revert a revertible that has been disposed.\");\n\t\t\t\t}\n\n\t\t\t\tconst revertMetrics = checkout.revertRevertible(revision, kind);\n\t\t\t\tcheckout.logger?.sendTelemetryEvent({\n\t\t\t\t\teventName: TreeCheckout.revertTelemetryEventName,\n\t\t\t\t\t...revertMetrics,\n\t\t\t\t});\n\n\t\t\t\tif (release) {\n\t\t\t\t\trevertible.dispose();\n\t\t\t\t}\n\t\t\t},\n\t\t\tclone: (targetBranch: TreeBranch) => {\n\t\t\t\t// TODO:#23442: When a revertible is cloned for a forked branch, optimize to create a fork of a revertible branch once per revision NOT once per revision per checkout.\n\t\t\t\tconst targetCheckout = getCheckout(targetBranch);\n\n\t\t\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\t\t\tif (revertibleBranch === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Unable to clone a revertible that has been disposed.\");\n\t\t\t\t}\n\n\t\t\t\tconst commitToRevert = revertibleBranch.getHead();\n\t\t\t\tconst activeBranchHead = targetCheckout.#transaction.activeBranch.getHead();\n\n\t\t\t\tif (isAncestor(commitToRevert, activeBranchHead, true) === false) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Cannot clone revertible for a commit that is not present on the given branch.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttargetCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());\n\n\t\t\t\treturn this.createRevertible(revision, kind, targetCheckout, onRevertibleDisposed);\n\t\t\t},\n\t\t\tdispose: () => {\n\t\t\t\tif (revertible.status === RevertibleStatus.Disposed) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"Unable to dispose a revertible that has already been disposed.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcheckout.disposeRevertible(revertible, revision);\n\t\t\t\tonRevertibleDisposed?.(revertible);\n\t\t\t},\n\t\t};\n\n\t\treturn revertible;\n\t}\n\n\t// For the new TreeViewAlpha API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot>;\n\n\t// For the old TreeView API\n\tpublic viewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n\n\tpublic viewWith<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema>(\n\t\tconfig: TreeViewConfiguration<ReadSchema<TRoot>>,\n\t): SchematizingSimpleTreeView<TRoot> {\n\t\tconst view = new SchematizingSimpleTreeView(\n\t\t\tthis,\n\t\t\tconfig,\n\t\t\tcreateNodeIdentifierManager(this.idCompressor),\n\t\t\t() => {\n\t\t\t\tthis.views.delete(view);\n\t\t\t},\n\t\t);\n\t\tthis.views.add(view);\n\t\treturn view;\n\t}\n\n\tpublic get rootEvents(): Listenable<AnchorSetRootEvents> {\n\t\treturn this.forest.anchors.events;\n\t}\n\n\tpublic get editor(): ISharedTreeEditor {\n\t\tthis.checkNotDisposed();\n\t\treturn this.editLock.editor;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tthis.checkNotDisposed();\n\t\treturn this.forest.anchors.locate(anchor);\n\t}\n\n\tpublic get transaction(): Transactor {\n\t\treturn this.#transaction;\n\t}\n\t/**\n\t * The {@link Transactor} for this checkout.\n\t * @remarks In the context of a checkout, transactions allow edits to be batched into atomic units.\n\t * Edits made during a transaction will update the local state of the tree immediately, but will be squashed into a single edit when the transaction is committed.\n\t * If the transaction is aborted, the local state will be reset to what it was before the transaction began.\n\t * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.\n\t *\n\t * To avoid updating observers of the view state with intermediate results during a transaction,\n\t * use {@link ITreeCheckout#branch} and {@link ISharedTreeFork#merge}.\n\t */\n\t#transaction: SquashingTransactionStack<SharedTreeEditBuilder, SharedTreeChange>;\n\n\tpublic branch(): TreeCheckout {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The parent branch has already been disposed and can no longer create new branches.\",\n\t\t);\n\t\tthis.editLock.checkUnlocked(\"Branching\");\n\t\tconst anchors = new AnchorSet();\n\t\tconst branch = this.#transaction.activeBranch.fork();\n\t\tconst storedSchema = this.storedSchema.clone();\n\t\tconst forest = this.forest.clone(storedSchema, anchors);\n\t\tconst checkout = new TreeCheckout(\n\t\t\tbranch,\n\t\t\tfalse,\n\t\t\tthis.changeFamily,\n\t\t\tstoredSchema,\n\t\t\tforest,\n\t\t\tthis.mintRevisionTag,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis._removedRoots.clone(),\n\t\t\tthis.logger,\n\t\t\tthis.breaker,\n\t\t\tthis.disposeForksAfterTransaction,\n\t\t);\n\t\tthis.#events.emit(\"fork\", checkout);\n\t\treturn checkout;\n\t}\n\n\tpublic switchBranch(\n\t\tbranch: SharedTreeBranch<SharedTreeEditBuilder, SharedTreeChange>,\n\t): void {\n\t\t// TODO: Dispose old branch, if necessary\n\t\tassert(\n\t\t\t!this.#transaction.isInProgress(),\n\t\t\t0xc55 /* Cannot switch branches during a transaction */,\n\t\t);\n\t\tconst diff = diffHistories(\n\t\t\tthis.changeFamily.rebaser,\n\t\t\tthis.#transaction.branch.getHead(),\n\t\t\tbranch.getHead(),\n\t\t\tthis.mintRevisionTag,\n\t\t);\n\n\t\tthis.unregisterFromBranchEvents();\n\n\t\tthis.#transaction = this.createTransactionStack(branch);\n\t\tthis.editLock = new EditLock(this.#transaction.activeBranchEditor);\n\t\tthis.registerForBranchEvents();\n\n\t\t// TODO: Rework eventing\n\t\tthis.applyChange(diff);\n\t\tthis.#events.emit(\"afterBatch\");\n\t}\n\n\tpublic rebase(checkout: TreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tthis.editLock.checkUnlocked(\"Rebasing\");\n\t\tassert(\n\t\t\t!checkout.transaction.isInProgress(),\n\t\t\t0x9af /* A view cannot be rebased while it has a pending transaction */,\n\t\t);\n\t\tassert(\n\t\t\t!checkout.isSharedBranch,\n\t\t\t0xa5d /* Shared branches cannot be rebased onto another branch. */,\n\t\t);\n\n\t\tcheckout.#transaction.activeBranch.rebaseOnto(this.#transaction.activeBranch);\n\t}\n\n\tpublic rebaseOnto(checkout: ITreeCheckout): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch rebase has been disposed and cannot be rebased.\",\n\t\t);\n\t\tcheckout.rebase(this);\n\t}\n\n\tpublic merge(checkout: TreeCheckout): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged: boolean): void;\n\tpublic merge(checkout: TreeCheckout, disposeMerged = true): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The target of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tcheckout.checkNotDisposed(\n\t\t\t\"The source of the branch merge has been disposed and cannot be merged.\",\n\t\t);\n\t\tthis.editLock.checkUnlocked(\"Merging\");\n\t\tassert(\n\t\t\t!this.transaction.isInProgress(),\n\t\t\t0x9b0 /* Views cannot be merged into a view while it has a pending transaction */,\n\t\t);\n\t\twhile (checkout.transaction.isInProgress()) {\n\t\t\tcheckout.transaction.commit();\n\t\t}\n\t\tthis.#transaction.activeBranch.merge(checkout.#transaction.activeBranch);\n\t\tif (disposeMerged && !checkout.isSharedBranch) {\n\t\t\t// Dispose the merged checkout unless it is a shared branch.\n\t\t\tcheckout[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic updateSchema(newSchema: TreeStoredSchema, allowNonSupersetSchema?: true): void {\n\t\tthis.checkNotDisposed();\n\t\tif (allowNonSupersetSchema !== true) {\n\t\t\tassert(\n\t\t\t\tallowsRepoSuperset(defaultSchemaPolicy, this.storedSchema.clone(), newSchema),\n\t\t\t\t0xbe6 /* New schema must allow all documents allowed by old schema */,\n\t\t\t);\n\t\t}\n\t\tthis.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.editLock.checkUnlocked(\"Disposing a view\");\n\t\tthis[disposeSymbol]();\n\t}\n\n\tpublic [disposeSymbol](): void {\n\t\tthis.checkNotDisposed(\n\t\t\t\"The branch has already been disposed and cannot be disposed again.\",\n\t\t);\n\t\tthis.disposed = true;\n\t\tthis.#transaction.branch.dispose();\n\t\tthis.#transaction.dispose();\n\t\tthis.purgeRevertibles();\n\t\tfor (const view of this.views) {\n\t\t\tview.dispose();\n\t\t}\n\t\tthis.#events.emit(\"dispose\");\n\t}\n\n\tpublic getRemovedRoots(): [string | number | undefined, number, JsonableTree][] {\n\t\tthis.assertNoUntrackedRoots();\n\t\tconst trees: [string | number | undefined, number, JsonableTree][] = [];\n\t\tconst cursor = this.forest.allocateCursor(\"getRemovedRoots\");\n\t\tfor (const { id, root } of this._removedRoots.entries()) {\n\t\t\tconst parentField = this._removedRoots.toFieldKey(root);\n\t\t\tthis.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);\n\t\t\tconst tree = jsonableTreeFromCursor(cursor);\n\t\t\t// This method is used for tree consistency comparison.\n\t\t\tconst { major, minor } = id;\n\t\t\tconst finalizedMajor = major !== undefined ? this.revisionTagCodec.encode(major) : major;\n\t\t\ttrees.push([finalizedMajor, minor, tree]);\n\t\t}\n\t\tcursor.free();\n\t\treturn trees;\n\t}\n\n\t/**\n\t * This must be called on the root/main checkout after loading from a summary.\n\t * @remarks This pattern is necessary because the EditManager skips the normal process of applying commits to branches when loading a summary.\n\t * Instead, it simply {@link SharedTreeBranch#setHead | mutates} the branches directly which does not propagate the typical events throughout the rest of the system.\n\t */\n\tpublic load(): void {\n\t\t// Set the tip revision as the latest relevant revision for any removed roots that are loaded from a summary - this allows them to be garbage collected later.\n\t\t// When a load happens, the head of the trunk and the head of the local/main branch must be the same (this is enforced by SharedTree).\n\t\tthis._removedRoots.setRevisionsForLoadedData(this.#transaction.branch.getHead().revision);\n\t\t// The content of the checkout (e.g. the forest) has (maybe) changed, so fire an afterBatch event.\n\t\tthis.#events.emit(\"afterBatch\");\n\t}\n\n\tprivate purgeRevertibles(): void {\n\t\tfor (const revertible of this.revertibles) {\n\t\t\trevertible.dispose();\n\t\t}\n\t}\n\n\tprivate disposeRevertible(revertible: RevertibleAlpha, revision: RevisionTag): void {\n\t\tthis.revertibleCommitBranches.get(revision)?.dispose();\n\t\tthis.revertibleCommitBranches.delete(revision);\n\t\tthis.revertibles.delete(revertible);\n\t}\n\n\tprivate revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {\n\t\tthis.editLock.checkUnlocked(\"Reverting a commit\");\n\t\tif (this.transaction.isInProgress()) {\n\t\t\tthrow new UsageError(\"Undo is not yet supported during transactions.\");\n\t\t}\n\n\t\tconst revertibleBranch = this.revertibleCommitBranches.get(revision);\n\t\tassert(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);\n\t\tconst commitToRevert = revertibleBranch.getHead();\n\t\tconst revisionForInvert = this.mintRevisionTag();\n\n\t\tlet change = tagChange(\n\t\t\tthis.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert),\n\t\t\trevisionForInvert,\n\t\t);\n\n\t\tconst headCommit = this.#transaction.activeBranch.getHead();\n\t\t// Rebase the inverted change onto any commits that occurred after the undoable commits.\n\t\tif (commitToRevert !== headCommit) {\n\t\t\tchange = tagChange(\n\t\t\t\trebaseChange(\n\t\t\t\t\tthis.changeFamily.rebaser,\n\t\t\t\t\tchange,\n\t\t\t\t\tcommitToRevert,\n\t\t\t\t\theadCommit,\n\t\t\t\t\tthis.mintRevisionTag,\n\t\t\t\t).change,\n\t\t\t\trevisionForInvert,\n\t\t\t);\n\t\t}\n\n\t\tthis.#transaction.activeBranch.apply(\n\t\t\tchange,\n\t\t\tkind === CommitKind.Default || kind === CommitKind.Redo\n\t\t\t\t? CommitKind.Undo\n\t\t\t\t: CommitKind.Redo,\n\t\t);\n\n\t\t// Derive some stats about the reversion to return to the caller.\n\t\tlet revertAge = 0;\n\t\tlet currentCommit = headCommit;\n\t\twhile (commitToRevert.revision !== currentCommit.revision) {\n\t\t\trevertAge++;\n\n\t\t\tconst parentCommit = currentCommit.parent;\n\t\t\tassert(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);\n\t\t\tcurrentCommit = parentCommit;\n\t\t}\n\n\t\treturn { age: revertAge };\n\t}\n\n\tprivate assertNoUntrackedRoots(): void {\n\t\tconst cursor = this.forest.getCursorAboveDetachedFields();\n\t\tconst rootFields = new Set([rootFieldKey]);\n\t\tfor (const { root } of this._removedRoots.entries()) {\n\t\t\trootFields.add(this._removedRoots.toFieldKey(root));\n\t\t}\n\n\t\tif (!cursor.firstField()) {\n\t\t\treturn;\n\t\t}\n\n\t\tdo {\n\t\t\tconst field = cursor.getFieldKey();\n\t\t\tassert(\n\t\t\t\trootFields.has(field),\n\t\t\t\t0xa22 /* Forest has a root field which is unknown to the detached field index */,\n\t\t\t);\n\n\t\t\trootFields.delete(field);\n\t\t} while (cursor.nextField());\n\t}\n\n\t/**\n\t * `true` iff the given branch change event is due to a remote change\n\t */\n\tprivate isRemoteChangeEvent(event: SharedTreeBranchChange<SharedTreeChange>): boolean {\n\t\treturn (\n\t\t\t// Remote changes are only ever applied to shared branches\n\t\t\tthis.isSharedBranch &&\n\t\t\t// Remote changes are applied to the branch by rebasing it onto the trunk.\n\t\t\t// No other rebases are allowed on shared branches, so we can use this to detect remote changes.\n\t\t\tevent.type === \"rebase\"\n\t\t);\n\t}\n\n\t// #region Commit Validation\n\n\t/** Used to maintain the contract of {@link onCommitValid}(). */\n\treadonly #validatedCommits = new WeakMap<\n\t\tGraphCommit<SharedTreeChange>,\n\t\t((commit: GraphCommit<SharedTreeChange>) => void)[] | true\n\t>();\n\n\t/**\n\t * Registers a function to be called when the given commit is validated.\n\t * @remarks A commit is validated by the checkout after it has been applied to the checkout's state (e.g. it has an effect on the forest).\n\t * If the commit applies successfully (i.e. it does not raise any unexpected errors), the commit is considered valid and the registered function is called.\n\t * If the commit does not apply successfully (because it causes an unexpected error), the function is not called (and the checkout will left in an error state).\n\t *\n\t * If the commit has already been validated when this function is called, the function is called immediately and this function returns `true`.\n\t * Otherwise, the function is registered to be called later and this function returns `false`.\n\t */\n\tpublic onCommitValid(\n\t\tcommit: GraphCommit<SharedTreeChange>,\n\t\tfn: (commit: GraphCommit<SharedTreeChange>) => void,\n\t): boolean {\n\t\tconst validated = getOrCreate(this.#validatedCommits, commit, () => []);\n\t\tif (validated === true) {\n\t\t\tfn(commit);\n\t\t\treturn true;\n\t\t}\n\n\t\tvalidated.push(fn);\n\t\treturn false;\n\t}\n\n\t/** Mark the given commit as \"validated\" according to the contract of {@link onCommitValid}(). */\n\tprivate validateCommit(commit: GraphCommit<SharedTreeChange>): void {\n\t\tconst validated = getOrCreate(this.#validatedCommits, commit, () => []);\n\t\tif (validated !== true) {\n\t\t\tvalidated.forEach((fn) => fn(commit));\n\t\t\tthis.#validatedCommits.set(commit, true);\n\t\t}\n\t}\n\n\t// #endregion Commit Validation\n}\n\n/**\n * A helper class that assists {@link TreeCheckout} in preventing functionality from being used while the tree is in the middle of being edited.\n */\nclass EditLock {\n\t/**\n\t * Edits the tree by calling the methods of the editor passed into the {@link EditLock} constructor.\n\t * @remarks Edits will throw an error if the lock is currently locked.\n\t */\n\tpublic readonly editor: ISharedTreeEditor;\n\tprivate locked = false;\n\n\t/**\n\t * @param editor - an editor which will be used to create a new editor that is monitored to determine if any changes are happening to the tree.\n\t * Use {@link EditLock.editor} in place of the original editor to ensure that changes are monitored.\n\t */\n\tpublic constructor(editor: ISharedTreeEditor) {\n\t\tconst checkLock = (): void => this.checkUnlocked(\"Editing the tree\");\n\t\tthis.editor = {\n\t\t\tget schema() {\n\t\t\t\treturn editor.schema;\n\t\t\t},\n\t\t\tvalueField(...fieldArgs) {\n\t\t\t\tconst valueField = editor.valueField(...fieldArgs);\n\t\t\t\treturn {\n\t\t\t\t\tset(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\tvalueField.set(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\toptionalField(...fieldArgs) {\n\t\t\t\tconst optionalField = editor.optionalField(...fieldArgs);\n\t\t\t\treturn {\n\t\t\t\t\tset(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\toptionalField.set(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tsequenceField(...fieldArgs) {\n\t\t\t\tconst sequenceField = editor.sequenceField(...fieldArgs);\n\t\t\t\treturn {\n\t\t\t\t\tinsert(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\tsequenceField.insert(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t\tremove(...editArgs) {\n\t\t\t\t\t\tcheckLock();\n\t\t\t\t\t\tsequenceField.remove(...editArgs);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tmove(...moveArgs) {\n\t\t\t\tcheckLock();\n\t\t\t\teditor.move(...moveArgs);\n\t\t\t},\n\t\t\taddNodeExistsConstraint(path) {\n\t\t\t\teditor.addNodeExistsConstraint(path);\n\t\t\t},\n\t\t\taddNodeExistsConstraintOnRevert(path) {\n\t\t\t\teditor.addNodeExistsConstraintOnRevert(path);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Prevent further changes from being made to {@link EditLock.editor} until {@link EditLock.unlock} is called.\n\t * @remarks May only be called when the lock is not already locked.\n\t */\n\tpublic lock(): void {\n\t\tif (this.locked) {\n\t\t\tdebugger;\n\t\t}\n\t\tassert(!this.locked, 0xaa7 /* Checkout has already been locked */);\n\t\tthis.locked = true;\n\t}\n\n\t/**\n\t * Throws an error if the lock is currently locked.\n\t * @param action - The current action being performed by the user.\n\t * This must start with a capital letter, as it shows up as the first part of the error message and we want it to look nice.\n\t */\n\tpublic checkUnlocked<T extends string>(action: T extends Capitalize<T> ? T : never): void {\n\t\tif (this.locked) {\n\t\t\t// These type assertions ensure that the event name strings used here match the actual event names\n\t\t\tconst nodeChanged: keyof TreeChangeEvents = \"nodeChanged\";\n\t\t\tconst treeChanged: keyof TreeChangeEvents = \"treeChanged\";\n\t\t\tthrow new UsageError(\n\t\t\t\t`${action} is forbidden during a ${nodeChanged} or ${treeChanged} event`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Allow changes to be made to {@link EditLock.editor} again.\n\t * @remarks May only be called when the lock is currently locked.\n\t */\n\tpublic unlock(): void {\n\t\tassert(this.locked, 0xaa8 /* Checkout has not been locked */);\n\t\tthis.locked = false;\n\t}\n}\n\n/**\n * Keeps track of all new forks created until the returned function is invoked, which will dispose all of those for.\n * The returned function may only be called once.\n *\n * @param checkout - The tree checkout for which you want to monitor forks for disposal.\n * @returns a function which can be called to dispose all of the tracked forks.\n */\nfunction trackForksForDisposal(checkout: TreeCheckout): () => void {\n\tconst forks = new Set<TreeCheckout>();\n\tconst onDisposeUnSubscribes: (() => void)[] = [];\n\tconst onForkUnSubscribe = onForkTransitive(checkout, (fork) => {\n\t\tforks.add(fork);\n\t\tonDisposeUnSubscribes.push(fork.events.on(\"dispose\", () => forks.delete(fork)));\n\t});\n\tlet disposed = false;\n\treturn () => {\n\t\tassert(!disposed, 0xaa9 /* Forks may only be disposed once */);\n\t\tforks.forEach((fork) => fork.dispose());\n\t\tonDisposeUnSubscribes.forEach((unsubscribe) => unsubscribe());\n\t\tonForkUnSubscribe();\n\t\tdisposed = true;\n\t};\n}\n\nfunction verboseFromCursor(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n): VerboseTree {\n\tconst fields = customFromCursorStored(reader, schema, verboseFromCursor);\n\tconst nodeSchema =\n\t\tschema.get(reader.type) ?? fail(0xac9 /* missing schema for type in cursor */);\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn fields as CustomTreeValue;\n\t}\n\n\treturn {\n\t\ttype: reader.type,\n\t\tfields: fields as CustomTreeNode<IFluidHandle>,\n\t};\n}\n\ninterface SerializedChange {\n\tversion: 1;\n\trevision: RevisionTag;\n\tchange: JsonCompatibleReadOnly;\n\toriginatorId: SessionId;\n}\n\nfunction isSerializedChange(value: unknown): value is SerializedChange {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst change = value as Partial<SerializedChange>;\n\treturn (\n\t\tchange.version === 1 &&\n\t\t(change.revision === \"root\" || typeof change.revision === \"number\") &&\n\t\ttypeof change.originatorId === \"string\" &&\n\t\tisStableId(change.originatorId) &&\n\t\tchange.change !== undefined\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"editManagerCodecs.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/editManagerCodecs.ts"],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/core-utils/internal";
6
6
  import { getConfigForMinVersionForCollab, lowestMinVersionForCollab, } from "@fluidframework/runtime-utils/internal";
7
7
  import { FluidClientVersion, makeCodecFamily, makeDiscontinuedCodecVersion, } from "../codec/index.js";
8
8
  import { makeVersionDispatchingCodec } from "../codec/index.js";
9
- import { brand } from "../util/index.js";
9
+ import { brand, unbrand } from "../util/index.js";
10
10
  import { makeV1CodecWithVersion } from "./editManagerCodecsV1toV4.js";
11
- import { makeV5CodecWithVersion } from "./editManagerCodecsV5.js";
11
+ import { makeSharedBranchesCodecWithVersion } from "./editManagerCodecsVSharedBranches.js";
12
12
  import { EditManagerFormatVersion, editManagerFormatVersions, } from "./editManagerFormatCommons.js";
13
13
  /**
14
14
  * Convert a MinimumVersionForCollab to an EditManagerFormatVersion.
@@ -26,7 +26,7 @@ export function clientVersionToEditManagerFormatVersion(clientVersion, writeVers
26
26
  * Returns the version that should be used for testing shared branches.
27
27
  */
28
28
  export function editManagerFormatVersionSelectorForSharedBranches(clientVersion) {
29
- return brand(EditManagerFormatVersion.v5);
29
+ return brand(EditManagerFormatVersion.vSharedBranches);
30
30
  }
31
31
  function editManagerFormatVersionFromOptions(options) {
32
32
  const selector = options.editManagerFormatSelector ?? clientVersionToEditManagerFormatVersion;
@@ -40,22 +40,24 @@ export function makeEditManagerCodec(changeCodecs, dependentChangeFormatVersion,
40
40
  export function makeEditManagerCodecs(changeCodecs, dependentChangeFormatVersion, revisionTagCodec, options) {
41
41
  const registry = Array.from(editManagerFormatVersions, (version) => {
42
42
  switch (version) {
43
- case EditManagerFormatVersion.v1:
44
- case EditManagerFormatVersion.v2:
43
+ case unbrand(EditManagerFormatVersion.v1):
44
+ case unbrand(EditManagerFormatVersion.v2):
45
45
  return [version, makeDiscontinuedCodecVersion(options, version, "2.73.0")];
46
- case EditManagerFormatVersion.v3:
47
- case EditManagerFormatVersion.v4: {
46
+ case unbrand(EditManagerFormatVersion.v3):
47
+ case unbrand(EditManagerFormatVersion.v4): {
48
48
  const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
49
49
  return [
50
50
  version,
51
51
  makeV1CodecWithVersion(changeCodec, revisionTagCodec, options, version),
52
52
  ];
53
53
  }
54
- case EditManagerFormatVersion.v5: {
54
+ case unbrand(EditManagerFormatVersion.v5):
55
+ return [version, makeDiscontinuedCodecVersion(options, version, "2.74.0")];
56
+ case unbrand(EditManagerFormatVersion.vSharedBranches): {
55
57
  const changeCodec = changeCodecs.resolve(dependentChangeFormatVersion.lookup(version));
56
58
  return [
57
59
  version,
58
- makeV5CodecWithVersion(changeCodec, revisionTagCodec, options, version),
60
+ makeSharedBranchesCodecWithVersion(changeCodec, revisionTagCodec, options, version),
59
61
  ];
60
62
  }
61
63
  default: