@weapp-tailwindcss/postcss 1.0.22-alpha.0 → 1.1.0
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 +34 -30
- package/dist/index.mjs +37 -33
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ function createContext() {
|
|
|
59
59
|
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
60
60
|
|
|
61
61
|
// src/selectorParser.ts
|
|
62
|
+
|
|
62
63
|
var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
|
|
63
64
|
|
|
64
65
|
// src/shared.ts
|
|
@@ -146,6 +147,9 @@ function createRuleTransform(rule, options) {
|
|
|
146
147
|
if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
|
|
147
148
|
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
148
149
|
} else if (selector.value === ":where") {
|
|
150
|
+
if (uniAppX) {
|
|
151
|
+
selector.value = ":is";
|
|
152
|
+
}
|
|
149
153
|
if (index === 0 && selector.length === 1) {
|
|
150
154
|
selector.walk((node, idx) => {
|
|
151
155
|
if (idx === 0 && node.type === "class") {
|
|
@@ -190,9 +194,6 @@ function createRuleTransform(rule, options) {
|
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
|
-
if (uniAppX) {
|
|
194
|
-
selector.remove();
|
|
195
|
-
}
|
|
196
197
|
} else if (selector.type === "combinator") {
|
|
197
198
|
if (selector.value === ">") {
|
|
198
199
|
const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
|
|
@@ -259,7 +260,8 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
|
259
260
|
}).astSync(node);
|
|
260
261
|
return b && a;
|
|
261
262
|
}
|
|
262
|
-
function getFallbackRemove(rule) {
|
|
263
|
+
function getFallbackRemove(rule, options) {
|
|
264
|
+
const { uniAppX } = _shared.defuOverrideArray.call(void 0, options, {});
|
|
263
265
|
const fallbackRemove = _postcssselectorparser2.default.call(void 0, (selectors) => {
|
|
264
266
|
let maybeImportantId = false;
|
|
265
267
|
selectors.walk((selector, idx) => {
|
|
@@ -307,6 +309,10 @@ function getFallbackRemove(rule) {
|
|
|
307
309
|
if (res) {
|
|
308
310
|
selector.remove();
|
|
309
311
|
}
|
|
312
|
+
} else if (selector.type === "pseudo") {
|
|
313
|
+
if (uniAppX) {
|
|
314
|
+
selector.remove();
|
|
315
|
+
}
|
|
310
316
|
}
|
|
311
317
|
}
|
|
312
318
|
});
|
|
@@ -324,34 +330,32 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
324
330
|
postcssPlugin
|
|
325
331
|
};
|
|
326
332
|
if (opts.isMainChunk) {
|
|
327
|
-
p.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
lossless: false
|
|
332
|
-
});
|
|
333
|
-
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
334
|
-
rule.remove();
|
|
335
|
-
}
|
|
336
|
-
rule.walkDecls((decl) => {
|
|
337
|
-
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
338
|
-
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
339
|
-
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
340
|
-
decl.value = "9999px";
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
if (opts.uniAppX) {
|
|
344
|
-
if (rule.nodes.length === 0) {
|
|
345
|
-
rule.remove();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
333
|
+
p.RuleExit = (rule) => {
|
|
334
|
+
getFallbackRemove(rule, opts).transformSync(rule, {
|
|
335
|
+
updateSelector: true,
|
|
336
|
+
lossless: false
|
|
348
337
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
338
|
+
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
339
|
+
rule.remove();
|
|
340
|
+
}
|
|
341
|
+
if (opts.uniAppX) {
|
|
342
|
+
if (rule.nodes.length === 0) {
|
|
343
|
+
rule.remove();
|
|
352
344
|
}
|
|
353
|
-
|
|
354
|
-
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
p.DeclarationExit = (decl) => {
|
|
348
|
+
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
349
|
+
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
350
|
+
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
351
|
+
decl.value = "9999px";
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
p.AtRuleExit = (atRule) => {
|
|
355
|
+
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
356
|
+
atRule.remove();
|
|
357
|
+
}
|
|
358
|
+
_optionalChain([atRule, 'access', _24 => _24.nodes, 'optionalAccess', _25 => _25.length]) === 0 && atRule.remove();
|
|
355
359
|
};
|
|
356
360
|
}
|
|
357
361
|
if (typeof opts.customRuleCallback === "function") {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./chunk-WAXGOBY2.mjs";
|
|
2
2
|
|
|
3
3
|
// src/handler.ts
|
|
4
|
-
import { defu as defu3, defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
4
|
+
import { defu as defu3, defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
5
5
|
import postcss from "postcss";
|
|
6
6
|
|
|
7
7
|
// src/defaults.ts
|
|
@@ -59,6 +59,7 @@ import { defu } from "@weapp-tailwindcss/shared";
|
|
|
59
59
|
var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
60
60
|
|
|
61
61
|
// src/selectorParser.ts
|
|
62
|
+
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
62
63
|
import psp from "postcss-selector-parser";
|
|
63
64
|
|
|
64
65
|
// src/shared.ts
|
|
@@ -146,6 +147,9 @@ function createRuleTransform(rule, options) {
|
|
|
146
147
|
if (selector.value === ":root" && cssSelectorReplacement?.root) {
|
|
147
148
|
selector.value = composeIsPseudo(cssSelectorReplacement.root);
|
|
148
149
|
} else if (selector.value === ":where") {
|
|
150
|
+
if (uniAppX) {
|
|
151
|
+
selector.value = ":is";
|
|
152
|
+
}
|
|
149
153
|
if (index === 0 && selector.length === 1) {
|
|
150
154
|
selector.walk((node, idx) => {
|
|
151
155
|
if (idx === 0 && node.type === "class") {
|
|
@@ -190,9 +194,6 @@ function createRuleTransform(rule, options) {
|
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
|
-
if (uniAppX) {
|
|
194
|
-
selector.remove();
|
|
195
|
-
}
|
|
196
197
|
} else if (selector.type === "combinator") {
|
|
197
198
|
if (selector.value === ">") {
|
|
198
199
|
const nodes2 = selector.parent?.nodes;
|
|
@@ -259,7 +260,8 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
|
|
|
259
260
|
}).astSync(node);
|
|
260
261
|
return b && a;
|
|
261
262
|
}
|
|
262
|
-
function getFallbackRemove(rule) {
|
|
263
|
+
function getFallbackRemove(rule, options) {
|
|
264
|
+
const { uniAppX } = defuOverrideArray(options, {});
|
|
263
265
|
const fallbackRemove = psp((selectors) => {
|
|
264
266
|
let maybeImportantId = false;
|
|
265
267
|
selectors.walk((selector, idx) => {
|
|
@@ -307,6 +309,10 @@ function getFallbackRemove(rule) {
|
|
|
307
309
|
if (res) {
|
|
308
310
|
selector.remove();
|
|
309
311
|
}
|
|
312
|
+
} else if (selector.type === "pseudo") {
|
|
313
|
+
if (uniAppX) {
|
|
314
|
+
selector.remove();
|
|
315
|
+
}
|
|
310
316
|
}
|
|
311
317
|
}
|
|
312
318
|
});
|
|
@@ -324,34 +330,32 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
|
|
|
324
330
|
postcssPlugin
|
|
325
331
|
};
|
|
326
332
|
if (opts.isMainChunk) {
|
|
327
|
-
p.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
lossless: false
|
|
332
|
-
});
|
|
333
|
-
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
334
|
-
rule.remove();
|
|
335
|
-
}
|
|
336
|
-
rule.walkDecls((decl) => {
|
|
337
|
-
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
338
|
-
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
339
|
-
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
340
|
-
decl.value = "9999px";
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
if (opts.uniAppX) {
|
|
344
|
-
if (rule.nodes.length === 0) {
|
|
345
|
-
rule.remove();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
333
|
+
p.RuleExit = (rule) => {
|
|
334
|
+
getFallbackRemove(rule, opts).transformSync(rule, {
|
|
335
|
+
updateSelector: true,
|
|
336
|
+
lossless: false
|
|
348
337
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
338
|
+
if (rule.selectors.length === 0 || rule.selectors.length === 1 && rule.selector.trim() === "") {
|
|
339
|
+
rule.remove();
|
|
340
|
+
}
|
|
341
|
+
if (opts.uniAppX) {
|
|
342
|
+
if (rule.nodes.length === 0) {
|
|
343
|
+
rule.remove();
|
|
352
344
|
}
|
|
353
|
-
|
|
354
|
-
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
p.DeclarationExit = (decl) => {
|
|
348
|
+
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
|
|
349
|
+
decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
|
|
350
|
+
} else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
|
|
351
|
+
decl.value = "9999px";
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
p.AtRuleExit = (atRule) => {
|
|
355
|
+
if (opts.cssRemoveProperty && atRule.name === "property") {
|
|
356
|
+
atRule.remove();
|
|
357
|
+
}
|
|
358
|
+
atRule.nodes?.length === 0 && atRule.remove();
|
|
355
359
|
};
|
|
356
360
|
}
|
|
357
361
|
if (typeof opts.customRuleCallback === "function") {
|
|
@@ -1289,7 +1293,7 @@ function styleHandler(rawSource, options) {
|
|
|
1289
1293
|
).async();
|
|
1290
1294
|
}
|
|
1291
1295
|
function createStyleHandler(options) {
|
|
1292
|
-
const cachedOptions =
|
|
1296
|
+
const cachedOptions = defuOverrideArray2(
|
|
1293
1297
|
options,
|
|
1294
1298
|
getDefaultOptions()
|
|
1295
1299
|
);
|
|
@@ -1297,7 +1301,7 @@ function createStyleHandler(options) {
|
|
|
1297
1301
|
return (rawSource, opt) => {
|
|
1298
1302
|
return styleHandler(
|
|
1299
1303
|
rawSource,
|
|
1300
|
-
|
|
1304
|
+
defuOverrideArray2(opt, cachedOptions)
|
|
1301
1305
|
);
|
|
1302
1306
|
};
|
|
1303
1307
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@weapp-core/escape": "~4.0.1",
|
|
43
43
|
"postcss": "~8.5.6",
|
|
44
|
-
"postcss-preset-env": "^10.
|
|
44
|
+
"postcss-preset-env": "^10.3.0",
|
|
45
45
|
"postcss-rem-to-responsive-pixel": "~6.0.2",
|
|
46
46
|
"postcss-selector-parser": "~7.1.0",
|
|
47
47
|
"@weapp-tailwindcss/shared": "1.0.3"
|