uniwind-plugin-next 1.1.2 → 1.3.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/README.md +21 -11
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/index.cjs +8 -365
- package/dist/index.d.cts +6 -9
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -9
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +8 -336
- package/dist/index.mjs.map +1 -0
- package/dist/postcss/index.cjs +8 -4
- package/dist/postcss/index.d.cts +10 -1
- package/dist/postcss/index.d.cts.map +1 -0
- package/dist/postcss/index.d.mts +11 -1
- package/dist/postcss/index.d.mts.map +1 -0
- package/dist/postcss/index.mjs +17 -19
- package/dist/postcss/index.mjs.map +1 -0
- package/dist/webpack/UniwindWebpackPlugin.cjs +49 -0
- package/dist/webpack/UniwindWebpackPlugin.mjs +48 -0
- package/dist/webpack/UniwindWebpackPlugin.mjs.map +1 -0
- package/dist/webpack/clientDirectiveLoader.js +8 -0
- package/dist/webpack/configInjectionLoader.js +6 -0
- package/dist/webpack/types.d.cts +9 -0
- package/dist/webpack/types.d.cts.map +1 -0
- package/dist/webpack/types.d.mts +9 -0
- package/dist/webpack/types.d.mts.map +1 -0
- package/dist/webpack/uniwind/package.cjs +11 -0
- package/dist/webpack/uniwind/package.mjs +6 -0
- package/dist/webpack/uniwind/package.mjs.map +1 -0
- package/dist/webpack/uniwind/src/css/index.cjs +28 -0
- package/dist/webpack/uniwind/src/css/index.mjs +26 -0
- package/dist/webpack/uniwind/src/css/index.mjs.map +1 -0
- package/dist/webpack/uniwind/src/css/insets.cjs +87 -0
- package/dist/webpack/uniwind/src/css/insets.mjs +87 -0
- package/dist/webpack/uniwind/src/css/insets.mjs.map +1 -0
- package/dist/webpack/uniwind/src/css/themes.cjs +84 -0
- package/dist/webpack/uniwind/src/css/themes.mjs +82 -0
- package/dist/webpack/uniwind/src/css/themes.mjs.map +1 -0
- package/dist/webpack/uniwind/src/css/variants.cjs +18 -0
- package/dist/webpack/uniwind/src/css/variants.mjs +18 -0
- package/dist/webpack/uniwind/src/css/variants.mjs.map +1 -0
- package/dist/webpack/uniwind/src/metro/logger.cjs +37 -0
- package/dist/webpack/uniwind/src/metro/logger.mjs +37 -0
- package/dist/webpack/uniwind/src/metro/logger.mjs.map +1 -0
- package/dist/webpack/uniwind/src/utils/buildDtsFile.cjs +27 -0
- package/dist/webpack/uniwind/src/utils/buildDtsFile.mjs +26 -0
- package/dist/webpack/uniwind/src/utils/buildDtsFile.mjs.map +1 -0
- package/dist/webpack/uniwind/src/utils/stringifyThemes.cjs +6 -0
- package/dist/webpack/uniwind/src/utils/stringifyThemes.mjs +6 -0
- package/dist/webpack/uniwind/src/utils/stringifyThemes.mjs.map +1 -0
- package/dist/webpack/util.cjs +6 -0
- package/dist/webpack/util.mjs +6 -0
- package/dist/webpack/util.mjs.map +1 -0
- package/dist/webpack/withUniwindBase.cjs +34 -0
- package/dist/webpack/withUniwindBase.mjs +32 -0
- package/dist/webpack/withUniwindBase.mjs.map +1 -0
- package/package.json +27 -8
- package/dist/chunk-3qlvafw2.mjs +0 -8
- package/dist/clientDirectiveLoader.js +0 -8
- package/dist/configInjectionLoader.js +0 -6
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { generateCSSForInsets } from "./insets.mjs";
|
|
2
|
+
import { generateCSSForThemes } from "./themes.mjs";
|
|
3
|
+
import { generateCSSForVariants } from "./variants.mjs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
|
|
7
|
+
//#region src/webpack/uniwind/src/css/index.ts
|
|
8
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
9
|
+
const buildCSS = async (themes, input) => {
|
|
10
|
+
const variants = generateCSSForVariants();
|
|
11
|
+
const insets = generateCSSForInsets();
|
|
12
|
+
const themesCSS = await generateCSSForThemes(themes, input);
|
|
13
|
+
const cssFilePath = path.join(dirname, "../../uniwind.css");
|
|
14
|
+
const oldCSSFile = fs.existsSync(cssFilePath) ? fs.readFileSync(cssFilePath, "utf-8") : "";
|
|
15
|
+
const newCssFile = [
|
|
16
|
+
variants,
|
|
17
|
+
insets,
|
|
18
|
+
themesCSS
|
|
19
|
+
].join("\n");
|
|
20
|
+
if (oldCSSFile === newCssFile) return;
|
|
21
|
+
fs.writeFileSync(cssFilePath, newCssFile);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { buildCSS };
|
|
26
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/index.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateCSSForInsets } from \"./insets\";\nimport { generateCSSForThemes } from \"./themes\";\nimport { generateCSSForVariants } from \"./variants\";\n\nconst dirname =\n typeof __dirname !== \"undefined\" ? __dirname : import.meta.dirname;\n\nexport const buildCSS = async (themes: Array<string>, input: string) => {\n const variants = generateCSSForVariants();\n const insets = generateCSSForInsets();\n const themesCSS = await generateCSSForThemes(themes, input);\n const cssFilePath = path.join(dirname, \"../../uniwind.css\");\n const oldCSSFile = fs.existsSync(cssFilePath)\n ? fs.readFileSync(cssFilePath, \"utf-8\")\n : \"\";\n\n const newCssFile = [variants, insets, themesCSS].join(\"\\n\");\n\n if (oldCSSFile === newCssFile) {\n return;\n }\n\n fs.writeFileSync(cssFilePath, newCssFile);\n};\n"],"mappings":";;;;;;;AAMA,MAAM,UACJ,OAAO,cAAc,cAAc,YAAY,OAAO,KAAK;AAE7D,MAAa,WAAW,OAAO,QAAuB,UAAkB;CACtE,MAAM,WAAW,wBAAwB;CACzC,MAAM,SAAS,sBAAsB;CACrC,MAAM,YAAY,MAAM,qBAAqB,QAAQ,MAAM;CAC3D,MAAM,cAAc,KAAK,KAAK,SAAS,oBAAoB;CAC3D,MAAM,aAAa,GAAG,WAAW,YAAY,GACzC,GAAG,aAAa,aAAa,QAAQ,GACrC;CAEJ,MAAM,aAAa;EAAC;EAAU;EAAQ;EAAU,CAAC,KAAK,KAAK;AAE3D,KAAI,eAAe,WACjB;AAGF,IAAG,cAAc,aAAa,WAAW"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/webpack/uniwind/src/css/insets.ts
|
|
3
|
+
const types = [
|
|
4
|
+
"margin",
|
|
5
|
+
"padding",
|
|
6
|
+
"inset"
|
|
7
|
+
];
|
|
8
|
+
const sides = [
|
|
9
|
+
"inset",
|
|
10
|
+
"x",
|
|
11
|
+
"y",
|
|
12
|
+
"top",
|
|
13
|
+
"bottom",
|
|
14
|
+
"left",
|
|
15
|
+
"right"
|
|
16
|
+
];
|
|
17
|
+
const safeAreaTypes = [
|
|
18
|
+
"safe",
|
|
19
|
+
"safe-or-*",
|
|
20
|
+
"safe-offset-*"
|
|
21
|
+
];
|
|
22
|
+
const spacing = "--spacing(--value(integer))";
|
|
23
|
+
const length = "--value([length])";
|
|
24
|
+
const generateCSSForInsets = () => {
|
|
25
|
+
let css = `@utility h-screen-safe {
|
|
26
|
+
height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
|
|
27
|
+
}\n\n`;
|
|
28
|
+
const getInsetsForSide = (side) => {
|
|
29
|
+
switch (side) {
|
|
30
|
+
case "top": return ["top"];
|
|
31
|
+
case "bottom": return ["bottom"];
|
|
32
|
+
case "left": return ["left"];
|
|
33
|
+
case "right": return ["right"];
|
|
34
|
+
case "x": return ["left", "right"];
|
|
35
|
+
case "y": return ["top", "bottom"];
|
|
36
|
+
case "inset": return [
|
|
37
|
+
"top",
|
|
38
|
+
"bottom",
|
|
39
|
+
"left",
|
|
40
|
+
"right"
|
|
41
|
+
];
|
|
42
|
+
default: return [];
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const getUtilityName = (typeName, side, safeAreaType) => {
|
|
46
|
+
if (typeName === "inset") return `${side}-${safeAreaType}`;
|
|
47
|
+
const sideSuffix = side === "inset" ? "" : side.at(0);
|
|
48
|
+
return `${typeName.at(0)}${sideSuffix}-${safeAreaType}`;
|
|
49
|
+
};
|
|
50
|
+
const getStyleProperty = (typeName, inset) => {
|
|
51
|
+
if (typeName === "inset") return inset;
|
|
52
|
+
return `${typeName}-${inset}`;
|
|
53
|
+
};
|
|
54
|
+
const getStylesForSafeAreaType = (safeAreaType, styles) => {
|
|
55
|
+
switch (safeAreaType) {
|
|
56
|
+
case "safe": return styles;
|
|
57
|
+
case "safe-or-*": return styles.flatMap((style) => {
|
|
58
|
+
const styleWithoutSemicolon = style.replace(";", "");
|
|
59
|
+
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${length});`)];
|
|
60
|
+
});
|
|
61
|
+
case "safe-offset-*": return styles.flatMap((style) => {
|
|
62
|
+
const styleWithoutSemicolon = style.replace(";", "");
|
|
63
|
+
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${length});`)];
|
|
64
|
+
});
|
|
65
|
+
default: return [];
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
types.forEach((type) => {
|
|
69
|
+
sides.forEach((side) => {
|
|
70
|
+
const styles = getInsetsForSide(side).map((inset) => `${getStyleProperty(type, inset)}: env(safe-area-inset-${inset});`);
|
|
71
|
+
safeAreaTypes.forEach((safeAreaType) => {
|
|
72
|
+
const utilityName = getUtilityName(type, side, safeAreaType);
|
|
73
|
+
css += [
|
|
74
|
+
`@utility ${utilityName} {`,
|
|
75
|
+
...getStylesForSafeAreaType(safeAreaType, styles).map((style) => ` ${style}`),
|
|
76
|
+
"}",
|
|
77
|
+
"",
|
|
78
|
+
""
|
|
79
|
+
].join("\n");
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return css.slice(0, -1);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
exports.generateCSSForInsets = generateCSSForInsets;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/webpack/uniwind/src/css/insets.ts
|
|
2
|
+
const types = [
|
|
3
|
+
"margin",
|
|
4
|
+
"padding",
|
|
5
|
+
"inset"
|
|
6
|
+
];
|
|
7
|
+
const sides = [
|
|
8
|
+
"inset",
|
|
9
|
+
"x",
|
|
10
|
+
"y",
|
|
11
|
+
"top",
|
|
12
|
+
"bottom",
|
|
13
|
+
"left",
|
|
14
|
+
"right"
|
|
15
|
+
];
|
|
16
|
+
const safeAreaTypes = [
|
|
17
|
+
"safe",
|
|
18
|
+
"safe-or-*",
|
|
19
|
+
"safe-offset-*"
|
|
20
|
+
];
|
|
21
|
+
const spacing = "--spacing(--value(integer))";
|
|
22
|
+
const length = "--value([length])";
|
|
23
|
+
const generateCSSForInsets = () => {
|
|
24
|
+
let css = `@utility h-screen-safe {
|
|
25
|
+
height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
|
|
26
|
+
}\n\n`;
|
|
27
|
+
const getInsetsForSide = (side) => {
|
|
28
|
+
switch (side) {
|
|
29
|
+
case "top": return ["top"];
|
|
30
|
+
case "bottom": return ["bottom"];
|
|
31
|
+
case "left": return ["left"];
|
|
32
|
+
case "right": return ["right"];
|
|
33
|
+
case "x": return ["left", "right"];
|
|
34
|
+
case "y": return ["top", "bottom"];
|
|
35
|
+
case "inset": return [
|
|
36
|
+
"top",
|
|
37
|
+
"bottom",
|
|
38
|
+
"left",
|
|
39
|
+
"right"
|
|
40
|
+
];
|
|
41
|
+
default: return [];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const getUtilityName = (typeName, side, safeAreaType) => {
|
|
45
|
+
if (typeName === "inset") return `${side}-${safeAreaType}`;
|
|
46
|
+
const sideSuffix = side === "inset" ? "" : side.at(0);
|
|
47
|
+
return `${typeName.at(0)}${sideSuffix}-${safeAreaType}`;
|
|
48
|
+
};
|
|
49
|
+
const getStyleProperty = (typeName, inset) => {
|
|
50
|
+
if (typeName === "inset") return inset;
|
|
51
|
+
return `${typeName}-${inset}`;
|
|
52
|
+
};
|
|
53
|
+
const getStylesForSafeAreaType = (safeAreaType, styles) => {
|
|
54
|
+
switch (safeAreaType) {
|
|
55
|
+
case "safe": return styles;
|
|
56
|
+
case "safe-or-*": return styles.flatMap((style) => {
|
|
57
|
+
const styleWithoutSemicolon = style.replace(";", "");
|
|
58
|
+
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${length});`)];
|
|
59
|
+
});
|
|
60
|
+
case "safe-offset-*": return styles.flatMap((style) => {
|
|
61
|
+
const styleWithoutSemicolon = style.replace(";", "");
|
|
62
|
+
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${length});`)];
|
|
63
|
+
});
|
|
64
|
+
default: return [];
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
types.forEach((type) => {
|
|
68
|
+
sides.forEach((side) => {
|
|
69
|
+
const styles = getInsetsForSide(side).map((inset) => `${getStyleProperty(type, inset)}: env(safe-area-inset-${inset});`);
|
|
70
|
+
safeAreaTypes.forEach((safeAreaType) => {
|
|
71
|
+
const utilityName = getUtilityName(type, side, safeAreaType);
|
|
72
|
+
css += [
|
|
73
|
+
`@utility ${utilityName} {`,
|
|
74
|
+
...getStylesForSafeAreaType(safeAreaType, styles).map((style) => ` ${style}`),
|
|
75
|
+
"}",
|
|
76
|
+
"",
|
|
77
|
+
""
|
|
78
|
+
].join("\n");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return css.slice(0, -1);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
export { generateCSSForInsets };
|
|
87
|
+
//# sourceMappingURL=insets.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insets.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/insets.ts"],"sourcesContent":["const types = [\"margin\", \"padding\", \"inset\"] as const;\nconst sides = [\"inset\", \"x\", \"y\", \"top\", \"bottom\", \"left\", \"right\"] as const;\nconst safeAreaTypes = [\"safe\", \"safe-or-*\", \"safe-offset-*\"] as const;\nconst spacing = \"--spacing(--value(integer))\";\nconst length = \"--value([length])\";\n\ntype Side = (typeof sides)[number];\ntype TypeName = (typeof types)[number];\ntype SafeAreaType = (typeof safeAreaTypes)[number];\ntype Inset = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport const generateCSSForInsets = () => {\n let css = `@utility h-screen-safe {\n height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));\n}\\n\\n`;\n\n const getInsetsForSide = (side: Side): Array<Inset> => {\n switch (side) {\n case \"top\":\n return [\"top\"];\n case \"bottom\":\n return [\"bottom\"];\n case \"left\":\n return [\"left\"];\n case \"right\":\n return [\"right\"];\n case \"x\":\n return [\"left\", \"right\"];\n case \"y\":\n return [\"top\", \"bottom\"];\n case \"inset\":\n return [\"top\", \"bottom\", \"left\", \"right\"];\n default:\n side satisfies never;\n return [];\n }\n };\n\n const getUtilityName = (\n typeName: TypeName,\n side: Side,\n safeAreaType: SafeAreaType,\n ) => {\n if (typeName === \"inset\") {\n return `${side}-${safeAreaType}`;\n }\n\n const sideSuffix = side === \"inset\" ? \"\" : side.at(0);\n\n return `${typeName.at(0)}${sideSuffix}-${safeAreaType}`;\n };\n\n const getStyleProperty = (typeName: TypeName, inset: Inset) => {\n if (typeName === \"inset\") {\n return inset;\n }\n\n return `${typeName}-${inset}`;\n };\n\n const getStylesForSafeAreaType = (\n safeAreaType: SafeAreaType,\n styles: Array<string>,\n ) => {\n switch (safeAreaType) {\n case \"safe\":\n return styles;\n case \"safe-or-*\":\n return styles.flatMap((style) => {\n const styleWithoutSemicolon = style.replace(\";\", \"\");\n\n return [\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: max(${env}, ${spacing});`,\n ),\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: max(${env}, ${length});`,\n ),\n ];\n });\n case \"safe-offset-*\":\n return styles.flatMap((style) => {\n const styleWithoutSemicolon = style.replace(\";\", \"\");\n\n return [\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: calc(${env} + ${spacing});`,\n ),\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: calc(${env} + ${length});`,\n ),\n ];\n });\n default:\n safeAreaType satisfies never;\n return [];\n }\n };\n\n types.forEach((type) => {\n sides.forEach((side) => {\n const insets = getInsetsForSide(side);\n const styles = insets.map(\n (inset) =>\n `${getStyleProperty(type, inset)}: env(safe-area-inset-${inset});`,\n );\n\n safeAreaTypes.forEach((safeAreaType) => {\n const utilityName = getUtilityName(type, side, safeAreaType);\n\n css += [\n `@utility ${utilityName} {`,\n ...getStylesForSafeAreaType(safeAreaType, styles).map(\n (style) => ` ${style}`,\n ),\n \"}\",\n \"\",\n \"\",\n ].join(\"\\n\");\n });\n });\n });\n\n // Remove the last newline character\n return css.slice(0, -1);\n};\n"],"mappings":";AAAA,MAAM,QAAQ;CAAC;CAAU;CAAW;CAAQ;AAC5C,MAAM,QAAQ;CAAC;CAAS;CAAK;CAAK;CAAO;CAAU;CAAQ;CAAQ;AACnE,MAAM,gBAAgB;CAAC;CAAQ;CAAa;CAAgB;AAC5D,MAAM,UAAU;AAChB,MAAM,SAAS;AAOf,MAAa,6BAA6B;CACxC,IAAI,MAAM;;;CAIV,MAAM,oBAAoB,SAA6B;AACrD,UAAQ,MAAR;GACE,KAAK,MACH,QAAO,CAAC,MAAM;GAChB,KAAK,SACH,QAAO,CAAC,SAAS;GACnB,KAAK,OACH,QAAO,CAAC,OAAO;GACjB,KAAK,QACH,QAAO,CAAC,QAAQ;GAClB,KAAK,IACH,QAAO,CAAC,QAAQ,QAAQ;GAC1B,KAAK,IACH,QAAO,CAAC,OAAO,SAAS;GAC1B,KAAK,QACH,QAAO;IAAC;IAAO;IAAU;IAAQ;IAAQ;GAC3C,QAEE,QAAO,EAAE;;;CAIf,MAAM,kBACJ,UACA,MACA,iBACG;AACH,MAAI,aAAa,QACf,QAAO,GAAG,KAAK,GAAG;EAGpB,MAAM,aAAa,SAAS,UAAU,KAAK,KAAK,GAAG,EAAE;AAErD,SAAO,GAAG,SAAS,GAAG,EAAE,GAAG,WAAW,GAAG;;CAG3C,MAAM,oBAAoB,UAAoB,UAAiB;AAC7D,MAAI,aAAa,QACf,QAAO;AAGT,SAAO,GAAG,SAAS,GAAG;;CAGxB,MAAM,4BACJ,cACA,WACG;AACH,UAAQ,cAAR;GACE,KAAK,OACH,QAAO;GACT,KAAK,YACH,QAAO,OAAO,SAAS,UAAU;IAC/B,MAAM,wBAAwB,MAAM,QAAQ,KAAK,GAAG;AAEpD,WAAO,CACL,sBAAsB,QACpB,cACC,GAAG,QAAQ,SAAS,IAAI,IAAI,QAAQ,IACtC,EACD,sBAAsB,QACpB,cACC,GAAG,QAAQ,SAAS,IAAI,IAAI,OAAO,IACrC,CACF;KACD;GACJ,KAAK,gBACH,QAAO,OAAO,SAAS,UAAU;IAC/B,MAAM,wBAAwB,MAAM,QAAQ,KAAK,GAAG;AAEpD,WAAO,CACL,sBAAsB,QACpB,cACC,GAAG,QAAQ,UAAU,IAAI,KAAK,QAAQ,IACxC,EACD,sBAAsB,QACpB,cACC,GAAG,QAAQ,UAAU,IAAI,KAAK,OAAO,IACvC,CACF;KACD;GACJ,QAEE,QAAO,EAAE;;;AAIf,OAAM,SAAS,SAAS;AACtB,QAAM,SAAS,SAAS;GAEtB,MAAM,SADS,iBAAiB,KAAK,CACf,KACnB,UACC,GAAG,iBAAiB,MAAM,MAAM,CAAC,wBAAwB,MAAM,IAClE;AAED,iBAAc,SAAS,iBAAiB;IACtC,MAAM,cAAc,eAAe,MAAM,MAAM,aAAa;AAE5D,WAAO;KACL,YAAY,YAAY;KACxB,GAAG,yBAAyB,cAAc,OAAO,CAAC,KAC/C,UAAU,OAAO,QACnB;KACD;KACA;KACA;KACD,CAAC,KAAK,KAAK;KACZ;IACF;GACF;AAGF,QAAO,IAAI,MAAM,GAAG,GAAG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_logger = require('../metro/logger.cjs');
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_rolldown_runtime.__toESM(path);
|
|
5
|
+
let fs = require("fs");
|
|
6
|
+
fs = require_rolldown_runtime.__toESM(fs);
|
|
7
|
+
let _tailwindcss_node = require("@tailwindcss/node");
|
|
8
|
+
let lightningcss = require("lightningcss");
|
|
9
|
+
|
|
10
|
+
//#region src/webpack/uniwind/src/css/themes.ts
|
|
11
|
+
const readFileSafe = (filePath) => {
|
|
12
|
+
try {
|
|
13
|
+
return fs.default.readFileSync(filePath, "utf-8");
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const isExcludedDependency = (url) => [
|
|
19
|
+
url.includes("node_modules/tailwindcss"),
|
|
20
|
+
url.includes("node_modules/@tailwindcss"),
|
|
21
|
+
url.includes("node_modules/uniwind")
|
|
22
|
+
].some(Boolean);
|
|
23
|
+
const generateCSSForThemes = async (themes, input) => {
|
|
24
|
+
const themesVariables = Object.fromEntries(themes.map((theme) => [theme, /* @__PURE__ */ new Set()]));
|
|
25
|
+
const findVariantsRec = async (cssPath) => {
|
|
26
|
+
const css = readFileSafe(cssPath);
|
|
27
|
+
if (css === null) return;
|
|
28
|
+
const { dependencies } = (0, lightningcss.transform)({
|
|
29
|
+
code: Buffer.from(css),
|
|
30
|
+
filename: "uniwind.css",
|
|
31
|
+
analyzeDependencies: true,
|
|
32
|
+
visitor: { Rule: (rule) => {
|
|
33
|
+
if (rule.type === "unknown" && rule.value.name === "variant") {
|
|
34
|
+
const [firstPrelude] = rule.value.prelude;
|
|
35
|
+
if (firstPrelude?.type !== "token" || firstPrelude.value.type !== "ident" || !themes.includes(firstPrelude.value.value)) return;
|
|
36
|
+
const theme = firstPrelude.value.value;
|
|
37
|
+
rule.value.block?.forEach((block) => {
|
|
38
|
+
if (block.type === "dashed-ident") themesVariables[theme]?.add(block.value);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} }
|
|
42
|
+
});
|
|
43
|
+
if (!Array.isArray(dependencies)) return;
|
|
44
|
+
const importUrls = /* @__PURE__ */ new Set();
|
|
45
|
+
await (0, _tailwindcss_node.compile)(dependencies.filter((dependency) => {
|
|
46
|
+
if (dependency.url.startsWith(".")) {
|
|
47
|
+
importUrls.add(path.default.resolve(path.default.dirname(cssPath), dependency.url));
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return !isExcludedDependency(dependency.url);
|
|
51
|
+
}).map((dependency) => `@import "${dependency.url}";`).join("\n"), {
|
|
52
|
+
base: path.default.resolve(path.default.dirname(cssPath)),
|
|
53
|
+
onDependency: (dependency) => {
|
|
54
|
+
if (isExcludedDependency(dependency)) return;
|
|
55
|
+
importUrls.add(dependency);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
for (const filePath of importUrls) await findVariantsRec(filePath);
|
|
59
|
+
};
|
|
60
|
+
await findVariantsRec(input);
|
|
61
|
+
let hasErrors = false;
|
|
62
|
+
const hasVariables = Object.values(themesVariables).some((variables) => variables.size > 0);
|
|
63
|
+
Object.values(themesVariables).forEach((variables) => {
|
|
64
|
+
Object.entries(themesVariables).forEach(([checkedTheme, checkedVariables]) => {
|
|
65
|
+
variables.forEach((variable) => {
|
|
66
|
+
if (!checkedVariables.has(variable)) {
|
|
67
|
+
require_logger.Logger.error(`Theme ${checkedTheme} is missing variable ${variable}`);
|
|
68
|
+
hasErrors = true;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
if (hasErrors) require_logger.Logger.error("All themes must have the same variables");
|
|
74
|
+
const variablesCSS = hasVariables ? [
|
|
75
|
+
"",
|
|
76
|
+
"@theme {",
|
|
77
|
+
...Array.from(Object.values(themesVariables).at(0) ?? []).map((variable) => ` ${variable}: unset;`),
|
|
78
|
+
"}"
|
|
79
|
+
] : [];
|
|
80
|
+
return [...themes.map((theme) => `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`), ...variablesCSS].join("\n");
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.generateCSSForThemes = generateCSSForThemes;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Logger } from "../metro/logger.mjs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { compile } from "@tailwindcss/node";
|
|
5
|
+
import { transform } from "lightningcss";
|
|
6
|
+
|
|
7
|
+
//#region src/webpack/uniwind/src/css/themes.ts
|
|
8
|
+
const readFileSafe = (filePath) => {
|
|
9
|
+
try {
|
|
10
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const isExcludedDependency = (url) => [
|
|
16
|
+
url.includes("node_modules/tailwindcss"),
|
|
17
|
+
url.includes("node_modules/@tailwindcss"),
|
|
18
|
+
url.includes("node_modules/uniwind")
|
|
19
|
+
].some(Boolean);
|
|
20
|
+
const generateCSSForThemes = async (themes, input) => {
|
|
21
|
+
const themesVariables = Object.fromEntries(themes.map((theme) => [theme, /* @__PURE__ */ new Set()]));
|
|
22
|
+
const findVariantsRec = async (cssPath) => {
|
|
23
|
+
const css = readFileSafe(cssPath);
|
|
24
|
+
if (css === null) return;
|
|
25
|
+
const { dependencies } = transform({
|
|
26
|
+
code: Buffer.from(css),
|
|
27
|
+
filename: "uniwind.css",
|
|
28
|
+
analyzeDependencies: true,
|
|
29
|
+
visitor: { Rule: (rule) => {
|
|
30
|
+
if (rule.type === "unknown" && rule.value.name === "variant") {
|
|
31
|
+
const [firstPrelude] = rule.value.prelude;
|
|
32
|
+
if (firstPrelude?.type !== "token" || firstPrelude.value.type !== "ident" || !themes.includes(firstPrelude.value.value)) return;
|
|
33
|
+
const theme = firstPrelude.value.value;
|
|
34
|
+
rule.value.block?.forEach((block) => {
|
|
35
|
+
if (block.type === "dashed-ident") themesVariables[theme]?.add(block.value);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} }
|
|
39
|
+
});
|
|
40
|
+
if (!Array.isArray(dependencies)) return;
|
|
41
|
+
const importUrls = /* @__PURE__ */ new Set();
|
|
42
|
+
await compile(dependencies.filter((dependency) => {
|
|
43
|
+
if (dependency.url.startsWith(".")) {
|
|
44
|
+
importUrls.add(path.resolve(path.dirname(cssPath), dependency.url));
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return !isExcludedDependency(dependency.url);
|
|
48
|
+
}).map((dependency) => `@import "${dependency.url}";`).join("\n"), {
|
|
49
|
+
base: path.resolve(path.dirname(cssPath)),
|
|
50
|
+
onDependency: (dependency) => {
|
|
51
|
+
if (isExcludedDependency(dependency)) return;
|
|
52
|
+
importUrls.add(dependency);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
for (const filePath of importUrls) await findVariantsRec(filePath);
|
|
56
|
+
};
|
|
57
|
+
await findVariantsRec(input);
|
|
58
|
+
let hasErrors = false;
|
|
59
|
+
const hasVariables = Object.values(themesVariables).some((variables) => variables.size > 0);
|
|
60
|
+
Object.values(themesVariables).forEach((variables) => {
|
|
61
|
+
Object.entries(themesVariables).forEach(([checkedTheme, checkedVariables]) => {
|
|
62
|
+
variables.forEach((variable) => {
|
|
63
|
+
if (!checkedVariables.has(variable)) {
|
|
64
|
+
Logger.error(`Theme ${checkedTheme} is missing variable ${variable}`);
|
|
65
|
+
hasErrors = true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
if (hasErrors) Logger.error("All themes must have the same variables");
|
|
71
|
+
const variablesCSS = hasVariables ? [
|
|
72
|
+
"",
|
|
73
|
+
"@theme {",
|
|
74
|
+
...Array.from(Object.values(themesVariables).at(0) ?? []).map((variable) => ` ${variable}: unset;`),
|
|
75
|
+
"}"
|
|
76
|
+
] : [];
|
|
77
|
+
return [...themes.map((theme) => `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`), ...variablesCSS].join("\n");
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export { generateCSSForThemes };
|
|
82
|
+
//# sourceMappingURL=themes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/themes.ts"],"sourcesContent":["import { compile } from \"@tailwindcss/node\";\nimport fs from \"fs\";\nimport { transform } from \"lightningcss\";\nimport path from \"path\";\nimport { Logger } from \"../metro/logger\";\n\nconst readFileSafe = (filePath: string) => {\n try {\n return fs.readFileSync(filePath, \"utf-8\");\n } catch {\n return null;\n }\n};\n\nconst isExcludedDependency = (url: string) =>\n [\n url.includes(\"node_modules/tailwindcss\"),\n url.includes(\"node_modules/@tailwindcss\"),\n url.includes(\"node_modules/uniwind\"),\n ].some(Boolean);\n\nexport const generateCSSForThemes = async (\n themes: Array<string>,\n input: string,\n) => {\n // css generation\n const themesVariables = Object.fromEntries(\n themes.map((theme) => [theme, new Set<string>()]),\n );\n\n const findVariantsRec = async (cssPath: string) => {\n const css = readFileSafe(cssPath);\n\n if (css === null) {\n return;\n }\n\n const { dependencies } = transform({\n code: Buffer.from(css),\n filename: \"uniwind.css\",\n analyzeDependencies: true,\n visitor: {\n Rule: (rule) => {\n if (rule.type === \"unknown\" && rule.value.name === \"variant\") {\n const [firstPrelude] = rule.value.prelude;\n\n if (\n firstPrelude?.type !== \"token\" ||\n firstPrelude.value.type !== \"ident\" ||\n !themes.includes(firstPrelude.value.value)\n ) {\n return;\n }\n\n const theme = firstPrelude.value.value;\n\n rule.value.block?.forEach((block) => {\n if (block.type === \"dashed-ident\") {\n themesVariables[theme]?.add(block.value);\n }\n });\n }\n },\n },\n });\n\n if (!Array.isArray(dependencies)) {\n return;\n }\n\n const importUrls = new Set<string>();\n const importsCSS = dependencies\n .filter((dependency) => {\n if (dependency.url.startsWith(\".\")) {\n importUrls.add(path.resolve(path.dirname(cssPath), dependency.url));\n\n return false;\n }\n\n return !isExcludedDependency(dependency.url);\n })\n .map((dependency) => `@import \"${dependency.url}\";`)\n .join(\"\\n\");\n\n await compile(importsCSS, {\n base: path.resolve(path.dirname(cssPath)),\n onDependency: (dependency) => {\n if (isExcludedDependency(dependency)) {\n return;\n }\n\n importUrls.add(dependency);\n },\n });\n\n for (const filePath of importUrls) {\n await findVariantsRec(filePath);\n }\n };\n\n await findVariantsRec(input);\n\n // Check if all themes have the same variables\n let hasErrors = false as boolean;\n const hasVariables = Object.values(themesVariables).some(\n (variables) => variables.size > 0,\n );\n\n Object.values(themesVariables).forEach((variables) => {\n Object.entries(themesVariables).forEach(\n ([checkedTheme, checkedVariables]) => {\n variables.forEach((variable) => {\n if (!checkedVariables.has(variable)) {\n Logger.error(\n `Theme ${checkedTheme} is missing variable ${variable}`,\n );\n hasErrors = true;\n }\n });\n },\n );\n });\n\n if (hasErrors) {\n Logger.error(\"All themes must have the same variables\");\n }\n\n const variablesCSS = hasVariables\n ? [\n \"\",\n \"@theme {\",\n ...Array.from(Object.values(themesVariables).at(0) ?? []).map(\n (variable) => ` ${variable}: unset;`,\n ),\n \"}\",\n ]\n : [];\n const uniwindCSS = [\n ...themes.map(\n (theme) => `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`,\n ),\n ...variablesCSS,\n ].join(\"\\n\");\n\n return uniwindCSS;\n};\n"],"mappings":";;;;;;;AAMA,MAAM,gBAAgB,aAAqB;AACzC,KAAI;AACF,SAAO,GAAG,aAAa,UAAU,QAAQ;SACnC;AACN,SAAO;;;AAIX,MAAM,wBAAwB,QAC5B;CACE,IAAI,SAAS,2BAA2B;CACxC,IAAI,SAAS,4BAA4B;CACzC,IAAI,SAAS,uBAAuB;CACrC,CAAC,KAAK,QAAQ;AAEjB,MAAa,uBAAuB,OAClC,QACA,UACG;CAEH,MAAM,kBAAkB,OAAO,YAC7B,OAAO,KAAK,UAAU,CAAC,uBAAO,IAAI,KAAa,CAAC,CAAC,CAClD;CAED,MAAM,kBAAkB,OAAO,YAAoB;EACjD,MAAM,MAAM,aAAa,QAAQ;AAEjC,MAAI,QAAQ,KACV;EAGF,MAAM,EAAE,iBAAiB,UAAU;GACjC,MAAM,OAAO,KAAK,IAAI;GACtB,UAAU;GACV,qBAAqB;GACrB,SAAS,EACP,OAAO,SAAS;AACd,QAAI,KAAK,SAAS,aAAa,KAAK,MAAM,SAAS,WAAW;KAC5D,MAAM,CAAC,gBAAgB,KAAK,MAAM;AAElC,SACE,cAAc,SAAS,WACvB,aAAa,MAAM,SAAS,WAC5B,CAAC,OAAO,SAAS,aAAa,MAAM,MAAM,CAE1C;KAGF,MAAM,QAAQ,aAAa,MAAM;AAEjC,UAAK,MAAM,OAAO,SAAS,UAAU;AACnC,UAAI,MAAM,SAAS,eACjB,iBAAgB,QAAQ,IAAI,MAAM,MAAM;OAE1C;;MAGP;GACF,CAAC;AAEF,MAAI,CAAC,MAAM,QAAQ,aAAa,CAC9B;EAGF,MAAM,6BAAa,IAAI,KAAa;AAcpC,QAAM,QAba,aAChB,QAAQ,eAAe;AACtB,OAAI,WAAW,IAAI,WAAW,IAAI,EAAE;AAClC,eAAW,IAAI,KAAK,QAAQ,KAAK,QAAQ,QAAQ,EAAE,WAAW,IAAI,CAAC;AAEnE,WAAO;;AAGT,UAAO,CAAC,qBAAqB,WAAW,IAAI;IAC5C,CACD,KAAK,eAAe,YAAY,WAAW,IAAI,IAAI,CACnD,KAAK,KAAK,EAEa;GACxB,MAAM,KAAK,QAAQ,KAAK,QAAQ,QAAQ,CAAC;GACzC,eAAe,eAAe;AAC5B,QAAI,qBAAqB,WAAW,CAClC;AAGF,eAAW,IAAI,WAAW;;GAE7B,CAAC;AAEF,OAAK,MAAM,YAAY,WACrB,OAAM,gBAAgB,SAAS;;AAInC,OAAM,gBAAgB,MAAM;CAG5B,IAAI,YAAY;CAChB,MAAM,eAAe,OAAO,OAAO,gBAAgB,CAAC,MACjD,cAAc,UAAU,OAAO,EACjC;AAED,QAAO,OAAO,gBAAgB,CAAC,SAAS,cAAc;AACpD,SAAO,QAAQ,gBAAgB,CAAC,SAC7B,CAAC,cAAc,sBAAsB;AACpC,aAAU,SAAS,aAAa;AAC9B,QAAI,CAAC,iBAAiB,IAAI,SAAS,EAAE;AACnC,YAAO,MACL,SAAS,aAAa,uBAAuB,WAC9C;AACD,iBAAY;;KAEd;IAEL;GACD;AAEF,KAAI,UACF,QAAO,MAAM,0CAA0C;CAGzD,MAAM,eAAe,eACjB;EACE;EACA;EACA,GAAG,MAAM,KAAK,OAAO,OAAO,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,KACvD,aAAa,OAAO,SAAS,UAC/B;EACD;EACD,GACD,EAAE;AAQN,QAPmB,CACjB,GAAG,OAAO,KACP,UAAU,mBAAmB,MAAM,aAAa,MAAM,KAAK,MAAM,OACnE,EACD,GAAG,aACJ,CAAC,KAAK,KAAK"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/webpack/uniwind/src/css/variants.ts
|
|
3
|
+
const variants = [
|
|
4
|
+
"ios",
|
|
5
|
+
"android",
|
|
6
|
+
"web",
|
|
7
|
+
"native"
|
|
8
|
+
];
|
|
9
|
+
const generateCSSForVariants = () => {
|
|
10
|
+
let css = "";
|
|
11
|
+
variants.forEach((variant) => {
|
|
12
|
+
css += `@custom-variant ${variant} (${variant === "web" ? "html &" : `@media ${variant}`});\n`;
|
|
13
|
+
});
|
|
14
|
+
return css;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.generateCSSForVariants = generateCSSForVariants;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/webpack/uniwind/src/css/variants.ts
|
|
2
|
+
const variants = [
|
|
3
|
+
"ios",
|
|
4
|
+
"android",
|
|
5
|
+
"web",
|
|
6
|
+
"native"
|
|
7
|
+
];
|
|
8
|
+
const generateCSSForVariants = () => {
|
|
9
|
+
let css = "";
|
|
10
|
+
variants.forEach((variant) => {
|
|
11
|
+
css += `@custom-variant ${variant} (${variant === "web" ? "html &" : `@media ${variant}`});\n`;
|
|
12
|
+
});
|
|
13
|
+
return css;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { generateCSSForVariants };
|
|
18
|
+
//# sourceMappingURL=variants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variants.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/variants.ts"],"sourcesContent":["const variants = [\"ios\", \"android\", \"web\", \"native\"];\n\nexport const generateCSSForVariants = () => {\n let css = \"\";\n\n variants.forEach((variant) => {\n css += `@custom-variant ${variant} (${variant === \"web\" ? \"html &\" : `@media ${variant}`});\\n`;\n });\n\n return css;\n};\n"],"mappings":";AAAA,MAAM,WAAW;CAAC;CAAO;CAAW;CAAO;CAAS;AAEpD,MAAa,+BAA+B;CAC1C,IAAI,MAAM;AAEV,UAAS,SAAS,YAAY;AAC5B,SAAO,mBAAmB,QAAQ,IAAI,YAAY,QAAQ,WAAW,UAAU,UAAU;GACzF;AAEF,QAAO"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/webpack/uniwind/src/metro/logger.ts
|
|
3
|
+
const red = "\x1B[91m";
|
|
4
|
+
const yellow = "\x1B[33m";
|
|
5
|
+
const blue = "\x1B[36m";
|
|
6
|
+
const reset = "\x1B[0m";
|
|
7
|
+
var Logger = class Logger {
|
|
8
|
+
static {
|
|
9
|
+
this.debug = false;
|
|
10
|
+
}
|
|
11
|
+
constructor(name) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
}
|
|
14
|
+
static log(message, meta = "") {
|
|
15
|
+
if (!Logger.debug) return;
|
|
16
|
+
console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);
|
|
17
|
+
}
|
|
18
|
+
static error(message, meta = "") {
|
|
19
|
+
console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
|
|
20
|
+
}
|
|
21
|
+
static warn(message, meta = "") {
|
|
22
|
+
if (!Logger.debug) return;
|
|
23
|
+
console.log(`${yellow}Uniwind Warning ${meta}- ${message}${reset}`);
|
|
24
|
+
}
|
|
25
|
+
log(message) {
|
|
26
|
+
Logger.log(message, `[${this.name} Processor] `);
|
|
27
|
+
}
|
|
28
|
+
error(message) {
|
|
29
|
+
Logger.error(message, `[${this.name} Processor] `);
|
|
30
|
+
}
|
|
31
|
+
warn(message) {
|
|
32
|
+
Logger.warn(message, `[${this.name} Processor] `);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/webpack/uniwind/src/metro/logger.ts
|
|
2
|
+
const red = "\x1B[91m";
|
|
3
|
+
const yellow = "\x1B[33m";
|
|
4
|
+
const blue = "\x1B[36m";
|
|
5
|
+
const reset = "\x1B[0m";
|
|
6
|
+
var Logger = class Logger {
|
|
7
|
+
static {
|
|
8
|
+
this.debug = false;
|
|
9
|
+
}
|
|
10
|
+
constructor(name) {
|
|
11
|
+
this.name = name;
|
|
12
|
+
}
|
|
13
|
+
static log(message, meta = "") {
|
|
14
|
+
if (!Logger.debug) return;
|
|
15
|
+
console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);
|
|
16
|
+
}
|
|
17
|
+
static error(message, meta = "") {
|
|
18
|
+
console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
|
|
19
|
+
}
|
|
20
|
+
static warn(message, meta = "") {
|
|
21
|
+
if (!Logger.debug) return;
|
|
22
|
+
console.log(`${yellow}Uniwind Warning ${meta}- ${message}${reset}`);
|
|
23
|
+
}
|
|
24
|
+
log(message) {
|
|
25
|
+
Logger.log(message, `[${this.name} Processor] `);
|
|
26
|
+
}
|
|
27
|
+
error(message) {
|
|
28
|
+
Logger.error(message, `[${this.name} Processor] `);
|
|
29
|
+
}
|
|
30
|
+
warn(message) {
|
|
31
|
+
Logger.warn(message, `[${this.name} Processor] `);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Logger };
|
|
37
|
+
//# sourceMappingURL=logger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":["name: string"],"sources":["../../../../../src/webpack/uniwind/src/metro/logger.ts"],"sourcesContent":["/* eslint-disable no-console */\n\nconst red = \"\\x1b[91m\";\nconst yellow = \"\\x1b[33m\";\nconst blue = \"\\x1b[36m\";\nconst reset = \"\\x1b[0m\";\n\nexport class Logger {\n static debug = false;\n\n constructor(private readonly name: string) {}\n\n static log(message: string, meta = \"\") {\n if (!Logger.debug) {\n return;\n }\n\n console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);\n }\n\n static error(message: string, meta = \"\") {\n console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);\n }\n\n static warn(message: string, meta = \"\") {\n if (!Logger.debug) {\n return;\n }\n\n console.log(`${yellow}Uniwind Warning ${meta}- ${message}${reset}`);\n }\n\n log(message: string) {\n Logger.log(message, `[${this.name} Processor] `);\n }\n\n error(message: string) {\n Logger.error(message, `[${this.name} Processor] `);\n }\n\n warn(message: string) {\n Logger.warn(message, `[${this.name} Processor] `);\n }\n}\n"],"mappings":";AAEA,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,OAAO;AACb,MAAM,QAAQ;AAEd,IAAa,SAAb,MAAa,OAAO;;eACH;;CAEf,YAAY,AAAiBA,MAAc;EAAd;;CAE7B,OAAO,IAAI,SAAiB,OAAO,IAAI;AACrC,MAAI,CAAC,OAAO,MACV;AAGF,UAAQ,IAAI,GAAG,KAAK,UAAU,KAAK,IAAI,UAAU,QAAQ;;CAG3D,OAAO,MAAM,SAAiB,OAAO,IAAI;AACvC,UAAQ,IAAI,GAAG,IAAI,gBAAgB,KAAK,IAAI,UAAU,QAAQ;;CAGhE,OAAO,KAAK,SAAiB,OAAO,IAAI;AACtC,MAAI,CAAC,OAAO,MACV;AAGF,UAAQ,IAAI,GAAG,OAAO,kBAAkB,KAAK,IAAI,UAAU,QAAQ;;CAGrE,IAAI,SAAiB;AACnB,SAAO,IAAI,SAAS,IAAI,KAAK,KAAK,cAAc;;CAGlD,MAAM,SAAiB;AACrB,SAAO,MAAM,SAAS,IAAI,KAAK,KAAK,cAAc;;CAGpD,KAAK,SAAiB;AACpB,SAAO,KAAK,SAAS,IAAI,KAAK,KAAK,cAAc"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_package = require('../../package.cjs');
|
|
3
|
+
let fs = require("fs");
|
|
4
|
+
fs = require_rolldown_runtime.__toESM(fs);
|
|
5
|
+
|
|
6
|
+
//#region src/webpack/uniwind/src/utils/buildDtsFile.ts
|
|
7
|
+
const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
8
|
+
const oldDtsContent = fs.default.existsSync(dtsPath) ? fs.default.readFileSync(dtsPath, "utf-8") : "";
|
|
9
|
+
const dtsContent = [
|
|
10
|
+
`// NOTE: This file is generated by ${require_package.name} and it should not be edited manually.`,
|
|
11
|
+
`/// <reference types="${require_package.name}/types" />`,
|
|
12
|
+
"",
|
|
13
|
+
`declare module '${require_package.name}' {`,
|
|
14
|
+
` export interface UniwindConfig {`,
|
|
15
|
+
` themes: readonly ${stringifiedThemes}`,
|
|
16
|
+
` }`,
|
|
17
|
+
`}`,
|
|
18
|
+
"",
|
|
19
|
+
`export {}`,
|
|
20
|
+
""
|
|
21
|
+
].join("\n");
|
|
22
|
+
if (oldDtsContent === dtsContent) return;
|
|
23
|
+
fs.default.writeFileSync(dtsPath, dtsContent);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.buildDtsFile = buildDtsFile;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { name } from "../../package.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
//#region src/webpack/uniwind/src/utils/buildDtsFile.ts
|
|
5
|
+
const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
6
|
+
const oldDtsContent = fs.existsSync(dtsPath) ? fs.readFileSync(dtsPath, "utf-8") : "";
|
|
7
|
+
const dtsContent = [
|
|
8
|
+
`// NOTE: This file is generated by ${name} and it should not be edited manually.`,
|
|
9
|
+
`/// <reference types="${name}/types" />`,
|
|
10
|
+
"",
|
|
11
|
+
`declare module '${name}' {`,
|
|
12
|
+
` export interface UniwindConfig {`,
|
|
13
|
+
` themes: readonly ${stringifiedThemes}`,
|
|
14
|
+
` }`,
|
|
15
|
+
`}`,
|
|
16
|
+
"",
|
|
17
|
+
`export {}`,
|
|
18
|
+
""
|
|
19
|
+
].join("\n");
|
|
20
|
+
if (oldDtsContent === dtsContent) return;
|
|
21
|
+
fs.writeFileSync(dtsPath, dtsContent);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { buildDtsFile };
|
|
26
|
+
//# sourceMappingURL=buildDtsFile.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildDtsFile.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/utils/buildDtsFile.ts"],"sourcesContent":["import fs from \"fs\";\nimport { name } from \"../../package.json\";\n\nexport const buildDtsFile = (dtsPath: string, stringifiedThemes: string) => {\n const oldDtsContent = fs.existsSync(dtsPath)\n ? fs.readFileSync(dtsPath, \"utf-8\")\n : \"\";\n const dtsContent = [\n `// NOTE: This file is generated by ${name} and it should not be edited manually.`,\n `/// <reference types=\"${name}/types\" />`,\n \"\",\n `declare module '${name}' {`,\n ` export interface UniwindConfig {`,\n ` themes: readonly ${stringifiedThemes}`,\n ` }`,\n `}`,\n \"\",\n `export {}`,\n \"\",\n ].join(\"\\n\");\n\n if (oldDtsContent === dtsContent) {\n return;\n }\n\n fs.writeFileSync(dtsPath, dtsContent);\n};\n"],"mappings":";;;;AAGA,MAAa,gBAAgB,SAAiB,sBAA8B;CAC1E,MAAM,gBAAgB,GAAG,WAAW,QAAQ,GACxC,GAAG,aAAa,SAAS,QAAQ,GACjC;CACJ,MAAM,aAAa;EACjB,sCAAsC,KAAK;EAC3C,yBAAyB,KAAK;EAC9B;EACA,mBAAmB,KAAK;EACxB;EACA,4BAA4B;EAC5B;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;AAEZ,KAAI,kBAAkB,WACpB;AAGF,IAAG,cAAc,SAAS,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyThemes.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/utils/stringifyThemes.ts"],"sourcesContent":["export const stringifyThemes = (themes: Array<string> = []) =>\n `[${themes.map((theme) => `'${theme}'`).join(\", \")}]`;\n"],"mappings":";AAAA,MAAa,mBAAmB,SAAwB,EAAE,KACxD,IAAI,OAAO,KAAK,UAAU,IAAI,MAAM,GAAG,CAAC,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.mjs","names":[],"sources":["../../src/webpack/util.ts"],"sourcesContent":["export const uniq = <T>(arr: Array<T>) => Array.from(new Set(arr));\n"],"mappings":";AAAA,MAAa,QAAW,QAAkB,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC"}
|