@fluidframework/tree 2.118.1 → 3.0.1

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 (1234) hide show
  1. package/CHANGELOG.md +367 -75
  2. package/README.md +55 -52
  3. package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
  4. package/api-report/tree.alpha.api.md +130 -145
  5. package/api-report/tree.beta.api.md +122 -91
  6. package/api-report/tree.legacy.beta.api.md +122 -91
  7. package/api-report/tree.legacy.public.api.md +26 -43
  8. package/api-report/tree.public.api.md +26 -43
  9. package/dist/api.d.ts +9 -1
  10. package/dist/api.d.ts.map +1 -1
  11. package/dist/api.js +2 -3
  12. package/dist/api.js.map +1 -1
  13. package/dist/codec/codec.d.ts +2 -2
  14. package/dist/codec/codec.d.ts.map +1 -1
  15. package/dist/codec/codec.js +9 -7
  16. package/dist/codec/codec.js.map +1 -1
  17. package/dist/codec/discriminatedUnions.js +1 -0
  18. package/dist/codec/discriminatedUnions.js.map +1 -1
  19. package/dist/codec/versioned/codec.d.ts.map +1 -1
  20. package/dist/codec/versioned/codec.js +4 -2
  21. package/dist/codec/versioned/codec.js.map +1 -1
  22. package/dist/componentApi.d.ts.map +1 -1
  23. package/dist/componentApi.js +20 -17
  24. package/dist/componentApi.js.map +1 -1
  25. package/dist/core/change-family/editBuilder.js +1 -0
  26. package/dist/core/change-family/editBuilder.js.map +1 -1
  27. package/dist/core/forest/editableForest.js +1 -2
  28. package/dist/core/forest/editableForest.js.map +1 -1
  29. package/dist/core/forest/forest.js +3 -3
  30. package/dist/core/forest/forest.js.map +1 -1
  31. package/dist/core/index.d.ts +2 -2
  32. package/dist/core/index.d.ts.map +1 -1
  33. package/dist/core/index.js +9 -5
  34. package/dist/core/index.js.map +1 -1
  35. package/dist/core/rebase/changeRebaser.js +5 -5
  36. package/dist/core/rebase/changeRebaser.js.map +1 -1
  37. package/dist/core/rebase/index.d.ts +1 -1
  38. package/dist/core/rebase/index.d.ts.map +1 -1
  39. package/dist/core/rebase/index.js +2 -1
  40. package/dist/core/rebase/index.js.map +1 -1
  41. package/dist/core/rebase/revisionTagCodec.d.ts +1 -1
  42. package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
  43. package/dist/core/rebase/revisionTagCodec.js +3 -1
  44. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  45. package/dist/core/rebase/types.d.ts +12 -1
  46. package/dist/core/rebase/types.d.ts.map +1 -1
  47. package/dist/core/rebase/types.js +19 -15
  48. package/dist/core/rebase/types.js.map +1 -1
  49. package/dist/core/rebase/utils.js +9 -10
  50. package/dist/core/rebase/utils.js.map +1 -1
  51. package/dist/core/schema-stored/schema.js +9 -4
  52. package/dist/core/schema-stored/schema.js.map +1 -1
  53. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  54. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  55. package/dist/core/schema-stored/storedSchemaRepository.js +6 -4
  56. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  57. package/dist/core/tree/anchorSet.d.ts +1 -1
  58. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  59. package/dist/core/tree/anchorSet.js +62 -55
  60. package/dist/core/tree/anchorSet.js.map +1 -1
  61. package/dist/core/tree/chunk.js +2 -2
  62. package/dist/core/tree/chunk.js.map +1 -1
  63. package/dist/core/tree/cursor.js +12 -12
  64. package/dist/core/tree/cursor.js.map +1 -1
  65. package/dist/core/tree/deltaUtil.d.ts +34 -9
  66. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  67. package/dist/core/tree/deltaUtil.js +51 -17
  68. package/dist/core/tree/deltaUtil.js.map +1 -1
  69. package/dist/core/tree/detachedFieldIndex.js +23 -21
  70. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  71. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +10 -10
  72. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  73. package/dist/core/tree/detachedFieldIndexCodecCommon.js +1 -2
  74. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  75. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  76. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  77. package/dist/core/tree/detachedFieldIndexCodecV2.js +3 -2
  78. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  79. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +3 -3
  80. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  81. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +1 -1
  82. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  83. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  84. package/dist/core/tree/index.d.ts +1 -1
  85. package/dist/core/tree/index.d.ts.map +1 -1
  86. package/dist/core/tree/index.js +7 -4
  87. package/dist/core/tree/index.js.map +1 -1
  88. package/dist/core/tree/mapTree.js +1 -2
  89. package/dist/core/tree/mapTree.js.map +1 -1
  90. package/dist/core/tree/pathTree.js +7 -8
  91. package/dist/core/tree/pathTree.js.map +1 -1
  92. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  93. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  94. package/dist/core/tree/sparseTree.js +17 -13
  95. package/dist/core/tree/sparseTree.js.map +1 -1
  96. package/dist/core/tree/treeTextFormat.js +4 -5
  97. package/dist/core/tree/treeTextFormat.js.map +1 -1
  98. package/dist/core/tree/types.js +3 -3
  99. package/dist/core/tree/types.js.map +1 -1
  100. package/dist/core/tree/visitDelta.js +1 -2
  101. package/dist/core/tree/visitDelta.js.map +1 -1
  102. package/dist/core/tree/visitorUtils.js +5 -6
  103. package/dist/core/tree/visitorUtils.js.map +1 -1
  104. package/dist/entrypoints/alpha.d.ts +1 -1
  105. package/dist/entrypoints/alpha.d.ts.map +1 -1
  106. package/dist/entrypoints/alpha.js +6 -4
  107. package/dist/entrypoints/alpha.js.map +1 -1
  108. package/dist/entrypoints/beta.d.ts +1 -1
  109. package/dist/entrypoints/beta.d.ts.map +1 -1
  110. package/dist/entrypoints/beta.js +2 -2
  111. package/dist/entrypoints/beta.js.map +1 -1
  112. package/dist/entrypoints/legacy.d.ts +1 -1
  113. package/dist/entrypoints/legacy.d.ts.map +1 -1
  114. package/dist/entrypoints/legacy.js +2 -2
  115. package/dist/entrypoints/legacy.js.map +1 -1
  116. package/dist/entrypoints/public.d.ts +1 -1
  117. package/dist/entrypoints/public.d.ts.map +1 -1
  118. package/dist/entrypoints/public.js +1 -2
  119. package/dist/entrypoints/public.js.map +1 -1
  120. package/dist/extensibleUnionNode.d.ts.map +1 -1
  121. package/dist/extensibleUnionNode.js +1 -1
  122. package/dist/extensibleUnionNode.js.map +1 -1
  123. package/dist/feature-libraries/changeAtomIdBTree.js +3 -4
  124. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  125. package/dist/feature-libraries/changeAtomIdCodec.js +1 -2
  126. package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
  127. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  128. package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -1
  129. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  130. package/dist/feature-libraries/chunked-forest/chunkTree.js +28 -20
  131. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  132. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  133. package/dist/feature-libraries/chunked-forest/chunkedForest.js +22 -16
  134. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  135. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +9 -11
  136. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  137. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +15 -7
  138. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  139. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +7 -3
  140. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  141. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -2
  142. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  143. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  144. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -0
  145. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  146. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +33 -17
  147. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  148. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +2 -2
  149. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  150. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +2 -2
  151. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
  152. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +11 -2
  153. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  154. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +5 -6
  155. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  156. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -3
  157. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  158. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +1 -0
  159. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  160. package/dist/feature-libraries/chunked-forest/uniformChunk.js +73 -15
  161. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  162. package/dist/feature-libraries/comparison-forest/comparisonForest.js +79 -79
  163. package/dist/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  164. package/dist/feature-libraries/cursorComparator.d.ts +8 -0
  165. package/dist/feature-libraries/cursorComparator.d.ts.map +1 -1
  166. package/dist/feature-libraries/cursorComparator.js +43 -10
  167. package/dist/feature-libraries/cursorComparator.js.map +1 -1
  168. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +6 -3
  169. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  170. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +2 -2
  171. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  172. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +2 -0
  173. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  174. package/dist/feature-libraries/deltaUtils.js +2 -3
  175. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  176. package/dist/feature-libraries/detachedFieldIndexSummarizer.js +2 -0
  177. package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  178. package/dist/feature-libraries/editableTreeBinder.js +1 -2
  179. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  180. package/dist/feature-libraries/flex-tree/context.js +19 -3
  181. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  182. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +2 -2
  183. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  184. package/dist/feature-libraries/flex-tree/lazyEntity.js +14 -14
  185. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  186. package/dist/feature-libraries/flex-tree/lazyField.js +28 -30
  187. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  188. package/dist/feature-libraries/flex-tree/lazyNode.js +24 -23
  189. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  190. package/dist/feature-libraries/flex-tree/observer.js +2 -2
  191. package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
  192. package/dist/feature-libraries/flex-tree/utilities.js +5 -5
  193. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  194. package/dist/feature-libraries/forest-summary/forestSummarizer.js +122 -117
  195. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  196. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +49 -32
  197. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  198. package/dist/feature-libraries/forest-summary/summaryTypes.js +2 -3
  199. package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
  200. package/dist/feature-libraries/indexing/anchorTreeIndex.js +35 -31
  201. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  202. package/dist/feature-libraries/mapTreeCursor.js +6 -7
  203. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  204. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -3
  205. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  206. package/dist/feature-libraries/modular-schema/comparison.js +6 -7
  207. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  208. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +4 -4
  209. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  210. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -12
  211. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  212. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +63 -10
  213. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  214. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +3 -3
  215. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  216. package/dist/feature-libraries/modular-schema/fieldKind.js +10 -0
  217. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  218. package/dist/feature-libraries/modular-schema/filterEdits.d.ts +13 -0
  219. package/dist/feature-libraries/modular-schema/filterEdits.d.ts.map +1 -0
  220. package/dist/feature-libraries/modular-schema/filterEdits.js +51 -0
  221. package/dist/feature-libraries/modular-schema/filterEdits.js.map +1 -0
  222. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  223. package/dist/feature-libraries/modular-schema/genericFieldKind.js +7 -4
  224. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  225. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -2
  226. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  227. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -2
  228. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  229. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js +1 -2
  230. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  231. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  232. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  233. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  234. package/dist/feature-libraries/modular-schema/invert.d.ts +1 -1
  235. package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -1
  236. package/dist/feature-libraries/modular-schema/invert.js +5 -30
  237. package/dist/feature-libraries/modular-schema/invert.js.map +1 -1
  238. package/dist/feature-libraries/modular-schema/isNeverTree.js +4 -5
  239. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  240. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +5 -7
  241. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  242. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +459 -10
  243. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  244. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +14 -15
  245. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  246. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -2
  247. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  248. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  249. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  250. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -10
  251. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  252. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +30 -97
  253. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  254. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +9 -9
  255. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  256. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +4 -4
  257. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +1 -2
  258. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  259. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +13 -1
  260. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  261. package/dist/feature-libraries/modular-schema/modularChangeUtils.js +115 -12
  262. package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  263. package/dist/feature-libraries/modular-schema/prune.d.ts +2 -3
  264. package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -1
  265. package/dist/feature-libraries/modular-schema/prune.js +25 -8
  266. package/dist/feature-libraries/modular-schema/prune.js.map +1 -1
  267. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -3
  268. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  269. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +2 -2
  270. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -1
  271. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +3 -3
  272. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  273. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  274. package/dist/feature-libraries/object-forest/objectForest.js +274 -267
  275. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  276. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  277. package/dist/feature-libraries/optional-field/optionalField.js +27 -35
  278. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  279. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +7 -7
  280. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  281. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +8 -8
  282. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  283. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +1 -2
  284. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  285. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  286. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +1 -2
  287. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  288. package/dist/feature-libraries/schema-index/schemaSummarizer.js +3 -0
  289. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  290. package/dist/feature-libraries/schemaChecker.js +5 -5
  291. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  292. package/dist/feature-libraries/sequence-field/compose.js +8 -2
  293. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  294. package/dist/feature-libraries/sequence-field/filterEdits.d.ts +3 -3
  295. package/dist/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -1
  296. package/dist/feature-libraries/sequence-field/filterEdits.js +29 -11
  297. package/dist/feature-libraries/sequence-field/filterEdits.js.map +1 -1
  298. package/dist/feature-libraries/sequence-field/formatV1.d.ts +102 -102
  299. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  300. package/dist/feature-libraries/sequence-field/formatV2.d.ts +79 -79
  301. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  302. package/dist/feature-libraries/sequence-field/formatV3.d.ts +56 -56
  303. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  304. package/dist/feature-libraries/sequence-field/invert.js +1 -2
  305. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  306. package/dist/feature-libraries/sequence-field/markListFactory.js +3 -4
  307. package/dist/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  308. package/dist/feature-libraries/sequence-field/markQueue.js +4 -2
  309. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  310. package/dist/feature-libraries/sequence-field/moveEffectTable.js +9 -9
  311. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  312. package/dist/feature-libraries/sequence-field/prune.js +1 -2
  313. package/dist/feature-libraries/sequence-field/prune.js.map +1 -1
  314. package/dist/feature-libraries/sequence-field/rebase.js +7 -2
  315. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  316. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +1 -2
  317. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  318. package/dist/feature-libraries/sequence-field/replaceRevisions.js +1 -2
  319. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  320. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -3
  321. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  322. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -2
  323. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  324. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  325. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -9
  326. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  327. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -2
  328. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  329. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
  330. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  331. package/dist/feature-libraries/sequence-field/utils.js +54 -67
  332. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  333. package/dist/feature-libraries/treeCursorUtils.js +19 -15
  334. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  335. package/dist/feature-libraries/treeTextCursor.js +8 -8
  336. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  337. package/dist/feature-libraries/valueUtilities.js +4 -5
  338. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  339. package/dist/index.d.ts +4 -29
  340. package/dist/index.d.ts.map +1 -1
  341. package/dist/index.js +6 -9
  342. package/dist/index.js.map +1 -1
  343. package/dist/internalTypes.d.ts +1 -1
  344. package/dist/internalTypes.d.ts.map +1 -1
  345. package/dist/internalTypes.js.map +1 -1
  346. package/dist/packageVersion.d.ts +1 -1
  347. package/dist/packageVersion.d.ts.map +1 -1
  348. package/dist/packageVersion.js +1 -1
  349. package/dist/packageVersion.js.map +1 -1
  350. package/dist/serializableDomainSchema.d.ts +1 -1
  351. package/dist/shared-tree/history.d.ts.map +1 -1
  352. package/dist/shared-tree/history.js +32 -13
  353. package/dist/shared-tree/history.js.map +1 -1
  354. package/dist/shared-tree/independentView.d.ts +27 -3
  355. package/dist/shared-tree/independentView.d.ts.map +1 -1
  356. package/dist/shared-tree/independentView.js +36 -7
  357. package/dist/shared-tree/independentView.js.map +1 -1
  358. package/dist/shared-tree/index.d.ts +2 -1
  359. package/dist/shared-tree/index.d.ts.map +1 -1
  360. package/dist/shared-tree/index.js +6 -2
  361. package/dist/shared-tree/index.js.map +1 -1
  362. package/dist/shared-tree/isAuditableFromOutcome.js +1 -2
  363. package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -1
  364. package/dist/shared-tree/schematizeTree.js +3 -4
  365. package/dist/shared-tree/schematizeTree.js.map +1 -1
  366. package/dist/shared-tree/schematizingTreeView.d.ts +2 -2
  367. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  368. package/dist/shared-tree/schematizingTreeView.js +59 -26
  369. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  370. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  371. package/dist/shared-tree/sharedTree.js +28 -19
  372. package/dist/shared-tree/sharedTree.js.map +1 -1
  373. package/dist/shared-tree/sharedTreeChangeCodecs.js +3 -3
  374. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  375. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  376. package/dist/shared-tree/sharedTreeChangeEnricher.js +12 -4
  377. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  378. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  379. package/dist/shared-tree/sharedTreeChangeFamily.js +11 -8
  380. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  381. package/dist/shared-tree/sharedTreeChangeFormat.js +2 -3
  382. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  383. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -0
  384. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  385. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
  386. package/dist/shared-tree/transactionMinimize.js +2 -1
  387. package/dist/shared-tree/transactionMinimize.js.map +1 -1
  388. package/dist/shared-tree/transactionPostProcessor.js +2 -3
  389. package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
  390. package/dist/shared-tree/tree.js +2 -2
  391. package/dist/shared-tree/tree.js.map +1 -1
  392. package/dist/shared-tree/treeAlpha.d.ts +5 -16
  393. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  394. package/dist/shared-tree/treeAlpha.js +18 -11
  395. package/dist/shared-tree/treeAlpha.js.map +1 -1
  396. package/{lib/simple-tree/api → dist/shared-tree}/treeBeta.d.ts +8 -65
  397. package/dist/shared-tree/treeBeta.d.ts.map +1 -0
  398. package/dist/shared-tree/treeBeta.js +70 -0
  399. package/dist/shared-tree/treeBeta.js.map +1 -0
  400. package/dist/shared-tree/treeCheckout.d.ts +5 -0
  401. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  402. package/dist/shared-tree/treeCheckout.js +986 -907
  403. package/dist/shared-tree/treeCheckout.js.map +1 -1
  404. package/dist/shared-tree/unhydratedTreeContext.js +3 -4
  405. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  406. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  407. package/dist/shared-tree-core/branch.js +24 -20
  408. package/dist/shared-tree-core/branch.js.map +1 -1
  409. package/dist/shared-tree-core/branchCommitCounter.js +35 -32
  410. package/dist/shared-tree-core/branchCommitCounter.js.map +1 -1
  411. package/dist/shared-tree-core/branchCommitEnricher.js +9 -8
  412. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  413. package/dist/shared-tree-core/branchIdCodec.js +2 -3
  414. package/dist/shared-tree-core/branchIdCodec.js.map +1 -1
  415. package/dist/shared-tree-core/customMetadataCodec.js +2 -3
  416. package/dist/shared-tree-core/customMetadataCodec.js.map +1 -1
  417. package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -1
  418. package/dist/shared-tree-core/defaultResubmitMachine.js +11 -9
  419. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  420. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  421. package/dist/shared-tree-core/editManager.js +73 -44
  422. package/dist/shared-tree-core/editManager.js.map +1 -1
  423. package/dist/shared-tree-core/editManagerCodecs.js +3 -3
  424. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  425. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  426. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  427. package/dist/shared-tree-core/editManagerCodecsCommons.js +33 -36
  428. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  429. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -2
  430. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  431. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -2
  432. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  433. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +11 -11
  434. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  435. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +5 -4
  436. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  437. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +10 -9
  438. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  439. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  440. package/dist/shared-tree-core/editManagerSummarizer.js +6 -1
  441. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  442. package/dist/shared-tree-core/messageCodecV1ToV4.js +1 -2
  443. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  444. package/dist/shared-tree-core/messageCodecVSharedBranches.js +1 -2
  445. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  446. package/dist/shared-tree-core/messageCodecs.js +3 -3
  447. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  448. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  449. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  450. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +3 -2
  451. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  452. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  453. package/dist/shared-tree-core/sharedTreeCore.js +44 -22
  454. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  455. package/dist/shared-tree-core/summaryTypes.js +2 -2
  456. package/dist/shared-tree-core/summaryTypes.js.map +1 -1
  457. package/dist/shared-tree-core/transaction.js +36 -39
  458. package/dist/shared-tree-core/transaction.js.map +1 -1
  459. package/dist/shared-tree-core/versionedSummarizer.js +4 -0
  460. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  461. package/dist/simple-tree/api/cloneTree.d.ts +11 -0
  462. package/dist/simple-tree/api/cloneTree.d.ts.map +1 -0
  463. package/dist/simple-tree/api/cloneTree.js +31 -0
  464. package/dist/simple-tree/api/cloneTree.js.map +1 -0
  465. package/dist/simple-tree/api/conciseTree.js +2 -3
  466. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  467. package/dist/simple-tree/api/configuration.js +21 -2
  468. package/dist/simple-tree/api/configuration.js.map +1 -1
  469. package/dist/simple-tree/api/create.js +2 -3
  470. package/dist/simple-tree/api/create.js.map +1 -1
  471. package/dist/simple-tree/api/customTree.js +6 -6
  472. package/dist/simple-tree/api/customTree.js.map +1 -1
  473. package/dist/simple-tree/api/dirtyIndex.js +1 -2
  474. package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
  475. package/dist/simple-tree/api/discrepancies.js +2 -3
  476. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  477. package/dist/simple-tree/api/eraseSchemaDetails.js +2 -3
  478. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  479. package/dist/simple-tree/api/getJsonSchema.js +1 -2
  480. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  481. package/dist/simple-tree/api/getSimpleSchema.js +1 -2
  482. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  483. package/dist/simple-tree/api/identifierIndex.js +1 -2
  484. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  485. package/dist/simple-tree/api/incrementalAllowedTypes.js +2 -2
  486. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  487. package/dist/simple-tree/api/index.d.ts +3 -3
  488. package/dist/simple-tree/api/index.d.ts.map +1 -1
  489. package/dist/simple-tree/api/index.js +4 -7
  490. package/dist/simple-tree/api/index.js.map +1 -1
  491. package/dist/simple-tree/api/schemaCompatibilityTester.js +2 -3
  492. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  493. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -7
  494. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  495. package/dist/simple-tree/api/schemaCreationUtilities.js +6 -9
  496. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  497. package/dist/simple-tree/api/schemaFactory.d.ts +4 -9
  498. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  499. package/dist/simple-tree/api/schemaFactory.js +13 -12
  500. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  501. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +20 -22
  502. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  503. package/dist/simple-tree/api/schemaFactoryAlpha.js +78 -81
  504. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  505. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +7 -9
  506. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  507. package/dist/simple-tree/api/schemaFactoryBeta.js +32 -35
  508. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  509. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -2
  510. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  511. package/dist/simple-tree/api/schemaFromSimple.js +1 -2
  512. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  513. package/dist/simple-tree/api/schemaStatics.d.ts +7 -7
  514. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  515. package/dist/simple-tree/api/simpleSchemaCodec.js +2 -3
  516. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  517. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +2 -3
  518. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  519. package/dist/simple-tree/api/simpleTreeIndex.js +1 -2
  520. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  521. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +46 -2
  522. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  523. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +54 -12
  524. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  525. package/dist/simple-tree/api/storedSchema.js +2 -3
  526. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  527. package/dist/simple-tree/api/transactionTypes.d.ts +4 -4
  528. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  529. package/dist/simple-tree/api/tree.d.ts +80 -61
  530. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  531. package/dist/simple-tree/api/tree.js +3 -5
  532. package/dist/simple-tree/api/tree.js.map +1 -1
  533. package/dist/simple-tree/api/treeChangeEvents.d.ts +16 -4
  534. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  535. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  536. package/dist/simple-tree/api/treeChangeEventsBeta.d.ts +209 -0
  537. package/dist/simple-tree/api/treeChangeEventsBeta.d.ts.map +1 -0
  538. package/dist/simple-tree/api/{treeAlpha.js → treeChangeEventsBeta.js} +1 -1
  539. package/dist/simple-tree/api/treeChangeEventsBeta.js.map +1 -0
  540. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -75
  541. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  542. package/dist/simple-tree/api/treeNodeApi.js +7 -7
  543. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  544. package/dist/simple-tree/api/typesUnsafe.d.ts +8 -6
  545. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  546. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  547. package/dist/simple-tree/api/verboseTree.js +5 -6
  548. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  549. package/dist/simple-tree/core/allowedTypes.js +22 -13
  550. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  551. package/dist/simple-tree/core/context.js +3 -0
  552. package/dist/simple-tree/core/context.js.map +1 -1
  553. package/dist/simple-tree/core/flexList.js +2 -3
  554. package/dist/simple-tree/core/flexList.js.map +1 -1
  555. package/dist/simple-tree/core/getOrCreateNode.js +2 -3
  556. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  557. package/dist/simple-tree/core/index.d.ts +1 -1
  558. package/dist/simple-tree/core/index.d.ts.map +1 -1
  559. package/dist/simple-tree/core/index.js +2 -2
  560. package/dist/simple-tree/core/index.js.map +1 -1
  561. package/dist/simple-tree/core/treeNode.d.ts +3 -4
  562. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  563. package/dist/simple-tree/core/treeNode.js +31 -32
  564. package/dist/simple-tree/core/treeNode.js.map +1 -1
  565. package/dist/simple-tree/core/treeNodeKernel.js +194 -192
  566. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  567. package/dist/simple-tree/core/treeNodeSchema.js +3 -3
  568. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  569. package/dist/simple-tree/core/treeNodeValid.js +23 -23
  570. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  571. package/dist/simple-tree/core/types.js +1 -2
  572. package/dist/simple-tree/core/types.js.map +1 -1
  573. package/dist/simple-tree/core/unhydratedFlexTree.js +177 -150
  574. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  575. package/dist/simple-tree/core/walkSchema.js +2 -3
  576. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  577. package/dist/simple-tree/core/withType.d.ts +7 -9
  578. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  579. package/dist/simple-tree/core/withType.js +6 -7
  580. package/dist/simple-tree/core/withType.js.map +1 -1
  581. package/dist/simple-tree/createContext.js +2 -3
  582. package/dist/simple-tree/createContext.js.map +1 -1
  583. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  584. package/dist/simple-tree/fieldSchema.js +33 -15
  585. package/dist/simple-tree/fieldSchema.js.map +1 -1
  586. package/dist/simple-tree/getTreeNodeForField.js +1 -2
  587. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  588. package/dist/simple-tree/index.d.ts +2 -2
  589. package/dist/simple-tree/index.d.ts.map +1 -1
  590. package/dist/simple-tree/index.js +5 -8
  591. package/dist/simple-tree/index.js.map +1 -1
  592. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  593. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  594. package/dist/simple-tree/leafNodeSchema.js +18 -17
  595. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  596. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -2
  597. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  598. package/dist/simple-tree/node-kinds/array/arrayNode.js +31 -33
  599. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  600. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  601. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js +2 -2
  602. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  603. package/dist/simple-tree/node-kinds/common.js +1 -2
  604. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  605. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +6 -6
  606. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  607. package/dist/simple-tree/node-kinds/map/mapNode.js +10 -16
  608. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  609. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  610. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js +2 -2
  611. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  612. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  613. package/dist/simple-tree/node-kinds/object/objectNode.js +27 -28
  614. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  615. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +1 -1
  616. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  617. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js +2 -2
  618. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  619. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  620. package/dist/simple-tree/node-kinds/record/recordNode.js +10 -13
  621. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  622. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -2
  623. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  624. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js +2 -2
  625. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  626. package/dist/simple-tree/prepareForInsertion.js +4 -5
  627. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  628. package/dist/simple-tree/toStoredSchema.js +11 -11
  629. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  630. package/dist/simple-tree/treeSchema.js +1 -2
  631. package/dist/simple-tree/treeSchema.js.map +1 -1
  632. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +3 -4
  633. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  634. package/dist/simple-tree/walkFieldSchema.js +1 -2
  635. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  636. package/dist/tableSchema.d.ts +2 -87
  637. package/dist/tableSchema.d.ts.map +1 -1
  638. package/dist/tableSchema.js +309 -275
  639. package/dist/tableSchema.js.map +1 -1
  640. package/dist/text/codePointUtils.d.ts +16 -3
  641. package/dist/text/codePointUtils.d.ts.map +1 -1
  642. package/dist/text/codePointUtils.js +24 -13
  643. package/dist/text/codePointUtils.js.map +1 -1
  644. package/dist/text/textDomain.d.ts +7 -1
  645. package/dist/text/textDomain.d.ts.map +1 -1
  646. package/dist/text/textDomain.js +32 -28
  647. package/dist/text/textDomain.js.map +1 -1
  648. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  649. package/dist/text/textDomainFormatted.js +45 -34
  650. package/dist/text/textDomainFormatted.js.map +1 -1
  651. package/dist/text/textDomainFormattedDefault.js +2 -5
  652. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  653. package/dist/treeDataStore.js +2 -3
  654. package/dist/treeDataStore.js.map +1 -1
  655. package/dist/treeFactory.js +7 -7
  656. package/dist/treeFactory.js.map +1 -1
  657. package/dist/util/arrayUtilities.js +5 -6
  658. package/dist/util/arrayUtilities.js.map +1 -1
  659. package/dist/util/bTreeUtils.js +3 -4
  660. package/dist/util/bTreeUtils.js.map +1 -1
  661. package/dist/util/brand.js +6 -5
  662. package/dist/util/brand.js.map +1 -1
  663. package/dist/util/brandedMap.js +2 -3
  664. package/dist/util/brandedMap.js.map +1 -1
  665. package/dist/util/breakable.d.ts.map +1 -1
  666. package/dist/util/breakable.js +7 -4
  667. package/dist/util/breakable.js.map +1 -1
  668. package/dist/util/cloneWithReplacements.js +1 -2
  669. package/dist/util/cloneWithReplacements.js.map +1 -1
  670. package/dist/util/compressedIds.js +29 -7
  671. package/dist/util/compressedIds.js.map +1 -1
  672. package/dist/util/idAllocator.js +3 -3
  673. package/dist/util/idAllocator.js.map +1 -1
  674. package/dist/util/nestedMap.js +15 -17
  675. package/dist/util/nestedMap.js.map +1 -1
  676. package/dist/util/nestedSet.js +2 -3
  677. package/dist/util/nestedSet.js.map +1 -1
  678. package/dist/util/offsetList.js +2 -4
  679. package/dist/util/offsetList.js.map +1 -1
  680. package/dist/util/opaque.js +2 -3
  681. package/dist/util/opaque.js.map +1 -1
  682. package/dist/util/rangeMap.js +6 -2
  683. package/dist/util/rangeMap.js.map +1 -1
  684. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  685. package/dist/util/referenceCounting.js +1 -0
  686. package/dist/util/referenceCounting.js.map +1 -1
  687. package/dist/util/stackyIterator.js +3 -2
  688. package/dist/util/stackyIterator.js.map +1 -1
  689. package/dist/util/typeUtils.js +1 -2
  690. package/dist/util/typeUtils.js.map +1 -1
  691. package/dist/util/typeboxBrand.js +2 -3
  692. package/dist/util/typeboxBrand.js.map +1 -1
  693. package/dist/util/utils.d.ts +2 -2
  694. package/dist/util/utils.d.ts.map +1 -1
  695. package/dist/util/utils.js +32 -32
  696. package/dist/util/utils.js.map +1 -1
  697. package/lib/api.d.ts +9 -1
  698. package/lib/api.d.ts.map +1 -1
  699. package/lib/api.js.map +1 -1
  700. package/lib/codec/codec.d.ts +2 -2
  701. package/lib/codec/codec.d.ts.map +1 -1
  702. package/lib/codec/codec.js +2 -0
  703. package/lib/codec/codec.js.map +1 -1
  704. package/lib/codec/discriminatedUnions.js +1 -0
  705. package/lib/codec/discriminatedUnions.js.map +1 -1
  706. package/lib/codec/versioned/codec.d.ts.map +1 -1
  707. package/lib/codec/versioned/codec.js +2 -0
  708. package/lib/codec/versioned/codec.js.map +1 -1
  709. package/lib/componentApi.d.ts.map +1 -1
  710. package/lib/componentApi.js +20 -17
  711. package/lib/componentApi.js.map +1 -1
  712. package/lib/core/change-family/editBuilder.js +1 -0
  713. package/lib/core/change-family/editBuilder.js.map +1 -1
  714. package/lib/core/index.d.ts +2 -2
  715. package/lib/core/index.d.ts.map +1 -1
  716. package/lib/core/index.js +2 -2
  717. package/lib/core/index.js.map +1 -1
  718. package/lib/core/rebase/index.d.ts +1 -1
  719. package/lib/core/rebase/index.d.ts.map +1 -1
  720. package/lib/core/rebase/index.js +1 -1
  721. package/lib/core/rebase/index.js.map +1 -1
  722. package/lib/core/rebase/revisionTagCodec.js +3 -1
  723. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  724. package/lib/core/rebase/types.d.ts +12 -1
  725. package/lib/core/rebase/types.d.ts.map +1 -1
  726. package/lib/core/rebase/types.js +3 -0
  727. package/lib/core/rebase/types.js.map +1 -1
  728. package/lib/core/schema-stored/schema.js +5 -0
  729. package/lib/core/schema-stored/schema.js.map +1 -1
  730. package/lib/core/schema-stored/storedSchemaRepository.js +4 -2
  731. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  732. package/lib/core/tree/anchorSet.js +61 -54
  733. package/lib/core/tree/anchorSet.js.map +1 -1
  734. package/lib/core/tree/deltaUtil.d.ts +34 -9
  735. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  736. package/lib/core/tree/deltaUtil.js +41 -10
  737. package/lib/core/tree/deltaUtil.js.map +1 -1
  738. package/lib/core/tree/detachedFieldIndex.js +23 -21
  739. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  740. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +10 -10
  741. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  742. package/lib/core/tree/detachedFieldIndexCodecV1.js +2 -0
  743. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  744. package/lib/core/tree/detachedFieldIndexCodecV2.js +2 -0
  745. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  746. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +3 -3
  747. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  748. package/lib/core/tree/index.d.ts +1 -1
  749. package/lib/core/tree/index.d.ts.map +1 -1
  750. package/lib/core/tree/index.js +1 -1
  751. package/lib/core/tree/index.js.map +1 -1
  752. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  753. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  754. package/lib/core/tree/sparseTree.js +15 -11
  755. package/lib/core/tree/sparseTree.js.map +1 -1
  756. package/lib/entrypoints/alpha.d.ts +1 -1
  757. package/lib/entrypoints/alpha.d.ts.map +1 -1
  758. package/lib/entrypoints/alpha.js +1 -1
  759. package/lib/entrypoints/alpha.js.map +1 -1
  760. package/lib/entrypoints/beta.d.ts +1 -1
  761. package/lib/entrypoints/beta.d.ts.map +1 -1
  762. package/lib/entrypoints/beta.js +1 -1
  763. package/lib/entrypoints/beta.js.map +1 -1
  764. package/lib/entrypoints/legacy.d.ts +1 -1
  765. package/lib/entrypoints/legacy.d.ts.map +1 -1
  766. package/lib/entrypoints/legacy.js +1 -1
  767. package/lib/entrypoints/legacy.js.map +1 -1
  768. package/lib/entrypoints/public.d.ts +1 -1
  769. package/lib/entrypoints/public.d.ts.map +1 -1
  770. package/lib/entrypoints/public.js +1 -1
  771. package/lib/entrypoints/public.js.map +1 -1
  772. package/lib/extensibleUnionNode.d.ts.map +1 -1
  773. package/lib/extensibleUnionNode.js +2 -2
  774. package/lib/extensibleUnionNode.js.map +1 -1
  775. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  776. package/lib/feature-libraries/chunked-forest/basicChunk.js +14 -1
  777. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  778. package/lib/feature-libraries/chunked-forest/chunkTree.js +14 -6
  779. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  780. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  781. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -12
  782. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  783. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +1 -3
  784. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  785. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +8 -0
  786. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  787. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -0
  788. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  789. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -0
  790. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  791. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  792. package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -0
  793. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  794. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +28 -12
  795. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  796. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +2 -2
  797. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  798. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -0
  799. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  800. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -0
  801. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  802. package/lib/feature-libraries/chunked-forest/uniformChunk.js +71 -13
  803. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  804. package/lib/feature-libraries/comparison-forest/comparisonForest.js +79 -79
  805. package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  806. package/lib/feature-libraries/cursorComparator.d.ts +8 -0
  807. package/lib/feature-libraries/cursorComparator.d.ts.map +1 -1
  808. package/lib/feature-libraries/cursorComparator.js +43 -9
  809. package/lib/feature-libraries/cursorComparator.js.map +1 -1
  810. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  811. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  812. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +2 -0
  813. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  814. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -0
  815. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  816. package/lib/feature-libraries/flex-tree/context.js +19 -3
  817. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  818. package/lib/feature-libraries/flex-tree/lazyEntity.js +12 -12
  819. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  820. package/lib/feature-libraries/flex-tree/lazyField.js +25 -27
  821. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  822. package/lib/feature-libraries/flex-tree/lazyNode.js +22 -21
  823. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  824. package/lib/feature-libraries/forest-summary/forestSummarizer.js +122 -117
  825. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  826. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +49 -32
  827. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  828. package/lib/feature-libraries/indexing/anchorTreeIndex.js +33 -29
  829. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  830. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -12
  831. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  832. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +63 -10
  833. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  834. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  835. package/lib/feature-libraries/modular-schema/fieldKind.js +10 -0
  836. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  837. package/lib/feature-libraries/modular-schema/filterEdits.d.ts +13 -0
  838. package/lib/feature-libraries/modular-schema/filterEdits.d.ts.map +1 -0
  839. package/lib/feature-libraries/modular-schema/filterEdits.js +46 -0
  840. package/lib/feature-libraries/modular-schema/filterEdits.js.map +1 -0
  841. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  842. package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -2
  843. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  844. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -2
  845. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  846. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  847. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  848. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  849. package/lib/feature-libraries/modular-schema/invert.d.ts +1 -1
  850. package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -1
  851. package/lib/feature-libraries/modular-schema/invert.js +6 -30
  852. package/lib/feature-libraries/modular-schema/invert.js.map +1 -1
  853. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +5 -7
  854. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  855. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +458 -8
  856. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  857. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -10
  858. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  859. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +20 -85
  860. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  861. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +13 -1
  862. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  863. package/lib/feature-libraries/modular-schema/modularChangeUtils.js +100 -3
  864. package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  865. package/lib/feature-libraries/modular-schema/prune.d.ts +2 -3
  866. package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -1
  867. package/lib/feature-libraries/modular-schema/prune.js +25 -7
  868. package/lib/feature-libraries/modular-schema/prune.js.map +1 -1
  869. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -3
  870. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  871. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +1 -0
  872. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  873. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  874. package/lib/feature-libraries/object-forest/objectForest.js +273 -266
  875. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  876. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  877. package/lib/feature-libraries/optional-field/optionalField.js +24 -32
  878. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  879. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +1 -1
  880. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  881. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +1 -1
  882. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  883. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  884. package/lib/feature-libraries/schema-index/schemaSummarizer.js +3 -0
  885. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  886. package/lib/feature-libraries/sequence-field/compose.js +6 -0
  887. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  888. package/lib/feature-libraries/sequence-field/filterEdits.d.ts +3 -3
  889. package/lib/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -1
  890. package/lib/feature-libraries/sequence-field/filterEdits.js +31 -12
  891. package/lib/feature-libraries/sequence-field/filterEdits.js.map +1 -1
  892. package/lib/feature-libraries/sequence-field/formatV1.d.ts +3 -3
  893. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  894. package/lib/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  895. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  896. package/lib/feature-libraries/sequence-field/formatV3.d.ts +2 -2
  897. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  898. package/lib/feature-libraries/sequence-field/markListFactory.js +3 -4
  899. package/lib/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  900. package/lib/feature-libraries/sequence-field/markQueue.js +4 -2
  901. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  902. package/lib/feature-libraries/sequence-field/rebase.js +6 -0
  903. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  904. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  905. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -9
  906. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  907. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
  908. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  909. package/lib/feature-libraries/sequence-field/utils.js +3 -15
  910. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  911. package/lib/feature-libraries/treeCursorUtils.js +13 -9
  912. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  913. package/lib/index.d.ts +4 -29
  914. package/lib/index.d.ts.map +1 -1
  915. package/lib/index.js +2 -17
  916. package/lib/index.js.map +1 -1
  917. package/lib/internalTypes.d.ts +1 -1
  918. package/lib/internalTypes.d.ts.map +1 -1
  919. package/lib/internalTypes.js.map +1 -1
  920. package/lib/packageVersion.d.ts +1 -1
  921. package/lib/packageVersion.d.ts.map +1 -1
  922. package/lib/packageVersion.js +1 -1
  923. package/lib/packageVersion.js.map +1 -1
  924. package/lib/serializableDomainSchema.d.ts +1 -1
  925. package/lib/shared-tree/history.d.ts.map +1 -1
  926. package/lib/shared-tree/history.js +32 -13
  927. package/lib/shared-tree/history.js.map +1 -1
  928. package/lib/shared-tree/independentView.d.ts +27 -3
  929. package/lib/shared-tree/independentView.d.ts.map +1 -1
  930. package/lib/shared-tree/independentView.js +30 -2
  931. package/lib/shared-tree/independentView.js.map +1 -1
  932. package/lib/shared-tree/index.d.ts +2 -1
  933. package/lib/shared-tree/index.d.ts.map +1 -1
  934. package/lib/shared-tree/index.js +2 -1
  935. package/lib/shared-tree/index.js.map +1 -1
  936. package/lib/shared-tree/schematizingTreeView.d.ts +2 -2
  937. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  938. package/lib/shared-tree/schematizingTreeView.js +60 -27
  939. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  940. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  941. package/lib/shared-tree/sharedTree.js +24 -15
  942. package/lib/shared-tree/sharedTree.js.map +1 -1
  943. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  944. package/lib/shared-tree/sharedTreeChangeEnricher.js +12 -4
  945. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  946. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  947. package/lib/shared-tree/sharedTreeChangeFamily.js +6 -3
  948. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  949. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -0
  950. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  951. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
  952. package/lib/shared-tree/transactionMinimize.js +4 -3
  953. package/lib/shared-tree/transactionMinimize.js.map +1 -1
  954. package/lib/shared-tree/treeAlpha.d.ts +5 -16
  955. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  956. package/lib/shared-tree/treeAlpha.js +13 -6
  957. package/lib/shared-tree/treeAlpha.js.map +1 -1
  958. package/{dist/simple-tree/api → lib/shared-tree}/treeBeta.d.ts +8 -65
  959. package/lib/shared-tree/treeBeta.d.ts.map +1 -0
  960. package/lib/shared-tree/treeBeta.js +64 -0
  961. package/lib/shared-tree/treeBeta.js.map +1 -0
  962. package/lib/shared-tree/treeCheckout.d.ts +5 -0
  963. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  964. package/lib/shared-tree/treeCheckout.js +985 -906
  965. package/lib/shared-tree/treeCheckout.js.map +1 -1
  966. package/lib/shared-tree/unhydratedTreeContext.js +3 -4
  967. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  968. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  969. package/lib/shared-tree-core/branch.js +22 -18
  970. package/lib/shared-tree-core/branch.js.map +1 -1
  971. package/lib/shared-tree-core/branchCommitCounter.js +35 -32
  972. package/lib/shared-tree-core/branchCommitCounter.js.map +1 -1
  973. package/lib/shared-tree-core/branchCommitEnricher.js +9 -8
  974. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  975. package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -1
  976. package/lib/shared-tree-core/defaultResubmitMachine.js +11 -9
  977. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  978. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  979. package/lib/shared-tree-core/editManager.js +73 -44
  980. package/lib/shared-tree-core/editManager.js.map +1 -1
  981. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  982. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  983. package/lib/shared-tree-core/editManagerCodecsCommons.js +32 -34
  984. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  985. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  986. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  987. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +4 -4
  988. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  989. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -1
  990. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  991. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +2 -1
  992. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  993. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  994. package/lib/shared-tree-core/editManagerSummarizer.js +6 -1
  995. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  996. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -1
  997. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  998. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +2 -1
  999. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  1000. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  1001. package/lib/shared-tree-core/sharedTreeCore.js +45 -23
  1002. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  1003. package/lib/shared-tree-core/transaction.js +36 -39
  1004. package/lib/shared-tree-core/transaction.js.map +1 -1
  1005. package/lib/shared-tree-core/versionedSummarizer.js +4 -0
  1006. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  1007. package/lib/simple-tree/api/cloneTree.d.ts +11 -0
  1008. package/lib/simple-tree/api/cloneTree.d.ts.map +1 -0
  1009. package/lib/simple-tree/api/cloneTree.js +28 -0
  1010. package/lib/simple-tree/api/cloneTree.js.map +1 -0
  1011. package/lib/simple-tree/api/configuration.js +19 -0
  1012. package/lib/simple-tree/api/configuration.js.map +1 -1
  1013. package/lib/simple-tree/api/index.d.ts +3 -3
  1014. package/lib/simple-tree/api/index.d.ts.map +1 -1
  1015. package/lib/simple-tree/api/index.js +1 -1
  1016. package/lib/simple-tree/api/index.js.map +1 -1
  1017. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -7
  1018. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  1019. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -3
  1020. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  1021. package/lib/simple-tree/api/schemaFactory.d.ts +4 -9
  1022. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  1023. package/lib/simple-tree/api/schemaFactory.js +9 -8
  1024. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  1025. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +18 -20
  1026. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  1027. package/lib/simple-tree/api/schemaFactoryAlpha.js +78 -81
  1028. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  1029. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +7 -9
  1030. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  1031. package/lib/simple-tree/api/schemaFactoryBeta.js +32 -35
  1032. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  1033. package/lib/simple-tree/api/schemaStatics.d.ts +7 -7
  1034. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  1035. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +46 -2
  1036. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  1037. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +48 -6
  1038. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  1039. package/lib/simple-tree/api/transactionTypes.d.ts +4 -4
  1040. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  1041. package/lib/simple-tree/api/tree.d.ts +80 -61
  1042. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  1043. package/lib/simple-tree/api/tree.js +2 -3
  1044. package/lib/simple-tree/api/tree.js.map +1 -1
  1045. package/lib/simple-tree/api/treeChangeEvents.d.ts +16 -4
  1046. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  1047. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  1048. package/lib/simple-tree/api/treeChangeEventsBeta.d.ts +209 -0
  1049. package/lib/simple-tree/api/treeChangeEventsBeta.d.ts.map +1 -0
  1050. package/lib/simple-tree/api/{treeAlpha.js → treeChangeEventsBeta.js} +1 -1
  1051. package/lib/simple-tree/api/treeChangeEventsBeta.js.map +1 -0
  1052. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -75
  1053. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  1054. package/lib/simple-tree/api/treeNodeApi.js +1 -1
  1055. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  1056. package/lib/simple-tree/api/typesUnsafe.d.ts +8 -6
  1057. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  1058. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  1059. package/lib/simple-tree/core/allowedTypes.js +12 -3
  1060. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  1061. package/lib/simple-tree/core/context.js +3 -0
  1062. package/lib/simple-tree/core/context.js.map +1 -1
  1063. package/lib/simple-tree/core/index.d.ts +1 -1
  1064. package/lib/simple-tree/core/index.d.ts.map +1 -1
  1065. package/lib/simple-tree/core/index.js +1 -1
  1066. package/lib/simple-tree/core/index.js.map +1 -1
  1067. package/lib/simple-tree/core/treeNode.d.ts +3 -4
  1068. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  1069. package/lib/simple-tree/core/treeNode.js +29 -30
  1070. package/lib/simple-tree/core/treeNode.js.map +1 -1
  1071. package/lib/simple-tree/core/treeNodeKernel.js +181 -179
  1072. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  1073. package/lib/simple-tree/core/treeNodeValid.js +19 -19
  1074. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  1075. package/lib/simple-tree/core/unhydratedFlexTree.js +173 -146
  1076. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  1077. package/lib/simple-tree/core/withType.d.ts +7 -9
  1078. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  1079. package/lib/simple-tree/core/withType.js +5 -6
  1080. package/lib/simple-tree/core/withType.js.map +1 -1
  1081. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  1082. package/lib/simple-tree/fieldSchema.js +23 -5
  1083. package/lib/simple-tree/fieldSchema.js.map +1 -1
  1084. package/lib/simple-tree/index.d.ts +2 -2
  1085. package/lib/simple-tree/index.d.ts.map +1 -1
  1086. package/lib/simple-tree/index.js +2 -2
  1087. package/lib/simple-tree/index.js.map +1 -1
  1088. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  1089. package/lib/simple-tree/leafNodeSchema.js +16 -15
  1090. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  1091. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -2
  1092. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  1093. package/lib/simple-tree/node-kinds/array/arrayNode.js +28 -32
  1094. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  1095. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  1096. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +6 -6
  1097. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  1098. package/lib/simple-tree/node-kinds/map/mapNode.js +10 -17
  1099. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  1100. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  1101. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  1102. package/lib/simple-tree/node-kinds/object/objectNode.js +25 -28
  1103. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  1104. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +1 -1
  1105. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  1106. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  1107. package/lib/simple-tree/node-kinds/record/recordNode.js +10 -14
  1108. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  1109. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -2
  1110. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  1111. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  1112. package/lib/tableSchema.d.ts +2 -87
  1113. package/lib/tableSchema.d.ts.map +1 -1
  1114. package/lib/tableSchema.js +309 -275
  1115. package/lib/tableSchema.js.map +1 -1
  1116. package/lib/text/codePointUtils.d.ts +16 -3
  1117. package/lib/text/codePointUtils.d.ts.map +1 -1
  1118. package/lib/text/codePointUtils.js +22 -10
  1119. package/lib/text/codePointUtils.js.map +1 -1
  1120. package/lib/text/textDomain.d.ts +7 -1
  1121. package/lib/text/textDomain.d.ts.map +1 -1
  1122. package/lib/text/textDomain.js +21 -17
  1123. package/lib/text/textDomain.js.map +1 -1
  1124. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  1125. package/lib/text/textDomainFormatted.js +43 -32
  1126. package/lib/text/textDomainFormatted.js.map +1 -1
  1127. package/lib/text/textDomainFormattedDefault.js +2 -5
  1128. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  1129. package/lib/util/brand.js +1 -0
  1130. package/lib/util/brand.js.map +1 -1
  1131. package/lib/util/breakable.d.ts.map +1 -1
  1132. package/lib/util/breakable.js +3 -0
  1133. package/lib/util/breakable.js.map +1 -1
  1134. package/lib/util/compressedIds.js +22 -0
  1135. package/lib/util/compressedIds.js.map +1 -1
  1136. package/lib/util/nestedMap.js +2 -4
  1137. package/lib/util/nestedMap.js.map +1 -1
  1138. package/lib/util/offsetList.js +2 -4
  1139. package/lib/util/offsetList.js.map +1 -1
  1140. package/lib/util/rangeMap.js +4 -0
  1141. package/lib/util/rangeMap.js.map +1 -1
  1142. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  1143. package/lib/util/referenceCounting.js +1 -0
  1144. package/lib/util/referenceCounting.js.map +1 -1
  1145. package/lib/util/stackyIterator.js +3 -2
  1146. package/lib/util/stackyIterator.js.map +1 -1
  1147. package/lib/util/utils.d.ts +2 -2
  1148. package/lib/util/utils.d.ts.map +1 -1
  1149. package/package.json +67 -95
  1150. package/src/api.ts +11 -0
  1151. package/src/core/index.ts +6 -2
  1152. package/src/core/rebase/index.ts +1 -0
  1153. package/src/core/rebase/types.ts +16 -1
  1154. package/src/core/tree/anchorSet.ts +2 -2
  1155. package/src/core/tree/deltaUtil.ts +67 -13
  1156. package/src/core/tree/index.ts +5 -2
  1157. package/src/entrypoints/alpha.ts +19 -21
  1158. package/src/entrypoints/beta.ts +12 -5
  1159. package/src/entrypoints/legacy.ts +12 -5
  1160. package/src/entrypoints/public.ts +1 -5
  1161. package/src/extensibleUnionNode.ts +1 -2
  1162. package/src/feature-libraries/cursorComparator.ts +57 -9
  1163. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +77 -12
  1164. package/src/feature-libraries/modular-schema/filterEdits.ts +108 -0
  1165. package/src/feature-libraries/modular-schema/genericFieldKind.ts +7 -4
  1166. package/src/feature-libraries/modular-schema/index.ts +5 -2
  1167. package/src/feature-libraries/modular-schema/invert.ts +16 -61
  1168. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +831 -10
  1169. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +10 -124
  1170. package/src/feature-libraries/modular-schema/modularChangeUtils.ts +164 -2
  1171. package/src/feature-libraries/modular-schema/prune.ts +52 -10
  1172. package/src/feature-libraries/optional-field/optionalField.ts +30 -42
  1173. package/src/feature-libraries/sequence-field/filterEdits.ts +62 -26
  1174. package/src/feature-libraries/sequence-field/utils.ts +7 -19
  1175. package/src/index.ts +7 -39
  1176. package/src/internalTypes.ts +1 -1
  1177. package/src/packageVersion.ts +1 -1
  1178. package/src/shared-tree/history.ts +41 -19
  1179. package/src/shared-tree/independentView.ts +40 -3
  1180. package/src/shared-tree/index.ts +5 -1
  1181. package/src/shared-tree/schematizingTreeView.ts +2 -2
  1182. package/src/shared-tree/sharedTree.ts +2 -1
  1183. package/src/shared-tree/transactionMinimize.ts +13 -4
  1184. package/src/shared-tree/treeAlpha.ts +17 -31
  1185. package/src/{simple-tree/api → shared-tree}/treeBeta.ts +56 -167
  1186. package/src/shared-tree/treeCheckout.ts +82 -9
  1187. package/src/shared-tree-core/editManager.ts +16 -8
  1188. package/src/shared-tree-core/editManagerCodecsCommons.ts +30 -34
  1189. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +1 -1
  1190. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -2
  1191. package/src/simple-tree/api/cloneTree.ts +47 -0
  1192. package/src/simple-tree/api/index.ts +15 -21
  1193. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -2
  1194. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +87 -6
  1195. package/src/simple-tree/api/transactionTypes.ts +4 -4
  1196. package/src/simple-tree/api/tree.ts +139 -85
  1197. package/src/simple-tree/api/treeChangeEvents.ts +16 -4
  1198. package/src/simple-tree/api/treeChangeEventsBeta.ts +245 -0
  1199. package/src/simple-tree/api/treeNodeApi.ts +6 -85
  1200. package/src/simple-tree/api/typesUnsafe.ts +8 -6
  1201. package/src/simple-tree/core/index.ts +1 -1
  1202. package/src/simple-tree/core/treeNode.ts +3 -10
  1203. package/src/simple-tree/core/withType.ts +8 -11
  1204. package/src/simple-tree/index.ts +3 -7
  1205. package/src/simple-tree/node-kinds/array/arrayNode.ts +14 -12
  1206. package/src/simple-tree/node-kinds/map/mapNode.ts +14 -15
  1207. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -6
  1208. package/src/simple-tree/node-kinds/record/recordNode.ts +6 -8
  1209. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -1
  1210. package/src/tableSchema.ts +8 -187
  1211. package/src/text/codePointUtils.ts +25 -14
  1212. package/src/text/textDomain.ts +15 -2
  1213. package/src/text/textDomainFormatted.ts +9 -4
  1214. package/tsconfig.json +1 -1
  1215. package/alpha.d.ts +0 -11
  1216. package/beta.d.ts +0 -11
  1217. package/dist/simple-tree/api/treeAlpha.d.ts +0 -126
  1218. package/dist/simple-tree/api/treeAlpha.d.ts.map +0 -1
  1219. package/dist/simple-tree/api/treeAlpha.js.map +0 -1
  1220. package/dist/simple-tree/api/treeBeta.d.ts.map +0 -1
  1221. package/dist/simple-tree/api/treeBeta.js +0 -83
  1222. package/dist/simple-tree/api/treeBeta.js.map +0 -1
  1223. package/docs/main/glossary.md +0 -163
  1224. package/internal.d.ts +0 -11
  1225. package/legacy.d.ts +0 -11
  1226. package/lib/simple-tree/api/treeAlpha.d.ts +0 -126
  1227. package/lib/simple-tree/api/treeAlpha.d.ts.map +0 -1
  1228. package/lib/simple-tree/api/treeAlpha.js.map +0 -1
  1229. package/lib/simple-tree/api/treeBeta.d.ts.map +0 -1
  1230. package/lib/simple-tree/api/treeBeta.js +0 -77
  1231. package/lib/simple-tree/api/treeBeta.js.map +0 -1
  1232. package/src/simple-tree/api/treeAlpha.ts +0 -153
  1233. /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
  1234. /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
@@ -4,7 +4,10 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.TreeCheckout = exports.assertValidConstraint = exports.addConstraintsToTransaction = exports.createTreeCheckout = void 0;
7
+ exports.TreeCheckout = void 0;
8
+ exports.createTreeCheckout = createTreeCheckout;
9
+ exports.addConstraintsToTransaction = addConstraintsToTransaction;
10
+ exports.assertValidConstraint = assertValidConstraint;
8
11
  const tslib_1 = require("tslib");
9
12
  const client_utils_1 = require("@fluid-internal/client-utils");
10
13
  const internal_1 = require("@fluidframework/core-utils/internal");
@@ -119,10 +122,10 @@ function createTreeCheckout(idCompressor, mintRevisionTag, revisionTagCodec, arg
119
122
  change: changeFamily.rebaser.compose([]),
120
123
  revision: "root",
121
124
  customMetadata: undefined,
125
+ wasTrimmed: true,
122
126
  }, changeFamily, () => idCompressor.generateCompressedId());
123
127
  return new TreeCheckout(branch, true, changeFamily, schema, forest, mintRevisionTag, revisionTagCodec, idCompressor, args?.removedRoots);
124
128
  }
125
- exports.createTreeCheckout = createTreeCheckout;
126
129
  /**
127
130
  * Get the {@link TreeCheckout} associated with a given {@link UntypedTreeView}.
128
131
  */
@@ -175,7 +178,6 @@ function addConstraintsToTransaction(checkout, constraintsOnRevert, constraints
175
178
  }
176
179
  }
177
180
  }
178
- exports.addConstraintsToTransaction = addConstraintsToTransaction;
179
181
  /**
180
182
  * Throws if the given {@link TransactionConstraintAlpha | transaction constraint} is not currently satisfied.
181
183
  */
@@ -198,12 +200,10 @@ function assertValidConstraint(constraint, onRevert) {
198
200
  }
199
201
  }
200
202
  }
201
- exports.assertValidConstraint = assertValidConstraint;
202
203
  /**
203
204
  * An implementation of {@link ITreeCheckout}.
204
205
  */
205
206
  let TreeCheckout = (() => {
206
- var _a, _TreeCheckout_events, _TreeCheckout_transaction, _TreeCheckout_validatedCommits;
207
207
  let _instanceExtraInitializers = [];
208
208
  let _exportVerbose_decorators;
209
209
  let _applySerializedChange_decorators;
@@ -213,990 +213,1069 @@ let TreeCheckout = (() => {
213
213
  let _withCombinedVisitor_decorators;
214
214
  let _viewWith_decorators;
215
215
  let _fork_decorators;
216
- return _a = class TreeCheckout {
217
- /**
218
- * Logger for telemetry events related to this checkout.
219
- * @remarks
220
- * This logger is provided by the {@link Breakable} passed to the constructor, and may be `undefined` if no logger was provided.
221
- * See the explanation on {@link Breakable.logger} for why this pattern makes sense.
222
- */
223
- get logger() {
224
- return this.breaker.logger;
216
+ return class TreeCheckout {
217
+ static {
218
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
219
+ tslib_1.__esDecorate(this, null, _exportVerbose_decorators, { kind: "method", name: "exportVerbose", static: false, private: false, access: { has: obj => "exportVerbose" in obj, get: obj => obj.exportVerbose }, metadata: _metadata }, null, _instanceExtraInitializers);
220
+ tslib_1.__esDecorate(this, null, _applySerializedChange_decorators, { kind: "method", name: "applySerializedChange", static: false, private: false, access: { has: obj => "applySerializedChange" in obj, get: obj => obj.applySerializedChange }, metadata: _metadata }, null, _instanceExtraInitializers);
221
+ tslib_1.__esDecorate(this, null, _applyChange_decorators, { kind: "method", name: "applyChange", static: false, private: false, access: { has: obj => "applyChange" in obj, get: obj => obj.applyChange }, metadata: _metadata }, null, _instanceExtraInitializers);
222
+ tslib_1.__esDecorate(this, null, _runTransaction_decorators, { kind: "method", name: "runTransaction", static: false, private: false, access: { has: obj => "runTransaction" in obj, get: obj => obj.runTransaction }, metadata: _metadata }, null, _instanceExtraInitializers);
223
+ tslib_1.__esDecorate(this, null, _runTransactionAsync_decorators, { kind: "method", name: "runTransactionAsync", static: false, private: false, access: { has: obj => "runTransactionAsync" in obj, get: obj => obj.runTransactionAsync }, metadata: _metadata }, null, _instanceExtraInitializers);
224
+ tslib_1.__esDecorate(this, null, _withCombinedVisitor_decorators, { kind: "method", name: "withCombinedVisitor", static: false, private: false, access: { has: obj => "withCombinedVisitor" in obj, get: obj => obj.withCombinedVisitor }, metadata: _metadata }, null, _instanceExtraInitializers);
225
+ tslib_1.__esDecorate(this, null, _viewWith_decorators, { kind: "method", name: "viewWith", static: false, private: false, access: { has: obj => "viewWith" in obj, get: obj => obj.viewWith }, metadata: _metadata }, null, _instanceExtraInitializers);
226
+ tslib_1.__esDecorate(this, null, _fork_decorators, { kind: "method", name: "fork", static: false, private: false, access: { has: obj => "fork" in obj, get: obj => obj.fork }, metadata: _metadata }, null, _instanceExtraInitializers);
227
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
228
+ }
229
+ branch = tslib_1.__runInitializers(this, _instanceExtraInitializers);
230
+ isSharedBranch;
231
+ changeFamily;
232
+ storedSchema;
233
+ forest;
234
+ mintRevisionTag;
235
+ revisionTagCodec;
236
+ idCompressor;
237
+ _removedRoots;
238
+ disposeForksAfterTransaction;
239
+ disposed = false;
240
+ /**
241
+ * Logger for telemetry events related to this checkout.
242
+ * @remarks
243
+ * This logger is provided by the {@link Breakable} passed to the constructor, and may be `undefined` if no logger was provided.
244
+ * See the explanation on {@link Breakable.logger} for why this pattern makes sense.
245
+ */
246
+ get logger() {
247
+ return this.breaker.logger;
248
+ }
249
+ /**
250
+ * The breaker for this checkout.
251
+ * @remarks
252
+ * As the forest is part of the mutable state of the checkout,
253
+ * we want to be broken if it is broken, so we use the forest's breaker as our own.
254
+ *
255
+ * This does mean that if something goes wrong in the checkout, we break the forest,
256
+ * which is not strictly necessary, but may be desirable as if something is wrong with the checkout,
257
+ * while the forest might be internally consistent, it likely doesn't contain the correct content
258
+ * (since the checkout is keeping it up to date properly anymore).
259
+ */
260
+ get breaker() {
261
+ return this.forest.breaker;
262
+ }
263
+ editLock;
264
+ /**
265
+ * Root of the mutable label tree tracking transaction nesting.
266
+ *
267
+ * @remarks
268
+ * The label tree is always isomorphic to the actual transaction tree — every transaction
269
+ * (whether labeled or not) gets its own node. To find the "current" (deepest open) node,
270
+ * walk down the right side of the tree, stopping at {@link TreeCheckout.mostRecentlyClosedLabelNode}.
271
+ *
272
+ * Cleared by {@link TreeCheckout.runWithTransactionLabel} after the commit event is emitted.
273
+ */
274
+ labelTreeNode;
275
+ /**
276
+ * Points to the most recently closed (committed) label node.
277
+ * Used by {@link TreeCheckout.currentLabelNode} to stop descending past committed nodes.
278
+ */
279
+ mostRecentlyClosedLabelNode;
280
+ views = new Set();
281
+ /**
282
+ * Event emitters for local commits.
283
+ */
284
+ localCommitEventEmitters = new Map();
285
+ /**
286
+ * Revertibles maintained for automatic disposal
287
+ */
288
+ revertibles = new Map();
289
+ /**
290
+ * Each branch's head commit corresponds to a revertible commit.
291
+ * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from
292
+ * being reverted.
293
+ */
294
+ revertibleCommitBranches = new Map();
295
+ /**
296
+ * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.
297
+ * @privateRemarks Exposed for testing purposes.
298
+ */
299
+ static revertTelemetryEventName = "RevertRevertible";
300
+ /**
301
+ * The name of the telemetry event logged when a schema change is applied.
302
+ * @privateRemarks Exposed for testing purposes.
303
+ */
304
+ static schemaChangeTelemetryEventName = "SchemaChangeApplied";
305
+ #events = (0, client_utils_1.createEmitter)();
306
+ events = this.#events;
307
+ _branchHistory;
308
+ constructor(branch,
309
+ /** True if and only if this checkout is for a branch which is persisted and shared with other clients. */
310
+ isSharedBranch, changeFamily, storedSchema, forest, mintRevisionTag, revisionTagCodec, idCompressor, _removedRoots = (0, index_js_2.makeDetachedFieldIndex)("repair"), disposeForksAfterTransaction = true) {
311
+ this.branch = branch;
312
+ this.isSharedBranch = isSharedBranch;
313
+ this.changeFamily = changeFamily;
314
+ this.storedSchema = storedSchema;
315
+ this.forest = forest;
316
+ this.mintRevisionTag = mintRevisionTag;
317
+ this.revisionTagCodec = revisionTagCodec;
318
+ this.idCompressor = idCompressor;
319
+ this._removedRoots = _removedRoots;
320
+ this.disposeForksAfterTransaction = disposeForksAfterTransaction;
321
+ this.#transaction = this.createTransactionStack(branch);
322
+ this.editLock = new EditLock(this.#transaction.activeBranchEditor);
323
+ this.registerForBranchEvents();
324
+ }
325
+ get branchHistory() {
326
+ this._branchHistory ??= new history_js_1.DefaultTreeBranchHistory(this.branch, this.idCompressor);
327
+ return this._branchHistory;
328
+ }
329
+ /**
330
+ * Pushes a new label node for a transaction nesting level.
331
+ *
332
+ * @param label - The label for this transaction level.
333
+ *
334
+ * @remarks
335
+ * Called at the start of each transaction (including nested ones).
336
+ * Creates a new {@link LabelTree} node as a child of the current deepest node (if any),
337
+ * or as the root if this is the outermost transaction.
338
+ */
339
+ pushLabelFrame(label) {
340
+ const node = { label, sublabels: [] };
341
+ if (this.labelTreeNode === undefined) {
342
+ this.labelTreeNode = node;
225
343
  }
226
- /**
227
- * The breaker for this checkout.
228
- * @remarks
229
- * As the forest is part of the mutable state of the checkout,
230
- * we want to be broken if it is broken, so we use the forest's breaker as our own.
231
- *
232
- * This does mean that if something goes wrong in the checkout, we break the forest,
233
- * which is not strictly necessary, but may be desirable as if something is wrong with the checkout,
234
- * while the forest might be internally consistent, it likely doesn't contain the correct content
235
- * (since the checkout is keeping it up to date properly anymore).
236
- */
237
- get breaker() {
238
- return this.forest.breaker;
344
+ else {
345
+ const current = this.currentLabelNode();
346
+ (0, internal_1.assert)(current !== undefined, 0xcdb /* Expected current label node to exist */);
347
+ current.sublabels.push(node);
239
348
  }
240
- constructor(branch,
241
- /** True if and only if this checkout is for a branch which is persisted and shared with other clients. */
242
- isSharedBranch, changeFamily, storedSchema, forest, mintRevisionTag, revisionTagCodec, idCompressor, _removedRoots = (0, index_js_2.makeDetachedFieldIndex)("repair"), disposeForksAfterTransaction = true) {
243
- this.branch = (tslib_1.__runInitializers(this, _instanceExtraInitializers), branch);
244
- this.isSharedBranch = isSharedBranch;
245
- this.changeFamily = changeFamily;
246
- this.storedSchema = storedSchema;
247
- this.forest = forest;
248
- this.mintRevisionTag = mintRevisionTag;
249
- this.revisionTagCodec = revisionTagCodec;
250
- this.idCompressor = idCompressor;
251
- this._removedRoots = _removedRoots;
252
- this.disposeForksAfterTransaction = disposeForksAfterTransaction;
253
- this.disposed = false;
254
- this.views = new Set();
255
- /**
256
- * Event emitters for local commits.
257
- */
258
- this.localCommitEventEmitters = new Map();
259
- /**
260
- * Revertibles maintained for automatic disposal
261
- */
262
- this.revertibles = new Map();
263
- /**
264
- * Each branch's head commit corresponds to a revertible commit.
265
- * Maintaining a whole branch ensures the commit graph is not pruned in a way that would prevent the commit from
266
- * being reverted.
267
- */
268
- this.revertibleCommitBranches = new Map();
269
- _TreeCheckout_events.set(this, (0, client_utils_1.createEmitter)());
270
- this.events = tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f");
271
- this.onCommitSequenced = (commit) => {
272
- const emitter = this.localCommitEventEmitters.get(commit.revision);
273
- if (emitter === undefined) {
274
- // If the commit predates the creation of this checkout, there will be no emitter associated with the commit.
275
- // In that case, we don't need to emit any events.
276
- return;
277
- }
278
- const constraintStatus = (0, sharedTreeChangeFamily_js_1.getConstraintStatus)(commit.change);
279
- let outcome;
280
- switch (constraintStatus) {
281
- case sharedTreeChangeFamily_js_1.ConstraintStatus.Satisfied: {
282
- outcome = index_js_2.CommitOutcome.FullyApplied;
283
- break;
284
- }
285
- case sharedTreeChangeFamily_js_1.ConstraintStatus.ImplicitViolation: {
286
- outcome = index_js_2.CommitOutcome.FullyDropped;
349
+ }
350
+ /**
351
+ * Returns the deepest open node on the right side of the label tree, which corresponds
352
+ * to the current (most recently pushed, not yet committed or aborted) transaction.
353
+ * Returns `undefined` when {@link TreeCheckout.labelTreeNode} is not set.
354
+ */
355
+ currentLabelNode() {
356
+ if (this.labelTreeNode === undefined) {
357
+ return undefined;
358
+ }
359
+ // Walk down the right spine of the tree. Only one closed node is ever reachable
360
+ // during this traversal, so a single pointer (mostRecentlyClosedLabelNode) suffices
361
+ // to stop descending past committed nodes.
362
+ let node = this.labelTreeNode;
363
+ while (node.sublabels.length > 0) {
364
+ const lastChild = node.sublabels[node.sublabels.length - 1];
365
+ (0, internal_1.assert)(lastChild !== undefined, 0xcdc /* Expected label tree node to have children */);
366
+ if (lastChild === this.mostRecentlyClosedLabelNode) {
367
+ break;
368
+ }
369
+ node = lastChild;
370
+ }
371
+ return node;
372
+ }
373
+ /**
374
+ * Pops the current label frame from the label tree.
375
+ * @param aborted - If true, the node is removed from the tree (transaction was aborted).
376
+ * If false, the node is kept in the tree but marked as closed (transaction was committed).
377
+ */
378
+ popLabelFrame(aborted) {
379
+ const node = this.currentLabelNode();
380
+ if (node === undefined) {
381
+ return;
382
+ }
383
+ if (aborted) {
384
+ if (node === this.labelTreeNode) {
385
+ this.labelTreeNode = undefined;
386
+ this.mostRecentlyClosedLabelNode = undefined;
387
+ }
388
+ else {
389
+ // Temporarily mark node as closed so currentLabelNode() returns its parent.
390
+ this.mostRecentlyClosedLabelNode = node;
391
+ const parent = this.currentLabelNode();
392
+ (0, internal_1.assert)(parent !== undefined, 0xcdd /* Expected parent label node to exist */);
393
+ parent.sublabels.pop();
394
+ // Point to the parent's new last child (guaranteed closed if it exists),
395
+ // or undefined if the parent has no more children.
396
+ const newLastChild = parent.sublabels[parent.sublabels.length - 1];
397
+ this.mostRecentlyClosedLabelNode = newLastChild;
398
+ }
399
+ }
400
+ else {
401
+ this.mostRecentlyClosedLabelNode = node;
402
+ }
403
+ }
404
+ /**
405
+ * Helper method for {@link SchematizingSimpleTreeView.runTransaction} to properly clear transaction labels once the function completes.
406
+ *
407
+ * @remarks
408
+ * The label is stored during the execution of the function and will be included in the {@link ChangeMetadata} of the transaction.
409
+ *
410
+ * Labels supplied to nested transactions are ignored - only the outermost transaction label is ever used.
411
+ *
412
+ * @param fn - The function to execute. It receives the user provided transaction label as an optional parameter.
413
+ * @param label - The label to associate with the outermost transaction.
414
+ * @returns The result of executing `fn`.
415
+ */
416
+ runWithTransactionLabel(fn, label) {
417
+ try {
418
+ return fn(label);
419
+ }
420
+ finally {
421
+ // Only clear the label tree when the outermost transaction has completed.
422
+ // Inner transactions' commits don't fire the "changed" event, so the label tree
423
+ // must remain intact until the outermost commit reads it.
424
+ if (this.transaction.size === 0) {
425
+ this.labelTreeNode = undefined;
426
+ this.mostRecentlyClosedLabelNode = undefined;
427
+ }
428
+ }
429
+ }
430
+ get removedRoots() {
431
+ return this._removedRoots;
432
+ }
433
+ registerForBranchEvents() {
434
+ this.#transaction.branch.events.on("afterChange", this.onAfterBranchChange);
435
+ this.#transaction.branch.events.on("commitSequenced", this.onCommitSequenced);
436
+ this.#transaction.activeBranchEvents.on("afterChange", this.onAfterChange);
437
+ this.#transaction.activeBranchEvents.on("ancestryTrimmed", this.onAncestryTrimmed);
438
+ }
439
+ unregisterFromBranchEvents() {
440
+ this.#transaction.branch.events.off("afterChange", this.onAfterBranchChange);
441
+ this.#transaction.branch.events.off("commitSequenced", this.onCommitSequenced);
442
+ this.#transaction.activeBranchEvents.off("afterChange", this.onAfterChange);
443
+ this.#transaction.activeBranchEvents.off("ancestryTrimmed", this.onAncestryTrimmed);
444
+ }
445
+ createTransactionStack(branch) {
446
+ return new index_js_4.SquashingTransactionStack(branch, this.mintRevisionTag, () => {
447
+ // When each transaction is started, make a restorable checkpoint of the current state of removed roots
448
+ const restoreRemovedRoots = this._removedRoots.createCheckpoint();
449
+ return (result, viewUpdate) => {
450
+ const newHead = this.#transaction.branch.getHead();
451
+ switch (result) {
452
+ case index_js_4.TransactionResult.Abort: {
453
+ restoreRemovedRoots();
454
+ if (viewUpdate !== undefined) {
455
+ this.applyInternalChange(viewUpdate, newHead.revision);
456
+ }
287
457
  break;
288
458
  }
289
- case sharedTreeChangeFamily_js_1.ConstraintStatus.ExplicitViolation: {
290
- outcome = index_js_2.CommitOutcome.NewContentOnly;
459
+ case index_js_4.TransactionResult.Commit: {
460
+ if (viewUpdate !== undefined) {
461
+ this.applyInternalChange(viewUpdate, newHead.revision);
462
+ }
463
+ if (this.transaction.size === 0) {
464
+ // 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.
465
+ this.validateCommit(newHead);
466
+ }
291
467
  break;
292
468
  }
293
469
  default: {
294
- (0, internal_1.unreachableCase)(constraintStatus);
295
- }
296
- }
297
- this.emitChangedLocked(() => {
298
- emitter.emit("settled", outcome);
299
- }, "a commit settled event callback");
300
- // No more events will be emitted for this commit, so we can remove the emitter from the map.
301
- this.localCommitEventEmitters.delete(commit.revision);
302
- };
303
- this.onAfterBranchChange = (event) => {
304
- // The following logic allows revertibles to be generated for the change.
305
- // Currently only appends (including merges and transaction commits) are supported.
306
- if (event.type === "append") {
307
- // TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.
308
- // Figure out a way to generate revertibles before the commits are garbage collected.
309
- for (const commit of event.newCommits) {
310
- const kind = event.type === "append" ? event.kind : index_js_2.CommitKind.Default;
311
- const { change, revision } = commit;
312
- // Snapshot the label tree for this commit before any listener runs, so the captured
313
- // value is stable against mutations to `metadata.labels.tree` (which aliases the
314
- // live `labelTreeNode`).
315
- const commitLabelTree = this.labelTreeNode === undefined ? undefined : cloneLabelTree(this.labelTreeNode);
316
- const getRevertible = (0, sharedTreeChangeFamily_js_1.hasSchemaChange)(change)
317
- ? undefined
318
- : (onRevertibleDisposed) => {
319
- if (!withinEventContext) {
320
- throw new internal_2.UsageError("Cannot get a revertible outside of the context of a changed event.");
321
- }
322
- if (this.revertibleCommitBranches.get(revision) !== undefined) {
323
- throw new internal_2.UsageError("Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.");
324
- }
325
- const revertible = this.createRevertible(revision, kind, this, onRevertibleDisposed, commitLabelTree);
326
- this.revertibleCommitBranches.set(revision, tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.fork(commit));
327
- this.revertibles.set(revision, revertible);
328
- return revertible;
329
- };
330
- let withinEventContext = true;
331
- const events = (0, client_utils_1.createEmitter)();
332
- this.localCommitEventEmitters.set(commit.revision, events);
333
- const metadata = {
334
- kind,
335
- isLocal: true,
336
- getChange: () => {
337
- (0, internal_1.assert)(commit.parent !== undefined, 0xca4 /* Expected applied commit to be parented */);
338
- return serializedChange_js_1.SerializedChange.V1.encode(this.idCompressor, this.changeFamily, change, revision);
339
- },
340
- getRevertible: (onDisposed) => getRevertible?.(onDisposed),
341
- label: this.labelTreeNode?.label,
342
- labels: buildLabelsSet(this.labelTreeNode),
343
- events,
344
- };
345
- this.emitChangedLocked(() => {
346
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("changed", metadata, getRevertible);
347
- });
348
- withinEventContext = false;
349
- }
350
- }
351
- else if (event.type === "remove") {
352
- // Commits that are rolled back should no longer be revertible
353
- for (const commit of event.removedCommits) {
354
- this.revertibles.get(commit.revision)?.dispose();
470
+ (0, internal_1.unreachableCase)(result);
355
471
  }
356
472
  }
357
- else if (this.isRemoteChangeEvent(event)) {
358
- // TODO: figure out how to plumb through commit kind info for remote changes
359
- this.emitChangedLocked(() => {
360
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("changed", {
361
- isLocal: false,
362
- kind: index_js_2.CommitKind.Default,
363
- labels: new Set(),
364
- });
365
- });
366
- }
367
473
  };
368
- this.onAfterChange = (event) => {
369
- this.editLock.lock("a change event callback");
370
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("beforeBatch", event);
371
- if (event.change !== undefined) {
372
- const revision = event.type === "rebase"
373
- ? tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranch.getHead().revision
374
- : event.change.revision;
375
- this.applyInternalChange(event.change.change, revision);
376
- }
377
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("afterBatch");
378
- this.editLock.unlock();
379
- if (event.type === "append") {
380
- for (const commit of event.newCommits) {
381
- this.validateCommit(commit);
382
- }
383
- }
384
- };
385
- this.onAncestryTrimmed = (revisions) => {
386
- // When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the
387
- // trimmed revisions.
388
- this.withCombinedVisitor((visitor) => {
389
- for (const revision of revisions) {
390
- // get all the roots last created or used by the revision
391
- const roots = this._removedRoots.getRootsLastTouchedByRevision(revision);
392
- // get the detached field for the root and delete it from the removed roots
393
- for (const root of roots) {
394
- visitor.destroy(this._removedRoots.toFieldKey(root), 1);
395
- }
396
- this._removedRoots.deleteRootsLastTouchedByRevision(revision);
397
- }
398
- });
399
- };
400
- /**
401
- * The {@link Transactor} for this checkout.
402
- * @remarks In the context of a checkout, transactions allow edits to be batched into atomic units.
403
- * 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.
404
- * If the transaction is aborted, the local state will be reset to what it was before the transaction began.
405
- * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.
406
- *
407
- * To avoid updating observers of the view state with intermediate results during a transaction,
408
- * use {@link ITreeCheckout#fork} and {@link ISharedTreeFork#merge}.
409
- */
410
- _TreeCheckout_transaction.set(this, void 0);
411
- // #region Commit Validation
412
- /** Used to maintain the contract of {@link onCommitValid}(). */
413
- _TreeCheckout_validatedCommits.set(this, new WeakMap());
414
- // #endregion Commit Validation
415
- // #region Enrichment
416
- /**
417
- * Statistics about enrichment operations performed by this checkout.
418
- * Used for testing. May be used for telemetry in the future.
419
- * The performance cost of maintaining this information is negligible.
420
- */
421
- this.enrichmentStats = { batches: 0, diffs: 0, commitsEnriched: 0, refreshers: 0, forks: 0, applied: 0 };
422
- tslib_1.__classPrivateFieldSet(this, _TreeCheckout_transaction, this.createTransactionStack(branch), "f");
423
- this.editLock = new EditLock(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEditor);
424
- this.registerForBranchEvents();
425
- }
426
- get branchHistory() {
427
- this._branchHistory ??= new history_js_1.DefaultTreeBranchHistory(this.branch, this.idCompressor);
428
- return this._branchHistory;
429
- }
430
- /**
431
- * Pushes a new label node for a transaction nesting level.
432
- *
433
- * @param label - The label for this transaction level.
434
- *
435
- * @remarks
436
- * Called at the start of each transaction (including nested ones).
437
- * Creates a new {@link LabelTree} node as a child of the current deepest node (if any),
438
- * or as the root if this is the outermost transaction.
439
- */
440
- pushLabelFrame(label) {
441
- const node = { label, sublabels: [] };
442
- if (this.labelTreeNode === undefined) {
443
- this.labelTreeNode = node;
474
+ });
475
+ }
476
+ exportVerbose() {
477
+ const cursor = this.forest.allocateCursor("contentSnapshot");
478
+ try {
479
+ (0, index_js_2.moveToDetachedField)(this.forest, cursor);
480
+ const length = cursor.getFieldLength();
481
+ if (length === 0) {
482
+ return undefined;
483
+ }
484
+ else if (length === 1) {
485
+ cursor.enterNode(0);
486
+ return verboseFromCursor(cursor, this.storedSchema.nodeSchema);
444
487
  }
445
488
  else {
446
- const current = this.currentLabelNode();
447
- (0, internal_1.assert)(current !== undefined, 0xcdb /* Expected current label node to exist */);
448
- current.sublabels.push(node);
489
+ (0, internal_1.fail)(0xac8 /* Invalid document root length */);
449
490
  }
450
491
  }
451
- /**
452
- * Returns the deepest open node on the right side of the label tree, which corresponds
453
- * to the current (most recently pushed, not yet committed or aborted) transaction.
454
- * Returns `undefined` when {@link TreeCheckout.labelTreeNode} is not set.
455
- */
456
- currentLabelNode() {
457
- if (this.labelTreeNode === undefined) {
458
- return undefined;
459
- }
460
- // Walk down the right spine of the tree. Only one closed node is ever reachable
461
- // during this traversal, so a single pointer (mostRecentlyClosedLabelNode) suffices
462
- // to stop descending past committed nodes.
463
- let node = this.labelTreeNode;
464
- while (node.sublabels.length > 0) {
465
- const lastChild = node.sublabels[node.sublabels.length - 1];
466
- (0, internal_1.assert)(lastChild !== undefined, 0xcdc /* Expected label tree node to have children */);
467
- if (lastChild === this.mostRecentlyClosedLabelNode) {
468
- break;
469
- }
470
- node = lastChild;
471
- }
472
- return node;
492
+ finally {
493
+ cursor.free();
473
494
  }
474
- /**
475
- * Pops the current label frame from the label tree.
476
- * @param aborted - If true, the node is removed from the tree (transaction was aborted).
477
- * If false, the node is kept in the tree but marked as closed (transaction was committed).
478
- */
479
- popLabelFrame(aborted) {
480
- const node = this.currentLabelNode();
481
- if (node === undefined) {
482
- return;
483
- }
484
- if (aborted) {
485
- if (node === this.labelTreeNode) {
486
- this.labelTreeNode = undefined;
487
- this.mostRecentlyClosedLabelNode = undefined;
488
- }
489
- else {
490
- // Temporarily mark node as closed so currentLabelNode() returns its parent.
491
- this.mostRecentlyClosedLabelNode = node;
492
- const parent = this.currentLabelNode();
493
- (0, internal_1.assert)(parent !== undefined, 0xcdd /* Expected parent label node to exist */);
494
- parent.sublabels.pop();
495
- // Point to the parent's new last child (guaranteed closed if it exists),
496
- // or undefined if the parent has no more children.
497
- const newLastChild = parent.sublabels[parent.sublabels.length - 1];
498
- this.mostRecentlyClosedLabelNode = newLastChild;
499
- }
495
+ }
496
+ onCommitSequenced = (commit) => {
497
+ const emitter = this.localCommitEventEmitters.get(commit.revision);
498
+ if (emitter === undefined) {
499
+ // If the commit predates the creation of this checkout, there will be no emitter associated with the commit.
500
+ // In that case, we don't need to emit any events.
501
+ return;
502
+ }
503
+ const constraintStatus = (0, sharedTreeChangeFamily_js_1.getConstraintStatus)(commit.change);
504
+ let outcome;
505
+ switch (constraintStatus) {
506
+ case sharedTreeChangeFamily_js_1.ConstraintStatus.Satisfied: {
507
+ outcome = index_js_2.CommitOutcome.FullyApplied;
508
+ break;
500
509
  }
501
- else {
502
- this.mostRecentlyClosedLabelNode = node;
510
+ case sharedTreeChangeFamily_js_1.ConstraintStatus.ImplicitViolation: {
511
+ outcome = index_js_2.CommitOutcome.FullyDropped;
512
+ break;
503
513
  }
504
- }
505
- /**
506
- * Helper method for {@link SchematizingSimpleTreeView.runTransaction} to properly clear transaction labels once the function completes.
507
- *
508
- * @remarks
509
- * The label is stored during the execution of the function and will be included in the {@link ChangeMetadata} of the transaction.
510
- *
511
- * Labels supplied to nested transactions are ignored - only the outermost transaction label is ever used.
512
- *
513
- * @param fn - The function to execute. It receives the user provided transaction label as an optional parameter.
514
- * @param label - The label to associate with the outermost transaction.
515
- * @returns The result of executing `fn`.
516
- */
517
- runWithTransactionLabel(fn, label) {
518
- try {
519
- return fn(label);
514
+ case sharedTreeChangeFamily_js_1.ConstraintStatus.ExplicitViolation: {
515
+ outcome = index_js_2.CommitOutcome.NewContentOnly;
516
+ break;
520
517
  }
521
- finally {
522
- // Only clear the label tree when the outermost transaction has completed.
523
- // Inner transactions' commits don't fire the "changed" event, so the label tree
524
- // must remain intact until the outermost commit reads it.
525
- if (this.transaction.size === 0) {
526
- this.labelTreeNode = undefined;
527
- this.mostRecentlyClosedLabelNode = undefined;
528
- }
518
+ default: {
519
+ (0, internal_1.unreachableCase)(constraintStatus);
529
520
  }
530
521
  }
531
- get removedRoots() {
532
- return this._removedRoots;
533
- }
534
- registerForBranchEvents() {
535
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.events.on("afterChange", this.onAfterBranchChange);
536
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.events.on("commitSequenced", this.onCommitSequenced);
537
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEvents.on("afterChange", this.onAfterChange);
538
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEvents.on("ancestryTrimmed", this.onAncestryTrimmed);
539
- }
540
- unregisterFromBranchEvents() {
541
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.events.off("afterChange", this.onAfterBranchChange);
542
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.events.off("commitSequenced", this.onCommitSequenced);
543
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEvents.off("afterChange", this.onAfterChange);
544
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEvents.off("ancestryTrimmed", this.onAncestryTrimmed);
545
- }
546
- createTransactionStack(branch) {
547
- return new index_js_4.SquashingTransactionStack(branch, this.mintRevisionTag, () => {
548
- // When each transaction is started, make a restorable checkpoint of the current state of removed roots
549
- const restoreRemovedRoots = this._removedRoots.createCheckpoint();
550
- return (result, viewUpdate) => {
551
- const newHead = tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead();
552
- switch (result) {
553
- case index_js_4.TransactionResult.Abort: {
554
- restoreRemovedRoots();
555
- if (viewUpdate !== undefined) {
556
- this.applyInternalChange(viewUpdate, newHead.revision);
557
- }
558
- break;
559
- }
560
- case index_js_4.TransactionResult.Commit: {
561
- if (viewUpdate !== undefined) {
562
- this.applyInternalChange(viewUpdate, newHead.revision);
563
- }
564
- if (this.transaction.size === 0) {
565
- // 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.
566
- this.validateCommit(newHead);
567
- }
568
- break;
522
+ this.emitChangedLocked(() => {
523
+ emitter.emit("settled", outcome);
524
+ }, "a commit settled event callback");
525
+ // No more events will be emitted for this commit, so we can remove the emitter from the map.
526
+ this.localCommitEventEmitters.delete(commit.revision);
527
+ };
528
+ onAfterBranchChange = (event) => {
529
+ // The following logic allows revertibles to be generated for the change.
530
+ // Currently only appends (including merges and transaction commits) are supported.
531
+ if (event.type === "append") {
532
+ // TODO:#20949: When the SharedTree is detached, these commits will already have been garbage collected.
533
+ // Figure out a way to generate revertibles before the commits are garbage collected.
534
+ for (const commit of event.newCommits) {
535
+ const kind = event.type === "append" ? event.kind : index_js_2.CommitKind.Default;
536
+ const { change, revision } = commit;
537
+ // Snapshot the label tree for this commit before any listener runs, so the captured
538
+ // value is stable against mutations to `metadata.labels.tree` (which aliases the
539
+ // live `labelTreeNode`).
540
+ const commitLabelTree = this.labelTreeNode === undefined ? undefined : cloneLabelTree(this.labelTreeNode);
541
+ const getRevertible = (0, sharedTreeChangeFamily_js_1.hasSchemaChange)(change)
542
+ ? undefined
543
+ : (onRevertibleDisposed) => {
544
+ if (!withinEventContext) {
545
+ throw new internal_2.UsageError("Cannot get a revertible outside of the context of a changed event.");
569
546
  }
570
- default: {
571
- (0, internal_1.unreachableCase)(result);
547
+ if (this.revertibleCommitBranches.get(revision) !== undefined) {
548
+ throw new internal_2.UsageError("Cannot generate the same revertible more than once. Note that this can happen when multiple changed event listeners are registered.");
572
549
  }
573
- }
550
+ const revertible = this.createRevertible(revision, kind, this, onRevertibleDisposed, commitLabelTree);
551
+ this.revertibleCommitBranches.set(revision, this.#transaction.branch.fork(commit));
552
+ this.revertibles.set(revision, revertible);
553
+ return revertible;
554
+ };
555
+ let withinEventContext = true;
556
+ const events = (0, client_utils_1.createEmitter)();
557
+ this.localCommitEventEmitters.set(commit.revision, events);
558
+ const metadata = {
559
+ kind,
560
+ isLocal: true,
561
+ getChange: () => {
562
+ (0, internal_1.assert)(commit.parent !== undefined, 0xca4 /* Expected applied commit to be parented */);
563
+ return serializedChange_js_1.SerializedChange.V1.encode(this.idCompressor, this.changeFamily, change, revision);
564
+ },
565
+ getRevertible: (onDisposed) => getRevertible?.(onDisposed),
566
+ label: this.labelTreeNode?.label,
567
+ labels: buildLabelsSet(this.labelTreeNode),
568
+ events,
574
569
  };
575
- });
576
- }
577
- exportVerbose() {
578
- const cursor = this.forest.allocateCursor("contentSnapshot");
579
- try {
580
- (0, index_js_2.moveToDetachedField)(this.forest, cursor);
581
- const length = cursor.getFieldLength();
582
- if (length === 0) {
583
- return undefined;
584
- }
585
- else if (length === 1) {
586
- cursor.enterNode(0);
587
- return verboseFromCursor(cursor, this.storedSchema.nodeSchema);
588
- }
589
- else {
590
- (0, internal_1.fail)(0xac8 /* Invalid document root length */);
591
- }
592
- }
593
- finally {
594
- cursor.free();
570
+ this.emitChangedLocked(() => {
571
+ this.#events.emit("changed", metadata, getRevertible);
572
+ });
573
+ withinEventContext = false;
595
574
  }
596
575
  }
597
- /**
598
- * Hold the `editLock` for the duration of `emit`, so that re-entrant edits, transactions,
599
- * branch operations, etc. attempted from inside a `changed` listener throw the canonical
600
- * "forbidden during a change event" {@link UsageError} via {@link EditLock.checkUnlocked}.
601
- *
602
- * @remarks
603
- * Shared by both the local and remote `changed` emission paths in {@link TreeCheckout.onAfterBranchChange}.
604
- * The `try`/`finally` ensures the lock is released even if a listener throws.
605
- */
606
- emitChangedLocked(emit, reason = "a change event callback") {
607
- this.editLock.lock(reason);
608
- try {
609
- emit();
610
- }
611
- finally {
612
- // TODO: any event that throws potentially leaves the code which triggered that event,
613
- // and thus this checkout (and likely more) in a broken state.
614
- // Unlocking this editLock prevents future use of this broken state from giving a confusing error in this case,
615
- // however, a better approach would probably be to put something (this checkout and/or the editLock)
616
- // into a broken state (using a properly scoped `Breakable`),
617
- // likely by moving emitChangedLocked into EditLock, and having EditLock get a Breakable,
618
- // and having the new emitChangedLocked use `Breakable.use`.
619
- this.editLock.unlock();
576
+ else if (event.type === "remove") {
577
+ // Commits that are rolled back should no longer be revertible
578
+ for (const commit of event.removedCommits) {
579
+ this.revertibles.get(commit.revision)?.dispose();
620
580
  }
621
581
  }
622
- /**
623
- * Applies the given serialized change (as was produced via a `"changed"` event of another checkout) to this checkout.
624
- */
625
- applySerializedChange(serializedChange) {
626
- const change = serializedChange_js_1.SerializedChange.V1.decode(this.idCompressor, this.changeFamily, serializedChange);
627
- // Apply the change to the branch, but _not_ the `activeBranch` - we do not support squashing serialized commits in a transaction.
628
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.apply(change, index_js_2.CommitKind.Default, undefined);
582
+ else if (this.isRemoteChangeEvent(event)) {
583
+ // TODO: figure out how to plumb through commit kind info for remote changes
584
+ this.emitChangedLocked(() => {
585
+ this.#events.emit("changed", {
586
+ isLocal: false,
587
+ kind: index_js_2.CommitKind.Default,
588
+ labels: new Set(),
589
+ });
590
+ });
629
591
  }
630
- // #region UntypedTreeViewAlpha
631
- applyChange(change) {
632
- this.applySerializedChange(change);
592
+ };
593
+ /**
594
+ * Hold the `editLock` for the duration of `emit`, so that re-entrant edits, transactions,
595
+ * branch operations, etc. attempted from inside a `changed` listener throw the canonical
596
+ * "forbidden during a change event" {@link UsageError} via {@link EditLock.checkUnlocked}.
597
+ *
598
+ * @remarks
599
+ * Shared by both the local and remote `changed` emission paths in {@link TreeCheckout.onAfterBranchChange}.
600
+ * The `try`/`finally` ensures the lock is released even if a listener throws.
601
+ */
602
+ emitChangedLocked(emit, reason = "a change event callback") {
603
+ this.editLock.lock(reason);
604
+ try {
605
+ emit();
633
606
  }
634
- isBranch() {
635
- return this.isView();
607
+ finally {
608
+ // TODO: any event that throws potentially leaves the code which triggered that event,
609
+ // and thus this checkout (and likely more) in a broken state.
610
+ // Unlocking this editLock prevents future use of this broken state from giving a confusing error in this case,
611
+ // however, a better approach would probably be to put something (this checkout and/or the editLock)
612
+ // into a broken state (using a properly scoped `Breakable`),
613
+ // likely by moving emitChangedLocked into EditLock, and having EditLock get a Breakable,
614
+ // and having the new emitChangedLocked use `Breakable.use`.
615
+ this.editLock.unlock();
636
616
  }
637
- isView() {
638
- return true;
617
+ }
618
+ onAfterChange = (event) => {
619
+ this.editLock.lock("a change event callback");
620
+ this.#events.emit("beforeBatch", event);
621
+ if (event.change !== undefined) {
622
+ const revision = event.type === "rebase"
623
+ ? this.#transaction.activeBranch.getHead().revision
624
+ : event.change.revision;
625
+ this.applyInternalChange(event.change.change, revision);
639
626
  }
640
- hasRootSchema(_schema) {
641
- return false;
627
+ this.#events.emit("afterBatch");
628
+ this.editLock.unlock();
629
+ if (event.type === "append") {
630
+ for (const commit of event.newCommits) {
631
+ this.validateCommit(commit);
632
+ }
642
633
  }
643
- runTransaction(transaction, params) {
644
- this.mountTransaction(params, false);
645
- const transactionCallbackStatus = transaction();
646
- return this.unmountTransaction(transactionCallbackStatus, params);
634
+ };
635
+ /**
636
+ * Applies the given serialized change (as was produced via a `"changed"` event of another checkout) to this checkout.
637
+ */
638
+ applySerializedChange(serializedChange) {
639
+ const change = serializedChange_js_1.SerializedChange.V1.decode(this.idCompressor, this.changeFamily, serializedChange);
640
+ // Apply the change to the branch, but _not_ the `activeBranch` - we do not support squashing serialized commits in a transaction.
641
+ this.#transaction.branch.apply(change, index_js_2.CommitKind.Default, undefined);
642
+ }
643
+ // #region UntypedTreeViewAlpha
644
+ applyChange(change) {
645
+ this.applySerializedChange(change);
646
+ }
647
+ isBranch() {
648
+ return this.isView();
649
+ }
650
+ isView() {
651
+ return true;
652
+ }
653
+ hasRootSchema(_schema) {
654
+ return false;
655
+ }
656
+ runTransaction(transaction, params) {
657
+ this.mountTransaction(params, false);
658
+ const transactionCallbackStatus = transaction();
659
+ return this.unmountTransaction(transactionCallbackStatus, params);
660
+ }
661
+ async runTransactionAsync(transaction, params) {
662
+ this.mountTransaction(params, true);
663
+ const transactionCallbackStatus = await transaction();
664
+ return this.unmountTransaction(transactionCallbackStatus, params);
665
+ }
666
+ mountTransaction(params, isAsync) {
667
+ this.checkNotDisposed();
668
+ // Starting a transaction is an edit, so it is forbidden from within a change-event
669
+ // callback (where the edit lock is held), the same as direct edits. For the async
670
+ // entry point this throw is captured as a rejected promise by the `async` wrapper.
671
+ //
672
+ // Note: because runTransaction/runTransactionAsync are `@breakingMethod`, this throw also
673
+ // puts the checkout into a broken state (unlike a direct edit, which throws recoverably).
674
+ // That is the same pre-existing broken-state limitation tracked by the TODO in
675
+ // `emitChangedLocked`, not something specific to transactions.
676
+ this.editLock.checkUnlocked("Running a transaction");
677
+ if (isAsync && this.transaction.size > 0) {
678
+ throw new internal_2.UsageError("An asynchronous transaction cannot be started while another transaction is already in progress.");
647
679
  }
648
- async runTransactionAsync(transaction, params) {
649
- this.mountTransaction(params, true);
650
- const transactionCallbackStatus = await transaction();
651
- return this.unmountTransaction(transactionCallbackStatus, params);
680
+ this.pushLabelFrame(params?.label);
681
+ this.transaction.start({
682
+ postProcessor: (0, transactionPostProcessor_js_1.extractTransactionChangeProcessor)(params?.postProcessor),
683
+ // Like the validation described above, rejecting malformed metadata breaks the checkout rather
684
+ // than being recoverable. Tracked by https://github.com/microsoft/FluidFramework/issues/28085.
685
+ customMetadata: snapshotCustomMetadata(params?.customMetadata),
686
+ });
687
+ addConstraintsToTransaction(this, false, params?.preconditions);
688
+ }
689
+ unmountTransaction(transactionCallbackStatus, params) {
690
+ this.checkNotDisposed();
691
+ const rollback = transactionCallbackStatus?.rollback;
692
+ const value = transactionCallbackStatus?.value;
693
+ if (rollback === true) {
694
+ this.popLabelFrame(true);
695
+ this.transaction.abort();
696
+ return value === undefined
697
+ ? { success: false }
698
+ : { success: false, value: value };
652
699
  }
653
- mountTransaction(params, isAsync) {
654
- this.checkNotDisposed();
655
- // Starting a transaction is an edit, so it is forbidden from within a change-event
656
- // callback (where the edit lock is held), the same as direct edits. For the async
657
- // entry point this throw is captured as a rejected promise by the `async` wrapper.
658
- //
659
- // Note: because runTransaction/runTransactionAsync are `@breakingMethod`, this throw also
660
- // puts the checkout into a broken state (unlike a direct edit, which throws recoverably).
661
- // That is the same pre-existing broken-state limitation tracked by the TODO in
662
- // `emitChangedLocked`, not something specific to transactions.
663
- this.editLock.checkUnlocked("Running a transaction");
664
- if (isAsync && this.transaction.size > 0) {
665
- throw new internal_2.UsageError("An asynchronous transaction cannot be started while another transaction is already in progress.");
700
+ addConstraintsToTransaction(this, true, transactionCallbackStatus?.preconditionsOnRevert);
701
+ this.popLabelFrame(false);
702
+ this.runWithTransactionLabel(() => {
703
+ this.transaction.commit();
704
+ }, params?.label);
705
+ return value === undefined
706
+ ? { success: true }
707
+ : { success: true, value: value };
708
+ }
709
+ // #endregion UntypedTreeViewAlpha
710
+ // Revision is the revision of the commit, if any, which caused this change.
711
+ applyInternalChange(change, revision) {
712
+ // Conflicts due to schema will be empty and thus are not applied.
713
+ for (const innerChange of change.changes) {
714
+ if (innerChange.type === "data") {
715
+ const delta = (0, index_js_3.intoDelta)((0, index_js_2.tagChange)(innerChange.innerChange, revision));
716
+ this.withCombinedVisitor((visitor) => {
717
+ (0, index_js_2.visitDelta)(delta, visitor, this._removedRoots, revision);
718
+ });
719
+ }
720
+ else if (innerChange.type === "schema") {
721
+ // Schema changes from a current to a new schema are expected to be backwards compatible.
722
+ // This guarantees that all data in the forest (which is valid before the schema change)
723
+ // is also valid under the new schema.
724
+ // Note however, that such schema changes may in some cases be rolled back:
725
+ // Case 1: A transaction with a schema change may be aborted.
726
+ // The transaction may have made some data changes that would render some trees invalid
727
+ // under the old schema, but these changes will also be rolled back, thereby putting the forest
728
+ // back in the state before the transaction, which is valid under the original (reinstated) schema.
729
+ // Case 2: A branch with a schema change may be rebased such that the schema change (because
730
+ // of a constraint) is no longer applied.
731
+ // Such a branch may contain data changes that would render some trees invalid under the
732
+ // original schema. These data changes may not necessarily be rolled back.
733
+ // They will however be rebased over the rollback of the schema change. This rebasing will
734
+ // ensure that these data changes are muted if they would render some trees invalid under the
735
+ // original (reinstated) schema.
736
+ const newSchema = innerChange.innerChange.schema.new;
737
+ const telemetryMetrics = getSchemaChangeTelemetryMetrics(this.storedSchema, newSchema, innerChange.innerChange.isInverse);
738
+ this.storedSchema.apply(newSchema);
739
+ this.logger?.sendTelemetryEvent({
740
+ eventName: TreeCheckout.schemaChangeTelemetryEventName,
741
+ ...(0, internal_2.tagCodeArtifacts)({
742
+ details: JSON.stringify({
743
+ ...telemetryMetrics,
744
+ isSharedBranch: this.isSharedBranch,
745
+ }),
746
+ }),
747
+ });
748
+ }
749
+ else {
750
+ (0, internal_1.fail)(0xad1 /* Unknown Shared Tree change type. */);
666
751
  }
667
- this.pushLabelFrame(params?.label);
668
- this.transaction.start({
669
- postProcessor: (0, transactionPostProcessor_js_1.extractTransactionChangeProcessor)(params?.postProcessor),
670
- // Like the validation described above, rejecting malformed metadata breaks the checkout rather
671
- // than being recoverable. Tracked by https://github.com/microsoft/FluidFramework/issues/28085.
672
- customMetadata: snapshotCustomMetadata(params?.customMetadata),
673
- });
674
- addConstraintsToTransaction(this, false, params?.preconditions);
675
752
  }
676
- unmountTransaction(transactionCallbackStatus, params) {
677
- this.checkNotDisposed();
678
- const rollback = transactionCallbackStatus?.rollback;
679
- const value = transactionCallbackStatus?.value;
680
- if (rollback === true) {
681
- this.popLabelFrame(true);
682
- this.transaction.abort();
683
- return value === undefined
684
- ? { success: false }
685
- : { success: false, value: value };
753
+ }
754
+ onAncestryTrimmed = (revisions) => {
755
+ // When the branch is trimmed, we can garbage collect any repair data whose latest relevant revision is one of the
756
+ // trimmed revisions.
757
+ this.withCombinedVisitor((visitor) => {
758
+ for (const revision of revisions) {
759
+ // get all the roots last created or used by the revision
760
+ const roots = this._removedRoots.getRootsLastTouchedByRevision(revision);
761
+ // get the detached field for the root and delete it from the removed roots
762
+ for (const root of roots) {
763
+ visitor.destroy(this._removedRoots.toFieldKey(root), 1);
764
+ }
765
+ this._removedRoots.deleteRootsLastTouchedByRevision(revision);
686
766
  }
687
- addConstraintsToTransaction(this, true, transactionCallbackStatus?.preconditionsOnRevert);
688
- this.popLabelFrame(false);
689
- this.runWithTransactionLabel(() => {
690
- this.transaction.commit();
691
- }, params?.label);
692
- return value === undefined
693
- ? { success: true }
694
- : { success: true, value: value };
767
+ });
768
+ };
769
+ withCombinedVisitor(fn) {
770
+ const anchorVisitor = this.forest.anchors.acquireVisitor();
771
+ const combinedVisitor = (0, index_js_2.combineVisitors)([this.forest.acquireVisitor(), anchorVisitor]);
772
+ fn(combinedVisitor);
773
+ combinedVisitor.free();
774
+ }
775
+ checkNotDisposed(usageError) {
776
+ this.breaker.use();
777
+ if (this.disposed) {
778
+ if (usageError !== undefined) {
779
+ throw new internal_2.UsageError(usageError);
780
+ }
781
+ (0, internal_1.fail)(0x911 /* Invalid operation on a disposed TreeCheckout */);
695
782
  }
696
- // #endregion UntypedTreeViewAlpha
697
- // Revision is the revision of the commit, if any, which caused this change.
698
- applyInternalChange(change, revision) {
699
- // Conflicts due to schema will be empty and thus are not applied.
700
- for (const innerChange of change.changes) {
701
- if (innerChange.type === "data") {
702
- const delta = (0, index_js_3.intoDelta)((0, index_js_2.tagChange)(innerChange.innerChange, revision));
703
- this.withCombinedVisitor((visitor) => {
704
- (0, index_js_2.visitDelta)(delta, visitor, this._removedRoots, revision);
705
- });
783
+ }
784
+ /**
785
+ * Creates a {@link RevertibleAlpha} object that can undo a specific change in the tree's history.
786
+ * Revision must exist in the given {@link TreeCheckout}'s branch.
787
+ *
788
+ * @param revision - The revision tag identifying the change to be made revertible.
789
+ * @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).
790
+ * @param checkout - The {@link TreeCheckout} instance this revertible belongs to.
791
+ * @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.
792
+ * @param labelTree - The {@link LabelTree} (if any) active when the original commit was produced.
793
+ * The revert commit inherits these labels so that commits and their reverts can be associated.
794
+ * @returns A {@link RevertibleAlpha} object.
795
+ */
796
+ createRevertible(revision, kind, checkout, onRevertibleDisposed, labelTree) {
797
+ const commitBranches = checkout.revertibleCommitBranches;
798
+ const revertible = {
799
+ get status() {
800
+ const revertibleCommit = commitBranches.get(revision);
801
+ return revertibleCommit === undefined
802
+ ? index_js_2.RevertibleStatus.Disposed
803
+ : index_js_2.RevertibleStatus.Valid;
804
+ },
805
+ revert: (releaseOrOptions = true) => {
806
+ if (revertible.status === index_js_2.RevertibleStatus.Disposed) {
807
+ throw new internal_2.UsageError("Unable to revert a revertible that has been disposed.");
706
808
  }
707
- else if (innerChange.type === "schema") {
708
- // Schema changes from a current to a new schema are expected to be backwards compatible.
709
- // This guarantees that all data in the forest (which is valid before the schema change)
710
- // is also valid under the new schema.
711
- // Note however, that such schema changes may in some cases be rolled back:
712
- // Case 1: A transaction with a schema change may be aborted.
713
- // The transaction may have made some data changes that would render some trees invalid
714
- // under the old schema, but these changes will also be rolled back, thereby putting the forest
715
- // back in the state before the transaction, which is valid under the original (reinstated) schema.
716
- // Case 2: A branch with a schema change may be rebased such that the schema change (because
717
- // of a constraint) is no longer applied.
718
- // Such a branch may contain data changes that would render some trees invalid under the
719
- // original schema. These data changes may not necessarily be rolled back.
720
- // They will however be rebased over the rollback of the schema change. This rebasing will
721
- // ensure that these data changes are muted if they would render some trees invalid under the
722
- // original (reinstated) schema.
723
- this.storedSchema.apply(innerChange.innerChange.schema.new);
809
+ const options = typeof releaseOrOptions === "boolean"
810
+ ? { dispose: releaseOrOptions }
811
+ : releaseOrOptions;
812
+ const revertMetrics = checkout.revertRevertible(revision, kind, labelTree, snapshotCustomMetadata(options.customMetadata));
813
+ checkout.logger?.sendTelemetryEvent({
814
+ eventName: TreeCheckout.revertTelemetryEventName,
815
+ ...revertMetrics,
816
+ });
817
+ if (options.dispose ?? true) {
818
+ revertible.dispose();
724
819
  }
725
- else {
726
- (0, internal_1.fail)(0xad1 /* Unknown Shared Tree change type. */);
820
+ },
821
+ clone: (targetView) => {
822
+ // 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.
823
+ const targetCheckout = getCheckout(targetView);
824
+ const revertibleBranch = this.revertibleCommitBranches.get(revision);
825
+ if (revertibleBranch === undefined) {
826
+ throw new internal_2.UsageError("Unable to clone a revertible that has been disposed.");
727
827
  }
728
- }
828
+ const commitToRevert = revertibleBranch.getHead();
829
+ const branchHead = targetCheckout.#transaction.branch.getHead();
830
+ if ((0, index_js_2.isAncestor)(commitToRevert, branchHead, true) === false) {
831
+ throw new internal_2.UsageError("Cannot clone revertible for a commit that is not present on the given branch.");
832
+ }
833
+ targetCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());
834
+ return this.createRevertible(revision, kind, targetCheckout, onRevertibleDisposed, labelTree);
835
+ },
836
+ dispose: () => {
837
+ if (revertible.status === index_js_2.RevertibleStatus.Disposed) {
838
+ throw new internal_2.UsageError("Unable to dispose a revertible that has already been disposed.");
839
+ }
840
+ checkout.disposeRevertible(revision);
841
+ onRevertibleDisposed?.(revertible);
842
+ },
843
+ };
844
+ return revertible;
845
+ }
846
+ viewWith(config) {
847
+ const view = new schematizingTreeView_js_1.SchematizingSimpleTreeView(this, config, (0, index_js_3.createNodeIdentifierManager)(this.idCompressor), () => {
848
+ this.views.delete(view);
849
+ });
850
+ this.views.add(view);
851
+ return view;
852
+ }
853
+ get rootEvents() {
854
+ return this.forest.anchors.events;
855
+ }
856
+ get editor() {
857
+ this.checkNotDisposed();
858
+ return this.editLock.editor;
859
+ }
860
+ locate(anchor) {
861
+ this.checkNotDisposed();
862
+ return this.forest.anchors.locate(anchor);
863
+ }
864
+ get transaction() {
865
+ return this.#transaction;
866
+ }
867
+ /**
868
+ * The {@link Transactor} for this checkout.
869
+ * @remarks In the context of a checkout, transactions allow edits to be batched into atomic units.
870
+ * 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.
871
+ * If the transaction is aborted, the local state will be reset to what it was before the transaction began.
872
+ * Transactions may nest, meaning that a transaction may be started while a transaction is already ongoing.
873
+ *
874
+ * To avoid updating observers of the view state with intermediate results during a transaction,
875
+ * use {@link ITreeCheckout#fork} and {@link ISharedTreeFork#merge}.
876
+ */
877
+ #transaction;
878
+ fork() {
879
+ this.checkNotDisposed("The parent branch has already been disposed and can no longer create new branches.");
880
+ // Branching after an unfinished transaction would expose the application to a state where its invariants may be violated.
881
+ if (this.transaction.size > 0) {
882
+ throw new internal_2.UsageError("A view cannot be forked while it has a pending transaction.");
729
883
  }
730
- withCombinedVisitor(fn) {
731
- const anchorVisitor = this.forest.anchors.acquireVisitor();
732
- const combinedVisitor = (0, index_js_2.combineVisitors)([this.forest.acquireVisitor(), anchorVisitor]);
733
- fn(combinedVisitor);
734
- combinedVisitor.free();
884
+ const branch = this.#transaction.branch.fork();
885
+ const storedSchema = this.storedSchema.clone();
886
+ const forkBreaker = new index_js_6.Breakable("TreeCheckout", this.logger);
887
+ const forest = this.forest.clone(storedSchema, forkBreaker);
888
+ const checkout = new TreeCheckout(branch, false, this.changeFamily, storedSchema, forest, this.mintRevisionTag, this.revisionTagCodec, this.idCompressor, this._removedRoots.clone());
889
+ this.#events.emit("fork", checkout);
890
+ return checkout;
891
+ }
892
+ switchBranch(branch) {
893
+ (0, internal_1.assert)(this.#transaction.size === 0, 0xc55 /* Cannot switch branches during a transaction */);
894
+ if (this.isSharedBranch) {
895
+ throw new internal_2.UsageError("Cannot switch a view away from a shared branch. Consider forking first.");
735
896
  }
736
- checkNotDisposed(usageError) {
737
- this.breaker.use();
738
- if (this.disposed) {
739
- if (usageError !== undefined) {
740
- throw new internal_2.UsageError(usageError);
741
- }
742
- (0, internal_1.fail)(0x911 /* Invalid operation on a disposed TreeCheckout */);
743
- }
897
+ const diff = (0, index_js_2.diffHistories)(this.changeFamily.rebaser, this.#transaction.branch.getHead(), branch.getHead(), this.mintRevisionTag);
898
+ this.unregisterFromBranchEvents();
899
+ this.#transaction = this.createTransactionStack(branch);
900
+ this.branch = branch;
901
+ this._branchHistory?.dispose();
902
+ this._branchHistory = undefined;
903
+ this.editLock = new EditLock(this.#transaction.activeBranchEditor);
904
+ this.registerForBranchEvents();
905
+ // TODO: Rework eventing
906
+ this.applyInternalChange(diff);
907
+ this.#events.emit("afterBatch");
908
+ }
909
+ rewindTo(revisionString) {
910
+ this.checkNotDisposed("The branch has already been disposed and cannot be rewound.");
911
+ if (this.#transaction.size > 0) {
912
+ throw new internal_2.UsageError("Rewinding is not supported during transactions.");
744
913
  }
745
- /**
746
- * Creates a {@link RevertibleAlpha} object that can undo a specific change in the tree's history.
747
- * Revision must exist in the given {@link TreeCheckout}'s branch.
748
- *
749
- * @param revision - The revision tag identifying the change to be made revertible.
750
- * @param kind - The {@link CommitKind} that produced this revertible (e.g., Default, Undo, Redo).
751
- * @param checkout - The {@link TreeCheckout} instance this revertible belongs to.
752
- * @param onRevertibleDisposed - Callback function that will be called when the revertible is disposed.
753
- * @param labelTree - The {@link LabelTree} (if any) active when the original commit was produced.
754
- * The revert commit inherits these labels so that commits and their reverts can be associated.
755
- * @returns A {@link RevertibleAlpha} object.
756
- */
757
- createRevertible(revision, kind, checkout, onRevertibleDisposed, labelTree) {
758
- const commitBranches = checkout.revertibleCommitBranches;
759
- const revertible = {
760
- get status() {
761
- const revertibleCommit = commitBranches.get(revision);
762
- return revertibleCommit === undefined
763
- ? index_js_2.RevertibleStatus.Disposed
764
- : index_js_2.RevertibleStatus.Valid;
765
- },
766
- revert: (releaseOrOptions = true) => {
767
- if (revertible.status === index_js_2.RevertibleStatus.Disposed) {
768
- throw new internal_2.UsageError("Unable to revert a revertible that has been disposed.");
769
- }
770
- const options = typeof releaseOrOptions === "boolean"
771
- ? { dispose: releaseOrOptions }
772
- : releaseOrOptions;
773
- const revertMetrics = checkout.revertRevertible(revision, kind, labelTree, snapshotCustomMetadata(options.customMetadata));
774
- checkout.logger?.sendTelemetryEvent({
775
- eventName: _a.revertTelemetryEventName,
776
- ...revertMetrics,
777
- });
778
- if (options.dispose ?? true) {
779
- revertible.dispose();
780
- }
781
- },
782
- clone: (targetView) => {
783
- // 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.
784
- const targetCheckout = getCheckout(targetView);
785
- const revertibleBranch = this.revertibleCommitBranches.get(revision);
786
- if (revertibleBranch === undefined) {
787
- throw new internal_2.UsageError("Unable to clone a revertible that has been disposed.");
788
- }
789
- const commitToRevert = revertibleBranch.getHead();
790
- const branchHead = tslib_1.__classPrivateFieldGet(targetCheckout, _TreeCheckout_transaction, "f").branch.getHead();
791
- if ((0, index_js_2.isAncestor)(commitToRevert, branchHead, true) === false) {
792
- throw new internal_2.UsageError("Cannot clone revertible for a commit that is not present on the given branch.");
793
- }
794
- targetCheckout.revertibleCommitBranches.set(revision, revertibleBranch.fork());
795
- return this.createRevertible(revision, kind, targetCheckout, onRevertibleDisposed, labelTree);
796
- },
797
- dispose: () => {
798
- if (revertible.status === index_js_2.RevertibleStatus.Disposed) {
799
- throw new internal_2.UsageError("Unable to dispose a revertible that has already been disposed.");
800
- }
801
- checkout.disposeRevertible(revision);
802
- onRevertibleDisposed?.(revertible);
803
- },
804
- };
805
- return revertible;
914
+ const revision = this.idCompressor.tryRecompress(revisionString);
915
+ if (revision === undefined) {
916
+ throw new internal_2.UsageError(`Unrecognized revision id: ${revisionString}`);
806
917
  }
807
- viewWith(config) {
808
- const view = new schematizingTreeView_js_1.SchematizingSimpleTreeView(this, config, (0, index_js_3.createNodeIdentifierManager)(this.idCompressor), () => {
809
- this.views.delete(view);
810
- });
811
- this.views.add(view);
812
- return view;
918
+ const targetCommit = (0, index_js_2.findAncestor)(this.#transaction.branch.getHead(), (commit) => commit.revision === revision);
919
+ if (targetCommit === undefined) {
920
+ throw new internal_2.UsageError(`No commit found with revision: ${revisionString}`);
813
921
  }
814
- get rootEvents() {
815
- return this.forest.anchors.events;
922
+ this.switchBranch(this.#transaction.branch.fork(targetCommit));
923
+ }
924
+ revertTo(revisionString, options) {
925
+ this.checkNotDisposed("The branch has already been disposed and prior revisions cannot be reverted to.");
926
+ this.editLock.checkUnlocked("Reverting to a revision");
927
+ if (this.#transaction.size > 0) {
928
+ throw new internal_2.UsageError("Reverting to a revision is not supported during transactions.");
816
929
  }
817
- get editor() {
818
- this.checkNotDisposed();
819
- return this.editLock.editor;
930
+ const customMetadata = snapshotCustomMetadata(options?.customMetadata);
931
+ const revision = this.idCompressor.tryRecompress(revisionString);
932
+ if (revision === undefined) {
933
+ throw new internal_2.UsageError(`Unrecognized revision id: ${revisionString}`);
820
934
  }
821
- locate(anchor) {
822
- this.checkNotDisposed();
823
- return this.forest.anchors.locate(anchor);
935
+ // Populated with the commits that came after the target commit, from oldest to newest.
936
+ const commitsToUndo = [];
937
+ const targetCommit = (0, index_js_2.findAncestor)([this.#transaction.activeBranch.getHead(), commitsToUndo], (commit) => commit.revision === revision);
938
+ if (targetCommit === undefined) {
939
+ throw new internal_2.UsageError(`No commit found with revision: ${revisionString}`);
824
940
  }
825
- get transaction() {
826
- return tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f");
941
+ if (!(0, index_js_6.hasSome)(commitsToUndo)) {
942
+ // The target commit is already the head of the branch, so there is nothing to revert.
943
+ return;
827
944
  }
828
- fork() {
829
- this.checkNotDisposed("The parent branch has already been disposed and can no longer create new branches.");
830
- // Branching after an unfinished transaction would expose the application to a state where its invariants may be violated.
831
- if (this.transaction.size > 0) {
832
- throw new internal_2.UsageError("A view cannot be forked while it has a pending transaction.");
833
- }
834
- const branch = tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.fork();
835
- const storedSchema = this.storedSchema.clone();
836
- const forkBreaker = new index_js_6.Breakable("TreeCheckout", this.logger);
837
- const forest = this.forest.clone(storedSchema, forkBreaker);
838
- const checkout = new _a(branch, false, this.changeFamily, storedSchema, forest, this.mintRevisionTag, this.revisionTagCodec, this.idCompressor, this._removedRoots.clone());
839
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("fork", checkout);
840
- return checkout;
945
+ const revisionForInvert = this.mintRevisionTag();
946
+ const toUndo = this.changeFamily.rebaser.compose(commitsToUndo);
947
+ const inverse = this.changeFamily.rebaser.invert((0, index_js_2.makeAnonChange)(toUndo), false, revisionForInvert);
948
+ this.#transaction.branch.apply((0, index_js_2.tagChange)(inverse, revisionForInvert), index_js_2.CommitKind.Default, toMetadataTree(customMetadata));
949
+ }
950
+ rebase(view) {
951
+ const checkout = getCheckout(view);
952
+ this.checkNotDisposed("The target branch of the rebase has been disposed and cannot be rebased.");
953
+ checkout.checkNotDisposed("The source branch of the rebase has been disposed and cannot be rebased.");
954
+ this.editLock.checkUnlocked("Rebasing");
955
+ if (this.transaction.size > 0) {
956
+ throw new internal_2.UsageError("Views cannot be rebased onto a view that has a pending transaction.");
841
957
  }
842
- switchBranch(branch) {
843
- (0, internal_1.assert)(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").size === 0, 0xc55 /* Cannot switch branches during a transaction */);
844
- if (this.isSharedBranch) {
845
- throw new internal_2.UsageError("Cannot switch a view away from a shared branch. Consider forking first.");
846
- }
847
- const diff = (0, index_js_2.diffHistories)(this.changeFamily.rebaser, tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead(), branch.getHead(), this.mintRevisionTag);
848
- this.unregisterFromBranchEvents();
849
- tslib_1.__classPrivateFieldSet(this, _TreeCheckout_transaction, this.createTransactionStack(branch), "f");
850
- this.branch = branch;
851
- this._branchHistory?.dispose();
852
- this._branchHistory = undefined;
853
- this.editLock = new EditLock(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranchEditor);
854
- this.registerForBranchEvents();
855
- // TODO: Rework eventing
856
- this.applyInternalChange(diff);
857
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("afterBatch");
958
+ if (checkout.transaction.size > 0) {
959
+ throw new internal_2.UsageError("A view cannot be rebased while it has a pending transaction.");
858
960
  }
859
- rewindTo(revisionString) {
860
- this.checkNotDisposed("The branch has already been disposed and cannot be rewound.");
861
- if (tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").size > 0) {
862
- throw new internal_2.UsageError("Rewinding is not supported during transactions.");
863
- }
864
- const revision = this.idCompressor.tryRecompress(revisionString);
865
- if (revision === undefined) {
866
- throw new internal_2.UsageError(`Unrecognized revision id: ${revisionString}`);
867
- }
868
- const targetCommit = (0, index_js_2.findAncestor)(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead(), (commit) => commit.revision === revision);
869
- if (targetCommit === undefined) {
870
- throw new internal_2.UsageError(`No commit found with revision: ${revisionString}`);
871
- }
872
- this.switchBranch(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.fork(targetCommit));
961
+ (0, internal_1.assert)(!checkout.isSharedBranch, 0xa5d /* Shared branches cannot be rebased onto another branch. */);
962
+ checkout.#transaction.branch.rebaseOnto(this.#transaction.branch);
963
+ }
964
+ rebaseOnto(view) {
965
+ getCheckout(view).rebase(this);
966
+ }
967
+ isMissingEditsFrom(view) {
968
+ const viewCheckout = getCheckout(view);
969
+ const targetPath = [];
970
+ const ancestor = (0, index_js_2.findCommonAncestor)(this.mainBranch.getHead(), [
971
+ viewCheckout.mainBranch.getHead(),
972
+ targetPath,
973
+ ]);
974
+ if (ancestor === undefined) {
975
+ throw new internal_2.UsageError("Branches do not share a common ancestor.");
873
976
  }
874
- revertTo(revisionString, options) {
875
- this.checkNotDisposed("The branch has already been disposed and prior revisions cannot be reverted to.");
876
- this.editLock.checkUnlocked("Reverting to a revision");
877
- if (tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").size > 0) {
878
- throw new internal_2.UsageError("Reverting to a revision is not supported during transactions.");
879
- }
880
- const customMetadata = snapshotCustomMetadata(options?.customMetadata);
881
- const revision = this.idCompressor.tryRecompress(revisionString);
882
- if (revision === undefined) {
883
- throw new internal_2.UsageError(`Unrecognized revision id: ${revisionString}`);
884
- }
885
- // Populated with the commits that came after the target commit, from oldest to newest.
886
- const commitsToUndo = [];
887
- const targetCommit = (0, index_js_2.findAncestor)([tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranch.getHead(), commitsToUndo], (commit) => commit.revision === revision);
888
- if (targetCommit === undefined) {
889
- throw new internal_2.UsageError(`No commit found with revision: ${revisionString}`);
890
- }
891
- if (!(0, index_js_6.hasSome)(commitsToUndo)) {
892
- // The target commit is already the head of the branch, so there is nothing to revert.
893
- return;
894
- }
895
- const revisionForInvert = this.mintRevisionTag();
896
- const toUndo = this.changeFamily.rebaser.compose(commitsToUndo);
897
- const inverse = this.changeFamily.rebaser.invert((0, index_js_2.makeAnonChange)(toUndo), false, revisionForInvert);
898
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.apply((0, index_js_2.tagChange)(inverse, revisionForInvert), index_js_2.CommitKind.Default, toMetadataTree(customMetadata));
977
+ return targetPath.length > 0;
978
+ }
979
+ computeNetChangeIfRebasedOnto(view) {
980
+ const viewCheckout = getCheckout(view);
981
+ const rebased = (0, index_js_2.rebaseBranch)(this.mintRevisionTag, this.changeFamily.rebaser, this.#transaction.branch.getHead(), viewCheckout.#transaction.branch.getHead());
982
+ if (rebased.sourceChange === undefined) {
983
+ return undefined;
899
984
  }
900
- rebase(view) {
901
- const checkout = getCheckout(view);
902
- this.checkNotDisposed("The target branch of the rebase has been disposed and cannot be rebased.");
903
- checkout.checkNotDisposed("The source branch of the rebase has been disposed and cannot be rebased.");
904
- this.editLock.checkUnlocked("Rebasing");
905
- if (this.transaction.size > 0) {
906
- throw new internal_2.UsageError("Views cannot be rebased onto a view that has a pending transaction.");
907
- }
908
- if (checkout.transaction.size > 0) {
909
- throw new internal_2.UsageError("A view cannot be rebased while it has a pending transaction.");
910
- }
911
- (0, internal_1.assert)(!checkout.isSharedBranch, 0xa5d /* Shared branches cannot be rebased onto another branch. */);
912
- tslib_1.__classPrivateFieldGet(checkout, _TreeCheckout_transaction, "f").branch.rebaseOnto(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch);
985
+ const revision = this.mintRevisionTag();
986
+ return serializedChange_js_1.SerializedChange.V1.encode(this.idCompressor, this.changeFamily, rebased.sourceChange, revision, undefined);
987
+ }
988
+ merge(view, disposeMerged = true) {
989
+ const checkout = getCheckout(view);
990
+ this.checkNotDisposed("The target branch of the merge has been disposed and cannot be merged.");
991
+ checkout.checkNotDisposed("The source branch of the merge has been disposed and cannot be merged.");
992
+ this.editLock.checkUnlocked("Merging");
993
+ if (this.transaction.size > 0) {
994
+ throw new internal_2.UsageError("Views cannot be merged into a view while it has a pending transaction.");
913
995
  }
914
- rebaseOnto(view) {
915
- getCheckout(view).rebase(this);
996
+ if (checkout.transaction.size > 0) {
997
+ throw new internal_2.UsageError("Views with an open transaction cannot be merged into another view.");
916
998
  }
917
- isMissingEditsFrom(view) {
918
- const viewCheckout = getCheckout(view);
919
- const targetPath = [];
920
- const ancestor = (0, index_js_2.findCommonAncestor)(this.mainBranch.getHead(), [
921
- viewCheckout.mainBranch.getHead(),
922
- targetPath,
923
- ]);
924
- if (ancestor === undefined) {
925
- throw new internal_2.UsageError("Branches do not share a common ancestor.");
926
- }
927
- return targetPath.length > 0;
999
+ this.#transaction.branch.merge(checkout.#transaction.branch);
1000
+ if (disposeMerged && !checkout.isSharedBranch) {
1001
+ // Dispose the merged checkout unless it is a shared branch.
1002
+ checkout[index_js_6.disposeSymbol]();
928
1003
  }
929
- computeNetChangeIfRebasedOnto(view) {
930
- const viewCheckout = getCheckout(view);
931
- const rebased = (0, index_js_2.rebaseBranch)(this.mintRevisionTag, this.changeFamily.rebaser, tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead(), tslib_1.__classPrivateFieldGet(viewCheckout, _TreeCheckout_transaction, "f").branch.getHead());
932
- if (rebased.sourceChange === undefined) {
933
- return undefined;
934
- }
935
- const revision = this.mintRevisionTag();
936
- return serializedChange_js_1.SerializedChange.V1.encode(this.idCompressor, this.changeFamily, rebased.sourceChange, revision, undefined);
1004
+ }
1005
+ updateSchema(newSchema, allowNonSupersetSchema) {
1006
+ this.checkNotDisposed();
1007
+ if (allowNonSupersetSchema !== true) {
1008
+ (0, internal_1.assert)((0, index_js_3.allowsRepoSuperset)(index_js_3.defaultSchemaPolicy, this.storedSchema.clone(), newSchema), 0xbe6 /* New schema must allow all documents allowed by old schema */);
937
1009
  }
938
- merge(view, disposeMerged = true) {
939
- const checkout = getCheckout(view);
940
- this.checkNotDisposed("The target branch of the merge has been disposed and cannot be merged.");
941
- checkout.checkNotDisposed("The source branch of the merge has been disposed and cannot be merged.");
942
- this.editLock.checkUnlocked("Merging");
943
- if (this.transaction.size > 0) {
944
- throw new internal_2.UsageError("Views cannot be merged into a view while it has a pending transaction.");
945
- }
946
- if (checkout.transaction.size > 0) {
947
- throw new internal_2.UsageError("Views with an open transaction cannot be merged into another view.");
948
- }
949
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.merge(tslib_1.__classPrivateFieldGet(checkout, _TreeCheckout_transaction, "f").branch);
950
- if (disposeMerged && !checkout.isSharedBranch) {
951
- // Dispose the merged checkout unless it is a shared branch.
952
- checkout[index_js_6.disposeSymbol]();
953
- }
1010
+ this.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);
1011
+ }
1012
+ dispose() {
1013
+ this.editLock.checkUnlocked("Disposing a view");
1014
+ this[index_js_6.disposeSymbol]();
1015
+ }
1016
+ [(_exportVerbose_decorators = [index_js_6.throwIfBroken], _applySerializedChange_decorators = [index_js_6.throwIfBroken], _applyChange_decorators = [index_js_6.throwIfBroken], _runTransaction_decorators = [index_js_6.breakingMethod], _runTransactionAsync_decorators = [index_js_6.breakingMethod], _withCombinedVisitor_decorators = [index_js_6.breakingMethod], _viewWith_decorators = [index_js_6.throwIfBroken], _fork_decorators = [index_js_6.throwIfBroken], index_js_6.disposeSymbol)]() {
1017
+ this.checkNotDisposed("The branch has already been disposed and cannot be disposed again.");
1018
+ this.disposed = true;
1019
+ this.#transaction.branch.dispose();
1020
+ this.#transaction.dispose();
1021
+ this.purgeRevertibles();
1022
+ for (const view of this.views) {
1023
+ view.dispose();
954
1024
  }
955
- updateSchema(newSchema, allowNonSupersetSchema) {
956
- this.checkNotDisposed();
957
- if (allowNonSupersetSchema !== true) {
958
- (0, internal_1.assert)((0, index_js_3.allowsRepoSuperset)(index_js_3.defaultSchemaPolicy, this.storedSchema.clone(), newSchema), 0xbe6 /* New schema must allow all documents allowed by old schema */);
959
- }
960
- this.editor.schema.setStoredSchema(this.storedSchema.clone(), newSchema);
1025
+ this.#events.emit("dispose");
1026
+ this._branchHistory?.dispose();
1027
+ this._branchHistory = undefined;
1028
+ }
1029
+ getRemovedRoots() {
1030
+ this.assertNoUntrackedRoots();
1031
+ const trees = [];
1032
+ const cursor = this.forest.allocateCursor("getRemovedRoots");
1033
+ for (const { id, root } of this._removedRoots.entries()) {
1034
+ const parentField = this._removedRoots.toFieldKey(root);
1035
+ this.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);
1036
+ const tree = (0, index_js_3.jsonableTreeFromCursor)(cursor);
1037
+ // This method is used for tree consistency comparison.
1038
+ const { major, minor } = id;
1039
+ const finalizedMajor = major === undefined ? major : this.revisionTagCodec.encode(major);
1040
+ trees.push([finalizedMajor, minor, tree]);
961
1041
  }
962
- dispose() {
963
- this.editLock.checkUnlocked("Disposing a view");
964
- this[index_js_6.disposeSymbol]();
1042
+ cursor.free();
1043
+ return trees;
1044
+ }
1045
+ /**
1046
+ * This must be called on the root/main checkout after loading from a summary.
1047
+ * @remarks This pattern is necessary because the EditManager skips the normal process of applying commits to branches when loading a summary.
1048
+ * Instead, it simply {@link SharedTreeBranch#setHead | mutates} the branches directly which does not propagate the typical events throughout the rest of the system.
1049
+ */
1050
+ load() {
1051
+ // 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.
1052
+ // 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).
1053
+ this._removedRoots.setRevisionsForLoadedData(this.#transaction.branch.getHead().revision);
1054
+ // The content of the checkout (e.g. the forest) has (maybe) changed, so fire an afterBatch event.
1055
+ this.#events.emit("afterBatch");
1056
+ }
1057
+ purgeRevertibles() {
1058
+ for (const revertible of this.revertibles.values()) {
1059
+ revertible.dispose();
965
1060
  }
966
- [(_TreeCheckout_events = new WeakMap(), _TreeCheckout_transaction = new WeakMap(), _TreeCheckout_validatedCommits = new WeakMap(), _exportVerbose_decorators = [index_js_6.throwIfBroken], _applySerializedChange_decorators = [index_js_6.throwIfBroken], _applyChange_decorators = [index_js_6.throwIfBroken], _runTransaction_decorators = [index_js_6.breakingMethod], _runTransactionAsync_decorators = [index_js_6.breakingMethod], _withCombinedVisitor_decorators = [index_js_6.breakingMethod], _viewWith_decorators = [index_js_6.throwIfBroken], _fork_decorators = [index_js_6.throwIfBroken], index_js_6.disposeSymbol)]() {
967
- this.checkNotDisposed("The branch has already been disposed and cannot be disposed again.");
968
- this.disposed = true;
969
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.dispose();
970
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").dispose();
971
- this.purgeRevertibles();
972
- for (const view of this.views) {
973
- view.dispose();
974
- }
975
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("dispose");
976
- this._branchHistory?.dispose();
977
- this._branchHistory = undefined;
1061
+ }
1062
+ disposeRevertible(revision) {
1063
+ this.revertibleCommitBranches.get(revision)?.dispose();
1064
+ this.revertibleCommitBranches.delete(revision);
1065
+ this.revertibles.delete(revision);
1066
+ }
1067
+ revertRevertible(revision, kind, labelTree, customMetadata) {
1068
+ this.editLock.checkUnlocked("Reverting a commit");
1069
+ if (this.transaction.size > 0) {
1070
+ throw new internal_2.UsageError("Undo is not yet supported during transactions.");
978
1071
  }
979
- getRemovedRoots() {
980
- this.assertNoUntrackedRoots();
981
- const trees = [];
982
- const cursor = this.forest.allocateCursor("getRemovedRoots");
983
- for (const { id, root } of this._removedRoots.entries()) {
984
- const parentField = this._removedRoots.toFieldKey(root);
985
- this.forest.moveCursorToPath({ parent: undefined, parentField, parentIndex: 0 }, cursor);
986
- const tree = (0, index_js_3.jsonableTreeFromCursor)(cursor);
987
- // This method is used for tree consistency comparison.
988
- const { major, minor } = id;
989
- const finalizedMajor = major === undefined ? major : this.revisionTagCodec.encode(major);
990
- trees.push([finalizedMajor, minor, tree]);
991
- }
992
- cursor.free();
993
- return trees;
1072
+ const revertibleBranch = this.revertibleCommitBranches.get(revision);
1073
+ (0, internal_1.assert)(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);
1074
+ const commitToRevert = revertibleBranch.getHead();
1075
+ const revisionForInvert = this.mintRevisionTag();
1076
+ let change = (0, index_js_2.tagChange)(this.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert), revisionForInvert);
1077
+ const headCommit = this.#transaction.branch.getHead();
1078
+ // Rebase the inverted change onto any commits that occurred after the undoable commits.
1079
+ if (commitToRevert !== headCommit) {
1080
+ // The inverse may be rebased over newer commits which (despite being present in the history)
1081
+ // have no net effect on the document state (e.g. an edit plus its undo).
1082
+ // In that case, a no-change constraint should not be violated during rebase.
1083
+ const diff = (0, index_js_2.diffHistories)(this.changeFamily.rebaser, commitToRevert, headCommit, this.mintRevisionTag);
1084
+ const ignoreNoChangeViolation = !sharedTreeChangeHasApplicationFacingChanges(diff);
1085
+ change = (0, index_js_2.tagChange)((0, index_js_2.rebaseChange)(this.changeFamily.rebaser, change, commitToRevert, headCommit, this.mintRevisionTag, ignoreNoChangeViolation).change, revisionForInvert);
994
1086
  }
995
- /**
996
- * This must be called on the root/main checkout after loading from a summary.
997
- * @remarks This pattern is necessary because the EditManager skips the normal process of applying commits to branches when loading a summary.
998
- * Instead, it simply {@link SharedTreeBranch#setHead | mutates} the branches directly which does not propagate the typical events throughout the rest of the system.
999
- */
1000
- load() {
1001
- // 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.
1002
- // 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).
1003
- this._removedRoots.setRevisionsForLoadedData(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead().revision);
1004
- // The content of the checkout (e.g. the forest) has (maybe) changed, so fire an afterBatch event.
1005
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_events, "f").emit("afterBatch");
1087
+ // Install the original commit's label tree so the revert commit's metadata inherits
1088
+ // the same labels. Reusing the captured tree (rather than wrapping it) ensures
1089
+ // revert-of-revert does not introduce new nesting.
1090
+ const previousLabelTreeNode = this.labelTreeNode;
1091
+ this.labelTreeNode = labelTree;
1092
+ try {
1093
+ this.#transaction.branch.apply(change, kind === index_js_2.CommitKind.Default || kind === index_js_2.CommitKind.Redo
1094
+ ? index_js_2.CommitKind.Undo
1095
+ : index_js_2.CommitKind.Redo, toMetadataTree(customMetadata));
1006
1096
  }
1007
- purgeRevertibles() {
1008
- for (const revertible of this.revertibles.values()) {
1009
- revertible.dispose();
1010
- }
1097
+ finally {
1098
+ this.labelTreeNode = previousLabelTreeNode;
1011
1099
  }
1012
- disposeRevertible(revision) {
1013
- this.revertibleCommitBranches.get(revision)?.dispose();
1014
- this.revertibleCommitBranches.delete(revision);
1015
- this.revertibles.delete(revision);
1100
+ // Derive some stats about the reversion to return to the caller.
1101
+ let revertAge = 0;
1102
+ let currentCommit = headCommit;
1103
+ while (commitToRevert.revision !== currentCommit.revision) {
1104
+ revertAge++;
1105
+ const parentCommit = currentCommit.parent;
1106
+ (0, internal_1.assert)(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);
1107
+ currentCommit = parentCommit;
1016
1108
  }
1017
- revertRevertible(revision, kind, labelTree, customMetadata) {
1018
- this.editLock.checkUnlocked("Reverting a commit");
1019
- if (this.transaction.size > 0) {
1020
- throw new internal_2.UsageError("Undo is not yet supported during transactions.");
1021
- }
1022
- const revertibleBranch = this.revertibleCommitBranches.get(revision);
1023
- (0, internal_1.assert)(revertibleBranch !== undefined, 0x7cc /* expected to find a revertible commit */);
1024
- const commitToRevert = revertibleBranch.getHead();
1025
- const revisionForInvert = this.mintRevisionTag();
1026
- let change = (0, index_js_2.tagChange)(this.changeFamily.rebaser.invert(commitToRevert, false, revisionForInvert), revisionForInvert);
1027
- const headCommit = tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.getHead();
1028
- // Rebase the inverted change onto any commits that occurred after the undoable commits.
1029
- if (commitToRevert !== headCommit) {
1030
- // The inverse may be rebased over newer commits which (despite being present in the history)
1031
- // have no net effect on the document state (e.g. an edit plus its undo).
1032
- // In that case, a no-change constraint should not be violated during rebase.
1033
- const diff = (0, index_js_2.diffHistories)(this.changeFamily.rebaser, commitToRevert, headCommit, this.mintRevisionTag);
1034
- const ignoreNoChangeViolation = !sharedTreeChangeHasVisibleChanges(diff);
1035
- change = (0, index_js_2.tagChange)((0, index_js_2.rebaseChange)(this.changeFamily.rebaser, change, commitToRevert, headCommit, this.mintRevisionTag, ignoreNoChangeViolation).change, revisionForInvert);
1036
- }
1037
- // Install the original commit's label tree so the revert commit's metadata inherits
1038
- // the same labels. Reusing the captured tree (rather than wrapping it) ensures
1039
- // revert-of-revert does not introduce new nesting.
1040
- const previousLabelTreeNode = this.labelTreeNode;
1041
- this.labelTreeNode = labelTree;
1042
- try {
1043
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch.apply(change, kind === index_js_2.CommitKind.Default || kind === index_js_2.CommitKind.Redo
1044
- ? index_js_2.CommitKind.Undo
1045
- : index_js_2.CommitKind.Redo, toMetadataTree(customMetadata));
1046
- }
1047
- finally {
1048
- this.labelTreeNode = previousLabelTreeNode;
1049
- }
1050
- // Derive some stats about the reversion to return to the caller.
1051
- let revertAge = 0;
1052
- let currentCommit = headCommit;
1053
- while (commitToRevert.revision !== currentCommit.revision) {
1054
- revertAge++;
1055
- const parentCommit = currentCommit.parent;
1056
- (0, internal_1.assert)(parentCommit !== undefined, 0x9a9 /* expected to find a parent commit */);
1057
- currentCommit = parentCommit;
1058
- }
1059
- return { age: revertAge };
1109
+ return { age: revertAge };
1110
+ }
1111
+ assertNoUntrackedRoots() {
1112
+ const cursor = this.forest.getCursorAboveDetachedFields();
1113
+ const rootFields = new Set([index_js_2.rootFieldKey]);
1114
+ for (const { root } of this._removedRoots.entries()) {
1115
+ rootFields.add(this._removedRoots.toFieldKey(root));
1060
1116
  }
1061
- assertNoUntrackedRoots() {
1062
- const cursor = this.forest.getCursorAboveDetachedFields();
1063
- const rootFields = new Set([index_js_2.rootFieldKey]);
1064
- for (const { root } of this._removedRoots.entries()) {
1065
- rootFields.add(this._removedRoots.toFieldKey(root));
1066
- }
1067
- if (!cursor.firstField()) {
1068
- return;
1069
- }
1070
- do {
1071
- const field = cursor.getFieldKey();
1072
- (0, internal_1.assert)(rootFields.has(field), 0xa22 /* Forest has a root field which is unknown to the detached field index */);
1073
- rootFields.delete(field);
1074
- } while (cursor.nextField());
1117
+ if (!cursor.firstField()) {
1118
+ return;
1075
1119
  }
1076
- /**
1077
- * `true` iff the given branch change event is due to a remote change
1078
- */
1079
- isRemoteChangeEvent(event) {
1080
- return (
1081
- // Remote changes are only ever applied to shared branches
1082
- this.isSharedBranch &&
1083
- // Remote changes are applied to the branch by rebasing it onto the trunk.
1084
- // No other rebases are allowed on shared branches, so we can use this to detect remote changes.
1085
- event.type === "rebase");
1120
+ do {
1121
+ const field = cursor.getFieldKey();
1122
+ (0, internal_1.assert)(rootFields.has(field), 0xa22 /* Forest has a root field which is unknown to the detached field index */);
1123
+ rootFields.delete(field);
1124
+ } while (cursor.nextField());
1125
+ }
1126
+ /**
1127
+ * `true` iff the given branch change event is due to a remote change
1128
+ */
1129
+ isRemoteChangeEvent(event) {
1130
+ return (
1131
+ // Remote changes are only ever applied to shared branches
1132
+ this.isSharedBranch &&
1133
+ // Remote changes are applied to the branch by rebasing it onto the trunk.
1134
+ // No other rebases are allowed on shared branches, so we can use this to detect remote changes.
1135
+ event.type === "rebase");
1136
+ }
1137
+ // #region Commit Validation
1138
+ /** Used to maintain the contract of {@link onCommitValid}(). */
1139
+ #validatedCommits = new WeakMap();
1140
+ /**
1141
+ * Registers a function to be called when the given commit is validated.
1142
+ * @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).
1143
+ * 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.
1144
+ * 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).
1145
+ *
1146
+ * If the commit has already been validated when this function is called, the function is called immediately and this function returns `true`.
1147
+ * Otherwise, the function is registered to be called later and this function returns `false`.
1148
+ */
1149
+ onCommitValid(commit, fn) {
1150
+ const validated = (0, index_js_6.getOrCreate)(this.#validatedCommits, commit, () => []);
1151
+ if (validated === true) {
1152
+ fn(commit);
1153
+ return true;
1086
1154
  }
1087
- /**
1088
- * Registers a function to be called when the given commit is validated.
1089
- * @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).
1090
- * 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.
1091
- * 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).
1092
- *
1093
- * If the commit has already been validated when this function is called, the function is called immediately and this function returns `true`.
1094
- * Otherwise, the function is registered to be called later and this function returns `false`.
1095
- */
1096
- onCommitValid(commit, fn) {
1097
- const validated = (0, index_js_6.getOrCreate)(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_validatedCommits, "f"), commit, () => []);
1098
- if (validated === true) {
1155
+ validated.push(fn);
1156
+ return false;
1157
+ }
1158
+ /** Mark the given commit as "validated" according to the contract of {@link onCommitValid}(). */
1159
+ validateCommit(commit) {
1160
+ const validated = (0, index_js_6.getOrCreate)(this.#validatedCommits, commit, () => []);
1161
+ if (validated !== true) {
1162
+ for (const fn of validated) {
1099
1163
  fn(commit);
1100
- return true;
1101
- }
1102
- validated.push(fn);
1103
- return false;
1104
- }
1105
- /** Mark the given commit as "validated" according to the contract of {@link onCommitValid}(). */
1106
- validateCommit(commit) {
1107
- const validated = (0, index_js_6.getOrCreate)(tslib_1.__classPrivateFieldGet(this, _TreeCheckout_validatedCommits, "f"), commit, () => []);
1108
- if (validated !== true) {
1109
- for (const fn of validated) {
1110
- fn(commit);
1111
- }
1112
- tslib_1.__classPrivateFieldGet(this, _TreeCheckout_validatedCommits, "f").set(commit, true);
1113
1164
  }
1165
+ this.#validatedCommits.set(commit, true);
1114
1166
  }
1115
- resetEnrichmentStats() {
1116
- this.enrichmentStats.batches = 0;
1117
- this.enrichmentStats.diffs = 0;
1118
- this.enrichmentStats.commitsEnriched = 0;
1119
- this.enrichmentStats.refreshers = 0;
1120
- this.enrichmentStats.forks = 0;
1121
- this.enrichmentStats.applied = 0;
1167
+ }
1168
+ // #endregion Commit Validation
1169
+ // #region Enrichment
1170
+ /**
1171
+ * Statistics about enrichment operations performed by this checkout.
1172
+ * Used for testing. May be used for telemetry in the future.
1173
+ * The performance cost of maintaining this information is negligible.
1174
+ */
1175
+ enrichmentStats = { batches: 0, diffs: 0, commitsEnriched: 0, refreshers: 0, forks: 0, applied: 0 };
1176
+ resetEnrichmentStats() {
1177
+ this.enrichmentStats.batches = 0;
1178
+ this.enrichmentStats.diffs = 0;
1179
+ this.enrichmentStats.commitsEnriched = 0;
1180
+ this.enrichmentStats.refreshers = 0;
1181
+ this.enrichmentStats.forks = 0;
1182
+ this.enrichmentStats.applied = 0;
1183
+ }
1184
+ getEnrichmentStats() {
1185
+ return { ...this.enrichmentStats };
1186
+ }
1187
+ enrich(context, changes, forceValidation) {
1188
+ if (!(0, index_js_6.hasSome)(changes)) {
1189
+ return [];
1122
1190
  }
1123
- getEnrichmentStats() {
1124
- return { ...this.enrichmentStats };
1191
+ this.enrichmentStats.batches += 1;
1192
+ const enricher = new sharedTreeChangeEnricher_js_1.SharedTreeChangeEnricher(this.forest, this._removedRoots, this.storedSchema, this.idCompressor, () => (this.enrichmentStats.commitsEnriched += 1), () => (this.enrichmentStats.refreshers += 1), () => (this.enrichmentStats.forks += 1), () => (this.enrichmentStats.applied += 1));
1193
+ // This `lastCommitApplied` may be on the main branch or on a transaction branch.
1194
+ // In either case, it is crucial that the state of the forest & detached field index reflects all changes up to and including this commit.
1195
+ const lastCommitApplied = this.#transaction.activeBranch.getHead();
1196
+ if (context !== lastCommitApplied) {
1197
+ enricher.enqueueChange(() => {
1198
+ this.enrichmentStats.diffs += 1;
1199
+ const diff = (0, index_js_2.diffHistories)(this.changeFamily.rebaser, lastCommitApplied, context, this.mintRevisionTag);
1200
+ return (0, index_js_2.makeAnonChange)(diff);
1201
+ });
1125
1202
  }
1126
- enrich(context, changes, forceValidation) {
1127
- if (!(0, index_js_6.hasSome)(changes)) {
1128
- return [];
1129
- }
1130
- this.enrichmentStats.batches += 1;
1131
- const enricher = new sharedTreeChangeEnricher_js_1.SharedTreeChangeEnricher(this.forest, this._removedRoots, this.storedSchema, this.idCompressor, () => (this.enrichmentStats.commitsEnriched += 1), () => (this.enrichmentStats.refreshers += 1), () => (this.enrichmentStats.forks += 1), () => (this.enrichmentStats.applied += 1));
1132
- // This `lastCommitApplied` may be on the main branch or on a transaction branch.
1133
- // In either case, it is crucial that the state of the forest & detached field index reflects all changes up to and including this commit.
1134
- const lastCommitApplied = tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").activeBranch.getHead();
1135
- if (context !== lastCommitApplied) {
1136
- enricher.enqueueChange(() => {
1137
- this.enrichmentStats.diffs += 1;
1138
- const diff = (0, index_js_2.diffHistories)(this.changeFamily.rebaser, lastCommitApplied, context, this.mintRevisionTag);
1139
- return (0, index_js_2.makeAnonChange)(diff);
1140
- });
1141
- }
1142
- const enrichedChanges = [];
1143
- for (const change of changes) {
1144
- const enrichedChange = enricher.enrich(change.change);
1145
- enrichedChanges.push(enrichedChange);
1146
- // We could either apply the original or the enriched change: either should allow subsequent changes to be enriched correctly.
1147
- // We choose to apply the enriched change in order to more closely replicate what a peer will experience (assuming no concurrent changes).
1148
- // This makes it more likely that we'll detect a bug in the enrichment logic.
1149
- // Note that enqueueing the change does not guarantee that it will be applied unless `forceValidation` is enabled.
1150
- enricher.enqueueChange((0, index_js_2.tagChange)(enrichedChange, change.revision));
1151
- }
1152
- if (forceValidation) {
1153
- // Ensure that all changes can be applied successfully.
1154
- // This is useful for catching bugs in the enrichment logic and in the rebasing logic that may have been involved in producing the changes.
1155
- // Note that we cannot guarantee that the enriched change will be applied successfully even in the absence of concurrent changes,
1156
- // because the checkout state we are applying this enriched change to was derived from the state of the checkout, which may be different from that of a peer.
1157
- enricher.purgeChangeQueue();
1158
- }
1159
- enricher[index_js_6.disposeSymbol]();
1160
- return enrichedChanges;
1203
+ const enrichedChanges = [];
1204
+ for (const change of changes) {
1205
+ const enrichedChange = enricher.enrich(change.change);
1206
+ enrichedChanges.push(enrichedChange);
1207
+ // We could either apply the original or the enriched change: either should allow subsequent changes to be enriched correctly.
1208
+ // We choose to apply the enriched change in order to more closely replicate what a peer will experience (assuming no concurrent changes).
1209
+ // This makes it more likely that we'll detect a bug in the enrichment logic.
1210
+ // Note that enqueueing the change does not guarantee that it will be applied unless `forceValidation` is enabled.
1211
+ enricher.enqueueChange((0, index_js_2.tagChange)(enrichedChange, change.revision));
1161
1212
  }
1162
- get mainBranch() {
1163
- return tslib_1.__classPrivateFieldGet(this, _TreeCheckout_transaction, "f").branch;
1213
+ if (forceValidation) {
1214
+ // Ensure that all changes can be applied successfully.
1215
+ // This is useful for catching bugs in the enrichment logic and in the rebasing logic that may have been involved in producing the changes.
1216
+ // Note that we cannot guarantee that the enriched change will be applied successfully even in the absence of concurrent changes,
1217
+ // because the checkout state we are applying this enriched change to was derived from the state of the checkout, which may be different from that of a peer.
1218
+ enricher.purgeChangeQueue();
1164
1219
  }
1165
- },
1166
- (() => {
1167
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
1168
- tslib_1.__esDecorate(_a, null, _exportVerbose_decorators, { kind: "method", name: "exportVerbose", static: false, private: false, access: { has: obj => "exportVerbose" in obj, get: obj => obj.exportVerbose }, metadata: _metadata }, null, _instanceExtraInitializers);
1169
- tslib_1.__esDecorate(_a, null, _applySerializedChange_decorators, { kind: "method", name: "applySerializedChange", static: false, private: false, access: { has: obj => "applySerializedChange" in obj, get: obj => obj.applySerializedChange }, metadata: _metadata }, null, _instanceExtraInitializers);
1170
- tslib_1.__esDecorate(_a, null, _applyChange_decorators, { kind: "method", name: "applyChange", static: false, private: false, access: { has: obj => "applyChange" in obj, get: obj => obj.applyChange }, metadata: _metadata }, null, _instanceExtraInitializers);
1171
- tslib_1.__esDecorate(_a, null, _runTransaction_decorators, { kind: "method", name: "runTransaction", static: false, private: false, access: { has: obj => "runTransaction" in obj, get: obj => obj.runTransaction }, metadata: _metadata }, null, _instanceExtraInitializers);
1172
- tslib_1.__esDecorate(_a, null, _runTransactionAsync_decorators, { kind: "method", name: "runTransactionAsync", static: false, private: false, access: { has: obj => "runTransactionAsync" in obj, get: obj => obj.runTransactionAsync }, metadata: _metadata }, null, _instanceExtraInitializers);
1173
- tslib_1.__esDecorate(_a, null, _withCombinedVisitor_decorators, { kind: "method", name: "withCombinedVisitor", static: false, private: false, access: { has: obj => "withCombinedVisitor" in obj, get: obj => obj.withCombinedVisitor }, metadata: _metadata }, null, _instanceExtraInitializers);
1174
- tslib_1.__esDecorate(_a, null, _viewWith_decorators, { kind: "method", name: "viewWith", static: false, private: false, access: { has: obj => "viewWith" in obj, get: obj => obj.viewWith }, metadata: _metadata }, null, _instanceExtraInitializers);
1175
- tslib_1.__esDecorate(_a, null, _fork_decorators, { kind: "method", name: "fork", static: false, private: false, access: { has: obj => "fork" in obj, get: obj => obj.fork }, metadata: _metadata }, null, _instanceExtraInitializers);
1176
- if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1177
- })(),
1178
- /**
1179
- * The name of the telemetry event logged for calls to {@link TreeCheckout.revertRevertible}.
1180
- * @privateRemarks Exposed for testing purposes.
1181
- */
1182
- _a.revertTelemetryEventName = "RevertRevertible",
1183
- _a;
1220
+ enricher[index_js_6.disposeSymbol]();
1221
+ return enrichedChanges;
1222
+ }
1223
+ get mainBranch() {
1224
+ return this.#transaction.branch;
1225
+ }
1226
+ };
1184
1227
  })();
1185
1228
  exports.TreeCheckout = TreeCheckout;
1229
+ function getSchemaChangeTelemetryMetrics(oldSchema, newSchema, isInverse) {
1230
+ let addedNodeSchemaCount = 0;
1231
+ for (const identifier of newSchema.nodeSchema.keys()) {
1232
+ if (!oldSchema.nodeSchema.has(identifier)) {
1233
+ addedNodeSchemaCount++;
1234
+ }
1235
+ }
1236
+ let removedNodeSchemaCount = 0;
1237
+ for (const identifier of oldSchema.nodeSchema.keys()) {
1238
+ if (!newSchema.nodeSchema.has(identifier)) {
1239
+ removedNodeSchemaCount++;
1240
+ }
1241
+ }
1242
+ return {
1243
+ changeKind: isInverse
1244
+ ? "rollback"
1245
+ : oldSchema.nodeSchema.size === 0
1246
+ ? "initialize"
1247
+ : (0, index_js_3.allowsRepoSuperset)(index_js_3.defaultSchemaPolicy, oldSchema, newSchema)
1248
+ ? "upgrade"
1249
+ : "restriction",
1250
+ isInverse,
1251
+ oldNodeSchemaCount: oldSchema.nodeSchema.size,
1252
+ newNodeSchemaCount: newSchema.nodeSchema.size,
1253
+ addedNodeSchemaCount,
1254
+ removedNodeSchemaCount,
1255
+ rootFieldKindChanged: oldSchema.rootFieldSchema.kind !== newSchema.rootFieldSchema.kind,
1256
+ oldRootAllowedTypeCount: oldSchema.rootFieldSchema.types.size,
1257
+ newRootAllowedTypeCount: newSchema.rootFieldSchema.types.size,
1258
+ };
1259
+ }
1186
1260
  /**
1187
1261
  * A helper class that assists {@link TreeCheckout} in preventing functionality from being used while the tree is in the middle of being edited.
1188
1262
  */
1189
1263
  class EditLock {
1264
+ /**
1265
+ * Edits the tree by calling the methods of the editor passed into the {@link EditLock} constructor.
1266
+ * @remarks Edits will throw an error if the lock is currently locked.
1267
+ */
1268
+ editor;
1269
+ /**
1270
+ * The current status of the lock.
1271
+ * The `reason` string will be included in the error message if an attempt is made to edit the tree while the lock is held.
1272
+ */
1273
+ status = { isLocked: false };
1190
1274
  /**
1191
1275
  * @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.
1192
1276
  * Use {@link EditLock.editor} in place of the original editor to ensure that changes are monitored.
1193
1277
  */
1194
1278
  constructor(editor) {
1195
- /**
1196
- * The current status of the lock.
1197
- * The `reason` string will be included in the error message if an attempt is made to edit the tree while the lock is held.
1198
- */
1199
- this.status = { isLocked: false };
1200
1279
  const checkLock = () => this.checkUnlocked("Editing the tree");
1201
1280
  this.editor = {
1202
1281
  get schema() {
@@ -1294,19 +1373,19 @@ function verboseFromCursor(reader, schema) {
1294
1373
  };
1295
1374
  }
1296
1375
  /**
1297
- * Enumerates through a shared tree change, looking for schema change and field changes that result in visible changes to the tree (e.g. an insert, move, delete).
1298
- * This function also considers changes to detached roots to be visible changes, but not renames of roots or builds of new roots.
1376
+ * Whether the change contains any application-facing changes.
1299
1377
  *
1300
1378
  * @param change - The change to analyze.
1301
- * @returns True if the change contains any schema changes or any field changes that result in visible changes to the tree, false otherwise.
1379
+ * @returns True if the change contains any schema changes or any field changes (either in the document tree or in detached trees), false otherwise.
1302
1380
  */
1303
- function sharedTreeChangeHasVisibleChanges(change) {
1381
+ function sharedTreeChangeHasApplicationFacingChanges(change) {
1304
1382
  for (const inner of change.changes) {
1305
1383
  if (inner.type === "schema") {
1306
1384
  return true;
1307
1385
  }
1308
1386
  const delta = (0, index_js_3.intoDelta)((0, index_js_2.tagChange)(inner.innerChange, undefined));
1309
- if ((0, index_js_2.deltaFieldMapHasVisibleChanges)(delta.fields)) {
1387
+ const profile = (0, index_js_2.getDeltaChangeProfile)(delta);
1388
+ if (profile.hasChangesInDocumentTree || profile.hasChangesInDetachedTrees) {
1310
1389
  return true;
1311
1390
  }
1312
1391
  }