@tbela99/css-parser 1.5.0 → 1.6.1
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 +59 -0
- package/README.md +10 -10
- package/dist/index-umd-web.js +5998 -4972
- package/dist/index.cjs +6001 -4977
- package/dist/index.d.ts +52 -38
- package/dist/lib/ast/expand.js +21 -7
- package/dist/lib/ast/features/calc.js +17 -55
- package/dist/lib/ast/features/if.js +7 -3
- package/dist/lib/ast/features/inlinecssvariables.js +6 -5
- package/dist/lib/ast/features/prefix.js +41 -44
- package/dist/lib/ast/features/shorthand.js +10 -5
- package/dist/lib/ast/features/transform.js +2 -2
- package/dist/lib/ast/math/expression.js +207 -34
- package/dist/lib/ast/minify.js +121 -24
- package/dist/lib/ast/node.js +5 -3
- package/dist/lib/ast/transform/compute.js +37 -5
- package/dist/lib/ast/transform/minify.js +7 -7
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/rotate.js +1 -1
- package/dist/lib/ast/transform/scale.js +1 -1
- package/dist/lib/ast/transform/skew.js +1 -1
- package/dist/lib/ast/transform/translate.js +1 -1
- package/dist/lib/ast/transform/utils.js +46 -18
- package/dist/lib/ast/walk.js +28 -4
- package/dist/{config.json.js → lib/data/properties.json.js} +106 -0
- package/dist/lib/{validation/config.json.js → data/validation.json.js} +14 -8
- package/dist/lib/fs/resolve.js +11 -2
- package/dist/lib/parser/declaration/list.js +22 -7
- package/dist/lib/parser/declaration/map.js +26 -8
- package/dist/lib/parser/declaration/set.js +3 -1
- package/dist/lib/parser/linesmap.js +2 -4
- package/dist/lib/parser/parse.js +393 -231
- package/dist/lib/parser/tokenize.js +1478 -819
- package/dist/lib/parser/utils/at-rule-container.js +28 -196
- package/dist/lib/parser/utils/at-rule-generic.js +6 -7
- package/dist/lib/parser/utils/at-rule-import.js +17 -13
- package/dist/lib/parser/utils/at-rule-media.js +36 -19
- package/dist/lib/parser/utils/at-rule-support.js +19 -9
- package/dist/lib/parser/utils/at-rule-when-else.js +11 -38
- package/dist/lib/parser/utils/at-rule.js +0 -18
- package/dist/lib/parser/utils/config.js +1 -1
- package/dist/lib/parser/utils/declaration.js +40 -97
- package/dist/lib/parser/utils/hash.js +4 -4
- package/dist/lib/parser/utils/selector.js +179 -224
- package/dist/lib/parser/utils/text.js +4 -2
- package/dist/lib/renderer/render.js +104 -74
- package/dist/lib/renderer/sourcemap/lib/codec.js +3 -3
- package/dist/lib/renderer/sourcemap/sourcemap.js +2 -5
- package/dist/lib/syntax/color/a98rgb.js +14 -4
- package/dist/lib/syntax/color/cmyk.js +14 -21
- package/dist/lib/syntax/color/color-mix.js +21 -34
- package/dist/lib/syntax/color/color.js +32 -49
- package/dist/lib/syntax/color/hsl.js +15 -15
- package/dist/lib/syntax/color/hwb.js +18 -17
- package/dist/lib/syntax/color/lab.js +17 -17
- package/dist/lib/syntax/color/lch.js +13 -13
- package/dist/lib/syntax/color/oklab.js +10 -11
- package/dist/lib/syntax/color/oklch.js +15 -18
- package/dist/lib/syntax/color/p3.js +18 -12
- package/dist/lib/syntax/color/prophotorgb.js +26 -28
- package/dist/lib/syntax/color/rec2020.js +8 -4
- package/dist/lib/syntax/color/relative-color.js +26 -10
- package/dist/lib/syntax/color/srgb.js +9 -7
- package/dist/lib/syntax/color/utils/distance.js +1 -1
- package/dist/lib/syntax/color/xyz.js +2 -2
- package/dist/lib/syntax/color/xyzd50.js +2 -2
- package/dist/lib/syntax/constants.js +13 -3
- package/dist/lib/syntax/syntax.js +32 -108
- package/dist/lib/validation/config.js +1 -1
- package/dist/lib/validation/match.js +29 -26
- package/dist/lib/validation/parser/parse.js +7 -3
- package/dist/node.js +16 -9
- package/dist/types.d.ts +5 -1
- package/dist/types.js +4 -0
- package/dist/utils/sync.js +22 -1
- package/dist/web.js +13 -4
- package/package.json +4 -4
- package/llms.txt +0 -80
|
@@ -123,10 +123,17 @@ class PropertyMap {
|
|
|
123
123
|
else {
|
|
124
124
|
if (current == tokens[property].length) {
|
|
125
125
|
tokens[property].push([]);
|
|
126
|
-
|
|
126
|
+
for (let i = 0; i < defaults.length; i++) {
|
|
127
|
+
tokens[property][current].push(defaults[i]);
|
|
128
|
+
}
|
|
127
129
|
}
|
|
128
130
|
else {
|
|
129
|
-
tokens[property][current].push({
|
|
131
|
+
tokens[property][current].push({
|
|
132
|
+
typ: EnumToken.WhitespaceTokenType,
|
|
133
|
+
});
|
|
134
|
+
for (let i = 0; i < defaults.length; i++) {
|
|
135
|
+
tokens[property][current].push(defaults[i]);
|
|
136
|
+
}
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
139
|
}
|
|
@@ -143,7 +150,9 @@ class PropertyMap {
|
|
|
143
150
|
if (acc.length > 0) {
|
|
144
151
|
acc.push({ ...separator });
|
|
145
152
|
}
|
|
146
|
-
|
|
153
|
+
for (let i = 0; i < curr.length; i++) {
|
|
154
|
+
acc.push(curr[i]);
|
|
155
|
+
}
|
|
147
156
|
return acc;
|
|
148
157
|
}, []),
|
|
149
158
|
});
|
|
@@ -278,7 +287,9 @@ class PropertyMap {
|
|
|
278
287
|
};
|
|
279
288
|
const values = [...this.declarations.values()].reduce((acc, curr) => {
|
|
280
289
|
if (curr instanceof PropertySet) {
|
|
281
|
-
|
|
290
|
+
for (const declaration of curr) {
|
|
291
|
+
acc.push(declaration);
|
|
292
|
+
}
|
|
282
293
|
}
|
|
283
294
|
else {
|
|
284
295
|
acc.push(curr);
|
|
@@ -500,7 +511,7 @@ class PropertyMap {
|
|
|
500
511
|
else if (acc[i].length > 0) {
|
|
501
512
|
acc[i].push({ typ: EnumToken.WhitespaceTokenType });
|
|
502
513
|
}
|
|
503
|
-
|
|
514
|
+
for (const v of values.reduce((acc, curr) => {
|
|
504
515
|
if (acc.length > 0) {
|
|
505
516
|
// @ts-ignore
|
|
506
517
|
acc.push({
|
|
@@ -514,7 +525,9 @@ class PropertyMap {
|
|
|
514
525
|
// @ts-ignore
|
|
515
526
|
acc.push(curr);
|
|
516
527
|
return acc;
|
|
517
|
-
}, []))
|
|
528
|
+
}, [])) {
|
|
529
|
+
acc[i].push(v);
|
|
530
|
+
}
|
|
518
531
|
}
|
|
519
532
|
}
|
|
520
533
|
return acc;
|
|
@@ -532,7 +545,9 @@ class PropertyMap {
|
|
|
532
545
|
return acc;
|
|
533
546
|
}, []));
|
|
534
547
|
}
|
|
535
|
-
|
|
548
|
+
for (const c of curr) {
|
|
549
|
+
acc.push(c);
|
|
550
|
+
}
|
|
536
551
|
return acc;
|
|
537
552
|
}, []);
|
|
538
553
|
if (this.config.mapping != null) {
|
|
@@ -600,10 +615,13 @@ class PropertyMap {
|
|
|
600
615
|
}
|
|
601
616
|
matchTypes(declaration) {
|
|
602
617
|
const patterns = this.pattern.slice();
|
|
603
|
-
const values = [
|
|
618
|
+
const values = [];
|
|
604
619
|
let i;
|
|
605
620
|
let j;
|
|
606
621
|
const map = new Map();
|
|
622
|
+
for (i = 0; i < declaration.val.length; i++) {
|
|
623
|
+
values.push(declaration.val[i]);
|
|
624
|
+
}
|
|
607
625
|
for (i = 0; i < patterns.length; i++) {
|
|
608
626
|
for (j = 0; j < values.length; j++) {
|
|
609
627
|
if (!map.has(patterns[i])) {
|
|
@@ -23,11 +23,9 @@ class LineMap {
|
|
|
23
23
|
*/
|
|
24
24
|
getOffsets(offset) {
|
|
25
25
|
const line = this.search(offset);
|
|
26
|
-
|
|
27
|
-
// return [1, 1];
|
|
28
|
-
// }
|
|
26
|
+
const column = offset - this.lineStarts[line];
|
|
29
27
|
// [line, column]
|
|
30
|
-
return [line + 1,
|
|
28
|
+
return [line + 1, line == 0 ? column + 1 : column];
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* search the greatest index of the value less than or equal to offset
|