weapp-tailwindcss 4.7.5 → 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-E5LRICST.js → chunk-2WZP7EXP.js} +280 -165
- package/dist/{chunk-PUFKPENL.mjs → chunk-APVOYXRF.mjs} +6 -15
- package/dist/{chunk-42FXROX4.mjs → chunk-FZNEB7RC.mjs} +2 -2
- package/dist/{chunk-XEQBYGBX.mjs → chunk-KGKHHXRC.mjs} +252 -137
- package/dist/{chunk-RLWIDWTA.js → chunk-MGHX7SCL.js} +15 -24
- package/dist/{chunk-R7GWRQDJ.js → chunk-MMBZHHNL.js} +1 -1
- package/dist/{chunk-SCOGAO45.mjs → chunk-MNKR7BNZ.mjs} +1 -1
- package/dist/{chunk-SJV6DCNZ.js → chunk-PP6KHC2I.js} +6 -6
- package/dist/{chunk-WXBFAARR.js → chunk-USAH2CX5.js} +1 -1
- package/dist/{chunk-GGD75A34.js → chunk-VLM4KUZA.js} +4 -4
- package/dist/{chunk-TK5LOBHZ.mjs → chunk-VPQLMV42.mjs} +1 -1
- package/dist/{chunk-24ADBRZN.js → chunk-X5SXNF7I.js} +10 -10
- package/dist/{chunk-KZJLIZIK.mjs → chunk-XVJBQIVY.mjs} +1 -1
- package/dist/cli.js +24 -13
- package/dist/cli.mjs +18 -7
- package/dist/core.js +10 -11
- package/dist/core.mjs +3 -4
- 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 +3 -3
- package/dist/defaults.mjs +2 -2
- 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 +6 -7
- package/dist/gulp.mjs +4 -5
- package/dist/index.js +8 -9
- package/dist/index.mjs +6 -7
- 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.d.mts +10 -11
- package/dist/types.d.ts +10 -11
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +6 -7
- package/dist/vite.mjs +4 -5
- package/dist/webpack.js +6 -7
- package/dist/webpack.mjs +4 -5
- package/dist/webpack4.js +13 -14
- package/dist/webpack4.mjs +3 -4
- package/package.json +7 -7
- package/dist/chunk-DWAEHRHN.js +0 -21
- package/dist/chunk-VSRDBMDB.mjs +0 -21
|
@@ -1,12 +1,9 @@
|
|
|
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
|
|
3
|
+
var _chunkVLM4KUZAjs = require('./chunk-VLM4KUZA.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkWXBFAARRjs = require('./chunk-WXBFAARR.js');
|
|
6
|
+
var _chunkUSAH2CX5js = require('./chunk-USAH2CX5.js');
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
|
|
@@ -109,26 +106,6 @@ function tryGetRuntimeClassSetSync(twPatcher) {
|
|
|
109
106
|
return void 0;
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
|
-
async function mergeContentTokensIntoSet(twPatcher, target) {
|
|
113
|
-
if (typeof twPatcher.collectContentTokens !== "function") {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
const report = await twPatcher.collectContentTokens();
|
|
118
|
-
const entries = _optionalChain([report, 'optionalAccess', _5 => _5.entries]);
|
|
119
|
-
if (!Array.isArray(entries)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
for (const entry of entries) {
|
|
123
|
-
const candidate = _optionalChain([entry, 'optionalAccess', _6 => _6.rawCandidate]);
|
|
124
|
-
if (typeof candidate === "string" && candidate.length > 0) {
|
|
125
|
-
target.add(candidate);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
} catch (error) {
|
|
129
|
-
debug("collectContentTokens() failed, continuing without merged tokens: %O", error);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
109
|
async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
133
110
|
let activePatcher = twPatcher;
|
|
134
111
|
if (options.force && !options.skipRefresh) {
|
|
@@ -146,7 +123,6 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
146
123
|
}
|
|
147
124
|
const entry = getCacheEntry(activePatcher);
|
|
148
125
|
const signature = getTailwindConfigSignature(activePatcher);
|
|
149
|
-
const shouldAugmentWithTokens = options.force || !entry.value;
|
|
150
126
|
if (!options.force) {
|
|
151
127
|
if (entry.value && entry.signature === signature) {
|
|
152
128
|
return entry.value;
|
|
@@ -164,7 +140,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
164
140
|
}
|
|
165
141
|
try {
|
|
166
142
|
const result = await activePatcher.extract({ write: false });
|
|
167
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
143
|
+
if (_optionalChain([result, 'optionalAccess', _5 => _5.classSet])) {
|
|
168
144
|
return result.classSet;
|
|
169
145
|
}
|
|
170
146
|
} catch (error) {
|
|
@@ -184,9 +160,6 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
184
160
|
entry.signature = signature;
|
|
185
161
|
try {
|
|
186
162
|
const resolved = await task;
|
|
187
|
-
if (shouldAugmentWithTokens) {
|
|
188
|
-
await mergeContentTokensIntoSet(activePatcher, resolved);
|
|
189
|
-
}
|
|
190
163
|
entry.value = resolved;
|
|
191
164
|
entry.promise = void 0;
|
|
192
165
|
entry.signature = signature;
|
|
@@ -197,6 +170,112 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
197
170
|
}
|
|
198
171
|
}
|
|
199
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
|
+
|
|
200
279
|
// src/constants.ts
|
|
201
280
|
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
202
281
|
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
@@ -208,8 +287,8 @@ var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
|
208
287
|
};
|
|
209
288
|
|
|
210
289
|
// src/context/index.ts
|
|
211
|
-
|
|
212
|
-
|
|
290
|
+
|
|
291
|
+
|
|
213
292
|
|
|
214
293
|
// src/cache/index.ts
|
|
215
294
|
var _lrucache = require('lru-cache');
|
|
@@ -288,13 +367,13 @@ function createCache(options) {
|
|
|
288
367
|
const nextHash = _nullishCoalesce(hash, () => ( cache.computeHash(rawSource)));
|
|
289
368
|
cache.calcHashValueChanged(cacheHashKey, nextHash);
|
|
290
369
|
const entry = cache.getHashValue(cacheHashKey);
|
|
291
|
-
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
370
|
+
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _12 => _12.changed]), () => ( true));
|
|
292
371
|
}
|
|
293
372
|
const readCache = _nullishCoalesce(resolveCache, () => ( (() => cache.get(key))));
|
|
294
373
|
if (!hasChanged) {
|
|
295
374
|
const cached = readCache();
|
|
296
375
|
if (cached !== void 0) {
|
|
297
|
-
await _optionalChain([onCacheHit, 'optionalCall',
|
|
376
|
+
await _optionalChain([onCacheHit, 'optionalCall', _13 => _13(cached)]);
|
|
298
377
|
return cached;
|
|
299
378
|
}
|
|
300
379
|
}
|
|
@@ -384,10 +463,10 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
384
463
|
const fuzzyMatcher = exact ? void 0 : buildFuzzyMatcher(fuzzyStrings);
|
|
385
464
|
const hasRegex = regexList.length > 0;
|
|
386
465
|
return (value) => {
|
|
387
|
-
if (exact && _optionalChain([exactStrings, 'optionalAccess',
|
|
466
|
+
if (exact && _optionalChain([exactStrings, 'optionalAccess', _14 => _14.has, 'call', _15 => _15(value)])) {
|
|
388
467
|
return true;
|
|
389
468
|
}
|
|
390
|
-
if (_optionalChain([fuzzyMatcher, 'optionalCall',
|
|
469
|
+
if (_optionalChain([fuzzyMatcher, 'optionalCall', _16 => _16(value)])) {
|
|
391
470
|
return true;
|
|
392
471
|
}
|
|
393
472
|
if (!hasRegex) {
|
|
@@ -399,22 +478,22 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
399
478
|
|
|
400
479
|
// src/js/evalTransforms.ts
|
|
401
480
|
var _escape = require('@ast-core/escape');
|
|
402
|
-
function isEvalPath(
|
|
403
|
-
if (
|
|
404
|
-
const calleePath =
|
|
481
|
+
function isEvalPath(path2) {
|
|
482
|
+
if (path2.isCallExpression()) {
|
|
483
|
+
const calleePath = path2.get("callee");
|
|
405
484
|
return calleePath.isIdentifier({ name: "eval" });
|
|
406
485
|
}
|
|
407
486
|
return false;
|
|
408
487
|
}
|
|
409
|
-
function createEvalReplacementToken(
|
|
410
|
-
const node =
|
|
488
|
+
function createEvalReplacementToken(path2, updated) {
|
|
489
|
+
const node = path2.node;
|
|
411
490
|
let offset = 0;
|
|
412
491
|
let original;
|
|
413
|
-
if (
|
|
492
|
+
if (path2.isStringLiteral()) {
|
|
414
493
|
offset = 1;
|
|
415
|
-
original =
|
|
416
|
-
} else if (
|
|
417
|
-
original =
|
|
494
|
+
original = path2.node.value;
|
|
495
|
+
} else if (path2.isTemplateElement()) {
|
|
496
|
+
original = path2.node.value.raw;
|
|
418
497
|
} else {
|
|
419
498
|
original = "";
|
|
420
499
|
}
|
|
@@ -429,16 +508,16 @@ function createEvalReplacementToken(path, updated) {
|
|
|
429
508
|
if (original === updated) {
|
|
430
509
|
return void 0;
|
|
431
510
|
}
|
|
432
|
-
const value =
|
|
511
|
+
const value = path2.isStringLiteral() ? _escape.jsStringEscape.call(void 0, updated) : updated;
|
|
433
512
|
return {
|
|
434
513
|
start,
|
|
435
514
|
end,
|
|
436
515
|
value,
|
|
437
|
-
path
|
|
516
|
+
path: path2
|
|
438
517
|
};
|
|
439
518
|
}
|
|
440
|
-
function handleEvalStringLiteral(
|
|
441
|
-
const { code } = handler(
|
|
519
|
+
function handleEvalStringLiteral(path2, options, updater, handler) {
|
|
520
|
+
const { code } = handler(path2.node.value, {
|
|
442
521
|
...options,
|
|
443
522
|
needEscaped: false,
|
|
444
523
|
generateMap: false
|
|
@@ -446,26 +525,26 @@ function handleEvalStringLiteral(path, options, updater, handler) {
|
|
|
446
525
|
if (!code) {
|
|
447
526
|
return;
|
|
448
527
|
}
|
|
449
|
-
const token = createEvalReplacementToken(
|
|
528
|
+
const token = createEvalReplacementToken(path2, code);
|
|
450
529
|
if (token) {
|
|
451
530
|
updater.addToken(token);
|
|
452
531
|
}
|
|
453
532
|
}
|
|
454
|
-
function handleEvalTemplateElement(
|
|
455
|
-
const { code } = handler(
|
|
533
|
+
function handleEvalTemplateElement(path2, options, updater, handler) {
|
|
534
|
+
const { code } = handler(path2.node.value.raw, {
|
|
456
535
|
...options,
|
|
457
536
|
generateMap: false
|
|
458
537
|
});
|
|
459
538
|
if (!code) {
|
|
460
539
|
return;
|
|
461
540
|
}
|
|
462
|
-
const token = createEvalReplacementToken(
|
|
541
|
+
const token = createEvalReplacementToken(path2, code);
|
|
463
542
|
if (token) {
|
|
464
543
|
updater.addToken(token);
|
|
465
544
|
}
|
|
466
545
|
}
|
|
467
|
-
function walkEvalExpression(
|
|
468
|
-
|
|
546
|
+
function walkEvalExpression(path2, options, updater, handler) {
|
|
547
|
+
path2.traverse({
|
|
469
548
|
StringLiteral(innerPath) {
|
|
470
549
|
handleEvalStringLiteral(innerPath, options, updater, handler);
|
|
471
550
|
},
|
|
@@ -503,6 +582,24 @@ function decodeUnicode2(input) {
|
|
|
503
582
|
}
|
|
504
583
|
}
|
|
505
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
|
+
|
|
506
603
|
// src/js/handlers.ts
|
|
507
604
|
var patternCache = /* @__PURE__ */ new Map();
|
|
508
605
|
var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -519,7 +616,7 @@ function getReplacement(candidate, escapeMap) {
|
|
|
519
616
|
if (!escapeMap) {
|
|
520
617
|
let cached2 = defaultReplacementCache.get(candidate);
|
|
521
618
|
if (cached2 === void 0) {
|
|
522
|
-
cached2 =
|
|
619
|
+
cached2 = replaceWxml(candidate, { escapeMap });
|
|
523
620
|
defaultReplacementCache.set(candidate, cached2);
|
|
524
621
|
}
|
|
525
622
|
return cached2;
|
|
@@ -531,7 +628,7 @@ function getReplacement(candidate, escapeMap) {
|
|
|
531
628
|
}
|
|
532
629
|
let cached = store.get(candidate);
|
|
533
630
|
if (cached === void 0) {
|
|
534
|
-
cached =
|
|
631
|
+
cached = replaceWxml(candidate, { escapeMap });
|
|
535
632
|
store.set(candidate, cached);
|
|
536
633
|
}
|
|
537
634
|
return cached;
|
|
@@ -553,17 +650,17 @@ function shouldTransformClassName(candidate, {
|
|
|
553
650
|
if (!classNameSet.has(candidate)) {
|
|
554
651
|
return false;
|
|
555
652
|
}
|
|
556
|
-
return !_optionalChain([jsPreserveClass, 'optionalCall',
|
|
653
|
+
return !_optionalChain([jsPreserveClass, 'optionalCall', _17 => _17(candidate)]);
|
|
557
654
|
}
|
|
558
|
-
function extractLiteralValue(
|
|
559
|
-
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess',
|
|
655
|
+
function extractLiteralValue(path2, { unescapeUnicode, arbitraryValues }) {
|
|
656
|
+
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _18 => _18.allowDoubleQuotes]);
|
|
560
657
|
let offset = 0;
|
|
561
658
|
let original;
|
|
562
|
-
if (
|
|
659
|
+
if (path2.isStringLiteral()) {
|
|
563
660
|
offset = 1;
|
|
564
|
-
original =
|
|
565
|
-
} else if (
|
|
566
|
-
original =
|
|
661
|
+
original = path2.node.value;
|
|
662
|
+
} else if (path2.isTemplateElement()) {
|
|
663
|
+
original = path2.node.value.raw;
|
|
567
664
|
} else {
|
|
568
665
|
original = "";
|
|
569
666
|
}
|
|
@@ -578,7 +675,7 @@ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
|
578
675
|
original
|
|
579
676
|
};
|
|
580
677
|
}
|
|
581
|
-
function replaceHandleValue(
|
|
678
|
+
function replaceHandleValue(path2, options) {
|
|
582
679
|
const {
|
|
583
680
|
escapeMap,
|
|
584
681
|
needEscaped = false
|
|
@@ -587,8 +684,8 @@ function replaceHandleValue(path, options) {
|
|
|
587
684
|
if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
|
|
588
685
|
return void 0;
|
|
589
686
|
}
|
|
590
|
-
const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(
|
|
591
|
-
if (hasIgnoreComment(
|
|
687
|
+
const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path2, options);
|
|
688
|
+
if (hasIgnoreComment(path2.node)) {
|
|
592
689
|
return void 0;
|
|
593
690
|
}
|
|
594
691
|
const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
|
|
@@ -612,7 +709,7 @@ function replaceHandleValue(path, options) {
|
|
|
612
709
|
mutated = true;
|
|
613
710
|
}
|
|
614
711
|
}
|
|
615
|
-
const node =
|
|
712
|
+
const node = path2.node;
|
|
616
713
|
if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") {
|
|
617
714
|
return void 0;
|
|
618
715
|
}
|
|
@@ -626,7 +723,7 @@ function replaceHandleValue(path, options) {
|
|
|
626
723
|
start,
|
|
627
724
|
end,
|
|
628
725
|
value,
|
|
629
|
-
path
|
|
726
|
+
path: path2
|
|
630
727
|
};
|
|
631
728
|
}
|
|
632
729
|
|
|
@@ -750,7 +847,7 @@ var JsModuleGraph = class {
|
|
|
750
847
|
continue;
|
|
751
848
|
}
|
|
752
849
|
if (exportPath.isExportNamedDeclaration()) {
|
|
753
|
-
const source = _optionalChain([exportPath, 'access',
|
|
850
|
+
const source = _optionalChain([exportPath, 'access', _19 => _19.node, 'access', _20 => _20.source, 'optionalAccess', _21 => _21.value]);
|
|
754
851
|
if (typeof source === "string") {
|
|
755
852
|
for (const spec of exportPath.get("specifiers")) {
|
|
756
853
|
if (!spec.isExportSpecifier()) {
|
|
@@ -817,7 +914,7 @@ var JsModuleGraph = class {
|
|
|
817
914
|
continue;
|
|
818
915
|
}
|
|
819
916
|
if (exportPath.isExportAllDeclaration()) {
|
|
820
|
-
const source = _optionalChain([exportPath, 'access',
|
|
917
|
+
const source = _optionalChain([exportPath, 'access', _22 => _22.node, 'access', _23 => _23.source, 'optionalAccess', _24 => _24.value]);
|
|
821
918
|
if (typeof source === "string") {
|
|
822
919
|
for (const exportName of names) {
|
|
823
920
|
propagate.push({
|
|
@@ -869,7 +966,7 @@ var JsModuleGraph = class {
|
|
|
869
966
|
}
|
|
870
967
|
for (const exportPath of state.analysis.exportDeclarations) {
|
|
871
968
|
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
872
|
-
const source = _optionalChain([exportPath, 'access',
|
|
969
|
+
const source = _optionalChain([exportPath, 'access', _25 => _25.node, 'access', _26 => _26.source, 'optionalAccess', _27 => _27.value]);
|
|
873
970
|
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
874
971
|
dependencySpecifiers.set(source, []);
|
|
875
972
|
}
|
|
@@ -938,35 +1035,35 @@ var NodePathWalker = class {
|
|
|
938
1035
|
this.visited = /* @__PURE__ */ new WeakSet();
|
|
939
1036
|
this.isIgnoredCallIdentifier = createNameMatcher(this.ignoreCallExpressionIdentifiers, { exact: true });
|
|
940
1037
|
}
|
|
941
|
-
walkVariableDeclarator(
|
|
942
|
-
const init =
|
|
1038
|
+
walkVariableDeclarator(path2) {
|
|
1039
|
+
const init = path2.get("init");
|
|
943
1040
|
this.walkNode(init);
|
|
944
1041
|
}
|
|
945
|
-
walkTemplateLiteral(
|
|
946
|
-
for (const exp of
|
|
1042
|
+
walkTemplateLiteral(path2) {
|
|
1043
|
+
for (const exp of path2.get("expressions")) {
|
|
947
1044
|
this.walkNode(exp);
|
|
948
1045
|
}
|
|
949
|
-
for (const quasis of
|
|
1046
|
+
for (const quasis of path2.get("quasis")) {
|
|
950
1047
|
this.callback(quasis);
|
|
951
1048
|
}
|
|
952
1049
|
}
|
|
953
|
-
walkStringLiteral(
|
|
954
|
-
this.callback(
|
|
1050
|
+
walkStringLiteral(path2) {
|
|
1051
|
+
this.callback(path2);
|
|
955
1052
|
}
|
|
956
|
-
walkBinaryExpression(
|
|
957
|
-
const left =
|
|
1053
|
+
walkBinaryExpression(path2) {
|
|
1054
|
+
const left = path2.get("left");
|
|
958
1055
|
this.walkNode(left);
|
|
959
|
-
const right =
|
|
1056
|
+
const right = path2.get("right");
|
|
960
1057
|
this.walkNode(right);
|
|
961
1058
|
}
|
|
962
|
-
walkLogicalExpression(
|
|
963
|
-
const left =
|
|
1059
|
+
walkLogicalExpression(path2) {
|
|
1060
|
+
const left = path2.get("left");
|
|
964
1061
|
this.walkNode(left);
|
|
965
|
-
const right =
|
|
1062
|
+
const right = path2.get("right");
|
|
966
1063
|
this.walkNode(right);
|
|
967
1064
|
}
|
|
968
|
-
walkObjectExpression(
|
|
969
|
-
const props =
|
|
1065
|
+
walkObjectExpression(path2) {
|
|
1066
|
+
const props = path2.get("properties");
|
|
970
1067
|
for (const prop of props) {
|
|
971
1068
|
if (prop.isObjectProperty()) {
|
|
972
1069
|
const key = prop.get("key");
|
|
@@ -976,8 +1073,8 @@ var NodePathWalker = class {
|
|
|
976
1073
|
}
|
|
977
1074
|
}
|
|
978
1075
|
}
|
|
979
|
-
walkArrayExpression(
|
|
980
|
-
const elements =
|
|
1076
|
+
walkArrayExpression(path2) {
|
|
1077
|
+
const elements = path2.get("elements");
|
|
981
1078
|
for (const element of elements) {
|
|
982
1079
|
this.walkNode(element);
|
|
983
1080
|
}
|
|
@@ -1050,33 +1147,33 @@ var NodePathWalker = class {
|
|
|
1050
1147
|
/**
|
|
1051
1148
|
* Walk the arguments of a desired call expression so their bindings can be analysed.
|
|
1052
1149
|
*/
|
|
1053
|
-
walkCallExpression(
|
|
1054
|
-
const calleePath =
|
|
1150
|
+
walkCallExpression(path2) {
|
|
1151
|
+
const calleePath = path2.get("callee");
|
|
1055
1152
|
if (calleePath.isIdentifier() && this.isIgnoredCallIdentifier(calleePath.node.name)) {
|
|
1056
|
-
for (const arg of
|
|
1153
|
+
for (const arg of path2.get("arguments")) {
|
|
1057
1154
|
this.walkNode(arg);
|
|
1058
1155
|
}
|
|
1059
1156
|
}
|
|
1060
1157
|
}
|
|
1061
|
-
walkExportDeclaration(
|
|
1062
|
-
if (
|
|
1063
|
-
if (
|
|
1064
|
-
this.walkExportNamedDeclaration(
|
|
1065
|
-
} else if (
|
|
1066
|
-
this.walkExportDefaultDeclaration(
|
|
1067
|
-
} else if (
|
|
1068
|
-
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);
|
|
1069
1166
|
}
|
|
1070
1167
|
}
|
|
1071
1168
|
}
|
|
1072
|
-
walkExportNamedDeclaration(
|
|
1073
|
-
const declaration =
|
|
1169
|
+
walkExportNamedDeclaration(path2) {
|
|
1170
|
+
const declaration = path2.get("declaration");
|
|
1074
1171
|
if (declaration.isVariableDeclaration()) {
|
|
1075
1172
|
for (const decl of declaration.get("declarations")) {
|
|
1076
1173
|
this.walkNode(decl);
|
|
1077
1174
|
}
|
|
1078
1175
|
}
|
|
1079
|
-
const specifiers =
|
|
1176
|
+
const specifiers = path2.get("specifiers");
|
|
1080
1177
|
for (const spec of specifiers) {
|
|
1081
1178
|
if (spec.isExportSpecifier()) {
|
|
1082
1179
|
const local = spec.get("local");
|
|
@@ -1086,20 +1183,20 @@ var NodePathWalker = class {
|
|
|
1086
1183
|
}
|
|
1087
1184
|
}
|
|
1088
1185
|
}
|
|
1089
|
-
walkExportDefaultDeclaration(
|
|
1090
|
-
const decl =
|
|
1186
|
+
walkExportDefaultDeclaration(path2) {
|
|
1187
|
+
const decl = path2.get("declaration");
|
|
1091
1188
|
if (decl.isIdentifier()) {
|
|
1092
1189
|
this.walkNode(decl);
|
|
1093
1190
|
} else {
|
|
1094
1191
|
this.walkNode(decl);
|
|
1095
1192
|
}
|
|
1096
1193
|
}
|
|
1097
|
-
walkExportAllDeclaration(
|
|
1098
|
-
const source =
|
|
1194
|
+
walkExportAllDeclaration(path2) {
|
|
1195
|
+
const source = path2.get("source");
|
|
1099
1196
|
if (source.isStringLiteral()) {
|
|
1100
1197
|
this.imports.add(
|
|
1101
1198
|
{
|
|
1102
|
-
declaration:
|
|
1199
|
+
declaration: path2,
|
|
1103
1200
|
source: source.node.value,
|
|
1104
1201
|
type: "ExportAllDeclaration"
|
|
1105
1202
|
}
|
|
@@ -1109,8 +1206,8 @@ var NodePathWalker = class {
|
|
|
1109
1206
|
};
|
|
1110
1207
|
|
|
1111
1208
|
// src/js/sourceAnalysis.ts
|
|
1112
|
-
function createModuleSpecifierReplacementToken(
|
|
1113
|
-
const node =
|
|
1209
|
+
function createModuleSpecifierReplacementToken(path2, replacement) {
|
|
1210
|
+
const node = path2.node;
|
|
1114
1211
|
if (node.value === replacement) {
|
|
1115
1212
|
return void 0;
|
|
1116
1213
|
}
|
|
@@ -1126,17 +1223,17 @@ function createModuleSpecifierReplacementToken(path, replacement) {
|
|
|
1126
1223
|
start,
|
|
1127
1224
|
end,
|
|
1128
1225
|
value: replacement,
|
|
1129
|
-
path
|
|
1226
|
+
path: path2
|
|
1130
1227
|
};
|
|
1131
1228
|
}
|
|
1132
1229
|
function collectModuleSpecifierReplacementTokens(analysis, replacements) {
|
|
1133
1230
|
const tokens = [];
|
|
1134
|
-
const applyReplacement = (
|
|
1135
|
-
const replacement = replacements[
|
|
1231
|
+
const applyReplacement = (path2) => {
|
|
1232
|
+
const replacement = replacements[path2.node.value];
|
|
1136
1233
|
if (!replacement) {
|
|
1137
1234
|
return;
|
|
1138
1235
|
}
|
|
1139
|
-
const token = createModuleSpecifierReplacementToken(
|
|
1236
|
+
const token = createModuleSpecifierReplacementToken(path2, replacement);
|
|
1140
1237
|
if (token) {
|
|
1141
1238
|
tokens.push(token);
|
|
1142
1239
|
}
|
|
@@ -1188,12 +1285,12 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1188
1285
|
}
|
|
1189
1286
|
return false;
|
|
1190
1287
|
};
|
|
1191
|
-
const resolvesMemberExpressionToIgnore = (
|
|
1192
|
-
const propertyPath =
|
|
1288
|
+
const resolvesMemberExpressionToIgnore = (path2, seen) => {
|
|
1289
|
+
const propertyPath = path2.get("property");
|
|
1193
1290
|
if (propertyMatches(propertyPath)) {
|
|
1194
1291
|
return true;
|
|
1195
1292
|
}
|
|
1196
|
-
const objectPath =
|
|
1293
|
+
const objectPath = path2.get("object");
|
|
1197
1294
|
if (objectPath.isIdentifier()) {
|
|
1198
1295
|
const binding = objectPath.scope.getBinding(objectPath.node.name);
|
|
1199
1296
|
if (binding) {
|
|
@@ -1240,7 +1337,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1240
1337
|
const getEffectiveTagPath = (tagPath) => {
|
|
1241
1338
|
let current = tagPath;
|
|
1242
1339
|
while (true) {
|
|
1243
|
-
if (_optionalChain([current, 'access',
|
|
1340
|
+
if (_optionalChain([current, 'access', _28 => _28.isParenthesizedExpression, 'optionalCall', _29 => _29()]) || current.node.type === "ParenthesizedExpression") {
|
|
1244
1341
|
current = current.get("expression");
|
|
1245
1342
|
continue;
|
|
1246
1343
|
}
|
|
@@ -1252,7 +1349,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1252
1349
|
current = current.get("expression");
|
|
1253
1350
|
continue;
|
|
1254
1351
|
}
|
|
1255
|
-
if (_optionalChain([current, 'access',
|
|
1352
|
+
if (_optionalChain([current, 'access', _30 => _30.isTypeCastExpression, 'optionalCall', _31 => _31()])) {
|
|
1256
1353
|
current = current.get("expression");
|
|
1257
1354
|
continue;
|
|
1258
1355
|
}
|
|
@@ -1264,7 +1361,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1264
1361
|
continue;
|
|
1265
1362
|
}
|
|
1266
1363
|
}
|
|
1267
|
-
if (_optionalChain([current, 'access',
|
|
1364
|
+
if (_optionalChain([current, 'access', _32 => _32.isCallExpression, 'optionalCall', _33 => _33()]) || current.node.type === "CallExpression") {
|
|
1268
1365
|
const callee = current.get("callee");
|
|
1269
1366
|
current = callee;
|
|
1270
1367
|
continue;
|
|
@@ -1274,7 +1371,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1274
1371
|
return current;
|
|
1275
1372
|
};
|
|
1276
1373
|
const evaluateTagPath = (tagPath) => {
|
|
1277
|
-
if (_optionalChain([tagPath, 'access',
|
|
1374
|
+
if (_optionalChain([tagPath, 'access', _34 => _34.isCallExpression, 'optionalCall', _35 => _35()]) || tagPath.node.type === "CallExpression") {
|
|
1278
1375
|
const calleePath = tagPath.get("callee");
|
|
1279
1376
|
return evaluateTagPath(calleePath);
|
|
1280
1377
|
}
|
|
@@ -1348,9 +1445,9 @@ function analyzeSource(ast, options, handler) {
|
|
|
1348
1445
|
const walker = new NodePathWalker(
|
|
1349
1446
|
{
|
|
1350
1447
|
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
1351
|
-
callback(
|
|
1352
|
-
if (
|
|
1353
|
-
ignoredPaths.add(
|
|
1448
|
+
callback(path2) {
|
|
1449
|
+
if (path2.isStringLiteral() || path2.isTemplateElement()) {
|
|
1450
|
+
ignoredPaths.add(path2);
|
|
1354
1451
|
}
|
|
1355
1452
|
}
|
|
1356
1453
|
}
|
|
@@ -1403,7 +1500,7 @@ function analyzeSource(ast, options, handler) {
|
|
|
1403
1500
|
const args = p.get("arguments");
|
|
1404
1501
|
if (Array.isArray(args) && args.length > 0) {
|
|
1405
1502
|
const first = args[0];
|
|
1406
|
-
if (_optionalChain([first, 'optionalAccess',
|
|
1503
|
+
if (_optionalChain([first, 'optionalAccess', _36 => _36.isStringLiteral, 'call', _37 => _37()])) {
|
|
1407
1504
|
requireCallPaths.push(first);
|
|
1408
1505
|
}
|
|
1409
1506
|
}
|
|
@@ -1438,15 +1535,15 @@ function processUpdatedSource(rawSource, options, analysis) {
|
|
|
1438
1535
|
const ms = new (0, _magicstring2.default)(rawSource);
|
|
1439
1536
|
const { targetPaths, jsTokenUpdater, ignoredPaths } = analysis;
|
|
1440
1537
|
const replacementTokens = [];
|
|
1441
|
-
for (const
|
|
1442
|
-
if (ignoredPaths.has(
|
|
1538
|
+
for (const path2 of targetPaths) {
|
|
1539
|
+
if (ignoredPaths.has(path2)) {
|
|
1443
1540
|
continue;
|
|
1444
1541
|
}
|
|
1445
1542
|
const token = replaceHandleValue(
|
|
1446
|
-
|
|
1543
|
+
path2,
|
|
1447
1544
|
{
|
|
1448
1545
|
...options,
|
|
1449
|
-
needEscaped:
|
|
1546
|
+
needEscaped: path2.isStringLiteral() ? _nullishCoalesce(options.needEscaped, () => ( true)) : false
|
|
1450
1547
|
}
|
|
1451
1548
|
);
|
|
1452
1549
|
if (token) {
|
|
@@ -1628,21 +1725,21 @@ function createAttributeMatcher(entities) {
|
|
|
1628
1725
|
// src/wxml/whitespace.ts
|
|
1629
1726
|
var WHITESPACE_CODES = /* @__PURE__ */ new Set([
|
|
1630
1727
|
9,
|
|
1631
|
-
// \t
|
|
1728
|
+
// 制表符 \t
|
|
1632
1729
|
10,
|
|
1633
|
-
// \n
|
|
1730
|
+
// 换行符 \n
|
|
1634
1731
|
11,
|
|
1635
|
-
// \v
|
|
1732
|
+
// 垂直制表符 \v
|
|
1636
1733
|
12,
|
|
1637
|
-
// \f
|
|
1734
|
+
// 换页符 \f
|
|
1638
1735
|
13,
|
|
1639
|
-
// \r
|
|
1736
|
+
// 回车符 \r
|
|
1640
1737
|
32,
|
|
1641
|
-
//
|
|
1738
|
+
// 空格
|
|
1642
1739
|
160,
|
|
1643
|
-
// \u00A0
|
|
1740
|
+
// 不间断空格 \u00A0
|
|
1644
1741
|
65279
|
|
1645
|
-
// \uFEFF
|
|
1742
|
+
// 零宽无断行空格 \uFEFF
|
|
1646
1743
|
]);
|
|
1647
1744
|
function isWhitespace(char) {
|
|
1648
1745
|
if (char.length === 0) {
|
|
@@ -1793,16 +1890,16 @@ function generateCode(match, options = {}) {
|
|
|
1793
1890
|
const ast = _parser.parseExpression.call(void 0, match);
|
|
1794
1891
|
const jsTokenUpdater = new JsTokenUpdater();
|
|
1795
1892
|
traverse(ast, {
|
|
1796
|
-
StringLiteral(
|
|
1797
|
-
if (t.isMemberExpression(
|
|
1893
|
+
StringLiteral(path2) {
|
|
1894
|
+
if (t.isMemberExpression(path2.parent)) {
|
|
1798
1895
|
return;
|
|
1799
1896
|
}
|
|
1800
|
-
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])))) {
|
|
1801
1898
|
return;
|
|
1802
1899
|
}
|
|
1803
1900
|
jsTokenUpdater.addToken(
|
|
1804
1901
|
replaceHandleValue(
|
|
1805
|
-
|
|
1902
|
+
path2,
|
|
1806
1903
|
{
|
|
1807
1904
|
escapeMap: options.escapeMap,
|
|
1808
1905
|
classNameSet: options.runtimeSet,
|
|
@@ -1827,7 +1924,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1827
1924
|
if (token.start > previousEnd) {
|
|
1828
1925
|
const gap = ms.slice(previousEnd, token.start);
|
|
1829
1926
|
if (isAllWhitespace(gap)) {
|
|
1830
|
-
ms.update(previousEnd, token.start,
|
|
1927
|
+
ms.update(previousEnd, token.start, replaceWxml(gap, {
|
|
1831
1928
|
keepEOL: false,
|
|
1832
1929
|
escapeMap: options.escapeMap,
|
|
1833
1930
|
ignoreHead: true
|
|
@@ -1838,7 +1935,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1838
1935
|
if (token.expressions.length > 0) {
|
|
1839
1936
|
for (const exp of token.expressions) {
|
|
1840
1937
|
if (exp.start > token.start && p < exp.start) {
|
|
1841
|
-
ms.update(p, exp.start,
|
|
1938
|
+
ms.update(p, exp.start, replaceWxml(ms.slice(p, exp.start), {
|
|
1842
1939
|
keepEOL: true,
|
|
1843
1940
|
escapeMap: options.escapeMap,
|
|
1844
1941
|
// 首的str才会被转译
|
|
@@ -1851,14 +1948,14 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1851
1948
|
p = exp.end;
|
|
1852
1949
|
}
|
|
1853
1950
|
if (token.end > p) {
|
|
1854
|
-
ms.update(p, token.end,
|
|
1951
|
+
ms.update(p, token.end, replaceWxml(ms.slice(p, token.end), {
|
|
1855
1952
|
keepEOL: false,
|
|
1856
1953
|
escapeMap: options.escapeMap,
|
|
1857
1954
|
ignoreHead: true
|
|
1858
1955
|
}));
|
|
1859
1956
|
}
|
|
1860
1957
|
} else {
|
|
1861
|
-
ms.update(token.start, token.end,
|
|
1958
|
+
ms.update(token.start, token.end, replaceWxml(token.value, {
|
|
1862
1959
|
keepEOL: false,
|
|
1863
1960
|
escapeMap: options.escapeMap,
|
|
1864
1961
|
ignoreHead: false
|
|
@@ -1871,7 +1968,7 @@ function handleEachClassFragment(ms, tokens, options = {}) {
|
|
|
1871
1968
|
if (lastToken.end < ms.original.length) {
|
|
1872
1969
|
const gap = ms.slice(lastToken.end, ms.original.length);
|
|
1873
1970
|
if (isAllWhitespace(gap)) {
|
|
1874
|
-
ms.update(lastToken.end, ms.original.length,
|
|
1971
|
+
ms.update(lastToken.end, ms.original.length, replaceWxml(gap, {
|
|
1875
1972
|
keepEOL: false,
|
|
1876
1973
|
escapeMap: options.escapeMap,
|
|
1877
1974
|
ignoreHead: true
|
|
@@ -1910,7 +2007,7 @@ async function customTemplateHandler(rawSource, options) {
|
|
|
1910
2007
|
}
|
|
1911
2008
|
const lowerName = name.toLowerCase();
|
|
1912
2009
|
const shouldHandleDefault = !disabledDefaultTemplateHandler && (lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass");
|
|
1913
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall',
|
|
2010
|
+
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _42 => _42(tag, name)]), () => ( false));
|
|
1914
2011
|
if (!shouldHandleDefault && !shouldHandleCustom) {
|
|
1915
2012
|
return;
|
|
1916
2013
|
}
|
|
@@ -2101,42 +2198,56 @@ function ensureDefaultsIncluded(value) {
|
|
|
2101
2198
|
}
|
|
2102
2199
|
return value;
|
|
2103
2200
|
}
|
|
2104
|
-
async function clearTailwindcssPatcherCache(patcher) {
|
|
2201
|
+
async function clearTailwindcssPatcherCache(patcher, options) {
|
|
2105
2202
|
if (!patcher) {
|
|
2106
2203
|
return;
|
|
2107
2204
|
}
|
|
2108
|
-
const cacheOptions = _optionalChain([patcher, 'access',
|
|
2109
|
-
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) {
|
|
2110
2207
|
return;
|
|
2111
2208
|
}
|
|
2112
|
-
const
|
|
2113
|
-
|
|
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) {
|
|
2114
2221
|
return;
|
|
2115
2222
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
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);
|
|
2122
2232
|
}
|
|
2123
|
-
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
2124
2233
|
}
|
|
2125
2234
|
}
|
|
2126
2235
|
function getCompilerContext(opts) {
|
|
2127
2236
|
const ctx = _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
|
|
2128
2237
|
opts,
|
|
2129
|
-
|
|
2238
|
+
_chunkUSAH2CX5js.getDefaultOptions.call(void 0, ),
|
|
2130
2239
|
{}
|
|
2131
2240
|
);
|
|
2132
2241
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
2133
2242
|
applyLoggerLevel(ctx.logLevel);
|
|
2134
|
-
const twPatcher =
|
|
2135
|
-
|
|
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])) {
|
|
2136
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)))}`);
|
|
2137
2247
|
} else {
|
|
2138
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`);
|
|
2139
2249
|
}
|
|
2250
|
+
warnIfCliPatchTargetMismatch(ctx.tailwindcssBasedir, twPatcher);
|
|
2140
2251
|
let cssCalcOptions = _nullishCoalesce(ctx.cssCalc, () => ( twPatcher.majorVersion === 4));
|
|
2141
2252
|
if (twPatcher.majorVersion === 4 && cssCalcOptions) {
|
|
2142
2253
|
cssCalcOptions = ensureDefaultsIncluded(cssCalcOptions);
|
|
@@ -2155,11 +2266,11 @@ function getCompilerContext(opts) {
|
|
|
2155
2266
|
ctx.twPatcher = twPatcher;
|
|
2156
2267
|
const refreshTailwindcssPatcher = async (options) => {
|
|
2157
2268
|
const previousPatcher = ctx.twPatcher;
|
|
2158
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2269
|
+
if (_optionalChain([options, 'optionalAccess', _54 => _54.clearCache]) !== false) {
|
|
2159
2270
|
await clearTailwindcssPatcherCache(previousPatcher);
|
|
2160
2271
|
}
|
|
2161
2272
|
invalidateRuntimeClassSet(previousPatcher);
|
|
2162
|
-
const nextPatcher =
|
|
2273
|
+
const nextPatcher = _chunkVLM4KUZAjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
2163
2274
|
Object.assign(previousPatcher, nextPatcher);
|
|
2164
2275
|
ctx.twPatcher = previousPatcher;
|
|
2165
2276
|
return previousPatcher;
|
|
@@ -2184,4 +2295,8 @@ function getCompilerContext(opts) {
|
|
|
2184
2295
|
|
|
2185
2296
|
|
|
2186
2297
|
|
|
2187
|
-
|
|
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;
|