html2canvas-pro 2.4.5 → 2.5.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 (228) hide show
  1. package/README.md +115 -13
  2. package/dist/html2canvas-pro.cjs +3058 -1607
  3. package/dist/html2canvas-pro.cjs.map +1 -1
  4. package/dist/html2canvas-pro.esm.js +3058 -1607
  5. package/dist/html2canvas-pro.esm.js.map +1 -1
  6. package/dist/html2canvas-pro.js +3055 -1604
  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 +4 -1
  10. package/dist/types/core/context.d.ts +10 -1
  11. package/dist/types/core/render-element.d.ts +11 -0
  12. package/dist/types/core/util.d.ts +6 -0
  13. package/dist/types/css/index.d.ts +77 -46
  14. package/dist/types/css/parse.d.ts +15 -0
  15. package/dist/types/css/property-descriptors/accent-color.d.ts +5 -0
  16. package/dist/types/css/property-descriptors/backdrop-filter.d.ts +9 -0
  17. package/dist/types/css/property-descriptors/background-blend-mode.d.ts +16 -16
  18. package/dist/types/css/property-descriptors/border-image-width.d.ts +36 -0
  19. package/dist/types/css/property-descriptors/clip-path.d.ts +16 -2
  20. package/dist/types/css/property-descriptors/isolation.d.ts +6 -0
  21. package/dist/types/css/property-descriptors/mask.d.ts +25 -0
  22. package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +16 -16
  23. package/dist/types/css/property-descriptors/outline.d.ts +15 -0
  24. package/dist/types/css/property-descriptors/text-emphasis.d.ts +22 -0
  25. package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
  26. package/dist/types/css/property-descriptors/webkit-box-reflect.d.ts +19 -0
  27. package/dist/types/css/property-descriptors/webkit-text-fill-color.d.ts +9 -0
  28. package/dist/types/css/syntax/token-constants.d.ts +1 -1
  29. package/dist/types/css/types/color-math.d.ts +7 -1
  30. package/dist/types/css/types/color-spaces/a98.d.ts +2 -1
  31. package/dist/types/css/types/color-spaces/p3.d.ts +5 -4
  32. package/dist/types/css/types/color-spaces/pro-photo.d.ts +5 -4
  33. package/dist/types/css/types/color-spaces/rec2020.d.ts +5 -4
  34. package/dist/types/css/types/color-spaces/srgb.d.ts +5 -4
  35. package/dist/types/css/types/color-utilities.d.ts +11 -11
  36. package/dist/types/css/types/color.d.ts +1 -0
  37. package/dist/types/css/types/functions/conic-gradient.d.ts +11 -0
  38. package/dist/types/css/types/functions/image-set.d.ts +11 -0
  39. package/dist/types/css/types/functions/repeating-radial-gradient.d.ts +8 -0
  40. package/dist/types/css/types/image.d.ts +15 -2
  41. package/dist/types/css/types/safe-eval.d.ts +0 -6
  42. package/dist/types/dom/copy-css-styles.d.ts +8 -0
  43. package/dist/types/dom/document-cloner.d.ts +3 -13
  44. package/dist/types/dom/iframe-mount.d.ts +37 -0
  45. package/dist/types/dom/pseudo-content.d.ts +33 -0
  46. package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +2 -2
  47. package/dist/types/options.d.ts +8 -2
  48. package/dist/types/render/canvas/background-renderer.d.ts +19 -0
  49. package/dist/types/render/canvas/border-image-renderer.d.ts +50 -1
  50. package/dist/types/render/canvas/canvas-renderer.d.ts +21 -15
  51. package/dist/types/render/canvas/mask-renderer.d.ts +36 -0
  52. package/dist/types/render/canvas/text-clip-renderer.d.ts +36 -0
  53. package/dist/types/render/canvas/text-renderer.d.ts +22 -0
  54. package/dist/types/render/stacking-context.d.ts +4 -1
  55. package/package.json +39 -40
  56. package/dist/lib/config.js +0 -49
  57. package/dist/lib/core/abort-helper.js +0 -20
  58. package/dist/lib/core/background-parser.js +0 -41
  59. package/dist/lib/core/bitwise.js +0 -5
  60. package/dist/lib/core/cache-storage.js +0 -283
  61. package/dist/lib/core/config-assembler.js +0 -88
  62. package/dist/lib/core/constants.js +0 -25
  63. package/dist/lib/core/context.js +0 -19
  64. package/dist/lib/core/debugger.js +0 -27
  65. package/dist/lib/core/features.js +0 -190
  66. package/dist/lib/core/logger.js +0 -56
  67. package/dist/lib/core/lru-map.js +0 -66
  68. package/dist/lib/core/origin-checker.js +0 -53
  69. package/dist/lib/core/performance-monitor.js +0 -185
  70. package/dist/lib/core/render-element.js +0 -131
  71. package/dist/lib/core/util.js +0 -4
  72. package/dist/lib/core/validator.js +0 -500
  73. package/dist/lib/css/grouped/background-styles.js +0 -36
  74. package/dist/lib/css/grouped/border-styles.js +0 -75
  75. package/dist/lib/css/grouped/font-styles.js +0 -93
  76. package/dist/lib/css/grouped/layout-styles.js +0 -127
  77. package/dist/lib/css/index.js +0 -339
  78. package/dist/lib/css/layout/bounds.js +0 -52
  79. package/dist/lib/css/layout/text.js +0 -133
  80. package/dist/lib/css/property-descriptor.js +0 -2
  81. package/dist/lib/css/property-descriptors/background-blend-mode.js +0 -41
  82. package/dist/lib/css/property-descriptors/background-clip.js +0 -25
  83. package/dist/lib/css/property-descriptors/background-color.js +0 -10
  84. package/dist/lib/css/property-descriptors/background-image.js +0 -24
  85. package/dist/lib/css/property-descriptors/background-origin.js +0 -23
  86. package/dist/lib/css/property-descriptors/background-position.js +0 -19
  87. package/dist/lib/css/property-descriptors/background-repeat.js +0 -33
  88. package/dist/lib/css/property-descriptors/background-size.js +0 -23
  89. package/dist/lib/css/property-descriptors/border-color.js +0 -14
  90. package/dist/lib/css/property-descriptors/border-image-repeat.js +0 -42
  91. package/dist/lib/css/property-descriptors/border-image-slice.js +0 -45
  92. package/dist/lib/css/property-descriptors/border-image-source.js +0 -22
  93. package/dist/lib/css/property-descriptors/border-radius.js +0 -15
  94. package/dist/lib/css/property-descriptors/border-style.js +0 -26
  95. package/dist/lib/css/property-descriptors/border-width.js +0 -20
  96. package/dist/lib/css/property-descriptors/box-decoration-break.js +0 -18
  97. package/dist/lib/css/property-descriptors/box-shadow.js +0 -54
  98. package/dist/lib/css/property-descriptors/clip-path.js +0 -189
  99. package/dist/lib/css/property-descriptors/color.js +0 -10
  100. package/dist/lib/css/property-descriptors/content.js +0 -19
  101. package/dist/lib/css/property-descriptors/counter-increment.js +0 -35
  102. package/dist/lib/css/property-descriptors/counter-reset.js +0 -18
  103. package/dist/lib/css/property-descriptors/direction.js +0 -18
  104. package/dist/lib/css/property-descriptors/display.js +0 -81
  105. package/dist/lib/css/property-descriptors/duration.js +0 -14
  106. package/dist/lib/css/property-descriptors/filter.js +0 -86
  107. package/dist/lib/css/property-descriptors/float.js +0 -22
  108. package/dist/lib/css/property-descriptors/font-family.js +0 -47
  109. package/dist/lib/css/property-descriptors/font-size.js +0 -10
  110. package/dist/lib/css/property-descriptors/font-style.js +0 -20
  111. package/dist/lib/css/property-descriptors/font-variant-ligatures.js +0 -34
  112. package/dist/lib/css/property-descriptors/font-variant.js +0 -13
  113. package/dist/lib/css/property-descriptors/font-weight.js +0 -25
  114. package/dist/lib/css/property-descriptors/image-rendering.js +0 -33
  115. package/dist/lib/css/property-descriptors/letter-spacing.js +0 -21
  116. package/dist/lib/css/property-descriptors/line-break.js +0 -23
  117. package/dist/lib/css/property-descriptors/line-height.js +0 -24
  118. package/dist/lib/css/property-descriptors/list-style-image.js +0 -17
  119. package/dist/lib/css/property-descriptors/list-style-position.js +0 -18
  120. package/dist/lib/css/property-descriptors/list-style-type.js +0 -122
  121. package/dist/lib/css/property-descriptors/margin.js +0 -13
  122. package/dist/lib/css/property-descriptors/mix-blend-mode.js +0 -31
  123. package/dist/lib/css/property-descriptors/object-fit.js +0 -28
  124. package/dist/lib/css/property-descriptors/object-position.js +0 -42
  125. package/dist/lib/css/property-descriptors/opacity.js +0 -16
  126. package/dist/lib/css/property-descriptors/overflow-wrap.js +0 -18
  127. package/dist/lib/css/property-descriptors/overflow.js +0 -27
  128. package/dist/lib/css/property-descriptors/padding.js +0 -14
  129. package/dist/lib/css/property-descriptors/paint-order.js +0 -33
  130. package/dist/lib/css/property-descriptors/position.js +0 -22
  131. package/dist/lib/css/property-descriptors/quotes.js +0 -41
  132. package/dist/lib/css/property-descriptors/rotate.js +0 -27
  133. package/dist/lib/css/property-descriptors/text-align.js +0 -21
  134. package/dist/lib/css/property-descriptors/text-decoration-color.js +0 -10
  135. package/dist/lib/css/property-descriptors/text-decoration-line.js +0 -28
  136. package/dist/lib/css/property-descriptors/text-decoration-style.js +0 -24
  137. package/dist/lib/css/property-descriptors/text-decoration-thickness.js +0 -26
  138. package/dist/lib/css/property-descriptors/text-overflow.js +0 -18
  139. package/dist/lib/css/property-descriptors/text-shadow.js +0 -46
  140. package/dist/lib/css/property-descriptors/text-transform.js +0 -20
  141. package/dist/lib/css/property-descriptors/text-underline-offset.js +0 -23
  142. package/dist/lib/css/property-descriptors/transform-origin.js +0 -24
  143. package/dist/lib/css/property-descriptors/transform.js +0 -57
  144. package/dist/lib/css/property-descriptors/visibility.js +0 -20
  145. package/dist/lib/css/property-descriptors/webkit-line-clamp.js +0 -26
  146. package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +0 -10
  147. package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +0 -16
  148. package/dist/lib/css/property-descriptors/white-space.js +0 -32
  149. package/dist/lib/css/property-descriptors/word-break.js +0 -26
  150. package/dist/lib/css/property-descriptors/writing-mode.js +0 -28
  151. package/dist/lib/css/property-descriptors/z-index.js +0 -19
  152. package/dist/lib/css/property-descriptors/zoom.js +0 -18
  153. package/dist/lib/css/syntax/parser.js +0 -141
  154. package/dist/lib/css/syntax/token-constants.js +0 -214
  155. package/dist/lib/css/syntax/token-singletons.js +0 -36
  156. package/dist/lib/css/syntax/token-types.js +0 -10
  157. package/dist/lib/css/syntax/tokenizer.js +0 -502
  158. package/dist/lib/css/type-descriptor.js +0 -2
  159. package/dist/lib/css/types/angle.js +0 -80
  160. package/dist/lib/css/types/color-math.js +0 -25
  161. package/dist/lib/css/types/color-spaces/a98.js +0 -78
  162. package/dist/lib/css/types/color-spaces/p3.js +0 -86
  163. package/dist/lib/css/types/color-spaces/pro-photo.js +0 -83
  164. package/dist/lib/css/types/color-spaces/rec2020.js +0 -85
  165. package/dist/lib/css/types/color-spaces/srgb.js +0 -79
  166. package/dist/lib/css/types/color-utilities.js +0 -342
  167. package/dist/lib/css/types/color.js +0 -400
  168. package/dist/lib/css/types/functions/-prefix-linear-gradient.js +0 -32
  169. package/dist/lib/css/types/functions/-prefix-radial-gradient.js +0 -83
  170. package/dist/lib/css/types/functions/-webkit-gradient.js +0 -59
  171. package/dist/lib/css/types/functions/counter.js +0 -367
  172. package/dist/lib/css/types/functions/gradient.js +0 -163
  173. package/dist/lib/css/types/functions/linear-gradient.js +0 -27
  174. package/dist/lib/css/types/functions/radial-gradient.js +0 -90
  175. package/dist/lib/css/types/functions/repeating-linear-gradient.js +0 -9
  176. package/dist/lib/css/types/image.js +0 -62
  177. package/dist/lib/css/types/index.js +0 -2
  178. package/dist/lib/css/types/length-percentage.js +0 -197
  179. package/dist/lib/css/types/length.js +0 -5
  180. package/dist/lib/css/types/safe-eval.js +0 -80
  181. package/dist/lib/css/types/time.js +0 -17
  182. package/dist/lib/dom/document-cloner.js +0 -618
  183. package/dist/lib/dom/dom-normalizer.js +0 -115
  184. package/dist/lib/dom/element-container.js +0 -71
  185. package/dist/lib/dom/elements/li-element-container.js +0 -11
  186. package/dist/lib/dom/elements/ol-element-container.js +0 -12
  187. package/dist/lib/dom/elements/select-element-container.js +0 -12
  188. package/dist/lib/dom/elements/textarea-element-container.js +0 -11
  189. package/dist/lib/dom/node-parser.js +0 -125
  190. package/dist/lib/dom/node-type-guards.js +0 -81
  191. package/dist/lib/dom/replaced-elements/canvas-element-container.js +0 -13
  192. package/dist/lib/dom/replaced-elements/iframe-element-container.js +0 -38
  193. package/dist/lib/dom/replaced-elements/image-element-container.js +0 -14
  194. package/dist/lib/dom/replaced-elements/index.js +0 -2
  195. package/dist/lib/dom/replaced-elements/input-element-container.js +0 -89
  196. package/dist/lib/dom/replaced-elements/svg-element-container.js +0 -57
  197. package/dist/lib/dom/slot-cloner.js +0 -176
  198. package/dist/lib/dom/text-container.js +0 -35
  199. package/dist/lib/index.js +0 -49
  200. package/dist/lib/options.js +0 -2
  201. package/dist/lib/render/background.js +0 -188
  202. package/dist/lib/render/bezier-curve.js +0 -34
  203. package/dist/lib/render/border.js +0 -104
  204. package/dist/lib/render/bound-curves.js +0 -188
  205. package/dist/lib/render/box-sizing.js +0 -20
  206. package/dist/lib/render/canvas/background-renderer.js +0 -338
  207. package/dist/lib/render/canvas/border-image-renderer.js +0 -153
  208. package/dist/lib/render/canvas/border-renderer.js +0 -184
  209. package/dist/lib/render/canvas/box-shadow-geometry.js +0 -52
  210. package/dist/lib/render/canvas/box-shadow-painter.js +0 -194
  211. package/dist/lib/render/canvas/box-shadow-transform.js +0 -42
  212. package/dist/lib/render/canvas/canvas-path.js +0 -25
  213. package/dist/lib/render/canvas/canvas-renderer.js +0 -610
  214. package/dist/lib/render/canvas/content-renderer.js +0 -270
  215. package/dist/lib/render/canvas/effects-renderer.js +0 -171
  216. package/dist/lib/render/canvas/filter-surface.js +0 -270
  217. package/dist/lib/render/canvas/font-utils.js +0 -46
  218. package/dist/lib/render/canvas/foreignobject-renderer.js +0 -38
  219. package/dist/lib/render/canvas/surface-bounds.js +0 -64
  220. package/dist/lib/render/canvas/text/text-decoration-renderer.js +0 -99
  221. package/dist/lib/render/canvas/text-renderer.js +0 -486
  222. package/dist/lib/render/effects.js +0 -231
  223. package/dist/lib/render/font-metrics.js +0 -53
  224. package/dist/lib/render/object-fit.js +0 -91
  225. package/dist/lib/render/path.js +0 -26
  226. package/dist/lib/render/renderer-interface.js +0 -2
  227. package/dist/lib/render/stacking-context.js +0 -341
  228. package/dist/lib/render/vector.js +0 -16
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textDecorationStyle = void 0;
4
- exports.textDecorationStyle = {
5
- name: 'text-decoration-style',
6
- initialValue: 'solid',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, style) => {
10
- switch (style) {
11
- case 'double':
12
- return 1 /* TEXT_DECORATION_STYLE.DOUBLE */;
13
- case 'dotted':
14
- return 2 /* TEXT_DECORATION_STYLE.DOTTED */;
15
- case 'dashed':
16
- return 3 /* TEXT_DECORATION_STYLE.DASHED */;
17
- case 'wavy':
18
- return 4 /* TEXT_DECORATION_STYLE.WAVY */;
19
- case 'solid':
20
- default:
21
- return 0 /* TEXT_DECORATION_STYLE.SOLID */;
22
- }
23
- }
24
- };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textDecorationThickness = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.textDecorationThickness = {
6
- name: 'text-decoration-thickness',
7
- initialValue: 'auto',
8
- prefix: false,
9
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
10
- parse: (_context, token) => {
11
- if ((0, parser_1.isIdentToken)(token)) {
12
- switch (token.value) {
13
- case 'auto':
14
- return 'auto';
15
- case 'from-font':
16
- return 'from-font';
17
- }
18
- }
19
- if ((0, parser_1.isDimensionToken)(token)) {
20
- // Convert to pixels
21
- return token.number;
22
- }
23
- // Default to auto
24
- return 'auto';
25
- }
26
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textOverflow = void 0;
4
- exports.textOverflow = {
5
- name: 'text-overflow',
6
- initialValue: 'clip',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, textOverflow) => {
10
- switch (textOverflow) {
11
- case 'ellipsis':
12
- return 1 /* TEXT_OVERFLOW.ELLIPSIS */;
13
- case 'clip':
14
- default:
15
- return 0 /* TEXT_OVERFLOW.CLIP */;
16
- }
17
- }
18
- };
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textShadow = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- const length_percentage_1 = require("../types/length-percentage");
6
- const color_1 = require("../types/color");
7
- const length_1 = require("../types/length");
8
- exports.textShadow = {
9
- name: 'text-shadow',
10
- initialValue: 'none',
11
- type: 1 /* PropertyDescriptorParsingType.LIST */,
12
- prefix: false,
13
- parse: (context, tokens) => {
14
- if (tokens.length === 1 && (0, parser_1.isIdentWithValue)(tokens[0], 'none')) {
15
- return [];
16
- }
17
- return (0, parser_1.parseFunctionArgs)(tokens).map((values) => {
18
- const shadow = {
19
- color: color_1.COLORS.TRANSPARENT,
20
- offsetX: length_percentage_1.ZERO_LENGTH,
21
- offsetY: length_percentage_1.ZERO_LENGTH,
22
- blur: length_percentage_1.ZERO_LENGTH
23
- };
24
- let c = 0;
25
- for (let i = 0; i < values.length; i++) {
26
- const token = values[i];
27
- if ((0, length_1.isLength)(token)) {
28
- if (c === 0) {
29
- shadow.offsetX = token;
30
- }
31
- else if (c === 1) {
32
- shadow.offsetY = token;
33
- }
34
- else {
35
- shadow.blur = token;
36
- }
37
- c++;
38
- }
39
- else {
40
- shadow.color = color_1.color.parse(context, token);
41
- }
42
- }
43
- return shadow;
44
- });
45
- }
46
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textTransform = void 0;
4
- exports.textTransform = {
5
- name: 'text-transform',
6
- initialValue: 'none',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, textTransform) => {
10
- switch (textTransform) {
11
- case 'uppercase':
12
- return 2 /* TEXT_TRANSFORM.UPPERCASE */;
13
- case 'lowercase':
14
- return 1 /* TEXT_TRANSFORM.LOWERCASE */;
15
- case 'capitalize':
16
- return 3 /* TEXT_TRANSFORM.CAPITALIZE */;
17
- }
18
- return 0 /* TEXT_TRANSFORM.NONE */;
19
- }
20
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textUnderlineOffset = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.textUnderlineOffset = {
6
- name: 'text-underline-offset',
7
- initialValue: 'auto',
8
- prefix: false,
9
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
10
- parse: (_context, token) => {
11
- if ((0, parser_1.isIdentToken)(token)) {
12
- if (token.value === 'auto') {
13
- return 'auto';
14
- }
15
- }
16
- if ((0, parser_1.isDimensionToken)(token)) {
17
- // Return pixel value
18
- return token.number;
19
- }
20
- // Default to auto
21
- return 'auto';
22
- }
23
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformOrigin = void 0;
4
- const length_percentage_1 = require("../types/length-percentage");
5
- const tokenizer_1 = require("../syntax/tokenizer");
6
- const DEFAULT_VALUE = {
7
- type: 16 /* TokenType.PERCENTAGE_TOKEN */,
8
- number: 50,
9
- flags: tokenizer_1.FLAG_INTEGER
10
- };
11
- const DEFAULT = [DEFAULT_VALUE, DEFAULT_VALUE];
12
- exports.transformOrigin = {
13
- name: 'transform-origin',
14
- initialValue: '50% 50%',
15
- prefix: true,
16
- type: 1 /* PropertyDescriptorParsingType.LIST */,
17
- parse: (_context, tokens) => {
18
- const origins = tokens.filter(length_percentage_1.isLengthPercentage);
19
- if (origins.length !== 2) {
20
- return DEFAULT;
21
- }
22
- return [origins[0], origins[1]];
23
- }
24
- };
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transform = void 0;
4
- const angle_1 = require("../types/angle");
5
- exports.transform = {
6
- name: 'transform',
7
- initialValue: 'none',
8
- prefix: true,
9
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
10
- parse: (_context, token) => {
11
- if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
12
- return null;
13
- }
14
- if (token.type === 18 /* TokenType.FUNCTION */) {
15
- const transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
16
- if (typeof transformFunction === 'undefined') {
17
- throw new Error(`Attempting to parse an unsupported transform function "${token.name}"`);
18
- }
19
- return transformFunction(_context, token.values);
20
- }
21
- return null;
22
- }
23
- };
24
- const matrix = (_context, args) => {
25
- const values = args.filter((arg) => arg.type === 17 /* TokenType.NUMBER_TOKEN */).map((arg) => arg.number);
26
- return values.length === 6 ? values : null;
27
- };
28
- // doesn't support 3D transforms at the moment
29
- const matrix3d = (_context, args) => {
30
- const values = args.filter((arg) => arg.type === 17 /* TokenType.NUMBER_TOKEN */).map((arg) => arg.number);
31
- const [a1, b1, {}, {}, a2, b2, {}, {}, {}, {}, {}, {}, a4, b4, {}, {}] = values;
32
- return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
33
- };
34
- const rotate = (context, args) => {
35
- if (args.length !== 1) {
36
- return null;
37
- }
38
- const arg = args[0];
39
- let radians = 0;
40
- if (arg.type === 17 /* TokenType.NUMBER_TOKEN */ && arg.number === 0) {
41
- radians = 0;
42
- }
43
- else if (arg.type === 15 /* TokenType.DIMENSION_TOKEN */) {
44
- radians = angle_1.angle.parse(context, arg);
45
- }
46
- else {
47
- return null;
48
- }
49
- const cos = Math.cos(radians);
50
- const sin = Math.sin(radians);
51
- return [cos, sin, -sin, cos, 0, 0];
52
- };
53
- const SUPPORTED_TRANSFORM_FUNCTIONS = {
54
- matrix: matrix,
55
- matrix3d: matrix3d,
56
- rotate: rotate
57
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visibility = void 0;
4
- exports.visibility = {
5
- name: 'visibility',
6
- initialValue: 'none',
7
- prefix: false,
8
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
9
- parse: (_context, visibility) => {
10
- switch (visibility) {
11
- case 'hidden':
12
- return 1 /* VISIBILITY.HIDDEN */;
13
- case 'collapse':
14
- return 2 /* VISIBILITY.COLLAPSE */;
15
- case 'visible':
16
- default:
17
- return 0 /* VISIBILITY.VISIBLE */;
18
- }
19
- }
20
- };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webkitLineClamp = void 0;
4
- /**
5
- * -webkit-line-clamp property descriptor
6
- * Used with display: -webkit-box and -webkit-box-orient: vertical
7
- * to limit text to a specific number of lines
8
- */
9
- exports.webkitLineClamp = {
10
- name: '-webkit-line-clamp',
11
- initialValue: 'none',
12
- prefix: true,
13
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
14
- parse: (_context, token) => {
15
- // 'none' means no line clamping
16
- if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
17
- return 0;
18
- }
19
- // Number value specifies the number of lines
20
- if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
21
- return Math.max(0, Math.floor(token.number));
22
- }
23
- // Default to 0 (no clamping)
24
- return 0;
25
- }
26
- };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webkitTextStrokeColor = void 0;
4
- exports.webkitTextStrokeColor = {
5
- name: `-webkit-text-stroke-color`,
6
- initialValue: 'currentcolor',
7
- prefix: false,
8
- type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
9
- format: 'color'
10
- };
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webkitTextStrokeWidth = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.webkitTextStrokeWidth = {
6
- name: `-webkit-text-stroke-width`,
7
- initialValue: '0',
8
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
9
- prefix: false,
10
- parse: (_context, token) => {
11
- if ((0, parser_1.isDimensionToken)(token)) {
12
- return token.number;
13
- }
14
- return 0;
15
- }
16
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.whiteSpace = exports.WHITE_SPACE = void 0;
4
- var WHITE_SPACE;
5
- (function (WHITE_SPACE) {
6
- WHITE_SPACE["NORMAL"] = "normal";
7
- WHITE_SPACE["PRE"] = "pre";
8
- WHITE_SPACE["NOWRAP"] = "nowrap";
9
- WHITE_SPACE["PRE_WRAP"] = "pre-wrap";
10
- WHITE_SPACE["PRE_LINE"] = "pre-line";
11
- })(WHITE_SPACE || (exports.WHITE_SPACE = WHITE_SPACE = {}));
12
- exports.whiteSpace = {
13
- name: 'white-space',
14
- initialValue: 'normal',
15
- prefix: false,
16
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
17
- parse: (_context, value) => {
18
- switch (value) {
19
- case 'pre':
20
- return WHITE_SPACE.PRE;
21
- case 'nowrap':
22
- return WHITE_SPACE.NOWRAP;
23
- case 'pre-wrap':
24
- return WHITE_SPACE.PRE_WRAP;
25
- case 'pre-line':
26
- return WHITE_SPACE.PRE_LINE;
27
- case 'normal':
28
- default:
29
- return WHITE_SPACE.NORMAL;
30
- }
31
- }
32
- };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wordBreak = exports.WORD_BREAK = void 0;
4
- var WORD_BREAK;
5
- (function (WORD_BREAK) {
6
- WORD_BREAK["NORMAL"] = "normal";
7
- WORD_BREAK["BREAK_ALL"] = "break-all";
8
- WORD_BREAK["KEEP_ALL"] = "keep-all";
9
- })(WORD_BREAK || (exports.WORD_BREAK = WORD_BREAK = {}));
10
- exports.wordBreak = {
11
- name: 'word-break',
12
- initialValue: 'normal',
13
- prefix: false,
14
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
15
- parse: (_context, wordBreak) => {
16
- switch (wordBreak) {
17
- case 'break-all':
18
- return WORD_BREAK.BREAK_ALL;
19
- case 'keep-all':
20
- return WORD_BREAK.KEEP_ALL;
21
- case 'normal':
22
- default:
23
- return WORD_BREAK.NORMAL;
24
- }
25
- }
26
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writingMode = exports.isSidewaysWritingMode = exports.isVerticalWritingMode = void 0;
4
- const isVerticalWritingMode = (writingMode) => writingMode !== 0 /* WRITING_MODE.HORIZONTAL_TB */;
5
- exports.isVerticalWritingMode = isVerticalWritingMode;
6
- const isSidewaysWritingMode = (writingMode) => writingMode === 3 /* WRITING_MODE.SIDEWAYS_RL */ || writingMode === 4 /* WRITING_MODE.SIDEWAYS_LR */;
7
- exports.isSidewaysWritingMode = isSidewaysWritingMode;
8
- exports.writingMode = {
9
- name: 'writing-mode',
10
- initialValue: 'horizontal-tb',
11
- prefix: false,
12
- type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
13
- parse: (_context, writingMode) => {
14
- switch (writingMode) {
15
- case 'vertical-rl':
16
- return 1 /* WRITING_MODE.VERTICAL_RL */;
17
- case 'vertical-lr':
18
- return 2 /* WRITING_MODE.VERTICAL_LR */;
19
- case 'sideways-rl':
20
- return 3 /* WRITING_MODE.SIDEWAYS_RL */;
21
- case 'sideways-lr':
22
- return 4 /* WRITING_MODE.SIDEWAYS_LR */;
23
- case 'horizontal-tb':
24
- default:
25
- return 0 /* WRITING_MODE.HORIZONTAL_TB */;
26
- }
27
- }
28
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zIndex = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- exports.zIndex = {
6
- name: 'z-index',
7
- initialValue: 'auto',
8
- prefix: false,
9
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
10
- parse: (_context, token) => {
11
- if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
12
- return { auto: true, order: 0 };
13
- }
14
- if ((0, parser_1.isNumberToken)(token)) {
15
- return { auto: false, order: token.number };
16
- }
17
- throw new Error(`Invalid z-index number parsed`);
18
- }
19
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zoom = void 0;
4
- exports.zoom = {
5
- name: 'zoom',
6
- initialValue: '1',
7
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
8
- prefix: false,
9
- parse: (_context, token) => {
10
- if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
11
- return Math.max(0, token.number / 100);
12
- }
13
- if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
14
- return Math.max(0, token.number);
15
- }
16
- return 1;
17
- }
18
- };
@@ -1,141 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseFunctionArgs = exports.nonFunctionArgSeparator = exports.nonWhiteSpace = exports.isIdentWithValue = exports.isStringToken = exports.isIdentToken = exports.isNumberToken = exports.isDimensionToken = exports.Parser = void 0;
4
- const tokenizer_1 = require("./tokenizer");
5
- class Parser {
6
- constructor(tokens) {
7
- this._tokens = tokens;
8
- }
9
- static create(value) {
10
- const tokenizer = new tokenizer_1.Tokenizer();
11
- tokenizer.write(value);
12
- return new Parser(tokenizer.read());
13
- }
14
- static parseValue(value) {
15
- return Parser.create(value).parseComponentValue();
16
- }
17
- static parseValues(value) {
18
- return Parser.create(value).parseComponentValues();
19
- }
20
- parseComponentValue() {
21
- let token = this.consumeToken();
22
- while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */) {
23
- token = this.consumeToken();
24
- }
25
- if (token.type === 32 /* TokenType.EOF_TOKEN */) {
26
- throw new SyntaxError(`Error parsing CSS component value, unexpected EOF`);
27
- }
28
- this.reconsumeToken(token);
29
- const value = this.consumeComponentValue();
30
- do {
31
- token = this.consumeToken();
32
- } while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */);
33
- if (token.type === 32 /* TokenType.EOF_TOKEN */) {
34
- return value;
35
- }
36
- throw new SyntaxError(`Error parsing CSS component value, multiple values found when expecting only one`);
37
- }
38
- parseComponentValues() {
39
- const values = [];
40
- while (true) {
41
- const value = this.consumeComponentValue();
42
- if (value.type === 32 /* TokenType.EOF_TOKEN */) {
43
- return values;
44
- }
45
- values.push(value);
46
- }
47
- }
48
- consumeComponentValue() {
49
- const token = this.consumeToken();
50
- switch (token.type) {
51
- case 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */:
52
- case 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */:
53
- case 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */:
54
- return this.consumeSimpleBlock(token.type);
55
- case 19 /* TokenType.FUNCTION_TOKEN */:
56
- return this.consumeFunction(token);
57
- }
58
- return token;
59
- }
60
- consumeSimpleBlock(type) {
61
- const block = { type, values: [] };
62
- let token = this.consumeToken();
63
- while (true) {
64
- if (token.type === 32 /* TokenType.EOF_TOKEN */ || isEndingTokenFor(token, type)) {
65
- return block;
66
- }
67
- this.reconsumeToken(token);
68
- block.values.push(this.consumeComponentValue());
69
- token = this.consumeToken();
70
- }
71
- }
72
- consumeFunction(functionToken) {
73
- const cssFunction = {
74
- name: functionToken.value,
75
- values: [],
76
- type: 18 /* TokenType.FUNCTION */
77
- };
78
- while (true) {
79
- const token = this.consumeToken();
80
- if (token.type === 32 /* TokenType.EOF_TOKEN */ || token.type === 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */) {
81
- return cssFunction;
82
- }
83
- this.reconsumeToken(token);
84
- cssFunction.values.push(this.consumeComponentValue());
85
- }
86
- }
87
- consumeToken() {
88
- const token = this._tokens.shift();
89
- return typeof token === 'undefined' ? tokenizer_1.EOF_TOKEN : token;
90
- }
91
- reconsumeToken(token) {
92
- this._tokens.unshift(token);
93
- }
94
- }
95
- exports.Parser = Parser;
96
- const isDimensionToken = (token) => token.type === 15 /* TokenType.DIMENSION_TOKEN */;
97
- exports.isDimensionToken = isDimensionToken;
98
- const isNumberToken = (token) => token.type === 17 /* TokenType.NUMBER_TOKEN */;
99
- exports.isNumberToken = isNumberToken;
100
- const isIdentToken = (token) => token.type === 20 /* TokenType.IDENT_TOKEN */;
101
- exports.isIdentToken = isIdentToken;
102
- const isStringToken = (token) => token.type === 0 /* TokenType.STRING_TOKEN */;
103
- exports.isStringToken = isStringToken;
104
- const isIdentWithValue = (token, value) => (0, exports.isIdentToken)(token) && token.value === value;
105
- exports.isIdentWithValue = isIdentWithValue;
106
- const nonWhiteSpace = (token) => token.type !== 31 /* TokenType.WHITESPACE_TOKEN */;
107
- exports.nonWhiteSpace = nonWhiteSpace;
108
- const nonFunctionArgSeparator = (token) => token.type !== 31 /* TokenType.WHITESPACE_TOKEN */ && token.type !== 4 /* TokenType.COMMA_TOKEN */;
109
- exports.nonFunctionArgSeparator = nonFunctionArgSeparator;
110
- const parseFunctionArgs = (tokens) => {
111
- const args = [];
112
- let arg = [];
113
- tokens.forEach((token) => {
114
- if (token.type === 4 /* TokenType.COMMA_TOKEN */) {
115
- // Skip empty arguments (e.g. "1px,,2px") instead of throwing —
116
- // real-world computed styles can produce them.
117
- if (arg.length) {
118
- args.push(arg);
119
- arg = [];
120
- }
121
- return;
122
- }
123
- if (token.type !== 31 /* TokenType.WHITESPACE_TOKEN */) {
124
- arg.push(token);
125
- }
126
- });
127
- if (arg.length) {
128
- args.push(arg);
129
- }
130
- return args;
131
- };
132
- exports.parseFunctionArgs = parseFunctionArgs;
133
- const isEndingTokenFor = (token, type) => {
134
- if (type === 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */ && token.type === 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */) {
135
- return true;
136
- }
137
- if (type === 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */ && token.type === 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */) {
138
- return true;
139
- }
140
- return type === 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */ && token.type === 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */;
141
- };