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.
- package/dist/{chunk-VZX2RV6M.js → chunk-3R7FDZJL.js} +31 -38
- package/dist/{chunk-JA6PNN27.js → chunk-6VKE7EWV.js} +28 -27
- package/dist/{chunk-6QU7CMAG.mjs → chunk-ACNOEKQI.mjs} +1 -1
- package/dist/{chunk-F6VHIO5B.mjs → chunk-BZCCVPSU.mjs} +1 -1
- package/dist/{chunk-PDP4OIKN.js → chunk-HJVZ4TO3.js} +3 -3
- package/dist/{chunk-VTIOEDOK.js → chunk-I35XJD75.js} +223 -97
- package/dist/{chunk-TNAPEHNW.mjs → chunk-LHBUALTK.mjs} +4 -3
- package/dist/{chunk-HFXMZGPW.js → chunk-M2ATX5ZS.js} +3 -3
- package/dist/{chunk-Q5IGGG5W.mjs → chunk-MPVAZKRB.mjs} +189 -63
- package/dist/{chunk-ZP6TLVZX.mjs → chunk-N6JOG5K3.mjs} +3 -2
- package/dist/{chunk-DA2K4ZIE.js → chunk-NPZ5QQC7.js} +8 -7
- package/dist/{chunk-D67CTJV5.mjs → chunk-WJU62RPV.mjs} +13 -20
- package/dist/cli.js +9 -9
- package/dist/cli.mjs +1 -1
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +22 -17
- package/dist/core.mjs +17 -12
- package/dist/defaults.d.mts +1 -1
- package/dist/defaults.d.ts +1 -1
- package/dist/gulp.d.mts +1 -1
- package/dist/gulp.d.ts +1 -1
- package/dist/gulp.js +4 -4
- package/dist/gulp.mjs +3 -3
- package/dist/{index-B6U7MoOM.d.ts → index-t_VBjwYm.d.mts} +13 -6
- package/dist/{index-B6U7MoOM.d.mts → index-t_VBjwYm.d.ts} +13 -6
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/index.mjs +6 -6
- package/dist/presets.d.mts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/types.d.mts +17 -4
- package/dist/types.d.ts +17 -4
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +4 -4
- package/dist/vite.mjs +3 -3
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +5 -5
- package/dist/webpack.mjs +4 -4
- package/dist/webpack4.d.mts +1 -1
- package/dist/webpack4.d.ts +1 -1
- package/dist/webpack4.js +27 -26
- package/dist/webpack4.mjs +4 -3
- 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
|
|
19
|
+
function debug3(formatter, ...args) {
|
|
20
20
|
return _debug((_nullishCoalesce(prefix, () => ( ""))) + formatter, ...args);
|
|
21
21
|
}
|
|
22
|
-
return
|
|
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.
|
|
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 @@ var _escape = require('@ast-core/escape');
|
|
|
1189
1189
|
|
|
1190
1190
|
var _extractors = require('@weapp-tailwindcss/shared/extractors');
|
|
1191
1191
|
|
|
1192
|
-
// src/shared
|
|
1193
|
-
var
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
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, "");
|
|
1199
1202
|
}
|
|
1200
|
-
|
|
1203
|
+
res = _escape3.escape.call(void 0, res, {
|
|
1204
|
+
map: escapeMap,
|
|
1205
|
+
ignoreHead
|
|
1206
|
+
});
|
|
1207
|
+
return res;
|
|
1201
1208
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
if (
|
|
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 (
|
|
1216
|
+
if (/^(?:https?:)?\/\//.test(normalized)) {
|
|
1216
1217
|
return false;
|
|
1217
1218
|
}
|
|
1218
|
-
|
|
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 (
|
|
1229
|
+
if (jsArbitraryValueFallback === false) {
|
|
1222
1230
|
return false;
|
|
1223
1231
|
}
|
|
1224
|
-
|
|
1225
|
-
return false;
|
|
1226
|
-
}
|
|
1227
|
-
return candidate.includes("-") || candidate.includes(":");
|
|
1232
|
+
return tailwindcssMajorVersion === 4 && (!classNameSet || classNameSet.size === 0);
|
|
1228
1233
|
}
|
|
1229
|
-
function
|
|
1234
|
+
function resolveClassNameTransformDecision(candidate, {
|
|
1230
1235
|
alwaysEscape,
|
|
1231
1236
|
classNameSet,
|
|
1232
|
-
|
|
1233
|
-
|
|
1237
|
+
escapeMap,
|
|
1238
|
+
jsArbitraryValueFallback,
|
|
1239
|
+
jsPreserveClass,
|
|
1240
|
+
tailwindcssMajorVersion,
|
|
1241
|
+
classContext
|
|
1234
1242
|
}) {
|
|
1235
1243
|
if (alwaysEscape) {
|
|
1236
|
-
return
|
|
1244
|
+
return "direct";
|
|
1237
1245
|
}
|
|
1238
1246
|
if (_optionalChain([jsPreserveClass, 'optionalCall', _33 => _33(candidate)])) {
|
|
1239
|
-
return
|
|
1247
|
+
return "skip";
|
|
1240
1248
|
}
|
|
1241
|
-
if (
|
|
1242
|
-
|
|
1243
|
-
return false;
|
|
1244
|
-
}
|
|
1245
|
-
return shouldFallbackEscapeClassName(candidate);
|
|
1249
|
+
if (_optionalChain([classNameSet, 'optionalAccess', _34 => _34.has, 'call', _35 => _35(candidate)])) {
|
|
1250
|
+
return "direct";
|
|
1246
1251
|
}
|
|
1247
|
-
if (classNameSet.
|
|
1248
|
-
|
|
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 (
|
|
1251
|
-
|
|
1258
|
+
if (classContext && isArbitraryValueCandidate(candidate) && shouldEnableArbitraryValueFallback({
|
|
1259
|
+
classNameSet,
|
|
1260
|
+
jsArbitraryValueFallback,
|
|
1261
|
+
tailwindcssMajorVersion
|
|
1262
|
+
})) {
|
|
1263
|
+
return "fallback";
|
|
1252
1264
|
}
|
|
1253
|
-
return
|
|
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/
|
|
1280
|
-
var
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
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
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
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;
|
|
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();
|
|
@@ -1331,7 +1423,7 @@ function hasIgnoreComment(node) {
|
|
|
1331
1423
|
return Array.isArray(node.leadingComments) && node.leadingComments.some((comment) => comment.value.includes("weapp-tw") && comment.value.includes("ignore"));
|
|
1332
1424
|
}
|
|
1333
1425
|
function extractLiteralValue(path5, { unescapeUnicode, arbitraryValues }) {
|
|
1334
|
-
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess',
|
|
1426
|
+
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _46 => _46.allowDoubleQuotes]);
|
|
1335
1427
|
let offset = 0;
|
|
1336
1428
|
let original;
|
|
1337
1429
|
if (path5.isStringLiteral()) {
|
|
@@ -1359,7 +1451,9 @@ function replaceHandleValue(path5, options) {
|
|
|
1359
1451
|
needEscaped = false
|
|
1360
1452
|
} = options;
|
|
1361
1453
|
const { classNameSet, alwaysEscape } = options;
|
|
1362
|
-
|
|
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
|
-
|
|
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
|
+
_nullishCoalesce(_optionalChain([classNameSet, 'optionalAccess', _47 => _47.size]), () => ( 0)),
|
|
1506
|
+
fallbackDecisionCount > 0,
|
|
1507
|
+
matchedCandidateCount,
|
|
1508
|
+
escapedDecisionCount,
|
|
1509
|
+
_nullishCoalesce(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) {
|
|
@@ -1564,7 +1682,7 @@ function handleEvalTemplateElement(path5, options, updater, handler) {
|
|
|
1564
1682
|
}
|
|
1565
1683
|
}
|
|
1566
1684
|
function walkEvalExpression(path5, options, updater, handler) {
|
|
1567
|
-
const maybeTraverse = _optionalChain([path5, 'optionalAccess',
|
|
1685
|
+
const maybeTraverse = _optionalChain([path5, 'optionalAccess', _48 => _48.traverse]);
|
|
1568
1686
|
if (typeof maybeTraverse === "function") {
|
|
1569
1687
|
try {
|
|
1570
1688
|
return maybeTraverse.call(path5, {
|
|
@@ -1576,21 +1694,21 @@ function walkEvalExpression(path5, options, updater, handler) {
|
|
|
1576
1694
|
}
|
|
1577
1695
|
});
|
|
1578
1696
|
} catch (error) {
|
|
1579
|
-
const msg = _nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
1697
|
+
const msg = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _49 => _49.message]), () => ( ""));
|
|
1580
1698
|
const scopeError = /pass a scope and parentPath|traversing a Program\/File/i.test(msg);
|
|
1581
1699
|
if (!scopeError) {
|
|
1582
1700
|
throw error;
|
|
1583
1701
|
}
|
|
1584
1702
|
}
|
|
1585
1703
|
}
|
|
1586
|
-
const getArgs = _optionalChain([path5, 'optionalAccess',
|
|
1704
|
+
const getArgs = _optionalChain([path5, 'optionalAccess', _50 => _50.get, 'optionalCall', _51 => _51("arguments")]);
|
|
1587
1705
|
if (Array.isArray(getArgs)) {
|
|
1588
1706
|
for (const arg of getArgs) {
|
|
1589
|
-
if (_optionalChain([arg, 'optionalAccess',
|
|
1707
|
+
if (_optionalChain([arg, 'optionalAccess', _52 => _52.isStringLiteral, 'optionalCall', _53 => _53()])) {
|
|
1590
1708
|
handleEvalStringLiteral(arg, options, updater, handler);
|
|
1591
1709
|
continue;
|
|
1592
1710
|
}
|
|
1593
|
-
if (_optionalChain([arg, 'optionalAccess',
|
|
1711
|
+
if (_optionalChain([arg, 'optionalAccess', _54 => _54.isTemplateLiteral, 'optionalCall', _55 => _55()])) {
|
|
1594
1712
|
for (const quasi of arg.get("quasis")) {
|
|
1595
1713
|
handleEvalTemplateElement(quasi, options, updater, handler);
|
|
1596
1714
|
}
|
|
@@ -1598,16 +1716,16 @@ function walkEvalExpression(path5, options, updater, handler) {
|
|
|
1598
1716
|
}
|
|
1599
1717
|
return;
|
|
1600
1718
|
}
|
|
1601
|
-
const nodeArgs = _optionalChain([path5, 'optionalAccess',
|
|
1719
|
+
const nodeArgs = _optionalChain([path5, 'optionalAccess', _56 => _56.node, 'optionalAccess', _57 => _57.arguments]);
|
|
1602
1720
|
if (Array.isArray(nodeArgs)) {
|
|
1603
1721
|
for (const n of nodeArgs) {
|
|
1604
|
-
if (_optionalChain([n, 'optionalAccess',
|
|
1722
|
+
if (_optionalChain([n, 'optionalAccess', _58 => _58.type]) === "StringLiteral") {
|
|
1605
1723
|
const stub = {
|
|
1606
1724
|
node: n,
|
|
1607
1725
|
isStringLiteral: () => true
|
|
1608
1726
|
};
|
|
1609
1727
|
handleEvalStringLiteral(stub, options, updater, handler);
|
|
1610
|
-
} else if (_optionalChain([n, 'optionalAccess',
|
|
1728
|
+
} else if (_optionalChain([n, 'optionalAccess', _59 => _59.type]) === "TemplateLiteral" && Array.isArray(n.quasis)) {
|
|
1611
1729
|
for (const q of n.quasis) {
|
|
1612
1730
|
const stub = {
|
|
1613
1731
|
node: q,
|
|
@@ -1709,7 +1827,7 @@ var IgnoredExportsTracker = class {
|
|
|
1709
1827
|
continue;
|
|
1710
1828
|
}
|
|
1711
1829
|
if (exportPath.isExportNamedDeclaration()) {
|
|
1712
|
-
const source = _optionalChain([exportPath, 'access',
|
|
1830
|
+
const source = _optionalChain([exportPath, 'access', _60 => _60.node, 'access', _61 => _61.source, 'optionalAccess', _62 => _62.value]);
|
|
1713
1831
|
if (typeof source === "string") {
|
|
1714
1832
|
for (const spec of exportPath.get("specifiers")) {
|
|
1715
1833
|
if (!spec.isExportSpecifier()) {
|
|
@@ -1776,7 +1894,7 @@ var IgnoredExportsTracker = class {
|
|
|
1776
1894
|
continue;
|
|
1777
1895
|
}
|
|
1778
1896
|
if (exportPath.isExportAllDeclaration()) {
|
|
1779
|
-
const source = _optionalChain([exportPath, 'access',
|
|
1897
|
+
const source = _optionalChain([exportPath, 'access', _63 => _63.node, 'access', _64 => _64.source, 'optionalAccess', _65 => _65.value]);
|
|
1780
1898
|
if (typeof source === "string") {
|
|
1781
1899
|
for (const exportName of names) {
|
|
1782
1900
|
propagate.push({
|
|
@@ -1877,7 +1995,7 @@ var JsModuleGraph = class {
|
|
|
1877
1995
|
}
|
|
1878
1996
|
for (const exportPath of state.analysis.exportDeclarations) {
|
|
1879
1997
|
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
1880
|
-
const source = _optionalChain([exportPath, 'access',
|
|
1998
|
+
const source = _optionalChain([exportPath, 'access', _66 => _66.node, 'access', _67 => _67.source, 'optionalAccess', _68 => _68.value]);
|
|
1881
1999
|
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
1882
2000
|
dependencySpecifiers.set(source, []);
|
|
1883
2001
|
}
|
|
@@ -2083,14 +2201,14 @@ var NodePathWalker = class {
|
|
|
2083
2201
|
}
|
|
2084
2202
|
this.visited.add(arg);
|
|
2085
2203
|
if (arg.isIdentifier()) {
|
|
2086
|
-
const binding = _optionalChain([arg, 'optionalAccess',
|
|
2204
|
+
const binding = _optionalChain([arg, 'optionalAccess', _69 => _69.scope, 'optionalAccess', _70 => _70.getBinding, 'optionalCall', _71 => _71(arg.node.name)]);
|
|
2087
2205
|
if (binding) {
|
|
2088
2206
|
this.walkNode(binding.path);
|
|
2089
2207
|
}
|
|
2090
2208
|
} else if (arg.isMemberExpression()) {
|
|
2091
2209
|
const objectPath = arg.get("object");
|
|
2092
2210
|
if (objectPath.isIdentifier()) {
|
|
2093
|
-
const binding = _optionalChain([arg, 'optionalAccess',
|
|
2211
|
+
const binding = _optionalChain([arg, 'optionalAccess', _72 => _72.scope, 'optionalAccess', _73 => _73.getBinding, 'optionalCall', _74 => _74(objectPath.node.name)]);
|
|
2094
2212
|
if (binding) {
|
|
2095
2213
|
if (binding.path.isVariableDeclarator()) {
|
|
2096
2214
|
this.walkVariableDeclarator(binding.path);
|
|
@@ -2167,8 +2285,8 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2167
2285
|
}
|
|
2168
2286
|
const objectPath = path5.get("object");
|
|
2169
2287
|
if (objectPath.isIdentifier()) {
|
|
2170
|
-
const scope = _optionalChain([objectPath, 'optionalAccess',
|
|
2171
|
-
const binding = _optionalChain([scope, 'optionalAccess',
|
|
2288
|
+
const scope = _optionalChain([objectPath, 'optionalAccess', _75 => _75.scope]);
|
|
2289
|
+
const binding = _optionalChain([scope, 'optionalAccess', _76 => _76.getBinding, 'optionalCall', _77 => _77(objectPath.node.name)]);
|
|
2172
2290
|
if (binding) {
|
|
2173
2291
|
return resolvesToWeappTwIgnore(binding, seen);
|
|
2174
2292
|
}
|
|
@@ -2197,7 +2315,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2197
2315
|
const init = bindingPath.get("init");
|
|
2198
2316
|
if (init && init.node) {
|
|
2199
2317
|
if (init.isIdentifier()) {
|
|
2200
|
-
const target = _optionalChain([binding, 'optionalAccess',
|
|
2318
|
+
const target = _optionalChain([binding, 'optionalAccess', _78 => _78.scope, 'optionalAccess', _79 => _79.getBinding, 'optionalCall', _80 => _80(init.node.name)]);
|
|
2201
2319
|
if (target) {
|
|
2202
2320
|
result = resolvesToWeappTwIgnore(target, seen);
|
|
2203
2321
|
}
|
|
@@ -2213,7 +2331,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2213
2331
|
const getEffectiveTagPath = (tagPath) => {
|
|
2214
2332
|
let current = tagPath;
|
|
2215
2333
|
while (true) {
|
|
2216
|
-
if (_optionalChain([current, 'access',
|
|
2334
|
+
if (_optionalChain([current, 'access', _81 => _81.isParenthesizedExpression, 'optionalCall', _82 => _82()]) || current.node.type === "ParenthesizedExpression") {
|
|
2217
2335
|
current = current.get("expression");
|
|
2218
2336
|
continue;
|
|
2219
2337
|
}
|
|
@@ -2225,7 +2343,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2225
2343
|
current = current.get("expression");
|
|
2226
2344
|
continue;
|
|
2227
2345
|
}
|
|
2228
|
-
if (_optionalChain([current, 'access',
|
|
2346
|
+
if (_optionalChain([current, 'access', _83 => _83.isTypeCastExpression, 'optionalCall', _84 => _84()])) {
|
|
2229
2347
|
current = current.get("expression");
|
|
2230
2348
|
continue;
|
|
2231
2349
|
}
|
|
@@ -2237,7 +2355,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2237
2355
|
continue;
|
|
2238
2356
|
}
|
|
2239
2357
|
}
|
|
2240
|
-
if (_optionalChain([current, 'access',
|
|
2358
|
+
if (_optionalChain([current, 'access', _85 => _85.isCallExpression, 'optionalCall', _86 => _86()]) || current.node.type === "CallExpression") {
|
|
2241
2359
|
const callee = current.get("callee");
|
|
2242
2360
|
current = callee;
|
|
2243
2361
|
continue;
|
|
@@ -2247,7 +2365,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2247
2365
|
return current;
|
|
2248
2366
|
};
|
|
2249
2367
|
const evaluateTagPath = (tagPath) => {
|
|
2250
|
-
if (_optionalChain([tagPath, 'access',
|
|
2368
|
+
if (_optionalChain([tagPath, 'access', _87 => _87.isCallExpression, 'optionalCall', _88 => _88()]) || tagPath.node.type === "CallExpression") {
|
|
2251
2369
|
const calleePath = tagPath.get("callee");
|
|
2252
2370
|
return evaluateTagPath(calleePath);
|
|
2253
2371
|
}
|
|
@@ -2255,7 +2373,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2255
2373
|
if (matcher(tagPath.node.name)) {
|
|
2256
2374
|
return true;
|
|
2257
2375
|
}
|
|
2258
|
-
const binding = _optionalChain([tagPath, 'optionalAccess',
|
|
2376
|
+
const binding = _optionalChain([tagPath, 'optionalAccess', _89 => _89.scope, 'optionalAccess', _90 => _90.getBinding, 'optionalCall', _91 => _91(tagPath.node.name)]);
|
|
2259
2377
|
if (binding) {
|
|
2260
2378
|
return resolvesToWeappTwIgnore(binding, /* @__PURE__ */ new Set());
|
|
2261
2379
|
}
|
|
@@ -2351,11 +2469,11 @@ function analyzeSource(ast, options, handler) {
|
|
|
2351
2469
|
return;
|
|
2352
2470
|
}
|
|
2353
2471
|
const calleePath = p.get("callee");
|
|
2354
|
-
if (calleePath.isIdentifier({ name: "require" }) && !_optionalChain([p, 'optionalAccess',
|
|
2472
|
+
if (calleePath.isIdentifier({ name: "require" }) && !_optionalChain([p, 'optionalAccess', _92 => _92.scope, 'optionalAccess', _93 => _93.hasBinding, 'optionalCall', _94 => _94("require")])) {
|
|
2355
2473
|
const args = p.get("arguments");
|
|
2356
2474
|
if (Array.isArray(args) && args.length > 0) {
|
|
2357
2475
|
const first = args[0];
|
|
2358
|
-
if (_optionalChain([first, 'optionalAccess',
|
|
2476
|
+
if (_optionalChain([first, 'optionalAccess', _95 => _95.isStringLiteral, 'call', _96 => _96()])) {
|
|
2359
2477
|
requireCallPaths.push(first);
|
|
2360
2478
|
}
|
|
2361
2479
|
}
|
|
@@ -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,
|
|
@@ -2559,7 +2681,7 @@ function shouldSkipLegacyStringLiteral(path5) {
|
|
|
2559
2681
|
return true;
|
|
2560
2682
|
}
|
|
2561
2683
|
return Boolean(
|
|
2562
|
-
t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access',
|
|
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])))
|
|
2563
2685
|
);
|
|
2564
2686
|
}
|
|
2565
2687
|
function createLegacyTraverseOptions(options, jsTokenUpdater) {
|
|
@@ -2860,7 +2982,7 @@ async function customTemplateHandler(rawSource, options) {
|
|
|
2860
2982
|
}
|
|
2861
2983
|
const lowerName = name.toLowerCase();
|
|
2862
2984
|
const shouldHandleDefault = !disabledDefaultTemplateHandler && (lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass");
|
|
2863
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall',
|
|
2985
|
+
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _101 => _101(tag, name)]), () => ( false));
|
|
2864
2986
|
if (!shouldHandleDefault && !shouldHandleCustom) {
|
|
2865
2987
|
return;
|
|
2866
2988
|
}
|
|
@@ -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: _nullishCoalesce(jsArbitraryValueFallback, () => ( "auto")),
|
|
3101
|
+
tailwindcssMajorVersion,
|
|
2977
3102
|
generateMap: true,
|
|
2978
3103
|
babelParserOptions,
|
|
2979
3104
|
ignoreCallExpressionIdentifiers,
|
|
@@ -3012,7 +3137,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3012
3137
|
if (!patcher) {
|
|
3013
3138
|
return;
|
|
3014
3139
|
}
|
|
3015
|
-
const cacheOptions = _optionalChain([patcher, 'access',
|
|
3140
|
+
const cacheOptions = _optionalChain([patcher, 'access', _102 => _102.options, 'optionalAccess', _103 => _103.cache]);
|
|
3016
3141
|
if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
|
|
3017
3142
|
return;
|
|
3018
3143
|
}
|
|
@@ -3023,19 +3148,19 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3023
3148
|
_logger.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
|
|
3024
3149
|
}
|
|
3025
3150
|
}
|
|
3026
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3151
|
+
if (!_optionalChain([options, 'optionalAccess', _104 => _104.removeDirectory])) {
|
|
3027
3152
|
return;
|
|
3028
3153
|
}
|
|
3029
3154
|
const cachePaths = /* @__PURE__ */ new Map();
|
|
3030
3155
|
const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
|
|
3031
|
-
if (_optionalChain([normalizedCacheOptions, 'optionalAccess',
|
|
3156
|
+
if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _105 => _105.path])) {
|
|
3032
3157
|
cachePaths.set(normalizedCacheOptions.path, false);
|
|
3033
3158
|
}
|
|
3034
|
-
const privateCachePath = _optionalChain([patcher, 'optionalAccess',
|
|
3159
|
+
const privateCachePath = _optionalChain([patcher, 'optionalAccess', _106 => _106.cacheStore, 'optionalAccess', _107 => _107.options, 'optionalAccess', _108 => _108.path]);
|
|
3035
3160
|
if (privateCachePath) {
|
|
3036
3161
|
cachePaths.set(privateCachePath, false);
|
|
3037
3162
|
}
|
|
3038
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3163
|
+
if (_optionalChain([options, 'optionalAccess', _109 => _109.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _110 => _110.dir])) {
|
|
3039
3164
|
cachePaths.set(normalizedCacheOptions.dir, true);
|
|
3040
3165
|
}
|
|
3041
3166
|
if (!cachePaths.size) {
|
|
@@ -3046,7 +3171,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3046
3171
|
await _promises.rm.call(void 0, cachePath, { force: true, recursive });
|
|
3047
3172
|
} catch (error) {
|
|
3048
3173
|
const err = error;
|
|
3049
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
3174
|
+
if (_optionalChain([err, 'optionalAccess', _111 => _111.code]) === "ENOENT") {
|
|
3050
3175
|
continue;
|
|
3051
3176
|
}
|
|
3052
3177
|
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
@@ -3063,7 +3188,7 @@ function createInternalCompilerContext(opts) {
|
|
|
3063
3188
|
applyLoggerLevel(ctx.logLevel);
|
|
3064
3189
|
const twPatcher = _chunk5APD2MNVjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
3065
3190
|
logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
|
|
3066
|
-
if (_optionalChain([twPatcher, 'access',
|
|
3191
|
+
if (_optionalChain([twPatcher, 'access', _112 => _112.packageInfo, 'optionalAccess', _113 => _113.version])) {
|
|
3067
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)))}`);
|
|
3068
3193
|
} else {
|
|
3069
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`);
|
|
@@ -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;
|
|
@@ -3084,7 +3210,7 @@ function createInternalCompilerContext(opts) {
|
|
|
3084
3210
|
ctx.twPatcher = twPatcher;
|
|
3085
3211
|
const refreshTailwindcssPatcher = async (options) => {
|
|
3086
3212
|
const previousPatcher = ctx.twPatcher;
|
|
3087
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3213
|
+
if (_optionalChain([options, 'optionalAccess', _114 => _114.clearCache]) !== false) {
|
|
3088
3214
|
await clearTailwindcssPatcherCache(previousPatcher);
|
|
3089
3215
|
}
|
|
3090
3216
|
invalidateRuntimeClassSet(previousPatcher);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isMpx,
|
|
11
11
|
patchMpxLoaderResolve,
|
|
12
12
|
setupMpxTailwindcssRedirect
|
|
13
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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: {
|