weapp-tailwindcss 5.0.8 → 5.0.11
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/dist/auto-CTp6wE5a.js +33 -0
- package/dist/auto-Cl8_hsG6.mjs +22 -0
- package/dist/{bundle-state-cHwTyrOS.js → bundle-state-BwtEqxvU.js} +3 -3
- package/dist/{bundle-state-5FtFktJr.mjs → bundle-state-CXzPknlT.mjs} +2 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +0 -2
- package/dist/cli.js +1 -159
- package/dist/cli.mjs +1 -159
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -7
- package/dist/css-macro/postcss.d.ts +1 -6
- package/dist/css-macro/postcss.js +15 -3
- package/dist/css-macro/postcss.mjs +2 -2
- package/dist/css-macro.js +19 -5
- package/dist/css-macro.mjs +16 -2
- package/dist/{generator-C--TrAod.js → generator-ChgOWNOj.js} +1 -1
- package/dist/{generator-DnwUQOXB.mjs → generator-h2XRiJ9-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B22YSGU_.mjs → gulp-Be88jhoY.mjs} +5 -5
- package/dist/{gulp-5Tan5bHG.js → gulp-CHtZF-oT.js} +6 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-CscCNKb9.js → hmr-timing-BkivBZvN.js} +41 -43
- package/dist/{hmr-timing-DK-mine6.mjs → hmr-timing-Ct5w4hdM.mjs} +6 -7
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/postcss.d.ts +2 -13
- package/dist/postcss.js +14 -3
- package/dist/postcss.mjs +10 -1
- package/dist/{precheck-CcxTR7E_.mjs → precheck-BpHxsWRd.mjs} +4 -4
- package/dist/{precheck-B8y6tDvG.js → precheck-CY9oaH49.js} +5 -5
- package/dist/presets.js +4 -4
- package/dist/presets.mjs +3 -3
- package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -1
- package/dist/{tailwindcss-0DaftXcU.mjs → tailwindcss-Bfy2egdX.mjs} +2 -2
- package/dist/{tailwindcss-DbZ4o4m_.js → tailwindcss-DbbAKAZP.js} +3 -3
- package/dist/{transform-DiW_u3eD.js → transform-Cd634UZV.js} +1 -1
- package/dist/{transform-DRyWUN5X.mjs → transform-r5evL6Hn.mjs} +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/{v3-engine-ArQVHEau.mjs → v3-engine-CFkP6dWF.mjs} +4 -5
- package/dist/{v3-engine-DdlvXpID.js → v3-engine-D0yA9ZkF.js} +35 -73
- package/dist/{vite-_iUhzc4t.mjs → vite-Bd8qf9dK.mjs} +21 -423
- package/dist/{vite-C_IUnDBy.js → vite-j9cB2Ff1.js} +38 -443
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/watch-dependencies-bpG6kmAf.js +80 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +60 -393
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-KLoTb5Dr.js → webpack-CJAOcYEO.js} +8 -8
- package/dist/{webpack-CqnI4Ymw.mjs → webpack-DPdrcC2X.mjs} +7 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -5
- package/dist/auto-Cvy0zWpS.js +0 -238
- package/dist/auto-DEHRmEAx.mjs +0 -200
- package/dist/bundlers/vite/postcss-config.d.ts +0 -6
- package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +0 -17
- package/dist/postcss/config-directive.d.ts +0 -1
- package/dist/postcss/context.d.ts +0 -9
- package/dist/postcss/source-files.d.ts +0 -8
- package/dist/postcss/tailwind-version.d.ts +0 -3
- package/dist/postcss-C7BMYpEF.mjs +0 -169
- package/dist/postcss-CiYLsqZn.js +0 -192
- package/dist/postcss-CjWuDZwL.mjs +0 -275
- package/dist/postcss-R5pDVHUy.js +0 -284
- package/dist/watch-dependencies-zwx4EhBn.js +0 -5535
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_watch_dependencies = require("./watch-dependencies-
|
|
5
|
+
const require_watch_dependencies = require("./watch-dependencies-bpG6kmAf.js");
|
|
6
6
|
let node_buffer = require("node:buffer");
|
|
7
7
|
let node_process = require("node:process");
|
|
8
8
|
node_process = require_watch_dependencies.__toESM(node_process);
|
|
@@ -63,284 +63,6 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
|
63
63
|
function createBundlerGeneratedCssMarker(bundler, file) {
|
|
64
64
|
return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
|
|
65
65
|
}
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/css-macro/constants.ts
|
|
68
|
-
const queryKey = "weapp-tw-platform";
|
|
69
|
-
const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
|
|
70
|
-
const WHITESPACE_RE = /\s+/g;
|
|
71
|
-
const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
|
|
72
|
-
function normalComment(text) {
|
|
73
|
-
if (typeof text === "string") {
|
|
74
|
-
const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
75
|
-
if (normalized.includes("\\")) return normalized;
|
|
76
|
-
return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
77
|
-
}
|
|
78
|
-
return text;
|
|
79
|
-
}
|
|
80
|
-
function ifdef(text) {
|
|
81
|
-
return {
|
|
82
|
-
start: `#ifdef ${normalComment(text)}`,
|
|
83
|
-
end: `#endif`
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function ifndef(text) {
|
|
87
|
-
return {
|
|
88
|
-
start: `#ifndef ${normalComment(text)}`,
|
|
89
|
-
end: `#endif`
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
93
|
-
function matchCustomPropertyFromValue(str, cb) {
|
|
94
|
-
let index = 0;
|
|
95
|
-
QUERY_KEY_REGEX.lastIndex = 0;
|
|
96
|
-
let arr = QUERY_KEY_REGEX.exec(str);
|
|
97
|
-
while (arr !== null) {
|
|
98
|
-
cb(arr, index);
|
|
99
|
-
index++;
|
|
100
|
-
arr = QUERY_KEY_REGEX.exec(str);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function parseConditionalAtRuleParam(params) {
|
|
104
|
-
const value = params.trim();
|
|
105
|
-
const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
|
|
106
|
-
if (!quoted) return value;
|
|
107
|
-
return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region src/css-macro/postcss.ts
|
|
111
|
-
const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
112
|
-
const CONDITIONAL_COMMENT_SPACING = " ";
|
|
113
|
-
const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
|
|
114
|
-
const creator = () => {
|
|
115
|
-
return {
|
|
116
|
-
postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
|
|
117
|
-
prepare() {
|
|
118
|
-
function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
|
|
119
|
-
const hasPreviousNode = Boolean(atRule.prev());
|
|
120
|
-
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
121
|
-
const startComment = helper.comment({
|
|
122
|
-
raws: {
|
|
123
|
-
left: CONDITIONAL_COMMENT_SPACING,
|
|
124
|
-
right: CONDITIONAL_COMMENT_SPACING
|
|
125
|
-
},
|
|
126
|
-
text: comment.start
|
|
127
|
-
});
|
|
128
|
-
const endComment = helper.comment({
|
|
129
|
-
raws: {
|
|
130
|
-
left: CONDITIONAL_COMMENT_SPACING,
|
|
131
|
-
right: CONDITIONAL_COMMENT_SPACING
|
|
132
|
-
},
|
|
133
|
-
text: comment.end
|
|
134
|
-
});
|
|
135
|
-
const nextNodes = [
|
|
136
|
-
startComment,
|
|
137
|
-
...clonedNodes,
|
|
138
|
-
endComment
|
|
139
|
-
];
|
|
140
|
-
atRule.replaceWith(nextNodes);
|
|
141
|
-
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
142
|
-
startComment.raws["after"] = "\n";
|
|
143
|
-
if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
|
|
144
|
-
endComment.raws.before = "\n";
|
|
145
|
-
endComment.raws["after"] = "\n";
|
|
146
|
-
const nextNode = endComment?.next();
|
|
147
|
-
if (nextNode) nextNode.raws.before = "\n";
|
|
148
|
-
}
|
|
149
|
-
function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
|
|
150
|
-
if (atRule.parent?.type !== "rule") return false;
|
|
151
|
-
const parentRule = atRule.parent;
|
|
152
|
-
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
153
|
-
const conditionalRule = parentRule.clone();
|
|
154
|
-
conditionalRule.removeAll();
|
|
155
|
-
conditionalRule.append(...clonedNodes);
|
|
156
|
-
const startComment = helper.comment({
|
|
157
|
-
raws: {
|
|
158
|
-
left: CONDITIONAL_COMMENT_SPACING,
|
|
159
|
-
right: CONDITIONAL_COMMENT_SPACING
|
|
160
|
-
},
|
|
161
|
-
text: comment.start
|
|
162
|
-
});
|
|
163
|
-
const endComment = helper.comment({
|
|
164
|
-
raws: {
|
|
165
|
-
left: CONDITIONAL_COMMENT_SPACING,
|
|
166
|
-
right: CONDITIONAL_COMMENT_SPACING
|
|
167
|
-
},
|
|
168
|
-
text: comment.end
|
|
169
|
-
});
|
|
170
|
-
const nextNodes = [
|
|
171
|
-
startComment,
|
|
172
|
-
conditionalRule,
|
|
173
|
-
endComment
|
|
174
|
-
];
|
|
175
|
-
const hasPreviousNode = Boolean(parentRule.prev());
|
|
176
|
-
atRule.remove();
|
|
177
|
-
if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
|
|
178
|
-
else parentRule.after(nextNodes);
|
|
179
|
-
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
180
|
-
startComment.raws["after"] = "\n";
|
|
181
|
-
conditionalRule.raws.before = "\n";
|
|
182
|
-
endComment.raws.before = "\n";
|
|
183
|
-
endComment.raws["after"] = "\n";
|
|
184
|
-
const nextNode = endComment.next();
|
|
185
|
-
if (nextNode) nextNode.raws.before = "\n";
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
AtRule(atRule, helper) {
|
|
190
|
-
if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
|
|
191
|
-
const text = parseConditionalAtRuleParam(atRule.params);
|
|
192
|
-
const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
|
|
193
|
-
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
194
|
-
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (atRule.name === "media") {
|
|
198
|
-
const values = [];
|
|
199
|
-
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
200
|
-
const value = arr[1];
|
|
201
|
-
if (value) values.push(value);
|
|
202
|
-
});
|
|
203
|
-
if (values.length > 0) {
|
|
204
|
-
const isNegative = atRule.params.includes("not");
|
|
205
|
-
const text = values.join(" ");
|
|
206
|
-
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
207
|
-
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
208
|
-
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
CommentExit(comment) {
|
|
213
|
-
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
214
|
-
comment.raws.left = CONDITIONAL_COMMENT_SPACING;
|
|
215
|
-
comment.raws.right = CONDITIONAL_COMMENT_SPACING;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
creator.postcss = true;
|
|
223
|
-
const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
|
|
224
|
-
const PLATFORM_ENV_KEYS = [
|
|
225
|
-
"WEAPP_TW_TARGET",
|
|
226
|
-
"WEAPP_TAILWINDCSS_TARGET",
|
|
227
|
-
"UNI_PLATFORM",
|
|
228
|
-
"UNI_UTS_PLATFORM",
|
|
229
|
-
"TARO_ENV",
|
|
230
|
-
"MPX_CLI_MODE",
|
|
231
|
-
"MPX_CURRENT_TARGET_MODE"
|
|
232
|
-
];
|
|
233
|
-
const CONDITIONAL_END_RE = /^\s*#endif\s*$/;
|
|
234
|
-
function readEnvValue(key) {
|
|
235
|
-
return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
|
|
236
|
-
}
|
|
237
|
-
function normalizePlatformToken(value) {
|
|
238
|
-
return value?.trim().replaceAll("_", "-").toUpperCase() || void 0;
|
|
239
|
-
}
|
|
240
|
-
function resolveCssMacroPlatform(options) {
|
|
241
|
-
const explicit = normalizePlatformToken(options?.platform);
|
|
242
|
-
if (explicit) return explicit;
|
|
243
|
-
for (const key of PLATFORM_ENV_KEYS) {
|
|
244
|
-
const value = normalizePlatformToken(readEnvValue(key));
|
|
245
|
-
if (value) return value;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
function createPlatformTokenSet(platform) {
|
|
249
|
-
const normalized = normalizePlatformToken(platform);
|
|
250
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
251
|
-
if (!normalized) return tokens;
|
|
252
|
-
tokens.add(normalized);
|
|
253
|
-
if (normalized.startsWith("MP-")) tokens.add("MP");
|
|
254
|
-
if (normalized === "WEAPP" || normalized === "WEIXIN" || normalized === "WX") {
|
|
255
|
-
tokens.add("MP");
|
|
256
|
-
tokens.add("MP-WEIXIN");
|
|
257
|
-
}
|
|
258
|
-
if (normalized === "MP-WEIXIN") {
|
|
259
|
-
tokens.add("WEAPP");
|
|
260
|
-
tokens.add("WEIXIN");
|
|
261
|
-
tokens.add("WX");
|
|
262
|
-
}
|
|
263
|
-
if (normalized === "H5") tokens.add("WEB");
|
|
264
|
-
if (normalized === "WEB") tokens.add("H5");
|
|
265
|
-
if (normalized === "APP") tokens.add("APP-PLUS");
|
|
266
|
-
if (normalized.startsWith("APP-")) tokens.add("APP");
|
|
267
|
-
if (normalized.startsWith("QUICKAPP-WEBVIEW")) tokens.add("QUICKAPP-WEBVIEW");
|
|
268
|
-
return tokens;
|
|
269
|
-
}
|
|
270
|
-
function combineAnd(values) {
|
|
271
|
-
if (values.includes(false)) return false;
|
|
272
|
-
return values.every((value) => value === true) ? true : void 0;
|
|
273
|
-
}
|
|
274
|
-
function combineOr(values) {
|
|
275
|
-
if (values.includes(true)) return true;
|
|
276
|
-
return values.every((value) => value === false) ? false : void 0;
|
|
277
|
-
}
|
|
278
|
-
function evaluatePlatformExpression(expression, platformTokens) {
|
|
279
|
-
return combineOr(expression.split(/\s*\|\|\s*/).map((orPart) => {
|
|
280
|
-
return combineAnd(orPart.split(/\s*&&\s*/).map((part) => {
|
|
281
|
-
const token = normalizePlatformToken(part);
|
|
282
|
-
if (!token || /[<>=!()]/.test(token)) return;
|
|
283
|
-
return platformTokens.has(token);
|
|
284
|
-
}));
|
|
285
|
-
}));
|
|
286
|
-
}
|
|
287
|
-
function negateConditionalValue(value) {
|
|
288
|
-
return value === void 0 ? void 0 : !value;
|
|
289
|
-
}
|
|
290
|
-
function getActiveConditionalValue(stack) {
|
|
291
|
-
if (stack.includes(false)) return false;
|
|
292
|
-
return stack.includes(void 0) ? void 0 : true;
|
|
293
|
-
}
|
|
294
|
-
function parseConditionalStart(text) {
|
|
295
|
-
const normalized = text.trim();
|
|
296
|
-
if (!normalized.startsWith("#")) return;
|
|
297
|
-
const body = normalized.slice(1).trimStart();
|
|
298
|
-
for (const directive of ["ifndef", "ifdef"]) {
|
|
299
|
-
if (!body.startsWith(directive)) continue;
|
|
300
|
-
const expression = body.slice(directive.length).trim();
|
|
301
|
-
if (expression.length === 0) return;
|
|
302
|
-
return {
|
|
303
|
-
directive,
|
|
304
|
-
expression
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function compileCssMacroConditionalComments(css, options) {
|
|
309
|
-
const platformTokens = createPlatformTokenSet(resolveCssMacroPlatform(options));
|
|
310
|
-
if (platformTokens.size === 0 || !css.includes("#if")) return css;
|
|
311
|
-
try {
|
|
312
|
-
const root = require_watch_dependencies.postcss_default.parse(css);
|
|
313
|
-
const transformContainer = (container) => {
|
|
314
|
-
const stack = [];
|
|
315
|
-
for (const node of [...container.nodes ?? []]) {
|
|
316
|
-
if (node.type === "comment") {
|
|
317
|
-
const start = parseConditionalStart(node.text);
|
|
318
|
-
if (start) {
|
|
319
|
-
const value = start.directive === "ifndef" ? negateConditionalValue(evaluatePlatformExpression(start.expression, platformTokens)) : evaluatePlatformExpression(start.expression, platformTokens);
|
|
320
|
-
const parentActive = getActiveConditionalValue(stack);
|
|
321
|
-
stack.push(value);
|
|
322
|
-
if (parentActive !== void 0 && value !== void 0) node.remove();
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
325
|
-
if (CONDITIONAL_END_RE.test(node.text)) {
|
|
326
|
-
const value = stack.pop();
|
|
327
|
-
if (getActiveConditionalValue(stack) !== void 0 && value !== void 0) node.remove();
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if (getActiveConditionalValue(stack) === false) {
|
|
332
|
-
node.remove();
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
if ("nodes" in node && node.nodes) transformContainer(node);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
transformContainer(root);
|
|
339
|
-
return root.toString();
|
|
340
|
-
} catch {
|
|
341
|
-
return css;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
66
|
function isCssMacroTailwindPlugin(value) {
|
|
345
67
|
return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
|
|
346
68
|
}
|
|
@@ -350,61 +72,6 @@ function hasCssMacroTailwindPlugin(plugins) {
|
|
|
350
72
|
if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
|
|
351
73
|
return false;
|
|
352
74
|
}
|
|
353
|
-
function parseCssPluginRequest(params) {
|
|
354
|
-
const value = params.trim();
|
|
355
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
356
|
-
if (quoted) return quoted[2];
|
|
357
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
358
|
-
return url?.[2] ?? url?.[3];
|
|
359
|
-
}
|
|
360
|
-
function isCssMacroPluginRequest(request) {
|
|
361
|
-
return request === "weapp-tailwindcss/css-macro";
|
|
362
|
-
}
|
|
363
|
-
function hasCssMacroTailwindV4Directive(css) {
|
|
364
|
-
if (!css?.includes("css-macro")) return false;
|
|
365
|
-
try {
|
|
366
|
-
let found = false;
|
|
367
|
-
require_watch_dependencies.postcss_default.parse(css).walkAtRules("plugin", (rule) => {
|
|
368
|
-
if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
|
|
369
|
-
});
|
|
370
|
-
return found;
|
|
371
|
-
} catch {
|
|
372
|
-
return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
function isCssMacroPostcssPlugin(plugin) {
|
|
376
|
-
if (plugin === creator) return true;
|
|
377
|
-
return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
|
|
378
|
-
}
|
|
379
|
-
function withCssMacroPostcssPlugins(plugins) {
|
|
380
|
-
const macroPlugin = creator();
|
|
381
|
-
if (!plugins) return [macroPlugin];
|
|
382
|
-
if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
|
|
383
|
-
if (typeof plugins === "object") {
|
|
384
|
-
const values = Object.values(plugins).filter(Boolean);
|
|
385
|
-
if (values.some(isCssMacroPostcssPlugin)) return values;
|
|
386
|
-
return [...values, macroPlugin];
|
|
387
|
-
}
|
|
388
|
-
return [macroPlugin];
|
|
389
|
-
}
|
|
390
|
-
function withCssMacroStyleOptions(options) {
|
|
391
|
-
const postcssOptions = options?.postcssOptions;
|
|
392
|
-
return {
|
|
393
|
-
...options,
|
|
394
|
-
[CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
|
|
395
|
-
postcssOptions: {
|
|
396
|
-
...postcssOptions,
|
|
397
|
-
plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
function hasCssMacroStyleOptions(options) {
|
|
402
|
-
return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
|
|
403
|
-
}
|
|
404
|
-
async function transformCssMacroCss(css, options) {
|
|
405
|
-
const result = (await require_watch_dependencies.postcss_default([creator()]).process(css, { from: void 0 })).css;
|
|
406
|
-
return compileCssMacroConditionalComments(result, options);
|
|
407
|
-
}
|
|
408
75
|
//#endregion
|
|
409
76
|
//#region src/utils/object.ts
|
|
410
77
|
function definedEntries(value) {
|
|
@@ -444,7 +111,7 @@ function collectApplyCandidatesFromCss(css) {
|
|
|
444
111
|
if (!css.includes("@apply")) return [];
|
|
445
112
|
const candidates = /* @__PURE__ */ new Set();
|
|
446
113
|
try {
|
|
447
|
-
|
|
114
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("apply", (rule) => {
|
|
448
115
|
for (const candidate of rule.params.split(/\s+/)) {
|
|
449
116
|
const normalized = candidate.replace(/!important$/, "").trim();
|
|
450
117
|
if (normalized) candidates.add(normalized);
|
|
@@ -485,7 +152,7 @@ function collectLayerCandidatesFromCss(css) {
|
|
|
485
152
|
if (!css.includes("@layer")) return [];
|
|
486
153
|
const candidates = /* @__PURE__ */ new Set();
|
|
487
154
|
try {
|
|
488
|
-
|
|
155
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("layer", (layer) => {
|
|
489
156
|
if (!isTailwindCandidateLayer(layer.params)) return;
|
|
490
157
|
layer.walkRules((rule) => {
|
|
491
158
|
extractClassCandidatesFromSelector(rule.selector, candidates);
|
|
@@ -1893,7 +1560,7 @@ function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
|
1893
1560
|
if (!css.includes("preflight")) return css;
|
|
1894
1561
|
let root;
|
|
1895
1562
|
try {
|
|
1896
|
-
root =
|
|
1563
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1897
1564
|
} catch {
|
|
1898
1565
|
return css;
|
|
1899
1566
|
}
|
|
@@ -1921,7 +1588,7 @@ function removeUnsupportedThemeVendorKeyframes(css) {
|
|
|
1921
1588
|
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1922
1589
|
let root;
|
|
1923
1590
|
try {
|
|
1924
|
-
root =
|
|
1591
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1925
1592
|
} catch {
|
|
1926
1593
|
return css;
|
|
1927
1594
|
}
|
|
@@ -2052,7 +1719,7 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
2052
1719
|
const from = source.dependencies[0];
|
|
2053
1720
|
let root;
|
|
2054
1721
|
try {
|
|
2055
|
-
root =
|
|
1722
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(source.css, { from });
|
|
2056
1723
|
} catch {
|
|
2057
1724
|
return;
|
|
2058
1725
|
}
|
|
@@ -2099,7 +1766,7 @@ function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
|
2099
1766
|
});
|
|
2100
1767
|
}
|
|
2101
1768
|
async function transformTailwindV4CssToWeapp(css, options) {
|
|
2102
|
-
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
1769
|
+
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
2103
1770
|
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
2104
1771
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
2105
1772
|
cssRemoveHoverPseudoClass: true,
|
|
@@ -2107,12 +1774,12 @@ async function transformTailwindV4CssToWeapp(css, options) {
|
|
|
2107
1774
|
majorVersion: 4,
|
|
2108
1775
|
...options
|
|
2109
1776
|
});
|
|
2110
|
-
const pruneOptions = { preserveConditionalComments: hasCssMacroStyleOptions(options) };
|
|
1777
|
+
const pruneOptions = { preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) };
|
|
2111
1778
|
return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
|
|
2112
1779
|
}
|
|
2113
1780
|
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
2114
1781
|
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
2115
|
-
return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
|
|
1782
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css;
|
|
2116
1783
|
}
|
|
2117
1784
|
//#endregion
|
|
2118
1785
|
//#region src/tailwindcss/v4-engine/generator.ts
|
|
@@ -2199,12 +1866,12 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
2199
1866
|
};
|
|
2200
1867
|
}
|
|
2201
1868
|
function resolveStyleOptions$1(source, options) {
|
|
2202
|
-
return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
|
|
1869
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Directive)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
2203
1870
|
}
|
|
2204
1871
|
function collectCustomPropertyValues(css) {
|
|
2205
1872
|
const values = /* @__PURE__ */ new Map();
|
|
2206
1873
|
try {
|
|
2207
|
-
|
|
1874
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkDecls((decl) => {
|
|
2208
1875
|
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
2209
1876
|
});
|
|
2210
1877
|
} catch {}
|
|
@@ -2693,12 +2360,12 @@ function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
|
|
|
2693
2360
|
}
|
|
2694
2361
|
function normalizeTailwindV3CssEntrySource(rawSource) {
|
|
2695
2362
|
try {
|
|
2696
|
-
const root =
|
|
2363
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2697
2364
|
let changed = false;
|
|
2698
2365
|
root.walkAtRules("import", (node) => {
|
|
2699
2366
|
const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
|
|
2700
2367
|
if (!layer) return;
|
|
2701
|
-
node.replaceWith(
|
|
2368
|
+
node.replaceWith(_weapp_tailwindcss_postcss.postcss.atRule({
|
|
2702
2369
|
name: "tailwind",
|
|
2703
2370
|
params: layer
|
|
2704
2371
|
}));
|
|
@@ -2712,7 +2379,7 @@ function normalizeTailwindV3CssEntrySource(rawSource) {
|
|
|
2712
2379
|
function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
2713
2380
|
if (!options.importFallback) return rawSource;
|
|
2714
2381
|
try {
|
|
2715
|
-
const root =
|
|
2382
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2716
2383
|
return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
|
|
2717
2384
|
} catch {
|
|
2718
2385
|
return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
|
|
@@ -2747,7 +2414,7 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
2747
2414
|
try {
|
|
2748
2415
|
const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
|
|
2749
2416
|
if (!source) return "";
|
|
2750
|
-
const root =
|
|
2417
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2751
2418
|
let removed = false;
|
|
2752
2419
|
root.walk((node) => {
|
|
2753
2420
|
if (isTailwindSourceDirective(node, options)) {
|
|
@@ -2763,7 +2430,7 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
2763
2430
|
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
2764
2431
|
try {
|
|
2765
2432
|
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
2766
|
-
const root =
|
|
2433
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2767
2434
|
let found = false;
|
|
2768
2435
|
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
2769
2436
|
root.walk((node) => {
|
|
@@ -2783,7 +2450,7 @@ function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
2783
2450
|
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
2784
2451
|
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
2785
2452
|
try {
|
|
2786
|
-
const root =
|
|
2453
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2787
2454
|
let found = false;
|
|
2788
2455
|
root.walkAtRules((node) => {
|
|
2789
2456
|
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
@@ -2800,7 +2467,7 @@ function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
|
2800
2467
|
function hasTailwindApplyDirective(rawSource) {
|
|
2801
2468
|
if (!rawSource.includes("@apply")) return false;
|
|
2802
2469
|
try {
|
|
2803
|
-
const root =
|
|
2470
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2804
2471
|
let found = false;
|
|
2805
2472
|
root.walkAtRules("apply", () => {
|
|
2806
2473
|
found = true;
|
|
@@ -2813,7 +2480,7 @@ function hasTailwindApplyDirective(rawSource) {
|
|
|
2813
2480
|
}
|
|
2814
2481
|
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
2815
2482
|
try {
|
|
2816
|
-
const root =
|
|
2483
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2817
2484
|
const normalizedImports = normalizeTailwindImportAtRules(root, options);
|
|
2818
2485
|
let found = false;
|
|
2819
2486
|
let config;
|
|
@@ -2956,7 +2623,7 @@ function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
|
2956
2623
|
if (!css.includes("tailwindcss")) return css;
|
|
2957
2624
|
let root;
|
|
2958
2625
|
try {
|
|
2959
|
-
root =
|
|
2626
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2960
2627
|
} catch {
|
|
2961
2628
|
return css;
|
|
2962
2629
|
}
|
|
@@ -3311,7 +2978,7 @@ async function resolveConfigContentEntries(root, base) {
|
|
|
3311
2978
|
async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
3312
2979
|
let root;
|
|
3313
2980
|
try {
|
|
3314
|
-
root =
|
|
2981
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3315
2982
|
} catch {
|
|
3316
2983
|
return;
|
|
3317
2984
|
}
|
|
@@ -3489,7 +3156,7 @@ function hasResetDeclaration(rule) {
|
|
|
3489
3156
|
}
|
|
3490
3157
|
function createPreflightDeclarations(cssPreflight) {
|
|
3491
3158
|
if (!cssPreflight || typeof cssPreflight !== "object") return [];
|
|
3492
|
-
return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) =>
|
|
3159
|
+
return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) => _weapp_tailwindcss_postcss.postcss.decl({
|
|
3493
3160
|
prop,
|
|
3494
3161
|
value: value.toString()
|
|
3495
3162
|
}));
|
|
@@ -3498,7 +3165,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
|
3498
3165
|
const declarations = createPreflightDeclarations(cssPreflight);
|
|
3499
3166
|
if (declarations.length === 0) return css;
|
|
3500
3167
|
try {
|
|
3501
|
-
const root =
|
|
3168
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3502
3169
|
let targetRule;
|
|
3503
3170
|
let hasReset = false;
|
|
3504
3171
|
root.walkRules((rule) => {
|
|
@@ -3514,7 +3181,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
|
3514
3181
|
}
|
|
3515
3182
|
}
|
|
3516
3183
|
async function transformTailwindV3CssToWeapp(css, options) {
|
|
3517
|
-
const result = await defaultStyleHandler(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css, {
|
|
3184
|
+
const result = await defaultStyleHandler((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css, {
|
|
3518
3185
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
3519
3186
|
cssRemoveHoverPseudoClass: true,
|
|
3520
3187
|
isMainChunk: true,
|
|
@@ -3523,13 +3190,13 @@ async function transformTailwindV3CssToWeapp(css, options) {
|
|
|
3523
3190
|
});
|
|
3524
3191
|
const pruneOptions = {
|
|
3525
3192
|
preservePreflight: true,
|
|
3526
|
-
preserveConditionalComments: hasCssMacroStyleOptions(options)
|
|
3193
|
+
preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options)
|
|
3527
3194
|
};
|
|
3528
3195
|
return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
|
|
3529
3196
|
}
|
|
3530
3197
|
async function transformTailwindV3CssByTarget(css, target, options) {
|
|
3531
3198
|
if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
|
|
3532
|
-
return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
|
|
3199
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css;
|
|
3533
3200
|
}
|
|
3534
3201
|
//#endregion
|
|
3535
3202
|
//#region src/tailwindcss/v3-engine/generator.ts
|
|
@@ -3600,7 +3267,7 @@ function shouldAutoEnableCssMacro(source) {
|
|
|
3600
3267
|
return hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
|
|
3601
3268
|
}
|
|
3602
3269
|
function resolveStyleOptions(source, options) {
|
|
3603
|
-
return shouldAutoEnableCssMacro(source) ? withCssMacroStyleOptions(options) : options;
|
|
3270
|
+
return shouldAutoEnableCssMacro(source) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
3604
3271
|
}
|
|
3605
3272
|
function loadTailwindV3Internals(source) {
|
|
3606
3273
|
const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
|
|
@@ -3706,7 +3373,7 @@ function createTailwindV3Engine(source) {
|
|
|
3706
3373
|
const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, tailwindOptions)));
|
|
3707
3374
|
const candidates = normalizedCandidates.candidates;
|
|
3708
3375
|
const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
|
|
3709
|
-
const root =
|
|
3376
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(generateSource.css, { from: void 0 });
|
|
3710
3377
|
const result = {
|
|
3711
3378
|
css: "",
|
|
3712
3379
|
messages: []
|
|
@@ -3756,7 +3423,7 @@ function createTailwindV3Engine(source) {
|
|
|
3756
3423
|
async function generateIncrementalMissingUtilities(context, candidates, target, styleOptions, bareArbitraryValues) {
|
|
3757
3424
|
tailwindInternals ??= loadTailwindV3Internals(source);
|
|
3758
3425
|
const internals = tailwindInternals;
|
|
3759
|
-
const root =
|
|
3426
|
+
const root = _weapp_tailwindcss_postcss.postcss.root();
|
|
3760
3427
|
const result = {
|
|
3761
3428
|
css: "",
|
|
3762
3429
|
messages: []
|
|
@@ -3878,7 +3545,7 @@ function resolveCssConfig(css, base) {
|
|
|
3878
3545
|
css,
|
|
3879
3546
|
config: void 0
|
|
3880
3547
|
};
|
|
3881
|
-
const root =
|
|
3548
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3882
3549
|
let config;
|
|
3883
3550
|
root.walkAtRules("config", (rule) => {
|
|
3884
3551
|
const configPath = parseConfigParam(rule.params);
|
|
@@ -4438,7 +4105,7 @@ function collectGeneratedSelectors(css) {
|
|
|
4438
4105
|
if (cached) return cached;
|
|
4439
4106
|
const selectors = /* @__PURE__ */ new Set();
|
|
4440
4107
|
try {
|
|
4441
|
-
|
|
4108
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkRules((rule) => {
|
|
4442
4109
|
if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
|
|
4443
4110
|
for (const selector of getRuleCompatSelectorKeys(rule)) selectors.add(selector);
|
|
4444
4111
|
});
|
|
@@ -4451,7 +4118,7 @@ function collectGeneratedSelectors(css) {
|
|
|
4451
4118
|
function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
|
|
4452
4119
|
const propsBySelector = /* @__PURE__ */ new Map();
|
|
4453
4120
|
try {
|
|
4454
|
-
|
|
4121
|
+
_weapp_tailwindcss_postcss.postcss.parse(generatedCss).walkRules((rule) => {
|
|
4455
4122
|
const matchedSelectors = getRuleCompatSelectorKeys(rule).filter((selector) => selectors.has(selector));
|
|
4456
4123
|
if (matchedSelectors.length === 0) return;
|
|
4457
4124
|
const props = /* @__PURE__ */ new Set();
|
|
@@ -4473,7 +4140,7 @@ function removeGeneratedSelectorCompatCss(css, generatedCss) {
|
|
|
4473
4140
|
const generatedSelectors = collectGeneratedSelectors(generatedCss);
|
|
4474
4141
|
if (generatedSelectors.size === 0) return css;
|
|
4475
4142
|
try {
|
|
4476
|
-
const root =
|
|
4143
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
4477
4144
|
let removed = false;
|
|
4478
4145
|
root.walkRules((rule) => {
|
|
4479
4146
|
if (isPseudoContentInitRule(rule)) {
|
|
@@ -4501,7 +4168,7 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
|
|
|
4501
4168
|
const generatedDeclarationPropsBySelector = collectGeneratedDeclarationPropsBySelector(generatedCss, generatedSelectors);
|
|
4502
4169
|
const preservedNodes = [];
|
|
4503
4170
|
try {
|
|
4504
|
-
const root =
|
|
4171
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
4505
4172
|
root.each((node) => {
|
|
4506
4173
|
if (node.type === "rule") {
|
|
4507
4174
|
const nodeSelectors = getRuleCompatSelectorKeys(node);
|
|
@@ -4530,7 +4197,7 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
|
|
|
4530
4197
|
preservedNodes.push(node.clone());
|
|
4531
4198
|
});
|
|
4532
4199
|
if (preservedNodes.length === root.nodes.length) return css;
|
|
4533
|
-
const nextRoot =
|
|
4200
|
+
const nextRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
4534
4201
|
nextRoot.append(preservedNodes);
|
|
4535
4202
|
return nextRoot.toString();
|
|
4536
4203
|
} catch {
|
|
@@ -5039,7 +4706,7 @@ function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
|
5039
4706
|
function collectTailwindApplyUtilities(css) {
|
|
5040
4707
|
let root;
|
|
5041
4708
|
try {
|
|
5042
|
-
root =
|
|
4709
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5043
4710
|
} catch {
|
|
5044
4711
|
return [];
|
|
5045
4712
|
}
|
|
@@ -5313,7 +4980,7 @@ function countUnclosedBlocks(source) {
|
|
|
5313
4980
|
}
|
|
5314
4981
|
function closeTrailingUnclosedBlocks(source) {
|
|
5315
4982
|
try {
|
|
5316
|
-
|
|
4983
|
+
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5317
4984
|
return source;
|
|
5318
4985
|
} catch (error) {
|
|
5319
4986
|
if (error.reason !== "Unclosed block") return source;
|
|
@@ -5323,7 +4990,7 @@ function closeTrailingUnclosedBlocks(source) {
|
|
|
5323
4990
|
}
|
|
5324
4991
|
function removeTailwindApplyRules(rawSource) {
|
|
5325
4992
|
try {
|
|
5326
|
-
const root =
|
|
4993
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
5327
4994
|
let removed = false;
|
|
5328
4995
|
root.walkAtRules("apply", (rule) => {
|
|
5329
4996
|
const parent = rule.parent;
|
|
@@ -5348,7 +5015,7 @@ function resolveLegacyCompatCssSource(rawSource) {
|
|
|
5348
5015
|
}
|
|
5349
5016
|
function removeMiniProgramContainerCompatCss(css) {
|
|
5350
5017
|
try {
|
|
5351
|
-
const root =
|
|
5018
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5352
5019
|
let removed = false;
|
|
5353
5020
|
root.walkRules((rule) => {
|
|
5354
5021
|
if (rule.selectors?.length === 1 && rule.selectors[0] === ".container") {
|
|
@@ -5438,7 +5105,7 @@ const CSS_LENGTH_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)(?:px|rem)\b/i;
|
|
|
5438
5105
|
const RPX_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)rpx\b/i;
|
|
5439
5106
|
function createLegacyDeclarationValueMap(css) {
|
|
5440
5107
|
const values = /* @__PURE__ */ new Map();
|
|
5441
|
-
|
|
5108
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkRules((rule) => {
|
|
5442
5109
|
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
5443
5110
|
for (const selector of rule.selectors) {
|
|
5444
5111
|
const normalizedSelectors = normalizeCompatSelectors(selector);
|
|
@@ -5453,7 +5120,7 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
|
5453
5120
|
try {
|
|
5454
5121
|
const legacyValues = createLegacyDeclarationValueMap(legacyCss);
|
|
5455
5122
|
if (legacyValues.size === 0) return css;
|
|
5456
|
-
const root =
|
|
5123
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5457
5124
|
let changed = false;
|
|
5458
5125
|
root.walkRules((rule) => {
|
|
5459
5126
|
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
@@ -5491,7 +5158,7 @@ function isLocalImportRequest(request) {
|
|
|
5491
5158
|
function isPureLocalCssImportWrapper(css) {
|
|
5492
5159
|
let hasImport = false;
|
|
5493
5160
|
try {
|
|
5494
|
-
const root =
|
|
5161
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5495
5162
|
for (const node of root.nodes) {
|
|
5496
5163
|
if (node.type === "comment") continue;
|
|
5497
5164
|
if (node.type !== "atrule" || node.name !== "import") return false;
|
|
@@ -5508,7 +5175,7 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
|
5508
5175
|
let hasLocalImport = false;
|
|
5509
5176
|
let hasTailwindDirective = false;
|
|
5510
5177
|
try {
|
|
5511
|
-
const root =
|
|
5178
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5512
5179
|
for (const node of root.nodes) {
|
|
5513
5180
|
if (node.type === "comment") continue;
|
|
5514
5181
|
if (node.type === "atrule" && node.name === "import") {
|
|
@@ -5530,7 +5197,7 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
|
5530
5197
|
}
|
|
5531
5198
|
function prefixLocalCssImportsWithWebpackIgnore(css) {
|
|
5532
5199
|
try {
|
|
5533
|
-
const root =
|
|
5200
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5534
5201
|
root.walkAtRules("import", (atRule) => {
|
|
5535
5202
|
const request = parseImportRequest(atRule.params);
|
|
5536
5203
|
if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
|
|
@@ -5542,8 +5209,8 @@ function prefixLocalCssImportsWithWebpackIgnore(css) {
|
|
|
5542
5209
|
}
|
|
5543
5210
|
function splitLocalCssImports(source) {
|
|
5544
5211
|
try {
|
|
5545
|
-
const root =
|
|
5546
|
-
const importRoot =
|
|
5212
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5213
|
+
const importRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
5547
5214
|
let changed = false;
|
|
5548
5215
|
for (const node of [...root.nodes]) {
|
|
5549
5216
|
if (node.type !== "atrule" || node.name !== "import") continue;
|
|
@@ -5580,7 +5247,7 @@ const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
|
|
|
5580
5247
|
function removeTailwindApplyAtRules(source) {
|
|
5581
5248
|
if (!source.includes("@apply")) return source;
|
|
5582
5249
|
try {
|
|
5583
|
-
const root =
|
|
5250
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5584
5251
|
let changed = false;
|
|
5585
5252
|
root.walkAtRules("apply", (rule) => {
|
|
5586
5253
|
rule.remove();
|
|
@@ -5596,7 +5263,7 @@ function removeTailwindApplyAtRules(source) {
|
|
|
5596
5263
|
}
|
|
5597
5264
|
function removeTailwindV4GeneratorAtRules(source) {
|
|
5598
5265
|
try {
|
|
5599
|
-
const root =
|
|
5266
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5600
5267
|
let changed = false;
|
|
5601
5268
|
root.walkAtRules((rule) => {
|
|
5602
5269
|
if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
|
|
@@ -5616,7 +5283,7 @@ function removeTailwindV4GeneratorAtRules(source) {
|
|
|
5616
5283
|
}
|
|
5617
5284
|
function isCommentOnlyCss(source) {
|
|
5618
5285
|
try {
|
|
5619
|
-
const root =
|
|
5286
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5620
5287
|
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
5621
5288
|
} catch {
|
|
5622
5289
|
return false;
|
|
@@ -5642,7 +5309,7 @@ function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
|
5642
5309
|
}
|
|
5643
5310
|
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
5644
5311
|
try {
|
|
5645
|
-
|
|
5312
|
+
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5646
5313
|
return source;
|
|
5647
5314
|
} catch {
|
|
5648
5315
|
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
@@ -5654,9 +5321,9 @@ function splitUserCssLayerBlocks(source) {
|
|
|
5654
5321
|
rest: source
|
|
5655
5322
|
};
|
|
5656
5323
|
try {
|
|
5657
|
-
const root =
|
|
5658
|
-
const layerRoot =
|
|
5659
|
-
const restRoot =
|
|
5324
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5325
|
+
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
5326
|
+
const restRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
5660
5327
|
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
5661
5328
|
return {
|
|
5662
5329
|
layer: layerRoot.toString(),
|
|
@@ -5673,7 +5340,7 @@ function hasUserCssLayerBlocks(source) {
|
|
|
5673
5340
|
if (!source.includes("@layer")) return false;
|
|
5674
5341
|
try {
|
|
5675
5342
|
let hasLayerBlock = false;
|
|
5676
|
-
|
|
5343
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
|
|
5677
5344
|
if (node.nodes?.length) hasLayerBlock = true;
|
|
5678
5345
|
});
|
|
5679
5346
|
return hasLayerBlock;
|
|
@@ -5684,7 +5351,7 @@ function hasUserCssLayerBlocks(source) {
|
|
|
5684
5351
|
function collectUserLayerSelectors(source) {
|
|
5685
5352
|
const selectors = /* @__PURE__ */ new Set();
|
|
5686
5353
|
try {
|
|
5687
|
-
|
|
5354
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
5688
5355
|
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
5689
5356
|
const normalized = selector.trim();
|
|
5690
5357
|
if (normalized) selectors.add(normalized);
|
|
@@ -5706,8 +5373,8 @@ function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
|
5706
5373
|
rest: css
|
|
5707
5374
|
};
|
|
5708
5375
|
try {
|
|
5709
|
-
const root =
|
|
5710
|
-
const layerRoot =
|
|
5376
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5377
|
+
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
5711
5378
|
const selectorList = [...selectors];
|
|
5712
5379
|
root.walkRules((rule) => {
|
|
5713
5380
|
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
@@ -5732,7 +5399,7 @@ function normalizeGeneratedSelector(selector) {
|
|
|
5732
5399
|
function collectApplyOnlySourceSelectors(source) {
|
|
5733
5400
|
const selectors = /* @__PURE__ */ new Set();
|
|
5734
5401
|
try {
|
|
5735
|
-
|
|
5402
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
5736
5403
|
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
5737
5404
|
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
5738
5405
|
const normalized = normalizeGeneratedSelector(selector);
|
|
@@ -5746,7 +5413,7 @@ function hasOnlyApplyBackedSourceRules(source) {
|
|
|
5746
5413
|
let hasApplyRule = false;
|
|
5747
5414
|
let hasNonApplyRule = false;
|
|
5748
5415
|
try {
|
|
5749
|
-
|
|
5416
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
5750
5417
|
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
5751
5418
|
else hasNonApplyRule = true;
|
|
5752
5419
|
});
|
|
@@ -5760,7 +5427,7 @@ function filterApplyOnlyGeneratedCss(css, source) {
|
|
|
5760
5427
|
if (selectors.size === 0) return css;
|
|
5761
5428
|
const selectorList = [...selectors];
|
|
5762
5429
|
try {
|
|
5763
|
-
const root =
|
|
5430
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5764
5431
|
root.walkRules((rule) => {
|
|
5765
5432
|
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
5766
5433
|
const normalized = normalizeGeneratedSelector(selector);
|