@weapp-tailwindcss/postcss 3.2.8 → 3.2.10
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/compat/lynx-css.d.ts +2 -0
- package/dist/css-macro/auto.d.ts +2 -4
- package/dist/css-macro/conditions.d.ts +6 -0
- package/dist/html-transform.cjs +5 -3
- package/dist/html-transform.js +4 -2
- package/dist/index.cjs +366 -113
- package/dist/index.d.ts +2 -0
- package/dist/index.js +364 -113
- package/dist/{rolldown-runtime-D6vf50IK.cjs → rolldown-runtime-VH7oDXx4.cjs} +1 -1
- package/dist/selectorParser/pseudo.d.ts +1 -0
- package/dist/selectorParser/rule-transformer/types.d.ts +1 -0
- package/dist/selectorParser/rule-transformer/unsupported-pseudos.d.ts +5 -0
- package/dist/selectorParser.d.ts +1 -0
- package/dist/types.d.ts +13 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -216,7 +216,8 @@ function trimNodes$1(nodes) {
|
|
|
216
216
|
}
|
|
217
217
|
function getParsedColorData(colorSource) {
|
|
218
218
|
try {
|
|
219
|
-
|
|
219
|
+
const parsed = parseComponentValue(tokenize({ css: colorSource }));
|
|
220
|
+
return color(parsed);
|
|
220
221
|
} catch {
|
|
221
222
|
return false;
|
|
222
223
|
}
|
|
@@ -1763,8 +1764,8 @@ function resolveNodes(nodes, variables, resolving) {
|
|
|
1763
1764
|
const fallback = commaIndex >= 0 ? valueParser.stringify(node.nodes.slice(commaIndex + 1)).trim() : "";
|
|
1764
1765
|
const configured = variables.get(variable.value);
|
|
1765
1766
|
let replacement;
|
|
1766
|
-
if (configured !== void 0 && !resolving.has(variable.value)) replacement = resolveThemeValue(configured, variables, /* @__PURE__ */ new Set([...resolving, variable.value]));
|
|
1767
|
-
else if (fallback && isTailwindcssV4ThemeVariable(variable.value)) replacement = resolveThemeValue(fallback, variables, resolving);
|
|
1767
|
+
if (configured !== void 0 && !resolving.has(variable.value)) replacement = resolveThemeValue$1(configured, variables, /* @__PURE__ */ new Set([...resolving, variable.value]));
|
|
1768
|
+
else if (fallback && isTailwindcssV4ThemeVariable(variable.value)) replacement = resolveThemeValue$1(fallback, variables, resolving);
|
|
1768
1769
|
if (replacement === void 0) {
|
|
1769
1770
|
resolveNodes(node.nodes, variables, resolving);
|
|
1770
1771
|
continue;
|
|
@@ -1774,7 +1775,7 @@ function resolveNodes(nodes, variables, resolving) {
|
|
|
1774
1775
|
index += replacementNodes.length - 1;
|
|
1775
1776
|
}
|
|
1776
1777
|
}
|
|
1777
|
-
function resolveThemeValue(value, variables, resolving = /* @__PURE__ */ new Set()) {
|
|
1778
|
+
function resolveThemeValue$1(value, variables, resolving = /* @__PURE__ */ new Set()) {
|
|
1778
1779
|
if (!value.includes("var(")) return value;
|
|
1779
1780
|
const parsed = valueParser(value);
|
|
1780
1781
|
resolveNodes(parsed.nodes, variables, resolving);
|
|
@@ -1828,7 +1829,7 @@ function consumeUniAppXSystemRootTheme(root, customPropertyValues) {
|
|
|
1828
1829
|
const carriers = new Set(carrierRules);
|
|
1829
1830
|
root.walkDecls((decl) => {
|
|
1830
1831
|
if (decl.parent?.type === "rule" && carriers.has(decl.parent)) return;
|
|
1831
|
-
decl.value = resolveThemeValue(decl.value, variables);
|
|
1832
|
+
decl.value = resolveThemeValue$1(decl.value, variables);
|
|
1832
1833
|
});
|
|
1833
1834
|
}
|
|
1834
1835
|
splitUnresolvedAuthorVariableFallbacks(root, variables);
|
|
@@ -2102,6 +2103,92 @@ function resolvePostcssStyleBranchProfile(options) {
|
|
|
2102
2103
|
return resolvePostcssFrameworkProfile(options);
|
|
2103
2104
|
}
|
|
2104
2105
|
//#endregion
|
|
2106
|
+
//#region src/compat/lynx-css.ts
|
|
2107
|
+
const tailwindThemePropertyPatterns = [
|
|
2108
|
+
/^--aspect-/,
|
|
2109
|
+
/^--animate-/,
|
|
2110
|
+
/^--blur-/,
|
|
2111
|
+
/^--breakpoint-/,
|
|
2112
|
+
/^--color-/,
|
|
2113
|
+
/^--container-/,
|
|
2114
|
+
/^--drop-shadow-/,
|
|
2115
|
+
/^--ease-/,
|
|
2116
|
+
/^--default-font-/,
|
|
2117
|
+
/^--font-/,
|
|
2118
|
+
/^--font-weight-/,
|
|
2119
|
+
/^--inset-shadow-/,
|
|
2120
|
+
/^--leading-/,
|
|
2121
|
+
/^--perspective-/,
|
|
2122
|
+
/^--radius-/,
|
|
2123
|
+
/^--shadow-/,
|
|
2124
|
+
/^--text-/,
|
|
2125
|
+
/^--tracking-/,
|
|
2126
|
+
/^--spacing$/
|
|
2127
|
+
];
|
|
2128
|
+
function isTailwindThemeProperty(property) {
|
|
2129
|
+
return tailwindThemePropertyPatterns.some((pattern) => pattern.test(property));
|
|
2130
|
+
}
|
|
2131
|
+
function isThemeScopeSelector(selector) {
|
|
2132
|
+
return selector.split(",").some((part) => {
|
|
2133
|
+
const normalized = part.trim();
|
|
2134
|
+
return normalized === ":root" || normalized === ":host";
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2137
|
+
function collectTailwindThemeProperties(root) {
|
|
2138
|
+
const values = /* @__PURE__ */ new Map();
|
|
2139
|
+
root.walkRules((rule) => {
|
|
2140
|
+
if (!isThemeScopeSelector(rule.selector)) return;
|
|
2141
|
+
rule.walkDecls((decl) => {
|
|
2142
|
+
if (isTailwindThemeProperty(decl.prop)) values.set(decl.prop, decl.value.trim());
|
|
2143
|
+
});
|
|
2144
|
+
});
|
|
2145
|
+
return values;
|
|
2146
|
+
}
|
|
2147
|
+
function resolveThemeValue(value, properties, resolving = /* @__PURE__ */ new Set()) {
|
|
2148
|
+
if (!value.includes("var(")) return value;
|
|
2149
|
+
const parsed = valueParser(value);
|
|
2150
|
+
parsed.walk((node) => {
|
|
2151
|
+
if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
|
|
2152
|
+
const property = node.nodes.find((child) => child.type === "word" && child.value.startsWith("--"))?.value;
|
|
2153
|
+
if (!property || resolving.has(property)) return;
|
|
2154
|
+
const propertyValue = properties.get(property);
|
|
2155
|
+
if (!propertyValue) return;
|
|
2156
|
+
const nextResolving = new Set(resolving);
|
|
2157
|
+
nextResolving.add(property);
|
|
2158
|
+
const resolved = resolveThemeValue(propertyValue, properties, nextResolving);
|
|
2159
|
+
const mutableNode = node;
|
|
2160
|
+
mutableNode.type = "word";
|
|
2161
|
+
mutableNode.value = resolved;
|
|
2162
|
+
delete mutableNode.nodes;
|
|
2163
|
+
});
|
|
2164
|
+
return parsed.toString();
|
|
2165
|
+
}
|
|
2166
|
+
function removeConsumedThemeProperties(root) {
|
|
2167
|
+
root.walkRules((rule) => {
|
|
2168
|
+
if (!isThemeScopeSelector(rule.selector)) return;
|
|
2169
|
+
rule.walkDecls((decl) => {
|
|
2170
|
+
if (isTailwindThemeProperty(decl.prop)) decl.remove();
|
|
2171
|
+
});
|
|
2172
|
+
if (rule.nodes.length === 0) rule.remove();
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
/** 将 Lynx 原生无法继承的 Tailwind theme 变量静态化。 */
|
|
2176
|
+
function transformLynxCssCompat(css) {
|
|
2177
|
+
try {
|
|
2178
|
+
const root = postcss$1.parse(css);
|
|
2179
|
+
const properties = collectTailwindThemeProperties(root);
|
|
2180
|
+
if (properties.size === 0) return css;
|
|
2181
|
+
root.walkDecls((decl) => {
|
|
2182
|
+
decl.value = resolveThemeValue(decl.value, properties);
|
|
2183
|
+
});
|
|
2184
|
+
removeConsumedThemeProperties(root);
|
|
2185
|
+
postcss$1([postcssCalc()]).process(root, { from: void 0 }).sync();
|
|
2186
|
+
return root.toString();
|
|
2187
|
+
} catch {
|
|
2188
|
+
return css;
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
//#endregion
|
|
2105
2192
|
//#region src/compat/mini-program-css/cascade-layers.ts
|
|
2106
2193
|
const LAYER_PATH_SEPARATOR = "";
|
|
2107
2194
|
const LAYER_INSERTION_ANCHOR = "__weapp_tailwindcss_layer_anchor__";
|
|
@@ -3248,8 +3335,7 @@ function transformWebCssSafeSelectors(css, options) {
|
|
|
3248
3335
|
}
|
|
3249
3336
|
}
|
|
3250
3337
|
//#endregion
|
|
3251
|
-
//#region src/css-macro/
|
|
3252
|
-
const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
|
|
3338
|
+
//#region src/css-macro/conditions.ts
|
|
3253
3339
|
const PLATFORM_ENV_KEYS$1 = [
|
|
3254
3340
|
"WEAPP_TW_TARGET",
|
|
3255
3341
|
"WEAPP_TAILWINDCSS_TARGET",
|
|
@@ -3261,9 +3347,6 @@ const PLATFORM_ENV_KEYS$1 = [
|
|
|
3261
3347
|
];
|
|
3262
3348
|
const CONDITIONAL_END_RE = /^\s*#endif\s*$/;
|
|
3263
3349
|
const CUSTOM_VARIANT_CONDITIONAL_FALLBACK_RE = /@custom-variant\b[\s\S]*?\/\*\s*#ifn?def\s[^*]*\*\/[\s\S]*?@slot\b[\s\S]*?\/\*\s*#endif\s*\*\//;
|
|
3264
|
-
function readEnvValue$1(key) {
|
|
3265
|
-
return typeof process === "undefined" ? void 0 : process.env[key];
|
|
3266
|
-
}
|
|
3267
3350
|
function normalizePlatformToken(value) {
|
|
3268
3351
|
return value?.trim().replaceAll("_", "-").toUpperCase() || void 0;
|
|
3269
3352
|
}
|
|
@@ -3271,7 +3354,7 @@ function resolveCssMacroPlatform(options) {
|
|
|
3271
3354
|
const explicit = normalizePlatformToken(options?.platform);
|
|
3272
3355
|
if (explicit) return explicit;
|
|
3273
3356
|
for (const key of PLATFORM_ENV_KEYS$1) {
|
|
3274
|
-
const value = normalizePlatformToken(
|
|
3357
|
+
const value = normalizePlatformToken(process.env[key]);
|
|
3275
3358
|
if (value) return value;
|
|
3276
3359
|
}
|
|
3277
3360
|
}
|
|
@@ -3341,45 +3424,84 @@ function quoteAtRuleParam(value) {
|
|
|
3341
3424
|
function hasSlotNode(nodes) {
|
|
3342
3425
|
return nodes.some((node) => node.type === "atrule" && node.name === "slot");
|
|
3343
3426
|
}
|
|
3427
|
+
function createConditionalAtRule(start, nodes) {
|
|
3428
|
+
const rule = postcss$1.atRule({
|
|
3429
|
+
name: start.directive === "ifndef" ? ifndefAtRule : ifdefAtRule,
|
|
3430
|
+
params: quoteAtRuleParam(start.expression)
|
|
3431
|
+
});
|
|
3432
|
+
rule.append(...nodes.map((node) => node.clone()));
|
|
3433
|
+
return rule;
|
|
3434
|
+
}
|
|
3435
|
+
function findConditionalEnd(nodes, index) {
|
|
3436
|
+
let depth = 1;
|
|
3437
|
+
for (let searchIndex = index + 1; searchIndex < nodes.length; searchIndex += 1) {
|
|
3438
|
+
const current = nodes[searchIndex];
|
|
3439
|
+
if (current?.type !== "comment") continue;
|
|
3440
|
+
if (parseConditionalStart(current.text)) depth += 1;
|
|
3441
|
+
else if (CONDITIONAL_END_RE.test(current.text) && --depth === 0) return searchIndex;
|
|
3442
|
+
}
|
|
3443
|
+
return -1;
|
|
3444
|
+
}
|
|
3344
3445
|
function rewriteCustomVariantConditionalComments(root) {
|
|
3345
3446
|
let changed = false;
|
|
3346
|
-
|
|
3347
|
-
const nodes = [...
|
|
3447
|
+
const transformContainer = (container, variant) => {
|
|
3448
|
+
const nodes = [...container.nodes ?? []];
|
|
3348
3449
|
for (let index = 0; index < nodes.length; index += 1) {
|
|
3349
3450
|
const node = nodes[index];
|
|
3350
|
-
|
|
3351
|
-
const start = parseConditionalStart(node.text);
|
|
3451
|
+
const start = node?.type === "comment" ? parseConditionalStart(node.text) : void 0;
|
|
3352
3452
|
if (!start) continue;
|
|
3353
|
-
|
|
3354
|
-
let endIndex = -1;
|
|
3355
|
-
for (let searchIndex = index + 1; searchIndex < nodes.length; searchIndex += 1) {
|
|
3356
|
-
const current = nodes[searchIndex];
|
|
3357
|
-
if (current?.type !== "comment") continue;
|
|
3358
|
-
if (parseConditionalStart(current.text)) {
|
|
3359
|
-
depth += 1;
|
|
3360
|
-
continue;
|
|
3361
|
-
}
|
|
3362
|
-
if (CONDITIONAL_END_RE.test(current.text)) {
|
|
3363
|
-
depth -= 1;
|
|
3364
|
-
if (depth === 0) {
|
|
3365
|
-
endIndex = searchIndex;
|
|
3366
|
-
break;
|
|
3367
|
-
}
|
|
3368
|
-
}
|
|
3369
|
-
}
|
|
3453
|
+
const endIndex = findConditionalEnd(nodes, index);
|
|
3370
3454
|
if (endIndex < 0) continue;
|
|
3371
3455
|
const conditionalNodes = nodes.slice(index + 1, endIndex);
|
|
3372
3456
|
if (!hasSlotNode(conditionalNodes)) continue;
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3457
|
+
if (container !== variant) {
|
|
3458
|
+
node.remove();
|
|
3459
|
+
nodes[endIndex]?.remove();
|
|
3460
|
+
const variantNodes = [...variant.nodes ?? []];
|
|
3461
|
+
variant.removeAll();
|
|
3462
|
+
variant.append(createConditionalAtRule(start, variantNodes));
|
|
3463
|
+
changed = true;
|
|
3464
|
+
return true;
|
|
3465
|
+
}
|
|
3466
|
+
node.replaceWith(createConditionalAtRule(start, conditionalNodes));
|
|
3379
3467
|
for (const removedNode of nodes.slice(index + 1, endIndex + 1)) removedNode.remove();
|
|
3380
3468
|
changed = true;
|
|
3381
3469
|
}
|
|
3382
|
-
|
|
3470
|
+
for (const node of [...container.nodes ?? []]) if ("nodes" in node && node.nodes && transformContainer(node, variant)) return true;
|
|
3471
|
+
return false;
|
|
3472
|
+
};
|
|
3473
|
+
const variants = [];
|
|
3474
|
+
root.walkAtRules("custom-variant", (rule) => variants.push(rule));
|
|
3475
|
+
for (const variant of variants) transformContainer(variant, variant);
|
|
3476
|
+
return changed;
|
|
3477
|
+
}
|
|
3478
|
+
function rewriteOuterCustomVariantConditionalComments(root) {
|
|
3479
|
+
let changed = false;
|
|
3480
|
+
const transformContainer = (container) => {
|
|
3481
|
+
const nodes = [...container.nodes ?? []];
|
|
3482
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
3483
|
+
const node = nodes[index];
|
|
3484
|
+
const start = node?.type === "comment" ? parseConditionalStart(node.text) : void 0;
|
|
3485
|
+
if (!start) continue;
|
|
3486
|
+
const endIndex = findConditionalEnd(nodes, index);
|
|
3487
|
+
if (endIndex < 0) continue;
|
|
3488
|
+
const conditionalNodes = nodes.slice(index + 1, endIndex);
|
|
3489
|
+
const customVariants = conditionalNodes.filter((current) => current.type === "atrule" && current.name === "custom-variant");
|
|
3490
|
+
if (customVariants.length === 0 || customVariants.some((variant) => !variant.nodes?.length)) continue;
|
|
3491
|
+
for (const variant of customVariants) {
|
|
3492
|
+
const variantNodes = [...variant.nodes ?? []];
|
|
3493
|
+
variant.removeAll();
|
|
3494
|
+
variant.append(createConditionalAtRule(start, variantNodes));
|
|
3495
|
+
}
|
|
3496
|
+
if (conditionalNodes.every((current) => current.type === "comment" || current.type === "atrule" && current.name === "custom-variant")) {
|
|
3497
|
+
node.remove();
|
|
3498
|
+
for (const removedNode of nodes.slice(index + 1, endIndex + 1)) if (removedNode.type === "comment") removedNode.remove();
|
|
3499
|
+
}
|
|
3500
|
+
changed = true;
|
|
3501
|
+
}
|
|
3502
|
+
for (const node of [...container.nodes ?? []]) if ("nodes" in node && node.nodes) transformContainer(node);
|
|
3503
|
+
};
|
|
3504
|
+
transformContainer(root);
|
|
3383
3505
|
return changed;
|
|
3384
3506
|
}
|
|
3385
3507
|
function compileCssMacroConditionalComments(css, options) {
|
|
@@ -3405,11 +3527,8 @@ function compileCssMacroConditionalComments(css, options) {
|
|
|
3405
3527
|
continue;
|
|
3406
3528
|
}
|
|
3407
3529
|
}
|
|
3408
|
-
if (getActiveConditionalValue(stack) === false)
|
|
3409
|
-
|
|
3410
|
-
continue;
|
|
3411
|
-
}
|
|
3412
|
-
if ("nodes" in node && node.nodes) transformContainer(node);
|
|
3530
|
+
if (getActiveConditionalValue(stack) === false) node.remove();
|
|
3531
|
+
else if ("nodes" in node && node.nodes) transformContainer(node);
|
|
3413
3532
|
}
|
|
3414
3533
|
};
|
|
3415
3534
|
transformContainer(root);
|
|
@@ -3418,28 +3537,15 @@ function compileCssMacroConditionalComments(css, options) {
|
|
|
3418
3537
|
return css;
|
|
3419
3538
|
}
|
|
3420
3539
|
}
|
|
3421
|
-
function
|
|
3422
|
-
|
|
3423
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
3424
|
-
if (quoted) return quoted[2];
|
|
3425
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
3426
|
-
return url?.[2] ?? url?.[3];
|
|
3427
|
-
}
|
|
3428
|
-
function isCssMacroPluginRequest(request) {
|
|
3429
|
-
if (request === "weapp-tailwindcss/css-macro") return true;
|
|
3430
|
-
if (!request?.includes("css-macro")) return false;
|
|
3431
|
-
return path.basename(request).startsWith("css-macro");
|
|
3432
|
-
}
|
|
3433
|
-
function hasCssMacroTailwindV4Directive(css) {
|
|
3434
|
-
if (!css?.includes("css-macro")) return false;
|
|
3540
|
+
function transformCssMacroTailwindV4Source(css) {
|
|
3541
|
+
if (!hasCssMacroTailwindV4CustomVariantConditionalComments(css)) return css;
|
|
3435
3542
|
try {
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
return found;
|
|
3543
|
+
const root = postcss$1.parse(css);
|
|
3544
|
+
const outerChanged = rewriteOuterCustomVariantConditionalComments(root);
|
|
3545
|
+
const innerChanged = rewriteCustomVariantConditionalComments(root);
|
|
3546
|
+
return outerChanged || innerChanged ? root.toString() : css;
|
|
3441
3547
|
} catch {
|
|
3442
|
-
return
|
|
3548
|
+
return css;
|
|
3443
3549
|
}
|
|
3444
3550
|
}
|
|
3445
3551
|
function hasCssMacroTailwindV4CustomVariantConditionalComments(css) {
|
|
@@ -3447,18 +3553,31 @@ function hasCssMacroTailwindV4CustomVariantConditionalComments(css) {
|
|
|
3447
3553
|
try {
|
|
3448
3554
|
const root = postcss$1.parse(css);
|
|
3449
3555
|
let found = false;
|
|
3450
|
-
|
|
3451
|
-
const nodes = [...
|
|
3556
|
+
const hasConditionalSlot = (container) => {
|
|
3557
|
+
const nodes = [...container.nodes ?? []];
|
|
3452
3558
|
for (let index = 0; index < nodes.length; index += 1) {
|
|
3453
3559
|
const node = nodes[index];
|
|
3454
3560
|
if (node?.type !== "comment" || !parseConditionalStart(node.text)) continue;
|
|
3455
3561
|
const tail = nodes.slice(index + 1);
|
|
3456
|
-
if (tail.some((current) => current.type === "comment" && CONDITIONAL_END_RE.test(current.text)) && hasSlotNode(tail))
|
|
3457
|
-
found = true;
|
|
3458
|
-
return false;
|
|
3459
|
-
}
|
|
3562
|
+
if (tail.some((current) => current.type === "comment" && CONDITIONAL_END_RE.test(current.text)) && hasSlotNode(tail)) return true;
|
|
3460
3563
|
}
|
|
3564
|
+
return nodes.some((node) => "nodes" in node && node.nodes && hasConditionalSlot(node));
|
|
3565
|
+
};
|
|
3566
|
+
root.walkAtRules("custom-variant", (rule) => {
|
|
3567
|
+
if (hasConditionalSlot(rule)) found = true;
|
|
3461
3568
|
});
|
|
3569
|
+
const scanOuterConditional = (container) => {
|
|
3570
|
+
const nodes = [...container.nodes ?? []];
|
|
3571
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
3572
|
+
const node = nodes[index];
|
|
3573
|
+
if (node?.type !== "comment" || !parseConditionalStart(node.text)) continue;
|
|
3574
|
+
const endIndex = findConditionalEnd(nodes, index);
|
|
3575
|
+
if (endIndex < 0) continue;
|
|
3576
|
+
if (nodes.slice(index + 1, endIndex).some((current) => current.type === "atrule" && current.name === "custom-variant")) return true;
|
|
3577
|
+
}
|
|
3578
|
+
return nodes.some((node) => "nodes" in node && node.nodes && scanOuterConditional(node));
|
|
3579
|
+
};
|
|
3580
|
+
found ||= scanOuterConditional(root);
|
|
3462
3581
|
return found;
|
|
3463
3582
|
} catch {
|
|
3464
3583
|
return CUSTOM_VARIANT_CONDITIONAL_FALLBACK_RE.test(css);
|
|
@@ -3469,28 +3588,42 @@ function hasCssMacroTailwindV4InternalAtRules(css) {
|
|
|
3469
3588
|
try {
|
|
3470
3589
|
let found = false;
|
|
3471
3590
|
postcss$1.parse(css).walkAtRules((rule) => {
|
|
3472
|
-
if (rule.name === "weapp-tw-ifdef" || rule.name === "weapp-tw-ifndef")
|
|
3473
|
-
found = true;
|
|
3474
|
-
return false;
|
|
3475
|
-
}
|
|
3591
|
+
if (rule.name === "weapp-tw-ifdef" || rule.name === "weapp-tw-ifndef") found = true;
|
|
3476
3592
|
});
|
|
3477
3593
|
return found;
|
|
3478
3594
|
} catch {
|
|
3479
3595
|
return /@weapp-tw-ifn?def\b/.test(css);
|
|
3480
3596
|
}
|
|
3481
3597
|
}
|
|
3482
|
-
|
|
3483
|
-
|
|
3598
|
+
//#endregion
|
|
3599
|
+
//#region src/css-macro/auto.ts
|
|
3600
|
+
const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
|
|
3601
|
+
function parseCssPluginRequest(params) {
|
|
3602
|
+
const value = params.trim();
|
|
3603
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
3604
|
+
if (quoted) return quoted[2];
|
|
3605
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
3606
|
+
return url?.[2] ?? url?.[3];
|
|
3484
3607
|
}
|
|
3485
|
-
function
|
|
3486
|
-
if (
|
|
3608
|
+
function isCssMacroPluginRequest(request) {
|
|
3609
|
+
if (request === "weapp-tailwindcss/css-macro") return true;
|
|
3610
|
+
return Boolean(request?.includes("css-macro") && path.basename(request).startsWith("css-macro"));
|
|
3611
|
+
}
|
|
3612
|
+
function hasCssMacroTailwindV4Directive(css) {
|
|
3613
|
+
if (!css?.includes("css-macro")) return false;
|
|
3487
3614
|
try {
|
|
3488
|
-
|
|
3489
|
-
|
|
3615
|
+
let found = false;
|
|
3616
|
+
postcss$1.parse(css).walkAtRules("plugin", (rule) => {
|
|
3617
|
+
if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
|
|
3618
|
+
});
|
|
3619
|
+
return found;
|
|
3490
3620
|
} catch {
|
|
3491
|
-
return css;
|
|
3621
|
+
return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
|
|
3492
3622
|
}
|
|
3493
3623
|
}
|
|
3624
|
+
function hasCssMacroTailwindV4Source(css) {
|
|
3625
|
+
return hasCssMacroTailwindV4Directive(css) || hasCssMacroTailwindV4CustomVariantConditionalComments(css) || hasCssMacroTailwindV4InternalAtRules(css);
|
|
3626
|
+
}
|
|
3494
3627
|
function isCssMacroPostcssPlugin(plugin) {
|
|
3495
3628
|
if (plugin === creator) return true;
|
|
3496
3629
|
return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
|
|
@@ -3501,8 +3634,7 @@ function withCssMacroPostcssPlugins(plugins) {
|
|
|
3501
3634
|
if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
|
|
3502
3635
|
if (typeof plugins === "object") {
|
|
3503
3636
|
const values = Object.values(plugins).filter(Boolean);
|
|
3504
|
-
|
|
3505
|
-
return [...values, macroPlugin];
|
|
3637
|
+
return values.some(isCssMacroPostcssPlugin) ? values : [...values, macroPlugin];
|
|
3506
3638
|
}
|
|
3507
3639
|
return [macroPlugin];
|
|
3508
3640
|
}
|
|
@@ -4168,7 +4300,10 @@ function isMiniProgramGeneratorTarget(target) {
|
|
|
4168
4300
|
return target !== "web";
|
|
4169
4301
|
}
|
|
4170
4302
|
function finalizeGeneratedCss(css, target, styleOptions, webCompat) {
|
|
4171
|
-
if (target === "web")
|
|
4303
|
+
if (target === "web") {
|
|
4304
|
+
const webCss = transformWebCssCompat(css, webCompat);
|
|
4305
|
+
return (styleOptions?.cssOptions?.platform ?? styleOptions?.platform) === "lynx" ? transformLynxCssCompat(webCss) : webCss;
|
|
4306
|
+
}
|
|
4172
4307
|
if (!isMiniProgramGeneratorTarget(target)) return css;
|
|
4173
4308
|
return finalizeMiniProgramCss(css, {
|
|
4174
4309
|
cssSelectorReplacement: styleOptions?.cssOptions?.cssSelectorReplacement ?? styleOptions?.cssSelectorReplacement,
|
|
@@ -4611,6 +4746,7 @@ function getDefaultOptions(options) {
|
|
|
4611
4746
|
autoprefixer: { add: false }
|
|
4612
4747
|
},
|
|
4613
4748
|
cssRemoveProperty: true,
|
|
4749
|
+
cssRemoveFocusPseudoClass: true,
|
|
4614
4750
|
uniAppXUnsupported: "warn",
|
|
4615
4751
|
cssSelectorReplacement: {
|
|
4616
4752
|
root: [
|
|
@@ -4658,7 +4794,9 @@ const CSS_OPTION_KEYS = [
|
|
|
4658
4794
|
"unitsToPx",
|
|
4659
4795
|
"unitConversion",
|
|
4660
4796
|
"platform",
|
|
4797
|
+
"cssRemoveActivePseudoClass",
|
|
4661
4798
|
"cssRemoveHoverPseudoClass",
|
|
4799
|
+
"cssRemoveFocusPseudoClass",
|
|
4662
4800
|
"cssRemoveProperty",
|
|
4663
4801
|
"cssCalc",
|
|
4664
4802
|
"atRules",
|
|
@@ -4668,7 +4806,9 @@ function getSimpleOverrideCacheKey(options) {
|
|
|
4668
4806
|
let isMainChunk = SIMPLE_OVERRIDE_UNSET;
|
|
4669
4807
|
let majorVersion = SIMPLE_OVERRIDE_UNSET;
|
|
4670
4808
|
let cssRemoveProperty = SIMPLE_OVERRIDE_UNSET;
|
|
4809
|
+
let cssRemoveActivePseudoClass = SIMPLE_OVERRIDE_UNSET;
|
|
4671
4810
|
let cssRemoveHoverPseudoClass = SIMPLE_OVERRIDE_UNSET;
|
|
4811
|
+
let cssRemoveFocusPseudoClass = SIMPLE_OVERRIDE_UNSET;
|
|
4672
4812
|
let uniAppX = SIMPLE_OVERRIDE_UNSET;
|
|
4673
4813
|
let cssPreflightRange = SIMPLE_OVERRIDE_UNSET;
|
|
4674
4814
|
let injectAdditionalCssVarScope = SIMPLE_OVERRIDE_UNSET;
|
|
@@ -4700,6 +4840,14 @@ function getSimpleOverrideCacheKey(options) {
|
|
|
4700
4840
|
if (typeof value !== "boolean") return;
|
|
4701
4841
|
cssRemoveHoverPseudoClass = value ? "1" : "0";
|
|
4702
4842
|
break;
|
|
4843
|
+
case "cssRemoveActivePseudoClass":
|
|
4844
|
+
if (typeof value !== "boolean") return;
|
|
4845
|
+
cssRemoveActivePseudoClass = value ? "1" : "0";
|
|
4846
|
+
break;
|
|
4847
|
+
case "cssRemoveFocusPseudoClass":
|
|
4848
|
+
if (typeof value !== "boolean") return;
|
|
4849
|
+
cssRemoveFocusPseudoClass = value ? "1" : "0";
|
|
4850
|
+
break;
|
|
4703
4851
|
case "uniAppX":
|
|
4704
4852
|
if (typeof value !== "boolean") return;
|
|
4705
4853
|
uniAppX = value ? "1" : "0";
|
|
@@ -4756,7 +4904,9 @@ function getSimpleOverrideCacheKey(options) {
|
|
|
4756
4904
|
isMainChunk,
|
|
4757
4905
|
majorVersion,
|
|
4758
4906
|
cssRemoveProperty,
|
|
4907
|
+
cssRemoveActivePseudoClass,
|
|
4759
4908
|
cssRemoveHoverPseudoClass,
|
|
4909
|
+
cssRemoveFocusPseudoClass,
|
|
4760
4910
|
uniAppX,
|
|
4761
4911
|
cssPreflightRange,
|
|
4762
4912
|
injectAdditionalCssVarScope,
|
|
@@ -5090,7 +5240,8 @@ const defaultRemTransformOptions = {
|
|
|
5090
5240
|
function getRemTransformPlugin(options) {
|
|
5091
5241
|
if (!options.rem2rpx) return null;
|
|
5092
5242
|
if (options.rem2rpx === true) return postcssRem2rpx(defaultRemTransformOptions);
|
|
5093
|
-
|
|
5243
|
+
const merged = defuOverrideArray(options.rem2rpx, defaultStage);
|
|
5244
|
+
return postcssRem2rpx(merged);
|
|
5094
5245
|
}
|
|
5095
5246
|
//#endregion
|
|
5096
5247
|
//#region src/plugins/getUnitConversionPlugin.ts
|
|
@@ -5330,9 +5481,10 @@ function getFallbackRemove(_rule, options) {
|
|
|
5330
5481
|
if (idx === 0 && (selector.type === "id" || selector.type === "class" || selector.type === "attribute")) maybeImportantId = true;
|
|
5331
5482
|
if (selector.type === "universal") selector.parent?.remove();
|
|
5332
5483
|
else if (selector.type === "pseudo") {
|
|
5333
|
-
if (selector.value === ":is")
|
|
5334
|
-
|
|
5335
|
-
|
|
5484
|
+
if (selector.value === ":is") {
|
|
5485
|
+
if (maybeImportantId && selector.nodes[0]?.type === "selector") selector.replaceWith(selector.nodes[0]);
|
|
5486
|
+
else selector.parent?.remove();
|
|
5487
|
+
} else if (selector.value === ":not") {
|
|
5336
5488
|
for (const x of selector.nodes) if (x.nodes.length === 1 && x.nodes[0].type === "id" && x.nodes[0].value === "#") x.nodes = [selectorParser.tag({ value: "#n" })];
|
|
5337
5489
|
}
|
|
5338
5490
|
} else if (selector.type === "attribute") {
|
|
@@ -5372,14 +5524,16 @@ function getFallbackRemove(_rule, options) {
|
|
|
5372
5524
|
} finally {
|
|
5373
5525
|
currentRule = void 0;
|
|
5374
5526
|
}
|
|
5375
|
-
if (transformOptions === FALLBACK_TRANSFORM_OPTIONS)
|
|
5376
|
-
targetRule.
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5527
|
+
if (transformOptions === FALLBACK_TRANSFORM_OPTIONS) {
|
|
5528
|
+
if (targetRule.parent == null) {
|
|
5529
|
+
targetRule.selector = "";
|
|
5530
|
+
writeSelectorCache(sourceSelector, { action: "remove" });
|
|
5531
|
+
} else if (targetRule.selector === sourceSelector) writeSelectorCache(sourceSelector, { action: "keep" });
|
|
5532
|
+
else writeSelectorCache(sourceSelector, {
|
|
5533
|
+
action: "update",
|
|
5534
|
+
selector: targetRule.selector
|
|
5535
|
+
});
|
|
5536
|
+
}
|
|
5383
5537
|
};
|
|
5384
5538
|
parser.transformSync = ((input, opts) => {
|
|
5385
5539
|
const transformOptions = opts ? normalizeTransformOptions(opts) : FALLBACK_TRANSFORM_OPTIONS;
|
|
@@ -5397,6 +5551,47 @@ function getFallbackRemove(_rule, options) {
|
|
|
5397
5551
|
return entry.parser;
|
|
5398
5552
|
}
|
|
5399
5553
|
//#endregion
|
|
5554
|
+
//#region src/selectorParser/pseudo.ts
|
|
5555
|
+
function selectorContainsPseudoClass(selector, pseudoClasses) {
|
|
5556
|
+
if (pseudoClasses.length === 0) return false;
|
|
5557
|
+
let attributeDepth = 0;
|
|
5558
|
+
let quote;
|
|
5559
|
+
let escaped = false;
|
|
5560
|
+
for (let index = 0; index < selector.length; index += 1) {
|
|
5561
|
+
const character = selector[index];
|
|
5562
|
+
if (escaped) {
|
|
5563
|
+
escaped = false;
|
|
5564
|
+
continue;
|
|
5565
|
+
}
|
|
5566
|
+
if (character === "\\") {
|
|
5567
|
+
escaped = true;
|
|
5568
|
+
continue;
|
|
5569
|
+
}
|
|
5570
|
+
if (quote) {
|
|
5571
|
+
if (character === quote) quote = void 0;
|
|
5572
|
+
continue;
|
|
5573
|
+
}
|
|
5574
|
+
if (character === "\"" || character === "'") {
|
|
5575
|
+
quote = character;
|
|
5576
|
+
continue;
|
|
5577
|
+
}
|
|
5578
|
+
if (character === "[") {
|
|
5579
|
+
attributeDepth += 1;
|
|
5580
|
+
continue;
|
|
5581
|
+
}
|
|
5582
|
+
if (character === "]") {
|
|
5583
|
+
attributeDepth = Math.max(0, attributeDepth - 1);
|
|
5584
|
+
continue;
|
|
5585
|
+
}
|
|
5586
|
+
if (attributeDepth > 0 || character !== ":") continue;
|
|
5587
|
+
let end = index + 1;
|
|
5588
|
+
while (end < selector.length && /[\w-]/.test(selector[end] ?? "")) end += 1;
|
|
5589
|
+
if (pseudoClasses.includes(selector.slice(index, end))) return true;
|
|
5590
|
+
index = end - 1;
|
|
5591
|
+
}
|
|
5592
|
+
return false;
|
|
5593
|
+
}
|
|
5594
|
+
//#endregion
|
|
5400
5595
|
//#region src/utils/decl-order.ts
|
|
5401
5596
|
/**
|
|
5402
5597
|
* 将同一规则内的声明重排,使字面量优先,带变量的声明靠后,保持各自相对顺序。
|
|
@@ -5506,6 +5701,53 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
5506
5701
|
for (const declarations of grouped.values()) dedupeSpacingGroup(rule, declarations);
|
|
5507
5702
|
}
|
|
5508
5703
|
//#endregion
|
|
5704
|
+
//#region src/selectorParser/rule-transformer/unsupported-pseudos.ts
|
|
5705
|
+
const UNSUPPORTED_MINI_PROGRAM_PSEUDO_CLASS_SET = /* @__PURE__ */ new Set([
|
|
5706
|
+
":autofill",
|
|
5707
|
+
":checked",
|
|
5708
|
+
":default",
|
|
5709
|
+
":disabled",
|
|
5710
|
+
":enabled",
|
|
5711
|
+
":focus-visible",
|
|
5712
|
+
":focus-within",
|
|
5713
|
+
":fullscreen",
|
|
5714
|
+
":indeterminate",
|
|
5715
|
+
":in-range",
|
|
5716
|
+
":invalid",
|
|
5717
|
+
":modal",
|
|
5718
|
+
":open",
|
|
5719
|
+
":optional",
|
|
5720
|
+
":out-of-range",
|
|
5721
|
+
":placeholder-shown",
|
|
5722
|
+
":read-only",
|
|
5723
|
+
":read-write",
|
|
5724
|
+
":required",
|
|
5725
|
+
":target",
|
|
5726
|
+
":valid",
|
|
5727
|
+
":visited"
|
|
5728
|
+
]);
|
|
5729
|
+
const unsupportedPseudoClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
5730
|
+
function getUnsupportedPseudoClassSet(options) {
|
|
5731
|
+
const cached = unsupportedPseudoClassSetCache.get(options);
|
|
5732
|
+
if (cached) return cached;
|
|
5733
|
+
const pseudoClasses = new Set(UNSUPPORTED_MINI_PROGRAM_PSEUDO_CLASS_SET);
|
|
5734
|
+
if (options.cssRemoveHoverPseudoClass) pseudoClasses.add(":hover");
|
|
5735
|
+
if (options.cssRemoveActivePseudoClass) pseudoClasses.add(":active");
|
|
5736
|
+
if (options.cssRemoveFocusPseudoClass) pseudoClasses.add(":focus");
|
|
5737
|
+
unsupportedPseudoClassSetCache.set(options, pseudoClasses);
|
|
5738
|
+
return pseudoClasses;
|
|
5739
|
+
}
|
|
5740
|
+
function findRootSelector(node) {
|
|
5741
|
+
let current = node;
|
|
5742
|
+
while (current.parent && current.parent.type !== "root") current = current.parent;
|
|
5743
|
+
return current.type === "selector" ? current : void 0;
|
|
5744
|
+
}
|
|
5745
|
+
function removeUnsupportedPseudoSelector(node, options, unsupportedPseudoClasses = getUnsupportedPseudoClassSet(options)) {
|
|
5746
|
+
if (node.type !== "pseudo" || !unsupportedPseudoClasses.has(node.value)) return false;
|
|
5747
|
+
findRootSelector(node)?.remove();
|
|
5748
|
+
return true;
|
|
5749
|
+
}
|
|
5750
|
+
//#endregion
|
|
5509
5751
|
//#region src/selectorParser/rule-transformer/pseudos.ts
|
|
5510
5752
|
const RTL_LANGUAGE_ANY_PSEUDO_SET = /* @__PURE__ */ new Set([
|
|
5511
5753
|
":-moz-any",
|
|
@@ -5639,6 +5881,12 @@ function transformExpandedSelectorNodes(selector, context) {
|
|
|
5639
5881
|
else if (node.type === "universal" && context.universalReplacement) node.value = context.universalReplacement;
|
|
5640
5882
|
});
|
|
5641
5883
|
}
|
|
5884
|
+
function transformExpandedUniversalNodes(selector, context) {
|
|
5885
|
+
if (!context.universalReplacement) return;
|
|
5886
|
+
selector.walk((node) => {
|
|
5887
|
+
if (node.type === "universal") node.value = context.universalReplacement;
|
|
5888
|
+
});
|
|
5889
|
+
}
|
|
5642
5890
|
function appendExpandedWhereSelectors(parent, index, branches, context) {
|
|
5643
5891
|
const root = parent.parent;
|
|
5644
5892
|
if (!root) return false;
|
|
@@ -5659,7 +5907,10 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
5659
5907
|
for (const branch of branches) if (transformSpacingSelector(branch.nodes, context.options)) context.requiresSpacingNormalization = true;
|
|
5660
5908
|
if (branches.length > 1 && appendExpandedWhereSelectors(parent, index, branches, context)) return;
|
|
5661
5909
|
const targetSelector = branches[0];
|
|
5662
|
-
if (targetSelector)
|
|
5910
|
+
if (targetSelector) {
|
|
5911
|
+
transformExpandedUniversalNodes(targetSelector, context);
|
|
5912
|
+
node.replaceWith(...targetSelector.nodes.map((item) => item.clone()));
|
|
5913
|
+
}
|
|
5663
5914
|
if (parent.type === "selector" && parent.length === 0) parent.remove();
|
|
5664
5915
|
}
|
|
5665
5916
|
function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
@@ -5668,6 +5919,7 @@ function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
|
5668
5919
|
}
|
|
5669
5920
|
function handlePseudoNode(node, index, context, parent) {
|
|
5670
5921
|
if (node.type !== "pseudo") return;
|
|
5922
|
+
if (removeUnsupportedPseudoSelector(node, context.options, context.unsupportedPseudoClasses ?? getUnsupportedPseudoClassSet(context.options))) return;
|
|
5671
5923
|
if (isRtlLanguageAnyPseudo(node)) {
|
|
5672
5924
|
stripUnsupportedRtlLanguagePseudo(node);
|
|
5673
5925
|
return;
|
|
@@ -5693,10 +5945,6 @@ function handleUniversalNode(node, context) {
|
|
|
5693
5945
|
if (node.type !== "universal") return;
|
|
5694
5946
|
if (context.universalReplacement) node.value = context.universalReplacement;
|
|
5695
5947
|
}
|
|
5696
|
-
function shouldRemoveHoverSelector(selector, options) {
|
|
5697
|
-
if (!options.cssRemoveHoverPseudoClass) return false;
|
|
5698
|
-
return selector.nodes.some((node) => node.type === "pseudo" && node.value === ":hover");
|
|
5699
|
-
}
|
|
5700
5948
|
function isHiddenOrTemplateNotPseudo(node) {
|
|
5701
5949
|
if (!node || node.type !== "pseudo" || node.value !== ":not") return false;
|
|
5702
5950
|
const selector = node.first;
|
|
@@ -5727,8 +5975,10 @@ function handleSelectorNode(selector, context) {
|
|
|
5727
5975
|
selector.remove();
|
|
5728
5976
|
return;
|
|
5729
5977
|
}
|
|
5730
|
-
|
|
5731
|
-
|
|
5978
|
+
const unsupportedPseudoClasses = context.unsupportedPseudoClasses ?? getUnsupportedPseudoClassSet(context.options);
|
|
5979
|
+
const unsupportedPseudo = selector.nodes.find((node) => node.type === "pseudo" && unsupportedPseudoClasses.has(node.value));
|
|
5980
|
+
if (unsupportedPseudo) {
|
|
5981
|
+
removeUnsupportedPseudoSelector(unsupportedPseudo, context.options, unsupportedPseudoClasses);
|
|
5732
5982
|
return;
|
|
5733
5983
|
}
|
|
5734
5984
|
if (transformSpacingSelector(selector.nodes, context.options)) context.requiresSpacingNormalization = true;
|
|
@@ -5763,10 +6013,7 @@ function transformSelectors(selectors, context) {
|
|
|
5763
6013
|
handleCombinatorNode(node, index, context);
|
|
5764
6014
|
break;
|
|
5765
6015
|
case "tag":
|
|
5766
|
-
case "attribute":
|
|
5767
|
-
handleTagOrAttribute(node, context);
|
|
5768
|
-
break;
|
|
5769
|
-
default: break;
|
|
6016
|
+
case "attribute": handleTagOrAttribute(node, context);
|
|
5770
6017
|
}
|
|
5771
6018
|
});
|
|
5772
6019
|
if (context.requiresSpacingNormalization) normalizeSpacingDeclarations(context.rule);
|
|
@@ -5786,6 +6033,7 @@ function createRuleTransformer(options) {
|
|
|
5786
6033
|
const rootReplacement = options.cssSelectorReplacement?.root ? composeIsPseudo(options.cssSelectorReplacement.root) : void 0;
|
|
5787
6034
|
const universalReplacement = options.cssSelectorReplacement?.universal ? composeIsPseudo(options.cssSelectorReplacement.universal) : void 0;
|
|
5788
6035
|
const selectorReplacerOptions = options.escapeMap ? { escapeMap: options.escapeMap } : void 0;
|
|
6036
|
+
const unsupportedPseudoClasses = getUnsupportedPseudoClassSet(options);
|
|
5789
6037
|
function writeSelectorResultCache(selector, result) {
|
|
5790
6038
|
if (selectorResultCache.size >= selectorResultCacheLimit) selectorResultCache.clear();
|
|
5791
6039
|
selectorResultCache.set(selector, result);
|
|
@@ -5814,7 +6062,8 @@ function createRuleTransformer(options) {
|
|
|
5814
6062
|
rule,
|
|
5815
6063
|
rootReplacement,
|
|
5816
6064
|
universalReplacement,
|
|
5817
|
-
selectorReplacerOptions
|
|
6065
|
+
selectorReplacerOptions,
|
|
6066
|
+
unsupportedPseudoClasses
|
|
5818
6067
|
};
|
|
5819
6068
|
let wasRemoved = false;
|
|
5820
6069
|
let requiresSpacingNormalization = false;
|
|
@@ -6459,9 +6708,10 @@ const postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
6459
6708
|
ruleTransformSync(rule, opts);
|
|
6460
6709
|
},
|
|
6461
6710
|
AtRule(atRule) {
|
|
6462
|
-
if (isAtMediaHover(atRule))
|
|
6463
|
-
|
|
6464
|
-
|
|
6711
|
+
if (isAtMediaHover(atRule)) {
|
|
6712
|
+
if (atRule.nodes) atRule.replaceWith(atRule.nodes);
|
|
6713
|
+
else atRule.remove();
|
|
6714
|
+
} else if (atRule.name === "supports") {
|
|
6465
6715
|
if (COLOR_MIX_RE.test(atRule.params)) removeAtRuleAndEmptyAncestors(atRule);
|
|
6466
6716
|
else if (isTailwindcssV4LinearGradientSupports(atRule)) removeAtRuleAndEmptyAncestors(atRule);
|
|
6467
6717
|
else if (isTailwindcssV4DisplayP3Supports(atRule)) removeAtRuleAndEmptyAncestors(atRule);
|
|
@@ -6729,7 +6979,8 @@ var StyleProcessorCache = class {
|
|
|
6729
6979
|
const compositeKey = this.createCompositeCacheKey(optionsKey, signal);
|
|
6730
6980
|
let processor = this.processorCacheByKey.get(compositeKey);
|
|
6731
6981
|
if (!processor) {
|
|
6732
|
-
|
|
6982
|
+
const pipeline = this.getPipeline(options, signal);
|
|
6983
|
+
processor = postcss$1(pipeline.plugins);
|
|
6733
6984
|
this.processorCacheByKey.set(compositeKey, processor);
|
|
6734
6985
|
}
|
|
6735
6986
|
return processor;
|
|
@@ -7343,4 +7594,4 @@ function mergeMiniProgramThemeScopeRuleDeclarations(baseCss, css) {
|
|
|
7343
7594
|
}
|
|
7344
7595
|
}
|
|
7345
7596
|
//#endregion
|
|
7346
|
-
export { CSS_MACRO_POSTCSS_PLUGIN_NAME, CSS_MACRO_STYLE_OPTIONS_MARKER, FULL_SOURCE_SCAN_EXTENSIONS, FULL_SOURCE_SCAN_EXTENSION_RE, FULL_SOURCE_SCAN_PATTERN, analyzeTailwindCssDirectives, cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, collectApplyOnlyCssSelectors, collectApplyOnlyCssSelectorsRoot, collectCssImportRequestsRoot, collectCssInlineSourceCandidates, compileCssMacroConditionalComments, consumeCascadeLayers, containsCssAfterMinify, convertTailwindcssRpxDeclarationToRem, convertTailwindcssRpxDeclarationsToRem, convertTailwindcssRpxValueToRem, createCssSourceOrderAppend, createFallbackPlaceholderReplacer, createInjectPreflight, createPostcssStyleTargetProfile, createSourceScanPattern, createStyleHandler, createStylePipeline, createTailwindSourceEntryMatcher, createWeappTailwindcssPostcssPlugin, creator as cssMacroPostcssPlugin, dedupeCoveredCssRules, expandInlineSourceCandidatePattern, expandTailwindSourceEntries, filterApplyOnlyGeneratedCss, filterApplyOnlyGeneratedCssRoot, filterExistingCssRules, finalizeMiniProgramCss, getPostcssPluginName, hasCssMacroStyleOptions, hasCssMacroTailwindV4CustomVariantConditionalComments, hasCssMacroTailwindV4Directive, hasCssMacroTailwindV4InternalAtRules, hasCssMacroTailwindV4Source, hasMiniProgramCssSpecificityPlaceholders, hoistTailwindPreflightBase, internalCssSelectorReplacer, isFileExcludedByTailwindSourceEntries, isFileMatchedByTailwindSourceEntries, isLocalCssImportRequest, isMiniProgramLocalCssImportRequest, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, isTailwindCssGenerationDirective, isTailwindCssImportAtRule, isTailwindCssImportRequest, isTailwindCssPackageJsonImportRequest, isWeappTailwindcssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeLegacyContentEntries, normalizeMiniProgramGeneratedCssForPostcss, normalizeMiniProgramPrefixedDeclaration, normalizeModernColorValue, normalizeOutputImportRequest, normalizeTailwindCssImportRequest, normalizeTailwindcssRpxDeclaration, normalizeTailwindcssRpxDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeTailwindcssWebRpxDeclarations, normalizeWebCssCompatOptions, parseConfigParam, parseSourceFileParam, parseTailwindCssConfigRequest, parseTailwindCssDirectiveRequest, postcss, postcssHtmlTransform, prefixLocalCssImportsWithWebpackIgnoreRoot, protectDynamicColorMixAlpha, protectDynamicVarFallbacks, pruneMiniProgramGeneratedCss, removeEmptyAtRules, removeMatchingLocalCssImports, removeMatchingLocalCssImportsRoot, removeTailwindPostcssPlugins, removeTailwindSourceDirectivesRoot, removeUnsupportedAtSupports, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules, removeUnsupportedMiniProgramCssImportsRoot, removeUnsupportedMiniProgramPrefixedAtRule, resolveCssSourceEntries, resolveFilteredPostcssConfig, resolvePostcssConfig, resolvePostcssFrameworkProfile, resolvePostcssFrameworkStrategy, resolvePostcssStyleBranch, resolvePostcssStyleBranchProfile, resolvePostcssStyleTarget, resolveSourceScanPath, resolveTailwindSourceEntry, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, rewriteLocalCssImportRequestsForOutputRoot, splitLocalCssImports, splitLocalCssImportsRoot, stripMiniProgramCssSpecificityPlaceholders, toPosixPath, transformCssMacroCss, transformCssMacroTailwindV4Source, transformWebCssCompat, transformWebCssSafeSelectors, unitConversionComposeRules, unitConversionPresets, unwrapUnsupportedCascadeLayers, withCssMacroStyleOptions };
|
|
7597
|
+
export { CSS_MACRO_POSTCSS_PLUGIN_NAME, CSS_MACRO_STYLE_OPTIONS_MARKER, FULL_SOURCE_SCAN_EXTENSIONS, FULL_SOURCE_SCAN_EXTENSION_RE, FULL_SOURCE_SCAN_PATTERN, analyzeTailwindCssDirectives, cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, collectApplyOnlyCssSelectors, collectApplyOnlyCssSelectorsRoot, collectCssImportRequestsRoot, collectCssInlineSourceCandidates, compileCssMacroConditionalComments, consumeCascadeLayers, containsCssAfterMinify, convertTailwindcssRpxDeclarationToRem, convertTailwindcssRpxDeclarationsToRem, convertTailwindcssRpxValueToRem, createCssSourceOrderAppend, createFallbackPlaceholderReplacer, createInjectPreflight, createPostcssStyleTargetProfile, createSourceScanPattern, createStyleHandler, createStylePipeline, createTailwindSourceEntryMatcher, createWeappTailwindcssPostcssPlugin, creator as cssMacroPostcssPlugin, dedupeCoveredCssRules, expandInlineSourceCandidatePattern, expandTailwindSourceEntries, filterApplyOnlyGeneratedCss, filterApplyOnlyGeneratedCssRoot, filterExistingCssRules, finalizeMiniProgramCss, getPostcssPluginName, hasCssMacroStyleOptions, hasCssMacroTailwindV4CustomVariantConditionalComments, hasCssMacroTailwindV4Directive, hasCssMacroTailwindV4InternalAtRules, hasCssMacroTailwindV4Source, hasMiniProgramCssSpecificityPlaceholders, hoistTailwindPreflightBase, internalCssSelectorReplacer, isFileExcludedByTailwindSourceEntries, isFileMatchedByTailwindSourceEntries, isLocalCssImportRequest, isMiniProgramLocalCssImportRequest, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, isTailwindCssGenerationDirective, isTailwindCssImportAtRule, isTailwindCssImportRequest, isTailwindCssPackageJsonImportRequest, isWeappTailwindcssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeLegacyContentEntries, normalizeMiniProgramGeneratedCssForPostcss, normalizeMiniProgramPrefixedDeclaration, normalizeModernColorValue, normalizeOutputImportRequest, normalizeTailwindCssImportRequest, normalizeTailwindcssRpxDeclaration, normalizeTailwindcssRpxDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeTailwindcssWebRpxDeclarations, normalizeWebCssCompatOptions, parseConfigParam, parseSourceFileParam, parseTailwindCssConfigRequest, parseTailwindCssDirectiveRequest, postcss, postcssHtmlTransform, prefixLocalCssImportsWithWebpackIgnoreRoot, protectDynamicColorMixAlpha, protectDynamicVarFallbacks, pruneMiniProgramGeneratedCss, removeEmptyAtRules, removeMatchingLocalCssImports, removeMatchingLocalCssImportsRoot, removeTailwindPostcssPlugins, removeTailwindSourceDirectivesRoot, removeUnsupportedAtSupports, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules, removeUnsupportedMiniProgramCssImportsRoot, removeUnsupportedMiniProgramPrefixedAtRule, resolveCssSourceEntries, resolveFilteredPostcssConfig, resolvePostcssConfig, resolvePostcssFrameworkProfile, resolvePostcssFrameworkStrategy, resolvePostcssStyleBranch, resolvePostcssStyleBranchProfile, resolvePostcssStyleTarget, resolveSourceScanPath, resolveTailwindSourceEntry, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, rewriteLocalCssImportRequestsForOutputRoot, selectorContainsPseudoClass, splitLocalCssImports, splitLocalCssImportsRoot, stripMiniProgramCssSpecificityPlaceholders, toPosixPath, transformCssMacroCss, transformCssMacroTailwindV4Source, transformLynxCssCompat, transformWebCssCompat, transformWebCssSafeSelectors, unitConversionComposeRules, unitConversionPresets, unwrapUnsupportedCascadeLayers, withCssMacroStyleOptions };
|