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,189 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clipPath = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- const length_percentage_1 = require("../types/length-percentage");
6
- const NONE = { type: 0 /* CLIP_PATH_TYPE.NONE */ };
7
- /**
8
- * Parse a shape-radius token: <length-percentage> | closest-side | farthest-side.
9
- * Defaults to 'closest-side' when no tokens are provided.
10
- */
11
- const parseShapeRadius = (tokens) => {
12
- const [first] = tokens;
13
- if (!first)
14
- return 'closest-side';
15
- if ((0, parser_1.isIdentToken)(first)) {
16
- // Any unrecognised keyword (e.g. 'closest-corner') intentionally falls back to
17
- // 'closest-side' as the CSS spec requires unknown values to be treated as invalid
18
- // and the initial value of <shape-radius> is 'closest-side'.
19
- return first.value === 'farthest-side' ? 'farthest-side' : 'closest-side';
20
- }
21
- return (0, length_percentage_1.isLengthPercentage)(first) ? first : 'closest-side';
22
- };
23
- /**
24
- * Parse a CSS <position> as (cx, cy), each as a LengthPercentage.
25
- *
26
- * Supports the **1–2 value** subset of the CSS `<position>` syntax.
27
- * The 4-value form (`at left 10px top 20px`) is not supported and will be
28
- * parsed on a best-effort basis.
29
- *
30
- * Axis assignment rules:
31
- * - `left` / `right` → x-axis (cx)
32
- * - `top` / `bottom` → y-axis (cy)
33
- * - `center` or a <length-percentage> → fills the first unset axis, in order
34
- *
35
- * Examples:
36
- * "at left" → cx=0, cy=50% (left is x; y defaults to center)
37
- * "at top" → cx=50%, cy=0 (top is y; x defaults to center)
38
- * "at center 30%" → cx=50%, cy=30%
39
- * "at 30% center" → cx=30%, cy=50%
40
- * "at left top" → cx=0, cy=0
41
- * "at top left" → cx=0, cy=0 (keyword order is irrelevant)
42
- *
43
- * Unset axes fall back to 50%.
44
- */
45
- const parsePosition = (tokens) => {
46
- let cx = null;
47
- let cy = null;
48
- for (const token of tokens) {
49
- if ((0, parser_1.isIdentToken)(token)) {
50
- switch (token.value) {
51
- case 'left':
52
- cx = length_percentage_1.ZERO_LENGTH;
53
- break;
54
- case 'right':
55
- cx = length_percentage_1.HUNDRED_PERCENT;
56
- break;
57
- case 'top':
58
- cy = length_percentage_1.ZERO_LENGTH;
59
- break;
60
- case 'bottom':
61
- cy = length_percentage_1.HUNDRED_PERCENT;
62
- break;
63
- case 'center':
64
- // `center` fills whichever axis has not yet been claimed.
65
- if (cx === null)
66
- cx = length_percentage_1.FIFTY_PERCENT;
67
- else if (cy === null)
68
- cy = length_percentage_1.FIFTY_PERCENT;
69
- break;
70
- }
71
- }
72
- else if ((0, length_percentage_1.isLengthPercentage)(token)) {
73
- // Length-percentages are assigned in source order.
74
- if (cx === null)
75
- cx = token;
76
- else if (cy === null)
77
- cy = token;
78
- }
79
- }
80
- return { cx: cx ?? length_percentage_1.FIFTY_PERCENT, cy: cy ?? length_percentage_1.FIFTY_PERCENT };
81
- };
82
- /**
83
- * inset( <length-percentage>{1,4} [ round <'border-radius'> ]? )
84
- * The 1-4 shorthand follows the same expansion as margin/padding:
85
- * 1 value → all four sides
86
- * 2 values → top/bottom | left/right
87
- * 3 values → top | left/right | bottom
88
- * 4 values → top | right | bottom | left
89
- * The optional `round` clause (border-radius) is parsed but ignored.
90
- */
91
- const parseInset = (values) => {
92
- const lengths = [];
93
- for (const token of values) {
94
- if (token.type === 31 /* TokenType.WHITESPACE_TOKEN */)
95
- continue;
96
- if ((0, parser_1.isIdentToken)(token) && token.value === 'round')
97
- break;
98
- if ((0, length_percentage_1.isLengthPercentage)(token))
99
- lengths.push(token);
100
- }
101
- const v0 = lengths[0] ?? length_percentage_1.ZERO_LENGTH;
102
- const v1 = lengths[1] ?? v0;
103
- const v2 = lengths[2] ?? v0;
104
- const v3 = lengths[3] ?? v1;
105
- return { type: 1 /* CLIP_PATH_TYPE.INSET */, top: v0, right: v1, bottom: v2, left: v3 };
106
- };
107
- /**
108
- * circle( [ <shape-radius> ]? [ at <position> ]? )
109
- */
110
- const parseCircle = (values) => {
111
- const nonWs = values.filter(parser_1.nonWhiteSpace);
112
- const atIdx = nonWs.findIndex((t) => (0, parser_1.isIdentWithValue)(t, 'at'));
113
- const radiusTokens = atIdx === -1 ? nonWs : nonWs.slice(0, atIdx);
114
- const posTokens = atIdx === -1 ? [] : nonWs.slice(atIdx + 1);
115
- return {
116
- type: 2 /* CLIP_PATH_TYPE.CIRCLE */,
117
- radius: parseShapeRadius(radiusTokens),
118
- ...parsePosition(posTokens)
119
- };
120
- };
121
- /**
122
- * ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )
123
- */
124
- const parseEllipse = (values) => {
125
- const nonWs = values.filter(parser_1.nonWhiteSpace);
126
- const atIdx = nonWs.findIndex((t) => (0, parser_1.isIdentWithValue)(t, 'at'));
127
- const radiusTokens = atIdx === -1 ? nonWs : nonWs.slice(0, atIdx);
128
- const posTokens = atIdx === -1 ? [] : nonWs.slice(atIdx + 1);
129
- return {
130
- type: 3 /* CLIP_PATH_TYPE.ELLIPSE */,
131
- rx: parseShapeRadius(radiusTokens.slice(0, 1)),
132
- ry: parseShapeRadius(radiusTokens.slice(1, 2)),
133
- ...parsePosition(posTokens)
134
- };
135
- };
136
- /**
137
- * polygon( [ <fill-rule>, ]? [ <length-percentage> <length-percentage> ]# )
138
- * Each comma-separated group defines one vertex (x y).
139
- * A leading fill-rule keyword (nonzero/evenodd) is skipped.
140
- */
141
- const parsePolygon = (values) => {
142
- const args = (0, parser_1.parseFunctionArgs)(values);
143
- const points = [];
144
- for (const arg of args) {
145
- if (arg.length === 1 && (0, parser_1.isIdentToken)(arg[0]))
146
- continue; // skip fill-rule
147
- const lengths = arg.filter(length_percentage_1.isLengthPercentage);
148
- if (lengths.length >= 2) {
149
- points.push([lengths[0], lengths[1]]);
150
- }
151
- }
152
- return { type: 4 /* CLIP_PATH_TYPE.POLYGON */, points };
153
- };
154
- /**
155
- * path( [ <fill-rule>, ]? <string> )
156
- * The string value is the SVG path data (coordinates in the element's local space).
157
- */
158
- const parsePath = (values) => {
159
- const stringToken = values.find((t) => t.type === 0 /* TokenType.STRING_TOKEN */);
160
- if (!stringToken)
161
- return NONE;
162
- return { type: 5 /* CLIP_PATH_TYPE.PATH */, d: stringToken.value };
163
- };
164
- exports.clipPath = {
165
- name: 'clip-path',
166
- initialValue: 'none',
167
- prefix: false,
168
- type: 0 /* PropertyDescriptorParsingType.VALUE */,
169
- parse: (_context, token) => {
170
- if ((0, parser_1.isIdentToken)(token) && token.value === 'none') {
171
- return NONE;
172
- }
173
- if (token.type === 18 /* TokenType.FUNCTION */) {
174
- switch (token.name) {
175
- case 'inset':
176
- return parseInset(token.values);
177
- case 'circle':
178
- return parseCircle(token.values);
179
- case 'ellipse':
180
- return parseEllipse(token.values);
181
- case 'polygon':
182
- return parsePolygon(token.values);
183
- case 'path':
184
- return parsePath(token.values);
185
- }
186
- }
187
- return NONE;
188
- }
189
- };
@@ -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
- };