weapp-tailwindcss 5.2.14 → 5.3.1
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 +55 -8
- package/README.zh-CN.md +64 -0
- package/dist/bundlers/rspack/rule-match.d.ts +13 -0
- package/dist/bundlers/shared/generator-css/types.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +7 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-plugin-order.d.ts +2 -0
- package/dist/{transform-52FLRu-0.js → component-local-style-C2wC8o9F.js} +23 -174
- package/dist/{transform-BiHG42Rp.cjs → component-local-style-CNhEhd2B.cjs} +34 -168
- package/dist/{context-vWlNv-Cf.cjs → context-CB4Ef9U0.cjs} +4 -4
- package/dist/{context-CKQKq4Mv.js → context-Kvr3lLEC.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/generator/index.d.ts +2 -2
- package/dist/{generator-BXrWA7Sj.cjs → generator-DKiYbTFR.cjs} +11 -1
- package/dist/{generator-BP4WmgIo.js → generator-EnTXLBlK.js} +1 -1
- package/dist/generator.cjs +8 -1
- package/dist/generator.js +2 -2
- package/dist/{gulp-DzIR7eO3.cjs → gulp-QJ_oz-06.cjs} +7 -7
- package/dist/{gulp-DG6cWPF4.js → gulp-vz36-uQP.js} +4 -4
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-CoyM6Dg2.js → hmr-timing-HGlM4hX3.js} +9 -11
- package/dist/{hmr-timing-BIPr9t9m.cjs → hmr-timing-W3kro20F.cjs} +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-DbYws6lr.cjs → options-CKZW99r4.cjs} +1 -1
- package/dist/{pipeline-helpers-Bp343-ik.cjs → pipeline-helpers-t95KPu4O.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +124 -7
- package/dist/rspack.js +124 -7
- package/dist/{source-candidate-scan-signature-BLXoEZN5.js → source-candidate-scan-signature-BHCPQVoD.js} +3 -3
- package/dist/{source-candidate-scan-signature-J9EW91KX.cjs → source-candidate-scan-signature-BSad7bMQ.cjs} +3 -3
- package/dist/{style-options-Cta1OP3i.cjs → style-options-PCgz2ywM.cjs} +2 -2
- package/dist/tailwindcss/candidates.d.ts +2 -2
- package/dist/{tailwindcss-C2K-vjJv.js → tailwindcss-BSEdWieh.js} +1 -1
- package/dist/{tailwindcss-D1M2xj5O.cjs → tailwindcss-jKzY37Sk.cjs} +2 -2
- package/dist/transform-CgohToUV.cjs +200 -0
- package/dist/transform-DSRPiBWz.js +201 -0
- package/dist/uni-app-x/component-local-style.d.ts +3 -1
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +1 -0
- package/dist/uni-app-x/vite/web-local-style.d.ts +6 -0
- package/dist/{v4-generation-core-CCnEsAgV.cjs → v4-generation-core-BfeXEc6R.cjs} +9 -11
- package/dist/{vite-DNTQV3gN.js → vite-Crz1mQR4.js} +186 -66
- package/dist/{vite-RJpkDte7.cjs → vite-CtmGLZXy.cjs} +189 -69
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +28 -10
- package/dist/{webpack-BY5y7f0X.cjs → webpack-Cf5RnhXt.cjs} +9 -9
- package/dist/{webpack-DYoIysDo.js → webpack-DwtdWqwr.js} +6 -6
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +9 -14
- package/README.en.md +0 -17
- package/bin/weapp-tailwindcss.cjs +0 -8
- package/dist/cli/context.d.ts +0 -3
- package/dist/cli/doctor/constants.d.ts +0 -7
- package/dist/cli/doctor/types.d.ts +0 -31
- package/dist/cli/doctor.d.ts +0 -4
- package/dist/cli/helpers/options/format.d.ts +0 -2
- package/dist/cli/helpers/options/parse.d.ts +0 -3
- package/dist/cli/helpers/options/resolve.d.ts +0 -1
- package/dist/cli/helpers/options.d.ts +0 -3
- package/dist/cli/helpers.d.ts +0 -4
- package/dist/cli/mount-options.d.ts +0 -4
- package/dist/cli/types.d.ts +0 -15
- package/dist/cli/vscode-entry.d.ts +0 -14
- package/dist/cli.cjs +0 -37065
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -2298
package/dist/rspack.cjs
CHANGED
|
@@ -1,8 +1,113 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_v4_generation_core = require("./v4-generation-core-BfeXEc6R.cjs");
|
|
4
|
+
const require_webpack = require("./webpack-Cf5RnhXt.cjs");
|
|
4
5
|
let node_path = require("node:path");
|
|
5
6
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
7
|
+
//#region src/bundlers/rspack/rule-match.ts
|
|
8
|
+
const STYLE_RULE_PROBES = [
|
|
9
|
+
"weapp-tailwindcss.css",
|
|
10
|
+
"weapp-tailwindcss.module.css",
|
|
11
|
+
"weapp-tailwindcss.wxss",
|
|
12
|
+
"weapp-tailwindcss.acss",
|
|
13
|
+
"weapp-tailwindcss.ttss",
|
|
14
|
+
"weapp-tailwindcss.qss",
|
|
15
|
+
"weapp-tailwindcss.jxss",
|
|
16
|
+
"weapp-tailwindcss.scss",
|
|
17
|
+
"weapp-tailwindcss.module.scss",
|
|
18
|
+
"weapp-tailwindcss.less",
|
|
19
|
+
"weapp-tailwindcss.styl",
|
|
20
|
+
"weapp-tailwindcss.pcss"
|
|
21
|
+
];
|
|
22
|
+
const SCRIPT_RULE_PROBES = [
|
|
23
|
+
"weapp-tailwindcss.js",
|
|
24
|
+
"weapp-tailwindcss.jsx",
|
|
25
|
+
"weapp-tailwindcss.mjs",
|
|
26
|
+
"weapp-tailwindcss.cjs",
|
|
27
|
+
"weapp-tailwindcss.ts",
|
|
28
|
+
"weapp-tailwindcss.tsx"
|
|
29
|
+
];
|
|
30
|
+
const STYLE_RESOURCE_QUERY_PROBES = [
|
|
31
|
+
"type=style",
|
|
32
|
+
"type=styles",
|
|
33
|
+
"vue&type=style&index=0&lang.css"
|
|
34
|
+
];
|
|
35
|
+
function isRegExpLike(value) {
|
|
36
|
+
return value instanceof RegExp;
|
|
37
|
+
}
|
|
38
|
+
function testRegexpMatcher(matcher, input) {
|
|
39
|
+
const lastIndex = matcher.lastIndex;
|
|
40
|
+
matcher.lastIndex = 0;
|
|
41
|
+
const result = matcher.test(input);
|
|
42
|
+
matcher.lastIndex = lastIndex;
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function matchesStringCondition(condition, input) {
|
|
46
|
+
if (typeof condition === "string") return input.includes(condition);
|
|
47
|
+
if (isRegExpLike(condition)) return testRegexpMatcher(condition, input);
|
|
48
|
+
}
|
|
49
|
+
function matchesCondition(condition, input) {
|
|
50
|
+
if (Array.isArray(condition)) {
|
|
51
|
+
let hasStaticMatcher = false;
|
|
52
|
+
for (const item of condition) {
|
|
53
|
+
const matched = matchesCondition(item, input);
|
|
54
|
+
if (matched === true) return true;
|
|
55
|
+
hasStaticMatcher || (hasStaticMatcher = matched === false);
|
|
56
|
+
}
|
|
57
|
+
return hasStaticMatcher ? false : void 0;
|
|
58
|
+
}
|
|
59
|
+
if (typeof condition === "object" && condition !== null && !isRegExpLike(condition)) {
|
|
60
|
+
const group = condition;
|
|
61
|
+
if (Array.isArray(group.and)) {
|
|
62
|
+
let hasUnknown = false;
|
|
63
|
+
for (const item of group.and) {
|
|
64
|
+
const matched = matchesCondition(item, input);
|
|
65
|
+
if (matched === false) return false;
|
|
66
|
+
hasUnknown || (hasUnknown = matched === void 0);
|
|
67
|
+
}
|
|
68
|
+
return hasUnknown ? void 0 : true;
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(group.or)) return matchesCondition(group.or, input);
|
|
71
|
+
if (group.not !== void 0) {
|
|
72
|
+
const matched = matchesCondition(group.not, input);
|
|
73
|
+
return matched === void 0 ? void 0 : !matched;
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
return matchesStringCondition(condition, input);
|
|
78
|
+
}
|
|
79
|
+
function matchesAnyStringCondition(condition, inputs) {
|
|
80
|
+
let hasStaticMatcher = false;
|
|
81
|
+
for (const input of inputs) {
|
|
82
|
+
const matched = matchesCondition(condition, input);
|
|
83
|
+
if (matched === true) return true;
|
|
84
|
+
hasStaticMatcher || (hasStaticMatcher = matched === false);
|
|
85
|
+
}
|
|
86
|
+
return hasStaticMatcher ? false : void 0;
|
|
87
|
+
}
|
|
88
|
+
function matchesStyleResourceCondition(condition) {
|
|
89
|
+
if (typeof condition === "function") return;
|
|
90
|
+
if (typeof condition === "string" && require_v4_generation_core.isSourceStyleRequest(condition)) return true;
|
|
91
|
+
const matched = matchesAnyStringCondition(condition, STYLE_RULE_PROBES);
|
|
92
|
+
return typeof condition === "string" && matched === false ? void 0 : matched;
|
|
93
|
+
}
|
|
94
|
+
function matchesResourceQueryCondition(condition) {
|
|
95
|
+
if (typeof condition === "function") return;
|
|
96
|
+
return matchesAnyStringCondition(condition, STYLE_RESOURCE_QUERY_PROBES);
|
|
97
|
+
}
|
|
98
|
+
function resolveRuleCssMatch(rule) {
|
|
99
|
+
if (matchesAnyStringCondition(rule.include, STYLE_RULE_PROBES) === true) return true;
|
|
100
|
+
if (matchesAnyStringCondition(rule.exclude, STYLE_RULE_PROBES) === true) return false;
|
|
101
|
+
if (matchesStyleResourceCondition(rule.resource) === true) return true;
|
|
102
|
+
if (matchesAnyStringCondition(rule.test, STYLE_RULE_PROBES) === true) return true;
|
|
103
|
+
if (matchesAnyStringCondition(rule.test, SCRIPT_RULE_PROBES) === true) return false;
|
|
104
|
+
if (matchesResourceQueryCondition(rule.resourceQuery) === true) return true;
|
|
105
|
+
if (typeof rule.type === "string") {
|
|
106
|
+
if (rule.type.includes("css") || rule.type.includes("style")) return true;
|
|
107
|
+
if (rule.type.includes("javascript")) return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
6
111
|
//#region src/bundlers/rspack/index.ts
|
|
7
112
|
const CSS_IMPORT_REWRITE_LOADER_NAME = "weapp-tw-css-import-rewrite-loader";
|
|
8
113
|
const LIGHTNING_CSS_LOADER_NAME = "builtin:lightningcss-loader";
|
|
@@ -11,10 +116,20 @@ const POSTCSS_LOADER_NAME = "postcss-loader";
|
|
|
11
116
|
function isRuleLike(value) {
|
|
12
117
|
return typeof value === "object" && value !== null;
|
|
13
118
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
119
|
+
function isRspackUseItem(value) {
|
|
120
|
+
return typeof value === "string" || typeof value === "object" && value !== null;
|
|
121
|
+
}
|
|
122
|
+
function normalizeRuleUse(use) {
|
|
123
|
+
if (Array.isArray(use)) return {
|
|
124
|
+
entries: use,
|
|
125
|
+
commit: (entries) => entries
|
|
126
|
+
};
|
|
16
127
|
if (use === void 0) return;
|
|
17
|
-
|
|
128
|
+
if (!isRspackUseItem(use)) return;
|
|
129
|
+
return {
|
|
130
|
+
entries: [use],
|
|
131
|
+
commit: (entries) => entries.length === 1 ? entries[0] : entries
|
|
132
|
+
};
|
|
18
133
|
}
|
|
19
134
|
function getLoaderName(item) {
|
|
20
135
|
if (typeof item === "string") return item;
|
|
@@ -35,8 +150,10 @@ function resolveCssImportRewriteOptions(options) {
|
|
|
35
150
|
return cssImportRewriteLoader === true ? {} : cssImportRewriteLoader;
|
|
36
151
|
}
|
|
37
152
|
function patchRuleUse(rule, options) {
|
|
38
|
-
|
|
39
|
-
|
|
153
|
+
if (resolveRuleCssMatch(rule) === false) return;
|
|
154
|
+
const normalizedUse = normalizeRuleUse(rule.use);
|
|
155
|
+
if (!normalizedUse) return;
|
|
156
|
+
let use = normalizedUse.entries;
|
|
40
157
|
if (options.removeLightningCssLoader) use = use.filter((item) => !includesLoaderName(item, LIGHTNING_CSS_LOADER_NAME));
|
|
41
158
|
const cssImportRewriteOptions = resolveCssImportRewriteOptions(options);
|
|
42
159
|
if (cssImportRewriteOptions) {
|
|
@@ -49,7 +166,7 @@ function patchRuleUse(rule, options) {
|
|
|
49
166
|
use.splice(fallbackAnchorIndex + 1, 0, loaderEntry);
|
|
50
167
|
}
|
|
51
168
|
}
|
|
52
|
-
rule.use = use;
|
|
169
|
+
rule.use = normalizedUse.commit(use);
|
|
53
170
|
}
|
|
54
171
|
function walkRspackRule(rule, options) {
|
|
55
172
|
if (!isRuleLike(rule)) return;
|
package/dist/rspack.js
CHANGED
|
@@ -1,5 +1,110 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as isSourceStyleRequest } from "./hmr-timing-HGlM4hX3.js";
|
|
2
|
+
import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-DwtdWqwr.js";
|
|
2
3
|
import path from "node:path";
|
|
4
|
+
//#region src/bundlers/rspack/rule-match.ts
|
|
5
|
+
const STYLE_RULE_PROBES = [
|
|
6
|
+
"weapp-tailwindcss.css",
|
|
7
|
+
"weapp-tailwindcss.module.css",
|
|
8
|
+
"weapp-tailwindcss.wxss",
|
|
9
|
+
"weapp-tailwindcss.acss",
|
|
10
|
+
"weapp-tailwindcss.ttss",
|
|
11
|
+
"weapp-tailwindcss.qss",
|
|
12
|
+
"weapp-tailwindcss.jxss",
|
|
13
|
+
"weapp-tailwindcss.scss",
|
|
14
|
+
"weapp-tailwindcss.module.scss",
|
|
15
|
+
"weapp-tailwindcss.less",
|
|
16
|
+
"weapp-tailwindcss.styl",
|
|
17
|
+
"weapp-tailwindcss.pcss"
|
|
18
|
+
];
|
|
19
|
+
const SCRIPT_RULE_PROBES = [
|
|
20
|
+
"weapp-tailwindcss.js",
|
|
21
|
+
"weapp-tailwindcss.jsx",
|
|
22
|
+
"weapp-tailwindcss.mjs",
|
|
23
|
+
"weapp-tailwindcss.cjs",
|
|
24
|
+
"weapp-tailwindcss.ts",
|
|
25
|
+
"weapp-tailwindcss.tsx"
|
|
26
|
+
];
|
|
27
|
+
const STYLE_RESOURCE_QUERY_PROBES = [
|
|
28
|
+
"type=style",
|
|
29
|
+
"type=styles",
|
|
30
|
+
"vue&type=style&index=0&lang.css"
|
|
31
|
+
];
|
|
32
|
+
function isRegExpLike(value) {
|
|
33
|
+
return value instanceof RegExp;
|
|
34
|
+
}
|
|
35
|
+
function testRegexpMatcher(matcher, input) {
|
|
36
|
+
const lastIndex = matcher.lastIndex;
|
|
37
|
+
matcher.lastIndex = 0;
|
|
38
|
+
const result = matcher.test(input);
|
|
39
|
+
matcher.lastIndex = lastIndex;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function matchesStringCondition(condition, input) {
|
|
43
|
+
if (typeof condition === "string") return input.includes(condition);
|
|
44
|
+
if (isRegExpLike(condition)) return testRegexpMatcher(condition, input);
|
|
45
|
+
}
|
|
46
|
+
function matchesCondition(condition, input) {
|
|
47
|
+
if (Array.isArray(condition)) {
|
|
48
|
+
let hasStaticMatcher = false;
|
|
49
|
+
for (const item of condition) {
|
|
50
|
+
const matched = matchesCondition(item, input);
|
|
51
|
+
if (matched === true) return true;
|
|
52
|
+
hasStaticMatcher || (hasStaticMatcher = matched === false);
|
|
53
|
+
}
|
|
54
|
+
return hasStaticMatcher ? false : void 0;
|
|
55
|
+
}
|
|
56
|
+
if (typeof condition === "object" && condition !== null && !isRegExpLike(condition)) {
|
|
57
|
+
const group = condition;
|
|
58
|
+
if (Array.isArray(group.and)) {
|
|
59
|
+
let hasUnknown = false;
|
|
60
|
+
for (const item of group.and) {
|
|
61
|
+
const matched = matchesCondition(item, input);
|
|
62
|
+
if (matched === false) return false;
|
|
63
|
+
hasUnknown || (hasUnknown = matched === void 0);
|
|
64
|
+
}
|
|
65
|
+
return hasUnknown ? void 0 : true;
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(group.or)) return matchesCondition(group.or, input);
|
|
68
|
+
if (group.not !== void 0) {
|
|
69
|
+
const matched = matchesCondition(group.not, input);
|
|
70
|
+
return matched === void 0 ? void 0 : !matched;
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
return matchesStringCondition(condition, input);
|
|
75
|
+
}
|
|
76
|
+
function matchesAnyStringCondition(condition, inputs) {
|
|
77
|
+
let hasStaticMatcher = false;
|
|
78
|
+
for (const input of inputs) {
|
|
79
|
+
const matched = matchesCondition(condition, input);
|
|
80
|
+
if (matched === true) return true;
|
|
81
|
+
hasStaticMatcher || (hasStaticMatcher = matched === false);
|
|
82
|
+
}
|
|
83
|
+
return hasStaticMatcher ? false : void 0;
|
|
84
|
+
}
|
|
85
|
+
function matchesStyleResourceCondition(condition) {
|
|
86
|
+
if (typeof condition === "function") return;
|
|
87
|
+
if (typeof condition === "string" && isSourceStyleRequest(condition)) return true;
|
|
88
|
+
const matched = matchesAnyStringCondition(condition, STYLE_RULE_PROBES);
|
|
89
|
+
return typeof condition === "string" && matched === false ? void 0 : matched;
|
|
90
|
+
}
|
|
91
|
+
function matchesResourceQueryCondition(condition) {
|
|
92
|
+
if (typeof condition === "function") return;
|
|
93
|
+
return matchesAnyStringCondition(condition, STYLE_RESOURCE_QUERY_PROBES);
|
|
94
|
+
}
|
|
95
|
+
function resolveRuleCssMatch(rule) {
|
|
96
|
+
if (matchesAnyStringCondition(rule.include, STYLE_RULE_PROBES) === true) return true;
|
|
97
|
+
if (matchesAnyStringCondition(rule.exclude, STYLE_RULE_PROBES) === true) return false;
|
|
98
|
+
if (matchesStyleResourceCondition(rule.resource) === true) return true;
|
|
99
|
+
if (matchesAnyStringCondition(rule.test, STYLE_RULE_PROBES) === true) return true;
|
|
100
|
+
if (matchesAnyStringCondition(rule.test, SCRIPT_RULE_PROBES) === true) return false;
|
|
101
|
+
if (matchesResourceQueryCondition(rule.resourceQuery) === true) return true;
|
|
102
|
+
if (typeof rule.type === "string") {
|
|
103
|
+
if (rule.type.includes("css") || rule.type.includes("style")) return true;
|
|
104
|
+
if (rule.type.includes("javascript")) return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
3
108
|
//#region src/bundlers/rspack/index.ts
|
|
4
109
|
const CSS_IMPORT_REWRITE_LOADER_NAME = "weapp-tw-css-import-rewrite-loader";
|
|
5
110
|
const LIGHTNING_CSS_LOADER_NAME = "builtin:lightningcss-loader";
|
|
@@ -8,10 +113,20 @@ const POSTCSS_LOADER_NAME = "postcss-loader";
|
|
|
8
113
|
function isRuleLike(value) {
|
|
9
114
|
return typeof value === "object" && value !== null;
|
|
10
115
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
116
|
+
function isRspackUseItem(value) {
|
|
117
|
+
return typeof value === "string" || typeof value === "object" && value !== null;
|
|
118
|
+
}
|
|
119
|
+
function normalizeRuleUse(use) {
|
|
120
|
+
if (Array.isArray(use)) return {
|
|
121
|
+
entries: use,
|
|
122
|
+
commit: (entries) => entries
|
|
123
|
+
};
|
|
13
124
|
if (use === void 0) return;
|
|
14
|
-
|
|
125
|
+
if (!isRspackUseItem(use)) return;
|
|
126
|
+
return {
|
|
127
|
+
entries: [use],
|
|
128
|
+
commit: (entries) => entries.length === 1 ? entries[0] : entries
|
|
129
|
+
};
|
|
15
130
|
}
|
|
16
131
|
function getLoaderName(item) {
|
|
17
132
|
if (typeof item === "string") return item;
|
|
@@ -32,8 +147,10 @@ function resolveCssImportRewriteOptions(options) {
|
|
|
32
147
|
return cssImportRewriteLoader === true ? {} : cssImportRewriteLoader;
|
|
33
148
|
}
|
|
34
149
|
function patchRuleUse(rule, options) {
|
|
35
|
-
|
|
36
|
-
|
|
150
|
+
if (resolveRuleCssMatch(rule) === false) return;
|
|
151
|
+
const normalizedUse = normalizeRuleUse(rule.use);
|
|
152
|
+
if (!normalizedUse) return;
|
|
153
|
+
let use = normalizedUse.entries;
|
|
37
154
|
if (options.removeLightningCssLoader) use = use.filter((item) => !includesLoaderName(item, LIGHTNING_CSS_LOADER_NAME));
|
|
38
155
|
const cssImportRewriteOptions = resolveCssImportRewriteOptions(options);
|
|
39
156
|
if (cssImportRewriteOptions) {
|
|
@@ -46,7 +163,7 @@ function patchRuleUse(rule, options) {
|
|
|
46
163
|
use.splice(fallbackAnchorIndex + 1, 0, loaderEntry);
|
|
47
164
|
}
|
|
48
165
|
}
|
|
49
|
-
rule.use = use;
|
|
166
|
+
rule.use = normalizedUse.commit(use);
|
|
50
167
|
}
|
|
51
168
|
function walkRspackRule(rule, options) {
|
|
52
169
|
if (!isRuleLike(rule)) return;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { detectAppType } from "./framework.js";
|
|
2
|
-
import { At as toPosixPath } from "./generator-
|
|
2
|
+
import { At as toPosixPath } from "./generator-EnTXLBlK.js";
|
|
3
3
|
import { n as hasCssMacroTailwindV4CustomVariantConditionalComments } from "./auto-2dg_uhEJ.js";
|
|
4
|
-
import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-
|
|
5
|
-
import { S as isSourceStyleRequest } from "./hmr-timing-
|
|
4
|
+
import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-BSEdWieh.js";
|
|
5
|
+
import { S as isSourceStyleRequest } from "./hmr-timing-HGlM4hX3.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { weappStyleInjector } from "weapp-style-injector/vite";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
4
4
|
require("./auto-DtU6f3X6.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
6
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
5
|
+
const require_options = require("./options-CKZW99r4.cjs");
|
|
6
|
+
const require_v4_generation_core = require("./v4-generation-core-BfeXEc6R.cjs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
9
9
|
let node_module = require("node:module");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_generator = require("./generator-
|
|
2
|
-
const require_options = require("./options-
|
|
1
|
+
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
2
|
+
const require_options = require("./options-CKZW99r4.cjs");
|
|
3
3
|
//#region src/context/style-options.ts
|
|
4
4
|
function normalizeStyleHandlerMajorVersion(majorVersion) {
|
|
5
5
|
return majorVersion === 4 ? 4 : void 0;
|
|
@@ -7,5 +7,5 @@ export interface SourceCandidateExtractionOptions {
|
|
|
7
7
|
extractor?: ((source: string, extension: string) => Promise<Iterable<string>> | Iterable<string>) | undefined;
|
|
8
8
|
}
|
|
9
9
|
export declare function extractCandidatesFromSource(source: string, extension: string, options?: SourceCandidateExtractionOptions): Promise<Set<string>>;
|
|
10
|
-
export declare function extractTemplateAttributeCandidates(source: string, extension: string, options: SourceCandidateExtractionOptions): Promise<never[]
|
|
11
|
-
export declare function extractScriptStringCandidates(source: string, extension: string, options: SourceCandidateExtractionOptions): Promise<never[]
|
|
10
|
+
export declare function extractTemplateAttributeCandidates(source: string, extension: string, options: SourceCandidateExtractionOptions): Promise<Set<string> | never[]>;
|
|
11
|
+
export declare function extractScriptStringCandidates(source: string, extension: string, options: SourceCandidateExtractionOptions): Promise<Set<string> | never[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as findWorkspacePackageDir, D as resolveTailwindcssOptions, Dt as resolveCssSourceEntries, E as normalizeTailwindcssRuntimeOptions, Et as parseConfigParam, Lt as loadTailwindV4DesignSystem, Nt as resolveCssMacroTailwindV4Source, O as normalizeStringListOption, S as findNearestPackageRoot, St as expandTailwindSourceEntries, T as normalizeExtendLengthUnits, Tt as normalizeLegacyContentEntries, b as isTailwindV4CssEntry, d as resolveTailwindV4SourceFromRuntime, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, kt as resolveTailwindV4CssSourceBase, m as filterTailwindV4CssSourceRoots, p as resolveTailwindV4SourceOptionsFromRuntime, v as groupCssEntriesByBase, w as findWorkspaceRoot, x as normalizeCssEntries, xt as FULL_SOURCE_SCAN_PATTERN, y as guessBasedirFromEntries } from "./generator-
|
|
1
|
+
import { C as findWorkspacePackageDir, D as resolveTailwindcssOptions, Dt as resolveCssSourceEntries, E as normalizeTailwindcssRuntimeOptions, Et as parseConfigParam, Lt as loadTailwindV4DesignSystem, Nt as resolveCssMacroTailwindV4Source, O as normalizeStringListOption, S as findNearestPackageRoot, St as expandTailwindSourceEntries, T as normalizeExtendLengthUnits, Tt as normalizeLegacyContentEntries, b as isTailwindV4CssEntry, d as resolveTailwindV4SourceFromRuntime, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, kt as resolveTailwindV4CssSourceBase, m as filterTailwindV4CssSourceRoots, p as resolveTailwindV4SourceOptionsFromRuntime, v as groupCssEntriesByBase, w as findWorkspaceRoot, x as normalizeCssEntries, xt as FULL_SOURCE_SCAN_PATTERN, y as guessBasedirFromEntries } from "./generator-EnTXLBlK.js";
|
|
2
2
|
import { t as omitUndefined } from "./object-B-8IHefx.js";
|
|
3
3
|
import { n as defuOverrideArray$1 } from "./utils-MVwpU07P.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
3
3
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
4
|
-
const require_options = require("./options-
|
|
4
|
+
const require_options = require("./options-CKZW99r4.cjs");
|
|
5
5
|
require("./utils-CuKLf1Zv.cjs");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
2
|
+
const require_component_local_style = require("./component-local-style-CNhEhd2B.cjs");
|
|
3
|
+
let _vue_compiler_dom = require("@vue/compiler-dom");
|
|
4
|
+
//#region src/uni-app-x/transform.ts
|
|
5
|
+
function traverse(node, visitor) {
|
|
6
|
+
visitor(node);
|
|
7
|
+
if (Array.isArray(node.children)) {
|
|
8
|
+
for (const child of node.children) if (child && typeof child === "object" && "type" in child) traverse(child, visitor);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function updateStaticAttribute(ms, prop, offset, content = prop.value?.content) {
|
|
12
|
+
if (!prop.value) return;
|
|
13
|
+
const start = offset + prop.value.loc.start.offset + 1;
|
|
14
|
+
const end = offset + prop.value.loc.end.offset - 1;
|
|
15
|
+
if (start < end) ms.update(start, end, require_wxml.replaceWxml(content ?? ""));
|
|
16
|
+
}
|
|
17
|
+
function updateStaticAttributeWithLocalStyle(ms, prop, offset, collector, deep, content = prop.value?.content) {
|
|
18
|
+
if (!prop.value) return;
|
|
19
|
+
const start = offset + prop.value.loc.start.offset + 1;
|
|
20
|
+
const end = offset + prop.value.loc.end.offset - 1;
|
|
21
|
+
if (start < end) ms.update(start, end, collector.collectAndRewriteStaticClass(content ?? "", { deep }));
|
|
22
|
+
}
|
|
23
|
+
function updateDirectiveExpression(ms, prop, offset, jsHandler, runtimeSet) {
|
|
24
|
+
if (prop.exp?.type !== _vue_compiler_dom.NodeTypes.SIMPLE_EXPRESSION) return;
|
|
25
|
+
const expression = prop.exp.content;
|
|
26
|
+
const start = offset + prop.exp.loc.start.offset;
|
|
27
|
+
const end = offset + prop.exp.loc.end.offset;
|
|
28
|
+
if (start >= end) return;
|
|
29
|
+
const generated = require_wxml.generateCode(expression, {
|
|
30
|
+
jsHandler,
|
|
31
|
+
runtimeSet,
|
|
32
|
+
wrapExpression: true
|
|
33
|
+
});
|
|
34
|
+
ms.update(start, end, generated);
|
|
35
|
+
}
|
|
36
|
+
function updateDirectiveExpressionWithLocalStyle(ms, prop, offset, jsHandler, collector, deep, runtimeSet) {
|
|
37
|
+
if (prop.exp?.type !== _vue_compiler_dom.NodeTypes.SIMPLE_EXPRESSION) return;
|
|
38
|
+
const expression = prop.exp.content;
|
|
39
|
+
const start = offset + prop.exp.loc.start.offset;
|
|
40
|
+
const end = offset + prop.exp.loc.end.offset;
|
|
41
|
+
if (start >= end) return;
|
|
42
|
+
collector.collectRuntimeClasses(expression, {
|
|
43
|
+
deep,
|
|
44
|
+
wrapExpression: true
|
|
45
|
+
});
|
|
46
|
+
const generated = require_wxml.generateCode(expression, {
|
|
47
|
+
jsHandler,
|
|
48
|
+
runtimeSet,
|
|
49
|
+
wrapExpression: true
|
|
50
|
+
});
|
|
51
|
+
ms.update(start, end, collector.rewriteTransformedCode(generated, { wrapExpression: true }));
|
|
52
|
+
}
|
|
53
|
+
function shouldEnableLocalStyle(id, options) {
|
|
54
|
+
if (options.enableComponentLocalStyle && require_component_local_style.shouldEnableComponentLocalStyle(id)) return true;
|
|
55
|
+
if (options.enablePageLocalStyle && require_component_local_style.shouldEnablePageLocalStyle(id)) return true;
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute) {
|
|
59
|
+
const lowerName = attrName.toLowerCase();
|
|
60
|
+
const shouldHandleDefault = !disabledDefaultTemplateHandler && lowerName === "class";
|
|
61
|
+
const shouldHandleCustom = matchCustomAttribute?.(tag, attrName) ?? false;
|
|
62
|
+
return {
|
|
63
|
+
shouldHandleDefault,
|
|
64
|
+
shouldHandleCustom,
|
|
65
|
+
shouldHandle: shouldHandleDefault || shouldHandleCustom
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const defaultCreateJsHandlerOptions = { babelParserOptions: { plugins: ["typescript"] } };
|
|
69
|
+
const UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
70
|
+
const SFC_BLOCK_RE = /<(template|script|style)\b([^>]*)>/gi;
|
|
71
|
+
const SCRIPT_SETUP_RE = /(?:^|\s)setup(?:\s|=|$)/;
|
|
72
|
+
const STYLE_SCOPED_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
73
|
+
function findSfcBlockEnd(code, type, contentStart) {
|
|
74
|
+
const closeTag = new RegExp(`<\\/${type}\\s*>`, "gi");
|
|
75
|
+
if (type !== "template") {
|
|
76
|
+
const match = closeTag.exec(code.slice(contentStart));
|
|
77
|
+
return match ? {
|
|
78
|
+
blockEnd: contentStart + match.index + match[0].length,
|
|
79
|
+
contentEnd: contentStart + match.index
|
|
80
|
+
} : void 0;
|
|
81
|
+
}
|
|
82
|
+
const tag = new RegExp(`<\\/?${type}\\b[^>]*>`, "gi");
|
|
83
|
+
tag.lastIndex = contentStart;
|
|
84
|
+
let depth = 1;
|
|
85
|
+
let match = tag.exec(code);
|
|
86
|
+
while (match) {
|
|
87
|
+
if (match[0].startsWith("</")) depth -= 1;
|
|
88
|
+
else if (!match[0].trimEnd().endsWith("/>")) depth += 1;
|
|
89
|
+
if (depth === 0) return {
|
|
90
|
+
blockEnd: tag.lastIndex,
|
|
91
|
+
contentEnd: match.index
|
|
92
|
+
};
|
|
93
|
+
match = tag.exec(code);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function parseSfc(code) {
|
|
97
|
+
const descriptor = {
|
|
98
|
+
errors: [],
|
|
99
|
+
styles: []
|
|
100
|
+
};
|
|
101
|
+
for (const match of code.matchAll(SFC_BLOCK_RE)) {
|
|
102
|
+
const type = match[1];
|
|
103
|
+
const attrs = match[2] ?? "";
|
|
104
|
+
const contentStart = (match.index ?? 0) + match[0].length;
|
|
105
|
+
const blockBoundary = findSfcBlockEnd(code, type, contentStart);
|
|
106
|
+
if (!blockBoundary) {
|
|
107
|
+
descriptor.errors.push(/* @__PURE__ */ new Error(`未闭合的 ${type} SFC 块`));
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const { contentEnd } = blockBoundary;
|
|
111
|
+
const content = code.slice(contentStart, contentEnd);
|
|
112
|
+
const block = {
|
|
113
|
+
content,
|
|
114
|
+
start: contentStart,
|
|
115
|
+
end: contentEnd,
|
|
116
|
+
attrs
|
|
117
|
+
};
|
|
118
|
+
if (type === "template" && !descriptor.template) {
|
|
119
|
+
try {
|
|
120
|
+
descriptor.template = {
|
|
121
|
+
...block,
|
|
122
|
+
ast: (0, _vue_compiler_dom.parse)(content)
|
|
123
|
+
};
|
|
124
|
+
} catch (error) {
|
|
125
|
+
descriptor.errors.push(error);
|
|
126
|
+
descriptor.template = block;
|
|
127
|
+
}
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (type === "script") {
|
|
131
|
+
if (SCRIPT_SETUP_RE.test(attrs)) descriptor.scriptSetup ?? (descriptor.scriptSetup = block);
|
|
132
|
+
else descriptor.script ?? (descriptor.script = block);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (type === "style") descriptor.styles.push(block);
|
|
136
|
+
}
|
|
137
|
+
return descriptor;
|
|
138
|
+
}
|
|
139
|
+
function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
140
|
+
if (!UVUE_NVUE_RE.test(id)) return;
|
|
141
|
+
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
142
|
+
const matchCustomAttribute = require_wxml.createAttributeMatcher(customAttributesEntities);
|
|
143
|
+
const ms = new require_wxml.MagicString(code);
|
|
144
|
+
const descriptor = parseSfc(code);
|
|
145
|
+
const localStyleCollector = shouldEnableLocalStyle(id, options) ? new require_component_local_style.UniAppXComponentLocalStyleCollector(id, runtimeSet) : void 0;
|
|
146
|
+
if (descriptor.errors.length === 0) {
|
|
147
|
+
if (descriptor.template?.ast) {
|
|
148
|
+
const templateOffset = descriptor.template.start;
|
|
149
|
+
traverse(descriptor.template.ast, (node) => {
|
|
150
|
+
if (node.type !== _vue_compiler_dom.NodeTypes.ELEMENT) return;
|
|
151
|
+
const tag = node.tag;
|
|
152
|
+
for (const prop of node.props) if (prop.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE) {
|
|
153
|
+
const { shouldHandle, shouldHandleCustom, shouldHandleDefault } = shouldHandleAttribute(tag, prop.name, disabledDefaultTemplateHandler, matchCustomAttribute);
|
|
154
|
+
if (!shouldHandle) continue;
|
|
155
|
+
if (localStyleCollector) updateStaticAttributeWithLocalStyle(ms, prop, templateOffset, localStyleCollector, options.webCustomAttributeDeep === true && shouldHandleCustom);
|
|
156
|
+
else updateStaticAttribute(ms, prop, templateOffset);
|
|
157
|
+
if (shouldHandleDefault) continue;
|
|
158
|
+
} else if (prop.type === _vue_compiler_dom.NodeTypes.DIRECTIVE && prop.name === "bind" && prop.arg?.type === _vue_compiler_dom.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic) {
|
|
159
|
+
const attrName = prop.arg.content;
|
|
160
|
+
const { shouldHandle, shouldHandleCustom } = shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute);
|
|
161
|
+
if (!shouldHandle) continue;
|
|
162
|
+
if (localStyleCollector) updateDirectiveExpressionWithLocalStyle(ms, prop, templateOffset, jsHandler, localStyleCollector, options.webCustomAttributeDeep === true && shouldHandleCustom, runtimeSet);
|
|
163
|
+
else updateDirectiveExpression(ms, prop, templateOffset, jsHandler, runtimeSet);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (descriptor.script) {
|
|
168
|
+
localStyleCollector?.collectRuntimeClasses(descriptor.script.content);
|
|
169
|
+
const { code } = jsHandler(descriptor.script.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
170
|
+
ms.update(descriptor.script.start, descriptor.script.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
171
|
+
}
|
|
172
|
+
if (descriptor.scriptSetup) {
|
|
173
|
+
localStyleCollector?.collectRuntimeClasses(descriptor.scriptSetup.content);
|
|
174
|
+
const { code } = jsHandler(descriptor.scriptSetup.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
175
|
+
ms.update(descriptor.scriptSetup.start, descriptor.scriptSetup.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
176
|
+
}
|
|
177
|
+
if (localStyleCollector?.hasStyles()) {
|
|
178
|
+
const scopedStyle = descriptor.styles.findLast((style) => STYLE_SCOPED_RE.test(style.attrs));
|
|
179
|
+
if (scopedStyle && options.onWebLocalStyleRules) options.onWebLocalStyleRules(localStyleCollector.toStyleRules());
|
|
180
|
+
else if (scopedStyle) {
|
|
181
|
+
const separator = scopedStyle.content.endsWith("\n") ? "" : "\n";
|
|
182
|
+
ms.appendLeft(scopedStyle.end, `${separator}${localStyleCollector.toStyleRules()}`);
|
|
183
|
+
} else ms.append(`\n${localStyleCollector.toStyleBlock()}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const result = {
|
|
187
|
+
code: ms.toString(),
|
|
188
|
+
map: null
|
|
189
|
+
};
|
|
190
|
+
Object.defineProperty(result, "map", {
|
|
191
|
+
configurable: true,
|
|
192
|
+
enumerable: true,
|
|
193
|
+
get() {
|
|
194
|
+
return ms.generateMap();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
exports.transformUVue = transformUVue;
|