@ohos-ports/html2canvas-pro 0.0.0-stage → 2.3.2-beta.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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/dist/html2canvas-pro.cjs +11191 -0
  4. package/dist/html2canvas-pro.cjs.map +1 -0
  5. package/dist/html2canvas-pro.esm.js +11182 -0
  6. package/dist/html2canvas-pro.esm.js.map +1 -0
  7. package/dist/html2canvas-pro.js +11196 -0
  8. package/dist/html2canvas-pro.js.map +1 -0
  9. package/dist/html2canvas-pro.min.js +10 -0
  10. package/dist/lib/config.js +49 -0
  11. package/dist/lib/core/abort-helper.js +20 -0
  12. package/dist/lib/core/background-parser.js +41 -0
  13. package/dist/lib/core/bitwise.js +5 -0
  14. package/dist/lib/core/cache-storage.js +268 -0
  15. package/dist/lib/core/config-assembler.js +88 -0
  16. package/dist/lib/core/constants.js +25 -0
  17. package/dist/lib/core/context.js +19 -0
  18. package/dist/lib/core/debugger.js +27 -0
  19. package/dist/lib/core/features.js +190 -0
  20. package/dist/lib/core/logger.js +56 -0
  21. package/dist/lib/core/lru-map.js +66 -0
  22. package/dist/lib/core/origin-checker.js +53 -0
  23. package/dist/lib/core/performance-monitor.js +185 -0
  24. package/dist/lib/core/render-element.js +132 -0
  25. package/dist/lib/core/util.js +4 -0
  26. package/dist/lib/core/validator.js +500 -0
  27. package/dist/lib/css/grouped/background-styles.js +36 -0
  28. package/dist/lib/css/grouped/border-styles.js +75 -0
  29. package/dist/lib/css/grouped/font-styles.js +93 -0
  30. package/dist/lib/css/grouped/layout-styles.js +127 -0
  31. package/dist/lib/css/index.js +330 -0
  32. package/dist/lib/css/layout/bounds.js +52 -0
  33. package/dist/lib/css/layout/text.js +133 -0
  34. package/dist/lib/css/property-descriptor.js +2 -0
  35. package/dist/lib/css/property-descriptors/background-blend-mode.js +41 -0
  36. package/dist/lib/css/property-descriptors/background-clip.js +23 -0
  37. package/dist/lib/css/property-descriptors/background-color.js +10 -0
  38. package/dist/lib/css/property-descriptors/background-image.js +24 -0
  39. package/dist/lib/css/property-descriptors/background-origin.js +23 -0
  40. package/dist/lib/css/property-descriptors/background-position.js +19 -0
  41. package/dist/lib/css/property-descriptors/background-repeat.js +33 -0
  42. package/dist/lib/css/property-descriptors/background-size.js +23 -0
  43. package/dist/lib/css/property-descriptors/border-color.js +14 -0
  44. package/dist/lib/css/property-descriptors/border-image-repeat.js +42 -0
  45. package/dist/lib/css/property-descriptors/border-image-slice.js +45 -0
  46. package/dist/lib/css/property-descriptors/border-image-source.js +22 -0
  47. package/dist/lib/css/property-descriptors/border-radius.js +15 -0
  48. package/dist/lib/css/property-descriptors/border-style.js +26 -0
  49. package/dist/lib/css/property-descriptors/border-width.js +20 -0
  50. package/dist/lib/css/property-descriptors/box-decoration-break.js +18 -0
  51. package/dist/lib/css/property-descriptors/box-shadow.js +54 -0
  52. package/dist/lib/css/property-descriptors/clip-path.js +189 -0
  53. package/dist/lib/css/property-descriptors/color.js +10 -0
  54. package/dist/lib/css/property-descriptors/content.js +19 -0
  55. package/dist/lib/css/property-descriptors/counter-increment.js +35 -0
  56. package/dist/lib/css/property-descriptors/counter-reset.js +18 -0
  57. package/dist/lib/css/property-descriptors/direction.js +18 -0
  58. package/dist/lib/css/property-descriptors/display.js +81 -0
  59. package/dist/lib/css/property-descriptors/duration.js +14 -0
  60. package/dist/lib/css/property-descriptors/filter.js +76 -0
  61. package/dist/lib/css/property-descriptors/float.js +22 -0
  62. package/dist/lib/css/property-descriptors/font-family.js +32 -0
  63. package/dist/lib/css/property-descriptors/font-size.js +10 -0
  64. package/dist/lib/css/property-descriptors/font-style.js +20 -0
  65. package/dist/lib/css/property-descriptors/font-variant-ligatures.js +34 -0
  66. package/dist/lib/css/property-descriptors/font-variant.js +13 -0
  67. package/dist/lib/css/property-descriptors/font-weight.js +25 -0
  68. package/dist/lib/css/property-descriptors/image-rendering.js +33 -0
  69. package/dist/lib/css/property-descriptors/letter-spacing.js +21 -0
  70. package/dist/lib/css/property-descriptors/line-break.js +23 -0
  71. package/dist/lib/css/property-descriptors/line-height.js +24 -0
  72. package/dist/lib/css/property-descriptors/list-style-image.js +17 -0
  73. package/dist/lib/css/property-descriptors/list-style-position.js +18 -0
  74. package/dist/lib/css/property-descriptors/list-style-type.js +122 -0
  75. package/dist/lib/css/property-descriptors/margin.js +13 -0
  76. package/dist/lib/css/property-descriptors/mix-blend-mode.js +31 -0
  77. package/dist/lib/css/property-descriptors/object-fit.js +28 -0
  78. package/dist/lib/css/property-descriptors/object-position.js +42 -0
  79. package/dist/lib/css/property-descriptors/opacity.js +16 -0
  80. package/dist/lib/css/property-descriptors/overflow-wrap.js +18 -0
  81. package/dist/lib/css/property-descriptors/overflow.js +27 -0
  82. package/dist/lib/css/property-descriptors/padding.js +14 -0
  83. package/dist/lib/css/property-descriptors/paint-order.js +33 -0
  84. package/dist/lib/css/property-descriptors/position.js +22 -0
  85. package/dist/lib/css/property-descriptors/quotes.js +41 -0
  86. package/dist/lib/css/property-descriptors/rotate.js +27 -0
  87. package/dist/lib/css/property-descriptors/text-align.js +21 -0
  88. package/dist/lib/css/property-descriptors/text-decoration-color.js +10 -0
  89. package/dist/lib/css/property-descriptors/text-decoration-line.js +28 -0
  90. package/dist/lib/css/property-descriptors/text-decoration-style.js +24 -0
  91. package/dist/lib/css/property-descriptors/text-decoration-thickness.js +26 -0
  92. package/dist/lib/css/property-descriptors/text-overflow.js +18 -0
  93. package/dist/lib/css/property-descriptors/text-shadow.js +46 -0
  94. package/dist/lib/css/property-descriptors/text-transform.js +20 -0
  95. package/dist/lib/css/property-descriptors/text-underline-offset.js +23 -0
  96. package/dist/lib/css/property-descriptors/transform-origin.js +24 -0
  97. package/dist/lib/css/property-descriptors/transform.js +57 -0
  98. package/dist/lib/css/property-descriptors/visibility.js +20 -0
  99. package/dist/lib/css/property-descriptors/webkit-line-clamp.js +26 -0
  100. package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +10 -0
  101. package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +16 -0
  102. package/dist/lib/css/property-descriptors/word-break.js +26 -0
  103. package/dist/lib/css/property-descriptors/writing-mode.js +28 -0
  104. package/dist/lib/css/property-descriptors/z-index.js +19 -0
  105. package/dist/lib/css/property-descriptors/zoom.js +18 -0
  106. package/dist/lib/css/syntax/parser.js +140 -0
  107. package/dist/lib/css/syntax/token-constants.js +214 -0
  108. package/dist/lib/css/syntax/token-singletons.js +36 -0
  109. package/dist/lib/css/syntax/token-types.js +10 -0
  110. package/dist/lib/css/syntax/tokenizer.js +502 -0
  111. package/dist/lib/css/type-descriptor.js +2 -0
  112. package/dist/lib/css/types/angle.js +80 -0
  113. package/dist/lib/css/types/color-math.js +25 -0
  114. package/dist/lib/css/types/color-spaces/a98.js +78 -0
  115. package/dist/lib/css/types/color-spaces/p3.js +86 -0
  116. package/dist/lib/css/types/color-spaces/pro-photo.js +83 -0
  117. package/dist/lib/css/types/color-spaces/rec2020.js +85 -0
  118. package/dist/lib/css/types/color-spaces/srgb.js +79 -0
  119. package/dist/lib/css/types/color-utilities.js +342 -0
  120. package/dist/lib/css/types/color.js +400 -0
  121. package/dist/lib/css/types/functions/-prefix-linear-gradient.js +32 -0
  122. package/dist/lib/css/types/functions/-prefix-radial-gradient.js +83 -0
  123. package/dist/lib/css/types/functions/-webkit-gradient.js +59 -0
  124. package/dist/lib/css/types/functions/counter.js +367 -0
  125. package/dist/lib/css/types/functions/gradient.js +163 -0
  126. package/dist/lib/css/types/functions/linear-gradient.js +27 -0
  127. package/dist/lib/css/types/functions/radial-gradient.js +90 -0
  128. package/dist/lib/css/types/functions/repeating-linear-gradient.js +9 -0
  129. package/dist/lib/css/types/image.js +62 -0
  130. package/dist/lib/css/types/index.js +2 -0
  131. package/dist/lib/css/types/length-percentage.js +197 -0
  132. package/dist/lib/css/types/length.js +5 -0
  133. package/dist/lib/css/types/safe-eval.js +80 -0
  134. package/dist/lib/css/types/time.js +17 -0
  135. package/dist/lib/dom/document-cloner.js +597 -0
  136. package/dist/lib/dom/dom-normalizer.js +115 -0
  137. package/dist/lib/dom/element-container.js +56 -0
  138. package/dist/lib/dom/elements/li-element-container.js +11 -0
  139. package/dist/lib/dom/elements/ol-element-container.js +12 -0
  140. package/dist/lib/dom/elements/select-element-container.js +12 -0
  141. package/dist/lib/dom/elements/textarea-element-container.js +11 -0
  142. package/dist/lib/dom/node-parser.js +112 -0
  143. package/dist/lib/dom/node-type-guards.js +81 -0
  144. package/dist/lib/dom/replaced-elements/canvas-element-container.js +13 -0
  145. package/dist/lib/dom/replaced-elements/iframe-element-container.js +38 -0
  146. package/dist/lib/dom/replaced-elements/image-element-container.js +14 -0
  147. package/dist/lib/dom/replaced-elements/index.js +2 -0
  148. package/dist/lib/dom/replaced-elements/input-element-container.js +89 -0
  149. package/dist/lib/dom/replaced-elements/svg-element-container.js +19 -0
  150. package/dist/lib/dom/slot-cloner.js +176 -0
  151. package/dist/lib/dom/text-container.js +35 -0
  152. package/dist/lib/index.js +49 -0
  153. package/dist/lib/options.js +2 -0
  154. package/dist/lib/render/background.js +188 -0
  155. package/dist/lib/render/bezier-curve.js +34 -0
  156. package/dist/lib/render/border.js +104 -0
  157. package/dist/lib/render/bound-curves.js +188 -0
  158. package/dist/lib/render/box-sizing.js +20 -0
  159. package/dist/lib/render/canvas/background-renderer.js +327 -0
  160. package/dist/lib/render/canvas/border-image-renderer.js +153 -0
  161. package/dist/lib/render/canvas/border-renderer.js +184 -0
  162. package/dist/lib/render/canvas/canvas-path.js +25 -0
  163. package/dist/lib/render/canvas/canvas-renderer.js +312 -0
  164. package/dist/lib/render/canvas/content-renderer.js +204 -0
  165. package/dist/lib/render/canvas/effects-renderer.js +171 -0
  166. package/dist/lib/render/canvas/font-utils.js +29 -0
  167. package/dist/lib/render/canvas/foreignobject-renderer.js +38 -0
  168. package/dist/lib/render/canvas/text/text-decoration-renderer.js +99 -0
  169. package/dist/lib/render/canvas/text-renderer.js +485 -0
  170. package/dist/lib/render/effects.js +231 -0
  171. package/dist/lib/render/font-metrics.js +53 -0
  172. package/dist/lib/render/object-fit.js +91 -0
  173. package/dist/lib/render/path.js +26 -0
  174. package/dist/lib/render/renderer-interface.js +2 -0
  175. package/dist/lib/render/stacking-context.js +340 -0
  176. package/dist/lib/render/vector.js +16 -0
  177. package/dist/types/config.d.ts +44 -0
  178. package/dist/types/core/abort-helper.d.ts +12 -0
  179. package/dist/types/core/background-parser.d.ts +16 -0
  180. package/dist/types/core/bitwise.d.ts +1 -0
  181. package/dist/types/core/cache-storage.d.ts +68 -0
  182. package/dist/types/core/config-assembler.d.ts +28 -0
  183. package/dist/types/core/constants.d.ts +22 -0
  184. package/dist/types/core/context.d.ts +22 -0
  185. package/dist/types/core/debugger.d.ts +8 -0
  186. package/dist/types/core/features.d.ts +12 -0
  187. package/dist/types/core/logger.d.ts +18 -0
  188. package/dist/types/core/lru-map.d.ts +37 -0
  189. package/dist/types/core/origin-checker.d.ts +33 -0
  190. package/dist/types/core/performance-monitor.d.ts +120 -0
  191. package/dist/types/core/render-element.d.ts +3 -0
  192. package/dist/types/core/util.d.ts +1 -0
  193. package/dist/types/core/validator.d.ts +130 -0
  194. package/dist/types/css/grouped/background-styles.d.ts +16 -0
  195. package/dist/types/css/grouped/border-styles.d.ts +31 -0
  196. package/dist/types/css/grouped/font-styles.d.ts +35 -0
  197. package/dist/types/css/grouped/layout-styles.d.ts +46 -0
  198. package/dist/types/css/index.d.ts +185 -0
  199. package/dist/types/css/layout/bounds.d.ts +14 -0
  200. package/dist/types/css/layout/text.d.ts +10 -0
  201. package/dist/types/css/property-descriptor.d.ts +40 -0
  202. package/dist/types/css/property-descriptors/background-blend-mode.d.ts +23 -0
  203. package/dist/types/css/property-descriptors/background-clip.d.ts +8 -0
  204. package/dist/types/css/property-descriptors/background-color.d.ts +2 -0
  205. package/dist/types/css/property-descriptors/background-image.d.ts +3 -0
  206. package/dist/types/css/property-descriptors/background-origin.d.ts +8 -0
  207. package/dist/types/css/property-descriptors/background-position.d.ts +5 -0
  208. package/dist/types/css/property-descriptors/background-repeat.d.ts +9 -0
  209. package/dist/types/css/property-descriptors/background-size.d.ts +11 -0
  210. package/dist/types/css/property-descriptors/border-color.d.ts +5 -0
  211. package/dist/types/css/property-descriptors/border-image-repeat.d.ts +12 -0
  212. package/dist/types/css/property-descriptors/border-image-slice.d.ts +10 -0
  213. package/dist/types/css/property-descriptors/border-image-source.d.ts +4 -0
  214. package/dist/types/css/property-descriptors/border-radius.d.ts +7 -0
  215. package/dist/types/css/property-descriptors/border-style.d.ts +12 -0
  216. package/dist/types/css/property-descriptors/border-width.d.ts +5 -0
  217. package/dist/types/css/property-descriptors/box-decoration-break.d.ts +6 -0
  218. package/dist/types/css/property-descriptors/box-shadow.d.ts +14 -0
  219. package/dist/types/css/property-descriptors/clip-path.d.ts +62 -0
  220. package/dist/types/css/property-descriptors/color.d.ts +2 -0
  221. package/dist/types/css/property-descriptors/content.d.ts +4 -0
  222. package/dist/types/css/property-descriptors/counter-increment.d.ts +10 -0
  223. package/dist/types/css/property-descriptors/counter-reset.d.ts +7 -0
  224. package/dist/types/css/property-descriptors/direction.d.ts +6 -0
  225. package/dist/types/css/property-descriptors/display.d.ts +35 -0
  226. package/dist/types/css/property-descriptors/duration.d.ts +2 -0
  227. package/dist/types/css/property-descriptors/filter.d.ts +3 -0
  228. package/dist/types/css/property-descriptors/float.d.ts +9 -0
  229. package/dist/types/css/property-descriptors/font-family.d.ts +4 -0
  230. package/dist/types/css/property-descriptors/font-size.d.ts +2 -0
  231. package/dist/types/css/property-descriptors/font-style.d.ts +7 -0
  232. package/dist/types/css/property-descriptors/font-variant-ligatures.d.ts +14 -0
  233. package/dist/types/css/property-descriptors/font-variant.d.ts +2 -0
  234. package/dist/types/css/property-descriptors/font-weight.d.ts +2 -0
  235. package/dist/types/css/property-descriptors/image-rendering.d.ts +8 -0
  236. package/dist/types/css/property-descriptors/letter-spacing.d.ts +2 -0
  237. package/dist/types/css/property-descriptors/line-break.d.ts +6 -0
  238. package/dist/types/css/property-descriptors/line-height.d.ts +4 -0
  239. package/dist/types/css/property-descriptors/list-style-image.d.ts +3 -0
  240. package/dist/types/css/property-descriptors/list-style-position.d.ts +6 -0
  241. package/dist/types/css/property-descriptors/list-style-type.d.ts +58 -0
  242. package/dist/types/css/property-descriptors/margin.d.ts +5 -0
  243. package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +21 -0
  244. package/dist/types/css/property-descriptors/object-fit.d.ts +10 -0
  245. package/dist/types/css/property-descriptors/object-position.d.ts +4 -0
  246. package/dist/types/css/property-descriptors/opacity.d.ts +2 -0
  247. package/dist/types/css/property-descriptors/overflow-wrap.d.ts +6 -0
  248. package/dist/types/css/property-descriptors/overflow.d.ts +9 -0
  249. package/dist/types/css/property-descriptors/padding.d.ts +5 -0
  250. package/dist/types/css/property-descriptors/paint-order.d.ts +8 -0
  251. package/dist/types/css/property-descriptors/position.d.ts +9 -0
  252. package/dist/types/css/property-descriptors/quotes.d.ts +8 -0
  253. package/dist/types/css/property-descriptors/rotate.d.ts +3 -0
  254. package/dist/types/css/property-descriptors/text-align.d.ts +7 -0
  255. package/dist/types/css/property-descriptors/text-decoration-color.d.ts +2 -0
  256. package/dist/types/css/property-descriptors/text-decoration-line.d.ts +10 -0
  257. package/dist/types/css/property-descriptors/text-decoration-style.d.ts +9 -0
  258. package/dist/types/css/property-descriptors/text-decoration-thickness.d.ts +3 -0
  259. package/dist/types/css/property-descriptors/text-overflow.d.ts +6 -0
  260. package/dist/types/css/property-descriptors/text-shadow.d.ts +12 -0
  261. package/dist/types/css/property-descriptors/text-transform.d.ts +8 -0
  262. package/dist/types/css/property-descriptors/text-underline-offset.d.ts +3 -0
  263. package/dist/types/css/property-descriptors/transform-origin.d.ts +4 -0
  264. package/dist/types/css/property-descriptors/transform.d.ts +4 -0
  265. package/dist/types/css/property-descriptors/visibility.d.ts +7 -0
  266. package/dist/types/css/property-descriptors/webkit-line-clamp.d.ts +7 -0
  267. package/dist/types/css/property-descriptors/webkit-text-stroke-color.d.ts +2 -0
  268. package/dist/types/css/property-descriptors/webkit-text-stroke-width.d.ts +2 -0
  269. package/dist/types/css/property-descriptors/word-break.d.ts +7 -0
  270. package/dist/types/css/property-descriptors/writing-mode.d.ts +11 -0
  271. package/dist/types/css/property-descriptors/z-index.d.ts +7 -0
  272. package/dist/types/css/property-descriptors/zoom.d.ts +3 -0
  273. package/dist/types/css/syntax/parser.d.ts +34 -0
  274. package/dist/types/css/syntax/token-constants.d.ts +74 -0
  275. package/dist/types/css/syntax/token-singletons.d.ts +22 -0
  276. package/dist/types/css/syntax/token-types.d.ts +72 -0
  277. package/dist/types/css/syntax/tokenizer.d.ts +32 -0
  278. package/dist/types/css/type-descriptor.d.ts +6 -0
  279. package/dist/types/css/types/angle.d.ts +7 -0
  280. package/dist/types/css/types/color-math.d.ts +12 -0
  281. package/dist/types/css/types/color-spaces/a98.d.ts +39 -0
  282. package/dist/types/css/types/color-spaces/p3.d.ts +45 -0
  283. package/dist/types/css/types/color-spaces/pro-photo.d.ts +45 -0
  284. package/dist/types/css/types/color-spaces/rec2020.d.ts +45 -0
  285. package/dist/types/css/types/color-spaces/srgb.d.ts +38 -0
  286. package/dist/types/css/types/color-utilities.d.ts +107 -0
  287. package/dist/types/css/types/color.d.ts +8 -0
  288. package/dist/types/css/types/functions/-prefix-linear-gradient.d.ts +4 -0
  289. package/dist/types/css/types/functions/-prefix-radial-gradient.d.ts +4 -0
  290. package/dist/types/css/types/functions/-webkit-gradient.d.ts +4 -0
  291. package/dist/types/css/types/functions/counter.d.ts +10 -0
  292. package/dist/types/css/types/functions/gradient.d.ts +7 -0
  293. package/dist/types/css/types/functions/linear-gradient.d.ts +4 -0
  294. package/dist/types/css/types/functions/radial-gradient.d.ts +12 -0
  295. package/dist/types/css/types/functions/repeating-linear-gradient.d.ts +4 -0
  296. package/dist/types/css/types/image.d.ts +56 -0
  297. package/dist/types/css/types/index.d.ts +1 -0
  298. package/dist/types/css/types/length-percentage.d.ts +62 -0
  299. package/dist/types/css/types/length.d.ts +4 -0
  300. package/dist/types/css/types/safe-eval.d.ts +8 -0
  301. package/dist/types/css/types/time.d.ts +2 -0
  302. package/dist/types/dom/document-cloner.d.ts +57 -0
  303. package/dist/types/dom/dom-normalizer.d.ts +62 -0
  304. package/dist/types/dom/element-container.d.ts +31 -0
  305. package/dist/types/dom/elements/li-element-container.d.ts +6 -0
  306. package/dist/types/dom/elements/ol-element-container.d.ts +7 -0
  307. package/dist/types/dom/elements/select-element-container.d.ts +6 -0
  308. package/dist/types/dom/elements/textarea-element-container.d.ts +6 -0
  309. package/dist/types/dom/node-parser.d.ts +3 -0
  310. package/dist/types/dom/node-type-guards.d.ts +32 -0
  311. package/dist/types/dom/replaced-elements/canvas-element-container.d.ts +8 -0
  312. package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +14 -0
  313. package/dist/types/dom/replaced-elements/image-element-container.d.ts +8 -0
  314. package/dist/types/dom/replaced-elements/index.d.ts +4 -0
  315. package/dist/types/dom/replaced-elements/input-element-container.d.ts +14 -0
  316. package/dist/types/dom/replaced-elements/svg-element-container.d.ts +8 -0
  317. package/dist/types/dom/slot-cloner.d.ts +66 -0
  318. package/dist/types/dom/text-container.d.ts +8 -0
  319. package/dist/types/index.d.ts +36 -0
  320. package/dist/types/options.d.ts +62 -0
  321. package/dist/types/render/background.d.ts +16 -0
  322. package/dist/types/render/bezier-curve.d.ts +14 -0
  323. package/dist/types/render/border.d.ts +6 -0
  324. package/dist/types/render/bound-curves.d.ts +32 -0
  325. package/dist/types/render/box-sizing.d.ts +4 -0
  326. package/dist/types/render/canvas/background-renderer.d.ts +94 -0
  327. package/dist/types/render/canvas/border-image-renderer.d.ts +18 -0
  328. package/dist/types/render/canvas/border-renderer.d.ts +67 -0
  329. package/dist/types/render/canvas/canvas-path.d.ts +3 -0
  330. package/dist/types/render/canvas/canvas-renderer.d.ts +60 -0
  331. package/dist/types/render/canvas/content-renderer.d.ts +43 -0
  332. package/dist/types/render/canvas/effects-renderer.d.ts +90 -0
  333. package/dist/types/render/canvas/font-utils.d.ts +19 -0
  334. package/dist/types/render/canvas/foreignobject-renderer.d.ts +10 -0
  335. package/dist/types/render/canvas/text/text-decoration-renderer.d.ts +18 -0
  336. package/dist/types/render/canvas/text-renderer.d.ts +103 -0
  337. package/dist/types/render/effects.d.ts +112 -0
  338. package/dist/types/render/font-metrics.d.ts +11 -0
  339. package/dist/types/render/object-fit.d.ts +19 -0
  340. package/dist/types/render/path.d.ts +13 -0
  341. package/dist/types/render/renderer-interface.d.ts +28 -0
  342. package/dist/types/render/stacking-context.d.ts +49 -0
  343. package/dist/types/render/vector.d.ts +9 -0
  344. package/package.json +139 -4
@@ -0,0 +1,485 @@
1
+ "use strict";
2
+ /**
3
+ * Text Renderer
4
+ *
5
+ * Handles rendering of text content including:
6
+ * - Text with letter spacing
7
+ * - Text decorations (underline, overline, line-through)
8
+ * - Text shadows
9
+ * - Webkit line clamp
10
+ * - Text overflow ellipsis
11
+ * - Paint order (fill/stroke)
12
+ * - Font styles
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TextRenderer = exports.hasCJKCharacters = void 0;
16
+ const text_1 = require("../../css/layout/text");
17
+ const color_utilities_1 = require("../../css/types/color-utilities");
18
+ const parser_1 = require("../../css/syntax/parser");
19
+ const writing_mode_1 = require("../../css/property-descriptors/writing-mode");
20
+ const text_decoration_renderer_1 = require("./text/text-decoration-renderer");
21
+ const font_utils_1 = require("./font-utils");
22
+ // iOS font fix - see https://github.com/niklasvh/html2canvas/pull/2645
23
+ const iOSBrokenFonts = ['-apple-system', 'system-ui'];
24
+ /**
25
+ * Detect CJK (Chinese, Japanese, Korean) characters in a string.
26
+ * CJK characters use the ideographic baseline in browsers, which differs
27
+ * from the alphabetic baseline used for Latin script.
28
+ *
29
+ * Covers:
30
+ * U+2E80–U+2FFF CJK Radicals Supplement, Kangxi Radicals
31
+ * U+3000–U+30FF CJK Symbols & Punctuation (。、「」…), Hiragana, Katakana
32
+ * U+3400–U+4DBF CJK Extension A
33
+ * U+4E00–U+9FFF CJK Unified Ideographs (most common Chinese/Japanese/Korean)
34
+ * U+AC00–U+D7AF Hangul Syllables
35
+ * U+F900–U+FAFF CJK Compatibility Ideographs
36
+ * U+FF01–U+FFEF Halfwidth and Fullwidth Forms (A B 1 2 ! ? etc.)
37
+ */
38
+ const CJK_CHAR_REGEX = /[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/;
39
+ const hasCJKCharacters = (text) => CJK_CHAR_REGEX.test(text);
40
+ exports.hasCJKCharacters = hasCJKCharacters;
41
+ /**
42
+ * Detect iOS version from user agent
43
+ * Returns null if not iOS or version cannot be determined
44
+ */
45
+ const getIOSVersion = () => {
46
+ if (typeof navigator === 'undefined') {
47
+ return null;
48
+ }
49
+ const userAgent = navigator.userAgent;
50
+ // Check if it's iOS or iPadOS
51
+ // iPadOS 13+ may identify as Macintosh, check for touch support
52
+ const isIOS = /iPhone|iPad|iPod/.test(userAgent);
53
+ const isIPadOS = /Macintosh/.test(userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1;
54
+ if (!isIOS && !isIPadOS) {
55
+ return null;
56
+ }
57
+ // Extract version number from various iOS user agent formats:
58
+ // - "iPhone OS 15_0" or "iPhone OS 15_0_1"
59
+ // - "CPU OS 15_0 like Mac OS X"
60
+ // - "CPU iPhone OS 15_0 like Mac OS X"
61
+ // - "Version/15.0" (for iPadOS)
62
+ const patterns = [
63
+ /(?:iPhone|CPU(?:\siPhone)?)\sOS\s(\d+)[\._](\d+)/, // iPhone OS, CPU OS, CPU iPhone OS
64
+ /Version\/(\d+)\.(\d+)/ // Version/15.0 (iPadOS)
65
+ ];
66
+ for (const pattern of patterns) {
67
+ const match = userAgent.match(pattern);
68
+ if (match && match[1]) {
69
+ return parseInt(match[1], 10);
70
+ }
71
+ }
72
+ return null;
73
+ };
74
+ const fixIOSSystemFonts = (fontFamilies) => {
75
+ const iosVersion = getIOSVersion();
76
+ // On iOS 15.0 and 15.1, system fonts have rendering issues
77
+ // Fixed in iOS 17+
78
+ if (iosVersion !== null && iosVersion >= 15 && iosVersion < 17) {
79
+ return fontFamilies.map((fontFamily) => iOSBrokenFonts.indexOf(fontFamily) !== -1
80
+ ? `-apple-system, "Helvetica Neue", Arial, sans-serif`
81
+ : fontFamily);
82
+ }
83
+ return fontFamilies;
84
+ };
85
+ const getTextStrokeLineJoin = () => {
86
+ const currentWindow = typeof window !== 'undefined' ? window : undefined;
87
+ return currentWindow?.chrome ? 'miter' : 'round';
88
+ };
89
+ /**
90
+ * Text Renderer
91
+ *
92
+ * Specialized renderer for text content.
93
+ * Extracted from CanvasRenderer to improve code organization and maintainability.
94
+ */
95
+ class TextRenderer {
96
+ constructor(deps) {
97
+ /**
98
+ * Per-render glyph width cache. Keyed by glyph + font string,
99
+ * avoids redundant `measureText` calls when letter-spacing is non-zero.
100
+ * Cleared at the start of each renderTextNode call.
101
+ */
102
+ this.glyphWidthCache = null;
103
+ this.ctx = deps.ctx;
104
+ this.options = deps.options;
105
+ this.decorationRenderer = new text_decoration_renderer_1.TextDecorationRenderer(deps.ctx);
106
+ }
107
+ /**
108
+ * Returns the cached width for a glyph+font pair, measuring via
109
+ * measureText if not yet cached. Only used when letterSpacing !== 0
110
+ * (the `canRenderWholeText` fast path handles the zero-spacing case).
111
+ */
112
+ cachedMeasureText(glyph, fontString) {
113
+ let cache = this.glyphWidthCache;
114
+ if (!cache) {
115
+ cache = new Map();
116
+ this.glyphWidthCache = cache;
117
+ }
118
+ const key = glyph + fontString;
119
+ let w = cache.get(key);
120
+ if (w === undefined) {
121
+ w = this.ctx.measureText(glyph).width;
122
+ cache.set(key, w);
123
+ }
124
+ return w;
125
+ }
126
+ /**
127
+ * Iterate grapheme clusters one-by-one, applying correct letter-spacing and
128
+ * per-script baseline for each character.
129
+ *
130
+ * Issue #73: When letter-spacing is non-zero, text must be rendered character by
131
+ * character. This helper centralises two fixes applied during that iteration:
132
+ * 1. Add `letterSpacing` to each character's advance width (was previously
133
+ * omitted, causing characters to render without any spacing).
134
+ * 2. Switch to the ideographic baseline for CJK glyphs so their vertical
135
+ * position matches how browsers lay them out in the DOM.
136
+ *
137
+ * The `renderFn` callback receives (letter, x, y) and performs the actual draw
138
+ * call (fillText or strokeText), allowing fill and stroke paths to share one
139
+ * implementation.
140
+ */
141
+ iterateLettersWithLetterSpacing(text, letterSpacing, baseline, writingMode, renderFn) {
142
+ if ((0, writing_mode_1.isVerticalWritingMode)(writingMode)) {
143
+ this.iterateVerticalGlyphs(text, letterSpacing, baseline, writingMode, renderFn);
144
+ return;
145
+ }
146
+ const letters = (0, text_1.segmentGraphemes)(text.text);
147
+ const y = text.bounds.top + baseline;
148
+ const fontString = this.ctx.font;
149
+ let left = text.bounds.left;
150
+ for (const letter of letters) {
151
+ if ((0, exports.hasCJKCharacters)(letter)) {
152
+ const savedBaseline = this.ctx.textBaseline;
153
+ this.ctx.textBaseline = 'ideographic';
154
+ renderFn(letter, left, y);
155
+ this.ctx.textBaseline = savedBaseline;
156
+ }
157
+ else {
158
+ renderFn(letter, left, y);
159
+ }
160
+ left += this.cachedMeasureText(letter, fontString) + letterSpacing;
161
+ }
162
+ }
163
+ iterateVerticalGlyphs(text, letterSpacing, baseline, writingMode, renderFn) {
164
+ const letters = (0, text_1.segmentGraphemes)(text.text);
165
+ const fontString = this.ctx.font;
166
+ const rotationAngle = writingMode === 4 /* WRITING_MODE.SIDEWAYS_LR */ ? -Math.PI / 2 : Math.PI / 2;
167
+ let top = text.bounds.top;
168
+ for (let i = 0; i < letters.length;) {
169
+ const letter = letters[i];
170
+ const isSideways = (0, writing_mode_1.isSidewaysWritingMode)(writingMode) || (!(0, exports.hasCJKCharacters)(letter) && letter.trim().length > 0);
171
+ if (!isSideways) {
172
+ // CJK glyph in vertical writing mode — render upright
173
+ const savedBaseline = this.ctx.textBaseline;
174
+ if ((0, exports.hasCJKCharacters)(letter)) {
175
+ this.ctx.textBaseline = 'ideographic';
176
+ }
177
+ renderFn(letter, text.bounds.left, top + baseline);
178
+ this.ctx.textBaseline = savedBaseline;
179
+ top += this.cachedMeasureText(letter, fontString) + letterSpacing;
180
+ i++;
181
+ continue;
182
+ }
183
+ // ── Batch consecutive sideways glyphs into one save/restore ──
184
+ const runStart = i;
185
+ while (i < letters.length) {
186
+ const ch = letters[i];
187
+ if (!(0, writing_mode_1.isSidewaysWritingMode)(writingMode) && !(0, exports.hasCJKCharacters)(ch) && ch.trim().length === 0)
188
+ break;
189
+ if ((0, writing_mode_1.isSidewaysWritingMode)(writingMode) || (!(0, exports.hasCJKCharacters)(ch) && ch.trim().length > 0)) {
190
+ i++;
191
+ }
192
+ else {
193
+ break;
194
+ }
195
+ }
196
+ // Render entire sideways run in one save/restore
197
+ this.ctx.save();
198
+ this.ctx.translate(text.bounds.left + baseline, top);
199
+ this.ctx.rotate(rotationAngle);
200
+ let runOffset = 0;
201
+ for (let j = runStart; j < i; j++) {
202
+ renderFn(letters[j], 0, runOffset);
203
+ runOffset += this.cachedMeasureText(letters[j], fontString) + letterSpacing;
204
+ }
205
+ this.ctx.restore();
206
+ top += runOffset;
207
+ }
208
+ }
209
+ /**
210
+ * Render text with letter-spacing applied (fill pass).
211
+ * When letterSpacing is 0 the whole string is drawn in one call; otherwise each
212
+ * grapheme is drawn individually so spacing and CJK baseline are applied correctly.
213
+ */
214
+ renderTextWithLetterSpacing(text, letterSpacing, baseline, writingMode = 0 /* WRITING_MODE.HORIZONTAL_TB */) {
215
+ this.renderFillText(text, letterSpacing, baseline, writingMode);
216
+ }
217
+ canRenderWholeText(letterSpacing, writingMode) {
218
+ return letterSpacing === 0 && !(0, writing_mode_1.isVerticalWritingMode)(writingMode);
219
+ }
220
+ renderFillText(text, letterSpacing, baseline, writingMode) {
221
+ if (this.canRenderWholeText(letterSpacing, writingMode)) {
222
+ this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
223
+ }
224
+ else {
225
+ this.iterateLettersWithLetterSpacing(text, letterSpacing, baseline, writingMode, (letter, x, y) => {
226
+ this.ctx.fillText(letter, x, y);
227
+ });
228
+ }
229
+ }
230
+ renderStrokeText(text, letterSpacing, baseline, writingMode) {
231
+ if (this.canRenderWholeText(letterSpacing, writingMode)) {
232
+ this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + baseline);
233
+ }
234
+ else {
235
+ this.iterateLettersWithLetterSpacing(text, letterSpacing, baseline, writingMode, (letter, x, y) => {
236
+ this.ctx.strokeText(letter, x, y);
237
+ });
238
+ }
239
+ }
240
+ renderTextStrokeWithStyle(text, styles, baseline) {
241
+ if (!styles.webkitTextStrokeWidth || !text.text.trim().length) {
242
+ return;
243
+ }
244
+ this.ctx.strokeStyle = (0, color_utilities_1.asString)(styles.webkitTextStrokeColor);
245
+ this.ctx.lineWidth = styles.webkitTextStrokeWidth;
246
+ this.ctx.lineJoin = getTextStrokeLineJoin();
247
+ this.renderStrokeText(text, styles.letterSpacing, baseline, styles.writingMode);
248
+ this.ctx.strokeStyle = '';
249
+ this.ctx.lineWidth = 0;
250
+ this.ctx.lineJoin = 'miter';
251
+ }
252
+ renderTextFillWithShadows(text, styles, baseline) {
253
+ this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.color);
254
+ this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline, styles.writingMode);
255
+ const textShadows = styles.textShadow;
256
+ if (textShadows.length && text.text.trim().length) {
257
+ textShadows
258
+ .slice(0)
259
+ .reverse()
260
+ .forEach((textShadow) => {
261
+ this.ctx.shadowColor = (0, color_utilities_1.asString)(textShadow.color);
262
+ this.ctx.shadowOffsetX = textShadow.offsetX.number * this.options.scale;
263
+ this.ctx.shadowOffsetY = textShadow.offsetY.number * this.options.scale;
264
+ this.ctx.shadowBlur = textShadow.blur.number;
265
+ this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline, styles.writingMode);
266
+ });
267
+ this.ctx.shadowColor = '';
268
+ this.ctx.shadowOffsetX = 0;
269
+ this.ctx.shadowOffsetY = 0;
270
+ this.ctx.shadowBlur = 0;
271
+ }
272
+ }
273
+ /**
274
+ * Helper method to render text with paint order support
275
+ * Reduces code duplication in line-clamp and normal rendering
276
+ */
277
+ renderTextBoundWithPaintOrder(textBound, styles, paintOrderLayers, baseline) {
278
+ paintOrderLayers.forEach((paintOrderLayer) => {
279
+ switch (paintOrderLayer) {
280
+ case 0 /* PAINT_ORDER_LAYER.FILL */:
281
+ this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.color);
282
+ this.renderTextWithLetterSpacing(textBound, styles.letterSpacing, baseline, styles.writingMode);
283
+ break;
284
+ case 1 /* PAINT_ORDER_LAYER.STROKE */:
285
+ this.renderTextStrokeWithStyle(textBound, styles, baseline);
286
+ break;
287
+ }
288
+ });
289
+ }
290
+ renderTextDecoration(bounds, styles) {
291
+ this.decorationRenderer.render(bounds, styles);
292
+ }
293
+ // Helper method to truncate text and add ellipsis if needed
294
+ truncateTextWithEllipsis(text, maxWidth, letterSpacing) {
295
+ // Use the Unicode ellipsis character (U+2026) whose width the browser measures
296
+ // as a single glyph, matching native text-overflow behaviour more closely.
297
+ const ellipsis = '\u2026';
298
+ const ellipsisWidth = this.ctx.measureText(ellipsis).width;
299
+ // Segment into grapheme clusters so multi-byte characters (emoji, composed
300
+ // sequences) are never split mid-character.
301
+ const graphemes = (0, text_1.segmentGraphemes)(text);
302
+ if (letterSpacing === 0) {
303
+ // Measure the whole candidate string for accuracy: the browser applies
304
+ // kerning and ligatures when rendering multiple glyphs together, so
305
+ // measuring them as one string is more precise than summing individual widths.
306
+ // Binary search reduces measurements from O(n) to O(log n).
307
+ // NOTE: can't use cachedMeasureText here — the binary search measures
308
+ // concatenated substrings, and kerning/ligatures depend on the full string.
309
+ const fits = (n) => this.ctx.measureText(graphemes.slice(0, n).join('')).width + ellipsisWidth <= maxWidth;
310
+ let lo = 0;
311
+ let hi = graphemes.length;
312
+ while (lo < hi) {
313
+ const mid = (lo + hi + 1) >> 1;
314
+ if (fits(mid)) {
315
+ lo = mid;
316
+ }
317
+ else {
318
+ hi = mid - 1;
319
+ }
320
+ }
321
+ return graphemes.slice(0, lo).join('') + ellipsis;
322
+ }
323
+ else {
324
+ const fontString = this.ctx.font;
325
+ let width = ellipsisWidth;
326
+ const result = [];
327
+ for (const letter of graphemes) {
328
+ const glyphWidth = this.cachedMeasureText(letter, fontString);
329
+ // Check against glyph width only (no trailing spacing): letter-spacing
330
+ // is applied *between* characters, not after the final glyph. Using
331
+ // `glyphWidth + letterSpacing` would incorrectly discard letters that
332
+ // fit as the last character before the ellipsis.
333
+ if (width + glyphWidth > maxWidth) {
334
+ break;
335
+ }
336
+ result.push(letter);
337
+ // Accumulate glyph + inter-character spacing for the *next* iteration.
338
+ width += glyphWidth + letterSpacing;
339
+ }
340
+ return result.join('') + ellipsis;
341
+ }
342
+ }
343
+ /**
344
+ * Create font style array
345
+ * Public method used by list rendering
346
+ */
347
+ createFontStyle(styles) {
348
+ const fontVariant = styles.fontVariant
349
+ .filter((variant) => variant === 'normal' || variant === 'small-caps')
350
+ .join('');
351
+ const fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', ');
352
+ const fontSize = (0, parser_1.isDimensionToken)(styles.fontSize)
353
+ ? `${styles.fontSize.number}${styles.fontSize.unit}`
354
+ : `${styles.fontSize.number}px`;
355
+ return [
356
+ [styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
357
+ fontFamily,
358
+ fontSize
359
+ ];
360
+ }
361
+ /**
362
+ * Render text with -webkit-line-clamp truncation.
363
+ * Groups text bounds by their Y position into visual lines, then renders
364
+ * only the first N-1 complete lines followed by an ellipsis on the Nth line.
365
+ */
366
+ renderLineClampedText(text, styles, paintOrder, baseline, containerBounds) {
367
+ const lineHeight = styles.fontSize.number * 1.5;
368
+ const lines = [];
369
+ let currentLine = [];
370
+ let currentLineTop = text.textBounds[0].bounds.top;
371
+ text.textBounds.forEach((tb) => {
372
+ if (Math.abs(tb.bounds.top - currentLineTop) >= lineHeight * 0.5) {
373
+ if (currentLine.length > 0)
374
+ lines.push(currentLine);
375
+ currentLine = [tb];
376
+ currentLineTop = tb.bounds.top;
377
+ }
378
+ else {
379
+ currentLine.push(tb);
380
+ }
381
+ });
382
+ if (currentLine.length > 0)
383
+ lines.push(currentLine);
384
+ const maxLines = styles.webkitLineClamp;
385
+ if (lines.length <= maxLines)
386
+ return false; // fall through to normal rendering
387
+ // Render full lines (0..N-2)
388
+ for (let i = 0; i < maxLines - 1; i++) {
389
+ lines[i].forEach((tb) => this.renderTextBoundWithPaintOrder(tb, styles, paintOrder, baseline));
390
+ }
391
+ // Nth line: truncated with ellipsis
392
+ const lastLine = lines[maxLines - 1];
393
+ if (lastLine?.length && containerBounds) {
394
+ const textStr = lastLine.map((tb) => tb.text).join('');
395
+ const first = lastLine[0];
396
+ const avail = containerBounds.width - (first.bounds.left - containerBounds.left);
397
+ const truncated = this.truncateTextWithEllipsis(textStr, avail, styles.letterSpacing);
398
+ const bounds = new text_1.TextBounds(truncated, first.bounds);
399
+ for (const layer of paintOrder) {
400
+ if (layer === 0 /* PAINT_ORDER_LAYER.FILL */) {
401
+ this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.color);
402
+ this.renderTextWithLetterSpacing(bounds, styles.letterSpacing, baseline, styles.writingMode);
403
+ }
404
+ else if (layer === 1 /* PAINT_ORDER_LAYER.STROKE */) {
405
+ this.renderTextStrokeWithStyle(bounds, styles, baseline);
406
+ }
407
+ }
408
+ }
409
+ return true;
410
+ }
411
+ /**
412
+ * Render single-line text with text-overflow: ellipsis.
413
+ * Returns true if ellipsis was applied (caller should skip normal rendering).
414
+ */
415
+ renderEllipsisText(text, styles, paintOrder, baseline, containerBounds) {
416
+ const lineHeight = styles.fontSize.number * 1.5;
417
+ const firstTop = text.textBounds[0].bounds.top;
418
+ const isSingleLine = text.textBounds.every((tb) => Math.abs(tb.bounds.top - firstTop) < lineHeight * 0.5);
419
+ if (!isSingleLine)
420
+ return false;
421
+ let fullText = text.textBounds
422
+ .map((tb) => tb.text)
423
+ .join('')
424
+ .replace(/\s+/g, ' ')
425
+ .trim();
426
+ const fullWidth = this.ctx.measureText(fullText).width;
427
+ if (fullWidth <= containerBounds.width)
428
+ return false;
429
+ const truncated = this.truncateTextWithEllipsis(fullText, containerBounds.width, styles.letterSpacing);
430
+ const bounds = new text_1.TextBounds(truncated, text.textBounds[0].bounds);
431
+ for (const layer of paintOrder) {
432
+ if (layer === 0 /* PAINT_ORDER_LAYER.FILL */)
433
+ this.renderTextFillWithShadows(bounds, styles, baseline);
434
+ else if (layer === 1 /* PAINT_ORDER_LAYER.STROKE */)
435
+ this.renderTextStrokeWithStyle(bounds, styles, baseline);
436
+ }
437
+ return true;
438
+ }
439
+ async renderTextNode(text, styles, containerBounds) {
440
+ // Reset glyph width cache at the start of each text node render —
441
+ // the font may change between nodes.
442
+ this.glyphWidthCache = null;
443
+ const [fontString] = this.createFontStyle(styles);
444
+ this.ctx.font = fontString;
445
+ this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
446
+ this.ctx.textAlign = 'left';
447
+ this.ctx.textBaseline = 'alphabetic';
448
+ const paintOrder = styles.paintOrder;
449
+ // Compute baseline using the actual rendered font via Canvas API.
450
+ // This ensures correct positioning whether using webfonts (which may not
451
+ // be loaded in the original document but are active in the Canvas) or
452
+ // system fonts.
453
+ const baseline = (0, font_utils_1.measureBaseline)(this.ctx, styles.fontSize.number);
454
+ // -webkit-line-clamp
455
+ const clamp = styles.webkitLineClamp > 0 &&
456
+ (styles.display & 2 /* DISPLAY.BLOCK */) !== 0 &&
457
+ styles.overflowY === 1 /* OVERFLOW.HIDDEN */ &&
458
+ text.textBounds.length > 0;
459
+ if (clamp) {
460
+ if (this.renderLineClampedText(text, styles, paintOrder, baseline, containerBounds))
461
+ return;
462
+ }
463
+ // text-overflow: ellipsis (single-line only)
464
+ const ellipsis = styles.textOverflow === 1 /* TEXT_OVERFLOW.ELLIPSIS */ &&
465
+ containerBounds &&
466
+ styles.overflowX === 1 /* OVERFLOW.HIDDEN */ &&
467
+ text.textBounds.length > 0;
468
+ if (ellipsis && this.renderEllipsisText(text, styles, paintOrder, baseline, containerBounds))
469
+ return;
470
+ // Normal rendering: fill + stroke + decorations per text bound
471
+ text.textBounds.forEach((tb) => {
472
+ paintOrder.forEach((layer) => {
473
+ if (layer === 0 /* PAINT_ORDER_LAYER.FILL */) {
474
+ this.renderTextFillWithShadows(tb, styles, baseline);
475
+ if (styles.textDecorationLine.length)
476
+ this.renderTextDecoration(tb.bounds, styles);
477
+ }
478
+ else if (layer === 1 /* PAINT_ORDER_LAYER.STROKE */) {
479
+ this.renderTextStrokeWithStyle(tb, styles, baseline);
480
+ }
481
+ });
482
+ });
483
+ }
484
+ }
485
+ exports.TextRenderer = TextRenderer;