@fluidframework/tree 2.23.0 → 2.30.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 (619) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/api-report/tree.alpha.api.md +28 -12
  3. package/dist/alpha.d.ts +6 -0
  4. package/dist/core/forest/editableForest.d.ts +1 -14
  5. package/dist/core/forest/editableForest.d.ts.map +1 -1
  6. package/dist/core/forest/editableForest.js +1 -28
  7. package/dist/core/forest/editableForest.js.map +1 -1
  8. package/dist/core/forest/forest.d.ts +16 -3
  9. package/dist/core/forest/forest.d.ts.map +1 -1
  10. package/dist/core/forest/forest.js +4 -1
  11. package/dist/core/forest/forest.js.map +1 -1
  12. package/dist/core/forest/index.d.ts +1 -1
  13. package/dist/core/forest/index.d.ts.map +1 -1
  14. package/dist/core/forest/index.js +1 -2
  15. package/dist/core/forest/index.js.map +1 -1
  16. package/dist/core/index.d.ts +2 -2
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +3 -3
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/tree/anchorSet.d.ts +8 -3
  21. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  22. package/dist/core/tree/anchorSet.js +12 -5
  23. package/dist/core/tree/anchorSet.js.map +1 -1
  24. package/dist/core/tree/delta.d.ts +8 -23
  25. package/dist/core/tree/delta.d.ts.map +1 -1
  26. package/dist/core/tree/delta.js.map +1 -1
  27. package/dist/core/tree/deltaUtil.d.ts +3 -3
  28. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  29. package/dist/core/tree/deltaUtil.js +2 -2
  30. package/dist/core/tree/deltaUtil.js.map +1 -1
  31. package/dist/core/tree/index.d.ts +2 -2
  32. package/dist/core/tree/index.d.ts.map +1 -1
  33. package/dist/core/tree/index.js +2 -1
  34. package/dist/core/tree/index.js.map +1 -1
  35. package/dist/core/tree/pathTree.d.ts +54 -1
  36. package/dist/core/tree/pathTree.d.ts.map +1 -1
  37. package/dist/core/tree/pathTree.js +8 -1
  38. package/dist/core/tree/pathTree.js.map +1 -1
  39. package/dist/core/tree/visitDelta.d.ts +7 -5
  40. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  41. package/dist/core/tree/visitDelta.js +19 -9
  42. package/dist/core/tree/visitDelta.js.map +1 -1
  43. package/dist/core/tree/visitorUtils.d.ts +5 -23
  44. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  45. package/dist/core/tree/visitorUtils.js +8 -5
  46. package/dist/core/tree/visitorUtils.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  48. package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
  49. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  51. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/chunkTree.js +10 -7
  53. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  55. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/chunkedForest.js +5 -2
  57. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  59. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  65. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  67. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  68. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/uniformChunk.js +3 -2
  70. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  71. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  72. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  74. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  75. package/dist/feature-libraries/default-schema/index.d.ts +1 -0
  76. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.js +3 -1
  78. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  79. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  80. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  81. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +57 -0
  82. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  83. package/dist/feature-libraries/deltaUtils.js +1 -1
  84. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  85. package/dist/feature-libraries/flex-tree/context.d.ts +5 -5
  86. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  87. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  88. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  89. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  90. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  91. package/dist/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  92. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  93. package/dist/feature-libraries/flex-tree/lazyField.js +9 -6
  94. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  95. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  96. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -5
  97. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  98. package/dist/feature-libraries/index.d.ts +2 -1
  99. package/dist/feature-libraries/index.d.ts.map +1 -1
  100. package/dist/feature-libraries/index.js +9 -7
  101. package/dist/feature-libraries/index.js.map +1 -1
  102. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  103. package/dist/feature-libraries/initializeForest.d.ts +18 -0
  104. package/dist/feature-libraries/initializeForest.d.ts.map +1 -0
  105. package/dist/feature-libraries/initializeForest.js +35 -0
  106. package/dist/feature-libraries/initializeForest.js.map +1 -0
  107. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  108. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +9 -15
  110. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  111. package/dist/feature-libraries/node-identifier/index.d.ts +8 -0
  112. package/dist/feature-libraries/node-identifier/index.d.ts.map +1 -0
  113. package/dist/feature-libraries/node-identifier/index.js +16 -0
  114. package/dist/feature-libraries/node-identifier/index.js.map +1 -0
  115. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  116. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  117. package/dist/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +18 -18
  118. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  119. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  120. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  121. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +26 -0
  122. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  123. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  124. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  125. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +48 -0
  126. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  127. package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -1
  128. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  129. package/dist/feature-libraries/object-forest/objectForest.js +6 -2
  130. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  131. package/dist/feature-libraries/treeCursorUtils.js +1 -1
  132. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  133. package/dist/index.d.ts +3 -3
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +9 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/packageVersion.d.ts +1 -1
  138. package/dist/packageVersion.js +1 -1
  139. package/dist/packageVersion.js.map +1 -1
  140. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  141. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  142. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  143. package/dist/shared-tree/independentView.d.ts.map +1 -1
  144. package/dist/shared-tree/independentView.js +3 -18
  145. package/dist/shared-tree/independentView.js.map +1 -1
  146. package/dist/shared-tree/index.d.ts +1 -1
  147. package/dist/shared-tree/index.d.ts.map +1 -1
  148. package/dist/shared-tree/index.js +2 -1
  149. package/dist/shared-tree/index.js.map +1 -1
  150. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  151. package/dist/shared-tree/schematizeTree.js +3 -2
  152. package/dist/shared-tree/schematizeTree.js.map +1 -1
  153. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  154. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  155. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  156. package/dist/shared-tree/sharedTree.d.ts +1 -0
  157. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  158. package/dist/shared-tree/sharedTree.js +11 -7
  159. package/dist/shared-tree/sharedTree.js.map +1 -1
  160. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  161. package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
  162. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  163. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  164. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  165. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  166. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  167. package/dist/shared-tree/treeApiAlpha.d.ts +6 -31
  168. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  169. package/dist/shared-tree/treeApiAlpha.js +3 -18
  170. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  171. package/dist/shared-tree/treeCheckout.js +1 -1
  172. package/dist/shared-tree/treeCheckout.js.map +1 -1
  173. package/dist/simple-tree/api/conciseTree.d.ts +8 -2
  174. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  175. package/dist/simple-tree/api/conciseTree.js +10 -1
  176. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  177. package/dist/simple-tree/api/create.d.ts +3 -3
  178. package/dist/simple-tree/api/create.d.ts.map +1 -1
  179. package/dist/simple-tree/api/create.js.map +1 -1
  180. package/dist/simple-tree/api/customTree.d.ts +42 -12
  181. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  182. package/dist/simple-tree/api/customTree.js +30 -2
  183. package/dist/simple-tree/api/customTree.js.map +1 -1
  184. package/dist/simple-tree/api/index.d.ts +4 -3
  185. package/dist/simple-tree/api/index.d.ts.map +1 -1
  186. package/dist/simple-tree/api/index.js +6 -1
  187. package/dist/simple-tree/api/index.js.map +1 -1
  188. package/dist/simple-tree/api/schemaFactory.d.ts +12 -9
  189. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  190. package/dist/simple-tree/api/schemaFactory.js +16 -26
  191. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  192. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
  193. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  194. package/dist/simple-tree/api/schemaFactoryAlpha.js +9 -0
  195. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  196. package/dist/simple-tree/api/schemaFromSimple.d.ts +19 -0
  197. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  198. package/dist/simple-tree/api/schemaFromSimple.js +60 -0
  199. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -0
  200. package/dist/simple-tree/api/simpleSchema.d.ts +3 -0
  201. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  202. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  203. package/dist/simple-tree/api/tree.d.ts +11 -5
  204. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  205. package/dist/simple-tree/api/tree.js +11 -2
  206. package/dist/simple-tree/api/tree.js.map +1 -1
  207. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  208. package/dist/simple-tree/api/treeNodeApi.js +2 -17
  209. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  210. package/dist/simple-tree/api/typesUnsafe.d.ts +15 -15
  211. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  212. package/dist/simple-tree/api/verboseTree.d.ts +16 -25
  213. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  214. package/dist/simple-tree/api/verboseTree.js +15 -10
  215. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  216. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  217. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  218. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  219. package/dist/simple-tree/flexList.d.ts +4 -5
  220. package/dist/simple-tree/flexList.d.ts.map +1 -1
  221. package/dist/simple-tree/flexList.js +1 -14
  222. package/dist/simple-tree/flexList.js.map +1 -1
  223. package/dist/simple-tree/index.d.ts +2 -2
  224. package/dist/simple-tree/index.d.ts.map +1 -1
  225. package/dist/simple-tree/index.js +7 -2
  226. package/dist/simple-tree/index.js.map +1 -1
  227. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  228. package/dist/simple-tree/objectNode.js +2 -0
  229. package/dist/simple-tree/objectNode.js.map +1 -1
  230. package/dist/simple-tree/schemaTypes.d.ts +34 -2
  231. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  232. package/dist/simple-tree/schemaTypes.js +55 -2
  233. package/dist/simple-tree/schemaTypes.js.map +1 -1
  234. package/dist/simple-tree/toMapTree.d.ts +4 -4
  235. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  236. package/dist/simple-tree/toMapTree.js.map +1 -1
  237. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  238. package/dist/simple-tree/toStoredSchema.js +1 -5
  239. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  240. package/dist/simple-tree/treeNodeValid.d.ts +7 -1
  241. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  242. package/dist/simple-tree/treeNodeValid.js +13 -5
  243. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  244. package/dist/util/cloneWithReplacements.d.ts +21 -0
  245. package/dist/util/cloneWithReplacements.d.ts.map +1 -0
  246. package/dist/util/cloneWithReplacements.js +38 -0
  247. package/dist/util/cloneWithReplacements.js.map +1 -0
  248. package/dist/util/index.d.ts +1 -0
  249. package/dist/util/index.d.ts.map +1 -1
  250. package/dist/util/index.js +3 -1
  251. package/dist/util/index.js.map +1 -1
  252. package/dist/util/referenceCounting.d.ts +18 -0
  253. package/dist/util/referenceCounting.d.ts.map +1 -1
  254. package/dist/util/referenceCounting.js.map +1 -1
  255. package/lib/alpha.d.ts +6 -0
  256. package/lib/core/forest/editableForest.d.ts +1 -14
  257. package/lib/core/forest/editableForest.d.ts.map +1 -1
  258. package/lib/core/forest/editableForest.js +0 -26
  259. package/lib/core/forest/editableForest.js.map +1 -1
  260. package/lib/core/forest/forest.d.ts +16 -3
  261. package/lib/core/forest/forest.d.ts.map +1 -1
  262. package/lib/core/forest/forest.js +4 -1
  263. package/lib/core/forest/forest.js.map +1 -1
  264. package/lib/core/forest/index.d.ts +1 -1
  265. package/lib/core/forest/index.d.ts.map +1 -1
  266. package/lib/core/forest/index.js +1 -1
  267. package/lib/core/forest/index.js.map +1 -1
  268. package/lib/core/index.d.ts +2 -2
  269. package/lib/core/index.d.ts.map +1 -1
  270. package/lib/core/index.js +2 -2
  271. package/lib/core/index.js.map +1 -1
  272. package/lib/core/tree/anchorSet.d.ts +8 -3
  273. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  274. package/lib/core/tree/anchorSet.js +12 -5
  275. package/lib/core/tree/anchorSet.js.map +1 -1
  276. package/lib/core/tree/delta.d.ts +8 -23
  277. package/lib/core/tree/delta.d.ts.map +1 -1
  278. package/lib/core/tree/delta.js.map +1 -1
  279. package/lib/core/tree/deltaUtil.d.ts +3 -3
  280. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  281. package/lib/core/tree/deltaUtil.js +2 -2
  282. package/lib/core/tree/deltaUtil.js.map +1 -1
  283. package/lib/core/tree/index.d.ts +2 -2
  284. package/lib/core/tree/index.d.ts.map +1 -1
  285. package/lib/core/tree/index.js +1 -1
  286. package/lib/core/tree/index.js.map +1 -1
  287. package/lib/core/tree/pathTree.d.ts +54 -1
  288. package/lib/core/tree/pathTree.d.ts.map +1 -1
  289. package/lib/core/tree/pathTree.js +6 -0
  290. package/lib/core/tree/pathTree.js.map +1 -1
  291. package/lib/core/tree/visitDelta.d.ts +7 -5
  292. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  293. package/lib/core/tree/visitDelta.js +19 -9
  294. package/lib/core/tree/visitDelta.js.map +1 -1
  295. package/lib/core/tree/visitorUtils.d.ts +5 -23
  296. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  297. package/lib/core/tree/visitorUtils.js +8 -5
  298. package/lib/core/tree/visitorUtils.js.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  300. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  301. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  302. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  303. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/chunkTree.js +11 -8
  305. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  307. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -3
  309. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  310. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  316. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  317. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  319. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  320. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  321. package/lib/feature-libraries/chunked-forest/uniformChunk.js +3 -2
  322. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  324. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  325. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  326. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  327. package/lib/feature-libraries/default-schema/index.d.ts +1 -0
  328. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  329. package/lib/feature-libraries/default-schema/index.js +1 -0
  330. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  331. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  332. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  333. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +53 -0
  334. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  335. package/lib/feature-libraries/deltaUtils.js +1 -1
  336. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  337. package/lib/feature-libraries/flex-tree/context.d.ts +5 -5
  338. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  339. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  340. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  341. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  342. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  343. package/lib/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  344. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  345. package/lib/feature-libraries/flex-tree/lazyField.js +11 -8
  346. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  347. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  348. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  349. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  350. package/lib/feature-libraries/index.d.ts +2 -1
  351. package/lib/feature-libraries/index.d.ts.map +1 -1
  352. package/lib/feature-libraries/index.js +2 -1
  353. package/lib/feature-libraries/index.js.map +1 -1
  354. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  355. package/lib/feature-libraries/initializeForest.d.ts +18 -0
  356. package/lib/feature-libraries/initializeForest.d.ts.map +1 -0
  357. package/lib/feature-libraries/initializeForest.js +31 -0
  358. package/lib/feature-libraries/initializeForest.js.map +1 -0
  359. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  360. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  361. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +10 -16
  362. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  363. package/lib/feature-libraries/node-identifier/index.d.ts +8 -0
  364. package/lib/feature-libraries/node-identifier/index.d.ts.map +1 -0
  365. package/lib/feature-libraries/node-identifier/index.js +8 -0
  366. package/lib/feature-libraries/node-identifier/index.js.map +1 -0
  367. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  368. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  369. package/lib/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +16 -16
  370. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  371. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  372. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  373. package/lib/feature-libraries/node-identifier/nodeIdentifier.js +22 -0
  374. package/lib/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  375. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  376. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  377. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +43 -0
  378. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  379. package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -1
  380. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  381. package/lib/feature-libraries/object-forest/objectForest.js +6 -2
  382. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  383. package/lib/feature-libraries/treeCursorUtils.js +1 -1
  384. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  385. package/lib/index.d.ts +3 -3
  386. package/lib/index.d.ts.map +1 -1
  387. package/lib/index.js +2 -1
  388. package/lib/index.js.map +1 -1
  389. package/lib/packageVersion.d.ts +1 -1
  390. package/lib/packageVersion.js +1 -1
  391. package/lib/packageVersion.js.map +1 -1
  392. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  393. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  394. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  395. package/lib/shared-tree/independentView.d.ts.map +1 -1
  396. package/lib/shared-tree/independentView.js +5 -20
  397. package/lib/shared-tree/independentView.js.map +1 -1
  398. package/lib/shared-tree/index.d.ts +1 -1
  399. package/lib/shared-tree/index.d.ts.map +1 -1
  400. package/lib/shared-tree/index.js +1 -1
  401. package/lib/shared-tree/index.js.map +1 -1
  402. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  403. package/lib/shared-tree/schematizeTree.js +3 -2
  404. package/lib/shared-tree/schematizeTree.js.map +1 -1
  405. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  406. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  407. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  408. package/lib/shared-tree/sharedTree.d.ts +1 -0
  409. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  410. package/lib/shared-tree/sharedTree.js +9 -6
  411. package/lib/shared-tree/sharedTree.js.map +1 -1
  412. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  413. package/lib/shared-tree/sharedTreeChangeFamily.js +1 -1
  414. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  415. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  416. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  417. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  418. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  419. package/lib/shared-tree/treeApiAlpha.d.ts +6 -31
  420. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  421. package/lib/shared-tree/treeApiAlpha.js +3 -18
  422. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  423. package/lib/shared-tree/treeCheckout.js +2 -2
  424. package/lib/shared-tree/treeCheckout.js.map +1 -1
  425. package/lib/simple-tree/api/conciseTree.d.ts +8 -2
  426. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  427. package/lib/simple-tree/api/conciseTree.js +9 -1
  428. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  429. package/lib/simple-tree/api/create.d.ts +3 -3
  430. package/lib/simple-tree/api/create.d.ts.map +1 -1
  431. package/lib/simple-tree/api/create.js.map +1 -1
  432. package/lib/simple-tree/api/customTree.d.ts +42 -12
  433. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  434. package/lib/simple-tree/api/customTree.js +29 -2
  435. package/lib/simple-tree/api/customTree.js.map +1 -1
  436. package/lib/simple-tree/api/index.d.ts +4 -3
  437. package/lib/simple-tree/api/index.d.ts.map +1 -1
  438. package/lib/simple-tree/api/index.js +4 -3
  439. package/lib/simple-tree/api/index.js.map +1 -1
  440. package/lib/simple-tree/api/schemaFactory.d.ts +12 -9
  441. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  442. package/lib/simple-tree/api/schemaFactory.js +14 -23
  443. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  444. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +7 -0
  445. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  446. package/lib/simple-tree/api/schemaFactoryAlpha.js +9 -0
  447. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  448. package/lib/simple-tree/api/schemaFromSimple.d.ts +19 -0
  449. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  450. package/lib/simple-tree/api/schemaFromSimple.js +56 -0
  451. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -0
  452. package/lib/simple-tree/api/simpleSchema.d.ts +3 -0
  453. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  454. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  455. package/lib/simple-tree/api/tree.d.ts +11 -5
  456. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  457. package/lib/simple-tree/api/tree.js +12 -3
  458. package/lib/simple-tree/api/tree.js.map +1 -1
  459. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  460. package/lib/simple-tree/api/treeNodeApi.js +4 -19
  461. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  462. package/lib/simple-tree/api/typesUnsafe.d.ts +15 -15
  463. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  464. package/lib/simple-tree/api/verboseTree.d.ts +16 -25
  465. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  466. package/lib/simple-tree/api/verboseTree.js +14 -10
  467. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  468. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  469. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  470. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  471. package/lib/simple-tree/flexList.d.ts +4 -5
  472. package/lib/simple-tree/flexList.d.ts.map +1 -1
  473. package/lib/simple-tree/flexList.js +0 -12
  474. package/lib/simple-tree/flexList.js.map +1 -1
  475. package/lib/simple-tree/index.d.ts +2 -2
  476. package/lib/simple-tree/index.d.ts.map +1 -1
  477. package/lib/simple-tree/index.js +2 -2
  478. package/lib/simple-tree/index.js.map +1 -1
  479. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  480. package/lib/simple-tree/objectNode.js +2 -0
  481. package/lib/simple-tree/objectNode.js.map +1 -1
  482. package/lib/simple-tree/schemaTypes.d.ts +34 -2
  483. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  484. package/lib/simple-tree/schemaTypes.js +54 -3
  485. package/lib/simple-tree/schemaTypes.js.map +1 -1
  486. package/lib/simple-tree/toMapTree.d.ts +4 -4
  487. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  488. package/lib/simple-tree/toMapTree.js.map +1 -1
  489. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  490. package/lib/simple-tree/toStoredSchema.js +3 -7
  491. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  492. package/lib/simple-tree/treeNodeValid.d.ts +7 -1
  493. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  494. package/lib/simple-tree/treeNodeValid.js +13 -5
  495. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  496. package/lib/util/cloneWithReplacements.d.ts +21 -0
  497. package/lib/util/cloneWithReplacements.d.ts.map +1 -0
  498. package/lib/util/cloneWithReplacements.js +34 -0
  499. package/lib/util/cloneWithReplacements.js.map +1 -0
  500. package/lib/util/index.d.ts +1 -0
  501. package/lib/util/index.d.ts.map +1 -1
  502. package/lib/util/index.js +1 -0
  503. package/lib/util/index.js.map +1 -1
  504. package/lib/util/referenceCounting.d.ts +18 -0
  505. package/lib/util/referenceCounting.d.ts.map +1 -1
  506. package/lib/util/referenceCounting.js.map +1 -1
  507. package/package.json +22 -22
  508. package/src/core/forest/editableForest.ts +1 -52
  509. package/src/core/forest/forest.ts +17 -2
  510. package/src/core/forest/index.ts +0 -1
  511. package/src/core/index.ts +4 -2
  512. package/src/core/tree/anchorSet.ts +41 -10
  513. package/src/core/tree/delta.ts +8 -25
  514. package/src/core/tree/deltaUtil.ts +5 -5
  515. package/src/core/tree/index.ts +4 -1
  516. package/src/core/tree/pathTree.ts +72 -1
  517. package/src/core/tree/visitDelta.ts +38 -17
  518. package/src/core/tree/visitorUtils.ts +22 -36
  519. package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
  520. package/src/feature-libraries/chunked-forest/chunkTree.ts +19 -8
  521. package/src/feature-libraries/chunked-forest/chunkedForest.ts +9 -4
  522. package/src/feature-libraries/chunked-forest/codec/README.md +3 -3
  523. package/src/feature-libraries/chunked-forest/codec/codecs.ts +1 -1
  524. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +1 -1
  525. package/src/feature-libraries/chunked-forest/uniformChunk.ts +3 -2
  526. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -38
  527. package/src/feature-libraries/default-schema/index.ts +2 -0
  528. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +68 -0
  529. package/src/feature-libraries/deltaUtils.ts +1 -1
  530. package/src/feature-libraries/flex-tree/context.ts +4 -4
  531. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -2
  532. package/src/feature-libraries/flex-tree/lazyField.ts +19 -10
  533. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -9
  534. package/src/feature-libraries/index.ts +10 -8
  535. package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
  536. package/src/feature-libraries/initializeForest.ts +55 -0
  537. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +12 -28
  538. package/src/feature-libraries/node-identifier/README.md +11 -0
  539. package/src/feature-libraries/node-identifier/index.ts +17 -0
  540. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +59 -0
  541. package/src/feature-libraries/node-identifier/nodeIdentifier.ts +50 -0
  542. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +95 -0
  543. package/src/feature-libraries/object-forest/objectForest.ts +10 -3
  544. package/src/feature-libraries/treeCursorUtils.ts +1 -1
  545. package/src/index.ts +17 -10
  546. package/src/packageVersion.ts +1 -1
  547. package/src/shared-tree/checkoutFlexTreeView.ts +2 -2
  548. package/src/shared-tree/independentView.ts +5 -29
  549. package/src/shared-tree/index.ts +1 -0
  550. package/src/shared-tree/schematizeTree.ts +3 -2
  551. package/src/shared-tree/schematizingTreeView.ts +3 -3
  552. package/src/shared-tree/sharedTree.ts +13 -9
  553. package/src/shared-tree/sharedTreeChangeFamily.ts +0 -1
  554. package/src/shared-tree/sharedTreeEditBuilder.ts +5 -11
  555. package/src/shared-tree/treeApiAlpha.ts +15 -78
  556. package/src/shared-tree/treeCheckout.ts +2 -2
  557. package/src/simple-tree/api/conciseTree.ts +25 -8
  558. package/src/simple-tree/api/create.ts +3 -3
  559. package/src/simple-tree/api/customTree.ts +59 -16
  560. package/src/simple-tree/api/index.ts +10 -1
  561. package/src/simple-tree/api/schemaFactory.ts +18 -32
  562. package/src/simple-tree/api/schemaFactoryAlpha.ts +12 -0
  563. package/src/simple-tree/api/schemaFromSimple.ts +68 -0
  564. package/src/simple-tree/api/simpleSchema.ts +10 -0
  565. package/src/simple-tree/api/tree.ts +13 -8
  566. package/src/simple-tree/api/treeNodeApi.ts +4 -17
  567. package/src/simple-tree/api/typesUnsafe.ts +15 -15
  568. package/src/simple-tree/api/verboseTree.ts +43 -55
  569. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
  570. package/src/simple-tree/flexList.ts +4 -14
  571. package/src/simple-tree/index.ts +6 -0
  572. package/src/simple-tree/objectNode.ts +3 -0
  573. package/src/simple-tree/schemaTypes.ts +70 -4
  574. package/src/simple-tree/toMapTree.ts +6 -6
  575. package/src/simple-tree/toStoredSchema.ts +3 -6
  576. package/src/simple-tree/treeNodeValid.ts +16 -5
  577. package/src/util/cloneWithReplacements.ts +41 -0
  578. package/src/util/index.ts +2 -0
  579. package/src/util/referenceCounting.ts +18 -1
  580. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  581. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  582. package/dist/feature-libraries/node-key/index.d.ts +0 -8
  583. package/dist/feature-libraries/node-key/index.d.ts.map +0 -1
  584. package/dist/feature-libraries/node-key/index.js +0 -16
  585. package/dist/feature-libraries/node-key/index.js.map +0 -1
  586. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  587. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  588. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  589. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -38
  590. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  591. package/dist/feature-libraries/node-key/nodeKey.js +0 -26
  592. package/dist/feature-libraries/node-key/nodeKey.js.map +0 -1
  593. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  594. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  595. package/dist/feature-libraries/node-key/nodeKeyManager.js +0 -48
  596. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  597. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  598. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  599. package/lib/feature-libraries/node-key/index.d.ts +0 -8
  600. package/lib/feature-libraries/node-key/index.d.ts.map +0 -1
  601. package/lib/feature-libraries/node-key/index.js +0 -8
  602. package/lib/feature-libraries/node-key/index.js.map +0 -1
  603. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  604. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  605. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  606. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -38
  607. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  608. package/lib/feature-libraries/node-key/nodeKey.js +0 -22
  609. package/lib/feature-libraries/node-key/nodeKey.js.map +0 -1
  610. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  611. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  612. package/lib/feature-libraries/node-key/nodeKeyManager.js +0 -43
  613. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  614. package/src/feature-libraries/node-key/README.md +0 -11
  615. package/src/feature-libraries/node-key/index.ts +0 -17
  616. package/src/feature-libraries/node-key/mockNodeKeyManager.ts +0 -54
  617. package/src/feature-libraries/node-key/nodeKey.ts +0 -47
  618. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -93
  619. /package/src/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.ts → schemaBasedEncode.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"visitDelta.js","sourceRoot":"","sources":["../../../src/core/tree/visitDelta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAkB,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAS1F,OAAO,EACN,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,GACd,MAAM,gBAAgB,CAAC;AAMxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;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,IAA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CAAC;oBACP,uBAAuB;oBACvB,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC7C,CAAC;gBACD,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;aAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC7D,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type NestedMap, setInNestedMap, tryGetFromNestedMap } from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { ITreeCursorSynchronous } from \"./cursor.js\";\n// eslint-disable-next-line import/no-duplicates\nimport type * as Delta from \"./delta.js\";\n// Since ProtoNodes is reexported, import it directly to avoid forcing Delta to be reexported.\n// eslint-disable-next-line import/no-duplicates\nimport type { ProtoNodes } from \"./delta.js\";\nimport {\n\tareDetachedNodeIdsEqual,\n\tisAttachMark,\n\tisDetachMark,\n\tisReplaceMark,\n\toffsetDetachId,\n} 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\";\nimport type { RevisionTag } from \"../index.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 * The detach pass is therefore responsible for making sure that all roots that needs to be attached during the\n * attach pass are detached.\n * In practice, this means the detach pass must:\n * - Create all subtrees that need to be created\n * - Detach all moved nodes\n *\n * In addition to that, the detach pass also detaches nodes that need removing, with the exception of nodes that get\n * replaced. The reason for this exception is that we need to be able to communicate replaces as atomic operations.\n * In order to do that, we need to wait until we are sure that the content to attach is available as a detached root.\n * Replaces are therefore handled during the attach pass.\n * Note that this could theoretically lead to a situation where, in the attach pass, one replace wants to attach\n * a node that has yet to be detached by another replace. This does not occur in practice because we do not support\n * editing operations that would lead to this situation.\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 detach field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches and replaces.\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 subtreecChanged 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 * This two-pass nature also means that the event may fire at a time where no change is visible in the tree. E.g.,\n * if a node is being replaced, when the event fires during the detach pass no change in the tree has happened so the\n * listener won't see any; then when it fires during the attach pass, the change will be visible in the event listener.\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\tdelta.refreshers?.forEach(({ id: { major, minor }, trees }) => {\n\t\tfor (let i = 0; i < trees.length; i += 1) {\n\t\t\tconst offsettedId = minor + i;\n\t\t\tsetInNestedMap(refreshers, major, offsettedId, trees[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);\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: ProtoNodes, 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 */\n\tdetach(source: Range, destination: FieldKey): void;\n\t/**\n\t * Replaces a range of nodes in the current field by transferring them out to a new detached field\n\t * and transferring in all the nodes from an existing detached field in their place.\n\t * The number of nodes being detached must match the number of nodes being attached.\n\t * @param newContentSource - The detached field to transfer the new nodes from.\n\t * @param range - The bounds of the range of nodes to replace.\n\t * @param oldContentDestination - The key for a new detached field to transfer the old nodes to.\n\t */\n\treplace(newContentSource: FieldKey, range: Range, oldContentDestination: FieldKey): 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 * - Performs all root creations\n * - Collects all roots that may need a detach pass\n * - Collects all roots that may need an attach pass\n * - Collects all relocates\n * - Collects all destructions\n * - Executes detaches (bottom-up) provided they are not part of a replace\n * (because we want to wait until we are sure content to attach is available as a root)\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) {\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 (isDetachMark(mark)) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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);\n\t\t\t}\n\t\t} else if (!isAttachMark(mark)) {\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(id, trees, config.detachedFieldIndex, config.latestRevision, visitor);\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 * - Executes replaces (top-down) applying nested changes on the attached nodes\n * - Collects detached roots (from replaces) that need an attach pass\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) {\n\t\tif (isAttachMark(mark) || isReplaceMark(mark)) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\tif (isReplaceMark(mark)) {\n\t\t\t\t\tconst rootDestination = config.detachedFieldIndex.createEntry(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\toffsetDetachId(mark.detach!, i),\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t);\n\t\t\t\t\tconst destinationField = config.detachedFieldIndex.toFieldKey(rootDestination);\n\t\t\t\t\tvisitor.replace(\n\t\t\t\t\t\tsourceField,\n\t\t\t\t\t\t{ start: offsetIndex, end: offsetIndex + 1 },\n\t\t\t\t\t\tdestinationField,\n\t\t\t\t\t);\n\t\t\t\t\t// We may need to do a second pass on the detached nodes\n\t\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\t\tconfig.attachPassRoots.set(rootDestination, mark.fields);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// This a simple attach\n\t\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\t}\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} else if (!isDetachMark(mark) && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (!isDetachMark(mark)) {\n\t\t\tindex += mark.count;\n\t\t}\n\t}\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;AAG1F,OAAO,EAAE,cAAc,EAA+B,MAAM,aAAa,CAAC;AAE1E,OAAO,EACN,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,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AC,EAAE,CAAC;YACzB,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 { FieldKey } from \"../schema-stored/index.js\";\n\nimport { mapCursorField, type ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport {\n\tareDetachedNodeIdsEqual,\n\tisAttachMark,\n\tisDetachMark,\n\tisReplaceMark,\n\toffsetDetachId,\n} 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\";\nimport type { RevisionTag, TreeChunk } from \"../index.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 * The detach pass is therefore responsible for making sure that all roots that needs to be attached during the\n * attach pass are detached.\n * In practice, this means the detach pass must:\n * - Create all subtrees that need to be created\n * - Detach all moved nodes\n *\n * In addition to that, the detach pass also detaches nodes that need removing, with the exception of nodes that get\n * replaced. The reason for this exception is that we need to be able to communicate replaces as atomic operations.\n * In order to do that, we need to wait until we are sure that the content to attach is available as a detached root.\n * Replaces are therefore handled during the attach pass.\n * Note that this could theoretically lead to a situation where, in the attach pass, one replace wants to attach\n * a node that has yet to be detached by another replace. This does not occur in practice because we do not support\n * editing operations that would lead to this situation.\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 detach field. That is the responsibility of the root transfers phase.\n *\n * The attach phase carries out attaches and replaces.\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 * This two-pass nature also means that the event may fire at a time where no change is visible in the tree. E.g.,\n * if a node is being replaced, when the event fires during the detach pass no change in the tree has happened so the\n * listener won't see any; then when it fires during the attach pass, the change will be visible in the event listener.\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\tdelta.refreshers?.forEach(({ id: { major, minor }, trees }) => {\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);\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 */\n\tdetach(source: Range, destination: FieldKey, id: Delta.DetachedNodeId): void;\n\t/**\n\t * Replaces a range of nodes in the current field by transferring them out to a new detached field\n\t * and transferring in all the nodes from an existing detached field in their place.\n\t * The number of nodes being detached must match the number of nodes being attached.\n\t * @param newContentSource - The detached field to transfer the new nodes from.\n\t * @param range - The bounds of the range of nodes to replace.\n\t * @param oldContentDestination - The key for a new detached field to transfer the old nodes to.\n\t * @param oldContentId - The ID assigned to the first replaced node as a result of the replace. The other nodes in the replaced range are assigned subsequent IDs.\n\t */\n\treplace(\n\t\tnewContentSource: FieldKey,\n\t\trange: Range,\n\t\toldContentDestination: FieldKey,\n\t\toldContentId: Delta.DetachedNodeId,\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 * - Performs all root creations\n * - Collects all roots that may need a detach pass\n * - Collects all roots that may need an attach pass\n * - Collects all relocates\n * - Collects all destructions\n * - Executes detaches (bottom-up) provided they are not part of a replace\n * (because we want to wait until we are sure content to attach is available as a root)\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) {\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 (isDetachMark(mark)) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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);\n\t\t\t}\n\t\t} else if (!isAttachMark(mark)) {\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 * - Executes replaces (top-down) applying nested changes on the attached nodes\n * - Collects detached roots (from replaces) that need an attach pass\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) {\n\t\tif (isAttachMark(mark) || isReplaceMark(mark)) {\n\t\t\tfor (let i = 0; i < mark.count; i += 1) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\tif (isReplaceMark(mark)) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst destinationId = offsetDetachId(mark.detach!, i);\n\t\t\t\t\tconst rootDestination = config.detachedFieldIndex.createEntry(\n\t\t\t\t\t\tdestinationId,\n\t\t\t\t\t\tconfig.latestRevision,\n\t\t\t\t\t);\n\t\t\t\t\tconst destinationField = config.detachedFieldIndex.toFieldKey(rootDestination);\n\t\t\t\t\tvisitor.replace(\n\t\t\t\t\t\tsourceField,\n\t\t\t\t\t\t{ start: offsetIndex, end: offsetIndex + 1 },\n\t\t\t\t\t\tdestinationField,\n\t\t\t\t\t\tdestinationId,\n\t\t\t\t\t);\n\t\t\t\t\t// We may need to do a second pass on the detached nodes\n\t\t\t\t\tif (mark.fields !== undefined) {\n\t\t\t\t\t\tconfig.attachPassRoots.set(rootDestination, mark.fields);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// This a simple attach\n\t\t\t\t\tvisitor.attach(sourceField, 1, offsetIndex);\n\t\t\t\t}\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} else if (!isDetachMark(mark) && mark.fields !== undefined) {\n\t\t\tvisitNode(index, mark.fields, visitor, config);\n\t\t}\n\t\tif (!isDetachMark(mark)) {\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"]}
@@ -5,11 +5,12 @@
5
5
  import type { ICodecOptions } from "../../codec/index.js";
6
6
  import type { RevisionTag, RevisionTagCodec } from "../rebase/index.js";
7
7
  import type { FieldKey } from "../schema-stored/index.js";
8
- import type { ProtoNodes, Root } from "./delta.js";
8
+ import type { Root } from "./delta.js";
9
9
  import { DetachedFieldIndex } from "./detachedFieldIndex.js";
10
- import type { NodeIndex, PlaceIndex, Range } from "./pathTree.js";
10
+ import type { PlaceIndex, Range } from "./pathTree.js";
11
11
  import { type DeltaVisitor } from "./visitDelta.js";
12
12
  import type { IIdCompressor } from "@fluidframework/id-compressor";
13
+ import type { ITreeCursorSynchronous } from "./cursor.js";
13
14
  export declare function makeDetachedFieldIndex(prefix: string | undefined, revisionTagCodec: RevisionTagCodec, idCompressor: IIdCompressor, options?: ICodecOptions): DetachedFieldIndex;
14
15
  export declare function applyDelta(delta: Root, latestRevision: RevisionTag | undefined, deltaProcessor: {
15
16
  acquireVisitor: () => DeltaVisitor;
@@ -34,7 +35,7 @@ export interface AnnouncedVisitor extends DeltaVisitor {
34
35
  /**
35
36
  * A hook that is called after all nodes have been created.
36
37
  */
37
- afterCreate(content: ProtoNodes, destination: FieldKey): void;
38
+ afterCreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;
38
39
  beforeDestroy(field: FieldKey, count: number): void;
39
40
  beforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void;
40
41
  afterAttach(source: FieldKey, destination: Range): void;
@@ -47,24 +48,5 @@ export interface AnnouncedVisitor extends DeltaVisitor {
47
48
  * Creates an announced visitor with only the provided functions and uses a no op for the rest.
48
49
  * This is provided to make some of the delta visitor definitions cleaner.
49
50
  */
50
- export declare function createAnnouncedVisitor(visitorFunctions: {
51
- free?: () => void;
52
- create?: (content: ProtoNodes, destination: FieldKey) => void;
53
- afterCreate?: (content: ProtoNodes, destination: FieldKey) => void;
54
- beforeDestroy?: (field: FieldKey, count: number) => void;
55
- destroy?: (detachedField: FieldKey, count: number) => void;
56
- beforeAttach?: (source: FieldKey, count: number, destination: PlaceIndex) => void;
57
- attach?: (source: FieldKey, count: number, destination: PlaceIndex) => void;
58
- afterAttach?: (source: FieldKey, destination: Range) => void;
59
- beforeDetach?: (source: Range, destination: FieldKey) => void;
60
- afterDetach?: (source: PlaceIndex, count: number, destination: FieldKey) => void;
61
- detach?: (source: Range, destination: FieldKey) => void;
62
- beforeReplace?: (newContent: FieldKey, oldContent: Range, oldContentDestination: FieldKey) => void;
63
- replace?: (newContentSource: FieldKey, range: Range, oldContentDestination: FieldKey) => void;
64
- afterReplace?: (newContentSource: FieldKey, newContent: Range, oldContent: FieldKey) => void;
65
- enterNode?: (index: NodeIndex) => void;
66
- exitNode?: (index: NodeIndex) => void;
67
- enterField?: (key: FieldKey) => void;
68
- exitField?: (key: FieldKey) => void;
69
- }): AnnouncedVisitor;
51
+ export declare function createAnnouncedVisitor(visitorFunctions: Partial<AnnouncedVisitor>): AnnouncedVisitor;
70
52
  //# sourceMappingURL=visitorUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"visitorUtils.d.ts","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,sBAAsB,CACrC,MAAM,oBAAiB,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,aAAa,EAC3B,OAAO,CAAC,EAAE,aAAa,GACrB,kBAAkB,CAQpB;AAED,wBAAgB,UAAU,CACzB,KAAK,EAAE,IAAI,EACX,cAAc,EAAE,WAAW,GAAG,SAAS,EACvC,cAAc,EAAE;IAAE,cAAc,EAAE,MAAM,YAAY,CAAA;CAAE,EACtD,kBAAkB,EAAE,kBAAkB,GACpC,IAAI,CAIN;AAED,wB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gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACzC,gBAAgB,CAsBlB"}
@@ -47,16 +47,19 @@ export function combineVisitors(visitors, announcedVisitors = []) {
47
47
  attach: (source, count, destination) => {
48
48
  announcedVisitors.forEach((v) => v.beforeAttach(source, count, destination));
49
49
  visitors.forEach((v) => v.attach(source, count, destination));
50
- announcedVisitors.forEach((v) => v.afterAttach(source, { start: destination, end: destination + count }));
50
+ announcedVisitors.forEach((v) => v.afterAttach(source, {
51
+ start: destination,
52
+ end: destination + count,
53
+ }));
51
54
  },
52
- detach: (source, destination) => {
55
+ detach: (source, destination, id) => {
53
56
  announcedVisitors.forEach((v) => v.beforeDetach(source, destination));
54
- visitors.forEach((v) => v.detach(source, destination));
57
+ visitors.forEach((v) => v.detach(source, destination, id));
55
58
  announcedVisitors.forEach((v) => v.afterDetach(source.start, source.end - source.start, destination));
56
59
  },
57
- replace: (newContent, oldContent, oldContentDestination) => {
60
+ replace: (newContent, oldContent, oldContentDestination, oldContentId) => {
58
61
  announcedVisitors.forEach((v) => v.beforeReplace(newContent, oldContent, oldContentDestination));
59
- visitors.forEach((v) => v.replace(newContent, oldContent, oldContentDestination));
62
+ visitors.forEach((v) => v.replace(newContent, oldContent, oldContentDestination, oldContentId));
60
63
  announcedVisitors.forEach((v) => v.afterReplace(newContent, oldContent, oldContentDestination));
61
64
  },
62
65
  enterNode: (...args) => visitors.forEach((v) => v.enterNode(...args)),
@@ -1 +1 @@
1
- {"version":3,"file":"visitorUtils.js","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAoB,oBAAoB,EAAE,MAAM,q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I,IAAI;QACnD,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;QAC7C,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,IAAI,IAAI;QAC3C,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI;QAC/C,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;KAC7C,CAAC;AACH,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 { ICodecOptions } from \"../../codec/index.js\";\nimport { type IdAllocator, idAllocatorFromMaxId } from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { ProtoNodes, Root } from \"./delta.js\";\nimport { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId } from \"./detachedFieldIndexTypes.js\";\nimport type { NodeIndex, PlaceIndex, Range } from \"./pathTree.js\";\nimport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nexport function makeDetachedFieldIndex(\n\tprefix: string = \"Temp\",\n\trevisionTagCodec: RevisionTagCodec,\n\tidCompressor: IIdCompressor,\n\toptions?: ICodecOptions,\n): DetachedFieldIndex {\n\treturn new DetachedFieldIndex(\n\t\tprefix,\n\t\tidAllocatorFromMaxId() as IdAllocator<ForestRootId>,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\toptions,\n\t);\n}\n\nexport function applyDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, visitor, detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\nexport function announceDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor & AnnouncedVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, combineVisitors([visitor], [visitor]), detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\n/**\n * @param visitors - The returned visitor invokes the corresponding events for all these visitors, in order.\n * @param announcedVisitors - Subset of `visitors` to also call {@link AnnouncedVisitor} methods on.\n * This must be a subset of `visitors`: if not the visitor will not have its path correctly set when the events are triggered.\n * When `visitors` are making changes to data, `announcedVisitors` can be used to get extra events before or after all the changes from all the visitors have been made.\n * This can, for example, enable visitors to have access to the tree in these extra events despite multiple separate visitors updating different tree related data-structures.\n * @returns a DeltaVisitor combining all `visitors`.\n */\nexport function combineVisitors(\n\tvisitors: readonly DeltaVisitor[],\n\tannouncedVisitors: readonly AnnouncedVisitor[] = [],\n): DeltaVisitor {\n\t{\n\t\tconst set = new Set(visitors);\n\t\tfor (const item of announcedVisitors) {\n\t\t\tassert(set.has(item), 0x8c8 /* AnnouncedVisitor would not get traversed */);\n\t\t}\n\t}\n\treturn {\n\t\tfree: () => visitors.forEach((v) => v.free()),\n\t\tcreate: (...args) => {\n\t\t\tvisitors.forEach((v) => v.create(...args));\n\t\t\tannouncedVisitors.forEach((v) => v.afterCreate(...args));\n\t\t},\n\t\tdestroy: (...args) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDestroy(...args));\n\t\t\tvisitors.forEach((v) => v.destroy(...args));\n\t\t},\n\t\tattach: (source: FieldKey, count: number, destination: PlaceIndex) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeAttach(source, count, destination));\n\t\t\tvisitors.forEach((v) => v.attach(source, count, destination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterAttach(source, { start: destination, end: destination + count }),\n\t\t\t);\n\t\t},\n\t\tdetach: (source: Range, destination: FieldKey) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDetach(source, destination));\n\t\t\tvisitors.forEach((v) => v.detach(source, destination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterDetach(source.start, source.end - source.start, destination),\n\t\t\t);\n\t\t},\n\t\treplace: (newContent: FieldKey, oldContent: Range, oldContentDestination: FieldKey) => {\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.beforeReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t\tvisitors.forEach((v) => v.replace(newContent, oldContent, oldContentDestination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t},\n\t\tenterNode: (...args) => visitors.forEach((v) => v.enterNode(...args)),\n\t\texitNode: (...args) => visitors.forEach((v) => v.exitNode(...args)),\n\t\tenterField: (...args) => visitors.forEach((v) => v.enterField(...args)),\n\t\texitField: (...args) => visitors.forEach((v) => v.exitField(...args)),\n\t};\n}\n\n/**\n * Visitor that is notified of changes before, after, and when changes are made.\n * Must be freed after use.\n */\nexport interface AnnouncedVisitor extends DeltaVisitor {\n\t/**\n\t * A hook that is called after all nodes have been created.\n\t */\n\tafterCreate(content: ProtoNodes, destination: FieldKey): void;\n\tbeforeDestroy(field: FieldKey, count: number): void;\n\tbeforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\tafterAttach(source: FieldKey, destination: Range): void;\n\tbeforeDetach(source: Range, destination: FieldKey): void;\n\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void;\n\tbeforeReplace(\n\t\tnewContent: FieldKey,\n\t\toldContent: Range,\n\t\toldContentDestination: FieldKey,\n\t): void;\n\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void;\n}\n\n/**\n * Creates an announced visitor with only the provided functions and uses a no op for the rest.\n * This is provided to make some of the delta visitor definitions cleaner.\n */\nexport function createAnnouncedVisitor(visitorFunctions: {\n\tfree?: () => void;\n\tcreate?: (content: ProtoNodes, destination: FieldKey) => void;\n\tafterCreate?: (content: ProtoNodes, destination: FieldKey) => void;\n\tbeforeDestroy?: (field: FieldKey, count: number) => void;\n\tdestroy?: (detachedField: FieldKey, count: number) => void;\n\tbeforeAttach?: (source: FieldKey, count: number, destination: PlaceIndex) => void;\n\tattach?: (source: FieldKey, count: number, destination: PlaceIndex) => void;\n\tafterAttach?: (source: FieldKey, destination: Range) => void;\n\tbeforeDetach?: (source: Range, destination: FieldKey) => void;\n\tafterDetach?: (source: PlaceIndex, count: number, destination: FieldKey) => void;\n\tdetach?: (source: Range, destination: FieldKey) => void;\n\tbeforeReplace?: (\n\t\tnewContent: FieldKey,\n\t\toldContent: Range,\n\t\toldContentDestination: FieldKey,\n\t) => void;\n\treplace?: (\n\t\tnewContentSource: FieldKey,\n\t\trange: Range,\n\t\toldContentDestination: FieldKey,\n\t) => void;\n\tafterReplace?: (newContentSource: FieldKey, newContent: Range, oldContent: FieldKey) => void;\n\tenterNode?: (index: NodeIndex) => void;\n\texitNode?: (index: NodeIndex) => void;\n\tenterField?: (key: FieldKey) => void;\n\texitField?: (key: FieldKey) => void;\n}): AnnouncedVisitor {\n\tconst noOp = (): void => {};\n\treturn {\n\t\tfree: visitorFunctions.free ?? noOp,\n\t\tcreate: visitorFunctions.create ?? noOp,\n\t\tafterCreate: visitorFunctions.afterCreate ?? noOp,\n\t\tbeforeDestroy: visitorFunctions.beforeDestroy ?? noOp,\n\t\tdestroy: visitorFunctions.destroy ?? noOp,\n\t\tbeforeAttach: visitorFunctions.beforeAttach ?? noOp,\n\t\tattach: visitorFunctions.attach ?? noOp,\n\t\tafterAttach: visitorFunctions.afterAttach ?? noOp,\n\t\tbeforeDetach: visitorFunctions.beforeDetach ?? noOp,\n\t\tdetach: visitorFunctions.detach ?? noOp,\n\t\tafterDetach: visitorFunctions.afterDetach ?? noOp,\n\t\tbeforeReplace: visitorFunctions.beforeReplace ?? noOp,\n\t\treplace: visitorFunctions.replace ?? noOp,\n\t\tafterReplace: visitorFunctions.afterReplace ?? noOp,\n\t\tenterNode: visitorFunctions.enterNode ?? noOp,\n\t\texitNode: visitorFunctions.exitNode ?? noOp,\n\t\tenterField: visitorFunctions.enterField ?? noOp,\n\t\texitField: visitorFunctions.exitField ?? noOp,\n\t};\n}\n"]}
1
+ {"version":3,"file":"visitorUtils.js","sourceRoot":"","sources":["../../../src/core/tree/visitorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAoB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAqB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIhE,MAAM,UAAU,sBAAsB,CACrC,SAAiB,MAAM,EACvB,gBAAkC,EAClC,YAA2B,EAC3B,OAAuB;IAEvB,OAAO,IAAI,kBAAkB,CAC5B,MAAM,EACN,oBAAoB,EAA+B,EACnD,gBAAgB,EAChB,YAAY,EACZ,OAAO,CACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CACzB,KAAW,EACX,cAAuC,EACvC,cAAsD,EACtD,kBAAsC;IAEtC,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,aAAa,CAC5B,KAAW,EACX,cAAuC,EACvC,cAAyE,EACzE,kBAAsC;IAEtC,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IAChD,UAAU,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,kBAAkB,E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AAO,IAAI,IAAI;QACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,MAAM,EAAE,gBAAgB,CAAC,MAAM,IAAI,IAAI;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;QACjD,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,MAAM,EAAE,gBAAgB,CAAC,MAAM,IAAI,IAAI;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;QACjD,aAAa,EAAE,gBAAgB,CAAC,aAAa,IAAI,IAAI;QACrD,OAAO,EAAE,gBAAgB,CAAC,OAAO,IAAI,IAAI;QACzC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI;QACnD,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;QAC7C,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,IAAI,IAAI;QAC3C,UAAU,EAAE,gBAAgB,CAAC,UAAU,IAAI,IAAI;QAC/C,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,IAAI;KAC7C,CAAC;AACH,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 { ICodecOptions } from \"../../codec/index.js\";\nimport { type IdAllocator, idAllocatorFromMaxId } from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { DetachedNodeId, Root } from \"./delta.js\";\nimport { DetachedFieldIndex } from \"./detachedFieldIndex.js\";\nimport type { ForestRootId } from \"./detachedFieldIndexTypes.js\";\nimport type { PlaceIndex, Range } from \"./pathTree.js\";\nimport { type DeltaVisitor, visitDelta } from \"./visitDelta.js\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { ITreeCursorSynchronous } from \"./cursor.js\";\n\nexport function makeDetachedFieldIndex(\n\tprefix: string = \"Temp\",\n\trevisionTagCodec: RevisionTagCodec,\n\tidCompressor: IIdCompressor,\n\toptions?: ICodecOptions,\n): DetachedFieldIndex {\n\treturn new DetachedFieldIndex(\n\t\tprefix,\n\t\tidAllocatorFromMaxId() as IdAllocator<ForestRootId>,\n\t\trevisionTagCodec,\n\t\tidCompressor,\n\t\toptions,\n\t);\n}\n\nexport function applyDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, visitor, detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\nexport function announceDelta(\n\tdelta: Root,\n\tlatestRevision: RevisionTag | undefined,\n\tdeltaProcessor: { acquireVisitor: () => DeltaVisitor & AnnouncedVisitor },\n\tdetachedFieldIndex: DetachedFieldIndex,\n): void {\n\tconst visitor = deltaProcessor.acquireVisitor();\n\tvisitDelta(delta, combineVisitors([visitor], [visitor]), detachedFieldIndex, latestRevision);\n\tvisitor.free();\n}\n\n/**\n * @param visitors - The returned visitor invokes the corresponding events for all these visitors, in order.\n * @param announcedVisitors - Subset of `visitors` to also call {@link AnnouncedVisitor} methods on.\n * This must be a subset of `visitors`: if not the visitor will not have its path correctly set when the events are triggered.\n * When `visitors` are making changes to data, `announcedVisitors` can be used to get extra events before or after all the changes from all the visitors have been made.\n * This can, for example, enable visitors to have access to the tree in these extra events despite multiple separate visitors updating different tree related data-structures.\n * @returns a DeltaVisitor combining all `visitors`.\n */\nexport function combineVisitors(\n\tvisitors: readonly DeltaVisitor[],\n\tannouncedVisitors: readonly AnnouncedVisitor[] = [],\n): DeltaVisitor {\n\t{\n\t\tconst set = new Set(visitors);\n\t\tfor (const item of announcedVisitors) {\n\t\t\tassert(set.has(item), 0x8c8 /* AnnouncedVisitor would not get traversed */);\n\t\t}\n\t}\n\treturn {\n\t\tfree: () => visitors.forEach((v) => v.free()),\n\t\tcreate: (...args) => {\n\t\t\tvisitors.forEach((v) => v.create(...args));\n\t\t\tannouncedVisitors.forEach((v) => v.afterCreate(...args));\n\t\t},\n\t\tdestroy: (...args) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDestroy(...args));\n\t\t\tvisitors.forEach((v) => v.destroy(...args));\n\t\t},\n\t\tattach: (source: FieldKey, count: number, destination: PlaceIndex) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeAttach(source, count, destination));\n\t\t\tvisitors.forEach((v) => v.attach(source, count, destination));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterAttach(source, {\n\t\t\t\t\tstart: destination,\n\t\t\t\t\tend: destination + count,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t\tdetach: (source: Range, destination: FieldKey, id: DetachedNodeId) => {\n\t\t\tannouncedVisitors.forEach((v) => v.beforeDetach(source, destination));\n\t\t\tvisitors.forEach((v) => v.detach(source, destination, id));\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterDetach(source.start, source.end - source.start, destination),\n\t\t\t);\n\t\t},\n\t\treplace: (\n\t\t\tnewContent: FieldKey,\n\t\t\toldContent: Range,\n\t\t\toldContentDestination: FieldKey,\n\t\t\toldContentId: DetachedNodeId,\n\t\t) => {\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.beforeReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t\tvisitors.forEach((v) =>\n\t\t\t\tv.replace(newContent, oldContent, oldContentDestination, oldContentId),\n\t\t\t);\n\t\t\tannouncedVisitors.forEach((v) =>\n\t\t\t\tv.afterReplace(newContent, oldContent, oldContentDestination),\n\t\t\t);\n\t\t},\n\t\tenterNode: (...args) => visitors.forEach((v) => v.enterNode(...args)),\n\t\texitNode: (...args) => visitors.forEach((v) => v.exitNode(...args)),\n\t\tenterField: (...args) => visitors.forEach((v) => v.enterField(...args)),\n\t\texitField: (...args) => visitors.forEach((v) => v.exitField(...args)),\n\t};\n}\n\n/**\n * Visitor that is notified of changes before, after, and when changes are made.\n * Must be freed after use.\n */\nexport interface AnnouncedVisitor extends DeltaVisitor {\n\t/**\n\t * A hook that is called after all nodes have been created.\n\t */\n\tafterCreate(content: readonly ITreeCursorSynchronous[], destination: FieldKey): void;\n\tbeforeDestroy(field: FieldKey, count: number): void;\n\tbeforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void;\n\tafterAttach(source: FieldKey, destination: Range): void;\n\tbeforeDetach(source: Range, destination: FieldKey): void;\n\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void;\n\tbeforeReplace(\n\t\tnewContent: FieldKey,\n\t\toldContent: Range,\n\t\toldContentDestination: FieldKey,\n\t): void;\n\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void;\n}\n\n/**\n * Creates an announced visitor with only the provided functions and uses a no op for the rest.\n * This is provided to make some of the delta visitor definitions cleaner.\n */\nexport function createAnnouncedVisitor(\n\tvisitorFunctions: Partial<AnnouncedVisitor>,\n): AnnouncedVisitor {\n\tconst noOp = (): void => {};\n\treturn {\n\t\tfree: visitorFunctions.free ?? noOp,\n\t\tcreate: visitorFunctions.create ?? noOp,\n\t\tafterCreate: visitorFunctions.afterCreate ?? noOp,\n\t\tbeforeDestroy: visitorFunctions.beforeDestroy ?? noOp,\n\t\tdestroy: visitorFunctions.destroy ?? noOp,\n\t\tbeforeAttach: visitorFunctions.beforeAttach ?? noOp,\n\t\tattach: visitorFunctions.attach ?? noOp,\n\t\tafterAttach: visitorFunctions.afterAttach ?? noOp,\n\t\tbeforeDetach: visitorFunctions.beforeDetach ?? noOp,\n\t\tdetach: visitorFunctions.detach ?? noOp,\n\t\tafterDetach: visitorFunctions.afterDetach ?? noOp,\n\t\tbeforeReplace: visitorFunctions.beforeReplace ?? noOp,\n\t\treplace: visitorFunctions.replace ?? noOp,\n\t\tafterReplace: visitorFunctions.afterReplace ?? noOp,\n\t\tenterNode: visitorFunctions.enterNode ?? noOp,\n\t\texitNode: visitorFunctions.exitNode ?? noOp,\n\t\tenterField: visitorFunctions.enterField ?? noOp,\n\t\texitField: visitorFunctions.exitField ?? noOp,\n\t};\n}\n"]}
@@ -52,7 +52,7 @@ export type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];
52
52
  * Cursor over basic chunks.
53
53
  *
54
54
  * @remarks This implementation is similar to StackCursor, however it is distinct because:
55
- * 1. The children are chunks, which might have a top level length that greater than 1.
55
+ * 1. The children are chunks, which might have a top level length that's greater than 1.
56
56
  * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).
57
57
  *
58
58
  * TODO:
@@ -61,7 +61,7 @@ export class BasicChunk extends ReferenceCountedBase {
61
61
  * Cursor over basic chunks.
62
62
  *
63
63
  * @remarks This implementation is similar to StackCursor, however it is distinct because:
64
- * 1. The children are chunks, which might have a top level length that greater than 1.
64
+ * 1. The children are chunks, which might have a top level length that's greater than 1.
65
65
  * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).
66
66
  *
67
67
  * TODO:
@@ -1 +1 @@
1
- {"version":3,"file":"basicChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAYN,WAAW,EACX,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,oBAAoB;IAGnD;;;;OAIG;IACH,YACQ,IAA8B;IACrC;;;;;;;OAOG;IACI,MAAkC;IACzC;;OAEG;IACI,KAAiB;Q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KAAK,CAAC;IACnB,CAAC;IAED;;;OAGG;IACK,YAAY;QACnB,MAAM,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1F,MAAM,CACL,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC/B,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,YAAY,CAAC,UAAU,EACvD,KAAK,CAAC,qCAAqC,CAC3C,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAC3C,CAAC;IAED,IAAW,UAAU;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAW,WAAW;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeType,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixPath } from \"../treeCursorUtils.js\";\n\n/**\n * General purpose one node chunk.\n */\nexport class BasicChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic readonly topLevelLength: number = 1;\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * Caller must have already accounted for references via `fields` to the children in the fields map (via `referenceAdded`).\n\t */\n\tpublic constructor(\n\t\tpublic type: TreeNodeSchemaIdentifier,\n\t\t/**\n\t\t * Fields of this node.\n\t\t * @remarks\n\t\t * This object has exclusive deep ownership of this map (which might mutate it in the future).\n\t\t * Any code editing this map must update child reference counts.\n\t\t *\n\t\t * Like with {@link MapTree}, fields with no nodes must be removed from the map.\n\t\t */\n\t\tpublic fields: Map<FieldKey, TreeChunk[]>,\n\t\t/**\n\t\t * The value on this node, if any.\n\t\t */\n\t\tpublic value?: TreeValue,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): BasicChunk {\n\t\tconst fields = new Map<FieldKey, TreeChunk[]>();\n\t\tfor (const [k, v] of this.fields) {\n\t\t\tconst field = v.map((child) => {\n\t\t\t\tchild.referenceAdded();\n\t\t\t\treturn child;\n\t\t\t});\n\t\t\tfields.set(k, field);\n\t\t}\n\t\treturn new BasicChunk(this.type, fields, this.value);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor([this], [], [], [], [], [dummyRoot], 0, 0, 0, undefined);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const v of this.fields.values()) {\n\t\t\tfor (const child of v) {\n\t\t\t\tchild.referenceRemoved();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];\n\n/**\n * Cursor over basic chunks.\n *\n * @remarks This implementation is similar to StackCursor, however it is distinct because:\n * 1. The children are chunks, which might have a top level length that greater than 1.\n * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).\n *\n * TODO:\n * This cursor currently only handles child chunks which are BasicChunks:\n * BasicChunks should be an optimized fast path, and arbitrary chunk formats,\n * like UniformChunk, should be supported by delegating to their cursor implementations.\n */\nexport class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {\n\t/**\n\t * Starts at root field which might be a detached sequence.\n\t *\n\t * @param root - sequence of BasicChunk which make up the contents of the root sequence.\n\t * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,\n\t * this is needed to get the actual root nodes when entering nodes of the root field.\n\t * @param siblingStack - Stack of collections of siblings along the path through the tree:\n\t * does not include current level (which is stored in `siblings`).\n\t * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.\n\t * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.\n\t * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.\n\t * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.\n\t * @param siblings - Siblings at the current level (not included in `siblingStack`).\n\t * @param index - Index into `siblings`.\n\t * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.\n\t * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.\n\t * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)\n\t * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)\n\t * it creates the `nestedCursor` over that chunk, and delegates all operations to it.\n\t */\n\tpublic constructor(\n\t\tprotected root: readonly TreeChunk[],\n\t\tprotected readonly siblingStack: SiblingsOrKey[],\n\t\tprotected readonly indexStack: number[],\n\t\tprotected readonly indexOfChunkStack: number[],\n\t\t// TODO: Currently only BasicChunks are supported, and the currently always have a top level length of 1.\n\t\t// That makes this stack unneeded. When BasicChunkCursor is more feature complete, this stack should be reevaluated, and removed if possible.\n\t\tprotected readonly indexWithinChunkStack: number[],\n\t\tprotected siblings: SiblingsOrKey,\n\t\tprotected index: number,\n\t\tprotected indexOfChunk: number,\n\t\tprotected indexWithinChunk: number,\n\t\tprotected nestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get [cursorChunk](): TreeChunk | undefined {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor[cursorChunk];\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x57a /* must be in nodes mode */);\n\t\treturn (this.siblings as TreeChunk[])[this.indexOfChunk];\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\treturn (\n\t\t\tthis.siblingStack.length < 2 &&\n\t\t\t(this.nestedCursor === undefined || this.nestedCursor.atChunkRoot())\n\t\t);\n\t}\n\n\tpublic fork(): BasicChunkCursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic get mode(): CursorLocationType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.mode;\n\t\t}\n\t\t// Compute the number of nodes deep the current depth is.\n\t\t// We want the floor of the result, which can computed using a bitwise shift assuming the depth is less than 2^31, which seems safe.\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst halfHeight = (this.siblingStack.length + 1) >> 1;\n\t\tassert(\n\t\t\tthis.indexOfChunkStack.length === halfHeight,\n\t\t\t0x51c /* unexpected indexOfChunkStack */,\n\t\t);\n\t\tassert(\n\t\t\tthis.indexWithinChunkStack.length === halfHeight,\n\t\t\t0x51d /* unexpected indexWithinChunkStack */,\n\t\t);\n\t\treturn this.siblingStack.length % 2 === 0\n\t\t\t? CursorLocationType.Fields\n\t\t\t: CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldKey();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x51e /* must be in fields mode */);\n\t\treturn this.siblings[this.index] as FieldKey;\n\t}\n\n\tprivate getStackedFieldKey(height: number): FieldKey {\n\t\tassert(height % 2 === 0, 0x51f /* must field height */);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.siblingStack[height]![this.indexStack[height]!] as FieldKey;\n\t}\n\n\tprivate getStackedNodeIndex(height: number): number {\n\t\tassert(height % 2 === 1, 0x520 /* must be node height */);\n\t\tassert(height >= 0, 0x521 /* must not be above root */);\n\t\treturn this.indexStack[height] ?? oob();\n\t}\n\n\tprivate getStackedNode(height: number): BasicChunk {\n\t\tconst index = this.getStackedNodeIndex(height);\n\t\treturn (this.siblingStack[height] as readonly TreeChunk[])[index] as BasicChunk;\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldLength();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x522 /* must be in fields mode */);\n\t\tlet total = 0;\n\t\t// TODO: optimize?\n\t\tfor (const chunk of this.getField()) {\n\t\t\ttotal += chunk.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\tpublic enterNode(index: number): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterNode(index);\n\t\t\treturn;\n\t\t}\n\t\tconst found = this.firstNode() && this.seekNodes(index);\n\t\tassert(found, 0x523 /* child must exist at index */);\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.nestedCursor.getPath(this.nestedPathPrefix(prefix)) ??\n\t\t\t\tfail(0xaee /* nested cursors should not be root */)\n\t\t\t);\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x524 /* must be in nodes mode */);\n\t\tconst path = this.getOffsetPath(0, prefix);\n\t\tassert(path !== undefined, 0x55c /* field root cursor should never have undefined path */);\n\t\treturn path;\n\t}\n\n\tprivate nestedPathPrefix(prefix?: PathRootPrefix): PathRootPrefix {\n\t\t// This uses index offset for actual node, when it should use offset for start of chunk.\n\t\t// To compensate, subtract this.indexWithinChunk below.\n\t\tconst rootPath: UpPath =\n\t\t\tthis.getOffsetPath(0, prefix) ?? fail(0xaef /* nested cursors should not be root */);\n\t\treturn {\n\t\t\tindexOffset: rootPath.parentIndex - this.indexWithinChunk,\n\t\t\trootFieldOverride: rootPath.parentField,\n\t\t\tparent: rootPath.parent,\n\t\t};\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldPath(this.nestedPathPrefix(prefix));\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x525 /* must be in fields mode */);\n\t\treturn {\n\t\t\tfield:\n\t\t\t\tthis.indexStack.length === 1\n\t\t\t\t\t? (prefix?.rootFieldOverride ?? this.getFieldKey())\n\t\t\t\t\t: this.getFieldKey(),\n\t\t\tparent: this.getOffsetPath(1, prefix),\n\t\t};\n\t}\n\n\tprivate getOffsetPath(\n\t\toffset: number,\n\t\tprefix: PathRootPrefix | undefined,\n\t): UpPath | undefined {\n\t\t// It is more efficient to handle prefix directly in here rather than delegating to PrefixedPath.\n\n\t\tconst length = this.indexStack.length - offset;\n\t\tif (length === -1) {\n\t\t\treturn prefix?.parent; // At root\n\t\t}\n\n\t\tassert(length > 0, 0x526 /* invalid offset to above root */);\n\t\tassert(length % 2 === 1, 0x527 /* offset path must point to node not field */);\n\n\t\t// Perf Note:\n\t\t// This is O(depth) in tree.\n\t\t// If many different anchors are created, this could be optimized to amortize the costs.\n\t\t// For example, the cursor could cache UpPaths from the anchorSet when creating an anchor,\n\t\t// then reuse them as a starting point when making another.\n\t\t// Could cache this at one depth, and remember the depth.\n\t\t// When navigating up, adjust cached anchor if present.\n\n\t\tlet path: UpPath | undefined;\n\t\tfunction updatePath(newPath: UpPath): void {\n\t\t\tpath = path === undefined ? prefixPath(prefix, newPath) : newPath;\n\t\t}\n\n\t\t// Skip top level, since root node in path is \"undefined\" and does not have a parent or index.\n\t\tfor (let height = 1; height < length; height += 2) {\n\t\t\tconst key = this.getStackedFieldKey(height - 1);\n\t\t\tupdatePath({\n\t\t\t\tparent: path,\n\t\t\t\tparentIndex: this.getStackedNodeIndex(height),\n\t\t\t\tparentField: key,\n\t\t\t});\n\t\t}\n\n\t\tupdatePath({\n\t\t\tparent: path,\n\t\t\tparentIndex: offset === 0 ? this.index : this.getStackedNodeIndex(length),\n\t\t\tparentField: this.getStackedFieldKey(length - 1),\n\t\t});\n\t\treturn path;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterField(key);\n\t\t\treturn;\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x528 /* must be in nodes mode */);\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\n\t\t// For fields, siblings are only used for key lookup and\n\t\t// nextField and which has arbitrary iteration order,\n\t\t// so making a array of just key here works.\n\t\t// This adds an allocation, so it's optimizing code simplicity and for the other use case (enumeration)\n\t\t// at the cost of an allocation here.\n\t\tthis.index = 0;\n\t\tthis.siblings = [key];\n\t}\n\n\tpublic nextField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.nextField();\n\t\t}\n\t\tthis.index += 1;\n\t\tif (this.index === (this.siblings as []).length) {\n\t\t\tthis.exitField();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic firstField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstField();\n\t\t}\n\t\tconst fields = this.getNode().fields;\n\t\tif (fields.size === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.index = 0;\n\t\tthis.siblings = [...fields.keys()]; // TODO: avoid this copy\n\t\treturn true;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.seekNodes(offset);\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x529 /* can only seekNodes when in Nodes */,\n\t\t);\n\t\tassert(this.indexOfChunk < this.siblings.length, 0x52a /* out of bounds indexOfChunk */);\n\n\t\tthis.indexWithinChunk += offset;\n\t\tif (offset >= 0) {\n\t\t\tconst chunks = (this.siblings as TreeChunk[]) ?? oob();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\twhile (this.indexWithinChunk >= chunks[this.indexOfChunk]!.topLevelLength) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk -= chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t\tthis.indexOfChunk++;\n\t\t\t\tif (this.indexOfChunk === chunks.length) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.indexOfChunk < this.siblings.length,\n\t\t\t\t\t0x52b /* out of bounds indexOfChunk */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst chunks = this.siblings as TreeChunk[];\n\t\t\twhile (this.indexWithinChunk < 0) {\n\t\t\t\tif (this.indexOfChunk === 0) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.indexOfChunk--;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk += chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t}\n\t\t}\n\n\t\tthis.index += offset;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstNode();\n\t\t}\n\t\tconst siblings = this.getField();\n\t\tif (siblings.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.indexOfChunkStack.push(this.indexOfChunk);\n\t\tthis.indexWithinChunkStack.push(this.indexWithinChunk);\n\t\tthis.index = 0;\n\t\tthis.siblings = siblings;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.nextNode();\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52c /* can only nextNode when in Nodes */,\n\t\t);\n\t\tthis.indexWithinChunk++;\n\t\tif (\n\t\t\tthis.indexWithinChunk ===\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(this.siblings as TreeChunk[])[this.indexOfChunk]!.topLevelLength\n\t\t) {\n\t\t\tthis.indexOfChunk++;\n\t\t\tif (this.indexOfChunk === (this.siblings as TreeChunk[]).length) {\n\t\t\t\tthis.exitNode();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.indexWithinChunk = 0;\n\t\t\tthis.initNestedCursor();\n\t\t}\n\t\tthis.index++;\n\t\treturn true;\n\t}\n\n\tprivate initNestedCursor(): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x55d /* can only initNestedCursor when in Nodes */,\n\t\t);\n\t\tconst chunk = (this.siblings as TreeChunk[])[this.indexOfChunk] ?? oob();\n\t\tthis.nestedCursor = !(chunk instanceof BasicChunk) ? chunk.cursor() : undefined;\n\t\tthis.nestedCursor?.enterNode(this.indexWithinChunk);\n\t}\n\n\tpublic exitField(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.exitField();\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x52d /* can only navigate up from field when in field */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf0 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf1 /* Unexpected indexStack.length */);\n\t}\n\n\tpublic exitNode(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (!this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.exitNode();\n\t\t\t}\n\t\t\tthis.nestedCursor = undefined;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52e /* can only navigate up from node when in node */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf2 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf3 /* Unexpected indexStack.length */);\n\t\tthis.indexOfChunk =\n\t\t\tthis.indexOfChunkStack.pop() ?? fail(0xaf4 /* Unexpected indexOfChunkStack.length */);\n\t\tthis.indexWithinChunk =\n\t\t\tthis.indexWithinChunkStack.pop() ??\n\t\t\tfail(0xaf5 /* Unexpected indexWithinChunkStack.length */);\n\t}\n\n\tprivate getNode(): BasicChunk {\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x52f /* can only get node when in node */);\n\t\treturn (this.siblings as TreeChunk[])[this.index] as BasicChunk;\n\t}\n\n\tprivate getField(): readonly TreeChunk[] {\n\t\tif (this.siblingStack.length === 0) {\n\t\t\treturn this.root;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x530 /* can only get field when in fields */,\n\t\t);\n\t\tconst parent = this.getStackedNode(this.indexStack.length - 1);\n\t\tconst key: FieldKey = this.getFieldKey();\n\t\tconst field = parent.fields.get(key) ?? [];\n\t\treturn field;\n\t}\n\n\tpublic get value(): Value {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.value;\n\t\t}\n\t\treturn this.getNode().value;\n\t}\n\n\tpublic get type(): TreeType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.type;\n\t\t}\n\t\treturn this.getNode().type;\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x531 /* can only node's index when in node */,\n\t\t);\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\t// TODO: this.index\n\t\t\t\treturn this.nestedCursor.fieldIndex + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.fieldIndex;\n\t\t}\n\t\treturn this.index;\n\t}\n\n\t/**\n\t * Within the field that `nestedCursor` is nested in:\n\t * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.\n\t */\n\tprivate nestedOffset(): number {\n\t\tassert(this.nestedCursor !== undefined, 0x55e /* nested offset requires nested cursor */);\n\t\tassert(\n\t\t\t!this.nestedCursor.atChunkRoot() ||\n\t\t\t\tthis.indexWithinChunk === this.nestedCursor.fieldIndex,\n\t\t\t0x55f /* indexes should match if at root */,\n\t\t);\n\t\treturn this.index - this.indexWithinChunk;\n\t}\n\n\tpublic get chunkStart(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.chunkStart + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.chunkStart;\n\t\t}\n\t\treturn this.fieldIndex;\n\t}\n\n\tpublic get chunkLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.chunkLength;\n\t\t}\n\t\treturn 1;\n\t}\n}\n"]}
1
+ {"version":3,"file":"basicChunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/basicChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAYN,WAAW,EACX,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,oBAAoB;IAGnD;;;;OAIG;IACH,YACQ,IAA8B;IACrC;;;;;;;OAOG;IACI,MAAkC;IACzC;;OAEG;IACI,KAAiB;QAExB,KAAK,EAAE,CAAC;QAfD,SAAI,GAAJ,IAAI,CAA0B;QAS9B,WAAM,GAAN,MAAM,CAA4B;QAIlC,UAAK,GAAL,KAAK,CAAY;QArBT,mBAAc,GAAW,CAAC,CAAC;IAwB3C,CAAC;IAEM,KAAK;QACX,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;QAChD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CA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CAAC;IAC3C,CAAC;IAED,IAAW,UAAU;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3D,CAAC;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAW,WAAW;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype PathRootPrefix,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeType,\n\ttype TreeValue,\n\ttype UpPath,\n\ttype Value,\n\ttype ChunkedCursor,\n\ttype TreeChunk,\n\tcursorChunk,\n\tdummyRoot,\n} from \"../../core/index.js\";\nimport { ReferenceCountedBase, fail } from \"../../util/index.js\";\nimport { SynchronousCursor, prefixPath } from \"../treeCursorUtils.js\";\n\n/**\n * General purpose one node chunk.\n */\nexport class BasicChunk extends ReferenceCountedBase implements TreeChunk {\n\tpublic readonly topLevelLength: number = 1;\n\n\t/**\n\t * Create a tree chunk with ref count 1.\n\t *\n\t * Caller must have already accounted for references via `fields` to the children in the fields map (via `referenceAdded`).\n\t */\n\tpublic constructor(\n\t\tpublic type: TreeNodeSchemaIdentifier,\n\t\t/**\n\t\t * Fields of this node.\n\t\t * @remarks\n\t\t * This object has exclusive deep ownership of this map (which might mutate it in the future).\n\t\t * Any code editing this map must update child reference counts.\n\t\t *\n\t\t * Like with {@link MapTree}, fields with no nodes must be removed from the map.\n\t\t */\n\t\tpublic fields: Map<FieldKey, TreeChunk[]>,\n\t\t/**\n\t\t * The value on this node, if any.\n\t\t */\n\t\tpublic value?: TreeValue,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic clone(): BasicChunk {\n\t\tconst fields = new Map<FieldKey, TreeChunk[]>();\n\t\tfor (const [k, v] of this.fields) {\n\t\t\tconst field = v.map((child) => {\n\t\t\t\tchild.referenceAdded();\n\t\t\t\treturn child;\n\t\t\t});\n\t\t\tfields.set(k, field);\n\t\t}\n\t\treturn new BasicChunk(this.type, fields, this.value);\n\t}\n\n\tpublic cursor(): ChunkedCursor {\n\t\treturn new BasicChunkCursor([this], [], [], [], [], [dummyRoot], 0, 0, 0, undefined);\n\t}\n\n\tprotected onUnreferenced(): void {\n\t\tfor (const v of this.fields.values()) {\n\t\t\tfor (const child of v) {\n\t\t\t\tchild.referenceRemoved();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type SiblingsOrKey = readonly TreeChunk[] | readonly FieldKey[];\n\n/**\n * Cursor over basic chunks.\n *\n * @remarks This implementation is similar to StackCursor, however it is distinct because:\n * 1. The children are chunks, which might have a top level length that's greater than 1.\n * 2. It needs to be able to delegate to cursors of other chunk formats it does not natively understand (See TODO below).\n *\n * TODO:\n * This cursor currently only handles child chunks which are BasicChunks:\n * BasicChunks should be an optimized fast path, and arbitrary chunk formats,\n * like UniformChunk, should be supported by delegating to their cursor implementations.\n */\nexport class BasicChunkCursor extends SynchronousCursor implements ChunkedCursor {\n\t/**\n\t * Starts at root field which might be a detached sequence.\n\t *\n\t * @param root - sequence of BasicChunk which make up the contents of the root sequence.\n\t * Since this cursor starts in `Fields` mode at the root, the siblings array when in fields mode is just the field keys,\n\t * this is needed to get the actual root nodes when entering nodes of the root field.\n\t * @param siblingStack - Stack of collections of siblings along the path through the tree:\n\t * does not include current level (which is stored in `siblings`).\n\t * Even levels in the stack (starting from 0) are keys and odd levels are sequences of nodes.\n\t * @param indexStack - Stack of indices into the corresponding levels in `siblingStack`.\n\t * @param indexOfChunkStack - Index of chunk in array of chunks. Only for Node levels.\n\t * @param indexWithinChunkStack - Index within chunk selected by indexOfChunkStack. Only for Node levels.\n\t * @param siblings - Siblings at the current level (not included in `siblingStack`).\n\t * @param index - Index into `siblings`.\n\t * @param indexOfChunk - Index of chunk in array of chunks. Only for Nodes mode.\n\t * @param indexWithinChunk - Index within chunk selected by indexOfChunkStack. Only for Nodes mode.\n\t * @param nestedCursor - When the outer cursor (this `BasicChunkCursor` cursor)\n\t * navigates into a chunk it does not natively understand (currently anything other than `BasicChunk`s)\n\t * it creates the `nestedCursor` over that chunk, and delegates all operations to it.\n\t */\n\tpublic constructor(\n\t\tprotected root: readonly TreeChunk[],\n\t\tprotected readonly siblingStack: SiblingsOrKey[],\n\t\tprotected readonly indexStack: number[],\n\t\tprotected readonly indexOfChunkStack: number[],\n\t\t// TODO: Currently only BasicChunks are supported, and the currently always have a top level length of 1.\n\t\t// That makes this stack unneeded. When BasicChunkCursor is more feature complete, this stack should be reevaluated, and removed if possible.\n\t\tprotected readonly indexWithinChunkStack: number[],\n\t\tprotected siblings: SiblingsOrKey,\n\t\tprotected index: number,\n\t\tprotected indexOfChunk: number,\n\t\tprotected indexWithinChunk: number,\n\t\tprotected nestedCursor: ChunkedCursor | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic get [cursorChunk](): TreeChunk | undefined {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor[cursorChunk];\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x57a /* must be in nodes mode */);\n\t\treturn (this.siblings as TreeChunk[])[this.indexOfChunk];\n\t}\n\n\tpublic atChunkRoot(): boolean {\n\t\treturn (\n\t\t\tthis.siblingStack.length < 2 &&\n\t\t\t(this.nestedCursor === undefined || this.nestedCursor.atChunkRoot())\n\t\t);\n\t}\n\n\tpublic fork(): BasicChunkCursor {\n\t\t// Siblings arrays are not modified during navigation and do not need be be copied.\n\t\t// This allows this copy to be shallow, and `this.siblings` below to not be copied as all.\n\t\treturn new BasicChunkCursor(\n\t\t\tthis.root,\n\t\t\t[...this.siblingStack],\n\t\t\t[...this.indexStack],\n\t\t\t[...this.indexOfChunkStack],\n\t\t\t[...this.indexWithinChunkStack],\n\t\t\tthis.siblings,\n\t\t\tthis.index,\n\t\t\tthis.indexOfChunk,\n\t\t\tthis.indexWithinChunk,\n\t\t\tthis.nestedCursor?.fork(),\n\t\t);\n\t}\n\n\tpublic get mode(): CursorLocationType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.mode;\n\t\t}\n\t\t// Compute the number of nodes deep the current depth is.\n\t\t// We want the floor of the result, which can computed using a bitwise shift assuming the depth is less than 2^31, which seems safe.\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst halfHeight = (this.siblingStack.length + 1) >> 1;\n\t\tassert(\n\t\t\tthis.indexOfChunkStack.length === halfHeight,\n\t\t\t0x51c /* unexpected indexOfChunkStack */,\n\t\t);\n\t\tassert(\n\t\t\tthis.indexWithinChunkStack.length === halfHeight,\n\t\t\t0x51d /* unexpected indexWithinChunkStack */,\n\t\t);\n\t\treturn this.siblingStack.length % 2 === 0\n\t\t\t? CursorLocationType.Fields\n\t\t\t: CursorLocationType.Nodes;\n\t}\n\n\tpublic getFieldKey(): FieldKey {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldKey();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x51e /* must be in fields mode */);\n\t\treturn this.siblings[this.index] as FieldKey;\n\t}\n\n\tprivate getStackedFieldKey(height: number): FieldKey {\n\t\tassert(height % 2 === 0, 0x51f /* must field height */);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this.siblingStack[height]![this.indexStack[height]!] as FieldKey;\n\t}\n\n\tprivate getStackedNodeIndex(height: number): number {\n\t\tassert(height % 2 === 1, 0x520 /* must be node height */);\n\t\tassert(height >= 0, 0x521 /* must not be above root */);\n\t\treturn this.indexStack[height] ?? oob();\n\t}\n\n\tprivate getStackedNode(height: number): BasicChunk {\n\t\tconst index = this.getStackedNodeIndex(height);\n\t\treturn (this.siblingStack[height] as readonly TreeChunk[])[index] as BasicChunk;\n\t}\n\n\tpublic getFieldLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldLength();\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x522 /* must be in fields mode */);\n\t\tlet total = 0;\n\t\t// TODO: optimize?\n\t\tfor (const chunk of this.getField()) {\n\t\t\ttotal += chunk.topLevelLength;\n\t\t}\n\t\treturn total;\n\t}\n\n\tpublic enterNode(index: number): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterNode(index);\n\t\t\treturn;\n\t\t}\n\t\tconst found = this.firstNode() && this.seekNodes(index);\n\t\tassert(found, 0x523 /* child must exist at index */);\n\t}\n\n\tpublic getPath(prefix?: PathRootPrefix): UpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.nestedCursor.getPath(this.nestedPathPrefix(prefix)) ??\n\t\t\t\tfail(0xaee /* nested cursors should not be root */)\n\t\t\t);\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x524 /* must be in nodes mode */);\n\t\tconst path = this.getOffsetPath(0, prefix);\n\t\tassert(path !== undefined, 0x55c /* field root cursor should never have undefined path */);\n\t\treturn path;\n\t}\n\n\tprivate nestedPathPrefix(prefix?: PathRootPrefix): PathRootPrefix {\n\t\t// This uses index offset for actual node, when it should use offset for start of chunk.\n\t\t// To compensate, subtract this.indexWithinChunk below.\n\t\tconst rootPath: UpPath =\n\t\t\tthis.getOffsetPath(0, prefix) ?? fail(0xaef /* nested cursors should not be root */);\n\t\treturn {\n\t\t\tindexOffset: rootPath.parentIndex - this.indexWithinChunk,\n\t\t\trootFieldOverride: rootPath.parentField,\n\t\t\tparent: rootPath.parent,\n\t\t};\n\t}\n\n\tpublic getFieldPath(prefix?: PathRootPrefix): FieldUpPath {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.getFieldPath(this.nestedPathPrefix(prefix));\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Fields, 0x525 /* must be in fields mode */);\n\t\treturn {\n\t\t\tfield:\n\t\t\t\tthis.indexStack.length === 1\n\t\t\t\t\t? (prefix?.rootFieldOverride ?? this.getFieldKey())\n\t\t\t\t\t: this.getFieldKey(),\n\t\t\tparent: this.getOffsetPath(1, prefix),\n\t\t};\n\t}\n\n\tprivate getOffsetPath(\n\t\toffset: number,\n\t\tprefix: PathRootPrefix | undefined,\n\t): UpPath | undefined {\n\t\t// It is more efficient to handle prefix directly in here rather than delegating to PrefixedPath.\n\n\t\tconst length = this.indexStack.length - offset;\n\t\tif (length === -1) {\n\t\t\treturn prefix?.parent; // At root\n\t\t}\n\n\t\tassert(length > 0, 0x526 /* invalid offset to above root */);\n\t\tassert(length % 2 === 1, 0x527 /* offset path must point to node not field */);\n\n\t\t// Perf Note:\n\t\t// This is O(depth) in tree.\n\t\t// If many different anchors are created, this could be optimized to amortize the costs.\n\t\t// For example, the cursor could cache UpPaths from the anchorSet when creating an anchor,\n\t\t// then reuse them as a starting point when making another.\n\t\t// Could cache this at one depth, and remember the depth.\n\t\t// When navigating up, adjust cached anchor if present.\n\n\t\tlet path: UpPath | undefined;\n\t\tfunction updatePath(newPath: UpPath): void {\n\t\t\tpath = path === undefined ? prefixPath(prefix, newPath) : newPath;\n\t\t}\n\n\t\t// Skip top level, since root node in path is \"undefined\" and does not have a parent or index.\n\t\tfor (let height = 1; height < length; height += 2) {\n\t\t\tconst key = this.getStackedFieldKey(height - 1);\n\t\t\tupdatePath({\n\t\t\t\tparent: path,\n\t\t\t\tparentIndex: this.getStackedNodeIndex(height),\n\t\t\t\tparentField: key,\n\t\t\t});\n\t\t}\n\n\t\tupdatePath({\n\t\t\tparent: path,\n\t\t\tparentIndex: offset === 0 ? this.index : this.getStackedNodeIndex(length),\n\t\t\tparentField: this.getStackedFieldKey(length - 1),\n\t\t});\n\t\treturn path;\n\t}\n\n\tpublic enterField(key: FieldKey): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tthis.nestedCursor.enterField(key);\n\t\t\treturn;\n\t\t}\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x528 /* must be in nodes mode */);\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\n\t\t// For fields, siblings are only used for key lookup and\n\t\t// nextField and which has arbitrary iteration order,\n\t\t// so making a array of just key here works.\n\t\t// This adds an allocation, so it's optimizing code simplicity and for the other use case (enumeration)\n\t\t// at the cost of an allocation here.\n\t\tthis.index = 0;\n\t\tthis.siblings = [key];\n\t}\n\n\tpublic nextField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.nextField();\n\t\t}\n\t\tthis.index += 1;\n\t\tif (this.index === (this.siblings as []).length) {\n\t\t\tthis.exitField();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic firstField(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstField();\n\t\t}\n\t\tconst fields = this.getNode().fields;\n\t\tif (fields.size === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.index = 0;\n\t\tthis.siblings = [...fields.keys()]; // TODO: avoid this copy\n\t\treturn true;\n\t}\n\n\tpublic seekNodes(offset: number): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.seekNodes(offset);\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x529 /* can only seekNodes when in Nodes */,\n\t\t);\n\t\tassert(this.indexOfChunk < this.siblings.length, 0x52a /* out of bounds indexOfChunk */);\n\n\t\tthis.indexWithinChunk += offset;\n\t\tif (offset >= 0) {\n\t\t\tconst chunks = (this.siblings as TreeChunk[]) ?? oob();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\twhile (this.indexWithinChunk >= chunks[this.indexOfChunk]!.topLevelLength) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk -= chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t\tthis.indexOfChunk++;\n\t\t\t\tif (this.indexOfChunk === chunks.length) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tassert(\n\t\t\t\t\tthis.indexOfChunk < this.siblings.length,\n\t\t\t\t\t0x52b /* out of bounds indexOfChunk */,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst chunks = this.siblings as TreeChunk[];\n\t\t\twhile (this.indexWithinChunk < 0) {\n\t\t\t\tif (this.indexOfChunk === 0) {\n\t\t\t\t\tthis.exitNode();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthis.indexOfChunk--;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.indexWithinChunk += chunks[this.indexOfChunk]!.topLevelLength;\n\t\t\t}\n\t\t}\n\n\t\tthis.index += offset;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic firstNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.firstNode();\n\t\t}\n\t\tconst siblings = this.getField();\n\t\tif (siblings.length === 0) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.siblingStack.push(this.siblings);\n\t\tthis.indexStack.push(this.index);\n\t\tthis.indexOfChunkStack.push(this.indexOfChunk);\n\t\tthis.indexWithinChunkStack.push(this.indexWithinChunk);\n\t\tthis.index = 0;\n\t\tthis.siblings = siblings;\n\t\tthis.indexOfChunk = 0;\n\t\tthis.indexWithinChunk = 0;\n\t\tthis.initNestedCursor();\n\t\treturn true;\n\t}\n\n\tpublic nextNode(): boolean {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tconst atRoot = this.nestedCursor.atChunkRoot();\n\t\t\tconst stillIn = this.nestedCursor.nextNode();\n\t\t\tif (!atRoot) {\n\t\t\t\treturn stillIn;\n\t\t\t}\n\t\t\tif (!stillIn) {\n\t\t\t\tthis.nestedCursor = undefined;\n\t\t\t}\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52c /* can only nextNode when in Nodes */,\n\t\t);\n\t\tthis.indexWithinChunk++;\n\t\tif (\n\t\t\tthis.indexWithinChunk ===\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t(this.siblings as TreeChunk[])[this.indexOfChunk]!.topLevelLength\n\t\t) {\n\t\t\tthis.indexOfChunk++;\n\t\t\tif (this.indexOfChunk === (this.siblings as TreeChunk[]).length) {\n\t\t\t\tthis.exitNode();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.indexWithinChunk = 0;\n\t\t\tthis.initNestedCursor();\n\t\t}\n\t\tthis.index++;\n\t\treturn true;\n\t}\n\n\tprivate initNestedCursor(): void {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x55d /* can only initNestedCursor when in Nodes */,\n\t\t);\n\t\tconst chunk = (this.siblings as TreeChunk[])[this.indexOfChunk] ?? oob();\n\t\tthis.nestedCursor = !(chunk instanceof BasicChunk) ? chunk.cursor() : undefined;\n\t\tthis.nestedCursor?.enterNode(this.indexWithinChunk);\n\t}\n\n\tpublic exitField(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.exitField();\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x52d /* can only navigate up from field when in field */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf0 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf1 /* Unexpected indexStack.length */);\n\t}\n\n\tpublic exitNode(): void {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (!this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.exitNode();\n\t\t\t}\n\t\t\tthis.nestedCursor = undefined;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x52e /* can only navigate up from node when in node */,\n\t\t);\n\t\tthis.siblings =\n\t\t\tthis.siblingStack.pop() ?? fail(0xaf2 /* Unexpected siblingStack.length */);\n\t\tthis.index = this.indexStack.pop() ?? fail(0xaf3 /* Unexpected indexStack.length */);\n\t\tthis.indexOfChunk =\n\t\t\tthis.indexOfChunkStack.pop() ?? fail(0xaf4 /* Unexpected indexOfChunkStack.length */);\n\t\tthis.indexWithinChunk =\n\t\t\tthis.indexWithinChunkStack.pop() ??\n\t\t\tfail(0xaf5 /* Unexpected indexWithinChunkStack.length */);\n\t}\n\n\tprivate getNode(): BasicChunk {\n\t\tassert(this.mode === CursorLocationType.Nodes, 0x52f /* can only get node when in node */);\n\t\treturn (this.siblings as TreeChunk[])[this.index] as BasicChunk;\n\t}\n\n\tprivate getField(): readonly TreeChunk[] {\n\t\tif (this.siblingStack.length === 0) {\n\t\t\treturn this.root;\n\t\t}\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Fields,\n\t\t\t0x530 /* can only get field when in fields */,\n\t\t);\n\t\tconst parent = this.getStackedNode(this.indexStack.length - 1);\n\t\tconst key: FieldKey = this.getFieldKey();\n\t\tconst field = parent.fields.get(key) ?? [];\n\t\treturn field;\n\t}\n\n\tpublic get value(): Value {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.value;\n\t\t}\n\t\treturn this.getNode().value;\n\t}\n\n\tpublic get type(): TreeType {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.type;\n\t\t}\n\t\treturn this.getNode().type;\n\t}\n\n\tpublic get fieldIndex(): number {\n\t\tassert(\n\t\t\tthis.mode === CursorLocationType.Nodes,\n\t\t\t0x531 /* can only node's index when in node */,\n\t\t);\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\t// TODO: this.index\n\t\t\t\treturn this.nestedCursor.fieldIndex + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.fieldIndex;\n\t\t}\n\t\treturn this.index;\n\t}\n\n\t/**\n\t * Within the field that `nestedCursor` is nested in:\n\t * returns the index within that field of the first node that is part of the chunk nestedCursor traverses.\n\t */\n\tprivate nestedOffset(): number {\n\t\tassert(this.nestedCursor !== undefined, 0x55e /* nested offset requires nested cursor */);\n\t\tassert(\n\t\t\t!this.nestedCursor.atChunkRoot() ||\n\t\t\t\tthis.indexWithinChunk === this.nestedCursor.fieldIndex,\n\t\t\t0x55f /* indexes should match if at root */,\n\t\t);\n\t\treturn this.index - this.indexWithinChunk;\n\t}\n\n\tpublic get chunkStart(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\tif (this.nestedCursor.atChunkRoot()) {\n\t\t\t\treturn this.nestedCursor.chunkStart + this.nestedOffset();\n\t\t\t}\n\t\t\treturn this.nestedCursor.chunkStart;\n\t\t}\n\t\treturn this.fieldIndex;\n\t}\n\n\tpublic get chunkLength(): number {\n\t\tif (this.nestedCursor !== undefined) {\n\t\t\treturn this.nestedCursor.chunkLength;\n\t\t}\n\t\treturn 1;\n\t}\n}\n"]}
@@ -145,10 +145,12 @@ export interface ChunkCompressor {
145
145
  readonly idCompressor: IIdCompressor | undefined;
146
146
  }
147
147
  /**
148
- * @param cursor - cursor in nodes mode
148
+ * Chunk a portion of a field.
149
+ *
150
+ * @param cursor - cursor at the starting node in the field.
149
151
  * @param policy - heuristics to impact chunking
150
- * @param length - how many nodes to process (at the top level)
151
- * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it.
152
+ * @param length - how many nodes to process (at the top level). When 0, the cursor is not moved, and may be at the end of the field (and thus in Fields mode)
153
+ * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it. Invalid if length is 0.
152
154
  */
153
155
  export declare function chunkRange(cursor: ITreeCursorSynchronous, chunkCompressor: ChunkCompressor, length: number, skipLastNavigation: boolean): TreeChunk[];
154
156
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"chunkTree.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAG3B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EAEjC,KAAK,KAAK,EAIV,KAAK,SAAS,EAEd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,M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