weapp-tailwindcss 4.10.0 → 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-VZX2RV6M.js → chunk-3R7FDZJL.js} +31 -38
  2. package/dist/{chunk-JA6PNN27.js → chunk-6VKE7EWV.js} +28 -27
  3. package/dist/{chunk-6QU7CMAG.mjs → chunk-ACNOEKQI.mjs} +1 -1
  4. package/dist/{chunk-F6VHIO5B.mjs → chunk-BZCCVPSU.mjs} +1 -1
  5. package/dist/{chunk-PDP4OIKN.js → chunk-HJVZ4TO3.js} +3 -3
  6. package/dist/{chunk-VTIOEDOK.js → chunk-I35XJD75.js} +223 -97
  7. package/dist/{chunk-TNAPEHNW.mjs → chunk-LHBUALTK.mjs} +4 -3
  8. package/dist/{chunk-HFXMZGPW.js → chunk-M2ATX5ZS.js} +3 -3
  9. package/dist/{chunk-Q5IGGG5W.mjs → chunk-MPVAZKRB.mjs} +189 -63
  10. package/dist/{chunk-ZP6TLVZX.mjs → chunk-N6JOG5K3.mjs} +3 -2
  11. package/dist/{chunk-DA2K4ZIE.js → chunk-NPZ5QQC7.js} +8 -7
  12. package/dist/{chunk-D67CTJV5.mjs → chunk-WJU62RPV.mjs} +13 -20
  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 -17
  18. package/dist/core.mjs +17 -12
  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-B6U7MoOM.d.ts → index-t_VBjwYm.d.mts} +13 -6
  26. package/dist/{index-B6U7MoOM.d.mts → index-t_VBjwYm.d.ts} +13 -6
  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 +17 -4
  34. package/dist/types.d.ts +17 -4
  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
@@ -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 _chunkVTIOEDOKjs = require('./chunk-VTIOEDOK.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 = _chunkVTIOEDOKjs.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 ? _chunkVTIOEDOKjs.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,
@@ -16,10 +16,10 @@ import {
16
16
  import _createDebug from "debug";
17
17
  var _debug = _createDebug("weapp-tw");
18
18
  function createDebug(prefix) {
19
- function debug2(formatter, ...args) {
19
+ function debug3(formatter, ...args) {
20
20
  return _debug((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.0",
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,68 +1189,80 @@ import { jsStringEscape } from "@ast-core/escape";
1189
1189
  import { escapeStringRegexp as escapeStringRegexp2 } from "@weapp-core/regex";
1190
1190
  import { splitCode } from "@weapp-tailwindcss/shared/extractors";
1191
1191
 
1192
- // src/shared/classname-transform.ts
1193
- var arbitraryClassTokenRE = /\[[^\]\r\n]+\]/;
1194
- var utilityLikeClassRE = /^-?[@\w][\w:/.[\]()%#!,-]*$/;
1195
- var escapableTokenRE = /[.[\]/:]/;
1196
- function isArbitraryValueClassName(candidate) {
1197
- if (!arbitraryClassTokenRE.test(candidate)) {
1198
- return false;
1192
+ // src/wxml/shared.ts
1193
+ import { escape, MappingChars2String } from "@weapp-core/escape";
1194
+ function replaceWxml(original, options = {
1195
+ keepEOL: false,
1196
+ escapeMap: MappingChars2String
1197
+ }) {
1198
+ const { keepEOL, escapeMap, ignoreHead } = options;
1199
+ let res = original;
1200
+ if (!keepEOL) {
1201
+ res = res.replaceAll(/[\n\r]+/g, "");
1199
1202
  }
1200
- return candidate.startsWith("[") || candidate.includes("-[") || candidate.includes(":[");
1203
+ res = escape(res, {
1204
+ map: escapeMap,
1205
+ ignoreHead
1206
+ });
1207
+ return res;
1201
1208
  }
1202
- function shouldFallbackEscapeClassName(candidate) {
1203
- if (!candidate) {
1204
- return false;
1205
- }
1206
- if (candidate.startsWith("@")) {
1207
- return false;
1208
- }
1209
- if (candidate.includes("://")) {
1210
- return false;
1211
- }
1212
- if (candidate.includes("/")) {
1209
+
1210
+ // src/shared/classname-transform.ts
1211
+ function isArbitraryValueCandidate(candidate) {
1212
+ const normalized = candidate.trim();
1213
+ if (!normalized.includes("[") || !normalized.includes("]")) {
1213
1214
  return false;
1214
1215
  }
1215
- if (!utilityLikeClassRE.test(candidate)) {
1216
+ if (/^(?:https?:)?\/\//.test(normalized)) {
1216
1217
  return false;
1217
1218
  }
1218
- if (isArbitraryValueClassName(candidate)) {
1219
+ return true;
1220
+ }
1221
+ function shouldEnableArbitraryValueFallback({
1222
+ classNameSet,
1223
+ jsArbitraryValueFallback,
1224
+ tailwindcssMajorVersion
1225
+ }) {
1226
+ if (jsArbitraryValueFallback === true) {
1219
1227
  return true;
1220
1228
  }
1221
- if (!escapableTokenRE.test(candidate)) {
1229
+ if (jsArbitraryValueFallback === false) {
1222
1230
  return false;
1223
1231
  }
1224
- if (!candidate.includes(".")) {
1225
- return false;
1226
- }
1227
- return candidate.includes("-") || candidate.includes(":");
1232
+ return tailwindcssMajorVersion === 4 && (!classNameSet || classNameSet.size === 0);
1228
1233
  }
1229
- function shouldTransformClassNameCandidate(candidate, {
1234
+ function resolveClassNameTransformDecision(candidate, {
1230
1235
  alwaysEscape,
1231
1236
  classNameSet,
1232
- staleClassNameFallback,
1233
- jsPreserveClass
1237
+ escapeMap,
1238
+ jsArbitraryValueFallback,
1239
+ jsPreserveClass,
1240
+ tailwindcssMajorVersion,
1241
+ classContext
1234
1242
  }) {
1235
1243
  if (alwaysEscape) {
1236
- return true;
1244
+ return "direct";
1237
1245
  }
1238
1246
  if (jsPreserveClass?.(candidate)) {
1239
- return false;
1247
+ return "skip";
1240
1248
  }
1241
- if (!classNameSet || classNameSet.size === 0) {
1242
- if (!staleClassNameFallback) {
1243
- return false;
1244
- }
1245
- return shouldFallbackEscapeClassName(candidate);
1249
+ if (classNameSet?.has(candidate)) {
1250
+ return "direct";
1246
1251
  }
1247
- if (classNameSet.has(candidate)) {
1248
- return true;
1252
+ if (classNameSet && classNameSet.size > 0) {
1253
+ const escapedCandidate = replaceWxml(candidate, { escapeMap });
1254
+ if (escapedCandidate !== candidate && classNameSet.has(escapedCandidate)) {
1255
+ return "escaped";
1256
+ }
1249
1257
  }
1250
- if (!staleClassNameFallback) {
1251
- return false;
1258
+ if (classContext && isArbitraryValueCandidate(candidate) && shouldEnableArbitraryValueFallback({
1259
+ classNameSet,
1260
+ jsArbitraryValueFallback,
1261
+ tailwindcssMajorVersion
1262
+ })) {
1263
+ return "fallback";
1252
1264
  }
1253
- return shouldFallbackEscapeClassName(candidate);
1265
+ return "skip";
1254
1266
  }
1255
1267
 
1256
1268
  // src/utils/decode.ts
@@ -1276,25 +1288,105 @@ function decodeUnicode2(input) {
1276
1288
  }
1277
1289
  }
1278
1290
 
1279
- // src/wxml/shared.ts
1280
- import { escape, MappingChars2String } from "@weapp-core/escape";
1281
- function replaceWxml(original, options = {
1282
- keepEOL: false,
1283
- escapeMap: MappingChars2String
1284
- }) {
1285
- const { keepEOL, escapeMap, ignoreHead } = options;
1286
- let res = original;
1287
- if (!keepEOL) {
1288
- 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;
1289
1315
  }
1290
- res = escape(res, {
1291
- map: escapeMap,
1292
- ignoreHead
1293
- });
1294
- return res;
1316
+ if (path5.isStringLiteral()) {
1317
+ return path5.node.value;
1318
+ }
1319
+ if (path5.isTemplateLiteral() && path5.node.expressions.length === 0) {
1320
+ return path5.node.quasis[0]?.value.cooked ?? path5.node.quasis[0]?.value.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;
1295
1386
  }
1296
1387
 
1297
1388
  // src/js/handlers.ts
1389
+ var debug2 = createDebug("[js:handlers] ");
1298
1390
  var patternCache = /* @__PURE__ */ new Map();
1299
1391
  var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
1300
1392
  var defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -1359,7 +1451,9 @@ function replaceHandleValue(path5, options) {
1359
1451
  needEscaped = false
1360
1452
  } = options;
1361
1453
  const { classNameSet, alwaysEscape } = options;
1362
- if (!alwaysEscape && (!classNameSet || classNameSet.size === 0) && !options.staleClassNameFallback) {
1454
+ const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
1455
+ const classContext = options.wrapExpression || isClassContextLiteralPath(path5);
1456
+ if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) {
1363
1457
  return void 0;
1364
1458
  }
1365
1459
  const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path5, options);
@@ -1372,10 +1466,24 @@ function replaceHandleValue(path5, options) {
1372
1466
  }
1373
1467
  let transformed = literal;
1374
1468
  let mutated = false;
1469
+ let matchedCandidateCount = 0;
1470
+ let escapedDecisionCount = 0;
1471
+ let fallbackDecisionCount = 0;
1375
1472
  for (const candidate of candidates) {
1376
- if (!shouldTransformClassNameCandidate(candidate, options)) {
1473
+ const decision = resolveClassNameTransformDecision(candidate, {
1474
+ ...options,
1475
+ classContext
1476
+ });
1477
+ if (decision === "skip") {
1377
1478
  continue;
1378
1479
  }
1480
+ matchedCandidateCount += 1;
1481
+ if (decision === "escaped") {
1482
+ escapedDecisionCount += 1;
1483
+ }
1484
+ if (decision === "fallback") {
1485
+ fallbackDecisionCount += 1;
1486
+ }
1379
1487
  if (!transformed.includes(candidate)) {
1380
1488
  continue;
1381
1489
  }
@@ -1391,6 +1499,16 @@ function replaceHandleValue(path5, options) {
1391
1499
  if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") {
1392
1500
  return void 0;
1393
1501
  }
1502
+ if (debug2.enabled) {
1503
+ debug2(
1504
+ "runtimeSet size=%d fallbackTriggered=%s matchedCandidates=%d escapedHits=%d file=%s",
1505
+ classNameSet?.size ?? 0,
1506
+ fallbackDecisionCount > 0,
1507
+ matchedCandidateCount,
1508
+ escapedDecisionCount,
1509
+ options.filename ?? "unknown"
1510
+ );
1511
+ }
1394
1512
  const start = node.start + offset;
1395
1513
  const end = node.end - offset;
1396
1514
  if (start >= end || transformed === original) {
@@ -2440,6 +2558,8 @@ function createJsHandler(options) {
2440
2558
  arbitraryValues,
2441
2559
  escapeMap,
2442
2560
  staleClassNameFallback,
2561
+ jsArbitraryValueFallback,
2562
+ tailwindcssMajorVersion,
2443
2563
  jsPreserveClass,
2444
2564
  generateMap,
2445
2565
  needEscaped,
@@ -2462,6 +2582,8 @@ function createJsHandler(options) {
2462
2582
  classNameSet,
2463
2583
  escapeMap,
2464
2584
  staleClassNameFallback,
2585
+ jsArbitraryValueFallback,
2586
+ tailwindcssMajorVersion,
2465
2587
  arbitraryValues,
2466
2588
  jsPreserveClass,
2467
2589
  generateMap,
@@ -2925,7 +3047,7 @@ function resolveRuntimePackageReplacements(option) {
2925
3047
  }
2926
3048
  return Object.keys(normalized).length > 0 ? normalized : void 0;
2927
3049
  }
2928
- function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions) {
3050
+ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
2929
3051
  const {
2930
3052
  cssPreflight,
2931
3053
  cssPreflightRange,
@@ -2944,6 +3066,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2944
3066
  arbitraryValues,
2945
3067
  jsPreserveClass,
2946
3068
  staleClassNameFallback,
3069
+ jsArbitraryValueFallback,
2947
3070
  babelParserOptions,
2948
3071
  ignoreCallExpressionIdentifiers,
2949
3072
  ignoreTaggedTemplateExpressionIdentifiers,
@@ -2974,6 +3097,8 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2974
3097
  arbitraryValues,
2975
3098
  jsPreserveClass,
2976
3099
  staleClassNameFallback,
3100
+ jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
3101
+ tailwindcssMajorVersion,
2977
3102
  generateMap: true,
2978
3103
  babelParserOptions,
2979
3104
  ignoreCallExpressionIdentifiers,
@@ -3075,7 +3200,8 @@ function createInternalCompilerContext(opts) {
3075
3200
  const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
3076
3201
  ctx,
3077
3202
  customAttributesEntities,
3078
- cssCalcOptions
3203
+ cssCalcOptions,
3204
+ twPatcher.majorVersion
3079
3205
  );
3080
3206
  ctx.styleHandler = styleHandler;
3081
3207
  ctx.jsHandler = jsHandler2;
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-RRHPTTCP.mjs";
4
4
  import {
5
5
  setupPatchRecorder
6
- } from "./chunk-F6VHIO5B.mjs";
6
+ } from "./chunk-BZCCVPSU.mjs";
7
7
  import {
8
8
  createDebug,
9
9
  ensureRuntimeClassSet,
10
10
  getCompilerContext,
11
11
  refreshTailwindRuntimeState
12
- } from "./chunk-Q5IGGG5W.mjs";
12
+ } from "./chunk-MPVAZKRB.mjs";
13
13
 
14
14
  // src/bundlers/gulp/index.ts
15
15
  import { Buffer } from "buffer";
@@ -164,6 +164,7 @@ function createPlugins(options = {}) {
164
164
  ...options2,
165
165
  filename,
166
166
  moduleGraph,
167
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
167
168
  babelParserOptions: {
168
169
  ...options2?.babelParserOptions ?? {},
169
170
  sourceFilename: filename
@@ -3,13 +3,13 @@
3
3
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
4
4
 
5
5
 
6
- var _chunkHFXMZGPWjs = require('./chunk-HFXMZGPW.js');
6
+ var _chunkM2ATX5ZSjs = require('./chunk-M2ATX5ZS.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- var _chunkVTIOEDOKjs = require('./chunk-VTIOEDOK.js');
12
+ var _chunkI35XJD75js = require('./chunk-I35XJD75.js');
13
13
 
14
14
  // src/bundlers/gulp/index.ts
15
15
  var _buffer = require('buffer');
@@ -17,12 +17,12 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
17
17
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
18
18
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
19
19
  var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
20
- var debug = _chunkVTIOEDOKjs.createDebug.call(void 0, );
20
+ var debug = _chunkI35XJD75js.createDebug.call(void 0, );
21
21
  var Transform = _stream2.default.Transform;
22
22
  function createPlugins(options = {}) {
23
- const opts = _chunkVTIOEDOKjs.getCompilerContext.call(void 0, options);
23
+ const opts = _chunkI35XJD75js.getCompilerContext.call(void 0, options);
24
24
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
25
- const patchRecorderState = _chunkHFXMZGPWjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
25
+ const patchRecorderState = _chunkM2ATX5ZSjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
26
26
  source: "runtime",
27
27
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
28
28
  });
@@ -36,13 +36,13 @@ function createPlugins(options = {}) {
36
36
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
37
37
  let runtimeSetInitialized = false;
38
38
  async function refreshRuntimeState(force) {
39
- await _chunkVTIOEDOKjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
39
+ await _chunkI35XJD75js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
40
40
  }
41
41
  async function refreshRuntimeSet(force = false) {
42
42
  if (!force && runtimeSetInitialized) {
43
43
  return runtimeSet;
44
44
  }
45
- runtimeSet = await _chunkVTIOEDOKjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
45
+ runtimeSet = await _chunkI35XJD75js.ensureRuntimeClassSet.call(void 0, runtimeState, {
46
46
  forceRefresh: force,
47
47
  forceCollect: force,
48
48
  clearCache: force,
@@ -164,6 +164,7 @@ function createPlugins(options = {}) {
164
164
  ...options2,
165
165
  filename,
166
166
  moduleGraph,
167
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
167
168
  babelParserOptions: {
168
169
  ..._nullishCoalesce(_optionalChain([options2, 'optionalAccess', _ => _.babelParserOptions]), () => ( {})),
169
170
  sourceFilename: filename
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-RRHPTTCP.mjs";
13
13
  import {
14
14
  setupPatchRecorder
15
- } from "./chunk-F6VHIO5B.mjs";
15
+ } from "./chunk-BZCCVPSU.mjs";
16
16
  import {
17
17
  collectRuntimeClassSet,
18
18
  createAttributeMatcher,
@@ -24,12 +24,13 @@ import {
24
24
  replaceWxml,
25
25
  toCustomAttributesEntities,
26
26
  vitePluginName
27
- } from "./chunk-Q5IGGG5W.mjs";
27
+ } from "./chunk-MPVAZKRB.mjs";
28
28
  import {
29
29
  resolveUniUtsPlatform
30
30
  } from "./chunk-OOHJLO5M.mjs";
31
31
 
32
32
  // src/bundlers/vite/index.ts
33
+ import path3 from "path";
33
34
  import process3 from "process";
34
35
  import postcssHtmlTransform from "@weapp-tailwindcss/postcss/html-transform";
35
36
 
@@ -666,21 +667,6 @@ function createJsHashSalt(runtimeSignature, linkedImpactSignature) {
666
667
  function hasRuntimeAffectingSourceChanges(changedByType) {
667
668
  return changedByType.html.size > 0 || changedByType.js.size > 0;
668
669
  }
669
- function resolveViteStaleClassNameFallback(option, resolvedConfig) {
670
- if (typeof option === "boolean") {
671
- return option;
672
- }
673
- if (!resolvedConfig) {
674
- return false;
675
- }
676
- if (resolvedConfig.command === "serve") {
677
- return true;
678
- }
679
- if (resolvedConfig.command === "build" && resolvedConfig.build?.watch) {
680
- return true;
681
- }
682
- return false;
683
- }
684
670
  function createGenerateBundleHook(context) {
685
671
  const state = {
686
672
  iteration: 0,
@@ -728,7 +714,6 @@ function createGenerateBundleHook(context) {
728
714
  const processSets = buildProcessSets(entries, opts, dirtyEntries.changedByType, state.previousLinkedByEntry, disableDirtyOptimization);
729
715
  const processFiles = processSets.files;
730
716
  const resolvedConfig = getResolvedConfig();
731
- const staleClassNameFallback = resolveViteStaleClassNameFallback(opts.staleClassNameFallback, resolvedConfig);
732
717
  const rootDir = resolvedConfig?.root ? path2.resolve(resolvedConfig.root) : process2.cwd();
733
718
  const outDir = resolvedConfig?.build?.outDir ? path2.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
734
719
  const jsEntries = /* @__PURE__ */ new Map();
@@ -771,8 +756,8 @@ function createGenerateBundleHook(context) {
771
756
  };
772
757
  const createHandlerOptions = (absoluteFilename, extra) => ({
773
758
  ...extra,
774
- staleClassNameFallback: extra?.staleClassNameFallback ?? staleClassNameFallback,
775
759
  filename: absoluteFilename,
760
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
776
761
  moduleGraph: moduleGraphOptions,
777
762
  babelParserOptions: {
778
763
  ...extra?.babelParserOptions ?? {},
@@ -1099,6 +1084,7 @@ var weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
1099
1084
  var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
1100
1085
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1101
1086
  const rewriteCssImportsSpecified = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
1087
+ const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
1102
1088
  const opts = getCompilerContext(options);
1103
1089
  const {
1104
1090
  disabled,
@@ -1222,8 +1208,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1222
1208
  {
1223
1209
  name: `${vitePluginName}:post`,
1224
1210
  enforce: "post",
1225
- configResolved(config) {
1211
+ async configResolved(config) {
1226
1212
  resolvedConfig = config;
1213
+ const resolvedRoot = config.root ? path3.resolve(config.root) : void 0;
1214
+ if (!hasExplicitTailwindcssBasedir && resolvedRoot && opts.tailwindcssBasedir !== resolvedRoot) {
1215
+ const previousBasedir = opts.tailwindcssBasedir;
1216
+ opts.tailwindcssBasedir = resolvedRoot;
1217
+ debug("align tailwindcss basedir with vite root: %s -> %s", previousBasedir ?? "undefined", resolvedRoot);
1218
+ await refreshRuntimeState(true);
1219
+ }
1227
1220
  if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
1228
1221
  const idx = config.css.postcss.plugins.findIndex((x) => (
1229
1222
  // @ts-ignore
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkVTIOEDOKjs = require('./chunk-VTIOEDOK.js');
6
+ var _chunkI35XJD75js = require('./chunk-I35XJD75.js');
7
7
 
8
8
 
9
9
 
@@ -404,9 +404,9 @@ async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
404
404
  try {
405
405
  const patcher = createWorkspacePatcher(dir);
406
406
  if (options.clearCache) {
407
- await _chunkVTIOEDOKjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
407
+ await _chunkI35XJD75js.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
408
408
  }
409
- const recorder = _chunkVTIOEDOKjs.createPatchTargetRecorder.call(void 0, dir, patcher, {
409
+ const recorder = _chunkI35XJD75js.createPatchTargetRecorder.call(void 0, dir, patcher, {
410
410
  source: "cli",
411
411
  cwd: dir,
412
412
  recordTarget: options.recordTarget !== false,
@@ -415,7 +415,7 @@ async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
415
415
  if (_optionalChain([recorder, 'optionalAccess', _12 => _12.message])) {
416
416
  _chunk5APD2MNVjs.logger.info("[workspace] %s %s", displayName, recorder.message);
417
417
  }
418
- _chunkVTIOEDOKjs.logTailwindcssTarget.call(void 0, "cli", patcher, dir);
418
+ _chunkI35XJD75js.logTailwindcssTarget.call(void 0, "cli", patcher, dir);
419
419
  await patcher.patch();
420
420
  if (_optionalChain([recorder, 'optionalAccess', _13 => _13.onPatched])) {
421
421
  await recorder.onPatched();
@@ -546,9 +546,9 @@ var mountOptions = {
546
546
  }
547
547
  const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
548
548
  if (shouldClearCache) {
549
- await _chunkVTIOEDOKjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
549
+ await _chunkI35XJD75js.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
550
550
  }
551
- const recorder = _chunkVTIOEDOKjs.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, {
551
+ const recorder = _chunkI35XJD75js.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, {
552
552
  source: "cli",
553
553
  cwd: ctx.cwd,
554
554
  recordTarget: shouldRecordTarget,
@@ -557,7 +557,7 @@ var mountOptions = {
557
557
  if (_optionalChain([recorder, 'optionalAccess', _15 => _15.message])) {
558
558
  _chunk5APD2MNVjs.logger.info(recorder.message);
559
559
  }
560
- _chunkVTIOEDOKjs.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd);
560
+ _chunkI35XJD75js.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd);
561
561
  await patcher.patch();
562
562
  if (_optionalChain([recorder, 'optionalAccess', _16 => _16.onPatched])) {
563
563
  const recordPath = await recorder.onPatched();
@@ -705,9 +705,9 @@ async function generateVscodeIntellisenseEntry(options) {
705
705
 
706
706
  // src/cli.ts
707
707
  _process2.default.title = "node (weapp-tailwindcss)";
708
- if (_semver2.default.lt(_process2.default.versions.node, _chunkVTIOEDOKjs.WEAPP_TW_REQUIRED_NODE_VERSION)) {
708
+ if (_semver2.default.lt(_process2.default.versions.node, _chunkI35XJD75js.WEAPP_TW_REQUIRED_NODE_VERSION)) {
709
709
  _chunk5APD2MNVjs.logger.warn(
710
- `You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunkVTIOEDOKjs.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
710
+ `You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunkI35XJD75js.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
711
711
  );
712
712
  }
713
713
  var cli = _tailwindcsspatch.createTailwindcssPatchCli.call(void 0, {
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  clearTailwindcssPatcherCache,
4
4
  createPatchTargetRecorder,
5
5
  logTailwindcssTarget
6
- } from "./chunk-Q5IGGG5W.mjs";
6
+ } from "./chunk-MPVAZKRB.mjs";
7
7
  import {
8
8
  findWorkspaceRoot,
9
9
  logger
package/dist/core.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ITemplateHandlerOptions, CreateJsHandlerOptions, JsHandlerResult } from './types.mjs';
2
2
  import * as postcss from 'postcss';
3
- import { U as UserDefinedOptions } from './index-B6U7MoOM.mjs';
3
+ import { U as UserDefinedOptions } from './index-t_VBjwYm.mjs';
4
4
  import { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
5
5
  import '@babel/parser';
6
6
  import 'magic-string';
package/dist/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ITemplateHandlerOptions, CreateJsHandlerOptions, JsHandlerResult } from './types.js';
2
2
  import * as postcss from 'postcss';
3
- import { U as UserDefinedOptions } from './index-B6U7MoOM.js';
3
+ import { U as UserDefinedOptions } from './index-t_VBjwYm.js';
4
4
  import { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
5
5
  import '@babel/parser';
6
6
  import 'magic-string';