@tbela99/css-parser 1.6.7 → 1.6.9
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.
- package/CHANGELOG.md +64 -4
- package/dist/index-umd-web.js +126 -49
- package/dist/index.cjs +119 -49
- package/dist/index.d.ts +51 -3
- package/dist/package.json.js +10 -0
- package/dist/{data → src/data}/properties.json.js +7 -0
- package/dist/{data → src/data}/validation.json.js +7 -0
- package/dist/{lib → src/lib}/ast/clone.js +7 -0
- package/dist/{lib → src/lib}/ast/expand.js +7 -0
- package/dist/{lib → src/lib}/ast/features/calc.js +7 -0
- package/dist/{lib → src/lib}/ast/features/if.js +7 -0
- package/dist/{lib → src/lib}/ast/features/index.js +7 -0
- package/dist/{lib → src/lib}/ast/features/inlinecssvariables.js +7 -0
- package/dist/{lib → src/lib}/ast/features/prefix.js +7 -0
- package/dist/{lib → src/lib}/ast/features/shorthand.js +7 -0
- package/dist/{lib → src/lib}/ast/features/transform.js +7 -0
- package/dist/{lib → src/lib}/ast/features/type.js +7 -0
- package/dist/{lib → src/lib}/ast/find.js +7 -0
- package/dist/{lib → src/lib}/ast/math/expression.js +7 -0
- package/dist/{lib → src/lib}/ast/math/math.js +7 -0
- package/dist/{lib → src/lib}/ast/minify.js +7 -0
- package/dist/{lib → src/lib}/ast/node.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/compute.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/matrix.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/minify.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/perspective.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/rotate.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/scale.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/skew.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/translate.js +7 -0
- package/dist/{lib → src/lib}/ast/transform/utils.js +7 -0
- package/dist/{lib → src/lib}/ast/types.js +12 -1
- package/dist/{lib → src/lib}/ast/walk.js +7 -0
- package/dist/{lib → src/lib}/fs/resolve.js +7 -0
- package/dist/{lib → src/lib}/parser/declaration/list.js +7 -0
- package/dist/{lib → src/lib}/parser/declaration/map.js +7 -0
- package/dist/{lib → src/lib}/parser/declaration/set.js +7 -0
- package/dist/{lib → src/lib}/parser/linesmap.js +7 -0
- package/dist/{lib → src/lib}/parser/parse.js +61 -21
- package/dist/{lib → src/lib}/parser/source.js +7 -0
- package/dist/{lib → src/lib}/parser/tokenize.js +24 -3
- package/dist/{lib → src/lib}/parser/utils/angle.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-container.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-font-feature-values.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-generic.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-import.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-media.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-support.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule-when-else.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/at-rule.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/base64.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/cache.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/config.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/declaration.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/eq.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/hash.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/selector.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/text.js +7 -0
- package/dist/{lib → src/lib}/parser/utils/token.js +15 -4
- package/dist/{lib → src/lib}/parser/utils/type.js +7 -0
- package/dist/{lib → src/lib}/printer/render.js +9 -1
- package/dist/{lib → src/lib}/printer/sourcemap/lib/codec.js +7 -0
- package/dist/{lib → src/lib}/printer/sourcemap/sourcemap.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/a98rgb.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/alpha.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/cmyk.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/color-mix.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/color.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/hex.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/hsl.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/hwb.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/lab.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/lch.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/oklab.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/oklch.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/p3.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/prophotorgb.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/rec2020.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/relative-color.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/rgb.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/srgb.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/utils/color-type.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/utils/colorspace.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/utils/components.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/utils/distance.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/utils/make-color.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/utils/matrix.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/xyz.js +7 -0
- package/dist/{lib → src/lib}/syntax/color/xyzd50.js +7 -0
- package/dist/{lib → src/lib}/syntax/constants.js +7 -0
- package/dist/{lib → src/lib}/syntax/syntax.js +7 -0
- package/dist/{lib → src/lib}/validation/config.js +7 -0
- package/dist/{lib → src/lib}/validation/match.js +37 -19
- package/dist/{lib → src/lib}/validation/parser/parse.js +7 -0
- package/dist/{lib → src/lib}/validation/parser/typedef.js +7 -0
- package/dist/{lib → src/lib}/validation/utils/list.js +7 -0
- package/dist/{node.js → src/node.js} +8 -0
- package/dist/{types.js → src/types.js} +7 -0
- package/dist/{utils → src/utils}/sync.js +7 -0
- package/dist/{web.js → src/web.js} +8 -0
- package/package.json +5 -4
- package/dist/lib/syntax/color/hsv.js +0 -6
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken, EnumAstNodeStatus, ColorType } from '../../ast/types.js';
|
|
2
9
|
import { LOCEND, STATE, ERRORS, LOCSTA, tokensfuncDefMap, COLORS_NAMES, nonStandardColors, systemColors, deprecatedSystemColors, tokensMap, trimTokenSpace, LOCSRCID } from '../../syntax/constants.js';
|
|
3
10
|
import { renamedStandardProperties, isColor, parseColor, isWhiteSpace } from '../../syntax/syntax.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken, EnumAstNodeStatus } from '../../ast/types.js';
|
|
2
9
|
import { renderValue } from '../../printer/render.js';
|
|
3
10
|
import { LOCEND, LOCSTA, LOCSRCID, ERRORS, STATE, TOKENS, pseudoElements, combinators, tokensfuncDefMap, PARENT } from '../../syntax/constants.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken } from '../../ast/types.js';
|
|
2
9
|
import { PARENT, tokensfuncSet } from '../../syntax/constants.js';
|
|
3
10
|
|
|
@@ -9,12 +16,15 @@ const trimTokenSpace = new Set([
|
|
|
9
16
|
EnumToken.LtTokenType,
|
|
10
17
|
EnumToken.LteTokenType,
|
|
11
18
|
EnumToken.ChildCombinatorTokenType,
|
|
19
|
+
EnumToken.PipeTokenType,
|
|
12
20
|
]);
|
|
13
21
|
const trimSpaceAfter = new Set([
|
|
14
22
|
...tokensfuncSet.values(),
|
|
15
23
|
EnumToken.ChildCombinatorTokenType,
|
|
16
24
|
EnumToken.SupportsQueryConditionTokenType,
|
|
17
25
|
EnumToken.SupportsQueryUnaryConditionTokenType,
|
|
26
|
+
EnumToken.CommaTokenType,
|
|
27
|
+
EnumToken.PipeTokenType,
|
|
18
28
|
]);
|
|
19
29
|
/**
|
|
20
30
|
* Replace token in its parent node
|
|
@@ -84,17 +94,18 @@ function trimWhiteSpaceTokens(tokens) {
|
|
|
84
94
|
return tokens;
|
|
85
95
|
}
|
|
86
96
|
for (; i < tokens.length; i++) {
|
|
87
|
-
if (
|
|
88
|
-
tokens.splice(i + 1, 1);
|
|
89
|
-
}
|
|
90
|
-
else if (trimTokenSpace.has(tokens[i].typ)) {
|
|
97
|
+
if (trimTokenSpace.has(tokens[i].typ)) {
|
|
91
98
|
if (tokens[i + 1]?.typ === EnumToken.WhitespaceTokenType) {
|
|
92
99
|
tokens.splice(i + 1, 1);
|
|
93
100
|
}
|
|
94
101
|
if (i > 0 && tokens[i - 1].typ === EnumToken.Whitespace) {
|
|
95
102
|
tokens.splice(--i, 1);
|
|
103
|
+
continue;
|
|
96
104
|
}
|
|
97
105
|
}
|
|
106
|
+
if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === EnumToken.WhitespaceTokenType) {
|
|
107
|
+
tokens.splice(i + 1, 1);
|
|
108
|
+
}
|
|
98
109
|
}
|
|
99
110
|
return tokens;
|
|
100
111
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken } from '../../ast/types.js';
|
|
2
9
|
import { tokensfuncSet } from '../../syntax/constants.js';
|
|
3
10
|
import { isColor } from '../../syntax/syntax.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { convertColor, getAngle } from '../syntax/color/color.js';
|
|
2
9
|
import { reduceHexValue } from '../syntax/color/hex.js';
|
|
3
10
|
import { EnumToken, ColorType } from '../ast/types.js';
|
|
@@ -1128,7 +1135,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
1128
1135
|
return ",";
|
|
1129
1136
|
case EnumToken.ImportantTokenType:
|
|
1130
1137
|
return "!important";
|
|
1131
|
-
case EnumToken.
|
|
1138
|
+
case EnumToken.PipeTokenType:
|
|
1132
1139
|
return "|";
|
|
1133
1140
|
case EnumToken.AttrTokenType:
|
|
1134
1141
|
case EnumToken.IdenListTokenType:
|
|
@@ -1251,6 +1258,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
|
|
|
1251
1258
|
pseudoElements.includes(token.val.slice(1))) {
|
|
1252
1259
|
return token.val.slice(1);
|
|
1253
1260
|
}
|
|
1261
|
+
case EnumToken.CssTypeTokenType:
|
|
1254
1262
|
case EnumToken.UrlTokenTokenType:
|
|
1255
1263
|
case EnumToken.HashTokenType:
|
|
1256
1264
|
case EnumToken.IdenTokenType:
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { xyz2srgb } from './srgb.js';
|
|
2
9
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
3
10
|
import { srgb2xyz } from './xyz.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { ColorType, EnumToken } from '../../ast/types.js';
|
|
2
9
|
import { convertColor } from './color.js';
|
|
3
10
|
import { getColorComponents } from './utils/components.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { ColorType, EnumToken } from '../../ast/types.js';
|
|
2
9
|
import { color2srgbvalues } from './color.js';
|
|
3
10
|
import { lch2srgbvalues, lab2srgbvalues, oklch2srgbvalues, oklab2srgbvalues, hwb2srgbvalues, rgb2srgbvalues } from './srgb.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken, ColorType, EnumAstNodeStatus } from '../../ast/types.js';
|
|
2
9
|
import { minmax, getNumber } from './color.js';
|
|
3
10
|
import { srgbvalues, srgb2lsrgbvalues, hslvalues } from './srgb.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { ColorType, EnumToken } from '../../ast/types.js';
|
|
2
9
|
import { color2RgbToken, lch2RgbToken, lab2RgbToken, oklch2RgbToken, oklab2RgbToken, cmyk2RgbToken, hwb2RgbToken, hsl2RgbToken, hex2RgbToken } from './rgb.js';
|
|
3
10
|
import { color2HslToken, lch2HslToken, lab2HslToken, oklch2HslToken, oklab2HslToken, cmyk2HslToken, hwb2HslToken, hex2HslToken, rgb2HslToken } from './hsl.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
2
9
|
import { color2srgbvalues, getNumber } from './color.js';
|
|
3
10
|
import { srgb2rgb, cmyk2rgbvalues, hwb2rgbvalues, hsl2rgbvalues } from './rgb.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { color2srgbvalues, getNumber } from './color.js';
|
|
2
9
|
import { lch2rgbvalues, lab2rgbvalues, cmyk2rgbvalues } from './rgb.js';
|
|
3
10
|
import { getColorComponents } from './utils/components.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { getColorComponents } from './utils/components.js';
|
|
2
9
|
import { color2srgbvalues, getNumber, getAngle } from './color.js';
|
|
3
10
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { e, k, D50 } from '../constants.js';
|
|
2
9
|
import { getColorComponents } from './utils/components.js';
|
|
3
10
|
import { srgb2xyz_d65, XYZ_D50_to_D65 } from './xyz.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { getColorComponents } from './utils/components.js';
|
|
2
9
|
import { color2srgbvalues, getNumber, getAngle } from './color.js';
|
|
3
10
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { getColorComponents } from './utils/components.js';
|
|
2
9
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
3
10
|
import { srgb2lsrgbvalues, lch2srgbvalues, lab2srgbvalues, cmyk2srgbvalues, hwb2srgbvalues, hsl2srgb, rgb2srgb, hex2srgbvalues, lsrgb2srgbvalues } from './srgb.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { getColorComponents } from './utils/components.js';
|
|
2
9
|
import { color2srgbvalues, getNumber, getAngle } from './color.js';
|
|
3
10
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { lsrgb2srgbvalues, xyz2srgb, srgb2lsrgbvalues } from './srgb.js';
|
|
2
9
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
3
10
|
import { srgb2xyz } from './xyz.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { xyz2srgb } from './srgb.js';
|
|
2
9
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
3
10
|
import { srgb2xyz } from './xyz.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { convertColor, getNumber } from './color.js';
|
|
2
9
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
3
10
|
import { walkValues } from '../../ast/walk.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { color2srgbvalues, minmax } from './color.js';
|
|
2
9
|
import { expandHexValue } from './hex.js';
|
|
3
10
|
import { hslvalues, hslvalues2srgbvalues, lch2srgbvalues, lab2srgbvalues, oklch2srgbvalues, oklab2srgbvalues, cmyk2srgbvalues, hwb2srgbvalues } from './srgb.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { getColorComponents } from './utils/components.js';
|
|
2
9
|
import { color2srgbvalues, getNumber, getAngle } from './color.js';
|
|
3
10
|
import { EnumToken, ColorType } from '../../ast/types.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { ColorType, EnumToken } from '../../../ast/types.js';
|
|
2
9
|
import { COLORS_NAMES } from '../../constants.js';
|
|
3
10
|
import { expandHexValue } from '../hex.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { convertColor } from '../color.js';
|
|
2
9
|
import { getOKLABComponents } from '../oklab.js';
|
|
3
10
|
import { ColorType } from '../../../ast/types.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken, ColorType } from '../../../ast/types.js';
|
|
2
9
|
import { equalsIgnoreCase } from '../../../parser/utils/text.js';
|
|
3
10
|
import { minmax, getNumber } from '../color.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
2
9
|
import { srgb2lsrgbvalues } from './srgb.js';
|
|
3
10
|
import { XYZ_D65_to_D50 } from './xyzd50.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { lsrgb2srgbvalues } from './srgb.js';
|
|
2
9
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
3
10
|
import { xyz2lab } from './lab.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { isOkLabClose } from './color/utils/distance.js';
|
|
2
9
|
import { EnumToken, ColorType } from '../ast/types.js';
|
|
3
10
|
import { walkValues, WalkerOptionEnum } from '../ast/walk.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import config from '../../data/validation.json.js';
|
|
2
9
|
import { trimSyntaxArray, parseSyntax } from './parser/parse.js';
|
|
3
10
|
import { ValidationTokenEnum } from './parser/typedef.js';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { getParsedSyntax, getSyntaxConfig } from './config.js';
|
|
2
9
|
import { EnumToken } from '../ast/types.js';
|
|
3
10
|
import { ValidationSyntaxGroupEnum, ValidationTokenEnum, MediaFeatureType } from './parser/typedef.js';
|
|
@@ -126,8 +133,7 @@ function isMFValue(featureName, tokens, isMFRange) {
|
|
|
126
133
|
case MediaFeatureType.RatioType:
|
|
127
134
|
return {
|
|
128
135
|
valid: true,
|
|
129
|
-
success: (tokens.length == 1 &&
|
|
130
|
-
tokens[0].typ == EnumToken.NumberTokenType) ||
|
|
136
|
+
success: (tokens.length == 1 && tokens[0].typ == EnumToken.NumberTokenType) ||
|
|
131
137
|
(tokens.length === 3 &&
|
|
132
138
|
tokens[0].typ == EnumToken.NumberTokenType &&
|
|
133
139
|
typeof tokens[0].val === "number" &&
|
|
@@ -434,7 +440,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
434
440
|
}
|
|
435
441
|
stack.push(token);
|
|
436
442
|
break;
|
|
437
|
-
case EnumToken.
|
|
443
|
+
case EnumToken.PipeTokenType:
|
|
438
444
|
case EnumToken.DelimTokenType:
|
|
439
445
|
case EnumToken.StringTokenType:
|
|
440
446
|
case EnumToken.IncludeMatchTokenType:
|
|
@@ -482,10 +488,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
482
488
|
}
|
|
483
489
|
slice.push(tokens[n]);
|
|
484
490
|
}
|
|
485
|
-
if (slice[1]?.typ === EnumToken.
|
|
491
|
+
if (slice[1]?.typ === EnumToken.PipeTokenType) {
|
|
486
492
|
slice.shift();
|
|
487
493
|
}
|
|
488
|
-
if (slice[0].typ === EnumToken.
|
|
494
|
+
if (slice[0].typ === EnumToken.PipeTokenType) {
|
|
489
495
|
slice.shift();
|
|
490
496
|
}
|
|
491
497
|
if (slice.length === 1) {
|
|
@@ -847,8 +853,8 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
847
853
|
// custom function token
|
|
848
854
|
if (token.typ === EnumToken.CustomFunctionTokenDefType) {
|
|
849
855
|
if (syntaxes[i].typ != ValidationTokenEnum.PropertyType ||
|
|
850
|
-
syntaxes[i + 1]
|
|
851
|
-
syntaxes[i + 2]
|
|
856
|
+
syntaxes[i + 1]?.typ != ValidationTokenEnum.OpenParenthesis ||
|
|
857
|
+
syntaxes[i + 2]?.typ == null) {
|
|
852
858
|
if (!isOptional) {
|
|
853
859
|
return {
|
|
854
860
|
success: false,
|
|
@@ -1695,17 +1701,15 @@ function matchProperty(property, context, options) {
|
|
|
1695
1701
|
case "display-internal":
|
|
1696
1702
|
case "display-outside":
|
|
1697
1703
|
case "display-legacy":
|
|
1698
|
-
case "content-position":
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
propertyKeywordValues.set(property.val, values);
|
|
1704
|
-
}
|
|
1705
|
-
success =
|
|
1706
|
-
token?.typ == EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
|
|
1707
|
-
break;
|
|
1704
|
+
case "content-position": {
|
|
1705
|
+
let values = propertyKeywordValues.get(property.val);
|
|
1706
|
+
if (values == null) {
|
|
1707
|
+
values = new Set(config.syntaxes[property.val].syntax.split(/[\s|]+/));
|
|
1708
|
+
propertyKeywordValues.set(property.val, values);
|
|
1708
1709
|
}
|
|
1710
|
+
success = token?.typ == EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
|
|
1711
|
+
break;
|
|
1712
|
+
}
|
|
1709
1713
|
case "mf-name":
|
|
1710
1714
|
{
|
|
1711
1715
|
const token = context.peek();
|
|
@@ -1725,8 +1729,7 @@ function matchProperty(property, context, options) {
|
|
|
1725
1729
|
case "custom-ident":
|
|
1726
1730
|
case "counter-name":
|
|
1727
1731
|
case "counter-style-name":
|
|
1728
|
-
success =
|
|
1729
|
-
token?.typ == EnumToken.IdenTokenType || token?.typ == EnumToken.DashedIdenTokenType;
|
|
1732
|
+
success = token?.typ == EnumToken.IdenTokenType || token?.typ == EnumToken.DashedIdenTokenType;
|
|
1730
1733
|
if (success && token?.typ === EnumToken.IdenTokenType) {
|
|
1731
1734
|
const val = token.val.toLowerCase();
|
|
1732
1735
|
success = "none" !== val && !allValues.includes(val);
|
|
@@ -2197,6 +2200,21 @@ function matchProperty(property, context, options) {
|
|
|
2197
2200
|
}
|
|
2198
2201
|
break;
|
|
2199
2202
|
}
|
|
2203
|
+
case "css-type": {
|
|
2204
|
+
success = context.peek()?.typ == EnumToken.CssTypeTokenType;
|
|
2205
|
+
if (success) {
|
|
2206
|
+
context.next();
|
|
2207
|
+
return {
|
|
2208
|
+
success: true,
|
|
2209
|
+
valid: true,
|
|
2210
|
+
token: null,
|
|
2211
|
+
context,
|
|
2212
|
+
syntaxToken: null,
|
|
2213
|
+
errors: [],
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
break;
|
|
2217
|
+
}
|
|
2200
2218
|
default:
|
|
2201
2219
|
if (!(property.val in config.syntaxes)) {
|
|
2202
2220
|
console.debug("Unknown syntax", context.peek(), property);
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 1.6.9
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
1
8
|
import { EnumToken } from '../../ast/types.js';
|
|
2
9
|
import { isIdentStart, isIdent, parseDimension, isPseudo } from '../../syntax/syntax.js';
|
|
3
10
|
import { ValidationTokenEnum } from './typedef.js';
|