@projectwallace/css-analyzer 9.3.0 → 9.5.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/dist/atrules/index.d.ts +2 -0
- package/dist/atrules/index.js +2 -0
- package/dist/atrules-CskmpIdJ.js +76 -0
- package/dist/atrules-CvzPtm16.d.ts +16 -0
- package/dist/browserhacks-eP_e1D5u.js +221 -0
- package/dist/index.d.ts +548 -592
- package/dist/index.js +1010 -0
- package/dist/selectors/index.d.ts +2 -0
- package/dist/selectors/index.js +3 -0
- package/dist/specificity-svLpcKkT.js +268 -0
- package/dist/string-utils-olNNcOlY.js +49 -0
- package/dist/utils-BUeYqEL1.d.ts +54 -0
- package/dist/values/index.d.ts +7 -0
- package/dist/values/index.js +3 -0
- package/dist/values-Dw53soqy.d.ts +26 -0
- package/package.json +25 -12
- package/dist/css-analyzer.js +0 -2900
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { BREAK, DIMENSION, IDENTIFIER, MEDIA_FEATURE, MEDIA_TYPE, NUMBER, SUPPORTS_QUERY, str_equals, walk } from "@projectwallace/css-parser";
|
|
2
|
+
//#region src/atrules/atrules.ts
|
|
3
|
+
/**
|
|
4
|
+
* Check if an @supports atRule is a browserhack (Wallace parser version)
|
|
5
|
+
* @param node - The Atrule CSSNode from Wallace parser
|
|
6
|
+
*/
|
|
7
|
+
function isSupportsBrowserhack(node, on_hack) {
|
|
8
|
+
walk(node, function(n) {
|
|
9
|
+
if (n.type === SUPPORTS_QUERY) {
|
|
10
|
+
const normalizedPrelude = (n.prelude || n.value || "").toString().toLowerCase().replaceAll(/\s+/g, "");
|
|
11
|
+
if (normalizedPrelude.includes("-webkit-appearance:none")) {
|
|
12
|
+
on_hack("-webkit-appearance: none");
|
|
13
|
+
return BREAK;
|
|
14
|
+
}
|
|
15
|
+
if (normalizedPrelude.includes("-moz-appearance:meterbar")) {
|
|
16
|
+
on_hack("-moz-appearance: meterbar");
|
|
17
|
+
return BREAK;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if a @media atRule is a browserhack (Wallace parser version)
|
|
24
|
+
* @param node - The Atrule CSSNode from Wallace parser
|
|
25
|
+
* @returns true if the atrule is a browserhack
|
|
26
|
+
*/
|
|
27
|
+
function isMediaBrowserhack(node, on_hack) {
|
|
28
|
+
walk(node, function(n) {
|
|
29
|
+
if (n.type === MEDIA_TYPE) {
|
|
30
|
+
const text = n.text || "";
|
|
31
|
+
if (text.startsWith("\\0")) {
|
|
32
|
+
on_hack("\\0");
|
|
33
|
+
return BREAK;
|
|
34
|
+
}
|
|
35
|
+
if (text.includes("\\9")) {
|
|
36
|
+
on_hack("\\9");
|
|
37
|
+
return BREAK;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (n.type === MEDIA_FEATURE) {
|
|
41
|
+
const name = n.property || "";
|
|
42
|
+
if (str_equals("-moz-images-in-menus", name)) {
|
|
43
|
+
on_hack("-moz-images-in-menus");
|
|
44
|
+
return BREAK;
|
|
45
|
+
}
|
|
46
|
+
if (str_equals("min--moz-device-pixel-ratio", name)) {
|
|
47
|
+
on_hack("min--moz-device-pixel-ratio");
|
|
48
|
+
return BREAK;
|
|
49
|
+
}
|
|
50
|
+
if (str_equals("-ms-high-contrast", name)) {
|
|
51
|
+
on_hack("-ms-high-contrast");
|
|
52
|
+
return BREAK;
|
|
53
|
+
}
|
|
54
|
+
if (str_equals("min-resolution", name) && n.has_children) {
|
|
55
|
+
for (const child of n) if (child.type === DIMENSION && child.value === .001 && str_equals("dpcm", child.unit || "")) {
|
|
56
|
+
on_hack("min-resolution: .001dpcm");
|
|
57
|
+
return BREAK;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (str_equals("-webkit-min-device-pixel-ratio", name) && n.has_children) {
|
|
61
|
+
for (const child of n) if (child.type === NUMBER && (child.value === 0 || child.value === 1e4)) {
|
|
62
|
+
on_hack("-webkit-min-device-pixel-ratio");
|
|
63
|
+
return BREAK;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (n.has_children) {
|
|
67
|
+
for (const child of n) if (child.type === IDENTIFIER && child.text === "\\0") {
|
|
68
|
+
on_hack("\\0");
|
|
69
|
+
return BREAK;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { isSupportsBrowserhack as n, isMediaBrowserhack as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSNode } from "@projectwallace/css-parser";
|
|
2
|
+
|
|
3
|
+
//#region src/atrules/atrules.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Check if an @supports atRule is a browserhack (Wallace parser version)
|
|
6
|
+
* @param node - The Atrule CSSNode from Wallace parser
|
|
7
|
+
*/
|
|
8
|
+
declare function isSupportsBrowserhack(node: CSSNode, on_hack: (hack: string) => void): void;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a @media atRule is a browserhack (Wallace parser version)
|
|
11
|
+
* @param node - The Atrule CSSNode from Wallace parser
|
|
12
|
+
* @returns true if the atrule is a browserhack
|
|
13
|
+
*/
|
|
14
|
+
declare function isMediaBrowserhack(node: CSSNode, on_hack: (hack: string) => void): void;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { isSupportsBrowserhack as n, isMediaBrowserhack as t };
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { r as KeywordSet, t as endsWith } from "./string-utils-olNNcOlY.js";
|
|
2
|
+
import { DIMENSION, IDENTIFIER, NUMBER } from "@projectwallace/css-parser";
|
|
3
|
+
//#region src/values/colors.ts
|
|
4
|
+
const namedColors = new KeywordSet([
|
|
5
|
+
"white",
|
|
6
|
+
"black",
|
|
7
|
+
"red",
|
|
8
|
+
"gray",
|
|
9
|
+
"silver",
|
|
10
|
+
"grey",
|
|
11
|
+
"green",
|
|
12
|
+
"orange",
|
|
13
|
+
"blue",
|
|
14
|
+
"dimgray",
|
|
15
|
+
"whitesmoke",
|
|
16
|
+
"lightgray",
|
|
17
|
+
"lightgrey",
|
|
18
|
+
"yellow",
|
|
19
|
+
"gold",
|
|
20
|
+
"pink",
|
|
21
|
+
"gainsboro",
|
|
22
|
+
"magenta",
|
|
23
|
+
"purple",
|
|
24
|
+
"darkgray",
|
|
25
|
+
"navy",
|
|
26
|
+
"darkred",
|
|
27
|
+
"teal",
|
|
28
|
+
"maroon",
|
|
29
|
+
"darkgrey",
|
|
30
|
+
"tomato",
|
|
31
|
+
"darkorange",
|
|
32
|
+
"brown",
|
|
33
|
+
"crimson",
|
|
34
|
+
"lightyellow",
|
|
35
|
+
"slategray",
|
|
36
|
+
"salmon",
|
|
37
|
+
"lightgreen",
|
|
38
|
+
"lightblue",
|
|
39
|
+
"orangered",
|
|
40
|
+
"aliceblue",
|
|
41
|
+
"dodgerblue",
|
|
42
|
+
"lime",
|
|
43
|
+
"darkblue",
|
|
44
|
+
"darkgoldenrod",
|
|
45
|
+
"skyblue",
|
|
46
|
+
"royalblue",
|
|
47
|
+
"darkgreen",
|
|
48
|
+
"ivory",
|
|
49
|
+
"olive",
|
|
50
|
+
"aqua",
|
|
51
|
+
"turquoise",
|
|
52
|
+
"cyan",
|
|
53
|
+
"khaki",
|
|
54
|
+
"beige",
|
|
55
|
+
"snow",
|
|
56
|
+
"ghostwhite",
|
|
57
|
+
"limegreen",
|
|
58
|
+
"coral",
|
|
59
|
+
"dimgrey",
|
|
60
|
+
"hotpink",
|
|
61
|
+
"midnightblue",
|
|
62
|
+
"firebrick",
|
|
63
|
+
"indigo",
|
|
64
|
+
"wheat",
|
|
65
|
+
"mediumblue",
|
|
66
|
+
"lightpink",
|
|
67
|
+
"plum",
|
|
68
|
+
"azure",
|
|
69
|
+
"violet",
|
|
70
|
+
"lavender",
|
|
71
|
+
"deepskyblue",
|
|
72
|
+
"darkslategrey",
|
|
73
|
+
"goldenrod",
|
|
74
|
+
"cornflowerblue",
|
|
75
|
+
"lightskyblue",
|
|
76
|
+
"indianred",
|
|
77
|
+
"yellowgreen",
|
|
78
|
+
"saddlebrown",
|
|
79
|
+
"palegreen",
|
|
80
|
+
"bisque",
|
|
81
|
+
"tan",
|
|
82
|
+
"antiquewhite",
|
|
83
|
+
"steelblue",
|
|
84
|
+
"forestgreen",
|
|
85
|
+
"fuchsia",
|
|
86
|
+
"mediumaquamarine",
|
|
87
|
+
"seagreen",
|
|
88
|
+
"sienna",
|
|
89
|
+
"deeppink",
|
|
90
|
+
"mediumseagreen",
|
|
91
|
+
"peru",
|
|
92
|
+
"greenyellow",
|
|
93
|
+
"lightgoldenrodyellow",
|
|
94
|
+
"orchid",
|
|
95
|
+
"cadetblue",
|
|
96
|
+
"navajowhite",
|
|
97
|
+
"lightsteelblue",
|
|
98
|
+
"slategrey",
|
|
99
|
+
"linen",
|
|
100
|
+
"lightseagreen",
|
|
101
|
+
"darkcyan",
|
|
102
|
+
"lightcoral",
|
|
103
|
+
"aquamarine",
|
|
104
|
+
"blueviolet",
|
|
105
|
+
"cornsilk",
|
|
106
|
+
"lightsalmon",
|
|
107
|
+
"chocolate",
|
|
108
|
+
"lightslategray",
|
|
109
|
+
"floralwhite",
|
|
110
|
+
"darkturquoise",
|
|
111
|
+
"darkslategray",
|
|
112
|
+
"rebeccapurple",
|
|
113
|
+
"burlywood",
|
|
114
|
+
"chartreuse",
|
|
115
|
+
"lightcyan",
|
|
116
|
+
"lemonchiffon",
|
|
117
|
+
"palevioletred",
|
|
118
|
+
"darkslateblue",
|
|
119
|
+
"mediumpurple",
|
|
120
|
+
"lawngreen",
|
|
121
|
+
"slateblue",
|
|
122
|
+
"darkseagreen",
|
|
123
|
+
"blanchedalmond",
|
|
124
|
+
"mistyrose",
|
|
125
|
+
"darkolivegreen",
|
|
126
|
+
"seashell",
|
|
127
|
+
"olivedrab",
|
|
128
|
+
"peachpuff",
|
|
129
|
+
"darkviolet",
|
|
130
|
+
"powderblue",
|
|
131
|
+
"darkmagenta",
|
|
132
|
+
"lightslategrey",
|
|
133
|
+
"honeydew",
|
|
134
|
+
"palegoldenrod",
|
|
135
|
+
"darkkhaki",
|
|
136
|
+
"oldlace",
|
|
137
|
+
"mintcream",
|
|
138
|
+
"sandybrown",
|
|
139
|
+
"mediumturquoise",
|
|
140
|
+
"papayawhip",
|
|
141
|
+
"paleturquoise",
|
|
142
|
+
"mediumvioletred",
|
|
143
|
+
"thistle",
|
|
144
|
+
"springgreen",
|
|
145
|
+
"moccasin",
|
|
146
|
+
"rosybrown",
|
|
147
|
+
"lavenderblush",
|
|
148
|
+
"mediumslateblue",
|
|
149
|
+
"darkorchid",
|
|
150
|
+
"mediumorchid",
|
|
151
|
+
"darksalmon",
|
|
152
|
+
"mediumspringgreen"
|
|
153
|
+
]);
|
|
154
|
+
const systemColors = new KeywordSet([
|
|
155
|
+
"accentcolor",
|
|
156
|
+
"accentcolortext",
|
|
157
|
+
"activetext",
|
|
158
|
+
"buttonborder",
|
|
159
|
+
"buttonface",
|
|
160
|
+
"buttontext",
|
|
161
|
+
"canvas",
|
|
162
|
+
"canvastext",
|
|
163
|
+
"field",
|
|
164
|
+
"fieldtext",
|
|
165
|
+
"graytext",
|
|
166
|
+
"highlight",
|
|
167
|
+
"highlighttext",
|
|
168
|
+
"linktext",
|
|
169
|
+
"mark",
|
|
170
|
+
"marktext",
|
|
171
|
+
"selecteditem",
|
|
172
|
+
"selecteditemtext",
|
|
173
|
+
"visitedtext"
|
|
174
|
+
]);
|
|
175
|
+
const colorFunctions = new KeywordSet([
|
|
176
|
+
"rgba",
|
|
177
|
+
"rgb",
|
|
178
|
+
"hsla",
|
|
179
|
+
"hsl",
|
|
180
|
+
"oklch",
|
|
181
|
+
"color",
|
|
182
|
+
"hwb",
|
|
183
|
+
"lch",
|
|
184
|
+
"lab",
|
|
185
|
+
"oklab"
|
|
186
|
+
]);
|
|
187
|
+
const colorKeywords = new KeywordSet(["transparent", "currentcolor"]);
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/values/values.ts
|
|
190
|
+
const keywords = new KeywordSet([
|
|
191
|
+
"auto",
|
|
192
|
+
"none",
|
|
193
|
+
"inherit",
|
|
194
|
+
"initial",
|
|
195
|
+
"unset",
|
|
196
|
+
"revert",
|
|
197
|
+
"revert-layer"
|
|
198
|
+
]);
|
|
199
|
+
/**
|
|
200
|
+
* Test whether a value is a reset (0, 0px, -0.0e0 etc.)
|
|
201
|
+
*/
|
|
202
|
+
function isValueReset(node) {
|
|
203
|
+
for (let child of node.children) {
|
|
204
|
+
if (child.type === NUMBER && child.value === 0) continue;
|
|
205
|
+
if (child.type === DIMENSION && child.value === 0) continue;
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/values/browserhacks.ts
|
|
212
|
+
function isIe9Hack(node) {
|
|
213
|
+
let children = node.children;
|
|
214
|
+
if (children) {
|
|
215
|
+
let last = children.at(-1);
|
|
216
|
+
return last && last.type === IDENTIFIER && endsWith("\\9", last.text) ? true : false;
|
|
217
|
+
}
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
export { colorKeywords as a, colorFunctions as i, isValueReset as n, namedColors as o, keywords as r, systemColors as s, isIe9Hack as t };
|