@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.
- package/.nyc_output/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
- package/.nyc_output/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
- package/.nyc_output/processinfo/4874b20e-6f53-4d7a-be5a-cf68316925f2.json +1 -0
- package/.nyc_output/processinfo/6193bc4c-6f5f-4898-8950-c628825e6342.json +1 -0
- package/.repl_history +4 -0
- package/CHANGELOG.md +164 -4
- package/README.md +43 -0
- package/badges/coverage.svg +20 -0
- package/deno.lock +2861 -0
- package/dist/config.json.js +33 -1
- package/dist/index-umd-web.js +24382 -18476
- package/dist/index.cjs +24522 -18618
- package/dist/index.d.ts +1396 -929
- package/dist/lib/ast/clone.d.ts +10 -0
- package/dist/lib/ast/clone.js +45 -0
- package/dist/lib/ast/expand.d.ts +14 -0
- package/dist/lib/ast/expand.js +89 -64
- package/dist/lib/ast/features/calc.d.ts +10 -0
- package/dist/lib/ast/features/calc.js +62 -24
- package/dist/lib/ast/features/if.d.ts +10 -0
- package/dist/lib/ast/features/if.js +215 -0
- package/dist/lib/ast/features/index.d.ts +6 -0
- package/dist/lib/ast/features/index.js +1 -0
- package/dist/lib/ast/features/inlinecssvariables.d.ts +15 -0
- package/dist/lib/ast/features/inlinecssvariables.js +32 -27
- package/dist/lib/ast/features/prefix.d.ts +8 -0
- package/dist/lib/ast/features/prefix.js +68 -43
- package/dist/lib/ast/features/shorthand.d.ts +12 -0
- package/dist/lib/ast/features/shorthand.js +6 -9
- package/dist/lib/ast/features/transform.d.ts +10 -0
- package/dist/lib/ast/features/transform.js +9 -13
- package/dist/lib/ast/features/type.d.ts +15 -0
- package/dist/lib/ast/find.d.ts +165 -0
- package/dist/lib/ast/find.js +175 -0
- package/dist/lib/ast/math/expression.d.ts +18 -0
- package/dist/lib/ast/math/expression.js +140 -98
- package/dist/lib/ast/math/math.d.ts +6 -0
- package/dist/lib/ast/math/math.js +30 -41
- package/dist/lib/ast/minify.d.ts +19 -0
- package/dist/lib/ast/minify.js +541 -217
- package/dist/lib/ast/transform/compute.d.ts +8 -0
- package/dist/lib/ast/transform/compute.js +82 -69
- package/dist/lib/ast/transform/matrix.d.ts +22 -0
- package/dist/lib/ast/transform/matrix.js +12 -26
- package/dist/lib/ast/transform/minify.d.ts +5 -0
- package/dist/lib/ast/transform/minify.js +20 -20
- package/dist/lib/ast/transform/perspective.d.ts +3 -0
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.d.ts +12 -0
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.d.ts +6 -0
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.d.ts +4 -0
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.d.ts +6 -0
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.d.ts +9 -0
- package/dist/lib/ast/types.d.ts +903 -0
- package/dist/lib/ast/types.js +277 -23
- package/dist/lib/ast/walk.d.ts +162 -0
- package/dist/lib/ast/walk.js +116 -60
- package/dist/lib/fs/resolve.d.ts +20 -0
- package/dist/lib/fs/resolve.js +37 -45
- package/dist/lib/parser/declaration/list.d.ts +16 -0
- package/dist/lib/parser/declaration/list.js +26 -24
- package/dist/lib/parser/declaration/map.d.ts +15 -0
- package/dist/lib/parser/declaration/map.js +140 -95
- package/dist/lib/parser/declaration/set.d.ts +9 -0
- package/dist/lib/parser/declaration/set.js +30 -25
- package/dist/lib/parser/node.d.ts +7 -0
- package/dist/lib/parser/parse.d.ts +107 -0
- package/dist/lib/parser/parse.js +1454 -1445
- package/dist/lib/parser/tokenize.d.ts +57 -0
- package/dist/lib/parser/tokenize.js +557 -404
- package/dist/lib/parser/utils/at-rule-container.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-container.js +486 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +13 -0
- package/dist/lib/parser/utils/at-rule-generic.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-generic.js +118 -0
- package/dist/lib/parser/utils/at-rule-import.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-import.js +393 -0
- package/dist/lib/parser/utils/at-rule-media.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-media.js +603 -0
- package/dist/lib/parser/utils/at-rule-page.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-page.js +28 -0
- package/dist/lib/parser/utils/at-rule-support.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-support.js +366 -0
- package/dist/lib/parser/utils/at-rule-token.d.ts +1 -0
- package/dist/lib/parser/utils/at-rule-when-else.d.ts +5 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +363 -0
- package/dist/lib/parser/utils/at-rule.d.ts +13 -0
- package/dist/lib/parser/utils/at-rule.js +37 -0
- package/dist/lib/parser/utils/cache.d.ts +6 -0
- package/dist/lib/parser/utils/cache.js +19 -0
- package/dist/lib/parser/utils/config.d.ts +2 -0
- package/dist/lib/parser/utils/config.js +1 -0
- package/dist/lib/parser/utils/declaration-list.d.ts +5 -0
- package/dist/lib/parser/utils/declaration.d.ts +18 -0
- package/dist/lib/parser/utils/declaration.js +569 -91
- package/dist/lib/parser/utils/eq.d.ts +1 -0
- package/dist/lib/parser/utils/hash.d.ts +21 -0
- package/dist/lib/parser/utils/hash.js +1 -1
- package/dist/lib/parser/utils/selector.d.ts +5 -0
- package/dist/lib/parser/utils/selector.js +476 -0
- package/dist/lib/parser/utils/text.d.ts +3 -0
- package/dist/lib/parser/utils/text.js +17 -1
- package/dist/lib/parser/utils/token.d.ts +14 -0
- package/dist/lib/parser/utils/token.js +102 -0
- package/dist/lib/parser/utils/type.d.ts +2 -0
- package/dist/lib/parser/utils/type.js +29 -18
- package/dist/lib/renderer/render.d.ts +28 -0
- package/dist/lib/renderer/render.js +421 -262
- package/dist/lib/renderer/sourcemap/lib/encode.d.ts +1 -0
- package/dist/lib/renderer/sourcemap/sourcemap.d.ts +26 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +17 -7
- package/dist/lib/syntax/color/a98rgb.d.ts +2 -0
- package/dist/lib/syntax/color/a98rgb.js +8 -12
- package/dist/lib/syntax/color/cmyk.d.ts +10 -0
- package/dist/lib/syntax/color/cmyk.js +23 -21
- package/dist/lib/syntax/color/color-mix.d.ts +2 -0
- package/dist/lib/syntax/color/color-mix.js +88 -77
- package/dist/lib/syntax/color/color.d.ts +42 -0
- package/dist/lib/syntax/color/color.js +65 -68
- package/dist/lib/syntax/color/hex.d.ts +16 -0
- package/dist/lib/syntax/color/hex.js +27 -31
- package/dist/lib/syntax/color/hsl.d.ts +20 -0
- package/dist/lib/syntax/color/hsl.js +5 -12
- package/dist/lib/syntax/color/hsv.d.ts +2 -0
- package/dist/lib/syntax/color/hwb.d.ts +21 -0
- package/dist/lib/syntax/color/hwb.js +8 -21
- package/dist/lib/syntax/color/lab.d.ts +25 -0
- package/dist/lib/syntax/color/lab.js +20 -21
- package/dist/lib/syntax/color/lch.d.ts +23 -0
- package/dist/lib/syntax/color/lch.js +13 -15
- package/dist/lib/syntax/color/oklab.d.ts +22 -0
- package/dist/lib/syntax/color/oklab.js +20 -39
- package/dist/lib/syntax/color/oklch.d.ts +20 -0
- package/dist/lib/syntax/color/oklch.js +14 -16
- package/dist/lib/syntax/color/p3.d.ts +6 -0
- package/dist/lib/syntax/color/p3.js +0 -8
- package/dist/lib/syntax/color/prophotorgb.d.ts +2 -0
- package/dist/lib/syntax/color/rec2020.d.ts +2 -0
- package/dist/lib/syntax/color/rec2020.js +9 -13
- package/dist/lib/syntax/color/relativecolor.d.ts +13 -0
- package/dist/lib/syntax/color/relativecolor.js +68 -41
- package/dist/lib/syntax/color/rgb.d.ts +20 -0
- package/dist/lib/syntax/color/rgb.js +14 -18
- package/dist/lib/syntax/color/srgb.d.ts +23 -0
- package/dist/lib/syntax/color/srgb.js +27 -26
- package/dist/lib/syntax/color/utils/components.d.ts +2 -0
- package/dist/lib/syntax/color/utils/components.js +30 -14
- package/dist/lib/syntax/color/utils/distance.d.ts +18 -0
- package/dist/lib/syntax/color/utils/distance.js +1 -8
- package/dist/lib/syntax/color/utils/matrix.d.ts +6 -0
- package/dist/lib/syntax/color/xyz.d.ts +5 -0
- package/dist/lib/syntax/color/xyz.js +8 -20
- package/dist/lib/syntax/color/xyzd50.d.ts +4 -0
- package/dist/lib/syntax/color/xyzd50.js +6 -20
- package/dist/lib/syntax/constants.d.ts +67 -0
- package/dist/lib/syntax/constants.js +436 -0
- package/dist/lib/syntax/syntax.d.ts +38 -0
- package/dist/lib/syntax/syntax.js +533 -568
- package/dist/lib/validation/config.d.ts +14 -0
- package/dist/lib/validation/config.js +72 -33
- package/dist/lib/validation/config.json.js +1159 -74
- package/dist/lib/validation/json.d.ts +2 -0
- package/dist/lib/validation/match.d.ts +38 -0
- package/dist/lib/validation/match.js +2985 -0
- package/dist/lib/validation/parser/parse.d.ts +8 -0
- package/dist/lib/validation/parser/parse.js +684 -935
- package/dist/lib/validation/parser/typedef.d.ts +95 -0
- package/dist/lib/validation/parser/typedef.js +100 -0
- package/dist/lib/validation/utils/list.d.ts +4 -0
- package/dist/lib/validation/utils/list.js +4 -11
- package/dist/lib/validation/utils/whitespace.d.ts +2 -0
- package/dist/lib/validation/utils/whitespace.js +2 -8
- package/dist/node.d.ts +207 -0
- package/dist/node.js +42 -39
- package/dist/web.d.ts +169 -0
- package/dist/web.js +38 -33
- package/package.json +15 -12
- package/playground/index.html +1328 -0
- package/playground/sw.js +55 -0
- package/playground/tree.js +176 -0
- package/dist/lib/syntax/color/utils/constants.js +0 -214
- package/dist/lib/syntax/utils.js +0 -70
- package/dist/lib/validation/at-rules/container.js +0 -342
- package/dist/lib/validation/at-rules/counter-style.js +0 -90
- package/dist/lib/validation/at-rules/custom-media.js +0 -50
- package/dist/lib/validation/at-rules/document.js +0 -89
- package/dist/lib/validation/at-rules/else.js +0 -5
- package/dist/lib/validation/at-rules/font-feature-values.js +0 -63
- package/dist/lib/validation/at-rules/import.js +0 -150
- package/dist/lib/validation/at-rules/keyframes.js +0 -67
- package/dist/lib/validation/at-rules/layer.js +0 -41
- package/dist/lib/validation/at-rules/media.js +0 -255
- package/dist/lib/validation/at-rules/namespace.js +0 -81
- package/dist/lib/validation/at-rules/page-margin-box.js +0 -64
- package/dist/lib/validation/at-rules/page.js +0 -100
- package/dist/lib/validation/at-rules/supports.js +0 -295
- package/dist/lib/validation/at-rules/when.js +0 -185
- package/dist/lib/validation/atrule.js +0 -184
- package/dist/lib/validation/selector.js +0 -36
- package/dist/lib/validation/syntax.js +0 -1073
- package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -27
- package/dist/lib/validation/syntaxes/complex-selector.js +0 -52
- package/dist/lib/validation/syntaxes/compound-selector.js +0 -196
- package/dist/lib/validation/syntaxes/family-name.js +0 -57
- package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -36
- package/dist/lib/validation/syntaxes/layer-name.js +0 -57
- package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -31
- package/dist/lib/validation/syntaxes/relative-selector.js +0 -38
- package/dist/lib/validation/syntaxes/selector-list.js +0 -5
- package/dist/lib/validation/syntaxes/selector.js +0 -5
- package/dist/lib/validation/syntaxes/url.js +0 -40
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { lsrgb2srgbvalues } from './srgb.js';
|
|
2
2
|
import { multiplyMatrices } from './utils/matrix.js';
|
|
3
|
-
import './utils/constants.js';
|
|
4
|
-
import '../../ast/types.js';
|
|
5
|
-
import '../../ast/minify.js';
|
|
6
|
-
import '../../ast/walk.js';
|
|
7
|
-
import '../../parser/parse.js';
|
|
8
|
-
import '../../parser/tokenize.js';
|
|
9
|
-
import '../../parser/utils/config.js';
|
|
10
3
|
import { xyz2lab } from './lab.js';
|
|
11
|
-
import { labvalues2lchvalues } from './lch.js';
|
|
12
4
|
import { XYZ_D50_to_D65 } from './xyz.js';
|
|
13
|
-
import '
|
|
5
|
+
import { labvalues2lchvalues } from './lch.js';
|
|
14
6
|
|
|
15
7
|
/*
|
|
16
|
-
*/
|
|
8
|
+
*/
|
|
17
9
|
function xyzd502lch(x, y, z, alpha) {
|
|
18
10
|
// @ts-ignore
|
|
19
11
|
const [l, a, b] = xyz2lab(...XYZ_D50_to_D65(x, y, z));
|
|
@@ -30,7 +22,7 @@ function XYZ_D65_to_D50(x, y, z, alpha = null) {
|
|
|
30
22
|
let M = [
|
|
31
23
|
[1.0479297925449969, 0.022946870601609652, -0.05019226628920524],
|
|
32
24
|
[0.02962780877005599, 0.9904344267538799, -0.017073799063418826],
|
|
33
|
-
[-0.009243040646204504, 0.015055191490298152, 0.7518742814281371]
|
|
25
|
+
[-0.009243040646204504, 0.015055191490298152, 0.7518742814281371],
|
|
34
26
|
];
|
|
35
27
|
return multiplyMatrices(M, [x, y, z]).concat(alpha == null || alpha == 1 ? [] : [alpha]);
|
|
36
28
|
}
|
|
@@ -38,17 +30,11 @@ function xyzd502srgb(x, y, z, alpha = null) {
|
|
|
38
30
|
// @ts-ignore
|
|
39
31
|
return lsrgb2srgbvalues(
|
|
40
32
|
/* r: */
|
|
41
|
-
x * 3.1341359569958707 -
|
|
42
|
-
y * 1.6173863321612538 -
|
|
43
|
-
0.4906619460083532 * z,
|
|
33
|
+
x * 3.1341359569958707 - y * 1.6173863321612538 - 0.4906619460083532 * z,
|
|
44
34
|
/* g: */
|
|
45
|
-
x * -0.978795502912089 +
|
|
46
|
-
y * 1.916254567259524 +
|
|
47
|
-
0.03344273116131949 * z,
|
|
35
|
+
x * -0.978795502912089 + y * 1.916254567259524 + 0.03344273116131949 * z,
|
|
48
36
|
/* b: */
|
|
49
|
-
x * 0.07195537988411677 -
|
|
50
|
-
y * 0.2289768264158322 +
|
|
51
|
-
1.405386058324125 * z, alpha);
|
|
37
|
+
x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z, alpha);
|
|
52
38
|
}
|
|
53
39
|
|
|
54
40
|
export { XYZ_D65_to_D50, xyzd502lch, xyzd502srgb };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { EnumToken } from "../ast/types.ts";
|
|
2
|
+
export declare const mFLT: Set<EnumToken>;
|
|
3
|
+
export declare const mFGT: Set<EnumToken>;
|
|
4
|
+
export declare const tokensMap: Map<EnumToken, EnumToken>;
|
|
5
|
+
export declare const urlTokenMatcher: RegExp;
|
|
6
|
+
export declare const tokensfuncDefMap: Map<EnumToken, EnumToken>;
|
|
7
|
+
export declare const tokensfuncSet: Set<EnumToken>;
|
|
8
|
+
export declare const colorPrecision = 6;
|
|
9
|
+
export declare const anglePrecision = 0.001;
|
|
10
|
+
export declare const colorRange: {
|
|
11
|
+
lab: {
|
|
12
|
+
l: number[];
|
|
13
|
+
a: number[];
|
|
14
|
+
b: number[];
|
|
15
|
+
};
|
|
16
|
+
lch: {
|
|
17
|
+
l: number[];
|
|
18
|
+
c: number[];
|
|
19
|
+
h: number[];
|
|
20
|
+
};
|
|
21
|
+
oklab: {
|
|
22
|
+
l: number[];
|
|
23
|
+
a: number[];
|
|
24
|
+
b: number[];
|
|
25
|
+
};
|
|
26
|
+
oklch: {
|
|
27
|
+
l: number[];
|
|
28
|
+
a: number[];
|
|
29
|
+
b: number[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const wildCardFuncs: string[];
|
|
33
|
+
export declare const mathFuncs: string[];
|
|
34
|
+
export declare const mediaTypes: string[];
|
|
35
|
+
export declare const pageMarginBoxType: Set<string>;
|
|
36
|
+
export declare const urlFunc: string[];
|
|
37
|
+
export declare const timelineFunc: string[];
|
|
38
|
+
export declare const gridTemplateFunc: string[];
|
|
39
|
+
export declare const generalEnclosedFunc: string[];
|
|
40
|
+
export declare const supportFunc: string[];
|
|
41
|
+
export declare const whenElseFunc: string[];
|
|
42
|
+
export declare const containerFunc: string[];
|
|
43
|
+
export declare const timingFunc: string[];
|
|
44
|
+
export declare const colorsFunc: string[];
|
|
45
|
+
export declare const imageFunc: string[];
|
|
46
|
+
export declare const transformFunctions: string[];
|
|
47
|
+
export declare const funcLike: EnumToken[];
|
|
48
|
+
export declare const colorFuncColorSpace: string[];
|
|
49
|
+
export declare const D50: number[];
|
|
50
|
+
export declare const k: number;
|
|
51
|
+
export declare const e: number;
|
|
52
|
+
export declare const nonStandardColors: Set<string>;
|
|
53
|
+
export declare const systemColors: Set<string>;
|
|
54
|
+
export declare const deprecatedSystemColors: Set<string>;
|
|
55
|
+
export declare const COLORS_NAMES: {
|
|
56
|
+
[key: string]: string;
|
|
57
|
+
};
|
|
58
|
+
export declare const NAMES_COLORS: {
|
|
59
|
+
[key: string]: string;
|
|
60
|
+
};
|
|
61
|
+
export declare const trimTokenSpace: Set<EnumToken>;
|
|
62
|
+
export declare const definedPropertySettings: {
|
|
63
|
+
configurable: boolean;
|
|
64
|
+
enumerable: boolean;
|
|
65
|
+
writable: boolean;
|
|
66
|
+
};
|
|
67
|
+
export declare const combinators: string[];
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { EnumToken } from '../ast/types.js';
|
|
2
|
+
import config from '../validation/config.json.js';
|
|
3
|
+
|
|
4
|
+
const mFLT = new Set([EnumToken.LtTokenType, EnumToken.LteTokenType]);
|
|
5
|
+
const mFGT = new Set([EnumToken.GtTokenType, EnumToken.GteTokenType]);
|
|
6
|
+
const tokensMap = new Map([
|
|
7
|
+
[EnumToken.Star, EnumToken.Mul],
|
|
8
|
+
[EnumToken.Plus, EnumToken.Add],
|
|
9
|
+
]);
|
|
10
|
+
const urlTokenMatcher = /^(["']?)[a-zA-Z0-9_/.-][a-zA-Z0-9_/:.#?-]+(\1)$/;
|
|
11
|
+
const tokensfuncDefMap = new Map([
|
|
12
|
+
[EnumToken.FunctionTokenDefType, EnumToken.FunctionTokenType],
|
|
13
|
+
[EnumToken.ColorFunctionTokenDefType, EnumToken.ColorTokenType],
|
|
14
|
+
[EnumToken.UrlFunctionTokenDefType, EnumToken.UrlFunctionTokenType],
|
|
15
|
+
[EnumToken.MathFunctionTokenDefType, EnumToken.MathFunctionTokenType],
|
|
16
|
+
[EnumToken.ImageFunctionTokenDefType, EnumToken.ImageFunctionTokenType],
|
|
17
|
+
[EnumToken.TimingFunctionTokenDefType, EnumToken.TimingFunctionTokenType],
|
|
18
|
+
[EnumToken.CustomFunctionTokenDefType, EnumToken.CustomFunctionTokenType],
|
|
19
|
+
[EnumToken.WildCardFunctionTokenDefType, EnumToken.WildCardFunctionTokenType],
|
|
20
|
+
[EnumToken.TimelineFunctionTokenDefType, EnumToken.TimelineFunctionTokenType],
|
|
21
|
+
[EnumToken.GridTemplateFuncTokenDefType, EnumToken.GridTemplateFuncTokenType],
|
|
22
|
+
[EnumToken.SupportsFunctionTokenDefType, EnumToken.SupportsFunctionTokenType],
|
|
23
|
+
[EnumToken.WhenElseFunctionTokenDefType, EnumToken.WhenElseFunctionTokenType],
|
|
24
|
+
[EnumToken.ContainerFunctionTokenDefType, EnumToken.ContainerFunctionTokenType],
|
|
25
|
+
[EnumToken.PseudoClassFunctionTokenDefType, EnumToken.PseudoClassFuncTokenType],
|
|
26
|
+
[EnumToken.TransformFunctionTokenDefType, EnumToken.TransformFunctionTokenType],
|
|
27
|
+
[EnumToken.GeneralEnclosedFunctionTokenDefType, EnumToken.GeneralEnclosedFunctionTokenType],
|
|
28
|
+
]);
|
|
29
|
+
const tokensfuncSet = new Set(tokensfuncDefMap.values());
|
|
30
|
+
const colorPrecision = 6;
|
|
31
|
+
const anglePrecision = 0.001;
|
|
32
|
+
const colorRange = {
|
|
33
|
+
lab: {
|
|
34
|
+
l: [0, 100],
|
|
35
|
+
a: [-125, 125],
|
|
36
|
+
b: [-125, 125],
|
|
37
|
+
},
|
|
38
|
+
lch: {
|
|
39
|
+
l: [0, 100],
|
|
40
|
+
c: [0, 150],
|
|
41
|
+
h: [0, 360],
|
|
42
|
+
},
|
|
43
|
+
oklab: {
|
|
44
|
+
l: [0, 1],
|
|
45
|
+
a: [-0.4, 0.4],
|
|
46
|
+
b: [-0.4, 0.4],
|
|
47
|
+
},
|
|
48
|
+
oklch: {
|
|
49
|
+
l: [0, 1],
|
|
50
|
+
a: [0, 0.4],
|
|
51
|
+
b: [0, 0.4],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const wildCardFuncs = ["var", "env", "if"];
|
|
55
|
+
const mathFuncs = [
|
|
56
|
+
"minmax",
|
|
57
|
+
"repeat",
|
|
58
|
+
"fit-content",
|
|
59
|
+
"calc",
|
|
60
|
+
"clamp",
|
|
61
|
+
"min",
|
|
62
|
+
"max",
|
|
63
|
+
"round",
|
|
64
|
+
"mod",
|
|
65
|
+
"rem",
|
|
66
|
+
"sin",
|
|
67
|
+
"cos",
|
|
68
|
+
"tan",
|
|
69
|
+
"asin",
|
|
70
|
+
"acos",
|
|
71
|
+
"atan",
|
|
72
|
+
"atan2",
|
|
73
|
+
"pow",
|
|
74
|
+
"sqrt",
|
|
75
|
+
"hypot",
|
|
76
|
+
"log",
|
|
77
|
+
"exp",
|
|
78
|
+
"abs",
|
|
79
|
+
"sign",
|
|
80
|
+
"anchor",
|
|
81
|
+
];
|
|
82
|
+
// export const fontFormat: string[] = ['collection', 'embedded-opentype', 'opentype', 'svg', 'truetype', 'woff', 'woff2'];
|
|
83
|
+
// export const colorFontTech: string[] = ['color-colrv0', 'color-colrv1', 'color-svg', 'color-sbix', 'color-cbdt'];
|
|
84
|
+
// export const fontFeaturesTech: string[] = ['features-opentype', 'features-aat', 'features-graphite', 'incremental-patch', 'incremental-range', 'incremental-auto', 'variations', 'palettes'];
|
|
85
|
+
// https://drafts.csswg.org/mediaqueries/#media-types
|
|
86
|
+
const mediaTypes = [
|
|
87
|
+
"all",
|
|
88
|
+
"print",
|
|
89
|
+
"screen",
|
|
90
|
+
/* deprecated */
|
|
91
|
+
"aural",
|
|
92
|
+
"braille",
|
|
93
|
+
"embossed",
|
|
94
|
+
"handheld",
|
|
95
|
+
"projection",
|
|
96
|
+
"tty",
|
|
97
|
+
"tv",
|
|
98
|
+
"speech",
|
|
99
|
+
];
|
|
100
|
+
const pageMarginBoxType = new Set([
|
|
101
|
+
"top-left-corner",
|
|
102
|
+
"top-left",
|
|
103
|
+
"top-center",
|
|
104
|
+
"top-right",
|
|
105
|
+
"top-right-corner",
|
|
106
|
+
"bottom-left-corner",
|
|
107
|
+
"bottom-left",
|
|
108
|
+
"bottom-center",
|
|
109
|
+
"bottom-right",
|
|
110
|
+
"bottom-right-corner",
|
|
111
|
+
"left-top",
|
|
112
|
+
"left-middle",
|
|
113
|
+
"left-bottom",
|
|
114
|
+
"right-top",
|
|
115
|
+
"right-middle",
|
|
116
|
+
"right-bottom",
|
|
117
|
+
]);
|
|
118
|
+
const urlFunc = ["url"];
|
|
119
|
+
const timelineFunc = ["view", "scroll"];
|
|
120
|
+
const gridTemplateFunc = ["minmax", "fit-content", "repeat"];
|
|
121
|
+
const generalEnclosedFunc = [];
|
|
122
|
+
const supportFunc = ["selector", "font-tech", "font-format", "at-rule", "named-feature"];
|
|
123
|
+
const whenElseFunc = ["media", "supports"];
|
|
124
|
+
const containerFunc = ["style", "scroll-state"];
|
|
125
|
+
const timingFunc = [
|
|
126
|
+
"ease",
|
|
127
|
+
"ease-in",
|
|
128
|
+
"ease-out",
|
|
129
|
+
"ease-in-out",
|
|
130
|
+
"linear",
|
|
131
|
+
"step-start",
|
|
132
|
+
"step-end",
|
|
133
|
+
"steps",
|
|
134
|
+
"cubic-bezier",
|
|
135
|
+
];
|
|
136
|
+
const colorsFunc = [
|
|
137
|
+
"rgb",
|
|
138
|
+
"rgba",
|
|
139
|
+
"hsl",
|
|
140
|
+
"hsla",
|
|
141
|
+
"hwb",
|
|
142
|
+
"device-cmyk",
|
|
143
|
+
"color-mix",
|
|
144
|
+
"color",
|
|
145
|
+
"oklab",
|
|
146
|
+
"lab",
|
|
147
|
+
"oklch",
|
|
148
|
+
"lch",
|
|
149
|
+
"light-dark",
|
|
150
|
+
"contrast-color",
|
|
151
|
+
];
|
|
152
|
+
const imageFunc = [
|
|
153
|
+
"linear-gradient",
|
|
154
|
+
"radial-gradient",
|
|
155
|
+
"repeating-linear-gradient",
|
|
156
|
+
"repeating-radial-gradient",
|
|
157
|
+
"conic-gradient",
|
|
158
|
+
"image",
|
|
159
|
+
"image-set",
|
|
160
|
+
"element",
|
|
161
|
+
"cross-fade",
|
|
162
|
+
"paint",
|
|
163
|
+
];
|
|
164
|
+
const transformFunctions = [
|
|
165
|
+
"translate",
|
|
166
|
+
"scale",
|
|
167
|
+
"rotate",
|
|
168
|
+
"skew",
|
|
169
|
+
"perspective",
|
|
170
|
+
"translateX",
|
|
171
|
+
"translateY",
|
|
172
|
+
"translateZ",
|
|
173
|
+
"scaleX",
|
|
174
|
+
"scaleY",
|
|
175
|
+
"scaleZ",
|
|
176
|
+
"rotateX",
|
|
177
|
+
"rotateY",
|
|
178
|
+
"rotateZ",
|
|
179
|
+
"skewX",
|
|
180
|
+
"skewY",
|
|
181
|
+
"rotate3d",
|
|
182
|
+
"translate3d",
|
|
183
|
+
"scale3d",
|
|
184
|
+
"matrix",
|
|
185
|
+
"matrix3d",
|
|
186
|
+
];
|
|
187
|
+
const funcLike = [
|
|
188
|
+
EnumToken.ParensTokenType,
|
|
189
|
+
EnumToken.FunctionTokenType,
|
|
190
|
+
EnumToken.UrlFunctionTokenType,
|
|
191
|
+
EnumToken.StartParensTokenType,
|
|
192
|
+
EnumToken.ImageFunctionTokenType,
|
|
193
|
+
EnumToken.TimingFunctionTokenType,
|
|
194
|
+
EnumToken.TimingFunctionTokenType,
|
|
195
|
+
EnumToken.PseudoClassFuncTokenType,
|
|
196
|
+
EnumToken.GridTemplateFuncTokenType,
|
|
197
|
+
];
|
|
198
|
+
const colorFuncColorSpace = [
|
|
199
|
+
"srgb",
|
|
200
|
+
"srgb-linear",
|
|
201
|
+
"display-p3",
|
|
202
|
+
"prophoto-rgb",
|
|
203
|
+
"a98-rgb",
|
|
204
|
+
"rec2020",
|
|
205
|
+
"xyz",
|
|
206
|
+
"xyz-d65",
|
|
207
|
+
"xyz-d50",
|
|
208
|
+
];
|
|
209
|
+
const D50 = [0.3457 / 0.3585, 1.0, (1.0 - 0.3457 - 0.3585) / 0.3585];
|
|
210
|
+
const k = Math.pow(29, 3) / Math.pow(3, 3);
|
|
211
|
+
const e = Math.pow(6, 3) / Math.pow(29, 3);
|
|
212
|
+
const nonStandardColors = new Set(config.syntaxes["-non-standard-color"].syntax.split(/[\s|]+/g).map((m) => m.toLowerCase()));
|
|
213
|
+
// color module v4
|
|
214
|
+
const systemColors = new Set([
|
|
215
|
+
"ActiveText",
|
|
216
|
+
"ButtonBorder",
|
|
217
|
+
"ButtonFace",
|
|
218
|
+
"ButtonText",
|
|
219
|
+
"Canvas",
|
|
220
|
+
"CanvasText",
|
|
221
|
+
"Field",
|
|
222
|
+
"FieldText",
|
|
223
|
+
"GrayText",
|
|
224
|
+
"Highlight",
|
|
225
|
+
"HighlightText",
|
|
226
|
+
"LinkText",
|
|
227
|
+
"Mark",
|
|
228
|
+
"MarkText",
|
|
229
|
+
"VisitedText",
|
|
230
|
+
"-webkit-focus-ring-color",
|
|
231
|
+
].map((m) => m.toLowerCase()));
|
|
232
|
+
// deprecated
|
|
233
|
+
const deprecatedSystemColors = new Set([
|
|
234
|
+
"ActiveBorder",
|
|
235
|
+
"ActiveCaption",
|
|
236
|
+
"AppWorkspace",
|
|
237
|
+
"Background",
|
|
238
|
+
"ButtonFace",
|
|
239
|
+
"ButtonHighlight",
|
|
240
|
+
"ButtonShadow",
|
|
241
|
+
"ButtonText",
|
|
242
|
+
"CaptionText",
|
|
243
|
+
"GrayText",
|
|
244
|
+
"Highlight",
|
|
245
|
+
"HighlightText",
|
|
246
|
+
"InactiveBorder",
|
|
247
|
+
"InactiveCaption",
|
|
248
|
+
"InactiveCaptionText",
|
|
249
|
+
"InfoBackground",
|
|
250
|
+
"InfoText",
|
|
251
|
+
"Menu",
|
|
252
|
+
"MenuText",
|
|
253
|
+
"Scrollbar",
|
|
254
|
+
"ThreeDDarkShadow",
|
|
255
|
+
"ThreeDFace",
|
|
256
|
+
"ThreeDHighlight",
|
|
257
|
+
"ThreeDLightShadow",
|
|
258
|
+
"ThreeDShadow",
|
|
259
|
+
"Window",
|
|
260
|
+
"WindowFrame",
|
|
261
|
+
"WindowText",
|
|
262
|
+
].map((t) => t.toLowerCase()));
|
|
263
|
+
// name to color
|
|
264
|
+
const COLORS_NAMES = Object.seal({
|
|
265
|
+
aliceblue: "#f0f8ff",
|
|
266
|
+
antiquewhite: "#faebd7",
|
|
267
|
+
aqua: "#00ffff",
|
|
268
|
+
aquamarine: "#7fffd4",
|
|
269
|
+
azure: "#f0ffff",
|
|
270
|
+
beige: "#f5f5dc",
|
|
271
|
+
bisque: "#ffe4c4",
|
|
272
|
+
black: "#000000",
|
|
273
|
+
blanchedalmond: "#ffebcd",
|
|
274
|
+
blue: "#0000ff",
|
|
275
|
+
blueviolet: "#8a2be2",
|
|
276
|
+
brown: "#a52a2a",
|
|
277
|
+
burlywood: "#deb887",
|
|
278
|
+
cadetblue: "#5f9ea0",
|
|
279
|
+
chartreuse: "#7fff00",
|
|
280
|
+
chocolate: "#d2691e",
|
|
281
|
+
coral: "#ff7f50",
|
|
282
|
+
cornflowerblue: "#6495ed",
|
|
283
|
+
cornsilk: "#fff8dc",
|
|
284
|
+
crimson: "#dc143c",
|
|
285
|
+
cyan: "#00ffff",
|
|
286
|
+
darkblue: "#00008b",
|
|
287
|
+
darkcyan: "#008b8b",
|
|
288
|
+
darkgoldenrod: "#b8860b",
|
|
289
|
+
darkgray: "#a9a9a9",
|
|
290
|
+
darkgrey: "#a9a9a9",
|
|
291
|
+
darkgreen: "#006400",
|
|
292
|
+
darkkhaki: "#bdb76b",
|
|
293
|
+
darkmagenta: "#8b008b",
|
|
294
|
+
darkolivegreen: "#556b2f",
|
|
295
|
+
darkorange: "#ff8c00",
|
|
296
|
+
darkorchid: "#9932cc",
|
|
297
|
+
darkred: "#8b0000",
|
|
298
|
+
darksalmon: "#e9967a",
|
|
299
|
+
darkseagreen: "#8fbc8f",
|
|
300
|
+
darkslateblue: "#483d8b",
|
|
301
|
+
darkslategray: "#2f4f4f",
|
|
302
|
+
darkslategrey: "#2f4f4f",
|
|
303
|
+
darkturquoise: "#00ced1",
|
|
304
|
+
darkviolet: "#9400d3",
|
|
305
|
+
deeppink: "#ff1493",
|
|
306
|
+
deepskyblue: "#00bfff",
|
|
307
|
+
dimgray: "#696969",
|
|
308
|
+
dimgrey: "#696969",
|
|
309
|
+
dodgerblue: "#1e90ff",
|
|
310
|
+
firebrick: "#b22222",
|
|
311
|
+
floralwhite: "#fffaf0",
|
|
312
|
+
forestgreen: "#228b22",
|
|
313
|
+
fuchsia: "#ff00ff",
|
|
314
|
+
gainsboro: "#dcdcdc",
|
|
315
|
+
ghostwhite: "#f8f8ff",
|
|
316
|
+
gold: "#ffd700",
|
|
317
|
+
goldenrod: "#daa520",
|
|
318
|
+
gray: "#808080",
|
|
319
|
+
grey: "#808080",
|
|
320
|
+
green: "#008000",
|
|
321
|
+
greenyellow: "#adff2f",
|
|
322
|
+
honeydew: "#f0fff0",
|
|
323
|
+
hotpink: "#ff69b4",
|
|
324
|
+
indianred: "#cd5c5c",
|
|
325
|
+
indigo: "#4b0082",
|
|
326
|
+
ivory: "#fffff0",
|
|
327
|
+
khaki: "#f0e68c",
|
|
328
|
+
lavender: "#e6e6fa",
|
|
329
|
+
lavenderblush: "#fff0f5",
|
|
330
|
+
lawngreen: "#7cfc00",
|
|
331
|
+
lemonchiffon: "#fffacd",
|
|
332
|
+
lightblue: "#add8e6",
|
|
333
|
+
lightcoral: "#f08080",
|
|
334
|
+
lightcyan: "#e0ffff",
|
|
335
|
+
lightgoldenrodyellow: "#fafad2",
|
|
336
|
+
lightgray: "#d3d3d3",
|
|
337
|
+
lightgrey: "#d3d3d3",
|
|
338
|
+
lightgreen: "#90ee90",
|
|
339
|
+
lightpink: "#ffb6c1",
|
|
340
|
+
lightsalmon: "#ffa07a",
|
|
341
|
+
lightseagreen: "#20b2aa",
|
|
342
|
+
lightskyblue: "#87cefa",
|
|
343
|
+
lightslategray: "#778899",
|
|
344
|
+
lightslategrey: "#778899",
|
|
345
|
+
lightsteelblue: "#b0c4de",
|
|
346
|
+
lightyellow: "#ffffe0",
|
|
347
|
+
lime: "#00ff00",
|
|
348
|
+
limegreen: "#32cd32",
|
|
349
|
+
linen: "#faf0e6",
|
|
350
|
+
magenta: "#ff00ff",
|
|
351
|
+
maroon: "#800000",
|
|
352
|
+
mediumaquamarine: "#66cdaa",
|
|
353
|
+
mediumblue: "#0000cd",
|
|
354
|
+
mediumorchid: "#ba55d3",
|
|
355
|
+
mediumpurple: "#9370d8",
|
|
356
|
+
mediumseagreen: "#3cb371",
|
|
357
|
+
mediumslateblue: "#7b68ee",
|
|
358
|
+
mediumspringgreen: "#00fa9a",
|
|
359
|
+
mediumturquoise: "#48d1cc",
|
|
360
|
+
mediumvioletred: "#c71585",
|
|
361
|
+
midnightblue: "#191970",
|
|
362
|
+
mintcream: "#f5fffa",
|
|
363
|
+
mistyrose: "#ffe4e1",
|
|
364
|
+
moccasin: "#ffe4b5",
|
|
365
|
+
navajowhite: "#ffdead",
|
|
366
|
+
navy: "#000080",
|
|
367
|
+
oldlace: "#fdf5e6",
|
|
368
|
+
olive: "#808000",
|
|
369
|
+
olivedrab: "#6b8e23",
|
|
370
|
+
orange: "#ffa500",
|
|
371
|
+
orangered: "#ff4500",
|
|
372
|
+
orchid: "#da70d6",
|
|
373
|
+
palegoldenrod: "#eee8aa",
|
|
374
|
+
palegreen: "#98fb98",
|
|
375
|
+
paleturquoise: "#afeeee",
|
|
376
|
+
palevioletred: "#d87093",
|
|
377
|
+
papayawhip: "#ffefd5",
|
|
378
|
+
peachpuff: "#ffdab9",
|
|
379
|
+
peru: "#cd853f",
|
|
380
|
+
pink: "#ffc0cb",
|
|
381
|
+
plum: "#dda0dd",
|
|
382
|
+
powderblue: "#b0e0e6",
|
|
383
|
+
purple: "#800080",
|
|
384
|
+
red: "#ff0000",
|
|
385
|
+
rosybrown: "#bc8f8f",
|
|
386
|
+
royalblue: "#4169e1",
|
|
387
|
+
saddlebrown: "#8b4513",
|
|
388
|
+
salmon: "#fa8072",
|
|
389
|
+
sandybrown: "#f4a460",
|
|
390
|
+
seagreen: "#2e8b57",
|
|
391
|
+
seashell: "#fff5ee",
|
|
392
|
+
sienna: "#a0522d",
|
|
393
|
+
silver: "#c0c0c0",
|
|
394
|
+
skyblue: "#87ceeb",
|
|
395
|
+
slateblue: "#6a5acd",
|
|
396
|
+
slategray: "#708090",
|
|
397
|
+
slategrey: "#708090",
|
|
398
|
+
snow: "#fffafa",
|
|
399
|
+
springgreen: "#00ff7f",
|
|
400
|
+
steelblue: "#4682b4",
|
|
401
|
+
tan: "#d2b48c",
|
|
402
|
+
teal: "#008080",
|
|
403
|
+
thistle: "#d8bfd8",
|
|
404
|
+
tomato: "#ff6347",
|
|
405
|
+
turquoise: "#40e0d0",
|
|
406
|
+
violet: "#ee82ee",
|
|
407
|
+
wheat: "#f5deb3",
|
|
408
|
+
white: "#ffffff",
|
|
409
|
+
whitesmoke: "#f5f5f5",
|
|
410
|
+
yellow: "#ffff00",
|
|
411
|
+
yellowgreen: "#9acd32",
|
|
412
|
+
rebeccapurple: "#663399",
|
|
413
|
+
transparent: "#00000000",
|
|
414
|
+
});
|
|
415
|
+
// color to name
|
|
416
|
+
const NAMES_COLORS = Object.seal(Object.entries(COLORS_NAMES).reduce((acc, [key, value]) => {
|
|
417
|
+
acc[value] = key;
|
|
418
|
+
return acc;
|
|
419
|
+
}, Object.create(null)));
|
|
420
|
+
const trimTokenSpace = new Set([
|
|
421
|
+
EnumToken.Add,
|
|
422
|
+
EnumToken.Mul,
|
|
423
|
+
EnumToken.Div,
|
|
424
|
+
EnumToken.Sub,
|
|
425
|
+
EnumToken.ColonTokenType,
|
|
426
|
+
EnumToken.CommaTokenType,
|
|
427
|
+
EnumToken.SemiColonTokenType,
|
|
428
|
+
EnumToken.DashedIdenTokenType,
|
|
429
|
+
EnumToken.DeclarationNodeType,
|
|
430
|
+
EnumToken.SupportsQueryConditionTokenType,
|
|
431
|
+
EnumToken.SupportsQueryUnaryConditionTokenType,
|
|
432
|
+
]);
|
|
433
|
+
const definedPropertySettings = { configurable: true, enumerable: false, writable: true };
|
|
434
|
+
const combinators = ["+", ">", "~", "||", "|"];
|
|
435
|
+
|
|
436
|
+
export { COLORS_NAMES, D50, NAMES_COLORS, anglePrecision, colorFuncColorSpace, colorPrecision, colorRange, colorsFunc, combinators, containerFunc, definedPropertySettings, deprecatedSystemColors, e, funcLike, generalEnclosedFunc, gridTemplateFunc, imageFunc, k, mFGT, mFLT, mathFuncs, mediaTypes, nonStandardColors, pageMarginBoxType, supportFunc, systemColors, timelineFunc, timingFunc, tokensMap, tokensfuncDefMap, tokensfuncSet, transformFunctions, trimTokenSpace, urlFunc, urlTokenMatcher, whenElseFunc, wildCardFuncs };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AngleToken, DimensionToken, ErrorDescription, FlexToken, FrequencyToken, LengthToken, ResolutionToken, TimeToken, Token } from "../../@types/index.d.ts";
|
|
2
|
+
export declare const dimensionUnits: Set<string>;
|
|
3
|
+
export declare const pseudoElements: string[];
|
|
4
|
+
export declare const pseudoAliasMap: Record<string, string>;
|
|
5
|
+
export declare const webkitExtensions: Set<string>;
|
|
6
|
+
export declare const mozExtensions: Set<string>;
|
|
7
|
+
export declare const renamedStandardProperties: Map<string, string>;
|
|
8
|
+
export declare function isLength(dimension: DimensionToken): boolean;
|
|
9
|
+
export declare function isResolution(dimension: DimensionToken): boolean;
|
|
10
|
+
export declare function isAngle(dimension: DimensionToken): boolean;
|
|
11
|
+
export declare function isTime(dimension: DimensionToken): boolean;
|
|
12
|
+
export declare function isFrequency(dimension: DimensionToken): boolean;
|
|
13
|
+
export declare function isColorspace(token: Token): boolean;
|
|
14
|
+
export declare function isRectangularOrthogonalColorspace(token: Token): boolean;
|
|
15
|
+
export declare function isPolarColorspace(token: Token): boolean;
|
|
16
|
+
export declare function isHueInterpolationMethod(token: Token | Token[]): boolean;
|
|
17
|
+
export declare function isIdentColor(token: Token): boolean;
|
|
18
|
+
export declare function isPercentageToken(token: Token): boolean;
|
|
19
|
+
export declare function isColor(token: Token, errors?: ErrorDescription[]): boolean;
|
|
20
|
+
export declare function parseColor(token: Token): Token;
|
|
21
|
+
export declare function isLetter(codepoint: number): boolean;
|
|
22
|
+
export declare function isIdentStart(codepoint: number): boolean;
|
|
23
|
+
export declare function isDigit(codepoint: number): boolean;
|
|
24
|
+
export declare function isIdentCodepoint(codepoint: number): boolean;
|
|
25
|
+
export declare function isIdent(name: string): boolean;
|
|
26
|
+
export declare function isNonPrintable(codepoint: number): boolean;
|
|
27
|
+
export declare function isPseudo(name: string): boolean;
|
|
28
|
+
export declare function isHash(name: string): boolean;
|
|
29
|
+
export declare function isNumber(name: string): boolean;
|
|
30
|
+
export declare function isPercentage(name: string): boolean;
|
|
31
|
+
export declare function isFlex(dimension: DimensionToken): boolean;
|
|
32
|
+
export declare function parseDimension(name: string): DimensionToken | LengthToken | AngleToken | FlexToken | TimeToken | ResolutionToken | FrequencyToken | null;
|
|
33
|
+
export declare function isHexColor(name: string): boolean;
|
|
34
|
+
export declare function isFunction(name: string): boolean;
|
|
35
|
+
export declare function isAtKeyword(name: string): boolean;
|
|
36
|
+
export declare function isNewLine(codepoint: number): boolean;
|
|
37
|
+
export declare function isWhiteSpace(codepoint: number): boolean;
|
|
38
|
+
export declare function isValue(token: Token): boolean;
|