@tbela99/css-parser 1.4.2 → 1.4.3

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 (216) hide show
  1. package/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
  2. package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
  3. package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
  4. package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
  5. package/.repl_history +4 -0
  6. package/CHANGELOG.md +164 -4
  7. package/README.md +43 -0
  8. package/badges/coverage.svg +20 -0
  9. package/deno.lock +2861 -0
  10. package/dist/config.json.js +33 -1
  11. package/dist/index-umd-web.js +24382 -18476
  12. package/dist/index.cjs +24522 -18618
  13. package/dist/index.d.ts +1396 -929
  14. package/dist/lib/ast/clone.d.ts +10 -0
  15. package/dist/lib/ast/clone.js +45 -0
  16. package/dist/lib/ast/expand.d.ts +14 -0
  17. package/dist/lib/ast/expand.js +89 -64
  18. package/dist/lib/ast/features/calc.d.ts +10 -0
  19. package/dist/lib/ast/features/calc.js +62 -24
  20. package/dist/lib/ast/features/if.d.ts +10 -0
  21. package/dist/lib/ast/features/if.js +215 -0
  22. package/dist/lib/ast/features/index.d.ts +6 -0
  23. package/dist/lib/ast/features/index.js +1 -0
  24. package/dist/lib/ast/features/inlinecssvariables.d.ts +15 -0
  25. package/dist/lib/ast/features/inlinecssvariables.js +32 -27
  26. package/dist/lib/ast/features/prefix.d.ts +8 -0
  27. package/dist/lib/ast/features/prefix.js +68 -43
  28. package/dist/lib/ast/features/shorthand.d.ts +12 -0
  29. package/dist/lib/ast/features/shorthand.js +6 -9
  30. package/dist/lib/ast/features/transform.d.ts +10 -0
  31. package/dist/lib/ast/features/transform.js +9 -13
  32. package/dist/lib/ast/features/type.d.ts +15 -0
  33. package/dist/lib/ast/find.d.ts +165 -0
  34. package/dist/lib/ast/find.js +175 -0
  35. package/dist/lib/ast/math/expression.d.ts +18 -0
  36. package/dist/lib/ast/math/expression.js +140 -98
  37. package/dist/lib/ast/math/math.d.ts +6 -0
  38. package/dist/lib/ast/math/math.js +30 -41
  39. package/dist/lib/ast/minify.d.ts +19 -0
  40. package/dist/lib/ast/minify.js +541 -217
  41. package/dist/lib/ast/transform/compute.d.ts +8 -0
  42. package/dist/lib/ast/transform/compute.js +82 -69
  43. package/dist/lib/ast/transform/matrix.d.ts +22 -0
  44. package/dist/lib/ast/transform/matrix.js +12 -26
  45. package/dist/lib/ast/transform/minify.d.ts +5 -0
  46. package/dist/lib/ast/transform/minify.js +20 -20
  47. package/dist/lib/ast/transform/perspective.d.ts +3 -0
  48. package/dist/lib/ast/transform/perspective.js +1 -1
  49. package/dist/lib/ast/transform/rotate.d.ts +12 -0
  50. package/dist/lib/ast/transform/rotate.js +1 -1
  51. package/dist/lib/ast/transform/scale.d.ts +6 -0
  52. package/dist/lib/ast/transform/scale.js +1 -1
  53. package/dist/lib/ast/transform/skew.d.ts +4 -0
  54. package/dist/lib/ast/transform/skew.js +1 -1
  55. package/dist/lib/ast/transform/translate.d.ts +6 -0
  56. package/dist/lib/ast/transform/translate.js +1 -1
  57. package/dist/lib/ast/transform/utils.d.ts +9 -0
  58. package/dist/lib/ast/types.d.ts +903 -0
  59. package/dist/lib/ast/types.js +277 -23
  60. package/dist/lib/ast/walk.d.ts +162 -0
  61. package/dist/lib/ast/walk.js +116 -60
  62. package/dist/lib/fs/resolve.d.ts +20 -0
  63. package/dist/lib/fs/resolve.js +37 -45
  64. package/dist/lib/parser/declaration/list.d.ts +16 -0
  65. package/dist/lib/parser/declaration/list.js +26 -24
  66. package/dist/lib/parser/declaration/map.d.ts +15 -0
  67. package/dist/lib/parser/declaration/map.js +140 -95
  68. package/dist/lib/parser/declaration/set.d.ts +9 -0
  69. package/dist/lib/parser/declaration/set.js +30 -25
  70. package/dist/lib/parser/node.d.ts +7 -0
  71. package/dist/lib/parser/parse.d.ts +107 -0
  72. package/dist/lib/parser/parse.js +1454 -1445
  73. package/dist/lib/parser/tokenize.d.ts +57 -0
  74. package/dist/lib/parser/tokenize.js +557 -404
  75. package/dist/lib/parser/utils/at-rule-container.d.ts +5 -0
  76. package/dist/lib/parser/utils/at-rule-container.js +486 -0
  77. package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +5 -0
  78. package/dist/lib/parser/utils/at-rule-font-feature-values.js +13 -0
  79. package/dist/lib/parser/utils/at-rule-generic.d.ts +5 -0
  80. package/dist/lib/parser/utils/at-rule-generic.js +118 -0
  81. package/dist/lib/parser/utils/at-rule-import.d.ts +5 -0
  82. package/dist/lib/parser/utils/at-rule-import.js +393 -0
  83. package/dist/lib/parser/utils/at-rule-media.d.ts +5 -0
  84. package/dist/lib/parser/utils/at-rule-media.js +603 -0
  85. package/dist/lib/parser/utils/at-rule-page.d.ts +5 -0
  86. package/dist/lib/parser/utils/at-rule-page.js +28 -0
  87. package/dist/lib/parser/utils/at-rule-support.d.ts +5 -0
  88. package/dist/lib/parser/utils/at-rule-support.js +366 -0
  89. package/dist/lib/parser/utils/at-rule-token.d.ts +1 -0
  90. package/dist/lib/parser/utils/at-rule-when-else.d.ts +5 -0
  91. package/dist/lib/parser/utils/at-rule-when-else.js +363 -0
  92. package/dist/lib/parser/utils/at-rule.d.ts +13 -0
  93. package/dist/lib/parser/utils/at-rule.js +37 -0
  94. package/dist/lib/parser/utils/cache.d.ts +6 -0
  95. package/dist/lib/parser/utils/cache.js +19 -0
  96. package/dist/lib/parser/utils/config.d.ts +2 -0
  97. package/dist/lib/parser/utils/config.js +1 -0
  98. package/dist/lib/parser/utils/declaration-list.d.ts +5 -0
  99. package/dist/lib/parser/utils/declaration.d.ts +18 -0
  100. package/dist/lib/parser/utils/declaration.js +569 -91
  101. package/dist/lib/parser/utils/eq.d.ts +1 -0
  102. package/dist/lib/parser/utils/hash.d.ts +21 -0
  103. package/dist/lib/parser/utils/hash.js +1 -1
  104. package/dist/lib/parser/utils/selector.d.ts +5 -0
  105. package/dist/lib/parser/utils/selector.js +476 -0
  106. package/dist/lib/parser/utils/text.d.ts +3 -0
  107. package/dist/lib/parser/utils/text.js +17 -1
  108. package/dist/lib/parser/utils/token.d.ts +14 -0
  109. package/dist/lib/parser/utils/token.js +102 -0
  110. package/dist/lib/parser/utils/type.d.ts +2 -0
  111. package/dist/lib/parser/utils/type.js +29 -18
  112. package/dist/lib/renderer/render.d.ts +28 -0
  113. package/dist/lib/renderer/render.js +421 -262
  114. package/dist/lib/renderer/sourcemap/lib/encode.d.ts +1 -0
  115. package/dist/lib/renderer/sourcemap/sourcemap.d.ts +26 -0
  116. package/dist/lib/renderer/sourcemap/sourcemap.js +17 -7
  117. package/dist/lib/syntax/color/a98rgb.d.ts +2 -0
  118. package/dist/lib/syntax/color/a98rgb.js +8 -12
  119. package/dist/lib/syntax/color/cmyk.d.ts +10 -0
  120. package/dist/lib/syntax/color/cmyk.js +23 -21
  121. package/dist/lib/syntax/color/color-mix.d.ts +2 -0
  122. package/dist/lib/syntax/color/color-mix.js +88 -77
  123. package/dist/lib/syntax/color/color.d.ts +42 -0
  124. package/dist/lib/syntax/color/color.js +65 -68
  125. package/dist/lib/syntax/color/hex.d.ts +16 -0
  126. package/dist/lib/syntax/color/hex.js +27 -31
  127. package/dist/lib/syntax/color/hsl.d.ts +20 -0
  128. package/dist/lib/syntax/color/hsl.js +5 -12
  129. package/dist/lib/syntax/color/hsv.d.ts +2 -0
  130. package/dist/lib/syntax/color/hwb.d.ts +21 -0
  131. package/dist/lib/syntax/color/hwb.js +8 -21
  132. package/dist/lib/syntax/color/lab.d.ts +25 -0
  133. package/dist/lib/syntax/color/lab.js +20 -21
  134. package/dist/lib/syntax/color/lch.d.ts +23 -0
  135. package/dist/lib/syntax/color/lch.js +13 -15
  136. package/dist/lib/syntax/color/oklab.d.ts +22 -0
  137. package/dist/lib/syntax/color/oklab.js +20 -39
  138. package/dist/lib/syntax/color/oklch.d.ts +20 -0
  139. package/dist/lib/syntax/color/oklch.js +14 -16
  140. package/dist/lib/syntax/color/p3.d.ts +6 -0
  141. package/dist/lib/syntax/color/p3.js +0 -8
  142. package/dist/lib/syntax/color/prophotorgb.d.ts +2 -0
  143. package/dist/lib/syntax/color/rec2020.d.ts +2 -0
  144. package/dist/lib/syntax/color/rec2020.js +9 -13
  145. package/dist/lib/syntax/color/relativecolor.d.ts +13 -0
  146. package/dist/lib/syntax/color/relativecolor.js +68 -41
  147. package/dist/lib/syntax/color/rgb.d.ts +20 -0
  148. package/dist/lib/syntax/color/rgb.js +14 -18
  149. package/dist/lib/syntax/color/srgb.d.ts +23 -0
  150. package/dist/lib/syntax/color/srgb.js +27 -26
  151. package/dist/lib/syntax/color/utils/components.d.ts +2 -0
  152. package/dist/lib/syntax/color/utils/components.js +30 -14
  153. package/dist/lib/syntax/color/utils/distance.d.ts +18 -0
  154. package/dist/lib/syntax/color/utils/distance.js +1 -8
  155. package/dist/lib/syntax/color/utils/matrix.d.ts +6 -0
  156. package/dist/lib/syntax/color/xyz.d.ts +5 -0
  157. package/dist/lib/syntax/color/xyz.js +8 -20
  158. package/dist/lib/syntax/color/xyzd50.d.ts +4 -0
  159. package/dist/lib/syntax/color/xyzd50.js +6 -20
  160. package/dist/lib/syntax/constants.d.ts +67 -0
  161. package/dist/lib/syntax/constants.js +436 -0
  162. package/dist/lib/syntax/syntax.d.ts +38 -0
  163. package/dist/lib/syntax/syntax.js +533 -568
  164. package/dist/lib/validation/config.d.ts +14 -0
  165. package/dist/lib/validation/config.js +72 -33
  166. package/dist/lib/validation/config.json.js +1159 -74
  167. package/dist/lib/validation/json.d.ts +2 -0
  168. package/dist/lib/validation/match.d.ts +38 -0
  169. package/dist/lib/validation/match.js +2985 -0
  170. package/dist/lib/validation/parser/parse.d.ts +8 -0
  171. package/dist/lib/validation/parser/parse.js +684 -935
  172. package/dist/lib/validation/parser/typedef.d.ts +95 -0
  173. package/dist/lib/validation/parser/typedef.js +100 -0
  174. package/dist/lib/validation/utils/list.d.ts +4 -0
  175. package/dist/lib/validation/utils/list.js +4 -11
  176. package/dist/lib/validation/utils/whitespace.d.ts +2 -0
  177. package/dist/lib/validation/utils/whitespace.js +2 -8
  178. package/dist/node.d.ts +207 -0
  179. package/dist/node.js +42 -39
  180. package/dist/web.d.ts +169 -0
  181. package/dist/web.js +38 -33
  182. package/package.json +15 -12
  183. package/playground/index.html +1328 -0
  184. package/playground/sw.js +55 -0
  185. package/playground/tree.js +176 -0
  186. package/dist/lib/syntax/color/utils/constants.js +0 -214
  187. package/dist/lib/syntax/utils.js +0 -70
  188. package/dist/lib/validation/at-rules/container.js +0 -342
  189. package/dist/lib/validation/at-rules/counter-style.js +0 -90
  190. package/dist/lib/validation/at-rules/custom-media.js +0 -50
  191. package/dist/lib/validation/at-rules/document.js +0 -89
  192. package/dist/lib/validation/at-rules/else.js +0 -5
  193. package/dist/lib/validation/at-rules/font-feature-values.js +0 -63
  194. package/dist/lib/validation/at-rules/import.js +0 -150
  195. package/dist/lib/validation/at-rules/keyframes.js +0 -67
  196. package/dist/lib/validation/at-rules/layer.js +0 -41
  197. package/dist/lib/validation/at-rules/media.js +0 -255
  198. package/dist/lib/validation/at-rules/namespace.js +0 -81
  199. package/dist/lib/validation/at-rules/page-margin-box.js +0 -64
  200. package/dist/lib/validation/at-rules/page.js +0 -100
  201. package/dist/lib/validation/at-rules/supports.js +0 -295
  202. package/dist/lib/validation/at-rules/when.js +0 -185
  203. package/dist/lib/validation/atrule.js +0 -184
  204. package/dist/lib/validation/selector.js +0 -36
  205. package/dist/lib/validation/syntax.js +0 -1073
  206. package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -27
  207. package/dist/lib/validation/syntaxes/complex-selector.js +0 -52
  208. package/dist/lib/validation/syntaxes/compound-selector.js +0 -196
  209. package/dist/lib/validation/syntaxes/family-name.js +0 -57
  210. package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -36
  211. package/dist/lib/validation/syntaxes/layer-name.js +0 -57
  212. package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -31
  213. package/dist/lib/validation/syntaxes/relative-selector.js +0 -38
  214. package/dist/lib/validation/syntaxes/selector-list.js +0 -5
  215. package/dist/lib/validation/syntaxes/selector.js +0 -5
  216. package/dist/lib/validation/syntaxes/url.js +0 -40
@@ -1,546 +1,324 @@
1
1
  import { EnumToken, ColorType } from '../ast/types.js';
2
- import '../ast/minify.js';
3
2
  import { walkValues, WalkerOptionEnum } from '../ast/walk.js';
4
- import '../parser/parse.js';
5
- import '../parser/tokenize.js';
6
- import '../parser/utils/config.js';
7
- import { COLORS_NAMES, colorsFunc, funcLike } from './color/utils/constants.js';
8
- import { buildExpression } from '../ast/math/expression.js';
9
- import '../renderer/sourcemap/lib/encode.js';
3
+ import { equalsIgnoreCase } from '../parser/utils/text.js';
4
+ import { colorsFunc, systemColors, deprecatedSystemColors, nonStandardColors, COLORS_NAMES, mathFuncs } from './constants.js';
10
5
 
11
6
  // https://www.w3.org/TR/CSS21/syndata.html#syntax
12
7
  // https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-ident-token
13
8
  // '\\'
14
9
  const REVERSE_SOLIDUS = 0x5c;
15
10
  const dimensionUnits = new Set([
16
- 'q', 'cap', 'ch', 'cm', 'cqb', 'cqh', 'cqi', 'cqmax', 'cqmin', 'cqw', 'dvb',
17
- 'dvh', 'dvi', 'dvmax', 'dvmin', 'dvw', 'em', 'ex', 'ic', 'in', 'lh', 'lvb',
18
- 'lvh', 'lvi', 'lvmax', 'lvw', 'mm', 'pc', 'pt', 'px', 'rem', 'rlh', 'svb',
19
- 'svh', 'svi', 'svmin', 'svw', 'vb', 'vh', 'vi', 'vmax', 'vmin', 'vw'
11
+ "q",
12
+ "cap",
13
+ "ch",
14
+ "cm",
15
+ "cqb",
16
+ "cqh",
17
+ "cqi",
18
+ "cqmax",
19
+ "cqmin",
20
+ "cqw",
21
+ "dvb",
22
+ "dvh",
23
+ "dvi",
24
+ "dvmax",
25
+ "dvmin",
26
+ "dvw",
27
+ "em",
28
+ "ex",
29
+ "ic",
30
+ "in",
31
+ "lh",
32
+ "lvb",
33
+ "lvh",
34
+ "lvi",
35
+ "lvmax",
36
+ "lvw",
37
+ "mm",
38
+ "pc",
39
+ "pt",
40
+ "px",
41
+ "rem",
42
+ "rlh",
43
+ "svb",
44
+ "svh",
45
+ "svi",
46
+ "svmin",
47
+ "svw",
48
+ "vb",
49
+ "vh",
50
+ "vi",
51
+ "vmax",
52
+ "vmin",
53
+ "vw",
20
54
  ]);
21
- const fontFormat = ['collection', 'embedded-opentype', 'opentype', 'svg', 'truetype', 'woff', 'woff2'];
22
- const colorFontTech = ['color-colrv0', 'color-colrv1', 'color-svg', 'color-sbix', 'color-cbdt'];
23
- const fontFeaturesTech = ['features-opentype', 'features-aat', 'features-graphite', 'incremental-patch', 'incremental-range', 'incremental-auto', 'variations', 'palettes'];
24
- /**
25
- * supported transform functions
26
- *
27
- * @internal
28
- */
29
- const transformFunctions = [
30
- 'translate', 'scale', 'rotate', 'skew', 'perspective',
31
- 'translateX', 'translateY', 'translateZ',
32
- 'scaleX', 'scaleY', 'scaleZ',
33
- 'rotateX', 'rotateY', 'rotateZ',
34
- 'skewX', 'skewY',
35
- 'rotate3d', 'translate3d', 'scale3d', 'matrix', 'matrix3d'
36
- ];
37
- // https://drafts.csswg.org/mediaqueries/#media-types
38
- const mediaTypes = ['all', 'print', 'screen',
39
- /* deprecated */
40
- 'aural', 'braille', 'embossed', 'handheld', 'projection', 'tty', 'tv', 'speech'];
41
55
  // https://www.w3.org/TR/css-values-4/#math-function
42
- /**
43
- * supported math functions
44
- *
45
- * @internal
46
- */
47
- const mathFuncs = ['minmax', 'repeat', 'fit-content', 'calc', 'clamp', 'min', 'max', 'round', 'mod', 'rem', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2', 'pow', 'sqrt', 'hypot', 'log', 'exp', 'abs', 'sign'];
48
- const wildCardFuncs = ['var', 'env'];
49
- const pseudoElements = [':before', ':after', ':first-line', ':first-letter'];
56
+ const pseudoElements = [":before", ":after", ":first-line", ":first-letter"];
50
57
  // https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
51
58
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
52
59
  const pseudoAliasMap = {
53
- '-moz-center': 'center',
54
- '-webkit-center': 'center',
55
- '-ms-grid-columns': 'grid-template-columns',
56
- '-ms-grid-rows': 'grid-template-rows',
57
- '-ms-grid-row': 'grid-row-start',
58
- '-ms-grid-column': 'grid-column-start',
59
- '-ms-grid-row-align': 'align-self',
60
- '-ms-grid-row-span': 'grid-row-end',
61
- '-ms-grid-column-span': 'grid-column-end',
62
- '-ms-grid-column-align': 'justify-self',
63
- ':-ms-input-placeholder': '::placeholder',
64
- '::-ms-input-placeholder': '::placeholder',
65
- ':-moz-any()': ':is',
66
- '-moz-user-modify': 'user-modify',
67
- '-webkit-match-parent': 'match-parent',
68
- '-moz-background-clip': 'background-clip',
69
- '-moz-background-origin': 'background-origin',
70
- '-ms-input-placeholder': 'placeholder',
71
- ':-webkit-autofill': ':autofill',
72
- ':-webkit-any()': ':is',
73
- '::-webkit-input-placeholder': '::placeholder',
74
- '::-webkit-file-upload-button': '::file-selector-button',
75
- '::-moz-placeholder': '::placeholder',
76
- ':-webkit-any-link': ':any-link',
77
- '-webkit-border-after': 'border-block-end',
78
- '-webkit-border-after-color': 'border-block-end-color',
79
- '-webkit-border-after-style': 'border-block-end-style',
80
- '-webkit-border-after-width': 'border-block-end-width',
81
- '-webkit-border-before': 'border-block-start',
82
- '-webkit-border-before-color': 'border-block-start-color',
83
- '-webkit-border-before-style': 'border-block-start-style',
84
- '-webkit-border-before-width': 'border-block-start-width',
85
- '-webkit-border-end': 'border-inline-end',
86
- '-webkit-border-end-color': 'border-inline-end-color',
87
- '-webkit-border-end-style': 'border-inline-end-style',
88
- '-webkit-border-end-width': 'border-inline-end-width',
89
- '-webkit-border-start': 'border-inline-start',
90
- '-webkit-border-start-color': 'border-inline-start-color',
91
- '-webkit-border-start-style': 'border-inline-start-style',
92
- '-webkit-border-start-width': 'border-inline-start-width',
93
- '-webkit-box-align': 'align-items',
94
- '-webkit-box-direction': 'flex-direction',
95
- '-webkit-box-flex': 'flex-grow',
96
- '-webkit-box-lines': 'flex-flow',
97
- '-webkit-box-ordinal-group': 'order',
98
- '-webkit-box-orient': 'flex-direction',
99
- '-webkit-box-pack': 'justify-content',
100
- '-webkit-column-break-after': 'break-after',
101
- '-webkit-column-break-before': 'break-before',
102
- '-webkit-column-break-inside': 'break-inside',
103
- '-webkit-font-feature-settings': 'font-feature-settings',
104
- '-webkit-hyphenate-character': 'hyphenate-character',
105
- '-webkit-initial-letter': 'initial-letter',
106
- '-webkit-margin-end': 'margin-block-end',
107
- '-webkit-margin-start': 'margin-block-start',
108
- '-webkit-padding-after': 'padding-block-end',
109
- '-webkit-padding-before': 'padding-block-start',
110
- '-webkit-padding-end': 'padding-inline-end',
111
- '-webkit-padding-start': 'padding-inline-start',
112
- '-webkit-min-device-pixel-ratio': 'min-resolution',
113
- '-webkit-max-device-pixel-ratio': 'max-resolution',
114
- '-webkit-font-smoothing': 'font-smooth',
115
- '-webkit-line-clamp': 'line-clamp',
116
- ':-webkit-autofill-strong-password': ':autofill',
117
- ':-webkit-full-page-media': ':fullscreen',
118
- ':-webkit-full-screen': ':fullscreen',
119
- ':-webkit-full-screen-ancestor': ':fullscreen',
120
- ':-webkit-full-screen-document': ':fullscreen',
121
- ':-webkit-full-screen-controls-hidden': ':fullscreen',
122
- '-moz-background-inline-policy': 'box-decoration-break',
123
- '-moz-background-size': 'background-size',
124
- '-moz-border-end': 'border-inline-end',
125
- '-moz-border-end-color': 'border-inline-end-color',
126
- '-moz-border-end-style': 'border-inline-end-style',
127
- '-moz-border-end-width': 'border-inline-end-width',
128
- '-moz-border-image': 'border-inline-end-width',
129
- '-moz-border-start': 'border-inline-start',
130
- '-moz-border-start-color': 'border-inline-start-color',
131
- '-moz-border-start-style': 'border-inline-start-style',
132
- '-moz-border-start-width': 'border-inline-start-width',
133
- '-moz-column-count': 'column-count',
134
- '-moz-column-fill': 'column-fill',
135
- '-moz-column-gap': 'column-gap',
136
- '-moz-column-width': 'column-width',
137
- '-moz-column-rule': 'column-rule',
138
- '-moz-column-rule-width': 'column-rule-width',
139
- '-moz-column-rule-style': 'column-rule-style',
140
- '-moz-column-rule-color': 'column-rule-color',
141
- '-moz-margin-end': 'margin-inline-end',
142
- '-moz-margin-start': 'margin-inline-start',
143
- '-moz-opacity': 'opacity',
144
- '-moz-outline': 'outline',
145
- '-moz-outline-color': 'outline-color',
146
- '-moz-outline-offset': 'outline-offset',
147
- '-moz-outline-style': 'outline-style',
148
- '-moz-outline-width': 'outline-width',
149
- '-moz-padding-end': 'padding-inline-end',
150
- '-moz-padding-start': 'padding-inline-start',
151
- '-moz-tab-size': 'tab-size',
152
- '-moz-text-align-last': 'text-align-last',
153
- '-moz-text-decoration-color': 'text-decoration-color',
154
- '-moz-text-decoration-line': 'text-decoration-line',
155
- '-moz-text-decoration-style': 'text-decoration-style',
156
- '-moz-transition': 'transition',
157
- '-moz-transition-delay': 'transition-delay',
158
- '-moz-transition-duration': 'transition-duration',
159
- '-moz-transition-property': 'transition-property',
160
- '-moz-transition-timing-function': 'transition-timing-function',
161
- '-moz-user-select': 'user-select',
162
- '-moz-initial': 'initial',
163
- '-moz-linear-gradient()': 'linear-gradient',
164
- '-moz-radial-gradient()': 'radial-gradient',
165
- '-moz-element()': 'element',
166
- '-moz-crisp-edges': 'crisp-edges',
167
- '-moz-calc()': 'calc',
168
- '-moz-min-content': 'min-content',
169
- '-moz-fit-content': 'fit-content',
170
- '-moz-max-content': 'max-content',
171
- '-moz-available': 'stretch',
172
- ':-moz-any-link': ':any-link',
173
- ':-moz-full-screen': ':fullscreen',
174
- ':-moz-full-screen-ancestor': ':fullscreen',
175
- ':-moz-placeholder': ':placeholder-shown',
176
- ':-moz-read-only': ':read-only',
177
- ':-moz-read-write': ':read-write',
178
- ':-moz-submit-invalid': ':invalid',
179
- ':-moz-ui-invalid': ':user-invalid',
180
- ':-moz-ui-valid': ':user-valid',
181
- '::-moz-selection': '::selection',
60
+ "-moz-center": "center",
61
+ "-webkit-center": "center",
62
+ "-ms-grid-columns": "grid-template-columns",
63
+ "-ms-grid-rows": "grid-template-rows",
64
+ "-ms-grid-row": "grid-row-start",
65
+ "-ms-grid-column": "grid-column-start",
66
+ "-ms-grid-row-align": "align-self",
67
+ "-ms-grid-row-span": "grid-row-end",
68
+ "-ms-grid-column-span": "grid-column-end",
69
+ "-ms-grid-column-align": "justify-self",
70
+ ":-ms-input-placeholder": "::placeholder",
71
+ "::-ms-input-placeholder": "::placeholder",
72
+ ":-moz-any()": ":is",
73
+ "-moz-user-modify": "user-modify",
74
+ "-webkit-match-parent": "match-parent",
75
+ "-moz-background-clip": "background-clip",
76
+ "-moz-background-origin": "background-origin",
77
+ "-ms-input-placeholder": "placeholder",
78
+ ":-webkit-autofill": ":autofill",
79
+ ":-webkit-any()": ":is",
80
+ "::-webkit-input-placeholder": "::placeholder",
81
+ "::-webkit-file-upload-button": "::file-selector-button",
82
+ "::-moz-placeholder": "::placeholder",
83
+ ":-webkit-any-link": ":any-link",
84
+ "-webkit-border-after": "border-block-end",
85
+ "-webkit-border-after-color": "border-block-end-color",
86
+ "-webkit-border-after-style": "border-block-end-style",
87
+ "-webkit-border-after-width": "border-block-end-width",
88
+ "-webkit-border-before": "border-block-start",
89
+ "-webkit-border-before-color": "border-block-start-color",
90
+ "-webkit-border-before-style": "border-block-start-style",
91
+ "-webkit-border-before-width": "border-block-start-width",
92
+ "-webkit-border-end": "border-inline-end",
93
+ "-webkit-border-end-color": "border-inline-end-color",
94
+ "-webkit-border-end-style": "border-inline-end-style",
95
+ "-webkit-border-end-width": "border-inline-end-width",
96
+ "-webkit-border-start": "border-inline-start",
97
+ "-webkit-border-start-color": "border-inline-start-color",
98
+ "-webkit-border-start-style": "border-inline-start-style",
99
+ "-webkit-border-start-width": "border-inline-start-width",
100
+ "-webkit-box-align": "align-items",
101
+ "-webkit-box-direction": "flex-direction",
102
+ "-webkit-box-flex": "flex-grow",
103
+ "-webkit-box-lines": "flex-flow",
104
+ "-webkit-box-ordinal-group": "order",
105
+ "-webkit-box-orient": "flex-direction",
106
+ "-webkit-box-pack": "justify-content",
107
+ "-webkit-column-break-after": "break-after",
108
+ "-webkit-column-break-before": "break-before",
109
+ "-webkit-column-break-inside": "break-inside",
110
+ "-webkit-font-feature-settings": "font-feature-settings",
111
+ "-webkit-hyphenate-character": "hyphenate-character",
112
+ "-webkit-initial-letter": "initial-letter",
113
+ "-webkit-margin-end": "margin-block-end",
114
+ "-webkit-margin-start": "margin-block-start",
115
+ "-webkit-padding-after": "padding-block-end",
116
+ "-webkit-padding-before": "padding-block-start",
117
+ "-webkit-padding-end": "padding-inline-end",
118
+ "-webkit-padding-start": "padding-inline-start",
119
+ "-webkit-min-device-pixel-ratio": "min-resolution",
120
+ "-webkit-max-device-pixel-ratio": "max-resolution",
121
+ "-webkit-font-smoothing": "font-smooth",
122
+ "-webkit-line-clamp": "line-clamp",
123
+ ":-webkit-autofill-strong-password": ":autofill",
124
+ ":-webkit-full-page-media": ":fullscreen",
125
+ ":-webkit-full-screen": ":fullscreen",
126
+ ":-webkit-full-screen-ancestor": ":fullscreen",
127
+ ":-webkit-full-screen-document": ":fullscreen",
128
+ ":-webkit-full-screen-controls-hidden": ":fullscreen",
129
+ "-moz-background-inline-policy": "box-decoration-break",
130
+ "-moz-background-size": "background-size",
131
+ "-moz-border-end": "border-inline-end",
132
+ "-moz-border-end-color": "border-inline-end-color",
133
+ "-moz-border-end-style": "border-inline-end-style",
134
+ "-moz-border-end-width": "border-inline-end-width",
135
+ "-moz-border-image": "border-inline-end-width",
136
+ "-moz-border-start": "border-inline-start",
137
+ "-moz-border-start-color": "border-inline-start-color",
138
+ "-moz-border-start-style": "border-inline-start-style",
139
+ "-moz-border-start-width": "border-inline-start-width",
140
+ "-moz-column-count": "column-count",
141
+ "-moz-column-fill": "column-fill",
142
+ "-moz-column-gap": "column-gap",
143
+ "-moz-column-width": "column-width",
144
+ "-moz-column-rule": "column-rule",
145
+ "-moz-column-rule-width": "column-rule-width",
146
+ "-moz-column-rule-style": "column-rule-style",
147
+ "-moz-column-rule-color": "column-rule-color",
148
+ "-moz-margin-end": "margin-inline-end",
149
+ "-moz-margin-start": "margin-inline-start",
150
+ "-moz-opacity": "opacity",
151
+ "-moz-outline": "outline",
152
+ "-moz-outline-color": "outline-color",
153
+ "-moz-outline-offset": "outline-offset",
154
+ "-moz-outline-style": "outline-style",
155
+ "-moz-outline-width": "outline-width",
156
+ "-moz-padding-end": "padding-inline-end",
157
+ "-moz-padding-start": "padding-inline-start",
158
+ "-moz-tab-size": "tab-size",
159
+ "-moz-text-align-last": "text-align-last",
160
+ "-moz-text-decoration-color": "text-decoration-color",
161
+ "-moz-text-decoration-line": "text-decoration-line",
162
+ "-moz-text-decoration-style": "text-decoration-style",
163
+ "-moz-transition": "transition",
164
+ "-moz-transition-delay": "transition-delay",
165
+ "-moz-transition-duration": "transition-duration",
166
+ "-moz-transition-property": "transition-property",
167
+ "-moz-transition-timing-function": "transition-timing-function",
168
+ "-moz-user-select": "user-select",
169
+ "-moz-initial": "initial",
170
+ "-moz-linear-gradient()": "linear-gradient",
171
+ "-moz-radial-gradient()": "radial-gradient",
172
+ "-moz-element()": "element",
173
+ "-moz-crisp-edges": "crisp-edges",
174
+ "-moz-calc()": "calc",
175
+ "-moz-min-content": "min-content",
176
+ "-moz-fit-content": "fit-content",
177
+ "-moz-max-content": "max-content",
178
+ "-moz-available": "stretch",
179
+ ":-moz-any-link": ":any-link",
180
+ ":-moz-full-screen": ":fullscreen",
181
+ ":-moz-full-screen-ancestor": ":fullscreen",
182
+ ":-moz-placeholder": ":placeholder-shown",
183
+ ":-moz-read-only": ":read-only",
184
+ ":-moz-read-write": ":read-write",
185
+ ":-moz-submit-invalid": ":invalid",
186
+ ":-moz-ui-invalid": ":user-invalid",
187
+ ":-moz-ui-valid": ":user-valid",
188
+ "::-moz-selection": "::selection",
182
189
  };
183
- // https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
184
- // https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar
185
- const webkitExtensions = new Set([
186
- '-webkit-app-region',
187
- '-webkit-border-horizontal-spacing',
188
- '-webkit-border-vertical-spacing',
189
- '-webkit-box-reflect',
190
- '-webkit-column-axis',
191
- '-webkit-column-progression',
192
- '-webkit-cursor-visibility',
193
- '-webkit-font-smoothing',
194
- '-webkit-hyphenate-limit-after',
195
- '-webkit-hyphenate-limit-before',
196
- '-webkit-hyphenate-limit-lines',
197
- '-webkit-line-align',
198
- '-webkit-line-box-contain',
199
- '-webkit-line-clamp',
200
- '-webkit-line-grid',
201
- '-webkit-line-snap',
202
- '-webkit-locale',
203
- '-webkit-logical-height',
204
- '-webkit-logical-width',
205
- '-webkit-margin-after',
206
- '-webkit-margin-before',
207
- '-webkit-mask-box-image-outset',
208
- '-webkit-mask-box-image-repeat',
209
- '-webkit-mask-box-image-slice',
210
- '-webkit-mask-box-image-source',
211
- '-webkit-mask-box-image-width',
212
- '-webkit-mask-box-image',
213
- '-webkit-mask-composite',
214
- '-webkit-mask-position-x',
215
- '-webkit-mask-position-y',
216
- '-webkit-mask-repeat-x',
217
- '-webkit-mask-repeat-y',
218
- '-webkit-mask-source-type',
219
- '-webkit-max-logical-height',
220
- '-webkit-max-logical-width',
221
- '-webkit-min-logical-height',
222
- '-webkit-min-logical-width',
223
- '-webkit-nbsp-mode',
224
- '-webkit-match-parent',
225
- '-webkit-perspective-origin-x',
226
- '-webkit-perspective-origin-y',
227
- '-webkit-rtl-ordering',
228
- '-webkit-tap-highlight-color',
229
- '-webkit-text-decoration-skip',
230
- '-webkit-text-decorations-in-effect',
231
- '-webkit-text-fill-color',
232
- '-webkit-text-security',
233
- '-webkit-text-stroke-color',
234
- '-webkit-text-stroke-width',
235
- '-webkit-text-stroke',
236
- '-webkit-text-zoom',
237
- '-webkit-touch-callout',
238
- '-webkit-transform-origin-x',
239
- '-webkit-transform-origin-y',
240
- '-webkit-transform-origin-z',
241
- '-webkit-user-drag',
242
- '-webkit-user-modify',
243
- '-webkit-border-after',
244
- '-webkit-border-after-color',
245
- '-webkit-border-after-style',
246
- '-webkit-border-after-width',
247
- '-webkit-border-before',
248
- '-webkit-border-before-color',
249
- '-webkit-border-before-style',
250
- '-webkit-border-before-width',
251
- '-webkit-border-end',
252
- '-webkit-border-end-color',
253
- '-webkit-border-end-style',
254
- '-webkit-border-end-width',
255
- '-webkit-border-start',
256
- '-webkit-border-start-color',
257
- '-webkit-border-start-style',
258
- '-webkit-border-start-width',
259
- '-webkit-box-align',
260
- '-webkit-box-direction',
261
- '-webkit-box-flex-group',
262
- '-webkit-box-flex',
263
- '-webkit-box-lines',
264
- '-webkit-box-ordinal-group',
265
- '-webkit-box-orient',
266
- '-webkit-box-pack',
267
- '-webkit-column-break-after',
268
- '-webkit-column-break-before',
269
- '-webkit-column-break-inside',
270
- '-webkit-font-feature-settings',
271
- '-webkit-hyphenate-character',
272
- '-webkit-initial-letter',
273
- '-webkit-margin-end',
274
- '-webkit-margin-start',
275
- '-webkit-padding-after',
276
- '-webkit-padding-before',
277
- '-webkit-padding-end',
278
- '-webkit-padding-start',
279
- '-webkit-fill-available',
280
- ':-webkit-animating-full-screen-transition',
281
- ':-webkit-any',
282
- ':-webkit-any-link',
283
- ':-webkit-autofill',
284
- ':-webkit-autofill-strong-password',
285
- ':-webkit-drag',
286
- ':-webkit-full-page-media',
287
- ':-webkit-full-screen*',
288
- ':-webkit-full-screen-ancestor',
289
- ':-webkit-full-screen-document',
290
- ':-webkit-full-screen-controls-hidden',
291
- '::-webkit-file-upload-button*',
292
- '::-webkit-inner-spin-button',
293
- '::-webkit-input-placeholder',
294
- '::-webkit-meter-bar',
295
- '::-webkit-meter-even-less-good-value',
296
- '::-webkit-meter-inner-element',
297
- '::-webkit-meter-optimum-value',
298
- '::-webkit-meter-suboptimum-value',
299
- '::-webkit-progress-bar',
300
- '::-webkit-progress-inner-element',
301
- '::-webkit-progress-value',
302
- '::-webkit-search-cancel-button',
303
- '::-webkit-search-results-button',
304
- '::-webkit-slider-runnable-track',
305
- '::-webkit-slider-thumb',
306
- '-webkit-animation',
307
- '-webkit-device-pixel-ratio',
308
- '-webkit-transform-2d',
309
- '-webkit-transform-3d',
310
- '-webkit-transition',
311
- '::-webkit-scrollbar',
312
- '::-webkit-scrollbar-button',
313
- '::-webkit-scrollbar',
314
- '::-webkit-scrollbar-thumb',
315
- '::-webkit-scrollbar-track',
316
- '::-webkit-scrollbar-track-piece',
317
- '::-webkit-scrollbar:vertical',
318
- '::-webkit-scrollbar-corner ',
319
- '::-webkit-resizer',
320
- ':vertical',
321
- ':horizontal',
322
- ]);
323
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
324
- const mozExtensions = new Set([
325
- '-moz-box-align',
326
- '-moz-box-direction',
327
- '-moz-box-flex',
328
- '-moz-box-ordinal-group',
329
- '-moz-box-orient',
330
- '-moz-box-pack',
331
- '-moz-float-edge',
332
- '-moz-force-broken-image-icon',
333
- '-moz-image-region',
334
- '-moz-orient',
335
- '-moz-osx-font-smoothing',
336
- '-moz-user-focus',
337
- '-moz-user-input',
338
- '-moz-user-modify',
339
- '-moz-animation',
340
- '-moz-animation-delay',
341
- '-moz-animation-direction',
342
- '-moz-animation-duration',
343
- '-moz-animation-fill-mode',
344
- '-moz-animation-iteration-count',
345
- '-moz-animation-name',
346
- '-moz-animation-play-state',
347
- '-moz-animation-timing-function',
348
- '-moz-appearance',
349
- '-moz-backface-visibility',
350
- '-moz-background-clip',
351
- '-moz-background-origin',
352
- '-moz-background-inline-policy',
353
- '-moz-background-size',
354
- '-moz-border-end',
355
- '-moz-border-end-color',
356
- '-moz-border-end-style',
357
- '-moz-border-end-width',
358
- '-moz-border-image',
359
- '-moz-border-start',
360
- '-moz-border-start-color',
361
- '-moz-border-start-style',
362
- '-moz-border-start-width',
363
- '-moz-box-sizing',
364
- 'clip-path',
365
- '-moz-column-count',
366
- '-moz-column-fill',
367
- '-moz-column-gap',
368
- '-moz-column-width',
369
- '-moz-column-rule',
370
- '-moz-column-rule-width',
371
- '-moz-column-rule-style',
372
- '-moz-column-rule-color',
373
- 'filter',
374
- '-moz-font-feature-settings',
375
- '-moz-font-language-override',
376
- '-moz-hyphens',
377
- '-moz-margin-end',
378
- '-moz-margin-start',
379
- 'mask',
380
- '-moz-opacity',
381
- '-moz-outline',
382
- '-moz-outline-color',
383
- '-moz-outline-offset',
384
- '-moz-outline-style',
385
- '-moz-outline-width',
386
- '-moz-padding-end',
387
- '-moz-padding-start',
388
- '-moz-perspective',
389
- '-moz-perspective-origin',
390
- 'pointer-events',
391
- '-moz-tab-size',
392
- '-moz-text-align-last',
393
- '-moz-text-decoration-color',
394
- '-moz-text-decoration-line',
395
- '-moz-text-decoration-style',
396
- '-moz-text-size-adjust',
397
- '-moz-transform',
398
- '-moz-transform-origin',
399
- '-moz-transform-style',
400
- '-moz-transition',
401
- '-moz-transition-delay',
402
- '-moz-transition-duration',
403
- '-moz-transition-property',
404
- '-moz-transition-timing-function',
405
- '-moz-user-select',
406
- '-moz-initial',
407
- '-moz-appearance',
408
- '-moz-linear-gradient',
409
- '-moz-radial-gradient',
410
- '-moz-element',
411
- '-moz-image-rect',
412
- '::-moz-anonymous-block',
413
- '::-moz-anonymous-positioned-block',
414
- ':-moz-any',
415
- ':-moz-any-link',
416
- ':-moz-broken',
417
- '::-moz-canvas',
418
- '::-moz-color-swatch',
419
- '::-moz-cell-content',
420
- ':-moz-drag-over',
421
- ':-moz-first-node',
422
- '::-moz-focus-inner',
423
- '::-moz-focus-outer',
424
- ':-moz-full-screen',
425
- ':-moz-full-screen-ancestor',
426
- ':-moz-handler-blocked',
427
- ':-moz-handler-crashed',
428
- ':-moz-handler-disabled',
429
- '::-moz-inline-table',
430
- ':-moz-last-node',
431
- '::-moz-list-bullet',
432
- '::-moz-list-number',
433
- ':-moz-loading',
434
- ':-moz-locale-dir',
435
- ':-moz-locale-dir',
436
- ':-moz-lwtheme',
437
- ':-moz-lwtheme-brighttext',
438
- ':-moz-lwtheme-darktext',
439
- '::-moz-meter-bar',
440
- ':-moz-native-anonymous',
441
- ':-moz-only-whitespace',
442
- '::-moz-pagebreak',
443
- '::-moz-pagecontent',
444
- ':-moz-placeholder',
445
- '::-moz-placeholder',
446
- '::-moz-progress-bar',
447
- '::-moz-range-progress',
448
- '::-moz-range-thumb',
449
- '::-moz-range-track',
450
- ':-moz-read-only',
451
- ':-moz-read-write',
452
- '::-moz-scrolled-canvas',
453
- '::-moz-scrolled-content',
454
- '::-moz-selection',
455
- ':-moz-submit-invalid',
456
- ':-moz-suppressed',
457
- '::-moz-svg-foreign-content',
458
- '::-moz-table',
459
- '::-moz-table-cell',
460
- '::-moz-table-column',
461
- '::-moz-table-column-group',
462
- '::-moz-table-outer',
463
- '::-moz-table-row',
464
- '::-moz-table-row-group',
465
- ':-moz-ui-invalid',
466
- ':-moz-ui-valid',
467
- ':-moz-user-disabled',
468
- '::-moz-viewport',
469
- '::-moz-viewport-scroll',
470
- ':-moz-window-inactive',
471
- '-moz-device-pixel-ratio',
472
- '-moz-os-version',
473
- '-moz-touch-enabled',
474
- '-moz-windows-glass',
475
- '-moz-alt-content'
476
- ]);
190
+ // renamed standard properties
191
+ const renamedStandardProperties = new Map([["color-adjust", "print-color-adjust"]]);
477
192
  function isLength(dimension) {
478
- return 'unit' in dimension && dimensionUnits.has(dimension.unit.toLowerCase());
193
+ return "unit" in dimension && dimensionUnits.has(dimension.unit.toLowerCase());
479
194
  }
480
195
  function isResolution(dimension) {
481
- return 'unit' in dimension && ['dpi', 'dpcm', 'dppx', 'x'].includes(dimension.unit.toLowerCase());
196
+ return "unit" in dimension && ["dpi", "dpcm", "dppx", "x"].includes(dimension.unit.toLowerCase());
482
197
  }
483
198
  function isAngle(dimension) {
484
- return 'unit' in dimension && ['rad', 'turn', 'deg', 'grad'].includes(dimension.unit.toLowerCase());
199
+ return "unit" in dimension && ["rad", "turn", "deg", "grad"].includes(dimension.unit.toLowerCase());
485
200
  }
486
201
  function isTime(dimension) {
487
- return 'unit' in dimension && ['ms', 's'].includes(dimension.unit.toLowerCase());
202
+ return "unit" in dimension && ["ms", "s"].includes(dimension.unit.toLowerCase());
488
203
  }
489
204
  function isFrequency(dimension) {
490
- return 'unit' in dimension && ['hz', 'khz'].includes(dimension.unit.toLowerCase());
205
+ return "unit" in dimension && ["hz", "khz"].includes(dimension.unit.toLowerCase());
491
206
  }
492
207
  function isColorspace(token) {
208
+ if (token.typ === EnumToken.WildCardFunctionTokenType && token.val === "var") {
209
+ return true;
210
+ }
493
211
  if (token.typ != EnumToken.IdenTokenType) {
494
212
  return false;
495
213
  }
496
- return ['srgb', 'srgb-linear', 'lab', 'oklab', 'lch', 'oklch', 'xyz', 'xyz-d50', 'xyz-d65', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec2020', 'rgb', 'hsl', 'hwb'].includes(token.val.toLowerCase());
214
+ return [
215
+ "srgb",
216
+ "srgb-linear",
217
+ "lab",
218
+ "oklab",
219
+ "lch",
220
+ "oklch",
221
+ "xyz",
222
+ "xyz-d50",
223
+ "xyz-d65",
224
+ "display-p3",
225
+ "a98-rgb",
226
+ "prophoto-rgb",
227
+ "rec2020",
228
+ "rgb",
229
+ "hsl",
230
+ "hwb",
231
+ ].includes(token.val.toLowerCase());
497
232
  }
498
233
  function isRectangularOrthogonalColorspace(token) {
499
234
  if (token.typ != EnumToken.IdenTokenType) {
500
235
  return false;
501
236
  }
502
- return ['srgb', 'srgb-linear', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec2020', 'lab', 'oklab', 'xyz', 'xyz-d50', 'xyz-d65'].includes(token.val.toLowerCase());
237
+ return [
238
+ "srgb",
239
+ "srgb-linear",
240
+ "display-p3",
241
+ "a98-rgb",
242
+ "prophoto-rgb",
243
+ "rec2020",
244
+ "lab",
245
+ "oklab",
246
+ "xyz",
247
+ "xyz-d50",
248
+ "xyz-d65",
249
+ ].includes(token.val.toLowerCase());
503
250
  }
504
251
  function isPolarColorspace(token) {
505
252
  if (token.typ != EnumToken.IdenTokenType) {
506
253
  return false;
507
254
  }
508
- return ['hsl', 'hwb', 'lch', 'oklch'].includes(token.val);
255
+ return ["hsl", "hwb", "lch", "oklch"].includes(token.val);
509
256
  }
510
257
  function isHueInterpolationMethod(token) {
511
258
  if (!Array.isArray(token)) {
512
- return token.typ == EnumToken.IdenTokenType && 'hue' === token.val?.toLowerCase?.();
259
+ return token.typ == EnumToken.IdenTokenType && "hue" === token.val?.toLowerCase?.();
513
260
  }
514
261
  if (token.length != 2 || token[0].typ != EnumToken.IdenTokenType || token[1].typ != EnumToken.IdenTokenType) {
515
262
  return false;
516
263
  }
517
- return ['shorter', 'longer', 'increasing', 'decreasing'].includes(token[0].val?.toLowerCase?.()) && 'hue' === token[1].val?.toLowerCase?.();
264
+ return (["shorter", "longer", "increasing", "decreasing"].includes(token[0].val?.toLowerCase?.()) &&
265
+ "hue" === token[1].val?.toLowerCase?.());
518
266
  }
519
267
  function isIdentColor(token) {
520
- return token.typ == EnumToken.ColorTokenType && [ColorType.SYS, ColorType.DPSYS, ColorType.LIT].includes(token.kin) && isIdent(token.val);
268
+ return (token.typ == EnumToken.ColorTokenType &&
269
+ [ColorType.SYS, ColorType.DPSYS, ColorType.LIT].includes(token.kin) &&
270
+ isIdent(token.val));
521
271
  }
522
272
  function isPercentageToken(token) {
523
- return token.typ == EnumToken.PercentageTokenType || (token.typ == EnumToken.NumberTokenType && token.val == 0);
273
+ return (token.typ == EnumToken.PercentageTokenType ||
274
+ (token.typ == EnumToken.NumberTokenType && token.val == 0));
524
275
  }
525
- function isColor(token) {
526
- if (token.typ == EnumToken.ColorTokenType) {
276
+ function isColor(token, errors) {
277
+ if (token.typ == EnumToken.WildCardFunctionTokenType) {
527
278
  return true;
528
279
  }
280
+ if (token.typ == EnumToken.FunctionTokenType) {
281
+ if (!colorsFunc.includes(token.val.toLowerCase())) {
282
+ return false;
283
+ }
284
+ }
285
+ if (token.typ == EnumToken.ColorTokenType) {
286
+ if ("kin" in token && !("chi" in token)) {
287
+ return true;
288
+ }
289
+ }
529
290
  if (token.typ == EnumToken.IdenTokenType) {
291
+ const val = token.val.toLowerCase();
292
+ if (systemColors.has(val) || deprecatedSystemColors.has(val) || nonStandardColors.has(val)) {
293
+ return true;
294
+ }
530
295
  // named color
531
- return token.val.toLowerCase() in COLORS_NAMES || 'currentcolor' === token.val.toLowerCase() || 'transparent' === token.val.toLowerCase();
296
+ return val in COLORS_NAMES || "currentcolor" === val || "transparent" === val;
532
297
  }
533
298
  let isLegacySyntax = false;
534
- if (token.typ == EnumToken.FunctionTokenType) {
299
+ if (token.typ === EnumToken.FunctionTokenType || token.typ === EnumToken.ColorTokenType) {
535
300
  if (!colorsFunc.includes(token.val.toLowerCase())) {
536
301
  return false;
537
302
  }
538
303
  if (token.chi.length > 0) {
539
304
  // @ts-ignore
540
- if (token.val == 'light-dark') {
305
+ if (token.val === "light-dark") {
541
306
  // @ts-ignore
542
- const children = token.chi.filter((t) => [EnumToken.IdenTokenType, EnumToken.NumberTokenType, EnumToken.LiteralTokenType, EnumToken.ColorTokenType, EnumToken.FunctionTokenType, EnumToken.PercentageTokenType].includes(t.typ));
307
+ const children = token.chi.filter((t) => [
308
+ EnumToken.IdenTokenType,
309
+ EnumToken.NumberTokenType,
310
+ EnumToken.LiteralTokenType,
311
+ EnumToken.ColorTokenType,
312
+ EnumToken.FunctionTokenType,
313
+ EnumToken.PercentageTokenType,
314
+ EnumToken.WildCardFunctionTokenType,
315
+ ].includes(t.typ));
543
316
  if (children.length != 2) {
317
+ errors?.push({
318
+ message: "light-dark function must have 2 arguments",
319
+ node: token,
320
+ action: "drop",
321
+ });
544
322
  return false;
545
323
  }
546
324
  if (isColor(children[0]) && isColor(children[1])) {
@@ -548,26 +326,89 @@ function isColor(token) {
548
326
  }
549
327
  }
550
328
  // adding numbers and percentages is disallowed
551
- // https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch#defining_relative_color_output_channel_components
329
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/lch#defining_relative_color_output_channel_components:~:text=Adding%20a%20%3Cpercentage%3E%20to%20a%20%3Cnumber%3E%2C%20for%20example%2C%20doesn%27t%20work
552
330
  // @ts-ignore
553
- for (const { value } of walkValues(token.chi, null, (node) => funcLike.includes(node.typ) ? WalkerOptionEnum.IgnoreChildren : null)) {
554
- if (funcLike.includes(value.typ)) {
555
- for (const { value: val } of walkValues([buildExpression(value.chi)])) {
556
- if (val.typ == EnumToken.BinaryExpressionTokenType &&
557
- (val.l.typ == EnumToken.PercentageTokenType || val.r.typ == EnumToken.PercentageTokenType) &&
558
- ((val.r.typ == EnumToken.PercentageTokenType && val.op == EnumToken.Div) ||
559
- ((val.op == EnumToken.Add || val.op == EnumToken.Sub) &&
560
- val.l.typ != val.r.typ))) {
561
- return false;
331
+ for (const { value, parent } of walkValues(token.chi, token, (value) => value.typ === EnumToken.WildCardFunctionTokenType
332
+ ? WalkerOptionEnum.Ignore | WalkerOptionEnum.IgnoreChildren
333
+ : null)) {
334
+ let k = 0;
335
+ let l;
336
+ let tk = null;
337
+ let tl = null;
338
+ if (value.typ === EnumToken.BinaryExpressionTokenType) {
339
+ tk = value.l;
340
+ tl = value.r;
341
+ }
342
+ else if (parent?.typ === EnumToken.MathFunctionTokenType &&
343
+ parent.val === "calc") {
344
+ l = k + 1;
345
+ while (l + 1 < parent.chi.length) {
346
+ const tk = parent.chi[l];
347
+ if (tk.typ === EnumToken.WhitespaceTokenType ||
348
+ tk.typ === EnumToken.CommentTokenType ||
349
+ tk.typ === EnumToken.Add ||
350
+ tk.typ === EnumToken.Sub ||
351
+ tk.typ === EnumToken.Div ||
352
+ tk.typ === EnumToken.Mul) {
353
+ l++;
354
+ continue;
562
355
  }
356
+ break;
357
+ }
358
+ tk = parent.chi[k];
359
+ tl = parent.chi[l];
360
+ }
361
+ if (tk != null && tl != null) {
362
+ if ((tk.typ === EnumToken.PercentageTokenType || tl.typ === EnumToken.PercentageTokenType) &&
363
+ tk.typ !== tl.typ) {
364
+ errors?.push({
365
+ action: "drop",
366
+ message: "adding percentage and number is not allowed",
367
+ node: token,
368
+ location: token.loc,
369
+ });
370
+ return false;
563
371
  }
564
372
  }
565
373
  }
566
374
  // @ts-ignore
567
- if (token.val == 'color') {
375
+ if (token.val == "color") {
568
376
  // @ts-ignore
569
- const children = token.chi.filter((t) => [EnumToken.IdenTokenType, EnumToken.NumberTokenType, EnumToken.LiteralTokenType, EnumToken.ColorTokenType, EnumToken.FunctionTokenType, EnumToken.PercentageTokenType].includes(t.typ));
570
- const isRelative = children[0].typ == EnumToken.IdenTokenType && children[0].val == 'from';
377
+ const children = token.chi.filter((t) => [
378
+ EnumToken.DashedIdenTokenType,
379
+ EnumToken.IdenTokenType,
380
+ EnumToken.NumberTokenType,
381
+ EnumToken.LiteralTokenType,
382
+ EnumToken.ColorTokenType,
383
+ EnumToken.FunctionTokenType,
384
+ EnumToken.MathFunctionTokenType,
385
+ EnumToken.PercentageTokenType,
386
+ ].includes(t.typ));
387
+ const isRelative = children[0].typ == EnumToken.IdenTokenType && children[0].val == "from";
388
+ let offset = 0;
389
+ if (isRelative) {
390
+ offset = 2;
391
+ }
392
+ if (children[offset]?.typ == EnumToken.DashedIdenTokenType) {
393
+ if (children.length < offset + 1) {
394
+ return false;
395
+ }
396
+ for (let i = offset + 1; i < children.length; i++) {
397
+ if (children[i].typ == EnumToken.NumberTokenType ||
398
+ children[i].typ == EnumToken.LiteralTokenType ||
399
+ children[i].typ == EnumToken.ColorTokenType ||
400
+ children[i].typ == EnumToken.FunctionTokenType ||
401
+ children[i].typ == EnumToken.MathFunctionTokenType ||
402
+ children[i].typ == EnumToken.PercentageTokenType ||
403
+ isColor(children[i]) ||
404
+ (children[i].typ == EnumToken.IdenTokenType &&
405
+ equalsIgnoreCase("none", children[i].val))) {
406
+ continue;
407
+ }
408
+ return false;
409
+ }
410
+ return true;
411
+ }
571
412
  if (children.length < 4 || children.length > 8) {
572
413
  return false;
573
414
  }
@@ -576,15 +417,21 @@ function isColor(token) {
576
417
  }
577
418
  for (let i = 1; i < children.length - 2; i++) {
578
419
  if (children[i].typ == EnumToken.IdenTokenType) {
579
- if (children[i].val != 'none' &&
580
- !(isRelative && ['alpha', 'r', 'g', 'b', 'x', 'y', 'z'].includes(children[i].val) || isColorspace(children[i]))) {
420
+ if (isColor(children[i])) {
421
+ continue;
422
+ }
423
+ if (children[i].val != "none" &&
424
+ !((isRelative &&
425
+ ["alpha", "r", "g", "b", "x", "y", "z"].includes(children[i].val)) ||
426
+ isColorspace(children[i]))) {
581
427
  return false;
582
428
  }
583
429
  }
584
- if (children[i].typ == EnumToken.FunctionTokenType) {
585
- if ('var' == children[i].val.toLowerCase()) {
586
- continue;
587
- }
430
+ if (children[i].typ === EnumToken.WildCardFunctionTokenType) {
431
+ continue;
432
+ }
433
+ if (children[i].typ === EnumToken.FunctionTokenType ||
434
+ children[i].typ === EnumToken.MathFunctionTokenType) {
588
435
  if (!mathFuncs.includes(children[i].val)) {
589
436
  return false;
590
437
  }
@@ -597,10 +444,11 @@ function isColor(token) {
597
444
  const sep = children.at(-2);
598
445
  const alpha = children.at(-1);
599
446
  // @ts-ignore
600
- if ((children.length > 6 || !isRelative) && sep.typ != EnumToken.LiteralTokenType || sep.val != '/') {
447
+ if (((children.length > 6 || !isRelative) && sep.typ != EnumToken.LiteralTokenType) ||
448
+ sep.val != "/") {
601
449
  return false;
602
450
  }
603
- if (alpha.typ == EnumToken.IdenTokenType && alpha.val != 'none') {
451
+ if (alpha.typ == EnumToken.IdenTokenType && alpha.val != "none") {
604
452
  return false;
605
453
  }
606
454
  else {
@@ -620,7 +468,7 @@ function isColor(token) {
620
468
  return true;
621
469
  }
622
470
  // @ts-ignore
623
- else if (token.val == 'color-mix') {
471
+ else if (token.val == "color-mix") {
624
472
  // @ts-ignore
625
473
  const children = token.chi.reduce((acc, t) => {
626
474
  if (t.typ == EnumToken.CommaTokenType) {
@@ -636,7 +484,7 @@ function isColor(token) {
636
484
  if (children.length == 3) {
637
485
  if (children[0].length > 4 ||
638
486
  children[0][0].typ != EnumToken.IdenTokenType ||
639
- 'in' !== children[0][0].val?.toLowerCase?.() ||
487
+ "in" !== children[0][0].val?.toLowerCase?.() ||
640
488
  !isColorspace(children[0][1]) ||
641
489
  (children[0].length >= 3 && !isHueInterpolationMethod(children[0].slice(2))) ||
642
490
  children[1].length > 2 ||
@@ -648,12 +496,16 @@ function isColor(token) {
648
496
  return false;
649
497
  }
650
498
  if (children[1].length == 2) {
651
- if (!(children[1][1].typ == EnumToken.PercentageTokenType || (children[1][1].typ == EnumToken.NumberTokenType && children[1][1].val == 0))) {
499
+ if (!(children[1][1].typ == EnumToken.PercentageTokenType ||
500
+ (children[1][1].typ == EnumToken.NumberTokenType &&
501
+ children[1][1].val == 0))) {
652
502
  return false;
653
503
  }
654
504
  }
655
505
  if (children[2].length == 2) {
656
- if (!(children[2][1].typ == EnumToken.PercentageTokenType || (children[2][1].typ == EnumToken.NumberTokenType && children[2][1].val == 0))) {
506
+ if (!(children[2][1].typ == EnumToken.PercentageTokenType ||
507
+ (children[2][1].typ == EnumToken.NumberTokenType &&
508
+ children[2][1].val == 0))) {
657
509
  return false;
658
510
  }
659
511
  }
@@ -662,11 +514,11 @@ function isColor(token) {
662
514
  return false;
663
515
  }
664
516
  else {
665
- const keywords = ['from', 'none'];
517
+ const keywords = ["from", "none"];
666
518
  // @ts-ignore
667
- if (['rgb', 'hsl', 'hwb', 'lab', 'lch', 'oklab', 'oklch'].includes(token.val)) {
519
+ if (["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].includes(token.val)) {
668
520
  // @ts-ignore
669
- keywords.push('alpha', ...token.val.slice(-3).split(''));
521
+ keywords.push("alpha", ...token.val.slice(-3).split(""));
670
522
  }
671
523
  // @ts-ignore
672
524
  for (const v of token.chi) {
@@ -674,6 +526,9 @@ function isColor(token) {
674
526
  isLegacySyntax = true;
675
527
  }
676
528
  if (v.typ == EnumToken.IdenTokenType) {
529
+ if (isColor(v)) {
530
+ continue;
531
+ }
677
532
  if (!(keywords.includes(v.val) || v.val.toLowerCase() in COLORS_NAMES)) {
678
533
  return false;
679
534
  }
@@ -682,16 +537,27 @@ function isColor(token) {
682
537
  return false;
683
538
  }
684
539
  // @ts-ignore
685
- if (v.val == 'from' && ['rgba', 'hsla'].includes(token.val)) {
540
+ if (v.val == "from" && ["rgba", "hsla"].includes(token.val)) {
686
541
  return false;
687
542
  }
688
543
  }
689
544
  continue;
690
545
  }
691
- if (v.typ == EnumToken.FunctionTokenType && (mathFuncs.includes(v.val) || v.val == 'var' || colorsFunc.includes(v.val))) {
546
+ if (v.typ === EnumToken.MathFunctionTokenType ||
547
+ v.typ === EnumToken.WildCardFunctionTokenType ||
548
+ colorsFunc.includes(v.val)) {
692
549
  continue;
693
550
  }
694
- if (![EnumToken.ColorTokenType, EnumToken.IdenTokenType, EnumToken.NumberTokenType, EnumToken.AngleTokenType, EnumToken.PercentageTokenType, EnumToken.CommaTokenType, EnumToken.WhitespaceTokenType, EnumToken.LiteralTokenType].includes(v.typ)) {
551
+ if (![
552
+ EnumToken.ColorTokenType,
553
+ EnumToken.IdenTokenType,
554
+ EnumToken.NumberTokenType,
555
+ EnumToken.AngleTokenType,
556
+ EnumToken.PercentageTokenType,
557
+ EnumToken.CommaTokenType,
558
+ EnumToken.WhitespaceTokenType,
559
+ EnumToken.LiteralTokenType,
560
+ ].includes(v.typ)) {
695
561
  return false;
696
562
  }
697
563
  }
@@ -702,26 +568,109 @@ function isColor(token) {
702
568
  return false;
703
569
  }
704
570
  function parseColor(token) {
571
+ if (token.typ === EnumToken.IdenTokenType) {
572
+ const val = token.val.toLowerCase();
573
+ if (nonStandardColors.has(val)) {
574
+ Object.assign(token, {
575
+ typ: EnumToken.ColorTokenType,
576
+ kin: ColorType.NON_STD,
577
+ });
578
+ return token;
579
+ }
580
+ if (systemColors.has(val)) {
581
+ Object.assign(token, {
582
+ typ: EnumToken.ColorTokenType,
583
+ kin: ColorType.SYS,
584
+ });
585
+ return token;
586
+ }
587
+ if (deprecatedSystemColors.has(val)) {
588
+ Object.assign(token, {
589
+ typ: EnumToken.ColorTokenType,
590
+ kin: ColorType.DPSYS,
591
+ });
592
+ return token;
593
+ }
594
+ if (val in COLORS_NAMES || val === "currentcolor") {
595
+ Object.assign(token, {
596
+ typ: EnumToken.ColorTokenType,
597
+ val,
598
+ kin: ColorType.LIT,
599
+ });
600
+ return token;
601
+ }
602
+ }
603
+ if (token.typ === EnumToken.ColorTokenType) {
604
+ if (!("kin" in token) && "val" in token) {
605
+ // @ts-expect-error
606
+ token.kin = ColorType[token.val.replaceAll("-", "_").toUpperCase()];
607
+ }
608
+ if ("chi" in token) {
609
+ const tk = token.chi?.find((t) => t.typ !== EnumToken.WhitespaceTokenType && t.typ !== EnumToken.CommentTokenType);
610
+ if (tk?.typ === EnumToken.IdenTokenType && tk.val === "from") {
611
+ token.cal = "rel";
612
+ }
613
+ else if (token.val == "color-mix" && tk.val == "in") {
614
+ token.cal = "mix";
615
+ }
616
+ if (token.val == "color") {
617
+ let index = token.chi.indexOf(tk);
618
+ if (token.cal == "rel") {
619
+ for (let k = 0; k < token.chi.length; k++) {
620
+ if (EnumToken.DashedIdenTokenType == token.chi[k].typ) {
621
+ index = k;
622
+ break;
623
+ }
624
+ }
625
+ }
626
+ if (EnumToken.DashedIdenTokenType == token?.chi?.[index]?.typ) {
627
+ token.kin = ColorType.CUSTOM_COLOR;
628
+ }
629
+ }
630
+ }
631
+ return token;
632
+ }
705
633
  // @ts-ignore
706
634
  token.typ = EnumToken.ColorTokenType;
707
635
  // @ts-ignore
708
- token.kin = ColorType[token.val.replaceAll('-', '_').toUpperCase()];
636
+ token.kin = ColorType[token.val.replaceAll("-", "_").toUpperCase()];
637
+ if (!("chi" in token)) {
638
+ const val = token.val.toLowerCase();
639
+ if (val == "currentcolor" || val == "transparent" || val in COLORS_NAMES) {
640
+ token.kin = ColorType.LIT;
641
+ }
642
+ else if (isHexColor(val)) {
643
+ token.kin = ColorType.HEX;
644
+ }
645
+ const tk = token.chi?.find((t) => t.typ !== EnumToken.WhitespaceTokenType && t.typ !== EnumToken.CommentTokenType);
646
+ if (tk?.typ === EnumToken.IdenTokenType && tk.val === "from") {
647
+ token.cal = "rel";
648
+ }
649
+ else if (token.val == "color-mix" && tk.val == "in") {
650
+ token.cal = "mix";
651
+ }
652
+ else if (token.val == "color") {
653
+ token.cal = "col";
654
+ }
655
+ return token;
656
+ }
709
657
  // @ts-ignore
710
658
  if (token.chi[0].typ == EnumToken.IdenTokenType) {
711
659
  // @ts-ignore
712
- if (token.chi[0].val == 'from') {
660
+ if (token.chi[0].val == "from") {
713
661
  // @ts-ignore
714
- token.cal = 'rel';
662
+ token.cal = "rel";
715
663
  }
716
664
  // @ts-ignore
717
- else if (token.val == 'color-mix' && token.chi[0].val == 'in') {
665
+ else if (token.val == "color-mix" && token.chi[0].val == "in") {
718
666
  // @ts-ignore
719
- token.cal = 'mix';
667
+ token.cal = "mix";
720
668
  }
721
- else { // @ts-ignore
722
- if (token.val == 'color') {
669
+ else {
670
+ // @ts-ignore
671
+ if (token.val == "color") {
723
672
  // @ts-ignore
724
- token.cal = 'col';
673
+ token.cal = "col";
725
674
  }
726
675
  }
727
676
  }
@@ -729,9 +678,9 @@ function parseColor(token) {
729
678
  }
730
679
  function isLetter(codepoint) {
731
680
  // lowercase
732
- return (codepoint >= 0x61 && codepoint <= 0x7a) ||
681
+ return ((codepoint >= 0x61 && codepoint <= 0x7a) ||
733
682
  // uppercase
734
- (codepoint >= 0x41 && codepoint <= 0x5a);
683
+ (codepoint >= 0x41 && codepoint <= 0x5a));
735
684
  }
736
685
  function isNonAscii(codepoint) {
737
686
  return codepoint >= 0x80;
@@ -757,26 +706,26 @@ function isIdent(name) {
757
706
  if (Number.isNaN(nextCodepoint)) {
758
707
  return false;
759
708
  }
760
- // -
761
- if (nextCodepoint == 0x2d) {
762
- return true;
763
- }
764
709
  if (nextCodepoint == REVERSE_SOLIDUS) {
765
710
  return name.length > 2 && !isNewLine(name.charCodeAt(2));
766
711
  }
767
- return true;
712
+ if (isDigit(nextCodepoint)) {
713
+ return false;
714
+ }
715
+ codepoint = nextCodepoint;
716
+ i = 1;
768
717
  }
769
- if (!isIdentStart(codepoint)) {
718
+ if (codepoint !== 0x2d && !isIdentStart(codepoint)) {
770
719
  return false;
771
720
  }
772
721
  if (codepoint == REVERSE_SOLIDUS) {
773
- codepoint = name.codePointAt(i + 1);
722
+ codepoint = name.charCodeAt(i + 1);
774
723
  if (!isIdentCodepoint(codepoint)) {
775
724
  return false;
776
725
  }
777
726
  i += String.fromCodePoint(codepoint).length;
778
727
  if (i < j) {
779
- codepoint = name.codePointAt(i);
728
+ codepoint = name.charCodeAt(i);
780
729
  if (!isIdentCodepoint(codepoint)) {
781
730
  return false;
782
731
  }
@@ -791,19 +740,19 @@ function isIdent(name) {
791
740
  i += codepoint < 0x80 ? 1 : String.fromCodePoint(codepoint).length;
792
741
  continue;
793
742
  }
794
- if (!isIdentCodepoint(codepoint)) {
743
+ if (codepoint !== 0x2d && !isIdentCodepoint(codepoint)) {
795
744
  return false;
796
745
  }
797
746
  }
798
747
  return true;
799
748
  }
800
749
  function isPseudo(name) {
801
- return name.charAt(0) == ':' &&
802
- ((name.endsWith('(') && isIdent(name.charAt(1) == ':' ? name.slice(2, -1) : name.slice(1, -1))) ||
803
- isIdent(name.charAt(1) == ':' ? name.slice(2) : name.slice(1)));
750
+ return (name.charAt(0) == ":" &&
751
+ ((name.endsWith("(") && isIdent(name.charAt(1) == ":" ? name.slice(2, -1) : name.slice(1, -1))) ||
752
+ isIdent(name.charAt(1) == ":" ? name.slice(2) : name.slice(1))));
804
753
  }
805
754
  function isHash(name) {
806
- return name.charAt(0) == '#' && isIdent(name.charAt(1));
755
+ return name.charAt(0) == "#" && isIdent(name.charAt(1));
807
756
  }
808
757
  function isNumber(name) {
809
758
  if (name.length == 0) {
@@ -874,29 +823,11 @@ function isNumber(name) {
874
823
  }
875
824
  return true;
876
825
  }
877
- // export function isDimension(name: string) {
878
- //
879
- // let index: number = name.length;
880
- //
881
- // while (index--) {
882
- //
883
- // if (isLetter(<number>name.charCodeAt(index))) {
884
- //
885
- // continue
886
- // }
887
- //
888
- // index++;
889
- // break;
890
- // }
891
- //
892
- // const number: string = name.slice(0, index);
893
- // return number.length > 0 && isIdentStart(name.charCodeAt(index)) && isNumber(number);
894
- // }
895
826
  function isPercentage(name) {
896
- return name.endsWith('%') && isNumber(name.slice(0, -1));
827
+ return name.endsWith("%") && isNumber(name.slice(0, -1));
897
828
  }
898
829
  function isFlex(dimension) {
899
- return 'unit' in dimension && 'fr' == dimension.unit.toLowerCase();
830
+ return "unit" in dimension && "fr" == dimension.unit.toLowerCase();
900
831
  }
901
832
  function parseDimension(name) {
902
833
  let index = name.length;
@@ -907,12 +838,15 @@ function parseDimension(name) {
907
838
  index++;
908
839
  break;
909
840
  }
841
+ if (index < 0) {
842
+ return null;
843
+ }
910
844
  const dimension = {
911
845
  typ: EnumToken.DimensionTokenType,
912
846
  val: +name.slice(0, index),
913
- unit: name.slice(index)
847
+ unit: name.slice(index),
914
848
  };
915
- if (index < 0 || Number.isNaN(dimension.val)) {
849
+ if (Number.isNaN(dimension.val)) {
916
850
  return null;
917
851
  }
918
852
  if (isAngle(dimension)) {
@@ -930,8 +864,8 @@ function parseDimension(name) {
930
864
  else if (isResolution(dimension)) {
931
865
  // @ts-ignore
932
866
  dimension.typ = EnumToken.ResolutionTokenType;
933
- if (dimension.unit == 'dppx') {
934
- dimension.unit = 'x';
867
+ if (dimension.unit == "dppx") {
868
+ dimension.unit = "x";
935
869
  }
936
870
  }
937
871
  else if (isFrequency(dimension)) {
@@ -945,7 +879,7 @@ function parseDimension(name) {
945
879
  return dimension;
946
880
  }
947
881
  function isHexColor(name) {
948
- if (name.charAt(0) != '#' || ![4, 5, 7, 9].includes(name.length)) {
882
+ if (name.charAt(0) != "#" || ![4, 5, 7, 9].includes(name.length)) {
949
883
  return false;
950
884
  }
951
885
  for (let chr of name.slice(1)) {
@@ -961,19 +895,50 @@ function isHexColor(name) {
961
895
  return true;
962
896
  }
963
897
  function isFunction(name) {
964
- return name.endsWith('(') && isIdent(name.slice(0, -1));
965
- }
966
- function isAtKeyword(name) {
967
- return name.charCodeAt(0) == 0x40 && isIdent(name.slice(1));
898
+ return name.endsWith("(") && isIdent(name.slice(0, -1));
968
899
  }
969
900
  function isNewLine(codepoint) {
970
- // \n \r \f
971
- return codepoint == 0xa || codepoint == 0xc || codepoint == 0xd;
901
+ // \n \r \f \v
902
+ return (codepoint == 0xa ||
903
+ codepoint == 0xb ||
904
+ codepoint == 0xc ||
905
+ codepoint == 0xd ||
906
+ codepoint == 0x2028 ||
907
+ codepoint == 0x2029);
972
908
  }
973
909
  function isWhiteSpace(codepoint) {
974
- return codepoint == 0x9 || codepoint == 0x20 ||
910
+ return (codepoint == 0x9 ||
911
+ codepoint == 0x20 ||
975
912
  // isNewLine
976
- codepoint == 0xa || codepoint == 0xc || codepoint == 0xd;
913
+ codepoint == 0xa ||
914
+ codepoint == 0xb ||
915
+ codepoint == 0xc ||
916
+ codepoint == 0xd ||
917
+ codepoint == 0x2028 ||
918
+ codepoint == 0x2029);
919
+ }
920
+ function isValue(token) {
921
+ if (token == null) {
922
+ return false;
923
+ }
924
+ return (token.typ === EnumToken.IdenTokenType ||
925
+ token.typ === EnumToken.DimensionTokenType ||
926
+ token.typ === EnumToken.LengthTokenType ||
927
+ token.typ === EnumToken.AngleTokenType ||
928
+ token.typ === EnumToken.FlexTokenType ||
929
+ token.typ === EnumToken.TimeTokenType ||
930
+ token.typ === EnumToken.ResolutionTokenType ||
931
+ token.typ === EnumToken.FrequencyTokenType ||
932
+ token.typ === EnumToken.NumberTokenType ||
933
+ token.typ === EnumToken.ColorTokenType ||
934
+ token.typ === EnumToken.FunctionTokenType ||
935
+ token.typ === EnumToken.UrlFunctionTokenType ||
936
+ token.typ === EnumToken.GridTemplateFuncTokenType ||
937
+ token.typ === EnumToken.ImageFunctionTokenType ||
938
+ token.typ === EnumToken.TimelineFunctionTokenType ||
939
+ token.typ === EnumToken.TimingFunctionTokenType ||
940
+ token.typ === EnumToken.MathFunctionTokenType ||
941
+ token.typ === EnumToken.TransformFunctionTokenType);
977
942
  }
978
943
 
979
- export { colorFontTech, fontFeaturesTech, fontFormat, isAngle, isAtKeyword, isColor, isColorspace, isDigit, isFlex, isFrequency, isFunction, isHash, isHexColor, isHueInterpolationMethod, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isNewLine, isNumber, isPercentage, isPercentageToken, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, mathFuncs, mediaTypes, mozExtensions, parseColor, parseDimension, pseudoAliasMap, pseudoElements, transformFunctions, webkitExtensions, wildCardFuncs };
944
+ export { dimensionUnits, isAngle, isColor, isColorspace, isDigit, isFlex, isFrequency, isFunction, isHash, isHexColor, isHueInterpolationMethod, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isLetter, isNewLine, isNumber, isPercentage, isPercentageToken, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isValue, isWhiteSpace, parseColor, parseDimension, pseudoAliasMap, pseudoElements, renamedStandardProperties };