@fluidframework/tree 2.82.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 (986) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +33 -5
  3. package/api-report/tree.alpha.api.md +26 -21
  4. package/api-report/tree.beta.api.md +14 -2
  5. package/api-report/tree.legacy.beta.api.md +14 -2
  6. package/api-report/tree.legacy.public.api.md +1 -1
  7. package/api-report/tree.public.api.md +1 -1
  8. package/dist/alpha.d.ts +3 -3
  9. package/dist/beta.d.ts +1 -0
  10. package/dist/codec/codec.d.ts +3 -39
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +5 -50
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +1 -2
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/codec/versioned/codec.d.ts +20 -7
  19. package/dist/codec/versioned/codec.d.ts.map +1 -1
  20. package/dist/codec/versioned/codec.js +56 -30
  21. package/dist/codec/versioned/codec.js.map +1 -1
  22. package/dist/core/change-family/changeFamily.d.ts +4 -1
  23. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  24. package/dist/core/change-family/changeFamily.js.map +1 -1
  25. package/dist/core/change-family/index.d.ts +1 -1
  26. package/dist/core/change-family/index.d.ts.map +1 -1
  27. package/dist/core/change-family/index.js.map +1 -1
  28. package/dist/core/index.d.ts +3 -3
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/core/index.js +6 -4
  31. package/dist/core/index.js.map +1 -1
  32. package/dist/core/rebase/changeRebaser.d.ts +6 -1
  33. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  34. package/dist/core/rebase/changeRebaser.js.map +1 -1
  35. package/dist/core/rebase/index.d.ts +1 -1
  36. package/dist/core/rebase/index.d.ts.map +1 -1
  37. package/dist/core/rebase/index.js +2 -1
  38. package/dist/core/rebase/index.js.map +1 -1
  39. package/dist/core/rebase/types.d.ts +1 -0
  40. package/dist/core/rebase/types.d.ts.map +1 -1
  41. package/dist/core/rebase/types.js +5 -1
  42. package/dist/core/rebase/types.js.map +1 -1
  43. package/dist/core/rebase/utils.d.ts.map +1 -1
  44. package/dist/core/rebase/utils.js +25 -7
  45. package/dist/core/rebase/utils.js.map +1 -1
  46. package/dist/core/tree/delta.d.ts +5 -0
  47. package/dist/core/tree/delta.d.ts.map +1 -1
  48. package/dist/core/tree/delta.js.map +1 -1
  49. package/dist/core/tree/detachedFieldIndex.d.ts +13 -1
  50. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  51. package/dist/core/tree/detachedFieldIndex.js +14 -1
  52. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  53. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  54. package/dist/core/tree/detachedFieldIndexCodecs.js +6 -4
  55. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  56. package/dist/core/tree/detachedFieldIndexTypes.d.ts +4 -0
  57. package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  58. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  59. package/dist/core/tree/index.d.ts +2 -2
  60. package/dist/core/tree/index.d.ts.map +1 -1
  61. package/dist/core/tree/index.js +4 -3
  62. package/dist/core/tree/index.js.map +1 -1
  63. package/dist/core/tree/pathTree.d.ts +11 -3
  64. package/dist/core/tree/pathTree.d.ts.map +1 -1
  65. package/dist/core/tree/pathTree.js +14 -2
  66. package/dist/core/tree/pathTree.js.map +1 -1
  67. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  68. package/dist/core/tree/visitDelta.js +17 -13
  69. package/dist/core/tree/visitDelta.js.map +1 -1
  70. package/dist/extensibleUnionNode.d.ts +97 -0
  71. package/dist/extensibleUnionNode.d.ts.map +1 -0
  72. package/dist/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
  73. package/dist/extensibleUnionNode.js.map +1 -0
  74. package/dist/feature-libraries/changeAtomIdBTree.d.ts +3 -2
  75. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  76. package/dist/feature-libraries/changeAtomIdBTree.js +15 -2
  77. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/codecs.js +4 -4
  81. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +92 -44
  83. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +220 -70
  85. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  87. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  88. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts +2 -1
  90. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/default-schema/index.js +4 -2
  92. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  93. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +40 -0
  94. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  95. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js +153 -0
  96. package/dist/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  97. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  98. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  99. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  100. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  101. package/dist/feature-libraries/deltaUtils.d.ts +1 -0
  102. package/dist/feature-libraries/deltaUtils.d.ts.map +1 -1
  103. package/dist/feature-libraries/deltaUtils.js +6 -1
  104. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  105. package/dist/feature-libraries/flex-tree/context.d.ts +9 -0
  106. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  107. package/dist/feature-libraries/flex-tree/context.js +6 -0
  108. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  109. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  110. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  111. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  112. package/dist/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  113. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  114. package/dist/feature-libraries/flex-tree/lazyField.js +39 -8
  115. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  116. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  117. package/dist/feature-libraries/forest-summary/codec.js +7 -1
  118. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  119. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
  120. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  121. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  122. package/dist/feature-libraries/forest-summary/formatV1.d.ts +2 -3
  123. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  124. package/dist/feature-libraries/forest-summary/formatV1.js +1 -2
  125. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
  126. package/dist/feature-libraries/forest-summary/formatV2.d.ts +2 -3
  127. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  128. package/dist/feature-libraries/forest-summary/formatV2.js +1 -2
  129. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
  130. package/dist/feature-libraries/index.d.ts +3 -3
  131. package/dist/feature-libraries/index.d.ts.map +1 -1
  132. package/dist/feature-libraries/index.js +8 -4
  133. package/dist/feature-libraries/index.js.map +1 -1
  134. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  135. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  136. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  137. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +100 -24
  138. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  139. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -12
  140. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  141. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +85 -51
  142. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  143. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  144. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  145. package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -9
  146. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  147. package/dist/feature-libraries/modular-schema/index.d.ts +3 -3
  148. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  149. package/dist/feature-libraries/modular-schema/index.js +2 -3
  150. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  151. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +20 -24
  152. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  153. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +277 -159
  154. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  155. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  156. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  157. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  158. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  159. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  160. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js +296 -0
  161. package/dist/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  162. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -0
  163. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  164. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +8 -0
  165. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  166. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +56 -22
  167. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  168. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1390 -462
  169. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  170. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  171. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  172. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +1 -2
  173. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  174. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +3 -3
  175. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  176. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +74 -0
  177. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  178. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js +35 -0
  179. package/dist/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  180. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +49 -10
  181. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  182. package/dist/feature-libraries/modular-schema/modularChangeTypes.js +3 -3
  183. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  184. package/dist/feature-libraries/optional-field/optionalField.d.ts +13 -32
  185. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  186. package/dist/feature-libraries/optional-field/optionalField.js +257 -446
  187. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  188. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  189. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  190. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +31 -0
  191. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  192. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  193. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  194. package/dist/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  195. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  196. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  197. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js +57 -28
  198. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  199. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  200. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  201. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js +57 -0
  202. package/dist/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  203. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  204. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  205. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  206. package/dist/feature-libraries/optional-field/requiredField.d.ts +3 -2
  207. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  208. package/dist/feature-libraries/optional-field/requiredField.js +6 -1
  209. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -1
  210. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  211. package/dist/feature-libraries/schema-index/codec.js +6 -4
  212. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  213. package/dist/feature-libraries/sequence-field/compose.d.ts +6 -7
  214. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  215. package/dist/feature-libraries/sequence-field/compose.js +81 -259
  216. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  217. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  218. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  219. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  220. package/dist/feature-libraries/sequence-field/invert.d.ts +3 -3
  221. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  222. package/dist/feature-libraries/sequence-field/invert.js +65 -167
  223. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  224. package/dist/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  225. package/dist/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  226. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  227. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  228. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  229. package/dist/feature-libraries/sequence-field/moveEffectTable.js +7 -90
  230. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  231. package/dist/feature-libraries/sequence-field/rebase.d.ts +3 -3
  232. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  233. package/dist/feature-libraries/sequence-field/rebase.js +109 -116
  234. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  235. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  236. package/dist/feature-libraries/sequence-field/replaceRevisions.js +19 -32
  237. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  238. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  239. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +1 -2
  240. package/dist/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  241. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  242. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  243. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +388 -187
  244. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  245. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  246. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +20 -62
  247. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  248. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  249. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  250. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  251. package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  252. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  253. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  254. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +16 -111
  255. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  256. package/dist/feature-libraries/sequence-field/types.d.ts +37 -74
  257. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  258. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  259. package/dist/feature-libraries/sequence-field/utils.d.ts +20 -25
  260. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  261. package/dist/feature-libraries/sequence-field/utils.js +159 -320
  262. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  263. package/dist/index.d.ts +2 -2
  264. package/dist/index.d.ts.map +1 -1
  265. package/dist/index.js +4 -4
  266. package/dist/index.js.map +1 -1
  267. package/dist/legacy.d.ts +1 -0
  268. package/dist/packageVersion.d.ts +1 -1
  269. package/dist/packageVersion.d.ts.map +1 -1
  270. package/dist/packageVersion.js +1 -1
  271. package/dist/packageVersion.js.map +1 -1
  272. package/dist/shared-tree/independentView.d.ts.map +1 -1
  273. package/dist/shared-tree/independentView.js +1 -1
  274. package/dist/shared-tree/independentView.js.map +1 -1
  275. package/dist/shared-tree/index.d.ts +1 -1
  276. package/dist/shared-tree/index.d.ts.map +1 -1
  277. package/dist/shared-tree/index.js.map +1 -1
  278. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  279. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  280. package/dist/shared-tree/schematizeTree.js +2 -1
  281. package/dist/shared-tree/schematizeTree.js.map +1 -1
  282. package/dist/shared-tree/schematizingTreeView.d.ts +1 -5
  283. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  284. package/dist/shared-tree/schematizingTreeView.js +21 -35
  285. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  286. package/dist/shared-tree/sharedTree.d.ts +9 -3
  287. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  288. package/dist/shared-tree/sharedTree.js +4 -1
  289. package/dist/shared-tree/sharedTree.js.map +1 -1
  290. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -0
  291. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  292. package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -1
  293. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  294. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  295. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  296. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  297. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  298. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  299. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  300. package/dist/shared-tree/sharedTreeEditBuilder.js +14 -7
  301. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  302. package/dist/shared-tree/tree.d.ts +1 -1
  303. package/dist/shared-tree/tree.js.map +1 -1
  304. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  305. package/dist/shared-tree/treeAlpha.js.map +1 -1
  306. package/dist/shared-tree/treeCheckout.d.ts +13 -11
  307. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  308. package/dist/shared-tree/treeCheckout.js +58 -10
  309. package/dist/shared-tree/treeCheckout.js.map +1 -1
  310. package/dist/shared-tree-core/branch.d.ts +3 -2
  311. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  312. package/dist/shared-tree-core/branch.js +4 -3
  313. package/dist/shared-tree-core/branch.js.map +1 -1
  314. package/dist/shared-tree-core/editManager.d.ts +2 -2
  315. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  316. package/dist/shared-tree-core/editManager.js +9 -9
  317. package/dist/shared-tree-core/editManager.js.map +1 -1
  318. package/dist/shared-tree-core/editManagerCodecs.d.ts +4 -0
  319. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  320. package/dist/shared-tree-core/editManagerCodecs.js +10 -2
  321. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  322. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  323. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  324. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -2
  325. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  326. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  327. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  328. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  329. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  330. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  331. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  332. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  333. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  334. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  335. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  336. package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
  337. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  338. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  339. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  340. package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  341. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  342. package/dist/shared-tree-core/index.d.ts +2 -2
  343. package/dist/shared-tree-core/index.d.ts.map +1 -1
  344. package/dist/shared-tree-core/index.js +3 -1
  345. package/dist/shared-tree-core/index.js.map +1 -1
  346. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  347. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  348. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  349. package/dist/shared-tree-core/messageCodecs.d.ts +4 -0
  350. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  351. package/dist/shared-tree-core/messageCodecs.js +12 -4
  352. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  353. package/dist/shared-tree-core/messageFormat.d.ts +1 -0
  354. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  355. package/dist/shared-tree-core/messageFormat.js +6 -0
  356. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  357. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  358. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  359. package/dist/shared-tree-core/messageFormatV1ToV4.js +1 -0
  360. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  361. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  362. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  363. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  364. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  365. package/dist/simple-tree/api/index.d.ts +1 -1
  366. package/dist/simple-tree/api/index.d.ts.map +1 -1
  367. package/dist/simple-tree/api/index.js +2 -2
  368. package/dist/simple-tree/api/index.js.map +1 -1
  369. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  370. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  371. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +180 -99
  372. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  373. package/dist/simple-tree/api/tree.d.ts +1 -1
  374. package/dist/simple-tree/api/tree.js.map +1 -1
  375. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  376. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  377. package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
  378. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  379. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +17 -12
  380. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  381. package/dist/simple-tree/core/unhydratedFlexTree.js +88 -8
  382. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  383. package/dist/simple-tree/fieldSchema.d.ts +4 -4
  384. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  385. package/dist/simple-tree/fieldSchema.js.map +1 -1
  386. package/dist/simple-tree/index.d.ts +3 -3
  387. package/dist/simple-tree/index.d.ts.map +1 -1
  388. package/dist/simple-tree/index.js +3 -3
  389. package/dist/simple-tree/index.js.map +1 -1
  390. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  391. package/dist/simple-tree/node-kinds/array/arrayNode.js +9 -16
  392. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  393. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  394. package/dist/simple-tree/node-kinds/common.js +1 -1
  395. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  396. package/dist/simple-tree/node-kinds/map/mapNode.js +2 -2
  397. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  398. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  399. package/dist/simple-tree/node-kinds/object/objectNode.js +19 -19
  400. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  401. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  402. package/dist/simple-tree/node-kinds/record/recordNode.js +4 -2
  403. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  404. package/dist/simple-tree/prepareForInsertion.d.ts +54 -47
  405. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  406. package/dist/simple-tree/prepareForInsertion.js +183 -125
  407. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  408. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +8 -3
  409. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  410. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +59 -19
  411. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  412. package/dist/text/textDomainFormatted.d.ts +3 -3
  413. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  414. package/dist/text/textDomainFormatted.js +48 -32
  415. package/dist/text/textDomainFormatted.js.map +1 -1
  416. package/dist/treeFactory.d.ts.map +1 -1
  417. package/dist/treeFactory.js +12 -2
  418. package/dist/treeFactory.js.map +1 -1
  419. package/dist/util/bTreeUtils.d.ts.map +1 -1
  420. package/dist/util/bTreeUtils.js +6 -6
  421. package/dist/util/bTreeUtils.js.map +1 -1
  422. package/dist/util/index.d.ts +1 -1
  423. package/dist/util/index.d.ts.map +1 -1
  424. package/dist/util/index.js +2 -1
  425. package/dist/util/index.js.map +1 -1
  426. package/dist/util/rangeMap.d.ts +23 -11
  427. package/dist/util/rangeMap.d.ts.map +1 -1
  428. package/dist/util/rangeMap.js +42 -10
  429. package/dist/util/rangeMap.js.map +1 -1
  430. package/lib/alpha.d.ts +3 -3
  431. package/lib/beta.d.ts +1 -0
  432. package/lib/codec/codec.d.ts +3 -39
  433. package/lib/codec/codec.d.ts.map +1 -1
  434. package/lib/codec/codec.js +4 -47
  435. package/lib/codec/codec.js.map +1 -1
  436. package/lib/codec/index.d.ts +1 -1
  437. package/lib/codec/index.d.ts.map +1 -1
  438. package/lib/codec/index.js +1 -1
  439. package/lib/codec/index.js.map +1 -1
  440. package/lib/codec/versioned/codec.d.ts +20 -7
  441. package/lib/codec/versioned/codec.d.ts.map +1 -1
  442. package/lib/codec/versioned/codec.js +59 -33
  443. package/lib/codec/versioned/codec.js.map +1 -1
  444. package/lib/core/change-family/changeFamily.d.ts +4 -1
  445. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  446. package/lib/core/change-family/changeFamily.js.map +1 -1
  447. package/lib/core/change-family/index.d.ts +1 -1
  448. package/lib/core/change-family/index.d.ts.map +1 -1
  449. package/lib/core/change-family/index.js.map +1 -1
  450. package/lib/core/index.d.ts +3 -3
  451. package/lib/core/index.d.ts.map +1 -1
  452. package/lib/core/index.js +2 -2
  453. package/lib/core/index.js.map +1 -1
  454. package/lib/core/rebase/changeRebaser.d.ts +6 -1
  455. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  456. package/lib/core/rebase/changeRebaser.js.map +1 -1
  457. package/lib/core/rebase/index.d.ts +1 -1
  458. package/lib/core/rebase/index.d.ts.map +1 -1
  459. package/lib/core/rebase/index.js +1 -1
  460. package/lib/core/rebase/index.js.map +1 -1
  461. package/lib/core/rebase/types.d.ts +1 -0
  462. package/lib/core/rebase/types.d.ts.map +1 -1
  463. package/lib/core/rebase/types.js +3 -0
  464. package/lib/core/rebase/types.js.map +1 -1
  465. package/lib/core/rebase/utils.d.ts.map +1 -1
  466. package/lib/core/rebase/utils.js +25 -7
  467. package/lib/core/rebase/utils.js.map +1 -1
  468. package/lib/core/tree/delta.d.ts +5 -0
  469. package/lib/core/tree/delta.d.ts.map +1 -1
  470. package/lib/core/tree/delta.js.map +1 -1
  471. package/lib/core/tree/detachedFieldIndex.d.ts +13 -1
  472. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  473. package/lib/core/tree/detachedFieldIndex.js +15 -2
  474. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  475. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  476. package/lib/core/tree/detachedFieldIndexCodecs.js +6 -4
  477. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  478. package/lib/core/tree/detachedFieldIndexTypes.d.ts +4 -0
  479. package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  480. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  481. package/lib/core/tree/index.d.ts +2 -2
  482. package/lib/core/tree/index.d.ts.map +1 -1
  483. package/lib/core/tree/index.js +1 -1
  484. package/lib/core/tree/index.js.map +1 -1
  485. package/lib/core/tree/pathTree.d.ts +11 -3
  486. package/lib/core/tree/pathTree.d.ts.map +1 -1
  487. package/lib/core/tree/pathTree.js +12 -1
  488. package/lib/core/tree/pathTree.js.map +1 -1
  489. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  490. package/lib/core/tree/visitDelta.js +17 -13
  491. package/lib/core/tree/visitDelta.js.map +1 -1
  492. package/lib/extensibleUnionNode.d.ts +97 -0
  493. package/lib/extensibleUnionNode.d.ts.map +1 -0
  494. package/lib/{extensibleSchemaUnion.js → extensibleUnionNode.js} +28 -18
  495. package/lib/extensibleUnionNode.js.map +1 -0
  496. package/lib/feature-libraries/changeAtomIdBTree.d.ts +3 -2
  497. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  498. package/lib/feature-libraries/changeAtomIdBTree.js +15 -3
  499. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  500. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  501. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  502. package/lib/feature-libraries/chunked-forest/codec/codecs.js +5 -5
  503. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  504. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +92 -44
  505. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  506. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +217 -69
  507. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  508. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  509. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +12 -2
  510. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  511. package/lib/feature-libraries/default-schema/index.d.ts +2 -1
  512. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  513. package/lib/feature-libraries/default-schema/index.js +2 -1
  514. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  515. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts +40 -0
  516. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.d.ts.map +1 -0
  517. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js +149 -0
  518. package/lib/feature-libraries/default-schema/locationBasedEditBuilder.js.map +1 -0
  519. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +7 -6
  520. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
  521. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +15 -0
  522. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
  523. package/lib/feature-libraries/deltaUtils.d.ts +1 -0
  524. package/lib/feature-libraries/deltaUtils.d.ts.map +1 -1
  525. package/lib/feature-libraries/deltaUtils.js +5 -1
  526. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  527. package/lib/feature-libraries/flex-tree/context.d.ts +9 -0
  528. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  529. package/lib/feature-libraries/flex-tree/context.js +6 -0
  530. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  531. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +6 -6
  532. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  533. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  534. package/lib/feature-libraries/flex-tree/lazyField.d.ts +8 -7
  535. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  536. package/lib/feature-libraries/flex-tree/lazyField.js +40 -9
  537. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  538. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  539. package/lib/feature-libraries/forest-summary/codec.js +8 -2
  540. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  541. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +3 -3
  542. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  543. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  544. package/lib/feature-libraries/forest-summary/formatV1.d.ts +2 -3
  545. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  546. package/lib/feature-libraries/forest-summary/formatV1.js +1 -2
  547. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
  548. package/lib/feature-libraries/forest-summary/formatV2.d.ts +2 -3
  549. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  550. package/lib/feature-libraries/forest-summary/formatV2.js +1 -2
  551. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
  552. package/lib/feature-libraries/index.d.ts +3 -3
  553. package/lib/feature-libraries/index.d.ts.map +1 -1
  554. package/lib/feature-libraries/index.js +3 -3
  555. package/lib/feature-libraries/index.js.map +1 -1
  556. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  557. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  558. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  559. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +100 -24
  560. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  561. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +7 -10
  562. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  563. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +85 -51
  564. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  565. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  566. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  567. package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -9
  568. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  569. package/lib/feature-libraries/modular-schema/index.d.ts +3 -3
  570. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  571. package/lib/feature-libraries/modular-schema/index.js +1 -1
  572. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  573. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +20 -24
  574. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  575. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +268 -145
  576. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  577. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  578. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  579. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  580. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts +15 -0
  581. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.d.ts.map +1 -0
  582. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js +292 -0
  583. package/lib/feature-libraries/modular-schema/modularChangeCodecV3.js.map +1 -0
  584. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +1 -0
  585. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  586. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +8 -0
  587. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  588. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +56 -22
  589. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  590. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1387 -468
  591. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  592. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  593. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  594. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +1 -2
  595. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  596. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
  597. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  598. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts +74 -0
  599. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.d.ts.map +1 -0
  600. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js +32 -0
  601. package/lib/feature-libraries/modular-schema/modularChangeFormatV3.js.map +1 -0
  602. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +49 -10
  603. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  604. package/lib/feature-libraries/modular-schema/modularChangeTypes.js +1 -1
  605. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  606. package/lib/feature-libraries/optional-field/optionalField.d.ts +13 -32
  607. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  608. package/lib/feature-libraries/optional-field/optionalField.js +254 -442
  609. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  610. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts +23 -0
  611. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.d.ts.map +1 -0
  612. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js +27 -0
  613. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV3.js.map +1 -0
  614. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts +31 -31
  615. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.d.ts.map +1 -1
  616. package/lib/feature-libraries/optional-field/optionalFieldChangeTypes.js.map +1 -1
  617. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +1 -1
  618. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  619. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +55 -26
  620. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  621. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts +12 -0
  622. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.d.ts.map +1 -0
  623. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js +53 -0
  624. package/lib/feature-libraries/optional-field/optionalFieldCodecV3.js.map +1 -0
  625. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  626. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +5 -1
  627. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  628. package/lib/feature-libraries/optional-field/requiredField.d.ts +3 -2
  629. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -1
  630. package/lib/feature-libraries/optional-field/requiredField.js +5 -1
  631. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -1
  632. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  633. package/lib/feature-libraries/schema-index/codec.js +6 -4
  634. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  635. package/lib/feature-libraries/sequence-field/compose.d.ts +6 -7
  636. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  637. package/lib/feature-libraries/sequence-field/compose.js +83 -261
  638. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  639. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +14 -10
  640. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  641. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  642. package/lib/feature-libraries/sequence-field/invert.d.ts +3 -3
  643. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  644. package/lib/feature-libraries/sequence-field/invert.js +67 -169
  645. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  646. package/lib/feature-libraries/sequence-field/markQueue.d.ts +2 -2
  647. package/lib/feature-libraries/sequence-field/markQueue.d.ts.map +1 -1
  648. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  649. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +4 -56
  650. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  651. package/lib/feature-libraries/sequence-field/moveEffectTable.js +6 -84
  652. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  653. package/lib/feature-libraries/sequence-field/rebase.d.ts +3 -3
  654. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  655. package/lib/feature-libraries/sequence-field/rebase.js +111 -118
  656. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  657. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  658. package/lib/feature-libraries/sequence-field/replaceRevisions.js +19 -32
  659. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  660. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.d.ts.map +1 -1
  661. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js +2 -3
  662. package/lib/feature-libraries/sequence-field/sequenceFieldChangeHandler.js.map +1 -1
  663. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +22 -4
  664. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  665. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +379 -182
  666. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  667. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  668. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +21 -63
  669. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  670. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +2 -2
  671. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
  672. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -13
  673. package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
  674. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts +3 -2
  675. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  676. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +16 -111
  677. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  678. package/lib/feature-libraries/sequence-field/types.d.ts +37 -74
  679. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  680. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  681. package/lib/feature-libraries/sequence-field/utils.d.ts +20 -25
  682. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  683. package/lib/feature-libraries/sequence-field/utils.js +155 -313
  684. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  685. package/lib/index.d.ts +2 -2
  686. package/lib/index.d.ts.map +1 -1
  687. package/lib/index.js +2 -2
  688. package/lib/index.js.map +1 -1
  689. package/lib/legacy.d.ts +1 -0
  690. package/lib/packageVersion.d.ts +1 -1
  691. package/lib/packageVersion.d.ts.map +1 -1
  692. package/lib/packageVersion.js +1 -1
  693. package/lib/packageVersion.js.map +1 -1
  694. package/lib/shared-tree/independentView.d.ts.map +1 -1
  695. package/lib/shared-tree/independentView.js +1 -1
  696. package/lib/shared-tree/independentView.js.map +1 -1
  697. package/lib/shared-tree/index.d.ts +1 -1
  698. package/lib/shared-tree/index.d.ts.map +1 -1
  699. package/lib/shared-tree/index.js.map +1 -1
  700. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  701. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  702. package/lib/shared-tree/schematizeTree.js +3 -2
  703. package/lib/shared-tree/schematizeTree.js.map +1 -1
  704. package/lib/shared-tree/schematizingTreeView.d.ts +1 -5
  705. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  706. package/lib/shared-tree/schematizingTreeView.js +24 -38
  707. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  708. package/lib/shared-tree/sharedTree.d.ts +9 -3
  709. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  710. package/lib/shared-tree/sharedTree.js +4 -1
  711. package/lib/shared-tree/sharedTree.js.map +1 -1
  712. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -0
  713. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  714. package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -1
  715. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  716. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +4 -4
  717. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  718. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  719. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  720. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +16 -6
  721. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  722. package/lib/shared-tree/sharedTreeEditBuilder.js +12 -6
  723. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  724. package/lib/shared-tree/tree.d.ts +1 -1
  725. package/lib/shared-tree/tree.js.map +1 -1
  726. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  727. package/lib/shared-tree/treeAlpha.js.map +1 -1
  728. package/lib/shared-tree/treeCheckout.d.ts +13 -11
  729. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  730. package/lib/shared-tree/treeCheckout.js +61 -13
  731. package/lib/shared-tree/treeCheckout.js.map +1 -1
  732. package/lib/shared-tree-core/branch.d.ts +3 -2
  733. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  734. package/lib/shared-tree-core/branch.js +4 -3
  735. package/lib/shared-tree-core/branch.js.map +1 -1
  736. package/lib/shared-tree-core/editManager.d.ts +2 -2
  737. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  738. package/lib/shared-tree-core/editManager.js +9 -9
  739. package/lib/shared-tree-core/editManager.js.map +1 -1
  740. package/lib/shared-tree-core/editManagerCodecs.d.ts +4 -0
  741. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  742. package/lib/shared-tree-core/editManagerCodecs.js +8 -1
  743. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  744. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -3
  745. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  746. package/lib/shared-tree-core/editManagerCodecsCommons.js +2 -2
  747. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  748. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +2 -2
  749. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  750. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +2 -2
  751. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  752. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  753. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  754. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +2 -2
  755. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  756. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
  757. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  758. package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
  759. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  760. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  761. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  762. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
  763. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  764. package/lib/shared-tree-core/index.d.ts +2 -2
  765. package/lib/shared-tree-core/index.d.ts.map +1 -1
  766. package/lib/shared-tree-core/index.js +2 -2
  767. package/lib/shared-tree-core/index.js.map +1 -1
  768. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  769. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  770. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  771. package/lib/shared-tree-core/messageCodecs.d.ts +4 -0
  772. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  773. package/lib/shared-tree-core/messageCodecs.js +10 -3
  774. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  775. package/lib/shared-tree-core/messageFormat.d.ts +1 -0
  776. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  777. package/lib/shared-tree-core/messageFormat.js +6 -0
  778. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  779. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +2 -2
  780. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  781. package/lib/shared-tree-core/messageFormatV1ToV4.js +1 -0
  782. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  783. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  784. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  785. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  786. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  787. package/lib/simple-tree/api/index.d.ts +1 -1
  788. package/lib/simple-tree/api/index.d.ts.map +1 -1
  789. package/lib/simple-tree/api/index.js +1 -1
  790. package/lib/simple-tree/api/index.js.map +1 -1
  791. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +148 -29
  792. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  793. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +179 -98
  794. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  795. package/lib/simple-tree/api/tree.d.ts +1 -1
  796. package/lib/simple-tree/api/tree.js.map +1 -1
  797. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  798. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  799. package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
  800. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  801. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +17 -12
  802. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  803. package/lib/simple-tree/core/unhydratedFlexTree.js +87 -8
  804. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  805. package/lib/simple-tree/fieldSchema.d.ts +4 -4
  806. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  807. package/lib/simple-tree/fieldSchema.js.map +1 -1
  808. package/lib/simple-tree/index.d.ts +3 -3
  809. package/lib/simple-tree/index.d.ts.map +1 -1
  810. package/lib/simple-tree/index.js +2 -2
  811. package/lib/simple-tree/index.js.map +1 -1
  812. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  813. package/lib/simple-tree/node-kinds/array/arrayNode.js +11 -18
  814. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  815. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  816. package/lib/simple-tree/node-kinds/common.js +2 -2
  817. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  818. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  819. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  820. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  821. package/lib/simple-tree/node-kinds/object/objectNode.js +20 -20
  822. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  823. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  824. package/lib/simple-tree/node-kinds/record/recordNode.js +4 -2
  825. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  826. package/lib/simple-tree/prepareForInsertion.d.ts +54 -47
  827. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  828. package/lib/simple-tree/prepareForInsertion.js +184 -125
  829. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  830. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +8 -3
  831. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  832. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +56 -17
  833. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  834. package/lib/text/textDomainFormatted.d.ts +3 -3
  835. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  836. package/lib/text/textDomainFormatted.js +30 -14
  837. package/lib/text/textDomainFormatted.js.map +1 -1
  838. package/lib/treeFactory.d.ts.map +1 -1
  839. package/lib/treeFactory.js +13 -3
  840. package/lib/treeFactory.js.map +1 -1
  841. package/lib/util/bTreeUtils.d.ts.map +1 -1
  842. package/lib/util/bTreeUtils.js +6 -6
  843. package/lib/util/bTreeUtils.js.map +1 -1
  844. package/lib/util/index.d.ts +1 -1
  845. package/lib/util/index.d.ts.map +1 -1
  846. package/lib/util/index.js +1 -1
  847. package/lib/util/index.js.map +1 -1
  848. package/lib/util/rangeMap.d.ts +23 -11
  849. package/lib/util/rangeMap.d.ts.map +1 -1
  850. package/lib/util/rangeMap.js +40 -9
  851. package/lib/util/rangeMap.js.map +1 -1
  852. package/package.json +23 -23
  853. package/src/codec/codec.ts +10 -112
  854. package/src/codec/index.ts +0 -3
  855. package/src/codec/versioned/codec.ts +119 -83
  856. package/src/core/change-family/changeFamily.ts +5 -0
  857. package/src/core/change-family/index.ts +1 -0
  858. package/src/core/index.ts +4 -1
  859. package/src/core/rebase/changeRebaser.ts +6 -1
  860. package/src/core/rebase/index.ts +1 -0
  861. package/src/core/rebase/types.ts +4 -0
  862. package/src/core/rebase/utils.ts +31 -7
  863. package/src/core/tree/delta.ts +6 -0
  864. package/src/core/tree/detachedFieldIndex.ts +29 -1
  865. package/src/core/tree/detachedFieldIndexCodecs.ts +6 -4
  866. package/src/core/tree/detachedFieldIndexTypes.ts +5 -0
  867. package/src/core/tree/index.ts +13 -12
  868. package/src/core/tree/pathTree.ts +16 -4
  869. package/src/core/tree/visitDelta.ts +31 -11
  870. package/src/{extensibleSchemaUnion.ts → extensibleUnionNode.ts} +61 -19
  871. package/src/feature-libraries/changeAtomIdBTree.ts +28 -3
  872. package/src/feature-libraries/chunked-forest/codec/codecs.ts +5 -11
  873. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +369 -127
  874. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +13 -4
  875. package/src/feature-libraries/default-schema/index.ts +16 -5
  876. package/src/feature-libraries/default-schema/locationBasedEditBuilder.ts +231 -0
  877. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +35 -9
  878. package/src/feature-libraries/deltaUtils.ts +6 -1
  879. package/src/feature-libraries/flex-tree/context.ts +17 -0
  880. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +7 -8
  881. package/src/feature-libraries/flex-tree/lazyField.ts +65 -24
  882. package/src/feature-libraries/forest-summary/codec.ts +8 -7
  883. package/src/feature-libraries/forest-summary/formatCommon.ts +5 -3
  884. package/src/feature-libraries/forest-summary/formatV1.ts +1 -3
  885. package/src/feature-libraries/forest-summary/formatV2.ts +1 -3
  886. package/src/feature-libraries/index.ts +22 -9
  887. package/src/feature-libraries/mitigatedChangeFamily.ts +3 -1
  888. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +144 -47
  889. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +113 -58
  890. package/src/feature-libraries/modular-schema/genericFieldKind.ts +7 -18
  891. package/src/feature-libraries/modular-schema/index.ts +16 -16
  892. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +626 -352
  893. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +1 -0
  894. package/src/feature-libraries/modular-schema/modularChangeCodecV3.ts +649 -0
  895. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +14 -0
  896. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +2694 -748
  897. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +1 -0
  898. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +1 -1
  899. package/src/feature-libraries/modular-schema/modularChangeFormatV3.ts +67 -0
  900. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +62 -10
  901. package/src/feature-libraries/optional-field/optionalField.ts +359 -568
  902. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV3.ts +45 -0
  903. package/src/feature-libraries/optional-field/optionalFieldChangeTypes.ts +31 -35
  904. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +89 -35
  905. package/src/feature-libraries/optional-field/optionalFieldCodecV3.ts +94 -0
  906. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +5 -1
  907. package/src/feature-libraries/optional-field/requiredField.ts +15 -2
  908. package/src/feature-libraries/schema-index/codec.ts +6 -4
  909. package/src/feature-libraries/sequence-field/compose.ts +137 -522
  910. package/src/feature-libraries/sequence-field/helperTypes.ts +34 -19
  911. package/src/feature-libraries/sequence-field/invert.ts +102 -228
  912. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  913. package/src/feature-libraries/sequence-field/moveEffectTable.ts +8 -195
  914. package/src/feature-libraries/sequence-field/rebase.ts +171 -207
  915. package/src/feature-libraries/sequence-field/replaceRevisions.ts +26 -52
  916. package/src/feature-libraries/sequence-field/sequenceFieldChangeHandler.ts +8 -3
  917. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +677 -229
  918. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +56 -70
  919. package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +28 -30
  920. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +21 -131
  921. package/src/feature-libraries/sequence-field/types.ts +40 -79
  922. package/src/feature-libraries/sequence-field/utils.ts +211 -370
  923. package/src/index.ts +3 -3
  924. package/src/packageVersion.ts +1 -1
  925. package/src/shared-tree/independentView.ts +12 -6
  926. package/src/shared-tree/index.ts +3 -2
  927. package/src/shared-tree/schematizeTree.ts +21 -8
  928. package/src/shared-tree/schematizingTreeView.ts +38 -68
  929. package/src/shared-tree/sharedTree.ts +30 -15
  930. package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -2
  931. package/src/shared-tree/sharedTreeChangeFamily.ts +7 -4
  932. package/src/shared-tree/sharedTreeEditBuilder.ts +43 -8
  933. package/src/shared-tree/tree.ts +1 -1
  934. package/src/shared-tree/treeAlpha.ts +1 -1
  935. package/src/shared-tree/treeCheckout.ts +95 -21
  936. package/src/shared-tree-core/branch.ts +8 -2
  937. package/src/shared-tree-core/editManager.ts +16 -2
  938. package/src/shared-tree-core/editManagerCodecs.ts +11 -1
  939. package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -7
  940. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -10
  941. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -10
  942. package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
  943. package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
  944. package/src/shared-tree-core/index.ts +2 -0
  945. package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
  946. package/src/shared-tree-core/messageCodecs.ts +13 -7
  947. package/src/shared-tree-core/messageFormat.ts +6 -0
  948. package/src/shared-tree-core/messageFormatV1ToV4.ts +3 -1
  949. package/src/shared-tree-core/sharedTreeCore.ts +4 -1
  950. package/src/simple-tree/api/index.ts +2 -2
  951. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +344 -142
  952. package/src/simple-tree/api/tree.ts +1 -1
  953. package/src/simple-tree/api/treeBeta.ts +1 -1
  954. package/src/simple-tree/core/allowedTypes.ts +1 -1
  955. package/src/simple-tree/core/unhydratedFlexTree.ts +124 -35
  956. package/src/simple-tree/fieldSchema.ts +6 -4
  957. package/src/simple-tree/index.ts +4 -3
  958. package/src/simple-tree/node-kinds/array/arrayNode.ts +20 -24
  959. package/src/simple-tree/node-kinds/common.ts +2 -5
  960. package/src/simple-tree/node-kinds/map/mapNode.ts +4 -4
  961. package/src/simple-tree/node-kinds/object/objectNode.ts +26 -26
  962. package/src/simple-tree/node-kinds/record/recordNode.ts +10 -9
  963. package/src/simple-tree/prepareForInsertion.ts +342 -200
  964. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +83 -22
  965. package/src/text/textDomainFormatted.ts +37 -17
  966. package/src/treeFactory.ts +16 -4
  967. package/src/util/bTreeUtils.ts +10 -6
  968. package/src/util/index.ts +3 -0
  969. package/src/util/rangeMap.ts +67 -22
  970. package/api-extractor-lint.json +0 -4
  971. package/dist/extensibleSchemaUnion.d.ts +0 -72
  972. package/dist/extensibleSchemaUnion.d.ts.map +0 -1
  973. package/dist/extensibleSchemaUnion.js.map +0 -1
  974. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  975. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  976. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -50
  977. package/dist/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  978. package/docs/main/sequence-field/move-composition.md +0 -46
  979. package/lib/extensibleSchemaUnion.d.ts +0 -72
  980. package/lib/extensibleSchemaUnion.d.ts.map +0 -1
  981. package/lib/extensibleSchemaUnion.js.map +0 -1
  982. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts +0 -9
  983. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.d.ts.map +0 -1
  984. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js +0 -46
  985. package/lib/feature-libraries/sequence-field/relevantRemovedRoots.js.map +0 -1
  986. package/src/feature-libraries/sequence-field/relevantRemovedRoots.ts +0 -57
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+CASwB;AANvB,yGAAA,SAAS,OAAA;AAGT,0GAAA,UAAU,OAAA;AAIX,yCAgBqB;AAdpB,+GAAA,kBAAkB,OAAA;AAClB,oHAAA,uBAAuB,OAAA;AACvB,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,wGAAA,WAAW,OAAA;AACX,iHAAA,oBAAoB,OAAA;AACpB,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAGlB,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AAcT,2CAAoF;AAAtC,6GAAA,eAAe,OAAA;AAC7D,6CAmBuB;AAlBtB,wGAAA,SAAS,OAAA;AACT,0GAAA,WAAW,OAAA;AACX,uGAAA,QAAQ,OAAA;AAWR,6GAAA,cAAc,OAAA;AACd,kHAAA,mBAAmB,OAAA;AACnB,+GAAA,oBAAoB,OAAoB;AACxC,6HAAA,8BAA8B,OAAA;AAG/B,yDAS6B;AAN5B,6HAAA,wBAAwB,OAAA;AACxB,oHAAA,eAAe,OAAA;AAEf,wHAAA,mBAAmB,OAAA;AAEnB,wHAAA,mBAAmB,OAAA;AAEpB,2EAAmE;AAA1D,iIAAA,mBAAmB,OAAA;AAC5B,uCAeoB;AAdnB,oGAAA,QAAQ,OAAA;AAQR,8GAAA,kBAAkB,OAAA;AAClB,8GAAA,kBAAkB,OAAA;AAClB,wGAAA,YAAY,OAAA;AAEZ,qGAAA,SAAS,OAAA;AACT,gHAAA,oBAAoB,OAAA;AAErB,iDAAgE;AAApC,2GAAA,UAAU,OAAA;AACtC,qDAO2B;AAL1B,gHAAA,aAAa,OAAA;AACb,6GAAA,UAAU,OAAA;AACV,yHAAA,sBAAsB,OAAA;AACtB,kHAAA,eAAe,OAAA;AACf,yHAAA,sBAAsB,OAAA;AAGvB,iDAA4D;AAAnD,2GAAA,UAAU,OAAA;AAAE,8GAAA,aAAa,OAAA;AAElC,+CAKwB;AAJvB,0HAAA,0BAA0B,OAAA;AAC1B,kHAAA,kBAAkB,OAAA;AAClB,8GAAA,cAAc,OAAA;AACd,0GAAA,UAAU,OAAA;AAGX,uCAMoB;AAJnB,qGAAA,SAAS,OAAA;AACT,uGAAA,WAAW,OAAA;AACX,uGAAA,WAAW,OAAA;AAIZ,iEAIiC;AAHhC,2HAAA,kBAAkB,OAAA;AAKnB,6EAA+E;AAAtE,6IAAA,8BAA8B,OAAA;AACvC,yFAAsF;AAA7E,oJAAA,+BAA+B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\tAnchorSet,\n\ttype AnchorSlot,\n\ttype AnchorNode,\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorSetRootEvents,\n} from \"./anchorSet.js\";\nexport {\n\ttype ITreeCursor,\n\tCursorLocationType,\n\tcastCursorToSynchronous,\n\tmapCursorField,\n\tmapCursorFields,\n\tforEachNode,\n\tforEachNodeInSubtree,\n\tforEachField,\n\titerateCursorField,\n\ttype ITreeCursorSynchronous,\n\ttype PathRootPrefix,\n\tinCursorField,\n\tinCursorNode,\n\tCursorMarker,\n\tisCursor,\n} from \"./cursor.js\";\nexport type {\n\tProtoNodes,\n\tRoot as DeltaRoot,\n\tMark as DeltaMark,\n\tDetachedNodeId as DeltaDetachedNodeId,\n\tFieldMap as DeltaFieldMap,\n\tDetachedNodeChanges as DeltaDetachedNodeChanges,\n\tDetachedNodeBuild as DeltaDetachedNodeBuild,\n\tDetachedNodeDestruction as DeltaDetachedNodeDestruction,\n\tDetachedNodeRename as DeltaDetachedNodeRename,\n\tFieldChanges as DeltaFieldChanges,\n} from \"./delta.js\";\nexport { type MapTree, type ExclusiveMapTree, deepCopyMapTree } from \"./mapTree.js\";\nexport {\n\tclonePath,\n\ttopDownPath,\n\tgetDepth,\n\ttype UpPath,\n\ttype NormalizedUpPath,\n\ttype INormalizedUpPath,\n\ttype NormalizedFieldUpPath,\n\ttype FieldUpPath,\n\ttype Range,\n\ttype RangeUpPath,\n\ttype PlaceUpPath,\n\ttype PlaceIndex,\n\ttype NodeIndex,\n\tcompareUpPaths,\n\tcompareFieldUpPaths,\n\tisDetachedUpPathRoot as isDetachedUpPath,\n\tgetDetachedFieldContainingPath,\n\ttype UpPathDefault,\n} from \"./pathTree.js\";\nexport {\n\ttype FieldMapObject,\n\ttype GenericFieldsNode,\n\tgenericTreeDeleteIfEmpty,\n\tgenericTreeKeys,\n\ttype GenericTreeNode,\n\tgetGenericTreeField,\n\ttype JsonableTree,\n\tsetGenericTreeField,\n} from \"./treeTextFormat.js\";\nexport { EncodedJsonableTree } from \"./persistedTreeTextFormat.js\";\nexport {\n\tEmptyKey,\n\ttype TreeType,\n\ttype ChildLocation,\n\ttype DetachedField,\n\ttype ChildCollection,\n\ttype RootField,\n\ttype Value,\n\ttype TreeValue,\n\tdetachedFieldAsKey,\n\tkeyAsDetachedField,\n\trootFieldKey,\n\ttype NodeData,\n\trootField,\n\taboveRootPlaceholder,\n} from \"./types.js\";\nexport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nexport {\n\ttype AnnouncedVisitor,\n\tannounceDelta,\n\tapplyDelta,\n\tcreateAnnouncedVisitor,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n} from \"./visitorUtils.js\";\n\nexport { SparseNode, getDescendant } from \"./sparseTree.js\";\n\nexport {\n\tdeltaForRootInitialization,\n\tmakeDetachedNodeId,\n\toffsetDetachId,\n\temptyDelta,\n} from \"./deltaUtil.js\";\n\nexport {\n\ttype TreeChunk,\n\tdummyRoot,\n\tcursorChunk,\n\ttryGetChunk,\n\ttype ChunkedCursor,\n} from \"./chunk.js\";\n\nexport {\n\tDetachedFieldIndex,\n\ttype DetachedFieldIndexCheckpoint,\n\ttype ReadOnlyDetachedFieldIndex,\n} from \"./detachedFieldIndex.js\";\n\nexport { detachedFieldIndexCodecBuilder } from \"./detachedFieldIndexCodecs.js\";\nexport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\nexport { type FormatV1 } from \"./detachedFieldIndexFormatV1.js\";\n\nexport { type ForestRootId } from \"./detachedFieldIndexTypes.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,+CASwB;AANvB,yGAAA,SAAS,OAAA;AAGT,0GAAA,UAAU,OAAA;AAIX,yCAgBqB;AAdpB,+GAAA,kBAAkB,OAAA;AAClB,oHAAA,uBAAuB,OAAA;AACvB,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,wGAAA,WAAW,OAAA;AACX,iHAAA,oBAAoB,OAAA;AACpB,yGAAA,YAAY,OAAA;AAC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AAA,kBAAkB,OAAA;AAKnB,6EAA+E;AAAtE,6IAAA,8BAA8B,OAAA;AACvC,yFAAsF;AAA7E,oJAAA,+BAA+B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype Anchor,\n\ttype AnchorLocator,\n\tAnchorSet,\n\ttype AnchorSlot,\n\ttype AnchorNode,\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorSetRootEvents,\n} from \"./anchorSet.js\";\nexport {\n\ttype ITreeCursor,\n\tCursorLocationType,\n\tcastCursorToSynchronous,\n\tmapCursorField,\n\tmapCursorFields,\n\tforEachNode,\n\tforEachNodeInSubtree,\n\tforEachField,\n\titerateCursorField,\n\ttype ITreeCursorSynchronous,\n\ttype PathRootPrefix,\n\tinCursorField,\n\tinCursorNode,\n\tCursorMarker,\n\tisCursor,\n} from \"./cursor.js\";\nexport {\n\ttype ProtoNodes,\n\ttype Root as DeltaRoot,\n\ttype Mark as DeltaMark,\n\ttype DetachedNodeId as DeltaDetachedNodeId,\n\ttype FieldMap as DeltaFieldMap,\n\ttype DetachedNodeChanges as DeltaDetachedNodeChanges,\n\ttype DetachedNodeBuild as DeltaDetachedNodeBuild,\n\ttype DetachedNodeDestruction as DeltaDetachedNodeDestruction,\n\ttype DetachedNodeRename as DeltaDetachedNodeRename,\n\ttype FieldChanges as DeltaFieldChanges,\n} from \"./delta.js\";\nexport { type MapTree, type ExclusiveMapTree, deepCopyMapTree } from \"./mapTree.js\";\nexport {\n\tclonePath,\n\ttopDownPath,\n\tgetDepth,\n\ttype UpPath,\n\ttype NormalizedUpPath,\n\ttype INormalizedUpPath,\n\ttype NormalizedFieldUpPath,\n\ttype FieldUpPath,\n\ttype Range,\n\ttype RangeUpPath,\n\ttype PlaceUpPath,\n\ttype PlaceIndex,\n\ttype NodeIndex,\n\tcompareUpPaths,\n\tcompareFieldUpPaths,\n\tisDetachedUpPathRoot,\n\tgetDetachedFieldContainingPath,\n\tgetDetachedFieldContainingFieldPath,\n\ttype UpPathDefault,\n} from \"./pathTree.js\";\nexport {\n\ttype FieldMapObject,\n\ttype GenericFieldsNode,\n\tgenericTreeDeleteIfEmpty,\n\tgenericTreeKeys,\n\ttype GenericTreeNode,\n\tgetGenericTreeField,\n\ttype JsonableTree,\n\tsetGenericTreeField,\n} from \"./treeTextFormat.js\";\nexport { EncodedJsonableTree } from \"./persistedTreeTextFormat.js\";\nexport {\n\tEmptyKey,\n\ttype TreeType,\n\ttype ChildLocation,\n\ttype DetachedField,\n\ttype ChildCollection,\n\ttype RootField,\n\ttype Value,\n\ttype TreeValue,\n\tdetachedFieldAsKey,\n\tkeyAsDetachedField,\n\trootFieldKey,\n\ttype NodeData,\n\trootField,\n\taboveRootPlaceholder,\n} from \"./types.js\";\nexport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nexport {\n\ttype AnnouncedVisitor,\n\tannounceDelta,\n\tapplyDelta,\n\tcreateAnnouncedVisitor,\n\tcombineVisitors,\n\tmakeDetachedFieldIndex,\n} from \"./visitorUtils.js\";\n\nexport { SparseNode, getDescendant } from \"./sparseTree.js\";\n\nexport {\n\tdeltaForRootInitialization,\n\tmakeDetachedNodeId,\n\toffsetDetachId,\n\temptyDelta,\n} from \"./deltaUtil.js\";\n\nexport {\n\ttype TreeChunk,\n\tdummyRoot,\n\tcursorChunk,\n\ttryGetChunk,\n\ttype ChunkedCursor,\n} from \"./chunk.js\";\n\nexport {\n\tDetachedFieldIndex,\n\ttype DetachedFieldIndexCheckpoint,\n\ttype ReadOnlyDetachedFieldIndex,\n} from \"./detachedFieldIndex.js\";\n\nexport { detachedFieldIndexCodecBuilder } from \"./detachedFieldIndexCodecs.js\";\nexport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\nexport { type FormatV1 } from \"./detachedFieldIndexFormatV1.js\";\n\nexport { type ForestRootId } from \"./detachedFieldIndexTypes.js\";\n"]}
@@ -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,KAA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AACH,MAAM,WAAW,WAAW,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,WAAW,CAAC,OAAO,CAAC;IACzF;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAaxE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,EAAE,CASzE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAYpF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAK3E;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAU1E;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAKpF"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getDetachedFieldContainingPath = exports.compareFieldUpPaths = exports.compareUpPaths = exports.topDownPath = exports.clonePath = exports.getDepth = exports.isDetachedUpPathRoot = void 0;
7
+ exports.getDetachedFieldContainingFieldPath = exports.getDetachedFieldContainingPath = exports.compareFieldUpPaths = exports.compareUpPaths = exports.topDownPath = exports.clonePath = exports.getDepth = exports.isDetachedUpPathRoot = void 0;
8
8
  const types_js_1 = require("./types.js");
9
9
  /**
10
10
  * Given an {@link UpPath}, checks if it is a path to a detached root.
@@ -87,7 +87,7 @@ function compareFieldUpPaths(a, b) {
87
87
  }
88
88
  exports.compareFieldUpPaths = compareFieldUpPaths;
89
89
  /**
90
- * Checks whether or not a given path is parented under the root field.
90
+ * Returns the field key for the root field.
91
91
  * @param path - the path you want to check.
92
92
  * @returns the {@link DetachedField} which contains the path.
93
93
  */
@@ -104,4 +104,16 @@ function getDetachedFieldContainingPath(path) {
104
104
  return (0, types_js_1.keyAsDetachedField)(path.parentField);
105
105
  }
106
106
  exports.getDetachedFieldContainingPath = getDetachedFieldContainingPath;
107
+ /**
108
+ * Returns the field key for the root field.
109
+ * @param path - the path you want to check.
110
+ * @returns the {@link DetachedField} which contains the path.
111
+ */
112
+ function getDetachedFieldContainingFieldPath(path) {
113
+ if (path.parent === undefined) {
114
+ return (0, types_js_1.keyAsDetachedField)(path.field);
115
+ }
116
+ return getDetachedFieldContainingPath(path.parent);
117
+ }
118
+ exports.getDetachedFieldContainingFieldPath = getDetachedFieldContainingFieldPath;
107
119
  //# sourceMappingURL=pathTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pathTree.js","sourceRoot":"","sources":["../../../src/core/tree/pathTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,yCAAoE;AAmHpE;;GAEG;AACH,SAAgB,oBAAoB,CACnC,IAAkC;IAElC,OAAQ,IAA6B,CAAC,cAAc,KAAK,SAAS,CAAC;AACpE,CAAC;AAJD,oDAIC;AAgDD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACpC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,IAAI,CAAC,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CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAZD,wCAYC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,CAAc,EAAE,CAAc;IACjE,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,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;AALD,kDAKC;AAED;;;;GAIG;AACH,SAAgB,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,IAAA,6BAAkB,EAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACP,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,CAAC;IACF,CAAC;IACD,OAAO,IAAA,6BAAkB,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC;AAVD,wEAUC","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,yCAAoE;AAmHpE;;GAEG;AACH,SAAgB,oBAAoB,CACnC,IAAkC;IAElC,OAAQ,IAA6B,CAAC,cAAc,KAAK,SAAS,CAAC;AACpE,CAAC;AAJD,oDAIC;AAgDD;;;;;GAKG;AACH,SAAgB,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;AARD,4BAQC;AAcD,SAAgB,SAAS,CAAC,IAAwB;IACjD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IAClB,CAAC;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,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AALD,kDAKC;AAED;;;;GAIG;AACH,SAAgB,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,IAAA,6BAAkB,EAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACP,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,CAAC;IACF,CAAC;IACD,OAAO,IAAA,6BAAkB,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC;AAVD,wEAUC;AAED;;;;GAIG;AACH,SAAgB,mCAAmC,CAAC,IAAiB;IACpE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,IAAA,6BAAkB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AALD,kFAKC","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,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CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAEjC;;;;;;;OAOG;IACH,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEhC;;;;;;;OAOG;IACH,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/B"}
@@ -139,7 +139,12 @@ function transferRoots(rootTransfers, mapToUpdate, detachedFieldIndex, visitor,
139
139
  // This if statement prevents that from happening.
140
140
  if (!(0, deltaUtil_js_1.areDetachedNodeIdsEqual)(oldId, newId)) {
141
141
  for (let i = 0; i < count; i += 1) {
142
- atomized.push({ oldId: (0, deltaUtil_js_1.offsetDetachId)(oldId, i), newId: (0, deltaUtil_js_1.offsetDetachId)(newId, i) });
142
+ const source = detachedFieldIndex.isAttachable((0, deltaUtil_js_1.offsetDetachId)(oldId, i));
143
+ atomized.push({
144
+ oldId: (0, deltaUtil_js_1.offsetDetachId)(oldId, i),
145
+ newId: (0, deltaUtil_js_1.offsetDetachId)(newId, i),
146
+ isAttachable: source,
147
+ });
143
148
  }
144
149
  }
145
150
  return atomized;
@@ -147,30 +152,29 @@ function transferRoots(rootTransfers, mapToUpdate, detachedFieldIndex, visitor,
147
152
  while (nextBatch.length > 0) {
148
153
  const delayed = [];
149
154
  const priorSize = nextBatch.length;
150
- for (const { oldId, newId } of nextBatch) {
155
+ for (const { oldId, newId, isAttachable } of nextBatch) {
151
156
  let oldRootId = detachedFieldIndex.tryGetEntry(oldId);
152
157
  if (oldRootId === undefined) {
153
158
  const tree = (0, index_js_1.tryGetFromNestedMap)(refreshers, oldId.major, oldId.minor);
154
159
  if (tree !== undefined) {
155
- buildTrees(oldId, [tree], detachedFieldIndex, revision, visitor);
160
+ buildTrees(oldId, [tree], detachedFieldIndex, revision, false, visitor);
156
161
  oldRootId = detachedFieldIndex.getEntry(oldId);
157
162
  }
158
163
  }
159
164
  if (oldRootId === undefined) {
160
165
  // The source field is not populated.
161
166
  // This can happen when another rename needs to be performed first.
162
- delayed.push({ oldId, newId });
167
+ delayed.push({ oldId, newId, isAttachable });
163
168
  continue;
164
169
  }
165
170
  let newRootId = detachedFieldIndex.tryGetEntry(newId);
166
171
  if (newRootId !== undefined) {
167
172
  // The destination field is already occupied.
168
173
  // This can happen when another rename needs to be performed first.
169
- delayed.push({ oldId, newId });
174
+ delayed.push({ oldId, newId, isAttachable });
170
175
  continue;
171
176
  }
172
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- intentional behavior
173
- newRootId = detachedFieldIndex.createEntry(newId, revision);
177
+ newRootId = detachedFieldIndex.createEntry(newId, revision, isAttachable);
174
178
  const fields = mapToUpdate.get(oldRootId);
175
179
  if (fields !== undefined) {
176
180
  mapToUpdate.delete(oldRootId);
@@ -218,7 +222,7 @@ function detachPass(fieldChanges, visitor, config) {
218
222
  if (mark.detach !== undefined) {
219
223
  for (let i = 0; i < mark.count; i += 1) {
220
224
  const id = (0, deltaUtil_js_1.offsetDetachId)(mark.detach, i);
221
- const root = config.detachedFieldIndex.createEntry(id, config.latestRevision);
225
+ const root = config.detachedFieldIndex.createEntry(id, config.latestRevision, fieldChanges.allowReattach);
222
226
  if (mark.fields !== undefined) {
223
227
  config.attachPassRoots.set(root, mark.fields);
224
228
  }
@@ -231,12 +235,12 @@ function detachPass(fieldChanges, visitor, config) {
231
235
  }
232
236
  }
233
237
  }
234
- function buildTrees(id, trees, detachedFieldIndex, latestRevision, visitor) {
238
+ function buildTrees(id, trees, detachedFieldIndex, latestRevision, isAttachable, visitor) {
235
239
  for (const [i, tree] of trees.entries()) {
236
240
  const offsettedId = (0, deltaUtil_js_1.offsetDetachId)(id, i);
237
241
  let root = detachedFieldIndex.tryGetEntry(offsettedId);
238
242
  (0, internal_1.assert)(root === undefined, 0x929 /* Unable to build tree that already exists */);
239
- root = detachedFieldIndex.createEntry(offsettedId, latestRevision);
243
+ root = detachedFieldIndex.createEntry(offsettedId, latestRevision, isAttachable);
240
244
  const field = detachedFieldIndex.toFieldKey(root);
241
245
  visitor.create([tree], field);
242
246
  }
@@ -244,7 +248,7 @@ function buildTrees(id, trees, detachedFieldIndex, latestRevision, visitor) {
244
248
  function processBuilds(builds, config, visitor) {
245
249
  if (builds !== undefined) {
246
250
  for (const { id, trees } of builds) {
247
- buildTrees(id, nodeCursorsFromChunk(trees), config.detachedFieldIndex, config.latestRevision, visitor);
251
+ buildTrees(id, nodeCursorsFromChunk(trees), config.detachedFieldIndex, config.latestRevision, true, visitor);
248
252
  }
249
253
  }
250
254
  }
@@ -255,7 +259,7 @@ function processGlobal(global, config, visitor) {
255
259
  if (root === undefined) {
256
260
  const tree = (0, index_js_1.tryGetFromNestedMap)(config.refreshers, id.major, id.minor);
257
261
  (0, internal_1.assert)(tree !== undefined, 0x928 /* refresher data not found */);
258
- buildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, visitor);
262
+ buildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, false, visitor);
259
263
  root = config.detachedFieldIndex.getEntry(id);
260
264
  }
261
265
  // the revision is updated for any refresher data included in the delta that is used
@@ -289,7 +293,7 @@ function attachPass(fieldChanges, visitor, config) {
289
293
  if (sourceRoot === undefined) {
290
294
  const tree = (0, index_js_1.tryGetFromNestedMap)(config.refreshers, offsetAttachId.major, offsetAttachId.minor);
291
295
  (0, internal_1.assert)(tree !== undefined, 0x92a /* refresher data not found */);
292
- buildTrees(offsetAttachId, [tree], config.detachedFieldIndex, config.latestRevision, visitor);
296
+ buildTrees(offsetAttachId, [tree], config.detachedFieldIndex, config.latestRevision, false, visitor);
293
297
  sourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);
294
298
  }
295
299
  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,kEAA6D;AAE7D,kDAA0F;AAK1F,2CAA0E;AAE1E,iDAAyE;AAK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AAO,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,IAAA,0BAAc,EAAC,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,kEAA6D;AAE7D,kDAA0F;AAK1F,2CAA0E;AAE1E,iDAAyE;AAKzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,SAAgB,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,GAAoC,EAAE,CAAC;IAC7D,MAAM,UAAU,GAAoD,IAAI,GAAG,EAAE,CAAC;IAC9E,KAAK,MAAM,EACV,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EACpB,KAAK,GACL,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAC;YAC9B,IAAA,yBAAc,EAAC,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;IACF,CAAC;IACD,MAAM,YAAY,GAAe;QAChC,IAAI,EAAE,UAAU;QAChB,cAAc;QACd,UAAU;QACV,kBAAkB;QAClB,eAAe;QACf,eAAe;QACf,aAAa;QACb,gBAAgB;KAChB,CAAC;IACF,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,YAA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IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,IAAA,0BAAc,EAAC,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"]}
@@ -0,0 +1,97 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { TreeNodeSchema, TreeNodeFromImplicitAllowedTypes, TreeFieldFromImplicitField, SchemaFactoryBeta } from "./simple-tree/index.js";
6
+ /**
7
+ * Utilities for creating extensible unions using a node.
8
+ * @remarks
9
+ * Use {@link ExtensibleUnionNode.createSchema} to create the union schema.
10
+ *
11
+ * Unlike a schema union created using {@link SchemaStaticsBeta.staged | staged} allowed types, this union allows for unknown future types to exist in addition to the known types.
12
+ * This allows for faster roll-outs of new types without waiting for old clients to be updated to be aware of them.
13
+ * This does mean however that old clients may see types they do not know about, which are simply exposed as `undefined` children.
14
+ *
15
+ * `staged` types are lower overhead, and might gain support for `unknown` types in the future, so prefer them when possible.
16
+ * This is simply an alternative for when future compatibility with unknown types is required.
17
+ * It is built on top of the existing {@link ObjectSchemaOptions.allowUnknownOptionalFields | allowUnknownOptionalFields} feature.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const sf = new SchemaFactoryBeta("extensibleUnionNodeExample.items");
22
+ * class ItemA extends sf.object("A", { x: sf.string }) {}
23
+ * class ItemB extends sf.object("B", { x: sf.number }) {}
24
+ *
25
+ * class AnyItem extends ExtensibleUnionNode.createSchema(
26
+ * [ItemA, ItemB], // Future versions may add more members here
27
+ * sf,
28
+ * "ExtensibleUnion",
29
+ * ) {}
30
+ * // Instances of the union are created using `create`.
31
+ * const anyItem = AnyItem.create(new ItemA({ x: "hello" }));
32
+ * // Reading the content from the union is done via the `union` property,
33
+ * // which can be `undefined` to handle the case where a future version of this schema allows a type unknown to the current version.
34
+ * const childNode: ItemA | ItemB | undefined = anyItem.union;
35
+ * // To determine which member of the union was present, its schema can be inspected:
36
+ * const aSchema = Tree.schema(childNode ?? assert.fail("No child"));
37
+ * assert.equal(aSchema, ItemA);
38
+ * ```
39
+ * @beta
40
+ */
41
+ export declare namespace ExtensibleUnionNode {
42
+ /**
43
+ * Members for classes created by {@link ExtensibleUnionNode.createSchema}.
44
+ * @beta
45
+ */
46
+ interface Members<T> {
47
+ /**
48
+ * The child wrapped by this node has one of the types allowed by the union,
49
+ * or `undefined` if the type is one which was added to the union by a future version of this schema.
50
+ *
51
+ * @throws if {@link ExtensibleUnionNode.Members.isValid} is false.
52
+ */
53
+ readonly union: T | undefined;
54
+ /**
55
+ * Returns true, unless this node is in an invalid state.
56
+ * @remarks
57
+ * A well behaved application should not need this API.
58
+ * If an application is hitting errors when accessing {@link ExtensibleUnionNode.Members.union},
59
+ * this API can be used to help detect and recover from the invalid state which causes those errors (for example by replacing the invalid nodes with new ones).
60
+ *
61
+ * In this context "invalid" means that the internal implementation details of this node have had their invariants violated.
62
+ * This can happen when:
63
+ * - Using weakly typed construction APIs like {@link (TreeBeta:interface).importConcise} or {@link (TreeAlpha:interface).importVerbose} to construct an invalid state directly.
64
+ * Using such APIs, even when not creating invalid nodes, is not supported for this schema,
65
+ * since doing so requires knowing the implementation details of this node which are subject to change.
66
+ * - By editing a document using a different client using a different schema for this node.
67
+ * - Violating the TypeScript types to directly manipulate the node internals.
68
+ * - A bug in this node's implementation (possibly in a different client) corrupted the node.
69
+ * - Corruption of the document this node is contained in.
70
+ *
71
+ * @privateRemarks
72
+ * We could support {@link (TreeBeta:interface).exportVerbose} using {@link KeyEncodingOptions.allStoredKeys}
73
+ * then {@link (TreeAlpha:interface).importVerbose} with {@link KeyEncodingOptions.knownStoredKeys}.
74
+ * However, even this will error (but will not produce an invalid node) if there is a node of an unknown type in the union.
75
+ */
76
+ isValid(): boolean;
77
+ }
78
+ /**
79
+ * Statics for classes created by {@link ExtensibleUnionNode.createSchema}.
80
+ * @beta
81
+ */
82
+ interface Statics<T extends readonly TreeNodeSchema[]> {
83
+ /**
84
+ * Create a {@link TreeNode} with `this` schema which wraps the provided child to create the union.
85
+ */
86
+ create<TThis extends TreeNodeSchema>(this: TThis, child: TreeNodeFromImplicitAllowedTypes<T>): TreeFieldFromImplicitField<TThis>;
87
+ }
88
+ /**
89
+ * Create an extensible schema union which currently supports the types in `types`,
90
+ * but tolerates collaboration with future versions that may include additional types.
91
+ * @remarks
92
+ * See {@link ExtensibleUnionNode} for an example use.
93
+ * @beta
94
+ */
95
+ function createSchema<const T extends readonly TreeNodeSchema[], const TScope extends string, const TName extends string>(types: T, inputSchemaFactory: SchemaFactoryBeta<TScope>, name: TName): Statics<T> & import("./simple-tree/index.js").TreeNodeSchemaCore<import("./simple-tree/index.js").ScopedSchemaName<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, import("./simple-tree/index.js").NodeKind, false, unknown, never, unknown> & (new (data: import("./simple-tree/index.js").InternalTreeNode) => Members<TreeNodeFromImplicitAllowedTypes<T>> & import("./simple-tree/index.js").TreeNode & import("./simple-tree/index.js").WithType<import("./simple-tree/index.js").ScopedSchemaName<`com.fluidframework.extensibleUnionNode<${TScope}>`, TName>, import("./simple-tree/index.js").NodeKind, unknown>);
96
+ }
97
+ //# sourceMappingURL=extensibleUnionNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensibleUnionNode.d.ts","sourceRoot":"","sources":["../src/extensibleUnionNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACX,cAAc,EACd,gCAAgC,EAChC,0BAA0B,EAG1B,iBAAiB,EACjB,MAAM,wBAAwB,CAAC;AAUhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,yBAAiB,mBAAmB,CAAC;IACpC;;;OAGG;IACH,UAAiB,OAAO,CAAC,CAAC;QACzB;;;;;WAKG;QACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;QAE9B;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,OAAO,IAAI,OAAO,CAAC;KACnB;IAED;;;OAGG;IACH,UAAiB,OAAO,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE;QAC3D;;WAEG;QACH,MAAM,CAAC,KAAK,SAAS,cAAc,EAClC,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,gCAAgC,CAAC,CAAC,CAAC,GACxC,0BAA0B,CAAC,KAAK,CAAC,CAAC;KACrC;IAED;;;;;;OAMG;IAEH,SAAgB,YAAY,CAC3B,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACzC,KAAK,CAAC,MAAM,SAAS,MAAM,EAC3B,KAAK,CAAC,KAAK,SAAS,MAAM,EACzB,KAAK,EAAE,CAAC,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,2mBAkDrE;CACD"}