html2canvas-pro 2.4.5 → 2.5.1

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 (231) hide show
  1. package/README.md +117 -13
  2. package/dist/html2canvas-pro.cjs +3425 -1677
  3. package/dist/html2canvas-pro.cjs.map +1 -1
  4. package/dist/html2canvas-pro.esm.js +3425 -1677
  5. package/dist/html2canvas-pro.esm.js.map +1 -1
  6. package/dist/html2canvas-pro.js +3479 -1731
  7. package/dist/html2canvas-pro.js.map +1 -1
  8. package/dist/html2canvas-pro.min.js +5 -5
  9. package/dist/types/core/cache-storage.d.ts +22 -1
  10. package/dist/types/core/context.d.ts +10 -1
  11. package/dist/types/core/logger.d.ts +0 -3
  12. package/dist/types/core/render-element.d.ts +11 -0
  13. package/dist/types/core/util.d.ts +6 -0
  14. package/dist/types/css/index.d.ts +77 -46
  15. package/dist/types/css/parse.d.ts +15 -0
  16. package/dist/types/css/property-descriptors/accent-color.d.ts +5 -0
  17. package/dist/types/css/property-descriptors/backdrop-filter.d.ts +9 -0
  18. package/dist/types/css/property-descriptors/background-blend-mode.d.ts +16 -16
  19. package/dist/types/css/property-descriptors/border-image-width.d.ts +36 -0
  20. package/dist/types/css/property-descriptors/clip-path.d.ts +16 -2
  21. package/dist/types/css/property-descriptors/isolation.d.ts +6 -0
  22. package/dist/types/css/property-descriptors/mask.d.ts +25 -0
  23. package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +16 -16
  24. package/dist/types/css/property-descriptors/outline.d.ts +15 -0
  25. package/dist/types/css/property-descriptors/text-emphasis.d.ts +22 -0
  26. package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
  27. package/dist/types/css/property-descriptors/webkit-box-reflect.d.ts +19 -0
  28. package/dist/types/css/property-descriptors/webkit-text-fill-color.d.ts +9 -0
  29. package/dist/types/css/syntax/token-constants.d.ts +1 -1
  30. package/dist/types/css/types/color-math.d.ts +7 -1
  31. package/dist/types/css/types/color-spaces/a98.d.ts +2 -1
  32. package/dist/types/css/types/color-spaces/p3.d.ts +5 -4
  33. package/dist/types/css/types/color-spaces/pro-photo.d.ts +5 -4
  34. package/dist/types/css/types/color-spaces/rec2020.d.ts +5 -4
  35. package/dist/types/css/types/color-spaces/srgb.d.ts +5 -4
  36. package/dist/types/css/types/color-utilities.d.ts +11 -11
  37. package/dist/types/css/types/color.d.ts +1 -0
  38. package/dist/types/css/types/functions/conic-gradient.d.ts +17 -0
  39. package/dist/types/css/types/functions/image-set.d.ts +11 -0
  40. package/dist/types/css/types/functions/repeating-radial-gradient.d.ts +8 -0
  41. package/dist/types/css/types/image.d.ts +17 -2
  42. package/dist/types/css/types/safe-eval.d.ts +0 -6
  43. package/dist/types/dom/copy-css-styles.d.ts +8 -0
  44. package/dist/types/dom/document-cloner.d.ts +3 -13
  45. package/dist/types/dom/iframe-mount.d.ts +37 -0
  46. package/dist/types/dom/pseudo-content.d.ts +33 -0
  47. package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +2 -2
  48. package/dist/types/dom/replaced-elements/input-element-container.d.ts +1 -1
  49. package/dist/types/options.d.ts +8 -2
  50. package/dist/types/render/canvas/background-renderer.d.ts +28 -0
  51. package/dist/types/render/canvas/border-image-renderer.d.ts +50 -1
  52. package/dist/types/render/canvas/canvas-renderer.d.ts +29 -15
  53. package/dist/types/render/canvas/effects-renderer.d.ts +8 -0
  54. package/dist/types/render/canvas/mask-renderer.d.ts +36 -0
  55. package/dist/types/render/canvas/text-clip-renderer.d.ts +56 -0
  56. package/dist/types/render/canvas/text-renderer.d.ts +22 -0
  57. package/dist/types/render/stacking-context.d.ts +4 -1
  58. package/package.json +41 -42
  59. package/dist/lib/config.js +0 -49
  60. package/dist/lib/core/abort-helper.js +0 -20
  61. package/dist/lib/core/background-parser.js +0 -41
  62. package/dist/lib/core/bitwise.js +0 -5
  63. package/dist/lib/core/cache-storage.js +0 -283
  64. package/dist/lib/core/config-assembler.js +0 -88
  65. package/dist/lib/core/constants.js +0 -25
  66. package/dist/lib/core/context.js +0 -19
  67. package/dist/lib/core/debugger.js +0 -27
  68. package/dist/lib/core/features.js +0 -190
  69. package/dist/lib/core/logger.js +0 -56
  70. package/dist/lib/core/lru-map.js +0 -66
  71. package/dist/lib/core/origin-checker.js +0 -53
  72. package/dist/lib/core/performance-monitor.js +0 -185
  73. package/dist/lib/core/render-element.js +0 -131
  74. package/dist/lib/core/util.js +0 -4
  75. package/dist/lib/core/validator.js +0 -500
  76. package/dist/lib/css/grouped/background-styles.js +0 -36
  77. package/dist/lib/css/grouped/border-styles.js +0 -75
  78. package/dist/lib/css/grouped/font-styles.js +0 -93
  79. package/dist/lib/css/grouped/layout-styles.js +0 -127
  80. package/dist/lib/css/index.js +0 -339
  81. package/dist/lib/css/layout/bounds.js +0 -52
  82. package/dist/lib/css/layout/text.js +0 -133
  83. package/dist/lib/css/property-descriptor.js +0 -2
  84. package/dist/lib/css/property-descriptors/background-blend-mode.js +0 -41
  85. package/dist/lib/css/property-descriptors/background-clip.js +0 -25
  86. package/dist/lib/css/property-descriptors/background-color.js +0 -10
  87. package/dist/lib/css/property-descriptors/background-image.js +0 -24
  88. package/dist/lib/css/property-descriptors/background-origin.js +0 -23
  89. package/dist/lib/css/property-descriptors/background-position.js +0 -19
  90. package/dist/lib/css/property-descriptors/background-repeat.js +0 -33
  91. package/dist/lib/css/property-descriptors/background-size.js +0 -23
  92. package/dist/lib/css/property-descriptors/border-color.js +0 -14
  93. package/dist/lib/css/property-descriptors/border-image-repeat.js +0 -42
  94. package/dist/lib/css/property-descriptors/border-image-slice.js +0 -45
  95. package/dist/lib/css/property-descriptors/border-image-source.js +0 -22
  96. package/dist/lib/css/property-descriptors/border-radius.js +0 -15
  97. package/dist/lib/css/property-descriptors/border-style.js +0 -26
  98. package/dist/lib/css/property-descriptors/border-width.js +0 -20
  99. package/dist/lib/css/property-descriptors/box-decoration-break.js +0 -18
  100. package/dist/lib/css/property-descriptors/box-shadow.js +0 -54
  101. package/dist/lib/css/property-descriptors/clip-path.js +0 -189
  102. package/dist/lib/css/property-descriptors/color.js +0 -10
  103. package/dist/lib/css/property-descriptors/content.js +0 -19
  104. package/dist/lib/css/property-descriptors/counter-increment.js +0 -35
  105. package/dist/lib/css/property-descriptors/counter-reset.js +0 -18
  106. package/dist/lib/css/property-descriptors/direction.js +0 -18
  107. package/dist/lib/css/property-descriptors/display.js +0 -81
  108. package/dist/lib/css/property-descriptors/duration.js +0 -14
  109. package/dist/lib/css/property-descriptors/filter.js +0 -86
  110. package/dist/lib/css/property-descriptors/float.js +0 -22
  111. package/dist/lib/css/property-descriptors/font-family.js +0 -47
  112. package/dist/lib/css/property-descriptors/font-size.js +0 -10
  113. package/dist/lib/css/property-descriptors/font-style.js +0 -20
  114. package/dist/lib/css/property-descriptors/font-variant-ligatures.js +0 -34
  115. package/dist/lib/css/property-descriptors/font-variant.js +0 -13
  116. package/dist/lib/css/property-descriptors/font-weight.js +0 -25
  117. package/dist/lib/css/property-descriptors/image-rendering.js +0 -33
  118. package/dist/lib/css/property-descriptors/letter-spacing.js +0 -21
  119. package/dist/lib/css/property-descriptors/line-break.js +0 -23
  120. package/dist/lib/css/property-descriptors/line-height.js +0 -24
  121. package/dist/lib/css/property-descriptors/list-style-image.js +0 -17
  122. package/dist/lib/css/property-descriptors/list-style-position.js +0 -18
  123. package/dist/lib/css/property-descriptors/list-style-type.js +0 -122
  124. package/dist/lib/css/property-descriptors/margin.js +0 -13
  125. package/dist/lib/css/property-descriptors/mix-blend-mode.js +0 -31
  126. package/dist/lib/css/property-descriptors/object-fit.js +0 -28
  127. package/dist/lib/css/property-descriptors/object-position.js +0 -42
  128. package/dist/lib/css/property-descriptors/opacity.js +0 -16
  129. package/dist/lib/css/property-descriptors/overflow-wrap.js +0 -18
  130. package/dist/lib/css/property-descriptors/overflow.js +0 -27
  131. package/dist/lib/css/property-descriptors/padding.js +0 -14
  132. package/dist/lib/css/property-descriptors/paint-order.js +0 -33
  133. package/dist/lib/css/property-descriptors/position.js +0 -22
  134. package/dist/lib/css/property-descriptors/quotes.js +0 -41
  135. package/dist/lib/css/property-descriptors/rotate.js +0 -27
  136. package/dist/lib/css/property-descriptors/text-align.js +0 -21
  137. package/dist/lib/css/property-descriptors/text-decoration-color.js +0 -10
  138. package/dist/lib/css/property-descriptors/text-decoration-line.js +0 -28
  139. package/dist/lib/css/property-descriptors/text-decoration-style.js +0 -24
  140. package/dist/lib/css/property-descriptors/text-decoration-thickness.js +0 -26
  141. package/dist/lib/css/property-descriptors/text-overflow.js +0 -18
  142. package/dist/lib/css/property-descriptors/text-shadow.js +0 -46
  143. package/dist/lib/css/property-descriptors/text-transform.js +0 -20
  144. package/dist/lib/css/property-descriptors/text-underline-offset.js +0 -23
  145. package/dist/lib/css/property-descriptors/transform-origin.js +0 -24
  146. package/dist/lib/css/property-descriptors/transform.js +0 -57
  147. package/dist/lib/css/property-descriptors/visibility.js +0 -20
  148. package/dist/lib/css/property-descriptors/webkit-line-clamp.js +0 -26
  149. package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +0 -10
  150. package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +0 -16
  151. package/dist/lib/css/property-descriptors/white-space.js +0 -32
  152. package/dist/lib/css/property-descriptors/word-break.js +0 -26
  153. package/dist/lib/css/property-descriptors/writing-mode.js +0 -28
  154. package/dist/lib/css/property-descriptors/z-index.js +0 -19
  155. package/dist/lib/css/property-descriptors/zoom.js +0 -18
  156. package/dist/lib/css/syntax/parser.js +0 -141
  157. package/dist/lib/css/syntax/token-constants.js +0 -214
  158. package/dist/lib/css/syntax/token-singletons.js +0 -36
  159. package/dist/lib/css/syntax/token-types.js +0 -10
  160. package/dist/lib/css/syntax/tokenizer.js +0 -502
  161. package/dist/lib/css/type-descriptor.js +0 -2
  162. package/dist/lib/css/types/angle.js +0 -80
  163. package/dist/lib/css/types/color-math.js +0 -25
  164. package/dist/lib/css/types/color-spaces/a98.js +0 -78
  165. package/dist/lib/css/types/color-spaces/p3.js +0 -86
  166. package/dist/lib/css/types/color-spaces/pro-photo.js +0 -83
  167. package/dist/lib/css/types/color-spaces/rec2020.js +0 -85
  168. package/dist/lib/css/types/color-spaces/srgb.js +0 -79
  169. package/dist/lib/css/types/color-utilities.js +0 -342
  170. package/dist/lib/css/types/color.js +0 -400
  171. package/dist/lib/css/types/functions/-prefix-linear-gradient.js +0 -32
  172. package/dist/lib/css/types/functions/-prefix-radial-gradient.js +0 -83
  173. package/dist/lib/css/types/functions/-webkit-gradient.js +0 -59
  174. package/dist/lib/css/types/functions/counter.js +0 -367
  175. package/dist/lib/css/types/functions/gradient.js +0 -163
  176. package/dist/lib/css/types/functions/linear-gradient.js +0 -27
  177. package/dist/lib/css/types/functions/radial-gradient.js +0 -90
  178. package/dist/lib/css/types/functions/repeating-linear-gradient.js +0 -9
  179. package/dist/lib/css/types/image.js +0 -62
  180. package/dist/lib/css/types/index.js +0 -2
  181. package/dist/lib/css/types/length-percentage.js +0 -197
  182. package/dist/lib/css/types/length.js +0 -5
  183. package/dist/lib/css/types/safe-eval.js +0 -80
  184. package/dist/lib/css/types/time.js +0 -17
  185. package/dist/lib/dom/document-cloner.js +0 -618
  186. package/dist/lib/dom/dom-normalizer.js +0 -115
  187. package/dist/lib/dom/element-container.js +0 -71
  188. package/dist/lib/dom/elements/li-element-container.js +0 -11
  189. package/dist/lib/dom/elements/ol-element-container.js +0 -12
  190. package/dist/lib/dom/elements/select-element-container.js +0 -12
  191. package/dist/lib/dom/elements/textarea-element-container.js +0 -11
  192. package/dist/lib/dom/node-parser.js +0 -125
  193. package/dist/lib/dom/node-type-guards.js +0 -81
  194. package/dist/lib/dom/replaced-elements/canvas-element-container.js +0 -13
  195. package/dist/lib/dom/replaced-elements/iframe-element-container.js +0 -38
  196. package/dist/lib/dom/replaced-elements/image-element-container.js +0 -14
  197. package/dist/lib/dom/replaced-elements/index.js +0 -2
  198. package/dist/lib/dom/replaced-elements/input-element-container.js +0 -89
  199. package/dist/lib/dom/replaced-elements/svg-element-container.js +0 -57
  200. package/dist/lib/dom/slot-cloner.js +0 -176
  201. package/dist/lib/dom/text-container.js +0 -35
  202. package/dist/lib/index.js +0 -49
  203. package/dist/lib/options.js +0 -2
  204. package/dist/lib/render/background.js +0 -188
  205. package/dist/lib/render/bezier-curve.js +0 -34
  206. package/dist/lib/render/border.js +0 -104
  207. package/dist/lib/render/bound-curves.js +0 -188
  208. package/dist/lib/render/box-sizing.js +0 -20
  209. package/dist/lib/render/canvas/background-renderer.js +0 -338
  210. package/dist/lib/render/canvas/border-image-renderer.js +0 -153
  211. package/dist/lib/render/canvas/border-renderer.js +0 -184
  212. package/dist/lib/render/canvas/box-shadow-geometry.js +0 -52
  213. package/dist/lib/render/canvas/box-shadow-painter.js +0 -194
  214. package/dist/lib/render/canvas/box-shadow-transform.js +0 -42
  215. package/dist/lib/render/canvas/canvas-path.js +0 -25
  216. package/dist/lib/render/canvas/canvas-renderer.js +0 -610
  217. package/dist/lib/render/canvas/content-renderer.js +0 -270
  218. package/dist/lib/render/canvas/effects-renderer.js +0 -171
  219. package/dist/lib/render/canvas/filter-surface.js +0 -270
  220. package/dist/lib/render/canvas/font-utils.js +0 -46
  221. package/dist/lib/render/canvas/foreignobject-renderer.js +0 -38
  222. package/dist/lib/render/canvas/surface-bounds.js +0 -64
  223. package/dist/lib/render/canvas/text/text-decoration-renderer.js +0 -99
  224. package/dist/lib/render/canvas/text-renderer.js +0 -486
  225. package/dist/lib/render/effects.js +0 -231
  226. package/dist/lib/render/font-metrics.js +0 -53
  227. package/dist/lib/render/object-fit.js +0 -91
  228. package/dist/lib/render/path.js +0 -26
  229. package/dist/lib/render/renderer-interface.js +0 -2
  230. package/dist/lib/render/stacking-context.js +0 -341
  231. package/dist/lib/render/vector.js +0 -16
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.color = void 0;
4
- exports.color = {
5
- name: `color`,
6
- initialValue: 'transparent',
7
- prefix: false,
8
- type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
9
- format: 'color'
10
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.content = void 0;
4
- exports.content = {
5
- name: 'content',
6
- initialValue: 'none',
7
- type: 1 /* PropertyDescriptorParsingType.LIST */,
8
- prefix: false,
9
- parse: (_context, tokens) => {
10
- if (tokens.length === 0) {
11
- return [];
12
- }
13
- const first = tokens[0];
14
- if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
15
- return [];
16
- }
17
- return tokens;
18
- }
19
- };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.counterIncrement = exports.parseCounterValue = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- /** Shared counter-ID parsing: returns next number or a fallback default. */
6
- const parseCounterValue = (tokens, defaultNumber) => {
7
- const entries = [];
8
- const filtered = tokens.filter(parser_1.nonWhiteSpace);
9
- for (let i = 0; i < filtered.length; i++) {
10
- const counter = filtered[i];
11
- const next = filtered[i + 1];
12
- if (counter.type === 20 /* TokenType.IDENT_TOKEN */) {
13
- const num = next && (0, parser_1.isNumberToken)(next) ? next.number : defaultNumber;
14
- entries.push([counter.value, num]);
15
- }
16
- }
17
- return entries;
18
- };
19
- exports.parseCounterValue = parseCounterValue;
20
- exports.counterIncrement = {
21
- name: 'counter-increment',
22
- initialValue: 'none',
23
- prefix: true,
24
- type: 1 /* PropertyDescriptorParsingType.LIST */,
25
- parse: (_context, tokens) => {
26
- if (tokens.length === 0) {
27
- return null;
28
- }
29
- const first = tokens[0];
30
- if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
31
- return null;
32
- }
33
- return (0, exports.parseCounterValue)(tokens, 1).map(([counter, increment]) => ({ counter, increment }));
34
- }
35
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.counterReset = void 0;
4
- const counter_increment_1 = require("./counter-increment");
5
- exports.counterReset = {
6
- name: 'counter-reset',
7
- initialValue: 'none',
8
- prefix: true,
9
- type: 1 /* PropertyDescriptorParsingType.LIST */,
10
- parse: (_context, tokens) => {
11
- if (tokens.length === 0) {
12
- return [];
13
- }
14
- return (0, counter_increment_1.parseCounterValue)(tokens, 0)
15
- .filter(([counter]) => counter !== 'none')
16
- .map(([counter, reset]) => ({ counter, reset }));
17
- }
18
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.direction = void 0;
4
- exports.direction = {
5
- name: 'direction',
6
- initialValue: 'ltr',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, direction) => {
10
- switch (direction) {
11
- case 'rtl':
12
- return 1 /* DIRECTION.RTL */;
13
- case 'ltr':
14
- default:
15
- return 0 /* DIRECTION.LTR */;
16
- }
17
- }
18
- };
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.display = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.display = {
6
- name: 'display',
7
- initialValue: 'inline-block',
8
- prefix: false,
9
- type: 1 /* PropertyDescriptorParsingType.LIST */,
10
- parse: (_context, tokens) => {
11
- return tokens.filter(parser_1.isIdentToken).reduce((bit, token) => {
12
- return bit | parseDisplayValue(token.value);
13
- }, 0 /* DISPLAY.NONE */);
14
- }
15
- };
16
- const parseDisplayValue = (display) => {
17
- switch (display) {
18
- case 'block':
19
- case '-webkit-box':
20
- return 2 /* DISPLAY.BLOCK */;
21
- case 'inline':
22
- return 4 /* DISPLAY.INLINE */;
23
- case 'run-in':
24
- return 8 /* DISPLAY.RUN_IN */;
25
- case 'flow':
26
- return 16 /* DISPLAY.FLOW */;
27
- case 'flow-root':
28
- return 32 /* DISPLAY.FLOW_ROOT */;
29
- case 'table':
30
- return 64 /* DISPLAY.TABLE */;
31
- case 'flex':
32
- case '-webkit-flex':
33
- return 128 /* DISPLAY.FLEX */;
34
- case 'grid':
35
- case '-ms-grid':
36
- return 256 /* DISPLAY.GRID */;
37
- case 'ruby':
38
- return 512 /* DISPLAY.RUBY */;
39
- case 'subgrid':
40
- return 1024 /* DISPLAY.SUBGRID */;
41
- case 'list-item':
42
- return 2048 /* DISPLAY.LIST_ITEM */;
43
- case 'table-row-group':
44
- return 4096 /* DISPLAY.TABLE_ROW_GROUP */;
45
- case 'table-header-group':
46
- return 8192 /* DISPLAY.TABLE_HEADER_GROUP */;
47
- case 'table-footer-group':
48
- return 16384 /* DISPLAY.TABLE_FOOTER_GROUP */;
49
- case 'table-row':
50
- return 32768 /* DISPLAY.TABLE_ROW */;
51
- case 'table-cell':
52
- return 65536 /* DISPLAY.TABLE_CELL */;
53
- case 'table-column-group':
54
- return 131072 /* DISPLAY.TABLE_COLUMN_GROUP */;
55
- case 'table-column':
56
- return 262144 /* DISPLAY.TABLE_COLUMN */;
57
- case 'table-caption':
58
- return 524288 /* DISPLAY.TABLE_CAPTION */;
59
- case 'ruby-base':
60
- return 1048576 /* DISPLAY.RUBY_BASE */;
61
- case 'ruby-text':
62
- return 2097152 /* DISPLAY.RUBY_TEXT */;
63
- case 'ruby-base-container':
64
- return 4194304 /* DISPLAY.RUBY_BASE_CONTAINER */;
65
- case 'ruby-text-container':
66
- return 8388608 /* DISPLAY.RUBY_TEXT_CONTAINER */;
67
- case 'contents':
68
- return 16777216 /* DISPLAY.CONTENTS */;
69
- case 'inline-block':
70
- return 33554432 /* DISPLAY.INLINE_BLOCK */;
71
- case 'inline-list-item':
72
- return 67108864 /* DISPLAY.INLINE_LIST_ITEM */;
73
- case 'inline-table':
74
- return 134217728 /* DISPLAY.INLINE_TABLE */;
75
- case 'inline-flex':
76
- return 268435456 /* DISPLAY.INLINE_FLEX */;
77
- case 'inline-grid':
78
- return 536870912 /* DISPLAY.INLINE_GRID */;
79
- }
80
- return 0 /* DISPLAY.NONE */;
81
- };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.duration = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- const time_1 = require("../types/time");
6
- exports.duration = {
7
- name: 'duration',
8
- initialValue: '0s',
9
- prefix: false,
10
- type: 1 /* PropertyDescriptorParsingType.LIST */,
11
- parse: (context, tokens) => {
12
- return tokens.filter(parser_1.isDimensionToken).map((token) => time_1.time.parse(context, token));
13
- }
14
- };
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filter = void 0;
4
- exports.filter = {
5
- name: 'filter',
6
- initialValue: 'none',
7
- prefix: false,
8
- type: 1 /* PropertyDescriptorParsingType.LIST */,
9
- parse: (_context, tokens) => {
10
- if (tokens.length === 1 && tokens[0].type === 20 /* TokenType.IDENT_TOKEN */ && tokens[0].value === 'none') {
11
- return null;
12
- }
13
- const parts = [];
14
- for (const token of tokens) {
15
- if (token.type === 18 /* TokenType.FUNCTION */) {
16
- const fn = token;
17
- // Reconstruct the function string from its name + values
18
- const renderedArgs = renderFilterArgs(fn.values);
19
- // Canvas API supports the same CSS filter string format
20
- switch (fn.name) {
21
- case 'blur':
22
- parts.push(`blur(${renderedArgs})`);
23
- break;
24
- case 'brightness':
25
- case 'contrast':
26
- case 'invert':
27
- case 'opacity':
28
- case 'saturate':
29
- case 'sepia':
30
- parts.push(`${fn.name}(${renderedArgs})`);
31
- break;
32
- case 'grayscale':
33
- parts.push(`grayscale(${renderedArgs})`);
34
- break;
35
- case 'hue-rotate':
36
- parts.push(`hue-rotate(${renderedArgs})`);
37
- break;
38
- case 'drop-shadow':
39
- parts.push(`drop-shadow(${renderedArgs})`);
40
- break;
41
- default:
42
- break;
43
- }
44
- }
45
- }
46
- return parts.length > 0 ? parts.join(' ') : null;
47
- }
48
- };
49
- /**
50
- * Render filter function arguments back into a CSS string suitable for Canvas API.
51
- * Canvas 2D `ctx.filter` accepts the same CSS filter function strings.
52
- */
53
- const renderFilterArgs = (values) => {
54
- const parts = [];
55
- for (const v of values) {
56
- if (v.type === 31 /* TokenType.WHITESPACE_TOKEN */) {
57
- parts.push(' ');
58
- continue;
59
- }
60
- if (v.type === 18 /* TokenType.FUNCTION */) {
61
- parts.push(`${v.name}(${renderFilterArgs(v.values)})`);
62
- }
63
- else if (v.type === 4 /* TokenType.COMMA_TOKEN */) {
64
- parts.push(',');
65
- }
66
- else if (v.type === 6 /* TokenType.DELIM_TOKEN */) {
67
- parts.push(v.value);
68
- }
69
- else if (v.type === 15 /* TokenType.DIMENSION_TOKEN */) {
70
- parts.push(`${v.number}${v.unit}`);
71
- }
72
- else if (v.type === 17 /* TokenType.NUMBER_TOKEN */) {
73
- parts.push(`${v.number}`);
74
- }
75
- else if (v.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
76
- parts.push(`${v.number}%`);
77
- }
78
- else if (v.type === 20 /* TokenType.IDENT_TOKEN */) {
79
- parts.push(v.value);
80
- }
81
- else if (v.type === 5 /* TokenType.HASH_TOKEN */) {
82
- parts.push(`#${v.value}`);
83
- }
84
- }
85
- return parts.join('').trim();
86
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.float = void 0;
4
- exports.float = {
5
- name: 'float',
6
- initialValue: 'none',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, float) => {
10
- switch (float) {
11
- case 'left':
12
- return 1 /* FLOAT.LEFT */;
13
- case 'right':
14
- return 2 /* FLOAT.RIGHT */;
15
- case 'inline-start':
16
- return 3 /* FLOAT.INLINE_START */;
17
- case 'inline-end':
18
- return 4 /* FLOAT.INLINE_END */;
19
- }
20
- return 0 /* FLOAT.NONE */;
21
- }
22
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontFamily = void 0;
4
- exports.fontFamily = {
5
- name: `font-family`,
6
- initialValue: '',
7
- prefix: false,
8
- type: 1 /* PropertyDescriptorParsingType.LIST */,
9
- parse: (_context, tokens) => {
10
- const accumulator = [];
11
- const results = [];
12
- const quoted = [];
13
- let isQuoted = false;
14
- tokens.forEach((token) => {
15
- switch (token.type) {
16
- case 20 /* TokenType.IDENT_TOKEN */:
17
- accumulator.push(token.value);
18
- break;
19
- case 0 /* TokenType.STRING_TOKEN */:
20
- isQuoted = true;
21
- accumulator.push(token.value);
22
- break;
23
- case 17 /* TokenType.NUMBER_TOKEN */:
24
- accumulator.push(token.number.toString());
25
- break;
26
- case 4 /* TokenType.COMMA_TOKEN */:
27
- results.push(accumulator.join(' '));
28
- quoted.push(isQuoted);
29
- isQuoted = false;
30
- accumulator.length = 0;
31
- break;
32
- }
33
- });
34
- if (accumulator.length) {
35
- results.push(accumulator.join(' '));
36
- quoted.push(isQuoted);
37
- }
38
- return results.map((result, index) => quoted[index] || result.indexOf(' ') !== -1
39
- ? `'${result
40
- .replace(/\\/g, '\\\\')
41
- .replace(/'/g, "\\'")
42
- .replace(/\n/g, '\\a ')
43
- .replace(/\r/g, '\\d ')
44
- .replace(/\f/g, '\\c ')}'`
45
- : result);
46
- }
47
- };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontSize = void 0;
4
- exports.fontSize = {
5
- name: `font-size`,
6
- initialValue: '0',
7
- prefix: false,
8
- type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
9
- format: 'length'
10
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontStyle = void 0;
4
- exports.fontStyle = {
5
- name: 'font-style',
6
- initialValue: 'normal',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, overflow) => {
10
- switch (overflow) {
11
- case 'oblique':
12
- return "oblique" /* FONT_STYLE.OBLIQUE */;
13
- case 'italic':
14
- return "italic" /* FONT_STYLE.ITALIC */;
15
- case 'normal':
16
- default:
17
- return "normal" /* FONT_STYLE.NORMAL */;
18
- }
19
- }
20
- };
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontVariantLigatures = void 0;
4
- exports.fontVariantLigatures = {
5
- name: 'font-variant-ligatures',
6
- initialValue: 'normal',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, value) => {
10
- switch (value) {
11
- case 'none':
12
- return 1 /* FONT_VARIANT_LIGATURES.NONE */;
13
- case 'common-ligatures':
14
- return 2 /* FONT_VARIANT_LIGATURES.COMMON_LIGATURES */;
15
- case 'no-common-ligatures':
16
- return 3 /* FONT_VARIANT_LIGATURES.NO_COMMON_LIGATURES */;
17
- case 'discretionary-ligatures':
18
- return 4 /* FONT_VARIANT_LIGATURES.DISCRETIONARY_LIGATURES */;
19
- case 'no-discretionary-ligatures':
20
- return 5 /* FONT_VARIANT_LIGATURES.NO_DISCRETIONARY_LIGATURES */;
21
- case 'historical-ligatures':
22
- return 6 /* FONT_VARIANT_LIGATURES.HISTORICAL_LIGATURES */;
23
- case 'no-historical-ligatures':
24
- return 7 /* FONT_VARIANT_LIGATURES.NO_HISTORICAL_LIGATURES */;
25
- case 'contextual':
26
- return 8 /* FONT_VARIANT_LIGATURES.CONTEXTUAL */;
27
- case 'no-contextual':
28
- return 9 /* FONT_VARIANT_LIGATURES.NO_CONTEXTUAL */;
29
- case 'normal':
30
- default:
31
- return 0 /* FONT_VARIANT_LIGATURES.NORMAL */;
32
- }
33
- }
34
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontVariant = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.fontVariant = {
6
- name: 'font-variant',
7
- initialValue: 'none',
8
- type: 1 /* PropertyDescriptorParsingType.LIST */,
9
- prefix: false,
10
- parse: (_context, tokens) => {
11
- return tokens.filter(parser_1.isIdentToken).map((token) => token.value);
12
- }
13
- };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fontWeight = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.fontWeight = {
6
- name: 'font-weight',
7
- initialValue: 'normal',
8
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
9
- prefix: false,
10
- parse: (_context, token) => {
11
- if ((0, parser_1.isNumberToken)(token)) {
12
- return token.number;
13
- }
14
- if ((0, parser_1.isIdentToken)(token)) {
15
- switch (token.value) {
16
- case 'bold':
17
- return 700;
18
- case 'normal':
19
- default:
20
- return 400;
21
- }
22
- }
23
- return 400;
24
- }
25
- };
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.imageRendering = exports.IMAGE_RENDERING = void 0;
4
- var IMAGE_RENDERING;
5
- (function (IMAGE_RENDERING) {
6
- IMAGE_RENDERING[IMAGE_RENDERING["AUTO"] = 0] = "AUTO";
7
- IMAGE_RENDERING[IMAGE_RENDERING["CRISP_EDGES"] = 1] = "CRISP_EDGES";
8
- IMAGE_RENDERING[IMAGE_RENDERING["PIXELATED"] = 2] = "PIXELATED";
9
- IMAGE_RENDERING[IMAGE_RENDERING["SMOOTH"] = 3] = "SMOOTH";
10
- })(IMAGE_RENDERING || (exports.IMAGE_RENDERING = IMAGE_RENDERING = {}));
11
- exports.imageRendering = {
12
- name: 'image-rendering',
13
- initialValue: 'auto',
14
- prefix: false,
15
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
16
- parse: (_context, value) => {
17
- switch (value.toLowerCase()) {
18
- case 'crisp-edges':
19
- case '-webkit-crisp-edges':
20
- case '-moz-crisp-edges':
21
- return IMAGE_RENDERING.CRISP_EDGES;
22
- case 'pixelated':
23
- case '-webkit-optimize-contrast':
24
- return IMAGE_RENDERING.PIXELATED;
25
- case 'smooth':
26
- case 'high-quality':
27
- return IMAGE_RENDERING.SMOOTH;
28
- case 'auto':
29
- default:
30
- return IMAGE_RENDERING.AUTO;
31
- }
32
- }
33
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.letterSpacing = void 0;
4
- exports.letterSpacing = {
5
- name: 'letter-spacing',
6
- initialValue: '0',
7
- prefix: false,
8
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
9
- parse: (_context, token) => {
10
- if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'normal') {
11
- return 0;
12
- }
13
- if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
14
- return token.number;
15
- }
16
- if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
17
- return token.number;
18
- }
19
- return 0;
20
- }
21
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lineBreak = exports.LINE_BREAK = void 0;
4
- var LINE_BREAK;
5
- (function (LINE_BREAK) {
6
- LINE_BREAK["NORMAL"] = "normal";
7
- LINE_BREAK["STRICT"] = "strict";
8
- })(LINE_BREAK || (exports.LINE_BREAK = LINE_BREAK = {}));
9
- exports.lineBreak = {
10
- name: 'line-break',
11
- initialValue: 'normal',
12
- prefix: false,
13
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
14
- parse: (_context, lineBreak) => {
15
- switch (lineBreak) {
16
- case 'strict':
17
- return LINE_BREAK.STRICT;
18
- case 'normal':
19
- default:
20
- return LINE_BREAK.NORMAL;
21
- }
22
- }
23
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.computeLineHeight = exports.lineHeight = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- const length_percentage_1 = require("../types/length-percentage");
6
- exports.lineHeight = {
7
- name: 'line-height',
8
- initialValue: 'normal',
9
- prefix: false,
10
- type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
11
- };
12
- const computeLineHeight = (token, fontSize) => {
13
- if ((0, parser_1.isIdentToken)(token) && token.value === 'normal') {
14
- return 1.2 * fontSize;
15
- }
16
- else if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
17
- return fontSize * token.number;
18
- }
19
- else if ((0, length_percentage_1.isLengthPercentage)(token)) {
20
- return (0, length_percentage_1.getAbsoluteValue)(token, fontSize);
21
- }
22
- return fontSize;
23
- };
24
- exports.computeLineHeight = computeLineHeight;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listStyleImage = void 0;
4
- const image_1 = require("../types/image");
5
- exports.listStyleImage = {
6
- name: 'list-style-image',
7
- initialValue: 'none',
8
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
9
- prefix: false,
10
- skipCache: true,
11
- parse: (context, token) => {
12
- if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
13
- return null;
14
- }
15
- return image_1.image.parse(context, token);
16
- }
17
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listStylePosition = void 0;
4
- exports.listStylePosition = {
5
- name: 'list-style-position',
6
- initialValue: 'outside',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, position) => {
10
- switch (position) {
11
- case 'inside':
12
- return 0 /* LIST_STYLE_POSITION.INSIDE */;
13
- case 'outside':
14
- default:
15
- return 1 /* LIST_STYLE_POSITION.OUTSIDE */;
16
- }
17
- }
18
- };