@weapp-tailwindcss/postcss 1.1.1 → 1.2.1-alpha.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,12 +1,14 @@
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';
1
+ import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-C5X6IWCb.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-C5X6IWCb.mjs';
3
3
  import postcss from 'postcss';
4
+ export { PostCssCalcOptions as CssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
5
+ export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
6
+ export { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
7
+ export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
4
8
  import '@weapp-tailwindcss/mangle';
5
9
  import 'postcss-load-config';
6
- import 'postcss-preset-env';
7
- import 'postcss-rem-to-responsive-pixel';
8
10
 
9
- declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
11
+ declare function createStyleHandler(options?: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
10
12
 
11
13
  declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
12
14
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
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';
1
+ import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-C5X6IWCb.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-C5X6IWCb.js';
3
3
  import postcss from 'postcss';
4
+ export { PostCssCalcOptions as CssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
5
+ export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
6
+ export { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
7
+ export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
4
8
  import '@weapp-tailwindcss/mangle';
5
9
  import 'postcss-load-config';
6
- import 'postcss-preset-env';
7
- import 'postcss-rem-to-responsive-pixel';
8
10
 
9
- declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
11
+ declare function createStyleHandler(options?: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
10
12
 
11
13
  declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
12
14
 
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var _shared = require('@weapp-tailwindcss/shared');
5
5
  var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
6
6
 
7
7
  // src/defaults.ts
8
- function getDefaultOptions() {
8
+ function getDefaultOptions(options) {
9
9
  return {
10
10
  // https://github.com/postcss/postcss-calc
11
11
  cssPresetEnv: {
@@ -16,12 +16,14 @@ function getDefaultOptions() {
16
16
  },
17
17
  "oklab-function": true,
18
18
  "color-mix": true,
19
- "custom-properties": false
19
+ // 在 calc 下,这个需要开启
20
+ "custom-properties": _optionalChain([options, 'optionalAccess', _ => _.cssCalc]) ? { preserve: false } : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.cssPresetEnv, 'optionalAccess', _3 => _3.features, 'optionalAccess', _4 => _4["custom-properties"]]), () => ( false))
20
21
  },
21
22
  autoprefixer: {
22
23
  add: false
23
24
  }
24
25
  },
26
+ // 支付宝小程序不支持,所以默认关闭
25
27
  cssRemoveProperty: true,
26
28
  // cssRemoveAtSupports: true,
27
29
  // cssRemoveAtMedia: true,
@@ -33,7 +35,10 @@ function getDefaultOptions() {
33
35
  }
34
36
 
35
37
  // src/plugins/index.ts
38
+ var _postcsscalc = require('@weapp-tailwindcss/postcss-calc'); var _postcsscalc2 = _interopRequireDefault(_postcsscalc);
39
+
36
40
  var _postcsspresetenv = require('postcss-preset-env'); var _postcsspresetenv2 = _interopRequireDefault(_postcsspresetenv);
41
+ var _postcsspxtransform = require('postcss-pxtransform'); var _postcsspxtransform2 = _interopRequireDefault(_postcsspxtransform);
37
42
  var _postcssremtoresponsivepixel = require('postcss-rem-to-responsive-pixel'); var _postcssremtoresponsivepixel2 = _interopRequireDefault(_postcssremtoresponsivepixel);
38
43
 
39
44
  // src/plugins/ctx.ts
@@ -133,7 +138,7 @@ function createRuleTransform(rule, options) {
133
138
  mangleContext
134
139
  });
135
140
  } else if (selector.type === "universal") {
136
- if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _ => _.universal])) {
141
+ if (_optionalChain([cssSelectorReplacement, 'optionalAccess', _5 => _5.universal])) {
137
142
  selector.value = composeIsPseudo(cssSelectorReplacement.universal);
138
143
  }
139
144
  } else if (selector.type === "selector") {
@@ -144,7 +149,7 @@ function createRuleTransform(rule, options) {
144
149
  }
145
150
  }
146
151
  } else if (selector.type === "pseudo") {
147
- if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _2 => _2.root])) {
152
+ if (selector.value === ":root" && _optionalChain([cssSelectorReplacement, 'optionalAccess', _6 => _6.root])) {
148
153
  selector.value = composeIsPseudo(cssSelectorReplacement.root);
149
154
  } else if (selector.value === ":where") {
150
155
  if (uniAppX) {
@@ -153,7 +158,7 @@ function createRuleTransform(rule, options) {
153
158
  if (index === 0 && selector.length === 1) {
154
159
  selector.walk((node, idx) => {
155
160
  if (idx === 0 && node.type === "class") {
156
- const nodes2 = _optionalChain([node, 'access', _3 => _3.parent, 'optionalAccess', _4 => _4.nodes]);
161
+ const nodes2 = _optionalChain([node, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes]);
157
162
  if (nodes2) {
158
163
  const first = nodes2[idx + 1];
159
164
  if (first && first.type === "combinator" && first.value === ">") {
@@ -196,7 +201,7 @@ function createRuleTransform(rule, options) {
196
201
  }
197
202
  } else if (selector.type === "combinator") {
198
203
  if (selector.value === ">") {
199
- const nodes2 = _optionalChain([selector, 'access', _5 => _5.parent, 'optionalAccess', _6 => _6.nodes]);
204
+ const nodes2 = _optionalChain([selector, 'access', _9 => _9.parent, 'optionalAccess', _10 => _10.nodes]);
200
205
  if (nodes2) {
201
206
  const first = nodes2[index + 1];
202
207
  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")) {
@@ -205,7 +210,7 @@ function createRuleTransform(rule, options) {
205
210
  const third = nodes2[index + 3];
206
211
  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")) {
207
212
  const ast = getCombinatorSelectorAst(options);
208
- _optionalChain([selector, 'access', _7 => _7.parent, 'optionalAccess', _8 => _8.nodes, 'access', _9 => _9.splice, 'call', _10 => _10(
213
+ _optionalChain([selector, 'access', _11 => _11.parent, 'optionalAccess', _12 => _12.nodes, 'access', _13 => _13.splice, 'call', _14 => _14(
209
214
  index + 1,
210
215
  3,
211
216
  ...ast
@@ -248,7 +253,7 @@ function isOnlyBeforeAndAfterPseudoElement(node) {
248
253
  let a = false;
249
254
  _postcssselectorparser2.default.call(void 0, (selectors) => {
250
255
  selectors.walkPseudos((s) => {
251
- if (_optionalChain([s, 'access', _11 => _11.parent, 'optionalAccess', _12 => _12.length]) === 1) {
256
+ if (_optionalChain([s, 'access', _15 => _15.parent, 'optionalAccess', _16 => _16.length]) === 1) {
252
257
  if (/^:?:before$/.test(s.value)) {
253
258
  b = true;
254
259
  }
@@ -269,13 +274,13 @@ function getFallbackRemove(rule, options) {
269
274
  maybeImportantId = true;
270
275
  }
271
276
  if (selector.type === "universal") {
272
- _optionalChain([selector, 'access', _13 => _13.parent, 'optionalAccess', _14 => _14.remove, 'call', _15 => _15()]);
277
+ _optionalChain([selector, 'access', _17 => _17.parent, 'optionalAccess', _18 => _18.remove, 'call', _19 => _19()]);
273
278
  } else if (selector.type === "pseudo") {
274
279
  if (selector.value === ":is") {
275
- if (maybeImportantId && _optionalChain([selector, 'access', _16 => _16.nodes, 'access', _17 => _17[0], 'optionalAccess', _18 => _18.type]) === "selector") {
280
+ if (maybeImportantId && _optionalChain([selector, 'access', _20 => _20.nodes, 'access', _21 => _21[0], 'optionalAccess', _22 => _22.type]) === "selector") {
276
281
  selector.replaceWith(selector.nodes[0]);
277
282
  } else {
278
- _optionalChain([selector, 'access', _19 => _19.parent, 'optionalAccess', _20 => _20.remove, 'call', _21 => _21()]);
283
+ _optionalChain([selector, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.remove, 'call', _25 => _25()]);
279
284
  }
280
285
  } else if (selector.value === ":not") {
281
286
  for (const x of selector.nodes) {
@@ -288,8 +293,8 @@ function getFallbackRemove(rule, options) {
288
293
  }
289
294
  }
290
295
  } else if (selector.value === ":where") {
291
- for (const n2 of selector.nodes) {
292
- for (const node of n2.nodes) {
296
+ for (const n of selector.nodes) {
297
+ for (const node of n.nodes) {
293
298
  if (node.type === "attribute") {
294
299
  node.remove();
295
300
  }
@@ -298,7 +303,7 @@ function getFallbackRemove(rule, options) {
298
303
  }
299
304
  } else if (selector.type === "attribute") {
300
305
  if (selector.attribute === "hidden") {
301
- _optionalChain([rule, 'optionalAccess', _22 => _22.remove, 'call', _23 => _23()]);
306
+ _optionalChain([rule, 'optionalAccess', _26 => _26.remove, 'call', _27 => _27()]);
302
307
  }
303
308
  }
304
309
  });
@@ -347,7 +352,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
347
352
  p.DeclarationExit = (decl) => {
348
353
  if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
349
354
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
350
- } else if (/calc\(\s*infinity\s*\*\s*1r?px/.test(decl.value)) {
355
+ } else if (/calc\(\s*infinity\s*\*\s*(?:\d+(?:\.\d*)?|\.\d+)r?px/.test(decl.value)) {
351
356
  decl.value = "9999px";
352
357
  }
353
358
  };
@@ -355,12 +360,12 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
355
360
  if (opts.cssRemoveProperty && atRule.name === "property") {
356
361
  atRule.remove();
357
362
  }
358
- _optionalChain([atRule, 'access', _24 => _24.nodes, 'optionalAccess', _25 => _25.length]) === 0 && atRule.remove();
363
+ _optionalChain([atRule, 'access', _28 => _28.nodes, 'optionalAccess', _29 => _29.length]) === 0 && atRule.remove();
359
364
  };
360
365
  }
361
366
  if (typeof opts.customRuleCallback === "function") {
362
367
  p.Rule = (rule) => {
363
- _optionalChain([opts, 'access', _26 => _26.customRuleCallback, 'optionalCall', _27 => _27(rule, opts)]);
368
+ _optionalChain([opts, 'access', _30 => _30.customRuleCallback, 'optionalCall', _31 => _31(rule, opts)]);
364
369
  };
365
370
  }
366
371
  return p;
@@ -801,7 +806,7 @@ function remakeCssVarSelector(selectors, options) {
801
806
  function commonChunkPreflight(node, options) {
802
807
  const { ctx, cssInjectPreflight, injectAdditionalCssVarScope } = options;
803
808
  if (testIfVariablesScope(node)) {
804
- _optionalChain([ctx, 'optionalAccess', _28 => _28.markVariablesScope, 'call', _29 => _29(node)]);
809
+ _optionalChain([ctx, 'optionalAccess', _32 => _32.markVariablesScope, 'call', _33 => _33(node)]);
805
810
  node.selectors = remakeCssVarSelector(node.selectors, options);
806
811
  node.before(makePseudoVarRule());
807
812
  if (typeof cssInjectPreflight === "function") {
@@ -866,9 +871,9 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
866
871
  root.walkAtRules((atRule) => {
867
872
  if (atRule.name === "layer") {
868
873
  if (atRule.params === "properties") {
869
- if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _30 => _30.nodes, 'optionalAccess', _31 => _31.length]) === 0) {
874
+ if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _34 => _34.nodes, 'optionalAccess', _35 => _35.length]) === 0) {
870
875
  layerProperties = atRule;
871
- } else if (_optionalChain([atRule, 'access', _32 => _32.first, 'optionalAccess', _33 => _33.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
876
+ } else if (_optionalChain([atRule, 'access', _36 => _36.first, 'optionalAccess', _37 => _37.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
872
877
  if (layerProperties) {
873
878
  layerProperties.replaceWith(atRule.first.nodes);
874
879
  atRule.remove();
@@ -880,7 +885,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
880
885
  atRule.replaceWith(atRule.nodes);
881
886
  }
882
887
  } else if (isTailwindcssV4ModernCheck(atRule)) {
883
- if (_optionalChain([atRule, 'access', _34 => _34.first, 'optionalAccess', _35 => _35.type]) === "atrule" && atRule.first.name === "layer") {
888
+ if (_optionalChain([atRule, 'access', _38 => _38.first, 'optionalAccess', _39 => _39.type]) === "atrule" && atRule.first.name === "layer") {
884
889
  atRule.replaceWith(atRule.first.nodes);
885
890
  }
886
891
  }
@@ -894,368 +899,68 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
894
899
  };
895
900
  postcssWeappTailwindcssPrePlugin.postcss = true;
896
901
 
897
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
898
-
899
-
900
- // ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
901
-
902
- function compare(e3, t) {
903
- return e3.a === t.a ? e3.b === t.b ? e3.c - t.c : e3.b - t.b : e3.a - t.a;
904
- }
905
- function selectorSpecificity(t, s) {
906
- const i = _optionalChain([s, 'optionalAccess', _36 => _36.customSpecificity, 'optionalCall', _37 => _37(t)]);
907
- if (i) return i;
908
- if (!t) return { a: 0, b: 0, c: 0 };
909
- let c = 0, n2 = 0, o2 = 0;
910
- if ("universal" == t.type) return { a: 0, b: 0, c: 0 };
911
- if ("id" === t.type) c += 1;
912
- else if ("tag" === t.type) o2 += 1;
913
- else if ("class" === t.type) n2 += 1;
914
- else if ("attribute" === t.type) n2 += 1;
915
- else if (isPseudoElement(t)) switch (t.value.toLowerCase()) {
916
- case "::slotted":
917
- if (o2 += 1, t.nodes && t.nodes.length > 0) {
918
- const e3 = specificityOfMostSpecificListItem(t.nodes, s);
919
- c += e3.a, n2 += e3.b, o2 += e3.c;
920
- }
921
- break;
922
- case "::view-transition-group":
923
- case "::view-transition-image-pair":
924
- case "::view-transition-old":
925
- case "::view-transition-new":
926
- return t.nodes && 1 === t.nodes.length && "selector" === t.nodes[0].type && selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0]) ? { a: 0, b: 0, c: 0 } : { a: 0, b: 0, c: 1 };
927
- default:
928
- o2 += 1;
929
- }
930
- else if (_postcssselectorparser2.default.isPseudoClass(t)) switch (t.value.toLowerCase()) {
931
- case ":-webkit-any":
932
- case ":any":
933
- default:
934
- n2 += 1;
935
- break;
936
- case ":-moz-any":
937
- case ":has":
938
- case ":is":
939
- case ":matches":
940
- case ":not":
941
- if (t.nodes && t.nodes.length > 0) {
942
- const e3 = specificityOfMostSpecificListItem(t.nodes, s);
943
- c += e3.a, n2 += e3.b, o2 += e3.c;
944
- }
945
- break;
946
- case ":where":
947
- break;
948
- case ":nth-child":
949
- case ":nth-last-child":
950
- if (n2 += 1, t.nodes && t.nodes.length > 0) {
951
- const i2 = t.nodes[0].nodes.findIndex(((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase()));
952
- if (i2 > -1) {
953
- const a = _postcssselectorparser2.default.selector({ nodes: [], value: "" });
954
- t.nodes[0].nodes.slice(i2 + 1).forEach(((e3) => {
955
- a.append(e3.clone());
956
- }));
957
- const r = [a];
958
- t.nodes.length > 1 && r.push(...t.nodes.slice(1));
959
- const l = specificityOfMostSpecificListItem(r, s);
960
- c += l.a, n2 += l.b, o2 += l.c;
961
- }
962
- }
963
- break;
964
- case ":local":
965
- case ":global":
966
- t.nodes && t.nodes.length > 0 && t.nodes.forEach(((e3) => {
967
- const t2 = selectorSpecificity(e3, s);
968
- c += t2.a, n2 += t2.b, o2 += t2.c;
969
- }));
970
- break;
971
- case ":host":
972
- case ":host-context":
973
- if (n2 += 1, t.nodes && t.nodes.length > 0) {
974
- const e3 = specificityOfMostSpecificListItem(t.nodes, s);
975
- c += e3.a, n2 += e3.b, o2 += e3.c;
976
- }
977
- break;
978
- case ":active-view-transition":
979
- case ":active-view-transition-type":
980
- return { a: 0, b: 1, c: 0 };
981
- }
982
- else _postcssselectorparser2.default.isContainer(t) && _optionalChain([t, 'access', _38 => _38.nodes, 'optionalAccess', _39 => _39.length]) > 0 && t.nodes.forEach(((e3) => {
983
- const t2 = selectorSpecificity(e3, s);
984
- c += t2.a, n2 += t2.b, o2 += t2.c;
985
- }));
986
- return { a: c, b: n2, c: o2 };
987
- }
988
- function specificityOfMostSpecificListItem(e3, t) {
989
- let s = { a: 0, b: 0, c: 0 };
990
- return e3.forEach(((e4) => {
991
- const i = selectorSpecificity(e4, t);
992
- compare(i, s) < 0 || (s = i);
993
- })), s;
994
- }
995
- function isPseudoElement(t) {
996
- return _postcssselectorparser2.default.isPseudoElement(t);
997
- }
998
- function selectorNodeContainsNothingOrOnlyUniversal(e3) {
999
- if (!e3) return false;
1000
- if (!e3.nodes) return false;
1001
- const t = e3.nodes.filter(((e4) => "comment" !== e4.type));
1002
- return 0 === t.length || 1 === t.length && "universal" === t[0].type;
1003
- }
1004
-
1005
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
1006
- function alwaysValidSelector(s) {
1007
- const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
1008
- let n2 = true;
1009
- return o2.walk(((e3) => {
1010
- 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())) {
1011
- if ("pseudo" === e3.type && 1 === _optionalChain([e3, 'access', _42 => _42.nodes, 'optionalAccess', _43 => _43.length]) && ":not" === e3.value.toLowerCase()) {
1012
- let s2 = true;
1013
- if (e3.nodes[0].walkCombinators((() => {
1014
- s2 = false;
1015
- })), s2) return;
1016
- }
1017
- return n2 = false, false;
1018
- }
1019
- })), n2;
1020
- }
1021
- function sortCompoundSelectorsInsideComplexSelector(s) {
1022
- if (!s || !s.nodes || 1 === s.nodes.length) return;
1023
- const o2 = [];
1024
- let n2 = [];
1025
- for (let t2 = 0; t2 < s.nodes.length; t2++) "combinator" !== s.nodes[t2].type ? _postcssselectorparser2.default.isPseudoElement(s.nodes[t2]) ? (o2.push(n2), n2 = [s.nodes[t2]]) : n2.push(s.nodes[t2]) : (o2.push(n2), o2.push([s.nodes[t2]]), n2 = []);
1026
- o2.push(n2);
1027
- const t = [];
1028
- for (let e3 = 0; e3 < o2.length; e3++) {
1029
- const s2 = o2[e3];
1030
- s2.sort(((e4, s3) => "selector" === e4.type && "selector" === s3.type && e4.nodes.length && s3.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : "selector" === e4.type && e4.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3, s3.type) : "selector" === s3.type && s3.nodes.length ? selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3, s3.type)));
1031
- const n3 = new Set(s2.map(((e4) => e4.type))), r = n3.has("universal") && (n3.has("tag") || n3.has("attribute") || n3.has("class") || n3.has("id") || n3.has("pseudo"));
1032
- for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
1033
- }
1034
- s.removeAll();
1035
- for (let o3 = t.length - 1; o3 >= 0; o3--) {
1036
- const n3 = t[o3 - 1];
1037
- if (t[o3].remove(), n3 && "tag" === n3.type && "tag" === t[o3].type) {
1038
- const n4 = _postcssselectorparser2.default.pseudo({ value: ":is", nodes: [_postcssselectorparser2.default.selector({ value: "", nodes: [t[o3]] })] });
1039
- n4.parent = s, s.nodes.unshift(n4);
1040
- } else t[o3].parent = s, s.nodes.unshift(t[o3]);
1041
- }
1042
- }
1043
- function selectorTypeOrder(s, n2) {
1044
- return _postcssselectorparser2.default.isPseudoElement(s) ? o.pseudoElement : o[n2];
1045
- }
1046
- var o = { universal: 0, tag: 1, pseudoElement: 2, id: 3, class: 4, attribute: 5, pseudo: 6, selector: 7, string: 8, root: 9, comment: 10 };
1047
- function childAdjacentChild(e3) {
1048
- return !(!e3 || !e3.nodes) && ("selector" === e3.type && (3 === e3.nodes.length && (!(!e3.nodes[0] || "pseudo" !== e3.nodes[0].type || ":-csstools-matches" !== e3.nodes[0].value) && (!(!e3.nodes[1] || "combinator" !== e3.nodes[1].type || "+" !== e3.nodes[1].value && "~" !== e3.nodes[1].value) && (!(!e3.nodes[2] || "pseudo" !== e3.nodes[2].type || ":-csstools-matches" !== e3.nodes[2].value) && (!(!e3.nodes[0].nodes || 1 !== e3.nodes[0].nodes.length) && ("selector" === e3.nodes[0].nodes[0].type && (!(!e3.nodes[0].nodes[0].nodes || 3 !== e3.nodes[0].nodes[0].nodes.length) && (!(!e3.nodes[0].nodes[0].nodes || "combinator" !== e3.nodes[0].nodes[0].nodes[1].type || ">" !== e3.nodes[0].nodes[0].nodes[1].value) && (!(!e3.nodes[2].nodes || 1 !== e3.nodes[2].nodes.length) && ("selector" === e3.nodes[2].nodes[0].type && (!(!e3.nodes[2].nodes[0].nodes || 3 !== e3.nodes[2].nodes[0].nodes.length) && (!(!e3.nodes[2].nodes[0].nodes || "combinator" !== e3.nodes[2].nodes[0].nodes[1].type || ">" !== e3.nodes[2].nodes[0].nodes[1].value) && (e3.nodes[0].nodes[0].insertAfter(e3.nodes[0].nodes[0].nodes[0], e3.nodes[2].nodes[0].nodes[0].clone()), e3.nodes[2].nodes[0].nodes[1].remove(), e3.nodes[2].nodes[0].nodes[0].remove(), e3.nodes[0].replaceWith(e3.nodes[0].nodes[0]), e3.nodes[2].replaceWith(e3.nodes[2].nodes[0]), true))))))))))))));
1049
- }
1050
- function isInCompoundWithOneOtherElement(s) {
1051
- if (!s || !s.nodes) return false;
1052
- if (!_postcssselectorparser2.default.isSelector(s)) return false;
1053
- if (2 !== s.nodes.length) return false;
1054
- let o2 = -1, n2 = -1;
1055
- s.nodes[0] && _postcssselectorparser2.default.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0, n2 = 1) : s.nodes[1] && _postcssselectorparser2.default.isPseudoClass(s.nodes[1]) && ":-csstools-matches" === s.nodes[1].value && (o2 = 1, n2 = 0);
1056
- const t = s.nodes[o2];
1057
- if (!t || !_postcssselectorparser2.default.isPseudoClass(t) || 1 !== t.nodes.length) return false;
1058
- const r = s.nodes[n2];
1059
- return !!r && (!_postcssselectorparser2.default.isCombinator(r) && (!_postcssselectorparser2.default.isPseudoElement(r) && (t.nodes[0].append(r.clone()), t.replaceWith(...t.nodes[0].nodes), r.remove(), true)));
1060
- }
1061
- function isPseudoInFirstCompound(s) {
1062
- if (!s || !s.nodes) return false;
1063
- if (!_postcssselectorparser2.default.isSelector(s)) return false;
1064
- let o2 = -1;
1065
- for (let n3 = 0; n3 < s.nodes.length; n3++) {
1066
- const t2 = s.nodes[n3];
1067
- if (_postcssselectorparser2.default.isCombinator(t2)) return false;
1068
- if (_postcssselectorparser2.default.isPseudoElement(t2)) return false;
1069
- if (_postcssselectorparser2.default.isPseudoClass(t2)) {
1070
- const e3 = t2;
1071
- if (":-csstools-matches" === e3.value) {
1072
- if (!e3.nodes || 1 !== e3.nodes.length) return false;
1073
- o2 = n3;
1074
- break;
1075
- }
1076
- }
1077
- }
1078
- if (-1 === o2) return false;
1079
- const n2 = s.nodes[o2];
1080
- if (!n2 || !_postcssselectorparser2.default.isPseudoClass(n2)) return false;
1081
- const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
1082
- return t.forEach(((e3) => {
1083
- n2.nodes[0].append(e3.clone());
1084
- })), r.forEach(((e3) => {
1085
- n2.nodes[0].append(e3.clone());
1086
- })), n2.replaceWith(...n2.nodes), t.forEach(((e3) => {
1087
- e3.remove();
1088
- })), r.forEach(((e3) => {
1089
- e3.remove();
1090
- })), true;
1091
- }
1092
- function samePrecedingElement(s) {
1093
- if (!s || !s.nodes) return false;
1094
- if ("selector" !== s.type) return false;
1095
- let o2 = -1;
1096
- for (let n3 = 0; n3 < s.nodes.length; n3++) {
1097
- const t2 = s.nodes[n3];
1098
- if (_postcssselectorparser2.default.isCombinator(t2)) {
1099
- o2 = n3;
1100
- break;
1101
- }
1102
- if (_postcssselectorparser2.default.isPseudoElement(t2)) return false;
1103
- }
1104
- if (-1 === o2) return false;
1105
- const n2 = o2 + 1;
1106
- if (!s.nodes[o2] || "combinator" !== s.nodes[o2].type || ">" !== s.nodes[o2].value && "+" !== s.nodes[o2].value) return false;
1107
- const t = s.nodes[o2].value;
1108
- if (!s.nodes[n2] || "pseudo" !== s.nodes[n2].type || ":-csstools-matches" !== s.nodes[n2].value) return false;
1109
- if (!s.nodes[n2].nodes || 1 !== s.nodes[n2].nodes.length) return false;
1110
- if ("selector" !== s.nodes[n2].nodes[0].type) return false;
1111
- if (!s.nodes[n2].nodes[0].nodes || 3 !== s.nodes[n2].nodes[0].nodes.length) return false;
1112
- if (!s.nodes[n2].nodes[0].nodes || "combinator" !== s.nodes[n2].nodes[0].nodes[1].type || s.nodes[n2].nodes[0].nodes[1].value !== t) return false;
1113
- const r = s.nodes[n2];
1114
- if (!r || !_postcssselectorparser2.default.isPseudoClass(r)) return false;
1115
- const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
1116
- return s.each(((e3) => {
1117
- e3.remove();
1118
- })), d.forEach(((e3) => {
1119
- s.append(e3);
1120
- })), r.nodes[0].nodes.forEach(((e3) => {
1121
- s.append(e3);
1122
- })), l.forEach(((e3) => {
1123
- s.append(e3);
1124
- })), true;
1125
- }
1126
- function complexSelectors(s, o2, n2, t) {
1127
- return s.flatMap(((s2) => {
1128
- if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
1129
- const r = _postcssselectorparser2.default.call(void 0, ).astSync(s2);
1130
- return r.walkPseudos(((s3) => {
1131
- if (":is" === s3.value.toLowerCase() && s3.nodes && s3.nodes.length && "selector" === s3.nodes[0].type && 0 === s3.nodes[0].nodes.length) return s3.value = ":not", void s3.nodes[0].append(_postcssselectorparser2.default.universal());
1132
- if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
1133
- if (s3.walkPseudos(((s4) => {
1134
- if (_postcssselectorparser2.default.isPseudoElement(s4)) {
1135
- let e3 = s4.value;
1136
- if (e3.startsWith("::-csstools-invalid-")) return;
1137
- for (; e3.startsWith(":"); ) e3 = e3.slice(1);
1138
- s4.value = `::-csstools-invalid-${e3}`, t();
1139
- }
1140
- })), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
1141
- if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
1142
- if (!s3.nodes[0].some(((e3) => "combinator" === e3.type))) return void s3.replaceWith(...s3.nodes[0].nodes);
1143
- }
1144
- 1 !== r.nodes.length || "selector" !== r.nodes[0].type || 1 !== r.nodes[0].nodes.length || r.nodes[0].nodes[0] !== s3 ? childAdjacentChild(s3.parent) || isInCompoundWithOneOtherElement(s3.parent) || isPseudoInFirstCompound(s3.parent) || samePrecedingElement(s3.parent) || ("warning" === o2.onComplexSelector && n2(), s3.value = ":is") : s3.replaceWith(...s3.nodes[0].nodes);
1145
- } else s3.remove();
1146
- })), r.walk(((e3) => {
1147
- "selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
1148
- })), r.walk(((e3) => {
1149
- "nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
1150
- })), r.toString();
1151
- })).filter(((e3) => !!e3));
1152
- }
1153
- function splitSelectors(o2, n2, t = 0) {
1154
- const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
1155
- return o2.flatMap(((o3) => {
1156
- if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
1157
- let i = false;
1158
- const a = [];
1159
- if (_postcssselectorparser2.default.call(void 0, ).astSync(o3).walkPseudos(((e3) => {
1160
- if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
1161
- if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
1162
- 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 a.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
1163
- 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");
1164
- let o4 = e3.parent;
1165
- for (; o4; ) {
1166
- if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (i = true);
1167
- o4 = o4.parent;
1168
- }
1169
- const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
1170
- e3.nodes.forEach(((e4) => {
1171
- const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
1172
- let a2 = e4.toString().trim();
1173
- const u = Math.max(0, n3.a - i2.a), h = Math.max(0, n3.b - i2.b), f = Math.max(0, n3.c - i2.c);
1174
- for (let e5 = 0; e5 < u; e5++) a2 += r;
1175
- for (let e5 = 0; e5 < h; e5++) a2 += d;
1176
- for (let e5 = 0; e5 < f; e5++) a2 += l;
1177
- o5.option = a2, p.push(o5);
1178
- })), a.push(p);
1179
- })), !a.length) return [o3];
1180
- let c = [];
1181
- return cartesianProduct(...a).forEach(((e3) => {
1182
- let s = "";
1183
- for (let n3 = 0; n3 < e3.length; n3++) {
1184
- const t2 = e3[n3];
1185
- s += o3.substring(_optionalChain([e3, 'access', _60 => _60[n3 - 1], 'optionalAccess', _61 => _61.end]) || 0, e3[n3].start), s += ":-csstools-matches(" + t2.option + ")", n3 === e3.length - 1 && (s += o3.substring(e3[n3].end));
1186
- }
1187
- c.push(s);
1188
- })), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
1189
- })).filter(((e3) => !!e3));
1190
- }
1191
- function cartesianProduct(...e3) {
1192
- const s = [], o2 = e3.length - 1;
1193
- return (function helper(n2, t) {
1194
- for (let r = 0, d = e3[t].length; r < d; r++) {
1195
- const d2 = n2.slice(0);
1196
- d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
1197
- }
1198
- })([], 0), s;
1199
- }
1200
- var n = /:is\(/i;
1201
- var creator = (e3) => {
1202
- const s = { specificityMatchingName: "does-not-exist", ...e3 || {} };
1203
- return { postcssPlugin: "postcss-is-pseudo-class", prepare() {
1204
- const e4 = /* @__PURE__ */ new WeakSet();
1205
- return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result: t }) {
1206
- if (!o2.selector) return;
1207
- if (!n.test(o2.selector)) return;
1208
- if (e4.has(o2)) return;
1209
- let r = false;
1210
- const warnOnComplexSelector = () => {
1211
- "warning" === s.onComplexSelector && (r || (r = true, o2.warn(t, `Complex selectors in '${o2.selector}' can not be transformed to an equivalent selector without ':is()'.`)));
1212
- };
1213
- let d = false;
1214
- const warnOnPseudoElements = () => {
1215
- "warning" === s.onPseudoElement && (d || (d = true, o2.warn(t, `Pseudo elements are not allowed in ':is()', unable to transform '${o2.selector}'`)));
1216
- };
1217
- try {
1218
- let n2 = false;
1219
- const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
1220
- if (Array.from(new Set(r2)).forEach(((s2) => {
1221
- if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
1222
- else {
1223
- if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
1224
- e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
1225
- }
1226
- })), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
1227
- if (!n2) return;
1228
- o2.remove();
1229
- }
1230
- } catch (e5) {
1231
- if (!(e5 instanceof Error)) throw e5;
1232
- if (e5.message.indexOf("call stack size exceeded") > -1) throw e5;
1233
- o2.warn(t, `Failed to parse selector "${o2.selector}" with error: ${e5.message}`);
1234
- }
1235
- } };
1236
- } };
1237
- };
1238
- creator.postcss = true;
1239
-
1240
902
  // src/plugins/index.ts
1241
903
 
1242
904
  function getPlugins(options) {
1243
905
  const ctx = createContext();
1244
906
  options.ctx = ctx;
1245
907
  const plugins = [
1246
- ..._nullishCoalesce(_optionalChain([options, 'access', _62 => _62.postcssOptions, 'optionalAccess', _63 => _63.plugins]), () => ( [])),
1247
- postcssWeappTailwindcssPrePlugin(options),
1248
- // calc({ }),
1249
- _postcsspresetenv2.default.call(void 0, options.cssPresetEnv)
1250
- ];
908
+ ..._nullishCoalesce(_optionalChain([options, 'access', _40 => _40.postcssOptions, 'optionalAccess', _41 => _41.plugins]), () => ( [])),
909
+ postcssWeappTailwindcssPrePlugin(options)
910
+ ].filter((x) => Boolean(x));
911
+ plugins.push(
912
+ // https://preset-env.cssdb.org/
913
+ // https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env#readme
914
+ _postcsspresetenv2.default.call(void 0,
915
+ options.cssPresetEnv
916
+ )
917
+ );
918
+ if (options.px2rpx) {
919
+ plugins.push(
920
+ _postcsspxtransform2.default.call(void 0,
921
+ _shared.defuOverrideArray.call(void 0,
922
+ typeof options.px2rpx === "object" ? options.px2rpx : {},
923
+ {
924
+ platform: "weapp",
925
+ unitPrecision: 5,
926
+ propList: ["*"],
927
+ selectorBlackList: [],
928
+ replace: true,
929
+ mediaQuery: false,
930
+ minPixelValue: 0,
931
+ designWidth: 750,
932
+ deviceRatio: {
933
+ 375: 2,
934
+ 640: 2.34 / 2,
935
+ 750: 1,
936
+ 828: 1.81 / 2
937
+ }
938
+ }
939
+ )
940
+ )
941
+ );
942
+ }
1251
943
  if (options.rem2rpx) {
1252
944
  plugins.push(
1253
945
  _postcssremtoresponsivepixel2.default.call(void 0,
1254
- typeof options.rem2rpx === "object" ? options.rem2rpx : {
1255
- rootValue: 32,
1256
- propList: ["*"],
1257
- transformUnit: "rpx"
1258
- }
946
+ _shared.defuOverrideArray.call(void 0,
947
+ typeof options.rem2rpx === "object" ? options.rem2rpx : {
948
+ rootValue: 32,
949
+ propList: ["*"],
950
+ transformUnit: "rpx"
951
+ },
952
+ {
953
+ processorStage: "OnceExit"
954
+ }
955
+ )
956
+ )
957
+ );
958
+ }
959
+ if (options.cssCalc) {
960
+ plugins.push(
961
+ // 核心在 OnceExit 的时候去执行的
962
+ _postcsscalc2.default.call(void 0,
963
+ typeof options.cssCalc === "object" ? options.cssCalc : {}
1259
964
  )
1260
965
  );
1261
966
  }
@@ -1288,7 +993,7 @@ function styleHandler(rawSource, options) {
1288
993
  getPlugins(options)
1289
994
  ).process(
1290
995
  rawSource,
1291
- _shared.defu.call(void 0, _optionalChain([options, 'access', _64 => _64.postcssOptions, 'optionalAccess', _65 => _65.options]), {
996
+ _shared.defu.call(void 0, _optionalChain([options, 'access', _42 => _42.postcssOptions, 'optionalAccess', _43 => _43.options]), {
1292
997
  from: void 0
1293
998
  })
1294
999
  ).async();
@@ -1296,7 +1001,7 @@ function styleHandler(rawSource, options) {
1296
1001
  function createStyleHandler(options) {
1297
1002
  const cachedOptions = _shared.defuOverrideArray.call(void 0,
1298
1003
  options,
1299
- getDefaultOptions()
1004
+ getDefaultOptions(options)
1300
1005
  );
1301
1006
  cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
1302
1007
  return (rawSource, opt) => {
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import "./chunk-WAXGOBY2.mjs";
2
2
 
3
3
  // src/handler.ts
4
- import { defu as defu3, defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
4
+ import { defu as defu3, defuOverrideArray as defuOverrideArray3 } from "@weapp-tailwindcss/shared";
5
5
  import postcss from "postcss";
6
6
 
7
7
  // src/defaults.ts
8
- function getDefaultOptions() {
8
+ function getDefaultOptions(options) {
9
9
  return {
10
10
  // https://github.com/postcss/postcss-calc
11
11
  cssPresetEnv: {
@@ -16,12 +16,14 @@ function getDefaultOptions() {
16
16
  },
17
17
  "oklab-function": true,
18
18
  "color-mix": true,
19
- "custom-properties": false
19
+ // 在 calc 下,这个需要开启
20
+ "custom-properties": options?.cssCalc ? { preserve: false } : options?.cssPresetEnv?.features?.["custom-properties"] ?? false
20
21
  },
21
22
  autoprefixer: {
22
23
  add: false
23
24
  }
24
25
  },
26
+ // 支付宝小程序不支持,所以默认关闭
25
27
  cssRemoveProperty: true,
26
28
  // cssRemoveAtSupports: true,
27
29
  // cssRemoveAtMedia: true,
@@ -33,7 +35,10 @@ function getDefaultOptions() {
33
35
  }
34
36
 
35
37
  // src/plugins/index.ts
38
+ import postcssCalc from "@weapp-tailwindcss/postcss-calc";
39
+ import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
36
40
  import postcssPresetEnv from "postcss-preset-env";
41
+ import postcssPxtransform from "postcss-pxtransform";
37
42
  import postcssRem2rpx from "postcss-rem-to-responsive-pixel";
38
43
 
39
44
  // src/plugins/ctx.ts
@@ -288,8 +293,8 @@ function getFallbackRemove(rule, options) {
288
293
  }
289
294
  }
290
295
  } else if (selector.value === ":where") {
291
- for (const n2 of selector.nodes) {
292
- for (const node of n2.nodes) {
296
+ for (const n of selector.nodes) {
297
+ for (const node of n.nodes) {
293
298
  if (node.type === "attribute") {
294
299
  node.remove();
295
300
  }
@@ -347,7 +352,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
347
352
  p.DeclarationExit = (decl) => {
348
353
  if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OklabSuffix)) {
349
354
  decl.value = decl.value.slice(0, decl.value.length - OklabSuffix.length);
350
- } else if (/calc\(\s*infinity\s*\*\s*1r?px/.test(decl.value)) {
355
+ } else if (/calc\(\s*infinity\s*\*\s*(?:\d+(?:\.\d*)?|\.\d+)r?px/.test(decl.value)) {
351
356
  decl.value = "9999px";
352
357
  }
353
358
  };
@@ -894,349 +899,6 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
894
899
  };
895
900
  postcssWeappTailwindcssPrePlugin.postcss = true;
896
901
 
897
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
898
- import e2 from "postcss-selector-parser";
899
-
900
- // ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
901
- import e from "postcss-selector-parser";
902
- function compare(e3, t) {
903
- return e3.a === t.a ? e3.b === t.b ? e3.c - t.c : e3.b - t.b : e3.a - t.a;
904
- }
905
- function selectorSpecificity(t, s) {
906
- const i = s?.customSpecificity?.(t);
907
- if (i) return i;
908
- if (!t) return { a: 0, b: 0, c: 0 };
909
- let c = 0, n2 = 0, o2 = 0;
910
- if ("universal" == t.type) return { a: 0, b: 0, c: 0 };
911
- if ("id" === t.type) c += 1;
912
- else if ("tag" === t.type) o2 += 1;
913
- else if ("class" === t.type) n2 += 1;
914
- else if ("attribute" === t.type) n2 += 1;
915
- else if (isPseudoElement(t)) switch (t.value.toLowerCase()) {
916
- case "::slotted":
917
- if (o2 += 1, t.nodes && t.nodes.length > 0) {
918
- const e3 = specificityOfMostSpecificListItem(t.nodes, s);
919
- c += e3.a, n2 += e3.b, o2 += e3.c;
920
- }
921
- break;
922
- case "::view-transition-group":
923
- case "::view-transition-image-pair":
924
- case "::view-transition-old":
925
- case "::view-transition-new":
926
- return t.nodes && 1 === t.nodes.length && "selector" === t.nodes[0].type && selectorNodeContainsNothingOrOnlyUniversal(t.nodes[0]) ? { a: 0, b: 0, c: 0 } : { a: 0, b: 0, c: 1 };
927
- default:
928
- o2 += 1;
929
- }
930
- else if (e.isPseudoClass(t)) switch (t.value.toLowerCase()) {
931
- case ":-webkit-any":
932
- case ":any":
933
- default:
934
- n2 += 1;
935
- break;
936
- case ":-moz-any":
937
- case ":has":
938
- case ":is":
939
- case ":matches":
940
- case ":not":
941
- if (t.nodes && t.nodes.length > 0) {
942
- const e3 = specificityOfMostSpecificListItem(t.nodes, s);
943
- c += e3.a, n2 += e3.b, o2 += e3.c;
944
- }
945
- break;
946
- case ":where":
947
- break;
948
- case ":nth-child":
949
- case ":nth-last-child":
950
- if (n2 += 1, t.nodes && t.nodes.length > 0) {
951
- const i2 = t.nodes[0].nodes.findIndex(((e3) => "tag" === e3.type && "of" === e3.value.toLowerCase()));
952
- if (i2 > -1) {
953
- const a = e.selector({ nodes: [], value: "" });
954
- t.nodes[0].nodes.slice(i2 + 1).forEach(((e3) => {
955
- a.append(e3.clone());
956
- }));
957
- const r = [a];
958
- t.nodes.length > 1 && r.push(...t.nodes.slice(1));
959
- const l = specificityOfMostSpecificListItem(r, s);
960
- c += l.a, n2 += l.b, o2 += l.c;
961
- }
962
- }
963
- break;
964
- case ":local":
965
- case ":global":
966
- t.nodes && t.nodes.length > 0 && t.nodes.forEach(((e3) => {
967
- const t2 = selectorSpecificity(e3, s);
968
- c += t2.a, n2 += t2.b, o2 += t2.c;
969
- }));
970
- break;
971
- case ":host":
972
- case ":host-context":
973
- if (n2 += 1, t.nodes && t.nodes.length > 0) {
974
- const e3 = specificityOfMostSpecificListItem(t.nodes, s);
975
- c += e3.a, n2 += e3.b, o2 += e3.c;
976
- }
977
- break;
978
- case ":active-view-transition":
979
- case ":active-view-transition-type":
980
- return { a: 0, b: 1, c: 0 };
981
- }
982
- else e.isContainer(t) && t.nodes?.length > 0 && t.nodes.forEach(((e3) => {
983
- const t2 = selectorSpecificity(e3, s);
984
- c += t2.a, n2 += t2.b, o2 += t2.c;
985
- }));
986
- return { a: c, b: n2, c: o2 };
987
- }
988
- function specificityOfMostSpecificListItem(e3, t) {
989
- let s = { a: 0, b: 0, c: 0 };
990
- return e3.forEach(((e4) => {
991
- const i = selectorSpecificity(e4, t);
992
- compare(i, s) < 0 || (s = i);
993
- })), s;
994
- }
995
- function isPseudoElement(t) {
996
- return e.isPseudoElement(t);
997
- }
998
- function selectorNodeContainsNothingOrOnlyUniversal(e3) {
999
- if (!e3) return false;
1000
- if (!e3.nodes) return false;
1001
- const t = e3.nodes.filter(((e4) => "comment" !== e4.type));
1002
- return 0 === t.length || 1 === t.length && "universal" === t[0].type;
1003
- }
1004
-
1005
- // ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.3_postcss@8.5.6/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
1006
- function alwaysValidSelector(s) {
1007
- const o2 = e2().astSync(s);
1008
- let n2 = true;
1009
- return o2.walk(((e3) => {
1010
- 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 || e3.nodes?.length || ":hover" !== e3.value.toLowerCase() && ":focus" !== e3.value.toLowerCase())) {
1011
- if ("pseudo" === e3.type && 1 === e3.nodes?.length && ":not" === e3.value.toLowerCase()) {
1012
- let s2 = true;
1013
- if (e3.nodes[0].walkCombinators((() => {
1014
- s2 = false;
1015
- })), s2) return;
1016
- }
1017
- return n2 = false, false;
1018
- }
1019
- })), n2;
1020
- }
1021
- function sortCompoundSelectorsInsideComplexSelector(s) {
1022
- if (!s || !s.nodes || 1 === s.nodes.length) return;
1023
- const o2 = [];
1024
- let n2 = [];
1025
- for (let t2 = 0; t2 < s.nodes.length; t2++) "combinator" !== s.nodes[t2].type ? e2.isPseudoElement(s.nodes[t2]) ? (o2.push(n2), n2 = [s.nodes[t2]]) : n2.push(s.nodes[t2]) : (o2.push(n2), o2.push([s.nodes[t2]]), n2 = []);
1026
- o2.push(n2);
1027
- const t = [];
1028
- for (let e3 = 0; e3 < o2.length; e3++) {
1029
- const s2 = o2[e3];
1030
- s2.sort(((e4, s3) => "selector" === e4.type && "selector" === s3.type && e4.nodes.length && s3.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : "selector" === e4.type && e4.nodes.length ? selectorTypeOrder(e4.nodes[0], e4.nodes[0].type) - selectorTypeOrder(s3, s3.type) : "selector" === s3.type && s3.nodes.length ? selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3.nodes[0], s3.nodes[0].type) : selectorTypeOrder(e4, e4.type) - selectorTypeOrder(s3, s3.type)));
1031
- const n3 = new Set(s2.map(((e4) => e4.type))), r = n3.has("universal") && (n3.has("tag") || n3.has("attribute") || n3.has("class") || n3.has("id") || n3.has("pseudo"));
1032
- for (let e4 = 0; e4 < s2.length; e4++) "universal" === s2[e4].type && r ? s2[e4].remove() : t.push(s2[e4]);
1033
- }
1034
- s.removeAll();
1035
- for (let o3 = t.length - 1; o3 >= 0; o3--) {
1036
- const n3 = t[o3 - 1];
1037
- if (t[o3].remove(), n3 && "tag" === n3.type && "tag" === t[o3].type) {
1038
- const n4 = e2.pseudo({ value: ":is", nodes: [e2.selector({ value: "", nodes: [t[o3]] })] });
1039
- n4.parent = s, s.nodes.unshift(n4);
1040
- } else t[o3].parent = s, s.nodes.unshift(t[o3]);
1041
- }
1042
- }
1043
- function selectorTypeOrder(s, n2) {
1044
- return e2.isPseudoElement(s) ? o.pseudoElement : o[n2];
1045
- }
1046
- var o = { universal: 0, tag: 1, pseudoElement: 2, id: 3, class: 4, attribute: 5, pseudo: 6, selector: 7, string: 8, root: 9, comment: 10 };
1047
- function childAdjacentChild(e3) {
1048
- return !(!e3 || !e3.nodes) && ("selector" === e3.type && (3 === e3.nodes.length && (!(!e3.nodes[0] || "pseudo" !== e3.nodes[0].type || ":-csstools-matches" !== e3.nodes[0].value) && (!(!e3.nodes[1] || "combinator" !== e3.nodes[1].type || "+" !== e3.nodes[1].value && "~" !== e3.nodes[1].value) && (!(!e3.nodes[2] || "pseudo" !== e3.nodes[2].type || ":-csstools-matches" !== e3.nodes[2].value) && (!(!e3.nodes[0].nodes || 1 !== e3.nodes[0].nodes.length) && ("selector" === e3.nodes[0].nodes[0].type && (!(!e3.nodes[0].nodes[0].nodes || 3 !== e3.nodes[0].nodes[0].nodes.length) && (!(!e3.nodes[0].nodes[0].nodes || "combinator" !== e3.nodes[0].nodes[0].nodes[1].type || ">" !== e3.nodes[0].nodes[0].nodes[1].value) && (!(!e3.nodes[2].nodes || 1 !== e3.nodes[2].nodes.length) && ("selector" === e3.nodes[2].nodes[0].type && (!(!e3.nodes[2].nodes[0].nodes || 3 !== e3.nodes[2].nodes[0].nodes.length) && (!(!e3.nodes[2].nodes[0].nodes || "combinator" !== e3.nodes[2].nodes[0].nodes[1].type || ">" !== e3.nodes[2].nodes[0].nodes[1].value) && (e3.nodes[0].nodes[0].insertAfter(e3.nodes[0].nodes[0].nodes[0], e3.nodes[2].nodes[0].nodes[0].clone()), e3.nodes[2].nodes[0].nodes[1].remove(), e3.nodes[2].nodes[0].nodes[0].remove(), e3.nodes[0].replaceWith(e3.nodes[0].nodes[0]), e3.nodes[2].replaceWith(e3.nodes[2].nodes[0]), true))))))))))))));
1049
- }
1050
- function isInCompoundWithOneOtherElement(s) {
1051
- if (!s || !s.nodes) return false;
1052
- if (!e2.isSelector(s)) return false;
1053
- if (2 !== s.nodes.length) return false;
1054
- let o2 = -1, n2 = -1;
1055
- s.nodes[0] && e2.isPseudoClass(s.nodes[0]) && ":-csstools-matches" === s.nodes[0].value ? (o2 = 0, n2 = 1) : s.nodes[1] && e2.isPseudoClass(s.nodes[1]) && ":-csstools-matches" === s.nodes[1].value && (o2 = 1, n2 = 0);
1056
- const t = s.nodes[o2];
1057
- if (!t || !e2.isPseudoClass(t) || 1 !== t.nodes.length) return false;
1058
- const r = s.nodes[n2];
1059
- return !!r && (!e2.isCombinator(r) && (!e2.isPseudoElement(r) && (t.nodes[0].append(r.clone()), t.replaceWith(...t.nodes[0].nodes), r.remove(), true)));
1060
- }
1061
- function isPseudoInFirstCompound(s) {
1062
- if (!s || !s.nodes) return false;
1063
- if (!e2.isSelector(s)) return false;
1064
- let o2 = -1;
1065
- for (let n3 = 0; n3 < s.nodes.length; n3++) {
1066
- const t2 = s.nodes[n3];
1067
- if (e2.isCombinator(t2)) return false;
1068
- if (e2.isPseudoElement(t2)) return false;
1069
- if (e2.isPseudoClass(t2)) {
1070
- const e3 = t2;
1071
- if (":-csstools-matches" === e3.value) {
1072
- if (!e3.nodes || 1 !== e3.nodes.length) return false;
1073
- o2 = n3;
1074
- break;
1075
- }
1076
- }
1077
- }
1078
- if (-1 === o2) return false;
1079
- const n2 = s.nodes[o2];
1080
- if (!n2 || !e2.isPseudoClass(n2)) return false;
1081
- const t = s.nodes.slice(0, o2), r = s.nodes.slice(o2 + 1);
1082
- return t.forEach(((e3) => {
1083
- n2.nodes[0].append(e3.clone());
1084
- })), r.forEach(((e3) => {
1085
- n2.nodes[0].append(e3.clone());
1086
- })), n2.replaceWith(...n2.nodes), t.forEach(((e3) => {
1087
- e3.remove();
1088
- })), r.forEach(((e3) => {
1089
- e3.remove();
1090
- })), true;
1091
- }
1092
- function samePrecedingElement(s) {
1093
- if (!s || !s.nodes) return false;
1094
- if ("selector" !== s.type) return false;
1095
- let o2 = -1;
1096
- for (let n3 = 0; n3 < s.nodes.length; n3++) {
1097
- const t2 = s.nodes[n3];
1098
- if (e2.isCombinator(t2)) {
1099
- o2 = n3;
1100
- break;
1101
- }
1102
- if (e2.isPseudoElement(t2)) return false;
1103
- }
1104
- if (-1 === o2) return false;
1105
- const n2 = o2 + 1;
1106
- if (!s.nodes[o2] || "combinator" !== s.nodes[o2].type || ">" !== s.nodes[o2].value && "+" !== s.nodes[o2].value) return false;
1107
- const t = s.nodes[o2].value;
1108
- if (!s.nodes[n2] || "pseudo" !== s.nodes[n2].type || ":-csstools-matches" !== s.nodes[n2].value) return false;
1109
- if (!s.nodes[n2].nodes || 1 !== s.nodes[n2].nodes.length) return false;
1110
- if ("selector" !== s.nodes[n2].nodes[0].type) return false;
1111
- if (!s.nodes[n2].nodes[0].nodes || 3 !== s.nodes[n2].nodes[0].nodes.length) return false;
1112
- if (!s.nodes[n2].nodes[0].nodes || "combinator" !== s.nodes[n2].nodes[0].nodes[1].type || s.nodes[n2].nodes[0].nodes[1].value !== t) return false;
1113
- const r = s.nodes[n2];
1114
- if (!r || !e2.isPseudoClass(r)) return false;
1115
- const d = s.nodes.slice(0, o2), l = s.nodes.slice(n2 + 1);
1116
- return s.each(((e3) => {
1117
- e3.remove();
1118
- })), d.forEach(((e3) => {
1119
- s.append(e3);
1120
- })), r.nodes[0].nodes.forEach(((e3) => {
1121
- s.append(e3);
1122
- })), l.forEach(((e3) => {
1123
- s.append(e3);
1124
- })), true;
1125
- }
1126
- function complexSelectors(s, o2, n2, t) {
1127
- return s.flatMap(((s2) => {
1128
- if (-1 === s2.indexOf(":-csstools-matches") && -1 === s2.toLowerCase().indexOf(":is")) return s2;
1129
- const r = e2().astSync(s2);
1130
- return r.walkPseudos(((s3) => {
1131
- if (":is" === s3.value.toLowerCase() && s3.nodes && s3.nodes.length && "selector" === s3.nodes[0].type && 0 === s3.nodes[0].nodes.length) return s3.value = ":not", void s3.nodes[0].append(e2.universal());
1132
- if (":-csstools-matches" === s3.value) if (!s3.nodes || s3.nodes.length) {
1133
- if (s3.walkPseudos(((s4) => {
1134
- if (e2.isPseudoElement(s4)) {
1135
- let e3 = s4.value;
1136
- if (e3.startsWith("::-csstools-invalid-")) return;
1137
- for (; e3.startsWith(":"); ) e3 = e3.slice(1);
1138
- s4.value = `::-csstools-invalid-${e3}`, t();
1139
- }
1140
- })), 1 === s3.nodes.length && "selector" === s3.nodes[0].type) {
1141
- if (1 === s3.nodes[0].nodes.length) return void s3.replaceWith(s3.nodes[0].nodes[0]);
1142
- if (!s3.nodes[0].some(((e3) => "combinator" === e3.type))) return void s3.replaceWith(...s3.nodes[0].nodes);
1143
- }
1144
- 1 !== r.nodes.length || "selector" !== r.nodes[0].type || 1 !== r.nodes[0].nodes.length || r.nodes[0].nodes[0] !== s3 ? childAdjacentChild(s3.parent) || isInCompoundWithOneOtherElement(s3.parent) || isPseudoInFirstCompound(s3.parent) || samePrecedingElement(s3.parent) || ("warning" === o2.onComplexSelector && n2(), s3.value = ":is") : s3.replaceWith(...s3.nodes[0].nodes);
1145
- } else s3.remove();
1146
- })), r.walk(((e3) => {
1147
- "selector" === e3.type && "nodes" in e3 && 1 === e3.nodes.length && "selector" === e3.nodes[0].type && e3.replaceWith(e3.nodes[0]);
1148
- })), r.walk(((e3) => {
1149
- "nodes" in e3 && sortCompoundSelectorsInsideComplexSelector(e3);
1150
- })), r.toString();
1151
- })).filter(((e3) => !!e3));
1152
- }
1153
- function splitSelectors(o2, n2, t = 0) {
1154
- const r = ":not(#" + n2.specificityMatchingName + ")", d = ":not(." + n2.specificityMatchingName + ")", l = ":not(" + n2.specificityMatchingName + ")";
1155
- return o2.flatMap(((o3) => {
1156
- if (-1 === o3.toLowerCase().indexOf(":is")) return o3;
1157
- let i = false;
1158
- const a = [];
1159
- if (e2().astSync(o3).walkPseudos(((e3) => {
1160
- if (":is" !== e3.value.toLowerCase() || !e3.nodes || !e3.nodes.length) return;
1161
- if ("selector" === e3.nodes[0].type && 0 === e3.nodes[0].nodes.length) return;
1162
- if ("pseudo" === e3.parent?.parent?.type && ":not" === e3.parent?.parent?.value?.toLowerCase()) return void a.push([{ start: e3.parent.parent.sourceIndex, end: e3.parent.parent.sourceIndex + e3.parent.parent.toString().length, option: `:not(${e3.nodes.toString()})` }]);
1163
- if ("pseudo" === e3.parent?.parent?.type && ":has" === e3.parent?.parent?.value?.toLowerCase()) return void (e3.value = ":-csstools-matches");
1164
- let o4 = e3.parent;
1165
- for (; o4; ) {
1166
- if (o4.value && ":is" === o4.value.toLowerCase() && "pseudo" === o4.type) return void (i = true);
1167
- o4 = o4.parent;
1168
- }
1169
- const n3 = selectorSpecificity(e3), t2 = e3.sourceIndex, c2 = t2 + e3.toString().length, p = [];
1170
- e3.nodes.forEach(((e4) => {
1171
- const o5 = { start: t2, end: c2, option: "" }, i2 = selectorSpecificity(e4);
1172
- let a2 = e4.toString().trim();
1173
- const u = Math.max(0, n3.a - i2.a), h = Math.max(0, n3.b - i2.b), f = Math.max(0, n3.c - i2.c);
1174
- for (let e5 = 0; e5 < u; e5++) a2 += r;
1175
- for (let e5 = 0; e5 < h; e5++) a2 += d;
1176
- for (let e5 = 0; e5 < f; e5++) a2 += l;
1177
- o5.option = a2, p.push(o5);
1178
- })), a.push(p);
1179
- })), !a.length) return [o3];
1180
- let c = [];
1181
- return cartesianProduct(...a).forEach(((e3) => {
1182
- let s = "";
1183
- for (let n3 = 0; n3 < e3.length; n3++) {
1184
- const t2 = e3[n3];
1185
- s += o3.substring(e3[n3 - 1]?.end || 0, e3[n3].start), s += ":-csstools-matches(" + t2.option + ")", n3 === e3.length - 1 && (s += o3.substring(e3[n3].end));
1186
- }
1187
- c.push(s);
1188
- })), i && t < 10 && (c = splitSelectors(c, n2, t + 1)), c;
1189
- })).filter(((e3) => !!e3));
1190
- }
1191
- function cartesianProduct(...e3) {
1192
- const s = [], o2 = e3.length - 1;
1193
- return (function helper(n2, t) {
1194
- for (let r = 0, d = e3[t].length; r < d; r++) {
1195
- const d2 = n2.slice(0);
1196
- d2.push(e3[t][r]), t === o2 ? s.push(d2) : helper(d2, t + 1);
1197
- }
1198
- })([], 0), s;
1199
- }
1200
- var n = /:is\(/i;
1201
- var creator = (e3) => {
1202
- const s = { specificityMatchingName: "does-not-exist", ...e3 || {} };
1203
- return { postcssPlugin: "postcss-is-pseudo-class", prepare() {
1204
- const e4 = /* @__PURE__ */ new WeakSet();
1205
- return { postcssPlugin: "postcss-is-pseudo-class", Rule(o2, { result: t }) {
1206
- if (!o2.selector) return;
1207
- if (!n.test(o2.selector)) return;
1208
- if (e4.has(o2)) return;
1209
- let r = false;
1210
- const warnOnComplexSelector = () => {
1211
- "warning" === s.onComplexSelector && (r || (r = true, o2.warn(t, `Complex selectors in '${o2.selector}' can not be transformed to an equivalent selector without ':is()'.`)));
1212
- };
1213
- let d = false;
1214
- const warnOnPseudoElements = () => {
1215
- "warning" === s.onPseudoElement && (d || (d = true, o2.warn(t, `Pseudo elements are not allowed in ':is()', unable to transform '${o2.selector}'`)));
1216
- };
1217
- try {
1218
- let n2 = false;
1219
- const t2 = [], r2 = complexSelectors(splitSelectors(o2.selectors, { specificityMatchingName: s.specificityMatchingName }), { onComplexSelector: s.onComplexSelector }, warnOnComplexSelector, warnOnPseudoElements);
1220
- if (Array.from(new Set(r2)).forEach(((s2) => {
1221
- if (o2.selectors.indexOf(s2) > -1) t2.push(s2);
1222
- else {
1223
- if (alwaysValidSelector(s2)) return t2.push(s2), void (n2 = true);
1224
- e4.add(o2), o2.cloneBefore({ selector: s2 }), n2 = true;
1225
- }
1226
- })), t2.length && n2 && (e4.add(o2), o2.cloneBefore({ selectors: t2 })), !s.preserve) {
1227
- if (!n2) return;
1228
- o2.remove();
1229
- }
1230
- } catch (e5) {
1231
- if (!(e5 instanceof Error)) throw e5;
1232
- if (e5.message.indexOf("call stack size exceeded") > -1) throw e5;
1233
- o2.warn(t, `Failed to parse selector "${o2.selector}" with error: ${e5.message}`);
1234
- }
1235
- } };
1236
- } };
1237
- };
1238
- creator.postcss = true;
1239
-
1240
902
  // src/plugins/index.ts
1241
903
  import { default as default2 } from "postcss-rem-to-responsive-pixel";
1242
904
  function getPlugins(options) {
@@ -1244,18 +906,61 @@ function getPlugins(options) {
1244
906
  options.ctx = ctx;
1245
907
  const plugins = [
1246
908
  ...options.postcssOptions?.plugins ?? [],
1247
- postcssWeappTailwindcssPrePlugin(options),
1248
- // calc({ }),
1249
- postcssPresetEnv(options.cssPresetEnv)
1250
- ];
909
+ postcssWeappTailwindcssPrePlugin(options)
910
+ ].filter((x) => Boolean(x));
911
+ plugins.push(
912
+ // https://preset-env.cssdb.org/
913
+ // https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env#readme
914
+ postcssPresetEnv(
915
+ options.cssPresetEnv
916
+ )
917
+ );
918
+ if (options.px2rpx) {
919
+ plugins.push(
920
+ postcssPxtransform(
921
+ defuOverrideArray2(
922
+ typeof options.px2rpx === "object" ? options.px2rpx : {},
923
+ {
924
+ platform: "weapp",
925
+ unitPrecision: 5,
926
+ propList: ["*"],
927
+ selectorBlackList: [],
928
+ replace: true,
929
+ mediaQuery: false,
930
+ minPixelValue: 0,
931
+ designWidth: 750,
932
+ deviceRatio: {
933
+ 375: 2,
934
+ 640: 2.34 / 2,
935
+ 750: 1,
936
+ 828: 1.81 / 2
937
+ }
938
+ }
939
+ )
940
+ )
941
+ );
942
+ }
1251
943
  if (options.rem2rpx) {
1252
944
  plugins.push(
1253
945
  postcssRem2rpx(
1254
- typeof options.rem2rpx === "object" ? options.rem2rpx : {
1255
- rootValue: 32,
1256
- propList: ["*"],
1257
- transformUnit: "rpx"
1258
- }
946
+ defuOverrideArray2(
947
+ typeof options.rem2rpx === "object" ? options.rem2rpx : {
948
+ rootValue: 32,
949
+ propList: ["*"],
950
+ transformUnit: "rpx"
951
+ },
952
+ {
953
+ processorStage: "OnceExit"
954
+ }
955
+ )
956
+ )
957
+ );
958
+ }
959
+ if (options.cssCalc) {
960
+ plugins.push(
961
+ // 核心在 OnceExit 的时候去执行的
962
+ postcssCalc(
963
+ typeof options.cssCalc === "object" ? options.cssCalc : {}
1259
964
  )
1260
965
  );
1261
966
  }
@@ -1294,15 +999,15 @@ function styleHandler(rawSource, options) {
1294
999
  ).async();
1295
1000
  }
1296
1001
  function createStyleHandler(options) {
1297
- const cachedOptions = defuOverrideArray2(
1002
+ const cachedOptions = defuOverrideArray3(
1298
1003
  options,
1299
- getDefaultOptions()
1004
+ getDefaultOptions(options)
1300
1005
  );
1301
1006
  cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
1302
1007
  return (rawSource, opt) => {
1303
1008
  return styleHandler(
1304
1009
  rawSource,
1305
- defuOverrideArray2(opt, cachedOptions)
1010
+ defuOverrideArray3(opt, cachedOptions)
1306
1011
  );
1307
1012
  };
1308
1013
  }
@@ -1,7 +1,9 @@
1
1
  import { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
2
+ import { PostCssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
2
3
  import { Rule } from 'postcss';
3
4
  import { Result } from 'postcss-load-config';
4
5
  import { pluginOptions } from 'postcss-preset-env';
6
+ import { PxtransformOptions } from 'postcss-pxtransform';
5
7
  import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
6
8
 
7
9
  declare function createContext(): {
@@ -31,7 +33,7 @@ type RequiredStyleHandlerOptions = {
31
33
  cssPreflight?: CssPreflightOptions;
32
34
  cssInjectPreflight?: InjectPreflight;
33
35
  escapeMap?: Record<string, string>;
34
- } & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
36
+ } & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx' | 'px2rpx'>;
35
37
  interface InternalCssSelectorReplacerOptions {
36
38
  mangleContext?: IMangleScopeContext;
37
39
  escapeMap?: Record<string, string>;
@@ -44,6 +46,7 @@ type IStyleHandlerOptions = {
44
46
  cssRemoveProperty?: boolean;
45
47
  cssRemoveHoverPseudoClass?: boolean;
46
48
  cssPresetEnv?: pluginOptions;
49
+ cssCalc?: boolean | PostCssCalcOptions;
47
50
  atRules?: {
48
51
  property?: boolean;
49
52
  supports?: boolean;
@@ -63,6 +66,7 @@ interface UserDefinedPostcssOptions {
63
66
  universal?: string | string[] | false;
64
67
  };
65
68
  rem2rpx?: boolean | UserDefinedOptions;
69
+ px2rpx?: boolean | PxtransformOptions;
66
70
  postcssOptions?: LoadedPostcssOptions;
67
71
  cssRemoveHoverPseudoClass?: boolean;
68
72
  cssRemoveProperty?: boolean;
@@ -1,7 +1,9 @@
1
1
  import { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
2
+ import { PostCssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
2
3
  import { Rule } from 'postcss';
3
4
  import { Result } from 'postcss-load-config';
4
5
  import { pluginOptions } from 'postcss-preset-env';
6
+ import { PxtransformOptions } from 'postcss-pxtransform';
5
7
  import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
6
8
 
7
9
  declare function createContext(): {
@@ -31,7 +33,7 @@ type RequiredStyleHandlerOptions = {
31
33
  cssPreflight?: CssPreflightOptions;
32
34
  cssInjectPreflight?: InjectPreflight;
33
35
  escapeMap?: Record<string, string>;
34
- } & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
36
+ } & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx' | 'px2rpx'>;
35
37
  interface InternalCssSelectorReplacerOptions {
36
38
  mangleContext?: IMangleScopeContext;
37
39
  escapeMap?: Record<string, string>;
@@ -44,6 +46,7 @@ type IStyleHandlerOptions = {
44
46
  cssRemoveProperty?: boolean;
45
47
  cssRemoveHoverPseudoClass?: boolean;
46
48
  cssPresetEnv?: pluginOptions;
49
+ cssCalc?: boolean | PostCssCalcOptions;
47
50
  atRules?: {
48
51
  property?: boolean;
49
52
  supports?: boolean;
@@ -63,6 +66,7 @@ interface UserDefinedPostcssOptions {
63
66
  universal?: string | string[] | false;
64
67
  };
65
68
  rem2rpx?: boolean | UserDefinedOptions;
69
+ px2rpx?: boolean | PxtransformOptions;
66
70
  postcssOptions?: LoadedPostcssOptions;
67
71
  cssRemoveHoverPseudoClass?: boolean;
68
72
  cssRemoveProperty?: boolean;
package/dist/types.d.mts CHANGED
@@ -1,6 +1,8 @@
1
1
  import '@weapp-tailwindcss/mangle';
2
+ export { PostCssCalcOptions as CssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
2
3
  import 'postcss';
3
4
  import 'postcss-load-config';
4
- import 'postcss-preset-env';
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-tu70dcVo.mjs';
5
+ export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
6
+ export { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
7
+ export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
8
+ 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-C5X6IWCb.mjs';
package/dist/types.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import '@weapp-tailwindcss/mangle';
2
+ export { PostCssCalcOptions as CssCalcOptions } from '@weapp-tailwindcss/postcss-calc';
2
3
  import 'postcss';
3
4
  import 'postcss-load-config';
4
- import 'postcss-preset-env';
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-tu70dcVo.js';
5
+ export { pluginOptions as PresetEnvOptions } from 'postcss-preset-env';
6
+ export { PxtransformOptions as Px2rpxOptions } from 'postcss-pxtransform';
7
+ export { UserDefinedOptions as Rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
8
+ 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-C5X6IWCb.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.1.1",
3
+ "version": "1.2.1-alpha.0",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -40,13 +40,16 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@weapp-core/escape": "~4.0.1",
43
+ "@weapp-tailwindcss/postcss-calc": "^1.0.0",
43
44
  "postcss": "~8.5.6",
44
45
  "postcss-preset-env": "^10.3.1",
45
- "postcss-rem-to-responsive-pixel": "~6.0.2",
46
+ "postcss-pxtransform": "^4.1.6",
47
+ "postcss-rem-to-responsive-pixel": "~6.1.0",
46
48
  "postcss-selector-parser": "~7.1.0",
47
49
  "@weapp-tailwindcss/shared": "1.0.3"
48
50
  },
49
51
  "devDependencies": {
52
+ "@csstools/postcss-is-pseudo-class": "^5.0.3",
50
53
  "postcss-calc": "^10.1.1",
51
54
  "postcss-value-parser": "^4.2.0",
52
55
  "@weapp-tailwindcss/mangle": "1.0.5"