@fluidframework/tree 2.101.1 → 2.103.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 (609) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-report/tree.alpha.api.md +19 -0
  3. package/dist/codec/codec.d.ts +22 -53
  4. package/dist/codec/codec.d.ts.map +1 -1
  5. package/dist/codec/codec.js +7 -44
  6. package/dist/codec/codec.js.map +1 -1
  7. package/dist/codec/index.d.ts +1 -1
  8. package/dist/codec/index.d.ts.map +1 -1
  9. package/dist/codec/index.js +2 -2
  10. package/dist/codec/index.js.map +1 -1
  11. package/dist/codec/versioned/codec.d.ts +56 -28
  12. package/dist/codec/versioned/codec.d.ts.map +1 -1
  13. package/dist/codec/versioned/codec.js +29 -12
  14. package/dist/codec/versioned/codec.js.map +1 -1
  15. package/dist/codec/versioned/format.d.ts +5 -4
  16. package/dist/codec/versioned/format.d.ts.map +1 -1
  17. package/dist/codec/versioned/format.js +26 -3
  18. package/dist/codec/versioned/format.js.map +1 -1
  19. package/dist/codec/versioned/index.d.ts +1 -1
  20. package/dist/codec/versioned/index.d.ts.map +1 -1
  21. package/dist/codec/versioned/index.js +2 -2
  22. package/dist/codec/versioned/index.js.map +1 -1
  23. package/dist/core/rebase/types.d.ts +4 -3
  24. package/dist/core/rebase/types.d.ts.map +1 -1
  25. package/dist/core/rebase/types.js +27 -4
  26. package/dist/core/rebase/types.js.map +1 -1
  27. package/dist/core/schema-stored/formatV1.d.ts +16 -15
  28. package/dist/core/schema-stored/formatV1.d.ts.map +1 -1
  29. package/dist/core/schema-stored/formatV1.js +31 -8
  30. package/dist/core/schema-stored/formatV1.js.map +1 -1
  31. package/dist/core/schema-stored/formatV2.d.ts +29 -28
  32. package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
  33. package/dist/core/schema-stored/formatV2.js +33 -10
  34. package/dist/core/schema-stored/formatV2.js.map +1 -1
  35. package/dist/core/tree/deltaUtil.d.ts +2 -2
  36. package/dist/core/tree/deltaUtil.js +2 -2
  37. package/dist/core/tree/deltaUtil.js.map +1 -1
  38. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  39. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  40. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  41. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  42. package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -2
  43. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  44. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
  45. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  46. package/dist/core/tree/detachedFieldIndexCodecs.js +1 -1
  47. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  48. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +11 -10
  49. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  50. package/dist/core/tree/detachedFieldIndexFormatCommon.js +33 -10
  51. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  52. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +7 -6
  53. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  54. package/dist/core/tree/detachedFieldIndexFormatV2.js +25 -2
  55. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  56. package/dist/core/tree/persistedTreeTextFormat.d.ts +19 -18
  57. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  58. package/dist/core/tree/persistedTreeTextFormat.js +33 -10
  59. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
  61. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/chunkTree.js +63 -5
  63. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/chunkedForest.js +18 -4
  66. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
  68. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +106 -3
  70. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
  72. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  74. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  75. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
  76. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  77. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +13 -12
  79. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js +36 -13
  81. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +36 -35
  83. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js +41 -18
  85. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +35 -14
  87. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
  88. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +35 -6
  89. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
  90. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +106 -0
  91. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
  92. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js +67 -0
  93. package/dist/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
  94. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
  95. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/codec/format/index.js +5 -1
  97. package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
  99. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
  100. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +7 -1
  101. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
  102. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  103. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  104. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +1 -2
  105. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  106. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +66 -14
  107. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  108. package/dist/feature-libraries/chunked-forest/uniformChunk.js +101 -36
  109. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  110. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  111. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +36 -14
  112. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  113. package/dist/feature-libraries/forest-summary/codec.d.ts +5 -4
  114. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  115. package/dist/feature-libraries/forest-summary/codec.js +2 -2
  116. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  117. package/dist/feature-libraries/forest-summary/formatCommon.d.ts +6 -5
  118. package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  119. package/dist/feature-libraries/forest-summary/formatCommon.js +26 -3
  120. package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  121. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +4 -3
  122. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  123. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js +26 -3
  124. package/dist/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
  125. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +45 -44
  126. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  127. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js +48 -25
  128. package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  129. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +23 -22
  130. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  131. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +29 -6
  132. package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  133. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
  134. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  135. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  136. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +9 -8
  137. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  138. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +31 -8
  139. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
  140. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +14 -13
  141. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  142. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +34 -11
  143. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
  144. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +5 -4
  145. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  146. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js +25 -2
  147. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  148. package/dist/feature-libraries/schema-index/codec.d.ts +2 -2
  149. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  150. package/dist/feature-libraries/schema-index/codec.js +1 -1
  151. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  152. package/dist/feature-libraries/schema-index/formatV1.d.ts +15 -14
  153. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  154. package/dist/feature-libraries/schema-index/formatV1.js +27 -4
  155. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
  156. package/dist/feature-libraries/schema-index/formatV2.d.ts +20 -19
  157. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  158. package/dist/feature-libraries/schema-index/formatV2.js +27 -4
  159. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  160. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  161. package/dist/feature-libraries/sequence-field/compose.js +1 -3
  162. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  163. package/dist/feature-libraries/sequence-field/formatV1.d.ts +283 -282
  164. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  165. package/dist/feature-libraries/sequence-field/formatV1.js +63 -40
  166. package/dist/feature-libraries/sequence-field/formatV1.js.map +1 -1
  167. package/dist/feature-libraries/sequence-field/formatV2.d.ts +180 -179
  168. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  169. package/dist/feature-libraries/sequence-field/formatV2.js +55 -32
  170. package/dist/feature-libraries/sequence-field/formatV2.js.map +1 -1
  171. package/dist/feature-libraries/sequence-field/formatV3.d.ts +126 -125
  172. package/dist/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  173. package/dist/feature-libraries/sequence-field/formatV3.js +27 -4
  174. package/dist/feature-libraries/sequence-field/formatV3.js.map +1 -1
  175. package/dist/index.d.ts +1 -1
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +3 -1
  178. package/dist/index.js.map +1 -1
  179. package/dist/packageVersion.d.ts +1 -1
  180. package/dist/packageVersion.js +1 -1
  181. package/dist/packageVersion.js.map +1 -1
  182. package/dist/shared-tree/isAuditableFromOutcome.d.ts +20 -0
  183. package/dist/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
  184. package/dist/shared-tree/isAuditableFromOutcome.js +36 -0
  185. package/dist/shared-tree/isAuditableFromOutcome.js.map +1 -0
  186. package/dist/shared-tree/sharedTree.d.ts +2 -2
  187. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  188. package/dist/shared-tree/sharedTree.js.map +1 -1
  189. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  190. package/dist/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  191. package/dist/shared-tree/sharedTreeChangeFormat.js +28 -5
  192. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  193. package/dist/shared-tree/treeCheckout.d.ts +5 -3
  194. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  195. package/dist/shared-tree/treeCheckout.js +37 -8
  196. package/dist/shared-tree/treeCheckout.js.map +1 -1
  197. package/dist/shared-tree-core/editManager.d.ts +2 -2
  198. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  199. package/dist/shared-tree-core/editManager.js.map +1 -1
  200. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -3
  201. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  202. package/dist/shared-tree-core/editManagerCodecs.js +2 -2
  203. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  204. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +35 -34
  205. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  206. package/dist/shared-tree-core/editManagerFormatCommons.js +39 -16
  207. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  208. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +15 -15
  209. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  210. package/dist/shared-tree-core/editManagerFormatV1toV4.js +33 -10
  211. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  212. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +40 -40
  213. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  214. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +27 -4
  215. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  216. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  217. package/dist/shared-tree-core/messageCodecVSharedBranches.js +25 -2
  218. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  219. package/dist/shared-tree-core/messageCodecs.d.ts +3 -3
  220. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  221. package/dist/shared-tree-core/messageCodecs.js +2 -2
  222. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  223. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +5 -5
  224. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  225. package/dist/shared-tree-core/messageFormatV1ToV4.js +31 -8
  226. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  227. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -7
  228. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  229. package/dist/shared-tree-core/messageFormatVSharedBranches.js +29 -6
  230. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  231. package/dist/simple-tree/core/treeNodeKernel.d.ts +5 -0
  232. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  233. package/dist/simple-tree/core/treeNodeKernel.js +62 -24
  234. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  235. package/dist/simple-tree/simpleSchemaFormatV1.d.ts +121 -120
  236. package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
  237. package/dist/simple-tree/simpleSchemaFormatV1.js +54 -31
  238. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  239. package/dist/text/codePointUtils.d.ts +48 -0
  240. package/dist/text/codePointUtils.d.ts.map +1 -0
  241. package/dist/text/codePointUtils.js +80 -0
  242. package/dist/text/codePointUtils.js.map +1 -0
  243. package/dist/text/index.d.ts +1 -0
  244. package/dist/text/index.d.ts.map +1 -1
  245. package/dist/text/index.js +4 -1
  246. package/dist/text/index.js.map +1 -1
  247. package/dist/text/textDomain.d.ts +93 -1
  248. package/dist/text/textDomain.d.ts.map +1 -1
  249. package/dist/text/textDomain.js +65 -8
  250. package/dist/text/textDomain.js.map +1 -1
  251. package/dist/text/textDomainFormatted.d.ts +24 -6
  252. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  253. package/dist/text/textDomainFormatted.js +29 -1
  254. package/dist/text/textDomainFormatted.js.map +1 -1
  255. package/dist/treeFactory.d.ts.map +1 -1
  256. package/dist/treeFactory.js +9 -7
  257. package/dist/treeFactory.js.map +1 -1
  258. package/dist/util/breakable.d.ts +7 -1
  259. package/dist/util/breakable.d.ts.map +1 -1
  260. package/dist/util/breakable.js +18 -4
  261. package/dist/util/breakable.js.map +1 -1
  262. package/dist/util/typeboxBrand.d.ts +1 -1
  263. package/dist/util/typeboxBrand.d.ts.map +1 -1
  264. package/dist/util/typeboxBrand.js +26 -3
  265. package/dist/util/typeboxBrand.js.map +1 -1
  266. package/dist/util/utils.d.ts +2 -2
  267. package/dist/util/utils.d.ts.map +1 -1
  268. package/dist/util/utils.js +25 -2
  269. package/dist/util/utils.js.map +1 -1
  270. package/eslint.config.mts +44 -0
  271. package/lib/codec/codec.d.ts +22 -53
  272. package/lib/codec/codec.d.ts.map +1 -1
  273. package/lib/codec/codec.js +7 -44
  274. package/lib/codec/codec.js.map +1 -1
  275. package/lib/codec/index.d.ts +1 -1
  276. package/lib/codec/index.d.ts.map +1 -1
  277. package/lib/codec/index.js +1 -1
  278. package/lib/codec/index.js.map +1 -1
  279. package/lib/codec/versioned/codec.d.ts +56 -28
  280. package/lib/codec/versioned/codec.d.ts.map +1 -1
  281. package/lib/codec/versioned/codec.js +27 -10
  282. package/lib/codec/versioned/codec.js.map +1 -1
  283. package/lib/codec/versioned/format.d.ts +5 -4
  284. package/lib/codec/versioned/format.d.ts.map +1 -1
  285. package/lib/codec/versioned/format.js +1 -1
  286. package/lib/codec/versioned/format.js.map +1 -1
  287. package/lib/codec/versioned/index.d.ts +1 -1
  288. package/lib/codec/versioned/index.d.ts.map +1 -1
  289. package/lib/codec/versioned/index.js +1 -1
  290. package/lib/codec/versioned/index.js.map +1 -1
  291. package/lib/core/rebase/types.d.ts +4 -3
  292. package/lib/core/rebase/types.d.ts.map +1 -1
  293. package/lib/core/rebase/types.js +1 -1
  294. package/lib/core/rebase/types.js.map +1 -1
  295. package/lib/core/schema-stored/formatV1.d.ts +16 -15
  296. package/lib/core/schema-stored/formatV1.d.ts.map +1 -1
  297. package/lib/core/schema-stored/formatV1.js +1 -1
  298. package/lib/core/schema-stored/formatV1.js.map +1 -1
  299. package/lib/core/schema-stored/formatV2.d.ts +29 -28
  300. package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
  301. package/lib/core/schema-stored/formatV2.js +1 -1
  302. package/lib/core/schema-stored/formatV2.js.map +1 -1
  303. package/lib/core/tree/deltaUtil.d.ts +2 -2
  304. package/lib/core/tree/deltaUtil.js +2 -2
  305. package/lib/core/tree/deltaUtil.js.map +1 -1
  306. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  307. package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
  308. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  309. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  310. package/lib/core/tree/detachedFieldIndexCodecV2.js +5 -3
  311. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  312. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +3 -3
  313. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  314. package/lib/core/tree/detachedFieldIndexCodecs.js +2 -2
  315. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  316. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +11 -10
  317. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  318. package/lib/core/tree/detachedFieldIndexFormatCommon.js +1 -1
  319. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  320. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +7 -6
  321. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  322. package/lib/core/tree/detachedFieldIndexFormatV2.js +1 -1
  323. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  324. package/lib/core/tree/persistedTreeTextFormat.d.ts +19 -18
  325. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  326. package/lib/core/tree/persistedTreeTextFormat.js +1 -1
  327. package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
  328. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +38 -1
  329. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  330. package/lib/feature-libraries/chunked-forest/chunkTree.js +62 -5
  331. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  332. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  333. package/lib/feature-libraries/chunked-forest/chunkedForest.js +20 -6
  334. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  335. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +34 -2
  336. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  337. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +102 -2
  338. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  339. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -5
  340. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  341. package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -3
  342. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  343. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +7 -7
  344. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  345. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  346. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +13 -12
  347. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
  348. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js +1 -1
  349. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
  350. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +36 -35
  351. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -1
  352. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js +1 -1
  353. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -1
  354. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +35 -14
  355. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -1
  356. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +9 -3
  357. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -1
  358. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts +106 -0
  359. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.d.ts.map +1 -0
  360. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js +41 -0
  361. package/lib/feature-libraries/chunked-forest/codec/format/formatVText.js.map +1 -0
  362. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +2 -1
  363. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
  364. package/lib/feature-libraries/chunked-forest/codec/format/index.js +2 -1
  365. package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
  366. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +38 -4
  367. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/codec/format/versions.js +6 -0
  369. package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  371. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  372. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +2 -3
  373. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  374. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +66 -14
  375. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  376. package/lib/feature-libraries/chunked-forest/uniformChunk.js +101 -36
  377. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  378. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  379. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +36 -14
  380. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  381. package/lib/feature-libraries/forest-summary/codec.d.ts +5 -4
  382. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  383. package/lib/feature-libraries/forest-summary/codec.js +3 -3
  384. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  385. package/lib/feature-libraries/forest-summary/formatCommon.d.ts +6 -5
  386. package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -1
  387. package/lib/feature-libraries/forest-summary/formatCommon.js +1 -1
  388. package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -1
  389. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts +4 -3
  390. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.d.ts.map +1 -1
  391. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js +1 -1
  392. package/lib/feature-libraries/modular-schema/genericFieldKindFormat.js.map +1 -1
  393. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts +45 -44
  394. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -1
  395. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js +1 -1
  396. package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -1
  397. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +23 -22
  398. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -1
  399. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +1 -1
  400. package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -1
  401. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +1 -1
  402. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  403. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  404. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +9 -8
  405. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  406. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.js +1 -1
  407. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.js.map +1 -1
  408. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +14 -13
  409. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  410. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.js +1 -1
  411. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.js.map +1 -1
  412. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +5 -4
  413. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  414. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +1 -1
  415. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  416. package/lib/feature-libraries/schema-index/codec.d.ts +2 -2
  417. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  418. package/lib/feature-libraries/schema-index/codec.js +2 -2
  419. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  420. package/lib/feature-libraries/schema-index/formatV1.d.ts +15 -14
  421. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  422. package/lib/feature-libraries/schema-index/formatV1.js +1 -1
  423. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
  424. package/lib/feature-libraries/schema-index/formatV2.d.ts +20 -19
  425. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  426. package/lib/feature-libraries/schema-index/formatV2.js +1 -1
  427. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  428. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  429. package/lib/feature-libraries/sequence-field/compose.js +1 -3
  430. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  431. package/lib/feature-libraries/sequence-field/formatV1.d.ts +283 -282
  432. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  433. package/lib/feature-libraries/sequence-field/formatV1.js +1 -1
  434. package/lib/feature-libraries/sequence-field/formatV1.js.map +1 -1
  435. package/lib/feature-libraries/sequence-field/formatV2.d.ts +180 -179
  436. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  437. package/lib/feature-libraries/sequence-field/formatV2.js +1 -1
  438. package/lib/feature-libraries/sequence-field/formatV2.js.map +1 -1
  439. package/lib/feature-libraries/sequence-field/formatV3.d.ts +126 -125
  440. package/lib/feature-libraries/sequence-field/formatV3.d.ts.map +1 -1
  441. package/lib/feature-libraries/sequence-field/formatV3.js +1 -1
  442. package/lib/feature-libraries/sequence-field/formatV3.js.map +1 -1
  443. package/lib/index.d.ts +1 -1
  444. package/lib/index.d.ts.map +1 -1
  445. package/lib/index.js +1 -1
  446. package/lib/index.js.map +1 -1
  447. package/lib/packageVersion.d.ts +1 -1
  448. package/lib/packageVersion.js +1 -1
  449. package/lib/packageVersion.js.map +1 -1
  450. package/lib/shared-tree/isAuditableFromOutcome.d.ts +20 -0
  451. package/lib/shared-tree/isAuditableFromOutcome.d.ts.map +1 -0
  452. package/lib/shared-tree/isAuditableFromOutcome.js +32 -0
  453. package/lib/shared-tree/isAuditableFromOutcome.js.map +1 -0
  454. package/lib/shared-tree/sharedTree.d.ts +2 -2
  455. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  456. package/lib/shared-tree/sharedTree.js +1 -1
  457. package/lib/shared-tree/sharedTree.js.map +1 -1
  458. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  459. package/lib/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  460. package/lib/shared-tree/sharedTreeChangeFormat.js +1 -1
  461. package/lib/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  462. package/lib/shared-tree/treeCheckout.d.ts +5 -3
  463. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  464. package/lib/shared-tree/treeCheckout.js +38 -9
  465. package/lib/shared-tree/treeCheckout.js.map +1 -1
  466. package/lib/shared-tree-core/editManager.d.ts +2 -2
  467. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  468. package/lib/shared-tree-core/editManager.js.map +1 -1
  469. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -3
  470. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  471. package/lib/shared-tree-core/editManagerCodecs.js +3 -3
  472. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  473. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +35 -34
  474. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  475. package/lib/shared-tree-core/editManagerFormatCommons.js +1 -1
  476. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  477. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +15 -15
  478. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  479. package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -1
  480. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  481. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +40 -40
  482. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  483. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +1 -1
  484. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  485. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  486. package/lib/shared-tree-core/messageCodecVSharedBranches.js +1 -1
  487. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  488. package/lib/shared-tree-core/messageCodecs.d.ts +3 -3
  489. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  490. package/lib/shared-tree-core/messageCodecs.js +3 -3
  491. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  492. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +5 -5
  493. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  494. package/lib/shared-tree-core/messageFormatV1ToV4.js +1 -1
  495. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  496. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts +7 -7
  497. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  498. package/lib/shared-tree-core/messageFormatVSharedBranches.js +1 -1
  499. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  500. package/lib/simple-tree/core/treeNodeKernel.d.ts +5 -0
  501. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  502. package/lib/simple-tree/core/treeNodeKernel.js +60 -23
  503. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  504. package/lib/simple-tree/simpleSchemaFormatV1.d.ts +121 -120
  505. package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
  506. package/lib/simple-tree/simpleSchemaFormatV1.js +1 -1
  507. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
  508. package/lib/text/codePointUtils.d.ts +48 -0
  509. package/lib/text/codePointUtils.d.ts.map +1 -0
  510. package/lib/text/codePointUtils.js +75 -0
  511. package/lib/text/codePointUtils.js.map +1 -0
  512. package/lib/text/index.d.ts +1 -0
  513. package/lib/text/index.d.ts.map +1 -1
  514. package/lib/text/index.js +1 -0
  515. package/lib/text/index.js.map +1 -1
  516. package/lib/text/textDomain.d.ts +93 -1
  517. package/lib/text/textDomain.d.ts.map +1 -1
  518. package/lib/text/textDomain.js +56 -0
  519. package/lib/text/textDomain.js.map +1 -1
  520. package/lib/text/textDomainFormatted.d.ts +24 -6
  521. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  522. package/lib/text/textDomainFormatted.js +30 -2
  523. package/lib/text/textDomainFormatted.js.map +1 -1
  524. package/lib/treeFactory.d.ts.map +1 -1
  525. package/lib/treeFactory.js +2 -0
  526. package/lib/treeFactory.js.map +1 -1
  527. package/lib/util/breakable.d.ts +7 -1
  528. package/lib/util/breakable.d.ts.map +1 -1
  529. package/lib/util/breakable.js +18 -4
  530. package/lib/util/breakable.js.map +1 -1
  531. package/lib/util/typeboxBrand.d.ts +1 -1
  532. package/lib/util/typeboxBrand.d.ts.map +1 -1
  533. package/lib/util/typeboxBrand.js +1 -1
  534. package/lib/util/typeboxBrand.js.map +1 -1
  535. package/lib/util/utils.d.ts +2 -2
  536. package/lib/util/utils.d.ts.map +1 -1
  537. package/lib/util/utils.js +1 -1
  538. package/lib/util/utils.js.map +1 -1
  539. package/package.json +24 -24
  540. package/src/codec/codec.ts +82 -73
  541. package/src/codec/index.ts +2 -1
  542. package/src/codec/versioned/codec.ts +173 -73
  543. package/src/codec/versioned/format.ts +2 -1
  544. package/src/codec/versioned/index.ts +2 -1
  545. package/src/core/rebase/types.ts +1 -1
  546. package/src/core/schema-stored/formatV1.ts +2 -1
  547. package/src/core/schema-stored/formatV2.ts +2 -1
  548. package/src/core/tree/deltaUtil.ts +2 -2
  549. package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -2
  550. package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -3
  551. package/src/core/tree/detachedFieldIndexCodecs.ts +2 -2
  552. package/src/core/tree/detachedFieldIndexFormatCommon.ts +2 -1
  553. package/src/core/tree/detachedFieldIndexFormatV2.ts +2 -1
  554. package/src/core/tree/persistedTreeTextFormat.ts +2 -1
  555. package/src/feature-libraries/chunked-forest/chunkTree.ts +88 -3
  556. package/src/feature-libraries/chunked-forest/chunkedForest.ts +27 -7
  557. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +143 -7
  558. package/src/feature-libraries/chunked-forest/codec/codecs.ts +30 -28
  559. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +7 -7
  560. package/src/feature-libraries/chunked-forest/codec/format/formatGeneric.ts +2 -1
  561. package/src/feature-libraries/chunked-forest/codec/format/formatV1.ts +2 -1
  562. package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +13 -8
  563. package/src/feature-libraries/chunked-forest/codec/format/formatVText.ts +84 -0
  564. package/src/feature-libraries/chunked-forest/codec/format/index.ts +6 -1
  565. package/src/feature-libraries/chunked-forest/codec/format/versions.ts +25 -4
  566. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +14 -18
  567. package/src/feature-libraries/chunked-forest/uniformChunk.ts +131 -44
  568. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +36 -14
  569. package/src/feature-libraries/forest-summary/codec.ts +9 -4
  570. package/src/feature-libraries/forest-summary/formatCommon.ts +2 -1
  571. package/src/feature-libraries/modular-schema/genericFieldKindFormat.ts +2 -1
  572. package/src/feature-libraries/modular-schema/modularChangeFormatV1.ts +2 -1
  573. package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +2 -1
  574. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +1 -1
  575. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV1.ts +2 -1
  576. package/src/feature-libraries/optional-field/optionalFieldChangeFormatV2.ts +2 -1
  577. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +2 -1
  578. package/src/feature-libraries/schema-index/codec.ts +2 -5
  579. package/src/feature-libraries/schema-index/formatV1.ts +2 -1
  580. package/src/feature-libraries/schema-index/formatV2.ts +2 -1
  581. package/src/feature-libraries/sequence-field/compose.ts +1 -4
  582. package/src/feature-libraries/sequence-field/formatV1.ts +2 -1
  583. package/src/feature-libraries/sequence-field/formatV2.ts +2 -1
  584. package/src/feature-libraries/sequence-field/formatV3.ts +2 -1
  585. package/src/index.ts +6 -1
  586. package/src/packageVersion.ts +1 -1
  587. package/src/shared-tree/isAuditableFromOutcome.ts +34 -0
  588. package/src/shared-tree/sharedTree.ts +2 -5
  589. package/src/shared-tree/sharedTreeChangeFormat.ts +2 -1
  590. package/src/shared-tree/treeCheckout.ts +55 -15
  591. package/src/shared-tree-core/editManager.ts +2 -2
  592. package/src/shared-tree-core/editManagerCodecs.ts +4 -6
  593. package/src/shared-tree-core/editManagerFormatCommons.ts +2 -1
  594. package/src/shared-tree-core/editManagerFormatV1toV4.ts +2 -1
  595. package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +2 -1
  596. package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
  597. package/src/shared-tree-core/messageCodecs.ts +4 -4
  598. package/src/shared-tree-core/messageFormatV1ToV4.ts +2 -1
  599. package/src/shared-tree-core/messageFormatVSharedBranches.ts +2 -1
  600. package/src/simple-tree/core/treeNodeKernel.ts +66 -28
  601. package/src/simple-tree/simpleSchemaFormatV1.ts +2 -1
  602. package/src/text/codePointUtils.ts +81 -0
  603. package/src/text/index.ts +1 -0
  604. package/src/text/textDomain.ts +155 -2
  605. package/src/text/textDomainFormatted.ts +73 -2
  606. package/src/treeFactory.ts +5 -0
  607. package/src/util/breakable.ts +27 -6
  608. package/src/util/typeboxBrand.ts +2 -1
  609. package/src/util/utils.ts +2 -1
@@ -0,0 +1,84 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import * as Type from "@sinclair/typebox";
7
+ import type { Static } from "@sinclair/typebox";
8
+
9
+ import { unionOptions } from "../../../../codec/index.js";
10
+
11
+ import { ShapeIndex } from "./formatGeneric.js";
12
+ import { EncodedFieldShape, EncodedValueShape } from "./formatV1.js";
13
+ import { shapesV2 } from "./formatV2.js";
14
+
15
+ /**
16
+ * A node shape that derives from another node shape by overlaying property-level overrides.
17
+ *
18
+ * @remarks
19
+ * Compresses runs of node shapes that differ only in a few properties: a base node shape
20
+ * defines the structural skeleton, and the specialization narrows specific properties.
21
+ *
22
+ * For example, a base `FormatNode` with a variable-boolean `bold` field can be specialized
23
+ * to a shape that pins `bold` to a constant `true` — every node decoded with the
24
+ * specialization contributes zero stream tokens for `bold`.
25
+ *
26
+ * Specialization rules: `type` is always inherited from the resolved base. `fields` overrides
27
+ * apply per-key: entries whose key matches a base field replace that entry's shape index in
28
+ * place; entries with new keys are appended after all base fields. For `value` and
29
+ * `extraFields`: if the property is absent on the wire, the base's value is inherited; if
30
+ * `null`, the resulting shape has no value / no extraFields (explicit clear); any other value
31
+ * replaces the base's.
32
+ *
33
+ * The `null` sentinel exists because JSON does not preserve `undefined`-valued properties,
34
+ * so override-vs-inherit cannot be discriminated by property presence after persistence.
35
+ *
36
+ * Decoded by {@link applySpecialization}.
37
+ */
38
+ export type EncodedSpecializedNodeShape = Static<typeof EncodedSpecializedNodeShape>;
39
+ export const EncodedSpecializedNodeShape = Type.Object(
40
+ {
41
+ /**
42
+ * Index into the enclosing batch's shapes array of the shape this specializes.
43
+ * Must resolve to either an {@link EncodedNodeShape} or another
44
+ * `EncodedSpecializedNodeShape`; chains are followed transitively until a node shape
45
+ * is reached. This restriction is enforced at runtime, not by the schema.
46
+ */
47
+ base: ShapeIndex,
48
+ /**
49
+ * Field-level overrides applied to the resolved base's `fields`. Entries whose key
50
+ * matches a base field replace that field's shape index in place; entries with new
51
+ * keys are appended after all base fields, in the order given here. Base field order
52
+ * is preserved — this is the stream consumption order at decode time, so encoders
53
+ * must serialize per-field tokens in the resulting field order, not in this list's order.
54
+ */
55
+ fields: Type.Optional(Type.Array(EncodedFieldShape)),
56
+ /**
57
+ * If absent, inherits the resolved base's value shape. If `null`, the resulting shape
58
+ * has no value shape (explicit clear). Any other value replaces the base's.
59
+ */
60
+ value: Type.Optional(Type.Union([EncodedValueShape, Type.Null()])),
61
+ /**
62
+ * If absent, inherits the resolved base's extraFields shape. If `null`, the resulting
63
+ * shape has no extraFields (explicit clear). Any other value replaces the base's.
64
+ */
65
+ extraFields: Type.Optional(Type.Union([ShapeIndex, Type.Null()])),
66
+ },
67
+ { additionalProperties: false },
68
+ );
69
+
70
+ /**
71
+ * Experimental extension of {@link EncodedChunkShapeV2}.
72
+ * @remarks
73
+ * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.
74
+ */
75
+ export type EncodedChunkShapeVTextExperimental = Static<
76
+ typeof EncodedChunkShapeVTextExperimental
77
+ >;
78
+ export const EncodedChunkShapeVTextExperimental = Type.Object(
79
+ {
80
+ ...shapesV2,
81
+ f: Type.Optional(EncodedSpecializedNodeShape),
82
+ },
83
+ unionOptions,
84
+ );
@@ -16,14 +16,19 @@ export {
16
16
  SpecialField,
17
17
  } from "./formatV1.js";
18
18
  export { EncodedIncrementalChunkShape, EncodedChunkShapeV2 } from "./formatV2.js";
19
+ export {
20
+ EncodedChunkShapeVTextExperimental,
21
+ EncodedSpecializedNodeShape,
22
+ } from "./formatVText.js";
19
23
  export {
20
24
  FieldBatchFormatVersion,
21
25
  EncodedFieldBatchV1,
22
26
  EncodedFieldBatchV2,
27
+ EncodedFieldBatchVTextExperimental,
23
28
  supportsIncrementalEncoding,
24
29
  type EncodedFieldBatchV1OrV2,
25
30
  type EncodedFieldBatchV1AndV2,
26
- type EncodedChunkShapeV1OrV2,
31
+ type EncodedChunkShape,
27
32
  } from "./versions.js";
28
33
  export type {
29
34
  ShapeIndex,
@@ -10,6 +10,7 @@ import { strictEnum, type Values } from "../../../../util/index.js";
10
10
  import { EncodedFieldBatchGeneric } from "./formatGeneric.js";
11
11
  import { EncodedChunkShapeV1 } from "./formatV1.js";
12
12
  import { EncodedChunkShapeV2 } from "./formatV2.js";
13
+ import { EncodedChunkShapeVTextExperimental } from "./formatVText.js";
13
14
 
14
15
  /**
15
16
  * The format version for the field batch.
@@ -29,6 +30,10 @@ export const FieldBatchFormatVersion = strictEnum("FieldBatchFormatVersion", {
29
30
  * {@link EncodedIncrementalChunkShape} was added in this version.
30
31
  */
31
32
  v2: 2,
33
+ /**
34
+ * Experimental codec with optimizations for text.
35
+ */
36
+ vTextExperimental: "text",
32
37
  });
33
38
 
34
39
  /**
@@ -68,6 +73,17 @@ export const EncodedFieldBatchV2 = EncodedFieldBatchGeneric(
68
73
  EncodedChunkShapeV2,
69
74
  );
70
75
 
76
+ /**
77
+ * Encoded {@link FieldBatch} using the experimental text optimized format.
78
+ */
79
+ export type EncodedFieldBatchVTextExperimental = Static<
80
+ typeof EncodedFieldBatchVTextExperimental
81
+ >;
82
+ export const EncodedFieldBatchVTextExperimental = EncodedFieldBatchGeneric(
83
+ FieldBatchFormatVersion.vTextExperimental,
84
+ EncodedChunkShapeVTextExperimental,
85
+ );
86
+
71
87
  /**
72
88
  * Encoded {@link FieldBatch}, which might use V2 features, but might also have been from a V1 encoder.
73
89
  * @remarks
@@ -88,9 +104,14 @@ export type EncodedFieldBatchV1OrV2 = EncodedFieldBatchV1 | EncodedFieldBatchV2;
88
104
  export type EncodedFieldBatchV1AndV2 = EncodedFieldBatchV1 & EncodedFieldBatchV2;
89
105
 
90
106
  /**
91
- * Encoded chunk shape, which might use V2 features, but might also have been from a V1 encoder.
107
+ * An encoded chunk shape from any known {@link FieldBatchFormatVersion}.
108
+ *
92
109
  * @remarks
93
- * Type wise, equivalent to V2, as that is a superset of V1.
94
- * Used instead of just V2 for clarity.
110
+ * Use this when working with chunk shapes uniformly across versions for example, in the
111
+ * shared decoder dispatcher and in encoder shape base classes. New format versions should
112
+ * add their chunk shape variant to this union.
95
113
  */
96
- export type EncodedChunkShapeV1OrV2 = EncodedChunkShapeV1 | EncodedChunkShapeV2;
114
+ export type EncodedChunkShape =
115
+ | EncodedChunkShapeV1
116
+ | EncodedChunkShapeV2
117
+ | EncodedChunkShapeVTextExperimental;
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { assert, fail } from "@fluidframework/core-utils/internal";
7
- import { isStableId } from "@fluidframework/id-compressor/internal";
7
+ import { isFinalId, isStableId } from "@fluidframework/id-compressor/internal";
8
8
 
9
9
  import {
10
10
  type FieldKey,
@@ -25,7 +25,7 @@ import {
25
25
  encodeValue,
26
26
  } from "./compressedEncode.js";
27
27
  import type {
28
- EncodedChunkShapeV1OrV2,
28
+ EncodedChunkShape,
29
29
  EncodedFieldShape,
30
30
  EncodedValueShape,
31
31
  } from "./format/index.js";
@@ -36,10 +36,7 @@ import type {
36
36
  * The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,
37
37
  * which is an easy way to keep all the related code together without extra objects.
38
38
  */
39
- export class NodeShapeBasedEncoder
40
- extends Shape<EncodedChunkShapeV1OrV2>
41
- implements NodeEncoder
42
- {
39
+ export class NodeShapeBasedEncoder extends Shape<EncodedChunkShape> implements NodeEncoder {
43
40
  /**
44
41
  * Set of keys for fields that are encoded using {@link NodeShapeBasedEncoder.specializedFieldEncoders}.
45
42
  * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.
@@ -82,8 +79,7 @@ export class NodeShapeBasedEncoder
82
79
  // This is not the case for forest summaries at the time of writing, so non-finalized ids are instead written using
83
80
  // their long form (by falling through to the original cursor value).
84
81
  // A scenario where such ids can appear in the summary is in the attach summary of a tree being attached to an already-attached container.
85
- // TODO: isFinalId should probably be exported from id-compressor and that could be used to do the narrowing here.
86
- if (!context.isSummary || opSpaceId >= 0) {
82
+ if (!context.isSummary || isFinalId(opSpaceId)) {
87
83
  return opSpaceId;
88
84
  }
89
85
  }
@@ -95,7 +91,7 @@ export class NodeShapeBasedEncoder
95
91
  public encodeNode(
96
92
  cursor: ITreeCursorSynchronous,
97
93
  context: EncoderContext,
98
- outputBuffer: BufferFormat<EncodedChunkShapeV1OrV2>,
94
+ outputBuffer: BufferFormat<EncodedChunkShape>,
99
95
  ): void {
100
96
  if (this.type === undefined) {
101
97
  outputBuffer.push(new IdentifierToken(cursor.type));
@@ -109,7 +105,7 @@ export class NodeShapeBasedEncoder
109
105
  cursor.exitField();
110
106
  }
111
107
 
112
- const otherFieldsBuffer: BufferFormat<EncodedChunkShapeV1OrV2> = [];
108
+ const otherFieldsBuffer: BufferFormat<EncodedChunkShape> = [];
113
109
 
114
110
  forEachField(cursor, () => {
115
111
  const key = cursor.getFieldKey();
@@ -130,8 +126,8 @@ export class NodeShapeBasedEncoder
130
126
 
131
127
  public encodeShape(
132
128
  identifiers: DeduplicationTable<string>,
133
- shapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,
134
- ): EncodedChunkShapeV1OrV2 {
129
+ shapes: DeduplicationTable<Shape<EncodedChunkShape>>,
130
+ ): EncodedChunkShape {
135
131
  return {
136
132
  c: {
137
133
  type: encodeOptionalIdentifier(this.type, identifiers),
@@ -144,7 +140,7 @@ export class NodeShapeBasedEncoder
144
140
 
145
141
  public countReferencedShapesAndIdentifiers(
146
142
  identifiers: Counter<string>,
147
- shapeDiscovered: (shape: Shape<EncodedChunkShapeV1OrV2>) => void,
143
+ shapeDiscovered: (shape: Shape<EncodedChunkShape>) => void,
148
144
  ): void {
149
145
  if (this.type !== undefined) {
150
146
  identifiers.add(this.type);
@@ -160,7 +156,7 @@ export class NodeShapeBasedEncoder
160
156
  }
161
157
  }
162
158
 
163
- public get shape(): Shape<EncodedChunkShapeV1OrV2> {
159
+ public get shape(): Shape<EncodedChunkShape> {
164
160
  return this;
165
161
  }
166
162
  }
@@ -168,7 +164,7 @@ export class NodeShapeBasedEncoder
168
164
  export function encodeFieldShapes(
169
165
  fieldEncoders: readonly KeyedFieldEncoder[],
170
166
  identifiers: DeduplicationTable<string>,
171
- shapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,
167
+ shapes: DeduplicationTable<Shape<EncodedChunkShape>>,
172
168
  ): EncodedFieldShape[] | undefined {
173
169
  if (fieldEncoders.length === 0) {
174
170
  return undefined;
@@ -197,14 +193,14 @@ function encodeOptionalIdentifier(
197
193
 
198
194
  function encodeOptionalFieldShape(
199
195
  encoder: FieldEncoder | undefined,
200
- shapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,
196
+ shapes: DeduplicationTable<Shape<EncodedChunkShape>>,
201
197
  ): number | undefined {
202
198
  return encoder === undefined ? undefined : dedupShape(encoder.shape, shapes);
203
199
  }
204
200
 
205
201
  function dedupShape(
206
- shape: Shape<EncodedChunkShapeV1OrV2>,
207
- shapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,
202
+ shape: Shape<EncodedChunkShape>,
203
+ shapes: DeduplicationTable<Shape<EncodedChunkShape>>,
208
204
  ): number {
209
205
  return shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);
210
206
  }
@@ -113,7 +113,15 @@ export class TreeShape {
113
113
  public readonly fieldsOffsetArray: readonly OffsetShape[];
114
114
  public readonly valuesPerTopLevelNode: number;
115
115
 
116
- // TODO: this is only needed at chunk roots. Optimize it base on that.
116
+ /**
117
+ * Information about every node in this shape.
118
+ * The root is first, and all indexes it uses to refer to other nodes are indexes into this array.
119
+ * Beyond that the ordering is an implementation detail of this shape.
120
+ * @remarks
121
+ * Use of this in contexts where there might be multiple top-level nodes requires some additional care.
122
+ * For example {@link Cursor} derives each node's actual position info from this shared
123
+ * array plus the node's top-level index within the chunk.
124
+ */
117
125
  public readonly positions: readonly NodePositionInfo[];
118
126
 
119
127
  /**
@@ -246,25 +254,19 @@ function clonePositions(
246
254
  /**
247
255
  * The shape (see `TreeShape`) of a sequence of trees, all with the same shape (like `FieldShape`, but without a field key).
248
256
  *
249
- * This shape is optimized (by caching derived data like the positions array),
250
- * so that when paired with a value array it can be efficiently traversed like a tree by an {@link ITreeCursorSynchronous}.
251
- * See {@link uniformChunk} for how to do this.
257
+ * @remarks
258
+ * Paired with a value array, this lets a {@link UniformChunk} be traversed like a tree by an
259
+ * {@link ITreeCursorSynchronous}. The {@link Cursor} derives each node's position info from the
260
+ * shared {@link TreeShape.positions} plus the node's top-level index.
252
261
  *
253
262
  * TODO: consider storing shape information in WASM
254
263
  */
255
264
  export class ChunkShape {
256
- public readonly positions: readonly (NodePositionInfo | undefined)[];
257
-
258
265
  public constructor(
259
266
  public readonly treeShape: TreeShape,
260
267
  public readonly topLevelLength: number,
261
268
  ) {
262
269
  assert(topLevelLength > 0, 0x4c6 /* topLevelLength must be greater than 0 */);
263
-
264
- // TODO: avoid duplication from inner loop
265
- const positions: (NodePositionInfo | undefined)[] = [undefined];
266
- clonePositions(0, [dummyRoot, treeShape, topLevelLength], 0, 0, positions);
267
- this.positions = positions;
268
270
  }
269
271
 
270
272
  public equals(other: ChunkShape): boolean {
@@ -295,17 +297,19 @@ class OffsetShape {
295
297
  }
296
298
 
297
299
  /**
298
- * Information about a node at a specific position within a uniform chunk.
300
+ * Information about a node at a specific position within one top-level tree of a {@link TreeShape}.
299
301
  */
300
302
  class NodePositionInfo implements UpPath {
301
303
  /**
302
- * @param parent - TODO
303
- * @param parentField - TODO
304
+ * @param parent - The parent node's {@link NodePositionInfo} or `undefined` for a root.
305
+ * @param parentField - The {@link FieldKey} of the field this node occupies within its parent.
304
306
  * @param parentIndex - indexWithinParentField
305
- * @param indexOfParentField - which field of the parent `parentIndex` is indexing into to locate this.
306
- * @param indexOfParentPosition - Index of parent NodePositionInfo in positions array. TODO: use offsets to avoid copying at top level?
307
+ * @param indexOfParentField - Which field of the parent `parentIndex` is indexing into to locate this.
308
+ * @param indexOfParentPosition - Index of this node's parent in {@link TreeShape.positions}
307
309
  * @param shape - Shape of the top level sequence this node is part of
308
- * @param valueOffset - TODO
310
+ * @param topLevelLength - Number of siblings in this node's field. For a root this is unused
311
+ * @param valueOffset - Offset of this node's value within one top-level tree's slice of the chunk's flat `values` array;
312
+ * only valid when `shape.hasValue` (otherwise it's where the value would have gone, and should not be used to read a value).
309
313
  */
310
314
  public constructor(
311
315
  public readonly parent: NodePositionInfo | undefined, // TODO; general UpPath to allow prefixing here?
@@ -322,16 +326,28 @@ class NodePositionInfo implements UpPath {
322
326
  /**
323
327
  * The cursor implementation for `UniformChunk`.
324
328
  *
325
- * Works by tracking its location in the chunk's `positions` array.
329
+ * @remarks
330
+ * Tracks a flat `positionIndex` and derives each node's position info from the shape's shared
331
+ * {@link TreeShape.positions} plus the node's top-level index.
326
332
  */
327
333
  class Cursor extends SynchronousCursor implements ChunkedCursor {
328
334
  private positionIndex!: number; // When in fields mode, this points to the parent node.
329
- // Undefined when in root field
335
+
336
+ /** Position info for the current node, or `undefined` when in root field. */
330
337
  private nodePositionInfo: NodePositionInfo | undefined;
331
338
 
332
- // Cached constants for faster access
339
+ /** Which top-level node of the chunk the current position is within. Valid when nodePositionInfo !== undefined. */
340
+ private topLevelIndex: number = 0;
341
+
342
+ // Cached constants for faster access.
343
+ /** The chunk's shape. */
333
344
  private readonly shape: ChunkShape;
334
- private readonly positions: readonly (NodePositionInfo | undefined)[];
345
+ /** The chunk's per-tree shape (shape of each top-level tree). */
346
+ private readonly treeShape: TreeShape;
347
+ /** Number of positions in one top-level tree (treeShape.positions.length). */
348
+ private readonly nodeLength: number;
349
+ /** Number of values per top-level node (treeShape.valuesPerTopLevelNode). */
350
+ private readonly stride: number;
335
351
 
336
352
  public mode: CursorLocationType = CursorLocationType.Fields;
337
353
 
@@ -346,7 +362,9 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
346
362
  public constructor(private readonly chunk: UniformChunk) {
347
363
  super();
348
364
  this.shape = this.chunk.shape;
349
- this.positions = this.shape.positions;
365
+ this.treeShape = this.shape.treeShape;
366
+ this.nodeLength = this.treeShape.positions.length;
367
+ this.stride = this.treeShape.valuesPerTopLevelNode;
350
368
  this.fieldKey = dummyRoot;
351
369
  this.moveToPosition(0);
352
370
  }
@@ -377,18 +395,70 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
377
395
 
378
396
  /**
379
397
  * Change the current node within the chunk.
398
+ *
399
+ * @param positionIndex - flat position index of the newly selected node. This is NOT an index
400
+ * within a field, and is not bounds checked.
401
+ *
402
+ * @remarks
403
+ * Decomposes the index into {@link Cursor.topLevelIndex} and {@link Cursor.nodePositionInfo}.
380
404
  * See `nodeInfo` for getting data about the current node.
381
405
  *
382
- * @param positionIndex - index of the position of the newly selected node in `positions`.
383
- * This is NOT an index within a field, and is not bounds checked.
384
406
  */
385
407
  private moveToPosition(positionIndex: number): void {
386
- this.nodePositionInfo = this.positions[positionIndex];
387
408
  this.positionIndex = positionIndex;
388
- if (this.nodePositionInfo === undefined) {
389
- assert(positionIndex === 0, 0x561 /* expected root at start */);
409
+ if (positionIndex === 0) {
410
+ this.nodePositionInfo = undefined;
390
411
  assert(this.mode === CursorLocationType.Fields, 0x562 /* expected root to be a field */);
412
+ return;
391
413
  }
414
+ const decoded = this.decodePosition(positionIndex);
415
+ this.topLevelIndex = decoded.topLevelIndex;
416
+ this.nodePositionInfo = decoded.info;
417
+ }
418
+
419
+ /**
420
+ * Decode a flat `positionIndex` into its components.
421
+ *
422
+ * @param positionIndex - flat position index of the node to decode. Must be greater than 0;
423
+ * @returns the node's index within {@link TreeShape.positions} (`withinTree`), which top-level
424
+ * tree holds it (`topLevelIndex`), and the corresponding shared {@link NodePositionInfo} (`info`).
425
+ */
426
+ private decodePosition(positionIndex: number): {
427
+ withinTree: number;
428
+ topLevelIndex: number;
429
+ info: NodePositionInfo;
430
+ } {
431
+ const offset = positionIndex - 1;
432
+ // Find the node's index within treeShape.positions, then which top-level tree holds it.
433
+ const withinTree = offset % this.nodeLength; // remainder
434
+ const topLevelIndex = (offset - withinTree) / this.nodeLength; // quotient
435
+ const info = this.treeShape.positions[withinTree] ?? oob();
436
+ return { withinTree, topLevelIndex, info };
437
+ }
438
+
439
+ /**
440
+ * Build a standalone {@link UpPath} for the node at `positionIndex`. O(depth) allocation.
441
+ *
442
+ * @remarks
443
+ * walks the shared per-tree {@link TreeShape.positions} and applies the top-level index
444
+ * at each level. Mirrors how the `BasicChunk` cursor allocates paths.
445
+ */
446
+ private materializePath(positionIndex: number): UpPath | undefined {
447
+ if (positionIndex === 0) {
448
+ return undefined;
449
+ }
450
+ const { withinTree, topLevelIndex, info } = this.decodePosition(positionIndex);
451
+ if (info.parent === undefined) {
452
+ // Top-level node: its parent is the (prefixed) chunk root.
453
+ return { parent: undefined, parentField: info.parentField, parentIndex: topLevelIndex };
454
+ }
455
+ return {
456
+ parent: this.materializePath(
457
+ positionIndex - withinTree + (info.indexOfParentPosition ?? oob()),
458
+ ),
459
+ parentField: info.parentField,
460
+ parentIndex: info.parentIndex,
461
+ };
392
462
  }
393
463
 
394
464
  /**
@@ -505,36 +575,51 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
505
575
  private enterRootNodeInner(childIndex: number): void {
506
576
  this.mode = CursorLocationType.Nodes;
507
577
  this.fieldKey = undefined;
508
- // 1 for the "undefined" at the beginning of the positions array, then stride by top level tree shape.
509
- this.moveToPosition(1 + childIndex * this.shape.treeShape.positions.length);
578
+ // 1 for the "undefined" root-field marker at position 0, then stride by one top-level tree (nodeLength).
579
+ this.moveToPosition(1 + childIndex * this.nodeLength);
510
580
  assert(this.fieldIndex === childIndex, 0x543 /* should be at selected child */);
511
581
  }
512
582
 
513
583
  public getFieldPath(prefix?: PathRootPrefix): FieldUpPath {
514
584
  return prefixFieldPath(prefix, {
515
585
  field: this.getFieldKey(),
516
- parent: this.nodePositionInfo,
586
+ parent: this.materializePath(this.positionIndex),
517
587
  });
518
588
  }
519
589
 
520
590
  public getPath(prefix?: PathRootPrefix): UpPath | undefined {
521
- return prefixPath(prefix, this.nodeInfo(CursorLocationType.Nodes));
591
+ this.nodeInfo(CursorLocationType.Nodes); // assert: in nodes mode at a node
592
+ return prefixPath(prefix, this.materializePath(this.positionIndex));
522
593
  }
523
594
 
524
595
  public get fieldIndex(): number {
525
- return this.nodeInfo(CursorLocationType.Nodes).parentIndex;
596
+ const info = this.nodeInfo(CursorLocationType.Nodes);
597
+ return info.parent === undefined ? this.topLevelIndex : info.parentIndex;
526
598
  }
527
599
 
528
600
  public readonly chunkStart: number = 0;
529
601
 
602
+ /**
603
+ * Number of nodes in `info`'s field including `info` itself.
604
+ *
605
+ * @remarks
606
+ * For top-level nodes this is the chunk's `topLevelLength`, read from the chunk
607
+ * rather than the node, so the shared per-tree {@link TreeShape.positions} stays independent of
608
+ * chunk length; the root entry's own `topLevelLength` field is unused. Nested nodes use the
609
+ * field length stored on the node.
610
+ */
611
+ private siblingCount(info: NodePositionInfo): number {
612
+ return info.parent === undefined ? this.shape.topLevelLength : info.topLevelLength;
613
+ }
614
+
530
615
  public get chunkLength(): number {
531
- return this.nodeInfo(CursorLocationType.Nodes).topLevelLength;
616
+ return this.siblingCount(this.nodeInfo(CursorLocationType.Nodes));
532
617
  }
533
618
 
534
619
  public seekNodes(offset: number): boolean {
535
620
  const info = this.nodeInfo(CursorLocationType.Nodes);
536
- const index = offset + info.parentIndex;
537
- if (index >= 0 && index < info.topLevelLength) {
621
+ const index = offset + this.fieldIndex;
622
+ if (index >= 0 && index < this.siblingCount(info)) {
538
623
  this.moveToPosition(this.positionIndex + offset * info.shape.positions.length);
539
624
  return true;
540
625
  }
@@ -546,8 +631,8 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
546
631
  // This is the same as `return this.seekNodes(1);` but slightly faster.
547
632
 
548
633
  const info = this.nodeInfo(CursorLocationType.Nodes);
549
- const index = info.parentIndex + 1;
550
- if (index === info.topLevelLength) {
634
+ const index = this.fieldIndex + 1;
635
+ if (index === this.siblingCount(info)) {
551
636
  this.exitNode();
552
637
  return false;
553
638
  }
@@ -557,15 +642,17 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
557
642
 
558
643
  public exitNode(): void {
559
644
  const info = this.nodeInfo(CursorLocationType.Nodes);
560
- this.indexOfField =
561
- info.indexOfParentField ??
562
- fail(0xb0a /* navigation up to root field not yet supported */); // TODO;
645
+ const withinTree = this.positionIndex - 1 - this.topLevelIndex * this.nodeLength;
646
+ // Top-level nodes (no parent) exit to the root field at position 0;
647
+ // nested nodes' parent is `indexOfParentPosition` within the same top-level instance.
648
+ this.indexOfField = info.indexOfParentField ?? 0;
563
649
  this.fieldKey = info.parentField;
564
650
  this.mode = CursorLocationType.Fields;
565
651
  this.moveToPosition(
566
- info.indexOfParentPosition ??
567
- fail(0xb0b /* navigation up to root field not yet supported */),
568
- ); // TODO
652
+ info.indexOfParentPosition === undefined
653
+ ? 0
654
+ : this.positionIndex - withinTree + info.indexOfParentPosition,
655
+ );
569
656
  }
570
657
 
571
658
  public firstField(): boolean {
@@ -598,7 +685,7 @@ class Cursor extends SynchronousCursor implements ChunkedCursor {
598
685
  public get value(): Value {
599
686
  const info = this.nodeInfo(CursorLocationType.Nodes);
600
687
  if (info.shape.hasValue) {
601
- const value = this.chunk.values[info.valueOffset];
688
+ const value = this.chunk.values[info.valueOffset + this.topLevelIndex * this.stride];
602
689
  // If mayContainCompressedIds is set, check if the value is a number (i.e. a compressed ID that needs decompression).
603
690
  if (info.shape.mayContainCompressedIds && typeof value === "number") {
604
691
  const idCompressor = this.chunk.idCompressor;
@@ -316,6 +316,7 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
316
316
  const detachCellId = this.modularBuilder.generateId(count);
317
317
  const attachCellId: CellId = { localId: this.modularBuilder.generateId(count), revision };
318
318
  if (compareFieldUpPaths(sourceField, destinationField)) {
319
+ // The source and destination fields are the same.
319
320
  const change = sequence.changeHandler.editor.move(
320
321
  sourceIndex,
321
322
  count,
@@ -331,32 +332,53 @@ export class DefaultEditBuilder implements ChangeFamilyEditor, IDefaultEditBuild
331
332
  revision,
332
333
  );
333
334
  } else {
335
+ // The source and destination fields are different.
334
336
  const detachPath = topDownPath(sourceField.parent);
335
337
  const attachPath = topDownPath(destinationField.parent);
338
+ /**
339
+ * The number of elements, starting from the root, that both paths have in common.
340
+ * This defines the lowest common ancestor node (LCA) of the source and destination fields.
341
+ */
336
342
  const sharedDepth = getSharedPrefixLength(detachPath, attachPath);
337
343
  let adjustedAttachField = destinationField;
338
- // After the above loop, `sharedDepth` is the number of elements, starting from the root,
339
- // that both paths have in common.
344
+ // Check if the detach parent
345
+ // (the node directly above the location of detach)
346
+ // is along the attach path,
347
+ // in which case the attach path might need to be adjusted.
348
+ // This is synonymous with checking if the attach parent
349
+ // (the node directly above the location of attach)
350
+ // is either below or the same as the detach parent.
351
+ // If not, then the move does not need to be adjusted
352
+ // as the attach path will not be affected by the detach.
340
353
  if (sharedDepth === detachPath.length) {
341
- const attachField = attachPath[sharedDepth]?.parentField ?? destinationField.field;
342
- if (attachField === sourceField.field) {
343
- // The detach occurs in an ancestor field of the field where the attach occurs.
344
- let attachAncestorIndex = attachPath[sharedDepth]?.parentIndex ?? sourceIndex;
345
- if (attachAncestorIndex < sourceIndex) {
354
+ const fieldOnDetachPathUnderLCA = sourceField.field;
355
+ const firstDifferentAttachAncestor = attachPath[sharedDepth];
356
+ // Check if the detach location uses the same field as in
357
+ // the attach path.
358
+ // Note that when `firstDifferentAttachAncestor` is undefined,
359
+ // that means the parents are the same. Since earlier call
360
+ // to `compareFieldUpPaths` returned false, we know that the
361
+ // fields must be different AND thus no adjustment is needed.
362
+ if (fieldOnDetachPathUnderLCA === firstDifferentAttachAncestor?.parentField) {
363
+ // Now working at the level where detach happens along the
364
+ // attach path.
365
+ if (firstDifferentAttachAncestor.parentIndex < sourceIndex) {
346
366
  // The attach path runs through a node located before the detached nodes.
347
367
  // No need to adjust the attach path.
348
- } else if (sourceIndex + count <= attachAncestorIndex) {
368
+ } else if (sourceIndex + count <= firstDifferentAttachAncestor.parentIndex) {
349
369
  // The attach path runs through a node located after the detached nodes.
350
- // adjust the index for the node at that depth of the path, so that it is interpreted correctly
370
+ // Adjust the index for the node at that depth of the path, so that it is interpreted correctly
351
371
  // in the composition performed by `submitChanges`.
352
- attachAncestorIndex -= count;
353
- let parent: UpPath | undefined = attachPath[sharedDepth - 1];
354
- const parentField = attachPath[sharedDepth] ?? oob();
372
+ // Start with path to root that remains intact.
373
+ let parent = firstDifferentAttachAncestor.parent;
374
+ // Extend with index-adjusted parent.
355
375
  parent = {
356
376
  parent,
357
- parentIndex: attachAncestorIndex,
358
- parentField: parentField.parentField,
377
+ parentIndex: firstDifferentAttachAncestor.parentIndex - count,
378
+ parentField: firstDifferentAttachAncestor.parentField,
359
379
  };
380
+ // Extend with the rest of the attach path, which is unaffected
381
+ // apart from parentage replacements.
360
382
  for (let i = sharedDepth + 1; i < attachPath.length; i += 1) {
361
383
  parent = {
362
384
  ...(attachPath[i] ?? oob()),