@styleframe/scanner 3.0.0 → 3.1.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 +34 -0
- package/dist/index.cjs +1 -665
- package/dist/index.d.ts +47 -24
- package/dist/index.js +408 -575
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return `${
|
|
11
|
-
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
1
|
+
import { readFile as D } from "node:fs/promises";
|
|
2
|
+
import j from "fast-glob";
|
|
3
|
+
import { classNameToCssSelector as z, defaultUtilitySelectorFn as k } from "@styleframe/core";
|
|
4
|
+
function B(s) {
|
|
5
|
+
let e = 0;
|
|
6
|
+
for (let t = 0; t < s.length; t++) {
|
|
7
|
+
const n = s.charCodeAt(t);
|
|
8
|
+
e = (e << 5) - e + n, e = e & e;
|
|
9
|
+
}
|
|
10
|
+
return `${e.toString(16)}-${s.length}`;
|
|
11
|
+
}
|
|
12
|
+
function G() {
|
|
13
|
+
const s = /* @__PURE__ */ new Map();
|
|
14
14
|
return {
|
|
15
|
-
get(
|
|
16
|
-
|
|
17
|
-
return entry?.result ?? null;
|
|
15
|
+
get(e) {
|
|
16
|
+
return s.get(e)?.result ?? null;
|
|
18
17
|
},
|
|
19
|
-
set(
|
|
20
|
-
|
|
21
|
-
hash:
|
|
22
|
-
result,
|
|
18
|
+
set(e, t, n) {
|
|
19
|
+
s.set(e, {
|
|
20
|
+
hash: n,
|
|
21
|
+
result: t,
|
|
23
22
|
timestamp: Date.now()
|
|
24
23
|
});
|
|
25
24
|
},
|
|
26
|
-
isValid(
|
|
27
|
-
const
|
|
28
|
-
return
|
|
25
|
+
isValid(e, t) {
|
|
26
|
+
const n = s.get(e);
|
|
27
|
+
return n !== void 0 && n.hash === t;
|
|
29
28
|
},
|
|
30
|
-
getIfValid(
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
return entry.result;
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
29
|
+
getIfValid(e, t) {
|
|
30
|
+
const n = s.get(e);
|
|
31
|
+
return n && n.hash === t ? n.result : null;
|
|
36
32
|
},
|
|
37
|
-
invalidate(
|
|
38
|
-
|
|
33
|
+
invalidate(e) {
|
|
34
|
+
s.delete(e);
|
|
39
35
|
},
|
|
40
36
|
clear() {
|
|
41
|
-
|
|
37
|
+
s.clear();
|
|
42
38
|
}
|
|
43
39
|
};
|
|
44
40
|
}
|
|
45
|
-
const
|
|
46
|
-
const ARBITRARY_VALUE_PATTERN = /^\[(.+)\]$/;
|
|
47
|
-
const DEFAULT_EXTENSIONS = [
|
|
41
|
+
const X = /_[a-zA-Z][a-zA-Z0-9-]*(?::[a-zA-Z0-9._-]+|:\[[^\]]+\])*/g, Q = /^\[(.+)\]$/, he = [
|
|
48
42
|
"html",
|
|
49
43
|
"htm",
|
|
50
44
|
"vue",
|
|
@@ -59,8 +53,7 @@ const DEFAULT_EXTENSIONS = [
|
|
|
59
53
|
"erb",
|
|
60
54
|
"twig",
|
|
61
55
|
"blade.php"
|
|
62
|
-
]
|
|
63
|
-
const DEFAULT_IGNORE_PATTERNS = [
|
|
56
|
+
], H = [
|
|
64
57
|
"**/node_modules/**",
|
|
65
58
|
"**/.git/**",
|
|
66
59
|
"**/dist/**",
|
|
@@ -69,595 +62,435 @@ const DEFAULT_IGNORE_PATTERNS = [
|
|
|
69
62
|
"**/.nuxt/**",
|
|
70
63
|
"**/coverage/**"
|
|
71
64
|
];
|
|
72
|
-
function
|
|
73
|
-
if (!
|
|
65
|
+
function C(s) {
|
|
66
|
+
if (!s.startsWith("_"))
|
|
74
67
|
return null;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!withoutPrefix) {
|
|
68
|
+
const e = s.slice(1);
|
|
69
|
+
if (!e)
|
|
78
70
|
return null;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (segments.length === 0) {
|
|
71
|
+
const t = K(e);
|
|
72
|
+
if (t.length === 0)
|
|
82
73
|
return null;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
let
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
let isArbitrary = false;
|
|
96
|
-
let arbitraryValue;
|
|
97
|
-
const arbitraryMatch = value.match(ARBITRARY_VALUE_PATTERN);
|
|
98
|
-
if (arbitraryMatch) {
|
|
99
|
-
isArbitrary = true;
|
|
100
|
-
arbitraryValue = arbitraryMatch[1];
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
raw: className,
|
|
104
|
-
name,
|
|
105
|
-
value,
|
|
106
|
-
modifiers,
|
|
107
|
-
isArbitrary,
|
|
108
|
-
arbitraryValue
|
|
74
|
+
let n, r, c = [];
|
|
75
|
+
t.length === 1 ? (n = t[0], r = "default") : (r = t[t.length - 1], n = t[t.length - 2], c = t.slice(0, -2));
|
|
76
|
+
let a = !1, l;
|
|
77
|
+
const u = r.match(Q);
|
|
78
|
+
return u && (a = !0, l = u[1]), {
|
|
79
|
+
raw: s,
|
|
80
|
+
name: n,
|
|
81
|
+
value: r,
|
|
82
|
+
modifiers: c,
|
|
83
|
+
isArbitrary: a,
|
|
84
|
+
arbitraryValue: l
|
|
109
85
|
};
|
|
110
86
|
}
|
|
111
|
-
function
|
|
112
|
-
const
|
|
113
|
-
let
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
function extractFromVue(content) {
|
|
230
|
-
const classes = [];
|
|
231
|
-
const templateMatch = content.match(/<template[^>]*>([\s\S]*?)<\/template>/i);
|
|
232
|
-
if (templateMatch?.[1]) {
|
|
233
|
-
classes.push(...extractFromHTML(templateMatch[1]));
|
|
234
|
-
classes.push(...extractFromStringLiterals(templateMatch[1]));
|
|
235
|
-
}
|
|
236
|
-
const scriptMatch = content.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
|
|
237
|
-
if (scriptMatch?.[1]) {
|
|
238
|
-
classes.push(...extractFromStringLiterals(scriptMatch[1]));
|
|
239
|
-
}
|
|
240
|
-
return [...new Set(classes)];
|
|
241
|
-
}
|
|
242
|
-
function extractFromSvelte(content) {
|
|
243
|
-
const classes = [];
|
|
244
|
-
classes.push(...extractFromHTML(content));
|
|
245
|
-
const expressions = extractClassExpressions(content);
|
|
246
|
-
for (const expr of expressions) {
|
|
247
|
-
classes.push(...extractFromStringLiterals(expr));
|
|
248
|
-
}
|
|
249
|
-
SVELTE_CLASS_DIRECTIVE_PATTERN.lastIndex = 0;
|
|
250
|
-
let match;
|
|
251
|
-
while ((match = SVELTE_CLASS_DIRECTIVE_PATTERN.exec(content)) !== null) {
|
|
252
|
-
if (match[1]) {
|
|
253
|
-
classes.push(match[1]);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
const scriptMatch = content.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
|
|
257
|
-
if (scriptMatch?.[1]) {
|
|
258
|
-
classes.push(...extractFromStringLiterals(scriptMatch[1]));
|
|
259
|
-
}
|
|
260
|
-
return [...new Set(classes)];
|
|
261
|
-
}
|
|
262
|
-
function extractFromAstro(content) {
|
|
263
|
-
const classes = [];
|
|
264
|
-
classes.push(...extractFromHTML(content));
|
|
265
|
-
classes.push(...extractFromJSX(content));
|
|
266
|
-
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
267
|
-
if (frontmatterMatch?.[1]) {
|
|
268
|
-
classes.push(...extractFromStringLiterals(frontmatterMatch[1]));
|
|
269
|
-
}
|
|
270
|
-
return [...new Set(classes)];
|
|
271
|
-
}
|
|
272
|
-
function extractFromStringLiterals(content) {
|
|
273
|
-
const classes = [];
|
|
274
|
-
let match;
|
|
275
|
-
SINGLE_QUOTE_PATTERN.lastIndex = 0;
|
|
276
|
-
while ((match = SINGLE_QUOTE_PATTERN.exec(content)) !== null) {
|
|
277
|
-
if (match[1]) {
|
|
278
|
-
classes.push(...extractUtilityClasses(match[1]));
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
DOUBLE_QUOTE_PATTERN.lastIndex = 0;
|
|
282
|
-
while ((match = DOUBLE_QUOTE_PATTERN.exec(content)) !== null) {
|
|
283
|
-
if (match[1]) {
|
|
284
|
-
classes.push(...extractUtilityClasses(match[1]));
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
TEMPLATE_LITERAL_PATTERN.lastIndex = 0;
|
|
288
|
-
while ((match = TEMPLATE_LITERAL_PATTERN.exec(content)) !== null) {
|
|
289
|
-
if (match[1]) {
|
|
290
|
-
classes.push(...extractUtilityClasses(match[1]));
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return classes;
|
|
294
|
-
}
|
|
295
|
-
function extractFromMDX(content) {
|
|
296
|
-
const classes = [];
|
|
297
|
-
classes.push(...extractFromHTML(content));
|
|
298
|
-
classes.push(...extractFromJSX(content));
|
|
299
|
-
return [...new Set(classes)];
|
|
300
|
-
}
|
|
301
|
-
const defaultExtractors = {
|
|
302
|
-
html: extractFromHTML,
|
|
303
|
-
htm: extractFromHTML,
|
|
304
|
-
vue: extractFromVue,
|
|
305
|
-
svelte: extractFromSvelte,
|
|
306
|
-
jsx: extractFromJSX,
|
|
307
|
-
tsx: extractFromJSX,
|
|
308
|
-
js: extractFromStringLiterals,
|
|
309
|
-
ts: extractFromStringLiterals,
|
|
310
|
-
astro: extractFromAstro,
|
|
311
|
-
mdx: extractFromMDX,
|
|
312
|
-
php: extractFromHTML,
|
|
313
|
-
erb: extractFromHTML,
|
|
314
|
-
twig: extractFromHTML,
|
|
315
|
-
"blade.php": extractFromHTML
|
|
87
|
+
function K(s) {
|
|
88
|
+
const e = [];
|
|
89
|
+
let t = "", n = 0;
|
|
90
|
+
for (const r of s)
|
|
91
|
+
r === "[" ? (n++, t += r) : r === "]" ? (n--, t += r) : r === ":" && n === 0 ? (t && e.push(t), t = "") : t += r;
|
|
92
|
+
return n !== 0 ? [] : (t && e.push(t), e);
|
|
93
|
+
}
|
|
94
|
+
function A(s, e) {
|
|
95
|
+
const t = s.match(e ?? X);
|
|
96
|
+
return t ? [...new Set(t)] : [];
|
|
97
|
+
}
|
|
98
|
+
function pe(s, e, t = []) {
|
|
99
|
+
const n = [...t, s];
|
|
100
|
+
return e !== "default" && n.push(e), `_${n.join(":")}`;
|
|
101
|
+
}
|
|
102
|
+
const R = /\bclassName\s*=\s*\{/g, _ = /\bclass\s*=\s*\{/g, I = /\bclass\s*=\s*["']([^"']+)["']/gi, b = /\bclassName\s*=\s*["']([^"']+)["']/gi, M = /\bclass:([^\s={>]+)/g, L = /'([^'\\]*(?:\\.[^'\\]*)*)'/g, F = /"([^"\\]*(?:\\.[^"\\]*)*)"/g, v = /`([^`\\]*(?:\\.[^`\\]*)*)`/g;
|
|
103
|
+
function P(s) {
|
|
104
|
+
let e = 1, t = 0;
|
|
105
|
+
for (; t < s.length && e > 0; ) {
|
|
106
|
+
const n = s[t];
|
|
107
|
+
n === "{" ? e++ : n === "}" && e--, t++;
|
|
108
|
+
}
|
|
109
|
+
return e !== 0 ? null : s.slice(0, t - 1);
|
|
110
|
+
}
|
|
111
|
+
function Z(s) {
|
|
112
|
+
const e = [];
|
|
113
|
+
R.lastIndex = 0;
|
|
114
|
+
let t;
|
|
115
|
+
for (; (t = R.exec(s)) !== null; ) {
|
|
116
|
+
const n = t.index + t[0].length, r = s.slice(n), c = P(r);
|
|
117
|
+
c !== null && e.push(c);
|
|
118
|
+
}
|
|
119
|
+
return e;
|
|
120
|
+
}
|
|
121
|
+
function W(s) {
|
|
122
|
+
const e = [];
|
|
123
|
+
_.lastIndex = 0;
|
|
124
|
+
let t;
|
|
125
|
+
for (; (t = _.exec(s)) !== null; ) {
|
|
126
|
+
const n = t.index + t[0].length, r = s.slice(n), c = P(r);
|
|
127
|
+
c !== null && e.push(c);
|
|
128
|
+
}
|
|
129
|
+
return e;
|
|
130
|
+
}
|
|
131
|
+
function h(s, e) {
|
|
132
|
+
const t = [];
|
|
133
|
+
I.lastIndex = 0;
|
|
134
|
+
let n;
|
|
135
|
+
for (; (n = I.exec(s)) !== null; )
|
|
136
|
+
n[1] && t.push(...A(n[1], e));
|
|
137
|
+
return t;
|
|
138
|
+
}
|
|
139
|
+
function y(s, e) {
|
|
140
|
+
const t = [];
|
|
141
|
+
b.lastIndex = 0;
|
|
142
|
+
let n;
|
|
143
|
+
for (; (n = b.exec(s)) !== null; )
|
|
144
|
+
n[1] && t.push(...A(n[1], e));
|
|
145
|
+
const r = Z(s);
|
|
146
|
+
for (const c of r)
|
|
147
|
+
t.push(...m(c, e));
|
|
148
|
+
return [...new Set(t)];
|
|
149
|
+
}
|
|
150
|
+
function Y(s, e) {
|
|
151
|
+
const t = [], n = s.match(/<template[^>]*>([\s\S]*?)<\/template>/i);
|
|
152
|
+
n?.[1] && (t.push(...h(n[1], e)), t.push(...m(n[1], e)));
|
|
153
|
+
const r = s.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
|
|
154
|
+
return r?.[1] && t.push(...m(r[1], e)), [...new Set(t)];
|
|
155
|
+
}
|
|
156
|
+
function q(s, e) {
|
|
157
|
+
const t = [];
|
|
158
|
+
t.push(...h(s, e));
|
|
159
|
+
const n = W(s);
|
|
160
|
+
for (const a of n)
|
|
161
|
+
t.push(...m(a, e));
|
|
162
|
+
M.lastIndex = 0;
|
|
163
|
+
let r;
|
|
164
|
+
for (; (r = M.exec(s)) !== null; )
|
|
165
|
+
r[1] && t.push(r[1]);
|
|
166
|
+
const c = s.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
|
|
167
|
+
return c?.[1] && t.push(...m(c[1], e)), [...new Set(t)];
|
|
168
|
+
}
|
|
169
|
+
function J(s, e) {
|
|
170
|
+
const t = [];
|
|
171
|
+
t.push(...h(s, e)), t.push(...y(s, e));
|
|
172
|
+
const n = s.match(/^---\n([\s\S]*?)\n---/);
|
|
173
|
+
return n?.[1] && t.push(...m(n[1], e)), [...new Set(t)];
|
|
174
|
+
}
|
|
175
|
+
function m(s, e) {
|
|
176
|
+
const t = [];
|
|
177
|
+
let n;
|
|
178
|
+
for (L.lastIndex = 0; (n = L.exec(s)) !== null; )
|
|
179
|
+
n[1] && t.push(...A(n[1], e));
|
|
180
|
+
for (F.lastIndex = 0; (n = F.exec(s)) !== null; )
|
|
181
|
+
n[1] && t.push(...A(n[1], e));
|
|
182
|
+
for (v.lastIndex = 0; (n = v.exec(s)) !== null; )
|
|
183
|
+
n[1] && t.push(...A(n[1], e));
|
|
184
|
+
return t;
|
|
185
|
+
}
|
|
186
|
+
function ee(s, e) {
|
|
187
|
+
const t = [];
|
|
188
|
+
return t.push(...h(s, e)), t.push(...y(s, e)), [...new Set(t)];
|
|
189
|
+
}
|
|
190
|
+
const te = {
|
|
191
|
+
html: h,
|
|
192
|
+
htm: h,
|
|
193
|
+
vue: Y,
|
|
194
|
+
svelte: q,
|
|
195
|
+
jsx: y,
|
|
196
|
+
tsx: y,
|
|
197
|
+
js: m,
|
|
198
|
+
ts: m,
|
|
199
|
+
astro: J,
|
|
200
|
+
mdx: ee,
|
|
201
|
+
php: h,
|
|
202
|
+
erb: h,
|
|
203
|
+
twig: h,
|
|
204
|
+
"blade.php": h
|
|
316
205
|
};
|
|
317
|
-
function
|
|
318
|
-
if (
|
|
206
|
+
function se(s) {
|
|
207
|
+
if (s.endsWith(".blade.php"))
|
|
319
208
|
return "blade.php";
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
valueSet.add(generateValueKey(v.key, v.modifiers));
|
|
356
|
-
}
|
|
357
|
-
factoryValueSets.set(utility, valueSet);
|
|
358
|
-
}
|
|
359
|
-
for (const modifier of root.modifiers) {
|
|
360
|
-
for (const key of modifier.key) {
|
|
361
|
-
modifierMap.set(key, modifier);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
const matches = [];
|
|
365
|
-
for (const parsedClass of parsed) {
|
|
366
|
-
const factory = utilityMap.get(parsedClass.name) ?? null;
|
|
367
|
-
const matchedModifiers = [];
|
|
368
|
-
for (const modKey of parsedClass.modifiers) {
|
|
369
|
-
const modifier = modifierMap.get(modKey);
|
|
370
|
-
if (modifier) {
|
|
371
|
-
matchedModifiers.push(modifier);
|
|
372
|
-
}
|
|
209
|
+
const e = s.split(".");
|
|
210
|
+
return e[e.length - 1]?.toLowerCase() ?? "";
|
|
211
|
+
}
|
|
212
|
+
function N(s, e, t, n) {
|
|
213
|
+
const r = [], c = se(e);
|
|
214
|
+
if (t)
|
|
215
|
+
for (const l of t)
|
|
216
|
+
r.push(...l(s, e));
|
|
217
|
+
const a = te[c];
|
|
218
|
+
return a ? r.push(...a(s, n)) : r.push(...m(s, n)), [...new Set(r)];
|
|
219
|
+
}
|
|
220
|
+
function U(s, e) {
|
|
221
|
+
if (e.length === 0)
|
|
222
|
+
return s;
|
|
223
|
+
const t = [...e].sort().join(",");
|
|
224
|
+
return `${s}|${t}`;
|
|
225
|
+
}
|
|
226
|
+
function ne(s, e) {
|
|
227
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
228
|
+
for (const a of e.utilities) {
|
|
229
|
+
t.set(a.name, a);
|
|
230
|
+
const l = /* @__PURE__ */ new Set();
|
|
231
|
+
for (const u of a.values)
|
|
232
|
+
l.add(U(u.key, u.modifiers));
|
|
233
|
+
r.set(a, l);
|
|
234
|
+
}
|
|
235
|
+
for (const a of e.modifiers)
|
|
236
|
+
for (const l of a.key)
|
|
237
|
+
n.set(l, a);
|
|
238
|
+
const c = [];
|
|
239
|
+
for (const a of s) {
|
|
240
|
+
const l = t.get(a.name) ?? null, u = [];
|
|
241
|
+
for (const T of a.modifiers) {
|
|
242
|
+
const w = n.get(T);
|
|
243
|
+
w && u.push(w);
|
|
373
244
|
}
|
|
374
|
-
let
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
245
|
+
let S = !1;
|
|
246
|
+
if (l) {
|
|
247
|
+
const T = U(
|
|
248
|
+
a.value,
|
|
249
|
+
a.modifiers
|
|
379
250
|
);
|
|
380
|
-
|
|
381
|
-
exists = valueSet?.has(lookupKey) ?? false;
|
|
251
|
+
S = r.get(l)?.has(T) ?? !1;
|
|
382
252
|
}
|
|
383
|
-
|
|
384
|
-
parsed:
|
|
385
|
-
factory,
|
|
386
|
-
modifierFactories:
|
|
387
|
-
exists
|
|
253
|
+
c.push({
|
|
254
|
+
parsed: a,
|
|
255
|
+
factory: l,
|
|
256
|
+
modifierFactories: u,
|
|
257
|
+
exists: S
|
|
388
258
|
});
|
|
389
259
|
}
|
|
390
|
-
return
|
|
391
|
-
}
|
|
392
|
-
function
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
function createUtilityFilter(usedClasses) {
|
|
411
|
-
return (utility) => {
|
|
412
|
-
const className = classNameFromUtilityOptions({
|
|
413
|
-
name: utility.name,
|
|
414
|
-
value: utility.value,
|
|
415
|
-
modifiers: utility.modifiers
|
|
416
|
-
});
|
|
417
|
-
return usedClasses.has(className);
|
|
260
|
+
return c;
|
|
261
|
+
}
|
|
262
|
+
function me(s, e) {
|
|
263
|
+
const t = V(s, e);
|
|
264
|
+
return z(t);
|
|
265
|
+
}
|
|
266
|
+
function V(s, e) {
|
|
267
|
+
return (e ?? k)(s);
|
|
268
|
+
}
|
|
269
|
+
function re(s, e) {
|
|
270
|
+
return (t) => {
|
|
271
|
+
const n = V(
|
|
272
|
+
{
|
|
273
|
+
name: t.name,
|
|
274
|
+
value: t.value,
|
|
275
|
+
modifiers: t.modifiers
|
|
276
|
+
},
|
|
277
|
+
e
|
|
278
|
+
);
|
|
279
|
+
return s.has(n);
|
|
418
280
|
};
|
|
419
281
|
}
|
|
420
|
-
function
|
|
421
|
-
const
|
|
422
|
-
return
|
|
423
|
-
if (child.type !== "utility") {
|
|
424
|
-
return true;
|
|
425
|
-
}
|
|
426
|
-
return filter(child);
|
|
427
|
-
});
|
|
282
|
+
function de(s, e, t) {
|
|
283
|
+
const n = re(e, t);
|
|
284
|
+
return s.children.filter((r) => r.type !== "utility" ? !0 : n(r));
|
|
428
285
|
}
|
|
429
|
-
function
|
|
430
|
-
const
|
|
431
|
-
for (const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return classNames;
|
|
286
|
+
function ge(s) {
|
|
287
|
+
const e = /* @__PURE__ */ new Set();
|
|
288
|
+
for (const t of s)
|
|
289
|
+
e.add(t.parsed.raw);
|
|
290
|
+
return e;
|
|
435
291
|
}
|
|
436
|
-
function
|
|
437
|
-
return
|
|
292
|
+
function xe(s) {
|
|
293
|
+
return s.filter((e) => e.factory !== null);
|
|
438
294
|
}
|
|
439
|
-
function
|
|
440
|
-
return
|
|
295
|
+
function Se(s) {
|
|
296
|
+
return s.filter((e) => e.exists);
|
|
441
297
|
}
|
|
442
|
-
function
|
|
443
|
-
return
|
|
298
|
+
function Te(s) {
|
|
299
|
+
return s.filter((e) => e.parsed.isArbitrary);
|
|
444
300
|
}
|
|
445
|
-
const
|
|
446
|
-
function
|
|
447
|
-
const
|
|
448
|
-
if (
|
|
449
|
-
return
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
compiledPatternCache.set(normalized, null);
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
301
|
+
const E = /* @__PURE__ */ new Map();
|
|
302
|
+
function ce(s) {
|
|
303
|
+
const e = s.replace(/\\/g, "/");
|
|
304
|
+
if (E.has(e))
|
|
305
|
+
return E.get(e);
|
|
306
|
+
if (!e.includes("**") && !e.includes("*") && !e.includes("?"))
|
|
307
|
+
return E.set(e, null), null;
|
|
455
308
|
try {
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
compiledPatternCache.set(normalized, regex);
|
|
459
|
-
return regex;
|
|
309
|
+
const t = oe(e), n = new RegExp(`^${t}$`);
|
|
310
|
+
return E.set(e, n), n;
|
|
460
311
|
} catch {
|
|
461
|
-
|
|
462
|
-
return null;
|
|
312
|
+
return E.set(e, null), null;
|
|
463
313
|
}
|
|
464
314
|
}
|
|
465
|
-
function
|
|
466
|
-
let
|
|
467
|
-
return (...
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
timeoutId = setTimeout(() => {
|
|
472
|
-
fn(...args);
|
|
473
|
-
timeoutId = null;
|
|
474
|
-
}, delay);
|
|
315
|
+
function we(s, e) {
|
|
316
|
+
let t = null;
|
|
317
|
+
return (...n) => {
|
|
318
|
+
t && clearTimeout(t), t = setTimeout(() => {
|
|
319
|
+
s(...n), t = null;
|
|
320
|
+
}, e);
|
|
475
321
|
};
|
|
476
322
|
}
|
|
477
|
-
function
|
|
478
|
-
const { debounce:
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
changedFiles.clear();
|
|
485
|
-
callback(files);
|
|
323
|
+
function ae(s, e = {}) {
|
|
324
|
+
const { debounce: t = 100 } = e, n = /* @__PURE__ */ new Set();
|
|
325
|
+
let r = null;
|
|
326
|
+
const c = () => {
|
|
327
|
+
if (n.size > 0) {
|
|
328
|
+
const l = [...n];
|
|
329
|
+
n.clear(), s(l);
|
|
486
330
|
}
|
|
487
331
|
};
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return
|
|
499
|
-
}
|
|
500
|
-
function
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
508
|
-
for (const pattern of patterns) {
|
|
509
|
-
const compiledRegex = getCompiledPattern(pattern);
|
|
510
|
-
if (compiledRegex !== null) {
|
|
511
|
-
if (compiledRegex.test(normalizedPath)) {
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
332
|
+
return { onChange: (l) => {
|
|
333
|
+
n.add(l), r && clearTimeout(r), r = setTimeout(() => {
|
|
334
|
+
c(), r = null;
|
|
335
|
+
}, t);
|
|
336
|
+
}, flush: c };
|
|
337
|
+
}
|
|
338
|
+
function le(s) {
|
|
339
|
+
return s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
340
|
+
}
|
|
341
|
+
function oe(s) {
|
|
342
|
+
return s.replace(/\*\*/g, "<<<GLOBSTAR>>>").replace(/\*/g, "<<<STAR>>>").replace(/\?/g, "<<<QUESTION>>>").split("<<<GLOBSTAR>>>").map(le).join(".*").replace(/<<<STAR>>>/g, "[^/]*").replace(/<<<QUESTION>>>/g, ".");
|
|
343
|
+
}
|
|
344
|
+
function Ee(s, e) {
|
|
345
|
+
const t = s.replace(/\\/g, "/");
|
|
346
|
+
for (const n of e) {
|
|
347
|
+
const r = ce(n);
|
|
348
|
+
if (r !== null) {
|
|
349
|
+
if (r.test(t))
|
|
350
|
+
return !0;
|
|
514
351
|
} else {
|
|
515
|
-
const
|
|
516
|
-
if (
|
|
517
|
-
return
|
|
518
|
-
}
|
|
352
|
+
const c = n.replace(/\\/g, "/");
|
|
353
|
+
if (t === c)
|
|
354
|
+
return !0;
|
|
519
355
|
}
|
|
520
356
|
}
|
|
521
|
-
return
|
|
522
|
-
}
|
|
523
|
-
function
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
absolute: true,
|
|
531
|
-
ignore: DEFAULT_IGNORE_PATTERNS
|
|
357
|
+
return !1;
|
|
358
|
+
}
|
|
359
|
+
function Ae(s) {
|
|
360
|
+
const e = G(), t = s.cwd ?? process.cwd(), n = s.extractors, r = s.utilities?.pattern, c = s.utilities?.parse ?? C;
|
|
361
|
+
async function a() {
|
|
362
|
+
return j(s.content, {
|
|
363
|
+
cwd: t,
|
|
364
|
+
absolute: !0,
|
|
365
|
+
ignore: H
|
|
532
366
|
});
|
|
533
367
|
}
|
|
534
|
-
async function
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
path:
|
|
545
|
-
classes: new Set(
|
|
546
|
-
parsed,
|
|
368
|
+
async function l(o) {
|
|
369
|
+
const f = await D(o, "utf-8"), d = B(f), p = e.getIfValid(o, d);
|
|
370
|
+
if (p)
|
|
371
|
+
return p;
|
|
372
|
+
const g = N(
|
|
373
|
+
f,
|
|
374
|
+
o,
|
|
375
|
+
n,
|
|
376
|
+
r
|
|
377
|
+
), i = g.map(c).filter((O) => O !== null), x = {
|
|
378
|
+
path: o,
|
|
379
|
+
classes: new Set(g),
|
|
380
|
+
parsed: i,
|
|
547
381
|
lastScanned: Date.now()
|
|
548
382
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
filePaths.map(async (filePath) => {
|
|
383
|
+
return e.set(o, x, d), x;
|
|
384
|
+
}
|
|
385
|
+
function u(o, f = "inline") {
|
|
386
|
+
return N(
|
|
387
|
+
o,
|
|
388
|
+
f,
|
|
389
|
+
n,
|
|
390
|
+
r
|
|
391
|
+
).map(c).filter((p) => p !== null);
|
|
392
|
+
}
|
|
393
|
+
async function S() {
|
|
394
|
+
const o = await a(), f = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), p = [], g = await Promise.all(
|
|
395
|
+
o.map(async (i) => {
|
|
563
396
|
try {
|
|
564
|
-
return await
|
|
565
|
-
} catch (
|
|
566
|
-
console.warn(
|
|
567
|
-
`[styleframe/scanner] Failed to scan ${
|
|
568
|
-
|
|
569
|
-
);
|
|
570
|
-
return null;
|
|
397
|
+
return await l(i);
|
|
398
|
+
} catch (x) {
|
|
399
|
+
return console.warn(
|
|
400
|
+
`[styleframe/scanner] Failed to scan ${i}:`,
|
|
401
|
+
x
|
|
402
|
+
), null;
|
|
571
403
|
}
|
|
572
404
|
})
|
|
573
405
|
);
|
|
574
|
-
for (const
|
|
575
|
-
if (
|
|
576
|
-
|
|
577
|
-
for (const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
allParsed.push(...result.parsed);
|
|
406
|
+
for (const i of g)
|
|
407
|
+
if (i) {
|
|
408
|
+
f.set(i.path, i);
|
|
409
|
+
for (const x of i.classes)
|
|
410
|
+
d.add(x);
|
|
411
|
+
p.push(...i.parsed);
|
|
581
412
|
}
|
|
582
|
-
}
|
|
583
413
|
return {
|
|
584
|
-
files,
|
|
585
|
-
allClasses,
|
|
586
|
-
allParsed
|
|
414
|
+
files: f,
|
|
415
|
+
allClasses: d,
|
|
416
|
+
allParsed: p
|
|
587
417
|
};
|
|
588
418
|
}
|
|
589
|
-
function
|
|
590
|
-
return
|
|
419
|
+
function T(o, f) {
|
|
420
|
+
return ne(o, f);
|
|
591
421
|
}
|
|
592
|
-
function
|
|
593
|
-
const { onChange, flush } =
|
|
594
|
-
for (const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
callback(result);
|
|
422
|
+
function w(o) {
|
|
423
|
+
const { onChange: f, flush: d } = ae(async (p) => {
|
|
424
|
+
for (const i of p)
|
|
425
|
+
e.invalidate(i);
|
|
426
|
+
const g = await S();
|
|
427
|
+
o(g);
|
|
599
428
|
});
|
|
600
429
|
return () => {
|
|
601
|
-
|
|
430
|
+
d();
|
|
602
431
|
};
|
|
603
432
|
}
|
|
604
|
-
function
|
|
605
|
-
|
|
606
|
-
cache.invalidate(filePath);
|
|
607
|
-
} else {
|
|
608
|
-
cache.clear();
|
|
609
|
-
}
|
|
433
|
+
function $(o) {
|
|
434
|
+
o ? e.invalidate(o) : e.clear();
|
|
610
435
|
}
|
|
611
436
|
return {
|
|
612
|
-
scan,
|
|
613
|
-
scanFile,
|
|
614
|
-
scanContent,
|
|
615
|
-
match,
|
|
616
|
-
watch,
|
|
617
|
-
invalidate
|
|
437
|
+
scan: S,
|
|
438
|
+
scanFile: l,
|
|
439
|
+
scanContent: u,
|
|
440
|
+
match: T,
|
|
441
|
+
watch: w,
|
|
442
|
+
invalidate: $
|
|
618
443
|
};
|
|
619
444
|
}
|
|
620
|
-
function
|
|
621
|
-
const
|
|
622
|
-
return
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
445
|
+
function ye(s, e = "inline.html", t) {
|
|
446
|
+
const n = t?.parse ?? C;
|
|
447
|
+
return N(
|
|
448
|
+
s,
|
|
449
|
+
e,
|
|
450
|
+
void 0,
|
|
451
|
+
t?.pattern
|
|
452
|
+
).map(n).filter((c) => c !== null);
|
|
453
|
+
}
|
|
454
|
+
function Ne(s, e) {
|
|
455
|
+
const t = e?.parse ?? C;
|
|
456
|
+
return (n, r = "inline") => N(
|
|
457
|
+
n,
|
|
458
|
+
r,
|
|
459
|
+
s,
|
|
460
|
+
e?.pattern
|
|
461
|
+
).map(t).filter((a) => a !== null);
|
|
629
462
|
}
|
|
630
463
|
export {
|
|
631
|
-
ARBITRARY_VALUE_PATTERN,
|
|
632
|
-
DEFAULT_EXTENSIONS,
|
|
633
|
-
DEFAULT_IGNORE_PATTERNS,
|
|
634
|
-
UTILITY_CLASS_PATTERN,
|
|
635
|
-
classNameFromUtilityOptions,
|
|
636
|
-
createCache,
|
|
637
|
-
createChangeHandler,
|
|
638
|
-
createContentScanner,
|
|
639
|
-
createScanner,
|
|
640
|
-
createUtilityFilter,
|
|
641
|
-
debounce,
|
|
642
|
-
extractClasses,
|
|
643
|
-
extractFromAstro,
|
|
644
|
-
extractFromHTML,
|
|
645
|
-
extractFromJSX,
|
|
646
|
-
extractFromMDX,
|
|
647
|
-
extractFromStringLiterals,
|
|
648
|
-
extractFromSvelte,
|
|
649
|
-
extractFromVue,
|
|
650
|
-
extractUtilityClasses,
|
|
651
|
-
filterUtilities,
|
|
652
|
-
generateUtilityClassName,
|
|
653
|
-
generateUtilitySelector,
|
|
654
|
-
getArbitraryMatches,
|
|
655
|
-
getExistingMatches,
|
|
656
|
-
getUsedClassNames,
|
|
657
|
-
getValidMatches,
|
|
658
|
-
hashContent,
|
|
659
|
-
matchUtilities,
|
|
660
|
-
matchesPatterns,
|
|
661
|
-
parseUtilityClass,
|
|
662
|
-
quickScan
|
|
464
|
+
Q as ARBITRARY_VALUE_PATTERN,
|
|
465
|
+
he as DEFAULT_EXTENSIONS,
|
|
466
|
+
H as DEFAULT_IGNORE_PATTERNS,
|
|
467
|
+
X as UTILITY_CLASS_PATTERN,
|
|
468
|
+
V as classNameFromUtilityOptions,
|
|
469
|
+
G as createCache,
|
|
470
|
+
ae as createChangeHandler,
|
|
471
|
+
Ne as createContentScanner,
|
|
472
|
+
Ae as createScanner,
|
|
473
|
+
re as createUtilityFilter,
|
|
474
|
+
we as debounce,
|
|
475
|
+
N as extractClasses,
|
|
476
|
+
J as extractFromAstro,
|
|
477
|
+
h as extractFromHTML,
|
|
478
|
+
y as extractFromJSX,
|
|
479
|
+
ee as extractFromMDX,
|
|
480
|
+
m as extractFromStringLiterals,
|
|
481
|
+
q as extractFromSvelte,
|
|
482
|
+
Y as extractFromVue,
|
|
483
|
+
A as extractUtilityClasses,
|
|
484
|
+
de as filterUtilities,
|
|
485
|
+
pe as generateUtilityClassName,
|
|
486
|
+
me as generateUtilitySelector,
|
|
487
|
+
Te as getArbitraryMatches,
|
|
488
|
+
Se as getExistingMatches,
|
|
489
|
+
ge as getUsedClassNames,
|
|
490
|
+
xe as getValidMatches,
|
|
491
|
+
B as hashContent,
|
|
492
|
+
ne as matchUtilities,
|
|
493
|
+
Ee as matchesPatterns,
|
|
494
|
+
C as parseUtilityClass,
|
|
495
|
+
ye as quickScan
|
|
663
496
|
};
|