@fluidframework/tree 2.91.0 → 2.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (866) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/api-report/tree.alpha.api.md +60 -22
  3. package/dist/api.d.ts +6 -1
  4. package/dist/api.d.ts.map +1 -1
  5. package/dist/api.js.map +1 -1
  6. package/dist/codec/codec.d.ts +28 -2
  7. package/dist/codec/codec.d.ts.map +1 -1
  8. package/dist/codec/codec.js +1 -0
  9. package/dist/codec/codec.js.map +1 -1
  10. package/dist/codec/index.d.ts +2 -2
  11. package/dist/codec/index.d.ts.map +1 -1
  12. package/dist/codec/index.js +2 -4
  13. package/dist/codec/index.js.map +1 -1
  14. package/dist/codec/versioned/codec.d.ts +18 -36
  15. package/dist/codec/versioned/codec.d.ts.map +1 -1
  16. package/dist/codec/versioned/codec.js +46 -59
  17. package/dist/codec/versioned/codec.js.map +1 -1
  18. package/dist/codec/versioned/index.d.ts +1 -1
  19. package/dist/codec/versioned/index.d.ts.map +1 -1
  20. package/dist/codec/versioned/index.js +2 -4
  21. package/dist/codec/versioned/index.js.map +1 -1
  22. package/dist/core/forest/forest.d.ts +5 -2
  23. package/dist/core/forest/forest.d.ts.map +1 -1
  24. package/dist/core/forest/forest.js.map +1 -1
  25. package/dist/core/index.d.ts +1 -1
  26. package/dist/core/index.d.ts.map +1 -1
  27. package/dist/core/index.js +6 -2
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/core/rebase/changeRebaser.d.ts +8 -1
  30. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  31. package/dist/core/rebase/changeRebaser.js.map +1 -1
  32. package/dist/core/rebase/revisionTagCodec.d.ts +4 -3
  33. package/dist/core/rebase/revisionTagCodec.d.ts.map +1 -1
  34. package/dist/core/rebase/revisionTagCodec.js +2 -0
  35. package/dist/core/rebase/revisionTagCodec.js.map +1 -1
  36. package/dist/core/rebase/utils.d.ts +2 -2
  37. package/dist/core/rebase/utils.d.ts.map +1 -1
  38. package/dist/core/rebase/utils.js +4 -4
  39. package/dist/core/rebase/utils.js.map +1 -1
  40. package/dist/core/schema-stored/formatV2.d.ts +1 -1
  41. package/dist/core/schema-stored/formatV2.js +1 -1
  42. package/dist/core/schema-stored/formatV2.js.map +1 -1
  43. package/dist/core/tree/anchorSet.d.ts +8 -0
  44. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  45. package/dist/core/tree/anchorSet.js +42 -7
  46. package/dist/core/tree/anchorSet.js.map +1 -1
  47. package/dist/core/tree/cursor.d.ts +25 -1
  48. package/dist/core/tree/cursor.d.ts.map +1 -1
  49. package/dist/core/tree/cursor.js +45 -1
  50. package/dist/core/tree/cursor.js.map +1 -1
  51. package/dist/core/tree/deltaUtil.d.ts +13 -1
  52. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  53. package/dist/core/tree/deltaUtil.js +34 -1
  54. package/dist/core/tree/deltaUtil.js.map +1 -1
  55. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -5
  56. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  57. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  58. package/dist/core/tree/index.d.ts +2 -2
  59. package/dist/core/tree/index.d.ts.map +1 -1
  60. package/dist/core/tree/index.js +6 -2
  61. package/dist/core/tree/index.js.map +1 -1
  62. package/dist/core/tree/visitDelta.d.ts +11 -0
  63. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  64. package/dist/core/tree/visitDelta.js +1 -1
  65. package/dist/core/tree/visitDelta.js.map +1 -1
  66. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  67. package/dist/core/tree/visitorUtils.js +5 -0
  68. package/dist/core/tree/visitorUtils.js.map +1 -1
  69. package/dist/entrypoints/alpha.d.ts +1 -1
  70. package/dist/entrypoints/alpha.d.ts.map +1 -1
  71. package/dist/entrypoints/alpha.js +2 -3
  72. package/dist/entrypoints/alpha.js.map +1 -1
  73. package/dist/entrypoints/beta.js +1 -1
  74. package/dist/entrypoints/beta.js.map +1 -1
  75. package/dist/entrypoints/legacy.d.ts +1 -1
  76. package/dist/entrypoints/legacy.d.ts.map +1 -1
  77. package/dist/entrypoints/legacy.js +1 -1
  78. package/dist/entrypoints/legacy.js.map +1 -1
  79. package/dist/entrypoints/public.js +1 -1
  80. package/dist/entrypoints/public.js.map +1 -1
  81. package/dist/feature-libraries/changeAtomIdCodec.d.ts +4 -3
  82. package/dist/feature-libraries/changeAtomIdCodec.d.ts.map +1 -1
  83. package/dist/feature-libraries/changeAtomIdCodec.js +2 -0
  84. package/dist/feature-libraries/changeAtomIdCodec.js.map +1 -1
  85. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +2 -1
  86. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  88. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +4 -4
  90. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  91. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +6 -6
  92. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  93. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  94. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  95. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -2
  97. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  99. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -4
  100. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  101. package/dist/feature-libraries/chunked-forest/codec/codecs.js +6 -6
  102. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  103. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +12 -12
  104. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  105. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  106. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  107. package/dist/feature-libraries/chunked-forest/codec/{formatGeneric.d.ts → format/formatGeneric.d.ts} +1 -1
  108. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -0
  109. package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -0
  110. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +187 -0
  111. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -0
  112. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js +115 -0
  113. package/dist/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -0
  114. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +33 -0
  115. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -0
  116. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js +16 -0
  117. package/dist/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -0
  118. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +10 -0
  119. package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -0
  120. package/dist/feature-libraries/chunked-forest/codec/format/index.js +18 -0
  121. package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -0
  122. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +93 -0
  123. package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -0
  124. package/dist/feature-libraries/chunked-forest/codec/format/versions.js +29 -0
  125. package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -0
  126. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  127. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  128. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -2
  129. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  130. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  131. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  132. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  133. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  134. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  135. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +6 -4
  136. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  137. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +1 -1
  138. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  139. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +3 -3
  140. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  141. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  142. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  143. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  144. package/dist/feature-libraries/cursorComparator.d.ts +23 -0
  145. package/dist/feature-libraries/cursorComparator.d.ts.map +1 -0
  146. package/dist/feature-libraries/cursorComparator.js +65 -0
  147. package/dist/feature-libraries/cursorComparator.js.map +1 -0
  148. package/dist/feature-libraries/forest-summary/codec.d.ts +1 -1
  149. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +3 -3
  150. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  151. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  152. package/dist/feature-libraries/index.d.ts +3 -2
  153. package/dist/feature-libraries/index.d.ts.map +1 -1
  154. package/dist/feature-libraries/index.js +5 -5
  155. package/dist/feature-libraries/index.js.map +1 -1
  156. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +2 -0
  157. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  158. package/dist/feature-libraries/indexing/anchorTreeIndex.js +12 -7
  159. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  160. package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  161. package/dist/feature-libraries/mitigatedChangeFamily.js +2 -2
  162. package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  163. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  164. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  165. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  166. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  167. package/dist/feature-libraries/modular-schema/genericFieldKind.js +0 -1
  168. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  169. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +10 -10
  170. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  171. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -4
  172. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  173. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +3 -3
  174. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  175. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  176. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +3 -3
  177. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  178. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  179. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
  180. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  181. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +4 -3
  182. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  183. package/dist/feature-libraries/object-forest/objectForest.d.ts +1 -1
  184. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  185. package/dist/feature-libraries/object-forest/objectForest.js +2 -2
  186. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  187. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +4 -4
  188. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  189. package/dist/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  190. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts +3 -3
  191. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  192. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  193. package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
  194. package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
  195. package/dist/feature-libraries/schema-edits/index.js +2 -3
  196. package/dist/feature-libraries/schema-edits/index.js.map +1 -1
  197. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -15
  198. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  199. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -54
  200. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  201. package/dist/feature-libraries/schema-index/codec.d.ts +3 -16
  202. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  203. package/dist/feature-libraries/schema-index/codec.js +1 -21
  204. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  205. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -1
  206. package/dist/feature-libraries/schema-index/formatV2.js +1 -1
  207. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  208. package/dist/feature-libraries/schema-index/index.d.ts +1 -1
  209. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  210. package/dist/feature-libraries/schema-index/index.js +1 -2
  211. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  212. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -4
  213. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  214. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  215. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +3 -3
  216. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  217. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  218. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -3
  219. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  220. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  221. package/dist/index.d.ts +2 -2
  222. package/dist/index.d.ts.map +1 -1
  223. package/dist/index.js +2 -3
  224. package/dist/index.js.map +1 -1
  225. package/dist/packageVersion.d.ts +1 -1
  226. package/dist/packageVersion.js +1 -1
  227. package/dist/packageVersion.js.map +1 -1
  228. package/dist/shared-tree/independentView.d.ts +1 -1
  229. package/dist/shared-tree/independentView.d.ts.map +1 -1
  230. package/dist/shared-tree/independentView.js +14 -21
  231. package/dist/shared-tree/independentView.js.map +1 -1
  232. package/dist/shared-tree/index.d.ts +2 -2
  233. package/dist/shared-tree/index.d.ts.map +1 -1
  234. package/dist/shared-tree/index.js +1 -2
  235. package/dist/shared-tree/index.js.map +1 -1
  236. package/dist/shared-tree/schematizingTreeView.d.ts +2 -36
  237. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  238. package/dist/shared-tree/schematizingTreeView.js +15 -117
  239. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  240. package/dist/shared-tree/sharedTree.d.ts +3 -22
  241. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  242. package/dist/shared-tree/sharedTree.js +10 -27
  243. package/dist/shared-tree/sharedTree.js.map +1 -1
  244. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +3 -2
  245. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  246. package/dist/shared-tree/sharedTreeChangeCodecs.js +23 -16
  247. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  248. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  249. package/dist/shared-tree/sharedTreeChangeEnricher.js +1 -1
  250. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  251. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  252. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  253. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  254. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  255. package/dist/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  256. package/dist/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  257. package/dist/shared-tree/sharedTreeChangeFormat.js +13 -5
  258. package/dist/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  259. package/dist/shared-tree/tree.d.ts.map +1 -1
  260. package/dist/shared-tree/tree.js +2 -1
  261. package/dist/shared-tree/tree.js.map +1 -1
  262. package/dist/shared-tree/treeAlpha.d.ts +13 -1
  263. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  264. package/dist/shared-tree/treeAlpha.js +3 -0
  265. package/dist/shared-tree/treeAlpha.js.map +1 -1
  266. package/dist/shared-tree/treeCheckout.d.ts +34 -69
  267. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  268. package/dist/shared-tree/treeCheckout.js +885 -678
  269. package/dist/shared-tree/treeCheckout.js.map +1 -1
  270. package/dist/shared-tree/unhydratedTreeContext.js +3 -3
  271. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  272. package/dist/shared-tree-core/editManagerCodecs.d.ts +23 -12
  273. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  274. package/dist/shared-tree-core/editManagerCodecs.js +40 -67
  275. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  276. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  277. package/dist/shared-tree-core/editManagerCodecsCommons.js +0 -1
  278. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  279. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +10 -2
  280. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  281. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +18 -13
  282. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  283. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  284. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  285. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +6 -9
  286. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  287. package/dist/shared-tree-core/index.d.ts +3 -3
  288. package/dist/shared-tree-core/index.d.ts.map +1 -1
  289. package/dist/shared-tree-core/index.js +5 -8
  290. package/dist/shared-tree-core/index.js.map +1 -1
  291. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -3
  292. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  293. package/dist/shared-tree-core/messageCodecV1ToV4.js +8 -8
  294. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  295. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts +2 -3
  296. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  297. package/dist/shared-tree-core/messageCodecVSharedBranches.js +5 -4
  298. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  299. package/dist/shared-tree-core/messageCodecs.d.ts +15 -14
  300. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  301. package/dist/shared-tree-core/messageCodecs.js +38 -74
  302. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  303. package/dist/shared-tree-core/messageFormat.d.ts +0 -1
  304. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  305. package/dist/shared-tree-core/messageFormat.js +1 -2
  306. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  307. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -3
  308. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  309. package/dist/shared-tree-core/sharedTreeCore.js +12 -2
  310. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  311. package/dist/sharedTreeAttributes.d.ts.map +1 -1
  312. package/dist/sharedTreeAttributes.js +3 -0
  313. package/dist/sharedTreeAttributes.js.map +1 -1
  314. package/dist/simple-tree/api/index.d.ts +1 -0
  315. package/dist/simple-tree/api/index.d.ts.map +1 -1
  316. package/dist/simple-tree/api/index.js.map +1 -1
  317. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  318. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  319. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +2 -2
  320. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  321. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  322. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  323. package/dist/simple-tree/api/storedSchema.js +6 -6
  324. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  325. package/dist/simple-tree/api/tree.d.ts +7 -19
  326. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  327. package/dist/simple-tree/api/tree.js.map +1 -1
  328. package/dist/simple-tree/api/treeAlpha.d.ts +69 -0
  329. package/dist/simple-tree/api/treeAlpha.d.ts.map +1 -0
  330. package/dist/simple-tree/api/treeAlpha.js +7 -0
  331. package/dist/simple-tree/api/treeAlpha.js.map +1 -0
  332. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  333. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  334. package/dist/simple-tree/api/treeChangeEvents.d.ts +3 -0
  335. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  336. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -1
  337. package/dist/simple-tree/api/treeNodeApi.d.ts +49 -0
  338. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  339. package/dist/simple-tree/api/treeNodeApi.js +41 -2
  340. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  341. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  342. package/dist/simple-tree/core/treeNodeKernel.js +45 -8
  343. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  344. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  345. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -1
  346. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  347. package/dist/simple-tree/index.d.ts +2 -2
  348. package/dist/simple-tree/index.d.ts.map +1 -1
  349. package/dist/simple-tree/index.js.map +1 -1
  350. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +16 -0
  351. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  352. package/dist/simple-tree/node-kinds/array/arrayNode.js +23 -0
  353. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  354. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +10 -1
  355. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  356. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  357. package/dist/simple-tree/node-kinds/array/index.d.ts +2 -2
  358. package/dist/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  359. package/dist/simple-tree/node-kinds/array/index.js.map +1 -1
  360. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  361. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  362. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  363. package/dist/text/textDomainFormatted.d.ts +319 -9
  364. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  365. package/dist/text/textDomainFormatted.js +100 -25
  366. package/dist/text/textDomainFormatted.js.map +1 -1
  367. package/dist/treeFactory.d.ts.map +1 -1
  368. package/dist/treeFactory.js +5 -2
  369. package/dist/treeFactory.js.map +1 -1
  370. package/dist/util/referenceCounting.d.ts.map +1 -1
  371. package/dist/util/referenceCounting.js +0 -1
  372. package/dist/util/referenceCounting.js.map +1 -1
  373. package/legacy.d.ts +2 -3
  374. package/lib/api.d.ts +6 -1
  375. package/lib/api.d.ts.map +1 -1
  376. package/lib/api.js.map +1 -1
  377. package/lib/codec/codec.d.ts +28 -2
  378. package/lib/codec/codec.d.ts.map +1 -1
  379. package/lib/codec/codec.js +1 -0
  380. package/lib/codec/codec.js.map +1 -1
  381. package/lib/codec/index.d.ts +2 -2
  382. package/lib/codec/index.d.ts.map +1 -1
  383. package/lib/codec/index.js +1 -1
  384. package/lib/codec/index.js.map +1 -1
  385. package/lib/codec/versioned/codec.d.ts +18 -36
  386. package/lib/codec/versioned/codec.d.ts.map +1 -1
  387. package/lib/codec/versioned/codec.js +45 -56
  388. package/lib/codec/versioned/codec.js.map +1 -1
  389. package/lib/codec/versioned/index.d.ts +1 -1
  390. package/lib/codec/versioned/index.d.ts.map +1 -1
  391. package/lib/codec/versioned/index.js +1 -1
  392. package/lib/codec/versioned/index.js.map +1 -1
  393. package/lib/core/forest/forest.d.ts +5 -2
  394. package/lib/core/forest/forest.d.ts.map +1 -1
  395. package/lib/core/forest/forest.js.map +1 -1
  396. package/lib/core/index.d.ts +1 -1
  397. package/lib/core/index.d.ts.map +1 -1
  398. package/lib/core/index.js +1 -1
  399. package/lib/core/index.js.map +1 -1
  400. package/lib/core/rebase/changeRebaser.d.ts +8 -1
  401. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  402. package/lib/core/rebase/changeRebaser.js.map +1 -1
  403. package/lib/core/rebase/revisionTagCodec.d.ts +4 -3
  404. package/lib/core/rebase/revisionTagCodec.d.ts.map +1 -1
  405. package/lib/core/rebase/revisionTagCodec.js +2 -0
  406. package/lib/core/rebase/revisionTagCodec.js.map +1 -1
  407. package/lib/core/rebase/utils.d.ts +2 -2
  408. package/lib/core/rebase/utils.d.ts.map +1 -1
  409. package/lib/core/rebase/utils.js +4 -4
  410. package/lib/core/rebase/utils.js.map +1 -1
  411. package/lib/core/schema-stored/formatV2.d.ts +1 -1
  412. package/lib/core/schema-stored/formatV2.js +1 -1
  413. package/lib/core/schema-stored/formatV2.js.map +1 -1
  414. package/lib/core/tree/anchorSet.d.ts +8 -0
  415. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  416. package/lib/core/tree/anchorSet.js +42 -7
  417. package/lib/core/tree/anchorSet.js.map +1 -1
  418. package/lib/core/tree/cursor.d.ts +25 -1
  419. package/lib/core/tree/cursor.d.ts.map +1 -1
  420. package/lib/core/tree/cursor.js +43 -0
  421. package/lib/core/tree/cursor.js.map +1 -1
  422. package/lib/core/tree/deltaUtil.d.ts +13 -1
  423. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  424. package/lib/core/tree/deltaUtil.js +31 -0
  425. package/lib/core/tree/deltaUtil.js.map +1 -1
  426. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -5
  427. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  428. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  429. package/lib/core/tree/index.d.ts +2 -2
  430. package/lib/core/tree/index.d.ts.map +1 -1
  431. package/lib/core/tree/index.js +2 -2
  432. package/lib/core/tree/index.js.map +1 -1
  433. package/lib/core/tree/visitDelta.d.ts +11 -0
  434. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  435. package/lib/core/tree/visitDelta.js +1 -1
  436. package/lib/core/tree/visitDelta.js.map +1 -1
  437. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  438. package/lib/core/tree/visitorUtils.js +5 -0
  439. package/lib/core/tree/visitorUtils.js.map +1 -1
  440. package/lib/entrypoints/alpha.d.ts +1 -1
  441. package/lib/entrypoints/alpha.d.ts.map +1 -1
  442. package/lib/entrypoints/alpha.js +2 -2
  443. package/lib/entrypoints/alpha.js.map +1 -1
  444. package/lib/entrypoints/beta.js +1 -1
  445. package/lib/entrypoints/beta.js.map +1 -1
  446. package/lib/entrypoints/legacy.d.ts +1 -1
  447. package/lib/entrypoints/legacy.d.ts.map +1 -1
  448. package/lib/entrypoints/legacy.js +1 -1
  449. package/lib/entrypoints/legacy.js.map +1 -1
  450. package/lib/entrypoints/public.js +1 -1
  451. package/lib/entrypoints/public.js.map +1 -1
  452. package/lib/feature-libraries/changeAtomIdCodec.d.ts +4 -3
  453. package/lib/feature-libraries/changeAtomIdCodec.d.ts.map +1 -1
  454. package/lib/feature-libraries/changeAtomIdCodec.js +2 -0
  455. package/lib/feature-libraries/changeAtomIdCodec.js.map +1 -1
  456. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +2 -1
  457. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  458. package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  459. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  460. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +4 -4
  461. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  462. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +4 -4
  463. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  464. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  465. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  466. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  467. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -2
  468. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  469. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  470. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -4
  471. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  472. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  473. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  474. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +12 -12
  475. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  476. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  477. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  478. package/lib/feature-libraries/chunked-forest/codec/{formatGeneric.d.ts → format/formatGeneric.d.ts} +1 -1
  479. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -0
  480. package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -0
  481. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts +187 -0
  482. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.d.ts.map +1 -0
  483. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js +112 -0
  484. package/lib/feature-libraries/chunked-forest/codec/format/formatV1.js.map +1 -0
  485. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts +33 -0
  486. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.d.ts.map +1 -0
  487. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js +13 -0
  488. package/lib/feature-libraries/chunked-forest/codec/format/formatV2.js.map +1 -0
  489. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +10 -0
  490. package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -0
  491. package/lib/feature-libraries/chunked-forest/codec/format/index.js +8 -0
  492. package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -0
  493. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +93 -0
  494. package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -0
  495. package/lib/feature-libraries/chunked-forest/codec/format/versions.js +26 -0
  496. package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -0
  497. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  498. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  499. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  500. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  501. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +7 -7
  502. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  503. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  504. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  505. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  506. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +4 -2
  507. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  508. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +1 -1
  509. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  510. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
  511. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  512. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  513. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  514. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  515. package/lib/feature-libraries/cursorComparator.d.ts +23 -0
  516. package/lib/feature-libraries/cursorComparator.d.ts.map +1 -0
  517. package/lib/feature-libraries/cursorComparator.js +61 -0
  518. package/lib/feature-libraries/cursorComparator.js.map +1 -0
  519. package/lib/feature-libraries/forest-summary/codec.d.ts +1 -1
  520. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +3 -3
  521. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  522. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  523. package/lib/feature-libraries/index.d.ts +3 -2
  524. package/lib/feature-libraries/index.d.ts.map +1 -1
  525. package/lib/feature-libraries/index.js +3 -2
  526. package/lib/feature-libraries/index.js.map +1 -1
  527. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +2 -0
  528. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  529. package/lib/feature-libraries/indexing/anchorTreeIndex.js +12 -7
  530. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  531. package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
  532. package/lib/feature-libraries/mitigatedChangeFamily.js +2 -2
  533. package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
  534. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
  535. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  536. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  537. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  538. package/lib/feature-libraries/modular-schema/genericFieldKind.js +0 -1
  539. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  540. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +10 -10
  541. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  542. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -4
  543. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  544. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +3 -3
  545. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  546. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  547. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +3 -3
  548. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  549. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  550. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -1
  551. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  552. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +4 -3
  553. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  554. package/lib/feature-libraries/object-forest/objectForest.d.ts +1 -1
  555. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  556. package/lib/feature-libraries/object-forest/objectForest.js +2 -2
  557. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  558. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts +4 -4
  559. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.d.ts.map +1 -1
  560. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js +1 -1
  561. package/lib/feature-libraries/optional-field/optionalFieldCodecV2.js.map +1 -1
  562. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts +3 -3
  563. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  564. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  565. package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
  566. package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
  567. package/lib/feature-libraries/schema-edits/index.js +1 -1
  568. package/lib/feature-libraries/schema-edits/index.js.map +1 -1
  569. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -15
  570. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  571. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -50
  572. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  573. package/lib/feature-libraries/schema-index/codec.d.ts +3 -16
  574. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  575. package/lib/feature-libraries/schema-index/codec.js +0 -19
  576. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  577. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -1
  578. package/lib/feature-libraries/schema-index/formatV2.js +1 -1
  579. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  580. package/lib/feature-libraries/schema-index/index.d.ts +1 -1
  581. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  582. package/lib/feature-libraries/schema-index/index.js +1 -1
  583. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  584. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +4 -4
  585. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  586. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  587. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +3 -3
  588. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
  589. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -1
  590. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
  591. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +3 -3
  592. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  593. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  594. package/lib/index.d.ts +2 -2
  595. package/lib/index.d.ts.map +1 -1
  596. package/lib/index.js +1 -1
  597. package/lib/index.js.map +1 -1
  598. package/lib/packageVersion.d.ts +1 -1
  599. package/lib/packageVersion.js +1 -1
  600. package/lib/packageVersion.js.map +1 -1
  601. package/lib/shared-tree/independentView.d.ts +1 -1
  602. package/lib/shared-tree/independentView.d.ts.map +1 -1
  603. package/lib/shared-tree/independentView.js +4 -11
  604. package/lib/shared-tree/independentView.js.map +1 -1
  605. package/lib/shared-tree/index.d.ts +2 -2
  606. package/lib/shared-tree/index.d.ts.map +1 -1
  607. package/lib/shared-tree/index.js +1 -1
  608. package/lib/shared-tree/index.js.map +1 -1
  609. package/lib/shared-tree/schematizingTreeView.d.ts +2 -36
  610. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  611. package/lib/shared-tree/schematizingTreeView.js +17 -116
  612. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  613. package/lib/shared-tree/sharedTree.d.ts +3 -22
  614. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  615. package/lib/shared-tree/sharedTree.js +11 -27
  616. package/lib/shared-tree/sharedTree.js.map +1 -1
  617. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +3 -2
  618. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  619. package/lib/shared-tree/sharedTreeChangeCodecs.js +19 -12
  620. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  621. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  622. package/lib/shared-tree/sharedTreeChangeEnricher.js +2 -2
  623. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  624. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +1 -1
  625. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  626. package/lib/shared-tree/sharedTreeChangeFamily.js +2 -2
  627. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  628. package/lib/shared-tree/sharedTreeChangeFormat.d.ts +8 -7
  629. package/lib/shared-tree/sharedTreeChangeFormat.d.ts.map +1 -1
  630. package/lib/shared-tree/sharedTreeChangeFormat.js +11 -5
  631. package/lib/shared-tree/sharedTreeChangeFormat.js.map +1 -1
  632. package/lib/shared-tree/tree.d.ts.map +1 -1
  633. package/lib/shared-tree/tree.js +2 -1
  634. package/lib/shared-tree/tree.js.map +1 -1
  635. package/lib/shared-tree/treeAlpha.d.ts +13 -1
  636. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  637. package/lib/shared-tree/treeAlpha.js +3 -0
  638. package/lib/shared-tree/treeAlpha.js.map +1 -1
  639. package/lib/shared-tree/treeCheckout.d.ts +34 -69
  640. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  641. package/lib/shared-tree/treeCheckout.js +889 -683
  642. package/lib/shared-tree/treeCheckout.js.map +1 -1
  643. package/lib/shared-tree/unhydratedTreeContext.js +1 -1
  644. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  645. package/lib/shared-tree-core/editManagerCodecs.d.ts +23 -12
  646. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  647. package/lib/shared-tree-core/editManagerCodecs.js +41 -65
  648. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  649. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  650. package/lib/shared-tree-core/editManagerCodecsCommons.js +0 -1
  651. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  652. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +10 -2
  653. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  654. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +16 -11
  655. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  656. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +2 -2
  657. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  658. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +5 -8
  659. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  660. package/lib/shared-tree-core/index.d.ts +3 -3
  661. package/lib/shared-tree-core/index.d.ts.map +1 -1
  662. package/lib/shared-tree-core/index.js +3 -3
  663. package/lib/shared-tree-core/index.js.map +1 -1
  664. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -3
  665. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  666. package/lib/shared-tree-core/messageCodecV1ToV4.js +8 -8
  667. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  668. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts +2 -3
  669. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  670. package/lib/shared-tree-core/messageCodecVSharedBranches.js +5 -4
  671. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  672. package/lib/shared-tree-core/messageCodecs.d.ts +15 -14
  673. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  674. package/lib/shared-tree-core/messageCodecs.js +38 -71
  675. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  676. package/lib/shared-tree-core/messageFormat.d.ts +0 -1
  677. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  678. package/lib/shared-tree-core/messageFormat.js +0 -1
  679. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  680. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -3
  681. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  682. package/lib/shared-tree-core/sharedTreeCore.js +14 -4
  683. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  684. package/lib/sharedTreeAttributes.d.ts.map +1 -1
  685. package/lib/sharedTreeAttributes.js +3 -0
  686. package/lib/sharedTreeAttributes.js.map +1 -1
  687. package/lib/simple-tree/api/index.d.ts +1 -0
  688. package/lib/simple-tree/api/index.d.ts.map +1 -1
  689. package/lib/simple-tree/api/index.js.map +1 -1
  690. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  691. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  692. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +2 -2
  693. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  694. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  695. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  696. package/lib/simple-tree/api/storedSchema.js +7 -7
  697. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  698. package/lib/simple-tree/api/tree.d.ts +7 -19
  699. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  700. package/lib/simple-tree/api/tree.js.map +1 -1
  701. package/lib/simple-tree/api/treeAlpha.d.ts +69 -0
  702. package/lib/simple-tree/api/treeAlpha.d.ts.map +1 -0
  703. package/lib/simple-tree/api/treeAlpha.js +6 -0
  704. package/lib/simple-tree/api/treeAlpha.js.map +1 -0
  705. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  706. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  707. package/lib/simple-tree/api/treeChangeEvents.d.ts +3 -0
  708. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -1
  709. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -1
  710. package/lib/simple-tree/api/treeNodeApi.d.ts +49 -0
  711. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  712. package/lib/simple-tree/api/treeNodeApi.js +41 -2
  713. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  714. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  715. package/lib/simple-tree/core/treeNodeKernel.js +45 -8
  716. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  717. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  718. package/lib/simple-tree/core/unhydratedFlexTree.js +5 -1
  719. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  720. package/lib/simple-tree/index.d.ts +2 -2
  721. package/lib/simple-tree/index.d.ts.map +1 -1
  722. package/lib/simple-tree/index.js.map +1 -1
  723. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +16 -0
  724. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  725. package/lib/simple-tree/node-kinds/array/arrayNode.js +23 -0
  726. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  727. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +10 -1
  728. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  729. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  730. package/lib/simple-tree/node-kinds/array/index.d.ts +2 -2
  731. package/lib/simple-tree/node-kinds/array/index.d.ts.map +1 -1
  732. package/lib/simple-tree/node-kinds/array/index.js.map +1 -1
  733. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  734. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  735. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  736. package/lib/text/textDomainFormatted.d.ts +319 -9
  737. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  738. package/lib/text/textDomainFormatted.js +103 -28
  739. package/lib/text/textDomainFormatted.js.map +1 -1
  740. package/lib/treeFactory.d.ts.map +1 -1
  741. package/lib/treeFactory.js +6 -3
  742. package/lib/treeFactory.js.map +1 -1
  743. package/lib/util/referenceCounting.d.ts.map +1 -1
  744. package/lib/util/referenceCounting.js +0 -1
  745. package/lib/util/referenceCounting.js.map +1 -1
  746. package/package.json +27 -27
  747. package/scripts/generate-entrypoint-sources.sh +4 -2
  748. package/src/api.ts +11 -0
  749. package/src/codec/codec.ts +32 -2
  750. package/src/codec/index.ts +2 -3
  751. package/src/codec/versioned/codec.ts +99 -109
  752. package/src/codec/versioned/index.ts +1 -3
  753. package/src/core/forest/forest.ts +5 -2
  754. package/src/core/index.ts +4 -0
  755. package/src/core/rebase/changeRebaser.ts +8 -0
  756. package/src/core/rebase/revisionTagCodec.ts +4 -4
  757. package/src/core/rebase/utils.ts +9 -2
  758. package/src/core/schema-stored/formatV2.ts +1 -1
  759. package/src/core/tree/anchorSet.ts +67 -10
  760. package/src/core/tree/cursor.ts +52 -1
  761. package/src/core/tree/deltaUtil.ts +37 -1
  762. package/src/core/tree/detachedFieldIndexCodecs.ts +4 -4
  763. package/src/core/tree/index.ts +4 -0
  764. package/src/core/tree/visitDelta.ts +13 -1
  765. package/src/core/tree/visitorUtils.ts +5 -0
  766. package/src/entrypoints/alpha.ts +13 -6
  767. package/src/entrypoints/beta.ts +2 -2
  768. package/src/entrypoints/legacy.ts +11 -3
  769. package/src/entrypoints/public.ts +1 -1
  770. package/src/feature-libraries/changeAtomIdCodec.ts +8 -7
  771. package/src/feature-libraries/chunked-forest/chunkedForest.ts +3 -2
  772. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +18 -13
  773. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  774. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -2
  775. package/src/feature-libraries/chunked-forest/codec/codecs.ts +16 -10
  776. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +16 -14
  777. package/src/feature-libraries/chunked-forest/codec/{formatGeneric.ts → format/formatGeneric.ts} +1 -1
  778. package/src/feature-libraries/chunked-forest/codec/{format.ts → format/formatV1.ts} +41 -111
  779. package/src/feature-libraries/chunked-forest/codec/format/formatV2.ts +31 -0
  780. package/src/feature-libraries/chunked-forest/codec/format/index.ts +31 -0
  781. package/src/feature-libraries/chunked-forest/codec/format/versions.ts +81 -0
  782. package/src/feature-libraries/chunked-forest/codec/index.ts +6 -2
  783. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +19 -12
  784. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +6 -4
  785. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +10 -10
  786. package/src/feature-libraries/chunked-forest/index.ts +2 -1
  787. package/src/feature-libraries/cursorComparator.ts +77 -0
  788. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +5 -5
  789. package/src/feature-libraries/index.ts +5 -3
  790. package/src/feature-libraries/indexing/anchorTreeIndex.ts +20 -10
  791. package/src/feature-libraries/mitigatedChangeFamily.ts +4 -1
  792. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +4 -5
  793. package/src/feature-libraries/modular-schema/genericFieldKind.ts +0 -1
  794. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +19 -26
  795. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +4 -4
  796. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +4 -5
  797. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +6 -2
  798. package/src/feature-libraries/object-forest/objectForest.ts +8 -2
  799. package/src/feature-libraries/optional-field/optionalFieldCodecV2.ts +11 -13
  800. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +4 -5
  801. package/src/feature-libraries/schema-edits/index.ts +1 -4
  802. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +10 -78
  803. package/src/feature-libraries/schema-index/codec.ts +0 -25
  804. package/src/feature-libraries/schema-index/formatV2.ts +1 -1
  805. package/src/feature-libraries/schema-index/index.ts +1 -4
  806. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +6 -6
  807. package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +8 -5
  808. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +4 -5
  809. package/src/index.ts +10 -3
  810. package/src/packageVersion.ts +1 -1
  811. package/src/shared-tree/independentView.ts +5 -18
  812. package/src/shared-tree/index.ts +0 -4
  813. package/src/shared-tree/schematizingTreeView.ts +19 -165
  814. package/src/shared-tree/sharedTree.ts +16 -59
  815. package/src/shared-tree/sharedTreeChangeCodecs.ts +23 -29
  816. package/src/shared-tree/sharedTreeChangeEnricher.ts +1 -2
  817. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -0
  818. package/src/shared-tree/sharedTreeChangeFormat.ts +23 -8
  819. package/src/shared-tree/tree.ts +2 -5
  820. package/src/shared-tree/treeAlpha.ts +26 -0
  821. package/src/shared-tree/treeCheckout.ts +275 -99
  822. package/src/shared-tree/unhydratedTreeContext.ts +1 -1
  823. package/src/shared-tree-core/editManagerCodecs.ts +99 -124
  824. package/src/shared-tree-core/editManagerCodecsCommons.ts +0 -1
  825. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +54 -59
  826. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +72 -95
  827. package/src/shared-tree-core/index.ts +4 -8
  828. package/src/shared-tree-core/messageCodecV1ToV4.ts +56 -71
  829. package/src/shared-tree-core/messageCodecVSharedBranches.ts +76 -92
  830. package/src/shared-tree-core/messageCodecs.ts +88 -126
  831. package/src/shared-tree-core/messageFormat.ts +0 -3
  832. package/src/shared-tree-core/sharedTreeCore.ts +14 -21
  833. package/src/sharedTreeAttributes.ts +3 -0
  834. package/src/simple-tree/api/index.ts +10 -0
  835. package/src/simple-tree/api/schemaFactory.ts +0 -2
  836. package/src/simple-tree/api/schemaFactoryAlpha.ts +13 -2
  837. package/src/simple-tree/api/storedSchema.ts +8 -19
  838. package/src/simple-tree/api/tree.ts +7 -20
  839. package/src/simple-tree/api/treeAlpha.ts +90 -0
  840. package/src/simple-tree/api/treeBeta.ts +1 -1
  841. package/src/simple-tree/api/treeChangeEvents.ts +3 -0
  842. package/src/simple-tree/api/treeNodeApi.ts +95 -3
  843. package/src/simple-tree/core/treeNodeKernel.ts +53 -7
  844. package/src/simple-tree/core/unhydratedFlexTree.ts +5 -1
  845. package/src/simple-tree/index.ts +10 -0
  846. package/src/simple-tree/node-kinds/array/arrayNode.ts +64 -0
  847. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +25 -1
  848. package/src/simple-tree/node-kinds/array/index.ts +2 -0
  849. package/src/simple-tree/node-kinds/index.ts +2 -0
  850. package/src/text/textDomainFormatted.ts +113 -11
  851. package/src/treeFactory.ts +10 -5
  852. package/src/util/referenceCounting.ts +0 -1
  853. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +0 -383
  854. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +0 -1
  855. package/dist/feature-libraries/chunked-forest/codec/format.js +0 -191
  856. package/dist/feature-libraries/chunked-forest/codec/format.js.map +0 -1
  857. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +0 -1
  858. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +0 -1
  859. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +0 -383
  860. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +0 -1
  861. package/lib/feature-libraries/chunked-forest/codec/format.js +0 -188
  862. package/lib/feature-libraries/chunked-forest/codec/format.js.map +0 -1
  863. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +0 -1
  864. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +0 -1
  865. /package/dist/feature-libraries/chunked-forest/codec/{formatGeneric.js → format/formatGeneric.js} +0 -0
  866. /package/lib/feature-libraries/chunked-forest/codec/{formatGeneric.js → format/formatGeneric.js} +0 -0
@@ -4,11 +4,11 @@
4
4
  */
5
5
  import { assert, compareArrays, debugAssert, fail } from "@fluidframework/core-utils/internal";
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
- import { EmptyKey, mapCursorField } from "../core/index.js";
8
- import { currentObserver } from "../feature-libraries/index.js";
7
+ import { EmptyKey, forEachNodeSubsequence, } from "../core/index.js";
8
+ import { currentObserver, buildNodeComparator } from "../feature-libraries/index.js";
9
9
  import { TreeAlpha } from "../shared-tree/index.js";
10
10
  import { enumFromStrings, eraseSchemaDetails, getInnerNode, SchemaFactory, SchemaFactoryAlpha, TreeArrayNode, TreeBeta, } from "../simple-tree/index.js";
11
- import { mapIterable, validateIndex, validateIndexRange } from "../util/index.js";
11
+ import { brand, mapIterable, validateIndex, validateIndexRange } from "../util/index.js";
12
12
  import { charactersFromString } from "./textDomain.js";
13
13
  const sf = new SchemaFactoryAlpha("com.fluidframework.text.formatted");
14
14
  class TextNode extends sf.object("Text", {
@@ -107,6 +107,12 @@ class TextNode extends sf.object("Text", {
107
107
  });
108
108
  }
109
109
  }
110
+ getUniformRun(startIndex, endIndex) {
111
+ return this.content.getUniformRun(startIndex, endIndex);
112
+ }
113
+ getString(startIndex, endIndex) {
114
+ return this.content.getString(startIndex, endIndex);
115
+ }
110
116
  }
111
117
  const defaultFormat = {
112
118
  bold: false,
@@ -115,6 +121,7 @@ const defaultFormat = {
115
121
  size: 12,
116
122
  font: "Arial",
117
123
  };
124
+ const formatKey = brand("format");
118
125
  function textAtomsFromString(value, format) {
119
126
  const result = mapIterable(charactersFromString(value), (char) => new FormattedTextAsTree.StringAtom({
120
127
  content: { content: char },
@@ -134,38 +141,97 @@ class StringArray extends sf.array("StringArray", [() => FormattedTextAsTree.Str
134
141
  cursor.exitField();
135
142
  return result;
136
143
  }
144
+ getCharactersSubarray(startIndex, endIndex) {
145
+ return this.withBorrowedSequenceCursor((cursor) => {
146
+ const result = [];
147
+ forEachNodeSubsequence(cursor, startIndex, endIndex, () => {
148
+ debugAssert(() => cursor.type === FormattedTextAsTree.StringAtom.identifier ||
149
+ "invalid fullString type optimizations");
150
+ cursor.enterField(EmptyKey);
151
+ cursor.enterNode(0);
152
+ let content;
153
+ switch (cursor.type) {
154
+ case FormattedTextAsTree.StringTextAtom.identifier: {
155
+ cursor.enterField(EmptyKey);
156
+ cursor.enterNode(0);
157
+ content = cursor.value;
158
+ debugAssert(() => typeof content === "string" || "invalid fullString type optimizations");
159
+ cursor.exitNode();
160
+ cursor.exitField();
161
+ break;
162
+ }
163
+ case FormattedTextAsTree.StringLineAtom.identifier: {
164
+ content = "\n";
165
+ break;
166
+ }
167
+ default: {
168
+ fail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);
169
+ }
170
+ }
171
+ cursor.exitNode();
172
+ cursor.exitField();
173
+ result.push(content);
174
+ });
175
+ return result;
176
+ });
177
+ }
137
178
  charactersCopy() {
138
- return this.withBorrowedSequenceCursor((cursor) => mapCursorField(cursor, () => {
139
- debugAssert(() => cursor.type === FormattedTextAsTree.StringAtom.identifier ||
140
- "invalid fullString type optimizations");
179
+ return this.getCharactersSubarray(0, this.length);
180
+ }
181
+ fullString() {
182
+ return this.charactersCopy().join("");
183
+ }
184
+ getString(startIndex, endIndex = this.length) {
185
+ validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getString");
186
+ return this.getCharactersSubarray(startIndex, endIndex).join("");
187
+ }
188
+ getUniformRun(startIndex, endIndex = this.length) {
189
+ validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getUniformRun");
190
+ if (endIndex === startIndex) {
191
+ throw new UsageError("endIndex must be greater than startIndex for getUniformRun.");
192
+ }
193
+ const arrayLength = this.length;
194
+ return this.withBorrowedSequenceCursor((cursor) => {
195
+ cursor.enterNode(startIndex);
196
+ // Capture the content type of the first atom
141
197
  cursor.enterField(EmptyKey);
142
198
  cursor.enterNode(0);
143
- let content;
144
- switch (cursor.type) {
145
- case FormattedTextAsTree.StringTextAtom.identifier: {
146
- cursor.enterField(EmptyKey);
147
- cursor.enterNode(0);
148
- content = cursor.value;
149
- debugAssert(() => typeof content === "string" || "invalid fullString type optimizations");
150
- cursor.exitNode();
151
- cursor.exitField();
199
+ const contentType = cursor.type;
200
+ cursor.exitNode();
201
+ cursor.exitField();
202
+ // Build a comparator from the format subtree of the first atom
203
+ // This compares by field key
204
+ cursor.enterField(formatKey);
205
+ cursor.enterNode(0);
206
+ const formatComparator = buildNodeComparator(cursor);
207
+ cursor.exitNode();
208
+ cursor.exitField();
209
+ let runLength = 1;
210
+ const limit = Math.min(endIndex, arrayLength) - startIndex;
211
+ while (runLength < limit && cursor.nextNode()) {
212
+ // Compare atom type
213
+ cursor.enterField(EmptyKey);
214
+ cursor.enterNode(0);
215
+ const typeMatches = cursor.type === contentType;
216
+ cursor.exitNode();
217
+ cursor.exitField();
218
+ if (!typeMatches) {
152
219
  break;
153
220
  }
154
- case FormattedTextAsTree.StringLineAtom.identifier: {
155
- content = "\n";
221
+ // Compare format subtree using the compiled comparator
222
+ cursor.enterField(formatKey);
223
+ cursor.enterNode(0);
224
+ const formatMatches = formatComparator(cursor);
225
+ cursor.exitNode();
226
+ cursor.exitField();
227
+ if (formatMatches !== true) {
156
228
  break;
157
229
  }
158
- default: {
159
- fail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);
160
- }
230
+ runLength++;
161
231
  }
162
232
  cursor.exitNode();
163
- cursor.exitField();
164
- return content;
165
- }));
166
- }
167
- fullString() {
168
- return this.charactersCopy().join("");
233
+ return runLength;
234
+ });
169
235
  }
170
236
  }
171
237
  /**
@@ -223,17 +289,26 @@ export var FormattedTextAsTree;
223
289
  "h4",
224
290
  "h5",
225
291
  "li",
292
+ "ol",
293
+ "checked",
294
+ "unchecked",
295
+ "blockquote",
296
+ "codeBlock",
226
297
  ]);
227
298
  /**
228
299
  * Unit in the string representing a new line character with line formatting.
229
300
  * @remarks
230
301
  * This aligns with how Quill represents line formatting.
231
- * Note that not all new lines will use this,
232
- * but only ones using this can have line specific formatting.
302
+ * Quill formats line attributes (headers, list, blockquote, etc... ) on the newline character
303
+ * and only lines using this atom can have line-specific formatting.
304
+ * The optional indent level mirrors Quill's indent attribute,
305
+ * which is applies to the line before the line break.
306
+ * Any tagged line can be indented independently.
233
307
  * @internal
234
308
  */
235
309
  class StringLineAtom extends sf.object("StringLineAtom", {
236
310
  tag: FormattedTextAsTree.LineTag.schema,
311
+ indent: SchemaFactory.number,
237
312
  }) {
238
313
  constructor() {
239
314
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EAAE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AE,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAC/D,GAAG,EAAE,oBAAA,OAAO,CAAC,MAAM;KACnB,CAAC;QAFF;;YAGiB,YAAO,GAAG,IAAI,CAAC;QAChC,CAAC;KAAA;IAJY,kCAAc,iBAI1B,CAAA;IAED;;;OAGG;IACU,qCAAiB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAU,CAAC;IAO3E;;;OAGG;IACH,MAAa,UAAW,SAAQ,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE;QACvD,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,oBAAA,iBAAiB,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;QACrE,MAAM,EAAE,eAAe;KACvB,CAAC;KAAG;IAHQ,8BAAU,aAGlB,CAAA;IAqFL;;;;;;OAMG;IACU,wBAAI,GAAG,kBAAkB,EAAoB,CAAC,QAAQ,CAAC,CAAC;AAEtE,CAAC,EAhLgB,mBAAmB,KAAnB,mBAAmB,QAgLnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EmptyKey, mapCursorField, type ITreeCursorSynchronous } from \"../core/index.js\";\nimport { currentObserver } from \"../feature-libraries/index.js\";\nimport { TreeAlpha } from \"../shared-tree/index.js\";\nimport {\n\tenumFromStrings,\n\teraseSchemaDetails,\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n} from \"../simple-tree/index.js\";\nimport type {\n\tInsertableTypedNode,\n\tTreeNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tWithType,\n} from \"../simple-tree/index.js\";\nimport { mapIterable, validateIndex, validateIndexRange } from \"../util/index.js\";\n\nimport { charactersFromString, type TextAsTree } from \"./textDomain.js\";\n\nconst sf = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nclass TextNode\n\textends sf.object(\"Text\", {\n\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t})\n\timplements FormattedTextAsTree.Members\n{\n\tpublic defaultFormat: FormattedTextAsTree.CharacterFormat =\n\t\tnew FormattedTextAsTree.CharacterFormat(defaultFormat);\n\n\tpublic insertAt(index: number, additionalCharacters: string): void {\n\t\tthis.content.insertAt(\n\t\t\tindex,\n\t\t\tTreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)),\n\t\t);\n\t}\n\n\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\tthis.content.removeRange(index, end);\n\t}\n\n\tpublic characters(): Iterable<string> {\n\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\tconst result = this.content.charactersCopy();\n\t\tdebugAssert(\n\t\t\t() =>\n\t\t\t\tcompareArrays(result, this.charactersCopy_reference()) ||\n\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\tpublic characterCount(): number {\n\t\treturn this.content.length;\n\t}\n\n\tpublic fullString(): string {\n\t\tconst result = this.content.fullString();\n\t\tdebugAssert(\n\t\t\t() => result === this.fullString_reference() || \"invalid fullString optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * A non-optimized reference implementation of fullString.\n\t */\n\tpublic fullString_reference(): string {\n\t\treturn [...this.characters()].join(\"\");\n\t}\n\n\t/**\n\t * Unoptimized trivially correct implementation of charactersCopy.\n\t */\n\tpublic charactersCopy_reference(): string[] {\n\t\treturn [...this.characters()];\n\t}\n\n\tpublic static fromString(\n\t\tvalue: string,\n\t\tformat?: FormattedTextAsTree.CharacterFormat,\n\t): TextNode {\n\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\treturn new TextNode({\n\t\t\tcontent: [\n\t\t\t\t...textAtomsFromString(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformat ?? new FormattedTextAsTree.CharacterFormat(defaultFormat),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\tpublic charactersWithFormatting(): readonly FormattedTextAsTree.StringAtom[] {\n\t\treturn this.content;\n\t}\n\tpublic insertWithFormattingAt(\n\t\tindex: number,\n\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof FormattedTextAsTree.StringAtom>>,\n\t): void {\n\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t}\n\tpublic formatRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\tformat: Partial<FormattedTextAsTree.CharacterFormat>,\n\t): void {\n\t\tconst formatStart = start ?? 0;\n\t\tvalidateIndex(formatStart, this.content, \"FormattedTextAsTree.formatRange\", true);\n\n\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\tvalidateIndexRange(\n\t\t\tformatStart,\n\t\t\tformatEnd,\n\t\t\tthis.content,\n\t\t\t\"FormattedTextAsTree.formatRange\",\n\t\t);\n\n\t\tconst branch = TreeAlpha.branch(this);\n\n\t\tconst applyFormatting = (): void => {\n\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\tconst atom = this.content[i];\n\t\t\t\tif (atom === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Index out of bounds while formatting text range.\");\n\t\t\t\t}\n\t\t\t\tfor (const [key, value] of Object.entries(format) as [\n\t\t\t\t\tkeyof FormattedTextAsTree.CharacterFormat,\n\t\t\t\t\tunknown,\n\t\t\t\t][]) {\n\t\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\t\tassert(\n\t\t\t\t\t\ttypeof key === \"string\",\n\t\t\t\t\t\t0xcc8 /* Object.entries returned a non-string key. */,\n\t\t\t\t\t);\n\t\t\t\t\tconst f = FormattedTextAsTree.CharacterFormat.fields.get(key);\n\t\t\t\t\tif (f === undefined) {\n\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t}\n\t\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\t\tatom.format[key] = TreeBeta.clone(TreeBeta.create(f, value as never)) as never;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (branch === undefined) {\n\t\t\t// If this node does not have a corresponding branch, then it is unhydrated.\n\t\t\t// I.e., it is not part of a collaborative session yet.\n\t\t\t// Therefore, we don't need to run the edits as a transaction.\n\t\t\tapplyFormatting();\n\t\t} else {\n\t\t\t// Wrap all formatting operations in a single transaction for atomicity.\n\t\t\tbranch.runTransaction(() => {\n\t\t\t\tapplyFormatting();\n\t\t\t});\n\t\t}\n\t}\n}\n\nconst defaultFormat = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tsize: 12,\n\tfont: \"Arial\",\n} as const;\n\nfunction textAtomsFromString(\n\tvalue: string,\n\tformat: FormattedTextAsTree.CharacterFormat,\n): Iterable<FormattedTextAsTree.StringAtom> {\n\tconst result = mapIterable(\n\t\tcharactersFromString(value),\n\t\t(char) =>\n\t\t\tnew FormattedTextAsTree.StringAtom({\n\t\t\t\tcontent: { content: char },\n\t\t\t\tformat: TreeBeta.clone<typeof FormattedTextAsTree.CharacterFormat>(format),\n\t\t\t}),\n\t);\n\treturn result;\n}\n\nclass StringArray extends sf.array(\"StringArray\", [() => FormattedTextAsTree.StringAtom]) {\n\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\tconst innerNode = getInnerNode(this);\n\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t// treat it as if it observed the whole subtree.\n\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\tconst cursor = innerNode.borrowCursor();\n\t\tcursor.enterField(EmptyKey);\n\t\tconst result = f(cursor);\n\t\tcursor.exitField();\n\t\treturn result;\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\treturn this.withBorrowedSequenceCursor((cursor) =>\n\t\t\tmapCursorField(cursor, () => {\n\t\t\t\tdebugAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcursor.type === FormattedTextAsTree.StringAtom.identifier ||\n\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t);\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tlet content: string;\n\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\tcase FormattedTextAsTree.StringTextAtom.identifier: {\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase FormattedTextAsTree.StringLineAtom.identifier: {\n\t\t\t\t\t\tcontent = \"\\n\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tfail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\treturn content;\n\t\t\t}),\n\t\t);\n\t}\n\n\tpublic fullString(): string {\n\t\treturn this.charactersCopy().join(\"\");\n\t}\n}\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n * @privateRemarks\n * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.\n * We will want to generalize this with a more generic schema factory function like with table.\n * Then either that and/or the output from it can be package exported.\n * This version is just an initial prototype.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Formatting options for characters.\n\t * @internal\n\t */\n\texport class CharacterFormat extends sf.objectAlpha(\"CharacterFormat\", {\n\t\tbold: SchemaFactory.boolean,\n\t\titalic: SchemaFactory.boolean,\n\t\tunderline: SchemaFactory.boolean,\n\t\tsize: SchemaFactory.number,\n\t\tfont: SchemaFactory.string,\n\t}) {}\n\n\t/**\n\t * Unit in the string representing a single character.\n\t * @internal\n\t */\n\texport class StringTextAtom extends sf.object(\"StringTextAtom\", {\n\t\t/**\n\t\t * The underlying text content of this atom.\n\t\t * @remarks\n\t\t * This is typically a single unicode codepoint, and thus may contain multiple utf-16 surrogate pair code units.\n\t\t * Using longer strings is still valid. For example, so users might store whole grapheme clusters here, or even longer sections of text.\n\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t * Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t * @privateRemarks\n\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t */\n\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t}) {}\n\n\t/**\n\t * Tag with which a line in text can be formatted from HTML.\n\t * @internal\n\t */\n\texport const LineTag = enumFromStrings(sf.scopedFactory(\"lineTag\"), [\n\t\t\"h1\",\n\t\t\"h2\",\n\t\t\"h3\",\n\t\t\"h4\",\n\t\t\"h5\",\n\t\t\"li\",\n\t]);\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(LineTag:variable)}\n\t * @internal\n\t */\n\texport type LineTag = TreeNodeFromImplicitAllowedTypes<typeof LineTag.schema>;\n\n\t/**\n\t * Unit in the string representing a new line character with line formatting.\n\t * @remarks\n\t * This aligns with how Quill represents line formatting.\n\t * Note that not all new lines will use this,\n\t * but only ones using this can have line specific formatting.\n\t * @internal\n\t */\n\texport class StringLineAtom extends sf.object(\"StringLineAtom\", {\n\t\ttag: LineTag.schema,\n\t}) {\n\t\tpublic readonly content = \"\\n\";\n\t}\n\n\t/**\n\t * Types of \"atoms\" that make up the text.\n\t * @internal\n\t */\n\texport const StringAtomContent = [StringTextAtom, StringLineAtom] as const;\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(StringAtomContent:variable)}\n\t * @internal\n\t */\n\texport type StringAtomContent = TreeNodeFromImplicitAllowedTypes<typeof StringAtomContent>;\n\n\t/**\n\t * A unit of the text, with formatting.\n\t * @internal\n\t */\n\texport class StringAtom extends sf.object(\"StringAtom\", {\n\t\tcontent: SchemaFactory.required(StringAtomContent, { key: EmptyKey }),\n\t\tformat: CharacterFormat,\n\t}) {}\n\n\t/**\n\t * Statics for text nodes.\n\t * @internal\n\t */\n\texport interface Statics {\n\t\t/**\n\t\t * Construct a {@link FormattedTextAsTree.(Tree:type)} from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(value: string): Tree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedTextAsTree.Statics.fromString} for construction.\n\t * @see {@link FormattedTextAsTree.(Tree:type)} for schema.\n\t * @internal\n\t */\n\texport interface Members extends TextAsTree.Members {\n\t\t/**\n\t\t * Format to use by default for text inserted with non-formatted APIs.\n\t\t * @remarks\n\t\t * This is not persisted in the tree, and observation of it is not tracked by the tree observation tracking.\n\t\t * @privateRemarks\n\t\t * Opt this into observation tracking.\n\t\t */\n\t\tdefaultFormat: CharacterFormat;\n\n\t\t/**\n\t\t * Gets an array type view of the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t * @privateRemarks\n\t\t * Currently this is implemented by a node and changes with the text over time.\n\t\t * We might not want to leak a node like this in the API.\n\t\t * Providing a way to index and iterate separately might be better.\n\t\t */\n\t\tcharactersWithFormatting(): readonly StringAtom[];\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedTextAsTree.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t */\n\t\tformatRange(\n\t\t\tstartIndex: number | undefined,\n\t\t\tendIndex: number | undefined,\n\t\t\tformat: Partial<CharacterFormat>,\n\t\t): void;\n\t}\n\n\t/**\n\t * Schema for a text node.\n\t * @remarks\n\t * See {@link FormattedTextAsTree.Members} for the API.\n\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t * @internal\n\t */\n\texport const Tree = eraseSchemaDetails<Members, Statics>()(TextNode);\n\texport type Tree = Members & TreeNode & WithType<\"com.fluidframework.text.formatted.Text\">;\n}\n"]}
1
+ {"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,sBAAsB,GAGtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EACN,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,QAAQ,GACR,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,oBAAoB,EAAmB,MAAM,iBAAiB,CAAC;AAExE,MAAM,EAAE,GAAG,IAAI,kBAAkB,CAAC,mCAAmC,CAAC,CAAC;AAEvE,MAAM,QACL,SAAQ,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;IACzB,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;CACvE,CAAC;IAHH;;QAMQ,kBAAa,GACnB,IAA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,EAAE,CAAC;QACrE,MAAM,EAAE,eAAe;KACvB,CAAC;KAAG;IAHQ,8BAAU,aAGlB,CAAA;IAkGL;;;;;;OAMG;IACU,wBAAI,GAAG,kBAAkB,EAAoB,CAAC,QAAQ,CAAC,CAAC;AAEtE,CAAC,EAtMgB,mBAAmB,KAAnB,mBAAmB,QAsMnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, compareArrays, debugAssert, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachNodeSubsequence,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n} from \"../core/index.js\";\nimport { currentObserver, buildNodeComparator } from \"../feature-libraries/index.js\";\nimport { TreeAlpha } from \"../shared-tree/index.js\";\nimport {\n\tenumFromStrings,\n\teraseSchemaDetails,\n\tgetInnerNode,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n} from \"../simple-tree/index.js\";\nimport type {\n\tInsertableTypedNode,\n\tTreeNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tWithType,\n} from \"../simple-tree/index.js\";\nimport { brand, mapIterable, validateIndex, validateIndexRange } from \"../util/index.js\";\n\nimport { charactersFromString, type TextAsTree } from \"./textDomain.js\";\n\nconst sf = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nclass TextNode\n\textends sf.object(\"Text\", {\n\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t})\n\timplements FormattedTextAsTree.Members\n{\n\tpublic defaultFormat: FormattedTextAsTree.CharacterFormat =\n\t\tnew FormattedTextAsTree.CharacterFormat(defaultFormat);\n\n\tpublic insertAt(index: number, additionalCharacters: string): void {\n\t\tthis.content.insertAt(\n\t\t\tindex,\n\t\t\tTreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)),\n\t\t);\n\t}\n\n\tpublic removeRange(index: number | undefined, end: number | undefined): void {\n\t\tthis.content.removeRange(index, end);\n\t}\n\n\tpublic characters(): Iterable<string> {\n\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\tconst result = this.content.charactersCopy();\n\t\tdebugAssert(\n\t\t\t() =>\n\t\t\t\tcompareArrays(result, this.charactersCopy_reference()) ||\n\t\t\t\t\"invalid charactersCopy optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\tpublic characterCount(): number {\n\t\treturn this.content.length;\n\t}\n\n\tpublic fullString(): string {\n\t\tconst result = this.content.fullString();\n\t\tdebugAssert(\n\t\t\t() => result === this.fullString_reference() || \"invalid fullString optimizations\",\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * A non-optimized reference implementation of fullString.\n\t */\n\tpublic fullString_reference(): string {\n\t\treturn [...this.characters()].join(\"\");\n\t}\n\n\t/**\n\t * Unoptimized trivially correct implementation of charactersCopy.\n\t */\n\tpublic charactersCopy_reference(): string[] {\n\t\treturn [...this.characters()];\n\t}\n\n\tpublic static fromString(\n\t\tvalue: string,\n\t\tformat?: FormattedTextAsTree.CharacterFormat,\n\t): TextNode {\n\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\treturn new TextNode({\n\t\t\tcontent: [\n\t\t\t\t...textAtomsFromString(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformat ?? new FormattedTextAsTree.CharacterFormat(defaultFormat),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\tpublic charactersWithFormatting(): readonly FormattedTextAsTree.StringAtom[] {\n\t\treturn this.content;\n\t}\n\tpublic insertWithFormattingAt(\n\t\tindex: number,\n\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof FormattedTextAsTree.StringAtom>>,\n\t): void {\n\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t}\n\tpublic formatRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\tformat: Partial<FormattedTextAsTree.CharacterFormat>,\n\t): void {\n\t\tconst formatStart = start ?? 0;\n\t\tvalidateIndex(formatStart, this.content, \"FormattedTextAsTree.formatRange\", true);\n\n\t\tconst formatEnd = Math.min(this.content.length, end ?? this.content.length);\n\t\tvalidateIndexRange(\n\t\t\tformatStart,\n\t\t\tformatEnd,\n\t\t\tthis.content,\n\t\t\t\"FormattedTextAsTree.formatRange\",\n\t\t);\n\n\t\tconst branch = TreeAlpha.branch(this);\n\n\t\tconst applyFormatting = (): void => {\n\t\t\tfor (let i = formatStart; i < formatEnd; i++) {\n\t\t\t\tconst atom = this.content[i];\n\t\t\t\tif (atom === undefined) {\n\t\t\t\t\tthrow new UsageError(\"Index out of bounds while formatting text range.\");\n\t\t\t\t}\n\t\t\t\tfor (const [key, value] of Object.entries(format) as [\n\t\t\t\t\tkeyof FormattedTextAsTree.CharacterFormat,\n\t\t\t\t\tunknown,\n\t\t\t\t][]) {\n\t\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\t\tassert(\n\t\t\t\t\t\ttypeof key === \"string\",\n\t\t\t\t\t\t0xcc8 /* Object.entries returned a non-string key. */,\n\t\t\t\t\t);\n\t\t\t\t\tconst f = FormattedTextAsTree.CharacterFormat.fields.get(key);\n\t\t\t\t\tif (f === undefined) {\n\t\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t\t}\n\t\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\t\tatom.format[key] = TreeBeta.clone(TreeBeta.create(f, value as never)) as never;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (branch === undefined) {\n\t\t\t// If this node does not have a corresponding branch, then it is unhydrated.\n\t\t\t// I.e., it is not part of a collaborative session yet.\n\t\t\t// Therefore, we don't need to run the edits as a transaction.\n\t\t\tapplyFormatting();\n\t\t} else {\n\t\t\t// Wrap all formatting operations in a single transaction for atomicity.\n\t\t\tbranch.runTransaction(() => {\n\t\t\t\tapplyFormatting();\n\t\t\t});\n\t\t}\n\t}\n\tpublic getUniformRun(startIndex: number, endIndex?: number): number {\n\t\treturn this.content.getUniformRun(startIndex, endIndex);\n\t}\n\tpublic getString(startIndex: number, endIndex?: number): string {\n\t\treturn this.content.getString(startIndex, endIndex);\n\t}\n}\n\nconst defaultFormat = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tsize: 12,\n\tfont: \"Arial\",\n} as const;\n\nconst formatKey: FieldKey = brand(\"format\");\n\nfunction textAtomsFromString(\n\tvalue: string,\n\tformat: FormattedTextAsTree.CharacterFormat,\n): Iterable<FormattedTextAsTree.StringAtom> {\n\tconst result = mapIterable(\n\t\tcharactersFromString(value),\n\t\t(char) =>\n\t\t\tnew FormattedTextAsTree.StringAtom({\n\t\t\t\tcontent: { content: char },\n\t\t\t\tformat: TreeBeta.clone<typeof FormattedTextAsTree.CharacterFormat>(format),\n\t\t\t}),\n\t);\n\treturn result;\n}\n\nclass StringArray extends sf.array(\"StringArray\", [() => FormattedTextAsTree.StringAtom]) {\n\tpublic withBorrowedSequenceCursor<T>(f: (cursor: ITreeCursorSynchronous) => T): T {\n\t\tconst innerNode = getInnerNode(this);\n\t\t// Since the cursor will be used to read content from the tree and won't track observations,\n\t\t// treat it as if it observed the whole subtree.\n\t\tcurrentObserver?.observeNodeDeep(innerNode);\n\t\tconst cursor = innerNode.borrowCursor();\n\t\tcursor.enterField(EmptyKey);\n\t\tconst result = f(cursor);\n\t\tcursor.exitField();\n\t\treturn result;\n\t}\n\n\tprivate getCharactersSubarray(startIndex: number, endIndex: number): string[] {\n\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\tconst result: string[] = [];\n\t\t\tforEachNodeSubsequence(cursor, startIndex, endIndex, () => {\n\t\t\t\tdebugAssert(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcursor.type === FormattedTextAsTree.StringAtom.identifier ||\n\t\t\t\t\t\t\"invalid fullString type optimizations\",\n\t\t\t\t);\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tlet content: string;\n\t\t\t\tswitch (cursor.type) {\n\t\t\t\t\tcase FormattedTextAsTree.StringTextAtom.identifier: {\n\t\t\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\t\t\tcursor.enterNode(0);\n\t\t\t\t\t\tcontent = cursor.value as string;\n\t\t\t\t\t\tdebugAssert(\n\t\t\t\t\t\t\t() => typeof content === \"string\" || \"invalid fullString type optimizations\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcursor.exitNode();\n\t\t\t\t\t\tcursor.exitField();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase FormattedTextAsTree.StringLineAtom.identifier: {\n\t\t\t\t\t\tcontent = \"\\n\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tfail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\tresult.push(content);\n\t\t\t});\n\t\t\treturn result;\n\t\t});\n\t}\n\n\tpublic charactersCopy(): string[] {\n\t\treturn this.getCharactersSubarray(0, this.length);\n\t}\n\n\tpublic fullString(): string {\n\t\treturn this.charactersCopy().join(\"\");\n\t}\n\n\tpublic getString(startIndex: number, endIndex: number = this.length): string {\n\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getString\");\n\t\treturn this.getCharactersSubarray(startIndex, endIndex).join(\"\");\n\t}\n\n\tpublic getUniformRun(startIndex: number, endIndex: number = this.length): number {\n\t\tvalidateIndexRange(startIndex, endIndex, this, \"FormattedTextAsTree.getUniformRun\");\n\t\tif (endIndex === startIndex) {\n\t\t\tthrow new UsageError(\"endIndex must be greater than startIndex for getUniformRun.\");\n\t\t}\n\t\tconst arrayLength = this.length;\n\t\treturn this.withBorrowedSequenceCursor((cursor) => {\n\t\t\tcursor.enterNode(startIndex);\n\n\t\t\t// Capture the content type of the first atom\n\t\t\tcursor.enterField(EmptyKey);\n\t\t\tcursor.enterNode(0);\n\t\t\tconst contentType = cursor.type;\n\t\t\tcursor.exitNode();\n\t\t\tcursor.exitField();\n\n\t\t\t// Build a comparator from the format subtree of the first atom\n\t\t\t// This compares by field key\n\t\t\tcursor.enterField(formatKey);\n\t\t\tcursor.enterNode(0);\n\t\t\tconst formatComparator = buildNodeComparator(cursor);\n\t\t\tcursor.exitNode();\n\t\t\tcursor.exitField();\n\n\t\t\tlet runLength = 1;\n\t\t\tconst limit = Math.min(endIndex, arrayLength) - startIndex;\n\n\t\t\twhile (runLength < limit && cursor.nextNode()) {\n\t\t\t\t// Compare atom type\n\t\t\t\tcursor.enterField(EmptyKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tconst typeMatches = cursor.type === contentType;\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\t\t\t\tif (!typeMatches) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Compare format subtree using the compiled comparator\n\t\t\t\tcursor.enterField(formatKey);\n\t\t\t\tcursor.enterNode(0);\n\t\t\t\tconst formatMatches = formatComparator(cursor);\n\t\t\t\tcursor.exitNode();\n\t\t\t\tcursor.exitField();\n\n\t\t\t\tif (formatMatches !== true) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\trunLength++;\n\t\t\t}\n\t\t\tcursor.exitNode();\n\t\t\treturn runLength;\n\t\t});\n\t}\n}\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n * @privateRemarks\n * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.\n * We will want to generalize this with a more generic schema factory function like with table.\n * Then either that and/or the output from it can be package exported.\n * This version is just an initial prototype.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Formatting options for characters.\n\t * @internal\n\t */\n\texport class CharacterFormat extends sf.objectAlpha(\"CharacterFormat\", {\n\t\tbold: SchemaFactory.boolean,\n\t\titalic: SchemaFactory.boolean,\n\t\tunderline: SchemaFactory.boolean,\n\t\tsize: SchemaFactory.number,\n\t\tfont: SchemaFactory.string,\n\t}) {}\n\n\t/**\n\t * Unit in the string representing a single character.\n\t * @internal\n\t */\n\texport class StringTextAtom extends sf.object(\"StringTextAtom\", {\n\t\t/**\n\t\t * The underlying text content of this atom.\n\t\t * @remarks\n\t\t * This is typically a single unicode codepoint, and thus may contain multiple utf-16 surrogate pair code units.\n\t\t * Using longer strings is still valid. For example, so users might store whole grapheme clusters here, or even longer sections of text.\n\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t * Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t * @privateRemarks\n\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t */\n\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t}) {}\n\n\t/**\n\t * Tag with which a line in text can be formatted from HTML.\n\t * @internal\n\t */\n\texport const LineTag = enumFromStrings(sf.scopedFactory(\"lineTag\"), [\n\t\t\"h1\",\n\t\t\"h2\",\n\t\t\"h3\",\n\t\t\"h4\",\n\t\t\"h5\",\n\t\t\"li\",\n\t\t\"ol\",\n\t\t\"checked\",\n\t\t\"unchecked\",\n\t\t\"blockquote\",\n\t\t\"codeBlock\",\n\t]);\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(LineTag:variable)}\n\t * @internal\n\t */\n\texport type LineTag = TreeNodeFromImplicitAllowedTypes<typeof LineTag.schema>;\n\n\t/**\n\t * Unit in the string representing a new line character with line formatting.\n\t * @remarks\n\t * This aligns with how Quill represents line formatting.\n\t * Quill formats line attributes (headers, list, blockquote, etc... ) on the newline character\n\t * and only lines using this atom can have line-specific formatting.\n\t * The optional indent level mirrors Quill's indent attribute,\n\t * which is applies to the line before the line break.\n\t * Any tagged line can be indented independently.\n\t * @internal\n\t */\n\texport class StringLineAtom extends sf.object(\"StringLineAtom\", {\n\t\ttag: LineTag.schema,\n\t\tindent: SchemaFactory.number,\n\t}) {\n\t\tpublic readonly content = \"\\n\";\n\t}\n\n\t/**\n\t * Types of \"atoms\" that make up the text.\n\t * @internal\n\t */\n\texport const StringAtomContent = [StringTextAtom, StringLineAtom] as const;\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(StringAtomContent:variable)}\n\t * @internal\n\t */\n\texport type StringAtomContent = TreeNodeFromImplicitAllowedTypes<typeof StringAtomContent>;\n\n\t/**\n\t * A unit of the text, with formatting.\n\t * @internal\n\t */\n\texport class StringAtom extends sf.object(\"StringAtom\", {\n\t\tcontent: SchemaFactory.required(StringAtomContent, { key: EmptyKey }),\n\t\tformat: CharacterFormat,\n\t}) {}\n\n\t/**\n\t * Statics for text nodes.\n\t * @internal\n\t */\n\texport interface Statics {\n\t\t/**\n\t\t * Construct a {@link FormattedTextAsTree.(Tree:type)} from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(value: string): Tree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedTextAsTree.Statics.fromString} for construction.\n\t * @see {@link FormattedTextAsTree.(Tree:type)} for schema.\n\t * @internal\n\t */\n\texport interface Members extends TextAsTree.Members {\n\t\t/**\n\t\t * Format to use by default for text inserted with non-formatted APIs.\n\t\t * @remarks\n\t\t * This is not persisted in the tree, and observation of it is not tracked by the tree observation tracking.\n\t\t * @privateRemarks\n\t\t * Opt this into observation tracking.\n\t\t */\n\t\tdefaultFormat: CharacterFormat;\n\n\t\t/**\n\t\t * Gets an array type view of the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t * @privateRemarks\n\t\t * Currently this is implemented by a node and changes with the text over time.\n\t\t * We might not want to leak a node like this in the API.\n\t\t * Providing a way to index and iterate separately might be better.\n\t\t */\n\t\tcharactersWithFormatting(): readonly StringAtom[];\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedTextAsTree.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index (inclusive) of the range to format.\n\t\t * @param endIndex - The ending index (exclusive) of the range to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t * @remarks\n\t\t * The start and end behave the same as in {@link (TreeArrayNode:interface).removeRange}.\n\t\t */\n\t\tformatRange(\n\t\t\tstartIndex: number | undefined,\n\t\t\tendIndex: number | undefined,\n\t\t\tformat: Partial<CharacterFormat>,\n\t\t): void;\n\n\t\t/**\n\t\t * Returns the length of the run of characters starting at `startIndex` which have the same formatting and atom type, up to `endIndex`.\n\t\t * @param startIndex - The starting index of the run.\n\t\t * @param endIndex - The ending index (exclusive) of the run. Defaults to the end of the text.\n\t\t */\n\t\tgetUniformRun(startIndex: number, endIndex?: number): number;\n\t\t/**\n\t\t * Returns a substring of the text from `startIndex` to `endIndex`\n\t\t * @param startIndex - starting index (inclusive)\n\t\t * @param endIndex - Optional ending index (exclusive). Defaults to the end of the text.\n\t\t */\n\t\tgetString(startIndex: number, endIndex?: number): string;\n\t}\n\n\t/**\n\t * Schema for a text node.\n\t * @remarks\n\t * See {@link FormattedTextAsTree.Members} for the API.\n\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t * @internal\n\t */\n\texport const Tree = eraseSchemaDetails<Members, Statics>()(TextNode);\n\texport type Tree = Members & TreeNode & WithType<\"com.fluidframework.text.formatted.Text\">;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAMtB,MAAM,6CAA6C,CAAC;AAIrD,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE9B,MAAM,wBAAwB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B,MAAM,wBAAwB,CAAC;AAQhC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa,EAAE,YAAY;CAAG;AA8DnE;;;;GAIG;AACH,eAAO,MAAM,UAAU,oDAA2B,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,qBAAqB,GAC5B,gBAAgB,CAAC,KAAK,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,qBAAqB,GAC5B,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAEpD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,iBAAiB,GACxB,gBAAgB,CAAC,KAAK,CAAC,CAEzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,iBAAiB,GACxB,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAGpD;AAED,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,yBAAyB,GAChC,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CASpD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,yBAAyB,CAQpF"}
@@ -6,7 +6,7 @@ import { makeSharedObjectKind, } from "@fluidframework/shared-object-base/intern
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
7
  import { FluidClientVersion } from "./codec/index.js";
8
8
  import { SharedTreeKernel, } from "./shared-tree/index.js";
9
- import { editManagerFormatVersionSelectorForSharedBranches, messageFormatVersionSelectorForSharedBranches, } from "./shared-tree-core/index.js";
9
+ import { editManagerCodecName, EditManagerFormatVersion, messageCodecName, MessageFormatVersion, } from "./shared-tree-core/index.js";
10
10
  import { SharedTreeFactoryType, SharedTreeAttributes } from "./sharedTreeAttributes.js";
11
11
  import { Breakable, copyProperty } from "./util/index.js";
12
12
  /**
@@ -148,7 +148,10 @@ function resolveFormatOptions(options) {
148
148
  return {};
149
149
  }
150
150
  const sharedBranchesOptions = {
151
- messageFormatSelector: messageFormatVersionSelectorForSharedBranches,
152
- editManagerFormatSelector: editManagerFormatVersionSelectorForSharedBranches,
151
+ writeVersionOverrides: new Map([
152
+ [editManagerCodecName, EditManagerFormatVersion.vSharedBranches],
153
+ [messageCodecName, MessageFormatVersion.vSharedBranches],
154
+ ]),
155
+ allowPossiblyIncompatibleWriteVersionOverrides: true,
153
156
  };
154
157
  //# sourceMappingURL=treeFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,oBAAoB,GAKpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,gBAAgB,GAMhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iDAAiD,EACjD,6CAA6C,GAC7C,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAExF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS1D;;;;;GAKG;AACH,SAAS,iBAAiB,CACzB,OAAkC;IAElC,SAAS,kBAAkB,CAAC,IAAgB;QAC3C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,UAAU,CAAC,gDAAgD,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,EAAE,mBAAmB,EAAE,GAAG,YAAY,EAAE,GAAG,OAA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qB,EAAE,6CAA6C;IACpE,yBAAyB,EAAE,iDAAiD;CAC5E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { FluidClientVersion } from \"./codec/index.js\";\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport {\n\teditManagerFormatVersionSelectorForSharedBranches,\n\tmessageFormatVersionSelectorForSharedBranches,\n} from \"./shared-tree-core/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable, copyProperty } from \"./util/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst { minVersionForCollab, ...otherOptions } = options;\n\n\t\tconst adjustedOptions = {\n\t\t\t...otherOptions,\n\t\t\t// Cases:\n\t\t\t// A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.\n\t\t\t// This value is set when:\n\t\t\t// - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.\n\t\t\t// There is currently no way to set it via the declarative API, but it could be added in the future.\n\t\t\t// - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab\n\t\t\t// B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.\n\t\t\t// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.\n\t\t\tminVersionForCollab:\n\t\t\t\tminVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,\n\t\t};\n\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.initialSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy @beta\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing.\n * For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.\n *\n * With great care, and knowledge of the support and stability of the options exposed here,\n * this can also be used to opt into some features early or for performance tuning.\n *\n * @example\n * ```typescript\n * import {\n * \tconfiguredSharedTreeBeta,\n * \tForestTypeReference,\n * } from \"fluid-framework/beta\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * });\n * ```\n * @privateRemarks\n * The Legacy `ISharedObjectKind<ITree>` type is omitted here for simplicity.\n * @beta\n */\nexport function configuredSharedTreeBeta(\n\toptions: SharedTreeOptionsBeta,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} including the legacy `ISharedObjectKind` type.\n * @privateRemarks\n * This is given a different export name (with legacy appended) to avoid the need to do the special reexport with different types from the fluid-framework package.\n * @legacy @beta\n */\nexport function configuredSharedTreeBetaLegacy(\n\toptions: SharedTreeOptionsBeta,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} but including the alpha {@link SharedTreeOptions}.\n * @alpha\n */\nexport function configuredSharedTreeAlpha(\n\toptions: SharedTreeOptions,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBetaLegacy} but including `@alpha` options.\n *\n * @example\n * ```typescript\n * import {\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \tFormatValidatorBasic,\n * \tForestTypeReference,\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: FormatValidatorBasic,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to no alpha+legacy being setup yet.\n *\n * This should be renamed to `configuredSharedTreeAlpha` to avoid colliding with the eventual public version which will have less options.\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst internalOptions = resolveOptions(options);\n\treturn configuredSharedTreeInternal(internalOptions);\n}\n\nexport function configuredSharedTreeInternal(\n\toptions: SharedTreeOptionsInternal,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n\nexport function resolveOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst internal: SharedTreeOptionsInternal = {\n\t\t...resolveFormatOptions(options),\n\t};\n\tfor (const optionName of Object.keys(options)) {\n\t\tcopyProperty(options, optionName, internal);\n\t}\n\treturn internal;\n}\n\nfunction resolveFormatOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst enableSharedBranches = options.enableSharedBranches ?? false;\n\n\tif (enableSharedBranches) {\n\t\treturn sharedBranchesOptions;\n\t}\n\n\treturn {};\n}\n\nconst sharedBranchesOptions: SharedTreeOptionsInternal = {\n\tmessageFormatSelector: messageFormatVersionSelectorForSharedBranches,\n\teditManagerFormatSelector: editManagerFormatVersionSelectorForSharedBranches,\n};\n"]}
1
+ {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,oBAAoB,GAKpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAsB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACN,gBAAgB,GAMhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,oB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AoB,CAAC,OAAO,CAAC;KAChC,CAAC;IACF,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACvD,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,KAAK,CAAC;IAEnE,IAAI,oBAAoB,EAAE,CAAC;QAC1B,OAAO,qBAAqB,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC;AAED,MAAM,qBAAqB,GAA8B;IACxD,qBAAqB,EAAE,IAAI,GAAG,CAAwB;QACrD,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,eAAe,CAAC;QAChE,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,eAAe,CAAC;KACxD,CAAC;IACF,8CAA8C,EAAE,IAAI;CACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { FluidClientVersion, type FormatVersion } from \"./codec/index.js\";\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport {\n\teditManagerCodecName,\n\tEditManagerFormatVersion,\n\tmessageCodecName,\n\tMessageFormatVersion,\n} from \"./shared-tree-core/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable, copyProperty } from \"./util/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst { minVersionForCollab, ...otherOptions } = options;\n\n\t\tconst adjustedOptions = {\n\t\t\t...otherOptions,\n\t\t\t// Cases:\n\t\t\t// A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.\n\t\t\t// This value is set when:\n\t\t\t// - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.\n\t\t\t// There is currently no way to set it via the declarative API, but it could be added in the future.\n\t\t\t// - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab\n\t\t\t// B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.\n\t\t\t// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.\n\t\t\tminVersionForCollab:\n\t\t\t\tminVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,\n\t\t};\n\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.initialSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy @beta\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing.\n * For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.\n *\n * With great care, and knowledge of the support and stability of the options exposed here,\n * this can also be used to opt into some features early or for performance tuning.\n *\n * @example\n * ```typescript\n * import {\n * \tconfiguredSharedTreeBeta,\n * \tForestTypeReference,\n * } from \"fluid-framework/beta\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * });\n * ```\n * @privateRemarks\n * The Legacy `ISharedObjectKind<ITree>` type is omitted here for simplicity.\n * @beta\n */\nexport function configuredSharedTreeBeta(\n\toptions: SharedTreeOptionsBeta,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} including the legacy `ISharedObjectKind` type.\n * @privateRemarks\n * This is given a different export name (with legacy appended) to avoid the need to do the special reexport with different types from the fluid-framework package.\n * @legacy @beta\n */\nexport function configuredSharedTreeBetaLegacy(\n\toptions: SharedTreeOptionsBeta,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} but including the alpha {@link SharedTreeOptions}.\n * @alpha\n */\nexport function configuredSharedTreeAlpha(\n\toptions: SharedTreeOptions,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBetaLegacy} but including `@alpha` options.\n *\n * @example\n * ```typescript\n * import {\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \tFormatValidatorBasic,\n * \tForestTypeReference,\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: FormatValidatorBasic,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to no alpha+legacy being setup yet.\n *\n * This should be renamed to `configuredSharedTreeAlpha` to avoid colliding with the eventual public version which will have less options.\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst internalOptions = resolveOptions(options);\n\treturn configuredSharedTreeInternal(internalOptions);\n}\n\nexport function configuredSharedTreeInternal(\n\toptions: SharedTreeOptionsInternal,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n\nexport function resolveOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst internal: SharedTreeOptionsInternal = {\n\t\t...resolveFormatOptions(options),\n\t};\n\tfor (const optionName of Object.keys(options)) {\n\t\tcopyProperty(options, optionName, internal);\n\t}\n\treturn internal;\n}\n\nfunction resolveFormatOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst enableSharedBranches = options.enableSharedBranches ?? false;\n\n\tif (enableSharedBranches) {\n\t\treturn sharedBranchesOptions;\n\t}\n\n\treturn {};\n}\n\nconst sharedBranchesOptions: SharedTreeOptionsInternal = {\n\twriteVersionOverrides: new Map<string, FormatVersion>([\n\t\t[editManagerCodecName, EditManagerFormatVersion.vSharedBranches],\n\t\t[messageCodecName, MessageFormatVersion.vSharedBranches],\n\t]),\n\tallowPossiblyIncompatibleWriteVersionOverrides: true,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"referenceCounting.d.ts","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,cAAc,IAAI,IAAI,CAAC;IACvB;;;;OAIG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,gBAAgB;IAE/C,OAAO,CAAC,QAAQ;IAAtC,SAAS,aAAqB,QAAQ,GAAE,MAAU;IAE3C,cAAc,CAAC,KAAK,SAAI,GAAG,IAAI;IAI/B,gBAAgB,CAAC,KAAK,SAAI,GAAG,IAAI;IAQjC,QAAQ,IAAI,OAAO;IAInB,cAAc,IAAI,OAAO;IAIhC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;CACzC"}
1
+ {"version":3,"file":"referenceCounting.d.ts","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,cAAc,IAAI,IAAI,CAAC;IACvB;;;;OAIG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,8BAAsB,oBAAqB,YAAW,gBAAgB;IAC/C,OAAO,CAAC,QAAQ;IAAtC,SAAS,aAAqB,QAAQ,GAAE,MAAU;IAE3C,cAAc,CAAC,KAAK,SAAI,GAAG,IAAI;IAI/B,gBAAgB,CAAC,KAAK,SAAI,GAAG,IAAI;IAQjC,QAAQ,IAAI,OAAO;IAInB,cAAc,IAAI,OAAO;IAIhC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;CACzC"}
@@ -7,7 +7,6 @@ import { assert } from "@fluidframework/core-utils/internal";
7
7
  * Base class to assist with implementing ReferenceCounted.
8
8
  */
9
9
  export class ReferenceCountedBase {
10
- // eslint-disable-next-line @typescript-eslint/prefer-readonly -- false positive; modified in multiple places
11
10
  constructor(refCount = 1) {
12
11
  this.refCount = refCount;
13
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"referenceCounting.js","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAgC7D;;GAEG;AACH,MAAM,OAAgB,oBAAoB;IACzC,6GAA6G;IAC7G,YAA8B,WAAmB,CAAC;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAAG,CAAC;IAE/C,cAAc,CAAC,KAAK,GAAG,CAAC;QAC9B,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;IACxB,CAAC;IAEM,gBAAgB,CAAC,KAAK,GAAG,CAAC;QAChC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,EAAE,CAAC;QACvB,CAAC;IACF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC1B,CAAC;IAEM,cAAc;QACpB,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC5B,CAAC;CAMD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * An object which counts the number of users / references to it.\n * @remarks\n * This implements the {@link https://en.wikipedia.org/wiki/Reference_counting | Reference counting} pattern.\n * Getting the reference count correct is difficult in TypeScript and great care must be used.\n * Because of this, this interface should not be used in the public API.\n */\nexport interface ReferenceCounted {\n\t/**\n\t * Called to increase the reference count tracked by this object.\n\t * @remarks\n\t * When a user of this object allows something else to use it,\n\t * this should be called.\n\t */\n\treferenceAdded(): void;\n\t/**\n\t * Called to decrease the reference count tracked by this object.\n\t * @remarks\n\t * When a user of this object will no longer use it, this should be called.\n\t */\n\treferenceRemoved(): void;\n\n\t/**\n\t * @returns true if mutating this object may impact other users of it.\n\t *\n\t * Implementations can return true if the refcount is 1 OR the content is logically immutable.\n\t */\n\tisShared(): boolean;\n}\n\n/**\n * Base class to assist with implementing ReferenceCounted.\n */\nexport abstract class ReferenceCountedBase implements ReferenceCounted {\n\t// eslint-disable-next-line @typescript-eslint/prefer-readonly -- false positive; modified in multiple places\n\tprotected constructor(private refCount: number = 1) {}\n\n\tpublic referenceAdded(count = 1): void {\n\t\tthis.refCount += count;\n\t}\n\n\tpublic referenceRemoved(count = 1): void {\n\t\tthis.refCount -= count;\n\t\tassert(this.refCount >= 0, 0x4c4 /* Negative ref count */);\n\t\tif (this.refCount === 0) {\n\t\t\tthis.onUnreferenced();\n\t\t}\n\t}\n\n\tpublic isShared(): boolean {\n\t\treturn this.refCount > 1;\n\t}\n\n\tpublic isUnreferenced(): boolean {\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Called when refcount reaches 0.\n\t */\n\tprotected abstract onUnreferenced(): void;\n}\n"]}
1
+ {"version":3,"file":"referenceCounting.js","sourceRoot":"","sources":["../../src/util/referenceCounting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAgC7D;;GAEG;AACH,MAAM,OAAgB,oBAAoB;IACzC,YAA8B,WAAmB,CAAC;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAAG,CAAC;IAE/C,cAAc,CAAC,KAAK,GAAG,CAAC;QAC9B,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;IACxB,CAAC;IAEM,gBAAgB,CAAC,KAAK,GAAG,CAAC;QAChC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,EAAE,CAAC;QACvB,CAAC;IACF,CAAC;IAEM,QAAQ;QACd,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC1B,CAAC;IAEM,cAAc;QACpB,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC5B,CAAC;CAMD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * An object which counts the number of users / references to it.\n * @remarks\n * This implements the {@link https://en.wikipedia.org/wiki/Reference_counting | Reference counting} pattern.\n * Getting the reference count correct is difficult in TypeScript and great care must be used.\n * Because of this, this interface should not be used in the public API.\n */\nexport interface ReferenceCounted {\n\t/**\n\t * Called to increase the reference count tracked by this object.\n\t * @remarks\n\t * When a user of this object allows something else to use it,\n\t * this should be called.\n\t */\n\treferenceAdded(): void;\n\t/**\n\t * Called to decrease the reference count tracked by this object.\n\t * @remarks\n\t * When a user of this object will no longer use it, this should be called.\n\t */\n\treferenceRemoved(): void;\n\n\t/**\n\t * @returns true if mutating this object may impact other users of it.\n\t *\n\t * Implementations can return true if the refcount is 1 OR the content is logically immutable.\n\t */\n\tisShared(): boolean;\n}\n\n/**\n * Base class to assist with implementing ReferenceCounted.\n */\nexport abstract class ReferenceCountedBase implements ReferenceCounted {\n\tprotected constructor(private refCount: number = 1) {}\n\n\tpublic referenceAdded(count = 1): void {\n\t\tthis.refCount += count;\n\t}\n\n\tpublic referenceRemoved(count = 1): void {\n\t\tthis.refCount -= count;\n\t\tassert(this.refCount >= 0, 0x4c4 /* Negative ref count */);\n\t\tif (this.refCount === 0) {\n\t\t\tthis.onUnreferenced();\n\t\t}\n\t}\n\n\tpublic isShared(): boolean {\n\t\treturn this.refCount > 1;\n\t}\n\n\tpublic isUnreferenced(): boolean {\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Called when refcount reaches 0.\n\t */\n\tprotected abstract onUnreferenced(): void;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree",
3
- "version": "2.91.0",
3
+ "version": "2.92.0",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -101,20 +101,19 @@
101
101
  "temp-directory": "nyc/.nyc_output"
102
102
  },
103
103
  "dependencies": {
104
- "@fluid-internal/client-utils": "~2.91.0",
105
- "@fluidframework/container-runtime": "~2.91.0",
106
- "@fluidframework/core-interfaces": "~2.91.0",
107
- "@fluidframework/core-utils": "~2.91.0",
108
- "@fluidframework/datastore-definitions": "~2.91.0",
109
- "@fluidframework/driver-definitions": "~2.91.0",
110
- "@fluidframework/id-compressor": "~2.91.0",
111
- "@fluidframework/runtime-definitions": "~2.91.0",
112
- "@fluidframework/runtime-utils": "~2.91.0",
113
- "@fluidframework/shared-object-base": "~2.91.0",
114
- "@fluidframework/telemetry-utils": "~2.91.0",
104
+ "@fluid-internal/client-utils": "~2.92.0",
105
+ "@fluidframework/container-runtime": "~2.92.0",
106
+ "@fluidframework/core-interfaces": "~2.92.0",
107
+ "@fluidframework/core-utils": "~2.92.0",
108
+ "@fluidframework/datastore-definitions": "~2.92.0",
109
+ "@fluidframework/driver-definitions": "~2.92.0",
110
+ "@fluidframework/id-compressor": "~2.92.0",
111
+ "@fluidframework/runtime-definitions": "~2.92.0",
112
+ "@fluidframework/runtime-utils": "~2.92.0",
113
+ "@fluidframework/shared-object-base": "~2.92.0",
114
+ "@fluidframework/telemetry-utils": "~2.92.0",
115
115
  "@sinclair/typebox": "^0.34.13",
116
116
  "@tylerbu/sorted-btree-es6": "^2.1.1",
117
- "@types/ungap__structured-clone": "^1.2.0",
118
117
  "@ungap/structured-clone": "^1.2.0",
119
118
  "semver-ts": "^1.0.3",
120
119
  "uuid": "^11.1.0"
@@ -122,25 +121,26 @@
122
121
  "devDependencies": {
123
122
  "@arethetypeswrong/cli": "^0.18.2",
124
123
  "@biomejs/biome": "~2.4.5",
125
- "@fluid-internal/mocha-test-setup": "~2.91.0",
126
- "@fluid-private/stochastic-test-utils": "~2.91.0",
127
- "@fluid-private/test-dds-utils": "~2.91.0",
128
- "@fluid-private/test-drivers": "~2.91.0",
124
+ "@fluid-internal/mocha-test-setup": "~2.92.0",
125
+ "@fluid-private/stochastic-test-utils": "~2.92.0",
126
+ "@fluid-private/test-dds-utils": "~2.92.0",
127
+ "@fluid-private/test-drivers": "~2.92.0",
129
128
  "@fluid-tools/benchmark": "^0.52.0",
130
- "@fluid-tools/build-cli": "^0.63.0",
129
+ "@fluid-tools/build-cli": "^0.64.0",
131
130
  "@fluidframework/build-common": "^2.0.3",
132
- "@fluidframework/build-tools": "^0.63.0",
133
- "@fluidframework/container-definitions": "~2.91.0",
134
- "@fluidframework/container-loader": "~2.91.0",
135
- "@fluidframework/eslint-config-fluid": "~2.91.0",
136
- "@fluidframework/test-runtime-utils": "~2.91.0",
137
- "@fluidframework/test-utils": "~2.91.0",
138
- "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.83.0",
131
+ "@fluidframework/build-tools": "^0.64.0",
132
+ "@fluidframework/container-definitions": "~2.92.0",
133
+ "@fluidframework/container-loader": "~2.92.0",
134
+ "@fluidframework/eslint-config-fluid": "^9.0.0",
135
+ "@fluidframework/test-runtime-utils": "~2.92.0",
136
+ "@fluidframework/test-utils": "~2.92.0",
137
+ "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.91.0",
139
138
  "@microsoft/api-extractor": "7.52.11",
140
139
  "@types/diff": "^3.5.1",
141
140
  "@types/easy-table": "^0.0.32",
142
141
  "@types/mocha": "^10.0.10",
143
142
  "@types/node": "~20.19.30",
143
+ "@types/ungap__structured-clone": "^1.2.0",
144
144
  "ajv": "^8.17.1",
145
145
  "ajv-formats": "^3.0.1",
146
146
  "c8": "^10.1.3",
@@ -148,7 +148,7 @@
148
148
  "copyfiles": "^2.4.1",
149
149
  "cross-env": "^10.1.0",
150
150
  "dependency-cruiser": "^17.3.2",
151
- "diff": "^3.5.0",
151
+ "diff": "^4.0.4",
152
152
  "easy-table": "^1.2.0",
153
153
  "eslint": "~9.39.1",
154
154
  "eslint-config-prettier": "~10.1.8",
@@ -211,7 +211,7 @@
211
211
  "ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
212
212
  "ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
213
213
  "ci:build:docs": "api-extractor run",
214
- "clean": "rimraf --glob dist lib {alpha,beta,internal}.d.ts \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
214
+ "clean": "rimraf --glob dist lib {alpha,beta,internal,legacy}.d.ts \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
215
215
  "depcruise": "depcruise src/ --ignore-known",
216
216
  "depcruise:regen-known-issues": "depcruise-baseline src",
217
217
  "eslint": "eslint --quiet --format stylish src",
@@ -18,12 +18,14 @@ mkdir -p ./lib/entrypoints
18
18
 
19
19
  # 1. Generate entrypoint .d.ts files in lib/entrypoints.
20
20
 
21
- pnpm flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib/entrypoints
21
+ export GENERATE_CL="flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib/entrypoints"
22
+ pnpm $GENERATE_CL
22
23
 
23
24
  # 2. Copy generated .d.ts files to src/entrypoints as .ts files.
24
25
  # A bug in "flub generate entrypoints" requires "./index.js" to be replaced with
25
26
  # "../index.js" hence use of sed.
27
+ # Additionally replace the generation header comment with "generate:entrypoint-sources".
26
28
 
27
29
  for tag in public beta alpha legacy; do
28
- sed "s|\./|../|" "./lib/entrypoints/${tag}.d.ts" > "./src/entrypoints/${tag}.ts"
30
+ sed -e "s|${GENERATE_CL}\" in @fluid-tools/build-cli|generate:entrypoint-sources\"|" -e "s|\./|../|" "./lib/entrypoints/${tag}.d.ts" > "./src/entrypoints/${tag}.ts"
29
31
  done
package/src/api.ts CHANGED
@@ -7,9 +7,12 @@ import type {
7
7
  TreeView,
8
8
  TreeViewAlpha,
9
9
  TreeViewBeta,
10
+ ImplicitAllowedTypes,
10
11
  ImplicitFieldSchema,
11
12
  TreeViewConfiguration,
12
13
  TreeViewConfigurationAlpha,
14
+ TreeArrayNode,
15
+ TreeArrayNodeAlpha,
13
16
  } from "./simple-tree/index.js";
14
17
 
15
18
  /**
@@ -34,6 +37,14 @@ export function asAlpha<TSchema extends ImplicitFieldSchema>(
34
37
  view: TreeViewConfiguration<TSchema>,
35
38
  ): TreeViewConfigurationAlpha<TSchema>;
36
39
 
40
+ /**
41
+ * Retrieve the {@link TreeArrayNodeAlpha | alpha API} for a {@link (TreeArrayNode:interface)}.
42
+ * @alpha
43
+ */
44
+ export function asAlpha<TAllowedTypes extends ImplicitAllowedTypes>(
45
+ node: TreeArrayNode<TAllowedTypes>,
46
+ ): TreeArrayNodeAlpha<TAllowedTypes>;
47
+
37
48
  /**
38
49
  * Implementation of overloads for {@link asAlpha}.
39
50
  */