uniwind-plugin-next 1.2.0 → 1.4.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 +22 -14
- package/dist/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/{webpack → common}/types.d.cts +1 -1
- package/dist/common/types.d.cts.map +1 -0
- package/dist/{webpack → common}/types.d.mts +1 -1
- package/dist/common/types.d.mts.map +1 -0
- package/dist/common/util.cjs +6 -0
- package/dist/common/util.mjs +6 -0
- package/dist/common/util.mjs.map +1 -0
- package/dist/index.cjs +12 -2
- package/dist/index.d.cts +8 -2
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +8 -2
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12 -2
- package/dist/index.mjs.map +1 -0
- package/dist/postcss/index.cjs +0 -3
- package/dist/postcss/index.mjs +0 -3
- package/dist/postcss/index.mjs.map +1 -1
- package/dist/{webpack/uniwind → uniwind}/package.cjs +1 -1
- package/dist/uniwind/package.mjs +6 -0
- package/dist/uniwind/package.mjs.map +1 -0
- package/dist/{webpack/uniwind → uniwind}/src/css/index.cjs +8 -6
- package/dist/{webpack/uniwind → uniwind}/src/css/index.mjs +7 -5
- package/dist/uniwind/src/css/index.mjs.map +1 -0
- package/dist/uniwind/src/css/insets.cjs +87 -0
- package/dist/uniwind/src/css/insets.mjs +87 -0
- package/dist/uniwind/src/css/insets.mjs.map +1 -0
- package/dist/{webpack/uniwind → uniwind}/src/css/themes.cjs +2 -2
- package/dist/{webpack/uniwind → uniwind}/src/css/themes.mjs +1 -1
- package/dist/uniwind/src/css/themes.mjs.map +1 -0
- package/dist/{webpack/uniwind → uniwind}/src/css/variants.cjs +1 -1
- package/dist/{webpack/uniwind → uniwind}/src/css/variants.mjs +1 -1
- package/dist/uniwind/src/css/variants.mjs.map +1 -0
- package/dist/{webpack/uniwind → uniwind}/src/metro/logger.cjs +1 -1
- package/dist/{webpack/uniwind → uniwind}/src/metro/logger.mjs +1 -1
- package/dist/uniwind/src/metro/logger.mjs.map +1 -0
- package/dist/{webpack/uniwind → uniwind}/src/utils/buildDtsFile.cjs +2 -2
- package/dist/{webpack/uniwind → uniwind}/src/utils/buildDtsFile.mjs +1 -1
- package/dist/uniwind/src/utils/buildDtsFile.mjs.map +1 -0
- package/dist/{webpack/uniwind → uniwind}/src/utils/stringifyThemes.cjs +1 -1
- package/dist/{webpack/uniwind → uniwind}/src/utils/stringifyThemes.mjs +1 -1
- package/dist/uniwind/src/utils/stringifyThemes.mjs.map +1 -0
- package/dist/webpack/UniwindWebpackPlugin.cjs +11 -8
- package/dist/webpack/UniwindWebpackPlugin.mjs +11 -7
- package/dist/webpack/UniwindWebpackPlugin.mjs.map +1 -1
- package/dist/webpack/withUniwindBase.cjs +39 -0
- package/dist/webpack/withUniwindBase.mjs +37 -0
- package/dist/webpack/withUniwindBase.mjs.map +1 -0
- package/package.json +11 -14
- package/LICENSE +0 -21
- package/dist/webpack/types.d.cts.map +0 -1
- package/dist/webpack/types.d.mts.map +0 -1
- package/dist/webpack/uniwind/package.mjs +0 -6
- package/dist/webpack/uniwind/package.mjs.map +0 -1
- package/dist/webpack/uniwind/src/css/index.mjs.map +0 -1
- package/dist/webpack/uniwind/src/css/insets.cjs +0 -66
- package/dist/webpack/uniwind/src/css/insets.mjs +0 -66
- package/dist/webpack/uniwind/src/css/insets.mjs.map +0 -1
- package/dist/webpack/uniwind/src/css/themes.mjs.map +0 -1
- package/dist/webpack/uniwind/src/css/variants.mjs.map +0 -1
- package/dist/webpack/uniwind/src/metro/logger.mjs.map +0 -1
- package/dist/webpack/uniwind/src/utils/buildDtsFile.mjs.map +0 -1
- package/dist/webpack/uniwind/src/utils/common.cjs +0 -6
- package/dist/webpack/uniwind/src/utils/common.mjs +0 -6
- package/dist/webpack/uniwind/src/utils/common.mjs.map +0 -1
- package/dist/webpack/uniwind/src/utils/stringifyThemes.mjs.map +0 -1
- package/dist/webpack/withUniwind.cjs +0 -34
- package/dist/webpack/withUniwind.d.cts +0 -7
- package/dist/webpack/withUniwind.d.cts.map +0 -1
- package/dist/webpack/withUniwind.d.mts +0 -7
- package/dist/webpack/withUniwind.d.mts.map +0 -1
- package/dist/webpack/withUniwind.mjs +0 -32
- package/dist/webpack/withUniwind.mjs.map +0 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
3
|
-
const require_index = require('
|
|
4
|
-
const require_buildDtsFile = require('
|
|
5
|
-
const require_stringifyThemes = require('
|
|
2
|
+
const require_util = require('../common/util.cjs');
|
|
3
|
+
const require_index = require('../uniwind/src/css/index.cjs');
|
|
4
|
+
const require_buildDtsFile = require('../uniwind/src/utils/buildDtsFile.cjs');
|
|
5
|
+
const require_stringifyThemes = require('../uniwind/src/utils/stringifyThemes.cjs');
|
|
6
6
|
let path = require("path");
|
|
7
7
|
path = require_rolldown_runtime.__toESM(path);
|
|
8
|
+
let fs_promises = require("fs/promises");
|
|
8
9
|
|
|
9
10
|
//#region src/webpack/UniwindWebpackPlugin.ts
|
|
10
11
|
const dirname = typeof __dirname !== "undefined" ? __dirname : __dirname;
|
|
11
12
|
var UniwindWebpackPlugin = class {
|
|
12
|
-
constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
13
|
+
constructor(packageName, { cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
14
|
+
this.packageName = packageName;
|
|
13
15
|
this.hasRun = false;
|
|
14
|
-
this.themes =
|
|
16
|
+
this.themes = require_util.uniq([
|
|
15
17
|
"light",
|
|
16
18
|
"dark",
|
|
17
19
|
...extraThemes ?? []
|
|
@@ -25,11 +27,12 @@ var UniwindWebpackPlugin = class {
|
|
|
25
27
|
this.hasRun = true;
|
|
26
28
|
await require_index.buildCSS(this.themes, this.cssEntryFile);
|
|
27
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 });
|
|
28
31
|
});
|
|
29
32
|
compiler.options.module = compiler.options.module || { rules: [] };
|
|
30
33
|
compiler.options.module.rules.push({
|
|
31
34
|
test: /config\.c?js$/,
|
|
32
|
-
include:
|
|
35
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist`),
|
|
33
36
|
use: [{
|
|
34
37
|
loader: path.default.resolve(dirname, "configInjectionLoader.js"),
|
|
35
38
|
options: { stringifiedThemes: require_stringifyThemes.stringifyThemes(this.themes) }
|
|
@@ -38,7 +41,7 @@ var UniwindWebpackPlugin = class {
|
|
|
38
41
|
compiler.options.module.rules.push({
|
|
39
42
|
test: /\.js$/,
|
|
40
43
|
exclude: /index\.js$/,
|
|
41
|
-
include:
|
|
44
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist[\\/\\\\]module[\\/\\\\]components[\\/\\\\]web`),
|
|
42
45
|
use: [{ loader: path.default.resolve(dirname, "clientDirectiveLoader.js") }]
|
|
43
46
|
});
|
|
44
47
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { __require } from "../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { uniq } from "../common/util.mjs";
|
|
3
|
+
import { buildCSS } from "../uniwind/src/css/index.mjs";
|
|
4
|
+
import { buildDtsFile } from "../uniwind/src/utils/buildDtsFile.mjs";
|
|
5
|
+
import { stringifyThemes } from "../uniwind/src/utils/stringifyThemes.mjs";
|
|
5
6
|
import path from "path";
|
|
7
|
+
import { cp } from "fs/promises";
|
|
6
8
|
|
|
7
9
|
//#region src/webpack/UniwindWebpackPlugin.ts
|
|
8
10
|
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
9
11
|
var UniwindWebpackPlugin = class {
|
|
10
|
-
constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
12
|
+
constructor(packageName, { cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
13
|
+
this.packageName = packageName;
|
|
11
14
|
this.hasRun = false;
|
|
12
15
|
this.themes = uniq([
|
|
13
16
|
"light",
|
|
@@ -23,11 +26,12 @@ var UniwindWebpackPlugin = class {
|
|
|
23
26
|
this.hasRun = true;
|
|
24
27
|
await buildCSS(this.themes, this.cssEntryFile);
|
|
25
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 });
|
|
26
30
|
});
|
|
27
31
|
compiler.options.module = compiler.options.module || { rules: [] };
|
|
28
32
|
compiler.options.module.rules.push({
|
|
29
33
|
test: /config\.c?js$/,
|
|
30
|
-
include:
|
|
34
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist`),
|
|
31
35
|
use: [{
|
|
32
36
|
loader: path.resolve(dirname, "configInjectionLoader.js"),
|
|
33
37
|
options: { stringifiedThemes: stringifyThemes(this.themes) }
|
|
@@ -36,7 +40,7 @@ var UniwindWebpackPlugin = class {
|
|
|
36
40
|
compiler.options.module.rules.push({
|
|
37
41
|
test: /\.js$/,
|
|
38
42
|
exclude: /index\.js$/,
|
|
39
|
-
include:
|
|
43
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist[\\/\\\\]module[\\/\\\\]components[\\/\\\\]web`),
|
|
40
44
|
use: [{ loader: path.resolve(dirname, "clientDirectiveLoader.js") }]
|
|
41
45
|
});
|
|
42
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniwindWebpackPlugin.mjs","names":[],"sources":["../../src/webpack/UniwindWebpackPlugin.ts"],"sourcesContent":["import {
|
|
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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_util = require('../common/util.cjs');
|
|
3
|
+
const require_UniwindWebpackPlugin = require('./UniwindWebpackPlugin.cjs');
|
|
4
|
+
let webpack = require("webpack");
|
|
5
|
+
webpack = require_rolldown_runtime.__toESM(webpack);
|
|
6
|
+
let path = require("path");
|
|
7
|
+
path = require_rolldown_runtime.__toESM(path);
|
|
8
|
+
|
|
9
|
+
//#region src/webpack/withUniwindBase.ts
|
|
10
|
+
const { NormalModuleReplacementPlugin } = webpack.default;
|
|
11
|
+
function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
|
|
12
|
+
if (typeof uniwindConfig === "undefined") throw new Error("Uniwind: You need to pass a second parameter to withUniwind");
|
|
13
|
+
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
|
+
return {
|
|
15
|
+
...nextConfig,
|
|
16
|
+
transpilePackages: require_util.uniq([
|
|
17
|
+
...nextConfig.transpilePackages || [],
|
|
18
|
+
packageName,
|
|
19
|
+
"react-native",
|
|
20
|
+
"react-native-web"
|
|
21
|
+
]),
|
|
22
|
+
webpack(config, options) {
|
|
23
|
+
if (!config.plugins) config.plugins = [];
|
|
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`;
|
|
27
|
+
}));
|
|
28
|
+
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
|
+
}));
|
|
31
|
+
config.plugins.push(new require_UniwindWebpackPlugin.UniwindWebpackPlugin(packageName, uniwindConfig));
|
|
32
|
+
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.withUniwindBase = withUniwindBase;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { uniq } from "../common/util.mjs";
|
|
2
|
+
import { UniwindWebpackPlugin } from "./UniwindWebpackPlugin.mjs";
|
|
3
|
+
import webpack from "webpack";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
//#region src/webpack/withUniwindBase.ts
|
|
7
|
+
const { NormalModuleReplacementPlugin } = webpack;
|
|
8
|
+
function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
|
|
9
|
+
if (typeof uniwindConfig === "undefined") throw new Error("Uniwind: You need to pass a second parameter to withUniwind");
|
|
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
|
+
return {
|
|
12
|
+
...nextConfig,
|
|
13
|
+
transpilePackages: uniq([
|
|
14
|
+
...nextConfig.transpilePackages || [],
|
|
15
|
+
packageName,
|
|
16
|
+
"react-native",
|
|
17
|
+
"react-native-web"
|
|
18
|
+
]),
|
|
19
|
+
webpack(config, options) {
|
|
20
|
+
if (!config.plugins) config.plugins = [];
|
|
21
|
+
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`;
|
|
24
|
+
}));
|
|
25
|
+
config.plugins.push(new webpack.NormalModuleReplacementPlugin(/^\.\/createOrderedCSSStyleSheet$/, (resource) => {
|
|
26
|
+
if ((resource.context || "").includes("react-native-web/dist/exports/StyleSheet")) resource.request = `${packageName}/components/createOrderedCSSStyleSheet`;
|
|
27
|
+
}));
|
|
28
|
+
config.plugins.push(new UniwindWebpackPlugin(packageName, uniwindConfig));
|
|
29
|
+
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
|
|
30
|
+
return config;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { withUniwindBase };
|
|
37
|
+
//# sourceMappingURL=withUniwindBase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniwind-plugin-next",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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",
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"url": "https://github.com/a16n-dev/uniwind-plugin-next.git"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsdown",
|
|
14
|
+
"dev": "tsdown --watch",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"test": "vitest run"
|
|
17
|
+
},
|
|
12
18
|
"devDependencies": {
|
|
13
19
|
"@vitest/ui": "^4.0.16",
|
|
14
20
|
"postcss": "^8.5.6",
|
|
@@ -19,7 +25,7 @@
|
|
|
19
25
|
"@tailwindcss/node": "^4",
|
|
20
26
|
"lightningcss": ">=1.30.2",
|
|
21
27
|
"postcss": "^8",
|
|
22
|
-
"uniwind": "
|
|
28
|
+
"uniwind": "^1.2.7",
|
|
23
29
|
"webpack": "^5"
|
|
24
30
|
},
|
|
25
31
|
"exports": {
|
|
@@ -31,10 +37,7 @@
|
|
|
31
37
|
"require": "./dist/postcss/index.cjs",
|
|
32
38
|
"import": "./dist/postcss/index.mjs"
|
|
33
39
|
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
"./css": {
|
|
36
|
-
"style": "./dist/webpack/uniwind/uniwind.css"
|
|
37
|
-
}
|
|
40
|
+
"./package.json": "./package.json"
|
|
38
41
|
},
|
|
39
42
|
"main": "./dist/index.cjs",
|
|
40
43
|
"module": "./dist/index.mjs",
|
|
@@ -42,11 +45,5 @@
|
|
|
42
45
|
"files": [
|
|
43
46
|
"dist",
|
|
44
47
|
"README.md"
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
"build": "tsdown",
|
|
48
|
-
"dev": "tsdown --watch",
|
|
49
|
-
"typecheck": "tsc --noEmit",
|
|
50
|
-
"test": "vitest run"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
48
|
+
]
|
|
49
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Alexander Nicholson
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/webpack/types.ts"],"sourcesContent":[],"mappings":";KAAY,aAAA;EAAA,YAAA,EAAA,MAAa;gBAET"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/webpack/types.ts"],"sourcesContent":[],"mappings":";KAAY,aAAA;EAAA,YAAA,EAAA,MAAa;gBAET"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.mjs","names":[],"sources":["../../../src/webpack/uniwind/package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
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 cssFile = path.join(dirname, \"../../uniwind.css\");\n const oldCSSFile = fs.existsSync(cssFile)\n ? fs.readFileSync(cssFile, \"utf-8\")\n : \"\";\n\n if (oldCSSFile === cssFile) {\n return;\n }\n\n fs.writeFileSync(cssFile, [variants, insets, themesCSS].join(\"\\n\"));\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,UAAU,KAAK,KAAK,SAAS,oBAAoB;AAKvD,MAJmB,GAAG,WAAW,QAAQ,GACrC,GAAG,aAAa,SAAS,QAAQ,GACjC,QAEe,QACjB;AAGF,IAAG,cAAc,SAAS;EAAC;EAAU;EAAQ;EAAU,CAAC,KAAK,KAAK,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/webpack/uniwind/src/css/insets.ts
|
|
3
|
-
const types = ["m", "p"];
|
|
4
|
-
const sides = [
|
|
5
|
-
"",
|
|
6
|
-
"x",
|
|
7
|
-
"y",
|
|
8
|
-
"t",
|
|
9
|
-
"b",
|
|
10
|
-
"l",
|
|
11
|
-
"r"
|
|
12
|
-
];
|
|
13
|
-
const spacing = "--spacing(--value(integer))";
|
|
14
|
-
const length = "--value([length])";
|
|
15
|
-
const generateCSSForInsets = () => {
|
|
16
|
-
let css = `@utility h-screen-safe {
|
|
17
|
-
height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
|
|
18
|
-
}\n`;
|
|
19
|
-
const getInsetsForSide = (side) => {
|
|
20
|
-
switch (side) {
|
|
21
|
-
case "t": return ["top"];
|
|
22
|
-
case "b": return ["bottom"];
|
|
23
|
-
case "l": return ["left"];
|
|
24
|
-
case "r": return ["right"];
|
|
25
|
-
case "x": return ["left", "right"];
|
|
26
|
-
case "y": return ["top", "bottom"];
|
|
27
|
-
default: return [
|
|
28
|
-
"top",
|
|
29
|
-
"bottom",
|
|
30
|
-
"left",
|
|
31
|
-
"right"
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
types.forEach((type) => {
|
|
36
|
-
sides.forEach((side) => {
|
|
37
|
-
const styleName = type === "m" ? "margin" : "padding";
|
|
38
|
-
const styles = getInsetsForSide(side).map((inset) => `${styleName}-${inset}: env(safe-area-inset-${inset});`);
|
|
39
|
-
const safeStyles = styles.flatMap((style) => {
|
|
40
|
-
const styleWithoutSemicolon = style.replace(";", "");
|
|
41
|
-
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${length});`)];
|
|
42
|
-
});
|
|
43
|
-
const safeOffsetStyles = styles.flatMap((style) => {
|
|
44
|
-
const styleWithoutSemicolon = style.replace(";", "");
|
|
45
|
-
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${length});`)];
|
|
46
|
-
});
|
|
47
|
-
css += `
|
|
48
|
-
@utility ${type}${side}-safe {
|
|
49
|
-
${styles.join("\n ")}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@utility ${type}${side}-safe-or-* {
|
|
53
|
-
${safeStyles.join("\n ")}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@utility ${type}${side}-safe-offset-* {
|
|
57
|
-
${safeOffsetStyles.join("\n ")}
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
return css.replaceAll(" ", "").trim() + "\n";
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
exports.generateCSSForInsets = generateCSSForInsets;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
//#region src/webpack/uniwind/src/css/insets.ts
|
|
2
|
-
const types = ["m", "p"];
|
|
3
|
-
const sides = [
|
|
4
|
-
"",
|
|
5
|
-
"x",
|
|
6
|
-
"y",
|
|
7
|
-
"t",
|
|
8
|
-
"b",
|
|
9
|
-
"l",
|
|
10
|
-
"r"
|
|
11
|
-
];
|
|
12
|
-
const spacing = "--spacing(--value(integer))";
|
|
13
|
-
const length = "--value([length])";
|
|
14
|
-
const generateCSSForInsets = () => {
|
|
15
|
-
let css = `@utility h-screen-safe {
|
|
16
|
-
height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
|
|
17
|
-
}\n`;
|
|
18
|
-
const getInsetsForSide = (side) => {
|
|
19
|
-
switch (side) {
|
|
20
|
-
case "t": return ["top"];
|
|
21
|
-
case "b": return ["bottom"];
|
|
22
|
-
case "l": return ["left"];
|
|
23
|
-
case "r": return ["right"];
|
|
24
|
-
case "x": return ["left", "right"];
|
|
25
|
-
case "y": return ["top", "bottom"];
|
|
26
|
-
default: return [
|
|
27
|
-
"top",
|
|
28
|
-
"bottom",
|
|
29
|
-
"left",
|
|
30
|
-
"right"
|
|
31
|
-
];
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
types.forEach((type) => {
|
|
35
|
-
sides.forEach((side) => {
|
|
36
|
-
const styleName = type === "m" ? "margin" : "padding";
|
|
37
|
-
const styles = getInsetsForSide(side).map((inset) => `${styleName}-${inset}: env(safe-area-inset-${inset});`);
|
|
38
|
-
const safeStyles = styles.flatMap((style) => {
|
|
39
|
-
const styleWithoutSemicolon = style.replace(";", "");
|
|
40
|
-
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${length});`)];
|
|
41
|
-
});
|
|
42
|
-
const safeOffsetStyles = styles.flatMap((style) => {
|
|
43
|
-
const styleWithoutSemicolon = style.replace(";", "");
|
|
44
|
-
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${length});`)];
|
|
45
|
-
});
|
|
46
|
-
css += `
|
|
47
|
-
@utility ${type}${side}-safe {
|
|
48
|
-
${styles.join("\n ")}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@utility ${type}${side}-safe-or-* {
|
|
52
|
-
${safeStyles.join("\n ")}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@utility ${type}${side}-safe-offset-* {
|
|
56
|
-
${safeOffsetStyles.join("\n ")}
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
return css.replaceAll(" ", "").trim() + "\n";
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
export { generateCSSForInsets };
|
|
66
|
-
//# sourceMappingURL=insets.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insets.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/insets.ts"],"sourcesContent":["const types = [\"m\", \"p\"] as const;\nconst sides = [\"\", \"x\", \"y\", \"t\", \"b\", \"l\", \"r\"] as const;\nconst spacing = \"--spacing(--value(integer))\";\nconst length = \"--value([length])\";\n\ntype Side = (typeof sides)[number];\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 const getInsetsForSide = (side: Side) => {\n switch (side) {\n case \"t\":\n return [\"top\"];\n case \"b\":\n return [\"bottom\"];\n case \"l\":\n return [\"left\"];\n case \"r\":\n return [\"right\"];\n case \"x\":\n return [\"left\", \"right\"];\n case \"y\":\n return [\"top\", \"bottom\"];\n default:\n return [\"top\", \"bottom\", \"left\", \"right\"];\n }\n };\n\n types.forEach((type) => {\n sides.forEach((side) => {\n const styleName = type === \"m\" ? \"margin\" : \"padding\";\n const insets = getInsetsForSide(side);\n const styles = insets.map(\n (inset) => `${styleName}-${inset}: env(safe-area-inset-${inset});`,\n );\n const safeStyles = 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 const safeOffsetStyles = 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\n css += `\n @utility ${type}${side}-safe {\n ${styles.join(\"\\n \")}\n }\n \n @utility ${type}${side}-safe-or-* {\n ${safeStyles.join(\"\\n \")}\n }\n \n @utility ${type}${side}-safe-offset-* {\n ${safeOffsetStyles.join(\"\\n \")}\n }\n `;\n });\n });\n\n // Remove all 8 spaces groups\n // eslint-disable-next-line prefer-template\n return css.replaceAll(\" \", \"\").trim() + \"\\n\";\n};\n"],"mappings":";AAAA,MAAM,QAAQ,CAAC,KAAK,IAAI;AACxB,MAAM,QAAQ;CAAC;CAAI;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;AAChD,MAAM,UAAU;AAChB,MAAM,SAAS;AAIf,MAAa,6BAA6B;CACxC,IAAI,MAAM;;;CAIV,MAAM,oBAAoB,SAAe;AACvC,UAAQ,MAAR;GACE,KAAK,IACH,QAAO,CAAC,MAAM;GAChB,KAAK,IACH,QAAO,CAAC,SAAS;GACnB,KAAK,IACH,QAAO,CAAC,OAAO;GACjB,KAAK,IACH,QAAO,CAAC,QAAQ;GAClB,KAAK,IACH,QAAO,CAAC,QAAQ,QAAQ;GAC1B,KAAK,IACH,QAAO,CAAC,OAAO,SAAS;GAC1B,QACE,QAAO;IAAC;IAAO;IAAU;IAAQ;IAAQ;;;AAI/C,OAAM,SAAS,SAAS;AACtB,QAAM,SAAS,SAAS;GACtB,MAAM,YAAY,SAAS,MAAM,WAAW;GAE5C,MAAM,SADS,iBAAiB,KAAK,CACf,KACnB,UAAU,GAAG,UAAU,GAAG,MAAM,wBAAwB,MAAM,IAChE;GACD,MAAM,aAAa,OAAO,SAAS,UAAU;IAC3C,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;GACF,MAAM,mBAAmB,OAAO,SAAS,UAAU;IACjD,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;AAEF,UAAO;2BACc,OAAO,KAAK;sBACjB,OAAO,KAAK,SAAS,CAAC;;;2BAGjB,OAAO,KAAK;sBACjB,WAAW,KAAK,SAAS,CAAC;;;2BAGrB,OAAO,KAAK;sBACjB,iBAAiB,KAAK,SAAS,CAAC;;;IAGhD;GACF;AAIF,QAAO,IAAI,WAAW,YAAY,GAAG,CAAC,MAAM,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/utils/common.ts"],"sourcesContent":["export const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\nexport const toCamelCase = (str: string) =>\n str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n\ntype P<I, O> = (data: I) => O;\ntype PipeFns<T> = {\n <A>(a: P<T, A>): A;\n <A, B>(a: P<T, A>, b: P<A, B>): B;\n <A, B, C>(a: P<T, A>, b: P<A, B>, c: P<B, C>): C;\n <A, B, C, D>(a: P<T, A>, b: P<A, B>, c: P<B, C>, d: P<C, D>): D;\n <A, B, C, D, E>(\n a: P<T, A>,\n b: P<A, B>,\n c: P<B, C>,\n d: P<C, D>,\n e: P<D, E>,\n ): E;\n <A, B, C, D, E, F>(\n a: P<T, A>,\n b: P<A, B>,\n c: P<B, C>,\n d: P<C, D>,\n e: P<D, E>,\n f: P<E, F>,\n ): F;\n <A, B, C, D, E, F, G>(\n a: P<T, A>,\n b: P<A, B>,\n c: P<B, C>,\n d: P<C, D>,\n e: P<D, E>,\n f: P<E, F>,\n g: P<F, G>,\n ): G;\n <A, B, C, D, E, F, G, H>(\n a: P<T, A>,\n b: P<A, B>,\n c: P<B, C>,\n d: P<C, D>,\n e: P<D, E>,\n f: P<E, F>,\n g: P<F, G>,\n h: P<G, H>,\n ): H;\n (...fns: Array<P<T, T>>): T;\n};\n\nexport const pipe = <T>(data: T) =>\n ((...fns: Array<any>) =>\n fns.reduce((acc, fn) => fn(acc), data)) as PipeFns<T>;\n\nexport const isNumber = (data: any) => {\n if (typeof data === \"number\") {\n return true;\n }\n\n if (typeof data === \"string\" && data !== \"\") {\n return !isNaN(Number(data));\n }\n\n return false;\n};\n\nexport const smartSplit = (str: string, separator = \" \" as string | RegExp) => {\n const escaper = \"&&&\";\n\n return pipe(str)(\n (x) => x.replace(/\\s\\?\\?\\s/g, `${escaper}??${escaper}`),\n (x) => x.replace(/\\s([+\\-*/])\\s/g, `${escaper}$1${escaper}`),\n (x) => x.split(separator),\n (x) => x.map((token) => token.replace(new RegExp(escaper, \"g\"), \" \")),\n );\n};\n\nexport const addMissingSpaces = (str: string) =>\n pipe(str)(\n (x) => x.trim(),\n (x) => x.replace(/([^ {])this/g, \"$1 this\"),\n (x) => x.replace(/\\](?=\\d)/g, \"] \"),\n (x) => x.replace(/\\)(?=\\S)/g, \") \"),\n (x) => x.replace(/(?<!^)(?<!\\s)\"(?=\\d)/g, '\" '),\n );\n\nexport const uniq = <T>(arr: Array<T>) => Array.from(new Set(arr));\n\nexport const isValidJSValue = (jsValueString: string) => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func\n new Function(`const test = ${jsValueString}`);\n\n return true;\n } catch {\n return false;\n }\n};\n\nexport const shouldBeSerialized = (value: string) => {\n if (value.includes(\"-\")) {\n return value.split(\"-\").some(shouldBeSerialized);\n }\n\n return [\n isNumber(value),\n value.startsWith(\"this[\"),\n value.startsWith(\"rt.\"),\n /[*/+-]/.test(value),\n value.includes('\"'),\n value.includes(\" \"),\n ].some(Boolean);\n};\n\nexport const roundToPrecision = (value: number, precision: number) =>\n parseFloat(value.toFixed(precision));\n\nexport const deepEqual = <T>(a: T, b: T): boolean => {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (\n typeof a !== \"object\" ||\n a === null ||\n typeof b !== \"object\" ||\n b === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(a) as Array<keyof T>;\n\n if (keysA.length !== Object.keys(b).length) {\n return false;\n }\n\n return keysA.every(\n (key) =>\n deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key),\n );\n};\n"],"mappings":";AAqFA,MAAa,QAAW,QAAkB,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_common = require('./uniwind/src/utils/common.cjs');
|
|
3
|
-
const require_UniwindWebpackPlugin = require('./UniwindWebpackPlugin.cjs');
|
|
4
|
-
let webpack = require("webpack");
|
|
5
|
-
webpack = require_rolldown_runtime.__toESM(webpack);
|
|
6
|
-
let path = require("path");
|
|
7
|
-
path = require_rolldown_runtime.__toESM(path);
|
|
8
|
-
|
|
9
|
-
//#region src/webpack/withUniwind.ts
|
|
10
|
-
const { NormalModuleReplacementPlugin } = webpack.default;
|
|
11
|
-
function withUniwind(nextConfig = {}, uniwindConfig) {
|
|
12
|
-
return {
|
|
13
|
-
...nextConfig,
|
|
14
|
-
transpilePackages: require_common.uniq([
|
|
15
|
-
...nextConfig.transpilePackages || [],
|
|
16
|
-
"uniwind",
|
|
17
|
-
"react-native",
|
|
18
|
-
"react-native-web"
|
|
19
|
-
]),
|
|
20
|
-
webpack(config, options) {
|
|
21
|
-
if (!config.plugins) config.plugins = [];
|
|
22
|
-
config.plugins.push(new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {
|
|
23
|
-
if ((resource.context || "").includes(`${path.default.sep}uniwind${path.default.sep}dist${path.default.sep}module${path.default.sep}components${path.default.sep}web`)) resource.request = "react-native-web";
|
|
24
|
-
else resource.request = "uniwind/components/index";
|
|
25
|
-
}));
|
|
26
|
-
config.plugins.push(new require_UniwindWebpackPlugin.UniwindWebpackPlugin(uniwindConfig));
|
|
27
|
-
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
|
|
28
|
-
return config;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
exports.withUniwind = withUniwind;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { UniwindConfig } from "./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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withUniwind.d.cts","names":[],"sources":["../../src/webpack/withUniwind.ts"],"sourcesContent":[],"mappings":";;;iBASgB,WAAA,6CAEC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { UniwindConfig } from "./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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withUniwind.d.mts","names":[],"sources":["../../src/webpack/withUniwind.ts"],"sourcesContent":[],"mappings":";;;iBASgB,WAAA,6CAEC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { uniq } from "./uniwind/src/utils/common.mjs";
|
|
2
|
-
import { UniwindWebpackPlugin } from "./UniwindWebpackPlugin.mjs";
|
|
3
|
-
import webpack from "webpack";
|
|
4
|
-
import path from "path";
|
|
5
|
-
|
|
6
|
-
//#region src/webpack/withUniwind.ts
|
|
7
|
-
const { NormalModuleReplacementPlugin } = webpack;
|
|
8
|
-
function withUniwind(nextConfig = {}, uniwindConfig) {
|
|
9
|
-
return {
|
|
10
|
-
...nextConfig,
|
|
11
|
-
transpilePackages: uniq([
|
|
12
|
-
...nextConfig.transpilePackages || [],
|
|
13
|
-
"uniwind",
|
|
14
|
-
"react-native",
|
|
15
|
-
"react-native-web"
|
|
16
|
-
]),
|
|
17
|
-
webpack(config, options) {
|
|
18
|
-
if (!config.plugins) config.plugins = [];
|
|
19
|
-
config.plugins.push(new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {
|
|
20
|
-
if ((resource.context || "").includes(`${path.sep}uniwind${path.sep}dist${path.sep}module${path.sep}components${path.sep}web`)) resource.request = "react-native-web";
|
|
21
|
-
else resource.request = "uniwind/components/index";
|
|
22
|
-
}));
|
|
23
|
-
config.plugins.push(new UniwindWebpackPlugin(uniwindConfig));
|
|
24
|
-
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
|
|
25
|
-
return config;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { withUniwind };
|
|
32
|
-
//# sourceMappingURL=withUniwind.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withUniwind.mjs","names":[],"sources":["../../src/webpack/withUniwind.ts"],"sourcesContent":["import webpack from \"webpack\";\nimport type { Configuration } from \"webpack\";\nimport path from \"path\";\nimport { UniwindConfig } from \"./types\";\nimport { UniwindWebpackPlugin } from \"./UniwindWebpackPlugin\";\nimport { uniq } from \"./uniwind/src/utils/common\";\n\nconst { NormalModuleReplacementPlugin } = webpack;\n\nexport function withUniwind(\n nextConfig: any = {},\n uniwindConfig: UniwindConfig,\n): any {\n return {\n ...nextConfig,\n transpilePackages: uniq([\n ...(nextConfig.transpilePackages || []),\n \"uniwind\",\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}uniwind${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 → uniwnd/web\n resource.request = \"uniwind/components/index\";\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":";;;;;;AAOA,MAAM,EAAE,kCAAkC;AAE1C,SAAgB,YACd,aAAkB,EAAE,EACpB,eACK;AACL,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,IAAI,SAAS,KAAK,IAAI,MAAM,KAAK,IAAI,QAAQ,KAAK,IAAI,YAAY,KAAK,IAAI,KACpF,CAGD,UAAS,UAAU;QAGnB,UAAS,UAAU;KAErB,CACH;AAED,UAAO,QAAQ,KAAK,IAAI,qBAAqB,cAAc,CAAC;AAG5D,OAAI,OAAO,WAAW,YAAY,WAChC,QAAO,WAAW,QAAQ,QAAQ,QAAQ;AAG5C,UAAO;;EAEV"}
|