uniwind-plugin-next 1.4.0 → 1.4.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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [Uniwind](https://uniwind.dev/) config plugin for Next.js projects using Webpack. Turbopack-based projects are not supported at this stage.
4
4
 
5
+ ✅ Supports both Uniwind and Uniwind Pro
6
+
5
7
  ## Example
6
8
  See a fully working example project here: [Demo](http://uniwind-next.a16n.dev/) ([Source](https://github.com/a16n-dev/uniwind-plugin-next/tree/main/examples/next-16))
7
9
 
@@ -10,11 +12,11 @@ See the table below for tested versions of `uniwind-plugin-next` and correspondi
10
12
 
11
13
  Tested on Next `16.1`, but other versions will likely work fine.
12
14
 
13
- | Uniwind | uniwind-plugin-next |
14
- |-------------------|---------------------|
15
- | `1.2.7` | `1.4.0` |
16
- | `1.2.4` - `1.2.6` | `1.3.0` |
17
- | `1.2.2`-`1.2.3` | `1.2.0` |
15
+ | Uniwind | Uniwind Pro | uniwind-plugin-next |
16
+ |-------------------|----------------|---------------------|
17
+ | `1.2.7` | `1.0.0-beta.9` | `1.4.2` |
18
+ | `1.2.4` - `1.2.6` | N/A | `1.3.0` |
19
+ | `1.2.2`-`1.2.3` | N/A | `1.2.0` |
18
20
 
19
21
  ## Installation & setup
20
22
  This setup guide assumes you already have a next.js project setup with Tailwind v4
@@ -76,18 +78,6 @@ return (
76
78
 
77
79
  6. Start the dev server to generate `uniwind-types.d.ts`. Make sure that it's included in your `tsconfig.json`'s `include` array.
78
80
 
79
- ## Uniwind Pro
80
-
81
- If you're using the pro version of Uniwind, use `withUniwindPro()` instead of `withUniwind()`.
82
-
83
- ```ts
84
- // next.config.ts
85
- import { withUniwindPro } from 'uniwind-plugin-next'
86
-
87
- export default withUniwindPro(withExpo(nextConfig), { ... });
88
- ```
89
-
90
-
91
81
  ## SSR Considerations
92
82
  - This plugin marks all Uniwind web components with `'use client'` automatically, so you do not need to do this manually.
93
83
 
@@ -0,0 +1,8 @@
1
+
2
+ //#region src/common/constants.ts
3
+ const UNIWIND_PACKAGE_NAME = "uniwind";
4
+ const UNIWIND_PRO_PACKAGE_NAME = "uniwind-pro";
5
+
6
+ //#endregion
7
+ exports.UNIWIND_PACKAGE_NAME = UNIWIND_PACKAGE_NAME;
8
+ exports.UNIWIND_PRO_PACKAGE_NAME = UNIWIND_PRO_PACKAGE_NAME;
@@ -0,0 +1,7 @@
1
+ //#region src/common/constants.ts
2
+ const UNIWIND_PACKAGE_NAME = "uniwind";
3
+ const UNIWIND_PRO_PACKAGE_NAME = "uniwind-pro";
4
+
5
+ //#endregion
6
+ export { UNIWIND_PACKAGE_NAME, UNIWIND_PRO_PACKAGE_NAME };
7
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../../src/common/constants.ts"],"sourcesContent":["export const UNIWIND_PACKAGE_NAME = \"uniwind\";\nexport const UNIWIND_PRO_PACKAGE_NAME = \"uniwind-pro\";\n"],"mappings":";AAAA,MAAa,uBAAuB;AACpC,MAAa,2BAA2B"}
package/dist/index.cjs CHANGED
@@ -1,13 +1,3 @@
1
- const require_withUniwindBase = require('./webpack/withUniwindBase.cjs');
1
+ const require_withUniwind = require('./webpack/withUniwind.cjs');
2
2
 
3
- //#region src/index.ts
4
- function withUniwind(nextConfig = {}, uniwindConfig) {
5
- return require_withUniwindBase.withUniwindBase("uniwind", nextConfig, uniwindConfig);
6
- }
7
- function withUniwindPro(nextConfig = {}, uniwindConfig) {
8
- return require_withUniwindBase.withUniwindBase("uniwind-pro", nextConfig, uniwindConfig);
9
- }
10
-
11
- //#endregion
12
- exports.withUniwind = withUniwind;
13
- exports.withUniwindPro = withUniwindPro;
3
+ exports.withUniwind = require_withUniwind.withUniwind;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,2 @@
1
- import { UniwindConfig } from "./common/types.cjs";
2
-
3
- //#region src/index.d.ts
4
- declare function withUniwind(nextConfig: any | undefined, uniwindConfig: UniwindConfig): any;
5
- declare function withUniwindPro(nextConfig: any | undefined, uniwindConfig: UniwindConfig): any;
6
- //#endregion
7
- export { withUniwind, withUniwindPro };
8
- //# sourceMappingURL=index.d.cts.map
1
+ import { withUniwind } from "./webpack/withUniwind.cjs";
2
+ export { withUniwind };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,2 @@
1
- import { UniwindConfig } from "./common/types.mjs";
2
-
3
- //#region src/index.d.ts
4
- declare function withUniwind(nextConfig: any | undefined, uniwindConfig: UniwindConfig): any;
5
- declare function withUniwindPro(nextConfig: any | undefined, uniwindConfig: UniwindConfig): any;
6
- //#endregion
7
- export { withUniwind, withUniwindPro };
8
- //# sourceMappingURL=index.d.mts.map
1
+ import { withUniwind } from "./webpack/withUniwind.mjs";
2
+ export { withUniwind };
package/dist/index.mjs CHANGED
@@ -1,13 +1,3 @@
1
- import { withUniwindBase } from "./webpack/withUniwindBase.mjs";
1
+ import { withUniwind } from "./webpack/withUniwind.mjs";
2
2
 
3
- //#region src/index.ts
4
- function withUniwind(nextConfig = {}, uniwindConfig) {
5
- return withUniwindBase("uniwind", nextConfig, uniwindConfig);
6
- }
7
- function withUniwindPro(nextConfig = {}, uniwindConfig) {
8
- return withUniwindBase("uniwind-pro", nextConfig, uniwindConfig);
9
- }
10
-
11
- //#endregion
12
- export { withUniwind, withUniwindPro };
13
- //# sourceMappingURL=index.mjs.map
3
+ export { withUniwind };
@@ -20,7 +20,7 @@ const safeAreaTypes = [
20
20
  "safe-offset-*"
21
21
  ];
22
22
  const spacing = "--spacing(--value(integer))";
23
- const length = "--value([length])";
23
+ const length = "--value([length], --spacing-*)";
24
24
  const generateCSSForInsets = () => {
25
25
  let css = `@utility h-screen-safe {
26
26
  height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
@@ -19,7 +19,7 @@ const safeAreaTypes = [
19
19
  "safe-offset-*"
20
20
  ];
21
21
  const spacing = "--spacing(--value(integer))";
22
- const length = "--value([length])";
22
+ const length = "--value([length], --spacing-*)";
23
23
  const generateCSSForInsets = () => {
24
24
  let css = `@utility h-screen-safe {
25
25
  height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
@@ -1 +1 @@
1
- {"version":3,"file":"insets.mjs","names":[],"sources":["../../../../src/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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f,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"}
1
+ {"version":3,"file":"insets.mjs","names":[],"sources":["../../../../src/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], --spacing-*)\";\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;A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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"}
@@ -77,7 +77,24 @@ const generateCSSForThemes = async (themes, input) => {
77
77
  ...Array.from(Object.values(themesVariables).at(0) ?? []).map((variable) => ` ${variable}: unset;`),
78
78
  "}"
79
79
  ] : [];
80
- return [...themes.map((theme) => `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`), ...variablesCSS].join("\n");
80
+ return [...themes.map((theme) => {
81
+ const notOtherThemes = themes.map((t) => `.${t}, .${t} *`);
82
+ if (theme === "dark" || theme === "light") return [
83
+ `@custom-variant ${theme} {`,
84
+ ` &:where(.${theme}, .${theme} *) {`,
85
+ " @slot;",
86
+ " }",
87
+ "",
88
+ ` @media (prefers-color-scheme: ${theme}) {`,
89
+ ` &:not(:where(${notOtherThemes.join(", ")})) {`,
90
+ " @slot;",
91
+ " }",
92
+ " }",
93
+ "}",
94
+ ""
95
+ ].join("\n");
96
+ return `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`;
97
+ }), ...variablesCSS].join("\n");
81
98
  };
82
99
 
83
100
  //#endregion
@@ -74,7 +74,24 @@ const generateCSSForThemes = async (themes, input) => {
74
74
  ...Array.from(Object.values(themesVariables).at(0) ?? []).map((variable) => ` ${variable}: unset;`),
75
75
  "}"
76
76
  ] : [];
77
- return [...themes.map((theme) => `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`), ...variablesCSS].join("\n");
77
+ return [...themes.map((theme) => {
78
+ const notOtherThemes = themes.map((t) => `.${t}, .${t} *`);
79
+ if (theme === "dark" || theme === "light") return [
80
+ `@custom-variant ${theme} {`,
81
+ ` &:where(.${theme}, .${theme} *) {`,
82
+ " @slot;",
83
+ " }",
84
+ "",
85
+ ` @media (prefers-color-scheme: ${theme}) {`,
86
+ ` &:not(:where(${notOtherThemes.join(", ")})) {`,
87
+ " @slot;",
88
+ " }",
89
+ " }",
90
+ "}",
91
+ ""
92
+ ].join("\n");
93
+ return `@custom-variant ${theme} (&:where(.${theme}, .${theme} *));`;
94
+ }), ...variablesCSS].join("\n");
78
95
  };
79
96
 
80
97
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"themes.mjs","names":[],"sources":["../../../../src/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,gBAA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,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"}
1
+ {"version":3,"file":"themes.mjs","names":[],"sources":["../../../../src/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((theme) => {\n const notOtherThemes = themes.map((t) => `.${t}, .${t} *`);\n\n if (theme === \"dark\" || theme === \"light\") {\n return [\n `@custom-variant ${theme} {`,\n ` &:where(.${theme}, .${theme} *) {`,\n \" @slot;\",\n \" }\",\n \"\",\n ` @media (prefers-color-scheme: ${theme}) {`,\n ` &:not(:where(${notOtherThemes.join(\", \")})) {`,\n \" @slot;\",\n \" }\",\n \" }\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n }\n\n return `@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,S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B,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;AA2BN,QA1BmB,CACjB,GAAG,OAAO,KAAK,UAAU;EACvB,MAAM,iBAAiB,OAAO,KAAK,MAAM,IAAI,EAAE,KAAK,EAAE,IAAI;AAE1D,MAAI,UAAU,UAAU,UAAU,QAChC,QAAO;GACL,mBAAmB,MAAM;GACzB,eAAe,MAAM,KAAK,MAAM;GAChC;GACA;GACA;GACA,oCAAoC,MAAM;GAC1C,uBAAuB,eAAe,KAAK,KAAK,CAAC;GACjD;GACA;GACA;GACA;GACA;GACD,CAAC,KAAK,KAAK;AAGd,SAAO,mBAAmB,MAAM,aAAa,MAAM,KAAK,MAAM;GAC9D,EACF,GAAG,aACJ,CAAC,KAAK,KAAK"}
@@ -3,6 +3,7 @@ const require_util = require('../common/util.cjs');
3
3
  const require_index = require('../uniwind/src/css/index.cjs');
4
4
  const require_buildDtsFile = require('../uniwind/src/utils/buildDtsFile.cjs');
5
5
  const require_stringifyThemes = require('../uniwind/src/utils/stringifyThemes.cjs');
6
+ const require_constants = require('../common/constants.cjs');
6
7
  let path = require("path");
7
8
  path = require_rolldown_runtime.__toESM(path);
8
9
  let fs_promises = require("fs/promises");
@@ -10,8 +11,7 @@ let fs_promises = require("fs/promises");
10
11
  //#region src/webpack/UniwindWebpackPlugin.ts
11
12
  const dirname = typeof __dirname !== "undefined" ? __dirname : __dirname;
12
13
  var UniwindWebpackPlugin = class {
13
- constructor(packageName, { cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
14
- this.packageName = packageName;
14
+ constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
15
15
  this.hasRun = false;
16
16
  this.themes = require_util.uniq([
17
17
  "light",
@@ -27,12 +27,12 @@ var UniwindWebpackPlugin = class {
27
27
  this.hasRun = true;
28
28
  await require_index.buildCSS(this.themes, this.cssEntryFile);
29
29
  require_buildDtsFile.buildDtsFile(this.dtsFile, require_stringifyThemes.stringifyThemes(this.themes));
30
- await (0, fs_promises.cp)(path.default.resolve(dirname, "../uniwind/uniwind.css"), path.default.join(path.default.dirname(require.resolve(this.packageName + "/package.json", { paths: [compiler.context] })), "uniwind.css"), { force: true });
30
+ await (0, fs_promises.cp)(path.default.resolve(dirname, "../uniwind/uniwind.css"), path.default.join(path.default.dirname(require.resolve(require_constants.UNIWIND_PACKAGE_NAME + "/package.json", { paths: [compiler.context] })), "uniwind.css"), { force: true });
31
31
  });
32
32
  compiler.options.module = compiler.options.module || { rules: [] };
33
33
  compiler.options.module.rules.push({
34
34
  test: /config\.c?js$/,
35
- include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist`),
35
+ include: /* @__PURE__ */ new RegExp(`(${require_constants.UNIWIND_PACKAGE_NAME}|${require_constants.UNIWIND_PRO_PACKAGE_NAME})[\\/\\\\]dist`),
36
36
  use: [{
37
37
  loader: path.default.resolve(dirname, "configInjectionLoader.js"),
38
38
  options: { stringifiedThemes: require_stringifyThemes.stringifyThemes(this.themes) }
@@ -41,7 +41,7 @@ var UniwindWebpackPlugin = class {
41
41
  compiler.options.module.rules.push({
42
42
  test: /\.js$/,
43
43
  exclude: /index\.js$/,
44
- include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist[\\/\\\\]module[\\/\\\\]components[\\/\\\\]web`),
44
+ include: /* @__PURE__ */ new RegExp(`(${require_constants.UNIWIND_PACKAGE_NAME}|${require_constants.UNIWIND_PRO_PACKAGE_NAME})[\\/\\\\]dist`),
45
45
  use: [{ loader: path.default.resolve(dirname, "clientDirectiveLoader.js") }]
46
46
  });
47
47
  }
@@ -3,14 +3,14 @@ import { uniq } from "../common/util.mjs";
3
3
  import { buildCSS } from "../uniwind/src/css/index.mjs";
4
4
  import { buildDtsFile } from "../uniwind/src/utils/buildDtsFile.mjs";
5
5
  import { stringifyThemes } from "../uniwind/src/utils/stringifyThemes.mjs";
6
+ import { UNIWIND_PACKAGE_NAME, UNIWIND_PRO_PACKAGE_NAME } from "../common/constants.mjs";
6
7
  import path from "path";
7
8
  import { cp } from "fs/promises";
8
9
 
9
10
  //#region src/webpack/UniwindWebpackPlugin.ts
10
11
  const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
11
12
  var UniwindWebpackPlugin = class {
12
- constructor(packageName, { cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
13
- this.packageName = packageName;
13
+ constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
14
14
  this.hasRun = false;
15
15
  this.themes = uniq([
16
16
  "light",
@@ -26,12 +26,12 @@ var UniwindWebpackPlugin = class {
26
26
  this.hasRun = true;
27
27
  await buildCSS(this.themes, this.cssEntryFile);
28
28
  buildDtsFile(this.dtsFile, stringifyThemes(this.themes));
29
- await cp(path.resolve(dirname, "../uniwind/uniwind.css"), path.join(path.dirname(__require.resolve(this.packageName + "/package.json", { paths: [compiler.context] })), "uniwind.css"), { force: true });
29
+ await cp(path.resolve(dirname, "../uniwind/uniwind.css"), path.join(path.dirname(__require.resolve(UNIWIND_PACKAGE_NAME + "/package.json", { paths: [compiler.context] })), "uniwind.css"), { force: true });
30
30
  });
31
31
  compiler.options.module = compiler.options.module || { rules: [] };
32
32
  compiler.options.module.rules.push({
33
33
  test: /config\.c?js$/,
34
- include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist`),
34
+ include: /* @__PURE__ */ new RegExp(`(${UNIWIND_PACKAGE_NAME}|${UNIWIND_PRO_PACKAGE_NAME})[\\/\\\\]dist`),
35
35
  use: [{
36
36
  loader: path.resolve(dirname, "configInjectionLoader.js"),
37
37
  options: { stringifiedThemes: stringifyThemes(this.themes) }
@@ -40,7 +40,7 @@ var UniwindWebpackPlugin = class {
40
40
  compiler.options.module.rules.push({
41
41
  test: /\.js$/,
42
42
  exclude: /index\.js$/,
43
- include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist[\\/\\\\]module[\\/\\\\]components[\\/\\\\]web`),
43
+ include: /* @__PURE__ */ new RegExp(`(${UNIWIND_PACKAGE_NAME}|${UNIWIND_PRO_PACKAGE_NAME})[\\/\\\\]dist`),
44
44
  use: [{ loader: path.resolve(dirname, "clientDirectiveLoader.js") }]
45
45
  });
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UniwindWebpackPlugin.mjs","names":["packageName: uniwindPackageName"],"sources":["../../src/webpack/UniwindWebpackPlugin.ts"],"sourcesContent":["import type { Compiler } from \"webpack\";\nimport path from \"path\";\nimport { cp } from \"fs/promises\";\nimport { UniwindConfig, uniwindPackageName } from \"../common/types\";\nimport { uniq } from \"../common/util\";\nimport { buildCSS } from \"../uniwind/src/css\";\nimport { buildDtsFile } from \"../uniwind/src/utils/buildDtsFile\";\nimport { stringifyThemes } from \"../uniwind/src/utils/stringifyThemes\";\n\nconst dirname =\n typeof __dirname !== \"undefined\" ? __dirname : import.meta.dirname;\n\nexport class UniwindWebpackPlugin {\n private hasRun = false;\n private readonly themes: string[];\n private readonly dtsFile: string;\n private readonly cssEntryFile: string;\n\n constructor(\n private readonly packageName: uniwindPackageName,\n {\n cssEntryFile,\n extraThemes = [],\n dtsFile = \"uniwind-types.d.ts\",\n }: UniwindConfig,\n ) {\n this.themes = uniq([\"light\", \"dark\", ...(extraThemes ?? [])]);\n this.dtsFile = dtsFile;\n this.cssEntryFile = cssEntryFile;\n }\n\n apply(compiler: Compiler) {\n compiler.hooks.beforeCompile.tapPromise(\n \"UniwindWebpackPlugin\",\n async () => {\n if (this.hasRun) return;\n this.hasRun = true;\n\n // 1. Generate uniwind.css\n await buildCSS(this.themes, this.cssEntryFile);\n\n // 2. Generate uniwind-types.d.ts\n buildDtsFile(this.dtsFile, stringifyThemes(this.themes));\n\n // 3. Move uniwind.css to the uniwind package dist folder\n const builtCSSPath = path.resolve(dirname, \"../uniwind/uniwind.css\");\n const targetCSSPath = path.join(\n path.dirname(\n require.resolve(this.packageName + \"/package.json\", {\n paths: [compiler.context],\n }),\n ),\n \"uniwind.css\",\n );\n\n await cp(builtCSSPath, targetCSSPath, { force: true });\n },\n );\n\n // Inject the uniwind reinit() call\n compiler.options.module = compiler.options.module || { rules: [] };\n compiler.options.module.rules.push({\n test: /config\\.c?js$/,\n include: new RegExp(`${this.packageName}[\\\\/\\\\\\\\]dist`),\n use: [\n {\n loader: path.resolve(dirname, \"configInjectionLoader.js\"),\n options: {\n stringifiedThemes: stringifyThemes(this.themes),\n },\n },\n ],\n });\n // Add \"use client\" to uniwind web components\n compiler.options.module.rules.push({\n test: /\\.js$/,\n exclude: /index\\.js$/,\n include: new RegExp(\n `${this.packageName}[\\\\/\\\\\\\\]dist[\\\\/\\\\\\\\]module[\\\\/\\\\\\\\]components[\\\\/\\\\\\\\]web`,\n ),\n use: [\n {\n loader: path.resolve(dirname, \"clientDirectiveLoader.js\"),\n },\n ],\n });\n }\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,UACJ,OAAO,cAAc,cAAc,YAAY,OAAO,KAAK;AAE7D,IAAa,uBAAb,MAAkC;CAMhC,YACE,AAAiBA,aACjB,EACE,cACA,cAAc,EAAE,EAChB,UAAU,wBAEZ;EANiB;gBANF;AAaf,OAAK,SAAS,KAAK;GAAC;GAAS;GAAQ,GAAI,eAAe,EAAE;GAAE,CAAC;AAC7D,OAAK,UAAU;AACf,OAAK,eAAe;;CAGtB,MAAM,UAAoB;AACxB,WAAS,MAAM,cAAc,WAC3B,wBACA,YAAY;AACV,OAAI,KAAK,OAAQ;AACjB,QAAK,SAAS;AAGd,SAAM,SAAS,KAAK,QAAQ,KAAK,aAAa;AAG9C,gBAAa,KAAK,SAAS,gBAAgB,KAAK,OAAO,CAAC;AAaxD,SAAM,GAVe,KAAK,QAAQ,SAAS,yBAAyB,EAC9C,KAAK,KACzB,KAAK,kBACK,QAAQ,KAAK,cAAc,iBAAiB,EAClD,OAAO,CAAC,SAAS,QAAQ,EAC1B,CAAC,CACH,EACD,cACD,EAEqC,EAAE,OAAO,MAAM,CAAC;IAEzD;AAGD,WAAS,QAAQ,SAAS,SAAS,QAAQ,UAAU,EAAE,OAAO,EAAE,EAAE;AAClE,WAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,yBAAS,IAAI,OAAO,GAAG,KAAK,YAAY,eAAe;GACvD,KAAK,CACH;IACE,QAAQ,KAAK,QAAQ,SAAS,2BAA2B;IACzD,SAAS,EACP,mBAAmB,gBAAgB,KAAK,OAAO,EAChD;IACF,CACF;GACF,CAAC;AAEF,WAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,SAAS;GACT,yBAAS,IAAI,OACX,GAAG,KAAK,YAAY,6DACrB;GACD,KAAK,CACH,EACE,QAAQ,KAAK,QAAQ,SAAS,2BAA2B,EAC1D,CACF;GACF,CAAC"}
1
+ {"version":3,"file":"UniwindWebpackPlugin.mjs","names":[],"sources":["../../src/webpack/UniwindWebpackPlugin.ts"],"sourcesContent":["import type { Compiler } from \"webpack\";\nimport path from \"path\";\nimport { cp } from \"fs/promises\";\nimport { UniwindConfig, uniwindPackageName } from \"../common/types\";\nimport { uniq } from \"../common/util\";\nimport { buildCSS } from \"../uniwind/src/css\";\nimport { buildDtsFile } from \"../uniwind/src/utils/buildDtsFile\";\nimport { stringifyThemes } from \"../uniwind/src/utils/stringifyThemes\";\nimport {\n UNIWIND_PACKAGE_NAME,\n UNIWIND_PRO_PACKAGE_NAME,\n} from \"../common/constants\";\n\nconst dirname =\n typeof __dirname !== \"undefined\" ? __dirname : import.meta.dirname;\n\nexport class UniwindWebpackPlugin {\n private hasRun = false;\n private readonly themes: string[];\n private readonly dtsFile: string;\n private readonly cssEntryFile: string;\n\n constructor({\n cssEntryFile,\n extraThemes = [],\n dtsFile = \"uniwind-types.d.ts\",\n }: UniwindConfig) {\n this.themes = uniq([\"light\", \"dark\", ...(extraThemes ?? [])]);\n this.dtsFile = dtsFile;\n this.cssEntryFile = cssEntryFile;\n }\n\n apply(compiler: Compiler) {\n compiler.hooks.beforeCompile.tapPromise(\n \"UniwindWebpackPlugin\",\n async () => {\n if (this.hasRun) return;\n this.hasRun = true;\n\n // 1. Generate uniwind.css\n await buildCSS(this.themes, this.cssEntryFile);\n\n // 2. Generate uniwind-types.d.ts\n buildDtsFile(this.dtsFile, stringifyThemes(this.themes));\n\n // 3. Move uniwind.css to the uniwind package dist folder\n const builtCSSPath = path.resolve(dirname, \"../uniwind/uniwind.css\");\n const targetCSSPath = path.join(\n path.dirname(\n require.resolve(UNIWIND_PACKAGE_NAME + \"/package.json\", {\n paths: [compiler.context],\n }),\n ),\n \"uniwind.css\",\n );\n\n await cp(builtCSSPath, targetCSSPath, { force: true });\n },\n );\n\n // Inject the uniwind reinit() call\n compiler.options.module = compiler.options.module || { rules: [] };\n compiler.options.module.rules.push({\n test: /config\\.c?js$/,\n include: new RegExp(\n `(${UNIWIND_PACKAGE_NAME}|${UNIWIND_PRO_PACKAGE_NAME})[\\\\/\\\\\\\\]dist`,\n ),\n use: [\n {\n loader: path.resolve(dirname, \"configInjectionLoader.js\"),\n options: {\n stringifiedThemes: stringifyThemes(this.themes),\n },\n },\n ],\n });\n // Add \"use client\" to uniwind web components\n compiler.options.module.rules.push({\n test: /\\.js$/,\n exclude: /index\\.js$/,\n include: new RegExp(\n `(${UNIWIND_PACKAGE_NAME}|${UNIWIND_PRO_PACKAGE_NAME})[\\\\/\\\\\\\\]dist`,\n ),\n use: [\n {\n loader: path.resolve(dirname, \"clientDirectiveLoader.js\"),\n },\n ],\n });\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAM,UACJ,OAAO,cAAc,cAAc,YAAY,OAAO,KAAK;AAE7D,IAAa,uBAAb,MAAkC;CAMhC,YAAY,EACV,cACA,cAAc,EAAE,EAChB,UAAU,wBACM;gBATD;AAUf,OAAK,SAAS,KAAK;GAAC;GAAS;GAAQ,GAAI,eAAe,EAAE;GAAE,CAAC;AAC7D,OAAK,UAAU;AACf,OAAK,eAAe;;CAGtB,MAAM,UAAoB;AACxB,WAAS,MAAM,cAAc,WAC3B,wBACA,YAAY;AACV,OAAI,KAAK,OAAQ;AACjB,QAAK,SAAS;AAGd,SAAM,SAAS,KAAK,QAAQ,KAAK,aAAa;AAG9C,gBAAa,KAAK,SAAS,gBAAgB,KAAK,OAAO,CAAC;AAaxD,SAAM,GAVe,KAAK,QAAQ,SAAS,yBAAyB,EAC9C,KAAK,KACzB,KAAK,kBACK,QAAQ,uBAAuB,iBAAiB,EACtD,OAAO,CAAC,SAAS,QAAQ,EAC1B,CAAC,CACH,EACD,cACD,EAEqC,EAAE,OAAO,MAAM,CAAC;IAEzD;AAGD,WAAS,QAAQ,SAAS,SAAS,QAAQ,UAAU,EAAE,OAAO,EAAE,EAAE;AAClE,WAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,yBAAS,IAAI,OACX,IAAI,qBAAqB,GAAG,yBAAyB,gBACtD;GACD,KAAK,CACH;IACE,QAAQ,KAAK,QAAQ,SAAS,2BAA2B;IACzD,SAAS,EACP,mBAAmB,gBAAgB,KAAK,OAAO,EAChD;IACF,CACF;GACF,CAAC;AAEF,WAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,SAAS;GACT,yBAAS,IAAI,OACX,IAAI,qBAAqB,GAAG,yBAAyB,gBACtD;GACD,KAAK,CACH,EACE,QAAQ,KAAK,QAAQ,SAAS,2BAA2B,EAC1D,CACF;GACF,CAAC"}
@@ -1,34 +1,35 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_util = require('../common/util.cjs');
3
+ const require_constants = require('../common/constants.cjs');
3
4
  const require_UniwindWebpackPlugin = require('./UniwindWebpackPlugin.cjs');
4
5
  let webpack = require("webpack");
5
6
  webpack = require_rolldown_runtime.__toESM(webpack);
6
- let path = require("path");
7
- path = require_rolldown_runtime.__toESM(path);
8
7
 
9
- //#region src/webpack/withUniwindBase.ts
8
+ //#region src/webpack/withUniwind.ts
10
9
  const { NormalModuleReplacementPlugin } = webpack.default;
11
- function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
10
+ function withUniwind(nextConfig = {}, uniwindConfig) {
12
11
  if (typeof uniwindConfig === "undefined") throw new Error("Uniwind: You need to pass a second parameter to withUniwind");
13
12
  if (typeof uniwindConfig.cssEntryFile === "undefined") throw new Error("Uniwind: You need to pass a css entry file to withUniwind, e.g. withUniwind(config, { cssEntryFile: \"./global.css\" })");
14
13
  return {
15
14
  ...nextConfig,
16
15
  transpilePackages: require_util.uniq([
17
16
  ...nextConfig.transpilePackages || [],
18
- packageName,
17
+ require_constants.UNIWIND_PACKAGE_NAME,
18
+ require_constants.UNIWIND_PRO_PACKAGE_NAME,
19
19
  "react-native",
20
20
  "react-native-web"
21
21
  ]),
22
22
  webpack(config, options) {
23
23
  if (!config.plugins) config.plugins = [];
24
24
  config.plugins.push(new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {
25
- if ((resource.context || "").includes(`${path.default.sep}${packageName}${path.default.sep}dist${path.default.sep}module${path.default.sep}components${path.default.sep}web`)) resource.request = "react-native-web";
26
- else resource.request = `${packageName}/components/index`;
25
+ const context = resource.context || "";
26
+ if (context.includes(`/${require_constants.UNIWIND_PACKAGE_NAME}/dist`) || context.includes(`/${require_constants.UNIWIND_PRO_PACKAGE_NAME}/dist`)) resource.request = "react-native-web";
27
+ else resource.request = `${require_constants.UNIWIND_PACKAGE_NAME}/components/index`;
27
28
  }));
28
29
  config.plugins.push(new webpack.default.NormalModuleReplacementPlugin(/^\.\/createOrderedCSSStyleSheet$/, (resource) => {
29
- if ((resource.context || "").includes("react-native-web/dist/exports/StyleSheet")) resource.request = `${packageName}/components/createOrderedCSSStyleSheet`;
30
+ if ((resource.context || "").includes("react-native-web/dist/exports/StyleSheet")) resource.request = `${require_constants.UNIWIND_PACKAGE_NAME}/components/createOrderedCSSStyleSheet`;
30
31
  }));
31
- config.plugins.push(new require_UniwindWebpackPlugin.UniwindWebpackPlugin(packageName, uniwindConfig));
32
+ config.plugins.push(new require_UniwindWebpackPlugin.UniwindWebpackPlugin(uniwindConfig));
32
33
  if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
33
34
  return config;
34
35
  }
@@ -36,4 +37,4 @@ function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
36
37
  }
37
38
 
38
39
  //#endregion
39
- exports.withUniwindBase = withUniwindBase;
40
+ exports.withUniwind = withUniwind;
@@ -0,0 +1,7 @@
1
+ import { UniwindConfig } from "../common/types.cjs";
2
+
3
+ //#region src/webpack/withUniwind.d.ts
4
+ declare function withUniwind(nextConfig: any | undefined, uniwindConfig: UniwindConfig): any;
5
+ //#endregion
6
+ export { withUniwind };
7
+ //# sourceMappingURL=withUniwind.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withUniwind.d.cts","names":[],"sources":["../../src/webpack/withUniwind.ts"],"sourcesContent":[],"mappings":";;;iBAYgB,WAAA,6CAEC"}
@@ -0,0 +1,7 @@
1
+ import { UniwindConfig } from "../common/types.mjs";
2
+
3
+ //#region src/webpack/withUniwind.d.ts
4
+ declare function withUniwind(nextConfig: any | undefined, uniwindConfig: UniwindConfig): any;
5
+ //#endregion
6
+ export { withUniwind };
7
+ //# sourceMappingURL=withUniwind.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withUniwind.d.mts","names":[],"sources":["../../src/webpack/withUniwind.ts"],"sourcesContent":[],"mappings":";;;iBAYgB,WAAA,6CAEC"}
@@ -1,31 +1,33 @@
1
1
  import { uniq } from "../common/util.mjs";
2
+ import { UNIWIND_PACKAGE_NAME, UNIWIND_PRO_PACKAGE_NAME } from "../common/constants.mjs";
2
3
  import { UniwindWebpackPlugin } from "./UniwindWebpackPlugin.mjs";
3
4
  import webpack from "webpack";
4
- import path from "path";
5
5
 
6
- //#region src/webpack/withUniwindBase.ts
6
+ //#region src/webpack/withUniwind.ts
7
7
  const { NormalModuleReplacementPlugin } = webpack;
8
- function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
8
+ function withUniwind(nextConfig = {}, uniwindConfig) {
9
9
  if (typeof uniwindConfig === "undefined") throw new Error("Uniwind: You need to pass a second parameter to withUniwind");
10
10
  if (typeof uniwindConfig.cssEntryFile === "undefined") throw new Error("Uniwind: You need to pass a css entry file to withUniwind, e.g. withUniwind(config, { cssEntryFile: \"./global.css\" })");
11
11
  return {
12
12
  ...nextConfig,
13
13
  transpilePackages: uniq([
14
14
  ...nextConfig.transpilePackages || [],
15
- packageName,
15
+ UNIWIND_PACKAGE_NAME,
16
+ UNIWIND_PRO_PACKAGE_NAME,
16
17
  "react-native",
17
18
  "react-native-web"
18
19
  ]),
19
20
  webpack(config, options) {
20
21
  if (!config.plugins) config.plugins = [];
21
22
  config.plugins.push(new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {
22
- if ((resource.context || "").includes(`${path.sep}${packageName}${path.sep}dist${path.sep}module${path.sep}components${path.sep}web`)) resource.request = "react-native-web";
23
- else resource.request = `${packageName}/components/index`;
23
+ const context = resource.context || "";
24
+ if (context.includes(`/${UNIWIND_PACKAGE_NAME}/dist`) || context.includes(`/${UNIWIND_PRO_PACKAGE_NAME}/dist`)) resource.request = "react-native-web";
25
+ else resource.request = `${UNIWIND_PACKAGE_NAME}/components/index`;
24
26
  }));
25
27
  config.plugins.push(new webpack.NormalModuleReplacementPlugin(/^\.\/createOrderedCSSStyleSheet$/, (resource) => {
26
- if ((resource.context || "").includes("react-native-web/dist/exports/StyleSheet")) resource.request = `${packageName}/components/createOrderedCSSStyleSheet`;
28
+ if ((resource.context || "").includes("react-native-web/dist/exports/StyleSheet")) resource.request = `${UNIWIND_PACKAGE_NAME}/components/createOrderedCSSStyleSheet`;
27
29
  }));
28
- config.plugins.push(new UniwindWebpackPlugin(packageName, uniwindConfig));
30
+ config.plugins.push(new UniwindWebpackPlugin(uniwindConfig));
29
31
  if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
30
32
  return config;
31
33
  }
@@ -33,5 +35,5 @@ function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
33
35
  }
34
36
 
35
37
  //#endregion
36
- export { withUniwindBase };
37
- //# sourceMappingURL=withUniwindBase.mjs.map
38
+ export { withUniwind };
39
+ //# sourceMappingURL=withUniwind.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withUniwind.mjs","names":[],"sources":["../../src/webpack/withUniwind.ts"],"sourcesContent":["import webpack from \"webpack\";\nimport type { Configuration } from \"webpack\";\nimport { UniwindWebpackPlugin } from \"./UniwindWebpackPlugin\";\nimport { UniwindConfig } from \"../common/types\";\nimport { uniq } from \"../common/util\";\nimport {\n UNIWIND_PACKAGE_NAME,\n UNIWIND_PRO_PACKAGE_NAME,\n} from \"../common/constants\";\n\nconst { NormalModuleReplacementPlugin } = webpack;\n\nexport function withUniwind(\n nextConfig: any = {},\n uniwindConfig: UniwindConfig,\n): any {\n if (typeof uniwindConfig === \"undefined\") {\n throw new Error(\n \"Uniwind: You need to pass a second parameter to withUniwind\",\n );\n }\n\n if (typeof uniwindConfig.cssEntryFile === \"undefined\") {\n throw new Error(\n 'Uniwind: You need to pass a css entry file to withUniwind, e.g. withUniwind(config, { cssEntryFile: \"./global.css\" })',\n );\n }\n\n return {\n ...nextConfig,\n transpilePackages: uniq([\n ...(nextConfig.transpilePackages || []),\n UNIWIND_PACKAGE_NAME,\n UNIWIND_PRO_PACKAGE_NAME,\n \"react-native\",\n \"react-native-web\",\n ]),\n webpack(config: Configuration, options: any): Configuration {\n if (!config.plugins) config.plugins = [];\n\n // Rewrite imports, slightly more complex than usual because we need both:\n // Rewrite `react-native` imports to `uniwind/components/index`\n // Rewrite `react-native` imports within Uniwind components to `react-native-web`\n config.plugins.push(\n new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {\n const context = resource.context || \"\";\n\n if (\n context.includes(`/${UNIWIND_PACKAGE_NAME}/dist`) ||\n context.includes(`/${UNIWIND_PRO_PACKAGE_NAME}/dist`)\n ) {\n // Inside uniwind/dist → react-native-web\n resource.request = \"react-native-web\";\n } else {\n // Everywhere else → uniwind/web\n resource.request = `${UNIWIND_PACKAGE_NAME}/components/index`;\n }\n }),\n );\n\n // Rewrite createOrderedCSSStyleSheet from react-native-web to the Uniwind version\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(\n /^\\.\\/createOrderedCSSStyleSheet$/,\n (resource) => {\n const context = resource.context || \"\";\n\n // Scope rewrite to react-native-web only\n if (context.includes(\"react-native-web/dist/exports/StyleSheet\")) {\n resource.request = `${UNIWIND_PACKAGE_NAME}/components/createOrderedCSSStyleSheet`;\n }\n },\n ),\n );\n\n config.plugins.push(new UniwindWebpackPlugin(uniwindConfig));\n\n // Execute the user-defined webpack config.\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options);\n }\n\n return config;\n },\n };\n}\n"],"mappings":";;;;;;AAUA,MAAM,EAAE,kCAAkC;AAE1C,SAAgB,YACd,aAAkB,EAAE,EACpB,eACK;AACL,KAAI,OAAO,kBAAkB,YAC3B,OAAM,IAAI,MACR,8DACD;AAGH,KAAI,OAAO,cAAc,iBAAiB,YACxC,OAAM,IAAI,MACR,0HACD;AAGH,QAAO;EACL,GAAG;EACH,mBAAmB,KAAK;GACtB,GAAI,WAAW,qBAAqB,EAAE;GACtC;GACA;GACA;GACA;GACD,CAAC;EACF,QAAQ,QAAuB,SAA6B;AAC1D,OAAI,CAAC,OAAO,QAAS,QAAO,UAAU,EAAE;AAKxC,UAAO,QAAQ,KACb,IAAI,8BAA8B,mBAAmB,aAAa;IAChE,MAAM,UAAU,SAAS,WAAW;AAEpC,QACE,QAAQ,SAAS,IAAI,qBAAqB,OAAO,IACjD,QAAQ,SAAS,IAAI,yBAAyB,OAAO,CAGrD,UAAS,UAAU;QAGnB,UAAS,UAAU,GAAG,qBAAqB;KAE7C,CACH;AAGD,UAAO,QAAQ,KACb,IAAI,QAAQ,8BACV,qCACC,aAAa;AAIZ,SAHgB,SAAS,WAAW,IAGxB,SAAS,2CAA2C,CAC9D,UAAS,UAAU,GAAG,qBAAqB;KAGhD,CACF;AAED,UAAO,QAAQ,KAAK,IAAI,qBAAqB,cAAc,CAAC;AAG5D,OAAI,OAAO,WAAW,YAAY,WAChC,QAAO,WAAW,QAAQ,QAAQ,QAAQ;AAG5C,UAAO;;EAEV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniwind-plugin-next",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "author": "Alexander Nicholson",
5
5
  "description": "Compatibility plugin for using Uniwind with Next.js",
6
6
  "homepage": "https://github.com/a16n-dev/uniwind-plugin-next#readme",
@@ -13,7 +13,8 @@
13
13
  "build": "tsdown",
14
14
  "dev": "tsdown --watch",
15
15
  "typecheck": "tsc --noEmit",
16
- "test": "vitest run"
16
+ "test": "vitest run",
17
+ "format": "prettier --write ."
17
18
  },
18
19
  "devDependencies": {
19
20
  "@vitest/ui": "^4.0.16",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAGgB,WAAA,6CAEC;iBAKD,cAAA,6CAEC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAGgB,WAAA,6CAEC;iBAKD,cAAA,6CAEC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { UniwindConfig } from \"./common/types\";\nimport { withUniwindBase } from \"./webpack/withUniwindBase\";\n\nexport function withUniwind(\n nextConfig: any = {},\n uniwindConfig: UniwindConfig,\n): any {\n return withUniwindBase(\"uniwind\", nextConfig, uniwindConfig);\n}\n\nexport function withUniwindPro(\n nextConfig: any = {},\n uniwindConfig: UniwindConfig,\n): any {\n return withUniwindBase(\"uniwind-pro\", nextConfig, uniwindConfig);\n}\n"],"mappings":";;;AAGA,SAAgB,YACd,aAAkB,EAAE,EACpB,eACK;AACL,QAAO,gBAAgB,WAAW,YAAY,cAAc;;AAG9D,SAAgB,eACd,aAAkB,EAAE,EACpB,eACK;AACL,QAAO,gBAAgB,eAAe,YAAY,cAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"withUniwindBase.mjs","names":[],"sources":["../../src/webpack/withUniwindBase.ts"],"sourcesContent":["import webpack from \"webpack\";\nimport type { Configuration } from \"webpack\";\nimport path from \"path\";\nimport { UniwindWebpackPlugin } from \"./UniwindWebpackPlugin\";\nimport { UniwindConfig, uniwindPackageName } from \"../common/types\";\nimport { uniq } from \"../common/util\";\n\nconst { NormalModuleReplacementPlugin } = webpack;\n\nexport function withUniwindBase(\n packageName: uniwindPackageName,\n nextConfig: any = {},\n uniwindConfig: UniwindConfig,\n): any {\n if (typeof uniwindConfig === \"undefined\") {\n throw new Error(\n \"Uniwind: You need to pass a second parameter to withUniwind\",\n );\n }\n\n if (typeof uniwindConfig.cssEntryFile === \"undefined\") {\n throw new Error(\n 'Uniwind: You need to pass a css entry file to withUniwind, e.g. withUniwind(config, { cssEntryFile: \"./global.css\" })',\n );\n }\n\n return {\n ...nextConfig,\n transpilePackages: uniq([\n ...(nextConfig.transpilePackages || []),\n packageName,\n \"react-native\",\n \"react-native-web\",\n ]),\n webpack(config: Configuration, options: any): Configuration {\n if (!config.plugins) config.plugins = [];\n\n // Rewrite imports, slightly more complex than usual because we need both:\n // Rewrite `react-native` imports to `uniwind/components/index`\n // Rewrite `react-native` imports within Uniwind components to `react-native-web`\n config.plugins.push(\n new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {\n const context = resource.context || \"\";\n\n if (\n context.includes(\n `${path.sep}${packageName}${path.sep}dist${path.sep}module${path.sep}components${path.sep}web`,\n )\n ) {\n // Inside uniwind/dist → react-native-web\n resource.request = \"react-native-web\";\n } else {\n // Everywhere else → uniwind/web\n resource.request = `${packageName}/components/index`;\n }\n }),\n );\n\n // Rewrite createOrderedCSSStyleSheet from react-native-web to the Uniwind version\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(\n /^\\.\\/createOrderedCSSStyleSheet$/,\n (resource) => {\n const context = resource.context || \"\";\n\n // Scope rewrite to react-native-web only\n if (context.includes(\"react-native-web/dist/exports/StyleSheet\")) {\n resource.request = `${packageName}/components/createOrderedCSSStyleSheet`;\n }\n },\n ),\n );\n\n config.plugins.push(new UniwindWebpackPlugin(packageName, uniwindConfig));\n\n // Execute the user-defined webpack config.\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options);\n }\n\n return config;\n },\n };\n}\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,kCAAkC;AAE1C,SAAgB,gBACd,aACA,aAAkB,EAAE,EACpB,eACK;AACL,KAAI,OAAO,kBAAkB,YAC3B,OAAM,IAAI,MACR,8DACD;AAGH,KAAI,OAAO,cAAc,iBAAiB,YACxC,OAAM,IAAI,MACR,0HACD;AAGH,QAAO;EACL,GAAG;EACH,mBAAmB,KAAK;GACtB,GAAI,WAAW,qBAAqB,EAAE;GACtC;GACA;GACA;GACD,CAAC;EACF,QAAQ,QAAuB,SAA6B;AAC1D,OAAI,CAAC,OAAO,QAAS,QAAO,UAAU,EAAE;AAKxC,UAAO,QAAQ,KACb,IAAI,8BAA8B,mBAAmB,aAAa;AAGhE,SAFgB,SAAS,WAAW,IAG1B,SACN,GAAG,KAAK,MAAM,cAAc,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,KAAK,IAAI,YAAY,KAAK,IAAI,KAC3F,CAGD,UAAS,UAAU;QAGnB,UAAS,UAAU,GAAG,YAAY;KAEpC,CACH;AAGD,UAAO,QAAQ,KACb,IAAI,QAAQ,8BACV,qCACC,aAAa;AAIZ,SAHgB,SAAS,WAAW,IAGxB,SAAS,2CAA2C,CAC9D,UAAS,UAAU,GAAG,YAAY;KAGvC,CACF;AAED,UAAO,QAAQ,KAAK,IAAI,qBAAqB,aAAa,cAAc,CAAC;AAGzE,OAAI,OAAO,WAAW,YAAY,WAChC,QAAO,WAAW,QAAQ,QAAQ,QAAQ;AAG5C,UAAO;;EAEV"}