weapp-tailwindcss 4.7.6 → 4.7.7
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-36GNZBVS.js → chunk-2WZP7EXP.js} +269 -130
- package/dist/{chunk-G4SYITSG.mjs → chunk-APVOYXRF.mjs} +2 -4
- package/dist/{chunk-MEX4EXZX.mjs → chunk-FZNEB7RC.mjs} +2 -2
- package/dist/{chunk-VL24RIGE.mjs → chunk-KGKHHXRC.mjs} +243 -104
- package/dist/{chunk-SXYSWJRO.js → chunk-MGHX7SCL.js} +11 -13
- package/dist/{chunk-3AAVIURI.js → chunk-MMBZHHNL.js} +1 -1
- package/dist/{chunk-EGX7MMTE.mjs → chunk-MNKR7BNZ.mjs} +1 -1
- package/dist/{chunk-6WB6H5P4.js → chunk-PP6KHC2I.js} +6 -6
- package/dist/{chunk-RTOKUKLA.js → chunk-VLM4KUZA.js} +4 -4
- package/dist/{chunk-UB5UEGVL.mjs → chunk-VPQLMV42.mjs} +1 -1
- package/dist/{chunk-JISOHATJ.js → chunk-X5SXNF7I.js} +10 -10
- package/dist/cli.js +23 -12
- package/dist/cli.mjs +17 -6
- package/dist/core.js +9 -10
- package/dist/core.mjs +2 -3
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/escape.d.mts +4 -16
- package/dist/escape.d.ts +4 -16
- package/dist/escape.js +53 -9
- package/dist/escape.mjs +19 -5
- package/dist/gulp.js +5 -6
- package/dist/gulp.mjs +3 -4
- package/dist/index.js +7 -8
- package/dist/index.mjs +5 -6
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +1 -1
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +5 -6
- package/dist/vite.mjs +3 -4
- package/dist/webpack.js +5 -6
- package/dist/webpack.mjs +3 -4
- package/dist/webpack4.js +12 -13
- package/dist/webpack4.mjs +2 -3
- package/package.json +5 -5
- package/dist/chunk-DWAEHRHN.js +0 -21
- package/dist/chunk-VSRDBMDB.mjs +0 -21
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkRTOKUKLAjs = require('./chunk-RTOKUKLA.js');
|
|
3
|
+
var _chunkVLM4KUZAjs = require('./chunk-VLM4KUZA.js');
|
|
7
4
|
|
|
8
5
|
|
|
9
6
|
var _chunkUSAH2CX5js = require('./chunk-USAH2CX5.js');
|
|
@@ -173,6 +170,112 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
|
|
173
|
+
// src/tailwindcss/targets.ts
|
|
174
|
+
|
|
175
|
+
var _promises = require('fs/promises');
|
|
176
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
177
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
178
|
+
var _logger = require('@weapp-tailwindcss/logger');
|
|
179
|
+
var PATCH_INFO_DIRNAME = ".tw-patch";
|
|
180
|
+
var PATCH_INFO_FILENAME = "tailwindcss-target.json";
|
|
181
|
+
function formatRelativeToBase(targetPath, baseDir) {
|
|
182
|
+
if (!baseDir) {
|
|
183
|
+
return _path2.default.normalize(targetPath);
|
|
184
|
+
}
|
|
185
|
+
const relative = _path2.default.relative(baseDir, targetPath);
|
|
186
|
+
if (!relative || relative === ".") {
|
|
187
|
+
return ".";
|
|
188
|
+
}
|
|
189
|
+
if (relative.startsWith("..")) {
|
|
190
|
+
return _path2.default.normalize(targetPath);
|
|
191
|
+
}
|
|
192
|
+
return _path2.default.join(".", relative);
|
|
193
|
+
}
|
|
194
|
+
function getRecordFilePath(baseDir) {
|
|
195
|
+
return _path2.default.join(baseDir, PATCH_INFO_DIRNAME, PATCH_INFO_FILENAME);
|
|
196
|
+
}
|
|
197
|
+
function logTailwindcssTarget(kind, patcher, baseDir) {
|
|
198
|
+
const packageInfo = _optionalChain([patcher, 'optionalAccess', _6 => _6.packageInfo]);
|
|
199
|
+
const label = kind === "cli" ? "weapp-tw patch" : "tailwindcss-patcher";
|
|
200
|
+
if (!_optionalChain([packageInfo, 'optionalAccess', _7 => _7.rootPath])) {
|
|
201
|
+
_logger.logger.warn(
|
|
202
|
+
"%s \u672A\u627E\u5230 Tailwind CSS \u4F9D\u8D56\uFF0C\u8BF7\u68C0\u67E5\u5728 %s \u662F\u5426\u5DF2\u5B89\u88C5 tailwindcss",
|
|
203
|
+
label,
|
|
204
|
+
_nullishCoalesce(baseDir, () => ( _process2.default.cwd()))
|
|
205
|
+
);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
|
|
209
|
+
const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
|
|
210
|
+
_logger.logger.info("%s \u7ED1\u5B9A Tailwind CSS -> %s%s", label, displayPath, version);
|
|
211
|
+
}
|
|
212
|
+
function readPatchTargetRecord(baseDir) {
|
|
213
|
+
if (!baseDir) {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
const recordPath = getRecordFilePath(baseDir);
|
|
217
|
+
if (!_fs.existsSync.call(void 0, recordPath)) {
|
|
218
|
+
return void 0;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
const content = _fs.readFileSync.call(void 0, recordPath, "utf8");
|
|
222
|
+
const parsed = JSON.parse(content);
|
|
223
|
+
if (!parsed || typeof parsed.tailwindPackagePath !== "string") {
|
|
224
|
+
return void 0;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
path: recordPath,
|
|
228
|
+
record: parsed
|
|
229
|
+
};
|
|
230
|
+
} catch (error) {
|
|
231
|
+
_logger.logger.debug("failed to read patch target record from %s: %O", recordPath, error);
|
|
232
|
+
return void 0;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async function saveCliPatchTargetRecord(baseDir, patcher) {
|
|
236
|
+
if (!baseDir || !_optionalChain([patcher, 'optionalAccess', _8 => _8.packageInfo, 'optionalAccess', _9 => _9.rootPath])) {
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
const record = {
|
|
240
|
+
tailwindPackagePath: _path2.default.normalize(patcher.packageInfo.rootPath),
|
|
241
|
+
packageVersion: patcher.packageInfo.version,
|
|
242
|
+
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
243
|
+
source: "cli",
|
|
244
|
+
tailwindcssBasedir: _path2.default.normalize(baseDir)
|
|
245
|
+
};
|
|
246
|
+
const recordPath = getRecordFilePath(baseDir);
|
|
247
|
+
try {
|
|
248
|
+
await _promises.mkdir.call(void 0, _path2.default.dirname(recordPath), { recursive: true });
|
|
249
|
+
await _promises.writeFile.call(void 0, recordPath, `${JSON.stringify(record, null, 2)}
|
|
250
|
+
`, "utf8");
|
|
251
|
+
return recordPath;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
_logger.logger.debug("failed to persist patch target record %s: %O", recordPath, error);
|
|
254
|
+
return void 0;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function warnIfCliPatchTargetMismatch(baseDir, patcher) {
|
|
258
|
+
if (!baseDir || !_optionalChain([patcher, 'optionalAccess', _10 => _10.packageInfo, 'optionalAccess', _11 => _11.rootPath])) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const recorded = readPatchTargetRecord(baseDir);
|
|
262
|
+
if (!recorded) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const normalizedRecorded = _path2.default.normalize(recorded.record.tailwindPackagePath);
|
|
266
|
+
const normalizedRuntime = _path2.default.normalize(patcher.packageInfo.rootPath);
|
|
267
|
+
if (normalizedRecorded === normalizedRuntime) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const recordedDisplay = formatRelativeToBase(normalizedRecorded, baseDir);
|
|
271
|
+
const runtimeDisplay = formatRelativeToBase(normalizedRuntime, baseDir);
|
|
272
|
+
const baseDisplay = formatRelativeToBase(_path2.default.normalize(baseDir), _process2.default.cwd());
|
|
273
|
+
const recordFileDisplay = formatRelativeToBase(recorded.path, baseDir);
|
|
274
|
+
_logger.logger.warn(
|
|
275
|
+
`\u68C0\u6D4B\u5230 ${baseDisplay} \u7684 Tailwind CSS \u76EE\u6807\u4E0D\u4E00\u81F4\uFF1ACLI \u6253\u8865\u4E01\u7684\u662F ${recordedDisplay}\uFF0C\u8FD0\u884C\u65F6\u8BFB\u53D6\u7684\u662F ${runtimeDisplay}\u3002\u8BF7\u5728\u5BF9\u5E94\u5B50\u5305\u6267\u884C "weapp-tw patch --cwd ${baseDir}"\uFF08\u8BB0\u5F55\u6587\u4EF6\uFF1A${recordFileDisplay}\uFF09\u3002`
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
176
279
|
// src/constants.ts
|
|
177
280
|
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
178
281
|
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
@@ -184,8 +287,8 @@ var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
|
184
287
|
};
|
|
185
288
|
|
|
186
289
|
// src/context/index.ts
|
|
187
|
-
|
|
188
|
-
|
|
290
|
+
|
|
291
|
+
|
|
189
292
|
|
|
190
293
|
// src/cache/index.ts
|
|
191
294
|
var _lrucache = require('lru-cache');
|
|
@@ -264,13 +367,13 @@ function createCache(options) {
|
|
|
264
367
|
const nextHash = _nullishCoalesce(hash, () => ( cache.computeHash(rawSource)));
|
|
265
368
|
cache.calcHashValueChanged(cacheHashKey, nextHash);
|
|
266
369
|
const entry = cache.getHashValue(cacheHashKey);
|
|
267
|
-
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
370
|
+
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _12 => _12.changed]), () => ( true));
|
|
268
371
|
}
|
|
269
372
|
const readCache = _nullishCoalesce(resolveCache, () => ( (() => cache.get(key))));
|
|
270
373
|
if (!hasChanged) {
|
|
271
374
|
const cached = readCache();
|
|
272
375
|
if (cached !== void 0) {
|
|
273
|
-
await _optionalChain([onCacheHit, 'optionalCall',
|
|
376
|
+
await _optionalChain([onCacheHit, 'optionalCall', _13 => _13(cached)]);
|
|
274
377
|
return cached;
|
|
275
378
|
}
|
|
276
379
|
}
|
|
@@ -360,10 +463,10 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
360
463
|
const fuzzyMatcher = exact ? void 0 : buildFuzzyMatcher(fuzzyStrings);
|
|
361
464
|
const hasRegex = regexList.length > 0;
|
|
362
465
|
return (value) => {
|
|
363
|
-
if (exact && _optionalChain([exactStrings, 'optionalAccess',
|
|
466
|
+
if (exact && _optionalChain([exactStrings, 'optionalAccess', _14 => _14.has, 'call', _15 => _15(value)])) {
|
|
364
467
|
return true;
|
|
365
468
|
}
|
|
366
|
-
if (_optionalChain([fuzzyMatcher, 'optionalCall',
|
|
469
|
+
if (_optionalChain([fuzzyMatcher, 'optionalCall', _16 => _16(value)])) {
|
|
367
470
|
return true;
|
|
368
471
|
}
|
|
369
472
|
if (!hasRegex) {
|
|
@@ -375,22 +478,22 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
375
478
|
|
|
376
479
|
// src/js/evalTransforms.ts
|
|
377
480
|
var _escape = require('@ast-core/escape');
|
|
378
|
-
function isEvalPath(
|
|
379
|
-
if (
|
|
380
|
-
const calleePath =
|
|
481
|
+
function isEvalPath(path2) {
|
|
482
|
+
if (path2.isCallExpression()) {
|
|
483
|
+
const calleePath = path2.get("callee");
|
|
381
484
|
return calleePath.isIdentifier({ name: "eval" });
|
|
382
485
|
}
|
|
383
486
|
return false;
|
|
384
487
|
}
|
|
385
|
-
function createEvalReplacementToken(
|
|
386
|
-
const node =
|
|
488
|
+
function createEvalReplacementToken(path2, updated) {
|
|
489
|
+
const node = path2.node;
|
|
387
490
|
let offset = 0;
|
|
388
491
|
let original;
|
|
389
|
-
if (
|
|
492
|
+
if (path2.isStringLiteral()) {
|
|
390
493
|
offset = 1;
|
|
391
|
-
original =
|
|
392
|
-
} else if (
|
|
393
|
-
original =
|
|
494
|
+
original = path2.node.value;
|
|
495
|
+
} else if (path2.isTemplateElement()) {
|
|
496
|
+
original = path2.node.value.raw;
|
|
394
497
|
} else {
|
|
395
498
|
original = "";
|
|
396
499
|
}
|
|
@@ -405,16 +508,16 @@ function createEvalReplacementToken(path, updated) {
|
|
|
405
508
|
if (original === updated) {
|
|
406
509
|
return void 0;
|
|
407
510
|
}
|
|
408
|
-
const value =
|
|
511
|
+
const value = path2.isStringLiteral() ? _escape.jsStringEscape.call(void 0, updated) : updated;
|
|
409
512
|
return {
|
|
410
513
|
start,
|
|
411
514
|
end,
|
|
412
515
|
value,
|
|
413
|
-
path
|
|
516
|
+
path: path2
|
|
414
517
|
};
|
|
415
518
|
}
|
|
416
|
-
function handleEvalStringLiteral(
|
|
417
|
-
const { code } = handler(
|
|
519
|
+
function handleEvalStringLiteral(path2, options, updater, handler) {
|
|
520
|
+
const { code } = handler(path2.node.value, {
|
|
418
521
|
...options,
|
|
419
522
|
needEscaped: false,
|
|
420
523
|
generateMap: false
|
|
@@ -422,26 +525,26 @@ function handleEvalStringLiteral(path, options, updater, handler) {
|
|
|
422
525
|
if (!code) {
|
|
423
526
|
return;
|
|
424
527
|
}
|
|
425
|
-
const token = createEvalReplacementToken(
|
|
528
|
+
const token = createEvalReplacementToken(path2, code);
|
|
426
529
|
if (token) {
|
|
427
530
|
updater.addToken(token);
|
|
428
531
|
}
|
|
429
532
|
}
|
|
430
|
-
function handleEvalTemplateElement(
|
|
431
|
-
const { code } = handler(
|
|
533
|
+
function handleEvalTemplateElement(path2, options, updater, handler) {
|
|
534
|
+
const { code } = handler(path2.node.value.raw, {
|
|
432
535
|
...options,
|
|
433
536
|
generateMap: false
|
|
434
537
|
});
|
|
435
538
|
if (!code) {
|
|
436
539
|
return;
|
|
437
540
|
}
|
|
438
|
-
const token = createEvalReplacementToken(
|
|
541
|
+
const token = createEvalReplacementToken(path2, code);
|
|
439
542
|
if (token) {
|
|
440
543
|
updater.addToken(token);
|
|
441
544
|
}
|
|
442
545
|
}
|
|
443
|
-
function walkEvalExpression(
|
|
444
|
-
|
|
546
|
+
function walkEvalExpression(path2, options, updater, handler) {
|
|
547
|
+
path2.traverse({
|
|
445
548
|
StringLiteral(innerPath) {
|
|
446
549
|
handleEvalStringLiteral(innerPath, options, updater, handler);
|
|
447
550
|
},
|
|
@@ -479,6 +582,24 @@ function decodeUnicode2(input) {
|
|
|
479
582
|
}
|
|
480
583
|
}
|
|
481
584
|
|
|
585
|
+
// src/wxml/shared.ts
|
|
586
|
+
var _escape3 = require('@weapp-core/escape');
|
|
587
|
+
function replaceWxml(original, options = {
|
|
588
|
+
keepEOL: false,
|
|
589
|
+
escapeMap: _escape3.MappingChars2String
|
|
590
|
+
}) {
|
|
591
|
+
const { keepEOL, escapeMap, ignoreHead } = options;
|
|
592
|
+
let res = original;
|
|
593
|
+
if (!keepEOL) {
|
|
594
|
+
res = res.replaceAll(/[\n\r]+/g, "");
|
|
595
|
+
}
|
|
596
|
+
res = _escape3.escape.call(void 0, res, {
|
|
597
|
+
map: escapeMap,
|
|
598
|
+
ignoreHead
|
|
599
|
+
});
|
|
600
|
+
return res;
|
|
601
|
+
}
|
|
602
|
+
|
|
482
603
|
// src/js/handlers.ts
|
|
483
604
|
var patternCache = /* @__PURE__ */ new Map();
|
|
484
605
|
var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -495,7 +616,7 @@ function getReplacement(candidate, escapeMap) {
|
|
|
495
616
|
if (!escapeMap) {
|
|
496
617
|
let cached2 = defaultReplacementCache.get(candidate);
|
|
497
618
|
if (cached2 === void 0) {
|
|
498
|
-
cached2 =
|
|
619
|
+
cached2 = replaceWxml(candidate, { escapeMap });
|
|
499
620
|
defaultReplacementCache.set(candidate, cached2);
|
|
500
621
|
}
|
|
501
622
|
return cached2;
|
|
@@ -507,7 +628,7 @@ function getReplacement(candidate, escapeMap) {
|
|
|
507
628
|
}
|
|
508
629
|
let cached = store.get(candidate);
|
|
509
630
|
if (cached === void 0) {
|
|
510
|
-
cached =
|
|
631
|
+
cached = replaceWxml(candidate, { escapeMap });
|
|
511
632
|
store.set(candidate, cached);
|
|
512
633
|
}
|
|
513
634
|
return cached;
|
|
@@ -529,17 +650,17 @@ function shouldTransformClassName(candidate, {
|
|
|
529
650
|
if (!classNameSet.has(candidate)) {
|
|
530
651
|
return false;
|
|
531
652
|
}
|
|
532
|
-
return !_optionalChain([jsPreserveClass, 'optionalCall',
|
|
653
|
+
return !_optionalChain([jsPreserveClass, 'optionalCall', _17 => _17(candidate)]);
|
|
533
654
|
}
|
|
534
|
-
function extractLiteralValue(
|
|
535
|
-
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess',
|
|
655
|
+
function extractLiteralValue(path2, { unescapeUnicode, arbitraryValues }) {
|
|
656
|
+
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _18 => _18.allowDoubleQuotes]);
|
|
536
657
|
let offset = 0;
|
|
537
658
|
let original;
|
|
538
|
-
if (
|
|
659
|
+
if (path2.isStringLiteral()) {
|
|
539
660
|
offset = 1;
|
|
540
|
-
original =
|
|
541
|
-
} else if (
|
|
542
|
-
original =
|
|
661
|
+
original = path2.node.value;
|
|
662
|
+
} else if (path2.isTemplateElement()) {
|
|
663
|
+
original = path2.node.value.raw;
|
|
543
664
|
} else {
|
|
544
665
|
original = "";
|
|
545
666
|
}
|
|
@@ -554,7 +675,7 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
554
675
|
original
|
|
555
676
|
};
|
|
556
677
|
}
|
|
557
|
-
function replaceHandleValue(
|
|
678
|
+
function replaceHandleValue(path2, options) {
|
|
558
679
|
const {
|
|
559
680
|
escapeMap,
|
|
560
681
|
needEscaped = false
|
|
@@ -563,8 +684,8 @@ function replaceHandleValue(path, options) {
|
|
|
563
684
|
if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
|
|
564
685
|
return void 0;
|
|
565
686
|
}
|
|
566
|
-
const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(
|
|
567
|
-
if (hasIgnoreComment(
|
|
687
|
+
const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path2, options);
|
|
688
|
+
if (hasIgnoreComment(path2.node)) {
|
|
568
689
|
return void 0;
|
|
569
690
|
}
|
|
570
691
|
const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
|
|
@@ -588,7 +709,7 @@ function replaceHandleValue(path, options) {
|
|
|
588
709
|
mutated = true;
|
|
589
710
|
}
|
|
590
711
|
}
|
|
591
|
-
const node =
|
|
712
|
+
const node = path2.node;
|
|
592
713
|
if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") {
|
|
593
714
|
return void 0;
|
|
594
715
|
}
|
|
@@ -602,7 +723,7 @@ function replaceHandleValue(path, options) {
|
|
|
602
723
|
start,
|
|
603
724
|
end,
|
|
604
725
|
value,
|
|
605
|
-
path
|
|
726
|
+
path: path2
|
|
606
727
|
};
|
|
607
728
|
}
|
|
608
729
|
|
|
@@ -726,7 +847,7 @@ var JsModuleGraph = class {
|
|
|
726
847
|
continue;
|
|
727
848
|
}
|
|
728
849
|
if (exportPath.isExportNamedDeclaration()) {
|
|
729
|
-
const source = _optionalChain([exportPath, 'access',
|
|
850
|
+
const source = _optionalChain([exportPath, 'access', _19 => _19.node, 'access', _20 => _20.source, 'optionalAccess', _21 => _21.value]);
|
|
730
851
|
if (typeof source === "string") {
|
|
731
852
|
for (const spec of exportPath.get("specifiers")) {
|
|
732
853
|
if (!spec.isExportSpecifier()) {
|
|
@@ -793,7 +914,7 @@ var JsModuleGraph = class {
|
|
|
793
914
|
continue;
|
|
794
915
|
}
|
|
795
916
|
if (exportPath.isExportAllDeclaration()) {
|
|
796
|
-
const source = _optionalChain([exportPath, 'access',
|
|
917
|
+
const source = _optionalChain([exportPath, 'access', _22 => _22.node, 'access', _23 => _23.source, 'optionalAccess', _24 => _24.value]);
|
|
797
918
|
if (typeof source === "string") {
|
|
798
919
|
for (const exportName of names) {
|
|
799
920
|
propagate.push({
|
|
@@ -845,7 +966,7 @@ var JsModuleGraph = class {
|
|
|
845
966
|
}
|
|
846
967
|
for (const exportPath of state.analysis.exportDeclarations) {
|
|
847
968
|
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
848
|
-
const source = _optionalChain([exportPath, 'access',
|
|
969
|
+
const source = _optionalChain([exportPath, 'access', _25 => _25.node, 'access', _26 => _26.source, 'optionalAccess', _27 => _27.value]);
|
|
849
970
|
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
850
971
|
dependencySpecifiers.set(source, []);
|
|
851
972
|
}
|
|
@@ -914,35 +1035,35 @@ var NodePathWalker = class {
|
|
|
914
1035
|
this.visited = /* @__PURE__ */ new WeakSet();
|
|
915
1036
|
this.isIgnoredCallIdentifier = createNameMatcher(this.ignoreCallExpressionIdentifiers, { exact: true });
|
|
916
1037
|
}
|
|
917
|
-
walkVariableDeclarator(
|
|
918
|
-
const init =
|
|
1038
|
+
walkVariableDeclarator(path2) {
|
|
1039
|
+
const init = path2.get("init");
|
|
919
1040
|
this.walkNode(init);
|
|
920
1041
|
}
|
|
921
|
-
walkTemplateLiteral(
|
|
922
|
-
for (const exp of
|
|
1042
|
+
walkTemplateLiteral(path2) {
|
|
1043
|
+
for (const exp of path2.get("expressions")) {
|
|
923
1044
|
this.walkNode(exp);
|
|
924
1045
|
}
|
|
925
|
-
for (const quasis of
|
|
1046
|
+
for (const quasis of path2.get("quasis")) {
|
|
926
1047
|
this.callback(quasis);
|
|
927
1048
|
}
|
|
928
1049
|
}
|
|
929
|
-
walkStringLiteral(
|
|
930
|
-
this.callback(
|
|
1050
|
+
walkStringLiteral(path2) {
|
|
1051
|
+
this.callback(path2);
|
|
931
1052
|
}
|
|
932
|
-
walkBinaryExpression(
|
|
933
|
-
const left =
|
|
1053
|
+
walkBinaryExpression(path2) {
|
|
1054
|
+
const left = path2.get("left");
|
|
934
1055
|
this.walkNode(left);
|
|
935
|
-
const right =
|
|
1056
|
+
const right = path2.get("right");
|
|
936
1057
|
this.walkNode(right);
|
|
937
1058
|
}
|
|
938
|
-
walkLogicalExpression(
|
|
939
|
-
const left =
|
|
1059
|
+
walkLogicalExpression(path2) {
|
|
1060
|
+
const left = path2.get("left");
|
|
940
1061
|
this.walkNode(left);
|
|
941
|
-
const right =
|
|
1062
|
+
const right = path2.get("right");
|
|
942
1063
|
this.walkNode(right);
|
|
943
1064
|
}
|
|
944
|
-
walkObjectExpression(
|
|
945
|
-
const props =
|
|
1065
|
+
walkObjectExpression(path2) {
|
|
1066
|
+
const props = path2.get("properties");
|
|
946
1067
|
for (const prop of props) {
|
|
947
1068
|
if (prop.isObjectProperty()) {
|
|
948
1069
|
const key = prop.get("key");
|
|
@@ -952,8 +1073,8 @@ var NodePathWalker = class {
|
|
|
952
1073
|
}
|
|
953
1074
|
}
|
|
954
1075
|
}
|
|
955
|
-
walkArrayExpression(
|
|
956
|
-
const elements =
|
|
1076
|
+
walkArrayExpression(path2) {
|
|
1077
|
+
const elements = path2.get("elements");
|
|
957
1078
|
for (const element of elements) {
|
|
958
1079
|
this.walkNode(element);
|
|
959
1080
|
}
|
|
@@ -1026,33 +1147,33 @@ var NodePathWalker = class {
|
|
|
1026
1147
|
/**
|
|
1027
1148
|
* Walk the arguments of a desired call expression so their bindings can be analysed.
|
|
1028
1149
|
*/
|
|
1029
|
-
walkCallExpression(
|
|
1030
|
-
const calleePath =
|
|
1150
|
+
walkCallExpression(path2) {
|
|
1151
|
+
const calleePath = path2.get("callee");
|
|
1031
1152
|
if (calleePath.isIdentifier() && this.isIgnoredCallIdentifier(calleePath.node.name)) {
|
|
1032
|
-
for (const arg of
|
|
1153
|
+
for (const arg of path2.get("arguments")) {
|
|
1033
1154
|
this.walkNode(arg);
|
|
1034
1155
|
}
|
|
1035
1156
|
}
|
|
1036
1157
|
}
|
|
1037
|
-
walkExportDeclaration(
|
|
1038
|
-
if (
|
|
1039
|
-
if (
|
|
1040
|
-
this.walkExportNamedDeclaration(
|
|
1041
|
-
} else if (
|
|
1042
|
-
this.walkExportDefaultDeclaration(
|
|
1043
|
-
} else if (
|
|
1044
|
-
this.walkExportAllDeclaration(
|
|
1158
|
+
walkExportDeclaration(path2) {
|
|
1159
|
+
if (path2.isExportDeclaration()) {
|
|
1160
|
+
if (path2.isExportNamedDeclaration()) {
|
|
1161
|
+
this.walkExportNamedDeclaration(path2);
|
|
1162
|
+
} else if (path2.isExportDefaultDeclaration()) {
|
|
1163
|
+
this.walkExportDefaultDeclaration(path2);
|
|
1164
|
+
} else if (path2.isExportAllDeclaration()) {
|
|
1165
|
+
this.walkExportAllDeclaration(path2);
|
|
1045
1166
|
}
|
|
1046
1167
|
}
|
|
1047
1168
|
}
|
|
1048
|
-
walkExportNamedDeclaration(
|
|
1049
|
-
const declaration =
|
|
1169
|
+
walkExportNamedDeclaration(path2) {
|
|
1170
|
+
const declaration = path2.get("declaration");
|
|
1050
1171
|
if (declaration.isVariableDeclaration()) {
|
|
1051
1172
|
for (const decl of declaration.get("declarations")) {
|
|
1052
1173
|
this.walkNode(decl);
|
|
1053
1174
|
}
|
|
1054
1175
|
}
|
|
1055
|
-
const specifiers =
|
|
1176
|
+
const specifiers = path2.get("specifiers");
|
|
1056
1177
|
for (const spec of specifiers) {
|
|
1057
1178
|
if (spec.isExportSpecifier()) {
|
|
1058
1179
|
const local = spec.get("local");
|
|
@@ -1062,20 +1183,20 @@ var NodePathWalker = class {
|
|
|
1062
1183
|
}
|
|
1063
1184
|
}
|
|
1064
1185
|
}
|
|
1065
|
-
walkExportDefaultDeclaration(
|
|
1066
|
-
const decl =
|
|
1186
|
+
walkExportDefaultDeclaration(path2) {
|
|
1187
|
+
const decl = path2.get("declaration");
|
|
1067
1188
|
if (decl.isIdentifier()) {
|
|
1068
1189
|
this.walkNode(decl);
|
|
1069
1190
|
} else {
|
|
1070
1191
|
this.walkNode(decl);
|
|
1071
1192
|
}
|
|
1072
1193
|
}
|
|
1073
|
-
walkExportAllDeclaration(
|
|
1074
|
-
const source =
|
|
1194
|
+
walkExportAllDeclaration(path2) {
|
|
1195
|
+
const source = path2.get("source");
|
|
1075
1196
|
if (source.isStringLiteral()) {
|
|
1076
1197
|
this.imports.add(
|
|
1077
1198
|
{
|
|
1078
|
-
declaration:
|
|
1199
|
+
declaration: path2,
|
|
1079
1200
|
source: source.node.value,
|
|
1080
1201
|
type: "ExportAllDeclaration"
|
|
1081
1202
|
}
|
|
@@ -1085,8 +1206,8 @@ var NodePathWalker = class {
|
|
|
1085
1206
|
};
|
|
1086
1207
|
|
|
1087
1208
|
// src/js/sourceAnalysis.ts
|
|
1088
|
-
function createModuleSpecifierReplacementToken(
|
|
1089
|
-
const node =
|
|
1209
|
+
function createModuleSpecifierReplacementToken(path2, replacement) {
|
|
1210
|
+
const node = path2.node;
|
|
1090
1211
|
if (node.value === replacement) {
|
|
1091
1212
|
return void 0;
|
|
1092
1213
|
}
|
|
@@ -1102,17 +1223,17 @@ function createModuleSpecifierReplacementToken(path, replacement) {
|
|
|
1102
1223
|
start,
|
|
1103
1224
|
end,
|
|
1104
1225
|
value: replacement,
|
|
1105
|
-
path
|
|
1226
|
+
path: path2
|
|
1106
1227
|
};
|
|
1107
1228
|
}
|
|
1108
1229
|
function collectModuleSpecifierReplacementTokens(analysis, replacements) {
|
|
1109
1230
|
const tokens = [];
|
|
1110
|
-
const applyReplacement = (
|
|
1111
|
-
const replacement = replacements[
|
|
1231
|
+
const applyReplacement = (path2) => {
|
|
1232
|
+
const replacement = replacements[path2.node.value];
|
|
1112
1233
|
if (!replacement) {
|
|
1113
1234
|
return;
|
|
1114
1235
|
}
|
|
1115
|
-
const token = createModuleSpecifierReplacementToken(
|
|
1236
|
+
const token = createModuleSpecifierReplacementToken(path2, replacement);
|
|
1116
1237
|
if (token) {
|
|
1117
1238
|
tokens.push(token);
|
|
1118
1239
|
}
|
|
@@ -1164,12 +1285,12 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1164
1285
|
}
|
|
1165
1286
|
return false;
|
|
1166
1287
|
};
|
|
1167
|
-
const resolvesMemberExpressionToIgnore = (
|
|
1168
|
-
const propertyPath =
|
|
1288
|
+
const resolvesMemberExpressionToIgnore = (path2, seen) => {
|
|
1289
|
+
const propertyPath = path2.get("property");
|
|
1169
1290
|
if (propertyMatches(propertyPath)) {
|
|
1170
1291
|
return true;
|
|
1171
1292
|
}
|
|
1172
|
-
const objectPath =
|
|
1293
|
+
const objectPath = path2.get("object");
|
|
1173
1294
|
if (objectPath.isIdentifier()) {
|
|
1174
1295
|
const binding = objectPath.scope.getBinding(objectPath.node.name);
|
|
1175
1296
|
if (binding) {
|
|
@@ -1216,7 +1337,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1216
1337
|
const getEffectiveTagPath = (tagPath) => {
|
|
1217
1338
|
let current = tagPath;
|
|
1218
1339
|
while (true) {
|
|
1219
|
-
if (_optionalChain([current, 'access',
|
|
1340
|
+
if (_optionalChain([current, 'access', _28 => _28.isParenthesizedExpression, 'optionalCall', _29 => _29()]) || current.node.type === "ParenthesizedExpression") {
|
|
1220
1341
|
current = current.get("expression");
|
|
1221
1342
|
continue;
|
|
1222
1343
|
}
|
|
@@ -1228,7 +1349,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1228
1349
|
current = current.get("expression");
|
|
1229
1350
|
continue;
|
|
1230
1351
|
}
|
|
1231
|
-
if (_optionalChain([current, 'access',
|
|
1352
|
+
if (_optionalChain([current, 'access', _30 => _30.isTypeCastExpression, 'optionalCall', _31 => _31()])) {
|
|
1232
1353
|
current = current.get("expression");
|
|
1233
1354
|
continue;
|
|
1234
1355
|
}
|
|
@@ -1240,7 +1361,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1240
1361
|
continue;
|
|
1241
1362
|
}
|
|
1242
1363
|
}
|
|
1243
|
-
if (_optionalChain([current, 'access',
|
|
1364
|
+
if (_optionalChain([current, 'access', _32 => _32.isCallExpression, 'optionalCall', _33 => _33()]) || current.node.type === "CallExpression") {
|
|
1244
1365
|
const callee = current.get("callee");
|
|
1245
1366
|
current = callee;
|
|
1246
1367
|
continue;
|
|
@@ -1250,7 +1371,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1250
1371
|
return current;
|
|
1251
1372
|
};
|
|
1252
1373
|
const evaluateTagPath = (tagPath) => {
|
|
1253
|
-
if (_optionalChain([tagPath, 'access',
|
|
1374
|
+
if (_optionalChain([tagPath, 'access', _34 => _34.isCallExpression, 'optionalCall', _35 => _35()]) || tagPath.node.type === "CallExpression") {
|
|
1254
1375
|
const calleePath = tagPath.get("callee");
|
|
1255
1376
|
return evaluateTagPath(calleePath);
|
|
1256
1377
|
}
|
|
@@ -1324,9 +1445,9 @@ function analyzeSource(ast, options, handler) {
|
|
|
1324
1445
|
const walker = new NodePathWalker(
|
|
1325
1446
|
{
|
|
1326
1447
|
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
1327
|
-
callback(
|
|
1328
|
-
if (
|
|
1329
|
-
ignoredPaths.add(
|
|
1448
|
+
callback(path2) {
|
|
1449
|
+
if (path2.isStringLiteral() || path2.isTemplateElement()) {
|
|
1450
|
+
ignoredPaths.add(path2);
|
|
1330
1451
|
}
|
|
1331
1452
|
}
|
|
1332
1453
|
}
|
|
@@ -1379,7 +1500,7 @@ function analyzeSource(ast, options, handler) {
|
|
|
1379
1500
|
const args = p.get("arguments");
|
|
1380
1501
|
if (Array.isArray(args) && args.length > 0) {
|
|
1381
1502
|
const first = args[0];
|
|
1382
|
-
if (_optionalChain([first, 'optionalAccess',
|
|
1503
|
+
if (_optionalChain([first, 'optionalAccess', _36 => _36.isStringLiteral, 'call', _37 => _37()])) {
|
|
1383
1504
|
requireCallPaths.push(first);
|
|
1384
1505
|
}
|
|
1385
1506
|
}
|
|
@@ -1414,15 +1535,15 @@ function processUpdatedSource(rawSource, options, analysis) {
|
|
|
1414
1535
|
const ms = new (0, _magicstring2.default)(rawSource);
|
|
1415
1536
|
const { targetPaths, jsTokenUpdater, ignoredPaths } = analysis;
|
|
1416
1537
|
const replacementTokens = [];
|
|
1417
|
-
for (const
|
|
1418
|
-
if (ignoredPaths.has(
|
|
1538
|
+
for (const path2 of targetPaths) {
|
|
1539
|
+
if (ignoredPaths.has(path2)) {
|
|
1419
1540
|
continue;
|
|
1420
1541
|
}
|
|
1421
1542
|
const token = replaceHandleValue(
|
|
1422
|
-
|
|
1543
|
+
path2,
|
|
1423
1544
|
{
|
|
1424
1545
|
...options,
|
|
1425
|
-
needEscaped:
|
|
1546
|
+
needEscaped: path2.isStringLiteral() ? _nullishCoalesce(options.needEscaped, () => ( true)) : false
|
|
1426
1547
|
}
|
|
1427
1548
|
);
|
|
1428
1549
|
if (token) {
|
|
@@ -1769,16 +1890,16 @@ function generateCode(match, options = {}) {
|
|
|
1769
1890
|
const ast = _parser.parseExpression.call(void 0, match);
|
|
1770
1891
|
const jsTokenUpdater = new JsTokenUpdater();
|
|
1771
1892
|
traverse(ast, {
|
|
1772
|
-
StringLiteral(
|
|
1773
|
-
if (t.isMemberExpression(
|
|
1893
|
+
StringLiteral(path2) {
|
|
1894
|
+
if (t.isMemberExpression(path2.parent)) {
|
|
1774
1895
|
return;
|
|
1775
1896
|
}
|
|
1776
|
-
if (t.isBinaryExpression(
|
|
1897
|
+
if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression(_optionalChain([path2, 'access', _38 => _38.parentPath, 'optionalAccess', _39 => _39.parent])) || t.isLogicalExpression(_optionalChain([path2, 'access', _40 => _40.parentPath, 'optionalAccess', _41 => _41.parent])))) {
|
|
1777
1898
|
return;
|
|
1778
1899
|
}
|
|
1779
1900
|
jsTokenUpdater.addToken(
|
|
1780
1901
|
replaceHandleValue(
|
|
1781
|
-
|
|
1902
|
+
path2,
|
|
1782
1903
|
{
|
|
1783
1904
|
escapeMap: options.escapeMap,
|
|
1784
1905
|
classNameSet: options.runtimeSet,
|
|
@@ -1803,7 +1924,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1803
1924
|
if (token.start > previousEnd) {
|
|
1804
1925
|
const gap = ms.slice(previousEnd, token.start);
|
|
1805
1926
|
if (isAllWhitespace(gap)) {
|
|
1806
|
-
ms.update(previousEnd, token.start,
|
|
1927
|
+
ms.update(previousEnd, token.start, replaceWxml(gap, {
|
|
1807
1928
|
keepEOL: false,
|
|
1808
1929
|
escapeMap: options.escapeMap,
|
|
1809
1930
|
ignoreHead: true
|
|
@@ -1814,7 +1935,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1814
1935
|
if (token.expressions.length > 0) {
|
|
1815
1936
|
for (const exp of token.expressions) {
|
|
1816
1937
|
if (exp.start > token.start && p < exp.start) {
|
|
1817
|
-
ms.update(p, exp.start,
|
|
1938
|
+
ms.update(p, exp.start, replaceWxml(ms.slice(p, exp.start), {
|
|
1818
1939
|
keepEOL: true,
|
|
1819
1940
|
escapeMap: options.escapeMap,
|
|
1820
1941
|
// 首的str才会被转译
|
|
@@ -1827,14 +1948,14 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1827
1948
|
p = exp.end;
|
|
1828
1949
|
}
|
|
1829
1950
|
if (token.end > p) {
|
|
1830
|
-
ms.update(p, token.end,
|
|
1951
|
+
ms.update(p, token.end, replaceWxml(ms.slice(p, token.end), {
|
|
1831
1952
|
keepEOL: false,
|
|
1832
1953
|
escapeMap: options.escapeMap,
|
|
1833
1954
|
ignoreHead: true
|
|
1834
1955
|
}));
|
|
1835
1956
|
}
|
|
1836
1957
|
} else {
|
|
1837
|
-
ms.update(token.start, token.end,
|
|
1958
|
+
ms.update(token.start, token.end, replaceWxml(token.value, {
|
|
1838
1959
|
keepEOL: false,
|
|
1839
1960
|
escapeMap: options.escapeMap,
|
|
1840
1961
|
ignoreHead: false
|
|
@@ -1847,7 +1968,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1847
1968
|
if (lastToken.end < ms.original.length) {
|
|
1848
1969
|
const gap = ms.slice(lastToken.end, ms.original.length);
|
|
1849
1970
|
if (isAllWhitespace(gap)) {
|
|
1850
|
-
ms.update(lastToken.end, ms.original.length,
|
|
1971
|
+
ms.update(lastToken.end, ms.original.length, replaceWxml(gap, {
|
|
1851
1972
|
keepEOL: false,
|
|
1852
1973
|
escapeMap: options.escapeMap,
|
|
1853
1974
|
ignoreHead: true
|
|
@@ -1886,7 +2007,7 @@ async function customTemplateHandler(rawSource, options) {
|
|
|
1886
2007
|
}
|
|
1887
2008
|
const lowerName = name.toLowerCase();
|
|
1888
2009
|
const shouldHandleDefault = !disabledDefaultTemplateHandler && (lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass");
|
|
1889
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall',
|
|
2010
|
+
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _42 => _42(tag, name)]), () => ( false));
|
|
1890
2011
|
if (!shouldHandleDefault && !shouldHandleCustom) {
|
|
1891
2012
|
return;
|
|
1892
2013
|
}
|
|
@@ -2077,26 +2198,38 @@ function ensureDefaultsIncluded(value) {
|
|
|
2077
2198
|
}
|
|
2078
2199
|
return value;
|
|
2079
2200
|
}
|
|
2080
|
-
async function clearTailwindcssPatcherCache(patcher) {
|
|
2201
|
+
async function clearTailwindcssPatcherCache(patcher, options) {
|
|
2081
2202
|
if (!patcher) {
|
|
2082
2203
|
return;
|
|
2083
2204
|
}
|
|
2084
|
-
const cacheOptions = _optionalChain([patcher, 'access',
|
|
2085
|
-
if (
|
|
2205
|
+
const cacheOptions = _optionalChain([patcher, 'access', _43 => _43.options, 'optionalAccess', _44 => _44.cache]);
|
|
2206
|
+
if (cacheOptions == null || cacheOptions === false || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
|
|
2086
2207
|
return;
|
|
2087
2208
|
}
|
|
2088
|
-
const
|
|
2089
|
-
|
|
2209
|
+
const cachePaths = /* @__PURE__ */ new Map();
|
|
2210
|
+
const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
|
|
2211
|
+
if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _45 => _45.path])) {
|
|
2212
|
+
cachePaths.set(normalizedCacheOptions.path, false);
|
|
2213
|
+
}
|
|
2214
|
+
if (_optionalChain([patcher, 'access', _46 => _46.cacheStore, 'optionalAccess', _47 => _47.options, 'optionalAccess', _48 => _48.path])) {
|
|
2215
|
+
cachePaths.set(patcher.cacheStore.options.path, false);
|
|
2216
|
+
}
|
|
2217
|
+
if (_optionalChain([options, 'optionalAccess', _49 => _49.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _50 => _50.dir])) {
|
|
2218
|
+
cachePaths.set(normalizedCacheOptions.dir, true);
|
|
2219
|
+
}
|
|
2220
|
+
if (!cachePaths.size) {
|
|
2090
2221
|
return;
|
|
2091
2222
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2223
|
+
for (const [cachePath, recursive] of cachePaths.entries()) {
|
|
2224
|
+
try {
|
|
2225
|
+
await _promises.rm.call(void 0, cachePath, { force: true, recursive });
|
|
2226
|
+
} catch (error) {
|
|
2227
|
+
const err = error;
|
|
2228
|
+
if (_optionalChain([err, 'optionalAccess', _51 => _51.code]) === "ENOENT") {
|
|
2229
|
+
continue;
|
|
2230
|
+
}
|
|
2231
|
+
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
2098
2232
|
}
|
|
2099
|
-
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
2100
2233
|
}
|
|
2101
2234
|
}
|
|
2102
2235
|
function getCompilerContext(opts) {
|
|
@@ -2107,12 +2240,14 @@ function getCompilerContext(opts) {
|
|
|
2107
2240
|
);
|
|
2108
2241
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
2109
2242
|
applyLoggerLevel(ctx.logLevel);
|
|
2110
|
-
const twPatcher =
|
|
2111
|
-
|
|
2243
|
+
const twPatcher = _chunkVLM4KUZAjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
2244
|
+
logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
|
|
2245
|
+
if (_optionalChain([twPatcher, 'access', _52 => _52.packageInfo, 'optionalAccess', _53 => _53.version])) {
|
|
2112
2246
|
_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)))}`);
|
|
2113
2247
|
} else {
|
|
2114
2248
|
_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`);
|
|
2115
2249
|
}
|
|
2250
|
+
warnIfCliPatchTargetMismatch(ctx.tailwindcssBasedir, twPatcher);
|
|
2116
2251
|
let cssCalcOptions = _nullishCoalesce(ctx.cssCalc, () => ( twPatcher.majorVersion === 4));
|
|
2117
2252
|
if (twPatcher.majorVersion === 4 && cssCalcOptions) {
|
|
2118
2253
|
cssCalcOptions = ensureDefaultsIncluded(cssCalcOptions);
|
|
@@ -2131,11 +2266,11 @@ function getCompilerContext(opts) {
|
|
|
2131
2266
|
ctx.twPatcher = twPatcher;
|
|
2132
2267
|
const refreshTailwindcssPatcher = async (options) => {
|
|
2133
2268
|
const previousPatcher = ctx.twPatcher;
|
|
2134
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2269
|
+
if (_optionalChain([options, 'optionalAccess', _54 => _54.clearCache]) !== false) {
|
|
2135
2270
|
await clearTailwindcssPatcherCache(previousPatcher);
|
|
2136
2271
|
}
|
|
2137
2272
|
invalidateRuntimeClassSet(previousPatcher);
|
|
2138
|
-
const nextPatcher =
|
|
2273
|
+
const nextPatcher = _chunkVLM4KUZAjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
2139
2274
|
Object.assign(previousPatcher, nextPatcher);
|
|
2140
2275
|
ctx.twPatcher = previousPatcher;
|
|
2141
2276
|
return previousPatcher;
|
|
@@ -2160,4 +2295,8 @@ function getCompilerContext(opts) {
|
|
|
2160
2295
|
|
|
2161
2296
|
|
|
2162
2297
|
|
|
2163
|
-
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
|
|
2301
|
+
|
|
2302
|
+
exports.createDebug = createDebug; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.logTailwindcssTarget = logTailwindcssTarget; exports.saveCliPatchTargetRecord = saveCliPatchTargetRecord; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION; exports.replaceWxml = replaceWxml; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.clearTailwindcssPatcherCache = clearTailwindcssPatcherCache; exports.getCompilerContext = getCompilerContext;
|