@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
@@ -1 +1 @@
1
- {"version":3,"file":"nodeEncoder.d.ts","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeEncoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAG7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,KAAK,YAAY,EAAmB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,qBAAa,qBACZ,SAAQ,KAAK,CAAC,uBAAuB,CACrC,YAAW,WAAW;aASL,IAAI,EAAE,SAAS,GAAG,wBAAwB;aAC1C,KAAK,EAAE,iBAAiB;IACxC;;;;;;;;;;OAUG;aACa,wBAAwB,EAAE,SAAS,iBAAiB,EAAE;IACtE;;;OAGG;aACa,kBAAkB,EAAE,SAAS,GAAG,YAAY;IAzB7D;;;OAGG;IACH,OAAO,C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,CAE3C;CACD;AAED,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACvC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAClD,iBAAiB,EAAE,GAAG,SAAS,CAUjC"}
@@ -54,8 +54,7 @@ class NodeShapeBasedEncoder extends chunkEncodingGeneric_js_1.Shape {
54
54
  // This is not the case for forest summaries at the time of writing, so non-finalized ids are instead written using
55
55
  // their long form (by falling through to the original cursor value).
56
56
  // 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.
57
- // TODO: isFinalId should probably be exported from id-compressor and that could be used to do the narrowing here.
58
- if (!context.isSummary || opSpaceId >= 0) {
57
+ if (!context.isSummary || (0, internal_2.isFinalId)(opSpaceId)) {
59
58
  return opSpaceId;
60
59
  }
61
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nodeEncoder.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeEncoder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,qEAAoE;AAEpE,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAO/B;;;;;GAKG;AACH,MAAa,qBACZ,SAAQ,+BAA8B;IAStC,YACiB,IAA0C,EAC1C,KAAwB;IACxC;;;;;;;;;;OAUG;IACa,wBAAsD;IACtE;;;OAGG;IACa,kBAA4C;QAE5D,KAAK,EAAE,CAAC;QApBQ,SAAI,GAAJ,IAAI,CAAsC;QAC1C,UAAK,GAAL,KAAK,CAAmB;QAYxB,6BAAwB,GAAxB,wBAAwB,CAA8B;QAKtD,uBAAkB,GAAlB,kBAAkB,CAA0B;QAG5D,IAAI,CAAC,oBAAoB,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC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,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,OAAiC,EACjC,MAA0D;IAE1D,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAClB,KAAqC,EACrC,MAA0D;IAE1D,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderContext,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type {\n\tEncodedChunkShapeV1OrV2,\n\tEncodedFieldShape,\n\tEncodedValueShape,\n} from \"./format/index.js\";\n\n/**\n * Encodes a node with the {@link EncodedNodeShape} shape.\n * @remarks\n * The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,\n * which is an easy way to keep all the related code together without extra objects.\n */\nexport class NodeShapeBasedEncoder\n\textends Shape<EncodedChunkShapeV1OrV2>\n\timplements NodeEncoder\n{\n\t/**\n\t * Set of keys for fields that are encoded using {@link NodeShapeBasedEncoder.specializedFieldEncoders}.\n\t * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\t */\n\tprivate readonly specializedFieldKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\t/**\n\t\t * Encoders for a specific set of fields, by key, in the order they will be encoded.\n\t\t * These are fields for which specialized encoding is provided as an optimization.\n\t\t * Using these for a given field instead of falling back to {@link NodeShapeBasedEncoder.specializedFieldEncoders} is often more efficient:\n\t\t * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.\n\t\t * Instead, this information is here, and thus is encoded only once as part of the node shape.\n\t\t * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).\n\t\t *\n\t\t * Any fields not included here will be encoded using {@link NodeShapeBasedEncoder.otherFieldsEncoder}.\n\t\t * If {@link NodeShapeBasedEncoder.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.\n\t\t */\n\t\tpublic readonly specializedFieldEncoders: readonly KeyedFieldEncoder[],\n\t\t/**\n\t\t * Encoder for all other fields that are not in {@link NodeShapeBasedEncoder.specializedFieldEncoders}. These fields must\n\t\t * be encoded after the specialized fields.\n\t\t */\n\t\tpublic readonly otherFieldsEncoder: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, context: EncoderContext): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = context.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\tconst opSpaceId = context.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t\t// Summaries can only contain finalized op-space ids unless they also include the originator's session id somewhere.\n\t\t\t\t\t// This is not the case for forest summaries at the time of writing, so non-finalized ids are instead written using\n\t\t\t\t\t// their long form (by falling through to the original cursor value).\n\t\t\t\t\t// 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.\n\t\t\t\t\t// TODO: isFinalId should probably be exported from id-compressor and that could be used to do the narrowing here.\n\t\t\t\t\tif (!context.isSummary || opSpaceId >= 0) {\n\t\t\t\t\t\treturn opSpaceId;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcontext: EncoderContext,\n\t\toutputBuffer: BufferFormat<EncodedChunkShapeV1OrV2>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, context), this.value, outputBuffer);\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tcursor.enterField(brand(fieldEncoder.key));\n\t\t\tfieldEncoder.encoder.encodeField(cursor, context, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst otherFieldsBuffer: BufferFormat<EncodedChunkShapeV1OrV2> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.specializedFieldKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.otherFieldsEncoder !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\totherFieldsBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.otherFieldsEncoder.encodeField(cursor, context, otherFieldsBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\toutputBuffer.push(otherFieldsBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,\n\t): EncodedChunkShapeV1OrV2 {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape<EncodedChunkShapeV1OrV2>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tidentifiers.add(fieldEncoder.key);\n\t\t\tshapeDiscovered(fieldEncoder.encoder.shape);\n\t\t}\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\tshapeDiscovered(this.otherFieldsEncoder.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): Shape<EncodedChunkShapeV1OrV2> {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfieldEncoders: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,\n): EncodedFieldShape[] | undefined {\n\tif (fieldEncoders.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fieldEncoders.map((fieldEncoder) => [\n\t\t// key\n\t\tencodeIdentifier(fieldEncoder.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tencoder: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,\n): number | undefined {\n\treturn encoder === undefined ? undefined : dedupShape(encoder.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShapeV1OrV2>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShapeV1OrV2>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
1
+ {"version":3,"file":"nodeEncoder.js","sourceRoot":"","sources":["../../../../src/feature-libraries/chunked-forest/codec/nodeEncoder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,qEAA+E;AAE/E,qDAMgC;AAChC,qDAA+C;AAG/C,uEAAsF;AACtF,+DAM+B;AAO/B;;;;;GAKG;AACH,MAAa,qBAAsB,SAAQ,+BAAwB;IAOlE,YACiB,IAA0C,EAC1C,KAAwB;IACxC;;;;;;;;;;OAUG;IACa,wBAAsD;IACtE;;;OAGG;IACa,kBAA4C;QAE5D,KAAK,EAAE,CAAC;QApBQ,SAAI,GAAJ,IAAI,CAAsC;QAC1C,UAAK,GAAL,KAAK,CAAmB;QAYxB,6BAAwB,GAAxB,wBAAwB,CAA8B;QAKtD,uBAAkB,GAAlB,kBAAkB,CAA0B;QAG5D,IAAI,CAAC,oBAAoB,GAA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,8CAcC;AAED,SAAS,gBAAgB,CACxB,UAAkB,EAClB,WAAuC;IAEvC,OAAO,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,wBAAwB,CAChC,UAA8B,EAC9B,WAAuC;IAEvC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,wBAAwB,CAChC,OAAiC,EACjC,MAAoD;IAEpD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAClB,KAA+B,EAC/B,MAAoD;IAEpD,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isFinalId, isStableId } from \"@fluidframework/id-compressor/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\ttype TreeNodeSchemaIdentifier,\n\tforEachField,\n\ttype Value,\n} from \"../../../core/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport type { Counter, DeduplicationTable } from \"./chunkCodecUtilities.js\";\nimport { type BufferFormat, IdentifierToken, Shape } from \"./chunkEncodingGeneric.js\";\nimport {\n\ttype EncoderContext,\n\ttype FieldEncoder,\n\ttype KeyedFieldEncoder,\n\ttype NodeEncoder,\n\tencodeValue,\n} from \"./compressedEncode.js\";\nimport type {\n\tEncodedChunkShape,\n\tEncodedFieldShape,\n\tEncodedValueShape,\n} from \"./format/index.js\";\n\n/**\n * Encodes a node with the {@link EncodedNodeShape} shape.\n * @remarks\n * The fact this is also a Shape is an implementation detail of the encoder: that allows the shape it uses to be itself,\n * which is an easy way to keep all the related code together without extra objects.\n */\nexport class NodeShapeBasedEncoder extends Shape<EncodedChunkShape> implements NodeEncoder {\n\t/**\n\t * Set of keys for fields that are encoded using {@link NodeShapeBasedEncoder.specializedFieldEncoders}.\n\t * TODO: Ensure uniform chunks, encoding and identifier generation sort fields the same.\n\t */\n\tprivate readonly specializedFieldKeys: Set<FieldKey>;\n\n\tpublic constructor(\n\t\tpublic readonly type: undefined | TreeNodeSchemaIdentifier,\n\t\tpublic readonly value: EncodedValueShape,\n\t\t/**\n\t\t * Encoders for a specific set of fields, by key, in the order they will be encoded.\n\t\t * These are fields for which specialized encoding is provided as an optimization.\n\t\t * Using these for a given field instead of falling back to {@link NodeShapeBasedEncoder.specializedFieldEncoders} is often more efficient:\n\t\t * this avoids the need to explicitly include the key and shape in the encoded data for each node instance.\n\t\t * Instead, this information is here, and thus is encoded only once as part of the node shape.\n\t\t * These encoders will be used, even if the field they apply to is empty (which can add overhead for fields which are usually empty).\n\t\t *\n\t\t * Any fields not included here will be encoded using {@link NodeShapeBasedEncoder.otherFieldsEncoder}.\n\t\t * If {@link NodeShapeBasedEncoder.otherFieldsEncoder} is undefined, then this must handle all non-empty fields.\n\t\t */\n\t\tpublic readonly specializedFieldEncoders: readonly KeyedFieldEncoder[],\n\t\t/**\n\t\t * Encoder for all other fields that are not in {@link NodeShapeBasedEncoder.specializedFieldEncoders}. These fields must\n\t\t * be encoded after the specialized fields.\n\t\t */\n\t\tpublic readonly otherFieldsEncoder: undefined | FieldEncoder,\n\t) {\n\t\tsuper();\n\t\tthis.specializedFieldKeys = new Set(this.specializedFieldEncoders.map((f) => f.key));\n\t}\n\n\tprivate getValueToEncode(cursor: ITreeCursorSynchronous, context: EncoderContext): Value {\n\t\tif (this.value === 0) {\n\t\t\tassert(typeof cursor.value === \"string\", 0x9aa /* identifier must be type string */);\n\t\t\tif (isStableId(cursor.value)) {\n\t\t\t\tconst sessionSpaceCompressedId = context.idCompressor.tryRecompress(cursor.value);\n\t\t\t\tif (sessionSpaceCompressedId !== undefined) {\n\t\t\t\t\tconst opSpaceId = context.idCompressor.normalizeToOpSpace(sessionSpaceCompressedId);\n\t\t\t\t\t// Summaries can only contain finalized op-space ids unless they also include the originator's session id somewhere.\n\t\t\t\t\t// This is not the case for forest summaries at the time of writing, so non-finalized ids are instead written using\n\t\t\t\t\t// their long form (by falling through to the original cursor value).\n\t\t\t\t\t// 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.\n\t\t\t\t\tif (!context.isSummary || isFinalId(opSpaceId)) {\n\t\t\t\t\t\treturn opSpaceId;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cursor.value;\n\t}\n\n\tpublic encodeNode(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tcontext: EncoderContext,\n\t\toutputBuffer: BufferFormat<EncodedChunkShape>,\n\t): void {\n\t\tif (this.type === undefined) {\n\t\t\toutputBuffer.push(new IdentifierToken(cursor.type));\n\t\t} else {\n\t\t\tassert(cursor.type === this.type, 0x741 /* type must match shape */);\n\t\t}\n\t\tencodeValue(this.getValueToEncode(cursor, context), this.value, outputBuffer);\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tcursor.enterField(brand(fieldEncoder.key));\n\t\t\tfieldEncoder.encoder.encodeField(cursor, context, outputBuffer);\n\t\t\tcursor.exitField();\n\t\t}\n\n\t\tconst otherFieldsBuffer: BufferFormat<EncodedChunkShape> = [];\n\n\t\tforEachField(cursor, () => {\n\t\t\tconst key = cursor.getFieldKey();\n\t\t\tif (!this.specializedFieldKeys.has(key)) {\n\t\t\t\tassert(\n\t\t\t\t\tthis.otherFieldsEncoder !== undefined,\n\t\t\t\t\t0x742 /* had extra local fields when shape does not support them */,\n\t\t\t\t);\n\t\t\t\totherFieldsBuffer.push(new IdentifierToken(key));\n\t\t\t\tthis.otherFieldsEncoder.encodeField(cursor, context, otherFieldsBuffer);\n\t\t\t}\n\t\t});\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\toutputBuffer.push(otherFieldsBuffer);\n\t\t}\n\t}\n\n\tpublic encodeShape(\n\t\tidentifiers: DeduplicationTable<string>,\n\t\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n\t): EncodedChunkShape {\n\t\treturn {\n\t\t\tc: {\n\t\t\t\ttype: encodeOptionalIdentifier(this.type, identifiers),\n\t\t\t\tvalue: this.value,\n\t\t\t\tfields: encodeFieldShapes(this.specializedFieldEncoders, identifiers, shapes),\n\t\t\t\textraFields: encodeOptionalFieldShape(this.otherFieldsEncoder, shapes),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic countReferencedShapesAndIdentifiers(\n\t\tidentifiers: Counter<string>,\n\t\tshapeDiscovered: (shape: Shape<EncodedChunkShape>) => void,\n\t): void {\n\t\tif (this.type !== undefined) {\n\t\t\tidentifiers.add(this.type);\n\t\t}\n\n\t\tfor (const fieldEncoder of this.specializedFieldEncoders) {\n\t\t\tidentifiers.add(fieldEncoder.key);\n\t\t\tshapeDiscovered(fieldEncoder.encoder.shape);\n\t\t}\n\n\t\tif (this.otherFieldsEncoder !== undefined) {\n\t\t\tshapeDiscovered(this.otherFieldsEncoder.shape);\n\t\t}\n\t}\n\n\tpublic get shape(): Shape<EncodedChunkShape> {\n\t\treturn this;\n\t}\n}\n\nexport function encodeFieldShapes(\n\tfieldEncoders: readonly KeyedFieldEncoder[],\n\tidentifiers: DeduplicationTable<string>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): EncodedFieldShape[] | undefined {\n\tif (fieldEncoders.length === 0) {\n\t\treturn undefined;\n\t}\n\treturn fieldEncoders.map((fieldEncoder) => [\n\t\t// key\n\t\tencodeIdentifier(fieldEncoder.key, identifiers),\n\t\t// shape\n\t\tshapes.valueToIndex.get(fieldEncoder.encoder.shape) ?? fail(0xb50 /* missing shape */),\n\t]);\n}\n\nfunction encodeIdentifier(\n\tidentifier: string,\n\tidentifiers: DeduplicationTable<string>,\n): string | number {\n\treturn identifiers.valueToIndex.get(identifier) ?? identifier;\n}\n\nfunction encodeOptionalIdentifier(\n\tidentifier: string | undefined,\n\tidentifiers: DeduplicationTable<string>,\n): string | number | undefined {\n\treturn identifier === undefined ? undefined : encodeIdentifier(identifier, identifiers);\n}\n\nfunction encodeOptionalFieldShape(\n\tencoder: FieldEncoder | undefined,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number | undefined {\n\treturn encoder === undefined ? undefined : dedupShape(encoder.shape, shapes);\n}\n\nfunction dedupShape(\n\tshape: Shape<EncodedChunkShape>,\n\tshapes: DeduplicationTable<Shape<EncodedChunkShape>>,\n): number {\n\treturn shapes.valueToIndex.get(shape) ?? fail(0xb51 /* missing shape */);\n}\n"]}
@@ -57,6 +57,15 @@ export declare class TreeShape {
57
57
  readonly fields: ReadonlyMap<FieldKey, OffsetShape>;
58
58
  readonly fieldsOffsetArray: readonly OffsetShape[];
59
59
  readonly valuesPerTopLevelNode: number;
60
+ /**
61
+ * Information about every node in this shape.
62
+ * The root is first, and all indexes it uses to refer to other nodes are indexes into this array.
63
+ * Beyond that the ordering is an implementation detail of this shape.
64
+ * @remarks
65
+ * Use of this in contexts where there might be multiple top-level nodes requires some additional care.
66
+ * For example {@link Cursor} derives each node's actual position info from this shared
67
+ * array plus the node's top-level index within the chunk.
68
+ */
60
69
  readonly positions: readonly NodePositionInfo[];
61
70
  /**
62
71
  * Whether chunks using this shape (including any descendant leaf within it) may contain values compressed by the {@link UniformChunk.idCompressor}.
@@ -89,16 +98,16 @@ export declare class TreeShape {
89
98
  /**
90
99
  * The shape (see `TreeShape`) of a sequence of trees, all with the same shape (like `FieldShape`, but without a field key).
91
100
  *
92
- * This shape is optimized (by caching derived data like the positions array),
93
- * so that when paired with a value array it can be efficiently traversed like a tree by an {@link ITreeCursorSynchronous}.
94
- * See {@link uniformChunk} for how to do this.
101
+ * @remarks
102
+ * Paired with a value array, this lets a {@link UniformChunk} be traversed like a tree by an
103
+ * {@link ITreeCursorSynchronous}. The {@link Cursor} derives each node's position info from the
104
+ * shared {@link TreeShape.positions} plus the node's top-level index.
95
105
  *
96
106
  * TODO: consider storing shape information in WASM
97
107
  */
98
108
  export declare class ChunkShape {
99
109
  readonly treeShape: TreeShape;
100
110
  readonly topLevelLength: number;
101
- readonly positions: readonly (NodePositionInfo | undefined)[];
102
111
  constructor(treeShape: TreeShape, topLevelLength: number);
103
112
  equals(other: ChunkShape): boolean;
104
113
  }
@@ -122,7 +131,7 @@ declare class OffsetShape {
122
131
  constructor(shape: TreeShape, topLevelLength: number, offset: number, key: FieldKey, indexOfParentField: number | undefined);
123
132
  }
124
133
  /**
125
- * Information about a node at a specific position within a uniform chunk.
134
+ * Information about a node at a specific position within one top-level tree of a {@link TreeShape}.
126
135
  */
127
136
  declare class NodePositionInfo implements UpPath {
128
137
  readonly parent: NodePositionInfo | undefined;
@@ -134,13 +143,15 @@ declare class NodePositionInfo implements UpPath {
134
143
  readonly topLevelLength: number;
135
144
  readonly valueOffset: number;
136
145
  /**
137
- * @param parent - TODO
138
- * @param parentField - TODO
146
+ * @param parent - The parent node's {@link NodePositionInfo} or `undefined` for a root.
147
+ * @param parentField - The {@link FieldKey} of the field this node occupies within its parent.
139
148
  * @param parentIndex - indexWithinParentField
140
- * @param indexOfParentField - which field of the parent `parentIndex` is indexing into to locate this.
141
- * @param indexOfParentPosition - Index of parent NodePositionInfo in positions array. TODO: use offsets to avoid copying at top level?
149
+ * @param indexOfParentField - Which field of the parent `parentIndex` is indexing into to locate this.
150
+ * @param indexOfParentPosition - Index of this node's parent in {@link TreeShape.positions}
142
151
  * @param shape - Shape of the top level sequence this node is part of
143
- * @param valueOffset - TODO
152
+ * @param topLevelLength - Number of siblings in this node's field. For a root this is unused
153
+ * @param valueOffset - Offset of this node's value within one top-level tree's slice of the chunk's flat `values` array;
154
+ * only valid when `shape.hasValue` (otherwise it's where the value would have gone, and should not be used to read a value).
144
155
  */
145
156
  constructor(parent: NodePositionInfo | undefined, // TODO; general UpPath to allow prefixing here?
146
157
  parentField: FieldKey, parentIndex: number, indexOfParentField: number | undefined, indexOfParentPosition: number | undefined, shape: TreeShape, // Shape of sequence that contains this node (top level is parent of this node)
@@ -149,14 +160,25 @@ declare class NodePositionInfo implements UpPath {
149
160
  /**
150
161
  * The cursor implementation for `UniformChunk`.
151
162
  *
152
- * Works by tracking its location in the chunk's `positions` array.
163
+ * @remarks
164
+ * Tracks a flat `positionIndex` and derives each node's position info from the shape's shared
165
+ * {@link TreeShape.positions} plus the node's top-level index.
153
166
  */
154
167
  declare class Cursor extends SynchronousCursor implements ChunkedCursor {
155
168
  private readonly chunk;
156
169
  private positionIndex;
170
+ /** Position info for the current node, or `undefined` when in root field. */
157
171
  private nodePositionInfo;
172
+ /** Which top-level node of the chunk the current position is within. Valid when nodePositionInfo !== undefined. */
173
+ private topLevelIndex;
174
+ /** The chunk's shape. */
158
175
  private readonly shape;
159
- private readonly positions;
176
+ /** The chunk's per-tree shape (shape of each top-level tree). */
177
+ private readonly treeShape;
178
+ /** Number of positions in one top-level tree (treeShape.positions.length). */
179
+ private readonly nodeLength;
180
+ /** Number of values per top-level node (treeShape.valuesPerTopLevelNode). */
181
+ private readonly stride;
160
182
  mode: CursorLocationType;
161
183
  private fieldKey?;
162
184
  private indexOfField;
@@ -166,12 +188,32 @@ declare class Cursor extends SynchronousCursor implements ChunkedCursor {
166
188
  fork(): Cursor;
167
189
  /**
168
190
  * Change the current node within the chunk.
191
+ *
192
+ * @param positionIndex - flat position index of the newly selected node. This is NOT an index
193
+ * within a field, and is not bounds checked.
194
+ *
195
+ * @remarks
196
+ * Decomposes the index into {@link Cursor.topLevelIndex} and {@link Cursor.nodePositionInfo}.
169
197
  * See `nodeInfo` for getting data about the current node.
170
198
  *
171
- * @param positionIndex - index of the position of the newly selected node in `positions`.
172
- * This is NOT an index within a field, and is not bounds checked.
173
199
  */
174
200
  private moveToPosition;
201
+ /**
202
+ * Decode a flat `positionIndex` into its components.
203
+ *
204
+ * @param positionIndex - flat position index of the node to decode. Must be greater than 0;
205
+ * @returns the node's index within {@link TreeShape.positions} (`withinTree`), which top-level
206
+ * tree holds it (`topLevelIndex`), and the corresponding shared {@link NodePositionInfo} (`info`).
207
+ */
208
+ private decodePosition;
209
+ /**
210
+ * Build a standalone {@link UpPath} for the node at `positionIndex`. O(depth) allocation.
211
+ *
212
+ * @remarks
213
+ * walks the shared per-tree {@link TreeShape.positions} and applies the top-level index
214
+ * at each level. Mirrors how the `BasicChunk` cursor allocates paths.
215
+ */
216
+ private materializePath;
175
217
  /**
176
218
  * Gets information about the current node.
177
219
  *
@@ -199,6 +241,16 @@ declare class Cursor extends SynchronousCursor implements ChunkedCursor {
199
241
  getPath(prefix?: PathRootPrefix): UpPath | undefined;
200
242
  get fieldIndex(): number;
201
243
  readonly chunkStart: number;
244
+ /**
245
+ * Number of nodes in `info`'s field including `info` itself.
246
+ *
247
+ * @remarks
248
+ * For top-level nodes this is the chunk's `topLevelLength`, read from the chunk
249
+ * rather than the node, so the shared per-tree {@link TreeShape.positions} stays independent of
250
+ * chunk length; the root entry's own `topLevelLength` field is unused. Nested nodes use the
251
+ * field length stored on the node.
252
+ */
253
+ private siblingCount;
202
254
  get chunkLength(): number;
203
255
  seekNodes(offset: number): boolean;
204
256
  nextNode(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"uniformChunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/uniformChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE7F,OAAO,EACN,kBAAkB,EAClB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK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gBxB;CACD"}
@@ -153,9 +153,10 @@ function clonePositions(indexOfParentInOutput, [key, shape, copies], indexOfPare
153
153
  /**
154
154
  * The shape (see `TreeShape`) of a sequence of trees, all with the same shape (like `FieldShape`, but without a field key).
155
155
  *
156
- * This shape is optimized (by caching derived data like the positions array),
157
- * so that when paired with a value array it can be efficiently traversed like a tree by an {@link ITreeCursorSynchronous}.
158
- * See {@link uniformChunk} for how to do this.
156
+ * @remarks
157
+ * Paired with a value array, this lets a {@link UniformChunk} be traversed like a tree by an
158
+ * {@link ITreeCursorSynchronous}. The {@link Cursor} derives each node's position info from the
159
+ * shared {@link TreeShape.positions} plus the node's top-level index.
159
160
  *
160
161
  * TODO: consider storing shape information in WASM
161
162
  */
@@ -164,10 +165,6 @@ class ChunkShape {
164
165
  this.treeShape = treeShape;
165
166
  this.topLevelLength = topLevelLength;
166
167
  (0, internal_1.assert)(topLevelLength > 0, 0x4c6 /* topLevelLength must be greater than 0 */);
167
- // TODO: avoid duplication from inner loop
168
- const positions = [undefined];
169
- clonePositions(0, [index_js_1.dummyRoot, treeShape, topLevelLength], 0, 0, positions);
170
- this.positions = positions;
171
168
  }
172
169
  equals(other) {
173
170
  // TODO: either dedup instances and/or store a collision resistant hash for fast compare.
@@ -196,17 +193,19 @@ class OffsetShape {
196
193
  }
197
194
  }
198
195
  /**
199
- * Information about a node at a specific position within a uniform chunk.
196
+ * Information about a node at a specific position within one top-level tree of a {@link TreeShape}.
200
197
  */
201
198
  class NodePositionInfo {
202
199
  /**
203
- * @param parent - TODO
204
- * @param parentField - TODO
200
+ * @param parent - The parent node's {@link NodePositionInfo} or `undefined` for a root.
201
+ * @param parentField - The {@link FieldKey} of the field this node occupies within its parent.
205
202
  * @param parentIndex - indexWithinParentField
206
- * @param indexOfParentField - which field of the parent `parentIndex` is indexing into to locate this.
207
- * @param indexOfParentPosition - Index of parent NodePositionInfo in positions array. TODO: use offsets to avoid copying at top level?
203
+ * @param indexOfParentField - Which field of the parent `parentIndex` is indexing into to locate this.
204
+ * @param indexOfParentPosition - Index of this node's parent in {@link TreeShape.positions}
208
205
  * @param shape - Shape of the top level sequence this node is part of
209
- * @param valueOffset - TODO
206
+ * @param topLevelLength - Number of siblings in this node's field. For a root this is unused
207
+ * @param valueOffset - Offset of this node's value within one top-level tree's slice of the chunk's flat `values` array;
208
+ * only valid when `shape.hasValue` (otherwise it's where the value would have gone, and should not be used to read a value).
210
209
  */
211
210
  constructor(parent, // TODO; general UpPath to allow prefixing here?
212
211
  parentField, parentIndex, indexOfParentField, indexOfParentPosition, shape, // Shape of sequence that contains this node (top level is parent of this node)
@@ -224,20 +223,26 @@ class NodePositionInfo {
224
223
  /**
225
224
  * The cursor implementation for `UniformChunk`.
226
225
  *
227
- * Works by tracking its location in the chunk's `positions` array.
226
+ * @remarks
227
+ * Tracks a flat `positionIndex` and derives each node's position info from the shape's shared
228
+ * {@link TreeShape.positions} plus the node's top-level index.
228
229
  */
229
230
  class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
230
231
  // TODO: support prefix (path above root, including index offset of chunk in its containing field)
231
232
  constructor(chunk) {
232
233
  super();
233
234
  this.chunk = chunk;
235
+ /** Which top-level node of the chunk the current position is within. Valid when nodePositionInfo !== undefined. */
236
+ this.topLevelIndex = 0;
234
237
  this.mode = 1 /* CursorLocationType.Fields */;
235
238
  // Valid only in fields mode. Can be past end for empty fields.
236
239
  // This is redundant with fieldKey above (but might be worth keeping for perf), and could be removed.
237
240
  this.indexOfField = 0;
238
241
  this.chunkStart = 0;
239
242
  this.shape = this.chunk.shape;
240
- this.positions = this.shape.positions;
243
+ this.treeShape = this.shape.treeShape;
244
+ this.nodeLength = this.treeShape.positions.length;
245
+ this.stride = this.treeShape.valuesPerTopLevelNode;
241
246
  this.fieldKey = index_js_1.dummyRoot;
242
247
  this.moveToPosition(0);
243
248
  }
@@ -259,18 +264,62 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
259
264
  }
260
265
  /**
261
266
  * Change the current node within the chunk.
267
+ *
268
+ * @param positionIndex - flat position index of the newly selected node. This is NOT an index
269
+ * within a field, and is not bounds checked.
270
+ *
271
+ * @remarks
272
+ * Decomposes the index into {@link Cursor.topLevelIndex} and {@link Cursor.nodePositionInfo}.
262
273
  * See `nodeInfo` for getting data about the current node.
263
274
  *
264
- * @param positionIndex - index of the position of the newly selected node in `positions`.
265
- * This is NOT an index within a field, and is not bounds checked.
266
275
  */
267
276
  moveToPosition(positionIndex) {
268
- this.nodePositionInfo = this.positions[positionIndex];
269
277
  this.positionIndex = positionIndex;
270
- if (this.nodePositionInfo === undefined) {
271
- (0, internal_1.assert)(positionIndex === 0, 0x561 /* expected root at start */);
278
+ if (positionIndex === 0) {
279
+ this.nodePositionInfo = undefined;
272
280
  (0, internal_1.assert)(this.mode === 1 /* CursorLocationType.Fields */, 0x562 /* expected root to be a field */);
281
+ return;
273
282
  }
283
+ const decoded = this.decodePosition(positionIndex);
284
+ this.topLevelIndex = decoded.topLevelIndex;
285
+ this.nodePositionInfo = decoded.info;
286
+ }
287
+ /**
288
+ * Decode a flat `positionIndex` into its components.
289
+ *
290
+ * @param positionIndex - flat position index of the node to decode. Must be greater than 0;
291
+ * @returns the node's index within {@link TreeShape.positions} (`withinTree`), which top-level
292
+ * tree holds it (`topLevelIndex`), and the corresponding shared {@link NodePositionInfo} (`info`).
293
+ */
294
+ decodePosition(positionIndex) {
295
+ const offset = positionIndex - 1;
296
+ // Find the node's index within treeShape.positions, then which top-level tree holds it.
297
+ const withinTree = offset % this.nodeLength; // remainder
298
+ const topLevelIndex = (offset - withinTree) / this.nodeLength; // quotient
299
+ const info = this.treeShape.positions[withinTree] ?? (0, internal_1.oob)();
300
+ return { withinTree, topLevelIndex, info };
301
+ }
302
+ /**
303
+ * Build a standalone {@link UpPath} for the node at `positionIndex`. O(depth) allocation.
304
+ *
305
+ * @remarks
306
+ * walks the shared per-tree {@link TreeShape.positions} and applies the top-level index
307
+ * at each level. Mirrors how the `BasicChunk` cursor allocates paths.
308
+ */
309
+ materializePath(positionIndex) {
310
+ if (positionIndex === 0) {
311
+ return undefined;
312
+ }
313
+ const { withinTree, topLevelIndex, info } = this.decodePosition(positionIndex);
314
+ if (info.parent === undefined) {
315
+ // Top-level node: its parent is the (prefixed) chunk root.
316
+ return { parent: undefined, parentField: info.parentField, parentIndex: topLevelIndex };
317
+ }
318
+ return {
319
+ parent: this.materializePath(positionIndex - withinTree + (info.indexOfParentPosition ?? (0, internal_1.oob)())),
320
+ parentField: info.parentField,
321
+ parentIndex: info.parentIndex,
322
+ };
274
323
  }
275
324
  /**
276
325
  * Gets information about the current node.
@@ -364,29 +413,43 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
364
413
  enterRootNodeInner(childIndex) {
365
414
  this.mode = 0 /* CursorLocationType.Nodes */;
366
415
  this.fieldKey = undefined;
367
- // 1 for the "undefined" at the beginning of the positions array, then stride by top level tree shape.
368
- this.moveToPosition(1 + childIndex * this.shape.treeShape.positions.length);
416
+ // 1 for the "undefined" root-field marker at position 0, then stride by one top-level tree (nodeLength).
417
+ this.moveToPosition(1 + childIndex * this.nodeLength);
369
418
  (0, internal_1.assert)(this.fieldIndex === childIndex, 0x543 /* should be at selected child */);
370
419
  }
371
420
  getFieldPath(prefix) {
372
421
  return (0, treeCursorUtils_js_1.prefixFieldPath)(prefix, {
373
422
  field: this.getFieldKey(),
374
- parent: this.nodePositionInfo,
423
+ parent: this.materializePath(this.positionIndex),
375
424
  });
376
425
  }
377
426
  getPath(prefix) {
378
- return (0, treeCursorUtils_js_1.prefixPath)(prefix, this.nodeInfo(0 /* CursorLocationType.Nodes */));
427
+ this.nodeInfo(0 /* CursorLocationType.Nodes */); // assert: in nodes mode at a node
428
+ return (0, treeCursorUtils_js_1.prefixPath)(prefix, this.materializePath(this.positionIndex));
379
429
  }
380
430
  get fieldIndex() {
381
- return this.nodeInfo(0 /* CursorLocationType.Nodes */).parentIndex;
431
+ const info = this.nodeInfo(0 /* CursorLocationType.Nodes */);
432
+ return info.parent === undefined ? this.topLevelIndex : info.parentIndex;
433
+ }
434
+ /**
435
+ * Number of nodes in `info`'s field including `info` itself.
436
+ *
437
+ * @remarks
438
+ * For top-level nodes this is the chunk's `topLevelLength`, read from the chunk
439
+ * rather than the node, so the shared per-tree {@link TreeShape.positions} stays independent of
440
+ * chunk length; the root entry's own `topLevelLength` field is unused. Nested nodes use the
441
+ * field length stored on the node.
442
+ */
443
+ siblingCount(info) {
444
+ return info.parent === undefined ? this.shape.topLevelLength : info.topLevelLength;
382
445
  }
383
446
  get chunkLength() {
384
- return this.nodeInfo(0 /* CursorLocationType.Nodes */).topLevelLength;
447
+ return this.siblingCount(this.nodeInfo(0 /* CursorLocationType.Nodes */));
385
448
  }
386
449
  seekNodes(offset) {
387
450
  const info = this.nodeInfo(0 /* CursorLocationType.Nodes */);
388
- const index = offset + info.parentIndex;
389
- if (index >= 0 && index < info.topLevelLength) {
451
+ const index = offset + this.fieldIndex;
452
+ if (index >= 0 && index < this.siblingCount(info)) {
390
453
  this.moveToPosition(this.positionIndex + offset * info.shape.positions.length);
391
454
  return true;
392
455
  }
@@ -396,8 +459,8 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
396
459
  nextNode() {
397
460
  // This is the same as `return this.seekNodes(1);` but slightly faster.
398
461
  const info = this.nodeInfo(0 /* CursorLocationType.Nodes */);
399
- const index = info.parentIndex + 1;
400
- if (index === info.topLevelLength) {
462
+ const index = this.fieldIndex + 1;
463
+ if (index === this.siblingCount(info)) {
401
464
  this.exitNode();
402
465
  return false;
403
466
  }
@@ -406,13 +469,15 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
406
469
  }
407
470
  exitNode() {
408
471
  const info = this.nodeInfo(0 /* CursorLocationType.Nodes */);
409
- this.indexOfField =
410
- info.indexOfParentField ??
411
- (0, internal_1.fail)(0xb0a /* navigation up to root field not yet supported */); // TODO;
472
+ const withinTree = this.positionIndex - 1 - this.topLevelIndex * this.nodeLength;
473
+ // Top-level nodes (no parent) exit to the root field at position 0;
474
+ // nested nodes' parent is `indexOfParentPosition` within the same top-level instance.
475
+ this.indexOfField = info.indexOfParentField ?? 0;
412
476
  this.fieldKey = info.parentField;
413
477
  this.mode = 1 /* CursorLocationType.Fields */;
414
- this.moveToPosition(info.indexOfParentPosition ??
415
- (0, internal_1.fail)(0xb0b /* navigation up to root field not yet supported */)); // TODO
478
+ this.moveToPosition(info.indexOfParentPosition === undefined
479
+ ? 0
480
+ : this.positionIndex - withinTree + info.indexOfParentPosition);
416
481
  }
417
482
  firstField() {
418
483
  const fieldsArray = this.nodeInfo(0 /* CursorLocationType.Nodes */).shape.fieldsArray;
@@ -441,7 +506,7 @@ class Cursor extends treeCursorUtils_js_1.SynchronousCursor {
441
506
  get value() {
442
507
  const info = this.nodeInfo(0 /* CursorLocationType.Nodes */);
443
508
  if (info.shape.hasValue) {
444
- const value = this.chunk.values[info.valueOffset];
509
+ const value = this.chunk.values[info.valueOffset + this.topLevelIndex * this.stride];
445
510
  // If mayContainCompressedIds is set, check if the value is a number (i.e. a compressed ID that needs decompression).
446
511
  if (info.shape.mayContainCompressedIds && typeof value === "number") {
447
512
  const idCompressor = this.chunk.idCompressor;