@fluidframework/tree 2.1.0 → 2.2.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 (1457) hide show
  1. package/.mocharc.customBenchmarks.cjs +33 -0
  2. package/CHANGELOG.md +297 -0
  3. package/README.md +34 -4
  4. package/api-extractor.json +17 -0
  5. package/api-report/tree.alpha.api.md +119 -25
  6. package/api-report/tree.beta.api.md +51 -25
  7. package/api-report/tree.public.api.md +51 -25
  8. package/dist/beta.d.ts +3 -1
  9. package/dist/codec/discriminatedUnions.d.ts +11 -5
  10. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  11. package/dist/codec/discriminatedUnions.js.map +1 -1
  12. package/dist/codec/index.d.ts +1 -1
  13. package/dist/codec/index.d.ts.map +1 -1
  14. package/dist/codec/index.js.map +1 -1
  15. package/dist/core/forest/editableForest.d.ts +1 -5
  16. package/dist/core/forest/editableForest.d.ts.map +1 -1
  17. package/dist/core/forest/editableForest.js.map +1 -1
  18. package/dist/core/forest/forest.d.ts +0 -6
  19. package/dist/core/forest/forest.d.ts.map +1 -1
  20. package/dist/core/forest/forest.js +0 -2
  21. package/dist/core/forest/forest.js.map +1 -1
  22. package/dist/core/index.d.ts +2 -2
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/index.js +3 -4
  25. package/dist/core/index.js.map +1 -1
  26. package/dist/core/rebase/changeRebaser.d.ts +0 -4
  27. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  28. package/dist/core/rebase/changeRebaser.js.map +1 -1
  29. package/dist/core/rebase/index.d.ts +1 -1
  30. package/dist/core/rebase/index.d.ts.map +1 -1
  31. package/dist/core/rebase/index.js +1 -3
  32. package/dist/core/rebase/index.js.map +1 -1
  33. package/dist/core/rebase/types.d.ts +1 -8
  34. package/dist/core/rebase/types.d.ts.map +1 -1
  35. package/dist/core/rebase/types.js +1 -9
  36. package/dist/core/rebase/types.js.map +1 -1
  37. package/dist/core/rebase/utils.d.ts +0 -1
  38. package/dist/core/rebase/utils.d.ts.map +1 -1
  39. package/dist/core/rebase/utils.js +12 -7
  40. package/dist/core/rebase/utils.js.map +1 -1
  41. package/dist/core/schema-stored/multiplicity.d.ts +0 -1
  42. package/dist/core/schema-stored/multiplicity.d.ts.map +1 -1
  43. package/dist/core/schema-stored/multiplicity.js +0 -1
  44. package/dist/core/schema-stored/multiplicity.js.map +1 -1
  45. package/dist/core/schema-stored/schema.d.ts +0 -7
  46. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  47. package/dist/core/schema-stored/schema.js +0 -4
  48. package/dist/core/schema-stored/schema.js.map +1 -1
  49. package/dist/core/schema-stored/storedSchemaRepository.d.ts +0 -3
  50. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  51. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  52. package/dist/core/schema-view/view.d.ts +0 -3
  53. package/dist/core/schema-view/view.d.ts.map +1 -1
  54. package/dist/core/schema-view/view.js +0 -1
  55. package/dist/core/schema-view/view.js.map +1 -1
  56. package/dist/core/tree/anchorSet.d.ts +0 -10
  57. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  58. package/dist/core/tree/anchorSet.js +1 -4
  59. package/dist/core/tree/anchorSet.js.map +1 -1
  60. package/dist/core/tree/cursor.d.ts +1 -6
  61. package/dist/core/tree/cursor.d.ts.map +1 -1
  62. package/dist/core/tree/cursor.js +0 -2
  63. package/dist/core/tree/cursor.js.map +1 -1
  64. package/dist/core/tree/delta.d.ts +0 -11
  65. package/dist/core/tree/delta.d.ts.map +1 -1
  66. package/dist/core/tree/delta.js.map +1 -1
  67. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  68. package/dist/core/tree/detachedFieldIndexCodec.js +3 -2
  69. package/dist/core/tree/detachedFieldIndexCodec.js.map +1 -1
  70. package/dist/core/tree/detachedFieldIndexTypes.d.ts +0 -1
  71. package/dist/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  72. package/dist/core/tree/detachedFieldIndexTypes.js.map +1 -1
  73. package/dist/core/tree/index.d.ts +1 -1
  74. package/dist/core/tree/index.d.ts.map +1 -1
  75. package/dist/core/tree/index.js +3 -1
  76. package/dist/core/tree/index.js.map +1 -1
  77. package/dist/core/tree/mapTree.d.ts +20 -4
  78. package/dist/core/tree/mapTree.d.ts.map +1 -1
  79. package/dist/core/tree/mapTree.js +29 -0
  80. package/dist/core/tree/mapTree.js.map +1 -1
  81. package/dist/core/tree/pathTree.d.ts +0 -11
  82. package/dist/core/tree/pathTree.d.ts.map +1 -1
  83. package/dist/core/tree/pathTree.js.map +1 -1
  84. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  85. package/dist/core/tree/treeTextFormat.js +3 -2
  86. package/dist/core/tree/treeTextFormat.js.map +1 -1
  87. package/dist/core/tree/types.d.ts +0 -11
  88. package/dist/core/tree/types.d.ts.map +1 -1
  89. package/dist/core/tree/types.js +0 -4
  90. package/dist/core/tree/types.js.map +1 -1
  91. package/dist/core/tree/visitDelta.d.ts +0 -1
  92. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  93. package/dist/core/tree/visitDelta.js +2 -2
  94. package/dist/core/tree/visitDelta.js.map +1 -1
  95. package/dist/core/tree/visitPath.d.ts +0 -2
  96. package/dist/core/tree/visitPath.d.ts.map +1 -1
  97. package/dist/core/tree/visitPath.js.map +1 -1
  98. package/dist/core/tree/visitorUtils.d.ts +0 -1
  99. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  100. package/dist/core/tree/visitorUtils.js.map +1 -1
  101. package/dist/domains/index.d.ts +1 -1
  102. package/dist/domains/index.d.ts.map +1 -1
  103. package/dist/domains/index.js +2 -1
  104. package/dist/domains/index.js.map +1 -1
  105. package/dist/domains/json/index.d.ts +1 -1
  106. package/dist/domains/json/index.d.ts.map +1 -1
  107. package/dist/domains/json/index.js +2 -1
  108. package/dist/domains/json/index.js.map +1 -1
  109. package/dist/domains/json/jsonCursor.d.ts +36 -2
  110. package/dist/domains/json/jsonCursor.d.ts.map +1 -1
  111. package/dist/domains/json/jsonCursor.js +76 -5
  112. package/dist/domains/json/jsonCursor.js.map +1 -1
  113. package/dist/domains/json/jsonDomainSchema.d.ts +13 -3
  114. package/dist/domains/json/jsonDomainSchema.d.ts.map +1 -1
  115. package/dist/domains/json/jsonDomainSchema.js +12 -4
  116. package/dist/domains/json/jsonDomainSchema.js.map +1 -1
  117. package/dist/domains/leafDomain.d.ts +0 -1
  118. package/dist/domains/leafDomain.d.ts.map +1 -1
  119. package/dist/domains/leafDomain.js +0 -1
  120. package/dist/domains/leafDomain.js.map +1 -1
  121. package/dist/domains/schemaBuilder.d.ts +1 -7
  122. package/dist/domains/schemaBuilder.d.ts.map +1 -1
  123. package/dist/domains/schemaBuilder.js +0 -10
  124. package/dist/domains/schemaBuilder.js.map +1 -1
  125. package/dist/events/events.d.ts +0 -4
  126. package/dist/events/events.d.ts.map +1 -1
  127. package/dist/events/events.js +0 -1
  128. package/dist/events/events.js.map +1 -1
  129. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  130. package/dist/feature-libraries/chunked-forest/basicChunk.js +8 -3
  131. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  132. package/dist/feature-libraries/chunked-forest/chunk.d.ts +1 -1
  133. package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +1 -1
  134. package/dist/feature-libraries/chunked-forest/chunk.js.map +1 -1
  135. package/dist/feature-libraries/chunked-forest/chunkTree.js +3 -3
  136. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  137. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  138. package/dist/feature-libraries/chunked-forest/chunkedForest.js +7 -5
  139. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  140. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +1 -1
  141. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  142. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  143. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +8 -5
  144. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  145. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  146. package/dist/feature-libraries/chunked-forest/uniformChunk.js +5 -3
  147. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  148. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -24
  149. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  150. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +9 -19
  151. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  152. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  153. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  154. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  155. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  156. package/dist/feature-libraries/default-schema/defaultSchema.d.ts +0 -1
  157. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  158. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -1
  159. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  160. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  161. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  162. package/dist/feature-libraries/default-schema/index.js +2 -1
  163. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  164. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +6 -0
  165. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  166. package/dist/feature-libraries/default-schema/schemaChecker.js +6 -0
  167. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  168. package/dist/feature-libraries/editableTreeBinder.d.ts +0 -67
  169. package/dist/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  170. package/dist/feature-libraries/editableTreeBinder.js +5 -24
  171. package/dist/feature-libraries/editableTreeBinder.js.map +1 -1
  172. package/dist/feature-libraries/fieldGenerator.d.ts +0 -3
  173. package/dist/feature-libraries/fieldGenerator.d.ts.map +1 -1
  174. package/dist/feature-libraries/fieldGenerator.js +0 -1
  175. package/dist/feature-libraries/fieldGenerator.js.map +1 -1
  176. package/dist/feature-libraries/flex-map-tree/index.d.ts +1 -1
  177. package/dist/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  178. package/dist/feature-libraries/flex-map-tree/index.js +2 -2
  179. package/dist/feature-libraries/flex-map-tree/index.js.map +1 -1
  180. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +57 -49
  181. package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  182. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +171 -168
  183. package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  184. package/dist/feature-libraries/flex-tree/context.d.ts +0 -1
  185. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  186. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  187. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +17 -282
  188. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  189. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -4
  190. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  191. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  192. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  193. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  194. package/dist/feature-libraries/flex-tree/lazyField.d.ts +9 -26
  195. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  196. package/dist/feature-libraries/flex-tree/lazyField.js +26 -99
  197. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  198. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +2 -10
  199. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  200. package/dist/feature-libraries/flex-tree/lazyNode.js +3 -42
  201. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  202. package/dist/feature-libraries/flex-tree/treeEvents.d.ts +0 -2
  203. package/dist/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  204. package/dist/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  205. package/dist/feature-libraries/flex-tree/utilities.d.ts +2 -1
  206. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  207. package/dist/feature-libraries/flex-tree/utilities.js +4 -0
  208. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  209. package/dist/feature-libraries/forest-summary/codec.js +2 -2
  210. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  211. package/dist/feature-libraries/index.d.ts +6 -8
  212. package/dist/feature-libraries/index.d.ts.map +1 -1
  213. package/dist/feature-libraries/index.js +7 -18
  214. package/dist/feature-libraries/index.js.map +1 -1
  215. package/dist/feature-libraries/mapTreeCursor.d.ts +6 -2
  216. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  217. package/dist/feature-libraries/mapTreeCursor.js +9 -1
  218. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  219. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -4
  220. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +1 -1
  221. package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -1
  222. package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +1 -1
  223. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  224. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  225. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +0 -1
  226. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  227. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +18 -0
  228. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  229. package/dist/feature-libraries/modular-schema/discrepancies.js +105 -2
  230. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  231. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -8
  232. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  233. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +0 -1
  234. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  235. package/dist/feature-libraries/modular-schema/fieldKind.d.ts +1 -3
  236. package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  237. package/dist/feature-libraries/modular-schema/fieldKind.js +1 -2
  238. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  239. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +1 -2
  240. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  241. package/dist/feature-libraries/modular-schema/genericFieldKind.js +57 -85
  242. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  243. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +1 -1
  244. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  245. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +5 -8
  246. package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  247. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.d.ts +3 -14
  248. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.d.ts.map +1 -1
  249. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js +6 -0
  250. package/dist/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  251. package/dist/feature-libraries/modular-schema/index.d.ts +2 -2
  252. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  253. package/dist/feature-libraries/modular-schema/index.js +2 -1
  254. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  255. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  256. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +39 -22
  257. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  258. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -8
  259. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  260. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +192 -228
  261. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  262. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +8 -14
  263. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  264. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  265. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -4
  266. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  267. package/dist/feature-libraries/node-key/nodeKey.js +0 -2
  268. package/dist/feature-libraries/node-key/nodeKey.js.map +1 -1
  269. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -1
  270. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  271. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  272. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  273. package/dist/feature-libraries/object-forest/objectForest.js +1 -10
  274. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  275. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  276. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  277. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  278. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  279. package/dist/feature-libraries/schemaBuilderBase.d.ts +2 -28
  280. package/dist/feature-libraries/schemaBuilderBase.d.ts.map +1 -1
  281. package/dist/feature-libraries/schemaBuilderBase.js +1 -27
  282. package/dist/feature-libraries/schemaBuilderBase.js.map +1 -1
  283. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  284. package/dist/feature-libraries/sequence-field/compose.js +24 -21
  285. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  286. package/dist/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  287. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  288. package/dist/feature-libraries/sequence-field/formatV2.js +7 -6
  289. package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -1
  290. package/dist/feature-libraries/sequence-field/formatV3.d.ts +195 -0
  291. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -0
  292. package/dist/feature-libraries/sequence-field/formatV3.js +23 -0
  293. package/dist/feature-libraries/sequence-field/formatV3.js.map +1 -0
  294. package/dist/feature-libraries/sequence-field/helperTypes.d.ts +11 -0
  295. package/dist/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  296. package/dist/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  297. package/dist/feature-libraries/sequence-field/index.d.ts +1 -1
  298. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  299. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  300. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  301. package/dist/feature-libraries/sequence-field/invert.js +21 -13
  302. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  303. package/dist/feature-libraries/sequence-field/markQueue.js +1 -1
  304. package/dist/feature-libraries/sequence-field/markQueue.js.map +1 -1
  305. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts +2 -2
  306. package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  307. package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  308. package/dist/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  309. package/dist/feature-libraries/sequence-field/rebase.js +24 -6
  310. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  311. package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  312. package/dist/feature-libraries/sequence-field/replaceRevisions.js +16 -3
  313. package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  314. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  315. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +38 -4
  316. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  317. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -1
  318. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  319. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +54 -9
  320. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  321. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +11 -0
  322. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -0
  323. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +85 -0
  324. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -0
  325. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  326. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +2 -0
  327. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  328. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  329. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +4 -1
  330. package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  331. package/dist/feature-libraries/sequence-field/types.d.ts +23 -4
  332. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  333. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  334. package/dist/feature-libraries/sequence-field/utils.d.ts +5 -4
  335. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  336. package/dist/feature-libraries/sequence-field/utils.js +70 -42
  337. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  338. package/dist/feature-libraries/storedToViewSchema.d.ts +0 -1
  339. package/dist/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  340. package/dist/feature-libraries/storedToViewSchema.js +0 -1
  341. package/dist/feature-libraries/storedToViewSchema.js.map +1 -1
  342. package/dist/feature-libraries/treeCursorUtils.d.ts +0 -6
  343. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  344. package/dist/feature-libraries/treeCursorUtils.js +8 -6
  345. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  346. package/dist/feature-libraries/treeTextCursor.d.ts +0 -2
  347. package/dist/feature-libraries/treeTextCursor.d.ts.map +1 -1
  348. package/dist/feature-libraries/treeTextCursor.js +0 -2
  349. package/dist/feature-libraries/treeTextCursor.js.map +1 -1
  350. package/dist/feature-libraries/typed-schema/flexList.d.ts +0 -3
  351. package/dist/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  352. package/dist/feature-libraries/typed-schema/flexList.js.map +1 -1
  353. package/dist/feature-libraries/typed-schema/index.d.ts +1 -1
  354. package/dist/feature-libraries/typed-schema/index.d.ts.map +1 -1
  355. package/dist/feature-libraries/typed-schema/index.js +1 -3
  356. package/dist/feature-libraries/typed-schema/index.js.map +1 -1
  357. package/dist/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  358. package/dist/feature-libraries/typed-schema/schemaCollection.js +0 -4
  359. package/dist/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  360. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts +2 -41
  361. package/dist/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  362. package/dist/feature-libraries/typed-schema/typedTreeSchema.js +1 -40
  363. package/dist/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  364. package/dist/feature-libraries/typed-schema/view.d.ts +0 -1
  365. package/dist/feature-libraries/typed-schema/view.d.ts.map +1 -1
  366. package/dist/feature-libraries/typed-schema/view.js.map +1 -1
  367. package/dist/index.d.ts +8 -9
  368. package/dist/index.d.ts.map +1 -1
  369. package/dist/index.js +31 -90
  370. package/dist/index.js.map +1 -1
  371. package/dist/internalTypes.d.ts +1 -1
  372. package/dist/internalTypes.d.ts.map +1 -1
  373. package/dist/internalTypes.js.map +1 -1
  374. package/dist/packageVersion.d.ts +1 -1
  375. package/dist/packageVersion.js +1 -1
  376. package/dist/packageVersion.js.map +1 -1
  377. package/dist/public.d.ts +3 -1
  378. package/dist/shared-tree/schematizeTree.d.ts +2 -11
  379. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  380. package/dist/shared-tree/schematizeTree.js +13 -2
  381. package/dist/shared-tree/schematizeTree.js.map +1 -1
  382. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  383. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  384. package/dist/shared-tree/schematizingTreeView.js +2 -2
  385. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  386. package/dist/shared-tree/sharedTree.d.ts +4 -17
  387. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  388. package/dist/shared-tree/sharedTree.js +4 -8
  389. package/dist/shared-tree/sharedTree.js.map +1 -1
  390. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  391. package/dist/shared-tree/sharedTreeChangeCodecs.js +4 -0
  392. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  393. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  394. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  395. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +0 -2
  396. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  397. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  398. package/dist/shared-tree/treeApi.js +2 -2
  399. package/dist/shared-tree/treeApi.js.map +1 -1
  400. package/dist/shared-tree/treeCheckout.d.ts +0 -5
  401. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  402. package/dist/shared-tree/treeCheckout.js +5 -3
  403. package/dist/shared-tree/treeCheckout.js.map +1 -1
  404. package/dist/shared-tree/treeView.d.ts +3 -6
  405. package/dist/shared-tree/treeView.d.ts.map +1 -1
  406. package/dist/shared-tree/treeView.js.map +1 -1
  407. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  408. package/dist/shared-tree-core/branch.js +11 -6
  409. package/dist/shared-tree-core/branch.js.map +1 -1
  410. package/dist/shared-tree-core/defaultResubmitMachine.js +3 -3
  411. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  412. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  413. package/dist/shared-tree-core/editManagerCodecs.js +1 -0
  414. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  415. package/dist/shared-tree-core/editManagerFormat.d.ts +2 -2
  416. package/dist/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  417. package/dist/shared-tree-core/editManagerFormat.js +6 -1
  418. package/dist/shared-tree-core/editManagerFormat.js.map +1 -1
  419. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  420. package/dist/shared-tree-core/messageCodecs.js +1 -0
  421. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  422. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  423. package/dist/shared-tree-core/sharedTreeCore.js +3 -1
  424. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  425. package/dist/simple-tree/api/create.d.ts +54 -0
  426. package/dist/simple-tree/api/create.d.ts.map +1 -0
  427. package/dist/simple-tree/api/create.js +99 -0
  428. package/dist/simple-tree/api/create.js.map +1 -0
  429. package/dist/simple-tree/api/index.d.ts +12 -0
  430. package/dist/simple-tree/api/index.d.ts.map +1 -0
  431. package/dist/simple-tree/api/index.js +28 -0
  432. package/dist/simple-tree/api/index.js.map +1 -0
  433. package/{lib/simple-tree → dist/simple-tree/api}/schemaCreationUtilities.d.ts +7 -4
  434. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -0
  435. package/dist/simple-tree/{schemaCreationUtilities.js → api/schemaCreationUtilities.js} +1 -1
  436. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -0
  437. package/dist/simple-tree/{schemaFactory.d.ts → api/schemaFactory.d.ts} +15 -14
  438. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -0
  439. package/dist/simple-tree/{schemaFactory.js → api/schemaFactory.js} +10 -9
  440. package/dist/simple-tree/api/schemaFactory.js.map +1 -0
  441. package/{lib/simple-tree → dist/simple-tree/api}/schemaFactoryRecursive.d.ts +40 -7
  442. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -0
  443. package/dist/simple-tree/{schemaFactoryRecursive.js → api/schemaFactoryRecursive.js} +1 -1
  444. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -0
  445. package/dist/simple-tree/api/testRecursiveDomain.d.ts +62 -0
  446. package/dist/simple-tree/api/testRecursiveDomain.d.ts.map +1 -0
  447. package/dist/simple-tree/api/testRecursiveDomain.js.map +1 -0
  448. package/{lib/simple-tree → dist/simple-tree/api}/tree.d.ts +111 -20
  449. package/dist/simple-tree/api/tree.d.ts.map +1 -0
  450. package/dist/simple-tree/api/tree.js +173 -0
  451. package/dist/simple-tree/api/tree.js.map +1 -0
  452. package/dist/simple-tree/{treeNodeApi.d.ts → api/treeNodeApi.d.ts} +6 -5
  453. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -0
  454. package/dist/simple-tree/{treeNodeApi.js → api/treeNodeApi.js} +28 -20
  455. package/dist/simple-tree/api/treeNodeApi.js.map +1 -0
  456. package/dist/simple-tree/api/verboseTree.d.ts +136 -0
  457. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -0
  458. package/dist/simple-tree/api/verboseTree.js +220 -0
  459. package/dist/simple-tree/api/verboseTree.js.map +1 -0
  460. package/dist/simple-tree/arrayNode.d.ts +3 -3
  461. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  462. package/dist/simple-tree/arrayNode.js +70 -69
  463. package/dist/simple-tree/arrayNode.js.map +1 -1
  464. package/dist/simple-tree/core/index.d.ts +10 -0
  465. package/dist/simple-tree/core/index.d.ts.map +1 -0
  466. package/dist/simple-tree/core/index.js +27 -0
  467. package/dist/simple-tree/core/index.js.map +1 -0
  468. package/{lib/simple-tree → dist/simple-tree/core}/schemaCaching.d.ts +2 -9
  469. package/dist/simple-tree/core/schemaCaching.d.ts.map +1 -0
  470. package/dist/simple-tree/{schemaCaching.js → core/schemaCaching.js} +2 -23
  471. package/dist/simple-tree/core/schemaCaching.js.map +1 -0
  472. package/dist/simple-tree/core/treeNodeKernel.d.ts +57 -0
  473. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -0
  474. package/dist/simple-tree/{treeNodeKernel.js → core/treeNodeKernel.js} +49 -4
  475. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -0
  476. package/dist/simple-tree/core/treeNodeSchema.d.ts +149 -0
  477. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -0
  478. package/dist/simple-tree/core/treeNodeSchema.js +35 -0
  479. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -0
  480. package/dist/simple-tree/{types.d.ts → core/types.d.ts} +23 -70
  481. package/dist/simple-tree/core/types.d.ts.map +1 -0
  482. package/dist/simple-tree/core/types.js +117 -0
  483. package/dist/simple-tree/core/types.js.map +1 -0
  484. package/dist/simple-tree/core/withType.d.ts +82 -0
  485. package/dist/simple-tree/core/withType.d.ts.map +1 -0
  486. package/dist/simple-tree/core/withType.js +39 -0
  487. package/dist/simple-tree/core/withType.js.map +1 -0
  488. package/dist/simple-tree/getJsonSchema.d.ts +55 -0
  489. package/dist/simple-tree/getJsonSchema.d.ts.map +1 -0
  490. package/dist/simple-tree/getJsonSchema.js +69 -0
  491. package/dist/simple-tree/getJsonSchema.js.map +1 -0
  492. package/dist/simple-tree/getSimpleFieldSchema.d.ts +14 -0
  493. package/dist/simple-tree/getSimpleFieldSchema.d.ts.map +1 -0
  494. package/dist/simple-tree/getSimpleFieldSchema.js +29 -0
  495. package/dist/simple-tree/getSimpleFieldSchema.js.map +1 -0
  496. package/dist/simple-tree/getSimpleSchema.d.ts +58 -0
  497. package/dist/simple-tree/getSimpleSchema.d.ts.map +1 -0
  498. package/dist/simple-tree/getSimpleSchema.js +68 -0
  499. package/dist/simple-tree/getSimpleSchema.js.map +1 -0
  500. package/dist/simple-tree/index.d.ts +12 -13
  501. package/dist/simple-tree/index.d.ts.map +1 -1
  502. package/dist/simple-tree/index.js +26 -23
  503. package/dist/simple-tree/index.js.map +1 -1
  504. package/dist/simple-tree/jsonSchema.d.ts +206 -0
  505. package/dist/simple-tree/jsonSchema.d.ts.map +1 -0
  506. package/dist/{feature-libraries/schema-aware/index.js → simple-tree/jsonSchema.js} +1 -1
  507. package/dist/simple-tree/jsonSchema.js.map +1 -0
  508. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  509. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  510. package/dist/simple-tree/leafNodeSchema.js +3 -4
  511. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  512. package/dist/simple-tree/mapNode.d.ts +9 -3
  513. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  514. package/dist/simple-tree/mapNode.js +33 -35
  515. package/dist/simple-tree/mapNode.js.map +1 -1
  516. package/dist/simple-tree/objectNode.d.ts +18 -16
  517. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  518. package/dist/simple-tree/objectNode.js +43 -44
  519. package/dist/simple-tree/objectNode.js.map +1 -1
  520. package/dist/simple-tree/objectNodeTypes.d.ts +38 -0
  521. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -0
  522. package/dist/simple-tree/objectNodeTypes.js +19 -0
  523. package/dist/simple-tree/objectNodeTypes.js.map +1 -0
  524. package/dist/simple-tree/proxies.d.ts +6 -25
  525. package/dist/simple-tree/proxies.d.ts.map +1 -1
  526. package/dist/simple-tree/proxies.js +50 -63
  527. package/dist/simple-tree/proxies.js.map +1 -1
  528. package/dist/simple-tree/proxyBinding.d.ts +45 -22
  529. package/dist/simple-tree/proxyBinding.d.ts.map +1 -1
  530. package/dist/simple-tree/proxyBinding.js +94 -59
  531. package/dist/simple-tree/proxyBinding.js.map +1 -1
  532. package/dist/simple-tree/schemaTypes.d.ts +10 -159
  533. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  534. package/dist/simple-tree/schemaTypes.js +11 -42
  535. package/dist/simple-tree/schemaTypes.js.map +1 -1
  536. package/dist/simple-tree/simpleSchema.d.ts +124 -0
  537. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  538. package/dist/{feature-libraries/schema-aware/schemaAware.js → simple-tree/simpleSchema.js} +1 -1
  539. package/dist/simple-tree/simpleSchema.js.map +1 -0
  540. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts +12 -0
  541. package/dist/simple-tree/simpleSchemaToJsonSchema.d.ts.map +1 -0
  542. package/dist/simple-tree/simpleSchemaToJsonSchema.js +146 -0
  543. package/dist/simple-tree/simpleSchemaToJsonSchema.js.map +1 -0
  544. package/dist/simple-tree/toFlexSchema.d.ts +4 -12
  545. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  546. package/dist/simple-tree/toFlexSchema.js +42 -52
  547. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  548. package/dist/simple-tree/toMapTree.d.ts +39 -39
  549. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  550. package/dist/simple-tree/toMapTree.js +227 -171
  551. package/dist/simple-tree/toMapTree.js.map +1 -1
  552. package/dist/simple-tree/treeNodeValid.d.ts +74 -0
  553. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -0
  554. package/dist/simple-tree/{types.js → treeNodeValid.js} +18 -111
  555. package/dist/simple-tree/treeNodeValid.js.map +1 -0
  556. package/dist/simple-tree/typesUnsafe.d.ts +35 -4
  557. package/dist/simple-tree/typesUnsafe.d.ts.map +1 -1
  558. package/dist/simple-tree/typesUnsafe.js.map +1 -1
  559. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts +11 -0
  560. package/dist/simple-tree/viewSchemaToSimpleSchema.d.ts.map +1 -0
  561. package/dist/simple-tree/viewSchemaToSimpleSchema.js +171 -0
  562. package/dist/simple-tree/viewSchemaToSimpleSchema.js.map +1 -0
  563. package/dist/util/brand.d.ts +0 -3
  564. package/dist/util/brand.d.ts.map +1 -1
  565. package/dist/util/brand.js +1 -2
  566. package/dist/util/brand.js.map +1 -1
  567. package/dist/util/brandedMap.d.ts +0 -5
  568. package/dist/util/brandedMap.d.ts.map +1 -1
  569. package/dist/util/brandedMap.js +0 -1
  570. package/dist/util/brandedMap.js.map +1 -1
  571. package/dist/util/idAllocator.d.ts +0 -2
  572. package/dist/util/idAllocator.d.ts.map +1 -1
  573. package/dist/util/idAllocator.js +0 -1
  574. package/dist/util/idAllocator.js.map +1 -1
  575. package/dist/util/index.d.ts +2 -2
  576. package/dist/util/index.d.ts.map +1 -1
  577. package/dist/util/index.js +4 -2
  578. package/dist/util/index.js.map +1 -1
  579. package/dist/util/nestedMap.d.ts +5 -19
  580. package/dist/util/nestedMap.d.ts.map +1 -1
  581. package/dist/util/nestedMap.js +17 -17
  582. package/dist/util/nestedMap.js.map +1 -1
  583. package/dist/util/opaque.d.ts +0 -4
  584. package/dist/util/opaque.d.ts.map +1 -1
  585. package/dist/util/opaque.js +0 -2
  586. package/dist/util/opaque.js.map +1 -1
  587. package/dist/util/rangeMap.d.ts +0 -2
  588. package/dist/util/rangeMap.d.ts.map +1 -1
  589. package/dist/util/rangeMap.js +4 -3
  590. package/dist/util/rangeMap.js.map +1 -1
  591. package/dist/util/transactionResult.d.ts +0 -1
  592. package/dist/util/transactionResult.d.ts.map +1 -1
  593. package/dist/util/transactionResult.js +0 -1
  594. package/dist/util/transactionResult.js.map +1 -1
  595. package/dist/util/typeCheck.d.ts +2 -20
  596. package/dist/util/typeCheck.d.ts.map +1 -1
  597. package/dist/util/typeCheck.js.map +1 -1
  598. package/dist/util/typeCheckTests.d.ts +4 -4
  599. package/dist/util/typeCheckTests.d.ts.map +1 -1
  600. package/dist/util/typeCheckTests.js.map +1 -1
  601. package/dist/util/typeUtils.d.ts +0 -7
  602. package/dist/util/typeUtils.d.ts.map +1 -1
  603. package/dist/util/typeUtils.js.map +1 -1
  604. package/dist/util/utils.d.ts +6 -8
  605. package/dist/util/utils.d.ts.map +1 -1
  606. package/dist/util/utils.js +14 -5
  607. package/dist/util/utils.js.map +1 -1
  608. package/lib/beta.d.ts +3 -1
  609. package/lib/codec/discriminatedUnions.d.ts +11 -5
  610. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  611. package/lib/codec/discriminatedUnions.js.map +1 -1
  612. package/lib/codec/index.d.ts +1 -1
  613. package/lib/codec/index.d.ts.map +1 -1
  614. package/lib/codec/index.js +1 -1
  615. package/lib/codec/index.js.map +1 -1
  616. package/lib/core/forest/editableForest.d.ts +1 -5
  617. package/lib/core/forest/editableForest.d.ts.map +1 -1
  618. package/lib/core/forest/editableForest.js.map +1 -1
  619. package/lib/core/forest/forest.d.ts +0 -6
  620. package/lib/core/forest/forest.d.ts.map +1 -1
  621. package/lib/core/forest/forest.js +0 -2
  622. package/lib/core/forest/forest.js.map +1 -1
  623. package/lib/core/index.d.ts +2 -2
  624. package/lib/core/index.d.ts.map +1 -1
  625. package/lib/core/index.js +2 -2
  626. package/lib/core/index.js.map +1 -1
  627. package/lib/core/rebase/changeRebaser.d.ts +0 -4
  628. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  629. package/lib/core/rebase/changeRebaser.js.map +1 -1
  630. package/lib/core/rebase/index.d.ts +1 -1
  631. package/lib/core/rebase/index.d.ts.map +1 -1
  632. package/lib/core/rebase/index.js +1 -1
  633. package/lib/core/rebase/index.js.map +1 -1
  634. package/lib/core/rebase/types.d.ts +1 -8
  635. package/lib/core/rebase/types.d.ts.map +1 -1
  636. package/lib/core/rebase/types.js +1 -7
  637. package/lib/core/rebase/types.js.map +1 -1
  638. package/lib/core/rebase/utils.d.ts +0 -1
  639. package/lib/core/rebase/utils.d.ts.map +1 -1
  640. package/lib/core/rebase/utils.js +13 -8
  641. package/lib/core/rebase/utils.js.map +1 -1
  642. package/lib/core/schema-stored/multiplicity.d.ts +0 -1
  643. package/lib/core/schema-stored/multiplicity.d.ts.map +1 -1
  644. package/lib/core/schema-stored/multiplicity.js +0 -1
  645. package/lib/core/schema-stored/multiplicity.js.map +1 -1
  646. package/lib/core/schema-stored/schema.d.ts +0 -7
  647. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  648. package/lib/core/schema-stored/schema.js +0 -4
  649. package/lib/core/schema-stored/schema.js.map +1 -1
  650. package/lib/core/schema-stored/storedSchemaRepository.d.ts +0 -3
  651. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  652. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  653. package/lib/core/schema-view/view.d.ts +0 -3
  654. package/lib/core/schema-view/view.d.ts.map +1 -1
  655. package/lib/core/schema-view/view.js +0 -1
  656. package/lib/core/schema-view/view.js.map +1 -1
  657. package/lib/core/tree/anchorSet.d.ts +0 -10
  658. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  659. package/lib/core/tree/anchorSet.js +1 -4
  660. package/lib/core/tree/anchorSet.js.map +1 -1
  661. package/lib/core/tree/cursor.d.ts +1 -6
  662. package/lib/core/tree/cursor.d.ts.map +1 -1
  663. package/lib/core/tree/cursor.js +0 -2
  664. package/lib/core/tree/cursor.js.map +1 -1
  665. package/lib/core/tree/delta.d.ts +0 -11
  666. package/lib/core/tree/delta.d.ts.map +1 -1
  667. package/lib/core/tree/delta.js.map +1 -1
  668. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +1 -1
  669. package/lib/core/tree/detachedFieldIndexCodec.js +4 -3
  670. package/lib/core/tree/detachedFieldIndexCodec.js.map +1 -1
  671. package/lib/core/tree/detachedFieldIndexTypes.d.ts +0 -1
  672. package/lib/core/tree/detachedFieldIndexTypes.d.ts.map +1 -1
  673. package/lib/core/tree/detachedFieldIndexTypes.js.map +1 -1
  674. package/lib/core/tree/index.d.ts +1 -1
  675. package/lib/core/tree/index.d.ts.map +1 -1
  676. package/lib/core/tree/index.js +1 -0
  677. package/lib/core/tree/index.js.map +1 -1
  678. package/lib/core/tree/mapTree.d.ts +20 -4
  679. package/lib/core/tree/mapTree.d.ts.map +1 -1
  680. package/lib/core/tree/mapTree.js +27 -1
  681. package/lib/core/tree/mapTree.js.map +1 -1
  682. package/lib/core/tree/pathTree.d.ts +0 -11
  683. package/lib/core/tree/pathTree.d.ts.map +1 -1
  684. package/lib/core/tree/pathTree.js.map +1 -1
  685. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  686. package/lib/core/tree/treeTextFormat.js +3 -2
  687. package/lib/core/tree/treeTextFormat.js.map +1 -1
  688. package/lib/core/tree/types.d.ts +0 -11
  689. package/lib/core/tree/types.d.ts.map +1 -1
  690. package/lib/core/tree/types.js +0 -4
  691. package/lib/core/tree/types.js.map +1 -1
  692. package/lib/core/tree/visitDelta.d.ts +0 -1
  693. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  694. package/lib/core/tree/visitDelta.js +2 -2
  695. package/lib/core/tree/visitDelta.js.map +1 -1
  696. package/lib/core/tree/visitPath.d.ts +0 -2
  697. package/lib/core/tree/visitPath.d.ts.map +1 -1
  698. package/lib/core/tree/visitPath.js.map +1 -1
  699. package/lib/core/tree/visitorUtils.d.ts +0 -1
  700. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  701. package/lib/core/tree/visitorUtils.js.map +1 -1
  702. package/lib/domains/index.d.ts +1 -1
  703. package/lib/domains/index.d.ts.map +1 -1
  704. package/lib/domains/index.js +1 -1
  705. package/lib/domains/index.js.map +1 -1
  706. package/lib/domains/json/index.d.ts +1 -1
  707. package/lib/domains/json/index.d.ts.map +1 -1
  708. package/lib/domains/json/index.js +1 -1
  709. package/lib/domains/json/index.js.map +1 -1
  710. package/lib/domains/json/jsonCursor.d.ts +36 -2
  711. package/lib/domains/json/jsonCursor.d.ts.map +1 -1
  712. package/lib/domains/json/jsonCursor.js +76 -5
  713. package/lib/domains/json/jsonCursor.js.map +1 -1
  714. package/lib/domains/json/jsonDomainSchema.d.ts +13 -3
  715. package/lib/domains/json/jsonDomainSchema.d.ts.map +1 -1
  716. package/lib/domains/json/jsonDomainSchema.js +9 -1
  717. package/lib/domains/json/jsonDomainSchema.js.map +1 -1
  718. package/lib/domains/leafDomain.d.ts +0 -1
  719. package/lib/domains/leafDomain.d.ts.map +1 -1
  720. package/lib/domains/leafDomain.js +0 -1
  721. package/lib/domains/leafDomain.js.map +1 -1
  722. package/lib/domains/schemaBuilder.d.ts +1 -7
  723. package/lib/domains/schemaBuilder.d.ts.map +1 -1
  724. package/lib/domains/schemaBuilder.js +1 -11
  725. package/lib/domains/schemaBuilder.js.map +1 -1
  726. package/lib/events/events.d.ts +0 -4
  727. package/lib/events/events.d.ts.map +1 -1
  728. package/lib/events/events.js +0 -1
  729. package/lib/events/events.js.map +1 -1
  730. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  731. package/lib/feature-libraries/chunked-forest/basicChunk.js +9 -4
  732. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  733. package/lib/feature-libraries/chunked-forest/chunk.d.ts +1 -1
  734. package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +1 -1
  735. package/lib/feature-libraries/chunked-forest/chunk.js.map +1 -1
  736. package/lib/feature-libraries/chunked-forest/chunkTree.js +4 -4
  737. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  738. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  739. package/lib/feature-libraries/chunked-forest/chunkedForest.js +8 -6
  740. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  741. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js +2 -2
  742. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  743. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  744. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -6
  745. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  746. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  747. package/lib/feature-libraries/chunked-forest/uniformChunk.js +6 -4
  748. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  749. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -24
  750. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  751. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +6 -16
  752. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  753. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -6
  754. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  755. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
  756. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  757. package/lib/feature-libraries/default-schema/defaultSchema.d.ts +0 -1
  758. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  759. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -1
  760. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  761. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  762. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  763. package/lib/feature-libraries/default-schema/index.js +1 -1
  764. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  765. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +6 -0
  766. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  767. package/lib/feature-libraries/default-schema/schemaChecker.js +6 -0
  768. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  769. package/lib/feature-libraries/editableTreeBinder.d.ts +0 -67
  770. package/lib/feature-libraries/editableTreeBinder.d.ts.map +1 -1
  771. package/lib/feature-libraries/editableTreeBinder.js +6 -25
  772. package/lib/feature-libraries/editableTreeBinder.js.map +1 -1
  773. package/lib/feature-libraries/fieldGenerator.d.ts +0 -3
  774. package/lib/feature-libraries/fieldGenerator.d.ts.map +1 -1
  775. package/lib/feature-libraries/fieldGenerator.js +0 -1
  776. package/lib/feature-libraries/fieldGenerator.js.map +1 -1
  777. package/lib/feature-libraries/flex-map-tree/index.d.ts +1 -1
  778. package/lib/feature-libraries/flex-map-tree/index.d.ts.map +1 -1
  779. package/lib/feature-libraries/flex-map-tree/index.js +1 -1
  780. package/lib/feature-libraries/flex-map-tree/index.js.map +1 -1
  781. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +57 -49
  782. package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
  783. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +172 -168
  784. package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
  785. package/lib/feature-libraries/flex-tree/context.d.ts +0 -1
  786. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  787. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  788. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +17 -282
  789. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  790. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -4
  791. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  792. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  793. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  794. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  795. package/lib/feature-libraries/flex-tree/lazyField.d.ts +9 -26
  796. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  797. package/lib/feature-libraries/flex-tree/lazyField.js +28 -101
  798. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  799. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +2 -10
  800. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  801. package/lib/feature-libraries/flex-tree/lazyNode.js +4 -42
  802. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  803. package/lib/feature-libraries/flex-tree/treeEvents.d.ts +0 -2
  804. package/lib/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
  805. package/lib/feature-libraries/flex-tree/treeEvents.js.map +1 -1
  806. package/lib/feature-libraries/flex-tree/utilities.d.ts +2 -1
  807. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  808. package/lib/feature-libraries/flex-tree/utilities.js +4 -0
  809. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  810. package/lib/feature-libraries/forest-summary/codec.js +3 -3
  811. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  812. package/lib/feature-libraries/index.d.ts +6 -8
  813. package/lib/feature-libraries/index.d.ts.map +1 -1
  814. package/lib/feature-libraries/index.js +5 -6
  815. package/lib/feature-libraries/index.js.map +1 -1
  816. package/lib/feature-libraries/mapTreeCursor.d.ts +6 -2
  817. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  818. package/lib/feature-libraries/mapTreeCursor.js +7 -0
  819. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  820. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -4
  821. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +1 -1
  822. package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -1
  823. package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +1 -1
  824. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  825. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  826. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +0 -1
  827. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  828. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +18 -0
  829. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  830. package/lib/feature-libraries/modular-schema/discrepancies.js +103 -1
  831. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  832. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -8
  833. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  834. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +0 -1
  835. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  836. package/lib/feature-libraries/modular-schema/fieldKind.d.ts +1 -3
  837. package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  838. package/lib/feature-libraries/modular-schema/fieldKind.js +1 -2
  839. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  840. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +1 -2
  841. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  842. package/lib/feature-libraries/modular-schema/genericFieldKind.js +56 -83
  843. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  844. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts +1 -1
  845. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.d.ts.map +1 -1
  846. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +6 -9
  847. package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
  848. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.d.ts +3 -14
  849. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.d.ts.map +1 -1
  850. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.js +4 -1
  851. package/lib/feature-libraries/modular-schema/genericFieldKindTypes.js.map +1 -1
  852. package/lib/feature-libraries/modular-schema/index.d.ts +2 -2
  853. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  854. package/lib/feature-libraries/modular-schema/index.js +1 -1
  855. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  856. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  857. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +42 -25
  858. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  859. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -8
  860. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  861. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +169 -206
  862. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  863. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +8 -14
  864. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  865. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  866. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -4
  867. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +1 -1
  868. package/lib/feature-libraries/node-key/nodeKey.js +0 -2
  869. package/lib/feature-libraries/node-key/nodeKey.js.map +1 -1
  870. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -1
  871. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +1 -1
  872. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +1 -1
  873. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  874. package/lib/feature-libraries/object-forest/objectForest.js +2 -11
  875. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  876. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  877. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  878. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  879. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  880. package/lib/feature-libraries/schemaBuilderBase.d.ts +2 -28
  881. package/lib/feature-libraries/schemaBuilderBase.d.ts.map +1 -1
  882. package/lib/feature-libraries/schemaBuilderBase.js +2 -28
  883. package/lib/feature-libraries/schemaBuilderBase.js.map +1 -1
  884. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  885. package/lib/feature-libraries/sequence-field/compose.js +25 -22
  886. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  887. package/lib/feature-libraries/sequence-field/formatV2.d.ts +3 -3
  888. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  889. package/lib/feature-libraries/sequence-field/formatV2.js +3 -3
  890. package/lib/feature-libraries/sequence-field/formatV2.js.map +1 -1
  891. package/lib/feature-libraries/sequence-field/formatV3.d.ts +195 -0
  892. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -0
  893. package/lib/feature-libraries/sequence-field/formatV3.js +19 -0
  894. package/lib/feature-libraries/sequence-field/formatV3.js.map +1 -0
  895. package/lib/feature-libraries/sequence-field/helperTypes.d.ts +11 -0
  896. package/lib/feature-libraries/sequence-field/helperTypes.d.ts.map +1 -1
  897. package/lib/feature-libraries/sequence-field/helperTypes.js.map +1 -1
  898. package/lib/feature-libraries/sequence-field/index.d.ts +1 -1
  899. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  900. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  901. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  902. package/lib/feature-libraries/sequence-field/invert.js +22 -14
  903. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  904. package/lib/feature-libraries/sequence-field/markQueue.js +2 -2
  905. package/lib/feature-libraries/sequence-field/markQueue.js.map +1 -1
  906. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts +2 -2
  907. package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
  908. package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
  909. package/lib/feature-libraries/sequence-field/rebase.d.ts.map +1 -1
  910. package/lib/feature-libraries/sequence-field/rebase.js +25 -7
  911. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  912. package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
  913. package/lib/feature-libraries/sequence-field/replaceRevisions.js +16 -3
  914. package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
  915. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  916. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +40 -6
  917. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  918. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -1
  919. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  920. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +55 -11
  921. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  922. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +11 -0
  923. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -0
  924. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +81 -0
  925. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -0
  926. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  927. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +2 -0
  928. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  929. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
  930. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +5 -2
  931. package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
  932. package/lib/feature-libraries/sequence-field/types.d.ts +23 -4
  933. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  934. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  935. package/lib/feature-libraries/sequence-field/utils.d.ts +5 -4
  936. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  937. package/lib/feature-libraries/sequence-field/utils.js +67 -41
  938. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  939. package/lib/feature-libraries/storedToViewSchema.d.ts +0 -1
  940. package/lib/feature-libraries/storedToViewSchema.d.ts.map +1 -1
  941. package/lib/feature-libraries/storedToViewSchema.js +0 -1
  942. package/lib/feature-libraries/storedToViewSchema.js.map +1 -1
  943. package/lib/feature-libraries/treeCursorUtils.d.ts +0 -6
  944. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  945. package/lib/feature-libraries/treeCursorUtils.js +9 -7
  946. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  947. package/lib/feature-libraries/treeTextCursor.d.ts +0 -2
  948. package/lib/feature-libraries/treeTextCursor.d.ts.map +1 -1
  949. package/lib/feature-libraries/treeTextCursor.js +0 -2
  950. package/lib/feature-libraries/treeTextCursor.js.map +1 -1
  951. package/lib/feature-libraries/typed-schema/flexList.d.ts +0 -3
  952. package/lib/feature-libraries/typed-schema/flexList.d.ts.map +1 -1
  953. package/lib/feature-libraries/typed-schema/flexList.js.map +1 -1
  954. package/lib/feature-libraries/typed-schema/index.d.ts +1 -1
  955. package/lib/feature-libraries/typed-schema/index.d.ts.map +1 -1
  956. package/lib/feature-libraries/typed-schema/index.js +1 -1
  957. package/lib/feature-libraries/typed-schema/index.js.map +1 -1
  958. package/lib/feature-libraries/typed-schema/schemaCollection.d.ts.map +1 -1
  959. package/lib/feature-libraries/typed-schema/schemaCollection.js +1 -5
  960. package/lib/feature-libraries/typed-schema/schemaCollection.js.map +1 -1
  961. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts +2 -41
  962. package/lib/feature-libraries/typed-schema/typedTreeSchema.d.ts.map +1 -1
  963. package/lib/feature-libraries/typed-schema/typedTreeSchema.js +1 -38
  964. package/lib/feature-libraries/typed-schema/typedTreeSchema.js.map +1 -1
  965. package/lib/feature-libraries/typed-schema/view.d.ts +0 -1
  966. package/lib/feature-libraries/typed-schema/view.d.ts.map +1 -1
  967. package/lib/feature-libraries/typed-schema/view.js.map +1 -1
  968. package/lib/index.d.ts +8 -9
  969. package/lib/index.d.ts.map +1 -1
  970. package/lib/index.js +4 -9
  971. package/lib/index.js.map +1 -1
  972. package/lib/internalTypes.d.ts +1 -1
  973. package/lib/internalTypes.d.ts.map +1 -1
  974. package/lib/internalTypes.js.map +1 -1
  975. package/lib/packageVersion.d.ts +1 -1
  976. package/lib/packageVersion.js +1 -1
  977. package/lib/packageVersion.js.map +1 -1
  978. package/lib/public.d.ts +3 -1
  979. package/lib/shared-tree/schematizeTree.d.ts +2 -11
  980. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  981. package/lib/shared-tree/schematizeTree.js +15 -4
  982. package/lib/shared-tree/schematizeTree.js.map +1 -1
  983. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  984. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  985. package/lib/shared-tree/schematizingTreeView.js +3 -3
  986. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  987. package/lib/shared-tree/sharedTree.d.ts +4 -17
  988. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  989. package/lib/shared-tree/sharedTree.js +6 -10
  990. package/lib/shared-tree/sharedTree.js.map +1 -1
  991. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  992. package/lib/shared-tree/sharedTreeChangeCodecs.js +4 -0
  993. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  994. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  995. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  996. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +0 -2
  997. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  998. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  999. package/lib/shared-tree/treeApi.js +3 -3
  1000. package/lib/shared-tree/treeApi.js.map +1 -1
  1001. package/lib/shared-tree/treeCheckout.d.ts +0 -5
  1002. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  1003. package/lib/shared-tree/treeCheckout.js +6 -4
  1004. package/lib/shared-tree/treeCheckout.js.map +1 -1
  1005. package/lib/shared-tree/treeView.d.ts +3 -6
  1006. package/lib/shared-tree/treeView.d.ts.map +1 -1
  1007. package/lib/shared-tree/treeView.js.map +1 -1
  1008. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  1009. package/lib/shared-tree-core/branch.js +12 -7
  1010. package/lib/shared-tree-core/branch.js.map +1 -1
  1011. package/lib/shared-tree-core/defaultResubmitMachine.js +4 -4
  1012. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  1013. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  1014. package/lib/shared-tree-core/editManagerCodecs.js +1 -0
  1015. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  1016. package/lib/shared-tree-core/editManagerFormat.d.ts +2 -2
  1017. package/lib/shared-tree-core/editManagerFormat.d.ts.map +1 -1
  1018. package/lib/shared-tree-core/editManagerFormat.js +6 -1
  1019. package/lib/shared-tree-core/editManagerFormat.js.map +1 -1
  1020. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  1021. package/lib/shared-tree-core/messageCodecs.js +1 -0
  1022. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  1023. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  1024. package/lib/shared-tree-core/sharedTreeCore.js +4 -2
  1025. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  1026. package/lib/simple-tree/api/create.d.ts +54 -0
  1027. package/lib/simple-tree/api/create.d.ts.map +1 -0
  1028. package/lib/simple-tree/api/create.js +92 -0
  1029. package/lib/simple-tree/api/create.js.map +1 -0
  1030. package/lib/simple-tree/api/index.d.ts +12 -0
  1031. package/lib/simple-tree/api/index.d.ts.map +1 -0
  1032. package/lib/simple-tree/api/index.js +13 -0
  1033. package/lib/simple-tree/api/index.js.map +1 -0
  1034. package/{dist/simple-tree → lib/simple-tree/api}/schemaCreationUtilities.d.ts +7 -4
  1035. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -0
  1036. package/lib/simple-tree/{schemaCreationUtilities.js → api/schemaCreationUtilities.js} +1 -1
  1037. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -0
  1038. package/lib/simple-tree/{schemaFactory.d.ts → api/schemaFactory.d.ts} +15 -14
  1039. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -0
  1040. package/lib/simple-tree/{schemaFactory.js → api/schemaFactory.js} +9 -8
  1041. package/lib/simple-tree/api/schemaFactory.js.map +1 -0
  1042. package/{dist/simple-tree → lib/simple-tree/api}/schemaFactoryRecursive.d.ts +40 -7
  1043. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -0
  1044. package/lib/simple-tree/{schemaFactoryRecursive.js → api/schemaFactoryRecursive.js} +1 -1
  1045. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -0
  1046. package/lib/simple-tree/api/testRecursiveDomain.d.ts +62 -0
  1047. package/lib/simple-tree/api/testRecursiveDomain.d.ts.map +1 -0
  1048. package/lib/simple-tree/api/testRecursiveDomain.js.map +1 -0
  1049. package/{dist/simple-tree → lib/simple-tree/api}/tree.d.ts +111 -20
  1050. package/lib/simple-tree/api/tree.d.ts.map +1 -0
  1051. package/lib/simple-tree/api/tree.js +165 -0
  1052. package/lib/simple-tree/api/tree.js.map +1 -0
  1053. package/lib/simple-tree/{treeNodeApi.d.ts → api/treeNodeApi.d.ts} +6 -5
  1054. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -0
  1055. package/lib/simple-tree/{treeNodeApi.js → api/treeNodeApi.js} +25 -17
  1056. package/lib/simple-tree/api/treeNodeApi.js.map +1 -0
  1057. package/lib/simple-tree/api/verboseTree.d.ts +136 -0
  1058. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -0
  1059. package/lib/simple-tree/api/verboseTree.js +213 -0
  1060. package/lib/simple-tree/api/verboseTree.js.map +1 -0
  1061. package/lib/simple-tree/arrayNode.d.ts +3 -3
  1062. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  1063. package/lib/simple-tree/arrayNode.js +56 -53
  1064. package/lib/simple-tree/arrayNode.js.map +1 -1
  1065. package/lib/simple-tree/core/index.d.ts +10 -0
  1066. package/lib/simple-tree/core/index.d.ts.map +1 -0
  1067. package/lib/simple-tree/core/index.js +10 -0
  1068. package/lib/simple-tree/core/index.js.map +1 -0
  1069. package/{dist/simple-tree → lib/simple-tree/core}/schemaCaching.d.ts +2 -9
  1070. package/lib/simple-tree/core/schemaCaching.d.ts.map +1 -0
  1071. package/lib/simple-tree/{schemaCaching.js → core/schemaCaching.js} +1 -21
  1072. package/lib/simple-tree/core/schemaCaching.js.map +1 -0
  1073. package/lib/simple-tree/core/treeNodeKernel.d.ts +57 -0
  1074. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -0
  1075. package/lib/simple-tree/{treeNodeKernel.js → core/treeNodeKernel.js} +45 -3
  1076. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -0
  1077. package/lib/simple-tree/core/treeNodeSchema.d.ts +149 -0
  1078. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -0
  1079. package/lib/simple-tree/core/treeNodeSchema.js +32 -0
  1080. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -0
  1081. package/lib/simple-tree/{types.d.ts → core/types.d.ts} +23 -70
  1082. package/lib/simple-tree/core/types.d.ts.map +1 -0
  1083. package/lib/simple-tree/core/types.js +111 -0
  1084. package/lib/simple-tree/core/types.js.map +1 -0
  1085. package/lib/simple-tree/core/withType.d.ts +82 -0
  1086. package/lib/simple-tree/core/withType.d.ts.map +1 -0
  1087. package/lib/simple-tree/core/withType.js +36 -0
  1088. package/lib/simple-tree/core/withType.js.map +1 -0
  1089. package/lib/simple-tree/getJsonSchema.d.ts +55 -0
  1090. package/lib/simple-tree/getJsonSchema.d.ts.map +1 -0
  1091. package/lib/simple-tree/getJsonSchema.js +65 -0
  1092. package/lib/simple-tree/getJsonSchema.js.map +1 -0
  1093. package/lib/simple-tree/getSimpleFieldSchema.d.ts +14 -0
  1094. package/lib/simple-tree/getSimpleFieldSchema.d.ts.map +1 -0
  1095. package/lib/simple-tree/getSimpleFieldSchema.js +25 -0
  1096. package/lib/simple-tree/getSimpleFieldSchema.js.map +1 -0
  1097. package/lib/simple-tree/getSimpleSchema.d.ts +58 -0
  1098. package/lib/simple-tree/getSimpleSchema.d.ts.map +1 -0
  1099. package/lib/simple-tree/getSimpleSchema.js +64 -0
  1100. package/lib/simple-tree/getSimpleSchema.js.map +1 -0
  1101. package/lib/simple-tree/index.d.ts +12 -13
  1102. package/lib/simple-tree/index.d.ts.map +1 -1
  1103. package/lib/simple-tree/index.js +8 -11
  1104. package/lib/simple-tree/index.js.map +1 -1
  1105. package/lib/simple-tree/jsonSchema.d.ts +206 -0
  1106. package/lib/simple-tree/jsonSchema.d.ts.map +1 -0
  1107. package/lib/simple-tree/{nodeKeys.js → jsonSchema.js} +1 -1
  1108. package/lib/simple-tree/jsonSchema.js.map +1 -0
  1109. package/lib/simple-tree/leafNodeSchema.d.ts +1 -1
  1110. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  1111. package/lib/simple-tree/leafNodeSchema.js +1 -2
  1112. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  1113. package/lib/simple-tree/mapNode.d.ts +9 -3
  1114. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  1115. package/lib/simple-tree/mapNode.js +36 -36
  1116. package/lib/simple-tree/mapNode.js.map +1 -1
  1117. package/lib/simple-tree/objectNode.d.ts +18 -16
  1118. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  1119. package/lib/simple-tree/objectNode.js +36 -34
  1120. package/lib/simple-tree/objectNode.js.map +1 -1
  1121. package/lib/simple-tree/objectNodeTypes.d.ts +38 -0
  1122. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -0
  1123. package/lib/simple-tree/objectNodeTypes.js +15 -0
  1124. package/lib/simple-tree/objectNodeTypes.js.map +1 -0
  1125. package/lib/simple-tree/proxies.d.ts +6 -25
  1126. package/lib/simple-tree/proxies.d.ts.map +1 -1
  1127. package/lib/simple-tree/proxies.js +46 -57
  1128. package/lib/simple-tree/proxies.js.map +1 -1
  1129. package/lib/simple-tree/proxyBinding.d.ts +45 -22
  1130. package/lib/simple-tree/proxyBinding.d.ts.map +1 -1
  1131. package/lib/simple-tree/proxyBinding.js +89 -52
  1132. package/lib/simple-tree/proxyBinding.js.map +1 -1
  1133. package/lib/simple-tree/schemaTypes.d.ts +10 -159
  1134. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  1135. package/lib/simple-tree/schemaTypes.js +9 -41
  1136. package/lib/simple-tree/schemaTypes.js.map +1 -1
  1137. package/lib/simple-tree/simpleSchema.d.ts +124 -0
  1138. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  1139. package/lib/{feature-libraries/schema-aware/schemaAware.js → simple-tree/simpleSchema.js} +1 -1
  1140. package/lib/simple-tree/simpleSchema.js.map +1 -0
  1141. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts +12 -0
  1142. package/lib/simple-tree/simpleSchemaToJsonSchema.d.ts.map +1 -0
  1143. package/lib/simple-tree/simpleSchemaToJsonSchema.js +142 -0
  1144. package/lib/simple-tree/simpleSchemaToJsonSchema.js.map +1 -0
  1145. package/lib/simple-tree/toFlexSchema.d.ts +4 -12
  1146. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  1147. package/lib/simple-tree/toFlexSchema.js +9 -18
  1148. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  1149. package/lib/simple-tree/toMapTree.d.ts +39 -39
  1150. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  1151. package/lib/simple-tree/toMapTree.js +214 -158
  1152. package/lib/simple-tree/toMapTree.js.map +1 -1
  1153. package/lib/simple-tree/treeNodeValid.d.ts +74 -0
  1154. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -0
  1155. package/lib/simple-tree/{types.js → treeNodeValid.js} +8 -98
  1156. package/lib/simple-tree/treeNodeValid.js.map +1 -0
  1157. package/lib/simple-tree/typesUnsafe.d.ts +35 -4
  1158. package/lib/simple-tree/typesUnsafe.d.ts.map +1 -1
  1159. package/lib/simple-tree/typesUnsafe.js.map +1 -1
  1160. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts +11 -0
  1161. package/lib/simple-tree/viewSchemaToSimpleSchema.d.ts.map +1 -0
  1162. package/lib/simple-tree/viewSchemaToSimpleSchema.js +167 -0
  1163. package/lib/simple-tree/viewSchemaToSimpleSchema.js.map +1 -0
  1164. package/lib/util/brand.d.ts +0 -3
  1165. package/lib/util/brand.d.ts.map +1 -1
  1166. package/lib/util/brand.js +1 -2
  1167. package/lib/util/brand.js.map +1 -1
  1168. package/lib/util/brandedMap.d.ts +0 -5
  1169. package/lib/util/brandedMap.d.ts.map +1 -1
  1170. package/lib/util/brandedMap.js +0 -1
  1171. package/lib/util/brandedMap.js.map +1 -1
  1172. package/lib/util/idAllocator.d.ts +0 -2
  1173. package/lib/util/idAllocator.d.ts.map +1 -1
  1174. package/lib/util/idAllocator.js +0 -1
  1175. package/lib/util/idAllocator.js.map +1 -1
  1176. package/lib/util/index.d.ts +2 -2
  1177. package/lib/util/index.d.ts.map +1 -1
  1178. package/lib/util/index.js +2 -2
  1179. package/lib/util/index.js.map +1 -1
  1180. package/lib/util/nestedMap.d.ts +5 -19
  1181. package/lib/util/nestedMap.d.ts.map +1 -1
  1182. package/lib/util/nestedMap.js +15 -16
  1183. package/lib/util/nestedMap.js.map +1 -1
  1184. package/lib/util/opaque.d.ts +0 -4
  1185. package/lib/util/opaque.d.ts.map +1 -1
  1186. package/lib/util/opaque.js +0 -2
  1187. package/lib/util/opaque.js.map +1 -1
  1188. package/lib/util/rangeMap.d.ts +0 -2
  1189. package/lib/util/rangeMap.d.ts.map +1 -1
  1190. package/lib/util/rangeMap.js +4 -3
  1191. package/lib/util/rangeMap.js.map +1 -1
  1192. package/lib/util/transactionResult.d.ts +0 -1
  1193. package/lib/util/transactionResult.d.ts.map +1 -1
  1194. package/lib/util/transactionResult.js +0 -1
  1195. package/lib/util/transactionResult.js.map +1 -1
  1196. package/lib/util/typeCheck.d.ts +2 -20
  1197. package/lib/util/typeCheck.d.ts.map +1 -1
  1198. package/lib/util/typeCheck.js.map +1 -1
  1199. package/lib/util/typeCheckTests.d.ts +4 -4
  1200. package/lib/util/typeCheckTests.d.ts.map +1 -1
  1201. package/lib/util/typeCheckTests.js.map +1 -1
  1202. package/lib/util/typeUtils.d.ts +0 -7
  1203. package/lib/util/typeUtils.d.ts.map +1 -1
  1204. package/lib/util/typeUtils.js.map +1 -1
  1205. package/lib/util/utils.d.ts +6 -8
  1206. package/lib/util/utils.d.ts.map +1 -1
  1207. package/lib/util/utils.js +12 -4
  1208. package/lib/util/utils.js.map +1 -1
  1209. package/package.json +36 -25
  1210. package/src/codec/discriminatedUnions.ts +20 -10
  1211. package/src/codec/index.ts +5 -1
  1212. package/src/core/forest/README.md +4 -2
  1213. package/src/core/forest/editableForest.ts +1 -6
  1214. package/src/core/forest/forest.ts +0 -6
  1215. package/src/core/index.ts +2 -2
  1216. package/src/core/rebase/changeRebaser.ts +0 -4
  1217. package/src/core/rebase/index.ts +0 -2
  1218. package/src/core/rebase/types.ts +1 -23
  1219. package/src/core/rebase/utils.ts +13 -11
  1220. package/src/core/schema-stored/multiplicity.ts +0 -1
  1221. package/src/core/schema-stored/schema.ts +0 -7
  1222. package/src/core/schema-stored/storedSchemaRepository.ts +0 -3
  1223. package/src/core/schema-view/view.ts +0 -3
  1224. package/src/core/tree/anchorSet.ts +7 -17
  1225. package/src/core/tree/cursor.ts +1 -6
  1226. package/src/core/tree/delta.ts +0 -11
  1227. package/src/core/tree/detachedFieldIndexCodec.ts +4 -3
  1228. package/src/core/tree/detachedFieldIndexTypes.ts +0 -1
  1229. package/src/core/tree/index.ts +1 -1
  1230. package/src/core/tree/mapTree.ts +45 -4
  1231. package/src/core/tree/pathTree.ts +0 -11
  1232. package/src/core/tree/treeTextFormat.ts +3 -2
  1233. package/src/core/tree/types.ts +0 -11
  1234. package/src/core/tree/visitDelta.ts +2 -3
  1235. package/src/core/tree/visitPath.ts +0 -2
  1236. package/src/core/tree/visitorUtils.ts +0 -1
  1237. package/src/domains/index.ts +3 -0
  1238. package/src/domains/json/index.ts +7 -1
  1239. package/src/domains/json/jsonCursor.ts +113 -6
  1240. package/src/domains/json/jsonDomainSchema.ts +4 -5
  1241. package/src/domains/leafDomain.ts +0 -1
  1242. package/src/domains/schemaBuilder.ts +0 -22
  1243. package/src/events/events.ts +0 -4
  1244. package/src/feature-libraries/chunked-forest/README.md +9 -1
  1245. package/src/feature-libraries/chunked-forest/basicChunk.ts +14 -9
  1246. package/src/feature-libraries/chunked-forest/chunk.ts +1 -1
  1247. package/src/feature-libraries/chunked-forest/chunkTree.ts +4 -4
  1248. package/src/feature-libraries/chunked-forest/chunkedForest.ts +8 -6
  1249. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +2 -2
  1250. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +9 -6
  1251. package/src/feature-libraries/chunked-forest/uniformChunk.ts +6 -4
  1252. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +18 -46
  1253. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +11 -6
  1254. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -1
  1255. package/src/feature-libraries/default-schema/index.ts +1 -1
  1256. package/src/feature-libraries/default-schema/schemaChecker.ts +6 -0
  1257. package/src/feature-libraries/editableTreeBinder.ts +6 -78
  1258. package/src/feature-libraries/fieldGenerator.ts +0 -3
  1259. package/src/feature-libraries/flex-map-tree/index.ts +2 -1
  1260. package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +238 -267
  1261. package/src/feature-libraries/flex-tree/context.ts +0 -1
  1262. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +27 -357
  1263. package/src/feature-libraries/flex-tree/index.ts +0 -1
  1264. package/src/feature-libraries/flex-tree/lazyField.ts +38 -208
  1265. package/src/feature-libraries/flex-tree/lazyNode.ts +5 -66
  1266. package/src/feature-libraries/flex-tree/treeEvents.ts +0 -2
  1267. package/src/feature-libraries/flex-tree/utilities.ts +6 -1
  1268. package/src/feature-libraries/forest-summary/codec.ts +3 -3
  1269. package/src/feature-libraries/index.ts +5 -35
  1270. package/src/feature-libraries/mapTreeCursor.ts +13 -4
  1271. package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -4
  1272. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +0 -2
  1273. package/src/feature-libraries/modular-schema/discrepancies.ts +117 -1
  1274. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +0 -8
  1275. package/src/feature-libraries/modular-schema/fieldKind.ts +1 -3
  1276. package/src/feature-libraries/modular-schema/genericFieldKind.ts +69 -92
  1277. package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +7 -14
  1278. package/src/feature-libraries/modular-schema/genericFieldKindTypes.ts +6 -15
  1279. package/src/feature-libraries/modular-schema/index.ts +2 -2
  1280. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +68 -34
  1281. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +330 -336
  1282. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +7 -14
  1283. package/src/feature-libraries/node-key/nodeKey.ts +0 -4
  1284. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -1
  1285. package/src/feature-libraries/object-forest/objectForest.ts +1 -13
  1286. package/src/feature-libraries/schemaBuilderBase.ts +1 -49
  1287. package/src/feature-libraries/sequence-field/compose.ts +41 -20
  1288. package/src/feature-libraries/sequence-field/formatV2.ts +3 -3
  1289. package/src/feature-libraries/sequence-field/formatV3.ts +65 -0
  1290. package/src/feature-libraries/sequence-field/helperTypes.ts +33 -0
  1291. package/src/feature-libraries/sequence-field/index.ts +1 -0
  1292. package/src/feature-libraries/sequence-field/invert.ts +28 -18
  1293. package/src/feature-libraries/sequence-field/markQueue.ts +2 -2
  1294. package/src/feature-libraries/sequence-field/moveEffectTable.ts +2 -2
  1295. package/src/feature-libraries/sequence-field/rebase.ts +30 -13
  1296. package/src/feature-libraries/sequence-field/replaceRevisions.ts +27 -3
  1297. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +52 -7
  1298. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +92 -19
  1299. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +134 -0
  1300. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +2 -0
  1301. package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +8 -2
  1302. package/src/feature-libraries/sequence-field/types.ts +24 -4
  1303. package/src/feature-libraries/sequence-field/utils.ts +78 -50
  1304. package/src/feature-libraries/storedToViewSchema.ts +0 -1
  1305. package/src/feature-libraries/treeCursorUtils.ts +11 -11
  1306. package/src/feature-libraries/treeTextCursor.ts +0 -2
  1307. package/src/feature-libraries/typed-schema/flexList.ts +0 -3
  1308. package/src/feature-libraries/typed-schema/index.ts +0 -2
  1309. package/src/feature-libraries/typed-schema/schemaCollection.ts +0 -5
  1310. package/src/feature-libraries/typed-schema/typedTreeSchema.ts +2 -68
  1311. package/src/feature-libraries/typed-schema/view.ts +0 -1
  1312. package/src/index.ts +27 -245
  1313. package/src/internalTypes.ts +1 -0
  1314. package/src/packageVersion.ts +1 -1
  1315. package/src/shared-tree/schematizeTree.ts +25 -21
  1316. package/src/shared-tree/schematizingTreeView.ts +6 -6
  1317. package/src/shared-tree/sharedTree.ts +8 -39
  1318. package/src/shared-tree/sharedTreeChangeCodecs.ts +8 -0
  1319. package/src/shared-tree/sharedTreeChangeFamily.ts +3 -3
  1320. package/src/shared-tree/sharedTreeEditBuilder.ts +0 -2
  1321. package/src/shared-tree/treeApi.ts +3 -3
  1322. package/src/shared-tree/treeCheckout.ts +6 -8
  1323. package/src/shared-tree/treeView.ts +3 -6
  1324. package/src/shared-tree-core/branch.ts +20 -8
  1325. package/src/shared-tree-core/defaultResubmitMachine.ts +4 -4
  1326. package/src/shared-tree-core/editManagerCodecs.ts +1 -0
  1327. package/src/shared-tree-core/editManagerFormat.ts +7 -2
  1328. package/src/shared-tree-core/messageCodecs.ts +2 -1
  1329. package/src/shared-tree-core/sharedTreeCore.ts +5 -3
  1330. package/src/simple-tree/ProxyBinding.md +2 -0
  1331. package/src/simple-tree/api/README.md +7 -0
  1332. package/src/simple-tree/api/create.ts +179 -0
  1333. package/src/simple-tree/api/index.ts +36 -0
  1334. package/src/simple-tree/{schemaCreationUtilities.ts → api/schemaCreationUtilities.ts} +13 -5
  1335. package/src/simple-tree/{schemaFactory.ts → api/schemaFactory.ts} +36 -34
  1336. package/src/simple-tree/{schemaFactoryRecursive.ts → api/schemaFactoryRecursive.ts} +47 -10
  1337. package/src/simple-tree/{testRecursiveDomain.ts → api/testRecursiveDomain.ts} +3 -1
  1338. package/src/simple-tree/{tree.ts → api/tree.ts} +246 -34
  1339. package/src/simple-tree/{treeNodeApi.ts → api/treeNodeApi.ts} +47 -36
  1340. package/src/simple-tree/api/verboseTree.ts +415 -0
  1341. package/src/simple-tree/arrayNode.ts +100 -98
  1342. package/src/simple-tree/core/README.md +11 -0
  1343. package/src/simple-tree/core/index.ts +33 -0
  1344. package/src/simple-tree/{schemaCaching.ts → core/schemaCaching.ts} +3 -37
  1345. package/src/simple-tree/{treeNodeKernel.ts → core/treeNodeKernel.ts} +55 -5
  1346. package/src/simple-tree/core/treeNodeSchema.ts +184 -0
  1347. package/src/simple-tree/core/types.ts +255 -0
  1348. package/src/simple-tree/core/withType.ts +89 -0
  1349. package/src/simple-tree/getJsonSchema.ts +70 -0
  1350. package/src/simple-tree/getSimpleFieldSchema.ts +36 -0
  1351. package/src/simple-tree/getSimpleSchema.ts +69 -0
  1352. package/src/simple-tree/index.ts +58 -33
  1353. package/src/simple-tree/jsonSchema.ts +230 -0
  1354. package/src/simple-tree/leafNodeSchema.ts +6 -3
  1355. package/src/simple-tree/mapNode.ts +56 -55
  1356. package/src/simple-tree/objectNode.ts +66 -90
  1357. package/src/simple-tree/objectNodeTypes.ts +68 -0
  1358. package/src/simple-tree/proxies.ts +52 -68
  1359. package/src/simple-tree/proxyBinding.ts +127 -72
  1360. package/src/simple-tree/schemaTypes.ts +29 -194
  1361. package/src/simple-tree/simpleSchema.ts +138 -0
  1362. package/src/simple-tree/simpleSchemaToJsonSchema.ts +178 -0
  1363. package/src/simple-tree/toFlexSchema.ts +9 -42
  1364. package/src/simple-tree/toMapTree.ts +270 -296
  1365. package/src/simple-tree/{types.ts → treeNodeValid.ts} +16 -232
  1366. package/src/simple-tree/typesUnsafe.ts +51 -5
  1367. package/src/simple-tree/viewSchemaToSimpleSchema.ts +209 -0
  1368. package/src/util/brand.ts +1 -4
  1369. package/src/util/brandedMap.ts +0 -5
  1370. package/src/util/idAllocator.ts +0 -2
  1371. package/src/util/index.ts +2 -0
  1372. package/src/util/nestedMap.ts +23 -20
  1373. package/src/util/opaque.ts +0 -4
  1374. package/src/util/rangeMap.ts +5 -5
  1375. package/src/util/transactionResult.ts +0 -1
  1376. package/src/util/typeCheck.ts +2 -20
  1377. package/src/util/typeCheckTests.ts +4 -4
  1378. package/src/util/typeUtils.ts +0 -7
  1379. package/src/util/utils.ts +13 -8
  1380. package/tsconfig.json +0 -1
  1381. package/dist/feature-libraries/contextuallyTyped.d.ts +0 -209
  1382. package/dist/feature-libraries/contextuallyTyped.d.ts.map +0 -1
  1383. package/dist/feature-libraries/contextuallyTyped.js +0 -328
  1384. package/dist/feature-libraries/contextuallyTyped.js.map +0 -1
  1385. package/dist/feature-libraries/schema-aware/index.d.ts +0 -6
  1386. package/dist/feature-libraries/schema-aware/index.d.ts.map +0 -1
  1387. package/dist/feature-libraries/schema-aware/index.js.map +0 -1
  1388. package/dist/feature-libraries/schema-aware/schemaAware.d.ts +0 -76
  1389. package/dist/feature-libraries/schema-aware/schemaAware.d.ts.map +0 -1
  1390. package/dist/feature-libraries/schema-aware/schemaAware.js.map +0 -1
  1391. package/dist/simple-tree/nodeKeys.d.ts +0 -41
  1392. package/dist/simple-tree/nodeKeys.d.ts.map +0 -1
  1393. package/dist/simple-tree/nodeKeys.js +0 -7
  1394. package/dist/simple-tree/nodeKeys.js.map +0 -1
  1395. package/dist/simple-tree/schemaCaching.d.ts.map +0 -1
  1396. package/dist/simple-tree/schemaCaching.js.map +0 -1
  1397. package/dist/simple-tree/schemaCreationUtilities.d.ts.map +0 -1
  1398. package/dist/simple-tree/schemaCreationUtilities.js.map +0 -1
  1399. package/dist/simple-tree/schemaFactory.d.ts.map +0 -1
  1400. package/dist/simple-tree/schemaFactory.js.map +0 -1
  1401. package/dist/simple-tree/schemaFactoryRecursive.d.ts.map +0 -1
  1402. package/dist/simple-tree/schemaFactoryRecursive.js.map +0 -1
  1403. package/dist/simple-tree/testRecursiveDomain.d.ts +0 -61
  1404. package/dist/simple-tree/testRecursiveDomain.d.ts.map +0 -1
  1405. package/dist/simple-tree/testRecursiveDomain.js.map +0 -1
  1406. package/dist/simple-tree/tree.d.ts.map +0 -1
  1407. package/dist/simple-tree/tree.js +0 -73
  1408. package/dist/simple-tree/tree.js.map +0 -1
  1409. package/dist/simple-tree/treeNodeApi.d.ts.map +0 -1
  1410. package/dist/simple-tree/treeNodeApi.js.map +0 -1
  1411. package/dist/simple-tree/treeNodeKernel.d.ts +0 -26
  1412. package/dist/simple-tree/treeNodeKernel.d.ts.map +0 -1
  1413. package/dist/simple-tree/treeNodeKernel.js.map +0 -1
  1414. package/dist/simple-tree/types.d.ts.map +0 -1
  1415. package/dist/simple-tree/types.js.map +0 -1
  1416. package/lib/feature-libraries/contextuallyTyped.d.ts +0 -209
  1417. package/lib/feature-libraries/contextuallyTyped.d.ts.map +0 -1
  1418. package/lib/feature-libraries/contextuallyTyped.js +0 -311
  1419. package/lib/feature-libraries/contextuallyTyped.js.map +0 -1
  1420. package/lib/feature-libraries/schema-aware/index.d.ts +0 -6
  1421. package/lib/feature-libraries/schema-aware/index.d.ts.map +0 -1
  1422. package/lib/feature-libraries/schema-aware/index.js +0 -6
  1423. package/lib/feature-libraries/schema-aware/index.js.map +0 -1
  1424. package/lib/feature-libraries/schema-aware/schemaAware.d.ts +0 -76
  1425. package/lib/feature-libraries/schema-aware/schemaAware.d.ts.map +0 -1
  1426. package/lib/feature-libraries/schema-aware/schemaAware.js.map +0 -1
  1427. package/lib/simple-tree/nodeKeys.d.ts +0 -41
  1428. package/lib/simple-tree/nodeKeys.d.ts.map +0 -1
  1429. package/lib/simple-tree/nodeKeys.js.map +0 -1
  1430. package/lib/simple-tree/schemaCaching.d.ts.map +0 -1
  1431. package/lib/simple-tree/schemaCaching.js.map +0 -1
  1432. package/lib/simple-tree/schemaCreationUtilities.d.ts.map +0 -1
  1433. package/lib/simple-tree/schemaCreationUtilities.js.map +0 -1
  1434. package/lib/simple-tree/schemaFactory.d.ts.map +0 -1
  1435. package/lib/simple-tree/schemaFactory.js.map +0 -1
  1436. package/lib/simple-tree/schemaFactoryRecursive.d.ts.map +0 -1
  1437. package/lib/simple-tree/schemaFactoryRecursive.js.map +0 -1
  1438. package/lib/simple-tree/testRecursiveDomain.d.ts +0 -61
  1439. package/lib/simple-tree/testRecursiveDomain.d.ts.map +0 -1
  1440. package/lib/simple-tree/testRecursiveDomain.js.map +0 -1
  1441. package/lib/simple-tree/tree.d.ts.map +0 -1
  1442. package/lib/simple-tree/tree.js +0 -66
  1443. package/lib/simple-tree/tree.js.map +0 -1
  1444. package/lib/simple-tree/treeNodeApi.d.ts.map +0 -1
  1445. package/lib/simple-tree/treeNodeApi.js.map +0 -1
  1446. package/lib/simple-tree/treeNodeKernel.d.ts +0 -26
  1447. package/lib/simple-tree/treeNodeKernel.d.ts.map +0 -1
  1448. package/lib/simple-tree/treeNodeKernel.js.map +0 -1
  1449. package/lib/simple-tree/types.d.ts.map +0 -1
  1450. package/lib/simple-tree/types.js.map +0 -1
  1451. package/src/feature-libraries/contextuallyTyped.ts +0 -582
  1452. package/src/feature-libraries/schema-aware/README.md +0 -19
  1453. package/src/feature-libraries/schema-aware/index.ts +0 -16
  1454. package/src/feature-libraries/schema-aware/schemaAware.ts +0 -135
  1455. package/src/simple-tree/nodeKeys.ts +0 -42
  1456. /package/dist/simple-tree/{testRecursiveDomain.js → api/testRecursiveDomain.js} +0 -0
  1457. /package/lib/simple-tree/{testRecursiveDomain.js → api/testRecursiveDomain.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"anchorSet.js","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,oDAAuE;AACvE,kDAS6B;AAa7B,yCAAkD;AAYlD;;GAEG;AACH,MAAM,WAAW,GAAW,IAAA,gBAAK,EAAC,CAAC,CAAC,CAAC;AA8MrC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,UAAU;IACzB,OAAO,IAAA,sBAAW,GAAwB,CAAC;AAC5C,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;;GAWG;AACH,MAAa,SAAS;IAkCrB;QAjCiB,WAAM,GAAG,IAAA,wBAAa,GAAuB,CAAC;QAC/D;;;WAGG;QACK,kBAAa,GAAG,CAAC,CAAC;QAE1B;;;;WAIG;QACI,qBAAgB,GAAG,CAAC,CAAC;QAE5B;;;;;;;;;;WAUG;QACc,SAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,mBAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;QAEnE,8GAA8G;QAC9G,yDAAyD;QACxC,iBAAY,GAA0B,IAAI,GAAG,EAAE,CAA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IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;YACtF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;gBAClC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC/B,CAAC;IACF,CAAC;CACD","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 Listenable, createEmitter } from \"../../events/index.js\";\nimport {\n\ttype Brand,\n\ttype BrandedKey,\n\ttype BrandedMapSubset,\n\ttype Opaque,\n\tReferenceCountedBase,\n\tbrand,\n\tbrandedSlot,\n\tfail,\n} from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedPlaceUpPath,\n\tDetachedRangeUpPath,\n\tPlaceIndex,\n\tPlaceUpPath,\n\tRange,\n\tRangeUpPath,\n\tUpPath,\n} from \"./pathTree.js\";\nimport { EmptyKey, type Value } from \"./types.js\";\nimport type { DeltaVisitor } from \"./visitDelta.js\";\nimport type { PathVisitor } from \"./visitPath.js\";\nimport type { AnnouncedVisitor } from \"./visitorUtils.js\";\n\n/**\n * A way to refer to a particular tree location within an {@link AnchorSet}.\n * Associated with a ref count on the underlying {@link AnchorNode}.\n * @internal\n */\nexport type Anchor = Brand<number, \"rebaser.Anchor\">;\n\n/**\n * A singleton which represents a permanently invalid location (i.e. there is never a node there)\n */\nconst NeverAnchor: Anchor = brand(0);\n\n/**\n * Maps anchors (which must be ones this locator knows about) to paths.\n * @internal\n */\nexport interface AnchorLocator {\n\t/**\n\t * Get the current location of an Anchor.\n\t * The returned value should not be used after an edit has occurred.\n\t *\n\t * TODO: support extra/custom return types for specific/custom anchor types:\n\t * for now caller must rely on data in anchor + returned node location\n\t * (not ideal for anchors for places or ranges instead of nodes).\n\t */\n\tlocate(anchor: Anchor): AnchorNode | undefined;\n}\n\n/**\n * Stores arbitrary, user-defined data on an {@link Anchor}.\n * This data is preserved over the course of that anchor's lifetime.\n * @see {@link anchorSlot} for creation and an example use case.\n * @internal\n */\nexport type AnchorSlot<TContent> = BrandedKey<Opaque<Brand<number, \"AnchorSlot\">>, TContent>;\n\n/**\n * Events for {@link AnchorNode}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Include sub-deltas in events.\n * - Add more events.\n *\n * @internal\n */\nexport interface AnchorEvents {\n\t/**\n\t * When the anchor node will never get reused by its AnchorSet.\n\t * This means that the content it corresponds to has been permanently destroyed.\n\t *\n\t * @remarks\n\t * When this happens depends entirely on how the anchorSet is used.\n\t * It's possible nodes removed from the tree will be kept indefinitely, and thus never trigger this event, or they may be discarded immediately.\n\t *\n\t * @privateRemarks\n\t * The specifics of the delta visit algorithm can impact the behavior of these events.\n\t * Refer to the privateRemarks of specific events and/or the documentation of the delta visit algorithm (as of\n\t * 2024-04-02, src/core/tree/visitDelta.ts) for more information.\n\t */\n\tafterDestroy(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children are about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t */\n\tchildrenChanging(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t */\n\tchildrenChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if one or more of this node's\n\t * direct children changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChanged} which is emitted in the middle of the batch/delta-visit.\n\t */\n\tchildrenChangedAfterBatch(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ be about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * The event can optionally return a {@link PathVisitor} to traverse the subtree.\n\t * Called on every parent (transitively) when a change is occurring.\n\t */\n\tsubtreeChanging(anchor: AnchorNode): PathVisitor | void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ have just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * While this event is always emitted in the presence of changes to the subtree,\n\t * it may also be emitted even though no changes have been made to the subtree.\n\t * It may be emitted multiple times within the application of a single edit or transaction.\n\t *\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, at\n\t * least once on each ancestor.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t *\n\t * @privateRemarks\n\t * The delta visit algorithm is complicated and it may fire this event multiple times for the same change to a node.\n\t * The change to the tree may not be visible until the event fires for the last time.\n\t * Refer to the documentation of the delta visit algorithm for more details.\n\t */\n\tsubtreeChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if something in the subtree\n\t * rooted at `anchor` changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, from bottom to top.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChanged} which is emitted in the middle of the batch/delta-visit.\n\t *\n\t * @privateRemarks\n\t * Note that because this is fired after the full batch of changes is applied, it guarantees that something in the\n\t * subtree changed, compared to {@link AnchorEvents.subtreeChanged} or {@link AnchorEvents.subtreeChanging} which\n\t * fire when something _may_ have changed or _may_ be about to change.\n\t */\n\tsubtreeChangedAfterBatch(anchor: AnchorNode): void;\n\n\t/**\n\t * Value on this node is changing.\n\t */\n\tvalueChanging(anchor: AnchorNode, value: Value): void;\n}\n\n/**\n * Events for {@link AnchorSet}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Design how events should be ordered.\n * - Include sub-deltas in events.\n * - Add more events.\n *\n * @internal\n */\nexport interface AnchorSetRootEvents {\n\t/**\n\t * What children are at the root is changing.\n\t */\n\tchildrenChanging(anchors: AnchorSet): void;\n\n\t/**\n\t * Something in the tree is changing.\n\t */\n\ttreeChanging(anchors: AnchorSet): void;\n}\n\n/**\n * Node in a tree of anchors.\n * @internal\n */\nexport interface AnchorNode extends UpPath<AnchorNode>, Listenable<AnchorEvents> {\n\t/**\n\t * Allows access to data stored on the Anchor in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t */\n\t// See note on BrandedKey\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treadonly slots: BrandedMapSubset<AnchorSlot<any>>;\n\n\t/**\n\t * The set this anchor node is part of.\n\t */\n\treadonly anchorSet: AnchorSet;\n\n\t/**\n\t * Gets a child of this node.\n\t *\n\t * @remarks\n\t * This does not return an AnchorNode since there might not be one, and lazily creating one here would have messy lifetime management (See {@link AnchorNode#getOrCreateChildRef})\n\t * If an AnchorNode is required, use the AnchorSet to track then locate the returned path.\n\t * TODO:\n\t * Revisit this API.\n\t * Perhaps if we use weak down pointers and remove ref counting, we can make this return a AnchorNode.\n\t *\n\t */\n\tchild(key: FieldKey, index: number): UpPath<AnchorNode>;\n\n\t/**\n\t * Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.\n\t * Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.\n\t */\n\tgetOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];\n}\n\n/**\n * Define a strongly typed slot on anchors in which data can be stored.\n *\n * @remarks\n * This is mainly useful for caching data associated with a location in the tree.\n *\n * Example usage:\n * ```typescript\n * const counterSlot = anchorSlot<number>();\n *\n * function useSlot(anchor: AnchorNode): void {\n * \tanchor.slots.set(counterSlot, 1 + anchor.slots.get(counterSlot) ?? 0);\n * }\n * ```\n * @internal\n */\nexport function anchorSlot<TContent>(): AnchorSlot<TContent> {\n\treturn brandedSlot<AnchorSlot<TContent>>();\n}\n\n/**\n * Collection of Anchors at a specific revision.\n *\n * See `Rebaser` for how to update across revisions.\n *\n * TODO: this should not be package exported.\n * If it's needed outside the package an Interface should be used instead which can reduce its\n * API surface to a small subset.\n *\n * @sealed\n * @internal\n */\nexport class AnchorSet implements Listenable<AnchorSetRootEvents>, AnchorLocator {\n\tprivate readonly events = createEmitter<AnchorSetRootEvents>();\n\t/**\n\t * Incrementing counter to give each anchor in this set a unique index for its identifier.\n\t * \"0\" is reserved for the `NeverAnchor`.\n\t */\n\tprivate anchorCounter = 1;\n\n\t/**\n\t * Incrementing number that is bumped each time that the {@link AnchorSet} is changed.\n\t * This allows consumers to cache state associated with a particular generation number and later determine if that state may have been invalidated using a comparison with the current generation number.\n\t * For example, anchor slots can be used to cache the removal status of a node to memoize repeated walks up the tree.\n\t */\n\tpublic generationNumber = 0;\n\n\t/**\n\t * Special root node under which all anchors in this anchor set are transitively parented.\n\t * This does not appear in the UpPaths (instead they use undefined for the root).\n\t * Immediate children of this root are in detached fields (which have their identifiers used as the field keys).\n\t *\n\t * This is allocated with refCount one, which is never freed so it is never cleaned up\n\t * (as long as this AnchorSet is not garbage collected).\n\t *\n\t * There should never be any children other than the special root detached field under this between transactions:\n\t * TODO: check for and enforce this.\n\t */\n\tprivate readonly root = new PathNode(this, EmptyKey, 0, undefined);\n\n\t// TODO: anchor system could be optimized a bit to avoid the maps (Anchor is ref to Path, path has ref count).\n\t// For now use this more encapsulated approach with maps.\n\tprivate readonly anchorToPath: Map<Anchor, PathNode> = new Map();\n\n\tprivate activeVisitor?: DeltaVisitor;\n\n\tpublic constructor() {\n\t\tthis.on(\"treeChanging\", () => {\n\t\t\tthis.generationNumber += 1;\n\t\t});\n\t}\n\n\t/**\n\t * Allows access to data stored on the AnchorSet in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t *\n\t * @privateRemarks\n\t * This forwards to the slots of the special above root anchor which locate can't access.\n\t */\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get slots(): BrandedMapSubset<AnchorSlot<any>> {\n\t\treturn this.root.slots;\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<AnchorNode> {\n\t\tconst stack: PathNode[] = [];\n\t\tlet node: PathNode | undefined = this.root;\n\t\twhile (node !== undefined) {\n\t\t\tyield node;\n\t\t\tfor (const [_, children] of node.children) {\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tstack.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t\tnode = stack.pop();\n\t\t}\n\t}\n\n\tpublic on<K extends keyof AnchorSetRootEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorSetRootEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\n\t}\n\n\t/**\n\t * Check if there are currently no anchors tracked.\n\t * Mainly for testing anchor cleanup.\n\t */\n\tpublic isEmpty(): boolean {\n\t\treturn this.root.children.size === 0;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tif (anchor === NeverAnchor) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = this.anchorToPath.get(anchor);\n\t\tassert(\n\t\t\tpath !== undefined,\n\t\t\t0x3a6 /* Cannot locate anchor which is not in this AnchorSet */,\n\t\t);\n\t\treturn path.status === Status.Alive ? path : undefined;\n\t}\n\n\tpublic forget(anchor: Anchor): void {\n\t\tif (anchor !== NeverAnchor) {\n\t\t\tconst path = this.anchorToPath.get(anchor);\n\t\t\tassert(path !== undefined, 0x351 /* cannot forget unknown Anchor */);\n\t\t\tpath.removeRef();\n\t\t\tthis.anchorToPath.delete(anchor);\n\t\t}\n\t}\n\n\t/**\n\t * TODO: Add APIs need to allow callers of this function to reduce copying here.\n\t * Ex: maybe return something extending UpPath here.\n\t * @param path - the path to the node to be tracked. If null, returns an anchor\n\t * which is permanently invalid.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic track(path: UpPath | null): Anchor {\n\t\tif (path === null) {\n\t\t\treturn NeverAnchor;\n\t\t}\n\n\t\tconst foundPath = this.trackInner(path);\n\t\tconst anchor: Anchor = brand(this.anchorCounter++);\n\t\tthis.anchorToPath.set(anchor, foundPath);\n\t\treturn anchor;\n\t}\n\n\t/**\n\t * Finds a path node, creating if needed, and adds a ref count to it.\n\t */\n\tprivate trackInner(path: UpPath): PathNode {\n\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\tpath.addRef();\n\t\t\treturn path;\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.trackInner(parent);\n\n\t\tconst child = parentPath.getOrCreateChild(path.parentField, path.parentIndex);\n\n\t\t// Now that child is added (if needed), remove the extra ref that we added in the recursive call.\n\t\tparentPath.removeRef();\n\n\t\treturn child;\n\t}\n\n\t/**\n\t * Finds a path node if it already exists.\n\t */\n\tprivate find(path: UpPath): PathNode | undefined {\n\t\tif (path instanceof PathNode) {\n\t\t\tif (path.anchorSet === this) {\n\t\t\t\treturn path;\n\t\t\t}\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.find(parent);\n\t\treturn parentPath?.tryGetChild(path.parentField, path.parentIndex);\n\t}\n\n\t/**\n\t * Returns an equivalent path making as much of it with PathNodes as possible.\n\t * This allows future operations (like find, track, locate) on this path (and derived ones) to be faster.\n\t * Note that the returned path may use AnchorNodes from this AnchorSet,\n\t * but does not have a tracked reference to them, so this should not be held onto across anything that might free an AnchorNode.\n\t *\n\t * @remarks\n\t * Also ensures that any PathNode in the path is from this AnchorSet.\n\t */\n\tpublic internalizePath(originalPath: UpPath): UpPath {\n\t\tlet path: UpPath | undefined = originalPath;\n\t\tconst stack: UpPath[] = [];\n\t\twhile (path !== undefined) {\n\t\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tstack.push(path);\n\t\t\tpath = path.parent;\n\t\t}\n\n\t\t// Now `path` contains an internalized path.\n\t\t// It just needs the paths from stackOut to wrap it.\n\n\t\tlet wrapWith: UpPath | undefined;\n\t\twhile ((wrapWith = stack.pop()) !== undefined) {\n\t\t\tif (path === undefined || path instanceof PathNode) {\n\t\t\t\t// If path already has an anchor, get an anchor for it's child if there is one:\n\t\t\t\tconst child = (path ?? this.root).tryGetChild(\n\t\t\t\t\twrapWith.parentField,\n\t\t\t\t\twrapWith.parentIndex,\n\t\t\t\t);\n\t\t\t\tif (child !== undefined) {\n\t\t\t\t\tpath = child;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Replacing this if with a ternary makes the documentation harder to include and hurts readability.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (path === wrapWith.parent && !(wrapWith instanceof PathNode)) {\n\t\t\t\t// path is safe to reuse from input path, so use it to avoid allocating another object.\n\t\t\t\tpath = wrapWith;\n\t\t\t} else {\n\t\t\t\tpath = {\n\t\t\t\t\tparent: path,\n\t\t\t\t\tparentField: wrapWith.parentField,\n\t\t\t\t\tparentIndex: wrapWith.parentIndex,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn path ?? fail(\"internalize path must be a path\");\n\t}\n\n\t/**\n\t * Recursively marks the given `nodes` and their descendants as disposed and pointing to a deleted node.\n\t * Note that this does NOT detach the nodes.\n\t */\n\tprivate deepDelete(nodes: readonly PathNode[]): void {\n\t\tconst stack = [...nodes];\n\t\twhile (stack.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst node = stack.pop()!;\n\t\t\tassert(node.status === Status.Alive, 0x408 /* PathNode must be alive */);\n\t\t\tnode.status = Status.Dangling;\n\t\t\tnode.events.emit(\"afterDestroy\", node);\n\t\t\tfor (const children of node.children.values()) {\n\t\t\t\tstack.push(...children);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Decouple nodes from their parent.\n\t * This removes the reference from the parent to the decoupled children, and updates the indexes of the remaining children accordingly.\n\t * This does NOT update the decoupled children: both their index and parent are left at their existing values.\n\t * To decouple and fixup the children, see `removeChildren` and `moveChildren`.\n\t * @param startPath - The path to the first node that is being decoupled.\n\t * @param count - number of siblings that are decoupled from the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate decoupleNodes(startPath: UpPath, count: number): PathNode[] {\n\t\tassert(count > 0, 0x681 /* count must be positive */);\n\n\t\tconst sourceParent = this.find(startPath.parent ?? this.root);\n\t\tconst sourceChildren = sourceParent?.children?.get(startPath.parentField);\n\t\tlet nodes: PathNode[] = [];\n\n\t\tif (sourceChildren !== undefined) {\n\t\t\tlet numberBeforeDecouple = 0;\n\t\t\tlet numberToDecouple = 0;\n\t\t\tlet index = 0;\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index].parentIndex < startPath.parentIndex\n\t\t\t) {\n\t\t\t\tnumberBeforeDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index].parentIndex < startPath.parentIndex + count\n\t\t\t) {\n\t\t\t\tnumberToDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (index < sourceChildren.length) {\n\t\t\t\t// Fix indexes in source after moved items (subtract count).\n\t\t\t\tsourceChildren[index].parentIndex -= count;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\t// Sever the parent -> child connections\n\t\t\tnodes = sourceChildren.splice(numberBeforeDecouple, numberToDecouple);\n\t\t\tif (sourceChildren.length === 0) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tsourceParent!.afterEmptyField(startPath.parentField);\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * Couple nodes to a parent.\n\t * @param destination - where the siblings are coupled to.\n\t * @param count - number of siblings that are coupled in the original tree.\n\t * @param coupleInfo - this object contains the nodes to couple and the parent index of the first node that is coupled in the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate coupleNodes(\n\t\tdestination: UpPath,\n\t\tcount: number,\n\t\tcoupleInfo: { startParentIndex: number; nodes: PathNode[] },\n\t): void {\n\t\tassert(coupleInfo.nodes.length > 0, 0x682 /* coupleInfo must have nodes to couple */);\n\n\t\t// The destination needs to be created if it does not exist yet.\n\t\tconst destinationPath = this.trackInner(destination.parent ?? this.root);\n\n\t\t// Update nodes for new parent.\n\t\tfor (const node of coupleInfo.nodes) {\n\t\t\tnode.parentIndex += destination.parentIndex - coupleInfo.startParentIndex;\n\t\t\tnode.parentPath = destinationPath;\n\t\t\tnode.parentField = destination.parentField;\n\t\t}\n\n\t\t// Update new parent to add children\n\t\tconst field = destinationPath.children.get(destination.parentField);\n\t\tif (field === undefined) {\n\t\t\tdestinationPath.children.set(destination.parentField, coupleInfo.nodes);\n\t\t} else {\n\t\t\t// Update existing field contents\n\t\t\tconst numberBeforeCouple = this.increaseParentIndexes(\n\t\t\t\tfield,\n\t\t\t\tdestination.parentIndex,\n\t\t\t\tcount,\n\t\t\t);\n\n\t\t\t// TODO: this will fail for very large numbers of anchors due to argument limits.\n\t\t\tfield.splice(numberBeforeCouple, 0, ...coupleInfo.nodes);\n\t\t}\n\n\t\tdestinationPath.removeRef();\n\t}\n\n\t/**\n\t * Updates the parent indexes within `field` to account for `count` children being inserted at `fromParentIndex`. Note that\n\t * `fromParentIndex` is the logical position within the field, not the index with the sparse PathNode array.\n\t *\n\t * @param field - the field to update.\n\t * @param fromParentIndex - the logical index within the field to start updating from.\n\t * @param count - the number to increase parent indexes.\n\t * @returns the number of items in the field that are not increased.\n\t *\n\t * TODO: tests\n\t */\n\tprivate increaseParentIndexes(\n\t\tfield: PathNode[],\n\t\tfromParentIndex: number,\n\t\tcount: number,\n\t): number {\n\t\tlet index = 0;\n\t\twhile (index < field.length && field[index].parentIndex < fromParentIndex) {\n\t\t\tindex++;\n\t\t}\n\t\tconst numberBeforeIncrease = index;\n\t\twhile (index < field.length) {\n\t\t\tfield[index].parentIndex += count;\n\t\t\tindex++;\n\t\t}\n\n\t\treturn numberBeforeIncrease;\n\t}\n\n\t/**\n\t * Updates paths for a range move (including re-parenting path items and updating indexes).\n\t * @param sourceStart - where the siblings are removed from.\n\t * @param destination - where the siblings are moved to.\n\t * @param count - number of siblings to move.\n\t *\n\t * TODO:\n\t * How should anchors that become invalid, then valid again (ex: into content that was deleted, then undone) work?\n\t * Add an API to resurrect them? Store them in special detached fields? Store them in special non-detached fields?\n\t *\n\t * TODO:\n\t * How should custom anchors work (ex: ones not just tied to a specific Node)?\n\t * This design assumes they can be expressed in terms of a Node anchor + some extra stuff,\n\t * but we don't have an API for the extra stuff yet.\n\t *\n\t * TODO: tests\n\t */\n\tprivate moveChildren(sourceStart: UpPath, destination: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(sourceStart, count);\n\t\tif (nodes.length > 0) {\n\t\t\tthis.coupleNodes(destination, count, {\n\t\t\t\tstartParentIndex: sourceStart.parentIndex,\n\t\t\t\tnodes,\n\t\t\t});\n\t\t} else {\n\t\t\t// If there are no nodes to move, we still need to update the parent indexes of the nodes\n\t\t\t// affected in the move in.\n\t\t\tthis.offsetChildren(destination, count);\n\t\t}\n\t}\n\n\tprivate removeChildren(path: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(path, count);\n\t\tthis.deepDelete(nodes);\n\t}\n\n\t/**\n\t * Updates the parent indexes of all the nodes located at right side of the given path by the given offset.\n\t * @param firstSiblingToOffset - the path to offset children of.\n\t * @param offset - the offset to apply to the children.\n\t *\n\t */\n\tprivate offsetChildren(firstSiblingToOffset: UpPath, offset: number): void {\n\t\tconst nodePath = this.find(firstSiblingToOffset.parent ?? this.root);\n\t\tconst field = nodePath?.children.get(firstSiblingToOffset.parentField);\n\t\tif (field !== undefined) {\n\t\t\tthis.increaseParentIndexes(field, firstSiblingToOffset.parentIndex, offset);\n\t\t}\n\t}\n\n\t/**\n\t * Provides a visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @returns A visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @remarks\n\t * Mutating the {@link AnchorSet} does NOT update the forest.\n\t * The visitor must be released after use by calling {@link DeltaVisitor.free} on it.\n\t * It is invalid to acquire a visitor without releasing the previous one,\n\t * and this method will throw an error if this is attempted.\n\t */\n\tpublic acquireVisitor(): AnnouncedVisitor & DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x767 /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\tconst referencedPathNodes: PathNode[] = [];\n\t\tconst visitor = {\n\t\t\tanchorSet: this,\n\t\t\t// Run `withNode` on anchorNode for parent if there is such an anchorNode.\n\t\t\t// If at root, run `withRoot` instead.\n\t\t\tmaybeWithNode(withNode: (anchorNode: PathNode) => void, withRoot?: () => void) {\n\t\t\t\tif (this.parent === undefined && withRoot !== undefined) {\n\t\t\t\t\twithRoot();\n\t\t\t\t} else {\n\t\t\t\t\tassert(this.parent !== undefined, 0x5b0 /* parent must exist */);\n\t\t\t\t\t// TODO:Perf:\n\t\t\t\t\t// When traversing to a depth D when there are not anchors in that subtree, this goes O(D^2).\n\t\t\t\t\t// Delta traversal should early out in this case because no work is needed (and all move outs are known to not contain anchors).\n\t\t\t\t\tthis.parent = this.anchorSet.internalizePath(this.parent);\n\t\t\t\t\tif (this.parent instanceof PathNode) {\n\t\t\t\t\t\tthis.parent.addRef();\n\t\t\t\t\t\treferencedPathNodes.push(this.parent);\n\t\t\t\t\t\twithNode(this.parent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Lookup table for path visitors collected from {@link AnchorEvents.visitSubtreeChanging} emitted events.\n\t\t\t// The key is the path of the node that the visitor is registered on. The code ensures that the path visitor visits only the appropriate subtrees\n\t\t\t// by maintaining the mapping only during time between the {@link DeltaVisitor.enterNode} and {@link DeltaVisitor.exitNode} calls for a given anchorNode.\n\t\t\tpathVisitors: new Map<PathNode, Set<PathVisitor>>(),\n\t\t\tparentField: undefined as FieldKey | undefined,\n\t\t\tparent: undefined as UpPath | undefined,\n\t\t\tbufferedEvents: [] as { node: PathNode; event: keyof AnchorEvents }[],\n\n\t\t\t// 'currentDepth' and 'depthThresholdForSubtreeChanged' serve to keep track of when do we need to emit\n\t\t\t// subtreeChangedAfterBatch events.\n\t\t\t// The algorithm works as follows:\n\t\t\t// - Initialize both to 0.\n\t\t\t// - As we walk the tree from the root towards the leaves, when we enter a node increment currentDepth by 1.\n\t\t\t// - When we edit a node, set depthThresholdForSubtreeChanged = currentDepth.\n\t\t\t// Intuitively, depthThresholdForSubtreeChanged means \"as you walk the tree towards the root, when you exit a\n\t\t\t// node at this depth you should emit a subtreeChangedAfterBatch event\".\n\t\t\t// - When we exit a node, if d === currentDepth then emit a subtreeChangedAfterBatch and decrement d by 1.\n\t\t\t// Then decrement currentDepth unconditionally.\n\t\t\t// Note that the event will be emitted when exiting a node that was edited (depthThresholdForSubtreeChanged will\n\t\t\t// have been set to the current depth when the edit happened), it will be emitted when exiting a node that is the\n\t\t\t// parent of a node that already emitted the event (because both depthThresholdForSubtreeChanged and currentDepth\n\t\t\t// get decremented when exiting a node so they stay in sync), and if we're already emitting the event but start\n\t\t\t// walking the tree back towards the leaves in a path where no edits happen, currentDepth will be increased again\n\t\t\t// as we walk that path, depthThresholdForSubtreeChanged will not, and thus no event will be emitted when walking\n\t\t\t// back up that path, until we get back to the depth where we were already emitting the event, and will continue\n\t\t\t// emitting it on the way to the root.\n\t\t\tcurrentDepth: 0,\n\t\t\tdepthThresholdForSubtreeChanged: 0,\n\n\t\t\tfree() {\n\t\t\t\tassert(\n\t\t\t\t\tthis.anchorSet.activeVisitor !== undefined,\n\t\t\t\t\t0x768 /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tfor (const node of referencedPathNodes) {\n\t\t\t\t\tnode.removeRef();\n\t\t\t\t}\n\t\t\t\tthis.anchorSet.activeVisitor = undefined;\n\t\t\t\tconst alreadyEmitted = new Map<PathNode, string[]>();\n\t\t\t\tfor (const { node, event } of this.bufferedEvents) {\n\t\t\t\t\tif (!alreadyEmitted.has(node)) {\n\t\t\t\t\t\talreadyEmitted.set(node, []);\n\t\t\t\t\t}\n\t\t\t\t\tconst emittedEvents = alreadyEmitted.get(node);\n\t\t\t\t\tif (emittedEvents?.includes(event) ?? false) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\temittedEvents?.push(event);\n\t\t\t\t\tnode.events.emit(event, node);\n\t\t\t\t}\n\t\t\t},\n\t\t\tnotifyChildrenChanging(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => p.events.emit(\"childrenChanging\", p),\n\t\t\t\t\t() => this.anchorSet.events.emit(\"childrenChanging\", this.anchorSet),\n\t\t\t\t);\n\t\t\t},\n\t\t\tnotifyChildrenChanged(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => {\n\t\t\t\t\t\tp.events.emit(\"childrenChanged\", p);\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"childrenChangedAfterBatch\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\t() => {},\n\t\t\t\t);\n\t\t\t},\n\t\t\tbeforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a0 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst destinationPath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: destination,\n\t\t\t\t};\n\t\t\t\tconst sourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeAttach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterAttach(source: FieldKey, destination: Range): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a1 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst destinationPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...destination,\n\t\t\t\t};\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterAttach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tattach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tattachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a2 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: source,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t};\n\t\t\t\tconst destinationPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: destination,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, count);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\tbeforeDetach(source: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a3 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a4 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdetach(source: Range, destination: FieldKey): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdetachEdit(source: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a5 /* Must be in a field in order to detach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: source.start,\n\t\t\t\t};\n\t\t\t\tconst destinationPath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: destination,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, source.end - source.start);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\tbeforeReplace(newContent: FieldKey, oldContent: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a6 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst oldContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...oldContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: newContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: oldContent.end - oldContent.start,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\toldContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a7 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst newContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...newContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: newContentSource,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: oldContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: newContent.end - newContent.start,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\tnewContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\treplace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tthis.anchorSet.removeChildren(\n\t\t\t\t\t{\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\tparentField: detachedField,\n\t\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\t},\n\t\t\t\t\tcount,\n\t\t\t\t);\n\t\t\t},\n\t\t\tbeforeDestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tconst range: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: detachedField,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDestroy(range);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcreate(content: Delta.ProtoNodes, destination: FieldKey): void {\n\t\t\t\t// Nothing to do since content can only be created in a new detached field,\n\t\t\t\t// which cannot contain any anchors.\n\t\t\t},\n\t\t\tafterCreate(content: Delta.ProtoNodes, destination: FieldKey): void {\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tconst rangePath: DetachedRangeUpPath = brand({\n\t\t\t\t\t\t\tfield: destination,\n\t\t\t\t\t\t\tstart: 0,\n\t\t\t\t\t\t\tend: content.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tpathVisitor.afterCreate(rangePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(this.parentField !== undefined, 0x3ab /* Must be in a field to enter node */);\n\n\t\t\t\tthis.parent = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tthis.parentField = undefined;\n\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\t// avoid multiple pass side-effects\n\t\t\t\t\tif (!this.pathVisitors.has(p)) {\n\t\t\t\t\t\tconst visitors: (PathVisitor | void)[] = p.events.emitAndCollect(\n\t\t\t\t\t\t\t\"subtreeChanging\",\n\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (visitors.length > 0) {\n\t\t\t\t\t\t\tthis.pathVisitors.set(\n\t\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t\t\tnew Set(visitors.filter((v): v is PathVisitor => v !== undefined)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis.currentDepth++;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(this.parent !== undefined, 0x3ac /* Must have parent node */);\n\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\tp.events.emit(\"subtreeChanged\", p);\n\t\t\t\t\tif (this.depthThresholdForSubtreeChanged === this.currentDepth) {\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"subtreeChangedAfterBatch\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.depthThresholdForSubtreeChanged--;\n\t\t\t\t\t}\n\t\t\t\t\t// Remove subtree path visitors added at this node if there are any\n\t\t\t\t\tthis.pathVisitors.delete(p);\n\t\t\t\t});\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tthis.parentField = parent.parentField;\n\t\t\t\tthis.parent = parent.parent;\n\t\t\t\tthis.currentDepth--;\n\t\t\t},\n\t\t\tenterField(key: FieldKey): void {\n\t\t\t\tthis.parentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tthis.parentField = undefined;\n\t\t\t},\n\t\t};\n\t\tthis.events.emit(\"treeChanging\", this);\n\t\tthis.activeVisitor = visitor;\n\t\treturn visitor;\n\t}\n}\n\n/**\n * Indicates the status of a `NodePath`.\n */\nenum Status {\n\t/**\n\t * Indicates the `NodePath` is being maintained and corresponds to a valid\n\t * (i.e., not removed) node in the document.\n\t */\n\tAlive,\n\t/**\n\t * Indicates the `NodePath` is not being maintained by the `AnchorSet`.\n\t * The `NodePath` may or may not correspond to a valid node in the document.\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDisposed,\n\t/**\n\t * Indicates the `NodePath` corresponds to a removed node in the document.\n\t * Such `NodePath`s are not maintained by the `AnchorSet` (other than updating\n\t * their status to `Disposed` when appropriate).\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDangling,\n}\n\n/**\n * Tree of anchors.\n *\n * Contains both child and parent pointers, which are kept in sync.\n *\n * Each anchor is equivalent to a path through the tree.\n * This tree structure stores a collection of these paths, but deduplicating the common prefixes of the tree\n * prefix-tree style.\n *\n * These anchors are used instead of just holding onto the node objects in forests for several reasons:\n *\n * - Update policy might be more complex than just tracking a node object in the forest.\n *\n * - Not all forests will have node objects: some may use compressed binary formats with no objects to reference.\n *\n * - Anchors are needed even when not using forests, and for nodes that are outside the currently loaded part of the\n * forest.\n *\n * - Forest in general do not need to support up pointers, but they are needed for anchors.\n *\n * Thus this can be thought of as a sparse copy of the subset of trees which are used as anchors,\n * plus the parent paths for them.\n *\n * ReferenceCountedBase tracks the number of references to this from external sources (`Anchors` via `AnchorSet`.).\n * Kept alive as if any of the follow are true:\n * 1. there are children.\n * 2. refcount is non-zero.\n * 3. events are registered.\n */\nclass PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorNode {\n\tpublic status: Status = Status.Alive;\n\t/**\n\t * Event emitter for this anchor.\n\t */\n\tpublic readonly events = createEmitter<AnchorEvents>(() => this.considerDispose());\n\n\t/**\n\t * PathNode arrays are kept sorted the PathNode's parentIndex for efficient search.\n\t * Users of this field must take care to maintain invariants (correct parent pointers, not empty child arrays etc.)\n\t *\n\t * Performance Note:\n\t * Large child lists could be updated more efficiently here using a data-structure optimized\n\t * for efficient prefix sum updates, such as a Fenwick tree or Finger tree.\n\t * This would be complicated by the need for parent pointers (including indexes),\n\t * but is possible to do.\n\t */\n\tpublic readonly children: Map<FieldKey, PathNode[]> = new Map();\n\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic readonly slots: BrandedMapSubset<AnchorSlot<any>> = new Map();\n\n\t/**\n\t * Construct a PathNode with refcount 1.\n\t * @param anchorSet - used to determine if this PathNode is already part of a specific anchorSet\n\t * to early out UpPath walking.\n\t */\n\tpublic constructor(\n\t\tpublic readonly anchorSet: AnchorSet,\n\t\tpublic parentField: FieldKey,\n\t\tpublic parentIndex: number,\n\t\t/**\n\t\t * The parent of this `PathNode` (an up pointer in the `PathNode` tree).\n\t\t * If the status of this node is `Alive`, then there must be a corresponding down pointer from the\n\t\t * `parentPath` node to this node.\n\t\t * When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.\n\t\t *\n\t\t * When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent\n\t\t * (updating down pointers first), but must ensure they are consistent before the editing operation returns\n\t\t * to non-`AnchorSet` code.\n\t\t * This consistency guarantee only applies to nodes that are `Alive`.\n\t\t */\n\t\tpublic parentPath: PathNode | undefined,\n\t) {\n\t\tsuper(1);\n\t}\n\n\tpublic on<K extends keyof AnchorEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\n\t}\n\n\tpublic child(key: FieldKey, index: number): UpPath<AnchorNode> {\n\t\t// Fast path: if child exists, return it.\n\t\treturn (\n\t\t\tthis.tryGetChild(key, index) ?? { parent: this, parentField: key, parentIndex: index }\n\t\t);\n\t}\n\n\tpublic getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode] {\n\t\tconst anchor = this.anchorSet.track(this.child(key, index));\n\t\tconst node =\n\t\t\tthis.anchorSet.locate(anchor) ?? fail(\"cannot reference child that does not exist\");\n\t\treturn [anchor, node];\n\t}\n\n\t/**\n\t * @returns true iff this PathNode is the special root node that sits above all the detached fields.\n\t * In this case, the fields are detached sequences.\n\t * Note that the special root node should never appear in an UpPath\n\t * since UpPaths represent this root as `undefined`.\n\t */\n\tprivate isRoot(): boolean {\n\t\treturn this.parentPath === undefined;\n\t}\n\n\tpublic get parent(): PathNode | undefined {\n\t\tassert(this.status !== Status.Disposed, 0x409 /* PathNode must not be disposed */);\n\t\tassert(\n\t\t\tthis.parentPath !== undefined,\n\t\t\t0x355 /* PathNode.parent is an UpPath API and thus should never be called on the root PathNode. */,\n\t\t);\n\t\t// Root PathNode corresponds to the undefined root for UpPath API.\n\t\tif (this.parentPath.isRoot()) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.parentPath;\n\t}\n\n\tpublic addRef(count = 1): void {\n\t\tassert(this.status === Status.Alive, 0x40a /* PathNode must be alive */);\n\t\tthis.referenceAdded(count);\n\t}\n\n\tpublic removeRef(count = 1): void {\n\t\tassert(this.status !== Status.Disposed, 0x40b /* PathNode must not be disposed */);\n\t\tthis.referenceRemoved(count);\n\t}\n\n\t// Called when refcount is set to 0.\n\t// Node may be kept alive by children or events after this point.\n\tprotected onUnreferenced(): void {\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * Gets a child, adding a ref to it.\n\t * Creates child (with 1 ref) if needed.\n\t */\n\tpublic getOrCreateChild(key: FieldKey, index: number): PathNode {\n\t\tassert(this.status === Status.Alive, 0x40c /* PathNode must be alive */);\n\t\tlet field = this.children.get(key);\n\t\tif (field === undefined) {\n\t\t\tfield = [];\n\t\t\tthis.children.set(key, field);\n\t\t}\n\t\t// TODO: should do more optimized search (ex: binary search).\n\t\tlet child = field.find((c) => c.parentIndex === index);\n\t\tif (child === undefined) {\n\t\t\tchild = new PathNode(this.anchorSet, key, index, this);\n\t\t\tfield.push(child);\n\t\t\t// Keep list sorted by index.\n\t\t\tfield.sort((a, b) => a.parentIndex - b.parentIndex);\n\t\t} else {\n\t\t\tchild.addRef();\n\t\t}\n\t\treturn child;\n\t}\n\n\t/**\n\t * Gets a child if it exists.\n\t * Does NOT add a ref.\n\t */\n\tpublic tryGetChild(key: FieldKey, index: number): PathNode | undefined {\n\t\tassert(this.status === Status.Alive, 0x40d /* PathNode must be alive */);\n\t\tconst field = this.children.get(key);\n\n\t\t// TODO: should do more optimized search (ex: binary search or better) using index.\n\t\treturn field?.find((c) => c.parentIndex === index);\n\t}\n\n\t/**\n\t * Removes reference from this to `child`.\n\t * Since PathNodes are doubly linked,\n\t * the caller must ensure that the reference from child to parent is also removed (or the child is no longer used).\n\t */\n\tpublic removeChild(child: PathNode): void {\n\t\tassert(this.status === Status.Alive, 0x40e /* PathNode must be alive */);\n\t\tconst key = child.parentField;\n\t\tconst field = this.children.get(key);\n\t\t// TODO: should do more optimized search (ex: binary search or better) using child.parentIndex()\n\t\t// Note that this is the index in the list of child paths, not the index within the field\n\t\tconst childIndex = field?.indexOf(child) ?? -1;\n\t\tassert(childIndex !== -1, 0x35c /* child must be parented to be removed */);\n\t\tfield?.splice(childIndex, 1);\n\t\tif (field?.length === 0) {\n\t\t\tthis.afterEmptyField(key);\n\t\t}\n\t}\n\n\t/**\n\t * Call this after directly editing the child array for a field to be empty.\n\t * Handles cleaning up unneeded data\n\t * (like the field in the map, and possibly this entire PathNode and its parents if they are no longer needed.)\n\t */\n\tpublic afterEmptyField(key: FieldKey): void {\n\t\tassert(this.status === Status.Alive, 0x40f /* PathNode must be alive */);\n\t\tthis.children.delete(key);\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * If node is no longer needed (has no references, no children and no events):\n\t * removes this from parent if alive, and sets this to disposed.\n\t * Must only be called when .\n\t *\n\t * Allowed when dangling (but not when disposed).\n\t */\n\tprivate considerDispose(): void {\n\t\tassert(this.status !== Status.Disposed, 0x41d /* PathNode must not be disposed */);\n\t\tif (this.isUnreferenced() && this.children.size === 0 && !this.events.hasListeners()) {\n\t\t\tif (this.status === Status.Alive) {\n\t\t\t\tthis.parentPath?.removeChild(this);\n\t\t\t}\n\t\t\tthis.status = Status.Disposed;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"anchorSet.js","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAA6D;AAE7D,kEAA6D;AAE7D,oDAAuE;AACvE,kDAS6B;AAa7B,yCAAkD;AAWlD;;GAEG;AACH,MAAM,WAAW,GAAW,IAAA,gBAAK,EAAC,CAAC,CAAC,CAAC;AAuMrC;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU;IACzB,OAAO,IAAA,sBAAW,GAAwB,CAAC;AAC5C,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;GAUG;AACH,MAAa,SAAS;IAkCrB;QAjCiB,WAAM,GAAG,IAAA,wBAAa,GAAuB,CAAC;QAC/D;;;WAGG;QACK,kBAAa,GAAG,CAAC,CAAC;QAE1B;;;;WAIG;QACI,qBAAgB,GAAG,CAAC,CAAC;QAE5B;;;;;;;;;;WAUG;QACc,SAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,mBAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;QAEnE,8GAA8G;QAC9G,yDAAyD;QACxC,iBAAY,GAA0B,IAAI,GAAG,EAAE,CAAC;QAKhE,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;YAC5B,IAAI,CAAC,gBAAgB,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OA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AAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC/B,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type Listenable, createEmitter } from \"../../events/index.js\";\nimport {\n\ttype Brand,\n\ttype BrandedKey,\n\ttype BrandedMapSubset,\n\ttype Opaque,\n\tReferenceCountedBase,\n\tbrand,\n\tbrandedSlot,\n\tfail,\n} from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedPlaceUpPath,\n\tDetachedRangeUpPath,\n\tPlaceIndex,\n\tPlaceUpPath,\n\tRange,\n\tRangeUpPath,\n\tUpPath,\n} from \"./pathTree.js\";\nimport { EmptyKey, type Value } from \"./types.js\";\nimport type { DeltaVisitor } from \"./visitDelta.js\";\nimport type { PathVisitor } from \"./visitPath.js\";\nimport type { AnnouncedVisitor } from \"./visitorUtils.js\";\n\n/**\n * A way to refer to a particular tree location within an {@link AnchorSet}.\n * Associated with a ref count on the underlying {@link AnchorNode}.\n */\nexport type Anchor = Brand<number, \"rebaser.Anchor\">;\n\n/**\n * A singleton which represents a permanently invalid location (i.e. there is never a node there)\n */\nconst NeverAnchor: Anchor = brand(0);\n\n/**\n * Maps anchors (which must be ones this locator knows about) to paths.\n */\nexport interface AnchorLocator {\n\t/**\n\t * Get the current location of an Anchor.\n\t * The returned value should not be used after an edit has occurred.\n\t *\n\t * TODO: support extra/custom return types for specific/custom anchor types:\n\t * for now caller must rely on data in anchor + returned node location\n\t * (not ideal for anchors for places or ranges instead of nodes).\n\t */\n\tlocate(anchor: Anchor): AnchorNode | undefined;\n}\n\n/**\n * Stores arbitrary, user-defined data on an {@link Anchor}.\n * This data is preserved over the course of that anchor's lifetime.\n * @see {@link anchorSlot} for creation and an example use case.\n */\nexport type AnchorSlot<TContent> = BrandedKey<Opaque<Brand<number, \"AnchorSlot\">>, TContent>;\n\n/**\n * Events for {@link AnchorNode}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Include sub-deltas in events.\n * - Add more events.\n */\nexport interface AnchorEvents {\n\t/**\n\t * When the anchor node will never get reused by its AnchorSet.\n\t * This means that the content it corresponds to has been permanently destroyed.\n\t *\n\t * @remarks\n\t * When this happens depends entirely on how the anchorSet is used.\n\t * It's possible nodes removed from the tree will be kept indefinitely, and thus never trigger this event, or they may be discarded immediately.\n\t *\n\t * @privateRemarks\n\t * The specifics of the delta visit algorithm can impact the behavior of these events.\n\t * Refer to the privateRemarks of specific events and/or the documentation of the delta visit algorithm (as of\n\t * 2024-04-02, src/core/tree/visitDelta.ts) for more information.\n\t */\n\tafterDestroy(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children are about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t */\n\tchildrenChanging(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t */\n\tchildrenChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if one or more of this node's\n\t * direct children changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChanged} which is emitted in the middle of the batch/delta-visit.\n\t */\n\tchildrenChangedAfterBatch(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ be about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * The event can optionally return a {@link PathVisitor} to traverse the subtree.\n\t * Called on every parent (transitively) when a change is occurring.\n\t */\n\tsubtreeChanging(anchor: AnchorNode): PathVisitor | void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ have just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * While this event is always emitted in the presence of changes to the subtree,\n\t * it may also be emitted even though no changes have been made to the subtree.\n\t * It may be emitted multiple times within the application of a single edit or transaction.\n\t *\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, at\n\t * least once on each ancestor.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t *\n\t * @privateRemarks\n\t * The delta visit algorithm is complicated and it may fire this event multiple times for the same change to a node.\n\t * The change to the tree may not be visible until the event fires for the last time.\n\t * Refer to the documentation of the delta visit algorithm for more details.\n\t */\n\tsubtreeChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if something in the subtree\n\t * rooted at `anchor` changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, from bottom to top.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChanged} which is emitted in the middle of the batch/delta-visit.\n\t *\n\t * @privateRemarks\n\t * Note that because this is fired after the full batch of changes is applied, it guarantees that something in the\n\t * subtree changed, compared to {@link AnchorEvents.subtreeChanged} or {@link AnchorEvents.subtreeChanging} which\n\t * fire when something _may_ have changed or _may_ be about to change.\n\t */\n\tsubtreeChangedAfterBatch(anchor: AnchorNode): void;\n\n\t/**\n\t * Value on this node is changing.\n\t */\n\tvalueChanging(anchor: AnchorNode, value: Value): void;\n}\n\n/**\n * Events for {@link AnchorSet}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Design how events should be ordered.\n * - Include sub-deltas in events.\n * - Add more events.\n */\nexport interface AnchorSetRootEvents {\n\t/**\n\t * What children are at the root is changing.\n\t */\n\tchildrenChanging(anchors: AnchorSet): void;\n\n\t/**\n\t * Something in the tree is changing.\n\t */\n\ttreeChanging(anchors: AnchorSet): void;\n}\n\n/**\n * Node in a tree of anchors.\n */\nexport interface AnchorNode extends UpPath<AnchorNode>, Listenable<AnchorEvents> {\n\t/**\n\t * Allows access to data stored on the Anchor in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t */\n\t// See note on BrandedKey\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treadonly slots: BrandedMapSubset<AnchorSlot<any>>;\n\n\t/**\n\t * The set this anchor node is part of.\n\t */\n\treadonly anchorSet: AnchorSet;\n\n\t/**\n\t * Gets a child of this node.\n\t *\n\t * @remarks\n\t * This does not return an AnchorNode since there might not be one, and lazily creating one here would have messy lifetime management (See {@link AnchorNode#getOrCreateChildRef})\n\t * If an AnchorNode is required, use the AnchorSet to track then locate the returned path.\n\t * TODO:\n\t * Revisit this API.\n\t * Perhaps if we use weak down pointers and remove ref counting, we can make this return a AnchorNode.\n\t *\n\t */\n\tchild(key: FieldKey, index: number): UpPath<AnchorNode>;\n\n\t/**\n\t * Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.\n\t * Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.\n\t */\n\tgetOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];\n}\n\n/**\n * Define a strongly typed slot on anchors in which data can be stored.\n *\n * @remarks\n * This is mainly useful for caching data associated with a location in the tree.\n *\n * Example usage:\n * ```typescript\n * const counterSlot = anchorSlot<number>();\n *\n * function useSlot(anchor: AnchorNode): void {\n * \tanchor.slots.set(counterSlot, 1 + anchor.slots.get(counterSlot) ?? 0);\n * }\n * ```\n */\nexport function anchorSlot<TContent>(): AnchorSlot<TContent> {\n\treturn brandedSlot<AnchorSlot<TContent>>();\n}\n\n/**\n * Collection of Anchors at a specific revision.\n *\n * See `Rebaser` for how to update across revisions.\n *\n * TODO: this should not be package exported.\n * If it's needed outside the package an Interface should be used instead which can reduce its\n * API surface to a small subset.\n *\n * @sealed\n */\nexport class AnchorSet implements Listenable<AnchorSetRootEvents>, AnchorLocator {\n\tprivate readonly events = createEmitter<AnchorSetRootEvents>();\n\t/**\n\t * Incrementing counter to give each anchor in this set a unique index for its identifier.\n\t * \"0\" is reserved for the `NeverAnchor`.\n\t */\n\tprivate anchorCounter = 1;\n\n\t/**\n\t * Incrementing number that is bumped each time that the {@link AnchorSet} is changed.\n\t * This allows consumers to cache state associated with a particular generation number and later determine if that state may have been invalidated using a comparison with the current generation number.\n\t * For example, anchor slots can be used to cache the removal status of a node to memoize repeated walks up the tree.\n\t */\n\tpublic generationNumber = 0;\n\n\t/**\n\t * Special root node under which all anchors in this anchor set are transitively parented.\n\t * This does not appear in the UpPaths (instead they use undefined for the root).\n\t * Immediate children of this root are in detached fields (which have their identifiers used as the field keys).\n\t *\n\t * This is allocated with refCount one, which is never freed so it is never cleaned up\n\t * (as long as this AnchorSet is not garbage collected).\n\t *\n\t * There should never be any children other than the special root detached field under this between transactions:\n\t * TODO: check for and enforce this.\n\t */\n\tprivate readonly root = new PathNode(this, EmptyKey, 0, undefined);\n\n\t// TODO: anchor system could be optimized a bit to avoid the maps (Anchor is ref to Path, path has ref count).\n\t// For now use this more encapsulated approach with maps.\n\tprivate readonly anchorToPath: Map<Anchor, PathNode> = new Map();\n\n\tprivate activeVisitor?: DeltaVisitor;\n\n\tpublic constructor() {\n\t\tthis.on(\"treeChanging\", () => {\n\t\t\tthis.generationNumber += 1;\n\t\t});\n\t}\n\n\t/**\n\t * Allows access to data stored on the AnchorSet in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t *\n\t * @privateRemarks\n\t * This forwards to the slots of the special above root anchor which locate can't access.\n\t */\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get slots(): BrandedMapSubset<AnchorSlot<any>> {\n\t\treturn this.root.slots;\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<AnchorNode> {\n\t\tconst stack: PathNode[] = [];\n\t\tlet node: PathNode | undefined = this.root;\n\t\twhile (node !== undefined) {\n\t\t\tyield node;\n\t\t\tfor (const [_, children] of node.children) {\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tstack.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t\tnode = stack.pop();\n\t\t}\n\t}\n\n\tpublic on<K extends keyof AnchorSetRootEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorSetRootEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\n\t}\n\n\t/**\n\t * Check if there are currently no anchors tracked.\n\t * Mainly for testing anchor cleanup.\n\t */\n\tpublic isEmpty(): boolean {\n\t\treturn this.root.children.size === 0;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tif (anchor === NeverAnchor) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = this.anchorToPath.get(anchor);\n\t\tassert(\n\t\t\tpath !== undefined,\n\t\t\t0x3a6 /* Cannot locate anchor which is not in this AnchorSet */,\n\t\t);\n\t\treturn path.status === Status.Alive ? path : undefined;\n\t}\n\n\tpublic forget(anchor: Anchor): void {\n\t\tif (anchor !== NeverAnchor) {\n\t\t\tconst path = this.anchorToPath.get(anchor);\n\t\t\tassert(path !== undefined, 0x351 /* cannot forget unknown Anchor */);\n\t\t\tpath.removeRef();\n\t\t\tthis.anchorToPath.delete(anchor);\n\t\t}\n\t}\n\n\t/**\n\t * TODO: Add APIs need to allow callers of this function to reduce copying here.\n\t * Ex: maybe return something extending UpPath here.\n\t * @param path - the path to the node to be tracked. If null, returns an anchor\n\t * which is permanently invalid.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic track(path: UpPath | null): Anchor {\n\t\tif (path === null) {\n\t\t\treturn NeverAnchor;\n\t\t}\n\n\t\tconst foundPath = this.trackInner(path);\n\t\tconst anchor: Anchor = brand(this.anchorCounter++);\n\t\tthis.anchorToPath.set(anchor, foundPath);\n\t\treturn anchor;\n\t}\n\n\t/**\n\t * Finds a path node, creating if needed, and adds a ref count to it.\n\t */\n\tprivate trackInner(path: UpPath): PathNode {\n\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\tpath.addRef();\n\t\t\treturn path;\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.trackInner(parent);\n\n\t\tconst child = parentPath.getOrCreateChild(path.parentField, path.parentIndex);\n\n\t\t// Now that child is added (if needed), remove the extra ref that we added in the recursive call.\n\t\tparentPath.removeRef();\n\n\t\treturn child;\n\t}\n\n\t/**\n\t * Finds a path node if it already exists.\n\t */\n\tprivate find(path: UpPath): PathNode | undefined {\n\t\tif (path instanceof PathNode) {\n\t\t\tif (path.anchorSet === this) {\n\t\t\t\treturn path;\n\t\t\t}\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.find(parent);\n\t\treturn parentPath?.tryGetChild(path.parentField, path.parentIndex);\n\t}\n\n\t/**\n\t * Returns an equivalent path making as much of it with PathNodes as possible.\n\t * This allows future operations (like find, track, locate) on this path (and derived ones) to be faster.\n\t * Note that the returned path may use AnchorNodes from this AnchorSet,\n\t * but does not have a tracked reference to them, so this should not be held onto across anything that might free an AnchorNode.\n\t *\n\t * @remarks\n\t * Also ensures that any PathNode in the path is from this AnchorSet.\n\t */\n\tpublic internalizePath(originalPath: UpPath): UpPath {\n\t\tlet path: UpPath | undefined = originalPath;\n\t\tconst stack: UpPath[] = [];\n\t\twhile (path !== undefined) {\n\t\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tstack.push(path);\n\t\t\tpath = path.parent;\n\t\t}\n\n\t\t// Now `path` contains an internalized path.\n\t\t// It just needs the paths from stackOut to wrap it.\n\n\t\tlet wrapWith: UpPath | undefined;\n\t\twhile ((wrapWith = stack.pop()) !== undefined) {\n\t\t\tif (path === undefined || path instanceof PathNode) {\n\t\t\t\t// If path already has an anchor, get an anchor for it's child if there is one:\n\t\t\t\tconst child = (path ?? this.root).tryGetChild(\n\t\t\t\t\twrapWith.parentField,\n\t\t\t\t\twrapWith.parentIndex,\n\t\t\t\t);\n\t\t\t\tif (child !== undefined) {\n\t\t\t\t\tpath = child;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Replacing this if with a ternary makes the documentation harder to include and hurts readability.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (path === wrapWith.parent && !(wrapWith instanceof PathNode)) {\n\t\t\t\t// path is safe to reuse from input path, so use it to avoid allocating another object.\n\t\t\t\tpath = wrapWith;\n\t\t\t} else {\n\t\t\t\tpath = {\n\t\t\t\t\tparent: path,\n\t\t\t\t\tparentField: wrapWith.parentField,\n\t\t\t\t\tparentIndex: wrapWith.parentIndex,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn path ?? fail(\"internalize path must be a path\");\n\t}\n\n\t/**\n\t * Recursively marks the given `nodes` and their descendants as disposed and pointing to a deleted node.\n\t * Note that this does NOT detach the nodes.\n\t */\n\tprivate deepDelete(nodes: readonly PathNode[]): void {\n\t\tconst stack = [...nodes];\n\t\twhile (stack.length > 0) {\n\t\t\tconst node = stack.pop()!;\n\t\t\tassert(node.status === Status.Alive, 0x408 /* PathNode must be alive */);\n\t\t\tnode.status = Status.Dangling;\n\t\t\tnode.events.emit(\"afterDestroy\", node);\n\t\t\tfor (const children of node.children.values()) {\n\t\t\t\tstack.push(...children);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Decouple nodes from their parent.\n\t * This removes the reference from the parent to the decoupled children, and updates the indexes of the remaining children accordingly.\n\t * This does NOT update the decoupled children: both their index and parent are left at their existing values.\n\t * To decouple and fixup the children, see `removeChildren` and `moveChildren`.\n\t * @param startPath - The path to the first node that is being decoupled.\n\t * @param count - number of siblings that are decoupled from the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate decoupleNodes(startPath: UpPath, count: number): PathNode[] {\n\t\tassert(count > 0, 0x681 /* count must be positive */);\n\n\t\tconst sourceParent = this.find(startPath.parent ?? this.root);\n\t\tconst sourceChildren = sourceParent?.children?.get(startPath.parentField);\n\t\tlet nodes: PathNode[] = [];\n\n\t\tif (sourceChildren !== undefined) {\n\t\t\tlet numberBeforeDecouple = 0;\n\t\t\tlet numberToDecouple = 0;\n\t\t\tlet index = 0;\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index]!.parentIndex < startPath.parentIndex\n\t\t\t) {\n\t\t\t\tnumberBeforeDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index]!.parentIndex < startPath.parentIndex + count\n\t\t\t) {\n\t\t\t\tnumberToDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (index < sourceChildren.length) {\n\t\t\t\t// Fix indexes in source after moved items (subtract count).\n\t\t\t\tsourceChildren[index]!.parentIndex -= count;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\t// Sever the parent -> child connections\n\t\t\tnodes = sourceChildren.splice(numberBeforeDecouple, numberToDecouple);\n\t\t\tif (sourceChildren.length === 0) {\n\t\t\t\tsourceParent!.afterEmptyField(startPath.parentField);\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * Couple nodes to a parent.\n\t * @param destination - where the siblings are coupled to.\n\t * @param count - number of siblings that are coupled in the original tree.\n\t * @param coupleInfo - this object contains the nodes to couple and the parent index of the first node that is coupled in the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate coupleNodes(\n\t\tdestination: UpPath,\n\t\tcount: number,\n\t\tcoupleInfo: { startParentIndex: number; nodes: PathNode[] },\n\t): void {\n\t\tassert(coupleInfo.nodes.length > 0, 0x682 /* coupleInfo must have nodes to couple */);\n\n\t\t// The destination needs to be created if it does not exist yet.\n\t\tconst destinationPath = this.trackInner(destination.parent ?? this.root);\n\n\t\t// Update nodes for new parent.\n\t\tfor (const node of coupleInfo.nodes) {\n\t\t\tnode.parentIndex += destination.parentIndex - coupleInfo.startParentIndex;\n\t\t\tnode.parentPath = destinationPath;\n\t\t\tnode.parentField = destination.parentField;\n\t\t}\n\n\t\t// Update new parent to add children\n\t\tconst field = destinationPath.children.get(destination.parentField);\n\t\tif (field === undefined) {\n\t\t\tdestinationPath.children.set(destination.parentField, coupleInfo.nodes);\n\t\t} else {\n\t\t\t// Update existing field contents\n\t\t\tconst numberBeforeCouple = this.increaseParentIndexes(\n\t\t\t\tfield,\n\t\t\t\tdestination.parentIndex,\n\t\t\t\tcount,\n\t\t\t);\n\n\t\t\t// TODO: this will fail for very large numbers of anchors due to argument limits.\n\t\t\tfield.splice(numberBeforeCouple, 0, ...coupleInfo.nodes);\n\t\t}\n\n\t\tdestinationPath.removeRef();\n\t}\n\n\t/**\n\t * Updates the parent indexes within `field` to account for `count` children being inserted at `fromParentIndex`. Note that\n\t * `fromParentIndex` is the logical position within the field, not the index with the sparse PathNode array.\n\t *\n\t * @param field - the field to update.\n\t * @param fromParentIndex - the logical index within the field to start updating from.\n\t * @param count - the number to increase parent indexes.\n\t * @returns the number of items in the field that are not increased.\n\t *\n\t * TODO: tests\n\t */\n\tprivate increaseParentIndexes(\n\t\tfield: PathNode[],\n\t\tfromParentIndex: number,\n\t\tcount: number,\n\t): number {\n\t\tlet index = 0;\n\t\twhile (index < field.length && field[index]!.parentIndex < fromParentIndex) {\n\t\t\tindex++;\n\t\t}\n\t\tconst numberBeforeIncrease = index;\n\t\twhile (index < field.length) {\n\t\t\tfield[index]!.parentIndex += count;\n\t\t\tindex++;\n\t\t}\n\n\t\treturn numberBeforeIncrease;\n\t}\n\n\t/**\n\t * Updates paths for a range move (including re-parenting path items and updating indexes).\n\t * @param sourceStart - where the siblings are removed from.\n\t * @param destination - where the siblings are moved to.\n\t * @param count - number of siblings to move.\n\t *\n\t * TODO:\n\t * How should anchors that become invalid, then valid again (ex: into content that was deleted, then undone) work?\n\t * Add an API to resurrect them? Store them in special detached fields? Store them in special non-detached fields?\n\t *\n\t * TODO:\n\t * How should custom anchors work (ex: ones not just tied to a specific Node)?\n\t * This design assumes they can be expressed in terms of a Node anchor + some extra stuff,\n\t * but we don't have an API for the extra stuff yet.\n\t *\n\t * TODO: tests\n\t */\n\tprivate moveChildren(sourceStart: UpPath, destination: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(sourceStart, count);\n\t\tif (nodes.length > 0) {\n\t\t\tthis.coupleNodes(destination, count, {\n\t\t\t\tstartParentIndex: sourceStart.parentIndex,\n\t\t\t\tnodes,\n\t\t\t});\n\t\t} else {\n\t\t\t// If there are no nodes to move, we still need to update the parent indexes of the nodes\n\t\t\t// affected in the move in.\n\t\t\tthis.offsetChildren(destination, count);\n\t\t}\n\t}\n\n\tprivate removeChildren(path: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(path, count);\n\t\tthis.deepDelete(nodes);\n\t}\n\n\t/**\n\t * Updates the parent indexes of all the nodes located at right side of the given path by the given offset.\n\t * @param firstSiblingToOffset - the path to offset children of.\n\t * @param offset - the offset to apply to the children.\n\t *\n\t */\n\tprivate offsetChildren(firstSiblingToOffset: UpPath, offset: number): void {\n\t\tconst nodePath = this.find(firstSiblingToOffset.parent ?? this.root);\n\t\tconst field = nodePath?.children.get(firstSiblingToOffset.parentField);\n\t\tif (field !== undefined) {\n\t\t\tthis.increaseParentIndexes(field, firstSiblingToOffset.parentIndex, offset);\n\t\t}\n\t}\n\n\t/**\n\t * Provides a visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @returns A visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @remarks\n\t * Mutating the {@link AnchorSet} does NOT update the forest.\n\t * The visitor must be released after use by calling {@link DeltaVisitor.free} on it.\n\t * It is invalid to acquire a visitor without releasing the previous one,\n\t * and this method will throw an error if this is attempted.\n\t */\n\tpublic acquireVisitor(): AnnouncedVisitor & DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x767 /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\tconst referencedPathNodes: PathNode[] = [];\n\t\tconst visitor = {\n\t\t\tanchorSet: this,\n\t\t\t// Run `withNode` on anchorNode for parent if there is such an anchorNode.\n\t\t\t// If at root, run `withRoot` instead.\n\t\t\tmaybeWithNode(withNode: (anchorNode: PathNode) => void, withRoot?: () => void) {\n\t\t\t\tif (this.parent === undefined && withRoot !== undefined) {\n\t\t\t\t\twithRoot();\n\t\t\t\t} else {\n\t\t\t\t\tassert(this.parent !== undefined, 0x5b0 /* parent must exist */);\n\t\t\t\t\t// TODO:Perf:\n\t\t\t\t\t// When traversing to a depth D when there are not anchors in that subtree, this goes O(D^2).\n\t\t\t\t\t// Delta traversal should early out in this case because no work is needed (and all move outs are known to not contain anchors).\n\t\t\t\t\tthis.parent = this.anchorSet.internalizePath(this.parent);\n\t\t\t\t\tif (this.parent instanceof PathNode) {\n\t\t\t\t\t\tthis.parent.addRef();\n\t\t\t\t\t\treferencedPathNodes.push(this.parent);\n\t\t\t\t\t\twithNode(this.parent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Lookup table for path visitors collected from {@link AnchorEvents.visitSubtreeChanging} emitted events.\n\t\t\t// The key is the path of the node that the visitor is registered on. The code ensures that the path visitor visits only the appropriate subtrees\n\t\t\t// by maintaining the mapping only during time between the {@link DeltaVisitor.enterNode} and {@link DeltaVisitor.exitNode} calls for a given anchorNode.\n\t\t\tpathVisitors: new Map<PathNode, Set<PathVisitor>>(),\n\t\t\tparentField: undefined as FieldKey | undefined,\n\t\t\tparent: undefined as UpPath | undefined,\n\t\t\tbufferedEvents: [] as { node: PathNode; event: keyof AnchorEvents }[],\n\n\t\t\t// 'currentDepth' and 'depthThresholdForSubtreeChanged' serve to keep track of when do we need to emit\n\t\t\t// subtreeChangedAfterBatch events.\n\t\t\t// The algorithm works as follows:\n\t\t\t// - Initialize both to 0.\n\t\t\t// - As we walk the tree from the root towards the leaves, when we enter a node increment currentDepth by 1.\n\t\t\t// - When we edit a node, set depthThresholdForSubtreeChanged = currentDepth.\n\t\t\t// Intuitively, depthThresholdForSubtreeChanged means \"as you walk the tree towards the root, when you exit a\n\t\t\t// node at this depth you should emit a subtreeChangedAfterBatch event\".\n\t\t\t// - When we exit a node, if d === currentDepth then emit a subtreeChangedAfterBatch and decrement d by 1.\n\t\t\t// Then decrement currentDepth unconditionally.\n\t\t\t// Note that the event will be emitted when exiting a node that was edited (depthThresholdForSubtreeChanged will\n\t\t\t// have been set to the current depth when the edit happened), it will be emitted when exiting a node that is the\n\t\t\t// parent of a node that already emitted the event (because both depthThresholdForSubtreeChanged and currentDepth\n\t\t\t// get decremented when exiting a node so they stay in sync), and if we're already emitting the event but start\n\t\t\t// walking the tree back towards the leaves in a path where no edits happen, currentDepth will be increased again\n\t\t\t// as we walk that path, depthThresholdForSubtreeChanged will not, and thus no event will be emitted when walking\n\t\t\t// back up that path, until we get back to the depth where we were already emitting the event, and will continue\n\t\t\t// emitting it on the way to the root.\n\t\t\tcurrentDepth: 0,\n\t\t\tdepthThresholdForSubtreeChanged: 0,\n\n\t\t\tfree() {\n\t\t\t\tassert(\n\t\t\t\t\tthis.anchorSet.activeVisitor !== undefined,\n\t\t\t\t\t0x768 /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tfor (const node of referencedPathNodes) {\n\t\t\t\t\tnode.removeRef();\n\t\t\t\t}\n\t\t\t\tthis.anchorSet.activeVisitor = undefined;\n\t\t\t\tconst alreadyEmitted = new Map<PathNode, string[]>();\n\t\t\t\tfor (const { node, event } of this.bufferedEvents) {\n\t\t\t\t\tif (!alreadyEmitted.has(node)) {\n\t\t\t\t\t\talreadyEmitted.set(node, []);\n\t\t\t\t\t}\n\t\t\t\t\tconst emittedEvents = alreadyEmitted.get(node);\n\t\t\t\t\tif (emittedEvents?.includes(event) ?? false) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\temittedEvents?.push(event);\n\t\t\t\t\tnode.events.emit(event, node);\n\t\t\t\t}\n\t\t\t},\n\t\t\tnotifyChildrenChanging(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => p.events.emit(\"childrenChanging\", p),\n\t\t\t\t\t() => this.anchorSet.events.emit(\"childrenChanging\", this.anchorSet),\n\t\t\t\t);\n\t\t\t},\n\t\t\tnotifyChildrenChanged(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => {\n\t\t\t\t\t\tp.events.emit(\"childrenChanged\", p);\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"childrenChangedAfterBatch\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\t() => {},\n\t\t\t\t);\n\t\t\t},\n\t\t\tbeforeAttach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a0 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst destinationPath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: destination,\n\t\t\t\t};\n\t\t\t\tconst sourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeAttach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterAttach(source: FieldKey, destination: Range): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a1 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst destinationPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...destination,\n\t\t\t\t};\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterAttach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tattach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tattachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a2 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: source,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t};\n\t\t\t\tconst destinationPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: destination,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, count);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\tbeforeDetach(source: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a3 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a4 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdetach(source: Range, destination: FieldKey): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdetachEdit(source: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a5 /* Must be in a field in order to detach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: source.start,\n\t\t\t\t};\n\t\t\t\tconst destinationPath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: destination,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, source.end - source.start);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\tbeforeReplace(newContent: FieldKey, oldContent: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a6 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst oldContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...oldContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: newContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: oldContent.end - oldContent.start,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\toldContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a7 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst newContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...newContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: newContentSource,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: oldContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: newContent.end - newContent.start,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\tnewContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\treplace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tthis.anchorSet.removeChildren(\n\t\t\t\t\t{\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\tparentField: detachedField,\n\t\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\t},\n\t\t\t\t\tcount,\n\t\t\t\t);\n\t\t\t},\n\t\t\tbeforeDestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tconst range: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: detachedField,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDestroy(range);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcreate(content: Delta.ProtoNodes, destination: FieldKey): void {\n\t\t\t\t// Nothing to do since content can only be created in a new detached field,\n\t\t\t\t// which cannot contain any anchors.\n\t\t\t},\n\t\t\tafterCreate(content: Delta.ProtoNodes, destination: FieldKey): void {\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tconst rangePath: DetachedRangeUpPath = brand({\n\t\t\t\t\t\t\tfield: destination,\n\t\t\t\t\t\t\tstart: 0,\n\t\t\t\t\t\t\tend: content.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tpathVisitor.afterCreate(rangePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(this.parentField !== undefined, 0x3ab /* Must be in a field to enter node */);\n\n\t\t\t\tthis.parent = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tthis.parentField = undefined;\n\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\t// avoid multiple pass side-effects\n\t\t\t\t\tif (!this.pathVisitors.has(p)) {\n\t\t\t\t\t\tconst visitors: (PathVisitor | void)[] = p.events.emitAndCollect(\n\t\t\t\t\t\t\t\"subtreeChanging\",\n\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (visitors.length > 0) {\n\t\t\t\t\t\t\tthis.pathVisitors.set(\n\t\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t\t\tnew Set(visitors.filter((v): v is PathVisitor => v !== undefined)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis.currentDepth++;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(this.parent !== undefined, 0x3ac /* Must have parent node */);\n\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\tp.events.emit(\"subtreeChanged\", p);\n\t\t\t\t\tif (this.depthThresholdForSubtreeChanged === this.currentDepth) {\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"subtreeChangedAfterBatch\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.depthThresholdForSubtreeChanged--;\n\t\t\t\t\t}\n\t\t\t\t\t// Remove subtree path visitors added at this node if there are any\n\t\t\t\t\tthis.pathVisitors.delete(p);\n\t\t\t\t});\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tthis.parentField = parent.parentField;\n\t\t\t\tthis.parent = parent.parent;\n\t\t\t\tthis.currentDepth--;\n\t\t\t},\n\t\t\tenterField(key: FieldKey): void {\n\t\t\t\tthis.parentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tthis.parentField = undefined;\n\t\t\t},\n\t\t};\n\t\tthis.events.emit(\"treeChanging\", this);\n\t\tthis.activeVisitor = visitor;\n\t\treturn visitor;\n\t}\n}\n\n/**\n * Indicates the status of a `NodePath`.\n */\nenum Status {\n\t/**\n\t * Indicates the `NodePath` is being maintained and corresponds to a valid\n\t * (i.e., not removed) node in the document.\n\t */\n\tAlive,\n\t/**\n\t * Indicates the `NodePath` is not being maintained by the `AnchorSet`.\n\t * The `NodePath` may or may not correspond to a valid node in the document.\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDisposed,\n\t/**\n\t * Indicates the `NodePath` corresponds to a removed node in the document.\n\t * Such `NodePath`s are not maintained by the `AnchorSet` (other than updating\n\t * their status to `Disposed` when appropriate).\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDangling,\n}\n\n/**\n * Tree of anchors.\n *\n * Contains both child and parent pointers, which are kept in sync.\n *\n * Each anchor is equivalent to a path through the tree.\n * This tree structure stores a collection of these paths, but deduplicating the common prefixes of the tree\n * prefix-tree style.\n *\n * These anchors are used instead of just holding onto the node objects in forests for several reasons:\n *\n * - Update policy might be more complex than just tracking a node object in the forest.\n *\n * - Not all forests will have node objects: some may use compressed binary formats with no objects to reference.\n *\n * - Anchors are needed even when not using forests, and for nodes that are outside the currently loaded part of the\n * forest.\n *\n * - Forest in general do not need to support up pointers, but they are needed for anchors.\n *\n * Thus this can be thought of as a sparse copy of the subset of trees which are used as anchors,\n * plus the parent paths for them.\n *\n * ReferenceCountedBase tracks the number of references to this from external sources (`Anchors` via `AnchorSet`.).\n * Kept alive as if any of the follow are true:\n * 1. there are children.\n * 2. refcount is non-zero.\n * 3. events are registered.\n */\nclass PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorNode {\n\tpublic status: Status = Status.Alive;\n\t/**\n\t * Event emitter for this anchor.\n\t */\n\tpublic readonly events = createEmitter<AnchorEvents>(() => this.considerDispose());\n\n\t/**\n\t * PathNode arrays are kept sorted the PathNode's parentIndex for efficient search.\n\t * Users of this field must take care to maintain invariants (correct parent pointers, not empty child arrays etc.)\n\t *\n\t * Performance Note:\n\t * Large child lists could be updated more efficiently here using a data-structure optimized\n\t * for efficient prefix sum updates, such as a Fenwick tree or Finger tree.\n\t * This would be complicated by the need for parent pointers (including indexes),\n\t * but is possible to do.\n\t */\n\tpublic readonly children: Map<FieldKey, PathNode[]> = new Map();\n\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic readonly slots: BrandedMapSubset<AnchorSlot<any>> = new Map();\n\n\t/**\n\t * Construct a PathNode with refcount 1.\n\t * @param anchorSet - used to determine if this PathNode is already part of a specific anchorSet\n\t * to early out UpPath walking.\n\t */\n\tpublic constructor(\n\t\tpublic readonly anchorSet: AnchorSet,\n\t\tpublic parentField: FieldKey,\n\t\tpublic parentIndex: number,\n\t\t/**\n\t\t * The parent of this `PathNode` (an up pointer in the `PathNode` tree).\n\t\t * If the status of this node is `Alive`, then there must be a corresponding down pointer from the\n\t\t * `parentPath` node to this node.\n\t\t * When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.\n\t\t *\n\t\t * When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent\n\t\t * (updating down pointers first), but must ensure they are consistent before the editing operation returns\n\t\t * to non-`AnchorSet` code.\n\t\t * This consistency guarantee only applies to nodes that are `Alive`.\n\t\t */\n\t\tpublic parentPath: PathNode | undefined,\n\t) {\n\t\tsuper(1);\n\t}\n\n\tpublic on<K extends keyof AnchorEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\n\t}\n\n\tpublic child(key: FieldKey, index: number): UpPath<AnchorNode> {\n\t\t// Fast path: if child exists, return it.\n\t\treturn (\n\t\t\tthis.tryGetChild(key, index) ?? { parent: this, parentField: key, parentIndex: index }\n\t\t);\n\t}\n\n\tpublic getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode] {\n\t\tconst anchor = this.anchorSet.track(this.child(key, index));\n\t\tconst node =\n\t\t\tthis.anchorSet.locate(anchor) ?? fail(\"cannot reference child that does not exist\");\n\t\treturn [anchor, node];\n\t}\n\n\t/**\n\t * @returns true iff this PathNode is the special root node that sits above all the detached fields.\n\t * In this case, the fields are detached sequences.\n\t * Note that the special root node should never appear in an UpPath\n\t * since UpPaths represent this root as `undefined`.\n\t */\n\tprivate isRoot(): boolean {\n\t\treturn this.parentPath === undefined;\n\t}\n\n\tpublic get parent(): PathNode | undefined {\n\t\tassert(this.status !== Status.Disposed, 0x409 /* PathNode must not be disposed */);\n\t\tassert(\n\t\t\tthis.parentPath !== undefined,\n\t\t\t0x355 /* PathNode.parent is an UpPath API and thus should never be called on the root PathNode. */,\n\t\t);\n\t\t// Root PathNode corresponds to the undefined root for UpPath API.\n\t\tif (this.parentPath.isRoot()) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.parentPath;\n\t}\n\n\tpublic addRef(count = 1): void {\n\t\tassert(this.status === Status.Alive, 0x40a /* PathNode must be alive */);\n\t\tthis.referenceAdded(count);\n\t}\n\n\tpublic removeRef(count = 1): void {\n\t\tassert(this.status !== Status.Disposed, 0x40b /* PathNode must not be disposed */);\n\t\tthis.referenceRemoved(count);\n\t}\n\n\t// Called when refcount is set to 0.\n\t// Node may be kept alive by children or events after this point.\n\tprotected onUnreferenced(): void {\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * Gets a child, adding a ref to it.\n\t * Creates child (with 1 ref) if needed.\n\t */\n\tpublic getOrCreateChild(key: FieldKey, index: number): PathNode {\n\t\tassert(this.status === Status.Alive, 0x40c /* PathNode must be alive */);\n\t\tlet field = this.children.get(key);\n\t\tif (field === undefined) {\n\t\t\tfield = [];\n\t\t\tthis.children.set(key, field);\n\t\t}\n\t\t// TODO: should do more optimized search (ex: binary search).\n\t\tlet child = field.find((c) => c.parentIndex === index);\n\t\tif (child === undefined) {\n\t\t\tchild = new PathNode(this.anchorSet, key, index, this);\n\t\t\tfield.push(child);\n\t\t\t// Keep list sorted by index.\n\t\t\tfield.sort((a, b) => a.parentIndex - b.parentIndex);\n\t\t} else {\n\t\t\tchild.addRef();\n\t\t}\n\t\treturn child;\n\t}\n\n\t/**\n\t * Gets a child if it exists.\n\t * Does NOT add a ref.\n\t */\n\tpublic tryGetChild(key: FieldKey, index: number): PathNode | undefined {\n\t\tassert(this.status === Status.Alive, 0x40d /* PathNode must be alive */);\n\t\tconst field = this.children.get(key);\n\n\t\t// TODO: should do more optimized search (ex: binary search or better) using index.\n\t\treturn field?.find((c) => c.parentIndex === index);\n\t}\n\n\t/**\n\t * Removes reference from this to `child`.\n\t * Since PathNodes are doubly linked,\n\t * the caller must ensure that the reference from child to parent is also removed (or the child is no longer used).\n\t */\n\tpublic removeChild(child: PathNode): void {\n\t\tassert(this.status === Status.Alive, 0x40e /* PathNode must be alive */);\n\t\tconst key = child.parentField;\n\t\tconst field = this.children.get(key);\n\t\t// TODO: should do more optimized search (ex: binary search or better) using child.parentIndex()\n\t\t// Note that this is the index in the list of child paths, not the index within the field\n\t\tconst childIndex = field?.indexOf(child) ?? -1;\n\t\tassert(childIndex !== -1, 0x35c /* child must be parented to be removed */);\n\t\tfield?.splice(childIndex, 1);\n\t\tif (field?.length === 0) {\n\t\t\tthis.afterEmptyField(key);\n\t\t}\n\t}\n\n\t/**\n\t * Call this after directly editing the child array for a field to be empty.\n\t * Handles cleaning up unneeded data\n\t * (like the field in the map, and possibly this entire PathNode and its parents if they are no longer needed.)\n\t */\n\tpublic afterEmptyField(key: FieldKey): void {\n\t\tassert(this.status === Status.Alive, 0x40f /* PathNode must be alive */);\n\t\tthis.children.delete(key);\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * If node is no longer needed (has no references, no children and no events):\n\t * removes this from parent if alive, and sets this to disposed.\n\t * Must only be called when .\n\t *\n\t * Allowed when dangling (but not when disposed).\n\t */\n\tprivate considerDispose(): void {\n\t\tassert(this.status !== Status.Disposed, 0x41d /* PathNode must not be disposed */);\n\t\tif (this.isUnreferenced() && this.children.size === 0 && !this.events.hasListeners()) {\n\t\t\tif (this.status === Status.Alive) {\n\t\t\t\tthis.parentPath?.removeChild(this);\n\t\t\t}\n\t\t\tthis.status = Status.Disposed;\n\t\t}\n\t}\n}\n"]}
@@ -9,7 +9,6 @@ import type { TreeType, Value } from "./types.js";
9
9
  * A symbol for marking an object as an {@link ITreeCursor}.
10
10
  *
11
11
  * Useful when APIs want to take in tree data in multiple formats, including cursors.
12
- * @internal
13
12
  */
14
13
  export declare const CursorMarker: unique symbol;
15
14
  /**
@@ -20,8 +19,7 @@ export declare const CursorMarker: unique symbol;
20
19
  export declare function isCursor(data: unknown): data is ITreeCursor;
21
20
  /**
22
21
  * A stateful low-level interface for reading tree data.
23
- * @internal
24
- *
22
+ * *
25
23
  * @remarks Cursor exists so that specialized data formats can be viewed through
26
24
  * a common abstraction. This allows performance optimizations to be done based
27
25
  * on data.
@@ -242,7 +240,6 @@ export interface ITreeCursor {
242
240
  * For example, if a node is being inserted in the 5th position in a field "Foo", you can update a path in that node's subtree to its new path by prefixing it with
243
241
  * `{ parent: theNodeAboveTheMovedNode, rootFieldOverride: Foo, indexOffset: 5 }`.
244
242
  * See {@link prefixPath} and {@link prefixFieldPath} for how to apply the prefix to the paths.
245
- * @internal
246
243
  */
247
244
  export interface PathRootPrefix {
248
245
  /**
@@ -264,7 +261,6 @@ export interface PathRootPrefix {
264
261
  indexOffset?: number;
265
262
  }
266
263
  /**
267
- * @internal
268
264
  */
269
265
  export declare const enum CursorLocationType {
270
266
  /**
@@ -280,7 +276,6 @@ export declare const enum CursorLocationType {
280
276
  }
281
277
  /**
282
278
  * {@link ITreeCursor} that is never pending.
283
- * @internal
284
279
  */
285
280
  export interface ITreeCursorSynchronous extends ITreeCursor {
286
281
  readonly pending: false;
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../../src/core/tree/cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACz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C,MAAM,EAAE,OAAO,KAAK,CAAC,GACvB,CAAC,CAKH"}
@@ -10,7 +10,6 @@ const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  * A symbol for marking an object as an {@link ITreeCursor}.
11
11
  *
12
12
  * Useful when APIs want to take in tree data in multiple formats, including cursors.
13
- * @internal
14
13
  */
15
14
  exports.CursorMarker = Symbol("CursorMarker");
16
15
  /**
@@ -27,7 +26,6 @@ function isCursor(data) {
27
26
  }
28
27
  exports.isCursor = isCursor;
29
28
  /**
30
- * @internal
31
29
  */
32
30
  var CursorLocationType;
33
31
  (function (CursorLocationType) {
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../src/core/tree/cursor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAO7D;;;;;GAKG;AACU,QAAA,YAAY,GAAkB,MAAM,CAAC,cAAc,CAAC,CAAC;AAElE;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAa;IACrC,sFAAsF;IACtF,6FAA6F;IAC7F,OAAO,CACN,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,QAAQ;QACvB,IAA6B,CAAC,oBAAY,CAAC,KAAK,IAAI,CACrD,CAAC;AACH,CAAC;AARD,4BAQC;AA4RD;;GAEG;AACH,IAAkB,kBAYjB;AAZD,WAAkB,kBAAkB;IACnC;;;OAGG;IACH,6DAAK,CAAA;IAEL;;;OAGG;IACH,+DAAM,CAAA;AACP,CAAC,EAZiB,kBAAkB,kCAAlB,kBAAkB,QAYnC;AAUD;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC9B,MAAe,EACf,CAAyB;IAEzB,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;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E,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC7E,CAAC,CAAC,MAAM,CAAC,CAAC;IACX,CAAC;AACF,CAAC;AARD,kCAQC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CACnC,MAAe,EACf,CAA4B;IAE5B,IAAI,MAAM,CAAC,IAAI,qCAA6B,EAAE,CAAC;QAC9C,CAAC,CAAC,MAAM,CAAC,CAAC;QACV,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;AACF,CAAC;AAVD,oDAUC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,MAAmB;IAC1D,OAAO,MAAgC,CAAC;AACzC,CAAC;AAFD,0DAEC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,MAAe,EACf,KAAe,EACf,CAAyB;IAEzB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,SAAS,EAAE,CAAC;IACnB,OAAO,MAAM,CAAC;AACf,CAAC;AATD,sCASC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAC3B,MAAe,EACf,KAAa,EACb,CAAyB;IAEzB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AACf,CAAC;AATD,oCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { FieldUpPath, UpPath } from \"./pathTree.js\";\nimport type { TreeType, Value } from \"./types.js\";\n\n/**\n * A symbol for marking an object as an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n * @internal\n */\nexport const CursorMarker: unique symbol = Symbol(\"CursorMarker\");\n\n/**\n * Check if something is an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport function isCursor(data: unknown): data is ITreeCursor {\n\t// Other than on null and undefined, looking up a missing symbol shouldn't type error.\n\t// typeof check deals with undefined while providing an early out for other non-object types.\n\treturn (\n\t\tdata !== null &&\n\t\ttypeof data === \"object\" &&\n\t\t(data as Partial<ITreeCursor>)[CursorMarker] === true\n\t);\n}\n\n/**\n * A stateful low-level interface for reading tree data.\n * @internal\n *\n * @remarks Cursor exists so that specialized data formats can be viewed through\n * a common abstraction. This allows performance optimizations to be done based\n * on data.\n *\n * A tree cursor is similar to a database cursor in that it allows for the efficient\n * traversal over the contents of a tree. Note that unlike a database cursor,\n * tree cursors may be invalidated after any edit to the tree. For a cursor-like\n * structure that also remains valid across edits, see {@link AnchorNode}.\n */\nexport interface ITreeCursor {\n\t/**\n\t * Marks this object as a cursor.\n\t */\n\treadonly [CursorMarker]: true;\n\n\t/**\n\t * What kind of place the cursor is at.\n\t * Determines which operations are allowed.\n\t *\n\t * @remarks\n\t * Users of cursors frequently need to refer to places in trees, both fields and nodes.\n\t * Approaches other than having the cursor have separate modes for these\n\t * cases had issues even worse than having the two modes.\n\t *\n\t * For example, modeling fields as parent + key has issues when there is no\n\t * parent, and doesn't provide a great way to do iteration over fields while\n\t * also having a nice API and making it easy for the implementation to track\n\t * state (like its current location inside a sequence tree of fields) while\n\t * traversing without having to allocate some state management for that.\n\t *\n\t * Another approach, of using arrays of cursors for fields (like we currently\n\t * do for inserting content) is very inefficient and better addressed by a\n\t * dual mode cursor.\n\t *\n\t * Another approach, of using the first node in a field when referring to\n\t * the field gets confusing since it's unclear if a given cursor means that\n\t * node, or that node, and the ones after it, and in the second case, it's\n\t * hard to restore the cursor back to the right state when returning. It also\n\t * doesn't work for empty fields. Overall there just didn't seem to be a way\n\t * that sucked less than the dual mode API.\n\t */\n\treadonly mode: CursorLocationType;\n\n\t/*\n\t * True iff the current field or node (depending on mode) is \"pending\",\n\t * meaning that it has not been downloaded.\n\t */\n\treadonly pending: boolean;\n\n\t// ********** APIs for when mode = Fields ********** //\n\n\t/**\n\t * Moves the \"current field\" forward one in an arbitrary field traversal order,\n\t * skipping any empty fields.\n\t *\n\t * If there is no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * If skipPending, skip past fields which are currently pending.\n\t * This can be used to skip to the end of a large number of consecutive pending fields.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tnextField(): boolean;\n\n\t/**\n\t * Navigate up to parent node.\n\t * Sets mode to `Nodes`\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * TODO: what to do if at root?\n\t */\n\texitField(): void;\n\n\t/**\n\t * Moves the \"current field\" forward until `pending` is `false`.\n\t *\n\t * If there are no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tskipPendingFields(): boolean;\n\n\t// ********** APIs for when mode = Fields, and not pending ********** //\n\n\t/**\n\t * Returns the FieldKey for the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldKey(): FieldKey;\n\n\t/**\n\t * @returns the number of immediate children in the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldLength(): number;\n\n\t/**\n\t * Moves to the first node of the selected field, setting mode to `Nodes`.\n\t *\n\t * If field is empty, returns false instead.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tfirstNode(): boolean;\n\n\t/**\n\t * Sets current node to the node at the provided `index` of the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t * Sets mode to `Nodes`.\n\t */\n\tenterNode(childIndex: number): void;\n\n\t/**\n\t * Returns a path to the current field. See {@link FieldUpPath}.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link FieldUpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current field.\n\t */\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath;\n\n\t// ********** APIs for when mode = Nodes ********** //\n\n\t/**\n\t * Returns a path to the current node. See {@link UpPath}.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link UpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current node.\n\t */\n\tgetPath(prefix?: PathRootPrefix): UpPath | undefined;\n\n\t/**\n\t * Index (within its parent field) of the current node.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly fieldIndex: number;\n\n\t/**\n\t * Index (within its parent field) of the first node in the current chunk.\n\t * Always less than or equal to `currentIndexInField`.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkStart: number;\n\n\t/**\n\t * Length of current chunk.\n\t * Since an entire chunk always has the same `pending` value,\n\t * can be used to help skip over all of a pending chunk at once.\n\t *\n\t * TODO:\n\t * Add optional APIs to access underlying chunks so readers can\n\t * accelerate processing of chunk formats they understand.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkLength: number;\n\n\t/**\n\t * Moves `offset` nodes in the field.\n\t * If seeking to exactly past either end,\n\t * returns false and navigates up to the parent field (setting mode to `Fields`).\n\t *\n\t * Allowed if mode is `Nodes`.\n\t */\n\tseekNodes(offset: number): boolean;\n\n\t/**\n\t * The same as `seekNodes(1)`, but might be faster.\n\t */\n\tnextNode(): boolean;\n\n\t/**\n\t * Navigate up to parent field.\n\t * Sets mode to `Fields`\n\t *\n\t * Same as seek Number.POSITIVE_INFINITY, but only valid when `mode` is `Nodes`.\n\t *\n\t * TODO: what to do if at root?\n\t * TODO: Maybe merge with upToNode to make a single \"Up\"?\n\t */\n\texitNode(): void;\n\n\t// ********** APIs for when mode = Nodes and not pending ********** //\n\n\t/**\n\t * Enters the first non-empty field (setting mode to `Fields`)\n\t * so fields can be iterated with `nextField` and `skipPendingFields`.\n\t *\n\t * If there are no fields, mode is returned to `Nodes` and false is returned.\n\t *\n\t * Allowed when `mode` is `Nodes` and not `pending`.\n\t */\n\tfirstField(): boolean;\n\n\t/**\n\t * Navigate to the field with the specified `key` and set the mode to `Fields`.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * The type of the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly type: TreeType;\n\n\t/**\n\t * The value associated with the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly value: Value;\n}\n\n/**\n * Prefix to apply as the root of a {@link UpPath} or {@link FieldUpPath}.\n *\n * @remarks This can be used to take a path relative to a subtree, and make it relative to a larger containing tree.\n * For example, if a node is being inserted in the 5th position in a field \"Foo\", you can update a path in that node's subtree to its new path by prefixing it with\n * `{ parent: theNodeAboveTheMovedNode, rootFieldOverride: Foo, indexOffset: 5 }`.\n * See {@link prefixPath} and {@link prefixFieldPath} for how to apply the prefix to the paths.\n * @internal\n */\nexport interface PathRootPrefix {\n\t/**\n\t * The new parent to place above root of the path which is being prefixed.\n\t * This replaces the `undefined` at the root of the path.\n\t *\n\t * @remarks specifying `undefined` here results in no change to the path.\n\t */\n\tparent?: UpPath | undefined;\n\n\t/**\n\t * The field of `parent` that the original path will be included under.\n\t *\n\t * If `undefined` the root field key from the original path will be used.\n\t */\n\trootFieldOverride?: FieldKey;\n\n\t/**\n\t * Offset to add to the uppermost `parentIndex` in the original path.\n\t */\n\tindexOffset?: number;\n}\n\n/**\n * @internal\n */\nexport const enum CursorLocationType {\n\t/**\n\t * Can iterate through nodes in a field.\n\t * At a \"current node\".\n\t */\n\tNodes,\n\n\t/**\n\t * Can iterate through fields of a node.\n\t * At a \"current field\".\n\t */\n\tFields,\n}\n\n/**\n * {@link ITreeCursor} that is never pending.\n * @internal\n */\nexport interface ITreeCursorSynchronous extends ITreeCursor {\n\treadonly pending: false;\n}\n\n/**\n * @param cursor - tree whose fields will be visited.\n * @param f - builds output from field, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each field of the current node on `cursor`.\n * Returns an empty array if the node is empty or not present (which are considered the same).\n * Note that order is not specified for field iteration.\n */\nexport function mapCursorFields<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachField(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * @param cursor - cursor at a node whose fields will be visited.\n * @param f - For on each field.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachField<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x411 /* should be in nodes */);\n\tfor (let inField = cursor.firstField(); inField; inField = cursor.nextField()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * @param cursor - tree whose field will be visited.\n * @param f - builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each item of the current field on `cursor`.\n * Returns an empty array if the field is empty or not present (which are considered the same).\n */\nexport function mapCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachNode(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * @param cursor - The tree whose field will be visited.\n * @param f - Builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns An iterable of `T` resulting from applying `f` to each item of the current field on `cursor`.\n * Yields nothing if an empty array if the field is empty or not present (which are considered the same).\n */\nexport function* iterateCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): IterableIterator<T> {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x7a8 /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tyield f(cursor);\n\t}\n}\n\n/**\n * @param cursor - cursor at a field whose nodes will be visited.\n * @param f - For on each node.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachNode<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x3bd /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * @param cursor - cursor at a field or node.\n * @param f - Function to invoke for each node.\n * If `f` moves the cursor, it must put it back to where it was at the beginning of `f` before returning.\n *\n * Invokes `f` on each node in the subtree rooted at the current field or node.\n * Traversal is pre-order.\n * If the cursor is at a node, `f` will be invoked on that node.\n *\n * Returns the `cursor` to its initial position.\n */\nexport function forEachNodeInSubtree<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tif (cursor.mode === CursorLocationType.Nodes) {\n\t\tf(cursor);\n\t\tforEachField(cursor, (c) => forEachNodeInSubtree(c, f));\n\t} else {\n\t\tforEachNode(cursor, (c) => forEachNodeInSubtree(c, f));\n\t}\n}\n\n/**\n * Casts a cursor to an {@link ITreeCursorSynchronous}.\n *\n * TODO: #1404: Handle this properly for partial data loading support.\n */\nexport function castCursorToSynchronous(cursor: ITreeCursor): ITreeCursorSynchronous {\n\treturn cursor as ITreeCursorSynchronous;\n}\n\n/**\n * Runs `f` inside of field `field` on `cursor`.\n * @param cursor - Cursor whose field to enter and exit. Must be in `nodes` mode.\n * @param field - Field to enter.\n * @param f - Callback to run when in field.\n * @returns return value of `f`\n */\nexport function inCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tfield: FieldKey,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterField(field);\n\tconst result = f(cursor);\n\tcursor.exitField();\n\treturn result;\n}\n\n/**\n * Runs `f` inside of node `index` on `cursor`.\n * @param cursor - Cursor whoso node to enter and exit. Must be in `fields` mode.\n * @param index - Node to enter.\n * @param f - Callback to run when in node.\n * @returns return value of `f`\n */\nexport function inCursorNode<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tindex: number,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterNode(index);\n\tconst result = f(cursor);\n\tcursor.exitNode();\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../src/core/tree/cursor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAO7D;;;;GAIG;AACU,QAAA,YAAY,GAAkB,MAAM,CAAC,cAAc,CAAC,CAAC;AAElE;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAa;IACrC,sFAAsF;IACtF,6FAA6F;IAC7F,OAAO,CACN,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,QAAQ;QACvB,IAA6B,CAAC,oBAAY,CAAC,KAAK,IAAI,CACrD,CAAC;AACH,CAAC;AARD,4BAQC;AA0RD;GACG;AACH,IAAkB,kBAYjB;AAZD,WAAkB,kBAAkB;IACnC;;;OAGG;IACH,6DAAK,CAAA;IAEL;;;OAGG;IACH,+DAAM,CAAA;AACP,CAAC,EAZiB,kBAAkB,kCAAlB,kBAAkB,QAYnC;AASD;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC9B,MAAe,EACf,CAAyB;IAEzB,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC;AATD,0CASC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAC3B,MAAe,EACf,CAA4B;IAE5B,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACjF,KAAK,IAAI,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;QAC/E,CAAC,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E,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;AACF,CAAC;AAVD,oDAUC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,MAAmB;IAC1D,OAAO,MAAgC,CAAC;AACzC,CAAC;AAFD,0DAEC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAC5B,MAAe,EACf,KAAe,EACf,CAAyB;IAEzB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,SAAS,EAAE,CAAC;IACnB,OAAO,MAAM,CAAC;AACf,CAAC;AATD,sCASC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAC3B,MAAe,EACf,KAAa,EACb,CAAyB;IAEzB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AACf,CAAC;AATD,oCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { FieldUpPath, UpPath } from \"./pathTree.js\";\nimport type { TreeType, Value } from \"./types.js\";\n\n/**\n * A symbol for marking an object as an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport const CursorMarker: unique symbol = Symbol(\"CursorMarker\");\n\n/**\n * Check if something is an {@link ITreeCursor}.\n *\n * Useful when APIs want to take in tree data in multiple formats, including cursors.\n */\nexport function isCursor(data: unknown): data is ITreeCursor {\n\t// Other than on null and undefined, looking up a missing symbol shouldn't type error.\n\t// typeof check deals with undefined while providing an early out for other non-object types.\n\treturn (\n\t\tdata !== null &&\n\t\ttypeof data === \"object\" &&\n\t\t(data as Partial<ITreeCursor>)[CursorMarker] === true\n\t);\n}\n\n/**\n * A stateful low-level interface for reading tree data.\n * *\n * @remarks Cursor exists so that specialized data formats can be viewed through\n * a common abstraction. This allows performance optimizations to be done based\n * on data.\n *\n * A tree cursor is similar to a database cursor in that it allows for the efficient\n * traversal over the contents of a tree. Note that unlike a database cursor,\n * tree cursors may be invalidated after any edit to the tree. For a cursor-like\n * structure that also remains valid across edits, see {@link AnchorNode}.\n */\nexport interface ITreeCursor {\n\t/**\n\t * Marks this object as a cursor.\n\t */\n\treadonly [CursorMarker]: true;\n\n\t/**\n\t * What kind of place the cursor is at.\n\t * Determines which operations are allowed.\n\t *\n\t * @remarks\n\t * Users of cursors frequently need to refer to places in trees, both fields and nodes.\n\t * Approaches other than having the cursor have separate modes for these\n\t * cases had issues even worse than having the two modes.\n\t *\n\t * For example, modeling fields as parent + key has issues when there is no\n\t * parent, and doesn't provide a great way to do iteration over fields while\n\t * also having a nice API and making it easy for the implementation to track\n\t * state (like its current location inside a sequence tree of fields) while\n\t * traversing without having to allocate some state management for that.\n\t *\n\t * Another approach, of using arrays of cursors for fields (like we currently\n\t * do for inserting content) is very inefficient and better addressed by a\n\t * dual mode cursor.\n\t *\n\t * Another approach, of using the first node in a field when referring to\n\t * the field gets confusing since it's unclear if a given cursor means that\n\t * node, or that node, and the ones after it, and in the second case, it's\n\t * hard to restore the cursor back to the right state when returning. It also\n\t * doesn't work for empty fields. Overall there just didn't seem to be a way\n\t * that sucked less than the dual mode API.\n\t */\n\treadonly mode: CursorLocationType;\n\n\t/*\n\t * True iff the current field or node (depending on mode) is \"pending\",\n\t * meaning that it has not been downloaded.\n\t */\n\treadonly pending: boolean;\n\n\t// ********** APIs for when mode = Fields ********** //\n\n\t/**\n\t * Moves the \"current field\" forward one in an arbitrary field traversal order,\n\t * skipping any empty fields.\n\t *\n\t * If there is no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * If skipPending, skip past fields which are currently pending.\n\t * This can be used to skip to the end of a large number of consecutive pending fields.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tnextField(): boolean;\n\n\t/**\n\t * Navigate up to parent node.\n\t * Sets mode to `Nodes`\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * TODO: what to do if at root?\n\t */\n\texitField(): void;\n\n\t/**\n\t * Moves the \"current field\" forward until `pending` is `false`.\n\t *\n\t * If there are no remaining field to iterate to,\n\t * returns false and navigates up to the parent setting the mode to `Nodes`.\n\t *\n\t * Order of fields is only guaranteed to be consistent through a single iteration.\n\t *\n\t * Allowed when `mode` is `Fields`.\n\t */\n\tskipPendingFields(): boolean;\n\n\t// ********** APIs for when mode = Fields, and not pending ********** //\n\n\t/**\n\t * Returns the FieldKey for the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldKey(): FieldKey;\n\n\t/**\n\t * @returns the number of immediate children in the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tgetFieldLength(): number;\n\n\t/**\n\t * Moves to the first node of the selected field, setting mode to `Nodes`.\n\t *\n\t * If field is empty, returns false instead.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t */\n\tfirstNode(): boolean;\n\n\t/**\n\t * Sets current node to the node at the provided `index` of the current field.\n\t *\n\t * Allowed when `mode` is `Fields`, and not `pending`.\n\t * Sets mode to `Nodes`.\n\t */\n\tenterNode(childIndex: number): void;\n\n\t/**\n\t * Returns a path to the current field. See {@link FieldUpPath}.\n\t *\n\t * Only valid when `mode` is `Fields`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link FieldUpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current field.\n\t */\n\tgetFieldPath(prefix?: PathRootPrefix): FieldUpPath;\n\n\t// ********** APIs for when mode = Nodes ********** //\n\n\t/**\n\t * Returns a path to the current node. See {@link UpPath}.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t *\n\t * If no prefix is provided, assumes this cursor is treated as if it has a root node where its field keys are actually detached sequences.\n\t * If the cursor is not rooted at such a node, the `prefix` should be used to ensure the path has the correct root.\n\t * This requirement exists because {@link UpPath}s are absolute paths\n\t * and thus must be rooted in a detached sequence.\n\t *\n\t * @param prefix - optional overrides to apply to the root of the returned path.\n\t * See {@link PathRootPrefix}.\n\t * This adjusts the path as if the tree data accessible to this cursor is part of a larger tree.\n\t *\n\t * @returns a path to the current node.\n\t */\n\tgetPath(prefix?: PathRootPrefix): UpPath | undefined;\n\n\t/**\n\t * Index (within its parent field) of the current node.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly fieldIndex: number;\n\n\t/**\n\t * Index (within its parent field) of the first node in the current chunk.\n\t * Always less than or equal to `currentIndexInField`.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkStart: number;\n\n\t/**\n\t * Length of current chunk.\n\t * Since an entire chunk always has the same `pending` value,\n\t * can be used to help skip over all of a pending chunk at once.\n\t *\n\t * TODO:\n\t * Add optional APIs to access underlying chunks so readers can\n\t * accelerate processing of chunk formats they understand.\n\t *\n\t * Only valid when `mode` is `Nodes`.\n\t */\n\treadonly chunkLength: number;\n\n\t/**\n\t * Moves `offset` nodes in the field.\n\t * If seeking to exactly past either end,\n\t * returns false and navigates up to the parent field (setting mode to `Fields`).\n\t *\n\t * Allowed if mode is `Nodes`.\n\t */\n\tseekNodes(offset: number): boolean;\n\n\t/**\n\t * The same as `seekNodes(1)`, but might be faster.\n\t */\n\tnextNode(): boolean;\n\n\t/**\n\t * Navigate up to parent field.\n\t * Sets mode to `Fields`\n\t *\n\t * Same as seek Number.POSITIVE_INFINITY, but only valid when `mode` is `Nodes`.\n\t *\n\t * TODO: what to do if at root?\n\t * TODO: Maybe merge with upToNode to make a single \"Up\"?\n\t */\n\texitNode(): void;\n\n\t// ********** APIs for when mode = Nodes and not pending ********** //\n\n\t/**\n\t * Enters the first non-empty field (setting mode to `Fields`)\n\t * so fields can be iterated with `nextField` and `skipPendingFields`.\n\t *\n\t * If there are no fields, mode is returned to `Nodes` and false is returned.\n\t *\n\t * Allowed when `mode` is `Nodes` and not `pending`.\n\t */\n\tfirstField(): boolean;\n\n\t/**\n\t * Navigate to the field with the specified `key` and set the mode to `Fields`.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\tenterField(key: FieldKey): void;\n\n\t/**\n\t * The type of the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly type: TreeType;\n\n\t/**\n\t * The value associated with the currently selected node.\n\t *\n\t * Only valid when `mode` is `Nodes`, and not `pending`.\n\t */\n\treadonly value: Value;\n}\n\n/**\n * Prefix to apply as the root of a {@link UpPath} or {@link FieldUpPath}.\n *\n * @remarks This can be used to take a path relative to a subtree, and make it relative to a larger containing tree.\n * For example, if a node is being inserted in the 5th position in a field \"Foo\", you can update a path in that node's subtree to its new path by prefixing it with\n * `{ parent: theNodeAboveTheMovedNode, rootFieldOverride: Foo, indexOffset: 5 }`.\n * See {@link prefixPath} and {@link prefixFieldPath} for how to apply the prefix to the paths.\n */\nexport interface PathRootPrefix {\n\t/**\n\t * The new parent to place above root of the path which is being prefixed.\n\t * This replaces the `undefined` at the root of the path.\n\t *\n\t * @remarks specifying `undefined` here results in no change to the path.\n\t */\n\tparent?: UpPath | undefined;\n\n\t/**\n\t * The field of `parent` that the original path will be included under.\n\t *\n\t * If `undefined` the root field key from the original path will be used.\n\t */\n\trootFieldOverride?: FieldKey;\n\n\t/**\n\t * Offset to add to the uppermost `parentIndex` in the original path.\n\t */\n\tindexOffset?: number;\n}\n\n/**\n */\nexport const enum CursorLocationType {\n\t/**\n\t * Can iterate through nodes in a field.\n\t * At a \"current node\".\n\t */\n\tNodes,\n\n\t/**\n\t * Can iterate through fields of a node.\n\t * At a \"current field\".\n\t */\n\tFields,\n}\n\n/**\n * {@link ITreeCursor} that is never pending.\n */\nexport interface ITreeCursorSynchronous extends ITreeCursor {\n\treadonly pending: false;\n}\n\n/**\n * @param cursor - tree whose fields will be visited.\n * @param f - builds output from field, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each field of the current node on `cursor`.\n * Returns an empty array if the node is empty or not present (which are considered the same).\n * Note that order is not specified for field iteration.\n */\nexport function mapCursorFields<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachField(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * @param cursor - cursor at a node whose fields will be visited.\n * @param f - For on each field.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachField<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x411 /* should be in nodes */);\n\tfor (let inField = cursor.firstField(); inField; inField = cursor.nextField()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * @param cursor - tree whose field will be visited.\n * @param f - builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns array resulting from applying `f` to each item of the current field on `cursor`.\n * Returns an empty array if the field is empty or not present (which are considered the same).\n */\nexport function mapCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): T[] {\n\tconst output: T[] = [];\n\tforEachNode(cursor, (c) => {\n\t\toutput.push(f(c));\n\t});\n\treturn output;\n}\n\n/**\n * @param cursor - The tree whose field will be visited.\n * @param f - Builds output from field member, which will be selected in cursor when cursor is provided.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n * @returns An iterable of `T` resulting from applying `f` to each item of the current field on `cursor`.\n * Yields nothing if an empty array if the field is empty or not present (which are considered the same).\n */\nexport function* iterateCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => T,\n): IterableIterator<T> {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x7a8 /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tyield f(cursor);\n\t}\n}\n\n/**\n * @param cursor - cursor at a field whose nodes will be visited.\n * @param f - For on each node.\n * If `f` moves cursor, it must put it back to where it was at the beginning of `f` before returning.\n */\nexport function forEachNode<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tassert(cursor.mode === CursorLocationType.Fields, 0x3bd /* should be in fields */);\n\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\tf(cursor);\n\t}\n}\n\n/**\n * @param cursor - cursor at a field or node.\n * @param f - Function to invoke for each node.\n * If `f` moves the cursor, it must put it back to where it was at the beginning of `f` before returning.\n *\n * Invokes `f` on each node in the subtree rooted at the current field or node.\n * Traversal is pre-order.\n * If the cursor is at a node, `f` will be invoked on that node.\n *\n * Returns the `cursor` to its initial position.\n */\nexport function forEachNodeInSubtree<TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tf: (cursor: TCursor) => void,\n): void {\n\tif (cursor.mode === CursorLocationType.Nodes) {\n\t\tf(cursor);\n\t\tforEachField(cursor, (c) => forEachNodeInSubtree(c, f));\n\t} else {\n\t\tforEachNode(cursor, (c) => forEachNodeInSubtree(c, f));\n\t}\n}\n\n/**\n * Casts a cursor to an {@link ITreeCursorSynchronous}.\n *\n * TODO: #1404: Handle this properly for partial data loading support.\n */\nexport function castCursorToSynchronous(cursor: ITreeCursor): ITreeCursorSynchronous {\n\treturn cursor as ITreeCursorSynchronous;\n}\n\n/**\n * Runs `f` inside of field `field` on `cursor`.\n * @param cursor - Cursor whose field to enter and exit. Must be in `nodes` mode.\n * @param field - Field to enter.\n * @param f - Callback to run when in field.\n * @returns return value of `f`\n */\nexport function inCursorField<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tfield: FieldKey,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterField(field);\n\tconst result = f(cursor);\n\tcursor.exitField();\n\treturn result;\n}\n\n/**\n * Runs `f` inside of node `index` on `cursor`.\n * @param cursor - Cursor whoso node to enter and exit. Must be in `fields` mode.\n * @param index - Node to enter.\n * @param f - Callback to run when in node.\n * @returns return value of `f`\n */\nexport function inCursorNode<T, TCursor extends ITreeCursor = ITreeCursor>(\n\tcursor: TCursor,\n\tindex: number,\n\tf: (cursor: TCursor) => T,\n): T {\n\tcursor.enterNode(index);\n\tconst result = f(cursor);\n\tcursor.exitNode();\n\treturn result;\n}\n"]}
@@ -65,7 +65,6 @@ import type { ITreeCursorSynchronous } from "./cursor.js";
65
65
  /**
66
66
  * Represents the change made to a document.
67
67
  * Immutable, therefore safe to retain for async processing.
68
- * @internal
69
68
  */
70
69
  export interface Root<TTree = ProtoNode> {
71
70
  /**
@@ -103,7 +102,6 @@ export interface Root<TTree = ProtoNode> {
103
102
  * Ownership and lifetime of data referenced by this cursor is unclear,
104
103
  * so it is a poor abstraction for this use-case which needs to hold onto the data in a non-exclusive (readonly) way.
105
104
  * Cursors can be one supported way to input data, but aren't a good storage format.
106
- * @internal
107
105
  */
108
106
  export type ProtoNode = ITreeCursorSynchronous;
109
107
  /**
@@ -114,12 +112,10 @@ export type ProtoNode = ITreeCursorSynchronous;
114
112
  * Additionally, Cursors support sequences, so if using cursors, there are better ways to handle this than an array of cursors,
115
113
  * like using a cursor over all the content (starting in fields mode).
116
114
  * Long term something like TreeChunk should probably be used here.
117
- * @internal
118
115
  */
119
116
  export type ProtoNodes = readonly ProtoNode[];
120
117
  /**
121
118
  * Represents a change being made to a part of the document tree.
122
- * @internal
123
119
  */
124
120
  export interface Mark {
125
121
  /**
@@ -145,19 +141,16 @@ export interface Mark {
145
141
  }
146
142
  /**
147
143
  * A globally unique ID for a node in a detached field.
148
- * @internal
149
144
  */
150
145
  export interface DetachedNodeId {
151
146
  readonly major?: RevisionTag;
152
147
  readonly minor: number;
153
148
  }
154
149
  /**
155
- * @internal
156
150
  */
157
151
  export type FieldMap = ReadonlyMap<FieldKey, FieldChanges>;
158
152
  /**
159
153
  * Represents changes made to a detached node
160
- * @internal
161
154
  */
162
155
  export interface DetachedNodeChanges {
163
156
  readonly id: DetachedNodeId;
@@ -168,7 +161,6 @@ export interface DetachedNodeChanges {
168
161
  *
169
162
  * Tree creation is idempotent: if a tree with the same ID already exists,
170
163
  * then this build is ignored in favor of the existing tree.
171
- * @internal
172
164
  */
173
165
  export interface DetachedNodeBuild<TTree = ProtoNode> {
174
166
  readonly id: DetachedNodeId;
@@ -176,7 +168,6 @@ export interface DetachedNodeBuild<TTree = ProtoNode> {
176
168
  }
177
169
  /**
178
170
  * Represents the destruction of detached nodes
179
- * @internal
180
171
  */
181
172
  export interface DetachedNodeDestruction {
182
173
  readonly id: DetachedNodeId;
@@ -184,7 +175,6 @@ export interface DetachedNodeDestruction {
184
175
  }
185
176
  /**
186
177
  * Represents a detached node being assigned a new `DetachedNodeId`.
187
- * @internal
188
178
  */
189
179
  export interface DetachedNodeRename {
190
180
  readonly count: number;
@@ -193,7 +183,6 @@ export interface DetachedNodeRename {
193
183
  }
194
184
  /**
195
185
  * Represents the changes to perform on a given field.
196
- * @internal
197
186
  */
198
187
  export interface FieldChanges {
199
188
  /**