create-z3 0.0.23 → 0.0.25
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/index.js
CHANGED
|
@@ -1974,13 +1974,28 @@ async function fetchOrReadCSS(source) {
|
|
|
1974
1974
|
}
|
|
1975
1975
|
function parseColorsFromCSS(css) {
|
|
1976
1976
|
const colors = [];
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
const
|
|
1981
|
-
const
|
|
1982
|
-
|
|
1983
|
-
|
|
1977
|
+
const rootBlockRegex = /:root\s*\{([^}]+)\}/gs;
|
|
1978
|
+
const rootMatch = rootBlockRegex.exec(css);
|
|
1979
|
+
if (rootMatch) {
|
|
1980
|
+
const rootContent = rootMatch[1];
|
|
1981
|
+
const cssVarRegex = /--([\w-]+)\s*:\s*([^;]+);/g;
|
|
1982
|
+
let match;
|
|
1983
|
+
while ((match = cssVarRegex.exec(rootContent)) !== null) {
|
|
1984
|
+
const name = `--${match[1]}`;
|
|
1985
|
+
const value = match[2].trim();
|
|
1986
|
+
colors.push({ name, value, theme: "root" });
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
const darkBlockRegex = /\.dark\s*\{([^}]+)\}/gs;
|
|
1990
|
+
const darkMatch = darkBlockRegex.exec(css);
|
|
1991
|
+
if (darkMatch) {
|
|
1992
|
+
const darkContent = darkMatch[1];
|
|
1993
|
+
const cssVarRegex = /--([\w-]+)\s*:\s*([^;]+);/g;
|
|
1994
|
+
let match;
|
|
1995
|
+
while ((match = cssVarRegex.exec(darkContent)) !== null) {
|
|
1996
|
+
const name = `--${match[1]}`;
|
|
1997
|
+
const value = match[2].trim();
|
|
1998
|
+
colors.push({ name, value, theme: "dark" });
|
|
1984
1999
|
}
|
|
1985
2000
|
}
|
|
1986
2001
|
return colors;
|
|
@@ -2051,11 +2066,29 @@ function generateCSSOutput(colors, format) {
|
|
|
2051
2066
|
if (colors.length === 0) {
|
|
2052
2067
|
return "";
|
|
2053
2068
|
}
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2069
|
+
const rootColors = colors.filter((c) => c.theme === "root");
|
|
2070
|
+
const darkColors = colors.filter((c) => c.theme === "dark");
|
|
2071
|
+
let output = "";
|
|
2072
|
+
if (rootColors.length > 0) {
|
|
2073
|
+
const rootDeclarations = rootColors.map((color) => {
|
|
2074
|
+
const value = format === "oklch" && color.oklch && isColorValue(color.value) ? color.oklch : color.value;
|
|
2075
|
+
return ` ${color.name}: ${value};`;
|
|
2076
|
+
}).join("\n");
|
|
2077
|
+
output += `:root {
|
|
2078
|
+
${rootDeclarations}
|
|
2079
|
+
}`;
|
|
2080
|
+
}
|
|
2081
|
+
if (darkColors.length > 0) {
|
|
2082
|
+
if (output) output += "\n\n";
|
|
2083
|
+
const darkDeclarations = darkColors.map((color) => {
|
|
2084
|
+
const value = format === "oklch" && color.oklch && isColorValue(color.value) ? color.oklch : color.value;
|
|
2085
|
+
return ` ${color.name}: ${value};`;
|
|
2086
|
+
}).join("\n");
|
|
2087
|
+
output += `.dark {
|
|
2088
|
+
${darkDeclarations}
|
|
2089
|
+
}`;
|
|
2090
|
+
}
|
|
2091
|
+
return output;
|
|
2059
2092
|
}
|
|
2060
2093
|
|
|
2061
2094
|
// src/installers/base.ts
|
package/package.json
CHANGED