@lovrozagar/flare 0.9.0 → 0.9.2
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/package.json +1 -1
- package/src/plugins/index.ts +3 -0
- package/src/plugins/tw-compile.ts +18 -16
package/package.json
CHANGED
package/src/plugins/index.ts
CHANGED
|
@@ -287,6 +287,9 @@ function createSsrBuildPlugin(entries: ResolvedEntries, config: FlarePluginConfi
|
|
|
287
287
|
},
|
|
288
288
|
},
|
|
289
289
|
optimizeDeps: {
|
|
290
|
+
/* Flare ships TSX source: the dep optimizer would bundle it without the Solid JSX
|
|
291
|
+
transform. Serve it as source, like a linked package. */
|
|
292
|
+
exclude: ["@lovrozagar/flare"],
|
|
290
293
|
include: ["solid-js", "@solidjs/web"],
|
|
291
294
|
},
|
|
292
295
|
resolve: {
|
|
@@ -37,18 +37,18 @@ function cssEscapeClass(cls: string): string {
|
|
|
37
37
|
return cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1");
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* What follows a requested utility's own class in `selector`: "" for the bare class, the variant
|
|
42
|
+
* suffix (`[aria-pressed="true"]`, `:focus-visible:disabled`, `:where(...)`, ` .child`) otherwise,
|
|
43
|
+
* or null when the selector is not that utility (`.p-40` is not `.p-4`).
|
|
44
|
+
*/
|
|
45
|
+
function suffixAfterUtility(selector: string, prefixes: Set<string>): string | null {
|
|
41
46
|
for (const prefix of prefixes) {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
selector.startsWith(`${prefix} `) ||
|
|
46
|
-
selector.startsWith(`${prefix},`)
|
|
47
|
-
) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
47
|
+
if (!selector.startsWith(prefix)) continue;
|
|
48
|
+
const suffix = selector.slice(prefix.length);
|
|
49
|
+
if (suffix === "" || /^[:[ ,]/.test(suffix)) return suffix;
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return null;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function extractLayerContent(css: string, atStart: number): string {
|
|
@@ -108,13 +108,15 @@ function extractDeclsInner(css: string, selectorSet?: Set<string>): string {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
const body = remaining.slice(braceStart + 1, i).trim();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
result.push(
|
|
111
|
+
if (body.length > 0) {
|
|
112
|
+
if (selectorSet) {
|
|
113
|
+
/* Keep the whole variant suffix: flattened attribute variants and chained pseudos. */
|
|
114
|
+
const suffix = suffixAfterUtility(selector, selectorSet);
|
|
115
|
+
if (suffix === "" || suffix?.startsWith(",")) result.push(body);
|
|
116
|
+
else if (suffix !== null) result.push(`&${suffix} { ${body} }`);
|
|
116
117
|
} else {
|
|
117
|
-
|
|
118
|
+
const pseudo = extractPseudo(selector);
|
|
119
|
+
result.push(pseudo ? `&${pseudo} { ${body} }` : body);
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
remaining = remaining.slice(i + 1).trim();
|