@tbela99/css-parser 1.0.0 → 1.1.1-alpha4
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 +269 -0
- package/README.md +16 -11
- package/dist/index-umd-web.js +3805 -1894
- package/dist/index.cjs +3806 -1895
- package/dist/index.d.ts +184 -57
- package/dist/lib/ast/expand.js +2 -1
- package/dist/lib/ast/features/calc.js +12 -1
- package/dist/lib/ast/features/inlinecssvariables.js +47 -24
- package/dist/lib/ast/features/prefix.js +117 -86
- package/dist/lib/ast/features/shorthand.js +29 -6
- package/dist/lib/ast/features/transform.js +10 -3
- package/dist/lib/ast/features/type.js +7 -0
- package/dist/lib/ast/math/expression.js +7 -1
- package/dist/lib/ast/math/math.js +6 -0
- package/dist/lib/ast/minify.js +165 -77
- package/dist/lib/ast/transform/compute.js +1 -0
- package/dist/lib/ast/transform/matrix.js +1 -0
- package/dist/lib/ast/types.js +26 -15
- package/dist/lib/ast/utils/utils.js +104 -0
- package/dist/lib/ast/walk.js +33 -7
- package/dist/lib/fs/resolve.js +10 -0
- package/dist/lib/parser/declaration/list.js +48 -45
- package/dist/lib/parser/declaration/map.js +1 -0
- package/dist/lib/parser/declaration/set.js +2 -1
- package/dist/lib/parser/parse.js +350 -279
- package/dist/lib/parser/tokenize.js +147 -72
- package/dist/lib/parser/utils/declaration.js +4 -3
- package/dist/lib/parser/utils/type.js +2 -1
- package/dist/lib/renderer/color/a98rgb.js +2 -1
- package/dist/lib/renderer/color/color-mix.js +10 -7
- package/dist/lib/renderer/color/color.js +171 -153
- package/dist/lib/renderer/color/hex.js +2 -1
- package/dist/lib/renderer/color/hsl.js +2 -1
- package/dist/lib/renderer/color/hwb.js +2 -1
- package/dist/lib/renderer/color/lab.js +2 -1
- package/dist/lib/renderer/color/lch.js +2 -1
- package/dist/lib/renderer/color/oklab.js +2 -1
- package/dist/lib/renderer/color/oklch.js +2 -1
- package/dist/lib/renderer/color/p3.js +2 -1
- package/dist/lib/renderer/color/rec2020.js +2 -1
- package/dist/lib/renderer/color/relativecolor.js +17 -11
- package/dist/lib/renderer/color/rgb.js +4 -3
- package/dist/lib/renderer/color/srgb.js +18 -17
- package/dist/lib/renderer/color/utils/components.js +6 -5
- package/dist/lib/renderer/color/utils/constants.js +47 -3
- package/dist/lib/renderer/color/xyz.js +2 -1
- package/dist/lib/renderer/color/xyzd50.js +2 -1
- package/dist/lib/renderer/render.js +48 -20
- package/dist/lib/syntax/syntax.js +257 -140
- package/dist/lib/validation/at-rules/container.js +75 -97
- package/dist/lib/validation/at-rules/counter-style.js +9 -8
- package/dist/lib/validation/at-rules/custom-media.js +13 -15
- package/dist/lib/validation/at-rules/document.js +22 -27
- package/dist/lib/validation/at-rules/font-feature-values.js +8 -8
- package/dist/lib/validation/at-rules/import.js +30 -81
- package/dist/lib/validation/at-rules/keyframes.js +18 -22
- package/dist/lib/validation/at-rules/layer.js +5 -5
- package/dist/lib/validation/at-rules/media.js +42 -52
- package/dist/lib/validation/at-rules/namespace.js +19 -23
- package/dist/lib/validation/at-rules/page-margin-box.js +15 -18
- package/dist/lib/validation/at-rules/page.js +8 -7
- package/dist/lib/validation/at-rules/supports.js +73 -82
- package/dist/lib/validation/at-rules/when.js +32 -36
- package/dist/lib/validation/atrule.js +15 -14
- package/dist/lib/validation/config.js +24 -1
- package/dist/lib/validation/config.json.js +611 -111
- package/dist/lib/validation/parser/parse.js +206 -212
- package/dist/lib/validation/parser/types.js +1 -1
- package/dist/lib/validation/selector.js +3 -3
- package/dist/lib/validation/syntax.js +984 -0
- package/dist/lib/validation/syntaxes/complex-selector-list.js +10 -11
- package/dist/lib/validation/syntaxes/complex-selector.js +10 -11
- package/dist/lib/validation/syntaxes/compound-selector.js +40 -50
- package/dist/lib/validation/syntaxes/family-name.js +9 -8
- package/dist/lib/validation/syntaxes/keyframe-block-list.js +4 -3
- package/dist/lib/validation/syntaxes/keyframe-selector.js +15 -18
- package/dist/lib/validation/syntaxes/layer-name.js +6 -5
- package/dist/lib/validation/syntaxes/relative-selector-list.js +7 -6
- package/dist/lib/validation/syntaxes/relative-selector.js +2 -1
- package/dist/lib/validation/syntaxes/url.js +18 -22
- package/dist/lib/validation/utils/list.js +2 -1
- package/dist/lib/validation/utils/whitespace.js +2 -1
- package/dist/node/index.js +4 -2
- package/dist/node/load.js +5 -0
- package/dist/web/index.js +4 -2
- package/dist/web/load.js +5 -0
- package/package.json +14 -13
|
@@ -4,6 +4,7 @@ import { EnumToken } from '../../ast/types.js';
|
|
|
4
4
|
import '../../ast/minify.js';
|
|
5
5
|
import '../../ast/walk.js';
|
|
6
6
|
import { parseString } from '../parse.js';
|
|
7
|
+
import '../tokenize.js';
|
|
7
8
|
import '../../renderer/color/utils/constants.js';
|
|
8
9
|
import '../../renderer/sourcemap/lib/encode.js';
|
|
9
10
|
import { PropertyMap } from './map.js';
|
|
@@ -23,61 +24,63 @@ class PropertyList {
|
|
|
23
24
|
val: Array.isArray(value) ? value : parseString(String(value))
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
add(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if ('map' in config.properties[propertyName]) {
|
|
41
|
-
shortHandType = 'map';
|
|
27
|
+
add(...declarations) {
|
|
28
|
+
for (const declaration of declarations) {
|
|
29
|
+
if (declaration.typ != EnumToken.DeclarationNodeType || !this.options.removeDuplicateDeclarations) {
|
|
30
|
+
this.declarations.set(Number(Math.random().toString().slice(2)).toString(36), declaration);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (!this.options.computeShorthand) {
|
|
34
|
+
this.declarations.set(declaration.nam, declaration);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
let propertyName = declaration.nam;
|
|
38
|
+
let shortHandType;
|
|
39
|
+
let shorthand;
|
|
40
|
+
if (propertyName in config.properties) {
|
|
42
41
|
// @ts-ignore
|
|
43
|
-
|
|
42
|
+
if ('map' in config.properties[propertyName]) {
|
|
43
|
+
shortHandType = 'map';
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
shorthand = config.properties[propertyName].map;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
shortHandType = 'set';
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
shorthand = config.properties[propertyName].shorthand;
|
|
51
|
+
}
|
|
44
52
|
}
|
|
45
|
-
else {
|
|
46
|
-
shortHandType = '
|
|
53
|
+
else if (propertyName in config.map) {
|
|
54
|
+
shortHandType = 'map';
|
|
47
55
|
// @ts-ignore
|
|
48
|
-
shorthand = config.
|
|
56
|
+
shorthand = config.map[propertyName].shorthand;
|
|
49
57
|
}
|
|
50
|
-
}
|
|
51
|
-
else if (propertyName in config.map) {
|
|
52
|
-
shortHandType = 'map';
|
|
53
58
|
// @ts-ignore
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if (shortHandType == 'map') {
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
if (!this.declarations.has(shorthand)) {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
64
|
+
}
|
|
60
65
|
// @ts-ignore
|
|
61
|
-
this.declarations.
|
|
66
|
+
this.declarations.get(shorthand).add(declaration);
|
|
67
|
+
// return this;
|
|
62
68
|
}
|
|
63
69
|
// @ts-ignore
|
|
64
|
-
|
|
65
|
-
// return this;
|
|
66
|
-
}
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
else if (shortHandType == 'set') {
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
// const shorthand: string = <string>config.properties[propertyName].shorthand;
|
|
71
|
-
if (!this.declarations.has(shorthand)) {
|
|
70
|
+
else if (shortHandType == 'set') {
|
|
72
71
|
// @ts-ignore
|
|
73
|
-
|
|
72
|
+
// const shorthand: string = <string>config.properties[propertyName].shorthand;
|
|
73
|
+
if (!this.declarations.has(shorthand)) {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
this.declarations.set(shorthand, new PropertySet(config.properties[shorthand]));
|
|
76
|
+
}
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
this.declarations.get(shorthand).add(declaration);
|
|
79
|
+
// return this;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.declarations.set(propertyName, declaration);
|
|
74
83
|
}
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
this.declarations.get(shorthand).add(declaration);
|
|
77
|
-
// return this;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
this.declarations.set(propertyName, declaration);
|
|
81
84
|
}
|
|
82
85
|
return this;
|
|
83
86
|
}
|
|
@@ -5,6 +5,7 @@ import { EnumToken } from '../../ast/types.js';
|
|
|
5
5
|
import '../../ast/minify.js';
|
|
6
6
|
import '../../ast/walk.js';
|
|
7
7
|
import { parseString } from '../parse.js';
|
|
8
|
+
import '../tokenize.js';
|
|
8
9
|
import { renderToken } from '../../renderer/render.js';
|
|
9
10
|
import '../../renderer/color/utils/constants.js';
|
|
10
11
|
import { PropertySet } from './set.js';
|
|
@@ -3,8 +3,9 @@ import { EnumToken } from '../../ast/types.js';
|
|
|
3
3
|
import '../../ast/minify.js';
|
|
4
4
|
import '../../ast/walk.js';
|
|
5
5
|
import '../parse.js';
|
|
6
|
-
import
|
|
6
|
+
import '../tokenize.js';
|
|
7
7
|
import '../utils/config.js';
|
|
8
|
+
import { isLength } from '../../syntax/syntax.js';
|
|
8
9
|
import '../../renderer/color/utils/constants.js';
|
|
9
10
|
import '../../renderer/sourcemap/lib/encode.js';
|
|
10
11
|
|