@weapp-tailwindcss/postcss 1.0.10-alpha.0 → 1.0.10-alpha.2
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 +32 -15
- package/dist/index.mjs +23 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -642,9 +642,13 @@ function commonChunkPreflight(node, options) {
|
|
|
642
642
|
function isAtMediaHover(atRule) {
|
|
643
643
|
return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || atRule.name === "media" && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params);
|
|
644
644
|
}
|
|
645
|
-
var TAILWIND_V4_MODERN_REGEX = /^\(\(-webkit-hyphens:\s*none\)\s+and\s+\(not\s+\(margin-trim:\s*inline\)\)\)\s+or\s+\(\(-moz-orient:\s*inline\)\s+and\s+\(not\s+\(color:\s*rgb\(from\s+red\s+r\s+g\s+b\)\)\)\)$/;
|
|
646
645
|
function isTailwindcssV4ModernCheck(atRule) {
|
|
647
|
-
return atRule.name === "supports" &&
|
|
646
|
+
return atRule.name === "supports" && [
|
|
647
|
+
/-webkit-hyphens\s*:\s*none/,
|
|
648
|
+
/margin-trim\s*:\s*inline/,
|
|
649
|
+
/-moz-orient\s*:\s*inline/,
|
|
650
|
+
/color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)/
|
|
651
|
+
].every((regex) => regex.test(atRule.params));
|
|
648
652
|
}
|
|
649
653
|
var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
650
654
|
const opts = _shared.defu.call(void 0, options, { isMainChunk: true });
|
|
@@ -660,18 +664,31 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
660
664
|
} else {
|
|
661
665
|
atRule.remove();
|
|
662
666
|
}
|
|
663
|
-
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
664
|
-
if (_optionalChain([atRule, 'access', _28 => _28.first, 'optionalAccess', _29 => _29.type]) === "atrule" && atRule.first.name === "layer") {
|
|
665
|
-
atRule.replaceWith(atRule.first.nodes);
|
|
666
|
-
}
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
};
|
|
670
670
|
if (opts.isMainChunk) {
|
|
671
|
+
let layerProperties;
|
|
671
672
|
p.Once = (root) => {
|
|
672
673
|
root.walkRules((rule) => {
|
|
673
674
|
commonChunkPreflight(rule, opts);
|
|
674
675
|
});
|
|
676
|
+
root.walkAtRules((atRule) => {
|
|
677
|
+
if (atRule.name === "layer" && atRule.params === "properties") {
|
|
678
|
+
if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _28 => _28.nodes, 'optionalAccess', _29 => _29.length]) === 0) {
|
|
679
|
+
layerProperties = atRule;
|
|
680
|
+
} else if (_optionalChain([atRule, 'access', _30 => _30.first, 'optionalAccess', _31 => _31.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
|
|
681
|
+
if (layerProperties) {
|
|
682
|
+
layerProperties.replaceWith(atRule.first.nodes);
|
|
683
|
+
atRule.remove();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
687
|
+
if (_optionalChain([atRule, 'access', _32 => _32.first, 'optionalAccess', _33 => _33.type]) === "atrule" && atRule.first.name === "layer") {
|
|
688
|
+
atRule.replaceWith(atRule.first.nodes);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
});
|
|
675
692
|
};
|
|
676
693
|
}
|
|
677
694
|
return p;
|
|
@@ -687,7 +704,7 @@ function compare(e3, t2) {
|
|
|
687
704
|
return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
|
|
688
705
|
}
|
|
689
706
|
function selectorSpecificity(t2, s) {
|
|
690
|
-
const i = _optionalChain([s, 'optionalAccess',
|
|
707
|
+
const i = _optionalChain([s, 'optionalAccess', _34 => _34.customSpecificity, 'optionalCall', _35 => _35(t2)]);
|
|
691
708
|
if (i) return i;
|
|
692
709
|
if (!t2) return { a: 0, b: 0, c: 0 };
|
|
693
710
|
let c = 0, n = 0, o2 = 0;
|
|
@@ -763,7 +780,7 @@ function selectorSpecificity(t2, s) {
|
|
|
763
780
|
case ":active-view-transition-type":
|
|
764
781
|
return { a: 0, b: 1, c: 0 };
|
|
765
782
|
}
|
|
766
|
-
else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access',
|
|
783
|
+
else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access', _36 => _36.nodes, 'optionalAccess', _37 => _37.length]) > 0 && t2.nodes.forEach((e3) => {
|
|
767
784
|
const t3 = selectorSpecificity(e3, s);
|
|
768
785
|
c += t3.a, n += t3.b, o2 += t3.c;
|
|
769
786
|
});
|
|
@@ -791,8 +808,8 @@ function alwaysValidSelector(s) {
|
|
|
791
808
|
const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
|
|
792
809
|
let t2 = true;
|
|
793
810
|
return o2.walk((e3) => {
|
|
794
|
-
if ("class" !== e3.type && "comment" !== e3.type && "id" !== e3.type && "root" !== e3.type && "selector" !== e3.type && "string" !== e3.type && "tag" !== e3.type && "universal" !== e3.type && ("attribute" !== e3.type || e3.insensitive) && ("combinator" !== e3.type || "+" !== e3.value && ">" !== e3.value && "~" !== e3.value && " " !== e3.value) && ("pseudo" !== e3.type || _optionalChain([e3, 'access',
|
|
795
|
-
if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access',
|
|
811
|
+
if ("class" !== e3.type && "comment" !== e3.type && "id" !== e3.type && "root" !== e3.type && "selector" !== e3.type && "string" !== e3.type && "tag" !== e3.type && "universal" !== e3.type && ("attribute" !== e3.type || e3.insensitive) && ("combinator" !== e3.type || "+" !== e3.value && ">" !== e3.value && "~" !== e3.value && " " !== e3.value) && ("pseudo" !== e3.type || _optionalChain([e3, 'access', _38 => _38.nodes, 'optionalAccess', _39 => _39.length]) || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
|
|
812
|
+
if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _40 => _40.nodes, 'optionalAccess', _41 => _41.length]) && ":not" === e3.value.toLowerCase()) {
|
|
796
813
|
let s2 = true;
|
|
797
814
|
if (e3.nodes[0].walkCombinators(() => {
|
|
798
815
|
s2 = false;
|
|
@@ -904,8 +921,8 @@ function splitSelectors(o2, t2, n = 0) {
|
|
|
904
921
|
if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
|
|
905
922
|
if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
|
|
906
923
|
if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
|
|
907
|
-
if ("pseudo" === _optionalChain([e3, 'access',
|
|
908
|
-
if ("pseudo" === _optionalChain([e3, 'access',
|
|
924
|
+
if ("pseudo" === _optionalChain([e3, 'access', _42 => _42.parent, 'optionalAccess', _43 => _43.parent, 'optionalAccess', _44 => _44.type]) && ":not" === _optionalChain([e3, 'access', _45 => _45.parent, 'optionalAccess', _46 => _46.parent, 'optionalAccess', _47 => _47.value, 'optionalAccess', _48 => _48.toLowerCase, 'call', _49 => _49()])) return void i.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
|
|
925
|
+
if ("pseudo" === _optionalChain([e3, 'access', _50 => _50.parent, 'optionalAccess', _51 => _51.parent, 'optionalAccess', _52 => _52.type]) && ":has" === _optionalChain([e3, 'access', _53 => _53.parent, 'optionalAccess', _54 => _54.parent, 'optionalAccess', _55 => _55.value, 'optionalAccess', _56 => _56.toLowerCase, 'call', _57 => _57()])) return void (e3.value = ":-csstools-matches");
|
|
909
926
|
let o4 = e3.parent;
|
|
910
927
|
for (; o4; ) {
|
|
911
928
|
if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (a = true);
|
|
@@ -927,7 +944,7 @@ function splitSelectors(o2, t2, n = 0) {
|
|
|
927
944
|
let s = "";
|
|
928
945
|
for (let t3 = 0; t3 < e3.length; t3++) {
|
|
929
946
|
const n2 = e3[t3];
|
|
930
|
-
s += o3.substring(_optionalChain([e3, 'access',
|
|
947
|
+
s += o3.substring(_optionalChain([e3, 'access', _58 => _58[t3 - 1], 'optionalAccess', _59 => _59.end]) || 0, e3[t3].start), s += ":-csstools-matches(" + n2.option + ")", t3 === e3.length - 1 && (s += o3.substring(e3[t3].end));
|
|
931
948
|
}
|
|
932
949
|
c.push(s);
|
|
933
950
|
}), a && n < 10 && (c = splitSelectors(c, t2, n + 1)), c;
|
|
@@ -988,7 +1005,7 @@ function getPlugins(options) {
|
|
|
988
1005
|
const ctx = createContext();
|
|
989
1006
|
options.ctx = ctx;
|
|
990
1007
|
const plugins = [
|
|
991
|
-
..._nullishCoalesce(_optionalChain([options, 'access',
|
|
1008
|
+
..._nullishCoalesce(_optionalChain([options, 'access', _60 => _60.postcssOptions, 'optionalAccess', _61 => _61.plugins]), () => ( [])),
|
|
992
1009
|
postcssWeappTailwindcssPrePlugin(options),
|
|
993
1010
|
_postcsspresetenv2.default.call(void 0, options.cssPresetEnv)
|
|
994
1011
|
];
|
|
@@ -1032,7 +1049,7 @@ function styleHandler(rawSource, options) {
|
|
|
1032
1049
|
getPlugins(options)
|
|
1033
1050
|
).process(
|
|
1034
1051
|
rawSource,
|
|
1035
|
-
_nullishCoalesce(_optionalChain([options, 'access',
|
|
1052
|
+
_nullishCoalesce(_optionalChain([options, 'access', _62 => _62.postcssOptions, 'optionalAccess', _63 => _63.options]), () => ( {
|
|
1036
1053
|
from: void 0
|
|
1037
1054
|
}))
|
|
1038
1055
|
).async();
|
package/dist/index.mjs
CHANGED
|
@@ -642,9 +642,13 @@ function commonChunkPreflight(node, options) {
|
|
|
642
642
|
function isAtMediaHover(atRule) {
|
|
643
643
|
return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || atRule.name === "media" && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params);
|
|
644
644
|
}
|
|
645
|
-
var TAILWIND_V4_MODERN_REGEX = /^\(\(-webkit-hyphens:\s*none\)\s+and\s+\(not\s+\(margin-trim:\s*inline\)\)\)\s+or\s+\(\(-moz-orient:\s*inline\)\s+and\s+\(not\s+\(color:\s*rgb\(from\s+red\s+r\s+g\s+b\)\)\)\)$/;
|
|
646
645
|
function isTailwindcssV4ModernCheck(atRule) {
|
|
647
|
-
return atRule.name === "supports" &&
|
|
646
|
+
return atRule.name === "supports" && [
|
|
647
|
+
/-webkit-hyphens\s*:\s*none/,
|
|
648
|
+
/margin-trim\s*:\s*inline/,
|
|
649
|
+
/-moz-orient\s*:\s*inline/,
|
|
650
|
+
/color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)/
|
|
651
|
+
].every((regex) => regex.test(atRule.params));
|
|
648
652
|
}
|
|
649
653
|
var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
650
654
|
const opts = defu2(options, { isMainChunk: true });
|
|
@@ -660,18 +664,31 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
|
|
|
660
664
|
} else {
|
|
661
665
|
atRule.remove();
|
|
662
666
|
}
|
|
663
|
-
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
664
|
-
if (atRule.first?.type === "atrule" && atRule.first.name === "layer") {
|
|
665
|
-
atRule.replaceWith(atRule.first.nodes);
|
|
666
|
-
}
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
};
|
|
670
670
|
if (opts.isMainChunk) {
|
|
671
|
+
let layerProperties;
|
|
671
672
|
p.Once = (root) => {
|
|
672
673
|
root.walkRules((rule) => {
|
|
673
674
|
commonChunkPreflight(rule, opts);
|
|
674
675
|
});
|
|
676
|
+
root.walkAtRules((atRule) => {
|
|
677
|
+
if (atRule.name === "layer" && atRule.params === "properties") {
|
|
678
|
+
if (atRule.nodes === void 0 || atRule.nodes?.length === 0) {
|
|
679
|
+
layerProperties = atRule;
|
|
680
|
+
} else if (atRule.first?.type === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
|
|
681
|
+
if (layerProperties) {
|
|
682
|
+
layerProperties.replaceWith(atRule.first.nodes);
|
|
683
|
+
atRule.remove();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
} else if (isTailwindcssV4ModernCheck(atRule)) {
|
|
687
|
+
if (atRule.first?.type === "atrule" && atRule.first.name === "layer") {
|
|
688
|
+
atRule.replaceWith(atRule.first.nodes);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
});
|
|
675
692
|
};
|
|
676
693
|
}
|
|
677
694
|
return p;
|