@fluidframework/tree 2.83.0 → 2.90.0-378676

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 (781) hide show
  1. package/api-report/tree.alpha.api.md +1 -0
  2. package/dist/core/change-family/changeFamily.d.ts +4 -1
  3. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  4. package/dist/core/change-family/changeFamily.js.map +1 -1
  5. package/dist/core/change-family/index.d.ts +1 -1
  6. package/dist/core/change-family/index.d.ts.map +1 -1
  7. package/dist/core/change-family/index.js.map +1 -1
  8. package/dist/core/index.d.ts +3 -3
  9. package/dist/core/index.d.ts.map +1 -1
  10. package/dist/core/index.js +6 -4
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/core/rebase/changeRebaser.d.ts +6 -1
  13. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  14. package/dist/core/rebase/changeRebaser.js.map +1 -1
  15. package/dist/core/rebase/index.d.ts +1 -1
  16. package/dist/core/rebase/index.d.ts.map +1 -1
  17. package/dist/core/rebase/index.js +2 -1
  18. package/dist/core/rebase/index.js.map +1 -1
  19. package/dist/core/rebase/types.d.ts +1 -0
  20. package/dist/core/rebase/types.d.ts.map +1 -1
  21. package/dist/core/rebase/types.js +5 -1
  22. package/dist/core/rebase/types.js.map +1 -1
  23. package/dist/core/rebase/utils.d.ts.map +1 -1
  24. package/dist/core/rebase/utils.js +25 -7
  25. package/dist/core/rebase/utils.js.map +1 -1
  26. package/dist/core/tree/delta.d.ts +5 -0
  27. package/dist/core/tree/delta.d.ts.map +1 -1
  28. package/dist/core/tree/delta.js.map +1 -1
  29. package/dist/core/tree/detachedFieldIndex.d.ts +13 -1
  30. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  31. package/dist/core/tree/detachedFieldIndex.js +14 -1
  32. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  33. package/dist/core/tree/detachedFieldIndexTypes.d.ts +4 -0
  34. package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  35. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  36. package/dist/core/tree/index.d.ts +2 -2
  37. package/dist/core/tree/index.d.ts.map +1 -1
  38. package/dist/core/tree/index.js +4 -3
  39. package/dist/core/tree/index.js.map +1 -1
  40. package/dist/core/tree/pathTree.d.ts +11 -3
  41. package/dist/core/tree/pathTree.d.ts.map +1 -1
  42. package/dist/core/tree/pathTree.js +14 -2
  43. package/dist/core/tree/pathTree.js.map +1 -1
  44. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  45. package/dist/core/tree/visitDelta.js +17 -13
  46. package/dist/core/tree/visitDelta.js.map +1 -1
  47. package/dist/feature-libraries/changeAtomIdBTree.d.ts +3 -2
  48. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  49. package/dist/feature-libraries/changeAtomIdBTree.js +15 -2
  50. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  51. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +92 -44
  52. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  53. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +220 -70
  54. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  55. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  56. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  57. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  58. package/dist/feature-libraries/default-schema/index.d.ts +2 -1
  59. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  60. package/dist/feature-libraries/default-schema/index.js +4 -2
  61. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  62. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +40 -0
  63. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  64. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +153 -0
  65. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  66. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  67. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  68. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  69. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  70. package/dist/feature-libraries/deltaUtils.d.ts +1 -0
  71. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  72. package/dist/feature-libraries/deltaUtils.js +6 -1
  73. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  74. package/dist/feature-libraries/flex-tree/context.d.ts +9 -0
  75. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  76. package/dist/feature-libraries/flex-tree/context.js +6 -0
  77. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  78. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  79. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  80. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  81. package/dist/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  82. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  83. package/dist/feature-libraries/flex-tree/lazyField.js +39 -8
  84. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  85. package/dist/feature-libraries/index.d.ts +3 -3
  86. package/dist/feature-libraries/index.d.ts.map +1 -1
  87. package/dist/feature-libraries/index.js +8 -4
  88. package/dist/feature-libraries/index.js.map +1 -1
  89. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  90. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  91. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  92. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +100 -24
  93. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  94. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -12
  95. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  96. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +85 -51
  97. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  98. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  99. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  100. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -9
  101. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  102. package/dist/feature-libraries/modular-schema/index.d.ts +3 -3
  103. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  104. package/dist/feature-libraries/modular-schema/index.js +2 -3
  105. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  106. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +18 -22
  107. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  108. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +276 -158
  109. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  110. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  111. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  113. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  114. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  115. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js +296 -0
  116. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  117. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -0
  118. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  119. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +8 -0
  120. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  121. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +56 -22
  122. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  123. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1390 -462
  124. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  125. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  126. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  127. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +1 -2
  128. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  129. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +3 -3
  130. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  131. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +74 -0
  132. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  133. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js +35 -0
  134. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  135. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +49 -10
  136. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  137. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -3
  138. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  139. package/dist/feature-libraries/optional-field/optionalField.d.ts +13 -32
  140. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  141. package/dist/feature-libraries/optional-field/optionalField.js +257 -446
  142. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  143. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  144. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  145. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +31 -0
  146. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  147. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  148. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  149. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  150. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  151. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  152. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +57 -28
  153. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  154. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  155. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  156. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js +57 -0
  157. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  158. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  159. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  160. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  161. package/dist/feature-libraries/optional-field/requiredField.d.ts +3 -2
  162. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  163. package/dist/feature-libraries/optional-field/requiredField.js +6 -1
  164. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  165. package/dist/feature-libraries/sequence-field/compose.d.ts +6 -7
  166. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  167. package/dist/feature-libraries/sequence-field/compose.js +81 -259
  168. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  169. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  170. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  171. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  172. package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
  173. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  174. package/dist/feature-libraries/sequence-field/invert.js +65 -167
  175. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  176. package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  177. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  178. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  179. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  180. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  181. package/dist/feature-libraries/sequence-field/moveEffectTable.js +7 -90
  182. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  183. package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
  184. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  185. package/dist/feature-libraries/sequence-field/rebase.js +109 -116
  186. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  187. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  188. package/dist/feature-libraries/sequence-field/replaceRevisions.js +19 -32
  189. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  190. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  191. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -2
  192. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  193. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  194. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  195. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +388 -187
  196. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  197. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  198. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +20 -62
  199. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  200. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  201. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  202. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  203. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  204. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  205. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  206. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +16 -111
  207. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  208. package/dist/feature-libraries/sequence-field/types.d.ts +37 -74
  209. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  210. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  211. package/dist/feature-libraries/sequence-field/utils.d.ts +20 -25
  212. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  213. package/dist/feature-libraries/sequence-field/utils.js +159 -320
  214. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  215. package/dist/packageVersion.d.ts +1 -1
  216. package/dist/packageVersion.d.ts.map +1 -1
  217. package/dist/packageVersion.js +1 -1
  218. package/dist/packageVersion.js.map +1 -1
  219. package/dist/shared-tree/independentView.d.ts.map +1 -1
  220. package/dist/shared-tree/independentView.js +1 -1
  221. package/dist/shared-tree/independentView.js.map +1 -1
  222. package/dist/shared-tree/index.d.ts +1 -1
  223. package/dist/shared-tree/index.d.ts.map +1 -1
  224. package/dist/shared-tree/index.js.map +1 -1
  225. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  226. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  227. package/dist/shared-tree/schematizeTree.js +2 -1
  228. package/dist/shared-tree/schematizeTree.js.map +1 -1
  229. package/dist/shared-tree/schematizingTreeView.d.ts +1 -5
  230. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  231. package/dist/shared-tree/schematizingTreeView.js +21 -35
  232. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  233. package/dist/shared-tree/sharedTree.d.ts +9 -3
  234. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  235. package/dist/shared-tree/sharedTree.js +4 -1
  236. package/dist/shared-tree/sharedTree.js.map +1 -1
  237. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -0
  238. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  239. package/dist/shared-tree/sharedTreeChangeCodecs.js +8 -0
  240. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  241. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  242. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  243. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  244. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  245. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  246. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  247. package/dist/shared-tree/sharedTreeEditBuilder.js +14 -7
  248. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  249. package/dist/shared-tree/treeCheckout.d.ts +13 -11
  250. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  251. package/dist/shared-tree/treeCheckout.js +56 -6
  252. package/dist/shared-tree/treeCheckout.js.map +1 -1
  253. package/dist/shared-tree-core/branch.d.ts +3 -2
  254. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  255. package/dist/shared-tree-core/branch.js +4 -3
  256. package/dist/shared-tree-core/branch.js.map +1 -1
  257. package/dist/shared-tree-core/editManager.d.ts +2 -2
  258. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  259. package/dist/shared-tree-core/editManager.js +9 -9
  260. package/dist/shared-tree-core/editManager.js.map +1 -1
  261. package/dist/shared-tree-core/editManagerCodecs.d.ts +4 -0
  262. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  263. package/dist/shared-tree-core/editManagerCodecs.js +10 -2
  264. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  265. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  266. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  267. package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
  268. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  269. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  270. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  271. package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  272. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  273. package/dist/shared-tree-core/index.d.ts +2 -2
  274. package/dist/shared-tree-core/index.d.ts.map +1 -1
  275. package/dist/shared-tree-core/index.js +3 -1
  276. package/dist/shared-tree-core/index.js.map +1 -1
  277. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  278. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  279. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  280. package/dist/shared-tree-core/messageCodecs.d.ts +4 -0
  281. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  282. package/dist/shared-tree-core/messageCodecs.js +10 -2
  283. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  284. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  285. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  286. package/dist/shared-tree-core/messageFormat.js +6 -0
  287. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  288. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  289. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  290. package/dist/shared-tree-core/messageFormatV1ToV4.js +1 -0
  291. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  292. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  293. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  294. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  295. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  296. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +16 -12
  297. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  298. package/dist/simple-tree/core/unhydratedFlexTree.js +59 -8
  299. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  300. package/dist/simple-tree/fieldSchema.d.ts +4 -4
  301. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  302. package/dist/simple-tree/fieldSchema.js.map +1 -1
  303. package/dist/simple-tree/index.d.ts +2 -2
  304. package/dist/simple-tree/index.d.ts.map +1 -1
  305. package/dist/simple-tree/index.js +1 -1
  306. package/dist/simple-tree/index.js.map +1 -1
  307. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  308. package/dist/simple-tree/node-kinds/array/arrayNode.js +5 -3
  309. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  310. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  311. package/dist/simple-tree/node-kinds/common.js +1 -1
  312. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  313. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  314. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  315. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  316. package/dist/simple-tree/node-kinds/object/objectNode.js +19 -19
  317. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  318. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  319. package/dist/simple-tree/node-kinds/record/recordNode.js +4 -2
  320. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  321. package/dist/simple-tree/prepareForInsertion.d.ts +54 -47
  322. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  323. package/dist/simple-tree/prepareForInsertion.js +183 -125
  324. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  325. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +8 -3
  326. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  327. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +27 -13
  328. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  329. package/dist/treeFactory.d.ts.map +1 -1
  330. package/dist/treeFactory.js +12 -2
  331. package/dist/treeFactory.js.map +1 -1
  332. package/dist/util/index.d.ts +1 -1
  333. package/dist/util/index.d.ts.map +1 -1
  334. package/dist/util/index.js +2 -1
  335. package/dist/util/index.js.map +1 -1
  336. package/dist/util/rangeMap.d.ts +23 -11
  337. package/dist/util/rangeMap.d.ts.map +1 -1
  338. package/dist/util/rangeMap.js +43 -10
  339. package/dist/util/rangeMap.js.map +1 -1
  340. package/lib/core/change-family/changeFamily.d.ts +4 -1
  341. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  342. package/lib/core/change-family/changeFamily.js.map +1 -1
  343. package/lib/core/change-family/index.d.ts +1 -1
  344. package/lib/core/change-family/index.d.ts.map +1 -1
  345. package/lib/core/change-family/index.js.map +1 -1
  346. package/lib/core/index.d.ts +3 -3
  347. package/lib/core/index.d.ts.map +1 -1
  348. package/lib/core/index.js +2 -2
  349. package/lib/core/index.js.map +1 -1
  350. package/lib/core/rebase/changeRebaser.d.ts +6 -1
  351. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  352. package/lib/core/rebase/changeRebaser.js.map +1 -1
  353. package/lib/core/rebase/index.d.ts +1 -1
  354. package/lib/core/rebase/index.d.ts.map +1 -1
  355. package/lib/core/rebase/index.js +1 -1
  356. package/lib/core/rebase/index.js.map +1 -1
  357. package/lib/core/rebase/types.d.ts +1 -0
  358. package/lib/core/rebase/types.d.ts.map +1 -1
  359. package/lib/core/rebase/types.js +3 -0
  360. package/lib/core/rebase/types.js.map +1 -1
  361. package/lib/core/rebase/utils.d.ts.map +1 -1
  362. package/lib/core/rebase/utils.js +25 -7
  363. package/lib/core/rebase/utils.js.map +1 -1
  364. package/lib/core/tree/delta.d.ts +5 -0
  365. package/lib/core/tree/delta.d.ts.map +1 -1
  366. package/lib/core/tree/delta.js.map +1 -1
  367. package/lib/core/tree/detachedFieldIndex.d.ts +13 -1
  368. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  369. package/lib/core/tree/detachedFieldIndex.js +15 -2
  370. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  371. package/lib/core/tree/detachedFieldIndexTypes.d.ts +4 -0
  372. package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  373. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  374. package/lib/core/tree/index.d.ts +2 -2
  375. package/lib/core/tree/index.d.ts.map +1 -1
  376. package/lib/core/tree/index.js +1 -1
  377. package/lib/core/tree/index.js.map +1 -1
  378. package/lib/core/tree/pathTree.d.ts +11 -3
  379. package/lib/core/tree/pathTree.d.ts.map +1 -1
  380. package/lib/core/tree/pathTree.js +12 -1
  381. package/lib/core/tree/pathTree.js.map +1 -1
  382. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  383. package/lib/core/tree/visitDelta.js +17 -13
  384. package/lib/core/tree/visitDelta.js.map +1 -1
  385. package/lib/feature-libraries/changeAtomIdBTree.d.ts +3 -2
  386. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  387. package/lib/feature-libraries/changeAtomIdBTree.js +15 -3
  388. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  389. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +92 -44
  390. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  391. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +217 -69
  392. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  393. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  394. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  395. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  396. package/lib/feature-libraries/default-schema/index.d.ts +2 -1
  397. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  398. package/lib/feature-libraries/default-schema/index.js +2 -1
  399. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  400. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +40 -0
  401. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  402. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +149 -0
  403. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  404. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  405. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  406. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  407. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  408. package/lib/feature-libraries/deltaUtils.d.ts +1 -0
  409. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  410. package/lib/feature-libraries/deltaUtils.js +5 -1
  411. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  412. package/lib/feature-libraries/flex-tree/context.d.ts +9 -0
  413. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  414. package/lib/feature-libraries/flex-tree/context.js +6 -0
  415. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  416. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  417. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  418. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  419. package/lib/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  420. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  421. package/lib/feature-libraries/flex-tree/lazyField.js +40 -9
  422. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  423. package/lib/feature-libraries/index.d.ts +3 -3
  424. package/lib/feature-libraries/index.d.ts.map +1 -1
  425. package/lib/feature-libraries/index.js +3 -3
  426. package/lib/feature-libraries/index.js.map +1 -1
  427. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  428. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  429. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  430. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +100 -24
  431. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  432. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +7 -10
  433. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  434. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +85 -51
  435. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  436. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  437. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  438. package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -9
  439. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  440. package/lib/feature-libraries/modular-schema/index.d.ts +3 -3
  441. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  442. package/lib/feature-libraries/modular-schema/index.js +1 -1
  443. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  444. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +18 -22
  445. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  446. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +267 -144
  447. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  448. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  449. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  450. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  451. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  452. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  453. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js +292 -0
  454. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  455. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -0
  456. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  457. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +8 -0
  458. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  459. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +56 -22
  460. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  461. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1387 -468
  462. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  463. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  464. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  465. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +1 -2
  466. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  467. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
  468. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  469. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +74 -0
  470. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  471. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js +32 -0
  472. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  473. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +49 -10
  474. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  475. package/lib/feature-libraries/modular-schema/modularChangeTypes.js +1 -1
  476. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  477. package/lib/feature-libraries/optional-field/optionalField.d.ts +13 -32
  478. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  479. package/lib/feature-libraries/optional-field/optionalField.js +254 -442
  480. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  481. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  482. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  483. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +27 -0
  484. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  485. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  486. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  487. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  488. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  489. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  490. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +55 -26
  491. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  492. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  493. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  494. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js +53 -0
  495. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  496. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  497. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  498. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  499. package/lib/feature-libraries/optional-field/requiredField.d.ts +3 -2
  500. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  501. package/lib/feature-libraries/optional-field/requiredField.js +5 -1
  502. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  503. package/lib/feature-libraries/sequence-field/compose.d.ts +6 -7
  504. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  505. package/lib/feature-libraries/sequence-field/compose.js +83 -261
  506. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  507. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  508. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  509. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  510. package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
  511. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  512. package/lib/feature-libraries/sequence-field/invert.js +67 -169
  513. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  514. package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  515. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  516. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  517. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  518. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  519. package/lib/feature-libraries/sequence-field/moveEffectTable.js +6 -84
  520. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  521. package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
  522. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  523. package/lib/feature-libraries/sequence-field/rebase.js +111 -118
  524. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  525. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  526. package/lib/feature-libraries/sequence-field/replaceRevisions.js +19 -32
  527. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  528. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  529. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -3
  530. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  531. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  532. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  533. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +379 -182
  534. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  535. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  536. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +21 -63
  537. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  538. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  539. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  540. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  541. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  542. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  543. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  544. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +16 -111
  545. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  546. package/lib/feature-libraries/sequence-field/types.d.ts +37 -74
  547. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  548. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  549. package/lib/feature-libraries/sequence-field/utils.d.ts +20 -25
  550. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  551. package/lib/feature-libraries/sequence-field/utils.js +155 -313
  552. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  553. package/lib/packageVersion.d.ts +1 -1
  554. package/lib/packageVersion.d.ts.map +1 -1
  555. package/lib/packageVersion.js +1 -1
  556. package/lib/packageVersion.js.map +1 -1
  557. package/lib/shared-tree/independentView.d.ts.map +1 -1
  558. package/lib/shared-tree/independentView.js +1 -1
  559. package/lib/shared-tree/independentView.js.map +1 -1
  560. package/lib/shared-tree/index.d.ts +1 -1
  561. package/lib/shared-tree/index.d.ts.map +1 -1
  562. package/lib/shared-tree/index.js.map +1 -1
  563. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  564. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  565. package/lib/shared-tree/schematizeTree.js +3 -2
  566. package/lib/shared-tree/schematizeTree.js.map +1 -1
  567. package/lib/shared-tree/schematizingTreeView.d.ts +1 -5
  568. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  569. package/lib/shared-tree/schematizingTreeView.js +24 -38
  570. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  571. package/lib/shared-tree/sharedTree.d.ts +9 -3
  572. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  573. package/lib/shared-tree/sharedTree.js +4 -1
  574. package/lib/shared-tree/sharedTree.js.map +1 -1
  575. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -0
  576. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  577. package/lib/shared-tree/sharedTreeChangeCodecs.js +8 -0
  578. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  579. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  580. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  581. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  582. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  583. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  584. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  585. package/lib/shared-tree/sharedTreeEditBuilder.js +12 -6
  586. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  587. package/lib/shared-tree/treeCheckout.d.ts +13 -11
  588. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  589. package/lib/shared-tree/treeCheckout.js +59 -9
  590. package/lib/shared-tree/treeCheckout.js.map +1 -1
  591. package/lib/shared-tree-core/branch.d.ts +3 -2
  592. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  593. package/lib/shared-tree-core/branch.js +4 -3
  594. package/lib/shared-tree-core/branch.js.map +1 -1
  595. package/lib/shared-tree-core/editManager.d.ts +2 -2
  596. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  597. package/lib/shared-tree-core/editManager.js +9 -9
  598. package/lib/shared-tree-core/editManager.js.map +1 -1
  599. package/lib/shared-tree-core/editManagerCodecs.d.ts +4 -0
  600. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  601. package/lib/shared-tree-core/editManagerCodecs.js +8 -1
  602. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  603. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  604. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  605. package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
  606. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  607. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  608. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  609. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  610. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  611. package/lib/shared-tree-core/index.d.ts +2 -2
  612. package/lib/shared-tree-core/index.d.ts.map +1 -1
  613. package/lib/shared-tree-core/index.js +2 -2
  614. package/lib/shared-tree-core/index.js.map +1 -1
  615. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  616. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  617. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  618. package/lib/shared-tree-core/messageCodecs.d.ts +4 -0
  619. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  620. package/lib/shared-tree-core/messageCodecs.js +8 -1
  621. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  622. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  623. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  624. package/lib/shared-tree-core/messageFormat.js +6 -0
  625. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  626. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  627. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  628. package/lib/shared-tree-core/messageFormatV1ToV4.js +1 -0
  629. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  630. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  631. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  632. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  633. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  634. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +16 -12
  635. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  636. package/lib/simple-tree/core/unhydratedFlexTree.js +58 -8
  637. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  638. package/lib/simple-tree/fieldSchema.d.ts +4 -4
  639. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  640. package/lib/simple-tree/fieldSchema.js.map +1 -1
  641. package/lib/simple-tree/index.d.ts +2 -2
  642. package/lib/simple-tree/index.d.ts.map +1 -1
  643. package/lib/simple-tree/index.js +1 -1
  644. package/lib/simple-tree/index.js.map +1 -1
  645. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  646. package/lib/simple-tree/node-kinds/array/arrayNode.js +6 -4
  647. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  648. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  649. package/lib/simple-tree/node-kinds/common.js +2 -2
  650. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  651. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  652. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  653. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  654. package/lib/simple-tree/node-kinds/object/objectNode.js +20 -20
  655. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  656. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  657. package/lib/simple-tree/node-kinds/record/recordNode.js +4 -2
  658. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  659. package/lib/simple-tree/prepareForInsertion.d.ts +54 -47
  660. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  661. package/lib/simple-tree/prepareForInsertion.js +184 -125
  662. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  663. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +8 -3
  664. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  665. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +23 -10
  666. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  667. package/lib/treeFactory.d.ts.map +1 -1
  668. package/lib/treeFactory.js +13 -3
  669. package/lib/treeFactory.js.map +1 -1
  670. package/lib/util/index.d.ts +1 -1
  671. package/lib/util/index.d.ts.map +1 -1
  672. package/lib/util/index.js +1 -1
  673. package/lib/util/index.js.map +1 -1
  674. package/lib/util/rangeMap.d.ts +23 -11
  675. package/lib/util/rangeMap.d.ts.map +1 -1
  676. package/lib/util/rangeMap.js +41 -9
  677. package/lib/util/rangeMap.js.map +1 -1
  678. package/package.json +21 -21
  679. package/src/core/change-family/changeFamily.ts +5 -0
  680. package/src/core/change-family/index.ts +1 -0
  681. package/src/core/index.ts +4 -1
  682. package/src/core/rebase/changeRebaser.ts +6 -1
  683. package/src/core/rebase/index.ts +1 -0
  684. package/src/core/rebase/types.ts +4 -0
  685. package/src/core/rebase/utils.ts +31 -7
  686. package/src/core/tree/delta.ts +6 -0
  687. package/src/core/tree/detachedFieldIndex.ts +29 -1
  688. package/src/core/tree/detachedFieldIndexTypes.ts +5 -0
  689. package/src/core/tree/index.ts +13 -12
  690. package/src/core/tree/pathTree.ts +16 -4
  691. package/src/core/tree/visitDelta.ts +31 -11
  692. package/src/feature-libraries/changeAtomIdBTree.ts +28 -3
  693. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +369 -127
  694. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +13 -4
  695. package/src/feature-libraries/default-schema/index.ts +16 -5
  696. package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +231 -0
  697. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +35 -9
  698. package/src/feature-libraries/deltaUtils.ts +6 -1
  699. package/src/feature-libraries/flex-tree/context.ts +17 -0
  700. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +7 -8
  701. package/src/feature-libraries/flex-tree/lazyField.ts +65 -24
  702. package/src/feature-libraries/index.ts +22 -9
  703. package/src/feature-libraries/mitigatedChangeFamily.ts +3 -1
  704. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +144 -47
  705. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +113 -58
  706. package/src/feature-libraries/modular-schema/genericFieldKind.ts +7 -18
  707. package/src/feature-libraries/modular-schema/index.ts +16 -16
  708. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +623 -348
  709. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +1 -0
  710. package/src/feature-libraries/modular-schema/modularChangeCodecV3.ts +649 -0
  711. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +14 -0
  712. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2694 -748
  713. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +1 -0
  714. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +1 -1
  715. package/src/feature-libraries/modular-schema/modularChangeFormatV3.ts +67 -0
  716. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +62 -10
  717. package/src/feature-libraries/optional-field/optionalField.ts +359 -568
  718. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +45 -0
  719. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +31 -35
  720. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +89 -35
  721. package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +94 -0
  722. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -1
  723. package/src/feature-libraries/optional-field/requiredField.ts +15 -2
  724. package/src/feature-libraries/sequence-field/compose.ts +137 -522
  725. package/src/feature-libraries/sequence-field/helperTypes.ts +34 -19
  726. package/src/feature-libraries/sequence-field/invert.ts +102 -228
  727. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  728. package/src/feature-libraries/sequence-field/moveEffectTable.ts +8 -195
  729. package/src/feature-libraries/sequence-field/rebase.ts +171 -207
  730. package/src/feature-libraries/sequence-field/replaceRevisions.ts +26 -52
  731. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +8 -3
  732. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +677 -229
  733. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +56 -70
  734. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +28 -30
  735. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +21 -131
  736. package/src/feature-libraries/sequence-field/types.ts +40 -79
  737. package/src/feature-libraries/sequence-field/utils.ts +211 -370
  738. package/src/packageVersion.ts +1 -1
  739. package/src/shared-tree/independentView.ts +12 -6
  740. package/src/shared-tree/index.ts +3 -2
  741. package/src/shared-tree/schematizeTree.ts +21 -8
  742. package/src/shared-tree/schematizingTreeView.ts +38 -68
  743. package/src/shared-tree/sharedTree.ts +30 -15
  744. package/src/shared-tree/sharedTreeChangeCodecs.ts +8 -0
  745. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -4
  746. package/src/shared-tree/sharedTreeEditBuilder.ts +43 -8
  747. package/src/shared-tree/treeCheckout.ts +93 -17
  748. package/src/shared-tree-core/branch.ts +8 -2
  749. package/src/shared-tree-core/editManager.ts +16 -2
  750. package/src/shared-tree-core/editManagerCodecs.ts +11 -1
  751. package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
  752. package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
  753. package/src/shared-tree-core/index.ts +2 -0
  754. package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
  755. package/src/shared-tree-core/messageCodecs.ts +11 -1
  756. package/src/shared-tree-core/messageFormat.ts +6 -0
  757. package/src/shared-tree-core/messageFormatV1ToV4.ts +3 -1
  758. package/src/shared-tree-core/sharedTreeCore.ts +4 -1
  759. package/src/simple-tree/core/unhydratedFlexTree.ts +82 -35
  760. package/src/simple-tree/fieldSchema.ts +6 -4
  761. package/src/simple-tree/index.ts +2 -1
  762. package/src/simple-tree/node-kinds/array/arrayNode.ts +7 -5
  763. package/src/simple-tree/node-kinds/common.ts +2 -5
  764. package/src/simple-tree/node-kinds/map/mapNode.ts +4 -4
  765. package/src/simple-tree/node-kinds/object/objectNode.ts +26 -26
  766. package/src/simple-tree/node-kinds/record/recordNode.ts +10 -9
  767. package/src/simple-tree/prepareForInsertion.ts +342 -200
  768. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +35 -15
  769. package/src/treeFactory.ts +16 -4
  770. package/src/util/index.ts +3 -0
  771. package/src/util/rangeMap.ts +68 -26
  772. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  773. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  774. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -50
  775. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  776. package/docs/main/sequence-field/move-composition.md +0 -46
  777. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  778. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  779. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -46
  780. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  781. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +0 -57
@@ -104,7 +104,9 @@ export interface FieldUpPath<TUpPath = UpPath> {
104
104
  /**
105
105
  * Given an {@link UpPath}, checks if it is a path to a detached root.
106
106
  */
107
- export declare function isDetachedUpPathRoot<T>(path: UpPath<T> | NormalizedUpPath): path is NormalizedUpPathRoot;
107
+ export declare function isDetachedUpPathRoot<T>(path: UpPath<T> | NormalizedUpPath): path is NormalizedUpPathRoot & {
108
+ readonly detachedNodeId: DetachedNodeId;
109
+ };
108
110
  /**
109
111
  * Delimits the extend of a range.
110
112
  */
@@ -166,7 +168,7 @@ export declare function clonePath(path: UpPath | undefined): UpPath | undefined;
166
168
  * Gets the elements of the given `path`, ordered from root-most to child-most.
167
169
  * @remarks These elements are unchanged and therefore still point "up".
168
170
  */
169
- export declare function topDownPath(path: UpPath | undefined): UpPath[];
171
+ export declare function topDownPath<T extends UpPath<T>>(path: T | undefined): T[];
170
172
  /**
171
173
  * Returns true if and only if `a` and `b` describe the same path.
172
174
  * @remarks
@@ -180,9 +182,15 @@ export declare function compareUpPaths(a: UpPath | undefined, b: UpPath | undefi
180
182
  */
181
183
  export declare function compareFieldUpPaths(a: FieldUpPath, b: FieldUpPath): boolean;
182
184
  /**
183
- * Checks whether or not a given path is parented under the root field.
185
+ * Returns the field key for the root field.
184
186
  * @param path - the path you want to check.
185
187
  * @returns the {@link DetachedField} which contains the path.
186
188
  */
187
189
  export declare function getDetachedFieldContainingPath(path: UpPath): DetachedField;
190
+ /**
191
+ * Returns the field key for the root field.
192
+ * @param path - the path you want to check.
193
+ * @returns the {@link DetachedField} which contains the path.
194
+ */
195
+ export declare function getDetachedFieldContainingFieldPath(path: FieldUpPath): DetachedField;
188
196
  //# sourceMappingURL=pathTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pathTree.d.ts","sourceRoot":"","sources":["../../../src/core/tree/pathTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,YAAY,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,MAAM,CAAC,OAAO,GAAG,aAAa;IAC9C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB,CAAC,OAAO,GAAG,wBAAwB,CACpE,SAAQ,MAAM,CAAC,OAAO,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;CACpD;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACzB,iBAAiB,CAAC,gBAAgB,CAAC,GACnC,wBAAwB,CAAC,gBAAgB,CAAC,GAC1C,oBAAoB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,MAAM,CAAC,SAAS,CAAC;IAC9D;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,SAA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;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAU1E;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAKpF"}
@@ -78,7 +78,7 @@ export function compareFieldUpPaths(a, b) {
78
78
  return compareUpPaths(a.parent, b.parent);
79
79
  }
80
80
  /**
81
- * Checks whether or not a given path is parented under the root field.
81
+ * Returns the field key for the root field.
82
82
  * @param path - the path you want to check.
83
83
  * @returns the {@link DetachedField} which contains the path.
84
84
  */
@@ -94,4 +94,15 @@ export function getDetachedFieldContainingPath(path) {
94
94
  }
95
95
  return keyAsDetachedField(path.parentField);
96
96
  }
97
+ /**
98
+ * Returns the field key for the root field.
99
+ * @param path - the path you want to check.
100
+ * @returns the {@link DetachedField} which contains the path.
101
+ */
102
+ export function getDetachedFieldContainingFieldPath(path) {
103
+ if (path.parent === undefined) {
104
+ return keyAsDetachedField(path.field);
105
+ }
106
+ return getDetachedFieldContainingPath(path.parent);
107
+ }
97
108
  //# sourceMappingURL=pathTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pathTree.js","sourceRoot":"","sources":["../../../src/core/tree/pathTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAmHpE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CACnC,IAAkC;IAElC,OAAQ,IAA6B,CAAC,cAAc,KAAK,SAAS,CAAC;AACpE,CAAC;AAgDD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACpC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACvB,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,KAA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,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,cAAc,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAY;IAC1D,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,OAAO,WAAW,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,kBAAkB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACP,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,CAAC;IACF,CAAC;IACD,OAAO,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { DetachedNodeId } from \"./delta.js\";\nimport { type DetachedField, keyAsDetachedField } from \"./types.js\";\n\n/**\n * Identical to {@link UpPath}, but a duplicate declaration is needed to make\n * the default type parameter compile.\n */\nexport type UpPathDefault = UpPath;\n\n/**\n * Path from a location in the tree upward.\n * UpPaths can be used with deduplicated upper parts to allow\n * working with paths localized to part of the tree without incurring\n * costs related to the depth of the local subtree.\n *\n * UpPaths can be thought of as terminating at a special root node (that is `undefined`)\n * whose FieldKeys correspond to detached sequences.\n *\n * UpPaths can be mutated over time and should be considered to be invalidated when any edits occurs:\n * Use of an UpPath that was acquired before the most recent edit is undefined behavior.\n */\nexport interface UpPath<TParent = UpPathDefault> {\n\t/**\n\t * The parent, or undefined in the case where this path is a member of a detached sequence.\n\t */\n\treadonly parent: TParent | undefined;\n\t/**\n\t * The Field under which this path points.\n\t * Note that if `parent` returns `undefined`, this key corresponds to a detached sequence.\n\t */\n\treadonly parentField: FieldKey; // TODO: Type information, including when in DetachedField.\n\t/**\n\t * The index within `parentField` this path is pointing to.\n\t */\n\treadonly parentIndex: NodeIndex;\n}\n\n/**\n * Identical to {@link INormalizedUpPath}, but a duplicate declaration is needed to make the default type parameter compile.\n */\nexport type INormalizedUpPathDefault = INormalizedUpPath;\n\n/**\n * Identical to {@link UpPath}, but a with a {@link DetachedNodeId} to specify the ID of detached roots.\n * Note that document roots (i.e., any node in the root field) are not considered detached roots and therefore do not have an associated ID.\n *\n * Use this interface for implementing a class that needs to be used as a {@link NormalizedUpPath}.\n */\nexport interface INormalizedUpPath<TParent = INormalizedUpPathDefault>\n\textends UpPath<TParent> {\n\treadonly detachedNodeId: DetachedNodeId | undefined;\n}\n\n/**\n * Identical to {@link UpPath}, but a with a {@link DetachedNodeId} to specify the ID of detached roots.\n * Note that document roots (i.e., any node in the root field) are not considered detached roots and therefore do not have an associated ID.\n *\n * Prefer this type over {@link INormalizedUpPath} except when implementing a class that needs to be used as a {@link NormalizedUpPath}.\n */\nexport type NormalizedUpPath =\n\t| INormalizedUpPath<NormalizedUpPath>\n\t| NormalizedUpPathInterior<NormalizedUpPath>\n\t| NormalizedUpPathRoot;\n\n/**\n * The root element of a {@link NormalizedUpPath}.\n */\nexport interface NormalizedUpPathRoot extends UpPath<undefined> {\n\t/**\n\t * The ID associated with this node if it is a detached root.\n\t */\n\treadonly detachedNodeId: DetachedNodeId | undefined;\n}\n\n/**\n * Identical to {@link NormalizedUpPathInterior}, but a duplicate declaration is needed to make the default type parameter compile.\n */\nexport type NormalizedUpPathInteriorDefault = NormalizedUpPathInterior;\n\n/**\n * An interior (i.e., non-root) element of a {@link NormalizedUpPath}.\n */\nexport interface NormalizedUpPathInterior<\n\tTParent = NormalizedUpPathInteriorDefault | NormalizedUpPathRoot,\n> extends UpPath<TParent> {\n\t/**\n\t * The parent.\n\t */\n\treadonly parent: TParent;\n}\n\n/**\n * Path from a field in the tree upward.\n *\n * See {@link UpPath}.\n */\nexport type NormalizedFieldUpPath<TParent = NormalizedUpPath> = FieldUpPath<TParent>;\n\n/**\n * Path from a field in the tree upward.\n *\n * See {@link FieldUpPath} and {@link NormalizedUpPath}.\n */\nexport interface FieldUpPath<TUpPath = UpPath> {\n\t/**\n\t * The parent, or undefined in the case where this path is to a detached sequence.\n\t */\n\treadonly parent: TUpPath | undefined;\n\n\t/**\n\t * The Field to which this path points.\n\t * Note that if `parent` returns `undefined`, this key corresponds to a detached sequence.\n\t */\n\treadonly field: FieldKey; // TODO: Type information, including when in DetachedField.\n}\n\n/**\n * Given an {@link UpPath}, checks if it is a path to a detached root.\n */\nexport function isDetachedUpPathRoot<T>(\n\tpath: UpPath<T> | NormalizedUpPath,\n): path is NormalizedUpPathRoot {\n\treturn (path as NormalizedUpPathRoot).detachedNodeId !== undefined;\n}\n\n/**\n * Delimits the extend of a range.\n */\nexport interface Range {\n\t/**\n\t * The location before the first node.\n\t * Must be less than or equal to `end`.\n\t */\n\treadonly start: PlaceIndex;\n\t/**\n\t * The location after the last node.\n\t * Must be greater than or equal to `start`.\n\t */\n\treadonly end: PlaceIndex;\n}\n\n/**\n * A possibly empty range of nodes in a field.\n * This object only characterizes the location of the range, it does not own/contain the nodes in the range.\n */\nexport interface RangeUpPath<TUpPath extends UpPath = UpPath>\n\textends FieldUpPath<TUpPath>,\n\t\tRange {}\n\n/**\n * A place in a field.\n */\nexport interface PlaceUpPath<TUpPath extends UpPath = UpPath> extends FieldUpPath<TUpPath> {\n\t/**\n\t * The location in the field.\n\t */\n\treadonly index: PlaceIndex;\n}\n\n/**\n * Indicates the index of a node in a field.\n * Zero indicates the first node in a field.\n */\nexport type NodeIndex = number;\n\n/**\n * Indicates a place between nodes in a field or at the extremity of a field.\n * Zero indicates the place at the start of the field (before the first node if any).\n */\nexport type PlaceIndex = number;\n\n/**\n * Gets the number of nodes above this one.\n * @remarks\n * Zero when the path's parent is undefined, meaning the path represents a node in a detached field.\n * Runs in O(depth) time.\n */\nexport function getDepth(path: UpPath): number {\n\tlet depth = 0;\n\tlet next = path.parent;\n\twhile (next !== undefined) {\n\t\tdepth += 1;\n\t\tnext = next.parent;\n\t}\n\treturn depth;\n}\n\n/**\n * Creates deep copy of the provided path as simple JavaScript object.\n * @remarks This is safe to hold onto and use deep object comparisons on.\n */\nexport function clonePath(path: UpPath): UpPath;\n\n/**\n * Creates a deep copy of the provided path as simple JavaScript object.\n * @remarks This is safe to hold onto and use deep object comparisons on.\n */\nexport function clonePath(path: UpPath | undefined): UpPath | undefined;\n\nexport function clonePath(path: UpPath | undefined): UpPath | undefined {\n\tif (path === undefined) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tparent: clonePath(path.parent),\n\t\tparentField: path.parentField,\n\t\tparentIndex: path.parentIndex,\n\t};\n}\n\n/**\n * Gets the elements of the given `path`, ordered from root-most to child-most.\n * @remarks These elements are unchanged and therefore still point \"up\".\n */\nexport function topDownPath(path: UpPath | undefined): UpPath[] {\n\tconst out: UpPath[] = [];\n\tlet curr = path;\n\twhile (curr !== undefined) {\n\t\tout.push(curr);\n\t\tcurr = curr.parent;\n\t}\n\tout.reverse();\n\treturn out;\n}\n\n/**\n * Returns true if and only if `a` and `b` describe the same path.\n * @remarks\n * Note that for mutable paths (as used in `AnchorSet`), this equality may change over time: this only checks if the two paths are currently the same.\n */\nexport function compareUpPaths(a: UpPath | undefined, b: UpPath | undefined): boolean {\n\tif (a === b) {\n\t\t// This handles the both `undefined` case, as well as provides an early out if a shared node is encountered.\n\t\treturn true;\n\t}\n\tif (a === undefined || b === undefined) {\n\t\treturn false;\n\t}\n\tif (a.parentField !== b.parentField || a.parentIndex !== b.parentIndex) {\n\t\treturn false;\n\t}\n\treturn compareUpPaths(a.parent, b.parent);\n}\n\n/**\n * Returns true if and only if `a` and `b` describe the same field path.\n * @remarks\n * Note that for mutable paths (as used in `AnchorSet`), this equality may change over time: this only checks if the two paths are currently the same.\n */\nexport function compareFieldUpPaths(a: FieldUpPath, b: FieldUpPath): boolean {\n\tif (a.field !== b.field) {\n\t\treturn false;\n\t}\n\treturn compareUpPaths(a.parent, b.parent);\n}\n\n/**\n * Checks whether or not a given path is parented under the root field.\n * @param path - the path you want to check.\n * @returns the {@link DetachedField} which contains the path.\n */\nexport function getDetachedFieldContainingPath(path: UpPath): DetachedField {\n\tlet currentPath = path;\n\twhile (currentPath !== undefined) {\n\t\tif (currentPath.parent === undefined) {\n\t\t\treturn keyAsDetachedField(currentPath.parentField);\n\t\t} else {\n\t\t\tcurrentPath = currentPath.parent;\n\t\t}\n\t}\n\treturn keyAsDetachedField(path.parentField);\n}\n"]}
1
+ {"version":3,"file":"pathTree.js","sourceRoot":"","sources":["../../../src/core/tree/pathTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAmHpE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CACnC,IAAkC;IAElC,OAAQ,IAA6B,CAAC,cAAc,KAAK,SAAS,CAAC;AACpE,CAAC;AAgDD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACpC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACvB,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAcD,MAAM,UAAU,SAAS,CAAC,IAAwB;IACjD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO;QACN,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;KAC7B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UA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S,EAAE,CAAC;YACtC,OAAO,kBAAkB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACP,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,CAAC;IACF,CAAC;IACD,OAAO,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CAAC,IAAiB;IACpE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { DetachedNodeId } from \"./delta.js\";\nimport { type DetachedField, keyAsDetachedField } from \"./types.js\";\n\n/**\n * Identical to {@link UpPath}, but a duplicate declaration is needed to make\n * the default type parameter compile.\n */\nexport type UpPathDefault = UpPath;\n\n/**\n * Path from a location in the tree upward.\n * UpPaths can be used with deduplicated upper parts to allow\n * working with paths localized to part of the tree without incurring\n * costs related to the depth of the local subtree.\n *\n * UpPaths can be thought of as terminating at a special root node (that is `undefined`)\n * whose FieldKeys correspond to detached sequences.\n *\n * UpPaths can be mutated over time and should be considered to be invalidated when any edits occurs:\n * Use of an UpPath that was acquired before the most recent edit is undefined behavior.\n */\nexport interface UpPath<TParent = UpPathDefault> {\n\t/**\n\t * The parent, or undefined in the case where this path is a member of a detached sequence.\n\t */\n\treadonly parent: TParent | undefined;\n\t/**\n\t * The Field under which this path points.\n\t * Note that if `parent` returns `undefined`, this key corresponds to a detached sequence.\n\t */\n\treadonly parentField: FieldKey; // TODO: Type information, including when in DetachedField.\n\t/**\n\t * The index within `parentField` this path is pointing to.\n\t */\n\treadonly parentIndex: NodeIndex;\n}\n\n/**\n * Identical to {@link INormalizedUpPath}, but a duplicate declaration is needed to make the default type parameter compile.\n */\nexport type INormalizedUpPathDefault = INormalizedUpPath;\n\n/**\n * Identical to {@link UpPath}, but a with a {@link DetachedNodeId} to specify the ID of detached roots.\n * Note that document roots (i.e., any node in the root field) are not considered detached roots and therefore do not have an associated ID.\n *\n * Use this interface for implementing a class that needs to be used as a {@link NormalizedUpPath}.\n */\nexport interface INormalizedUpPath<TParent = INormalizedUpPathDefault>\n\textends UpPath<TParent> {\n\treadonly detachedNodeId: DetachedNodeId | undefined;\n}\n\n/**\n * Identical to {@link UpPath}, but a with a {@link DetachedNodeId} to specify the ID of detached roots.\n * Note that document roots (i.e., any node in the root field) are not considered detached roots and therefore do not have an associated ID.\n *\n * Prefer this type over {@link INormalizedUpPath} except when implementing a class that needs to be used as a {@link NormalizedUpPath}.\n */\nexport type NormalizedUpPath =\n\t| INormalizedUpPath<NormalizedUpPath>\n\t| NormalizedUpPathInterior<NormalizedUpPath>\n\t| NormalizedUpPathRoot;\n\n/**\n * The root element of a {@link NormalizedUpPath}.\n */\nexport interface NormalizedUpPathRoot extends UpPath<undefined> {\n\t/**\n\t * The ID associated with this node if it is a detached root.\n\t */\n\treadonly detachedNodeId: DetachedNodeId | undefined;\n}\n\n/**\n * Identical to {@link NormalizedUpPathInterior}, but a duplicate declaration is needed to make the default type parameter compile.\n */\nexport type NormalizedUpPathInteriorDefault = NormalizedUpPathInterior;\n\n/**\n * An interior (i.e., non-root) element of a {@link NormalizedUpPath}.\n */\nexport interface NormalizedUpPathInterior<\n\tTParent = NormalizedUpPathInteriorDefault | NormalizedUpPathRoot,\n> extends UpPath<TParent> {\n\t/**\n\t * The parent.\n\t */\n\treadonly parent: TParent;\n}\n\n/**\n * Path from a field in the tree upward.\n *\n * See {@link UpPath}.\n */\nexport type NormalizedFieldUpPath<TParent = NormalizedUpPath> = FieldUpPath<TParent>;\n\n/**\n * Path from a field in the tree upward.\n *\n * See {@link FieldUpPath} and {@link NormalizedUpPath}.\n */\nexport interface FieldUpPath<TUpPath = UpPath> {\n\t/**\n\t * The parent, or undefined in the case where this path is to a detached sequence.\n\t */\n\treadonly parent: TUpPath | undefined;\n\n\t/**\n\t * The Field to which this path points.\n\t * Note that if `parent` returns `undefined`, this key corresponds to a detached sequence.\n\t */\n\treadonly field: FieldKey; // TODO: Type information, including when in DetachedField.\n}\n\n/**\n * Given an {@link UpPath}, checks if it is a path to a detached root.\n */\nexport function isDetachedUpPathRoot<T>(\n\tpath: UpPath<T> | NormalizedUpPath,\n): path is NormalizedUpPathRoot & { readonly detachedNodeId: DetachedNodeId } {\n\treturn (path as NormalizedUpPathRoot).detachedNodeId !== undefined;\n}\n\n/**\n * Delimits the extend of a range.\n */\nexport interface Range {\n\t/**\n\t * The location before the first node.\n\t * Must be less than or equal to `end`.\n\t */\n\treadonly start: PlaceIndex;\n\t/**\n\t * The location after the last node.\n\t * Must be greater than or equal to `start`.\n\t */\n\treadonly end: PlaceIndex;\n}\n\n/**\n * A possibly empty range of nodes in a field.\n * This object only characterizes the location of the range, it does not own/contain the nodes in the range.\n */\nexport interface RangeUpPath<TUpPath extends UpPath = UpPath>\n\textends FieldUpPath<TUpPath>,\n\t\tRange {}\n\n/**\n * A place in a field.\n */\nexport interface PlaceUpPath<TUpPath extends UpPath = UpPath> extends FieldUpPath<TUpPath> {\n\t/**\n\t * The location in the field.\n\t */\n\treadonly index: PlaceIndex;\n}\n\n/**\n * Indicates the index of a node in a field.\n * Zero indicates the first node in a field.\n */\nexport type NodeIndex = number;\n\n/**\n * Indicates a place between nodes in a field or at the extremity of a field.\n * Zero indicates the place at the start of the field (before the first node if any).\n */\nexport type PlaceIndex = number;\n\n/**\n * Gets the number of nodes above this one.\n * @remarks\n * Zero when the path's parent is undefined, meaning the path represents a node in a detached field.\n * Runs in O(depth) time.\n */\nexport function getDepth(path: UpPath): number {\n\tlet depth = 0;\n\tlet next = path.parent;\n\twhile (next !== undefined) {\n\t\tdepth += 1;\n\t\tnext = next.parent;\n\t}\n\treturn depth;\n}\n\n/**\n * Creates deep copy of the provided path as simple JavaScript object.\n * @remarks This is safe to hold onto and use deep object comparisons on.\n */\nexport function clonePath(path: UpPath): UpPath;\n\n/**\n * Creates a deep copy of the provided path as simple JavaScript object.\n * @remarks This is safe to hold onto and use deep object comparisons on.\n */\nexport function clonePath(path: UpPath | undefined): UpPath | undefined;\n\nexport function clonePath(path: UpPath | undefined): UpPath | undefined {\n\tif (path === undefined) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tparent: clonePath(path.parent),\n\t\tparentField: path.parentField,\n\t\tparentIndex: path.parentIndex,\n\t};\n}\n\n/**\n * Gets the elements of the given `path`, ordered from root-most to child-most.\n * @remarks These elements are unchanged and therefore still point \"up\".\n */\nexport function topDownPath<T extends UpPath<T>>(path: T | undefined): T[] {\n\tconst out: T[] = [];\n\tlet curr = path;\n\twhile (curr !== undefined) {\n\t\tout.push(curr);\n\t\tcurr = curr.parent;\n\t}\n\tout.reverse();\n\treturn out;\n}\n\n/**\n * Returns true if and only if `a` and `b` describe the same path.\n * @remarks\n * Note that for mutable paths (as used in `AnchorSet`), this equality may change over time: this only checks if the two paths are currently the same.\n */\nexport function compareUpPaths(a: UpPath | undefined, b: UpPath | undefined): boolean {\n\tif (a === b) {\n\t\t// This handles the both `undefined` case, as well as provides an early out if a shared node is encountered.\n\t\treturn true;\n\t}\n\tif (a === undefined || b === undefined) {\n\t\treturn false;\n\t}\n\tif (a.parentField !== b.parentField || a.parentIndex !== b.parentIndex) {\n\t\treturn false;\n\t}\n\treturn compareUpPaths(a.parent, b.parent);\n}\n\n/**\n * Returns true if and only if `a` and `b` describe the same field path.\n * @remarks\n * Note that for mutable paths (as used in `AnchorSet`), this equality may change over time: this only checks if the two paths are currently the same.\n */\nexport function compareFieldUpPaths(a: FieldUpPath, b: FieldUpPath): boolean {\n\tif (a.field !== b.field) {\n\t\treturn false;\n\t}\n\treturn compareUpPaths(a.parent, b.parent);\n}\n\n/**\n * Returns the field key for the root field.\n * @param path - the path you want to check.\n * @returns the {@link DetachedField} which contains the path.\n */\nexport function getDetachedFieldContainingPath(path: UpPath): DetachedField {\n\tlet currentPath = path;\n\twhile (currentPath !== undefined) {\n\t\tif (currentPath.parent === undefined) {\n\t\t\treturn keyAsDetachedField(currentPath.parentField);\n\t\t} else {\n\t\t\tcurrentPath = currentPath.parent;\n\t\t}\n\t}\n\treturn keyAsDetachedField(path.parentField);\n}\n\n/**\n * Returns the field key for the root field.\n * @param path - the path you want to check.\n * @returns the {@link DetachedField} which contains the path.\n */\nexport function getDetachedFieldContainingFieldPath(path: FieldUpPath): DetachedField {\n\tif (path.parent === undefined) {\n\t\treturn keyAsDetachedField(path.field);\n\t}\n\treturn getDetachedFieldContainingPath(path.parent);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.d.ts","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG1D,OAAO,EAAkB,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,KAAK,CAAC,IAAI,EACjB,OAAO,EAAE,YAAY,EACrB,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,WAAW,GAAG,SAAS,GACrC,IAAI,CA6DN;AA2GD;;;GAGG;AAC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ndex, visitor,
135
135
  // This if statement prevents that from happening.
136
136
  if (!areDetachedNodeIdsEqual(oldId, newId)) {
137
137
  for (let i = 0; i < count; i += 1) {
138
- atomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });
138
+ const source = detachedFieldIndex.isAttachable(offsetDetachId(oldId, i));
139
+ atomized.push({
140
+ oldId: offsetDetachId(oldId, i),
141
+ newId: offsetDetachId(newId, i),
142
+ isAttachable: source,
143
+ });
139
144
  }
140
145
  }
141
146
  return atomized;
@@ -143,30 +148,29 @@ function transferRoots(rootTransfers, mapToUpdate, detachedFieldIndex, visitor,
143
148
  while (nextBatch.length > 0) {
144
149
  const delayed = [];
145
150
  const priorSize = nextBatch.length;
146
- for (const { oldId, newId } of nextBatch) {
151
+ for (const { oldId, newId, isAttachable } of nextBatch) {
147
152
  let oldRootId = detachedFieldIndex.tryGetEntry(oldId);
148
153
  if (oldRootId === undefined) {
149
154
  const tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);
150
155
  if (tree !== undefined) {
151
- buildTrees(oldId, [tree], detachedFieldIndex, revision, visitor);
156
+ buildTrees(oldId, [tree], detachedFieldIndex, revision, false, visitor);
152
157
  oldRootId = detachedFieldIndex.getEntry(oldId);
153
158
  }
154
159
  }
155
160
  if (oldRootId === undefined) {
156
161
  // The source field is not populated.
157
162
  // This can happen when another rename needs to be performed first.
158
- delayed.push({ oldId, newId });
163
+ delayed.push({ oldId, newId, isAttachable });
159
164
  continue;
160
165
  }
161
166
  let newRootId = detachedFieldIndex.tryGetEntry(newId);
162
167
  if (newRootId !== undefined) {
163
168
  // The destination field is already occupied.
164
169
  // This can happen when another rename needs to be performed first.
165
- delayed.push({ oldId, newId });
170
+ delayed.push({ oldId, newId, isAttachable });
166
171
  continue;
167
172
  }
168
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- intentional behavior
169
- newRootId = detachedFieldIndex.createEntry(newId, revision);
173
+ newRootId = detachedFieldIndex.createEntry(newId, revision, isAttachable);
170
174
  const fields = mapToUpdate.get(oldRootId);
171
175
  if (fields !== undefined) {
172
176
  mapToUpdate.delete(oldRootId);
@@ -214,7 +218,7 @@ function detachPass(fieldChanges, visitor, config) {
214
218
  if (mark.detach !== undefined) {
215
219
  for (let i = 0; i < mark.count; i += 1) {
216
220
  const id = offsetDetachId(mark.detach, i);
217
- const root = config.detachedFieldIndex.createEntry(id, config.latestRevision);
221
+ const root = config.detachedFieldIndex.createEntry(id, config.latestRevision, fieldChanges.allowReattach);
218
222
  if (mark.fields !== undefined) {
219
223
  config.attachPassRoots.set(root, mark.fields);
220
224
  }
@@ -227,12 +231,12 @@ function detachPass(fieldChanges, visitor, config) {
227
231
  }
228
232
  }
229
233
  }
230
- function buildTrees(id, trees, detachedFieldIndex, latestRevision, visitor) {
234
+ function buildTrees(id, trees, detachedFieldIndex, latestRevision, isAttachable, visitor) {
231
235
  for (const [i, tree] of trees.entries()) {
232
236
  const offsettedId = offsetDetachId(id, i);
233
237
  let root = detachedFieldIndex.tryGetEntry(offsettedId);
234
238
  assert(root === undefined, 0x929 /* Unable to build tree that already exists */);
235
- root = detachedFieldIndex.createEntry(offsettedId, latestRevision);
239
+ root = detachedFieldIndex.createEntry(offsettedId, latestRevision, isAttachable);
236
240
  const field = detachedFieldIndex.toFieldKey(root);
237
241
  visitor.create([tree], field);
238
242
  }
@@ -240,7 +244,7 @@ function buildTrees(id, trees, detachedFieldIndex, latestRevision, visitor) {
240
244
  function processBuilds(builds, config, visitor) {
241
245
  if (builds !== undefined) {
242
246
  for (const { id, trees } of builds) {
243
- buildTrees(id, nodeCursorsFromChunk(trees), config.detachedFieldIndex, config.latestRevision, visitor);
247
+ buildTrees(id, nodeCursorsFromChunk(trees), config.detachedFieldIndex, config.latestRevision, true, visitor);
244
248
  }
245
249
  }
246
250
  }
@@ -251,7 +255,7 @@ function processGlobal(global, config, visitor) {
251
255
  if (root === undefined) {
252
256
  const tree = tryGetFromNestedMap(config.refreshers, id.major, id.minor);
253
257
  assert(tree !== undefined, 0x928 /* refresher data not found */);
254
- buildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, visitor);
258
+ buildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, false, visitor);
255
259
  root = config.detachedFieldIndex.getEntry(id);
256
260
  }
257
261
  // the revision is updated for any refresher data included in the delta that is used
@@ -285,7 +289,7 @@ function attachPass(fieldChanges, visitor, config) {
285
289
  if (sourceRoot === undefined) {
286
290
  const tree = tryGetFromNestedMap(config.refreshers, offsetAttachId.major, offsetAttachId.minor);
287
291
  assert(tree !== undefined, 0x92a /* refresher data not found */);
288
- buildTrees(offsetAttachId, [tree], config.detachedFieldIndex, config.latestRevision, visitor);
292
+ buildTrees(offsetAttachId, [tree], config.detachedFieldIndex, config.latestRevision, false, visitor);
289
293
  sourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);
290
294
  }
291
295
  const sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAkB,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1F,OAAO,EAAE,cAAc,EAA+B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACzB,KAAiB,EACjB,OAAqB,EACrB,kBAAsC,EACtC,cAAuC;IAEvC,MAAM,eAAe,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrE,MAAM,eAAe,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrE,MAAM,aAAa,GAA+B,EAAE,CAAC;IACrD,MAAM,gBAAgB,GA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F,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { RevisionTag } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { areDetachedNodeIdsEqual, offsetDetachId } from \"./deltaUtil.js\";\nimport type { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId, Major, Minor } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detached field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n *\n * The details of the delta visit algorithm can impact how/when events are emitted by the objects that own the visitors.\n * For example, as of 2024-03-27, the subtreeChanged event of an AnchorNode is emitted when exiting a node during a\n * delta visit, and thus the two-pass nature of the algorithm means the event fires twice for any given change.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n * @param latestRevision - The latest revision tag associated with this delta.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous> = new Map();\n\tfor (const {\n\t\tid: { major, minor },\n\t\ttrees,\n\t} of delta.refreshers ?? []) {\n\t\tconst treeCursors = nodeCursorsFromChunk(trees);\n\t\tfor (let i = 0; i < trees.topLevelLength; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, treeCursors[i]);\n\t\t}\n\t}\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tprocessGlobal(delta.global, detachConfig, visitor);\n\tprocessRename(delta.rename, detachConfig);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(\n\t\trootTransfers,\n\t\tattachPassRoots,\n\t\tdetachedFieldIndex,\n\t\tvisitor,\n\t\trefreshers,\n\t\tlatestRevision,\n\t);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n): void {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * This occurs in the following circumstances:\n * - A changeset moves then removes a node\n * - A changeset restores then moves a node\n * - A changeset restores then removes a node\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n\trefreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>,\n\trevision?: RevisionTag,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\">;\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tatomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId } of nextBatch) {\n\t\t\tlet oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);\n\t\t\t\tif (tree !== undefined) {\n\t\t\t\t\tbuildTrees(oldId, [tree], detachedFieldIndex, revision, visitor);\n\t\t\t\t\toldRootId = detachedFieldIndex.getEntry(oldId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- intentional behavior\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId, revision);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField, newId, false);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor.\n\t *\n\t * Must be called once the visitor finished traversing the delta for a couple of reasons:\n\t *\n\t * 1. Some visitors, such as those from forests, are put into a special mode while they have a visitor, forbidding some actions (like making more visitors).\n\t *\n\t * 2. Some visitors, such as those from an anchorSet, defer some events for batching purposes until the visitor is freed.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t * @param id - The ID assigned to the first detached node as a result of the detach. The other nodes in the detached range are assigned subsequent IDs.\n\t * @param isReplaced - Whether the detached content will be replaced by a later attach.\n\t * This is not guaranteed to be true in all cases where it could be true,\n\t * but it is guaranteed to be true in all cases where a later attach is needed to keep the data compliant with the schema.\n\t */\n\tdetach(\n\t\tsource: Range,\n\t\tdestination: FieldKey,\n\t\tid: Delta.DetachedNodeId,\n\t\tisReplaced: boolean,\n\t): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\n\t/**\n\t * The latest revision tag associated with the given delta. This is used to keep track\n\t * of when repair data should be garbage collected.\n\t */\n\treadonly latestRevision: RevisionTag | undefined;\n\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\t/**\n\t * A mapping between forest root id and trees that represent refresher data. Each entry is only\n\t * created in the forest once needed.\n\t */\n\treadonly refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Collects all roots that may need an attach pass\n * - Executes detaches (bottom-up)\n */\nfunction detachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.fields !== undefined) {\n\t\t\tassert(\n\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t);\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst id = offsetDetachId(mark.detach, i);\n\t\t\t\tconst root = config.detachedFieldIndex.createEntry(id, config.latestRevision);\n\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t}\n\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field, id, mark.attach !== undefined);\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.attach === undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\nfunction buildTrees(\n\tid: Delta.DetachedNodeId,\n\ttrees: readonly ITreeCursorSynchronous[],\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n\tvisitor: DeltaVisitor,\n): void {\n\tfor (const [i, tree] of trees.entries()) {\n\t\tconst offsettedId = offsetDetachId(id, i);\n\t\tlet root = detachedFieldIndex.tryGetEntry(offsettedId);\n\t\tassert(root === undefined, 0x929 /* Unable to build tree that already exists */);\n\t\troot = detachedFieldIndex.createEntry(offsettedId, latestRevision);\n\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\tvisitor.create([tree], field);\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tbuildTrees(\n\t\t\t\tid,\n\t\t\t\tnodeCursorsFromChunk(trees),\n\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\tconfig.latestRevision,\n\t\t\t\tvisitor,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction processGlobal(\n\tglobal: readonly Delta.DetachedNodeChanges[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (global !== undefined) {\n\t\tfor (const { id, fields } of global) {\n\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(id);\n\t\t\tif (root === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(config.refreshers, id.major, id.minor);\n\t\t\t\tassert(tree !== undefined, 0x928 /* refresher data not found */);\n\t\t\t\tbuildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, visitor);\n\t\t\t\troot = config.detachedFieldIndex.getEntry(id);\n\t\t\t}\n\t\t\t// the revision is updated for any refresher data included in the delta that is used\n\t\t\tconfig.detachedFieldIndex.updateLatestRevision(id, config.latestRevision);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n}\n\nfunction processRename(\n\trename: readonly Delta.DetachedNodeRename[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (rename !== undefined) {\n\t\tconfig.rootTransfers.push(...rename);\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n */\nfunction attachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.attach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach, i);\n\t\t\t\tlet sourceRoot = config.detachedFieldIndex.tryGetEntry(offsetAttachId);\n\t\t\t\tif (sourceRoot === undefined) {\n\t\t\t\t\tconst tree = tryGetFromNestedMap(\n\t\t\t\t\t\tconfig.refreshers,\n\t\t\t\t\t\toffsetAttachId.major,\n\t\t\t\t\t\toffsetAttachId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(tree !== undefined, 0x92a /* refresher data not found */);\n\t\t\t\t\tbuildTrees(\n\t\t\t\t\t\toffsetAttachId,\n\t\t\t\t\t\t[tree],\n\t\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t\tvisitor,\n\t\t\t\t\t);\n\t\t\t\t\tsourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t}\n\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach === undefined || mark.attach !== undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\n/**\n * Converts a chunk of trees into an array of cursors.\n *\n * TODO: Update the visitDelta logic and downstream APIs to avoid splitting up sequences into individual nodes.\n */\nfunction nodeCursorsFromChunk(trees: TreeChunk): ITreeCursorSynchronous[] {\n\treturn mapCursorField(trees.cursor(), (c) => c.fork());\n}\n"]}
1
+ {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAkB,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1F,OAAO,EAAE,cAAc,EAA+B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKzE;;;;;;;;;;;;;;;;;;;;;;GAs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,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;gBACrE,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAC;gBAC9B,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC5C,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBACtD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACtD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC1B,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;oBAC1C,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;gBACjD,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { RevisionTag } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { areDetachedNodeIdsEqual, offsetDetachId } from \"./deltaUtil.js\";\nimport type { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId, Major, Minor } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detached field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n *\n * The details of the delta visit algorithm can impact how/when events are emitted by the objects that own the visitors.\n * For example, as of 2024-03-27, the subtreeChanged event of an AnchorNode is emitted when exiting a node during a\n * delta visit, and thus the two-pass nature of the algorithm means the event fires twice for any given change.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n * @param latestRevision - The latest revision tag associated with this delta.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous> = new Map();\n\tfor (const {\n\t\tid: { major, minor },\n\t\ttrees,\n\t} of delta.refreshers ?? []) {\n\t\tconst treeCursors = nodeCursorsFromChunk(trees);\n\t\tfor (let i = 0; i < trees.topLevelLength; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, treeCursors[i]);\n\t\t}\n\t}\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tprocessGlobal(delta.global, detachConfig, visitor);\n\tprocessRename(delta.rename, detachConfig);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(\n\t\trootTransfers,\n\t\tattachPassRoots,\n\t\tdetachedFieldIndex,\n\t\tvisitor,\n\t\trefreshers,\n\t\tlatestRevision,\n\t);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n): void {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * This occurs in the following circumstances:\n * - A changeset moves then removes a node\n * - A changeset restores then moves a node\n * - A changeset restores then removes a node\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n\trefreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>,\n\trevision?: RevisionTag,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\"> & {\n\t\tisAttachable?: boolean;\n\t};\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tconst source = detachedFieldIndex.isAttachable(offsetDetachId(oldId, i));\n\t\t\t\tatomized.push({\n\t\t\t\t\toldId: offsetDetachId(oldId, i),\n\t\t\t\t\tnewId: offsetDetachId(newId, i),\n\t\t\t\t\tisAttachable: source,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId, isAttachable } of nextBatch) {\n\t\t\tlet oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);\n\t\t\t\tif (tree !== undefined) {\n\t\t\t\t\tbuildTrees(oldId, [tree], detachedFieldIndex, revision, false, visitor);\n\t\t\t\t\toldRootId = detachedFieldIndex.getEntry(oldId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId, isAttachable });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId, isAttachable });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId, revision, isAttachable);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField, newId, false);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor.\n\t *\n\t * Must be called once the visitor finished traversing the delta for a couple of reasons:\n\t *\n\t * 1. Some visitors, such as those from forests, are put into a special mode while they have a visitor, forbidding some actions (like making more visitors).\n\t *\n\t * 2. Some visitors, such as those from an anchorSet, defer some events for batching purposes until the visitor is freed.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t * @param id - The ID assigned to the first detached node as a result of the detach. The other nodes in the detached range are assigned subsequent IDs.\n\t * @param isReplaced - Whether the detached content will be replaced by a later attach.\n\t * This is not guaranteed to be true in all cases where it could be true,\n\t * but it is guaranteed to be true in all cases where a later attach is needed to keep the data compliant with the schema.\n\t */\n\tdetach(\n\t\tsource: Range,\n\t\tdestination: FieldKey,\n\t\tid: Delta.DetachedNodeId,\n\t\tisReplaced: boolean,\n\t): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\n\t/**\n\t * The latest revision tag associated with the given delta. This is used to keep track\n\t * of when repair data should be garbage collected.\n\t */\n\treadonly latestRevision: RevisionTag | undefined;\n\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\t/**\n\t * A mapping between forest root id and trees that represent refresher data. Each entry is only\n\t * created in the forest once needed.\n\t */\n\treadonly refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Collects all roots that may need an attach pass\n * - Executes detaches (bottom-up)\n */\nfunction detachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.fields !== undefined) {\n\t\t\tassert(\n\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t);\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst id = offsetDetachId(mark.detach, i);\n\t\t\t\tconst root = config.detachedFieldIndex.createEntry(\n\t\t\t\t\tid,\n\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\tfieldChanges.allowReattach,\n\t\t\t\t);\n\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t}\n\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field, id, mark.attach !== undefined);\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.attach === undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\nfunction buildTrees(\n\tid: Delta.DetachedNodeId,\n\ttrees: readonly ITreeCursorSynchronous[],\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n\tisAttachable: boolean,\n\tvisitor: DeltaVisitor,\n): void {\n\tfor (const [i, tree] of trees.entries()) {\n\t\tconst offsettedId = offsetDetachId(id, i);\n\t\tlet root = detachedFieldIndex.tryGetEntry(offsettedId);\n\t\tassert(root === undefined, 0x929 /* Unable to build tree that already exists */);\n\t\troot = detachedFieldIndex.createEntry(offsettedId, latestRevision, isAttachable);\n\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\tvisitor.create([tree], field);\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tbuildTrees(\n\t\t\t\tid,\n\t\t\t\tnodeCursorsFromChunk(trees),\n\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\tconfig.latestRevision,\n\t\t\t\ttrue,\n\t\t\t\tvisitor,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction processGlobal(\n\tglobal: readonly Delta.DetachedNodeChanges[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (global !== undefined) {\n\t\tfor (const { id, fields } of global) {\n\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(id);\n\t\t\tif (root === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(config.refreshers, id.major, id.minor);\n\t\t\t\tassert(tree !== undefined, 0x928 /* refresher data not found */);\n\t\t\t\tbuildTrees(\n\t\t\t\t\tid,\n\t\t\t\t\t[tree],\n\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\tfalse,\n\t\t\t\t\tvisitor,\n\t\t\t\t);\n\t\t\t\troot = config.detachedFieldIndex.getEntry(id);\n\t\t\t}\n\t\t\t// the revision is updated for any refresher data included in the delta that is used\n\t\t\tconfig.detachedFieldIndex.updateLatestRevision(id, config.latestRevision);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n}\n\nfunction processRename(\n\trename: readonly Delta.DetachedNodeRename[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (rename !== undefined) {\n\t\tconfig.rootTransfers.push(...rename);\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n */\nfunction attachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.attach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach, i);\n\t\t\t\tlet sourceRoot = config.detachedFieldIndex.tryGetEntry(offsetAttachId);\n\t\t\t\tif (sourceRoot === undefined) {\n\t\t\t\t\tconst tree = tryGetFromNestedMap(\n\t\t\t\t\t\tconfig.refreshers,\n\t\t\t\t\t\toffsetAttachId.major,\n\t\t\t\t\t\toffsetAttachId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(tree !== undefined, 0x92a /* refresher data not found */);\n\t\t\t\t\tbuildTrees(\n\t\t\t\t\t\toffsetAttachId,\n\t\t\t\t\t\t[tree],\n\t\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tvisitor,\n\t\t\t\t\t);\n\t\t\t\t\tsourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t}\n\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach === undefined || mark.attach !== undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\n/**\n * Converts a chunk of trees into an array of cursors.\n *\n * TODO: Update the visitDelta logic and downstream APIs to avoid splitting up sequences into individual nodes.\n */\nfunction nodeCursorsFromChunk(trees: TreeChunk): ITreeCursorSynchronous[] {\n\treturn mapCursorField(trees.cursor(), (c) => c.fork());\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type ChangeAtomId, type ChangesetLocalId, type RevisionTag } from "../core/index.js";
6
- import { type TupleBTree } from "../util/index.js";
6
+ import { type RangeQueryResult, type TupleBTree } from "../util/index.js";
7
7
  /**
8
8
  * A BTree which uses ChangeAtomId flattened into a tuple as the key.
9
9
  * @remarks
@@ -13,5 +13,6 @@ export type ChangeAtomIdBTree<V> = TupleBTree<readonly [RevisionTag | undefined,
13
13
  /** Creates a new {@link ChangeAtomIdBTree} */
14
14
  export declare function newChangeAtomIdBTree<V>(entries?: [readonly [RevisionTag | undefined, ChangesetLocalId], V][]): ChangeAtomIdBTree<V>;
15
15
  export declare function getFromChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId): T | undefined;
16
- export declare function setInChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId, value: T): void;
16
+ export declare function setInChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId, value: T): boolean;
17
+ export declare function rangeQueryChangeAtomIdMap<T>(map: ChangeAtomIdBTree<T>, id: ChangeAtomId, count: number): RangeQueryResult<T | undefined>;
17
18
  //# sourceMappingURL=changeAtomIdBTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"changeAtomIdBTree.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/changeAtomIdBTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,UAAU,CAC5C,SAAS,CAAC,WAAW,GAAG,SAAS,EAAE,gBAAgB,CAAC,EACpD,CAAC,CACD,CAAC;AAEF,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,GACnE,iBAAiB,CAAC,CAAC,CAAC,CAEtB;AAID,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,GACd,CAAC,GAAG,SAAS,CAEf;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,CAAC,GACN,IAAI,CAEN"}
1
+ {"version":3,"file":"changeAtomIdBTree.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/changeAtomIdBTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGN,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,UAAU,CAC5C,SAAS,CAAC,WAAW,GAAG,SAAS,EAAE,gBAAgB,CAAC,EACpD,CAAC,CACD,CAAC;AAEF,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,GACnE,iBAAiB,CAAC,CAAC,CAAC,CAEtB;AAID,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,GACd,CAAC,GAAG,SAAS,CAEf;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,CAAC,GACN,OAAO,CAET;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAC1C,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,MAAM,GACX,gBAAgB,CAAC,CAAC,GAAG,SAAS,CAAC,CAajC"}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { compareChangesetLocalIds, comparePartialRevisions, } from "../core/index.js";
6
- import { createTupleComparator, newTupleBTree } from "../util/index.js";
5
+ import { subtractChangeAtomIds, compareChangesetLocalIds, comparePartialRevisions, } from "../core/index.js";
6
+ import { createTupleComparator, newTupleBTree, } from "../util/index.js";
7
7
  /** Creates a new {@link ChangeAtomIdBTree} */
8
8
  export function newChangeAtomIdBTree(entries) {
9
9
  return newTupleBTree(compareKeys, entries);
@@ -13,6 +13,18 @@ export function getFromChangeAtomIdMap(map, id) {
13
13
  return map.get([id.revision, id.localId]);
14
14
  }
15
15
  export function setInChangeAtomIdMap(map, id, value) {
16
- map.set([id.revision, id.localId], value);
16
+ return map.set([id.revision, id.localId], value);
17
+ }
18
+ export function rangeQueryChangeAtomIdMap(map, id, count) {
19
+ const pair = map.getPairOrNextHigher([id.revision, id.localId]);
20
+ if (pair === undefined) {
21
+ return { value: undefined, length: count };
22
+ }
23
+ const [[revision, localId], value] = pair;
24
+ const lengthBefore = subtractChangeAtomIds({ revision, localId }, id);
25
+ if (lengthBefore === 0) {
26
+ return { value, length: 1 };
27
+ }
28
+ return { value: undefined, length: Math.min(lengthBefore, count) };
17
29
  }
18
30
  //# sourceMappingURL=changeAtomIdBTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"changeAtomIdBTree.js","sourceRoot":"","sources":["../../src/feature-libraries/changeAtomIdBTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,uBAAuB,GAIvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AAYzF,8CAA8C;AAC9C,MAAM,UAAU,oBAAoB,CACnC,OAAqE;IAErE,OAAO,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,WAAW,GAAG,qBAAqB,CAAC,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,CAAC,CAAC;AAE/F,MAAM,UAAU,sBAAsB,CACrC,GAAyB,EACzB,EAAgB;IAEhB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,oBAAoB,CACnC,GAAyB,EACzB,EAAgB,EAChB,KAAQ;IAER,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tcompareChangesetLocalIds,\n\tcomparePartialRevisions,\n\ttype ChangeAtomId,\n\ttype ChangesetLocalId,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport { createTupleComparator, newTupleBTree, type TupleBTree } from \"../util/index.js\";\n\n/**\n * A BTree which uses ChangeAtomId flattened into a tuple as the key.\n * @remarks\n * Read values with {@link getFromChangeAtomIdMap} and write values with {@link setInChangeAtomIdMap}.\n */\nexport type ChangeAtomIdBTree<V> = TupleBTree<\n\treadonly [RevisionTag | undefined, ChangesetLocalId],\n\tV\n>;\n\n/** Creates a new {@link ChangeAtomIdBTree} */\nexport function newChangeAtomIdBTree<V>(\n\tentries?: [readonly [RevisionTag | undefined, ChangesetLocalId], V][],\n): ChangeAtomIdBTree<V> {\n\treturn newTupleBTree(compareKeys, entries);\n}\n\nconst compareKeys = createTupleComparator([comparePartialRevisions, compareChangesetLocalIds]);\n\nexport function getFromChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n): T | undefined {\n\treturn map.get([id.revision, id.localId]);\n}\n\nexport function setInChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n\tvalue: T,\n): void {\n\tmap.set([id.revision, id.localId], value);\n}\n"]}
1
+ {"version":3,"file":"changeAtomIdBTree.js","sourceRoot":"","sources":["../../src/feature-libraries/changeAtomIdBTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,GAIvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,qBAAqB,EACrB,aAAa,GAGb,MAAM,kBAAkB,CAAC;AAY1B,8CAA8C;AAC9C,MAAM,UAAU,oBAAoB,CACnC,OAAqE;IAErE,OAAO,a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ourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tsubtractChangeAtomIds,\n\tcompareChangesetLocalIds,\n\tcomparePartialRevisions,\n\ttype ChangeAtomId,\n\ttype ChangesetLocalId,\n\ttype RevisionTag,\n} from \"../core/index.js\";\nimport {\n\tcreateTupleComparator,\n\tnewTupleBTree,\n\ttype RangeQueryResult,\n\ttype TupleBTree,\n} from \"../util/index.js\";\n\n/**\n * A BTree which uses ChangeAtomId flattened into a tuple as the key.\n * @remarks\n * Read values with {@link getFromChangeAtomIdMap} and write values with {@link setInChangeAtomIdMap}.\n */\nexport type ChangeAtomIdBTree<V> = TupleBTree<\n\treadonly [RevisionTag | undefined, ChangesetLocalId],\n\tV\n>;\n\n/** Creates a new {@link ChangeAtomIdBTree} */\nexport function newChangeAtomIdBTree<V>(\n\tentries?: [readonly [RevisionTag | undefined, ChangesetLocalId], V][],\n): ChangeAtomIdBTree<V> {\n\treturn newTupleBTree(compareKeys, entries);\n}\n\nconst compareKeys = createTupleComparator([comparePartialRevisions, compareChangesetLocalIds]);\n\nexport function getFromChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n): T | undefined {\n\treturn map.get([id.revision, id.localId]);\n}\n\nexport function setInChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n\tvalue: T,\n): boolean {\n\treturn map.set([id.revision, id.localId], value);\n}\n\nexport function rangeQueryChangeAtomIdMap<T>(\n\tmap: ChangeAtomIdBTree<T>,\n\tid: ChangeAtomId,\n\tcount: number,\n): RangeQueryResult<T | undefined> {\n\tconst pair = map.getPairOrNextHigher([id.revision, id.localId]);\n\tif (pair === undefined) {\n\t\treturn { value: undefined, length: count };\n\t}\n\n\tconst [[revision, localId], value] = pair;\n\tconst lengthBefore = subtractChangeAtomIds({ revision, localId }, id);\n\tif (lengthBefore === 0) {\n\t\treturn { value, length: 1 };\n\t}\n\n\treturn { value: undefined, length: Math.min(lengthBefore, count) };\n}\n"]}