@tbela99/css-parser 1.4.5 → 1.4.7
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 +23 -2
- package/README.md +2 -0
- package/dist/index-umd-web.js +6546 -6987
- package/dist/index.cjs +7784 -8223
- package/dist/index.d.ts +919 -51
- package/dist/lib/ast/clone.js +16 -23
- package/dist/lib/ast/expand.js +2 -2
- package/dist/lib/ast/features/if.js +88 -87
- package/dist/lib/ast/features/inlinecssvariables.js +2 -2
- package/dist/lib/ast/features/prefix.js +26 -22
- package/dist/lib/ast/features/transform.js +3 -3
- package/dist/lib/ast/find.js +17 -14
- package/dist/lib/ast/minify.js +97 -94
- package/dist/lib/ast/types.js +6 -2
- package/dist/lib/ast/walk.js +1 -1
- package/dist/lib/fs/resolve.js +46 -44
- package/dist/lib/parser/declaration/list.js +9 -10
- package/dist/lib/parser/declaration/map.js +13 -18
- package/dist/lib/parser/parse.js +331 -506
- package/dist/lib/parser/tokenize.js +39 -33
- package/dist/lib/parser/utils/at-rule-container.js +244 -247
- package/dist/lib/parser/utils/at-rule-generic.js +25 -25
- package/dist/lib/parser/utils/at-rule-import.js +194 -234
- package/dist/lib/parser/utils/at-rule-media.js +286 -286
- package/dist/lib/parser/utils/at-rule-support.js +279 -251
- package/dist/lib/parser/utils/at-rule-when-else.js +256 -259
- package/dist/lib/parser/utils/at-rule.js +19 -16
- package/dist/lib/parser/utils/cache.js +33 -5
- package/dist/lib/parser/utils/declaration.js +260 -322
- package/dist/lib/parser/utils/hash.js +15 -15
- package/dist/lib/parser/utils/selector.js +182 -222
- package/dist/lib/parser/utils/token.js +4 -7
- package/dist/lib/renderer/render.js +150 -120
- package/dist/lib/syntax/color/alpha.js +1 -4
- package/dist/lib/syntax/color/color.js +5 -5
- package/dist/lib/syntax/color/utils/colorspace.js +3 -3
- package/dist/lib/syntax/color/utils/components.js +21 -22
- package/dist/lib/syntax/color/utils/matrix.js +12 -11
- package/dist/lib/syntax/constants.js +22 -3
- package/dist/lib/syntax/syntax.js +252 -311
- package/dist/lib/validation/config.js +16 -17
- package/dist/lib/validation/match.js +1118 -1131
- package/dist/lib/validation/parser/parse.js +130 -286
- package/dist/node.js +16 -12
- package/dist/web.js +10 -8
- package/package.json +4 -4
- package/dist/lib/validation/utils/whitespace.js +0 -17
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { EnumToken } from '../../ast/types.js';
|
|
2
1
|
import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
|
|
3
2
|
import { getSyntaxRule } from '../../validation/config.js';
|
|
4
3
|
import { trimArray, matchAllSyntaxes, createValidationContext } from '../../validation/match.js';
|
|
@@ -8,23 +7,27 @@ function matchAtRuleSyntax(atRule, stream, options) {
|
|
|
8
7
|
const syntax = syntaxRules?.getPreludeRules()?.slice?.(1);
|
|
9
8
|
trimArray(stream);
|
|
10
9
|
if (syntax.length === 0) {
|
|
11
|
-
const filtered = stream.filter(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
// const filtered = stream.filter(
|
|
11
|
+
// (token) => token.typ !== EnumToken.WhitespaceTokenType && token.typ !== EnumToken.CommentTokenType,
|
|
12
|
+
// );
|
|
13
|
+
// if (filtered.length > 0) {
|
|
14
|
+
// return {
|
|
15
|
+
// success: false,
|
|
16
|
+
// errors: [
|
|
17
|
+
// {
|
|
18
|
+
// action: "drop",
|
|
19
|
+
// message: `unexpected token ${EnumToken[filtered[0].typ]} at ${filtered[0][LOC]!.src}:${
|
|
20
|
+
// filtered[0][LOC]!.sta.lin
|
|
21
|
+
// }:${filtered[0][LOC]!.sta.col}`,
|
|
22
|
+
// node: filtered[0],
|
|
23
|
+
// location: filtered[0][LOC]!,
|
|
24
|
+
// },
|
|
25
|
+
// ],
|
|
26
|
+
// };
|
|
27
|
+
// }
|
|
25
28
|
return { success: true, errors: [] };
|
|
26
29
|
}
|
|
27
|
-
const { success, errors} = matchAllSyntaxes(syntax, createValidationContext(stream), options);
|
|
30
|
+
const { success, errors } = matchAllSyntaxes(syntax, createValidationContext(stream), options);
|
|
28
31
|
return { success, errors };
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -4,14 +4,42 @@
|
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
6
6
|
function memoize(fn) {
|
|
7
|
-
const
|
|
7
|
+
const buckets = new Map();
|
|
8
8
|
return function (...args) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const n = args.length;
|
|
10
|
+
let bucket = buckets.get(n);
|
|
11
|
+
if (bucket == null) {
|
|
12
|
+
bucket = new Map();
|
|
13
|
+
buckets.set(n, bucket);
|
|
12
14
|
}
|
|
15
|
+
if (n === 1) {
|
|
16
|
+
const key = args[0];
|
|
17
|
+
const value = bucket.get(key);
|
|
18
|
+
if (value != null)
|
|
19
|
+
return bucket.get(key);
|
|
20
|
+
const result = fn(key);
|
|
21
|
+
bucket.set(key, result);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
let node = bucket;
|
|
25
|
+
for (let i = 0; i < n; i++) {
|
|
26
|
+
const key = args[i];
|
|
27
|
+
const next = node.get(key);
|
|
28
|
+
if (next == null) {
|
|
29
|
+
const newNode = new Map();
|
|
30
|
+
node.set(key, newNode);
|
|
31
|
+
node = newNode;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
node = next;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const last = n === 0 ? undefined : args[n - 1];
|
|
38
|
+
const value = node.get(last);
|
|
39
|
+
if (value != null)
|
|
40
|
+
return value;
|
|
13
41
|
const result = fn(...args);
|
|
14
|
-
|
|
42
|
+
node.set(last, result);
|
|
15
43
|
return result;
|
|
16
44
|
};
|
|
17
45
|
}
|