weapp-tailwindcss 4.11.0-alpha.1 → 4.11.0-alpha.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-35EI5JMK.mjs → chunk-23K4XDKF.mjs} +3 -1
- package/dist/{chunk-W2EMGF7H.js → chunk-2W24MRCQ.js} +10 -12
- package/dist/chunk-4AFQP74Z.js +24 -0
- package/dist/{chunk-SQG2MOFQ.js → chunk-4TTPYMVM.js} +12 -8
- package/dist/{chunk-4LPOQMFS.js → chunk-5KSBT6GU.js} +396 -219
- package/dist/{chunk-LD7LZ4IK.mjs → chunk-66E76FQE.mjs} +91 -50
- package/dist/{chunk-GWDHNCL2.js → chunk-6O7HJU2F.js} +123 -42
- package/dist/{chunk-RRHPTTCP.mjs → chunk-76S2EME4.mjs} +2 -0
- package/dist/{chunk-G3G437UE.js → chunk-7LKMJZD2.js} +2 -2
- package/dist/{chunk-OV7FX6XR.js → chunk-CRDOWYG4.js} +1 -1
- package/dist/{chunk-DOH7FULQ.mjs → chunk-EFBQ4SQR.mjs} +1 -1
- package/dist/{chunk-IEZ5RBMG.mjs → chunk-EW2K6CO5.mjs} +365 -188
- package/dist/{chunk-FZNYV7VH.mjs → chunk-HADJCWHU.mjs} +212 -258
- package/dist/{chunk-CZLXTEHN.js → chunk-K7CZXT46.js} +132 -91
- package/dist/{chunk-ACTJYB33.js → chunk-LL3QUKJI.js} +3 -1
- package/dist/{chunk-G5NLM3AL.js → chunk-LYGLQCWI.js} +278 -324
- package/dist/{chunk-LTJQUORK.js → chunk-OF6MFURR.js} +2 -0
- package/dist/{chunk-KKT2DKMW.mjs → chunk-RED7Y22U.mjs} +91 -10
- package/dist/{chunk-R6KEYO3F.mjs → chunk-SJ3SG6DU.mjs} +5 -1
- package/dist/{chunk-JBM3HGHP.mjs → chunk-UCUAXK7F.mjs} +4 -6
- package/dist/cli.js +1006 -147
- package/dist/cli.mjs +942 -107
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +9 -11
- package/dist/core.mjs +6 -8
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +3 -3
- package/dist/css-macro.mjs +4 -4
- package/dist/defaults.d.mts +2 -2
- package/dist/defaults.d.ts +2 -2
- package/dist/defaults.js +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/gulp.d.mts +2 -2
- package/dist/gulp.d.ts +2 -2
- package/dist/gulp.js +7 -8
- package/dist/gulp.mjs +6 -7
- package/dist/{index-t_VBjwYm.d.ts → index-BMwzhITq.d.mts} +6 -6
- package/dist/{index-t_VBjwYm.d.mts → index-BMwzhITq.d.ts} +6 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -12
- package/dist/index.mjs +9 -10
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.d.mts +2 -2
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +8 -9
- package/dist/vite.mjs +6 -7
- package/dist/weapp-tw-css-import-rewrite-loader.js +3 -1
- package/dist/weapp-tw-runtime-classset-loader.js +29 -2
- package/dist/webpack.d.mts +2 -2
- package/dist/webpack.d.ts +2 -2
- package/dist/webpack.js +9 -10
- package/dist/webpack.mjs +7 -8
- package/dist/webpack4.d.mts +2 -2
- package/dist/webpack4.d.ts +2 -2
- package/dist/webpack4.js +41 -41
- package/dist/webpack4.mjs +12 -12
- package/package.json +8 -8
- package/dist/chunk-NOKJXG3W.js +0 -29
- package/dist/chunk-QYZCRG7F.mjs +0 -29
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var _chunk4LPOQMFSjs = require('./chunk-4LPOQMFS.js');
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk5KSBT6GUjs = require('./chunk-5KSBT6GU.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkLL3QUKJIjs = require('./chunk-LL3QUKJI.js');
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
|
|
@@ -29,78 +33,12 @@ function createDebug(prefix) {
|
|
|
29
33
|
return debug3;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
// src/tailwindcss/runtime/cache.ts
|
|
33
|
-
var _fs = require('fs');
|
|
34
|
-
var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
35
|
-
var runtimeConfigSignatureCache = /* @__PURE__ */ new Map();
|
|
36
|
-
var runtimeConfigSignatureCacheClearTimer;
|
|
37
|
-
function getCacheEntry(twPatcher) {
|
|
38
|
-
let entry = runtimeClassSetCache.get(twPatcher);
|
|
39
|
-
if (!entry) {
|
|
40
|
-
entry = {};
|
|
41
|
-
runtimeClassSetCache.set(twPatcher, entry);
|
|
42
|
-
}
|
|
43
|
-
return entry;
|
|
44
|
-
}
|
|
45
|
-
function scheduleRuntimeConfigSignatureCacheClear() {
|
|
46
|
-
if (runtimeConfigSignatureCacheClearTimer) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
runtimeConfigSignatureCacheClearTimer = setTimeout(() => {
|
|
50
|
-
runtimeConfigSignatureCache.clear();
|
|
51
|
-
runtimeConfigSignatureCacheClearTimer = void 0;
|
|
52
|
-
}, 0);
|
|
53
|
-
_optionalChain([runtimeConfigSignatureCacheClearTimer, 'access', _2 => _2.unref, 'optionalCall', _3 => _3()]);
|
|
54
|
-
}
|
|
55
|
-
function getTailwindConfigSignature(twPatcher) {
|
|
56
|
-
const configPath = _optionalChain([twPatcher, 'access', _4 => _4.options, 'optionalAccess', _5 => _5.tailwind, 'optionalAccess', _6 => _6.config]);
|
|
57
|
-
if (typeof configPath !== "string" || configPath.length === 0) {
|
|
58
|
-
return void 0;
|
|
59
|
-
}
|
|
60
|
-
const cached = runtimeConfigSignatureCache.get(configPath);
|
|
61
|
-
if (cached !== void 0) {
|
|
62
|
-
return cached;
|
|
63
|
-
}
|
|
64
|
-
let signature;
|
|
65
|
-
try {
|
|
66
|
-
const stats = _fs.statSync.call(void 0, configPath);
|
|
67
|
-
signature = `${configPath}:${stats.size}:${stats.mtimeMs}`;
|
|
68
|
-
} catch (e2) {
|
|
69
|
-
signature = `${configPath}:missing`;
|
|
70
|
-
}
|
|
71
|
-
runtimeConfigSignatureCache.set(configPath, signature);
|
|
72
|
-
scheduleRuntimeConfigSignatureCacheClear();
|
|
73
|
-
return signature;
|
|
74
|
-
}
|
|
75
|
-
function getPatchTargetSignature(twPatcher) {
|
|
76
|
-
const packageInfo = twPatcher.packageInfo;
|
|
77
|
-
return `${_nullishCoalesce(_optionalChain([packageInfo, 'optionalAccess', _7 => _7.rootPath]), () => ( "missing"))}:${_nullishCoalesce(_optionalChain([packageInfo, 'optionalAccess', _8 => _8.version]), () => ( "unknown"))}:${_nullishCoalesce(twPatcher.majorVersion, () => ( "unknown"))}`;
|
|
78
|
-
}
|
|
79
|
-
function invalidateRuntimeClassSet(twPatcher) {
|
|
80
|
-
if (!twPatcher) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const configPath = _optionalChain([twPatcher, 'access', _9 => _9.options, 'optionalAccess', _10 => _10.tailwind, 'optionalAccess', _11 => _11.config]);
|
|
84
|
-
if (typeof configPath === "string" && configPath.length > 0) {
|
|
85
|
-
runtimeConfigSignatureCache.delete(configPath);
|
|
86
|
-
}
|
|
87
|
-
runtimeClassSetCache.delete(twPatcher);
|
|
88
|
-
}
|
|
89
|
-
function getRuntimeClassSetCacheEntry(twPatcher) {
|
|
90
|
-
return getCacheEntry(twPatcher);
|
|
91
|
-
}
|
|
92
|
-
function getRuntimeClassSetSignature(twPatcher) {
|
|
93
|
-
const configSignature = _nullishCoalesce(getTailwindConfigSignature(twPatcher), () => ( "config:missing"));
|
|
94
|
-
const patchTargetSignature = getPatchTargetSignature(twPatcher);
|
|
95
|
-
return `${configSignature}|patch:${patchTargetSignature}`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
36
|
// src/tailwindcss/runtime.ts
|
|
99
37
|
var debug = createDebug("[tailwindcss:runtime] ");
|
|
100
38
|
var refreshTailwindcssPatcherSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
|
|
101
39
|
function createTailwindPatchPromise(twPatcher, onPatched) {
|
|
102
40
|
return Promise.resolve(twPatcher.patch()).then(async () => {
|
|
103
|
-
invalidateRuntimeClassSet(twPatcher);
|
|
41
|
+
_chunk5KSBT6GUjs.invalidateRuntimeClassSet.call(void 0, twPatcher);
|
|
104
42
|
if (onPatched) {
|
|
105
43
|
try {
|
|
106
44
|
await onPatched();
|
|
@@ -126,6 +64,7 @@ async function refreshTailwindRuntimeState(state, forceOrOptions) {
|
|
|
126
64
|
if (!force) {
|
|
127
65
|
return false;
|
|
128
66
|
}
|
|
67
|
+
debug("refresh runtime state start, clearCache=%s major=%s", clearCache, _nullishCoalesce(state.twPatcher.majorVersion, () => ( "unknown")));
|
|
129
68
|
await state.patchPromise;
|
|
130
69
|
let refreshed = false;
|
|
131
70
|
if (typeof state.refreshTailwindcssPatcher === "function") {
|
|
@@ -138,6 +77,7 @@ async function refreshTailwindRuntimeState(state, forceOrOptions) {
|
|
|
138
77
|
if (refreshed) {
|
|
139
78
|
state.patchPromise = createTailwindPatchPromise(state.twPatcher, state.onPatchCompleted);
|
|
140
79
|
}
|
|
80
|
+
debug("refresh runtime state end, refreshed=%s major=%s", refreshed, _nullishCoalesce(state.twPatcher.majorVersion, () => ( "unknown")));
|
|
141
81
|
return refreshed;
|
|
142
82
|
}
|
|
143
83
|
async function ensureRuntimeClassSet(state, options = {}) {
|
|
@@ -153,7 +93,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
153
93
|
}
|
|
154
94
|
await state.patchPromise;
|
|
155
95
|
const entry = getRuntimeClassSetStateEntry(state);
|
|
156
|
-
const signature = getRuntimeClassSetSignature(state.twPatcher);
|
|
96
|
+
const signature = _chunk5KSBT6GUjs.getRuntimeClassSetSignature.call(void 0, state.twPatcher);
|
|
157
97
|
const signatureChanged = entry.signature !== signature;
|
|
158
98
|
const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
|
|
159
99
|
if (!shouldForceCollect) {
|
|
@@ -188,7 +128,7 @@ async function ensureRuntimeClassSet(state, options = {}) {
|
|
|
188
128
|
try {
|
|
189
129
|
const runtimeSet = await task;
|
|
190
130
|
entry.value = runtimeSet;
|
|
191
|
-
entry.signature = getRuntimeClassSetSignature(state.twPatcher);
|
|
131
|
+
entry.signature = _chunk5KSBT6GUjs.getRuntimeClassSetSignature.call(void 0, state.twPatcher);
|
|
192
132
|
return runtimeSet;
|
|
193
133
|
} finally {
|
|
194
134
|
if (entry.promise === task) {
|
|
@@ -245,8 +185,8 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
245
185
|
}
|
|
246
186
|
}
|
|
247
187
|
}
|
|
248
|
-
const entry = getRuntimeClassSetCacheEntry(activePatcher);
|
|
249
|
-
const signature = getRuntimeClassSetSignature(activePatcher);
|
|
188
|
+
const entry = _chunk5KSBT6GUjs.getRuntimeClassSetCacheEntry.call(void 0, activePatcher);
|
|
189
|
+
const signature = _chunk5KSBT6GUjs.getRuntimeClassSetSignature.call(void 0, activePatcher);
|
|
250
190
|
if (!options.force) {
|
|
251
191
|
if (entry.value && entry.signature === signature) {
|
|
252
192
|
return entry.value;
|
|
@@ -265,7 +205,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
265
205
|
const preferExtract = options.force === true;
|
|
266
206
|
try {
|
|
267
207
|
const result = await activePatcher.extract({ write: false });
|
|
268
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
208
|
+
if (_optionalChain([result, 'optionalAccess', _2 => _2.classSet])) {
|
|
269
209
|
if (result.classSet.size > 0) {
|
|
270
210
|
debug("runtime class set resolved via extract(), size=%d", result.classSet.size);
|
|
271
211
|
return result.classSet;
|
|
@@ -313,10 +253,176 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
313
253
|
}
|
|
314
254
|
}
|
|
315
255
|
|
|
256
|
+
// src/context/index.ts
|
|
257
|
+
var _promises = require('fs/promises');
|
|
258
|
+
var _logger = require('@weapp-tailwindcss/logger');
|
|
259
|
+
|
|
260
|
+
// src/cache/index.ts
|
|
261
|
+
var _lrucache = require('lru-cache');
|
|
262
|
+
|
|
263
|
+
// src/cache/md5.ts
|
|
264
|
+
var _node = require('@weapp-tailwindcss/shared/node');
|
|
265
|
+
|
|
266
|
+
// src/cache/index.ts
|
|
267
|
+
function isProcessResult(value) {
|
|
268
|
+
return typeof value === "object" && value !== null && "result" in value;
|
|
269
|
+
}
|
|
270
|
+
function createCache(options) {
|
|
271
|
+
const disabled = options === false;
|
|
272
|
+
const hashMap = /* @__PURE__ */ new Map();
|
|
273
|
+
const instance = new (0, _lrucache.LRUCache)({
|
|
274
|
+
// 可能会添加和删除一些页面和组件, 先设定 1024 吧
|
|
275
|
+
max: 1024,
|
|
276
|
+
ttl: 0,
|
|
277
|
+
ttlAutopurge: false
|
|
278
|
+
});
|
|
279
|
+
const cache = {
|
|
280
|
+
hashMap,
|
|
281
|
+
instance,
|
|
282
|
+
hasHashKey(key) {
|
|
283
|
+
return hashMap.has(key);
|
|
284
|
+
},
|
|
285
|
+
getHashValue(key) {
|
|
286
|
+
return hashMap.get(key);
|
|
287
|
+
},
|
|
288
|
+
setHashValue(key, value) {
|
|
289
|
+
return hashMap.set(key, value);
|
|
290
|
+
},
|
|
291
|
+
get(key) {
|
|
292
|
+
return instance.get(key);
|
|
293
|
+
},
|
|
294
|
+
set(key, value) {
|
|
295
|
+
return instance.set(key, value);
|
|
296
|
+
},
|
|
297
|
+
computeHash(message) {
|
|
298
|
+
return _node.md5.call(void 0, message);
|
|
299
|
+
},
|
|
300
|
+
calcHashValueChanged(key, hash) {
|
|
301
|
+
const hit = hashMap.get(key);
|
|
302
|
+
if (hit) {
|
|
303
|
+
hashMap.set(key, {
|
|
304
|
+
changed: hash !== hit.hash,
|
|
305
|
+
hash
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
hashMap.set(key, {
|
|
309
|
+
changed: true,
|
|
310
|
+
hash
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return cache;
|
|
314
|
+
},
|
|
315
|
+
has(key) {
|
|
316
|
+
return instance.has(key);
|
|
317
|
+
},
|
|
318
|
+
async process({
|
|
319
|
+
key,
|
|
320
|
+
hashKey,
|
|
321
|
+
rawSource,
|
|
322
|
+
hash,
|
|
323
|
+
resolveCache,
|
|
324
|
+
transform,
|
|
325
|
+
onCacheHit
|
|
326
|
+
}) {
|
|
327
|
+
if (disabled) {
|
|
328
|
+
const value2 = await transform();
|
|
329
|
+
return isProcessResult(value2) ? value2.result : value2;
|
|
330
|
+
}
|
|
331
|
+
const cacheHashKey = _nullishCoalesce(hashKey, () => ( key));
|
|
332
|
+
let hasChanged = true;
|
|
333
|
+
if (hash != null || rawSource != null) {
|
|
334
|
+
const nextHash = _nullishCoalesce(hash, () => ( cache.computeHash(rawSource)));
|
|
335
|
+
cache.calcHashValueChanged(cacheHashKey, nextHash);
|
|
336
|
+
const entry = cache.getHashValue(cacheHashKey);
|
|
337
|
+
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _3 => _3.changed]), () => ( true));
|
|
338
|
+
}
|
|
339
|
+
const readCache = _nullishCoalesce(resolveCache, () => ( (() => cache.get(key))));
|
|
340
|
+
if (!hasChanged) {
|
|
341
|
+
const cached = readCache();
|
|
342
|
+
if (cached !== void 0) {
|
|
343
|
+
await _optionalChain([onCacheHit, 'optionalCall', _4 => _4(cached)]);
|
|
344
|
+
return cached;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const value = await transform();
|
|
348
|
+
const normalized = isProcessResult(value) ? value : { result: value };
|
|
349
|
+
const stored = _nullishCoalesce(normalized.cacheValue, () => ( normalized.result));
|
|
350
|
+
cache.set(key, stored);
|
|
351
|
+
return normalized.result;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
return cache;
|
|
355
|
+
}
|
|
356
|
+
function initializeCache(cacheConfig) {
|
|
357
|
+
if (typeof cacheConfig === "boolean" || cacheConfig === void 0) {
|
|
358
|
+
return createCache(cacheConfig);
|
|
359
|
+
}
|
|
360
|
+
return cacheConfig;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// src/tailwindcss/targets.ts
|
|
364
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
// src/tailwindcss/targets/paths.ts
|
|
368
|
+
var _fs = require('fs');
|
|
369
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
370
|
+
var PATCH_INFO_FILENAME = "tailwindcss-target.json";
|
|
371
|
+
var PATCH_INFO_CACHE_RELATIVE_PATH = _path2.default.join("node_modules", ".cache", "weapp-tailwindcss", PATCH_INFO_FILENAME);
|
|
372
|
+
var PATCH_INFO_LEGACY_RELATIVE_PATH = _path2.default.join(".tw-patch", PATCH_INFO_FILENAME);
|
|
373
|
+
function formatRelativeToBase(targetPath, baseDir) {
|
|
374
|
+
if (!baseDir) {
|
|
375
|
+
return _path2.default.normalize(targetPath);
|
|
376
|
+
}
|
|
377
|
+
const relative = _path2.default.relative(baseDir, targetPath);
|
|
378
|
+
if (!relative || relative === ".") {
|
|
379
|
+
return ".";
|
|
380
|
+
}
|
|
381
|
+
if (relative.startsWith("..")) {
|
|
382
|
+
return _path2.default.normalize(targetPath);
|
|
383
|
+
}
|
|
384
|
+
return _path2.default.join(".", relative);
|
|
385
|
+
}
|
|
386
|
+
function resolveRecordLocation(baseDir) {
|
|
387
|
+
const normalizedBase = _path2.default.normalize(baseDir);
|
|
388
|
+
const packageRoot = _nullishCoalesce(_chunk5KSBT6GUjs.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
|
|
389
|
+
const packageJsonPath = _path2.default.join(packageRoot, "package.json");
|
|
390
|
+
const hasPackageJson = _fs.existsSync.call(void 0, packageJsonPath);
|
|
391
|
+
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
392
|
+
const recordKey = _node.md5.call(void 0, _path2.default.normalize(recordKeySource));
|
|
393
|
+
const recordDir = _path2.default.join(packageRoot, "node_modules", ".cache", "weapp-tailwindcss", recordKey);
|
|
394
|
+
const recordPath = _path2.default.join(recordDir, PATCH_INFO_FILENAME);
|
|
395
|
+
return {
|
|
396
|
+
normalizedBase,
|
|
397
|
+
packageRoot,
|
|
398
|
+
recordDir,
|
|
399
|
+
recordKey,
|
|
400
|
+
recordPath,
|
|
401
|
+
packageJsonPath: hasPackageJson ? packageJsonPath : void 0
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function getRecordFileCandidates(baseDir) {
|
|
405
|
+
const { normalizedBase, packageRoot, recordPath } = resolveRecordLocation(baseDir);
|
|
406
|
+
const candidates = /* @__PURE__ */ new Set([
|
|
407
|
+
recordPath,
|
|
408
|
+
_path2.default.join(packageRoot, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
409
|
+
_path2.default.join(normalizedBase, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
410
|
+
_path2.default.join(normalizedBase, PATCH_INFO_LEGACY_RELATIVE_PATH)
|
|
411
|
+
]);
|
|
412
|
+
return [...candidates];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// src/tailwindcss/targets/record-io.ts
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
316
422
|
// package.json
|
|
317
423
|
var package_default = {
|
|
318
424
|
name: "weapp-tailwindcss",
|
|
319
|
-
version: "4.11.0-alpha.
|
|
425
|
+
version: "4.11.0-alpha.2",
|
|
320
426
|
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!",
|
|
321
427
|
author: "ice breaker <1324318532@qq.com>",
|
|
322
428
|
license: "MIT",
|
|
@@ -472,7 +578,7 @@ var package_default = {
|
|
|
472
578
|
"with-layer.css"
|
|
473
579
|
],
|
|
474
580
|
engines: {
|
|
475
|
-
node: "^
|
|
581
|
+
node: "^18.17.0 || >=20.5.0"
|
|
476
582
|
},
|
|
477
583
|
scripts: {
|
|
478
584
|
dev: "tsup --watch --sourcemap",
|
|
@@ -508,7 +614,7 @@ var package_default = {
|
|
|
508
614
|
},
|
|
509
615
|
dependencies: {
|
|
510
616
|
"@ast-core/escape": "~1.0.1",
|
|
511
|
-
"@babel/parser": "~7.29.
|
|
617
|
+
"@babel/parser": "~7.29.2",
|
|
512
618
|
"@babel/traverse": "~7.29.0",
|
|
513
619
|
"@babel/types": "~7.29.0",
|
|
514
620
|
"@tailwindcss-mangle/config": "^6.1.3",
|
|
@@ -519,7 +625,7 @@ var package_default = {
|
|
|
519
625
|
"@weapp-tailwindcss/logger": "workspace:*",
|
|
520
626
|
"@weapp-tailwindcss/postcss": "workspace:*",
|
|
521
627
|
"@weapp-tailwindcss/shared": "workspace:*",
|
|
522
|
-
cac: "
|
|
628
|
+
cac: "6.7.14",
|
|
523
629
|
debug: "~4.4.3",
|
|
524
630
|
"fast-glob": "^3.3.3",
|
|
525
631
|
htmlparser2: "10.1.0",
|
|
@@ -530,14 +636,13 @@ var package_default = {
|
|
|
530
636
|
semver: "~7.7.4",
|
|
531
637
|
"tailwindcss-patch": "catalog:tailwindcssPatch",
|
|
532
638
|
"webpack-sources": "3.3.4",
|
|
533
|
-
yaml: "^2.8.
|
|
639
|
+
yaml: "^2.8.3"
|
|
534
640
|
}
|
|
535
641
|
};
|
|
536
642
|
|
|
537
643
|
// src/constants.ts
|
|
538
644
|
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
539
645
|
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
540
|
-
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
541
646
|
var WEAPP_TW_VERSION = package_default.version;
|
|
542
647
|
var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
543
648
|
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
@@ -545,171 +650,7 @@ var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
|
545
650
|
"tailwind-variants": "@weapp-tailwindcss/variants"
|
|
546
651
|
};
|
|
547
652
|
|
|
548
|
-
// src/context/index.ts
|
|
549
|
-
var _promises = require('fs/promises');
|
|
550
|
-
var _logger = require('@weapp-tailwindcss/logger');
|
|
551
|
-
|
|
552
|
-
// src/cache/index.ts
|
|
553
|
-
var _lrucache = require('lru-cache');
|
|
554
|
-
|
|
555
|
-
// src/cache/md5.ts
|
|
556
|
-
var _node = require('@weapp-tailwindcss/shared/node');
|
|
557
|
-
|
|
558
|
-
// src/cache/index.ts
|
|
559
|
-
function isProcessResult(value) {
|
|
560
|
-
return typeof value === "object" && value !== null && "result" in value;
|
|
561
|
-
}
|
|
562
|
-
function createCache(options) {
|
|
563
|
-
const disabled = options === false;
|
|
564
|
-
const hashMap = /* @__PURE__ */ new Map();
|
|
565
|
-
const instance = new (0, _lrucache.LRUCache)({
|
|
566
|
-
// 可能会添加和删除一些页面和组件, 先设定 1024 吧
|
|
567
|
-
max: 1024,
|
|
568
|
-
ttl: 0,
|
|
569
|
-
ttlAutopurge: false
|
|
570
|
-
});
|
|
571
|
-
const cache = {
|
|
572
|
-
hashMap,
|
|
573
|
-
instance,
|
|
574
|
-
hasHashKey(key) {
|
|
575
|
-
return hashMap.has(key);
|
|
576
|
-
},
|
|
577
|
-
getHashValue(key) {
|
|
578
|
-
return hashMap.get(key);
|
|
579
|
-
},
|
|
580
|
-
setHashValue(key, value) {
|
|
581
|
-
return hashMap.set(key, value);
|
|
582
|
-
},
|
|
583
|
-
get(key) {
|
|
584
|
-
return instance.get(key);
|
|
585
|
-
},
|
|
586
|
-
set(key, value) {
|
|
587
|
-
return instance.set(key, value);
|
|
588
|
-
},
|
|
589
|
-
computeHash(message) {
|
|
590
|
-
return _node.md5.call(void 0, message);
|
|
591
|
-
},
|
|
592
|
-
calcHashValueChanged(key, hash) {
|
|
593
|
-
const hit = hashMap.get(key);
|
|
594
|
-
if (hit) {
|
|
595
|
-
hashMap.set(key, {
|
|
596
|
-
changed: hash !== hit.hash,
|
|
597
|
-
hash
|
|
598
|
-
});
|
|
599
|
-
} else {
|
|
600
|
-
hashMap.set(key, {
|
|
601
|
-
changed: true,
|
|
602
|
-
hash
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
return cache;
|
|
606
|
-
},
|
|
607
|
-
has(key) {
|
|
608
|
-
return instance.has(key);
|
|
609
|
-
},
|
|
610
|
-
async process({
|
|
611
|
-
key,
|
|
612
|
-
hashKey,
|
|
613
|
-
rawSource,
|
|
614
|
-
hash,
|
|
615
|
-
resolveCache,
|
|
616
|
-
transform,
|
|
617
|
-
onCacheHit
|
|
618
|
-
}) {
|
|
619
|
-
if (disabled) {
|
|
620
|
-
const value2 = await transform();
|
|
621
|
-
return isProcessResult(value2) ? value2.result : value2;
|
|
622
|
-
}
|
|
623
|
-
const cacheHashKey = _nullishCoalesce(hashKey, () => ( key));
|
|
624
|
-
let hasChanged = true;
|
|
625
|
-
if (hash != null || rawSource != null) {
|
|
626
|
-
const nextHash = _nullishCoalesce(hash, () => ( cache.computeHash(rawSource)));
|
|
627
|
-
cache.calcHashValueChanged(cacheHashKey, nextHash);
|
|
628
|
-
const entry = cache.getHashValue(cacheHashKey);
|
|
629
|
-
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _13 => _13.changed]), () => ( true));
|
|
630
|
-
}
|
|
631
|
-
const readCache = _nullishCoalesce(resolveCache, () => ( (() => cache.get(key))));
|
|
632
|
-
if (!hasChanged) {
|
|
633
|
-
const cached = readCache();
|
|
634
|
-
if (cached !== void 0) {
|
|
635
|
-
await _optionalChain([onCacheHit, 'optionalCall', _14 => _14(cached)]);
|
|
636
|
-
return cached;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
const value = await transform();
|
|
640
|
-
const normalized = isProcessResult(value) ? value : { result: value };
|
|
641
|
-
const stored = _nullishCoalesce(normalized.cacheValue, () => ( normalized.result));
|
|
642
|
-
cache.set(key, stored);
|
|
643
|
-
return normalized.result;
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
return cache;
|
|
647
|
-
}
|
|
648
|
-
function initializeCache(cacheConfig) {
|
|
649
|
-
if (typeof cacheConfig === "boolean" || cacheConfig === void 0) {
|
|
650
|
-
return createCache(cacheConfig);
|
|
651
|
-
}
|
|
652
|
-
return cacheConfig;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// src/tailwindcss/targets.ts
|
|
656
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
// src/tailwindcss/targets/paths.ts
|
|
660
|
-
|
|
661
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
662
|
-
var PATCH_INFO_FILENAME = "tailwindcss-target.json";
|
|
663
|
-
var PATCH_INFO_CACHE_RELATIVE_PATH = _path2.default.join("node_modules", ".cache", "weapp-tailwindcss", PATCH_INFO_FILENAME);
|
|
664
|
-
var PATCH_INFO_LEGACY_RELATIVE_PATH = _path2.default.join(".tw-patch", PATCH_INFO_FILENAME);
|
|
665
|
-
function formatRelativeToBase(targetPath, baseDir) {
|
|
666
|
-
if (!baseDir) {
|
|
667
|
-
return _path2.default.normalize(targetPath);
|
|
668
|
-
}
|
|
669
|
-
const relative = _path2.default.relative(baseDir, targetPath);
|
|
670
|
-
if (!relative || relative === ".") {
|
|
671
|
-
return ".";
|
|
672
|
-
}
|
|
673
|
-
if (relative.startsWith("..")) {
|
|
674
|
-
return _path2.default.normalize(targetPath);
|
|
675
|
-
}
|
|
676
|
-
return _path2.default.join(".", relative);
|
|
677
|
-
}
|
|
678
|
-
function resolveRecordLocation(baseDir) {
|
|
679
|
-
const normalizedBase = _path2.default.normalize(baseDir);
|
|
680
|
-
const packageRoot = _nullishCoalesce(_chunk4LPOQMFSjs.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
|
|
681
|
-
const packageJsonPath = _path2.default.join(packageRoot, "package.json");
|
|
682
|
-
const hasPackageJson = _fs.existsSync.call(void 0, packageJsonPath);
|
|
683
|
-
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
684
|
-
const recordKey = _node.md5.call(void 0, _path2.default.normalize(recordKeySource));
|
|
685
|
-
const recordDir = _path2.default.join(packageRoot, "node_modules", ".cache", "weapp-tailwindcss", recordKey);
|
|
686
|
-
const recordPath = _path2.default.join(recordDir, PATCH_INFO_FILENAME);
|
|
687
|
-
return {
|
|
688
|
-
normalizedBase,
|
|
689
|
-
packageRoot,
|
|
690
|
-
recordDir,
|
|
691
|
-
recordKey,
|
|
692
|
-
recordPath,
|
|
693
|
-
packageJsonPath: hasPackageJson ? packageJsonPath : void 0
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
function getRecordFileCandidates(baseDir) {
|
|
697
|
-
const { normalizedBase, packageRoot, recordPath } = resolveRecordLocation(baseDir);
|
|
698
|
-
const candidates = /* @__PURE__ */ new Set([
|
|
699
|
-
recordPath,
|
|
700
|
-
_path2.default.join(packageRoot, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
701
|
-
_path2.default.join(normalizedBase, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
702
|
-
_path2.default.join(normalizedBase, PATCH_INFO_LEGACY_RELATIVE_PATH)
|
|
703
|
-
]);
|
|
704
|
-
return [...candidates];
|
|
705
|
-
}
|
|
706
|
-
|
|
707
653
|
// src/tailwindcss/targets/record-io.ts
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
654
|
var loggedInvalidPatchRecords = /* @__PURE__ */ new Set();
|
|
714
655
|
function warnInvalidPatchTargetRecord(baseDir, recordPath, reason) {
|
|
715
656
|
const normalizedPath = _path2.default.normalize(recordPath);
|
|
@@ -754,22 +695,22 @@ function readPatchTargetRecord(baseDir) {
|
|
|
754
695
|
return void 0;
|
|
755
696
|
}
|
|
756
697
|
async function saveCliPatchTargetRecord(baseDir, patcher, options) {
|
|
757
|
-
if (!baseDir || !_optionalChain([patcher, 'optionalAccess',
|
|
698
|
+
if (!baseDir || !_optionalChain([patcher, 'optionalAccess', _5 => _5.packageInfo, 'optionalAccess', _6 => _6.rootPath])) {
|
|
758
699
|
return void 0;
|
|
759
700
|
}
|
|
760
701
|
const normalizedBase = _path2.default.normalize(baseDir);
|
|
761
702
|
const location = resolveRecordLocation(normalizedBase);
|
|
762
|
-
const recordPath = _optionalChain([options, 'optionalAccess',
|
|
703
|
+
const recordPath = _optionalChain([options, 'optionalAccess', _7 => _7.recordPath]) ? _path2.default.normalize(options.recordPath) : location.recordPath;
|
|
763
704
|
const record = {
|
|
764
705
|
tailwindPackagePath: _path2.default.normalize(patcher.packageInfo.rootPath),
|
|
765
706
|
packageVersion: patcher.packageInfo.version,
|
|
766
707
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
767
|
-
source: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
708
|
+
source: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _8 => _8.source]), () => ( "cli")),
|
|
768
709
|
tailwindcssBasedir: normalizedBase,
|
|
769
|
-
cwd: _optionalChain([options, 'optionalAccess',
|
|
710
|
+
cwd: _optionalChain([options, 'optionalAccess', _9 => _9.cwd]) ? _path2.default.normalize(options.cwd) : normalizedBase,
|
|
770
711
|
patchVersion: WEAPP_TW_VERSION,
|
|
771
|
-
packageJsonPath: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
772
|
-
recordKey: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
712
|
+
packageJsonPath: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _10 => _10.packageJsonPath]), () => ( location.packageJsonPath)),
|
|
713
|
+
recordKey: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.recordKey]), () => ( location.recordKey))
|
|
773
714
|
};
|
|
774
715
|
try {
|
|
775
716
|
await _promises.mkdir.call(void 0, _path2.default.dirname(recordPath), { recursive: true });
|
|
@@ -810,7 +751,7 @@ function findPatchTargetRecord(baseDir) {
|
|
|
810
751
|
return void 0;
|
|
811
752
|
}
|
|
812
753
|
function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
813
|
-
if (!baseDir || !_optionalChain([patcher, 'optionalAccess',
|
|
754
|
+
if (!baseDir || !_optionalChain([patcher, 'optionalAccess', _12 => _12.packageInfo, 'optionalAccess', _13 => _13.rootPath]) || _optionalChain([options, 'optionalAccess', _14 => _14.recordTarget]) === false) {
|
|
814
755
|
return void 0;
|
|
815
756
|
}
|
|
816
757
|
const normalizedBase = _path2.default.normalize(baseDir);
|
|
@@ -828,13 +769,13 @@ function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
|
828
769
|
reason = "migrate";
|
|
829
770
|
} else if (!recorded.record.patchVersion || recorded.record.patchVersion !== WEAPP_TW_VERSION) {
|
|
830
771
|
reason = "stale";
|
|
831
|
-
} else if (_optionalChain([options, 'optionalAccess',
|
|
772
|
+
} else if (_optionalChain([options, 'optionalAccess', _15 => _15.cwd]) && recorded.record.cwd && _path2.default.normalize(recorded.record.cwd) !== _path2.default.normalize(options.cwd)) {
|
|
832
773
|
reason = "metadata";
|
|
833
|
-
} else if (!recorded.record.cwd && _optionalChain([options, 'optionalAccess',
|
|
774
|
+
} else if (!recorded.record.cwd && _optionalChain([options, 'optionalAccess', _16 => _16.cwd])) {
|
|
834
775
|
reason = "metadata";
|
|
835
776
|
}
|
|
836
777
|
}
|
|
837
|
-
const shouldPersist = _optionalChain([options, 'optionalAccess',
|
|
778
|
+
const shouldPersist = _optionalChain([options, 'optionalAccess', _17 => _17.alwaysRecord]) || !recorded || Boolean(reason);
|
|
838
779
|
if (!shouldPersist) {
|
|
839
780
|
return void 0;
|
|
840
781
|
}
|
|
@@ -854,8 +795,8 @@ function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
|
854
795
|
break;
|
|
855
796
|
}
|
|
856
797
|
const onPatched = async () => saveCliPatchTargetRecord(normalizedBase, patcher, {
|
|
857
|
-
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
858
|
-
source: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
798
|
+
cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.cwd]), () => ( normalizedBase)),
|
|
799
|
+
source: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _19 => _19.source]), () => ( "cli")),
|
|
859
800
|
recordPath: location.recordPath,
|
|
860
801
|
recordKey: location.recordKey,
|
|
861
802
|
packageJsonPath: location.packageJsonPath
|
|
@@ -870,9 +811,9 @@ function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
|
870
811
|
|
|
871
812
|
// src/tailwindcss/targets.ts
|
|
872
813
|
function logTailwindcssTarget(kind, patcher, baseDir) {
|
|
873
|
-
const packageInfo = _optionalChain([patcher, 'optionalAccess',
|
|
814
|
+
const packageInfo = _optionalChain([patcher, 'optionalAccess', _20 => _20.packageInfo]);
|
|
874
815
|
const label = kind === "cli" ? "weapp-tw patch" : "tailwindcss-patcher";
|
|
875
|
-
if (!_optionalChain([packageInfo, 'optionalAccess',
|
|
816
|
+
if (!_optionalChain([packageInfo, 'optionalAccess', _21 => _21.rootPath])) {
|
|
876
817
|
_logger.logger.warn(
|
|
877
818
|
"%s \u672A\u627E\u5230 Tailwind CSS \u4F9D\u8D56\uFF0C\u8BF7\u68C0\u67E5\u5728 %s \u662F\u5426\u5DF2\u5B89\u88C5 tailwindcss",
|
|
878
819
|
label,
|
|
@@ -916,7 +857,7 @@ function encodeTaggedValue(type, value) {
|
|
|
916
857
|
return record;
|
|
917
858
|
}
|
|
918
859
|
function hasExplicitOptionBasedir(opts) {
|
|
919
|
-
return typeof _optionalChain([opts, 'optionalAccess',
|
|
860
|
+
return typeof _optionalChain([opts, 'optionalAccess', _22 => _22.tailwindcssBasedir]) === "string" && opts.tailwindcssBasedir.length > 0;
|
|
920
861
|
}
|
|
921
862
|
function shouldProbeCallerLocation(opts) {
|
|
922
863
|
if (hasExplicitOptionBasedir(opts)) {
|
|
@@ -932,7 +873,7 @@ function detectCallerLocation() {
|
|
|
932
873
|
const lines = stack.split("\n");
|
|
933
874
|
for (const line of lines) {
|
|
934
875
|
const match = _nullishCoalesce(line.match(PAREN_CONTENT_RE), () => ( line.match(AT_LOCATION_RE)));
|
|
935
|
-
const location = _optionalChain([match, 'optionalAccess',
|
|
876
|
+
const location = _optionalChain([match, 'optionalAccess', _23 => _23[1]]);
|
|
936
877
|
if (!location) {
|
|
937
878
|
continue;
|
|
938
879
|
}
|
|
@@ -1061,7 +1002,7 @@ function normalizeOptionsValue(rawValue, stack = /* @__PURE__ */ new WeakSet())
|
|
|
1061
1002
|
if (ArrayBuffer.isView(rawValue)) {
|
|
1062
1003
|
const view = rawValue;
|
|
1063
1004
|
const buffer = _buffer.Buffer.from(view.buffer, view.byteOffset, view.byteLength);
|
|
1064
|
-
return encodeTaggedValue(_nullishCoalesce(_optionalChain([view, 'access',
|
|
1005
|
+
return encodeTaggedValue(_nullishCoalesce(_optionalChain([view, 'access', _24 => _24.constructor, 'optionalAccess', _25 => _25.name]), () => ( "ArrayBufferView")), buffer.toString("base64"));
|
|
1065
1006
|
}
|
|
1066
1007
|
if (rawValue instanceof ArrayBuffer) {
|
|
1067
1008
|
return encodeTaggedValue("ArrayBuffer", _buffer.Buffer.from(rawValue).toString("base64"));
|
|
@@ -1225,7 +1166,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
1225
1166
|
}
|
|
1226
1167
|
}
|
|
1227
1168
|
if (exact) {
|
|
1228
|
-
const exactStringCount = _nullishCoalesce(_optionalChain([exactStrings, 'optionalAccess',
|
|
1169
|
+
const exactStringCount = _nullishCoalesce(_optionalChain([exactStrings, 'optionalAccess', _26 => _26.size]), () => ( 0));
|
|
1229
1170
|
if (exactStringCount === 1 && regexList.length === 0) {
|
|
1230
1171
|
const [needle] = exactStrings;
|
|
1231
1172
|
return (value) => value === needle;
|
|
@@ -1238,7 +1179,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
1238
1179
|
return (value) => regex.test(value);
|
|
1239
1180
|
}
|
|
1240
1181
|
return (value) => {
|
|
1241
|
-
if (_optionalChain([exactStrings, 'optionalAccess',
|
|
1182
|
+
if (_optionalChain([exactStrings, 'optionalAccess', _27 => _27.has, 'call', _28 => _28(value)])) {
|
|
1242
1183
|
return true;
|
|
1243
1184
|
}
|
|
1244
1185
|
return regexList.some((regex) => regex.test(value));
|
|
@@ -1254,7 +1195,7 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
1254
1195
|
return (value) => regex.test(value);
|
|
1255
1196
|
}
|
|
1256
1197
|
return (value) => {
|
|
1257
|
-
if (_optionalChain([fuzzyMatcher, 'optionalCall',
|
|
1198
|
+
if (_optionalChain([fuzzyMatcher, 'optionalCall', _29 => _29(value)])) {
|
|
1258
1199
|
return true;
|
|
1259
1200
|
}
|
|
1260
1201
|
if (!hasRegex) {
|
|
@@ -1410,10 +1351,10 @@ function resolveClassNameTransformWithResult(candidate, {
|
|
|
1410
1351
|
if (alwaysEscape) {
|
|
1411
1352
|
return DIRECT_RESULT;
|
|
1412
1353
|
}
|
|
1413
|
-
if (_optionalChain([jsPreserveClass, 'optionalCall',
|
|
1354
|
+
if (_optionalChain([jsPreserveClass, 'optionalCall', _30 => _30(candidate)])) {
|
|
1414
1355
|
return SKIP_RESULT;
|
|
1415
1356
|
}
|
|
1416
|
-
if (_optionalChain([classNameSet, 'optionalAccess',
|
|
1357
|
+
if (_optionalChain([classNameSet, 'optionalAccess', _31 => _31.has, 'call', _32 => _32(candidate)])) {
|
|
1417
1358
|
return DIRECT_RESULT;
|
|
1418
1359
|
}
|
|
1419
1360
|
if (classNameSet && classNameSet.size > 0) {
|
|
@@ -1517,7 +1458,7 @@ function readObjectKeyName(path5) {
|
|
|
1517
1458
|
return path5.node.value;
|
|
1518
1459
|
}
|
|
1519
1460
|
if (path5.isTemplateLiteral() && path5.node.expressions.length === 0) {
|
|
1520
|
-
return _nullishCoalesce(_optionalChain([path5, 'access',
|
|
1461
|
+
return _nullishCoalesce(_optionalChain([path5, 'access', _33 => _33.node, 'access', _34 => _34.quasis, 'access', _35 => _35[0], 'optionalAccess', _36 => _36.value, 'access', _37 => _37.cooked]), () => ( _optionalChain([path5, 'access', _38 => _38.node, 'access', _39 => _39.quasis, 'access', _40 => _40[0], 'optionalAccess', _41 => _41.value, 'access', _42 => _42.raw])));
|
|
1521
1462
|
}
|
|
1522
1463
|
return void 0;
|
|
1523
1464
|
}
|
|
@@ -1626,7 +1567,7 @@ function hasIgnoreComment(node) {
|
|
|
1626
1567
|
return false;
|
|
1627
1568
|
}
|
|
1628
1569
|
function extractLiteralValue(path5, { unescapeUnicode, arbitraryValues }) {
|
|
1629
|
-
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess',
|
|
1570
|
+
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _43 => _43.allowDoubleQuotes]);
|
|
1630
1571
|
const { node } = path5;
|
|
1631
1572
|
let offset = 0;
|
|
1632
1573
|
let original;
|
|
@@ -1765,15 +1706,15 @@ function replaceHandleValue(path5, options) {
|
|
|
1765
1706
|
if (debugEnabled) {
|
|
1766
1707
|
debug2(
|
|
1767
1708
|
"runtimeSet size=%d fallbackTriggered=%s candidates=%d matched=%d escapedHits=%d skipped=%d file=%s escapedSamples=%s skippedSamples=%s",
|
|
1768
|
-
_nullishCoalesce(_optionalChain([classNameSet, 'optionalAccess',
|
|
1709
|
+
_nullishCoalesce(_optionalChain([classNameSet, 'optionalAccess', _44 => _44.size]), () => ( 0)),
|
|
1769
1710
|
fallbackDecisionCount > 0,
|
|
1770
1711
|
candidates.length,
|
|
1771
1712
|
matchedCandidateCount,
|
|
1772
1713
|
escapedDecisionCount,
|
|
1773
|
-
_nullishCoalesce(_optionalChain([skippedSamples, 'optionalAccess',
|
|
1714
|
+
_nullishCoalesce(_optionalChain([skippedSamples, 'optionalAccess', _45 => _45.length]), () => ( 0)),
|
|
1774
1715
|
_nullishCoalesce(options.filename, () => ( "unknown")),
|
|
1775
|
-
_optionalChain([escapedSamples, 'optionalAccess',
|
|
1776
|
-
_optionalChain([skippedSamples, 'optionalAccess',
|
|
1716
|
+
_optionalChain([escapedSamples, 'optionalAccess', _46 => _46.join, 'call', _47 => _47(",")]) || "-",
|
|
1717
|
+
_optionalChain([skippedSamples, 'optionalAccess', _48 => _48.join, 'call', _49 => _49(",")]) || "-"
|
|
1777
1718
|
);
|
|
1778
1719
|
}
|
|
1779
1720
|
const start = node.start + offset;
|
|
@@ -2022,7 +1963,7 @@ function getEvalTemplateHandlerOptions(options) {
|
|
|
2022
1963
|
function walkEvalExpression(path5, options, updater, handler) {
|
|
2023
1964
|
const stringHandlerOptions = getEvalStringHandlerOptions(options);
|
|
2024
1965
|
const templateHandlerOptions = getEvalTemplateHandlerOptions(options);
|
|
2025
|
-
const maybeTraverse = _optionalChain([path5, 'optionalAccess',
|
|
1966
|
+
const maybeTraverse = _optionalChain([path5, 'optionalAccess', _50 => _50.traverse]);
|
|
2026
1967
|
if (typeof maybeTraverse === "function") {
|
|
2027
1968
|
try {
|
|
2028
1969
|
return maybeTraverse.call(path5, {
|
|
@@ -2034,21 +1975,21 @@ function walkEvalExpression(path5, options, updater, handler) {
|
|
|
2034
1975
|
}
|
|
2035
1976
|
});
|
|
2036
1977
|
} catch (error) {
|
|
2037
|
-
const msg = _nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
1978
|
+
const msg = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _51 => _51.message]), () => ( ""));
|
|
2038
1979
|
const scopeError = EVAL_SCOPE_ERROR_REGEXP.test(msg);
|
|
2039
1980
|
if (!scopeError) {
|
|
2040
1981
|
throw error;
|
|
2041
1982
|
}
|
|
2042
1983
|
}
|
|
2043
1984
|
}
|
|
2044
|
-
const getArgs = _optionalChain([path5, 'optionalAccess',
|
|
1985
|
+
const getArgs = _optionalChain([path5, 'optionalAccess', _52 => _52.get, 'optionalCall', _53 => _53("arguments")]);
|
|
2045
1986
|
if (Array.isArray(getArgs)) {
|
|
2046
1987
|
for (const arg of getArgs) {
|
|
2047
|
-
if (_optionalChain([arg, 'optionalAccess',
|
|
1988
|
+
if (_optionalChain([arg, 'optionalAccess', _54 => _54.isStringLiteral, 'optionalCall', _55 => _55()])) {
|
|
2048
1989
|
handleEvalStringLiteral(arg, stringHandlerOptions, updater, handler);
|
|
2049
1990
|
continue;
|
|
2050
1991
|
}
|
|
2051
|
-
if (_optionalChain([arg, 'optionalAccess',
|
|
1992
|
+
if (_optionalChain([arg, 'optionalAccess', _56 => _56.isTemplateLiteral, 'optionalCall', _57 => _57()])) {
|
|
2052
1993
|
for (const quasi of arg.get("quasis")) {
|
|
2053
1994
|
handleEvalTemplateElement(quasi, templateHandlerOptions, updater, handler);
|
|
2054
1995
|
}
|
|
@@ -2056,16 +1997,16 @@ function walkEvalExpression(path5, options, updater, handler) {
|
|
|
2056
1997
|
}
|
|
2057
1998
|
return;
|
|
2058
1999
|
}
|
|
2059
|
-
const nodeArgs = _optionalChain([path5, 'optionalAccess',
|
|
2000
|
+
const nodeArgs = _optionalChain([path5, 'optionalAccess', _58 => _58.node, 'optionalAccess', _59 => _59.arguments]);
|
|
2060
2001
|
if (Array.isArray(nodeArgs)) {
|
|
2061
2002
|
for (const n of nodeArgs) {
|
|
2062
|
-
if (_optionalChain([n, 'optionalAccess',
|
|
2003
|
+
if (_optionalChain([n, 'optionalAccess', _60 => _60.type]) === "StringLiteral") {
|
|
2063
2004
|
const stub = {
|
|
2064
2005
|
node: n,
|
|
2065
2006
|
isStringLiteral: () => true
|
|
2066
2007
|
};
|
|
2067
2008
|
handleEvalStringLiteral(stub, stringHandlerOptions, updater, handler);
|
|
2068
|
-
} else if (_optionalChain([n, 'optionalAccess',
|
|
2009
|
+
} else if (_optionalChain([n, 'optionalAccess', _61 => _61.type]) === "TemplateLiteral" && Array.isArray(n.quasis)) {
|
|
2069
2010
|
for (const q of n.quasis) {
|
|
2070
2011
|
const stub = {
|
|
2071
2012
|
node: q,
|
|
@@ -2167,7 +2108,7 @@ var IgnoredExportsTracker = class {
|
|
|
2167
2108
|
continue;
|
|
2168
2109
|
}
|
|
2169
2110
|
if (exportPath.isExportNamedDeclaration()) {
|
|
2170
|
-
const source = _optionalChain([exportPath, 'access',
|
|
2111
|
+
const source = _optionalChain([exportPath, 'access', _62 => _62.node, 'access', _63 => _63.source, 'optionalAccess', _64 => _64.value]);
|
|
2171
2112
|
if (typeof source === "string") {
|
|
2172
2113
|
for (const spec of exportPath.get("specifiers")) {
|
|
2173
2114
|
if (!spec.isExportSpecifier()) {
|
|
@@ -2234,7 +2175,7 @@ var IgnoredExportsTracker = class {
|
|
|
2234
2175
|
continue;
|
|
2235
2176
|
}
|
|
2236
2177
|
if (exportPath.isExportAllDeclaration()) {
|
|
2237
|
-
const source = _optionalChain([exportPath, 'access',
|
|
2178
|
+
const source = _optionalChain([exportPath, 'access', _65 => _65.node, 'access', _66 => _66.source, 'optionalAccess', _67 => _67.value]);
|
|
2238
2179
|
if (typeof source === "string") {
|
|
2239
2180
|
for (const exportName of names) {
|
|
2240
2181
|
propagate.push({
|
|
@@ -2250,7 +2191,7 @@ var IgnoredExportsTracker = class {
|
|
|
2250
2191
|
let resolved;
|
|
2251
2192
|
try {
|
|
2252
2193
|
resolved = this.options.resolve(specifier, filename);
|
|
2253
|
-
} catch (
|
|
2194
|
+
} catch (e2) {
|
|
2254
2195
|
resolved = void 0;
|
|
2255
2196
|
}
|
|
2256
2197
|
if (!resolved) {
|
|
@@ -2338,7 +2279,7 @@ var JsModuleGraph = class {
|
|
|
2338
2279
|
}
|
|
2339
2280
|
for (const exportPath of state.analysis.exportDeclarations) {
|
|
2340
2281
|
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
2341
|
-
const source = _optionalChain([exportPath, 'access',
|
|
2282
|
+
const source = _optionalChain([exportPath, 'access', _68 => _68.node, 'access', _69 => _69.source, 'optionalAccess', _70 => _70.value]);
|
|
2342
2283
|
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
2343
2284
|
dependencySpecifiers.set(source, []);
|
|
2344
2285
|
}
|
|
@@ -2348,7 +2289,7 @@ var JsModuleGraph = class {
|
|
|
2348
2289
|
let resolved;
|
|
2349
2290
|
try {
|
|
2350
2291
|
resolved = this.resolve(specifier, filename);
|
|
2351
|
-
} catch (
|
|
2292
|
+
} catch (e3) {
|
|
2352
2293
|
continue;
|
|
2353
2294
|
}
|
|
2354
2295
|
if (!resolved) {
|
|
@@ -2366,7 +2307,7 @@ var JsModuleGraph = class {
|
|
|
2366
2307
|
let source;
|
|
2367
2308
|
try {
|
|
2368
2309
|
source = this.load(resolved);
|
|
2369
|
-
} catch (
|
|
2310
|
+
} catch (e4) {
|
|
2370
2311
|
continue;
|
|
2371
2312
|
}
|
|
2372
2313
|
if (typeof source !== "string") {
|
|
@@ -2383,7 +2324,7 @@ var JsModuleGraph = class {
|
|
|
2383
2324
|
filename: resolved
|
|
2384
2325
|
});
|
|
2385
2326
|
this.ignoredExports.applyIgnoredExportsToAnalysis(resolved, analysis);
|
|
2386
|
-
} catch (
|
|
2327
|
+
} catch (e5) {
|
|
2387
2328
|
continue;
|
|
2388
2329
|
}
|
|
2389
2330
|
this.modules.set(resolved, {
|
|
@@ -2566,14 +2507,14 @@ var NodePathWalker = class {
|
|
|
2566
2507
|
}
|
|
2567
2508
|
visited.add(arg);
|
|
2568
2509
|
if (arg.isIdentifier()) {
|
|
2569
|
-
const binding = _optionalChain([arg, 'optionalAccess',
|
|
2510
|
+
const binding = _optionalChain([arg, 'optionalAccess', _71 => _71.scope, 'optionalAccess', _72 => _72.getBinding, 'optionalCall', _73 => _73(arg.node.name)]);
|
|
2570
2511
|
if (binding) {
|
|
2571
2512
|
this.walkNode(binding.path);
|
|
2572
2513
|
}
|
|
2573
2514
|
} else if (arg.isMemberExpression()) {
|
|
2574
2515
|
const objectPath = arg.get("object");
|
|
2575
2516
|
if (objectPath.isIdentifier()) {
|
|
2576
|
-
const binding = _optionalChain([arg, 'optionalAccess',
|
|
2517
|
+
const binding = _optionalChain([arg, 'optionalAccess', _74 => _74.scope, 'optionalAccess', _75 => _75.getBinding, 'optionalCall', _76 => _76(objectPath.node.name)]);
|
|
2577
2518
|
if (binding) {
|
|
2578
2519
|
if (binding.path.isVariableDeclarator()) {
|
|
2579
2520
|
this.walkVariableDeclarator(binding.path);
|
|
@@ -2681,8 +2622,8 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2681
2622
|
}
|
|
2682
2623
|
const objectPath = path5.get("object");
|
|
2683
2624
|
if (objectPath.isIdentifier()) {
|
|
2684
|
-
const scope = _optionalChain([objectPath, 'optionalAccess',
|
|
2685
|
-
const binding = _optionalChain([scope, 'optionalAccess',
|
|
2625
|
+
const scope = _optionalChain([objectPath, 'optionalAccess', _77 => _77.scope]);
|
|
2626
|
+
const binding = _optionalChain([scope, 'optionalAccess', _78 => _78.getBinding, 'optionalCall', _79 => _79(objectPath.node.name)]);
|
|
2686
2627
|
if (binding) {
|
|
2687
2628
|
return resolvesToWeappTwIgnore(binding, seen);
|
|
2688
2629
|
}
|
|
@@ -2711,7 +2652,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2711
2652
|
const init = bindingPath.get("init");
|
|
2712
2653
|
if (init && init.node) {
|
|
2713
2654
|
if (init.isIdentifier()) {
|
|
2714
|
-
const target = _optionalChain([binding, 'optionalAccess',
|
|
2655
|
+
const target = _optionalChain([binding, 'optionalAccess', _80 => _80.scope, 'optionalAccess', _81 => _81.getBinding, 'optionalCall', _82 => _82(init.node.name)]);
|
|
2715
2656
|
if (target) {
|
|
2716
2657
|
result = resolvesToWeappTwIgnore(target, seen);
|
|
2717
2658
|
}
|
|
@@ -2727,7 +2668,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2727
2668
|
const getEffectiveTagPath = (tagPath) => {
|
|
2728
2669
|
let current = tagPath;
|
|
2729
2670
|
while (true) {
|
|
2730
|
-
if (_optionalChain([current, 'access',
|
|
2671
|
+
if (_optionalChain([current, 'access', _83 => _83.isParenthesizedExpression, 'optionalCall', _84 => _84()]) || current.node.type === "ParenthesizedExpression") {
|
|
2731
2672
|
current = current.get("expression");
|
|
2732
2673
|
continue;
|
|
2733
2674
|
}
|
|
@@ -2739,7 +2680,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2739
2680
|
current = current.get("expression");
|
|
2740
2681
|
continue;
|
|
2741
2682
|
}
|
|
2742
|
-
if (_optionalChain([current, 'access',
|
|
2683
|
+
if (_optionalChain([current, 'access', _85 => _85.isTypeCastExpression, 'optionalCall', _86 => _86()])) {
|
|
2743
2684
|
current = current.get("expression");
|
|
2744
2685
|
continue;
|
|
2745
2686
|
}
|
|
@@ -2751,7 +2692,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2751
2692
|
continue;
|
|
2752
2693
|
}
|
|
2753
2694
|
}
|
|
2754
|
-
if (_optionalChain([current, 'access',
|
|
2695
|
+
if (_optionalChain([current, 'access', _87 => _87.isCallExpression, 'optionalCall', _88 => _88()]) || current.node.type === "CallExpression") {
|
|
2755
2696
|
const callee = current.get("callee");
|
|
2756
2697
|
current = callee;
|
|
2757
2698
|
continue;
|
|
@@ -2761,7 +2702,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2761
2702
|
return current;
|
|
2762
2703
|
};
|
|
2763
2704
|
const evaluateTagPath = (tagPath, seen) => {
|
|
2764
|
-
if (_optionalChain([tagPath, 'access',
|
|
2705
|
+
if (_optionalChain([tagPath, 'access', _89 => _89.isCallExpression, 'optionalCall', _90 => _90()]) || tagPath.node.type === "CallExpression") {
|
|
2765
2706
|
const calleePath = tagPath.get("callee");
|
|
2766
2707
|
return evaluateTagPath(calleePath, seen);
|
|
2767
2708
|
}
|
|
@@ -2769,7 +2710,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
2769
2710
|
if (matchesIgnoreName(tagPath.node.name)) {
|
|
2770
2711
|
return true;
|
|
2771
2712
|
}
|
|
2772
|
-
const binding = _optionalChain([tagPath, 'optionalAccess',
|
|
2713
|
+
const binding = _optionalChain([tagPath, 'optionalAccess', _91 => _91.scope, 'optionalAccess', _92 => _92.getBinding, 'optionalCall', _93 => _93(tagPath.node.name)]);
|
|
2773
2714
|
if (binding) {
|
|
2774
2715
|
return resolvesToWeappTwIgnore(binding, seen);
|
|
2775
2716
|
}
|
|
@@ -2885,11 +2826,11 @@ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
|
|
|
2885
2826
|
return;
|
|
2886
2827
|
}
|
|
2887
2828
|
const calleePath = p.get("callee");
|
|
2888
|
-
if (collectModuleMetadata && calleePath.isIdentifier({ name: "require" }) && !_optionalChain([p, 'optionalAccess',
|
|
2829
|
+
if (collectModuleMetadata && calleePath.isIdentifier({ name: "require" }) && !_optionalChain([p, 'optionalAccess', _94 => _94.scope, 'optionalAccess', _95 => _95.hasBinding, 'optionalCall', _96 => _96("require")])) {
|
|
2889
2830
|
const args = p.get("arguments");
|
|
2890
2831
|
if (Array.isArray(args) && args.length > 0) {
|
|
2891
2832
|
const first = args[0];
|
|
2892
|
-
if (_optionalChain([first, 'optionalAccess',
|
|
2833
|
+
if (_optionalChain([first, 'optionalAccess', _97 => _97.isStringLiteral, 'call', _98 => _98()])) {
|
|
2893
2834
|
requireCallPaths.push(first);
|
|
2894
2835
|
}
|
|
2895
2836
|
}
|
|
@@ -3063,7 +3004,7 @@ function createJsHandler(options) {
|
|
|
3063
3004
|
return void 0;
|
|
3064
3005
|
}
|
|
3065
3006
|
const cache = resultCache.get(resolvedOptions);
|
|
3066
|
-
return _optionalChain([cache, 'optionalAccess',
|
|
3007
|
+
return _optionalChain([cache, 'optionalAccess', _99 => _99.get, 'call', _100 => _100(rawSource)]);
|
|
3067
3008
|
}
|
|
3068
3009
|
function setCachedJsResult(rawSource, resolvedOptions, result) {
|
|
3069
3010
|
if (!shouldCacheJsResult(rawSource, resolvedOptions) || result.error || result.linked) {
|
|
@@ -3211,7 +3152,7 @@ function shouldSkipLegacyStringLiteral(path5) {
|
|
|
3211
3152
|
return true;
|
|
3212
3153
|
}
|
|
3213
3154
|
return Boolean(
|
|
3214
|
-
t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access',
|
|
3155
|
+
t.isBinaryExpression(path5.parent) && (t.isConditionalExpression(_optionalChain([path5, 'access', _101 => _101.parentPath, 'optionalAccess', _102 => _102.parent])) || t.isLogicalExpression(_optionalChain([path5, 'access', _103 => _103.parentPath, 'optionalAccess', _104 => _104.parent])))
|
|
3215
3156
|
);
|
|
3216
3157
|
}
|
|
3217
3158
|
function createLegacyTraverseOptions(options, jsTokenUpdater) {
|
|
@@ -3271,7 +3212,7 @@ function generateCode(match, options = {}) {
|
|
|
3271
3212
|
} else {
|
|
3272
3213
|
return rewriteLegacyExpression(match, options);
|
|
3273
3214
|
}
|
|
3274
|
-
} catch (
|
|
3215
|
+
} catch (e6) {
|
|
3275
3216
|
return match;
|
|
3276
3217
|
}
|
|
3277
3218
|
}
|
|
@@ -3553,7 +3494,7 @@ async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
|
3553
3494
|
return;
|
|
3554
3495
|
}
|
|
3555
3496
|
const shouldHandleDefault = defaultTemplateHandlerEnabled && isDefaultTemplateAttribute(name);
|
|
3556
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall',
|
|
3497
|
+
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _105 => _105(tag, name)]), () => ( false));
|
|
3557
3498
|
if (!shouldHandleDefault && !shouldHandleCustom) {
|
|
3558
3499
|
return;
|
|
3559
3500
|
}
|
|
@@ -3593,7 +3534,7 @@ async function customTemplateHandler(rawSource, options, cachedMatcher) {
|
|
|
3593
3534
|
getMagicString().update(startIndex, endIndex, code);
|
|
3594
3535
|
}
|
|
3595
3536
|
}
|
|
3596
|
-
return _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
3537
|
+
return _nullishCoalesce(_optionalChain([s, 'optionalAccess', _106 => _106.toString, 'call', _107 => _107()]), () => ( rawSource));
|
|
3597
3538
|
}
|
|
3598
3539
|
|
|
3599
3540
|
// src/wxml/utils.ts
|
|
@@ -3605,7 +3546,7 @@ function createTemplateHandler(options = {}) {
|
|
|
3605
3546
|
let cachedRuntimeSet;
|
|
3606
3547
|
let cachedOptionsWithRuntimeSet;
|
|
3607
3548
|
return (rawSource, opt) => {
|
|
3608
|
-
const runtimeSet = _optionalChain([opt, 'optionalAccess',
|
|
3549
|
+
const runtimeSet = _optionalChain([opt, 'optionalAccess', _108 => _108.runtimeSet]);
|
|
3609
3550
|
if (runtimeSet === void 0) {
|
|
3610
3551
|
return customTemplateHandler(rawSource, defaultOptions, cachedMatcher);
|
|
3611
3552
|
}
|
|
@@ -3725,7 +3666,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3725
3666
|
if (!patcher) {
|
|
3726
3667
|
return;
|
|
3727
3668
|
}
|
|
3728
|
-
const cacheOptions = _optionalChain([patcher, 'access',
|
|
3669
|
+
const cacheOptions = _optionalChain([patcher, 'access', _109 => _109.options, 'optionalAccess', _110 => _110.cache]);
|
|
3729
3670
|
if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
|
|
3730
3671
|
return;
|
|
3731
3672
|
}
|
|
@@ -3736,19 +3677,19 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3736
3677
|
_logger.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
|
|
3737
3678
|
}
|
|
3738
3679
|
}
|
|
3739
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3680
|
+
if (!_optionalChain([options, 'optionalAccess', _111 => _111.removeDirectory])) {
|
|
3740
3681
|
return;
|
|
3741
3682
|
}
|
|
3742
3683
|
const cachePaths = /* @__PURE__ */ new Map();
|
|
3743
3684
|
const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
|
|
3744
|
-
if (_optionalChain([normalizedCacheOptions, 'optionalAccess',
|
|
3685
|
+
if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _112 => _112.path])) {
|
|
3745
3686
|
cachePaths.set(normalizedCacheOptions.path, false);
|
|
3746
3687
|
}
|
|
3747
|
-
const privateCachePath = _optionalChain([patcher, 'optionalAccess',
|
|
3688
|
+
const privateCachePath = _optionalChain([patcher, 'optionalAccess', _113 => _113.cacheStore, 'optionalAccess', _114 => _114.options, 'optionalAccess', _115 => _115.path]);
|
|
3748
3689
|
if (privateCachePath) {
|
|
3749
3690
|
cachePaths.set(privateCachePath, false);
|
|
3750
3691
|
}
|
|
3751
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3692
|
+
if (_optionalChain([options, 'optionalAccess', _116 => _116.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _117 => _117.dir])) {
|
|
3752
3693
|
cachePaths.set(normalizedCacheOptions.dir, true);
|
|
3753
3694
|
}
|
|
3754
3695
|
if (!cachePaths.size) {
|
|
@@ -3759,7 +3700,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3759
3700
|
await _promises.rm.call(void 0, cachePath, { force: true, recursive });
|
|
3760
3701
|
} catch (error) {
|
|
3761
3702
|
const err = error;
|
|
3762
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
3703
|
+
if (_optionalChain([err, 'optionalAccess', _118 => _118.code]) === "ENOENT") {
|
|
3763
3704
|
continue;
|
|
3764
3705
|
}
|
|
3765
3706
|
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
@@ -3769,20 +3710,20 @@ async function clearTailwindcssPatcherCache(patcher, options) {
|
|
|
3769
3710
|
function createInternalCompilerContext(opts) {
|
|
3770
3711
|
const ctx = _chunkDYLQ6UOIjs.defuOverrideArray.call(void 0,
|
|
3771
3712
|
opts,
|
|
3772
|
-
|
|
3713
|
+
_chunkLL3QUKJIjs.getDefaultOptions.call(void 0, ),
|
|
3773
3714
|
{}
|
|
3774
3715
|
);
|
|
3775
3716
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
3776
3717
|
applyLoggerLevel(ctx.logLevel);
|
|
3777
|
-
const twPatcher =
|
|
3718
|
+
const twPatcher = _chunk5KSBT6GUjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
3778
3719
|
logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
|
|
3779
|
-
if (_optionalChain([twPatcher, 'access',
|
|
3720
|
+
if (_optionalChain([twPatcher, 'access', _119 => _119.packageInfo, 'optionalAccess', _120 => _120.version])) {
|
|
3780
3721
|
_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)))}`);
|
|
3781
3722
|
} else {
|
|
3782
3723
|
_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`);
|
|
3783
3724
|
}
|
|
3784
|
-
|
|
3785
|
-
const cssCalcOptions =
|
|
3725
|
+
_chunk5KSBT6GUjs.warnMissingCssEntries.call(void 0, ctx, twPatcher);
|
|
3726
|
+
const cssCalcOptions = _chunk5KSBT6GUjs.applyV4CssCalcDefaults.call(void 0, ctx.cssCalc, twPatcher);
|
|
3786
3727
|
ctx.cssCalc = cssCalcOptions;
|
|
3787
3728
|
const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
|
|
3788
3729
|
const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
|
|
@@ -3798,11 +3739,11 @@ function createInternalCompilerContext(opts) {
|
|
|
3798
3739
|
ctx.twPatcher = twPatcher;
|
|
3799
3740
|
const refreshTailwindcssPatcher = async (options) => {
|
|
3800
3741
|
const previousPatcher = ctx.twPatcher;
|
|
3801
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3742
|
+
if (_optionalChain([options, 'optionalAccess', _121 => _121.clearCache]) !== false) {
|
|
3802
3743
|
await clearTailwindcssPatcherCache(previousPatcher);
|
|
3803
3744
|
}
|
|
3804
|
-
invalidateRuntimeClassSet(previousPatcher);
|
|
3805
|
-
const nextPatcher =
|
|
3745
|
+
_chunk5KSBT6GUjs.invalidateRuntimeClassSet.call(void 0, previousPatcher);
|
|
3746
|
+
const nextPatcher = _chunk5KSBT6GUjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
3806
3747
|
Object.assign(previousPatcher, nextPatcher);
|
|
3807
3748
|
ctx.twPatcher = previousPatcher;
|
|
3808
3749
|
return previousPatcher;
|
|
@@ -3818,6 +3759,23 @@ function getCompilerContext(opts) {
|
|
|
3818
3759
|
return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
|
|
3819
3760
|
}
|
|
3820
3761
|
|
|
3762
|
+
// src/tailwindcss/recorder.ts
|
|
3763
|
+
function setupPatchRecorder(patcher, baseDir, options) {
|
|
3764
|
+
const recorder = createPatchTargetRecorder(baseDir, patcher, options);
|
|
3765
|
+
if (_optionalChain([recorder, 'optionalAccess', _122 => _122.message]) && _optionalChain([options, 'optionalAccess', _123 => _123.logMessage]) !== false) {
|
|
3766
|
+
const prefix = _optionalChain([options, 'optionalAccess', _124 => _124.messagePrefix]) ? `${options.messagePrefix} ` : "";
|
|
3767
|
+
_chunk5KSBT6GUjs.logger.info("%s%s", prefix, recorder.message);
|
|
3768
|
+
}
|
|
3769
|
+
const onPatchCompleted = _optionalChain([recorder, 'optionalAccess', _125 => _125.onPatched]) ? async () => {
|
|
3770
|
+
await recorder.onPatched();
|
|
3771
|
+
} : void 0;
|
|
3772
|
+
const patchPromise = patcher ? createTailwindPatchPromise(patcher, onPatchCompleted) : Promise.resolve();
|
|
3773
|
+
return {
|
|
3774
|
+
recorder,
|
|
3775
|
+
patchPromise,
|
|
3776
|
+
onPatchCompleted
|
|
3777
|
+
};
|
|
3778
|
+
}
|
|
3821
3779
|
|
|
3822
3780
|
|
|
3823
3781
|
|
|
@@ -3834,8 +3792,4 @@ function getCompilerContext(opts) {
|
|
|
3834
3792
|
|
|
3835
3793
|
|
|
3836
3794
|
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
exports.createDebug = createDebug; exports.getRuntimeClassSetSignature = getRuntimeClassSetSignature; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.ensureRuntimeClassSet = ensureRuntimeClassSet; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION; exports.createPatchTargetRecorder = createPatchTargetRecorder; exports.logTailwindcssTarget = logTailwindcssTarget; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.traverse = traverse; exports.babelParse = babelParse; exports.replaceWxml = replaceWxml; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.clearTailwindcssPatcherCache = clearTailwindcssPatcherCache; exports.getCompilerContext = getCompilerContext;
|
|
3795
|
+
exports.createDebug = createDebug; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.ensureRuntimeClassSet = ensureRuntimeClassSet; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.traverse = traverse; exports.babelParse = babelParse; exports.replaceWxml = replaceWxml; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.getCompilerContext = getCompilerContext; exports.setupPatchRecorder = setupPatchRecorder;
|