@fluidframework/tree 2.110.0 → 2.111.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 (374) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/CHANGELOG.md +48 -0
  3. package/api-report/tree.alpha.api.md +48 -31
  4. package/api-report/tree.beta.api.md +38 -0
  5. package/api-report/tree.legacy.beta.api.md +38 -0
  6. package/dist/core/change-family/changeFamily.d.ts +3 -10
  7. package/dist/core/change-family/changeFamily.d.ts.map +1 -1
  8. package/dist/core/change-family/changeFamily.js.map +1 -1
  9. package/dist/core/rebase/types.d.ts +2 -2
  10. package/dist/core/rebase/types.js.map +1 -1
  11. package/dist/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  12. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  13. package/dist/entrypoints/alpha.d.ts +1 -1
  14. package/dist/entrypoints/alpha.d.ts.map +1 -1
  15. package/dist/entrypoints/alpha.js.map +1 -1
  16. package/dist/entrypoints/beta.d.ts +1 -1
  17. package/dist/entrypoints/beta.d.ts.map +1 -1
  18. package/dist/entrypoints/beta.js.map +1 -1
  19. package/dist/entrypoints/legacy.d.ts +1 -1
  20. package/dist/entrypoints/legacy.d.ts.map +1 -1
  21. package/dist/entrypoints/legacy.js.map +1 -1
  22. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +19 -14
  23. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  24. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +13 -32
  25. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  26. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +85 -28
  27. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/codec/codecs.js +83 -9
  29. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
  31. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +11 -0
  33. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  35. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
  37. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
  41. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  43. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/index.js +2 -1
  45. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  46. package/dist/feature-libraries/forest-summary/codec.d.ts +3 -3
  47. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  48. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  49. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
  50. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  51. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -6
  52. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  53. package/dist/feature-libraries/index.d.ts +1 -1
  54. package/dist/feature-libraries/index.d.ts.map +1 -1
  55. package/dist/feature-libraries/index.js +2 -1
  56. package/dist/feature-libraries/index.js.map +1 -1
  57. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  58. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +9 -9
  59. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  60. package/dist/index.d.ts +2 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +2 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/packageVersion.d.ts +1 -1
  65. package/dist/packageVersion.js +1 -1
  66. package/dist/packageVersion.js.map +1 -1
  67. package/dist/shared-tree/independentView.d.ts.map +1 -1
  68. package/dist/shared-tree/independentView.js +4 -7
  69. package/dist/shared-tree/independentView.js.map +1 -1
  70. package/dist/shared-tree/index.d.ts +1 -1
  71. package/dist/shared-tree/index.d.ts.map +1 -1
  72. package/dist/shared-tree/index.js.map +1 -1
  73. package/dist/shared-tree/schematizingTreeView.d.ts +5 -5
  74. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  75. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  76. package/dist/shared-tree/sharedTree.d.ts +5 -0
  77. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  78. package/dist/shared-tree/sharedTree.js +7 -4
  79. package/dist/shared-tree/sharedTree.js.map +1 -1
  80. package/dist/shared-tree/transactionPostProcessor.d.ts +28 -0
  81. package/dist/shared-tree/transactionPostProcessor.d.ts.map +1 -0
  82. package/dist/shared-tree/transactionPostProcessor.js +28 -0
  83. package/dist/shared-tree/transactionPostProcessor.js.map +1 -0
  84. package/dist/shared-tree/treeAlpha.js +3 -3
  85. package/dist/shared-tree/treeAlpha.js.map +1 -1
  86. package/dist/shared-tree/treeCheckout.d.ts +16 -12
  87. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  88. package/dist/shared-tree/treeCheckout.js +18 -9
  89. package/dist/shared-tree/treeCheckout.js.map +1 -1
  90. package/dist/shared-tree/unhydratedTreeContext.d.ts +5 -5
  91. package/dist/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  92. package/dist/shared-tree/unhydratedTreeContext.js.map +1 -1
  93. package/dist/shared-tree-core/editManagerCodecs.d.ts +3 -2
  94. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  95. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  96. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
  97. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  98. package/dist/shared-tree-core/editManagerCodecsCommons.js +2 -4
  99. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  100. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
  101. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  102. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  103. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
  104. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  105. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  106. package/dist/shared-tree-core/editManagerSummarizer.d.ts +5 -9
  107. package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  108. package/dist/shared-tree-core/editManagerSummarizer.js +5 -10
  109. package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
  110. package/dist/shared-tree-core/index.d.ts +1 -1
  111. package/dist/shared-tree-core/index.d.ts.map +1 -1
  112. package/dist/shared-tree-core/index.js +3 -2
  113. package/dist/shared-tree-core/index.js.map +1 -1
  114. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  115. package/dist/shared-tree-core/sharedTreeCore.js +3 -1
  116. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  117. package/dist/shared-tree-core/transaction.d.ts +84 -9
  118. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  119. package/dist/shared-tree-core/transaction.js +74 -7
  120. package/dist/shared-tree-core/transaction.js.map +1 -1
  121. package/dist/simple-tree/api/index.d.ts +1 -1
  122. package/dist/simple-tree/api/index.d.ts.map +1 -1
  123. package/dist/simple-tree/api/index.js.map +1 -1
  124. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  125. package/dist/simple-tree/api/schemaCreationUtilities.js +3 -3
  126. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  127. package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
  128. package/dist/simple-tree/api/schemaFactory.js +2 -2
  129. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  130. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
  131. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  132. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  133. package/dist/simple-tree/api/transactionTypes.d.ts +91 -28
  134. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  135. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  136. package/dist/simple-tree/api/tree.d.ts +86 -22
  137. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  138. package/dist/simple-tree/api/tree.js.map +1 -1
  139. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  140. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  141. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -7
  142. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  143. package/dist/simple-tree/index.d.ts +1 -1
  144. package/dist/simple-tree/index.d.ts.map +1 -1
  145. package/dist/simple-tree/index.js.map +1 -1
  146. package/dist/text/index.d.ts +1 -0
  147. package/dist/text/index.d.ts.map +1 -1
  148. package/dist/text/index.js +3 -1
  149. package/dist/text/index.js.map +1 -1
  150. package/dist/text/textDomainFormatted.d.ts +69 -758
  151. package/dist/text/textDomainFormatted.d.ts.map +1 -1
  152. package/dist/text/textDomainFormatted.js +275 -322
  153. package/dist/text/textDomainFormatted.js.map +1 -1
  154. package/dist/text/textDomainFormattedDefault.d.ts +273 -0
  155. package/dist/text/textDomainFormattedDefault.d.ts.map +1 -0
  156. package/dist/text/textDomainFormattedDefault.js +94 -0
  157. package/dist/text/textDomainFormattedDefault.js.map +1 -0
  158. package/dist/util/compressedIds.d.ts +118 -0
  159. package/dist/util/compressedIds.d.ts.map +1 -0
  160. package/dist/util/compressedIds.js +133 -0
  161. package/dist/util/compressedIds.js.map +1 -0
  162. package/dist/util/index.d.ts +1 -0
  163. package/dist/util/index.d.ts.map +1 -1
  164. package/dist/util/index.js +9 -1
  165. package/dist/util/index.js.map +1 -1
  166. package/lib/core/change-family/changeFamily.d.ts +3 -10
  167. package/lib/core/change-family/changeFamily.d.ts.map +1 -1
  168. package/lib/core/change-family/changeFamily.js.map +1 -1
  169. package/lib/core/rebase/types.d.ts +2 -2
  170. package/lib/core/rebase/types.js.map +1 -1
  171. package/lib/core/schema-stored/storedSchemaRepository.d.ts +2 -2
  172. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  173. package/lib/entrypoints/alpha.d.ts +1 -1
  174. package/lib/entrypoints/alpha.d.ts.map +1 -1
  175. package/lib/entrypoints/alpha.js.map +1 -1
  176. package/lib/entrypoints/beta.d.ts +1 -1
  177. package/lib/entrypoints/beta.d.ts.map +1 -1
  178. package/lib/entrypoints/beta.js.map +1 -1
  179. package/lib/entrypoints/legacy.d.ts +1 -1
  180. package/lib/entrypoints/legacy.d.ts.map +1 -1
  181. package/lib/entrypoints/legacy.js.map +1 -1
  182. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +19 -14
  183. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  184. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +14 -33
  185. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  186. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +85 -28
  187. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  188. package/lib/feature-libraries/chunked-forest/codec/codecs.js +82 -9
  189. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  190. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +4 -2
  191. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  192. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +12 -1
  193. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  194. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  195. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  196. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  197. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  198. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts +1 -1
  199. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -1
  200. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js +3 -15
  201. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -1
  202. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  203. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  204. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  205. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  206. package/lib/feature-libraries/forest-summary/codec.d.ts +3 -3
  207. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  208. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  209. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +3 -2
  210. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  211. package/lib/feature-libraries/forest-summary/forestSummarizer.js +4 -6
  212. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  213. package/lib/feature-libraries/index.d.ts +1 -1
  214. package/lib/feature-libraries/index.d.ts.map +1 -1
  215. package/lib/feature-libraries/index.js +1 -1
  216. package/lib/feature-libraries/index.js.map +1 -1
  217. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  218. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +10 -10
  219. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  220. package/lib/index.d.ts +2 -2
  221. package/lib/index.d.ts.map +1 -1
  222. package/lib/index.js +1 -1
  223. package/lib/index.js.map +1 -1
  224. package/lib/packageVersion.d.ts +1 -1
  225. package/lib/packageVersion.js +1 -1
  226. package/lib/packageVersion.js.map +1 -1
  227. package/lib/shared-tree/independentView.d.ts.map +1 -1
  228. package/lib/shared-tree/independentView.js +5 -8
  229. package/lib/shared-tree/independentView.js.map +1 -1
  230. package/lib/shared-tree/index.d.ts +1 -1
  231. package/lib/shared-tree/index.d.ts.map +1 -1
  232. package/lib/shared-tree/index.js.map +1 -1
  233. package/lib/shared-tree/schematizingTreeView.d.ts +5 -5
  234. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  235. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  236. package/lib/shared-tree/sharedTree.d.ts +5 -0
  237. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  238. package/lib/shared-tree/sharedTree.js +8 -5
  239. package/lib/shared-tree/sharedTree.js.map +1 -1
  240. package/lib/shared-tree/transactionPostProcessor.d.ts +28 -0
  241. package/lib/shared-tree/transactionPostProcessor.d.ts.map +1 -0
  242. package/lib/shared-tree/transactionPostProcessor.js +23 -0
  243. package/lib/shared-tree/transactionPostProcessor.js.map +1 -0
  244. package/lib/shared-tree/treeAlpha.js +3 -3
  245. package/lib/shared-tree/treeAlpha.js.map +1 -1
  246. package/lib/shared-tree/treeCheckout.d.ts +16 -12
  247. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  248. package/lib/shared-tree/treeCheckout.js +18 -9
  249. package/lib/shared-tree/treeCheckout.js.map +1 -1
  250. package/lib/shared-tree/unhydratedTreeContext.d.ts +5 -5
  251. package/lib/shared-tree/unhydratedTreeContext.d.ts.map +1 -1
  252. package/lib/shared-tree/unhydratedTreeContext.js.map +1 -1
  253. package/lib/shared-tree-core/editManagerCodecs.d.ts +3 -2
  254. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  255. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  256. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +3 -9
  257. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  258. package/lib/shared-tree-core/editManagerCodecsCommons.js +3 -5
  259. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  260. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts +3 -3
  261. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  262. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  263. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts +3 -3
  264. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  265. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  266. package/lib/shared-tree-core/editManagerSummarizer.d.ts +5 -9
  267. package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
  268. package/lib/shared-tree-core/editManagerSummarizer.js +5 -10
  269. package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
  270. package/lib/shared-tree-core/index.d.ts +1 -1
  271. package/lib/shared-tree-core/index.d.ts.map +1 -1
  272. package/lib/shared-tree-core/index.js +1 -1
  273. package/lib/shared-tree-core/index.js.map +1 -1
  274. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  275. package/lib/shared-tree-core/sharedTreeCore.js +3 -1
  276. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  277. package/lib/shared-tree-core/transaction.d.ts +84 -9
  278. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  279. package/lib/shared-tree-core/transaction.js +73 -6
  280. package/lib/shared-tree-core/transaction.js.map +1 -1
  281. package/lib/simple-tree/api/index.d.ts +1 -1
  282. package/lib/simple-tree/api/index.d.ts.map +1 -1
  283. package/lib/simple-tree/api/index.js.map +1 -1
  284. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +3 -3
  285. package/lib/simple-tree/api/schemaCreationUtilities.js +3 -3
  286. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  287. package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
  288. package/lib/simple-tree/api/schemaFactory.js +2 -2
  289. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  290. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +2 -2
  291. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +2 -2
  292. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  293. package/lib/simple-tree/api/transactionTypes.d.ts +91 -28
  294. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  295. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  296. package/lib/simple-tree/api/tree.d.ts +86 -22
  297. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  298. package/lib/simple-tree/api/tree.js.map +1 -1
  299. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  300. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  301. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -7
  302. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  303. package/lib/simple-tree/index.d.ts +1 -1
  304. package/lib/simple-tree/index.d.ts.map +1 -1
  305. package/lib/simple-tree/index.js.map +1 -1
  306. package/lib/text/index.d.ts +1 -0
  307. package/lib/text/index.d.ts.map +1 -1
  308. package/lib/text/index.js +1 -0
  309. package/lib/text/index.js.map +1 -1
  310. package/lib/text/textDomainFormatted.d.ts +69 -758
  311. package/lib/text/textDomainFormatted.d.ts.map +1 -1
  312. package/lib/text/textDomainFormatted.js +277 -324
  313. package/lib/text/textDomainFormatted.js.map +1 -1
  314. package/lib/text/textDomainFormattedDefault.d.ts +273 -0
  315. package/lib/text/textDomainFormattedDefault.d.ts.map +1 -0
  316. package/lib/text/textDomainFormattedDefault.js +91 -0
  317. package/lib/text/textDomainFormattedDefault.js.map +1 -0
  318. package/lib/util/compressedIds.d.ts +118 -0
  319. package/lib/util/compressedIds.d.ts.map +1 -0
  320. package/lib/util/compressedIds.js +124 -0
  321. package/lib/util/compressedIds.js.map +1 -0
  322. package/lib/util/index.d.ts +1 -0
  323. package/lib/util/index.d.ts.map +1 -1
  324. package/lib/util/index.js +1 -0
  325. package/lib/util/index.js.map +1 -1
  326. package/package.json +23 -23
  327. package/src/core/change-family/changeFamily.ts +3 -12
  328. package/src/core/rebase/types.ts +2 -2
  329. package/src/core/schema-stored/storedSchemaRepository.ts +2 -2
  330. package/src/entrypoints/alpha.ts +12 -8
  331. package/src/entrypoints/beta.ts +8 -0
  332. package/src/entrypoints/legacy.ts +8 -0
  333. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +35 -64
  334. package/src/feature-libraries/chunked-forest/codec/codecs.ts +138 -42
  335. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +32 -4
  336. package/src/feature-libraries/chunked-forest/codec/index.ts +1 -0
  337. package/src/feature-libraries/chunked-forest/codec/nodeEncoder.ts +7 -19
  338. package/src/feature-libraries/chunked-forest/index.ts +3 -0
  339. package/src/feature-libraries/forest-summary/codec.ts +5 -3
  340. package/src/feature-libraries/forest-summary/forestSummarizer.ts +4 -5
  341. package/src/feature-libraries/index.ts +3 -0
  342. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +13 -9
  343. package/src/index.ts +13 -8
  344. package/src/packageVersion.ts +1 -1
  345. package/src/shared-tree/independentView.ts +5 -10
  346. package/src/shared-tree/index.ts +1 -0
  347. package/src/shared-tree/schematizingTreeView.ts +25 -25
  348. package/src/shared-tree/sharedTree.ts +16 -4
  349. package/src/shared-tree/transactionPostProcessor.ts +40 -0
  350. package/src/shared-tree/treeAlpha.ts +3 -3
  351. package/src/shared-tree/treeCheckout.ts +61 -44
  352. package/src/shared-tree/unhydratedTreeContext.ts +18 -15
  353. package/src/shared-tree-core/editManagerCodecs.ts +3 -2
  354. package/src/shared-tree-core/editManagerCodecsCommons.ts +10 -14
  355. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +3 -2
  356. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +3 -2
  357. package/src/shared-tree-core/editManagerSummarizer.ts +5 -9
  358. package/src/shared-tree-core/index.ts +8 -5
  359. package/src/shared-tree-core/sharedTreeCore.ts +3 -2
  360. package/src/shared-tree-core/transaction.ts +148 -18
  361. package/src/simple-tree/api/index.ts +13 -9
  362. package/src/simple-tree/api/schemaCreationUtilities.ts +3 -3
  363. package/src/simple-tree/api/schemaFactory.ts +2 -2
  364. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +2 -2
  365. package/src/simple-tree/api/transactionTypes.ts +111 -39
  366. package/src/simple-tree/api/tree.ts +141 -47
  367. package/src/simple-tree/api/treeBeta.ts +2 -0
  368. package/src/simple-tree/core/treeNodeSchema.ts +7 -7
  369. package/src/simple-tree/index.ts +12 -8
  370. package/src/text/index.ts +1 -0
  371. package/src/text/textDomainFormatted.ts +520 -415
  372. package/src/text/textDomainFormattedDefault.ts +150 -0
  373. package/src/util/compressedIds.ts +216 -0
  374. package/src/util/index.ts +15 -0
@@ -6,291 +6,305 @@ import { assert, compareArrays, debugAssert, fail } from "@fluidframework/core-u
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
7
  import { EmptyKey, forEachNodeSubsequence, } from "../core/index.js";
8
8
  import { currentObserver, buildNodeComparator } from "../feature-libraries/index.js";
9
- import { TreeAlpha } from "../shared-tree/index.js";
10
- import { enumFromStrings, eraseSchemaDetails, getInnerNode, SchemaFactory, SchemaFactoryAlpha, TreeArrayNode, TreeBeta, } from "../simple-tree/index.js";
9
+ import { TreeAlpha, Tree as TreeStatic } from "../shared-tree/index.js";
10
+ import { getInnerNode, SchemaFactory, SchemaFactoryAlpha, TreeArrayNode, TreeBeta, createCustomizedFluidFrameworkScopedFactory, isObjectNodeSchema, eraseSchemaDetailsSubclassable, } from "../simple-tree/index.js";
11
11
  import { brand, mapIterable, validateIndex, validateIndexRange } from "../util/index.js";
12
12
  import { charactersFromString, processCharactersChangedDelta, } from "./textDomain.js";
13
- const sf = new SchemaFactoryAlpha("com.fluidframework.text.formatted");
14
- class TextNode extends sf.object("Text", {
15
- content: SchemaFactory.required([() => StringArray], { key: EmptyKey }),
16
- }) {
17
- constructor() {
18
- super(...arguments);
19
- this.defaultFormat = new FormattedTextAsTree.CharacterFormat(defaultFormat);
20
- }
21
- insertAt(index, additionalCharacters) {
22
- this.content.insertAt(index, TreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)));
23
- }
24
- removeRange(index, end) {
25
- this.content.removeRange(index, end);
26
- }
27
- characters() {
28
- return mapIterable(this.content, (atom) => atom.content.content);
29
- }
30
- charactersCopy() {
31
- const result = this.content.charactersCopy();
32
- debugAssert(() => compareArrays(result, this.charactersCopy_reference()) ||
33
- "invalid charactersCopy optimizations");
34
- return result;
35
- }
36
- characterCount() {
37
- return this.content.length;
38
- }
39
- fullString() {
40
- const result = this.content.fullString();
41
- debugAssert(() => result === this.fullString_reference() || "invalid fullString optimizations");
42
- return result;
43
- }
44
- /**
45
- * A non-optimized reference implementation of fullString.
46
- */
47
- fullString_reference() {
48
- return [...this.characters()].join("");
49
- }
13
+ /**
14
+ * Sets up scope for formatted text schema built-in types.
15
+ * @remarks User-provided factory scoping will be applied as `com.fluidframework.text.formatted<user-scope>`.
16
+ */
17
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Inferring is the most practical option here
18
+ function createFormattedScopedFactory(inputSchemaFactory) {
19
+ return createCustomizedFluidFrameworkScopedFactory(inputSchemaFactory, "text.formatted");
20
+ }
21
+ /**
22
+ * Schema factory for formatted text types which are not generic.
23
+ */
24
+ const sfStatic = new SchemaFactoryAlpha("com.fluidframework.text.formatted");
25
+ const formatKey = brand("format");
26
+ /**
27
+ * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
28
+ * @remarks
29
+ * This is generic over formatting an embedded object/atom types.
30
+ * See {@link FormattedTextAsTreeDefault} for a default parameterization.
31
+ * @privateRemarks
32
+ * TODO:
33
+ * - Add more comprehensive tests for generic parameterizations other than default.
34
+ * - Sort out API around overwriting subsets of formatting information.
35
+ * @internal
36
+ */
37
+ export var FormattedTextAsTree;
38
+ (function (FormattedTextAsTree) {
50
39
  /**
51
- * Unoptimized trivially correct implementation of charactersCopy.
40
+ * Factory for formatted text schema as a function of the formatting and the embedded object (atom) types.
52
41
  */
53
- charactersCopy_reference() {
54
- return [...this.characters()];
55
- }
56
- static fromString(value, format) {
57
- // Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,
58
- // 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.
59
- // Thus the array construction here is necessary to avoid a runtime error.
60
- return new TextNode({
61
- content: [
62
- ...textAtomsFromString(value, format ?? new FormattedTextAsTree.CharacterFormat(defaultFormat)),
63
- ],
64
- });
65
- }
66
- charactersWithFormatting() {
67
- return this.content;
68
- }
69
- insertWithFormattingAt(index, additionalCharacters) {
70
- this.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));
71
- }
72
- formatRange(start, end, format) {
73
- const formatStart = start ?? 0;
74
- validateIndex(formatStart, this.content, "FormattedTextAsTree.formatRange", true);
75
- const formatEnd = Math.min(this.content.length, end ?? this.content.length);
76
- validateIndexRange(formatStart, formatEnd, this.content, "FormattedTextAsTree.formatRange");
77
- const branch = TreeAlpha.branch(this);
78
- const applyFormatting = () => {
79
- for (let i = formatStart; i < formatEnd; i++) {
80
- const atom = this.content[i];
81
- if (atom === undefined) {
82
- throw new UsageError("Index out of bounds while formatting text range.");
83
- }
84
- for (const [key, value] of Object.entries(format)) {
85
- // Object.entries should only return string keyed enumerable own properties.
86
- // The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
87
- assert(typeof key === "string", 0xcc8 /* Object.entries returned a non-string key. */);
88
- const f = FormattedTextAsTree.CharacterFormat.fields.get(key);
89
- if (f === undefined) {
90
- throw new UsageError(`Unknown format key: ${key}`);
42
+ function createSchema(inputSchemaFactory, formatSchema, extraAtoms, defaultFormatInsertable) {
43
+ const atoms = [StringTextAtom, ...extraAtoms];
44
+ const sf = createFormattedScopedFactory(inputSchemaFactory);
45
+ class TextNode extends sf.object("Text", {
46
+ content: SchemaFactory.required([() => StringArray], { key: EmptyKey }),
47
+ }) {
48
+ constructor() {
49
+ super(...arguments);
50
+ this.defaultFormat = TreeBeta.create(formatSchema, defaultFormatInsertable);
51
+ }
52
+ insertAt(index, additionalCharacters) {
53
+ this.content.insertAt(index, TreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)));
54
+ }
55
+ removeRange(index, end) {
56
+ this.content.removeRange(index, end);
57
+ }
58
+ characters() {
59
+ return mapIterable(this.content, (atom) => atom.content.content);
60
+ }
61
+ charactersCopy() {
62
+ const result = this.content.charactersCopy();
63
+ debugAssert(() => compareArrays(result, this.charactersCopy_reference()) ||
64
+ "invalid charactersCopy optimizations");
65
+ return result;
66
+ }
67
+ characterCount() {
68
+ return this.content.length;
69
+ }
70
+ fullString() {
71
+ const result = this.content.fullString();
72
+ debugAssert(() => result === this.fullString_reference() || "invalid fullString optimizations");
73
+ return result;
74
+ }
75
+ /**
76
+ * A non-optimized reference implementation of fullString.
77
+ */
78
+ fullString_reference() {
79
+ return [...this.characters()].join("");
80
+ }
81
+ /**
82
+ * Unoptimized trivially correct implementation of charactersCopy.
83
+ */
84
+ charactersCopy_reference() {
85
+ return [...this.characters()];
86
+ }
87
+ static fromString(value, format) {
88
+ // Use `this` rather than `TextNode` so the more derived schema class is constructed when using this as a static on a subclass.
89
+ return new this({
90
+ content: [
91
+ // Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,
92
+ // 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.
93
+ // Thus the array construction here is necessary to avoid a runtime error.
94
+ ...textAtomsFromString(value, format ?? TreeBeta.create(formatSchema, defaultFormatInsertable)),
95
+ ],
96
+ });
97
+ }
98
+ charactersWithFormatting() {
99
+ return this.content;
100
+ }
101
+ insertWithFormattingAt(index, additionalCharacters) {
102
+ this.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));
103
+ }
104
+ formatRange(start, end, format) {
105
+ const formatStart = start ?? 0;
106
+ validateIndex(formatStart, this.content, "FormattedTextAsTree.formatRange", true);
107
+ const formatEnd = Math.min(this.content.length, end ?? this.content.length);
108
+ validateIndexRange(formatStart, formatEnd, this.content, "FormattedTextAsTree.formatRange");
109
+ const fieldFormats = Object.entries(format);
110
+ TreeAlpha.context(this).runTransaction(() => {
111
+ for (let i = formatStart; i < formatEnd; i++) {
112
+ const atom = this.content[i];
113
+ // Range validated above, so this should never fail.
114
+ assert(atom !== undefined, 0xd08 /* Index out of bounds while formatting text range. */);
115
+ const formatNode = atom.format;
116
+ const atomFormatSchema = TreeStatic.schema(formatNode);
117
+ if (!isObjectNodeSchema(atomFormatSchema)) {
118
+ // TODO: redesign this API to work with all allowed FormatSchema types.
119
+ throw new UsageError("formatRange currently only supports object nodes for the format.");
120
+ }
121
+ for (const [key, value] of fieldFormats) {
122
+ // Object.entries should only return string keyed enumerable own properties.
123
+ // The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
124
+ assert(typeof key === "string", 0xcc8 /* Object.entries returned a non-string key. */);
125
+ const field = atomFormatSchema.fields.get(key);
126
+ if (field === undefined) {
127
+ throw new UsageError(`Unknown format key: ${key}`);
128
+ }
129
+ // Ensures that if the input is a node, it is cloned before being inserted into the tree.
130
+ const clonedValue = TreeBeta.clone(TreeBeta.create(field, value));
131
+ formatNode[key] = clonedValue;
132
+ }
91
133
  }
92
- // Ensures that if the input is a node, it is cloned before being inserted into the tree.
93
- atom.format[key] = TreeBeta.clone(TreeBeta.create(f, value));
94
- }
134
+ });
135
+ }
136
+ /**
137
+ * Returns the {@link FormattedTextAsTree.TextAtom.content} at the given atom index, or `undefined` if out of bounds.
138
+ */
139
+ getAtomCharacterAt(index) {
140
+ const atom = this.content[index];
141
+ if (atom === undefined)
142
+ return undefined;
143
+ return atom.content.content;
144
+ }
145
+ onCharactersChanged(callback) {
146
+ return TreeAlpha.on(this.content, "nodeChanged", ({ delta }) => processCharactersChangedDelta(delta, (index) => this.getAtomCharacterAt(index), callback));
147
+ }
148
+ onContentChanged(callback) {
149
+ return TreeAlpha.on(this.content, "treeChanged", ({ delta }) => processCharactersChangedDelta(delta, (index) => this.getAtomCharacterAt(index), callback));
150
+ }
151
+ getUniformRun(startIndex, endIndex) {
152
+ return this.content.getUniformRun(startIndex, endIndex);
153
+ }
154
+ getString(startIndex, endIndex) {
155
+ return this.content.getString(startIndex, endIndex);
95
156
  }
96
- };
97
- if (branch === undefined) {
98
- // If this node does not have a corresponding branch, then it is unhydrated.
99
- // I.e., it is not part of a collaborative session yet.
100
- // Therefore, we don't need to run the edits as a transaction.
101
- // Note: for unhydrated nodes each atom edit fires a separate `treeChanged` event,
102
- // so formatting N atoms will produce N callbacks on `onContentChanged` subscribers
103
- // instead of the single callback that hydrated (transacted) edits produce.
104
- // `withBufferedTreeEvents` is not a viable mitigation here: when more than one atom's
105
- // `format` field changes within the same buffered scope, the kernel's per-field
106
- // dedup logic discards the delta (see `treeNodeKernel.ts` `#fieldMarksBuffer`),
107
- // which is worse for incremental consumers than N well-formed callbacks.
108
- // Use `runTransaction` on a hydrated node (i.e. after inserting into the document)
109
- // if batched events matter.
110
- applyFormatting();
111
157
  }
112
- else {
113
- // Wrap all formatting operations in a single transaction for atomicity.
114
- branch.runTransaction(() => {
115
- applyFormatting();
158
+ function textAtomsFromString(value, format) {
159
+ const result = mapIterable(charactersFromString(value), (char) => {
160
+ const textAtom = new StringTextAtom({ content: char });
161
+ const data = {
162
+ content: textAtom,
163
+ format: TreeBeta.clone(format),
164
+ };
165
+ return new StringAtom(data); // Generic break type safety here. TODO: try and make safer.
116
166
  });
167
+ return result;
117
168
  }
118
- }
119
- /**
120
- * Returns the character string at the given atom index, or `undefined` if out of bounds.
121
- * @remarks
122
- * Line atoms expand to `"\n"`; text atoms return their underlying code point(s).
123
- */
124
- getAtomCharacterAt(index) {
125
- const atom = this.content[index];
126
- if (atom === undefined)
127
- return undefined;
128
- return atom.content instanceof FormattedTextAsTree.StringLineAtom
129
- ? "\n"
130
- : atom.content.content;
131
- }
132
- onCharactersChanged(callback) {
133
- return TreeAlpha.on(this.content, "nodeChanged", ({ delta }) => processCharactersChangedDelta(delta, (index) => this.getAtomCharacterAt(index), callback));
134
- }
135
- onContentChanged(callback) {
136
- return TreeAlpha.on(this.content, "treeChanged", ({ delta }) => processCharactersChangedDelta(delta, (index) => this.getAtomCharacterAt(index), callback));
137
- }
138
- getUniformRun(startIndex, endIndex) {
139
- return this.content.getUniformRun(startIndex, endIndex);
140
- }
141
- getString(startIndex, endIndex) {
142
- return this.content.getString(startIndex, endIndex);
143
- }
144
- }
145
- const defaultFormat = {
146
- bold: false,
147
- italic: false,
148
- underline: false,
149
- size: 12,
150
- font: "Arial",
151
- };
152
- const formatKey = brand("format");
153
- function textAtomsFromString(value, format) {
154
- const result = mapIterable(charactersFromString(value), (char) => new FormattedTextAsTree.StringAtom({
155
- content: { content: char },
156
- format: TreeBeta.clone(format),
157
- }));
158
- return result;
159
- }
160
- class StringArray extends sf.array("StringArray", [() => FormattedTextAsTree.StringAtom]) {
161
- withBorrowedSequenceCursor(f) {
162
- const innerNode = getInnerNode(this);
163
- // Since the cursor will be used to read content from the tree and won't track observations,
164
- // treat it as if it observed the whole subtree.
165
- currentObserver?.observeNodeDeep(innerNode);
166
- const cursor = innerNode.borrowCursor();
167
- cursor.enterField(EmptyKey);
168
- const result = f(cursor);
169
- cursor.exitField();
170
- return result;
171
- }
172
- getCharactersSubarray(startIndex, endIndex) {
173
- return this.withBorrowedSequenceCursor((cursor) => {
174
- const result = [];
175
- forEachNodeSubsequence(cursor, startIndex, endIndex, () => {
176
- debugAssert(() => cursor.type === FormattedTextAsTree.StringAtom.identifier ||
177
- "invalid fullString type optimizations");
169
+ class StringArray extends sf.array("StringArray", [() => StringAtom]) {
170
+ withBorrowedSequenceCursor(f) {
171
+ const innerNode = getInnerNode(this);
172
+ // Since the cursor will be used to read content from the tree and won't track observations,
173
+ // treat it as if it observed the whole subtree.
174
+ currentObserver?.observeNodeDeep(innerNode);
175
+ const cursor = innerNode.borrowCursor();
178
176
  cursor.enterField(EmptyKey);
179
- cursor.enterNode(0);
180
- let content;
181
- switch (cursor.type) {
182
- case FormattedTextAsTree.StringTextAtom.identifier: {
177
+ const result = f(cursor);
178
+ cursor.exitField();
179
+ return result;
180
+ }
181
+ getCharactersSubarray(startIndex, endIndex) {
182
+ const slowPathIndexes = [];
183
+ const result = [];
184
+ this.withBorrowedSequenceCursor((cursor) => {
185
+ forEachNodeSubsequence(cursor, startIndex, endIndex, () => {
186
+ debugAssert(() => cursor.type === StringAtom.identifier ||
187
+ "invalid fullString type optimizations");
183
188
  cursor.enterField(EmptyKey);
184
189
  cursor.enterNode(0);
185
- content = cursor.value;
186
- debugAssert(() => typeof content === "string" || "invalid fullString type optimizations");
190
+ let content;
191
+ switch (cursor.type) {
192
+ case StringTextAtom.identifier: {
193
+ cursor.enterField(EmptyKey);
194
+ cursor.enterNode(0);
195
+ content = cursor.value;
196
+ debugAssert(() => typeof content === "string" || "invalid fullString type optimizations");
197
+ cursor.exitNode();
198
+ cursor.exitField();
199
+ break;
200
+ }
201
+ // TODO: we could optimize this for constant cases via an optional symbol on the atom schema holding the constant.
202
+ // A less general optimization could just include cases for build in types with constant values
203
+ // (like below commented code: currently this would cause a cyclical dependency but could be refactored).
204
+ // case FormattedTextAsTree.StringLineAtom.identifier: {
205
+ // content = "\n";
206
+ // break;
207
+ // }
208
+ default: {
209
+ slowPathIndexes.push(result.length);
210
+ content = ""; // Placeholder for slow path content
211
+ }
212
+ }
187
213
  cursor.exitNode();
188
214
  cursor.exitField();
189
- break;
190
- }
191
- case FormattedTextAsTree.StringLineAtom.identifier: {
192
- content = "\n";
193
- break;
194
- }
195
- default: {
196
- fail(0xcde /* Unsupported node type in text array */, () => `${cursor.type}`);
197
- }
215
+ result.push(content);
216
+ });
217
+ });
218
+ // Fill in slow path cases not optimized above.
219
+ for (const index of slowPathIndexes) {
220
+ const node = this[index + startIndex] ??
221
+ fail(0xd09 /* getCharactersSubarray failed to find index after index range was checked */);
222
+ result[index] = node.content.content;
198
223
  }
199
- cursor.exitNode();
200
- cursor.exitField();
201
- result.push(content);
202
- });
203
- return result;
204
- });
205
- }
206
- charactersCopy() {
207
- return this.getCharactersSubarray(0, this.length);
208
- }
209
- fullString() {
210
- return this.charactersCopy().join("");
211
- }
212
- getString(startIndex, endIndex = this.length) {
213
- validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getString");
214
- return this.getCharactersSubarray(startIndex, endIndex).join("");
215
- }
216
- getUniformRun(startIndex, endIndex = this.length) {
217
- validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getUniformRun");
218
- if (endIndex === startIndex) {
219
- throw new UsageError("endIndex must be greater than startIndex for getUniformRun.");
220
- }
221
- const arrayLength = this.length;
222
- return this.withBorrowedSequenceCursor((cursor) => {
223
- cursor.enterNode(startIndex);
224
- // Capture the content type of the first atom
225
- cursor.enterField(EmptyKey);
226
- cursor.enterNode(0);
227
- const contentType = cursor.type;
228
- cursor.exitNode();
229
- cursor.exitField();
230
- // Build a comparator from the format subtree of the first atom
231
- // This compares by field key
232
- cursor.enterField(formatKey);
233
- cursor.enterNode(0);
234
- const formatComparator = buildNodeComparator(cursor);
235
- cursor.exitNode();
236
- cursor.exitField();
237
- let runLength = 1;
238
- const limit = Math.min(endIndex, arrayLength) - startIndex;
239
- while (runLength < limit && cursor.nextNode()) {
240
- // Compare atom type
241
- cursor.enterField(EmptyKey);
242
- cursor.enterNode(0);
243
- const typeMatches = cursor.type === contentType;
244
- cursor.exitNode();
245
- cursor.exitField();
246
- if (!typeMatches) {
247
- break;
248
- }
249
- // Compare format subtree using the compiled comparator
250
- cursor.enterField(formatKey);
251
- cursor.enterNode(0);
252
- const formatMatches = formatComparator(cursor);
253
- cursor.exitNode();
254
- cursor.exitField();
255
- if (formatMatches !== true) {
256
- break;
224
+ return result;
225
+ }
226
+ charactersCopy() {
227
+ return this.getCharactersSubarray(0, this.length);
228
+ }
229
+ fullString() {
230
+ return this.charactersCopy().join("");
231
+ }
232
+ getString(startIndex, endIndex = this.length) {
233
+ validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getString");
234
+ return this.getCharactersSubarray(startIndex, endIndex).join("");
235
+ }
236
+ getUniformRun(startIndex, endIndex = this.length) {
237
+ validateIndexRange(startIndex, endIndex, this, "FormattedTextAsTree.getUniformRun");
238
+ if (endIndex === startIndex) {
239
+ throw new UsageError("endIndex must be greater than startIndex for getUniformRun.");
257
240
  }
258
- runLength++;
241
+ const arrayLength = this.length;
242
+ return this.withBorrowedSequenceCursor((cursor) => {
243
+ cursor.enterNode(startIndex);
244
+ // Capture the content type of the first atom
245
+ cursor.enterField(EmptyKey);
246
+ cursor.enterNode(0);
247
+ const contentType = cursor.type;
248
+ cursor.exitNode();
249
+ cursor.exitField();
250
+ // Build a comparator from the format subtree of the first atom
251
+ // This compares by field key
252
+ cursor.enterField(formatKey);
253
+ cursor.enterNode(0);
254
+ const formatComparator = buildNodeComparator(cursor);
255
+ cursor.exitNode();
256
+ cursor.exitField();
257
+ let runLength = 1;
258
+ const limit = Math.min(endIndex, arrayLength) - startIndex;
259
+ while (runLength < limit && cursor.nextNode()) {
260
+ // Compare atom type
261
+ cursor.enterField(EmptyKey);
262
+ cursor.enterNode(0);
263
+ const typeMatches = cursor.type === contentType;
264
+ cursor.exitNode();
265
+ cursor.exitField();
266
+ if (!typeMatches) {
267
+ break;
268
+ }
269
+ // Compare format subtree using the compiled comparator
270
+ cursor.enterField(formatKey);
271
+ cursor.enterNode(0);
272
+ const formatMatches = formatComparator(cursor);
273
+ cursor.exitNode();
274
+ cursor.exitField();
275
+ if (formatMatches !== true) {
276
+ break;
277
+ }
278
+ runLength++;
279
+ }
280
+ cursor.exitNode();
281
+ return runLength;
282
+ });
259
283
  }
260
- cursor.exitNode();
261
- return runLength;
262
- });
263
- }
264
- }
265
- /**
266
- * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
267
- * @privateRemarks
268
- * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
269
- * We will want to generalize this with a more generic schema factory function like with table.
270
- * Then either that and/or the output from it can be package exported.
271
- * This version is just an initial prototype.
272
- * @internal
273
- */
274
- export var FormattedTextAsTree;
275
- (function (FormattedTextAsTree) {
276
- /**
277
- * Formatting options for characters.
278
- * @internal
279
- */
280
- class CharacterFormat extends sf.objectAlpha("CharacterFormat", {
281
- bold: SchemaFactory.boolean,
282
- italic: SchemaFactory.boolean,
283
- underline: SchemaFactory.boolean,
284
- size: SchemaFactory.number,
285
- font: SchemaFactory.string,
286
- }) {
284
+ }
285
+ /**
286
+ * A unit of the text, with formatting.
287
+ */
288
+ class StringAtom extends sf.object("StringAtom", {
289
+ content: SchemaFactory.required(atoms, { key: EmptyKey }),
290
+ format: SchemaFactory.required(formatSchema),
291
+ }) {
292
+ }
293
+ /**
294
+ * Schema for a text node.
295
+ * @remarks
296
+ * See {@link FormattedTextAsTree.Members} for the API.
297
+ * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.
298
+ */
299
+ const Tree = eraseSchemaDetailsSubclassable()(TextNode);
300
+ return Tree;
287
301
  }
288
- FormattedTextAsTree.CharacterFormat = CharacterFormat;
302
+ FormattedTextAsTree.createSchema = createSchema;
289
303
  /**
290
304
  * Unit in the string representing a single character.
291
305
  * @internal
292
306
  */
293
- class StringTextAtom extends sf.object("StringTextAtom", {
307
+ class StringTextAtom extends sfStatic.object("StringTextAtom", {
294
308
  /**
295
309
  * The underlying text content of this atom.
296
310
  * @remarks
@@ -306,66 +320,5 @@ export var FormattedTextAsTree;
306
320
  }) {
307
321
  }
308
322
  FormattedTextAsTree.StringTextAtom = StringTextAtom;
309
- /**
310
- * Tag with which a line in text can be formatted from HTML.
311
- * @internal
312
- */
313
- FormattedTextAsTree.LineTag = enumFromStrings(sf.scopedFactory("lineTag"), [
314
- "h1",
315
- "h2",
316
- "h3",
317
- "h4",
318
- "h5",
319
- "li",
320
- "ol",
321
- "checked",
322
- "unchecked",
323
- "blockquote",
324
- "codeBlock",
325
- ]);
326
- /**
327
- * Unit in the string representing a new line character with line formatting.
328
- * @remarks
329
- * This aligns with how Quill represents line formatting.
330
- * Quill formats line attributes (headers, list, blockquote, etc... ) on the newline character
331
- * and only lines using this atom can have line-specific formatting.
332
- * The optional indent level mirrors Quill's indent attribute,
333
- * which is applies to the line before the line break.
334
- * Any tagged line can be indented independently.
335
- * @internal
336
- */
337
- class StringLineAtom extends sf.object("StringLineAtom", {
338
- tag: FormattedTextAsTree.LineTag.schema,
339
- indent: SchemaFactory.number,
340
- }) {
341
- constructor() {
342
- super(...arguments);
343
- this.content = "\n";
344
- }
345
- }
346
- FormattedTextAsTree.StringLineAtom = StringLineAtom;
347
- /**
348
- * Types of "atoms" that make up the text.
349
- * @internal
350
- */
351
- FormattedTextAsTree.StringAtomContent = [StringTextAtom, StringLineAtom];
352
- /**
353
- * A unit of the text, with formatting.
354
- * @internal
355
- */
356
- class StringAtom extends sf.object("StringAtom", {
357
- content: SchemaFactory.required(FormattedTextAsTree.StringAtomContent, { key: EmptyKey }),
358
- format: CharacterFormat,
359
- }) {
360
- }
361
- FormattedTextAsTree.StringAtom = StringAtom;
362
- /**
363
- * Schema for a text node.
364
- * @remarks
365
- * See {@link FormattedTextAsTree.Members} for the API.
366
- * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.
367
- * @internal
368
- */
369
- FormattedTextAsTree.Tree = eraseSchemaDetails()(TextNode);
370
323
  })(FormattedTextAsTree || (FormattedTextAsTree = {}));
371
324
  //# sourceMappingURL=textDomainFormatted.js.map