@weapp-tailwindcss/postcss 3.2.7 → 3.2.8
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/index.cjs +31 -12
- package/dist/index.js +31 -12
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -5023,26 +5023,45 @@ function getCustomPropertyCleaner(options) {
|
|
|
5023
5023
|
const includeCustomProperties = Array.isArray(options.cssCalc) ? options.cssCalc : typeof options.cssCalc === "object" ? options.cssCalc.includeCustomProperties : [];
|
|
5024
5024
|
if (!(Array.isArray(includeCustomProperties) && includeCustomProperties.length > 0)) return null;
|
|
5025
5025
|
const shouldInspectValue = (value) => value.includes("var(") && value.includes("--");
|
|
5026
|
+
const containsIncludedCustomProperty = (value) => {
|
|
5027
|
+
if (!shouldInspectValue(value)) return false;
|
|
5028
|
+
const parsed = (0, postcss_value_parser.default)(value);
|
|
5029
|
+
let containsIncludedCustomProperty = false;
|
|
5030
|
+
parsed.walk((node) => {
|
|
5031
|
+
if (node.type !== "function" || node.value !== "var" || containsIncludedCustomProperty) return;
|
|
5032
|
+
if (node.nodes.find((x) => {
|
|
5033
|
+
return x.type === "word" && (0, _weapp_tailwindcss_shared.regExpTest)(includeCustomProperties, x.value);
|
|
5034
|
+
})) containsIncludedCustomProperty = true;
|
|
5035
|
+
});
|
|
5036
|
+
return containsIncludedCustomProperty;
|
|
5037
|
+
};
|
|
5038
|
+
const hasSameSourceRange = (left, right) => {
|
|
5039
|
+
const leftSource = left.source;
|
|
5040
|
+
const rightSource = right.source;
|
|
5041
|
+
if (!leftSource?.start || !leftSource.end || !rightSource?.start || !rightSource.end || leftSource.input !== rightSource.input) return false;
|
|
5042
|
+
return leftSource.start.line === rightSource.start.line && leftSource.start.column === rightSource.start.column && leftSource.end.line === rightSource.end.line && leftSource.end.column === rightSource.end.column;
|
|
5043
|
+
};
|
|
5026
5044
|
return {
|
|
5027
5045
|
postcssPlugin: "postcss-remove-include-custom-properties",
|
|
5028
5046
|
OnceExit(root) {
|
|
5029
5047
|
root.walkDecls((decl) => {
|
|
5030
5048
|
const prevNode = decl.prev();
|
|
5031
|
-
if (
|
|
5032
|
-
if (prevNode.value === decl.value) {
|
|
5049
|
+
if (prevNode && prevNode.type === "decl" && prevNode.prop === decl.prop && prevNode.important === decl.important && prevNode.value === decl.value) {
|
|
5033
5050
|
decl.remove();
|
|
5034
5051
|
return;
|
|
5035
5052
|
}
|
|
5036
|
-
if (!
|
|
5037
|
-
|
|
5038
|
-
let
|
|
5039
|
-
|
|
5040
|
-
if (node.type
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
}
|
|
5044
|
-
|
|
5045
|
-
|
|
5053
|
+
if (!containsIncludedCustomProperty(decl.value)) return;
|
|
5054
|
+
let fallbackDecl;
|
|
5055
|
+
let node = prevNode;
|
|
5056
|
+
while (node) {
|
|
5057
|
+
if (node.type === "decl" && node.prop === decl.prop) {
|
|
5058
|
+
fallbackDecl = node;
|
|
5059
|
+
break;
|
|
5060
|
+
}
|
|
5061
|
+
node = node.prev();
|
|
5062
|
+
}
|
|
5063
|
+
if (!fallbackDecl || fallbackDecl.important !== decl.important || fallbackDecl !== prevNode && !hasSameSourceRange(fallbackDecl, decl) || containsIncludedCustomProperty(fallbackDecl.value)) return;
|
|
5064
|
+
decl.remove();
|
|
5046
5065
|
});
|
|
5047
5066
|
}
|
|
5048
5067
|
};
|
package/dist/index.js
CHANGED
|
@@ -5008,26 +5008,45 @@ function getCustomPropertyCleaner(options) {
|
|
|
5008
5008
|
const includeCustomProperties = Array.isArray(options.cssCalc) ? options.cssCalc : typeof options.cssCalc === "object" ? options.cssCalc.includeCustomProperties : [];
|
|
5009
5009
|
if (!(Array.isArray(includeCustomProperties) && includeCustomProperties.length > 0)) return null;
|
|
5010
5010
|
const shouldInspectValue = (value) => value.includes("var(") && value.includes("--");
|
|
5011
|
+
const containsIncludedCustomProperty = (value) => {
|
|
5012
|
+
if (!shouldInspectValue(value)) return false;
|
|
5013
|
+
const parsed = valueParser(value);
|
|
5014
|
+
let containsIncludedCustomProperty = false;
|
|
5015
|
+
parsed.walk((node) => {
|
|
5016
|
+
if (node.type !== "function" || node.value !== "var" || containsIncludedCustomProperty) return;
|
|
5017
|
+
if (node.nodes.find((x) => {
|
|
5018
|
+
return x.type === "word" && regExpTest(includeCustomProperties, x.value);
|
|
5019
|
+
})) containsIncludedCustomProperty = true;
|
|
5020
|
+
});
|
|
5021
|
+
return containsIncludedCustomProperty;
|
|
5022
|
+
};
|
|
5023
|
+
const hasSameSourceRange = (left, right) => {
|
|
5024
|
+
const leftSource = left.source;
|
|
5025
|
+
const rightSource = right.source;
|
|
5026
|
+
if (!leftSource?.start || !leftSource.end || !rightSource?.start || !rightSource.end || leftSource.input !== rightSource.input) return false;
|
|
5027
|
+
return leftSource.start.line === rightSource.start.line && leftSource.start.column === rightSource.start.column && leftSource.end.line === rightSource.end.line && leftSource.end.column === rightSource.end.column;
|
|
5028
|
+
};
|
|
5011
5029
|
return {
|
|
5012
5030
|
postcssPlugin: "postcss-remove-include-custom-properties",
|
|
5013
5031
|
OnceExit(root) {
|
|
5014
5032
|
root.walkDecls((decl) => {
|
|
5015
5033
|
const prevNode = decl.prev();
|
|
5016
|
-
if (
|
|
5017
|
-
if (prevNode.value === decl.value) {
|
|
5034
|
+
if (prevNode && prevNode.type === "decl" && prevNode.prop === decl.prop && prevNode.important === decl.important && prevNode.value === decl.value) {
|
|
5018
5035
|
decl.remove();
|
|
5019
5036
|
return;
|
|
5020
5037
|
}
|
|
5021
|
-
if (!
|
|
5022
|
-
|
|
5023
|
-
let
|
|
5024
|
-
|
|
5025
|
-
if (node.type
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
}
|
|
5029
|
-
|
|
5030
|
-
|
|
5038
|
+
if (!containsIncludedCustomProperty(decl.value)) return;
|
|
5039
|
+
let fallbackDecl;
|
|
5040
|
+
let node = prevNode;
|
|
5041
|
+
while (node) {
|
|
5042
|
+
if (node.type === "decl" && node.prop === decl.prop) {
|
|
5043
|
+
fallbackDecl = node;
|
|
5044
|
+
break;
|
|
5045
|
+
}
|
|
5046
|
+
node = node.prev();
|
|
5047
|
+
}
|
|
5048
|
+
if (!fallbackDecl || fallbackDecl.important !== decl.important || fallbackDecl !== prevNode && !hasSameSourceRange(fallbackDecl, decl) || containsIncludedCustomProperty(fallbackDecl.value)) return;
|
|
5049
|
+
decl.remove();
|
|
5031
5050
|
});
|
|
5032
5051
|
}
|
|
5033
5052
|
};
|
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.8",
|
|
5
5
|
"description": "@weapp-tailwindcss/postcss",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"postcss-selector-parser": "~7.1.4",
|
|
84
84
|
"postcss-value-parser": "^4.2.0",
|
|
85
85
|
"@weapp-tailwindcss/postcss-calc": "^1.0.3",
|
|
86
|
-
"
|
|
87
|
-
"tailwindcss
|
|
86
|
+
"tailwindcss-config": "2.0.2",
|
|
87
|
+
"@weapp-tailwindcss/shared": "2.0.1"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@csstools/postcss-is-pseudo-class": "^6.0.0",
|