@tbela99/css-parser 0.9.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +15 -8
- package/dist/index-umd-web.js +1815 -498
- package/dist/index.cjs +1816 -499
- package/dist/index.d.ts +46 -14
- package/dist/lib/ast/features/calc.js +7 -10
- package/dist/lib/ast/features/index.js +1 -0
- package/dist/lib/ast/features/inlinecssvariables.js +0 -5
- package/dist/lib/ast/features/prefix.js +2 -7
- package/dist/lib/ast/features/shorthand.js +6 -9
- package/dist/lib/ast/features/transform.js +60 -0
- package/dist/lib/ast/math/expression.js +14 -10
- package/dist/lib/ast/math/math.js +14 -2
- package/dist/lib/ast/minify.js +46 -5
- package/dist/lib/ast/transform/compute.js +336 -0
- package/dist/lib/ast/transform/convert.js +33 -0
- package/dist/lib/ast/transform/matrix.js +111 -0
- package/dist/lib/ast/transform/minify.js +296 -0
- package/dist/lib/ast/transform/perspective.js +10 -0
- package/dist/lib/ast/transform/rotate.js +40 -0
- package/dist/lib/ast/transform/scale.js +32 -0
- package/dist/lib/ast/transform/skew.js +23 -0
- package/dist/lib/ast/transform/translate.js +32 -0
- package/dist/lib/ast/transform/utils.js +198 -0
- package/dist/lib/ast/types.js +1 -0
- package/dist/lib/ast/walk.js +23 -17
- package/dist/lib/parser/parse.js +109 -88
- package/dist/lib/parser/utils/declaration.js +1 -1
- package/dist/lib/renderer/color/{colormix.js → color-mix.js} +6 -0
- package/dist/lib/renderer/color/color.js +94 -18
- package/dist/lib/renderer/color/hex.js +17 -7
- package/dist/lib/renderer/color/hsl.js +7 -2
- package/dist/lib/renderer/color/lab.js +8 -0
- package/dist/lib/renderer/color/lch.js +8 -0
- package/dist/lib/renderer/color/oklab.js +8 -0
- package/dist/lib/renderer/color/oklch.js +8 -0
- package/dist/lib/renderer/color/relativecolor.js +10 -21
- package/dist/lib/renderer/color/rgb.js +10 -7
- package/dist/lib/renderer/color/srgb.js +30 -6
- package/dist/lib/renderer/color/utils/components.js +13 -2
- package/dist/lib/renderer/render.js +67 -30
- package/dist/lib/syntax/syntax.js +74 -56
- package/dist/lib/validation/at-rules/container.js +6 -6
- package/dist/lib/validation/at-rules/document.js +1 -1
- package/dist/lib/validation/at-rules/keyframes.js +1 -1
- package/dist/lib/validation/at-rules/media.js +0 -1
- package/dist/lib/validation/atrule.js +0 -4
- package/dist/lib/validation/selector.js +5 -2
- package/dist/lib/validation/syntaxes/keyframe-block-list.js +2 -2
- package/dist/lib/validation/syntaxes/keyframe-selector.js +11 -90
- package/dist/lib/validation/syntaxes/relative-selector.js +15 -14
- package/dist/lib/validation/utils/list.js +18 -1
- package/dist/node/load.js +1 -1
- package/package.json +12 -12
- package/dist/lib/renderer/color/prophotoRgb.js +0 -56
- package/dist/lib/validation/declaration.js +0 -94
- package/dist/lib/validation/syntax.js +0 -1509
- package/dist/lib/validation/syntaxes/image.js +0 -29
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { EnumToken, ValidationLevel } from '../ast/types.js';
|
|
2
|
-
import '../ast/minify.js';
|
|
3
|
-
import '../ast/walk.js';
|
|
4
|
-
import '../parser/parse.js';
|
|
5
|
-
import '../renderer/color/utils/constants.js';
|
|
6
|
-
import '../renderer/sourcemap/lib/encode.js';
|
|
7
|
-
import '../parser/utils/config.js';
|
|
8
|
-
import { getSyntaxConfig, getParsedSyntax } from './config.js';
|
|
9
|
-
import { validateSyntax } from './syntax.js';
|
|
10
|
-
|
|
11
|
-
function validateDeclaration(declaration, options, root) {
|
|
12
|
-
const config = getSyntaxConfig();
|
|
13
|
-
let name = declaration.nam;
|
|
14
|
-
if (!(name in config.declarations) && !(name in config.syntaxes)) {
|
|
15
|
-
if (name[0] == '-') {
|
|
16
|
-
const match = /^-([a-z]+)-(.*)$/.exec(name);
|
|
17
|
-
if (match != null) {
|
|
18
|
-
name = match[2];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// root is at-rule - check if declaration allowed
|
|
23
|
-
if (root?.typ == EnumToken.AtRuleNodeType) {
|
|
24
|
-
//
|
|
25
|
-
const syntax = getParsedSyntax("atRules" /* ValidationSyntaxGroupEnum.AtRules */, '@' + root.nam)?.[0];
|
|
26
|
-
if (syntax != null) {
|
|
27
|
-
if (!('chi' in syntax)) {
|
|
28
|
-
return {
|
|
29
|
-
valid: ValidationLevel.Drop,
|
|
30
|
-
node: declaration,
|
|
31
|
-
syntax,
|
|
32
|
-
error: 'declaration not allowed here'
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
if (name.startsWith('--')) {
|
|
36
|
-
return {
|
|
37
|
-
valid: ValidationLevel.Valid,
|
|
38
|
-
node: declaration,
|
|
39
|
-
syntax: null,
|
|
40
|
-
error: ''
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// console.error({syntax});
|
|
44
|
-
const config = getSyntaxConfig();
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
const obj = config["atRules" /* ValidationSyntaxGroupEnum.AtRules */]['@' + root.nam];
|
|
47
|
-
if ('descriptors' in obj) {
|
|
48
|
-
const descriptors = obj.descriptors;
|
|
49
|
-
if (!(name in descriptors)) {
|
|
50
|
-
return {
|
|
51
|
-
valid: ValidationLevel.Drop,
|
|
52
|
-
node: declaration,
|
|
53
|
-
syntax: `<${declaration.nam}>`,
|
|
54
|
-
error: `declaration <${declaration.nam}> is not allowed in <@${root.nam}>`
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const syntax = getParsedSyntax("atRules" /* ValidationSyntaxGroupEnum.AtRules */, ['@' + root.nam, 'descriptors', name]);
|
|
58
|
-
return validateSyntax(syntax, declaration.val, root, options);
|
|
59
|
-
}
|
|
60
|
-
// console.error({name});
|
|
61
|
-
// if (!(name in config.declarations) && !(name in config.syntaxes)) {
|
|
62
|
-
//
|
|
63
|
-
// return {
|
|
64
|
-
//
|
|
65
|
-
// valid: ValidationLevel.Drop,
|
|
66
|
-
// node: declaration,
|
|
67
|
-
// syntax: null,
|
|
68
|
-
// error: `unknown declaration "${declaration.nam}"`
|
|
69
|
-
// }
|
|
70
|
-
// }
|
|
71
|
-
//
|
|
72
|
-
// return validateSyntax((syntax as ValidationAtRuleDefinitionToken).chi as ValidationToken[], [declaration], root, options);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (name.startsWith('--')) {
|
|
76
|
-
return {
|
|
77
|
-
valid: ValidationLevel.Valid,
|
|
78
|
-
node: declaration,
|
|
79
|
-
syntax: null,
|
|
80
|
-
error: ''
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (!(name in config.declarations) && !(name in config.syntaxes)) {
|
|
84
|
-
return {
|
|
85
|
-
valid: ValidationLevel.Drop,
|
|
86
|
-
node: declaration,
|
|
87
|
-
syntax: `<${declaration.nam}>`,
|
|
88
|
-
error: `unknown declaration "${declaration.nam}"`
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return validateSyntax(getParsedSyntax("declarations" /* ValidationSyntaxGroupEnum.Declarations */, name), declaration.val);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { validateDeclaration };
|