@weapp-tailwindcss/postcss 1.0.10-alpha.1 → 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 CHANGED
@@ -664,18 +664,31 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
664
664
  } else {
665
665
  atRule.remove();
666
666
  }
667
- } else if (isTailwindcssV4ModernCheck(atRule)) {
668
- if (_optionalChain([atRule, 'access', _28 => _28.first, 'optionalAccess', _29 => _29.type]) === "atrule" && atRule.first.name === "layer") {
669
- atRule.replaceWith(atRule.first.nodes);
670
- }
671
667
  }
672
668
  }
673
669
  };
674
670
  if (opts.isMainChunk) {
671
+ let layerProperties;
675
672
  p.Once = (root) => {
676
673
  root.walkRules((rule) => {
677
674
  commonChunkPreflight(rule, opts);
678
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
+ });
679
692
  };
680
693
  }
681
694
  return p;
@@ -691,7 +704,7 @@ function compare(e3, t2) {
691
704
  return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
692
705
  }
693
706
  function selectorSpecificity(t2, s) {
694
- const i = _optionalChain([s, 'optionalAccess', _30 => _30.customSpecificity, 'optionalCall', _31 => _31(t2)]);
707
+ const i = _optionalChain([s, 'optionalAccess', _34 => _34.customSpecificity, 'optionalCall', _35 => _35(t2)]);
695
708
  if (i) return i;
696
709
  if (!t2) return { a: 0, b: 0, c: 0 };
697
710
  let c = 0, n = 0, o2 = 0;
@@ -767,7 +780,7 @@ function selectorSpecificity(t2, s) {
767
780
  case ":active-view-transition-type":
768
781
  return { a: 0, b: 1, c: 0 };
769
782
  }
770
- else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access', _32 => _32.nodes, 'optionalAccess', _33 => _33.length]) > 0 && t2.nodes.forEach((e3) => {
783
+ else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access', _36 => _36.nodes, 'optionalAccess', _37 => _37.length]) > 0 && t2.nodes.forEach((e3) => {
771
784
  const t3 = selectorSpecificity(e3, s);
772
785
  c += t3.a, n += t3.b, o2 += t3.c;
773
786
  });
@@ -795,8 +808,8 @@ function alwaysValidSelector(s) {
795
808
  const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
796
809
  let t2 = true;
797
810
  return o2.walk((e3) => {
798
- 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', _34 => _34.nodes, 'optionalAccess', _35 => _35.length]) || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
799
- if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _36 => _36.nodes, 'optionalAccess', _37 => _37.length]) && ":not" === e3.value.toLowerCase()) {
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()) {
800
813
  let s2 = true;
801
814
  if (e3.nodes[0].walkCombinators(() => {
802
815
  s2 = false;
@@ -908,8 +921,8 @@ function splitSelectors(o2, t2, n = 0) {
908
921
  if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
909
922
  if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
910
923
  if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
911
- if ("pseudo" === _optionalChain([e3, 'access', _38 => _38.parent, 'optionalAccess', _39 => _39.parent, 'optionalAccess', _40 => _40.type]) && ":not" === _optionalChain([e3, 'access', _41 => _41.parent, 'optionalAccess', _42 => _42.parent, 'optionalAccess', _43 => _43.value, 'optionalAccess', _44 => _44.toLowerCase, 'call', _45 => _45()])) return void i.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
912
- if ("pseudo" === _optionalChain([e3, 'access', _46 => _46.parent, 'optionalAccess', _47 => _47.parent, 'optionalAccess', _48 => _48.type]) && ":has" === _optionalChain([e3, 'access', _49 => _49.parent, 'optionalAccess', _50 => _50.parent, 'optionalAccess', _51 => _51.value, 'optionalAccess', _52 => _52.toLowerCase, 'call', _53 => _53()])) return void (e3.value = ":-csstools-matches");
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");
913
926
  let o4 = e3.parent;
914
927
  for (; o4; ) {
915
928
  if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (a = true);
@@ -931,7 +944,7 @@ function splitSelectors(o2, t2, n = 0) {
931
944
  let s = "";
932
945
  for (let t3 = 0; t3 < e3.length; t3++) {
933
946
  const n2 = e3[t3];
934
- s += o3.substring(_optionalChain([e3, 'access', _54 => _54[t3 - 1], 'optionalAccess', _55 => _55.end]) || 0, e3[t3].start), s += ":-csstools-matches(" + n2.option + ")", t3 === e3.length - 1 && (s += o3.substring(e3[t3].end));
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));
935
948
  }
936
949
  c.push(s);
937
950
  }), a && n < 10 && (c = splitSelectors(c, t2, n + 1)), c;
@@ -992,7 +1005,7 @@ function getPlugins(options) {
992
1005
  const ctx = createContext();
993
1006
  options.ctx = ctx;
994
1007
  const plugins = [
995
- ..._nullishCoalesce(_optionalChain([options, 'access', _56 => _56.postcssOptions, 'optionalAccess', _57 => _57.plugins]), () => ( [])),
1008
+ ..._nullishCoalesce(_optionalChain([options, 'access', _60 => _60.postcssOptions, 'optionalAccess', _61 => _61.plugins]), () => ( [])),
996
1009
  postcssWeappTailwindcssPrePlugin(options),
997
1010
  _postcsspresetenv2.default.call(void 0, options.cssPresetEnv)
998
1011
  ];
@@ -1036,7 +1049,7 @@ function styleHandler(rawSource, options) {
1036
1049
  getPlugins(options)
1037
1050
  ).process(
1038
1051
  rawSource,
1039
- _nullishCoalesce(_optionalChain([options, 'access', _58 => _58.postcssOptions, 'optionalAccess', _59 => _59.options]), () => ( {
1052
+ _nullishCoalesce(_optionalChain([options, 'access', _62 => _62.postcssOptions, 'optionalAccess', _63 => _63.options]), () => ( {
1040
1053
  from: void 0
1041
1054
  }))
1042
1055
  ).async();
package/dist/index.mjs CHANGED
@@ -664,18 +664,31 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
664
664
  } else {
665
665
  atRule.remove();
666
666
  }
667
- } else if (isTailwindcssV4ModernCheck(atRule)) {
668
- if (atRule.first?.type === "atrule" && atRule.first.name === "layer") {
669
- atRule.replaceWith(atRule.first.nodes);
670
- }
671
667
  }
672
668
  }
673
669
  };
674
670
  if (opts.isMainChunk) {
671
+ let layerProperties;
675
672
  p.Once = (root) => {
676
673
  root.walkRules((rule) => {
677
674
  commonChunkPreflight(rule, opts);
678
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
+ });
679
692
  };
680
693
  }
681
694
  return p;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.0.10-alpha.1",
3
+ "version": "1.0.10-alpha.2",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",