@fluidframework/tree 2.117.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1275) hide show
  1. package/CHANGELOG.md +385 -7
  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 +174 -146
  5. package/api-report/tree.beta.api.md +160 -91
  6. package/api-report/tree.legacy.beta.api.md +160 -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/index.d.ts +1 -1
  201. package/dist/feature-libraries/index.js.map +1 -1
  202. package/dist/feature-libraries/indexing/anchorTreeIndex.js +35 -31
  203. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  204. package/dist/feature-libraries/mapTreeCursor.js +6 -7
  205. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  206. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -3
  207. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  208. package/dist/feature-libraries/modular-schema/comparison.js +6 -7
  209. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  210. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +4 -4
  211. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  212. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -12
  213. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  214. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +63 -10
  215. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  216. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +3 -3
  217. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  218. package/dist/feature-libraries/modular-schema/fieldKind.js +10 -0
  219. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  220. package/dist/feature-libraries/modular-schema/filterEdits.d.ts +13 -0
  221. package/dist/feature-libraries/modular-schema/filterEdits.d.ts.map +1 -0
  222. package/dist/feature-libraries/modular-schema/filterEdits.js +51 -0
  223. package/dist/feature-libraries/modular-schema/filterEdits.js.map +1 -0
  224. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  225. package/dist/feature-libraries/modular-schema/genericFieldKind.js +7 -4
  226. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  227. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -2
  228. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  229. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -2
  230. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  231. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js +1 -2
  232. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  233. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  234. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  235. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  236. package/dist/feature-libraries/modular-schema/invert.d.ts +1 -1
  237. package/dist/feature-libraries/modular-schema/invert.d.ts.map +1 -1
  238. package/dist/feature-libraries/modular-schema/invert.js +5 -30
  239. package/dist/feature-libraries/modular-schema/invert.js.map +1 -1
  240. package/dist/feature-libraries/modular-schema/isNeverTree.js +4 -5
  241. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  242. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts +5 -7
  243. package/dist/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  244. package/dist/feature-libraries/modular-schema/minimizeModularChange.js +459 -10
  245. package/dist/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  246. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +14 -15
  247. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  248. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -2
  249. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  250. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  251. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  252. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -10
  253. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  254. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +30 -97
  255. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  256. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +9 -9
  257. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  258. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +4 -4
  259. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +1 -2
  260. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  261. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts +13 -1
  262. package/dist/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  263. package/dist/feature-libraries/modular-schema/modularChangeUtils.js +115 -12
  264. package/dist/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  265. package/dist/feature-libraries/modular-schema/prune.d.ts +2 -3
  266. package/dist/feature-libraries/modular-schema/prune.d.ts.map +1 -1
  267. package/dist/feature-libraries/modular-schema/prune.js +25 -8
  268. package/dist/feature-libraries/modular-schema/prune.js.map +1 -1
  269. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -3
  270. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  271. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +2 -2
  272. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -1
  273. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +3 -3
  274. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  275. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  276. package/dist/feature-libraries/object-forest/objectForest.js +274 -267
  277. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  278. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  279. package/dist/feature-libraries/optional-field/optionalField.js +27 -35
  280. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  281. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +7 -7
  282. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  283. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +8 -8
  284. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  285. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +1 -2
  286. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  287. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  288. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +1 -2
  289. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  290. package/dist/feature-libraries/schema-index/schemaSummarizer.js +3 -0
  291. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  292. package/dist/feature-libraries/schemaChecker.d.ts +9 -19
  293. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  294. package/dist/feature-libraries/schemaChecker.js +135 -51
  295. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  296. package/dist/feature-libraries/sequence-field/compose.js +8 -2
  297. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  298. package/dist/feature-libraries/sequence-field/filterEdits.d.ts +3 -3
  299. package/dist/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -1
  300. package/dist/feature-libraries/sequence-field/filterEdits.js +29 -11
  301. package/dist/feature-libraries/sequence-field/filterEdits.js.map +1 -1
  302. package/dist/feature-libraries/sequence-field/formatV1.d.ts +102 -102
  303. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  304. package/dist/feature-libraries/sequence-field/formatV2.d.ts +79 -79
  305. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  306. package/dist/feature-libraries/sequence-field/formatV3.d.ts +56 -56
  307. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  308. package/dist/feature-libraries/sequence-field/invert.js +1 -2
  309. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  310. package/dist/feature-libraries/sequence-field/markListFactory.js +3 -4
  311. package/dist/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  312. package/dist/feature-libraries/sequence-field/markQueue.js +4 -2
  313. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  314. package/dist/feature-libraries/sequence-field/moveEffectTable.js +9 -9
  315. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  316. package/dist/feature-libraries/sequence-field/prune.js +1 -2
  317. package/dist/feature-libraries/sequence-field/prune.js.map +1 -1
  318. package/dist/feature-libraries/sequence-field/rebase.js +7 -2
  319. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  320. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +1 -2
  321. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +1 -1
  322. package/dist/feature-libraries/sequence-field/replaceRevisions.js +1 -2
  323. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  324. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -3
  325. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  326. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -2
  327. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  328. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  329. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -9
  330. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  331. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +1 -2
  332. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  333. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
  334. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  335. package/dist/feature-libraries/sequence-field/utils.js +54 -67
  336. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  337. package/dist/feature-libraries/treeCursorUtils.js +19 -15
  338. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  339. package/dist/feature-libraries/treeTextCursor.js +8 -8
  340. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  341. package/dist/feature-libraries/valueUtilities.js +4 -5
  342. package/dist/feature-libraries/valueUtilities.js.map +1 -1
  343. package/dist/index.d.ts +4 -29
  344. package/dist/index.d.ts.map +1 -1
  345. package/dist/index.js +6 -9
  346. package/dist/index.js.map +1 -1
  347. package/dist/internalTypes.d.ts +1 -1
  348. package/dist/internalTypes.d.ts.map +1 -1
  349. package/dist/internalTypes.js.map +1 -1
  350. package/dist/packageVersion.d.ts +1 -1
  351. package/dist/packageVersion.d.ts.map +1 -1
  352. package/dist/packageVersion.js +1 -1
  353. package/dist/packageVersion.js.map +1 -1
  354. package/dist/serializableDomainSchema.d.ts +1 -1
  355. package/dist/shared-tree/history.d.ts.map +1 -1
  356. package/dist/shared-tree/history.js +32 -13
  357. package/dist/shared-tree/history.js.map +1 -1
  358. package/dist/shared-tree/independentView.d.ts +27 -3
  359. package/dist/shared-tree/independentView.d.ts.map +1 -1
  360. package/dist/shared-tree/independentView.js +36 -7
  361. package/dist/shared-tree/independentView.js.map +1 -1
  362. package/dist/shared-tree/index.d.ts +2 -1
  363. package/dist/shared-tree/index.d.ts.map +1 -1
  364. package/dist/shared-tree/index.js +6 -2
  365. package/dist/shared-tree/index.js.map +1 -1
  366. package/dist/shared-tree/isAuditableFromOutcome.js +1 -2
  367. package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -1
  368. package/dist/shared-tree/schematizeTree.js +3 -4
  369. package/dist/shared-tree/schematizeTree.js.map +1 -1
  370. package/dist/shared-tree/schematizingTreeView.d.ts +14 -4
  371. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  372. package/dist/shared-tree/schematizingTreeView.js +107 -37
  373. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  374. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  375. package/dist/shared-tree/sharedTree.js +28 -19
  376. package/dist/shared-tree/sharedTree.js.map +1 -1
  377. package/dist/shared-tree/sharedTreeChangeCodecs.js +3 -3
  378. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  379. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  380. package/dist/shared-tree/sharedTreeChangeEnricher.js +12 -4
  381. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  382. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  383. package/dist/shared-tree/sharedTreeChangeFamily.js +11 -8
  384. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  385. package/dist/shared-tree/sharedTreeChangeFormat.js +2 -3
  386. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  387. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -0
  388. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  389. package/dist/shared-tree/transactionMinimize.d.ts.map +1 -1
  390. package/dist/shared-tree/transactionMinimize.js +2 -1
  391. package/dist/shared-tree/transactionMinimize.js.map +1 -1
  392. package/dist/shared-tree/transactionPostProcessor.js +2 -3
  393. package/dist/shared-tree/transactionPostProcessor.js.map +1 -1
  394. package/dist/shared-tree/tree.js +2 -2
  395. package/dist/shared-tree/tree.js.map +1 -1
  396. package/dist/shared-tree/treeAlpha.d.ts +5 -16
  397. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  398. package/dist/shared-tree/treeAlpha.js +18 -11
  399. package/dist/shared-tree/treeAlpha.js.map +1 -1
  400. package/{lib/simple-tree/api → dist/shared-tree}/treeBeta.d.ts +8 -65
  401. package/dist/shared-tree/treeBeta.d.ts.map +1 -0
  402. package/dist/shared-tree/treeBeta.js +70 -0
  403. package/dist/shared-tree/treeBeta.js.map +1 -0
  404. package/dist/shared-tree/treeCheckout.d.ts +5 -0
  405. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  406. package/dist/shared-tree/treeCheckout.js +986 -907
  407. package/dist/shared-tree/treeCheckout.js.map +1 -1
  408. package/dist/shared-tree/unhydratedTreeContext.js +3 -4
  409. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  410. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  411. package/dist/shared-tree-core/branch.js +24 -20
  412. package/dist/shared-tree-core/branch.js.map +1 -1
  413. package/dist/shared-tree-core/branchCommitCounter.js +35 -32
  414. package/dist/shared-tree-core/branchCommitCounter.js.map +1 -1
  415. package/dist/shared-tree-core/branchCommitEnricher.js +9 -8
  416. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  417. package/dist/shared-tree-core/branchIdCodec.js +2 -3
  418. package/dist/shared-tree-core/branchIdCodec.js.map +1 -1
  419. package/dist/shared-tree-core/customMetadataCodec.js +2 -3
  420. package/dist/shared-tree-core/customMetadataCodec.js.map +1 -1
  421. package/dist/shared-tree-core/customMetadataFormat.d.ts.map +1 -1
  422. package/dist/shared-tree-core/defaultResubmitMachine.js +11 -9
  423. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  424. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  425. package/dist/shared-tree-core/editManager.js +73 -44
  426. package/dist/shared-tree-core/editManager.js.map +1 -1
  427. package/dist/shared-tree-core/editManagerCodecs.js +3 -3
  428. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  429. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  430. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  431. package/dist/shared-tree-core/editManagerCodecsCommons.js +33 -36
  432. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  433. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -2
  434. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  435. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -2
  436. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  437. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +11 -11
  438. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  439. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +5 -4
  440. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  441. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +10 -9
  442. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  443. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  444. package/dist/shared-tree-core/editManagerSummarizer.js +6 -1
  445. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  446. package/dist/shared-tree-core/messageCodecV1ToV4.js +1 -2
  447. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  448. package/dist/shared-tree-core/messageCodecVSharedBranches.js +1 -2
  449. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  450. package/dist/shared-tree-core/messageCodecs.js +3 -3
  451. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  452. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
  453. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  454. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +3 -2
  455. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  456. package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  457. package/dist/shared-tree-core/sharedTreeCore.js +44 -22
  458. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  459. package/dist/shared-tree-core/summaryTypes.js +2 -2
  460. package/dist/shared-tree-core/summaryTypes.js.map +1 -1
  461. package/dist/shared-tree-core/transaction.js +36 -39
  462. package/dist/shared-tree-core/transaction.js.map +1 -1
  463. package/dist/shared-tree-core/versionedSummarizer.js +4 -0
  464. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  465. package/dist/simple-tree/api/cloneTree.d.ts +11 -0
  466. package/dist/simple-tree/api/cloneTree.d.ts.map +1 -0
  467. package/dist/simple-tree/api/cloneTree.js +31 -0
  468. package/dist/simple-tree/api/cloneTree.js.map +1 -0
  469. package/dist/simple-tree/api/conciseTree.js +2 -3
  470. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  471. package/dist/simple-tree/api/configuration.d.ts +4 -4
  472. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  473. package/dist/simple-tree/api/configuration.js +21 -2
  474. package/dist/simple-tree/api/configuration.js.map +1 -1
  475. package/dist/simple-tree/api/create.js +2 -3
  476. package/dist/simple-tree/api/create.js.map +1 -1
  477. package/dist/simple-tree/api/customTree.js +6 -6
  478. package/dist/simple-tree/api/customTree.js.map +1 -1
  479. package/dist/simple-tree/api/dirtyIndex.js +1 -2
  480. package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
  481. package/dist/simple-tree/api/discrepancies.d.ts +36 -3
  482. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  483. package/dist/simple-tree/api/discrepancies.js +42 -17
  484. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  485. package/dist/simple-tree/api/eraseSchemaDetails.js +2 -3
  486. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  487. package/dist/simple-tree/api/getJsonSchema.js +1 -2
  488. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  489. package/dist/simple-tree/api/getSimpleSchema.js +1 -2
  490. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  491. package/dist/simple-tree/api/identifierIndex.js +1 -2
  492. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  493. package/dist/simple-tree/api/incrementalAllowedTypes.js +2 -2
  494. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  495. package/dist/simple-tree/api/index.d.ts +5 -4
  496. package/dist/simple-tree/api/index.d.ts.map +1 -1
  497. package/dist/simple-tree/api/index.js +5 -7
  498. package/dist/simple-tree/api/index.js.map +1 -1
  499. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
  500. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  501. package/dist/simple-tree/api/schemaCompatibilityTester.js +140 -11
  502. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  503. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -7
  504. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  505. package/dist/simple-tree/api/schemaCreationUtilities.js +6 -9
  506. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  507. package/dist/simple-tree/api/schemaFactory.d.ts +4 -9
  508. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  509. package/dist/simple-tree/api/schemaFactory.js +13 -12
  510. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  511. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +20 -22
  512. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  513. package/dist/simple-tree/api/schemaFactoryAlpha.js +78 -81
  514. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  515. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +7 -9
  516. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  517. package/dist/simple-tree/api/schemaFactoryBeta.js +32 -35
  518. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  519. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -2
  520. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  521. package/dist/simple-tree/api/schemaFromSimple.js +1 -2
  522. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  523. package/dist/simple-tree/api/schemaStatics.d.ts +7 -7
  524. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  525. package/dist/simple-tree/api/simpleSchemaCodec.js +2 -3
  526. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  527. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +2 -3
  528. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  529. package/dist/simple-tree/api/simpleTreeIndex.js +1 -2
  530. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  531. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +46 -2
  532. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  533. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +54 -12
  534. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  535. package/dist/simple-tree/api/storedSchema.js +2 -3
  536. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  537. package/dist/simple-tree/api/transactionTypes.d.ts +4 -4
  538. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  539. package/dist/simple-tree/api/tree.d.ts +243 -58
  540. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  541. package/dist/simple-tree/api/tree.js +3 -5
  542. package/dist/simple-tree/api/tree.js.map +1 -1
  543. package/dist/simple-tree/api/treeChangeEvents.d.ts +16 -4
  544. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  545. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  546. package/dist/simple-tree/api/treeChangeEventsBeta.d.ts +209 -0
  547. package/dist/simple-tree/api/treeChangeEventsBeta.d.ts.map +1 -0
  548. package/dist/simple-tree/api/{treeAlpha.js → treeChangeEventsBeta.js} +1 -1
  549. package/dist/simple-tree/api/treeChangeEventsBeta.js.map +1 -0
  550. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -75
  551. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  552. package/dist/simple-tree/api/treeNodeApi.js +7 -7
  553. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  554. package/dist/simple-tree/api/typesUnsafe.d.ts +8 -6
  555. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  556. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  557. package/dist/simple-tree/api/verboseTree.js +5 -6
  558. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  559. package/dist/simple-tree/core/allowedTypes.js +22 -13
  560. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  561. package/dist/simple-tree/core/context.js +3 -0
  562. package/dist/simple-tree/core/context.js.map +1 -1
  563. package/dist/simple-tree/core/flexList.js +2 -3
  564. package/dist/simple-tree/core/flexList.js.map +1 -1
  565. package/dist/simple-tree/core/getOrCreateNode.js +2 -3
  566. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  567. package/dist/simple-tree/core/index.d.ts +1 -1
  568. package/dist/simple-tree/core/index.d.ts.map +1 -1
  569. package/dist/simple-tree/core/index.js +2 -2
  570. package/dist/simple-tree/core/index.js.map +1 -1
  571. package/dist/simple-tree/core/toStored.d.ts +7 -0
  572. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  573. package/dist/simple-tree/core/toStored.js.map +1 -1
  574. package/dist/simple-tree/core/treeNode.d.ts +3 -4
  575. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  576. package/dist/simple-tree/core/treeNode.js +31 -32
  577. package/dist/simple-tree/core/treeNode.js.map +1 -1
  578. package/dist/simple-tree/core/treeNodeKernel.js +194 -192
  579. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  580. package/dist/simple-tree/core/treeNodeSchema.js +3 -3
  581. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  582. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  583. package/dist/simple-tree/core/treeNodeValid.js +25 -25
  584. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  585. package/dist/simple-tree/core/types.js +1 -2
  586. package/dist/simple-tree/core/types.js.map +1 -1
  587. package/dist/simple-tree/core/unhydratedFlexTree.js +177 -150
  588. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  589. package/dist/simple-tree/core/walkSchema.js +2 -3
  590. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  591. package/dist/simple-tree/core/withType.d.ts +7 -9
  592. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  593. package/dist/simple-tree/core/withType.js +6 -7
  594. package/dist/simple-tree/core/withType.js.map +1 -1
  595. package/dist/simple-tree/createContext.js +2 -3
  596. package/dist/simple-tree/createContext.js.map +1 -1
  597. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  598. package/dist/simple-tree/fieldSchema.js +33 -15
  599. package/dist/simple-tree/fieldSchema.js.map +1 -1
  600. package/dist/simple-tree/getTreeNodeForField.js +1 -2
  601. package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
  602. package/dist/simple-tree/index.d.ts +2 -2
  603. package/dist/simple-tree/index.d.ts.map +1 -1
  604. package/dist/simple-tree/index.js +6 -8
  605. package/dist/simple-tree/index.js.map +1 -1
  606. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  607. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  608. package/dist/simple-tree/leafNodeSchema.js +18 -17
  609. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  610. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -2
  611. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  612. package/dist/simple-tree/node-kinds/array/arrayNode.js +31 -33
  613. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  614. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  615. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js +2 -2
  616. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  617. package/dist/simple-tree/node-kinds/common.js +1 -2
  618. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  619. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +6 -6
  620. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  621. package/dist/simple-tree/node-kinds/map/mapNode.js +10 -16
  622. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  623. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  624. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js +2 -2
  625. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  626. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  627. package/dist/simple-tree/node-kinds/object/objectNode.js +27 -28
  628. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  629. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +1 -1
  630. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  631. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js +2 -2
  632. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  633. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  634. package/dist/simple-tree/node-kinds/record/recordNode.js +10 -13
  635. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  636. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -2
  637. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  638. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js +2 -2
  639. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  640. package/dist/simple-tree/prepareForInsertion.js +4 -5
  641. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  642. package/dist/simple-tree/toStoredSchema.js +11 -11
  643. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  644. package/dist/simple-tree/treeSchema.js +1 -2
  645. package/dist/simple-tree/treeSchema.js.map +1 -1
  646. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +3 -4
  647. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  648. package/dist/simple-tree/walkFieldSchema.js +1 -2
  649. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  650. package/dist/tableSchema.d.ts +2 -87
  651. package/dist/tableSchema.d.ts.map +1 -1
  652. package/dist/tableSchema.js +309 -275
  653. package/dist/tableSchema.js.map +1 -1
  654. package/dist/text/codePointUtils.d.ts +16 -3
  655. package/dist/text/codePointUtils.d.ts.map +1 -1
  656. package/dist/text/codePointUtils.js +24 -13
  657. package/dist/text/codePointUtils.js.map +1 -1
  658. package/dist/text/textDomain.d.ts +7 -1
  659. package/dist/text/textDomain.d.ts.map +1 -1
  660. package/dist/text/textDomain.js +32 -28
  661. package/dist/text/textDomain.js.map +1 -1
  662. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  663. package/dist/text/textDomainFormatted.js +45 -34
  664. package/dist/text/textDomainFormatted.js.map +1 -1
  665. package/dist/text/textDomainFormattedDefault.js +2 -5
  666. package/dist/text/textDomainFormattedDefault.js.map +1 -1
  667. package/dist/treeDataStore.js +2 -3
  668. package/dist/treeDataStore.js.map +1 -1
  669. package/dist/treeFactory.js +7 -7
  670. package/dist/treeFactory.js.map +1 -1
  671. package/dist/util/arrayUtilities.js +5 -6
  672. package/dist/util/arrayUtilities.js.map +1 -1
  673. package/dist/util/bTreeUtils.js +3 -4
  674. package/dist/util/bTreeUtils.js.map +1 -1
  675. package/dist/util/brand.js +6 -5
  676. package/dist/util/brand.js.map +1 -1
  677. package/dist/util/brandedMap.js +2 -3
  678. package/dist/util/brandedMap.js.map +1 -1
  679. package/dist/util/breakable.d.ts.map +1 -1
  680. package/dist/util/breakable.js +7 -4
  681. package/dist/util/breakable.js.map +1 -1
  682. package/dist/util/cloneWithReplacements.js +1 -2
  683. package/dist/util/cloneWithReplacements.js.map +1 -1
  684. package/dist/util/compressedIds.js +29 -7
  685. package/dist/util/compressedIds.js.map +1 -1
  686. package/dist/util/idAllocator.js +3 -3
  687. package/dist/util/idAllocator.js.map +1 -1
  688. package/dist/util/nestedMap.js +15 -17
  689. package/dist/util/nestedMap.js.map +1 -1
  690. package/dist/util/nestedSet.js +2 -3
  691. package/dist/util/nestedSet.js.map +1 -1
  692. package/dist/util/offsetList.js +2 -4
  693. package/dist/util/offsetList.js.map +1 -1
  694. package/dist/util/opaque.js +2 -3
  695. package/dist/util/opaque.js.map +1 -1
  696. package/dist/util/rangeMap.js +6 -2
  697. package/dist/util/rangeMap.js.map +1 -1
  698. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  699. package/dist/util/referenceCounting.js +1 -0
  700. package/dist/util/referenceCounting.js.map +1 -1
  701. package/dist/util/stackyIterator.js +3 -2
  702. package/dist/util/stackyIterator.js.map +1 -1
  703. package/dist/util/typeUtils.js +1 -2
  704. package/dist/util/typeUtils.js.map +1 -1
  705. package/dist/util/typeboxBrand.js +2 -3
  706. package/dist/util/typeboxBrand.js.map +1 -1
  707. package/dist/util/utils.d.ts +2 -2
  708. package/dist/util/utils.d.ts.map +1 -1
  709. package/dist/util/utils.js +32 -32
  710. package/dist/util/utils.js.map +1 -1
  711. package/lib/api.d.ts +9 -1
  712. package/lib/api.d.ts.map +1 -1
  713. package/lib/api.js.map +1 -1
  714. package/lib/codec/codec.d.ts +2 -2
  715. package/lib/codec/codec.d.ts.map +1 -1
  716. package/lib/codec/codec.js +2 -0
  717. package/lib/codec/codec.js.map +1 -1
  718. package/lib/codec/discriminatedUnions.js +1 -0
  719. package/lib/codec/discriminatedUnions.js.map +1 -1
  720. package/lib/codec/versioned/codec.d.ts.map +1 -1
  721. package/lib/codec/versioned/codec.js +2 -0
  722. package/lib/codec/versioned/codec.js.map +1 -1
  723. package/lib/componentApi.d.ts.map +1 -1
  724. package/lib/componentApi.js +20 -17
  725. package/lib/componentApi.js.map +1 -1
  726. package/lib/core/change-family/editBuilder.js +1 -0
  727. package/lib/core/change-family/editBuilder.js.map +1 -1
  728. package/lib/core/index.d.ts +2 -2
  729. package/lib/core/index.d.ts.map +1 -1
  730. package/lib/core/index.js +2 -2
  731. package/lib/core/index.js.map +1 -1
  732. package/lib/core/rebase/index.d.ts +1 -1
  733. package/lib/core/rebase/index.d.ts.map +1 -1
  734. package/lib/core/rebase/index.js +1 -1
  735. package/lib/core/rebase/index.js.map +1 -1
  736. package/lib/core/rebase/revisionTagCodec.js +3 -1
  737. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  738. package/lib/core/rebase/types.d.ts +12 -1
  739. package/lib/core/rebase/types.d.ts.map +1 -1
  740. package/lib/core/rebase/types.js +3 -0
  741. package/lib/core/rebase/types.js.map +1 -1
  742. package/lib/core/schema-stored/schema.js +5 -0
  743. package/lib/core/schema-stored/schema.js.map +1 -1
  744. package/lib/core/schema-stored/storedSchemaRepository.js +4 -2
  745. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  746. package/lib/core/tree/anchorSet.js +61 -54
  747. package/lib/core/tree/anchorSet.js.map +1 -1
  748. package/lib/core/tree/deltaUtil.d.ts +34 -9
  749. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  750. package/lib/core/tree/deltaUtil.js +41 -10
  751. package/lib/core/tree/deltaUtil.js.map +1 -1
  752. package/lib/core/tree/detachedFieldIndex.js +23 -21
  753. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  754. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +10 -10
  755. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  756. package/lib/core/tree/detachedFieldIndexCodecV1.js +2 -0
  757. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  758. package/lib/core/tree/detachedFieldIndexCodecV2.js +2 -0
  759. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  760. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +3 -3
  761. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  762. package/lib/core/tree/index.d.ts +1 -1
  763. package/lib/core/tree/index.d.ts.map +1 -1
  764. package/lib/core/tree/index.js +1 -1
  765. package/lib/core/tree/index.js.map +1 -1
  766. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  767. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  768. package/lib/core/tree/sparseTree.js +15 -11
  769. package/lib/core/tree/sparseTree.js.map +1 -1
  770. package/lib/entrypoints/alpha.d.ts +1 -1
  771. package/lib/entrypoints/alpha.d.ts.map +1 -1
  772. package/lib/entrypoints/alpha.js +1 -1
  773. package/lib/entrypoints/alpha.js.map +1 -1
  774. package/lib/entrypoints/beta.d.ts +1 -1
  775. package/lib/entrypoints/beta.d.ts.map +1 -1
  776. package/lib/entrypoints/beta.js +1 -1
  777. package/lib/entrypoints/beta.js.map +1 -1
  778. package/lib/entrypoints/legacy.d.ts +1 -1
  779. package/lib/entrypoints/legacy.d.ts.map +1 -1
  780. package/lib/entrypoints/legacy.js +1 -1
  781. package/lib/entrypoints/legacy.js.map +1 -1
  782. package/lib/entrypoints/public.d.ts +1 -1
  783. package/lib/entrypoints/public.d.ts.map +1 -1
  784. package/lib/entrypoints/public.js +1 -1
  785. package/lib/entrypoints/public.js.map +1 -1
  786. package/lib/extensibleUnionNode.d.ts.map +1 -1
  787. package/lib/extensibleUnionNode.js +2 -2
  788. package/lib/extensibleUnionNode.js.map +1 -1
  789. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  790. package/lib/feature-libraries/chunked-forest/basicChunk.js +14 -1
  791. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  792. package/lib/feature-libraries/chunked-forest/chunkTree.js +14 -6
  793. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  794. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  795. package/lib/feature-libraries/chunked-forest/chunkedForest.js +18 -12
  796. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  797. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +1 -3
  798. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  799. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +8 -0
  800. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  801. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -0
  802. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  803. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -0
  804. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  805. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  806. package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -0
  807. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  808. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +28 -12
  809. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  810. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +2 -2
  811. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  812. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +9 -0
  813. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  814. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -0
  815. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  816. package/lib/feature-libraries/chunked-forest/uniformChunk.js +71 -13
  817. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  818. package/lib/feature-libraries/comparison-forest/comparisonForest.js +79 -79
  819. package/lib/feature-libraries/comparison-forest/comparisonForest.js.map +1 -1
  820. package/lib/feature-libraries/cursorComparator.d.ts +8 -0
  821. package/lib/feature-libraries/cursorComparator.d.ts.map +1 -1
  822. package/lib/feature-libraries/cursorComparator.js +43 -9
  823. package/lib/feature-libraries/cursorComparator.js.map +1 -1
  824. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  825. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  826. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +2 -0
  827. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  828. package/lib/feature-libraries/detachedFieldIndexSummarizer.js +2 -0
  829. package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
  830. package/lib/feature-libraries/flex-tree/context.js +19 -3
  831. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  832. package/lib/feature-libraries/flex-tree/lazyEntity.js +12 -12
  833. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  834. package/lib/feature-libraries/flex-tree/lazyField.js +25 -27
  835. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  836. package/lib/feature-libraries/flex-tree/lazyNode.js +22 -21
  837. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  838. package/lib/feature-libraries/forest-summary/forestSummarizer.js +122 -117
  839. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  840. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +49 -32
  841. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  842. package/lib/feature-libraries/index.d.ts +1 -1
  843. package/lib/feature-libraries/index.js.map +1 -1
  844. package/lib/feature-libraries/indexing/anchorTreeIndex.js +33 -29
  845. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  846. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -12
  847. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  848. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +63 -10
  849. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  850. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  851. package/lib/feature-libraries/modular-schema/fieldKind.js +10 -0
  852. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  853. package/lib/feature-libraries/modular-schema/filterEdits.d.ts +13 -0
  854. package/lib/feature-libraries/modular-schema/filterEdits.d.ts.map +1 -0
  855. package/lib/feature-libraries/modular-schema/filterEdits.js +46 -0
  856. package/lib/feature-libraries/modular-schema/filterEdits.js.map +1 -0
  857. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  858. package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -2
  859. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  860. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +2 -2
  861. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  862. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  863. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  864. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  865. package/lib/feature-libraries/modular-schema/invert.d.ts +1 -1
  866. package/lib/feature-libraries/modular-schema/invert.d.ts.map +1 -1
  867. package/lib/feature-libraries/modular-schema/invert.js +6 -30
  868. package/lib/feature-libraries/modular-schema/invert.js.map +1 -1
  869. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts +5 -7
  870. package/lib/feature-libraries/modular-schema/minimizeModularChange.d.ts.map +1 -1
  871. package/lib/feature-libraries/modular-schema/minimizeModularChange.js +458 -8
  872. package/lib/feature-libraries/modular-schema/minimizeModularChange.js.map +1 -1
  873. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -10
  874. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  875. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +20 -85
  876. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  877. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts +13 -1
  878. package/lib/feature-libraries/modular-schema/modularChangeUtils.d.ts.map +1 -1
  879. package/lib/feature-libraries/modular-schema/modularChangeUtils.js +100 -3
  880. package/lib/feature-libraries/modular-schema/modularChangeUtils.js.map +1 -1
  881. package/lib/feature-libraries/modular-schema/prune.d.ts +2 -3
  882. package/lib/feature-libraries/modular-schema/prune.d.ts.map +1 -1
  883. package/lib/feature-libraries/modular-schema/prune.js +25 -7
  884. package/lib/feature-libraries/modular-schema/prune.js.map +1 -1
  885. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -3
  886. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  887. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +1 -0
  888. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  889. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  890. package/lib/feature-libraries/object-forest/objectForest.js +273 -266
  891. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  892. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  893. package/lib/feature-libraries/optional-field/optionalField.js +24 -32
  894. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  895. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +1 -1
  896. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  897. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +1 -1
  898. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  899. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  900. package/lib/feature-libraries/schema-index/schemaSummarizer.js +3 -0
  901. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  902. package/lib/feature-libraries/schemaChecker.d.ts +9 -19
  903. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  904. package/lib/feature-libraries/schemaChecker.js +133 -49
  905. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  906. package/lib/feature-libraries/sequence-field/compose.js +6 -0
  907. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  908. package/lib/feature-libraries/sequence-field/filterEdits.d.ts +3 -3
  909. package/lib/feature-libraries/sequence-field/filterEdits.d.ts.map +1 -1
  910. package/lib/feature-libraries/sequence-field/filterEdits.js +31 -12
  911. package/lib/feature-libraries/sequence-field/filterEdits.js.map +1 -1
  912. package/lib/feature-libraries/sequence-field/formatV1.d.ts +3 -3
  913. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  914. package/lib/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  915. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  916. package/lib/feature-libraries/sequence-field/formatV3.d.ts +2 -2
  917. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  918. package/lib/feature-libraries/sequence-field/markListFactory.js +3 -4
  919. package/lib/feature-libraries/sequence-field/markListFactory.js.map +1 -1
  920. package/lib/feature-libraries/sequence-field/markQueue.js +4 -2
  921. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  922. package/lib/feature-libraries/sequence-field/rebase.js +6 -0
  923. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  924. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  925. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +9 -9
  926. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  927. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
  928. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  929. package/lib/feature-libraries/sequence-field/utils.js +3 -15
  930. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  931. package/lib/feature-libraries/treeCursorUtils.js +13 -9
  932. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  933. package/lib/index.d.ts +4 -29
  934. package/lib/index.d.ts.map +1 -1
  935. package/lib/index.js +2 -17
  936. package/lib/index.js.map +1 -1
  937. package/lib/internalTypes.d.ts +1 -1
  938. package/lib/internalTypes.d.ts.map +1 -1
  939. package/lib/internalTypes.js.map +1 -1
  940. package/lib/packageVersion.d.ts +1 -1
  941. package/lib/packageVersion.d.ts.map +1 -1
  942. package/lib/packageVersion.js +1 -1
  943. package/lib/packageVersion.js.map +1 -1
  944. package/lib/serializableDomainSchema.d.ts +1 -1
  945. package/lib/shared-tree/history.d.ts.map +1 -1
  946. package/lib/shared-tree/history.js +32 -13
  947. package/lib/shared-tree/history.js.map +1 -1
  948. package/lib/shared-tree/independentView.d.ts +27 -3
  949. package/lib/shared-tree/independentView.d.ts.map +1 -1
  950. package/lib/shared-tree/independentView.js +30 -2
  951. package/lib/shared-tree/independentView.js.map +1 -1
  952. package/lib/shared-tree/index.d.ts +2 -1
  953. package/lib/shared-tree/index.d.ts.map +1 -1
  954. package/lib/shared-tree/index.js +2 -1
  955. package/lib/shared-tree/index.js.map +1 -1
  956. package/lib/shared-tree/schematizingTreeView.d.ts +14 -4
  957. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  958. package/lib/shared-tree/schematizingTreeView.js +109 -39
  959. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  960. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  961. package/lib/shared-tree/sharedTree.js +24 -15
  962. package/lib/shared-tree/sharedTree.js.map +1 -1
  963. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  964. package/lib/shared-tree/sharedTreeChangeEnricher.js +12 -4
  965. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  966. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  967. package/lib/shared-tree/sharedTreeChangeFamily.js +6 -3
  968. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  969. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -0
  970. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  971. package/lib/shared-tree/transactionMinimize.d.ts.map +1 -1
  972. package/lib/shared-tree/transactionMinimize.js +4 -3
  973. package/lib/shared-tree/transactionMinimize.js.map +1 -1
  974. package/lib/shared-tree/treeAlpha.d.ts +5 -16
  975. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  976. package/lib/shared-tree/treeAlpha.js +13 -6
  977. package/lib/shared-tree/treeAlpha.js.map +1 -1
  978. package/{dist/simple-tree/api → lib/shared-tree}/treeBeta.d.ts +8 -65
  979. package/lib/shared-tree/treeBeta.d.ts.map +1 -0
  980. package/lib/shared-tree/treeBeta.js +64 -0
  981. package/lib/shared-tree/treeBeta.js.map +1 -0
  982. package/lib/shared-tree/treeCheckout.d.ts +5 -0
  983. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  984. package/lib/shared-tree/treeCheckout.js +985 -906
  985. package/lib/shared-tree/treeCheckout.js.map +1 -1
  986. package/lib/shared-tree/unhydratedTreeContext.js +3 -4
  987. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  988. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  989. package/lib/shared-tree-core/branch.js +22 -18
  990. package/lib/shared-tree-core/branch.js.map +1 -1
  991. package/lib/shared-tree-core/branchCommitCounter.js +35 -32
  992. package/lib/shared-tree-core/branchCommitCounter.js.map +1 -1
  993. package/lib/shared-tree-core/branchCommitEnricher.js +9 -8
  994. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  995. package/lib/shared-tree-core/customMetadataFormat.d.ts.map +1 -1
  996. package/lib/shared-tree-core/defaultResubmitMachine.js +11 -9
  997. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  998. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  999. package/lib/shared-tree-core/editManager.js +73 -44
  1000. package/lib/shared-tree-core/editManager.js.map +1 -1
  1001. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  1002. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  1003. package/lib/shared-tree-core/editManagerCodecsCommons.js +32 -34
  1004. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  1005. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  1006. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  1007. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +4 -4
  1008. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  1009. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -1
  1010. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  1011. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +2 -1
  1012. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  1013. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  1014. package/lib/shared-tree-core/editManagerSummarizer.js +6 -1
  1015. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  1016. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -1
  1017. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  1018. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +2 -1
  1019. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  1020. package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
  1021. package/lib/shared-tree-core/sharedTreeCore.js +45 -23
  1022. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  1023. package/lib/shared-tree-core/transaction.js +36 -39
  1024. package/lib/shared-tree-core/transaction.js.map +1 -1
  1025. package/lib/shared-tree-core/versionedSummarizer.js +4 -0
  1026. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  1027. package/lib/simple-tree/api/cloneTree.d.ts +11 -0
  1028. package/lib/simple-tree/api/cloneTree.d.ts.map +1 -0
  1029. package/lib/simple-tree/api/cloneTree.js +28 -0
  1030. package/lib/simple-tree/api/cloneTree.js.map +1 -0
  1031. package/lib/simple-tree/api/configuration.d.ts +4 -4
  1032. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  1033. package/lib/simple-tree/api/configuration.js +19 -0
  1034. package/lib/simple-tree/api/configuration.js.map +1 -1
  1035. package/lib/simple-tree/api/discrepancies.d.ts +36 -3
  1036. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  1037. package/lib/simple-tree/api/discrepancies.js +40 -14
  1038. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  1039. package/lib/simple-tree/api/index.d.ts +5 -4
  1040. package/lib/simple-tree/api/index.d.ts.map +1 -1
  1041. package/lib/simple-tree/api/index.js +2 -2
  1042. package/lib/simple-tree/api/index.js.map +1 -1
  1043. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +22 -3
  1044. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  1045. package/lib/simple-tree/api/schemaCompatibilityTester.js +136 -7
  1046. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  1047. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -7
  1048. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  1049. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -3
  1050. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  1051. package/lib/simple-tree/api/schemaFactory.d.ts +4 -9
  1052. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  1053. package/lib/simple-tree/api/schemaFactory.js +9 -8
  1054. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  1055. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +18 -20
  1056. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  1057. package/lib/simple-tree/api/schemaFactoryAlpha.js +78 -81
  1058. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  1059. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +7 -9
  1060. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  1061. package/lib/simple-tree/api/schemaFactoryBeta.js +32 -35
  1062. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  1063. package/lib/simple-tree/api/schemaStatics.d.ts +7 -7
  1064. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  1065. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +46 -2
  1066. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  1067. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +48 -6
  1068. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  1069. package/lib/simple-tree/api/transactionTypes.d.ts +4 -4
  1070. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  1071. package/lib/simple-tree/api/tree.d.ts +243 -58
  1072. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  1073. package/lib/simple-tree/api/tree.js +2 -3
  1074. package/lib/simple-tree/api/tree.js.map +1 -1
  1075. package/lib/simple-tree/api/treeChangeEvents.d.ts +16 -4
  1076. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  1077. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  1078. package/lib/simple-tree/api/treeChangeEventsBeta.d.ts +209 -0
  1079. package/lib/simple-tree/api/treeChangeEventsBeta.d.ts.map +1 -0
  1080. package/lib/simple-tree/api/{treeAlpha.js → treeChangeEventsBeta.js} +1 -1
  1081. package/lib/simple-tree/api/treeChangeEventsBeta.js.map +1 -0
  1082. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -75
  1083. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  1084. package/lib/simple-tree/api/treeNodeApi.js +1 -1
  1085. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  1086. package/lib/simple-tree/api/typesUnsafe.d.ts +8 -6
  1087. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  1088. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  1089. package/lib/simple-tree/core/allowedTypes.js +12 -3
  1090. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  1091. package/lib/simple-tree/core/context.js +3 -0
  1092. package/lib/simple-tree/core/context.js.map +1 -1
  1093. package/lib/simple-tree/core/index.d.ts +1 -1
  1094. package/lib/simple-tree/core/index.d.ts.map +1 -1
  1095. package/lib/simple-tree/core/index.js +1 -1
  1096. package/lib/simple-tree/core/index.js.map +1 -1
  1097. package/lib/simple-tree/core/toStored.d.ts +7 -0
  1098. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  1099. package/lib/simple-tree/core/toStored.js.map +1 -1
  1100. package/lib/simple-tree/core/treeNode.d.ts +3 -4
  1101. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  1102. package/lib/simple-tree/core/treeNode.js +29 -30
  1103. package/lib/simple-tree/core/treeNode.js.map +1 -1
  1104. package/lib/simple-tree/core/treeNodeKernel.js +181 -179
  1105. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  1106. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  1107. package/lib/simple-tree/core/treeNodeValid.js +22 -22
  1108. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  1109. package/lib/simple-tree/core/unhydratedFlexTree.js +173 -146
  1110. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  1111. package/lib/simple-tree/core/withType.d.ts +7 -9
  1112. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  1113. package/lib/simple-tree/core/withType.js +5 -6
  1114. package/lib/simple-tree/core/withType.js.map +1 -1
  1115. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  1116. package/lib/simple-tree/fieldSchema.js +23 -5
  1117. package/lib/simple-tree/fieldSchema.js.map +1 -1
  1118. package/lib/simple-tree/index.d.ts +2 -2
  1119. package/lib/simple-tree/index.d.ts.map +1 -1
  1120. package/lib/simple-tree/index.js +2 -2
  1121. package/lib/simple-tree/index.js.map +1 -1
  1122. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  1123. package/lib/simple-tree/leafNodeSchema.js +16 -15
  1124. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  1125. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -2
  1126. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  1127. package/lib/simple-tree/node-kinds/array/arrayNode.js +28 -32
  1128. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  1129. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  1130. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +6 -6
  1131. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  1132. package/lib/simple-tree/node-kinds/map/mapNode.js +10 -17
  1133. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  1134. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  1135. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  1136. package/lib/simple-tree/node-kinds/object/objectNode.js +25 -28
  1137. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  1138. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +1 -1
  1139. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  1140. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  1141. package/lib/simple-tree/node-kinds/record/recordNode.js +10 -14
  1142. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  1143. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -2
  1144. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  1145. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  1146. package/lib/tableSchema.d.ts +2 -87
  1147. package/lib/tableSchema.d.ts.map +1 -1
  1148. package/lib/tableSchema.js +309 -275
  1149. package/lib/tableSchema.js.map +1 -1
  1150. package/lib/text/codePointUtils.d.ts +16 -3
  1151. package/lib/text/codePointUtils.d.ts.map +1 -1
  1152. package/lib/text/codePointUtils.js +22 -10
  1153. package/lib/text/codePointUtils.js.map +1 -1
  1154. package/lib/text/textDomain.d.ts +7 -1
  1155. package/lib/text/textDomain.d.ts.map +1 -1
  1156. package/lib/text/textDomain.js +21 -17
  1157. package/lib/text/textDomain.js.map +1 -1
  1158. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  1159. package/lib/text/textDomainFormatted.js +43 -32
  1160. package/lib/text/textDomainFormatted.js.map +1 -1
  1161. package/lib/text/textDomainFormattedDefault.js +2 -5
  1162. package/lib/text/textDomainFormattedDefault.js.map +1 -1
  1163. package/lib/util/brand.js +1 -0
  1164. package/lib/util/brand.js.map +1 -1
  1165. package/lib/util/breakable.d.ts.map +1 -1
  1166. package/lib/util/breakable.js +3 -0
  1167. package/lib/util/breakable.js.map +1 -1
  1168. package/lib/util/compressedIds.js +22 -0
  1169. package/lib/util/compressedIds.js.map +1 -1
  1170. package/lib/util/nestedMap.js +2 -4
  1171. package/lib/util/nestedMap.js.map +1 -1
  1172. package/lib/util/offsetList.js +2 -4
  1173. package/lib/util/offsetList.js.map +1 -1
  1174. package/lib/util/rangeMap.js +4 -0
  1175. package/lib/util/rangeMap.js.map +1 -1
  1176. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  1177. package/lib/util/referenceCounting.js +1 -0
  1178. package/lib/util/referenceCounting.js.map +1 -1
  1179. package/lib/util/stackyIterator.js +3 -2
  1180. package/lib/util/stackyIterator.js.map +1 -1
  1181. package/lib/util/utils.d.ts +2 -2
  1182. package/lib/util/utils.d.ts.map +1 -1
  1183. package/package.json +67 -95
  1184. package/src/api.ts +11 -0
  1185. package/src/core/index.ts +6 -2
  1186. package/src/core/rebase/index.ts +1 -0
  1187. package/src/core/rebase/types.ts +16 -1
  1188. package/src/core/tree/anchorSet.ts +2 -2
  1189. package/src/core/tree/deltaUtil.ts +67 -13
  1190. package/src/core/tree/index.ts +5 -2
  1191. package/src/entrypoints/alpha.ts +21 -20
  1192. package/src/entrypoints/beta.ts +14 -5
  1193. package/src/entrypoints/legacy.ts +14 -5
  1194. package/src/entrypoints/public.ts +1 -5
  1195. package/src/extensibleUnionNode.ts +1 -2
  1196. package/src/feature-libraries/cursorComparator.ts +57 -9
  1197. package/src/feature-libraries/index.ts +1 -1
  1198. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +77 -12
  1199. package/src/feature-libraries/modular-schema/filterEdits.ts +108 -0
  1200. package/src/feature-libraries/modular-schema/genericFieldKind.ts +7 -4
  1201. package/src/feature-libraries/modular-schema/index.ts +5 -2
  1202. package/src/feature-libraries/modular-schema/invert.ts +16 -61
  1203. package/src/feature-libraries/modular-schema/minimizeModularChange.ts +831 -10
  1204. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +10 -124
  1205. package/src/feature-libraries/modular-schema/modularChangeUtils.ts +164 -2
  1206. package/src/feature-libraries/modular-schema/prune.ts +52 -10
  1207. package/src/feature-libraries/optional-field/optionalField.ts +30 -42
  1208. package/src/feature-libraries/schemaChecker.ts +198 -82
  1209. package/src/feature-libraries/sequence-field/filterEdits.ts +62 -26
  1210. package/src/feature-libraries/sequence-field/utils.ts +7 -19
  1211. package/src/index.ts +10 -39
  1212. package/src/internalTypes.ts +1 -1
  1213. package/src/packageVersion.ts +1 -1
  1214. package/src/shared-tree/history.ts +41 -19
  1215. package/src/shared-tree/independentView.ts +40 -3
  1216. package/src/shared-tree/index.ts +5 -1
  1217. package/src/shared-tree/schematizingTreeView.ts +77 -23
  1218. package/src/shared-tree/sharedTree.ts +2 -1
  1219. package/src/shared-tree/transactionMinimize.ts +13 -4
  1220. package/src/shared-tree/treeAlpha.ts +17 -31
  1221. package/src/{simple-tree/api → shared-tree}/treeBeta.ts +56 -167
  1222. package/src/shared-tree/treeCheckout.ts +82 -9
  1223. package/src/shared-tree-core/editManager.ts +16 -8
  1224. package/src/shared-tree-core/editManagerCodecsCommons.ts +30 -34
  1225. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +1 -1
  1226. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -2
  1227. package/src/simple-tree/api/cloneTree.ts +47 -0
  1228. package/src/simple-tree/api/configuration.ts +4 -4
  1229. package/src/simple-tree/api/discrepancies.ts +100 -5
  1230. package/src/simple-tree/api/index.ts +22 -22
  1231. package/src/simple-tree/api/schemaCompatibilityTester.ts +185 -11
  1232. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -2
  1233. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +87 -6
  1234. package/src/simple-tree/api/transactionTypes.ts +4 -4
  1235. package/src/simple-tree/api/tree.ts +318 -87
  1236. package/src/simple-tree/api/treeChangeEvents.ts +16 -4
  1237. package/src/simple-tree/api/treeChangeEventsBeta.ts +245 -0
  1238. package/src/simple-tree/api/treeNodeApi.ts +6 -85
  1239. package/src/simple-tree/api/typesUnsafe.ts +8 -6
  1240. package/src/simple-tree/core/index.ts +1 -1
  1241. package/src/simple-tree/core/toStored.ts +8 -0
  1242. package/src/simple-tree/core/treeNode.ts +3 -10
  1243. package/src/simple-tree/core/treeNodeValid.ts +3 -1
  1244. package/src/simple-tree/core/withType.ts +8 -11
  1245. package/src/simple-tree/index.ts +7 -7
  1246. package/src/simple-tree/node-kinds/array/arrayNode.ts +14 -12
  1247. package/src/simple-tree/node-kinds/map/mapNode.ts +14 -15
  1248. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -6
  1249. package/src/simple-tree/node-kinds/record/recordNode.ts +6 -8
  1250. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -1
  1251. package/src/tableSchema.ts +8 -187
  1252. package/src/text/codePointUtils.ts +25 -14
  1253. package/src/text/textDomain.ts +15 -2
  1254. package/src/text/textDomainFormatted.ts +9 -4
  1255. package/tsconfig.json +1 -1
  1256. package/alpha.d.ts +0 -11
  1257. package/beta.d.ts +0 -11
  1258. package/dist/simple-tree/api/treeAlpha.d.ts +0 -126
  1259. package/dist/simple-tree/api/treeAlpha.d.ts.map +0 -1
  1260. package/dist/simple-tree/api/treeAlpha.js.map +0 -1
  1261. package/dist/simple-tree/api/treeBeta.d.ts.map +0 -1
  1262. package/dist/simple-tree/api/treeBeta.js +0 -83
  1263. package/dist/simple-tree/api/treeBeta.js.map +0 -1
  1264. package/docs/main/runtime-schema-upgrade.md +0 -208
  1265. package/internal.d.ts +0 -11
  1266. package/legacy.d.ts +0 -11
  1267. package/lib/simple-tree/api/treeAlpha.d.ts +0 -126
  1268. package/lib/simple-tree/api/treeAlpha.d.ts.map +0 -1
  1269. package/lib/simple-tree/api/treeAlpha.js.map +0 -1
  1270. package/lib/simple-tree/api/treeBeta.d.ts.map +0 -1
  1271. package/lib/simple-tree/api/treeBeta.js +0 -77
  1272. package/lib/simple-tree/api/treeBeta.js.map +0 -1
  1273. package/src/simple-tree/api/treeAlpha.ts +0 -153
  1274. /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
  1275. /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"invert.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/invert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EACN,8BAA8B,GAS9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAoB,MAAM,qBAAqB,CAAC;AACpF,OAAO,EACN,oBAAoB,EACpB,oBAAoB,GAEpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,qBAAqB,GAQrB,MAAM,yBAAyB,CAAC;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,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;QAC/C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,qCAAqC,CACpC,IAAI,EACJ,IAAI,CAAC,YAAY,EACjB;gBACC,QAAQ;gBACR,OAAO;aACP,EACD,UAAU,CACV,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,qCAAqC,CAC7C,KAAyB,EACzB,MAAsB,EACtB,MAA0B,EAC1B,UAA2D;IAE3D,KAAK,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,MAAM,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,iBAAiB,CACjF,WAAW,CAAC,MAAM,CAClB,CAAC;QACF,KAAK,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC;YACnC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport {\n\trevisionMetadataSourceFromInfo,\n\ttype ChangeAtomId,\n\ttype ChangesetLocalId,\n\ttype FieldKindIdentifier,\n\ttype RevisionInfo,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\ttype TreeChunk,\n} from \"../../core/index.js\";\nimport { brand, idAllocatorFromMaxId, type IdAllocator } from \"../../util/index.js\";\nimport {\n\tnewChangeAtomIdBTree,\n\tsetInChangeAtomIdMap,\n\ttype ChangeAtomIdBTree,\n} from \"../changeAtomIdBTree.js\";\nimport {\n\tnewCrossFieldKeyTable,\n\ttype CrossFieldKeyTable,\n\ttype FieldChange,\n\ttype FieldChangeMap,\n\ttype FieldId,\n\ttype ModularChangeset,\n\ttype NodeChangeset,\n\ttype NodeId,\n} from \"./modularChangeTypes.js\";\nimport {\n\tCrossFieldManagerI,\n\tgetChangeHandler,\n\tgetRevInfoFromTaggedChanges,\n\thasConflicts,\n\tmakeModularChangeset,\n\tnewConstraintState,\n\tnewCrossFieldTable,\n\tupdateConstraintsForFields,\n\ttype CrossFieldTable,\n} from \"./modularChangeUtils.js\";\nimport type { CrossFieldTarget } from \"./crossFieldQueries.js\";\nimport type { FlexFieldKind } from \"./fieldKind.js\";\nimport { NodeAttachState } from \"./fieldChangeHandler.js\";\n\n/**\n * @param change - The change to invert.\n * @param isRollback - Whether the inverted change is meant to rollback a change on a branch as is the case when\n * performing a sandwich rebase.\n * @param revisionForInvert - The revision for the invert changeset.\n */\nexport function invertModularChange(\n\tchange: TaggedChange<ModularChangeset>,\n\tisRollback: boolean,\n\trevisionForInvert: RevisionTag,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): ModularChangeset {\n\t// Rollback changesets destroy the nodes created by the change being rolled back.\n\tconst destroys = isRollback ? invertBuilds(change.change.builds) : undefined;\n\n\t// Destroys only occur in rollback changesets, which are never inverted.\n\tassert(\n\t\tchange.change.destroys === undefined,\n\t\t0x89a /* Unexpected destroys in change to invert */,\n\t);\n\n\tconst revInfos: RevisionInfo[] = isRollback\n\t\t? [{ revision: revisionForInvert, rollbackOf: change.revision }]\n\t\t: [{ revision: revisionForInvert }];\n\n\tconst noChangeConstraint = change.change.noChangeConstraintOnRevert;\n\tconst noChangeConstraintOnRevert = change.change.noChangeConstraint;\n\n\tif (hasConflicts(change.change)) {\n\t\treturn makeModularChangeset({\n\t\t\tmaxId: change.change.maxId as number,\n\t\t\trevisions: revInfos,\n\t\t\tdestroys,\n\t\t});\n\t}\n\n\tconst genId: IdAllocator = idAllocatorFromMaxId(change.change.maxId ?? -1);\n\n\tconst crossFieldTable: InvertTable = {\n\t\t...newCrossFieldTable<FieldChange>(),\n\t\toriginalFieldToContext: new Map(),\n\t\tinvertedNodeToParent: brand(change.change.nodeToParent.clone()),\n\t};\n\tconst { revInfos: oldRevInfos } = getRevInfoFromTaggedChanges([change]);\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(oldRevInfos);\n\n\tconst invertedFields = invertFieldMap(\n\t\tchange.change.fieldChanges,\n\t\tundefined,\n\t\tisRollback,\n\t\tgenId,\n\t\tcrossFieldTable,\n\t\trevisionMetadata,\n\t\trevisionForInvert,\n\t\tfieldKinds,\n\t);\n\n\tconst invertedNodes = newChangeAtomIdBTree<NodeChangeset>();\n\tchange.change.nodeChanges.forEachPair(([revision, localId], nodeChangeset) => {\n\t\tinvertedNodes.set(\n\t\t\t[revision, localId],\n\t\t\tinvertNodeChange(\n\t\t\t\tnodeChangeset,\n\t\t\t\t{ revision, localId },\n\t\t\t\tisRollback,\n\t\t\t\tgenId,\n\t\t\t\tcrossFieldTable,\n\t\t\t\trevisionMetadata,\n\t\t\t\trevisionForInvert,\n\t\t\t\tfieldKinds,\n\t\t\t),\n\t\t);\n\t});\n\n\tif (crossFieldTable.invalidatedFields.size > 0) {\n\t\tconst fieldsToUpdate = crossFieldTable.invalidatedFields;\n\t\tcrossFieldTable.invalidatedFields = new Set();\n\t\tfor (const fieldChange of fieldsToUpdate) {\n\t\t\tconst originalFieldChange = fieldChange.change;\n\t\t\tconst context = crossFieldTable.originalFieldToContext.get(fieldChange);\n\t\t\tassert(\n\t\t\t\tcontext !== undefined,\n\t\t\t\t0x851 /* Should have context for every invalidated field */,\n\t\t\t);\n\t\t\tconst { invertedField, fieldId } = context;\n\n\t\t\tconst amendedChange = getChangeHandler(fieldKinds, fieldChange.fieldKind).rebaser.invert(\n\t\t\t\toriginalFieldChange,\n\t\t\t\tisRollback,\n\t\t\t\tgenId,\n\t\t\t\trevisionForInvert,\n\t\t\t\tnew InvertManager(crossFieldTable, fieldChange, fieldId),\n\t\t\t\trevisionMetadata,\n\t\t\t);\n\t\t\tinvertedField.change = brand(amendedChange);\n\t\t}\n\t}\n\n\tconst crossFieldKeys = makeCrossFieldKeyTable(invertedFields, invertedNodes, fieldKinds);\n\n\tconst constraintState = newConstraintState(0);\n\tupdateConstraintsForFields(\n\t\tinvertedFields,\n\t\tNodeAttachState.Attached,\n\t\tconstraintState,\n\t\tinvertedNodes,\n\t\tfieldKinds,\n\t);\n\n\treturn makeModularChangeset({\n\t\tfieldChanges: invertedFields,\n\t\tnodeChanges: invertedNodes,\n\t\tnodeToParent: crossFieldTable.invertedNodeToParent,\n\t\tnodeAliases: change.change.nodeAliases,\n\t\tcrossFieldKeys,\n\t\tmaxId: genId.getMaxId(),\n\t\trevisions: revInfos,\n\t\tconstraintViolationCount: constraintState.violationCount,\n\t\tnoChangeConstraint,\n\t\tnoChangeConstraintOnRevert,\n\t\tdestroys,\n\t});\n}\n\nfunction invertFieldMap(\n\tchanges: FieldChangeMap,\n\tparentId: NodeId | undefined,\n\tisRollback: boolean,\n\tgenId: IdAllocator,\n\tcrossFieldTable: InvertTable,\n\trevisionMetadata: RevisionMetadataSource,\n\trevisionForInvert: RevisionTag,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): FieldChangeMap {\n\tconst invertedFields: FieldChangeMap = new Map();\n\n\tfor (const [field, fieldChange] of changes) {\n\t\tconst fieldId = { nodeId: parentId, field };\n\t\tconst manager = new InvertManager(crossFieldTable, fieldChange, fieldId);\n\t\tconst invertedChange = getChangeHandler(fieldKinds, fieldChange.fieldKind).rebaser.invert(\n\t\t\tfieldChange.change,\n\t\t\tisRollback,\n\t\t\tgenId,\n\t\t\trevisionForInvert,\n\t\t\tmanager,\n\t\t\trevisionMetadata,\n\t\t);\n\n\t\tconst invertedFieldChange: FieldChange = {\n\t\t\t...fieldChange,\n\t\t\tchange: brand(invertedChange),\n\t\t};\n\t\tinvertedFields.set(field, invertedFieldChange);\n\n\t\tcrossFieldTable.originalFieldToContext.set(fieldChange, {\n\t\t\tfieldId,\n\t\t\tinvertedField: invertedFieldChange,\n\t\t});\n\t}\n\n\treturn invertedFields;\n}\n\nfunction invertNodeChange(\n\tchange: NodeChangeset,\n\tid: NodeId,\n\tisRollback: boolean,\n\tgenId: IdAllocator,\n\tcrossFieldTable: InvertTable,\n\trevisionMetadata: RevisionMetadataSource,\n\trevisionForInvert: RevisionTag,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): NodeChangeset {\n\tconst inverse: NodeChangeset = {};\n\n\t// If the node has a constraint, it should be inverted to a node-exist-on-revert constraint. This ensure that if\n\t// the inverse is inverted again, the original input constraint will be restored.\n\tif (change.nodeExistsConstraint !== undefined) {\n\t\tinverse.nodeExistsConstraintOnRevert = change.nodeExistsConstraint;\n\t}\n\n\t// The node-exist-on-revert constraint of a node is the constraint that should apply when the a change is reverted.\n\t// So, it should become the constraint in the inverse. If this constraint is violated when applying the inverse,\n\t// it will be discarded.\n\tif (change.nodeExistsConstraintOnRevert !== undefined) {\n\t\tinverse.nodeExistsConstraint = change.nodeExistsConstraintOnRevert;\n\t}\n\n\tif (change.fieldChanges !== undefined) {\n\t\tinverse.fieldChanges = invertFieldMap(\n\t\t\tchange.fieldChanges,\n\t\t\tid,\n\t\t\tisRollback,\n\t\t\tgenId,\n\t\t\tcrossFieldTable,\n\t\t\trevisionMetadata,\n\t\t\trevisionForInvert,\n\t\t\tfieldKinds,\n\t\t);\n\t}\n\n\treturn inverse;\n}\n\nfunction invertBuilds(\n\tbuilds: ChangeAtomIdBTree<TreeChunk> | undefined,\n): ChangeAtomIdBTree<number> | undefined {\n\tif (builds !== undefined) {\n\t\treturn brand(builds.mapValues((chunk) => chunk.topLevelLength));\n\t}\n\treturn undefined;\n}\n\ninterface InvertTable extends CrossFieldTable<FieldChange> {\n\toriginalFieldToContext: Map<FieldChange, InvertContext>;\n\tinvertedNodeToParent: ChangeAtomIdBTree<FieldId>;\n}\n\ninterface InvertContext {\n\tfieldId: FieldId;\n\tinvertedField: FieldChange;\n}\n\nclass InvertManager extends CrossFieldManagerI<FieldChange> {\n\tpublic constructor(\n\t\ttable: InvertTable,\n\t\tfield: FieldChange,\n\t\tprivate readonly fieldId: FieldId,\n\t\tallowInval = true,\n\t) {\n\t\tsuper(table, field, allowInval);\n\t}\n\n\tpublic override onMoveIn(id: ChangeAtomId): void {\n\t\tsetInChangeAtomIdMap(this.table.invertedNodeToParent, id, this.fieldId);\n\t}\n\n\tpublic override moveKey(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t): void {\n\t\tfail(0x9c5 /* Keys should not be moved manually during invert */);\n\t}\n\n\tprivate get table(): InvertTable {\n\t\treturn this.crossFieldTable as InvertTable;\n\t}\n}\n\nfunction makeCrossFieldKeyTable(\n\tfields: FieldChangeMap,\n\tnodes: ChangeAtomIdBTree<NodeChangeset>,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): CrossFieldKeyTable {\n\tconst keys: CrossFieldKeyTable = newCrossFieldKeyTable();\n\tpopulateCrossFieldKeyTableForFieldMap(keys, fields, undefined, fieldKinds);\n\tnodes.forEachPair(([revision, localId], node) => {\n\t\tif (node.fieldChanges !== undefined) {\n\t\t\tpopulateCrossFieldKeyTableForFieldMap(\n\t\t\t\tkeys,\n\t\t\t\tnode.fieldChanges,\n\t\t\t\t{\n\t\t\t\t\trevision,\n\t\t\t\t\tlocalId,\n\t\t\t\t},\n\t\t\t\tfieldKinds,\n\t\t\t);\n\t\t}\n\t});\n\n\treturn keys;\n}\n\nfunction populateCrossFieldKeyTableForFieldMap(\n\ttable: CrossFieldKeyTable,\n\tfields: FieldChangeMap,\n\tparent: NodeId | undefined,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): void {\n\tfor (const [fieldKey, fieldChange] of fields) {\n\t\tconst keys = getChangeHandler(fieldKinds, fieldChange.fieldKind).getCrossFieldKeys(\n\t\t\tfieldChange.change,\n\t\t);\n\t\tfor (const { key, count } of keys) {\n\t\t\ttable.set(key, count, { nodeId: parent, field: fieldKey });\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"invert.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/invert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EACN,8BAA8B,GAS9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAoB,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAC;AASvF,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,2BAA2B,EAC3B,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,GAE1B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAAsC,EACtC,UAAmB,EACnB,iBAA8B,EAC9B,UAA2D;IAE3D,iFAAiF;IACjF,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7E,wEAAwE;IACxE,MAAM,CACL,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,EACpC,KAAK,CAAC,6CAA6C,CACnD,CAAC;IAEF,MAAM,QAAQ,GAAmB,UAAU;QAC1C,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,CAAC,Q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,QAAiC,EACjC,EAAoB,EACpB,KAAa;QAEb,IAAI,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACnE,CAAC;IAED,IAAY,KAAK;QAChB,OAAO,IAAI,CAAC,eAA8B,CAAC;IAC5C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport {\n\trevisionMetadataSourceFromInfo,\n\ttype ChangeAtomId,\n\ttype ChangesetLocalId,\n\ttype FieldKindIdentifier,\n\ttype RevisionInfo,\n\ttype RevisionMetadataSource,\n\ttype RevisionTag,\n\ttype TaggedChange,\n\ttype TreeChunk,\n} from \"../../core/index.js\";\nimport { brand, idAllocatorFromMaxId, type IdAllocator } from \"../../util/index.js\";\nimport { newChangeAtomIdBTree, type ChangeAtomIdBTree } from \"../changeAtomIdBTree.js\";\nimport type {\n\tFieldChange,\n\tFieldChangeMap,\n\tFieldId,\n\tModularChangeset,\n\tNodeChangeset,\n\tNodeId,\n} from \"./modularChangeTypes.js\";\nimport {\n\tCrossFieldManagerI,\n\tgetChangeHandler,\n\tgetRevInfoFromTaggedChanges,\n\thasConflicts,\n\tmakeChangesetInversions,\n\tmakeModularChangeset,\n\tnewConstraintState,\n\tnewCrossFieldTable,\n\tupdateConstraintsForFields,\n\ttype CrossFieldTable,\n} from \"./modularChangeUtils.js\";\nimport type { CrossFieldTarget } from \"./crossFieldQueries.js\";\nimport type { FlexFieldKind } from \"./fieldKind.js\";\nimport { NodeAttachState } from \"./fieldChangeHandler.js\";\n\n/**\n * @param change - The change to invert.\n * @param isRollback - Whether the inverted change is meant to rollback a change on a branch as is the case when\n * performing a sandwich rebase.\n * @param revisionForInvert - The revision for the invert changeset.\n */\nexport function invertModularChange(\n\tchange: TaggedChange<ModularChangeset>,\n\tisRollback: boolean,\n\trevisionForInvert: RevisionTag,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): ModularChangeset {\n\t// Rollback changesets destroy the nodes created by the change being rolled back.\n\tconst destroys = isRollback ? invertBuilds(change.change.builds) : undefined;\n\n\t// Destroys only occur in rollback changesets, which are never inverted.\n\tassert(\n\t\tchange.change.destroys === undefined,\n\t\t0x89a /* Unexpected destroys in change to invert */,\n\t);\n\n\tconst revInfos: RevisionInfo[] = isRollback\n\t\t? [{ revision: revisionForInvert, rollbackOf: change.revision }]\n\t\t: [{ revision: revisionForInvert }];\n\n\tconst noChangeConstraint = change.change.noChangeConstraintOnRevert;\n\tconst noChangeConstraintOnRevert = change.change.noChangeConstraint;\n\n\tif (hasConflicts(change.change)) {\n\t\treturn makeModularChangeset({\n\t\t\tmaxId: change.change.maxId as number,\n\t\t\trevisions: revInfos,\n\t\t\tdestroys,\n\t\t});\n\t}\n\n\tconst genId: IdAllocator = idAllocatorFromMaxId(change.change.maxId ?? -1);\n\n\tconst crossFieldTable: InvertTable = {\n\t\t...newCrossFieldTable<FieldChange>(),\n\t\toriginalFieldToContext: new Map(),\n\t};\n\tconst { revInfos: oldRevInfos } = getRevInfoFromTaggedChanges([change]);\n\tconst revisionMetadata = revisionMetadataSourceFromInfo(oldRevInfos);\n\n\tconst invertedFields = invertFieldMap(\n\t\tchange.change.fieldChanges,\n\t\tundefined,\n\t\tisRollback,\n\t\tgenId,\n\t\tcrossFieldTable,\n\t\trevisionMetadata,\n\t\trevisionForInvert,\n\t\tfieldKinds,\n\t);\n\n\tconst invertedNodes = newChangeAtomIdBTree<NodeChangeset>();\n\tchange.change.nodeChanges.forEachPair(([revision, localId], nodeChangeset) => {\n\t\tinvertedNodes.set(\n\t\t\t[revision, localId],\n\t\t\tinvertNodeChange(\n\t\t\t\tnodeChangeset,\n\t\t\t\t{ revision, localId },\n\t\t\t\tisRollback,\n\t\t\t\tgenId,\n\t\t\t\tcrossFieldTable,\n\t\t\t\trevisionMetadata,\n\t\t\t\trevisionForInvert,\n\t\t\t\tfieldKinds,\n\t\t\t),\n\t\t);\n\t});\n\n\tif (crossFieldTable.invalidatedFields.size > 0) {\n\t\tconst fieldsToUpdate = crossFieldTable.invalidatedFields;\n\t\tcrossFieldTable.invalidatedFields = new Set();\n\t\tfor (const fieldChange of fieldsToUpdate) {\n\t\t\tconst originalFieldChange = fieldChange.change;\n\t\t\tconst context = crossFieldTable.originalFieldToContext.get(fieldChange);\n\t\t\tassert(\n\t\t\t\tcontext !== undefined,\n\t\t\t\t0x851 /* Should have context for every invalidated field */,\n\t\t\t);\n\t\t\tconst { invertedField, fieldId } = context;\n\n\t\t\tconst amendedChange = getChangeHandler(fieldKinds, fieldChange.fieldKind).rebaser.invert(\n\t\t\t\toriginalFieldChange,\n\t\t\t\tisRollback,\n\t\t\t\tgenId,\n\t\t\t\trevisionForInvert,\n\t\t\t\tnew InvertManager(crossFieldTable, fieldChange, fieldId),\n\t\t\t\trevisionMetadata,\n\t\t\t);\n\t\t\tinvertedField.change = brand(amendedChange);\n\t\t}\n\t}\n\n\tconst { crossFieldKeys, nodeToParent } = makeChangesetInversions(\n\t\tinvertedFields,\n\t\tinvertedNodes,\n\t\tfieldKinds,\n\t);\n\n\tconst constraintState = newConstraintState(0);\n\tupdateConstraintsForFields(\n\t\tinvertedFields,\n\t\tNodeAttachState.Attached,\n\t\tconstraintState,\n\t\tinvertedNodes,\n\t\tfieldKinds,\n\t);\n\n\treturn makeModularChangeset({\n\t\tfieldChanges: invertedFields,\n\t\tnodeChanges: invertedNodes,\n\t\tnodeToParent,\n\t\tnodeAliases: change.change.nodeAliases,\n\t\tcrossFieldKeys,\n\t\tmaxId: genId.getMaxId(),\n\t\trevisions: revInfos,\n\t\tconstraintViolationCount: constraintState.violationCount,\n\t\tnoChangeConstraint,\n\t\tnoChangeConstraintOnRevert,\n\t\tdestroys,\n\t});\n}\n\nfunction invertFieldMap(\n\tchanges: FieldChangeMap,\n\tparentId: NodeId | undefined,\n\tisRollback: boolean,\n\tgenId: IdAllocator,\n\tcrossFieldTable: InvertTable,\n\trevisionMetadata: RevisionMetadataSource,\n\trevisionForInvert: RevisionTag,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): FieldChangeMap {\n\tconst invertedFields: FieldChangeMap = new Map();\n\n\tfor (const [field, fieldChange] of changes) {\n\t\tconst fieldId = { nodeId: parentId, field };\n\t\tconst manager = new InvertManager(crossFieldTable, fieldChange, fieldId);\n\t\tconst invertedChange = getChangeHandler(fieldKinds, fieldChange.fieldKind).rebaser.invert(\n\t\t\tfieldChange.change,\n\t\t\tisRollback,\n\t\t\tgenId,\n\t\t\trevisionForInvert,\n\t\t\tmanager,\n\t\t\trevisionMetadata,\n\t\t);\n\n\t\tconst invertedFieldChange: FieldChange = {\n\t\t\t...fieldChange,\n\t\t\tchange: brand(invertedChange),\n\t\t};\n\t\tinvertedFields.set(field, invertedFieldChange);\n\n\t\tcrossFieldTable.originalFieldToContext.set(fieldChange, {\n\t\t\tfieldId,\n\t\t\tinvertedField: invertedFieldChange,\n\t\t});\n\t}\n\n\treturn invertedFields;\n}\n\nfunction invertNodeChange(\n\tchange: NodeChangeset,\n\tid: NodeId,\n\tisRollback: boolean,\n\tgenId: IdAllocator,\n\tcrossFieldTable: InvertTable,\n\trevisionMetadata: RevisionMetadataSource,\n\trevisionForInvert: RevisionTag,\n\tfieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,\n): NodeChangeset {\n\tconst inverse: NodeChangeset = {};\n\n\t// If the node has a constraint, it should be inverted to a node-exist-on-revert constraint. This ensure that if\n\t// the inverse is inverted again, the original input constraint will be restored.\n\tif (change.nodeExistsConstraint !== undefined) {\n\t\tinverse.nodeExistsConstraintOnRevert = change.nodeExistsConstraint;\n\t}\n\n\t// The node-exist-on-revert constraint of a node is the constraint that should apply when the a change is reverted.\n\t// So, it should become the constraint in the inverse. If this constraint is violated when applying the inverse,\n\t// it will be discarded.\n\tif (change.nodeExistsConstraintOnRevert !== undefined) {\n\t\tinverse.nodeExistsConstraint = change.nodeExistsConstraintOnRevert;\n\t}\n\n\tif (change.fieldChanges !== undefined) {\n\t\tinverse.fieldChanges = invertFieldMap(\n\t\t\tchange.fieldChanges,\n\t\t\tid,\n\t\t\tisRollback,\n\t\t\tgenId,\n\t\t\tcrossFieldTable,\n\t\t\trevisionMetadata,\n\t\t\trevisionForInvert,\n\t\t\tfieldKinds,\n\t\t);\n\t}\n\n\treturn inverse;\n}\n\nfunction invertBuilds(\n\tbuilds: ChangeAtomIdBTree<TreeChunk> | undefined,\n): ChangeAtomIdBTree<number> | undefined {\n\tif (builds !== undefined) {\n\t\treturn brand(builds.mapValues((chunk) => chunk.topLevelLength));\n\t}\n\treturn undefined;\n}\n\ninterface InvertTable extends CrossFieldTable<FieldChange> {\n\toriginalFieldToContext: Map<FieldChange, InvertContext>;\n}\n\ninterface InvertContext {\n\tfieldId: FieldId;\n\tinvertedField: FieldChange;\n}\n\nclass InvertManager extends CrossFieldManagerI<FieldChange> {\n\tpublic constructor(\n\t\ttable: InvertTable,\n\t\tfield: FieldChange,\n\t\tprivate readonly fieldId: FieldId,\n\t\tallowInval = true,\n\t) {\n\t\tsuper(table, field, allowInval);\n\t}\n\n\tpublic override onMoveIn(id: ChangeAtomId): void {}\n\n\tpublic override moveKey(\n\t\ttarget: CrossFieldTarget,\n\t\trevision: RevisionTag | undefined,\n\t\tid: ChangesetLocalId,\n\t\tcount: number,\n\t): void {\n\t\tfail(0x9c5 /* Keys should not be moved manually during invert */);\n\t}\n\n\tprivate get table(): InvertTable {\n\t\treturn this.crossFieldTable as InvertTable;\n\t}\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ModularChangeFamily } from "./modularChangeFamily.js";
5
+ import { type FieldKindIdentifier, type IEditableForest } from "../../core/index.js";
6
+ import type { FlexFieldKind } from "./fieldKind.js";
6
7
  import type { ModularChangeset } from "./modularChangeTypes.js";
7
8
  /**
8
9
  * "Minimizes" a {@link ModularChangeset} so that it contains no extraneous
@@ -13,12 +14,9 @@ import type { ModularChangeset } from "./modularChangeTypes.js";
13
14
  * transaction, or changes whose effects cancel out to nothing. Minimizing reduces the size of an edit without altering
14
15
  * its observable effect.
15
16
  *
16
- * This is the eventual home of the minimization algorithm, colocated with {@link ModularChangeFamily} so it can use its
17
- * internals. It is currently a no-op that returns the change unchanged; a real implementation will be provided in a
18
- * future change.
19
- *
20
17
  * @param change - The change to minimize.
21
- * @param changeFamily - The change family used to compute the change's delta and identify built nodes.
18
+ * @param fieldKinds - The field kinds used in the changeset.
19
+ * @param forestFactory - A function that returns a new forest instance.
22
20
  */
23
- export declare function minimizeModularChangeset(change: ModularChangeset, changeFamily: ModularChangeFamily): ModularChangeset;
21
+ export declare function minimizeModularChangeset(change: ModularChangeset, fieldKinds: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>, forestFactory: () => IEditableForest): ModularChangeset;
24
22
  //# sourceMappingURL=minimizeModularChange.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"minimizeModularChange.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/minimizeModularChange.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,mBAAmB,GAC/B,gBAAgB,CAGlB"}
1
+ {"version":3,"file":"minimizeModularChange.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/minimizeModularChange.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAcN,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAEpB,MAAM,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,OAAO,KAAK,EAIX,gBAAgB,EAGhB,MAAM,yBAAyB,CAAC;AASjC;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,WAAW,CAAC,mBAAmB,EAAE,aAAa,CAAC,EAC3D,aAAa,EAAE,MAAM,eAAe,GAClC,gBAAgB,CAElB"}
@@ -2,6 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { deltaFieldMapHasChanges, makeAnonChange, makeChangeAtomId, makeDetachedFieldIndex, newChangeAtomIdRangeMap, newChangeAtomIdTransform, offsetChangeAtomId, visitDelta, } from "../../core/index.js";
6
+ import { brand, hasSingle, setInNestedMap, } from "../../util/index.js";
7
+ import { getFromChangeAtomIdMap, newChangeAtomIdBTree, setInChangeAtomIdMap, } from "../changeAtomIdBTree.js";
8
+ import { CrossFieldTarget } from "./crossFieldQueries.js";
9
+ import { EditFilterStatus, NodeAttachState, } from "./fieldChangeHandler.js";
10
+ import { filterEdits } from "./filterEdits.js";
11
+ import { invertModularChange } from "./invert.js";
12
+ import { intoDelta } from "./modularChangeFamily.js";
13
+ import { getChangeHandler, nodeChangeFromId, normalizeNodeId, validateChangeset, } from "./modularChangeUtils.js";
14
+ import { assert, fail } from "@fluidframework/core-utils/internal";
5
15
  /**
6
16
  * "Minimizes" a {@link ModularChangeset} so that it contains no extraneous
7
17
  * information, i.e. no new content that isn't observable from document tree
@@ -11,15 +21,455 @@
11
21
  * transaction, or changes whose effects cancel out to nothing. Minimizing reduces the size of an edit without altering
12
22
  * its observable effect.
13
23
  *
14
- * This is the eventual home of the minimization algorithm, colocated with {@link ModularChangeFamily} so it can use its
15
- * internals. It is currently a no-op that returns the change unchanged; a real implementation will be provided in a
16
- * future change.
17
- *
18
24
  * @param change - The change to minimize.
19
- * @param changeFamily - The change family used to compute the change's delta and identify built nodes.
25
+ * @param fieldKinds - The field kinds used in the changeset.
26
+ * @param forestFactory - A function that returns a new forest instance.
27
+ */
28
+ export function minimizeModularChangeset(change, fieldKinds, forestFactory) {
29
+ return new ModularChangeMinimizer(change, fieldKinds).minimize(forestFactory);
30
+ }
31
+ class ModularChangeMinimizer {
32
+ change;
33
+ fieldKinds;
34
+ builtNodeIds;
35
+ builtRootIds;
36
+ outputAttachStates;
37
+ outputToInputRootId;
38
+ rootIdToNodeId;
39
+ attachedRootIds;
40
+ constructor(change, fieldKinds) {
41
+ this.change = change;
42
+ this.fieldKinds = fieldKinds;
43
+ this.outputAttachStates = getOutputNodeAttachStates(change, fieldKinds);
44
+ const nodeInfo = getNodeInfo(change, fieldKinds);
45
+ this.builtNodeIds = nodeInfo.builtNodeIds;
46
+ this.builtRootIds = nodeInfo.builtRootIds;
47
+ this.rootIdToNodeId = nodeInfo.rootIdToNodeId;
48
+ const delta = intoDelta(makeAnonChange(change), fieldKinds);
49
+ this.outputToInputRootId = outputToInputRootIdFromDelta(delta);
50
+ this.attachedRootIds = collectAttachedRootIds(delta, this.outputToInputRootId);
51
+ }
52
+ minimize(forestFactory) {
53
+ const residualChange = filterEdits(this.change, this.filterEditsForResidualChange.bind(this), this.fieldKinds);
54
+ residualChange.builds = this.squashBuilds(forestFactory);
55
+ validateChangeset(residualChange, this.fieldKinds);
56
+ return residualChange;
57
+ }
58
+ isNodeIdInBuiltTree(nodeId) {
59
+ return (nodeId !== undefined &&
60
+ getFromChangeAtomIdMap(this.builtNodeIds, normalizeNodeId(nodeId, this.change.nodeAliases)) === true);
61
+ }
62
+ isNodeDetachedInOutput(nodeId) {
63
+ return ((getFromChangeAtomIdMap(this.outputAttachStates, normalizeNodeId(nodeId, this.change.nodeAliases)) ?? fail(0xd37 /* Should have attach state for every node ID */)) ===
64
+ NodeAttachState.Detached);
65
+ }
66
+ isFieldDetachedInOutput(fieldId) {
67
+ return fieldId.nodeId !== undefined && this.isNodeDetachedInOutput(fieldId.nodeId);
68
+ }
69
+ shouldSquashDetach(fieldId, inputRootId) {
70
+ // `inputRootId === undefined` indicates that this is a move of a transiently attached built root.
71
+ // In that case, we convert the move to an insert at the final location, discarding the detach portion.
72
+ return this.isNodeIdInBuiltTree(fieldId.nodeId) && inputRootId === undefined;
73
+ }
74
+ shouldSquashAttach(fieldId, rootInputId, count, endpoint) {
75
+ if (!this.isNodeIdInBuiltTree(fieldId.nodeId)) {
76
+ return { value: false, length: count };
77
+ }
78
+ let countProcessed = count;
79
+ const isMoveOfBuiltRootEntry = this.builtRootIds.getFirst(rootInputId, countProcessed);
80
+ countProcessed = isMoveOfBuiltRootEntry.length;
81
+ const isAttachOfBuiltRoot = isMoveOfBuiltRootEntry?.value ?? false;
82
+ const isMoveFromBuiltTree = endpoint?.nodeId !== undefined && this.isNodeIdInBuiltTree(endpoint.nodeId);
83
+ const isAttachOfBuiltNode = isAttachOfBuiltRoot || isMoveFromBuiltTree;
84
+ return { value: isAttachOfBuiltNode, length: countProcessed };
85
+ }
86
+ shouldDropAttach(fieldId, rootInputId, count, endpoint) {
87
+ const isInDetachedTree = this.isFieldDetachedInOutput(fieldId);
88
+ let countProcessed = count;
89
+ const shouldSquashAttachEntry = this.shouldSquashAttach(fieldId, rootInputId, countProcessed, endpoint);
90
+ countProcessed = shouldSquashAttachEntry.length;
91
+ const isBuiltRootEntry = this.builtRootIds.getFirst(rootInputId, countProcessed);
92
+ countProcessed = isBuiltRootEntry.length;
93
+ const isAttachOfBuild = isBuiltRootEntry.value ??
94
+ (endpoint !== undefined && this.isNodeIdInBuiltTree(endpoint.nodeId));
95
+ const isAttachedRootEntry = this.attachedRootIds.getFirst(rootInputId, countProcessed);
96
+ countProcessed = isAttachedRootEntry.length;
97
+ const isTransientAttachOfBuild = isAttachOfBuild && !isAttachedRootEntry.value;
98
+ return {
99
+ value: isInDetachedTree || shouldSquashAttachEntry.value || isTransientAttachOfBuild,
100
+ length: countProcessed,
101
+ };
102
+ }
103
+ shouldDropDetach(fieldId, detachId, rootInputId, count, endpoint) {
104
+ let countProcessed = count;
105
+ if (this.shouldSquashDetach(fieldId, rootInputId)) {
106
+ return { value: true, length: countProcessed };
107
+ }
108
+ if (rootInputId !== undefined) {
109
+ // `inputRootId` is defined when this detach represents the rename of a detached root.
110
+ const isDetachOfBuiltRootEntry = this.builtRootIds.getFirst(rootInputId, countProcessed);
111
+ countProcessed = isDetachOfBuiltRootEntry.length;
112
+ const isDetachOfBuiltRoot = isDetachOfBuiltRootEntry.value !== undefined;
113
+ if (isDetachOfBuiltRoot)
114
+ // If this is a rename of a built node, either it ends detached, or is moved elsewhere.
115
+ // If moved, we squash the detach away, leaving only an attach at the destination.
116
+ // If detached, the build is not used, so we drop the rename.
117
+ return {
118
+ value: true,
119
+ length: countProcessed,
120
+ };
121
+ }
122
+ if (endpoint !== undefined) {
123
+ const shouldDropAttachEntry = this.shouldDropAttach(endpoint, rootInputId ?? detachId, countProcessed, fieldId);
124
+ countProcessed = shouldDropAttachEntry.length;
125
+ if (!shouldDropAttachEntry.value) {
126
+ // This detach is part of a move, and we are not dropping the attach, so we must preserve the detach as well.
127
+ return { value: false, length: countProcessed };
128
+ }
129
+ }
130
+ return { value: this.isFieldDetachedInOutput(fieldId), length: countProcessed };
131
+ }
132
+ filterEditsForBuildChange(fieldChange, fieldId) {
133
+ return {
134
+ ...fieldChange,
135
+ change: brand(getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.filterEdits(fieldChange.change, {
136
+ filterDetach: (detachId, count, inputRootId, endpoint) => this.filterDetachForBuildChange(fieldId, detachId, count, inputRootId, endpoint),
137
+ filterAttach: (id, count, _outputRootId, endpoint) => this.filterAttachForBuildChange(fieldId, id, count, endpoint),
138
+ preserveOtherEdits: false,
139
+ })),
140
+ };
141
+ }
142
+ filterDetachForBuildChange(fieldId, detachId, count, inputRootId, endpoint) {
143
+ if (!this.shouldSquashDetach(fieldId, inputRootId)) {
144
+ return {
145
+ value: { action: EditFilterStatus.Remove, shouldRemoveChild: false },
146
+ length: count,
147
+ };
148
+ }
149
+ let countProcessed = count;
150
+ const moveEndpointEntry = this.change.crossFieldKeys.getFirst({ ...(endpoint ?? detachId), target: CrossFieldTarget.Destination }, countProcessed);
151
+ countProcessed = moveEndpointEntry.length;
152
+ if (moveEndpointEntry.value !== undefined) {
153
+ const willSquashEndpointEntry = this.shouldSquashAttach(moveEndpointEntry.value, inputRootId ?? detachId, countProcessed, fieldId);
154
+ countProcessed = willSquashEndpointEntry.length;
155
+ const action = willSquashEndpointEntry.value
156
+ ? EditFilterStatus.Preserve
157
+ : EditFilterStatus.PreserveWithoutMove;
158
+ return { value: { action }, length: countProcessed };
159
+ }
160
+ return { value: { action: EditFilterStatus.Preserve }, length: countProcessed };
161
+ }
162
+ filterAttachForBuildChange(fieldId, id, count, endpoint) {
163
+ let countProcessed = count;
164
+ const moveId = endpoint ?? id;
165
+ const moveEndpointEntry = this.change.crossFieldKeys.getFirst({ ...moveId, target: CrossFieldTarget.Source }, countProcessed);
166
+ countProcessed = moveEndpointEntry.length;
167
+ const inputIdEntry = this.outputToInputRootId.getFirst(moveId, countProcessed);
168
+ countProcessed = inputIdEntry.length;
169
+ const rootInputId = inputIdEntry.value ?? moveId;
170
+ const shouldSquashEntry = this.shouldSquashAttach(fieldId, rootInputId, countProcessed, moveEndpointEntry.value);
171
+ countProcessed = shouldSquashEntry.length;
172
+ const isMove = moveEndpointEntry.value !== undefined;
173
+ if (!shouldSquashEntry.value) {
174
+ return { value: { action: EditFilterStatus.Remove }, length: countProcessed };
175
+ }
176
+ if (isMove) {
177
+ const movedNodeId = getFromChangeAtomIdMap(this.rootIdToNodeId, moveId);
178
+ return {
179
+ value: {
180
+ action: EditFilterStatus.PreserveWithoutMove,
181
+ nodeId: movedNodeId,
182
+ newAttachId: rootInputId,
183
+ },
184
+ length: countProcessed,
185
+ };
186
+ }
187
+ return {
188
+ value: { action: EditFilterStatus.Preserve },
189
+ length: countProcessed,
190
+ };
191
+ }
192
+ /**
193
+ * Returns a version of `fieldChange` to be used in the final minimized change.
194
+ * The filtered change will have dropped:
195
+ * - Edits which were squashed into the built trees.
196
+ * - Detaches of built roots. If part of a move, these are instead represented as an attach at the final location.
197
+ * - Edits to nodes which are detached in the output, except for detaches of content which does end attached.
198
+ */
199
+ filterEditsForResidualChange(fieldChange, fieldId) {
200
+ return {
201
+ ...fieldChange,
202
+ change: brand(getChangeHandler(this.fieldKinds, fieldChange.fieldKind).rebaser.filterEdits(fieldChange.change, {
203
+ filterDetach: (...args) => this.filterDetachForResidualChange(fieldId, ...args),
204
+ filterAttach: (...args) => this.filterAttachForResidualChange(fieldId, ...args),
205
+ preserveOtherEdits: false,
206
+ })),
207
+ };
208
+ }
209
+ filterDetachForResidualChange(fieldId, detachId, count, inputRootId, endpoint) {
210
+ let countProcessed = count;
211
+ const moveId = endpoint ?? detachId;
212
+ const moveEndpointEntry = this.change.crossFieldKeys.getFirst({ ...moveId, target: CrossFieldTarget.Destination }, count);
213
+ countProcessed = moveEndpointEntry.length;
214
+ const shouldDropEntry = this.shouldDropDetach(fieldId, detachId, inputRootId, countProcessed, moveEndpointEntry.value);
215
+ countProcessed = shouldDropEntry.length;
216
+ let hasPreservedAttach = false;
217
+ let hasDroppedAttach = false;
218
+ if (moveEndpointEntry.value !== undefined) {
219
+ const willDropAttachEntry = this.shouldDropAttach(moveEndpointEntry.value, inputRootId ?? detachId, countProcessed, fieldId);
220
+ countProcessed = willDropAttachEntry.length;
221
+ hasDroppedAttach = willDropAttachEntry.value;
222
+ hasPreservedAttach = !willDropAttachEntry.value;
223
+ }
224
+ if (shouldDropEntry.value) {
225
+ // If there is a preserved attach, we will represent any child change at that location,
226
+ // so we must remove them from here.
227
+ return {
228
+ value: { action: EditFilterStatus.Remove, shouldRemoveChild: hasPreservedAttach },
229
+ length: countProcessed,
230
+ };
231
+ }
232
+ return {
233
+ value: {
234
+ action: hasDroppedAttach
235
+ ? EditFilterStatus.PreserveWithoutMove
236
+ : EditFilterStatus.Preserve,
237
+ },
238
+ length: countProcessed,
239
+ };
240
+ }
241
+ filterAttachForResidualChange(fieldId, id, count, outputRootId, endpoint) {
242
+ let countProcessed = count;
243
+ const moveId = endpoint ?? id;
244
+ const moveEndpointEntry = this.change.crossFieldKeys.getFirst({ ...moveId, target: CrossFieldTarget.Source }, countProcessed);
245
+ countProcessed = moveEndpointEntry.length;
246
+ const inputIdEntry = this.outputToInputRootId.getFirst(moveId, countProcessed);
247
+ countProcessed = inputIdEntry.length;
248
+ const rootInputId = inputIdEntry.value ?? moveId;
249
+ const shouldDropEntry = this.shouldDropAttach(fieldId, rootInputId, countProcessed, moveEndpointEntry.value);
250
+ countProcessed = shouldDropEntry.length;
251
+ if (shouldDropEntry.value) {
252
+ return {
253
+ value: { action: EditFilterStatus.Remove },
254
+ length: countProcessed,
255
+ };
256
+ }
257
+ if (moveEndpointEntry.value !== undefined) {
258
+ const willDropEndpointEntry = this.shouldDropDetach(moveEndpointEntry.value, moveId, inputIdEntry.value, countProcessed, fieldId);
259
+ countProcessed = willDropEndpointEntry.length;
260
+ if (willDropEndpointEntry.value) {
261
+ const movedNodeId = getFromChangeAtomIdMap(this.rootIdToNodeId, moveId);
262
+ return {
263
+ value: {
264
+ action: EditFilterStatus.PreserveWithoutMove,
265
+ nodeId: movedNodeId,
266
+ newAttachId: inputIdEntry.value ?? moveId,
267
+ },
268
+ length: countProcessed,
269
+ };
270
+ }
271
+ }
272
+ return {
273
+ value: { action: EditFilterStatus.Preserve },
274
+ length: countProcessed,
275
+ };
276
+ }
277
+ squashBuilds(forestFactory) {
278
+ const changeForBuilds = filterEdits(this.change, this.filterEditsForBuildChange.bind(this), this.fieldKinds);
279
+ const deltaForBuilds = intoDelta(makeAnonChange(changeForBuilds), this.fieldKinds);
280
+ assert(!deltaFieldMapHasChanges(deltaForBuilds.fields), 0xd38 /* Expected all changes to attached tree to be filtered out */);
281
+ // There may still be paths to existing nodes in the delta, which must be removed before being applied to an empty forest.
282
+ // It is safe to remove these, because there are no edits to them, as asserted above.
283
+ deltaForBuilds.fields = new Map();
284
+ const forest = forestFactory();
285
+ const detachedFieldIndex = makeDetachedFieldIndex();
286
+ visitDelta(deltaForBuilds, forest.acquireVisitor(), detachedFieldIndex, undefined);
287
+ const squashedBuilds = newChangeAtomIdBTree();
288
+ const cursor = forest.getCursorAboveDetachedFields();
289
+ for (const entry of detachedFieldIndex.entries()) {
290
+ cursor.enterField(detachedFieldIndex.toFieldKey(entry.root));
291
+ const chunks = forest.chunkField(cursor);
292
+ // Delta visiting currently splits ranges of nodes into individual elements,
293
+ // so for now we will not have more than one node in a detached field.
294
+ assert(hasSingle(chunks), 0xd39 /* TODO: Handle multiple chunks */);
295
+ const chunk = chunks[0];
296
+ assert(chunk.topLevelLength === 1, 0xd3a /* TODO: Handle chunk with range of nodes */);
297
+ const rootId = {
298
+ revision: entry.id.major,
299
+ localId: brand(entry.id.minor),
300
+ };
301
+ const isAttachedEntry = this.attachedRootIds.getFirst(rootId, chunk.topLevelLength);
302
+ assert(isAttachedEntry.length === chunk.topLevelLength, 0xd3b /* TODO: Handle chunks which are only partially attached */);
303
+ if (isAttachedEntry.value) {
304
+ setInChangeAtomIdMap(squashedBuilds, rootId, chunk);
305
+ }
306
+ cursor.exitField();
307
+ }
308
+ return squashedBuilds;
309
+ }
310
+ }
311
+ function getOutputNodeAttachStates(change, fieldKinds) {
312
+ const inverse = invertModularChange(makeAnonChange(change), true, "root", fieldKinds);
313
+ return getInputNodeAttachStates(inverse, fieldKinds);
314
+ }
315
+ function getInputNodeAttachStates(change, fieldKinds) {
316
+ const nodeAttachStates = newChangeAtomIdBTree();
317
+ addInputNodeAttachStatesForFields(NodeAttachState.Attached, change.fieldChanges, change.nodeChanges, change.nodeAliases, fieldKinds, nodeAttachStates);
318
+ return nodeAttachStates;
319
+ }
320
+ function addInputNodeAttachStatesForFields(parentState, fields, nodes, nodeAliases, fieldKinds, nodeAttachStates) {
321
+ for (const fieldChange of fields.values()) {
322
+ const children = getChangeHandler(fieldKinds, fieldChange.fieldKind).getNestedChanges(fieldChange.change);
323
+ for (const { nodeId, inputRootId: inputId } of children) {
324
+ const normalizedNodeId = normalizeNodeId(nodeId, nodeAliases);
325
+ const attachState = parentState === NodeAttachState.Attached && inputId === undefined
326
+ ? NodeAttachState.Attached
327
+ : NodeAttachState.Detached;
328
+ nodeAttachStates.set([normalizedNodeId.revision, normalizedNodeId.localId], attachState);
329
+ const nodeChangeset = nodeChangeFromId(nodes, normalizedNodeId);
330
+ if (nodeChangeset.fieldChanges !== undefined) {
331
+ addInputNodeAttachStatesForFields(attachState, nodeChangeset.fieldChanges, nodes, nodeAliases, fieldKinds, nodeAttachStates);
332
+ }
333
+ }
334
+ }
335
+ }
336
+ function getNodeInfo(change, fieldKinds) {
337
+ const builtRootIds = newChangeAtomIdRangeMap();
338
+ if (change.builds !== undefined) {
339
+ for (const [rootId, chunk] of change.builds.entries()) {
340
+ builtRootIds.set(makeChangeAtomId(rootId[1], rootId[0]), chunk.topLevelLength, true);
341
+ }
342
+ }
343
+ const builtNodeIds = newChangeAtomIdBTree();
344
+ const rootIdToNodeId = newChangeAtomIdBTree();
345
+ addNodeInfoForFields(false, change.fieldChanges, change.nodeChanges, change.nodeAliases, builtRootIds, fieldKinds, builtNodeIds, rootIdToNodeId);
346
+ return { builtRootIds, builtNodeIds, rootIdToNodeId };
347
+ }
348
+ function addNodeInfoForFields(parentIsBuilt, fields, nodes, nodeAliases, buildIds, fieldKinds, builtNodeIds, rootIdToNodeId) {
349
+ for (const fieldChange of fields.values()) {
350
+ const children = getChangeHandler(fieldKinds, fieldChange.fieldKind).getNestedChanges(fieldChange.change);
351
+ for (const { nodeId, inputRootId: inputId, detachId } of children) {
352
+ const normalizedNodeId = normalizeNodeId(nodeId, nodeAliases);
353
+ const isPartOfBuild = parentIsBuilt ||
354
+ (inputId !== undefined && buildIds.getFirst(inputId, 1).value === true);
355
+ if (isPartOfBuild) {
356
+ builtNodeIds.set([normalizedNodeId.revision, normalizedNodeId.localId], true);
357
+ }
358
+ if (inputId !== undefined) {
359
+ setInChangeAtomIdMap(rootIdToNodeId, inputId, normalizedNodeId);
360
+ }
361
+ if (detachId !== undefined) {
362
+ setInChangeAtomIdMap(rootIdToNodeId, detachId, normalizedNodeId);
363
+ }
364
+ const nodeChangeset = nodeChangeFromId(nodes, normalizedNodeId);
365
+ if (nodeChangeset.fieldChanges !== undefined) {
366
+ addNodeInfoForFields(isPartOfBuild, nodeChangeset.fieldChanges, nodes, nodeAliases, buildIds, fieldKinds, builtNodeIds, rootIdToNodeId);
367
+ }
368
+ }
369
+ }
370
+ }
371
+ /**
372
+ * Collects the set of root IDs whose content ends up attached within the live document tree
373
+ * once the given change is applied.
374
+ * There are entries both for nodes which are detached in the input context,
375
+ * and also for nodes which are detached by this delta.
376
+ * The keys are pre-rename IDs.
377
+ *
378
+ * @remarks
379
+ * These are the "used" nodes: any build whose nodes are not in this set has no observable
380
+ * effect on the resulting document and can be dropped.
20
381
  */
21
- export function minimizeModularChangeset(change, changeFamily) {
22
- // TODO: Actually minimize the change. For now this is a no-op that returns the change unchanged.
23
- return change;
382
+ function collectAttachedRootIds(delta, outputToInputRootId) {
383
+ const detachIdToNodeChanges = getDeltaNodeChangesByDetachId(delta);
384
+ const attached = newChangeAtomIdRangeMap();
385
+ // Worklist of detached node ID ranges newly discovered to be live, whose own nested content must be visited.
386
+ const worklist = [];
387
+ const markLive = (attachId, count) => {
388
+ for (const inputIdEntry of outputToInputRootId.getAll(attachId, count)) {
389
+ const inputId = inputIdEntry.value ?? offsetChangeAtomId(attachId, inputIdEntry.offset);
390
+ // Only the sub-ranges of `[id, id + count)` that are not already live are newly discovered.
391
+ // Mark each such run live in a single range operation and enqueue it for processing.
392
+ for (const fragment of attached.getAll(inputId, inputIdEntry.length)) {
393
+ if (fragment.value === undefined) {
394
+ const runStart = offsetChangeAtomId(inputId, fragment.offset);
395
+ attached.set(runStart, fragment.length, true);
396
+ worklist.push({ id: runStart, count: fragment.length });
397
+ }
398
+ }
399
+ }
400
+ };
401
+ const visitLiveFields = (fields) => {
402
+ if (fields === undefined) {
403
+ return;
404
+ }
405
+ for (const field of fields.values()) {
406
+ for (const mark of field.marks) {
407
+ if (mark.attach !== undefined) {
408
+ markLive({ revision: mark.attach.major, localId: brand(mark.attach.minor) }, mark.count);
409
+ }
410
+ // `mark.fields` edits the cell's pre-existing content. Only descend when that content
411
+ // stays in the live tree (i.e. it is not being detached out of the tree).
412
+ if (mark.detach === undefined) {
413
+ visitLiveFields(mark.fields);
414
+ }
415
+ }
416
+ }
417
+ };
418
+ visitLiveFields(delta.fields);
419
+ // Process node ranges discovered to be live: pull in their nested content and propagate
420
+ // liveness backwards across renames (a node attached under its post-rename ID was built under its
421
+ // pre-rename ID). Iterate to a fixed point.
422
+ while (worklist.length > 0) {
423
+ const next = worklist.pop();
424
+ if (next === undefined) {
425
+ break;
426
+ }
427
+ const { id, count } = next;
428
+ // Nested content is keyed per node, so it must be visited one ID at a time.
429
+ for (let offset = 0; offset < count; offset += 1) {
430
+ visitLiveFields(detachIdToNodeChanges.get(id.revision)?.get(brand(id.localId + offset)));
431
+ }
432
+ }
433
+ return attached;
434
+ }
435
+ /**
436
+ * Returns a mapping from root ID to the field changes for that node.
437
+ * There are entries both for nodes which are detached in the input context,
438
+ * and also for nodes which are detached by this delta.
439
+ * The keys are pre-rename IDs.
440
+ */
441
+ function getDeltaNodeChangesByDetachId(delta) {
442
+ const detachIdToChanges = new Map();
443
+ const visitFields = (fields) => {
444
+ for (const fieldChange of fields.values()) {
445
+ for (const mark of fieldChange.marks) {
446
+ if (mark.fields !== undefined) {
447
+ visitFields(mark.fields);
448
+ if (mark.detach !== undefined) {
449
+ setInNestedMap(detachIdToChanges, mark.detach.major, mark.detach.minor, mark.fields);
450
+ }
451
+ }
452
+ }
453
+ }
454
+ };
455
+ if (delta.fields !== undefined) {
456
+ visitFields(delta.fields);
457
+ }
458
+ if (delta.global !== undefined) {
459
+ for (const { id, fields } of delta.global) {
460
+ setInNestedMap(detachIdToChanges, id.major, id.minor, fields);
461
+ visitFields(fields);
462
+ }
463
+ }
464
+ return detachIdToChanges;
465
+ }
466
+ function outputToInputRootIdFromDelta(delta) {
467
+ const outputToInputRootId = newChangeAtomIdTransform();
468
+ if (delta.rename !== undefined) {
469
+ for (const { oldId, newId, count } of delta.rename) {
470
+ outputToInputRootId.set(makeChangeAtomId(brand(newId.minor), newId.major), count, makeChangeAtomId(brand(oldId.minor), oldId.major));
471
+ }
472
+ }
473
+ return outputToInputRootId;
24
474
  }
25
475
  //# sourceMappingURL=minimizeModularChange.js.map