@weapp-tailwindcss/postcss 1.0.16 → 1.0.17
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.js +74 -87
- package/dist/index.mjs +74 -87
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -123,105 +123,94 @@ function getCombinatorSelectorAst(options) {
|
|
|
123
123
|
return childCombinatorReplaceValue;
|
|
124
124
|
}
|
|
125
125
|
function createRuleTransform(rule, options) {
|
|
126
|
-
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass
|
|
126
|
+
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
|
|
127
127
|
const transform = (selectors) => {
|
|
128
128
|
selectors.walk((selector, index) => {
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
selector.remove();
|
|
144
|
-
}
|
|
129
|
+
if (selector.type === "class") {
|
|
130
|
+
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
131
|
+
escapeMap,
|
|
132
|
+
mangleContext
|
|
133
|
+
});
|
|
134
|
+
} else if (selector.type === "universal") {
|
|
135
|
+
if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
|
|
136
|
+
selector.value = composeIsPseudo(cssSelectorReplacement.universal);
|
|
137
|
+
}
|
|
138
|
+
} else if (selector.type === "selector") {
|
|
139
|
+
if (cssRemoveHoverPseudoClass) {
|
|
140
|
+
const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
|
|
141
|
+
if (node) {
|
|
142
|
+
selector.remove();
|
|
145
143
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
144
|
+
}
|
|
145
|
+
} else if (selector.type === "pseudo") {
|
|
146
|
+
if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
|
|
147
|
+
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
148
|
+
} else if (selector.value === ":where") {
|
|
149
|
+
if (index === 0 && selector.length === 1) {
|
|
150
|
+
selector.walk((node, idx) => {
|
|
151
|
+
if (idx === 0 && node.type === "class") {
|
|
152
|
+
const nodes2 = _optionalChain([node, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.nodes]);
|
|
153
|
+
if (nodes2) {
|
|
154
|
+
const first = nodes2[idx + 1];
|
|
155
|
+
if (first && first.type === "combinator" && first.value === ">") {
|
|
156
|
+
const second = nodes2[idx + 2];
|
|
157
|
+
if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
|
|
158
|
+
const ast = getCombinatorSelectorAst(options);
|
|
159
|
+
second.replaceWith(
|
|
160
|
+
...ast
|
|
161
|
+
);
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
selector.replaceWith(...selector.nodes);
|
|
168
|
+
for (const node of rule.nodes) {
|
|
169
|
+
if (node.type === "decl") {
|
|
170
|
+
if (node.prop === "margin-block-start") {
|
|
171
|
+
node.prop = "margin-block-end";
|
|
172
|
+
} else if (node.prop === "margin-block-end") {
|
|
173
|
+
node.prop = "margin-block-start";
|
|
174
|
+
} else if (node.prop === "margin-inline-start") {
|
|
175
|
+
node.prop = "margin-inline-end";
|
|
176
|
+
} else if (node.prop === "margin-inline-end") {
|
|
177
|
+
node.prop = "margin-inline-start";
|
|
178
|
+
} else if (node.prop === "margin-top") {
|
|
179
|
+
node.prop = "margin-bottom";
|
|
180
|
+
} else if (node.prop === "margin-bottom") {
|
|
181
|
+
node.prop = "margin-top";
|
|
182
|
+
} else if (node.prop === "margin-left") {
|
|
183
|
+
node.prop = "margin-right";
|
|
184
|
+
} else if (node.prop === "margin-right") {
|
|
185
|
+
node.prop = "margin-left";
|
|
186
|
+
} else if (node.prop === "-webkit-margin-start" || node.prop === "-webkit-margin-end" || node.prop === "-webkit-margin-before" || node.prop === "-webkit-margin-after") {
|
|
187
|
+
node.remove();
|
|
190
188
|
}
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
}
|
|
193
|
+
} else if (selector.type === "combinator") {
|
|
194
|
+
if (selector.value === ">") {
|
|
195
|
+
const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
|
|
196
|
+
if (nodes2) {
|
|
197
|
+
const first = nodes2[index + 1];
|
|
198
|
+
if (first && first.type === "pseudo" && first.value === ":not" && (first.first.first.type === "attribute" && first.first.first.attribute === "hidden" || first.first.first.type === "tag" && first.first.first.value === "template")) {
|
|
199
|
+
const second = nodes2[index + 2];
|
|
200
|
+
if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
|
|
201
|
+
const third = nodes2[index + 3];
|
|
202
|
+
if (third && third.type === "pseudo" && third.value === ":not" && (third.first.first.type === "attribute" && third.first.first.attribute === "hidden" || third.first.first.type === "tag" && third.first.first.value === "template")) {
|
|
203
|
+
const ast = getCombinatorSelectorAst(options);
|
|
204
|
+
_optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
|
|
205
|
+
index + 1,
|
|
206
|
+
3,
|
|
207
|
+
...ast
|
|
208
|
+
)]);
|
|
211
209
|
}
|
|
212
210
|
}
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
}
|
|
216
|
-
} else {
|
|
217
|
-
if (selector.type === "class") {
|
|
218
|
-
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
219
|
-
escapeMap,
|
|
220
|
-
mangleContext
|
|
221
|
-
});
|
|
222
|
-
} else {
|
|
223
|
-
selector.remove();
|
|
224
|
-
}
|
|
225
214
|
}
|
|
226
215
|
});
|
|
227
216
|
if (selectors.length === 0) {
|
|
@@ -331,9 +320,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
331
320
|
rule.remove();
|
|
332
321
|
}
|
|
333
322
|
rule.walkDecls((decl) => {
|
|
334
|
-
if (
|
|
335
|
-
decl.remove();
|
|
336
|
-
} else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
323
|
+
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
337
324
|
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
338
325
|
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
339
326
|
decl.value = "9999px";
|
package/dist/index.mjs
CHANGED
|
@@ -123,105 +123,94 @@ function getCombinatorSelectorAst(options) {
|
|
|
123
123
|
return childCombinatorReplaceValue;
|
|
124
124
|
}
|
|
125
125
|
function createRuleTransform(rule, options) {
|
|
126
|
-
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass
|
|
126
|
+
const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
|
|
127
127
|
const transform = (selectors) => {
|
|
128
128
|
selectors.walk((selector, index) => {
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
selector.remove();
|
|
144
|
-
}
|
|
129
|
+
if (selector.type === "class") {
|
|
130
|
+
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
131
|
+
escapeMap,
|
|
132
|
+
mangleContext
|
|
133
|
+
});
|
|
134
|
+
} else if (selector.type === "universal") {
|
|
135
|
+
if (cssSelectorReplacement?.universal) {
|
|
136
|
+
selector.value = composeIsPseudo(cssSelectorReplacement.universal);
|
|
137
|
+
}
|
|
138
|
+
} else if (selector.type === "selector") {
|
|
139
|
+
if (cssRemoveHoverPseudoClass) {
|
|
140
|
+
const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
|
|
141
|
+
if (node) {
|
|
142
|
+
selector.remove();
|
|
145
143
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
144
|
+
}
|
|
145
|
+
} else if (selector.type === "pseudo") {
|
|
146
|
+
if (selector.value === ":root" && cssSelectorReplacement?.root) {
|
|
147
|
+
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
148
|
+
} else if (selector.value === ":where") {
|
|
149
|
+
if (index === 0 && selector.length === 1) {
|
|
150
|
+
selector.walk((node, idx) => {
|
|
151
|
+
if (idx === 0 && node.type === "class") {
|
|
152
|
+
const nodes2 = node.parent?.nodes;
|
|
153
|
+
if (nodes2) {
|
|
154
|
+
const first = nodes2[idx + 1];
|
|
155
|
+
if (first && first.type === "combinator" && first.value === ">") {
|
|
156
|
+
const second = nodes2[idx + 2];
|
|
157
|
+
if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
|
|
158
|
+
const ast = getCombinatorSelectorAst(options);
|
|
159
|
+
second.replaceWith(
|
|
160
|
+
...ast
|
|
161
|
+
);
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
selector.replaceWith(...selector.nodes);
|
|
168
|
+
for (const node of rule.nodes) {
|
|
169
|
+
if (node.type === "decl") {
|
|
170
|
+
if (node.prop === "margin-block-start") {
|
|
171
|
+
node.prop = "margin-block-end";
|
|
172
|
+
} else if (node.prop === "margin-block-end") {
|
|
173
|
+
node.prop = "margin-block-start";
|
|
174
|
+
} else if (node.prop === "margin-inline-start") {
|
|
175
|
+
node.prop = "margin-inline-end";
|
|
176
|
+
} else if (node.prop === "margin-inline-end") {
|
|
177
|
+
node.prop = "margin-inline-start";
|
|
178
|
+
} else if (node.prop === "margin-top") {
|
|
179
|
+
node.prop = "margin-bottom";
|
|
180
|
+
} else if (node.prop === "margin-bottom") {
|
|
181
|
+
node.prop = "margin-top";
|
|
182
|
+
} else if (node.prop === "margin-left") {
|
|
183
|
+
node.prop = "margin-right";
|
|
184
|
+
} else if (node.prop === "margin-right") {
|
|
185
|
+
node.prop = "margin-left";
|
|
186
|
+
} else if (node.prop === "-webkit-margin-start" || node.prop === "-webkit-margin-end" || node.prop === "-webkit-margin-before" || node.prop === "-webkit-margin-after") {
|
|
187
|
+
node.remove();
|
|
190
188
|
}
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
}
|
|
193
|
+
} else if (selector.type === "combinator") {
|
|
194
|
+
if (selector.value === ">") {
|
|
195
|
+
const nodes2 = selector.parent?.nodes;
|
|
196
|
+
if (nodes2) {
|
|
197
|
+
const first = nodes2[index + 1];
|
|
198
|
+
if (first && first.type === "pseudo" && first.value === ":not" && (first.first.first.type === "attribute" && first.first.first.attribute === "hidden" || first.first.first.type === "tag" && first.first.first.value === "template")) {
|
|
199
|
+
const second = nodes2[index + 2];
|
|
200
|
+
if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
|
|
201
|
+
const third = nodes2[index + 3];
|
|
202
|
+
if (third && third.type === "pseudo" && third.value === ":not" && (third.first.first.type === "attribute" && third.first.first.attribute === "hidden" || third.first.first.type === "tag" && third.first.first.value === "template")) {
|
|
203
|
+
const ast = getCombinatorSelectorAst(options);
|
|
204
|
+
selector.parent?.nodes.splice(
|
|
205
|
+
index + 1,
|
|
206
|
+
3,
|
|
207
|
+
...ast
|
|
208
|
+
);
|
|
211
209
|
}
|
|
212
210
|
}
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
}
|
|
216
|
-
} else {
|
|
217
|
-
if (selector.type === "class") {
|
|
218
|
-
selector.value = internalCssSelectorReplacer(selector.value, {
|
|
219
|
-
escapeMap,
|
|
220
|
-
mangleContext
|
|
221
|
-
});
|
|
222
|
-
} else {
|
|
223
|
-
selector.remove();
|
|
224
|
-
}
|
|
225
214
|
}
|
|
226
215
|
});
|
|
227
216
|
if (selectors.length === 0) {
|
|
@@ -331,9 +320,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
331
320
|
rule.remove();
|
|
332
321
|
}
|
|
333
322
|
rule.walkDecls((decl) => {
|
|
334
|
-
if (
|
|
335
|
-
decl.remove();
|
|
336
|
-
} else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
323
|
+
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
337
324
|
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
338
325
|
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
339
326
|
decl.value = "9999px";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"postcss-preset-env": "^10.2.4",
|
|
45
45
|
"postcss-rem-to-responsive-pixel": "~6.0.2",
|
|
46
46
|
"postcss-selector-parser": "~7.1.0",
|
|
47
|
-
"@weapp-tailwindcss/shared": "1.0.
|
|
47
|
+
"@weapp-tailwindcss/shared": "1.0.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"postcss-value-parser": "^4.2.0",
|
|
51
|
-
"@weapp-tailwindcss/mangle": "1.0.
|
|
51
|
+
"@weapp-tailwindcss/mangle": "1.0.5"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"dev": "tsup --watch --sourcemap",
|