@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,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlotCloner = exports.IGNORE_ATTRIBUTE = void 0;
4
+ const node_type_guards_1 = require("./node-type-guards");
5
+ /** Exported for reuse in document-cloner.ts */
6
+ exports.IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';
7
+ /**
8
+ * Handles shadow DOM child cloning, slot assignment, and light DOM traversal.
9
+ * Extracted from DocumentCloner to reduce file size and improve separation of concerns.
10
+ */
11
+ class SlotCloner {
12
+ constructor(cloneNodeFn, options, context) {
13
+ this.cloneNodeFn = cloneNodeFn;
14
+ this.options = options;
15
+ this.context = context;
16
+ }
17
+ appendChildNode(clone, child, copyStyles) {
18
+ this.safeAppendClonedChild(clone, child, copyStyles);
19
+ }
20
+ /**
21
+ * Clone child nodes from source element to clone element.
22
+ * Handles shadow DOM, slots, and light DOM appropriately.
23
+ */
24
+ cloneChildNodes(node, clone, copyStyles) {
25
+ if (node.shadowRoot && clone.shadowRoot) {
26
+ // Both original and clone have shadow roots - clone shadow DOM content
27
+ this.cloneShadowDOMChildren(node.shadowRoot, clone.shadowRoot, copyStyles);
28
+ // Also clone light DOM (slot content sources)
29
+ this.cloneLightDOMChildren(node, clone, copyStyles);
30
+ }
31
+ else if (node.shadowRoot && !clone.shadowRoot) {
32
+ // Original has shadow root but clone doesn't (creation failed)
33
+ // Fallback: clone shadow DOM content as light DOM to preserve content
34
+ this.cloneShadowDOMAsLightDOM(node.shadowRoot, clone, copyStyles);
35
+ }
36
+ else {
37
+ // No shadow DOM - just clone light DOM children
38
+ this.cloneLightDOMChildren(node, clone, copyStyles);
39
+ }
40
+ }
41
+ /**
42
+ * Check if a child node should be cloned based on filtering rules.
43
+ * Filters out: scripts, ignored elements, and optionally styles.
44
+ */
45
+ shouldCloneChild(child) {
46
+ return (!(0, node_type_guards_1.isElementNode)(child) ||
47
+ (!(0, node_type_guards_1.isScriptElement)(child) &&
48
+ !child.hasAttribute(exports.IGNORE_ATTRIBUTE) &&
49
+ (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child))));
50
+ }
51
+ /**
52
+ * Check if a style element should be cloned based on copyStyles option.
53
+ */
54
+ shouldCloneStyleElement(child) {
55
+ return !this.options.copyStyles || !(0, node_type_guards_1.isElementNode)(child) || !(0, node_type_guards_1.isStyleElement)(child);
56
+ }
57
+ /**
58
+ * Safely append a cloned child to a target, applying all filtering rules.
59
+ */
60
+ safeAppendClonedChild(target, child, copyStyles) {
61
+ if (this.shouldCloneChild(child) && this.shouldCloneStyleElement(child)) {
62
+ target.appendChild(this.cloneNodeFn(child, copyStyles));
63
+ }
64
+ }
65
+ /**
66
+ * Clone assigned nodes from a slot element to the target.
67
+ */
68
+ cloneAssignedNodes(assignedNodes, target, copyStyles) {
69
+ assignedNodes.forEach((node) => {
70
+ this.safeAppendClonedChild(target, node, copyStyles);
71
+ });
72
+ }
73
+ /**
74
+ * Clone fallback content from a slot element when no nodes are assigned.
75
+ */
76
+ cloneSlotFallbackContent(slot, target, copyStyles) {
77
+ for (let child = slot.firstChild; child; child = child.nextSibling) {
78
+ this.safeAppendClonedChild(target, child, copyStyles);
79
+ }
80
+ }
81
+ /**
82
+ * Handle cloning of a slot element, including assigned nodes or fallback content.
83
+ */
84
+ cloneSlotElement(slot, targetShadowRoot, copyStyles) {
85
+ if (!(0, node_type_guards_1.isSlotElement)(slot)) {
86
+ return;
87
+ }
88
+ const slotElement = slot;
89
+ // Defensive check: ensure assignedNodes method exists
90
+ if (typeof slotElement.assignedNodes !== 'function') {
91
+ this.context.logger.warn('HTMLSlotElement.assignedNodes is not available', slot);
92
+ this.cloneSlotFallbackContent(slot, targetShadowRoot, copyStyles);
93
+ return;
94
+ }
95
+ const assignedNodes = slotElement.assignedNodes();
96
+ // Defensive check: ensure assignedNodes returns an array
97
+ if (!assignedNodes || !Array.isArray(assignedNodes)) {
98
+ this.context.logger.warn('assignedNodes() did not return a valid array', slot);
99
+ this.cloneSlotFallbackContent(slot, targetShadowRoot, copyStyles);
100
+ return;
101
+ }
102
+ if (assignedNodes.length > 0) {
103
+ // Clone assigned nodes
104
+ this.cloneAssignedNodes(assignedNodes, targetShadowRoot, copyStyles);
105
+ }
106
+ else {
107
+ // Clone fallback content
108
+ this.cloneSlotFallbackContent(slot, targetShadowRoot, copyStyles);
109
+ }
110
+ }
111
+ /**
112
+ * Clone shadow DOM children to the target shadow root.
113
+ */
114
+ cloneShadowDOMChildren(shadowRoot, targetShadowRoot, copyStyles) {
115
+ for (let child = shadowRoot.firstChild; child; child = child.nextSibling) {
116
+ if ((0, node_type_guards_1.isElementNode)(child) && (0, node_type_guards_1.isSlotElement)(child)) {
117
+ // Handle slot elements specially
118
+ this.cloneSlotElement(child, targetShadowRoot, copyStyles);
119
+ }
120
+ else {
121
+ // Clone regular elements
122
+ this.safeAppendClonedChild(targetShadowRoot, child, copyStyles);
123
+ }
124
+ }
125
+ }
126
+ /**
127
+ * Clone light DOM children to the target element.
128
+ */
129
+ cloneLightDOMChildren(node, clone, copyStyles) {
130
+ for (let child = node.firstChild; child; child = child.nextSibling) {
131
+ this.appendChildNode(clone, child, copyStyles);
132
+ }
133
+ }
134
+ /**
135
+ * Clone slot element as light DOM when shadow root creation failed.
136
+ */
137
+ cloneSlotElementAsLightDOM(slot, clone, copyStyles) {
138
+ if (!(0, node_type_guards_1.isSlotElement)(slot)) {
139
+ return;
140
+ }
141
+ const slotElement = slot;
142
+ if (typeof slotElement.assignedNodes !== 'function') {
143
+ // Fallback: clone slot's children
144
+ for (let child = slot.firstChild; child; child = child.nextSibling) {
145
+ this.appendChildNode(clone, child, copyStyles);
146
+ }
147
+ return;
148
+ }
149
+ const assignedNodes = slotElement.assignedNodes();
150
+ if (assignedNodes && Array.isArray(assignedNodes) && assignedNodes.length > 0) {
151
+ // Clone assigned nodes as light DOM
152
+ assignedNodes.forEach((node) => this.appendChildNode(clone, node, copyStyles));
153
+ }
154
+ else {
155
+ // Clone fallback content as light DOM
156
+ for (let child = slot.firstChild; child; child = child.nextSibling) {
157
+ this.appendChildNode(clone, child, copyStyles);
158
+ }
159
+ }
160
+ }
161
+ /**
162
+ * Clone shadow DOM content as light DOM when shadow root creation failed.
163
+ * This is a fallback mechanism to ensure content is not lost.
164
+ */
165
+ cloneShadowDOMAsLightDOM(shadowRoot, clone, copyStyles) {
166
+ for (let child = shadowRoot.firstChild; child; child = child.nextSibling) {
167
+ if ((0, node_type_guards_1.isElementNode)(child) && (0, node_type_guards_1.isSlotElement)(child)) {
168
+ this.cloneSlotElementAsLightDOM(child, clone, copyStyles);
169
+ }
170
+ else {
171
+ this.appendChildNode(clone, child, copyStyles);
172
+ }
173
+ }
174
+ }
175
+ }
176
+ exports.SlotCloner = SlotCloner;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextContainer = void 0;
4
+ const text_1 = require("../css/layout/text");
5
+ class TextContainer {
6
+ constructor(context, node, styles) {
7
+ this.text = transform(node.data, styles.textTransform);
8
+ // Range offsets below are based on transformed text; keep the node in sync
9
+ // when casing changes string length, for example "ß".toUpperCase() === "SS".
10
+ if (this.text.length !== node.data.length) {
11
+ node.data = this.text;
12
+ }
13
+ this.textBounds = (0, text_1.parseTextBounds)(context, this.text, styles, node);
14
+ }
15
+ }
16
+ exports.TextContainer = TextContainer;
17
+ const transform = (text, transform) => {
18
+ switch (transform) {
19
+ case 1 /* TEXT_TRANSFORM.LOWERCASE */:
20
+ return text.toLowerCase();
21
+ case 3 /* TEXT_TRANSFORM.CAPITALIZE */:
22
+ return text.replace(CAPITALIZE, capitalize);
23
+ case 2 /* TEXT_TRANSFORM.UPPERCASE */:
24
+ return text.toUpperCase();
25
+ default:
26
+ return text;
27
+ }
28
+ };
29
+ const CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g;
30
+ const capitalize = (m, p1, p2) => {
31
+ if (m.length > 0) {
32
+ return p1 + p2.toUpperCase();
33
+ }
34
+ return m;
35
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PerformanceMonitor = exports.createDefaultValidator = exports.Validator = exports.Html2CanvasConfig = exports.html2canvas = void 0;
4
+ const config_1 = require("./config");
5
+ Object.defineProperty(exports, "Html2CanvasConfig", { enumerable: true, get: function () { return config_1.Html2CanvasConfig; } });
6
+ const validator_1 = require("./core/validator");
7
+ Object.defineProperty(exports, "createDefaultValidator", { enumerable: true, get: function () { return validator_1.createDefaultValidator; } });
8
+ Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return validator_1.Validator; } });
9
+ const performance_monitor_1 = require("./core/performance-monitor");
10
+ Object.defineProperty(exports, "PerformanceMonitor", { enumerable: true, get: function () { return performance_monitor_1.PerformanceMonitor; } });
11
+ const render_element_1 = require("./core/render-element");
12
+ /**
13
+ * Renders an HTML element to a `<canvas>` element.
14
+ *
15
+ * The function clones the target element and its subtree into a hidden iframe,
16
+ * resolves all computed styles, and paints the result onto a canvas —
17
+ * producing a visual snapshot of the DOM as it appears in the browser.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import html2canvas from 'html2canvas-pro';
22
+ *
23
+ * const canvas = await html2canvas(document.body, {
24
+ * backgroundColor: '#ffffff',
25
+ * scale: 2,
26
+ * useCORS: true
27
+ * });
28
+ * document.body.appendChild(canvas);
29
+ * ```
30
+ *
31
+ * @param element - The root HTMLElement to render.
32
+ * @param options - Rendering options.
33
+ * @param config - Advanced configuration. In most cases this is auto-created;
34
+ * only pass it if you need to share a cache across multiple calls.
35
+ * @returns A promise that resolves to the rendered HTMLCanvasElement.
36
+ *
37
+ * @throws {Error} If the element is not attached to a document.
38
+ * @throws {DOMException} If an {@link Options.signal|AbortSignal} was provided and the operation was aborted.
39
+ */
40
+ const html2canvas = (element, options = {}, config) => {
41
+ const finalConfig = config ||
42
+ config_1.Html2CanvasConfig.fromElement(element, {
43
+ cspNonce: options.cspNonce,
44
+ cache: options.cache
45
+ });
46
+ return (0, render_element_1.renderElement)(element, options, finalConfig);
47
+ };
48
+ exports.html2canvas = html2canvas;
49
+ exports.default = html2canvas;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateBackgroundRepeatPath = exports.getBackgroundValueForIndex = exports.calculateBackgroundSize = exports.isAuto = exports.calculateBackgroundRendering = exports.calculateBackgroundPaintingArea = exports.calculateBackgroundPositioningArea = void 0;
4
+ const background_size_1 = require("../css/property-descriptors/background-size");
5
+ const vector_1 = require("./vector");
6
+ const length_percentage_1 = require("../css/types/length-percentage");
7
+ const parser_1 = require("../css/syntax/parser");
8
+ const box_sizing_1 = require("./box-sizing");
9
+ const calculateBackgroundPositioningArea = (backgroundOrigin, element) => {
10
+ if (backgroundOrigin === 0 /* BACKGROUND_ORIGIN.BORDER_BOX */) {
11
+ return element.bounds;
12
+ }
13
+ if (backgroundOrigin === 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */) {
14
+ return (0, box_sizing_1.contentBox)(element);
15
+ }
16
+ return (0, box_sizing_1.paddingBox)(element);
17
+ };
18
+ exports.calculateBackgroundPositioningArea = calculateBackgroundPositioningArea;
19
+ const calculateBackgroundPaintingArea = (backgroundClip, element) => {
20
+ if (backgroundClip === 0 /* BACKGROUND_CLIP.BORDER_BOX */) {
21
+ return element.bounds;
22
+ }
23
+ if (backgroundClip === 2 /* BACKGROUND_CLIP.CONTENT_BOX */) {
24
+ return (0, box_sizing_1.contentBox)(element);
25
+ }
26
+ return (0, box_sizing_1.paddingBox)(element);
27
+ };
28
+ exports.calculateBackgroundPaintingArea = calculateBackgroundPaintingArea;
29
+ const calculateBackgroundRendering = (container, index, intrinsicSize) => {
30
+ const backgroundPositioningArea = (0, exports.calculateBackgroundPositioningArea)((0, exports.getBackgroundValueForIndex)(container.styles.backgroundOrigin, index), container);
31
+ const backgroundPaintingArea = (0, exports.calculateBackgroundPaintingArea)((0, exports.getBackgroundValueForIndex)(container.styles.backgroundClip, index), container);
32
+ const backgroundImageSize = (0, exports.calculateBackgroundSize)((0, exports.getBackgroundValueForIndex)(container.styles.backgroundSize, index), intrinsicSize, backgroundPositioningArea);
33
+ let [sizeWidth, sizeHeight] = backgroundImageSize;
34
+ const position = (0, length_percentage_1.getAbsoluteValueForTuple)((0, exports.getBackgroundValueForIndex)(container.styles.backgroundPosition, index), backgroundPositioningArea.width - sizeWidth, backgroundPositioningArea.height - sizeHeight);
35
+ const path = (0, exports.calculateBackgroundRepeatPath)((0, exports.getBackgroundValueForIndex)(container.styles.backgroundRepeat, index), position, backgroundImageSize, backgroundPositioningArea, backgroundPaintingArea);
36
+ const offsetX = Math.round(backgroundPositioningArea.left + position[0]);
37
+ const offsetY = Math.round(backgroundPositioningArea.top + position[1]);
38
+ sizeWidth = Math.max(1, sizeWidth);
39
+ sizeHeight = Math.max(1, sizeHeight);
40
+ return [path, offsetX, offsetY, sizeWidth, sizeHeight];
41
+ };
42
+ exports.calculateBackgroundRendering = calculateBackgroundRendering;
43
+ const isAuto = (token) => (0, parser_1.isIdentToken)(token) && token.value === background_size_1.BACKGROUND_SIZE.AUTO;
44
+ exports.isAuto = isAuto;
45
+ const hasIntrinsicValue = (value) => typeof value === 'number';
46
+ const calculateBackgroundSize = (size, [intrinsicWidth, intrinsicHeight, intrinsicProportion], bounds) => {
47
+ const [first, second] = size;
48
+ if (!first) {
49
+ return [0, 0];
50
+ }
51
+ if ((0, length_percentage_1.isLengthPercentage)(first) && second && (0, length_percentage_1.isLengthPercentage)(second)) {
52
+ return [(0, length_percentage_1.getAbsoluteValue)(first, bounds.width), (0, length_percentage_1.getAbsoluteValue)(second, bounds.height)];
53
+ }
54
+ const hasIntrinsicProportion = hasIntrinsicValue(intrinsicProportion);
55
+ if ((0, parser_1.isIdentToken)(first) && (first.value === background_size_1.BACKGROUND_SIZE.CONTAIN || first.value === background_size_1.BACKGROUND_SIZE.COVER)) {
56
+ if (hasIntrinsicValue(intrinsicProportion)) {
57
+ const targetRatio = bounds.width / bounds.height;
58
+ return targetRatio < intrinsicProportion !== (first.value === background_size_1.BACKGROUND_SIZE.COVER)
59
+ ? [bounds.width, bounds.width / intrinsicProportion]
60
+ : [bounds.height * intrinsicProportion, bounds.height];
61
+ }
62
+ return [bounds.width, bounds.height];
63
+ }
64
+ const hasIntrinsicWidth = hasIntrinsicValue(intrinsicWidth);
65
+ const hasIntrinsicHeight = hasIntrinsicValue(intrinsicHeight);
66
+ const hasIntrinsicDimensions = hasIntrinsicWidth || hasIntrinsicHeight;
67
+ // If the background-size is auto or auto auto:
68
+ if ((0, exports.isAuto)(first) && (!second || (0, exports.isAuto)(second))) {
69
+ // If the image has both horizontal and vertical intrinsic dimensions, it's rendered at that size.
70
+ if (hasIntrinsicWidth && hasIntrinsicHeight) {
71
+ return [intrinsicWidth, intrinsicHeight];
72
+ }
73
+ // If the image has no intrinsic dimensions and has no intrinsic proportions,
74
+ // it's rendered at the size of the background positioning area.
75
+ if (!hasIntrinsicProportion && !hasIntrinsicDimensions) {
76
+ return [bounds.width, bounds.height];
77
+ }
78
+ // NOTE (known gap): Per the CSS spec, images with intrinsic proportions
79
+ // but no intrinsic dimensions should be rendered as if 'contain' had been
80
+ // specified. This branch is not yet implemented — the image will render
81
+ // at the size of the background positioning area instead.
82
+ // If the image has only one intrinsic dimension and has intrinsic proportions, it's rendered at the size corresponding to that one dimension.
83
+ // The other dimension is computed using the specified dimension and the intrinsic proportions.
84
+ if (hasIntrinsicDimensions && hasIntrinsicProportion) {
85
+ const width = hasIntrinsicWidth
86
+ ? intrinsicWidth
87
+ : intrinsicHeight * intrinsicProportion;
88
+ const height = hasIntrinsicHeight
89
+ ? intrinsicHeight
90
+ : intrinsicWidth / intrinsicProportion;
91
+ return [width, height];
92
+ }
93
+ // If the image has only one intrinsic dimension but has no intrinsic proportions,
94
+ // it's rendered using the specified dimension and the other dimension of the background positioning area.
95
+ const width = hasIntrinsicWidth ? intrinsicWidth : bounds.width;
96
+ const height = hasIntrinsicHeight ? intrinsicHeight : bounds.height;
97
+ return [width, height];
98
+ }
99
+ // If the image has intrinsic proportions, it's stretched to the specified dimension.
100
+ // The unspecified dimension is computed using the specified dimension and the intrinsic proportions.
101
+ if (hasIntrinsicProportion) {
102
+ let width = 0;
103
+ let height = 0;
104
+ if ((0, length_percentage_1.isLengthPercentage)(first)) {
105
+ width = (0, length_percentage_1.getAbsoluteValue)(first, bounds.width);
106
+ }
107
+ else if ((0, length_percentage_1.isLengthPercentage)(second)) {
108
+ height = (0, length_percentage_1.getAbsoluteValue)(second, bounds.height);
109
+ }
110
+ if ((0, exports.isAuto)(first)) {
111
+ width = height * intrinsicProportion;
112
+ }
113
+ else if (!second || (0, exports.isAuto)(second)) {
114
+ height = width / intrinsicProportion;
115
+ }
116
+ return [width, height];
117
+ }
118
+ // If the image has no intrinsic proportions, it's stretched to the specified dimension.
119
+ // The unspecified dimension is computed using the image's corresponding intrinsic dimension,
120
+ // if there is one. If there is no such intrinsic dimension,
121
+ // it becomes the corresponding dimension of the background positioning area.
122
+ let width = null;
123
+ let height = null;
124
+ if ((0, length_percentage_1.isLengthPercentage)(first)) {
125
+ width = (0, length_percentage_1.getAbsoluteValue)(first, bounds.width);
126
+ }
127
+ else if (second && (0, length_percentage_1.isLengthPercentage)(second)) {
128
+ height = (0, length_percentage_1.getAbsoluteValue)(second, bounds.height);
129
+ }
130
+ if (width !== null && (!second || (0, exports.isAuto)(second))) {
131
+ height =
132
+ hasIntrinsicWidth && hasIntrinsicHeight
133
+ ? (width / intrinsicWidth) * intrinsicHeight
134
+ : bounds.height;
135
+ }
136
+ if (height !== null && (0, exports.isAuto)(first)) {
137
+ width =
138
+ hasIntrinsicWidth && hasIntrinsicHeight
139
+ ? (height / intrinsicHeight) * intrinsicWidth
140
+ : bounds.width;
141
+ }
142
+ if (width !== null && height !== null) {
143
+ return [width, height];
144
+ }
145
+ throw new Error(`Unable to calculate background-size for element`);
146
+ };
147
+ exports.calculateBackgroundSize = calculateBackgroundSize;
148
+ const getBackgroundValueForIndex = (values, index) => {
149
+ const value = values[index];
150
+ if (typeof value === 'undefined') {
151
+ return values[0];
152
+ }
153
+ return value;
154
+ };
155
+ exports.getBackgroundValueForIndex = getBackgroundValueForIndex;
156
+ const calculateBackgroundRepeatPath = (repeat, [x, y], [width, height], backgroundPositioningArea, backgroundPaintingArea) => {
157
+ switch (repeat) {
158
+ case 2 /* BACKGROUND_REPEAT.REPEAT_X */:
159
+ return [
160
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left), Math.round(backgroundPositioningArea.top + y)),
161
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(backgroundPositioningArea.top + y)),
162
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(height + backgroundPositioningArea.top + y)),
163
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left), Math.round(height + backgroundPositioningArea.top + y))
164
+ ];
165
+ case 3 /* BACKGROUND_REPEAT.REPEAT_Y */:
166
+ return [
167
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top)),
168
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top)),
169
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top)),
170
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top))
171
+ ];
172
+ case 1 /* BACKGROUND_REPEAT.NO_REPEAT */:
173
+ return [
174
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y)),
175
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y)),
176
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y + height)),
177
+ new vector_1.Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y + height))
178
+ ];
179
+ default:
180
+ return [
181
+ new vector_1.Vector(Math.round(backgroundPaintingArea.left), Math.round(backgroundPaintingArea.top)),
182
+ new vector_1.Vector(Math.round(backgroundPaintingArea.left + backgroundPaintingArea.width), Math.round(backgroundPaintingArea.top)),
183
+ new vector_1.Vector(Math.round(backgroundPaintingArea.left + backgroundPaintingArea.width), Math.round(backgroundPaintingArea.height + backgroundPaintingArea.top)),
184
+ new vector_1.Vector(Math.round(backgroundPaintingArea.left), Math.round(backgroundPaintingArea.height + backgroundPaintingArea.top))
185
+ ];
186
+ }
187
+ };
188
+ exports.calculateBackgroundRepeatPath = calculateBackgroundRepeatPath;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBezierCurve = exports.BezierCurve = void 0;
4
+ const vector_1 = require("./vector");
5
+ const lerp = (a, b, t) => {
6
+ return new vector_1.Vector(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);
7
+ };
8
+ class BezierCurve {
9
+ constructor(start, startControl, endControl, end) {
10
+ this.type = 1 /* PathType.BEZIER_CURVE */;
11
+ this.start = start;
12
+ this.startControl = startControl;
13
+ this.endControl = endControl;
14
+ this.end = end;
15
+ }
16
+ subdivide(t, firstHalf) {
17
+ const ab = lerp(this.start, this.startControl, t);
18
+ const bc = lerp(this.startControl, this.endControl, t);
19
+ const cd = lerp(this.endControl, this.end, t);
20
+ const abbc = lerp(ab, bc, t);
21
+ const bccd = lerp(bc, cd, t);
22
+ const dest = lerp(abbc, bccd, t);
23
+ return firstHalf ? new BezierCurve(this.start, ab, abbc, dest) : new BezierCurve(dest, bccd, cd, this.end);
24
+ }
25
+ add(deltaX, deltaY) {
26
+ return new BezierCurve(this.start.add(deltaX, deltaY), this.startControl.add(deltaX, deltaY), this.endControl.add(deltaX, deltaY), this.end.add(deltaX, deltaY));
27
+ }
28
+ reverse() {
29
+ return new BezierCurve(this.end, this.endControl, this.startControl, this.start);
30
+ }
31
+ }
32
+ exports.BezierCurve = BezierCurve;
33
+ const isBezierCurve = (path) => path.type === 1 /* PathType.BEZIER_CURVE */;
34
+ exports.isBezierCurve = isBezierCurve;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePathForBorderStroke = exports.parsePathForBorderDoubleInner = exports.parsePathForBorderDoubleOuter = exports.parsePathForBorder = void 0;
4
+ const bezier_curve_1 = require("./bezier-curve");
5
+ const parsePathForBorder = (curves, borderSide) => {
6
+ switch (borderSide) {
7
+ case 0:
8
+ return createPathFromCurves(curves.topLeftBorderBox, curves.topLeftPaddingBox, curves.topRightBorderBox, curves.topRightPaddingBox);
9
+ case 1:
10
+ return createPathFromCurves(curves.topRightBorderBox, curves.topRightPaddingBox, curves.bottomRightBorderBox, curves.bottomRightPaddingBox);
11
+ case 2:
12
+ return createPathFromCurves(curves.bottomRightBorderBox, curves.bottomRightPaddingBox, curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox);
13
+ case 3:
14
+ default:
15
+ return createPathFromCurves(curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox, curves.topLeftBorderBox, curves.topLeftPaddingBox);
16
+ }
17
+ };
18
+ exports.parsePathForBorder = parsePathForBorder;
19
+ const parsePathForBorderDoubleOuter = (curves, borderSide) => {
20
+ switch (borderSide) {
21
+ case 0:
22
+ return createPathFromCurves(curves.topLeftBorderBox, curves.topLeftBorderDoubleOuterBox, curves.topRightBorderBox, curves.topRightBorderDoubleOuterBox);
23
+ case 1:
24
+ return createPathFromCurves(curves.topRightBorderBox, curves.topRightBorderDoubleOuterBox, curves.bottomRightBorderBox, curves.bottomRightBorderDoubleOuterBox);
25
+ case 2:
26
+ return createPathFromCurves(curves.bottomRightBorderBox, curves.bottomRightBorderDoubleOuterBox, curves.bottomLeftBorderBox, curves.bottomLeftBorderDoubleOuterBox);
27
+ case 3:
28
+ default:
29
+ return createPathFromCurves(curves.bottomLeftBorderBox, curves.bottomLeftBorderDoubleOuterBox, curves.topLeftBorderBox, curves.topLeftBorderDoubleOuterBox);
30
+ }
31
+ };
32
+ exports.parsePathForBorderDoubleOuter = parsePathForBorderDoubleOuter;
33
+ const parsePathForBorderDoubleInner = (curves, borderSide) => {
34
+ switch (borderSide) {
35
+ case 0:
36
+ return createPathFromCurves(curves.topLeftBorderDoubleInnerBox, curves.topLeftPaddingBox, curves.topRightBorderDoubleInnerBox, curves.topRightPaddingBox);
37
+ case 1:
38
+ return createPathFromCurves(curves.topRightBorderDoubleInnerBox, curves.topRightPaddingBox, curves.bottomRightBorderDoubleInnerBox, curves.bottomRightPaddingBox);
39
+ case 2:
40
+ return createPathFromCurves(curves.bottomRightBorderDoubleInnerBox, curves.bottomRightPaddingBox, curves.bottomLeftBorderDoubleInnerBox, curves.bottomLeftPaddingBox);
41
+ case 3:
42
+ default:
43
+ return createPathFromCurves(curves.bottomLeftBorderDoubleInnerBox, curves.bottomLeftPaddingBox, curves.topLeftBorderDoubleInnerBox, curves.topLeftPaddingBox);
44
+ }
45
+ };
46
+ exports.parsePathForBorderDoubleInner = parsePathForBorderDoubleInner;
47
+ const parsePathForBorderStroke = (curves, borderSide) => {
48
+ switch (borderSide) {
49
+ case 0:
50
+ return createStrokePathFromCurves(curves.topLeftBorderStroke, curves.topRightBorderStroke);
51
+ case 1:
52
+ return createStrokePathFromCurves(curves.topRightBorderStroke, curves.bottomRightBorderStroke);
53
+ case 2:
54
+ return createStrokePathFromCurves(curves.bottomRightBorderStroke, curves.bottomLeftBorderStroke);
55
+ case 3:
56
+ default:
57
+ return createStrokePathFromCurves(curves.bottomLeftBorderStroke, curves.topLeftBorderStroke);
58
+ }
59
+ };
60
+ exports.parsePathForBorderStroke = parsePathForBorderStroke;
61
+ const createStrokePathFromCurves = (outer1, outer2) => {
62
+ const path = [];
63
+ if ((0, bezier_curve_1.isBezierCurve)(outer1)) {
64
+ path.push(outer1.subdivide(0.5, false));
65
+ }
66
+ else {
67
+ path.push(outer1);
68
+ }
69
+ if ((0, bezier_curve_1.isBezierCurve)(outer2)) {
70
+ path.push(outer2.subdivide(0.5, true));
71
+ }
72
+ else {
73
+ path.push(outer2);
74
+ }
75
+ return path;
76
+ };
77
+ const createPathFromCurves = (outer1, inner1, outer2, inner2) => {
78
+ const path = [];
79
+ if ((0, bezier_curve_1.isBezierCurve)(outer1)) {
80
+ path.push(outer1.subdivide(0.5, false));
81
+ }
82
+ else {
83
+ path.push(outer1);
84
+ }
85
+ if ((0, bezier_curve_1.isBezierCurve)(outer2)) {
86
+ path.push(outer2.subdivide(0.5, true));
87
+ }
88
+ else {
89
+ path.push(outer2);
90
+ }
91
+ if ((0, bezier_curve_1.isBezierCurve)(inner2)) {
92
+ path.push(inner2.subdivide(0.5, true).reverse());
93
+ }
94
+ else {
95
+ path.push(inner2);
96
+ }
97
+ if ((0, bezier_curve_1.isBezierCurve)(inner1)) {
98
+ path.push(inner1.subdivide(0.5, false).reverse());
99
+ }
100
+ else {
101
+ path.push(inner1);
102
+ }
103
+ return path;
104
+ };