@fluidframework/tree 2.90.0 → 2.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1006) hide show
  1. package/CHANGELOG.md +365 -0
  2. package/alpha.d.ts +2 -2
  3. package/api-extractor/api-extractor-lint-alpha.cjs.json +1 -1
  4. package/api-extractor/api-extractor-lint-alpha.esm.json +1 -1
  5. package/api-extractor/api-extractor-lint-beta.cjs.json +1 -1
  6. package/api-extractor/api-extractor-lint-beta.esm.json +1 -1
  7. package/api-extractor/api-extractor-lint-bundle.json +1 -1
  8. package/api-extractor/api-extractor-lint-legacy.cjs.json +1 -1
  9. package/api-extractor/api-extractor-lint-legacy.esm.json +1 -1
  10. package/api-extractor/api-extractor-lint-public.cjs.json +1 -1
  11. package/api-extractor/api-extractor-lint-public.esm.json +1 -1
  12. package/api-extractor/api-extractor.current.json +1 -1
  13. package/api-extractor/api-extractor.legacy.json +2 -1
  14. package/api-extractor.json +1 -0
  15. package/api-report/tree.alpha.api.md +141 -37
  16. package/beta.d.ts +2 -2
  17. package/dist/api.d.ts +6 -1
  18. package/dist/api.d.ts.map +1 -1
  19. package/dist/api.js.map +1 -1
  20. package/dist/codec/codec.d.ts +28 -2
  21. package/dist/codec/codec.d.ts.map +1 -1
  22. package/dist/codec/codec.js +1 -0
  23. package/dist/codec/codec.js.map +1 -1
  24. package/dist/codec/index.d.ts +2 -2
  25. package/dist/codec/index.d.ts.map +1 -1
  26. package/dist/codec/index.js +2 -4
  27. package/dist/codec/index.js.map +1 -1
  28. package/dist/codec/versioned/codec.d.ts +18 -36
  29. package/dist/codec/versioned/codec.d.ts.map +1 -1
  30. package/dist/codec/versioned/codec.js +46 -59
  31. package/dist/codec/versioned/codec.js.map +1 -1
  32. package/dist/codec/versioned/index.d.ts +1 -1
  33. package/dist/codec/versioned/index.d.ts.map +1 -1
  34. package/dist/codec/versioned/index.js +2 -4
  35. package/dist/codec/versioned/index.js.map +1 -1
  36. package/dist/core/forest/forest.d.ts +5 -2
  37. package/dist/core/forest/forest.d.ts.map +1 -1
  38. package/dist/core/forest/forest.js.map +1 -1
  39. package/dist/core/index.d.ts +1 -1
  40. package/dist/core/index.d.ts.map +1 -1
  41. package/dist/core/index.js +6 -2
  42. package/dist/core/index.js.map +1 -1
  43. package/dist/core/rebase/changeRebaser.d.ts +8 -1
  44. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  45. package/dist/core/rebase/changeRebaser.js.map +1 -1
  46. package/dist/core/rebase/revisionTagCodec.d.ts +4 -3
  47. package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
  48. package/dist/core/rebase/revisionTagCodec.js +2 -0
  49. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  50. package/dist/core/rebase/utils.d.ts +2 -2
  51. package/dist/core/rebase/utils.d.ts.map +1 -1
  52. package/dist/core/rebase/utils.js +4 -4
  53. package/dist/core/rebase/utils.js.map +1 -1
  54. package/dist/core/schema-stored/formatV2.d.ts +1 -1
  55. package/dist/core/schema-stored/formatV2.js +1 -1
  56. package/dist/core/schema-stored/formatV2.js.map +1 -1
  57. package/dist/core/tree/anchorSet.d.ts +8 -0
  58. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  59. package/dist/core/tree/anchorSet.js +42 -7
  60. package/dist/core/tree/anchorSet.js.map +1 -1
  61. package/dist/core/tree/cursor.d.ts +25 -1
  62. package/dist/core/tree/cursor.d.ts.map +1 -1
  63. package/dist/core/tree/cursor.js +45 -1
  64. package/dist/core/tree/cursor.js.map +1 -1
  65. package/dist/core/tree/deltaUtil.d.ts +13 -1
  66. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  67. package/dist/core/tree/deltaUtil.js +34 -1
  68. package/dist/core/tree/deltaUtil.js.map +1 -1
  69. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -5
  70. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  71. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  72. package/dist/core/tree/index.d.ts +2 -2
  73. package/dist/core/tree/index.d.ts.map +1 -1
  74. package/dist/core/tree/index.js +6 -2
  75. package/dist/core/tree/index.js.map +1 -1
  76. package/dist/core/tree/visitDelta.d.ts +11 -0
  77. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  78. package/dist/core/tree/visitDelta.js +1 -1
  79. package/dist/core/tree/visitDelta.js.map +1 -1
  80. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  81. package/dist/core/tree/visitorUtils.js +5 -0
  82. package/dist/core/tree/visitorUtils.js.map +1 -1
  83. package/dist/entrypoints/alpha.d.ts +6 -0
  84. package/dist/entrypoints/alpha.d.ts.map +1 -0
  85. package/dist/entrypoints/alpha.js +91 -0
  86. package/dist/entrypoints/alpha.js.map +1 -0
  87. package/dist/entrypoints/beta.d.ts +6 -0
  88. package/dist/entrypoints/beta.d.ts.map +1 -0
  89. package/dist/entrypoints/beta.js +43 -0
  90. package/dist/entrypoints/beta.js.map +1 -0
  91. package/dist/entrypoints/internal.d.ts +6 -0
  92. package/dist/entrypoints/internal.d.ts.map +1 -0
  93. package/dist/entrypoints/internal.js +28 -0
  94. package/dist/entrypoints/internal.js.map +1 -0
  95. package/dist/entrypoints/legacy.d.ts +6 -0
  96. package/dist/entrypoints/legacy.d.ts.map +1 -0
  97. package/dist/entrypoints/legacy.js +49 -0
  98. package/dist/entrypoints/legacy.js.map +1 -0
  99. package/dist/entrypoints/public.d.ts +6 -0
  100. package/dist/entrypoints/public.d.ts.map +1 -0
  101. package/dist/entrypoints/public.js +27 -0
  102. package/dist/entrypoints/public.js.map +1 -0
  103. package/dist/feature-libraries/changeAtomIdCodec.d.ts +4 -3
  104. package/dist/feature-libraries/changeAtomIdCodec.d.ts.map +1 -1
  105. package/dist/feature-libraries/changeAtomIdCodec.js +2 -0
  106. package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
  107. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +2 -1
  108. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  109. package/dist/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  110. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  111. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +4 -4
  112. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  113. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +6 -6
  114. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  115. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  116. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  117. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  118. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -2
  119. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  120. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  121. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -4
  122. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  123. package/dist/feature-libraries/chunked-forest/codec/codecs.js +6 -6
  124. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  125. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +12 -12
  126. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  127. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  128. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  129. package/dist/feature-libraries/chunked-forest/codec/{formatGeneric.d.ts → format/formatGeneric.d.ts} +1 -1
  130. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -0
  131. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -0
  132. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +187 -0
  133. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -0
  134. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js +115 -0
  135. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -0
  136. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +33 -0
  137. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -0
  138. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +16 -0
  139. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -0
  140. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +10 -0
  141. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -0
  142. package/dist/feature-libraries/chunked-forest/codec/format/index.js +18 -0
  143. package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -0
  144. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +93 -0
  145. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -0
  146. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +29 -0
  147. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -0
  148. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  149. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  150. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -2
  151. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  152. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  153. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  154. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  155. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  156. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  157. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +6 -4
  158. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  159. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +1 -1
  160. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  161. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +3 -3
  162. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  163. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  164. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  165. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  166. package/dist/feature-libraries/cursorComparator.d.ts +23 -0
  167. package/dist/feature-libraries/cursorComparator.d.ts.map +1 -0
  168. package/dist/feature-libraries/cursorComparator.js +65 -0
  169. package/dist/feature-libraries/cursorComparator.js.map +1 -0
  170. package/dist/feature-libraries/forest-summary/codec.d.ts +1 -1
  171. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +3 -3
  172. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  173. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  174. package/dist/feature-libraries/index.d.ts +3 -2
  175. package/dist/feature-libraries/index.d.ts.map +1 -1
  176. package/dist/feature-libraries/index.js +5 -5
  177. package/dist/feature-libraries/index.js.map +1 -1
  178. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +2 -0
  179. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  180. package/dist/feature-libraries/indexing/anchorTreeIndex.js +12 -7
  181. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  182. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  183. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  184. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  185. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +3 -3
  186. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  187. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  188. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +1 -0
  189. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  190. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -6
  191. package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  192. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  193. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  194. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  195. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  196. package/dist/feature-libraries/modular-schema/genericFieldKind.js +0 -1
  197. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  198. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +10 -10
  199. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  200. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -4
  201. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  202. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +3 -3
  203. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  204. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  205. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +3 -3
  206. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  207. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  208. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
  209. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  210. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +11 -6
  211. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  212. package/dist/feature-libraries/object-forest/objectForest.d.ts +1 -1
  213. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  214. package/dist/feature-libraries/object-forest/objectForest.js +2 -2
  215. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  216. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +4 -4
  217. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  218. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  219. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +3 -3
  220. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  221. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  222. package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
  223. package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
  224. package/dist/feature-libraries/schema-edits/index.js +2 -3
  225. package/dist/feature-libraries/schema-edits/index.js.map +1 -1
  226. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -15
  227. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  228. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -54
  229. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  230. package/dist/feature-libraries/schema-index/codec.d.ts +3 -16
  231. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  232. package/dist/feature-libraries/schema-index/codec.js +1 -21
  233. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  234. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -1
  235. package/dist/feature-libraries/schema-index/formatV2.js +1 -1
  236. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  237. package/dist/feature-libraries/schema-index/index.d.ts +1 -1
  238. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  239. package/dist/feature-libraries/schema-index/index.js +1 -2
  240. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  241. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  242. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  243. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  244. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -4
  245. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  246. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  247. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +3 -3
  248. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  249. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  250. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -3
  251. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  252. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  253. package/dist/index.d.ts +8 -2
  254. package/dist/index.d.ts.map +1 -1
  255. package/dist/index.js +4 -3
  256. package/dist/index.js.map +1 -1
  257. package/dist/packageVersion.d.ts +1 -1
  258. package/dist/packageVersion.js +1 -1
  259. package/dist/packageVersion.js.map +1 -1
  260. package/dist/shared-tree/independentView.d.ts +1 -1
  261. package/dist/shared-tree/independentView.d.ts.map +1 -1
  262. package/dist/shared-tree/independentView.js +14 -21
  263. package/dist/shared-tree/independentView.js.map +1 -1
  264. package/dist/shared-tree/index.d.ts +2 -2
  265. package/dist/shared-tree/index.d.ts.map +1 -1
  266. package/dist/shared-tree/index.js +1 -2
  267. package/dist/shared-tree/index.js.map +1 -1
  268. package/dist/shared-tree/schematizingTreeView.d.ts +2 -36
  269. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  270. package/dist/shared-tree/schematizingTreeView.js +15 -117
  271. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  272. package/dist/shared-tree/sharedTree.d.ts +3 -22
  273. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  274. package/dist/shared-tree/sharedTree.js +10 -27
  275. package/dist/shared-tree/sharedTree.js.map +1 -1
  276. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +3 -2
  277. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  278. package/dist/shared-tree/sharedTreeChangeCodecs.js +23 -16
  279. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  280. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  281. package/dist/shared-tree/sharedTreeChangeEnricher.js +1 -1
  282. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  283. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  284. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  285. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  286. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  287. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  288. package/dist/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  289. package/dist/shared-tree/sharedTreeChangeFormat.js +13 -5
  290. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  291. package/dist/shared-tree/tree.d.ts.map +1 -1
  292. package/dist/shared-tree/tree.js +2 -1
  293. package/dist/shared-tree/tree.js.map +1 -1
  294. package/dist/shared-tree/treeAlpha.d.ts +13 -1
  295. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  296. package/dist/shared-tree/treeAlpha.js +3 -0
  297. package/dist/shared-tree/treeAlpha.js.map +1 -1
  298. package/dist/shared-tree/treeCheckout.d.ts +34 -69
  299. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  300. package/dist/shared-tree/treeCheckout.js +885 -677
  301. package/dist/shared-tree/treeCheckout.js.map +1 -1
  302. package/dist/shared-tree/unhydratedTreeContext.js +3 -3
  303. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  304. package/dist/shared-tree-core/editManagerCodecs.d.ts +23 -12
  305. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  306. package/dist/shared-tree-core/editManagerCodecs.js +40 -67
  307. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  308. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  309. package/dist/shared-tree-core/editManagerCodecsCommons.js +0 -1
  310. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  311. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +10 -2
  312. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  313. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +18 -13
  314. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  315. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  316. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  317. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +6 -9
  318. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  319. package/dist/shared-tree-core/index.d.ts +3 -3
  320. package/dist/shared-tree-core/index.d.ts.map +1 -1
  321. package/dist/shared-tree-core/index.js +5 -8
  322. package/dist/shared-tree-core/index.js.map +1 -1
  323. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -3
  324. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  325. package/dist/shared-tree-core/messageCodecV1ToV4.js +8 -8
  326. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  327. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts +2 -3
  328. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  329. package/dist/shared-tree-core/messageCodecVSharedBranches.js +5 -4
  330. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  331. package/dist/shared-tree-core/messageCodecs.d.ts +15 -14
  332. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  333. package/dist/shared-tree-core/messageCodecs.js +38 -74
  334. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  335. package/dist/shared-tree-core/messageFormat.d.ts +0 -1
  336. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  337. package/dist/shared-tree-core/messageFormat.js +1 -2
  338. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  339. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -3
  340. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  341. package/dist/shared-tree-core/sharedTreeCore.js +12 -2
  342. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  343. package/dist/sharedTreeAttributes.d.ts.map +1 -1
  344. package/dist/sharedTreeAttributes.js +3 -0
  345. package/dist/sharedTreeAttributes.js.map +1 -1
  346. package/dist/simple-tree/api/eraseSchemaDetails.d.ts +43 -0
  347. package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
  348. package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  349. package/dist/simple-tree/api/index.d.ts +4 -2
  350. package/dist/simple-tree/api/index.d.ts.map +1 -1
  351. package/dist/simple-tree/api/index.js.map +1 -1
  352. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  353. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  354. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +126 -29
  355. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  356. package/dist/simple-tree/api/schemaFactoryAlpha.js +72 -7
  357. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  358. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  359. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  360. package/dist/simple-tree/api/schemaStatics.d.ts +10 -11
  361. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  362. package/dist/simple-tree/api/schemaStatics.js +13 -7
  363. package/dist/simple-tree/api/schemaStatics.js.map +1 -1
  364. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  365. package/dist/simple-tree/api/storedSchema.js +6 -6
  366. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  367. package/dist/simple-tree/api/tree.d.ts +7 -19
  368. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  369. package/dist/simple-tree/api/tree.js.map +1 -1
  370. package/dist/simple-tree/api/treeAlpha.d.ts +69 -0
  371. package/dist/simple-tree/api/treeAlpha.d.ts.map +1 -0
  372. package/dist/simple-tree/api/treeAlpha.js +7 -0
  373. package/dist/simple-tree/api/treeAlpha.js.map +1 -0
  374. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  375. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  376. package/dist/simple-tree/api/treeChangeEvents.d.ts +3 -0
  377. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  378. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  379. package/dist/simple-tree/api/treeNodeApi.d.ts +49 -0
  380. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  381. package/dist/simple-tree/api/treeNodeApi.js +41 -2
  382. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  383. package/dist/simple-tree/api/typesUnsafe.d.ts +23 -2
  384. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  385. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  386. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  387. package/dist/simple-tree/core/treeNodeKernel.js +45 -8
  388. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  389. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  390. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -1
  391. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  392. package/dist/simple-tree/fieldSchema.d.ts +3 -2
  393. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  394. package/dist/simple-tree/fieldSchema.js +3 -4
  395. package/dist/simple-tree/fieldSchema.js.map +1 -1
  396. package/dist/simple-tree/index.d.ts +2 -2
  397. package/dist/simple-tree/index.d.ts.map +1 -1
  398. package/dist/simple-tree/index.js.map +1 -1
  399. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +16 -0
  400. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  401. package/dist/simple-tree/node-kinds/array/arrayNode.js +23 -0
  402. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  403. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +10 -1
  404. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  405. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  406. package/dist/simple-tree/node-kinds/array/index.d.ts +2 -2
  407. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  408. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  409. package/dist/simple-tree/node-kinds/index.d.ts +2 -2
  410. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  411. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  412. package/dist/simple-tree/node-kinds/object/index.d.ts +2 -2
  413. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  414. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  415. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +43 -7
  416. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  417. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  418. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +26 -2
  419. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  420. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  421. package/dist/text/textDomainFormatted.d.ts +321 -13
  422. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  423. package/dist/text/textDomainFormatted.js +100 -25
  424. package/dist/text/textDomainFormatted.js.map +1 -1
  425. package/dist/treeFactory.d.ts.map +1 -1
  426. package/dist/treeFactory.js +5 -2
  427. package/dist/treeFactory.js.map +1 -1
  428. package/dist/util/rangeMap.d.ts +25 -18
  429. package/dist/util/rangeMap.d.ts.map +1 -1
  430. package/dist/util/rangeMap.js +24 -30
  431. package/dist/util/rangeMap.js.map +1 -1
  432. package/dist/util/referenceCounting.d.ts.map +1 -1
  433. package/dist/util/referenceCounting.js +0 -1
  434. package/dist/util/referenceCounting.js.map +1 -1
  435. package/dist/util/typeCheck.d.ts.map +1 -1
  436. package/dist/util/typeCheck.js.map +1 -1
  437. package/dist/util/typeUtils.d.ts.map +1 -1
  438. package/dist/util/typeUtils.js.map +1 -1
  439. package/eslint.config.mts +10 -2
  440. package/internal.d.ts +2 -2
  441. package/legacy.d.ts +2 -2
  442. package/lib/api.d.ts +6 -1
  443. package/lib/api.d.ts.map +1 -1
  444. package/lib/api.js.map +1 -1
  445. package/lib/codec/codec.d.ts +28 -2
  446. package/lib/codec/codec.d.ts.map +1 -1
  447. package/lib/codec/codec.js +1 -0
  448. package/lib/codec/codec.js.map +1 -1
  449. package/lib/codec/index.d.ts +2 -2
  450. package/lib/codec/index.d.ts.map +1 -1
  451. package/lib/codec/index.js +1 -1
  452. package/lib/codec/index.js.map +1 -1
  453. package/lib/codec/versioned/codec.d.ts +18 -36
  454. package/lib/codec/versioned/codec.d.ts.map +1 -1
  455. package/lib/codec/versioned/codec.js +45 -56
  456. package/lib/codec/versioned/codec.js.map +1 -1
  457. package/lib/codec/versioned/index.d.ts +1 -1
  458. package/lib/codec/versioned/index.d.ts.map +1 -1
  459. package/lib/codec/versioned/index.js +1 -1
  460. package/lib/codec/versioned/index.js.map +1 -1
  461. package/lib/core/forest/forest.d.ts +5 -2
  462. package/lib/core/forest/forest.d.ts.map +1 -1
  463. package/lib/core/forest/forest.js.map +1 -1
  464. package/lib/core/index.d.ts +1 -1
  465. package/lib/core/index.d.ts.map +1 -1
  466. package/lib/core/index.js +1 -1
  467. package/lib/core/index.js.map +1 -1
  468. package/lib/core/rebase/changeRebaser.d.ts +8 -1
  469. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  470. package/lib/core/rebase/changeRebaser.js.map +1 -1
  471. package/lib/core/rebase/revisionTagCodec.d.ts +4 -3
  472. package/lib/core/rebase/revisionTagCodec.d.ts.map +1 -1
  473. package/lib/core/rebase/revisionTagCodec.js +2 -0
  474. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  475. package/lib/core/rebase/utils.d.ts +2 -2
  476. package/lib/core/rebase/utils.d.ts.map +1 -1
  477. package/lib/core/rebase/utils.js +4 -4
  478. package/lib/core/rebase/utils.js.map +1 -1
  479. package/lib/core/schema-stored/formatV2.d.ts +1 -1
  480. package/lib/core/schema-stored/formatV2.js +1 -1
  481. package/lib/core/schema-stored/formatV2.js.map +1 -1
  482. package/lib/core/tree/anchorSet.d.ts +8 -0
  483. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  484. package/lib/core/tree/anchorSet.js +42 -7
  485. package/lib/core/tree/anchorSet.js.map +1 -1
  486. package/lib/core/tree/cursor.d.ts +25 -1
  487. package/lib/core/tree/cursor.d.ts.map +1 -1
  488. package/lib/core/tree/cursor.js +43 -0
  489. package/lib/core/tree/cursor.js.map +1 -1
  490. package/lib/core/tree/deltaUtil.d.ts +13 -1
  491. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  492. package/lib/core/tree/deltaUtil.js +31 -0
  493. package/lib/core/tree/deltaUtil.js.map +1 -1
  494. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -5
  495. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  496. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  497. package/lib/core/tree/index.d.ts +2 -2
  498. package/lib/core/tree/index.d.ts.map +1 -1
  499. package/lib/core/tree/index.js +2 -2
  500. package/lib/core/tree/index.js.map +1 -1
  501. package/lib/core/tree/visitDelta.d.ts +11 -0
  502. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  503. package/lib/core/tree/visitDelta.js +1 -1
  504. package/lib/core/tree/visitDelta.js.map +1 -1
  505. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  506. package/lib/core/tree/visitorUtils.js +5 -0
  507. package/lib/core/tree/visitorUtils.js.map +1 -1
  508. package/lib/entrypoints/alpha.d.ts +6 -0
  509. package/lib/entrypoints/alpha.d.ts.map +1 -0
  510. package/lib/entrypoints/alpha.js +12 -0
  511. package/lib/entrypoints/alpha.js.map +1 -0
  512. package/lib/entrypoints/beta.d.ts +6 -0
  513. package/lib/entrypoints/beta.d.ts.map +1 -0
  514. package/lib/entrypoints/beta.js +12 -0
  515. package/lib/entrypoints/beta.js.map +1 -0
  516. package/lib/entrypoints/internal.d.ts +6 -0
  517. package/lib/entrypoints/internal.d.ts.map +1 -0
  518. package/lib/entrypoints/internal.js +12 -0
  519. package/lib/entrypoints/internal.js.map +1 -0
  520. package/lib/entrypoints/legacy.d.ts +6 -0
  521. package/lib/entrypoints/legacy.d.ts.map +1 -0
  522. package/lib/entrypoints/legacy.js +15 -0
  523. package/lib/entrypoints/legacy.js.map +1 -0
  524. package/lib/entrypoints/public.d.ts +6 -0
  525. package/lib/entrypoints/public.d.ts.map +1 -0
  526. package/lib/entrypoints/public.js +10 -0
  527. package/lib/entrypoints/public.js.map +1 -0
  528. package/lib/feature-libraries/changeAtomIdCodec.d.ts +4 -3
  529. package/lib/feature-libraries/changeAtomIdCodec.d.ts.map +1 -1
  530. package/lib/feature-libraries/changeAtomIdCodec.js +2 -0
  531. package/lib/feature-libraries/changeAtomIdCodec.js.map +1 -1
  532. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +2 -1
  533. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  534. package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  535. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  536. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +4 -4
  537. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  538. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +4 -4
  539. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  540. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  541. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  542. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  543. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -2
  544. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  545. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  546. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -4
  547. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  548. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  549. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  550. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +12 -12
  551. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  552. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  553. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  554. package/lib/feature-libraries/chunked-forest/codec/{formatGeneric.d.ts → format/formatGeneric.d.ts} +1 -1
  555. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -0
  556. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -0
  557. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +187 -0
  558. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -0
  559. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js +112 -0
  560. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -0
  561. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +33 -0
  562. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -0
  563. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +13 -0
  564. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -0
  565. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +10 -0
  566. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -0
  567. package/lib/feature-libraries/chunked-forest/codec/format/index.js +8 -0
  568. package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -0
  569. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +93 -0
  570. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -0
  571. package/lib/feature-libraries/chunked-forest/codec/format/versions.js +26 -0
  572. package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -0
  573. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  574. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  575. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  576. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  577. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  578. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  579. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  580. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  581. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  582. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +4 -2
  583. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  584. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +1 -1
  585. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  586. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
  587. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  588. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  589. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  590. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  591. package/lib/feature-libraries/cursorComparator.d.ts +23 -0
  592. package/lib/feature-libraries/cursorComparator.d.ts.map +1 -0
  593. package/lib/feature-libraries/cursorComparator.js +61 -0
  594. package/lib/feature-libraries/cursorComparator.js.map +1 -0
  595. package/lib/feature-libraries/forest-summary/codec.d.ts +1 -1
  596. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +3 -3
  597. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  598. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  599. package/lib/feature-libraries/index.d.ts +3 -2
  600. package/lib/feature-libraries/index.d.ts.map +1 -1
  601. package/lib/feature-libraries/index.js +3 -2
  602. package/lib/feature-libraries/index.js.map +1 -1
  603. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +2 -0
  604. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  605. package/lib/feature-libraries/indexing/anchorTreeIndex.js +12 -7
  606. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  607. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  608. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  609. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  610. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +3 -3
  611. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  612. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  613. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +1 -0
  614. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -1
  615. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +14 -6
  616. package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -1
  617. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  618. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  619. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  620. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  621. package/lib/feature-libraries/modular-schema/genericFieldKind.js +0 -1
  622. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  623. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +10 -10
  624. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  625. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -4
  626. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  627. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +3 -3
  628. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  629. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  630. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +3 -3
  631. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  632. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  633. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
  634. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  635. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +11 -6
  636. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  637. package/lib/feature-libraries/object-forest/objectForest.d.ts +1 -1
  638. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  639. package/lib/feature-libraries/object-forest/objectForest.js +2 -2
  640. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  641. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +4 -4
  642. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  643. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +1 -1
  644. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  645. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +3 -3
  646. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  647. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  648. package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
  649. package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
  650. package/lib/feature-libraries/schema-edits/index.js +1 -1
  651. package/lib/feature-libraries/schema-edits/index.js.map +1 -1
  652. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -15
  653. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  654. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -50
  655. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  656. package/lib/feature-libraries/schema-index/codec.d.ts +3 -16
  657. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  658. package/lib/feature-libraries/schema-index/codec.js +0 -19
  659. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  660. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -1
  661. package/lib/feature-libraries/schema-index/formatV2.js +1 -1
  662. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  663. package/lib/feature-libraries/schema-index/index.d.ts +1 -1
  664. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  665. package/lib/feature-libraries/schema-index/index.js +1 -1
  666. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  667. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +1 -1
  668. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  669. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  670. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -4
  671. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  672. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  673. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +3 -3
  674. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  675. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -1
  676. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  677. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -3
  678. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  679. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  680. package/lib/index.d.ts +8 -2
  681. package/lib/index.d.ts.map +1 -1
  682. package/lib/index.js +9 -1
  683. package/lib/index.js.map +1 -1
  684. package/lib/packageVersion.d.ts +1 -1
  685. package/lib/packageVersion.js +1 -1
  686. package/lib/packageVersion.js.map +1 -1
  687. package/lib/shared-tree/independentView.d.ts +1 -1
  688. package/lib/shared-tree/independentView.d.ts.map +1 -1
  689. package/lib/shared-tree/independentView.js +4 -11
  690. package/lib/shared-tree/independentView.js.map +1 -1
  691. package/lib/shared-tree/index.d.ts +2 -2
  692. package/lib/shared-tree/index.d.ts.map +1 -1
  693. package/lib/shared-tree/index.js +1 -1
  694. package/lib/shared-tree/index.js.map +1 -1
  695. package/lib/shared-tree/schematizingTreeView.d.ts +2 -36
  696. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  697. package/lib/shared-tree/schematizingTreeView.js +17 -116
  698. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  699. package/lib/shared-tree/sharedTree.d.ts +3 -22
  700. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  701. package/lib/shared-tree/sharedTree.js +11 -27
  702. package/lib/shared-tree/sharedTree.js.map +1 -1
  703. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +3 -2
  704. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  705. package/lib/shared-tree/sharedTreeChangeCodecs.js +19 -12
  706. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  707. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  708. package/lib/shared-tree/sharedTreeChangeEnricher.js +2 -2
  709. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  710. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  711. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  712. package/lib/shared-tree/sharedTreeChangeFamily.js +2 -2
  713. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  714. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  715. package/lib/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  716. package/lib/shared-tree/sharedTreeChangeFormat.js +11 -5
  717. package/lib/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  718. package/lib/shared-tree/tree.d.ts.map +1 -1
  719. package/lib/shared-tree/tree.js +2 -1
  720. package/lib/shared-tree/tree.js.map +1 -1
  721. package/lib/shared-tree/treeAlpha.d.ts +13 -1
  722. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  723. package/lib/shared-tree/treeAlpha.js +3 -0
  724. package/lib/shared-tree/treeAlpha.js.map +1 -1
  725. package/lib/shared-tree/treeCheckout.d.ts +34 -69
  726. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  727. package/lib/shared-tree/treeCheckout.js +889 -682
  728. package/lib/shared-tree/treeCheckout.js.map +1 -1
  729. package/lib/shared-tree/unhydratedTreeContext.js +1 -1
  730. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  731. package/lib/shared-tree-core/editManagerCodecs.d.ts +23 -12
  732. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  733. package/lib/shared-tree-core/editManagerCodecs.js +41 -65
  734. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  735. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  736. package/lib/shared-tree-core/editManagerCodecsCommons.js +0 -1
  737. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  738. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +10 -2
  739. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  740. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +16 -11
  741. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  742. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  743. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  744. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +5 -8
  745. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  746. package/lib/shared-tree-core/index.d.ts +3 -3
  747. package/lib/shared-tree-core/index.d.ts.map +1 -1
  748. package/lib/shared-tree-core/index.js +3 -3
  749. package/lib/shared-tree-core/index.js.map +1 -1
  750. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -3
  751. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  752. package/lib/shared-tree-core/messageCodecV1ToV4.js +8 -8
  753. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  754. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts +2 -3
  755. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  756. package/lib/shared-tree-core/messageCodecVSharedBranches.js +5 -4
  757. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  758. package/lib/shared-tree-core/messageCodecs.d.ts +15 -14
  759. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  760. package/lib/shared-tree-core/messageCodecs.js +38 -71
  761. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  762. package/lib/shared-tree-core/messageFormat.d.ts +0 -1
  763. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  764. package/lib/shared-tree-core/messageFormat.js +0 -1
  765. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  766. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -3
  767. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  768. package/lib/shared-tree-core/sharedTreeCore.js +14 -4
  769. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  770. package/lib/sharedTreeAttributes.d.ts.map +1 -1
  771. package/lib/sharedTreeAttributes.js +3 -0
  772. package/lib/sharedTreeAttributes.js.map +1 -1
  773. package/lib/simple-tree/api/eraseSchemaDetails.d.ts +43 -0
  774. package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -1
  775. package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -1
  776. package/lib/simple-tree/api/index.d.ts +4 -2
  777. package/lib/simple-tree/api/index.d.ts.map +1 -1
  778. package/lib/simple-tree/api/index.js +1 -1
  779. package/lib/simple-tree/api/index.js.map +1 -1
  780. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  781. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  782. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +126 -29
  783. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  784. package/lib/simple-tree/api/schemaFactoryAlpha.js +66 -1
  785. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  786. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  787. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  788. package/lib/simple-tree/api/schemaStatics.d.ts +10 -11
  789. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  790. package/lib/simple-tree/api/schemaStatics.js +14 -8
  791. package/lib/simple-tree/api/schemaStatics.js.map +1 -1
  792. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  793. package/lib/simple-tree/api/storedSchema.js +7 -7
  794. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  795. package/lib/simple-tree/api/tree.d.ts +7 -19
  796. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  797. package/lib/simple-tree/api/tree.js.map +1 -1
  798. package/lib/simple-tree/api/treeAlpha.d.ts +69 -0
  799. package/lib/simple-tree/api/treeAlpha.d.ts.map +1 -0
  800. package/lib/simple-tree/api/treeAlpha.js +6 -0
  801. package/lib/simple-tree/api/treeAlpha.js.map +1 -0
  802. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  803. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  804. package/lib/simple-tree/api/treeChangeEvents.d.ts +3 -0
  805. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  806. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  807. package/lib/simple-tree/api/treeNodeApi.d.ts +49 -0
  808. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  809. package/lib/simple-tree/api/treeNodeApi.js +41 -2
  810. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  811. package/lib/simple-tree/api/typesUnsafe.d.ts +23 -2
  812. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  813. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  814. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  815. package/lib/simple-tree/core/treeNodeKernel.js +45 -8
  816. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  817. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  818. package/lib/simple-tree/core/unhydratedFlexTree.js +5 -1
  819. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  820. package/lib/simple-tree/fieldSchema.d.ts +3 -2
  821. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  822. package/lib/simple-tree/fieldSchema.js +3 -4
  823. package/lib/simple-tree/fieldSchema.js.map +1 -1
  824. package/lib/simple-tree/index.d.ts +2 -2
  825. package/lib/simple-tree/index.d.ts.map +1 -1
  826. package/lib/simple-tree/index.js.map +1 -1
  827. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +16 -0
  828. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  829. package/lib/simple-tree/node-kinds/array/arrayNode.js +23 -0
  830. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  831. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +10 -1
  832. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  833. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  834. package/lib/simple-tree/node-kinds/array/index.d.ts +2 -2
  835. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  836. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  837. package/lib/simple-tree/node-kinds/index.d.ts +2 -2
  838. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  839. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  840. package/lib/simple-tree/node-kinds/object/index.d.ts +2 -2
  841. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  842. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  843. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +43 -7
  844. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  845. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  846. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +26 -2
  847. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  848. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  849. package/lib/text/textDomainFormatted.d.ts +321 -13
  850. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  851. package/lib/text/textDomainFormatted.js +103 -28
  852. package/lib/text/textDomainFormatted.js.map +1 -1
  853. package/lib/treeFactory.d.ts.map +1 -1
  854. package/lib/treeFactory.js +6 -3
  855. package/lib/treeFactory.js.map +1 -1
  856. package/lib/util/rangeMap.d.ts +25 -18
  857. package/lib/util/rangeMap.d.ts.map +1 -1
  858. package/lib/util/rangeMap.js +25 -31
  859. package/lib/util/rangeMap.js.map +1 -1
  860. package/lib/util/referenceCounting.d.ts.map +1 -1
  861. package/lib/util/referenceCounting.js +0 -1
  862. package/lib/util/referenceCounting.js.map +1 -1
  863. package/lib/util/typeCheck.d.ts.map +1 -1
  864. package/lib/util/typeCheck.js.map +1 -1
  865. package/lib/util/typeUtils.d.ts.map +1 -1
  866. package/lib/util/typeUtils.js.map +1 -1
  867. package/package.json +50 -50
  868. package/scripts/generate-entrypoint-sources.sh +31 -0
  869. package/src/api.ts +11 -0
  870. package/src/codec/codec.ts +32 -2
  871. package/src/codec/index.ts +2 -3
  872. package/src/codec/versioned/codec.ts +99 -109
  873. package/src/codec/versioned/index.ts +1 -3
  874. package/src/core/forest/forest.ts +5 -2
  875. package/src/core/index.ts +4 -0
  876. package/src/core/rebase/changeRebaser.ts +8 -0
  877. package/src/core/rebase/revisionTagCodec.ts +4 -4
  878. package/src/core/rebase/utils.ts +9 -2
  879. package/src/core/schema-stored/formatV2.ts +1 -1
  880. package/src/core/tree/anchorSet.ts +67 -10
  881. package/src/core/tree/cursor.ts +52 -1
  882. package/src/core/tree/deltaUtil.ts +37 -1
  883. package/src/core/tree/detachedFieldIndexCodecs.ts +4 -4
  884. package/src/core/tree/index.ts +4 -0
  885. package/src/core/tree/visitDelta.ts +13 -1
  886. package/src/core/tree/visitorUtils.ts +5 -0
  887. package/{dist/alpha.d.ts → src/entrypoints/alpha.ts} +25 -11
  888. package/{lib/beta.d.ts → src/entrypoints/beta.ts} +4 -7
  889. package/src/entrypoints/internal.ts +13 -0
  890. package/{lib/legacy.d.ts → src/entrypoints/legacy.ts} +13 -8
  891. package/{dist/public.d.ts → src/entrypoints/public.ts} +3 -6
  892. package/src/feature-libraries/changeAtomIdCodec.ts +8 -7
  893. package/src/feature-libraries/chunked-forest/chunkedForest.ts +3 -2
  894. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +18 -13
  895. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  896. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -2
  897. package/src/feature-libraries/chunked-forest/codec/codecs.ts +16 -10
  898. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -14
  899. package/src/feature-libraries/chunked-forest/codec/{formatGeneric.ts → format/formatGeneric.ts} +1 -1
  900. package/src/feature-libraries/chunked-forest/codec/{format.ts → format/formatV1.ts} +41 -111
  901. package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +31 -0
  902. package/src/feature-libraries/chunked-forest/codec/format/index.ts +31 -0
  903. package/src/feature-libraries/chunked-forest/codec/format/versions.ts +81 -0
  904. package/src/feature-libraries/chunked-forest/codec/index.ts +6 -2
  905. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +19 -12
  906. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +6 -4
  907. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +10 -10
  908. package/src/feature-libraries/chunked-forest/index.ts +2 -1
  909. package/src/feature-libraries/cursorComparator.ts +77 -0
  910. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +5 -5
  911. package/src/feature-libraries/index.ts +5 -3
  912. package/src/feature-libraries/indexing/anchorTreeIndex.ts +20 -10
  913. package/src/feature-libraries/mitigatedChangeFamily.ts +4 -1
  914. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +3 -8
  915. package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +16 -8
  916. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +4 -5
  917. package/src/feature-libraries/modular-schema/genericFieldKind.ts +0 -1
  918. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +19 -26
  919. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +4 -4
  920. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -5
  921. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +15 -6
  922. package/src/feature-libraries/object-forest/objectForest.ts +8 -2
  923. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +11 -13
  924. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +4 -5
  925. package/src/feature-libraries/schema-edits/index.ts +1 -4
  926. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +10 -78
  927. package/src/feature-libraries/schema-index/codec.ts +0 -25
  928. package/src/feature-libraries/schema-index/formatV2.ts +1 -1
  929. package/src/feature-libraries/schema-index/index.ts +1 -4
  930. package/src/feature-libraries/sequence-field/moveEffectTable.ts +1 -1
  931. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +6 -6
  932. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +8 -5
  933. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +4 -5
  934. package/src/index.ts +29 -3
  935. package/src/packageVersion.ts +1 -1
  936. package/src/shared-tree/independentView.ts +5 -18
  937. package/src/shared-tree/index.ts +0 -4
  938. package/src/shared-tree/schematizingTreeView.ts +19 -165
  939. package/src/shared-tree/sharedTree.ts +16 -59
  940. package/src/shared-tree/sharedTreeChangeCodecs.ts +23 -29
  941. package/src/shared-tree/sharedTreeChangeEnricher.ts +1 -2
  942. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -0
  943. package/src/shared-tree/sharedTreeChangeFormat.ts +23 -8
  944. package/src/shared-tree/tree.ts +2 -5
  945. package/src/shared-tree/treeAlpha.ts +26 -0
  946. package/src/shared-tree/treeCheckout.ts +277 -100
  947. package/src/shared-tree/unhydratedTreeContext.ts +1 -1
  948. package/src/shared-tree-core/editManagerCodecs.ts +99 -124
  949. package/src/shared-tree-core/editManagerCodecsCommons.ts +0 -1
  950. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +54 -59
  951. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +72 -95
  952. package/src/shared-tree-core/index.ts +4 -8
  953. package/src/shared-tree-core/messageCodecV1ToV4.ts +56 -71
  954. package/src/shared-tree-core/messageCodecVSharedBranches.ts +76 -92
  955. package/src/shared-tree-core/messageCodecs.ts +88 -126
  956. package/src/shared-tree-core/messageFormat.ts +0 -3
  957. package/src/shared-tree-core/sharedTreeCore.ts +14 -21
  958. package/src/sharedTreeAttributes.ts +3 -0
  959. package/src/simple-tree/api/eraseSchemaDetails.ts +60 -0
  960. package/src/simple-tree/api/index.ts +22 -1
  961. package/src/simple-tree/api/schemaFactory.ts +8 -3
  962. package/src/simple-tree/api/schemaFactoryAlpha.ts +275 -27
  963. package/src/simple-tree/api/schemaFactoryBeta.ts +10 -1
  964. package/src/simple-tree/api/schemaStatics.ts +79 -21
  965. package/src/simple-tree/api/storedSchema.ts +8 -19
  966. package/src/simple-tree/api/tree.ts +7 -20
  967. package/src/simple-tree/api/treeAlpha.ts +90 -0
  968. package/src/simple-tree/api/treeBeta.ts +1 -1
  969. package/src/simple-tree/api/treeChangeEvents.ts +3 -0
  970. package/src/simple-tree/api/treeNodeApi.ts +95 -3
  971. package/src/simple-tree/api/typesUnsafe.ts +49 -1
  972. package/src/simple-tree/core/treeNodeKernel.ts +53 -7
  973. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  974. package/src/simple-tree/fieldSchema.ts +29 -5
  975. package/src/simple-tree/index.ts +20 -0
  976. package/src/simple-tree/node-kinds/array/arrayNode.ts +64 -0
  977. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +25 -1
  978. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  979. package/src/simple-tree/node-kinds/index.ts +5 -0
  980. package/src/simple-tree/node-kinds/object/index.ts +3 -0
  981. package/src/simple-tree/node-kinds/object/objectNode.ts +69 -11
  982. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +33 -2
  983. package/src/text/textDomainFormatted.ts +113 -11
  984. package/src/treeFactory.ts +10 -5
  985. package/src/util/rangeMap.ts +54 -50
  986. package/src/util/referenceCounting.ts +0 -1
  987. package/src/util/typeCheck.ts +1 -0
  988. package/src/util/typeUtils.ts +4 -7
  989. package/dist/beta.d.ts +0 -152
  990. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +0 -383
  991. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +0 -1
  992. package/dist/feature-libraries/chunked-forest/codec/format.js +0 -191
  993. package/dist/feature-libraries/chunked-forest/codec/format.js.map +0 -1
  994. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +0 -1
  995. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +0 -1
  996. package/dist/legacy.d.ts +0 -159
  997. package/lib/alpha.d.ts +0 -304
  998. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +0 -383
  999. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +0 -1
  1000. package/lib/feature-libraries/chunked-forest/codec/format.js +0 -188
  1001. package/lib/feature-libraries/chunked-forest/codec/format.js.map +0 -1
  1002. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +0 -1
  1003. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +0 -1
  1004. package/lib/public.d.ts +0 -94
  1005. /package/dist/feature-libraries/chunked-forest/codec/{formatGeneric.js → format/formatGeneric.js} +0 -0
  1006. /package/lib/feature-libraries/chunked-forest/codec/{formatGeneric.js → format/formatGeneric.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../src/core/tree/cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAO7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,cAAc,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAa;IACrC,sFAAsF;IACtF,6FAA6F;IAC7F,OAAO,CACN,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,QAAQ;QACvB,IAA6B,CAAC,YAAY,CAAC,KAAK,IAAI,CACrD,CAAC;AACH,CAAC;AA0RD,MAAM,CAAN,IAAkB,kBAYjB;AAZD,WAAkB,kBAAkB;IACnC;;;OAGG;IACH,6DAAK,CAAA;IAEL;;;OAGG;IACH,+DAAM,CAAA;AACP,CAAC,EAZiB,kBAAkB,KAAlB,kBAAkB,QAYnC;AASD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC9B,MAAe,EACf,CAAyB;IAEzB,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC3B,MAAe,EACf,CAA4B;IAE5B,MAAM,CAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACjF,KAAK,IAAI,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;Q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AC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAmB;IAC1D,OAAO,MAAgC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC5B,MAAe,EACf,KAAe,EACf,CAAyB;IAEzB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,SAAS,EAAE,CAAC;IACnB,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC3B,MAAe,EACf,KAAa,EACb,CAAyB;IAEzB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AACf,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 { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { FieldUpPath, UpPath } from \"./pathTree.js\";\nimport type { TreeType, Value } from \"./types.js\";\n\n/**\n * A symbol for marking an object as an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport const CursorMarker: unique symbol = Symbol(\"CursorMarker\");\n\n/**\n * Check if something is an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport function isCursor(data: unknown): data is ITreeCursor {\n\t// Other than on null and undefined, looking up a missing symbol shouldn't type error.\n\t// typeof check deals with undefined while providing an early out for other non-object types.\n\treturn (\n\t\tdata !== null &&\n\t\ttypeof data === \"object\" &&\n\t\t(data as Partial<ITreeCursor>)[CursorMarker] === true\n\t);\n}\n\n/**\n * A stateful low-level interface for reading tree data.\n * *\n * @remarks Cursor exists so that specialized data formats can be viewed through\n * a common abstraction. This allows performance optimizations to be done based\n * on data.\n *\n * A tree cursor is similar to a database cursor in that it allows for the efficient\n * traversal over the contents of a tree. Note that unlike a database cursor,\n * tree cursors may be invalidated after any edit to the tree. For a cursor-like\n * structure that also remains valid across edits, see {@link AnchorNode}.\n */\nexport interface ITreeCursor {\n\t/**\n\t * Marks this object as a cursor.\n\t */\n\treadonly [CursorMarker]: true;\n\n\t/**\n\t * What kind of place the cursor is at.\n\t * Determines which operations are allowed.\n\t *\n\t * @remarks\n\t * Users of cursors frequently need to refer to places in trees, both fields and nodes.\n\t * Approaches other than having the cursor have separate modes for these\n\t * cases had issues even worse than having the two modes.\n\t *\n\t * For example, modeling fields as parent + key has issues when there is no\n\t * parent, and doesn't provide a great way to do iteration over fields while\n\t * also having a nice API and making it easy for the implementation to track\n\t * state (like its current location inside a sequence tree of fields) while\n\t * traversing without having to allocate some state management for that.\n\t *\n\t * Another approach, of using arrays of cursors for fields (like we currently\n\t * do for inserting content) is very inefficient and better addressed by a\n\t * dual mode cursor.\n\t *\n\t * Another approach, of using the first node in a field when referring to\n\t * the field gets confusing since it's unclear if a given cursor means that\n\t * node, or that node, and the ones after it, and in the second case, it's\n\t * hard to restore the cursor back to the right state when returning. It also\n\t * doesn't work for empty fields. Overall there just didn't seem to be a way\n\t * that sucked less than the dual mode API.\n\t */\n\treadonly mode: CursorLocationType;\n\n\t/*\n\t * True iff the current field or node (depending on mode) is \"pending\",\n\t * meaning that it has not been downloaded.\n\t */\n\treadonly pending: boolean;\n\n\t// ********** APIs for when mode = Fields ********** //\n\n\t/**\n\t * Moves the \"current field\" forward one in an arbitrary field traversal order,\n\t * skipping any empty fields.\n\t *\n\t * If there is no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * If skipPending, skip past fields which are currently pending.\n\t * This can be used to skip to the end of a large number of consecutive pending fields.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tnextField(): boolean;\n\n\t/**\n\t * Navigate up to parent node.\n\t * Sets mode to `Nodes`\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * TODO: what to do if at root?\n\t */\n\texitField(): void;\n\n\t/**\n\t * Moves the \"current field\" forward until `pending` is `false`.\n\t *\n\t * If there are no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tskipPendingFields(): boolean;\n\n\t// ********** APIs for when mode = Fields, and not pending ********** //\n\n\t/**\n\t * Returns the FieldKey for the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldKey(): FieldKey;\n\n\t/**\n\t * @returns the number of immediate children in the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldLength(): number;\n\n\t/**\n\t * Moves to the first node of the selected field, setting mode to `Nodes`.\n\t *\n\t * If field is empty, returns false instead.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tfirstNode(): boolean;\n\n\t/**\n\t * Sets current node to the node at the provided `index` of the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t * Sets mode to `Nodes`.\n\t */\n\tenterNode(childIndex: number): void;\n\n\t/**\n\t * Returns a path to the current field. See {@link FieldUpPath}.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link FieldUpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current field.\n\t */\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath;\n\n\t// ********** APIs for when mode = Nodes ********** //\n\n\t/**\n\t * Returns a path to the current node. See {@link UpPath}.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link UpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current node.\n\t */\n\tgetPath(prefix?: PathRootPrefix): UpPath | undefined;\n\n\t/**\n\t * Index (within its parent field) of the current node.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly fieldIndex: number;\n\n\t/**\n\t * Index (within its parent field) of the first node in the current chunk.\n\t * Always less than or equal to `currentIndexInField`.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkStart: number;\n\n\t/**\n\t * Length of current chunk.\n\t * Since an entire chunk always has the same `pending` value,\n\t * can be used to help skip over all of a pending chunk at once.\n\t *\n\t * TODO:\n\t * Add optional APIs to access underlying chunks so readers can\n\t * accelerate processing of chunk formats they understand.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkLength: number;\n\n\t/**\n\t * Moves `offset` nodes in the field.\n\t * If seeking to exactly past either end,\n\t * returns false and navigates up to the parent field (setting mode to `Fields`).\n\t *\n\t * Allowed if mode is `Nodes`.\n\t */\n\tseekNodes(offset: number): boolean;\n\n\t/**\n\t * The same as `seekNodes(1)`, but might be faster.\n\t */\n\tnextNode(): boolean;\n\n\t/**\n\t * Navigate up to parent field.\n\t * Sets mode to `Fields`\n\t *\n\t * Same as seek Number.POSITIVE_INFINITY, but only valid when `mode` is `Nodes`.\n\t *\n\t * TODO: what to do if at root?\n\t * TODO: Maybe merge with upToNode to make a single \"Up\"?\n\t */\n\texitNode(): void;\n\n\t// ********** APIs for when mode = Nodes and not pending ********** //\n\n\t/**\n\t * Enters the first non-empty field (setting mode to `Fields`)\n\t * so fields can be iterated with `nextField` and `skipPendingFields`.\n\t *\n\t * If there are no fields, mode is returned to `Nodes` and false is returned.\n\t *\n\t * Allowed when `mode` is `Nodes` and not `pending`.\n\t */\n\tfirstField(): boolean;\n\n\t/**\n\t * Navigate to the field with the specified `key` and set the mode to `Fields`.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * The type of the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly type: TreeType;\n\n\t/**\n\t * The value associated with the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly value: Value;\n}\n\n/**\n * Prefix to apply as the root of a {@link UpPath} or {@link FieldUpPath}.\n *\n * @remarks This can be used to take a path relative to a subtree, and make it relative to a larger containing tree.\n * For example, if a node is being inserted in the 5th position in a field \"Foo\", you can update a path in that node's subtree to its new path by prefixing it with\n * `{ parent: theNodeAboveTheMovedNode, rootFieldOverride: Foo, indexOffset: 5 }`.\n * See {@link prefixPath} and {@link prefixFieldPath} for how to apply the prefix to the paths.\n */\nexport interface PathRootPrefix {\n\t/**\n\t * The new parent to place above root of the path which is being prefixed.\n\t * This replaces the `undefined` at the root of the path.\n\t *\n\t * @remarks specifying `undefined` here results in no change to the path.\n\t */\n\tparent?: UpPath | undefined;\n\n\t/**\n\t * The field of `parent` that the original path will be included under.\n\t *\n\t * If `undefined` the root field key from the original path will be used.\n\t */\n\trootFieldOverride?: FieldKey;\n\n\t/**\n\t * Offset to add to the uppermost `parentIndex` in the original path.\n\t */\n\tindexOffset?: number;\n}\n\nexport const enum CursorLocationType {\n\t/**\n\t * Can iterate through nodes in a field.\n\t * At a \"current node\".\n\t */\n\tNodes,\n\n\t/**\n\t * Can iterate through fields of a node.\n\t * At a \"current field\".\n\t */\n\tFields,\n}\n\n/**\n * {@link ITreeCursor} that is never pending.\n */\nexport interface ITreeCursorSynchronous extends ITreeCursor {\n\treadonly pending: false;\n}\n\n/**\n * @param cursor - tree whose fields will be visited.\n * @param f - builds output from field, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each field of the current node on `cursor`.\n * Returns an empty array if the node is empty or not present (which are considered the same).\n * Note that order is not specified for field iteration.\n */\nexport function mapCursorFields<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachField(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * @param cursor - cursor at a node whose fields will be visited.\n * @param f - For on each field.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachField<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x411 /* should be in nodes */);\n\tfor (let inField = cursor.firstField(); inField; inField = cursor.nextField()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * @param cursor - tree whose field will be visited.\n * @param f - builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each item of the current field on `cursor`.\n * Returns an empty array if the field is empty or not present (which are considered the same).\n */\nexport function mapCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachNode(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * @param cursor - The tree whose field will be visited.\n * @param f - Builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns An iterable of `T` resulting from applying `f` to each item of the current field on `cursor`.\n * Yields nothing if an empty array if the field is empty or not present (which are considered the same).\n */\nexport function* iterateCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): IterableIterator<T> {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x7a8 /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tyield f(cursor);\n\t}\n}\n\n/**\n * @param cursor - cursor at a field whose nodes will be visited.\n * @param f - For on each node.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachNode<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x3bd /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * @param cursor - cursor at a field or node.\n * @param f - Function to invoke for each node.\n * If `f` moves the cursor, it must put it back to where it was at the beginning of `f` before returning.\n *\n * Invokes `f` on each node in the subtree rooted at the current field or node.\n * Traversal is pre-order.\n * If the cursor is at a node, `f` will be invoked on that node.\n *\n * Returns the `cursor` to its initial position.\n */\nexport function forEachNodeInSubtree<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tif (cursor.mode === CursorLocationType.Nodes) {\n\t\tf(cursor);\n\t\tforEachField(cursor, (c) => forEachNodeInSubtree(c, f));\n\t} else {\n\t\tforEachNode(cursor, (c) => forEachNodeInSubtree(c, f));\n\t}\n}\n\n/**\n * Casts a cursor to an {@link ITreeCursorSynchronous}.\n *\n * TODO: #1404: Handle this properly for partial data loading support.\n */\nexport function castCursorToSynchronous(cursor: ITreeCursor): ITreeCursorSynchronous {\n\treturn cursor as ITreeCursorSynchronous;\n}\n\n/**\n * Runs `f` inside of field `field` on `cursor`.\n * @param cursor - Cursor whose field to enter and exit. Must be in `nodes` mode.\n * @param field - Field to enter.\n * @param f - Callback to run when in field.\n * @returns return value of `f`\n */\nexport function inCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tfield: FieldKey,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterField(field);\n\tconst result = f(cursor);\n\tcursor.exitField();\n\treturn result;\n}\n\n/**\n * Runs `f` inside of node `index` on `cursor`.\n * @param cursor - Cursor whoso node to enter and exit. Must be in `fields` mode.\n * @param index - Node to enter.\n * @param f - Callback to run when in node.\n * @returns return value of `f`\n */\nexport function inCursorNode<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tindex: number,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterNode(index);\n\tconst result = f(cursor);\n\tcursor.exitNode();\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../src/core/tree/cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAO7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,cAAc,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAa;IACrC,sFAAsF;IACtF,6FAA6F;IAC7F,OAAO,CAC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AM,CAAC,CAAC;IACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AACf,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 { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { FieldUpPath, UpPath } from \"./pathTree.js\";\nimport type { TreeType, Value } from \"./types.js\";\n\n/**\n * A symbol for marking an object as an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport const CursorMarker: unique symbol = Symbol(\"CursorMarker\");\n\n/**\n * Check if something is an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport function isCursor(data: unknown): data is ITreeCursor {\n\t// Other than on null and undefined, looking up a missing symbol shouldn't type error.\n\t// typeof check deals with undefined while providing an early out for other non-object types.\n\treturn (\n\t\tdata !== null &&\n\t\ttypeof data === \"object\" &&\n\t\t(data as Partial<ITreeCursor>)[CursorMarker] === true\n\t);\n}\n\n/**\n * A stateful low-level interface for reading tree data.\n * *\n * @remarks Cursor exists so that specialized data formats can be viewed through\n * a common abstraction. This allows performance optimizations to be done based\n * on data.\n *\n * A tree cursor is similar to a database cursor in that it allows for the efficient\n * traversal over the contents of a tree. Note that unlike a database cursor,\n * tree cursors may be invalidated after any edit to the tree. For a cursor-like\n * structure that also remains valid across edits, see {@link AnchorNode}.\n */\nexport interface ITreeCursor {\n\t/**\n\t * Marks this object as a cursor.\n\t */\n\treadonly [CursorMarker]: true;\n\n\t/**\n\t * What kind of place the cursor is at.\n\t * Determines which operations are allowed.\n\t *\n\t * @remarks\n\t * Users of cursors frequently need to refer to places in trees, both fields and nodes.\n\t * Approaches other than having the cursor have separate modes for these\n\t * cases had issues even worse than having the two modes.\n\t *\n\t * For example, modeling fields as parent + key has issues when there is no\n\t * parent, and doesn't provide a great way to do iteration over fields while\n\t * also having a nice API and making it easy for the implementation to track\n\t * state (like its current location inside a sequence tree of fields) while\n\t * traversing without having to allocate some state management for that.\n\t *\n\t * Another approach, of using arrays of cursors for fields (like we currently\n\t * do for inserting content) is very inefficient and better addressed by a\n\t * dual mode cursor.\n\t *\n\t * Another approach, of using the first node in a field when referring to\n\t * the field gets confusing since it's unclear if a given cursor means that\n\t * node, or that node, and the ones after it, and in the second case, it's\n\t * hard to restore the cursor back to the right state when returning. It also\n\t * doesn't work for empty fields. Overall there just didn't seem to be a way\n\t * that sucked less than the dual mode API.\n\t */\n\treadonly mode: CursorLocationType;\n\n\t/*\n\t * True iff the current field or node (depending on mode) is \"pending\",\n\t * meaning that it has not been downloaded.\n\t */\n\treadonly pending: boolean;\n\n\t// ********** APIs for when mode = Fields ********** //\n\n\t/**\n\t * Moves the \"current field\" forward one in an arbitrary field traversal order,\n\t * skipping any empty fields.\n\t *\n\t * If there is no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * If skipPending, skip past fields which are currently pending.\n\t * This can be used to skip to the end of a large number of consecutive pending fields.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tnextField(): boolean;\n\n\t/**\n\t * Navigate up to parent node.\n\t * Sets mode to `Nodes`\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * TODO: what to do if at root?\n\t */\n\texitField(): void;\n\n\t/**\n\t * Moves the \"current field\" forward until `pending` is `false`.\n\t *\n\t * If there are no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tskipPendingFields(): boolean;\n\n\t// ********** APIs for when mode = Fields, and not pending ********** //\n\n\t/**\n\t * Returns the FieldKey for the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldKey(): FieldKey;\n\n\t/**\n\t * Returns the number of immediate children in the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldLength(): number;\n\n\t/**\n\t * Moves to the first node of the selected field, setting mode to `Nodes`.\n\t *\n\t * If field is empty, returns false instead.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tfirstNode(): boolean;\n\n\t/**\n\t * Sets current node to the node at the provided `index` of the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t * Sets mode to `Nodes`.\n\t */\n\tenterNode(childIndex: number): void;\n\n\t/**\n\t * Returns a path to the current field. See {@link FieldUpPath}.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link FieldUpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current field.\n\t */\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath;\n\n\t// ********** APIs for when mode = Nodes ********** //\n\n\t/**\n\t * Returns a path to the current node. See {@link UpPath}.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link UpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current node.\n\t */\n\tgetPath(prefix?: PathRootPrefix): UpPath | undefined;\n\n\t/**\n\t * Index (within its parent field) of the current node.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly fieldIndex: number;\n\n\t/**\n\t * Index (within its parent field) of the first node in the current chunk.\n\t * Always less than or equal to `currentIndexInField`.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkStart: number;\n\n\t/**\n\t * Length of current chunk.\n\t * Since an entire chunk always has the same `pending` value,\n\t * can be used to help skip over all of a pending chunk at once.\n\t *\n\t * TODO:\n\t * Add optional APIs to access underlying chunks so readers can\n\t * accelerate processing of chunk formats they understand.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkLength: number;\n\n\t/**\n\t * Moves `offset` nodes in the field.\n\t * If seeking to exactly past either end,\n\t * returns false and navigates up to the parent field (setting mode to `Fields`).\n\t *\n\t * Allowed if mode is `Nodes`.\n\t */\n\tseekNodes(offset: number): boolean;\n\n\t/**\n\t * The same as `seekNodes(1)`, but might be faster.\n\t */\n\tnextNode(): boolean;\n\n\t/**\n\t * Navigate up to parent field.\n\t * Sets mode to `Fields`\n\t *\n\t * Same as seek Number.POSITIVE_INFINITY, but only valid when `mode` is `Nodes`.\n\t *\n\t * TODO: what to do if at root?\n\t * TODO: Maybe merge with upToNode to make a single \"Up\"?\n\t */\n\texitNode(): void;\n\n\t// ********** APIs for when mode = Nodes and not pending ********** //\n\n\t/**\n\t * Enters the first non-empty field (setting mode to `Fields`)\n\t * so fields can be iterated with `nextField` and `skipPendingFields`.\n\t *\n\t * If there are no fields, mode is returned to `Nodes` and false is returned.\n\t *\n\t * Allowed when `mode` is `Nodes` and not `pending`.\n\t */\n\tfirstField(): boolean;\n\n\t/**\n\t * Navigate to the field with the specified `key` and set the mode to `Fields`.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * The type of the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly type: TreeType;\n\n\t/**\n\t * The value associated with the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly value: Value;\n}\n\n/**\n * Prefix to apply as the root of a {@link UpPath} or {@link FieldUpPath}.\n *\n * @remarks This can be used to take a path relative to a subtree, and make it relative to a larger containing tree.\n * For example, if a node is being inserted in the 5th position in a field \"Foo\", you can update a path in that node's subtree to its new path by prefixing it with\n * `{ parent: theNodeAboveTheMovedNode, rootFieldOverride: Foo, indexOffset: 5 }`.\n * See {@link prefixPath} and {@link prefixFieldPath} for how to apply the prefix to the paths.\n */\nexport interface PathRootPrefix {\n\t/**\n\t * The new parent to place above root of the path which is being prefixed.\n\t * This replaces the `undefined` at the root of the path.\n\t *\n\t * @remarks specifying `undefined` here results in no change to the path.\n\t */\n\tparent?: UpPath | undefined;\n\n\t/**\n\t * The field of `parent` that the original path will be included under.\n\t *\n\t * If `undefined` the root field key from the original path will be used.\n\t */\n\trootFieldOverride?: FieldKey;\n\n\t/**\n\t * Offset to add to the uppermost `parentIndex` in the original path.\n\t */\n\tindexOffset?: number;\n}\n\nexport const enum CursorLocationType {\n\t/**\n\t * Can iterate through nodes in a field.\n\t * At a \"current node\".\n\t */\n\tNodes,\n\n\t/**\n\t * Can iterate through fields of a node.\n\t * At a \"current field\".\n\t */\n\tFields,\n}\n\n/**\n * {@link ITreeCursor} that is never pending.\n */\nexport interface ITreeCursorSynchronous extends ITreeCursor {\n\treadonly pending: false;\n}\n\n/**\n * Applies a mapping function to each field of the current node, returning the results as an array.\n *\n * @param cursor - tree whose fields will be visited.\n * @param f - builds output from field, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each field of the current node on `cursor`.\n * Returns an empty array if the node is empty or not present (which are considered the same).\n * Note that order is not specified for field iteration.\n */\nexport function mapCursorFields<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachField(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * Iterates over each field of the current node, invoking a callback for each.\n *\n * @param cursor - cursor at a node whose fields will be visited.\n * @param f - For on each field.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachField<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x411 /* should be in nodes */);\n\tfor (let inField = cursor.firstField(); inField; inField = cursor.nextField()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * Applies a mapping function to each node of the current field, returning the results as an array.\n *\n * @param cursor - tree whose field will be visited.\n * @param f - builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each item of the current field on `cursor`.\n * Returns an empty array if the field is empty or not present (which are considered the same).\n */\nexport function mapCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachNode(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * Lazily iterates over each node in the current field, yielding the result of applying a mapping function to each.\n *\n * @param cursor - The tree whose field will be visited.\n * @param f - Builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns An iterable of `T` resulting from applying `f` to each item of the current field on `cursor`.\n * Yields nothing if an empty array if the field is empty or not present (which are considered the same).\n */\nexport function* iterateCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): IterableIterator<T> {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x7a8 /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tyield f(cursor);\n\t}\n}\n\n/**\n * Iterates over each node in the current field, invoking a callback for each.\n *\n * @param cursor - cursor at a field whose nodes will be visited.\n * @param f - For on each node.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachNode<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x3bd /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * Iterates over a subrange of nodes in the current field, invoking a callback for each.\n * See {@link forEachNode} for a version that visits all nodes in the field.\n *\n * @param cursor - cursor at a field whose nodes will be visited.\n * @param startIndex - index of first node to visit. Must be non-negative.\n * @param endIndex - index of first node to NOT visit. Must be greater than or equal to `startIndex`.\n * @param f - For on each node.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachNodeSubsequence<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tstartIndex: number,\n\tendIndex: number,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Fields, 0xce5 /* should be in fields */);\n\n\tassert(startIndex >= 0, 0xce6 /* invalid startIndex */);\n\tassert(endIndex >= startIndex, 0xce7 /* invalid endIndex */);\n\tconst outputLength = endIndex - startIndex;\n\tif (outputLength === 0) {\n\t\t// Avoids out of bounds index on cursor.enterNode when requesting 0 length subarray at end of array.\n\t\treturn;\n\t}\n\n\tcursor.enterNode(startIndex);\n\tfor (let i = 0; i < outputLength; i++) {\n\t\tf(cursor);\n\t\tconst hasNext = cursor.nextNode();\n\t\tif (!hasNext) {\n\t\t\tassert(i === outputLength - 1, 0xce8 /* requested endIndex is out of bounds */);\n\t\t\treturn;\n\t\t}\n\t}\n\tcursor.exitNode();\n}\n\n/**\n * Deeply iterates over each node in the current subtree (rooted at a node or field),\n * invoking a callback for each.\n *\n * @param cursor - cursor at a field or node.\n * @param f - Function to invoke for each node.\n * If `f` moves the cursor, it must put it back to where it was at the beginning of `f` before returning.\n *\n * Invokes `f` on each node in the subtree rooted at the current field or node.\n * Traversal is pre-order.\n * If the cursor is at a node, `f` will be invoked on that node.\n *\n * Returns the `cursor` to its initial position.\n */\nexport function forEachNodeInSubtree<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tif (cursor.mode === CursorLocationType.Nodes) {\n\t\tf(cursor);\n\t\tforEachField(cursor, (c) => forEachNodeInSubtree(c, f));\n\t} else {\n\t\tforEachNode(cursor, (c) => forEachNodeInSubtree(c, f));\n\t}\n}\n\n/**\n * Casts a cursor to an {@link ITreeCursorSynchronous}.\n *\n * TODO: #1404: Handle this properly for partial data loading support.\n */\nexport function castCursorToSynchronous(cursor: ITreeCursor): ITreeCursorSynchronous {\n\treturn cursor as ITreeCursorSynchronous;\n}\n\n/**\n * Runs `f` inside of field `field` on `cursor`.\n * @param cursor - Cursor whose field to enter and exit. Must be in `nodes` mode.\n * @param field - Field to enter.\n * @param f - Callback to run when in field.\n * @returns return value of `f`\n */\nexport function inCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tfield: FieldKey,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterField(field);\n\tconst result = f(cursor);\n\tcursor.exitField();\n\treturn result;\n}\n\n/**\n * Runs `f` inside of node `index` on `cursor`.\n * @param cursor - Cursor whoso node to enter and exit. Must be in `fields` mode.\n * @param index - Node to enter.\n * @param f - Callback to run when in node.\n * @returns return value of `f`\n */\nexport function inCursorNode<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tindex: number,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterNode(index);\n\tconst result = f(cursor);\n\tcursor.exitNode();\n\treturn result;\n}\n"]}
@@ -3,11 +3,23 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { TreeChunk } from "./chunk.js";
6
- import type { DetachedNodeId, Root } from "./delta.js";
6
+ import type { DetachedNodeId, FieldChanges, FieldMap, Root } from "./delta.js";
7
7
  export declare const emptyDelta: Root;
8
8
  export declare function deltaForRootInitialization(content: TreeChunk): Root;
9
9
  export declare function makeDetachedNodeId(major: DetachedNodeId["major"], minor: DetachedNodeId["minor"]): DetachedNodeId;
10
10
  export declare function offsetDetachId(id: DetachedNodeId, offset: number): DetachedNodeId;
11
11
  export declare function offsetDetachId(id: DetachedNodeId | undefined, offset: number): DetachedNodeId | undefined;
12
12
  export declare function areDetachedNodeIdsEqual(a: DetachedNodeId, b: DetachedNodeId): boolean;
13
+ /**
14
+ * Returns true if a delta field map contains any changes that would be visible in the document (eg, an insert, move, edit)
15
+ * @param fields - Delta FieldMap to check for visible changes
16
+ * @returns True if change map contains any changes that would be visible in the document, false otherwise
17
+ */
18
+ export declare function deltaFieldMapHasVisibleChanges(fields: FieldMap | undefined): boolean;
19
+ /**
20
+ * Returns true if the given field changes contains any changes that would be visible in the document (eg, an insert, move, edit)
21
+ * @param fieldChanges - Field changes to check for visible changes
22
+ * @returns True if the field changes contain any changes that would be visible in the document, false otherwise
23
+ */
24
+ export declare function deltaFieldChangesHaveVisibleChanges(fieldChanges: FieldChanges): boolean;
13
25
  //# sourceMappingURL=deltaUtil.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deltaUtil.d.ts","sourceRoot":"","sources":["../../../src/core/tree/deltaUtil.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAgB,IAAI,EAAE,MAAM,YAAY,CAAC;AAGrE,eAAO,MAAM,UAAU,EAAE,IAAS,CAAC;AAEnC,wBAAgB,0BAA0B,CAAC,OAAO,EA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IG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAUpF;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAYvF"}
@@ -36,4 +36,35 @@ export function offsetDetachId(id, offset) {
36
36
  export function areDetachedNodeIdsEqual(a, b) {
37
37
  return a.major === b.major && a.minor === b.minor;
38
38
  }
39
+ /**
40
+ * Returns true if a delta field map contains any changes that would be visible in the document (eg, an insert, move, edit)
41
+ * @param fields - Delta FieldMap to check for visible changes
42
+ * @returns True if change map contains any changes that would be visible in the document, false otherwise
43
+ */
44
+ export function deltaFieldMapHasVisibleChanges(fields) {
45
+ if (fields === undefined || fields.size === 0) {
46
+ return false;
47
+ }
48
+ for (const [, fieldChanges] of fields) {
49
+ if (deltaFieldChangesHaveVisibleChanges(fieldChanges)) {
50
+ return true;
51
+ }
52
+ }
53
+ return false;
54
+ }
55
+ /**
56
+ * Returns true if the given field changes contains any changes that would be visible in the document (eg, an insert, move, edit)
57
+ * @param fieldChanges - Field changes to check for visible changes
58
+ * @returns True if the field changes contain any changes that would be visible in the document, false otherwise
59
+ */
60
+ export function deltaFieldChangesHaveVisibleChanges(fieldChanges) {
61
+ for (const mark of fieldChanges.marks) {
62
+ if (mark.attach !== undefined ||
63
+ mark.detach !== undefined ||
64
+ deltaFieldMapHasVisibleChanges(mark.fields)) {
65
+ return true;
66
+ }
67
+ }
68
+ return false;
69
+ }
39
70
  //# sourceMappingURL=deltaUtil.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deltaUtil.js","sourceRoot":"","sources":["../../../src/core/tree/deltaUtil.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAS,EAAE,CAAC;AAEnC,MAAM,UAAU,0BAA0B,CAAC,OAAkB;IAC5D,IAAI,OAAO,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAS;QACnB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QACxC,MAAM,EAAE,IAAI,GAAG,CAAyB;YACvC,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;SAC/E,CAAC;KACF,CAAC;IACF,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CACjC,KAA8B,EAC9B,KAA8B;IAE9B,MAAM,GAAG,GAA4B,EAAE,KAAK,EAAE,CAAC;IAC/C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAOD,MAAM,UAAU,cAAc,CAC7B,EAA8B,EAC9B,MAAc;IAEd,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO;QACN,GAAG,EAAE;QACL,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM;KACxB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,CAAiB,EAAE,CAAiB;IAC3E,OAAO,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Mutable } from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport type { DetachedNodeId, FieldChanges, Root } from \"./delta.js\";\nimport { rootFieldKey } from \"./types.js\";\n\nexport const emptyDelta: Root = {};\n\nexport function deltaForRootInitialization(content: TreeChunk): Root {\n\tif (content.topLevelLength === 0) {\n\t\treturn emptyDelta;\n\t}\n\tconst buildId = { minor: 0 };\n\tconst delta: Root = {\n\t\tbuild: [{ id: buildId, trees: content }],\n\t\tfields: new Map<FieldKey, FieldChanges>([\n\t\t\t[rootFieldKey, { marks: [{ count: content.topLevelLength, attach: buildId }] }],\n\t\t]),\n\t};\n\treturn delta;\n}\n\nexport function makeDetachedNodeId(\n\tmajor: DetachedNodeId[\"major\"],\n\tminor: DetachedNodeId[\"minor\"],\n): DetachedNodeId {\n\tconst out: Mutable<DetachedNodeId> = { minor };\n\tif (major !== undefined) {\n\t\tout.major = major;\n\t}\n\treturn out;\n}\n\nexport function offsetDetachId(id: DetachedNodeId, offset: number): DetachedNodeId;\nexport function offsetDetachId(\n\tid: DetachedNodeId | undefined,\n\toffset: number,\n): DetachedNodeId | undefined;\nexport function offsetDetachId(\n\tid: DetachedNodeId | undefined,\n\toffset: number,\n): DetachedNodeId | undefined {\n\tif (id === undefined) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\t...id,\n\t\tminor: id.minor + offset,\n\t};\n}\n\nexport function areDetachedNodeIdsEqual(a: DetachedNodeId, b: DetachedNodeId): boolean {\n\treturn a.major === b.major && a.minor === b.minor;\n}\n"]}
1
+ {"version":3,"file":"deltaUtil.js","sourceRoot":"","sources":["../../../src/core/tree/deltaUtil.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAS,EAAE,CAAC;AAEnC,MAAM,UAAU,0BAA0B,CAAC,OAAkB;IAC5D,IAAI,OAAO,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;QAClC,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ACD,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,IAAI,MAAM,EAAE,CAAC;QACvC,IAAI,mCAAmC,CAAC,YAAY,CAAC,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CAAC,YAA0B;IAC7E,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;QACvC,IACC,IAAI,CAAC,MAAM,KAAK,SAAS;YACzB,IAAI,CAAC,MAAM,KAAK,SAAS;YACzB,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1C,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Mutable } from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport type { DetachedNodeId, FieldChanges, FieldMap, Root } from \"./delta.js\";\nimport { rootFieldKey } from \"./types.js\";\n\nexport const emptyDelta: Root = {};\n\nexport function deltaForRootInitialization(content: TreeChunk): Root {\n\tif (content.topLevelLength === 0) {\n\t\treturn emptyDelta;\n\t}\n\tconst buildId = { minor: 0 };\n\tconst delta: Root = {\n\t\tbuild: [{ id: buildId, trees: content }],\n\t\tfields: new Map<FieldKey, FieldChanges>([\n\t\t\t[rootFieldKey, { marks: [{ count: content.topLevelLength, attach: buildId }] }],\n\t\t]),\n\t};\n\treturn delta;\n}\n\nexport function makeDetachedNodeId(\n\tmajor: DetachedNodeId[\"major\"],\n\tminor: DetachedNodeId[\"minor\"],\n): DetachedNodeId {\n\tconst out: Mutable<DetachedNodeId> = { minor };\n\tif (major !== undefined) {\n\t\tout.major = major;\n\t}\n\treturn out;\n}\n\nexport function offsetDetachId(id: DetachedNodeId, offset: number): DetachedNodeId;\nexport function offsetDetachId(\n\tid: DetachedNodeId | undefined,\n\toffset: number,\n): DetachedNodeId | undefined;\nexport function offsetDetachId(\n\tid: DetachedNodeId | undefined,\n\toffset: number,\n): DetachedNodeId | undefined {\n\tif (id === undefined) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\t...id,\n\t\tminor: id.minor + offset,\n\t};\n}\n\nexport function areDetachedNodeIdsEqual(a: DetachedNodeId, b: DetachedNodeId): boolean {\n\treturn a.major === b.major && a.minor === b.minor;\n}\n\n/**\n * Returns true if a delta field map contains any changes that would be visible in the document (eg, an insert, move, edit)\n * @param fields - Delta FieldMap to check for visible changes\n * @returns True if change map contains any changes that would be visible in the document, false otherwise\n */\nexport function deltaFieldMapHasVisibleChanges(fields: FieldMap | undefined): boolean {\n\tif (fields === undefined || fields.size === 0) {\n\t\treturn false;\n\t}\n\tfor (const [, fieldChanges] of fields) {\n\t\tif (deltaFieldChangesHaveVisibleChanges(fieldChanges)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Returns true if the given field changes contains any changes that would be visible in the document (eg, an insert, move, edit)\n * @param fieldChanges - Field changes to check for visible changes\n * @returns True if the field changes contain any changes that would be visible in the document, false otherwise\n */\nexport function deltaFieldChangesHaveVisibleChanges(fieldChanges: FieldChanges): boolean {\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (\n\t\t\tmark.attach !== undefined ||\n\t\t\tmark.detach !== undefined ||\n\t\t\tdeltaFieldMapHasVisibleChanges(mark.fields)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"]}
@@ -3,10 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IIdCompressor } from "@fluidframework/id-compressor";
6
- import { ClientVersionDispatchingCodecBuilder, type CodecWriteOptions } from "../../codec/index.js";
6
+ import { ClientVersionDispatchingCodecBuilder, type ICodecOptions } from "../../codec/index.js";
7
7
  import type { RevisionTagCodec } from "../rebase/index.js";
8
- export declare const detachedFieldIndexCodecBuilder: ClientVersionDispatchingCodecBuilder<"DetachedFieldIndex", import("./detachedFieldIndexTypes.js").DetachedFieldSummaryData, void, import("../../util/brand.js").Brand<1, "DetachedFieldIndexFormatVersion"> | import("../../util/brand.js").Brand<2, "DetachedFieldIndexFormatVersion">, CodecWriteOptions & {
9
- revisionTagCodec: RevisionTagCodec;
10
- idCompressor: IIdCompressor;
11
- }>;
8
+ export declare const detachedFieldIndexCodecBuilder: ClientVersionDispatchingCodecBuilder<ICodecOptions & {
9
+ readonly revisionTagCodec: RevisionTagCodec;
10
+ readonly idCompressor: IIdCompressor;
11
+ }, import("./detachedFieldIndexTypes.js").DetachedFieldSummaryData, void, import("../../util/brand.js").Brand<1, "DetachedFieldIndexFormatVersion"> | import("../../util/brand.js").Brand<2, "DetachedFieldIndexFormatVersion">, "DetachedFieldIndex">;
12
12
  //# sourceMappingURL=detachedFieldIndexCodecs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"detachedFieldIndexCodecs.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EACN,oCAAoC,EACpC,KAAK,iBAAiB,EAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAW3D,eAAO,MAAM,8BAA8B;sBAJxB,gBAAgB;kBACpB,aAAa;EAmB3B,CAAC"}
1
+ {"version":3,"file":"detachedFieldIndexCodecs.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EACN,oCAAoC,EAEpC,KAAK,aAAa,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAW3D,eAAO,MAAM,8BAA8B;+BAJf,gBAAgB;2BACpB,aAAa;sPAmBpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EACN,oCAAoC,EAEpC,kBAAkB,GAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAOtF,MAAM,CAAC,MAAM,8BAA8B,GAAG,oCAAoC,CAAC,KAAK,CACvF,oBAAoB,EACpB;IACC;QACC,mBAAmB,EAAE,yBAAyB;QAC9C,aAAa,EAAE,+BAA+B,CAAC,EAAE;QACjD,KAAK,EAAE,CAAC,SAAoB,EAAE,EAAE,CAC/B,8BAA8B,CAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC;KACnF;IACD;QACC,mBAAmB,EAAE,kBAAkB,CAAC,KAAK;QAC7C,aAAa,EAAE,+BAA+B,CAAC,EAAE;QACjD,KAAK,EAAE,CAAC,SAAoB,EAAE,EAAE,CAC/B,8BAA8B,CAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC;KACnF;CACD,CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tClientVersionDispatchingCodecBuilder,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n} from \"../../codec/index.js\";\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\n\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\n\ntype BuildData = CodecWriteOptions & {\n\trevisionTagCodec: RevisionTagCodec;\n\tidCompressor: IIdCompressor;\n};\n\nexport const detachedFieldIndexCodecBuilder = ClientVersionDispatchingCodecBuilder.build(\n\t\"DetachedFieldIndex\",\n\t[\n\t\t{\n\t\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\t\tformatVersion: DetachedFieldIndexFormatVersion.v1,\n\t\t\tcodec: (buildData: BuildData) =>\n\t\t\t\tmakeDetachedNodeToFieldCodecV1(buildData.revisionTagCodec, buildData.idCompressor),\n\t\t},\n\t\t{\n\t\t\tminVersionForCollab: FluidClientVersion.v2_52,\n\t\t\tformatVersion: DetachedFieldIndexFormatVersion.v2,\n\t\t\tcodec: (buildData: BuildData) =>\n\t\t\t\tmakeDetachedNodeToFieldCodecV2(buildData.revisionTagCodec, buildData.idCompressor),\n\t\t},\n\t],\n);\n"]}
1
+ {"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EACN,oCAAoC,EACpC,kBAAkB,GAElB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAOtF,MAAM,CAAC,MAAM,8BAA8B,GAAG,oCAAoC,CAAC,KAAK,CACvF,oBAAoB,EACpB;IACC;QACC,mBAAmB,EAAE,yBAAyB;QAC9C,aAAa,EAAE,+BAA+B,CAAC,EAAE;QACjD,KAAK,EAAE,CAAC,SAAoB,EAAE,EAAE,CAC/B,8BAA8B,CAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC;KACnF;IACD;QACC,mBAAmB,EAAE,kBAAkB,CAAC,KAAK;QAC7C,aAAa,EAAE,+BAA+B,CAAC,EAAE;QACjD,KAAK,EAAE,CAAC,SAAoB,EAAE,EAAE,CAC/B,8BAA8B,CAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC;KACnF;CACD,CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { lowestMinVersionForCollab } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tClientVersionDispatchingCodecBuilder,\n\tFluidClientVersion,\n\ttype ICodecOptions,\n} from \"../../codec/index.js\";\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\n\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\n\ntype BuildData = ICodecOptions & {\n\treadonly revisionTagCodec: RevisionTagCodec;\n\treadonly idCompressor: IIdCompressor;\n};\n\nexport const detachedFieldIndexCodecBuilder = ClientVersionDispatchingCodecBuilder.build(\n\t\"DetachedFieldIndex\",\n\t[\n\t\t{\n\t\t\tminVersionForCollab: lowestMinVersionForCollab,\n\t\t\tformatVersion: DetachedFieldIndexFormatVersion.v1,\n\t\t\tcodec: (buildData: BuildData) =>\n\t\t\t\tmakeDetachedNodeToFieldCodecV1(buildData.revisionTagCodec, buildData.idCompressor),\n\t\t},\n\t\t{\n\t\t\tminVersionForCollab: FluidClientVersion.v2_52,\n\t\t\tformatVersion: DetachedFieldIndexFormatVersion.v2,\n\t\t\tcodec: (buildData: BuildData) =>\n\t\t\t\tmakeDetachedNodeToFieldCodecV2(buildData.revisionTagCodec, buildData.idCompressor),\n\t\t},\n\t],\n);\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { type Anchor, type AnchorLocator, AnchorSet, type AnchorSlot, type AnchorNode, anchorSlot, type AnchorEvents, type AnchorSetRootEvents, } from "./anchorSet.js";
6
- export { type ITreeCursor, CursorLocationType, castCursorToSynchronous, mapCursorField, mapCursorFields, forEachNode, forEachNodeInSubtree, forEachField, iterateCursorField, type ITreeCursorSynchronous, type PathRootPrefix, inCursorField, inCursorNode, CursorMarker, isCursor, } from "./cursor.js";
6
+ export { type ITreeCursor, CursorLocationType, castCursorToSynchronous, mapCursorField, mapCursorFields, forEachNode, forEachNodeInSubtree, forEachField, iterateCursorField, type ITreeCursorSynchronous, type PathRootPrefix, inCursorField, inCursorNode, CursorMarker, isCursor, forEachNodeSubsequence, } from "./cursor.js";
7
7
  export type { ProtoNodes, Root as DeltaRoot, Mark as DeltaMark, DetachedNodeId as DeltaDetachedNodeId, FieldMap as DeltaFieldMap, DetachedNodeChanges as DeltaDetachedNodeChanges, DetachedNodeBuild as DeltaDetachedNodeBuild, DetachedNodeDestruction as DeltaDetachedNodeDestruction, DetachedNodeRename as DeltaDetachedNodeRename, FieldChanges as DeltaFieldChanges, } from "./delta.js";
8
8
  export { type MapTree, type ExclusiveMapTree, deepCopyMapTree } from "./mapTree.js";
9
9
  export { clonePath, topDownPath, getDepth, type UpPath, type NormalizedUpPath, type INormalizedUpPath, type NormalizedFieldUpPath, type FieldUpPath, type Range, type RangeUpPath, type PlaceUpPath, type PlaceIndex, type NodeIndex, compareUpPaths, compareFieldUpPaths, isDetachedUpPathRoot as isDetachedUpPath, getDetachedFieldContainingPath, type UpPathDefault, } from "./pathTree.js";
@@ -13,7 +13,7 @@ export { EmptyKey, type TreeType, type ChildLocation, type DetachedField, type C
13
13
  export { type DeltaVisitor, visitDelta } from "./visitDelta.js";
14
14
  export { type AnnouncedVisitor, announceDelta, applyDelta, createAnnouncedVisitor, combineVisitors, makeDetachedFieldIndex, } from "./visitorUtils.js";
15
15
  export { SparseNode, getDescendant } from "./sparseTree.js";
16
- export { deltaForRootInitialization, makeDetachedNodeId, offsetDetachId, emptyDelta, } from "./deltaUtil.js";
16
+ export { deltaForRootInitialization, makeDetachedNodeId, offsetDetachId, emptyDelta, areDetachedNodeIdsEqual, deltaFieldMapHasVisibleChanges, deltaFieldChangesHaveVisibleChanges, } from "./deltaUtil.js";
17
17
  export { type TreeChunk, dummyRoot, cursorChunk, tryGetChunk, type ChunkedCursor, } from "./chunk.js";
18
18
  export { DetachedFieldIndex, type DetachedFieldIndexCheckpoint, type ReadOnlyDetachedFieldIndex, } from "./detachedFieldIndex.js";
19
19
  export { detachedFieldIndexCodecBuilder } from "./detachedFieldIndexCodecs.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,SAAS,EACT,KAAK,UAAU,EACf,KAAK,UAAU,EACf,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,WAAW,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,GACR,MAAM,aAAa,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E,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACN,KAAK,gBAAgB,EACrB,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,UAAU,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,KAAK,aAAa,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,GAC/B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,SAAS,EACT,KAAK,UAAU,EACf,KAAK,UAAU,EACf,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,WAAW,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,sBAAsB,GACtB,MAAM,aA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EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACN,KAAK,gBAAgB,EACrB,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,mCAAmC,GACnC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,KAAK,aAAa,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,GAC/B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { AnchorSet, anchorSlot, } from "./anchorSet.js";
6
- export { CursorLocationType, castCursorToSynchronous, mapCursorField, mapCursorFields, forEachNode, forEachNodeInSubtree, forEachField, iterateCursorField, inCursorField, inCursorNode, CursorMarker, isCursor, } from "./cursor.js";
6
+ export { CursorLocationType, castCursorToSynchronous, mapCursorField, mapCursorFields, forEachNode, forEachNodeInSubtree, forEachField, iterateCursorField, inCursorField, inCursorNode, CursorMarker, isCursor, forEachNodeSubsequence, } from "./cursor.js";
7
7
  export { deepCopyMapTree } from "./mapTree.js";
8
8
  export { clonePath, topDownPath, getDepth, compareUpPaths, compareFieldUpPaths, isDetachedUpPathRoot as isDetachedUpPath, getDetachedFieldContainingPath, } from "./pathTree.js";
9
9
  export { genericTreeDeleteIfEmpty, genericTreeKeys, getGenericTreeField, setGenericTreeField, } from "./treeTextFormat.js";
@@ -12,7 +12,7 @@ export { EmptyKey, detachedFieldAsKey, keyAsDetachedField, rootFieldKey, rootFie
12
12
  export { visitDelta } from "./visitDelta.js";
13
13
  export { announceDelta, applyDelta, createAnnouncedVisitor, combineVisitors, makeDetachedFieldIndex, } from "./visitorUtils.js";
14
14
  export { SparseNode, getDescendant } from "./sparseTree.js";
15
- export { deltaForRootInitialization, makeDetachedNodeId, offsetDetachId, emptyDelta, } from "./deltaUtil.js";
15
+ export { deltaForRootInitialization, makeDetachedNodeId, offsetDetachId, emptyDelta, areDetachedNodeIdsEqual, deltaFieldMapHasVisibleChanges, deltaFieldChangesHaveVisibleChanges, } from "./deltaUtil.js";
16
16
  export { dummyRoot, cursorChunk, tryGetChunk, } from "./chunk.js";
17
17
  export { DetachedFieldIndex, } from "./detachedFieldIndex.js";
18
18
  export { detachedFieldIndexCodecBuilder } from "./detachedFieldIndexCodecs.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,SAAS,EAGT,UAAU,GAGV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEN,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAGlB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,GACR,MAAM,aAAa,CAAC;AAarB,OAAO,EAAuC,eAAe,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EAWR,cAAc,EACd,mBAAmB,EACnB,oBAAoB,IAAI,gBAAgB,EACxC,8BAA8B,GAE9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAGN,wBAAwB,EACxB,eAAe,EAEf,mBAAmB,EAEnB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,QAAQ,EAQR,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EAEZ,SAAS,EACT,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAqB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAEN,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,UAAU,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEN,SAAS,EACT,WAAW,EACX,WAAW,GAEX,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,kBAAkB,GAGlB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC","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,OAAO,EAGN,SAAS,EAGT,UAAU,GAGV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEN,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAGlB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,sBAAsB,GACtB,MAAM,aAAa,CAAC;AAarB,OAAO,EAAuC,eAAe,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EAWR,cAAc,EACd,mBAAmB,EACnB,oBAAoB,IAAI,gBAAgB,EACxC,8BAA8B,GAE9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAGN,wBAAwB,EACxB,eAAe,EAEf,mBAAmB,EAEnB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,QAAQ,EAQR,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EAEZ,SAAS,EACT,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAqB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAEN,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,mCAAmC,GACnC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEN,SAAS,EACT,WAAW,EACX,WAAW,GAEX,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,kBAAkB,GAGlB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC","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\tforEachNodeSubsequence,\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\tareDetachedNodeIdsEqual,\n\tdeltaFieldMapHasVisibleChanges,\n\tdeltaFieldChangesHaveVisibleChanges,\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"]}
@@ -127,5 +127,16 @@ export interface DeltaVisitor {
127
127
  * @remarks This should only be called when the "current location" is a Field.
128
128
  */
129
129
  exitField(key: FieldKey): void;
130
+ /**
131
+ * Optional hook for obtaining the complete ordered change description for a field, suitable
132
+ * for producing positional deltas for external representations (e.g. a text editor or virtual
133
+ * list) without needing to diff the old and new states.
134
+ * @remarks
135
+ * Called once per field per delta, during the first (detach) pass only, after `enterField` but
136
+ * before any `attach`, `detach`, or `enterNode` calls for the field. Firing only during the
137
+ * detach pass ensures marks are always relative to the original array positions rather than an
138
+ * intermediate partially-transformed state.
139
+ */
140
+ fieldMarks?(marks: readonly Delta.Mark[]): void;
130
141
  }
131
142
  //# sourceMappingURL=visitDelta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.d.ts","sourceR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K,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IACvE;;;;;;;;;OASG;IACH,MAAM,CACL,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,QAAQ,EACrB,EAAE,EAAE,KAAK,CAAC,cAAc,EACxB,UAAU,EAAE,OAAO,GACjB,IAAI,CAAC;IAER;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAElC;;;;;;;OAOG;IACH,QAAQ,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;IAE/B;;;;;;;;;OASG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;CAChD"}
@@ -165,7 +165,6 @@ function transferRoots(rootTransfers, mapToUpdate, detachedFieldIndex, visitor,
165
165
  delayed.push({ oldId, newId });
166
166
  continue;
167
167
  }
168
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- intentional behavior
169
168
  newRootId = detachedFieldIndex.createEntry(newId, revision);
170
169
  const fields = mapToUpdate.get(oldRootId);
171
170
  if (fields !== undefined) {
@@ -205,6 +204,7 @@ function visitNode(index, fields, visitor, config) {
205
204
  * - Executes detaches (bottom-up)
206
205
  */
207
206
  function detachPass(fieldChanges, visitor, config) {
207
+ visitor.fieldMarks?.(fieldChanges.marks);
208
208
  let index = 0;
209
209
  for (const mark of fieldChanges.marks) {
210
210
  if (mark.fields !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/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AAC,CAAC;gBACjE,CAAC;gBACD,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;gBACrE,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,CAAC;gBAC9B,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC5C,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBACtD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACtD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC1B,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;oBAC1C,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;gBACjD,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { RevisionTag } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { areDetachedNodeIdsEqual, offsetDetachId } from \"./deltaUtil.js\";\nimport type { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId, Major, Minor } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detached field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n *\n * The details of the delta visit algorithm can impact how/when events are emitted by the objects that own the visitors.\n * For example, as of 2024-03-27, the subtreeChanged event of an AnchorNode is emitted when exiting a node during a\n * delta visit, and thus the two-pass nature of the algorithm means the event fires twice for any given change.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n * @param latestRevision - The latest revision tag associated with this delta.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous> = new Map();\n\tfor (const {\n\t\tid: { major, minor },\n\t\ttrees,\n\t} of delta.refreshers ?? []) {\n\t\tconst treeCursors = nodeCursorsFromChunk(trees);\n\t\tfor (let i = 0; i < trees.topLevelLength; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, treeCursors[i]);\n\t\t}\n\t}\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tprocessGlobal(delta.global, detachConfig, visitor);\n\tprocessRename(delta.rename, detachConfig);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(\n\t\trootTransfers,\n\t\tattachPassRoots,\n\t\tdetachedFieldIndex,\n\t\tvisitor,\n\t\trefreshers,\n\t\tlatestRevision,\n\t);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n): void {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * This occurs in the following circumstances:\n * - A changeset moves then removes a node\n * - A changeset restores then moves a node\n * - A changeset restores then removes a node\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n\trefreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>,\n\trevision?: RevisionTag,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\">;\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tatomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId } of nextBatch) {\n\t\t\tlet oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);\n\t\t\t\tif (tree !== undefined) {\n\t\t\t\t\tbuildTrees(oldId, [tree], detachedFieldIndex, revision, visitor);\n\t\t\t\t\toldRootId = detachedFieldIndex.getEntry(oldId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- intentional behavior\n\t\t\tnewRootId = detachedFieldIndex.createEntry(newId, revision);\n\t\t\tconst fields = mapToUpdate.get(oldRootId);\n\t\t\tif (fields !== undefined) {\n\t\t\t\tmapToUpdate.delete(oldRootId);\n\t\t\t\tmapToUpdate.set(newRootId, fields);\n\t\t\t}\n\t\t\tconst oldField = detachedFieldIndex.toFieldKey(oldRootId);\n\t\t\tconst newField = detachedFieldIndex.toFieldKey(newRootId);\n\t\t\tvisitor.enterField(oldField);\n\t\t\tvisitor.detach({ start: 0, end: 1 }, newField, newId, false);\n\t\t\tvisitor.exitField(oldField);\n\t\t\tdetachedFieldIndex.deleteEntry(oldId);\n\t\t}\n\t\tassert(delayed.length < priorSize, 0x7cf /* transferRoots should make progress */);\n\t\tnextBatch = delayed;\n\t}\n}\n\n/**\n * Visitor for changes in a delta.\n * Must be freed after use.\n */\nexport interface DeltaVisitor {\n\t/**\n\t * Frees/releases the visitor.\n\t *\n\t * Must be called once the visitor finished traversing the delta for a couple of reasons:\n\t *\n\t * 1. Some visitors, such as those from forests, are put into a special mode while they have a visitor, forbidding some actions (like making more visitors).\n\t *\n\t * 2. Some visitors, such as those from an anchorSet, defer some events for batching purposes until the visitor is freed.\n\t */\n\tfree(): void;\n\t/**\n\t * Creates nodes for the given content in a new detached field.\n\t * @param content - The content to create.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t */\n\tcreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\t/**\n\t * Recursively destroys the given detached field and all of the nodes within it.\n\t * @param detachedField - The key for the detached field to destroy.\n\t * @param count - The number of nodes being destroyed.\n\t * Expected to match the number of nodes in the detached field being destroyed.\n\t */\n\tdestroy(detachedField: FieldKey, count: number): void;\n\t/**\n\t * Transfers all the nodes from a detached field to the current field.\n\t * @param source - The detached field to transfer the nodes from.\n\t * @param count - The number of nodes being attached.\n\t * Expected to match the number of nodes in the source detached field.\n\t * @param destination - The index at which to attach the nodes.\n\t */\n\tattach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\t/**\n\t * Transfers a range of nodes from the current field to a new detached field.\n\t * @param source - The bounds of the range of nodes to detach.\n\t * @param destination - The key for a new detached field.\n\t * A field with this key must not already exist.\n\t * @param id - The ID assigned to the first detached node as a result of the detach. The other nodes in the detached range are assigned subsequent IDs.\n\t * @param isReplaced - Whether the detached content will be replaced by a later attach.\n\t * This is not guaranteed to be true in all cases where it could be true,\n\t * but it is guaranteed to be true in all cases where a later attach is needed to keep the data compliant with the schema.\n\t */\n\tdetach(\n\t\tsource: Range,\n\t\tdestination: FieldKey,\n\t\tid: Delta.DetachedNodeId,\n\t\tisReplaced: boolean,\n\t): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node at the specified index\n\t * within the Field that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within the Field) of the node that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\tenterNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field which contains the Node\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param index - The index (within its Field) of the node that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\texitNode(index: NodeIndex): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Field with the specified key,\n\t * within the Node that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that should become the new \"current location\".\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Node.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * Tells the visitor that it should update its \"current location\" to be the Node which contains the Field\n\t * that is the current \"current location\".\n\t * Future calls to methods of {@link DeltaVisitor} will assume that's the location where their effects are happening.\n\t * @param key - The key of the field that is being exited.\n\t *\n\t * @remarks This should only be called when the \"current location\" is a Field.\n\t */\n\texitField(key: FieldKey): void;\n}\n\ninterface PassConfig {\n\treadonly func: Pass;\n\n\t/**\n\t * The latest revision tag associated with the given delta. This is used to keep track\n\t * of when repair data should be garbage collected.\n\t */\n\treadonly latestRevision: RevisionTag | undefined;\n\n\treadonly detachedFieldIndex: DetachedFieldIndex;\n\t/**\n\t * A mapping between forest root id and trees that represent refresher data. Each entry is only\n\t * created in the forest once needed.\n\t */\n\treadonly refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the detach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t */\n\treadonly detachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Nested changes on roots that need to be visited as part of the attach pass.\n\t * Each entry is removed when its associated changes are visited.\n\t * Some of these roots will attached during the attach pass, in which case the nested changes are visited after\n\t * the node is attached.\n\t * Some of these nodes will never be attached, in which case we visit them in their detached fields at the end of\n\t * the attach pass. Note that such a visit might lead to more nodes being attached, including nodes were visited as\n\t * roots.\n\t */\n\treadonly attachPassRoots: Map<ForestRootId, Delta.FieldMap>;\n\t/**\n\t * Represents transfers of roots from one detached field to another.\n\t */\n\treadonly rootTransfers: Delta.DetachedNodeRename[];\n\t/**\n\t * Represents roots that need to be destroyed.\n\t * Collected as part of the detach pass.\n\t * Carried out at the end of the attach pass.\n\t */\n\treadonly rootDestructions: Delta.DetachedNodeDestruction[];\n}\n\ntype Pass = (delta: Delta.FieldChanges, visitor: DeltaVisitor, config: PassConfig) => void;\n\nfunction visitFieldMarks(\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tfor (const [key, field] of fields) {\n\t\t\tvisitor.enterField(key);\n\t\t\tconfig.func(field, visitor, config);\n\t\t\tvisitor.exitField(key);\n\t\t}\n\t}\n}\n\nfunction visitNode(\n\tindex: number,\n\tfields: Delta.FieldMap | undefined,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tif (fields !== undefined) {\n\t\tvisitor.enterNode(index);\n\t\tvisitFieldMarks(fields, visitor, config);\n\t\tvisitor.exitNode(index);\n\t}\n}\n\n/**\n * Performs the following:\n * - Collects all roots that may need an attach pass\n * - Executes detaches (bottom-up)\n */\nfunction detachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.fields !== undefined) {\n\t\t\tassert(\n\t\t\t\tmark.attach === undefined || mark.detach !== undefined,\n\t\t\t\t0x7d0 /* Invalid nested changes on an additive mark */,\n\t\t\t);\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst id = offsetDetachId(mark.detach, i);\n\t\t\t\tconst root = config.detachedFieldIndex.createEntry(id, config.latestRevision);\n\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.set(root, mark.fields);\n\t\t\t\t}\n\t\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\t\tvisitor.detach({ start: index, end: index + 1 }, field, id, mark.attach !== undefined);\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.attach === undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\nfunction buildTrees(\n\tid: Delta.DetachedNodeId,\n\ttrees: readonly ITreeCursorSynchronous[],\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n\tvisitor: DeltaVisitor,\n): void {\n\tfor (const [i, tree] of trees.entries()) {\n\t\tconst offsettedId = offsetDetachId(id, i);\n\t\tlet root = detachedFieldIndex.tryGetEntry(offsettedId);\n\t\tassert(root === undefined, 0x929 /* Unable to build tree that already exists */);\n\t\troot = detachedFieldIndex.createEntry(offsettedId, latestRevision);\n\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\tvisitor.create([tree], field);\n\t}\n}\n\nfunction processBuilds(\n\tbuilds: readonly Delta.DetachedNodeBuild[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (builds !== undefined) {\n\t\tfor (const { id, trees } of builds) {\n\t\t\tbuildTrees(\n\t\t\t\tid,\n\t\t\t\tnodeCursorsFromChunk(trees),\n\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\tconfig.latestRevision,\n\t\t\t\tvisitor,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction processGlobal(\n\tglobal: readonly Delta.DetachedNodeChanges[] | undefined,\n\tconfig: PassConfig,\n\tvisitor: DeltaVisitor,\n): void {\n\tif (global !== undefined) {\n\t\tfor (const { id, fields } of global) {\n\t\t\tlet root = config.detachedFieldIndex.tryGetEntry(id);\n\t\t\tif (root === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(config.refreshers, id.major, id.minor);\n\t\t\t\tassert(tree !== undefined, 0x928 /* refresher data not found */);\n\t\t\t\tbuildTrees(id, [tree], config.detachedFieldIndex, config.latestRevision, visitor);\n\t\t\t\troot = config.detachedFieldIndex.getEntry(id);\n\t\t\t}\n\t\t\t// the revision is updated for any refresher data included in the delta that is used\n\t\t\tconfig.detachedFieldIndex.updateLatestRevision(id, config.latestRevision);\n\t\t\tconfig.detachPassRoots.set(root, fields);\n\t\t\tconfig.attachPassRoots.set(root, fields);\n\t\t}\n\t}\n}\n\nfunction processRename(\n\trename: readonly Delta.DetachedNodeRename[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (rename !== undefined) {\n\t\tconfig.rootTransfers.push(...rename);\n\t}\n}\n\nfunction collectDestroys(\n\tdestroys: readonly Delta.DetachedNodeDestruction[] | undefined,\n\tconfig: PassConfig,\n): void {\n\tif (destroys !== undefined) {\n\t\tconfig.rootDestructions.push(...destroys);\n\t}\n}\n\n/**\n * Preforms the following:\n * - Executes attaches (top-down) applying nested changes on the attached nodes\n */\nfunction attachPass(\n\tfieldChanges: Delta.FieldChanges,\n\tvisitor: DeltaVisitor,\n\tconfig: PassConfig,\n): void {\n\tlet index = 0;\n\tfor (const mark of fieldChanges.marks) {\n\t\tif (mark.attach !== undefined) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\tconst offsetAttachId = offsetDetachId(mark.attach, i);\n\t\t\t\tlet sourceRoot = config.detachedFieldIndex.tryGetEntry(offsetAttachId);\n\t\t\t\tif (sourceRoot === undefined) {\n\t\t\t\t\tconst tree = tryGetFromNestedMap(\n\t\t\t\t\t\tconfig.refreshers,\n\t\t\t\t\t\toffsetAttachId.major,\n\t\t\t\t\t\toffsetAttachId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(tree !== undefined, 0x92a /* refresher data not found */);\n\t\t\t\t\tbuildTrees(\n\t\t\t\t\t\toffsetAttachId,\n\t\t\t\t\t\t[tree],\n\t\t\t\t\t\tconfig.detachedFieldIndex,\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t\tvisitor,\n\t\t\t\t\t);\n\t\t\t\t\tsourceRoot = config.detachedFieldIndex.getEntry(offsetAttachId);\n\t\t\t\t}\n\t\t\t\tconst sourceField = config.detachedFieldIndex.toFieldKey(sourceRoot);\n\t\t\t\tconst offsetIndex = index + i;\n\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\tconfig.detachedFieldIndex.deleteEntry(offsetAttachId);\n\t\t\t\tconst fields = config.attachPassRoots.get(sourceRoot);\n\t\t\t\tif (fields !== undefined) {\n\t\t\t\t\tconfig.attachPassRoots.delete(sourceRoot);\n\t\t\t\t\tvisitNode(offsetIndex, fields, visitor, config);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (mark.detach === undefined && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (mark.detach === undefined || mark.attach !== undefined) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\n}\n\n/**\n * Converts a chunk of trees into an array of cursors.\n *\n * TODO: Update the visitDelta logic and downstream APIs to avoid splitting up sequences into individual nodes.\n */\nfunction nodeCursorsFromChunk(trees: TreeChunk): ITreeCursorSynchronous[] {\n\treturn mapCursorField(trees.cursor(), (c) => c.fork());\n}\n"]}
1
+ {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAkB,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1F,OAAO,EAAE,cAAc,EAA+B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACzB,KAAiB,EACjB,OAAqB,EACrB,kBAAsC,EACtC,cAAuC;IAEvC,MAAM,eAAe,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrE,MAAM,eAAe,GAAsC,IAAI,GAAG,EAAE,CAAC;IACrE,MAAM,aAAa,GAA+B,EAAE,CAAC;IACrD,MAAM,gBAAgB,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,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C;IACF,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAgB;IAC7C,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { RevisionTag } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { TreeChunk } from \"./chunk.js\";\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { areDetachedNodeIdsEqual, offsetDetachId } from \"./deltaUtil.js\";\nimport type { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId, Major, Minor } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\n\n/**\n * Implementation notes:\n *\n * The visit is organized into four phases:\n * 1. a detach pass\n * 2. root transfers\n * 3. an attach pass\n * 4. root destructions\n *\n * The core idea is that before content can be attached, it must first exist and be in a detached field.\n *\n * While the detach pass ensures that nodes to be attached are in a detached state, it does not guarantee that they\n * reside in the correct detached field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches.\n *\n * After the attach phase, roots destruction is carried out.\n * This needs to happen last to allow modifications to detached roots to be applied before they are destroyed.\n *\n * The details of the delta visit algorithm can impact how/when events are emitted by the objects that own the visitors.\n * For example, as of 2024-03-27, the subtreeChanged event of an AnchorNode is emitted when exiting a node during a\n * delta visit, and thus the two-pass nature of the algorithm means the event fires twice for any given change.\n */\n\n/**\n * Crawls the given `delta`, calling `visitor`'s callback for each change encountered.\n * Each successive call to the visitor callbacks assumes that the change described by earlier calls have been applied\n * to the document tree. For example, for a change that removes the first and third node of a field, the visitor calls\n * will first call detach with a range from indices 0 to 1 then call detach with a range from indices 1 to 2.\n *\n * @param delta - The delta to be crawled.\n * @param visitor - The object to notify of the changes encountered.\n * @param detachedFieldIndex - Index responsible for keeping track of the existing detached fields.\n * @param latestRevision - The latest revision tag associated with this delta.\n */\nexport function visitDelta(\n\tdelta: Delta.Root,\n\tvisitor: DeltaVisitor,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tlatestRevision: RevisionTag | undefined,\n): void {\n\tconst detachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst attachPassRoots: Map<ForestRootId, Delta.FieldMap> = new Map();\n\tconst rootTransfers: Delta.DetachedNodeRename[] = [];\n\tconst rootDestructions: Delta.DetachedNodeDestruction[] = [];\n\tconst refreshers: NestedMap<Major, Minor, ITreeCursorSynchronous> = new Map();\n\tfor (const {\n\t\tid: { major, minor },\n\t\ttrees,\n\t} of delta.refreshers ?? []) {\n\t\tconst treeCursors = nodeCursorsFromChunk(trees);\n\t\tfor (let i = 0; i < trees.topLevelLength; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, treeCursors[i]);\n\t\t}\n\t}\n\tconst detachConfig: PassConfig = {\n\t\tfunc: detachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tprocessBuilds(delta.build, detachConfig, visitor);\n\tprocessGlobal(delta.global, detachConfig, visitor);\n\tprocessRename(delta.rename, detachConfig);\n\tvisitFieldMarks(delta.fields, visitor, detachConfig);\n\tfixedPointVisitOfRoots(visitor, detachPassRoots, detachConfig);\n\ttransferRoots(\n\t\trootTransfers,\n\t\tattachPassRoots,\n\t\tdetachedFieldIndex,\n\t\tvisitor,\n\t\trefreshers,\n\t\tlatestRevision,\n\t);\n\tconst attachConfig: PassConfig = {\n\t\tfunc: attachPass,\n\t\tlatestRevision,\n\t\trefreshers,\n\t\tdetachedFieldIndex,\n\t\tdetachPassRoots,\n\t\tattachPassRoots,\n\t\trootTransfers,\n\t\trootDestructions,\n\t};\n\tvisitFieldMarks(delta.fields, visitor, attachConfig);\n\tfixedPointVisitOfRoots(visitor, attachPassRoots, attachConfig);\n\tcollectDestroys(delta.destroy, attachConfig);\n\tfor (const { id, count } of rootDestructions) {\n\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\tconst offsetId = offsetDetachId(id, i);\n\t\t\tconst root = detachedFieldIndex.getEntry(offsetId);\n\t\t\tconst field = detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.destroy(field, 1);\n\t\t\tdetachedFieldIndex.deleteEntry(offsetId);\n\t\t}\n\t}\n}\n\n/**\n * Visits all nodes in `roots` until none are left.\n * This function tolerates entries being added to and removed from `roots` as part of visits.\n * @param visitor - The visitor to visit the roots with.\n * @param roots - The initial set of roots to visit.\n * Individual entries are removed prior to being visited.\n * @param config - The configuration to use for visits.\n */\nfunction fixedPointVisitOfRoots(\n\tvisitor: DeltaVisitor,\n\troots: Map<ForestRootId, Delta.FieldMap>,\n\tconfig: PassConfig,\n): void {\n\twhile (roots.size > 0) {\n\t\tfor (const [root, modifications] of roots) {\n\t\t\troots.delete(root);\n\t\t\tconst field = config.detachedFieldIndex.toFieldKey(root);\n\t\t\tvisitor.enterField(field);\n\t\t\t// Note: each visit may lead to `roots` being populated with new entries or having some entries removed.\n\t\t\tvisitNode(0, modifications, visitor, config);\n\t\t\tvisitor.exitField(field);\n\t\t}\n\t}\n}\n\n/**\n * Transfers roots from one detached field to another.\n * This occurs in the following circumstances:\n * - A changeset moves then removes a node\n * - A changeset restores then moves a node\n * - A changeset restores then removes a node\n * TODO#5481: update the DetachedFieldIndex instead of moving the nodes around.\n *\n * @param rootTransfers - The transfers to perform.\n * @param mapToUpdate - A map to update based on the transfers being performed.\n * @param detachedFieldIndex - The index to update based on the transfers being performed.\n * @param visitor - The visitor to inform of the transfers being performed.\n */\nfunction transferRoots(\n\trootTransfers: readonly Delta.DetachedNodeRename[],\n\tmapToUpdate: Map<ForestRootId, unknown>,\n\tdetachedFieldIndex: DetachedFieldIndex,\n\tvisitor: DeltaVisitor,\n\trefreshers: NestedMap<Major, Minor, ITreeCursorSynchronous>,\n\trevision?: RevisionTag,\n): void {\n\ttype AtomizedNodeRename = Omit<Delta.DetachedNodeRename, \"count\">;\n\tlet nextBatch = rootTransfers.flatMap(({ oldId, newId, count }) => {\n\t\tconst atomized: AtomizedNodeRename[] = [];\n\t\t// It's possible for a detached node to be revived transiently such that it ends up back in the same detached field.\n\t\t// Making such a transfer wouldn't just be inefficient, it would lead us to mistakenly think we have moved all content\n\t\t// out of the source detached field, and would lead us to delete the tree index entry for that source detached field.\n\t\t// This would effectively result in the tree index missing an entry for the detached field.\n\t\t// This if statement prevents that from happening.\n\t\tif (!areDetachedNodeIdsEqual(oldId, newId)) {\n\t\t\tfor (let i = 0; i < count; i += 1) {\n\t\t\t\tatomized.push({ oldId: offsetDetachId(oldId, i), newId: offsetDetachId(newId, i) });\n\t\t\t}\n\t\t}\n\t\treturn atomized;\n\t});\n\twhile (nextBatch.length > 0) {\n\t\tconst delayed: AtomizedNodeRename[] = [];\n\t\tconst priorSize = nextBatch.length;\n\t\tfor (const { oldId, newId } of nextBatch) {\n\t\t\tlet oldRootId = detachedFieldIndex.tryGetEntry(oldId);\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\tconst tree = tryGetFromNestedMap(refreshers, oldId.major, oldId.minor);\n\t\t\t\tif (tree !== undefined) {\n\t\t\t\t\tbuildTrees(oldId, [tree], detachedFieldIndex, revision, visitor);\n\t\t\t\t\toldRootId = detachedFieldIndex.getEntry(oldId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldRootId === undefined) {\n\t\t\t\t// The source field is not populated.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet newRootId = detachedFieldIndex.tryGetEntry(newId);\n\t\t\tif (newRootId !== undefined) {\n\t\t\t\t// The destination field is already occupied.\n\t\t\t\t// This can happen when another rename needs to be performed first.\n\t\t\t\tdelayed.push({ oldId, newId });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\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\t/**\n\t * Optional hook for obtaining the complete ordered change description for a field, suitable\n\t * for producing positional deltas for external representations (e.g. a text editor or virtual\n\t * list) without needing to diff the old and new states.\n\t * @remarks\n\t * Called once per field per delta, during the first (detach) pass only, after `enterField` but\n\t * before any `attach`, `detach`, or `enterNode` calls for the field. Firing only during the\n\t * detach pass ensures marks are always relative to the original array positions rather than an\n\t * intermediate partially-transformed state.\n\t */\n\tfieldMarks?(marks: readonly Delta.Mark[]): 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\tvisitor.fieldMarks?.(fieldChanges.marks);\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 +1 @@
1
- {"version":3,"file":"visitorUtils.d.ts","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO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ACrF,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACpD,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IAC7E,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;IACxD,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9E,WAAW,CACV,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,QAAQ,EACrB,UAAU,EAAE,OAAO,GACjB,IAAI,CAAC;CACR;AAID;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACzC,gBAAgB,CAmBlB"}
@@ -95,6 +95,11 @@ export function combineVisitors(visitors) {
95
95
  v.exitField(...args);
96
96
  }
97
97
  },
98
+ fieldMarks: (marks) => {
99
+ for (const v of allVisitors) {
100
+ v.fieldMarks?.(marks);
101
+ }
102
+ },
98
103
  };
99
104
  }
100
105
  const noOp = () => { };