@weapp-tailwindcss/postcss 3.2.4 → 3.2.6
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/mini-program-css/root-cleanups.d.ts +1 -0
- package/dist/index.cjs +63 -12
- package/dist/index.js +63 -12
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ export declare function removeRootSpecificityPlaceholders(root: postcss.Root): v
|
|
|
7
7
|
export declare function removeEmptyAtRules(root: postcss.Root): number;
|
|
8
8
|
export declare function removeEmptyBlockAtRules(root: postcss.Root): number;
|
|
9
9
|
export declare function removeUnsupportedBrowserSelectors(root: postcss.Root): void;
|
|
10
|
+
export declare function removeEmptyStandardPropertyFallbacks(root: postcss.Root): void;
|
|
10
11
|
export declare function removeDisplayP3Declarations(root: postcss.Root): void;
|
|
11
12
|
interface RemoveTailwindContainerRulesOptions {
|
|
12
13
|
generatedOnly?: boolean;
|
package/dist/index.cjs
CHANGED
|
@@ -937,15 +937,18 @@ function isTailwindPreflightDeclaration(decl) {
|
|
|
937
937
|
if (prop === "font-family" && value.startsWith("var(--default-font-family") || prop === "font-feature-settings" && value.startsWith("var(--default-font-feature-settings") || prop === "font-variation-settings" && value.startsWith("var(--default-font-variation-settings")) return true;
|
|
938
938
|
return TAILWIND_PREFLIGHT_DECLARATIONS.has(`${prop}:${value}`);
|
|
939
939
|
}
|
|
940
|
-
function
|
|
940
|
+
function hasTailwindSourceEvidence(declarations, hasTailwindBanner) {
|
|
941
|
+
return hasTailwindBanner || declarations.some((decl) => decl.prop.startsWith("--tw-"));
|
|
942
|
+
}
|
|
943
|
+
function isScopedTailwindThemeCarrierRule(rule, hasTailwindBanner) {
|
|
941
944
|
const selectors = rule.selectors ?? [rule.selector];
|
|
942
945
|
const declarations = getDeclarations(rule);
|
|
943
946
|
return selectors.length > 0 && selectors.every((selector) => {
|
|
944
947
|
const normalized = normalizeCssSignatureValue(selector);
|
|
945
948
|
return hasVueScopedAttr(selector) && (normalized.startsWith(":root") || normalized.startsWith(":host"));
|
|
946
|
-
}) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--"));
|
|
949
|
+
}) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--")) && hasTailwindSourceEvidence(declarations, hasTailwindBanner);
|
|
947
950
|
}
|
|
948
|
-
function isScopedUniversalTailwindPreflightRule(rule) {
|
|
951
|
+
function isScopedUniversalTailwindPreflightRule(rule, hasTailwindBanner) {
|
|
949
952
|
const selectors = rule.selectors ?? [rule.selector];
|
|
950
953
|
const declarations = getDeclarations(rule);
|
|
951
954
|
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || [
|
|
@@ -953,7 +956,7 @@ function isScopedUniversalTailwindPreflightRule(rule) {
|
|
|
953
956
|
"margin",
|
|
954
957
|
"padding",
|
|
955
958
|
"border"
|
|
956
|
-
].includes(decl.prop));
|
|
959
|
+
].includes(decl.prop)) && hasTailwindSourceEvidence(declarations, hasTailwindBanner);
|
|
957
960
|
}
|
|
958
961
|
function isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) {
|
|
959
962
|
if (!hasTailwindBanner) return false;
|
|
@@ -961,7 +964,7 @@ function isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) {
|
|
|
961
964
|
const declarations = getDeclarations(rule);
|
|
962
965
|
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
963
966
|
}
|
|
964
|
-
function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
967
|
+
function isUnscopedMiniProgramTailwindPreflightRule(rule, hasTailwindBanner) {
|
|
965
968
|
const selectors = rule.selectors ?? [rule.selector];
|
|
966
969
|
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
967
970
|
const normalized = normalizeCssSignatureValue(selector);
|
|
@@ -973,7 +976,7 @@ function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
|
973
976
|
"margin",
|
|
974
977
|
"padding",
|
|
975
978
|
"border"
|
|
976
|
-
].includes(decl.prop));
|
|
979
|
+
].includes(decl.prop)) && hasTailwindSourceEvidence(declarations, hasTailwindBanner);
|
|
977
980
|
}
|
|
978
981
|
function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
979
982
|
const selectors = rule.selectors ?? [rule.selector];
|
|
@@ -996,7 +999,7 @@ function stripScopedTailwindNoise(root) {
|
|
|
996
999
|
if (TAILWIND_VERSION_COMMENT_RE.test(comment.text)) comment.remove();
|
|
997
1000
|
});
|
|
998
1001
|
root.walkRules((rule) => {
|
|
999
|
-
if (isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule)) rule.remove();
|
|
1002
|
+
if (isScopedTailwindThemeCarrierRule(rule, hasTailwindBanner) || isScopedUniversalTailwindPreflightRule(rule, hasTailwindBanner) || isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) || isUnscopedMiniProgramTailwindPreflightRule(rule, hasTailwindBanner) || isScopedMiniProgramTailwindContentInitRule(rule)) rule.remove();
|
|
1000
1003
|
});
|
|
1001
1004
|
root.walkAtRules((atRule) => {
|
|
1002
1005
|
if (isLikelyTailwindPropertyAtRule(atRule)) {
|
|
@@ -1217,9 +1220,15 @@ function applyUniAppXUvueCompatibility(result, options) {
|
|
|
1217
1220
|
root = calcResult.root;
|
|
1218
1221
|
calcMessages = calcResult.messages;
|
|
1219
1222
|
}
|
|
1220
|
-
if (sfcStyleRequest)
|
|
1223
|
+
if (sfcStyleRequest) {
|
|
1224
|
+
stripScopedTailwindNoise(root);
|
|
1225
|
+
const nextResult = root.toResult(result.opts);
|
|
1226
|
+
nextResult.messages.push(...result.messages);
|
|
1227
|
+
nextResult.messages.push(...calcMessages);
|
|
1228
|
+
return nextResult;
|
|
1229
|
+
}
|
|
1221
1230
|
root.walkRules((rule) => {
|
|
1222
|
-
if (!
|
|
1231
|
+
if (!hasOnlyClassSelectors(rule)) {
|
|
1223
1232
|
reportUnsupportedRule(rule, result, mode, warningCache, "selector must be class-only");
|
|
1224
1233
|
rule.remove();
|
|
1225
1234
|
return;
|
|
@@ -2539,6 +2548,11 @@ function removeDeclarationAndEmptyRule$1(decl) {
|
|
|
2539
2548
|
removeEmptyAtRuleAncestors(ruleParent);
|
|
2540
2549
|
}
|
|
2541
2550
|
}
|
|
2551
|
+
function removeEmptyStandardPropertyFallbacks(root) {
|
|
2552
|
+
root.walkDecls((decl) => {
|
|
2553
|
+
if (!decl.prop.startsWith("--") && decl.value.trim().length === 0 && decl.parent?.nodes.some((node) => node !== decl && node.type === "decl" && node.prop === decl.prop && node.value.trim().length > 0)) removeDeclarationAndEmptyRule$1(decl);
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2542
2556
|
function removeDisplayP3Declarations(root) {
|
|
2543
2557
|
root.walkAtRules((atRule) => {
|
|
2544
2558
|
if (isDisplayP3MediaRule(atRule)) {
|
|
@@ -2636,6 +2650,7 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
2636
2650
|
removeRootSpecificityPlaceholders(root);
|
|
2637
2651
|
removeUnsupportedBrowserSelectors(root);
|
|
2638
2652
|
removeDisplayP3Declarations(root);
|
|
2653
|
+
removeEmptyStandardPropertyFallbacks(root);
|
|
2639
2654
|
removeTailwindContainerMaxWidthMediaRules(root);
|
|
2640
2655
|
removeTailwindContainerWidthRules(root, { generatedOnly: true });
|
|
2641
2656
|
removeUnsupportedModernColorDeclarations(root);
|
|
@@ -3032,8 +3047,14 @@ function isWebCssCompatEnabled(options) {
|
|
|
3032
3047
|
}
|
|
3033
3048
|
function collectCustomPropertyValues(root) {
|
|
3034
3049
|
const values = /* @__PURE__ */ new Map();
|
|
3035
|
-
root.
|
|
3036
|
-
if (
|
|
3050
|
+
root.walkRules((rule) => {
|
|
3051
|
+
if (!rule.selectors.some((selector) => selector.trim() === ":root" || selector.trim() === ":host")) return;
|
|
3052
|
+
rule.each((node) => {
|
|
3053
|
+
if (node.type === "decl" && node.prop.startsWith("--") && !node.prop.startsWith("--tw-")) {
|
|
3054
|
+
const decl = node;
|
|
3055
|
+
values.set(decl.prop, decl.value.trim());
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3037
3058
|
});
|
|
3038
3059
|
return values;
|
|
3039
3060
|
}
|
|
@@ -3183,6 +3204,16 @@ function removeEmptyAtRules$2(root) {
|
|
|
3183
3204
|
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
3184
3205
|
});
|
|
3185
3206
|
}
|
|
3207
|
+
function insertWebkitBackgroundClipText(root) {
|
|
3208
|
+
root.walkDecls("background-clip", (decl) => {
|
|
3209
|
+
if (decl.value.trim().toLowerCase() !== "text") return;
|
|
3210
|
+
const parent = decl.parent;
|
|
3211
|
+
if (!parent || !("nodes" in parent)) return;
|
|
3212
|
+
if (!parent.nodes.some((node) => {
|
|
3213
|
+
return node.type === "decl" && node.prop.toLowerCase() === "-webkit-background-clip" && node.value.trim().toLowerCase() === "text";
|
|
3214
|
+
})) decl.cloneBefore({ prop: "-webkit-background-clip" });
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3186
3217
|
function transformCssNesting(root) {
|
|
3187
3218
|
(0, postcss.default)([(0, postcss_preset_env.default)({
|
|
3188
3219
|
stage: false,
|
|
@@ -3192,7 +3223,7 @@ function transformCssNesting(root) {
|
|
|
3192
3223
|
}
|
|
3193
3224
|
function transformWebCssCompat(css, options) {
|
|
3194
3225
|
const normalized = normalizeWebCssCompatOptions(options);
|
|
3195
|
-
if (!isWebCssCompatEnabled(normalized)) return css;
|
|
3226
|
+
if (!isWebCssCompatEnabled(normalized) && normalized.preset !== "legacy-web") return css;
|
|
3196
3227
|
try {
|
|
3197
3228
|
const root = postcss.default.parse(css);
|
|
3198
3229
|
if (normalized.features.theme) unwrapThemeAtRules(root);
|
|
@@ -3206,6 +3237,7 @@ function transformWebCssCompat(css, options) {
|
|
|
3206
3237
|
normalizeTailwindcssV4GradientPositionDeclarations(root);
|
|
3207
3238
|
normalizeTailwindcssV4InfinityCalcDeclarations(root);
|
|
3208
3239
|
normalizeModernColorDeclarations(root, normalized.features);
|
|
3240
|
+
if (normalized.preset === "legacy-web") insertWebkitBackgroundClipText(root);
|
|
3209
3241
|
if (normalized.features.layer) removeUnsupportedCascadeLayers(root);
|
|
3210
3242
|
removeEmptyAtRules$2(root);
|
|
3211
3243
|
return root.toString();
|
|
@@ -6481,8 +6513,27 @@ function shouldUseDefaultAutoprefixer(options, userPlugins) {
|
|
|
6481
6513
|
if (options.autoprefixer === true || typeof options.autoprefixer === "object") return true;
|
|
6482
6514
|
return options.majorVersion === 4;
|
|
6483
6515
|
}
|
|
6516
|
+
function isUniAppXNativeAuthorStyle(options) {
|
|
6517
|
+
const source = options.uniAppXCssSource;
|
|
6518
|
+
return options.uniAppX === true && options.uniAppXCssTarget === "uvue" && (source === "author" || source === "author-apply");
|
|
6519
|
+
}
|
|
6520
|
+
function appendUniAppXNativeAuthorDeclarationNodes(preparedNodes, options) {
|
|
6521
|
+
if (options.uniAppXCssSource !== "author-apply") return;
|
|
6522
|
+
const declarationPlugins = [
|
|
6523
|
+
["normal:units-to-px", getUnitsToPxPlugin(options)],
|
|
6524
|
+
["normal:px-transform", getPxTransformPlugin(options)],
|
|
6525
|
+
["normal:rem-transform", getRemTransformPlugin(options)],
|
|
6526
|
+
["normal:unit-conversion", getUnitConversionPlugin(options)],
|
|
6527
|
+
["normal:calc", getCalcPlugin(options)]
|
|
6528
|
+
];
|
|
6529
|
+
for (const [id, plugin] of declarationPlugins) if (plugin) preparedNodes.push(createPreparedNode(id, "normal", () => plugin));
|
|
6530
|
+
}
|
|
6484
6531
|
function createPreparedNodes(options, signal) {
|
|
6485
6532
|
const preparedNodes = [];
|
|
6533
|
+
if (isUniAppXNativeAuthorStyle(options)) {
|
|
6534
|
+
appendUniAppXNativeAuthorDeclarationNodes(preparedNodes, options);
|
|
6535
|
+
return preparedNodes;
|
|
6536
|
+
}
|
|
6486
6537
|
const userPlugins = normalizeUserPlugins(options.postcssOptions?.plugins);
|
|
6487
6538
|
const presetEnvOptions = {
|
|
6488
6539
|
...options.cssPresetEnv,
|
package/dist/index.js
CHANGED
|
@@ -922,15 +922,18 @@ function isTailwindPreflightDeclaration(decl) {
|
|
|
922
922
|
if (prop === "font-family" && value.startsWith("var(--default-font-family") || prop === "font-feature-settings" && value.startsWith("var(--default-font-feature-settings") || prop === "font-variation-settings" && value.startsWith("var(--default-font-variation-settings")) return true;
|
|
923
923
|
return TAILWIND_PREFLIGHT_DECLARATIONS.has(`${prop}:${value}`);
|
|
924
924
|
}
|
|
925
|
-
function
|
|
925
|
+
function hasTailwindSourceEvidence(declarations, hasTailwindBanner) {
|
|
926
|
+
return hasTailwindBanner || declarations.some((decl) => decl.prop.startsWith("--tw-"));
|
|
927
|
+
}
|
|
928
|
+
function isScopedTailwindThemeCarrierRule(rule, hasTailwindBanner) {
|
|
926
929
|
const selectors = rule.selectors ?? [rule.selector];
|
|
927
930
|
const declarations = getDeclarations(rule);
|
|
928
931
|
return selectors.length > 0 && selectors.every((selector) => {
|
|
929
932
|
const normalized = normalizeCssSignatureValue(selector);
|
|
930
933
|
return hasVueScopedAttr(selector) && (normalized.startsWith(":root") || normalized.startsWith(":host"));
|
|
931
|
-
}) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--"));
|
|
934
|
+
}) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--")) && hasTailwindSourceEvidence(declarations, hasTailwindBanner);
|
|
932
935
|
}
|
|
933
|
-
function isScopedUniversalTailwindPreflightRule(rule) {
|
|
936
|
+
function isScopedUniversalTailwindPreflightRule(rule, hasTailwindBanner) {
|
|
934
937
|
const selectors = rule.selectors ?? [rule.selector];
|
|
935
938
|
const declarations = getDeclarations(rule);
|
|
936
939
|
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || [
|
|
@@ -938,7 +941,7 @@ function isScopedUniversalTailwindPreflightRule(rule) {
|
|
|
938
941
|
"margin",
|
|
939
942
|
"padding",
|
|
940
943
|
"border"
|
|
941
|
-
].includes(decl.prop));
|
|
944
|
+
].includes(decl.prop)) && hasTailwindSourceEvidence(declarations, hasTailwindBanner);
|
|
942
945
|
}
|
|
943
946
|
function isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) {
|
|
944
947
|
if (!hasTailwindBanner) return false;
|
|
@@ -946,7 +949,7 @@ function isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) {
|
|
|
946
949
|
const declarations = getDeclarations(rule);
|
|
947
950
|
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
948
951
|
}
|
|
949
|
-
function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
952
|
+
function isUnscopedMiniProgramTailwindPreflightRule(rule, hasTailwindBanner) {
|
|
950
953
|
const selectors = rule.selectors ?? [rule.selector];
|
|
951
954
|
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
952
955
|
const normalized = normalizeCssSignatureValue(selector);
|
|
@@ -958,7 +961,7 @@ function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
|
958
961
|
"margin",
|
|
959
962
|
"padding",
|
|
960
963
|
"border"
|
|
961
|
-
].includes(decl.prop));
|
|
964
|
+
].includes(decl.prop)) && hasTailwindSourceEvidence(declarations, hasTailwindBanner);
|
|
962
965
|
}
|
|
963
966
|
function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
964
967
|
const selectors = rule.selectors ?? [rule.selector];
|
|
@@ -981,7 +984,7 @@ function stripScopedTailwindNoise(root) {
|
|
|
981
984
|
if (TAILWIND_VERSION_COMMENT_RE.test(comment.text)) comment.remove();
|
|
982
985
|
});
|
|
983
986
|
root.walkRules((rule) => {
|
|
984
|
-
if (isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule)) rule.remove();
|
|
987
|
+
if (isScopedTailwindThemeCarrierRule(rule, hasTailwindBanner) || isScopedUniversalTailwindPreflightRule(rule, hasTailwindBanner) || isScopedTailwindElementPreflightRule(rule, hasTailwindBanner) || isUnscopedMiniProgramTailwindPreflightRule(rule, hasTailwindBanner) || isScopedMiniProgramTailwindContentInitRule(rule)) rule.remove();
|
|
985
988
|
});
|
|
986
989
|
root.walkAtRules((atRule) => {
|
|
987
990
|
if (isLikelyTailwindPropertyAtRule(atRule)) {
|
|
@@ -1202,9 +1205,15 @@ function applyUniAppXUvueCompatibility(result, options) {
|
|
|
1202
1205
|
root = calcResult.root;
|
|
1203
1206
|
calcMessages = calcResult.messages;
|
|
1204
1207
|
}
|
|
1205
|
-
if (sfcStyleRequest)
|
|
1208
|
+
if (sfcStyleRequest) {
|
|
1209
|
+
stripScopedTailwindNoise(root);
|
|
1210
|
+
const nextResult = root.toResult(result.opts);
|
|
1211
|
+
nextResult.messages.push(...result.messages);
|
|
1212
|
+
nextResult.messages.push(...calcMessages);
|
|
1213
|
+
return nextResult;
|
|
1214
|
+
}
|
|
1206
1215
|
root.walkRules((rule) => {
|
|
1207
|
-
if (!
|
|
1216
|
+
if (!hasOnlyClassSelectors(rule)) {
|
|
1208
1217
|
reportUnsupportedRule(rule, result, mode, warningCache, "selector must be class-only");
|
|
1209
1218
|
rule.remove();
|
|
1210
1219
|
return;
|
|
@@ -2524,6 +2533,11 @@ function removeDeclarationAndEmptyRule$1(decl) {
|
|
|
2524
2533
|
removeEmptyAtRuleAncestors(ruleParent);
|
|
2525
2534
|
}
|
|
2526
2535
|
}
|
|
2536
|
+
function removeEmptyStandardPropertyFallbacks(root) {
|
|
2537
|
+
root.walkDecls((decl) => {
|
|
2538
|
+
if (!decl.prop.startsWith("--") && decl.value.trim().length === 0 && decl.parent?.nodes.some((node) => node !== decl && node.type === "decl" && node.prop === decl.prop && node.value.trim().length > 0)) removeDeclarationAndEmptyRule$1(decl);
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2527
2541
|
function removeDisplayP3Declarations(root) {
|
|
2528
2542
|
root.walkAtRules((atRule) => {
|
|
2529
2543
|
if (isDisplayP3MediaRule(atRule)) {
|
|
@@ -2621,6 +2635,7 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
2621
2635
|
removeRootSpecificityPlaceholders(root);
|
|
2622
2636
|
removeUnsupportedBrowserSelectors(root);
|
|
2623
2637
|
removeDisplayP3Declarations(root);
|
|
2638
|
+
removeEmptyStandardPropertyFallbacks(root);
|
|
2624
2639
|
removeTailwindContainerMaxWidthMediaRules(root);
|
|
2625
2640
|
removeTailwindContainerWidthRules(root, { generatedOnly: true });
|
|
2626
2641
|
removeUnsupportedModernColorDeclarations(root);
|
|
@@ -3017,8 +3032,14 @@ function isWebCssCompatEnabled(options) {
|
|
|
3017
3032
|
}
|
|
3018
3033
|
function collectCustomPropertyValues(root) {
|
|
3019
3034
|
const values = /* @__PURE__ */ new Map();
|
|
3020
|
-
root.
|
|
3021
|
-
if (
|
|
3035
|
+
root.walkRules((rule) => {
|
|
3036
|
+
if (!rule.selectors.some((selector) => selector.trim() === ":root" || selector.trim() === ":host")) return;
|
|
3037
|
+
rule.each((node) => {
|
|
3038
|
+
if (node.type === "decl" && node.prop.startsWith("--") && !node.prop.startsWith("--tw-")) {
|
|
3039
|
+
const decl = node;
|
|
3040
|
+
values.set(decl.prop, decl.value.trim());
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3022
3043
|
});
|
|
3023
3044
|
return values;
|
|
3024
3045
|
}
|
|
@@ -3168,6 +3189,16 @@ function removeEmptyAtRules$2(root) {
|
|
|
3168
3189
|
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
3169
3190
|
});
|
|
3170
3191
|
}
|
|
3192
|
+
function insertWebkitBackgroundClipText(root) {
|
|
3193
|
+
root.walkDecls("background-clip", (decl) => {
|
|
3194
|
+
if (decl.value.trim().toLowerCase() !== "text") return;
|
|
3195
|
+
const parent = decl.parent;
|
|
3196
|
+
if (!parent || !("nodes" in parent)) return;
|
|
3197
|
+
if (!parent.nodes.some((node) => {
|
|
3198
|
+
return node.type === "decl" && node.prop.toLowerCase() === "-webkit-background-clip" && node.value.trim().toLowerCase() === "text";
|
|
3199
|
+
})) decl.cloneBefore({ prop: "-webkit-background-clip" });
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3171
3202
|
function transformCssNesting(root) {
|
|
3172
3203
|
postcss$1([postcssPresetEnv({
|
|
3173
3204
|
stage: false,
|
|
@@ -3177,7 +3208,7 @@ function transformCssNesting(root) {
|
|
|
3177
3208
|
}
|
|
3178
3209
|
function transformWebCssCompat(css, options) {
|
|
3179
3210
|
const normalized = normalizeWebCssCompatOptions(options);
|
|
3180
|
-
if (!isWebCssCompatEnabled(normalized)) return css;
|
|
3211
|
+
if (!isWebCssCompatEnabled(normalized) && normalized.preset !== "legacy-web") return css;
|
|
3181
3212
|
try {
|
|
3182
3213
|
const root = postcss$1.parse(css);
|
|
3183
3214
|
if (normalized.features.theme) unwrapThemeAtRules(root);
|
|
@@ -3191,6 +3222,7 @@ function transformWebCssCompat(css, options) {
|
|
|
3191
3222
|
normalizeTailwindcssV4GradientPositionDeclarations(root);
|
|
3192
3223
|
normalizeTailwindcssV4InfinityCalcDeclarations(root);
|
|
3193
3224
|
normalizeModernColorDeclarations(root, normalized.features);
|
|
3225
|
+
if (normalized.preset === "legacy-web") insertWebkitBackgroundClipText(root);
|
|
3194
3226
|
if (normalized.features.layer) removeUnsupportedCascadeLayers(root);
|
|
3195
3227
|
removeEmptyAtRules$2(root);
|
|
3196
3228
|
return root.toString();
|
|
@@ -6466,8 +6498,27 @@ function shouldUseDefaultAutoprefixer(options, userPlugins) {
|
|
|
6466
6498
|
if (options.autoprefixer === true || typeof options.autoprefixer === "object") return true;
|
|
6467
6499
|
return options.majorVersion === 4;
|
|
6468
6500
|
}
|
|
6501
|
+
function isUniAppXNativeAuthorStyle(options) {
|
|
6502
|
+
const source = options.uniAppXCssSource;
|
|
6503
|
+
return options.uniAppX === true && options.uniAppXCssTarget === "uvue" && (source === "author" || source === "author-apply");
|
|
6504
|
+
}
|
|
6505
|
+
function appendUniAppXNativeAuthorDeclarationNodes(preparedNodes, options) {
|
|
6506
|
+
if (options.uniAppXCssSource !== "author-apply") return;
|
|
6507
|
+
const declarationPlugins = [
|
|
6508
|
+
["normal:units-to-px", getUnitsToPxPlugin(options)],
|
|
6509
|
+
["normal:px-transform", getPxTransformPlugin(options)],
|
|
6510
|
+
["normal:rem-transform", getRemTransformPlugin(options)],
|
|
6511
|
+
["normal:unit-conversion", getUnitConversionPlugin(options)],
|
|
6512
|
+
["normal:calc", getCalcPlugin(options)]
|
|
6513
|
+
];
|
|
6514
|
+
for (const [id, plugin] of declarationPlugins) if (plugin) preparedNodes.push(createPreparedNode(id, "normal", () => plugin));
|
|
6515
|
+
}
|
|
6469
6516
|
function createPreparedNodes(options, signal) {
|
|
6470
6517
|
const preparedNodes = [];
|
|
6518
|
+
if (isUniAppXNativeAuthorStyle(options)) {
|
|
6519
|
+
appendUniAppXNativeAuthorDeclarationNodes(preparedNodes, options);
|
|
6520
|
+
return preparedNodes;
|
|
6521
|
+
}
|
|
6471
6522
|
const userPlugins = normalizeUserPlugins(options.postcssOptions?.plugins);
|
|
6472
6523
|
const presetEnvOptions = {
|
|
6473
6524
|
...options.cssPresetEnv,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.6",
|
|
5
5
|
"description": "@weapp-tailwindcss/postcss",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"@tailwindcss-mangle/engine": "0.2.0",
|
|
72
72
|
"@weapp-core/escape": "~8.0.0",
|
|
73
73
|
"autoprefixer": "^10.5.4",
|
|
74
|
-
"es-toolkit": "^1.
|
|
74
|
+
"es-toolkit": "^1.50.0",
|
|
75
75
|
"lru-cache": "11.5.2",
|
|
76
76
|
"micromatch": "^4.0.8",
|
|
77
|
-
"postcss": "^8.5.
|
|
77
|
+
"postcss": "^8.5.25",
|
|
78
78
|
"postcss-load-config": "^6.0.1",
|
|
79
79
|
"postcss-preset-env": "^11.3.2",
|
|
80
80
|
"postcss-pxtrans": "^1.0.4",
|