@weapp-tailwindcss/postcss 1.0.11 → 1.0.13-beta.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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-Ca68m5Pt.mjs';
2
- export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-Ca68m5Pt.mjs';
1
+ import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-tu70dcVo.mjs';
2
+ export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-tu70dcVo.mjs';
3
3
  import postcss from 'postcss';
4
4
  import '@weapp-tailwindcss/mangle';
5
5
  import 'postcss-load-config';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-Ca68m5Pt.js';
2
- export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-Ca68m5Pt.js';
1
+ import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-tu70dcVo.js';
2
+ export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-tu70dcVo.js';
3
3
  import postcss from 'postcss';
4
4
  import '@weapp-tailwindcss/mangle';
5
5
  import 'postcss-load-config';
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postc
7
7
  // src/defaults.ts
8
8
  function getDefaultOptions() {
9
9
  return {
10
+ // https://github.com/postcss/postcss-calc
10
11
  cssPresetEnv: {
11
12
  features: {
12
13
  "cascade-layers": true,
@@ -122,92 +123,103 @@ function getCombinatorSelectorAst(options) {
122
123
  return childCombinatorReplaceValue;
123
124
  }
124
125
  function createRuleTransform(rule, options) {
125
- const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
126
+ const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass, uniAppX } = options;
126
127
  const transform = (selectors) => {
127
128
  selectors.walk((selector, index) => {
128
- if (selector.type === "universal") {
129
- if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
130
- selector.value = composeIsPseudo(cssSelectorReplacement.universal);
131
- }
132
- } else if (selector.type === "selector") {
133
- if (cssRemoveHoverPseudoClass) {
134
- const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
135
- if (node) {
136
- selector.remove();
129
+ if (!uniAppX) {
130
+ if (selector.type === "class") {
131
+ selector.value = internalCssSelectorReplacer(selector.value, {
132
+ escapeMap,
133
+ mangleContext
134
+ });
135
+ } else if (selector.type === "universal") {
136
+ if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
137
+ selector.value = composeIsPseudo(cssSelectorReplacement.universal);
137
138
  }
138
- }
139
- } else if (selector.type === "pseudo") {
140
- if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
141
- selector.value = composeIsPseudo(cssSelectorReplacement.root);
142
- } else if (selector.value === ":where") {
143
- if (index === 0 && selector.length === 1) {
144
- selector.walk((node, idx) => {
145
- if (idx === 0 && node.type === "class") {
146
- const nodes = _optionalChain([node, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.nodes]);
147
- if (nodes) {
148
- const first = nodes[idx + 1];
149
- if (first && first.type === "combinator" && first.value === ">") {
150
- const second = nodes[idx + 2];
151
- if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
152
- const ast = getCombinatorSelectorAst(options);
153
- second.replaceWith(
154
- ...ast
155
- );
139
+ } else if (selector.type === "selector") {
140
+ if (cssRemoveHoverPseudoClass) {
141
+ const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
142
+ if (node) {
143
+ selector.remove();
144
+ }
145
+ }
146
+ } else if (selector.type === "pseudo") {
147
+ if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
148
+ selector.value = composeIsPseudo(cssSelectorReplacement.root);
149
+ } else if (selector.value === ":where") {
150
+ if (index === 0 && selector.length === 1) {
151
+ selector.walk((node, idx) => {
152
+ if (idx === 0 && node.type === "class") {
153
+ const nodes2 = _optionalChain([node, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.nodes]);
154
+ if (nodes2) {
155
+ const first = nodes2[idx + 1];
156
+ if (first && first.type === "combinator" && first.value === ">") {
157
+ const second = nodes2[idx + 2];
158
+ if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
159
+ const ast = getCombinatorSelectorAst(options);
160
+ second.replaceWith(
161
+ ...ast
162
+ );
163
+ }
156
164
  }
157
165
  }
158
166
  }
159
- }
160
- });
161
- selector.replaceWith(...selector.nodes);
162
- for (const node of rule.nodes) {
163
- if (node.type === "decl") {
164
- if (node.prop === "margin-block-start") {
165
- node.prop = "margin-block-end";
166
- } else if (node.prop === "margin-block-end") {
167
- node.prop = "margin-block-start";
168
- } else if (node.prop === "margin-inline-start") {
169
- node.prop = "margin-inline-end";
170
- } else if (node.prop === "margin-inline-end") {
171
- node.prop = "margin-inline-start";
172
- } else if (node.prop === "margin-top") {
173
- node.prop = "margin-bottom";
174
- } else if (node.prop === "margin-bottom") {
175
- node.prop = "margin-top";
176
- } else if (node.prop === "margin-left") {
177
- node.prop = "margin-right";
178
- } else if (node.prop === "margin-right") {
179
- node.prop = "margin-left";
167
+ });
168
+ selector.replaceWith(...selector.nodes);
169
+ for (const node of rule.nodes) {
170
+ if (node.type === "decl") {
171
+ if (node.prop === "margin-block-start") {
172
+ node.prop = "margin-block-end";
173
+ } else if (node.prop === "margin-block-end") {
174
+ node.prop = "margin-block-start";
175
+ } else if (node.prop === "margin-inline-start") {
176
+ node.prop = "margin-inline-end";
177
+ } else if (node.prop === "margin-inline-end") {
178
+ node.prop = "margin-inline-start";
179
+ } else if (node.prop === "margin-top") {
180
+ node.prop = "margin-bottom";
181
+ } else if (node.prop === "margin-bottom") {
182
+ node.prop = "margin-top";
183
+ } else if (node.prop === "margin-left") {
184
+ node.prop = "margin-right";
185
+ } else if (node.prop === "margin-right") {
186
+ node.prop = "margin-left";
187
+ }
180
188
  }
181
189
  }
182
190
  }
183
191
  }
184
- }
185
- } else if (selector.type === "class") {
186
- selector.value = internalCssSelectorReplacer(selector.value, {
187
- escapeMap,
188
- mangleContext
189
- });
190
- } else if (selector.type === "combinator") {
191
- if (selector.value === ">") {
192
- const nodes = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
193
- if (nodes) {
194
- const first = nodes[index + 1];
195
- 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")) {
196
- const second = nodes[index + 2];
197
- if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
198
- const third = nodes[index + 3];
199
- 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")) {
200
- const ast = getCombinatorSelectorAst(options);
201
- _optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
202
- index + 1,
203
- 3,
204
- ...ast
205
- )]);
192
+ } else if (selector.type === "combinator") {
193
+ if (selector.value === ">") {
194
+ const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
195
+ if (nodes2) {
196
+ const first = nodes2[index + 1];
197
+ 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")) {
198
+ const second = nodes2[index + 2];
199
+ if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
200
+ const third = nodes2[index + 3];
201
+ 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")) {
202
+ const ast = getCombinatorSelectorAst(options);
203
+ _optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
204
+ index + 1,
205
+ 3,
206
+ ...ast
207
+ )]);
208
+ }
206
209
  }
207
210
  }
208
211
  }
209
212
  }
210
213
  }
214
+ } else {
215
+ if (selector.type === "class") {
216
+ selector.value = internalCssSelectorReplacer(selector.value, {
217
+ escapeMap,
218
+ mangleContext
219
+ });
220
+ } else {
221
+ selector.remove();
222
+ }
211
223
  }
212
224
  });
213
225
  if (selectors.length === 0) {
@@ -317,19 +329,31 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
317
329
  rule.remove();
318
330
  }
319
331
  rule.walkDecls((decl) => {
320
- if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
332
+ if (opts.uniAppX && decl.prop.startsWith("--")) {
333
+ decl.remove();
334
+ } else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
321
335
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
336
+ } else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
337
+ decl.value = "9999px";
322
338
  }
323
339
  });
340
+ if (opts.uniAppX) {
341
+ if (rule.nodes.length === 0) {
342
+ rule.remove();
343
+ }
344
+ }
324
345
  });
325
- opts.cssRemoveProperty && root.walkAtRules("property", (rule) => {
326
- rule.remove();
346
+ root.walkAtRules((atRule) => {
347
+ if (opts.cssRemoveProperty && atRule.name === "property") {
348
+ atRule.remove();
349
+ }
350
+ _optionalChain([atRule, 'access', _24 => _24.nodes, 'optionalAccess', _25 => _25.length]) === 0 && atRule.remove();
327
351
  });
328
352
  };
329
353
  }
330
354
  if (typeof opts.customRuleCallback === "function") {
331
355
  p.Rule = (rule) => {
332
- _optionalChain([opts, 'access', _24 => _24.customRuleCallback, 'optionalCall', _25 => _25(rule, opts)]);
356
+ _optionalChain([opts, 'access', _26 => _26.customRuleCallback, 'optionalCall', _27 => _27(rule, opts)]);
333
357
  };
334
358
  }
335
359
  return p;
@@ -342,8 +366,8 @@ postcssWeappTailwindcssPostPlugin.postcss = true;
342
366
  // src/mp.ts
343
367
 
344
368
 
345
- // src/cssVars.ts
346
- var cssVars_default = [
369
+ // src/cssVarsV3.ts
370
+ var cssVarsV3_default = [
347
371
  {
348
372
  prop: "--tw-border-spacing-x",
349
373
  value: "0"
@@ -550,8 +574,152 @@ var cssVars_default = [
550
574
  }
551
575
  ];
552
576
 
577
+ // src/cssVarsV4.ts
578
+ function property(ident, initialValue, _syntax) {
579
+ return {
580
+ prop: ident,
581
+ value: initialValue || ""
582
+ };
583
+ }
584
+ var nullShadow = "0 0 #0000";
585
+ var nodes = [
586
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1137
587
+ property("--tw-border-spacing-x", "0", "<length>"),
588
+ property("--tw-border-spacing-y", "0", "<length>"),
589
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1205
590
+ property("--tw-translate-x", "0"),
591
+ property("--tw-translate-y", "0"),
592
+ property("--tw-translate-z", "0"),
593
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1285
594
+ property("--tw-scale-x", "1"),
595
+ property("--tw-scale-y", "1"),
596
+ property("--tw-scale-z", "1"),
597
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1424
598
+ property("--tw-rotate-x"),
599
+ property("--tw-rotate-y"),
600
+ property("--tw-rotate-z"),
601
+ property("--tw-skew-x"),
602
+ property("--tw-skew-y"),
603
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1641C13-L1641C88
604
+ property("--tw-pan-x"),
605
+ property("--tw-pan-y"),
606
+ property("--tw-pinch-zoom"),
607
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1688C38-L1688C95
608
+ property("--tw-scroll-snap-strictness", "proximity", "*"),
609
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1688C38-L1688C95
610
+ property("--tw-space-x-reverse", "0"),
611
+ property("--tw-space-y-reverse", "0"),
612
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L2169C22-L2169C60
613
+ property("--tw-border-style", "solid"),
614
+ property("--tw-divide-x-reverse", "0"),
615
+ property("--tw-divide-y-reverse", "0"),
616
+ property("--tw-gradient-position"),
617
+ property("--tw-gradient-from", "#0000", "<color>"),
618
+ property("--tw-gradient-via", "#0000", "<color>"),
619
+ property("--tw-gradient-to", "#0000", "<color>"),
620
+ property("--tw-gradient-stops"),
621
+ property("--tw-gradient-via-stops"),
622
+ property("--tw-gradient-from-position", "0%", "<length-percentage>"),
623
+ property("--tw-gradient-via-position", "50%", "<length-percentage>"),
624
+ property("--tw-gradient-to-position", "100%", "<length-percentage>"),
625
+ property("--tw-mask-linear", "linear-gradient(#fff, #fff)"),
626
+ property("--tw-mask-radial", "linear-gradient(#fff, #fff)"),
627
+ property("--tw-mask-conic", "linear-gradient(#fff, #fff)"),
628
+ property("--tw-mask-left", "linear-gradient(#fff, #fff)"),
629
+ property("--tw-mask-right", "linear-gradient(#fff, #fff)"),
630
+ property("--tw-mask-bottom", "linear-gradient(#fff, #fff)"),
631
+ property("--tw-mask-top", "linear-gradient(#fff, #fff)"),
632
+ property("--tw-mask-linear-position", "0deg"),
633
+ property("--tw-mask-linear-from-position", "0%"),
634
+ property("--tw-mask-linear-to-position", "100%"),
635
+ property("--tw-mask-linear-from-color", "black"),
636
+ property("--tw-mask-linear-to-color", "transparent"),
637
+ property("--tw-mask-radial-from-position", "0%"),
638
+ property("--tw-mask-radial-to-position", "100%"),
639
+ property("--tw-mask-radial-from-color", "black"),
640
+ property("--tw-mask-radial-to-color", "transparent"),
641
+ property("--tw-mask-radial-shape", "ellipse"),
642
+ property("--tw-mask-radial-size", "farthest-corner"),
643
+ property("--tw-mask-radial-position", "center"),
644
+ property("--tw-mask-conic-position", "0deg"),
645
+ property("--tw-mask-conic-from-position", "0%"),
646
+ property("--tw-mask-conic-to-position", "100%"),
647
+ property("--tw-mask-conic-from-color", "black"),
648
+ property("--tw-mask-conic-to-color", "transparent"),
649
+ property("--tw-font-weight"),
650
+ property("--tw-blur"),
651
+ property("--tw-brightness"),
652
+ property("--tw-contrast"),
653
+ property("--tw-grayscale"),
654
+ property("--tw-hue-rotate"),
655
+ property("--tw-invert"),
656
+ property("--tw-opacity"),
657
+ property("--tw-saturate"),
658
+ property("--tw-sepia"),
659
+ property("--tw-drop-shadow"),
660
+ property("--tw-drop-shadow-color"),
661
+ property("--tw-drop-shadow-alpha", "100%", "<percentage>"),
662
+ property("--tw-drop-shadow-size"),
663
+ property("--tw-backdrop-blur"),
664
+ property("--tw-backdrop-brightness"),
665
+ property("--tw-backdrop-contrast"),
666
+ property("--tw-backdrop-grayscale"),
667
+ property("--tw-backdrop-hue-rotate"),
668
+ property("--tw-backdrop-invert"),
669
+ property("--tw-backdrop-opacity"),
670
+ property("--tw-backdrop-saturate"),
671
+ property("--tw-backdrop-sepia"),
672
+ property("--tw-duration"),
673
+ property("--tw-ease"),
674
+ property("--tw-content", '""'),
675
+ property("--tw-contain-size"),
676
+ property("--tw-contain-layout"),
677
+ property("--tw-contain-paint"),
678
+ property("--tw-contain-style"),
679
+ property("--tw-leading"),
680
+ property("--tw-tracking"),
681
+ property("--tw-ordinal"),
682
+ property("--tw-slashed-zero"),
683
+ property("--tw-numeric-figure"),
684
+ property("--tw-numeric-spacing"),
685
+ property("--tw-numeric-fraction"),
686
+ property("--tw-outline-style", "solid"),
687
+ property("--tw-text-shadow-color"),
688
+ property("--tw-text-shadow-alpha", "100%", "<percentage>"),
689
+ property("--tw-shadow", nullShadow),
690
+ property("--tw-shadow-color"),
691
+ property("--tw-shadow-alpha", "100%", "<percentage>"),
692
+ property("--tw-inset-shadow", nullShadow),
693
+ property("--tw-inset-shadow-color"),
694
+ property("--tw-inset-shadow-alpha", "100%", "<percentage>"),
695
+ property("--tw-ring-color"),
696
+ property("--tw-ring-shadow", nullShadow),
697
+ property("--tw-inset-ring-color"),
698
+ property("--tw-inset-ring-shadow", nullShadow),
699
+ // Legacy
700
+ property("--tw-ring-inset"),
701
+ property("--tw-ring-offset-width", "0px", "<length>"),
702
+ property("--tw-ring-offset-color", "#fff"),
703
+ property("--tw-ring-offset-shadow", nullShadow)
704
+ ];
705
+ for (const edge of ["top", "right", "bottom", "left"]) {
706
+ nodes.push(
707
+ property(`--tw-mask-${edge}-from-position`, "0%"),
708
+ property(`--tw-mask-${edge}-to-position`, "100%"),
709
+ property(`--tw-mask-${edge}-from-color`, "black"),
710
+ property(`--tw-mask-${edge}-to-color`, "transparent")
711
+ );
712
+ }
713
+ var cssVarsV4_default = nodes;
714
+
553
715
  // src/mp.ts
554
- var initialNodes = cssVars_default.map((x) => {
716
+ var cssVarsV3Nodes = cssVarsV3_default.map((x) => {
717
+ return new (0, _postcss.Declaration)({
718
+ prop: x.prop,
719
+ value: x.value
720
+ });
721
+ });
722
+ var cssVarsV4Nodes = cssVarsV4_default.map((x) => {
555
723
  return new (0, _postcss.Declaration)({
556
724
  prop: x.prop,
557
725
  value: x.value
@@ -559,9 +727,9 @@ var initialNodes = cssVars_default.map((x) => {
559
727
  });
560
728
  function testIfVariablesScope(node, count = 2) {
561
729
  if (isOnlyBeforeAndAfterPseudoElement(node)) {
562
- const nodes = node.nodes;
730
+ const nodes2 = node.nodes;
563
731
  let c = 0;
564
- for (const tryTestDecl of nodes) {
732
+ for (const tryTestDecl of nodes2) {
565
733
  if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
566
734
  c++;
567
735
  }
@@ -575,9 +743,9 @@ function testIfVariablesScope(node, count = 2) {
575
743
  }
576
744
  function testIfTwBackdrop(node, count = 2) {
577
745
  if (node.type === "rule" && node.selector === "::backdrop") {
578
- const nodes = node.nodes;
746
+ const nodes2 = node.nodes;
579
747
  let c = 0;
580
- for (const tryTestDecl of nodes) {
748
+ for (const tryTestDecl of nodes2) {
581
749
  if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
582
750
  c++;
583
751
  }
@@ -589,6 +757,9 @@ function testIfTwBackdrop(node, count = 2) {
589
757
  }
590
758
  return false;
591
759
  }
760
+ function testIfRootHostForV4(node) {
761
+ return node.type === "rule" && node.selector.includes(":root") && node.selector.includes(":host");
762
+ }
592
763
  function makePseudoVarRule() {
593
764
  const pseudoVarRule = new (0, _postcss.Rule)({
594
765
  // selectors: ['::before', '::after'],
@@ -623,17 +794,18 @@ function remakeCssVarSelector(selectors, options) {
623
794
  function commonChunkPreflight(node, options) {
624
795
  const { ctx, cssInjectPreflight, injectAdditionalCssVarScope } = options;
625
796
  if (testIfVariablesScope(node)) {
626
- _optionalChain([ctx, 'optionalAccess', _26 => _26.markVariablesScope, 'call', _27 => _27(node)]);
797
+ _optionalChain([ctx, 'optionalAccess', _28 => _28.markVariablesScope, 'call', _29 => _29(node)]);
627
798
  node.selectors = remakeCssVarSelector(node.selectors, options);
628
799
  node.before(makePseudoVarRule());
629
800
  if (typeof cssInjectPreflight === "function") {
630
801
  node.append(...cssInjectPreflight());
631
802
  }
632
803
  }
633
- if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
804
+ const isTailwindcss4 = options.majorVersion === 4;
805
+ if (injectAdditionalCssVarScope && (isTailwindcss4 ? testIfRootHostForV4(node) : testIfTwBackdrop(node))) {
634
806
  const syntheticRule = new (0, _postcss.Rule)({
635
807
  selectors: ["*", "::after", "::before"],
636
- nodes: initialNodes
808
+ nodes: isTailwindcss4 ? cssVarsV4Nodes : cssVarsV3Nodes
637
809
  });
638
810
  syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
639
811
  node.before(syntheticRule);
@@ -682,9 +854,9 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
682
854
  p.Once = (root) => {
683
855
  root.walkAtRules((atRule) => {
684
856
  if (atRule.name === "layer" && atRule.params === "properties") {
685
- if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _28 => _28.nodes, 'optionalAccess', _29 => _29.length]) === 0) {
857
+ if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _30 => _30.nodes, 'optionalAccess', _31 => _31.length]) === 0) {
686
858
  layerProperties = atRule;
687
- } else if (_optionalChain([atRule, 'access', _30 => _30.first, 'optionalAccess', _31 => _31.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
859
+ } else if (_optionalChain([atRule, 'access', _32 => _32.first, 'optionalAccess', _33 => _33.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
688
860
  if (layerProperties) {
689
861
  layerProperties.replaceWith(atRule.first.nodes);
690
862
  atRule.remove();
@@ -693,7 +865,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
693
865
  }
694
866
  }
695
867
  } else if (isTailwindcssV4ModernCheck(atRule)) {
696
- if (_optionalChain([atRule, 'access', _32 => _32.first, 'optionalAccess', _33 => _33.type]) === "atrule" && atRule.first.name === "layer") {
868
+ if (_optionalChain([atRule, 'access', _34 => _34.first, 'optionalAccess', _35 => _35.type]) === "atrule" && atRule.first.name === "layer") {
697
869
  atRule.replaceWith(atRule.first.nodes);
698
870
  }
699
871
  }
@@ -707,7 +879,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
707
879
  };
708
880
  postcssWeappTailwindcssPrePlugin.postcss = true;
709
881
 
710
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.3/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
882
+ // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.4/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
711
883
 
712
884
 
713
885
  // ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
@@ -716,7 +888,7 @@ function compare(e3, t2) {
716
888
  return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
717
889
  }
718
890
  function selectorSpecificity(t2, s) {
719
- const i = _optionalChain([s, 'optionalAccess', _34 => _34.customSpecificity, 'optionalCall', _35 => _35(t2)]);
891
+ const i = _optionalChain([s, 'optionalAccess', _36 => _36.customSpecificity, 'optionalCall', _37 => _37(t2)]);
720
892
  if (i) return i;
721
893
  if (!t2) return { a: 0, b: 0, c: 0 };
722
894
  let c = 0, n = 0, o2 = 0;
@@ -792,7 +964,7 @@ function selectorSpecificity(t2, s) {
792
964
  case ":active-view-transition-type":
793
965
  return { a: 0, b: 1, c: 0 };
794
966
  }
795
- else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access', _36 => _36.nodes, 'optionalAccess', _37 => _37.length]) > 0 && t2.nodes.forEach((e3) => {
967
+ else _postcssselectorparser2.default.isContainer(t2) && _optionalChain([t2, 'access', _38 => _38.nodes, 'optionalAccess', _39 => _39.length]) > 0 && t2.nodes.forEach((e3) => {
796
968
  const t3 = selectorSpecificity(e3, s);
797
969
  c += t3.a, n += t3.b, o2 += t3.c;
798
970
  });
@@ -815,13 +987,13 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
815
987
  return 0 === t2.length || 1 === t2.length && "universal" === t2[0].type;
816
988
  }
817
989
 
818
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.3/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
990
+ // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.4/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
819
991
  function alwaysValidSelector(s) {
820
992
  const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
821
993
  let t2 = true;
822
994
  return o2.walk((e3) => {
823
- 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())) {
824
- if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _40 => _40.nodes, 'optionalAccess', _41 => _41.length]) && ":not" === e3.value.toLowerCase()) {
995
+ 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', _40 => _40.nodes, 'optionalAccess', _41 => _41.length]) || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
996
+ if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _42 => _42.nodes, 'optionalAccess', _43 => _43.length]) && ":not" === e3.value.toLowerCase()) {
825
997
  let s2 = true;
826
998
  if (e3.nodes[0].walkCombinators(() => {
827
999
  s2 = false;
@@ -933,8 +1105,8 @@ function splitSelectors(o2, t2, n = 0) {
933
1105
  if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos((e3) => {
934
1106
  if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
935
1107
  if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
936
- 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()})` }]);
937
- 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");
1108
+ if ("pseudo" === _optionalChain([e3, 'access', _44 => _44.parent, 'optionalAccess', _45 => _45.parent, 'optionalAccess', _46 => _46.type]) && ":not" === _optionalChain([e3, 'access', _47 => _47.parent, 'optionalAccess', _48 => _48.parent, 'optionalAccess', _49 => _49.value, 'optionalAccess', _50 => _50.toLowerCase, 'call', _51 => _51()])) return void i.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
1109
+ if ("pseudo" === _optionalChain([e3, 'access', _52 => _52.parent, 'optionalAccess', _53 => _53.parent, 'optionalAccess', _54 => _54.type]) && ":has" === _optionalChain([e3, 'access', _55 => _55.parent, 'optionalAccess', _56 => _56.parent, 'optionalAccess', _57 => _57.value, 'optionalAccess', _58 => _58.toLowerCase, 'call', _59 => _59()])) return void (e3.value = ":-csstools-matches");
938
1110
  let o4 = e3.parent;
939
1111
  for (; o4; ) {
940
1112
  if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (a = true);
@@ -956,7 +1128,7 @@ function splitSelectors(o2, t2, n = 0) {
956
1128
  let s = "";
957
1129
  for (let t3 = 0; t3 < e3.length; t3++) {
958
1130
  const n2 = e3[t3];
959
- 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));
1131
+ s += o3.substring(_optionalChain([e3, 'access', _60 => _60[t3 - 1], 'optionalAccess', _61 => _61.end]) || 0, e3[t3].start), s += ":-csstools-matches(" + n2.option + ")", t3 === e3.length - 1 && (s += o3.substring(e3[t3].end));
960
1132
  }
961
1133
  c.push(s);
962
1134
  }), a && n < 10 && (c = splitSelectors(c, t2, n + 1)), c;
@@ -1017,7 +1189,7 @@ function getPlugins(options) {
1017
1189
  const ctx = createContext();
1018
1190
  options.ctx = ctx;
1019
1191
  const plugins = [
1020
- ..._nullishCoalesce(_optionalChain([options, 'access', _60 => _60.postcssOptions, 'optionalAccess', _61 => _61.plugins]), () => ( [])),
1192
+ ..._nullishCoalesce(_optionalChain([options, 'access', _62 => _62.postcssOptions, 'optionalAccess', _63 => _63.plugins]), () => ( [])),
1021
1193
  postcssWeappTailwindcssPrePlugin(options),
1022
1194
  _postcsspresetenv2.default.call(void 0, options.cssPresetEnv)
1023
1195
  ];
@@ -1061,7 +1233,7 @@ function styleHandler(rawSource, options) {
1061
1233
  getPlugins(options)
1062
1234
  ).process(
1063
1235
  rawSource,
1064
- _nullishCoalesce(_optionalChain([options, 'access', _62 => _62.postcssOptions, 'optionalAccess', _63 => _63.options]), () => ( {
1236
+ _nullishCoalesce(_optionalChain([options, 'access', _64 => _64.postcssOptions, 'optionalAccess', _65 => _65.options]), () => ( {
1065
1237
  from: void 0
1066
1238
  }))
1067
1239
  ).async();
package/dist/index.mjs CHANGED
@@ -7,6 +7,7 @@ import postcss from "postcss";
7
7
  // src/defaults.ts
8
8
  function getDefaultOptions() {
9
9
  return {
10
+ // https://github.com/postcss/postcss-calc
10
11
  cssPresetEnv: {
11
12
  features: {
12
13
  "cascade-layers": true,
@@ -122,92 +123,103 @@ function getCombinatorSelectorAst(options) {
122
123
  return childCombinatorReplaceValue;
123
124
  }
124
125
  function createRuleTransform(rule, options) {
125
- const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass } = options;
126
+ const { escapeMap, mangleContext, cssSelectorReplacement, cssRemoveHoverPseudoClass, uniAppX } = options;
126
127
  const transform = (selectors) => {
127
128
  selectors.walk((selector, index) => {
128
- if (selector.type === "universal") {
129
- if (cssSelectorReplacement?.universal) {
130
- selector.value = composeIsPseudo(cssSelectorReplacement.universal);
131
- }
132
- } else if (selector.type === "selector") {
133
- if (cssRemoveHoverPseudoClass) {
134
- const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
135
- if (node) {
136
- selector.remove();
129
+ if (!uniAppX) {
130
+ if (selector.type === "class") {
131
+ selector.value = internalCssSelectorReplacer(selector.value, {
132
+ escapeMap,
133
+ mangleContext
134
+ });
135
+ } else if (selector.type === "universal") {
136
+ if (cssSelectorReplacement?.universal) {
137
+ selector.value = composeIsPseudo(cssSelectorReplacement.universal);
137
138
  }
138
- }
139
- } else if (selector.type === "pseudo") {
140
- if (selector.value === ":root" && cssSelectorReplacement?.root) {
141
- selector.value = composeIsPseudo(cssSelectorReplacement.root);
142
- } else if (selector.value === ":where") {
143
- if (index === 0 && selector.length === 1) {
144
- selector.walk((node, idx) => {
145
- if (idx === 0 && node.type === "class") {
146
- const nodes = node.parent?.nodes;
147
- if (nodes) {
148
- const first = nodes[idx + 1];
149
- if (first && first.type === "combinator" && first.value === ">") {
150
- const second = nodes[idx + 2];
151
- if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
152
- const ast = getCombinatorSelectorAst(options);
153
- second.replaceWith(
154
- ...ast
155
- );
139
+ } else if (selector.type === "selector") {
140
+ if (cssRemoveHoverPseudoClass) {
141
+ const node = selector.nodes.find((x) => x.type === "pseudo" && x.value === ":hover");
142
+ if (node) {
143
+ selector.remove();
144
+ }
145
+ }
146
+ } else if (selector.type === "pseudo") {
147
+ if (selector.value === ":root" && cssSelectorReplacement?.root) {
148
+ selector.value = composeIsPseudo(cssSelectorReplacement.root);
149
+ } else if (selector.value === ":where") {
150
+ if (index === 0 && selector.length === 1) {
151
+ selector.walk((node, idx) => {
152
+ if (idx === 0 && node.type === "class") {
153
+ const nodes2 = node.parent?.nodes;
154
+ if (nodes2) {
155
+ const first = nodes2[idx + 1];
156
+ if (first && first.type === "combinator" && first.value === ">") {
157
+ const second = nodes2[idx + 2];
158
+ if (second && second.type === "pseudo" && second.value === ":not" && second.first.first.type === "pseudo" && second.first.first.value === ":last-child") {
159
+ const ast = getCombinatorSelectorAst(options);
160
+ second.replaceWith(
161
+ ...ast
162
+ );
163
+ }
156
164
  }
157
165
  }
158
166
  }
159
- }
160
- });
161
- selector.replaceWith(...selector.nodes);
162
- for (const node of rule.nodes) {
163
- if (node.type === "decl") {
164
- if (node.prop === "margin-block-start") {
165
- node.prop = "margin-block-end";
166
- } else if (node.prop === "margin-block-end") {
167
- node.prop = "margin-block-start";
168
- } else if (node.prop === "margin-inline-start") {
169
- node.prop = "margin-inline-end";
170
- } else if (node.prop === "margin-inline-end") {
171
- node.prop = "margin-inline-start";
172
- } else if (node.prop === "margin-top") {
173
- node.prop = "margin-bottom";
174
- } else if (node.prop === "margin-bottom") {
175
- node.prop = "margin-top";
176
- } else if (node.prop === "margin-left") {
177
- node.prop = "margin-right";
178
- } else if (node.prop === "margin-right") {
179
- node.prop = "margin-left";
167
+ });
168
+ selector.replaceWith(...selector.nodes);
169
+ for (const node of rule.nodes) {
170
+ if (node.type === "decl") {
171
+ if (node.prop === "margin-block-start") {
172
+ node.prop = "margin-block-end";
173
+ } else if (node.prop === "margin-block-end") {
174
+ node.prop = "margin-block-start";
175
+ } else if (node.prop === "margin-inline-start") {
176
+ node.prop = "margin-inline-end";
177
+ } else if (node.prop === "margin-inline-end") {
178
+ node.prop = "margin-inline-start";
179
+ } else if (node.prop === "margin-top") {
180
+ node.prop = "margin-bottom";
181
+ } else if (node.prop === "margin-bottom") {
182
+ node.prop = "margin-top";
183
+ } else if (node.prop === "margin-left") {
184
+ node.prop = "margin-right";
185
+ } else if (node.prop === "margin-right") {
186
+ node.prop = "margin-left";
187
+ }
180
188
  }
181
189
  }
182
190
  }
183
191
  }
184
- }
185
- } else if (selector.type === "class") {
186
- selector.value = internalCssSelectorReplacer(selector.value, {
187
- escapeMap,
188
- mangleContext
189
- });
190
- } else if (selector.type === "combinator") {
191
- if (selector.value === ">") {
192
- const nodes = selector.parent?.nodes;
193
- if (nodes) {
194
- const first = nodes[index + 1];
195
- 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")) {
196
- const second = nodes[index + 2];
197
- if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
198
- const third = nodes[index + 3];
199
- 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")) {
200
- const ast = getCombinatorSelectorAst(options);
201
- selector.parent?.nodes.splice(
202
- index + 1,
203
- 3,
204
- ...ast
205
- );
192
+ } else if (selector.type === "combinator") {
193
+ if (selector.value === ">") {
194
+ const nodes2 = selector.parent?.nodes;
195
+ if (nodes2) {
196
+ const first = nodes2[index + 1];
197
+ 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")) {
198
+ const second = nodes2[index + 2];
199
+ if (second && second.type === "combinator" && (second.value === "~" || second.value === "+")) {
200
+ const third = nodes2[index + 3];
201
+ 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")) {
202
+ const ast = getCombinatorSelectorAst(options);
203
+ selector.parent?.nodes.splice(
204
+ index + 1,
205
+ 3,
206
+ ...ast
207
+ );
208
+ }
206
209
  }
207
210
  }
208
211
  }
209
212
  }
210
213
  }
214
+ } else {
215
+ if (selector.type === "class") {
216
+ selector.value = internalCssSelectorReplacer(selector.value, {
217
+ escapeMap,
218
+ mangleContext
219
+ });
220
+ } else {
221
+ selector.remove();
222
+ }
211
223
  }
212
224
  });
213
225
  if (selectors.length === 0) {
@@ -317,13 +329,25 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
317
329
  rule.remove();
318
330
  }
319
331
  rule.walkDecls((decl) => {
320
- if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
332
+ if (opts.uniAppX && decl.prop.startsWith("--")) {
333
+ decl.remove();
334
+ } else if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
321
335
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
336
+ } else if (/calc\(\s*infinity\s*\*\s*1px/.test(decl.value)) {
337
+ decl.value = "9999px";
322
338
  }
323
339
  });
340
+ if (opts.uniAppX) {
341
+ if (rule.nodes.length === 0) {
342
+ rule.remove();
343
+ }
344
+ }
324
345
  });
325
- opts.cssRemoveProperty && root.walkAtRules("property", (rule) => {
326
- rule.remove();
346
+ root.walkAtRules((atRule) => {
347
+ if (opts.cssRemoveProperty && atRule.name === "property") {
348
+ atRule.remove();
349
+ }
350
+ atRule.nodes?.length === 0 && atRule.remove();
327
351
  });
328
352
  };
329
353
  }
@@ -342,8 +366,8 @@ import { defu as defu2 } from "@weapp-tailwindcss/shared";
342
366
  // src/mp.ts
343
367
  import { Declaration, Rule } from "postcss";
344
368
 
345
- // src/cssVars.ts
346
- var cssVars_default = [
369
+ // src/cssVarsV3.ts
370
+ var cssVarsV3_default = [
347
371
  {
348
372
  prop: "--tw-border-spacing-x",
349
373
  value: "0"
@@ -550,8 +574,152 @@ var cssVars_default = [
550
574
  }
551
575
  ];
552
576
 
577
+ // src/cssVarsV4.ts
578
+ function property(ident, initialValue, _syntax) {
579
+ return {
580
+ prop: ident,
581
+ value: initialValue || ""
582
+ };
583
+ }
584
+ var nullShadow = "0 0 #0000";
585
+ var nodes = [
586
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1137
587
+ property("--tw-border-spacing-x", "0", "<length>"),
588
+ property("--tw-border-spacing-y", "0", "<length>"),
589
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1205
590
+ property("--tw-translate-x", "0"),
591
+ property("--tw-translate-y", "0"),
592
+ property("--tw-translate-z", "0"),
593
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1285
594
+ property("--tw-scale-x", "1"),
595
+ property("--tw-scale-y", "1"),
596
+ property("--tw-scale-z", "1"),
597
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1424
598
+ property("--tw-rotate-x"),
599
+ property("--tw-rotate-y"),
600
+ property("--tw-rotate-z"),
601
+ property("--tw-skew-x"),
602
+ property("--tw-skew-y"),
603
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1641C13-L1641C88
604
+ property("--tw-pan-x"),
605
+ property("--tw-pan-y"),
606
+ property("--tw-pinch-zoom"),
607
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1688C38-L1688C95
608
+ property("--tw-scroll-snap-strictness", "proximity", "*"),
609
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L1688C38-L1688C95
610
+ property("--tw-space-x-reverse", "0"),
611
+ property("--tw-space-y-reverse", "0"),
612
+ // https://github.com/tailwindlabs/tailwindcss/blob/main/packages/tailwindcss/src/utilities.ts#L2169C22-L2169C60
613
+ property("--tw-border-style", "solid"),
614
+ property("--tw-divide-x-reverse", "0"),
615
+ property("--tw-divide-y-reverse", "0"),
616
+ property("--tw-gradient-position"),
617
+ property("--tw-gradient-from", "#0000", "<color>"),
618
+ property("--tw-gradient-via", "#0000", "<color>"),
619
+ property("--tw-gradient-to", "#0000", "<color>"),
620
+ property("--tw-gradient-stops"),
621
+ property("--tw-gradient-via-stops"),
622
+ property("--tw-gradient-from-position", "0%", "<length-percentage>"),
623
+ property("--tw-gradient-via-position", "50%", "<length-percentage>"),
624
+ property("--tw-gradient-to-position", "100%", "<length-percentage>"),
625
+ property("--tw-mask-linear", "linear-gradient(#fff, #fff)"),
626
+ property("--tw-mask-radial", "linear-gradient(#fff, #fff)"),
627
+ property("--tw-mask-conic", "linear-gradient(#fff, #fff)"),
628
+ property("--tw-mask-left", "linear-gradient(#fff, #fff)"),
629
+ property("--tw-mask-right", "linear-gradient(#fff, #fff)"),
630
+ property("--tw-mask-bottom", "linear-gradient(#fff, #fff)"),
631
+ property("--tw-mask-top", "linear-gradient(#fff, #fff)"),
632
+ property("--tw-mask-linear-position", "0deg"),
633
+ property("--tw-mask-linear-from-position", "0%"),
634
+ property("--tw-mask-linear-to-position", "100%"),
635
+ property("--tw-mask-linear-from-color", "black"),
636
+ property("--tw-mask-linear-to-color", "transparent"),
637
+ property("--tw-mask-radial-from-position", "0%"),
638
+ property("--tw-mask-radial-to-position", "100%"),
639
+ property("--tw-mask-radial-from-color", "black"),
640
+ property("--tw-mask-radial-to-color", "transparent"),
641
+ property("--tw-mask-radial-shape", "ellipse"),
642
+ property("--tw-mask-radial-size", "farthest-corner"),
643
+ property("--tw-mask-radial-position", "center"),
644
+ property("--tw-mask-conic-position", "0deg"),
645
+ property("--tw-mask-conic-from-position", "0%"),
646
+ property("--tw-mask-conic-to-position", "100%"),
647
+ property("--tw-mask-conic-from-color", "black"),
648
+ property("--tw-mask-conic-to-color", "transparent"),
649
+ property("--tw-font-weight"),
650
+ property("--tw-blur"),
651
+ property("--tw-brightness"),
652
+ property("--tw-contrast"),
653
+ property("--tw-grayscale"),
654
+ property("--tw-hue-rotate"),
655
+ property("--tw-invert"),
656
+ property("--tw-opacity"),
657
+ property("--tw-saturate"),
658
+ property("--tw-sepia"),
659
+ property("--tw-drop-shadow"),
660
+ property("--tw-drop-shadow-color"),
661
+ property("--tw-drop-shadow-alpha", "100%", "<percentage>"),
662
+ property("--tw-drop-shadow-size"),
663
+ property("--tw-backdrop-blur"),
664
+ property("--tw-backdrop-brightness"),
665
+ property("--tw-backdrop-contrast"),
666
+ property("--tw-backdrop-grayscale"),
667
+ property("--tw-backdrop-hue-rotate"),
668
+ property("--tw-backdrop-invert"),
669
+ property("--tw-backdrop-opacity"),
670
+ property("--tw-backdrop-saturate"),
671
+ property("--tw-backdrop-sepia"),
672
+ property("--tw-duration"),
673
+ property("--tw-ease"),
674
+ property("--tw-content", '""'),
675
+ property("--tw-contain-size"),
676
+ property("--tw-contain-layout"),
677
+ property("--tw-contain-paint"),
678
+ property("--tw-contain-style"),
679
+ property("--tw-leading"),
680
+ property("--tw-tracking"),
681
+ property("--tw-ordinal"),
682
+ property("--tw-slashed-zero"),
683
+ property("--tw-numeric-figure"),
684
+ property("--tw-numeric-spacing"),
685
+ property("--tw-numeric-fraction"),
686
+ property("--tw-outline-style", "solid"),
687
+ property("--tw-text-shadow-color"),
688
+ property("--tw-text-shadow-alpha", "100%", "<percentage>"),
689
+ property("--tw-shadow", nullShadow),
690
+ property("--tw-shadow-color"),
691
+ property("--tw-shadow-alpha", "100%", "<percentage>"),
692
+ property("--tw-inset-shadow", nullShadow),
693
+ property("--tw-inset-shadow-color"),
694
+ property("--tw-inset-shadow-alpha", "100%", "<percentage>"),
695
+ property("--tw-ring-color"),
696
+ property("--tw-ring-shadow", nullShadow),
697
+ property("--tw-inset-ring-color"),
698
+ property("--tw-inset-ring-shadow", nullShadow),
699
+ // Legacy
700
+ property("--tw-ring-inset"),
701
+ property("--tw-ring-offset-width", "0px", "<length>"),
702
+ property("--tw-ring-offset-color", "#fff"),
703
+ property("--tw-ring-offset-shadow", nullShadow)
704
+ ];
705
+ for (const edge of ["top", "right", "bottom", "left"]) {
706
+ nodes.push(
707
+ property(`--tw-mask-${edge}-from-position`, "0%"),
708
+ property(`--tw-mask-${edge}-to-position`, "100%"),
709
+ property(`--tw-mask-${edge}-from-color`, "black"),
710
+ property(`--tw-mask-${edge}-to-color`, "transparent")
711
+ );
712
+ }
713
+ var cssVarsV4_default = nodes;
714
+
553
715
  // src/mp.ts
554
- var initialNodes = cssVars_default.map((x) => {
716
+ var cssVarsV3Nodes = cssVarsV3_default.map((x) => {
717
+ return new Declaration({
718
+ prop: x.prop,
719
+ value: x.value
720
+ });
721
+ });
722
+ var cssVarsV4Nodes = cssVarsV4_default.map((x) => {
555
723
  return new Declaration({
556
724
  prop: x.prop,
557
725
  value: x.value
@@ -559,9 +727,9 @@ var initialNodes = cssVars_default.map((x) => {
559
727
  });
560
728
  function testIfVariablesScope(node, count = 2) {
561
729
  if (isOnlyBeforeAndAfterPseudoElement(node)) {
562
- const nodes = node.nodes;
730
+ const nodes2 = node.nodes;
563
731
  let c = 0;
564
- for (const tryTestDecl of nodes) {
732
+ for (const tryTestDecl of nodes2) {
565
733
  if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
566
734
  c++;
567
735
  }
@@ -575,9 +743,9 @@ function testIfVariablesScope(node, count = 2) {
575
743
  }
576
744
  function testIfTwBackdrop(node, count = 2) {
577
745
  if (node.type === "rule" && node.selector === "::backdrop") {
578
- const nodes = node.nodes;
746
+ const nodes2 = node.nodes;
579
747
  let c = 0;
580
- for (const tryTestDecl of nodes) {
748
+ for (const tryTestDecl of nodes2) {
581
749
  if (tryTestDecl && tryTestDecl.type === "decl" && tryTestDecl.prop.startsWith("--tw-")) {
582
750
  c++;
583
751
  }
@@ -589,6 +757,9 @@ function testIfTwBackdrop(node, count = 2) {
589
757
  }
590
758
  return false;
591
759
  }
760
+ function testIfRootHostForV4(node) {
761
+ return node.type === "rule" && node.selector.includes(":root") && node.selector.includes(":host");
762
+ }
592
763
  function makePseudoVarRule() {
593
764
  const pseudoVarRule = new Rule({
594
765
  // selectors: ['::before', '::after'],
@@ -630,10 +801,11 @@ function commonChunkPreflight(node, options) {
630
801
  node.append(...cssInjectPreflight());
631
802
  }
632
803
  }
633
- if (injectAdditionalCssVarScope && testIfTwBackdrop(node)) {
804
+ const isTailwindcss4 = options.majorVersion === 4;
805
+ if (injectAdditionalCssVarScope && (isTailwindcss4 ? testIfRootHostForV4(node) : testIfTwBackdrop(node))) {
634
806
  const syntheticRule = new Rule({
635
807
  selectors: ["*", "::after", "::before"],
636
- nodes: initialNodes
808
+ nodes: isTailwindcss4 ? cssVarsV4Nodes : cssVarsV3Nodes
637
809
  });
638
810
  syntheticRule.selectors = remakeCssVarSelector(syntheticRule.selectors, options);
639
811
  node.before(syntheticRule);
@@ -707,7 +879,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
707
879
  };
708
880
  postcssWeappTailwindcssPrePlugin.postcss = true;
709
881
 
710
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.3/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
882
+ // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.4/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
711
883
  import e2 from "postcss-selector-parser";
712
884
 
713
885
  // ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
@@ -815,7 +987,7 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
815
987
  return 0 === t2.length || 1 === t2.length && "universal" === t2[0].type;
816
988
  }
817
989
 
818
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.3/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
990
+ // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.4/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
819
991
  function alwaysValidSelector(s) {
820
992
  const o2 = e2().astSync(s);
821
993
  let t2 = true;
@@ -49,6 +49,8 @@ type IStyleHandlerOptions = {
49
49
  supports?: boolean;
50
50
  media?: boolean;
51
51
  };
52
+ uniAppX?: boolean;
53
+ majorVersion?: number;
52
54
  } & RequiredStyleHandlerOptions;
53
55
  interface UserDefinedPostcssOptions {
54
56
  cssPreflight?: CssPreflightOptions;
@@ -65,6 +67,7 @@ interface UserDefinedPostcssOptions {
65
67
  cssRemoveHoverPseudoClass?: boolean;
66
68
  cssRemoveProperty?: boolean;
67
69
  customRuleCallback?: CustomRuleCallback;
70
+ uniAppX?: boolean;
68
71
  }
69
72
 
70
73
  export { type CustomRuleCallback as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type RequiredStyleHandlerOptions as R, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type IPropValue as b, createInjectPreflight as c, type CssPreflightOptions as d };
@@ -49,6 +49,8 @@ type IStyleHandlerOptions = {
49
49
  supports?: boolean;
50
50
  media?: boolean;
51
51
  };
52
+ uniAppX?: boolean;
53
+ majorVersion?: number;
52
54
  } & RequiredStyleHandlerOptions;
53
55
  interface UserDefinedPostcssOptions {
54
56
  cssPreflight?: CssPreflightOptions;
@@ -65,6 +67,7 @@ interface UserDefinedPostcssOptions {
65
67
  cssRemoveHoverPseudoClass?: boolean;
66
68
  cssRemoveProperty?: boolean;
67
69
  customRuleCallback?: CustomRuleCallback;
70
+ uniAppX?: boolean;
68
71
  }
69
72
 
70
73
  export { type CustomRuleCallback as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type RequiredStyleHandlerOptions as R, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type IPropValue as b, createInjectPreflight as c, type CssPreflightOptions as d };
package/dist/types.d.mts CHANGED
@@ -3,4 +3,4 @@ import 'postcss';
3
3
  import 'postcss-load-config';
4
4
  import 'postcss-preset-env';
5
5
  import 'postcss-rem-to-responsive-pixel';
6
- export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-Ca68m5Pt.mjs';
6
+ export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-tu70dcVo.mjs';
package/dist/types.d.ts CHANGED
@@ -3,4 +3,4 @@ import 'postcss';
3
3
  import 'postcss-load-config';
4
4
  import 'postcss-preset-env';
5
5
  import 'postcss-rem-to-responsive-pixel';
6
- export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-Ca68m5Pt.js';
6
+ export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-tu70dcVo.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.0.11",
3
+ "version": "1.0.13-beta.0",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -34,13 +34,14 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@weapp-core/escape": "~4.0.1",
37
- "postcss": "~8.5.3",
38
- "postcss-preset-env": "^10.1.5",
37
+ "postcss": "~8.5.4",
38
+ "postcss-preset-env": "^10.2.0",
39
39
  "postcss-rem-to-responsive-pixel": "~6.0.2",
40
40
  "postcss-selector-parser": "~7.1.0",
41
41
  "@weapp-tailwindcss/shared": "1.0.2"
42
42
  },
43
43
  "devDependencies": {
44
+ "postcss-value-parser": "^4.2.0",
44
45
  "@weapp-tailwindcss/mangle": "1.0.4"
45
46
  },
46
47
  "scripts": {