@weapp-tailwindcss/postcss 2.1.7 → 2.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;require('./chunk-GGNOJ77I.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
+
3
+ var _chunk2Y3ULRB3js = require('./chunk-2Y3ULRB3.js');
4
+ require('./chunk-GGNOJ77I.js');
2
5
 
3
6
  // src/handler.ts
4
7
  var _shared = require('@weapp-tailwindcss/shared');
8
+ var _lrucache = require('lru-cache');
5
9
 
6
10
  // src/compat/uni-app-x.ts
7
11
  var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
@@ -132,6 +136,145 @@ function shouldRemoveEmptyRuleForUniAppX(rule, options) {
132
136
  return isUniAppXEnabled(options) && rule.nodes.length === 0;
133
137
  }
134
138
 
139
+ // src/compat/uni-app-x-uvue.ts
140
+ var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
141
+ var ALLOWED_DISPLAY_VALUES = /* @__PURE__ */ new Set(["flex", "none"]);
142
+ var FALLBACK_CLASS_RE = /\.((?:\\.|[\w-])+)/g;
143
+ var IMPORTANT_SUFFIX_RE = /\s*!important$/i;
144
+ function isUniAppXUvueTarget(options) {
145
+ return Boolean(_optionalChain([options, 'optionalAccess', _2 => _2.uniAppX])) && _optionalChain([options, 'optionalAccess', _3 => _3.uniAppXCssTarget]) === "uvue";
146
+ }
147
+ function normalizeUnsupportedMode(mode) {
148
+ return _nullishCoalesce(mode, () => ( "warn"));
149
+ }
150
+ function normalizeValue(value) {
151
+ return value.trim().toLowerCase().replace(IMPORTANT_SUFFIX_RE, "");
152
+ }
153
+ function getSourceFile(rule, result) {
154
+ return _nullishCoalesce(_nullishCoalesce(_optionalChain([rule, 'access', _4 => _4.source, 'optionalAccess', _5 => _5.input, 'access', _6 => _6.from]), () => ( result.opts.from)), () => ( "unknown source"));
155
+ }
156
+ function collectUtilityClassNames(rule) {
157
+ const classNames = /* @__PURE__ */ new Set();
158
+ for (const selector of _nullishCoalesce(rule.selectors, () => ( []))) {
159
+ try {
160
+ const ast = _postcssselectorparser2.default.call(void 0, ).astSync(selector);
161
+ ast.walkClasses((node) => {
162
+ if (node.value) {
163
+ classNames.add(node.value);
164
+ }
165
+ });
166
+ } catch (e) {
167
+ for (const match of selector.matchAll(FALLBACK_CLASS_RE)) {
168
+ if (match[1]) {
169
+ classNames.add(match[1].replaceAll("\\", ""));
170
+ }
171
+ }
172
+ }
173
+ }
174
+ return [...classNames];
175
+ }
176
+ function hasOnlyClassSelectors(rule) {
177
+ const selectors = _nullishCoalesce(rule.selectors, () => ( []));
178
+ if (selectors.length === 0) {
179
+ return false;
180
+ }
181
+ return selectors.every((selector) => {
182
+ try {
183
+ const ast = _postcssselectorparser2.default.call(void 0, ).astSync(selector);
184
+ return ast.nodes.every((node) => node.nodes.length > 0 && node.nodes.every((child) => child.type === "class"));
185
+ } catch (e2) {
186
+ return false;
187
+ }
188
+ });
189
+ }
190
+ function getUnsupportedDeclarationReason(prop, value) {
191
+ const normalizedProp = prop.trim().toLowerCase();
192
+ const normalizedValue = normalizeValue(value);
193
+ if (normalizedProp === "display" && !ALLOWED_DISPLAY_VALUES.has(normalizedValue)) {
194
+ return `${normalizedProp}: ${value}`;
195
+ }
196
+ if (normalizedProp === "min-height" && normalizedValue === "100vh") {
197
+ return `${normalizedProp}: ${value}`;
198
+ }
199
+ if (normalizedProp === "grid-template-columns" || normalizedProp === "grid-template-rows" || normalizedProp === "grid-auto-columns" || normalizedProp === "grid-auto-rows" || normalizedProp === "grid-auto-flow") {
200
+ return `${normalizedProp}: ${value}`;
201
+ }
202
+ if (normalizedProp === "gap" || normalizedProp === "row-gap" || normalizedProp === "column-gap") {
203
+ return `${normalizedProp}: ${value}`;
204
+ }
205
+ }
206
+ function reportUnsupportedRule(rule, result, mode, warningCache, reason) {
207
+ if (mode === "silent") {
208
+ return;
209
+ }
210
+ const classNames = collectUtilityClassNames(rule);
211
+ const classLabel = classNames.length > 0 ? classNames.join(", ") : rule.selector;
212
+ const source = getSourceFile(rule, result);
213
+ const message = `uni-app x uvue unsupported utility: ${classLabel} (${reason}) in ${source}`;
214
+ if (mode === "error") {
215
+ throw rule.error(message);
216
+ }
217
+ if (warningCache.has(message)) {
218
+ return;
219
+ }
220
+ warningCache.add(message);
221
+ rule.warn(result, message);
222
+ }
223
+ function applyUniAppXUvueCompatibility(result, options) {
224
+ if (!isUniAppXUvueTarget(options)) {
225
+ return result;
226
+ }
227
+ const mode = normalizeUnsupportedMode(_optionalChain([options, 'optionalAccess', _7 => _7.uniAppXUnsupported]));
228
+ const warningCache = /* @__PURE__ */ new Set();
229
+ result.root.walkRules((rule) => {
230
+ if (!hasOnlyClassSelectors(rule)) {
231
+ reportUnsupportedRule(rule, result, mode, warningCache, "selector must be class-only");
232
+ rule.remove();
233
+ return;
234
+ }
235
+ rule.walkDecls((decl) => {
236
+ const reason = getUnsupportedDeclarationReason(decl.prop, decl.value);
237
+ if (!reason) {
238
+ return;
239
+ }
240
+ reportUnsupportedRule(rule, result, mode, warningCache, reason);
241
+ decl.remove();
242
+ });
243
+ if ((_nullishCoalesce(_optionalChain([rule, 'access', _8 => _8.nodes, 'optionalAccess', _9 => _9.length]), () => ( 0))) === 0) {
244
+ rule.remove();
245
+ }
246
+ });
247
+ result.root.walkAtRules((atRule) => {
248
+ if ((_nullishCoalesce(_optionalChain([atRule, 'access', _10 => _10.nodes, 'optionalAccess', _11 => _11.length]), () => ( 0))) === 0) {
249
+ atRule.remove();
250
+ }
251
+ });
252
+ const nextResult = result.root.toResult(result.opts);
253
+ nextResult.messages.push(...result.messages);
254
+ return nextResult;
255
+ }
256
+
257
+ // src/content-probe.ts
258
+ var EMPTY_SIGNAL = {
259
+ hasModernColorFunction: false,
260
+ hasPresetEnvFeatures: false
261
+ };
262
+ var MODERN_COLOR_RE = /rgb\w*\s*\([^),][^\s),]*\s[^),][^\s),]*\s[^),][^),/]*\/[^)]+\)/i;
263
+ function probeFeatures(css) {
264
+ if (!css) {
265
+ return { ...EMPTY_SIGNAL };
266
+ }
267
+ const hasModernColorFunction = MODERN_COLOR_RE.test(css);
268
+ const hasPresetEnvFeatures = true;
269
+ return {
270
+ hasModernColorFunction,
271
+ hasPresetEnvFeatures
272
+ };
273
+ }
274
+ function signalToCacheKey(signal) {
275
+ return `signal:${signal.hasPresetEnvFeatures ? 1 : 0},${signal.hasModernColorFunction ? 1 : 0}`;
276
+ }
277
+
135
278
  // src/defaults.ts
136
279
  function getDefaultOptions(options) {
137
280
  return {
@@ -144,9 +287,9 @@ function getDefaultOptions(options) {
144
287
  },
145
288
  "oklab-function": true,
146
289
  "color-mix": true,
147
- "color-functional-notation": _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.cssPresetEnv, 'optionalAccess', _3 => _3.features, 'optionalAccess', _4 => _4["color-functional-notation"]]), () => ( { preserve: false })),
290
+ "color-functional-notation": _nullishCoalesce(_optionalChain([options, 'optionalAccess', _12 => _12.cssPresetEnv, 'optionalAccess', _13 => _13.features, 'optionalAccess', _14 => _14["color-functional-notation"]]), () => ( { preserve: false })),
148
291
  // 在 calc 下,这个需要开启
149
- "custom-properties": _nullishCoalesce(_optionalChain([options, 'optionalAccess', _5 => _5.cssPresetEnv, 'optionalAccess', _6 => _6.features, 'optionalAccess', _7 => _7["custom-properties"]]), () => ( _optionalChain([options, 'optionalAccess', _8 => _8.cssCalc]))) ? { preserve: true } : false
292
+ "custom-properties": _nullishCoalesce(_optionalChain([options, 'optionalAccess', _15 => _15.cssPresetEnv, 'optionalAccess', _16 => _16.features, 'optionalAccess', _17 => _17["custom-properties"]]), () => ( _optionalChain([options, 'optionalAccess', _18 => _18.cssCalc]))) ? { preserve: true } : false
150
293
  },
151
294
  autoprefixer: {
152
295
  add: false
@@ -154,6 +297,7 @@ function getDefaultOptions(options) {
154
297
  },
155
298
  // 支付宝小程序不支持,所以默认关闭
156
299
  cssRemoveProperty: true,
300
+ uniAppXUnsupported: "warn",
157
301
  // cssRemoveAtSupports: true,
158
302
  // cssRemoveAtMedia: true,
159
303
  cssSelectorReplacement: {
@@ -163,9 +307,6 @@ function getDefaultOptions(options) {
163
307
  };
164
308
  }
165
309
 
166
- // src/options-resolver.ts
167
-
168
-
169
310
  // src/fingerprint.ts
170
311
  function fingerprintOptions(value, state = { map: /* @__PURE__ */ new WeakMap(), counter: 0 }) {
171
312
  if (value === null || value === void 0) {
@@ -197,6 +338,7 @@ function fingerprintOptions(value, state = { map: /* @__PURE__ */ new WeakMap(),
197
338
  }
198
339
 
199
340
  // src/options-resolver.ts
341
+
200
342
  var BASE_CACHE_KEY = "base";
201
343
  var SIMPLE_OVERRIDE_UNSET = "__unset__";
202
344
  function getSimpleOverrideCacheKey(options) {
@@ -213,6 +355,7 @@ function getSimpleOverrideCacheKey(options) {
213
355
  let cssCalc = SIMPLE_OVERRIDE_UNSET;
214
356
  let cssChildCombinatorReplaceValue = SIMPLE_OVERRIDE_UNSET;
215
357
  let cssPreflight = SIMPLE_OVERRIDE_UNSET;
358
+ let autoprefixer = SIMPLE_OVERRIDE_UNSET;
216
359
  for (const key of Object.keys(options)) {
217
360
  const value = options[key];
218
361
  switch (key) {
@@ -294,6 +437,12 @@ function getSimpleOverrideCacheKey(options) {
294
437
  }
295
438
  cssPreflight = "0";
296
439
  break;
440
+ case "autoprefixer":
441
+ if (typeof value !== "boolean") {
442
+ return void 0;
443
+ }
444
+ autoprefixer = value ? "1" : "0";
445
+ break;
297
446
  default:
298
447
  return void 0;
299
448
  }
@@ -312,7 +461,8 @@ function getSimpleOverrideCacheKey(options) {
312
461
  unitsToPx,
313
462
  cssCalc,
314
463
  cssChildCombinatorReplaceValue,
315
- cssPreflight
464
+ cssPreflight,
465
+ autoprefixer
316
466
  ].join(":");
317
467
  }
318
468
  function hasOverrides(options) {
@@ -387,6 +537,28 @@ function createInjectPreflight(options) {
387
537
  // src/pipeline.ts
388
538
  var _postcsspresetenv = require('postcss-preset-env'); var _postcsspresetenv2 = _interopRequireDefault(_postcsspresetenv);
389
539
 
540
+ // src/autoprefixer.ts
541
+ var _autoprefixer = require('autoprefixer'); var _autoprefixer2 = _interopRequireDefault(_autoprefixer);
542
+ var WEAPP_AUTOPREFIXER_BROWSERS = [
543
+ "iOS >= 8",
544
+ "Android >= 4.4",
545
+ "ChromeAndroid >= 37"
546
+ ];
547
+ var AUTOPREFIXER_PLUGIN_NAME = "autoprefixer";
548
+ function isAutoprefixerPlugin(plugin) {
549
+ return _optionalChain([plugin, 'optionalAccess', _19 => _19.postcssPlugin]) === AUTOPREFIXER_PLUGIN_NAME;
550
+ }
551
+ function resolveAutoprefixerPlugin(option) {
552
+ if (option === false) {
553
+ return void 0;
554
+ }
555
+ const userOptions = option === true || option === void 0 ? {} : option;
556
+ return _autoprefixer2.default.call(void 0, {
557
+ ...userOptions,
558
+ overrideBrowserslist: _nullishCoalesce(userOptions.overrideBrowserslist, () => ( WEAPP_AUTOPREFIXER_BROWSERS))
559
+ });
560
+ }
561
+
390
562
  // src/plugins/colorFunctionalFallback.ts
391
563
  var _postcssvalueparser = require('postcss-value-parser'); var _postcssvalueparser2 = _interopRequireDefault(_postcssvalueparser);
392
564
  var RGB_FUNCTION_NAME = "rgb";
@@ -394,10 +566,10 @@ var isSlashDiv = (node) => node.type === "div" && node.value === "/";
394
566
  function trimNodes(nodes2) {
395
567
  let start = 0;
396
568
  let end = nodes2.length;
397
- while (start < end && _optionalChain([nodes2, 'access', _9 => _9[start], 'optionalAccess', _10 => _10.type]) === "space") {
569
+ while (start < end && _optionalChain([nodes2, 'access', _20 => _20[start], 'optionalAccess', _21 => _21.type]) === "space") {
398
570
  start += 1;
399
571
  }
400
- while (end > start && _optionalChain([nodes2, 'access', _11 => _11[end - 1], 'optionalAccess', _12 => _12.type]) === "space") {
572
+ while (end > start && _optionalChain([nodes2, 'access', _22 => _22[end - 1], 'optionalAccess', _23 => _23.type]) === "space") {
401
573
  end -= 1;
402
574
  }
403
575
  return nodes2.slice(start, end);
@@ -532,7 +704,7 @@ function getCalcDuplicateCleaner(options) {
532
704
  // src/plugins/getCalcPlugin.ts
533
705
  var _postcsscalc = require('@weapp-tailwindcss/postcss-calc'); var _postcsscalc2 = _interopRequireDefault(_postcsscalc);
534
706
 
535
- // ../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/omit.mjs
707
+ // ../../node_modules/.pnpm/es-toolkit@1.46.0/node_modules/es-toolkit/dist/object/omit.mjs
536
708
  function omit(obj, keys) {
537
709
  const result = { ...obj };
538
710
  for (let i = 0; i < keys.length; i++) {
@@ -682,7 +854,7 @@ function getUnitsToPxPlugin(options) {
682
854
  // src/compat/tailwindcss-rpx.ts
683
855
  var LENGTH_VALUE_REGEXP = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?rpx$/i;
684
856
  function normalizeTailwindcssRpxDeclaration(decl, options) {
685
- const majorVersion = _optionalChain([options, 'optionalAccess', _13 => _13.majorVersion]);
857
+ const majorVersion = _optionalChain([options, 'optionalAccess', _24 => _24.majorVersion]);
686
858
  const normalizedValue = decl.value.trim();
687
859
  if (LENGTH_VALUE_REGEXP.test(normalizedValue) && (majorVersion === void 0 || majorVersion === 2 || majorVersion === 3 || majorVersion === 4)) {
688
860
  const lowerProp = decl.prop.toLowerCase();
@@ -869,7 +1041,7 @@ var MODERN_CHECK_COLOR_RGB_RE = /color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)
869
1041
  var RADIUS_VALUE_RE = /\b([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)\s*(r?px)\b/gi;
870
1042
  var SCIENTIFIC_NOTATION_RE = /e/i;
871
1043
  function isTailwindcssV4(options) {
872
- return _optionalChain([options, 'optionalAccess', _14 => _14.majorVersion]) === 4;
1044
+ return _optionalChain([options, 'optionalAccess', _25 => _25.majorVersion]) === 4;
873
1045
  }
874
1046
  function testIfRootHostForV4(node) {
875
1047
  return node.type === "rule" && node.selector.includes(":root") && node.selector.includes(":host");
@@ -919,7 +1091,7 @@ function normalizeTailwindcssV4Declaration(decl) {
919
1091
  var postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
920
1092
 
921
1093
  // src/selectorParser/before-after.ts
922
- var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
1094
+
923
1095
  var beforeAfterStateRef = null;
924
1096
  var BEFORE_PSEUDO_RE = /^:?:before$/;
925
1097
  var AFTER_PSEUDO_RE = /^:?:after$/;
@@ -929,7 +1101,7 @@ var beforeAfterParser = _postcssselectorparser2.default.call(void 0, (selectors)
929
1101
  return;
930
1102
  }
931
1103
  selectors.walkPseudos((s) => {
932
- if (_optionalChain([s, 'access', _15 => _15.parent, 'optionalAccess', _16 => _16.length]) === 1) {
1104
+ if (_optionalChain([s, 'access', _26 => _26.parent, 'optionalAccess', _27 => _27.length]) === 1) {
933
1105
  if (BEFORE_PSEUDO_RE.test(s.value)) {
934
1106
  state.before = true;
935
1107
  }
@@ -1032,13 +1204,13 @@ function getFallbackRemove(_rule, options) {
1032
1204
  maybeImportantId = true;
1033
1205
  }
1034
1206
  if (selector.type === "universal") {
1035
- _optionalChain([selector, 'access', _17 => _17.parent, 'optionalAccess', _18 => _18.remove, 'call', _19 => _19()]);
1207
+ _optionalChain([selector, 'access', _28 => _28.parent, 'optionalAccess', _29 => _29.remove, 'call', _30 => _30()]);
1036
1208
  } else if (selector.type === "pseudo") {
1037
1209
  if (selector.value === ":is") {
1038
- if (maybeImportantId && _optionalChain([selector, 'access', _20 => _20.nodes, 'access', _21 => _21[0], 'optionalAccess', _22 => _22.type]) === "selector") {
1210
+ if (maybeImportantId && _optionalChain([selector, 'access', _31 => _31.nodes, 'access', _32 => _32[0], 'optionalAccess', _33 => _33.type]) === "selector") {
1039
1211
  selector.replaceWith(selector.nodes[0]);
1040
1212
  } else {
1041
- _optionalChain([selector, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.remove, 'call', _25 => _25()]);
1213
+ _optionalChain([selector, 'access', _34 => _34.parent, 'optionalAccess', _35 => _35.remove, 'call', _36 => _36()]);
1042
1214
  }
1043
1215
  } else if (selector.value === ":not") {
1044
1216
  for (const x of selector.nodes) {
@@ -1061,7 +1233,7 @@ function getFallbackRemove(_rule, options) {
1061
1233
  }
1062
1234
  } else if (selector.type === "attribute") {
1063
1235
  if (selector.attribute === "hidden") {
1064
- _optionalChain([activeRule, 'optionalAccess', _26 => _26.remove, 'call', _27 => _27()]);
1236
+ _optionalChain([activeRule, 'optionalAccess', _37 => _37.remove, 'call', _38 => _38()]);
1065
1237
  }
1066
1238
  }
1067
1239
  });
@@ -1147,7 +1319,7 @@ function getEscapeOptions(escapeMap) {
1147
1319
  return cached;
1148
1320
  }
1149
1321
  function internalCssSelectorReplacer(selectors, options) {
1150
- const escapeMap = _optionalChain([options, 'optionalAccess', _28 => _28.escapeMap]);
1322
+ const escapeMap = _optionalChain([options, 'optionalAccess', _39 => _39.escapeMap]);
1151
1323
  if (escapeMap === void 0 || escapeMap === _escape.MappingChars2String) {
1152
1324
  return _escape.escape.call(void 0, selectors);
1153
1325
  }
@@ -1191,7 +1363,7 @@ function reorderLiteralFirst(rule, declarations, isVariable) {
1191
1363
  if (alreadyOrdered) {
1192
1364
  return;
1193
1365
  }
1194
- const anchor = _nullishCoalesce(_optionalChain([declarations, 'access', _29 => _29.at, 'call', _30 => _30(-1), 'optionalAccess', _31 => _31.next, 'call', _32 => _32()]), () => ( void 0));
1366
+ const anchor = _nullishCoalesce(_optionalChain([declarations, 'access', _40 => _40.at, 'call', _41 => _41(-1), 'optionalAccess', _42 => _42.next, 'call', _43 => _43()]), () => ( void 0));
1195
1367
  for (const decl of declarations) {
1196
1368
  decl.remove();
1197
1369
  }
@@ -1269,7 +1441,7 @@ function isNotLastChildPseudo(node) {
1269
1441
  if (!firstSelector || firstSelector.type !== "selector") {
1270
1442
  return false;
1271
1443
  }
1272
- const target = _optionalChain([firstSelector, 'access', _33 => _33.nodes, 'optionalAccess', _34 => _34[0]]);
1444
+ const target = _optionalChain([firstSelector, 'access', _44 => _44.nodes, 'optionalAccess', _45 => _45[0]]);
1273
1445
  return Boolean(target && target.type === "pseudo" && target.value === ":last-child");
1274
1446
  }
1275
1447
  function transformSpacingSelector(nodes2, options) {
@@ -1381,7 +1553,7 @@ function flattenWherePseudo(node, context, index, parent) {
1381
1553
  node.value = ":is";
1382
1554
  }
1383
1555
  if (index === 0 && node.length === 1) {
1384
- const targetSelector = _optionalChain([node, 'access', _35 => _35.nodes, 'optionalAccess', _36 => _36[0]]);
1556
+ const targetSelector = _optionalChain([node, 'access', _46 => _46.nodes, 'optionalAccess', _47 => _47[0]]);
1385
1557
  if (targetSelector && targetSelector.type === "selector" && transformSpacingSelector(targetSelector.nodes, context.options)) {
1386
1558
  context.requiresSpacingNormalization = true;
1387
1559
  }
@@ -1449,7 +1621,7 @@ function handleCombinatorNode(node, index, context) {
1449
1621
  if (node.type !== "combinator" || node.value !== ">") {
1450
1622
  return;
1451
1623
  }
1452
- const nodes2 = _optionalChain([node, 'access', _37 => _37.parent, 'optionalAccess', _38 => _38.nodes]);
1624
+ const nodes2 = _optionalChain([node, 'access', _48 => _48.parent, 'optionalAccess', _49 => _49.nodes]);
1453
1625
  if (!nodes2) {
1454
1626
  return;
1455
1627
  }
@@ -1502,7 +1674,7 @@ function canSkipRuleTransform(rule) {
1502
1674
  }
1503
1675
  function transformSelectors(selectors, context) {
1504
1676
  selectors.walk((node, index) => {
1505
- const parent = _optionalChain([node, 'access', _39 => _39.parent, 'optionalAccess', _40 => _40.type]) === "selector" ? node.parent : void 0;
1677
+ const parent = _optionalChain([node, 'access', _50 => _50.parent, 'optionalAccess', _51 => _51.type]) === "selector" ? node.parent : void 0;
1506
1678
  switch (node.type) {
1507
1679
  case "class":
1508
1680
  handleClassNode(node, context);
@@ -1549,8 +1721,8 @@ function createRuleTransformer(options) {
1549
1721
  let context;
1550
1722
  const selectorResultCache = /* @__PURE__ */ new Map();
1551
1723
  const selectorResultCacheLimit = 5e4;
1552
- const rootReplacement = _optionalChain([options, 'access', _41 => _41.cssSelectorReplacement, 'optionalAccess', _42 => _42.root]) ? composeIsPseudo(options.cssSelectorReplacement.root) : void 0;
1553
- const universalReplacement = _optionalChain([options, 'access', _43 => _43.cssSelectorReplacement, 'optionalAccess', _44 => _44.universal]) ? composeIsPseudo(options.cssSelectorReplacement.universal) : void 0;
1724
+ const rootReplacement = _optionalChain([options, 'access', _52 => _52.cssSelectorReplacement, 'optionalAccess', _53 => _53.root]) ? composeIsPseudo(options.cssSelectorReplacement.root) : void 0;
1725
+ const universalReplacement = _optionalChain([options, 'access', _54 => _54.cssSelectorReplacement, 'optionalAccess', _55 => _55.universal]) ? composeIsPseudo(options.cssSelectorReplacement.universal) : void 0;
1554
1726
  const selectorReplacerOptions = options.escapeMap ? { escapeMap: options.escapeMap } : void 0;
1555
1727
  function writeSelectorResultCache(selector, result) {
1556
1728
  if (selectorResultCache.size >= selectorResultCacheLimit) {
@@ -1598,7 +1770,7 @@ function createRuleTransformer(options) {
1598
1770
  } finally {
1599
1771
  const currentContext = context;
1600
1772
  wasRemoved = rule.parent == null;
1601
- requiresSpacingNormalization = _optionalChain([currentContext, 'optionalAccess', _45 => _45.requiresSpacingNormalization]) === true;
1773
+ requiresSpacingNormalization = _optionalChain([currentContext, 'optionalAccess', _56 => _56.requiresSpacingNormalization]) === true;
1602
1774
  context = void 0;
1603
1775
  }
1604
1776
  if (wasRemoved) {
@@ -1830,7 +2002,7 @@ function normalizeSelectorList(value) {
1830
2002
  return Array.isArray(value) ? value.filter(Boolean) : [value];
1831
2003
  }
1832
2004
  function getSpecificityMatchingName(options) {
1833
- const feature = _optionalChain([options, 'access', _46 => _46.cssPresetEnv, 'optionalAccess', _47 => _47.features, 'optionalAccess', _48 => _48["is-pseudo-class"]]);
2005
+ const feature = _optionalChain([options, 'access', _57 => _57.cssPresetEnv, 'optionalAccess', _58 => _58.features, 'optionalAccess', _59 => _59["is-pseudo-class"]]);
1834
2006
  if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
1835
2007
  const specificityName = feature.specificityMatchingName;
1836
2008
  return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
@@ -1878,12 +2050,12 @@ function createFallbackPlaceholderCleaner() {
1878
2050
  }
1879
2051
  function createRootSpecificityCleaner(options) {
1880
2052
  const specificityMatchingName = getSpecificityMatchingName(options);
1881
- const selectors = normalizeSelectorList(_optionalChain([options, 'access', _49 => _49.cssSelectorReplacement, 'optionalAccess', _50 => _50.root]));
2053
+ const selectors = normalizeSelectorList(_optionalChain([options, 'access', _60 => _60.cssSelectorReplacement, 'optionalAccess', _61 => _61.root]));
1882
2054
  if (!specificityMatchingName || selectors.length === 0) {
1883
2055
  return void 0;
1884
2056
  }
1885
2057
  const suffix = `:not(.${specificityMatchingName})`;
1886
- const targets = selectors.map((selector) => _optionalChain([selector, 'optionalAccess', _51 => _51.trim, 'call', _52 => _52()])).filter((selector) => Boolean(_optionalChain([selector, 'optionalAccess', _53 => _53.length]))).map((selector) => ({
2058
+ const targets = selectors.map((selector) => _optionalChain([selector, 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()])).filter((selector) => Boolean(_optionalChain([selector, 'optionalAccess', _64 => _64.length]))).map((selector) => ({
1887
2059
  match: `${selector}${suffix}`,
1888
2060
  spacedMatch: `${selector} ${suffix}`,
1889
2061
  replacement: selector
@@ -1927,7 +2099,7 @@ function normalizeRootSelectors(value) {
1927
2099
  return Array.isArray(value) ? value.filter(Boolean) : [value];
1928
2100
  }
1929
2101
  function createHostSelectorAppender(options) {
1930
- const rootSelectors = normalizeRootSelectors(_optionalChain([options, 'access', _54 => _54.cssSelectorReplacement, 'optionalAccess', _55 => _55.root]));
2102
+ const rootSelectors = normalizeRootSelectors(_optionalChain([options, 'access', _65 => _65.cssSelectorReplacement, 'optionalAccess', _66 => _66.root]));
1931
2103
  const shouldAppendHostSelector = rootSelectors.length === DEFAULT_ROOT_SELECTORS.length && rootSelectors.every((selector, index) => selector === DEFAULT_ROOT_SELECTORS[index]);
1932
2104
  if (!shouldAppendHostSelector) {
1933
2105
  return void 0;
@@ -1955,12 +2127,12 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
1955
2127
  const fallbackRemove = enableMainChunkTransforms ? getFallbackRemove(void 0, opts) : void 0;
1956
2128
  p.RuleExit = (rule) => {
1957
2129
  if (enableMainChunkTransforms) {
1958
- _optionalChain([fallbackRemove, 'optionalAccess', _56 => _56.transformSync, 'call', _57 => _57(rule)]);
2130
+ _optionalChain([fallbackRemove, 'optionalAccess', _67 => _67.transformSync, 'call', _68 => _68(rule)]);
1959
2131
  }
1960
2132
  cleanFallbackPlaceholder(rule);
1961
- _optionalChain([cleanRootSpecificity, 'optionalCall', _58 => _58(rule)]);
2133
+ _optionalChain([cleanRootSpecificity, 'optionalCall', _69 => _69(rule)]);
1962
2134
  if (enableMainChunkTransforms) {
1963
- if (_optionalChain([shouldAppendHostSelector, 'optionalCall', _59 => _59(rule)])) {
2135
+ if (_optionalChain([shouldAppendHostSelector, 'optionalCall', _70 => _70(rule)])) {
1964
2136
  appendRuleSelector(rule, ":host", {
1965
2137
  phase: "post",
1966
2138
  reason: "append-host-selector"
@@ -1989,7 +2161,7 @@ var postcssWeappTailwindcssPostPlugin = (options) => {
1989
2161
  if (opts.cssRemoveProperty && atRule.name === "property") {
1990
2162
  atRule.remove();
1991
2163
  }
1992
- _optionalChain([atRule, 'access', _60 => _60.nodes, 'optionalAccess', _61 => _61.length]) === 0 && atRule.remove();
2164
+ _optionalChain([atRule, 'access', _71 => _71.nodes, 'optionalAccess', _72 => _72.length]) === 0 && atRule.remove();
1993
2165
  };
1994
2166
  }
1995
2167
  return p;
@@ -2271,7 +2443,7 @@ function remakeCssVarSelector(selectors, options) {
2271
2443
  return selectors;
2272
2444
  }
2273
2445
  function resolveUniAppXVariableScopeSelectors(options) {
2274
- const universal = _optionalChain([options, 'access', _62 => _62.cssSelectorReplacement, 'optionalAccess', _63 => _63.universal]);
2446
+ const universal = _optionalChain([options, 'access', _73 => _73.cssSelectorReplacement, 'optionalAccess', _74 => _74.universal]);
2275
2447
  if (Array.isArray(universal) && universal.length > 0) {
2276
2448
  return [...universal];
2277
2449
  }
@@ -2283,7 +2455,7 @@ function resolveUniAppXVariableScopeSelectors(options) {
2283
2455
  function commonChunkPreflight(node, options) {
2284
2456
  const { ctx, cssInjectPreflight, injectAdditionalCssVarScope } = options;
2285
2457
  const uniAppXEnabled = isUniAppXEnabled(options);
2286
- const rootOption = _optionalChain([options, 'access', _64 => _64.cssSelectorReplacement, 'optionalAccess', _65 => _65.root]);
2458
+ const rootOption = _optionalChain([options, 'access', _75 => _75.cssSelectorReplacement, 'optionalAccess', _76 => _76.root]);
2287
2459
  const rootSelectors = rootOption === false || rootOption === void 0 ? [] : Array.isArray(rootOption) ? rootOption.filter(Boolean) : [rootOption];
2288
2460
  const hasHostSelector = node.selectors.some((selector) => selector.includes(":host"));
2289
2461
  const hasRootPseudoSelector = node.selectors.some((selector) => selector.includes(":root"));
@@ -2295,7 +2467,7 @@ function commonChunkPreflight(node, options) {
2295
2467
  });
2296
2468
  }
2297
2469
  if (testIfVariablesScope(node) || uniAppXEnabled && node.selectors.includes("*") && hasTwVars(node, 2)) {
2298
- _optionalChain([ctx, 'optionalAccess', _66 => _66.markVariablesScope, 'call', _67 => _67(node)]);
2470
+ _optionalChain([ctx, 'optionalAccess', _77 => _77.markVariablesScope, 'call', _78 => _78(node)]);
2299
2471
  assignRuleSelectors(node, uniAppXEnabled ? resolveUniAppXVariableScopeSelectors(options) : remakeCssVarSelector(node.selectors, options), {
2300
2472
  phase: "pre",
2301
2473
  reason: "rewrite-variable-scope"
@@ -2367,9 +2539,9 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
2367
2539
  root.walkAtRules((atRule) => {
2368
2540
  if (atRule.name === "layer") {
2369
2541
  if (atRule.params === "properties") {
2370
- if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _68 => _68.nodes, 'optionalAccess', _69 => _69.length]) === 0) {
2542
+ if (atRule.nodes === void 0 || _optionalChain([atRule, 'access', _79 => _79.nodes, 'optionalAccess', _80 => _80.length]) === 0) {
2371
2543
  layerProperties = atRule;
2372
- } else if (_optionalChain([atRule, 'access', _70 => _70.first, 'optionalAccess', _71 => _71.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
2544
+ } else if (_optionalChain([atRule, 'access', _81 => _81.first, 'optionalAccess', _82 => _82.type]) === "atrule" && isTailwindcssV4ModernCheck(atRule.first)) {
2373
2545
  if (layerProperties) {
2374
2546
  layerProperties.replaceWith(atRule.first.nodes);
2375
2547
  atRule.remove();
@@ -2381,7 +2553,7 @@ var postcssWeappTailwindcssPrePlugin = (options) => {
2381
2553
  atRule.replaceWith(atRule.nodes);
2382
2554
  }
2383
2555
  } else if (isTailwindcssV4ModernCheck(atRule)) {
2384
- if (_optionalChain([atRule, 'access', _72 => _72.first, 'optionalAccess', _73 => _73.type]) === "atrule" && atRule.first.name === "layer") {
2556
+ if (_optionalChain([atRule, 'access', _83 => _83.first, 'optionalAccess', _84 => _84.type]) === "atrule" && atRule.first.name === "layer") {
2385
2557
  atRule.replaceWith(atRule.first.nodes);
2386
2558
  }
2387
2559
  }
@@ -2415,16 +2587,42 @@ function createPreparedNode(id, stage, createPlugin) {
2415
2587
  createPlugin
2416
2588
  };
2417
2589
  }
2418
- function createPreparedNodes(options) {
2590
+ function hasUserAutoprefixerPlugin(rawPlugins, plugins) {
2591
+ if (plugins.some((plugin) => isAutoprefixerPlugin(plugin))) {
2592
+ return true;
2593
+ }
2594
+ if (rawPlugins && !Array.isArray(rawPlugins) && typeof rawPlugins === "object") {
2595
+ const autoprefixerEntry = rawPlugins["autoprefixer"];
2596
+ return Boolean(autoprefixerEntry);
2597
+ }
2598
+ return false;
2599
+ }
2600
+ function shouldUseDefaultAutoprefixer(options, userPlugins) {
2601
+ if (options.autoprefixer === false) {
2602
+ return false;
2603
+ }
2604
+ if (hasUserAutoprefixerPlugin(_optionalChain([options, 'access', _85 => _85.postcssOptions, 'optionalAccess', _86 => _86.plugins]), userPlugins)) {
2605
+ return false;
2606
+ }
2607
+ if (options.autoprefixer === true || typeof options.autoprefixer === "object") {
2608
+ return true;
2609
+ }
2610
+ return options.majorVersion === 4;
2611
+ }
2612
+ function createPreparedNodes(options, signal) {
2419
2613
  const preparedNodes = [];
2420
- const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access', _74 => _74.postcssOptions, 'optionalAccess', _75 => _75.plugins]));
2614
+ const userPlugins = normalizeUserPlugins(_optionalChain([options, 'access', _87 => _87.postcssOptions, 'optionalAccess', _88 => _88.plugins]));
2421
2615
  const presetEnvOptions = options.cssPresetEnv;
2422
2616
  userPlugins.forEach((plugin, index) => {
2423
2617
  preparedNodes.push(createPreparedNode(`pre:user-${index}`, "pre", () => plugin));
2424
2618
  });
2425
2619
  preparedNodes.push(createPreparedNode("pre:core", "pre", () => postcssWeappTailwindcssPrePlugin(options)));
2426
- preparedNodes.push(createPreparedNode("normal:preset-env", "normal", () => _postcsspresetenv2.default.call(void 0, presetEnvOptions)));
2427
- preparedNodes.push(createPreparedNode("normal:color-functional-fallback", "normal", () => createColorFunctionalFallback()));
2620
+ if (!signal || signal.hasPresetEnvFeatures) {
2621
+ preparedNodes.push(createPreparedNode("normal:preset-env", "normal", () => _postcsspresetenv2.default.call(void 0, presetEnvOptions)));
2622
+ }
2623
+ if (!signal || signal.hasModernColorFunction) {
2624
+ preparedNodes.push(createPreparedNode("normal:color-functional-fallback", "normal", () => createColorFunctionalFallback()));
2625
+ }
2428
2626
  const unitsToPxPlugin = getUnitsToPxPlugin(options);
2429
2627
  if (unitsToPxPlugin) {
2430
2628
  preparedNodes.push(createPreparedNode("normal:units-to-px", "normal", () => unitsToPxPlugin));
@@ -2449,12 +2647,18 @@ function createPreparedNodes(options) {
2449
2647
  if (customPropertyCleaner) {
2450
2648
  preparedNodes.push(createPreparedNode("normal:custom-property-cleaner", "normal", () => customPropertyCleaner));
2451
2649
  }
2650
+ if (shouldUseDefaultAutoprefixer(options, userPlugins)) {
2651
+ const plugin = resolveAutoprefixerPlugin(options.autoprefixer);
2652
+ if (plugin) {
2653
+ preparedNodes.push(createPreparedNode("normal:autoprefixer", "normal", () => plugin));
2654
+ }
2655
+ }
2452
2656
  preparedNodes.push(createPreparedNode("post:core", "post", () => postcssWeappTailwindcssPostPlugin(options)));
2453
2657
  return preparedNodes;
2454
2658
  }
2455
- function createStylePipeline(options) {
2659
+ function createStylePipeline(options, signal) {
2456
2660
  options.ctx = createContext();
2457
- const preparedNodes = createPreparedNodes(options);
2661
+ const preparedNodes = createPreparedNodes(options, signal);
2458
2662
  if (preparedNodes.length === 0) {
2459
2663
  return {
2460
2664
  nodes: [],
@@ -2513,7 +2717,7 @@ function createStylePipeline(options) {
2513
2717
  function createProcessOptions(options) {
2514
2718
  return {
2515
2719
  from: void 0,
2516
- ..._nullishCoalesce(_optionalChain([options, 'access', _76 => _76.postcssOptions, 'optionalAccess', _77 => _77.options]), () => ( {}))
2720
+ ..._nullishCoalesce(_optionalChain([options, 'access', _89 => _89.postcssOptions, 'optionalAccess', _90 => _90.options]), () => ( {}))
2517
2721
  };
2518
2722
  }
2519
2723
  function getSimpleProcessOptionsCacheKey(options) {
@@ -2545,14 +2749,13 @@ function getSimpleProcessOptionsCacheKey(options) {
2545
2749
  }
2546
2750
  return parts.join("|");
2547
2751
  }
2548
- var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this); }
2549
- __init() {this.pipelineCache = /* @__PURE__ */ new WeakMap()}
2752
+ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this); }
2753
+ __init() {this.pipelineCacheByKey = /* @__PURE__ */ new Map()}
2550
2754
  __init2() {this.processOptionsCache = /* @__PURE__ */ new WeakMap()}
2551
- __init3() {this.processorCache = /* @__PURE__ */ new WeakMap()}
2552
- __init4() {this.processorCacheByKey = /* @__PURE__ */ new Map()}
2553
- __init5() {this.processorKeyCache = /* @__PURE__ */ new WeakMap()}
2755
+ __init3() {this.processorCacheByKey = /* @__PURE__ */ new Map()}
2756
+ __init4() {this.processorKeyCache = /* @__PURE__ */ new WeakMap()}
2554
2757
  createProcessorCacheKey(options) {
2555
- const from = _optionalChain([options, 'access', _78 => _78.postcssOptions, 'optionalAccess', _79 => _79.options, 'optionalAccess', _80 => _80.from]);
2758
+ const from = _optionalChain([options, 'access', _91 => _91.postcssOptions, 'optionalAccess', _92 => _92.options, 'optionalAccess', _93 => _93.from]);
2556
2759
  if (from == null) {
2557
2760
  return fingerprintOptions(options);
2558
2761
  }
@@ -2561,22 +2764,37 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
2561
2764
  postcssOptions: {
2562
2765
  ..._nullishCoalesce(options.postcssOptions, () => ( {})),
2563
2766
  options: {
2564
- ..._nullishCoalesce(_optionalChain([options, 'access', _81 => _81.postcssOptions, 'optionalAccess', _82 => _82.options]), () => ( {})),
2767
+ ..._nullishCoalesce(_optionalChain([options, 'access', _94 => _94.postcssOptions, 'optionalAccess', _95 => _95.options]), () => ( {})),
2565
2768
  from: void 0
2566
2769
  }
2567
2770
  }
2568
2771
  });
2569
2772
  }
2570
- getPipeline(options) {
2571
- let pipeline = this.pipelineCache.get(options);
2773
+ /**
2774
+ * 构建包含信号的复合缓存键
2775
+ */
2776
+ createCompositeCacheKey(optionsFingerprint, signal) {
2777
+ if (!signal) {
2778
+ return optionsFingerprint;
2779
+ }
2780
+ return `${optionsFingerprint}|${signalToCacheKey(signal)}`;
2781
+ }
2782
+ getPipeline(options, signal) {
2783
+ let optionsKey = this.processorKeyCache.get(options);
2784
+ if (!optionsKey) {
2785
+ optionsKey = this.createProcessorCacheKey(options);
2786
+ this.processorKeyCache.set(options, optionsKey);
2787
+ }
2788
+ const compositeKey = this.createCompositeCacheKey(optionsKey, signal);
2789
+ let pipeline = this.pipelineCacheByKey.get(compositeKey);
2572
2790
  if (!pipeline) {
2573
- pipeline = createStylePipeline(options);
2574
- this.pipelineCache.set(options, pipeline);
2791
+ pipeline = createStylePipeline(options, signal);
2792
+ this.pipelineCacheByKey.set(compositeKey, pipeline);
2575
2793
  }
2576
2794
  return pipeline;
2577
2795
  }
2578
2796
  getProcessOptions(options) {
2579
- const source = _optionalChain([options, 'access', _83 => _83.postcssOptions, 'optionalAccess', _84 => _84.options]);
2797
+ const source = _optionalChain([options, 'access', _96 => _96.postcssOptions, 'optionalAccess', _97 => _97.options]);
2580
2798
  const cacheKey = source ? _nullishCoalesce(getSimpleProcessOptionsCacheKey(source), () => ( fingerprintOptions(source))) : void 0;
2581
2799
  const cached = this.processOptionsCache.get(options);
2582
2800
  if (!cached || cached.cacheKey !== cacheKey) {
@@ -2586,27 +2804,33 @@ var StyleProcessorCache = (_class = class {constructor() { _class.prototype.__in
2586
2804
  }
2587
2805
  return { ...cached.value };
2588
2806
  }
2589
- getProcessor(options) {
2590
- let processor = this.processorCache.get(options);
2807
+ getProcessor(options, signal) {
2808
+ let optionsKey = this.processorKeyCache.get(options);
2809
+ if (!optionsKey) {
2810
+ optionsKey = this.createProcessorCacheKey(options);
2811
+ this.processorKeyCache.set(options, optionsKey);
2812
+ }
2813
+ const compositeKey = this.createCompositeCacheKey(optionsKey, signal);
2814
+ let processor = this.processorCacheByKey.get(compositeKey);
2591
2815
  if (!processor) {
2592
- let cacheKey = this.processorKeyCache.get(options);
2593
- if (!cacheKey) {
2594
- cacheKey = this.createProcessorCacheKey(options);
2595
- this.processorKeyCache.set(options, cacheKey);
2596
- }
2597
- processor = this.processorCacheByKey.get(cacheKey);
2598
- if (!processor) {
2599
- const pipeline = this.getPipeline(options);
2600
- processor = _postcss2.default.call(void 0, pipeline.plugins);
2601
- this.processorCacheByKey.set(cacheKey, processor);
2602
- }
2603
- this.processorCache.set(options, processor);
2816
+ const pipeline = this.getPipeline(options, signal);
2817
+ processor = _postcss2.default.call(void 0, pipeline.plugins);
2818
+ this.processorCacheByKey.set(compositeKey, processor);
2604
2819
  }
2605
2820
  return processor;
2606
2821
  }
2607
2822
  }, _class);
2608
2823
 
2609
2824
  // src/handler.ts
2825
+ var CSS_RESULT_CACHE_MAX = 256;
2826
+ function simpleHash(str) {
2827
+ let hash = 2166136261 | 0;
2828
+ for (let i = 0; i < str.length; i++) {
2829
+ hash ^= str.charCodeAt(i);
2830
+ hash = hash * 16777619 | 0;
2831
+ }
2832
+ return (hash >>> 0).toString(36);
2833
+ }
2610
2834
  function createStyleHandler(options) {
2611
2835
  const cachedOptions = _shared.defuOverrideArray.call(void 0,
2612
2836
  options,
@@ -2614,22 +2838,57 @@ function createStyleHandler(options) {
2614
2838
  );
2615
2839
  cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
2616
2840
  const resolver = createOptionsResolver(cachedOptions);
2617
- const cache = new StyleProcessorCache();
2841
+ const processorCache = new StyleProcessorCache();
2618
2842
  const base = resolver.resolve();
2619
- cache.getProcessor(base);
2620
- cache.getProcessOptions(base);
2843
+ processorCache.getProcessor(base);
2844
+ processorCache.getProcessOptions(base);
2845
+ const optionsFingerprintCache = /* @__PURE__ */ new WeakMap();
2846
+ function getOptionsFingerprint(opts) {
2847
+ const cached = optionsFingerprintCache.get(opts);
2848
+ if (cached) {
2849
+ return cached;
2850
+ }
2851
+ const fp = fingerprintOptions(opts);
2852
+ optionsFingerprintCache.set(opts, fp);
2853
+ return fp;
2854
+ }
2855
+ const resultCache = new (0, _lrucache.LRUCache)({ max: CSS_RESULT_CACHE_MAX });
2856
+ const hasUserPlugins = Boolean(
2857
+ _optionalChain([cachedOptions, 'access', _98 => _98.postcssOptions, 'optionalAccess', _99 => _99.plugins]) && (Array.isArray(cachedOptions.postcssOptions.plugins) ? cachedOptions.postcssOptions.plugins.length > 0 : typeof cachedOptions.postcssOptions.plugins === "object" && Object.keys(cachedOptions.postcssOptions.plugins).length > 0)
2858
+ );
2621
2859
  const handler = ((rawSource, opt) => {
2622
2860
  const resolvedOptions = resolver.resolve(opt);
2623
- const processor = cache.getProcessor(resolvedOptions);
2624
- const processOptions = cache.getProcessOptions(resolvedOptions);
2861
+ let signal;
2862
+ if (!hasUserPlugins) {
2863
+ try {
2864
+ signal = probeFeatures(rawSource);
2865
+ } catch (e3) {
2866
+ signal = void 0;
2867
+ }
2868
+ }
2869
+ const optsFp = getOptionsFingerprint(resolvedOptions);
2870
+ const signalKey = signal ? signalToCacheKey(signal) : "";
2871
+ const contentHash = simpleHash(rawSource);
2872
+ const cacheKey = `${optsFp}|${signalKey}|${contentHash}`;
2873
+ const cachedResult = resultCache.get(cacheKey);
2874
+ if (cachedResult) {
2875
+ return Promise.resolve(cachedResult);
2876
+ }
2877
+ const processor = processorCache.getProcessor(resolvedOptions, signal);
2878
+ const processOptions = processorCache.getProcessOptions(resolvedOptions);
2625
2879
  return processor.process(
2626
2880
  rawSource,
2627
2881
  processOptions
2628
- ).async().then((result) => applyUniAppXBaseCompatibility(result, resolvedOptions));
2882
+ ).async().then((result) => {
2883
+ const baseCompatible = applyUniAppXBaseCompatibility(result, resolvedOptions);
2884
+ const finalResult = applyUniAppXUvueCompatibility(baseCompatible, resolvedOptions);
2885
+ resultCache.set(cacheKey, finalResult);
2886
+ return finalResult;
2887
+ });
2629
2888
  });
2630
2889
  handler.getPipeline = (opt) => {
2631
2890
  const resolvedOptions = resolver.resolve(opt);
2632
- return cache.getPipeline(resolvedOptions);
2891
+ return processorCache.getPipeline(resolvedOptions);
2633
2892
  };
2634
2893
  return handler;
2635
2894
  }
@@ -2639,4 +2898,5 @@ function createStyleHandler(options) {
2639
2898
 
2640
2899
 
2641
2900
 
2642
- exports.createFallbackPlaceholderReplacer = createFallbackPlaceholderReplacer; exports.createInjectPreflight = createInjectPreflight; exports.createStyleHandler = createStyleHandler; exports.createStylePipeline = createStylePipeline; exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
2901
+
2902
+ exports.createFallbackPlaceholderReplacer = createFallbackPlaceholderReplacer; exports.createInjectPreflight = createInjectPreflight; exports.createStyleHandler = createStyleHandler; exports.createStylePipeline = createStylePipeline; exports.internalCssSelectorReplacer = internalCssSelectorReplacer; exports.postcssHtmlTransform = _chunk2Y3ULRB3js.html_transform_default;