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