html2canvas-pro 2.4.4 → 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 +3246 -1601
  3. package/dist/html2canvas-pro.cjs.map +1 -1
  4. package/dist/html2canvas-pro.esm.js +3246 -1601
  5. package/dist/html2canvas-pro.esm.js.map +1 -1
  6. package/dist/html2canvas-pro.js +3242 -1597
  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/box-shadow-geometry.d.ts +3 -0
  51. package/dist/types/render/canvas/box-shadow-painter.d.ts +13 -0
  52. package/dist/types/render/canvas/box-shadow-transform.d.ts +16 -0
  53. package/dist/types/render/canvas/canvas-renderer.d.ts +21 -15
  54. package/dist/types/render/canvas/mask-renderer.d.ts +36 -0
  55. package/dist/types/render/canvas/text-clip-renderer.d.ts +36 -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 +39 -40
  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/canvas-path.js +0 -25
  213. package/dist/lib/render/canvas/canvas-renderer.js +0 -633
  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,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EOF_TOKEN = exports.WHITESPACE_TOKEN = exports.RIGHT_SQUARE_BRACKET_TOKEN = exports.LEFT_SQUARE_BRACKET_TOKEN = exports.SEMICOLON_TOKEN = exports.COLON_TOKEN = exports.CDC_TOKEN = exports.CDO_TOKEN = exports.BAD_STRING_TOKEN = exports.BAD_URL_TOKEN = exports.SUBSTRING_MATCH_TOKEN = exports.RIGHT_CURLY_BRACKET_TOKEN = exports.LEFT_CURLY_BRACKET_TOKEN = exports.INCLUDE_MATCH_TOKEN = exports.DASH_MATCH_TOKEN = exports.COLUMN_TOKEN = exports.PREFIX_MATCH_TOKEN = exports.SUFFIX_MATCH_TOKEN = exports.COMMA_TOKEN = exports.RIGHT_PARENTHESIS_TOKEN = exports.LEFT_PARENTHESIS_TOKEN = void 0;
4
- exports.LEFT_PARENTHESIS_TOKEN = {
5
- type: 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */
6
- };
7
- exports.RIGHT_PARENTHESIS_TOKEN = {
8
- type: 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */
9
- };
10
- exports.COMMA_TOKEN = { type: 4 /* TokenType.COMMA_TOKEN */ };
11
- exports.SUFFIX_MATCH_TOKEN = { type: 13 /* TokenType.SUFFIX_MATCH_TOKEN */ };
12
- exports.PREFIX_MATCH_TOKEN = { type: 8 /* TokenType.PREFIX_MATCH_TOKEN */ };
13
- exports.COLUMN_TOKEN = { type: 21 /* TokenType.COLUMN_TOKEN */ };
14
- exports.DASH_MATCH_TOKEN = { type: 9 /* TokenType.DASH_MATCH_TOKEN */ };
15
- exports.INCLUDE_MATCH_TOKEN = { type: 10 /* TokenType.INCLUDE_MATCH_TOKEN */ };
16
- exports.LEFT_CURLY_BRACKET_TOKEN = {
17
- type: 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */
18
- };
19
- exports.RIGHT_CURLY_BRACKET_TOKEN = {
20
- type: 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */
21
- };
22
- exports.SUBSTRING_MATCH_TOKEN = { type: 14 /* TokenType.SUBSTRING_MATCH_TOKEN */ };
23
- exports.BAD_URL_TOKEN = { type: 23 /* TokenType.BAD_URL_TOKEN */ };
24
- exports.BAD_STRING_TOKEN = { type: 1 /* TokenType.BAD_STRING_TOKEN */ };
25
- exports.CDO_TOKEN = { type: 25 /* TokenType.CDO_TOKEN */ };
26
- exports.CDC_TOKEN = { type: 24 /* TokenType.CDC_TOKEN */ };
27
- exports.COLON_TOKEN = { type: 26 /* TokenType.COLON_TOKEN */ };
28
- exports.SEMICOLON_TOKEN = { type: 27 /* TokenType.SEMICOLON_TOKEN */ };
29
- exports.LEFT_SQUARE_BRACKET_TOKEN = {
30
- type: 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */
31
- };
32
- exports.RIGHT_SQUARE_BRACKET_TOKEN = {
33
- type: 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */
34
- };
35
- exports.WHITESPACE_TOKEN = { type: 31 /* TokenType.WHITESPACE_TOKEN */ };
36
- exports.EOF_TOKEN = { type: 32 /* TokenType.EOF_TOKEN */ };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- // https://www.w3.org/TR/css-syntax-3
3
- // Token type system — enums, interfaces, and union types consumed by
4
- // the tokenizer, parser, and property descriptors.
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FLAG_NUMBER = exports.FLAG_INTEGER = exports.FLAG_ID = exports.FLAG_UNRESTRICTED = void 0;
7
- exports.FLAG_UNRESTRICTED = 1 << 0;
8
- exports.FLAG_ID = 1 << 1;
9
- exports.FLAG_INTEGER = 1 << 2;
10
- exports.FLAG_NUMBER = 1 << 3;
@@ -1,502 +0,0 @@
1
- "use strict";
2
- // https://www.w3.org/TR/css-syntax-3
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Tokenizer = exports.COLUMN_TOKEN = exports.INCLUDE_MATCH_TOKEN = exports.DASH_MATCH_TOKEN = exports.SUBSTRING_MATCH_TOKEN = exports.SUFFIX_MATCH_TOKEN = exports.PREFIX_MATCH_TOKEN = exports.CDO_TOKEN = exports.CDC_TOKEN = exports.BAD_STRING_TOKEN = exports.BAD_URL_TOKEN = exports.EOF_TOKEN = exports.WHITESPACE_TOKEN = exports.RIGHT_SQUARE_BRACKET_TOKEN = exports.LEFT_SQUARE_BRACKET_TOKEN = exports.RIGHT_CURLY_BRACKET_TOKEN = exports.LEFT_CURLY_BRACKET_TOKEN = exports.RIGHT_PARENTHESIS_TOKEN = exports.LEFT_PARENTHESIS_TOKEN = exports.SEMICOLON_TOKEN = exports.COLON_TOKEN = exports.COMMA_TOKEN = exports.isNumberStart = exports.isNameStartCodePoint = exports.isIdentifierStart = exports.isValidEscape = exports.isNameCodePoint = exports.isWhiteSpace = exports.isHex = exports.isDigit = exports.FLAG_NUMBER = exports.FLAG_INTEGER = exports.FLAG_ID = exports.FLAG_UNRESTRICTED = void 0;
5
- const css_line_break_1 = require("css-line-break");
6
- const token_types_1 = require("./token-types");
7
- const token_constants_1 = require("./token-constants");
8
- const token_constants_2 = require("./token-constants");
9
- const token_singletons_1 = require("./token-singletons");
10
- var token_types_2 = require("./token-types");
11
- Object.defineProperty(exports, "FLAG_UNRESTRICTED", { enumerable: true, get: function () { return token_types_2.FLAG_UNRESTRICTED; } });
12
- Object.defineProperty(exports, "FLAG_ID", { enumerable: true, get: function () { return token_types_2.FLAG_ID; } });
13
- Object.defineProperty(exports, "FLAG_INTEGER", { enumerable: true, get: function () { return token_types_2.FLAG_INTEGER; } });
14
- Object.defineProperty(exports, "FLAG_NUMBER", { enumerable: true, get: function () { return token_types_2.FLAG_NUMBER; } });
15
- var token_constants_3 = require("./token-constants");
16
- Object.defineProperty(exports, "isDigit", { enumerable: true, get: function () { return token_constants_3.isDigit; } });
17
- Object.defineProperty(exports, "isHex", { enumerable: true, get: function () { return token_constants_3.isHex; } });
18
- Object.defineProperty(exports, "isWhiteSpace", { enumerable: true, get: function () { return token_constants_3.isWhiteSpace; } });
19
- Object.defineProperty(exports, "isNameCodePoint", { enumerable: true, get: function () { return token_constants_3.isNameCodePoint; } });
20
- Object.defineProperty(exports, "isValidEscape", { enumerable: true, get: function () { return token_constants_3.isValidEscape; } });
21
- Object.defineProperty(exports, "isIdentifierStart", { enumerable: true, get: function () { return token_constants_3.isIdentifierStart; } });
22
- Object.defineProperty(exports, "isNameStartCodePoint", { enumerable: true, get: function () { return token_constants_3.isNameStartCodePoint; } });
23
- Object.defineProperty(exports, "isNumberStart", { enumerable: true, get: function () { return token_constants_3.isNumberStart; } });
24
- var token_singletons_2 = require("./token-singletons");
25
- Object.defineProperty(exports, "COMMA_TOKEN", { enumerable: true, get: function () { return token_singletons_2.COMMA_TOKEN; } });
26
- Object.defineProperty(exports, "COLON_TOKEN", { enumerable: true, get: function () { return token_singletons_2.COLON_TOKEN; } });
27
- Object.defineProperty(exports, "SEMICOLON_TOKEN", { enumerable: true, get: function () { return token_singletons_2.SEMICOLON_TOKEN; } });
28
- Object.defineProperty(exports, "LEFT_PARENTHESIS_TOKEN", { enumerable: true, get: function () { return token_singletons_2.LEFT_PARENTHESIS_TOKEN; } });
29
- Object.defineProperty(exports, "RIGHT_PARENTHESIS_TOKEN", { enumerable: true, get: function () { return token_singletons_2.RIGHT_PARENTHESIS_TOKEN; } });
30
- Object.defineProperty(exports, "LEFT_CURLY_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.LEFT_CURLY_BRACKET_TOKEN; } });
31
- Object.defineProperty(exports, "RIGHT_CURLY_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.RIGHT_CURLY_BRACKET_TOKEN; } });
32
- Object.defineProperty(exports, "LEFT_SQUARE_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.LEFT_SQUARE_BRACKET_TOKEN; } });
33
- Object.defineProperty(exports, "RIGHT_SQUARE_BRACKET_TOKEN", { enumerable: true, get: function () { return token_singletons_2.RIGHT_SQUARE_BRACKET_TOKEN; } });
34
- Object.defineProperty(exports, "WHITESPACE_TOKEN", { enumerable: true, get: function () { return token_singletons_2.WHITESPACE_TOKEN; } });
35
- Object.defineProperty(exports, "EOF_TOKEN", { enumerable: true, get: function () { return token_singletons_2.EOF_TOKEN; } });
36
- Object.defineProperty(exports, "BAD_URL_TOKEN", { enumerable: true, get: function () { return token_singletons_2.BAD_URL_TOKEN; } });
37
- Object.defineProperty(exports, "BAD_STRING_TOKEN", { enumerable: true, get: function () { return token_singletons_2.BAD_STRING_TOKEN; } });
38
- Object.defineProperty(exports, "CDC_TOKEN", { enumerable: true, get: function () { return token_singletons_2.CDC_TOKEN; } });
39
- Object.defineProperty(exports, "CDO_TOKEN", { enumerable: true, get: function () { return token_singletons_2.CDO_TOKEN; } });
40
- Object.defineProperty(exports, "PREFIX_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.PREFIX_MATCH_TOKEN; } });
41
- Object.defineProperty(exports, "SUFFIX_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.SUFFIX_MATCH_TOKEN; } });
42
- Object.defineProperty(exports, "SUBSTRING_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.SUBSTRING_MATCH_TOKEN; } });
43
- Object.defineProperty(exports, "DASH_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.DASH_MATCH_TOKEN; } });
44
- Object.defineProperty(exports, "INCLUDE_MATCH_TOKEN", { enumerable: true, get: function () { return token_singletons_2.INCLUDE_MATCH_TOKEN; } });
45
- Object.defineProperty(exports, "COLUMN_TOKEN", { enumerable: true, get: function () { return token_singletons_2.COLUMN_TOKEN; } });
46
- class Tokenizer {
47
- static get() {
48
- return Tokenizer._pool.pop() || new Tokenizer();
49
- }
50
- static release(tokenizer) {
51
- if (Tokenizer._pool.length < Tokenizer.MAX_POOL_SIZE) {
52
- tokenizer._reset();
53
- Tokenizer._pool.push(tokenizer);
54
- }
55
- }
56
- constructor() {
57
- this._value = [];
58
- }
59
- _reset() {
60
- this._value = [];
61
- }
62
- write(chunk) {
63
- this._value = this._value.concat((0, css_line_break_1.toCodePoints)(chunk));
64
- }
65
- read() {
66
- const tokens = [];
67
- let token = this.consumeToken();
68
- while (token !== token_singletons_1.EOF_TOKEN) {
69
- tokens.push(token);
70
- token = this.consumeToken();
71
- }
72
- return tokens;
73
- }
74
- consumeToken() {
75
- const codePoint = this.consumeCodePoint();
76
- switch (codePoint) {
77
- case token_constants_1.QUOTATION_MARK:
78
- return this.consumeStringToken(token_constants_1.QUOTATION_MARK);
79
- case token_constants_1.NUMBER_SIGN: {
80
- const c1 = this.peekCodePoint(0);
81
- const c2 = this.peekCodePoint(1);
82
- const c3 = this.peekCodePoint(2);
83
- if ((0, token_constants_2.isNameCodePoint)(c1) || (0, token_constants_2.isValidEscape)(c2, c3)) {
84
- const flags = (0, token_constants_2.isIdentifierStart)(c1, c2, c3) ? token_types_1.FLAG_ID : token_types_1.FLAG_UNRESTRICTED;
85
- const value = this.consumeName();
86
- return { type: 5 /* TokenType.HASH_TOKEN */, value, flags };
87
- }
88
- break;
89
- }
90
- case token_constants_1.DOLLAR_SIGN:
91
- if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
92
- this.consumeCodePoint();
93
- return token_singletons_1.SUFFIX_MATCH_TOKEN;
94
- }
95
- break;
96
- case token_constants_1.APOSTROPHE:
97
- return this.consumeStringToken(token_constants_1.APOSTROPHE);
98
- case token_constants_1.LEFT_PARENTHESIS:
99
- return token_singletons_1.LEFT_PARENTHESIS_TOKEN;
100
- case token_constants_1.RIGHT_PARENTHESIS:
101
- return token_singletons_1.RIGHT_PARENTHESIS_TOKEN;
102
- case token_constants_1.ASTERISK:
103
- if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
104
- this.consumeCodePoint();
105
- return token_singletons_1.SUBSTRING_MATCH_TOKEN;
106
- }
107
- break;
108
- case token_constants_1.PLUS_SIGN:
109
- if ((0, token_constants_2.isNumberStart)(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
110
- this.reconsumeCodePoint(codePoint);
111
- return this.consumeNumericToken();
112
- }
113
- break;
114
- case token_constants_1.COMMA:
115
- return token_singletons_1.COMMA_TOKEN;
116
- case token_constants_1.HYPHEN_MINUS: {
117
- const e1 = codePoint;
118
- const e2 = this.peekCodePoint(0);
119
- const e3 = this.peekCodePoint(1);
120
- if ((0, token_constants_2.isNumberStart)(e1, e2, e3)) {
121
- this.reconsumeCodePoint(codePoint);
122
- return this.consumeNumericToken();
123
- }
124
- if ((0, token_constants_2.isIdentifierStart)(e1, e2, e3)) {
125
- this.reconsumeCodePoint(codePoint);
126
- return this.consumeIdentLikeToken();
127
- }
128
- if (e2 === token_constants_1.HYPHEN_MINUS && e3 === token_constants_1.GREATER_THAN_SIGN) {
129
- this.consumeCodePoint();
130
- this.consumeCodePoint();
131
- return token_singletons_1.CDC_TOKEN;
132
- }
133
- break;
134
- }
135
- case token_constants_1.FULL_STOP:
136
- if ((0, token_constants_2.isNumberStart)(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
137
- this.reconsumeCodePoint(codePoint);
138
- return this.consumeNumericToken();
139
- }
140
- break;
141
- case token_constants_1.SOLIDUS:
142
- if (this.peekCodePoint(0) === token_constants_1.ASTERISK) {
143
- this.consumeCodePoint();
144
- while (true) {
145
- let c = this.consumeCodePoint();
146
- if (c === token_constants_1.ASTERISK) {
147
- c = this.consumeCodePoint();
148
- if (c === token_constants_1.SOLIDUS) {
149
- return this.consumeToken();
150
- }
151
- }
152
- if (c === token_constants_1.EOF) {
153
- return this.consumeToken();
154
- }
155
- }
156
- }
157
- break;
158
- case token_constants_1.COLON:
159
- return token_singletons_1.COLON_TOKEN;
160
- case token_constants_1.SEMICOLON:
161
- return token_singletons_1.SEMICOLON_TOKEN;
162
- case token_constants_1.LESS_THAN_SIGN:
163
- if (this.peekCodePoint(0) === token_constants_1.EXCLAMATION_MARK &&
164
- this.peekCodePoint(1) === token_constants_1.HYPHEN_MINUS &&
165
- this.peekCodePoint(2) === token_constants_1.HYPHEN_MINUS) {
166
- this.consumeCodePoint();
167
- this.consumeCodePoint();
168
- return token_singletons_1.CDO_TOKEN;
169
- }
170
- break;
171
- case token_constants_1.COMMERCIAL_AT: {
172
- const a1 = this.peekCodePoint(0);
173
- const a2 = this.peekCodePoint(1);
174
- const a3 = this.peekCodePoint(2);
175
- if ((0, token_constants_2.isIdentifierStart)(a1, a2, a3)) {
176
- const value = this.consumeName();
177
- return { type: 7 /* TokenType.AT_KEYWORD_TOKEN */, value };
178
- }
179
- break;
180
- }
181
- case token_constants_1.LEFT_SQUARE_BRACKET:
182
- return token_singletons_1.LEFT_SQUARE_BRACKET_TOKEN;
183
- case token_constants_1.REVERSE_SOLIDUS:
184
- if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
185
- this.reconsumeCodePoint(codePoint);
186
- return this.consumeIdentLikeToken();
187
- }
188
- break;
189
- case token_constants_1.RIGHT_SQUARE_BRACKET:
190
- return token_singletons_1.RIGHT_SQUARE_BRACKET_TOKEN;
191
- case token_constants_1.CIRCUMFLEX_ACCENT:
192
- if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
193
- this.consumeCodePoint();
194
- return token_singletons_1.PREFIX_MATCH_TOKEN;
195
- }
196
- break;
197
- case token_constants_1.LEFT_CURLY_BRACKET:
198
- return token_singletons_1.LEFT_CURLY_BRACKET_TOKEN;
199
- case token_constants_1.RIGHT_CURLY_BRACKET:
200
- return token_singletons_1.RIGHT_CURLY_BRACKET_TOKEN;
201
- case token_constants_1.u:
202
- case token_constants_1.U: {
203
- const u1 = this.peekCodePoint(0);
204
- const u2 = this.peekCodePoint(1);
205
- if (u1 === token_constants_1.PLUS_SIGN && ((0, token_constants_2.isHex)(u2) || u2 === token_constants_1.QUESTION_MARK)) {
206
- this.consumeCodePoint();
207
- this.consumeUnicodeRangeToken();
208
- }
209
- this.reconsumeCodePoint(codePoint);
210
- return this.consumeIdentLikeToken();
211
- }
212
- case token_constants_1.VERTICAL_LINE:
213
- if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
214
- this.consumeCodePoint();
215
- return token_singletons_1.DASH_MATCH_TOKEN;
216
- }
217
- if (this.peekCodePoint(0) === token_constants_1.VERTICAL_LINE) {
218
- this.consumeCodePoint();
219
- return token_singletons_1.COLUMN_TOKEN;
220
- }
221
- break;
222
- case token_constants_1.TILDE:
223
- if (this.peekCodePoint(0) === token_constants_1.EQUALS_SIGN) {
224
- this.consumeCodePoint();
225
- return token_singletons_1.INCLUDE_MATCH_TOKEN;
226
- }
227
- break;
228
- case token_constants_1.EOF:
229
- return token_singletons_1.EOF_TOKEN;
230
- }
231
- if ((0, token_constants_2.isWhiteSpace)(codePoint)) {
232
- this.consumeWhiteSpace();
233
- return token_singletons_1.WHITESPACE_TOKEN;
234
- }
235
- if ((0, token_constants_2.isDigit)(codePoint)) {
236
- this.reconsumeCodePoint(codePoint);
237
- return this.consumeNumericToken();
238
- }
239
- if ((0, token_constants_2.isNameStartCodePoint)(codePoint)) {
240
- this.reconsumeCodePoint(codePoint);
241
- return this.consumeIdentLikeToken();
242
- }
243
- return { type: 6 /* TokenType.DELIM_TOKEN */, value: (0, css_line_break_1.fromCodePoint)(codePoint) };
244
- }
245
- consumeCodePoint() {
246
- const value = this._value.shift();
247
- return typeof value === 'undefined' ? -1 : value;
248
- }
249
- reconsumeCodePoint(codePoint) {
250
- this._value.unshift(codePoint);
251
- }
252
- peekCodePoint(delta) {
253
- if (delta >= this._value.length) {
254
- return -1;
255
- }
256
- return this._value[delta];
257
- }
258
- consumeUnicodeRangeToken() {
259
- const digits = [];
260
- let codePoint = this.consumeCodePoint();
261
- while ((0, token_constants_2.isHex)(codePoint) && digits.length < 6) {
262
- digits.push(codePoint);
263
- codePoint = this.consumeCodePoint();
264
- }
265
- let questionMarks = false;
266
- while (codePoint === token_constants_1.QUESTION_MARK && digits.length < 6) {
267
- digits.push(codePoint);
268
- codePoint = this.consumeCodePoint();
269
- questionMarks = true;
270
- }
271
- if (questionMarks) {
272
- const start = parseInt((0, css_line_break_1.fromCodePoint)(...digits.map((digit) => (digit === token_constants_1.QUESTION_MARK ? token_constants_1.ZERO : digit))), 16);
273
- const end = parseInt((0, css_line_break_1.fromCodePoint)(...digits.map((digit) => (digit === token_constants_1.QUESTION_MARK ? token_constants_1.F : digit))), 16);
274
- return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start, end };
275
- }
276
- const start = parseInt((0, css_line_break_1.fromCodePoint)(...digits), 16);
277
- if (this.peekCodePoint(0) === token_constants_1.HYPHEN_MINUS && (0, token_constants_2.isHex)(this.peekCodePoint(1))) {
278
- this.consumeCodePoint();
279
- codePoint = this.consumeCodePoint();
280
- const endDigits = [];
281
- while ((0, token_constants_2.isHex)(codePoint) && endDigits.length < 6) {
282
- endDigits.push(codePoint);
283
- codePoint = this.consumeCodePoint();
284
- }
285
- const end = parseInt((0, css_line_break_1.fromCodePoint)(...endDigits), 16);
286
- return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start, end };
287
- }
288
- else {
289
- return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start, end: start };
290
- }
291
- }
292
- consumeIdentLikeToken() {
293
- const value = this.consumeName();
294
- if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === token_constants_1.LEFT_PARENTHESIS) {
295
- this.consumeCodePoint();
296
- return this.consumeUrlToken();
297
- }
298
- else if (this.peekCodePoint(0) === token_constants_1.LEFT_PARENTHESIS) {
299
- this.consumeCodePoint();
300
- return { type: 19 /* TokenType.FUNCTION_TOKEN */, value };
301
- }
302
- return { type: 20 /* TokenType.IDENT_TOKEN */, value };
303
- }
304
- consumeUrlToken() {
305
- const value = [];
306
- this.consumeWhiteSpace();
307
- if (this.peekCodePoint(0) === token_constants_1.EOF) {
308
- return { type: 22 /* TokenType.URL_TOKEN */, value: '' };
309
- }
310
- const next = this.peekCodePoint(0);
311
- if (next === token_constants_1.APOSTROPHE || next === token_constants_1.QUOTATION_MARK) {
312
- const stringToken = this.consumeStringToken(this.consumeCodePoint());
313
- if (stringToken.type === 0 /* TokenType.STRING_TOKEN */) {
314
- this.consumeWhiteSpace();
315
- if (this.peekCodePoint(0) === token_constants_1.EOF || this.peekCodePoint(0) === token_constants_1.RIGHT_PARENTHESIS) {
316
- this.consumeCodePoint();
317
- return { type: 22 /* TokenType.URL_TOKEN */, value: stringToken.value };
318
- }
319
- }
320
- this.consumeBadUrlRemnants();
321
- return token_singletons_1.BAD_URL_TOKEN;
322
- }
323
- while (true) {
324
- const codePoint = this.consumeCodePoint();
325
- if (codePoint === token_constants_1.EOF || codePoint === token_constants_1.RIGHT_PARENTHESIS) {
326
- return { type: 22 /* TokenType.URL_TOKEN */, value: (0, css_line_break_1.fromCodePoint)(...value) };
327
- }
328
- else if ((0, token_constants_2.isWhiteSpace)(codePoint)) {
329
- this.consumeWhiteSpace();
330
- if (this.peekCodePoint(0) === token_constants_1.EOF || this.peekCodePoint(0) === token_constants_1.RIGHT_PARENTHESIS) {
331
- this.consumeCodePoint();
332
- return { type: 22 /* TokenType.URL_TOKEN */, value: (0, css_line_break_1.fromCodePoint)(...value) };
333
- }
334
- this.consumeBadUrlRemnants();
335
- return token_singletons_1.BAD_URL_TOKEN;
336
- }
337
- else if (codePoint === token_constants_1.QUOTATION_MARK ||
338
- codePoint === token_constants_1.APOSTROPHE ||
339
- codePoint === token_constants_1.LEFT_PARENTHESIS ||
340
- (0, token_constants_2.isNonPrintableCodePoint)(codePoint)) {
341
- this.consumeBadUrlRemnants();
342
- return token_singletons_1.BAD_URL_TOKEN;
343
- }
344
- else if (codePoint === token_constants_1.REVERSE_SOLIDUS) {
345
- if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
346
- value.push(this.consumeEscapedCodePoint());
347
- }
348
- else {
349
- this.consumeBadUrlRemnants();
350
- return token_singletons_1.BAD_URL_TOKEN;
351
- }
352
- }
353
- else {
354
- value.push(codePoint);
355
- }
356
- }
357
- }
358
- consumeWhiteSpace() {
359
- while ((0, token_constants_2.isWhiteSpace)(this.peekCodePoint(0))) {
360
- this.consumeCodePoint();
361
- }
362
- }
363
- consumeBadUrlRemnants() {
364
- while (true) {
365
- const codePoint = this.consumeCodePoint();
366
- if (codePoint === token_constants_1.RIGHT_PARENTHESIS || codePoint === token_constants_1.EOF) {
367
- return;
368
- }
369
- if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
370
- this.consumeEscapedCodePoint();
371
- }
372
- }
373
- }
374
- consumeStringSlice(count) {
375
- const SLICE_STACK_SIZE = 50000;
376
- let value = '';
377
- while (count > 0) {
378
- const amount = Math.min(SLICE_STACK_SIZE, count);
379
- value += (0, css_line_break_1.fromCodePoint)(...this._value.splice(0, amount));
380
- count -= amount;
381
- }
382
- this._value.shift();
383
- return value;
384
- }
385
- consumeStringToken(endingCodePoint) {
386
- let value = '';
387
- let i = 0;
388
- do {
389
- const codePoint = this._value[i];
390
- if (codePoint === token_constants_1.EOF || codePoint === undefined || codePoint === endingCodePoint) {
391
- value += this.consumeStringSlice(i);
392
- return { type: 0 /* TokenType.STRING_TOKEN */, value };
393
- }
394
- if (codePoint === token_constants_1.LINE_FEED) {
395
- this._value.splice(0, i);
396
- return token_singletons_1.BAD_STRING_TOKEN;
397
- }
398
- if (codePoint === token_constants_1.REVERSE_SOLIDUS) {
399
- const next = this._value[i + 1];
400
- if (next !== token_constants_1.EOF && next !== undefined) {
401
- if (next === token_constants_1.LINE_FEED) {
402
- value += this.consumeStringSlice(i);
403
- i = -1;
404
- this._value.shift();
405
- }
406
- else if ((0, token_constants_2.isValidEscape)(codePoint, next)) {
407
- value += this.consumeStringSlice(i);
408
- value += (0, css_line_break_1.fromCodePoint)(this.consumeEscapedCodePoint());
409
- i = -1;
410
- }
411
- }
412
- }
413
- i++;
414
- } while (true);
415
- }
416
- consumeNumber() {
417
- const repr = [];
418
- let type = token_types_1.FLAG_INTEGER;
419
- let c1 = this.peekCodePoint(0);
420
- if (c1 === token_constants_1.PLUS_SIGN || c1 === token_constants_1.HYPHEN_MINUS) {
421
- repr.push(this.consumeCodePoint());
422
- }
423
- while ((0, token_constants_2.isDigit)(this.peekCodePoint(0))) {
424
- repr.push(this.consumeCodePoint());
425
- }
426
- c1 = this.peekCodePoint(0);
427
- let c2 = this.peekCodePoint(1);
428
- if (c1 === token_constants_1.FULL_STOP && (0, token_constants_2.isDigit)(c2)) {
429
- repr.push(this.consumeCodePoint(), this.consumeCodePoint());
430
- type = token_types_1.FLAG_NUMBER;
431
- while ((0, token_constants_2.isDigit)(this.peekCodePoint(0))) {
432
- repr.push(this.consumeCodePoint());
433
- }
434
- }
435
- c1 = this.peekCodePoint(0);
436
- c2 = this.peekCodePoint(1);
437
- const c3 = this.peekCodePoint(2);
438
- if ((c1 === token_constants_1.E || c1 === token_constants_1.e) && (((c2 === token_constants_1.PLUS_SIGN || c2 === token_constants_1.HYPHEN_MINUS) && (0, token_constants_2.isDigit)(c3)) || (0, token_constants_2.isDigit)(c2))) {
439
- repr.push(this.consumeCodePoint(), this.consumeCodePoint());
440
- type = token_types_1.FLAG_NUMBER;
441
- while ((0, token_constants_2.isDigit)(this.peekCodePoint(0))) {
442
- repr.push(this.consumeCodePoint());
443
- }
444
- }
445
- return [(0, token_constants_2.stringToNumber)(repr), type];
446
- }
447
- consumeNumericToken() {
448
- const [number, flags] = this.consumeNumber();
449
- const c1 = this.peekCodePoint(0);
450
- const c2 = this.peekCodePoint(1);
451
- const c3 = this.peekCodePoint(2);
452
- if ((0, token_constants_2.isIdentifierStart)(c1, c2, c3)) {
453
- const unit = this.consumeName();
454
- return { type: 15 /* TokenType.DIMENSION_TOKEN */, number, flags, unit };
455
- }
456
- if (c1 === token_constants_1.PERCENTAGE_SIGN) {
457
- this.consumeCodePoint();
458
- return { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number, flags };
459
- }
460
- return { type: 17 /* TokenType.NUMBER_TOKEN */, number, flags };
461
- }
462
- consumeEscapedCodePoint() {
463
- const codePoint = this.consumeCodePoint();
464
- if ((0, token_constants_2.isHex)(codePoint)) {
465
- let hex = (0, css_line_break_1.fromCodePoint)(codePoint);
466
- while ((0, token_constants_2.isHex)(this.peekCodePoint(0)) && hex.length < 6) {
467
- hex += (0, css_line_break_1.fromCodePoint)(this.consumeCodePoint());
468
- }
469
- if ((0, token_constants_2.isWhiteSpace)(this.peekCodePoint(0))) {
470
- this.consumeCodePoint();
471
- }
472
- const hexCodePoint = parseInt(hex, 16);
473
- if (hexCodePoint === 0 || (0, token_constants_2.isSurrogateCodePoint)(hexCodePoint) || hexCodePoint > 0x10ffff) {
474
- return token_constants_1.REPLACEMENT_CHARACTER;
475
- }
476
- return hexCodePoint;
477
- }
478
- if (codePoint === token_constants_1.EOF) {
479
- return token_constants_1.REPLACEMENT_CHARACTER;
480
- }
481
- return codePoint;
482
- }
483
- consumeName() {
484
- let result = '';
485
- while (true) {
486
- const codePoint = this.consumeCodePoint();
487
- if ((0, token_constants_2.isNameCodePoint)(codePoint)) {
488
- result += (0, css_line_break_1.fromCodePoint)(codePoint);
489
- }
490
- else if ((0, token_constants_2.isValidEscape)(codePoint, this.peekCodePoint(0))) {
491
- result += (0, css_line_break_1.fromCodePoint)(this.consumeEscapedCodePoint());
492
- }
493
- else {
494
- this.reconsumeCodePoint(codePoint);
495
- return result;
496
- }
497
- }
498
- }
499
- }
500
- exports.Tokenizer = Tokenizer;
501
- Tokenizer._pool = [];
502
- Tokenizer.MAX_POOL_SIZE = 40;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deg = exports.parseNamedSide = exports.isAngle = exports.angle = void 0;
4
- const parser_1 = require("../syntax/parser");
5
- const length_percentage_1 = require("./length-percentage");
6
- const DEG = 'deg';
7
- const GRAD = 'grad';
8
- const RAD = 'rad';
9
- const TURN = 'turn';
10
- exports.angle = {
11
- name: 'angle',
12
- parse: (_context, value) => {
13
- if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
14
- switch (value.unit) {
15
- case DEG:
16
- return (Math.PI * value.number) / 180;
17
- case GRAD:
18
- return (Math.PI / 200) * value.number;
19
- case RAD:
20
- return value.number;
21
- case TURN:
22
- return Math.PI * 2 * value.number;
23
- }
24
- }
25
- throw new Error(`Unsupported angle type`);
26
- }
27
- };
28
- const isAngle = (value) => {
29
- if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
30
- if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {
31
- return true;
32
- }
33
- }
34
- return false;
35
- };
36
- exports.isAngle = isAngle;
37
- const parseNamedSide = (tokens) => {
38
- const sideOrCorner = tokens
39
- .filter(parser_1.isIdentToken)
40
- .map((ident) => ident.value)
41
- .join(' ');
42
- switch (sideOrCorner) {
43
- case 'to bottom right':
44
- case 'to right bottom':
45
- case 'left top':
46
- case 'top left':
47
- return [length_percentage_1.ZERO_LENGTH, length_percentage_1.ZERO_LENGTH];
48
- case 'to top':
49
- case 'bottom':
50
- return (0, exports.deg)(0);
51
- case 'to bottom left':
52
- case 'to left bottom':
53
- case 'right top':
54
- case 'top right':
55
- return [length_percentage_1.ZERO_LENGTH, length_percentage_1.HUNDRED_PERCENT];
56
- case 'to right':
57
- case 'left':
58
- return (0, exports.deg)(90);
59
- case 'to top left':
60
- case 'to left top':
61
- case 'right bottom':
62
- case 'bottom right':
63
- return [length_percentage_1.HUNDRED_PERCENT, length_percentage_1.HUNDRED_PERCENT];
64
- case 'to bottom':
65
- case 'top':
66
- return (0, exports.deg)(180);
67
- case 'to top right':
68
- case 'to right top':
69
- case 'left bottom':
70
- case 'bottom left':
71
- return [length_percentage_1.HUNDRED_PERCENT, length_percentage_1.ZERO_LENGTH];
72
- case 'to left':
73
- case 'right':
74
- return (0, exports.deg)(270);
75
- }
76
- return 0;
77
- };
78
- exports.parseNamedSide = parseNamedSide;
79
- const deg = (deg) => (Math.PI * deg) / 180;
80
- exports.deg = deg;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- * Color mathematics utilities
4
- * Extracted to break circular dependency between srgb.ts and color-utilities.ts
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.multiplyMatrices = exports.clamp = void 0;
8
- /**
9
- * Clamp a value between min and max
10
- */
11
- const clamp = (value, min, max) => {
12
- return Math.min(Math.max(value, min), max);
13
- };
14
- exports.clamp = clamp;
15
- /**
16
- * Multiply two 3x3 matrices
17
- */
18
- const multiplyMatrices = (A, B) => {
19
- return [
20
- A[0] * B[0] + A[1] * B[1] + A[2] * B[2],
21
- A[3] * B[0] + A[4] * B[1] + A[5] * B[2],
22
- A[6] * B[0] + A[7] * B[1] + A[8] * B[2]
23
- ];
24
- };
25
- exports.multiplyMatrices = multiplyMatrices;