weapp-tailwindcss 4.10.1 → 4.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{chunk-EE4DYM4E.js → chunk-3R7FDZJL.js} +27 -17
  2. package/dist/{chunk-K7CTHHN2.js → chunk-6VKE7EWV.js} +28 -27
  3. package/dist/{chunk-GKT5AE7D.mjs → chunk-ACNOEKQI.mjs} +1 -1
  4. package/dist/{chunk-4QCL7FBX.mjs → chunk-BZCCVPSU.mjs} +1 -1
  5. package/dist/{chunk-P65O2L27.js → chunk-HJVZ4TO3.js} +3 -3
  6. package/dist/{chunk-7K3R5LV6.js → chunk-I35XJD75.js} +235 -63
  7. package/dist/{chunk-3BKE5AJQ.mjs → chunk-LHBUALTK.mjs} +4 -3
  8. package/dist/{chunk-RB7YN5XZ.js → chunk-M2ATX5ZS.js} +3 -3
  9. package/dist/{chunk-RXM5ERRJ.mjs → chunk-MPVAZKRB.mjs} +201 -29
  10. package/dist/{chunk-7ZI6WVIU.mjs → chunk-N6JOG5K3.mjs} +3 -2
  11. package/dist/{chunk-W3EZEDKD.js → chunk-NPZ5QQC7.js} +8 -7
  12. package/dist/{chunk-ESIT2XWD.mjs → chunk-WJU62RPV.mjs} +13 -3
  13. package/dist/cli.js +9 -9
  14. package/dist/cli.mjs +1 -1
  15. package/dist/core.d.mts +1 -1
  16. package/dist/core.d.ts +1 -1
  17. package/dist/core.js +22 -9
  18. package/dist/core.mjs +17 -4
  19. package/dist/defaults.d.mts +1 -1
  20. package/dist/defaults.d.ts +1 -1
  21. package/dist/gulp.d.mts +1 -1
  22. package/dist/gulp.d.ts +1 -1
  23. package/dist/gulp.js +4 -4
  24. package/dist/gulp.mjs +3 -3
  25. package/dist/{index-BESv5MWf.d.ts → index-t_VBjwYm.d.mts} +11 -0
  26. package/dist/{index-BESv5MWf.d.mts → index-t_VBjwYm.d.ts} +11 -0
  27. package/dist/index.d.mts +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +7 -7
  30. package/dist/index.mjs +6 -6
  31. package/dist/presets.d.mts +1 -1
  32. package/dist/presets.d.ts +1 -1
  33. package/dist/types.d.mts +14 -2
  34. package/dist/types.d.ts +14 -2
  35. package/dist/vite.d.mts +1 -1
  36. package/dist/vite.d.ts +1 -1
  37. package/dist/vite.js +4 -4
  38. package/dist/vite.mjs +3 -3
  39. package/dist/webpack.d.mts +1 -1
  40. package/dist/webpack.d.ts +1 -1
  41. package/dist/webpack.js +5 -5
  42. package/dist/webpack.mjs +4 -4
  43. package/dist/webpack4.d.mts +1 -1
  44. package/dist/webpack4.d.ts +1 -1
  45. package/dist/webpack4.js +27 -26
  46. package/dist/webpack4.mjs +4 -3
  47. package/package.json +4 -4
@@ -16,10 +16,10 @@ var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
16
16
  var _debug2 = require('debug'); var _debug3 = _interopRequireDefault(_debug2);
17
17
  var _debug = _debug3.default.call(void 0, "weapp-tw");
18
18
  function createDebug(prefix) {
19
- function debug2(formatter, ...args) {
19
+ function debug3(formatter, ...args) {
20
20
  return _debug((_nullishCoalesce(prefix, () => ( ""))) + formatter, ...args);
21
21
  }
22
- return debug2;
22
+ return debug3;
23
23
  }
24
24
 
25
25
  // src/tailwindcss/runtime/cache.ts
@@ -285,7 +285,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
285
285
  // package.json
286
286
  var package_default = {
287
287
  name: "weapp-tailwindcss",
288
- version: "4.10.1",
288
+ version: "4.10.2",
289
289
  description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
290
290
  author: "ice breaker <1324318532@qq.com>",
291
291
  license: "MIT",
@@ -1189,22 +1189,80 @@ var _escape = require('@ast-core/escape');
1189
1189
 
1190
1190
  var _extractors = require('@weapp-tailwindcss/shared/extractors');
1191
1191
 
1192
+ // src/wxml/shared.ts
1193
+ var _escape3 = require('@weapp-core/escape');
1194
+ function replaceWxml(original, options = {
1195
+ keepEOL: false,
1196
+ escapeMap: _escape3.MappingChars2String
1197
+ }) {
1198
+ const { keepEOL, escapeMap, ignoreHead } = options;
1199
+ let res = original;
1200
+ if (!keepEOL) {
1201
+ res = res.replaceAll(/[\n\r]+/g, "");
1202
+ }
1203
+ res = _escape3.escape.call(void 0, res, {
1204
+ map: escapeMap,
1205
+ ignoreHead
1206
+ });
1207
+ return res;
1208
+ }
1209
+
1192
1210
  // src/shared/classname-transform.ts
1193
- function shouldTransformClassNameCandidate(candidate, {
1211
+ function isArbitraryValueCandidate(candidate) {
1212
+ const normalized = candidate.trim();
1213
+ if (!normalized.includes("[") || !normalized.includes("]")) {
1214
+ return false;
1215
+ }
1216
+ if (/^(?:https?:)?\/\//.test(normalized)) {
1217
+ return false;
1218
+ }
1219
+ return true;
1220
+ }
1221
+ function shouldEnableArbitraryValueFallback({
1222
+ classNameSet,
1223
+ jsArbitraryValueFallback,
1224
+ tailwindcssMajorVersion
1225
+ }) {
1226
+ if (jsArbitraryValueFallback === true) {
1227
+ return true;
1228
+ }
1229
+ if (jsArbitraryValueFallback === false) {
1230
+ return false;
1231
+ }
1232
+ return tailwindcssMajorVersion === 4 && (!classNameSet || classNameSet.size === 0);
1233
+ }
1234
+ function resolveClassNameTransformDecision(candidate, {
1194
1235
  alwaysEscape,
1195
1236
  classNameSet,
1196
- jsPreserveClass
1237
+ escapeMap,
1238
+ jsArbitraryValueFallback,
1239
+ jsPreserveClass,
1240
+ tailwindcssMajorVersion,
1241
+ classContext
1197
1242
  }) {
1198
1243
  if (alwaysEscape) {
1199
- return true;
1244
+ return "direct";
1200
1245
  }
1201
1246
  if (_optionalChain([jsPreserveClass, 'optionalCall', _33 => _33(candidate)])) {
1202
- return false;
1247
+ return "skip";
1203
1248
  }
1204
- if (!classNameSet || classNameSet.size === 0) {
1205
- return false;
1249
+ if (_optionalChain([classNameSet, 'optionalAccess', _34 => _34.has, 'call', _35 => _35(candidate)])) {
1250
+ return "direct";
1251
+ }
1252
+ if (classNameSet && classNameSet.size > 0) {
1253
+ const escapedCandidate = replaceWxml(candidate, { escapeMap });
1254
+ if (escapedCandidate !== candidate && classNameSet.has(escapedCandidate)) {
1255
+ return "escaped";
1256
+ }
1257
+ }
1258
+ if (classContext && isArbitraryValueCandidate(candidate) && shouldEnableArbitraryValueFallback({
1259
+ classNameSet,
1260
+ jsArbitraryValueFallback,
1261
+ tailwindcssMajorVersion
1262
+ })) {
1263
+ return "fallback";
1206
1264
  }
1207
- return classNameSet.has(candidate);
1265
+ return "skip";
1208
1266
  }
1209
1267
 
1210
1268
  // src/utils/decode.ts
@@ -1230,25 +1288,105 @@ function decodeUnicode2(input) {
1230
1288
  }
1231
1289
  }
1232
1290
 
1233
- // src/wxml/shared.ts
1234
- var _escape3 = require('@weapp-core/escape');
1235
- function replaceWxml(original, options = {
1236
- keepEOL: false,
1237
- escapeMap: _escape3.MappingChars2String
1238
- }) {
1239
- const { keepEOL, escapeMap, ignoreHead } = options;
1240
- let res = original;
1241
- if (!keepEOL) {
1242
- res = res.replaceAll(/[\n\r]+/g, "");
1291
+ // src/js/class-context.ts
1292
+ var CLASS_LIKE_KEYWORDS = /* @__PURE__ */ new Set([
1293
+ "class",
1294
+ "classname",
1295
+ "hoverclass",
1296
+ "virtualhostclass",
1297
+ "rootclass"
1298
+ ]);
1299
+ var CLASS_HELPER_IDENTIFIERS = /* @__PURE__ */ new Set([
1300
+ "cn",
1301
+ "clsx",
1302
+ "classnames",
1303
+ "twmerge",
1304
+ "cva",
1305
+ "tv",
1306
+ "cx",
1307
+ "r"
1308
+ ]);
1309
+ function normalizeKeyword(name) {
1310
+ return name.replace(/[-_:]/g, "").toLowerCase();
1311
+ }
1312
+ function readObjectKeyName(path5) {
1313
+ if (path5.isIdentifier()) {
1314
+ return path5.node.name;
1243
1315
  }
1244
- res = _escape3.escape.call(void 0, res, {
1245
- map: escapeMap,
1246
- ignoreHead
1247
- });
1248
- return res;
1316
+ if (path5.isStringLiteral()) {
1317
+ return path5.node.value;
1318
+ }
1319
+ if (path5.isTemplateLiteral() && path5.node.expressions.length === 0) {
1320
+ return _nullishCoalesce(_optionalChain([path5, 'access', _36 => _36.node, 'access', _37 => _37.quasis, 'access', _38 => _38[0], 'optionalAccess', _39 => _39.value, 'access', _40 => _40.cooked]), () => ( _optionalChain([path5, 'access', _41 => _41.node, 'access', _42 => _42.quasis, 'access', _43 => _43[0], 'optionalAccess', _44 => _44.value, 'access', _45 => _45.raw])));
1321
+ }
1322
+ return void 0;
1323
+ }
1324
+ function isClassLikeObjectProperty(path5, valuePath) {
1325
+ if (!path5.isObjectProperty()) {
1326
+ return false;
1327
+ }
1328
+ if (path5.get("value") !== valuePath) {
1329
+ return false;
1330
+ }
1331
+ const keyName = readObjectKeyName(path5.get("key"));
1332
+ if (!keyName) {
1333
+ return false;
1334
+ }
1335
+ return CLASS_LIKE_KEYWORDS.has(normalizeKeyword(keyName));
1336
+ }
1337
+ function isClassLikeJsxAttribute(path5) {
1338
+ if (!path5.isJSXAttribute()) {
1339
+ return false;
1340
+ }
1341
+ const namePath = path5.get("name");
1342
+ if (!namePath.isJSXIdentifier()) {
1343
+ return false;
1344
+ }
1345
+ return CLASS_LIKE_KEYWORDS.has(normalizeKeyword(namePath.node.name));
1346
+ }
1347
+ function isClassLikeCallExpression(path5, valuePath) {
1348
+ if (!path5.isCallExpression()) {
1349
+ return false;
1350
+ }
1351
+ const args = path5.get("arguments");
1352
+ if (!args.includes(valuePath)) {
1353
+ return false;
1354
+ }
1355
+ const calleePath = path5.get("callee");
1356
+ if (calleePath.isIdentifier()) {
1357
+ return CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(calleePath.node.name));
1358
+ }
1359
+ if (calleePath.isMemberExpression()) {
1360
+ const propertyPath = calleePath.get("property");
1361
+ if (propertyPath.isIdentifier()) {
1362
+ return CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(propertyPath.node.name));
1363
+ }
1364
+ if (propertyPath.isStringLiteral()) {
1365
+ return CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(propertyPath.node.value));
1366
+ }
1367
+ }
1368
+ return false;
1369
+ }
1370
+ function isClassContextLiteralPath(path5) {
1371
+ let current = path5;
1372
+ while (current.parentPath) {
1373
+ const parent = current.parentPath;
1374
+ if (isClassLikeObjectProperty(parent, current)) {
1375
+ return true;
1376
+ }
1377
+ if (isClassLikeJsxAttribute(parent)) {
1378
+ return true;
1379
+ }
1380
+ if (isClassLikeCallExpression(parent, current)) {
1381
+ return true;
1382
+ }
1383
+ current = parent;
1384
+ }
1385
+ return false;
1249
1386
  }
1250
1387
 
1251
1388
  // src/js/handlers.ts
1389
+ var debug2 = createDebug("[js:handlers] ");
1252
1390
  var patternCache = /* @__PURE__ */ new Map();
1253
1391
  var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
1254
1392
  var defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -1285,7 +1423,7 @@ function hasIgnoreComment(node) {
1285
1423
  return Array.isArray(node.leadingComments) && node.leadingComments.some((comment) => comment.value.includes("weapp-tw") && comment.value.includes("ignore"));
1286
1424
  }
1287
1425
  function extractLiteralValue(path5, { unescapeUnicode, arbitraryValues }) {
1288
- const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _34 => _34.allowDoubleQuotes]);
1426
+ const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _46 => _46.allowDoubleQuotes]);
1289
1427
  let offset = 0;
1290
1428
  let original;
1291
1429
  if (path5.isStringLiteral()) {
@@ -1313,7 +1451,9 @@ function replaceHandleValue(path5, options) {
1313
1451
  needEscaped = false
1314
1452
  } = options;
1315
1453
  const { classNameSet, alwaysEscape } = options;
1316
- if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
1454
+ const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
1455
+ const classContext = options.wrapExpression || isClassContextLiteralPath(path5);
1456
+ if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) {
1317
1457
  return void 0;
1318
1458
  }
1319
1459
  const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path5, options);
@@ -1326,10 +1466,24 @@ function replaceHandleValue(path5, options) {
1326
1466
  }
1327
1467
  let transformed = literal;
1328
1468
  let mutated = false;
1469
+ let matchedCandidateCount = 0;
1470
+ let escapedDecisionCount = 0;
1471
+ let fallbackDecisionCount = 0;
1329
1472
  for (const candidate of candidates) {
1330
- if (!shouldTransformClassNameCandidate(candidate, options)) {
1473
+ const decision = resolveClassNameTransformDecision(candidate, {
1474
+ ...options,
1475
+ classContext
1476
+ });
1477
+ if (decision === "skip") {
1331
1478
  continue;
1332
1479
  }
1480
+ matchedCandidateCount += 1;
1481
+ if (decision === "escaped") {
1482
+ escapedDecisionCount += 1;
1483
+ }
1484
+ if (decision === "fallback") {
1485
+ fallbackDecisionCount += 1;
1486
+ }
1333
1487
  if (!transformed.includes(candidate)) {
1334
1488
  continue;
1335
1489
  }
@@ -1345,6 +1499,16 @@ function replaceHandleValue(path5, options) {
1345
1499
  if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") {
1346
1500
  return void 0;
1347
1501
  }
1502
+ if (debug2.enabled) {
1503
+ debug2(
1504
+ "runtimeSet size=%d fallbackTriggered=%s matchedCandidates=%d escapedHits=%d file=%s",
1505
+ _nullishCoalesce(_optionalChain([classNameSet, 'optionalAccess', _47 => _47.size]), () => ( 0)),
1506
+ fallbackDecisionCount > 0,
1507
+ matchedCandidateCount,
1508
+ escapedDecisionCount,
1509
+ _nullishCoalesce(options.filename, () => ( "unknown"))
1510
+ );
1511
+ }
1348
1512
  const start = node.start + offset;
1349
1513
  const end = node.end - offset;
1350
1514
  if (start >= end || transformed === original) {
@@ -1518,7 +1682,7 @@ function handleEvalTemplateElement(path5, options, updater, handler) {
1518
1682
  }
1519
1683
  }
1520
1684
  function walkEvalExpression(path5, options, updater, handler) {
1521
- const maybeTraverse = _optionalChain([path5, 'optionalAccess', _35 => _35.traverse]);
1685
+ const maybeTraverse = _optionalChain([path5, 'optionalAccess', _48 => _48.traverse]);
1522
1686
  if (typeof maybeTraverse === "function") {
1523
1687
  try {
1524
1688
  return maybeTraverse.call(path5, {
@@ -1530,21 +1694,21 @@ function walkEvalExpression(path5, options, updater, handler) {
1530
1694
  }
1531
1695
  });
1532
1696
  } catch (error) {
1533
- const msg = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _36 => _36.message]), () => ( ""));
1697
+ const msg = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _49 => _49.message]), () => ( ""));
1534
1698
  const scopeError = /pass a scope and parentPath|traversing a Program\/File/i.test(msg);
1535
1699
  if (!scopeError) {
1536
1700
  throw error;
1537
1701
  }
1538
1702
  }
1539
1703
  }
1540
- const getArgs = _optionalChain([path5, 'optionalAccess', _37 => _37.get, 'optionalCall', _38 => _38("arguments")]);
1704
+ const getArgs = _optionalChain([path5, 'optionalAccess', _50 => _50.get, 'optionalCall', _51 => _51("arguments")]);
1541
1705
  if (Array.isArray(getArgs)) {
1542
1706
  for (const arg of getArgs) {
1543
- if (_optionalChain([arg, 'optionalAccess', _39 => _39.isStringLiteral, 'optionalCall', _40 => _40()])) {
1707
+ if (_optionalChain([arg, 'optionalAccess', _52 => _52.isStringLiteral, 'optionalCall', _53 => _53()])) {
1544
1708
  handleEvalStringLiteral(arg, options, updater, handler);
1545
1709
  continue;
1546
1710
  }
1547
- if (_optionalChain([arg, 'optionalAccess', _41 => _41.isTemplateLiteral, 'optionalCall', _42 => _42()])) {
1711
+ if (_optionalChain([arg, 'optionalAccess', _54 => _54.isTemplateLiteral, 'optionalCall', _55 => _55()])) {
1548
1712
  for (const quasi of arg.get("quasis")) {
1549
1713
  handleEvalTemplateElement(quasi, options, updater, handler);
1550
1714
  }
@@ -1552,16 +1716,16 @@ function walkEvalExpression(path5, options, updater, handler) {
1552
1716
  }
1553
1717
  return;
1554
1718
  }
1555
- const nodeArgs = _optionalChain([path5, 'optionalAccess', _43 => _43.node, 'optionalAccess', _44 => _44.arguments]);
1719
+ const nodeArgs = _optionalChain([path5, 'optionalAccess', _56 => _56.node, 'optionalAccess', _57 => _57.arguments]);
1556
1720
  if (Array.isArray(nodeArgs)) {
1557
1721
  for (const n of nodeArgs) {
1558
- if (_optionalChain([n, 'optionalAccess', _45 => _45.type]) === "StringLiteral") {
1722
+ if (_optionalChain([n, 'optionalAccess', _58 => _58.type]) === "StringLiteral") {
1559
1723
  const stub = {
1560
1724
  node: n,
1561
1725
  isStringLiteral: () => true
1562
1726
  };
1563
1727
  handleEvalStringLiteral(stub, options, updater, handler);
1564
- } else if (_optionalChain([n, 'optionalAccess', _46 => _46.type]) === "TemplateLiteral" && Array.isArray(n.quasis)) {
1728
+ } else if (_optionalChain([n, 'optionalAccess', _59 => _59.type]) === "TemplateLiteral" && Array.isArray(n.quasis)) {
1565
1729
  for (const q of n.quasis) {
1566
1730
  const stub = {
1567
1731
  node: q,
@@ -1663,7 +1827,7 @@ var IgnoredExportsTracker = class {
1663
1827
  continue;
1664
1828
  }
1665
1829
  if (exportPath.isExportNamedDeclaration()) {
1666
- const source = _optionalChain([exportPath, 'access', _47 => _47.node, 'access', _48 => _48.source, 'optionalAccess', _49 => _49.value]);
1830
+ const source = _optionalChain([exportPath, 'access', _60 => _60.node, 'access', _61 => _61.source, 'optionalAccess', _62 => _62.value]);
1667
1831
  if (typeof source === "string") {
1668
1832
  for (const spec of exportPath.get("specifiers")) {
1669
1833
  if (!spec.isExportSpecifier()) {
@@ -1730,7 +1894,7 @@ var IgnoredExportsTracker = class {
1730
1894
  continue;
1731
1895
  }
1732
1896
  if (exportPath.isExportAllDeclaration()) {
1733
- const source = _optionalChain([exportPath, 'access', _50 => _50.node, 'access', _51 => _51.source, 'optionalAccess', _52 => _52.value]);
1897
+ const source = _optionalChain([exportPath, 'access', _63 => _63.node, 'access', _64 => _64.source, 'optionalAccess', _65 => _65.value]);
1734
1898
  if (typeof source === "string") {
1735
1899
  for (const exportName of names) {
1736
1900
  propagate.push({
@@ -1831,7 +1995,7 @@ var JsModuleGraph = class {
1831
1995
  }
1832
1996
  for (const exportPath of state.analysis.exportDeclarations) {
1833
1997
  if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
1834
- const source = _optionalChain([exportPath, 'access', _53 => _53.node, 'access', _54 => _54.source, 'optionalAccess', _55 => _55.value]);
1998
+ const source = _optionalChain([exportPath, 'access', _66 => _66.node, 'access', _67 => _67.source, 'optionalAccess', _68 => _68.value]);
1835
1999
  if (typeof source === "string" && !dependencySpecifiers.has(source)) {
1836
2000
  dependencySpecifiers.set(source, []);
1837
2001
  }
@@ -2037,14 +2201,14 @@ var NodePathWalker = class {
2037
2201
  }
2038
2202
  this.visited.add(arg);
2039
2203
  if (arg.isIdentifier()) {
2040
- const binding = _optionalChain([arg, 'optionalAccess', _56 => _56.scope, 'optionalAccess', _57 => _57.getBinding, 'optionalCall', _58 => _58(arg.node.name)]);
2204
+ const binding = _optionalChain([arg, 'optionalAccess', _69 => _69.scope, 'optionalAccess', _70 => _70.getBinding, 'optionalCall', _71 => _71(arg.node.name)]);
2041
2205
  if (binding) {
2042
2206
  this.walkNode(binding.path);
2043
2207
  }
2044
2208
  } else if (arg.isMemberExpression()) {
2045
2209
  const objectPath = arg.get("object");
2046
2210
  if (objectPath.isIdentifier()) {
2047
- const binding = _optionalChain([arg, 'optionalAccess', _59 => _59.scope, 'optionalAccess', _60 => _60.getBinding, 'optionalCall', _61 => _61(objectPath.node.name)]);
2211
+ const binding = _optionalChain([arg, 'optionalAccess', _72 => _72.scope, 'optionalAccess', _73 => _73.getBinding, 'optionalCall', _74 => _74(objectPath.node.name)]);
2048
2212
  if (binding) {
2049
2213
  if (binding.path.isVariableDeclarator()) {
2050
2214
  this.walkVariableDeclarator(binding.path);
@@ -2121,8 +2285,8 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2121
2285
  }
2122
2286
  const objectPath = path5.get("object");
2123
2287
  if (objectPath.isIdentifier()) {
2124
- const scope = _optionalChain([objectPath, 'optionalAccess', _62 => _62.scope]);
2125
- const binding = _optionalChain([scope, 'optionalAccess', _63 => _63.getBinding, 'optionalCall', _64 => _64(objectPath.node.name)]);
2288
+ const scope = _optionalChain([objectPath, 'optionalAccess', _75 => _75.scope]);
2289
+ const binding = _optionalChain([scope, 'optionalAccess', _76 => _76.getBinding, 'optionalCall', _77 => _77(objectPath.node.name)]);
2126
2290
  if (binding) {
2127
2291
  return resolvesToWeappTwIgnore(binding, seen);
2128
2292
  }
@@ -2151,7 +2315,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2151
2315
  const init = bindingPath.get("init");
2152
2316
  if (init && init.node) {
2153
2317
  if (init.isIdentifier()) {
2154
- const target = _optionalChain([binding, 'optionalAccess', _65 => _65.scope, 'optionalAccess', _66 => _66.getBinding, 'optionalCall', _67 => _67(init.node.name)]);
2318
+ const target = _optionalChain([binding, 'optionalAccess', _78 => _78.scope, 'optionalAccess', _79 => _79.getBinding, 'optionalCall', _80 => _80(init.node.name)]);
2155
2319
  if (target) {
2156
2320
  result = resolvesToWeappTwIgnore(target, seen);
2157
2321
  }
@@ -2167,7 +2331,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2167
2331
  const getEffectiveTagPath = (tagPath) => {
2168
2332
  let current = tagPath;
2169
2333
  while (true) {
2170
- if (_optionalChain([current, 'access', _68 => _68.isParenthesizedExpression, 'optionalCall', _69 => _69()]) || current.node.type === "ParenthesizedExpression") {
2334
+ if (_optionalChain([current, 'access', _81 => _81.isParenthesizedExpression, 'optionalCall', _82 => _82()]) || current.node.type === "ParenthesizedExpression") {
2171
2335
  current = current.get("expression");
2172
2336
  continue;
2173
2337
  }
@@ -2179,7 +2343,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2179
2343
  current = current.get("expression");
2180
2344
  continue;
2181
2345
  }
2182
- if (_optionalChain([current, 'access', _70 => _70.isTypeCastExpression, 'optionalCall', _71 => _71()])) {
2346
+ if (_optionalChain([current, 'access', _83 => _83.isTypeCastExpression, 'optionalCall', _84 => _84()])) {
2183
2347
  current = current.get("expression");
2184
2348
  continue;
2185
2349
  }
@@ -2191,7 +2355,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2191
2355
  continue;
2192
2356
  }
2193
2357
  }
2194
- if (_optionalChain([current, 'access', _72 => _72.isCallExpression, 'optionalCall', _73 => _73()]) || current.node.type === "CallExpression") {
2358
+ if (_optionalChain([current, 'access', _85 => _85.isCallExpression, 'optionalCall', _86 => _86()]) || current.node.type === "CallExpression") {
2195
2359
  const callee = current.get("callee");
2196
2360
  current = callee;
2197
2361
  continue;
@@ -2201,7 +2365,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2201
2365
  return current;
2202
2366
  };
2203
2367
  const evaluateTagPath = (tagPath) => {
2204
- if (_optionalChain([tagPath, 'access', _74 => _74.isCallExpression, 'optionalCall', _75 => _75()]) || tagPath.node.type === "CallExpression") {
2368
+ if (_optionalChain([tagPath, 'access', _87 => _87.isCallExpression, 'optionalCall', _88 => _88()]) || tagPath.node.type === "CallExpression") {
2205
2369
  const calleePath = tagPath.get("callee");
2206
2370
  return evaluateTagPath(calleePath);
2207
2371
  }
@@ -2209,7 +2373,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
2209
2373
  if (matcher(tagPath.node.name)) {
2210
2374
  return true;
2211
2375
  }
2212
- const binding = _optionalChain([tagPath, 'optionalAccess', _76 => _76.scope, 'optionalAccess', _77 => _77.getBinding, 'optionalCall', _78 => _78(tagPath.node.name)]);
2376
+ const binding = _optionalChain([tagPath, 'optionalAccess', _89 => _89.scope, 'optionalAccess', _90 => _90.getBinding, 'optionalCall', _91 => _91(tagPath.node.name)]);
2213
2377
  if (binding) {
2214
2378
  return resolvesToWeappTwIgnore(binding, /* @__PURE__ */ new Set());
2215
2379
  }
@@ -2305,11 +2469,11 @@ function analyzeSource(ast, options, handler) {
2305
2469
  return;
2306
2470
  }
2307
2471
  const calleePath = p.get("callee");
2308
- if (calleePath.isIdentifier({ name: "require" }) && !_optionalChain([p, 'optionalAccess', _79 => _79.scope, 'optionalAccess', _80 => _80.hasBinding, 'optionalCall', _81 => _81("require")])) {
2472
+ if (calleePath.isIdentifier({ name: "require" }) && !_optionalChain([p, 'optionalAccess', _92 => _92.scope, 'optionalAccess', _93 => _93.hasBinding, 'optionalCall', _94 => _94("require")])) {
2309
2473
  const args = p.get("arguments");
2310
2474
  if (Array.isArray(args) && args.length > 0) {
2311
2475
  const first = args[0];
2312
- if (_optionalChain([first, 'optionalAccess', _82 => _82.isStringLiteral, 'call', _83 => _83()])) {
2476
+ if (_optionalChain([first, 'optionalAccess', _95 => _95.isStringLiteral, 'call', _96 => _96()])) {
2313
2477
  requireCallPaths.push(first);
2314
2478
  }
2315
2479
  }
@@ -2394,6 +2558,8 @@ function createJsHandler(options) {
2394
2558
  arbitraryValues,
2395
2559
  escapeMap,
2396
2560
  staleClassNameFallback,
2561
+ jsArbitraryValueFallback,
2562
+ tailwindcssMajorVersion,
2397
2563
  jsPreserveClass,
2398
2564
  generateMap,
2399
2565
  needEscaped,
@@ -2416,6 +2582,8 @@ function createJsHandler(options) {
2416
2582
  classNameSet,
2417
2583
  escapeMap,
2418
2584
  staleClassNameFallback,
2585
+ jsArbitraryValueFallback,
2586
+ tailwindcssMajorVersion,
2419
2587
  arbitraryValues,
2420
2588
  jsPreserveClass,
2421
2589
  generateMap,
@@ -2513,7 +2681,7 @@ function shouldSkipLegacyStringLiteral(path5) {
2513
2681
  return true;
2514
2682
  }
2515
2683
  return Boolean(
2516
- t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access', _84 => _84.parentPath, 'optionalAccess', _85 => _85.parent])) || t.isLogicalExpression(_optionalChain([path5, 'access', _86 => _86.parentPath, 'optionalAccess', _87 => _87.parent])))
2684
+ t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access', _97 => _97.parentPath, 'optionalAccess', _98 => _98.parent])) || t.isLogicalExpression(_optionalChain([path5, 'access', _99 => _99.parentPath, 'optionalAccess', _100 => _100.parent])))
2517
2685
  );
2518
2686
  }
2519
2687
  function createLegacyTraverseOptions(options, jsTokenUpdater) {
@@ -2814,7 +2982,7 @@ async function customTemplateHandler(rawSource, options) {
2814
2982
  }
2815
2983
  const lowerName = name.toLowerCase();
2816
2984
  const shouldHandleDefault = !disabledDefaultTemplateHandler && (lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass");
2817
- const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _88 => _88(tag, name)]), () => ( false));
2985
+ const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _101 => _101(tag, name)]), () => ( false));
2818
2986
  if (!shouldHandleDefault && !shouldHandleCustom) {
2819
2987
  return;
2820
2988
  }
@@ -2879,7 +3047,7 @@ function resolveRuntimePackageReplacements(option) {
2879
3047
  }
2880
3048
  return Object.keys(normalized).length > 0 ? normalized : void 0;
2881
3049
  }
2882
- function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions) {
3050
+ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
2883
3051
  const {
2884
3052
  cssPreflight,
2885
3053
  cssPreflightRange,
@@ -2898,6 +3066,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2898
3066
  arbitraryValues,
2899
3067
  jsPreserveClass,
2900
3068
  staleClassNameFallback,
3069
+ jsArbitraryValueFallback,
2901
3070
  babelParserOptions,
2902
3071
  ignoreCallExpressionIdentifiers,
2903
3072
  ignoreTaggedTemplateExpressionIdentifiers,
@@ -2928,6 +3097,8 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2928
3097
  arbitraryValues,
2929
3098
  jsPreserveClass,
2930
3099
  staleClassNameFallback,
3100
+ jsArbitraryValueFallback: _nullishCoalesce(jsArbitraryValueFallback, () => ( "auto")),
3101
+ tailwindcssMajorVersion,
2931
3102
  generateMap: true,
2932
3103
  babelParserOptions,
2933
3104
  ignoreCallExpressionIdentifiers,
@@ -2966,7 +3137,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2966
3137
  if (!patcher) {
2967
3138
  return;
2968
3139
  }
2969
- const cacheOptions = _optionalChain([patcher, 'access', _89 => _89.options, 'optionalAccess', _90 => _90.cache]);
3140
+ const cacheOptions = _optionalChain([patcher, 'access', _102 => _102.options, 'optionalAccess', _103 => _103.cache]);
2970
3141
  if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
2971
3142
  return;
2972
3143
  }
@@ -2977,19 +3148,19 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2977
3148
  _logger.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
2978
3149
  }
2979
3150
  }
2980
- if (!_optionalChain([options, 'optionalAccess', _91 => _91.removeDirectory])) {
3151
+ if (!_optionalChain([options, 'optionalAccess', _104 => _104.removeDirectory])) {
2981
3152
  return;
2982
3153
  }
2983
3154
  const cachePaths = /* @__PURE__ */ new Map();
2984
3155
  const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
2985
- if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _92 => _92.path])) {
3156
+ if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _105 => _105.path])) {
2986
3157
  cachePaths.set(normalizedCacheOptions.path, false);
2987
3158
  }
2988
- const privateCachePath = _optionalChain([patcher, 'optionalAccess', _93 => _93.cacheStore, 'optionalAccess', _94 => _94.options, 'optionalAccess', _95 => _95.path]);
3159
+ const privateCachePath = _optionalChain([patcher, 'optionalAccess', _106 => _106.cacheStore, 'optionalAccess', _107 => _107.options, 'optionalAccess', _108 => _108.path]);
2989
3160
  if (privateCachePath) {
2990
3161
  cachePaths.set(privateCachePath, false);
2991
3162
  }
2992
- if (_optionalChain([options, 'optionalAccess', _96 => _96.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _97 => _97.dir])) {
3163
+ if (_optionalChain([options, 'optionalAccess', _109 => _109.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _110 => _110.dir])) {
2993
3164
  cachePaths.set(normalizedCacheOptions.dir, true);
2994
3165
  }
2995
3166
  if (!cachePaths.size) {
@@ -3000,7 +3171,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
3000
3171
  await _promises.rm.call(void 0, cachePath, { force: true, recursive });
3001
3172
  } catch (error) {
3002
3173
  const err = error;
3003
- if (_optionalChain([err, 'optionalAccess', _98 => _98.code]) === "ENOENT") {
3174
+ if (_optionalChain([err, 'optionalAccess', _111 => _111.code]) === "ENOENT") {
3004
3175
  continue;
3005
3176
  }
3006
3177
  _logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
@@ -3017,7 +3188,7 @@ function createInternalCompilerContext(opts) {
3017
3188
  applyLoggerLevel(ctx.logLevel);
3018
3189
  const twPatcher = _chunk5APD2MNVjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
3019
3190
  logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
3020
- if (_optionalChain([twPatcher, 'access', _99 => _99.packageInfo, 'optionalAccess', _100 => _100.version])) {
3191
+ if (_optionalChain([twPatcher, 'access', _112 => _112.packageInfo, 'optionalAccess', _113 => _113.version])) {
3021
3192
  _logger.logger.success(`\u5F53\u524D\u4F7F\u7528 ${_logger.pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${_logger.pc.underline(_logger.pc.bold(_logger.pc.green(twPatcher.packageInfo.version)))}`);
3022
3193
  } else {
3023
3194
  _logger.logger.warn(`${_logger.pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
@@ -3029,7 +3200,8 @@ function createInternalCompilerContext(opts) {
3029
3200
  const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
3030
3201
  ctx,
3031
3202
  customAttributesEntities,
3032
- cssCalcOptions
3203
+ cssCalcOptions,
3204
+ twPatcher.majorVersion
3033
3205
  );
3034
3206
  ctx.styleHandler = styleHandler;
3035
3207
  ctx.jsHandler = jsHandler2;
@@ -3038,7 +3210,7 @@ function createInternalCompilerContext(opts) {
3038
3210
  ctx.twPatcher = twPatcher;
3039
3211
  const refreshTailwindcssPatcher = async (options) => {
3040
3212
  const previousPatcher = ctx.twPatcher;
3041
- if (_optionalChain([options, 'optionalAccess', _101 => _101.clearCache]) !== false) {
3213
+ if (_optionalChain([options, 'optionalAccess', _114 => _114.clearCache]) !== false) {
3042
3214
  await clearTailwindcssPatcherCache(previousPatcher);
3043
3215
  }
3044
3216
  invalidateRuntimeClassSet(previousPatcher);
@@ -10,7 +10,7 @@ import {
10
10
  isMpx,
11
11
  patchMpxLoaderResolve,
12
12
  setupMpxTailwindcssRedirect
13
- } from "./chunk-GKT5AE7D.mjs";
13
+ } from "./chunk-ACNOEKQI.mjs";
14
14
  import {
15
15
  pushConcurrentTaskFactories,
16
16
  resolveDisabledOptions,
@@ -23,14 +23,14 @@ import {
23
23
  } from "./chunk-RRHPTTCP.mjs";
24
24
  import {
25
25
  setupPatchRecorder
26
- } from "./chunk-4QCL7FBX.mjs";
26
+ } from "./chunk-BZCCVPSU.mjs";
27
27
  import {
28
28
  createDebug,
29
29
  ensureRuntimeClassSet,
30
30
  getCompilerContext,
31
31
  getRuntimeClassSetSignature,
32
32
  pluginName
33
- } from "./chunk-RXM5ERRJ.mjs";
33
+ } from "./chunk-MPVAZKRB.mjs";
34
34
  import {
35
35
  getGroupedEntries
36
36
  } from "./chunk-OOHJLO5M.mjs";
@@ -205,6 +205,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
205
205
  const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
206
206
  const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, {
207
207
  staleClassNameFallback,
208
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
208
209
  filename: absoluteFile,
209
210
  moduleGraph: moduleGraphOptions,
210
211
  babelParserOptions: {
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
2
2
 
3
3
 
4
- var _chunk7K3R5LV6js = require('./chunk-7K3R5LV6.js');
4
+ var _chunkI35XJD75js = require('./chunk-I35XJD75.js');
5
5
 
6
6
 
7
7
  var _chunk5APD2MNVjs = require('./chunk-5APD2MNV.js');
8
8
 
9
9
  // src/tailwindcss/recorder.ts
10
10
  function setupPatchRecorder(patcher, baseDir, options) {
11
- const recorder = _chunk7K3R5LV6js.createPatchTargetRecorder.call(void 0, baseDir, patcher, options);
11
+ const recorder = _chunkI35XJD75js.createPatchTargetRecorder.call(void 0, baseDir, patcher, options);
12
12
  if (_optionalChain([recorder, 'optionalAccess', _ => _.message]) && _optionalChain([options, 'optionalAccess', _2 => _2.logMessage]) !== false) {
13
13
  const prefix = _optionalChain([options, 'optionalAccess', _3 => _3.messagePrefix]) ? `${options.messagePrefix} ` : "";
14
14
  _chunk5APD2MNVjs.logger.info("%s%s", prefix, recorder.message);
@@ -16,7 +16,7 @@ function setupPatchRecorder(patcher, baseDir, options) {
16
16
  const onPatchCompleted = _optionalChain([recorder, 'optionalAccess', _4 => _4.onPatched]) ? async () => {
17
17
  await recorder.onPatched();
18
18
  } : void 0;
19
- const patchPromise = patcher ? _chunk7K3R5LV6js.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
19
+ const patchPromise = patcher ? _chunkI35XJD75js.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
20
20
  return {
21
21
  recorder,
22
22
  patchPromise,