uniwind-plugin-next 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -4
- 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/webpack/UniwindWebpackPlugin.cjs +6 -5
- package/dist/webpack/UniwindWebpackPlugin.mjs +5 -4
- package/dist/webpack/UniwindWebpackPlugin.mjs.map +1 -1
- package/dist/webpack/uniwind/src/css/index.cjs +6 -4
- package/dist/webpack/uniwind/src/css/index.mjs +6 -4
- package/dist/webpack/uniwind/src/css/index.mjs.map +1 -1
- package/dist/webpack/uniwind/src/css/insets.cjs +53 -32
- package/dist/webpack/uniwind/src/css/insets.mjs +53 -32
- package/dist/webpack/uniwind/src/css/insets.mjs.map +1 -1
- package/dist/webpack/util.cjs +6 -0
- package/dist/webpack/util.mjs +6 -0
- package/dist/webpack/util.mjs.map +1 -0
- package/dist/webpack/{withUniwind.cjs → withUniwindBase.cjs} +9 -9
- package/dist/webpack/{withUniwind.mjs → withUniwindBase.mjs} +9 -9
- package/dist/webpack/withUniwindBase.mjs.map +1 -0
- package/package.json +9 -9
- package/LICENSE +0 -21
- 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/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.map +0 -1
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ See the table below for tested versions of `uniwind-plugin-next` and correspondi
|
|
|
13
13
|
|
|
14
14
|
Tested on Next `16.1`, but other versions will likely work fine.
|
|
15
15
|
|
|
16
|
-
| uniwind-plugin-next |
|
|
17
|
-
|
|
18
|
-
| `1.1.
|
|
19
|
-
| `1.2.
|
|
16
|
+
| Uniwind | uniwind-plugin-next |
|
|
17
|
+
|-----------------|---------------------|
|
|
18
|
+
| `1.2.2`-`1.2.3` | `1.1.0`-`1.2.0` |
|
|
19
|
+
| `1.2.4` | `1.3.0` |
|
|
20
20
|
|
|
21
21
|
## Installation & setup
|
|
22
22
|
This setup guide assumes you already have a next.js project setup with Tailwind v4
|
|
@@ -45,6 +45,17 @@ export default withUniwind(withExpo(nextConfig), {
|
|
|
45
45
|
// See https://docs.uniwind.dev/api/metro-config#configuration-options
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
|
+
#### Uniwind Pro
|
|
49
|
+
|
|
50
|
+
If you're using the pro version of Uniwind, use `withUniwindPro()` instead of `withUniwind()`.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// next.config.ts
|
|
54
|
+
import { withUniwindPro } from 'uniwind-plugin-next'
|
|
55
|
+
|
|
56
|
+
export default withUniwindPro(withExpo(nextConfig), { ... });
|
|
57
|
+
```
|
|
58
|
+
|
|
48
59
|
|
|
49
60
|
3. Add the postcss plugin
|
|
50
61
|
```js
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_withUniwindBase = require('./webpack/withUniwindBase.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
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;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { UniwindConfig } from "./webpack/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAGgB,WAAA,6CAEC;iBAKD,cAAA,6CAEC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { UniwindConfig } from "./webpack/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAGgB,WAAA,6CAEC;iBAKD,cAAA,6CAEC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withUniwindBase } from "./webpack/withUniwindBase.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { UniwindConfig } from \"./webpack/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,17 +1,18 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_common = require('./uniwind/src/utils/common.cjs');
|
|
3
2
|
const require_index = require('./uniwind/src/css/index.cjs');
|
|
4
3
|
const require_buildDtsFile = require('./uniwind/src/utils/buildDtsFile.cjs');
|
|
5
4
|
const require_stringifyThemes = require('./uniwind/src/utils/stringifyThemes.cjs');
|
|
5
|
+
const require_util = require('./util.cjs');
|
|
6
6
|
let path = require("path");
|
|
7
7
|
path = require_rolldown_runtime.__toESM(path);
|
|
8
8
|
|
|
9
9
|
//#region src/webpack/UniwindWebpackPlugin.ts
|
|
10
10
|
const dirname = typeof __dirname !== "undefined" ? __dirname : __dirname;
|
|
11
11
|
var UniwindWebpackPlugin = class {
|
|
12
|
-
constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
12
|
+
constructor(packageName, { cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
13
|
+
this.packageName = packageName;
|
|
13
14
|
this.hasRun = false;
|
|
14
|
-
this.themes =
|
|
15
|
+
this.themes = require_util.uniq([
|
|
15
16
|
"light",
|
|
16
17
|
"dark",
|
|
17
18
|
...extraThemes ?? []
|
|
@@ -29,7 +30,7 @@ var UniwindWebpackPlugin = class {
|
|
|
29
30
|
compiler.options.module = compiler.options.module || { rules: [] };
|
|
30
31
|
compiler.options.module.rules.push({
|
|
31
32
|
test: /config\.c?js$/,
|
|
32
|
-
include:
|
|
33
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist`),
|
|
33
34
|
use: [{
|
|
34
35
|
loader: path.default.resolve(dirname, "configInjectionLoader.js"),
|
|
35
36
|
options: { stringifiedThemes: require_stringifyThemes.stringifyThemes(this.themes) }
|
|
@@ -38,7 +39,7 @@ var UniwindWebpackPlugin = class {
|
|
|
38
39
|
compiler.options.module.rules.push({
|
|
39
40
|
test: /\.js$/,
|
|
40
41
|
exclude: /index\.js$/,
|
|
41
|
-
include:
|
|
42
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist[\\/\\\\]module[\\/\\\\]components[\\/\\\\]web`),
|
|
42
43
|
use: [{ loader: path.default.resolve(dirname, "clientDirectiveLoader.js") }]
|
|
43
44
|
});
|
|
44
45
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { uniq } from "./uniwind/src/utils/common.mjs";
|
|
2
1
|
import { buildCSS } from "./uniwind/src/css/index.mjs";
|
|
3
2
|
import { buildDtsFile } from "./uniwind/src/utils/buildDtsFile.mjs";
|
|
4
3
|
import { stringifyThemes } from "./uniwind/src/utils/stringifyThemes.mjs";
|
|
4
|
+
import { uniq } from "./util.mjs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
|
|
7
7
|
//#region src/webpack/UniwindWebpackPlugin.ts
|
|
8
8
|
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
9
9
|
var UniwindWebpackPlugin = class {
|
|
10
|
-
constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
10
|
+
constructor(packageName, { cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
11
|
+
this.packageName = packageName;
|
|
11
12
|
this.hasRun = false;
|
|
12
13
|
this.themes = uniq([
|
|
13
14
|
"light",
|
|
@@ -27,7 +28,7 @@ var UniwindWebpackPlugin = class {
|
|
|
27
28
|
compiler.options.module = compiler.options.module || { rules: [] };
|
|
28
29
|
compiler.options.module.rules.push({
|
|
29
30
|
test: /config\.c?js$/,
|
|
30
|
-
include:
|
|
31
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist`),
|
|
31
32
|
use: [{
|
|
32
33
|
loader: path.resolve(dirname, "configInjectionLoader.js"),
|
|
33
34
|
options: { stringifiedThemes: stringifyThemes(this.themes) }
|
|
@@ -36,7 +37,7 @@ var UniwindWebpackPlugin = class {
|
|
|
36
37
|
compiler.options.module.rules.push({
|
|
37
38
|
test: /\.js$/,
|
|
38
39
|
exclude: /index\.js$/,
|
|
39
|
-
include:
|
|
40
|
+
include: /* @__PURE__ */ new RegExp(`${this.packageName}[\\/\\\\]dist[\\/\\\\]module[\\/\\\\]components[\\/\\\\]web`),
|
|
40
41
|
use: [{ loader: path.resolve(dirname, "clientDirectiveLoader.js") }]
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniwindWebpackPlugin.mjs","names":[],"sources":["../../src/webpack/UniwindWebpackPlugin.ts"],"sourcesContent":["import { UniwindConfig } from \"./types\";\nimport type { Compiler } from \"webpack\";\nimport path from \"path\";\nimport {
|
|
1
|
+
{"version":3,"file":"UniwindWebpackPlugin.mjs","names":["packageName: uniwindPackageName"],"sources":["../../src/webpack/UniwindWebpackPlugin.ts"],"sourcesContent":["import { UniwindConfig, uniwindPackageName } from \"./types\";\nimport type { Compiler } from \"webpack\";\nimport path from \"path\";\nimport { buildCSS } from \"./uniwind/src/css\";\nimport { buildDtsFile } from \"./uniwind/src/utils/buildDtsFile\";\nimport { stringifyThemes } from \"./uniwind/src/utils/stringifyThemes\";\nimport { uniq } from \"./util\";\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 );\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":";;;;;;;AAQA,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;IAE3D;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"}
|
|
@@ -13,13 +13,15 @@ const buildCSS = async (themes, input) => {
|
|
|
13
13
|
const variants = require_variants.generateCSSForVariants();
|
|
14
14
|
const insets = require_insets.generateCSSForInsets();
|
|
15
15
|
const themesCSS = await require_themes.generateCSSForThemes(themes, input);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const cssFilePath = path.default.join(dirname, "../../uniwind.css");
|
|
17
|
+
const oldCSSFile = fs.default.existsSync(cssFilePath) ? fs.default.readFileSync(cssFilePath, "utf-8") : "";
|
|
18
|
+
const newCssFile = [
|
|
19
19
|
variants,
|
|
20
20
|
insets,
|
|
21
21
|
themesCSS
|
|
22
|
-
].join("\n")
|
|
22
|
+
].join("\n");
|
|
23
|
+
if (oldCSSFile === newCssFile) return;
|
|
24
|
+
fs.default.writeFileSync(cssFilePath, newCssFile);
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
//#endregion
|
|
@@ -10,13 +10,15 @@ const buildCSS = async (themes, input) => {
|
|
|
10
10
|
const variants = generateCSSForVariants();
|
|
11
11
|
const insets = generateCSSForInsets();
|
|
12
12
|
const themesCSS = await generateCSSForThemes(themes, input);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const cssFilePath = path.join(dirname, "../../uniwind.css");
|
|
14
|
+
const oldCSSFile = fs.existsSync(cssFilePath) ? fs.readFileSync(cssFilePath, "utf-8") : "";
|
|
15
|
+
const newCssFile = [
|
|
16
16
|
variants,
|
|
17
17
|
insets,
|
|
18
18
|
themesCSS
|
|
19
|
-
].join("\n")
|
|
19
|
+
].join("\n");
|
|
20
|
+
if (oldCSSFile === newCssFile) return;
|
|
21
|
+
fs.writeFileSync(cssFilePath, newCssFile);
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/index.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateCSSForInsets } from \"./insets\";\nimport { generateCSSForThemes } from \"./themes\";\nimport { generateCSSForVariants } from \"./variants\";\n\nconst dirname =\n typeof __dirname !== \"undefined\" ? __dirname : import.meta.dirname;\n\nexport const buildCSS = async (themes: Array<string>, input: string) => {\n const variants = generateCSSForVariants();\n const insets = generateCSSForInsets();\n const themesCSS = await generateCSSForThemes(themes, input);\n const
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/index.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateCSSForInsets } from \"./insets\";\nimport { generateCSSForThemes } from \"./themes\";\nimport { generateCSSForVariants } from \"./variants\";\n\nconst dirname =\n typeof __dirname !== \"undefined\" ? __dirname : import.meta.dirname;\n\nexport const buildCSS = async (themes: Array<string>, input: string) => {\n const variants = generateCSSForVariants();\n const insets = generateCSSForInsets();\n const themesCSS = await generateCSSForThemes(themes, input);\n const cssFilePath = path.join(dirname, \"../../uniwind.css\");\n const oldCSSFile = fs.existsSync(cssFilePath)\n ? fs.readFileSync(cssFilePath, \"utf-8\")\n : \"\";\n\n const newCssFile = [variants, insets, themesCSS].join(\"\\n\");\n\n if (oldCSSFile === newCssFile) {\n return;\n }\n\n fs.writeFileSync(cssFilePath, newCssFile);\n};\n"],"mappings":";;;;;;;AAMA,MAAM,UACJ,OAAO,cAAc,cAAc,YAAY,OAAO,KAAK;AAE7D,MAAa,WAAW,OAAO,QAAuB,UAAkB;CACtE,MAAM,WAAW,wBAAwB;CACzC,MAAM,SAAS,sBAAsB;CACrC,MAAM,YAAY,MAAM,qBAAqB,QAAQ,MAAM;CAC3D,MAAM,cAAc,KAAK,KAAK,SAAS,oBAAoB;CAC3D,MAAM,aAAa,GAAG,WAAW,YAAY,GACzC,GAAG,aAAa,aAAa,QAAQ,GACrC;CAEJ,MAAM,aAAa;EAAC;EAAU;EAAQ;EAAU,CAAC,KAAK,KAAK;AAE3D,KAAI,eAAe,WACjB;AAGF,IAAG,cAAc,aAAa,WAAW"}
|
|
@@ -1,65 +1,86 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/webpack/uniwind/src/css/insets.ts
|
|
3
|
-
const types = [
|
|
3
|
+
const types = [
|
|
4
|
+
"margin",
|
|
5
|
+
"padding",
|
|
6
|
+
"inset"
|
|
7
|
+
];
|
|
4
8
|
const sides = [
|
|
5
|
-
"",
|
|
9
|
+
"inset",
|
|
6
10
|
"x",
|
|
7
11
|
"y",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
+
"top",
|
|
13
|
+
"bottom",
|
|
14
|
+
"left",
|
|
15
|
+
"right"
|
|
16
|
+
];
|
|
17
|
+
const safeAreaTypes = [
|
|
18
|
+
"safe",
|
|
19
|
+
"safe-or-*",
|
|
20
|
+
"safe-offset-*"
|
|
12
21
|
];
|
|
13
22
|
const spacing = "--spacing(--value(integer))";
|
|
14
23
|
const length = "--value([length])";
|
|
15
24
|
const generateCSSForInsets = () => {
|
|
16
25
|
let css = `@utility h-screen-safe {
|
|
17
26
|
height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
|
|
18
|
-
}\n`;
|
|
27
|
+
}\n\n`;
|
|
19
28
|
const getInsetsForSide = (side) => {
|
|
20
29
|
switch (side) {
|
|
21
|
-
case "
|
|
22
|
-
case "
|
|
23
|
-
case "
|
|
24
|
-
case "
|
|
30
|
+
case "top": return ["top"];
|
|
31
|
+
case "bottom": return ["bottom"];
|
|
32
|
+
case "left": return ["left"];
|
|
33
|
+
case "right": return ["right"];
|
|
25
34
|
case "x": return ["left", "right"];
|
|
26
35
|
case "y": return ["top", "bottom"];
|
|
27
|
-
|
|
36
|
+
case "inset": return [
|
|
28
37
|
"top",
|
|
29
38
|
"bottom",
|
|
30
39
|
"left",
|
|
31
40
|
"right"
|
|
32
41
|
];
|
|
42
|
+
default: return [];
|
|
33
43
|
}
|
|
34
44
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
const getUtilityName = (typeName, side, safeAreaType) => {
|
|
46
|
+
if (typeName === "inset") return `${side}-${safeAreaType}`;
|
|
47
|
+
const sideSuffix = side === "inset" ? "" : side.at(0);
|
|
48
|
+
return `${typeName.at(0)}${sideSuffix}-${safeAreaType}`;
|
|
49
|
+
};
|
|
50
|
+
const getStyleProperty = (typeName, inset) => {
|
|
51
|
+
if (typeName === "inset") return inset;
|
|
52
|
+
return `${typeName}-${inset}`;
|
|
53
|
+
};
|
|
54
|
+
const getStylesForSafeAreaType = (safeAreaType, styles) => {
|
|
55
|
+
switch (safeAreaType) {
|
|
56
|
+
case "safe": return styles;
|
|
57
|
+
case "safe-or-*": return styles.flatMap((style) => {
|
|
40
58
|
const styleWithoutSemicolon = style.replace(";", "");
|
|
41
59
|
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${length});`)];
|
|
42
60
|
});
|
|
43
|
-
|
|
61
|
+
case "safe-offset-*": return styles.flatMap((style) => {
|
|
44
62
|
const styleWithoutSemicolon = style.replace(";", "");
|
|
45
63
|
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${length});`)];
|
|
46
64
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
default: return [];
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
types.forEach((type) => {
|
|
69
|
+
sides.forEach((side) => {
|
|
70
|
+
const styles = getInsetsForSide(side).map((inset) => `${getStyleProperty(type, inset)}: env(safe-area-inset-${inset});`);
|
|
71
|
+
safeAreaTypes.forEach((safeAreaType) => {
|
|
72
|
+
const utilityName = getUtilityName(type, side, safeAreaType);
|
|
73
|
+
css += [
|
|
74
|
+
`@utility ${utilityName} {`,
|
|
75
|
+
...getStylesForSafeAreaType(safeAreaType, styles).map((style) => ` ${style}`),
|
|
76
|
+
"}",
|
|
77
|
+
"",
|
|
78
|
+
""
|
|
79
|
+
].join("\n");
|
|
80
|
+
});
|
|
60
81
|
});
|
|
61
82
|
});
|
|
62
|
-
return css.
|
|
83
|
+
return css.slice(0, -1);
|
|
63
84
|
};
|
|
64
85
|
|
|
65
86
|
//#endregion
|
|
@@ -1,64 +1,85 @@
|
|
|
1
1
|
//#region src/webpack/uniwind/src/css/insets.ts
|
|
2
|
-
const types = [
|
|
2
|
+
const types = [
|
|
3
|
+
"margin",
|
|
4
|
+
"padding",
|
|
5
|
+
"inset"
|
|
6
|
+
];
|
|
3
7
|
const sides = [
|
|
4
|
-
"",
|
|
8
|
+
"inset",
|
|
5
9
|
"x",
|
|
6
10
|
"y",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
+
"top",
|
|
12
|
+
"bottom",
|
|
13
|
+
"left",
|
|
14
|
+
"right"
|
|
15
|
+
];
|
|
16
|
+
const safeAreaTypes = [
|
|
17
|
+
"safe",
|
|
18
|
+
"safe-or-*",
|
|
19
|
+
"safe-offset-*"
|
|
11
20
|
];
|
|
12
21
|
const spacing = "--spacing(--value(integer))";
|
|
13
22
|
const length = "--value([length])";
|
|
14
23
|
const generateCSSForInsets = () => {
|
|
15
24
|
let css = `@utility h-screen-safe {
|
|
16
25
|
height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));
|
|
17
|
-
}\n`;
|
|
26
|
+
}\n\n`;
|
|
18
27
|
const getInsetsForSide = (side) => {
|
|
19
28
|
switch (side) {
|
|
20
|
-
case "
|
|
21
|
-
case "
|
|
22
|
-
case "
|
|
23
|
-
case "
|
|
29
|
+
case "top": return ["top"];
|
|
30
|
+
case "bottom": return ["bottom"];
|
|
31
|
+
case "left": return ["left"];
|
|
32
|
+
case "right": return ["right"];
|
|
24
33
|
case "x": return ["left", "right"];
|
|
25
34
|
case "y": return ["top", "bottom"];
|
|
26
|
-
|
|
35
|
+
case "inset": return [
|
|
27
36
|
"top",
|
|
28
37
|
"bottom",
|
|
29
38
|
"left",
|
|
30
39
|
"right"
|
|
31
40
|
];
|
|
41
|
+
default: return [];
|
|
32
42
|
}
|
|
33
43
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
const getUtilityName = (typeName, side, safeAreaType) => {
|
|
45
|
+
if (typeName === "inset") return `${side}-${safeAreaType}`;
|
|
46
|
+
const sideSuffix = side === "inset" ? "" : side.at(0);
|
|
47
|
+
return `${typeName.at(0)}${sideSuffix}-${safeAreaType}`;
|
|
48
|
+
};
|
|
49
|
+
const getStyleProperty = (typeName, inset) => {
|
|
50
|
+
if (typeName === "inset") return inset;
|
|
51
|
+
return `${typeName}-${inset}`;
|
|
52
|
+
};
|
|
53
|
+
const getStylesForSafeAreaType = (safeAreaType, styles) => {
|
|
54
|
+
switch (safeAreaType) {
|
|
55
|
+
case "safe": return styles;
|
|
56
|
+
case "safe-or-*": return styles.flatMap((style) => {
|
|
39
57
|
const styleWithoutSemicolon = style.replace(";", "");
|
|
40
58
|
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: max(${env}, ${length});`)];
|
|
41
59
|
});
|
|
42
|
-
|
|
60
|
+
case "safe-offset-*": return styles.flatMap((style) => {
|
|
43
61
|
const styleWithoutSemicolon = style.replace(";", "");
|
|
44
62
|
return [styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${spacing});`), styleWithoutSemicolon.replace(/: (env.*)/, (_, env) => `: calc(${env} + ${length});`)];
|
|
45
63
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
default: return [];
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
types.forEach((type) => {
|
|
68
|
+
sides.forEach((side) => {
|
|
69
|
+
const styles = getInsetsForSide(side).map((inset) => `${getStyleProperty(type, inset)}: env(safe-area-inset-${inset});`);
|
|
70
|
+
safeAreaTypes.forEach((safeAreaType) => {
|
|
71
|
+
const utilityName = getUtilityName(type, side, safeAreaType);
|
|
72
|
+
css += [
|
|
73
|
+
`@utility ${utilityName} {`,
|
|
74
|
+
...getStylesForSafeAreaType(safeAreaType, styles).map((style) => ` ${style}`),
|
|
75
|
+
"}",
|
|
76
|
+
"",
|
|
77
|
+
""
|
|
78
|
+
].join("\n");
|
|
79
|
+
});
|
|
59
80
|
});
|
|
60
81
|
});
|
|
61
|
-
return css.
|
|
82
|
+
return css.slice(0, -1);
|
|
62
83
|
};
|
|
63
84
|
|
|
64
85
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insets.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/insets.ts"],"sourcesContent":["const types = [\"
|
|
1
|
+
{"version":3,"file":"insets.mjs","names":[],"sources":["../../../../../src/webpack/uniwind/src/css/insets.ts"],"sourcesContent":["const types = [\"margin\", \"padding\", \"inset\"] as const;\nconst sides = [\"inset\", \"x\", \"y\", \"top\", \"bottom\", \"left\", \"right\"] as const;\nconst safeAreaTypes = [\"safe\", \"safe-or-*\", \"safe-offset-*\"] as const;\nconst spacing = \"--spacing(--value(integer))\";\nconst length = \"--value([length])\";\n\ntype Side = (typeof sides)[number];\ntype TypeName = (typeof types)[number];\ntype SafeAreaType = (typeof safeAreaTypes)[number];\ntype Inset = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport const generateCSSForInsets = () => {\n let css = `@utility h-screen-safe {\n height: calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)));\n}\\n\\n`;\n\n const getInsetsForSide = (side: Side): Array<Inset> => {\n switch (side) {\n case \"top\":\n return [\"top\"];\n case \"bottom\":\n return [\"bottom\"];\n case \"left\":\n return [\"left\"];\n case \"right\":\n return [\"right\"];\n case \"x\":\n return [\"left\", \"right\"];\n case \"y\":\n return [\"top\", \"bottom\"];\n case \"inset\":\n return [\"top\", \"bottom\", \"left\", \"right\"];\n default:\n side satisfies never;\n return [];\n }\n };\n\n const getUtilityName = (\n typeName: TypeName,\n side: Side,\n safeAreaType: SafeAreaType,\n ) => {\n if (typeName === \"inset\") {\n return `${side}-${safeAreaType}`;\n }\n\n const sideSuffix = side === \"inset\" ? \"\" : side.at(0);\n\n return `${typeName.at(0)}${sideSuffix}-${safeAreaType}`;\n };\n\n const getStyleProperty = (typeName: TypeName, inset: Inset) => {\n if (typeName === \"inset\") {\n return inset;\n }\n\n return `${typeName}-${inset}`;\n };\n\n const getStylesForSafeAreaType = (\n safeAreaType: SafeAreaType,\n styles: Array<string>,\n ) => {\n switch (safeAreaType) {\n case \"safe\":\n return styles;\n case \"safe-or-*\":\n return styles.flatMap((style) => {\n const styleWithoutSemicolon = style.replace(\";\", \"\");\n\n return [\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: max(${env}, ${spacing});`,\n ),\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: max(${env}, ${length});`,\n ),\n ];\n });\n case \"safe-offset-*\":\n return styles.flatMap((style) => {\n const styleWithoutSemicolon = style.replace(\";\", \"\");\n\n return [\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: calc(${env} + ${spacing});`,\n ),\n styleWithoutSemicolon.replace(\n /: (env.*)/,\n (_, env) => `: calc(${env} + ${length});`,\n ),\n ];\n });\n default:\n safeAreaType satisfies never;\n return [];\n }\n };\n\n types.forEach((type) => {\n sides.forEach((side) => {\n const insets = getInsetsForSide(side);\n const styles = insets.map(\n (inset) =>\n `${getStyleProperty(type, inset)}: env(safe-area-inset-${inset});`,\n );\n\n safeAreaTypes.forEach((safeAreaType) => {\n const utilityName = getUtilityName(type, side, safeAreaType);\n\n css += [\n `@utility ${utilityName} {`,\n ...getStylesForSafeAreaType(safeAreaType, styles).map(\n (style) => ` ${style}`,\n ),\n \"}\",\n \"\",\n \"\",\n ].join(\"\\n\");\n });\n });\n });\n\n // Remove the last newline character\n return css.slice(0, -1);\n};\n"],"mappings":";AAAA,MAAM,QAAQ;CAAC;CAAU;CAAW;CAAQ;AAC5C,MAAM,QAAQ;CAAC;CAAS;CAAK;CAAK;CAAO;CAAU;CAAQ;CAAQ;AACnE,MAAM,gBAAgB;CAAC;CAAQ;CAAa;CAAgB;AAC5D,MAAM,UAAU;AAChB,MAAM,SAAS;AAOf,MAAa,6BAA6B;CACxC,IAAI,MAAM;;;CAIV,MAAM,oBAAoB,SAA6B;AACrD,UAAQ,MAAR;GACE,KAAK,MACH,QAAO,CAAC,MAAM;GAChB,KAAK,SACH,QAAO,CAAC,SAAS;GACnB,KAAK,OACH,QAAO,CAAC,OAAO;GACjB,KAAK,QACH,QAAO,CAAC,QAAQ;GAClB,KAAK,IACH,QAAO,CAAC,QAAQ,QAAQ;GAC1B,KAAK,IACH,QAAO,CAAC,OAAO,SAAS;GAC1B,KAAK,QACH,QAAO;IAAC;IAAO;IAAU;IAAQ;IAAQ;GAC3C,QAEE,QAAO,EAAE;;;CAIf,MAAM,kBACJ,UACA,MACA,iBACG;AACH,MAAI,aAAa,QACf,QAAO,GAAG,KAAK,GAAG;EAGpB,MAAM,aAAa,SAAS,UAAU,KAAK,KAAK,GAAG,EAAE;AAErD,SAAO,GAAG,SAAS,GAAG,EAAE,GAAG,WAAW,GAAG;;CAG3C,MAAM,oBAAoB,UAAoB,UAAiB;AAC7D,MAAI,aAAa,QACf,QAAO;AAGT,SAAO,GAAG,SAAS,GAAG;;CAGxB,MAAM,4BACJ,cACA,WACG;AACH,UAAQ,cAAR;GACE,KAAK,OACH,QAAO;GACT,KAAK,YACH,QAAO,OAAO,SAAS,UAAU;IAC/B,MAAM,wBAAwB,MAAM,QAAQ,KAAK,GAAG;AAEpD,WAAO,CACL,sBAAsB,QACpB,cACC,GAAG,QAAQ,SAAS,IAAI,IAAI,QAAQ,IACtC,EACD,sBAAsB,QACpB,cACC,GAAG,QAAQ,SAAS,IAAI,IAAI,OAAO,IACrC,CACF;KACD;GACJ,KAAK,gBACH,QAAO,OAAO,SAAS,UAAU;IAC/B,MAAM,wBAAwB,MAAM,QAAQ,KAAK,GAAG;AAEpD,WAAO,CACL,sBAAsB,QACpB,cACC,GAAG,QAAQ,UAAU,IAAI,KAAK,QAAQ,IACxC,EACD,sBAAsB,QACpB,cACC,GAAG,QAAQ,UAAU,IAAI,KAAK,OAAO,IACvC,CACF;KACD;GACJ,QAEE,QAAO,EAAE;;;AAIf,OAAM,SAAS,SAAS;AACtB,QAAM,SAAS,SAAS;GAEtB,MAAM,SADS,iBAAiB,KAAK,CACf,KACnB,UACC,GAAG,iBAAiB,MAAM,MAAM,CAAC,wBAAwB,MAAM,IAClE;AAED,iBAAc,SAAS,iBAAiB;IACtC,MAAM,cAAc,eAAe,MAAM,MAAM,aAAa;AAE5D,WAAO;KACL,YAAY,YAAY;KACxB,GAAG,yBAAyB,cAAc,OAAO,CAAC,KAC/C,UAAU,OAAO,QACnB;KACD;KACA;KACA;KACD,CAAC,KAAK,KAAK;KACZ;IACF;GACF;AAGF,QAAO,IAAI,MAAM,GAAG,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.mjs","names":[],"sources":["../../src/webpack/util.ts"],"sourcesContent":["export const uniq = <T>(arr: Array<T>) => Array.from(new Set(arr));\n"],"mappings":";AAAA,MAAa,QAAW,QAAkB,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_util = require('./util.cjs');
|
|
3
3
|
const require_UniwindWebpackPlugin = require('./UniwindWebpackPlugin.cjs');
|
|
4
4
|
let webpack = require("webpack");
|
|
5
5
|
webpack = require_rolldown_runtime.__toESM(webpack);
|
|
6
6
|
let path = require("path");
|
|
7
7
|
path = require_rolldown_runtime.__toESM(path);
|
|
8
8
|
|
|
9
|
-
//#region src/webpack/
|
|
9
|
+
//#region src/webpack/withUniwindBase.ts
|
|
10
10
|
const { NormalModuleReplacementPlugin } = webpack.default;
|
|
11
|
-
function
|
|
11
|
+
function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
|
|
12
12
|
return {
|
|
13
13
|
...nextConfig,
|
|
14
|
-
transpilePackages:
|
|
14
|
+
transpilePackages: require_util.uniq([
|
|
15
15
|
...nextConfig.transpilePackages || [],
|
|
16
|
-
|
|
16
|
+
packageName,
|
|
17
17
|
"react-native",
|
|
18
18
|
"react-native-web"
|
|
19
19
|
]),
|
|
20
20
|
webpack(config, options) {
|
|
21
21
|
if (!config.plugins) config.plugins = [];
|
|
22
22
|
config.plugins.push(new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {
|
|
23
|
-
if ((resource.context || "").includes(`${path.default.sep}
|
|
24
|
-
else resource.request =
|
|
23
|
+
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";
|
|
24
|
+
else resource.request = `${packageName}/components/index`;
|
|
25
25
|
}));
|
|
26
|
-
config.plugins.push(new require_UniwindWebpackPlugin.UniwindWebpackPlugin(uniwindConfig));
|
|
26
|
+
config.plugins.push(new require_UniwindWebpackPlugin.UniwindWebpackPlugin(packageName, uniwindConfig));
|
|
27
27
|
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
|
|
28
28
|
return config;
|
|
29
29
|
}
|
|
@@ -31,4 +31,4 @@ function withUniwind(nextConfig = {}, uniwindConfig) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
exports.
|
|
34
|
+
exports.withUniwindBase = withUniwindBase;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { uniq } from "./
|
|
1
|
+
import { uniq } from "./util.mjs";
|
|
2
2
|
import { UniwindWebpackPlugin } from "./UniwindWebpackPlugin.mjs";
|
|
3
3
|
import webpack from "webpack";
|
|
4
4
|
import path from "path";
|
|
5
5
|
|
|
6
|
-
//#region src/webpack/
|
|
6
|
+
//#region src/webpack/withUniwindBase.ts
|
|
7
7
|
const { NormalModuleReplacementPlugin } = webpack;
|
|
8
|
-
function
|
|
8
|
+
function withUniwindBase(packageName, nextConfig = {}, uniwindConfig) {
|
|
9
9
|
return {
|
|
10
10
|
...nextConfig,
|
|
11
11
|
transpilePackages: uniq([
|
|
12
12
|
...nextConfig.transpilePackages || [],
|
|
13
|
-
|
|
13
|
+
packageName,
|
|
14
14
|
"react-native",
|
|
15
15
|
"react-native-web"
|
|
16
16
|
]),
|
|
17
17
|
webpack(config, options) {
|
|
18
18
|
if (!config.plugins) config.plugins = [];
|
|
19
19
|
config.plugins.push(new NormalModuleReplacementPlugin(/^react-native$/, (resource) => {
|
|
20
|
-
if ((resource.context || "").includes(`${path.sep}
|
|
21
|
-
else resource.request =
|
|
20
|
+
if ((resource.context || "").includes(`${path.sep}${packageName}${path.sep}dist${path.sep}module${path.sep}components${path.sep}web`)) resource.request = "react-native-web";
|
|
21
|
+
else resource.request = `${packageName}/components/index`;
|
|
22
22
|
}));
|
|
23
|
-
config.plugins.push(new UniwindWebpackPlugin(uniwindConfig));
|
|
23
|
+
config.plugins.push(new UniwindWebpackPlugin(packageName, uniwindConfig));
|
|
24
24
|
if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, options);
|
|
25
25
|
return config;
|
|
26
26
|
}
|
|
@@ -28,5 +28,5 @@ function withUniwind(nextConfig = {}, uniwindConfig) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
export {
|
|
32
|
-
//# sourceMappingURL=
|
|
31
|
+
export { withUniwindBase };
|
|
32
|
+
//# 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 type { UniwindConfig, uniwindPackageName } from \"./types\";\nimport { UniwindWebpackPlugin } from \"./UniwindWebpackPlugin\";\nimport { uniq } from \"./util\";\n\nconst { NormalModuleReplacementPlugin } = webpack;\n\nexport function withUniwindBase(\n packageName: uniwindPackageName,\n nextConfig: any = {},\n uniwindConfig: UniwindConfig,\n): any {\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 → uniwnd/web\n resource.request = `${packageName}/components/index`;\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,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;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.3.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",
|
|
@@ -42,11 +48,5 @@
|
|
|
42
48
|
"files": [
|
|
43
49
|
"dist",
|
|
44
50
|
"README.md"
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
"build": "tsdown",
|
|
48
|
-
"dev": "tsdown --watch",
|
|
49
|
-
"typecheck": "tsc --noEmit",
|
|
50
|
-
"test": "vitest run"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
51
|
+
]
|
|
52
|
+
}
|
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":"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,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 +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"}
|